create-bluecopa-react-app 1.0.12 → 1.0.14
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/package.json +1 -1
- package/templates/latest/Agent.md +639 -521
- package/templates/latest/app/routes/websocket.tsx +5 -4
- package/templates/latest/app/routes.tsx +5 -8
- package/templates/latest/components.json +1 -2
- package/templates/latest/dist/assets/{__federation_expose_App-B2IoFaIA.js → __federation_expose_App-BIH7hwj_.js} +3 -4
- package/templates/latest/dist/assets/{home-BBY02MnI.js → client-CsvW46cT.js} +18448 -929
- package/templates/latest/dist/assets/{index-CNNS7Foy.js → index-CFECuPSy.js} +3 -4
- package/templates/latest/dist/assets/remoteEntry.css +151 -19
- package/templates/latest/dist/assets/remoteEntry.js +1 -1
- package/templates/latest/dist/favicon.ico +0 -0
- package/templates/latest/dist/index.html +2 -3
- package/templates/latest/package-lock.json +203 -203
- package/templates/latest/package.json +1 -1
- package/templates/latest/dist/assets/client-LFBsfOjG.js +0 -2775
- package/templates/latest/dist/assets/index-D5og7-RT-BA7DwZw1.js +0 -9917
- package/templates/latest/dist/avatars/shadcn.svg +0 -6
- /package/templates/latest/app/routes/{home.tsx → dashboard.tsx} +0 -0
|
@@ -1,2775 +0,0 @@
|
|
|
1
|
-
System.register(['./__federation_fn_import-CzfA7kmP.js', './index-D5og7-RT-BA7DwZw1.js', './index-BzNimew1.js', './index-DMFtQdNS.js'], (function (exports, module) {
|
|
2
|
-
'use strict';
|
|
3
|
-
var importShared, jsxRuntimeExports, FR, s1, PA, getDefaultExportFromCjs, requireReactDom;
|
|
4
|
-
return {
|
|
5
|
-
setters: [module => {
|
|
6
|
-
importShared = module.importShared;
|
|
7
|
-
}, module => {
|
|
8
|
-
jsxRuntimeExports = module.j;
|
|
9
|
-
FR = module.F;
|
|
10
|
-
s1 = module.s;
|
|
11
|
-
PA = module.P;
|
|
12
|
-
}, module => {
|
|
13
|
-
getDefaultExportFromCjs = module.g;
|
|
14
|
-
}, module => {
|
|
15
|
-
requireReactDom = module.r;
|
|
16
|
-
}],
|
|
17
|
-
execute: (async function () {
|
|
18
|
-
|
|
19
|
-
exports({
|
|
20
|
-
A: App,
|
|
21
|
-
B: BrowserRouter,
|
|
22
|
-
M: MemoryRouter
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
var PopStateEventType = "popstate";
|
|
26
|
-
function createMemoryHistory(options = {}) {
|
|
27
|
-
let { initialEntries = ["/"], initialIndex, v5Compat = false } = options;
|
|
28
|
-
let entries;
|
|
29
|
-
entries = initialEntries.map(
|
|
30
|
-
(entry, index2) => createMemoryLocation(
|
|
31
|
-
entry,
|
|
32
|
-
typeof entry === "string" ? null : entry.state,
|
|
33
|
-
index2 === 0 ? "default" : void 0
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
let index = clampIndex(
|
|
37
|
-
initialIndex == null ? entries.length - 1 : initialIndex
|
|
38
|
-
);
|
|
39
|
-
let action = "POP";
|
|
40
|
-
let listener = null;
|
|
41
|
-
function clampIndex(n) {
|
|
42
|
-
return Math.min(Math.max(n, 0), entries.length - 1);
|
|
43
|
-
}
|
|
44
|
-
function getCurrentLocation() {
|
|
45
|
-
return entries[index];
|
|
46
|
-
}
|
|
47
|
-
function createMemoryLocation(to, state = null, key) {
|
|
48
|
-
let location = createLocation(
|
|
49
|
-
entries ? getCurrentLocation().pathname : "/",
|
|
50
|
-
to,
|
|
51
|
-
state,
|
|
52
|
-
key
|
|
53
|
-
);
|
|
54
|
-
warning(
|
|
55
|
-
location.pathname.charAt(0) === "/",
|
|
56
|
-
`relative pathnames are not supported in memory history: ${JSON.stringify(
|
|
57
|
-
to
|
|
58
|
-
)}`
|
|
59
|
-
);
|
|
60
|
-
return location;
|
|
61
|
-
}
|
|
62
|
-
function createHref2(to) {
|
|
63
|
-
return typeof to === "string" ? to : createPath(to);
|
|
64
|
-
}
|
|
65
|
-
let history = {
|
|
66
|
-
get index() {
|
|
67
|
-
return index;
|
|
68
|
-
},
|
|
69
|
-
get action() {
|
|
70
|
-
return action;
|
|
71
|
-
},
|
|
72
|
-
get location() {
|
|
73
|
-
return getCurrentLocation();
|
|
74
|
-
},
|
|
75
|
-
createHref: createHref2,
|
|
76
|
-
createURL(to) {
|
|
77
|
-
return new URL(createHref2(to), "http://localhost");
|
|
78
|
-
},
|
|
79
|
-
encodeLocation(to) {
|
|
80
|
-
let path = typeof to === "string" ? parsePath(to) : to;
|
|
81
|
-
return {
|
|
82
|
-
pathname: path.pathname || "",
|
|
83
|
-
search: path.search || "",
|
|
84
|
-
hash: path.hash || ""
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
push(to, state) {
|
|
88
|
-
action = "PUSH";
|
|
89
|
-
let nextLocation = createMemoryLocation(to, state);
|
|
90
|
-
index += 1;
|
|
91
|
-
entries.splice(index, entries.length, nextLocation);
|
|
92
|
-
if (v5Compat && listener) {
|
|
93
|
-
listener({ action, location: nextLocation, delta: 1 });
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
replace(to, state) {
|
|
97
|
-
action = "REPLACE";
|
|
98
|
-
let nextLocation = createMemoryLocation(to, state);
|
|
99
|
-
entries[index] = nextLocation;
|
|
100
|
-
if (v5Compat && listener) {
|
|
101
|
-
listener({ action, location: nextLocation, delta: 0 });
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
go(delta) {
|
|
105
|
-
action = "POP";
|
|
106
|
-
let nextIndex = clampIndex(index + delta);
|
|
107
|
-
let nextLocation = entries[nextIndex];
|
|
108
|
-
index = nextIndex;
|
|
109
|
-
if (listener) {
|
|
110
|
-
listener({ action, location: nextLocation, delta });
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
listen(fn) {
|
|
114
|
-
listener = fn;
|
|
115
|
-
return () => {
|
|
116
|
-
listener = null;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
return history;
|
|
121
|
-
}
|
|
122
|
-
function createBrowserHistory(options = {}) {
|
|
123
|
-
function createBrowserLocation(window2, globalHistory) {
|
|
124
|
-
let { pathname, search, hash } = window2.location;
|
|
125
|
-
return createLocation(
|
|
126
|
-
"",
|
|
127
|
-
{ pathname, search, hash },
|
|
128
|
-
// state defaults to `null` because `window.history.state` does
|
|
129
|
-
globalHistory.state && globalHistory.state.usr || null,
|
|
130
|
-
globalHistory.state && globalHistory.state.key || "default"
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
function createBrowserHref(window2, to) {
|
|
134
|
-
return typeof to === "string" ? to : createPath(to);
|
|
135
|
-
}
|
|
136
|
-
return getUrlBasedHistory(
|
|
137
|
-
createBrowserLocation,
|
|
138
|
-
createBrowserHref,
|
|
139
|
-
null,
|
|
140
|
-
options
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
function invariant(value, message) {
|
|
144
|
-
if (value === false || value === null || typeof value === "undefined") {
|
|
145
|
-
throw new Error(message);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function warning(cond, message) {
|
|
149
|
-
if (!cond) {
|
|
150
|
-
if (typeof console !== "undefined") console.warn(message);
|
|
151
|
-
try {
|
|
152
|
-
throw new Error(message);
|
|
153
|
-
} catch (e) {
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
function createKey() {
|
|
158
|
-
return Math.random().toString(36).substring(2, 10);
|
|
159
|
-
}
|
|
160
|
-
function getHistoryState(location, index) {
|
|
161
|
-
return {
|
|
162
|
-
usr: location.state,
|
|
163
|
-
key: location.key,
|
|
164
|
-
idx: index
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function createLocation(current, to, state = null, key) {
|
|
168
|
-
let location = {
|
|
169
|
-
pathname: typeof current === "string" ? current : current.pathname,
|
|
170
|
-
search: "",
|
|
171
|
-
hash: "",
|
|
172
|
-
...typeof to === "string" ? parsePath(to) : to,
|
|
173
|
-
state,
|
|
174
|
-
// TODO: This could be cleaned up. push/replace should probably just take
|
|
175
|
-
// full Locations now and avoid the need to run through this flow at all
|
|
176
|
-
// But that's a pretty big refactor to the current test suite so going to
|
|
177
|
-
// keep as is for the time being and just let any incoming keys take precedence
|
|
178
|
-
key: to && to.key || key || createKey()
|
|
179
|
-
};
|
|
180
|
-
return location;
|
|
181
|
-
}
|
|
182
|
-
function createPath({
|
|
183
|
-
pathname = "/",
|
|
184
|
-
search = "",
|
|
185
|
-
hash = ""
|
|
186
|
-
}) {
|
|
187
|
-
if (search && search !== "?")
|
|
188
|
-
pathname += search.charAt(0) === "?" ? search : "?" + search;
|
|
189
|
-
if (hash && hash !== "#")
|
|
190
|
-
pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
|
191
|
-
return pathname;
|
|
192
|
-
}
|
|
193
|
-
function parsePath(path) {
|
|
194
|
-
let parsedPath = {};
|
|
195
|
-
if (path) {
|
|
196
|
-
let hashIndex = path.indexOf("#");
|
|
197
|
-
if (hashIndex >= 0) {
|
|
198
|
-
parsedPath.hash = path.substring(hashIndex);
|
|
199
|
-
path = path.substring(0, hashIndex);
|
|
200
|
-
}
|
|
201
|
-
let searchIndex = path.indexOf("?");
|
|
202
|
-
if (searchIndex >= 0) {
|
|
203
|
-
parsedPath.search = path.substring(searchIndex);
|
|
204
|
-
path = path.substring(0, searchIndex);
|
|
205
|
-
}
|
|
206
|
-
if (path) {
|
|
207
|
-
parsedPath.pathname = path;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return parsedPath;
|
|
211
|
-
}
|
|
212
|
-
function getUrlBasedHistory(getLocation, createHref2, validateLocation, options = {}) {
|
|
213
|
-
let { window: window2 = document.defaultView, v5Compat = false } = options;
|
|
214
|
-
let globalHistory = window2.history;
|
|
215
|
-
let action = "POP";
|
|
216
|
-
let listener = null;
|
|
217
|
-
let index = getIndex();
|
|
218
|
-
if (index == null) {
|
|
219
|
-
index = 0;
|
|
220
|
-
globalHistory.replaceState({ ...globalHistory.state, idx: index }, "");
|
|
221
|
-
}
|
|
222
|
-
function getIndex() {
|
|
223
|
-
let state = globalHistory.state || { idx: null };
|
|
224
|
-
return state.idx;
|
|
225
|
-
}
|
|
226
|
-
function handlePop() {
|
|
227
|
-
action = "POP";
|
|
228
|
-
let nextIndex = getIndex();
|
|
229
|
-
let delta = nextIndex == null ? null : nextIndex - index;
|
|
230
|
-
index = nextIndex;
|
|
231
|
-
if (listener) {
|
|
232
|
-
listener({ action, location: history.location, delta });
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function push(to, state) {
|
|
236
|
-
action = "PUSH";
|
|
237
|
-
let location = createLocation(history.location, to, state);
|
|
238
|
-
index = getIndex() + 1;
|
|
239
|
-
let historyState = getHistoryState(location, index);
|
|
240
|
-
let url = history.createHref(location);
|
|
241
|
-
try {
|
|
242
|
-
globalHistory.pushState(historyState, "", url);
|
|
243
|
-
} catch (error) {
|
|
244
|
-
if (error instanceof DOMException && error.name === "DataCloneError") {
|
|
245
|
-
throw error;
|
|
246
|
-
}
|
|
247
|
-
window2.location.assign(url);
|
|
248
|
-
}
|
|
249
|
-
if (v5Compat && listener) {
|
|
250
|
-
listener({ action, location: history.location, delta: 1 });
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function replace2(to, state) {
|
|
254
|
-
action = "REPLACE";
|
|
255
|
-
let location = createLocation(history.location, to, state);
|
|
256
|
-
index = getIndex();
|
|
257
|
-
let historyState = getHistoryState(location, index);
|
|
258
|
-
let url = history.createHref(location);
|
|
259
|
-
globalHistory.replaceState(historyState, "", url);
|
|
260
|
-
if (v5Compat && listener) {
|
|
261
|
-
listener({ action, location: history.location, delta: 0 });
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function createURL(to) {
|
|
265
|
-
return createBrowserURLImpl(to);
|
|
266
|
-
}
|
|
267
|
-
let history = {
|
|
268
|
-
get action() {
|
|
269
|
-
return action;
|
|
270
|
-
},
|
|
271
|
-
get location() {
|
|
272
|
-
return getLocation(window2, globalHistory);
|
|
273
|
-
},
|
|
274
|
-
listen(fn) {
|
|
275
|
-
if (listener) {
|
|
276
|
-
throw new Error("A history only accepts one active listener");
|
|
277
|
-
}
|
|
278
|
-
window2.addEventListener(PopStateEventType, handlePop);
|
|
279
|
-
listener = fn;
|
|
280
|
-
return () => {
|
|
281
|
-
window2.removeEventListener(PopStateEventType, handlePop);
|
|
282
|
-
listener = null;
|
|
283
|
-
};
|
|
284
|
-
},
|
|
285
|
-
createHref(to) {
|
|
286
|
-
return createHref2(window2, to);
|
|
287
|
-
},
|
|
288
|
-
createURL,
|
|
289
|
-
encodeLocation(to) {
|
|
290
|
-
let url = createURL(to);
|
|
291
|
-
return {
|
|
292
|
-
pathname: url.pathname,
|
|
293
|
-
search: url.search,
|
|
294
|
-
hash: url.hash
|
|
295
|
-
};
|
|
296
|
-
},
|
|
297
|
-
push,
|
|
298
|
-
replace: replace2,
|
|
299
|
-
go(n) {
|
|
300
|
-
return globalHistory.go(n);
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
return history;
|
|
304
|
-
}
|
|
305
|
-
function createBrowserURLImpl(to, isAbsolute = false) {
|
|
306
|
-
let base = "http://localhost";
|
|
307
|
-
if (typeof window !== "undefined") {
|
|
308
|
-
base = window.location.origin !== "null" ? window.location.origin : window.location.href;
|
|
309
|
-
}
|
|
310
|
-
invariant(base, "No window.location.(origin|href) available to create URL");
|
|
311
|
-
let href = typeof to === "string" ? to : createPath(to);
|
|
312
|
-
href = href.replace(/ $/, "%20");
|
|
313
|
-
if (!isAbsolute && href.startsWith("//")) {
|
|
314
|
-
href = base + href;
|
|
315
|
-
}
|
|
316
|
-
return new URL(href, base);
|
|
317
|
-
}
|
|
318
|
-
function matchRoutes(routes, locationArg, basename = "/") {
|
|
319
|
-
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
320
|
-
}
|
|
321
|
-
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
322
|
-
let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
323
|
-
let pathname = stripBasename(location.pathname || "/", basename);
|
|
324
|
-
if (pathname == null) {
|
|
325
|
-
return null;
|
|
326
|
-
}
|
|
327
|
-
let branches = flattenRoutes(routes);
|
|
328
|
-
rankRouteBranches(branches);
|
|
329
|
-
let matches = null;
|
|
330
|
-
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
331
|
-
let decoded = decodePath(pathname);
|
|
332
|
-
matches = matchRouteBranch(
|
|
333
|
-
branches[i],
|
|
334
|
-
decoded,
|
|
335
|
-
allowPartial
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
return matches;
|
|
339
|
-
}
|
|
340
|
-
function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
|
|
341
|
-
let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
|
|
342
|
-
let meta = {
|
|
343
|
-
relativePath: relativePath === void 0 ? route.path || "" : relativePath,
|
|
344
|
-
caseSensitive: route.caseSensitive === true,
|
|
345
|
-
childrenIndex: index,
|
|
346
|
-
route
|
|
347
|
-
};
|
|
348
|
-
if (meta.relativePath.startsWith("/")) {
|
|
349
|
-
if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
invariant(
|
|
353
|
-
meta.relativePath.startsWith(parentPath),
|
|
354
|
-
`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.`
|
|
355
|
-
);
|
|
356
|
-
meta.relativePath = meta.relativePath.slice(parentPath.length);
|
|
357
|
-
}
|
|
358
|
-
let path = joinPaths([parentPath, meta.relativePath]);
|
|
359
|
-
let routesMeta = parentsMeta.concat(meta);
|
|
360
|
-
if (route.children && route.children.length > 0) {
|
|
361
|
-
invariant(
|
|
362
|
-
// Our types know better, but runtime JS may not!
|
|
363
|
-
// @ts-expect-error
|
|
364
|
-
route.index !== true,
|
|
365
|
-
`Index routes must not have child routes. Please remove all child routes from route path "${path}".`
|
|
366
|
-
);
|
|
367
|
-
flattenRoutes(
|
|
368
|
-
route.children,
|
|
369
|
-
branches,
|
|
370
|
-
routesMeta,
|
|
371
|
-
path,
|
|
372
|
-
hasParentOptionalSegments
|
|
373
|
-
);
|
|
374
|
-
}
|
|
375
|
-
if (route.path == null && !route.index) {
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
branches.push({
|
|
379
|
-
path,
|
|
380
|
-
score: computeScore(path, route.index),
|
|
381
|
-
routesMeta
|
|
382
|
-
});
|
|
383
|
-
};
|
|
384
|
-
routes.forEach((route, index) => {
|
|
385
|
-
if (route.path === "" || !route.path?.includes("?")) {
|
|
386
|
-
flattenRoute(route, index);
|
|
387
|
-
} else {
|
|
388
|
-
for (let exploded of explodeOptionalSegments(route.path)) {
|
|
389
|
-
flattenRoute(route, index, true, exploded);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
return branches;
|
|
394
|
-
}
|
|
395
|
-
function explodeOptionalSegments(path) {
|
|
396
|
-
let segments = path.split("/");
|
|
397
|
-
if (segments.length === 0) return [];
|
|
398
|
-
let [first, ...rest] = segments;
|
|
399
|
-
let isOptional = first.endsWith("?");
|
|
400
|
-
let required = first.replace(/\?$/, "");
|
|
401
|
-
if (rest.length === 0) {
|
|
402
|
-
return isOptional ? [required, ""] : [required];
|
|
403
|
-
}
|
|
404
|
-
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
405
|
-
let result = [];
|
|
406
|
-
result.push(
|
|
407
|
-
...restExploded.map(
|
|
408
|
-
(subpath) => subpath === "" ? required : [required, subpath].join("/")
|
|
409
|
-
)
|
|
410
|
-
);
|
|
411
|
-
if (isOptional) {
|
|
412
|
-
result.push(...restExploded);
|
|
413
|
-
}
|
|
414
|
-
return result.map(
|
|
415
|
-
(exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded
|
|
416
|
-
);
|
|
417
|
-
}
|
|
418
|
-
function rankRouteBranches(branches) {
|
|
419
|
-
branches.sort(
|
|
420
|
-
(a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(
|
|
421
|
-
a.routesMeta.map((meta) => meta.childrenIndex),
|
|
422
|
-
b.routesMeta.map((meta) => meta.childrenIndex)
|
|
423
|
-
)
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
var paramRe = /^:[\w-]+$/;
|
|
427
|
-
var dynamicSegmentValue = 3;
|
|
428
|
-
var indexRouteValue = 2;
|
|
429
|
-
var emptySegmentValue = 1;
|
|
430
|
-
var staticSegmentValue = 10;
|
|
431
|
-
var splatPenalty = -2;
|
|
432
|
-
var isSplat = (s) => s === "*";
|
|
433
|
-
function computeScore(path, index) {
|
|
434
|
-
let segments = path.split("/");
|
|
435
|
-
let initialScore = segments.length;
|
|
436
|
-
if (segments.some(isSplat)) {
|
|
437
|
-
initialScore += splatPenalty;
|
|
438
|
-
}
|
|
439
|
-
if (index) {
|
|
440
|
-
initialScore += indexRouteValue;
|
|
441
|
-
}
|
|
442
|
-
return segments.filter((s) => !isSplat(s)).reduce(
|
|
443
|
-
(score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
|
|
444
|
-
initialScore
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
function compareIndexes(a, b) {
|
|
448
|
-
let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
|
|
449
|
-
return siblings ? (
|
|
450
|
-
// If two routes are siblings, we should try to match the earlier sibling
|
|
451
|
-
// first. This allows people to have fine-grained control over the matching
|
|
452
|
-
// behavior by simply putting routes with identical paths in the order they
|
|
453
|
-
// want them tried.
|
|
454
|
-
a[a.length - 1] - b[b.length - 1]
|
|
455
|
-
) : (
|
|
456
|
-
// Otherwise, it doesn't really make sense to rank non-siblings by index,
|
|
457
|
-
// so they sort equally.
|
|
458
|
-
0
|
|
459
|
-
);
|
|
460
|
-
}
|
|
461
|
-
function matchRouteBranch(branch, pathname, allowPartial = false) {
|
|
462
|
-
let { routesMeta } = branch;
|
|
463
|
-
let matchedParams = {};
|
|
464
|
-
let matchedPathname = "/";
|
|
465
|
-
let matches = [];
|
|
466
|
-
for (let i = 0; i < routesMeta.length; ++i) {
|
|
467
|
-
let meta = routesMeta[i];
|
|
468
|
-
let end = i === routesMeta.length - 1;
|
|
469
|
-
let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
|
|
470
|
-
let match = matchPath(
|
|
471
|
-
{ path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
|
|
472
|
-
remainingPathname
|
|
473
|
-
);
|
|
474
|
-
let route = meta.route;
|
|
475
|
-
if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
|
|
476
|
-
match = matchPath(
|
|
477
|
-
{
|
|
478
|
-
path: meta.relativePath,
|
|
479
|
-
caseSensitive: meta.caseSensitive,
|
|
480
|
-
end: false
|
|
481
|
-
},
|
|
482
|
-
remainingPathname
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
if (!match) {
|
|
486
|
-
return null;
|
|
487
|
-
}
|
|
488
|
-
Object.assign(matchedParams, match.params);
|
|
489
|
-
matches.push({
|
|
490
|
-
// TODO: Can this as be avoided?
|
|
491
|
-
params: matchedParams,
|
|
492
|
-
pathname: joinPaths([matchedPathname, match.pathname]),
|
|
493
|
-
pathnameBase: normalizePathname(
|
|
494
|
-
joinPaths([matchedPathname, match.pathnameBase])
|
|
495
|
-
),
|
|
496
|
-
route
|
|
497
|
-
});
|
|
498
|
-
if (match.pathnameBase !== "/") {
|
|
499
|
-
matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
return matches;
|
|
503
|
-
}
|
|
504
|
-
function matchPath(pattern, pathname) {
|
|
505
|
-
if (typeof pattern === "string") {
|
|
506
|
-
pattern = { path: pattern, caseSensitive: false, end: true };
|
|
507
|
-
}
|
|
508
|
-
let [matcher, compiledParams] = compilePath(
|
|
509
|
-
pattern.path,
|
|
510
|
-
pattern.caseSensitive,
|
|
511
|
-
pattern.end
|
|
512
|
-
);
|
|
513
|
-
let match = pathname.match(matcher);
|
|
514
|
-
if (!match) return null;
|
|
515
|
-
let matchedPathname = match[0];
|
|
516
|
-
let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
|
|
517
|
-
let captureGroups = match.slice(1);
|
|
518
|
-
let params = compiledParams.reduce(
|
|
519
|
-
(memo2, { paramName, isOptional }, index) => {
|
|
520
|
-
if (paramName === "*") {
|
|
521
|
-
let splatValue = captureGroups[index] || "";
|
|
522
|
-
pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
|
|
523
|
-
}
|
|
524
|
-
const value = captureGroups[index];
|
|
525
|
-
if (isOptional && !value) {
|
|
526
|
-
memo2[paramName] = void 0;
|
|
527
|
-
} else {
|
|
528
|
-
memo2[paramName] = (value || "").replace(/%2F/g, "/");
|
|
529
|
-
}
|
|
530
|
-
return memo2;
|
|
531
|
-
},
|
|
532
|
-
{}
|
|
533
|
-
);
|
|
534
|
-
return {
|
|
535
|
-
params,
|
|
536
|
-
pathname: matchedPathname,
|
|
537
|
-
pathnameBase,
|
|
538
|
-
pattern
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
function compilePath(path, caseSensitive = false, end = true) {
|
|
542
|
-
warning(
|
|
543
|
-
path === "*" || !path.endsWith("*") || path.endsWith("/*"),
|
|
544
|
-
`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(/\*$/, "/*")}".`
|
|
545
|
-
);
|
|
546
|
-
let params = [];
|
|
547
|
-
let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
|
|
548
|
-
/\/:([\w-]+)(\?)?/g,
|
|
549
|
-
(_, paramName, isOptional) => {
|
|
550
|
-
params.push({ paramName, isOptional: isOptional != null });
|
|
551
|
-
return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
|
|
552
|
-
}
|
|
553
|
-
).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
|
|
554
|
-
if (path.endsWith("*")) {
|
|
555
|
-
params.push({ paramName: "*" });
|
|
556
|
-
regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
|
|
557
|
-
} else if (end) {
|
|
558
|
-
regexpSource += "\\/*$";
|
|
559
|
-
} else if (path !== "" && path !== "/") {
|
|
560
|
-
regexpSource += "(?:(?=\\/|$))";
|
|
561
|
-
} else ;
|
|
562
|
-
let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
|
|
563
|
-
return [matcher, params];
|
|
564
|
-
}
|
|
565
|
-
function decodePath(value) {
|
|
566
|
-
try {
|
|
567
|
-
return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
568
|
-
} catch (error) {
|
|
569
|
-
warning(
|
|
570
|
-
false,
|
|
571
|
-
`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}).`
|
|
572
|
-
);
|
|
573
|
-
return value;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
function stripBasename(pathname, basename) {
|
|
577
|
-
if (basename === "/") return pathname;
|
|
578
|
-
if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
|
|
579
|
-
return null;
|
|
580
|
-
}
|
|
581
|
-
let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
|
|
582
|
-
let nextChar = pathname.charAt(startIndex);
|
|
583
|
-
if (nextChar && nextChar !== "/") {
|
|
584
|
-
return null;
|
|
585
|
-
}
|
|
586
|
-
return pathname.slice(startIndex) || "/";
|
|
587
|
-
}
|
|
588
|
-
function resolvePath(to, fromPathname = "/") {
|
|
589
|
-
let {
|
|
590
|
-
pathname: toPathname,
|
|
591
|
-
search = "",
|
|
592
|
-
hash = ""
|
|
593
|
-
} = typeof to === "string" ? parsePath(to) : to;
|
|
594
|
-
let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname;
|
|
595
|
-
return {
|
|
596
|
-
pathname,
|
|
597
|
-
search: normalizeSearch(search),
|
|
598
|
-
hash: normalizeHash(hash)
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
function resolvePathname(relativePath, fromPathname) {
|
|
602
|
-
let segments = fromPathname.replace(/\/+$/, "").split("/");
|
|
603
|
-
let relativeSegments = relativePath.split("/");
|
|
604
|
-
relativeSegments.forEach((segment) => {
|
|
605
|
-
if (segment === "..") {
|
|
606
|
-
if (segments.length > 1) segments.pop();
|
|
607
|
-
} else if (segment !== ".") {
|
|
608
|
-
segments.push(segment);
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
return segments.length > 1 ? segments.join("/") : "/";
|
|
612
|
-
}
|
|
613
|
-
function getInvalidPathError(char, field, dest, path) {
|
|
614
|
-
return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(
|
|
615
|
-
path
|
|
616
|
-
)}]. 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.`;
|
|
617
|
-
}
|
|
618
|
-
function getPathContributingMatches(matches) {
|
|
619
|
-
return matches.filter(
|
|
620
|
-
(match, index) => index === 0 || match.route.path && match.route.path.length > 0
|
|
621
|
-
);
|
|
622
|
-
}
|
|
623
|
-
function getResolveToMatches(matches) {
|
|
624
|
-
let pathMatches = getPathContributingMatches(matches);
|
|
625
|
-
return pathMatches.map(
|
|
626
|
-
(match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase
|
|
627
|
-
);
|
|
628
|
-
}
|
|
629
|
-
function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
|
|
630
|
-
let to;
|
|
631
|
-
if (typeof toArg === "string") {
|
|
632
|
-
to = parsePath(toArg);
|
|
633
|
-
} else {
|
|
634
|
-
to = { ...toArg };
|
|
635
|
-
invariant(
|
|
636
|
-
!to.pathname || !to.pathname.includes("?"),
|
|
637
|
-
getInvalidPathError("?", "pathname", "search", to)
|
|
638
|
-
);
|
|
639
|
-
invariant(
|
|
640
|
-
!to.pathname || !to.pathname.includes("#"),
|
|
641
|
-
getInvalidPathError("#", "pathname", "hash", to)
|
|
642
|
-
);
|
|
643
|
-
invariant(
|
|
644
|
-
!to.search || !to.search.includes("#"),
|
|
645
|
-
getInvalidPathError("#", "search", "hash", to)
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
let isEmptyPath = toArg === "" || to.pathname === "";
|
|
649
|
-
let toPathname = isEmptyPath ? "/" : to.pathname;
|
|
650
|
-
let from;
|
|
651
|
-
if (toPathname == null) {
|
|
652
|
-
from = locationPathname;
|
|
653
|
-
} else {
|
|
654
|
-
let routePathnameIndex = routePathnames.length - 1;
|
|
655
|
-
if (!isPathRelative && toPathname.startsWith("..")) {
|
|
656
|
-
let toSegments = toPathname.split("/");
|
|
657
|
-
while (toSegments[0] === "..") {
|
|
658
|
-
toSegments.shift();
|
|
659
|
-
routePathnameIndex -= 1;
|
|
660
|
-
}
|
|
661
|
-
to.pathname = toSegments.join("/");
|
|
662
|
-
}
|
|
663
|
-
from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
|
|
664
|
-
}
|
|
665
|
-
let path = resolvePath(to, from);
|
|
666
|
-
let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
|
|
667
|
-
let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
|
|
668
|
-
if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
|
|
669
|
-
path.pathname += "/";
|
|
670
|
-
}
|
|
671
|
-
return path;
|
|
672
|
-
}
|
|
673
|
-
var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
|
|
674
|
-
var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
|
|
675
|
-
var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
|
676
|
-
var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
677
|
-
function isRouteErrorResponse(error) {
|
|
678
|
-
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
679
|
-
}
|
|
680
|
-
var validMutationMethodsArr = [
|
|
681
|
-
"POST",
|
|
682
|
-
"PUT",
|
|
683
|
-
"PATCH",
|
|
684
|
-
"DELETE"
|
|
685
|
-
];
|
|
686
|
-
new Set(
|
|
687
|
-
validMutationMethodsArr
|
|
688
|
-
);
|
|
689
|
-
var validRequestMethodsArr = [
|
|
690
|
-
"GET",
|
|
691
|
-
...validMutationMethodsArr
|
|
692
|
-
];
|
|
693
|
-
new Set(validRequestMethodsArr);
|
|
694
|
-
const React = await importShared('react');
|
|
695
|
-
|
|
696
|
-
var DataRouterContext = React.createContext(null);
|
|
697
|
-
DataRouterContext.displayName = "DataRouter";
|
|
698
|
-
var DataRouterStateContext = React.createContext(null);
|
|
699
|
-
DataRouterStateContext.displayName = "DataRouterState";
|
|
700
|
-
var RSCRouterContext = React.createContext(false);
|
|
701
|
-
function useIsRSCRouterContext() {
|
|
702
|
-
return React.useContext(RSCRouterContext);
|
|
703
|
-
}
|
|
704
|
-
var ViewTransitionContext = React.createContext({
|
|
705
|
-
isTransitioning: false
|
|
706
|
-
});
|
|
707
|
-
ViewTransitionContext.displayName = "ViewTransition";
|
|
708
|
-
var FetchersContext = React.createContext(
|
|
709
|
-
/* @__PURE__ */ new Map()
|
|
710
|
-
);
|
|
711
|
-
FetchersContext.displayName = "Fetchers";
|
|
712
|
-
var AwaitContext = React.createContext(null);
|
|
713
|
-
AwaitContext.displayName = "Await";
|
|
714
|
-
var NavigationContext = React.createContext(
|
|
715
|
-
null
|
|
716
|
-
);
|
|
717
|
-
NavigationContext.displayName = "Navigation";
|
|
718
|
-
var LocationContext = React.createContext(
|
|
719
|
-
null
|
|
720
|
-
);
|
|
721
|
-
LocationContext.displayName = "Location";
|
|
722
|
-
var RouteContext = React.createContext({
|
|
723
|
-
outlet: null,
|
|
724
|
-
matches: [],
|
|
725
|
-
isDataRoute: false
|
|
726
|
-
});
|
|
727
|
-
RouteContext.displayName = "Route";
|
|
728
|
-
var RouteErrorContext = React.createContext(null);
|
|
729
|
-
RouteErrorContext.displayName = "RouteError";
|
|
730
|
-
const React2 = await importShared('react');
|
|
731
|
-
|
|
732
|
-
function useHref(to, { relative } = {}) {
|
|
733
|
-
invariant(
|
|
734
|
-
useInRouterContext(),
|
|
735
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
|
736
|
-
// router loaded. We can help them understand how to avoid that.
|
|
737
|
-
`useHref() may be used only in the context of a <Router> component.`
|
|
738
|
-
);
|
|
739
|
-
let { basename, navigator } = React2.useContext(NavigationContext);
|
|
740
|
-
let { hash, pathname, search } = useResolvedPath(to, { relative });
|
|
741
|
-
let joinedPathname = pathname;
|
|
742
|
-
if (basename !== "/") {
|
|
743
|
-
joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
|
|
744
|
-
}
|
|
745
|
-
return navigator.createHref({ pathname: joinedPathname, search, hash });
|
|
746
|
-
}
|
|
747
|
-
function useInRouterContext() {
|
|
748
|
-
return React2.useContext(LocationContext) != null;
|
|
749
|
-
}
|
|
750
|
-
function useLocation() {
|
|
751
|
-
invariant(
|
|
752
|
-
useInRouterContext(),
|
|
753
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
|
754
|
-
// router loaded. We can help them understand how to avoid that.
|
|
755
|
-
`useLocation() may be used only in the context of a <Router> component.`
|
|
756
|
-
);
|
|
757
|
-
return React2.useContext(LocationContext).location;
|
|
758
|
-
}
|
|
759
|
-
var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
|
|
760
|
-
function useIsomorphicLayoutEffect(cb) {
|
|
761
|
-
let isStatic = React2.useContext(NavigationContext).static;
|
|
762
|
-
if (!isStatic) {
|
|
763
|
-
React2.useLayoutEffect(cb);
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
function useNavigate() {
|
|
767
|
-
let { isDataRoute } = React2.useContext(RouteContext);
|
|
768
|
-
return isDataRoute ? useNavigateStable() : useNavigateUnstable();
|
|
769
|
-
}
|
|
770
|
-
function useNavigateUnstable() {
|
|
771
|
-
invariant(
|
|
772
|
-
useInRouterContext(),
|
|
773
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
|
774
|
-
// router loaded. We can help them understand how to avoid that.
|
|
775
|
-
`useNavigate() may be used only in the context of a <Router> component.`
|
|
776
|
-
);
|
|
777
|
-
let dataRouterContext = React2.useContext(DataRouterContext);
|
|
778
|
-
let { basename, navigator } = React2.useContext(NavigationContext);
|
|
779
|
-
let { matches } = React2.useContext(RouteContext);
|
|
780
|
-
let { pathname: locationPathname } = useLocation();
|
|
781
|
-
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
782
|
-
let activeRef = React2.useRef(false);
|
|
783
|
-
useIsomorphicLayoutEffect(() => {
|
|
784
|
-
activeRef.current = true;
|
|
785
|
-
});
|
|
786
|
-
let navigate = React2.useCallback(
|
|
787
|
-
(to, options = {}) => {
|
|
788
|
-
warning(activeRef.current, navigateEffectWarning);
|
|
789
|
-
if (!activeRef.current) return;
|
|
790
|
-
if (typeof to === "number") {
|
|
791
|
-
navigator.go(to);
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
let path = resolveTo(
|
|
795
|
-
to,
|
|
796
|
-
JSON.parse(routePathnamesJson),
|
|
797
|
-
locationPathname,
|
|
798
|
-
options.relative === "path"
|
|
799
|
-
);
|
|
800
|
-
if (dataRouterContext == null && basename !== "/") {
|
|
801
|
-
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
802
|
-
}
|
|
803
|
-
(!!options.replace ? navigator.replace : navigator.push)(
|
|
804
|
-
path,
|
|
805
|
-
options.state,
|
|
806
|
-
options
|
|
807
|
-
);
|
|
808
|
-
},
|
|
809
|
-
[
|
|
810
|
-
basename,
|
|
811
|
-
navigator,
|
|
812
|
-
routePathnamesJson,
|
|
813
|
-
locationPathname,
|
|
814
|
-
dataRouterContext
|
|
815
|
-
]
|
|
816
|
-
);
|
|
817
|
-
return navigate;
|
|
818
|
-
}
|
|
819
|
-
React2.createContext(null);
|
|
820
|
-
function useResolvedPath(to, { relative } = {}) {
|
|
821
|
-
let { matches } = React2.useContext(RouteContext);
|
|
822
|
-
let { pathname: locationPathname } = useLocation();
|
|
823
|
-
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
824
|
-
return React2.useMemo(
|
|
825
|
-
() => resolveTo(
|
|
826
|
-
to,
|
|
827
|
-
JSON.parse(routePathnamesJson),
|
|
828
|
-
locationPathname,
|
|
829
|
-
relative === "path"
|
|
830
|
-
),
|
|
831
|
-
[to, routePathnamesJson, locationPathname, relative]
|
|
832
|
-
);
|
|
833
|
-
}
|
|
834
|
-
function useRoutes(routes, locationArg) {
|
|
835
|
-
return useRoutesImpl(routes, locationArg);
|
|
836
|
-
}
|
|
837
|
-
function useRoutesImpl(routes, locationArg, dataRouterState, unstable_onError, future) {
|
|
838
|
-
invariant(
|
|
839
|
-
useInRouterContext(),
|
|
840
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
|
841
|
-
// router loaded. We can help them understand how to avoid that.
|
|
842
|
-
`useRoutes() may be used only in the context of a <Router> component.`
|
|
843
|
-
);
|
|
844
|
-
let { navigator } = React2.useContext(NavigationContext);
|
|
845
|
-
let { matches: parentMatches } = React2.useContext(RouteContext);
|
|
846
|
-
let routeMatch = parentMatches[parentMatches.length - 1];
|
|
847
|
-
let parentParams = routeMatch ? routeMatch.params : {};
|
|
848
|
-
let parentPathname = routeMatch ? routeMatch.pathname : "/";
|
|
849
|
-
let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
|
|
850
|
-
let parentRoute = routeMatch && routeMatch.route;
|
|
851
|
-
{
|
|
852
|
-
let parentPath = parentRoute && parentRoute.path || "";
|
|
853
|
-
warningOnce(
|
|
854
|
-
parentPathname,
|
|
855
|
-
!parentRoute || parentPath.endsWith("*") || parentPath.endsWith("*?"),
|
|
856
|
-
`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${parentPathname}" (under <Route path="${parentPath}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
857
|
-
|
|
858
|
-
Please change the parent <Route path="${parentPath}"> to <Route path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`
|
|
859
|
-
);
|
|
860
|
-
}
|
|
861
|
-
let locationFromContext = useLocation();
|
|
862
|
-
let location;
|
|
863
|
-
if (locationArg) {
|
|
864
|
-
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
865
|
-
invariant(
|
|
866
|
-
parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
|
|
867
|
-
`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${parentPathnameBase}" but pathname "${parsedLocationArg.pathname}" was given in the \`location\` prop.`
|
|
868
|
-
);
|
|
869
|
-
location = parsedLocationArg;
|
|
870
|
-
} else {
|
|
871
|
-
location = locationFromContext;
|
|
872
|
-
}
|
|
873
|
-
let pathname = location.pathname || "/";
|
|
874
|
-
let remainingPathname = pathname;
|
|
875
|
-
if (parentPathnameBase !== "/") {
|
|
876
|
-
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
|
|
877
|
-
let segments = pathname.replace(/^\//, "").split("/");
|
|
878
|
-
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
|
|
879
|
-
}
|
|
880
|
-
let matches = matchRoutes(routes, { pathname: remainingPathname });
|
|
881
|
-
{
|
|
882
|
-
warning(
|
|
883
|
-
parentRoute || matches != null,
|
|
884
|
-
`No routes matched location "${location.pathname}${location.search}${location.hash}" `
|
|
885
|
-
);
|
|
886
|
-
warning(
|
|
887
|
-
matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0,
|
|
888
|
-
`Matched leaf route at location "${location.pathname}${location.search}${location.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
|
|
889
|
-
);
|
|
890
|
-
}
|
|
891
|
-
let renderedMatches = _renderMatches(
|
|
892
|
-
matches && matches.map(
|
|
893
|
-
(match) => Object.assign({}, match, {
|
|
894
|
-
params: Object.assign({}, parentParams, match.params),
|
|
895
|
-
pathname: joinPaths([
|
|
896
|
-
parentPathnameBase,
|
|
897
|
-
// Re-encode pathnames that were decoded inside matchRoutes.
|
|
898
|
-
// Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
|
|
899
|
-
// `new URL()` internally and we need to prevent it from treating
|
|
900
|
-
// them as separators
|
|
901
|
-
navigator.encodeLocation ? navigator.encodeLocation(
|
|
902
|
-
match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
|
|
903
|
-
).pathname : match.pathname
|
|
904
|
-
]),
|
|
905
|
-
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
|
|
906
|
-
parentPathnameBase,
|
|
907
|
-
// Re-encode pathnames that were decoded inside matchRoutes
|
|
908
|
-
// Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
|
|
909
|
-
// `new URL()` internally and we need to prevent it from treating
|
|
910
|
-
// them as separators
|
|
911
|
-
navigator.encodeLocation ? navigator.encodeLocation(
|
|
912
|
-
match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
|
|
913
|
-
).pathname : match.pathnameBase
|
|
914
|
-
])
|
|
915
|
-
})
|
|
916
|
-
),
|
|
917
|
-
parentMatches,
|
|
918
|
-
dataRouterState,
|
|
919
|
-
unstable_onError,
|
|
920
|
-
future
|
|
921
|
-
);
|
|
922
|
-
if (locationArg && renderedMatches) {
|
|
923
|
-
return /* @__PURE__ */ React2.createElement(
|
|
924
|
-
LocationContext.Provider,
|
|
925
|
-
{
|
|
926
|
-
value: {
|
|
927
|
-
location: {
|
|
928
|
-
pathname: "/",
|
|
929
|
-
search: "",
|
|
930
|
-
hash: "",
|
|
931
|
-
state: null,
|
|
932
|
-
key: "default",
|
|
933
|
-
...location
|
|
934
|
-
},
|
|
935
|
-
navigationType: "POP"
|
|
936
|
-
/* Pop */
|
|
937
|
-
}
|
|
938
|
-
},
|
|
939
|
-
renderedMatches
|
|
940
|
-
);
|
|
941
|
-
}
|
|
942
|
-
return renderedMatches;
|
|
943
|
-
}
|
|
944
|
-
function DefaultErrorComponent() {
|
|
945
|
-
let error = useRouteError();
|
|
946
|
-
let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
|
|
947
|
-
let stack = error instanceof Error ? error.stack : null;
|
|
948
|
-
let lightgrey = "rgba(200,200,200, 0.5)";
|
|
949
|
-
let preStyles = { padding: "0.5rem", backgroundColor: lightgrey };
|
|
950
|
-
let codeStyles = { padding: "2px 4px", backgroundColor: lightgrey };
|
|
951
|
-
let devInfo = null;
|
|
952
|
-
{
|
|
953
|
-
console.error(
|
|
954
|
-
"Error handled by React Router default ErrorBoundary:",
|
|
955
|
-
error
|
|
956
|
-
);
|
|
957
|
-
devInfo = /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ React2.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React2.createElement("code", { style: codeStyles }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React2.createElement("code", { style: codeStyles }, "errorElement"), " prop on your route."));
|
|
958
|
-
}
|
|
959
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React2.createElement("h3", { style: { fontStyle: "italic" } }, message), stack ? /* @__PURE__ */ React2.createElement("pre", { style: preStyles }, stack) : null, devInfo);
|
|
960
|
-
}
|
|
961
|
-
var defaultErrorElement = /* @__PURE__ */ React2.createElement(DefaultErrorComponent, null);
|
|
962
|
-
var RenderErrorBoundary = class extends React2.Component {
|
|
963
|
-
constructor(props) {
|
|
964
|
-
super(props);
|
|
965
|
-
this.state = {
|
|
966
|
-
location: props.location,
|
|
967
|
-
revalidation: props.revalidation,
|
|
968
|
-
error: props.error
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
static getDerivedStateFromError(error) {
|
|
972
|
-
return { error };
|
|
973
|
-
}
|
|
974
|
-
static getDerivedStateFromProps(props, state) {
|
|
975
|
-
if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
|
|
976
|
-
return {
|
|
977
|
-
error: props.error,
|
|
978
|
-
location: props.location,
|
|
979
|
-
revalidation: props.revalidation
|
|
980
|
-
};
|
|
981
|
-
}
|
|
982
|
-
return {
|
|
983
|
-
error: props.error !== void 0 ? props.error : state.error,
|
|
984
|
-
location: state.location,
|
|
985
|
-
revalidation: props.revalidation || state.revalidation
|
|
986
|
-
};
|
|
987
|
-
}
|
|
988
|
-
componentDidCatch(error, errorInfo) {
|
|
989
|
-
if (this.props.unstable_onError) {
|
|
990
|
-
this.props.unstable_onError(error, errorInfo);
|
|
991
|
-
} else {
|
|
992
|
-
console.error(
|
|
993
|
-
"React Router caught the following error during render",
|
|
994
|
-
error
|
|
995
|
-
);
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
render() {
|
|
999
|
-
return this.state.error !== void 0 ? /* @__PURE__ */ React2.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React2.createElement(
|
|
1000
|
-
RouteErrorContext.Provider,
|
|
1001
|
-
{
|
|
1002
|
-
value: this.state.error,
|
|
1003
|
-
children: this.props.component
|
|
1004
|
-
}
|
|
1005
|
-
)) : this.props.children;
|
|
1006
|
-
}
|
|
1007
|
-
};
|
|
1008
|
-
function RenderedRoute({ routeContext, match, children }) {
|
|
1009
|
-
let dataRouterContext = React2.useContext(DataRouterContext);
|
|
1010
|
-
if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
|
|
1011
|
-
dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
|
|
1012
|
-
}
|
|
1013
|
-
return /* @__PURE__ */ React2.createElement(RouteContext.Provider, { value: routeContext }, children);
|
|
1014
|
-
}
|
|
1015
|
-
function _renderMatches(matches, parentMatches = [], dataRouterState = null, unstable_onError = null, future = null) {
|
|
1016
|
-
if (matches == null) {
|
|
1017
|
-
if (!dataRouterState) {
|
|
1018
|
-
return null;
|
|
1019
|
-
}
|
|
1020
|
-
if (dataRouterState.errors) {
|
|
1021
|
-
matches = dataRouterState.matches;
|
|
1022
|
-
} else if (parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
|
|
1023
|
-
matches = dataRouterState.matches;
|
|
1024
|
-
} else {
|
|
1025
|
-
return null;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
let renderedMatches = matches;
|
|
1029
|
-
let errors = dataRouterState?.errors;
|
|
1030
|
-
if (errors != null) {
|
|
1031
|
-
let errorIndex = renderedMatches.findIndex(
|
|
1032
|
-
(m) => m.route.id && errors?.[m.route.id] !== void 0
|
|
1033
|
-
);
|
|
1034
|
-
invariant(
|
|
1035
|
-
errorIndex >= 0,
|
|
1036
|
-
`Could not find a matching route for errors on route IDs: ${Object.keys(
|
|
1037
|
-
errors
|
|
1038
|
-
).join(",")}`
|
|
1039
|
-
);
|
|
1040
|
-
renderedMatches = renderedMatches.slice(
|
|
1041
|
-
0,
|
|
1042
|
-
Math.min(renderedMatches.length, errorIndex + 1)
|
|
1043
|
-
);
|
|
1044
|
-
}
|
|
1045
|
-
let renderFallback = false;
|
|
1046
|
-
let fallbackIndex = -1;
|
|
1047
|
-
if (dataRouterState) {
|
|
1048
|
-
for (let i = 0; i < renderedMatches.length; i++) {
|
|
1049
|
-
let match = renderedMatches[i];
|
|
1050
|
-
if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
|
|
1051
|
-
fallbackIndex = i;
|
|
1052
|
-
}
|
|
1053
|
-
if (match.route.id) {
|
|
1054
|
-
let { loaderData, errors: errors2 } = dataRouterState;
|
|
1055
|
-
let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
|
|
1056
|
-
if (match.route.lazy || needsToRunLoader) {
|
|
1057
|
-
renderFallback = true;
|
|
1058
|
-
if (fallbackIndex >= 0) {
|
|
1059
|
-
renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
|
|
1060
|
-
} else {
|
|
1061
|
-
renderedMatches = [renderedMatches[0]];
|
|
1062
|
-
}
|
|
1063
|
-
break;
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
return renderedMatches.reduceRight(
|
|
1069
|
-
(outlet, match, index) => {
|
|
1070
|
-
let error;
|
|
1071
|
-
let shouldRenderHydrateFallback = false;
|
|
1072
|
-
let errorElement = null;
|
|
1073
|
-
let hydrateFallbackElement = null;
|
|
1074
|
-
if (dataRouterState) {
|
|
1075
|
-
error = errors && match.route.id ? errors[match.route.id] : void 0;
|
|
1076
|
-
errorElement = match.route.errorElement || defaultErrorElement;
|
|
1077
|
-
if (renderFallback) {
|
|
1078
|
-
if (fallbackIndex < 0 && index === 0) {
|
|
1079
|
-
warningOnce(
|
|
1080
|
-
"route-fallback",
|
|
1081
|
-
false,
|
|
1082
|
-
"No `HydrateFallback` element provided to render during initial hydration"
|
|
1083
|
-
);
|
|
1084
|
-
shouldRenderHydrateFallback = true;
|
|
1085
|
-
hydrateFallbackElement = null;
|
|
1086
|
-
} else if (fallbackIndex === index) {
|
|
1087
|
-
shouldRenderHydrateFallback = true;
|
|
1088
|
-
hydrateFallbackElement = match.route.hydrateFallbackElement || null;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
|
|
1093
|
-
let getChildren = () => {
|
|
1094
|
-
let children;
|
|
1095
|
-
if (error) {
|
|
1096
|
-
children = errorElement;
|
|
1097
|
-
} else if (shouldRenderHydrateFallback) {
|
|
1098
|
-
children = hydrateFallbackElement;
|
|
1099
|
-
} else if (match.route.Component) {
|
|
1100
|
-
children = /* @__PURE__ */ React2.createElement(match.route.Component, null);
|
|
1101
|
-
} else if (match.route.element) {
|
|
1102
|
-
children = match.route.element;
|
|
1103
|
-
} else {
|
|
1104
|
-
children = outlet;
|
|
1105
|
-
}
|
|
1106
|
-
return /* @__PURE__ */ React2.createElement(
|
|
1107
|
-
RenderedRoute,
|
|
1108
|
-
{
|
|
1109
|
-
match,
|
|
1110
|
-
routeContext: {
|
|
1111
|
-
outlet,
|
|
1112
|
-
matches: matches2,
|
|
1113
|
-
isDataRoute: dataRouterState != null
|
|
1114
|
-
},
|
|
1115
|
-
children
|
|
1116
|
-
}
|
|
1117
|
-
);
|
|
1118
|
-
};
|
|
1119
|
-
return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React2.createElement(
|
|
1120
|
-
RenderErrorBoundary,
|
|
1121
|
-
{
|
|
1122
|
-
location: dataRouterState.location,
|
|
1123
|
-
revalidation: dataRouterState.revalidation,
|
|
1124
|
-
component: errorElement,
|
|
1125
|
-
error,
|
|
1126
|
-
children: getChildren(),
|
|
1127
|
-
routeContext: { outlet: null, matches: matches2, isDataRoute: true },
|
|
1128
|
-
unstable_onError
|
|
1129
|
-
}
|
|
1130
|
-
) : getChildren();
|
|
1131
|
-
},
|
|
1132
|
-
null
|
|
1133
|
-
);
|
|
1134
|
-
}
|
|
1135
|
-
function getDataRouterConsoleError(hookName) {
|
|
1136
|
-
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
1137
|
-
}
|
|
1138
|
-
function useDataRouterContext(hookName) {
|
|
1139
|
-
let ctx = React2.useContext(DataRouterContext);
|
|
1140
|
-
invariant(ctx, getDataRouterConsoleError(hookName));
|
|
1141
|
-
return ctx;
|
|
1142
|
-
}
|
|
1143
|
-
function useDataRouterState(hookName) {
|
|
1144
|
-
let state = React2.useContext(DataRouterStateContext);
|
|
1145
|
-
invariant(state, getDataRouterConsoleError(hookName));
|
|
1146
|
-
return state;
|
|
1147
|
-
}
|
|
1148
|
-
function useRouteContext(hookName) {
|
|
1149
|
-
let route = React2.useContext(RouteContext);
|
|
1150
|
-
invariant(route, getDataRouterConsoleError(hookName));
|
|
1151
|
-
return route;
|
|
1152
|
-
}
|
|
1153
|
-
function useCurrentRouteId(hookName) {
|
|
1154
|
-
let route = useRouteContext(hookName);
|
|
1155
|
-
let thisRoute = route.matches[route.matches.length - 1];
|
|
1156
|
-
invariant(
|
|
1157
|
-
thisRoute.route.id,
|
|
1158
|
-
`${hookName} can only be used on routes that contain a unique "id"`
|
|
1159
|
-
);
|
|
1160
|
-
return thisRoute.route.id;
|
|
1161
|
-
}
|
|
1162
|
-
function useRouteId() {
|
|
1163
|
-
return useCurrentRouteId(
|
|
1164
|
-
"useRouteId"
|
|
1165
|
-
/* UseRouteId */
|
|
1166
|
-
);
|
|
1167
|
-
}
|
|
1168
|
-
function useRouteError() {
|
|
1169
|
-
let error = React2.useContext(RouteErrorContext);
|
|
1170
|
-
let state = useDataRouterState(
|
|
1171
|
-
"useRouteError"
|
|
1172
|
-
/* UseRouteError */
|
|
1173
|
-
);
|
|
1174
|
-
let routeId = useCurrentRouteId(
|
|
1175
|
-
"useRouteError"
|
|
1176
|
-
/* UseRouteError */
|
|
1177
|
-
);
|
|
1178
|
-
if (error !== void 0) {
|
|
1179
|
-
return error;
|
|
1180
|
-
}
|
|
1181
|
-
return state.errors?.[routeId];
|
|
1182
|
-
}
|
|
1183
|
-
function useNavigateStable() {
|
|
1184
|
-
let { router } = useDataRouterContext(
|
|
1185
|
-
"useNavigate"
|
|
1186
|
-
/* UseNavigateStable */
|
|
1187
|
-
);
|
|
1188
|
-
let id = useCurrentRouteId(
|
|
1189
|
-
"useNavigate"
|
|
1190
|
-
/* UseNavigateStable */
|
|
1191
|
-
);
|
|
1192
|
-
let activeRef = React2.useRef(false);
|
|
1193
|
-
useIsomorphicLayoutEffect(() => {
|
|
1194
|
-
activeRef.current = true;
|
|
1195
|
-
});
|
|
1196
|
-
let navigate = React2.useCallback(
|
|
1197
|
-
async (to, options = {}) => {
|
|
1198
|
-
warning(activeRef.current, navigateEffectWarning);
|
|
1199
|
-
if (!activeRef.current) return;
|
|
1200
|
-
if (typeof to === "number") {
|
|
1201
|
-
router.navigate(to);
|
|
1202
|
-
} else {
|
|
1203
|
-
await router.navigate(to, { fromRouteId: id, ...options });
|
|
1204
|
-
}
|
|
1205
|
-
},
|
|
1206
|
-
[router, id]
|
|
1207
|
-
);
|
|
1208
|
-
return navigate;
|
|
1209
|
-
}
|
|
1210
|
-
var alreadyWarned = {};
|
|
1211
|
-
function warningOnce(key, cond, message) {
|
|
1212
|
-
if (!cond && !alreadyWarned[key]) {
|
|
1213
|
-
alreadyWarned[key] = true;
|
|
1214
|
-
warning(false, message);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
const React3 = await importShared('react');
|
|
1218
|
-
|
|
1219
|
-
var alreadyWarned2 = {};
|
|
1220
|
-
function warnOnce(condition, message) {
|
|
1221
|
-
if (!condition && !alreadyWarned2[message]) {
|
|
1222
|
-
alreadyWarned2[message] = true;
|
|
1223
|
-
console.warn(message);
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
React3.memo(DataRoutes);
|
|
1227
|
-
function DataRoutes({
|
|
1228
|
-
routes,
|
|
1229
|
-
future,
|
|
1230
|
-
state,
|
|
1231
|
-
unstable_onError
|
|
1232
|
-
}) {
|
|
1233
|
-
return useRoutesImpl(routes, void 0, state, unstable_onError, future);
|
|
1234
|
-
}
|
|
1235
|
-
function MemoryRouter({
|
|
1236
|
-
basename,
|
|
1237
|
-
children,
|
|
1238
|
-
initialEntries,
|
|
1239
|
-
initialIndex
|
|
1240
|
-
}) {
|
|
1241
|
-
let historyRef = React3.useRef();
|
|
1242
|
-
if (historyRef.current == null) {
|
|
1243
|
-
historyRef.current = createMemoryHistory({
|
|
1244
|
-
initialEntries,
|
|
1245
|
-
initialIndex,
|
|
1246
|
-
v5Compat: true
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
let history = historyRef.current;
|
|
1250
|
-
let [state, setStateImpl] = React3.useState({
|
|
1251
|
-
action: history.action,
|
|
1252
|
-
location: history.location
|
|
1253
|
-
});
|
|
1254
|
-
let setState = React3.useCallback(
|
|
1255
|
-
(newState) => {
|
|
1256
|
-
React3.startTransition(() => setStateImpl(newState));
|
|
1257
|
-
},
|
|
1258
|
-
[setStateImpl]
|
|
1259
|
-
);
|
|
1260
|
-
React3.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
1261
|
-
return /* @__PURE__ */ React3.createElement(
|
|
1262
|
-
Router,
|
|
1263
|
-
{
|
|
1264
|
-
basename,
|
|
1265
|
-
children,
|
|
1266
|
-
location: state.location,
|
|
1267
|
-
navigationType: state.action,
|
|
1268
|
-
navigator: history
|
|
1269
|
-
}
|
|
1270
|
-
);
|
|
1271
|
-
}
|
|
1272
|
-
function Navigate({
|
|
1273
|
-
to,
|
|
1274
|
-
replace: replace2,
|
|
1275
|
-
state,
|
|
1276
|
-
relative
|
|
1277
|
-
}) {
|
|
1278
|
-
invariant(
|
|
1279
|
-
useInRouterContext(),
|
|
1280
|
-
// TODO: This error is probably because they somehow have 2 versions of
|
|
1281
|
-
// the router loaded. We can help them understand how to avoid that.
|
|
1282
|
-
`<Navigate> may be used only in the context of a <Router> component.`
|
|
1283
|
-
);
|
|
1284
|
-
let { static: isStatic } = React3.useContext(NavigationContext);
|
|
1285
|
-
warning(
|
|
1286
|
-
!isStatic,
|
|
1287
|
-
`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`
|
|
1288
|
-
);
|
|
1289
|
-
let { matches } = React3.useContext(RouteContext);
|
|
1290
|
-
let { pathname: locationPathname } = useLocation();
|
|
1291
|
-
let navigate = useNavigate();
|
|
1292
|
-
let path = resolveTo(
|
|
1293
|
-
to,
|
|
1294
|
-
getResolveToMatches(matches),
|
|
1295
|
-
locationPathname,
|
|
1296
|
-
relative === "path"
|
|
1297
|
-
);
|
|
1298
|
-
let jsonPath = JSON.stringify(path);
|
|
1299
|
-
React3.useEffect(() => {
|
|
1300
|
-
navigate(JSON.parse(jsonPath), { replace: replace2, state, relative });
|
|
1301
|
-
}, [navigate, jsonPath, relative, replace2, state]);
|
|
1302
|
-
return null;
|
|
1303
|
-
}
|
|
1304
|
-
function Route(props) {
|
|
1305
|
-
invariant(
|
|
1306
|
-
false,
|
|
1307
|
-
`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`
|
|
1308
|
-
);
|
|
1309
|
-
}
|
|
1310
|
-
function Router({
|
|
1311
|
-
basename: basenameProp = "/",
|
|
1312
|
-
children = null,
|
|
1313
|
-
location: locationProp,
|
|
1314
|
-
navigationType = "POP",
|
|
1315
|
-
navigator,
|
|
1316
|
-
static: staticProp = false
|
|
1317
|
-
}) {
|
|
1318
|
-
invariant(
|
|
1319
|
-
!useInRouterContext(),
|
|
1320
|
-
`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`
|
|
1321
|
-
);
|
|
1322
|
-
let basename = basenameProp.replace(/^\/*/, "/");
|
|
1323
|
-
let navigationContext = React3.useMemo(
|
|
1324
|
-
() => ({
|
|
1325
|
-
basename,
|
|
1326
|
-
navigator,
|
|
1327
|
-
static: staticProp,
|
|
1328
|
-
future: {}
|
|
1329
|
-
}),
|
|
1330
|
-
[basename, navigator, staticProp]
|
|
1331
|
-
);
|
|
1332
|
-
if (typeof locationProp === "string") {
|
|
1333
|
-
locationProp = parsePath(locationProp);
|
|
1334
|
-
}
|
|
1335
|
-
let {
|
|
1336
|
-
pathname = "/",
|
|
1337
|
-
search = "",
|
|
1338
|
-
hash = "",
|
|
1339
|
-
state = null,
|
|
1340
|
-
key = "default"
|
|
1341
|
-
} = locationProp;
|
|
1342
|
-
let locationContext = React3.useMemo(() => {
|
|
1343
|
-
let trailingPathname = stripBasename(pathname, basename);
|
|
1344
|
-
if (trailingPathname == null) {
|
|
1345
|
-
return null;
|
|
1346
|
-
}
|
|
1347
|
-
return {
|
|
1348
|
-
location: {
|
|
1349
|
-
pathname: trailingPathname,
|
|
1350
|
-
search,
|
|
1351
|
-
hash,
|
|
1352
|
-
state,
|
|
1353
|
-
key
|
|
1354
|
-
},
|
|
1355
|
-
navigationType
|
|
1356
|
-
};
|
|
1357
|
-
}, [basename, pathname, search, hash, state, key, navigationType]);
|
|
1358
|
-
warning(
|
|
1359
|
-
locationContext != null,
|
|
1360
|
-
`<Router basename="${basename}"> is not able to match the URL "${pathname}${search}${hash}" because it does not start with the basename, so the <Router> won't render anything.`
|
|
1361
|
-
);
|
|
1362
|
-
if (locationContext == null) {
|
|
1363
|
-
return null;
|
|
1364
|
-
}
|
|
1365
|
-
return /* @__PURE__ */ React3.createElement(NavigationContext.Provider, { value: navigationContext }, /* @__PURE__ */ React3.createElement(LocationContext.Provider, { children, value: locationContext }));
|
|
1366
|
-
}
|
|
1367
|
-
function Routes({
|
|
1368
|
-
children,
|
|
1369
|
-
location
|
|
1370
|
-
}) {
|
|
1371
|
-
return useRoutes(createRoutesFromChildren(children), location);
|
|
1372
|
-
}
|
|
1373
|
-
(class extends React3.Component {
|
|
1374
|
-
constructor(props) {
|
|
1375
|
-
super(props);
|
|
1376
|
-
this.state = { error: null };
|
|
1377
|
-
}
|
|
1378
|
-
static getDerivedStateFromError(error) {
|
|
1379
|
-
return { error };
|
|
1380
|
-
}
|
|
1381
|
-
componentDidCatch(error, errorInfo) {
|
|
1382
|
-
if (this.props.unstable_onError) {
|
|
1383
|
-
this.props.unstable_onError(error, errorInfo);
|
|
1384
|
-
} else {
|
|
1385
|
-
console.error(
|
|
1386
|
-
"<Await> caught the following error during render",
|
|
1387
|
-
error,
|
|
1388
|
-
errorInfo
|
|
1389
|
-
);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
render() {
|
|
1393
|
-
let { children, errorElement, resolve } = this.props;
|
|
1394
|
-
let promise = null;
|
|
1395
|
-
let status = 0;
|
|
1396
|
-
if (!(resolve instanceof Promise)) {
|
|
1397
|
-
status = 1;
|
|
1398
|
-
promise = Promise.resolve();
|
|
1399
|
-
Object.defineProperty(promise, "_tracked", { get: () => true });
|
|
1400
|
-
Object.defineProperty(promise, "_data", { get: () => resolve });
|
|
1401
|
-
} else if (this.state.error) {
|
|
1402
|
-
status = 2;
|
|
1403
|
-
let renderError = this.state.error;
|
|
1404
|
-
promise = Promise.reject().catch(() => {
|
|
1405
|
-
});
|
|
1406
|
-
Object.defineProperty(promise, "_tracked", { get: () => true });
|
|
1407
|
-
Object.defineProperty(promise, "_error", { get: () => renderError });
|
|
1408
|
-
} else if (resolve._tracked) {
|
|
1409
|
-
promise = resolve;
|
|
1410
|
-
status = "_error" in promise ? 2 : "_data" in promise ? 1 : 0;
|
|
1411
|
-
} else {
|
|
1412
|
-
status = 0;
|
|
1413
|
-
Object.defineProperty(resolve, "_tracked", { get: () => true });
|
|
1414
|
-
promise = resolve.then(
|
|
1415
|
-
(data2) => Object.defineProperty(resolve, "_data", { get: () => data2 }),
|
|
1416
|
-
(error) => {
|
|
1417
|
-
this.props.unstable_onError?.(error);
|
|
1418
|
-
Object.defineProperty(resolve, "_error", { get: () => error });
|
|
1419
|
-
}
|
|
1420
|
-
);
|
|
1421
|
-
}
|
|
1422
|
-
if (status === 2 && !errorElement) {
|
|
1423
|
-
throw promise._error;
|
|
1424
|
-
}
|
|
1425
|
-
if (status === 2) {
|
|
1426
|
-
return /* @__PURE__ */ React3.createElement(AwaitContext.Provider, { value: promise, children: errorElement });
|
|
1427
|
-
}
|
|
1428
|
-
if (status === 1) {
|
|
1429
|
-
return /* @__PURE__ */ React3.createElement(AwaitContext.Provider, { value: promise, children });
|
|
1430
|
-
}
|
|
1431
|
-
throw promise;
|
|
1432
|
-
}
|
|
1433
|
-
});
|
|
1434
|
-
function createRoutesFromChildren(children, parentPath = []) {
|
|
1435
|
-
let routes = [];
|
|
1436
|
-
React3.Children.forEach(children, (element, index) => {
|
|
1437
|
-
if (!React3.isValidElement(element)) {
|
|
1438
|
-
return;
|
|
1439
|
-
}
|
|
1440
|
-
let treePath = [...parentPath, index];
|
|
1441
|
-
if (element.type === React3.Fragment) {
|
|
1442
|
-
routes.push.apply(
|
|
1443
|
-
routes,
|
|
1444
|
-
createRoutesFromChildren(element.props.children, treePath)
|
|
1445
|
-
);
|
|
1446
|
-
return;
|
|
1447
|
-
}
|
|
1448
|
-
invariant(
|
|
1449
|
-
element.type === Route,
|
|
1450
|
-
`[${typeof element.type === "string" ? element.type : element.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`
|
|
1451
|
-
);
|
|
1452
|
-
invariant(
|
|
1453
|
-
!element.props.index || !element.props.children,
|
|
1454
|
-
"An index route cannot have child routes."
|
|
1455
|
-
);
|
|
1456
|
-
let route = {
|
|
1457
|
-
id: element.props.id || treePath.join("-"),
|
|
1458
|
-
caseSensitive: element.props.caseSensitive,
|
|
1459
|
-
element: element.props.element,
|
|
1460
|
-
Component: element.props.Component,
|
|
1461
|
-
index: element.props.index,
|
|
1462
|
-
path: element.props.path,
|
|
1463
|
-
middleware: element.props.middleware,
|
|
1464
|
-
loader: element.props.loader,
|
|
1465
|
-
action: element.props.action,
|
|
1466
|
-
hydrateFallbackElement: element.props.hydrateFallbackElement,
|
|
1467
|
-
HydrateFallback: element.props.HydrateFallback,
|
|
1468
|
-
errorElement: element.props.errorElement,
|
|
1469
|
-
ErrorBoundary: element.props.ErrorBoundary,
|
|
1470
|
-
hasErrorBoundary: element.props.hasErrorBoundary === true || element.props.ErrorBoundary != null || element.props.errorElement != null,
|
|
1471
|
-
shouldRevalidate: element.props.shouldRevalidate,
|
|
1472
|
-
handle: element.props.handle,
|
|
1473
|
-
lazy: element.props.lazy
|
|
1474
|
-
};
|
|
1475
|
-
if (element.props.children) {
|
|
1476
|
-
route.children = createRoutesFromChildren(
|
|
1477
|
-
element.props.children,
|
|
1478
|
-
treePath
|
|
1479
|
-
);
|
|
1480
|
-
}
|
|
1481
|
-
routes.push(route);
|
|
1482
|
-
});
|
|
1483
|
-
return routes;
|
|
1484
|
-
}
|
|
1485
|
-
var defaultMethod = "get";
|
|
1486
|
-
var defaultEncType = "application/x-www-form-urlencoded";
|
|
1487
|
-
function isHtmlElement(object) {
|
|
1488
|
-
return object != null && typeof object.tagName === "string";
|
|
1489
|
-
}
|
|
1490
|
-
function isButtonElement(object) {
|
|
1491
|
-
return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
|
|
1492
|
-
}
|
|
1493
|
-
function isFormElement(object) {
|
|
1494
|
-
return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
|
|
1495
|
-
}
|
|
1496
|
-
function isInputElement(object) {
|
|
1497
|
-
return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
|
|
1498
|
-
}
|
|
1499
|
-
function isModifiedEvent(event) {
|
|
1500
|
-
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
1501
|
-
}
|
|
1502
|
-
function shouldProcessLinkClick(event, target) {
|
|
1503
|
-
return event.button === 0 && // Ignore everything but left clicks
|
|
1504
|
-
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
|
|
1505
|
-
!isModifiedEvent(event);
|
|
1506
|
-
}
|
|
1507
|
-
var _formDataSupportsSubmitter = null;
|
|
1508
|
-
function isFormDataSubmitterSupported() {
|
|
1509
|
-
if (_formDataSupportsSubmitter === null) {
|
|
1510
|
-
try {
|
|
1511
|
-
new FormData(
|
|
1512
|
-
document.createElement("form"),
|
|
1513
|
-
// @ts-expect-error if FormData supports the submitter parameter, this will throw
|
|
1514
|
-
0
|
|
1515
|
-
);
|
|
1516
|
-
_formDataSupportsSubmitter = false;
|
|
1517
|
-
} catch (e) {
|
|
1518
|
-
_formDataSupportsSubmitter = true;
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
return _formDataSupportsSubmitter;
|
|
1522
|
-
}
|
|
1523
|
-
var supportedFormEncTypes = /* @__PURE__ */ new Set([
|
|
1524
|
-
"application/x-www-form-urlencoded",
|
|
1525
|
-
"multipart/form-data",
|
|
1526
|
-
"text/plain"
|
|
1527
|
-
]);
|
|
1528
|
-
function getFormEncType(encType) {
|
|
1529
|
-
if (encType != null && !supportedFormEncTypes.has(encType)) {
|
|
1530
|
-
warning(
|
|
1531
|
-
false,
|
|
1532
|
-
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
|
|
1533
|
-
);
|
|
1534
|
-
return null;
|
|
1535
|
-
}
|
|
1536
|
-
return encType;
|
|
1537
|
-
}
|
|
1538
|
-
function getFormSubmissionInfo(target, basename) {
|
|
1539
|
-
let method;
|
|
1540
|
-
let action;
|
|
1541
|
-
let encType;
|
|
1542
|
-
let formData;
|
|
1543
|
-
let body;
|
|
1544
|
-
if (isFormElement(target)) {
|
|
1545
|
-
let attr = target.getAttribute("action");
|
|
1546
|
-
action = attr ? stripBasename(attr, basename) : null;
|
|
1547
|
-
method = target.getAttribute("method") || defaultMethod;
|
|
1548
|
-
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
|
1549
|
-
formData = new FormData(target);
|
|
1550
|
-
} else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
|
|
1551
|
-
let form = target.form;
|
|
1552
|
-
if (form == null) {
|
|
1553
|
-
throw new Error(
|
|
1554
|
-
`Cannot submit a <button> or <input type="submit"> without a <form>`
|
|
1555
|
-
);
|
|
1556
|
-
}
|
|
1557
|
-
let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
|
1558
|
-
action = attr ? stripBasename(attr, basename) : null;
|
|
1559
|
-
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
|
|
1560
|
-
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
|
1561
|
-
formData = new FormData(form, target);
|
|
1562
|
-
if (!isFormDataSubmitterSupported()) {
|
|
1563
|
-
let { name, type, value } = target;
|
|
1564
|
-
if (type === "image") {
|
|
1565
|
-
let prefix = name ? `${name}.` : "";
|
|
1566
|
-
formData.append(`${prefix}x`, "0");
|
|
1567
|
-
formData.append(`${prefix}y`, "0");
|
|
1568
|
-
} else if (name) {
|
|
1569
|
-
formData.append(name, value);
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
} else if (isHtmlElement(target)) {
|
|
1573
|
-
throw new Error(
|
|
1574
|
-
`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
|
|
1575
|
-
);
|
|
1576
|
-
} else {
|
|
1577
|
-
method = defaultMethod;
|
|
1578
|
-
action = null;
|
|
1579
|
-
encType = defaultEncType;
|
|
1580
|
-
body = target;
|
|
1581
|
-
}
|
|
1582
|
-
if (formData && encType === "text/plain") {
|
|
1583
|
-
body = formData;
|
|
1584
|
-
formData = void 0;
|
|
1585
|
-
}
|
|
1586
|
-
return { action, method: method.toLowerCase(), encType, formData, body };
|
|
1587
|
-
}
|
|
1588
|
-
await importShared('react');
|
|
1589
|
-
Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
1590
|
-
function invariant2(value, message) {
|
|
1591
|
-
if (value === false || value === null || typeof value === "undefined") {
|
|
1592
|
-
throw new Error(message);
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
function singleFetchUrl(reqUrl, basename, extension) {
|
|
1596
|
-
let url = typeof reqUrl === "string" ? new URL(
|
|
1597
|
-
reqUrl,
|
|
1598
|
-
// This can be called during the SSR flow via PrefetchPageLinksImpl so
|
|
1599
|
-
// don't assume window is available
|
|
1600
|
-
typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
|
|
1601
|
-
) : reqUrl;
|
|
1602
|
-
if (url.pathname === "/") {
|
|
1603
|
-
url.pathname = `_root.${extension}`;
|
|
1604
|
-
} else if (basename && stripBasename(url.pathname, basename) === "/") {
|
|
1605
|
-
url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
|
|
1606
|
-
} else {
|
|
1607
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
|
|
1608
|
-
}
|
|
1609
|
-
return url;
|
|
1610
|
-
}
|
|
1611
|
-
const React9 = await importShared('react');
|
|
1612
|
-
|
|
1613
|
-
const React8 = await importShared('react');
|
|
1614
|
-
|
|
1615
|
-
async function loadRouteModule(route, routeModulesCache) {
|
|
1616
|
-
if (route.id in routeModulesCache) {
|
|
1617
|
-
return routeModulesCache[route.id];
|
|
1618
|
-
}
|
|
1619
|
-
try {
|
|
1620
|
-
let routeModule = await module.import(
|
|
1621
|
-
/* @vite-ignore */
|
|
1622
|
-
/* webpackIgnore: true */
|
|
1623
|
-
route.module
|
|
1624
|
-
);
|
|
1625
|
-
routeModulesCache[route.id] = routeModule;
|
|
1626
|
-
return routeModule;
|
|
1627
|
-
} catch (error) {
|
|
1628
|
-
console.error(
|
|
1629
|
-
`Error loading route module \`${route.module}\`, reloading page...`
|
|
1630
|
-
);
|
|
1631
|
-
console.error(error);
|
|
1632
|
-
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
1633
|
-
void 0) ;
|
|
1634
|
-
window.location.reload();
|
|
1635
|
-
return new Promise(() => {
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
function isHtmlLinkDescriptor(object) {
|
|
1640
|
-
if (object == null) {
|
|
1641
|
-
return false;
|
|
1642
|
-
}
|
|
1643
|
-
if (object.href == null) {
|
|
1644
|
-
return object.rel === "preload" && typeof object.imageSrcSet === "string" && typeof object.imageSizes === "string";
|
|
1645
|
-
}
|
|
1646
|
-
return typeof object.rel === "string" && typeof object.href === "string";
|
|
1647
|
-
}
|
|
1648
|
-
async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
1649
|
-
let links = await Promise.all(
|
|
1650
|
-
matches.map(async (match) => {
|
|
1651
|
-
let route = manifest.routes[match.route.id];
|
|
1652
|
-
if (route) {
|
|
1653
|
-
let mod = await loadRouteModule(route, routeModules);
|
|
1654
|
-
return mod.links ? mod.links() : [];
|
|
1655
|
-
}
|
|
1656
|
-
return [];
|
|
1657
|
-
})
|
|
1658
|
-
);
|
|
1659
|
-
return dedupeLinkDescriptors(
|
|
1660
|
-
links.flat(1).filter(isHtmlLinkDescriptor).filter((link) => link.rel === "stylesheet" || link.rel === "preload").map(
|
|
1661
|
-
(link) => link.rel === "stylesheet" ? { ...link, rel: "prefetch", as: "style" } : { ...link, rel: "prefetch" }
|
|
1662
|
-
)
|
|
1663
|
-
);
|
|
1664
|
-
}
|
|
1665
|
-
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
|
|
1666
|
-
let isNew = (match, index) => {
|
|
1667
|
-
if (!currentMatches[index]) return true;
|
|
1668
|
-
return match.route.id !== currentMatches[index].route.id;
|
|
1669
|
-
};
|
|
1670
|
-
let matchPathChanged = (match, index) => {
|
|
1671
|
-
return (
|
|
1672
|
-
// param change, /users/123 -> /users/456
|
|
1673
|
-
currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
|
|
1674
|
-
// e.g. /files/images/avatar.jpg -> files/finances.xls
|
|
1675
|
-
currentMatches[index].route.path?.endsWith("*") && currentMatches[index].params["*"] !== match.params["*"]
|
|
1676
|
-
);
|
|
1677
|
-
};
|
|
1678
|
-
if (mode === "assets") {
|
|
1679
|
-
return nextMatches.filter(
|
|
1680
|
-
(match, index) => isNew(match, index) || matchPathChanged(match, index)
|
|
1681
|
-
);
|
|
1682
|
-
}
|
|
1683
|
-
if (mode === "data") {
|
|
1684
|
-
return nextMatches.filter((match, index) => {
|
|
1685
|
-
let manifestRoute = manifest.routes[match.route.id];
|
|
1686
|
-
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
1687
|
-
return false;
|
|
1688
|
-
}
|
|
1689
|
-
if (isNew(match, index) || matchPathChanged(match, index)) {
|
|
1690
|
-
return true;
|
|
1691
|
-
}
|
|
1692
|
-
if (match.route.shouldRevalidate) {
|
|
1693
|
-
let routeChoice = match.route.shouldRevalidate({
|
|
1694
|
-
currentUrl: new URL(
|
|
1695
|
-
location.pathname + location.search + location.hash,
|
|
1696
|
-
window.origin
|
|
1697
|
-
),
|
|
1698
|
-
currentParams: currentMatches[0]?.params || {},
|
|
1699
|
-
nextUrl: new URL(page, window.origin),
|
|
1700
|
-
nextParams: match.params,
|
|
1701
|
-
defaultShouldRevalidate: true
|
|
1702
|
-
});
|
|
1703
|
-
if (typeof routeChoice === "boolean") {
|
|
1704
|
-
return routeChoice;
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
return true;
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
return [];
|
|
1711
|
-
}
|
|
1712
|
-
function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
|
|
1713
|
-
return dedupeHrefs(
|
|
1714
|
-
matches.map((match) => {
|
|
1715
|
-
let route = manifest.routes[match.route.id];
|
|
1716
|
-
if (!route) return [];
|
|
1717
|
-
let hrefs = [route.module];
|
|
1718
|
-
if (route.clientActionModule) {
|
|
1719
|
-
hrefs = hrefs.concat(route.clientActionModule);
|
|
1720
|
-
}
|
|
1721
|
-
if (route.clientLoaderModule) {
|
|
1722
|
-
hrefs = hrefs.concat(route.clientLoaderModule);
|
|
1723
|
-
}
|
|
1724
|
-
if (includeHydrateFallback && route.hydrateFallbackModule) {
|
|
1725
|
-
hrefs = hrefs.concat(route.hydrateFallbackModule);
|
|
1726
|
-
}
|
|
1727
|
-
if (route.imports) {
|
|
1728
|
-
hrefs = hrefs.concat(route.imports);
|
|
1729
|
-
}
|
|
1730
|
-
return hrefs;
|
|
1731
|
-
}).flat(1)
|
|
1732
|
-
);
|
|
1733
|
-
}
|
|
1734
|
-
function dedupeHrefs(hrefs) {
|
|
1735
|
-
return [...new Set(hrefs)];
|
|
1736
|
-
}
|
|
1737
|
-
function sortKeys(obj) {
|
|
1738
|
-
let sorted = {};
|
|
1739
|
-
let keys = Object.keys(obj).sort();
|
|
1740
|
-
for (let key of keys) {
|
|
1741
|
-
sorted[key] = obj[key];
|
|
1742
|
-
}
|
|
1743
|
-
return sorted;
|
|
1744
|
-
}
|
|
1745
|
-
function dedupeLinkDescriptors(descriptors, preloads) {
|
|
1746
|
-
let set = /* @__PURE__ */ new Set();
|
|
1747
|
-
new Set(preloads);
|
|
1748
|
-
return descriptors.reduce((deduped, descriptor) => {
|
|
1749
|
-
let key = JSON.stringify(sortKeys(descriptor));
|
|
1750
|
-
if (!set.has(key)) {
|
|
1751
|
-
set.add(key);
|
|
1752
|
-
deduped.push({ key, link: descriptor });
|
|
1753
|
-
}
|
|
1754
|
-
return deduped;
|
|
1755
|
-
}, []);
|
|
1756
|
-
}
|
|
1757
|
-
await importShared('react');
|
|
1758
|
-
|
|
1759
|
-
await importShared('react');
|
|
1760
|
-
|
|
1761
|
-
await importShared('react');
|
|
1762
|
-
function isFogOfWarEnabled(routeDiscovery, ssr) {
|
|
1763
|
-
return routeDiscovery.mode === "lazy" && ssr === true;
|
|
1764
|
-
}
|
|
1765
|
-
function getPartialManifest({ sri, ...manifest }, router) {
|
|
1766
|
-
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
|
|
1767
|
-
let segments = router.state.location.pathname.split("/").filter(Boolean);
|
|
1768
|
-
let paths = ["/"];
|
|
1769
|
-
segments.pop();
|
|
1770
|
-
while (segments.length > 0) {
|
|
1771
|
-
paths.push(`/${segments.join("/")}`);
|
|
1772
|
-
segments.pop();
|
|
1773
|
-
}
|
|
1774
|
-
paths.forEach((path) => {
|
|
1775
|
-
let matches = matchRoutes(router.routes, path, router.basename);
|
|
1776
|
-
if (matches) {
|
|
1777
|
-
matches.forEach((m) => routeIds.add(m.route.id));
|
|
1778
|
-
}
|
|
1779
|
-
});
|
|
1780
|
-
let initialRoutes = [...routeIds].reduce(
|
|
1781
|
-
(acc, id) => Object.assign(acc, { [id]: manifest.routes[id] }),
|
|
1782
|
-
{}
|
|
1783
|
-
);
|
|
1784
|
-
return {
|
|
1785
|
-
...manifest,
|
|
1786
|
-
routes: initialRoutes,
|
|
1787
|
-
sri: sri ? true : void 0
|
|
1788
|
-
};
|
|
1789
|
-
}
|
|
1790
|
-
function useDataRouterContext2() {
|
|
1791
|
-
let context = React8.useContext(DataRouterContext);
|
|
1792
|
-
invariant2(
|
|
1793
|
-
context,
|
|
1794
|
-
"You must render this element inside a <DataRouterContext.Provider> element"
|
|
1795
|
-
);
|
|
1796
|
-
return context;
|
|
1797
|
-
}
|
|
1798
|
-
function useDataRouterStateContext() {
|
|
1799
|
-
let context = React8.useContext(DataRouterStateContext);
|
|
1800
|
-
invariant2(
|
|
1801
|
-
context,
|
|
1802
|
-
"You must render this element inside a <DataRouterStateContext.Provider> element"
|
|
1803
|
-
);
|
|
1804
|
-
return context;
|
|
1805
|
-
}
|
|
1806
|
-
var FrameworkContext = React8.createContext(void 0);
|
|
1807
|
-
FrameworkContext.displayName = "FrameworkContext";
|
|
1808
|
-
function useFrameworkContext() {
|
|
1809
|
-
let context = React8.useContext(FrameworkContext);
|
|
1810
|
-
invariant2(
|
|
1811
|
-
context,
|
|
1812
|
-
"You must render this element inside a <HydratedRouter> element"
|
|
1813
|
-
);
|
|
1814
|
-
return context;
|
|
1815
|
-
}
|
|
1816
|
-
function usePrefetchBehavior(prefetch, theirElementProps) {
|
|
1817
|
-
let frameworkContext = React8.useContext(FrameworkContext);
|
|
1818
|
-
let [maybePrefetch, setMaybePrefetch] = React8.useState(false);
|
|
1819
|
-
let [shouldPrefetch, setShouldPrefetch] = React8.useState(false);
|
|
1820
|
-
let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
|
|
1821
|
-
let ref = React8.useRef(null);
|
|
1822
|
-
React8.useEffect(() => {
|
|
1823
|
-
if (prefetch === "render") {
|
|
1824
|
-
setShouldPrefetch(true);
|
|
1825
|
-
}
|
|
1826
|
-
if (prefetch === "viewport") {
|
|
1827
|
-
let callback = (entries) => {
|
|
1828
|
-
entries.forEach((entry) => {
|
|
1829
|
-
setShouldPrefetch(entry.isIntersecting);
|
|
1830
|
-
});
|
|
1831
|
-
};
|
|
1832
|
-
let observer = new IntersectionObserver(callback, { threshold: 0.5 });
|
|
1833
|
-
if (ref.current) observer.observe(ref.current);
|
|
1834
|
-
return () => {
|
|
1835
|
-
observer.disconnect();
|
|
1836
|
-
};
|
|
1837
|
-
}
|
|
1838
|
-
}, [prefetch]);
|
|
1839
|
-
React8.useEffect(() => {
|
|
1840
|
-
if (maybePrefetch) {
|
|
1841
|
-
let id = setTimeout(() => {
|
|
1842
|
-
setShouldPrefetch(true);
|
|
1843
|
-
}, 100);
|
|
1844
|
-
return () => {
|
|
1845
|
-
clearTimeout(id);
|
|
1846
|
-
};
|
|
1847
|
-
}
|
|
1848
|
-
}, [maybePrefetch]);
|
|
1849
|
-
let setIntent = () => {
|
|
1850
|
-
setMaybePrefetch(true);
|
|
1851
|
-
};
|
|
1852
|
-
let cancelIntent = () => {
|
|
1853
|
-
setMaybePrefetch(false);
|
|
1854
|
-
setShouldPrefetch(false);
|
|
1855
|
-
};
|
|
1856
|
-
if (!frameworkContext) {
|
|
1857
|
-
return [false, ref, {}];
|
|
1858
|
-
}
|
|
1859
|
-
if (prefetch !== "intent") {
|
|
1860
|
-
return [shouldPrefetch, ref, {}];
|
|
1861
|
-
}
|
|
1862
|
-
return [
|
|
1863
|
-
shouldPrefetch,
|
|
1864
|
-
ref,
|
|
1865
|
-
{
|
|
1866
|
-
onFocus: composeEventHandlers(onFocus, setIntent),
|
|
1867
|
-
onBlur: composeEventHandlers(onBlur, cancelIntent),
|
|
1868
|
-
onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
|
|
1869
|
-
onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
|
|
1870
|
-
onTouchStart: composeEventHandlers(onTouchStart, setIntent)
|
|
1871
|
-
}
|
|
1872
|
-
];
|
|
1873
|
-
}
|
|
1874
|
-
function composeEventHandlers(theirHandler, ourHandler) {
|
|
1875
|
-
return (event) => {
|
|
1876
|
-
theirHandler && theirHandler(event);
|
|
1877
|
-
if (!event.defaultPrevented) {
|
|
1878
|
-
ourHandler(event);
|
|
1879
|
-
}
|
|
1880
|
-
};
|
|
1881
|
-
}
|
|
1882
|
-
function getActiveMatches(matches, errors, isSpaMode) {
|
|
1883
|
-
if (isSpaMode && !isHydrated) {
|
|
1884
|
-
return [matches[0]];
|
|
1885
|
-
}
|
|
1886
|
-
return matches;
|
|
1887
|
-
}
|
|
1888
|
-
function PrefetchPageLinks({ page, ...linkProps }) {
|
|
1889
|
-
let { router } = useDataRouterContext2();
|
|
1890
|
-
let matches = React8.useMemo(
|
|
1891
|
-
() => matchRoutes(router.routes, page, router.basename),
|
|
1892
|
-
[router.routes, page, router.basename]
|
|
1893
|
-
);
|
|
1894
|
-
if (!matches) {
|
|
1895
|
-
return null;
|
|
1896
|
-
}
|
|
1897
|
-
return /* @__PURE__ */ React8.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
|
|
1898
|
-
}
|
|
1899
|
-
function useKeyedPrefetchLinks(matches) {
|
|
1900
|
-
let { manifest, routeModules } = useFrameworkContext();
|
|
1901
|
-
let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React8.useState([]);
|
|
1902
|
-
React8.useEffect(() => {
|
|
1903
|
-
let interrupted = false;
|
|
1904
|
-
void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
|
|
1905
|
-
(links) => {
|
|
1906
|
-
if (!interrupted) {
|
|
1907
|
-
setKeyedPrefetchLinks(links);
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
);
|
|
1911
|
-
return () => {
|
|
1912
|
-
interrupted = true;
|
|
1913
|
-
};
|
|
1914
|
-
}, [matches, manifest, routeModules]);
|
|
1915
|
-
return keyedPrefetchLinks;
|
|
1916
|
-
}
|
|
1917
|
-
function PrefetchPageLinksImpl({
|
|
1918
|
-
page,
|
|
1919
|
-
matches: nextMatches,
|
|
1920
|
-
...linkProps
|
|
1921
|
-
}) {
|
|
1922
|
-
let location = useLocation();
|
|
1923
|
-
let { manifest, routeModules } = useFrameworkContext();
|
|
1924
|
-
let { basename } = useDataRouterContext2();
|
|
1925
|
-
let { loaderData, matches } = useDataRouterStateContext();
|
|
1926
|
-
let newMatchesForData = React8.useMemo(
|
|
1927
|
-
() => getNewMatchesForLinks(
|
|
1928
|
-
page,
|
|
1929
|
-
nextMatches,
|
|
1930
|
-
matches,
|
|
1931
|
-
manifest,
|
|
1932
|
-
location,
|
|
1933
|
-
"data"
|
|
1934
|
-
),
|
|
1935
|
-
[page, nextMatches, matches, manifest, location]
|
|
1936
|
-
);
|
|
1937
|
-
let newMatchesForAssets = React8.useMemo(
|
|
1938
|
-
() => getNewMatchesForLinks(
|
|
1939
|
-
page,
|
|
1940
|
-
nextMatches,
|
|
1941
|
-
matches,
|
|
1942
|
-
manifest,
|
|
1943
|
-
location,
|
|
1944
|
-
"assets"
|
|
1945
|
-
),
|
|
1946
|
-
[page, nextMatches, matches, manifest, location]
|
|
1947
|
-
);
|
|
1948
|
-
let dataHrefs = React8.useMemo(() => {
|
|
1949
|
-
if (page === location.pathname + location.search + location.hash) {
|
|
1950
|
-
return [];
|
|
1951
|
-
}
|
|
1952
|
-
let routesParams = /* @__PURE__ */ new Set();
|
|
1953
|
-
let foundOptOutRoute = false;
|
|
1954
|
-
nextMatches.forEach((m) => {
|
|
1955
|
-
let manifestRoute = manifest.routes[m.route.id];
|
|
1956
|
-
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
1957
|
-
return;
|
|
1958
|
-
}
|
|
1959
|
-
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && routeModules[m.route.id]?.shouldRevalidate) {
|
|
1960
|
-
foundOptOutRoute = true;
|
|
1961
|
-
} else if (manifestRoute.hasClientLoader) {
|
|
1962
|
-
foundOptOutRoute = true;
|
|
1963
|
-
} else {
|
|
1964
|
-
routesParams.add(m.route.id);
|
|
1965
|
-
}
|
|
1966
|
-
});
|
|
1967
|
-
if (routesParams.size === 0) {
|
|
1968
|
-
return [];
|
|
1969
|
-
}
|
|
1970
|
-
let url = singleFetchUrl(page, basename, "data");
|
|
1971
|
-
if (foundOptOutRoute && routesParams.size > 0) {
|
|
1972
|
-
url.searchParams.set(
|
|
1973
|
-
"_routes",
|
|
1974
|
-
nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
|
|
1975
|
-
);
|
|
1976
|
-
}
|
|
1977
|
-
return [url.pathname + url.search];
|
|
1978
|
-
}, [
|
|
1979
|
-
basename,
|
|
1980
|
-
loaderData,
|
|
1981
|
-
location,
|
|
1982
|
-
manifest,
|
|
1983
|
-
newMatchesForData,
|
|
1984
|
-
nextMatches,
|
|
1985
|
-
page,
|
|
1986
|
-
routeModules
|
|
1987
|
-
]);
|
|
1988
|
-
let moduleHrefs = React8.useMemo(
|
|
1989
|
-
() => getModuleLinkHrefs(newMatchesForAssets, manifest),
|
|
1990
|
-
[newMatchesForAssets, manifest]
|
|
1991
|
-
);
|
|
1992
|
-
let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
|
|
1993
|
-
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React8.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React8.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
|
|
1994
|
-
// these don't spread `linkProps` because they are full link descriptors
|
|
1995
|
-
// already with their own props
|
|
1996
|
-
/* @__PURE__ */ React8.createElement("link", { key, nonce: linkProps.nonce, ...link })
|
|
1997
|
-
)));
|
|
1998
|
-
}
|
|
1999
|
-
var isHydrated = false;
|
|
2000
|
-
function setIsHydrated() {
|
|
2001
|
-
isHydrated = true;
|
|
2002
|
-
}
|
|
2003
|
-
function Scripts(scriptProps) {
|
|
2004
|
-
let {
|
|
2005
|
-
manifest,
|
|
2006
|
-
serverHandoffString,
|
|
2007
|
-
isSpaMode,
|
|
2008
|
-
renderMeta,
|
|
2009
|
-
routeDiscovery,
|
|
2010
|
-
ssr
|
|
2011
|
-
} = useFrameworkContext();
|
|
2012
|
-
let { router, static: isStatic, staticContext } = useDataRouterContext2();
|
|
2013
|
-
let { matches: routerMatches } = useDataRouterStateContext();
|
|
2014
|
-
let isRSCRouterContext = useIsRSCRouterContext();
|
|
2015
|
-
let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr);
|
|
2016
|
-
if (renderMeta) {
|
|
2017
|
-
renderMeta.didRenderScripts = true;
|
|
2018
|
-
}
|
|
2019
|
-
let matches = getActiveMatches(routerMatches, null, isSpaMode);
|
|
2020
|
-
React8.useEffect(() => {
|
|
2021
|
-
setIsHydrated();
|
|
2022
|
-
}, []);
|
|
2023
|
-
let initialScripts = React8.useMemo(() => {
|
|
2024
|
-
if (isRSCRouterContext) {
|
|
2025
|
-
return null;
|
|
2026
|
-
}
|
|
2027
|
-
let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
|
|
2028
|
-
let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
|
|
2029
|
-
let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
|
|
2030
|
-
${matches.map((match, routeIndex) => {
|
|
2031
|
-
let routeVarName = `route${routeIndex}`;
|
|
2032
|
-
let manifestEntry = manifest.routes[match.route.id];
|
|
2033
|
-
invariant2(manifestEntry, `Route ${match.route.id} not found in manifest`);
|
|
2034
|
-
let {
|
|
2035
|
-
clientActionModule,
|
|
2036
|
-
clientLoaderModule,
|
|
2037
|
-
clientMiddlewareModule,
|
|
2038
|
-
hydrateFallbackModule,
|
|
2039
|
-
module
|
|
2040
|
-
} = manifestEntry;
|
|
2041
|
-
let chunks = [
|
|
2042
|
-
...clientActionModule ? [
|
|
2043
|
-
{
|
|
2044
|
-
module: clientActionModule,
|
|
2045
|
-
varName: `${routeVarName}_clientAction`
|
|
2046
|
-
}
|
|
2047
|
-
] : [],
|
|
2048
|
-
...clientLoaderModule ? [
|
|
2049
|
-
{
|
|
2050
|
-
module: clientLoaderModule,
|
|
2051
|
-
varName: `${routeVarName}_clientLoader`
|
|
2052
|
-
}
|
|
2053
|
-
] : [],
|
|
2054
|
-
...clientMiddlewareModule ? [
|
|
2055
|
-
{
|
|
2056
|
-
module: clientMiddlewareModule,
|
|
2057
|
-
varName: `${routeVarName}_clientMiddleware`
|
|
2058
|
-
}
|
|
2059
|
-
] : [],
|
|
2060
|
-
...hydrateFallbackModule ? [
|
|
2061
|
-
{
|
|
2062
|
-
module: hydrateFallbackModule,
|
|
2063
|
-
varName: `${routeVarName}_HydrateFallback`
|
|
2064
|
-
}
|
|
2065
|
-
] : [],
|
|
2066
|
-
{ module, varName: `${routeVarName}_main` }
|
|
2067
|
-
];
|
|
2068
|
-
if (chunks.length === 1) {
|
|
2069
|
-
return `import * as ${routeVarName} from ${JSON.stringify(module)};`;
|
|
2070
|
-
}
|
|
2071
|
-
let chunkImportsSnippet = chunks.map((chunk) => `import * as ${chunk.varName} from "${chunk.module}";`).join("\n");
|
|
2072
|
-
let mergedChunksSnippet = `const ${routeVarName} = {${chunks.map((chunk) => `...${chunk.varName}`).join(",")}};`;
|
|
2073
|
-
return [chunkImportsSnippet, mergedChunksSnippet].join("\n");
|
|
2074
|
-
}).join("\n")}
|
|
2075
|
-
${enableFogOfWar ? (
|
|
2076
|
-
// Inline a minimal manifest with the SSR matches
|
|
2077
|
-
`window.__reactRouterManifest = ${JSON.stringify(
|
|
2078
|
-
getPartialManifest(manifest, router),
|
|
2079
|
-
null,
|
|
2080
|
-
2
|
|
2081
|
-
)};`
|
|
2082
|
-
) : ""}
|
|
2083
|
-
window.__reactRouterRouteModules = {${matches.map((match, index) => `${JSON.stringify(match.route.id)}:route${index}`).join(",")}};
|
|
2084
|
-
|
|
2085
|
-
import(${JSON.stringify(manifest.entry.module)});`;
|
|
2086
|
-
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(
|
|
2087
|
-
"script",
|
|
2088
|
-
{
|
|
2089
|
-
...scriptProps,
|
|
2090
|
-
suppressHydrationWarning: true,
|
|
2091
|
-
dangerouslySetInnerHTML: { __html: contextScript },
|
|
2092
|
-
type: void 0
|
|
2093
|
-
}
|
|
2094
|
-
), /* @__PURE__ */ React8.createElement(
|
|
2095
|
-
"script",
|
|
2096
|
-
{
|
|
2097
|
-
...scriptProps,
|
|
2098
|
-
suppressHydrationWarning: true,
|
|
2099
|
-
dangerouslySetInnerHTML: { __html: routeModulesScript },
|
|
2100
|
-
type: "module",
|
|
2101
|
-
async: true
|
|
2102
|
-
}
|
|
2103
|
-
));
|
|
2104
|
-
}, []);
|
|
2105
|
-
let preloads = isHydrated || isRSCRouterContext ? [] : dedupe(
|
|
2106
|
-
manifest.entry.imports.concat(
|
|
2107
|
-
getModuleLinkHrefs(matches, manifest, {
|
|
2108
|
-
includeHydrateFallback: true
|
|
2109
|
-
})
|
|
2110
|
-
)
|
|
2111
|
-
);
|
|
2112
|
-
let sri = typeof manifest.sri === "object" ? manifest.sri : {};
|
|
2113
|
-
warnOnce(
|
|
2114
|
-
!isRSCRouterContext,
|
|
2115
|
-
"The <Scripts /> element is a no-op when using RSC and can be safely removed."
|
|
2116
|
-
);
|
|
2117
|
-
return isHydrated || isRSCRouterContext ? null : /* @__PURE__ */ React8.createElement(React8.Fragment, null, typeof manifest.sri === "object" ? /* @__PURE__ */ React8.createElement(
|
|
2118
|
-
"script",
|
|
2119
|
-
{
|
|
2120
|
-
"rr-importmap": "",
|
|
2121
|
-
type: "importmap",
|
|
2122
|
-
suppressHydrationWarning: true,
|
|
2123
|
-
dangerouslySetInnerHTML: {
|
|
2124
|
-
__html: JSON.stringify({
|
|
2125
|
-
integrity: sri
|
|
2126
|
-
})
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
) : null, !enableFogOfWar ? /* @__PURE__ */ React8.createElement(
|
|
2130
|
-
"link",
|
|
2131
|
-
{
|
|
2132
|
-
rel: "modulepreload",
|
|
2133
|
-
href: manifest.url,
|
|
2134
|
-
crossOrigin: scriptProps.crossOrigin,
|
|
2135
|
-
integrity: sri[manifest.url],
|
|
2136
|
-
suppressHydrationWarning: true
|
|
2137
|
-
}
|
|
2138
|
-
) : null, /* @__PURE__ */ React8.createElement(
|
|
2139
|
-
"link",
|
|
2140
|
-
{
|
|
2141
|
-
rel: "modulepreload",
|
|
2142
|
-
href: manifest.entry.module,
|
|
2143
|
-
crossOrigin: scriptProps.crossOrigin,
|
|
2144
|
-
integrity: sri[manifest.entry.module],
|
|
2145
|
-
suppressHydrationWarning: true
|
|
2146
|
-
}
|
|
2147
|
-
), preloads.map((path) => /* @__PURE__ */ React8.createElement(
|
|
2148
|
-
"link",
|
|
2149
|
-
{
|
|
2150
|
-
key: path,
|
|
2151
|
-
rel: "modulepreload",
|
|
2152
|
-
href: path,
|
|
2153
|
-
crossOrigin: scriptProps.crossOrigin,
|
|
2154
|
-
integrity: sri[path],
|
|
2155
|
-
suppressHydrationWarning: true
|
|
2156
|
-
}
|
|
2157
|
-
)), initialScripts);
|
|
2158
|
-
}
|
|
2159
|
-
function dedupe(array) {
|
|
2160
|
-
return [...new Set(array)];
|
|
2161
|
-
}
|
|
2162
|
-
function mergeRefs(...refs) {
|
|
2163
|
-
return (value) => {
|
|
2164
|
-
refs.forEach((ref) => {
|
|
2165
|
-
if (typeof ref === "function") {
|
|
2166
|
-
ref(value);
|
|
2167
|
-
} else if (ref != null) {
|
|
2168
|
-
ref.current = value;
|
|
2169
|
-
}
|
|
2170
|
-
});
|
|
2171
|
-
};
|
|
2172
|
-
}
|
|
2173
|
-
(class extends React9.Component {
|
|
2174
|
-
constructor(props) {
|
|
2175
|
-
super(props);
|
|
2176
|
-
this.state = { error: props.error || null, location: props.location };
|
|
2177
|
-
}
|
|
2178
|
-
static getDerivedStateFromError(error) {
|
|
2179
|
-
return { error };
|
|
2180
|
-
}
|
|
2181
|
-
static getDerivedStateFromProps(props, state) {
|
|
2182
|
-
if (state.location !== props.location) {
|
|
2183
|
-
return { error: props.error || null, location: props.location };
|
|
2184
|
-
}
|
|
2185
|
-
return { error: props.error || state.error, location: state.location };
|
|
2186
|
-
}
|
|
2187
|
-
render() {
|
|
2188
|
-
if (this.state.error) {
|
|
2189
|
-
return /* @__PURE__ */ React9.createElement(
|
|
2190
|
-
RemixRootDefaultErrorBoundary,
|
|
2191
|
-
{
|
|
2192
|
-
error: this.state.error,
|
|
2193
|
-
isOutsideRemixApp: true
|
|
2194
|
-
}
|
|
2195
|
-
);
|
|
2196
|
-
} else {
|
|
2197
|
-
return this.props.children;
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
});
|
|
2201
|
-
function RemixRootDefaultErrorBoundary({
|
|
2202
|
-
error,
|
|
2203
|
-
isOutsideRemixApp
|
|
2204
|
-
}) {
|
|
2205
|
-
console.error(error);
|
|
2206
|
-
let heyDeveloper = /* @__PURE__ */ React9.createElement(
|
|
2207
|
-
"script",
|
|
2208
|
-
{
|
|
2209
|
-
dangerouslySetInnerHTML: {
|
|
2210
|
-
__html: `
|
|
2211
|
-
console.log(
|
|
2212
|
-
"💿 Hey developer 👋. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
|
|
2213
|
-
);
|
|
2214
|
-
`
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
);
|
|
2218
|
-
if (isRouteErrorResponse(error)) {
|
|
2219
|
-
return /* @__PURE__ */ React9.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React9.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), heyDeveloper );
|
|
2220
|
-
}
|
|
2221
|
-
let errorInstance;
|
|
2222
|
-
if (error instanceof Error) {
|
|
2223
|
-
errorInstance = error;
|
|
2224
|
-
} else {
|
|
2225
|
-
let errorString = error == null ? "Unknown Error" : typeof error === "object" && "toString" in error ? error.toString() : JSON.stringify(error);
|
|
2226
|
-
errorInstance = new Error(errorString);
|
|
2227
|
-
}
|
|
2228
|
-
return /* @__PURE__ */ React9.createElement(
|
|
2229
|
-
BoundaryShell,
|
|
2230
|
-
{
|
|
2231
|
-
title: "Application Error!",
|
|
2232
|
-
isOutsideRemixApp
|
|
2233
|
-
},
|
|
2234
|
-
/* @__PURE__ */ React9.createElement("h1", { style: { fontSize: "24px" } }, "Application Error"),
|
|
2235
|
-
/* @__PURE__ */ React9.createElement(
|
|
2236
|
-
"pre",
|
|
2237
|
-
{
|
|
2238
|
-
style: {
|
|
2239
|
-
padding: "2rem",
|
|
2240
|
-
background: "hsla(10, 50%, 50%, 0.1)",
|
|
2241
|
-
color: "red",
|
|
2242
|
-
overflow: "auto"
|
|
2243
|
-
}
|
|
2244
|
-
},
|
|
2245
|
-
errorInstance.stack
|
|
2246
|
-
),
|
|
2247
|
-
heyDeveloper
|
|
2248
|
-
);
|
|
2249
|
-
}
|
|
2250
|
-
function BoundaryShell({
|
|
2251
|
-
title,
|
|
2252
|
-
renderScripts,
|
|
2253
|
-
isOutsideRemixApp,
|
|
2254
|
-
children
|
|
2255
|
-
}) {
|
|
2256
|
-
let { routeModules } = useFrameworkContext();
|
|
2257
|
-
if (routeModules.root?.Layout && !isOutsideRemixApp) {
|
|
2258
|
-
return children;
|
|
2259
|
-
}
|
|
2260
|
-
return /* @__PURE__ */ React9.createElement("html", { lang: "en" }, /* @__PURE__ */ React9.createElement("head", null, /* @__PURE__ */ React9.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ React9.createElement(
|
|
2261
|
-
"meta",
|
|
2262
|
-
{
|
|
2263
|
-
name: "viewport",
|
|
2264
|
-
content: "width=device-width,initial-scale=1,viewport-fit=cover"
|
|
2265
|
-
}
|
|
2266
|
-
), /* @__PURE__ */ React9.createElement("title", null, title)), /* @__PURE__ */ React9.createElement("body", null, /* @__PURE__ */ React9.createElement("main", { style: { fontFamily: "system-ui, sans-serif", padding: "2rem" } }, children, renderScripts ? /* @__PURE__ */ React9.createElement(Scripts, null) : null)));
|
|
2267
|
-
}
|
|
2268
|
-
const React10 = await importShared('react');
|
|
2269
|
-
|
|
2270
|
-
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
2271
|
-
try {
|
|
2272
|
-
if (isBrowser) {
|
|
2273
|
-
window.__reactRouterVersion = // @ts-expect-error
|
|
2274
|
-
"7.9.3";
|
|
2275
|
-
}
|
|
2276
|
-
} catch (e) {
|
|
2277
|
-
}
|
|
2278
|
-
function BrowserRouter({
|
|
2279
|
-
basename,
|
|
2280
|
-
children,
|
|
2281
|
-
window: window2
|
|
2282
|
-
}) {
|
|
2283
|
-
let historyRef = React10.useRef();
|
|
2284
|
-
if (historyRef.current == null) {
|
|
2285
|
-
historyRef.current = createBrowserHistory({ window: window2, v5Compat: true });
|
|
2286
|
-
}
|
|
2287
|
-
let history = historyRef.current;
|
|
2288
|
-
let [state, setStateImpl] = React10.useState({
|
|
2289
|
-
action: history.action,
|
|
2290
|
-
location: history.location
|
|
2291
|
-
});
|
|
2292
|
-
let setState = React10.useCallback(
|
|
2293
|
-
(newState) => {
|
|
2294
|
-
React10.startTransition(() => setStateImpl(newState));
|
|
2295
|
-
},
|
|
2296
|
-
[setStateImpl]
|
|
2297
|
-
);
|
|
2298
|
-
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
2299
|
-
return /* @__PURE__ */ React10.createElement(
|
|
2300
|
-
Router,
|
|
2301
|
-
{
|
|
2302
|
-
basename,
|
|
2303
|
-
children,
|
|
2304
|
-
location: state.location,
|
|
2305
|
-
navigationType: state.action,
|
|
2306
|
-
navigator: history
|
|
2307
|
-
}
|
|
2308
|
-
);
|
|
2309
|
-
}
|
|
2310
|
-
var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
2311
|
-
var Link = React10.forwardRef(
|
|
2312
|
-
function LinkWithRef({
|
|
2313
|
-
onClick,
|
|
2314
|
-
discover = "render",
|
|
2315
|
-
prefetch = "none",
|
|
2316
|
-
relative,
|
|
2317
|
-
reloadDocument,
|
|
2318
|
-
replace: replace2,
|
|
2319
|
-
state,
|
|
2320
|
-
target,
|
|
2321
|
-
to,
|
|
2322
|
-
preventScrollReset,
|
|
2323
|
-
viewTransition,
|
|
2324
|
-
...rest
|
|
2325
|
-
}, forwardedRef) {
|
|
2326
|
-
let { basename } = React10.useContext(NavigationContext);
|
|
2327
|
-
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
|
|
2328
|
-
let absoluteHref;
|
|
2329
|
-
let isExternal = false;
|
|
2330
|
-
if (typeof to === "string" && isAbsolute) {
|
|
2331
|
-
absoluteHref = to;
|
|
2332
|
-
if (isBrowser) {
|
|
2333
|
-
try {
|
|
2334
|
-
let currentUrl = new URL(window.location.href);
|
|
2335
|
-
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
|
|
2336
|
-
let path = stripBasename(targetUrl.pathname, basename);
|
|
2337
|
-
if (targetUrl.origin === currentUrl.origin && path != null) {
|
|
2338
|
-
to = path + targetUrl.search + targetUrl.hash;
|
|
2339
|
-
} else {
|
|
2340
|
-
isExternal = true;
|
|
2341
|
-
}
|
|
2342
|
-
} catch (e) {
|
|
2343
|
-
warning(
|
|
2344
|
-
false,
|
|
2345
|
-
`<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
|
|
2346
|
-
);
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
}
|
|
2350
|
-
let href = useHref(to, { relative });
|
|
2351
|
-
let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
|
|
2352
|
-
prefetch,
|
|
2353
|
-
rest
|
|
2354
|
-
);
|
|
2355
|
-
let internalOnClick = useLinkClickHandler(to, {
|
|
2356
|
-
replace: replace2,
|
|
2357
|
-
state,
|
|
2358
|
-
target,
|
|
2359
|
-
preventScrollReset,
|
|
2360
|
-
relative,
|
|
2361
|
-
viewTransition
|
|
2362
|
-
});
|
|
2363
|
-
function handleClick(event) {
|
|
2364
|
-
if (onClick) onClick(event);
|
|
2365
|
-
if (!event.defaultPrevented) {
|
|
2366
|
-
internalOnClick(event);
|
|
2367
|
-
}
|
|
2368
|
-
}
|
|
2369
|
-
let link = (
|
|
2370
|
-
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
2371
|
-
/* @__PURE__ */ React10.createElement(
|
|
2372
|
-
"a",
|
|
2373
|
-
{
|
|
2374
|
-
...rest,
|
|
2375
|
-
...prefetchHandlers,
|
|
2376
|
-
href: absoluteHref || href,
|
|
2377
|
-
onClick: isExternal || reloadDocument ? onClick : handleClick,
|
|
2378
|
-
ref: mergeRefs(forwardedRef, prefetchRef),
|
|
2379
|
-
target,
|
|
2380
|
-
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
2381
|
-
}
|
|
2382
|
-
)
|
|
2383
|
-
);
|
|
2384
|
-
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React10.createElement(React10.Fragment, null, link, /* @__PURE__ */ React10.createElement(PrefetchPageLinks, { page: href })) : link;
|
|
2385
|
-
}
|
|
2386
|
-
);
|
|
2387
|
-
Link.displayName = "Link";
|
|
2388
|
-
var NavLink = React10.forwardRef(
|
|
2389
|
-
function NavLinkWithRef({
|
|
2390
|
-
"aria-current": ariaCurrentProp = "page",
|
|
2391
|
-
caseSensitive = false,
|
|
2392
|
-
className: classNameProp = "",
|
|
2393
|
-
end = false,
|
|
2394
|
-
style: styleProp,
|
|
2395
|
-
to,
|
|
2396
|
-
viewTransition,
|
|
2397
|
-
children,
|
|
2398
|
-
...rest
|
|
2399
|
-
}, ref) {
|
|
2400
|
-
let path = useResolvedPath(to, { relative: rest.relative });
|
|
2401
|
-
let location = useLocation();
|
|
2402
|
-
let routerState = React10.useContext(DataRouterStateContext);
|
|
2403
|
-
let { navigator, basename } = React10.useContext(NavigationContext);
|
|
2404
|
-
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
2405
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
2406
|
-
useViewTransitionState(path) && viewTransition === true;
|
|
2407
|
-
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
|
|
2408
|
-
let locationPathname = location.pathname;
|
|
2409
|
-
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
|
2410
|
-
if (!caseSensitive) {
|
|
2411
|
-
locationPathname = locationPathname.toLowerCase();
|
|
2412
|
-
nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
|
|
2413
|
-
toPathname = toPathname.toLowerCase();
|
|
2414
|
-
}
|
|
2415
|
-
if (nextLocationPathname && basename) {
|
|
2416
|
-
nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
|
|
2417
|
-
}
|
|
2418
|
-
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
|
|
2419
|
-
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
|
|
2420
|
-
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
|
|
2421
|
-
let renderProps = {
|
|
2422
|
-
isActive,
|
|
2423
|
-
isPending,
|
|
2424
|
-
isTransitioning
|
|
2425
|
-
};
|
|
2426
|
-
let ariaCurrent = isActive ? ariaCurrentProp : void 0;
|
|
2427
|
-
let className;
|
|
2428
|
-
if (typeof classNameProp === "function") {
|
|
2429
|
-
className = classNameProp(renderProps);
|
|
2430
|
-
} else {
|
|
2431
|
-
className = [
|
|
2432
|
-
classNameProp,
|
|
2433
|
-
isActive ? "active" : null,
|
|
2434
|
-
isPending ? "pending" : null,
|
|
2435
|
-
isTransitioning ? "transitioning" : null
|
|
2436
|
-
].filter(Boolean).join(" ");
|
|
2437
|
-
}
|
|
2438
|
-
let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
|
|
2439
|
-
return /* @__PURE__ */ React10.createElement(
|
|
2440
|
-
Link,
|
|
2441
|
-
{
|
|
2442
|
-
...rest,
|
|
2443
|
-
"aria-current": ariaCurrent,
|
|
2444
|
-
className,
|
|
2445
|
-
ref,
|
|
2446
|
-
style,
|
|
2447
|
-
to,
|
|
2448
|
-
viewTransition
|
|
2449
|
-
},
|
|
2450
|
-
typeof children === "function" ? children(renderProps) : children
|
|
2451
|
-
);
|
|
2452
|
-
}
|
|
2453
|
-
);
|
|
2454
|
-
NavLink.displayName = "NavLink";
|
|
2455
|
-
var Form = React10.forwardRef(
|
|
2456
|
-
({
|
|
2457
|
-
discover = "render",
|
|
2458
|
-
fetcherKey,
|
|
2459
|
-
navigate,
|
|
2460
|
-
reloadDocument,
|
|
2461
|
-
replace: replace2,
|
|
2462
|
-
state,
|
|
2463
|
-
method = defaultMethod,
|
|
2464
|
-
action,
|
|
2465
|
-
onSubmit,
|
|
2466
|
-
relative,
|
|
2467
|
-
preventScrollReset,
|
|
2468
|
-
viewTransition,
|
|
2469
|
-
...props
|
|
2470
|
-
}, forwardedRef) => {
|
|
2471
|
-
let submit = useSubmit();
|
|
2472
|
-
let formAction = useFormAction(action, { relative });
|
|
2473
|
-
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
|
2474
|
-
let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
|
|
2475
|
-
let submitHandler = (event) => {
|
|
2476
|
-
onSubmit && onSubmit(event);
|
|
2477
|
-
if (event.defaultPrevented) return;
|
|
2478
|
-
event.preventDefault();
|
|
2479
|
-
let submitter = event.nativeEvent.submitter;
|
|
2480
|
-
let submitMethod = submitter?.getAttribute("formmethod") || method;
|
|
2481
|
-
submit(submitter || event.currentTarget, {
|
|
2482
|
-
fetcherKey,
|
|
2483
|
-
method: submitMethod,
|
|
2484
|
-
navigate,
|
|
2485
|
-
replace: replace2,
|
|
2486
|
-
state,
|
|
2487
|
-
relative,
|
|
2488
|
-
preventScrollReset,
|
|
2489
|
-
viewTransition
|
|
2490
|
-
});
|
|
2491
|
-
};
|
|
2492
|
-
return /* @__PURE__ */ React10.createElement(
|
|
2493
|
-
"form",
|
|
2494
|
-
{
|
|
2495
|
-
ref: forwardedRef,
|
|
2496
|
-
method: formMethod,
|
|
2497
|
-
action: formAction,
|
|
2498
|
-
onSubmit: reloadDocument ? onSubmit : submitHandler,
|
|
2499
|
-
...props,
|
|
2500
|
-
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
2501
|
-
}
|
|
2502
|
-
);
|
|
2503
|
-
}
|
|
2504
|
-
);
|
|
2505
|
-
Form.displayName = "Form";
|
|
2506
|
-
function getDataRouterConsoleError2(hookName) {
|
|
2507
|
-
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
2508
|
-
}
|
|
2509
|
-
function useDataRouterContext3(hookName) {
|
|
2510
|
-
let ctx = React10.useContext(DataRouterContext);
|
|
2511
|
-
invariant(ctx, getDataRouterConsoleError2(hookName));
|
|
2512
|
-
return ctx;
|
|
2513
|
-
}
|
|
2514
|
-
function useLinkClickHandler(to, {
|
|
2515
|
-
target,
|
|
2516
|
-
replace: replaceProp,
|
|
2517
|
-
state,
|
|
2518
|
-
preventScrollReset,
|
|
2519
|
-
relative,
|
|
2520
|
-
viewTransition
|
|
2521
|
-
} = {}) {
|
|
2522
|
-
let navigate = useNavigate();
|
|
2523
|
-
let location = useLocation();
|
|
2524
|
-
let path = useResolvedPath(to, { relative });
|
|
2525
|
-
return React10.useCallback(
|
|
2526
|
-
(event) => {
|
|
2527
|
-
if (shouldProcessLinkClick(event, target)) {
|
|
2528
|
-
event.preventDefault();
|
|
2529
|
-
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
|
|
2530
|
-
navigate(to, {
|
|
2531
|
-
replace: replace2,
|
|
2532
|
-
state,
|
|
2533
|
-
preventScrollReset,
|
|
2534
|
-
relative,
|
|
2535
|
-
viewTransition
|
|
2536
|
-
});
|
|
2537
|
-
}
|
|
2538
|
-
},
|
|
2539
|
-
[
|
|
2540
|
-
location,
|
|
2541
|
-
navigate,
|
|
2542
|
-
path,
|
|
2543
|
-
replaceProp,
|
|
2544
|
-
state,
|
|
2545
|
-
target,
|
|
2546
|
-
to,
|
|
2547
|
-
preventScrollReset,
|
|
2548
|
-
relative,
|
|
2549
|
-
viewTransition
|
|
2550
|
-
]
|
|
2551
|
-
);
|
|
2552
|
-
}
|
|
2553
|
-
var fetcherId = 0;
|
|
2554
|
-
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
|
|
2555
|
-
function useSubmit() {
|
|
2556
|
-
let { router } = useDataRouterContext3(
|
|
2557
|
-
"useSubmit"
|
|
2558
|
-
/* UseSubmit */
|
|
2559
|
-
);
|
|
2560
|
-
let { basename } = React10.useContext(NavigationContext);
|
|
2561
|
-
let currentRouteId = useRouteId();
|
|
2562
|
-
return React10.useCallback(
|
|
2563
|
-
async (target, options = {}) => {
|
|
2564
|
-
let { action, method, encType, formData, body } = getFormSubmissionInfo(
|
|
2565
|
-
target,
|
|
2566
|
-
basename
|
|
2567
|
-
);
|
|
2568
|
-
if (options.navigate === false) {
|
|
2569
|
-
let key = options.fetcherKey || getUniqueFetcherId();
|
|
2570
|
-
await router.fetch(key, currentRouteId, options.action || action, {
|
|
2571
|
-
preventScrollReset: options.preventScrollReset,
|
|
2572
|
-
formData,
|
|
2573
|
-
body,
|
|
2574
|
-
formMethod: options.method || method,
|
|
2575
|
-
formEncType: options.encType || encType,
|
|
2576
|
-
flushSync: options.flushSync
|
|
2577
|
-
});
|
|
2578
|
-
} else {
|
|
2579
|
-
await router.navigate(options.action || action, {
|
|
2580
|
-
preventScrollReset: options.preventScrollReset,
|
|
2581
|
-
formData,
|
|
2582
|
-
body,
|
|
2583
|
-
formMethod: options.method || method,
|
|
2584
|
-
formEncType: options.encType || encType,
|
|
2585
|
-
replace: options.replace,
|
|
2586
|
-
state: options.state,
|
|
2587
|
-
fromRouteId: currentRouteId,
|
|
2588
|
-
flushSync: options.flushSync,
|
|
2589
|
-
viewTransition: options.viewTransition
|
|
2590
|
-
});
|
|
2591
|
-
}
|
|
2592
|
-
},
|
|
2593
|
-
[router, basename, currentRouteId]
|
|
2594
|
-
);
|
|
2595
|
-
}
|
|
2596
|
-
function useFormAction(action, { relative } = {}) {
|
|
2597
|
-
let { basename } = React10.useContext(NavigationContext);
|
|
2598
|
-
let routeContext = React10.useContext(RouteContext);
|
|
2599
|
-
invariant(routeContext, "useFormAction must be used inside a RouteContext");
|
|
2600
|
-
let [match] = routeContext.matches.slice(-1);
|
|
2601
|
-
let path = { ...useResolvedPath(action ? action : ".", { relative }) };
|
|
2602
|
-
let location = useLocation();
|
|
2603
|
-
if (action == null) {
|
|
2604
|
-
path.search = location.search;
|
|
2605
|
-
let params = new URLSearchParams(path.search);
|
|
2606
|
-
let indexValues = params.getAll("index");
|
|
2607
|
-
let hasNakedIndexParam = indexValues.some((v) => v === "");
|
|
2608
|
-
if (hasNakedIndexParam) {
|
|
2609
|
-
params.delete("index");
|
|
2610
|
-
indexValues.filter((v) => v).forEach((v) => params.append("index", v));
|
|
2611
|
-
let qs = params.toString();
|
|
2612
|
-
path.search = qs ? `?${qs}` : "";
|
|
2613
|
-
}
|
|
2614
|
-
}
|
|
2615
|
-
if ((!action || action === ".") && match.route.index) {
|
|
2616
|
-
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
|
2617
|
-
}
|
|
2618
|
-
if (basename !== "/") {
|
|
2619
|
-
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
2620
|
-
}
|
|
2621
|
-
return createPath(path);
|
|
2622
|
-
}
|
|
2623
|
-
function useViewTransitionState(to, { relative } = {}) {
|
|
2624
|
-
let vtContext = React10.useContext(ViewTransitionContext);
|
|
2625
|
-
invariant(
|
|
2626
|
-
vtContext != null,
|
|
2627
|
-
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
|
|
2628
|
-
);
|
|
2629
|
-
let { basename } = useDataRouterContext3(
|
|
2630
|
-
"useViewTransitionState"
|
|
2631
|
-
/* useViewTransitionState */
|
|
2632
|
-
);
|
|
2633
|
-
let path = useResolvedPath(to, { relative });
|
|
2634
|
-
if (!vtContext.isTransitioning) {
|
|
2635
|
-
return false;
|
|
2636
|
-
}
|
|
2637
|
-
let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
|
|
2638
|
-
let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
|
|
2639
|
-
return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
|
|
2640
|
-
}
|
|
2641
|
-
await importShared('react');
|
|
2642
|
-
|
|
2643
|
-
const scriptRel = 'modulepreload';const assetsURL = function(dep) { return "/"+dep };const seen = {};const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
2644
|
-
let promise = Promise.resolve();
|
|
2645
|
-
if (false && deps && deps.length > 0) {
|
|
2646
|
-
let allSettled2 = function(promises) {
|
|
2647
|
-
return Promise.all(
|
|
2648
|
-
promises.map(
|
|
2649
|
-
(p) => Promise.resolve(p).then(
|
|
2650
|
-
(value) => ({ status: "fulfilled", value }),
|
|
2651
|
-
(reason) => ({ status: "rejected", reason })
|
|
2652
|
-
)
|
|
2653
|
-
)
|
|
2654
|
-
);
|
|
2655
|
-
};
|
|
2656
|
-
document.getElementsByTagName("link");
|
|
2657
|
-
const cspNonceMeta = document.querySelector(
|
|
2658
|
-
"meta[property=csp-nonce]"
|
|
2659
|
-
);
|
|
2660
|
-
const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce");
|
|
2661
|
-
promise = allSettled2(
|
|
2662
|
-
deps.map((dep) => {
|
|
2663
|
-
dep = assetsURL(dep);
|
|
2664
|
-
if (dep in seen) return;
|
|
2665
|
-
seen[dep] = true;
|
|
2666
|
-
const isCss = dep.endsWith(".css");
|
|
2667
|
-
const cssSelector = isCss ? '[rel="stylesheet"]' : "";
|
|
2668
|
-
if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) {
|
|
2669
|
-
return;
|
|
2670
|
-
}
|
|
2671
|
-
const link = document.createElement("link");
|
|
2672
|
-
link.rel = isCss ? "stylesheet" : scriptRel;
|
|
2673
|
-
if (!isCss) {
|
|
2674
|
-
link.as = "script";
|
|
2675
|
-
}
|
|
2676
|
-
link.crossOrigin = "";
|
|
2677
|
-
link.href = dep;
|
|
2678
|
-
if (cspNonce) {
|
|
2679
|
-
link.setAttribute("nonce", cspNonce);
|
|
2680
|
-
}
|
|
2681
|
-
document.head.appendChild(link);
|
|
2682
|
-
if (isCss) {
|
|
2683
|
-
return new Promise((res, rej) => {
|
|
2684
|
-
link.addEventListener("load", res);
|
|
2685
|
-
link.addEventListener(
|
|
2686
|
-
"error",
|
|
2687
|
-
() => rej(new Error(`Unable to preload CSS for ${dep}`))
|
|
2688
|
-
);
|
|
2689
|
-
});
|
|
2690
|
-
}
|
|
2691
|
-
})
|
|
2692
|
-
);
|
|
2693
|
-
}
|
|
2694
|
-
function handlePreloadError(err) {
|
|
2695
|
-
const e = new Event("vite:preloadError", {
|
|
2696
|
-
cancelable: true
|
|
2697
|
-
});
|
|
2698
|
-
e.payload = err;
|
|
2699
|
-
window.dispatchEvent(e);
|
|
2700
|
-
if (!e.defaultPrevented) {
|
|
2701
|
-
throw err;
|
|
2702
|
-
}
|
|
2703
|
-
}
|
|
2704
|
-
return promise.then((res) => {
|
|
2705
|
-
for (const item of res || []) {
|
|
2706
|
-
if (item.status !== "rejected") continue;
|
|
2707
|
-
handlePreloadError(item.reason);
|
|
2708
|
-
}
|
|
2709
|
-
return baseModule().catch(handlePreloadError);
|
|
2710
|
-
});
|
|
2711
|
-
};
|
|
2712
|
-
|
|
2713
|
-
const {lazy} = await importShared('react');
|
|
2714
|
-
const Home = lazy(() => __vitePreload(() => module.import('./home-BBY02MnI.js'),false ?__VITE_PRELOAD__:void 0));
|
|
2715
|
-
function RouteConfig() {
|
|
2716
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Routes, { children: [
|
|
2717
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Route, { path: "/", element: /* @__PURE__ */ jsxRuntimeExports.jsx(Home, {}) }),
|
|
2718
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Route, { path: "*", element: /* @__PURE__ */ jsxRuntimeExports.jsx(Navigate, { to: "/", replace: true }) })
|
|
2719
|
-
] });
|
|
2720
|
-
}
|
|
2721
|
-
|
|
2722
|
-
const {Suspense,useEffect,useState} = await importShared('react');
|
|
2723
|
-
const { QueryClient, QueryClientProvider } = FR;
|
|
2724
|
-
function App(props) {
|
|
2725
|
-
const [queryClient] = useState(() => new QueryClient({
|
|
2726
|
-
defaultOptions: {
|
|
2727
|
-
queries: {
|
|
2728
|
-
staleTime: 60 * 1e3,
|
|
2729
|
-
// 1 minute
|
|
2730
|
-
refetchOnWindowFocus: false
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
}));
|
|
2734
|
-
useEffect(() => {
|
|
2735
|
-
let copaUser = {};
|
|
2736
|
-
try {
|
|
2737
|
-
const copaToken = undefined ? atob(undefined ) : "{}";
|
|
2738
|
-
copaUser = JSON.parse(copaToken);
|
|
2739
|
-
} catch (error) {
|
|
2740
|
-
console.warn("Failed to parse VITE_BLUECOPA_API_TOKEN:", error);
|
|
2741
|
-
}
|
|
2742
|
-
s1({
|
|
2743
|
-
apiBaseUrl: props.apiBaseUrl || undefined || "https://develop.bluecopa.com",
|
|
2744
|
-
workspaceId: props.workspaceId || undefined || "",
|
|
2745
|
-
accessToken: props.accessToken || copaUser?.accessToken || "",
|
|
2746
|
-
userId: props.userId || ""
|
|
2747
|
-
});
|
|
2748
|
-
}, []);
|
|
2749
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 text-sm text-muted-foreground", children: "Loading…" }), children: [
|
|
2750
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(RouteConfig, {}),
|
|
2751
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(PA, { initialIsOpen: false })
|
|
2752
|
-
] }) });
|
|
2753
|
-
}
|
|
2754
|
-
|
|
2755
|
-
var client = {};
|
|
2756
|
-
|
|
2757
|
-
var hasRequiredClient;
|
|
2758
|
-
|
|
2759
|
-
function requireClient () {
|
|
2760
|
-
if (hasRequiredClient) return client;
|
|
2761
|
-
hasRequiredClient = 1;
|
|
2762
|
-
var m = requireReactDom();
|
|
2763
|
-
{
|
|
2764
|
-
client.createRoot = m.createRoot;
|
|
2765
|
-
client.hydrateRoot = m.hydrateRoot;
|
|
2766
|
-
}
|
|
2767
|
-
return client;
|
|
2768
|
-
}
|
|
2769
|
-
|
|
2770
|
-
var clientExports = exports("c", requireClient());
|
|
2771
|
-
const ReactDOM = exports("R", /*@__PURE__*/getDefaultExportFromCjs(clientExports));
|
|
2772
|
-
|
|
2773
|
-
})
|
|
2774
|
-
};
|
|
2775
|
-
}));
|