@takeokunn/gbrainx 0.0.0-stage → 0.1.1
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 +58 -2
- package/dist/core.mjs +1346 -0
- package/dist/gbrainx.mjs +7097 -0
- package/dist/web/client/assets/api-BvRk9kiK.js +0 -0
- package/dist/web/client/assets/demo-G0WCPBHC.js +10 -0
- package/dist/web/client/assets/entry.client-BMJZABtH.js +9 -0
- package/dist/web/client/assets/gbrainx-DfnQgPxe.js +49 -0
- package/dist/web/client/assets/health-BvRk9kiK.js +0 -0
- package/dist/web/client/assets/home-DSGr2mzJ.js +7 -0
- package/dist/web/client/assets/i18n-CbBRRmtS.js +1 -0
- package/dist/web/client/assets/jsx-runtime-C8YK_IxR.js +16 -0
- package/dist/web/client/assets/lib-C32AnKSP.js +1 -0
- package/dist/web/client/assets/manifest-813cc1a4.js +1 -0
- package/dist/web/client/assets/root-C-cLqVHP.js +1 -0
- package/dist/web/client/assets/root-D4kqIC2S.css +2 -0
- package/dist/web/client/assets/root-i18n-_0Yddpt_.js +1 -0
- package/dist/web/client/assets/sell-CxnwvqXu.css +1 -0
- package/dist/web/client/assets/sell-DbbNBdAa.js +1 -0
- package/dist/web/client/assets/use-lp-language-ij45BzB4.js +1 -0
- package/dist/web/client/avatars/aiko.svg +7 -0
- package/dist/web/client/avatars/daniel.svg +7 -0
- package/dist/web/client/avatars/ken.svg +7 -0
- package/dist/web/client/avatars/leo.svg +7 -0
- package/dist/web/client/avatars/yui.svg +7 -0
- package/dist/web/client/demo.mp4 +0 -0
- package/dist/web/client/favicon.ico +0 -0
- package/dist/web/server/assets/cloudflare-context-CIZdXilT.js +3426 -0
- package/dist/web/server/assets/rolldown-runtime-nwr4M8im.js +34 -0
- package/dist/web/server/assets/server-build-2JeuoODN.css +2 -0
- package/dist/web/server/assets/server-build-B915Unu9.js +22845 -0
- package/package.json +13 -4
|
@@ -0,0 +1,3426 @@
|
|
|
1
|
+
import { r as __toESM, t as __commonJSMin } from "./rolldown-runtime-nwr4M8im.js";
|
|
2
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/router/url.js
|
|
3
|
+
/**
|
|
4
|
+
* react-router v8.5.3
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Remix Software Inc.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
* @license MIT
|
|
12
|
+
*/
|
|
13
|
+
var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i;
|
|
14
|
+
var PROTOCOL_RELATIVE_URL_REGEX = /^[\\/]{2}/;
|
|
15
|
+
function normalizeProtocolRelativeUrl(url, protocol) {
|
|
16
|
+
return protocol + url.replace(/\\/g, "/");
|
|
17
|
+
}
|
|
18
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/router/history.js
|
|
19
|
+
/**
|
|
20
|
+
* react-router v8.5.3
|
|
21
|
+
*
|
|
22
|
+
* Copyright (c) Remix Software Inc.
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the MIT license found in the
|
|
25
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
26
|
+
*
|
|
27
|
+
* @license MIT
|
|
28
|
+
*/
|
|
29
|
+
function invariant(value, message) {
|
|
30
|
+
if (value === false || value === null || typeof value === "undefined") throw new Error(message);
|
|
31
|
+
}
|
|
32
|
+
function warning(cond, message) {
|
|
33
|
+
if (!cond) {
|
|
34
|
+
if (typeof console !== "undefined") console.warn(message);
|
|
35
|
+
try {
|
|
36
|
+
throw new Error(message);
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function createKey() {
|
|
41
|
+
return Math.random().toString(36).substring(2, 10);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a Location object with a unique key from the given Path
|
|
45
|
+
*/
|
|
46
|
+
function createLocation(current, to, state = null, key, mask) {
|
|
47
|
+
return {
|
|
48
|
+
pathname: typeof current === "string" ? current : current.pathname,
|
|
49
|
+
search: "",
|
|
50
|
+
hash: "",
|
|
51
|
+
...typeof to === "string" ? parsePath(to) : to,
|
|
52
|
+
state,
|
|
53
|
+
key: to && to.key || key || createKey(),
|
|
54
|
+
mask
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a string URL path from the given pathname, search, and hash components.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
* @category Utils
|
|
62
|
+
* @param path The pathname, search, and hash components to combine.
|
|
63
|
+
* @returns The combined URL path.
|
|
64
|
+
*/
|
|
65
|
+
function createPath({ pathname = "/", search = "", hash = "" }) {
|
|
66
|
+
if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search;
|
|
67
|
+
if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
|
68
|
+
return pathname;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Parses a string URL path into its separate pathname, search, and hash components.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
* @category Utils
|
|
75
|
+
* @param path The URL path to parse.
|
|
76
|
+
* @returns The parsed pathname, search, and hash components.
|
|
77
|
+
*/
|
|
78
|
+
function parsePath(path) {
|
|
79
|
+
let parsedPath = {};
|
|
80
|
+
if (path) {
|
|
81
|
+
let hashIndex = path.indexOf("#");
|
|
82
|
+
if (hashIndex >= 0) {
|
|
83
|
+
parsedPath.hash = path.substring(hashIndex);
|
|
84
|
+
path = path.substring(0, hashIndex);
|
|
85
|
+
}
|
|
86
|
+
let searchIndex = path.indexOf("?");
|
|
87
|
+
if (searchIndex >= 0) {
|
|
88
|
+
parsedPath.search = path.substring(searchIndex);
|
|
89
|
+
path = path.substring(0, searchIndex);
|
|
90
|
+
}
|
|
91
|
+
if (path) parsedPath.pathname = path;
|
|
92
|
+
}
|
|
93
|
+
return parsedPath;
|
|
94
|
+
}
|
|
95
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/router/navigation.js
|
|
96
|
+
/**
|
|
97
|
+
* react-router v8.5.3
|
|
98
|
+
*
|
|
99
|
+
* Copyright (c) Remix Software Inc.
|
|
100
|
+
*
|
|
101
|
+
* This source code is licensed under the MIT license found in the
|
|
102
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
103
|
+
*
|
|
104
|
+
* @license MIT
|
|
105
|
+
*/
|
|
106
|
+
var DEFAULT_NAVIGATION_URL = new URL("http://localhost");
|
|
107
|
+
function getNavigatorCurrentUrl(navigator) {
|
|
108
|
+
if (navigator.createURL) return navigator.createURL("/");
|
|
109
|
+
try {
|
|
110
|
+
return new URL(navigator.createHref("/"), DEFAULT_NAVIGATION_URL);
|
|
111
|
+
} catch {
|
|
112
|
+
return DEFAULT_NAVIGATION_URL;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function isSameOrigin(a, b) {
|
|
116
|
+
return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
|
|
117
|
+
}
|
|
118
|
+
function isExplicitUrl(destination, target) {
|
|
119
|
+
if (destination.startsWith("//")) return true;
|
|
120
|
+
let protocol = target.protocol.toLowerCase();
|
|
121
|
+
if (!destination.toLowerCase().startsWith(protocol)) return false;
|
|
122
|
+
return target.host === "" || destination.slice(protocol.length).startsWith("//");
|
|
123
|
+
}
|
|
124
|
+
function validateDocumentNavigationTarget(destination) {
|
|
125
|
+
let normalized = destination.replace(/[\t\n\r]/g, "");
|
|
126
|
+
let start = 0;
|
|
127
|
+
while (normalized.charCodeAt(start) <= 32) start++;
|
|
128
|
+
normalized = normalized.slice(start);
|
|
129
|
+
if (!ABSOLUTE_URL_REGEX.test(normalized)) return;
|
|
130
|
+
let target;
|
|
131
|
+
try {
|
|
132
|
+
target = new URL(destination, DEFAULT_NAVIGATION_URL);
|
|
133
|
+
} catch {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (!isExplicitUrl(destination, target)) throw new Error("External navigation is not allowed");
|
|
137
|
+
}
|
|
138
|
+
function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
|
|
139
|
+
let originalUrl = null;
|
|
140
|
+
try {
|
|
141
|
+
originalUrl = original == null ? null : new URL(original, currentUrl);
|
|
142
|
+
} catch {}
|
|
143
|
+
let resolvedUrl = new URL(resolved, currentUrl);
|
|
144
|
+
let originalIsExternal = originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
|
|
145
|
+
let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
|
|
146
|
+
if (externalPolicy === "reject") {
|
|
147
|
+
if (originalIsExternal || resolvedIsExternal) throw new Error("External navigation is not allowed");
|
|
148
|
+
} else if (resolvedIsExternal) {
|
|
149
|
+
if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) throw new Error("External navigation is not allowed");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// node_modules/.pnpm/react@19.3.1/node_modules/react/cjs/react.production.js
|
|
153
|
+
/**
|
|
154
|
+
* @license React
|
|
155
|
+
* react.production.js
|
|
156
|
+
*
|
|
157
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
158
|
+
*
|
|
159
|
+
* This source code is licensed under the MIT license found in the
|
|
160
|
+
* LICENSE file in the root directory of this source tree.
|
|
161
|
+
*/
|
|
162
|
+
var require_react_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
163
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element");
|
|
164
|
+
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
|
165
|
+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
166
|
+
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
|
|
167
|
+
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
168
|
+
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer");
|
|
169
|
+
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
|
170
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
|
171
|
+
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
172
|
+
var REACT_MEMO_TYPE = Symbol.for("react.memo");
|
|
173
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
174
|
+
var REACT_ACTIVITY_TYPE = Symbol.for("react.activity");
|
|
175
|
+
var REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition");
|
|
176
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
177
|
+
function getIteratorFn(maybeIterable) {
|
|
178
|
+
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
|
|
179
|
+
maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
|
|
180
|
+
return "function" === typeof maybeIterable ? maybeIterable : null;
|
|
181
|
+
}
|
|
182
|
+
var ReactNoopUpdateQueue = {
|
|
183
|
+
isMounted: function() {
|
|
184
|
+
return !1;
|
|
185
|
+
},
|
|
186
|
+
enqueueForceUpdate: function() {},
|
|
187
|
+
enqueueReplaceState: function() {},
|
|
188
|
+
enqueueSetState: function() {}
|
|
189
|
+
};
|
|
190
|
+
var assign = Object.assign;
|
|
191
|
+
var emptyObject = {};
|
|
192
|
+
function Component(props, context, updater) {
|
|
193
|
+
this.props = props;
|
|
194
|
+
this.context = context;
|
|
195
|
+
this.refs = emptyObject;
|
|
196
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
197
|
+
}
|
|
198
|
+
Component.prototype.isReactComponent = {};
|
|
199
|
+
Component.prototype.setState = function(partialState, callback) {
|
|
200
|
+
if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState) throw Error("takes an object of state variables to update or a function which returns an object of state variables.");
|
|
201
|
+
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
202
|
+
};
|
|
203
|
+
Component.prototype.forceUpdate = function(callback) {
|
|
204
|
+
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
205
|
+
};
|
|
206
|
+
function ComponentDummy() {}
|
|
207
|
+
ComponentDummy.prototype = Component.prototype;
|
|
208
|
+
function PureComponent(props, context, updater) {
|
|
209
|
+
this.props = props;
|
|
210
|
+
this.context = context;
|
|
211
|
+
this.refs = emptyObject;
|
|
212
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
213
|
+
}
|
|
214
|
+
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
215
|
+
pureComponentPrototype.constructor = PureComponent;
|
|
216
|
+
assign(pureComponentPrototype, Component.prototype);
|
|
217
|
+
pureComponentPrototype.isPureReactComponent = !0;
|
|
218
|
+
var isArrayImpl = Array.isArray;
|
|
219
|
+
function noop() {}
|
|
220
|
+
var ReactSharedInternals = {
|
|
221
|
+
H: null,
|
|
222
|
+
A: null,
|
|
223
|
+
T: null,
|
|
224
|
+
S: null
|
|
225
|
+
};
|
|
226
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
227
|
+
function ReactElement(type, key, props) {
|
|
228
|
+
var refProp = props.ref;
|
|
229
|
+
return {
|
|
230
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
231
|
+
type,
|
|
232
|
+
key,
|
|
233
|
+
ref: void 0 !== refProp ? refProp : null,
|
|
234
|
+
props
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
|
238
|
+
return ReactElement(oldElement.type, newKey, oldElement.props);
|
|
239
|
+
}
|
|
240
|
+
function isValidElement(object) {
|
|
241
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
242
|
+
}
|
|
243
|
+
function escape(key) {
|
|
244
|
+
var escaperLookup = {
|
|
245
|
+
"=": "=0",
|
|
246
|
+
":": "=2"
|
|
247
|
+
};
|
|
248
|
+
return "$" + key.replace(/[=:]/g, function(match) {
|
|
249
|
+
return escaperLookup[match];
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
253
|
+
function getElementKey(element, index) {
|
|
254
|
+
return "object" === typeof element && null !== element && null != element.key ? escape("" + element.key) : index.toString(36);
|
|
255
|
+
}
|
|
256
|
+
function resolveThenable(thenable) {
|
|
257
|
+
switch (thenable.status) {
|
|
258
|
+
case "fulfilled": return thenable.value;
|
|
259
|
+
case "rejected": throw thenable.reason;
|
|
260
|
+
default: switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(function(fulfilledValue) {
|
|
261
|
+
"pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
|
|
262
|
+
}, function(error) {
|
|
263
|
+
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
264
|
+
})), thenable.status) {
|
|
265
|
+
case "fulfilled": return thenable.value;
|
|
266
|
+
case "rejected": throw thenable.reason;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
throw thenable;
|
|
270
|
+
}
|
|
271
|
+
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
272
|
+
var type = typeof children;
|
|
273
|
+
if ("undefined" === type || "boolean" === type) children = null;
|
|
274
|
+
var invokeCallback = !1;
|
|
275
|
+
if (null === children) invokeCallback = !0;
|
|
276
|
+
else switch (type) {
|
|
277
|
+
case "bigint":
|
|
278
|
+
case "string":
|
|
279
|
+
case "number":
|
|
280
|
+
invokeCallback = !0;
|
|
281
|
+
break;
|
|
282
|
+
case "object": switch (children.$$typeof) {
|
|
283
|
+
case REACT_ELEMENT_TYPE:
|
|
284
|
+
case REACT_PORTAL_TYPE:
|
|
285
|
+
invokeCallback = !0;
|
|
286
|
+
break;
|
|
287
|
+
case REACT_LAZY_TYPE: return invokeCallback = children._init, mapIntoArray(invokeCallback(children._payload), array, escapedPrefix, nameSoFar, callback);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (invokeCallback) return callback = callback(children), invokeCallback = "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar, isArrayImpl(callback) ? (escapedPrefix = "", null != invokeCallback && (escapedPrefix = invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
|
|
291
|
+
return c;
|
|
292
|
+
})) : null != callback && (isValidElement(callback) && (callback = cloneAndReplaceKey(callback, escapedPrefix + (null == callback.key || children && children.key === callback.key ? "" : ("" + callback.key).replace(userProvidedKeyEscapeRegex, "$&/") + "/") + invokeCallback)), array.push(callback)), 1;
|
|
293
|
+
invokeCallback = 0;
|
|
294
|
+
var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
|
|
295
|
+
if (isArrayImpl(children)) for (var i = 0; i < children.length; i++) nameSoFar = children[i], type = nextNamePrefix + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
|
|
296
|
+
else if (i = getIteratorFn(children), "function" === typeof i) for (children = i.call(children), i = 0; !(nameSoFar = children.next()).done;) nameSoFar = nameSoFar.value, type = nextNamePrefix + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
|
|
297
|
+
else if ("object" === type) {
|
|
298
|
+
if ("function" === typeof children.then) return mapIntoArray(resolveThenable(children), array, escapedPrefix, nameSoFar, callback);
|
|
299
|
+
array = String(children);
|
|
300
|
+
throw Error("Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead.");
|
|
301
|
+
}
|
|
302
|
+
return invokeCallback;
|
|
303
|
+
}
|
|
304
|
+
function mapChildren(children, func, context) {
|
|
305
|
+
if (null == children) return children;
|
|
306
|
+
var result = [], count = 0;
|
|
307
|
+
mapIntoArray(children, result, "", "", function(child) {
|
|
308
|
+
return func.call(context, child, count++);
|
|
309
|
+
});
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
function lazyInitializer(payload) {
|
|
313
|
+
if (-1 === payload._status) {
|
|
314
|
+
var thenable = (0, payload._result)();
|
|
315
|
+
thenable.then(function(moduleObject) {
|
|
316
|
+
if (0 === payload._status || -1 === payload._status) payload._status = 1, payload._result = moduleObject, void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
|
|
317
|
+
}, function(error) {
|
|
318
|
+
if (0 === payload._status || -1 === payload._status) payload._status = 2, payload._result = error, void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
319
|
+
});
|
|
320
|
+
-1 === payload._status && (payload._status = 0, payload._result = thenable);
|
|
321
|
+
}
|
|
322
|
+
if (1 === payload._status) return payload._result.default;
|
|
323
|
+
throw payload._result;
|
|
324
|
+
}
|
|
325
|
+
var reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
|
|
326
|
+
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
|
327
|
+
var event = new window.ErrorEvent("error", {
|
|
328
|
+
bubbles: !0,
|
|
329
|
+
cancelable: !0,
|
|
330
|
+
message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
|
|
331
|
+
error
|
|
332
|
+
});
|
|
333
|
+
if (!window.dispatchEvent(event)) return;
|
|
334
|
+
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
|
335
|
+
process.emit("uncaughtException", error);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
console.error(error);
|
|
339
|
+
};
|
|
340
|
+
function startTransition(scope) {
|
|
341
|
+
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
|
342
|
+
currentTransition.types = null !== prevTransition ? prevTransition.types : null;
|
|
343
|
+
ReactSharedInternals.T = currentTransition;
|
|
344
|
+
try {
|
|
345
|
+
var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
|
|
346
|
+
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
|
347
|
+
"object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop, reportGlobalError);
|
|
348
|
+
} catch (error) {
|
|
349
|
+
reportGlobalError(error);
|
|
350
|
+
} finally {
|
|
351
|
+
null !== prevTransition && null !== currentTransition.types && (prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function addTransitionType(type) {
|
|
355
|
+
var transition = ReactSharedInternals.T;
|
|
356
|
+
if (null !== transition) {
|
|
357
|
+
var transitionTypes = transition.types;
|
|
358
|
+
null === transitionTypes ? transition.types = [type] : -1 === transitionTypes.indexOf(type) && transitionTypes.push(type);
|
|
359
|
+
} else startTransition(addTransitionType.bind(null, type));
|
|
360
|
+
}
|
|
361
|
+
var Children = {
|
|
362
|
+
map: mapChildren,
|
|
363
|
+
forEach: function(children, forEachFunc, forEachContext) {
|
|
364
|
+
mapChildren(children, function() {
|
|
365
|
+
forEachFunc.apply(this, arguments);
|
|
366
|
+
}, forEachContext);
|
|
367
|
+
},
|
|
368
|
+
count: function(children) {
|
|
369
|
+
var n = 0;
|
|
370
|
+
mapChildren(children, function() {
|
|
371
|
+
n++;
|
|
372
|
+
});
|
|
373
|
+
return n;
|
|
374
|
+
},
|
|
375
|
+
toArray: function(children) {
|
|
376
|
+
return mapChildren(children, function(child) {
|
|
377
|
+
return child;
|
|
378
|
+
}) || [];
|
|
379
|
+
},
|
|
380
|
+
only: function(children) {
|
|
381
|
+
if (!isValidElement(children)) throw Error("React.Children.only expected to receive a single React element child.");
|
|
382
|
+
return children;
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
exports.Activity = REACT_ACTIVITY_TYPE;
|
|
386
|
+
exports.Children = Children;
|
|
387
|
+
exports.Component = Component;
|
|
388
|
+
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
389
|
+
exports.Profiler = REACT_PROFILER_TYPE;
|
|
390
|
+
exports.PureComponent = PureComponent;
|
|
391
|
+
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
392
|
+
exports.Suspense = REACT_SUSPENSE_TYPE;
|
|
393
|
+
exports.ViewTransition = REACT_VIEW_TRANSITION_TYPE;
|
|
394
|
+
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
|
|
395
|
+
exports.__COMPILER_RUNTIME = {
|
|
396
|
+
__proto__: null,
|
|
397
|
+
c: function(size) {
|
|
398
|
+
return ReactSharedInternals.H.useMemoCache(size);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
exports.addTransitionType = addTransitionType;
|
|
402
|
+
exports.cache = function(fn) {
|
|
403
|
+
return function() {
|
|
404
|
+
return fn.apply(null, arguments);
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
exports.cacheSignal = function() {
|
|
408
|
+
return null;
|
|
409
|
+
};
|
|
410
|
+
exports.cloneElement = function(element, config, children) {
|
|
411
|
+
if (null === element || void 0 === element) throw Error("The argument must be a React element, but you passed " + element + ".");
|
|
412
|
+
var props = assign({}, element.props), key = element.key;
|
|
413
|
+
if (null != config) for (propName in void 0 !== config.key && (key = "" + config.key), config) !hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
|
|
414
|
+
var propName = arguments.length - 2;
|
|
415
|
+
if (1 === propName) props.children = children;
|
|
416
|
+
else if (1 < propName) {
|
|
417
|
+
for (var childArray = Array(propName), i = 0; i < propName; i++) childArray[i] = arguments[i + 2];
|
|
418
|
+
props.children = childArray;
|
|
419
|
+
}
|
|
420
|
+
return ReactElement(element.type, key, props);
|
|
421
|
+
};
|
|
422
|
+
exports.createContext = function(defaultValue) {
|
|
423
|
+
defaultValue = {
|
|
424
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
425
|
+
_currentValue: defaultValue,
|
|
426
|
+
_currentValue2: defaultValue,
|
|
427
|
+
_threadCount: 0,
|
|
428
|
+
Provider: null,
|
|
429
|
+
Consumer: null
|
|
430
|
+
};
|
|
431
|
+
defaultValue.Provider = defaultValue;
|
|
432
|
+
defaultValue.Consumer = {
|
|
433
|
+
$$typeof: REACT_CONSUMER_TYPE,
|
|
434
|
+
_context: defaultValue
|
|
435
|
+
};
|
|
436
|
+
return defaultValue;
|
|
437
|
+
};
|
|
438
|
+
exports.createElement = function(type, config, children) {
|
|
439
|
+
var propName, props = {}, key = null;
|
|
440
|
+
if (null != config) for (propName in void 0 !== config.key && (key = "" + config.key), config) hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (props[propName] = config[propName]);
|
|
441
|
+
var childrenLength = arguments.length - 2;
|
|
442
|
+
if (1 === childrenLength) props.children = children;
|
|
443
|
+
else if (1 < childrenLength) {
|
|
444
|
+
for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++) childArray[i] = arguments[i + 2];
|
|
445
|
+
props.children = childArray;
|
|
446
|
+
}
|
|
447
|
+
if (type && type.defaultProps) for (propName in childrenLength = type.defaultProps, childrenLength) void 0 === props[propName] && (props[propName] = childrenLength[propName]);
|
|
448
|
+
return ReactElement(type, key, props);
|
|
449
|
+
};
|
|
450
|
+
exports.createRef = function() {
|
|
451
|
+
return { current: null };
|
|
452
|
+
};
|
|
453
|
+
exports.forwardRef = function(render) {
|
|
454
|
+
return {
|
|
455
|
+
$$typeof: REACT_FORWARD_REF_TYPE,
|
|
456
|
+
render
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
exports.isValidElement = isValidElement;
|
|
460
|
+
exports.lazy = function(ctor) {
|
|
461
|
+
return {
|
|
462
|
+
$$typeof: REACT_LAZY_TYPE,
|
|
463
|
+
_payload: {
|
|
464
|
+
_status: -1,
|
|
465
|
+
_result: ctor
|
|
466
|
+
},
|
|
467
|
+
_init: lazyInitializer
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
exports.memo = function(type, compare) {
|
|
471
|
+
return {
|
|
472
|
+
$$typeof: REACT_MEMO_TYPE,
|
|
473
|
+
type,
|
|
474
|
+
compare: void 0 === compare ? null : compare
|
|
475
|
+
};
|
|
476
|
+
};
|
|
477
|
+
exports.startTransition = startTransition;
|
|
478
|
+
exports.unstable_useCacheRefresh = function() {
|
|
479
|
+
return ReactSharedInternals.H.useCacheRefresh();
|
|
480
|
+
};
|
|
481
|
+
exports.use = function(usable) {
|
|
482
|
+
return ReactSharedInternals.H.use(usable);
|
|
483
|
+
};
|
|
484
|
+
exports.useActionState = function(action, initialState, permalink) {
|
|
485
|
+
return ReactSharedInternals.H.useActionState(action, initialState, permalink);
|
|
486
|
+
};
|
|
487
|
+
exports.useCallback = function(callback, deps) {
|
|
488
|
+
return ReactSharedInternals.H.useCallback(callback, deps);
|
|
489
|
+
};
|
|
490
|
+
exports.useContext = function(Context) {
|
|
491
|
+
return ReactSharedInternals.H.useContext(Context);
|
|
492
|
+
};
|
|
493
|
+
exports.useDebugValue = function() {};
|
|
494
|
+
exports.useDeferredValue = function(value, initialValue) {
|
|
495
|
+
return ReactSharedInternals.H.useDeferredValue(value, initialValue);
|
|
496
|
+
};
|
|
497
|
+
exports.useEffect = function(create, deps) {
|
|
498
|
+
return ReactSharedInternals.H.useEffect(create, deps);
|
|
499
|
+
};
|
|
500
|
+
exports.useEffectEvent = function(callback) {
|
|
501
|
+
return ReactSharedInternals.H.useEffectEvent(callback);
|
|
502
|
+
};
|
|
503
|
+
exports.useId = function() {
|
|
504
|
+
return ReactSharedInternals.H.useId();
|
|
505
|
+
};
|
|
506
|
+
exports.useImperativeHandle = function(ref, create, deps) {
|
|
507
|
+
return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
|
|
508
|
+
};
|
|
509
|
+
exports.useInsertionEffect = function(create, deps) {
|
|
510
|
+
return ReactSharedInternals.H.useInsertionEffect(create, deps);
|
|
511
|
+
};
|
|
512
|
+
exports.useLayoutEffect = function(create, deps) {
|
|
513
|
+
return ReactSharedInternals.H.useLayoutEffect(create, deps);
|
|
514
|
+
};
|
|
515
|
+
exports.useMemo = function(create, deps) {
|
|
516
|
+
return ReactSharedInternals.H.useMemo(create, deps);
|
|
517
|
+
};
|
|
518
|
+
exports.useOptimistic = function(passthrough, reducer) {
|
|
519
|
+
return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
|
|
520
|
+
};
|
|
521
|
+
exports.useReducer = function(reducer, initialArg, init) {
|
|
522
|
+
return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
|
|
523
|
+
};
|
|
524
|
+
exports.useRef = function(initialValue) {
|
|
525
|
+
return ReactSharedInternals.H.useRef(initialValue);
|
|
526
|
+
};
|
|
527
|
+
exports.useState = function(initialState) {
|
|
528
|
+
return ReactSharedInternals.H.useState(initialState);
|
|
529
|
+
};
|
|
530
|
+
exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
|
|
531
|
+
return ReactSharedInternals.H.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
532
|
+
};
|
|
533
|
+
exports.useTransition = function() {
|
|
534
|
+
return ReactSharedInternals.H.useTransition();
|
|
535
|
+
};
|
|
536
|
+
exports.version = "19.3.1";
|
|
537
|
+
}));
|
|
538
|
+
// node_modules/.pnpm/react@19.3.1/node_modules/react/index.js
|
|
539
|
+
var require_react = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
540
|
+
module.exports = require_react_production();
|
|
541
|
+
}));
|
|
542
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/router/utils.js
|
|
543
|
+
/**
|
|
544
|
+
* react-router v8.5.3
|
|
545
|
+
*
|
|
546
|
+
* Copyright (c) Remix Software Inc.
|
|
547
|
+
*
|
|
548
|
+
* This source code is licensed under the MIT license found in the
|
|
549
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
550
|
+
*
|
|
551
|
+
* @license MIT
|
|
552
|
+
*/
|
|
553
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
554
|
+
/**
|
|
555
|
+
* Creates a type-safe {@link RouterContext} object that can be used to
|
|
556
|
+
* store and retrieve arbitrary values in [`action`](../../start/framework/route-module#action)s,
|
|
557
|
+
* [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
|
|
558
|
+
* Similar to React's [`createContext`](https://react.dev/reference/react/createContext),
|
|
559
|
+
* but specifically designed for React Router's request/response lifecycle.
|
|
560
|
+
*
|
|
561
|
+
* If a `defaultValue` is provided, it will be returned from `context.get()`
|
|
562
|
+
* when no value has been set for the context. Otherwise, reading this context
|
|
563
|
+
* when no value has been set will throw an error.
|
|
564
|
+
*
|
|
565
|
+
* ```tsx filename=app/context.ts
|
|
566
|
+
* import { createContext } from "react-router";
|
|
567
|
+
*
|
|
568
|
+
* // Create a context for user data
|
|
569
|
+
* export const userContext =
|
|
570
|
+
* createContext<User | null>(null);
|
|
571
|
+
* ```
|
|
572
|
+
*
|
|
573
|
+
* ```tsx filename=app/middleware/auth.ts
|
|
574
|
+
* import { getUserFromSession } from "~/auth.server";
|
|
575
|
+
* import { userContext } from "~/context";
|
|
576
|
+
*
|
|
577
|
+
* export const authMiddleware = async ({
|
|
578
|
+
* context,
|
|
579
|
+
* request,
|
|
580
|
+
* }) => {
|
|
581
|
+
* const user = await getUserFromSession(request);
|
|
582
|
+
* context.set(userContext, user);
|
|
583
|
+
* };
|
|
584
|
+
* ```
|
|
585
|
+
*
|
|
586
|
+
* ```tsx filename=app/routes/profile.tsx
|
|
587
|
+
* import { userContext } from "~/context";
|
|
588
|
+
*
|
|
589
|
+
* export async function loader({
|
|
590
|
+
* context,
|
|
591
|
+
* }: Route.LoaderArgs) {
|
|
592
|
+
* const user = context.get(userContext);
|
|
593
|
+
*
|
|
594
|
+
* if (!user) {
|
|
595
|
+
* throw new Response("Unauthorized", { status: 401 });
|
|
596
|
+
* }
|
|
597
|
+
*
|
|
598
|
+
* return { user };
|
|
599
|
+
* }
|
|
600
|
+
* ```
|
|
601
|
+
*
|
|
602
|
+
* @public
|
|
603
|
+
* @category Utils
|
|
604
|
+
* @mode framework
|
|
605
|
+
* @mode data
|
|
606
|
+
* @param defaultValue An optional default value for the context. This value
|
|
607
|
+
* will be returned if no value has been set for this context.
|
|
608
|
+
* @returns A {@link RouterContext} object that can be used with
|
|
609
|
+
* `context.get()` and `context.set()` in [`action`](../../start/framework/route-module#action)s,
|
|
610
|
+
* [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
|
|
611
|
+
*/
|
|
612
|
+
function createContext(defaultValue) {
|
|
613
|
+
return { defaultValue };
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Provides methods for writing/reading values in application context in a
|
|
617
|
+
* type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* import {
|
|
621
|
+
* createContext,
|
|
622
|
+
* RouterContextProvider
|
|
623
|
+
* } from "react-router";
|
|
624
|
+
*
|
|
625
|
+
* const userContext = createContext<User | null>(null);
|
|
626
|
+
* const contextProvider = new RouterContextProvider();
|
|
627
|
+
* contextProvider.set(userContext, getUser());
|
|
628
|
+
* // ^ Type-safe
|
|
629
|
+
* const user = contextProvider.get(userContext);
|
|
630
|
+
* // ^ User
|
|
631
|
+
*
|
|
632
|
+
* @public
|
|
633
|
+
* @category Utils
|
|
634
|
+
* @mode framework
|
|
635
|
+
* @mode data
|
|
636
|
+
*/
|
|
637
|
+
var RouterContextProvider = class {
|
|
638
|
+
#map = /* @__PURE__ */ new Map();
|
|
639
|
+
/**
|
|
640
|
+
* Create a new `RouterContextProvider` instance
|
|
641
|
+
* @param init An optional initial context map to populate the provider with
|
|
642
|
+
*/
|
|
643
|
+
constructor(init) {
|
|
644
|
+
if (init) for (let [context, value] of init) this.set(context, value);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Access a value from the context. If no value has been set for the context,
|
|
648
|
+
* it will return the context's `defaultValue` if provided, or throw an error
|
|
649
|
+
* if no `defaultValue` was set.
|
|
650
|
+
* @param context The context to get the value for
|
|
651
|
+
* @returns The value for the context, or the context's `defaultValue` if no
|
|
652
|
+
* value was set
|
|
653
|
+
*/
|
|
654
|
+
get(context) {
|
|
655
|
+
if (this.#map.has(context)) return this.#map.get(context);
|
|
656
|
+
if (context.defaultValue !== void 0) return context.defaultValue;
|
|
657
|
+
throw new Error("No value found for context");
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Set a value for the context. If the context already has a value set, this
|
|
661
|
+
* will overwrite it.
|
|
662
|
+
*
|
|
663
|
+
* @param context The context to set the value for
|
|
664
|
+
* @param value The value to set for the context
|
|
665
|
+
* @returns {void}
|
|
666
|
+
*/
|
|
667
|
+
set(context, value) {
|
|
668
|
+
this.#map.set(context, value);
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
var unsupportedLazyRouteObjectKeys = /* @__PURE__ */ new Set([
|
|
672
|
+
"lazy",
|
|
673
|
+
"caseSensitive",
|
|
674
|
+
"path",
|
|
675
|
+
"id",
|
|
676
|
+
"index",
|
|
677
|
+
"children",
|
|
678
|
+
"unstable_validateParams"
|
|
679
|
+
]);
|
|
680
|
+
function isUnsupportedLazyRouteObjectKey(key) {
|
|
681
|
+
return unsupportedLazyRouteObjectKeys.has(key);
|
|
682
|
+
}
|
|
683
|
+
var unsupportedLazyRouteFunctionKeys = /* @__PURE__ */ new Set([
|
|
684
|
+
"lazy",
|
|
685
|
+
"caseSensitive",
|
|
686
|
+
"path",
|
|
687
|
+
"id",
|
|
688
|
+
"index",
|
|
689
|
+
"middleware",
|
|
690
|
+
"children",
|
|
691
|
+
"unstable_validateParams"
|
|
692
|
+
]);
|
|
693
|
+
function isUnsupportedLazyRouteFunctionKey(key) {
|
|
694
|
+
return unsupportedLazyRouteFunctionKeys.has(key);
|
|
695
|
+
}
|
|
696
|
+
function isIndexRoute(route) {
|
|
697
|
+
return route.index === true;
|
|
698
|
+
}
|
|
699
|
+
function defaultMapRouteProperties(route) {
|
|
700
|
+
let updates = {};
|
|
701
|
+
if (route.Component) Object.assign(updates, {
|
|
702
|
+
element: import_react.createElement(route.Component),
|
|
703
|
+
Component: void 0
|
|
704
|
+
});
|
|
705
|
+
if (route.HydrateFallback) Object.assign(updates, {
|
|
706
|
+
hydrateFallbackElement: import_react.createElement(route.HydrateFallback),
|
|
707
|
+
HydrateFallback: void 0
|
|
708
|
+
});
|
|
709
|
+
if (route.ErrorBoundary) Object.assign(updates, {
|
|
710
|
+
errorElement: import_react.createElement(route.ErrorBoundary),
|
|
711
|
+
ErrorBoundary: void 0
|
|
712
|
+
});
|
|
713
|
+
return updates;
|
|
714
|
+
}
|
|
715
|
+
function convertRoutesToDataRoutes(routes, mapRouteProperties = defaultMapRouteProperties, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
|
|
716
|
+
return routes.map((route, index) => {
|
|
717
|
+
let treePath = [...parentPath, String(index)];
|
|
718
|
+
let id = typeof route.id === "string" ? route.id : treePath.join("-");
|
|
719
|
+
invariant(route.index !== true || !route.children, `Cannot specify children on an index route`);
|
|
720
|
+
invariant(allowInPlaceMutations || !manifest[id], `Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`);
|
|
721
|
+
if (isIndexRoute(route)) {
|
|
722
|
+
let indexRoute = {
|
|
723
|
+
...route,
|
|
724
|
+
id
|
|
725
|
+
};
|
|
726
|
+
manifest[id] = mergeRouteUpdates(indexRoute, mapRouteProperties(indexRoute));
|
|
727
|
+
return indexRoute;
|
|
728
|
+
} else {
|
|
729
|
+
let pathOrLayoutRoute = {
|
|
730
|
+
...route,
|
|
731
|
+
id,
|
|
732
|
+
children: void 0
|
|
733
|
+
};
|
|
734
|
+
manifest[id] = mergeRouteUpdates(pathOrLayoutRoute, mapRouteProperties(pathOrLayoutRoute));
|
|
735
|
+
if (route.children) pathOrLayoutRoute.children = convertRoutesToDataRoutes(route.children, mapRouteProperties, treePath, manifest, allowInPlaceMutations);
|
|
736
|
+
return pathOrLayoutRoute;
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
function mergeRouteUpdates(route, updates) {
|
|
741
|
+
return Object.assign(route, {
|
|
742
|
+
...updates,
|
|
743
|
+
...typeof updates.lazy === "object" && updates.lazy != null ? { lazy: {
|
|
744
|
+
...route.lazy,
|
|
745
|
+
...updates.lazy
|
|
746
|
+
} } : {}
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Matches the given routes to a location and returns the match data.
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* import { matchRoutes } from "react-router";
|
|
754
|
+
*
|
|
755
|
+
* let routes = [{
|
|
756
|
+
* path: "/",
|
|
757
|
+
* Component: Root,
|
|
758
|
+
* children: [{
|
|
759
|
+
* path: "dashboard",
|
|
760
|
+
* Component: Dashboard,
|
|
761
|
+
* }]
|
|
762
|
+
* }];
|
|
763
|
+
*
|
|
764
|
+
* matchRoutes(routes, "/dashboard"); // [rootMatch, dashboardMatch]
|
|
765
|
+
*
|
|
766
|
+
* @public
|
|
767
|
+
* @category Utils
|
|
768
|
+
* @param routes The array of route objects to match against.
|
|
769
|
+
* @param locationArg The location to match against, either a string path or a
|
|
770
|
+
* partial {@link Location} object
|
|
771
|
+
* @param basename Optional base path to strip from the location before matching.
|
|
772
|
+
* Defaults to `/`.
|
|
773
|
+
* @returns An array of matched routes, or `null` if no matches were found.
|
|
774
|
+
*/
|
|
775
|
+
function matchRoutes(routes, locationArg, basename = "/") {
|
|
776
|
+
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
777
|
+
}
|
|
778
|
+
function matchRoutesImpl(routes, locationArg, basename, allowPartial, precomputedBranches) {
|
|
779
|
+
let pathname = stripBasename((typeof locationArg === "string" ? parsePath(locationArg) : locationArg).pathname || "/", basename);
|
|
780
|
+
if (pathname == null) return null;
|
|
781
|
+
let branches = precomputedBranches ?? flattenAndRankRoutes(routes);
|
|
782
|
+
let matches = null;
|
|
783
|
+
let decoded = decodePath(pathname);
|
|
784
|
+
for (let i = 0; matches == null && i < branches.length; ++i) matches = matchRouteBranch(branches[i], decoded, allowPartial);
|
|
785
|
+
return matches;
|
|
786
|
+
}
|
|
787
|
+
function convertRouteMatchToUiMatch(match, loaderData) {
|
|
788
|
+
let { route, pathname, params } = match;
|
|
789
|
+
return {
|
|
790
|
+
id: route.id,
|
|
791
|
+
pathname,
|
|
792
|
+
params,
|
|
793
|
+
loaderData: loaderData[route.id],
|
|
794
|
+
handle: route.handle
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
function flattenAndRankRoutes(routes) {
|
|
798
|
+
let branches = flattenRoutes(routes);
|
|
799
|
+
rankRouteBranches(branches);
|
|
800
|
+
return branches;
|
|
801
|
+
}
|
|
802
|
+
function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
|
|
803
|
+
let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
|
|
804
|
+
let meta = {
|
|
805
|
+
relativePath: relativePath === void 0 ? route.path || "" : relativePath,
|
|
806
|
+
caseSensitive: route.caseSensitive === true,
|
|
807
|
+
childrenIndex: index,
|
|
808
|
+
route
|
|
809
|
+
};
|
|
810
|
+
if (meta.relativePath.startsWith("/")) {
|
|
811
|
+
if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) return;
|
|
812
|
+
invariant(meta.relativePath.startsWith(parentPath), `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`);
|
|
813
|
+
meta.relativePath = meta.relativePath.slice(parentPath.length);
|
|
814
|
+
}
|
|
815
|
+
let path = joinPaths([parentPath, meta.relativePath]);
|
|
816
|
+
let routesMeta = parentsMeta.concat(meta);
|
|
817
|
+
if (route.children && route.children.length > 0) {
|
|
818
|
+
invariant(route.index !== true, `Index routes must not have child routes. Please remove all child routes from route path "${path}".`);
|
|
819
|
+
flattenRoutes(route.children, branches, routesMeta, path, hasParentOptionalSegments);
|
|
820
|
+
}
|
|
821
|
+
if (route.path == null && !route.index) return;
|
|
822
|
+
branches.push({
|
|
823
|
+
path,
|
|
824
|
+
score: computeScore(path, route.index),
|
|
825
|
+
routesMeta: routesMeta.map((meta, i) => {
|
|
826
|
+
let [matcher, params] = compilePath(meta.relativePath, meta.caseSensitive, i === routesMeta.length - 1);
|
|
827
|
+
return {
|
|
828
|
+
...meta,
|
|
829
|
+
matcher,
|
|
830
|
+
compiledParams: params
|
|
831
|
+
};
|
|
832
|
+
})
|
|
833
|
+
});
|
|
834
|
+
};
|
|
835
|
+
routes.forEach((route, index) => {
|
|
836
|
+
if (route.path === "" || !route.path?.includes("?")) flattenRoute(route, index);
|
|
837
|
+
else for (let exploded of explodeOptionalSegments(route.path)) flattenRoute(route, index, true, exploded);
|
|
838
|
+
});
|
|
839
|
+
return branches;
|
|
840
|
+
}
|
|
841
|
+
function explodeOptionalSegments(path) {
|
|
842
|
+
let segments = path.split("/");
|
|
843
|
+
if (segments.length === 0) return [];
|
|
844
|
+
let [first, ...rest] = segments;
|
|
845
|
+
let isOptional = first.endsWith("?");
|
|
846
|
+
let required = first.replace(/\?$/, "");
|
|
847
|
+
if (rest.length === 0) return isOptional ? [required, ""] : [required];
|
|
848
|
+
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
849
|
+
let result = [];
|
|
850
|
+
result.push(...restExploded.map((subpath) => subpath === "" ? required : [required, subpath].join("/")));
|
|
851
|
+
if (isOptional) result.push(...restExploded);
|
|
852
|
+
return result.map((exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded);
|
|
853
|
+
}
|
|
854
|
+
function rankRouteBranches(branches) {
|
|
855
|
+
branches.sort((a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta) => meta.childrenIndex), b.routesMeta.map((meta) => meta.childrenIndex)));
|
|
856
|
+
}
|
|
857
|
+
var paramRe = /^:[\w-]+$/;
|
|
858
|
+
var partialParamRe = /^:[\w-]+/;
|
|
859
|
+
var partialDynamicSegmentValue = 3.5;
|
|
860
|
+
var dynamicSegmentValue = 3;
|
|
861
|
+
var indexRouteValue = 2;
|
|
862
|
+
var emptySegmentValue = 1;
|
|
863
|
+
var staticSegmentValue = 10;
|
|
864
|
+
var splatPenalty = -2;
|
|
865
|
+
var isSplat = (s) => s === "*";
|
|
866
|
+
function computeScore(path, index) {
|
|
867
|
+
let segments = path.split("/");
|
|
868
|
+
let initialScore = segments.length;
|
|
869
|
+
if (segments.some(isSplat)) initialScore += splatPenalty;
|
|
870
|
+
if (index) initialScore += indexRouteValue;
|
|
871
|
+
return segments.filter((s) => !isSplat(s)).reduce((score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : partialParamRe.test(segment) ? partialDynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore);
|
|
872
|
+
}
|
|
873
|
+
function compareIndexes(a, b) {
|
|
874
|
+
return a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]) ? a[a.length - 1] - b[b.length - 1] : 0;
|
|
875
|
+
}
|
|
876
|
+
function matchRouteBranch(branch, pathname, allowPartial = false) {
|
|
877
|
+
let { routesMeta } = branch;
|
|
878
|
+
let matchedParams = {};
|
|
879
|
+
let matchedPathname = "/";
|
|
880
|
+
let matches = [];
|
|
881
|
+
for (let i = 0; i < routesMeta.length; ++i) {
|
|
882
|
+
let meta = routesMeta[i];
|
|
883
|
+
let end = i === routesMeta.length - 1;
|
|
884
|
+
let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
|
|
885
|
+
let pattern = {
|
|
886
|
+
path: meta.relativePath,
|
|
887
|
+
caseSensitive: meta.caseSensitive,
|
|
888
|
+
end
|
|
889
|
+
};
|
|
890
|
+
let match = meta.matcher && meta.compiledParams ? matchPathImpl(pattern, remainingPathname, meta.matcher, meta.compiledParams) : matchPath(pattern, remainingPathname);
|
|
891
|
+
let route = meta.route;
|
|
892
|
+
if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) match = matchPath({
|
|
893
|
+
path: meta.relativePath,
|
|
894
|
+
caseSensitive: meta.caseSensitive,
|
|
895
|
+
end: false
|
|
896
|
+
}, remainingPathname);
|
|
897
|
+
if (!match) return null;
|
|
898
|
+
Object.assign(matchedParams, match.params);
|
|
899
|
+
matches.push({
|
|
900
|
+
params: matchedParams,
|
|
901
|
+
pathname: joinPaths([matchedPathname, match.pathname]),
|
|
902
|
+
pathnameBase: normalizePathname(joinPaths([matchedPathname, match.pathnameBase])),
|
|
903
|
+
route
|
|
904
|
+
});
|
|
905
|
+
if (match.pathnameBase !== "/") matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
|
|
906
|
+
}
|
|
907
|
+
return matches;
|
|
908
|
+
}
|
|
909
|
+
var MAX_OPTIONAL_PATH_SEGMENTS = 12;
|
|
910
|
+
/**
|
|
911
|
+
* Performs pattern matching on a URL pathname and returns information about
|
|
912
|
+
* the match.
|
|
913
|
+
*
|
|
914
|
+
* Throws if the pattern contains more than 12 optional (`?`) markers.
|
|
915
|
+
*
|
|
916
|
+
* @public
|
|
917
|
+
* @category Utils
|
|
918
|
+
* @param pattern The pattern to match against the URL pathname. This can be a
|
|
919
|
+
* string or a {@link PathPattern} object. If a string is provided, it will be
|
|
920
|
+
* treated as a pattern with `caseSensitive` set to `false` and `end` set to
|
|
921
|
+
* `true`.
|
|
922
|
+
* @param pathname The URL pathname to match against the pattern.
|
|
923
|
+
* @returns A path match object if the pattern matches the pathname,
|
|
924
|
+
* or `null` if it does not match.
|
|
925
|
+
*/
|
|
926
|
+
function matchPath(pattern, pathname) {
|
|
927
|
+
if (typeof pattern === "string") pattern = {
|
|
928
|
+
path: pattern,
|
|
929
|
+
caseSensitive: false,
|
|
930
|
+
end: true
|
|
931
|
+
};
|
|
932
|
+
let { path } = pattern;
|
|
933
|
+
let optionalSegments = 0;
|
|
934
|
+
for (let index = path.indexOf("?"); index !== -1; index = path.indexOf("?", index + 1)) if (++optionalSegments > MAX_OPTIONAL_PATH_SEGMENTS) throw new Error(`Path pattern ${JSON.stringify(path)} exceeds the limit of ${MAX_OPTIONAL_PATH_SEGMENTS} optional segments.`);
|
|
935
|
+
let [matcher, compiledParams] = compilePath(path, pattern.caseSensitive, pattern.end);
|
|
936
|
+
return matchPathImpl(pattern, pathname, matcher, compiledParams);
|
|
937
|
+
}
|
|
938
|
+
function matchPathImpl(pattern, pathname, matcher, compiledParams) {
|
|
939
|
+
let match = pathname.match(matcher);
|
|
940
|
+
if (!match) return null;
|
|
941
|
+
let matchedPathname = match[0];
|
|
942
|
+
let pathnameBase = removeTrailingSlash(matchedPathname, 1);
|
|
943
|
+
let captureGroups = match.slice(1);
|
|
944
|
+
return {
|
|
945
|
+
params: compiledParams.reduce((memo, { paramName, isOptional }, index) => {
|
|
946
|
+
if (paramName === "*") {
|
|
947
|
+
let splatValue = captureGroups[index] || "";
|
|
948
|
+
pathnameBase = removeTrailingSlash(matchedPathname.slice(0, matchedPathname.length - splatValue.length), 1);
|
|
949
|
+
}
|
|
950
|
+
const value = captureGroups[index];
|
|
951
|
+
if (isOptional && !value) memo[paramName] = void 0;
|
|
952
|
+
else memo[paramName] = (value || "").replace(/%2F/g, "/");
|
|
953
|
+
return memo;
|
|
954
|
+
}, {}),
|
|
955
|
+
pathname: matchedPathname,
|
|
956
|
+
pathnameBase,
|
|
957
|
+
pattern
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
function compilePath(path, caseSensitive = false, end = true) {
|
|
961
|
+
warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`);
|
|
962
|
+
let params = [];
|
|
963
|
+
let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (match, paramName, isOptional, index, str) => {
|
|
964
|
+
params.push({
|
|
965
|
+
paramName,
|
|
966
|
+
isOptional: isOptional != null
|
|
967
|
+
});
|
|
968
|
+
if (isOptional) {
|
|
969
|
+
let nextChar = str.charAt(index + match.length);
|
|
970
|
+
if (nextChar && nextChar !== "/") return "/([^\\/]*)";
|
|
971
|
+
return "(?:/([^\\/]*))?";
|
|
972
|
+
}
|
|
973
|
+
return "/([^\\/]+)";
|
|
974
|
+
}).replace(/\/((?:[^/?()[\]*^\\]|\\.)+)\?(?=\/|$|\()/g, "(?:/$1)?");
|
|
975
|
+
if (path.endsWith("*")) {
|
|
976
|
+
params.push({ paramName: "*" });
|
|
977
|
+
regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
|
|
978
|
+
} else if (end) regexpSource += "\\/*$";
|
|
979
|
+
else if (path !== "" && path !== "/") regexpSource += "(?:(?=\\/|$))";
|
|
980
|
+
return [new RegExp(regexpSource, caseSensitive ? void 0 : "i"), params];
|
|
981
|
+
}
|
|
982
|
+
function decodePath(value) {
|
|
983
|
+
try {
|
|
984
|
+
return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
985
|
+
} catch (error) {
|
|
986
|
+
warning(false, `The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`);
|
|
987
|
+
return value;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
function stripBasename(pathname, basename) {
|
|
991
|
+
if (basename === "/") return pathname;
|
|
992
|
+
if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) return null;
|
|
993
|
+
let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
|
|
994
|
+
let nextChar = pathname.charAt(startIndex);
|
|
995
|
+
if (nextChar && nextChar !== "/") return null;
|
|
996
|
+
return pathname.slice(startIndex) || "/";
|
|
997
|
+
}
|
|
998
|
+
function prependBasename({ basename, pathname }) {
|
|
999
|
+
return pathname === "/" ? basename : joinPaths([basename, pathname]);
|
|
1000
|
+
}
|
|
1001
|
+
var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
|
|
1002
|
+
/**
|
|
1003
|
+
* Returns a resolved {@link Path} object relative to the given pathname.
|
|
1004
|
+
*
|
|
1005
|
+
* @public
|
|
1006
|
+
* @category Utils
|
|
1007
|
+
* @param to The path to resolve, either a string or a partial {@link Path}
|
|
1008
|
+
* object.
|
|
1009
|
+
* @param fromPathname The pathname to resolve the path from. Defaults to `/`.
|
|
1010
|
+
* @returns A {@link Path} object with the resolved pathname, search, and hash.
|
|
1011
|
+
*/
|
|
1012
|
+
function resolvePath(to, fromPathname = "/") {
|
|
1013
|
+
let { pathname: toPathname, search = "", hash = "" } = typeof to === "string" ? parsePath(to) : to;
|
|
1014
|
+
let pathname;
|
|
1015
|
+
if (toPathname) {
|
|
1016
|
+
toPathname = removeDoubleSlashes(toPathname);
|
|
1017
|
+
if (toPathname.startsWith("/") || toPathname.startsWith("\\")) pathname = resolvePathname(toPathname.substring(1), "/");
|
|
1018
|
+
else pathname = resolvePathname(toPathname, fromPathname);
|
|
1019
|
+
} else pathname = fromPathname;
|
|
1020
|
+
return {
|
|
1021
|
+
pathname,
|
|
1022
|
+
search: normalizeSearch(search),
|
|
1023
|
+
hash: normalizeHash(hash)
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
function resolvePathname(relativePath, fromPathname) {
|
|
1027
|
+
let segments = removeTrailingSlash(fromPathname).split("/");
|
|
1028
|
+
relativePath.split("/").forEach((segment) => {
|
|
1029
|
+
if (segment === "..") {
|
|
1030
|
+
if (segments.length > 1) segments.pop();
|
|
1031
|
+
} else if (segment !== ".") segments.push(segment);
|
|
1032
|
+
});
|
|
1033
|
+
return segments.length > 1 ? segments.join("/") : "/";
|
|
1034
|
+
}
|
|
1035
|
+
function getInvalidPathError(char, field, dest, path) {
|
|
1036
|
+
return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(path)}]. Please separate it out to the \`to.${dest}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
|
|
1037
|
+
}
|
|
1038
|
+
function getPathContributingMatches(matches) {
|
|
1039
|
+
return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
|
|
1040
|
+
}
|
|
1041
|
+
function getResolveToMatches(matches) {
|
|
1042
|
+
let pathMatches = getPathContributingMatches(matches);
|
|
1043
|
+
return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
|
|
1044
|
+
}
|
|
1045
|
+
function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
|
|
1046
|
+
let to;
|
|
1047
|
+
if (typeof toArg === "string") to = parsePath(toArg);
|
|
1048
|
+
else {
|
|
1049
|
+
to = { ...toArg };
|
|
1050
|
+
invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
|
|
1051
|
+
invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
|
|
1052
|
+
invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
|
|
1053
|
+
}
|
|
1054
|
+
let isEmptyPath = toArg === "" || to.pathname === "";
|
|
1055
|
+
let toPathname = isEmptyPath ? "/" : to.pathname;
|
|
1056
|
+
let from;
|
|
1057
|
+
if (toPathname == null) from = locationPathname;
|
|
1058
|
+
else {
|
|
1059
|
+
let routePathnameIndex = routePathnames.length - 1;
|
|
1060
|
+
if (!isPathRelative && toPathname.startsWith("..")) {
|
|
1061
|
+
let toSegments = toPathname.split("/");
|
|
1062
|
+
while (toSegments[0] === "..") {
|
|
1063
|
+
toSegments.shift();
|
|
1064
|
+
routePathnameIndex -= 1;
|
|
1065
|
+
}
|
|
1066
|
+
to.pathname = toSegments.join("/");
|
|
1067
|
+
}
|
|
1068
|
+
from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
|
|
1069
|
+
}
|
|
1070
|
+
let path = resolvePath(to, from);
|
|
1071
|
+
let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
|
|
1072
|
+
let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
|
|
1073
|
+
if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) path.pathname += "/";
|
|
1074
|
+
return path;
|
|
1075
|
+
}
|
|
1076
|
+
var removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
|
|
1077
|
+
var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
|
|
1078
|
+
function removeTrailingSlash(path, minLength = 0) {
|
|
1079
|
+
let end = path.length;
|
|
1080
|
+
while (end > minLength && path.charCodeAt(end - 1) === 47) end--;
|
|
1081
|
+
return end === path.length ? path : path.slice(0, end);
|
|
1082
|
+
}
|
|
1083
|
+
var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
|
|
1084
|
+
var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
|
1085
|
+
var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
1086
|
+
/**
|
|
1087
|
+
* A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
|
|
1088
|
+
* Sets the status code and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
|
|
1089
|
+
* header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
|
|
1090
|
+
*
|
|
1091
|
+
* This utility accepts absolute URLs and can navigate to external domains, so
|
|
1092
|
+
* the application should validate any user-supplied inputs to redirects.
|
|
1093
|
+
*
|
|
1094
|
+
* @example
|
|
1095
|
+
* import { redirect } from "react-router";
|
|
1096
|
+
*
|
|
1097
|
+
* export async function loader({ request }: Route.LoaderArgs) {
|
|
1098
|
+
* if (!isLoggedIn(request))
|
|
1099
|
+
* throw redirect("/login");
|
|
1100
|
+
* }
|
|
1101
|
+
*
|
|
1102
|
+
* // ...
|
|
1103
|
+
* }
|
|
1104
|
+
*
|
|
1105
|
+
* @public
|
|
1106
|
+
* @category Utils
|
|
1107
|
+
* @mode framework
|
|
1108
|
+
* @mode data
|
|
1109
|
+
* @param url The URL to redirect to.
|
|
1110
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
1111
|
+
* response.
|
|
1112
|
+
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
1113
|
+
* object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
|
|
1114
|
+
* header.
|
|
1115
|
+
*/
|
|
1116
|
+
var redirect = (url, init = 302) => {
|
|
1117
|
+
validateDocumentNavigationTarget(url);
|
|
1118
|
+
let responseInit = init;
|
|
1119
|
+
if (typeof responseInit === "number") responseInit = { status: responseInit };
|
|
1120
|
+
let headers = new Headers(responseInit.headers);
|
|
1121
|
+
headers.set("Location", url);
|
|
1122
|
+
if (typeof responseInit.status === "undefined") responseInit = {
|
|
1123
|
+
...responseInit,
|
|
1124
|
+
status: 302
|
|
1125
|
+
};
|
|
1126
|
+
return new Response(null, {
|
|
1127
|
+
...responseInit,
|
|
1128
|
+
headers
|
|
1129
|
+
});
|
|
1130
|
+
};
|
|
1131
|
+
/**
|
|
1132
|
+
* A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
1133
|
+
* that will force a document reload to the new location. Sets the status code
|
|
1134
|
+
* and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
|
|
1135
|
+
* header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
|
|
1136
|
+
*
|
|
1137
|
+
* This utility accepts absolute URLs and can navigate to external domains, so
|
|
1138
|
+
* the application should validate any user-supplied inputs to redirects.
|
|
1139
|
+
*
|
|
1140
|
+
* ```tsx filename=routes/logout.tsx
|
|
1141
|
+
* import { redirectDocument } from "react-router";
|
|
1142
|
+
*
|
|
1143
|
+
* import { destroySession } from "../sessions.server";
|
|
1144
|
+
*
|
|
1145
|
+
* export async function action({ request }: Route.ActionArgs) {
|
|
1146
|
+
* let session = await getSession(request.headers.get("Cookie"));
|
|
1147
|
+
* return redirectDocument("/", {
|
|
1148
|
+
* headers: { "Set-Cookie": await destroySession(session) }
|
|
1149
|
+
* });
|
|
1150
|
+
* }
|
|
1151
|
+
* ```
|
|
1152
|
+
*
|
|
1153
|
+
* @public
|
|
1154
|
+
* @category Utils
|
|
1155
|
+
* @mode framework
|
|
1156
|
+
* @mode data
|
|
1157
|
+
* @param url The URL to redirect to.
|
|
1158
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
1159
|
+
* response.
|
|
1160
|
+
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
1161
|
+
* object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
|
|
1162
|
+
* header.
|
|
1163
|
+
*/
|
|
1164
|
+
var redirectDocument = (url, init) => {
|
|
1165
|
+
let response = redirect(url, init);
|
|
1166
|
+
response.headers.set("X-Remix-Reload-Document", "true");
|
|
1167
|
+
return response;
|
|
1168
|
+
};
|
|
1169
|
+
/**
|
|
1170
|
+
* A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
1171
|
+
* that will perform a [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState)
|
|
1172
|
+
* instead of a [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
|
|
1173
|
+
* for client-side navigation redirects. Sets the status code and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
|
|
1174
|
+
* header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
* import { replace } from "react-router";
|
|
1178
|
+
*
|
|
1179
|
+
* export async function loader() {
|
|
1180
|
+
* return replace("/new-location");
|
|
1181
|
+
* }
|
|
1182
|
+
*
|
|
1183
|
+
* @public
|
|
1184
|
+
* @category Utils
|
|
1185
|
+
* @mode framework
|
|
1186
|
+
* @mode data
|
|
1187
|
+
* @param url The URL to redirect to.
|
|
1188
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
1189
|
+
* response.
|
|
1190
|
+
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
1191
|
+
* object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
|
|
1192
|
+
* header.
|
|
1193
|
+
*/
|
|
1194
|
+
var replace = (url, init) => {
|
|
1195
|
+
let response = redirect(url, init);
|
|
1196
|
+
response.headers.set("X-Remix-Replace", "true");
|
|
1197
|
+
return response;
|
|
1198
|
+
};
|
|
1199
|
+
var SUPPORTED_ERROR_TYPES = [
|
|
1200
|
+
"EvalError",
|
|
1201
|
+
"RangeError",
|
|
1202
|
+
"ReferenceError",
|
|
1203
|
+
"SyntaxError",
|
|
1204
|
+
"TypeError",
|
|
1205
|
+
"URIError"
|
|
1206
|
+
];
|
|
1207
|
+
var ErrorResponseImpl = class {
|
|
1208
|
+
status;
|
|
1209
|
+
statusText;
|
|
1210
|
+
data;
|
|
1211
|
+
error;
|
|
1212
|
+
internal;
|
|
1213
|
+
constructor(status, statusText, data, internal = false) {
|
|
1214
|
+
this.status = status;
|
|
1215
|
+
this.statusText = statusText || "";
|
|
1216
|
+
this.internal = internal;
|
|
1217
|
+
if (data instanceof Error) {
|
|
1218
|
+
this.data = data.toString();
|
|
1219
|
+
this.error = data;
|
|
1220
|
+
} else this.data = data;
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
/**
|
|
1224
|
+
* Check if the given error is an {@link ErrorResponse} generated from a 4xx/5xx
|
|
1225
|
+
* [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
1226
|
+
* thrown from an [`action`](../../start/framework/route-module#action) or
|
|
1227
|
+
* [`loader`](../../start/framework/route-module#loader) function.
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* import { isRouteErrorResponse } from "react-router";
|
|
1231
|
+
*
|
|
1232
|
+
* export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
|
|
1233
|
+
* if (isRouteErrorResponse(error)) {
|
|
1234
|
+
* return (
|
|
1235
|
+
* <>
|
|
1236
|
+
* <p>Error: `${error.status}: ${error.statusText}`</p>
|
|
1237
|
+
* <p>{error.data}</p>
|
|
1238
|
+
* </>
|
|
1239
|
+
* );
|
|
1240
|
+
* }
|
|
1241
|
+
*
|
|
1242
|
+
* return (
|
|
1243
|
+
* <p>Error: {error instanceof Error ? error.message : "Unknown Error"}</p>
|
|
1244
|
+
* );
|
|
1245
|
+
* }
|
|
1246
|
+
*
|
|
1247
|
+
* @public
|
|
1248
|
+
* @category Utils
|
|
1249
|
+
* @mode framework
|
|
1250
|
+
* @mode data
|
|
1251
|
+
* @param error The error to check.
|
|
1252
|
+
* @returns `true` if the error is an {@link ErrorResponse}, `false` otherwise.
|
|
1253
|
+
*/
|
|
1254
|
+
function isRouteErrorResponse(error) {
|
|
1255
|
+
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
1256
|
+
}
|
|
1257
|
+
function getRoutePattern(matches) {
|
|
1258
|
+
return joinPaths(matches.map((m) => m.route.path).filter(Boolean)) || "/";
|
|
1259
|
+
}
|
|
1260
|
+
function createDataFunctionUrl(request, path) {
|
|
1261
|
+
let url = new URL(typeof request === "string" || request instanceof URL ? request : request.url);
|
|
1262
|
+
let parsed = typeof path === "string" ? parsePath(path) : path;
|
|
1263
|
+
url.pathname = parsed.pathname || "/";
|
|
1264
|
+
if (parsed.search) {
|
|
1265
|
+
let searchParams = new URLSearchParams(parsed.search);
|
|
1266
|
+
let indexValues = searchParams.getAll("index");
|
|
1267
|
+
searchParams.delete("index");
|
|
1268
|
+
for (let value of indexValues.filter(Boolean)) searchParams.append("index", value);
|
|
1269
|
+
let search = searchParams.toString();
|
|
1270
|
+
url.search = search ? `?${search}` : "";
|
|
1271
|
+
} else url.search = "";
|
|
1272
|
+
url.hash = parsed.hash || "";
|
|
1273
|
+
return url;
|
|
1274
|
+
}
|
|
1275
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
1276
|
+
function parseToInfo(_to, basename) {
|
|
1277
|
+
let to = _to;
|
|
1278
|
+
if (typeof to !== "string" || !ABSOLUTE_URL_REGEX.test(to)) return {
|
|
1279
|
+
absoluteURL: void 0,
|
|
1280
|
+
isExternal: false,
|
|
1281
|
+
to
|
|
1282
|
+
};
|
|
1283
|
+
let absoluteURL = to;
|
|
1284
|
+
let isExternal = false;
|
|
1285
|
+
if (isBrowser) try {
|
|
1286
|
+
let currentUrl = new URL(window.location.href);
|
|
1287
|
+
let targetUrl = PROTOCOL_RELATIVE_URL_REGEX.test(to) ? new URL(normalizeProtocolRelativeUrl(to, currentUrl.protocol)) : new URL(to);
|
|
1288
|
+
let path = stripBasename(targetUrl.pathname, basename);
|
|
1289
|
+
if (targetUrl.origin === currentUrl.origin && path != null) to = path + targetUrl.search + targetUrl.hash;
|
|
1290
|
+
else isExternal = true;
|
|
1291
|
+
} catch {
|
|
1292
|
+
warning(false, `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`);
|
|
1293
|
+
}
|
|
1294
|
+
return {
|
|
1295
|
+
absoluteURL,
|
|
1296
|
+
isExternal,
|
|
1297
|
+
to
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/router/instrumentation.js
|
|
1301
|
+
/**
|
|
1302
|
+
* react-router v8.5.3
|
|
1303
|
+
*
|
|
1304
|
+
* Copyright (c) Remix Software Inc.
|
|
1305
|
+
*
|
|
1306
|
+
* This source code is licensed under the MIT license found in the
|
|
1307
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
1308
|
+
*
|
|
1309
|
+
* @license MIT
|
|
1310
|
+
*/
|
|
1311
|
+
var UninstrumentedSymbol = Symbol("Uninstrumented");
|
|
1312
|
+
var instrumentationResultMetaContext = createContext();
|
|
1313
|
+
function getRouteInstrumentationUpdates(fns, route) {
|
|
1314
|
+
let aggregated = {
|
|
1315
|
+
lazy: [],
|
|
1316
|
+
"lazy.loader": [],
|
|
1317
|
+
"lazy.action": [],
|
|
1318
|
+
"lazy.middleware": [],
|
|
1319
|
+
middleware: [],
|
|
1320
|
+
loader: [],
|
|
1321
|
+
action: []
|
|
1322
|
+
};
|
|
1323
|
+
fns.forEach((fn) => fn({
|
|
1324
|
+
id: route.id,
|
|
1325
|
+
index: route.index,
|
|
1326
|
+
path: route.path,
|
|
1327
|
+
instrument(i) {
|
|
1328
|
+
if (i.lazy != null) aggregated.lazy.push(i.lazy);
|
|
1329
|
+
if (i["lazy.loader"] != null) aggregated["lazy.loader"].push(i["lazy.loader"]);
|
|
1330
|
+
if (i["lazy.action"] != null) aggregated["lazy.action"].push(i["lazy.action"]);
|
|
1331
|
+
if (i["lazy.middleware"] != null) aggregated["lazy.middleware"].push(i["lazy.middleware"]);
|
|
1332
|
+
if (i.middleware != null) aggregated.middleware.push(i.middleware);
|
|
1333
|
+
if (i.loader != null) aggregated.loader.push(i.loader);
|
|
1334
|
+
if (i.action != null) aggregated.action.push(i.action);
|
|
1335
|
+
}
|
|
1336
|
+
}));
|
|
1337
|
+
let updates = {};
|
|
1338
|
+
if (typeof route.lazy === "function" && aggregated.lazy.length > 0) {
|
|
1339
|
+
let lazy = route.lazy;
|
|
1340
|
+
updates.lazy = async (...args) => {
|
|
1341
|
+
return throwOrReturnResult(await recurseRight(aggregated.lazy, void 0, () => lazy(...args), getInstrumentationInnerResult));
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
if (typeof route.lazy === "object") {
|
|
1345
|
+
let lazyObject = route.lazy;
|
|
1346
|
+
if (typeof lazyObject.middleware === "function" && aggregated["lazy.middleware"].length > 0) {
|
|
1347
|
+
let middleware = lazyObject.middleware;
|
|
1348
|
+
updates.lazy = Object.assign(updates.lazy || {}, { middleware: async (...args) => {
|
|
1349
|
+
return throwOrReturnResult(await recurseRight(aggregated["lazy.middleware"], void 0, () => middleware(...args), getInstrumentationInnerResult));
|
|
1350
|
+
} });
|
|
1351
|
+
}
|
|
1352
|
+
if (typeof lazyObject.loader === "function" && aggregated["lazy.loader"].length > 0) {
|
|
1353
|
+
let loader = lazyObject.loader;
|
|
1354
|
+
updates.lazy = Object.assign(updates.lazy || {}, { loader: async (...args) => {
|
|
1355
|
+
return throwOrReturnResult(await recurseRight(aggregated["lazy.loader"], void 0, () => loader(...args), getInstrumentationInnerResult));
|
|
1356
|
+
} });
|
|
1357
|
+
}
|
|
1358
|
+
if (typeof lazyObject.action === "function" && aggregated["lazy.action"].length > 0) {
|
|
1359
|
+
let action = lazyObject.action;
|
|
1360
|
+
updates.lazy = Object.assign(updates.lazy || {}, { action: async (...args) => {
|
|
1361
|
+
return throwOrReturnResult(await recurseRight(aggregated["lazy.action"], void 0, () => action(...args), getInstrumentationInnerResult));
|
|
1362
|
+
} });
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
if (typeof route.loader === "function" && aggregated.loader.length > 0) {
|
|
1366
|
+
let original = getUninstrumentedHandler(route.loader);
|
|
1367
|
+
let instrumented = async (...args) => {
|
|
1368
|
+
return throwOrReturnResult(await recurseRight(aggregated.loader, getHandlerInfo(args[0]), () => original(...args), getInstrumentationInnerResult));
|
|
1369
|
+
};
|
|
1370
|
+
if (original.hydrate === true) instrumented.hydrate = true;
|
|
1371
|
+
setUninstrumentedHandler(instrumented, original);
|
|
1372
|
+
updates.loader = instrumented;
|
|
1373
|
+
}
|
|
1374
|
+
if (typeof route.action === "function" && aggregated.action.length > 0) {
|
|
1375
|
+
let original = getUninstrumentedHandler(route.action);
|
|
1376
|
+
let instrumented = async (...args) => {
|
|
1377
|
+
return throwOrReturnResult(await recurseRight(aggregated.action, getHandlerInfo(args[0]), () => original(...args), getInstrumentationInnerResult));
|
|
1378
|
+
};
|
|
1379
|
+
setUninstrumentedHandler(instrumented, original);
|
|
1380
|
+
updates.action = instrumented;
|
|
1381
|
+
}
|
|
1382
|
+
if (route.middleware && route.middleware.length > 0 && aggregated.middleware.length > 0) updates.middleware = route.middleware.map((middleware) => {
|
|
1383
|
+
let original = getUninstrumentedHandler(middleware);
|
|
1384
|
+
let instrumented = async (...args) => {
|
|
1385
|
+
return throwOrReturnResult(await recurseRight(aggregated.middleware, getHandlerInfo(args[0]), () => original(...args), getInstrumentationInnerResult));
|
|
1386
|
+
};
|
|
1387
|
+
setUninstrumentedHandler(instrumented, original);
|
|
1388
|
+
return instrumented;
|
|
1389
|
+
});
|
|
1390
|
+
return updates;
|
|
1391
|
+
}
|
|
1392
|
+
function instrumentHandler(handler, fns) {
|
|
1393
|
+
let aggregated = { request: [] };
|
|
1394
|
+
fns.forEach((fn) => fn({ instrument(i) {
|
|
1395
|
+
if (i.request != null) aggregated.request.push(i.request);
|
|
1396
|
+
} }));
|
|
1397
|
+
let instrumentedHandler = handler;
|
|
1398
|
+
if (aggregated.request.length > 0) instrumentedHandler = async (...args) => {
|
|
1399
|
+
let [request, context] = args;
|
|
1400
|
+
let instrumentationContext = context ?? new RouterContextProvider();
|
|
1401
|
+
return throwOrReturnResult(await recurseRight(aggregated.request, {
|
|
1402
|
+
request: getReadonlyRequest(request),
|
|
1403
|
+
context: getReadonlyContext(instrumentationContext)
|
|
1404
|
+
}, () => handler(request, instrumentationContext), (result, info) => {
|
|
1405
|
+
let meta;
|
|
1406
|
+
try {
|
|
1407
|
+
meta = info.context?.get(instrumentationResultMetaContext);
|
|
1408
|
+
} catch {}
|
|
1409
|
+
invariant(result.value instanceof Response, "Expected a Response from the request handler");
|
|
1410
|
+
return {
|
|
1411
|
+
...getInstrumentationInnerResult(result),
|
|
1412
|
+
statusCode: result.value.status,
|
|
1413
|
+
meta
|
|
1414
|
+
};
|
|
1415
|
+
}));
|
|
1416
|
+
};
|
|
1417
|
+
return instrumentedHandler;
|
|
1418
|
+
}
|
|
1419
|
+
function getUninstrumentedHandler(handler) {
|
|
1420
|
+
return handler[UninstrumentedSymbol] ?? handler;
|
|
1421
|
+
}
|
|
1422
|
+
function setUninstrumentedHandler(handler, uninstrumentedHandler) {
|
|
1423
|
+
handler[UninstrumentedSymbol] = uninstrumentedHandler;
|
|
1424
|
+
}
|
|
1425
|
+
function throwOrReturnResult(result) {
|
|
1426
|
+
if (result.type === "error") throw result.value;
|
|
1427
|
+
return result.value;
|
|
1428
|
+
}
|
|
1429
|
+
async function recurseRight(impls, info, handler, getInnerResult, state = {
|
|
1430
|
+
result: null,
|
|
1431
|
+
innerResult: null
|
|
1432
|
+
}, index = impls.length - 1) {
|
|
1433
|
+
let impl = impls[index];
|
|
1434
|
+
if (!impl) {
|
|
1435
|
+
try {
|
|
1436
|
+
state.result = {
|
|
1437
|
+
type: "success",
|
|
1438
|
+
value: await handler()
|
|
1439
|
+
};
|
|
1440
|
+
} catch (e) {
|
|
1441
|
+
state.result = {
|
|
1442
|
+
type: "error",
|
|
1443
|
+
value: e
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
state.innerResult = getInnerResult(state.result, info);
|
|
1447
|
+
} else {
|
|
1448
|
+
let handlerPromise = void 0;
|
|
1449
|
+
let callHandler = async () => {
|
|
1450
|
+
if (handlerPromise) console.error("You cannot call instrumented handlers more than once");
|
|
1451
|
+
else handlerPromise = recurseRight(impls, info, handler, getInnerResult, state, index - 1);
|
|
1452
|
+
await handlerPromise;
|
|
1453
|
+
invariant(state.innerResult, "Expected an inner result");
|
|
1454
|
+
return state.innerResult;
|
|
1455
|
+
};
|
|
1456
|
+
try {
|
|
1457
|
+
await impl(callHandler, info);
|
|
1458
|
+
} catch (e) {
|
|
1459
|
+
console.error("An instrumentation function threw an error:", e);
|
|
1460
|
+
}
|
|
1461
|
+
if (!handlerPromise) await callHandler();
|
|
1462
|
+
await handlerPromise;
|
|
1463
|
+
}
|
|
1464
|
+
if (state.result) return state.result;
|
|
1465
|
+
state.result = {
|
|
1466
|
+
type: "error",
|
|
1467
|
+
value: /* @__PURE__ */ new Error("No result assigned in instrumentation chain.")
|
|
1468
|
+
};
|
|
1469
|
+
state.innerResult = getInnerResult(state.result, info);
|
|
1470
|
+
return state.result;
|
|
1471
|
+
}
|
|
1472
|
+
function getInstrumentationInnerResult(result) {
|
|
1473
|
+
if (result.type === "error" && result.value instanceof Error) return {
|
|
1474
|
+
status: "error",
|
|
1475
|
+
error: result.value
|
|
1476
|
+
};
|
|
1477
|
+
return {
|
|
1478
|
+
status: "success",
|
|
1479
|
+
error: void 0
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
function getHandlerInfo(args) {
|
|
1483
|
+
let { request, context, params } = args;
|
|
1484
|
+
return {
|
|
1485
|
+
...args,
|
|
1486
|
+
request: getReadonlyRequest(request),
|
|
1487
|
+
params: { ...params },
|
|
1488
|
+
context: getReadonlyContext(context)
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
function getReadonlyRequest(request) {
|
|
1492
|
+
return {
|
|
1493
|
+
method: request.method,
|
|
1494
|
+
url: request.url,
|
|
1495
|
+
headers: { get: (...args) => request.headers.get(...args) }
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
function getReadonlyContext(context) {
|
|
1499
|
+
return { get: (ctx) => context.get(ctx) };
|
|
1500
|
+
}
|
|
1501
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/router/matcher.js
|
|
1502
|
+
/**
|
|
1503
|
+
* react-router v8.5.3
|
|
1504
|
+
*
|
|
1505
|
+
* Copyright (c) Remix Software Inc.
|
|
1506
|
+
*
|
|
1507
|
+
* This source code is licensed under the MIT license found in the
|
|
1508
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
1509
|
+
*
|
|
1510
|
+
* @license MIT
|
|
1511
|
+
*/
|
|
1512
|
+
var V6RegExMatcher = class {
|
|
1513
|
+
#routes = [];
|
|
1514
|
+
#branches = [];
|
|
1515
|
+
#basename;
|
|
1516
|
+
#matchCost = 0;
|
|
1517
|
+
constructor(basename) {
|
|
1518
|
+
this.#basename = basename;
|
|
1519
|
+
}
|
|
1520
|
+
update(routes) {
|
|
1521
|
+
this.#routes = routes;
|
|
1522
|
+
this.#branches = flattenAndRankRoutes(routes);
|
|
1523
|
+
this.#matchCost = this.#branches.reduce((total, branch) => total + branch.routesMeta.length, 0);
|
|
1524
|
+
}
|
|
1525
|
+
get matchCost() {
|
|
1526
|
+
return this.#matchCost;
|
|
1527
|
+
}
|
|
1528
|
+
match(locationArg, allowPartial = false) {
|
|
1529
|
+
return matchRoutesImpl(this.#routes, locationArg, this.#basename, allowPartial, this.#branches);
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
/**
|
|
1533
|
+
* react-router v8.5.3
|
|
1534
|
+
*
|
|
1535
|
+
* Copyright (c) Remix Software Inc.
|
|
1536
|
+
*
|
|
1537
|
+
* This source code is licensed under the MIT license found in the
|
|
1538
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
1539
|
+
*
|
|
1540
|
+
* @license MIT
|
|
1541
|
+
*/
|
|
1542
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/router/router.js
|
|
1543
|
+
/**
|
|
1544
|
+
* react-router v8.5.3
|
|
1545
|
+
*
|
|
1546
|
+
* Copyright (c) Remix Software Inc.
|
|
1547
|
+
*
|
|
1548
|
+
* This source code is licensed under the MIT license found in the
|
|
1549
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
1550
|
+
*
|
|
1551
|
+
* @license MIT
|
|
1552
|
+
*/
|
|
1553
|
+
var validMutationMethodsArr = [
|
|
1554
|
+
"POST",
|
|
1555
|
+
"PUT",
|
|
1556
|
+
"PATCH",
|
|
1557
|
+
"DELETE"
|
|
1558
|
+
];
|
|
1559
|
+
var validMutationMethods = new Set(validMutationMethodsArr);
|
|
1560
|
+
var validRequestMethodsArr = ["GET", ...validMutationMethodsArr];
|
|
1561
|
+
var validRequestMethods = new Set(validRequestMethodsArr);
|
|
1562
|
+
var redirectStatusCodes = /* @__PURE__ */ new Set([
|
|
1563
|
+
301,
|
|
1564
|
+
302,
|
|
1565
|
+
303,
|
|
1566
|
+
307,
|
|
1567
|
+
308
|
|
1568
|
+
]);
|
|
1569
|
+
var IDLE_NAVIGATION = {
|
|
1570
|
+
state: "idle",
|
|
1571
|
+
location: void 0,
|
|
1572
|
+
matches: void 0,
|
|
1573
|
+
historyAction: void 0,
|
|
1574
|
+
formMethod: void 0,
|
|
1575
|
+
formAction: void 0,
|
|
1576
|
+
formEncType: void 0,
|
|
1577
|
+
formData: void 0,
|
|
1578
|
+
json: void 0,
|
|
1579
|
+
text: void 0
|
|
1580
|
+
};
|
|
1581
|
+
var IDLE_FETCHER = {
|
|
1582
|
+
state: "idle",
|
|
1583
|
+
data: void 0,
|
|
1584
|
+
formMethod: void 0,
|
|
1585
|
+
formAction: void 0,
|
|
1586
|
+
formEncType: void 0,
|
|
1587
|
+
formData: void 0,
|
|
1588
|
+
json: void 0,
|
|
1589
|
+
text: void 0
|
|
1590
|
+
};
|
|
1591
|
+
var IDLE_BLOCKER = {
|
|
1592
|
+
state: "unblocked",
|
|
1593
|
+
proceed: void 0,
|
|
1594
|
+
reset: void 0,
|
|
1595
|
+
location: void 0
|
|
1596
|
+
};
|
|
1597
|
+
var ResetLoaderDataSymbol = Symbol("ResetLoaderData");
|
|
1598
|
+
function createDataRouteMatcher(future, basename) {
|
|
1599
|
+
if (future.unstable_routePatternMatching) {
|
|
1600
|
+
let RoutePatternMatcher = void 0;
|
|
1601
|
+
invariant(RoutePatternMatcher, "You must call unstable_preloadRoutePattern() from \"react-router/route-pattern\" before enabling future.unstable_routePatternMatching.");
|
|
1602
|
+
return new RoutePatternMatcher(basename);
|
|
1603
|
+
}
|
|
1604
|
+
return new V6RegExMatcher(basename);
|
|
1605
|
+
}
|
|
1606
|
+
/**
|
|
1607
|
+
* Create a static handler to perform server-side data loading
|
|
1608
|
+
*
|
|
1609
|
+
* @example
|
|
1610
|
+
* export async function handleRequest(request: Request) {
|
|
1611
|
+
* let { query, dataRoutes } = createStaticHandler(routes);
|
|
1612
|
+
* let context = await query(request);
|
|
1613
|
+
*
|
|
1614
|
+
* if (context instanceof Response) {
|
|
1615
|
+
* return context;
|
|
1616
|
+
* }
|
|
1617
|
+
*
|
|
1618
|
+
* let router = createStaticRouter(dataRoutes, context);
|
|
1619
|
+
* return new Response(
|
|
1620
|
+
* ReactDOMServer.renderToString(<StaticRouterProvider ... />),
|
|
1621
|
+
* { headers: { "Content-Type": "text/html" } }
|
|
1622
|
+
* );
|
|
1623
|
+
* }
|
|
1624
|
+
*
|
|
1625
|
+
* @public
|
|
1626
|
+
* @category Data Routers
|
|
1627
|
+
* @mode data
|
|
1628
|
+
* @param routes The {@link RouteObject | route objects} to create a static
|
|
1629
|
+
* handler for
|
|
1630
|
+
* @param opts Options
|
|
1631
|
+
* @param opts.basename The base URL for the static handler (default: `/`)
|
|
1632
|
+
* @param opts.future Future flags for the static handler
|
|
1633
|
+
* @returns A static handler that can be used to query data for the provided
|
|
1634
|
+
* routes
|
|
1635
|
+
*/
|
|
1636
|
+
function createStaticHandler(routes, opts) {
|
|
1637
|
+
invariant(routes.length > 0, "You must provide a non-empty routes array to createStaticHandler");
|
|
1638
|
+
let manifest = {};
|
|
1639
|
+
let basename = (opts ? opts.basename : null) || "/";
|
|
1640
|
+
let _mapRouteProperties = opts?.mapRouteProperties;
|
|
1641
|
+
let mapRouteProperties = _mapRouteProperties ? _mapRouteProperties : () => ({});
|
|
1642
|
+
let dataRouteMatcher = createDataRouteMatcher({ ...opts?.future }, basename);
|
|
1643
|
+
if (opts?.instrumentations) {
|
|
1644
|
+
let instrumentations = opts.instrumentations;
|
|
1645
|
+
mapRouteProperties = (route) => {
|
|
1646
|
+
return {
|
|
1647
|
+
..._mapRouteProperties?.(route),
|
|
1648
|
+
...getRouteInstrumentationUpdates(instrumentations.map((i) => i.route).filter(Boolean), route)
|
|
1649
|
+
};
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, void 0, manifest);
|
|
1653
|
+
dataRouteMatcher.update(dataRoutes);
|
|
1654
|
+
let match = (locationArg) => dataRouteMatcher.match(locationArg);
|
|
1655
|
+
/**
|
|
1656
|
+
* The query() method is intended for document requests, in which we want to
|
|
1657
|
+
* call an optional action and potentially multiple loaders for all nested
|
|
1658
|
+
* routes. It returns a StaticHandlerContext object, which is very similar
|
|
1659
|
+
* to the router state (location, loaderData, actionData, errors, etc.) and
|
|
1660
|
+
* also adds SSR-specific information such as the statusCode and headers
|
|
1661
|
+
* from action/loaders Responses.
|
|
1662
|
+
*
|
|
1663
|
+
* It _should_ never throw and should report all errors through the
|
|
1664
|
+
* returned handlerContext.errors object, properly associating errors to
|
|
1665
|
+
* their error boundary. Additionally, it tracks _deepestRenderedBoundaryId
|
|
1666
|
+
* which can be used to emulate React error boundaries during SSR by performing
|
|
1667
|
+
* a second pass only down to the boundaryId.
|
|
1668
|
+
*
|
|
1669
|
+
* The one exception where we do not return a StaticHandlerContext is when a
|
|
1670
|
+
* redirect response is returned or thrown from any action/loader. We
|
|
1671
|
+
* propagate that out and return the raw Response so the HTTP server can
|
|
1672
|
+
* return it directly.
|
|
1673
|
+
*
|
|
1674
|
+
* - `opts.requestContext` is an optional server context that will be passed
|
|
1675
|
+
* to actions/loaders in the `context` parameter
|
|
1676
|
+
* - `opts.skipLoaderErrorBubbling` is an optional parameter that will prevent
|
|
1677
|
+
* the bubbling of errors which allows single-fetch-type implementations
|
|
1678
|
+
* where the client will handle the bubbling and we may need to return data
|
|
1679
|
+
* for the handling route
|
|
1680
|
+
*/
|
|
1681
|
+
async function query(request, { requestContext, filterMatchesToLoad, skipLoaderErrorBubbling, skipRevalidation, dataStrategy, generateMiddlewareResponse, normalizePath } = {}) {
|
|
1682
|
+
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
1683
|
+
let method = request.method;
|
|
1684
|
+
let location = createLocation("", normalizePathImpl(request), null, "default");
|
|
1685
|
+
let matches = dataRouteMatcher.match(location);
|
|
1686
|
+
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
1687
|
+
if (!isValidMethod(method) && method !== "HEAD") {
|
|
1688
|
+
let error = getInternalRouterError(405, { method });
|
|
1689
|
+
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
1690
|
+
let staticContext = {
|
|
1691
|
+
basename,
|
|
1692
|
+
location,
|
|
1693
|
+
matches: methodNotAllowedMatches,
|
|
1694
|
+
loaderData: {},
|
|
1695
|
+
actionData: null,
|
|
1696
|
+
errors: { [route.id]: error },
|
|
1697
|
+
statusCode: error.status,
|
|
1698
|
+
loaderHeaders: {},
|
|
1699
|
+
actionHeaders: {},
|
|
1700
|
+
_match: match
|
|
1701
|
+
};
|
|
1702
|
+
return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
|
|
1703
|
+
} else if (!matches) {
|
|
1704
|
+
let error = getInternalRouterError(404, { pathname: location.pathname });
|
|
1705
|
+
let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
1706
|
+
let staticContext = {
|
|
1707
|
+
basename,
|
|
1708
|
+
location,
|
|
1709
|
+
matches: notFoundMatches,
|
|
1710
|
+
loaderData: {},
|
|
1711
|
+
actionData: null,
|
|
1712
|
+
errors: { [route.id]: error },
|
|
1713
|
+
statusCode: error.status,
|
|
1714
|
+
loaderHeaders: {},
|
|
1715
|
+
actionHeaders: {},
|
|
1716
|
+
_match: match
|
|
1717
|
+
};
|
|
1718
|
+
return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
|
|
1719
|
+
}
|
|
1720
|
+
if (generateMiddlewareResponse) {
|
|
1721
|
+
invariant(requestContext instanceof RouterContextProvider, "When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");
|
|
1722
|
+
try {
|
|
1723
|
+
await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties);
|
|
1724
|
+
let renderedStaticContext;
|
|
1725
|
+
let response = await runServerMiddlewarePipeline({
|
|
1726
|
+
request,
|
|
1727
|
+
url: createDataFunctionUrl(request, location),
|
|
1728
|
+
pattern: getRoutePattern(matches),
|
|
1729
|
+
matches,
|
|
1730
|
+
params: matches[0].params,
|
|
1731
|
+
context: requestContext
|
|
1732
|
+
}, async () => {
|
|
1733
|
+
return await generateMiddlewareResponse(async (revalidationRequest, opts = {}) => {
|
|
1734
|
+
let result = await queryImpl(revalidationRequest, location, matches, requestContext, dataStrategy || null, skipLoaderErrorBubbling === true, null, "filterMatchesToLoad" in opts ? opts.filterMatchesToLoad ?? null : filterMatchesToLoad ?? null, skipRevalidation === true);
|
|
1735
|
+
if (isResponse(result)) return result;
|
|
1736
|
+
renderedStaticContext = {
|
|
1737
|
+
location,
|
|
1738
|
+
basename,
|
|
1739
|
+
...result,
|
|
1740
|
+
_match: match
|
|
1741
|
+
};
|
|
1742
|
+
return renderedStaticContext;
|
|
1743
|
+
});
|
|
1744
|
+
}, async (error, routeId) => {
|
|
1745
|
+
if (isRedirectResponse(error)) return error;
|
|
1746
|
+
if (isResponse(error)) try {
|
|
1747
|
+
error = new ErrorResponseImpl(error.status, error.statusText, await parseResponseBody(error));
|
|
1748
|
+
} catch (e) {
|
|
1749
|
+
error = e;
|
|
1750
|
+
}
|
|
1751
|
+
if (isDataWithResponseInit(error)) error = dataWithResponseInitToErrorResponse(error);
|
|
1752
|
+
if (renderedStaticContext) {
|
|
1753
|
+
if (routeId in renderedStaticContext.loaderData) renderedStaticContext.loaderData[routeId] = void 0;
|
|
1754
|
+
let staticContext = getStaticContextFromError(dataRoutes, renderedStaticContext, error, skipLoaderErrorBubbling ? routeId : findNearestBoundary(matches, routeId).route.id);
|
|
1755
|
+
return generateMiddlewareResponse(() => Promise.resolve(staticContext));
|
|
1756
|
+
} else {
|
|
1757
|
+
let staticContext = {
|
|
1758
|
+
matches,
|
|
1759
|
+
location,
|
|
1760
|
+
basename,
|
|
1761
|
+
loaderData: {},
|
|
1762
|
+
actionData: null,
|
|
1763
|
+
errors: { [skipLoaderErrorBubbling ? routeId : findNearestBoundary(matches, matches.find((m) => m.route.id === routeId || m.route.loader)?.route.id || routeId).route.id]: error },
|
|
1764
|
+
statusCode: isRouteErrorResponse(error) ? error.status : 500,
|
|
1765
|
+
actionHeaders: {},
|
|
1766
|
+
loaderHeaders: {},
|
|
1767
|
+
_match: match
|
|
1768
|
+
};
|
|
1769
|
+
return generateMiddlewareResponse(() => Promise.resolve(staticContext));
|
|
1770
|
+
}
|
|
1771
|
+
});
|
|
1772
|
+
invariant(isResponse(response), "Expected a response in query()");
|
|
1773
|
+
return response;
|
|
1774
|
+
} catch (e) {
|
|
1775
|
+
if (isResponse(e)) return e;
|
|
1776
|
+
throw e;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
let result = await queryImpl(request, location, matches, requestContext, dataStrategy || null, skipLoaderErrorBubbling === true, null, filterMatchesToLoad || null, skipRevalidation === true);
|
|
1780
|
+
if (isResponse(result)) return result;
|
|
1781
|
+
return {
|
|
1782
|
+
location,
|
|
1783
|
+
basename,
|
|
1784
|
+
...result,
|
|
1785
|
+
_match: match
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* The queryRoute() method is intended for targeted route requests, either
|
|
1790
|
+
* for fetch ?_data requests or resource route requests. In this case, we
|
|
1791
|
+
* are only ever calling a single action or loader, and we are returning the
|
|
1792
|
+
* returned value directly. In most cases, this will be a Response returned
|
|
1793
|
+
* from the action/loader, but it may be a primitive or other value as well -
|
|
1794
|
+
* and in such cases the calling context should handle that accordingly.
|
|
1795
|
+
*
|
|
1796
|
+
* We do respect the throw/return differentiation, so if an action/loader
|
|
1797
|
+
* throws, then this method will throw the value. This is important so we
|
|
1798
|
+
* can do proper boundary identification in Remix where a thrown Response
|
|
1799
|
+
* must go to the Catch Boundary but a returned Response is happy-path.
|
|
1800
|
+
*
|
|
1801
|
+
* One thing to note is that any Router-initiated Errors that make sense
|
|
1802
|
+
* to associate with a status code will be thrown as an ErrorResponse
|
|
1803
|
+
* instance which include the raw Error, such that the calling context can
|
|
1804
|
+
* serialize the error as they see fit while including the proper response
|
|
1805
|
+
* code. Examples here are 404 and 405 errors that occur prior to reaching
|
|
1806
|
+
* any user-defined loaders.
|
|
1807
|
+
*
|
|
1808
|
+
* - `opts.routeId` allows you to specify the specific route handler to call.
|
|
1809
|
+
* If not provided the handler will determine the proper route by matching
|
|
1810
|
+
* against `request.url`
|
|
1811
|
+
* - `opts.requestContext` is an optional server context that will be passed
|
|
1812
|
+
* to actions/loaders in the `context` parameter
|
|
1813
|
+
*/
|
|
1814
|
+
async function queryRoute(request, { routeId, requestContext, dataStrategy, generateMiddlewareResponse, normalizePath } = {}) {
|
|
1815
|
+
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
1816
|
+
let method = request.method;
|
|
1817
|
+
let location = createLocation("", normalizePathImpl(request), null, "default");
|
|
1818
|
+
let matches = dataRouteMatcher.match(location);
|
|
1819
|
+
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
1820
|
+
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") throw getInternalRouterError(405, { method });
|
|
1821
|
+
else if (!matches) throw getInternalRouterError(404, { pathname: location.pathname });
|
|
1822
|
+
let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location);
|
|
1823
|
+
if (routeId && !match) throw getInternalRouterError(403, {
|
|
1824
|
+
pathname: location.pathname,
|
|
1825
|
+
routeId
|
|
1826
|
+
});
|
|
1827
|
+
else if (!match) throw getInternalRouterError(404, { pathname: location.pathname });
|
|
1828
|
+
if (generateMiddlewareResponse) {
|
|
1829
|
+
invariant(requestContext instanceof RouterContextProvider, "When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`");
|
|
1830
|
+
await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties);
|
|
1831
|
+
return await runServerMiddlewarePipeline({
|
|
1832
|
+
request,
|
|
1833
|
+
url: createDataFunctionUrl(request, location),
|
|
1834
|
+
pattern: getRoutePattern(matches),
|
|
1835
|
+
matches,
|
|
1836
|
+
params: matches[0].params,
|
|
1837
|
+
context: requestContext
|
|
1838
|
+
}, async () => {
|
|
1839
|
+
return await generateMiddlewareResponse(async (innerRequest) => {
|
|
1840
|
+
let processed = handleQueryResult(await queryImpl(innerRequest, location, matches, requestContext, dataStrategy || null, false, match, null, false));
|
|
1841
|
+
return isResponse(processed) ? processed : typeof processed === "string" ? new Response(processed) : Response.json(processed);
|
|
1842
|
+
});
|
|
1843
|
+
}, (error) => {
|
|
1844
|
+
if (isDataWithResponseInit(error)) return Promise.resolve(dataWithResponseInitToResponse(error));
|
|
1845
|
+
if (isResponse(error)) return Promise.resolve(error);
|
|
1846
|
+
throw error;
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
return handleQueryResult(await queryImpl(request, location, matches, requestContext, dataStrategy || null, false, match, null, false));
|
|
1850
|
+
function handleQueryResult(result) {
|
|
1851
|
+
if (isResponse(result)) return result;
|
|
1852
|
+
let error = result.errors ? Object.values(result.errors)[0] : void 0;
|
|
1853
|
+
if (error !== void 0) throw error;
|
|
1854
|
+
if (result.actionData) return Object.values(result.actionData)[0];
|
|
1855
|
+
if (result.loaderData) return Object.values(result.loaderData)[0];
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
async function queryImpl(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
|
|
1859
|
+
invariant(request.signal, "query()/queryRoute() requests must contain an AbortController signal");
|
|
1860
|
+
try {
|
|
1861
|
+
if (isMutationMethod(request.method)) return await submit(request, location, matches, routeMatch || getTargetMatch(matches, location), requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch != null, filterMatchesToLoad, skipRevalidation);
|
|
1862
|
+
let result = await loadRouteData(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad);
|
|
1863
|
+
return isResponse(result) ? result : {
|
|
1864
|
+
...result,
|
|
1865
|
+
actionData: null,
|
|
1866
|
+
actionHeaders: {}
|
|
1867
|
+
};
|
|
1868
|
+
} catch (e) {
|
|
1869
|
+
if (isDataStrategyResult(e) && isResponse(e.result)) {
|
|
1870
|
+
if (e.type === "error") throw e.result;
|
|
1871
|
+
return e.result;
|
|
1872
|
+
}
|
|
1873
|
+
if (isRedirectResponse(e)) return e;
|
|
1874
|
+
throw e;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
async function submit(request, location, matches, actionMatch, requestContext, dataStrategy, skipLoaderErrorBubbling, isRouteRequest, filterMatchesToLoad, skipRevalidation) {
|
|
1878
|
+
let result;
|
|
1879
|
+
if (!actionMatch.route.action && !actionMatch.route.lazy) {
|
|
1880
|
+
let error = getInternalRouterError(405, {
|
|
1881
|
+
method: request.method,
|
|
1882
|
+
pathname: new URL(request.url).pathname,
|
|
1883
|
+
routeId: actionMatch.route.id
|
|
1884
|
+
});
|
|
1885
|
+
if (isRouteRequest) throw error;
|
|
1886
|
+
result = {
|
|
1887
|
+
type: "error",
|
|
1888
|
+
error
|
|
1889
|
+
};
|
|
1890
|
+
} else {
|
|
1891
|
+
result = (await callDataStrategy(request, location, getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, location, matches, actionMatch, [], requestContext), isRouteRequest, requestContext, dataStrategy))[actionMatch.route.id];
|
|
1892
|
+
if (request.signal.aborted) throwStaticHandlerAbortedError(request, isRouteRequest);
|
|
1893
|
+
}
|
|
1894
|
+
if (isRedirectResult(result)) throw new Response(null, {
|
|
1895
|
+
status: result.response.status,
|
|
1896
|
+
headers: { Location: result.response.headers.get("Location") }
|
|
1897
|
+
});
|
|
1898
|
+
if (isRouteRequest) {
|
|
1899
|
+
if (isErrorResult(result)) throw result.error;
|
|
1900
|
+
return {
|
|
1901
|
+
matches: [actionMatch],
|
|
1902
|
+
loaderData: {},
|
|
1903
|
+
actionData: { [actionMatch.route.id]: result.data },
|
|
1904
|
+
errors: null,
|
|
1905
|
+
statusCode: 200,
|
|
1906
|
+
loaderHeaders: {},
|
|
1907
|
+
actionHeaders: {}
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
if (skipRevalidation) if (isErrorResult(result)) {
|
|
1911
|
+
let boundaryMatch = skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id);
|
|
1912
|
+
return {
|
|
1913
|
+
statusCode: isRouteErrorResponse(result.error) ? result.error.status : result.statusCode != null ? result.statusCode : 500,
|
|
1914
|
+
actionData: null,
|
|
1915
|
+
actionHeaders: { ...result.headers ? { [actionMatch.route.id]: result.headers } : {} },
|
|
1916
|
+
matches,
|
|
1917
|
+
loaderData: {},
|
|
1918
|
+
errors: { [boundaryMatch.route.id]: result.error },
|
|
1919
|
+
loaderHeaders: {}
|
|
1920
|
+
};
|
|
1921
|
+
} else return {
|
|
1922
|
+
actionData: { [actionMatch.route.id]: result.data },
|
|
1923
|
+
actionHeaders: result.headers ? { [actionMatch.route.id]: result.headers } : {},
|
|
1924
|
+
matches,
|
|
1925
|
+
loaderData: {},
|
|
1926
|
+
errors: null,
|
|
1927
|
+
statusCode: result.statusCode || 200,
|
|
1928
|
+
loaderHeaders: {}
|
|
1929
|
+
};
|
|
1930
|
+
let loaderRequest = new Request(request.url, {
|
|
1931
|
+
headers: request.headers,
|
|
1932
|
+
redirect: request.redirect,
|
|
1933
|
+
signal: request.signal
|
|
1934
|
+
});
|
|
1935
|
+
if (isErrorResult(result)) return {
|
|
1936
|
+
...await loadRouteData(loaderRequest, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, null, filterMatchesToLoad, [(skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id)).route.id, result]),
|
|
1937
|
+
statusCode: isRouteErrorResponse(result.error) ? result.error.status : result.statusCode != null ? result.statusCode : 500,
|
|
1938
|
+
actionData: null,
|
|
1939
|
+
actionHeaders: { ...result.headers ? { [actionMatch.route.id]: result.headers } : {} }
|
|
1940
|
+
};
|
|
1941
|
+
return {
|
|
1942
|
+
...await loadRouteData(loaderRequest, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, null, filterMatchesToLoad),
|
|
1943
|
+
actionData: { [actionMatch.route.id]: result.data },
|
|
1944
|
+
...result.statusCode ? { statusCode: result.statusCode } : {},
|
|
1945
|
+
actionHeaders: result.headers ? { [actionMatch.route.id]: result.headers } : {}
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
async function loadRouteData(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, pendingActionResult) {
|
|
1949
|
+
let isRouteRequest = routeMatch != null;
|
|
1950
|
+
if (isRouteRequest && !routeMatch?.route.loader && !routeMatch?.route.lazy) throw getInternalRouterError(400, {
|
|
1951
|
+
method: request.method,
|
|
1952
|
+
pathname: new URL(request.url).pathname,
|
|
1953
|
+
routeId: routeMatch?.route.id
|
|
1954
|
+
});
|
|
1955
|
+
let dsMatches;
|
|
1956
|
+
if (routeMatch) dsMatches = getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, location, matches, routeMatch, [], requestContext);
|
|
1957
|
+
else {
|
|
1958
|
+
let maxIdx = pendingActionResult && isErrorResult(pendingActionResult[1]) ? matches.findIndex((m) => m.route.id === pendingActionResult[0]) - 1 : void 0;
|
|
1959
|
+
let pattern = getRoutePattern(matches);
|
|
1960
|
+
dsMatches = matches.map((match, index) => {
|
|
1961
|
+
if (maxIdx != null && index > maxIdx) return getDataStrategyMatch(mapRouteProperties, manifest, request, location, pattern, match, [], requestContext, false);
|
|
1962
|
+
return getDataStrategyMatch(mapRouteProperties, manifest, request, location, pattern, match, [], requestContext, (match.route.loader || match.route.lazy) != null && (!filterMatchesToLoad || filterMatchesToLoad(match)));
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
if (!dataStrategy && !dsMatches.some((m) => m.shouldLoad)) return {
|
|
1966
|
+
matches,
|
|
1967
|
+
loaderData: {},
|
|
1968
|
+
errors: pendingActionResult && isErrorResult(pendingActionResult[1]) ? { [pendingActionResult[0]]: pendingActionResult[1].error } : null,
|
|
1969
|
+
statusCode: 200,
|
|
1970
|
+
loaderHeaders: {}
|
|
1971
|
+
};
|
|
1972
|
+
let results = await callDataStrategy(request, location, dsMatches, isRouteRequest, requestContext, dataStrategy);
|
|
1973
|
+
if (request.signal.aborted) throwStaticHandlerAbortedError(request, isRouteRequest);
|
|
1974
|
+
return {
|
|
1975
|
+
...processRouteLoaderData(matches, results, pendingActionResult, true, skipLoaderErrorBubbling),
|
|
1976
|
+
matches
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
async function callDataStrategy(request, location, matches, isRouteRequest, requestContext, dataStrategy) {
|
|
1980
|
+
let results = await callDataStrategyImpl(dataStrategy || defaultDataStrategy, request, location, matches, null, "static", requestContext, true);
|
|
1981
|
+
let dataResults = {};
|
|
1982
|
+
await Promise.all(matches.map(async (match) => {
|
|
1983
|
+
if (!(match.route.id in results)) return;
|
|
1984
|
+
let result = results[match.route.id];
|
|
1985
|
+
if (isRedirectDataStrategyResult(result)) throw normalizeRelativeRoutingRedirectResponse(result.result, request, match.route.id, matches, basename);
|
|
1986
|
+
if (isRouteRequest) {
|
|
1987
|
+
if (isResponse(result.result)) throw result;
|
|
1988
|
+
else if (isDataWithResponseInit(result.result)) throw dataWithResponseInitToResponse(result.result);
|
|
1989
|
+
}
|
|
1990
|
+
dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result);
|
|
1991
|
+
}));
|
|
1992
|
+
return dataResults;
|
|
1993
|
+
}
|
|
1994
|
+
return {
|
|
1995
|
+
dataRoutes,
|
|
1996
|
+
get _matchCost() {
|
|
1997
|
+
return dataRouteMatcher instanceof V6RegExMatcher ? dataRouteMatcher.matchCost : void 0;
|
|
1998
|
+
},
|
|
1999
|
+
match,
|
|
2000
|
+
query,
|
|
2001
|
+
queryRoute
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Given an existing StaticHandlerContext and an error thrown at render time,
|
|
2006
|
+
* provide an updated StaticHandlerContext suitable for a second SSR render
|
|
2007
|
+
*
|
|
2008
|
+
* @category Utils
|
|
2009
|
+
*/
|
|
2010
|
+
function getStaticContextFromError(routes, handlerContext, error, boundaryId) {
|
|
2011
|
+
let errorBoundaryId = boundaryId || handlerContext._deepestRenderedBoundaryId || routes[0].id;
|
|
2012
|
+
return {
|
|
2013
|
+
...handlerContext,
|
|
2014
|
+
statusCode: isRouteErrorResponse(error) ? error.status : 500,
|
|
2015
|
+
errors: { [errorBoundaryId]: error }
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2018
|
+
function throwStaticHandlerAbortedError(request, isRouteRequest) {
|
|
2019
|
+
if (request.signal.reason !== void 0) throw request.signal.reason;
|
|
2020
|
+
throw new Error(`${isRouteRequest ? "queryRoute" : "query"}() call aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`);
|
|
2021
|
+
}
|
|
2022
|
+
function defaultNormalizePath(request) {
|
|
2023
|
+
let url = new URL(request.url);
|
|
2024
|
+
return {
|
|
2025
|
+
pathname: url.pathname,
|
|
2026
|
+
search: url.search,
|
|
2027
|
+
hash: url.hash
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
2030
|
+
function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
|
|
2031
|
+
let contextualMatches;
|
|
2032
|
+
let activeRouteMatch;
|
|
2033
|
+
if (fromRouteId) {
|
|
2034
|
+
contextualMatches = [];
|
|
2035
|
+
for (let match of matches) {
|
|
2036
|
+
contextualMatches.push(match);
|
|
2037
|
+
if (match.route.id === fromRouteId) {
|
|
2038
|
+
activeRouteMatch = match;
|
|
2039
|
+
break;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
} else {
|
|
2043
|
+
contextualMatches = matches;
|
|
2044
|
+
activeRouteMatch = matches[matches.length - 1];
|
|
2045
|
+
}
|
|
2046
|
+
let path = resolveTo(to ? to : ".", getResolveToMatches(contextualMatches), stripBasename(location.pathname, basename) || location.pathname, relative === "path");
|
|
2047
|
+
if (to == null) {
|
|
2048
|
+
path.search = location.search;
|
|
2049
|
+
path.hash = location.hash;
|
|
2050
|
+
}
|
|
2051
|
+
if ((to == null || to === "" || to === ".") && activeRouteMatch) {
|
|
2052
|
+
let nakedIndex = hasNakedIndexQuery(path.search);
|
|
2053
|
+
if (activeRouteMatch.route.index && !nakedIndex) path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
|
2054
|
+
else if (!activeRouteMatch.route.index && nakedIndex) {
|
|
2055
|
+
let params = new URLSearchParams(path.search);
|
|
2056
|
+
let indexValues = params.getAll("index");
|
|
2057
|
+
params.delete("index");
|
|
2058
|
+
indexValues.filter((v) => v).forEach((v) => params.append("index", v));
|
|
2059
|
+
let qs = params.toString();
|
|
2060
|
+
path.search = qs ? `?${qs}` : "";
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
if (basename !== "/") path.pathname = prependBasename({
|
|
2064
|
+
basename,
|
|
2065
|
+
pathname: path.pathname
|
|
2066
|
+
});
|
|
2067
|
+
return createPath(path);
|
|
2068
|
+
}
|
|
2069
|
+
function shouldRevalidateLoader(loaderMatch, arg) {
|
|
2070
|
+
if (loaderMatch.route.shouldRevalidate) {
|
|
2071
|
+
let routeChoice = loaderMatch.route.shouldRevalidate(arg);
|
|
2072
|
+
if (typeof routeChoice === "boolean") return routeChoice;
|
|
2073
|
+
}
|
|
2074
|
+
return arg.defaultShouldRevalidate;
|
|
2075
|
+
}
|
|
2076
|
+
var lazyRoutePropertyCache = /* @__PURE__ */ new WeakMap();
|
|
2077
|
+
var loadLazyRouteProperty = ({ key, route, manifest, mapRouteProperties }) => {
|
|
2078
|
+
let routeToUpdate = manifest[route.id];
|
|
2079
|
+
invariant(routeToUpdate, "No route found in manifest");
|
|
2080
|
+
if (!routeToUpdate.lazy || typeof routeToUpdate.lazy !== "object") return;
|
|
2081
|
+
let lazyFn = routeToUpdate.lazy[key];
|
|
2082
|
+
if (!lazyFn) return;
|
|
2083
|
+
let cache = lazyRoutePropertyCache.get(routeToUpdate);
|
|
2084
|
+
if (!cache) {
|
|
2085
|
+
cache = {};
|
|
2086
|
+
lazyRoutePropertyCache.set(routeToUpdate, cache);
|
|
2087
|
+
}
|
|
2088
|
+
let cachedPromise = cache[key];
|
|
2089
|
+
if (cachedPromise) return cachedPromise;
|
|
2090
|
+
let propertyPromise = (async () => {
|
|
2091
|
+
let isUnsupported = isUnsupportedLazyRouteObjectKey(key);
|
|
2092
|
+
let isStaticallyDefined = routeToUpdate[key] !== void 0;
|
|
2093
|
+
if (isUnsupported) {
|
|
2094
|
+
warning(!isUnsupported, "Route property " + key + " is not a supported lazy route property. This property will be ignored.");
|
|
2095
|
+
cache[key] = Promise.resolve();
|
|
2096
|
+
} else if (isStaticallyDefined) warning(false, `Route "${routeToUpdate.id}" has a static property "${key}" defined. The lazy property will be ignored.`);
|
|
2097
|
+
else {
|
|
2098
|
+
let value = await lazyFn();
|
|
2099
|
+
if (value != null) {
|
|
2100
|
+
Object.assign(routeToUpdate, { [key]: value });
|
|
2101
|
+
Object.assign(routeToUpdate, mapRouteProperties(routeToUpdate));
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
if (typeof routeToUpdate.lazy === "object") {
|
|
2105
|
+
routeToUpdate.lazy[key] = void 0;
|
|
2106
|
+
if (Object.values(routeToUpdate.lazy).every((value) => value === void 0)) routeToUpdate.lazy = void 0;
|
|
2107
|
+
}
|
|
2108
|
+
})();
|
|
2109
|
+
cache[key] = propertyPromise;
|
|
2110
|
+
propertyPromise.catch(() => {
|
|
2111
|
+
if (cache[key] === propertyPromise) delete cache[key];
|
|
2112
|
+
});
|
|
2113
|
+
return propertyPromise;
|
|
2114
|
+
};
|
|
2115
|
+
var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
2116
|
+
/**
|
|
2117
|
+
* Execute route.lazy functions to lazily load route modules (loader, action,
|
|
2118
|
+
* shouldRevalidate) and update the routeManifest in place which shares objects
|
|
2119
|
+
* with dataRoutes so those get updated as well.
|
|
2120
|
+
*/
|
|
2121
|
+
function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePropertiesToSkip) {
|
|
2122
|
+
let routeToUpdate = manifest[route.id];
|
|
2123
|
+
invariant(routeToUpdate, "No route found in manifest");
|
|
2124
|
+
if (!route.lazy) return {
|
|
2125
|
+
lazyRoutePromise: void 0,
|
|
2126
|
+
lazyHandlerPromise: void 0
|
|
2127
|
+
};
|
|
2128
|
+
if (typeof route.lazy === "function") {
|
|
2129
|
+
let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
|
|
2130
|
+
if (cachedPromise) return {
|
|
2131
|
+
lazyRoutePromise: cachedPromise,
|
|
2132
|
+
lazyHandlerPromise: cachedPromise
|
|
2133
|
+
};
|
|
2134
|
+
let lazyRoutePromise = (async () => {
|
|
2135
|
+
invariant(typeof route.lazy === "function", "No lazy route function found");
|
|
2136
|
+
let lazyRoute = await route.lazy();
|
|
2137
|
+
let routeUpdates = {};
|
|
2138
|
+
for (let lazyRouteProperty in lazyRoute) {
|
|
2139
|
+
let lazyValue = lazyRoute[lazyRouteProperty];
|
|
2140
|
+
if (lazyValue === void 0) continue;
|
|
2141
|
+
let isUnsupported = isUnsupportedLazyRouteFunctionKey(lazyRouteProperty);
|
|
2142
|
+
let isStaticallyDefined = routeToUpdate[lazyRouteProperty] !== void 0;
|
|
2143
|
+
if (isUnsupported) warning(!isUnsupported, "Route property " + lazyRouteProperty + " is not a supported property to be returned from a lazy route function. This property will be ignored.");
|
|
2144
|
+
else if (isStaticallyDefined) warning(!isStaticallyDefined, `Route "${routeToUpdate.id}" has a static property "${lazyRouteProperty}" defined but its lazy function is also returning a value for this property. The lazy route property "${lazyRouteProperty}" will be ignored.`);
|
|
2145
|
+
else routeUpdates[lazyRouteProperty] = lazyValue;
|
|
2146
|
+
}
|
|
2147
|
+
Object.assign(routeToUpdate, routeUpdates);
|
|
2148
|
+
Object.assign(routeToUpdate, {
|
|
2149
|
+
...mapRouteProperties(routeToUpdate),
|
|
2150
|
+
lazy: void 0
|
|
2151
|
+
});
|
|
2152
|
+
})();
|
|
2153
|
+
lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
|
|
2154
|
+
lazyRoutePromise.catch(() => {
|
|
2155
|
+
if (lazyRouteFunctionCache.get(routeToUpdate) === lazyRoutePromise) lazyRouteFunctionCache.delete(routeToUpdate);
|
|
2156
|
+
});
|
|
2157
|
+
return {
|
|
2158
|
+
lazyRoutePromise,
|
|
2159
|
+
lazyHandlerPromise: lazyRoutePromise
|
|
2160
|
+
};
|
|
2161
|
+
}
|
|
2162
|
+
let lazyKeys = Object.keys(route.lazy);
|
|
2163
|
+
let lazyPropertyPromises = [];
|
|
2164
|
+
let lazyHandlerPromise = void 0;
|
|
2165
|
+
for (let key of lazyKeys) {
|
|
2166
|
+
if (lazyRoutePropertiesToSkip && lazyRoutePropertiesToSkip.includes(key)) continue;
|
|
2167
|
+
let promise = loadLazyRouteProperty({
|
|
2168
|
+
key,
|
|
2169
|
+
route,
|
|
2170
|
+
manifest,
|
|
2171
|
+
mapRouteProperties
|
|
2172
|
+
});
|
|
2173
|
+
if (promise) {
|
|
2174
|
+
lazyPropertyPromises.push(promise);
|
|
2175
|
+
if (key === type) lazyHandlerPromise = promise;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
let lazyRoutePromise = lazyPropertyPromises.length > 0 ? Promise.all(lazyPropertyPromises).then(() => {}) : void 0;
|
|
2179
|
+
lazyRoutePromise?.catch(() => {});
|
|
2180
|
+
lazyHandlerPromise?.catch(() => {});
|
|
2181
|
+
return {
|
|
2182
|
+
lazyRoutePromise,
|
|
2183
|
+
lazyHandlerPromise
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
function isNonNullable(value) {
|
|
2187
|
+
return value !== void 0;
|
|
2188
|
+
}
|
|
2189
|
+
function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties) {
|
|
2190
|
+
let promises = matches.map(({ route }) => {
|
|
2191
|
+
if (typeof route.lazy !== "object" || !route.lazy.middleware) return;
|
|
2192
|
+
return loadLazyRouteProperty({
|
|
2193
|
+
key: "middleware",
|
|
2194
|
+
route,
|
|
2195
|
+
manifest,
|
|
2196
|
+
mapRouteProperties
|
|
2197
|
+
});
|
|
2198
|
+
}).filter(isNonNullable);
|
|
2199
|
+
return promises.length > 0 ? Promise.all(promises) : void 0;
|
|
2200
|
+
}
|
|
2201
|
+
async function defaultDataStrategy(args) {
|
|
2202
|
+
let matchesToLoad = args.matches.filter((m) => m.shouldLoad);
|
|
2203
|
+
let keyedResults = {};
|
|
2204
|
+
(await Promise.all(matchesToLoad.map((m) => m.resolve()))).forEach((result, i) => {
|
|
2205
|
+
keyedResults[matchesToLoad[i].route.id] = result;
|
|
2206
|
+
});
|
|
2207
|
+
return keyedResults;
|
|
2208
|
+
}
|
|
2209
|
+
function runServerMiddlewarePipeline(args, handler, errorHandler) {
|
|
2210
|
+
return runMiddlewarePipeline(args, handler, processResult, isResponse, errorHandler);
|
|
2211
|
+
function processResult(result) {
|
|
2212
|
+
return isDataWithResponseInit(result) ? dataWithResponseInitToResponse(result) : result;
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
function runClientMiddlewarePipeline(args, handler) {
|
|
2216
|
+
return runMiddlewarePipeline(args, handler, (r) => {
|
|
2217
|
+
if (isRedirectResponse(r)) throw r;
|
|
2218
|
+
return r;
|
|
2219
|
+
}, isDataStrategyResults, errorHandler);
|
|
2220
|
+
async function errorHandler(error, routeId, nextResult) {
|
|
2221
|
+
if (nextResult) return Object.assign(nextResult.value, { [routeId]: {
|
|
2222
|
+
type: "error",
|
|
2223
|
+
result: error
|
|
2224
|
+
} });
|
|
2225
|
+
else {
|
|
2226
|
+
let { matches } = args;
|
|
2227
|
+
let maxBoundaryIdx = Math.min(Math.max(matches.findIndex((m) => m.route.id === routeId), 0), Math.max(matches.findIndex((m) => m.shouldCallHandler()), 0));
|
|
2228
|
+
let deepestRouteId = matches[maxBoundaryIdx].route.id;
|
|
2229
|
+
for (let match of matches.slice(0, maxBoundaryIdx + 1)) try {
|
|
2230
|
+
await match._lazyPromises?.route;
|
|
2231
|
+
} catch {
|
|
2232
|
+
deepestRouteId = match.route.id;
|
|
2233
|
+
break;
|
|
2234
|
+
}
|
|
2235
|
+
return { [findNearestBoundary(matches, deepestRouteId).route.id]: {
|
|
2236
|
+
type: "error",
|
|
2237
|
+
result: error
|
|
2238
|
+
} };
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
|
|
2243
|
+
let { matches, ...dataFnArgs } = args;
|
|
2244
|
+
return await callRouteMiddleware(dataFnArgs, matches.flatMap((m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []), handler, processResult, isResult, errorHandler);
|
|
2245
|
+
}
|
|
2246
|
+
async function callRouteMiddleware(args, middlewares, handler, processResult, isResult, errorHandler, idx = 0) {
|
|
2247
|
+
let { request } = args;
|
|
2248
|
+
if (request.signal.aborted) throw request.signal.reason ?? /* @__PURE__ */ new Error(`Request aborted: ${request.method} ${request.url}`);
|
|
2249
|
+
let tuple = middlewares[idx];
|
|
2250
|
+
if (!tuple) return await handler();
|
|
2251
|
+
let [routeId, middleware] = tuple;
|
|
2252
|
+
let nextResult;
|
|
2253
|
+
let next = async () => {
|
|
2254
|
+
if (nextResult) throw new Error("You may only call `next()` once per middleware");
|
|
2255
|
+
try {
|
|
2256
|
+
nextResult = { value: await callRouteMiddleware(args, middlewares, handler, processResult, isResult, errorHandler, idx + 1) };
|
|
2257
|
+
return nextResult.value;
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
nextResult = { value: await errorHandler(error, routeId, nextResult) };
|
|
2260
|
+
return nextResult.value;
|
|
2261
|
+
}
|
|
2262
|
+
};
|
|
2263
|
+
try {
|
|
2264
|
+
let value = await middleware(args, next);
|
|
2265
|
+
let result = value != null ? processResult(value) : void 0;
|
|
2266
|
+
if (isResult(result)) return result;
|
|
2267
|
+
else if (nextResult) return result ?? nextResult.value;
|
|
2268
|
+
else {
|
|
2269
|
+
nextResult = { value: await next() };
|
|
2270
|
+
return nextResult.value;
|
|
2271
|
+
}
|
|
2272
|
+
} catch (error) {
|
|
2273
|
+
return await errorHandler(error, routeId, nextResult);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
2277
|
+
let lazyMiddlewarePromise = loadLazyRouteProperty({
|
|
2278
|
+
key: "middleware",
|
|
2279
|
+
route: match.route,
|
|
2280
|
+
manifest,
|
|
2281
|
+
mapRouteProperties
|
|
2282
|
+
});
|
|
2283
|
+
let lazyRoutePromises = loadLazyRoute(match.route, isMutationMethod(request.method) ? "action" : "loader", manifest, mapRouteProperties, lazyRoutePropertiesToSkip);
|
|
2284
|
+
return {
|
|
2285
|
+
middleware: lazyMiddlewarePromise,
|
|
2286
|
+
route: lazyRoutePromises.lazyRoutePromise,
|
|
2287
|
+
handler: lazyRoutePromises.lazyHandlerPromise
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
function getDataStrategyMatch(mapRouteProperties, manifest, request, path, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
|
|
2291
|
+
let isUsingNewApi = false;
|
|
2292
|
+
let _lazyPromises = getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request, match, lazyRoutePropertiesToSkip);
|
|
2293
|
+
return {
|
|
2294
|
+
...match,
|
|
2295
|
+
_lazyPromises,
|
|
2296
|
+
shouldLoad,
|
|
2297
|
+
shouldRevalidateArgs,
|
|
2298
|
+
shouldCallHandler(defaultShouldRevalidate) {
|
|
2299
|
+
isUsingNewApi = true;
|
|
2300
|
+
if (!shouldRevalidateArgs) return shouldLoad;
|
|
2301
|
+
if (typeof callSiteDefaultShouldRevalidate === "boolean") return shouldRevalidateLoader(match, {
|
|
2302
|
+
...shouldRevalidateArgs,
|
|
2303
|
+
defaultShouldRevalidate: callSiteDefaultShouldRevalidate
|
|
2304
|
+
});
|
|
2305
|
+
if (typeof defaultShouldRevalidate === "boolean") return shouldRevalidateLoader(match, {
|
|
2306
|
+
...shouldRevalidateArgs,
|
|
2307
|
+
defaultShouldRevalidate
|
|
2308
|
+
});
|
|
2309
|
+
return shouldRevalidateLoader(match, shouldRevalidateArgs);
|
|
2310
|
+
},
|
|
2311
|
+
resolve(handlerOverride) {
|
|
2312
|
+
let { lazy, loader, middleware } = match.route;
|
|
2313
|
+
let callHandler = isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (lazy || loader);
|
|
2314
|
+
let isMiddlewareOnlyRoute = middleware && middleware.length > 0 && !loader && !lazy;
|
|
2315
|
+
if (callHandler && (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)) return callLoaderOrAction({
|
|
2316
|
+
request,
|
|
2317
|
+
path,
|
|
2318
|
+
pattern,
|
|
2319
|
+
match,
|
|
2320
|
+
lazyHandlerPromise: _lazyPromises?.handler,
|
|
2321
|
+
lazyRoutePromise: _lazyPromises?.route,
|
|
2322
|
+
handlerOverride,
|
|
2323
|
+
scopedContext
|
|
2324
|
+
});
|
|
2325
|
+
return Promise.resolve({
|
|
2326
|
+
type: "data",
|
|
2327
|
+
result: void 0
|
|
2328
|
+
});
|
|
2329
|
+
}
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, path, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
|
|
2333
|
+
return matches.map((match) => {
|
|
2334
|
+
if (match.route.id !== targetMatch.route.id) return {
|
|
2335
|
+
...match,
|
|
2336
|
+
shouldLoad: false,
|
|
2337
|
+
shouldRevalidateArgs,
|
|
2338
|
+
shouldCallHandler: () => false,
|
|
2339
|
+
_lazyPromises: getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request, match, lazyRoutePropertiesToSkip),
|
|
2340
|
+
resolve: () => Promise.resolve({
|
|
2341
|
+
type: "data",
|
|
2342
|
+
result: void 0
|
|
2343
|
+
})
|
|
2344
|
+
};
|
|
2345
|
+
return getDataStrategyMatch(mapRouteProperties, manifest, request, path, getRoutePattern(matches), match, lazyRoutePropertiesToSkip, scopedContext, true, shouldRevalidateArgs);
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2348
|
+
async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fetcherKey, initiator, scopedContext, isStaticHandler, navigationType = null) {
|
|
2349
|
+
if (matches.some((m) => m._lazyPromises?.middleware)) await Promise.all(matches.map((m) => m._lazyPromises?.middleware));
|
|
2350
|
+
let dataStrategyArgs = {
|
|
2351
|
+
request,
|
|
2352
|
+
url: createDataFunctionUrl(request, path),
|
|
2353
|
+
pattern: getRoutePattern(matches),
|
|
2354
|
+
params: matches[0].params,
|
|
2355
|
+
context: scopedContext,
|
|
2356
|
+
matches,
|
|
2357
|
+
unstable_initiator: initiator,
|
|
2358
|
+
unstable_navigationType: initiator === "navigation" ? navigationType : null
|
|
2359
|
+
};
|
|
2360
|
+
let runClientMiddleware = isStaticHandler ? () => {
|
|
2361
|
+
throw new Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`");
|
|
2362
|
+
} : (cb) => {
|
|
2363
|
+
let typedDataStrategyArgs = dataStrategyArgs;
|
|
2364
|
+
return runClientMiddlewarePipeline(typedDataStrategyArgs, () => {
|
|
2365
|
+
return cb({
|
|
2366
|
+
...typedDataStrategyArgs,
|
|
2367
|
+
fetcherKey,
|
|
2368
|
+
runClientMiddleware: () => {
|
|
2369
|
+
throw new Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler");
|
|
2370
|
+
}
|
|
2371
|
+
});
|
|
2372
|
+
});
|
|
2373
|
+
};
|
|
2374
|
+
let results = await dataStrategyImpl({
|
|
2375
|
+
...dataStrategyArgs,
|
|
2376
|
+
fetcherKey,
|
|
2377
|
+
runClientMiddleware
|
|
2378
|
+
});
|
|
2379
|
+
try {
|
|
2380
|
+
await Promise.all(matches.flatMap((m) => [m._lazyPromises?.handler, m._lazyPromises?.route]));
|
|
2381
|
+
} catch {}
|
|
2382
|
+
return results;
|
|
2383
|
+
}
|
|
2384
|
+
async function callLoaderOrAction({ request, path, pattern, match, lazyHandlerPromise, lazyRoutePromise, handlerOverride, scopedContext }) {
|
|
2385
|
+
let result;
|
|
2386
|
+
let onReject;
|
|
2387
|
+
let isAction = isMutationMethod(request.method);
|
|
2388
|
+
let type = isAction ? "action" : "loader";
|
|
2389
|
+
let runHandler = (handler) => {
|
|
2390
|
+
let reject;
|
|
2391
|
+
let abortPromise = new Promise((_, r) => reject = r);
|
|
2392
|
+
onReject = () => reject();
|
|
2393
|
+
request.signal.addEventListener("abort", onReject);
|
|
2394
|
+
let actualHandler = (ctx) => {
|
|
2395
|
+
if (typeof handler !== "function") return Promise.reject(/* @__PURE__ */ new Error(`You cannot call the handler for a route which defines a boolean "${type}" [routeId: ${match.route.id}]`));
|
|
2396
|
+
return handler({
|
|
2397
|
+
request,
|
|
2398
|
+
url: createDataFunctionUrl(request, path),
|
|
2399
|
+
pattern,
|
|
2400
|
+
params: match.params,
|
|
2401
|
+
context: scopedContext
|
|
2402
|
+
}, ...ctx !== void 0 ? [ctx] : []);
|
|
2403
|
+
};
|
|
2404
|
+
let handlerPromise = (async () => {
|
|
2405
|
+
try {
|
|
2406
|
+
return {
|
|
2407
|
+
type: "data",
|
|
2408
|
+
result: await (handlerOverride ? handlerOverride((ctx) => actualHandler(ctx)) : actualHandler())
|
|
2409
|
+
};
|
|
2410
|
+
} catch (e) {
|
|
2411
|
+
return {
|
|
2412
|
+
type: "error",
|
|
2413
|
+
result: e
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
})();
|
|
2417
|
+
return Promise.race([handlerPromise, abortPromise]);
|
|
2418
|
+
};
|
|
2419
|
+
try {
|
|
2420
|
+
let handler = isAction ? match.route.action : match.route.loader;
|
|
2421
|
+
if (lazyHandlerPromise || lazyRoutePromise) if (handler) {
|
|
2422
|
+
let handlerError;
|
|
2423
|
+
let [value] = await Promise.all([
|
|
2424
|
+
runHandler(handler).catch((e) => {
|
|
2425
|
+
handlerError = e;
|
|
2426
|
+
}),
|
|
2427
|
+
lazyHandlerPromise,
|
|
2428
|
+
lazyRoutePromise
|
|
2429
|
+
]);
|
|
2430
|
+
if (handlerError !== void 0) throw handlerError;
|
|
2431
|
+
result = value;
|
|
2432
|
+
} else {
|
|
2433
|
+
await lazyHandlerPromise;
|
|
2434
|
+
let handler = isAction ? match.route.action : match.route.loader;
|
|
2435
|
+
if (handler) [result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
|
|
2436
|
+
else if (type === "action") {
|
|
2437
|
+
let url = new URL(request.url);
|
|
2438
|
+
let pathname = url.pathname + url.search;
|
|
2439
|
+
throw getInternalRouterError(405, {
|
|
2440
|
+
method: request.method,
|
|
2441
|
+
pathname,
|
|
2442
|
+
routeId: match.route.id
|
|
2443
|
+
});
|
|
2444
|
+
} else {
|
|
2445
|
+
await lazyRoutePromise;
|
|
2446
|
+
return {
|
|
2447
|
+
type: "data",
|
|
2448
|
+
result: void 0
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
else if (!handler) {
|
|
2453
|
+
let url = new URL(request.url);
|
|
2454
|
+
throw getInternalRouterError(404, { pathname: url.pathname + url.search });
|
|
2455
|
+
} else result = await runHandler(handler);
|
|
2456
|
+
} catch (e) {
|
|
2457
|
+
return {
|
|
2458
|
+
type: "error",
|
|
2459
|
+
result: e
|
|
2460
|
+
};
|
|
2461
|
+
} finally {
|
|
2462
|
+
if (onReject) request.signal.removeEventListener("abort", onReject);
|
|
2463
|
+
}
|
|
2464
|
+
return result;
|
|
2465
|
+
}
|
|
2466
|
+
async function parseResponseBody(response) {
|
|
2467
|
+
let contentType = response.headers.get("Content-Type");
|
|
2468
|
+
if (contentType && /\bapplication\/json\b/.test(contentType)) return response.body == null ? null : response.json();
|
|
2469
|
+
return response.text();
|
|
2470
|
+
}
|
|
2471
|
+
async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
2472
|
+
let { result, type } = dataStrategyResult;
|
|
2473
|
+
if (isResponse(result)) {
|
|
2474
|
+
let data;
|
|
2475
|
+
try {
|
|
2476
|
+
data = await parseResponseBody(result);
|
|
2477
|
+
} catch (e) {
|
|
2478
|
+
return {
|
|
2479
|
+
type: "error",
|
|
2480
|
+
error: e
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
if (type === "error") return {
|
|
2484
|
+
type: "error",
|
|
2485
|
+
error: new ErrorResponseImpl(result.status, result.statusText, data),
|
|
2486
|
+
statusCode: result.status,
|
|
2487
|
+
headers: result.headers
|
|
2488
|
+
};
|
|
2489
|
+
return {
|
|
2490
|
+
type: "data",
|
|
2491
|
+
data,
|
|
2492
|
+
statusCode: result.status,
|
|
2493
|
+
headers: result.headers
|
|
2494
|
+
};
|
|
2495
|
+
}
|
|
2496
|
+
if (type === "error") {
|
|
2497
|
+
if (isDataWithResponseInit(result)) {
|
|
2498
|
+
if (result.data instanceof Error) return {
|
|
2499
|
+
type: "error",
|
|
2500
|
+
error: result.data,
|
|
2501
|
+
statusCode: result.init?.status,
|
|
2502
|
+
headers: result.init?.headers ? new Headers(result.init.headers) : void 0
|
|
2503
|
+
};
|
|
2504
|
+
return {
|
|
2505
|
+
type: "error",
|
|
2506
|
+
error: dataWithResponseInitToErrorResponse(result),
|
|
2507
|
+
statusCode: isRouteErrorResponse(result) ? result.status : void 0,
|
|
2508
|
+
headers: result.init?.headers ? new Headers(result.init.headers) : void 0
|
|
2509
|
+
};
|
|
2510
|
+
}
|
|
2511
|
+
return {
|
|
2512
|
+
type: "error",
|
|
2513
|
+
error: result,
|
|
2514
|
+
statusCode: isRouteErrorResponse(result) ? result.status : void 0
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
if (isDataWithResponseInit(result)) return {
|
|
2518
|
+
type: "data",
|
|
2519
|
+
data: result.data,
|
|
2520
|
+
statusCode: result.init?.status,
|
|
2521
|
+
headers: result.init?.headers ? new Headers(result.init.headers) : void 0
|
|
2522
|
+
};
|
|
2523
|
+
return {
|
|
2524
|
+
type: "data",
|
|
2525
|
+
data: result
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
|
|
2529
|
+
let location = response.headers.get("Location");
|
|
2530
|
+
invariant(location, "Redirects returned/thrown from loaders/actions must have a Location header");
|
|
2531
|
+
validateNavigationTarget(location, location, new URL(request.url), "allow-explicit");
|
|
2532
|
+
if (!isAbsoluteUrl(location)) {
|
|
2533
|
+
let trimmedMatches = matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1);
|
|
2534
|
+
location = normalizeTo(new URL(request.url), trimmedMatches, basename, location);
|
|
2535
|
+
response.headers.set("Location", location);
|
|
2536
|
+
}
|
|
2537
|
+
return response;
|
|
2538
|
+
}
|
|
2539
|
+
var invalidProtocols = [
|
|
2540
|
+
"about:",
|
|
2541
|
+
"blob:",
|
|
2542
|
+
"chrome:",
|
|
2543
|
+
"chrome-untrusted:",
|
|
2544
|
+
"content:",
|
|
2545
|
+
"data:",
|
|
2546
|
+
"devtools:",
|
|
2547
|
+
"file:",
|
|
2548
|
+
"filesystem:",
|
|
2549
|
+
"javascript:"
|
|
2550
|
+
];
|
|
2551
|
+
function hasInvalidProtocol(location) {
|
|
2552
|
+
try {
|
|
2553
|
+
return invalidProtocols.includes(new URL(location).protocol);
|
|
2554
|
+
} catch {
|
|
2555
|
+
return false;
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
function processRouteLoaderData(matches, results, pendingActionResult, isStaticHandler = false, skipLoaderErrorBubbling = false) {
|
|
2559
|
+
let loaderData = {};
|
|
2560
|
+
let errors = null;
|
|
2561
|
+
let statusCode;
|
|
2562
|
+
let foundError = false;
|
|
2563
|
+
let loaderHeaders = {};
|
|
2564
|
+
let pendingError = pendingActionResult && isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : void 0;
|
|
2565
|
+
matches.forEach((match) => {
|
|
2566
|
+
if (!(match.route.id in results)) return;
|
|
2567
|
+
let id = match.route.id;
|
|
2568
|
+
let result = results[id];
|
|
2569
|
+
invariant(!isRedirectResult(result), "Cannot handle redirect results in processLoaderData");
|
|
2570
|
+
if (isErrorResult(result)) {
|
|
2571
|
+
let error = result.error;
|
|
2572
|
+
if (pendingError !== void 0) {
|
|
2573
|
+
error = pendingError;
|
|
2574
|
+
pendingError = void 0;
|
|
2575
|
+
}
|
|
2576
|
+
errors = errors || {};
|
|
2577
|
+
if (skipLoaderErrorBubbling) errors[id] = error;
|
|
2578
|
+
else {
|
|
2579
|
+
let boundaryMatch = findNearestBoundary(matches, id);
|
|
2580
|
+
if (errors[boundaryMatch.route.id] == null) errors[boundaryMatch.route.id] = error;
|
|
2581
|
+
}
|
|
2582
|
+
if (!isStaticHandler) loaderData[id] = ResetLoaderDataSymbol;
|
|
2583
|
+
if (!foundError) {
|
|
2584
|
+
foundError = true;
|
|
2585
|
+
statusCode = isRouteErrorResponse(result.error) ? result.error.status : 500;
|
|
2586
|
+
}
|
|
2587
|
+
if (result.headers) loaderHeaders[id] = result.headers;
|
|
2588
|
+
} else {
|
|
2589
|
+
loaderData[id] = result.data;
|
|
2590
|
+
if (result.statusCode && result.statusCode !== 200 && !foundError) statusCode = result.statusCode;
|
|
2591
|
+
if (result.headers) loaderHeaders[id] = result.headers;
|
|
2592
|
+
}
|
|
2593
|
+
});
|
|
2594
|
+
if (pendingError !== void 0 && pendingActionResult) {
|
|
2595
|
+
errors = { [pendingActionResult[0]]: pendingError };
|
|
2596
|
+
if (pendingActionResult[2]) loaderData[pendingActionResult[2]] = void 0;
|
|
2597
|
+
}
|
|
2598
|
+
return {
|
|
2599
|
+
loaderData,
|
|
2600
|
+
errors,
|
|
2601
|
+
statusCode: statusCode || 200,
|
|
2602
|
+
loaderHeaders
|
|
2603
|
+
};
|
|
2604
|
+
}
|
|
2605
|
+
function findNearestBoundary(matches, routeId) {
|
|
2606
|
+
return (routeId ? matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1) : [...matches]).reverse().find((m) => m.route.ErrorBoundary != null || m.route.errorElement != null) || matches[0];
|
|
2607
|
+
}
|
|
2608
|
+
function getShortCircuitMatches(routes) {
|
|
2609
|
+
let route = routes.length === 1 ? routes[0] : routes.find((r) => r.index || !r.path || r.path === "/") || { id: `__shim-error-route__` };
|
|
2610
|
+
return {
|
|
2611
|
+
matches: [{
|
|
2612
|
+
params: {},
|
|
2613
|
+
pathname: "",
|
|
2614
|
+
pathnameBase: "",
|
|
2615
|
+
route
|
|
2616
|
+
}],
|
|
2617
|
+
route
|
|
2618
|
+
};
|
|
2619
|
+
}
|
|
2620
|
+
function getInternalRouterError(status, { pathname, routeId, method, type, message } = {}) {
|
|
2621
|
+
let statusText = "Unknown Server Error";
|
|
2622
|
+
let errorMessage = "Unknown @remix-run/router error";
|
|
2623
|
+
if (status === 400) {
|
|
2624
|
+
statusText = "Bad Request";
|
|
2625
|
+
if (method && pathname && routeId) errorMessage = `You made a ${method} request to "${pathname}" but did not provide a \`loader\` for route "${routeId}", so there is no way to handle the request.`;
|
|
2626
|
+
else if (type === "invalid-body") errorMessage = "Unable to encode submission body";
|
|
2627
|
+
} else if (status === 403) {
|
|
2628
|
+
statusText = "Forbidden";
|
|
2629
|
+
errorMessage = `Route "${routeId}" does not match URL "${pathname}"`;
|
|
2630
|
+
} else if (status === 404) {
|
|
2631
|
+
statusText = "Not Found";
|
|
2632
|
+
errorMessage = `No route matches URL "${pathname}"`;
|
|
2633
|
+
} else if (status === 405) {
|
|
2634
|
+
statusText = "Method Not Allowed";
|
|
2635
|
+
if (method && pathname && routeId) errorMessage = `You made a ${method.toUpperCase()} request to "${pathname}" but did not provide an \`action\` for route "${routeId}", so there is no way to handle the request.`;
|
|
2636
|
+
else if (method) errorMessage = `Invalid request method "${method.toUpperCase()}"`;
|
|
2637
|
+
}
|
|
2638
|
+
return new ErrorResponseImpl(status || 500, statusText, new Error(errorMessage), true);
|
|
2639
|
+
}
|
|
2640
|
+
function dataWithResponseInitToResponse(data) {
|
|
2641
|
+
return Response.json(data.data, data.init ?? void 0);
|
|
2642
|
+
}
|
|
2643
|
+
function dataWithResponseInitToErrorResponse(data) {
|
|
2644
|
+
return new ErrorResponseImpl(data.init?.status ?? 500, data.init?.statusText ?? "Internal Server Error", data.data);
|
|
2645
|
+
}
|
|
2646
|
+
function isDataStrategyResults(result) {
|
|
2647
|
+
return result != null && typeof result === "object" && Object.entries(result).every(([key, value]) => typeof key === "string" && isDataStrategyResult(value));
|
|
2648
|
+
}
|
|
2649
|
+
function isDataStrategyResult(result) {
|
|
2650
|
+
return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" || result.type === "error");
|
|
2651
|
+
}
|
|
2652
|
+
function isRedirectDataStrategyResult(result) {
|
|
2653
|
+
return isResponse(result.result) && redirectStatusCodes.has(result.result.status);
|
|
2654
|
+
}
|
|
2655
|
+
function isErrorResult(result) {
|
|
2656
|
+
return result.type === "error";
|
|
2657
|
+
}
|
|
2658
|
+
function isRedirectResult(result) {
|
|
2659
|
+
return (result && result.type) === "redirect";
|
|
2660
|
+
}
|
|
2661
|
+
function isDataWithResponseInit(value) {
|
|
2662
|
+
return typeof value === "object" && value != null && "type" in value && "data" in value && "init" in value && value.type === "DataWithResponseInit";
|
|
2663
|
+
}
|
|
2664
|
+
function isResponse(value) {
|
|
2665
|
+
return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined";
|
|
2666
|
+
}
|
|
2667
|
+
function isRedirectStatusCode(statusCode) {
|
|
2668
|
+
return redirectStatusCodes.has(statusCode);
|
|
2669
|
+
}
|
|
2670
|
+
function isRedirectResponse(result) {
|
|
2671
|
+
return isResponse(result) && isRedirectStatusCode(result.status) && result.headers.has("Location");
|
|
2672
|
+
}
|
|
2673
|
+
function isValidMethod(method) {
|
|
2674
|
+
return validRequestMethods.has(method.toUpperCase());
|
|
2675
|
+
}
|
|
2676
|
+
function isMutationMethod(method) {
|
|
2677
|
+
return validMutationMethods.has(method.toUpperCase());
|
|
2678
|
+
}
|
|
2679
|
+
function hasNakedIndexQuery(search) {
|
|
2680
|
+
return new URLSearchParams(search).getAll("index").some((v) => v === "");
|
|
2681
|
+
}
|
|
2682
|
+
function getTargetMatch(matches, location) {
|
|
2683
|
+
let search = typeof location === "string" ? parsePath(location).search : location.search;
|
|
2684
|
+
if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) return matches[matches.length - 1];
|
|
2685
|
+
let pathMatches = getPathContributingMatches(matches);
|
|
2686
|
+
return pathMatches[pathMatches.length - 1];
|
|
2687
|
+
}
|
|
2688
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/dom/ssr/markup.js
|
|
2689
|
+
/**
|
|
2690
|
+
* react-router v8.5.3
|
|
2691
|
+
*
|
|
2692
|
+
* Copyright (c) Remix Software Inc.
|
|
2693
|
+
*
|
|
2694
|
+
* This source code is licensed under the MIT license found in the
|
|
2695
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
2696
|
+
*
|
|
2697
|
+
* @license MIT
|
|
2698
|
+
*/
|
|
2699
|
+
var ESCAPE_LOOKUP = {
|
|
2700
|
+
"&": "\\u0026",
|
|
2701
|
+
">": "\\u003e",
|
|
2702
|
+
"<": "\\u003c",
|
|
2703
|
+
"\u2028": "\\u2028",
|
|
2704
|
+
"\u2029": "\\u2029"
|
|
2705
|
+
};
|
|
2706
|
+
var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
|
2707
|
+
function escapeHtml(html) {
|
|
2708
|
+
return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
|
|
2709
|
+
}
|
|
2710
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/vendor/turbo-stream-v2/utils.js
|
|
2711
|
+
/**
|
|
2712
|
+
* react-router v8.5.3
|
|
2713
|
+
*
|
|
2714
|
+
* Copyright (c) Remix Software Inc.
|
|
2715
|
+
*
|
|
2716
|
+
* This source code is licensed under the MIT license found in the
|
|
2717
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
2718
|
+
*
|
|
2719
|
+
* @license MIT
|
|
2720
|
+
*/
|
|
2721
|
+
var Deferred = class {
|
|
2722
|
+
promise;
|
|
2723
|
+
resolve;
|
|
2724
|
+
reject;
|
|
2725
|
+
constructor() {
|
|
2726
|
+
this.promise = new Promise((resolve, reject) => {
|
|
2727
|
+
this.resolve = resolve;
|
|
2728
|
+
this.reject = reject;
|
|
2729
|
+
});
|
|
2730
|
+
}
|
|
2731
|
+
};
|
|
2732
|
+
function createLineSplittingTransform() {
|
|
2733
|
+
const decoder = new TextDecoder();
|
|
2734
|
+
let leftover = "";
|
|
2735
|
+
return new TransformStream({
|
|
2736
|
+
transform(chunk, controller) {
|
|
2737
|
+
const str = decoder.decode(chunk, { stream: true });
|
|
2738
|
+
const parts = (leftover + str).split("\n");
|
|
2739
|
+
leftover = parts.pop() || "";
|
|
2740
|
+
for (const part of parts) controller.enqueue(part);
|
|
2741
|
+
},
|
|
2742
|
+
flush(controller) {
|
|
2743
|
+
if (leftover) controller.enqueue(leftover);
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/vendor/turbo-stream-v2/flatten.js
|
|
2748
|
+
/**
|
|
2749
|
+
* react-router v8.5.3
|
|
2750
|
+
*
|
|
2751
|
+
* Copyright (c) Remix Software Inc.
|
|
2752
|
+
*
|
|
2753
|
+
* This source code is licensed under the MIT license found in the
|
|
2754
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
2755
|
+
*
|
|
2756
|
+
* @license MIT
|
|
2757
|
+
*/
|
|
2758
|
+
var TIME_LIMIT_MS = 1;
|
|
2759
|
+
var getNow = () => Date.now();
|
|
2760
|
+
var yieldToMain = () => new Promise((resolve) => setTimeout(resolve, 0));
|
|
2761
|
+
async function flatten(input) {
|
|
2762
|
+
const { indices } = this;
|
|
2763
|
+
const existing = indices.get(input);
|
|
2764
|
+
if (existing) return [existing];
|
|
2765
|
+
if (input === void 0) return -7;
|
|
2766
|
+
if (input === null) return -5;
|
|
2767
|
+
if (Number.isNaN(input)) return -2;
|
|
2768
|
+
if (input === Number.POSITIVE_INFINITY) return -6;
|
|
2769
|
+
if (input === Number.NEGATIVE_INFINITY) return -3;
|
|
2770
|
+
if (input === 0 && 1 / input < 0) return -4;
|
|
2771
|
+
const index = this.index++;
|
|
2772
|
+
indices.set(input, index);
|
|
2773
|
+
const stack = [[input, index]];
|
|
2774
|
+
await stringify.call(this, stack);
|
|
2775
|
+
return index;
|
|
2776
|
+
}
|
|
2777
|
+
async function stringify(stack) {
|
|
2778
|
+
const { deferred, indices, plugins, postPlugins } = this;
|
|
2779
|
+
const str = this.stringified;
|
|
2780
|
+
let lastYieldTime = getNow();
|
|
2781
|
+
const flattenValue = (value) => {
|
|
2782
|
+
const existing = indices.get(value);
|
|
2783
|
+
if (existing) return [existing];
|
|
2784
|
+
if (value === void 0) return -7;
|
|
2785
|
+
if (value === null) return -5;
|
|
2786
|
+
if (Number.isNaN(value)) return -2;
|
|
2787
|
+
if (value === Number.POSITIVE_INFINITY) return -6;
|
|
2788
|
+
if (value === Number.NEGATIVE_INFINITY) return -3;
|
|
2789
|
+
if (value === 0 && 1 / value < 0) return -4;
|
|
2790
|
+
const index = this.index++;
|
|
2791
|
+
indices.set(value, index);
|
|
2792
|
+
stack.push([value, index]);
|
|
2793
|
+
return index;
|
|
2794
|
+
};
|
|
2795
|
+
let i = 0;
|
|
2796
|
+
while (stack.length > 0) {
|
|
2797
|
+
const now = getNow();
|
|
2798
|
+
if (++i % 6e3 === 0 && now - lastYieldTime >= TIME_LIMIT_MS) {
|
|
2799
|
+
await yieldToMain();
|
|
2800
|
+
lastYieldTime = getNow();
|
|
2801
|
+
}
|
|
2802
|
+
const [input, index] = stack.pop();
|
|
2803
|
+
const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flattenValue(k)}":${flattenValue(obj[k])}`).join(",");
|
|
2804
|
+
let error = null;
|
|
2805
|
+
switch (typeof input) {
|
|
2806
|
+
case "boolean":
|
|
2807
|
+
case "number":
|
|
2808
|
+
case "string":
|
|
2809
|
+
str[index] = JSON.stringify(input);
|
|
2810
|
+
break;
|
|
2811
|
+
case "bigint":
|
|
2812
|
+
str[index] = `["B","${input}"]`;
|
|
2813
|
+
break;
|
|
2814
|
+
case "symbol": {
|
|
2815
|
+
const keyFor = Symbol.keyFor(input);
|
|
2816
|
+
if (!keyFor) error = /* @__PURE__ */ new Error("Cannot encode symbol unless created with Symbol.for()");
|
|
2817
|
+
else str[index] = `["Y",${JSON.stringify(keyFor)}]`;
|
|
2818
|
+
break;
|
|
2819
|
+
}
|
|
2820
|
+
case "object": {
|
|
2821
|
+
if (!input) {
|
|
2822
|
+
str[index] = `-5`;
|
|
2823
|
+
break;
|
|
2824
|
+
}
|
|
2825
|
+
const isArray = Array.isArray(input);
|
|
2826
|
+
let pluginHandled = false;
|
|
2827
|
+
if (!isArray && plugins) for (const plugin of plugins) {
|
|
2828
|
+
const pluginResult = plugin(input);
|
|
2829
|
+
if (Array.isArray(pluginResult)) {
|
|
2830
|
+
pluginHandled = true;
|
|
2831
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
2832
|
+
str[index] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
2833
|
+
if (rest.length > 0) str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
|
|
2834
|
+
str[index] += "]";
|
|
2835
|
+
break;
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
if (!pluginHandled) {
|
|
2839
|
+
let result = isArray ? "[" : "{";
|
|
2840
|
+
if (isArray) {
|
|
2841
|
+
for (let i = 0; i < input.length; i++) result += (i ? "," : "") + (i in input ? flattenValue(input[i]) : -1);
|
|
2842
|
+
str[index] = `${result}]`;
|
|
2843
|
+
} else if (input instanceof Date) {
|
|
2844
|
+
const dateTime = input.getTime();
|
|
2845
|
+
str[index] = `["D",${Number.isNaN(dateTime) ? JSON.stringify("invalid") : dateTime}]`;
|
|
2846
|
+
} else if (input instanceof URL) str[index] = `["U",${JSON.stringify(input.href)}]`;
|
|
2847
|
+
else if (input instanceof RegExp) str[index] = `["R",${JSON.stringify(input.source)},${JSON.stringify(input.flags)}]`;
|
|
2848
|
+
else if (input instanceof Set) if (input.size > 0) str[index] = `["S",${[...input].map((val) => flattenValue(val)).join(",")}]`;
|
|
2849
|
+
else str[index] = `["S"]`;
|
|
2850
|
+
else if (input instanceof Map) if (input.size > 0) str[index] = `["M",${[...input].flatMap(([k, v]) => [flattenValue(k), flattenValue(v)]).join(",")}]`;
|
|
2851
|
+
else str[index] = `["M"]`;
|
|
2852
|
+
else if (input instanceof Promise) {
|
|
2853
|
+
str[index] = `["P",${index}]`;
|
|
2854
|
+
deferred[index] = input;
|
|
2855
|
+
} else if (input instanceof Error) {
|
|
2856
|
+
str[index] = `["E",${JSON.stringify(input.message)}`;
|
|
2857
|
+
if (input.name !== "Error") str[index] += `,${JSON.stringify(input.name)}`;
|
|
2858
|
+
str[index] += "]";
|
|
2859
|
+
} else if (Object.getPrototypeOf(input) === null) str[index] = `["N",{${partsForObj(input)}}]`;
|
|
2860
|
+
else if (isPlainObject(input)) str[index] = `{${partsForObj(input)}}`;
|
|
2861
|
+
else error = /* @__PURE__ */ new Error("Cannot encode object with prototype");
|
|
2862
|
+
}
|
|
2863
|
+
break;
|
|
2864
|
+
}
|
|
2865
|
+
default: {
|
|
2866
|
+
const isArray = Array.isArray(input);
|
|
2867
|
+
let pluginHandled = false;
|
|
2868
|
+
if (!isArray && plugins) for (const plugin of plugins) {
|
|
2869
|
+
const pluginResult = plugin(input);
|
|
2870
|
+
if (Array.isArray(pluginResult)) {
|
|
2871
|
+
pluginHandled = true;
|
|
2872
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
2873
|
+
str[index] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
2874
|
+
if (rest.length > 0) str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
|
|
2875
|
+
str[index] += "]";
|
|
2876
|
+
break;
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
if (!pluginHandled) error = /* @__PURE__ */ new Error("Cannot encode function or unexpected type");
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
if (error) {
|
|
2883
|
+
let pluginHandled = false;
|
|
2884
|
+
if (postPlugins) for (const plugin of postPlugins) {
|
|
2885
|
+
const pluginResult = plugin(input);
|
|
2886
|
+
if (Array.isArray(pluginResult)) {
|
|
2887
|
+
pluginHandled = true;
|
|
2888
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
2889
|
+
str[index] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
2890
|
+
if (rest.length > 0) str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
|
|
2891
|
+
str[index] += "]";
|
|
2892
|
+
break;
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
if (!pluginHandled) throw error;
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
var objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
2900
|
+
function isPlainObject(thing) {
|
|
2901
|
+
const proto = Object.getPrototypeOf(thing);
|
|
2902
|
+
return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
|
|
2903
|
+
}
|
|
2904
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/vendor/turbo-stream-v2/unflatten.js
|
|
2905
|
+
/**
|
|
2906
|
+
* react-router v8.5.3
|
|
2907
|
+
*
|
|
2908
|
+
* Copyright (c) Remix Software Inc.
|
|
2909
|
+
*
|
|
2910
|
+
* This source code is licensed under the MIT license found in the
|
|
2911
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
2912
|
+
*
|
|
2913
|
+
* @license MIT
|
|
2914
|
+
*/
|
|
2915
|
+
var globalObj = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
2916
|
+
function unflatten(parsed) {
|
|
2917
|
+
const { hydrated, values } = this;
|
|
2918
|
+
if (typeof parsed === "number") return hydrate.call(this, parsed);
|
|
2919
|
+
if (!Array.isArray(parsed) || !parsed.length) throw new SyntaxError();
|
|
2920
|
+
const startIndex = values.length;
|
|
2921
|
+
for (const value of parsed) values.push(value);
|
|
2922
|
+
hydrated.length = values.length;
|
|
2923
|
+
return hydrate.call(this, startIndex);
|
|
2924
|
+
}
|
|
2925
|
+
function hydrate(index) {
|
|
2926
|
+
const { hydrated, values, deferred, plugins } = this;
|
|
2927
|
+
let result;
|
|
2928
|
+
const stack = [[index, (v) => {
|
|
2929
|
+
result = v;
|
|
2930
|
+
}]];
|
|
2931
|
+
let postRun = [];
|
|
2932
|
+
while (stack.length > 0) {
|
|
2933
|
+
const [index, set] = stack.pop();
|
|
2934
|
+
switch (index) {
|
|
2935
|
+
case -7:
|
|
2936
|
+
set(void 0);
|
|
2937
|
+
continue;
|
|
2938
|
+
case -5:
|
|
2939
|
+
set(null);
|
|
2940
|
+
continue;
|
|
2941
|
+
case -2:
|
|
2942
|
+
set(NaN);
|
|
2943
|
+
continue;
|
|
2944
|
+
case -6:
|
|
2945
|
+
set(1e400);
|
|
2946
|
+
continue;
|
|
2947
|
+
case -3:
|
|
2948
|
+
set(-1e400);
|
|
2949
|
+
continue;
|
|
2950
|
+
case -4:
|
|
2951
|
+
set(-0);
|
|
2952
|
+
continue;
|
|
2953
|
+
}
|
|
2954
|
+
validateIndex(index, values.length);
|
|
2955
|
+
if (hydrated[index]) {
|
|
2956
|
+
set(hydrated[index]);
|
|
2957
|
+
continue;
|
|
2958
|
+
}
|
|
2959
|
+
const value = values[index];
|
|
2960
|
+
if (!value || typeof value !== "object") {
|
|
2961
|
+
hydrated[index] = value;
|
|
2962
|
+
set(value);
|
|
2963
|
+
continue;
|
|
2964
|
+
}
|
|
2965
|
+
if (Array.isArray(value)) if (typeof value[0] === "string") {
|
|
2966
|
+
const [type, b, c] = value;
|
|
2967
|
+
switch (type) {
|
|
2968
|
+
case "D":
|
|
2969
|
+
set(hydrated[index] = new Date(b));
|
|
2970
|
+
continue;
|
|
2971
|
+
case "U":
|
|
2972
|
+
set(hydrated[index] = new URL(b));
|
|
2973
|
+
continue;
|
|
2974
|
+
case "B":
|
|
2975
|
+
set(hydrated[index] = BigInt(b));
|
|
2976
|
+
continue;
|
|
2977
|
+
case "R":
|
|
2978
|
+
set(hydrated[index] = new RegExp(b, c));
|
|
2979
|
+
continue;
|
|
2980
|
+
case "Y":
|
|
2981
|
+
set(hydrated[index] = Symbol.for(b));
|
|
2982
|
+
continue;
|
|
2983
|
+
case "S":
|
|
2984
|
+
const newSet = /* @__PURE__ */ new Set();
|
|
2985
|
+
hydrated[index] = newSet;
|
|
2986
|
+
for (let i = value.length - 1; i > 0; i--) stack.push([value[i], (v) => {
|
|
2987
|
+
newSet.add(v);
|
|
2988
|
+
}]);
|
|
2989
|
+
set(newSet);
|
|
2990
|
+
continue;
|
|
2991
|
+
case "M":
|
|
2992
|
+
const map = /* @__PURE__ */ new Map();
|
|
2993
|
+
hydrated[index] = map;
|
|
2994
|
+
for (let i = value.length - 2; i > 0; i -= 2) {
|
|
2995
|
+
const r = [];
|
|
2996
|
+
stack.push([value[i + 1], (v) => {
|
|
2997
|
+
r[1] = v;
|
|
2998
|
+
}]);
|
|
2999
|
+
stack.push([value[i], (k) => {
|
|
3000
|
+
r[0] = k;
|
|
3001
|
+
}]);
|
|
3002
|
+
postRun.push(() => {
|
|
3003
|
+
map.set(r[0], r[1]);
|
|
3004
|
+
});
|
|
3005
|
+
}
|
|
3006
|
+
set(map);
|
|
3007
|
+
continue;
|
|
3008
|
+
case "N":
|
|
3009
|
+
const obj = Object.create(null);
|
|
3010
|
+
hydrated[index] = obj;
|
|
3011
|
+
for (const key of Object.keys(b).reverse()) {
|
|
3012
|
+
const r = [];
|
|
3013
|
+
stack.push([b[key], (v) => {
|
|
3014
|
+
r[1] = v;
|
|
3015
|
+
}]);
|
|
3016
|
+
stack.push([Number(key.slice(1)), (k) => {
|
|
3017
|
+
r[0] = k;
|
|
3018
|
+
}]);
|
|
3019
|
+
postRun.push(() => {
|
|
3020
|
+
obj[r[0]] = r[1];
|
|
3021
|
+
});
|
|
3022
|
+
}
|
|
3023
|
+
set(obj);
|
|
3024
|
+
continue;
|
|
3025
|
+
case "P":
|
|
3026
|
+
validateIndex(b, values.length);
|
|
3027
|
+
if (hydrated[b]) set(hydrated[index] = hydrated[b]);
|
|
3028
|
+
else {
|
|
3029
|
+
const d = new Deferred();
|
|
3030
|
+
const promise = d.promise;
|
|
3031
|
+
promise.status = "pending";
|
|
3032
|
+
promise.then((value) => {
|
|
3033
|
+
promise.status = "fulfilled";
|
|
3034
|
+
promise.value = value;
|
|
3035
|
+
}, (reason) => {
|
|
3036
|
+
promise.status = "rejected";
|
|
3037
|
+
promise.reason = reason;
|
|
3038
|
+
});
|
|
3039
|
+
deferred[b] = d;
|
|
3040
|
+
set(hydrated[index] = promise);
|
|
3041
|
+
}
|
|
3042
|
+
continue;
|
|
3043
|
+
case "E":
|
|
3044
|
+
const [, message, errorType] = value;
|
|
3045
|
+
let error = errorType && globalObj && SUPPORTED_ERROR_TYPES.includes(errorType) && errorType in globalObj && typeof globalObj[errorType] === "function" ? new globalObj[errorType](message) : new Error(message);
|
|
3046
|
+
hydrated[index] = error;
|
|
3047
|
+
set(error);
|
|
3048
|
+
continue;
|
|
3049
|
+
case "Z":
|
|
3050
|
+
validateIndex(b, values.length);
|
|
3051
|
+
set(hydrated[index] = hydrated[b]);
|
|
3052
|
+
continue;
|
|
3053
|
+
default:
|
|
3054
|
+
if (Array.isArray(plugins)) {
|
|
3055
|
+
const r = [];
|
|
3056
|
+
const vals = value.slice(1);
|
|
3057
|
+
for (let i = 0; i < vals.length; i++) {
|
|
3058
|
+
const v = vals[i];
|
|
3059
|
+
stack.push([v, (v) => {
|
|
3060
|
+
r[i] = v;
|
|
3061
|
+
}]);
|
|
3062
|
+
}
|
|
3063
|
+
postRun.push(() => {
|
|
3064
|
+
for (const plugin of plugins) {
|
|
3065
|
+
const result = plugin(value[0], ...r);
|
|
3066
|
+
if (result) {
|
|
3067
|
+
set(hydrated[index] = result.value);
|
|
3068
|
+
return;
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
throw new SyntaxError();
|
|
3072
|
+
});
|
|
3073
|
+
continue;
|
|
3074
|
+
}
|
|
3075
|
+
throw new SyntaxError();
|
|
3076
|
+
}
|
|
3077
|
+
} else {
|
|
3078
|
+
const array = [];
|
|
3079
|
+
hydrated[index] = array;
|
|
3080
|
+
for (let i = 0; i < value.length; i++) {
|
|
3081
|
+
const n = value[i];
|
|
3082
|
+
if (n !== -1) stack.push([n, (v) => {
|
|
3083
|
+
array[i] = v;
|
|
3084
|
+
}]);
|
|
3085
|
+
}
|
|
3086
|
+
set(array);
|
|
3087
|
+
continue;
|
|
3088
|
+
}
|
|
3089
|
+
else {
|
|
3090
|
+
const object = {};
|
|
3091
|
+
hydrated[index] = object;
|
|
3092
|
+
for (const key of Object.keys(value).reverse()) {
|
|
3093
|
+
const r = [];
|
|
3094
|
+
stack.push([value[key], (v) => {
|
|
3095
|
+
r[1] = v;
|
|
3096
|
+
}]);
|
|
3097
|
+
stack.push([Number(key.slice(1)), (k) => {
|
|
3098
|
+
r[0] = k;
|
|
3099
|
+
}]);
|
|
3100
|
+
postRun.push(() => {
|
|
3101
|
+
Object.defineProperty(object, r[0], {
|
|
3102
|
+
value: r[1],
|
|
3103
|
+
enumerable: true,
|
|
3104
|
+
configurable: true,
|
|
3105
|
+
writable: true
|
|
3106
|
+
});
|
|
3107
|
+
});
|
|
3108
|
+
}
|
|
3109
|
+
set(object);
|
|
3110
|
+
continue;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
while (postRun.length > 0) postRun.pop()();
|
|
3114
|
+
return result;
|
|
3115
|
+
}
|
|
3116
|
+
function validateIndex(index, length) {
|
|
3117
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= length) throw new SyntaxError();
|
|
3118
|
+
}
|
|
3119
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/vendor/turbo-stream-v2/turbo-stream.js
|
|
3120
|
+
/**
|
|
3121
|
+
* react-router v8.5.3
|
|
3122
|
+
*
|
|
3123
|
+
* Copyright (c) Remix Software Inc.
|
|
3124
|
+
*
|
|
3125
|
+
* This source code is licensed under the MIT license found in the
|
|
3126
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
3127
|
+
*
|
|
3128
|
+
* @license MIT
|
|
3129
|
+
*/
|
|
3130
|
+
async function decode(readable, options) {
|
|
3131
|
+
const { plugins } = options ?? {};
|
|
3132
|
+
const reader = readable.pipeThrough(createLineSplittingTransform()).getReader();
|
|
3133
|
+
const decoder = {
|
|
3134
|
+
values: [],
|
|
3135
|
+
hydrated: [],
|
|
3136
|
+
deferred: {},
|
|
3137
|
+
plugins
|
|
3138
|
+
};
|
|
3139
|
+
const decoded = await decodeInitial.call(decoder, reader);
|
|
3140
|
+
let donePromise;
|
|
3141
|
+
if (decoded.done) donePromise = Promise.resolve();
|
|
3142
|
+
else donePromise = decodeDeferred.call(decoder, reader).catch((reason) => {
|
|
3143
|
+
for (const deferred of Object.values(decoder.deferred)) deferred.reject(reason);
|
|
3144
|
+
throw reason;
|
|
3145
|
+
});
|
|
3146
|
+
const finished = donePromise.then(() => reader.closed);
|
|
3147
|
+
finished.catch(() => {});
|
|
3148
|
+
return {
|
|
3149
|
+
done: finished,
|
|
3150
|
+
value: decoded.value
|
|
3151
|
+
};
|
|
3152
|
+
}
|
|
3153
|
+
async function decodeInitial(reader) {
|
|
3154
|
+
const read = await reader.read();
|
|
3155
|
+
if (!read.value) throw new SyntaxError();
|
|
3156
|
+
let line;
|
|
3157
|
+
try {
|
|
3158
|
+
line = JSON.parse(read.value);
|
|
3159
|
+
} catch {
|
|
3160
|
+
throw new SyntaxError();
|
|
3161
|
+
}
|
|
3162
|
+
return {
|
|
3163
|
+
done: read.done,
|
|
3164
|
+
value: unflatten.call(this, line)
|
|
3165
|
+
};
|
|
3166
|
+
}
|
|
3167
|
+
async function decodeDeferred(reader) {
|
|
3168
|
+
let read = await reader.read();
|
|
3169
|
+
while (!read.done) {
|
|
3170
|
+
if (!read.value) continue;
|
|
3171
|
+
const line = read.value;
|
|
3172
|
+
switch (line[0]) {
|
|
3173
|
+
case "P": {
|
|
3174
|
+
const colonIndex = line.indexOf(":");
|
|
3175
|
+
const deferredId = Number(line.slice(1, colonIndex));
|
|
3176
|
+
const deferred = this.deferred[deferredId];
|
|
3177
|
+
if (!deferred) throw new Error(`Deferred ID ${deferredId} not found in stream`);
|
|
3178
|
+
const lineData = line.slice(colonIndex + 1);
|
|
3179
|
+
let jsonLine;
|
|
3180
|
+
try {
|
|
3181
|
+
jsonLine = JSON.parse(lineData);
|
|
3182
|
+
} catch {
|
|
3183
|
+
throw new SyntaxError();
|
|
3184
|
+
}
|
|
3185
|
+
const value = unflatten.call(this, jsonLine);
|
|
3186
|
+
deferred.resolve(value);
|
|
3187
|
+
break;
|
|
3188
|
+
}
|
|
3189
|
+
case "E": {
|
|
3190
|
+
const colonIndex = line.indexOf(":");
|
|
3191
|
+
const deferredId = Number(line.slice(1, colonIndex));
|
|
3192
|
+
const deferred = this.deferred[deferredId];
|
|
3193
|
+
if (!deferred) throw new Error(`Deferred ID ${deferredId} not found in stream`);
|
|
3194
|
+
const lineData = line.slice(colonIndex + 1);
|
|
3195
|
+
let jsonLine;
|
|
3196
|
+
try {
|
|
3197
|
+
jsonLine = JSON.parse(lineData);
|
|
3198
|
+
} catch {
|
|
3199
|
+
throw new SyntaxError();
|
|
3200
|
+
}
|
|
3201
|
+
const value = unflatten.call(this, jsonLine);
|
|
3202
|
+
deferred.reject(value);
|
|
3203
|
+
break;
|
|
3204
|
+
}
|
|
3205
|
+
default: throw new SyntaxError();
|
|
3206
|
+
}
|
|
3207
|
+
read = await reader.read();
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
function encode(input, options) {
|
|
3211
|
+
const { onComplete, plugins, postPlugins, signal } = options ?? {};
|
|
3212
|
+
const encoder = {
|
|
3213
|
+
deferred: {},
|
|
3214
|
+
index: 0,
|
|
3215
|
+
indices: /* @__PURE__ */ new Map(),
|
|
3216
|
+
stringified: [],
|
|
3217
|
+
plugins,
|
|
3218
|
+
postPlugins,
|
|
3219
|
+
signal
|
|
3220
|
+
};
|
|
3221
|
+
const textEncoder = new TextEncoder();
|
|
3222
|
+
let lastSentIndex = 0;
|
|
3223
|
+
let cancelled = false;
|
|
3224
|
+
return new ReadableStream({
|
|
3225
|
+
async start(controller) {
|
|
3226
|
+
const enqueue = (chunk) => {
|
|
3227
|
+
if (!cancelled) controller.enqueue(chunk);
|
|
3228
|
+
};
|
|
3229
|
+
const id = await flatten.call(encoder, input);
|
|
3230
|
+
if (Array.isArray(id)) throw new Error("This should never happen");
|
|
3231
|
+
if (id < 0) enqueue(textEncoder.encode(`${id}\n`));
|
|
3232
|
+
else {
|
|
3233
|
+
enqueue(textEncoder.encode(`[${encoder.stringified.join(",")}]\n`));
|
|
3234
|
+
lastSentIndex = encoder.stringified.length - 1;
|
|
3235
|
+
}
|
|
3236
|
+
const seenPromises = /* @__PURE__ */ new WeakSet();
|
|
3237
|
+
let processingChain = Promise.resolve();
|
|
3238
|
+
if (Object.keys(encoder.deferred).length) {
|
|
3239
|
+
let raceDone;
|
|
3240
|
+
const racePromise = new Promise((resolve, reject) => {
|
|
3241
|
+
raceDone = resolve;
|
|
3242
|
+
if (signal) {
|
|
3243
|
+
const rejectPromise = () => reject(signal.reason || /* @__PURE__ */ new Error("Signal was aborted."));
|
|
3244
|
+
if (signal.aborted) rejectPromise();
|
|
3245
|
+
else signal.addEventListener("abort", (event) => {
|
|
3246
|
+
rejectPromise();
|
|
3247
|
+
});
|
|
3248
|
+
}
|
|
3249
|
+
});
|
|
3250
|
+
while (Object.keys(encoder.deferred).length > 0) {
|
|
3251
|
+
for (const [deferredId, deferred] of Object.entries(encoder.deferred)) {
|
|
3252
|
+
if (seenPromises.has(deferred)) continue;
|
|
3253
|
+
seenPromises.add(encoder.deferred[Number(deferredId)] = Promise.race([racePromise, deferred]).then((resolved) => {
|
|
3254
|
+
processingChain = processingChain.then(async () => {
|
|
3255
|
+
const id = await flatten.call(encoder, resolved);
|
|
3256
|
+
if (Array.isArray(id)) {
|
|
3257
|
+
enqueue(textEncoder.encode(`P${deferredId}:[["Z",${id[0]}]]\n`));
|
|
3258
|
+
encoder.index++;
|
|
3259
|
+
lastSentIndex++;
|
|
3260
|
+
} else if (id < 0) enqueue(textEncoder.encode(`P${deferredId}:${id}\n`));
|
|
3261
|
+
else {
|
|
3262
|
+
const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
|
|
3263
|
+
enqueue(textEncoder.encode(`P${deferredId}:[${values}]\n`));
|
|
3264
|
+
lastSentIndex = encoder.stringified.length - 1;
|
|
3265
|
+
}
|
|
3266
|
+
});
|
|
3267
|
+
return processingChain;
|
|
3268
|
+
}, (reason) => {
|
|
3269
|
+
processingChain = processingChain.then(async () => {
|
|
3270
|
+
if (!reason || typeof reason !== "object" || !(reason instanceof Error)) reason = /* @__PURE__ */ new Error("An unknown error occurred");
|
|
3271
|
+
const id = await flatten.call(encoder, reason);
|
|
3272
|
+
if (Array.isArray(id)) {
|
|
3273
|
+
enqueue(textEncoder.encode(`E${deferredId}:[["Z",${id[0]}]]\n`));
|
|
3274
|
+
encoder.index++;
|
|
3275
|
+
lastSentIndex++;
|
|
3276
|
+
} else if (id < 0) enqueue(textEncoder.encode(`E${deferredId}:${id}\n`));
|
|
3277
|
+
else {
|
|
3278
|
+
const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
|
|
3279
|
+
enqueue(textEncoder.encode(`E${deferredId}:[${values}]\n`));
|
|
3280
|
+
lastSentIndex = encoder.stringified.length - 1;
|
|
3281
|
+
}
|
|
3282
|
+
});
|
|
3283
|
+
return processingChain;
|
|
3284
|
+
}).finally(() => {
|
|
3285
|
+
delete encoder.deferred[Number(deferredId)];
|
|
3286
|
+
}));
|
|
3287
|
+
}
|
|
3288
|
+
await Promise.race(Object.values(encoder.deferred));
|
|
3289
|
+
}
|
|
3290
|
+
raceDone();
|
|
3291
|
+
}
|
|
3292
|
+
await Promise.all(Object.values(encoder.deferred));
|
|
3293
|
+
await processingChain;
|
|
3294
|
+
if (!cancelled) controller.close();
|
|
3295
|
+
onComplete?.();
|
|
3296
|
+
},
|
|
3297
|
+
cancel() {
|
|
3298
|
+
cancelled = true;
|
|
3299
|
+
}
|
|
3300
|
+
});
|
|
3301
|
+
}
|
|
3302
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/dom/ssr/single-fetch.js
|
|
3303
|
+
/**
|
|
3304
|
+
* react-router v8.5.3
|
|
3305
|
+
*
|
|
3306
|
+
* Copyright (c) Remix Software Inc.
|
|
3307
|
+
*
|
|
3308
|
+
* This source code is licensed under the MIT license found in the
|
|
3309
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
3310
|
+
*
|
|
3311
|
+
* @license MIT
|
|
3312
|
+
*/
|
|
3313
|
+
var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
|
|
3314
|
+
var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
3315
|
+
100,
|
|
3316
|
+
101,
|
|
3317
|
+
204,
|
|
3318
|
+
205
|
|
3319
|
+
]);
|
|
3320
|
+
function StreamTransfer({ context, identifier, reader, textDecoder, nonce }) {
|
|
3321
|
+
if (!context.renderMeta || !context.renderMeta.didRenderScripts) return null;
|
|
3322
|
+
if (!context.renderMeta.streamCache) context.renderMeta.streamCache = {};
|
|
3323
|
+
let { streamCache } = context.renderMeta;
|
|
3324
|
+
let promise = streamCache[identifier];
|
|
3325
|
+
if (!promise) promise = streamCache[identifier] = reader.read().then((result) => {
|
|
3326
|
+
streamCache[identifier].result = {
|
|
3327
|
+
done: result.done,
|
|
3328
|
+
value: textDecoder.decode(result.value, { stream: true })
|
|
3329
|
+
};
|
|
3330
|
+
}).catch((e) => {
|
|
3331
|
+
streamCache[identifier].error = e;
|
|
3332
|
+
});
|
|
3333
|
+
if (promise.error) throw promise.error;
|
|
3334
|
+
if (promise.result === void 0) throw promise;
|
|
3335
|
+
let { done, value } = promise.result;
|
|
3336
|
+
let scriptTag = value ? /* @__PURE__ */ import_react.createElement("script", {
|
|
3337
|
+
nonce,
|
|
3338
|
+
dangerouslySetInnerHTML: { __html: `window.__reactRouterContext.streamController.enqueue(${escapeHtml(JSON.stringify(value))});` }
|
|
3339
|
+
}) : null;
|
|
3340
|
+
if (done) return /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, scriptTag, /* @__PURE__ */ import_react.createElement("script", {
|
|
3341
|
+
nonce,
|
|
3342
|
+
dangerouslySetInnerHTML: { __html: `window.__reactRouterContext.streamController.close();` }
|
|
3343
|
+
}));
|
|
3344
|
+
else return /* @__PURE__ */ import_react.createElement(import_react.Fragment, null, scriptTag, /* @__PURE__ */ import_react.createElement(import_react.Suspense, null, /* @__PURE__ */ import_react.createElement(StreamTransfer, {
|
|
3345
|
+
context,
|
|
3346
|
+
identifier: identifier + 1,
|
|
3347
|
+
reader,
|
|
3348
|
+
textDecoder,
|
|
3349
|
+
nonce
|
|
3350
|
+
})));
|
|
3351
|
+
}
|
|
3352
|
+
function singleFetchUrl(reqUrl, extension, serverOrigin) {
|
|
3353
|
+
let url = typeof reqUrl === "string" ? new URL(reqUrl, serverOrigin ?? (typeof window === "undefined" ? "server://singlefetch/" : window.location.origin)) : new URL(reqUrl);
|
|
3354
|
+
if (serverOrigin && url.origin !== serverOrigin) url = new URL(url.pathname + url.search + url.hash, serverOrigin);
|
|
3355
|
+
if (url.pathname.endsWith("/")) url.pathname = `${url.pathname}_.${extension}`;
|
|
3356
|
+
else url.pathname = `${url.pathname}.${extension}`;
|
|
3357
|
+
return url;
|
|
3358
|
+
}
|
|
3359
|
+
function decodeViaTurboStream(body, global) {
|
|
3360
|
+
return decode(body, { plugins: [(type, ...rest) => {
|
|
3361
|
+
if (type === "SanitizedError") {
|
|
3362
|
+
let [name, message, stack] = rest;
|
|
3363
|
+
let Constructor = Error;
|
|
3364
|
+
if (name && SUPPORTED_ERROR_TYPES.includes(name) && name in global && typeof global[name] === "function") Constructor = global[name];
|
|
3365
|
+
let error = new Constructor(message);
|
|
3366
|
+
error.stack = stack;
|
|
3367
|
+
return { value: error };
|
|
3368
|
+
}
|
|
3369
|
+
if (type === "ErrorResponse") {
|
|
3370
|
+
let [data, status, statusText] = rest;
|
|
3371
|
+
return { value: new ErrorResponseImpl(status, statusText, data) };
|
|
3372
|
+
}
|
|
3373
|
+
if (type === "SingleFetchRedirect") return { value: { [SingleFetchRedirectSymbol]: rest[0] } };
|
|
3374
|
+
if (type === "SingleFetchClassInstance") return { value: rest[0] };
|
|
3375
|
+
if (type === "SingleFetchFallback") return { value: void 0 };
|
|
3376
|
+
}] });
|
|
3377
|
+
}
|
|
3378
|
+
// node_modules/.pnpm/react-router@8.5.3_@types+react-dom@19.3.0_@types+react@19.3.3__@types+react@19.3.3_rea_2af81234aa7c8ca5cc115b818069da17/node_modules/react-router/dist/production/lib/dom/ssr/fog-of-war.js
|
|
3379
|
+
/**
|
|
3380
|
+
* react-router v8.5.3
|
|
3381
|
+
*
|
|
3382
|
+
* Copyright (c) Remix Software Inc.
|
|
3383
|
+
*
|
|
3384
|
+
* This source code is licensed under the MIT license found in the
|
|
3385
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
3386
|
+
*
|
|
3387
|
+
* @license MIT
|
|
3388
|
+
*/
|
|
3389
|
+
function isFogOfWarEnabled(routeDiscovery, ssr) {
|
|
3390
|
+
return routeDiscovery.mode === "lazy" && ssr;
|
|
3391
|
+
}
|
|
3392
|
+
var MANIFEST_MATCH_COST_LIMIT = 5e4;
|
|
3393
|
+
var MANIFEST_MATCH_COST_SEGMENT_THRESHOLD = 10;
|
|
3394
|
+
function shouldUseInitialRouteDiscovery(pathname, matchCost = 0) {
|
|
3395
|
+
let segmentCount = pathname.split("/").length - 1;
|
|
3396
|
+
return Math.max(segmentCount - 1, 0) * pathname.length + 1 > 7680 || segmentCount > MANIFEST_MATCH_COST_SEGMENT_THRESHOLD && segmentCount * matchCost > MANIFEST_MATCH_COST_LIMIT;
|
|
3397
|
+
}
|
|
3398
|
+
function getPartialManifest({ sri, ...manifest }, router) {
|
|
3399
|
+
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
|
|
3400
|
+
let segments = router.state.location.pathname.split("/").filter(Boolean);
|
|
3401
|
+
let paths = ["/"];
|
|
3402
|
+
segments.pop();
|
|
3403
|
+
while (segments.length > 0) {
|
|
3404
|
+
paths.push(`/${segments.join("/")}`);
|
|
3405
|
+
segments.pop();
|
|
3406
|
+
}
|
|
3407
|
+
paths.forEach((path) => {
|
|
3408
|
+
let matches = router.match(path);
|
|
3409
|
+
if (matches) matches.forEach((m) => routeIds.add(m.route.id));
|
|
3410
|
+
});
|
|
3411
|
+
let initialRoutes = [...routeIds].reduce((acc, id) => Object.assign(acc, { [id]: manifest.routes[id] }), {});
|
|
3412
|
+
return {
|
|
3413
|
+
...manifest,
|
|
3414
|
+
routes: initialRoutes,
|
|
3415
|
+
sri: sri ? true : void 0
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3418
|
+
function getManifestPath(_manifestPath, basename) {
|
|
3419
|
+
let manifestPath = _manifestPath || "/__manifest";
|
|
3420
|
+
return basename == null ? manifestPath : joinPaths([basename, manifestPath]);
|
|
3421
|
+
}
|
|
3422
|
+
// app/cloudflare-context.ts
|
|
3423
|
+
var cloudflareContext = createContext();
|
|
3424
|
+
export { warning as $, createDataFunctionUrl as A, redirect as B, isResponse as C, RouterContextProvider as D, ErrorResponseImpl as E, isRouteErrorResponse as F, stripBasename as G, removeTrailingSlash as H, joinPaths as I, validateDocumentNavigationTarget as J, require_react as K, matchPath as L, getResolveToMatches as M, getRoutePattern as N, convertRouteMatchToUiMatch as O, isBrowser as P, parsePath as Q, matchRoutes as R, isRedirectStatusCode as S, instrumentationResultMetaContext as T, replace as U, redirectDocument as V, resolveTo as W, createPath as X, validateNavigationTarget as Y, invariant as Z, getStaticContextFromError as _, shouldUseInitialRouteDiscovery as a, isMutationMethod as b, StreamTransfer as c, encode as d, ABSOLUTE_URL_REGEX as et, escapeHtml as f, createStaticHandler as g, IDLE_NAVIGATION as h, isFogOfWarEnabled as i, defaultMapRouteProperties as j, convertRoutesToDataRoutes as k, decodeViaTurboStream as l, IDLE_FETCHER as m, getManifestPath as n, NO_BODY_STATUS_CODES as o, IDLE_BLOCKER as p, getNavigatorCurrentUrl as q, getPartialManifest as r, SingleFetchRedirectSymbol as s, cloudflareContext as t, PROTOCOL_RELATIVE_URL_REGEX as tt, singleFetchUrl as u, hasInvalidProtocol as v, instrumentHandler as w, isRedirectResponse as x, isDataWithResponseInit as y, parseToInfo as z };
|
|
3425
|
+
|
|
3426
|
+
//# sourceMappingURL=cloudflare-context-CIZdXilT.js.map
|