feat: generate referenced asset names in .riv schemas, type referencedAssets - #359
Open
mfazekas wants to merge 1 commit into
Open
feat: generate referenced asset names in .riv schemas, type referencedAssets#359mfazekas wants to merge 1 commit into
mfazekas wants to merge 1 commit into
Conversation
…dAssets Adds an assets record to generated schemas: unique asset identifier (the documented referencedAssets key form, e.g. 'Inter-594377') → 'image' | 'font' | 'audio'. Only non-embedded assets are listed — referenced and CDN-hosted ones are exactly what an app must supply out-of-band on the new runtime, which does not fetch CDN assets. useRiveFile (and RiveFileFactory.fromSource) then constrain referencedAssets for schema-typed inputs: keys must name an asset in the file, each entry's declared type must match the asset's actual kind, and RiveImage objects are only accepted for image assets. useRiveFile's typed/untyped overload pair is merged into one generic signature so an invalid key errors instead of silently falling through to the untyped number-input overload; unknown schemas and plain inputs degrade to the untyped ReferencedAssets as before. Extraction happens in the existing load() asset-loader callback (the only place the WASM exposes asset metadata). The out-of-band example now uses the typed asset import; every mistake class is pinned by tsd tests and the classifyAsset/emit paths by bun tests, with assets added to the emit fuzzer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #352 (git-town: main → feat/type-safe-riv-schema-2 → this). Implements the review feature request: generate asset names (images, fonts, audio) for out-of-band handling.
Generated schemas gain an
assetsrecord — unique asset identifier (the documentedreferencedAssetskey form, e.g.'Inter-594377') →'image' | 'font' | 'audio'. Only non-embedded assets are listed: referenced and CDN-hosted ones are exactly what an app must supply on the new runtime, which doesn't fetch CDN assets (embedded assets need nothing, so they're omitted). Extraction happens in the existing WASMload()asset-loader callback — the only place asset metadata is visible — so no extra pass.On the typing side,
useRiveFile(andRiveFileFactory.fromSource) constrainreferencedAssetsfor schema-typed inputs:typemust match the asset's actual kind (mislabeling a font asimageis a compile error — useful since the new runtime can't infer types and relies on this hint),RiveImageobjects are only accepted for image assets,useRiveFile's typed/untyped overload pair is merged into one generic signature so an invalid key is a hard error instead of silently falling through to the untyped number-input overload (the same fallthrough class fixed in #355 forviewModelName— caught here by sabotage-testing the example before writing the types). Unknown schemas and plain inputs degrade to the untypedReferencedAssetsexactly as before.The out-of-band example now uses the typed asset import as a live showcase;
out_of_band.riv.d.tsshows the emitted shape (3 referenced + 3 CDN assets). All 31 committed schemas regenerated. Coverage: tsd pins for every mistake class plus backward-compat, bun unit tests forclassifyAsset/emit, and the emit fuzzer extended with hostile asset names.Runtime behavior is unchanged (pure codegen + types); semantics target the new runtime per the request — legacy is out of scope.