Skip to content

feat(router): prototype declarative multi-container routing - #20

Closed
Huxpro wants to merge 1 commit into
mainfrom
feat/sparkling-declarative-router
Closed

feat(router): prototype declarative multi-container routing#20
Huxpro wants to merge 1 commit into
mainfrom
feat/sparkling-declarative-router

Conversation

@Huxpro

@Huxpro Huxpro commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • add sparkling-history, a TanStack RouterHistory-compatible MPA history that keeps in-container navigation local and forwards cross-container navigation to sparkling-navigation
  • add sparkling-router, which owns the serializable multi-container manifest and resolves hard vs. soft navigation while continuing to use the official TanStack React binding
  • add sparkling-router-plugin, with TypeScript-AST-based scanners for both TanStack file routes and Next-style app directories, emitting the same neutral manifest schema
  • add a ReactLynx TanStack Router demo that combines the official route generator with generated per-container Rspeedy entries
  • document the prototype findings, tradeoffs, and the remaining native stack-protocol gate

Findings

  1. @tanstack/router-core contains the reusable routing machinery, but does not expose complete framework-neutral createRouter / createRoute factories. For ReactLynx, using the official @tanstack/react-router binding over a Sparkling history adapter is lower risk than maintaining another framework subclass layer.
  2. TanStack file routing is the most direct primary authoring path. The official generator continues to own typed routes; Sparkling only adds container partitioning and manifest/entry emission.
  3. A Next app-directory scanner can target the same manifest and runtime without changing the core. This proves the shared-core direction, but does not yet claim full Next runtime/API compatibility.

Validation

  • pnpm --filter sparkling-history build
  • pnpm --filter sparkling-router build
  • pnpm --filter sparkling-router-plugin build
  • pnpm --filter sparkling-history test — 29 tests
  • pnpm --filter sparkling-router test — 3 tests
  • pnpm --filter sparkling-router-plugin test — 3 tests
  • pnpm --filter tanstack-router-demo test — 16 tests
  • pnpm --filter tanstack-router-demo build — generated spike, home, detail, and settings Lynx bundles
  • git diff --check huxpro/main...HEAD

Out of scope

This prototype does not implement or freeze the native stack protocol. The next gate is an iOS implementation plus conformance tests for stack state/versioning, gesture-driven changes, reset/getState, syncOwnLocation, prefetch, and result delivery.

Add a TanStack-compatible MPA history, a neutral route manifest runtime, and file-route compilation for both TanStack and Next-style conventions. Include a ReactLynx demo, generated multi-entry bundles, tests, and prototype findings.

Co-authored-by: TRAE CLI <noreply@bytedance.com>
@cursor

cursor Bot commented Jul 25, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@vercel

vercel Bot commented Jul 25, 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 25, 2026 8:06pm

Request Review

Huxpro pushed a commit that referenced this pull request Jul 26, 2026
…oundary checks

Release-hardening pass (M0 + M2 of the release plan):

- Manifest schema v1: adds 'version' and 'scheme.base' (the JS<->native
  contract is now versioned, serializable data) and per-page
  'presentation: push | modal' — resolved through PageTarget and encoded
  into the sparkling scheme (native support pending; push fallback).
  Design points adopted from the PR #20 prototype, with credit.
- Per-page pruned route trees: each bundle now boots
  pages.gen/<id>/routeTree.ts — own routes with full options, foreign
  routes as path-only href stubs; the full routeTree.gen.ts stays the
  type-level source of truth. The runtime no longer imports default
  artifacts (a static default dragged every page's components into every
  bundle — bundles now differ per page, framework baseline is the
  remaining shared-chunk work).
- AST-based marker extraction (TypeScript API) replaces regex+eval:
  satisfies-wrapped literals supported, re-exports/dynamic values fail
  the build with precise errors.
- Directory boundaries via '-container.ts' (the '-' prefix is excluded
  by the official generator; '_container' would create a pathless layout
  route and corrupt the tree). In-file 'page' export overrides.
- Boundary containment check (subset rule R3, static approximation):
  an unmarked route under another page's declared prefix fails the build.
- Next-style frontend explicitly marked experimental (not v1 API).
- Tests: demo 22 -> 35 (pruned-trees, codegen-boundaries suites),
  history 39 -> 40 (presentation scheme encoding); all green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wEPNgmHbba2Bgkr1KcDYa

Huxpro commented Jul 26, 2026

Copy link
Copy Markdown
Owner Author

Closing this prototype in favor of the #1 + #19 stack, after adopting its three strongest design points there (commit 7ab4ac7 on #19, with credit):

  1. Manifest schema versioningversion + scheme.base are now part of manifest v1; the manifest is treated as the serializable JS↔native contract.
  2. presentation: 'push' | 'modal' — now flows manifest → resolver → sparkling scheme (native support pending, push fallback).
  3. AST-based marker extraction — regex+eval replaced with the TypeScript API, same direction as this PR's static-config.ts; satisfies supported, unreadable forms fail the build.

Directory-level boundaries were also adopted, with one correction: the boundary file is named -container.ts, not _container.tsx — the official TanStack generator treats _-prefixed files as pathless layout routes (which would corrupt routeTree.gen.ts), while --prefixed files are excluded from routing.

Not carried over: the sparkling-router re-export barrel (adds a package boundary without behavior), the plugin's entries output (maps container ids to route source files, which are not bootable entries), and the resolver's new URL() usage (no URL global in the native Lynx runtime — same class of bug #1's review caught). This branch also predates #1's review fixes (85d184d), so those regressions live on here.

Thanks — the schema and boundary ideas made v1 better.


Generated by Claude Code

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.

1 participant