Skip to content

feat(website): run Sparkling web methods (navigation) in the go-web preview - #6

Merged
Huxpro merged 3 commits into
claude/vue-lynx-go-web-examples-ec3vk7from
claude/sparkling-web-navigation
Jul 12, 2026
Merged

feat(website): run Sparkling web methods (navigation) in the go-web preview#6
Huxpro merged 3 commits into
claude/vue-lynx-go-web-examples-ec3vk7from
claude/sparkling-web-navigation

Conversation

@Huxpro

@Huxpro Huxpro commented Jul 12, 2026

Copy link
Copy Markdown
Owner

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.

Stacked on #5 (base branch claude/vue-lynx-go-web-examples-ec3vk7), which adds the go-web examples + playground web build this depends on. The diff here is only the web-method-support layer.

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), a WebMethodHandler type, a ./web-registry export, and a LynxPipe.call web-handler interception (a no-op on native, where the registry stays empty).
  • sparkling-navigation / sparkling-storage / sparkling-media — port the /web handlers (router.open via History API + sparkling:navigate event, storage via localStorage, media via file input / fetch) behind a ./web package export.
  • website — new 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:
    • registers the /web handlers on the main thread, and
    • patches every <lynx-view> so its worker's NativeModules.spkPipe RPC-bridges to those handlers (mirrors sparkling-web-shell), and
    • swaps the active preview's bundle when a sparkling:navigate event fires.
  • website build — build the method packages before rspress (build:methods) so the /web subpath imports resolve on a clean checkout.
  • docs — note that navigation/storage/media now run in the Web preview.

How to test

pnpm --filter sparkling-website dev
# open /guide/examples/navigation, in the nav-basic Web preview tap
# "Navigate with Params" — the preview swaps to the gp-container page.

Automated end-to-end check (headless Chromium against a production build): loads the navigation example, asserts spkPipe is installed on the <lynx-view>, clicks "Navigate with Params", and asserts the preview URL swaps nav-basic.web.bundlegp-container.web.bundle. ✅

Checklist

  • I read CONTRIBUTING.md.
  • I linked a related issue (or explained why this is standalone).
  • I ran relevant checks (clean DOCS_BASE=/ pnpm --filter sparkling-website build; headless-browser navigation test).
  • I updated docs/examples (if needed).
  • I added/updated tests (if applicable), or explained why not — verified with a headless-browser script; no unit test harness for the web preview yet.

🤖 Generated with Claude Code


Generated by Claude Code

@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sparkling Ready Ready Preview, Comment Jul 12, 2026 10:02pm

claude added 3 commits July 12, 2026 22:00
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
Huxpro force-pushed the claude/sparkling-web-navigation branch from 5489a03 to c44fdf1 Compare July 12, 2026 22:01
@Huxpro
Huxpro merged commit 41614d4 into claude/vue-lynx-go-web-examples-ec3vk7 Jul 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants