@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.9 → 3.5.0-ultramodern.90
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
|
@@ -37,123 +37,18 @@ const url_namespaceObject = require("@modern-js/runtime-utils/url");
|
|
|
37
37
|
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
38
38
|
const external_react_namespaceObject = require("react");
|
|
39
39
|
const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.js");
|
|
40
|
+
const external_blockingSubscribe_js_namespaceObject = require("./blockingSubscribe.js");
|
|
41
|
+
const external_clientBasepath_js_namespaceObject = require("./clientBasepath.js");
|
|
42
|
+
const external_clientHydration_js_namespaceObject = require("./clientHydration.js");
|
|
40
43
|
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
41
44
|
const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
|
|
42
45
|
const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
|
|
43
|
-
const
|
|
44
|
-
const external_pluginCore_js_namespaceObject = require("./pluginCore.js");
|
|
46
|
+
const external_pluginShared_js_namespaceObject = require("./pluginShared.js");
|
|
45
47
|
const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
|
|
46
48
|
const external_routeHooks_js_namespaceObject = require("./routeHooks.js");
|
|
47
49
|
const external_routeTree_js_namespaceObject = require("./routeTree.js");
|
|
48
50
|
const client_js_namespaceObject = require("./rsc/client.js");
|
|
49
51
|
const external_types_js_namespaceObject = require("./types.js");
|
|
50
|
-
const external_utils_js_namespaceObject = require("./utils.js");
|
|
51
|
-
const BLOCKING_SUBSCRIBE_SYMBOL = Symbol.for('@modern-js/plugin-tanstack:blocking-subscribe');
|
|
52
|
-
const BLOCKING_STATE_SYMBOL = Symbol.for('@modern-js/plugin-tanstack:blocking-state');
|
|
53
|
-
function normalizeBase(b) {
|
|
54
|
-
if (b.length > 1 && b.endsWith('/')) return b.slice(0, -1);
|
|
55
|
-
return b || '/';
|
|
56
|
-
}
|
|
57
|
-
function isSegmentPrefix(pathname, base) {
|
|
58
|
-
const b = normalizeBase(base);
|
|
59
|
-
const p = pathname || '/';
|
|
60
|
-
return p === b || p.startsWith(`${b}/`);
|
|
61
|
-
}
|
|
62
|
-
function wrapRouterSubscribeWithBlockState(router, getBlockNavState) {
|
|
63
|
-
if (!router || 'object' != typeof router) return;
|
|
64
|
-
const target = router;
|
|
65
|
-
target[BLOCKING_STATE_SYMBOL] = getBlockNavState;
|
|
66
|
-
if (target[BLOCKING_SUBSCRIBE_SYMBOL] || 'function' != typeof target.subscribe) return;
|
|
67
|
-
const originSubscribe = target.subscribe.bind(target);
|
|
68
|
-
target.subscribe = (eventType, listener)=>{
|
|
69
|
-
const wrappedListener = (...args)=>{
|
|
70
|
-
const blockRoute = target[BLOCKING_STATE_SYMBOL]?.() || false;
|
|
71
|
-
if (blockRoute) return;
|
|
72
|
-
return listener(...args);
|
|
73
|
-
};
|
|
74
|
-
return originSubscribe(eventType, wrappedListener);
|
|
75
|
-
};
|
|
76
|
-
target[BLOCKING_SUBSCRIBE_SYMBOL] = true;
|
|
77
|
-
}
|
|
78
|
-
const routerHydrationRecords = new WeakMap();
|
|
79
|
-
const routeModulesKey = '_routeModules';
|
|
80
|
-
function pickRouteModuleComponent(routeModule, seen = new Set()) {
|
|
81
|
-
if ('function' == typeof routeModule || routeModule && 'object' == typeof routeModule && '$$typeof' in routeModule) return routeModule;
|
|
82
|
-
if (!routeModule || 'object' != typeof routeModule) return;
|
|
83
|
-
if (seen.has(routeModule)) return;
|
|
84
|
-
seen.add(routeModule);
|
|
85
|
-
const module = routeModule;
|
|
86
|
-
for (const candidate of [
|
|
87
|
-
module.default,
|
|
88
|
-
module.Component
|
|
89
|
-
]){
|
|
90
|
-
const component = pickRouteModuleComponent(candidate, seen);
|
|
91
|
-
if (component) return component;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function getCachedRouteModule(routeId) {
|
|
95
|
-
if ("u" < typeof window) return;
|
|
96
|
-
return window[routeModulesKey]?.[routeId];
|
|
97
|
-
}
|
|
98
|
-
function preloadHydratedRouteComponents(router) {
|
|
99
|
-
const preloadableRouter = router;
|
|
100
|
-
const routesById = preloadableRouter.routesById || {};
|
|
101
|
-
const matches = preloadableRouter.stores.matches.get();
|
|
102
|
-
return Promise.all(matches.map((match)=>{
|
|
103
|
-
if (void 0 === match.routeId || '' === match.routeId) return;
|
|
104
|
-
const route = routesById[match.routeId];
|
|
105
|
-
const component = route?.options?.component;
|
|
106
|
-
const preload = component?.load || component?.preload;
|
|
107
|
-
if ('function' != typeof preload) return;
|
|
108
|
-
return Promise.resolve(preload.call(component)).then((routeModule)=>{
|
|
109
|
-
const modernRouteId = route?.options?.staticData?.modernRouteId;
|
|
110
|
-
const cachedRouteModule = 'string' == typeof modernRouteId && '' !== modernRouteId ? getCachedRouteModule(modernRouteId) : void 0;
|
|
111
|
-
const resolvedComponent = pickRouteModuleComponent(cachedRouteModule ?? routeModule);
|
|
112
|
-
if (void 0 !== resolvedComponent && 'string' == typeof modernRouteId && '' !== modernRouteId) route.options.component = (0, external_outlet_js_namespaceObject.withModernRouteMatchContext)(resolvedComponent, modernRouteId);
|
|
113
|
-
});
|
|
114
|
-
})).then(()=>void 0);
|
|
115
|
-
}
|
|
116
|
-
function hydrateTanstackRouter(router) {
|
|
117
|
-
return import("@tanstack/react-router/ssr/client").then(({ hydrate })=>hydrate(router));
|
|
118
|
-
}
|
|
119
|
-
function getTanstackSsrHydrationRecord(router) {
|
|
120
|
-
const existingHydrationRecord = routerHydrationRecords.get(router);
|
|
121
|
-
if (void 0 !== existingHydrationRecord) return existingHydrationRecord;
|
|
122
|
-
const hydrationRecord = {
|
|
123
|
-
promise: Promise.resolve(),
|
|
124
|
-
status: 'pending'
|
|
125
|
-
};
|
|
126
|
-
routerHydrationRecords.set(router, hydrationRecord);
|
|
127
|
-
try {
|
|
128
|
-
hydrationRecord.promise = hydrateTanstackRouter(router).then((value)=>preloadHydratedRouteComponents(router).then(()=>value)).then((value)=>{
|
|
129
|
-
hydrationRecord.status = 'fulfilled';
|
|
130
|
-
return value;
|
|
131
|
-
}, (error)=>{
|
|
132
|
-
hydrationRecord.status = 'rejected';
|
|
133
|
-
hydrationRecord.error = error;
|
|
134
|
-
throw error;
|
|
135
|
-
});
|
|
136
|
-
} catch (error) {
|
|
137
|
-
hydrationRecord.status = 'rejected';
|
|
138
|
-
hydrationRecord.error = error;
|
|
139
|
-
hydrationRecord.promise = Promise.reject(error);
|
|
140
|
-
hydrationRecord.promise.catch(()=>{});
|
|
141
|
-
}
|
|
142
|
-
return hydrationRecord;
|
|
143
|
-
}
|
|
144
|
-
function getTanstackSsrHydrationPromise(router) {
|
|
145
|
-
return getTanstackSsrHydrationRecord(router).promise;
|
|
146
|
-
}
|
|
147
|
-
function hasTanstackSsrHydrationRecord(router) {
|
|
148
|
-
return routerHydrationRecords.has(router);
|
|
149
|
-
}
|
|
150
|
-
function ModernRouterClient({ router }) {
|
|
151
|
-
const hydrationRecord = getTanstackSsrHydrationRecord(router);
|
|
152
|
-
if ('rejected' === hydrationRecord.status) throw hydrationRecord.error;
|
|
153
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
|
|
154
|
-
router: router
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
52
|
const tanstackRouterPlugin = (userConfig = {})=>{
|
|
158
53
|
const plugin = {
|
|
159
54
|
name: '@modern-js/plugin-router-tanstack',
|
|
@@ -164,16 +59,13 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
164
59
|
let cachedRouteTree = null;
|
|
165
60
|
let cachedRouter = null;
|
|
166
61
|
let cachedRouterBasepath = null;
|
|
167
|
-
const getMergedConfig = ()=>(0,
|
|
62
|
+
const getMergedConfig = ()=>(0, external_pluginShared_js_namespaceObject.getMergedRouterConfig)(api, userConfig);
|
|
168
63
|
const getRouteObjects = ()=>{
|
|
169
64
|
if (void 0 !== cachedRouteObjects) return cachedRouteObjects;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
routesConfig: finalRouteConfig
|
|
175
|
-
}) || [];
|
|
176
|
-
cachedRouteObjects = hooks.modifyRoutes.call(routeObjects);
|
|
65
|
+
cachedRouteObjects = (0, external_pluginShared_js_namespaceObject.createTanstackRouteObjects)({
|
|
66
|
+
hooks,
|
|
67
|
+
routeConfig: (0, external_pluginShared_js_namespaceObject.getTanstackRouteConfig)(api, userConfig)
|
|
68
|
+
});
|
|
177
69
|
return cachedRouteObjects;
|
|
178
70
|
};
|
|
179
71
|
const getRouteTree = ()=>{
|
|
@@ -187,13 +79,13 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
187
79
|
};
|
|
188
80
|
const selectBasePath = (pathname)=>{
|
|
189
81
|
const { serverBase = [] } = getMergedConfig();
|
|
190
|
-
const match = serverBase.find((baseUrl)=>isSegmentPrefix(pathname, baseUrl));
|
|
82
|
+
const match = serverBase.find((baseUrl)=>(0, external_clientBasepath_js_namespaceObject.isSegmentPrefix)(pathname, baseUrl));
|
|
191
83
|
return match || '/';
|
|
192
84
|
};
|
|
193
85
|
const getClientBasename = (runtimeContext)=>{
|
|
194
86
|
const { basename = '' } = getMergedConfig();
|
|
195
87
|
const baseUrl = selectBasePath(location.pathname).replace(/^\/*/, '/');
|
|
196
|
-
return '/' === baseUrl ? (0,
|
|
88
|
+
return '/' === baseUrl ? (0, external_pluginShared_js_namespaceObject.joinBasename)(baseUrl, runtimeContext._internalRouterBaseName || basename || '') : baseUrl;
|
|
197
89
|
};
|
|
198
90
|
const getRouter = (runtimeContext, _basename)=>{
|
|
199
91
|
const routeTree = getRouteTree();
|
|
@@ -207,7 +99,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
207
99
|
};
|
|
208
100
|
hooks.onBeforeCreateRouter.call(lifecycleContext);
|
|
209
101
|
if (cachedRouter && cachedRouterBasepath === _basename) {
|
|
210
|
-
wrapRouterSubscribeWithBlockState(cachedRouter, runtimeContext.unstable_getBlockNavState);
|
|
102
|
+
(0, external_blockingSubscribe_js_namespaceObject.wrapRouterSubscribeWithBlockState)(cachedRouter, runtimeContext.unstable_getBlockNavState);
|
|
211
103
|
hooks.onAfterCreateRouter.call({
|
|
212
104
|
...lifecycleContext,
|
|
213
105
|
router: cachedRouter,
|
|
@@ -220,8 +112,12 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
220
112
|
const history = supportHtml5History ? (0, react_router_namespaceObject.createBrowserHistory)() : (0, react_router_namespaceObject.createHashHistory)();
|
|
221
113
|
const rewrite = (0, external_basepathRewrite_js_namespaceObject.createModernBasepathRewrite)(_basename);
|
|
222
114
|
const serializationAdapters = (0, context_namespaceObject.getGlobalEnableRsc)() ? (0, client_js_namespaceObject.getTanstackRscSerializationAdapters)() : void 0;
|
|
115
|
+
const routerFastDefaults = (0, external_types_js_namespaceObject.getModernTanstackRouterFastDefaults)(mergedConfig);
|
|
223
116
|
cachedRouter = (0, react_router_namespaceObject.createRouter)({
|
|
224
|
-
...
|
|
117
|
+
...routerFastDefaults,
|
|
118
|
+
...serializationAdapters ? {
|
|
119
|
+
defaultStructuralSharing: false
|
|
120
|
+
} : {},
|
|
225
121
|
routeTree,
|
|
226
122
|
basepath: '/',
|
|
227
123
|
rewrite,
|
|
@@ -232,7 +128,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
232
128
|
} : {}
|
|
233
129
|
});
|
|
234
130
|
cachedRouterBasepath = _basename;
|
|
235
|
-
wrapRouterSubscribeWithBlockState(cachedRouter, runtimeContext.unstable_getBlockNavState);
|
|
131
|
+
(0, external_blockingSubscribe_js_namespaceObject.wrapRouterSubscribeWithBlockState)(cachedRouter, runtimeContext.unstable_getBlockNavState);
|
|
236
132
|
hooks.onAfterCreateRouter.call({
|
|
237
133
|
...lifecycleContext,
|
|
238
134
|
router: cachedRouter,
|
|
@@ -263,7 +159,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
263
159
|
if (hasSSRBootstrap && getRouteObjects().length > 0) {
|
|
264
160
|
const runtimeContext = context;
|
|
265
161
|
const router = getRouter(runtimeContext, getClientBasename(runtimeContext));
|
|
266
|
-
if (null != router) return getTanstackSsrHydrationPromise(router).then(()=>void 0);
|
|
162
|
+
if (null != router) return (0, external_clientHydration_js_namespaceObject.getTanstackSsrHydrationPromise)(router).then(()=>void 0);
|
|
267
163
|
}
|
|
268
164
|
});
|
|
269
165
|
api.wrapRoot((App)=>{
|
|
@@ -292,7 +188,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
292
188
|
basename: _basename,
|
|
293
189
|
router
|
|
294
190
|
};
|
|
295
|
-
const hasSSRBootstrap = "u" > typeof window && (Boolean(window.$_TSR) || hasTanstackSsrHydrationRecord(router));
|
|
191
|
+
const hasSSRBootstrap = "u" > typeof window && (Boolean(window.$_TSR) || (0, external_clientHydration_js_namespaceObject.hasTanstackSsrHydrationRecord)(router));
|
|
296
192
|
const needsRouterClient = hasSSRBootstrap;
|
|
297
193
|
if (needsRouterClient) hooks.onBeforeHydrateRouter.call({
|
|
298
194
|
...lifecycleContext,
|
|
@@ -300,7 +196,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
300
196
|
router,
|
|
301
197
|
runtimeContext: runtimeState
|
|
302
198
|
});
|
|
303
|
-
const RouterContent = needsRouterClient ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModernRouterClient, {
|
|
199
|
+
const RouterContent = needsRouterClient ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_clientHydration_js_namespaceObject.ModernRouterClient, {
|
|
304
200
|
router: router
|
|
305
201
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
|
|
306
202
|
router: router
|
|
@@ -42,138 +42,43 @@ const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.j
|
|
|
42
42
|
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
43
43
|
const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
|
|
44
44
|
const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
|
|
45
|
-
const
|
|
45
|
+
const external_pluginShared_js_namespaceObject = require("./pluginShared.js");
|
|
46
46
|
const external_routeTree_js_namespaceObject = require("./routeTree.js");
|
|
47
47
|
const payloadRouter_js_namespaceObject = require("./rsc/payloadRouter.js");
|
|
48
|
+
const payloadStorage_js_namespaceObject = require("./rsc/payloadStorage.js");
|
|
49
|
+
const external_ssrManagedTags_js_namespaceObject = require("./ssrManagedTags.js");
|
|
50
|
+
const external_ssrPreload_js_namespaceObject = require("./ssrPreload.js");
|
|
48
51
|
const external_types_js_namespaceObject = require("./types.js");
|
|
49
|
-
const external_utils_js_namespaceObject = require("./utils.js");
|
|
50
|
-
const setTanstackRscServerPayload = (payload)=>{
|
|
51
|
-
const storageContext = node_namespaceObject.storage.useContext?.();
|
|
52
|
-
if (storageContext) storageContext.serverPayload = payload;
|
|
53
|
-
};
|
|
54
|
-
function isPromiseLike(value) {
|
|
55
|
-
return Boolean(value && 'function' == typeof value.then);
|
|
56
|
-
}
|
|
57
|
-
function isPreloadableRouteComponent(component) {
|
|
58
|
-
if (!component || 'function' != typeof component) return false;
|
|
59
|
-
const preloadable = component;
|
|
60
|
-
return 'function' == typeof preloadable.load || 'function' == typeof preloadable.preload;
|
|
61
|
-
}
|
|
62
|
-
function isReactLazyRouteComponent(component) {
|
|
63
|
-
return null != component && 'object' == typeof component && 'function' == typeof component._init && '_payload' in component;
|
|
64
|
-
}
|
|
65
|
-
async function preloadReactLazyRouteComponent(component) {
|
|
66
|
-
try {
|
|
67
|
-
component._init?.(component._payload);
|
|
68
|
-
} catch (thrown) {
|
|
69
|
-
if (!isPromiseLike(thrown)) throw thrown;
|
|
70
|
-
await thrown;
|
|
71
|
-
component._init?.(component._payload);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async function preloadRouteComponent(component) {
|
|
75
|
-
if (isReactLazyRouteComponent(component)) return void await preloadReactLazyRouteComponent(component);
|
|
76
|
-
if (!isPreloadableRouteComponent(component)) return;
|
|
77
|
-
if ('function' == typeof component.load) return void await component.load({});
|
|
78
|
-
await component.preload?.({});
|
|
79
|
-
}
|
|
80
|
-
async function preloadMatchedRouteComponents(tanstackRouter) {
|
|
81
|
-
const matches = Array.isArray(tanstackRouter.state.matches) ? tanstackRouter.state.matches : [];
|
|
82
|
-
const routesById = tanstackRouter.routesById || {};
|
|
83
|
-
await Promise.all(matches.map(async (match)=>{
|
|
84
|
-
const routeId = 'string' == typeof match.routeId ? match.routeId : 'string' == typeof match.route?.id ? match.route.id : void 0;
|
|
85
|
-
const route = routeId ? routesById[routeId] : match.route;
|
|
86
|
-
const options = route?.options;
|
|
87
|
-
if (!options) return;
|
|
88
|
-
await Promise.all([
|
|
89
|
-
preloadRouteComponent(options.component),
|
|
90
|
-
preloadRouteComponent(options.pendingComponent),
|
|
91
|
-
preloadRouteComponent(options.errorComponent),
|
|
92
|
-
preloadRouteComponent(options.notFoundComponent)
|
|
93
|
-
]);
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
async function waitForRouterSerialization(tanstackRouter) {
|
|
97
|
-
const serverSsr = tanstackRouter.serverSsr;
|
|
98
|
-
if (!serverSsr || 'function' != typeof serverSsr.onSerializationFinished || serverSsr.isSerializationFinished?.()) return;
|
|
99
|
-
await new Promise((resolve)=>{
|
|
100
|
-
serverSsr.onSerializationFinished?.(resolve);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function htmlEscapeAttr(value) {
|
|
104
|
-
return value.replace(/&/g, '&').replace(/"/g, '"');
|
|
105
|
-
}
|
|
106
|
-
function routerManagedTagToHtml(tag) {
|
|
107
|
-
if (!tag || 'object' != typeof tag) return '';
|
|
108
|
-
const managedTag = tag;
|
|
109
|
-
if (!managedTag || "script" !== managedTag.tag) return '';
|
|
110
|
-
const attrs = managedTag.attrs || {};
|
|
111
|
-
const attrsStr = Object.entries(attrs).filter(([, v])=>null != v && false !== v).map(([k, v])=>{
|
|
112
|
-
const name = 'className' === k ? 'class' : k;
|
|
113
|
-
if (true === v) return name;
|
|
114
|
-
return `${name}="${htmlEscapeAttr(String(v))}"`;
|
|
115
|
-
}).join(' ');
|
|
116
|
-
const open = attrsStr.length ? `<script ${attrsStr}>` : "<script>";
|
|
117
|
-
const children = 'string' == typeof managedTag.children ? managedTag.children : '';
|
|
118
|
-
return `${open}${children}</script>`;
|
|
119
|
-
}
|
|
120
|
-
function routerManagedTagsToHtml(tags) {
|
|
121
|
-
const normalizedTags = Array.isArray(tags) ? tags : [
|
|
122
|
-
tags
|
|
123
|
-
];
|
|
124
|
-
return normalizedTags.map(routerManagedTagToHtml).filter(Boolean);
|
|
125
|
-
}
|
|
126
|
-
function createGetSsrHref(request) {
|
|
127
|
-
const url = new URL(request.url);
|
|
128
|
-
return `${url.pathname}${url.search}${url.hash}`;
|
|
129
|
-
}
|
|
130
|
-
function collectRouterErrors(tanstackRouter) {
|
|
131
|
-
const state = tanstackRouter.state;
|
|
132
|
-
const matches = Array.isArray(state.matches) ? state.matches : [];
|
|
133
|
-
const errors = matches.reduce((acc, match)=>{
|
|
134
|
-
if (!match.error) return acc;
|
|
135
|
-
const routeId = 'string' == typeof match.routeId ? match.routeId : 'string' == typeof match.route?.id ? match.route.id : `match-${Object.keys(acc).length}`;
|
|
136
|
-
acc[routeId] = match.error;
|
|
137
|
-
return acc;
|
|
138
|
-
}, {});
|
|
139
|
-
return Object.keys(errors).length > 0 ? errors : void 0;
|
|
140
|
-
}
|
|
141
|
-
async function attachServerSsrUtils(router) {
|
|
142
|
-
const { attachRouterServerSsrUtils } = await import("@tanstack/router-core/ssr/server");
|
|
143
|
-
attachRouterServerSsrUtils({
|
|
144
|
-
router,
|
|
145
|
-
manifest: void 0
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
52
|
const tanstackRouterPlugin = (userConfig = {})=>{
|
|
149
53
|
const plugin = {
|
|
150
54
|
name: '@modern-js/plugin-router-tanstack',
|
|
151
55
|
registryHooks: external_hooks_js_namespaceObject.routerProviderRegistryHooks,
|
|
152
56
|
setup: (api)=>{
|
|
153
57
|
api.onBeforeRender(async (context, interrupt)=>{
|
|
154
|
-
const
|
|
58
|
+
const routeConfig = (0, external_pluginShared_js_namespaceObject.getTanstackRouteConfig)(api, userConfig);
|
|
59
|
+
const { mergedConfig } = routeConfig;
|
|
155
60
|
const serializationAdapters = (0, context_namespaceObject.getGlobalEnableRsc)() ? (await import("./rsc/server.js")).getTanstackRscSerializationAdapters() : void 0;
|
|
156
61
|
const enableRsc = (0, context_namespaceObject.getGlobalEnableRsc)();
|
|
157
|
-
const { basename = ''
|
|
158
|
-
|
|
159
|
-
if (!finalRouteConfig.routes && !createRoutes) return;
|
|
62
|
+
const { basename = '' } = mergedConfig;
|
|
63
|
+
if (!routeConfig.hasConfiguredRoutes) return;
|
|
160
64
|
const hooks = api.getHooks();
|
|
161
65
|
await hooks.onBeforeCreateRoutes.call(context);
|
|
162
|
-
const
|
|
163
|
-
|
|
66
|
+
const modifiedRouteObjects = (0, external_pluginShared_js_namespaceObject.createTanstackRouteObjects)({
|
|
67
|
+
hooks,
|
|
68
|
+
routeConfig,
|
|
164
69
|
ssrMode: context.ssrContext?.mode
|
|
165
|
-
})
|
|
166
|
-
const modifiedRouteObjects = hooks.modifyRoutes.call(routeObjects);
|
|
70
|
+
});
|
|
167
71
|
if (!modifiedRouteObjects.length) return;
|
|
168
72
|
const { request, nonce, baseUrl, loaderFailureMode = 'errorBoundary' } = context.ssrContext;
|
|
169
|
-
const _basename = '/' === baseUrl ? (0,
|
|
170
|
-
const
|
|
171
|
-
const
|
|
73
|
+
const _basename = '/' === baseUrl ? (0, external_pluginShared_js_namespaceObject.joinBasename)(baseUrl, basename || '') : baseUrl;
|
|
74
|
+
const rawRequest = request.raw;
|
|
75
|
+
const initialHref = (0, external_ssrManagedTags_js_namespaceObject.createGetSsrHref)(rawRequest);
|
|
76
|
+
const isRSCNavigation = enableRsc && 'true' === rawRequest.headers.get('x-rsc-tree');
|
|
172
77
|
const requestContext = (0, node_namespaceObject.createRequestContext)(context.ssrContext?.loaderContext);
|
|
173
78
|
const controller = new AbortController();
|
|
174
|
-
const ssrRequest = new Request(
|
|
79
|
+
const ssrRequest = new Request(rawRequest.url, {
|
|
175
80
|
method: 'GET',
|
|
176
|
-
headers:
|
|
81
|
+
headers: rawRequest.headers,
|
|
177
82
|
signal: controller.signal
|
|
178
83
|
});
|
|
179
84
|
const routerContext = {
|
|
@@ -201,7 +106,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
201
106
|
history,
|
|
202
107
|
basepath: '/',
|
|
203
108
|
rewrite,
|
|
204
|
-
origin: new URL(
|
|
109
|
+
origin: new URL(rawRequest.url).origin,
|
|
205
110
|
ssr: {
|
|
206
111
|
nonce
|
|
207
112
|
},
|
|
@@ -211,7 +116,8 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
211
116
|
} : {}
|
|
212
117
|
});
|
|
213
118
|
const serverRouter = tanstackRouter;
|
|
214
|
-
|
|
119
|
+
if (enableRsc) (0, payloadStorage_js_namespaceObject.setTanstackRscRouter)(serverRouter);
|
|
120
|
+
await (0, external_ssrManagedTags_js_namespaceObject.attachServerSsrUtils)(serverRouter);
|
|
215
121
|
const end = (0, time_namespaceObject.time)();
|
|
216
122
|
try {
|
|
217
123
|
await tanstackRouter.load({
|
|
@@ -228,25 +134,25 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
228
134
|
} catch {}
|
|
229
135
|
return interrupt(isRSCNavigation ? (0, payloadRouter_js_namespaceObject.handleTanstackRscRedirect)(resolved.headers, _basename, resolved.status) : resolved);
|
|
230
136
|
}
|
|
231
|
-
const routerErrors = collectRouterErrors(tanstackRouter);
|
|
137
|
+
const routerErrors = (0, external_ssrManagedTags_js_namespaceObject.collectRouterErrors)(tanstackRouter);
|
|
232
138
|
if (routerErrors && 'clientRender' === loaderFailureMode) {
|
|
233
|
-
context.ssrContext?.response
|
|
139
|
+
context.ssrContext?.response?.status(200);
|
|
234
140
|
try {
|
|
235
141
|
serverRouter.serverSsr?.cleanup?.();
|
|
236
142
|
} catch {}
|
|
237
143
|
throw Object.values(routerErrors)[0];
|
|
238
144
|
}
|
|
239
|
-
await preloadMatchedRouteComponents(serverRouter);
|
|
240
|
-
context.ssrContext?.response
|
|
145
|
+
await (0, external_ssrPreload_js_namespaceObject.preloadMatchedRouteComponents)(serverRouter);
|
|
146
|
+
context.ssrContext?.response?.status(tanstackRouter.state.statusCode);
|
|
241
147
|
await serverRouter.serverSsr?.dehydrate?.();
|
|
242
|
-
if (
|
|
243
|
-
await waitForRouterSerialization(serverRouter);
|
|
244
|
-
setTanstackRscServerPayload((0, payloadRouter_js_namespaceObject.createTanstackRscServerPayload)(serverRouter, {
|
|
245
|
-
omitClientLoaderData:
|
|
148
|
+
if (enableRsc) {
|
|
149
|
+
if (isRSCNavigation) await (0, external_ssrManagedTags_js_namespaceObject.waitForRouterSerialization)(serverRouter);
|
|
150
|
+
(0, payloadStorage_js_namespaceObject.setTanstackRscServerPayload)((0, payloadRouter_js_namespaceObject.createTanstackRscServerPayload)(serverRouter, {
|
|
151
|
+
omitClientLoaderData: isRSCNavigation
|
|
246
152
|
}));
|
|
247
153
|
}
|
|
248
154
|
const ssrScriptTags = serverRouter.serverSsr?.takeBufferedScripts?.();
|
|
249
|
-
const hydrationScripts = routerManagedTagsToHtml(ssrScriptTags);
|
|
155
|
+
const hydrationScripts = (0, external_ssrManagedTags_js_namespaceObject.routerManagedTagsToHtml)(ssrScriptTags);
|
|
250
156
|
const matchedRouteIds = (0, external_routeTree_js_namespaceObject.getModernRouteIdsFromMatches)(serverRouter);
|
|
251
157
|
const routerServerSnapshot = (0, external_lifecycle_js_namespaceObject.createRouterServerSnapshot)({
|
|
252
158
|
framework: 'tanstack',
|
|
@@ -276,7 +182,20 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
276
182
|
});
|
|
277
183
|
});
|
|
278
184
|
api.wrapRoot((App)=>{
|
|
279
|
-
const getRouteApp = ()=>
|
|
185
|
+
const getRouteApp = ()=>{
|
|
186
|
+
if ((0, context_namespaceObject.getGlobalEnableRsc)()) return (props)=>{
|
|
187
|
+
const router = (0, payloadStorage_js_namespaceObject.getTanstackRscRouter)();
|
|
188
|
+
if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
|
|
189
|
+
...props
|
|
190
|
+
}) : null;
|
|
191
|
+
const routerWrapper = (0, external_hydrationBoundary_js_namespaceObject.wrapTanstackSsrHydrationBoundary)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
|
|
192
|
+
router: router
|
|
193
|
+
}), true);
|
|
194
|
+
return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
|
|
195
|
+
children: routerWrapper
|
|
196
|
+
}) : routerWrapper;
|
|
197
|
+
};
|
|
198
|
+
return (props)=>{
|
|
280
199
|
const context = (0, external_react_namespaceObject.useContext)(context_namespaceObject.InternalRuntimeContext);
|
|
281
200
|
const router = (0, external_lifecycle_js_namespaceObject.getRouterRuntimeState)(context)?.instance;
|
|
282
201
|
if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
|
|
@@ -289,6 +208,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
289
208
|
children: routerWrapper
|
|
290
209
|
}) : routerWrapper;
|
|
291
210
|
};
|
|
211
|
+
};
|
|
292
212
|
return getRouteApp();
|
|
293
213
|
});
|
|
294
214
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
createTanstackRouteObjects: ()=>createTanstackRouteObjects,
|
|
32
|
+
getMergedRouterConfig: ()=>getMergedRouterConfig,
|
|
33
|
+
getTanstackRouteConfig: ()=>getTanstackRouteConfig,
|
|
34
|
+
joinBasename: ()=>joinBasename
|
|
35
|
+
});
|
|
36
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
37
|
+
const merge_namespaceObject = require("@modern-js/runtime-utils/merge");
|
|
38
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
39
|
+
function getMergedRouterConfig(api, userConfig) {
|
|
40
|
+
const pluginConfig = api.getRuntimeConfig();
|
|
41
|
+
return (0, merge_namespaceObject.merge)(pluginConfig.router || {}, userConfig);
|
|
42
|
+
}
|
|
43
|
+
function getFinalRouteConfig(mergedConfig) {
|
|
44
|
+
return {
|
|
45
|
+
routes: (0, context_namespaceObject.getGlobalRoutes)(),
|
|
46
|
+
globalApp: (0, context_namespaceObject.getGlobalLayoutApp)(),
|
|
47
|
+
...mergedConfig.routesConfig
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function getTanstackRouteConfig(api, userConfig) {
|
|
51
|
+
const mergedConfig = getMergedRouterConfig(api, userConfig);
|
|
52
|
+
const finalRouteConfig = getFinalRouteConfig(mergedConfig);
|
|
53
|
+
return {
|
|
54
|
+
mergedConfig,
|
|
55
|
+
finalRouteConfig,
|
|
56
|
+
hasConfiguredRoutes: Boolean(finalRouteConfig.routes) || Boolean(mergedConfig.createRoutes)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function createTanstackRouteObjects({ hooks, routeConfig, ssrMode }) {
|
|
60
|
+
const { mergedConfig, finalRouteConfig } = routeConfig;
|
|
61
|
+
const routeObjects = mergedConfig.createRoutes ? mergedConfig.createRoutes() : (0, external_utils_js_namespaceObject.createTanstackRouteObjectsFromConfig)({
|
|
62
|
+
routesConfig: finalRouteConfig,
|
|
63
|
+
ssrMode
|
|
64
|
+
}) || [];
|
|
65
|
+
return hooks.modifyRoutes.call(routeObjects);
|
|
66
|
+
}
|
|
67
|
+
function joinBasename(baseUrl, basename) {
|
|
68
|
+
const base = baseUrl || '/';
|
|
69
|
+
const normalizedBase = base.startsWith('/') ? base : `/${base}`;
|
|
70
|
+
const trimmedBase = normalizedBase.length > 1 ? normalizedBase.replace(/\/+$/g, '') : normalizedBase;
|
|
71
|
+
const trimmedBasename = basename.replace(/^\/+|\/+$/g, '');
|
|
72
|
+
if (!trimmedBasename) return trimmedBase || '/';
|
|
73
|
+
return `${trimmedBase}/${trimmedBasename}`.replace(/\/{2,}/g, '/');
|
|
74
|
+
}
|
|
75
|
+
exports.createTanstackRouteObjects = __webpack_exports__.createTanstackRouteObjects;
|
|
76
|
+
exports.getMergedRouterConfig = __webpack_exports__.getMergedRouterConfig;
|
|
77
|
+
exports.getTanstackRouteConfig = __webpack_exports__.getTanstackRouteConfig;
|
|
78
|
+
exports.joinBasename = __webpack_exports__.joinBasename;
|
|
79
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
80
|
+
"createTanstackRouteObjects",
|
|
81
|
+
"getMergedRouterConfig",
|
|
82
|
+
"getTanstackRouteConfig",
|
|
83
|
+
"joinBasename"
|
|
84
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
85
|
+
Object.defineProperty(exports, '__esModule', {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
@@ -40,10 +40,23 @@ function resolvePreloadFromPrefetch(prefetch, preload) {
|
|
|
40
40
|
return 'viewport';
|
|
41
41
|
}
|
|
42
42
|
const LinkComponentImpl = (props)=>{
|
|
43
|
-
const { prefetch, preload, ...rest } = props;
|
|
44
|
-
|
|
43
|
+
const { prefetch, preload, 'aria-current': ariaCurrentProp, ref, children, ...rest } = props;
|
|
44
|
+
const hasAriaCurrentOverride = 'aria-current' in props;
|
|
45
|
+
const linkOptions = {
|
|
45
46
|
...rest,
|
|
46
47
|
preload: resolvePreloadFromPrefetch(prefetch, preload)
|
|
48
|
+
};
|
|
49
|
+
const linkProps = (0, react_router_namespaceObject.useLinkProps)(linkOptions, ref);
|
|
50
|
+
const { disabled: _disabled, type: _type, ...anchorProps } = linkProps;
|
|
51
|
+
if (hasAriaCurrentOverride) if (false === ariaCurrentProp || void 0 === ariaCurrentProp) delete anchorProps['aria-current'];
|
|
52
|
+
else anchorProps['aria-current'] = ariaCurrentProp;
|
|
53
|
+
const resolvedChildren = 'function' == typeof children ? children({
|
|
54
|
+
isActive: 'active' === anchorProps['data-status'],
|
|
55
|
+
isTransitioning: 'transitioning' === anchorProps['data-transitioning']
|
|
56
|
+
}) : children;
|
|
57
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
|
|
58
|
+
...anchorProps,
|
|
59
|
+
children: resolvedChildren
|
|
47
60
|
});
|
|
48
61
|
};
|
|
49
62
|
const Link = LinkComponentImpl;
|
|
@@ -28,28 +28,15 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
|
|
31
|
+
tanstackRouterProviderFactory: ()=>tanstackRouterProviderFactory
|
|
32
32
|
});
|
|
33
33
|
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
34
|
-
const external_dataMutation_js_namespaceObject = require("./dataMutation.js");
|
|
35
|
-
const external_outlet_js_namespaceObject = require("./outlet.js");
|
|
36
34
|
const external_plugin_js_namespaceObject = require("./plugin.js");
|
|
37
|
-
const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
|
|
38
35
|
const tanstackRouterProviderFactory = (userConfig)=>(0, external_plugin_js_namespaceObject.tanstackRouterPlugin)(userConfig);
|
|
39
36
|
(0, context_namespaceObject.registerRouterProvider)('tanstack', tanstackRouterProviderFactory);
|
|
40
|
-
|
|
41
|
-
const tanstackRouterCompatBindings = {
|
|
42
|
-
Form: external_dataMutation_js_namespaceObject.Form,
|
|
43
|
-
Link: external_prefetchLink_js_namespaceObject.Link,
|
|
44
|
-
NavLink: external_prefetchLink_js_namespaceObject.NavLink,
|
|
45
|
-
Outlet: external_outlet_js_namespaceObject.Outlet,
|
|
46
|
-
RouteActionResponseError: external_dataMutation_js_namespaceObject.RouteActionResponseError,
|
|
47
|
-
useFetcher: external_dataMutation_js_namespaceObject.useFetcher
|
|
48
|
-
};
|
|
49
|
-
globalThis[COMPAT_BINDINGS_SLOT] ??= tanstackRouterCompatBindings;
|
|
50
|
-
exports.tanstackRouterCompatBindings = __webpack_exports__.tanstackRouterCompatBindings;
|
|
37
|
+
exports.tanstackRouterProviderFactory = __webpack_exports__.tanstackRouterProviderFactory;
|
|
51
38
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
52
|
-
"
|
|
39
|
+
"tanstackRouterProviderFactory"
|
|
53
40
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
54
41
|
Object.defineProperty(exports, '__esModule', {
|
|
55
42
|
value: true
|