@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.9 → 3.5.0-ultramodern.91
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/cjs/cli/artifacts.js +157 -0
- package/dist/cjs/cli/index.js +8 -79
- package/dist/cjs/cli/tanstackTypes/canonicalRoutes.js +113 -0
- package/dist/cjs/cli/tanstackTypes/shared.js +123 -0
- package/dist/cjs/cli/tanstackTypes/source.js +255 -0
- package/dist/cjs/cli/tanstackTypes.js +4 -350
- package/dist/cjs/runtime/blockingSubscribe.js +57 -0
- package/dist/cjs/runtime/{pluginCore.js → clientBasepath.js} +12 -19
- package/dist/cjs/runtime/clientHydration.js +118 -0
- package/dist/cjs/runtime/dataMutation.js +11 -176
- package/dist/cjs/runtime/formData.js +116 -0
- package/dist/cjs/runtime/loaderBridge.js +7 -11
- package/dist/cjs/runtime/plugin.js +21 -125
- package/dist/cjs/runtime/plugin.node.js +45 -125
- package/dist/cjs/runtime/pluginShared.js +87 -0
- package/dist/cjs/runtime/prefetchLink.js +15 -2
- package/dist/cjs/runtime/register.js +3 -16
- package/dist/cjs/runtime/routeTree/components.js +102 -0
- package/dist/cjs/runtime/routeTree/construction.js +152 -0
- package/dist/cjs/runtime/routeTree/index.js +47 -0
- package/dist/cjs/runtime/routeTree/loaders.js +158 -0
- package/dist/cjs/runtime/routeTree/paths.js +57 -0
- package/dist/cjs/runtime/routeTree/staticData.js +63 -0
- package/dist/cjs/runtime/routeTree/tanstackRoutes.js +57 -0
- package/dist/cjs/runtime/routeTree/types.js +18 -0
- package/dist/cjs/runtime/routeTree.js +7 -320
- package/dist/cjs/runtime/router.js +15 -2
- package/dist/cjs/runtime/rsc/CompositeComponent.js +18 -13
- package/dist/cjs/runtime/rsc/ReplayableStream.js +0 -4
- package/dist/cjs/runtime/rsc/RscNodeRenderer.js +5 -16
- package/dist/cjs/runtime/rsc/client.js +8 -25
- package/dist/cjs/runtime/rsc/flightSerialization.js +132 -0
- package/dist/cjs/runtime/rsc/payloadErrors.js +99 -0
- package/dist/cjs/runtime/rsc/payloadFetch.js +105 -0
- package/dist/cjs/runtime/rsc/payloadRouter.js +21 -142
- package/dist/cjs/runtime/rsc/payloadRoutes.js +94 -0
- package/dist/cjs/runtime/rsc/payloadStorage.js +58 -0
- package/dist/cjs/runtime/rsc/server.js +14 -18
- package/dist/cjs/runtime/rsc/shared.js +68 -0
- package/dist/cjs/runtime/rsc/slotUsageSanitizer.js +1 -0
- package/dist/cjs/runtime/rsc/treeGetter.js +72 -0
- package/dist/cjs/runtime/shared/isAbsoluteUrl.js +47 -0
- package/dist/cjs/runtime/ssrManagedTags.js +103 -0
- package/dist/cjs/runtime/ssrPreload.js +89 -0
- package/dist/cjs/runtime/ssrTypes.js +18 -0
- package/dist/cjs/runtime/state.js +1 -1
- package/dist/cjs/runtime/submitAction.js +161 -0
- package/dist/cjs/runtime/utils.js +49 -86
- package/dist/esm/cli/artifacts.mjs +103 -0
- package/dist/esm/cli/index.mjs +8 -82
- package/dist/esm/cli/tanstackTypes/canonicalRoutes.mjs +75 -0
- package/dist/esm/cli/tanstackTypes/shared.mjs +61 -0
- package/dist/esm/cli/tanstackTypes/source.mjs +207 -0
- package/dist/esm/cli/tanstackTypes.mjs +2 -339
- package/dist/esm/runtime/blockingSubscribe.mjs +19 -0
- package/dist/esm/runtime/clientBasepath.mjs +10 -0
- package/dist/esm/runtime/clientHydration.mjs +71 -0
- package/dist/esm/runtime/dataMutation.mjs +2 -167
- package/dist/esm/runtime/formData.mjs +63 -0
- package/dist/esm/runtime/loaderBridge.mjs +5 -9
- package/dist/esm/runtime/plugin.mjs +14 -118
- package/dist/esm/runtime/plugin.node.mjs +41 -121
- package/dist/esm/runtime/pluginShared.mjs +40 -0
- package/dist/esm/runtime/prefetchLink.mjs +18 -5
- package/dist/esm/runtime/register.mjs +1 -14
- package/dist/esm/runtime/routeTree/components.mjs +55 -0
- package/dist/esm/runtime/routeTree/construction.mjs +111 -0
- package/dist/esm/runtime/routeTree/index.mjs +2 -0
- package/dist/esm/runtime/routeTree/loaders.mjs +117 -0
- package/dist/esm/runtime/routeTree/paths.mjs +16 -0
- package/dist/esm/runtime/routeTree/staticData.mjs +22 -0
- package/dist/esm/runtime/routeTree/tanstackRoutes.mjs +13 -0
- package/dist/esm/runtime/routeTree/types.mjs +0 -0
- package/dist/esm/runtime/routeTree.mjs +1 -318
- package/dist/esm/runtime/router.mjs +16 -2
- package/dist/esm/runtime/rsc/CompositeComponent.mjs +18 -13
- package/dist/esm/runtime/rsc/ReplayableStream.mjs +1 -1
- package/dist/esm/runtime/rsc/RscNodeRenderer.mjs +4 -15
- package/dist/esm/runtime/rsc/client.mjs +6 -26
- package/dist/esm/runtime/rsc/flightSerialization.mjs +88 -0
- package/dist/esm/runtime/rsc/payloadErrors.mjs +49 -0
- package/dist/esm/runtime/rsc/payloadFetch.mjs +55 -0
- package/dist/esm/runtime/rsc/payloadRouter.mjs +12 -133
- package/dist/esm/runtime/rsc/payloadRoutes.mjs +50 -0
- package/dist/esm/runtime/rsc/payloadStorage.mjs +14 -0
- package/dist/esm/runtime/rsc/server.mjs +17 -21
- package/dist/esm/runtime/rsc/shared.mjs +21 -0
- package/dist/esm/runtime/rsc/slotUsageSanitizer.mjs +1 -0
- package/dist/esm/runtime/rsc/treeGetter.mjs +34 -0
- package/dist/esm/runtime/shared/isAbsoluteUrl.mjs +9 -0
- package/dist/esm/runtime/ssrManagedTags.mjs +53 -0
- package/dist/esm/runtime/ssrPreload.mjs +51 -0
- package/dist/esm/runtime/ssrTypes.mjs +0 -0
- package/dist/esm/runtime/state.mjs +1 -1
- package/dist/esm/runtime/submitAction.mjs +120 -0
- package/dist/esm/runtime/utils.mjs +47 -75
- package/dist/esm-node/cli/artifacts.mjs +104 -0
- package/dist/esm-node/cli/index.mjs +8 -82
- package/dist/esm-node/cli/tanstackTypes/canonicalRoutes.mjs +76 -0
- package/dist/esm-node/cli/tanstackTypes/shared.mjs +62 -0
- package/dist/esm-node/cli/tanstackTypes/source.mjs +208 -0
- package/dist/esm-node/cli/tanstackTypes.mjs +2 -339
- package/dist/esm-node/runtime/blockingSubscribe.mjs +20 -0
- package/dist/esm-node/runtime/clientBasepath.mjs +11 -0
- package/dist/esm-node/runtime/clientHydration.mjs +72 -0
- package/dist/esm-node/runtime/dataMutation.mjs +2 -167
- package/dist/esm-node/runtime/formData.mjs +64 -0
- package/dist/esm-node/runtime/loaderBridge.mjs +5 -9
- package/dist/esm-node/runtime/plugin.mjs +14 -118
- package/dist/esm-node/runtime/plugin.node.mjs +41 -121
- package/dist/esm-node/runtime/pluginShared.mjs +41 -0
- package/dist/esm-node/runtime/prefetchLink.mjs +18 -5
- package/dist/esm-node/runtime/register.mjs +1 -14
- package/dist/esm-node/runtime/routeTree/components.mjs +56 -0
- package/dist/esm-node/runtime/routeTree/construction.mjs +112 -0
- package/dist/esm-node/runtime/routeTree/index.mjs +3 -0
- package/dist/esm-node/runtime/routeTree/loaders.mjs +118 -0
- package/dist/esm-node/runtime/routeTree/paths.mjs +17 -0
- package/dist/esm-node/runtime/routeTree/staticData.mjs +23 -0
- package/dist/esm-node/runtime/routeTree/tanstackRoutes.mjs +14 -0
- package/dist/esm-node/runtime/routeTree/types.mjs +1 -0
- package/dist/esm-node/runtime/routeTree.mjs +1 -318
- package/dist/esm-node/runtime/router.mjs +16 -2
- package/dist/esm-node/runtime/rsc/CompositeComponent.mjs +18 -13
- package/dist/esm-node/runtime/rsc/ReplayableStream.mjs +1 -1
- package/dist/esm-node/runtime/rsc/RscNodeRenderer.mjs +4 -15
- package/dist/esm-node/runtime/rsc/client.mjs +6 -26
- package/dist/esm-node/runtime/rsc/flightSerialization.mjs +89 -0
- package/dist/esm-node/runtime/rsc/payloadErrors.mjs +50 -0
- package/dist/esm-node/runtime/rsc/payloadFetch.mjs +56 -0
- package/dist/esm-node/runtime/rsc/payloadRouter.mjs +12 -133
- package/dist/esm-node/runtime/rsc/payloadRoutes.mjs +51 -0
- package/dist/esm-node/runtime/rsc/payloadStorage.mjs +15 -0
- package/dist/esm-node/runtime/rsc/server.mjs +17 -21
- package/dist/esm-node/runtime/rsc/shared.mjs +22 -0
- package/dist/esm-node/runtime/rsc/slotUsageSanitizer.mjs +1 -0
- package/dist/esm-node/runtime/rsc/treeGetter.mjs +35 -0
- package/dist/esm-node/runtime/shared/isAbsoluteUrl.mjs +10 -0
- package/dist/esm-node/runtime/ssrManagedTags.mjs +54 -0
- package/dist/esm-node/runtime/ssrPreload.mjs +52 -0
- package/dist/esm-node/runtime/ssrTypes.mjs +1 -0
- package/dist/esm-node/runtime/state.mjs +1 -1
- package/dist/esm-node/runtime/submitAction.mjs +121 -0
- package/dist/esm-node/runtime/utils.mjs +47 -75
- package/dist/types/cli/artifacts.d.ts +33 -0
- package/dist/types/cli/index.d.ts +2 -22
- package/dist/types/cli/tanstackTypes/canonicalRoutes.d.ts +22 -0
- package/dist/types/cli/tanstackTypes/shared.d.ts +20 -0
- package/dist/types/cli/tanstackTypes/source.d.ts +12 -0
- package/dist/types/cli/tanstackTypes.d.ts +3 -31
- package/dist/types/runtime/blockingSubscribe.d.ts +1 -0
- package/dist/types/runtime/clientBasepath.d.ts +1 -0
- package/dist/types/runtime/clientHydration.d.ts +10 -0
- package/dist/types/runtime/dataMutation.d.ts +3 -12
- package/dist/types/runtime/formData.d.ts +24 -0
- package/dist/types/runtime/loaderBridge.d.ts +2 -1
- package/dist/types/runtime/plugin.d.ts +1 -1
- package/dist/types/runtime/plugin.node.d.ts +1 -1
- package/dist/types/runtime/pluginShared.d.ts +38 -0
- package/dist/types/runtime/register.d.ts +10 -9
- package/dist/types/runtime/routeTree/components.d.ts +7 -0
- package/dist/types/runtime/routeTree/construction.d.ts +5 -0
- package/dist/types/runtime/routeTree/index.d.ts +2 -0
- package/dist/types/runtime/routeTree/loaders.d.ts +4 -0
- package/dist/types/runtime/routeTree/paths.d.ts +3 -0
- package/dist/types/runtime/routeTree/staticData.d.ts +19 -0
- package/dist/types/runtime/routeTree/tanstackRoutes.d.ts +4 -0
- package/dist/types/runtime/routeTree/types.d.ts +76 -0
- package/dist/types/runtime/routeTree.d.ts +1 -9
- package/dist/types/runtime/router.d.ts +6 -7
- package/dist/types/runtime/rsc/CompositeComponent.d.ts +1 -2
- package/dist/types/runtime/rsc/ReplayableStream.d.ts +3 -2
- package/dist/types/runtime/rsc/RscNodeRenderer.d.ts +2 -3
- package/dist/types/runtime/rsc/SlotContext.d.ts +2 -1
- package/dist/types/runtime/rsc/client.d.ts +2 -0
- package/dist/types/runtime/rsc/flightSerialization.d.ts +3 -0
- package/dist/types/runtime/rsc/payloadErrors.d.ts +6 -0
- package/dist/types/runtime/rsc/payloadFetch.d.ts +8 -0
- package/dist/types/runtime/rsc/payloadRouter.d.ts +2 -10
- package/dist/types/runtime/rsc/payloadRoutes.d.ts +40 -0
- package/dist/types/runtime/rsc/payloadStorage.d.ts +5 -0
- package/dist/types/runtime/rsc/shared.d.ts +18 -0
- package/dist/types/runtime/rsc/treeGetter.d.ts +1 -0
- package/dist/types/runtime/shared/isAbsoluteUrl.d.ts +1 -0
- package/dist/types/runtime/ssrManagedTags.d.ts +7 -0
- package/dist/types/runtime/ssrPreload.d.ts +2 -0
- package/dist/types/runtime/ssrTypes.d.ts +44 -0
- package/dist/types/runtime/state.d.ts +1 -1
- package/dist/types/runtime/submitAction.d.ts +14 -0
- package/dist/types/runtime/types.d.ts +4 -10
- package/dist/types/runtime/utils.d.ts +4 -24
- package/package.json +37 -17
- package/rstest.config.mts +23 -0
- package/src/cli/artifacts.ts +255 -0
- package/src/cli/index.ts +7 -185
- package/src/cli/tanstackTypes/canonicalRoutes.ts +157 -0
- package/src/cli/tanstackTypes/shared.ts +113 -0
- package/src/cli/tanstackTypes/source.ts +414 -0
- package/src/cli/tanstackTypes.ts +4 -647
- package/src/runtime/blockingSubscribe.ts +48 -0
- package/src/runtime/clientBasepath.ts +12 -0
- package/src/runtime/clientHydration.ts +149 -0
- package/src/runtime/dataMutation.tsx +9 -306
- package/src/runtime/formData.ts +153 -0
- package/src/runtime/loaderBridge.ts +11 -12
- package/src/runtime/plugin.node.tsx +76 -291
- package/src/runtime/plugin.tsx +21 -257
- package/src/runtime/pluginShared.ts +112 -0
- package/src/runtime/prefetchLink.tsx +78 -15
- package/src/runtime/register.ts +10 -42
- package/src/runtime/routeTree/components.ts +130 -0
- package/src/runtime/routeTree/construction.ts +238 -0
- package/src/runtime/routeTree/index.ts +7 -0
- package/src/runtime/routeTree/loaders.ts +232 -0
- package/src/runtime/routeTree/paths.ts +36 -0
- package/src/runtime/routeTree/staticData.ts +66 -0
- package/src/runtime/routeTree/tanstackRoutes.ts +36 -0
- package/src/runtime/routeTree/types.ts +87 -0
- package/src/runtime/routeTree.ts +5 -750
- package/src/runtime/router.ts +35 -7
- package/src/runtime/rsc/CompositeComponent.tsx +29 -20
- package/src/runtime/rsc/ReplayableStream.ts +2 -2
- package/src/runtime/rsc/RscNodeRenderer.tsx +9 -27
- package/src/runtime/rsc/SlotContext.tsx +1 -1
- package/src/runtime/rsc/client.tsx +12 -40
- package/src/runtime/rsc/flightSerialization.ts +158 -0
- package/src/runtime/rsc/payloadErrors.ts +73 -0
- package/src/runtime/rsc/payloadFetch.ts +92 -0
- package/src/runtime/rsc/payloadRouter.ts +29 -234
- package/src/runtime/rsc/payloadRoutes.ts +122 -0
- package/src/runtime/rsc/payloadStorage.ts +35 -0
- package/src/runtime/rsc/server.tsx +20 -29
- package/src/runtime/rsc/shared.ts +70 -0
- package/src/runtime/rsc/slotUsageSanitizer.ts +4 -0
- package/src/runtime/rsc/treeGetter.tsx +52 -0
- package/src/runtime/shared/isAbsoluteUrl.ts +8 -0
- package/src/runtime/ssrManagedTags.ts +107 -0
- package/src/runtime/ssrPreload.ts +125 -0
- package/src/runtime/ssrTypes.ts +51 -0
- package/src/runtime/state.ts +9 -3
- package/src/runtime/submitAction.ts +201 -0
- package/src/runtime/types.ts +4 -18
- package/src/runtime/utils.tsx +76 -110
- package/src/types/react-server-dom-rspack.d.ts +56 -0
- package/tests/castRatchet.test.ts +85 -0
- package/tests/realm-isolation.test.ts +114 -0
- package/tests/router/cli.test.ts +7 -0
- package/tests/router/clientHydration.test.tsx +61 -0
- package/tests/router/dataMutation.test.tsx +59 -0
- package/tests/router/fixtures/legacyRuntimeRouter.ts +10 -0
- package/tests/router/fixtures/router-gen.golden.txt +71 -0
- package/tests/router/fixtures/router-gen.oxlint.json +5 -0
- package/tests/router/flightSerialization.roundtrip.test.tsx +137 -0
- package/tests/router/generateRouteArtifacts.test.ts +106 -0
- package/tests/router/hooks.test.ts +14 -0
- package/tests/router/loaderBridge.test.ts +21 -0
- package/tests/router/prefetchLink.test.tsx +106 -59
- package/tests/router/prefetchLinkPreload.test.tsx +85 -0
- package/tests/router/register.test.ts +1 -39
- package/tests/router/routeTree.test.ts +51 -11
- package/tests/router/routerCompatibility.test.ts +245 -0
- package/tests/router/rsc.test.tsx +189 -0
- package/tests/router/rscPayloadRouterMatrix.test.ts +197 -0
- package/tests/router/slotUsageSanitizer.test.ts +23 -0
- package/tests/router/ssrPreload.test.ts +30 -0
- package/tests/router/tanstackTypes.test.ts +298 -1
- package/dist/esm/runtime/pluginCore.mjs +0 -14
- package/dist/esm-node/runtime/pluginCore.mjs +0 -15
- package/dist/types/runtime/pluginCore.d.ts +0 -21
- package/src/runtime/pluginCore.ts +0 -48
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
isSerializedNotFound: ()=>isSerializedNotFound,
|
|
32
|
+
serializePayloadError: ()=>serializePayloadError,
|
|
33
|
+
shouldRedactServerError: ()=>shouldRedactServerError,
|
|
34
|
+
toRouteErrors: ()=>toRouteErrors,
|
|
35
|
+
toRouteLoaderData: ()=>toRouteLoaderData
|
|
36
|
+
});
|
|
37
|
+
const router_namespaceObject = require("@modern-js/runtime-utils/router");
|
|
38
|
+
function shouldRedactServerError(status = 500) {
|
|
39
|
+
return status >= 500 && 'development' !== process.env.NODE_ENV && 'test' !== process.env.NODE_ENV;
|
|
40
|
+
}
|
|
41
|
+
function serializePayloadError(error) {
|
|
42
|
+
if ((0, router_namespaceObject.isRouteErrorResponse)(error)) {
|
|
43
|
+
if (shouldRedactServerError(error.status)) return {
|
|
44
|
+
status: error.status,
|
|
45
|
+
statusText: 'Internal Server Error',
|
|
46
|
+
data: 'Unexpected Server Error',
|
|
47
|
+
__type: 'RouteErrorResponse'
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
...error,
|
|
51
|
+
__type: 'RouteErrorResponse'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
if (shouldRedactServerError()) return {
|
|
56
|
+
message: 'Unexpected Server Error',
|
|
57
|
+
stack: void 0,
|
|
58
|
+
__type: 'Error'
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
message: error.message,
|
|
62
|
+
stack: error.stack,
|
|
63
|
+
__type: 'Error',
|
|
64
|
+
...'Error' !== error.name ? {
|
|
65
|
+
__subType: error.name
|
|
66
|
+
} : {}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (shouldRedactServerError()) return {
|
|
70
|
+
message: 'Unexpected Server Error',
|
|
71
|
+
stack: void 0,
|
|
72
|
+
__type: 'Error'
|
|
73
|
+
};
|
|
74
|
+
return error;
|
|
75
|
+
}
|
|
76
|
+
function isSerializedNotFound(value) {
|
|
77
|
+
return Boolean(value) && 'object' == typeof value && true === value.isNotFound;
|
|
78
|
+
}
|
|
79
|
+
function toRouteErrors(payload) {
|
|
80
|
+
return payload.errors && 'object' == typeof payload.errors ? payload.errors : {};
|
|
81
|
+
}
|
|
82
|
+
function toRouteLoaderData(payload) {
|
|
83
|
+
return payload.loaderData && 'object' == typeof payload.loaderData ? payload.loaderData : {};
|
|
84
|
+
}
|
|
85
|
+
exports.isSerializedNotFound = __webpack_exports__.isSerializedNotFound;
|
|
86
|
+
exports.serializePayloadError = __webpack_exports__.serializePayloadError;
|
|
87
|
+
exports.shouldRedactServerError = __webpack_exports__.shouldRedactServerError;
|
|
88
|
+
exports.toRouteErrors = __webpack_exports__.toRouteErrors;
|
|
89
|
+
exports.toRouteLoaderData = __webpack_exports__.toRouteLoaderData;
|
|
90
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
91
|
+
"isSerializedNotFound",
|
|
92
|
+
"serializePayloadError",
|
|
93
|
+
"shouldRedactServerError",
|
|
94
|
+
"toRouteErrors",
|
|
95
|
+
"toRouteLoaderData"
|
|
96
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
97
|
+
Object.defineProperty(exports, '__esModule', {
|
|
98
|
+
value: true
|
|
99
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
__setTanstackRscPayloadDecoderForTests: ()=>__setTanstackRscPayloadDecoderForTests,
|
|
32
|
+
createPayloadFetchKey: ()=>createPayloadFetchKey,
|
|
33
|
+
fetchTanstackRscPayload: ()=>fetchTanstackRscPayload,
|
|
34
|
+
isAbsoluteUrl: ()=>isAbsoluteUrl_js_namespaceObject.isAbsoluteUrl,
|
|
35
|
+
payloadFetchCache: ()=>payloadFetchCache
|
|
36
|
+
});
|
|
37
|
+
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
38
|
+
const isAbsoluteUrl_js_namespaceObject = require("../shared/isAbsoluteUrl.js");
|
|
39
|
+
const external_flightSerialization_js_namespaceObject = require("./flightSerialization.js");
|
|
40
|
+
const payloadFetchCache = new Map();
|
|
41
|
+
let payloadDecoder;
|
|
42
|
+
async function decodePayload(stream) {
|
|
43
|
+
if (payloadDecoder) return (0, external_flightSerialization_js_namespaceObject.reviveTanstackRscFlightValues)(await payloadDecoder(stream));
|
|
44
|
+
const runtime = await import("@modern-js/runtime/rsc/client");
|
|
45
|
+
return (0, external_flightSerialization_js_namespaceObject.reviveTanstackRscFlightValues)(await runtime.createFromReadableStream(stream));
|
|
46
|
+
}
|
|
47
|
+
function isServerPayload(value) {
|
|
48
|
+
return Boolean(value) && 'object' == typeof value && 'render' === value.type && Array.isArray(value.routes);
|
|
49
|
+
}
|
|
50
|
+
function createPayloadFetchKey(request) {
|
|
51
|
+
return JSON.stringify([
|
|
52
|
+
request.url,
|
|
53
|
+
request.method,
|
|
54
|
+
[
|
|
55
|
+
...request.headers.entries()
|
|
56
|
+
].sort(([left], [right])=>left.localeCompare(right))
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
async function fetchTanstackRscPayload(request) {
|
|
60
|
+
const headers = new Headers(request.headers);
|
|
61
|
+
headers.set('x-rsc-tree', 'true');
|
|
62
|
+
const response = await fetch(request.url, {
|
|
63
|
+
credentials: 'same-origin',
|
|
64
|
+
headers,
|
|
65
|
+
method: 'GET',
|
|
66
|
+
signal: request.signal
|
|
67
|
+
});
|
|
68
|
+
const redirectLocation = response.headers.get('X-Modernjs-Redirect');
|
|
69
|
+
if (redirectLocation) {
|
|
70
|
+
if ((0, isAbsoluteUrl_js_namespaceObject.isAbsoluteUrl)(redirectLocation)) throw (0, react_router_namespaceObject.redirect)({
|
|
71
|
+
headers: response.headers,
|
|
72
|
+
href: redirectLocation,
|
|
73
|
+
statusCode: response.status
|
|
74
|
+
});
|
|
75
|
+
throw (0, react_router_namespaceObject.redirect)({
|
|
76
|
+
headers: response.headers,
|
|
77
|
+
statusCode: response.status,
|
|
78
|
+
to: redirectLocation || '/'
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (404 === response.status && !response.body) throw (0, react_router_namespaceObject.notFound)();
|
|
82
|
+
if (!response.body) throw new Error('TanStack RSC payload response body is null.');
|
|
83
|
+
const payload = await decodePayload(response.body);
|
|
84
|
+
if (!isServerPayload(payload)) throw new Error('Unexpected TanStack RSC payload type.');
|
|
85
|
+
return payload;
|
|
86
|
+
}
|
|
87
|
+
function __setTanstackRscPayloadDecoderForTests(decoder) {
|
|
88
|
+
payloadDecoder = decoder;
|
|
89
|
+
payloadFetchCache.clear();
|
|
90
|
+
}
|
|
91
|
+
exports.__setTanstackRscPayloadDecoderForTests = __webpack_exports__.__setTanstackRscPayloadDecoderForTests;
|
|
92
|
+
exports.createPayloadFetchKey = __webpack_exports__.createPayloadFetchKey;
|
|
93
|
+
exports.fetchTanstackRscPayload = __webpack_exports__.fetchTanstackRscPayload;
|
|
94
|
+
exports.isAbsoluteUrl = __webpack_exports__.isAbsoluteUrl;
|
|
95
|
+
exports.payloadFetchCache = __webpack_exports__.payloadFetchCache;
|
|
96
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
97
|
+
"__setTanstackRscPayloadDecoderForTests",
|
|
98
|
+
"createPayloadFetchKey",
|
|
99
|
+
"fetchTanstackRscPayload",
|
|
100
|
+
"isAbsoluteUrl",
|
|
101
|
+
"payloadFetchCache"
|
|
102
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
103
|
+
Object.defineProperty(exports, '__esModule', {
|
|
104
|
+
value: true
|
|
105
|
+
});
|
|
@@ -28,97 +28,29 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
__setTanstackRscPayloadDecoderForTests: ()=>__setTanstackRscPayloadDecoderForTests,
|
|
31
|
+
__setTanstackRscPayloadDecoderForTests: ()=>external_payloadFetch_js_namespaceObject.__setTanstackRscPayloadDecoderForTests,
|
|
32
32
|
createTanstackRscServerPayload: ()=>createTanstackRscServerPayload,
|
|
33
33
|
handleTanstackRscRedirect: ()=>handleTanstackRscRedirect,
|
|
34
34
|
isTanstackRscPayloadNavigationEnabled: ()=>isTanstackRscPayloadNavigationEnabled,
|
|
35
35
|
loadTanstackRscPayload: ()=>loadTanstackRscPayload,
|
|
36
36
|
loadTanstackRscRouteData: ()=>loadTanstackRscRouteData
|
|
37
37
|
});
|
|
38
|
-
const router_namespaceObject = require("@modern-js/runtime-utils/router");
|
|
39
38
|
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return 'string' == typeof routeId ? routeId : void 0;
|
|
45
|
-
}
|
|
46
|
-
function getRouteStaticData(match) {
|
|
47
|
-
return match.route?.options?.staticData || {};
|
|
48
|
-
}
|
|
49
|
-
function getRouteParentId(match) {
|
|
50
|
-
const parentId = match.route?.parentRoute?.id;
|
|
51
|
-
return 'string' == typeof parentId ? parentId : void 0;
|
|
52
|
-
}
|
|
53
|
-
function toRoutePath(match) {
|
|
54
|
-
const path = match.route?.options?.path;
|
|
55
|
-
return 'string' == typeof path ? path : void 0;
|
|
56
|
-
}
|
|
57
|
-
function toPayloadRoute(match) {
|
|
58
|
-
const routeId = getRouteId(match);
|
|
59
|
-
if (!routeId) return;
|
|
60
|
-
const staticData = getRouteStaticData(match);
|
|
61
|
-
const params = match.params && 'object' == typeof match.params ? match.params : {};
|
|
62
|
-
const pathname = 'string' == typeof match.pathname ? match.pathname : '';
|
|
63
|
-
return {
|
|
64
|
-
handle: staticData.modernRouteHandle,
|
|
65
|
-
hasAction: Boolean(staticData.modernRouteHasAction || staticData.modernRouteAction),
|
|
66
|
-
hasErrorBoundary: false,
|
|
67
|
-
hasLoader: Boolean(staticData.modernRouteHasLoader),
|
|
68
|
-
hasClientLoader: Boolean(staticData.modernRouteHasClientLoader),
|
|
69
|
-
id: routeId,
|
|
70
|
-
index: Boolean(match.route?.options?.index) || void 0,
|
|
71
|
-
params,
|
|
72
|
-
parentId: getRouteParentId(match),
|
|
73
|
-
path: toRoutePath(match),
|
|
74
|
-
pathname,
|
|
75
|
-
pathnameBase: 'string' == typeof match.pathnameBase ? match.pathnameBase : pathname
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function shouldRedactServerError(status = 500) {
|
|
79
|
-
return status >= 500 && 'development' !== process.env.NODE_ENV && 'test' !== process.env.NODE_ENV;
|
|
80
|
-
}
|
|
81
|
-
function serializePayloadError(error) {
|
|
82
|
-
if ((0, router_namespaceObject.isRouteErrorResponse)(error)) {
|
|
83
|
-
if (shouldRedactServerError(error.status)) return {
|
|
84
|
-
status: error.status,
|
|
85
|
-
statusText: 'Internal Server Error',
|
|
86
|
-
data: 'Unexpected Server Error',
|
|
87
|
-
__type: 'RouteErrorResponse'
|
|
88
|
-
};
|
|
89
|
-
return {
|
|
90
|
-
...error,
|
|
91
|
-
__type: 'RouteErrorResponse'
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
if (error instanceof Error) {
|
|
95
|
-
if (shouldRedactServerError()) return {
|
|
96
|
-
message: 'Unexpected Server Error',
|
|
97
|
-
stack: void 0,
|
|
98
|
-
__type: 'Error'
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
message: error.message,
|
|
102
|
-
stack: error.stack,
|
|
103
|
-
__type: 'Error',
|
|
104
|
-
...'Error' !== error.name ? {
|
|
105
|
-
__subType: error.name
|
|
106
|
-
} : {}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
return error;
|
|
110
|
-
}
|
|
39
|
+
const external_flightSerialization_js_namespaceObject = require("./flightSerialization.js");
|
|
40
|
+
const external_payloadErrors_js_namespaceObject = require("./payloadErrors.js");
|
|
41
|
+
const external_payloadFetch_js_namespaceObject = require("./payloadFetch.js");
|
|
42
|
+
const external_payloadRoutes_js_namespaceObject = require("./payloadRoutes.js");
|
|
111
43
|
function createTanstackRscServerPayload(router, options = {}) {
|
|
112
44
|
const matches = Array.isArray(router.state?.matches) ? router.state.matches : [];
|
|
113
45
|
const routes = [];
|
|
114
46
|
const loaderData = {};
|
|
115
47
|
const errors = {};
|
|
116
48
|
for (const match of matches){
|
|
117
|
-
const payloadRoute = toPayloadRoute(match);
|
|
49
|
+
const payloadRoute = (0, external_payloadRoutes_js_namespaceObject.toPayloadRoute)(match);
|
|
118
50
|
if (payloadRoute) {
|
|
119
51
|
routes.push(payloadRoute);
|
|
120
|
-
if ('loaderData' in match && void 0 !== match.loaderData && !(options.omitClientLoaderData && payloadRoute.hasClientLoader)) loaderData[payloadRoute.id] = match.loaderData;
|
|
121
|
-
if (void 0 !== match.error) errors[payloadRoute.id] = serializePayloadError(match.error);
|
|
52
|
+
if ('loaderData' in match && void 0 !== match.loaderData && !(options.omitClientLoaderData && payloadRoute.hasClientLoader)) loaderData[payloadRoute.id] = (0, external_flightSerialization_js_namespaceObject.serializeTanstackRscFlightValues)(match.loaderData);
|
|
53
|
+
if (void 0 !== match.error) errors[payloadRoute.id] = (0, external_payloadErrors_js_namespaceObject.serializePayloadError)(match.error);
|
|
122
54
|
}
|
|
123
55
|
}
|
|
124
56
|
return {
|
|
@@ -126,14 +58,17 @@ function createTanstackRscServerPayload(router, options = {}) {
|
|
|
126
58
|
actionData: null,
|
|
127
59
|
errors: Object.keys(errors).length > 0 ? errors : null,
|
|
128
60
|
loaderData,
|
|
129
|
-
location: router.state?.location,
|
|
61
|
+
location: (0, external_payloadRoutes_js_namespaceObject.toPlainLocation)(router.state?.location),
|
|
130
62
|
routes
|
|
131
63
|
};
|
|
132
64
|
}
|
|
133
65
|
function handleTanstackRscRedirect(headers, basename, status) {
|
|
134
66
|
const newHeaders = new Headers(headers);
|
|
135
67
|
let redirectUrl = headers.get('Location') || '/';
|
|
136
|
-
if ('/' !== basename)
|
|
68
|
+
if ('/' !== basename) {
|
|
69
|
+
if (redirectUrl === basename) redirectUrl = '/';
|
|
70
|
+
else if (redirectUrl.startsWith(`${basename}/`)) redirectUrl = redirectUrl.slice(basename.length);
|
|
71
|
+
}
|
|
137
72
|
newHeaders.set('X-Modernjs-Redirect', redirectUrl);
|
|
138
73
|
newHeaders.set('X-Modernjs-BaseUrl', basename);
|
|
139
74
|
newHeaders.delete('Location');
|
|
@@ -145,91 +80,35 @@ function handleTanstackRscRedirect(headers, basename, status) {
|
|
|
145
80
|
function isTanstackRscPayloadNavigationEnabled() {
|
|
146
81
|
return "u" > typeof window;
|
|
147
82
|
}
|
|
148
|
-
async function decodePayload(stream) {
|
|
149
|
-
if (payloadDecoder) return payloadDecoder(stream);
|
|
150
|
-
const runtime = await import("@modern-js/runtime/rsc/client");
|
|
151
|
-
return runtime.createFromReadableStream(stream);
|
|
152
|
-
}
|
|
153
|
-
function isServerPayload(value) {
|
|
154
|
-
return Boolean(value) && 'object' == typeof value && 'render' === value.type && Array.isArray(value.routes);
|
|
155
|
-
}
|
|
156
|
-
function createPayloadFetchKey(request) {
|
|
157
|
-
return request.url;
|
|
158
|
-
}
|
|
159
|
-
function isAbsoluteUrl(value) {
|
|
160
|
-
try {
|
|
161
|
-
new URL(value);
|
|
162
|
-
return true;
|
|
163
|
-
} catch {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
async function fetchTanstackRscPayload(request) {
|
|
168
|
-
const headers = new Headers(request.headers);
|
|
169
|
-
headers.set('x-rsc-tree', 'true');
|
|
170
|
-
const response = await fetch(request.url, {
|
|
171
|
-
credentials: 'same-origin',
|
|
172
|
-
headers,
|
|
173
|
-
method: 'GET',
|
|
174
|
-
signal: request.signal
|
|
175
|
-
});
|
|
176
|
-
const redirectLocation = response.headers.get('X-Modernjs-Redirect');
|
|
177
|
-
if (redirectLocation) {
|
|
178
|
-
if (isAbsoluteUrl(redirectLocation)) throw (0, react_router_namespaceObject.redirect)({
|
|
179
|
-
href: redirectLocation
|
|
180
|
-
});
|
|
181
|
-
throw (0, react_router_namespaceObject.redirect)({
|
|
182
|
-
to: redirectLocation || '/'
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
if (404 === response.status && !response.body) throw (0, react_router_namespaceObject.notFound)();
|
|
186
|
-
if (!response.body) throw new Error('TanStack RSC payload response body is null.');
|
|
187
|
-
const payload = await decodePayload(response.body);
|
|
188
|
-
if (!isServerPayload(payload)) throw new Error('Unexpected TanStack RSC payload type.');
|
|
189
|
-
return payload;
|
|
190
|
-
}
|
|
191
83
|
function loadTanstackRscPayload(request) {
|
|
192
|
-
const key = createPayloadFetchKey(request);
|
|
193
|
-
let payloadPromise = payloadFetchCache.get(key);
|
|
84
|
+
const key = (0, external_payloadFetch_js_namespaceObject.createPayloadFetchKey)(request);
|
|
85
|
+
let payloadPromise = external_payloadFetch_js_namespaceObject.payloadFetchCache.get(key);
|
|
194
86
|
if (!payloadPromise) {
|
|
195
|
-
payloadPromise = fetchTanstackRscPayload(request).finally(()=>{
|
|
196
|
-
payloadFetchCache
|
|
87
|
+
payloadPromise = (0, external_payloadFetch_js_namespaceObject.fetchTanstackRscPayload)(request).finally(()=>{
|
|
88
|
+
external_payloadFetch_js_namespaceObject.payloadFetchCache["delete"](key);
|
|
197
89
|
});
|
|
198
|
-
payloadFetchCache.set(key, payloadPromise);
|
|
90
|
+
external_payloadFetch_js_namespaceObject.payloadFetchCache.set(key, payloadPromise);
|
|
199
91
|
}
|
|
200
92
|
return payloadPromise;
|
|
201
93
|
}
|
|
202
|
-
function isSerializedNotFound(value) {
|
|
203
|
-
return Boolean(value) && 'object' == typeof value && true === value.isNotFound;
|
|
204
|
-
}
|
|
205
|
-
function toRouteErrors(payload) {
|
|
206
|
-
return payload.errors && 'object' == typeof payload.errors ? payload.errors : {};
|
|
207
|
-
}
|
|
208
|
-
function toRouteLoaderData(payload) {
|
|
209
|
-
return payload.loaderData && 'object' == typeof payload.loaderData ? payload.loaderData : {};
|
|
210
|
-
}
|
|
211
94
|
async function loadTanstackRscRouteData({ hasClientLoader, loadClientData, request, routeId }) {
|
|
212
95
|
if (hasClientLoader) return loadClientData();
|
|
213
96
|
if (!routeId) return loadClientData();
|
|
214
97
|
const payload = await loadTanstackRscPayload(request);
|
|
215
|
-
const errors = toRouteErrors(payload);
|
|
98
|
+
const errors = (0, external_payloadErrors_js_namespaceObject.toRouteErrors)(payload);
|
|
216
99
|
const routeError = errors[routeId];
|
|
217
100
|
if (void 0 !== routeError) {
|
|
218
|
-
if (isSerializedNotFound(routeError)) throw (0, react_router_namespaceObject.notFound)({
|
|
101
|
+
if ((0, external_payloadErrors_js_namespaceObject.isSerializedNotFound)(routeError)) throw (0, react_router_namespaceObject.notFound)({
|
|
219
102
|
...routeError,
|
|
220
103
|
routeId
|
|
221
104
|
});
|
|
222
105
|
throw routeError;
|
|
223
106
|
}
|
|
224
|
-
const loaderData = toRouteLoaderData(payload);
|
|
107
|
+
const loaderData = (0, external_payloadErrors_js_namespaceObject.toRouteLoaderData)(payload);
|
|
225
108
|
if (routeId in loaderData) return loaderData[routeId];
|
|
226
109
|
const payloadRoute = payload.routes.find((route)=>route.id === routeId);
|
|
227
110
|
if (payloadRoute && payloadRoute.hasClientLoader) return loadClientData();
|
|
228
111
|
}
|
|
229
|
-
function __setTanstackRscPayloadDecoderForTests(decoder) {
|
|
230
|
-
payloadDecoder = decoder;
|
|
231
|
-
payloadFetchCache.clear();
|
|
232
|
-
}
|
|
233
112
|
exports.__setTanstackRscPayloadDecoderForTests = __webpack_exports__.__setTanstackRscPayloadDecoderForTests;
|
|
234
113
|
exports.createTanstackRscServerPayload = __webpack_exports__.createTanstackRscServerPayload;
|
|
235
114
|
exports.handleTanstackRscRedirect = __webpack_exports__.handleTanstackRscRedirect;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
function toPlainRecord(value) {
|
|
31
|
+
if (!value || 'object' != typeof value) return {};
|
|
32
|
+
return Object.fromEntries(Object.entries(value));
|
|
33
|
+
}
|
|
34
|
+
function toPlainLocation(location) {
|
|
35
|
+
if (!location || 'object' != typeof location) return location;
|
|
36
|
+
const plainLocation = toPlainRecord(location);
|
|
37
|
+
for (const key of [
|
|
38
|
+
'search',
|
|
39
|
+
'state'
|
|
40
|
+
])if (plainLocation[key] && 'object' == typeof plainLocation[key] && !Array.isArray(plainLocation[key])) plainLocation[key] = toPlainRecord(plainLocation[key]);
|
|
41
|
+
return plainLocation;
|
|
42
|
+
}
|
|
43
|
+
function getRouteId(match) {
|
|
44
|
+
const routeId = match.routeId ?? match.route?.id ?? match.id;
|
|
45
|
+
return 'string' == typeof routeId ? routeId : void 0;
|
|
46
|
+
}
|
|
47
|
+
function getRouteStaticData(match) {
|
|
48
|
+
return match.route?.options?.staticData || {};
|
|
49
|
+
}
|
|
50
|
+
function getRouteParentId(match) {
|
|
51
|
+
const parentId = match.route?.parentRoute?.id;
|
|
52
|
+
return 'string' == typeof parentId ? parentId : void 0;
|
|
53
|
+
}
|
|
54
|
+
function toRoutePath(match) {
|
|
55
|
+
const path = match.route?.options?.path;
|
|
56
|
+
return 'string' == typeof path ? path : void 0;
|
|
57
|
+
}
|
|
58
|
+
function toPayloadRoute(match) {
|
|
59
|
+
const routeId = getRouteId(match);
|
|
60
|
+
if (!routeId) return;
|
|
61
|
+
const staticData = getRouteStaticData(match);
|
|
62
|
+
const params = match.params && 'object' == typeof match.params ? toPlainRecord(match.params) : {};
|
|
63
|
+
const pathname = 'string' == typeof match.pathname ? match.pathname : '';
|
|
64
|
+
return {
|
|
65
|
+
handle: staticData.modernRouteHandle,
|
|
66
|
+
hasAction: Boolean(staticData.modernRouteHasAction || staticData.modernRouteAction),
|
|
67
|
+
hasErrorBoundary: false,
|
|
68
|
+
hasLoader: Boolean(staticData.modernRouteHasLoader),
|
|
69
|
+
hasClientLoader: Boolean(staticData.modernRouteHasClientLoader),
|
|
70
|
+
id: routeId,
|
|
71
|
+
index: Boolean(match.route?.options?.index) || void 0,
|
|
72
|
+
params,
|
|
73
|
+
parentId: getRouteParentId(match),
|
|
74
|
+
path: toRoutePath(match),
|
|
75
|
+
pathname,
|
|
76
|
+
pathnameBase: 'string' == typeof match.pathnameBase ? match.pathnameBase : pathname
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
80
|
+
getRouteId: ()=>getRouteId,
|
|
81
|
+
toPayloadRoute: ()=>toPayloadRoute,
|
|
82
|
+
toPlainLocation: ()=>toPlainLocation
|
|
83
|
+
});
|
|
84
|
+
exports.getRouteId = __webpack_exports__.getRouteId;
|
|
85
|
+
exports.toPayloadRoute = __webpack_exports__.toPayloadRoute;
|
|
86
|
+
exports.toPlainLocation = __webpack_exports__.toPlainLocation;
|
|
87
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
88
|
+
"getRouteId",
|
|
89
|
+
"toPayloadRoute",
|
|
90
|
+
"toPlainLocation"
|
|
91
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
92
|
+
Object.defineProperty(exports, '__esModule', {
|
|
93
|
+
value: true
|
|
94
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
getTanstackRscRouter: ()=>getTanstackRscRouter,
|
|
32
|
+
setTanstackRscRouter: ()=>setTanstackRscRouter,
|
|
33
|
+
setTanstackRscServerPayload: ()=>setTanstackRscServerPayload
|
|
34
|
+
});
|
|
35
|
+
const node_namespaceObject = require("@modern-js/runtime-utils/node");
|
|
36
|
+
const setTanstackRscServerPayload = (payload)=>{
|
|
37
|
+
const storageContext = node_namespaceObject.storage.useContext?.();
|
|
38
|
+
if (storageContext) storageContext.serverPayload = payload;
|
|
39
|
+
};
|
|
40
|
+
const setTanstackRscRouter = (router)=>{
|
|
41
|
+
const storageContext = node_namespaceObject.storage.useContext?.();
|
|
42
|
+
if (storageContext) storageContext.tanstackRscRouter = router;
|
|
43
|
+
};
|
|
44
|
+
const getTanstackRscRouter = ()=>{
|
|
45
|
+
const storageContext = node_namespaceObject.storage.useContext?.();
|
|
46
|
+
return storageContext?.tanstackRscRouter;
|
|
47
|
+
};
|
|
48
|
+
exports.getTanstackRscRouter = __webpack_exports__.getTanstackRscRouter;
|
|
49
|
+
exports.setTanstackRscRouter = __webpack_exports__.setTanstackRscRouter;
|
|
50
|
+
exports.setTanstackRscServerPayload = __webpack_exports__.setTanstackRscServerPayload;
|
|
51
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
52
|
+
"getTanstackRscRouter",
|
|
53
|
+
"setTanstackRscRouter",
|
|
54
|
+
"setTanstackRscServerPayload"
|
|
55
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|
|
@@ -36,28 +36,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
36
|
});
|
|
37
37
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
38
38
|
const server_namespaceObject = require("@modern-js/runtime/rsc/server");
|
|
39
|
-
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
40
39
|
const router_core_namespaceObject = require("@tanstack/router-core");
|
|
41
40
|
const external_react_namespaceObject = require("react");
|
|
42
41
|
const external_ClientSlot_js_namespaceObject = require("./ClientSlot.js");
|
|
43
|
-
const external_createRscProxy_js_namespaceObject = require("./createRscProxy.js");
|
|
44
42
|
const external_ReplayableStream_js_namespaceObject = require("./ReplayableStream.js");
|
|
45
43
|
const external_slotUsageSanitizer_js_namespaceObject = require("./slotUsageSanitizer.js");
|
|
46
44
|
const external_symbols_js_namespaceObject = require("./symbols.js");
|
|
47
45
|
const external_CompositeComponent_js_namespaceObject = require("./CompositeComponent.js");
|
|
48
|
-
function createTreeGetter(stream) {
|
|
49
|
-
let ready = false;
|
|
50
|
-
let tree;
|
|
51
|
-
const treePromise = Promise.resolve((0, server_namespaceObject.createFromReadableStream)(stream.createReplayStream())).then((value)=>{
|
|
52
|
-
tree = value;
|
|
53
|
-
ready = true;
|
|
54
|
-
return value;
|
|
55
|
-
});
|
|
56
|
-
return ()=>{
|
|
57
|
-
if (ready) return tree;
|
|
58
|
-
return (0, external_react_namespaceObject.use)(treePromise);
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
46
|
function createSlotProxy(options) {
|
|
62
47
|
const cache = new Map();
|
|
63
48
|
return new Proxy({}, {
|
|
@@ -81,6 +66,17 @@ function createSlotProxy(options) {
|
|
|
81
66
|
}
|
|
82
67
|
});
|
|
83
68
|
}
|
|
69
|
+
function createServerRscValue(options) {
|
|
70
|
+
return {
|
|
71
|
+
[external_symbols_js_namespaceObject.SERVER_COMPONENT_STREAM]: options.stream,
|
|
72
|
+
...options.renderable ? {
|
|
73
|
+
[external_symbols_js_namespaceObject.RENDERABLE_RSC]: true
|
|
74
|
+
} : {},
|
|
75
|
+
...options.slotUsagesStream ? {
|
|
76
|
+
[external_symbols_js_namespaceObject.RSC_SLOT_USAGES_STREAM]: options.slotUsagesStream
|
|
77
|
+
} : {}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
84
80
|
function toReplayableFlightStream(node, handlers) {
|
|
85
81
|
const flightStream = (0, server_namespaceObject.renderRsc)({
|
|
86
82
|
element: node
|
|
@@ -94,7 +90,7 @@ async function renderServerComponent(node) {
|
|
|
94
90
|
const streamWrapper = {
|
|
95
91
|
createReplayStream: ()=>stream.createReplayStream()
|
|
96
92
|
};
|
|
97
|
-
return (
|
|
93
|
+
return createServerRscValue({
|
|
98
94
|
renderable: true,
|
|
99
95
|
stream: streamWrapper
|
|
100
96
|
});
|
|
@@ -123,13 +119,13 @@ async function createCompositeComponent(component) {
|
|
|
123
119
|
const streamWrapper = {
|
|
124
120
|
createReplayStream: ()=>flightStream.createReplayStream()
|
|
125
121
|
};
|
|
126
|
-
return (
|
|
122
|
+
return createServerRscValue({
|
|
127
123
|
renderable: false,
|
|
128
124
|
slotUsagesStream: slotUsagesEmitter?.stream,
|
|
129
125
|
stream: streamWrapper
|
|
130
126
|
});
|
|
131
127
|
}
|
|
132
|
-
const adapter = (0,
|
|
128
|
+
const adapter = (0, router_core_namespaceObject.createSerializationAdapter)({
|
|
133
129
|
key: '$MODERN_TANSTACK_RSC',
|
|
134
130
|
test: external_symbols_js_namespaceObject.isServerComponent,
|
|
135
131
|
toSerializable: (component)=>{
|