Skip to content

Route gate - #158

Closed
NickTheFreak97 wants to merge 28 commits into
vapor:mainfrom
NickTheFreak97:route-gate
Closed

NickTheFreak97 wants to merge 28 commits into
vapor:mainfrom
NickTheFreak97:route-gate

Conversation

@NickTheFreak97

Copy link
Copy Markdown

No description provided.

Niccolò Della Rocca and others added 28 commits December 3, 2023 14:20
… and NavigationView

New ZNavigation target (product ZTronNavigationKit), Apple-only: ZRoute, ZNavigator with a NavigationStack and a
NavigationView backend of identical observable behaviour, ZNavigationStack and ZNavigationScope containers,
ZRouteLink, ZRouteDestinationView, resolvers over a TrieRouter, ZRouteModels, ZNavigationHub and ZPageViewReporter.
Model tests run with swift test; the hosted parity suite and a plain NavigationStack baseline run on an iOS
simulator. The design article with the ZombieTron migration plan is in Sources/ZNavigation/Docs.docc.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Constants are still tried first at every node; when the rest of the path cannot be matched below the constant, the
search falls back to the parameter branch, so a constant never shadows a parameter route. Catch-alls keep the lowest
precedence. Parameters captured on a failed branch are restored and a path that matches nothing leaves the bag
untouched; the matching path allocates nothing it did not allocate before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Ours wins on conflicts and the fork stays a drop-in replacement for upstream. Kept: the mutable routing-kit 4 API
(TrieRouter.init(options:), register(_:at:)), the traversal helpers, the macOS 10.15 / iOS 13 platforms and the
Swift 5 language mode, without upstream's Swift 6.2-only settings or its swift-algorithms dependency. Added on top,
from routing-kit 5: RouterBuilder, TrieRouterBuilder with value semantics, TrieRouter.Configuration, partial
parameters, a root catch-all matching the empty path, and the string utilities. Output is not required to be
Sendable; TrieRouter and TrieRouterBuilder are Sendable when it is. The upstream product name RoutingKit is exported
next to ZTronRoutingKit, and the Benchmarks manifest references the parent package by its identity. Upstream's
swift-testing suite runs against the fork unchanged; the fork's own tests move to TrieRouterExtensionTests.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A chain of constants with no wildcard, partial or catch-all beside it needs no decision, so the matcher follows it in a
loop and recurses only where backtracking could ever be needed. Same results, less overhead on the common case of a
route made of constants.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A DocC article with the nine app-side steps and the code each one needs: resolving the ZTronNavigationKit product,
the database model resolver, the compatibility breadcrumb, the app's resolver, installing ZNavigationScope in the
navigation-view modifier, ZRouteLink at the three link sites, the hub with Spotlight, page views through
ZPageViewReporter, what to remove afterwards and how to verify. Linked from the module page and from the design
article's migration section.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Step 1 now contains the whole resolver, mirroring ZTronHomePageModel.loadGames, ZTronMapSelection.loadMaps and
ZTronMapToolsPicker.loadToolsAndTabs call for call (readAllGames with .all, readAllMaps and readAllSubmaps limited
to first-level masters paired with submap counts, readTabsWithToolsForMap), and assembling for every level the
complete environment the screens inject today, including the serialised map and the tool for tool routes.
Unknown maps and tools are left out rather than thrown, so constant routes keep opening.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The resolver is built lazily next to the one route table instead of once per tab, so there is a single trie, a
single database cache and a single Spotlight table; the modifier only reads it. Nothing is registered twice.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… too

A NavigationStack destination inherits the environment of the stack's root, not of the pushing screen, so the tool
level must carry everything it received before, the same set the resolver of step 1 produces for a deep link.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A dependency-free hook that lets the host gate a route without the routing
kit knowing about the paywall kit (freemium design, milestone 5).

- ZRouteGate (decision(for:), wrap(_:for:presence:)) and ZRouteGateDecision.
- gate: parameter on ZNavigator.init and ZNavigationScope.init, nil by default.
- ZNavigator.canPass(_:) and presence(of:).
- ZRouteLink asks the gate once per tap and does nothing on .denied.
- ZDestinationState wraps the erased screen once per push, on the carried
  and the async path. push, navigate(to:) and the hub do not consult it.

With gate == nil no hook runs; the parity suite passes unmodified. New
model-level tests and hosted tests (real link taps on both backends) count
decisions and wraps with a probe gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NickTheFreak97
NickTheFreak97 deleted the route-gate branch November 22, 2026 15:22
@NickTheFreak97
NickTheFreak97 restored the route-gate branch November 22, 2026 15:22
@NickTheFreak97
NickTheFreak97 deleted the route-gate branch November 22, 2026 15:24
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