@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.30 → 3.5.0-ultramodern.31
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 +6 -103
- package/dist/cjs/cli/tanstackTypes/canonicalRoutes.js +113 -0
- package/dist/cjs/cli/tanstackTypes/shared.js +130 -0
- package/dist/cjs/cli/tanstackTypes/source.js +251 -0
- package/dist/cjs/cli/tanstackTypes.js +4 -350
- package/dist/cjs/runtime/blockingSubscribe.js +64 -0
- package/dist/cjs/runtime/{pluginCore.js → clientBasepath.js} +12 -19
- package/dist/cjs/runtime/clientHydration.js +129 -0
- package/dist/cjs/runtime/dataMutation.js +11 -176
- package/dist/cjs/runtime/formData.js +116 -0
- package/dist/cjs/runtime/loaderBridge.js +4 -1
- package/dist/cjs/runtime/plugin.js +21 -125
- package/dist/cjs/runtime/plugin.node.js +38 -119
- package/dist/cjs/runtime/pluginShared.js +90 -0
- 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/rsc/CompositeComponent.js +18 -13
- 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 +117 -0
- package/dist/cjs/runtime/rsc/payloadRouter.js +21 -142
- package/dist/cjs/runtime/rsc/payloadRoutes.js +106 -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 +71 -0
- package/dist/cjs/runtime/rsc/treeGetter.js +72 -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/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 +4 -101
- package/dist/esm/cli/tanstackTypes/canonicalRoutes.mjs +75 -0
- package/dist/esm/cli/tanstackTypes/shared.mjs +68 -0
- package/dist/esm/cli/tanstackTypes/source.mjs +203 -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 +70 -0
- package/dist/esm/runtime/dataMutation.mjs +2 -167
- package/dist/esm/runtime/formData.mjs +63 -0
- package/dist/esm/runtime/loaderBridge.mjs +4 -1
- package/dist/esm/runtime/plugin.mjs +14 -118
- package/dist/esm/runtime/plugin.node.mjs +33 -114
- package/dist/esm/runtime/pluginShared.mjs +40 -0
- 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/rsc/CompositeComponent.mjs +18 -13
- 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 +61 -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/treeGetter.mjs +34 -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/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 +4 -101
- package/dist/esm-node/cli/tanstackTypes/canonicalRoutes.mjs +76 -0
- package/dist/esm-node/cli/tanstackTypes/shared.mjs +69 -0
- package/dist/esm-node/cli/tanstackTypes/source.mjs +204 -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 +71 -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 +4 -1
- package/dist/esm-node/runtime/plugin.mjs +14 -118
- package/dist/esm-node/runtime/plugin.node.mjs +33 -114
- package/dist/esm-node/runtime/pluginShared.mjs +41 -0
- 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/rsc/CompositeComponent.mjs +18 -13
- 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 +62 -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/treeGetter.mjs +35 -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/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 -33
- 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 +10 -0
- package/dist/types/cli/tanstackTypes.d.ts +3 -31
- package/dist/types/runtime/blockingSubscribe.d.ts +3 -0
- package/dist/types/runtime/clientBasepath.d.ts +1 -0
- package/dist/types/runtime/clientHydration.d.ts +19 -0
- package/dist/types/runtime/dataMutation.d.ts +3 -12
- package/dist/types/runtime/formData.d.ts +23 -0
- package/dist/types/runtime/plugin.d.ts +1 -1
- package/dist/types/runtime/plugin.node.d.ts +1 -1
- package/dist/types/runtime/{pluginCore.d.ts → pluginShared.d.ts} +14 -0
- 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 +75 -0
- package/dist/types/runtime/routeTree.d.ts +1 -9
- package/dist/types/runtime/rsc/CompositeComponent.d.ts +1 -2
- package/dist/types/runtime/rsc/RscNodeRenderer.d.ts +2 -3
- 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 +10 -0
- package/dist/types/runtime/rsc/payloadRouter.d.ts +2 -10
- package/dist/types/runtime/rsc/payloadRoutes.d.ts +43 -0
- package/dist/types/runtime/rsc/payloadStorage.d.ts +5 -0
- package/dist/types/runtime/rsc/shared.d.ts +19 -0
- package/dist/types/runtime/rsc/treeGetter.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 +43 -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 +3 -46
- package/dist/types/runtime/utils.d.ts +1 -22
- package/package.json +30 -9
- package/rstest.config.mts +1 -0
- package/src/cli/artifacts.ts +255 -0
- package/src/cli/index.ts +6 -246
- package/src/cli/tanstackTypes/canonicalRoutes.ts +157 -0
- package/src/cli/tanstackTypes/shared.ts +119 -0
- package/src/cli/tanstackTypes/source.ts +405 -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 +151 -0
- package/src/runtime/dataMutation.tsx +9 -306
- package/src/runtime/formData.ts +153 -0
- package/src/runtime/loaderBridge.ts +8 -3
- package/src/runtime/plugin.node.tsx +60 -284
- package/src/runtime/plugin.tsx +21 -257
- package/src/runtime/pluginShared.ts +112 -0
- 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/rsc/CompositeComponent.tsx +29 -20
- package/src/runtime/rsc/RscNodeRenderer.tsx +9 -27
- 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 +97 -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/treeGetter.tsx +52 -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 +4 -2
- package/src/runtime/submitAction.ts +194 -0
- package/src/runtime/types.ts +14 -51
- package/src/runtime/utils.tsx +72 -108
- package/src/types/react-server-dom-rspack.d.ts +56 -0
- package/tests/castRatchet.test.ts +85 -0
- package/tests/router/dataMutation.test.tsx +59 -0
- package/tests/router/fixtures/router-gen.golden.txt +72 -0
- package/tests/router/loaderBridge.test.ts +21 -0
- package/tests/router/routeTree.test.ts +46 -11
- package/tests/router/rsc.test.tsx +189 -0
- package/tests/router/ssrPreload.test.ts +30 -0
- package/tests/router/tanstackTypes.test.ts +254 -1
- package/dist/esm/runtime/pluginCore.mjs +0 -14
- package/dist/esm-node/runtime/pluginCore.mjs +0 -15
- package/src/runtime/pluginCore.ts +0 -56
|
@@ -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,133 +42,37 @@ 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,
|
|
73
|
+
const _basename = '/' === baseUrl ? (0, external_pluginShared_js_namespaceObject.joinBasename)(baseUrl, basename || '') : baseUrl;
|
|
170
74
|
const rawRequest = request.raw;
|
|
171
|
-
const initialHref = createGetSsrHref(rawRequest);
|
|
75
|
+
const initialHref = (0, external_ssrManagedTags_js_namespaceObject.createGetSsrHref)(rawRequest);
|
|
172
76
|
const isRSCNavigation = enableRsc && 'true' === rawRequest.headers.get('x-rsc-tree');
|
|
173
77
|
const requestContext = (0, node_namespaceObject.createRequestContext)(context.ssrContext?.loaderContext);
|
|
174
78
|
const controller = new AbortController();
|
|
@@ -212,7 +116,8 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
212
116
|
} : {}
|
|
213
117
|
});
|
|
214
118
|
const serverRouter = tanstackRouter;
|
|
215
|
-
|
|
119
|
+
if (enableRsc) (0, payloadStorage_js_namespaceObject.setTanstackRscRouter)(serverRouter);
|
|
120
|
+
await (0, external_ssrManagedTags_js_namespaceObject.attachServerSsrUtils)(serverRouter);
|
|
216
121
|
const end = (0, time_namespaceObject.time)();
|
|
217
122
|
try {
|
|
218
123
|
await tanstackRouter.load({
|
|
@@ -229,7 +134,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
229
134
|
} catch {}
|
|
230
135
|
return interrupt(isRSCNavigation ? (0, payloadRouter_js_namespaceObject.handleTanstackRscRedirect)(resolved.headers, _basename, resolved.status) : resolved);
|
|
231
136
|
}
|
|
232
|
-
const routerErrors = collectRouterErrors(tanstackRouter);
|
|
137
|
+
const routerErrors = (0, external_ssrManagedTags_js_namespaceObject.collectRouterErrors)(tanstackRouter);
|
|
233
138
|
if (routerErrors && 'clientRender' === loaderFailureMode) {
|
|
234
139
|
context.ssrContext?.response?.status(200);
|
|
235
140
|
try {
|
|
@@ -237,17 +142,17 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
237
142
|
} catch {}
|
|
238
143
|
throw Object.values(routerErrors)[0];
|
|
239
144
|
}
|
|
240
|
-
await preloadMatchedRouteComponents(serverRouter);
|
|
145
|
+
await (0, external_ssrPreload_js_namespaceObject.preloadMatchedRouteComponents)(serverRouter);
|
|
241
146
|
context.ssrContext?.response?.status(tanstackRouter.state.statusCode);
|
|
242
147
|
await serverRouter.serverSsr?.dehydrate?.();
|
|
243
|
-
if (
|
|
244
|
-
await waitForRouterSerialization(serverRouter);
|
|
245
|
-
setTanstackRscServerPayload((0, payloadRouter_js_namespaceObject.createTanstackRscServerPayload)(serverRouter, {
|
|
246
|
-
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
|
|
247
152
|
}));
|
|
248
153
|
}
|
|
249
154
|
const ssrScriptTags = serverRouter.serverSsr?.takeBufferedScripts?.();
|
|
250
|
-
const hydrationScripts = routerManagedTagsToHtml(ssrScriptTags);
|
|
155
|
+
const hydrationScripts = (0, external_ssrManagedTags_js_namespaceObject.routerManagedTagsToHtml)(ssrScriptTags);
|
|
251
156
|
const matchedRouteIds = (0, external_routeTree_js_namespaceObject.getModernRouteIdsFromMatches)(serverRouter);
|
|
252
157
|
const routerServerSnapshot = (0, external_lifecycle_js_namespaceObject.createRouterServerSnapshot)({
|
|
253
158
|
framework: 'tanstack',
|
|
@@ -277,7 +182,20 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
277
182
|
});
|
|
278
183
|
});
|
|
279
184
|
api.wrapRoot((App)=>{
|
|
280
|
-
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)=>{
|
|
281
199
|
const context = (0, external_react_namespaceObject.useContext)(context_namespaceObject.InternalRuntimeContext);
|
|
282
200
|
const router = (0, external_lifecycle_js_namespaceObject.getRouterRuntimeState)(context)?.instance;
|
|
283
201
|
if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
|
|
@@ -290,6 +208,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
290
208
|
children: routerWrapper
|
|
291
209
|
}) : routerWrapper;
|
|
292
210
|
};
|
|
211
|
+
};
|
|
293
212
|
return getRouteApp();
|
|
294
213
|
});
|
|
295
214
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
getFinalRouteConfig: ()=>getFinalRouteConfig,
|
|
33
|
+
getMergedRouterConfig: ()=>getMergedRouterConfig,
|
|
34
|
+
getTanstackRouteConfig: ()=>getTanstackRouteConfig,
|
|
35
|
+
joinBasename: ()=>joinBasename
|
|
36
|
+
});
|
|
37
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
38
|
+
const merge_namespaceObject = require("@modern-js/runtime-utils/merge");
|
|
39
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
40
|
+
function getMergedRouterConfig(api, userConfig) {
|
|
41
|
+
const pluginConfig = api.getRuntimeConfig();
|
|
42
|
+
return (0, merge_namespaceObject.merge)(pluginConfig.router || {}, userConfig);
|
|
43
|
+
}
|
|
44
|
+
function getFinalRouteConfig(mergedConfig) {
|
|
45
|
+
return {
|
|
46
|
+
routes: (0, context_namespaceObject.getGlobalRoutes)(),
|
|
47
|
+
globalApp: (0, context_namespaceObject.getGlobalLayoutApp)(),
|
|
48
|
+
...mergedConfig.routesConfig
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function getTanstackRouteConfig(api, userConfig) {
|
|
52
|
+
const mergedConfig = getMergedRouterConfig(api, userConfig);
|
|
53
|
+
const finalRouteConfig = getFinalRouteConfig(mergedConfig);
|
|
54
|
+
return {
|
|
55
|
+
mergedConfig,
|
|
56
|
+
finalRouteConfig,
|
|
57
|
+
hasConfiguredRoutes: Boolean(finalRouteConfig.routes) || Boolean(mergedConfig.createRoutes)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function createTanstackRouteObjects({ hooks, routeConfig, ssrMode }) {
|
|
61
|
+
const { mergedConfig, finalRouteConfig } = routeConfig;
|
|
62
|
+
const routeObjects = mergedConfig.createRoutes ? mergedConfig.createRoutes() : (0, external_utils_js_namespaceObject.createTanstackRouteObjectsFromConfig)({
|
|
63
|
+
routesConfig: finalRouteConfig,
|
|
64
|
+
ssrMode
|
|
65
|
+
}) || [];
|
|
66
|
+
return hooks.modifyRoutes.call(routeObjects);
|
|
67
|
+
}
|
|
68
|
+
function joinBasename(baseUrl, basename) {
|
|
69
|
+
const base = baseUrl || '/';
|
|
70
|
+
const normalizedBase = base.startsWith('/') ? base : `/${base}`;
|
|
71
|
+
const trimmedBase = normalizedBase.length > 1 ? normalizedBase.replace(/\/+$/g, '') : normalizedBase;
|
|
72
|
+
const trimmedBasename = basename.replace(/^\/+|\/+$/g, '');
|
|
73
|
+
if (!trimmedBasename) return trimmedBase || '/';
|
|
74
|
+
return `${trimmedBase}/${trimmedBasename}`.replace(/\/{2,}/g, '/');
|
|
75
|
+
}
|
|
76
|
+
exports.createTanstackRouteObjects = __webpack_exports__.createTanstackRouteObjects;
|
|
77
|
+
exports.getFinalRouteConfig = __webpack_exports__.getFinalRouteConfig;
|
|
78
|
+
exports.getMergedRouterConfig = __webpack_exports__.getMergedRouterConfig;
|
|
79
|
+
exports.getTanstackRouteConfig = __webpack_exports__.getTanstackRouteConfig;
|
|
80
|
+
exports.joinBasename = __webpack_exports__.joinBasename;
|
|
81
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
82
|
+
"createTanstackRouteObjects",
|
|
83
|
+
"getFinalRouteConfig",
|
|
84
|
+
"getMergedRouterConfig",
|
|
85
|
+
"getTanstackRouteConfig",
|
|
86
|
+
"joinBasename"
|
|
87
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
88
|
+
Object.defineProperty(exports, '__esModule', {
|
|
89
|
+
value: true
|
|
90
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
pickRouteModuleComponent: ()=>pickRouteModuleComponent,
|
|
32
|
+
toErrorComponent: ()=>toErrorComponent,
|
|
33
|
+
toPendingComponent: ()=>toPendingComponent,
|
|
34
|
+
toRouteComponent: ()=>toRouteComponent
|
|
35
|
+
});
|
|
36
|
+
const external_react_namespaceObject = require("react");
|
|
37
|
+
function pickRouteModuleComponent(routeModule, seen = new Set()) {
|
|
38
|
+
if ('function' == typeof routeModule || routeModule && 'object' == typeof routeModule && '$$typeof' in routeModule) return routeModule;
|
|
39
|
+
if (!routeModule || 'object' != typeof routeModule) return;
|
|
40
|
+
if (seen.has(routeModule)) return;
|
|
41
|
+
seen.add(routeModule);
|
|
42
|
+
const module = routeModule;
|
|
43
|
+
for (const candidate of [
|
|
44
|
+
module.default,
|
|
45
|
+
module.Component
|
|
46
|
+
]){
|
|
47
|
+
const component = pickRouteModuleComponent(candidate, seen);
|
|
48
|
+
if (component) return component;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function createServerLazyImportComponent(lazyImport, fallbackComponent) {
|
|
52
|
+
if ("u" > typeof document) return fallbackComponent;
|
|
53
|
+
let resolvedComponent;
|
|
54
|
+
let pendingLoad;
|
|
55
|
+
const load = async ()=>{
|
|
56
|
+
if (resolvedComponent) return resolvedComponent;
|
|
57
|
+
const routeModule = await lazyImport();
|
|
58
|
+
const component = pickRouteModuleComponent(routeModule);
|
|
59
|
+
if (component) resolvedComponent = component;
|
|
60
|
+
return resolvedComponent;
|
|
61
|
+
};
|
|
62
|
+
const Component = (props)=>{
|
|
63
|
+
if (resolvedComponent) return (0, external_react_namespaceObject.createElement)(resolvedComponent, props);
|
|
64
|
+
pendingLoad ||= load();
|
|
65
|
+
throw pendingLoad;
|
|
66
|
+
};
|
|
67
|
+
Component.load = load;
|
|
68
|
+
Component.preload = load;
|
|
69
|
+
return Component;
|
|
70
|
+
}
|
|
71
|
+
function toRouteComponent(routeObject, options = {}) {
|
|
72
|
+
const route = routeObject;
|
|
73
|
+
const lazyImport = 'function' == typeof route.lazyImport ? route.lazyImport : void 0;
|
|
74
|
+
const routeComponent = route.Component || route.component;
|
|
75
|
+
const fallbackComponent = routeComponent ? routeComponent : route.element ? ()=>route.element : void 0;
|
|
76
|
+
if (lazyImport && fallbackComponent) return createServerLazyImportComponent(lazyImport, fallbackComponent);
|
|
77
|
+
if (routeComponent) return routeComponent;
|
|
78
|
+
const element = route.element;
|
|
79
|
+
if (element) return ()=>element;
|
|
80
|
+
}
|
|
81
|
+
function toErrorComponent(routeObject) {
|
|
82
|
+
const route = routeObject;
|
|
83
|
+
if (route.ErrorBoundary) return route.ErrorBoundary;
|
|
84
|
+
if (route.errorElement) return ()=>route.errorElement;
|
|
85
|
+
}
|
|
86
|
+
function toPendingComponent(routeObject) {
|
|
87
|
+
const route = routeObject;
|
|
88
|
+
return route.HydrateFallback || route.pendingComponent || void 0;
|
|
89
|
+
}
|
|
90
|
+
exports.pickRouteModuleComponent = __webpack_exports__.pickRouteModuleComponent;
|
|
91
|
+
exports.toErrorComponent = __webpack_exports__.toErrorComponent;
|
|
92
|
+
exports.toPendingComponent = __webpack_exports__.toPendingComponent;
|
|
93
|
+
exports.toRouteComponent = __webpack_exports__.toRouteComponent;
|
|
94
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
95
|
+
"pickRouteModuleComponent",
|
|
96
|
+
"toErrorComponent",
|
|
97
|
+
"toPendingComponent",
|
|
98
|
+
"toRouteComponent"
|
|
99
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
100
|
+
Object.defineProperty(exports, '__esModule', {
|
|
101
|
+
value: true
|
|
102
|
+
});
|