react-router 0.0.0-experimental-e145538f2 → 0.0.0-experimental-10a6fd0e1
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/index.js +16 -164
- package/dist/index.js.map +1 -1
- package/dist/lib/dom/global.d.ts +0 -2
- package/dist/lib/dom/ssr/single-fetch.d.ts +1 -2
- package/dist/main.js +1 -1
- package/dist/react-router.development.js +16 -164
- package/dist/react-router.development.js.map +1 -1
- package/dist/react-router.production.min.js +2 -2
- package/dist/react-router.production.min.js.map +1 -1
- package/dist/umd/react-router.development.js +16 -169
- package/dist/umd/react-router.development.js.map +1 -1
- package/dist/umd/react-router.production.min.js +2 -2
- package/dist/umd/react-router.production.min.js.map +1 -1
- package/package.json +1 -10
- package/dist/rsc.js +0 -1642
package/dist/lib/dom/global.d.ts
CHANGED
|
@@ -11,8 +11,6 @@ export type WindowRemixContext = {
|
|
|
11
11
|
isSpaMode: boolean;
|
|
12
12
|
stream: ReadableStream<Uint8Array> | undefined;
|
|
13
13
|
streamController: ReadableStreamDefaultController<Uint8Array>;
|
|
14
|
-
streamAction?: ReadableStream<Uint8Array> | undefined;
|
|
15
|
-
streamControllerAction?: ReadableStreamDefaultController<Uint8Array>;
|
|
16
14
|
a?: number;
|
|
17
15
|
dev?: {
|
|
18
16
|
port?: number;
|
|
@@ -24,10 +24,9 @@ interface StreamTransferProps {
|
|
|
24
24
|
identifier: number;
|
|
25
25
|
reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
26
26
|
textDecoder: TextDecoder;
|
|
27
|
-
isAction: boolean;
|
|
28
27
|
nonce?: string;
|
|
29
28
|
}
|
|
30
|
-
export declare function StreamTransfer({ context, identifier, reader, textDecoder,
|
|
29
|
+
export declare function StreamTransfer({ context, identifier, reader, textDecoder, nonce, }: StreamTransferProps): React.JSX.Element | null;
|
|
31
30
|
export declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules): DataStrategyFunction;
|
|
32
31
|
export declare function addRevalidationParam(manifest: AssetsManifest, routeModules: RouteModules, matchedRoutes: DataRouteObject[], loadRoutes: DataRouteObject[], url: URL): URL;
|
|
33
32
|
export declare function singleFetchUrl(reqUrl: URL | string): URL;
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* React Router v0.0.0-experimental-
|
|
2
|
+
* React Router v0.0.0-experimental-10a6fd0e1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -7308,7 +7308,6 @@ function StreamTransfer({
|
|
|
7308
7308
|
identifier,
|
|
7309
7309
|
reader,
|
|
7310
7310
|
textDecoder,
|
|
7311
|
-
isAction,
|
|
7312
7311
|
nonce
|
|
7313
7312
|
}) {
|
|
7314
7313
|
// If the user didn't render the <Scripts> component then we don't have to
|
|
@@ -7319,16 +7318,9 @@ function StreamTransfer({
|
|
|
7319
7318
|
if (!context.renderMeta.streamCache) {
|
|
7320
7319
|
context.renderMeta.streamCache = {};
|
|
7321
7320
|
}
|
|
7322
|
-
let
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
context.renderMeta.streamCacheAction = {};
|
|
7326
|
-
streamCache = context.renderMeta.streamCacheAction;
|
|
7327
|
-
} else {
|
|
7328
|
-
context.renderMeta.streamCache = {};
|
|
7329
|
-
streamCache = context.renderMeta.streamCache;
|
|
7330
|
-
}
|
|
7331
|
-
}
|
|
7321
|
+
let {
|
|
7322
|
+
streamCache
|
|
7323
|
+
} = context.renderMeta;
|
|
7332
7324
|
let promise = streamCache[identifier];
|
|
7333
7325
|
if (!promise) {
|
|
7334
7326
|
promise = streamCache[identifier] = reader.read().then(result => {
|
|
@@ -7355,14 +7347,14 @@ function StreamTransfer({
|
|
|
7355
7347
|
let scriptTag = value ? /*#__PURE__*/React.createElement("script", {
|
|
7356
7348
|
nonce: nonce,
|
|
7357
7349
|
dangerouslySetInnerHTML: {
|
|
7358
|
-
__html: `window.__remixContext.streamController
|
|
7350
|
+
__html: `window.__remixContext.streamController.enqueue(${escapeHtml(JSON.stringify(value))});`
|
|
7359
7351
|
}
|
|
7360
7352
|
}) : null;
|
|
7361
7353
|
if (done) {
|
|
7362
7354
|
return /*#__PURE__*/React.createElement(React.Fragment, null, scriptTag, /*#__PURE__*/React.createElement("script", {
|
|
7363
7355
|
nonce: nonce,
|
|
7364
7356
|
dangerouslySetInnerHTML: {
|
|
7365
|
-
__html: `window.__remixContext.streamController
|
|
7357
|
+
__html: `window.__remixContext.streamController.close();`
|
|
7366
7358
|
}
|
|
7367
7359
|
}));
|
|
7368
7360
|
} else {
|
|
@@ -7371,7 +7363,6 @@ function StreamTransfer({
|
|
|
7371
7363
|
identifier: identifier + 1,
|
|
7372
7364
|
reader: reader,
|
|
7373
7365
|
textDecoder: textDecoder,
|
|
7374
|
-
isAction: isAction,
|
|
7375
7366
|
nonce: nonce
|
|
7376
7367
|
})));
|
|
7377
7368
|
}
|
|
@@ -7507,15 +7498,6 @@ function singleFetchUrl(reqUrl) {
|
|
|
7507
7498
|
async function fetchAndDecode(url, init) {
|
|
7508
7499
|
let res = await fetch(url, init);
|
|
7509
7500
|
!res.body ? invariant(false, "No response body to decode") : void 0;
|
|
7510
|
-
if (res.headers.get("Content-Type")?.includes("text/x-component")) {
|
|
7511
|
-
!res.body ? invariant(false, "No response body to decode") : void 0;
|
|
7512
|
-
// @ts-expect-error - TODO: Figure out where this comes from
|
|
7513
|
-
let decoded = await window.createFromReadableStream(res.body);
|
|
7514
|
-
return {
|
|
7515
|
-
status: res.status,
|
|
7516
|
-
data: decoded
|
|
7517
|
-
};
|
|
7518
|
-
}
|
|
7519
7501
|
try {
|
|
7520
7502
|
let decoded = await decodeViaTurboStream(res.body, window);
|
|
7521
7503
|
return {
|
|
@@ -8049,8 +8031,7 @@ function Scripts(props) {
|
|
|
8049
8031
|
manifest,
|
|
8050
8032
|
serverHandoffString,
|
|
8051
8033
|
isSpaMode,
|
|
8052
|
-
renderMeta
|
|
8053
|
-
future
|
|
8034
|
+
renderMeta
|
|
8054
8035
|
} = useRemixContext();
|
|
8055
8036
|
let {
|
|
8056
8037
|
router,
|
|
@@ -8073,9 +8054,6 @@ function Scripts(props) {
|
|
|
8073
8054
|
}, []);
|
|
8074
8055
|
let initialScripts = React.useMemo(() => {
|
|
8075
8056
|
let streamScript = "window.__remixContext.stream = new ReadableStream({" + "start(controller){" + "window.__remixContext.streamController = controller;" + "}" + "}).pipeThrough(new TextEncoderStream());";
|
|
8076
|
-
if (future.unstable_serverComponents && staticContext?.actionData) {
|
|
8077
|
-
streamScript += "window.__remixContext.streamAction = new ReadableStream({" + "start(controller){" + "window.__remixContext.streamControllerAction = controller;" + "}" + "}).pipeThrough(new TextEncoderStream());";
|
|
8078
|
-
}
|
|
8079
8057
|
let contextScript = staticContext ? `window.__remixContext = ${serverHandoffString};${streamScript}` : " ";
|
|
8080
8058
|
let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}import ${JSON.stringify(manifest.url)};
|
|
8081
8059
|
${matches.map((match, index) => `import * as route${index} from ${JSON.stringify(manifest.routes[match.route.id].module)};`).join("\n")}
|
|
@@ -10351,7 +10329,7 @@ function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId
|
|
|
10351
10329
|
// has a loader/clientLoader, but it won't ever be called during the static
|
|
10352
10330
|
// render, so just give it a no-op function so we can render down to the
|
|
10353
10331
|
// proper fallback
|
|
10354
|
-
loader: route.hasLoader || route.hasClientLoader ?
|
|
10332
|
+
loader: route.hasLoader || route.hasClientLoader ? () => null : undefined
|
|
10355
10333
|
// We don't need action/shouldRevalidate on these routes since they're
|
|
10356
10334
|
// for a static render
|
|
10357
10335
|
};
|
|
@@ -10626,85 +10604,6 @@ function initSsrInfo() {
|
|
|
10626
10604
|
};
|
|
10627
10605
|
}
|
|
10628
10606
|
}
|
|
10629
|
-
let hmrInfo = null;
|
|
10630
|
-
if (import.meta &&
|
|
10631
|
-
// @ts-expect-error
|
|
10632
|
-
import.meta.hot && typeof window !== "undefined" && window.__remixManifest) {
|
|
10633
|
-
let resolve;
|
|
10634
|
-
let routerReadyPromise = new Promise(r => {
|
|
10635
|
-
resolve = r;
|
|
10636
|
-
}).catch(() => {
|
|
10637
|
-
// This is a noop catch handler to avoid unhandled promise rejection warnings
|
|
10638
|
-
// in the console. The promise is never rejected.
|
|
10639
|
-
return undefined;
|
|
10640
|
-
});
|
|
10641
|
-
hmrInfo = {
|
|
10642
|
-
abortController: undefined,
|
|
10643
|
-
routerReadyResolve: resolve,
|
|
10644
|
-
// There's a race condition with HMR where the remix:manifest is signaled before
|
|
10645
|
-
// the router is assigned in the RemixBrowser component. This promise gates the
|
|
10646
|
-
// HMR handler until the router is ready
|
|
10647
|
-
routerReadyPromise
|
|
10648
|
-
};
|
|
10649
|
-
|
|
10650
|
-
// @ts-expect-error
|
|
10651
|
-
import.meta.hot.accept("remix:manifest", async ({
|
|
10652
|
-
assetsManifest,
|
|
10653
|
-
needsRevalidation
|
|
10654
|
-
}) => {
|
|
10655
|
-
let router = await hmrInfo.routerReadyPromise;
|
|
10656
|
-
// This should never happen, but just in case...
|
|
10657
|
-
if (!router || !ssrInfo || !hmrInfo) {
|
|
10658
|
-
console.error("Failed to accept HMR update because the router/ssrInfo was not ready.");
|
|
10659
|
-
return;
|
|
10660
|
-
}
|
|
10661
|
-
let routeIds = [...new Set(router.state.matches.map(m => m.route.id).concat(Object.keys(ssrInfo.routeModules)))];
|
|
10662
|
-
hmrInfo.abortController?.abort();
|
|
10663
|
-
hmrInfo.abortController = new AbortController();
|
|
10664
|
-
let signal = hmrInfo.abortController.signal;
|
|
10665
|
-
|
|
10666
|
-
// Load new route modules that we've seen.
|
|
10667
|
-
let newRouteModules = Object.assign({}, ssrInfo.routeModules, Object.fromEntries((await Promise.all(routeIds.map(async id => {
|
|
10668
|
-
if (!assetsManifest.routes[id]) {
|
|
10669
|
-
return null;
|
|
10670
|
-
}
|
|
10671
|
-
let imported = await import(assetsManifest.routes[id].module + `?t=${assetsManifest.hmr?.timestamp}`);
|
|
10672
|
-
!ssrInfo ? invariant(false, "ssrInfo unavailable for HMR update") : void 0;
|
|
10673
|
-
return [id, {
|
|
10674
|
-
...imported,
|
|
10675
|
-
// react-refresh takes care of updating these in-place,
|
|
10676
|
-
// if we don't preserve existing values we'll loose state.
|
|
10677
|
-
default: imported.default ? ssrInfo.routeModules[id]?.default || imported.default : imported.default,
|
|
10678
|
-
ErrorBoundary: imported.ErrorBoundary ? ssrInfo.routeModules[id]?.ErrorBoundary || imported.ErrorBoundary : imported.ErrorBoundary,
|
|
10679
|
-
HydrateFallback: imported.HydrateFallback ? ssrInfo.routeModules[id]?.HydrateFallback || imported.HydrateFallback : imported.HydrateFallback
|
|
10680
|
-
}];
|
|
10681
|
-
}))).filter(Boolean)));
|
|
10682
|
-
Object.assign(ssrInfo.routeModules, newRouteModules);
|
|
10683
|
-
// Create new routes
|
|
10684
|
-
let routes = createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, assetsManifest.routes, ssrInfo.routeModules, ssrInfo.context.state, ssrInfo.context.future, ssrInfo.context.isSpaMode);
|
|
10685
|
-
|
|
10686
|
-
// This is temporary API and will be more granular before release
|
|
10687
|
-
router._internalSetRoutes(routes);
|
|
10688
|
-
|
|
10689
|
-
// Wait for router to be idle before updating the manifest and route modules
|
|
10690
|
-
// and triggering a react-refresh
|
|
10691
|
-
let unsub = router.subscribe(state => {
|
|
10692
|
-
if (state.revalidation === "idle") {
|
|
10693
|
-
unsub();
|
|
10694
|
-
// Abort if a new update comes in while we're waiting for the
|
|
10695
|
-
// router to be idle.
|
|
10696
|
-
if (signal.aborted) return;
|
|
10697
|
-
// Ensure RouterProvider setState has flushed before re-rendering
|
|
10698
|
-
setTimeout(() => {
|
|
10699
|
-
Object.assign(ssrInfo.manifest, assetsManifest);
|
|
10700
|
-
window.$RefreshRuntime$.performReactRefresh();
|
|
10701
|
-
}, 1);
|
|
10702
|
-
}
|
|
10703
|
-
});
|
|
10704
|
-
window.__remixRevalidation = (window.__remixRevalidation || 0) + 1;
|
|
10705
|
-
router.revalidate();
|
|
10706
|
-
});
|
|
10707
|
-
}
|
|
10708
10607
|
function createHydratedRouter() {
|
|
10709
10608
|
initSsrInfo();
|
|
10710
10609
|
if (!ssrInfo) {
|
|
@@ -10723,49 +10622,14 @@ function createHydratedRouter() {
|
|
|
10723
10622
|
// then only get past here and create the `router` one time
|
|
10724
10623
|
if (!ssrInfo.stateDecodingPromise) {
|
|
10725
10624
|
let stream = ssrInfo.context.stream;
|
|
10726
|
-
let streamAction = ssrInfo.context.streamAction;
|
|
10727
10625
|
!stream ? invariant(false, "No stream found for single fetch decoding") : void 0;
|
|
10728
10626
|
ssrInfo.context.stream = undefined;
|
|
10729
|
-
|
|
10730
|
-
ssrInfo.
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
let state = {};
|
|
10736
|
-
for (let routeId of Object.keys(ssrInfo.routeModules)) {
|
|
10737
|
-
if ("error" in loaderPayload[routeId]) {
|
|
10738
|
-
state.errors = state.errors || {};
|
|
10739
|
-
state.errors[routeId] = loaderPayload[routeId].error;
|
|
10740
|
-
} else if ("data" in loaderPayload[routeId]) {
|
|
10741
|
-
state.loaderData = state.loaderData || {};
|
|
10742
|
-
state.loaderData[routeId] = loaderPayload[routeId].data;
|
|
10743
|
-
}
|
|
10744
|
-
}
|
|
10745
|
-
if (actionPayload) {
|
|
10746
|
-
// @ts-expect-error - TODO: Fix types and don't get it off the window directly
|
|
10747
|
-
const actionId = window.__remixContext.serverHandoffActionId;
|
|
10748
|
-
if ("error" in actionPayload) {
|
|
10749
|
-
state.errors = state.errors || {};
|
|
10750
|
-
state.errors[actionId] = actionPayload.error;
|
|
10751
|
-
} else if ("data" in actionPayload) {
|
|
10752
|
-
state.actionData = state.actionData || {};
|
|
10753
|
-
state.actionData[actionId] = actionPayload.data;
|
|
10754
|
-
}
|
|
10755
|
-
}
|
|
10756
|
-
ssrInfo.context.state = state;
|
|
10757
|
-
localSsrInfo.stateDecodingPromise.value = true;
|
|
10758
|
-
}).catch(e => {
|
|
10759
|
-
localSsrInfo.stateDecodingPromise.error = e;
|
|
10760
|
-
});
|
|
10761
|
-
} else {
|
|
10762
|
-
ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then(value => {
|
|
10763
|
-
ssrInfo.context.state = value.value;
|
|
10764
|
-
localSsrInfo.stateDecodingPromise.value = true;
|
|
10765
|
-
}).catch(e => {
|
|
10766
|
-
localSsrInfo.stateDecodingPromise.error = e;
|
|
10767
|
-
});
|
|
10768
|
-
}
|
|
10627
|
+
ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then(value => {
|
|
10628
|
+
ssrInfo.context.state = value.value;
|
|
10629
|
+
localSsrInfo.stateDecodingPromise.value = true;
|
|
10630
|
+
}).catch(e => {
|
|
10631
|
+
localSsrInfo.stateDecodingPromise.error = e;
|
|
10632
|
+
});
|
|
10769
10633
|
}
|
|
10770
10634
|
if (ssrInfo.stateDecodingPromise.error) {
|
|
10771
10635
|
throw ssrInfo.stateDecodingPromise.error;
|
|
@@ -10848,9 +10712,6 @@ function createHydratedRouter() {
|
|
|
10848
10712
|
// @ts-ignore
|
|
10849
10713
|
router.createRoutesForHMR = createClientRoutesWithHMRRevalidationOptOut;
|
|
10850
10714
|
window.__remixRouter = router;
|
|
10851
|
-
|
|
10852
|
-
// Notify that the router is ready for HMR
|
|
10853
|
-
hmrInfo?.routerReadyResolve(router);
|
|
10854
10715
|
return router;
|
|
10855
10716
|
}
|
|
10856
10717
|
|
|
@@ -10987,19 +10848,11 @@ function RemixServer({
|
|
|
10987
10848
|
router: router,
|
|
10988
10849
|
context: context.staticHandlerContext,
|
|
10989
10850
|
hydrate: false
|
|
10990
|
-
}))), context.
|
|
10991
|
-
context: context,
|
|
10992
|
-
identifier: 0,
|
|
10993
|
-
reader: context.serverHandoffStreamAction.getReader(),
|
|
10994
|
-
textDecoder: new TextDecoder(),
|
|
10995
|
-
isAction: true,
|
|
10996
|
-
nonce: nonce
|
|
10997
|
-
})) : null, context.serverHandoffStream ? /*#__PURE__*/React.createElement(React.Suspense, null, /*#__PURE__*/React.createElement(StreamTransfer, {
|
|
10851
|
+
}))), context.serverHandoffStream ? /*#__PURE__*/React.createElement(React.Suspense, null, /*#__PURE__*/React.createElement(StreamTransfer, {
|
|
10998
10852
|
context: context,
|
|
10999
10853
|
identifier: 0,
|
|
11000
10854
|
reader: context.serverHandoffStream.getReader(),
|
|
11001
10855
|
textDecoder: new TextDecoder(),
|
|
11002
|
-
isAction: false,
|
|
11003
10856
|
nonce: nonce
|
|
11004
10857
|
})) : null);
|
|
11005
10858
|
}
|
|
@@ -11020,8 +10873,7 @@ function createRemixStub(routes, context = {}) {
|
|
|
11020
10873
|
remixContextRef.current = {
|
|
11021
10874
|
future: {
|
|
11022
10875
|
v3_fetcherPersist: future?.v3_fetcherPersist === true,
|
|
11023
|
-
v3_relativeSplatPath: future?.v3_relativeSplatPath === true
|
|
11024
|
-
unstable_serverComponents: future?.unstable_serverComponents === true
|
|
10876
|
+
v3_relativeSplatPath: future?.v3_relativeSplatPath === true
|
|
11025
10877
|
},
|
|
11026
10878
|
manifest: {
|
|
11027
10879
|
routes: {},
|