Expand description
#1883 (static assets), slice 1b: the project’s assets folder — the one
directory an asset name = "path" declaration may name a file in — and
the walk that reads it.
Assets are public by construction, so they come only from
<project root>/assets/ (decided on #1883 after the review of #1903): a
declaration can never publish .env or a .bynk source by mistake. The
checker states the rule (bynk.asset.outside_assets_dir); the driver and
the test harnesses list the folder as an AssetFolder, so bynk-emit
and bynk-check stay disk-free and read the bytes of only the files a
declaration names, and the LSP lists it with list_asset_files for the
existence check.
Structs§
- Asset
Folder - The project’s
assets/folder as the compiler sees it: the files in it, listed up front, and a reader the compiler calls for the bytes of only those a declaration names. A large file nothing declares is never read.
Constants§
- PROJECT_
ASSETS_ DIR - The project’s assets folder, relative to the project root.
- PROJECT_
EMBEDS_ DIR - The project’s embedded-text folder, relative to the project root (#2387).
Unlike
PROJECT_ASSETS_DIRnothing in it is served: anembedcompiles a file’s text into the code. It is listed and read as anAssetFolder(EmbedFolder).
Functions§
- is_
in_ assets_ dir - Whether the normalised
pathnames a file inside the assets folder —assets/<at least one more segment>. - is_
in_ embeds_ dir - Whether the normalised
pathnames a file inside the embeds folder —embeds/<at least one more segment>. - list_
asset_ files - Every regular file under
<project_root>/assets/, by its normalised project-relative path (assets/board.css), without reading any bytes. Symbolic links are not followed, so a link cannot pull a file in from outside the folder; a missing folder is an empty set. - list_
embed_ files list_asset_filesfor the project’sembeds/folder (#2387).- normalise_
asset_ path pathas the keylist_asset_filesfiles it under: separators made/, and empty and.segments dropped, so./assets//board.cssandassets\board.cssboth becomeassets/board.css. A..segment is kept (the checker rejects it separately,bynk.asset.unsafe_path).
Type Aliases§
- Asset
Reader - Reads one listed asset file’s bytes, given its normalised key.
- Embed
Folder - The project’s
embeds/folder as the compiler sees it: anAssetFolderoverembeds/instead ofassets/(#2387).