feat(sparkling-history): reusable web-history shim for native MPA navigation - #14
Open
Huxpro wants to merge 1 commit into
Open
feat(sparkling-history): reusable web-history shim for native MPA navigation#14Huxpro wants to merge 1 commit into
Huxpro wants to merge 1 commit into
Conversation
…igation A router-agnostic navigation shim that lets any web-history-driven router drive Sparkling's native multi-page navigation. It has no dependency on any specific router — @tanstack/react-router appears only as a test devDependency to prove the contract against a real router. - NavigationHost contract (types.ts): the minimal open/close/stack-depth surface a native container must provide. - createMpaHistory: an in-memory entry stack for in-page routes plus page- boundary semantics — cross-page hrefs forward to host.open, back below the local root forwards to host.close. Mirrors @tanstack/history's memory history for the in-page subset, with blockers evaluated in any JS environment. - createSparklingHost: binds the contract to sparkling-navigation — builds the hybrid:// scheme (bundle + __mpa_href/depth/state transport) and reconstructs a destination page's initial location from its launch queryItems. The native container's own push/pop transition is opted in via the `animated` flag. - createMemoryHost: a recording test double. - resolve-page / parse-href helpers. - Unit tests (in-page, mpa, sparkling-host) covering the in-page subset and the cross-page/native behaviors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H1EU55YA4e1zj2oVHh7Zme
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Stacked PR 1/5. Introduces
sparkling-history— a router-agnostic navigation shim that lets any web-history-driven router drive Sparkling's native multi-page (MPA) navigation. This is the reusable foundation; the TanStack Router port sits on top of it in later PRs.It has no runtime dependency on any specific router —
@tanstack/react-routerappears only as a test devDependency, to prove the contract against a real router.📚 Stack (review bottom → top)
tsr-01-sparkling-history— router-agnostic web-history shim (this PR)tsr-02-reactlynx-spike— prove TanStack Router runs on ReactLynxtsr-03-mpa-codegen— file-based routing + native MPA + codegentsr-04-website-goweb— go-web example + in-card web bridgetsr-05-docs-guide— design guide + support matrix + RN comparisonRelated issues
Standalone (part of the TanStack-Router-on-Sparkling effort). Supersedes the combined branch in #1.
Changes
NavigationHostcontract (types.ts): the minimal open/close/stack-depth surface a native container must provide.createMpaHistory: an in-memory entry stack for in-page routes plus page-boundary semantics — cross-page hrefs forward tohost.open,backbelow the local root forwards tohost.close. Mirrors@tanstack/history's memory history for the in-page subset; blockers run in any JS environment (nodocumentgate).createSparklingHost: binds the contract tosparkling-navigation— builds thehybrid://scheme (bundle +__mpa_href/depth/statetransport) and reconstructs a destination page's initial location from its launchqueryItems. The native container's own push/pop transition is opted in via theanimatedflag.createMemoryHost: a recording test double.resolve-page/parse-hrefhelpers.How to test
Checklist
pnpm --filter sparkling-history test→ 29 passing)🤖 Generated with Claude Code
https://claude.ai/code/session_01H1EU55YA4e1zj2oVHh7Zme
Generated by Claude Code