@shapeshift-labs/frontier-route
v0.1.0
Published
DOM-neutral logical route, scene, and location graph primitives for Frontier apps and games.
Maintainers
Readme
@shapeshift-labs/frontier-route
DOM-neutral route, scene, and location graph primitives for Frontier apps and games. The package treats app routes, game scenes, rooms, panels, overlays, and other navigable resources as first-class registry entries so DOM renderers, Playwright harnesses, migrations, cache loaders, effects, telemetry, and replay tooling can all talk about the same touched resource ids.
- npm:
@shapeshift-labs/frontier-route - source:
siliconjungle/-shapeshift-labs-frontier-route - license: MIT
API Shape
import {
createRouteManifest,
createRouteRegistryGraph,
createRouteSession,
explainRoute,
matchRoute,
planRouteTransition,
queryRouteManifest,
resolveRoute,
traceRouteImpact
} from '@shapeshift-labs/frontier-route';
const manifest = createRouteManifest({
routes: [
{
id: 'app',
pattern: 'route:/',
exact: false,
reads: ['app.boot']
},
{
id: 'todo.detail',
parentId: 'app',
pattern: 'route:/todos/:id',
feature: 'todos',
reads: [['entities', 'todo']],
writes: ['ui.selection'],
loads: [{ id: 'todo.loader', resource: 'query:todo/:id' }],
guards: ['auth.required'],
emits: ['route.enter.todo'],
source: { file: 'src/routes/todo.ts', symbol: 'TodoRoute' }
},
{
id: 'scene.overworld',
kind: 'scene',
pattern: 'scene:overworld/:zone?',
reads: ['save.current'],
writes: ['game.scene'],
loads: ['asset:overworld']
}
],
transitions: [
{
from: 'app',
to: 'todo.detail',
kind: 'push',
reads: ['auth.user'],
guards: ['auth.required']
}
]
});
const resolved = resolveRoute(manifest, 'todo.detail', { id: '123' });
const match = matchRoute(manifest, resolved.resource);
const plan = planRouteTransition(manifest, 'app', { id: 'todo.detail', params: { id: '123' } });
const session = createRouteSession(manifest, { initial: 'app' });
session.navigate({ id: 'todo.detail', params: { id: '123' } }, 'push');
const graph = createRouteRegistryGraph(manifest, {
package: '@app/todos',
feature: 'todos'
});
const byFeature = queryRouteManifest(manifest, { features: ['todos'] });
const impact = traceRouteImpact(manifest, { resources: ['route:/todos/123'] });
const explanation = explainRoute(manifest, 'todo.detail');
void match;
void plan;
void graph;
void byFeature;
void impact;
void explanation;Design Notes
frontier-route deliberately does not own rendering, history APIs, React hooks, DOM events, browser storage, scene graph transforms, game replication, or Playwright. It owns stable logical navigation ids and the dependency metadata around them.
- Resource ids use a scheme form such as
route:/todos/:id,scene:overworld/:zone?,room:/dungeon/:roomId/boss,modal:settings, orpanel:inventory. - Matching supports static segments,
:param,:param?,*splat,*splat?, Next.js-style[param],[...splat], and[[...splat]]. - Specificity ranking prefers static segments, then dynamic params, then optional params, then splats, with route rank/order as deterministic tie-breakers.
- Manifests build lazy internal indexes for route ids, compiled route patterns, leading static prefixes, parent chains, children, resources, and transition targets while keeping the serialized manifest plain JSON-like data.
- Parent ids model app route layouts, game scene stacks, room hierarchies, modal ownership, or any other logical containment.
- Transition plans report shared, leaving, and entering route chains plus declared reads, writes, loaders, guards, and emitted events.
- Route queries find entries by route id, concrete or symbolic resource, kind, package, feature, owner, tag, source file, state path, loader, guard, and emitted event. Filters are union-style so a harness can ask "anything touching this feature or this file or this state path" in one pass.
- Route impact tracing expands query seeds through ancestors, descendants, and transition edges to produce the complete route ids, scene ids, resources, reads, writes, loaders, guards, emits, files, packages, features, and tags a migration, replay, telemetry span, or AI feature task should inspect.
- Route explanations produce a compact per-route view with the symbolic target resource, chain, optional descendants, related transitions, and dependency/source metadata without requiring concrete params.
- Route sessions provide a small serializable runtime for active app routes, game scenes, overlays, pause/resume, sleep/wake, stop/start, stack history, and replay snapshots.
- Registry graph output turns every route and transition into Frontier registry entries with
touches,declares-read,declares-write,handles,produces,emits,declared-in, package, feature, owner, and tag edges. - Pattern resources stay symbolic for manifests and registry output, while resolved concrete resources URL-encode parameter values.
App And Game Use
App routing and game routing use the same model because both are logical navigation through named resources.
- Apps can represent pages, nested layouts, loaders/actions, modals, tabs, panels, route-state reads, cache keys, and DOM hydration roots.
- Games can represent active scenes, rooms, levels, zones, overlays, pause menus, transition gates, asset loads, save-state reads, scene writes, and replication-visible resources.
- Test and AI harnesses can query
route:/todos/:idorscene:overworld/:zone?as touched resources without importing a DOM renderer or a game engine. - Migrations can tag route or scene entries so schema changes can find the route-state/cache/effect/test surfaces that need review.
- Telemetry can attach route transition plans to structured logs without the logging package depending on this package directly.
Related Packages
The published Frontier package family is generated from one shared package catalog so READMEs stay in sync across packages:
@shapeshift-labs/frontier: Core JSON diff/apply, compact patch tuples, JSON Pointer, equality, clone, validation, Unicode helpers, and tiny dependency-free runtime budget/scheduler primitives.@shapeshift-labs/frontier-query: Shared query-key, selector path, condition, entity identity, and table-shape primitives.@shapeshift-labs/frontier-codec: Patch serialization, binary frames, canonical JSON, and patch-history codecs.@shapeshift-labs/frontier-engine: Stateful planned diff engine, adaptive profiles, schema plans, and engine-level history helpers.@shapeshift-labs/frontier-state: Patch-routed app-state subscriptions, owned commits, maintained views, and path mapping.@shapeshift-labs/frontier-state-cache: Normalized query-result cache with entity/query watchers, persistence, change logs, optimistic layers, scheduled persistence, and mutation bridge.@shapeshift-labs/frontier-state-cache-idb: IndexedDB persistence adapter for Frontier state-cache snapshots and durable change logs.@shapeshift-labs/frontier-state-cache-file: Structured file persistence adapter for Frontier state-cache snapshots and change logs.@shapeshift-labs/frontier-state-cache-sql: SQL persistence adapter for Frontier state-cache snapshots and change logs.@shapeshift-labs/frontier-schema: JSON Schema validation, Frontier profile generation, CloudEvent envelopes, and query/table schema helpers.@shapeshift-labs/frontier-migrations: Boundary-first data migrations, import normalization, plugin/API version mapping, versioned envelopes, dry-run reports, and current-shape rehydration.@shapeshift-labs/frontier-event-log: Bounded event logs, replay cursors, consumer acknowledgements, keyed compaction, checkpoints, and Frontier patch event records.@shapeshift-labs/frontier-inspect: Cross-package inspection/evidence bundles, registry graph snapshots, feature/resource impact reports, timeline/event normalization, redaction, JSONL import/export, and AI-readable app feature maps.@shapeshift-labs/frontier-scheduler: Deterministic work scheduling, lanes, cancellation, backpressure, frame policies, replay snapshots, and work graphs.@shapeshift-labs/frontier-logging: Opt-in structured logging, browser telemetry, scheduled sinks, file sinks, exporters, benchmark traces, and Frontier patch/update summaries.@shapeshift-labs/frontier-mutation: Explicit mutation and selector plans compiled to Frontier patches or CRDT operations.@shapeshift-labs/frontier-virtual: DOM-neutral virtualization, layout providers, range materialization, grids, spatial/frustum indexes, patch invalidation, camera anchors, and serializable layout state.@shapeshift-labs/frontier-scene: Patch-native 2D/3D scene graph, transform propagation, bounds queries, virtual/culling adapters, spatial invalidation, and camera/frustum materialization.@shapeshift-labs/frontier-pathfinding: Patch-native grid pathfinding, typed-array A*/Dijkstra search, flow fields, connected components, line-of-sight smoothing, dirty-cell invalidation, and scheduler-friendly path jobs.@shapeshift-labs/frontier-lod: Patch-native level-of-detail and significance selection for rendering and computation workloads, compact typed hot paths, multi-observer selection, budget degradation, materialization frames, and scheduler work plans.@shapeshift-labs/frontier-dom: Patch-native DOM and host renderer bindings, manifest hydration, JSX runtime/compiler helpers, SSR, devtools, and logging bridges.@shapeshift-labs/frontier-playwright: Playwright/headless automation probes for Frontier state, DOM, devtools, marks, and timeline queries.@shapeshift-labs/frontier-crdt: Native CRDT documents, update tooling, awareness, branches, conflict introspection, version frames, and undo.@shapeshift-labs/frontier-crdt-sync: CRDT sync endpoints, repo/storage/provider contracts, scheduled sync work, document URLs, local networks, model checking, forensics, and text binding contracts.@shapeshift-labs/frontier-crdt-websocket: WebSocket client/server transports for Frontier CRDT sync providers.@shapeshift-labs/frontier-react: React external-store hooks and adapters for Frontier state, cache, and CRDT surfaces.@shapeshift-labs/frontier-richtext: Rich text Delta normalization/application, marks, embeds, ranges, and cursor/selection transforms for local editor integrations.@shapeshift-labs/frontier-realtime: Shared realtime command, tick, snapshot, prediction, reconciliation, interpolation, rollback, message, and delta primitives.@shapeshift-labs/frontier-realtime-server: Authoritative realtime room, tick, command validation, rate-limit, session, and snapshot-history runtime.@shapeshift-labs/frontier-realtime-websocket: WebSocket client, wire, and Node room-server transport for Frontier realtime.@shapeshift-labs/frontier-game: Game-facing entity, component, player, room, ownership, spatial interest, rollback, physics, and replication helpers above realtime.
Package source repositories:
siliconjungle/-shapeshift-labs-frontiersiliconjungle/-shapeshift-labs-frontier-querysiliconjungle/-shapeshift-labs-frontier-codecsiliconjungle/-shapeshift-labs-frontier-enginesiliconjungle/-shapeshift-labs-frontier-statesiliconjungle/-shapeshift-labs-frontier-state-cachesiliconjungle/-shapeshift-labs-frontier-state-cache-idbsiliconjungle/-shapeshift-labs-frontier-state-cache-filesiliconjungle/-shapeshift-labs-frontier-state-cache-sqlsiliconjungle/-shapeshift-labs-frontier-schemasiliconjungle/-shapeshift-labs-frontier-migrationssiliconjungle/-shapeshift-labs-frontier-event-logsiliconjungle/-shapeshift-labs-frontier-inspectsiliconjungle/-shapeshift-labs-frontier-schedulersiliconjungle/-shapeshift-labs-frontier-loggingsiliconjungle/-shapeshift-labs-frontier-mutationsiliconjungle/-shapeshift-labs-frontier-virtualsiliconjungle/-shapeshift-labs-frontier-scenesiliconjungle/-shapeshift-labs-frontier-pathfindingsiliconjungle/-shapeshift-labs-frontier-lodsiliconjungle/-shapeshift-labs-frontier-routesiliconjungle/-shapeshift-labs-frontier-domsiliconjungle/-shapeshift-labs-frontier-playwrightsiliconjungle/-shapeshift-labs-frontier-crdtsiliconjungle/-shapeshift-labs-frontier-crdt-syncsiliconjungle/-shapeshift-labs-frontier-crdt-websocketsiliconjungle/-shapeshift-labs-frontier-reactsiliconjungle/-shapeshift-labs-frontier-richtextsiliconjungle/-shapeshift-labs-frontier-realtimesiliconjungle/-shapeshift-labs-frontier-realtime-serversiliconjungle/-shapeshift-labs-frontier-realtime-websocketsiliconjungle/-shapeshift-labs-frontier-game
Install
npm install @shapeshift-labs/frontier-routeBenchmarks
These are Frontier-only package measurements, not competitor comparisons.
Run package-local measurements:
npm run benchThe benchmark covers manifest creation, dynamic matching, catchall matching, scene optional-param matching, route resolution, transition planning, route query, impact tracing, route explanation, session navigation, and registry graph generation.
Latest local package benchmark on Node v26.1.0, darwin arm64, 2k routes and 50 rounds:
| Fixture | Median | p95 |
| --- | ---: | ---: |
| create-manifest-2000 | 3.65 ms | 6.07 ms |
| match-dynamic-2000 | 1.61 us | 3.30 us |
| match-catchall-2000 | 1.56 us | 2.74 us |
| match-scene-optional-2000 | 0.77 us | 1.36 us |
| resolve-dynamic-2000 | 0.61 us | 0.90 us |
| plan-transition-2000 | 1.77 us | 4.05 us |
| query-resource-2000 | 91.62 us | 139.51 us |
| impact-route-2000 | 787.62 us | 880.14 us |
| explain-route-2000 | 175.19 us | 184.49 us |
| session-replace-2000 | 1.29 us | 1.65 us |
| registry-graph-2000 | 5.85 ms | 9.48 ms |
