@bleedingdev/modern-js-plugin-tanstack 3.9.0-ultramodern.2 → 3.9.0-ultramodern.20
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 +15 -1
- package/dist/cjs/cli/index.js +12 -0
- package/dist/cjs/cli/routeMetadata.js +131 -0
- package/dist/cjs/cli/tanstackTypes/canonicalRoutes.js +7 -7
- package/dist/cjs/cli/tanstackTypes/shared.js +0 -14
- package/dist/cjs/cli/tanstackTypes/source.js +27 -60
- package/dist/cjs/runtime/basepathRewrite.js +13 -6
- package/dist/cjs/runtime/lifecycle.js +6 -9
- package/dist/cjs/runtime/loaderBridge.js +10 -4
- package/dist/cjs/runtime/navigation.js +102 -0
- package/dist/cjs/runtime/plugin.js +7 -2
- package/dist/cjs/runtime/plugin.node.js +86 -64
- package/dist/cjs/runtime/prefetchLink.js +2 -7
- package/dist/cjs/runtime/register.js +0 -2
- package/dist/cjs/runtime/routeTree/construction.js +19 -59
- package/dist/cjs/runtime/routeTree/loaders.js +1 -1
- package/dist/cjs/runtime/routeTree/paths.js +0 -6
- package/dist/cjs/runtime/router.js +25 -9
- package/dist/cjs/runtime/ssrManagedTags.js +2 -12
- package/dist/cjs/runtime/state.js +2 -2
- package/dist/cjs/runtime/utils.js +3 -0
- package/dist/cjs/shared/routeDescriptor.js +60 -0
- package/dist/esm/cli/artifacts.mjs +13 -2
- package/dist/esm/cli/index.mjs +12 -9
- package/dist/esm/cli/routeMetadata.mjs +71 -0
- package/dist/esm/cli/tanstackTypes/canonicalRoutes.mjs +7 -7
- package/dist/esm/cli/tanstackTypes/shared.mjs +1 -9
- package/dist/esm/cli/tanstackTypes/source.mjs +28 -61
- package/dist/esm/runtime/basepathRewrite.mjs +10 -3
- package/dist/esm/runtime/lifecycle.mjs +1 -1
- package/dist/esm/runtime/loaderBridge.mjs +8 -5
- package/dist/esm/runtime/navigation.mjs +64 -0
- package/dist/esm/runtime/plugin.mjs +7 -2
- package/dist/esm/runtime/plugin.node.mjs +88 -66
- package/dist/esm/runtime/prefetchLink.mjs +1 -6
- package/dist/esm/runtime/register.mjs +0 -2
- package/dist/esm/runtime/routeTree/construction.mjs +19 -59
- package/dist/esm/runtime/routeTree/loaders.mjs +2 -2
- package/dist/esm/runtime/routeTree/paths.mjs +1 -4
- package/dist/esm/runtime/router.mjs +27 -11
- package/dist/esm/runtime/ssrManagedTags.mjs +1 -8
- package/dist/esm/runtime/state.mjs +1 -1
- package/dist/esm/runtime/utils.mjs +3 -0
- package/dist/esm/shared/routeDescriptor.mjs +22 -0
- package/dist/esm-node/cli/artifacts.mjs +13 -2
- package/dist/esm-node/cli/index.mjs +12 -9
- package/dist/esm-node/cli/routeMetadata.mjs +72 -0
- package/dist/esm-node/cli/tanstackTypes/canonicalRoutes.mjs +7 -7
- package/dist/esm-node/cli/tanstackTypes/shared.mjs +1 -9
- package/dist/esm-node/cli/tanstackTypes/source.mjs +28 -61
- package/dist/esm-node/runtime/basepathRewrite.mjs +10 -3
- package/dist/esm-node/runtime/lifecycle.mjs +1 -1
- package/dist/esm-node/runtime/loaderBridge.mjs +8 -5
- package/dist/esm-node/runtime/navigation.mjs +65 -0
- package/dist/esm-node/runtime/plugin.mjs +7 -2
- package/dist/esm-node/runtime/plugin.node.mjs +88 -66
- package/dist/esm-node/runtime/prefetchLink.mjs +1 -6
- package/dist/esm-node/runtime/register.mjs +0 -2
- package/dist/esm-node/runtime/routeTree/construction.mjs +19 -59
- package/dist/esm-node/runtime/routeTree/loaders.mjs +2 -2
- package/dist/esm-node/runtime/routeTree/paths.mjs +1 -4
- package/dist/esm-node/runtime/router.mjs +27 -11
- package/dist/esm-node/runtime/ssrManagedTags.mjs +1 -8
- package/dist/esm-node/runtime/state.mjs +1 -1
- package/dist/esm-node/runtime/utils.mjs +3 -0
- package/dist/esm-node/shared/routeDescriptor.mjs +23 -0
- package/dist/types/cli/artifacts.d.ts +13 -5
- package/dist/types/cli/index.d.ts +1 -1
- package/dist/types/cli/routeMetadata.d.ts +18 -0
- package/dist/types/cli/tanstackTypes/shared.d.ts +0 -2
- package/dist/types/runtime/basepathRewrite.d.ts +2 -1
- package/dist/types/runtime/lifecycle.d.ts +9 -2
- package/dist/types/runtime/loaderBridge.d.ts +1 -0
- package/dist/types/runtime/navigation.d.ts +4 -0
- package/dist/types/runtime/register.d.ts +1 -9
- package/dist/types/runtime/routeTree/paths.d.ts +0 -2
- package/dist/types/runtime/router.d.ts +2 -13
- package/dist/types/runtime/ssrManagedTags.d.ts +0 -1
- package/dist/types/runtime/ssrTypes.d.ts +0 -7
- package/dist/types/runtime/state.d.ts +1 -1
- package/dist/types/runtime/types.d.ts +2 -1
- package/dist/types/shared/routeDescriptor.d.ts +26 -0
- package/package.json +22 -19
- package/rstest.config.mts +2 -24
- package/src/cli/artifacts.ts +53 -6
- package/src/cli/index.ts +11 -2
- package/src/cli/routeMetadata.ts +121 -0
- package/src/cli/tanstackTypes/canonicalRoutes.ts +17 -12
- package/src/cli/tanstackTypes/shared.ts +0 -14
- package/src/cli/tanstackTypes/source.ts +42 -116
- package/src/runtime/basepathRewrite.ts +11 -2
- package/src/runtime/lifecycle.ts +14 -4
- package/src/runtime/loaderBridge.ts +9 -9
- package/src/runtime/navigation.ts +78 -0
- package/src/runtime/plugin.node.tsx +120 -93
- package/src/runtime/plugin.tsx +11 -1
- package/src/runtime/prefetchLink.tsx +1 -23
- package/src/runtime/register.ts +1 -12
- package/src/runtime/routeTree/construction.ts +32 -110
- package/src/runtime/routeTree/loaders.ts +2 -4
- package/src/runtime/routeTree/paths.ts +0 -6
- package/src/runtime/router.ts +25 -40
- package/src/runtime/ssrManagedTags.ts +0 -17
- package/src/runtime/ssrTypes.ts +0 -7
- package/src/runtime/state.ts +1 -1
- package/src/runtime/types.ts +2 -2
- package/src/runtime/utils.tsx +4 -1
- package/src/shared/routeDescriptor.ts +46 -0
- package/tests/router/cli.test.ts +148 -824
- package/tests/router/clientNavigation.ts +13 -0
- package/tests/router/dataMutation.test.tsx +17 -85
- package/tests/router/flightSerialization.roundtrip.test.tsx +9 -6
- package/tests/router/generateRouteArtifacts.test.ts +139 -27
- package/tests/router/loaderBridge.test.ts +0 -25
- package/tests/router/localisedIdentity.test.tsx +100 -0
- package/tests/router/prefetchLink.test.tsx +46 -21
- package/tests/router/prefetchLinkPreload.test.tsx +11 -32
- package/tests/router/routeHooks.test.ts +42 -105
- package/tests/router/routeMetadata.test.ts +171 -0
- package/tests/router/routeTree.test.ts +144 -836
- package/tests/router/rsc.test.tsx +131 -166
- package/tests/router/serverPlugin.test.ts +193 -1
- package/tests/router/tanstackTypes.test.ts +218 -963
- package/dist/esm/rslib-runtime~1.mjs +0 -18
- package/dist/esm-node/rslib-runtime~0.mjs +0 -19
- package/tests/realm-isolation.test.ts +0 -114
- package/tests/router/fastDefaults.test.ts +0 -32
- package/tests/router/fixtures/legacyRuntimeRouter.ts +0 -10
- package/tests/router/fixtures/rscDecoderSecurityChild.cjs +0 -162
- package/tests/router/hooks.test.ts +0 -40
- package/tests/router/hydrationBoundary.test.tsx +0 -23
- package/tests/router/packageSurface.test.ts +0 -24
- package/tests/router/preloadRedirect.test.ts +0 -64
- package/tests/router/register.test.ts +0 -8
- package/tests/router/routerCompatibility.test.ts +0 -239
- package/tests/router/rscDecoderSecurity.test.ts +0 -113
- package/tests/router/rscPayloadRouterMatrix.test.ts +0 -197
|
@@ -38,12 +38,14 @@ var __webpack_exports__ = {};
|
|
|
38
38
|
__webpack_require__.r(__webpack_exports__);
|
|
39
39
|
__webpack_require__.d(__webpack_exports__, {
|
|
40
40
|
generateTanstackRouteArtifacts: ()=>generateTanstackRouteArtifacts,
|
|
41
|
+
writeRouteMetadataManifest: ()=>writeRouteMetadataManifest,
|
|
41
42
|
writeTanstackRegisterFile: ()=>writeTanstackRegisterFile,
|
|
42
43
|
writeTanstackRouterTypesForEntries: ()=>writeTanstackRouterTypesForEntries
|
|
43
44
|
});
|
|
44
45
|
const external_node_path_namespaceObject = require("node:path");
|
|
45
46
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
46
47
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
48
|
+
const external_routeMetadata_js_namespaceObject = require("./routeMetadata.js");
|
|
47
49
|
const external_tanstackTypes_js_namespaceObject = require("./tanstackTypes.js");
|
|
48
50
|
const DEFAULT_GENERATED_DIR_NAME = 'modern-tanstack';
|
|
49
51
|
async function writeFileIfChanged(filePath, content) {
|
|
@@ -121,7 +123,16 @@ async function writeTanstackRouterTypesForEntries(opts) {
|
|
|
121
123
|
canonicalRoutes
|
|
122
124
|
});
|
|
123
125
|
}
|
|
126
|
+
async function writeRouteMetadataManifest(opts) {
|
|
127
|
+
const routesDirectory = external_node_path_default().join(opts.appDirectory, 'src', 'routes');
|
|
128
|
+
const manifestPath = external_node_path_default().join(routesDirectory, external_routeMetadata_js_namespaceObject.ROUTE_METADATA_MANIFEST_FILE_NAME);
|
|
129
|
+
const manifest = (0, external_routeMetadata_js_namespaceObject.renderRouteMetadataManifest)(await (0, external_routeMetadata_js_namespaceObject.findRouteMetaFiles)(routesDirectory));
|
|
130
|
+
if (null !== manifest) return void await writeFileIfChanged(manifestPath, manifest);
|
|
131
|
+
const previous = await utils_namespaceObject.fs.pathExists(manifestPath) ? await utils_namespaceObject.fs.readFile(manifestPath, 'utf-8') : null;
|
|
132
|
+
if (previous?.startsWith(`${external_routeMetadata_js_namespaceObject.ROUTE_METADATA_MANIFEST_HEADER}\n`)) throw new Error(`[plugin-tanstack] ${manifestPath} is generated from route.meta.ts files, but none remain below ${routesDirectory}. Restore at least one route.meta.ts that exports routeMeta, or delete the manifest together with its imports.`);
|
|
133
|
+
}
|
|
124
134
|
async function generateTanstackRouteArtifacts(opts) {
|
|
135
|
+
await writeRouteMetadataManifest(opts);
|
|
125
136
|
const [{ createRunOptions }, { cli }, utils] = await Promise.all([
|
|
126
137
|
import("@modern-js/app-tools/cli/run"),
|
|
127
138
|
import("@modern-js/plugin/cli"),
|
|
@@ -139,16 +150,19 @@ async function generateTanstackRouteArtifacts(opts) {
|
|
|
139
150
|
version: opts.version || process.env.MODERN_JS_VERSION || '0.0.0-routes-generate',
|
|
140
151
|
internalPlugins: utils.INTERNAL_RUNTIME_PLUGINS
|
|
141
152
|
});
|
|
142
|
-
await cli.init({
|
|
153
|
+
const { appContext } = await cli.init({
|
|
143
154
|
...runOptions,
|
|
144
155
|
command: 'build'
|
|
145
156
|
});
|
|
157
|
+
await appContext.hooks.onBeforeExit.call();
|
|
146
158
|
}
|
|
147
159
|
exports.generateTanstackRouteArtifacts = __webpack_exports__.generateTanstackRouteArtifacts;
|
|
160
|
+
exports.writeRouteMetadataManifest = __webpack_exports__.writeRouteMetadataManifest;
|
|
148
161
|
exports.writeTanstackRegisterFile = __webpack_exports__.writeTanstackRegisterFile;
|
|
149
162
|
exports.writeTanstackRouterTypesForEntries = __webpack_exports__.writeTanstackRouterTypesForEntries;
|
|
150
163
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
151
164
|
"generateTanstackRouteArtifacts",
|
|
165
|
+
"writeRouteMetadataManifest",
|
|
152
166
|
"writeTanstackRegisterFile",
|
|
153
167
|
"writeTanstackRouterTypesForEntries"
|
|
154
168
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
package/dist/cjs/cli/index.js
CHANGED
|
@@ -59,6 +59,7 @@ var __webpack_exports__ = {};
|
|
|
59
59
|
generateTanstackRouterTypesSourceForEntry: ()=>external_tanstackTypes_js_namespaceObject.generateTanstackRouterTypesSourceForEntry,
|
|
60
60
|
resolveTanstackRouteCodeSplittingEnabled: ()=>external_routeSplitting_js_namespaceObject.resolveTanstackRouteCodeSplittingEnabled,
|
|
61
61
|
tanstackRouterPlugin: ()=>tanstackRouterPlugin,
|
|
62
|
+
writeRouteMetadataManifest: ()=>external_artifacts_js_namespaceObject.writeRouteMetadataManifest,
|
|
62
63
|
writeTanstackRegisterFile: ()=>external_artifacts_js_namespaceObject.writeTanstackRegisterFile,
|
|
63
64
|
writeTanstackRouterTypesForEntries: ()=>external_artifacts_js_namespaceObject.writeTanstackRouterTypesForEntries
|
|
64
65
|
});
|
|
@@ -91,6 +92,15 @@ var __webpack_exports__ = {};
|
|
|
91
92
|
'@modern-js/runtime'
|
|
92
93
|
],
|
|
93
94
|
setup: (api)=>{
|
|
95
|
+
const { srcDirectory, serverCompileExcludedFiles = [] } = api.getAppContext();
|
|
96
|
+
api.updateAppContext({
|
|
97
|
+
serverCompileExcludedFiles: [
|
|
98
|
+
...new Set([
|
|
99
|
+
...serverCompileExcludedFiles,
|
|
100
|
+
external_node_path_default().join(srcDirectory, generatedDirName, 'register.gen.d.ts')
|
|
101
|
+
])
|
|
102
|
+
]
|
|
103
|
+
});
|
|
94
104
|
const nestedRoutesForServer = {};
|
|
95
105
|
const isTanstackEntrypoint = (entrypoint)=>{
|
|
96
106
|
const { getEntrypointRoutesDir } = getRuntimeRouterCli();
|
|
@@ -239,6 +249,7 @@ exports.generateTanstackRouteArtifacts = __webpack_exports__.generateTanstackRou
|
|
|
239
249
|
exports.generateTanstackRouterTypesSourceForEntry = __webpack_exports__.generateTanstackRouterTypesSourceForEntry;
|
|
240
250
|
exports.resolveTanstackRouteCodeSplittingEnabled = __webpack_exports__.resolveTanstackRouteCodeSplittingEnabled;
|
|
241
251
|
exports.tanstackRouterPlugin = __webpack_exports__.tanstackRouterPlugin;
|
|
252
|
+
exports.writeRouteMetadataManifest = __webpack_exports__.writeRouteMetadataManifest;
|
|
242
253
|
exports.writeTanstackRegisterFile = __webpack_exports__.writeTanstackRegisterFile;
|
|
243
254
|
exports.writeTanstackRouterTypesForEntries = __webpack_exports__.writeTanstackRouterTypesForEntries;
|
|
244
255
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -249,6 +260,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
249
260
|
"generateTanstackRouterTypesSourceForEntry",
|
|
250
261
|
"resolveTanstackRouteCodeSplittingEnabled",
|
|
251
262
|
"tanstackRouterPlugin",
|
|
263
|
+
"writeRouteMetadataManifest",
|
|
252
264
|
"writeTanstackRegisterFile",
|
|
253
265
|
"writeTanstackRouterTypesForEntries"
|
|
254
266
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
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");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
ROUTE_METADATA_MANIFEST_FILE_NAME: ()=>ROUTE_METADATA_MANIFEST_FILE_NAME,
|
|
41
|
+
ROUTE_METADATA_MANIFEST_HEADER: ()=>ROUTE_METADATA_MANIFEST_HEADER,
|
|
42
|
+
ROUTE_META_FILE_NAME: ()=>ROUTE_META_FILE_NAME,
|
|
43
|
+
findRouteMetaFiles: ()=>findRouteMetaFiles,
|
|
44
|
+
renderRouteMetadataManifest: ()=>renderRouteMetadataManifest
|
|
45
|
+
});
|
|
46
|
+
const promises_namespaceObject = require("node:fs/promises");
|
|
47
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
48
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
49
|
+
const ROUTE_META_FILE_NAME = 'route.meta.ts';
|
|
50
|
+
const ROUTE_METADATA_MANIFEST_FILE_NAME = 'ultramodern-route-metadata.ts';
|
|
51
|
+
const ROUTE_METADATA_MANIFEST_HEADER = `// @generated by @modern-js/plugin-tanstack from ${ROUTE_META_FILE_NAME} files. Run routes-generate; do not edit.`;
|
|
52
|
+
const PRINT_WIDTH = 120;
|
|
53
|
+
const MANIFEST_BODY = `export const ultramodernLocalisedUrls = Object.fromEntries(
|
|
54
|
+
ultramodernRouteMetadata
|
|
55
|
+
.filter((route) => route.canonicalPath !== '/')
|
|
56
|
+
.map((route) => [route.canonicalPath, route.localisedPaths]),
|
|
57
|
+
);
|
|
58
|
+
export const ultramodernPublicRoutes = ultramodernRouteMetadata
|
|
59
|
+
.filter((route) => route.public && route.indexable)
|
|
60
|
+
.map((route) => ({
|
|
61
|
+
canonicalPath: route.canonicalPath,
|
|
62
|
+
descriptionKey: route.descriptionKey,
|
|
63
|
+
id: route.id,
|
|
64
|
+
localisedPaths: route.localisedPaths,
|
|
65
|
+
namespace: route.namespace,
|
|
66
|
+
ownerAppId: route.ownerAppId,
|
|
67
|
+
titleKey: route.titleKey,
|
|
68
|
+
...('jsonLd' in route ? { jsonLd: route.jsonLd } : {}),
|
|
69
|
+
}));
|
|
70
|
+
export const ultramodernRouteConfig = {
|
|
71
|
+
authoring: 'colocated-route-meta',
|
|
72
|
+
generatedManifest: true,
|
|
73
|
+
localisedUrls: ultramodernLocalisedUrls,
|
|
74
|
+
namespace: ultramodernRouteNamespace,
|
|
75
|
+
publicRoutes: ultramodernPublicRoutes,
|
|
76
|
+
routes: ultramodernRouteMetadata,
|
|
77
|
+
source: 'route-owned',
|
|
78
|
+
} as const;
|
|
79
|
+
`;
|
|
80
|
+
const compareCodeUnits = (left, right)=>left < right ? -1 : left > right ? 1 : 0;
|
|
81
|
+
const quoteSpecifier = (specifier)=>specifier.includes("'") ? JSON.stringify(specifier) : `'${specifier}'`;
|
|
82
|
+
function renderRouteMetadataManifest(routeMetaFiles) {
|
|
83
|
+
const specifiers = routeMetaFiles.map((file)=>`./${file.replaceAll('\\', '/').replace(/\.ts$/u, '')}`).sort(compareCodeUnits);
|
|
84
|
+
if (0 === specifiers.length) return null;
|
|
85
|
+
const bindings = specifiers.map((_, index)=>`route${index}`);
|
|
86
|
+
const imports = specifiers.map((specifier, index)=>`import { routeMeta as ${bindings[index]} } from ${quoteSpecifier(specifier)};`);
|
|
87
|
+
const inlineRoutes = `export const ultramodernRouteMetadata = [${bindings.join(', ')}] as const;`;
|
|
88
|
+
const routes = inlineRoutes.length <= PRINT_WIDTH ? inlineRoutes : `export const ultramodernRouteMetadata = [\n${bindings.map((binding)=>` ${binding},\n`).join('')}] as const;`;
|
|
89
|
+
return `${ROUTE_METADATA_MANIFEST_HEADER}
|
|
90
|
+
${imports.join('\n')}
|
|
91
|
+
|
|
92
|
+
export const ultramodernRouteNamespace = route0.namespace;
|
|
93
|
+
${routes}
|
|
94
|
+
${MANIFEST_BODY}`;
|
|
95
|
+
}
|
|
96
|
+
async function findRouteMetaFiles(routesDirectory) {
|
|
97
|
+
const files = [];
|
|
98
|
+
const visit = async (relativeDirectory)=>{
|
|
99
|
+
const entries = await (0, promises_namespaceObject.readdir)(external_node_path_default().join(routesDirectory, relativeDirectory), {
|
|
100
|
+
withFileTypes: true
|
|
101
|
+
});
|
|
102
|
+
for (const entry of entries){
|
|
103
|
+
const relativePath = external_node_path_default().join(relativeDirectory, entry.name);
|
|
104
|
+
if (entry.isDirectory()) await visit(relativePath);
|
|
105
|
+
else if (entry.isFile() && entry.name === ROUTE_META_FILE_NAME) files.push(relativePath);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
try {
|
|
109
|
+
await visit('');
|
|
110
|
+
} catch (error) {
|
|
111
|
+
const { code, path: missingPath } = error;
|
|
112
|
+
if ('ENOENT' === code && missingPath === routesDirectory) return [];
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
return files;
|
|
116
|
+
}
|
|
117
|
+
exports.ROUTE_METADATA_MANIFEST_FILE_NAME = __webpack_exports__.ROUTE_METADATA_MANIFEST_FILE_NAME;
|
|
118
|
+
exports.ROUTE_METADATA_MANIFEST_HEADER = __webpack_exports__.ROUTE_METADATA_MANIFEST_HEADER;
|
|
119
|
+
exports.ROUTE_META_FILE_NAME = __webpack_exports__.ROUTE_META_FILE_NAME;
|
|
120
|
+
exports.findRouteMetaFiles = __webpack_exports__.findRouteMetaFiles;
|
|
121
|
+
exports.renderRouteMetadataManifest = __webpack_exports__.renderRouteMetadataManifest;
|
|
122
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
123
|
+
"ROUTE_METADATA_MANIFEST_FILE_NAME",
|
|
124
|
+
"ROUTE_METADATA_MANIFEST_HEADER",
|
|
125
|
+
"ROUTE_META_FILE_NAME",
|
|
126
|
+
"findRouteMetaFiles",
|
|
127
|
+
"renderRouteMetadataManifest"
|
|
128
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
129
|
+
Object.defineProperty(exports, '__esModule', {
|
|
130
|
+
value: true
|
|
131
|
+
});
|
|
@@ -30,6 +30,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
collectCanonicalRoutesForEntry: ()=>collectCanonicalRoutesForEntry
|
|
32
32
|
});
|
|
33
|
+
const routeDescriptor_js_namespaceObject = require("../../shared/routeDescriptor.js");
|
|
33
34
|
const external_shared_js_namespaceObject = require("./shared.js");
|
|
34
35
|
const LOCALE_PARAM_SEGMENTS = new Set([
|
|
35
36
|
':lang',
|
|
@@ -76,11 +77,13 @@ function collectCanonicalRoutesForEntry(routes, options = {}) {
|
|
|
76
77
|
const key = (0, external_shared_js_namespaceObject.toTanstackPath)(normalized);
|
|
77
78
|
if (!canonicalParams.has(key)) canonicalParams.set(key, paramsTypeForCanonicalPath(normalized));
|
|
78
79
|
};
|
|
79
|
-
const visit = (
|
|
80
|
+
const visit = (descriptor, parentPath)=>{
|
|
81
|
+
const { source: route, children } = descriptor;
|
|
80
82
|
let currentPath = parentPath;
|
|
81
|
-
|
|
83
|
+
const canonicalPath = route.modernLocalisedRoute?.canonicalPath ?? route.modernCanonicalPath;
|
|
84
|
+
if ('string' == typeof canonicalPath) {
|
|
82
85
|
hasI18nSurface = true;
|
|
83
|
-
currentPath = normalizeJoined(
|
|
86
|
+
currentPath = canonicalPath ? normalizeJoined(canonicalPath) : '';
|
|
84
87
|
} else if ('string' == typeof route.path && route.path.length > 0) {
|
|
85
88
|
const segments = route.path.replace(/\[(.+?)\]/g, ':$1').split('/').filter(Boolean);
|
|
86
89
|
if (localeParamHeuristic && '' === parentPath && LOCALE_PARAM_SEGMENTS.has(segments[0])) {
|
|
@@ -89,16 +92,13 @@ function collectCanonicalRoutesForEntry(routes, options = {}) {
|
|
|
89
92
|
}
|
|
90
93
|
currentPath = segments.length ? normalizeJoined(`${parentPath}/${segments.join('/')}`) : parentPath;
|
|
91
94
|
}
|
|
92
|
-
const children = route.children;
|
|
93
95
|
if (children && children.length > 0) {
|
|
94
96
|
for (const child of children)visit(child, currentPath);
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
99
|
record(currentPath || '/');
|
|
98
100
|
};
|
|
99
|
-
const
|
|
100
|
-
const topLevel = rootModern ? rootModern.children ?? [] : routes;
|
|
101
|
-
for (const route of topLevel)visit(route, '');
|
|
101
|
+
for (const route of (0, routeDescriptor_js_namespaceObject.describeRouteTree)(routes).children)visit(route, '');
|
|
102
102
|
if (!hasI18nSurface || 0 === canonicalParams.size) return null;
|
|
103
103
|
return Object.fromEntries([
|
|
104
104
|
...canonicalParams.entries()
|
|
@@ -29,8 +29,6 @@ var __webpack_exports__ = {};
|
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
createRouteStaticDataSnippet: ()=>createRouteStaticDataSnippet,
|
|
32
|
-
isIndexRoute: ()=>isIndexRoute,
|
|
33
|
-
isPathlessLayout: ()=>isPathlessLayout,
|
|
34
32
|
normalizeRelativeImport: ()=>normalizeRelativeImport,
|
|
35
33
|
pickModernLoaderModule: ()=>pickModernLoaderModule,
|
|
36
34
|
pickRouteSearchContractModules: ()=>pickRouteSearchContractModules,
|
|
@@ -83,14 +81,6 @@ function pickRouteSearchContractModules(route) {
|
|
|
83
81
|
loaderDepsPath: 'string' == typeof loaderDepsPath ? loaderDepsPath : null
|
|
84
82
|
};
|
|
85
83
|
}
|
|
86
|
-
function isPathlessLayout(route) {
|
|
87
|
-
const extras = route;
|
|
88
|
-
return 'nested' === extras.type && 'boolean' != typeof extras.index && void 0 === extras.path;
|
|
89
|
-
}
|
|
90
|
-
function isIndexRoute(route) {
|
|
91
|
-
const extras = route;
|
|
92
|
-
return 'nested' === extras.type && Boolean(extras.index);
|
|
93
|
-
}
|
|
94
84
|
function createRouteStaticDataSnippet(opts) {
|
|
95
85
|
const staticData = (0, routeStaticData_js_namespaceObject.createRouteStaticData)({
|
|
96
86
|
modernRouteId: opts.modernRouteId && quote(opts.modernRouteId),
|
|
@@ -101,8 +91,6 @@ function createRouteStaticDataSnippet(opts) {
|
|
|
101
91
|
return entries.length > 0 ? `staticData: createRouteStaticData({\n ${entries.map(([key, value])=>`${key}: ${value},`).join('\n ')}\n }),` : null;
|
|
102
92
|
}
|
|
103
93
|
exports.createRouteStaticDataSnippet = __webpack_exports__.createRouteStaticDataSnippet;
|
|
104
|
-
exports.isIndexRoute = __webpack_exports__.isIndexRoute;
|
|
105
|
-
exports.isPathlessLayout = __webpack_exports__.isPathlessLayout;
|
|
106
94
|
exports.normalizeRelativeImport = __webpack_exports__.normalizeRelativeImport;
|
|
107
95
|
exports.pickModernLoaderModule = __webpack_exports__.pickModernLoaderModule;
|
|
108
96
|
exports.pickRouteSearchContractModules = __webpack_exports__.pickRouteSearchContractModules;
|
|
@@ -111,8 +99,6 @@ exports.resolveFileNoExt = __webpack_exports__.resolveFileNoExt;
|
|
|
111
99
|
exports.toTanstackPath = __webpack_exports__.toTanstackPath;
|
|
112
100
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
113
101
|
"createRouteStaticDataSnippet",
|
|
114
|
-
"isIndexRoute",
|
|
115
|
-
"isPathlessLayout",
|
|
116
102
|
"normalizeRelativeImport",
|
|
117
103
|
"pickModernLoaderModule",
|
|
118
104
|
"pickRouteSearchContractModules",
|
|
@@ -32,16 +32,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
});
|
|
33
33
|
const cli_namespaceObject = require("@modern-js/runtime/cli");
|
|
34
34
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
35
|
+
const routeDescriptor_js_namespaceObject = require("../../shared/routeDescriptor.js");
|
|
35
36
|
const external_shared_js_namespaceObject = require("./shared.js");
|
|
36
37
|
async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
37
38
|
const { appContext, entryName, generatedDirName = 'modern-tanstack', routes } = opts;
|
|
38
39
|
const outDir = utils_namespaceObject.upath.join(appContext.srcDirectory, generatedDirName, entryName);
|
|
39
|
-
const rootModern =
|
|
40
|
-
const extras = r;
|
|
41
|
-
return r && 'nested' === extras.type && extras.isRoot;
|
|
42
|
-
});
|
|
43
|
-
const rootExtras = rootModern;
|
|
44
|
-
const topLevel = rootModern ? rootExtras?.children || [] : routes;
|
|
40
|
+
const { root: rootModern, children: topLevel } = (0, routeDescriptor_js_namespaceObject.describeRouteTree)(routes);
|
|
45
41
|
const imports = [];
|
|
46
42
|
const statements = [];
|
|
47
43
|
const loaderImportMap = new Map();
|
|
@@ -58,9 +54,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
58
54
|
let pendingImportName = componentImportMap.get(componentPath);
|
|
59
55
|
if (!pendingImportName) {
|
|
60
56
|
pendingImportName = (async ()=>{
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
63
|
-
const relImport = (0, external_shared_js_namespaceObject.normalizeRelativeImport)(utils_namespaceObject.upath.relative(outDir, resolvedNoExt));
|
|
57
|
+
const relImport = await resolveRouteImport(componentPath);
|
|
58
|
+
if (!relImport) return null;
|
|
64
59
|
const componentName = `component_${componentIndex++}`;
|
|
65
60
|
imports.push(`import ${componentName} from ${(0, external_shared_js_namespaceObject.quote)(relImport)};`);
|
|
66
61
|
return componentName;
|
|
@@ -69,14 +64,15 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
69
64
|
}
|
|
70
65
|
return pendingImportName;
|
|
71
66
|
};
|
|
72
|
-
const
|
|
67
|
+
const resolveRouteImport = async (aliasedNoExtPath)=>{
|
|
73
68
|
const prefix = `${appContext.internalSrcAlias}/`;
|
|
74
69
|
let absNoExt;
|
|
75
70
|
if (aliasedNoExtPath.startsWith(prefix)) {
|
|
76
71
|
const rel = aliasedNoExtPath.slice(prefix.length);
|
|
77
72
|
absNoExt = utils_namespaceObject.upath.join(appContext.srcDirectory, rel);
|
|
78
73
|
} else absNoExt = utils_namespaceObject.upath.isAbsolute(aliasedNoExtPath) ? aliasedNoExtPath : utils_namespaceObject.upath.join(appContext.srcDirectory, aliasedNoExtPath);
|
|
79
|
-
|
|
74
|
+
const resolvedNoExt = await (0, external_shared_js_namespaceObject.resolveFileNoExt)(absNoExt);
|
|
75
|
+
return resolvedNoExt ? (0, external_shared_js_namespaceObject.normalizeRelativeImport)(utils_namespaceObject.upath.relative(outDir, resolvedNoExt)) : null;
|
|
80
76
|
};
|
|
81
77
|
const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
|
|
82
78
|
const key = `${inline ? 'inline' : 'default'}:${hasAction ? 'action' : 'loader'}:${aliasedNoExtPath}`;
|
|
@@ -85,9 +81,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
85
81
|
loaderName: existing,
|
|
86
82
|
actionName: hasAction ? existing.replace(/^loader_/, 'action_') : null
|
|
87
83
|
};
|
|
88
|
-
const
|
|
89
|
-
if (!
|
|
90
|
-
const relImport = (0, external_shared_js_namespaceObject.normalizeRelativeImport)(utils_namespaceObject.upath.relative(outDir, resolvedNoExt));
|
|
84
|
+
const relImport = await resolveRouteImport(aliasedNoExtPath);
|
|
85
|
+
if (!relImport) return null;
|
|
91
86
|
const importName = `loader_${loaderIndex++}`;
|
|
92
87
|
const actionName = hasAction ? importName.replace(/^loader_/, 'action_') : null;
|
|
93
88
|
if (inline) {
|
|
@@ -107,9 +102,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
107
102
|
const key = `${exportName}:${aliasedNoExtPath}`;
|
|
108
103
|
const existing = searchContractImportMap.get(key);
|
|
109
104
|
if (existing) return existing;
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
112
|
-
const relImport = (0, external_shared_js_namespaceObject.normalizeRelativeImport)(utils_namespaceObject.upath.relative(outDir, resolvedNoExt));
|
|
105
|
+
const relImport = await resolveRouteImport(aliasedNoExtPath);
|
|
106
|
+
if (!relImport) return null;
|
|
113
107
|
const importName = 'validateSearch' === exportName ? `validateSearch_${validateSearchIndex++}` : `loaderDeps_${loaderDepsIndex++}`;
|
|
114
108
|
imports.push(`import { ${exportName} as ${importName} } from ${(0, external_shared_js_namespaceObject.quote)(relImport)};`);
|
|
115
109
|
searchContractImportMap.set(key, importName);
|
|
@@ -127,9 +121,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
127
121
|
const base = id ? (0, cli_namespaceObject.makeLegalIdentifier)(id) : `r_${routeIndex++}`;
|
|
128
122
|
return reserveRouteVarName(`route_${base}`);
|
|
129
123
|
};
|
|
130
|
-
const
|
|
131
|
-
const { parentVar, route } = opts;
|
|
132
|
-
const varName = createRouteVarName(route);
|
|
124
|
+
const createRouteOptions = async (route, hasSplat)=>{
|
|
133
125
|
const routeExtras = route;
|
|
134
126
|
const loaderInfo = (0, external_shared_js_namespaceObject.pickModernLoaderModule)(route);
|
|
135
127
|
const routeAction = routeExtras.action;
|
|
@@ -139,20 +131,9 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
139
131
|
const searchContractInfo = (0, external_shared_js_namespaceObject.pickRouteSearchContractModules)(route);
|
|
140
132
|
const validateSearchName = searchContractInfo.validateSearchPath ? await getImportNameForSearchContract(searchContractInfo.validateSearchPath, 'validateSearch') : null;
|
|
141
133
|
const loaderDepsName = searchContractInfo.loaderDepsPath ? await getImportNameForSearchContract(searchContractInfo.loaderDepsPath, 'loaderDeps') : null;
|
|
142
|
-
const
|
|
143
|
-
const hasSplat = 'string' == typeof rawPath && rawPath.includes('*');
|
|
144
|
-
const routeOpts = [
|
|
145
|
-
`getParentRoute: () => ${parentVar},`
|
|
146
|
-
];
|
|
134
|
+
const routeOpts = [];
|
|
147
135
|
const componentName = await getImportNameForComponent(routeExtras._component);
|
|
148
136
|
if (componentName) routeOpts.push(`component: ${componentName},`);
|
|
149
|
-
if ((0, external_shared_js_namespaceObject.isPathlessLayout)(route)) {
|
|
150
|
-
const id = routeExtras.id;
|
|
151
|
-
routeOpts.push(`id: ${(0, external_shared_js_namespaceObject.quote)(id || 'pathless')},`);
|
|
152
|
-
} else {
|
|
153
|
-
const p = (0, external_shared_js_namespaceObject.isIndexRoute)(route) ? '/' : (0, external_shared_js_namespaceObject.toTanstackPath)(rawPath || '');
|
|
154
|
-
routeOpts.push(`path: ${(0, external_shared_js_namespaceObject.quote)(p)},`);
|
|
155
|
-
}
|
|
156
137
|
if (loaderName) routeOpts.push(`loader: modernLoaderToTanstack({ hasSplat: ${hasSplat} }, ${loaderName}),`);
|
|
157
138
|
if (validateSearchName) routeOpts.push(`validateSearch: ${validateSearchName},`);
|
|
158
139
|
if (loaderDepsName) routeOpts.push(`loaderDeps: ${loaderDepsName},`);
|
|
@@ -162,39 +143,29 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
162
143
|
actionName
|
|
163
144
|
});
|
|
164
145
|
if (staticDataSnippet) routeOpts.push(staticDataSnippet);
|
|
165
|
-
|
|
146
|
+
return routeOpts;
|
|
147
|
+
};
|
|
148
|
+
const buildRoute = async (descriptor, parentVar)=>{
|
|
149
|
+
const { source: route, location, hasSplat, children } = descriptor;
|
|
150
|
+
const varName = createRouteVarName(route);
|
|
151
|
+
const routeOpts = [
|
|
152
|
+
`getParentRoute: () => ${parentVar},`,
|
|
153
|
+
...Object.entries(location).map(([key, value])=>`${key}: ${(0, external_shared_js_namespaceObject.quote)(value)},`),
|
|
154
|
+
...await createRouteOptions(route, hasSplat)
|
|
155
|
+
];
|
|
166
156
|
const hasChildren = Boolean(children && children.length > 0);
|
|
167
157
|
const routeCtorVarName = hasChildren ? reserveRouteVarName(`${varName}__base`) : varName;
|
|
168
158
|
statements.push(`const ${routeCtorVarName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
|
|
169
159
|
if (children && children.length > 0) {
|
|
170
160
|
const childVars = [];
|
|
171
|
-
for (const child of children)childVars.push(await buildRoute(
|
|
172
|
-
parentVar: routeCtorVarName,
|
|
173
|
-
route: child
|
|
174
|
-
}));
|
|
161
|
+
for (const child of children)childVars.push(await buildRoute(child, routeCtorVarName));
|
|
175
162
|
statements.push(`const ${varName} = ${routeCtorVarName}.addChildren([${childVars.join(', ')}]);`);
|
|
176
163
|
}
|
|
177
164
|
return varName;
|
|
178
165
|
};
|
|
179
|
-
const rootLoaderInfo = rootModern ? (0, external_shared_js_namespaceObject.pickModernLoaderModule)(rootModern) : null;
|
|
180
|
-
const rootAction = rootExtras?.action;
|
|
181
|
-
const rootLoaderImports = rootLoaderInfo?.loaderPath ? await getImportNamesForLoader(rootLoaderInfo.loaderPath, rootLoaderInfo.inline, Boolean(rootLoaderInfo.inline && rootAction === rootLoaderInfo.loaderPath)) : null;
|
|
182
|
-
const rootLoaderName = rootLoaderImports?.loaderName || null;
|
|
183
|
-
const rootActionName = rootLoaderImports?.actionName || null;
|
|
184
|
-
const rootSearchContractInfo = rootModern ? (0, external_shared_js_namespaceObject.pickRouteSearchContractModules)(rootModern) : null;
|
|
185
|
-
const rootValidateSearchName = rootSearchContractInfo?.validateSearchPath ? await getImportNameForSearchContract(rootSearchContractInfo.validateSearchPath, 'validateSearch') : null;
|
|
186
|
-
const rootLoaderDepsName = rootSearchContractInfo?.loaderDepsPath ? await getImportNameForSearchContract(rootSearchContractInfo.loaderDepsPath, 'loaderDeps') : null;
|
|
187
166
|
const topLevelVars = [];
|
|
188
|
-
for (const route of topLevel)topLevelVars.push(await buildRoute(
|
|
189
|
-
|
|
190
|
-
route
|
|
191
|
-
}));
|
|
192
|
-
const rootOpts = [];
|
|
193
|
-
const rootComponentName = await getImportNameForComponent(rootExtras?._component);
|
|
194
|
-
if (rootComponentName) rootOpts.push(`component: ${rootComponentName},`);
|
|
195
|
-
if (rootLoaderName) rootOpts.push(`loader: modernLoaderToTanstack({ hasSplat: false }, ${rootLoaderName}),`);
|
|
196
|
-
if (rootValidateSearchName) rootOpts.push(`validateSearch: ${rootValidateSearchName},`);
|
|
197
|
-
if (rootLoaderDepsName) rootOpts.push(`loaderDeps: ${rootLoaderDepsName},`);
|
|
167
|
+
for (const route of topLevel)topLevelVars.push(await buildRoute(route, 'rootRoute'));
|
|
168
|
+
const rootOpts = rootModern ? await createRouteOptions(rootModern, false) : [];
|
|
198
169
|
const routerGenTs = `// This file is auto-generated by Modern.js. Do not edit manually.
|
|
199
170
|
|
|
200
171
|
import {
|
|
@@ -211,11 +182,7 @@ ${imports.join('\n')}
|
|
|
211
182
|
|
|
212
183
|
export const rootRoute = createRootRouteWithContext<ModernRouterContext>()({
|
|
213
184
|
${rootOpts.join('\n ')}
|
|
214
|
-
|
|
215
|
-
modernRouteId: rootExtras?.id,
|
|
216
|
-
loaderName: rootLoaderName,
|
|
217
|
-
actionName: rootActionName
|
|
218
|
-
}) || ''}
|
|
185
|
+
|
|
219
186
|
});
|
|
220
187
|
|
|
221
188
|
${statements.join('\n\n')}
|
|
@@ -27,19 +27,25 @@ var __webpack_require__ = {};
|
|
|
27
27
|
})();
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
createModernBasepathRewrite: ()=>createModernBasepathRewrite
|
|
32
|
+
});
|
|
33
|
+
const i18n_runtime_extensions_namespaceObject = require("@modern-js/i18n-runtime-extensions");
|
|
34
|
+
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
30
35
|
function normalizeBasepath(basepath) {
|
|
31
36
|
if (!basepath) return '/';
|
|
32
37
|
let normalized = basepath.startsWith('/') ? basepath : `/${basepath}`;
|
|
33
38
|
if (normalized.length > 1 && normalized.endsWith('/')) normalized = normalized.slice(0, -1);
|
|
34
39
|
return normalized || '/';
|
|
35
40
|
}
|
|
36
|
-
function createModernBasepathRewrite(basepath, caseSensitive = false) {
|
|
41
|
+
function createModernBasepathRewrite(basepath, caseSensitive = false, routes = []) {
|
|
42
|
+
const localisedRewrite = (0, i18n_runtime_extensions_namespaceObject.createLocalisedRouteRewrite)(routes);
|
|
37
43
|
const normalizedBasepath = normalizeBasepath(basepath);
|
|
38
|
-
if ('/' === normalizedBasepath) return;
|
|
44
|
+
if ('/' === normalizedBasepath) return localisedRewrite;
|
|
39
45
|
const normalizedBasepathWithSlash = `${normalizedBasepath}/`;
|
|
40
46
|
const checkBasepath = caseSensitive ? normalizedBasepath : normalizedBasepath.toLowerCase();
|
|
41
47
|
const checkBasepathWithSlash = caseSensitive ? normalizedBasepathWithSlash : normalizedBasepathWithSlash.toLowerCase();
|
|
42
|
-
|
|
48
|
+
const basepathRewrite = {
|
|
43
49
|
input: ({ url })=>{
|
|
44
50
|
const pathname = caseSensitive ? url.pathname : url.pathname.toLowerCase();
|
|
45
51
|
if (pathname === checkBasepath) url.pathname = '/';
|
|
@@ -53,10 +59,11 @@ function createModernBasepathRewrite(basepath, caseSensitive = false) {
|
|
|
53
59
|
return url;
|
|
54
60
|
}
|
|
55
61
|
};
|
|
62
|
+
return localisedRewrite ? (0, react_router_namespaceObject.composeRewrites)([
|
|
63
|
+
basepathRewrite,
|
|
64
|
+
localisedRewrite
|
|
65
|
+
]) : basepathRewrite;
|
|
56
66
|
}
|
|
57
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
58
|
-
createModernBasepathRewrite: ()=>createModernBasepathRewrite
|
|
59
|
-
});
|
|
60
67
|
exports.createModernBasepathRewrite = __webpack_exports__.createModernBasepathRewrite;
|
|
61
68
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
62
69
|
"createModernBasepathRewrite"
|
|
@@ -28,24 +28,21 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
applyRouterRuntimeState: ()=>
|
|
32
|
-
applyRouterServerPrepareResult: ()=>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
getRouterServerSnapshot: ()=>context_namespaceObject.getRouterServerSnapshot
|
|
31
|
+
applyRouterRuntimeState: ()=>router_state_namespaceObject.applyRouterRuntimeState,
|
|
32
|
+
applyRouterServerPrepareResult: ()=>router_state_namespaceObject.applyRouterServerPrepareResult,
|
|
33
|
+
createRouterServerSnapshot: ()=>router_state_namespaceObject.createRouterServerSnapshot,
|
|
34
|
+
getRouterRuntimeState: ()=>router_state_namespaceObject.getRouterRuntimeState,
|
|
35
|
+
getRouterServerSnapshot: ()=>router_state_namespaceObject.getRouterServerSnapshot
|
|
37
36
|
});
|
|
38
|
-
const
|
|
37
|
+
const router_state_namespaceObject = require("@modern-js/runtime-extensions/router-state");
|
|
39
38
|
exports.applyRouterRuntimeState = __webpack_exports__.applyRouterRuntimeState;
|
|
40
39
|
exports.applyRouterServerPrepareResult = __webpack_exports__.applyRouterServerPrepareResult;
|
|
41
|
-
exports.createRouterRuntimeState = __webpack_exports__.createRouterRuntimeState;
|
|
42
40
|
exports.createRouterServerSnapshot = __webpack_exports__.createRouterServerSnapshot;
|
|
43
41
|
exports.getRouterRuntimeState = __webpack_exports__.getRouterRuntimeState;
|
|
44
42
|
exports.getRouterServerSnapshot = __webpack_exports__.getRouterServerSnapshot;
|
|
45
43
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
46
44
|
"applyRouterRuntimeState",
|
|
47
45
|
"applyRouterServerPrepareResult",
|
|
48
|
-
"createRouterRuntimeState",
|
|
49
46
|
"createRouterServerSnapshot",
|
|
50
47
|
"getRouterRuntimeState",
|
|
51
48
|
"getRouterServerSnapshot"
|
|
@@ -30,6 +30,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
createRouteStaticData: ()=>routeStaticData_js_namespaceObject.createRouteStaticData,
|
|
32
32
|
getLoaderHref: ()=>getLoaderHref,
|
|
33
|
+
getLoaderSignal: ()=>getLoaderSignal,
|
|
33
34
|
handleModernLoaderError: ()=>handleModernLoaderError,
|
|
34
35
|
handleModernLoaderResult: ()=>handleModernLoaderResult,
|
|
35
36
|
isAbsoluteUrl: ()=>isAbsoluteUrl_js_namespaceObject.isAbsoluteUrl,
|
|
@@ -79,10 +80,13 @@ function mapSplatParamsForModernLoader(params, hasSplat) {
|
|
|
79
80
|
return rest;
|
|
80
81
|
}
|
|
81
82
|
function getLoaderSignal(ctx) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
const matchSignal = ctx?.abortController?.signal ?? ctx?.signal;
|
|
84
|
+
const requestSignal = ctx?.context?.request?.signal;
|
|
85
|
+
const signals = [
|
|
86
|
+
matchSignal,
|
|
87
|
+
requestSignal
|
|
88
|
+
].filter((signal)=>signal instanceof AbortSignal);
|
|
89
|
+
return AbortSignal.any(signals);
|
|
86
90
|
}
|
|
87
91
|
function getLoaderHref(ctx) {
|
|
88
92
|
if ('string' == typeof ctx?.location) return ctx.location;
|
|
@@ -145,6 +149,7 @@ function modernLoaderToTanstack(opts, modernLoader) {
|
|
|
145
149
|
}
|
|
146
150
|
exports.createRouteStaticData = __webpack_exports__.createRouteStaticData;
|
|
147
151
|
exports.getLoaderHref = __webpack_exports__.getLoaderHref;
|
|
152
|
+
exports.getLoaderSignal = __webpack_exports__.getLoaderSignal;
|
|
148
153
|
exports.handleModernLoaderError = __webpack_exports__.handleModernLoaderError;
|
|
149
154
|
exports.handleModernLoaderResult = __webpack_exports__.handleModernLoaderResult;
|
|
150
155
|
exports.isAbsoluteUrl = __webpack_exports__.isAbsoluteUrl;
|
|
@@ -157,6 +162,7 @@ exports.throwTanstackRedirect = __webpack_exports__.throwTanstackRedirect;
|
|
|
157
162
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
158
163
|
"createRouteStaticData",
|
|
159
164
|
"getLoaderHref",
|
|
165
|
+
"getLoaderSignal",
|
|
160
166
|
"handleModernLoaderError",
|
|
161
167
|
"handleModernLoaderResult",
|
|
162
168
|
"isAbsoluteUrl",
|