Assets and .ferret packages
Skill ferret-packages · download all skills · SKILL.md
When to use#
Packing a game's levels, loading content from a URL or a file, signing or encrypting it, caching downloads, or reasoning about the security of loaded content.
What exists#
FerretPackage,packPackage,PackageManifest,validatePackageManifest,validatePackage: the format and its own checks.- Signing and keys:
generateSigningKey,signManifest,verifyManifestSignature,generateEncryptionKey,createEncryption. - Sources:
urlSource,httpFolderSource,folderSource,bytesSource,blobSource. - Catalogs and streaming:
buildCatalog,signCatalog,loadCatalog,CatalogClient(inlevels), travel with a transition. - Cache:
PersistentCachewith backends (IndexedDB, storage, memory), LRU by package, pins, quota, partials,downloadedContentItemfor a menu entry. CodePolicy: a package that carries code runs under it.- The asset library (
docs/concepts/asset-library.md): textures, PBR materials, characters, clip sets, models and sounds as.ferretpackages of kindassets, and ready-made code (moduleitems: packages of kindlibrary,mod-<id>) found by id in a catalog (the server's:ferret.partners.solutions/ferret/library/catalog.json, orFERRET_ASSETS). Take from it instead of copying files out of another project:AssetLibrary(inlevels) withlist,material(id, { variant }),texture(id),character(id, { tier }),model(id),module(id)(runs the code once under the code policy and returns its exports;code: { origin, trusted, engine }in the options),preload; the viewer's?libraryshows every item. Items are built bytools/asset-lib/make.mjs(UE exports;ferretModelsandmodulesofids.jsonfor what is made in Ferret), never by hand. - Running code:
code.entryinferret.json(one bundled ES module undercode/exportinginstall(ctx)),installCode/CodeLoader.require(id)(dependencies first, policy, sha256 of the module,installonce; the engine comes asctx.ferret, the sharedglobalThis.Ferret), commandspkg.requireandpkg.loaded. - Dependencies the player fetches:
dependenciesnames packages by id and range,catalogs(catalog.json URLs, absolute or relative to the package's own URL) says where to look;<ferret-player catalogs=".." base="..">/playPackage({ catalogs, base })add the page's.DependencyResolver(@ferret/levels) opens each from the first catalog with a version in range, then theirs from theircatalogs, before the code and the first level run. Their code runs unsigned only from the page's origin. A miss is aDependencyErrornaming every catalog tried. - Models in the
.fmdlformat: the skillferret-models.
Steps to publish#
- Pack the level folder with
packPackage(see API reference for options). - Sign with a developer key; the owner of the keys signs and encrypts, an agent only prepares unsigned drafts.
- Build and sign a catalog if levels are fetched remotely.
- Load with
installPackages; the loader checks signatures, hashes and paths before anything is used.
Check afterwards#
validatePackage is clean; a tampered file is refused; a second load is served from the cache; quota errors are handled (QuotaError).
What usually goes wrong#
- Putting private keys in the repo or in a draft; keys are the developer's.
- Paths with
..or absolute paths in the manifest: refused by the loader by design. - A package with code and no
CodePolicydecision. - Assuming the cache is unlimited: it evicts by package and has a quota.
Files#
reference/levels.md— The level manifest, the level registry and travel, environment, and the .ferret package format.reference/api-assets.md— every export of@ferret/assetswith signature and doc commentreference/api-assets-2.md— every export of@ferret/assetswith signature and doc commentreference/api-assets-3.md— every export of@ferret/assetswith signature and doc commentreference/api-levels.md— every export of@ferret/levelswith signature and doc commentreference/api-levels-2.md— every export of@ferret/levelswith signature and doc commentreference/api-levels-3.md— every export of@ferret/levelswith signature and doc commentreference/api-levels-4.md— every export of@ferret/levelswith signature and doc commentreference/api-levels-5.md— every export of@ferret/levelswith signature and doc commentreference/commands.md— 64 commands of these packages with their arguments