Skip to content

feat(methods): Sparkling Web method support + pluggable router host - #7

Merged
Huxpro merged 2 commits into
mainfrom
claude/sparkling-web-method-support
Jul 12, 2026
Merged

feat(methods): Sparkling Web method support + pluggable router host#7
Huxpro merged 2 commits into
mainfrom
claude/sparkling-web-method-support

Conversation

@Huxpro

@Huxpro Huxpro commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

The method-package layer for running Sparkling methods on web. This is the upstreamable half of the go-web web-preview work (#6) — it has no website/go-web code, so it can be reviewed on its own and its commits cherry-picked onto the upstream experimental PR tiktok/sparkling#22.

Two commits:

  1. feat(methods): add Sparkling Web method support — ports feat: introduce URL-first Sparkling Router #22's web layer: sparkling-method web registry (registerWebMethod/getWebMethodHandler/isWebEnvironment + LynxPipe.call dispatch) and the /web handlers for navigation/storage/media. (This mirrors feat: introduce URL-first Sparkling Router #22; upstream already has it.)
  2. fix(navigation): make the web router host pluggable — the actual fix. router.open/router.close no longer hardcode window.history (correct for a full-page host like sparkling-web-shell, wrong for embedders). A pluggable RouterWebHost (setRouterWebHost) lets an embedder scope navigation to its own card; the default host keeps the History-API behavior, so sparkling-web-shell is unchanged. This is the single-file commit to cherry-pick onto feat: introduce URL-first Sparkling Router #22.

Related issues

Completes/stacks on tiktok#22.

Changes

  • sparkling-method: web-registry.ts, WebMethodHandler, ./web-registry export, LynxPipe.call web dispatch.
  • sparkling-navigation / sparkling-storage / sparkling-media: /web handlers behind a ./web export; navigation gains a pluggable RouterWebHost.

How to test

pnpm --filter sparkling-method --filter sparkling-navigation --filter sparkling-storage --filter sparkling-media build

Behavioral verification lives in the consumer PR (#6), which drives these handlers end-to-end in a browser.

Checklist

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits July 12, 2026 22:01
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
@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

@Huxpro
Huxpro merged commit 9644d90 into main 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