feat(methods): Sparkling Web method support + pluggable router host - #7
Merged
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
5 tasks
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
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:
feat(methods): add Sparkling Web method support— ports feat: introduce URL-first Sparkling Router #22's web layer:sparkling-methodweb registry (registerWebMethod/getWebMethodHandler/isWebEnvironment+LynxPipe.calldispatch) and the/webhandlers for navigation/storage/media. (This mirrors feat: introduce URL-first Sparkling Router #22; upstream already has it.)fix(navigation): make the web router host pluggable— the actual fix.router.open/router.closeno longer hardcodewindow.history(correct for a full-page host likesparkling-web-shell, wrong for embedders). A pluggableRouterWebHost(setRouterWebHost) lets an embedder scope navigation to its own card; the default host keeps the History-API behavior, sosparkling-web-shellis 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-registryexport,LynxPipe.callweb dispatch.sparkling-navigation/sparkling-storage/sparkling-media:/webhandlers behind a./webexport; navigation gains a pluggableRouterWebHost.How to test
Behavioral verification lives in the consumer PR (#6), which drives these handlers end-to-end in a browser.
Checklist
CONTRIBUTING.md.tscbuild).🤖 Generated with Claude Code
Generated by Claude Code