react-router 0.0.0-experimental-89dc2043e → 0.0.0-experimental-6844c5934
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/CHANGELOG.md +21 -0
- package/dist/development/{chunk-TRZSGY2F.mjs → chunk-U3YJJR4X.mjs} +73 -54
- package/dist/development/dom-export.d.mts +5 -3
- package/dist/development/dom-export.d.ts +5 -3
- package/dist/development/dom-export.js +65 -45
- package/dist/development/dom-export.mjs +18 -9
- package/dist/development/{fog-of-war-DU_DzpDb.d.ts → fog-of-war-D8HgFD2R.d.ts} +7 -73
- package/dist/{production/fog-of-war-DU_DzpDb.d.ts → development/fog-of-war-DhPlOTYA.d.mts} +7 -73
- package/dist/development/index.d.mts +9 -7
- package/dist/development/index.d.ts +9 -7
- package/dist/development/index.js +72 -54
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/route-module.d.mts +5 -5
- package/dist/development/lib/types/route-module.d.ts +5 -5
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/development/{route-data-DuV3tXo2.d.ts → route-data-Dwy1K32H.d.mts} +78 -7
- package/dist/{production/route-data-DuV3tXo2.d.mts → development/route-data-Dwy1K32H.d.ts} +78 -7
- package/dist/production/{chunk-VRQVD6TT.mjs → chunk-PUDTWONU.mjs} +73 -54
- package/dist/production/dom-export.d.mts +5 -3
- package/dist/production/dom-export.d.ts +5 -3
- package/dist/production/dom-export.js +65 -45
- package/dist/production/dom-export.mjs +18 -9
- package/dist/production/{fog-of-war-BkI3XFdx.d.mts → fog-of-war-D8HgFD2R.d.ts} +7 -73
- package/dist/{development/fog-of-war-BkI3XFdx.d.mts → production/fog-of-war-DhPlOTYA.d.mts} +7 -73
- package/dist/production/index.d.mts +9 -7
- package/dist/production/index.d.ts +9 -7
- package/dist/production/index.js +72 -54
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/route-module.d.mts +5 -5
- package/dist/production/lib/types/route-module.d.ts +5 -5
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/dist/production/{route-data-DuV3tXo2.d.ts → route-data-Dwy1K32H.d.mts} +78 -7
- package/dist/{development/route-data-DuV3tXo2.d.mts → production/route-data-Dwy1K32H.d.ts} +78 -7
- package/package.json +20 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## 7.1.1
|
|
4
|
+
|
|
5
|
+
## 7.1.0
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- Throw unwrapped single fetch redirect to align with pre-single fetch behavior ([#12506](https://github.com/remix-run/react-router/pull/12506))
|
|
10
|
+
- Ignore redirects when inferring loader data types ([#12527](https://github.com/remix-run/react-router/pull/12527))
|
|
11
|
+
- Remove `<Link prefetch>` warning which suffers from false positives in a lazy route discovery world ([#12485](https://github.com/remix-run/react-router/pull/12485))
|
|
12
|
+
|
|
13
|
+
## 7.0.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- temporarily only use one build in export map so packages can have a peer dependency on react router ([#12437](https://github.com/remix-run/react-router/pull/12437))
|
|
18
|
+
- Generate wide `matches` and `params` types for current route and child routes ([#12397](https://github.com/remix-run/react-router/pull/12397))
|
|
19
|
+
|
|
20
|
+
At runtime, `matches` includes child route matches and `params` include child route path parameters.
|
|
21
|
+
But previously, we only generated types for parent routes in `matches`; for `params`, we only considered the parent routes and the current route.
|
|
22
|
+
To align our generated types more closely to the runtime behavior, we now generate more permissive, wider types when accessing child route information.
|
|
23
|
+
|
|
3
24
|
## 7.0.1
|
|
4
25
|
|
|
5
26
|
## 7.0.0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-6844c5934
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -5308,34 +5308,6 @@ function invariant2(value, message) {
|
|
|
5308
5308
|
}
|
|
5309
5309
|
}
|
|
5310
5310
|
|
|
5311
|
-
// lib/dom/ssr/routeModules.ts
|
|
5312
|
-
async function loadRouteModule(route, routeModulesCache) {
|
|
5313
|
-
if (route.id in routeModulesCache) {
|
|
5314
|
-
return routeModulesCache[route.id];
|
|
5315
|
-
}
|
|
5316
|
-
try {
|
|
5317
|
-
let routeModule = await import(
|
|
5318
|
-
/* @vite-ignore */
|
|
5319
|
-
/* webpackIgnore: true */
|
|
5320
|
-
route.module
|
|
5321
|
-
);
|
|
5322
|
-
routeModulesCache[route.id] = routeModule;
|
|
5323
|
-
return routeModule;
|
|
5324
|
-
} catch (error) {
|
|
5325
|
-
console.error(
|
|
5326
|
-
`Error loading route module \`${route.module}\`, reloading page...`
|
|
5327
|
-
);
|
|
5328
|
-
console.error(error);
|
|
5329
|
-
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
5330
|
-
import.meta.hot) {
|
|
5331
|
-
throw error;
|
|
5332
|
-
}
|
|
5333
|
-
window.location.reload();
|
|
5334
|
-
return new Promise(() => {
|
|
5335
|
-
});
|
|
5336
|
-
}
|
|
5337
|
-
}
|
|
5338
|
-
|
|
5339
5311
|
// lib/dom/ssr/links.ts
|
|
5340
5312
|
function getKeyedLinksForMatches(matches, routeModules, manifest) {
|
|
5341
5313
|
let descriptors = matches.map((match) => {
|
|
@@ -5406,7 +5378,7 @@ function isHtmlLinkDescriptor(object) {
|
|
|
5406
5378
|
}
|
|
5407
5379
|
return typeof object.rel === "string" && typeof object.href === "string";
|
|
5408
5380
|
}
|
|
5409
|
-
async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
5381
|
+
async function getKeyedPrefetchLinks(matches, manifest, routeModules, loadRouteModule) {
|
|
5410
5382
|
let links = await Promise.all(
|
|
5411
5383
|
matches.map(async (match) => {
|
|
5412
5384
|
let route = manifest.routes[match.route.id];
|
|
@@ -5881,7 +5853,7 @@ function unwrapSingleFetchResult(result, routeId) {
|
|
|
5881
5853
|
if (result.replace) {
|
|
5882
5854
|
headers["X-Remix-Replace"] = "yes";
|
|
5883
5855
|
}
|
|
5884
|
-
|
|
5856
|
+
throw redirect(result.redirect, { status: result.status, headers });
|
|
5885
5857
|
} else if ("data" in result) {
|
|
5886
5858
|
return result.data;
|
|
5887
5859
|
} else {
|
|
@@ -6113,12 +6085,13 @@ function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId
|
|
|
6113
6085
|
return dataRoute;
|
|
6114
6086
|
});
|
|
6115
6087
|
}
|
|
6116
|
-
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, future, isSpaMode) {
|
|
6088
|
+
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, future, isSpaMode, loadRouteModule) {
|
|
6117
6089
|
return createClientRoutes(
|
|
6118
6090
|
manifest,
|
|
6119
6091
|
routeModulesCache,
|
|
6120
6092
|
initialState,
|
|
6121
6093
|
isSpaMode,
|
|
6094
|
+
loadRouteModule,
|
|
6122
6095
|
"",
|
|
6123
6096
|
groupRoutesByParentId(manifest),
|
|
6124
6097
|
needsRevalidation
|
|
@@ -6144,7 +6117,7 @@ function noActionDefinedError(type, routeId) {
|
|
|
6144
6117
|
console.error(msg);
|
|
6145
6118
|
throw new ErrorResponseImpl(405, "Method Not Allowed", new Error(msg), true);
|
|
6146
6119
|
}
|
|
6147
|
-
function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
6120
|
+
function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode, loadRouteModule, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
6148
6121
|
return (routesByParentId[parentId] || []).map((route) => {
|
|
6149
6122
|
let routeModule = routeModulesCache[route.id];
|
|
6150
6123
|
function fetchServerHandler(singleFetch) {
|
|
@@ -6272,7 +6245,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6272
6245
|
dataRoute.lazy = async () => {
|
|
6273
6246
|
let mod = await loadRouteModuleWithBlockingLinks(
|
|
6274
6247
|
route,
|
|
6275
|
-
routeModulesCache
|
|
6248
|
+
routeModulesCache,
|
|
6249
|
+
loadRouteModule
|
|
6276
6250
|
);
|
|
6277
6251
|
let lazyRoute = { ...mod };
|
|
6278
6252
|
if (mod.clientLoader) {
|
|
@@ -6317,6 +6291,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6317
6291
|
routeModulesCache,
|
|
6318
6292
|
initialState,
|
|
6319
6293
|
isSpaMode,
|
|
6294
|
+
loadRouteModule,
|
|
6320
6295
|
route.id,
|
|
6321
6296
|
routesByParentId,
|
|
6322
6297
|
needsRevalidation
|
|
@@ -6349,7 +6324,7 @@ function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalid
|
|
|
6349
6324
|
return routeShouldRevalidate ? routeShouldRevalidate(arg) : arg.defaultShouldRevalidate;
|
|
6350
6325
|
};
|
|
6351
6326
|
}
|
|
6352
|
-
async function loadRouteModuleWithBlockingLinks(route, routeModules) {
|
|
6327
|
+
async function loadRouteModuleWithBlockingLinks(route, routeModules, loadRouteModule) {
|
|
6353
6328
|
let routeModule = await loadRouteModule(route, routeModules);
|
|
6354
6329
|
await prefetchStyleLinks(route, routeModule);
|
|
6355
6330
|
return {
|
|
@@ -6406,7 +6381,7 @@ function getPartialManifest(manifest, router) {
|
|
|
6406
6381
|
routes: initialRoutes
|
|
6407
6382
|
};
|
|
6408
6383
|
}
|
|
6409
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, basename) {
|
|
6384
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, basename, loadRouteModule) {
|
|
6410
6385
|
if (!isFogOfWarEnabled(isSpaMode)) {
|
|
6411
6386
|
return void 0;
|
|
6412
6387
|
}
|
|
@@ -6419,12 +6394,13 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, b
|
|
|
6419
6394
|
manifest,
|
|
6420
6395
|
routeModules,
|
|
6421
6396
|
isSpaMode,
|
|
6397
|
+
loadRouteModule,
|
|
6422
6398
|
basename,
|
|
6423
6399
|
patch
|
|
6424
6400
|
);
|
|
6425
6401
|
};
|
|
6426
6402
|
}
|
|
6427
|
-
function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
|
|
6403
|
+
function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode, loadRouteModule) {
|
|
6428
6404
|
React8.useEffect(() => {
|
|
6429
6405
|
if (!isFogOfWarEnabled(isSpaMode) || navigator.connection?.saveData === true) {
|
|
6430
6406
|
return;
|
|
@@ -6456,6 +6432,7 @@ function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
|
|
|
6456
6432
|
manifest,
|
|
6457
6433
|
routeModules,
|
|
6458
6434
|
isSpaMode,
|
|
6435
|
+
loadRouteModule,
|
|
6459
6436
|
router.basename,
|
|
6460
6437
|
router.patchRoutes
|
|
6461
6438
|
);
|
|
@@ -6496,7 +6473,7 @@ function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
|
|
|
6496
6473
|
return () => observer.disconnect();
|
|
6497
6474
|
}, [isSpaMode, manifest, routeModules, router]);
|
|
6498
6475
|
}
|
|
6499
|
-
async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, basename, patchRoutes) {
|
|
6476
|
+
async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, loadRouteModule, basename, patchRoutes) {
|
|
6500
6477
|
let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
|
|
6501
6478
|
/\/+/g,
|
|
6502
6479
|
"/"
|
|
@@ -6533,7 +6510,14 @@ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpa
|
|
|
6533
6510
|
parentIds.forEach(
|
|
6534
6511
|
(parentId) => patchRoutes(
|
|
6535
6512
|
parentId || null,
|
|
6536
|
-
createClientRoutes(
|
|
6513
|
+
createClientRoutes(
|
|
6514
|
+
patches,
|
|
6515
|
+
routeModules,
|
|
6516
|
+
null,
|
|
6517
|
+
isSpaMode,
|
|
6518
|
+
loadRouteModule,
|
|
6519
|
+
parentId
|
|
6520
|
+
)
|
|
6537
6521
|
)
|
|
6538
6522
|
);
|
|
6539
6523
|
}
|
|
@@ -6677,23 +6661,25 @@ function PrefetchPageLinks({
|
|
|
6677
6661
|
[router.routes, page, router.basename]
|
|
6678
6662
|
);
|
|
6679
6663
|
if (!matches) {
|
|
6680
|
-
console.warn(`Tried to prefetch ${page} but no routes matched.`);
|
|
6681
6664
|
return null;
|
|
6682
6665
|
}
|
|
6683
6666
|
return /* @__PURE__ */ React9.createElement(PrefetchPageLinksImpl, { page, matches, ...dataLinkProps });
|
|
6684
6667
|
}
|
|
6685
6668
|
function useKeyedPrefetchLinks(matches) {
|
|
6686
|
-
let { manifest, routeModules } = useFrameworkContext();
|
|
6669
|
+
let { manifest, routeModules, loadRouteModule } = useFrameworkContext();
|
|
6687
6670
|
let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React9.useState([]);
|
|
6688
6671
|
React9.useEffect(() => {
|
|
6689
6672
|
let interrupted = false;
|
|
6690
|
-
void getKeyedPrefetchLinks(
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6673
|
+
void getKeyedPrefetchLinks(
|
|
6674
|
+
matches,
|
|
6675
|
+
manifest,
|
|
6676
|
+
routeModules,
|
|
6677
|
+
loadRouteModule
|
|
6678
|
+
).then((links) => {
|
|
6679
|
+
if (!interrupted) {
|
|
6680
|
+
setKeyedPrefetchLinks(links);
|
|
6695
6681
|
}
|
|
6696
|
-
);
|
|
6682
|
+
});
|
|
6697
6683
|
return () => {
|
|
6698
6684
|
interrupted = true;
|
|
6699
6685
|
};
|
|
@@ -6981,7 +6967,7 @@ function mergeRefs(...refs) {
|
|
|
6981
6967
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
6982
6968
|
try {
|
|
6983
6969
|
if (isBrowser) {
|
|
6984
|
-
window.__reactRouterVersion = "0.0.0-experimental-
|
|
6970
|
+
window.__reactRouterVersion = "0.0.0-experimental-6844c5934";
|
|
6985
6971
|
}
|
|
6986
6972
|
} catch (e) {
|
|
6987
6973
|
}
|
|
@@ -8057,10 +8043,39 @@ function htmlEscape(str) {
|
|
|
8057
8043
|
|
|
8058
8044
|
// lib/dom/ssr/server.tsx
|
|
8059
8045
|
import * as React12 from "react";
|
|
8046
|
+
|
|
8047
|
+
// lib/dom/ssr/routeModules.ts
|
|
8048
|
+
var defaultLoadRouteModule = async (route, routeModulesCache) => {
|
|
8049
|
+
if (route.id in routeModulesCache) {
|
|
8050
|
+
return routeModulesCache[route.id];
|
|
8051
|
+
}
|
|
8052
|
+
try {
|
|
8053
|
+
let routeModule = await import(
|
|
8054
|
+
/* @vite-ignore */
|
|
8055
|
+
/* webpackIgnore: true */
|
|
8056
|
+
route.module
|
|
8057
|
+
);
|
|
8058
|
+
routeModulesCache[route.id] = routeModule;
|
|
8059
|
+
return routeModule;
|
|
8060
|
+
} catch (error) {
|
|
8061
|
+
console.error(
|
|
8062
|
+
`Error loading route module \`${route.module}\`, reloading page...`
|
|
8063
|
+
);
|
|
8064
|
+
console.error(error);
|
|
8065
|
+
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
8066
|
+
import.meta.hot) {
|
|
8067
|
+
throw error;
|
|
8068
|
+
}
|
|
8069
|
+
window.location.reload();
|
|
8070
|
+
return new Promise(() => {
|
|
8071
|
+
});
|
|
8072
|
+
}
|
|
8073
|
+
};
|
|
8074
|
+
|
|
8075
|
+
// lib/dom/ssr/server.tsx
|
|
8060
8076
|
function ServerRouter({
|
|
8061
8077
|
context,
|
|
8062
8078
|
url,
|
|
8063
|
-
abortDelay,
|
|
8064
8079
|
nonce
|
|
8065
8080
|
}) {
|
|
8066
8081
|
if (typeof url === "string") {
|
|
@@ -8096,8 +8111,8 @@ function ServerRouter({
|
|
|
8096
8111
|
future: context.future,
|
|
8097
8112
|
isSpaMode: context.isSpaMode,
|
|
8098
8113
|
serializeError: context.serializeError,
|
|
8099
|
-
|
|
8100
|
-
|
|
8114
|
+
renderMeta: context.renderMeta,
|
|
8115
|
+
loadRouteModule: defaultLoadRouteModule
|
|
8101
8116
|
}
|
|
8102
8117
|
},
|
|
8103
8118
|
/* @__PURE__ */ React12.createElement(RemixErrorBoundary, { location: router.state.location }, /* @__PURE__ */ React12.createElement(
|
|
@@ -8127,7 +8142,8 @@ function createRoutesStub(routes, context = {}) {
|
|
|
8127
8142
|
initialEntries,
|
|
8128
8143
|
initialIndex,
|
|
8129
8144
|
hydrationData,
|
|
8130
|
-
future
|
|
8145
|
+
future,
|
|
8146
|
+
loadRouteModule = defaultLoadRouteModule
|
|
8131
8147
|
}) {
|
|
8132
8148
|
let routerRef = React13.useRef();
|
|
8133
8149
|
let remixContextRef = React13.useRef();
|
|
@@ -8141,7 +8157,8 @@ function createRoutesStub(routes, context = {}) {
|
|
|
8141
8157
|
version: ""
|
|
8142
8158
|
},
|
|
8143
8159
|
routeModules: {},
|
|
8144
|
-
isSpaMode: false
|
|
8160
|
+
isSpaMode: false,
|
|
8161
|
+
loadRouteModule
|
|
8145
8162
|
};
|
|
8146
8163
|
let patched = processRoutes(
|
|
8147
8164
|
// @ts-expect-error loader/action context types don't match :/
|
|
@@ -9199,7 +9216,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
9199
9216
|
renderMeta: {},
|
|
9200
9217
|
future: build.future,
|
|
9201
9218
|
isSpaMode: build.isSpaMode,
|
|
9202
|
-
serializeError: (err) => serializeError(err, serverMode)
|
|
9219
|
+
serializeError: (err) => serializeError(err, serverMode),
|
|
9220
|
+
loadRouteModule: defaultLoadRouteModule
|
|
9203
9221
|
};
|
|
9204
9222
|
let handleDocumentRequestFunction = build.entry.module.default;
|
|
9205
9223
|
try {
|
|
@@ -9604,6 +9622,7 @@ export {
|
|
|
9604
9622
|
StaticRouterProvider,
|
|
9605
9623
|
createStaticHandler2 as createStaticHandler,
|
|
9606
9624
|
createStaticRouter,
|
|
9625
|
+
defaultLoadRouteModule,
|
|
9607
9626
|
ServerRouter,
|
|
9608
9627
|
createRoutesStub,
|
|
9609
9628
|
createCookie,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { R as RouterProviderProps$1 } from './fog-of-war-
|
|
3
|
-
import './route-data-
|
|
2
|
+
import { R as RouterProviderProps$1 } from './fog-of-war-DhPlOTYA.mjs';
|
|
3
|
+
import { L as LoadRouteModuleFunction } from './route-data-Dwy1K32H.mjs';
|
|
4
4
|
|
|
5
5
|
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
6
6
|
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
@@ -8,6 +8,8 @@ declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">):
|
|
|
8
8
|
/**
|
|
9
9
|
* @category Router Components
|
|
10
10
|
*/
|
|
11
|
-
declare function HydratedRouter(
|
|
11
|
+
declare function HydratedRouter({ loadRouteModule, }: {
|
|
12
|
+
loadRouteModule?: LoadRouteModuleFunction;
|
|
13
|
+
}): React.JSX.Element;
|
|
12
14
|
|
|
13
15
|
export { HydratedRouter, RouterProvider, type RouterProviderProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { R as RouterProviderProps$1 } from './fog-of-war-
|
|
3
|
-
import './route-data-
|
|
2
|
+
import { R as RouterProviderProps$1 } from './fog-of-war-D8HgFD2R.js';
|
|
3
|
+
import { L as LoadRouteModuleFunction } from './route-data-Dwy1K32H.js';
|
|
4
4
|
|
|
5
5
|
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
6
6
|
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
@@ -8,6 +8,8 @@ declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">):
|
|
|
8
8
|
/**
|
|
9
9
|
* @category Router Components
|
|
10
10
|
*/
|
|
11
|
-
declare function HydratedRouter(
|
|
11
|
+
declare function HydratedRouter({ loadRouteModule, }: {
|
|
12
|
+
loadRouteModule?: LoadRouteModuleFunction;
|
|
13
|
+
}): React.JSX.Element;
|
|
12
14
|
|
|
13
15
|
export { HydratedRouter, RouterProvider, type RouterProviderProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-6844c5934
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -4183,34 +4183,6 @@ function invariant2(value, message) {
|
|
|
4183
4183
|
}
|
|
4184
4184
|
}
|
|
4185
4185
|
|
|
4186
|
-
// lib/dom/ssr/routeModules.ts
|
|
4187
|
-
async function loadRouteModule(route, routeModulesCache) {
|
|
4188
|
-
if (route.id in routeModulesCache) {
|
|
4189
|
-
return routeModulesCache[route.id];
|
|
4190
|
-
}
|
|
4191
|
-
try {
|
|
4192
|
-
let routeModule = await import(
|
|
4193
|
-
/* @vite-ignore */
|
|
4194
|
-
/* webpackIgnore: true */
|
|
4195
|
-
route.module
|
|
4196
|
-
);
|
|
4197
|
-
routeModulesCache[route.id] = routeModule;
|
|
4198
|
-
return routeModule;
|
|
4199
|
-
} catch (error) {
|
|
4200
|
-
console.error(
|
|
4201
|
-
`Error loading route module \`${route.module}\`, reloading page...`
|
|
4202
|
-
);
|
|
4203
|
-
console.error(error);
|
|
4204
|
-
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
4205
|
-
void 0) {
|
|
4206
|
-
throw error;
|
|
4207
|
-
}
|
|
4208
|
-
window.location.reload();
|
|
4209
|
-
return new Promise(() => {
|
|
4210
|
-
});
|
|
4211
|
-
}
|
|
4212
|
-
}
|
|
4213
|
-
|
|
4214
4186
|
// lib/dom/ssr/links.ts
|
|
4215
4187
|
async function prefetchStyleLinks(route, routeModule) {
|
|
4216
4188
|
if (!route.css && !routeModule.links || !isPreloadSupported()) return;
|
|
@@ -4541,7 +4513,7 @@ function unwrapSingleFetchResult(result, routeId) {
|
|
|
4541
4513
|
if (result.replace) {
|
|
4542
4514
|
headers["X-Remix-Replace"] = "yes";
|
|
4543
4515
|
}
|
|
4544
|
-
|
|
4516
|
+
throw redirect(result.redirect, { status: result.status, headers });
|
|
4545
4517
|
} else if ("data" in result) {
|
|
4546
4518
|
return result.data;
|
|
4547
4519
|
} else {
|
|
@@ -4733,12 +4705,13 @@ function getRouteComponents(route, routeModule, isSpaMode) {
|
|
|
4733
4705
|
}
|
|
4734
4706
|
return { Component: Component4, ErrorBoundary, HydrateFallback };
|
|
4735
4707
|
}
|
|
4736
|
-
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, future, isSpaMode) {
|
|
4708
|
+
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, future, isSpaMode, loadRouteModule) {
|
|
4737
4709
|
return createClientRoutes(
|
|
4738
4710
|
manifest,
|
|
4739
4711
|
routeModulesCache,
|
|
4740
4712
|
initialState,
|
|
4741
4713
|
isSpaMode,
|
|
4714
|
+
loadRouteModule,
|
|
4742
4715
|
"",
|
|
4743
4716
|
groupRoutesByParentId(manifest),
|
|
4744
4717
|
needsRevalidation
|
|
@@ -4764,7 +4737,7 @@ function noActionDefinedError(type, routeId) {
|
|
|
4764
4737
|
console.error(msg);
|
|
4765
4738
|
throw new ErrorResponseImpl(405, "Method Not Allowed", new Error(msg), true);
|
|
4766
4739
|
}
|
|
4767
|
-
function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
4740
|
+
function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode, loadRouteModule, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
4768
4741
|
return (routesByParentId[parentId] || []).map((route) => {
|
|
4769
4742
|
let routeModule = routeModulesCache[route.id];
|
|
4770
4743
|
function fetchServerHandler(singleFetch) {
|
|
@@ -4892,7 +4865,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4892
4865
|
dataRoute.lazy = async () => {
|
|
4893
4866
|
let mod = await loadRouteModuleWithBlockingLinks(
|
|
4894
4867
|
route,
|
|
4895
|
-
routeModulesCache
|
|
4868
|
+
routeModulesCache,
|
|
4869
|
+
loadRouteModule
|
|
4896
4870
|
);
|
|
4897
4871
|
let lazyRoute = { ...mod };
|
|
4898
4872
|
if (mod.clientLoader) {
|
|
@@ -4937,6 +4911,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
4937
4911
|
routeModulesCache,
|
|
4938
4912
|
initialState,
|
|
4939
4913
|
isSpaMode,
|
|
4914
|
+
loadRouteModule,
|
|
4940
4915
|
route.id,
|
|
4941
4916
|
routesByParentId,
|
|
4942
4917
|
needsRevalidation
|
|
@@ -4969,7 +4944,7 @@ function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalid
|
|
|
4969
4944
|
return routeShouldRevalidate ? routeShouldRevalidate(arg) : arg.defaultShouldRevalidate;
|
|
4970
4945
|
};
|
|
4971
4946
|
}
|
|
4972
|
-
async function loadRouteModuleWithBlockingLinks(route, routeModules) {
|
|
4947
|
+
async function loadRouteModuleWithBlockingLinks(route, routeModules, loadRouteModule) {
|
|
4973
4948
|
let routeModule = await loadRouteModule(route, routeModules);
|
|
4974
4949
|
await prefetchStyleLinks(route, routeModule);
|
|
4975
4950
|
return {
|
|
@@ -5026,7 +5001,7 @@ function getPartialManifest(manifest, router2) {
|
|
|
5026
5001
|
routes: initialRoutes
|
|
5027
5002
|
};
|
|
5028
5003
|
}
|
|
5029
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, basename) {
|
|
5004
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, basename, loadRouteModule) {
|
|
5030
5005
|
if (!isFogOfWarEnabled(isSpaMode)) {
|
|
5031
5006
|
return void 0;
|
|
5032
5007
|
}
|
|
@@ -5039,12 +5014,13 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, b
|
|
|
5039
5014
|
manifest,
|
|
5040
5015
|
routeModules,
|
|
5041
5016
|
isSpaMode,
|
|
5017
|
+
loadRouteModule,
|
|
5042
5018
|
basename,
|
|
5043
5019
|
patch
|
|
5044
5020
|
);
|
|
5045
5021
|
};
|
|
5046
5022
|
}
|
|
5047
|
-
function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
|
|
5023
|
+
function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode, loadRouteModule) {
|
|
5048
5024
|
React8.useEffect(() => {
|
|
5049
5025
|
if (!isFogOfWarEnabled(isSpaMode) || navigator.connection?.saveData === true) {
|
|
5050
5026
|
return;
|
|
@@ -5076,6 +5052,7 @@ function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
|
|
|
5076
5052
|
manifest,
|
|
5077
5053
|
routeModules,
|
|
5078
5054
|
isSpaMode,
|
|
5055
|
+
loadRouteModule,
|
|
5079
5056
|
router2.basename,
|
|
5080
5057
|
router2.patchRoutes
|
|
5081
5058
|
);
|
|
@@ -5116,7 +5093,7 @@ function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
|
|
|
5116
5093
|
return () => observer.disconnect();
|
|
5117
5094
|
}, [isSpaMode, manifest, routeModules, router2]);
|
|
5118
5095
|
}
|
|
5119
|
-
async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, basename, patchRoutes) {
|
|
5096
|
+
async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, loadRouteModule, basename, patchRoutes) {
|
|
5120
5097
|
let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
|
|
5121
5098
|
/\/+/g,
|
|
5122
5099
|
"/"
|
|
@@ -5153,7 +5130,14 @@ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpa
|
|
|
5153
5130
|
parentIds.forEach(
|
|
5154
5131
|
(parentId) => patchRoutes(
|
|
5155
5132
|
parentId || null,
|
|
5156
|
-
createClientRoutes(
|
|
5133
|
+
createClientRoutes(
|
|
5134
|
+
patches,
|
|
5135
|
+
routeModules,
|
|
5136
|
+
null,
|
|
5137
|
+
isSpaMode,
|
|
5138
|
+
loadRouteModule,
|
|
5139
|
+
parentId
|
|
5140
|
+
)
|
|
5157
5141
|
)
|
|
5158
5142
|
);
|
|
5159
5143
|
}
|
|
@@ -5294,6 +5278,34 @@ function dedupe(array) {
|
|
|
5294
5278
|
return [...new Set(array)];
|
|
5295
5279
|
}
|
|
5296
5280
|
|
|
5281
|
+
// lib/dom/ssr/routeModules.ts
|
|
5282
|
+
var defaultLoadRouteModule = async (route, routeModulesCache) => {
|
|
5283
|
+
if (route.id in routeModulesCache) {
|
|
5284
|
+
return routeModulesCache[route.id];
|
|
5285
|
+
}
|
|
5286
|
+
try {
|
|
5287
|
+
let routeModule = await import(
|
|
5288
|
+
/* @vite-ignore */
|
|
5289
|
+
/* webpackIgnore: true */
|
|
5290
|
+
route.module
|
|
5291
|
+
);
|
|
5292
|
+
routeModulesCache[route.id] = routeModule;
|
|
5293
|
+
return routeModule;
|
|
5294
|
+
} catch (error) {
|
|
5295
|
+
console.error(
|
|
5296
|
+
`Error loading route module \`${route.module}\`, reloading page...`
|
|
5297
|
+
);
|
|
5298
|
+
console.error(error);
|
|
5299
|
+
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
5300
|
+
void 0) {
|
|
5301
|
+
throw error;
|
|
5302
|
+
}
|
|
5303
|
+
window.location.reload();
|
|
5304
|
+
return new Promise(() => {
|
|
5305
|
+
});
|
|
5306
|
+
}
|
|
5307
|
+
};
|
|
5308
|
+
|
|
5297
5309
|
// lib/dom/ssr/errors.ts
|
|
5298
5310
|
function deserializeErrors(errors) {
|
|
5299
5311
|
if (!errors) return null;
|
|
@@ -5352,7 +5364,9 @@ function initSsrInfo() {
|
|
|
5352
5364
|
};
|
|
5353
5365
|
}
|
|
5354
5366
|
}
|
|
5355
|
-
function createHydratedRouter(
|
|
5367
|
+
function createHydratedRouter({
|
|
5368
|
+
loadRouteModule = defaultLoadRouteModule
|
|
5369
|
+
} = {}) {
|
|
5356
5370
|
initSsrInfo();
|
|
5357
5371
|
if (!ssrInfo) {
|
|
5358
5372
|
throw new Error(
|
|
@@ -5381,7 +5395,8 @@ function createHydratedRouter() {
|
|
|
5381
5395
|
ssrInfo.manifest.routes,
|
|
5382
5396
|
ssrInfo.routeModules,
|
|
5383
5397
|
ssrInfo.context.state,
|
|
5384
|
-
ssrInfo.context.isSpaMode
|
|
5398
|
+
ssrInfo.context.isSpaMode,
|
|
5399
|
+
loadRouteModule
|
|
5385
5400
|
);
|
|
5386
5401
|
let hydrationData = void 0;
|
|
5387
5402
|
if (!ssrInfo.context.isSpaMode) {
|
|
@@ -5429,7 +5444,8 @@ function createHydratedRouter() {
|
|
|
5429
5444
|
ssrInfo.manifest,
|
|
5430
5445
|
ssrInfo.routeModules,
|
|
5431
5446
|
ssrInfo.context.isSpaMode,
|
|
5432
|
-
ssrInfo.context.basename
|
|
5447
|
+
ssrInfo.context.basename,
|
|
5448
|
+
loadRouteModule
|
|
5433
5449
|
)
|
|
5434
5450
|
});
|
|
5435
5451
|
ssrInfo.router = router2;
|
|
@@ -5442,9 +5458,11 @@ function createHydratedRouter() {
|
|
|
5442
5458
|
window.__reactRouterDataRouter = router2;
|
|
5443
5459
|
return router2;
|
|
5444
5460
|
}
|
|
5445
|
-
function HydratedRouter(
|
|
5461
|
+
function HydratedRouter({
|
|
5462
|
+
loadRouteModule = defaultLoadRouteModule
|
|
5463
|
+
}) {
|
|
5446
5464
|
if (!router) {
|
|
5447
|
-
router = createHydratedRouter();
|
|
5465
|
+
router = createHydratedRouter({ loadRouteModule });
|
|
5448
5466
|
}
|
|
5449
5467
|
let [criticalCss, setCriticalCss] = React11.useState(
|
|
5450
5468
|
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|
|
@@ -5475,7 +5493,8 @@ function HydratedRouter() {
|
|
|
5475
5493
|
router,
|
|
5476
5494
|
ssrInfo.manifest,
|
|
5477
5495
|
ssrInfo.routeModules,
|
|
5478
|
-
ssrInfo.context.isSpaMode
|
|
5496
|
+
ssrInfo.context.isSpaMode,
|
|
5497
|
+
loadRouteModule
|
|
5479
5498
|
);
|
|
5480
5499
|
return (
|
|
5481
5500
|
// This fragment is important to ensure we match the <ServerRouter> JSX
|
|
@@ -5488,7 +5507,8 @@ function HydratedRouter() {
|
|
|
5488
5507
|
routeModules: ssrInfo.routeModules,
|
|
5489
5508
|
future: ssrInfo.context.future,
|
|
5490
5509
|
criticalCss,
|
|
5491
|
-
isSpaMode: ssrInfo.context.isSpaMode
|
|
5510
|
+
isSpaMode: ssrInfo.context.isSpaMode,
|
|
5511
|
+
loadRouteModule
|
|
5492
5512
|
}
|
|
5493
5513
|
},
|
|
5494
5514
|
/* @__PURE__ */ React11.createElement(RemixErrorBoundary, { location }, /* @__PURE__ */ React11.createElement(RouterProvider2, { router }))
|