feat(website): run Sparkling web methods (navigation) in the go-web preview - #6
Merged
Huxpro merged 3 commits intoJul 12, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Port the Web method layer from tiktok#22 so Sparkling methods can run in a browser (e.g. Lynx-on-web via @lynx-js/web-core), not just native. - sparkling-method: a `web-registry` (`registerWebMethod` / `getWebMethodHandler` / `isWebEnvironment`), a `WebMethodHandler` type, a `./web-registry` export, and a `LynxPipe.call` web-handler dispatch (a no-op on native, where the registry is empty). - sparkling-navigation / sparkling-storage / sparkling-media: `/web` handlers (router.open/close, storage get/set/remove, media choose/upload/download) behind a `./web` package export. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Si6NyRMutX8GJ5MuQ3BnfU
router.open/router.close drove the global window.history, which is correct for a full-page host (sparkling-web-shell owns the page) but wrong for embedders that render Lynx cards inside a larger page: router.open pollutes the top-level URL and router.close navigates the whole document away. Introduce a pluggable `RouterWebHost` (`setRouterWebHost`). The default host keeps the History-API behavior, so existing full-page hosts are unchanged; an embedder (e.g. the go-web `<Go>` preview) can override it to scope navigation to its own card. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Si6NyRMutX8GJ5MuQ3BnfU
Wire the Sparkling Web method support into the website's go-web `<lynx-view>`
preview so the playground demos run Sparkling methods live in the browser —
navigation actually swaps the previewed page.
- `sparkling-web-bridge.ts` (imported by the `<Go>` wrapper): registers the
`/web` handlers on the main thread and patches every `<lynx-view>` so its
worker's `NativeModules.spkPipe` RPC-bridges to those handlers (go-web exposes
no native-modules hook). It installs a per-preview `RouterWebHost` (via
`setRouterWebHost`) that swaps the calling card's bundle and keeps a
per-preview `{url, globalProps}` back stack, so navigation/close stay scoped to
the card and never touch window.history. Scheme params are delivered to the
opened page as `globalProps.queryItems` (matching native), so the
navigation-stack demo's `depth` increments correctly.
- website build: build the method packages before rspress so the `/web` subpath
imports resolve on a clean checkout.
- docs: note that navigation/storage/media now run in the Web preview.
Verified end-to-end in headless Chromium: nav-basic navigates to gp-container
and "Close Page" returns to nav-basic; the navigation-stack demo pushes to
depth 2/3; the top-level document URL never changes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Si6NyRMutX8GJ5MuQ3BnfU
Huxpro
force-pushed
the
claude/sparkling-web-navigation
branch
from
July 12, 2026 22:01
5489a03 to
c44fdf1
Compare
5 tasks
Huxpro
merged commit Jul 12, 2026
41614d4
into
claude/vue-lynx-go-web-examples-ec3vk7
2 checks passed
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
Wires Sparkling's experimental Web method support (tiktok/sparkling#22) into the website's go-web
<lynx-view>preview, so the Sparkling Go playground demos can run Sparkling methods live in the browser. Most visibly, navigation now works in the Web preview — tapping a demo's navigate button swaps the previewed page.Related issues
Consumes the web-support APIs from tiktok#22. Standalone otherwise.
Changes
sparkling-method— port the web dispatch layer:web-registry.ts(registerWebMethod/getWebMethodHandler/isWebEnvironment), aWebMethodHandlertype, a./web-registryexport, and aLynxPipe.callweb-handler interception (a no-op on native, where the registry stays empty).sparkling-navigation/sparkling-storage/sparkling-media— port the/webhandlers (router.open via History API +sparkling:navigateevent, storage vialocalStorage, media via file input /fetch) behind a./webpackage export.src/components/go/sparkling-web-bridge.ts, imported by the<Go>wrapper. go-web owns the<lynx-view>and exposes no native-modules hook, so the bridge:/webhandlers on the main thread, and<lynx-view>so its worker'sNativeModules.spkPipeRPC-bridges to those handlers (mirrorssparkling-web-shell), andsparkling:navigateevent fires.build:methods) so the/websubpath imports resolve on a clean checkout.How to test
Automated end-to-end check (headless Chromium against a production build): loads the navigation example, asserts
spkPipeis installed on the<lynx-view>, clicks "Navigate with Params", and asserts the preview URL swapsnav-basic.web.bundle→gp-container.web.bundle. ✅Checklist
CONTRIBUTING.md.DOCS_BASE=/ pnpm --filter sparkling-website build; headless-browser navigation test).🤖 Generated with Claude Code
Generated by Claude Code