@uniqbit/mate-core 0.18.5 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/claude-capability-plugins/companion-mentions/.claude-plugin/marketplace.json +14 -0
- package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +8 -0
- package/claude-capability-plugins/companion-mentions/hooks/companion.ts +457 -0
- package/claude-capability-plugins/companion-mentions/hooks/hooks.json +1 -0
- package/claude-capability-plugins/companion-mentions/hooks/register.ts +403 -0
- package/claude-plugin/hooks/companion-instructions.mjs +9 -0
- package/claude-plugin/hooks/hooks.json +50 -2
- package/claude-plugin/hooks/rtk-worktree-git.mjs +58 -0
- package/claude-plugin/hooks/session-attention.mjs +10 -0
- package/claude-plugin/hooks/session-end.mjs +9 -0
- package/claude-plugin/hooks/session-guidance.mjs +1 -1
- package/claude-plugin/hooks/tokensave-route.mjs +52 -0
- package/opencode-plugin/src/server.ts +25 -3
- package/opencode-plugin/src/tui.tsx +3 -1
- package/opencode-plugin/tui.tsx +4 -1
- package/package.json +53 -15
- package/src/brand/art.generated.ts +69 -0
- package/src/brand/index.ts +12 -0
- package/src/brand/palette.ts +19 -0
- package/src/brand/svg.generated.ts +8 -0
- package/src/brand/terminal.ts +88 -0
- package/src/brand/types.ts +33 -0
- package/src/cli/commands/artifact/apply-context.ts +275 -0
- package/src/cli/commands/artifact/artifact.ts +12 -0
- package/src/cli/commands/artifact/delivery/archive.ts +125 -0
- package/src/cli/commands/artifact/delivery/branch-flags.ts +55 -0
- package/src/cli/commands/artifact/delivery/environment.ts +147 -0
- package/src/cli/commands/artifact/delivery/link.ts +210 -0
- package/src/cli/commands/artifact/delivery/output.ts +104 -0
- package/src/cli/commands/artifact/finish/command.ts +83 -8
- package/src/cli/commands/artifact/finish/engine.ts +91 -14
- package/src/cli/commands/artifact/finish/finisher.ts +10 -0
- package/src/cli/commands/artifact/finish/git.ts +132 -19
- package/src/cli/commands/artifact/finish/openspec.ts +180 -138
- package/src/cli/commands/artifact/finish/secret-scan.ts +43 -0
- package/src/cli/commands/artifact/finish/worktree-cleanup.ts +92 -0
- package/src/cli/commands/artifact/pending/command.ts +31 -3
- package/src/cli/commands/artifact/pending/discovery.ts +21 -57
- package/src/cli/commands/cap/graphify.ts +52 -3
- package/src/cli/commands/cap/index-cmd.ts +71 -15
- package/src/cli/commands/cap/openspec.ts +13 -25
- package/src/cli/commands/cap/tokensave.ts +7 -5
- package/src/cli/commands/companion/companion.ts +1 -1
- package/src/cli/commands/companion/link.ts +50 -5
- package/src/cli/commands/companion/open.ts +101 -51
- package/src/cli/commands/companion/sync.ts +10 -0
- package/src/cli/commands/companion/tui.ts +17 -7
- package/src/cli/commands/companion/update.ts +144 -66
- package/src/cli/commands/doctor.ts +317 -7
- package/src/cli/commands/factory/factory.ts +311 -0
- package/src/cli/commands/install.ts +180 -45
- package/src/cli/commands/launch/claude.ts +2 -0
- package/src/cli/commands/launch/shared.ts +48 -16
- package/src/cli/commands/plugin/install.ts +36 -15
- package/src/cli/commands/plugin/plugin.ts +3 -2
- package/src/cli/commands/report/adapter.ts +11 -2
- package/src/cli/commands/report/contract.ts +21 -0
- package/src/cli/commands/report/highlight.ts +34 -4
- package/src/cli/commands/report/index.ts +186 -171
- package/src/cli/commands/report/markdown.ts +105 -0
- package/src/cli/commands/report/palette.ts +118 -0
- package/src/cli/commands/report/renderer.ts +456 -153
- package/src/cli/commands/report/types.ts +16 -0
- package/src/cli/commands/session/context.ts +102 -0
- package/src/cli/commands/session/prepare.ts +32 -4
- package/src/cli/commands/session/registry.ts +90 -0
- package/src/cli/commands/setup.ts +50 -24
- package/src/cli/commands/shared/companion-selection.ts +3 -1
- package/src/cli/commands/studio/access.ts +6 -14
- package/src/cli/commands/studio/areas.ts +112 -33
- package/src/cli/commands/studio/companion-add.ts +87 -0
- package/src/cli/commands/studio/companion-removal.ts +86 -0
- package/src/cli/commands/studio/factory-credential.ts +35 -0
- package/src/cli/commands/studio/factory-git-tokens.ts +40 -0
- package/src/cli/commands/studio/factory-relay.ts +18 -0
- package/src/cli/commands/studio/graph-model.ts +61 -0
- package/src/cli/commands/studio/graph.ts +336 -0
- package/src/cli/commands/studio/index.ts +33 -6
- package/src/cli/commands/studio/mate-inventory.ts +1 -1
- package/src/cli/commands/studio/openspec-cli.ts +10 -58
- package/src/cli/commands/studio/payload.ts +292 -20
- package/src/cli/commands/studio/repository-add.ts +116 -0
- package/src/cli/commands/studio/routes.ts +47 -6
- package/src/cli/commands/studio/selection.ts +170 -17
- package/src/cli/commands/studio/server.ts +552 -327
- package/src/cli/commands/studio/services.ts +120 -0
- package/src/cli/commands/studio/skill-files.ts +133 -0
- package/src/cli/commands/studio/studio-app.ts +67 -0
- package/src/cli/commands/studio/terminal-assets.ts +21 -33
- package/src/cli/commands/studio/terminal.ts +128 -16
- package/src/cli/commands/studio/vault.ts +218 -44
- package/src/cli/commands/studio/views/model.ts +13 -0
- package/src/cli/commands/studio/views/vault/markdown-tree.ts +599 -0
- package/src/cli/commands/studio/views/vault/view.ts +185 -0
- package/src/cli/commands/studio/workset-session.ts +164 -0
- package/src/cli/commands/unwrap.ts +19 -0
- package/src/cli/commands/update.ts +55 -9
- package/src/cli/commands/vscode/release-vsix.json +4 -0
- package/src/cli/commands/vscode/setup.ts +213 -0
- package/src/cli/commands/vscode/vsix.ts +114 -0
- package/src/cli/commands/working/cleanup.ts +83 -18
- package/src/cli/commands/working/link.ts +76 -0
- package/src/cli/commands/working/working.ts +10 -0
- package/src/cli/commands/working/worktree.ts +547 -0
- package/src/cli/commands/wrap.ts +38 -20
- package/src/cli/companion-link-wizard.tsx +2 -0
- package/src/cli/companion-selector.tsx +2 -0
- package/src/cli/confirm.ts +2 -0
- package/src/cli/install-plan.tsx +127 -160
- package/src/cli/launch-selector.tsx +2 -0
- package/src/cli/main.ts +48 -5
- package/src/cli/parse-flags.ts +32 -6
- package/src/cli/repo-list-table.tsx +2 -0
- package/src/cli/setup-selector.tsx +86 -151
- package/src/cli/usage.ts +20 -1
- package/src/create-mate.ts +5 -4
- package/src/hooks/companion-instructions.ts +198 -0
- package/src/hooks/hook-io.ts +78 -0
- package/src/hooks/rtk-worktree-git.ts +48 -0
- package/src/hooks/session-banner.ts +24 -30
- package/src/hooks/session-end.ts +10 -0
- package/src/hooks/session-guidance.ts +18 -22
- package/src/hooks/session-prepare.ts +137 -34
- package/src/hooks/session-register.ts +199 -0
- package/src/hooks/tokensave-route.ts +30 -0
- package/src/hooks/validate-artifact-path.ts +121 -25
- package/src/index.ts +4 -0
- package/src/lib/apply-context/fingerprint.ts +174 -0
- package/src/lib/apply-context/protocol.ts +193 -0
- package/src/lib/change-layout.ts +154 -0
- package/src/lib/components/confirm-prompt.tsx +21 -9
- package/src/lib/components/select-menu.tsx +10 -3
- package/src/lib/components/spinner.tsx +4 -2
- package/src/lib/components/startup-progress.tsx +227 -41
- package/src/lib/components/text-input-display.tsx +2 -0
- package/src/lib/components/wizard-footer.tsx +2 -0
- package/src/lib/components/wizard-header.tsx +16 -12
- package/src/lib/context-mode-package.ts +24 -11
- package/src/lib/delivery/archive-change.ts +165 -0
- package/src/lib/delivery/branch-template.ts +122 -0
- package/src/lib/delivery/branches.ts +152 -0
- package/src/lib/delivery/checkout.ts +102 -0
- package/src/lib/delivery/environment.ts +37 -0
- package/src/lib/delivery/forge.ts +279 -0
- package/src/lib/delivery/merge-git.ts +273 -0
- package/src/lib/delivery/overlap.ts +209 -0
- package/src/lib/delivery/record-delivery.ts +392 -0
- package/src/lib/delivery/record.ts +417 -0
- package/src/lib/delivery/refresh.ts +288 -0
- package/src/lib/delivery/repository-access.ts +141 -0
- package/src/lib/delivery/resolve-branch.ts +430 -0
- package/src/lib/delivery/stages.ts +111 -0
- package/src/lib/delivery/token.ts +24 -0
- package/src/lib/factory/attach-client.ts +123 -0
- package/src/lib/factory/attach.ts +178 -0
- package/src/lib/factory/broker.ts +187 -0
- package/src/lib/factory/bun-commands.ts +39 -0
- package/src/lib/factory/client.ts +113 -0
- package/src/lib/factory/clone-url.ts +39 -0
- package/src/lib/factory/command.ts +77 -0
- package/src/lib/factory/credential-store.ts +153 -0
- package/src/lib/factory/frames.ts +77 -0
- package/src/lib/factory/git-auth.ts +61 -0
- package/src/lib/factory/git-credential-store.ts +181 -0
- package/src/lib/factory/ids.ts +68 -0
- package/src/lib/factory/keyed-serial.ts +27 -0
- package/src/lib/factory/outcomes/actions.ts +130 -0
- package/src/lib/factory/outcomes/index.ts +457 -0
- package/src/lib/factory/outcomes/lifecycle.ts +212 -0
- package/src/lib/factory/outcomes/runs.ts +81 -0
- package/src/lib/factory/outcomes/sessions.ts +60 -0
- package/src/lib/factory/prepare.ts +55 -0
- package/src/lib/factory/pty.ts +103 -0
- package/src/lib/factory/runner/companion-context.ts +178 -0
- package/src/lib/factory/runner/control.ts +92 -0
- package/src/lib/factory/runner/harness-agent.ts +250 -0
- package/src/lib/factory/runner/live.ts +159 -0
- package/src/lib/factory/runner/questions.ts +22 -0
- package/src/lib/factory/runner/rank.ts +26 -0
- package/src/lib/factory/runner/run-policy.ts +12 -0
- package/src/lib/factory/runner/run.ts +199 -0
- package/src/lib/factory/runner/scheduler.ts +498 -0
- package/src/lib/factory/runner/state.ts +233 -0
- package/src/lib/factory/runner/workflow.ts +546 -0
- package/src/lib/factory/runtime.ts +1081 -0
- package/src/lib/factory/sandbox.ts +292 -0
- package/src/lib/factory/worktree-branch.ts +17 -0
- package/src/lib/frontmatter.ts +18 -0
- package/src/lib/install.ts +66 -14
- package/src/lib/live-progress.ts +36 -0
- package/src/lib/member-choices.ts +67 -0
- package/src/lib/opencode-plugin-package.ts +5 -5
- package/src/lib/opencode-server.ts +238 -0
- package/src/lib/openspec-cli.ts +116 -0
- package/src/lib/openspec-scopes.ts +86 -0
- package/src/lib/orchestrator/adapters/base.ts +55 -22
- package/src/lib/orchestrator/adapters/claude-args.ts +50 -0
- package/src/lib/orchestrator/adapters/claude.ts +201 -43
- package/src/lib/orchestrator/adapters/opencode.ts +55 -2
- package/src/lib/orchestrator/checkout-adoption.ts +125 -0
- package/src/lib/orchestrator/companion-hub.ts +6 -1
- package/src/lib/orchestrator/companion-registry-store.ts +6 -2
- package/src/lib/orchestrator/config-store.ts +3 -2
- package/src/lib/orchestrator/editor.ts +32 -26
- package/src/lib/orchestrator/engine-floor.ts +48 -0
- package/src/lib/orchestrator/framework-context.ts +26 -14
- package/src/lib/orchestrator/global-config-store.ts +11 -0
- package/src/lib/orchestrator/launcher.ts +49 -3
- package/src/lib/orchestrator/openspec-store.ts +14 -54
- package/src/lib/orchestrator/projection-claude-commands.ts +36 -0
- package/src/lib/orchestrator/projection-claude-entry.ts +42 -21
- package/src/lib/orchestrator/projection-claude-links.ts +230 -0
- package/src/lib/orchestrator/projection-claude-skills.ts +39 -131
- package/src/lib/orchestrator/projection-companion-link.ts +12 -1
- package/src/lib/orchestrator/projection-entries.ts +121 -51
- package/src/lib/orchestrator/projection-opencode-copies.ts +93 -32
- package/src/lib/orchestrator/projection-openspec-store.ts +54 -9
- package/src/lib/orchestrator/projection-runtime-documents.ts +81 -49
- package/src/lib/orchestrator/projection-types.ts +63 -1
- package/src/lib/orchestrator/refresh-working-claude-links.ts +89 -0
- package/src/lib/orchestrator/registry-checkouts.ts +177 -0
- package/src/lib/orchestrator/repository-link.ts +216 -57
- package/src/lib/orchestrator/serving-claude-wrap.ts +43 -0
- package/src/lib/orchestrator/session-context-link.ts +73 -0
- package/src/lib/orchestrator/session-prepare.ts +87 -12
- package/src/lib/orchestrator/setup-compatibilities.ts +56 -70
- package/src/lib/orchestrator/types.ts +16 -2
- package/src/lib/orchestrator/umbrella-checkouts.ts +102 -0
- package/src/lib/orchestrator/working-repo-projection.ts +73 -10
- package/src/lib/orchestrator/workspace-document.ts +105 -0
- package/src/lib/orchestrator/workspace-inventory.ts +5 -1
- package/src/lib/orchestrator/wrap-pass.ts +23 -1
- package/src/lib/package-paths.ts +37 -0
- package/src/lib/public-npm.ts +105 -43
- package/src/lib/runtime-directory-refresh.ts +17 -1
- package/src/lib/session-attribution.ts +52 -0
- package/src/lib/session-state.ts +355 -0
- package/src/lib/session-stop.ts +64 -0
- package/src/lib/update-checker.ts +7 -1
- package/src/lib/usage/aggregate.ts +202 -0
- package/src/lib/usage/cache.ts +87 -0
- package/src/lib/usage/claude-pricing.ts +71 -0
- package/src/lib/usage/claude.ts +189 -0
- package/src/lib/usage/collect.ts +56 -0
- package/src/lib/usage/opencode.ts +188 -0
- package/src/lib/usage/records.ts +80 -0
- package/src/lib/usage/rtk-database.ts +72 -0
- package/src/lib/usage/savings.ts +209 -0
- package/src/lib/usage/scope.ts +182 -0
- package/src/lib/usage/source.ts +102 -0
- package/src/lib/usage/types.ts +143 -0
- package/src/lib/usage/window.ts +37 -0
- package/src/lib/workset/factory-local.ts +157 -0
- package/src/lib/workset/record.ts +547 -0
- package/src/lib/workset/repositories.ts +148 -0
- package/src/lib/workset/stage.ts +148 -0
- package/src/lib/workset/stages.ts +113 -0
- package/src/lib/workset/worktree-include.ts +161 -0
- package/src/lib/workset/worktree-index.ts +120 -0
- package/src/lib/workset/worktree.ts +1388 -0
- package/src/opencode/background-server.ts +145 -0
- package/src/opencode/companion-hooks.ts +151 -9
- package/src/opencode/companion-policy.ts +54 -22
- package/src/opencode/enter-worktree.ts +320 -0
- package/src/opencode/projected-guidance.ts +6 -2
- package/src/opencode/session-prepare.ts +2 -1
- package/src/opencode/session-register.ts +176 -0
- package/src/opencode/tui.tsx +24 -27
- package/src/plugins.ts +1 -0
- package/src/runtime/artifact-refusal.ts +63 -0
- package/src/runtime/claude-bg-isolation.ts +138 -0
- package/src/runtime/claude-delivery-plan.ts +121 -11
- package/src/runtime/commit-attribution-guard.ts +181 -0
- package/src/runtime/companion-git.ts +62 -12
- package/src/runtime/companion-guidance.ts +37 -12
- package/src/runtime/companion-instructions.ts +340 -0
- package/src/runtime/companion-lock.ts +30 -7
- package/src/runtime/current-branch.ts +24 -0
- package/src/runtime/entered-worktree.ts +24 -0
- package/src/runtime/env.ts +59 -8
- package/src/runtime/error-message.ts +4 -0
- package/src/runtime/git-layout.ts +366 -0
- package/src/runtime/git-tracked.ts +60 -0
- package/src/runtime/index.ts +29 -0
- package/src/runtime/launch-env-guard.ts +65 -0
- package/src/runtime/managed-block.ts +117 -0
- package/src/runtime/markdown-scan.ts +266 -0
- package/src/runtime/opencode-server-record.ts +136 -0
- package/src/runtime/physical-path.ts +111 -0
- package/src/runtime/policy.ts +50 -2
- package/src/runtime/projected-flag.ts +7 -0
- package/src/runtime/projected-guidance.ts +1 -0
- package/src/runtime/projection.ts +40 -6
- package/src/runtime/repo-destination.ts +72 -0
- package/src/runtime/repo-local.ts +29 -2
- package/src/runtime/rtk-git-guard.ts +66 -0
- package/src/runtime/runtime-directory.ts +5 -0
- package/src/runtime/runtime-document-manifest.ts +290 -29
- package/src/runtime/runtime-document-manifest.typecheck.ts +10 -0
- package/src/runtime/secret-guard.ts +169 -0
- package/src/runtime/secret-patterns.ts +397 -0
- package/src/runtime/secret-policy-weakening.ts +122 -0
- package/src/runtime/secret-scan.ts +90 -0
- package/src/runtime/serving-claude-wrap.ts +41 -0
- package/src/runtime/session-context.ts +99 -0
- package/src/runtime/session-kind.ts +13 -0
- package/src/runtime/session-registry.ts +434 -0
- package/src/runtime/shell-heredoc.ts +81 -0
- package/src/runtime/tokensave-route.ts +157 -0
- package/src/runtime/umbrella-folder.ts +56 -0
- package/src/runtime/wrap-state.ts +80 -15
- package/src/runtime/write-atomic.ts +64 -0
- package/src/studio.ts +163 -0
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +14 -10
- package/src/templates/capabilities/openspec-cap/mate-minimal/templates/spec.md +3 -5
- package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +18 -102
- package/src/templates/capabilities/openspec-cap/mate-v1/templates/spec.md +3 -5
- package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +20 -14
- package/src/templates/mate-skills/THIRD-PARTY-NOTICES.md +40 -0
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +217 -0
- package/src/templates/mate-skills/agents/mate-apply-change/references/mate-compact-apply.md +47 -0
- package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +200 -0
- package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +81 -0
- package/src/templates/mate-skills/agents/{mate-openspec-backfill → mate-backfill-spec}/SKILL.md +11 -4
- package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +110 -0
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +70 -0
- package/src/templates/mate-skills/agents/mate-explore-change/references/openspec-explore.md +350 -0
- package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +11 -4
- package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +2 -2
- package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +12 -5
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +106 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +45 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-propose.md +169 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +103 -0
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +271 -0
- package/src/templates/mate-skills/{claude/mate-artifact-publish → agents/mate-publish-artifact}/references/openspec.md +8 -5
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +105 -20
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +91 -68
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +217 -0
- package/src/templates/mate-skills/claude/mate-apply-change/references/mate-compact-apply.md +47 -0
- package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +200 -0
- package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +81 -0
- package/src/templates/mate-skills/claude/{mate-openspec-backfill → mate-backfill-spec}/SKILL.md +11 -4
- package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +110 -0
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +70 -0
- package/src/templates/mate-skills/claude/mate-explore-change/references/openspec-explore.md +350 -0
- package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +11 -4
- package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +2 -2
- package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +12 -5
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +106 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +45 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-propose.md +169 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +103 -0
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +271 -0
- package/src/templates/mate-skills/{agents/mate-artifact-publish → claude/mate-publish-artifact}/references/openspec.md +8 -5
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +105 -20
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +91 -68
- package/src/templates/mate-skills/openspec-references.ts +142 -0
- package/src/templates/root/TEMPLATE_AGENTS.md +2 -2
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +4581 -397
- package/src/tools/setup/capabilities/companion-mentions.ts +27 -0
- package/src/tools/setup/capabilities/context-mode.ts +56 -7
- package/src/tools/setup/capabilities/graphify-gate.ts +31 -0
- package/src/tools/setup/capabilities/graphify-secrets.ts +243 -0
- package/src/tools/setup/capabilities/graphify.ts +46 -7
- package/src/tools/setup/capabilities/openspec.ts +163 -272
- package/src/tools/setup/capabilities/react-doctor.ts +8 -1
- package/src/tools/setup/capabilities/rtk.ts +97 -1
- package/src/tools/setup/capabilities/tokensave.ts +113 -71
- package/src/tools/setup/context-services.ts +9 -17
- package/src/tools/setup/dynamic-plugins/audiences.ts +65 -21
- package/src/tools/setup/dynamic-plugins/frozen.ts +32 -13
- package/src/tools/setup/dynamic-plugins/hydrate.ts +8 -7
- package/src/tools/setup/dynamic-plugins/install.ts +46 -48
- package/src/tools/setup/dynamic-plugins/loader.ts +11 -7
- package/src/tools/setup/dynamic-plugins/paths.ts +30 -10
- package/src/tools/setup/dynamic-plugins/verify.ts +10 -7
- package/src/tools/setup/dynamic-plugins/workspaces.ts +153 -0
- package/src/tools/setup/engine.ts +100 -23
- package/src/tools/setup/install-contract.ts +8 -0
- package/src/tools/setup/managed-output.ts +51 -0
- package/src/tools/setup/mate-skill-copies.ts +51 -0
- package/src/tools/setup/mate.ts +88 -13
- package/src/tools/setup/package-managers/uv.ts +73 -11
- package/src/tools/setup/plugin.ts +40 -0
- package/src/tools/setup/plugins/gitignore.ts +15 -9
- package/src/tools/setup/plugins/guidance.ts +7 -4
- package/src/tools/setup/providers/agent-file-sections.ts +4 -2
- package/src/tools/setup/providers/claude-attribution.ts +65 -0
- package/src/tools/setup/providers/claude-plugin-folders.ts +625 -0
- package/src/tools/setup/providers/claude-plugin-hooks.ts +89 -19
- package/src/tools/setup/providers/claude-worktree-plugins.ts +122 -0
- package/src/tools/setup/providers/claude.ts +332 -8
- package/src/tools/setup/providers/opencode.ts +180 -1
- package/src/tools/setup/utils.ts +22 -6
- package/src/tools/setup/working-repo-cleanup.ts +30 -2
- package/src/tools/setup/working-repo-local-state.ts +252 -75
- package/src/tools/setup.ts +196 -28
- package/studio-dist/client/assets/app-D9cw6szy.css +2 -0
- package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +1 -0
- package/studio-dist/client/assets/button-Br0O1sXw.js +1 -0
- package/studio-dist/client/assets/combobox-DA7RAUUZ.js +1 -0
- package/studio-dist/client/assets/companion-view-CrabvxS8.js +1 -0
- package/studio-dist/client/assets/dist-Dm7MtyHc.js +5 -0
- package/studio-dist/client/assets/factory-DGS0E16C.js +6 -0
- package/studio-dist/client/assets/fields-6aXBpFhJ.js +1 -0
- package/studio-dist/client/assets/getting-started-Clde4w6P.js +1 -0
- package/studio-dist/client/assets/getting-started-D6kgWwWZ.js +1 -0
- package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +1 -0
- package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +1 -0
- package/studio-dist/client/assets/graph-B_TCBVbu.js +2 -0
- package/studio-dist/client/assets/graph-canvas-Ba37Y5AE.js +3242 -0
- package/studio-dist/client/assets/guides-Du_RtJxP.js +1 -0
- package/studio-dist/client/assets/index-Df8L1LQa.js +40 -0
- package/studio-dist/client/assets/jsx-runtime-MZURdZre.js +1 -0
- package/studio-dist/client/assets/markdown-view-BOX6x0rL.js +1 -0
- package/studio-dist/client/assets/panel-dbmCx7Mx.js +1 -0
- package/studio-dist/client/assets/preload-helper-BLdHbfdN.js +1 -0
- package/studio-dist/client/assets/queries-RvHeXY12.js +1 -0
- package/studio-dist/client/assets/react-3QStrcDO.js +27 -0
- package/studio-dist/client/assets/report-url-XRL0x1SY.js +1 -0
- package/studio-dist/client/assets/reports-r3IK7Doz.js +1 -0
- package/studio-dist/client/assets/routes-C0A5LTFc.js +1 -0
- package/studio-dist/client/assets/select-CnaMd617.js +1 -0
- package/studio-dist/client/assets/skills-CzjzHpBT.js +1 -0
- package/studio-dist/client/assets/specs-B0ldF_6J.js +1 -0
- package/studio-dist/client/assets/specs-view-BnCLA0gW.js +1 -0
- package/studio-dist/client/assets/spinner-Dcm3fqK1.js +1 -0
- package/studio-dist/client/assets/steps-C0p2N1Pb.js +1 -0
- package/studio-dist/client/assets/store-Dw34catY.js +1 -0
- package/studio-dist/client/assets/studio-Cpz_HRHp.js +100 -0
- package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +2 -0
- package/studio-dist/client/assets/terminal-eU5fzQzv.css +1 -0
- package/studio-dist/client/assets/usage-C2QJ_0IZ.js +55 -0
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +1 -0
- package/studio-dist/client/assets/useMutation-aAr2uiay.js +1 -0
- package/studio-dist/client/assets/useSelector-AYcH7lB0.js +2 -0
- package/studio-dist/client/assets/vault-BGcxkSIY.js +1 -0
- package/studio-dist/client/assets/warnings-R1cE1rLf.js +1 -0
- package/studio-dist/client/assets/wasm-inline-C2en61B5.js +1 -0
- package/studio-dist/client/assets/workflow-C2qTrMDH.js +1 -0
- package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-Bn896ZYj.js +122 -0
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +162 -0
- package/studio-dist/server/assets/actions-D8erOphH.js +44 -0
- package/studio-dist/server/assets/actions-DYSv-9VV.js +60 -0
- package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +216 -0
- package/studio-dist/server/assets/button-CgOIVdmD.js +10240 -0
- package/studio-dist/server/assets/combobox-DV_s9W0s.js +483 -0
- package/studio-dist/server/assets/companion-view-BKVXD3TO.js +39 -0
- package/studio-dist/server/assets/companions-C7fctnU9.js +31 -0
- package/studio-dist/server/assets/createServerRpc-bFKFpGFG.js +11 -0
- package/studio-dist/server/assets/dist-DpJWKyCm.js +5582 -0
- package/studio-dist/server/assets/empty-plugin-adapters-Cipd4ZH4.js +4 -0
- package/studio-dist/server/assets/factory-C7Ybg0xG.js +3075 -0
- package/studio-dist/server/assets/factory-Df5uAHjb.js +116 -0
- package/studio-dist/server/assets/fields-BbieQTD0.js +1190 -0
- package/studio-dist/server/assets/getting-started-B136TP57.js +4 -0
- package/studio-dist/server/assets/getting-started-CRxMWorQ.js +67 -0
- package/studio-dist/server/assets/getting-started._topic-DJKQAzYl.js +13 -0
- package/studio-dist/server/assets/getting-started.index-D84gec1t.js +13 -0
- package/studio-dist/server/assets/graph-CSje3029.js +801 -0
- package/studio-dist/server/assets/graph-DDZzXM1L.js +16 -0
- package/studio-dist/server/assets/graph-canvas-22bWB5-2.js +21066 -0
- package/studio-dist/server/assets/graph-wire-BdSUx0G5.js +58 -0
- package/studio-dist/server/assets/guides-D9dk1Frq.js +13 -0
- package/studio-dist/server/assets/guides-IE-19POz.js +5 -0
- package/studio-dist/server/assets/guides.server-vcYRY5wx.js +66 -0
- package/studio-dist/server/assets/jsx-runtime-Bt0s0YKS.js +451 -0
- package/studio-dist/server/assets/markdown-view-BR8dJ7aR.js +105 -0
- package/studio-dist/server/assets/model-PyPALjii.js +18 -0
- package/studio-dist/server/assets/panel-BR_t9iMM.js +169 -0
- package/studio-dist/server/assets/queries-DWoTin-q.js +32 -0
- package/studio-dist/server/assets/react-CdqSUhaL.js +89 -0
- package/studio-dist/server/assets/redirect-BaZ_QyqF.js +39 -0
- package/studio-dist/server/assets/report-url-BUXPcE_8.js +9 -0
- package/studio-dist/server/assets/reports-CQ9qQ1-n.js +141 -0
- package/studio-dist/server/assets/reports-dYDEoBeq.js +18 -0
- package/studio-dist/server/assets/router-DkRHNTpE.js +11638 -0
- package/studio-dist/server/assets/routes-B6GfOew4.js +473 -0
- package/studio-dist/server/assets/search-BJnWLfkG.js +55 -0
- package/studio-dist/server/assets/select-Af7Wibii.js +1609 -0
- package/studio-dist/server/assets/shell-Hq-hXgnT.js +53 -0
- package/studio-dist/server/assets/skills-B7nEuVbx.js +267 -0
- package/studio-dist/server/assets/skills-B_YYL7q8.js +28 -0
- package/studio-dist/server/assets/specs-BpLUFntA.js +51 -0
- package/studio-dist/server/assets/specs-view-0peMVd22.js +426 -0
- package/studio-dist/server/assets/spinner-CdwJW4VB.js +20 -0
- package/studio-dist/server/assets/start-h3ICWwd2.js +36 -0
- package/studio-dist/server/assets/steps-D56DApvK.js +181 -0
- package/studio-dist/server/assets/store-Cs17okNG.js +280 -0
- package/studio-dist/server/assets/studio-CAcKp3bM.js +10340 -0
- package/studio-dist/server/assets/studio-queries-BtRGzDdh.js +1451 -0
- package/studio-dist/server/assets/usage-COdjd1gD.js +25570 -0
- package/studio-dist/server/assets/usage-f6pqE1tm.js +24 -0
- package/studio-dist/server/assets/useAnchoredPopupScrollLock-DlBKHRw7.js +756 -0
- package/studio-dist/server/assets/useMutation-DzTZGenE.js +690 -0
- package/studio-dist/server/assets/useSelector-DUmCUXAs.js +3387 -0
- package/studio-dist/server/assets/utils-C9CX1kcy.js +221 -0
- package/studio-dist/server/assets/vault-BDuIUq0F.js +1035 -0
- package/studio-dist/server/assets/vault-BVLp6zu3.js +85 -0
- package/studio-dist/server/assets/views-flRUr21z.js +80 -0
- package/studio-dist/server/assets/warnings-CDy9pdgL.js +24 -0
- package/studio-dist/server/assets/wasm-inline-CNeBKGwC.js +3 -0
- package/studio-dist/server/assets/workflow-D9GKI2EV.js +680 -0
- package/studio-dist/server/server.js +16640 -0
- package/wrappers/bin/graphify +52 -4
- package/wrappers/bin/openspec +33 -9
- package/wrappers/lib/graphify-gate.mjs +8 -0
- package/src/cli/commands/report/collector.ts +0 -288
- package/src/cli/commands/studio/views/client.ts +0 -654
- package/src/cli/commands/studio/views/companion-picker.tsx +0 -95
- package/src/cli/commands/studio/views/companion-selector.tsx +0 -94
- package/src/cli/commands/studio/views/dashboard/changes.tsx +0 -107
- package/src/cli/commands/studio/views/dashboard/index.tsx +0 -19
- package/src/cli/commands/studio/views/document.tsx +0 -842
- package/src/cli/commands/studio/views/error.tsx +0 -20
- package/src/cli/commands/studio/views/reports/index.tsx +0 -49
- package/src/cli/commands/studio/views/selection-fields.tsx +0 -14
- package/src/cli/commands/studio/views/skills/index.tsx +0 -87
- package/src/cli/commands/studio/views/specs/index.tsx +0 -157
- package/src/cli/commands/studio/views/styles.ts +0 -519
- package/src/cli/commands/studio/views/terminal.tsx +0 -484
- package/src/cli/commands/studio/views/vault/state.ts +0 -43
- package/src/cli/commands/studio/views/warnings.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/index.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/steps.ts +0 -337
- package/src/cli/commands/studio/views/workflow/transcript.tsx +0 -190
- package/src/lib/components/theme.ts +0 -2
- package/src/templates/mate-skills/agents/mate-artifact-publish/SKILL.md +0 -185
- package/src/templates/mate-skills/claude/mate-artifact-publish/SKILL.md +0 -185
- package/src/tools/setup/git-utils.ts +0 -30
- package/src/tools/setup/runtime-documents.ts +0 -291
|
@@ -0,0 +1,3387 @@
|
|
|
1
|
+
import { n as require_react, o as __toESM, r as __commonJSMin } from "./jsx-runtime-Bt0s0YKS.js";
|
|
2
|
+
import { r as redirect, t as isRedirect } from "./redirect-BaZ_QyqF.js";
|
|
3
|
+
import { _ as protocolRelativePrefixRegex, a as deepEqual, c as functionalUpdate, d as hasOwn, g as nullReplaceEqualDeep, h as last, i as decodePath, l as getUrlScheme, n as arraysEqual, o as encodePathLikeUrl, r as createNull, t as DEFAULT_PROTOCOL_ALLOWLIST, u as hasKeys, v as replaceEqualDeep } from "./utils-C9CX1kcy.js";
|
|
4
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/not-found.js
|
|
5
|
+
/** Determine if a value is a TanStack Router not-found error. */
|
|
6
|
+
function isNotFound(obj) {
|
|
7
|
+
return obj?.isNotFound === true;
|
|
8
|
+
}
|
|
9
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/root.js
|
|
10
|
+
/** Stable identifier used for the root route in a route tree. */
|
|
11
|
+
var rootRouteId = "__root__";
|
|
12
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/path.js
|
|
13
|
+
/** Remove repeated slashes from a path string. */
|
|
14
|
+
function cleanPath(path) {
|
|
15
|
+
return path.replace(/\/{2,}/g, "/");
|
|
16
|
+
}
|
|
17
|
+
/** Trim leading slashes (except preserving root '/'). */
|
|
18
|
+
function trimPathLeft(path) {
|
|
19
|
+
return path === "/" ? path : path.replace(/^\/+/, "");
|
|
20
|
+
}
|
|
21
|
+
/** Trim trailing slashes (except preserving root '/'). */
|
|
22
|
+
function trimPathRight(path) {
|
|
23
|
+
const len = path.length;
|
|
24
|
+
return len > 1 && path[len - 1] === "/" ? path.replace(/\/+$/, "") : path;
|
|
25
|
+
}
|
|
26
|
+
/** Trim both leading and trailing slashes. */
|
|
27
|
+
function trimPath(path) {
|
|
28
|
+
return trimPathRight(trimPathLeft(path));
|
|
29
|
+
}
|
|
30
|
+
/** Remove a trailing slash from value when appropriate for comparisons. */
|
|
31
|
+
function removeTrailingSlash(value, basepath) {
|
|
32
|
+
if (value?.endsWith("/") && value !== "/" && value !== `${basepath}/`) return value.slice(0, -1);
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Resolve a destination path against a base, honoring trailing-slash policy
|
|
37
|
+
* and supporting relative segments (`.`/`..`) and absolute `to` values.
|
|
38
|
+
*
|
|
39
|
+
* Internal: parameters are positional so the router's hot callers pass no
|
|
40
|
+
* options object.
|
|
41
|
+
*/
|
|
42
|
+
function resolvePath(base, to, trailingSlash = "never", cache) {
|
|
43
|
+
if (to.includes("//")) to = cleanPath(to);
|
|
44
|
+
if (to.startsWith("/")) {
|
|
45
|
+
if (to.length === 1 || trailingSlash === "preserve") return to;
|
|
46
|
+
if (trailingSlash === "always") return to.endsWith("/") ? to : `${to}/`;
|
|
47
|
+
return to.endsWith("/") ? to.slice(0, -1) : to;
|
|
48
|
+
}
|
|
49
|
+
const isBase = to === ".";
|
|
50
|
+
let key;
|
|
51
|
+
if (cache) {
|
|
52
|
+
key = isBase ? base : base + "\0" + to;
|
|
53
|
+
const cached = cache.get(key);
|
|
54
|
+
if (cached) return cached;
|
|
55
|
+
}
|
|
56
|
+
let baseSegments;
|
|
57
|
+
if (isBase) baseSegments = base.split("/");
|
|
58
|
+
else {
|
|
59
|
+
if (base.includes("//")) base = cleanPath(base);
|
|
60
|
+
baseSegments = base.split("/");
|
|
61
|
+
while (baseSegments.length > 1 && last(baseSegments) === "") baseSegments.pop();
|
|
62
|
+
const toSegments = to.split("/");
|
|
63
|
+
for (let index = 0, length = toSegments.length; index < length; index++) {
|
|
64
|
+
const value = toSegments[index];
|
|
65
|
+
if (value === "") {
|
|
66
|
+
if (!index) baseSegments = [value];
|
|
67
|
+
else if (index === length - 1) baseSegments.push(value);
|
|
68
|
+
} else if (value === "..") {
|
|
69
|
+
if (baseSegments.length > 1) baseSegments.pop();
|
|
70
|
+
else baseSegments = [""];
|
|
71
|
+
} else if (value === ".") {} else baseSegments.push(value);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (baseSegments.length > 1) {
|
|
75
|
+
if (last(baseSegments) === "") {
|
|
76
|
+
if (trailingSlash === "never") baseSegments.pop();
|
|
77
|
+
} else if (trailingSlash === "always") baseSegments.push("");
|
|
78
|
+
}
|
|
79
|
+
const joined = baseSegments.join("/");
|
|
80
|
+
const result = (isBase ? cleanPath(joined) : joined) || "/";
|
|
81
|
+
if (key && cache) cache.set(key, result);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a pre-compiled decode config from allowed characters.
|
|
86
|
+
* Created once for the router's fixed encoding configuration.
|
|
87
|
+
*/
|
|
88
|
+
function compileDecodeCharMap(pathParamsAllowedCharacters) {
|
|
89
|
+
const charMap = new Map(pathParamsAllowedCharacters.map((char) => [encodeURIComponent(char), char]));
|
|
90
|
+
const regex = new RegExp([...charMap.keys()].join("|").replace(/[.*()]/g, "\\$&"), "g");
|
|
91
|
+
return (encoded) => encoded.replace(regex, (match) => charMap.get(match) ?? match);
|
|
92
|
+
}
|
|
93
|
+
/** A splat is missing when it has no value; `0` and `false` are stringified like any other param. */
|
|
94
|
+
function isMissingSplat(value) {
|
|
95
|
+
return value == null || value === "";
|
|
96
|
+
}
|
|
97
|
+
function encodeParam(key, value, decoder) {
|
|
98
|
+
if (typeof value !== "string") return "" + (value ?? void 0);
|
|
99
|
+
const splat = key === "_splat";
|
|
100
|
+
if (splat && (!value || /^[a-zA-Z0-9\-._~!/]*$/.test(value))) return value;
|
|
101
|
+
let encoded = encodeURIComponent(value);
|
|
102
|
+
if (splat) encoded = encoded.replaceAll("%2F", "/");
|
|
103
|
+
return decoder ? decoder(encoded) : encoded;
|
|
104
|
+
}
|
|
105
|
+
/** Substitute current values into parsed segments, optionally collecting raw params. */
|
|
106
|
+
function interpolatePath(path, segments, params, decoder, usedParams) {
|
|
107
|
+
const trailingSlash = path.endsWith("/") ? "/" : "";
|
|
108
|
+
let joined = "";
|
|
109
|
+
for (const part of segments) {
|
|
110
|
+
if (typeof part === "string") {
|
|
111
|
+
joined += part;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const [kind, key, prefix, rawSuffix] = part;
|
|
115
|
+
const splat = kind === 2;
|
|
116
|
+
const suffix = splat && rawSuffix !== void 0 ? rawSuffix + trailingSlash : rawSuffix;
|
|
117
|
+
let paramValue = params[key];
|
|
118
|
+
if (kind === 3 && paramValue == null) continue;
|
|
119
|
+
if (usedParams) {
|
|
120
|
+
usedParams[key] = paramValue;
|
|
121
|
+
if (splat) usedParams["*"] = paramValue;
|
|
122
|
+
}
|
|
123
|
+
if (splat && isMissingSplat(paramValue)) {
|
|
124
|
+
if (prefix === "/" && !suffix) continue;
|
|
125
|
+
paramValue = "";
|
|
126
|
+
}
|
|
127
|
+
joined += prefix + encodeParam(key, paramValue, decoder) + (suffix || "");
|
|
128
|
+
}
|
|
129
|
+
return joined + trailingSlash || "/";
|
|
130
|
+
}
|
|
131
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/sieve-cache.js
|
|
132
|
+
/**
|
|
133
|
+
* A fixed-capacity cache using the SIEVE eviction algorithm
|
|
134
|
+
* (https://cachemon.github.io/SIEVE-website/).
|
|
135
|
+
*
|
|
136
|
+
* Entries live in the Map's FIFO insertion order; a hit only flips a `visited`
|
|
137
|
+
* bit instead of relinking the entry, which makes `get` (by far the hottest
|
|
138
|
+
* operation here) one `Map.get` plus a boolean store. Eviction sweeps a `hand`
|
|
139
|
+
* from the oldest entry towards the newest, clearing `visited` bits until it
|
|
140
|
+
* finds an unvisited entry to drop, so entries touched since the last sweep
|
|
141
|
+
* survive one more round. This keeps LRU-like hit ratios while being
|
|
142
|
+
* scan-resistant.
|
|
143
|
+
*/
|
|
144
|
+
function createSieveCache(max) {
|
|
145
|
+
const cache = /* @__PURE__ */ new Map();
|
|
146
|
+
let hand;
|
|
147
|
+
let newest;
|
|
148
|
+
return {
|
|
149
|
+
get(key) {
|
|
150
|
+
const entry = cache.get(key);
|
|
151
|
+
if (!entry) return;
|
|
152
|
+
entry.visited = true;
|
|
153
|
+
return entry.value;
|
|
154
|
+
},
|
|
155
|
+
set(key, value) {
|
|
156
|
+
const existing = cache.get(key);
|
|
157
|
+
if (existing) {
|
|
158
|
+
existing.value = value;
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (cache.size >= max) {
|
|
162
|
+
let node = hand?.next().value;
|
|
163
|
+
while (!node || node.visited) {
|
|
164
|
+
if (node) node.visited = false;
|
|
165
|
+
else hand = cache.values();
|
|
166
|
+
node = hand.next().value;
|
|
167
|
+
}
|
|
168
|
+
if (node === newest) hand = void 0;
|
|
169
|
+
cache.delete(node.key);
|
|
170
|
+
}
|
|
171
|
+
const entry = {
|
|
172
|
+
key,
|
|
173
|
+
value,
|
|
174
|
+
visited: false
|
|
175
|
+
};
|
|
176
|
+
newest = entry;
|
|
177
|
+
cache.set(key, entry);
|
|
178
|
+
},
|
|
179
|
+
clear() {
|
|
180
|
+
cache.clear();
|
|
181
|
+
hand = void 0;
|
|
182
|
+
newest = void 0;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/invariant.js
|
|
187
|
+
function invariant() {
|
|
188
|
+
throw new Error("Invariant failed");
|
|
189
|
+
}
|
|
190
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/new-process-route-tree.js
|
|
191
|
+
var SEGMENT_TYPE_INDEX = 4;
|
|
192
|
+
var SEGMENT_TYPE_PATHLESS = 5;
|
|
193
|
+
function getParamNames(data) {
|
|
194
|
+
const cached = data.names;
|
|
195
|
+
if (cached) return cached;
|
|
196
|
+
const keys = [];
|
|
197
|
+
for (const segment of data) if (typeof segment !== "string") keys.push(segment[1]);
|
|
198
|
+
return data.names = keys;
|
|
199
|
+
}
|
|
200
|
+
/** Parse one segment for matching and retain the same record for interpolation. */
|
|
201
|
+
function parseSegment(path, start, end) {
|
|
202
|
+
const part = path.slice(start, end);
|
|
203
|
+
if (part.charCodeAt(0) === 36) return part.length === 1 ? [
|
|
204
|
+
2,
|
|
205
|
+
"_splat",
|
|
206
|
+
"",
|
|
207
|
+
void 0
|
|
208
|
+
] : [
|
|
209
|
+
1,
|
|
210
|
+
part.slice(1),
|
|
211
|
+
"",
|
|
212
|
+
""
|
|
213
|
+
];
|
|
214
|
+
const open = part.indexOf("{");
|
|
215
|
+
if (open >= 0) {
|
|
216
|
+
const close = part.indexOf("}", open);
|
|
217
|
+
const optional = part.charCodeAt(open + 1) === 45;
|
|
218
|
+
const nameStart = open + (optional ? 3 : 2);
|
|
219
|
+
if (close >= 0 && part.charCodeAt(nameStart - 1) === 36 && (!optional || nameStart < close)) {
|
|
220
|
+
const key = part.slice(nameStart, close);
|
|
221
|
+
return [
|
|
222
|
+
optional ? 3 : key ? 1 : 2,
|
|
223
|
+
key || "_splat",
|
|
224
|
+
part.slice(0, open),
|
|
225
|
+
path.slice(start + close + 1, key ? end : path.length)
|
|
226
|
+
];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return part;
|
|
230
|
+
}
|
|
231
|
+
function parseSegments(defaultCaseSensitive, route, start, node, dynamicListsToSort, parentInterpolation) {
|
|
232
|
+
let cursor = start;
|
|
233
|
+
const path = route.fullPath ?? route.from;
|
|
234
|
+
const options = route.options;
|
|
235
|
+
const length = path.length;
|
|
236
|
+
const literalEnd = path.endsWith("/") ? length - 1 : length;
|
|
237
|
+
const caseSensitive = options?.caseSensitive ?? defaultCaseSensitive;
|
|
238
|
+
const parseParams = options?.params?.parse ?? options?.parseParams;
|
|
239
|
+
let interpolation;
|
|
240
|
+
let literalStart = parentInterpolation ? start - 1 : 0;
|
|
241
|
+
if (!node || path.includes("$")) {
|
|
242
|
+
interpolation = parentInterpolation?.slice() ?? [];
|
|
243
|
+
const tail = last(interpolation);
|
|
244
|
+
if (tail && typeof tail !== "string" && tail[0] === 2) {
|
|
245
|
+
interpolation[interpolation.length - 1] = [
|
|
246
|
+
tail[0],
|
|
247
|
+
tail[1],
|
|
248
|
+
tail[2],
|
|
249
|
+
tail[3] === void 0 ? void 0 : tail[3] + path.substring(start - (path[start - 2] === "/" ? 2 : 1), literalEnd)
|
|
250
|
+
];
|
|
251
|
+
literalStart = length;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
while (cursor < length) {
|
|
255
|
+
const start = cursor;
|
|
256
|
+
const next = path.indexOf("/", start);
|
|
257
|
+
let end = next === -1 ? length : next;
|
|
258
|
+
const segment = parseSegment(path, start, end);
|
|
259
|
+
cursor = end + 1;
|
|
260
|
+
let nextNode;
|
|
261
|
+
if (typeof segment === "string") {
|
|
262
|
+
if (!node) continue;
|
|
263
|
+
let name = segment;
|
|
264
|
+
let staticChildren;
|
|
265
|
+
if (caseSensitive) staticChildren = node.static ??= /* @__PURE__ */ new Map();
|
|
266
|
+
else {
|
|
267
|
+
name = segment.toLowerCase();
|
|
268
|
+
staticChildren = node.staticInsensitive ??= /* @__PURE__ */ new Map();
|
|
269
|
+
}
|
|
270
|
+
const existingNode = staticChildren.get(name);
|
|
271
|
+
if (existingNode) nextNode = existingNode;
|
|
272
|
+
else {
|
|
273
|
+
const next = createSegmentNode(node);
|
|
274
|
+
nextNode = next;
|
|
275
|
+
staticChildren.set(name, next);
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
const kind = segment[0];
|
|
279
|
+
let prefix = segment[2];
|
|
280
|
+
let suffix = segment[3] ?? "";
|
|
281
|
+
if (kind === 2) {
|
|
282
|
+
end = length;
|
|
283
|
+
cursor = end + 1;
|
|
284
|
+
}
|
|
285
|
+
if (interpolation && literalStart < end) {
|
|
286
|
+
if (literalStart < start - 1) interpolation.push(path.slice(literalStart, start - 1));
|
|
287
|
+
segment[2] = "/" + prefix;
|
|
288
|
+
if (kind === 2 && segment[3] !== void 0 && literalEnd < length) segment[3] = suffix.slice(0, -1);
|
|
289
|
+
interpolation.push(segment);
|
|
290
|
+
literalStart = end;
|
|
291
|
+
}
|
|
292
|
+
if (!node) continue;
|
|
293
|
+
const actuallyCaseSensitive = caseSensitive && !!(prefix || suffix);
|
|
294
|
+
if (!caseSensitive) {
|
|
295
|
+
prefix = prefix.toLowerCase();
|
|
296
|
+
suffix = suffix.toLowerCase();
|
|
297
|
+
}
|
|
298
|
+
const siblings = kind === 1 ? node.dynamic ??= [] : kind === 3 ? node.optional ??= [] : node.wildcard ??= [];
|
|
299
|
+
const existingNode = kind !== 2 && !parseParams && siblings.find((s) => !s.parse && s.caseSensitive === actuallyCaseSensitive && s.prefix === prefix && s.suffix === suffix);
|
|
300
|
+
if (existingNode) nextNode = existingNode;
|
|
301
|
+
else {
|
|
302
|
+
const next = createSegmentNode(node, kind, actuallyCaseSensitive, prefix, suffix);
|
|
303
|
+
nextNode = next;
|
|
304
|
+
siblings.push(next);
|
|
305
|
+
if (siblings.length === 2) dynamicListsToSort?.push(siblings);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
node = nextNode;
|
|
309
|
+
}
|
|
310
|
+
if (interpolation && literalStart < literalEnd) interpolation.push(path.slice(literalStart, literalEnd));
|
|
311
|
+
const segmentData = interpolation?.slice();
|
|
312
|
+
if (!node) return segmentData;
|
|
313
|
+
if (parseParams && route.children && !route.isRoot && route.id && route.id.charCodeAt(route.id.lastIndexOf("/") + 1) === 95) {
|
|
314
|
+
const pathlessNode = createSegmentNode(node, SEGMENT_TYPE_PATHLESS);
|
|
315
|
+
(node.pathless ??= []).push(pathlessNode);
|
|
316
|
+
node = pathlessNode;
|
|
317
|
+
}
|
|
318
|
+
const isLeaf = (route.path || !route.children) && !route.isRoot;
|
|
319
|
+
if (isLeaf && literalEnd < length) {
|
|
320
|
+
const indexNode = createSegmentNode(node, SEGMENT_TYPE_INDEX);
|
|
321
|
+
node.index = indexNode;
|
|
322
|
+
node = indexNode;
|
|
323
|
+
}
|
|
324
|
+
node.parse = parseParams ?? null;
|
|
325
|
+
node.priority = options?.params?.priority ?? 0;
|
|
326
|
+
if (!node.route) {
|
|
327
|
+
node.data = segmentData;
|
|
328
|
+
if (isLeaf) node.route = route;
|
|
329
|
+
}
|
|
330
|
+
return [
|
|
331
|
+
node,
|
|
332
|
+
cursor,
|
|
333
|
+
segmentData
|
|
334
|
+
];
|
|
335
|
+
}
|
|
336
|
+
function sortDynamic(a, b) {
|
|
337
|
+
if (a.parse && !b.parse) return -1;
|
|
338
|
+
if (!a.parse && b.parse) return 1;
|
|
339
|
+
if (a.parse && b.parse && (a.priority || b.priority)) return b.priority - a.priority;
|
|
340
|
+
if (a.prefix && b.prefix && a.prefix !== b.prefix) {
|
|
341
|
+
if (a.prefix.startsWith(b.prefix)) return -1;
|
|
342
|
+
if (b.prefix.startsWith(a.prefix)) return 1;
|
|
343
|
+
}
|
|
344
|
+
if (a.suffix && b.suffix && a.suffix !== b.suffix) {
|
|
345
|
+
if (a.suffix.endsWith(b.suffix)) return -1;
|
|
346
|
+
if (b.suffix.endsWith(a.suffix)) return 1;
|
|
347
|
+
}
|
|
348
|
+
if (a.prefix && !b.prefix) return -1;
|
|
349
|
+
if (!a.prefix && b.prefix) return 1;
|
|
350
|
+
if (a.suffix && !b.suffix) return -1;
|
|
351
|
+
if (!a.suffix && b.suffix) return 1;
|
|
352
|
+
if (a.caseSensitive && !b.caseSensitive) return -1;
|
|
353
|
+
if (!a.caseSensitive && b.caseSensitive) return 1;
|
|
354
|
+
return 0;
|
|
355
|
+
}
|
|
356
|
+
function createSegmentNode(parent, kind = 0, caseSensitive, prefix, suffix) {
|
|
357
|
+
return {
|
|
358
|
+
kind,
|
|
359
|
+
depth: parent ? parent.depth + 1 : 0,
|
|
360
|
+
pathless: null,
|
|
361
|
+
index: null,
|
|
362
|
+
static: null,
|
|
363
|
+
staticInsensitive: null,
|
|
364
|
+
dynamic: null,
|
|
365
|
+
optional: null,
|
|
366
|
+
wildcard: null,
|
|
367
|
+
route: null,
|
|
368
|
+
data: void 0,
|
|
369
|
+
parent,
|
|
370
|
+
parse: null,
|
|
371
|
+
priority: 0,
|
|
372
|
+
caseSensitive,
|
|
373
|
+
prefix,
|
|
374
|
+
suffix
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function processRouteMasks(routeList, processedTree) {
|
|
378
|
+
const segmentTree = createSegmentNode();
|
|
379
|
+
const dynamicListsToSort = [];
|
|
380
|
+
function visit(route, start, parentNode, parentInterpolation) {
|
|
381
|
+
const [node, cursor, segments] = parseSegments(false, route, start, parentNode, dynamicListsToSort, parentInterpolation);
|
|
382
|
+
if (route.children) for (const child of route.children) visit(child, cursor, node, segments);
|
|
383
|
+
}
|
|
384
|
+
for (const route of routeList) visit(route, 1, segmentTree);
|
|
385
|
+
for (const nodes of dynamicListsToSort) nodes.sort(sortDynamic);
|
|
386
|
+
processedTree.masksTree = segmentTree;
|
|
387
|
+
processedTree.flatCache = createSieveCache(1e3);
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Take an arbitrary list of routes, create a tree from them (if it hasn't been created already), and match a path against it.
|
|
391
|
+
*/
|
|
392
|
+
function findFlatMatch(path, processedTree) {
|
|
393
|
+
path ||= "/";
|
|
394
|
+
const cached = processedTree.flatCache.get(path);
|
|
395
|
+
if (cached !== void 0) return cached;
|
|
396
|
+
const result = findMatch(path, processedTree.masksTree);
|
|
397
|
+
processedTree.flatCache.set(path, result);
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* @deprecated keep until v2 so that `router.matchRoute` can keep not caring about the actual route tree
|
|
402
|
+
*/
|
|
403
|
+
function findSingleMatch(from, caseSensitive, fuzzy, path, processedTree) {
|
|
404
|
+
from ||= "/";
|
|
405
|
+
path ||= "/";
|
|
406
|
+
const key = caseSensitive ? `case\0${from}` : from;
|
|
407
|
+
let tree = processedTree.singleCache.get(key);
|
|
408
|
+
if (!tree) {
|
|
409
|
+
tree = createSegmentNode();
|
|
410
|
+
parseSegments(caseSensitive, { from }, 1, tree);
|
|
411
|
+
processedTree.singleCache.set(key, tree);
|
|
412
|
+
}
|
|
413
|
+
return findMatch(path, tree, fuzzy);
|
|
414
|
+
}
|
|
415
|
+
function findRouteMatch(path, processedTree, fuzzy = false) {
|
|
416
|
+
const key = fuzzy ? path : `nofuzz\0${path}`;
|
|
417
|
+
const cached = processedTree.matchCache.get(key);
|
|
418
|
+
if (cached !== void 0) return cached;
|
|
419
|
+
path ||= "/";
|
|
420
|
+
let result;
|
|
421
|
+
try {
|
|
422
|
+
result = findMatch(path, processedTree.segmentTree, fuzzy);
|
|
423
|
+
} catch (err) {
|
|
424
|
+
if (err instanceof URIError) result = null;
|
|
425
|
+
else throw err;
|
|
426
|
+
}
|
|
427
|
+
if (result) result.branch = buildRouteBranch(result.route);
|
|
428
|
+
processedTree.matchCache.set(key, result);
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Processes a route tree into a segment trie for efficient path matching.
|
|
433
|
+
* Also builds lookup maps for routes by ID and by trimmed full path.
|
|
434
|
+
*/
|
|
435
|
+
function processRouteTree(routeTree, caseSensitive = false) {
|
|
436
|
+
const segmentTree = createSegmentNode();
|
|
437
|
+
const dynamicListsToSort = [];
|
|
438
|
+
const routesById = {};
|
|
439
|
+
const routesByPath = {};
|
|
440
|
+
let index = 0;
|
|
441
|
+
function visit(route, start, parentNode, parentInterpolation) {
|
|
442
|
+
route.init(index);
|
|
443
|
+
if (route.id in routesById) invariant();
|
|
444
|
+
routesById[route.id] = route;
|
|
445
|
+
if (index !== 0 && route.path) {
|
|
446
|
+
const trimmedFullPath = trimPathRight(route.fullPath);
|
|
447
|
+
if (!routesByPath[trimmedFullPath] || route.fullPath.endsWith("/")) routesByPath[trimmedFullPath] = route;
|
|
448
|
+
}
|
|
449
|
+
index++;
|
|
450
|
+
const [node, cursor, segments] = parseSegments(caseSensitive, route, start, parentNode, dynamicListsToSort, parentInterpolation);
|
|
451
|
+
route._interpolation = segments;
|
|
452
|
+
if (route.children) for (const child of route.children) visit(child, cursor, node, segments);
|
|
453
|
+
}
|
|
454
|
+
visit(routeTree, 1, segmentTree);
|
|
455
|
+
for (const nodes of dynamicListsToSort) nodes.sort(sortDynamic);
|
|
456
|
+
return {
|
|
457
|
+
processedTree: {
|
|
458
|
+
segmentTree,
|
|
459
|
+
singleCache: createSieveCache(1e3),
|
|
460
|
+
matchCache: createSieveCache(1e3),
|
|
461
|
+
flatCache: null,
|
|
462
|
+
masksTree: null
|
|
463
|
+
},
|
|
464
|
+
routesById,
|
|
465
|
+
routesByPath
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
function findMatch(path, segmentTree, fuzzy = false) {
|
|
469
|
+
const parts = path.split("/");
|
|
470
|
+
const leaf = getNodeMatch(path, parts, segmentTree, fuzzy);
|
|
471
|
+
if (!leaf) return null;
|
|
472
|
+
const [rawParams] = extractParams(path, parts, leaf);
|
|
473
|
+
return {
|
|
474
|
+
route: leaf.node.route,
|
|
475
|
+
rawParams
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* This function is "resumable":
|
|
480
|
+
* - the `leaf` input can contain `extract` and `rawParams` properties from a previous `extractParams` call
|
|
481
|
+
* - the returned `state` can be passed back as `extract` in a future call to continue extracting params from where we left off
|
|
482
|
+
*
|
|
483
|
+
* Inputs are *not* mutated.
|
|
484
|
+
*/
|
|
485
|
+
function extractParams(path, parts, leaf) {
|
|
486
|
+
const list = buildBranch(leaf.node);
|
|
487
|
+
const names = leaf.node.data && getParamNames(leaf.node.data);
|
|
488
|
+
const rawParams = Object.create(null);
|
|
489
|
+
/** which segment of the path we're currently processing */
|
|
490
|
+
let partIndex = leaf.extract?.part ?? 0;
|
|
491
|
+
/** which node of the route tree branch we're currently processing */
|
|
492
|
+
let nodeIndex = leaf.extract?.node ?? 0;
|
|
493
|
+
/** index of the 1st character of the segment we're processing in the path string */
|
|
494
|
+
let pathIndex = leaf.extract?.path ?? 0;
|
|
495
|
+
/** Next original parameter name, independent of pathless/static nodes. */
|
|
496
|
+
let paramIndex = leaf.extract?.param ?? 0;
|
|
497
|
+
for (; nodeIndex < list.length; partIndex++, nodeIndex++, pathIndex++) {
|
|
498
|
+
const node = list[nodeIndex];
|
|
499
|
+
if (node.kind === SEGMENT_TYPE_INDEX) break;
|
|
500
|
+
if (node.kind === SEGMENT_TYPE_PATHLESS) {
|
|
501
|
+
partIndex--;
|
|
502
|
+
pathIndex--;
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
const part = parts[partIndex];
|
|
506
|
+
const currentPathIndex = pathIndex;
|
|
507
|
+
if (part) pathIndex += part.length;
|
|
508
|
+
if (node.kind === 1 || node.kind === 3) {
|
|
509
|
+
const name = names[paramIndex++];
|
|
510
|
+
if (node.kind === 3 && leaf.skipped & 1 << nodeIndex) {
|
|
511
|
+
partIndex--;
|
|
512
|
+
pathIndex = currentPathIndex - 1;
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
const value = node.suffix || node.prefix ? part.substring(node.prefix.length, part.length - node.suffix.length) : part;
|
|
516
|
+
if (value || node.kind === 1) rawParams[name] = decodeURIComponent(value);
|
|
517
|
+
} else if (node.kind === 2) {
|
|
518
|
+
const n = node;
|
|
519
|
+
const value = path.substring(currentPathIndex + n.prefix.length, path.length - n.suffix.length);
|
|
520
|
+
const splat = decodeURIComponent(value);
|
|
521
|
+
rawParams["*"] = splat;
|
|
522
|
+
rawParams._splat = splat;
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
if (leaf.rawParams) Object.assign(rawParams, leaf.rawParams);
|
|
527
|
+
return [rawParams, {
|
|
528
|
+
part: partIndex,
|
|
529
|
+
node: nodeIndex,
|
|
530
|
+
path: pathIndex,
|
|
531
|
+
param: paramIndex
|
|
532
|
+
}];
|
|
533
|
+
}
|
|
534
|
+
function buildRouteBranch(route) {
|
|
535
|
+
const list = [route];
|
|
536
|
+
while (route.parentRoute) {
|
|
537
|
+
route = route.parentRoute;
|
|
538
|
+
list.push(route);
|
|
539
|
+
}
|
|
540
|
+
list.reverse();
|
|
541
|
+
return list;
|
|
542
|
+
}
|
|
543
|
+
function buildBranch(node) {
|
|
544
|
+
const list = Array(node.depth + 1);
|
|
545
|
+
do {
|
|
546
|
+
list[node.depth] = node;
|
|
547
|
+
node = node.parent;
|
|
548
|
+
} while (node);
|
|
549
|
+
return list;
|
|
550
|
+
}
|
|
551
|
+
function getNodeMatch(path, parts, segmentTree, fuzzy) {
|
|
552
|
+
if (path === "/" && segmentTree.index) return {
|
|
553
|
+
node: segmentTree.index,
|
|
554
|
+
skipped: 0
|
|
555
|
+
};
|
|
556
|
+
const trailingSlash = !last(parts);
|
|
557
|
+
const pathIsIndex = trailingSlash && path !== "/";
|
|
558
|
+
const partsLength = parts.length - (trailingSlash ? 1 : 0);
|
|
559
|
+
const stack = [{
|
|
560
|
+
node: segmentTree,
|
|
561
|
+
index: 1,
|
|
562
|
+
skipped: 0,
|
|
563
|
+
statics: 0,
|
|
564
|
+
dynamics: 0,
|
|
565
|
+
optionals: 0
|
|
566
|
+
}];
|
|
567
|
+
let bestFuzzy = null;
|
|
568
|
+
let bestMatch = null;
|
|
569
|
+
while (stack.length) {
|
|
570
|
+
const frame = stack.pop();
|
|
571
|
+
const { node, index, skipped, statics, dynamics, optionals } = frame;
|
|
572
|
+
let { extract, rawParams } = frame;
|
|
573
|
+
if (node.kind === 2 && node.route && !isFrameMoreSpecific(bestMatch, frame)) continue;
|
|
574
|
+
if (node.parse) {
|
|
575
|
+
if (!validateParseParams(path, parts, frame)) continue;
|
|
576
|
+
rawParams = frame.rawParams;
|
|
577
|
+
extract = frame.extract;
|
|
578
|
+
}
|
|
579
|
+
if (fuzzy && node.route && node.kind !== SEGMENT_TYPE_INDEX && isFrameMoreSpecific(bestFuzzy, frame)) bestFuzzy = frame;
|
|
580
|
+
const isBeyondPath = index === partsLength;
|
|
581
|
+
if (isBeyondPath) {
|
|
582
|
+
if (node.route && (!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX || node.kind === 2) && isFrameMoreSpecific(bestMatch, frame)) bestMatch = frame;
|
|
583
|
+
if (!node.optional && !node.wildcard && !node.index && !node.pathless) continue;
|
|
584
|
+
}
|
|
585
|
+
const part = isBeyondPath ? void 0 : parts[index];
|
|
586
|
+
let lowerPart;
|
|
587
|
+
if (isBeyondPath && node.index) {
|
|
588
|
+
const indexFrame = {
|
|
589
|
+
node: node.index,
|
|
590
|
+
index,
|
|
591
|
+
skipped,
|
|
592
|
+
statics,
|
|
593
|
+
dynamics,
|
|
594
|
+
optionals,
|
|
595
|
+
extract,
|
|
596
|
+
rawParams
|
|
597
|
+
};
|
|
598
|
+
let indexValid = true;
|
|
599
|
+
if (node.index.parse) {
|
|
600
|
+
if (!validateParseParams(path, parts, indexFrame)) indexValid = false;
|
|
601
|
+
}
|
|
602
|
+
if (indexValid) {
|
|
603
|
+
if (!dynamics && !optionals && !skipped && isPerfectStaticMatch(statics, partsLength)) return indexFrame;
|
|
604
|
+
if (isFrameMoreSpecific(bestMatch, indexFrame)) bestMatch = indexFrame;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (node.wildcard) for (let i = node.wildcard.length - 1; i >= 0; i--) {
|
|
608
|
+
const segment = node.wildcard[i];
|
|
609
|
+
const { prefix, suffix } = segment;
|
|
610
|
+
if (prefix) {
|
|
611
|
+
if (isBeyondPath) continue;
|
|
612
|
+
if (!(segment.caseSensitive ? part : lowerPart ??= part.toLowerCase()).startsWith(prefix)) continue;
|
|
613
|
+
}
|
|
614
|
+
if (suffix) {
|
|
615
|
+
if (isBeyondPath) continue;
|
|
616
|
+
const end = parts.slice(index).join("/");
|
|
617
|
+
const suffixPart = end.slice(-suffix.length);
|
|
618
|
+
if ((segment.caseSensitive ? suffixPart : suffixPart.toLowerCase()) !== suffix || end.length - suffix.length < prefix.length) continue;
|
|
619
|
+
}
|
|
620
|
+
stack.push({
|
|
621
|
+
node: segment,
|
|
622
|
+
index: partsLength,
|
|
623
|
+
skipped,
|
|
624
|
+
statics,
|
|
625
|
+
dynamics,
|
|
626
|
+
optionals,
|
|
627
|
+
extract,
|
|
628
|
+
rawParams
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
if (node.optional) {
|
|
632
|
+
const nextSkipped = skipped | 1 << node.depth + 1;
|
|
633
|
+
for (let i = node.optional.length - 1; i >= 0; i--) {
|
|
634
|
+
const segment = node.optional[i];
|
|
635
|
+
stack.push({
|
|
636
|
+
node: segment,
|
|
637
|
+
index,
|
|
638
|
+
skipped: nextSkipped,
|
|
639
|
+
statics,
|
|
640
|
+
dynamics,
|
|
641
|
+
optionals,
|
|
642
|
+
extract,
|
|
643
|
+
rawParams
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
if (!isBeyondPath) for (let i = node.optional.length - 1; i >= 0; i--) {
|
|
647
|
+
const segment = node.optional[i];
|
|
648
|
+
const { prefix, suffix } = segment;
|
|
649
|
+
if (prefix || suffix) {
|
|
650
|
+
const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
|
|
651
|
+
if (prefix && !casePart.startsWith(prefix)) continue;
|
|
652
|
+
if (suffix && casePart.indexOf(suffix, casePart.length - suffix.length) < prefix.length) continue;
|
|
653
|
+
}
|
|
654
|
+
stack.push({
|
|
655
|
+
node: segment,
|
|
656
|
+
index: index + 1,
|
|
657
|
+
skipped,
|
|
658
|
+
statics,
|
|
659
|
+
dynamics,
|
|
660
|
+
optionals: optionals + segmentScore(partsLength, index),
|
|
661
|
+
extract,
|
|
662
|
+
rawParams
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
if (!isBeyondPath && node.dynamic && part) for (let i = node.dynamic.length - 1; i >= 0; i--) {
|
|
667
|
+
const segment = node.dynamic[i];
|
|
668
|
+
const { prefix, suffix } = segment;
|
|
669
|
+
if (prefix || suffix) {
|
|
670
|
+
const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
|
|
671
|
+
if (prefix && !casePart.startsWith(prefix)) continue;
|
|
672
|
+
if (suffix && casePart.indexOf(suffix, casePart.length - suffix.length) < prefix.length) continue;
|
|
673
|
+
}
|
|
674
|
+
stack.push({
|
|
675
|
+
node: segment,
|
|
676
|
+
index: index + 1,
|
|
677
|
+
skipped,
|
|
678
|
+
statics,
|
|
679
|
+
dynamics: dynamics + segmentScore(partsLength, index),
|
|
680
|
+
optionals,
|
|
681
|
+
extract,
|
|
682
|
+
rawParams
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
if (!isBeyondPath && node.staticInsensitive) {
|
|
686
|
+
const match = node.staticInsensitive.get(lowerPart ??= part.toLowerCase());
|
|
687
|
+
if (match) stack.push({
|
|
688
|
+
node: match,
|
|
689
|
+
index: index + 1,
|
|
690
|
+
skipped,
|
|
691
|
+
statics: statics + segmentScore(partsLength, index),
|
|
692
|
+
dynamics,
|
|
693
|
+
optionals,
|
|
694
|
+
extract,
|
|
695
|
+
rawParams
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
if (!isBeyondPath && node.static) {
|
|
699
|
+
const match = node.static.get(part);
|
|
700
|
+
if (match) stack.push({
|
|
701
|
+
node: match,
|
|
702
|
+
index: index + 1,
|
|
703
|
+
skipped,
|
|
704
|
+
statics: statics + segmentScore(partsLength, index),
|
|
705
|
+
dynamics,
|
|
706
|
+
optionals,
|
|
707
|
+
extract,
|
|
708
|
+
rawParams
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
if (node.pathless) for (let i = node.pathless.length - 1; i >= 0; i--) {
|
|
712
|
+
const segment = node.pathless[i];
|
|
713
|
+
stack.push({
|
|
714
|
+
node: segment,
|
|
715
|
+
index,
|
|
716
|
+
skipped,
|
|
717
|
+
statics,
|
|
718
|
+
dynamics,
|
|
719
|
+
optionals,
|
|
720
|
+
extract,
|
|
721
|
+
rawParams
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (bestMatch) return bestMatch;
|
|
726
|
+
if (fuzzy && bestFuzzy) {
|
|
727
|
+
let sliceIndex = bestFuzzy.index;
|
|
728
|
+
for (let i = 0; i < bestFuzzy.index; i++) sliceIndex += parts[i].length;
|
|
729
|
+
const splat = sliceIndex === path.length ? "/" : path.slice(sliceIndex);
|
|
730
|
+
bestFuzzy.rawParams ??= Object.create(null);
|
|
731
|
+
bestFuzzy.rawParams["**"] = decodeURIComponent(splat);
|
|
732
|
+
return bestFuzzy;
|
|
733
|
+
}
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
736
|
+
function segmentScore(partsLength, index) {
|
|
737
|
+
return 2 ** (partsLength - index - 1);
|
|
738
|
+
}
|
|
739
|
+
function isPerfectStaticMatch(statics, partsLength) {
|
|
740
|
+
return statics === 2 ** (partsLength - 1) - 1;
|
|
741
|
+
}
|
|
742
|
+
function validateParseParams(path, parts, frame) {
|
|
743
|
+
let rawParams;
|
|
744
|
+
let state;
|
|
745
|
+
try {
|
|
746
|
+
[rawParams, state] = extractParams(path, parts, frame);
|
|
747
|
+
} catch {
|
|
748
|
+
return null;
|
|
749
|
+
}
|
|
750
|
+
frame.rawParams = rawParams;
|
|
751
|
+
frame.extract = state;
|
|
752
|
+
if (!frame.node.parse) return true;
|
|
753
|
+
try {
|
|
754
|
+
if (frame.node.parse(rawParams) === false) return null;
|
|
755
|
+
} catch {}
|
|
756
|
+
return true;
|
|
757
|
+
}
|
|
758
|
+
function isFrameMoreSpecific(prev, next) {
|
|
759
|
+
if (!prev) return true;
|
|
760
|
+
return next.statics > prev.statics || next.statics === prev.statics && (next.dynamics > prev.dynamics || next.dynamics === prev.dynamics && (next.optionals > prev.optionals || next.optionals === prev.optionals && ((next.node.kind === SEGMENT_TYPE_INDEX) > (prev.node.kind === SEGMENT_TYPE_INDEX) || next.node.kind === SEGMENT_TYPE_INDEX === (prev.node.kind === SEGMENT_TYPE_INDEX) && next.node.depth > prev.node.depth)));
|
|
761
|
+
}
|
|
762
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.js
|
|
763
|
+
function getSafeSessionStorage() {
|
|
764
|
+
try {
|
|
765
|
+
return sessionStorage;
|
|
766
|
+
} catch {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
var storageKey = "tsr-scroll-restoration-v1_3";
|
|
771
|
+
getSafeSessionStorage();
|
|
772
|
+
/**
|
|
773
|
+
* The default `getKey` function for `useScrollRestoration`.
|
|
774
|
+
* It returns the `key` from the location state or the `href` of the location.
|
|
775
|
+
*
|
|
776
|
+
* The `location.href` is used as a fallback to support the use case where the location state is not available like the initial render.
|
|
777
|
+
*/
|
|
778
|
+
var defaultGetScrollRestorationKey = (location) => {
|
|
779
|
+
return location.state.__TSR_key || location.href;
|
|
780
|
+
};
|
|
781
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/qss.js
|
|
782
|
+
/**
|
|
783
|
+
* Program is a reimplementation of the `qss` package:
|
|
784
|
+
* Copyright (c) Luke Edwards luke.edwards05@gmail.com, MIT License
|
|
785
|
+
* https://github.com/lukeed/qss/blob/master/license.md
|
|
786
|
+
*
|
|
787
|
+
* This reimplementation uses modern browser APIs
|
|
788
|
+
* (namely URLSearchParams) and TypeScript while still
|
|
789
|
+
* maintaining the original functionality and interface.
|
|
790
|
+
*
|
|
791
|
+
* Update: this implementation has also been mangled to
|
|
792
|
+
* fit exactly our use-case (single value per key in encoding).
|
|
793
|
+
*/
|
|
794
|
+
/**
|
|
795
|
+
* Encodes an object into a query string.
|
|
796
|
+
* @param obj - The object to encode into a query string.
|
|
797
|
+
* @param stringify - An optional custom stringify function.
|
|
798
|
+
* @returns The encoded query string.
|
|
799
|
+
* @example
|
|
800
|
+
* ```
|
|
801
|
+
* // Example input: encode({ token: 'foo', key: 'value' })
|
|
802
|
+
* // Expected output: "token=foo&key=value"
|
|
803
|
+
* ```
|
|
804
|
+
*/
|
|
805
|
+
function encode(obj, stringify = String) {
|
|
806
|
+
let result;
|
|
807
|
+
for (const key in obj) {
|
|
808
|
+
const val = obj[key];
|
|
809
|
+
if (val !== void 0) (result ||= new URLSearchParams()).set(key, stringify(val));
|
|
810
|
+
}
|
|
811
|
+
return result ? result.toString() : "";
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Converts a string value to its appropriate type (string, number, boolean).
|
|
815
|
+
* @param mix - The string value to convert.
|
|
816
|
+
* @returns The converted value.
|
|
817
|
+
* @example
|
|
818
|
+
* // Example input: toValue("123")
|
|
819
|
+
* // Expected output: 123
|
|
820
|
+
*/
|
|
821
|
+
function toValue(str) {
|
|
822
|
+
if (!str) return "";
|
|
823
|
+
if (str === "false") return false;
|
|
824
|
+
if (str === "true") return true;
|
|
825
|
+
return +str * 0 === 0 && +str + "" === str ? +str : str;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Decodes a query string into an object.
|
|
829
|
+
* @param str - The query string to decode.
|
|
830
|
+
* @returns The decoded key-value pairs in an object format.
|
|
831
|
+
* @example
|
|
832
|
+
* // Example input: decode("token=foo&key=value")
|
|
833
|
+
* // Expected output: { "token": "foo", "key": "value" }
|
|
834
|
+
*/
|
|
835
|
+
function decode(str) {
|
|
836
|
+
const searchParams = new URLSearchParams(str);
|
|
837
|
+
const result = Object.create(null);
|
|
838
|
+
for (const [key, value] of searchParams.entries()) {
|
|
839
|
+
const previousValue = result[key];
|
|
840
|
+
if (previousValue == null) result[key] = toValue(value);
|
|
841
|
+
else if (Array.isArray(previousValue)) previousValue.push(toValue(value));
|
|
842
|
+
else result[key] = [previousValue, toValue(value)];
|
|
843
|
+
}
|
|
844
|
+
return result;
|
|
845
|
+
}
|
|
846
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/searchParams.js
|
|
847
|
+
var jsonStart = /^(?:\s|["[{\d-]|fa|nu|tr)/;
|
|
848
|
+
/** Default `parseSearch` that strips leading '?' and JSON-parses values. */
|
|
849
|
+
var defaultParseSearch = parseSearchWith(JSON.parse);
|
|
850
|
+
/** Default `stringifySearch` using JSON.stringify for complex values. */
|
|
851
|
+
var defaultStringifySearch = stringifySearchWith(JSON.stringify, JSON.parse);
|
|
852
|
+
/**
|
|
853
|
+
* Build a `parseSearch` function using a provided JSON-like parser.
|
|
854
|
+
*
|
|
855
|
+
* The returned function strips a leading `?`, decodes values, and attempts to
|
|
856
|
+
* JSON-parse string values using the given `parser`.
|
|
857
|
+
*
|
|
858
|
+
* @param parser Function to parse a string value (e.g. `JSON.parse`).
|
|
859
|
+
* @returns A `parseSearch` function compatible with `Router` options.
|
|
860
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization
|
|
861
|
+
*/
|
|
862
|
+
function parseSearchWith(parser) {
|
|
863
|
+
const isJsonParser = parser === JSON.parse;
|
|
864
|
+
return (searchStr) => {
|
|
865
|
+
if (searchStr[0] === "?") searchStr = searchStr.slice(1);
|
|
866
|
+
const query = decode(searchStr);
|
|
867
|
+
for (const key in query) {
|
|
868
|
+
const value = query[key];
|
|
869
|
+
if (typeof value === "string") {
|
|
870
|
+
if (isJsonParser && !jsonStart.test(value)) continue;
|
|
871
|
+
try {
|
|
872
|
+
query[key] = parser(value);
|
|
873
|
+
} catch (_err) {}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
return query;
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Build a `stringifySearch` function using a provided serializer.
|
|
881
|
+
*
|
|
882
|
+
* Non-primitive values are serialized with `stringify`. If a `parser` is
|
|
883
|
+
* supplied, string values that are parseable are re-serialized to ensure
|
|
884
|
+
* symmetry with `parseSearch`.
|
|
885
|
+
*
|
|
886
|
+
* @param stringify Function to serialize a value (e.g. `JSON.stringify`).
|
|
887
|
+
* @param parser Optional parser to detect parseable strings.
|
|
888
|
+
* @returns A `stringifySearch` function compatible with `Router` options.
|
|
889
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization
|
|
890
|
+
*/
|
|
891
|
+
function stringifySearchWith(stringify, parser) {
|
|
892
|
+
const isJsonParser = parser === JSON.parse;
|
|
893
|
+
function stringifyValue(val) {
|
|
894
|
+
if (val && typeof val === "object") try {
|
|
895
|
+
return stringify(val);
|
|
896
|
+
} catch (_err) {}
|
|
897
|
+
else if (parser && typeof val === "string") {
|
|
898
|
+
if (isJsonParser && !jsonStart.test(val)) return val;
|
|
899
|
+
try {
|
|
900
|
+
parser(val);
|
|
901
|
+
return stringify(val);
|
|
902
|
+
} catch (_err) {}
|
|
903
|
+
}
|
|
904
|
+
return val;
|
|
905
|
+
}
|
|
906
|
+
return (search) => {
|
|
907
|
+
const searchStr = encode(search, stringifyValue);
|
|
908
|
+
return searchStr ? `?${searchStr}` : "";
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/rewrite.js
|
|
912
|
+
/** Create a rewrite pair that strips/adds a basepath on input/output. */
|
|
913
|
+
function rewriteBasepath(basepath, caseSensitive, rewrite) {
|
|
914
|
+
const trimmedBasepath = trimPath(basepath);
|
|
915
|
+
const normalizedBasepath = `/${trimmedBasepath}`;
|
|
916
|
+
const checkBasepath = caseSensitive ? normalizedBasepath : normalizedBasepath.toLowerCase();
|
|
917
|
+
const checkBasepathWithSlash = `${checkBasepath}/`;
|
|
918
|
+
const basepathRewrite = {
|
|
919
|
+
input: ({ url }) => {
|
|
920
|
+
const pathname = caseSensitive ? url.pathname : url.pathname.toLowerCase();
|
|
921
|
+
if (pathname === checkBasepath) url.pathname = "/";
|
|
922
|
+
else if (pathname.startsWith(checkBasepathWithSlash)) url.pathname = url.pathname.slice(normalizedBasepath.length);
|
|
923
|
+
return url;
|
|
924
|
+
},
|
|
925
|
+
output: ({ url }) => {
|
|
926
|
+
url.pathname = cleanPath(`/${trimmedBasepath}${url.pathname}`);
|
|
927
|
+
return url;
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
return rewrite ? {
|
|
931
|
+
input: ({ url }) => executeRewriteInput(rewrite, basepathRewrite.input({ url })),
|
|
932
|
+
output: ({ url }) => basepathRewrite.output({ url: executeRewriteOutput(rewrite, url) })
|
|
933
|
+
} : basepathRewrite;
|
|
934
|
+
}
|
|
935
|
+
/** Execute a location input rewrite if provided. */
|
|
936
|
+
function executeRewriteInput(rewrite, url) {
|
|
937
|
+
const res = rewrite?.input?.({ url });
|
|
938
|
+
if (res) {
|
|
939
|
+
if (typeof res === "string") return new URL(res);
|
|
940
|
+
else if (res instanceof URL) return res;
|
|
941
|
+
}
|
|
942
|
+
return url;
|
|
943
|
+
}
|
|
944
|
+
/** Execute a location output rewrite if provided. */
|
|
945
|
+
function executeRewriteOutput(rewrite, url) {
|
|
946
|
+
const res = rewrite?.output?.({ url });
|
|
947
|
+
if (res) {
|
|
948
|
+
if (typeof res === "string") return new URL(res);
|
|
949
|
+
else if (res instanceof URL) return res;
|
|
950
|
+
}
|
|
951
|
+
return url;
|
|
952
|
+
}
|
|
953
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/stores.js
|
|
954
|
+
/** SSR non-reactive createMutableStore */
|
|
955
|
+
function createNonReactiveMutableStore(initialValue) {
|
|
956
|
+
let value = initialValue;
|
|
957
|
+
return {
|
|
958
|
+
get() {
|
|
959
|
+
return value;
|
|
960
|
+
},
|
|
961
|
+
set(nextOrUpdater) {
|
|
962
|
+
value = functionalUpdate(nextOrUpdater, value);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
/** SSR non-reactive createReadonlyStore */
|
|
967
|
+
function createNonReactiveReadonlyStore(read) {
|
|
968
|
+
return { get() {
|
|
969
|
+
return read();
|
|
970
|
+
} };
|
|
971
|
+
}
|
|
972
|
+
function createRouterStores(initialLocation, config) {
|
|
973
|
+
const { createMutableStore, createReadonlyStore, batch } = config;
|
|
974
|
+
const byRoute = /* @__PURE__ */ new Map();
|
|
975
|
+
const status = createMutableStore("idle");
|
|
976
|
+
const location = createMutableStore(initialLocation);
|
|
977
|
+
const resolvedLocation = createMutableStore(void 0);
|
|
978
|
+
const ids = createMutableStore([]);
|
|
979
|
+
const matches = createReadonlyStore(() => ids.get().map((id) => byRoute.get(id).get()));
|
|
980
|
+
const __store = createReadonlyStore(() => ({
|
|
981
|
+
status: status.get(),
|
|
982
|
+
isLoading: status.get() === "pending",
|
|
983
|
+
matches: matches.get(),
|
|
984
|
+
location: location.get(),
|
|
985
|
+
resolvedLocation: resolvedLocation.get()
|
|
986
|
+
}));
|
|
987
|
+
function getMatchStore(routeId) {
|
|
988
|
+
let matchStore = byRoute.get(routeId);
|
|
989
|
+
if (!matchStore) {
|
|
990
|
+
matchStore = createMutableStore(void 0);
|
|
991
|
+
byRoute.set(routeId, matchStore);
|
|
992
|
+
}
|
|
993
|
+
return matchStore;
|
|
994
|
+
}
|
|
995
|
+
const store = {
|
|
996
|
+
status,
|
|
997
|
+
location,
|
|
998
|
+
resolvedLocation,
|
|
999
|
+
ids,
|
|
1000
|
+
matches,
|
|
1001
|
+
byRoute,
|
|
1002
|
+
__store,
|
|
1003
|
+
getMatchStore,
|
|
1004
|
+
setMatches
|
|
1005
|
+
};
|
|
1006
|
+
function setMatches(nextMatches) {
|
|
1007
|
+
const previousIds = ids.get();
|
|
1008
|
+
const nextIds = nextMatches.map((match) => match.routeId);
|
|
1009
|
+
batch(() => {
|
|
1010
|
+
if (!arraysEqual(previousIds, nextIds)) ids.set(nextIds);
|
|
1011
|
+
for (const id of previousIds) if (!nextIds.includes(id)) byRoute.get(id).set(() => void 0);
|
|
1012
|
+
for (const nextMatch of nextMatches) {
|
|
1013
|
+
const matchStore = getMatchStore(nextMatch.routeId);
|
|
1014
|
+
if (matchStore.get() !== nextMatch) matchStore.set(nextMatch);
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
return store;
|
|
1019
|
+
}
|
|
1020
|
+
// ../../node_modules/.bun/@tanstack+history@1.162.5/node_modules/@tanstack/history/dist/esm/index.js
|
|
1021
|
+
var stateIndexKey = "__TSR_index";
|
|
1022
|
+
/**
|
|
1023
|
+
* Turn protocol-relative inputs such as "//evil.example" into paths
|
|
1024
|
+
* such as "/evil.example", keeping navigation on the current origin.
|
|
1025
|
+
*
|
|
1026
|
+
* For HTTP(S) URLs, WHATWG parsing ignores leading C0 controls and spaces,
|
|
1027
|
+
* removes tabs/newlines, and treats backslashes as slashes, so inputs like
|
|
1028
|
+
* "/\evil.example" also need normalization. This only allocates when those
|
|
1029
|
+
* rules would make the input protocol-relative.
|
|
1030
|
+
*/
|
|
1031
|
+
var protocolRelativePrefix = /^[\x00-\x20]*(?:[\\/][\t\n\r]*){2,}/;
|
|
1032
|
+
function normalizeProtocolRelative(url) {
|
|
1033
|
+
const match = protocolRelativePrefix.exec(url);
|
|
1034
|
+
return match ? "/" + url.slice(match[0].length) : url;
|
|
1035
|
+
}
|
|
1036
|
+
function normalizeHref(href) {
|
|
1037
|
+
if (/[\x00-\x1f\x7f]/.test(href)) href = href.replace(/[\x00-\x1f\x7f]/g, (character) => " \n\r".includes(character) ? "" : encodeURIComponent(character));
|
|
1038
|
+
return normalizeProtocolRelative(href);
|
|
1039
|
+
}
|
|
1040
|
+
var noop = () => {};
|
|
1041
|
+
var ServerHistory = class {
|
|
1042
|
+
constructor(location) {
|
|
1043
|
+
this.location = location;
|
|
1044
|
+
}
|
|
1045
|
+
get length() {
|
|
1046
|
+
return 1;
|
|
1047
|
+
}
|
|
1048
|
+
get subscribers() {
|
|
1049
|
+
return this._subscribers ??= /* @__PURE__ */ new Set();
|
|
1050
|
+
}
|
|
1051
|
+
subscribe() {
|
|
1052
|
+
return noop;
|
|
1053
|
+
}
|
|
1054
|
+
push() {}
|
|
1055
|
+
replace() {}
|
|
1056
|
+
go() {}
|
|
1057
|
+
back() {}
|
|
1058
|
+
forward() {}
|
|
1059
|
+
canGoBack() {
|
|
1060
|
+
return false;
|
|
1061
|
+
}
|
|
1062
|
+
createHref(href) {
|
|
1063
|
+
return normalizeHref(href);
|
|
1064
|
+
}
|
|
1065
|
+
block() {
|
|
1066
|
+
return noop;
|
|
1067
|
+
}
|
|
1068
|
+
flush() {}
|
|
1069
|
+
destroy() {}
|
|
1070
|
+
notify() {}
|
|
1071
|
+
_getBlockers() {
|
|
1072
|
+
return [];
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
/** A fixed request location; server navigation is a no-op. */
|
|
1076
|
+
function createServerHistory(href) {
|
|
1077
|
+
return new ServerHistory(parseHref(href, void 0));
|
|
1078
|
+
}
|
|
1079
|
+
function parseHref(href, state) {
|
|
1080
|
+
const sanitizedHref = normalizeHref(href);
|
|
1081
|
+
const hashIndex = sanitizedHref.indexOf("#");
|
|
1082
|
+
const searchIndex = sanitizedHref.indexOf("?");
|
|
1083
|
+
if (!state) {
|
|
1084
|
+
const key = createRandomKey();
|
|
1085
|
+
state = {
|
|
1086
|
+
[stateIndexKey]: 0,
|
|
1087
|
+
key,
|
|
1088
|
+
__TSR_key: key
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
return {
|
|
1092
|
+
href: sanitizedHref,
|
|
1093
|
+
pathname: sanitizedHref.slice(0, hashIndex > -1 ? searchIndex > -1 ? Math.min(hashIndex, searchIndex) : hashIndex : searchIndex > -1 ? searchIndex : sanitizedHref.length),
|
|
1094
|
+
hash: hashIndex > -1 ? sanitizedHref.slice(hashIndex) : "",
|
|
1095
|
+
search: searchIndex > -1 ? sanitizedHref.slice(searchIndex, hashIndex === -1 ? void 0 : hashIndex) : "",
|
|
1096
|
+
state
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
function createRandomKey() {
|
|
1100
|
+
return (Math.random() + 1).toString(36).slice(7);
|
|
1101
|
+
}
|
|
1102
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/router.js
|
|
1103
|
+
function isExternalUrl(url, origin) {
|
|
1104
|
+
return url.protocol !== "http:" && url.protocol !== "https:" || url.origin !== origin || !!url.username || !!url.password;
|
|
1105
|
+
}
|
|
1106
|
+
function getUrlPath(url) {
|
|
1107
|
+
return url.pathname + url.search + url.hash;
|
|
1108
|
+
}
|
|
1109
|
+
function routeNeedsLoad(route) {
|
|
1110
|
+
return route.options.loader || route.options.beforeLoad || route.lazyFn || route.options.component?.preload || route.options.pendingComponent?.preload;
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Compute whether path, href or hash changed between previous and current
|
|
1114
|
+
* resolved locations.
|
|
1115
|
+
*/
|
|
1116
|
+
function getLocationChangeInfo(location, resolvedLocation) {
|
|
1117
|
+
return {
|
|
1118
|
+
fromLocation: resolvedLocation,
|
|
1119
|
+
toLocation: location,
|
|
1120
|
+
pathChanged: resolvedLocation?.pathname !== location.pathname,
|
|
1121
|
+
hrefChanged: resolvedLocation?.href !== location.href,
|
|
1122
|
+
hashChanged: resolvedLocation?.hash !== location.hash
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
function lifecycleEnd(matches) {
|
|
1126
|
+
return matches.findIndex((match) => match.status === "error" || match.status === "notFound" || match._notFound) + 1;
|
|
1127
|
+
}
|
|
1128
|
+
/** Run route lifecycle callbacks in leave/enter/stay phases. */
|
|
1129
|
+
function runRouteLifecycle(router, previous, matches, previousEnd, nextEnd, owner) {
|
|
1130
|
+
if (previousEnd) previous = previous.slice(0, previousEnd);
|
|
1131
|
+
if (nextEnd) matches = matches.slice(0, nextEnd);
|
|
1132
|
+
for (const match of previous) {
|
|
1133
|
+
if (owner && router._tx !== owner) return;
|
|
1134
|
+
if (!matches.some((candidate) => candidate.routeId === match.routeId)) router.routesById[match.routeId].options.onLeave?.(match);
|
|
1135
|
+
}
|
|
1136
|
+
for (const match of matches) {
|
|
1137
|
+
if (owner && router._tx !== owner) return;
|
|
1138
|
+
router.routesById[match.routeId].options[previous.some((candidate) => candidate.routeId === match.routeId) ? "onStay" : "onEnter"]?.(match);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Core, framework-agnostic router engine that powers TanStack Router.
|
|
1143
|
+
*
|
|
1144
|
+
* Provides navigation, matching, loading, preloading, caching and event APIs
|
|
1145
|
+
* used by framework adapters (React/Solid). Prefer framework helpers like
|
|
1146
|
+
* `createRouter` in app code.
|
|
1147
|
+
*
|
|
1148
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType
|
|
1149
|
+
*/
|
|
1150
|
+
var RouterCore = class {
|
|
1151
|
+
/**
|
|
1152
|
+
* @deprecated Use the `createRouter` function instead
|
|
1153
|
+
*/
|
|
1154
|
+
constructor(options, getStoreConfig) {
|
|
1155
|
+
this.tempLocationKey = `${Math.round(Math.random() * 1e7)}`;
|
|
1156
|
+
this._scroll = { n: true };
|
|
1157
|
+
this.subscribers = /* @__PURE__ */ new Set();
|
|
1158
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
1159
|
+
this._committed = [];
|
|
1160
|
+
this.startTransition = async (fn) => {
|
|
1161
|
+
fn();
|
|
1162
|
+
return false;
|
|
1163
|
+
};
|
|
1164
|
+
this.update = (newOptions) => {
|
|
1165
|
+
const prevOptions = this.options;
|
|
1166
|
+
this.options = {
|
|
1167
|
+
...prevOptions,
|
|
1168
|
+
...newOptions
|
|
1169
|
+
};
|
|
1170
|
+
this.isServer = this.options.isServer ?? true ?? typeof document === "undefined";
|
|
1171
|
+
this.protocolAllowlist = new Set(this.options.protocolAllowlist);
|
|
1172
|
+
if (!this.history || this.options.history && this.options.history !== this.history) {
|
|
1173
|
+
if (!this.options.history) {} else this.history = this.options.history;
|
|
1174
|
+
}
|
|
1175
|
+
this.origin = this.options.origin;
|
|
1176
|
+
if (!this.origin) this.origin = "http://localhost";
|
|
1177
|
+
const nextBasepath = this.options.basepath ?? "/";
|
|
1178
|
+
const nextRewriteOption = this.options.rewrite;
|
|
1179
|
+
const rewriteChanged = this.basepath !== nextBasepath || prevOptions?.rewrite !== nextRewriteOption || prevOptions?.caseSensitive !== this.options.caseSensitive;
|
|
1180
|
+
if (rewriteChanged) {
|
|
1181
|
+
this.basepath = nextBasepath;
|
|
1182
|
+
this.rewrite = nextBasepath !== "/" && trimPath(nextBasepath) ? rewriteBasepath(nextBasepath, this.options.caseSensitive, nextRewriteOption) : nextRewriteOption;
|
|
1183
|
+
}
|
|
1184
|
+
if (this.history) this.updateLatestLocation();
|
|
1185
|
+
if (this.options.routeTree !== this.routeTree || prevOptions?.caseSensitive !== this.options.caseSensitive) {
|
|
1186
|
+
this.routeTree = this.options.routeTree;
|
|
1187
|
+
let processRouteTreeResult;
|
|
1188
|
+
if (globalThis.__TSR_CACHE__ && globalThis.__TSR_CACHE__.routeTree === this.routeTree && globalThis.__TSR_CACHE__.caseSensitive === this.options.caseSensitive) processRouteTreeResult = globalThis.__TSR_CACHE__.processRouteTreeResult;
|
|
1189
|
+
else {
|
|
1190
|
+
processRouteTreeResult = this.buildRouteTree();
|
|
1191
|
+
if (globalThis.__TSR_CACHE__ === void 0) globalThis.__TSR_CACHE__ = {
|
|
1192
|
+
routeTree: this.routeTree,
|
|
1193
|
+
caseSensitive: this.options.caseSensitive,
|
|
1194
|
+
processRouteTreeResult
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
this.setRoutes(processRouteTreeResult);
|
|
1198
|
+
}
|
|
1199
|
+
if (!this.stores) {
|
|
1200
|
+
if (this.latestLocation) {
|
|
1201
|
+
const config = this.getStoreConfig(this);
|
|
1202
|
+
this.batch = config.batch;
|
|
1203
|
+
this.stores = createRouterStores(this.latestLocation, config);
|
|
1204
|
+
}
|
|
1205
|
+
} else if (rewriteChanged) this.stores.location.set(this.latestLocation);
|
|
1206
|
+
};
|
|
1207
|
+
this.updateLatestLocation = () => {
|
|
1208
|
+
this.latestLocation = this.parseLocation(this.history.location, this.latestLocation);
|
|
1209
|
+
};
|
|
1210
|
+
this.buildRouteTree = () => {
|
|
1211
|
+
const result = processRouteTree(this.routeTree, this.options.caseSensitive);
|
|
1212
|
+
if (this.options.routeMasks) processRouteMasks(this.options.routeMasks, result.processedTree);
|
|
1213
|
+
return {
|
|
1214
|
+
...result,
|
|
1215
|
+
resolvePathCache: createSieveCache(1e3)
|
|
1216
|
+
};
|
|
1217
|
+
};
|
|
1218
|
+
this.subscribe = (eventType, fn) => {
|
|
1219
|
+
const listener = {
|
|
1220
|
+
eventType,
|
|
1221
|
+
fn
|
|
1222
|
+
};
|
|
1223
|
+
this.subscribers.add(listener);
|
|
1224
|
+
return () => {
|
|
1225
|
+
this.subscribers.delete(listener);
|
|
1226
|
+
};
|
|
1227
|
+
};
|
|
1228
|
+
this.emit = (routerEvent) => {
|
|
1229
|
+
for (const listener of this.subscribers) if (listener.eventType === routerEvent.type) try {
|
|
1230
|
+
listener.fn(routerEvent);
|
|
1231
|
+
} catch (e) {
|
|
1232
|
+
console.error(e);
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
this.parseLocation = (locationToParse, previousLocation) => {
|
|
1236
|
+
const parse = ({ pathname, search, hash, href }, state) => {
|
|
1237
|
+
if (!this.rewrite && !/[ \x00-\x1f\x7f\u0080-\uffff]/.test(pathname)) {
|
|
1238
|
+
const parsedSearch = this.options.parseSearch(search);
|
|
1239
|
+
const searchStr = this.options.stringifySearch(parsedSearch);
|
|
1240
|
+
return {
|
|
1241
|
+
href: pathname + searchStr + hash,
|
|
1242
|
+
publicHref: pathname + searchStr + hash,
|
|
1243
|
+
pathname: decodePath(pathname),
|
|
1244
|
+
external: false,
|
|
1245
|
+
searchStr,
|
|
1246
|
+
search: nullReplaceEqualDeep(previousLocation?.search, parsedSearch),
|
|
1247
|
+
hash: decodePath(hash.slice(1)),
|
|
1248
|
+
state: replaceEqualDeep(previousLocation?.state, state)
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
const url = executeRewriteInput(this.rewrite, new URL(href, this.origin));
|
|
1252
|
+
const parsedSearch = this.options.parseSearch(url.search);
|
|
1253
|
+
const searchStr = this.options.stringifySearch(parsedSearch);
|
|
1254
|
+
url.search = searchStr;
|
|
1255
|
+
return {
|
|
1256
|
+
href: url.href.replace(url.origin, ""),
|
|
1257
|
+
publicHref: href,
|
|
1258
|
+
pathname: decodePath(normalizeProtocolRelative(url.pathname)),
|
|
1259
|
+
external: !!this.rewrite && isExternalUrl(url, this.origin),
|
|
1260
|
+
searchStr,
|
|
1261
|
+
search: nullReplaceEqualDeep(previousLocation?.search, parsedSearch),
|
|
1262
|
+
hash: decodePath(url.hash.slice(1)),
|
|
1263
|
+
state: replaceEqualDeep(previousLocation?.state, state)
|
|
1264
|
+
};
|
|
1265
|
+
};
|
|
1266
|
+
const location = parse(locationToParse, locationToParse.state);
|
|
1267
|
+
const { __tempLocation, __tempKey } = location.state;
|
|
1268
|
+
if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
|
|
1269
|
+
const parsedTempLocation = parse(__tempLocation, {
|
|
1270
|
+
...__tempLocation.state,
|
|
1271
|
+
__tempLocation: void 0,
|
|
1272
|
+
key: location.state.key,
|
|
1273
|
+
__TSR_key: location.state.__TSR_key
|
|
1274
|
+
});
|
|
1275
|
+
parsedTempLocation.maskedLocation = location;
|
|
1276
|
+
return parsedTempLocation;
|
|
1277
|
+
}
|
|
1278
|
+
return location;
|
|
1279
|
+
};
|
|
1280
|
+
this.matchRoutes = (pathnameOrNext, locationSearchOrOpts, opts) => {
|
|
1281
|
+
if (typeof pathnameOrNext === "string") return this.matchRoutesInternal({
|
|
1282
|
+
pathname: pathnameOrNext,
|
|
1283
|
+
search: locationSearchOrOpts
|
|
1284
|
+
}, opts);
|
|
1285
|
+
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
|
|
1286
|
+
};
|
|
1287
|
+
this.getMatchedRoutes = (pathname) => {
|
|
1288
|
+
const rawParams = Object.create(null);
|
|
1289
|
+
const match = findRouteMatch(trimPathRight(pathname), this.processedTree, true);
|
|
1290
|
+
if (match) Object.assign(rawParams, match.rawParams);
|
|
1291
|
+
return [
|
|
1292
|
+
match?.branch || [this.routesById["__root__"]],
|
|
1293
|
+
rawParams,
|
|
1294
|
+
match?.route
|
|
1295
|
+
];
|
|
1296
|
+
};
|
|
1297
|
+
this.buildLocation = (opts) => {
|
|
1298
|
+
const build = (dest = {}) => {
|
|
1299
|
+
if (dest.href) {
|
|
1300
|
+
const parsed = parseHref(dest.href, {});
|
|
1301
|
+
dest = {
|
|
1302
|
+
...dest,
|
|
1303
|
+
to: executeRewriteInput(this.rewrite, new URL(parsed.pathname, this.origin)).pathname,
|
|
1304
|
+
search: this.options.parseSearch(parsed.search),
|
|
1305
|
+
hash: parsed.hash.slice(1)
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
const currentLocation = opts._fromLocation || this._pendingLocation || this.latestLocation;
|
|
1309
|
+
let lightweight;
|
|
1310
|
+
const current = () => {
|
|
1311
|
+
return currentLocation;
|
|
1312
|
+
};
|
|
1313
|
+
const currentMatch = () => lightweight ??= this.matchRoutesLightweight(current());
|
|
1314
|
+
const to = dest.to ? `${dest.to}` : ".";
|
|
1315
|
+
const nextTo = resolvePath(to[0] === "/" ? "" : dest.unsafeRelative === "path" ? current().pathname : dest.from ?? currentMatch()[1], to, this.options.trailingSlash, this.resolvePathCache);
|
|
1316
|
+
const destRoute = this.routesByPath[trimPathRight(nextTo)];
|
|
1317
|
+
const isTemplate = nextTo.includes("$");
|
|
1318
|
+
let destRoutes;
|
|
1319
|
+
if (destRoute) destRoutes = destRoute._branch ??= buildRouteBranch(destRoute);
|
|
1320
|
+
else if (isTemplate) destRoutes = [];
|
|
1321
|
+
else {
|
|
1322
|
+
const [matchedRoutes, rawParams, foundRoute] = this.getMatchedRoutes(nextTo);
|
|
1323
|
+
destRoutes = matchedRoutes;
|
|
1324
|
+
if (this.options.notFoundRoute && (!foundRoute || foundRoute.path !== "/" && rawParams["**"])) destRoutes = [...destRoutes, this.options.notFoundRoute];
|
|
1325
|
+
}
|
|
1326
|
+
const interpolation = isTemplate ? destRoute?._interpolation ?? parseSegments(false, { fullPath: nextTo }, 0) : void 0;
|
|
1327
|
+
let nextParams;
|
|
1328
|
+
for (const route of destRoutes) {
|
|
1329
|
+
const fn = route.options.params?.stringify ?? route.options.stringifyParams;
|
|
1330
|
+
if (fn) {
|
|
1331
|
+
const fromParams = currentMatch()[3];
|
|
1332
|
+
nextParams ??= resolveNextParams(dest.params, fromParams);
|
|
1333
|
+
if (!hasKeys(nextParams)) break;
|
|
1334
|
+
if (nextParams === fromParams) nextParams = Object.assign(createNull(), nextParams);
|
|
1335
|
+
try {
|
|
1336
|
+
Object.assign(nextParams, fn(nextParams));
|
|
1337
|
+
} catch {}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
nextParams ??= resolveNextParams(dest.params, needsInheritedParams(dest.params, interpolation) ? currentMatch()[3] : EMPTY_RECORD);
|
|
1341
|
+
const nextPathname = opts.leaveParams ? nextTo : normalizeProtocolRelative(decodePath(interpolation ? interpolatePath(nextTo, interpolation, nextParams, this.pathParamsDecoder) : nextTo));
|
|
1342
|
+
const middlewares = getSearchMiddlewares(destRoutes, opts._includeValidateSearch);
|
|
1343
|
+
const fromSearch = () => {
|
|
1344
|
+
let search = currentMatch()[2];
|
|
1345
|
+
if (opts._includeValidateSearch && this.options.search?.strict) {
|
|
1346
|
+
const validatedSearch = {};
|
|
1347
|
+
destRoutes.forEach((route) => {
|
|
1348
|
+
if (route.options.validateSearch) try {
|
|
1349
|
+
Object.assign(validatedSearch, validateSearch(route.options.validateSearch, {
|
|
1350
|
+
...validatedSearch,
|
|
1351
|
+
...search
|
|
1352
|
+
}));
|
|
1353
|
+
} catch {}
|
|
1354
|
+
});
|
|
1355
|
+
search = validatedSearch;
|
|
1356
|
+
}
|
|
1357
|
+
return search;
|
|
1358
|
+
};
|
|
1359
|
+
const nextSearch = middlewares.length ? applySearchMiddleware(middlewares, fromSearch(), dest) : dest.search === true ? fromSearch() : typeof dest.search === "function" ? dest.search(fromSearch()) : dest.search || EMPTY_RECORD;
|
|
1360
|
+
const searchStr = this.options.stringifySearch(nextSearch);
|
|
1361
|
+
const hash = dest.hash === true ? current().hash : typeof dest.hash === "function" ? dest.hash(current().hash) : dest.hash || void 0;
|
|
1362
|
+
const hashStr = hash ? `#${hash}` : "";
|
|
1363
|
+
const nextState = !dest.state ? EMPTY_RECORD : dest.state === true ? current().state : typeof dest.state === "function" ? dest.state(current().state) : dest.state;
|
|
1364
|
+
const fullPath = `${nextPathname}${searchStr}${hashStr}`;
|
|
1365
|
+
let href;
|
|
1366
|
+
let publicHref;
|
|
1367
|
+
let external = false;
|
|
1368
|
+
if (this.rewrite) {
|
|
1369
|
+
const url = new URL(fullPath, this.origin);
|
|
1370
|
+
const origin = url.origin;
|
|
1371
|
+
const rewrittenUrl = executeRewriteOutput(this.rewrite, url);
|
|
1372
|
+
href = getUrlPath(url);
|
|
1373
|
+
if (isExternalUrl(rewrittenUrl, origin)) {
|
|
1374
|
+
publicHref = rewrittenUrl.href;
|
|
1375
|
+
external = true;
|
|
1376
|
+
} else publicHref = normalizeProtocolRelative(getUrlPath(rewrittenUrl));
|
|
1377
|
+
} else {
|
|
1378
|
+
href = encodePathLikeUrl(fullPath);
|
|
1379
|
+
publicHref = href;
|
|
1380
|
+
}
|
|
1381
|
+
return {
|
|
1382
|
+
publicHref,
|
|
1383
|
+
href,
|
|
1384
|
+
pathname: nextPathname,
|
|
1385
|
+
search: nextSearch,
|
|
1386
|
+
searchStr,
|
|
1387
|
+
state: nextState,
|
|
1388
|
+
hash: hash ?? "",
|
|
1389
|
+
external,
|
|
1390
|
+
unmaskOnReload: dest.unmaskOnReload
|
|
1391
|
+
};
|
|
1392
|
+
};
|
|
1393
|
+
const next = build(opts);
|
|
1394
|
+
if (opts.mask) next.maskedLocation = build({
|
|
1395
|
+
from: opts.from,
|
|
1396
|
+
...opts.mask
|
|
1397
|
+
});
|
|
1398
|
+
else if (this.options.routeMasks) {
|
|
1399
|
+
const match = findFlatMatch(next.pathname, this.processedTree);
|
|
1400
|
+
if (match) {
|
|
1401
|
+
const params = Object.assign(createNull(), match.rawParams);
|
|
1402
|
+
const { from: _from, params: maskParams, ...maskProps } = match.route;
|
|
1403
|
+
const nextParams = resolveNextParams(maskParams, params);
|
|
1404
|
+
next.maskedLocation = build({
|
|
1405
|
+
from: opts.from,
|
|
1406
|
+
...maskProps,
|
|
1407
|
+
params: nextParams
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
return next;
|
|
1412
|
+
};
|
|
1413
|
+
this.commitLocation = async ({ viewTransition, ignoreBlocker, ...next }) => {};
|
|
1414
|
+
this.buildAndCommitLocation = ({ replace, resetScroll, hashScrollIntoView, viewTransition, ignoreBlocker, ...rest } = {}) => {
|
|
1415
|
+
return Promise.resolve();
|
|
1416
|
+
};
|
|
1417
|
+
this.navigate = async ({ to, reloadDocument, href, publicHref, ...rest }) => {};
|
|
1418
|
+
this.load = async (opts) => {
|
|
1419
|
+
return loadServerRoute(this, opts);
|
|
1420
|
+
};
|
|
1421
|
+
this.startViewTransition = (fn) => {
|
|
1422
|
+
this.shouldViewTransition ?? this.options.defaultViewTransition;
|
|
1423
|
+
this.shouldViewTransition = void 0;
|
|
1424
|
+
return fn();
|
|
1425
|
+
};
|
|
1426
|
+
this.invalidate = (opts) => {
|
|
1427
|
+
const committedMatches = this._committed;
|
|
1428
|
+
const filter = opts?.filter;
|
|
1429
|
+
const preloads = this._preloads;
|
|
1430
|
+
const invalidIds = /* @__PURE__ */ new Set();
|
|
1431
|
+
const consider = (match) => {
|
|
1432
|
+
if (!filter || filter(match)) invalidIds.add(match.id);
|
|
1433
|
+
};
|
|
1434
|
+
committedMatches.forEach(consider);
|
|
1435
|
+
this._cache.forEach(consider);
|
|
1436
|
+
preloads?.forEach((matches) => matches.forEach(consider));
|
|
1437
|
+
this._tx?.[3].forEach(consider);
|
|
1438
|
+
const abort = [];
|
|
1439
|
+
for (const [controller, matches] of preloads ?? []) if (matches.some((match) => invalidIds.has(match.id))) {
|
|
1440
|
+
preloads.delete(controller);
|
|
1441
|
+
abort.push(controller);
|
|
1442
|
+
}
|
|
1443
|
+
const invalidate = (d) => {
|
|
1444
|
+
if (invalidIds.has(d.id)) {
|
|
1445
|
+
const route = this.routesById[d.routeId];
|
|
1446
|
+
const next = {
|
|
1447
|
+
...d,
|
|
1448
|
+
invalid: true,
|
|
1449
|
+
...(opts?.forcePending || d.status === "error" || d.status === "notFound") && routeNeedsLoad(route) ? {
|
|
1450
|
+
status: "pending",
|
|
1451
|
+
error: void 0
|
|
1452
|
+
} : void 0
|
|
1453
|
+
};
|
|
1454
|
+
d._flight = void 0;
|
|
1455
|
+
return next;
|
|
1456
|
+
}
|
|
1457
|
+
return d;
|
|
1458
|
+
};
|
|
1459
|
+
this._committed = committedMatches.map(invalidate);
|
|
1460
|
+
for (const [id, match] of this._cache) if (invalidIds.has(id)) {
|
|
1461
|
+
match.invalid = true;
|
|
1462
|
+
if (opts?.forcePending) match.status = "pending";
|
|
1463
|
+
}
|
|
1464
|
+
for (const id of invalidIds) {
|
|
1465
|
+
const flight = this._flights?.get(id);
|
|
1466
|
+
this._flights?.delete(id);
|
|
1467
|
+
if (flight && !flight[2]) abort.push(flight[1]);
|
|
1468
|
+
}
|
|
1469
|
+
for (const controller of abort) controller.abort();
|
|
1470
|
+
this.shouldViewTransition = false;
|
|
1471
|
+
return this.load({ sync: opts?.sync });
|
|
1472
|
+
};
|
|
1473
|
+
this.resolveRedirect = (redirect) => {
|
|
1474
|
+
const options = redirect.options;
|
|
1475
|
+
let href = redirect.headers.get("Location") || options.href;
|
|
1476
|
+
if (!href) {
|
|
1477
|
+
const location = this.buildLocation(options);
|
|
1478
|
+
href = (location.maskedLocation ?? location).publicHref || "/";
|
|
1479
|
+
}
|
|
1480
|
+
let scheme;
|
|
1481
|
+
if (protocolRelativePrefixRegex.test(href) || (scheme = getUrlScheme(href)) && !this.protocolAllowlist.has(scheme)) throw new Error("Redirect blocked: unsafe protocol");
|
|
1482
|
+
if (scheme === "http:" || scheme === "https:") {
|
|
1483
|
+
const url = new URL(href);
|
|
1484
|
+
if (url.pathname.startsWith("//")) href = url.href;
|
|
1485
|
+
else if (!isExternalUrl(url, this.origin)) {
|
|
1486
|
+
href = getUrlPath(url);
|
|
1487
|
+
scheme = void 0;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
if (scheme) options.reloadDocument = true;
|
|
1491
|
+
options.href = href;
|
|
1492
|
+
redirect.headers.set("Location", href);
|
|
1493
|
+
return redirect;
|
|
1494
|
+
};
|
|
1495
|
+
this.clearCache = (opts) => {
|
|
1496
|
+
const cached = this._cache;
|
|
1497
|
+
const preloads = this._preloads;
|
|
1498
|
+
const filter = opts?.filter;
|
|
1499
|
+
const discarded = [];
|
|
1500
|
+
const discardedIds = [];
|
|
1501
|
+
for (const [id, match] of cached) if (!filter || filter(match)) {
|
|
1502
|
+
discardedIds.push(id);
|
|
1503
|
+
discarded.push(match);
|
|
1504
|
+
}
|
|
1505
|
+
const abort = [];
|
|
1506
|
+
for (const [controller, matches] of preloads ?? []) if (!filter || matches.some(filter)) {
|
|
1507
|
+
abort.push(controller);
|
|
1508
|
+
discarded.push(...matches);
|
|
1509
|
+
}
|
|
1510
|
+
for (const id of discardedIds) cached.delete(id);
|
|
1511
|
+
for (const controller of abort) preloads.delete(controller);
|
|
1512
|
+
for (const match of discarded) {
|
|
1513
|
+
const flight = match._flight;
|
|
1514
|
+
match._flight = void 0;
|
|
1515
|
+
if (flight && !--flight[2]) {
|
|
1516
|
+
if (this._flights?.get(match.id) === flight) this._flights.delete(match.id);
|
|
1517
|
+
abort.push(flight[1]);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
for (const controller of abort) controller.abort();
|
|
1521
|
+
};
|
|
1522
|
+
this.loadRouteChunk = loadRouteChunk;
|
|
1523
|
+
this.preloadRoute = (opts) => preloadClientRoute(this, opts);
|
|
1524
|
+
this.matchRoute = (location, opts) => {
|
|
1525
|
+
const matchLocation = {
|
|
1526
|
+
...location,
|
|
1527
|
+
to: location.to ? resolvePath(location.from || "", location.to, this.options.trailingSlash, this.resolvePathCache) : void 0,
|
|
1528
|
+
params: location.params || {},
|
|
1529
|
+
leaveParams: true
|
|
1530
|
+
};
|
|
1531
|
+
const next = this.buildLocation(matchLocation);
|
|
1532
|
+
const isPending = this.stores.status.get() === "pending";
|
|
1533
|
+
if (opts?.pending && !isPending) return false;
|
|
1534
|
+
const baseLocation = opts?.pending ?? !isPending ? this.latestLocation : this.stores.resolvedLocation.get() || this.stores.location.get();
|
|
1535
|
+
const match = findSingleMatch(next.pathname, opts?.caseSensitive ?? false, opts?.fuzzy ?? false, baseLocation.pathname, this.processedTree);
|
|
1536
|
+
if (!match) return false;
|
|
1537
|
+
if (location.params) {
|
|
1538
|
+
if (!deepEqual(match.rawParams, location.params, true)) return false;
|
|
1539
|
+
}
|
|
1540
|
+
if (opts?.includeSearch ?? true) return deepEqual(baseLocation.search, next.search, true) ? match.rawParams : false;
|
|
1541
|
+
return match.rawParams;
|
|
1542
|
+
};
|
|
1543
|
+
this.getStoreConfig = getStoreConfig;
|
|
1544
|
+
if (options.pathParamsAllowedCharacters?.length) this.pathParamsDecoder = compileDecodeCharMap(options.pathParamsAllowedCharacters);
|
|
1545
|
+
this.update({
|
|
1546
|
+
defaultPreloadDelay: 50,
|
|
1547
|
+
defaultPendingMs: 1e3,
|
|
1548
|
+
defaultPendingMinMs: 500,
|
|
1549
|
+
context: void 0,
|
|
1550
|
+
...options,
|
|
1551
|
+
caseSensitive: options.caseSensitive ?? false,
|
|
1552
|
+
notFoundMode: options.notFoundMode ?? "fuzzy",
|
|
1553
|
+
stringifySearch: options.stringifySearch ?? defaultStringifySearch,
|
|
1554
|
+
parseSearch: options.parseSearch ?? defaultParseSearch,
|
|
1555
|
+
protocolAllowlist: options.protocolAllowlist ?? DEFAULT_PROTOCOL_ALLOWLIST
|
|
1556
|
+
});
|
|
1557
|
+
}
|
|
1558
|
+
isShell() {
|
|
1559
|
+
return !!this.options.isShell;
|
|
1560
|
+
}
|
|
1561
|
+
get state() {
|
|
1562
|
+
return this.stores.__store.get();
|
|
1563
|
+
}
|
|
1564
|
+
setRoutes(caches) {
|
|
1565
|
+
Object.assign(this, caches);
|
|
1566
|
+
this.lightweightCache = /* @__PURE__ */ new WeakMap();
|
|
1567
|
+
const notFoundRoute = this.options.notFoundRoute;
|
|
1568
|
+
if (notFoundRoute) {
|
|
1569
|
+
notFoundRoute.init(99999999999);
|
|
1570
|
+
if (this.routesById[notFoundRoute.id] !== notFoundRoute) notFoundRoute._interpolation = parseSegments(false, notFoundRoute, 0);
|
|
1571
|
+
this.routesById[notFoundRoute.id] = notFoundRoute;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
matchRoutesInternal(next, opts) {
|
|
1575
|
+
const [initialMatchedRoutes, rawParams, foundRoute] = this.getMatchedRoutes(next.pathname);
|
|
1576
|
+
let matchedRoutes = initialMatchedRoutes;
|
|
1577
|
+
let isGlobalNotFound = false;
|
|
1578
|
+
if (foundRoute ? foundRoute.path !== "/" && rawParams["**"] : trimPathRight(next.pathname)) {
|
|
1579
|
+
if (this.options.notFoundRoute) matchedRoutes = [...matchedRoutes, this.options.notFoundRoute];
|
|
1580
|
+
else isGlobalNotFound = true;
|
|
1581
|
+
}
|
|
1582
|
+
const _notFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
|
|
1583
|
+
const matches = new Array(matchedRoutes.length);
|
|
1584
|
+
const committed = this._committed;
|
|
1585
|
+
const previousAt = (route, index) => {
|
|
1586
|
+
const match = committed[index];
|
|
1587
|
+
return match?.routeId === route.id ? match : route === this.options.notFoundRoute ? committed.find((candidate) => candidate.routeId === route.id) : void 0;
|
|
1588
|
+
};
|
|
1589
|
+
let strictParams;
|
|
1590
|
+
for (let index = 0; index < matchedRoutes.length; index++) {
|
|
1591
|
+
const route = matchedRoutes[index];
|
|
1592
|
+
const parentMatch = matches[index - 1];
|
|
1593
|
+
let preMatchSearch;
|
|
1594
|
+
let strictMatchSearch;
|
|
1595
|
+
let searchError;
|
|
1596
|
+
{
|
|
1597
|
+
const parentSearch = parentMatch?.search ?? next.search;
|
|
1598
|
+
const parentStrictSearch = parentMatch?._strictSearch ?? void 0;
|
|
1599
|
+
try {
|
|
1600
|
+
const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
|
|
1601
|
+
preMatchSearch = {
|
|
1602
|
+
...parentSearch,
|
|
1603
|
+
...strictSearch
|
|
1604
|
+
};
|
|
1605
|
+
strictMatchSearch = {
|
|
1606
|
+
...parentStrictSearch,
|
|
1607
|
+
...strictSearch
|
|
1608
|
+
};
|
|
1609
|
+
} catch (err) {
|
|
1610
|
+
let searchParamError = err;
|
|
1611
|
+
if (!(err instanceof SearchParamError)) searchParamError = new SearchParamError(err.message, { cause: err });
|
|
1612
|
+
if (opts?.throwOnError) throw searchParamError;
|
|
1613
|
+
preMatchSearch = parentSearch;
|
|
1614
|
+
strictMatchSearch = {};
|
|
1615
|
+
searchError = searchParamError;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
let loaderDeps = "";
|
|
1619
|
+
let loaderDepsHash = "";
|
|
1620
|
+
try {
|
|
1621
|
+
loaderDeps = route.options.loaderDeps?.({ search: preMatchSearch }) ?? "";
|
|
1622
|
+
loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) || "" : "";
|
|
1623
|
+
} catch (cause) {
|
|
1624
|
+
if (opts?.throwOnError) throw cause;
|
|
1625
|
+
searchError ??= cause;
|
|
1626
|
+
}
|
|
1627
|
+
const usedParams = createNull();
|
|
1628
|
+
const interpolatedPath = route._interpolation ? interpolatePath(route.fullPath, route._interpolation, rawParams, this.pathParamsDecoder, usedParams) : route.fullPath;
|
|
1629
|
+
const matchId = route.id + interpolatedPath + loaderDepsHash;
|
|
1630
|
+
const previousMatch = previousAt(route, index);
|
|
1631
|
+
const existingMatch = this._cache.get(matchId) ?? (previousMatch?.id === matchId ? previousMatch : void 0);
|
|
1632
|
+
strictParams = existingMatch?._strictParams ?? Object.assign(usedParams, strictParams);
|
|
1633
|
+
let paramsError;
|
|
1634
|
+
if (!existingMatch) try {
|
|
1635
|
+
extractStrictParams(route, strictParams);
|
|
1636
|
+
} catch (err) {
|
|
1637
|
+
if (isNotFound(err) || isRedirect(err)) paramsError = err;
|
|
1638
|
+
else paramsError = new PathParamError(err.message, { cause: err });
|
|
1639
|
+
if (opts?.throwOnError) throw paramsError;
|
|
1640
|
+
}
|
|
1641
|
+
const cause = previousMatch ? "stay" : "enter";
|
|
1642
|
+
let match;
|
|
1643
|
+
if (existingMatch) match = {
|
|
1644
|
+
...existingMatch,
|
|
1645
|
+
cause,
|
|
1646
|
+
search: previousMatch ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch) : nullReplaceEqualDeep(existingMatch.search, preMatchSearch),
|
|
1647
|
+
_strictSearch: strictMatchSearch,
|
|
1648
|
+
searchError
|
|
1649
|
+
};
|
|
1650
|
+
else {
|
|
1651
|
+
const status = routeNeedsLoad(route) ? "pending" : "success";
|
|
1652
|
+
match = {
|
|
1653
|
+
id: matchId,
|
|
1654
|
+
ssr: void 0,
|
|
1655
|
+
index,
|
|
1656
|
+
routeId: route.id,
|
|
1657
|
+
params: previousMatch?.params ?? strictParams,
|
|
1658
|
+
_strictParams: strictParams,
|
|
1659
|
+
pathname: interpolatedPath,
|
|
1660
|
+
updatedAt: Date.now(),
|
|
1661
|
+
search: previousMatch ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
|
|
1662
|
+
_strictSearch: strictMatchSearch,
|
|
1663
|
+
searchError,
|
|
1664
|
+
status,
|
|
1665
|
+
isFetching: false,
|
|
1666
|
+
error: void 0,
|
|
1667
|
+
paramsError,
|
|
1668
|
+
context: {},
|
|
1669
|
+
abortController: opts?._controller ?? new AbortController(),
|
|
1670
|
+
cause,
|
|
1671
|
+
loaderDeps: previousMatch ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps) : loaderDeps,
|
|
1672
|
+
invalid: false,
|
|
1673
|
+
preload: false,
|
|
1674
|
+
staticData: route.options.staticData || {},
|
|
1675
|
+
fullPath: route.fullPath
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
const _notFound = _notFoundRouteId === route.id;
|
|
1679
|
+
if (match._notFound && !_notFound) match.error = void 0;
|
|
1680
|
+
match._notFound = _notFound;
|
|
1681
|
+
matches[index] = match;
|
|
1682
|
+
}
|
|
1683
|
+
for (let index = 0; index < matches.length; index++) {
|
|
1684
|
+
const match = matches[index];
|
|
1685
|
+
match.params = match.cause === "stay" ? nullReplaceEqualDeep(match.params, strictParams) : strictParams;
|
|
1686
|
+
if (opts?._controller) match.context = {};
|
|
1687
|
+
}
|
|
1688
|
+
return matches;
|
|
1689
|
+
}
|
|
1690
|
+
/**
|
|
1691
|
+
* Lightweight route matching for buildLocation.
|
|
1692
|
+
* Only computes fullPath, accumulated search, and params - skipping expensive
|
|
1693
|
+
* operations like AbortController, loaderDeps, and full match objects.
|
|
1694
|
+
*/
|
|
1695
|
+
matchRoutesLightweight(location) {
|
|
1696
|
+
const lastRouteId = last(this.stores.ids.get());
|
|
1697
|
+
const lastStateMatch = lastRouteId ? this.stores.byRoute.get(lastRouteId).get() : void 0;
|
|
1698
|
+
const lastStateMatchId = lastStateMatch?.id;
|
|
1699
|
+
const cached = this.lightweightCache.get(location);
|
|
1700
|
+
if (cached && cached[0] === lastStateMatchId) return cached[1];
|
|
1701
|
+
const [matchedRoutes, rawParams] = this.getMatchedRoutes(location.pathname);
|
|
1702
|
+
const lastRoute = last(matchedRoutes);
|
|
1703
|
+
const accumulatedSearch = { ...location.search };
|
|
1704
|
+
for (const route of matchedRoutes) try {
|
|
1705
|
+
Object.assign(accumulatedSearch, validateSearch(route.options.validateSearch, accumulatedSearch));
|
|
1706
|
+
} catch {}
|
|
1707
|
+
const canReuseParams = lastStateMatch && lastStateMatch.routeId === lastRoute.id && lastStateMatch.pathname === location.pathname;
|
|
1708
|
+
let params;
|
|
1709
|
+
if (canReuseParams) params = lastStateMatch.params;
|
|
1710
|
+
else {
|
|
1711
|
+
const strictParams = rawParams;
|
|
1712
|
+
for (const route of matchedRoutes) try {
|
|
1713
|
+
extractStrictParams(route, strictParams);
|
|
1714
|
+
} catch {}
|
|
1715
|
+
params = strictParams;
|
|
1716
|
+
}
|
|
1717
|
+
const result = [
|
|
1718
|
+
matchedRoutes,
|
|
1719
|
+
lastRoute.fullPath,
|
|
1720
|
+
accumulatedSearch,
|
|
1721
|
+
params
|
|
1722
|
+
];
|
|
1723
|
+
this.lightweightCache.set(location, [lastStateMatchId, result]);
|
|
1724
|
+
return result;
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
/** Error thrown when search parameter validation fails. */
|
|
1728
|
+
var SearchParamError = class extends Error {};
|
|
1729
|
+
/** Error thrown when path parameter parsing/validation fails. */
|
|
1730
|
+
var PathParamError = class extends Error {};
|
|
1731
|
+
function validateSearch(validateSearch, input) {
|
|
1732
|
+
if (validateSearch == null) return {};
|
|
1733
|
+
if ("~standard" in validateSearch) {
|
|
1734
|
+
const result = validateSearch["~standard"].validate(input);
|
|
1735
|
+
if (result instanceof Promise) throw new SearchParamError("Async validation not supported");
|
|
1736
|
+
if (result.issues) throw new SearchParamError(JSON.stringify(result.issues, void 0, 2), { cause: result });
|
|
1737
|
+
return result.value;
|
|
1738
|
+
}
|
|
1739
|
+
if ("parse" in validateSearch) return validateSearch.parse(input);
|
|
1740
|
+
if (typeof validateSearch === "function") return validateSearch(input);
|
|
1741
|
+
return {};
|
|
1742
|
+
}
|
|
1743
|
+
function resolveNextParams(spec, base) {
|
|
1744
|
+
if (spec === void 0 || spec === true) return base;
|
|
1745
|
+
const next = Object.create(null);
|
|
1746
|
+
if (spec === false || spec === null) return next;
|
|
1747
|
+
if (typeof spec === "function") {
|
|
1748
|
+
Object.assign(next, base);
|
|
1749
|
+
return Object.assign(next, spec(next));
|
|
1750
|
+
}
|
|
1751
|
+
return Object.assign(next, base, spec);
|
|
1752
|
+
}
|
|
1753
|
+
function needsInheritedParams(spec, interpolation) {
|
|
1754
|
+
if (typeof spec === "function") return true;
|
|
1755
|
+
if (!interpolation || spec === false || spec === null) return false;
|
|
1756
|
+
return spec === void 0 || spec === true || interpolation.some((part) => typeof part !== "string" && !hasOwn.call(spec, part[1]));
|
|
1757
|
+
}
|
|
1758
|
+
var EMPTY_RECORD = Object.freeze({});
|
|
1759
|
+
function getSearchMiddlewares(destRoutes, includeValidateSearch) {
|
|
1760
|
+
const middlewares = [];
|
|
1761
|
+
for (let i = 0; i < destRoutes.length; i++) {
|
|
1762
|
+
const routeOptions = destRoutes[i].options;
|
|
1763
|
+
if ("search" in routeOptions) {
|
|
1764
|
+
if (routeOptions.search?.middlewares) middlewares.push(...routeOptions.search.middlewares);
|
|
1765
|
+
} else if (routeOptions.preSearchFilters || routeOptions.postSearchFilters) {
|
|
1766
|
+
const legacyMiddleware = ({ search, next }) => {
|
|
1767
|
+
const result = next(routeOptions.preSearchFilters ? routeOptions.preSearchFilters.reduce((prev, next) => next(prev), search) : search);
|
|
1768
|
+
return routeOptions.postSearchFilters ? routeOptions.postSearchFilters.reduce((prev, next) => next(prev), result) : result;
|
|
1769
|
+
};
|
|
1770
|
+
middlewares.push(legacyMiddleware);
|
|
1771
|
+
}
|
|
1772
|
+
const routeValidateSearch = routeOptions.validateSearch;
|
|
1773
|
+
if (includeValidateSearch && routeValidateSearch) {
|
|
1774
|
+
const validate = ({ search, next, meta }) => {
|
|
1775
|
+
const result = next(search);
|
|
1776
|
+
try {
|
|
1777
|
+
const validated = validateSearch(routeValidateSearch, result);
|
|
1778
|
+
if (meta && validated) {
|
|
1779
|
+
for (const key in validated) if (!(key in result)) (meta.defaulted ||= /* @__PURE__ */ new Map()).set(key, validated[key]);
|
|
1780
|
+
}
|
|
1781
|
+
return {
|
|
1782
|
+
...result,
|
|
1783
|
+
...validated
|
|
1784
|
+
};
|
|
1785
|
+
} catch {}
|
|
1786
|
+
return result;
|
|
1787
|
+
};
|
|
1788
|
+
middlewares.push(validate);
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
return middlewares;
|
|
1792
|
+
}
|
|
1793
|
+
function applySearchMiddleware(middlewares, search, dest) {
|
|
1794
|
+
const applyNext = (index, currentSearch, meta) => {
|
|
1795
|
+
if (index >= middlewares.length) {
|
|
1796
|
+
if (!dest.search) return {};
|
|
1797
|
+
if (dest.search === true) return currentSearch;
|
|
1798
|
+
const result = functionalUpdate(dest.search, currentSearch);
|
|
1799
|
+
if (meta) meta.explicit = result;
|
|
1800
|
+
return result;
|
|
1801
|
+
}
|
|
1802
|
+
const next = (newSearch, collectMeta) => {
|
|
1803
|
+
if (collectMeta) {
|
|
1804
|
+
const nextMeta = meta || {};
|
|
1805
|
+
return {
|
|
1806
|
+
search: applyNext(index + 1, newSearch, nextMeta),
|
|
1807
|
+
meta: nextMeta
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
return applyNext(index + 1, newSearch, meta);
|
|
1811
|
+
};
|
|
1812
|
+
return middlewares[index]({
|
|
1813
|
+
search: currentSearch,
|
|
1814
|
+
next,
|
|
1815
|
+
meta
|
|
1816
|
+
});
|
|
1817
|
+
};
|
|
1818
|
+
return applyNext(0, search);
|
|
1819
|
+
}
|
|
1820
|
+
function findGlobalNotFoundRouteId(notFoundMode, routes) {
|
|
1821
|
+
if (notFoundMode !== "root") {
|
|
1822
|
+
let fallback;
|
|
1823
|
+
for (let i = routes.length - 1; i >= 0; i--) {
|
|
1824
|
+
const route = routes[i];
|
|
1825
|
+
if (route.options.notFoundComponent) return route.id;
|
|
1826
|
+
fallback ||= route.children && route.id;
|
|
1827
|
+
}
|
|
1828
|
+
if (fallback) return fallback;
|
|
1829
|
+
}
|
|
1830
|
+
return rootRouteId;
|
|
1831
|
+
}
|
|
1832
|
+
function extractStrictParams(route, accumulatedParams) {
|
|
1833
|
+
const parseParams = route.options.params?.parse ?? route.options.parseParams;
|
|
1834
|
+
if (parseParams) Object.assign(accumulatedParams, parseParams(accumulatedParams));
|
|
1835
|
+
}
|
|
1836
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/load-client.js
|
|
1837
|
+
function preloadComponent(route, type) {
|
|
1838
|
+
return route.options[type]?.preload?.();
|
|
1839
|
+
}
|
|
1840
|
+
function loadComponents(route, onPendingReady) {
|
|
1841
|
+
const component = preloadComponent(route, "component");
|
|
1842
|
+
let pending = preloadComponent(route, "pendingComponent");
|
|
1843
|
+
if (onPendingReady) {
|
|
1844
|
+
if (pending) pending = pending.then(onPendingReady);
|
|
1845
|
+
else onPendingReady();
|
|
1846
|
+
}
|
|
1847
|
+
if (component && pending) return Promise.all([component, pending]).then(() => {});
|
|
1848
|
+
return component ?? pending;
|
|
1849
|
+
}
|
|
1850
|
+
function loadRouteChunk(route, componentType, onPendingReady) {
|
|
1851
|
+
const afterLazy = () => componentType === false ? void 0 : componentType ? preloadComponent(route, componentType) : loadComponents(route, onPendingReady);
|
|
1852
|
+
const current = route._lazy;
|
|
1853
|
+
if (current) return current === true ? afterLazy() : current.then(afterLazy);
|
|
1854
|
+
if (!route.lazyFn) return afterLazy();
|
|
1855
|
+
const promise = route.lazyFn().then((lazyRoute) => {
|
|
1856
|
+
{
|
|
1857
|
+
const { id: _id, ...options } = lazyRoute.options;
|
|
1858
|
+
Object.assign(route.options, options);
|
|
1859
|
+
route._lazy = true;
|
|
1860
|
+
}
|
|
1861
|
+
}, (error) => {
|
|
1862
|
+
route._lazy = void 0;
|
|
1863
|
+
throw error;
|
|
1864
|
+
});
|
|
1865
|
+
route._lazy = promise;
|
|
1866
|
+
return promise.then(afterLazy);
|
|
1867
|
+
}
|
|
1868
|
+
/** Return the structural lane through the first terminal render boundary. */
|
|
1869
|
+
function _getRenderedMatches(matches) {
|
|
1870
|
+
const end = matches.findIndex((match) => match.status !== "success" || match._notFound) + 1;
|
|
1871
|
+
return end && end < matches.length ? matches.slice(0, end) : matches;
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Truthy when the transaction publishing `location` leaves `routeId` out of its
|
|
1875
|
+
* matches, so subscribers scoped to that route can skip the publication: the
|
|
1876
|
+
* route unmounts when the transaction commits, and a transaction that ends
|
|
1877
|
+
* otherwise is superseded or redirected by a newer publication. Only valid
|
|
1878
|
+
* synchronously inside the publication: the transaction's matches are emptied
|
|
1879
|
+
* at commit and before following a redirect. Publications without a matching
|
|
1880
|
+
* transaction (hydration) and scopes without a route never depart.
|
|
1881
|
+
*/
|
|
1882
|
+
function _isRouteDeparting(router, routeId, location) {
|
|
1883
|
+
const tx = router._tx;
|
|
1884
|
+
return routeId && tx?.[2] === location && !tx[3].some((match) => match.routeId === routeId);
|
|
1885
|
+
}
|
|
1886
|
+
/** Return the lane whose document assets belong to the current presentation. */
|
|
1887
|
+
function _getAssetMatches(matches) {
|
|
1888
|
+
let end = matches.length;
|
|
1889
|
+
for (let index = 0; index < end; index++) {
|
|
1890
|
+
const match = matches[index];
|
|
1891
|
+
if (match._assetEnd !== void 0) {
|
|
1892
|
+
end = Math.min(end, Math.max(index + 1, match._assetEnd));
|
|
1893
|
+
continue;
|
|
1894
|
+
}
|
|
1895
|
+
if (match.status !== "success" || match._notFound) {
|
|
1896
|
+
end = index + 1;
|
|
1897
|
+
break;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
return end < matches.length ? matches.slice(0, end) : matches;
|
|
1901
|
+
}
|
|
1902
|
+
var SUCCESS$1 = 0;
|
|
1903
|
+
var ERROR$1 = 1;
|
|
1904
|
+
var NOT_FOUND$1 = 2;
|
|
1905
|
+
var REDIRECTED$1 = 3;
|
|
1906
|
+
var CANCELED_OUTCOME = [4];
|
|
1907
|
+
function isControl(result) {
|
|
1908
|
+
return typeof result[0] === "number";
|
|
1909
|
+
}
|
|
1910
|
+
function waitFor$1(value, signal) {
|
|
1911
|
+
if (signal.aborted) return Promise.race([Promise.reject(signal), value]);
|
|
1912
|
+
return new Promise((resolve, reject) => {
|
|
1913
|
+
const abort = () => reject(signal);
|
|
1914
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
1915
|
+
Promise.resolve(value).then(resolve, reject).then(() => signal.removeEventListener("abort", abort));
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
function getRoute$1(router, match) {
|
|
1919
|
+
return router.routesById[match.routeId];
|
|
1920
|
+
}
|
|
1921
|
+
function normalize$1(value, rejected, routeId) {
|
|
1922
|
+
if (isRedirect(value)) return [REDIRECTED$1, value];
|
|
1923
|
+
if (isNotFound(value)) {
|
|
1924
|
+
value.routeId ||= routeId;
|
|
1925
|
+
return [NOT_FOUND$1, value];
|
|
1926
|
+
}
|
|
1927
|
+
if (!rejected) return [SUCCESS$1, value];
|
|
1928
|
+
if (typeof value?.then === "function") value = new Error("A Promise was thrown", { cause: value });
|
|
1929
|
+
return [ERROR$1, value];
|
|
1930
|
+
}
|
|
1931
|
+
function normalizeError$1(route, cause) {
|
|
1932
|
+
let outcome = normalize$1(cause, true, route.id);
|
|
1933
|
+
if (outcome[0] !== ERROR$1) return outcome;
|
|
1934
|
+
try {
|
|
1935
|
+
route.options.onError?.(outcome[1]);
|
|
1936
|
+
} catch (onErrorCause) {
|
|
1937
|
+
outcome = normalize$1(onErrorCause, true, route.id);
|
|
1938
|
+
}
|
|
1939
|
+
return outcome;
|
|
1940
|
+
}
|
|
1941
|
+
function normalizeLaneError(router, lane, route, cause, options) {
|
|
1942
|
+
if (options[0].signal.aborted) return CANCELED_OUTCOME;
|
|
1943
|
+
return materializeRedirect$1(router, lane, route, normalizeError$1(route, cause), options);
|
|
1944
|
+
}
|
|
1945
|
+
async function contextualize$1(router, lane, options, end, planSuccessfulLane, retainedEnd) {
|
|
1946
|
+
const [location, matches] = lane;
|
|
1947
|
+
const signal = options[0].signal;
|
|
1948
|
+
const preload = !!options[3];
|
|
1949
|
+
for (let index = options[6] ?? 0; index < end; index++) {
|
|
1950
|
+
const match = matches[index];
|
|
1951
|
+
const route = getRoute$1(router, match);
|
|
1952
|
+
match.abortController = options[0];
|
|
1953
|
+
const parentContext = matches[index - 1]?.context ?? router.options.context ?? {};
|
|
1954
|
+
const common = {
|
|
1955
|
+
params: match.params,
|
|
1956
|
+
location,
|
|
1957
|
+
navigate: (opts) => router.navigate({
|
|
1958
|
+
...opts,
|
|
1959
|
+
_fromLocation: location
|
|
1960
|
+
}),
|
|
1961
|
+
buildLocation: router.buildLocation,
|
|
1962
|
+
cause: preload ? "preload" : match.cause,
|
|
1963
|
+
abortController: options[0],
|
|
1964
|
+
preload,
|
|
1965
|
+
matches,
|
|
1966
|
+
routeId: route.id
|
|
1967
|
+
};
|
|
1968
|
+
try {
|
|
1969
|
+
const routeContext = match._ctx ||= route.options.context ? route.options.context({
|
|
1970
|
+
...common,
|
|
1971
|
+
deps: match.loaderDeps,
|
|
1972
|
+
context: parentContext
|
|
1973
|
+
}) || {} : void 0;
|
|
1974
|
+
match.context = {
|
|
1975
|
+
...parentContext,
|
|
1976
|
+
...routeContext
|
|
1977
|
+
};
|
|
1978
|
+
} catch (cause) {
|
|
1979
|
+
releaseFlight(router, match);
|
|
1980
|
+
return [index, normalizeLaneError(router, lane, route, cause, options)];
|
|
1981
|
+
}
|
|
1982
|
+
if (signal.aborted) return [index, CANCELED_OUTCOME];
|
|
1983
|
+
const validationError = match.paramsError ?? match.searchError;
|
|
1984
|
+
if (validationError !== void 0) {
|
|
1985
|
+
releaseFlight(router, match);
|
|
1986
|
+
return [index, normalizeLaneError(router, lane, route, validationError, options)];
|
|
1987
|
+
}
|
|
1988
|
+
const beforeLoad = route.options.beforeLoad;
|
|
1989
|
+
if (!beforeLoad) continue;
|
|
1990
|
+
const previousStatus = match.status;
|
|
1991
|
+
if (index >= retainedEnd) {
|
|
1992
|
+
match.status = "pending";
|
|
1993
|
+
options[7]?.();
|
|
1994
|
+
}
|
|
1995
|
+
try {
|
|
1996
|
+
setFetching(router, match, "beforeLoad", options[0]);
|
|
1997
|
+
const value = beforeLoad({
|
|
1998
|
+
...common,
|
|
1999
|
+
search: match.search,
|
|
2000
|
+
context: match.context,
|
|
2001
|
+
...router.options.additionalContext
|
|
2002
|
+
});
|
|
2003
|
+
const result = await (typeof value?.then === "function" ? waitFor$1(value, signal) : value);
|
|
2004
|
+
if (signal.aborted) return [index, CANCELED_OUTCOME];
|
|
2005
|
+
const outcome = materializeRedirect$1(router, lane, route, normalize$1(result, false, route.id), options);
|
|
2006
|
+
if (outcome[0] !== SUCCESS$1) {
|
|
2007
|
+
releaseFlight(router, match);
|
|
2008
|
+
return [index, outcome];
|
|
2009
|
+
}
|
|
2010
|
+
match.context = {
|
|
2011
|
+
...match.context,
|
|
2012
|
+
...result
|
|
2013
|
+
};
|
|
2014
|
+
} catch (cause) {
|
|
2015
|
+
releaseFlight(router, match);
|
|
2016
|
+
return [index, normalizeLaneError(router, lane, route, cause, options)];
|
|
2017
|
+
} finally {
|
|
2018
|
+
match.status = previousStatus;
|
|
2019
|
+
setFetching(router, match, false, options[0]);
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
planSuccessfulLane();
|
|
2023
|
+
}
|
|
2024
|
+
function releaseOwnedFlight(router, match, flight) {
|
|
2025
|
+
if (!flight || --flight[2]) return;
|
|
2026
|
+
if (router._flights?.get(match.id) === flight) {
|
|
2027
|
+
const current = router._tx;
|
|
2028
|
+
if (current && !current[0].signal.aborted && !current[3].includes(match) && current[3].some((candidate) => candidate.id === match.id) && current[3].some((candidate) => candidate.isFetching === "beforeLoad")) return;
|
|
2029
|
+
router._flights.delete(match.id);
|
|
2030
|
+
}
|
|
2031
|
+
return flight[1];
|
|
2032
|
+
}
|
|
2033
|
+
function releaseFlight(router, match) {
|
|
2034
|
+
const flight = match._flight;
|
|
2035
|
+
match._flight = void 0;
|
|
2036
|
+
releaseOwnedFlight(router, match, flight)?.abort();
|
|
2037
|
+
}
|
|
2038
|
+
/**
|
|
2039
|
+
* Not passing in a `next` ownership recipient
|
|
2040
|
+
* is equivalent to discarding the match resources
|
|
2041
|
+
*/
|
|
2042
|
+
function transferMatchResources(router, previous, next, deferSameIdFlight) {
|
|
2043
|
+
const abort = [];
|
|
2044
|
+
for (const match of previous) if (!next?.includes(match)) {
|
|
2045
|
+
const flight = match._flight;
|
|
2046
|
+
match._flight = void 0;
|
|
2047
|
+
if (deferSameIdFlight && flight?.[2] === 1 && router._flights?.get(match.id) === flight && next?.some((candidate) => candidate.id === match.id)) flight[2] = 0;
|
|
2048
|
+
else {
|
|
2049
|
+
const controller = releaseOwnedFlight(router, match, flight);
|
|
2050
|
+
if (controller) abort.push(controller);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
for (const controller of abort) controller.abort();
|
|
2054
|
+
}
|
|
2055
|
+
function acquireMatchResources(matches) {
|
|
2056
|
+
for (const match of matches) {
|
|
2057
|
+
const flight = match._flight;
|
|
2058
|
+
if (flight) flight[2]++;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
function setFetching(router, match, value, owner) {
|
|
2062
|
+
match.isFetching = value;
|
|
2063
|
+
if (owner && router._tx?.[0] !== owner) return;
|
|
2064
|
+
const store = router.stores.byRoute.get(match.routeId);
|
|
2065
|
+
const presented = store?.get();
|
|
2066
|
+
if (presented?.id === match.id) store.set({
|
|
2067
|
+
...presented,
|
|
2068
|
+
isFetching: value
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
function getLoaderContext$1(router, lane, match, route, controller, parentMatchPromise, preload) {
|
|
2072
|
+
const location = lane[0];
|
|
2073
|
+
return {
|
|
2074
|
+
params: match.params,
|
|
2075
|
+
location,
|
|
2076
|
+
navigate: (opts) => router.navigate({
|
|
2077
|
+
...opts,
|
|
2078
|
+
_fromLocation: location
|
|
2079
|
+
}),
|
|
2080
|
+
cause: preload ? "preload" : match.cause,
|
|
2081
|
+
abortController: controller,
|
|
2082
|
+
preload,
|
|
2083
|
+
deps: match.loaderDeps,
|
|
2084
|
+
parentMatchPromise,
|
|
2085
|
+
context: match.context,
|
|
2086
|
+
route,
|
|
2087
|
+
...router.options.additionalContext
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
2090
|
+
async function loadResource(router, lane, match, route, loader, parentMatchPromise, options) {
|
|
2091
|
+
const owner = options[0];
|
|
2092
|
+
const signal = owner.signal;
|
|
2093
|
+
if (signal.aborted) return CANCELED_OUTCOME;
|
|
2094
|
+
if (!loader) return [SUCCESS$1, void 0];
|
|
2095
|
+
let flight = match._flight;
|
|
2096
|
+
setFetching(router, match, "loader", owner);
|
|
2097
|
+
try {
|
|
2098
|
+
if (!flight) {
|
|
2099
|
+
const controller = new AbortController();
|
|
2100
|
+
flight = [
|
|
2101
|
+
Promise.resolve().then(() => loader(getLoaderContext$1(router, lane, match, route, controller, parentMatchPromise, !!options[3]))).then((value) => normalize$1(value, false, route.id), (cause) => normalize$1(cause, true, route.id)).then((result) => {
|
|
2102
|
+
if (result[0] !== SUCCESS$1 && router._flights?.get(match.id) === flight) {
|
|
2103
|
+
router._flights.delete(match.id);
|
|
2104
|
+
if (!flight[2]) controller.abort();
|
|
2105
|
+
}
|
|
2106
|
+
return result[0] === ERROR$1 && flight[2] ? normalizeError$1(route, result[1]) : result;
|
|
2107
|
+
}),
|
|
2108
|
+
controller,
|
|
2109
|
+
1
|
|
2110
|
+
];
|
|
2111
|
+
(router._flights ??= /* @__PURE__ */ new Map()).set(match.id, flight);
|
|
2112
|
+
}
|
|
2113
|
+
match._flight = flight;
|
|
2114
|
+
match.abortController = flight[1];
|
|
2115
|
+
return materializeRedirect$1(router, lane, route, await waitFor$1(flight[0], signal), options);
|
|
2116
|
+
} catch (cause) {
|
|
2117
|
+
if (cause !== signal || !signal.aborted) throw cause;
|
|
2118
|
+
releaseFlight(router, match);
|
|
2119
|
+
return CANCELED_OUTCOME;
|
|
2120
|
+
} finally {
|
|
2121
|
+
setFetching(router, match, false, owner);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
function settleInto(match, result, preload) {
|
|
2125
|
+
if (result[0] === REDIRECTED$1) return;
|
|
2126
|
+
match.status = "success";
|
|
2127
|
+
match.error = void 0;
|
|
2128
|
+
if (result[0] === SUCCESS$1) {
|
|
2129
|
+
match.loaderData = result[1];
|
|
2130
|
+
match.invalid = false;
|
|
2131
|
+
match.updatedAt = Date.now();
|
|
2132
|
+
match.preload = preload;
|
|
2133
|
+
} else match.invalid = true;
|
|
2134
|
+
}
|
|
2135
|
+
function cacheLoaderMatch(router, match, planned) {
|
|
2136
|
+
const current = router._cache.get(match.id);
|
|
2137
|
+
if (current !== planned || router._committed.some((candidate) => candidate.id === match.id && candidate._flight === match._flight)) return;
|
|
2138
|
+
const cached = {
|
|
2139
|
+
...match,
|
|
2140
|
+
_notFound: void 0,
|
|
2141
|
+
context: {}
|
|
2142
|
+
};
|
|
2143
|
+
if (cached._flight) cached._flight[2]++;
|
|
2144
|
+
router._cache.set(match.id, cached);
|
|
2145
|
+
if (current) releaseFlight(router, current);
|
|
2146
|
+
}
|
|
2147
|
+
function getParentSnapshot(match, outcome) {
|
|
2148
|
+
if (outcome[0] === ERROR$1 || outcome[0] === NOT_FOUND$1) return {
|
|
2149
|
+
...match,
|
|
2150
|
+
status: outcome[0] === ERROR$1 ? "error" : "notFound",
|
|
2151
|
+
error: outcome[1],
|
|
2152
|
+
_flight: void 0
|
|
2153
|
+
};
|
|
2154
|
+
return match;
|
|
2155
|
+
}
|
|
2156
|
+
function createLoaderTask$1(router, lane, index, tasks, semanticParent, options, retainedEnd) {
|
|
2157
|
+
const match = lane[1][index];
|
|
2158
|
+
const route = getRoute$1(router, match);
|
|
2159
|
+
const preload = !!options[3];
|
|
2160
|
+
const plannedCacheMatch = router._cache.get(match.id);
|
|
2161
|
+
let configured;
|
|
2162
|
+
let reload = false;
|
|
2163
|
+
let reloadFailure;
|
|
2164
|
+
try {
|
|
2165
|
+
if (match.status === "success") {
|
|
2166
|
+
configured = route.options.shouldReload;
|
|
2167
|
+
if (typeof configured === "function") configured = configured(getLoaderContext$1(router, lane, match, route, options[0], semanticParent, preload));
|
|
2168
|
+
if (options[0].signal.aborted) reloadFailure = CANCELED_OUTCOME;
|
|
2169
|
+
}
|
|
2170
|
+
if (!reloadFailure) {
|
|
2171
|
+
if (match.status !== "success") reload = true;
|
|
2172
|
+
else {
|
|
2173
|
+
const staleAge = preload || match.preload ? route.options.preloadStaleTime ?? router.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? router.options.defaultStaleTime ?? 0;
|
|
2174
|
+
reload = !!(match.invalid || configured || configured === void 0 && Date.now() - match.updatedAt >= staleAge && (options[5] || match.cause === "enter" || options[2].some((candidate) => candidate.routeId === match.routeId && candidate.id !== match.id)));
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
} catch (cause) {
|
|
2178
|
+
match.invalid = true;
|
|
2179
|
+
releaseFlight(router, match);
|
|
2180
|
+
reloadFailure = normalizeLaneError(router, lane, route, cause, options);
|
|
2181
|
+
}
|
|
2182
|
+
const routeLoader = route.options.loader;
|
|
2183
|
+
const isLoaderFn = typeof routeLoader === "function";
|
|
2184
|
+
const loader = isLoaderFn ? routeLoader : routeLoader?.handler;
|
|
2185
|
+
const preloadable = !preload || route.options.preload !== false;
|
|
2186
|
+
let donor = preloadable && routeLoader && true ? router._flights?.get(match.id) : void 0;
|
|
2187
|
+
if (donor === match._flight || reloadFailure) donor = void 0;
|
|
2188
|
+
else if (donor && !reload && !preload && configured === void 0) reload = true;
|
|
2189
|
+
else if (!reload) donor = void 0;
|
|
2190
|
+
const background = !!(routeLoader && reload && match.status === "success" && !preload && !options[4] && ((isLoaderFn ? void 0 : routeLoader.staleReloadMode) ?? router.options.defaultStaleReloadMode) !== "blocking");
|
|
2191
|
+
const loaded = reload && preloadable;
|
|
2192
|
+
const blocking = loaded && !background && (match.status !== "success" || !!routeLoader);
|
|
2193
|
+
const onReady = index >= retainedEnd ? options[7] : void 0;
|
|
2194
|
+
const onLazyReady = route.lazyFn && route._lazy !== true ? onReady : void 0;
|
|
2195
|
+
if (loaded && !routeLoader) {
|
|
2196
|
+
match.invalid = false;
|
|
2197
|
+
match.updatedAt = Date.now();
|
|
2198
|
+
}
|
|
2199
|
+
if (donor) donor[2]++;
|
|
2200
|
+
if (blocking) {
|
|
2201
|
+
const acceptedFlight = match._flight;
|
|
2202
|
+
match._flight = donor;
|
|
2203
|
+
releaseOwnedFlight(router, match, acceptedFlight)?.abort();
|
|
2204
|
+
if (index >= retainedEnd) match.status = "pending";
|
|
2205
|
+
onReady?.();
|
|
2206
|
+
}
|
|
2207
|
+
if (!loaded) match.isFetching = false;
|
|
2208
|
+
const outcome = !reloadFailure && blocking ? loadResource(router, lane, match, route, loader, semanticParent, options).then((result) => {
|
|
2209
|
+
settleInto(match, result, preload);
|
|
2210
|
+
if (result[0] === SUCCESS$1) {
|
|
2211
|
+
if (routeLoader && !options[0].signal.aborted) cacheLoaderMatch(router, match, plannedCacheMatch);
|
|
2212
|
+
if (index >= retainedEnd) match.status = "pending";
|
|
2213
|
+
}
|
|
2214
|
+
return result;
|
|
2215
|
+
}) : Promise.resolve(reloadFailure ?? [SUCCESS$1, match.loaderData]);
|
|
2216
|
+
const chunkFailure = (async () => {
|
|
2217
|
+
try {
|
|
2218
|
+
const chunk = loadRouteChunk(route, void 0, onLazyReady);
|
|
2219
|
+
if (chunk) await waitFor$1(chunk, options[0].signal);
|
|
2220
|
+
} catch (cause) {
|
|
2221
|
+
if (!lane[1].some((candidate, candidateIndex) => candidateIndex <= index && (candidate.status === "error" || candidate.status === "notFound" || candidate._notFound))) return [index, normalizeLaneError(router, lane, route, cause, options)];
|
|
2222
|
+
}
|
|
2223
|
+
const result = await outcome;
|
|
2224
|
+
if (blocking && result[0] === SUCCESS$1 && match.status === "pending" && !options[0].signal.aborted) {
|
|
2225
|
+
match.status = "success";
|
|
2226
|
+
onReady?.();
|
|
2227
|
+
}
|
|
2228
|
+
})();
|
|
2229
|
+
tasks.push([
|
|
2230
|
+
index,
|
|
2231
|
+
outcome,
|
|
2232
|
+
chunkFailure
|
|
2233
|
+
]);
|
|
2234
|
+
if (!background) return outcome.then((result) => getParentSnapshot(match, result));
|
|
2235
|
+
const candidate = {
|
|
2236
|
+
...match,
|
|
2237
|
+
status: "pending",
|
|
2238
|
+
preload: false,
|
|
2239
|
+
_flight: donor
|
|
2240
|
+
};
|
|
2241
|
+
match.invalid = false;
|
|
2242
|
+
match.isFetching = "loader";
|
|
2243
|
+
const backgroundOutcome = loadResource(router, lane, candidate, route, loader, semanticParent, options).then((result) => {
|
|
2244
|
+
match.isFetching = false;
|
|
2245
|
+
settleInto(candidate, result, false);
|
|
2246
|
+
return result;
|
|
2247
|
+
});
|
|
2248
|
+
(lane[2] ??= []).push([
|
|
2249
|
+
index,
|
|
2250
|
+
backgroundOutcome,
|
|
2251
|
+
chunkFailure,
|
|
2252
|
+
candidate
|
|
2253
|
+
]);
|
|
2254
|
+
return backgroundOutcome.then((result) => getParentSnapshot(candidate, result));
|
|
2255
|
+
}
|
|
2256
|
+
async function getNotFoundBoundary$1(router, matches, indexed, signal, fallback = 0) {
|
|
2257
|
+
const cause = indexed?.[1][1];
|
|
2258
|
+
let index = cause?.routeId ? matches.findIndex((match) => match.routeId === cause.routeId) : indexed?.[0] ?? matches.length - 1;
|
|
2259
|
+
if (index < 0) index = 0;
|
|
2260
|
+
for (let i = index; i >= 0; i--) {
|
|
2261
|
+
const route = getRoute$1(router, matches[i]);
|
|
2262
|
+
try {
|
|
2263
|
+
const loading = loadRouteChunk(route, false);
|
|
2264
|
+
if (loading) await waitFor$1(loading, signal);
|
|
2265
|
+
} catch (cause) {
|
|
2266
|
+
if (cause === signal && signal.aborted) throw cause;
|
|
2267
|
+
}
|
|
2268
|
+
if (route.options.notFoundComponent) return i;
|
|
2269
|
+
}
|
|
2270
|
+
return cause?.routeId ? index : fallback;
|
|
2271
|
+
}
|
|
2272
|
+
function discardBackground(router, lane) {
|
|
2273
|
+
if (lane[2]) {
|
|
2274
|
+
transferMatchResources(router, lane[2].map((task) => task[3]));
|
|
2275
|
+
lane[2] = void 0;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
async function settleTasks(tasks, serialFailure, redirectTasks, gate) {
|
|
2279
|
+
let loaderFailure;
|
|
2280
|
+
try {
|
|
2281
|
+
await Promise.all(tasks.map((task) => task[1].then(async (outcome) => {
|
|
2282
|
+
const taskIndex = task[0];
|
|
2283
|
+
if (gate && taskIndex >= await gate) return;
|
|
2284
|
+
if (outcome[0] >= REDIRECTED$1) throw [taskIndex, outcome];
|
|
2285
|
+
if (!loaderFailure && outcome[0] !== SUCCESS$1) {
|
|
2286
|
+
loaderFailure = [taskIndex, outcome];
|
|
2287
|
+
await Promise.all((redirectTasks ?? []).map((nextTask) => {
|
|
2288
|
+
if (nextTask[0] <= taskIndex) return;
|
|
2289
|
+
return nextTask[1].then((nextOutcome) => {
|
|
2290
|
+
if (nextOutcome[0] === REDIRECTED$1) throw [nextTask[0], nextOutcome];
|
|
2291
|
+
});
|
|
2292
|
+
}));
|
|
2293
|
+
}
|
|
2294
|
+
})));
|
|
2295
|
+
} catch (cause) {
|
|
2296
|
+
return cause;
|
|
2297
|
+
}
|
|
2298
|
+
return serialFailure ?? loaderFailure;
|
|
2299
|
+
}
|
|
2300
|
+
function materializeRedirect$1(router, lane, route, outcome, options, failed) {
|
|
2301
|
+
while (outcome[0] === REDIRECTED$1) {
|
|
2302
|
+
const redirect = outcome[1];
|
|
2303
|
+
const redirectOptions = redirect.options;
|
|
2304
|
+
try {
|
|
2305
|
+
if (redirectOptions.href || redirect.headers.has("Location")) {
|
|
2306
|
+
router.resolveRedirect(redirect);
|
|
2307
|
+
if (redirectOptions.reloadDocument) return outcome;
|
|
2308
|
+
}
|
|
2309
|
+
if (redirectOptions.reloadDocument ? options[3] : options[1] >= 20) return outcome;
|
|
2310
|
+
const location = router.buildLocation({
|
|
2311
|
+
...redirectOptions,
|
|
2312
|
+
_fromLocation: lane[0],
|
|
2313
|
+
_includeValidateSearch: true
|
|
2314
|
+
});
|
|
2315
|
+
const publicLocation = location.maskedLocation ?? location;
|
|
2316
|
+
if (publicLocation.external) {
|
|
2317
|
+
const resolved = redirect.clone();
|
|
2318
|
+
resolved.options = { ...redirectOptions };
|
|
2319
|
+
resolved.headers.set("Location", publicLocation.publicHref);
|
|
2320
|
+
router.resolveRedirect(resolved);
|
|
2321
|
+
return options[3] ? [REDIRECTED$1, resolved] : [
|
|
2322
|
+
REDIRECTED$1,
|
|
2323
|
+
resolved,
|
|
2324
|
+
publicLocation
|
|
2325
|
+
];
|
|
2326
|
+
}
|
|
2327
|
+
return [
|
|
2328
|
+
REDIRECTED$1,
|
|
2329
|
+
redirect,
|
|
2330
|
+
location
|
|
2331
|
+
];
|
|
2332
|
+
} catch (cause) {
|
|
2333
|
+
outcome = failed ? [ERROR$1, cause] : normalizeError$1(route, cause);
|
|
2334
|
+
failed = true;
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
return outcome;
|
|
2338
|
+
}
|
|
2339
|
+
async function reduceLane(router, lane, tasks, controller, settlement, onReady) {
|
|
2340
|
+
const matches = lane[1];
|
|
2341
|
+
let failure = await settlement;
|
|
2342
|
+
let redirectLimitExceeded = false;
|
|
2343
|
+
const plannedBoundary = matches.findIndex((match) => match._notFound);
|
|
2344
|
+
const boundaryOf = (found) => found[1][0] === NOT_FOUND$1 ? getNotFoundBoundary$1(router, matches, found, controller.signal) : found[0];
|
|
2345
|
+
let readinessEnd = plannedBoundary < 0 ? matches.length : plannedBoundary;
|
|
2346
|
+
if ((failure?.[1][0] ?? 0) >= REDIRECTED$1) readinessEnd = 0;
|
|
2347
|
+
else if (failure) {
|
|
2348
|
+
readinessEnd = failure[2] ??= await boundaryOf(failure);
|
|
2349
|
+
for (const task of tasks) {
|
|
2350
|
+
if (task[0] >= readinessEnd) break;
|
|
2351
|
+
const outcome = await task[1];
|
|
2352
|
+
if (outcome[0] !== SUCCESS$1 && outcome[0] < REDIRECTED$1 && !("loaderData" in matches[task[0]])) {
|
|
2353
|
+
failure = [task[0], outcome];
|
|
2354
|
+
readinessEnd = failure[2] = await boundaryOf(failure);
|
|
2355
|
+
break;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
for (const task of tasks) {
|
|
2360
|
+
if (task[0] >= readinessEnd) break;
|
|
2361
|
+
const chunkFailure = await task[2];
|
|
2362
|
+
if (!chunkFailure) continue;
|
|
2363
|
+
failure = chunkFailure;
|
|
2364
|
+
break;
|
|
2365
|
+
}
|
|
2366
|
+
if ((failure?.[1][0] ?? 0) >= REDIRECTED$1) {
|
|
2367
|
+
const outcome = failure[1];
|
|
2368
|
+
if (outcome[0] !== REDIRECTED$1 || outcome[1].options.reloadDocument || outcome[2]) {
|
|
2369
|
+
discardBackground(router, lane);
|
|
2370
|
+
return outcome;
|
|
2371
|
+
}
|
|
2372
|
+
redirectLimitExceeded = true;
|
|
2373
|
+
failure = [0, [ERROR$1, /* @__PURE__ */ new Error("Too many redirects")]];
|
|
2374
|
+
}
|
|
2375
|
+
const boundary = failure ? failure[2] ?? await boundaryOf(failure) : plannedBoundary;
|
|
2376
|
+
if (boundary >= 0) {
|
|
2377
|
+
const outcome = failure?.[1];
|
|
2378
|
+
const kind = outcome?.[0];
|
|
2379
|
+
const match = matches[boundary];
|
|
2380
|
+
const cause = outcome?.[1];
|
|
2381
|
+
const install = () => {
|
|
2382
|
+
if (outcome) {
|
|
2383
|
+
match._notFound = void 0;
|
|
2384
|
+
if (kind === ERROR$1) match.status = "error";
|
|
2385
|
+
else {
|
|
2386
|
+
cause.routeId = match.routeId;
|
|
2387
|
+
if (match.routeId === router.routeTree.id) {
|
|
2388
|
+
match.status = "success";
|
|
2389
|
+
match._notFound = true;
|
|
2390
|
+
} else match.status = "notFound";
|
|
2391
|
+
}
|
|
2392
|
+
match.error = cause;
|
|
2393
|
+
match.isFetching = false;
|
|
2394
|
+
}
|
|
2395
|
+
};
|
|
2396
|
+
install();
|
|
2397
|
+
if (!outcome) onReady?.();
|
|
2398
|
+
const route = getRoute$1(router, match);
|
|
2399
|
+
try {
|
|
2400
|
+
await waitFor$1(outcome ? Promise.resolve().then(() => loadRouteChunk(route, kind === ERROR$1 ? "errorComponent" : "notFoundComponent")) : Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]), controller.signal);
|
|
2401
|
+
} catch (cause) {
|
|
2402
|
+
if (cause === controller.signal && controller.signal.aborted) {
|
|
2403
|
+
discardBackground(router, lane);
|
|
2404
|
+
return CANCELED_OUTCOME;
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
if (!outcome) match.status = "success";
|
|
2408
|
+
else if (redirectLimitExceeded) {
|
|
2409
|
+
controller.abort();
|
|
2410
|
+
await Promise.all([
|
|
2411
|
+
...tasks.map((task) => task[1]),
|
|
2412
|
+
...tasks.map((task) => task[2]),
|
|
2413
|
+
...(lane[2] ?? []).map((task) => task[1])
|
|
2414
|
+
]);
|
|
2415
|
+
discardBackground(router, lane);
|
|
2416
|
+
transferMatchResources(router, matches);
|
|
2417
|
+
install();
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
return lane;
|
|
2421
|
+
}
|
|
2422
|
+
async function projectLane$1(router, lane, signal, start = 0, end = lane[1].length) {
|
|
2423
|
+
const matches = lane[1];
|
|
2424
|
+
for (let index = start; index < end; index++) {
|
|
2425
|
+
const match = matches[index];
|
|
2426
|
+
const routeOptions = getRoute$1(router, match).options;
|
|
2427
|
+
if (routeOptions.head || routeOptions.scripts) try {
|
|
2428
|
+
const context = {
|
|
2429
|
+
ssr: router.options.ssr,
|
|
2430
|
+
matches,
|
|
2431
|
+
match,
|
|
2432
|
+
params: match.params,
|
|
2433
|
+
loaderData: match.loaderData
|
|
2434
|
+
};
|
|
2435
|
+
const [head, scripts] = await waitFor$1(Promise.all([routeOptions.head?.(context), routeOptions.scripts?.(context)]), signal);
|
|
2436
|
+
match.meta = head?.meta;
|
|
2437
|
+
match.links = head?.links;
|
|
2438
|
+
match.headScripts = head?.scripts;
|
|
2439
|
+
match.styles = head?.styles;
|
|
2440
|
+
match.scripts = scripts;
|
|
2441
|
+
} catch (cause) {
|
|
2442
|
+
if (cause === signal && signal.aborted) break;
|
|
2443
|
+
console.error(cause);
|
|
2444
|
+
}
|
|
2445
|
+
if (match.status !== "success" || match._notFound) break;
|
|
2446
|
+
}
|
|
2447
|
+
return lane;
|
|
2448
|
+
}
|
|
2449
|
+
async function executeClientLane(router, location, matches, options) {
|
|
2450
|
+
const matched = [location, matches];
|
|
2451
|
+
const signal = options[0].signal;
|
|
2452
|
+
let reduced;
|
|
2453
|
+
try {
|
|
2454
|
+
const presented = router.stores.matches.get();
|
|
2455
|
+
let plannedBoundary = matches.findIndex((match) => match._notFound);
|
|
2456
|
+
if (router.options.notFoundMode !== "root" && plannedBoundary >= 0) {
|
|
2457
|
+
const boundary = await getNotFoundBoundary$1(router, matches, void 0, signal, plannedBoundary);
|
|
2458
|
+
matches[plannedBoundary]._notFound = void 0;
|
|
2459
|
+
matches[boundary]._notFound = true;
|
|
2460
|
+
plannedBoundary = boundary;
|
|
2461
|
+
}
|
|
2462
|
+
let end = plannedBoundary < 0 ? matches.length : plannedBoundary + 1;
|
|
2463
|
+
let retainedEnd = 0;
|
|
2464
|
+
while (retainedEnd < end && retainedEnd !== plannedBoundary) {
|
|
2465
|
+
const match = matches[retainedEnd];
|
|
2466
|
+
const committed = options[2][retainedEnd];
|
|
2467
|
+
const visible = presented[retainedEnd];
|
|
2468
|
+
if (committed?.id !== match.id || committed.status !== "success" || match.preload || visible?.id !== match.id || visible.status !== "success") break;
|
|
2469
|
+
retainedEnd++;
|
|
2470
|
+
if (committed._notFound || visible._notFound) break;
|
|
2471
|
+
}
|
|
2472
|
+
const tasks = [];
|
|
2473
|
+
const start = options[6] ?? 0;
|
|
2474
|
+
let semanticParent = start ? Promise.resolve(matches[start - 1]) : void 0;
|
|
2475
|
+
const planSuccessfulLane = () => {
|
|
2476
|
+
for (let index = start; index < end; index++) {
|
|
2477
|
+
if (signal.aborted) break;
|
|
2478
|
+
semanticParent = createLoaderTask$1(router, matched, index, tasks, semanticParent, options, retainedEnd);
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
const failure = await contextualize$1(router, matched, options, end, planSuccessfulLane, retainedEnd);
|
|
2482
|
+
if (failure) {
|
|
2483
|
+
options[4] = true;
|
|
2484
|
+
end = failure[0];
|
|
2485
|
+
if (failure[1][0] === NOT_FOUND$1) {
|
|
2486
|
+
const boundary = await getNotFoundBoundary$1(router, matches, failure, signal);
|
|
2487
|
+
failure[2] = boundary;
|
|
2488
|
+
end = Math.min(end, boundary + 1);
|
|
2489
|
+
} else if (failure[1][0] >= REDIRECTED$1) end = 0;
|
|
2490
|
+
planSuccessfulLane();
|
|
2491
|
+
}
|
|
2492
|
+
if (!signal.aborted && !options[3]) {
|
|
2493
|
+
const abort = [];
|
|
2494
|
+
for (const [id, flight] of router._flights ?? []) if (!flight[2]) {
|
|
2495
|
+
router._flights.delete(id);
|
|
2496
|
+
abort.push(flight[1]);
|
|
2497
|
+
}
|
|
2498
|
+
for (const controller of abort) controller.abort();
|
|
2499
|
+
}
|
|
2500
|
+
const reduction = reduceLane(router, matched, tasks, options[0], settleTasks(tasks, failure, matched[2]), options[7]);
|
|
2501
|
+
if (matched[2]?.length) matched[3] = settleTasks(matched[2], void 0, void 0, reduction.then((foreground) => isControl(foreground) ? 0 : _getRenderedMatches(matches).length, () => 0));
|
|
2502
|
+
reduced = await reduction;
|
|
2503
|
+
} catch (cause) {
|
|
2504
|
+
discardBackground(router, matched);
|
|
2505
|
+
if (cause === signal && signal.aborted) return CANCELED_OUTCOME;
|
|
2506
|
+
throw cause;
|
|
2507
|
+
}
|
|
2508
|
+
if (isControl(reduced)) return reduced;
|
|
2509
|
+
return projectLane$1(router, reduced, signal, options[6] === matches.length ? options[6] : 0);
|
|
2510
|
+
}
|
|
2511
|
+
async function preloadClientRoute(router, opts) {
|
|
2512
|
+
let location = router.buildLocation(opts);
|
|
2513
|
+
for (let redirects = 0;; redirects++) {
|
|
2514
|
+
const base = router._committed;
|
|
2515
|
+
const controller = new AbortController();
|
|
2516
|
+
let matches;
|
|
2517
|
+
let active;
|
|
2518
|
+
let result;
|
|
2519
|
+
try {
|
|
2520
|
+
try {
|
|
2521
|
+
matches = router.matchRoutes(location, { _controller: controller });
|
|
2522
|
+
acquireMatchResources(matches);
|
|
2523
|
+
active = (router._preloads ??= /* @__PURE__ */ new Map()).set(controller, matches);
|
|
2524
|
+
result = await executeClientLane(router, location, matches, [
|
|
2525
|
+
controller,
|
|
2526
|
+
redirects,
|
|
2527
|
+
base,
|
|
2528
|
+
true
|
|
2529
|
+
]);
|
|
2530
|
+
} finally {
|
|
2531
|
+
if (active) {
|
|
2532
|
+
active = active.delete(controller);
|
|
2533
|
+
transferMatchResources(router, matches);
|
|
2534
|
+
}
|
|
2535
|
+
controller.abort();
|
|
2536
|
+
}
|
|
2537
|
+
if (!isControl(result)) return result[1];
|
|
2538
|
+
if (!active || result.length < 3 || false) return;
|
|
2539
|
+
location = result[2];
|
|
2540
|
+
} catch (cause) {
|
|
2541
|
+
if (!isNotFound(cause)) console.error(cause);
|
|
2542
|
+
return;
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/await-signal.js
|
|
2547
|
+
function observeLate(callback, value) {
|
|
2548
|
+
if (!callback) return;
|
|
2549
|
+
try {
|
|
2550
|
+
const result = callback(value);
|
|
2551
|
+
if (result !== void 0) Promise.resolve(result).catch(() => {});
|
|
2552
|
+
} catch {}
|
|
2553
|
+
}
|
|
2554
|
+
/**
|
|
2555
|
+
* Await `value` unless `signal` aborts first. A result that settles after the
|
|
2556
|
+
* abort is passed to `onLate` / `onLateError` instead.
|
|
2557
|
+
*
|
|
2558
|
+
* One abort listener per wait: SSR requests nest at most a few waits on one
|
|
2559
|
+
* signal, so pooling them was measurably slower than this.
|
|
2560
|
+
*/
|
|
2561
|
+
function waitForReason(value, signal, onLate, onLateError) {
|
|
2562
|
+
const promise = Promise.resolve(value);
|
|
2563
|
+
if (signal.aborted) {
|
|
2564
|
+
promise.then((result) => observeLate(onLate, result), (error) => observeLate(onLateError, error));
|
|
2565
|
+
return Promise.reject(signal.reason);
|
|
2566
|
+
}
|
|
2567
|
+
return new Promise((resolve, reject) => {
|
|
2568
|
+
const abort = () => reject(signal.reason);
|
|
2569
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
2570
|
+
promise.then((result) => {
|
|
2571
|
+
signal.removeEventListener("abort", abort);
|
|
2572
|
+
if (signal.aborted) observeLate(onLate, result);
|
|
2573
|
+
else resolve(result);
|
|
2574
|
+
}, (error) => {
|
|
2575
|
+
signal.removeEventListener("abort", abort);
|
|
2576
|
+
if (signal.aborted) observeLate(onLateError, error);
|
|
2577
|
+
else reject(error);
|
|
2578
|
+
});
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
// ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/load-server.js
|
|
2582
|
+
var SUCCESS = 0;
|
|
2583
|
+
var ERROR = 1;
|
|
2584
|
+
var NOT_FOUND = 2;
|
|
2585
|
+
var REDIRECTED = 3;
|
|
2586
|
+
var SKIPPED = 4;
|
|
2587
|
+
var MATCH_SETTLED_ABORT_REASON = Object.freeze({
|
|
2588
|
+
name: "AbortError",
|
|
2589
|
+
message: "TanStack Router aborted this server match because it settled."
|
|
2590
|
+
});
|
|
2591
|
+
var REDIRECT_ABORT_REASON = Object.freeze({
|
|
2592
|
+
name: "AbortError",
|
|
2593
|
+
message: "TanStack Router aborted this server match because of a redirect."
|
|
2594
|
+
});
|
|
2595
|
+
function getRoute(router, match) {
|
|
2596
|
+
return router.routesById[match.routeId];
|
|
2597
|
+
}
|
|
2598
|
+
function normalize(value, rejected) {
|
|
2599
|
+
if (isRedirect(value)) return [REDIRECTED, value];
|
|
2600
|
+
if (isNotFound(value)) return [NOT_FOUND, value];
|
|
2601
|
+
if (rejected && typeof value?.then === "function") value = new Error("A Promise was thrown", { cause: value });
|
|
2602
|
+
return rejected ? [ERROR, value] : [SUCCESS, value];
|
|
2603
|
+
}
|
|
2604
|
+
function normalizeError(router, lane, route, cause, signal, notify = true) {
|
|
2605
|
+
signal?.throwIfAborted();
|
|
2606
|
+
let outcome = normalize(cause, true);
|
|
2607
|
+
if (outcome[0] !== ERROR) return materializeRedirect(router, lane, route, outcome, signal, notify);
|
|
2608
|
+
try {
|
|
2609
|
+
route.options.onError?.(outcome[1]);
|
|
2610
|
+
} catch (onErrorCause) {
|
|
2611
|
+
outcome = normalize(onErrorCause, true);
|
|
2612
|
+
}
|
|
2613
|
+
signal?.throwIfAborted();
|
|
2614
|
+
return materializeRedirect(router, lane, route, outcome, signal, notify);
|
|
2615
|
+
}
|
|
2616
|
+
function materializeRedirect(router, lane, route, outcome, signal, notify = true) {
|
|
2617
|
+
if (outcome[0] !== REDIRECTED) return outcome;
|
|
2618
|
+
signal?.throwIfAborted();
|
|
2619
|
+
try {
|
|
2620
|
+
outcome[1].options._fromLocation = lane.location;
|
|
2621
|
+
router.resolveRedirect(outcome[1]);
|
|
2622
|
+
signal?.throwIfAborted();
|
|
2623
|
+
return outcome;
|
|
2624
|
+
} catch (cause) {
|
|
2625
|
+
signal?.throwIfAborted();
|
|
2626
|
+
return notify ? normalizeError(router, lane, route, cause, signal, false) : [ERROR, cause];
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
function maybe(value, cause) {
|
|
2630
|
+
if (cause !== void 0) return {
|
|
2631
|
+
status: "error",
|
|
2632
|
+
error: cause
|
|
2633
|
+
};
|
|
2634
|
+
return {
|
|
2635
|
+
status: "success",
|
|
2636
|
+
value
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
function navigateFrom(router, location) {
|
|
2640
|
+
return (options) => router.navigate({
|
|
2641
|
+
...options,
|
|
2642
|
+
_fromLocation: location
|
|
2643
|
+
});
|
|
2644
|
+
}
|
|
2645
|
+
function waitFor(value, signal) {
|
|
2646
|
+
return signal ? waitForReason(value, signal) : value;
|
|
2647
|
+
}
|
|
2648
|
+
function resolveSsr(router, lane, index) {
|
|
2649
|
+
const match = lane.matches[index];
|
|
2650
|
+
const route = getRoute(router, match);
|
|
2651
|
+
const parentSsr = lane.matches[index - 1]?.ssr;
|
|
2652
|
+
if (router.isShell()) return route.id === rootRouteId;
|
|
2653
|
+
if (parentSsr === false) return false;
|
|
2654
|
+
const inherit = (value) => {
|
|
2655
|
+
return value === true && parentSsr === "data-only" ? "data-only" : value;
|
|
2656
|
+
};
|
|
2657
|
+
const defaultSsr = router.options.defaultSsr ?? true;
|
|
2658
|
+
const inheritedDefault = inherit(defaultSsr);
|
|
2659
|
+
match.ssr = inheritedDefault;
|
|
2660
|
+
const option = route.options.ssr;
|
|
2661
|
+
if (option === void 0) return inheritedDefault;
|
|
2662
|
+
if (typeof option !== "function") return inherit(option);
|
|
2663
|
+
const context = {
|
|
2664
|
+
search: maybe(match.search, match.searchError),
|
|
2665
|
+
params: maybe(match.params, match.paramsError),
|
|
2666
|
+
location: lane.location,
|
|
2667
|
+
matches: lane.matches.map((candidate) => ({
|
|
2668
|
+
index: candidate.index,
|
|
2669
|
+
pathname: candidate.pathname,
|
|
2670
|
+
fullPath: candidate.fullPath,
|
|
2671
|
+
staticData: candidate.staticData,
|
|
2672
|
+
id: candidate.id,
|
|
2673
|
+
routeId: candidate.routeId,
|
|
2674
|
+
search: maybe(candidate.search, candidate.searchError),
|
|
2675
|
+
params: maybe(candidate.params, candidate.paramsError),
|
|
2676
|
+
ssr: candidate.ssr
|
|
2677
|
+
}))
|
|
2678
|
+
};
|
|
2679
|
+
try {
|
|
2680
|
+
return Promise.resolve(option(context)).then((value) => inherit(value ?? defaultSsr));
|
|
2681
|
+
} catch (cause) {
|
|
2682
|
+
return Promise.reject(cause);
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
function stampNotFound(match, outcome) {
|
|
2686
|
+
if (outcome[0] === NOT_FOUND && !outcome[1].routeId) outcome[1].routeId = match.routeId;
|
|
2687
|
+
return outcome;
|
|
2688
|
+
}
|
|
2689
|
+
async function contextualize(router, lane, signal) {
|
|
2690
|
+
const globalBoundary = lane.matches.findIndex((match) => match._notFound);
|
|
2691
|
+
let end = globalBoundary < 0 ? lane.matches.length : globalBoundary + 1;
|
|
2692
|
+
let failure;
|
|
2693
|
+
let parentContext = { ...router.options.context ?? {} };
|
|
2694
|
+
for (let index = 0; index < end; index++) {
|
|
2695
|
+
const match = lane.matches[index];
|
|
2696
|
+
const route = getRoute(router, match);
|
|
2697
|
+
try {
|
|
2698
|
+
const ssr = resolveSsr(router, lane, index);
|
|
2699
|
+
match.ssr = ssr instanceof Promise ? await ssr : ssr;
|
|
2700
|
+
} catch (cause) {
|
|
2701
|
+
signal?.throwIfAborted();
|
|
2702
|
+
failure = [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
|
|
2703
|
+
end = index;
|
|
2704
|
+
}
|
|
2705
|
+
signal?.throwIfAborted();
|
|
2706
|
+
if (failure?.[1][0] === REDIRECTED) break;
|
|
2707
|
+
match.__beforeLoadContext = void 0;
|
|
2708
|
+
let context = parentContext;
|
|
2709
|
+
try {
|
|
2710
|
+
let routeContext;
|
|
2711
|
+
if (route.options.context) {
|
|
2712
|
+
const routeContextOptions = {
|
|
2713
|
+
deps: match.loaderDeps,
|
|
2714
|
+
params: match.params,
|
|
2715
|
+
context: parentContext,
|
|
2716
|
+
location: lane.location,
|
|
2717
|
+
navigate: navigateFrom(router, lane.location),
|
|
2718
|
+
buildLocation: router.buildLocation,
|
|
2719
|
+
cause: match.cause,
|
|
2720
|
+
abortController: match.abortController,
|
|
2721
|
+
preload: false,
|
|
2722
|
+
matches: lane.matches,
|
|
2723
|
+
routeId: route.id
|
|
2724
|
+
};
|
|
2725
|
+
routeContext = route.options.context(routeContextOptions) ?? void 0;
|
|
2726
|
+
}
|
|
2727
|
+
context = {
|
|
2728
|
+
...parentContext,
|
|
2729
|
+
...routeContext
|
|
2730
|
+
};
|
|
2731
|
+
match.context = context;
|
|
2732
|
+
} catch (cause) {
|
|
2733
|
+
signal?.throwIfAborted();
|
|
2734
|
+
if (!failure) failure = [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
|
|
2735
|
+
end = index;
|
|
2736
|
+
break;
|
|
2737
|
+
}
|
|
2738
|
+
signal?.throwIfAborted();
|
|
2739
|
+
if (failure) break;
|
|
2740
|
+
const validationError = match.paramsError ?? match.searchError;
|
|
2741
|
+
if (validationError !== void 0) {
|
|
2742
|
+
failure = [index, stampNotFound(match, normalizeError(router, lane, route, validationError, signal))];
|
|
2743
|
+
end = index;
|
|
2744
|
+
break;
|
|
2745
|
+
}
|
|
2746
|
+
signal?.throwIfAborted();
|
|
2747
|
+
if (match.ssr === false || !route.options.beforeLoad) {
|
|
2748
|
+
parentContext = context;
|
|
2749
|
+
continue;
|
|
2750
|
+
}
|
|
2751
|
+
const abortController = match.abortController;
|
|
2752
|
+
const options = {
|
|
2753
|
+
search: match.search,
|
|
2754
|
+
abortController,
|
|
2755
|
+
params: match.params,
|
|
2756
|
+
preload: false,
|
|
2757
|
+
context,
|
|
2758
|
+
location: lane.location,
|
|
2759
|
+
navigate: navigateFrom(router, lane.location),
|
|
2760
|
+
buildLocation: router.buildLocation,
|
|
2761
|
+
cause: match.cause,
|
|
2762
|
+
matches: lane.matches,
|
|
2763
|
+
routeId: route.id,
|
|
2764
|
+
...router.options.additionalContext
|
|
2765
|
+
};
|
|
2766
|
+
try {
|
|
2767
|
+
const beforeLoadContext = await route.options.beforeLoad(options);
|
|
2768
|
+
signal?.throwIfAborted();
|
|
2769
|
+
const outcome = stampNotFound(match, materializeRedirect(router, lane, route, normalize(beforeLoadContext, false), signal));
|
|
2770
|
+
if (outcome[0] !== SUCCESS) {
|
|
2771
|
+
failure = [index, outcome];
|
|
2772
|
+
end = index;
|
|
2773
|
+
break;
|
|
2774
|
+
}
|
|
2775
|
+
match.__beforeLoadContext = beforeLoadContext;
|
|
2776
|
+
match.context = {
|
|
2777
|
+
...context,
|
|
2778
|
+
...beforeLoadContext
|
|
2779
|
+
};
|
|
2780
|
+
parentContext = match.context;
|
|
2781
|
+
} catch (cause) {
|
|
2782
|
+
signal?.throwIfAborted();
|
|
2783
|
+
failure = [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
|
|
2784
|
+
end = index;
|
|
2785
|
+
break;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
return {
|
|
2789
|
+
location: lane.location,
|
|
2790
|
+
matches: lane.matches,
|
|
2791
|
+
end,
|
|
2792
|
+
failure
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2795
|
+
function getLoaderContext(router, lane, match, route, index, tasks) {
|
|
2796
|
+
return {
|
|
2797
|
+
params: match.params,
|
|
2798
|
+
deps: match.loaderDeps,
|
|
2799
|
+
preload: false,
|
|
2800
|
+
parentMatchPromise: tasks[index - 1]?.match,
|
|
2801
|
+
abortController: match.abortController,
|
|
2802
|
+
context: match.context,
|
|
2803
|
+
location: lane.location,
|
|
2804
|
+
navigate: navigateFrom(router, lane.location),
|
|
2805
|
+
cause: match.cause,
|
|
2806
|
+
route,
|
|
2807
|
+
...router.options.additionalContext
|
|
2808
|
+
};
|
|
2809
|
+
}
|
|
2810
|
+
function createLoaderTask(router, lane, index, tasks, signal) {
|
|
2811
|
+
const match = lane.matches[index];
|
|
2812
|
+
const route = getRoute(router, match);
|
|
2813
|
+
let outcome;
|
|
2814
|
+
if (match.ssr === false) outcome = Promise.resolve([SKIPPED]);
|
|
2815
|
+
else {
|
|
2816
|
+
const routeLoader = route.options.loader;
|
|
2817
|
+
const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
|
|
2818
|
+
if (!loader) outcome = Promise.resolve([SUCCESS, void 0]);
|
|
2819
|
+
else outcome = Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, index, tasks))).then((result) => normalize(result, false), (cause) => normalize(cause, true)).then((result) => {
|
|
2820
|
+
if (signal?.aborted || match.abortController.signal.reason === REDIRECT_ABORT_REASON) return [SKIPPED];
|
|
2821
|
+
if (result[0] === ERROR) result = normalizeError(router, lane, route, result[1], signal);
|
|
2822
|
+
else result = materializeRedirect(router, lane, route, result, signal);
|
|
2823
|
+
return stampNotFound(match, result);
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2826
|
+
const parentMatch = outcome.then((result) => {
|
|
2827
|
+
const snapshot = { ...match };
|
|
2828
|
+
if (result[0] === SUCCESS) {
|
|
2829
|
+
snapshot.loaderData = result[1];
|
|
2830
|
+
snapshot.status = "success";
|
|
2831
|
+
snapshot.error = void 0;
|
|
2832
|
+
snapshot.invalid = false;
|
|
2833
|
+
snapshot.isFetching = false;
|
|
2834
|
+
} else if (result[0] === ERROR) {
|
|
2835
|
+
snapshot.status = "error";
|
|
2836
|
+
snapshot.error = result[1];
|
|
2837
|
+
} else if (result[0] === NOT_FOUND) {
|
|
2838
|
+
snapshot.status = "notFound";
|
|
2839
|
+
snapshot.error = result[1];
|
|
2840
|
+
}
|
|
2841
|
+
return snapshot;
|
|
2842
|
+
});
|
|
2843
|
+
return {
|
|
2844
|
+
index,
|
|
2845
|
+
outcome,
|
|
2846
|
+
match: parentMatch
|
|
2847
|
+
};
|
|
2848
|
+
}
|
|
2849
|
+
async function getNotFoundBoundary(router, matches, indexed, signal, fallback = 0) {
|
|
2850
|
+
const cause = indexed?.[1][1];
|
|
2851
|
+
let index = cause?.routeId ? matches.findIndex((match) => match.routeId === cause.routeId) : indexed?.[0] ?? matches.length - 1;
|
|
2852
|
+
if (index < 0) index = 0;
|
|
2853
|
+
for (let candidate = index; candidate >= 0; candidate--) {
|
|
2854
|
+
const route = getRoute(router, matches[candidate]);
|
|
2855
|
+
try {
|
|
2856
|
+
const loading = loadRouteChunk(route, false);
|
|
2857
|
+
if (loading) await loading;
|
|
2858
|
+
} catch {
|
|
2859
|
+
signal?.throwIfAborted();
|
|
2860
|
+
}
|
|
2861
|
+
signal?.throwIfAborted();
|
|
2862
|
+
if (route.options.notFoundComponent) return candidate;
|
|
2863
|
+
}
|
|
2864
|
+
return cause?.routeId ? index : fallback;
|
|
2865
|
+
}
|
|
2866
|
+
function abortMatches(matches, start = 0, reason = MATCH_SETTLED_ABORT_REASON) {
|
|
2867
|
+
for (let index = start; index < matches.length; index++) matches[index].abortController.abort(reason);
|
|
2868
|
+
}
|
|
2869
|
+
async function applyFailure(router, lane, indexed, signal) {
|
|
2870
|
+
if (!indexed) {
|
|
2871
|
+
const boundary = lane.matches.findIndex((match) => match._notFound);
|
|
2872
|
+
if (boundary >= 0) {
|
|
2873
|
+
abortMatches(lane.matches, boundary + 1);
|
|
2874
|
+
return {
|
|
2875
|
+
status: 404,
|
|
2876
|
+
boundary,
|
|
2877
|
+
kind: NOT_FOUND
|
|
2878
|
+
};
|
|
2879
|
+
}
|
|
2880
|
+
return { status: 200 };
|
|
2881
|
+
}
|
|
2882
|
+
const [index, outcome] = indexed;
|
|
2883
|
+
if (outcome[0] === ERROR) {
|
|
2884
|
+
const match = lane.matches[index];
|
|
2885
|
+
match._notFound = void 0;
|
|
2886
|
+
match.status = "error";
|
|
2887
|
+
match.error = outcome[1];
|
|
2888
|
+
match.isFetching = false;
|
|
2889
|
+
abortMatches(lane.matches, index + 1);
|
|
2890
|
+
return {
|
|
2891
|
+
status: 500,
|
|
2892
|
+
boundary: index,
|
|
2893
|
+
kind: ERROR
|
|
2894
|
+
};
|
|
2895
|
+
}
|
|
2896
|
+
const boundary = indexed[2] ?? await getNotFoundBoundary(router, lane.matches, indexed, signal);
|
|
2897
|
+
const match = lane.matches[boundary];
|
|
2898
|
+
const cause = outcome[1];
|
|
2899
|
+
cause.routeId = match.routeId;
|
|
2900
|
+
match._notFound = void 0;
|
|
2901
|
+
if (match.routeId === router.routeTree.id) {
|
|
2902
|
+
match.status = "success";
|
|
2903
|
+
match._notFound = true;
|
|
2904
|
+
match.error = cause;
|
|
2905
|
+
} else {
|
|
2906
|
+
match.status = "notFound";
|
|
2907
|
+
match.error = cause;
|
|
2908
|
+
}
|
|
2909
|
+
match.isFetching = false;
|
|
2910
|
+
abortMatches(lane.matches, boundary + 1);
|
|
2911
|
+
return {
|
|
2912
|
+
status: 404,
|
|
2913
|
+
boundary,
|
|
2914
|
+
kind: NOT_FOUND
|
|
2915
|
+
};
|
|
2916
|
+
}
|
|
2917
|
+
async function loadNormalChunks(router, lane, end, signal) {
|
|
2918
|
+
const chunks = [];
|
|
2919
|
+
for (let index = 0; index < lane.matches.length; index++) {
|
|
2920
|
+
const match = lane.matches[index];
|
|
2921
|
+
if (index >= end || match.ssr !== true || match.status !== "success") continue;
|
|
2922
|
+
const route = getRoute(router, match);
|
|
2923
|
+
try {
|
|
2924
|
+
const loading = loadRouteChunk(route);
|
|
2925
|
+
if (loading) {
|
|
2926
|
+
const chunk = loading.then(() => {
|
|
2927
|
+
signal?.throwIfAborted();
|
|
2928
|
+
}, (cause) => {
|
|
2929
|
+
signal?.throwIfAborted();
|
|
2930
|
+
return [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
|
|
2931
|
+
});
|
|
2932
|
+
chunk.catch(() => {});
|
|
2933
|
+
chunks.push(chunk);
|
|
2934
|
+
}
|
|
2935
|
+
} catch (cause) {
|
|
2936
|
+
signal?.throwIfAborted();
|
|
2937
|
+
chunks.push([index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))]);
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
for (const chunk of chunks) {
|
|
2941
|
+
const indexed = Array.isArray(chunk) ? chunk : await chunk;
|
|
2942
|
+
if (indexed) return indexed;
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
async function projectLane(router, lane, signal) {
|
|
2946
|
+
for (const match of lane.matches) {
|
|
2947
|
+
const routeOptions = getRoute(router, match).options;
|
|
2948
|
+
if (routeOptions.head || routeOptions.scripts || routeOptions.headers) {
|
|
2949
|
+
const context = {
|
|
2950
|
+
ssr: router.options.ssr,
|
|
2951
|
+
matches: lane.matches,
|
|
2952
|
+
match,
|
|
2953
|
+
params: match.params,
|
|
2954
|
+
loaderData: match.loaderData
|
|
2955
|
+
};
|
|
2956
|
+
try {
|
|
2957
|
+
const [head, scripts, headers] = await Promise.all([
|
|
2958
|
+
routeOptions.head?.(context),
|
|
2959
|
+
routeOptions.scripts?.(context),
|
|
2960
|
+
routeOptions.headers?.(context)
|
|
2961
|
+
]);
|
|
2962
|
+
signal?.throwIfAborted();
|
|
2963
|
+
match.meta = head?.meta;
|
|
2964
|
+
match.links = head?.links;
|
|
2965
|
+
match.headScripts = head?.scripts;
|
|
2966
|
+
match.styles = head?.styles;
|
|
2967
|
+
match.scripts = scripts;
|
|
2968
|
+
match.headers = headers;
|
|
2969
|
+
} catch (cause) {
|
|
2970
|
+
signal?.throwIfAborted();
|
|
2971
|
+
console.error(cause);
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
if (match.ssr === false || match.status !== "success" || match._notFound) break;
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
async function executeServerLane(router, location, matchedMatches, signal) {
|
|
2978
|
+
const matched = {
|
|
2979
|
+
location,
|
|
2980
|
+
matches: matchedMatches.map((match) => ({
|
|
2981
|
+
...match,
|
|
2982
|
+
__beforeLoadContext: void 0,
|
|
2983
|
+
context: {},
|
|
2984
|
+
isFetching: false,
|
|
2985
|
+
abortController: new AbortController()
|
|
2986
|
+
}))
|
|
2987
|
+
};
|
|
2988
|
+
const abortLane = () => abortMatches(matched.matches, 0, signal?.reason ?? MATCH_SETTLED_ABORT_REASON);
|
|
2989
|
+
if (signal?.aborted) {
|
|
2990
|
+
abortLane();
|
|
2991
|
+
signal.throwIfAborted();
|
|
2992
|
+
}
|
|
2993
|
+
signal?.addEventListener("abort", abortLane, { once: true });
|
|
2994
|
+
try {
|
|
2995
|
+
const plannedGlobalBoundary = matched.matches.findIndex((match) => match._notFound);
|
|
2996
|
+
if (router.options.notFoundMode !== "root" && plannedGlobalBoundary >= 0) {
|
|
2997
|
+
const boundary = await getNotFoundBoundary(router, matched.matches, void 0, signal, plannedGlobalBoundary);
|
|
2998
|
+
if (boundary !== plannedGlobalBoundary) {
|
|
2999
|
+
matched.matches[plannedGlobalBoundary]._notFound = void 0;
|
|
3000
|
+
matched.matches[boundary]._notFound = true;
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
const lane = await contextualize(router, matched, signal);
|
|
3004
|
+
signal?.throwIfAborted();
|
|
3005
|
+
let loaderEnd = lane.end;
|
|
3006
|
+
if (lane.failure?.[1][0] === REDIRECTED) loaderEnd = 0;
|
|
3007
|
+
else if (lane.failure?.[1][0] === NOT_FOUND) {
|
|
3008
|
+
lane.failure[2] = await getNotFoundBoundary(router, lane.matches, lane.failure, signal);
|
|
3009
|
+
loaderEnd = Math.min(loaderEnd, lane.failure[2] + 1);
|
|
3010
|
+
}
|
|
3011
|
+
const tasks = [];
|
|
3012
|
+
for (let index = 0; index < loaderEnd; index++) {
|
|
3013
|
+
const task = createLoaderTask(router, lane, index, tasks, signal);
|
|
3014
|
+
tasks.push(task);
|
|
3015
|
+
}
|
|
3016
|
+
let loaderFailure;
|
|
3017
|
+
let control = lane.failure?.[1][0] === REDIRECTED ? lane.failure : void 0;
|
|
3018
|
+
try {
|
|
3019
|
+
await Promise.all(tasks.map((task) => task.outcome.then((loadedOutcome) => {
|
|
3020
|
+
const match = lane.matches[task.index];
|
|
3021
|
+
const outcome = loadedOutcome;
|
|
3022
|
+
if (outcome[0] === SUCCESS) {
|
|
3023
|
+
match.loaderData = outcome[1];
|
|
3024
|
+
match.status = "success";
|
|
3025
|
+
match.error = void 0;
|
|
3026
|
+
match.invalid = false;
|
|
3027
|
+
match.isFetching = false;
|
|
3028
|
+
match.updatedAt = Date.now();
|
|
3029
|
+
} else if (outcome[0] === REDIRECTED) {
|
|
3030
|
+
control = [task.index, outcome];
|
|
3031
|
+
throw control;
|
|
3032
|
+
} else {
|
|
3033
|
+
if (match.ssr !== false) {
|
|
3034
|
+
match.status = "success";
|
|
3035
|
+
match.error = void 0;
|
|
3036
|
+
match.invalid = true;
|
|
3037
|
+
match.isFetching = false;
|
|
3038
|
+
}
|
|
3039
|
+
if (!loaderFailure && outcome[0] !== SKIPPED) loaderFailure = [task.index, outcome];
|
|
3040
|
+
}
|
|
3041
|
+
})));
|
|
3042
|
+
} catch (cause) {
|
|
3043
|
+
if (!Array.isArray(cause)) throw cause;
|
|
3044
|
+
control = cause;
|
|
3045
|
+
}
|
|
3046
|
+
signal?.throwIfAborted();
|
|
3047
|
+
if (control?.[1][0] === REDIRECTED) {
|
|
3048
|
+
abortMatches(lane.matches, 0, REDIRECT_ABORT_REASON);
|
|
3049
|
+
return {
|
|
3050
|
+
type: "redirect",
|
|
3051
|
+
redirect: control[1][1]
|
|
3052
|
+
};
|
|
3053
|
+
}
|
|
3054
|
+
let failure = lane.failure ?? loaderFailure;
|
|
3055
|
+
const plannedBoundary = lane.matches.findIndex((match) => match._notFound);
|
|
3056
|
+
let readinessEnd;
|
|
3057
|
+
if (failure) {
|
|
3058
|
+
const outcomeEnd = failure[2] ??= failure[1][0] === NOT_FOUND ? await getNotFoundBoundary(router, lane.matches, failure, signal) : failure[0];
|
|
3059
|
+
for (const task of tasks) {
|
|
3060
|
+
if (task.index >= outcomeEnd) break;
|
|
3061
|
+
const outcome = await task.outcome;
|
|
3062
|
+
if (outcome[0] !== SUCCESS && outcome[0] < REDIRECTED && !("loaderData" in lane.matches[task.index])) {
|
|
3063
|
+
failure = [task.index, outcome];
|
|
3064
|
+
failure[2] = outcome[0] === NOT_FOUND ? await getNotFoundBoundary(router, lane.matches, failure, signal) : task.index;
|
|
3065
|
+
break;
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
readinessEnd = failure[2];
|
|
3069
|
+
} else readinessEnd = plannedBoundary < 0 ? lane.matches.length : plannedBoundary;
|
|
3070
|
+
const requiredFailure = await loadNormalChunks(router, lane, readinessEnd, signal);
|
|
3071
|
+
signal?.throwIfAborted();
|
|
3072
|
+
if (requiredFailure) {
|
|
3073
|
+
if (requiredFailure[1][0] === REDIRECTED) {
|
|
3074
|
+
abortMatches(lane.matches, 0, REDIRECT_ABORT_REASON);
|
|
3075
|
+
return {
|
|
3076
|
+
type: "redirect",
|
|
3077
|
+
redirect: requiredFailure[1][1]
|
|
3078
|
+
};
|
|
3079
|
+
}
|
|
3080
|
+
failure = requiredFailure;
|
|
3081
|
+
}
|
|
3082
|
+
const terminal = await applyFailure(router, lane, failure, signal);
|
|
3083
|
+
if (terminal.boundary !== void 0) {
|
|
3084
|
+
const match = lane.matches[terminal.boundary];
|
|
3085
|
+
if (match.ssr === true) {
|
|
3086
|
+
const route = getRoute(router, match);
|
|
3087
|
+
try {
|
|
3088
|
+
if (terminal.kind === ERROR) await loadRouteChunk(route, "errorComponent");
|
|
3089
|
+
else if (match._notFound) await Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]);
|
|
3090
|
+
else await loadRouteChunk(route, "notFoundComponent");
|
|
3091
|
+
} catch {}
|
|
3092
|
+
signal?.throwIfAborted();
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
signal?.throwIfAborted();
|
|
3096
|
+
await projectLane(router, {
|
|
3097
|
+
location: lane.location,
|
|
3098
|
+
matches: lane.matches
|
|
3099
|
+
}, signal);
|
|
3100
|
+
signal?.throwIfAborted();
|
|
3101
|
+
router.serverSsr?.onCleanup((settled) => {
|
|
3102
|
+
if (!settled) abortLane();
|
|
3103
|
+
});
|
|
3104
|
+
return {
|
|
3105
|
+
type: "render",
|
|
3106
|
+
status: terminal.status,
|
|
3107
|
+
matches: lane.matches
|
|
3108
|
+
};
|
|
3109
|
+
} finally {
|
|
3110
|
+
signal?.removeEventListener("abort", abortLane);
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
async function loadServerRoute(router, opts) {
|
|
3114
|
+
if (!opts?._skipLocationUpdate) router.updateLatestLocation();
|
|
3115
|
+
const next = router.latestLocation;
|
|
3116
|
+
const previous = router._committed;
|
|
3117
|
+
const previousEnd = router._lifecycleEnd;
|
|
3118
|
+
let result;
|
|
3119
|
+
try {
|
|
3120
|
+
const canonical = router.buildLocation({
|
|
3121
|
+
to: next.pathname,
|
|
3122
|
+
search: true,
|
|
3123
|
+
params: true,
|
|
3124
|
+
hash: true,
|
|
3125
|
+
state: true,
|
|
3126
|
+
_includeValidateSearch: true
|
|
3127
|
+
});
|
|
3128
|
+
if (next.publicHref !== canonical.publicHref) {
|
|
3129
|
+
const href = canonical.publicHref || "/";
|
|
3130
|
+
throw redirect({ href });
|
|
3131
|
+
}
|
|
3132
|
+
const changeInfo = getLocationChangeInfo(next, router.stores.resolvedLocation.get());
|
|
3133
|
+
router.emit({
|
|
3134
|
+
type: "onBeforeNavigate",
|
|
3135
|
+
...changeInfo
|
|
3136
|
+
});
|
|
3137
|
+
router.emit({
|
|
3138
|
+
type: "onBeforeLoad",
|
|
3139
|
+
...changeInfo
|
|
3140
|
+
});
|
|
3141
|
+
opts?._signal?.throwIfAborted();
|
|
3142
|
+
result = await waitFor(executeServerLane(router, next, router.matchRoutes(next), opts?._signal), opts?._signal);
|
|
3143
|
+
opts?._signal?.throwIfAborted();
|
|
3144
|
+
} catch (cause) {
|
|
3145
|
+
opts?._signal?.throwIfAborted();
|
|
3146
|
+
if (!isRedirect(cause)) throw cause;
|
|
3147
|
+
cause.options._fromLocation = next;
|
|
3148
|
+
result = {
|
|
3149
|
+
type: "redirect",
|
|
3150
|
+
redirect: router.resolveRedirect(cause)
|
|
3151
|
+
};
|
|
3152
|
+
}
|
|
3153
|
+
router._serverResult = result;
|
|
3154
|
+
let nextEnd = 0;
|
|
3155
|
+
router.batch(() => {
|
|
3156
|
+
router.stores.location.set(next);
|
|
3157
|
+
router.stores.status.set("idle");
|
|
3158
|
+
if (result.type === "render") {
|
|
3159
|
+
router._committed = result.matches;
|
|
3160
|
+
nextEnd = router._lifecycleEnd = lifecycleEnd(result.matches);
|
|
3161
|
+
router.stores.setMatches(result.matches);
|
|
3162
|
+
router.stores.resolvedLocation.set(next);
|
|
3163
|
+
}
|
|
3164
|
+
});
|
|
3165
|
+
if (result.type === "render") runRouteLifecycle(router, previous, result.matches, previousEnd, nextEnd);
|
|
3166
|
+
router._commitPromise?.resolve();
|
|
3167
|
+
router._commitPromise = void 0;
|
|
3168
|
+
}
|
|
3169
|
+
// ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/routerContext.js
|
|
3170
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
3171
|
+
var routerContext = import_react.createContext(null);
|
|
3172
|
+
// ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useRouter.js
|
|
3173
|
+
/**
|
|
3174
|
+
* Access the current TanStack Router instance from React context.
|
|
3175
|
+
* Must be used within a `RouterProvider`.
|
|
3176
|
+
*
|
|
3177
|
+
* Options:
|
|
3178
|
+
* - `warn`: Log a warning if no router context is found (default: true).
|
|
3179
|
+
*
|
|
3180
|
+
* @returns The registered router instance.
|
|
3181
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
|
|
3182
|
+
*/
|
|
3183
|
+
function useRouter(opts) {
|
|
3184
|
+
const value = import_react.useContext(routerContext);
|
|
3185
|
+
if (!value);
|
|
3186
|
+
return value;
|
|
3187
|
+
}
|
|
3188
|
+
// ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/matchContext.js
|
|
3189
|
+
function createLinkScope(router, routeId) {
|
|
3190
|
+
const store = router.stores.location;
|
|
3191
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
3192
|
+
let source;
|
|
3193
|
+
let unsubscribe;
|
|
3194
|
+
const update = (location) => {
|
|
3195
|
+
if (!_isRouteDeparting(router, routeId, location)) {
|
|
3196
|
+
source = location;
|
|
3197
|
+
listeners.forEach((listener) => listener());
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
return [() => source ?? store.get(), (listener) => {
|
|
3201
|
+
if (!listeners.size) {
|
|
3202
|
+
source = store.get();
|
|
3203
|
+
unsubscribe = store.subscribe(update).unsubscribe;
|
|
3204
|
+
}
|
|
3205
|
+
listeners.add(listener);
|
|
3206
|
+
return () => {
|
|
3207
|
+
listeners.delete(listener);
|
|
3208
|
+
if (!listeners.size) {
|
|
3209
|
+
unsubscribe();
|
|
3210
|
+
source = void 0;
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
}];
|
|
3214
|
+
}
|
|
3215
|
+
var matchContext = import_react.createContext(void 0);
|
|
3216
|
+
var dummyMatchContext = import_react.createContext(void 0);
|
|
3217
|
+
// ../../node_modules/.bun/use-sync-external-store@1.6.0+e14d3f224186685e/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
|
|
3218
|
+
/**
|
|
3219
|
+
* @license React
|
|
3220
|
+
* use-sync-external-store-shim.production.js
|
|
3221
|
+
*
|
|
3222
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3223
|
+
*
|
|
3224
|
+
* This source code is licensed under the MIT license found in the
|
|
3225
|
+
* LICENSE file in the root directory of this source tree.
|
|
3226
|
+
*/
|
|
3227
|
+
var require_use_sync_external_store_shim_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3228
|
+
var React = require_react();
|
|
3229
|
+
function is(x, y) {
|
|
3230
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
3231
|
+
}
|
|
3232
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
|
3233
|
+
var useState = React.useState;
|
|
3234
|
+
var useEffect = React.useEffect;
|
|
3235
|
+
var useLayoutEffect = React.useLayoutEffect;
|
|
3236
|
+
var useDebugValue = React.useDebugValue;
|
|
3237
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
3238
|
+
var value = getSnapshot(), _useState = useState({ inst: {
|
|
3239
|
+
value,
|
|
3240
|
+
getSnapshot
|
|
3241
|
+
} }), inst = _useState[0].inst, forceUpdate = _useState[1];
|
|
3242
|
+
useLayoutEffect(function() {
|
|
3243
|
+
inst.value = value;
|
|
3244
|
+
inst.getSnapshot = getSnapshot;
|
|
3245
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
3246
|
+
}, [
|
|
3247
|
+
subscribe,
|
|
3248
|
+
value,
|
|
3249
|
+
getSnapshot
|
|
3250
|
+
]);
|
|
3251
|
+
useEffect(function() {
|
|
3252
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
3253
|
+
return subscribe(function() {
|
|
3254
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
3255
|
+
});
|
|
3256
|
+
}, [subscribe]);
|
|
3257
|
+
useDebugValue(value);
|
|
3258
|
+
return value;
|
|
3259
|
+
}
|
|
3260
|
+
function checkIfSnapshotChanged(inst) {
|
|
3261
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
3262
|
+
inst = inst.value;
|
|
3263
|
+
try {
|
|
3264
|
+
var nextValue = latestGetSnapshot();
|
|
3265
|
+
return !objectIs(inst, nextValue);
|
|
3266
|
+
} catch (error) {
|
|
3267
|
+
return !0;
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
3271
|
+
return getSnapshot();
|
|
3272
|
+
}
|
|
3273
|
+
var shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
3274
|
+
exports.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
|
|
3275
|
+
}));
|
|
3276
|
+
// ../../node_modules/.bun/use-sync-external-store@1.6.0+e14d3f224186685e/node_modules/use-sync-external-store/shim/index.js
|
|
3277
|
+
var require_shim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3278
|
+
module.exports = require_use_sync_external_store_shim_production();
|
|
3279
|
+
}));
|
|
3280
|
+
// ../../node_modules/.bun/use-sync-external-store@1.6.0+e14d3f224186685e/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js
|
|
3281
|
+
/**
|
|
3282
|
+
* @license React
|
|
3283
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
3284
|
+
*
|
|
3285
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3286
|
+
*
|
|
3287
|
+
* This source code is licensed under the MIT license found in the
|
|
3288
|
+
* LICENSE file in the root directory of this source tree.
|
|
3289
|
+
*/
|
|
3290
|
+
var require_with_selector_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3291
|
+
var React = require_react();
|
|
3292
|
+
var shim = require_shim();
|
|
3293
|
+
function is(x, y) {
|
|
3294
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
3295
|
+
}
|
|
3296
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
|
3297
|
+
var useSyncExternalStore = shim.useSyncExternalStore;
|
|
3298
|
+
var useRef = React.useRef;
|
|
3299
|
+
var useEffect = React.useEffect;
|
|
3300
|
+
var useMemo = React.useMemo;
|
|
3301
|
+
var useDebugValue = React.useDebugValue;
|
|
3302
|
+
exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
3303
|
+
var instRef = useRef(null);
|
|
3304
|
+
if (null === instRef.current) {
|
|
3305
|
+
var inst = {
|
|
3306
|
+
hasValue: !1,
|
|
3307
|
+
value: null
|
|
3308
|
+
};
|
|
3309
|
+
instRef.current = inst;
|
|
3310
|
+
} else inst = instRef.current;
|
|
3311
|
+
instRef = useMemo(function() {
|
|
3312
|
+
function memoizedSelector(nextSnapshot) {
|
|
3313
|
+
if (!hasMemo) {
|
|
3314
|
+
hasMemo = !0;
|
|
3315
|
+
memoizedSnapshot = nextSnapshot;
|
|
3316
|
+
nextSnapshot = selector(nextSnapshot);
|
|
3317
|
+
if (void 0 !== isEqual && inst.hasValue) {
|
|
3318
|
+
var currentSelection = inst.value;
|
|
3319
|
+
if (isEqual(currentSelection, nextSnapshot)) return memoizedSelection = currentSelection;
|
|
3320
|
+
}
|
|
3321
|
+
return memoizedSelection = nextSnapshot;
|
|
3322
|
+
}
|
|
3323
|
+
currentSelection = memoizedSelection;
|
|
3324
|
+
if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
|
|
3325
|
+
var nextSelection = selector(nextSnapshot);
|
|
3326
|
+
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
3327
|
+
memoizedSnapshot = nextSnapshot;
|
|
3328
|
+
return memoizedSelection = nextSelection;
|
|
3329
|
+
}
|
|
3330
|
+
var hasMemo = !1, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
3331
|
+
return [function() {
|
|
3332
|
+
return memoizedSelector(getSnapshot());
|
|
3333
|
+
}, null === maybeGetServerSnapshot ? void 0 : function() {
|
|
3334
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
3335
|
+
}];
|
|
3336
|
+
}, [
|
|
3337
|
+
getSnapshot,
|
|
3338
|
+
getServerSnapshot,
|
|
3339
|
+
selector,
|
|
3340
|
+
isEqual
|
|
3341
|
+
]);
|
|
3342
|
+
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
3343
|
+
useEffect(function() {
|
|
3344
|
+
inst.hasValue = !0;
|
|
3345
|
+
inst.value = value;
|
|
3346
|
+
}, [value]);
|
|
3347
|
+
useDebugValue(value);
|
|
3348
|
+
return value;
|
|
3349
|
+
};
|
|
3350
|
+
}));
|
|
3351
|
+
// ../../node_modules/.bun/@tanstack+react-store@0.11.2+7492c01c6988791b/node_modules/@tanstack/react-store/dist/useSelector.js
|
|
3352
|
+
var import_with_selector = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3353
|
+
module.exports = require_with_selector_production();
|
|
3354
|
+
})))();
|
|
3355
|
+
function defaultCompare(a, b) {
|
|
3356
|
+
return a === b;
|
|
3357
|
+
}
|
|
3358
|
+
/**
|
|
3359
|
+
* Selects a slice of state from an atom or store and subscribes the component
|
|
3360
|
+
* to that selection.
|
|
3361
|
+
*
|
|
3362
|
+
* This is the primary React read hook for TanStack Store. It works with any
|
|
3363
|
+
* source that exposes `get()` and `subscribe()`, including atoms, readonly
|
|
3364
|
+
* atoms, stores, and readonly stores.
|
|
3365
|
+
*
|
|
3366
|
+
* Omit the selector to subscribe to the whole value.
|
|
3367
|
+
*
|
|
3368
|
+
* @example
|
|
3369
|
+
* ```tsx
|
|
3370
|
+
* const count = useSelector(counterStore, (state) => state.count)
|
|
3371
|
+
* ```
|
|
3372
|
+
*
|
|
3373
|
+
* @example
|
|
3374
|
+
* ```tsx
|
|
3375
|
+
* const value = useSelector(countAtom)
|
|
3376
|
+
* ```
|
|
3377
|
+
*/
|
|
3378
|
+
function useSelector(source, selector = (s) => s, options) {
|
|
3379
|
+
const compare = options?.compare ?? defaultCompare;
|
|
3380
|
+
const subscribe = (0, import_react.useCallback)((handleStoreChange) => {
|
|
3381
|
+
const { unsubscribe } = source.subscribe(handleStoreChange);
|
|
3382
|
+
return unsubscribe;
|
|
3383
|
+
}, [source]);
|
|
3384
|
+
const getSnapshot = (0, import_react.useCallback)(() => source.get(), [source]);
|
|
3385
|
+
return (0, import_with_selector.useSyncExternalStoreWithSelector)(subscribe, getSnapshot, getSnapshot, selector, compare);
|
|
3386
|
+
}
|
|
3387
|
+
export { rootRouteId as C, trimPathRight as S, invariant as _, useRouter as a, removeTrailingSlash as b, _getAssetMatches as c, getLocationChangeInfo as d, createServerHistory as f, storageKey as g, defaultGetScrollRestorationKey as h, matchContext as i, _getRenderedMatches as l, createNonReactiveReadonlyStore as m, createLinkScope as n, routerContext as o, createNonReactiveMutableStore as p, dummyMatchContext as r, waitForReason as s, useSelector as t, RouterCore as u, createSieveCache as v, isNotFound as w, trimPathLeft as x, cleanPath as y };
|