Skip to content

feat(gallery): build the gallery per group and load one on demand - #2514

Open
Laotree wants to merge 10 commits into
nsgo-dev:mainfrom
Laotree:feature/gallery-per-group
Open

Laotree wants to merge 10 commits into
nsgo-dev:mainfrom
Laotree:feature/gallery-per-group

Conversation

@Laotree

@Laotree Laotree commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A first visit to /gallery/ fetched one 20.7 MiB gzipped web bundle that held every demo. It now fetches a shell and one group's app, 12.1 to 16.1 MiB.

  • examples/gallery registers each group's demos in a file of its own with a build tag, so a build named with gallery_group and gallery_<group> carries that group alone and the linker drops the rest. The default build registers every group, so nothing about the gallery's own build changes (119 tests pass).
  • website/scripts/build-gallery.mjs builds each group with its tags, writes each group's app.html from the loader, and writes the group list into the shell as the icon is written.
  • website/scripts/gallery-frame.html lists those groups and loads the selected one's app.html behind the platform chrome, with ?group= deep links. Switching groups replaces the frame; the platform choice works as before. The iframe's address is assembled from build-time and constant values only, which CodeQL's DOM-text check requires.
  • /gallery/app.html and /gallery/loader.html redirect to the shell, so old links keep working.

Measured locally, web, gzip -9:

Build wasm gzip
Before: one bundle 96.6 MB 20.7 MiB
apps 14.6 MiB
actions, feedback, styling 12.1 MiB
documents 16.1 MiB

The engine and the components every demo shares are about 12 MiB gzipped, so groups are the useful unit; going below that needs the gallery to link less of the framework, which is a separate change. Demo-level deep links (?demo=) need the gallery app to read such a parameter; this does not add it yet.

Part of #2512.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

The change is the gallery example and the website's gallery scripts.

Screenshots

None. The shell keeps its layout; a group select joins the platform control.

Verification

  • go tool nsgo check — exit 0.
  • go tool nsgo test ./examples/gallery — 119 passed, 0 failed, 23 skipped; tab, group and demo order unchanged.
  • bun scripts/build-gallery.mjs in website/ — 14 groups built in about 2m20s, each group directory has its app.html, <wasm>.gzip, nsgo.js and wasm_exec.js, and the shell holds the group list it writes.
  • Served public/gallery locally and checked: the shell names <group>/app.html from its built-in list; apps/app.html references its own app.wasm.gzip; /app.html redirects to the shell.
  • The shell's inline script passes node --check, and build-gallery.mjs and web-build.mjs parse with node --check.
  • bun run build in website/ — not run: node_modules is not installed on this machine, so Astro's check and build were not exercised. The website workflow builds the site.

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and a capability users can see has a line in a changelog.d/ fragment, not in CHANGELOG.md.
  • New third-party code, assets and dependencies name their source and license.

No changelog.d fragment: this changes the site's gallery, not the framework an app author uses.

🤖 Generated with Claude Code

Laotree and others added 5 commits November 26, 2026 19:18
Add driver.GPUEnabler and a table per backend for a GPU view's item,
resize, frame and release entry points, and connect the frame submitter
only when an app mounts a GPU view. Android's minimal app links neither
glsl nor the frame path now. On macOS, Linux, Windows and the web the
minimal app still links its writer: the pipeline types name writer types
(macOS, Linux), and the glass and effect paths compile a program without
a GPU view (Windows, web). The minimal-app link test fails on those four.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mirror the writers' pipeline types locally, so a struct kept by an
interface no longer names msl or glsl, and register Linux's GPU GL
callbacks when a GPU view mounts instead of at start. The minimal-app
link test now passes on macOS, Linux and Android; Windows and the web
still link their writer through the glass and backdrop effect paths,
which compile a program without a GPU view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Route a glass effect's program and a shader effect's backdrop picture
through the glass and shader tables, mirror the writers' register and
slot types locally so an interface-kept struct does not name them, and
enable the glass table from style resolution. The minimal-app link test
passes on every target now, and the feature app still links all three
writers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iOS refuses GPU views when the environment has no GPU, and its enabler
said nothing about it. The guard also keeps the macOS and iOS enablers
from being the same copy, which the duplicate backend check refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each group's demo list moves out of the tab assembly into a file of its
own with a build tag, and a build named with gallery_group and
gallery_<group> carries only that group: Go's linker drops the demos the
assembly no longer names. The default build registers every group, so
the gallery the site publishes is unchanged (119 tests pass), and a
single group's web wasm is 52.0 MB against the full build's 96.6 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build-gallery.mjs builds each group's web app with its tag and writes an
index.json the shell reads. The shell lists the groups and loads the
selected one's app.html on demand behind the platform chrome, with
?group= deep links; the old app.html and loader.html addresses redirect
to it. A first visit fetches one group, 12.1 to 16.1 MB gzipped, against
the 20.7 MB bundle it fetched before, and switching groups fetches only
that group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Laotree Laotree changed the title feat(gallery): register demos per group so a build can carry one feat(gallery): build the gallery per group and load one on demand Nov 26, 2026
A link naming no group, or one the build no longer has, opens the first
group; the address now says which one, so a shared link returns to what
the visitor saw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the size/L label Nov 26, 2026
Laotree and others added 3 commits November 26, 2026 22:25
The iframe's address carried the page's own query text, which the
DOM-XSS query flags at the src assignment. Every part now comes from a
constant list: the platforms, and the languages and appearances the app
takes as debugging flags, and the group the build's index names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shell read its groups from index.json, so the address the iframe
loads still traced back to the page. The build writes the list into the
shell now, as it writes the icon, and the theme is a constant index. Every
part of the iframe's address is then build-time or from a constant list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The radio and the group select handed their values straight to the
frame's state, so the address built from them traced back to the page.
Both now pass through their constant lists, and each part of the address
is URI-encoded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant