@reckona/mreact-router 0.0.81 → 0.0.83
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/README.md +2 -0
- package/dist/adapters/aws-lambda.d.ts.map +1 -1
- package/dist/adapters/aws-lambda.js +17 -22
- package/dist/adapters/aws-lambda.js.map +1 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +3 -1
- package/dist/build.js.map +1 -1
- package/dist/client-route-inference.d.ts +2 -0
- package/dist/client-route-inference.d.ts.map +1 -0
- package/dist/client-route-inference.js +2 -0
- package/dist/client-route-inference.js.map +1 -0
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +89 -24
- package/dist/client.js.map +1 -1
- package/dist/layout-composer.d.ts +24 -0
- package/dist/layout-composer.d.ts.map +1 -0
- package/dist/layout-composer.js +83 -0
- package/dist/layout-composer.js.map +1 -0
- package/dist/metadata.d.ts +9 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +419 -0
- package/dist/metadata.js.map +1 -0
- package/dist/middleware.d.ts +22 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +94 -0
- package/dist/middleware.js.map +1 -0
- package/dist/module-runner.d.ts +2 -2
- package/dist/module-runner.d.ts.map +1 -1
- package/dist/module-runner.js +1 -1
- package/dist/module-runner.js.map +1 -1
- package/dist/navigation-runtime.d.ts +2 -0
- package/dist/navigation-runtime.d.ts.map +1 -0
- package/dist/navigation-runtime.js +2 -0
- package/dist/navigation-runtime.js.map +1 -0
- package/dist/preload-policy.d.ts +24 -0
- package/dist/preload-policy.d.ts.map +1 -0
- package/dist/preload-policy.js +45 -0
- package/dist/preload-policy.js.map +1 -0
- package/dist/render.d.ts +1 -3
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +32 -676
- package/dist/render.js.map +1 -1
- package/dist/route-hydration-contract.d.ts +11 -0
- package/dist/route-hydration-contract.d.ts.map +1 -0
- package/dist/route-hydration-contract.js +21 -0
- package/dist/route-hydration-contract.js.map +1 -0
- package/dist/route-module-loader.d.ts +10 -0
- package/dist/route-module-loader.d.ts.map +1 -0
- package/dist/route-module-loader.js +61 -0
- package/dist/route-module-loader.js.map +1 -0
- package/dist/routes.js +6 -0
- package/dist/routes.js.map +1 -1
- package/dist/serve.d.ts +13 -0
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +63 -28
- package/dist/serve.js.map +1 -1
- package/dist/server-action-inference.d.ts.map +1 -1
- package/dist/server-action-inference.js +37 -1
- package/dist/server-action-inference.js.map +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +2 -1
- package/dist/vite.js.map +1 -1
- package/package.json +11 -11
- package/src/adapters/aws-lambda.ts +21 -28
- package/src/build.ts +9 -6
- package/src/client-route-inference.ts +18 -0
- package/src/client.ts +124 -24
- package/src/layout-composer.ts +142 -0
- package/src/metadata.ts +578 -0
- package/src/middleware.ts +153 -0
- package/src/module-runner.ts +3 -2
- package/src/navigation-runtime.ts +16 -0
- package/src/preload-policy.ts +89 -0
- package/src/render.ts +75 -986
- package/src/route-hydration-contract.ts +22 -0
- package/src/route-module-loader.ts +95 -0
- package/src/routes.ts +8 -0
- package/src/serve.ts +110 -29
- package/src/server-action-inference.ts +49 -0
- package/src/vite.ts +6 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { collectClientRouteReferences, compilerModuleContextForSource, createClientRouteInferenceCache, detectClientNavigationHint, detectNavigationRuntimeHint, formatClientRouteInferenceDiagnostic, inferClientRouteModule, isClientRouteModule, isClientRouteSource, routeToClientManifestEntry, type ClientReferenceImport, type ClientRouteInferenceCache, type ClientRouteInferenceDiagnostic, type ClientRouteInferenceResult, type ClientRouteManifestEntry, type ClientRouteReferenceResult, } from "./client.js";
|
|
2
|
+
//# sourceMappingURL=client-route-inference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-route-inference.d.ts","sourceRoot":"","sources":["../src/client-route-inference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,2BAA2B,EAC3B,oCAAoC,EACpC,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,EACnC,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,GAChC,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { collectClientRouteReferences, compilerModuleContextForSource, createClientRouteInferenceCache, detectClientNavigationHint, detectNavigationRuntimeHint, formatClientRouteInferenceDiagnostic, inferClientRouteModule, isClientRouteModule, isClientRouteSource, routeToClientManifestEntry, } from "./client.js";
|
|
2
|
+
//# sourceMappingURL=client-route-inference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-route-inference.js","sourceRoot":"","sources":["../src/client-route-inference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,2BAA2B,EAC3B,oCAAoC,EACpC,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,GAO3B,MAAM,aAAa,CAAC","sourcesContent":["export {\n collectClientRouteReferences,\n compilerModuleContextForSource,\n createClientRouteInferenceCache,\n detectClientNavigationHint,\n detectNavigationRuntimeHint,\n formatClientRouteInferenceDiagnostic,\n inferClientRouteModule,\n isClientRouteModule,\n isClientRouteSource,\n routeToClientManifestEntry,\n type ClientReferenceImport,\n type ClientRouteInferenceCache,\n type ClientRouteInferenceDiagnostic,\n type ClientRouteInferenceResult,\n type ClientRouteManifestEntry,\n type ClientRouteReferenceResult,\n} from \"./client.js\";\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type ClientRouteModuleAnalysis
|
|
1
|
+
import { type ClientRouteModuleAnalysis } from "@reckona/mreact-compiler";
|
|
2
|
+
import type { ClientReferenceMetadata } from "@reckona/mreact-shared/compiler-contract";
|
|
2
3
|
import { type CompilerModuleContext } from "@reckona/mreact-compiler/internal";
|
|
3
4
|
import { type RouterBundleAssetOutput, type RouterBundleChunkOutput } from "./bundle-pipeline.js";
|
|
4
5
|
import type { AppRoute } from "./routes.js";
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,yBAAyB,EAI/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EAKL,KAAK,qBAAqB,EAC3B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAY5C,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAC;AAIjD,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,g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js
CHANGED
|
@@ -2,11 +2,12 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { readFile, stat } from "node:fs/promises";
|
|
3
3
|
import { builtinModules } from "node:module";
|
|
4
4
|
import { dirname, extname, join, relative, sep } from "node:path";
|
|
5
|
-
import { collectClientRouteModuleAnalysis, formatDiagnostic, } from "@reckona/mreact-compiler";
|
|
5
|
+
import { analyzeBoundaryGraph, collectClientRouteModuleAnalysis, formatDiagnostic, } from "@reckona/mreact-compiler";
|
|
6
6
|
import { collectClientRouteModuleAnalysisFromContext, createCompilerModuleContext, stripTypeScriptWithOxc, transformCompilerModuleContext, } from "@reckona/mreact-compiler/internal";
|
|
7
7
|
import { assetPath } from "./assets.js";
|
|
8
8
|
import { bundleRouterModule, bundleRouterModules, } from "./bundle-pipeline.js";
|
|
9
9
|
import { existingRouteShellCandidates } from "./route-shells.js";
|
|
10
|
+
import { routeDataScriptIds, routeDataScriptSelector, routeHydrationContract, } from "./route-hydration-contract.js";
|
|
10
11
|
import { stripRouteClientSource } from "./route-source.js";
|
|
11
12
|
import { hasJsxSyntax } from "./source-jsx.js";
|
|
12
13
|
import { sourceModuleCandidates } from "./source-modules.js";
|
|
@@ -65,8 +66,16 @@ export async function inferClientRouteModule(options) {
|
|
|
65
66
|
seen: new Set(),
|
|
66
67
|
sourceTransform,
|
|
67
68
|
});
|
|
69
|
+
const mergedRouteInference = routeInference.boundaryGraphFallbackRequired
|
|
70
|
+
? mergeClientRouteInference(routeInference, await inferClientRouteModuleBoundaryGraph({
|
|
71
|
+
cache,
|
|
72
|
+
code,
|
|
73
|
+
filename: options.filename,
|
|
74
|
+
sourceTransform,
|
|
75
|
+
}))
|
|
76
|
+
: routeInference;
|
|
68
77
|
if (options.appDir === undefined) {
|
|
69
|
-
return
|
|
78
|
+
return mergedRouteInference;
|
|
70
79
|
}
|
|
71
80
|
const shellInferences = await inferClientRouteShellModules({
|
|
72
81
|
appDir: options.appDir,
|
|
@@ -75,10 +84,10 @@ export async function inferClientRouteModule(options) {
|
|
|
75
84
|
sourceTransform,
|
|
76
85
|
});
|
|
77
86
|
return {
|
|
78
|
-
client:
|
|
79
|
-
clientBoundaryImports:
|
|
87
|
+
client: mergedRouteInference.client || shellInferences.some((inference) => inference.client),
|
|
88
|
+
clientBoundaryImports: mergedRouteInference.clientBoundaryImports,
|
|
80
89
|
diagnostics: [
|
|
81
|
-
...
|
|
90
|
+
...mergedRouteInference.diagnostics,
|
|
82
91
|
...shellInferences.flatMap((inference) => inference.diagnostics),
|
|
83
92
|
],
|
|
84
93
|
};
|
|
@@ -87,6 +96,46 @@ export async function inferClientRouteModule(options) {
|
|
|
87
96
|
throw new Error(`Failed to infer client route for ${options.routePath ?? "<unknown>"} (${options.filename}).\n${errorMessage(error)}`, { cause: error });
|
|
88
97
|
}
|
|
89
98
|
}
|
|
99
|
+
async function inferClientRouteModuleBoundaryGraph(options) {
|
|
100
|
+
const graph = await analyzeBoundaryGraph({
|
|
101
|
+
entries: [{ file: options.filename, kind: "route-page" }],
|
|
102
|
+
readModule: async (file) => {
|
|
103
|
+
if (file === options.filename) {
|
|
104
|
+
return options.code;
|
|
105
|
+
}
|
|
106
|
+
return await readClientRouteSource({
|
|
107
|
+
cache: options.cache,
|
|
108
|
+
filename: file,
|
|
109
|
+
sourceTransform: options.sourceTransform,
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
resolveModule: async ({ importer, source }) => await resolveAppLocalModule({
|
|
113
|
+
allowExplicitNonSource: options.sourceTransform !== undefined,
|
|
114
|
+
cache: options.cache,
|
|
115
|
+
importer,
|
|
116
|
+
specifier: source,
|
|
117
|
+
}),
|
|
118
|
+
});
|
|
119
|
+
return clientRouteInferenceFromBoundaryGraph(graph, options.filename);
|
|
120
|
+
}
|
|
121
|
+
function clientRouteInferenceFromBoundaryGraph(graph, filename) {
|
|
122
|
+
const clientBoundaryImports = graph.clientBoundaries
|
|
123
|
+
.filter((boundary) => boundary.importerFile === filename)
|
|
124
|
+
.map((boundary) => boundary.source);
|
|
125
|
+
const clientRoute = graph.modules.some((module) => module.file === filename && module.classification === "client-route");
|
|
126
|
+
return {
|
|
127
|
+
client: clientRoute || clientBoundaryImports.length > 0,
|
|
128
|
+
clientBoundaryImports,
|
|
129
|
+
diagnostics: [],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function mergeClientRouteInference(left, right) {
|
|
133
|
+
return {
|
|
134
|
+
client: left.client || right.client,
|
|
135
|
+
clientBoundaryImports: Array.from(new Set([...left.clientBoundaryImports, ...right.clientBoundaryImports])),
|
|
136
|
+
diagnostics: [...left.diagnostics, ...right.diagnostics],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
90
139
|
export async function collectClientRouteReferences(options) {
|
|
91
140
|
const cache = options.cache ?? createClientRouteInferenceCache();
|
|
92
141
|
const sourceTransform = clientRouteSourceTransformForVitePlugins(options.vitePlugins);
|
|
@@ -300,6 +349,7 @@ async function inferClientRouteModuleSource(options) {
|
|
|
300
349
|
const nestedClientExportNames = new Set();
|
|
301
350
|
const clientReferenceSourceFiles = [];
|
|
302
351
|
const diagnostics = [];
|
|
352
|
+
let boundaryGraphFallbackRequired = false;
|
|
303
353
|
let clientProxy = false;
|
|
304
354
|
let nestedClient = false;
|
|
305
355
|
const exportInfo = analysis.topLevelExportRenderInfo;
|
|
@@ -361,6 +411,9 @@ async function inferClientRouteModuleSource(options) {
|
|
|
361
411
|
});
|
|
362
412
|
diagnostics.push(...imported.diagnostics);
|
|
363
413
|
if (!imported.client) {
|
|
414
|
+
if (rendered && imported.boundaryGraphFallbackCandidate) {
|
|
415
|
+
boundaryGraphFallbackRequired = true;
|
|
416
|
+
}
|
|
364
417
|
if (imported.serverOnlyClientRuntime && rendered) {
|
|
365
418
|
diagnostics.push(serverOnlyClientImportReferenceDiagnostic({
|
|
366
419
|
filename: options.filename,
|
|
@@ -447,9 +500,14 @@ async function inferClientRouteModuleSource(options) {
|
|
|
447
500
|
nestedClient = true;
|
|
448
501
|
clientReferenceSourceFiles.push(resolved);
|
|
449
502
|
}
|
|
503
|
+
else if (exported.boundaryGraphFallbackCandidate) {
|
|
504
|
+
boundaryGraphFallbackRequired = true;
|
|
505
|
+
}
|
|
450
506
|
}
|
|
451
507
|
}
|
|
452
508
|
return {
|
|
509
|
+
boundaryGraphFallbackCandidate: analysis.staticExports.length > 0 || boundaryGraphFallbackRequired,
|
|
510
|
+
boundaryGraphFallbackRequired,
|
|
453
511
|
client: clientBoundaryImports.length > 0 ||
|
|
454
512
|
clientBoundaryExportNames.size > 0 ||
|
|
455
513
|
implicitModuleClient ||
|
|
@@ -471,6 +529,8 @@ async function inferClientRouteModuleSource(options) {
|
|
|
471
529
|
}
|
|
472
530
|
function emptyClientRouteModuleInferenceResult(overrides = {}) {
|
|
473
531
|
return {
|
|
532
|
+
boundaryGraphFallbackCandidate: false,
|
|
533
|
+
boundaryGraphFallbackRequired: false,
|
|
474
534
|
client: false,
|
|
475
535
|
clientBoundaryImports: [],
|
|
476
536
|
clientBoundaryExportNames: [],
|
|
@@ -828,11 +888,12 @@ export function withHydrationMarkers(options) {
|
|
|
828
888
|
}
|
|
829
889
|
export function withRouteMarkers(options) {
|
|
830
890
|
const routeId = routeIdForPath(options.routePath);
|
|
831
|
-
return `<div
|
|
891
|
+
return `<div ${routeHydrationContract.routeMarkerAttribute}="${escapeHtmlAttribute(routeId)}">${options.html}</div>`;
|
|
832
892
|
}
|
|
833
893
|
export function hydrationMarkerParts(options) {
|
|
834
894
|
const routeId = routeIdForPath(options.routePath);
|
|
835
895
|
const escapedRouteId = escapeHtmlAttribute(routeId);
|
|
896
|
+
const [propsScriptId, clientReferencesScriptId] = routeDataScriptIds(routeId).map((id) => escapeHtmlAttribute(id));
|
|
836
897
|
const propsJson = escapeScriptJson(JSON.stringify(options.props));
|
|
837
898
|
const script = options.script ?? clientScriptForPath(options.routePath);
|
|
838
899
|
const scriptSrc = assetPath(script, options.assetBaseUrl ?? "/_mreact/client/");
|
|
@@ -840,13 +901,13 @@ export function hydrationMarkerParts(options) {
|
|
|
840
901
|
? undefined
|
|
841
902
|
: escapeScriptJson(JSON.stringify(options.clientReferenceManifest));
|
|
842
903
|
return {
|
|
843
|
-
prefix: `<div
|
|
904
|
+
prefix: `<div ${routeHydrationContract.routeMarkerAttribute}="${escapedRouteId}">`,
|
|
844
905
|
suffix: [
|
|
845
906
|
"</div>",
|
|
846
|
-
`<script type="application/json" id="
|
|
907
|
+
`<script type="application/json" id="${propsScriptId}">${propsJson}</script>`,
|
|
847
908
|
clientReferencesJson === undefined
|
|
848
909
|
? undefined
|
|
849
|
-
: `<script type="application/json" id="
|
|
910
|
+
: `<script type="application/json" id="${clientReferencesScriptId}">${clientReferencesJson}</script>`,
|
|
850
911
|
`<script type="module" src="${escapeHtmlAttribute(scriptSrc)}"></script>`,
|
|
851
912
|
]
|
|
852
913
|
.filter((part) => part !== undefined)
|
|
@@ -1145,7 +1206,7 @@ function __mreactResolveRouteNode(value) {
|
|
|
1145
1206
|
const boundaryOnlyHydrationBlock = routeRequiresFullHydration
|
|
1146
1207
|
? ""
|
|
1147
1208
|
: `${routeCellHydrationIndent}if (!__mreactHasNonSerializableClientBoundaries(__mreactMarker) && __mreactHydrateClientBoundaries(document, __mreactClientReferences, __mreactClientReferenceComponents)) {
|
|
1148
|
-
${routeCellHydrationIndent} __mreactMarker.setAttribute(
|
|
1209
|
+
${routeCellHydrationIndent} __mreactMarker.setAttribute(${JSON.stringify(routeHydrationContract.hydratedAttribute)}, "true");
|
|
1149
1210
|
${routeCellHydrationIndent} return;
|
|
1150
1211
|
${routeCellHydrationIndent}}
|
|
1151
1212
|
`;
|
|
@@ -1156,8 +1217,12 @@ ${routeCellHydrationIndent}}
|
|
|
1156
1217
|
const entry = `${routeCellEffectImport}${routeCleanupScopeImport}${emitCompatClientReferenceImportBlock(compatClientReferenceNames)}${clientReferenceImportBlock}${routeHydrationCode}
|
|
1157
1218
|
|
|
1158
1219
|
const __mreactRouteId = ${JSON.stringify(routeId)};
|
|
1159
|
-
const __mreactRouteStateSignature = ${JSON.stringify(routeStateSignature)};
|
|
1160
|
-
const
|
|
1220
|
+
const __mreactRouteStateSignature = ${JSON.stringify(routeStateSignature)};
|
|
1221
|
+
const __mreactRouteMarkerAttribute = ${JSON.stringify(routeHydrationContract.routeMarkerAttribute)};
|
|
1222
|
+
const __mreactRouteHydratedAttribute = ${JSON.stringify(routeHydrationContract.hydratedAttribute)};
|
|
1223
|
+
const __mreactPropsScriptPrefix = ${JSON.stringify(routeHydrationContract.propsScriptPrefix)};
|
|
1224
|
+
const __mreactClientReferencesScriptPrefix = ${JSON.stringify(routeHydrationContract.clientReferencesScriptPrefix)};
|
|
1225
|
+
const __mreactGlobal = globalThis;
|
|
1161
1226
|
${navigationStateDeclaration}
|
|
1162
1227
|
${routeCellStateDeclaration}
|
|
1163
1228
|
${routeCleanupStateDeclaration}
|
|
@@ -1167,9 +1232,9 @@ ${routeNodeResolver}
|
|
|
1167
1232
|
|
|
1168
1233
|
export function __mreactHydrateRoute() {
|
|
1169
1234
|
__mreactApplyOutOfOrderFragments(document);
|
|
1170
|
-
const __mreactMarker = document.querySelector(\`[
|
|
1171
|
-
const __mreactPropsElement = document.getElementById(
|
|
1172
|
-
const __mreactClientReferencesElement = document.getElementById(
|
|
1235
|
+
const __mreactMarker = document.querySelector(\`[\${__mreactRouteMarkerAttribute}="\${__mreactRouteId}"]\`);
|
|
1236
|
+
const __mreactPropsElement = document.getElementById(\`\${__mreactPropsScriptPrefix}\${__mreactRouteId}\`);
|
|
1237
|
+
const __mreactClientReferencesElement = document.getElementById(\`\${__mreactClientReferencesScriptPrefix}\${__mreactRouteId}\`);
|
|
1173
1238
|
const __mreactProps = __mreactPropsElement?.textContent === undefined
|
|
1174
1239
|
? {}
|
|
1175
1240
|
: JSON.parse(__mreactPropsElement.textContent);
|
|
@@ -1186,7 +1251,7 @@ export function __mreactHydrateRoute() {
|
|
|
1186
1251
|
${routeCellHydrationStart}${routeCleanupHydrationStart}${boundaryOnlyHydrationBlock}${routeComponentGuard}${routeCellHydrationIndent}const __mreactNode = ${routeNodeExpression};
|
|
1187
1252
|
${routeCellHydrationIndent}__mreactResumeRoute(__mreactMarker, __mreactNode);
|
|
1188
1253
|
${routeCellHydrationIndent}__mreactHydrateClientBoundaries(document, __mreactClientReferences, __mreactClientReferenceComponents);
|
|
1189
|
-
${routeCellHydrationIndent}__mreactMarker.setAttribute(
|
|
1254
|
+
${routeCellHydrationIndent}__mreactMarker.setAttribute(__mreactRouteHydratedAttribute, "true");
|
|
1190
1255
|
${routeCellHydrationEnd}}
|
|
1191
1256
|
${routeCellDropFunction}
|
|
1192
1257
|
${routeCleanupFunction}
|
|
@@ -1572,15 +1637,15 @@ function __mreactApplyNavigationHtml(html, url) {
|
|
|
1572
1637
|
const template = document.createElement("template");
|
|
1573
1638
|
template.innerHTML = html.replace(/^\\s*<!doctype html>/i, "");
|
|
1574
1639
|
__mreactApplyOutOfOrderFragments(template.content);
|
|
1575
|
-
const nextMarker = template.content.querySelector("[
|
|
1576
|
-
const currentMarker = document.querySelector("[
|
|
1640
|
+
const nextMarker = template.content.querySelector("[${routeHydrationContract.routeMarkerAttribute}]");
|
|
1641
|
+
const currentMarker = document.querySelector("[${routeHydrationContract.routeMarkerAttribute}]");
|
|
1577
1642
|
|
|
1578
1643
|
if (nextMarker === null || currentMarker === null) {
|
|
1579
1644
|
return false;
|
|
1580
1645
|
}
|
|
1581
1646
|
|
|
1582
|
-
const currentRouteId = currentMarker.getAttribute("
|
|
1583
|
-
const nextRouteId = nextMarker.getAttribute("
|
|
1647
|
+
const currentRouteId = currentMarker.getAttribute("${routeHydrationContract.routeMarkerAttribute}");
|
|
1648
|
+
const nextRouteId = nextMarker.getAttribute("${routeHydrationContract.routeMarkerAttribute}");
|
|
1584
1649
|
|
|
1585
1650
|
__mreactSyncHeadMetadata(template.content, html);
|
|
1586
1651
|
__mreactResumeNode(currentMarker, nextMarker);
|
|
@@ -1588,7 +1653,7 @@ ${routeCleanupNavigationDispose} __mreactSyncRouteDataScripts(template.content,
|
|
|
1588
1653
|
|
|
1589
1654
|
const script = template.content.querySelector('script[type="module"][src]')?.getAttribute("src");
|
|
1590
1655
|
if (script !== null && script !== undefined) {
|
|
1591
|
-
void import(/* @vite-ignore */ script).then((module) => module.
|
|
1656
|
+
void import(/* @vite-ignore */ script).then((module) => module.${routeHydrationContract.routeHydrateExport}?.());
|
|
1592
1657
|
}
|
|
1593
1658
|
|
|
1594
1659
|
__mreactApplyOutOfOrderFragments(document);
|
|
@@ -1681,15 +1746,15 @@ function __mreactRouteDataScriptIds(...routeIds) {
|
|
|
1681
1746
|
continue;
|
|
1682
1747
|
}
|
|
1683
1748
|
|
|
1684
|
-
ids.add(
|
|
1685
|
-
ids.add(
|
|
1749
|
+
ids.add(\`${routeHydrationContract.propsScriptPrefix}\${routeId}\`);
|
|
1750
|
+
ids.add(\`${routeHydrationContract.clientReferencesScriptPrefix}\${routeId}\`);
|
|
1686
1751
|
}
|
|
1687
1752
|
|
|
1688
1753
|
return ids;
|
|
1689
1754
|
}
|
|
1690
1755
|
|
|
1691
1756
|
function __mreactRouteDataScriptSelector() {
|
|
1692
|
-
return
|
|
1757
|
+
return ${JSON.stringify(routeDataScriptSelector())};
|
|
1693
1758
|
}
|
|
1694
1759
|
|
|
1695
1760
|
function __mreactCurrentHistoryState(url) {
|