Assets API¶
Public helpers for asset URL resolution, manifests, and layout preloading.
See Asset Collection for conceptual documentation and Renderer for AssetMode and RenderSession.
AssetManifest¶
Resolved public URLs for assets collected during a render session. Built by asset_manifest() or RenderSession.manifest().
DEFAULT_RUNTIME_URL¶
Default public URL for the pyjinhx client runtime in AssetMode.REFERENCE. Override process-wide with Renderer.set_default_runtime_url().
runtime_asset_path¶
Return the absolute filesystem path to the bundled pjx.js client runtime. Mount this directory as static files in production.
from fastapi.staticfiles import StaticFiles
from pyjinhx.assets import runtime_asset_path
import os
app.mount(
"/static/pyjinhx",
StaticFiles(directory=os.path.dirname(runtime_asset_path())),
name="pyjinhx",
)
default_asset_url¶
Map an absolute asset path to a default public URL under /static/components/. The runtime path maps to DEFAULT_RUNTIME_URL.
make_default_asset_url_resolver¶
Build a callable resolver using default_asset_url(). Pass to Renderer.set_asset_url_resolver() or asset_manifest().
from pyjinhx import Renderer
from pyjinhx.assets import make_default_asset_url_resolver
Renderer.set_asset_url_resolver(make_default_asset_url_resolver("./components"))
hashed_filename¶
Return a content-hash filename such as button.a1b2c3d4.js. Reads the file to compute a SHA-256 digest.
resolver_with_hash¶
Build an asset URL resolver that embeds a content hash in each filename. The runtime file is placed under {base_url}/pyjinhx/{hashed}.
from pyjinhx import Renderer
from pyjinhx.assets import resolver_with_hash
Renderer.set_asset_url_resolver(resolver_with_hash("/static/components", root="./components"))
asset_manifest¶
Build an AssetManifest from a RenderSession and a URL resolver. Equivalent to session.manifest(resolver=resolver).
Finder.layout_asset_tags¶
Instance method on Finder. Emit <link> and <script src> tags for every component asset discovered under the finder's root. Use in layout shells to preload all component assets instead of per-page discovery.