react-router 0.0.0-experimental-1d8f3ee → 0.0.0-experimental-8265d95da
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/dist/development/{browser-Dy-ESm-r.d.mts → browser-CeOQ1V8U.d.mts} +1 -1
- package/dist/development/{chunk-PACOJA5V.js → chunk-D3LQIA7F.js} +69 -40
- package/dist/development/{chunk-RCYOOFMP.mjs → chunk-F6CHBNAM.mjs} +14 -54
- package/dist/development/{chunk-LCKD6EHG.mjs → chunk-H7YY6DT4.mjs} +64 -35
- package/dist/development/{chunk-XDNTV7B4.js → chunk-LZUZLU54.js} +1 -1
- package/dist/development/{components-Yh5Jx3In.d.mts → components-C4N5AKOq.d.mts} +1 -1
- package/dist/development/dom-export.d.mts +3 -8
- package/dist/development/dom-export.d.ts +0 -6
- package/dist/development/dom-export.js +10 -20
- package/dist/development/dom-export.mjs +10 -18
- package/dist/{production/index-react-server-client-CdDCHn2r.d.mts → development/index-react-server-client-B5PRzNjB.d.mts} +30 -4
- package/dist/development/{index-react-server-client-BM01za3r.d.ts → index-react-server-client-CZfY0YIG.d.ts} +29 -3
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +2 -2
- package/dist/development/index-react-server.d.ts +2 -2
- package/dist/development/index-react-server.js +2 -7
- package/dist/development/index-react-server.mjs +2 -7
- package/dist/development/index.d.mts +12 -16
- package/dist/development/index.d.ts +8 -12
- package/dist/development/index.js +126 -138
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +1 -1
- package/dist/development/lib/types/internal.d.ts +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{routeModules-C82B1sOz.d.ts → route-data-CDK1PbMf.d.ts} +166 -194
- package/dist/{production/route-data-DJcKSHWq.d.mts → development/route-data-CT-4wcAx.d.mts} +3 -31
- package/dist/production/{browser-Dy-ESm-r.d.mts → browser-CeOQ1V8U.d.mts} +1 -1
- package/dist/production/{chunk-F3UQRILU.js → chunk-4AOOXYBO.js} +69 -40
- package/dist/production/{chunk-FDXAKVCT.mjs → chunk-4C6ZXFI7.mjs} +14 -54
- package/dist/production/{chunk-XDNTV7B4.js → chunk-LZUZLU54.js} +1 -1
- package/dist/production/{chunk-VJ4SUXKA.mjs → chunk-QMNFIUXP.mjs} +64 -35
- package/dist/production/{components-Yh5Jx3In.d.mts → components-C4N5AKOq.d.mts} +1 -1
- package/dist/production/dom-export.d.mts +3 -8
- package/dist/production/dom-export.d.ts +0 -6
- package/dist/production/dom-export.js +10 -20
- package/dist/production/dom-export.mjs +10 -18
- package/dist/{development/index-react-server-client-CdDCHn2r.d.mts → production/index-react-server-client-B5PRzNjB.d.mts} +30 -4
- package/dist/production/{index-react-server-client-BM01za3r.d.ts → index-react-server-client-CZfY0YIG.d.ts} +29 -3
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +2 -2
- package/dist/production/index-react-server.d.ts +2 -2
- package/dist/production/index-react-server.js +2 -7
- package/dist/production/index-react-server.mjs +2 -7
- package/dist/production/index.d.mts +12 -16
- package/dist/production/index.d.ts +8 -12
- package/dist/production/index.js +126 -138
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +1 -1
- package/dist/production/lib/types/internal.d.ts +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{routeModules-C82B1sOz.d.ts → route-data-CDK1PbMf.d.ts} +166 -194
- package/dist/{development/route-data-DJcKSHWq.d.mts → production/route-data-CT-4wcAx.d.mts} +3 -31
- package/package.json +4 -3
- package/dist/development/chunk-DUZSUZPY.js +0 -42
- package/dist/production/chunk-DUZSUZPY.js +0 -42
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { p as ActionFunction, C as ClientActionFunction, q as ClientLoaderFunction, r as HeadersFunction, s as LinksFunction, t as LoaderFunction, M as MetaFunction, u as ShouldRevalidateFunction, L as Location, g as Params, h as Router } from './route-data-CT-4wcAx.mjs';
|
|
3
3
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
4
|
|
|
5
5
|
type ServerContext = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-8265d95da
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkLZUZLU54js = require('./chunk-LZUZLU54.js');
|
|
15
15
|
|
|
16
16
|
// lib/router/history.ts
|
|
17
17
|
var Action = /* @__PURE__ */ ((Action2) => {
|
|
@@ -366,7 +366,7 @@ function unstable_createContext(defaultValue) {
|
|
|
366
366
|
var _map;
|
|
367
367
|
var unstable_RouterContextProvider = class {
|
|
368
368
|
constructor(init) {
|
|
369
|
-
|
|
369
|
+
_chunkLZUZLU54js.__privateAdd.call(void 0, this, _map, /* @__PURE__ */ new Map());
|
|
370
370
|
if (init) {
|
|
371
371
|
for (let [context, value] of init) {
|
|
372
372
|
this.set(context, value);
|
|
@@ -374,8 +374,8 @@ var unstable_RouterContextProvider = class {
|
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
get(context) {
|
|
377
|
-
if (
|
|
378
|
-
return
|
|
377
|
+
if (_chunkLZUZLU54js.__privateGet.call(void 0, this, _map).has(context)) {
|
|
378
|
+
return _chunkLZUZLU54js.__privateGet.call(void 0, this, _map).get(context);
|
|
379
379
|
}
|
|
380
380
|
if (context.defaultValue !== void 0) {
|
|
381
381
|
return context.defaultValue;
|
|
@@ -383,7 +383,7 @@ var unstable_RouterContextProvider = class {
|
|
|
383
383
|
throw new Error("No value found for context");
|
|
384
384
|
}
|
|
385
385
|
set(context, value) {
|
|
386
|
-
|
|
386
|
+
_chunkLZUZLU54js.__privateGet.call(void 0, this, _map).set(context, value);
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
_map = new WeakMap();
|
|
@@ -1896,7 +1896,7 @@ function createRouter(init) {
|
|
|
1896
1896
|
if (isFogOfWar) {
|
|
1897
1897
|
let discoverResult = await discoverRoutes(
|
|
1898
1898
|
requestMatches,
|
|
1899
|
-
|
|
1899
|
+
new URL(fetchRequest.url).pathname,
|
|
1900
1900
|
fetchRequest.signal,
|
|
1901
1901
|
key
|
|
1902
1902
|
);
|
|
@@ -2120,7 +2120,7 @@ function createRouter(init) {
|
|
|
2120
2120
|
if (isFogOfWar) {
|
|
2121
2121
|
let discoverResult = await discoverRoutes(
|
|
2122
2122
|
matches,
|
|
2123
|
-
|
|
2123
|
+
new URL(fetchRequest.url).pathname,
|
|
2124
2124
|
fetchRequest.signal,
|
|
2125
2125
|
key
|
|
2126
2126
|
);
|
|
@@ -7324,6 +7324,34 @@ function createDeferred2() {
|
|
|
7324
7324
|
// lib/dom/ssr/components.tsx
|
|
7325
7325
|
|
|
7326
7326
|
|
|
7327
|
+
// lib/dom/ssr/routeModules.ts
|
|
7328
|
+
async function loadRouteModule(route, routeModulesCache) {
|
|
7329
|
+
if (route.id in routeModulesCache) {
|
|
7330
|
+
return routeModulesCache[route.id];
|
|
7331
|
+
}
|
|
7332
|
+
try {
|
|
7333
|
+
let routeModule = await Promise.resolve().then(() => _interopRequireWildcard(require(
|
|
7334
|
+
/* @vite-ignore */
|
|
7335
|
+
/* webpackIgnore: true */
|
|
7336
|
+
route.module
|
|
7337
|
+
)));
|
|
7338
|
+
routeModulesCache[route.id] = routeModule;
|
|
7339
|
+
return routeModule;
|
|
7340
|
+
} catch (error) {
|
|
7341
|
+
console.error(
|
|
7342
|
+
`Error loading route module \`${route.module}\`, reloading page...`
|
|
7343
|
+
);
|
|
7344
|
+
console.error(error);
|
|
7345
|
+
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
7346
|
+
void 0) {
|
|
7347
|
+
throw error;
|
|
7348
|
+
}
|
|
7349
|
+
window.location.reload();
|
|
7350
|
+
return new Promise(() => {
|
|
7351
|
+
});
|
|
7352
|
+
}
|
|
7353
|
+
}
|
|
7354
|
+
|
|
7327
7355
|
// lib/dom/ssr/links.ts
|
|
7328
7356
|
function getKeyedLinksForMatches(matches, routeModules, manifest) {
|
|
7329
7357
|
let descriptors = matches.map((match) => {
|
|
@@ -7405,7 +7433,7 @@ function isHtmlLinkDescriptor(object) {
|
|
|
7405
7433
|
}
|
|
7406
7434
|
return typeof object.rel === "string" && typeof object.href === "string";
|
|
7407
7435
|
}
|
|
7408
|
-
async function getKeyedPrefetchLinks(matches, manifest, routeModules
|
|
7436
|
+
async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
7409
7437
|
let links = await Promise.all(
|
|
7410
7438
|
matches.map(async (match) => {
|
|
7411
7439
|
let route = manifest.routes[match.route.id];
|
|
@@ -7628,14 +7656,13 @@ function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId
|
|
|
7628
7656
|
return dataRoute;
|
|
7629
7657
|
});
|
|
7630
7658
|
}
|
|
7631
|
-
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, ssr, isSpaMode
|
|
7659
|
+
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, ssr, isSpaMode) {
|
|
7632
7660
|
return createClientRoutes(
|
|
7633
7661
|
manifest,
|
|
7634
7662
|
routeModulesCache,
|
|
7635
7663
|
initialState,
|
|
7636
7664
|
ssr,
|
|
7637
7665
|
isSpaMode,
|
|
7638
|
-
loadRouteModule,
|
|
7639
7666
|
"",
|
|
7640
7667
|
groupRoutesByParentId(manifest),
|
|
7641
7668
|
needsRevalidation
|
|
@@ -7655,7 +7682,7 @@ function noActionDefinedError(type, routeId) {
|
|
|
7655
7682
|
console.error(msg);
|
|
7656
7683
|
throw new ErrorResponseImpl(405, "Method Not Allowed", new Error(msg), true);
|
|
7657
7684
|
}
|
|
7658
|
-
function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSpaMode,
|
|
7685
|
+
function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
7659
7686
|
return (routesByParentId[parentId] || []).map((route) => {
|
|
7660
7687
|
let routeModule = routeModulesCache[route.id];
|
|
7661
7688
|
function fetchServerHandler(singleFetch) {
|
|
@@ -7810,8 +7837,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7810
7837
|
}
|
|
7811
7838
|
let routeModulePromise = loadRouteModuleWithBlockingLinks(
|
|
7812
7839
|
route,
|
|
7813
|
-
routeModulesCache
|
|
7814
|
-
loadRouteModule
|
|
7840
|
+
routeModulesCache
|
|
7815
7841
|
);
|
|
7816
7842
|
prefetchRouteModuleChunks(route);
|
|
7817
7843
|
return await routeModulePromise;
|
|
@@ -7886,7 +7912,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7886
7912
|
initialState,
|
|
7887
7913
|
ssr,
|
|
7888
7914
|
isSpaMode,
|
|
7889
|
-
loadRouteModule,
|
|
7890
7915
|
route.id,
|
|
7891
7916
|
routesByParentId,
|
|
7892
7917
|
needsRevalidation
|
|
@@ -7932,7 +7957,7 @@ function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalid
|
|
|
7932
7957
|
return routeShouldRevalidate ? routeShouldRevalidate(arg) : arg.defaultShouldRevalidate;
|
|
7933
7958
|
};
|
|
7934
7959
|
}
|
|
7935
|
-
async function loadRouteModuleWithBlockingLinks(route, routeModules
|
|
7960
|
+
async function loadRouteModuleWithBlockingLinks(route, routeModules) {
|
|
7936
7961
|
let routeModulePromise = loadRouteModule(route, routeModules);
|
|
7937
7962
|
let prefetchRouteCssPromise = prefetchRouteCss(route);
|
|
7938
7963
|
let routeModule = await routeModulePromise;
|
|
@@ -7996,7 +8021,7 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
7996
8021
|
sri: sri ? true : void 0
|
|
7997
8022
|
};
|
|
7998
8023
|
}
|
|
7999
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDiscovery, isSpaMode, basename
|
|
8024
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDiscovery, isSpaMode, basename) {
|
|
8000
8025
|
if (!isFogOfWarEnabled(routeDiscovery, ssr)) {
|
|
8001
8026
|
return void 0;
|
|
8002
8027
|
}
|
|
@@ -8011,7 +8036,6 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
8011
8036
|
routeModules,
|
|
8012
8037
|
ssr,
|
|
8013
8038
|
isSpaMode,
|
|
8014
|
-
loadRouteModule,
|
|
8015
8039
|
basename,
|
|
8016
8040
|
routeDiscovery.manifestPath,
|
|
8017
8041
|
patch,
|
|
@@ -8019,7 +8043,7 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
8019
8043
|
);
|
|
8020
8044
|
};
|
|
8021
8045
|
}
|
|
8022
|
-
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode
|
|
8046
|
+
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode) {
|
|
8023
8047
|
React7.useEffect(() => {
|
|
8024
8048
|
if (!isFogOfWarEnabled(routeDiscovery, ssr) || // @ts-expect-error - TS doesn't know about this yet
|
|
8025
8049
|
_optionalChain([window, 'access', _97 => _97.navigator, 'optionalAccess', _98 => _98.connection, 'optionalAccess', _99 => _99.saveData]) === true) {
|
|
@@ -8055,7 +8079,6 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
|
|
|
8055
8079
|
routeModules,
|
|
8056
8080
|
ssr,
|
|
8057
8081
|
isSpaMode,
|
|
8058
|
-
loadRouteModule,
|
|
8059
8082
|
router.basename,
|
|
8060
8083
|
routeDiscovery.manifestPath,
|
|
8061
8084
|
router.patchRoutes
|
|
@@ -8084,7 +8107,7 @@ function getManifestPath(_manifestPath, basename) {
|
|
|
8084
8107
|
return `${basename}${manifestPath}`.replace(/\/+/g, "/");
|
|
8085
8108
|
}
|
|
8086
8109
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
8087
|
-
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode,
|
|
8110
|
+
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
|
|
8088
8111
|
let url = new URL(
|
|
8089
8112
|
getManifestPath(manifestPath, basename),
|
|
8090
8113
|
window.location.origin
|
|
@@ -8145,7 +8168,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
8145
8168
|
parentIds.forEach(
|
|
8146
8169
|
(parentId) => patchRoutes(
|
|
8147
8170
|
parentId || null,
|
|
8148
|
-
createClientRoutes(patches, routeModules, null, ssr, isSpaMode,
|
|
8171
|
+
createClientRoutes(patches, routeModules, null, ssr, isSpaMode, parentId)
|
|
8149
8172
|
)
|
|
8150
8173
|
);
|
|
8151
8174
|
}
|
|
@@ -8294,20 +8317,17 @@ function PrefetchPageLinks({
|
|
|
8294
8317
|
return /* @__PURE__ */ React8.createElement(PrefetchPageLinksImpl, { page, matches, ...dataLinkProps });
|
|
8295
8318
|
}
|
|
8296
8319
|
function useKeyedPrefetchLinks(matches) {
|
|
8297
|
-
let { manifest, routeModules
|
|
8320
|
+
let { manifest, routeModules } = useFrameworkContext();
|
|
8298
8321
|
let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React8.useState([]);
|
|
8299
8322
|
React8.useEffect(() => {
|
|
8300
8323
|
let interrupted = false;
|
|
8301
|
-
void getKeyedPrefetchLinks(
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
).then((links) => {
|
|
8307
|
-
if (!interrupted) {
|
|
8308
|
-
setKeyedPrefetchLinks(links);
|
|
8324
|
+
void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
|
|
8325
|
+
(links) => {
|
|
8326
|
+
if (!interrupted) {
|
|
8327
|
+
setKeyedPrefetchLinks(links);
|
|
8328
|
+
}
|
|
8309
8329
|
}
|
|
8310
|
-
|
|
8330
|
+
);
|
|
8311
8331
|
return () => {
|
|
8312
8332
|
interrupted = true;
|
|
8313
8333
|
};
|
|
@@ -8772,7 +8792,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
8772
8792
|
try {
|
|
8773
8793
|
if (isBrowser) {
|
|
8774
8794
|
window.__reactRouterVersion = // @ts-expect-error
|
|
8775
|
-
"0.0.0-experimental-
|
|
8795
|
+
"0.0.0-experimental-8265d95da";
|
|
8776
8796
|
}
|
|
8777
8797
|
} catch (e) {
|
|
8778
8798
|
}
|
|
@@ -9504,14 +9524,23 @@ function useScrollRestoration({
|
|
|
9504
9524
|
window.scrollTo(0, restoreScrollPosition);
|
|
9505
9525
|
return;
|
|
9506
9526
|
}
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
el
|
|
9513
|
-
|
|
9527
|
+
try {
|
|
9528
|
+
if (location.hash) {
|
|
9529
|
+
let el = document.getElementById(
|
|
9530
|
+
decodeURIComponent(location.hash.slice(1))
|
|
9531
|
+
);
|
|
9532
|
+
if (el) {
|
|
9533
|
+
el.scrollIntoView();
|
|
9534
|
+
return;
|
|
9535
|
+
}
|
|
9514
9536
|
}
|
|
9537
|
+
} catch (e2) {
|
|
9538
|
+
warning(
|
|
9539
|
+
false,
|
|
9540
|
+
`"${location.hash.slice(
|
|
9541
|
+
1
|
|
9542
|
+
)}" is not a decodable element ID. The view will not scroll to it.`
|
|
9543
|
+
);
|
|
9515
9544
|
}
|
|
9516
9545
|
if (preventScrollReset === true) {
|
|
9517
9546
|
return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-8265d95da
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -57,40 +57,10 @@ import {
|
|
|
57
57
|
withComponentProps,
|
|
58
58
|
withErrorBoundaryProps,
|
|
59
59
|
withHydrateFallbackProps
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-H7YY6DT4.mjs";
|
|
61
61
|
|
|
62
62
|
// lib/dom/ssr/server.tsx
|
|
63
63
|
import * as React from "react";
|
|
64
|
-
|
|
65
|
-
// lib/dom/ssr/routeModules.ts
|
|
66
|
-
var defaultLoadRouteModule = async (route, routeModulesCache) => {
|
|
67
|
-
if (route.id in routeModulesCache) {
|
|
68
|
-
return routeModulesCache[route.id];
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
let routeModule = await import(
|
|
72
|
-
/* @vite-ignore */
|
|
73
|
-
/* webpackIgnore: true */
|
|
74
|
-
route.module
|
|
75
|
-
);
|
|
76
|
-
routeModulesCache[route.id] = routeModule;
|
|
77
|
-
return routeModule;
|
|
78
|
-
} catch (error) {
|
|
79
|
-
console.error(
|
|
80
|
-
`Error loading route module \`${route.module}\`, reloading page...`
|
|
81
|
-
);
|
|
82
|
-
console.error(error);
|
|
83
|
-
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
84
|
-
import.meta.hot) {
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
87
|
-
window.location.reload();
|
|
88
|
-
return new Promise(() => {
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// lib/dom/ssr/server.tsx
|
|
94
64
|
function ServerRouter({
|
|
95
65
|
context,
|
|
96
66
|
url,
|
|
@@ -136,8 +106,7 @@ function ServerRouter({
|
|
|
136
106
|
isSpaMode: context.isSpaMode,
|
|
137
107
|
routeDiscovery: context.routeDiscovery,
|
|
138
108
|
serializeError: context.serializeError,
|
|
139
|
-
renderMeta: context.renderMeta
|
|
140
|
-
loadRouteModule: defaultLoadRouteModule
|
|
109
|
+
renderMeta: context.renderMeta
|
|
141
110
|
}
|
|
142
111
|
},
|
|
143
112
|
/* @__PURE__ */ React.createElement(RemixErrorBoundary, { location: router.state.location }, /* @__PURE__ */ React.createElement(
|
|
@@ -162,13 +131,12 @@ function ServerRouter({
|
|
|
162
131
|
|
|
163
132
|
// lib/dom/ssr/routes-test-stub.tsx
|
|
164
133
|
import * as React2 from "react";
|
|
165
|
-
function createRoutesStub(routes,
|
|
134
|
+
function createRoutesStub(routes, _context) {
|
|
166
135
|
return function RoutesTestStub({
|
|
167
136
|
initialEntries,
|
|
168
137
|
initialIndex,
|
|
169
138
|
hydrationData,
|
|
170
|
-
future
|
|
171
|
-
loadRouteModule = defaultLoadRouteModule
|
|
139
|
+
future
|
|
172
140
|
}) {
|
|
173
141
|
let routerRef = React2.useRef();
|
|
174
142
|
let remixContextRef = React2.useRef();
|
|
@@ -187,18 +155,17 @@ function createRoutesStub(routes, unstable_getContext) {
|
|
|
187
155
|
routeModules: {},
|
|
188
156
|
ssr: false,
|
|
189
157
|
isSpaMode: false,
|
|
190
|
-
loadRouteModule,
|
|
191
158
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }
|
|
192
159
|
};
|
|
193
160
|
let patched = processRoutes(
|
|
194
161
|
// @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
|
|
195
162
|
// types compared to `AgnosticRouteObject`
|
|
196
163
|
convertRoutesToDataRoutes(routes, (r) => r),
|
|
164
|
+
_context !== void 0 ? _context : future?.unstable_middleware ? new unstable_RouterContextProvider() : {},
|
|
197
165
|
remixContextRef.current.manifest,
|
|
198
166
|
remixContextRef.current.routeModules
|
|
199
167
|
);
|
|
200
168
|
routerRef.current = createMemoryRouter(patched, {
|
|
201
|
-
unstable_getContext,
|
|
202
169
|
initialEntries,
|
|
203
170
|
initialIndex,
|
|
204
171
|
hydrationData
|
|
@@ -207,7 +174,7 @@ function createRoutesStub(routes, unstable_getContext) {
|
|
|
207
174
|
return /* @__PURE__ */ React2.createElement(FrameworkContext.Provider, { value: remixContextRef.current }, /* @__PURE__ */ React2.createElement(RouterProvider, { router: routerRef.current }));
|
|
208
175
|
};
|
|
209
176
|
}
|
|
210
|
-
function processRoutes(routes, manifest, routeModules, parentId) {
|
|
177
|
+
function processRoutes(routes, context, manifest, routeModules, parentId) {
|
|
211
178
|
return routes.map((route) => {
|
|
212
179
|
if (!route.id) {
|
|
213
180
|
throw new Error(
|
|
@@ -221,8 +188,8 @@ function processRoutes(routes, manifest, routeModules, parentId) {
|
|
|
221
188
|
Component: route.Component ? withComponentProps(route.Component) : void 0,
|
|
222
189
|
HydrateFallback: route.HydrateFallback ? withHydrateFallbackProps(route.HydrateFallback) : void 0,
|
|
223
190
|
ErrorBoundary: route.ErrorBoundary ? withErrorBoundaryProps(route.ErrorBoundary) : void 0,
|
|
224
|
-
action: route.action,
|
|
225
|
-
loader: route.loader,
|
|
191
|
+
action: route.action ? (args) => route.action({ ...args, context }) : void 0,
|
|
192
|
+
loader: route.loader ? (args) => route.loader({ ...args, context }) : void 0,
|
|
226
193
|
handle: route.handle,
|
|
227
194
|
shouldRevalidate: route.shouldRevalidate
|
|
228
195
|
};
|
|
@@ -259,6 +226,7 @@ function processRoutes(routes, manifest, routeModules, parentId) {
|
|
|
259
226
|
if (route.children) {
|
|
260
227
|
newRoute.children = processRoutes(
|
|
261
228
|
route.children,
|
|
229
|
+
context,
|
|
262
230
|
manifest,
|
|
263
231
|
routeModules,
|
|
264
232
|
newRoute.id
|
|
@@ -1393,8 +1361,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
1393
1361
|
ssr: build.ssr,
|
|
1394
1362
|
routeDiscovery: build.routeDiscovery,
|
|
1395
1363
|
isSpaMode: isSpaMode2,
|
|
1396
|
-
serializeError: (err) => serializeError(err, serverMode)
|
|
1397
|
-
loadRouteModule: defaultLoadRouteModule
|
|
1364
|
+
serializeError: (err) => serializeError(err, serverMode)
|
|
1398
1365
|
};
|
|
1399
1366
|
let handleDocumentRequestFunction = build.entry.module.default;
|
|
1400
1367
|
try {
|
|
@@ -2211,10 +2178,7 @@ function RSCHydratedRouter({
|
|
|
2211
2178
|
}
|
|
2212
2179
|
},
|
|
2213
2180
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
2214
|
-
routeModules: {}
|
|
2215
|
-
loadRouteModule: () => {
|
|
2216
|
-
throw new Error("Not required in RSC Mode");
|
|
2217
|
-
}
|
|
2181
|
+
routeModules: {}
|
|
2218
2182
|
};
|
|
2219
2183
|
return /* @__PURE__ */ React4.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React4.createElement(RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React4.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React4.createElement(RouterProvider, { router, flushSync: ReactDOM.flushSync }))));
|
|
2220
2184
|
}
|
|
@@ -2269,7 +2233,7 @@ function createRouteFromServerManifest(match, payload) {
|
|
|
2269
2233
|
...args,
|
|
2270
2234
|
serverAction: async () => {
|
|
2271
2235
|
preventInvalidServerHandlerCall(
|
|
2272
|
-
"
|
|
2236
|
+
"action",
|
|
2273
2237
|
match.id,
|
|
2274
2238
|
match.hasLoader
|
|
2275
2239
|
);
|
|
@@ -2603,10 +2567,7 @@ function RSCStaticRouter({
|
|
|
2603
2567
|
}
|
|
2604
2568
|
},
|
|
2605
2569
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
2606
|
-
routeModules: {}
|
|
2607
|
-
loadRouteModule: () => {
|
|
2608
|
-
throw new Error("Not required in RSC Mode");
|
|
2609
|
-
}
|
|
2570
|
+
routeModules: {}
|
|
2610
2571
|
};
|
|
2611
2572
|
return /* @__PURE__ */ React5.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React5.createElement(RSCRouterGlobalErrorBoundary, { location: payload.location }, /* @__PURE__ */ React5.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React5.createElement(
|
|
2612
2573
|
StaticRouterProvider,
|
|
@@ -2698,7 +2659,6 @@ function deserializeErrors(errors) {
|
|
|
2698
2659
|
}
|
|
2699
2660
|
|
|
2700
2661
|
export {
|
|
2701
|
-
defaultLoadRouteModule,
|
|
2702
2662
|
ServerRouter,
|
|
2703
2663
|
createRoutesStub,
|
|
2704
2664
|
createCookie,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-8265d95da
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1898,7 +1898,7 @@ function createRouter(init) {
|
|
|
1898
1898
|
if (isFogOfWar) {
|
|
1899
1899
|
let discoverResult = await discoverRoutes(
|
|
1900
1900
|
requestMatches,
|
|
1901
|
-
|
|
1901
|
+
new URL(fetchRequest.url).pathname,
|
|
1902
1902
|
fetchRequest.signal,
|
|
1903
1903
|
key
|
|
1904
1904
|
);
|
|
@@ -2122,7 +2122,7 @@ function createRouter(init) {
|
|
|
2122
2122
|
if (isFogOfWar) {
|
|
2123
2123
|
let discoverResult = await discoverRoutes(
|
|
2124
2124
|
matches,
|
|
2125
|
-
|
|
2125
|
+
new URL(fetchRequest.url).pathname,
|
|
2126
2126
|
fetchRequest.signal,
|
|
2127
2127
|
key
|
|
2128
2128
|
);
|
|
@@ -7326,6 +7326,34 @@ import * as React9 from "react";
|
|
|
7326
7326
|
// lib/dom/ssr/components.tsx
|
|
7327
7327
|
import * as React8 from "react";
|
|
7328
7328
|
|
|
7329
|
+
// lib/dom/ssr/routeModules.ts
|
|
7330
|
+
async function loadRouteModule(route, routeModulesCache) {
|
|
7331
|
+
if (route.id in routeModulesCache) {
|
|
7332
|
+
return routeModulesCache[route.id];
|
|
7333
|
+
}
|
|
7334
|
+
try {
|
|
7335
|
+
let routeModule = await import(
|
|
7336
|
+
/* @vite-ignore */
|
|
7337
|
+
/* webpackIgnore: true */
|
|
7338
|
+
route.module
|
|
7339
|
+
);
|
|
7340
|
+
routeModulesCache[route.id] = routeModule;
|
|
7341
|
+
return routeModule;
|
|
7342
|
+
} catch (error) {
|
|
7343
|
+
console.error(
|
|
7344
|
+
`Error loading route module \`${route.module}\`, reloading page...`
|
|
7345
|
+
);
|
|
7346
|
+
console.error(error);
|
|
7347
|
+
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
7348
|
+
import.meta.hot) {
|
|
7349
|
+
throw error;
|
|
7350
|
+
}
|
|
7351
|
+
window.location.reload();
|
|
7352
|
+
return new Promise(() => {
|
|
7353
|
+
});
|
|
7354
|
+
}
|
|
7355
|
+
}
|
|
7356
|
+
|
|
7329
7357
|
// lib/dom/ssr/links.ts
|
|
7330
7358
|
function getKeyedLinksForMatches(matches, routeModules, manifest) {
|
|
7331
7359
|
let descriptors = matches.map((match) => {
|
|
@@ -7407,7 +7435,7 @@ function isHtmlLinkDescriptor(object) {
|
|
|
7407
7435
|
}
|
|
7408
7436
|
return typeof object.rel === "string" && typeof object.href === "string";
|
|
7409
7437
|
}
|
|
7410
|
-
async function getKeyedPrefetchLinks(matches, manifest, routeModules
|
|
7438
|
+
async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
7411
7439
|
let links = await Promise.all(
|
|
7412
7440
|
matches.map(async (match) => {
|
|
7413
7441
|
let route = manifest.routes[match.route.id];
|
|
@@ -7630,14 +7658,13 @@ function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId
|
|
|
7630
7658
|
return dataRoute;
|
|
7631
7659
|
});
|
|
7632
7660
|
}
|
|
7633
|
-
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, ssr, isSpaMode
|
|
7661
|
+
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, ssr, isSpaMode) {
|
|
7634
7662
|
return createClientRoutes(
|
|
7635
7663
|
manifest,
|
|
7636
7664
|
routeModulesCache,
|
|
7637
7665
|
initialState,
|
|
7638
7666
|
ssr,
|
|
7639
7667
|
isSpaMode,
|
|
7640
|
-
loadRouteModule,
|
|
7641
7668
|
"",
|
|
7642
7669
|
groupRoutesByParentId(manifest),
|
|
7643
7670
|
needsRevalidation
|
|
@@ -7657,7 +7684,7 @@ function noActionDefinedError(type, routeId) {
|
|
|
7657
7684
|
console.error(msg);
|
|
7658
7685
|
throw new ErrorResponseImpl(405, "Method Not Allowed", new Error(msg), true);
|
|
7659
7686
|
}
|
|
7660
|
-
function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSpaMode,
|
|
7687
|
+
function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
7661
7688
|
return (routesByParentId[parentId] || []).map((route) => {
|
|
7662
7689
|
let routeModule = routeModulesCache[route.id];
|
|
7663
7690
|
function fetchServerHandler(singleFetch) {
|
|
@@ -7812,8 +7839,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7812
7839
|
}
|
|
7813
7840
|
let routeModulePromise = loadRouteModuleWithBlockingLinks(
|
|
7814
7841
|
route,
|
|
7815
|
-
routeModulesCache
|
|
7816
|
-
loadRouteModule
|
|
7842
|
+
routeModulesCache
|
|
7817
7843
|
);
|
|
7818
7844
|
prefetchRouteModuleChunks(route);
|
|
7819
7845
|
return await routeModulePromise;
|
|
@@ -7888,7 +7914,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7888
7914
|
initialState,
|
|
7889
7915
|
ssr,
|
|
7890
7916
|
isSpaMode,
|
|
7891
|
-
loadRouteModule,
|
|
7892
7917
|
route.id,
|
|
7893
7918
|
routesByParentId,
|
|
7894
7919
|
needsRevalidation
|
|
@@ -7934,7 +7959,7 @@ function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalid
|
|
|
7934
7959
|
return routeShouldRevalidate ? routeShouldRevalidate(arg) : arg.defaultShouldRevalidate;
|
|
7935
7960
|
};
|
|
7936
7961
|
}
|
|
7937
|
-
async function loadRouteModuleWithBlockingLinks(route, routeModules
|
|
7962
|
+
async function loadRouteModuleWithBlockingLinks(route, routeModules) {
|
|
7938
7963
|
let routeModulePromise = loadRouteModule(route, routeModules);
|
|
7939
7964
|
let prefetchRouteCssPromise = prefetchRouteCss(route);
|
|
7940
7965
|
let routeModule = await routeModulePromise;
|
|
@@ -7998,7 +8023,7 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
7998
8023
|
sri: sri ? true : void 0
|
|
7999
8024
|
};
|
|
8000
8025
|
}
|
|
8001
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDiscovery, isSpaMode, basename
|
|
8026
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDiscovery, isSpaMode, basename) {
|
|
8002
8027
|
if (!isFogOfWarEnabled(routeDiscovery, ssr)) {
|
|
8003
8028
|
return void 0;
|
|
8004
8029
|
}
|
|
@@ -8013,7 +8038,6 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
8013
8038
|
routeModules,
|
|
8014
8039
|
ssr,
|
|
8015
8040
|
isSpaMode,
|
|
8016
|
-
loadRouteModule,
|
|
8017
8041
|
basename,
|
|
8018
8042
|
routeDiscovery.manifestPath,
|
|
8019
8043
|
patch,
|
|
@@ -8021,7 +8045,7 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
8021
8045
|
);
|
|
8022
8046
|
};
|
|
8023
8047
|
}
|
|
8024
|
-
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode
|
|
8048
|
+
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode) {
|
|
8025
8049
|
React7.useEffect(() => {
|
|
8026
8050
|
if (!isFogOfWarEnabled(routeDiscovery, ssr) || // @ts-expect-error - TS doesn't know about this yet
|
|
8027
8051
|
window.navigator?.connection?.saveData === true) {
|
|
@@ -8057,7 +8081,6 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
|
|
|
8057
8081
|
routeModules,
|
|
8058
8082
|
ssr,
|
|
8059
8083
|
isSpaMode,
|
|
8060
|
-
loadRouteModule,
|
|
8061
8084
|
router.basename,
|
|
8062
8085
|
routeDiscovery.manifestPath,
|
|
8063
8086
|
router.patchRoutes
|
|
@@ -8086,7 +8109,7 @@ function getManifestPath(_manifestPath, basename) {
|
|
|
8086
8109
|
return `${basename}${manifestPath}`.replace(/\/+/g, "/");
|
|
8087
8110
|
}
|
|
8088
8111
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
8089
|
-
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode,
|
|
8112
|
+
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
|
|
8090
8113
|
let url = new URL(
|
|
8091
8114
|
getManifestPath(manifestPath, basename),
|
|
8092
8115
|
window.location.origin
|
|
@@ -8147,7 +8170,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
8147
8170
|
parentIds.forEach(
|
|
8148
8171
|
(parentId) => patchRoutes(
|
|
8149
8172
|
parentId || null,
|
|
8150
|
-
createClientRoutes(patches, routeModules, null, ssr, isSpaMode,
|
|
8173
|
+
createClientRoutes(patches, routeModules, null, ssr, isSpaMode, parentId)
|
|
8151
8174
|
)
|
|
8152
8175
|
);
|
|
8153
8176
|
}
|
|
@@ -8296,20 +8319,17 @@ function PrefetchPageLinks({
|
|
|
8296
8319
|
return /* @__PURE__ */ React8.createElement(PrefetchPageLinksImpl, { page, matches, ...dataLinkProps });
|
|
8297
8320
|
}
|
|
8298
8321
|
function useKeyedPrefetchLinks(matches) {
|
|
8299
|
-
let { manifest, routeModules
|
|
8322
|
+
let { manifest, routeModules } = useFrameworkContext();
|
|
8300
8323
|
let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React8.useState([]);
|
|
8301
8324
|
React8.useEffect(() => {
|
|
8302
8325
|
let interrupted = false;
|
|
8303
|
-
void getKeyedPrefetchLinks(
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
).then((links) => {
|
|
8309
|
-
if (!interrupted) {
|
|
8310
|
-
setKeyedPrefetchLinks(links);
|
|
8326
|
+
void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
|
|
8327
|
+
(links) => {
|
|
8328
|
+
if (!interrupted) {
|
|
8329
|
+
setKeyedPrefetchLinks(links);
|
|
8330
|
+
}
|
|
8311
8331
|
}
|
|
8312
|
-
|
|
8332
|
+
);
|
|
8313
8333
|
return () => {
|
|
8314
8334
|
interrupted = true;
|
|
8315
8335
|
};
|
|
@@ -8774,7 +8794,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
8774
8794
|
try {
|
|
8775
8795
|
if (isBrowser) {
|
|
8776
8796
|
window.__reactRouterVersion = // @ts-expect-error
|
|
8777
|
-
"0.0.0-experimental-
|
|
8797
|
+
"0.0.0-experimental-8265d95da";
|
|
8778
8798
|
}
|
|
8779
8799
|
} catch (e) {
|
|
8780
8800
|
}
|
|
@@ -9506,14 +9526,23 @@ function useScrollRestoration({
|
|
|
9506
9526
|
window.scrollTo(0, restoreScrollPosition);
|
|
9507
9527
|
return;
|
|
9508
9528
|
}
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
el
|
|
9515
|
-
|
|
9529
|
+
try {
|
|
9530
|
+
if (location.hash) {
|
|
9531
|
+
let el = document.getElementById(
|
|
9532
|
+
decodeURIComponent(location.hash.slice(1))
|
|
9533
|
+
);
|
|
9534
|
+
if (el) {
|
|
9535
|
+
el.scrollIntoView();
|
|
9536
|
+
return;
|
|
9537
|
+
}
|
|
9516
9538
|
}
|
|
9539
|
+
} catch {
|
|
9540
|
+
warning(
|
|
9541
|
+
false,
|
|
9542
|
+
`"${location.hash.slice(
|
|
9543
|
+
1
|
|
9544
|
+
)}" is not a decodable element ID. The view will not scroll to it.`
|
|
9545
|
+
);
|
|
9517
9546
|
}
|
|
9518
9547
|
if (preventScrollReset === true) {
|
|
9519
9548
|
return;
|