feat(examples): download example as a standalone Vite project#8825
Merged
Conversation
3b72d72 to
877b901
Compare
Contributor
|
any way we can preserve the CC licenses for assets the example uses? |
Contributor
Author
Yep just done |
Adds a download icon to the code panel toolbar that exports the current example as a runnable, self-contained Vite project, zipped in-browser with fflate. The generated project includes the example source (config stripped, imports rewritten to a local examples/context shim), the current control values captured to data.json and replayed after the example loads, the referenced assets, and a package.json pinned to the latest published playcanvas + observer.
…project Replace the sidecar-.txt probing with the authoritative @credit attribution: the iframe already parses @credit (title/author/source/license) into the example snapshot, so surface it through the snapshot and write a dedicated CREDITS.md. This covers remote assets (e.g. gsplat scenes) that ship no local license file, and removes the per-asset 404 probing. Spine's folder license has redistribution terms requiring the file to travel with the assets, so co-locate it via an explicit COLOCATED_LICENSES entry; add a @credit block to the spineboy example.
9ac7c07 to
b6b7ca4
Compare
kpal81xd
added a commit
that referenced
this pull request
Jun 3, 2026
* feat(examples): download example as a standalone Vite project Adds a download icon to the code panel toolbar that exports the current example as a runnable, self-contained Vite project, zipped in-browser with fflate. The generated project includes the example source (config stripped, imports rewritten to a local examples/context shim), the current control values captured to data.json and replayed after the example loads, the referenced assets, and a package.json pinned to the latest published playcanvas + observer. * feat(examples): bundle CC license sidecars in the downloaded Vite project * feat(examples): export asset attribution as CREDITS.md in downloaded project Replace the sidecar-.txt probing with the authoritative @credit attribution: the iframe already parses @credit (title/author/source/license) into the example snapshot, so surface it through the snapshot and write a dedicated CREDITS.md. This covers remote assets (e.g. gsplat scenes) that ship no local license file, and removes the per-asset 404 probing. Spine's folder license has redistribution terms requiring the file to travel with the assets, so co-locate it via an explicit COLOCATED_LICENSES entry; add a @credit block to the spineboy example.
kpal81xd
added a commit
that referenced
this pull request
Jun 3, 2026
* feat(examples): download example as a standalone Vite project Adds a download icon to the code panel toolbar that exports the current example as a runnable, self-contained Vite project, zipped in-browser with fflate. The generated project includes the example source (config stripped, imports rewritten to a local examples/context shim), the current control values captured to data.json and replayed after the example loads, the referenced assets, and a package.json pinned to the latest published playcanvas + observer. * feat(examples): bundle CC license sidecars in the downloaded Vite project * feat(examples): export asset attribution as CREDITS.md in downloaded project Replace the sidecar-.txt probing with the authoritative @credit attribution: the iframe already parses @credit (title/author/source/license) into the example snapshot, so surface it through the snapshot and write a dedicated CREDITS.md. This covers remote assets (e.g. gsplat scenes) that ship no local license file, and removes the per-asset 404 probing. Spine's folder license has redistribution terms requiring the file to travel with the assets, so co-locate it via an explicit COLOCATED_LICENSES entry; add a @credit block to the spineboy example.
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.
Summary
Adds a Download button to the examples-browser code panel toolbar (next to the refresh/GitHub icons) that exports the currently-viewed example as a runnable, self-contained Vite project — generated entirely in-browser, no server or hosting changes.
The zip is produced client-side with
fflate(already bundled). It captures the live Monaco buffers, so any edits the user made in the code panel are included.Preview
What's in the generated project
examples/context→./context.mjs; non-publishedexamples/assets/scripts/**modules are vendored (and their imports recursed);playcanvas/playcanvas/scripts/**left as npm specifiers.src/data.jsonand replayed after the example initialises, mirroring the browser'sapplyControlState(so values that the example seeds itself aren't clobbered)../assets/&./scripts/URLs, fetched from the live/static/…, and shipped underpublic/so they resolve unchanged. Dynamic/remote URLs that can't be bundled are noted in the generated README.@creditblocks (title / author / source / license) are written to a dedicatedCREDITS.md, so asset attribution survives in the download. This covers remote / CDN assets (e.g. gaussian-splatting scenes) that ship no local license file. The credits come from the same parse the in-app credits overlay uses (surfaced via the example snapshot), so there's no guesswork or duplicate parsing. Folder-level license files whose terms require the file to travel with the assets (currently only spine) are co-located underpublic/alongside them.package.jsonpinsplaycanvas: "latest"+@playcanvas/observer; README notes the exact authoring version in case a newer release differs.Testing
misc-hello-world.zip; unzipped →npm i && npm run devrenders the example, with imports rewritten and the@configblock stripped.buildProjectZip:graphics/shadow-catcher→CREDITS.md(Poly Haven, CC BY 4.0), asset still bundled.gaussian-splatting/first-person(remote S3 splat, no local license) →CREDITS.md(Sunnyvale, CC BY 4.0).misc/spineboy→CREDITS.mdand co-locatedpublic/assets/spine/license.txt.CREDITS.mdand make no extra license fetches.