react-router 0.0.0-experimental-e16afd9b7 → 0.0.0-experimental-13d6d438f
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 +19 -86
- 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 +19 -84
- 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 +19 -86
- 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 -1641
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* React Router v0.0.0-experimental-
|
|
2
|
+
* React Router v0.0.0-experimental-13d6d438f
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -6428,8 +6428,7 @@ function StreamTransfer(_ref) {
|
|
|
6428
6428
|
context,
|
|
6429
6429
|
identifier,
|
|
6430
6430
|
reader,
|
|
6431
|
-
textDecoder
|
|
6432
|
-
isAction
|
|
6431
|
+
textDecoder
|
|
6433
6432
|
} = _ref;
|
|
6434
6433
|
// If the user didn't render the <Scripts> component then we don't have to
|
|
6435
6434
|
// bother streaming anything in
|
|
@@ -6439,16 +6438,9 @@ function StreamTransfer(_ref) {
|
|
|
6439
6438
|
if (!context.renderMeta.streamCache) {
|
|
6440
6439
|
context.renderMeta.streamCache = {};
|
|
6441
6440
|
}
|
|
6442
|
-
let
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
context.renderMeta.streamCacheAction = {};
|
|
6446
|
-
streamCache = context.renderMeta.streamCacheAction;
|
|
6447
|
-
} else {
|
|
6448
|
-
context.renderMeta.streamCache = {};
|
|
6449
|
-
streamCache = context.renderMeta.streamCache;
|
|
6450
|
-
}
|
|
6451
|
-
}
|
|
6441
|
+
let {
|
|
6442
|
+
streamCache
|
|
6443
|
+
} = context.renderMeta;
|
|
6452
6444
|
let promise = streamCache[identifier];
|
|
6453
6445
|
if (!promise) {
|
|
6454
6446
|
promise = streamCache[identifier] = reader.read().then(result => {
|
|
@@ -6474,13 +6466,13 @@ function StreamTransfer(_ref) {
|
|
|
6474
6466
|
} = promise.result;
|
|
6475
6467
|
let scriptTag = value ? ( /*#__PURE__*/React.createElement("script", {
|
|
6476
6468
|
dangerouslySetInnerHTML: {
|
|
6477
|
-
__html: "window.__remixContext.streamController
|
|
6469
|
+
__html: "window.__remixContext.streamController.enqueue(" + escapeHtml(JSON.stringify(value)) + ");"
|
|
6478
6470
|
}
|
|
6479
6471
|
})) : null;
|
|
6480
6472
|
if (done) {
|
|
6481
6473
|
return /*#__PURE__*/React.createElement(React.Fragment, null, scriptTag, /*#__PURE__*/React.createElement("script", {
|
|
6482
6474
|
dangerouslySetInnerHTML: {
|
|
6483
|
-
__html: "window.__remixContext.streamController
|
|
6475
|
+
__html: "window.__remixContext.streamController.close();"
|
|
6484
6476
|
}
|
|
6485
6477
|
}));
|
|
6486
6478
|
} else {
|
|
@@ -6488,8 +6480,7 @@ function StreamTransfer(_ref) {
|
|
|
6488
6480
|
context: context,
|
|
6489
6481
|
identifier: identifier + 1,
|
|
6490
6482
|
reader: reader,
|
|
6491
|
-
textDecoder: textDecoder
|
|
6492
|
-
isAction: isAction
|
|
6483
|
+
textDecoder: textDecoder
|
|
6493
6484
|
})));
|
|
6494
6485
|
}
|
|
6495
6486
|
}
|
|
@@ -6628,18 +6619,8 @@ function singleFetchUrl(reqUrl) {
|
|
|
6628
6619
|
return url;
|
|
6629
6620
|
}
|
|
6630
6621
|
async function fetchAndDecode(url, init) {
|
|
6631
|
-
var _res$headers$get;
|
|
6632
6622
|
let res = await fetch(url, init);
|
|
6633
6623
|
!res.body ? process.env.NODE_ENV !== "production" ? invariant(false, "No response body to decode") : invariant(false) : void 0;
|
|
6634
|
-
if ((_res$headers$get = res.headers.get("Content-Type")) != null && _res$headers$get.includes("text/x-component")) {
|
|
6635
|
-
!res.body ? process.env.NODE_ENV !== "production" ? invariant(false, "No response body to decode") : invariant(false) : void 0;
|
|
6636
|
-
// @ts-expect-error - TODO: Figure out where this comes from
|
|
6637
|
-
let decoded = await window.createFromReadableStream(res.body);
|
|
6638
|
-
return {
|
|
6639
|
-
status: res.status,
|
|
6640
|
-
data: decoded
|
|
6641
|
-
};
|
|
6642
|
-
}
|
|
6643
6624
|
try {
|
|
6644
6625
|
let decoded = await decodeViaTurboStream(res.body, window);
|
|
6645
6626
|
return {
|
|
@@ -7139,8 +7120,7 @@ function Scripts(props) {
|
|
|
7139
7120
|
manifest,
|
|
7140
7121
|
serverHandoffString,
|
|
7141
7122
|
isSpaMode,
|
|
7142
|
-
renderMeta
|
|
7143
|
-
future
|
|
7123
|
+
renderMeta
|
|
7144
7124
|
} = useRemixContext();
|
|
7145
7125
|
let {
|
|
7146
7126
|
router,
|
|
@@ -7163,9 +7143,6 @@ function Scripts(props) {
|
|
|
7163
7143
|
let initialScripts = React.useMemo(() => {
|
|
7164
7144
|
var _manifest$hmr;
|
|
7165
7145
|
let streamScript = "window.__remixContext.stream = new ReadableStream({" + "start(controller){" + "window.__remixContext.streamController = controller;" + "}" + "}).pipeThrough(new TextEncoderStream());";
|
|
7166
|
-
if (future.unstable_serverComponents && staticContext != null && staticContext.actionData) {
|
|
7167
|
-
streamScript += "window.__remixContext.streamAction = new ReadableStream({" + "start(controller){" + "window.__remixContext.streamControllerAction = controller;" + "}" + "}).pipeThrough(new TextEncoderStream());";
|
|
7168
|
-
}
|
|
7169
7146
|
let contextScript = staticContext ? "window.__remixContext = " + serverHandoffString + ";" + streamScript : " ";
|
|
7170
7147
|
let routeModulesScript = !isStatic ? " " : ((_manifest$hmr = manifest.hmr) != null && _manifest$hmr.runtime ? "import " + JSON.stringify(manifest.hmr.runtime) + ";" : "") + "import " + JSON.stringify(manifest.url) + ";\n" + matches.map((match, index) => "import * as route" + index + " from " + JSON.stringify(manifest.routes[match.route.id].module) + ";").join("\n") + "\nwindow.__remixRouteModules = {" + matches.map((match, index) => JSON.stringify(match.route.id) + ":route" + index).join(",") + "};\n\nimport(" + JSON.stringify(manifest.entry.module) + ");";
|
|
7171
7148
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("script", _extends({}, props, {
|
|
@@ -9105,7 +9082,7 @@ function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId,
|
|
|
9105
9082
|
// has a loader/clientLoader, but it won't ever be called during the static
|
|
9106
9083
|
// render, so just give it a no-op function so we can render down to the
|
|
9107
9084
|
// proper fallback
|
|
9108
|
-
loader: route.hasLoader || route.hasClientLoader ?
|
|
9085
|
+
loader: route.hasLoader || route.hasClientLoader ? () => null : undefined
|
|
9109
9086
|
// We don't need action/shouldRevalidate on these routes since they're
|
|
9110
9087
|
// for a static render
|
|
9111
9088
|
});
|
|
@@ -9467,50 +9444,14 @@ function createHydratedRouter() {
|
|
|
9467
9444
|
// then only get past here and create the `router` one time
|
|
9468
9445
|
if (!ssrInfo.stateDecodingPromise) {
|
|
9469
9446
|
let stream = ssrInfo.context.stream;
|
|
9470
|
-
let streamAction = ssrInfo.context.streamAction;
|
|
9471
9447
|
!stream ? process.env.NODE_ENV !== "production" ? invariant(false, "No stream found for single fetch decoding") : invariant(false) : void 0;
|
|
9472
9448
|
ssrInfo.context.stream = undefined;
|
|
9473
|
-
|
|
9474
|
-
ssrInfo.
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
let [loaderPayload, actionPayload] = _ref2;
|
|
9480
|
-
let state = {};
|
|
9481
|
-
for (let routeId of Object.keys(ssrInfo.routeModules)) {
|
|
9482
|
-
if ("error" in loaderPayload[routeId]) {
|
|
9483
|
-
state.errors = state.errors || {};
|
|
9484
|
-
state.errors[routeId] = loaderPayload[routeId].error;
|
|
9485
|
-
} else if ("data" in loaderPayload[routeId]) {
|
|
9486
|
-
state.loaderData = state.loaderData || {};
|
|
9487
|
-
state.loaderData[routeId] = loaderPayload[routeId].data;
|
|
9488
|
-
}
|
|
9489
|
-
}
|
|
9490
|
-
if (actionPayload) {
|
|
9491
|
-
// @ts-expect-error - TODO: Fix types and don't get it off the window directly
|
|
9492
|
-
const actionId = window.__remixContext.serverHandoffActionId;
|
|
9493
|
-
if ("error" in actionPayload) {
|
|
9494
|
-
state.errors = state.errors || {};
|
|
9495
|
-
state.errors[actionId] = actionPayload.error;
|
|
9496
|
-
} else if ("data" in actionPayload) {
|
|
9497
|
-
state.actionData = state.actionData || {};
|
|
9498
|
-
state.actionData[actionId] = actionPayload.data;
|
|
9499
|
-
}
|
|
9500
|
-
}
|
|
9501
|
-
ssrInfo.context.state = state;
|
|
9502
|
-
localSsrInfo.stateDecodingPromise.value = true;
|
|
9503
|
-
}).catch(e => {
|
|
9504
|
-
localSsrInfo.stateDecodingPromise.error = e;
|
|
9505
|
-
});
|
|
9506
|
-
} else {
|
|
9507
|
-
ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then(value => {
|
|
9508
|
-
ssrInfo.context.state = value.value;
|
|
9509
|
-
localSsrInfo.stateDecodingPromise.value = true;
|
|
9510
|
-
}).catch(e => {
|
|
9511
|
-
localSsrInfo.stateDecodingPromise.error = e;
|
|
9512
|
-
});
|
|
9513
|
-
}
|
|
9449
|
+
ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then(value => {
|
|
9450
|
+
ssrInfo.context.state = value.value;
|
|
9451
|
+
localSsrInfo.stateDecodingPromise.value = true;
|
|
9452
|
+
}).catch(e => {
|
|
9453
|
+
localSsrInfo.stateDecodingPromise.error = e;
|
|
9454
|
+
});
|
|
9514
9455
|
}
|
|
9515
9456
|
if (ssrInfo.stateDecodingPromise.error) {
|
|
9516
9457
|
throw ssrInfo.stateDecodingPromise.error;
|
|
@@ -9715,18 +9656,11 @@ function RemixServer(_ref) {
|
|
|
9715
9656
|
router: router,
|
|
9716
9657
|
context: context.staticHandlerContext,
|
|
9717
9658
|
hydrate: false
|
|
9718
|
-
}))), context.
|
|
9719
|
-
context: context,
|
|
9720
|
-
identifier: 0,
|
|
9721
|
-
reader: context.serverHandoffStreamAction.getReader(),
|
|
9722
|
-
textDecoder: new TextDecoder(),
|
|
9723
|
-
isAction: true
|
|
9724
|
-
}))) : null, context.serverHandoffStream ? ( /*#__PURE__*/React.createElement(React.Suspense, null, /*#__PURE__*/React.createElement(StreamTransfer, {
|
|
9659
|
+
}))), context.serverHandoffStream ? ( /*#__PURE__*/React.createElement(React.Suspense, null, /*#__PURE__*/React.createElement(StreamTransfer, {
|
|
9725
9660
|
context: context,
|
|
9726
9661
|
identifier: 0,
|
|
9727
9662
|
reader: context.serverHandoffStream.getReader(),
|
|
9728
|
-
textDecoder: new TextDecoder()
|
|
9729
|
-
isAction: false
|
|
9663
|
+
textDecoder: new TextDecoder()
|
|
9730
9664
|
}))) : null);
|
|
9731
9665
|
}
|
|
9732
9666
|
|
|
@@ -9747,8 +9681,7 @@ function createRemixStub(routes, context) {
|
|
|
9747
9681
|
remixContextRef.current = {
|
|
9748
9682
|
future: {
|
|
9749
9683
|
v3_fetcherPersist: (future == null ? void 0 : future.v3_fetcherPersist) === true,
|
|
9750
|
-
v3_relativeSplatPath: (future == null ? void 0 : future.v3_relativeSplatPath) === true
|
|
9751
|
-
unstable_serverComponents: (future == null ? void 0 : future.unstable_serverComponents) === true
|
|
9684
|
+
v3_relativeSplatPath: (future == null ? void 0 : future.v3_relativeSplatPath) === true
|
|
9752
9685
|
},
|
|
9753
9686
|
manifest: {
|
|
9754
9687
|
routes: {},
|