@coffre/ui 0.0.0 → 0.1.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/LICENSE +21 -0
- package/README.md +7 -3
- package/dist/client/.assetsignore +2 -0
- package/dist/client/_coffre/assets/account-C3Zo1l5A.js +1 -0
- package/dist/client/_coffre/assets/account-C4bNbeO7.js +2 -0
- package/dist/client/_coffre/assets/affordances-DiuJIiR2.js +1 -0
- package/dist/client/_coffre/assets/audit-1xLyuxGz.js +2 -0
- package/dist/client/_coffre/assets/audit-Dab2GuRj.js +1 -0
- package/dist/client/_coffre/assets/auth.device-BfCfeBWe.js +2 -0
- package/dist/client/_coffre/assets/auth.device-D2pCLF-X.js +1 -0
- package/dist/client/_coffre/assets/coffre-C7qL3HGR.js +1 -0
- package/dist/client/_coffre/assets/directory-C2Ou4SQv.js +1 -0
- package/dist/client/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/client/_coffre/assets/grants-fqTtJ-aW.js +1 -0
- package/dist/client/_coffre/assets/index-BpGwbjmM.js +12 -0
- package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/client/_coffre/assets/login-CR9CBXlw.js +2 -0
- package/dist/client/_coffre/assets/login-DZizFxa4.js +1 -0
- package/dist/client/_coffre/assets/offboarding-DOLJQcXU.js +1 -0
- package/dist/client/_coffre/assets/page-BxW2MwaX.js +1 -0
- package/dist/client/_coffre/assets/preload-helper-BHuP8_FL.js +46 -0
- package/dist/client/_coffre/assets/principal-page-xnBZVURr.js +1 -0
- package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +1 -0
- package/dist/client/_coffre/assets/projects._project._environment-CrWjQmIA.js +2 -0
- package/dist/client/_coffre/assets/projects._project._environment-CwRVG9Ne.js +3 -0
- package/dist/client/_coffre/assets/projects._project.index-CCDEuE-z.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-DCJsmnD7.js +1 -0
- package/dist/client/_coffre/assets/projects.index-B8eV8JIn.js +1 -0
- package/dist/client/_coffre/assets/projects.index-BNEC7Oz8.js +2 -0
- package/dist/client/_coffre/assets/settings-2BPsenNM.js +2 -0
- package/dist/client/_coffre/assets/settings-BrS0-wEt.js +1 -0
- package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +1 -0
- package/dist/client/_coffre/assets/tokens._token-B3-YwuKp.js +2 -0
- package/dist/client/_coffre/assets/tokens._token-D_hsbHx6.js +1 -0
- package/dist/client/_coffre/assets/tokens.index-BdKE2Jv8.js +2 -0
- package/dist/client/_coffre/assets/tokens.index-XvA4XRxh.js +1 -0
- package/dist/client/_coffre/assets/unregistered-CTRMtBIy.js +1 -0
- package/dist/client/_coffre/assets/use-action-DgAf-tiX.js +1 -0
- package/dist/client/_coffre/assets/users._user-BFPXcJ4y.js +2 -0
- package/dist/client/_coffre/assets/users._user-DEtMeSoh.js +1 -0
- package/dist/client/_coffre/assets/users.index-B03beUHq.js +1 -0
- package/dist/client/_coffre/assets/users.index-D8hwzM6P.js +2 -0
- package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/server/.vite/manifest.json +572 -0
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-B6CZDfrB.js +133 -0
- package/dist/server/_coffre/assets/account-B71_b5xc.js +296 -0
- package/dist/server/_coffre/assets/account-BoO6ZqMc.js +176 -0
- package/dist/server/_coffre/assets/affordances-BNaXjMOb.js +46 -0
- package/dist/server/_coffre/assets/async-local-storage-C0cwgkEr.js +3107 -0
- package/dist/server/_coffre/assets/audit-CwRFnSAY.js +74 -0
- package/dist/server/_coffre/assets/audit-t1sYjtrf.js +964 -0
- package/dist/server/_coffre/assets/auth.device-1IcJ475s.js +208 -0
- package/dist/server/_coffre/assets/auth.device-CJwZYYtn.js +29 -0
- package/dist/server/_coffre/assets/coffre-1hxT2E_U.js +278 -0
- package/dist/server/_coffre/assets/directory-wm_JQUfk.js +396 -0
- package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +5 -0
- package/dist/server/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/server/_coffre/assets/grants-BmhEY1vz.js +243 -0
- package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/server/_coffre/assets/login-B5O5LPXV.js +100 -0
- package/dist/server/_coffre/assets/login-Bvc4gp0X.js +22 -0
- package/dist/server/_coffre/assets/offboarding-CvSilnSm.js +330 -0
- package/dist/server/_coffre/assets/page-BjXk0Ehu.js +2003 -0
- package/dist/server/_coffre/assets/principal-page-DkwNGzM2.js +617 -0
- package/dist/server/_coffre/assets/project-environments-lEzFHUt4.js +9 -0
- package/dist/server/_coffre/assets/projects._project._environment-7grhqlgq.js +2227 -0
- package/dist/server/_coffre/assets/projects._project._environment-ByEf6pmz.js +55 -0
- package/dist/server/_coffre/assets/projects._project.index-B1bjowP-.js +932 -0
- package/dist/server/_coffre/assets/projects._project.index-DU8wtoHD.js +22 -0
- package/dist/server/_coffre/assets/projects.index-B0DoHbCz.js +280 -0
- package/dist/server/_coffre/assets/projects.index-kMDA6pMy.js +54 -0
- package/dist/server/_coffre/assets/react-dom-qCTiwGGR.js +1352 -0
- package/dist/server/_coffre/assets/router-ChU_CwCX.js +2028 -0
- package/dist/server/_coffre/assets/settings-CM9-h7in.js +18 -0
- package/dist/server/_coffre/assets/settings-Cg5qOGij.js +60 -0
- package/dist/server/_coffre/assets/signin-errors-BEFlVDbQ.js +28 -0
- package/dist/server/_coffre/assets/start-DR3rN0St.js +4 -0
- package/dist/server/_coffre/assets/tokens._token-CCpaPMAk.js +268 -0
- package/dist/server/_coffre/assets/tokens._token-Di4OZdAA.js +18 -0
- package/dist/server/_coffre/assets/tokens.index-Do3OHR31.js +34 -0
- package/dist/server/_coffre/assets/tokens.index-tDKq4AFh.js +10 -0
- package/dist/server/_coffre/assets/ui-BNzhIAQP.js +15710 -0
- package/dist/server/_coffre/assets/unregistered-BqaWYFJK.js +51 -0
- package/dist/server/_coffre/assets/use-action-BkJXC5JM.js +953 -0
- package/dist/server/_coffre/assets/useStore-DWGPqzXR.js +892 -0
- package/dist/server/_coffre/assets/users._user-BenYva93.js +15 -0
- package/dist/server/_coffre/assets/users._user-Cp039Va-.js +10 -0
- package/dist/server/_coffre/assets/users.index-BrzG1Ecq.js +10 -0
- package/dist/server/_coffre/assets/users.index-DQ_45DQl.js +34 -0
- package/dist/server/_coffre/assets/validation-BQtqPe2V.js +27 -0
- package/dist/server/index.js +13910 -0
- package/package.json +58 -5
- package/src/components/affordances.ts +80 -0
- package/src/components/agentation.tsx +34 -0
- package/src/components/command-palette.tsx +271 -0
- package/src/components/directory.tsx +448 -0
- package/src/components/grants.tsx +204 -0
- package/src/components/icons.tsx +283 -0
- package/src/components/offboarding.tsx +286 -0
- package/src/components/page.tsx +128 -0
- package/src/components/principal-page.tsx +549 -0
- package/src/components/principal-picker.tsx +168 -0
- package/src/components/principal.tsx +53 -0
- package/src/components/route-states.tsx +60 -0
- package/src/components/service-tokens.tsx +212 -0
- package/src/components/shell.tsx +641 -0
- package/src/components/syncs.tsx +581 -0
- package/src/components/theme.tsx +141 -0
- package/src/components/tile.tsx +22 -0
- package/src/components/ui.tsx +440 -0
- package/src/entry.ts +19 -0
- package/src/lib/access-plan.ts +201 -0
- package/src/lib/audit-sentences.ts +468 -0
- package/src/lib/capabilities.ts +45 -0
- package/src/lib/coffre.ts +57 -0
- package/src/lib/project-access.ts +95 -0
- package/src/lib/project-environments.ts +23 -0
- package/src/lib/reveal.ts +21 -0
- package/src/lib/secret-edit-batch.ts +181 -0
- package/src/lib/signin-errors.ts +33 -0
- package/src/lib/use-action.ts +50 -0
- package/src/lib/validation.ts +27 -0
- package/src/routeTree.gen.ts +367 -0
- package/src/router.tsx +84 -0
- package/src/routes/__root.tsx +192 -0
- package/src/routes/access.tsx +11 -0
- package/src/routes/account.tsx +359 -0
- package/src/routes/audit.tsx +545 -0
- package/src/routes/auth.device.tsx +200 -0
- package/src/routes/index.tsx +15 -0
- package/src/routes/login.tsx +129 -0
- package/src/routes/projects.$project.$environment.tsx +1659 -0
- package/src/routes/projects.$project.index.tsx +917 -0
- package/src/routes/projects.index.tsx +353 -0
- package/src/routes/settings.tsx +72 -0
- package/src/routes/tokens.$token.tsx +35 -0
- package/src/routes/tokens.index.tsx +37 -0
- package/src/routes/unregistered.tsx +59 -0
- package/src/routes/users.$user.tsx +13 -0
- package/src/routes/users.index.tsx +37 -0
- package/src/shared/models.ts +55 -0
- package/src/styles/globals.css +4118 -0
- package/src/types.ts +21 -0
|
@@ -0,0 +1,1352 @@
|
|
|
1
|
+
import { C as require_react, E as __toESM, b as last, o as require_jsx_runtime, s as invariant, w as __commonJSMin } from "./useStore-DWGPqzXR.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.18_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/@tanstack/react-router/dist/esm/utils.js
|
|
3
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
4
|
+
/**
|
|
5
|
+
* React.use if available (React 19+), undefined otherwise.
|
|
6
|
+
* Use dynamic lookup to avoid Webpack compilation errors with React 18.
|
|
7
|
+
*/
|
|
8
|
+
var reactUse = import_react.use;
|
|
9
|
+
var useLayoutEffect = typeof window !== "undefined" ? import_react.useLayoutEffect : import_react.useEffect;
|
|
10
|
+
/**
|
|
11
|
+
* Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3
|
|
12
|
+
*/
|
|
13
|
+
function usePrevious(value) {
|
|
14
|
+
const ref = import_react.useRef({
|
|
15
|
+
value,
|
|
16
|
+
prev: null
|
|
17
|
+
});
|
|
18
|
+
const current = ref.current.value;
|
|
19
|
+
if (value !== current) ref.current = {
|
|
20
|
+
value,
|
|
21
|
+
prev: current
|
|
22
|
+
};
|
|
23
|
+
return ref.current.prev;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* React hook to wrap `IntersectionObserver`.
|
|
27
|
+
*
|
|
28
|
+
* This hook will create an `IntersectionObserver` and observe the ref passed to it.
|
|
29
|
+
*
|
|
30
|
+
* When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.
|
|
31
|
+
*
|
|
32
|
+
* @param ref - The ref to observe
|
|
33
|
+
* @param intersectionObserverOptions - The options to pass to the IntersectionObserver
|
|
34
|
+
* @param options - The options to pass to the hook
|
|
35
|
+
* @param callback - The callback to call when the intersection changes
|
|
36
|
+
* @returns The IntersectionObserver instance
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* const MyComponent = () => {
|
|
40
|
+
* const ref = React.useRef<HTMLDivElement>(null)
|
|
41
|
+
* useIntersectionObserver(
|
|
42
|
+
* ref,
|
|
43
|
+
* (entry) => { doSomething(entry) },
|
|
44
|
+
* { rootMargin: '10px' },
|
|
45
|
+
* { disabled: false }
|
|
46
|
+
* )
|
|
47
|
+
* return <div ref={ref} />
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function useIntersectionObserver(ref, callback, intersectionObserverOptions = {}, options = {}) {
|
|
51
|
+
import_react.useEffect(() => {
|
|
52
|
+
if (!ref.current || options.disabled || typeof IntersectionObserver !== "function") return;
|
|
53
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
54
|
+
callback(entry);
|
|
55
|
+
}, intersectionObserverOptions);
|
|
56
|
+
observer.observe(ref.current);
|
|
57
|
+
return () => {
|
|
58
|
+
observer.disconnect();
|
|
59
|
+
};
|
|
60
|
+
}, [
|
|
61
|
+
callback,
|
|
62
|
+
intersectionObserverOptions,
|
|
63
|
+
options.disabled,
|
|
64
|
+
ref
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.
|
|
69
|
+
*
|
|
70
|
+
* @param ref - The forwarded ref
|
|
71
|
+
* @returns The inner ref returned by `useRef`
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* const MyComponent = React.forwardRef((props, ref) => {
|
|
75
|
+
* const innerRef = useForwardedRef(ref)
|
|
76
|
+
* return <div ref={innerRef} />
|
|
77
|
+
* })
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
function useForwardedRef(ref) {
|
|
81
|
+
const innerRef = import_react.useRef(null);
|
|
82
|
+
import_react.useImperativeHandle(ref, () => innerRef.current, []);
|
|
83
|
+
return innerRef;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.15/node_modules/@tanstack/router-core/dist/esm/lru-cache.js
|
|
87
|
+
function createLRUCache(max) {
|
|
88
|
+
const cache = /* @__PURE__ */ new Map();
|
|
89
|
+
let oldest;
|
|
90
|
+
let newest;
|
|
91
|
+
const touch = (entry) => {
|
|
92
|
+
if (!entry.next) return;
|
|
93
|
+
if (!entry.prev) {
|
|
94
|
+
entry.next.prev = void 0;
|
|
95
|
+
oldest = entry.next;
|
|
96
|
+
entry.next = void 0;
|
|
97
|
+
if (newest) {
|
|
98
|
+
entry.prev = newest;
|
|
99
|
+
newest.next = entry;
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
entry.prev.next = entry.next;
|
|
103
|
+
entry.next.prev = entry.prev;
|
|
104
|
+
entry.next = void 0;
|
|
105
|
+
if (newest) {
|
|
106
|
+
newest.next = entry;
|
|
107
|
+
entry.prev = newest;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
newest = entry;
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
get(key) {
|
|
114
|
+
const entry = cache.get(key);
|
|
115
|
+
if (!entry) return void 0;
|
|
116
|
+
touch(entry);
|
|
117
|
+
return entry.value;
|
|
118
|
+
},
|
|
119
|
+
set(key, value) {
|
|
120
|
+
if (cache.size >= max && oldest) {
|
|
121
|
+
const toDelete = oldest;
|
|
122
|
+
cache.delete(toDelete.key);
|
|
123
|
+
if (toDelete.next) {
|
|
124
|
+
oldest = toDelete.next;
|
|
125
|
+
toDelete.next.prev = void 0;
|
|
126
|
+
}
|
|
127
|
+
if (toDelete === newest) newest = void 0;
|
|
128
|
+
}
|
|
129
|
+
const existing = cache.get(key);
|
|
130
|
+
if (existing) {
|
|
131
|
+
existing.value = value;
|
|
132
|
+
touch(existing);
|
|
133
|
+
} else {
|
|
134
|
+
const entry = {
|
|
135
|
+
key,
|
|
136
|
+
value,
|
|
137
|
+
prev: newest
|
|
138
|
+
};
|
|
139
|
+
if (newest) newest.next = entry;
|
|
140
|
+
newest = entry;
|
|
141
|
+
if (!oldest) oldest = entry;
|
|
142
|
+
cache.set(key, entry);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
clear() {
|
|
146
|
+
cache.clear();
|
|
147
|
+
oldest = void 0;
|
|
148
|
+
newest = void 0;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.15/node_modules/@tanstack/router-core/dist/esm/new-process-route-tree.js
|
|
154
|
+
var SEGMENT_TYPE_INDEX = 4;
|
|
155
|
+
var SEGMENT_TYPE_PATHLESS = 5;
|
|
156
|
+
function getOpenAndCloseBraces(part) {
|
|
157
|
+
const openBrace = part.indexOf("{");
|
|
158
|
+
if (openBrace === -1) return null;
|
|
159
|
+
const closeBrace = part.indexOf("}", openBrace);
|
|
160
|
+
if (closeBrace === -1) return null;
|
|
161
|
+
if (openBrace + 1 >= part.length) return null;
|
|
162
|
+
return [openBrace, closeBrace];
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Populates the `output` array with the parsed representation of the given `segment` string.
|
|
166
|
+
*
|
|
167
|
+
* Usage:
|
|
168
|
+
* ```ts
|
|
169
|
+
* let output
|
|
170
|
+
* let cursor = 0
|
|
171
|
+
* while (cursor < path.length) {
|
|
172
|
+
* output = parseSegment(path, cursor, output)
|
|
173
|
+
* const end = output[5]
|
|
174
|
+
* cursor = end + 1
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* `output` is stored outside to avoid allocations during repeated calls. It doesn't need to be typed
|
|
178
|
+
* or initialized, it will be done automatically.
|
|
179
|
+
*/
|
|
180
|
+
function parseSegment(path, start, output = /* @__PURE__ */ new Uint16Array(6)) {
|
|
181
|
+
const next = path.indexOf("/", start);
|
|
182
|
+
const end = next === -1 ? path.length : next;
|
|
183
|
+
const part = path.substring(start, end);
|
|
184
|
+
if (!part || !part.includes("$")) {
|
|
185
|
+
output[0] = 0;
|
|
186
|
+
output[1] = start;
|
|
187
|
+
output[2] = start;
|
|
188
|
+
output[3] = end;
|
|
189
|
+
output[4] = end;
|
|
190
|
+
output[5] = end;
|
|
191
|
+
return output;
|
|
192
|
+
}
|
|
193
|
+
if (part === "$") {
|
|
194
|
+
const total = path.length;
|
|
195
|
+
output[0] = 2;
|
|
196
|
+
output[1] = start;
|
|
197
|
+
output[2] = start;
|
|
198
|
+
output[3] = total;
|
|
199
|
+
output[4] = total;
|
|
200
|
+
output[5] = total;
|
|
201
|
+
return output;
|
|
202
|
+
}
|
|
203
|
+
if (part.charCodeAt(0) === 36) {
|
|
204
|
+
output[0] = 1;
|
|
205
|
+
output[1] = start;
|
|
206
|
+
output[2] = start + 1;
|
|
207
|
+
output[3] = end;
|
|
208
|
+
output[4] = end;
|
|
209
|
+
output[5] = end;
|
|
210
|
+
return output;
|
|
211
|
+
}
|
|
212
|
+
const braces = getOpenAndCloseBraces(part);
|
|
213
|
+
if (braces) {
|
|
214
|
+
const [openBrace, closeBrace] = braces;
|
|
215
|
+
const firstChar = part.charCodeAt(openBrace + 1);
|
|
216
|
+
if (firstChar === 45) {
|
|
217
|
+
if (openBrace + 2 < part.length && part.charCodeAt(openBrace + 2) === 36) {
|
|
218
|
+
const paramStart = openBrace + 3;
|
|
219
|
+
const paramEnd = closeBrace;
|
|
220
|
+
if (paramStart < paramEnd) {
|
|
221
|
+
output[0] = 3;
|
|
222
|
+
output[1] = start + openBrace;
|
|
223
|
+
output[2] = start + paramStart;
|
|
224
|
+
output[3] = start + paramEnd;
|
|
225
|
+
output[4] = start + closeBrace + 1;
|
|
226
|
+
output[5] = end;
|
|
227
|
+
return output;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} else if (firstChar === 36) {
|
|
231
|
+
const dollarPos = openBrace + 1;
|
|
232
|
+
const afterDollar = openBrace + 2;
|
|
233
|
+
if (afterDollar === closeBrace) {
|
|
234
|
+
output[0] = 2;
|
|
235
|
+
output[1] = start + openBrace;
|
|
236
|
+
output[2] = start + dollarPos;
|
|
237
|
+
output[3] = start + afterDollar;
|
|
238
|
+
output[4] = start + closeBrace + 1;
|
|
239
|
+
output[5] = path.length;
|
|
240
|
+
return output;
|
|
241
|
+
}
|
|
242
|
+
output[0] = 1;
|
|
243
|
+
output[1] = start + openBrace;
|
|
244
|
+
output[2] = start + afterDollar;
|
|
245
|
+
output[3] = start + closeBrace;
|
|
246
|
+
output[4] = start + closeBrace + 1;
|
|
247
|
+
output[5] = end;
|
|
248
|
+
return output;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
output[0] = 0;
|
|
252
|
+
output[1] = start;
|
|
253
|
+
output[2] = start;
|
|
254
|
+
output[3] = end;
|
|
255
|
+
output[4] = end;
|
|
256
|
+
output[5] = end;
|
|
257
|
+
return output;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Recursively parses the segments of the given route tree and populates a segment trie.
|
|
261
|
+
*
|
|
262
|
+
* @param data A reusable Uint16Array for parsing segments. (non important, we're just avoiding allocations)
|
|
263
|
+
* @param route The current route to parse.
|
|
264
|
+
* @param start The starting index for parsing within the route's full path.
|
|
265
|
+
* @param node The current segment node in the trie to populate.
|
|
266
|
+
* @param onRoute Callback invoked for each route processed.
|
|
267
|
+
*/
|
|
268
|
+
function parseSegments(defaultCaseSensitive, data, route, start, node, depth, onRoute) {
|
|
269
|
+
onRoute?.(route);
|
|
270
|
+
let cursor = start;
|
|
271
|
+
{
|
|
272
|
+
const path = route.fullPath ?? route.from;
|
|
273
|
+
const length = path.length;
|
|
274
|
+
const caseSensitive = route.options?.caseSensitive ?? defaultCaseSensitive;
|
|
275
|
+
const parseParams = route.options?.params?.parse ?? route.options?.parseParams;
|
|
276
|
+
while (cursor < length) {
|
|
277
|
+
const segment = parseSegment(path, cursor, data);
|
|
278
|
+
let nextNode;
|
|
279
|
+
const start = cursor;
|
|
280
|
+
const end = segment[5];
|
|
281
|
+
cursor = end + 1;
|
|
282
|
+
depth++;
|
|
283
|
+
switch (segment[0]) {
|
|
284
|
+
case 0: {
|
|
285
|
+
const value = path.substring(segment[2], segment[3]);
|
|
286
|
+
if (caseSensitive) {
|
|
287
|
+
const existingNode = node.static?.get(value);
|
|
288
|
+
if (existingNode) nextNode = existingNode;
|
|
289
|
+
else {
|
|
290
|
+
node.static ??= /* @__PURE__ */ new Map();
|
|
291
|
+
const next = createStaticNode(route.fullPath ?? route.from);
|
|
292
|
+
next.parent = node;
|
|
293
|
+
next.depth = depth;
|
|
294
|
+
nextNode = next;
|
|
295
|
+
node.static.set(value, next);
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
const name = value.toLowerCase();
|
|
299
|
+
const existingNode = node.staticInsensitive?.get(name);
|
|
300
|
+
if (existingNode) nextNode = existingNode;
|
|
301
|
+
else {
|
|
302
|
+
node.staticInsensitive ??= /* @__PURE__ */ new Map();
|
|
303
|
+
const next = createStaticNode(route.fullPath ?? route.from);
|
|
304
|
+
next.parent = node;
|
|
305
|
+
next.depth = depth;
|
|
306
|
+
nextNode = next;
|
|
307
|
+
node.staticInsensitive.set(name, next);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
case 1: {
|
|
313
|
+
const prefix_raw = path.substring(start, segment[1]);
|
|
314
|
+
const suffix_raw = path.substring(segment[4], end);
|
|
315
|
+
const actuallyCaseSensitive = caseSensitive && !!(prefix_raw || suffix_raw);
|
|
316
|
+
const prefix = !prefix_raw ? void 0 : actuallyCaseSensitive ? prefix_raw : prefix_raw.toLowerCase();
|
|
317
|
+
const suffix = !suffix_raw ? void 0 : actuallyCaseSensitive ? suffix_raw : suffix_raw.toLowerCase();
|
|
318
|
+
const existingNode = !parseParams && node.dynamic?.find((s) => !s.parse && s.caseSensitive === actuallyCaseSensitive && s.prefix === prefix && s.suffix === suffix);
|
|
319
|
+
if (existingNode) nextNode = existingNode;
|
|
320
|
+
else {
|
|
321
|
+
const next = createDynamicNode(1, route.fullPath ?? route.from, actuallyCaseSensitive, prefix, suffix);
|
|
322
|
+
nextNode = next;
|
|
323
|
+
next.depth = depth;
|
|
324
|
+
next.parent = node;
|
|
325
|
+
node.dynamic ??= [];
|
|
326
|
+
node.dynamic.push(next);
|
|
327
|
+
}
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
case 3: {
|
|
331
|
+
const prefix_raw = path.substring(start, segment[1]);
|
|
332
|
+
const suffix_raw = path.substring(segment[4], end);
|
|
333
|
+
const actuallyCaseSensitive = caseSensitive && !!(prefix_raw || suffix_raw);
|
|
334
|
+
const prefix = !prefix_raw ? void 0 : actuallyCaseSensitive ? prefix_raw : prefix_raw.toLowerCase();
|
|
335
|
+
const suffix = !suffix_raw ? void 0 : actuallyCaseSensitive ? suffix_raw : suffix_raw.toLowerCase();
|
|
336
|
+
const existingNode = !parseParams && node.optional?.find((s) => !s.parse && s.caseSensitive === actuallyCaseSensitive && s.prefix === prefix && s.suffix === suffix);
|
|
337
|
+
if (existingNode) nextNode = existingNode;
|
|
338
|
+
else {
|
|
339
|
+
const next = createDynamicNode(3, route.fullPath ?? route.from, actuallyCaseSensitive, prefix, suffix);
|
|
340
|
+
nextNode = next;
|
|
341
|
+
next.parent = node;
|
|
342
|
+
next.depth = depth;
|
|
343
|
+
node.optional ??= [];
|
|
344
|
+
node.optional.push(next);
|
|
345
|
+
}
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
case 2: {
|
|
349
|
+
const prefix_raw = path.substring(start, segment[1]);
|
|
350
|
+
const suffix_raw = path.substring(segment[4], end);
|
|
351
|
+
const actuallyCaseSensitive = caseSensitive && !!(prefix_raw || suffix_raw);
|
|
352
|
+
const prefix = !prefix_raw ? void 0 : actuallyCaseSensitive ? prefix_raw : prefix_raw.toLowerCase();
|
|
353
|
+
const suffix = !suffix_raw ? void 0 : actuallyCaseSensitive ? suffix_raw : suffix_raw.toLowerCase();
|
|
354
|
+
const next = createDynamicNode(2, route.fullPath ?? route.from, actuallyCaseSensitive, prefix, suffix);
|
|
355
|
+
nextNode = next;
|
|
356
|
+
next.parent = node;
|
|
357
|
+
next.depth = depth;
|
|
358
|
+
node.wildcard ??= [];
|
|
359
|
+
node.wildcard.push(next);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
node = nextNode;
|
|
363
|
+
}
|
|
364
|
+
if (parseParams && route.children && !route.isRoot && route.id && route.id.charCodeAt(route.id.lastIndexOf("/") + 1) === 95) {
|
|
365
|
+
const pathlessNode = createStaticNode(route.fullPath ?? route.from);
|
|
366
|
+
pathlessNode.kind = SEGMENT_TYPE_PATHLESS;
|
|
367
|
+
pathlessNode.parent = node;
|
|
368
|
+
depth++;
|
|
369
|
+
pathlessNode.depth = depth;
|
|
370
|
+
node.pathless ??= [];
|
|
371
|
+
node.pathless.push(pathlessNode);
|
|
372
|
+
node = pathlessNode;
|
|
373
|
+
}
|
|
374
|
+
const isLeaf = (route.path || !route.children) && !route.isRoot;
|
|
375
|
+
if (isLeaf && path.endsWith("/")) {
|
|
376
|
+
const indexNode = createStaticNode(route.fullPath ?? route.from);
|
|
377
|
+
indexNode.kind = SEGMENT_TYPE_INDEX;
|
|
378
|
+
indexNode.parent = node;
|
|
379
|
+
depth++;
|
|
380
|
+
indexNode.depth = depth;
|
|
381
|
+
node.index = indexNode;
|
|
382
|
+
node = indexNode;
|
|
383
|
+
}
|
|
384
|
+
node.parse = parseParams ?? null;
|
|
385
|
+
node.priority = route.options?.params?.priority ?? 0;
|
|
386
|
+
if (isLeaf && !node.route) {
|
|
387
|
+
node.route = route;
|
|
388
|
+
node.fullPath = route.fullPath ?? route.from;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (route.children) for (const child of route.children) parseSegments(defaultCaseSensitive, data, child, cursor, node, depth, onRoute);
|
|
392
|
+
}
|
|
393
|
+
function sortDynamic(a, b) {
|
|
394
|
+
if (a.parse && !b.parse) return -1;
|
|
395
|
+
if (!a.parse && b.parse) return 1;
|
|
396
|
+
if (a.parse && b.parse && (a.priority || b.priority)) return b.priority - a.priority;
|
|
397
|
+
if (a.prefix && b.prefix && a.prefix !== b.prefix) {
|
|
398
|
+
if (a.prefix.startsWith(b.prefix)) return -1;
|
|
399
|
+
if (b.prefix.startsWith(a.prefix)) return 1;
|
|
400
|
+
}
|
|
401
|
+
if (a.suffix && b.suffix && a.suffix !== b.suffix) {
|
|
402
|
+
if (a.suffix.endsWith(b.suffix)) return -1;
|
|
403
|
+
if (b.suffix.endsWith(a.suffix)) return 1;
|
|
404
|
+
}
|
|
405
|
+
if (a.prefix && !b.prefix) return -1;
|
|
406
|
+
if (!a.prefix && b.prefix) return 1;
|
|
407
|
+
if (a.suffix && !b.suffix) return -1;
|
|
408
|
+
if (!a.suffix && b.suffix) return 1;
|
|
409
|
+
if (a.caseSensitive && !b.caseSensitive) return -1;
|
|
410
|
+
if (!a.caseSensitive && b.caseSensitive) return 1;
|
|
411
|
+
return 0;
|
|
412
|
+
}
|
|
413
|
+
function sortTreeNodes(node) {
|
|
414
|
+
if (node.pathless) for (const child of node.pathless) sortTreeNodes(child);
|
|
415
|
+
if (node.static) for (const child of node.static.values()) sortTreeNodes(child);
|
|
416
|
+
if (node.staticInsensitive) for (const child of node.staticInsensitive.values()) sortTreeNodes(child);
|
|
417
|
+
if (node.dynamic?.length) {
|
|
418
|
+
node.dynamic.sort(sortDynamic);
|
|
419
|
+
for (const child of node.dynamic) sortTreeNodes(child);
|
|
420
|
+
}
|
|
421
|
+
if (node.optional?.length) {
|
|
422
|
+
node.optional.sort(sortDynamic);
|
|
423
|
+
for (const child of node.optional) sortTreeNodes(child);
|
|
424
|
+
}
|
|
425
|
+
if (node.wildcard?.length) {
|
|
426
|
+
node.wildcard.sort(sortDynamic);
|
|
427
|
+
for (const child of node.wildcard) sortTreeNodes(child);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function createStaticNode(fullPath) {
|
|
431
|
+
return {
|
|
432
|
+
kind: 0,
|
|
433
|
+
depth: 0,
|
|
434
|
+
pathless: null,
|
|
435
|
+
index: null,
|
|
436
|
+
static: null,
|
|
437
|
+
staticInsensitive: null,
|
|
438
|
+
dynamic: null,
|
|
439
|
+
optional: null,
|
|
440
|
+
wildcard: null,
|
|
441
|
+
route: null,
|
|
442
|
+
fullPath,
|
|
443
|
+
parent: null,
|
|
444
|
+
parse: null,
|
|
445
|
+
priority: 0
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Keys must be declared in the same order as in `SegmentNode` type,
|
|
450
|
+
* to ensure they are represented as the same object class in the engine.
|
|
451
|
+
*/
|
|
452
|
+
function createDynamicNode(kind, fullPath, caseSensitive, prefix, suffix) {
|
|
453
|
+
return {
|
|
454
|
+
kind,
|
|
455
|
+
depth: 0,
|
|
456
|
+
pathless: null,
|
|
457
|
+
index: null,
|
|
458
|
+
static: null,
|
|
459
|
+
staticInsensitive: null,
|
|
460
|
+
dynamic: null,
|
|
461
|
+
optional: null,
|
|
462
|
+
wildcard: null,
|
|
463
|
+
route: null,
|
|
464
|
+
fullPath,
|
|
465
|
+
parent: null,
|
|
466
|
+
parse: null,
|
|
467
|
+
priority: 0,
|
|
468
|
+
caseSensitive,
|
|
469
|
+
prefix,
|
|
470
|
+
suffix
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function processRouteMasks(routeList, processedTree) {
|
|
474
|
+
const segmentTree = createStaticNode("/");
|
|
475
|
+
const data = /* @__PURE__ */ new Uint16Array(6);
|
|
476
|
+
for (const route of routeList) parseSegments(false, data, route, 1, segmentTree, 0);
|
|
477
|
+
sortTreeNodes(segmentTree);
|
|
478
|
+
processedTree.masksTree = segmentTree;
|
|
479
|
+
processedTree.flatCache = createLRUCache(1e3);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Take an arbitrary list of routes, create a tree from them (if it hasn't been created already), and match a path against it.
|
|
483
|
+
*/
|
|
484
|
+
function findFlatMatch(path, processedTree) {
|
|
485
|
+
path ||= "/";
|
|
486
|
+
const cached = processedTree.flatCache.get(path);
|
|
487
|
+
if (cached) return cached;
|
|
488
|
+
const result = findMatch(path, processedTree.masksTree);
|
|
489
|
+
processedTree.flatCache.set(path, result);
|
|
490
|
+
return result;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* @deprecated keep until v2 so that `router.matchRoute` can keep not caring about the actual route tree
|
|
494
|
+
*/
|
|
495
|
+
function findSingleMatch(from, caseSensitive, fuzzy, path, processedTree) {
|
|
496
|
+
from ||= "/";
|
|
497
|
+
path ||= "/";
|
|
498
|
+
const key = caseSensitive ? `case\0${from}` : from;
|
|
499
|
+
let tree = processedTree.singleCache.get(key);
|
|
500
|
+
if (!tree) {
|
|
501
|
+
tree = createStaticNode("/");
|
|
502
|
+
parseSegments(caseSensitive, /* @__PURE__ */ new Uint16Array(6), { from }, 1, tree, 0);
|
|
503
|
+
processedTree.singleCache.set(key, tree);
|
|
504
|
+
}
|
|
505
|
+
return findMatch(path, tree, fuzzy);
|
|
506
|
+
}
|
|
507
|
+
function findRouteMatch(path, processedTree, fuzzy = false) {
|
|
508
|
+
const key = fuzzy ? path : `nofuzz\0${path}`;
|
|
509
|
+
const cached = processedTree.matchCache.get(key);
|
|
510
|
+
if (cached !== void 0) return cached;
|
|
511
|
+
path ||= "/";
|
|
512
|
+
let result;
|
|
513
|
+
try {
|
|
514
|
+
result = findMatch(path, processedTree.segmentTree, fuzzy);
|
|
515
|
+
} catch (err) {
|
|
516
|
+
if (err instanceof URIError) result = null;
|
|
517
|
+
else throw err;
|
|
518
|
+
}
|
|
519
|
+
if (result) result.branch = buildRouteBranch(result.route);
|
|
520
|
+
processedTree.matchCache.set(key, result);
|
|
521
|
+
return result;
|
|
522
|
+
}
|
|
523
|
+
/** Trim trailing slashes (except preserving root '/'). */
|
|
524
|
+
function trimPathRight$1(path) {
|
|
525
|
+
return path === "/" ? path : path.replace(/\/{1,}$/, "");
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Processes a route tree into a segment trie for efficient path matching.
|
|
529
|
+
* Also builds lookup maps for routes by ID and by trimmed full path.
|
|
530
|
+
*/
|
|
531
|
+
function processRouteTree(routeTree, caseSensitive = false, initRoute) {
|
|
532
|
+
const segmentTree = createStaticNode(routeTree.fullPath);
|
|
533
|
+
const data = /* @__PURE__ */ new Uint16Array(6);
|
|
534
|
+
const routesById = {};
|
|
535
|
+
const routesByPath = {};
|
|
536
|
+
let index = 0;
|
|
537
|
+
parseSegments(caseSensitive, data, routeTree, 1, segmentTree, 0, (route) => {
|
|
538
|
+
initRoute?.(route, index);
|
|
539
|
+
if (route.id in routesById) invariant();
|
|
540
|
+
routesById[route.id] = route;
|
|
541
|
+
if (index !== 0 && route.path) {
|
|
542
|
+
const trimmedFullPath = trimPathRight$1(route.fullPath);
|
|
543
|
+
if (!routesByPath[trimmedFullPath] || route.fullPath.endsWith("/")) routesByPath[trimmedFullPath] = route;
|
|
544
|
+
}
|
|
545
|
+
index++;
|
|
546
|
+
});
|
|
547
|
+
sortTreeNodes(segmentTree);
|
|
548
|
+
return {
|
|
549
|
+
processedTree: {
|
|
550
|
+
segmentTree,
|
|
551
|
+
singleCache: createLRUCache(1e3),
|
|
552
|
+
matchCache: createLRUCache(1e3),
|
|
553
|
+
flatCache: null,
|
|
554
|
+
masksTree: null
|
|
555
|
+
},
|
|
556
|
+
routesById,
|
|
557
|
+
routesByPath
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
function findMatch(path, segmentTree, fuzzy = false) {
|
|
561
|
+
const parts = path.split("/");
|
|
562
|
+
const leaf = getNodeMatch(path, parts, segmentTree, fuzzy);
|
|
563
|
+
if (!leaf) return null;
|
|
564
|
+
const [rawParams] = extractParams(path, parts, leaf);
|
|
565
|
+
return {
|
|
566
|
+
route: leaf.node.route,
|
|
567
|
+
rawParams
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* This function is "resumable":
|
|
572
|
+
* - the `leaf` input can contain `extract` and `rawParams` properties from a previous `extractParams` call
|
|
573
|
+
* - the returned `state` can be passed back as `extract` in a future call to continue extracting params from where we left off
|
|
574
|
+
*
|
|
575
|
+
* Inputs are *not* mutated.
|
|
576
|
+
*/
|
|
577
|
+
function extractParams(path, parts, leaf) {
|
|
578
|
+
const list = buildBranch(leaf.node);
|
|
579
|
+
let nodeParts = null;
|
|
580
|
+
const rawParams = Object.create(null);
|
|
581
|
+
/** which segment of the path we're currently processing */
|
|
582
|
+
let partIndex = leaf.extract?.part ?? 0;
|
|
583
|
+
/** which node of the route tree branch we're currently processing */
|
|
584
|
+
let nodeIndex = leaf.extract?.node ?? 0;
|
|
585
|
+
/** index of the 1st character of the segment we're processing in the path string */
|
|
586
|
+
let pathIndex = leaf.extract?.path ?? 0;
|
|
587
|
+
/** which fullPath segment we're currently processing */
|
|
588
|
+
let segmentCount = leaf.extract?.segment ?? 0;
|
|
589
|
+
for (; nodeIndex < list.length; partIndex++, nodeIndex++, pathIndex++, segmentCount++) {
|
|
590
|
+
const node = list[nodeIndex];
|
|
591
|
+
if (node.kind === SEGMENT_TYPE_INDEX) break;
|
|
592
|
+
if (node.kind === SEGMENT_TYPE_PATHLESS) {
|
|
593
|
+
segmentCount--;
|
|
594
|
+
partIndex--;
|
|
595
|
+
pathIndex--;
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
const part = parts[partIndex];
|
|
599
|
+
const currentPathIndex = pathIndex;
|
|
600
|
+
if (part) pathIndex += part.length;
|
|
601
|
+
if (node.kind === 1) {
|
|
602
|
+
nodeParts ??= leaf.node.fullPath.split("/");
|
|
603
|
+
const nodePart = nodeParts[segmentCount];
|
|
604
|
+
const preLength = node.prefix?.length ?? 0;
|
|
605
|
+
if (nodePart.charCodeAt(preLength) === 123) {
|
|
606
|
+
const sufLength = node.suffix?.length ?? 0;
|
|
607
|
+
const name = nodePart.substring(preLength + 2, nodePart.length - sufLength - 1);
|
|
608
|
+
const value = part.substring(preLength, part.length - sufLength);
|
|
609
|
+
rawParams[name] = decodeURIComponent(value);
|
|
610
|
+
} else {
|
|
611
|
+
const name = nodePart.substring(1);
|
|
612
|
+
rawParams[name] = decodeURIComponent(part);
|
|
613
|
+
}
|
|
614
|
+
} else if (node.kind === 3) {
|
|
615
|
+
if (leaf.skipped & 1 << nodeIndex) {
|
|
616
|
+
partIndex--;
|
|
617
|
+
pathIndex = currentPathIndex - 1;
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
nodeParts ??= leaf.node.fullPath.split("/");
|
|
621
|
+
const nodePart = nodeParts[segmentCount];
|
|
622
|
+
const preLength = node.prefix?.length ?? 0;
|
|
623
|
+
const sufLength = node.suffix?.length ?? 0;
|
|
624
|
+
const name = nodePart.substring(preLength + 3, nodePart.length - sufLength - 1);
|
|
625
|
+
const value = node.suffix || node.prefix ? part.substring(preLength, part.length - sufLength) : part;
|
|
626
|
+
if (value) rawParams[name] = decodeURIComponent(value);
|
|
627
|
+
} else if (node.kind === 2) {
|
|
628
|
+
const n = node;
|
|
629
|
+
const value = path.substring(currentPathIndex + (n.prefix?.length ?? 0), path.length - (n.suffix?.length ?? 0));
|
|
630
|
+
const splat = decodeURIComponent(value);
|
|
631
|
+
rawParams["*"] = splat;
|
|
632
|
+
rawParams._splat = splat;
|
|
633
|
+
break;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (leaf.rawParams) Object.assign(rawParams, leaf.rawParams);
|
|
637
|
+
return [rawParams, {
|
|
638
|
+
part: partIndex,
|
|
639
|
+
node: nodeIndex,
|
|
640
|
+
path: pathIndex,
|
|
641
|
+
segment: segmentCount
|
|
642
|
+
}];
|
|
643
|
+
}
|
|
644
|
+
function buildRouteBranch(route) {
|
|
645
|
+
const list = [route];
|
|
646
|
+
while (route.parentRoute) {
|
|
647
|
+
route = route.parentRoute;
|
|
648
|
+
list.push(route);
|
|
649
|
+
}
|
|
650
|
+
list.reverse();
|
|
651
|
+
return list;
|
|
652
|
+
}
|
|
653
|
+
function buildBranch(node) {
|
|
654
|
+
const list = Array(node.depth + 1);
|
|
655
|
+
do {
|
|
656
|
+
list[node.depth] = node;
|
|
657
|
+
node = node.parent;
|
|
658
|
+
} while (node);
|
|
659
|
+
return list;
|
|
660
|
+
}
|
|
661
|
+
function getNodeMatch(path, parts, segmentTree, fuzzy) {
|
|
662
|
+
if (path === "/" && segmentTree.index) return {
|
|
663
|
+
node: segmentTree.index,
|
|
664
|
+
skipped: 0
|
|
665
|
+
};
|
|
666
|
+
const trailingSlash = !last(parts);
|
|
667
|
+
const pathIsIndex = trailingSlash && path !== "/";
|
|
668
|
+
const partsLength = parts.length - (trailingSlash ? 1 : 0);
|
|
669
|
+
const stack = [{
|
|
670
|
+
node: segmentTree,
|
|
671
|
+
index: 1,
|
|
672
|
+
skipped: 0,
|
|
673
|
+
depth: 1,
|
|
674
|
+
statics: 0,
|
|
675
|
+
dynamics: 0,
|
|
676
|
+
optionals: 0
|
|
677
|
+
}];
|
|
678
|
+
let bestFuzzy = null;
|
|
679
|
+
let bestMatch = null;
|
|
680
|
+
while (stack.length) {
|
|
681
|
+
const frame = stack.pop();
|
|
682
|
+
const { node, index, skipped, depth, statics, dynamics, optionals } = frame;
|
|
683
|
+
let { extract, rawParams } = frame;
|
|
684
|
+
if (node.kind === 2 && node.route && !isFrameMoreSpecific(bestMatch, frame)) continue;
|
|
685
|
+
if (node.parse) {
|
|
686
|
+
if (!validateParseParams(path, parts, frame)) continue;
|
|
687
|
+
rawParams = frame.rawParams;
|
|
688
|
+
extract = frame.extract;
|
|
689
|
+
}
|
|
690
|
+
if (fuzzy && node.route && node.kind !== SEGMENT_TYPE_INDEX && isFrameMoreSpecific(bestFuzzy, frame)) bestFuzzy = frame;
|
|
691
|
+
const isBeyondPath = index === partsLength;
|
|
692
|
+
if (isBeyondPath) {
|
|
693
|
+
if (node.route && (!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX || node.kind === 2) && isFrameMoreSpecific(bestMatch, frame)) bestMatch = frame;
|
|
694
|
+
if (!node.optional && !node.wildcard && !node.index && !node.pathless) continue;
|
|
695
|
+
}
|
|
696
|
+
const part = isBeyondPath ? void 0 : parts[index];
|
|
697
|
+
let lowerPart;
|
|
698
|
+
if (isBeyondPath && node.index) {
|
|
699
|
+
const indexFrame = {
|
|
700
|
+
node: node.index,
|
|
701
|
+
index,
|
|
702
|
+
skipped,
|
|
703
|
+
depth: depth + 1,
|
|
704
|
+
statics,
|
|
705
|
+
dynamics,
|
|
706
|
+
optionals,
|
|
707
|
+
extract,
|
|
708
|
+
rawParams
|
|
709
|
+
};
|
|
710
|
+
let indexValid = true;
|
|
711
|
+
if (node.index.parse) {
|
|
712
|
+
if (!validateParseParams(path, parts, indexFrame)) indexValid = false;
|
|
713
|
+
}
|
|
714
|
+
if (indexValid) {
|
|
715
|
+
if (!dynamics && !optionals && !skipped && isPerfectStaticMatch(statics, partsLength)) return indexFrame;
|
|
716
|
+
if (isFrameMoreSpecific(bestMatch, indexFrame)) bestMatch = indexFrame;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
if (node.wildcard) for (let i = node.wildcard.length - 1; i >= 0; i--) {
|
|
720
|
+
const segment = node.wildcard[i];
|
|
721
|
+
const { prefix, suffix } = segment;
|
|
722
|
+
if (prefix) {
|
|
723
|
+
if (isBeyondPath) continue;
|
|
724
|
+
if (!(segment.caseSensitive ? part : lowerPart ??= part.toLowerCase()).startsWith(prefix)) continue;
|
|
725
|
+
}
|
|
726
|
+
if (suffix) {
|
|
727
|
+
if (isBeyondPath) continue;
|
|
728
|
+
const end = parts.slice(index).join("/").slice(-suffix.length);
|
|
729
|
+
if ((segment.caseSensitive ? end : end.toLowerCase()) !== suffix) continue;
|
|
730
|
+
}
|
|
731
|
+
stack.push({
|
|
732
|
+
node: segment,
|
|
733
|
+
index: partsLength,
|
|
734
|
+
skipped,
|
|
735
|
+
depth: depth + 1,
|
|
736
|
+
statics,
|
|
737
|
+
dynamics,
|
|
738
|
+
optionals,
|
|
739
|
+
extract,
|
|
740
|
+
rawParams
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
if (node.optional) {
|
|
744
|
+
const nextSkipped = skipped | 1 << depth;
|
|
745
|
+
const nextDepth = depth + 1;
|
|
746
|
+
for (let i = node.optional.length - 1; i >= 0; i--) {
|
|
747
|
+
const segment = node.optional[i];
|
|
748
|
+
stack.push({
|
|
749
|
+
node: segment,
|
|
750
|
+
index,
|
|
751
|
+
skipped: nextSkipped,
|
|
752
|
+
depth: nextDepth,
|
|
753
|
+
statics,
|
|
754
|
+
dynamics,
|
|
755
|
+
optionals,
|
|
756
|
+
extract,
|
|
757
|
+
rawParams
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
if (!isBeyondPath) for (let i = node.optional.length - 1; i >= 0; i--) {
|
|
761
|
+
const segment = node.optional[i];
|
|
762
|
+
const { prefix, suffix } = segment;
|
|
763
|
+
if (prefix || suffix) {
|
|
764
|
+
const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
|
|
765
|
+
if (prefix && !casePart.startsWith(prefix)) continue;
|
|
766
|
+
if (suffix && !casePart.endsWith(suffix)) continue;
|
|
767
|
+
}
|
|
768
|
+
stack.push({
|
|
769
|
+
node: segment,
|
|
770
|
+
index: index + 1,
|
|
771
|
+
skipped,
|
|
772
|
+
depth: nextDepth,
|
|
773
|
+
statics,
|
|
774
|
+
dynamics,
|
|
775
|
+
optionals: optionals + segmentScore(partsLength, index),
|
|
776
|
+
extract,
|
|
777
|
+
rawParams
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
if (!isBeyondPath && node.dynamic && part) for (let i = node.dynamic.length - 1; i >= 0; i--) {
|
|
782
|
+
const segment = node.dynamic[i];
|
|
783
|
+
const { prefix, suffix } = segment;
|
|
784
|
+
if (prefix || suffix) {
|
|
785
|
+
const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
|
|
786
|
+
if (prefix && !casePart.startsWith(prefix)) continue;
|
|
787
|
+
if (suffix && !casePart.endsWith(suffix)) continue;
|
|
788
|
+
}
|
|
789
|
+
stack.push({
|
|
790
|
+
node: segment,
|
|
791
|
+
index: index + 1,
|
|
792
|
+
skipped,
|
|
793
|
+
depth: depth + 1,
|
|
794
|
+
statics,
|
|
795
|
+
dynamics: dynamics + segmentScore(partsLength, index),
|
|
796
|
+
optionals,
|
|
797
|
+
extract,
|
|
798
|
+
rawParams
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
if (!isBeyondPath && node.staticInsensitive) {
|
|
802
|
+
const match = node.staticInsensitive.get(lowerPart ??= part.toLowerCase());
|
|
803
|
+
if (match) stack.push({
|
|
804
|
+
node: match,
|
|
805
|
+
index: index + 1,
|
|
806
|
+
skipped,
|
|
807
|
+
depth: depth + 1,
|
|
808
|
+
statics: statics + segmentScore(partsLength, index),
|
|
809
|
+
dynamics,
|
|
810
|
+
optionals,
|
|
811
|
+
extract,
|
|
812
|
+
rawParams
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
if (!isBeyondPath && node.static) {
|
|
816
|
+
const match = node.static.get(part);
|
|
817
|
+
if (match) stack.push({
|
|
818
|
+
node: match,
|
|
819
|
+
index: index + 1,
|
|
820
|
+
skipped,
|
|
821
|
+
depth: depth + 1,
|
|
822
|
+
statics: statics + segmentScore(partsLength, index),
|
|
823
|
+
dynamics,
|
|
824
|
+
optionals,
|
|
825
|
+
extract,
|
|
826
|
+
rawParams
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
if (node.pathless) {
|
|
830
|
+
const nextDepth = depth + 1;
|
|
831
|
+
for (let i = node.pathless.length - 1; i >= 0; i--) {
|
|
832
|
+
const segment = node.pathless[i];
|
|
833
|
+
stack.push({
|
|
834
|
+
node: segment,
|
|
835
|
+
index,
|
|
836
|
+
skipped,
|
|
837
|
+
depth: nextDepth,
|
|
838
|
+
statics,
|
|
839
|
+
dynamics,
|
|
840
|
+
optionals,
|
|
841
|
+
extract,
|
|
842
|
+
rawParams
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (bestMatch) return bestMatch;
|
|
848
|
+
if (fuzzy && bestFuzzy) {
|
|
849
|
+
let sliceIndex = bestFuzzy.index;
|
|
850
|
+
for (let i = 0; i < bestFuzzy.index; i++) sliceIndex += parts[i].length;
|
|
851
|
+
const splat = sliceIndex === path.length ? "/" : path.slice(sliceIndex);
|
|
852
|
+
bestFuzzy.rawParams ??= Object.create(null);
|
|
853
|
+
bestFuzzy.rawParams["**"] = decodeURIComponent(splat);
|
|
854
|
+
return bestFuzzy;
|
|
855
|
+
}
|
|
856
|
+
return null;
|
|
857
|
+
}
|
|
858
|
+
function segmentScore(partsLength, index) {
|
|
859
|
+
return 2 ** (partsLength - index - 1);
|
|
860
|
+
}
|
|
861
|
+
function isPerfectStaticMatch(statics, partsLength) {
|
|
862
|
+
return statics === 2 ** (partsLength - 1) - 1;
|
|
863
|
+
}
|
|
864
|
+
function validateParseParams(path, parts, frame) {
|
|
865
|
+
let rawParams;
|
|
866
|
+
let state;
|
|
867
|
+
try {
|
|
868
|
+
[rawParams, state] = extractParams(path, parts, frame);
|
|
869
|
+
} catch {
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
frame.rawParams = rawParams;
|
|
873
|
+
frame.extract = state;
|
|
874
|
+
if (!frame.node.parse) return true;
|
|
875
|
+
try {
|
|
876
|
+
if (frame.node.parse(rawParams) === false) return null;
|
|
877
|
+
} catch {}
|
|
878
|
+
return true;
|
|
879
|
+
}
|
|
880
|
+
function isFrameMoreSpecific(prev, next) {
|
|
881
|
+
if (!prev) return true;
|
|
882
|
+
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.depth > prev.depth)));
|
|
883
|
+
}
|
|
884
|
+
//#endregion
|
|
885
|
+
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.15/node_modules/@tanstack/router-core/dist/esm/path.js
|
|
886
|
+
/** Join path segments, cleaning duplicate slashes between parts. */
|
|
887
|
+
function joinPaths(paths) {
|
|
888
|
+
return cleanPath(paths.filter((val) => {
|
|
889
|
+
return val !== void 0;
|
|
890
|
+
}).join("/"));
|
|
891
|
+
}
|
|
892
|
+
/** Remove repeated slashes from a path string. */
|
|
893
|
+
function cleanPath(path) {
|
|
894
|
+
return path.replace(/\/{2,}/g, "/");
|
|
895
|
+
}
|
|
896
|
+
/** Trim leading slashes (except preserving root '/'). */
|
|
897
|
+
function trimPathLeft(path) {
|
|
898
|
+
return path === "/" ? path : path.replace(/^\/{1,}/, "");
|
|
899
|
+
}
|
|
900
|
+
/** Trim trailing slashes (except preserving root '/'). */
|
|
901
|
+
function trimPathRight(path) {
|
|
902
|
+
const len = path.length;
|
|
903
|
+
return len > 1 && path[len - 1] === "/" ? path.replace(/\/{1,}$/, "") : path;
|
|
904
|
+
}
|
|
905
|
+
/** Trim both leading and trailing slashes. */
|
|
906
|
+
function trimPath(path) {
|
|
907
|
+
return trimPathRight(trimPathLeft(path));
|
|
908
|
+
}
|
|
909
|
+
/** Remove a trailing slash from value when appropriate for comparisons. */
|
|
910
|
+
function removeTrailingSlash(value, basepath) {
|
|
911
|
+
if (value?.endsWith("/") && value !== "/" && value !== `${basepath}/`) return value.slice(0, -1);
|
|
912
|
+
return value;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Compare two pathnames for exact equality after normalizing trailing slashes
|
|
916
|
+
* relative to the provided `basepath`.
|
|
917
|
+
*/
|
|
918
|
+
function exactPathTest(pathName1, pathName2, basepath) {
|
|
919
|
+
return removeTrailingSlash(pathName1, basepath) === removeTrailingSlash(pathName2, basepath);
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Resolve a destination path against a base, honoring trailing-slash policy
|
|
923
|
+
* and supporting relative segments (`.`/`..`) and absolute `to` values.
|
|
924
|
+
*/
|
|
925
|
+
function resolvePath({ base, to, trailingSlash = "never", cache }) {
|
|
926
|
+
const isAbsolute = to.startsWith("/");
|
|
927
|
+
const isBase = !isAbsolute && to === ".";
|
|
928
|
+
let key;
|
|
929
|
+
if (cache) {
|
|
930
|
+
key = isAbsolute ? to : isBase ? base : base + "\0" + to;
|
|
931
|
+
const cached = cache.get(key);
|
|
932
|
+
if (cached) return cached;
|
|
933
|
+
}
|
|
934
|
+
let baseSegments;
|
|
935
|
+
if (isBase) baseSegments = base.split("/");
|
|
936
|
+
else if (isAbsolute) baseSegments = to.split("/");
|
|
937
|
+
else {
|
|
938
|
+
baseSegments = base.split("/");
|
|
939
|
+
while (baseSegments.length > 1 && last(baseSegments) === "") baseSegments.pop();
|
|
940
|
+
const toSegments = to.split("/");
|
|
941
|
+
for (let index = 0, length = toSegments.length; index < length; index++) {
|
|
942
|
+
const value = toSegments[index];
|
|
943
|
+
if (value === "") {
|
|
944
|
+
if (!index) baseSegments = [value];
|
|
945
|
+
else if (index === length - 1) baseSegments.push(value);
|
|
946
|
+
} else if (value === "..") baseSegments.pop();
|
|
947
|
+
else if (value === ".") {} else baseSegments.push(value);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
if (baseSegments.length > 1) {
|
|
951
|
+
if (last(baseSegments) === "") {
|
|
952
|
+
if (trailingSlash === "never") baseSegments.pop();
|
|
953
|
+
} else if (trailingSlash === "always") baseSegments.push("");
|
|
954
|
+
}
|
|
955
|
+
const result = cleanPath(baseSegments.join("/")) || "/";
|
|
956
|
+
if (key && cache) cache.set(key, result);
|
|
957
|
+
return result;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Create a pre-compiled decode config from allowed characters.
|
|
961
|
+
* This should be called once at router initialization.
|
|
962
|
+
*/
|
|
963
|
+
function compileDecodeCharMap(pathParamsAllowedCharacters) {
|
|
964
|
+
const charMap = new Map(pathParamsAllowedCharacters.map((char) => [encodeURIComponent(char), char]));
|
|
965
|
+
const pattern = Array.from(charMap.keys()).map((key) => key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
966
|
+
const regex = new RegExp(pattern, "g");
|
|
967
|
+
return (encoded) => encoded.replace(regex, (match) => charMap.get(match) ?? match);
|
|
968
|
+
}
|
|
969
|
+
function encodeParam(key, params, decoder) {
|
|
970
|
+
const value = params[key];
|
|
971
|
+
if (typeof value !== "string") return value;
|
|
972
|
+
if (key === "_splat") {
|
|
973
|
+
if (/^[a-zA-Z0-9\-._~!/]*$/.test(value)) return value;
|
|
974
|
+
return value.split("/").map((segment) => encodePathParam(segment, decoder)).join("/");
|
|
975
|
+
} else return encodePathParam(value, decoder);
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Interpolate params and wildcards into a route path template.
|
|
979
|
+
*
|
|
980
|
+
* - Encodes params safely (configurable allowed characters)
|
|
981
|
+
* - Supports `{-$optional}` segments, `{prefix{$id}suffix}` and `{$}` wildcards
|
|
982
|
+
*/
|
|
983
|
+
function interpolatePath({ path, params, decoder, ...rest }) {
|
|
984
|
+
let isMissingParams = false;
|
|
985
|
+
const usedParams = Object.create(null);
|
|
986
|
+
if (!path || path === "/") return {
|
|
987
|
+
interpolatedPath: "/",
|
|
988
|
+
usedParams,
|
|
989
|
+
isMissingParams
|
|
990
|
+
};
|
|
991
|
+
if (!path.includes("$")) return {
|
|
992
|
+
interpolatedPath: path,
|
|
993
|
+
usedParams,
|
|
994
|
+
isMissingParams
|
|
995
|
+
};
|
|
996
|
+
if (path.indexOf("{") === -1) {
|
|
997
|
+
const length = path.length;
|
|
998
|
+
let cursor = 0;
|
|
999
|
+
let joined = "";
|
|
1000
|
+
while (cursor < length) {
|
|
1001
|
+
while (cursor < length && path.charCodeAt(cursor) === 47) cursor++;
|
|
1002
|
+
if (cursor >= length) break;
|
|
1003
|
+
const start = cursor;
|
|
1004
|
+
let end = path.indexOf("/", cursor);
|
|
1005
|
+
if (end === -1) end = length;
|
|
1006
|
+
cursor = end;
|
|
1007
|
+
const part = path.substring(start, end);
|
|
1008
|
+
if (!part) continue;
|
|
1009
|
+
if (part.charCodeAt(0) === 36) if (part.length === 1) {
|
|
1010
|
+
const splat = params._splat;
|
|
1011
|
+
usedParams._splat = splat;
|
|
1012
|
+
usedParams["*"] = splat;
|
|
1013
|
+
if (!splat) {
|
|
1014
|
+
isMissingParams = true;
|
|
1015
|
+
continue;
|
|
1016
|
+
}
|
|
1017
|
+
const value = encodeParam("_splat", params, decoder);
|
|
1018
|
+
joined += "/" + value;
|
|
1019
|
+
} else {
|
|
1020
|
+
const key = part.substring(1);
|
|
1021
|
+
if (!isMissingParams && !(key in params)) isMissingParams = true;
|
|
1022
|
+
usedParams[key] = params[key];
|
|
1023
|
+
const value = encodeParam(key, params, decoder) ?? "undefined";
|
|
1024
|
+
joined += "/" + value;
|
|
1025
|
+
}
|
|
1026
|
+
else joined += "/" + part;
|
|
1027
|
+
}
|
|
1028
|
+
if (path.endsWith("/")) joined += "/";
|
|
1029
|
+
return {
|
|
1030
|
+
usedParams,
|
|
1031
|
+
interpolatedPath: joined || "/",
|
|
1032
|
+
isMissingParams
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
const length = path.length;
|
|
1036
|
+
let cursor = 0;
|
|
1037
|
+
let segment;
|
|
1038
|
+
let joined = "";
|
|
1039
|
+
while (cursor < length) {
|
|
1040
|
+
const start = cursor;
|
|
1041
|
+
segment = parseSegment(path, start, segment);
|
|
1042
|
+
const end = segment[5];
|
|
1043
|
+
cursor = end + 1;
|
|
1044
|
+
if (start === end) continue;
|
|
1045
|
+
const kind = segment[0];
|
|
1046
|
+
if (kind === 0) {
|
|
1047
|
+
joined += "/" + path.substring(start, end);
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
if (kind === 2) {
|
|
1051
|
+
const splat = params._splat;
|
|
1052
|
+
usedParams._splat = splat;
|
|
1053
|
+
usedParams["*"] = splat;
|
|
1054
|
+
const prefix = path.substring(start, segment[1]);
|
|
1055
|
+
const suffix = path.substring(segment[4], end);
|
|
1056
|
+
if (!splat) {
|
|
1057
|
+
isMissingParams = true;
|
|
1058
|
+
if (prefix || suffix) joined += "/" + prefix + suffix;
|
|
1059
|
+
continue;
|
|
1060
|
+
}
|
|
1061
|
+
const value = encodeParam("_splat", params, decoder);
|
|
1062
|
+
joined += "/" + prefix + value + suffix;
|
|
1063
|
+
continue;
|
|
1064
|
+
}
|
|
1065
|
+
if (kind === 1) {
|
|
1066
|
+
const key = path.substring(segment[2], segment[3]);
|
|
1067
|
+
if (!isMissingParams && !(key in params)) isMissingParams = true;
|
|
1068
|
+
usedParams[key] = params[key];
|
|
1069
|
+
const prefix = path.substring(start, segment[1]);
|
|
1070
|
+
const suffix = path.substring(segment[4], end);
|
|
1071
|
+
const value = encodeParam(key, params, decoder) ?? "undefined";
|
|
1072
|
+
joined += "/" + prefix + value + suffix;
|
|
1073
|
+
continue;
|
|
1074
|
+
}
|
|
1075
|
+
if (kind === 3) {
|
|
1076
|
+
const key = path.substring(segment[2], segment[3]);
|
|
1077
|
+
const valueRaw = params[key];
|
|
1078
|
+
if (valueRaw == null) continue;
|
|
1079
|
+
usedParams[key] = valueRaw;
|
|
1080
|
+
const prefix = path.substring(start, segment[1]);
|
|
1081
|
+
const suffix = path.substring(segment[4], end);
|
|
1082
|
+
const value = encodeParam(key, params, decoder) ?? "";
|
|
1083
|
+
joined += "/" + prefix + value + suffix;
|
|
1084
|
+
continue;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
if (path.endsWith("/")) joined += "/";
|
|
1088
|
+
return {
|
|
1089
|
+
usedParams,
|
|
1090
|
+
interpolatedPath: joined || "/",
|
|
1091
|
+
isMissingParams
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
function encodePathParam(value, decoder) {
|
|
1095
|
+
const encoded = encodeURIComponent(value);
|
|
1096
|
+
return decoder?.(encoded) ?? encoded;
|
|
1097
|
+
}
|
|
1098
|
+
//#endregion
|
|
1099
|
+
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.15/node_modules/@tanstack/router-core/dist/esm/root.js
|
|
1100
|
+
/** Stable identifier used for the root route in a route tree. */
|
|
1101
|
+
var rootRouteId = "__root__";
|
|
1102
|
+
//#endregion
|
|
1103
|
+
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.15/node_modules/@tanstack/router-core/dist/esm/redirect.js
|
|
1104
|
+
/**
|
|
1105
|
+
* Create a redirect Response understood by TanStack Router.
|
|
1106
|
+
*
|
|
1107
|
+
* Use from route `loader`/`beforeLoad` or server functions to trigger a
|
|
1108
|
+
* navigation. If `throw: true` is set, the redirect is thrown instead of
|
|
1109
|
+
* returned. When an absolute `href` is supplied and `reloadDocument` is not
|
|
1110
|
+
* set, a full-document navigation is inferred.
|
|
1111
|
+
*
|
|
1112
|
+
* @param opts Options for the redirect. Common fields:
|
|
1113
|
+
* - `href`: absolute URL for external redirects; infers `reloadDocument`.
|
|
1114
|
+
* - `statusCode`: HTTP status code to use (defaults to 307).
|
|
1115
|
+
* - `headers`: additional headers to include on the Response.
|
|
1116
|
+
* - Standard navigation options like `to`, `params`, `search`, `replace`,
|
|
1117
|
+
* and `reloadDocument` for internal redirects.
|
|
1118
|
+
* @returns A Response augmented with router navigation options.
|
|
1119
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/redirectFunction
|
|
1120
|
+
*/
|
|
1121
|
+
function redirect(opts) {
|
|
1122
|
+
opts.statusCode = opts.statusCode || opts.code || 307;
|
|
1123
|
+
if (!opts._builtLocation && !opts.reloadDocument && typeof opts.href === "string") try {
|
|
1124
|
+
new URL(opts.href);
|
|
1125
|
+
opts.reloadDocument = true;
|
|
1126
|
+
} catch {}
|
|
1127
|
+
const headers = new Headers(opts.headers);
|
|
1128
|
+
if (opts.href && headers.get("Location") === null) headers.set("Location", opts.href);
|
|
1129
|
+
const response = new Response(null, {
|
|
1130
|
+
status: opts.statusCode,
|
|
1131
|
+
headers
|
|
1132
|
+
});
|
|
1133
|
+
response.options = opts;
|
|
1134
|
+
if (opts.throw) throw response;
|
|
1135
|
+
return response;
|
|
1136
|
+
}
|
|
1137
|
+
/** Check whether a value is a TanStack Router redirect Response. */
|
|
1138
|
+
/** Check whether a value is a TanStack Router redirect Response. */
|
|
1139
|
+
function isRedirect(obj) {
|
|
1140
|
+
return obj instanceof Response && !!obj.options;
|
|
1141
|
+
}
|
|
1142
|
+
/** True if value is a redirect with a resolved `href` location. */
|
|
1143
|
+
/** True if value is a redirect with a resolved `href` location. */
|
|
1144
|
+
function isResolvedRedirect(obj) {
|
|
1145
|
+
return isRedirect(obj) && !!obj.options.href;
|
|
1146
|
+
}
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.18_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/@tanstack/react-router/dist/esm/ClientOnly.js
|
|
1149
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
1150
|
+
/**
|
|
1151
|
+
* Render the children only after the JS has loaded client-side. Use an optional
|
|
1152
|
+
* fallback component if the JS is not yet loaded.
|
|
1153
|
+
*
|
|
1154
|
+
* @example
|
|
1155
|
+
* Render a Chart component if JS loads, renders a simple FakeChart
|
|
1156
|
+
* component server-side or if there is no JS. The FakeChart can have only the
|
|
1157
|
+
* UI without the behavior or be a loading spinner or skeleton.
|
|
1158
|
+
*
|
|
1159
|
+
* ```tsx
|
|
1160
|
+
* return (
|
|
1161
|
+
* <ClientOnly fallback={<FakeChart />}>
|
|
1162
|
+
* <Chart />
|
|
1163
|
+
* </ClientOnly>
|
|
1164
|
+
* )
|
|
1165
|
+
* ```
|
|
1166
|
+
*/
|
|
1167
|
+
function ClientOnly({ children, fallback = null }) {
|
|
1168
|
+
return useHydrated() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: fallback });
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Return a boolean indicating if the JS has been hydrated already.
|
|
1172
|
+
* When doing Server-Side Rendering, the result will always be false.
|
|
1173
|
+
* When doing Client-Side Rendering, the result will always be false on the
|
|
1174
|
+
* first render and true from then on. Even if a new component renders it will
|
|
1175
|
+
* always start with true.
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* ```tsx
|
|
1179
|
+
* // Disable a button that needs JS to work.
|
|
1180
|
+
* let hydrated = useHydrated()
|
|
1181
|
+
* return (
|
|
1182
|
+
* <button type="button" disabled={!hydrated} onClick={doSomethingCustom}>
|
|
1183
|
+
* Click me
|
|
1184
|
+
* </button>
|
|
1185
|
+
* )
|
|
1186
|
+
* ```
|
|
1187
|
+
* @returns True if the JS has been hydrated already, false otherwise.
|
|
1188
|
+
*/
|
|
1189
|
+
function useHydrated() {
|
|
1190
|
+
return import_react.useSyncExternalStore(subscribe, () => true, () => false);
|
|
1191
|
+
}
|
|
1192
|
+
function subscribe() {
|
|
1193
|
+
return () => {};
|
|
1194
|
+
}
|
|
1195
|
+
//#endregion
|
|
1196
|
+
//#region ../../node_modules/.pnpm/react-dom@19.2.7_react@19.2.7/node_modules/react-dom/cjs/react-dom.production.js
|
|
1197
|
+
/**
|
|
1198
|
+
* @license React
|
|
1199
|
+
* react-dom.production.js
|
|
1200
|
+
*
|
|
1201
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1202
|
+
*
|
|
1203
|
+
* This source code is licensed under the MIT license found in the
|
|
1204
|
+
* LICENSE file in the root directory of this source tree.
|
|
1205
|
+
*/
|
|
1206
|
+
var require_react_dom_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1207
|
+
var React = require_react();
|
|
1208
|
+
function formatProdErrorMessage(code) {
|
|
1209
|
+
var url = "https://react.dev/errors/" + code;
|
|
1210
|
+
if (1 < arguments.length) {
|
|
1211
|
+
url += "?args[]=" + encodeURIComponent(arguments[1]);
|
|
1212
|
+
for (var i = 2; i < arguments.length; i++) url += "&args[]=" + encodeURIComponent(arguments[i]);
|
|
1213
|
+
}
|
|
1214
|
+
return "Minified React error #" + code + "; visit " + url + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
|
|
1215
|
+
}
|
|
1216
|
+
function noop() {}
|
|
1217
|
+
var Internals = {
|
|
1218
|
+
d: {
|
|
1219
|
+
f: noop,
|
|
1220
|
+
r: function() {
|
|
1221
|
+
throw Error(formatProdErrorMessage(522));
|
|
1222
|
+
},
|
|
1223
|
+
D: noop,
|
|
1224
|
+
C: noop,
|
|
1225
|
+
L: noop,
|
|
1226
|
+
m: noop,
|
|
1227
|
+
X: noop,
|
|
1228
|
+
S: noop,
|
|
1229
|
+
M: noop
|
|
1230
|
+
},
|
|
1231
|
+
p: 0,
|
|
1232
|
+
findDOMNode: null
|
|
1233
|
+
};
|
|
1234
|
+
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
|
1235
|
+
function createPortal$1(children, containerInfo, implementation) {
|
|
1236
|
+
var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
|
|
1237
|
+
return {
|
|
1238
|
+
$$typeof: REACT_PORTAL_TYPE,
|
|
1239
|
+
key: null == key ? null : "" + key,
|
|
1240
|
+
children,
|
|
1241
|
+
containerInfo,
|
|
1242
|
+
implementation
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
var ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
1246
|
+
function getCrossOriginStringAs(as, input) {
|
|
1247
|
+
if ("font" === as) return "";
|
|
1248
|
+
if ("string" === typeof input) return "use-credentials" === input ? input : "";
|
|
1249
|
+
}
|
|
1250
|
+
exports.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = Internals;
|
|
1251
|
+
exports.createPortal = function(children, container) {
|
|
1252
|
+
var key = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : null;
|
|
1253
|
+
if (!container || 1 !== container.nodeType && 9 !== container.nodeType && 11 !== container.nodeType) throw Error(formatProdErrorMessage(299));
|
|
1254
|
+
return createPortal$1(children, container, null, key);
|
|
1255
|
+
};
|
|
1256
|
+
exports.flushSync = function(fn) {
|
|
1257
|
+
var previousTransition = ReactSharedInternals.T, previousUpdatePriority = Internals.p;
|
|
1258
|
+
try {
|
|
1259
|
+
if (ReactSharedInternals.T = null, Internals.p = 2, fn) return fn();
|
|
1260
|
+
} finally {
|
|
1261
|
+
ReactSharedInternals.T = previousTransition, Internals.p = previousUpdatePriority, Internals.d.f();
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
exports.preconnect = function(href, options) {
|
|
1265
|
+
"string" === typeof href && (options ? (options = options.crossOrigin, options = "string" === typeof options ? "use-credentials" === options ? options : "" : void 0) : options = null, Internals.d.C(href, options));
|
|
1266
|
+
};
|
|
1267
|
+
exports.prefetchDNS = function(href) {
|
|
1268
|
+
"string" === typeof href && Internals.d.D(href);
|
|
1269
|
+
};
|
|
1270
|
+
exports.preinit = function(href, options) {
|
|
1271
|
+
if ("string" === typeof href && options && "string" === typeof options.as) {
|
|
1272
|
+
var as = options.as, crossOrigin = getCrossOriginStringAs(as, options.crossOrigin), integrity = "string" === typeof options.integrity ? options.integrity : void 0, fetchPriority = "string" === typeof options.fetchPriority ? options.fetchPriority : void 0;
|
|
1273
|
+
"style" === as ? Internals.d.S(href, "string" === typeof options.precedence ? options.precedence : void 0, {
|
|
1274
|
+
crossOrigin,
|
|
1275
|
+
integrity,
|
|
1276
|
+
fetchPriority
|
|
1277
|
+
}) : "script" === as && Internals.d.X(href, {
|
|
1278
|
+
crossOrigin,
|
|
1279
|
+
integrity,
|
|
1280
|
+
fetchPriority,
|
|
1281
|
+
nonce: "string" === typeof options.nonce ? options.nonce : void 0
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
exports.preinitModule = function(href, options) {
|
|
1286
|
+
if ("string" === typeof href) if ("object" === typeof options && null !== options) {
|
|
1287
|
+
if (null == options.as || "script" === options.as) {
|
|
1288
|
+
var crossOrigin = getCrossOriginStringAs(options.as, options.crossOrigin);
|
|
1289
|
+
Internals.d.M(href, {
|
|
1290
|
+
crossOrigin,
|
|
1291
|
+
integrity: "string" === typeof options.integrity ? options.integrity : void 0,
|
|
1292
|
+
nonce: "string" === typeof options.nonce ? options.nonce : void 0
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
} else options ?? Internals.d.M(href);
|
|
1296
|
+
};
|
|
1297
|
+
exports.preload = function(href, options) {
|
|
1298
|
+
if ("string" === typeof href && "object" === typeof options && null !== options && "string" === typeof options.as) {
|
|
1299
|
+
var as = options.as, crossOrigin = getCrossOriginStringAs(as, options.crossOrigin);
|
|
1300
|
+
Internals.d.L(href, as, {
|
|
1301
|
+
crossOrigin,
|
|
1302
|
+
integrity: "string" === typeof options.integrity ? options.integrity : void 0,
|
|
1303
|
+
nonce: "string" === typeof options.nonce ? options.nonce : void 0,
|
|
1304
|
+
type: "string" === typeof options.type ? options.type : void 0,
|
|
1305
|
+
fetchPriority: "string" === typeof options.fetchPriority ? options.fetchPriority : void 0,
|
|
1306
|
+
referrerPolicy: "string" === typeof options.referrerPolicy ? options.referrerPolicy : void 0,
|
|
1307
|
+
imageSrcSet: "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0,
|
|
1308
|
+
imageSizes: "string" === typeof options.imageSizes ? options.imageSizes : void 0,
|
|
1309
|
+
media: "string" === typeof options.media ? options.media : void 0
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
exports.preloadModule = function(href, options) {
|
|
1314
|
+
if ("string" === typeof href) if (options) {
|
|
1315
|
+
var crossOrigin = getCrossOriginStringAs(options.as, options.crossOrigin);
|
|
1316
|
+
Internals.d.m(href, {
|
|
1317
|
+
as: "string" === typeof options.as && "script" !== options.as ? options.as : void 0,
|
|
1318
|
+
crossOrigin,
|
|
1319
|
+
integrity: "string" === typeof options.integrity ? options.integrity : void 0
|
|
1320
|
+
});
|
|
1321
|
+
} else Internals.d.m(href);
|
|
1322
|
+
};
|
|
1323
|
+
exports.requestFormReset = function(form) {
|
|
1324
|
+
Internals.d.r(form);
|
|
1325
|
+
};
|
|
1326
|
+
exports.unstable_batchedUpdates = function(fn, a) {
|
|
1327
|
+
return fn(a);
|
|
1328
|
+
};
|
|
1329
|
+
exports.useFormState = function(action, initialState, permalink) {
|
|
1330
|
+
return ReactSharedInternals.H.useFormState(action, initialState, permalink);
|
|
1331
|
+
};
|
|
1332
|
+
exports.useFormStatus = function() {
|
|
1333
|
+
return ReactSharedInternals.H.useHostTransitionStatus();
|
|
1334
|
+
};
|
|
1335
|
+
exports.version = "19.2.7";
|
|
1336
|
+
}));
|
|
1337
|
+
//#endregion
|
|
1338
|
+
//#region ../../node_modules/.pnpm/react-dom@19.2.7_react@19.2.7/node_modules/react-dom/index.js
|
|
1339
|
+
var require_react_dom = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1340
|
+
function checkDCE() {
|
|
1341
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== "function") return;
|
|
1342
|
+
try {
|
|
1343
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
|
|
1344
|
+
} catch (err) {
|
|
1345
|
+
console.error(err);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
checkDCE();
|
|
1349
|
+
module.exports = require_react_dom_production();
|
|
1350
|
+
}));
|
|
1351
|
+
//#endregion
|
|
1352
|
+
export { processRouteTree as C, useIntersectionObserver as D, useForwardedRef as E, useLayoutEffect as O, processRouteMasks as S, reactUse as T, trimPathRight as _, isResolvedRedirect as a, findRouteMatch as b, cleanPath as c, interpolatePath as d, joinPaths as f, trimPathLeft as g, trimPath as h, isRedirect as i, usePrevious as k, compileDecodeCharMap as l, resolvePath as m, ClientOnly as n, redirect as o, removeTrailingSlash as p, useHydrated as r, rootRouteId as s, require_react_dom as t, exactPathTest as u, buildRouteBranch as v, createLRUCache as w, findSingleMatch as x, findFlatMatch as y };
|