@bleedingdev/modern-js-plugin-tanstack 3.2.0-ultramodern.99 → 3.4.0-ultramodern.0
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/index.js +80 -34
- package/dist/cjs/cli/routeSplitting.js +13 -41
- package/dist/cjs/cli/tanstackTypes.js +114 -200
- package/dist/cjs/cli.js +12 -8
- package/dist/cjs/runtime/basepathRewrite.js +12 -8
- package/dist/cjs/runtime/dataMutation.js +9 -5
- package/dist/cjs/runtime/hooks.js +20 -19
- package/dist/cjs/runtime/hydrationBoundary.js +12 -7
- package/dist/cjs/runtime/index.js +66 -54
- package/dist/cjs/runtime/lifecycle.js +21 -91
- package/dist/cjs/runtime/loaderBridge.js +173 -0
- package/dist/cjs/runtime/outlet.js +58 -0
- package/dist/cjs/runtime/plugin.js +190 -110
- package/dist/cjs/runtime/plugin.node.js +25 -40
- package/dist/cjs/runtime/plugin.worker.js +9 -5
- package/dist/cjs/runtime/pluginCore.js +55 -0
- package/dist/cjs/runtime/prefetchLink.js +10 -6
- package/dist/cjs/runtime/register.js +56 -0
- package/dist/cjs/runtime/routeTree.js +30 -212
- package/dist/cjs/runtime/router.js +41 -0
- package/dist/cjs/runtime/rsc/ClientSlot.js +9 -5
- package/dist/cjs/runtime/rsc/CompositeComponent.js +9 -5
- package/dist/cjs/runtime/rsc/ReplayableStream.js +14 -9
- package/dist/cjs/runtime/rsc/RscNodeRenderer.js +9 -5
- package/dist/cjs/runtime/rsc/SlotContext.js +9 -5
- package/dist/cjs/runtime/rsc/client.js +9 -5
- package/dist/cjs/runtime/rsc/createRscProxy.js +9 -5
- package/dist/cjs/runtime/rsc/index.js +9 -5
- package/dist/cjs/runtime/rsc/payloadRouter.js +44 -6
- package/dist/cjs/runtime/rsc/server.js +9 -5
- package/dist/cjs/runtime/rsc/slotUsageSanitizer.js +9 -5
- package/dist/cjs/runtime/rsc/symbols.js +20 -15
- package/dist/cjs/runtime/state.js +45 -0
- package/dist/cjs/runtime/types.js +13 -9
- package/dist/cjs/runtime/utils.js +9 -11
- package/dist/cjs/runtime.js +9 -5
- package/dist/esm/cli/index.mjs +73 -28
- package/dist/esm/cli/routeSplitting.mjs +1 -30
- package/dist/esm/cli/tanstackTypes.mjs +100 -190
- package/dist/esm/runtime/hooks.mjs +1 -8
- package/dist/esm/runtime/hydrationBoundary.mjs +3 -2
- package/dist/esm/runtime/index.mjs +4 -2
- package/dist/esm/runtime/lifecycle.mjs +1 -82
- package/dist/esm/runtime/loaderBridge.mjs +114 -0
- package/dist/esm/runtime/outlet.mjs +17 -0
- package/dist/esm/runtime/plugin.mjs +183 -107
- package/dist/esm/runtime/plugin.node.mjs +19 -38
- package/dist/esm/runtime/pluginCore.mjs +14 -0
- package/dist/esm/runtime/prefetchLink.mjs +1 -1
- package/dist/esm/runtime/register.mjs +18 -0
- package/dist/esm/runtime/routeTree.mjs +15 -198
- package/dist/esm/runtime/router.mjs +2 -0
- package/dist/esm/runtime/rsc/payloadRouter.mjs +35 -1
- package/dist/esm/runtime/state.mjs +7 -0
- package/dist/esm/runtime/utils.mjs +0 -6
- package/dist/esm-node/cli/index.mjs +73 -28
- package/dist/esm-node/cli/routeSplitting.mjs +1 -30
- package/dist/esm-node/cli/tanstackTypes.mjs +100 -190
- package/dist/esm-node/runtime/hooks.mjs +1 -8
- package/dist/esm-node/runtime/hydrationBoundary.mjs +3 -2
- package/dist/esm-node/runtime/index.mjs +4 -2
- package/dist/esm-node/runtime/lifecycle.mjs +1 -82
- package/dist/esm-node/runtime/loaderBridge.mjs +115 -0
- package/dist/esm-node/runtime/outlet.mjs +18 -0
- package/dist/esm-node/runtime/plugin.mjs +183 -107
- package/dist/esm-node/runtime/plugin.node.mjs +19 -38
- package/dist/esm-node/runtime/pluginCore.mjs +15 -0
- package/dist/esm-node/runtime/prefetchLink.mjs +1 -1
- package/dist/esm-node/runtime/register.mjs +19 -0
- package/dist/esm-node/runtime/routeTree.mjs +15 -198
- package/dist/esm-node/runtime/router.mjs +3 -0
- package/dist/esm-node/runtime/rsc/payloadRouter.mjs +35 -1
- package/dist/esm-node/runtime/state.mjs +8 -0
- package/dist/esm-node/runtime/utils.mjs +0 -6
- package/dist/types/cli/index.d.ts +11 -2
- package/dist/types/cli/routeSplitting.d.ts +6 -15
- package/dist/types/cli/tanstackTypes.d.ts +21 -1
- package/dist/types/runtime/hooks.d.ts +8 -33
- package/dist/types/runtime/index.d.ts +6 -3
- package/dist/types/runtime/lifecycle.d.ts +7 -22
- package/dist/types/runtime/loaderBridge.d.ts +48 -0
- package/dist/types/runtime/outlet.d.ts +2 -0
- package/dist/types/runtime/plugin.d.ts +1 -14
- package/dist/types/runtime/plugin.node.d.ts +1 -14
- package/dist/types/runtime/pluginCore.d.ts +21 -0
- package/dist/types/runtime/register.d.ts +9 -0
- package/dist/types/runtime/routeTree.d.ts +0 -2
- package/dist/types/runtime/router.d.ts +14 -0
- package/dist/types/runtime/state.d.ts +16 -0
- package/dist/types/runtime/types.d.ts +7 -53
- package/package.json +40 -38
- package/rstest.config.mts +6 -0
- package/src/cli/index.ts +146 -24
- package/src/cli/routeSplitting.ts +6 -44
- package/src/cli/tanstackTypes.ts +203 -208
- package/src/runtime/hooks.ts +10 -27
- package/src/runtime/hydrationBoundary.tsx +5 -5
- package/src/runtime/index.tsx +12 -14
- package/src/runtime/lifecycle.ts +16 -151
- package/src/runtime/loaderBridge.ts +257 -0
- package/src/runtime/outlet.tsx +48 -0
- package/src/runtime/plugin.node.tsx +28 -83
- package/src/runtime/plugin.tsx +350 -202
- package/src/runtime/pluginCore.ts +48 -0
- package/src/runtime/prefetchLink.tsx +1 -1
- package/src/runtime/register.ts +58 -0
- package/src/runtime/routeTree.ts +41 -365
- package/src/runtime/router.ts +15 -0
- package/src/runtime/rsc/payloadRouter.ts +45 -2
- package/src/runtime/ssr-shim.d.ts +1 -3
- package/src/runtime/state.ts +29 -0
- package/src/runtime/types.ts +20 -67
- package/src/runtime/utils.tsx +3 -7
- package/tests/router/cli.test.ts +373 -31
- package/tests/router/hooks.test.ts +26 -0
- package/tests/router/loaderBridge.test.ts +211 -0
- package/tests/router/packageSurface.test.ts +24 -0
- package/tests/router/prefetchLink.test.tsx +43 -7
- package/tests/router/register.test.ts +46 -0
- package/tests/router/routeTree.test.ts +176 -139
- package/tests/router/rsc.test.tsx +70 -0
- package/tests/router/tanstackTypes.test.ts +395 -7
- package/dist/cjs/runtime/DefaultNotFound.js +0 -47
- package/dist/esm/runtime/DefaultNotFound.mjs +0 -13
- package/dist/esm-node/runtime/DefaultNotFound.mjs +0 -14
- package/dist/types/runtime/DefaultNotFound.d.ts +0 -2
- package/src/runtime/DefaultNotFound.tsx +0 -15
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -33,24 +37,13 @@ var __webpack_require__ = {};
|
|
|
33
37
|
var __webpack_exports__ = {};
|
|
34
38
|
__webpack_require__.r(__webpack_exports__);
|
|
35
39
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
collectCanonicalRoutesForEntry: ()=>collectCanonicalRoutesForEntry,
|
|
41
|
+
generateTanstackRouterTypesSourceForEntry: ()=>generateTanstackRouterTypesSourceForEntry
|
|
38
42
|
});
|
|
43
|
+
const cli_namespaceObject = require("@modern-js/runtime/cli");
|
|
39
44
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
40
45
|
const external_path_namespaceObject = require("path");
|
|
41
46
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
42
|
-
const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
|
|
43
|
-
const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
|
|
44
|
-
const forbidList = new Set(`${reservedWords} ${builtins}`.split(' '));
|
|
45
|
-
function makeLegalIdentifier(str) {
|
|
46
|
-
const identifier = str.replace(/-(\w)/g, (_, letter)=>letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, '_');
|
|
47
|
-
if (/\d/.test(identifier[0]) || forbidList.has(identifier)) return `_${identifier}`;
|
|
48
|
-
return identifier || '_';
|
|
49
|
-
}
|
|
50
|
-
function getPathWithoutExt(filename) {
|
|
51
|
-
const extname = external_path_default().extname(filename);
|
|
52
|
-
return extname ? filename.slice(0, -extname.length) : filename;
|
|
53
|
-
}
|
|
54
47
|
const JS_OR_TS_EXTS = [
|
|
55
48
|
'.js',
|
|
56
49
|
'.jsx',
|
|
@@ -75,7 +68,7 @@ function toTanstackPath(pathname) {
|
|
|
75
68
|
}
|
|
76
69
|
async function resolveFileNoExt(inputNoExtPath) {
|
|
77
70
|
const file = (0, utils_namespaceObject.findExists)(JS_OR_TS_EXTS.map((ext)=>`${inputNoExtPath}${ext}`));
|
|
78
|
-
return file ? getPathWithoutExt(file) : null;
|
|
71
|
+
return file ? (0, cli_namespaceObject.getPathWithoutExt)(file) : null;
|
|
79
72
|
}
|
|
80
73
|
function quote(str) {
|
|
81
74
|
return JSON.stringify(str);
|
|
@@ -116,16 +109,78 @@ function createRouteStaticDataSnippet(opts) {
|
|
|
116
109
|
if (!staticDataLines.length) return null;
|
|
117
110
|
return `staticData: createRouteStaticData({\n ${staticDataLines.join('\n ')}\n }),`;
|
|
118
111
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
112
|
+
const LOCALE_PARAM_SEGMENTS = new Set([
|
|
113
|
+
':lang',
|
|
114
|
+
':locale',
|
|
115
|
+
':language',
|
|
116
|
+
'$lang',
|
|
117
|
+
'$locale',
|
|
118
|
+
'$language'
|
|
119
|
+
]);
|
|
120
|
+
function paramsTypeForCanonicalPath(canonicalPath) {
|
|
121
|
+
const fields = [];
|
|
122
|
+
for (const segment of canonicalPath.split('/'))if (segment) {
|
|
123
|
+
if ('*' === segment || '$' === segment) {
|
|
124
|
+
fields.push("'_splat'?: string");
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (segment.startsWith('{-$') && segment.endsWith('}')) {
|
|
128
|
+
fields.push(`${JSON.stringify(segment.slice(3, -1))}?: string`);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (segment.startsWith('$')) {
|
|
132
|
+
fields.push(`${JSON.stringify(segment.slice(1))}: string`);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (segment.startsWith(':')) {
|
|
136
|
+
const optional = segment.endsWith('?');
|
|
137
|
+
const name = segment.slice(1, optional ? void 0 : segment.length);
|
|
138
|
+
fields.push(`${JSON.stringify(optional ? name.slice(0, -1) : name)}${optional ? '?' : ''}: string`);
|
|
139
|
+
}
|
|
128
140
|
}
|
|
141
|
+
return fields.length > 0 ? `{ ${fields.join('; ')} }` : 'Record<string, never>';
|
|
142
|
+
}
|
|
143
|
+
function collectCanonicalRoutesForEntry(routes, options = {}) {
|
|
144
|
+
const { localeParamHeuristic = true } = options;
|
|
145
|
+
const canonicalParams = new Map();
|
|
146
|
+
let hasI18nSurface = false;
|
|
147
|
+
const normalizeJoined = (joined)=>{
|
|
148
|
+
const collapsed = joined.replace(/\/+/g, '/');
|
|
149
|
+
const withLeading = collapsed.startsWith('/') ? collapsed : `/${collapsed}`;
|
|
150
|
+
return withLeading.length > 1 ? withLeading.replace(/\/+$/, '') : withLeading;
|
|
151
|
+
};
|
|
152
|
+
const record = (canonicalPath)=>{
|
|
153
|
+
const normalized = normalizeJoined(canonicalPath || '/');
|
|
154
|
+
const key = toTanstackPath(normalized);
|
|
155
|
+
if (!canonicalParams.has(key)) canonicalParams.set(key, paramsTypeForCanonicalPath(normalized));
|
|
156
|
+
};
|
|
157
|
+
const visit = (route, parentPath)=>{
|
|
158
|
+
let currentPath = parentPath;
|
|
159
|
+
if ('string' == typeof route.modernCanonicalPath) {
|
|
160
|
+
hasI18nSurface = true;
|
|
161
|
+
currentPath = normalizeJoined(route.modernCanonicalPath);
|
|
162
|
+
} else if ('string' == typeof route.path && route.path.length > 0) {
|
|
163
|
+
const segments = route.path.replace(/\[(.+?)\]/g, ':$1').split('/').filter(Boolean);
|
|
164
|
+
if (localeParamHeuristic && '' === parentPath && LOCALE_PARAM_SEGMENTS.has(segments[0])) {
|
|
165
|
+
hasI18nSurface = true;
|
|
166
|
+
segments.shift();
|
|
167
|
+
}
|
|
168
|
+
currentPath = segments.length ? normalizeJoined(`${parentPath}/${segments.join('/')}`) : parentPath;
|
|
169
|
+
}
|
|
170
|
+
const children = route.children;
|
|
171
|
+
if (children && children.length > 0) {
|
|
172
|
+
for (const child of children)visit(child, currentPath);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
record(currentPath || '/');
|
|
176
|
+
};
|
|
177
|
+
const rootModern = routes.find((route)=>route.isRoot);
|
|
178
|
+
const topLevel = rootModern ? rootModern.children ?? [] : routes;
|
|
179
|
+
for (const route of topLevel)visit(route, '');
|
|
180
|
+
if (!hasI18nSurface || 0 === canonicalParams.size) return null;
|
|
181
|
+
return Object.fromEntries([
|
|
182
|
+
...canonicalParams.entries()
|
|
183
|
+
].sort(([a], [b])=>a.localeCompare(b)));
|
|
129
184
|
}
|
|
130
185
|
async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
131
186
|
const { appContext, entryName, generatedDirName = 'modern-tanstack', routes } = opts;
|
|
@@ -135,12 +190,30 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
135
190
|
const imports = [];
|
|
136
191
|
const statements = [];
|
|
137
192
|
const loaderImportMap = new Map();
|
|
193
|
+
const componentImportMap = new Map();
|
|
138
194
|
const searchContractImportMap = new Map();
|
|
139
195
|
const usedRouteVarNames = new Set();
|
|
140
196
|
let loaderIndex = 0;
|
|
197
|
+
let componentIndex = 0;
|
|
141
198
|
let validateSearchIndex = 0;
|
|
142
199
|
let loaderDepsIndex = 0;
|
|
143
200
|
let routeIndex = 0;
|
|
201
|
+
const getImportNameForComponent = (componentPath)=>{
|
|
202
|
+
if ('string' != typeof componentPath || 0 === componentPath.length) return Promise.resolve(null);
|
|
203
|
+
let pendingImportName = componentImportMap.get(componentPath);
|
|
204
|
+
if (!pendingImportName) {
|
|
205
|
+
pendingImportName = (async ()=>{
|
|
206
|
+
const resolvedNoExt = await resolveRouteModuleNoExt(componentPath);
|
|
207
|
+
if (!resolvedNoExt) return null;
|
|
208
|
+
const relImport = normalizeRelativeImport(external_path_default().relative(outDir, resolvedNoExt));
|
|
209
|
+
const componentName = `component_${componentIndex++}`;
|
|
210
|
+
imports.push(`import ${componentName} from ${quote(relImport)};`);
|
|
211
|
+
return componentName;
|
|
212
|
+
})();
|
|
213
|
+
componentImportMap.set(componentPath, pendingImportName);
|
|
214
|
+
}
|
|
215
|
+
return pendingImportName;
|
|
216
|
+
};
|
|
144
217
|
const resolveRouteModuleNoExt = async (aliasedNoExtPath)=>{
|
|
145
218
|
const prefix = `${appContext.internalSrcAlias}/`;
|
|
146
219
|
let absNoExt;
|
|
@@ -196,7 +269,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
196
269
|
};
|
|
197
270
|
const createRouteVarName = (route)=>{
|
|
198
271
|
const id = route.id;
|
|
199
|
-
const base = id ? makeLegalIdentifier(id) : `r_${routeIndex++}`;
|
|
272
|
+
const base = id ? (0, cli_namespaceObject.makeLegalIdentifier)(id) : `r_${routeIndex++}`;
|
|
200
273
|
return reserveRouteVarName(`route_${base}`);
|
|
201
274
|
};
|
|
202
275
|
const buildRoute = async (opts)=>{
|
|
@@ -215,6 +288,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
215
288
|
const routeOpts = [
|
|
216
289
|
`getParentRoute: () => ${parentVar},`
|
|
217
290
|
];
|
|
291
|
+
const componentName = await getImportNameForComponent(route._component);
|
|
292
|
+
if (componentName) routeOpts.push(`component: ${componentName},`);
|
|
218
293
|
if (isPathlessLayout(route)) {
|
|
219
294
|
const id = route.id;
|
|
220
295
|
routeOpts.push(`id: ${quote(id || 'pathless')},`);
|
|
@@ -257,6 +332,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
257
332
|
route
|
|
258
333
|
})));
|
|
259
334
|
const rootOpts = [];
|
|
335
|
+
const rootComponentName = await getImportNameForComponent(rootModern?._component);
|
|
336
|
+
if (rootComponentName) rootOpts.push(`component: ${rootComponentName},`);
|
|
260
337
|
if (rootLoaderName) rootOpts.push(`loader: modernLoaderToTanstack({ hasSplat: false }, ${rootLoaderName}),`);
|
|
261
338
|
if (rootValidateSearchName) rootOpts.push(`validateSearch: ${rootValidateSearchName},`);
|
|
262
339
|
if (rootLoaderDepsName) rootOpts.push(`loaderDeps: ${rootLoaderDepsName},`);
|
|
@@ -265,178 +342,15 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
265
342
|
|
|
266
343
|
import {
|
|
267
344
|
createMemoryHistory,
|
|
268
|
-
modernTanstackRouterFastDefaults,
|
|
269
345
|
createRootRouteWithContext,
|
|
270
346
|
createRoute,
|
|
271
347
|
createRouter,
|
|
272
|
-
|
|
273
|
-
|
|
348
|
+
createRouteStaticData,
|
|
349
|
+
type ModernRouterContext,
|
|
350
|
+
modernLoaderToTanstack,
|
|
351
|
+
modernTanstackRouterFastDefaults,
|
|
274
352
|
} from '@modern-js/plugin-tanstack/runtime';
|
|
275
353
|
|
|
276
|
-
type ModernRouterContext = {
|
|
277
|
-
request?: Request;
|
|
278
|
-
requestContext?: unknown;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
function isResponse(value: unknown): value is Response {
|
|
282
|
-
return (
|
|
283
|
-
value != null &&
|
|
284
|
-
typeof value === 'object' &&
|
|
285
|
-
typeof (value as any).status === 'number' &&
|
|
286
|
-
typeof (value as any).headers === 'object'
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const redirectStatusCodes = new Set([301, 302, 303, 307, 308]);
|
|
291
|
-
function isRedirectResponse(res: Response) {
|
|
292
|
-
return redirectStatusCodes.has(res.status);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function throwTanstackRedirect(location: string) {
|
|
296
|
-
const target = location.length > 0 ? location : '/';
|
|
297
|
-
try {
|
|
298
|
-
void new URL(target);
|
|
299
|
-
throw redirect({ href: target });
|
|
300
|
-
} catch {
|
|
301
|
-
throw redirect({ to: target });
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function mapParamsForModernLoader(params: Record<string, string>, hasSplat: boolean) {
|
|
306
|
-
if (!hasSplat) {
|
|
307
|
-
return params;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const { _splat, ...rest } = params as any;
|
|
311
|
-
if (typeof _splat !== 'undefined') {
|
|
312
|
-
return { ...rest, '*': _splat };
|
|
313
|
-
}
|
|
314
|
-
return rest;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function createRouteStaticData(opts: {
|
|
318
|
-
modernRouteId?: string;
|
|
319
|
-
modernRouteAction?: unknown;
|
|
320
|
-
modernRouteLoader?: unknown;
|
|
321
|
-
}) {
|
|
322
|
-
const staticData: {
|
|
323
|
-
modernRouteId?: string;
|
|
324
|
-
modernRouteAction?: unknown;
|
|
325
|
-
modernRouteLoader?: unknown;
|
|
326
|
-
} = {};
|
|
327
|
-
|
|
328
|
-
if (typeof opts.modernRouteId === 'string' && opts.modernRouteId.length > 0) {
|
|
329
|
-
staticData.modernRouteId = opts.modernRouteId;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (typeof opts.modernRouteLoader !== 'undefined') {
|
|
333
|
-
staticData.modernRouteLoader = opts.modernRouteLoader;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (typeof opts.modernRouteAction !== 'undefined') {
|
|
337
|
-
staticData.modernRouteAction = opts.modernRouteAction;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return staticData;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function getLoaderSignal(ctx: any): AbortSignal {
|
|
344
|
-
const abortSignal = ctx?.abortController?.signal;
|
|
345
|
-
if (abortSignal instanceof AbortSignal) {
|
|
346
|
-
return abortSignal;
|
|
347
|
-
}
|
|
348
|
-
if (ctx?.signal instanceof AbortSignal) {
|
|
349
|
-
return ctx.signal;
|
|
350
|
-
}
|
|
351
|
-
return new AbortController().signal;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
function getLoaderHref(ctx: any): string {
|
|
355
|
-
if (typeof ctx?.location === 'string') {
|
|
356
|
-
return ctx.location;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
const publicHref = ctx?.location?.publicHref;
|
|
360
|
-
if (typeof publicHref === 'string') {
|
|
361
|
-
return publicHref;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
const href = ctx?.location?.href;
|
|
365
|
-
if (typeof href === 'string') {
|
|
366
|
-
return href;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
const urlHref = ctx?.location?.url?.href;
|
|
370
|
-
return typeof urlHref === 'string' ? urlHref : '';
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function getLoaderParams(ctx: any): Record<string, string> {
|
|
374
|
-
return typeof ctx?.params === 'object' && ctx.params !== null ? ctx.params : {};
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function handleModernLoaderResult<LoaderResult>(result: LoaderResult): LoaderResult {
|
|
378
|
-
if (isResponse(result)) {
|
|
379
|
-
if (isRedirectResponse(result)) {
|
|
380
|
-
const location = result.headers.get('Location') ?? '/';
|
|
381
|
-
throwTanstackRedirect(location);
|
|
382
|
-
}
|
|
383
|
-
if (result.status === 404) {
|
|
384
|
-
throw notFound();
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return result;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function handleModernLoaderError(err: unknown): never {
|
|
392
|
-
if (isResponse(err)) {
|
|
393
|
-
if (isRedirectResponse(err)) {
|
|
394
|
-
const location = err.headers.get('Location') ?? '/';
|
|
395
|
-
throwTanstackRedirect(location);
|
|
396
|
-
}
|
|
397
|
-
if (err.status === 404) {
|
|
398
|
-
throw notFound();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
throw err;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function modernLoaderToTanstack<TLoader extends (args: any) => any>(
|
|
406
|
-
opts: { hasSplat: boolean },
|
|
407
|
-
modernLoader: TLoader,
|
|
408
|
-
) {
|
|
409
|
-
type LoaderResult = Awaited<ReturnType<TLoader>>;
|
|
410
|
-
|
|
411
|
-
return (ctx: any): Promise<LoaderResult> => {
|
|
412
|
-
try {
|
|
413
|
-
const signal = getLoaderSignal(ctx);
|
|
414
|
-
const baseRequest: Request | undefined =
|
|
415
|
-
ctx?.context?.request instanceof Request ? ctx.context.request : undefined;
|
|
416
|
-
|
|
417
|
-
const href = getLoaderHref(ctx);
|
|
418
|
-
|
|
419
|
-
const request = baseRequest !== undefined
|
|
420
|
-
? new Request(baseRequest, { signal })
|
|
421
|
-
: new Request(href, { signal });
|
|
422
|
-
|
|
423
|
-
const params = mapParamsForModernLoader(getLoaderParams(ctx), opts.hasSplat);
|
|
424
|
-
|
|
425
|
-
return Promise.resolve(
|
|
426
|
-
(modernLoader as any)({
|
|
427
|
-
request,
|
|
428
|
-
params,
|
|
429
|
-
context: ctx?.context?.requestContext,
|
|
430
|
-
}),
|
|
431
|
-
)
|
|
432
|
-
.then((result: LoaderResult) => handleModernLoaderResult(result))
|
|
433
|
-
.catch(handleModernLoaderError);
|
|
434
|
-
} catch (err) {
|
|
435
|
-
handleModernLoaderError(err);
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
|
|
440
354
|
${imports.join('\n')}
|
|
441
355
|
|
|
442
356
|
export const rootRoute = createRootRouteWithContext<ModernRouterContext>()({
|
|
@@ -465,11 +379,11 @@ export const router = createRouter({
|
|
|
465
379
|
routerGenTs
|
|
466
380
|
};
|
|
467
381
|
}
|
|
382
|
+
exports.collectCanonicalRoutesForEntry = __webpack_exports__.collectCanonicalRoutesForEntry;
|
|
468
383
|
exports.generateTanstackRouterTypesSourceForEntry = __webpack_exports__.generateTanstackRouterTypesSourceForEntry;
|
|
469
|
-
exports.isTanstackRouterFrameworkEnabled = __webpack_exports__.isTanstackRouterFrameworkEnabled;
|
|
470
384
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
471
|
-
"
|
|
472
|
-
"
|
|
385
|
+
"collectCanonicalRoutesForEntry",
|
|
386
|
+
"generateTanstackRouterTypesSourceForEntry"
|
|
473
387
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
474
388
|
Object.defineProperty(exports, '__esModule', {
|
|
475
389
|
value: true
|
package/dist/cjs/cli.js
CHANGED
|
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
|
|
|
24
24
|
};
|
|
25
25
|
})();
|
|
26
26
|
(()=>{
|
|
27
|
-
__webpack_require__.d = (exports1,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
28
|
+
var define = (defs, kind)=>{
|
|
29
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
[kind]: defs[key]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
define(getters, "get");
|
|
35
|
+
define(values, "value");
|
|
32
36
|
};
|
|
33
37
|
})();
|
|
34
38
|
(()=>{
|
|
@@ -47,14 +51,14 @@ function __webpack_require__(moduleId) {
|
|
|
47
51
|
var __webpack_exports__ = {};
|
|
48
52
|
(()=>{
|
|
49
53
|
__webpack_require__.r(__webpack_exports__);
|
|
50
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
51
|
-
default: ()=>_cli_index__rspack_import_0_default.a
|
|
52
|
-
});
|
|
53
54
|
var _cli_index__rspack_import_0 = __webpack_require__("./cli/index");
|
|
54
55
|
var _cli_index__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(_cli_index__rspack_import_0);
|
|
55
56
|
var __rspack_reexport = {};
|
|
56
57
|
for(const __rspack_import_key in _cli_index__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_cli_index__rspack_import_0[__rspack_import_key];
|
|
57
58
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
59
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
60
|
+
default: ()=>_cli_index__rspack_import_0_default.a
|
|
61
|
+
});
|
|
58
62
|
})();
|
|
59
63
|
exports["default"] = __webpack_exports__["default"];
|
|
60
64
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -23,9 +27,6 @@ var __webpack_require__ = {};
|
|
|
23
27
|
})();
|
|
24
28
|
var __webpack_exports__ = {};
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
createModernBasepathRewrite: ()=>createModernBasepathRewrite
|
|
28
|
-
});
|
|
29
30
|
function normalizeBasepath(basepath) {
|
|
30
31
|
if (!basepath) return '/';
|
|
31
32
|
let normalized = basepath.startsWith('/') ? basepath : `/${basepath}`;
|
|
@@ -53,6 +54,9 @@ function createModernBasepathRewrite(basepath, caseSensitive = false) {
|
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
}
|
|
57
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
58
|
+
createModernBasepathRewrite: ()=>createModernBasepathRewrite
|
|
59
|
+
});
|
|
56
60
|
exports.createModernBasepathRewrite = __webpack_exports__.createModernBasepathRewrite;
|
|
57
61
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
58
62
|
"createModernBasepathRewrite"
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -24,33 +28,30 @@ var __webpack_require__ = {};
|
|
|
24
28
|
var __webpack_exports__ = {};
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
modifyRoutes: ()=>modifyRoutes,
|
|
28
|
-
onAfterCreateRouter: ()=>onAfterCreateRouter,
|
|
29
|
-
onAfterHydrateRouter: ()=>onAfterHydrateRouter,
|
|
30
|
-
onBeforeCreateRouter: ()=>onBeforeCreateRouter,
|
|
31
|
-
onBeforeCreateRoutes: ()=>onBeforeCreateRoutes,
|
|
32
|
-
onBeforeHydrateRouter: ()=>onBeforeHydrateRouter
|
|
31
|
+
modifyRoutes: ()=>context_namespaceObject.modifyRoutes,
|
|
32
|
+
onAfterCreateRouter: ()=>context_namespaceObject.onAfterCreateRouter,
|
|
33
|
+
onAfterHydrateRouter: ()=>context_namespaceObject.onAfterHydrateRouter,
|
|
34
|
+
onBeforeCreateRouter: ()=>context_namespaceObject.onBeforeCreateRouter,
|
|
35
|
+
onBeforeCreateRoutes: ()=>context_namespaceObject.onBeforeCreateRoutes,
|
|
36
|
+
onBeforeHydrateRouter: ()=>context_namespaceObject.onBeforeHydrateRouter,
|
|
37
|
+
routerProviderRegistryHooks: ()=>context_namespaceObject.routerProviderRegistryHooks
|
|
33
38
|
});
|
|
34
|
-
const
|
|
35
|
-
const modifyRoutes = (0, plugin_namespaceObject.createSyncHook)();
|
|
36
|
-
const onBeforeCreateRoutes = (0, plugin_namespaceObject.createSyncHook)();
|
|
37
|
-
const onBeforeCreateRouter = (0, plugin_namespaceObject.createSyncHook)();
|
|
38
|
-
const onAfterCreateRouter = (0, plugin_namespaceObject.createSyncHook)();
|
|
39
|
-
const onBeforeHydrateRouter = (0, plugin_namespaceObject.createSyncHook)();
|
|
40
|
-
const onAfterHydrateRouter = (0, plugin_namespaceObject.createSyncHook)();
|
|
39
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
41
40
|
exports.modifyRoutes = __webpack_exports__.modifyRoutes;
|
|
42
41
|
exports.onAfterCreateRouter = __webpack_exports__.onAfterCreateRouter;
|
|
43
42
|
exports.onAfterHydrateRouter = __webpack_exports__.onAfterHydrateRouter;
|
|
44
43
|
exports.onBeforeCreateRouter = __webpack_exports__.onBeforeCreateRouter;
|
|
45
44
|
exports.onBeforeCreateRoutes = __webpack_exports__.onBeforeCreateRoutes;
|
|
46
45
|
exports.onBeforeHydrateRouter = __webpack_exports__.onBeforeHydrateRouter;
|
|
46
|
+
exports.routerProviderRegistryHooks = __webpack_exports__.routerProviderRegistryHooks;
|
|
47
47
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
48
48
|
"modifyRoutes",
|
|
49
49
|
"onAfterCreateRouter",
|
|
50
50
|
"onAfterHydrateRouter",
|
|
51
51
|
"onBeforeCreateRouter",
|
|
52
52
|
"onBeforeCreateRoutes",
|
|
53
|
-
"onBeforeHydrateRouter"
|
|
53
|
+
"onBeforeHydrateRouter",
|
|
54
|
+
"routerProviderRegistryHooks"
|
|
54
55
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
55
56
|
Object.defineProperty(exports, '__esModule', {
|
|
56
57
|
value: true
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -29,10 +33,11 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
33
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
34
|
const external_react_namespaceObject = require("react");
|
|
31
35
|
function wrapTanstackSsrHydrationBoundary(routerContent, shouldWrap) {
|
|
32
|
-
|
|
36
|
+
if (shouldWrap) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Suspense, {
|
|
33
37
|
fallback: null,
|
|
34
38
|
children: routerContent
|
|
35
|
-
})
|
|
39
|
+
});
|
|
40
|
+
return routerContent;
|
|
36
41
|
}
|
|
37
42
|
exports.wrapTanstackSsrHydrationBoundary = __webpack_exports__.wrapTanstackSsrHydrationBoundary;
|
|
38
43
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|