@reckona/mreact-router 0.0.165 → 0.0.167
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/actions.d.ts +6 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +71 -8
- package/dist/actions.js.map +1 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +21 -8
- package/dist/build.js.map +1 -1
- package/dist/render.d.ts +1 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +42 -16
- package/dist/render.js.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +1 -0
- package/dist/serve.js.map +1 -1
- package/package.json +11 -11
- package/src/actions.ts +106 -8
- package/src/build.ts +29 -11
- package/src/render.ts +76 -25
- package/src/serve.ts +1 -0
package/dist/render.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export declare function preloadBuiltRequestModules(options: {
|
|
|
71
71
|
serverModules?: ReadonlyMap<string, BuiltServerModuleArtifact> | undefined;
|
|
72
72
|
serverModuleCacheVersion: string;
|
|
73
73
|
serverSourceFiles: ReadonlyMap<string, string>;
|
|
74
|
+
serverActionReferencesByFile?: ReadonlyMap<string, readonly PreparedFormActionReference[]> | undefined;
|
|
74
75
|
vitePlugins?: readonly PluginOption[] | undefined;
|
|
75
76
|
}): Promise<void>;
|
|
76
77
|
export declare function routerRenderRuntimeCacheStats(): RouterRuntimeCacheStat[];
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EAChB,eAAe,EAChB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAIL,KAAK,yBAAyB,EAE/B,MAAM,6BAA6B,CAAC;AAUrC,OAAO,KAAK,EAAE,QAAQ,E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E,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACjD,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CACnD,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBlB;AA8MD,iBAAS,6BAA6B,CAAC,OAAO,EAAE;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACjD,wBAAwB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CACnD,GAAG,MAAM,GAAG,SAAS,CAIrB;AAED,eAAO,MAAM,yCAAyC,sCAAgC,CAAC;AAkMvF,UAAU,YAAY;IACpB,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC1B;AAED,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CAmDnD;AAED,eAAO,MAAM,yBAAyB,sBAAgB,CAAC"}
|
package/dist/render.js
CHANGED
|
@@ -11,7 +11,7 @@ import { assetPath } from "./assets.js";
|
|
|
11
11
|
import { escapeHtmlAttribute } from "@reckona/mreact-shared/html-escape";
|
|
12
12
|
import { matchRoute, scanAppRoutes } from "./routes.js";
|
|
13
13
|
import { appFileConventionContentType } from "./file-conventions.js";
|
|
14
|
-
import { dispatchServerActionRequest, prepareRouteServerActions, } from "./actions.js";
|
|
14
|
+
import { dispatchServerActionRequest, prepareRouteServerActionPlaceholders, prepareRouteServerActions, } from "./actions.js";
|
|
15
15
|
import { serverActionCookie } from "./csrf.js";
|
|
16
16
|
import { beginRouteCacheContext, cachedRouteResponse, cacheRouteResponse, routeCacheKey, routeCachePolicyFromSource, } from "./cache.js";
|
|
17
17
|
import { resolveRouterCacheLimit } from "./cache-config.js";
|
|
@@ -20,7 +20,7 @@ import { bytesResponse, htmlResponse } from "./http.js";
|
|
|
20
20
|
import { isNotFoundError, isRedirectError, rewriteLocation } from "./navigation.js";
|
|
21
21
|
import { createAppRouterImportPolicyPlugin } from "./import-policy.js";
|
|
22
22
|
import { existingRouteShellCandidates } from "./route-shells.js";
|
|
23
|
-
import { hasLoaderExport, isStreamRouteSource, routeClosureMayUseAwaitBoundary, stripRouteClientOnlyExports, stripRouteLoaderOnlyExports, stripRouteMetadataOnlyExports,
|
|
23
|
+
import { hasLoaderExport, isStreamRouteSource, routeClosureMayUseAwaitBoundary, stripRouteBuildExports, stripRouteModuleExports, stripRouteClientOnlyExports, stripRouteClientSource, stripRouteLoaderOnlyExports, stripRouteMetadataOnlyExports, } from "./route-source.js";
|
|
24
24
|
import { emitRouterLog, logDurationMs, logNow } from "./logger.js";
|
|
25
25
|
import { createRouterRuntimeCacheCounters, readRouterRuntimeCacheEntry, routerRuntimeCacheStat, } from "./cache-stats.js";
|
|
26
26
|
import { bundleRouterModule } from "./bundle-pipeline.js";
|
|
@@ -73,21 +73,29 @@ export async function preloadBuiltRequestModules(options) {
|
|
|
73
73
|
continue;
|
|
74
74
|
}
|
|
75
75
|
if (options.includeRenderModules !== false) {
|
|
76
|
+
const actionReferences = options.serverActionReferencesByFile?.get(route.file) ?? [];
|
|
77
|
+
const analysisCode = actionReferences.length === 0
|
|
78
|
+
? code
|
|
79
|
+
: prepareRouteServerActionPlaceholders({
|
|
80
|
+
code,
|
|
81
|
+
formActionReferences: actionReferences,
|
|
82
|
+
});
|
|
76
83
|
const analysis = await analyzeRouteSource({
|
|
77
84
|
appDir: options.appDir,
|
|
78
85
|
artifact: options.serverModules?.get(route.file)?.analysis,
|
|
79
|
-
code,
|
|
86
|
+
buildRenderCode: analysisCode !== code,
|
|
87
|
+
code: analysisCode,
|
|
80
88
|
filename: route.file,
|
|
81
89
|
routePath: route.path,
|
|
82
90
|
clientRouteInferenceCache,
|
|
83
|
-
serverModuleCacheVersion: options.serverModuleCacheVersion,
|
|
91
|
+
serverModuleCacheVersion: actionReferences.length === 0 ? options.serverModuleCacheVersion : undefined,
|
|
84
92
|
serverSourceFiles: options.serverSourceFiles,
|
|
85
93
|
vitePlugins: options.vitePlugins,
|
|
86
94
|
});
|
|
87
95
|
await preloadBuiltPageRouteModules({
|
|
88
96
|
...options,
|
|
89
97
|
analysis,
|
|
90
|
-
code,
|
|
98
|
+
code: analysisCode,
|
|
91
99
|
file: route.file,
|
|
92
100
|
});
|
|
93
101
|
}
|
|
@@ -553,6 +561,7 @@ async function renderAppRequestInternal(options) {
|
|
|
553
561
|
appDir: options.appDir,
|
|
554
562
|
code: originalCode,
|
|
555
563
|
formActionReferences: options.serverActionReferencesByFile?.get(matched.route.file),
|
|
564
|
+
placeholders: true,
|
|
556
565
|
pageFile: matched.route.file,
|
|
557
566
|
request: options.request,
|
|
558
567
|
});
|
|
@@ -566,6 +575,7 @@ async function renderAppRequestInternal(options) {
|
|
|
566
575
|
? originalAnalysis
|
|
567
576
|
: await analyzeRouteSource({
|
|
568
577
|
appDir: options.appDir,
|
|
578
|
+
buildRenderCode: preparedActions.htmlReplacements !== undefined,
|
|
569
579
|
code,
|
|
570
580
|
filename: matched.route.file,
|
|
571
581
|
routePath: matched.route.path,
|
|
@@ -584,7 +594,7 @@ async function renderAppRequestInternal(options) {
|
|
|
584
594
|
const dataPromise = routeAnalysis.hasLoader
|
|
585
595
|
? loadRouteDataWithInstrumentation({
|
|
586
596
|
appDir: options.appDir,
|
|
587
|
-
code,
|
|
597
|
+
code: originalCode,
|
|
588
598
|
context: {
|
|
589
599
|
env: options.env,
|
|
590
600
|
params: matched.params,
|
|
@@ -739,13 +749,13 @@ async function renderAppRequestInternal(options) {
|
|
|
739
749
|
});
|
|
740
750
|
html = injectAuthSessionClaims(html, originalAnalysis.authIncludesClaims ? currentAuthClaims() : undefined);
|
|
741
751
|
html = injectQueryState(html, dehydrate(queryClient));
|
|
742
|
-
const response = withOptionalActionCookie(htmlResponse(`<!DOCTYPE html>${clientNavigationHeadTags({
|
|
752
|
+
const response = withOptionalActionCookie(htmlResponse(applyActionHtmlReplacements(`<!DOCTYPE html>${clientNavigationHeadTags({
|
|
743
753
|
assetBaseUrl: options.assetBaseUrl,
|
|
744
754
|
currentStyleSheets: clientStyleSheets,
|
|
745
755
|
currentScript: clientRoute ? clientScript : undefined,
|
|
746
756
|
currentNavigationScript: clientRoute ? undefined : navigationScript,
|
|
747
757
|
routeScripts: options.clientScripts,
|
|
748
|
-
})}${html}`, {
|
|
758
|
+
})}${html}`, preparedActions.htmlReplacements), {
|
|
749
759
|
headers: responseHeadersForMetadata(metadata, options.request, {
|
|
750
760
|
"x-mreact-stream": "1",
|
|
751
761
|
}),
|
|
@@ -756,7 +766,7 @@ async function renderAppRequestInternal(options) {
|
|
|
756
766
|
let streamData;
|
|
757
767
|
let streamDataPromise = dataPromise ?? Promise.resolve(undefined);
|
|
758
768
|
phaseStartedAt = renderTimingPhaseStartedAt(timing);
|
|
759
|
-
if (loadingFile === undefined || routeLoaderMayReturnControlResponse(
|
|
769
|
+
if (loadingFile === undefined || routeLoaderMayReturnControlResponse(originalCode)) {
|
|
760
770
|
try {
|
|
761
771
|
streamData = dataPromise === undefined ? undefined : await dataPromise;
|
|
762
772
|
}
|
|
@@ -982,13 +992,13 @@ async function renderAppRequestInternal(options) {
|
|
|
982
992
|
});
|
|
983
993
|
html = injectAuthSessionClaims(html, originalAnalysis.authIncludesClaims ? currentAuthClaims() : undefined);
|
|
984
994
|
html = injectQueryState(html, dehydrate(queryClient));
|
|
985
|
-
const response = withOptionalActionCookie(htmlResponse(`<!DOCTYPE html>${clientNavigationHeadTags({
|
|
995
|
+
const response = withOptionalActionCookie(htmlResponse(applyActionHtmlReplacements(`<!DOCTYPE html>${clientNavigationHeadTags({
|
|
986
996
|
assetBaseUrl: options.assetBaseUrl,
|
|
987
997
|
currentStyleSheets: clientStyleSheets,
|
|
988
998
|
currentScript: clientRoute ? clientScript : undefined,
|
|
989
999
|
currentNavigationScript: clientRoute ? undefined : navigationScript,
|
|
990
1000
|
routeScripts: options.clientScripts,
|
|
991
|
-
})}${html}`, {
|
|
1001
|
+
})}${html}`, preparedActions.htmlReplacements), {
|
|
992
1002
|
headers: responseHeadersForMetadata(metadata, options.request),
|
|
993
1003
|
}), preparedActions.csrfToken, preparedActions.csrfTokenIsNew === true);
|
|
994
1004
|
const effectiveCachePolicy = cachePolicy ?? routeCacheContext.cachePolicy;
|
|
@@ -1085,6 +1095,16 @@ function withOptionalActionCookie(response, csrfToken, csrfTokenIsNew) {
|
|
|
1085
1095
|
}
|
|
1086
1096
|
return response;
|
|
1087
1097
|
}
|
|
1098
|
+
function applyActionHtmlReplacements(html, replacements) {
|
|
1099
|
+
if (replacements === undefined || replacements.length === 0) {
|
|
1100
|
+
return html;
|
|
1101
|
+
}
|
|
1102
|
+
let next = html;
|
|
1103
|
+
for (const [placeholder, value] of replacements) {
|
|
1104
|
+
next = next.replaceAll(placeholder, escapeHtmlAttribute(value));
|
|
1105
|
+
}
|
|
1106
|
+
return next;
|
|
1107
|
+
}
|
|
1088
1108
|
function modulePreloadTags(script, assetBaseUrl) {
|
|
1089
1109
|
return script === undefined
|
|
1090
1110
|
? ""
|
|
@@ -1818,7 +1838,7 @@ async function analyzeRouteSource(options) {
|
|
|
1818
1838
|
finishRenderTimingPhase(options.timing, artifactStartedAt, "sourceAnalysisArtifactMs");
|
|
1819
1839
|
return analysis;
|
|
1820
1840
|
}
|
|
1821
|
-
const cacheKey = `${options.serverModuleCacheVersion ?? "dev"}\0${options.filename}\0${sourceHash}\0${viteDefineCacheKey(options.define)}\0${vitePluginsCacheKey(options.vitePlugins)}`;
|
|
1841
|
+
const cacheKey = `${options.serverModuleCacheVersion ?? "dev"}\0${options.filename}\0${sourceHash}\0${options.buildRenderCode === true ? "build-render" : "render"}\0${viteDefineCacheKey(options.define)}\0${vitePluginsCacheKey(options.vitePlugins)}`;
|
|
1822
1842
|
const cached = readRouterRuntimeCacheEntry(routeSourceAnalysisCache, cacheKey, routeSourceAnalysisCacheCounters);
|
|
1823
1843
|
if (cached !== undefined) {
|
|
1824
1844
|
return cached;
|
|
@@ -1847,11 +1867,13 @@ function routeSourceAnalysisFromArtifact(artifact) {
|
|
|
1847
1867
|
};
|
|
1848
1868
|
}
|
|
1849
1869
|
async function analyzeRouteSourceUncached(options) {
|
|
1850
|
-
const routeCode =
|
|
1870
|
+
const routeCode = options.buildRenderCode === true
|
|
1871
|
+
? stripRouteBuildExports(options.code, options.filename)
|
|
1872
|
+
: stripRouteModuleExports(options.code, options.filename);
|
|
1851
1873
|
const clientInference = await inferClientRouteModule({
|
|
1852
1874
|
appDir: options.appDir,
|
|
1853
1875
|
cache: options.clientRouteInferenceCache,
|
|
1854
|
-
code:
|
|
1876
|
+
code: stripRouteClientSource({ code: options.code, filename: options.filename }),
|
|
1855
1877
|
filename: options.filename,
|
|
1856
1878
|
routePath: options.routePath,
|
|
1857
1879
|
vitePlugins: options.vitePlugins,
|
|
@@ -1902,6 +1924,7 @@ async function loadServerModule(code, sourcefile, serverModules, serverModuleCac
|
|
|
1902
1924
|
const artifact = serverModules?.get(sourcefile)?.string;
|
|
1903
1925
|
const codeHash = memoizedHashText(code);
|
|
1904
1926
|
const prebuiltCode = prebuiltServerComponentModuleCode(artifact, code, codeHash);
|
|
1927
|
+
const usesPrebuiltCompiledCode = artifact?.code === code;
|
|
1905
1928
|
if (artifact !== undefined &&
|
|
1906
1929
|
prebuiltServerModuleOutputMatches(artifact, code, codeHash) &&
|
|
1907
1930
|
artifact.moduleFile !== undefined) {
|
|
@@ -1929,7 +1952,7 @@ async function loadServerModule(code, sourcefile, serverModules, serverModuleCac
|
|
|
1929
1952
|
label: "Server component",
|
|
1930
1953
|
}),
|
|
1931
1954
|
],
|
|
1932
|
-
...(prebuiltCode === undefined
|
|
1955
|
+
...(prebuiltCode === undefined && !usesPrebuiltCompiledCode
|
|
1933
1956
|
? {
|
|
1934
1957
|
resolveDir: dirname(sourcefile),
|
|
1935
1958
|
serverSourceTransform: {
|
|
@@ -1941,6 +1964,7 @@ async function loadServerModule(code, sourcefile, serverModules, serverModuleCac
|
|
|
1941
1964
|
},
|
|
1942
1965
|
}
|
|
1943
1966
|
: {}),
|
|
1967
|
+
...(usesPrebuiltCompiledCode ? { resolveDir: dirname(sourcefile) } : {}),
|
|
1944
1968
|
sourcefile,
|
|
1945
1969
|
vitePlugins,
|
|
1946
1970
|
});
|
|
@@ -2230,6 +2254,7 @@ async function loadServerStreamModule(code, sourcefile, serverModules, serverMod
|
|
|
2230
2254
|
const artifactCode = serverModules?.get(sourcefile)?.stream;
|
|
2231
2255
|
const codeHash = memoizedHashText(code);
|
|
2232
2256
|
const prebuiltCode = prebuiltServerComponentModuleCode(artifactCode, code, codeHash, outputOptions);
|
|
2257
|
+
const usesPrebuiltCompiledCode = artifactCode?.code === code;
|
|
2233
2258
|
if (artifactCode !== undefined &&
|
|
2234
2259
|
prebuiltServerModuleOutputOptionsMatch(artifactCode, outputOptions) &&
|
|
2235
2260
|
prebuiltServerModuleOutputMatches(artifactCode, code, codeHash) &&
|
|
@@ -2258,7 +2283,7 @@ async function loadServerStreamModule(code, sourcefile, serverModules, serverMod
|
|
|
2258
2283
|
label: "Server stream component",
|
|
2259
2284
|
}),
|
|
2260
2285
|
],
|
|
2261
|
-
...(prebuiltCode === undefined
|
|
2286
|
+
...(prebuiltCode === undefined && !usesPrebuiltCompiledCode
|
|
2262
2287
|
? {
|
|
2263
2288
|
resolveDir: dirname(sourcefile),
|
|
2264
2289
|
serverSourceTransform: {
|
|
@@ -2270,6 +2295,7 @@ async function loadServerStreamModule(code, sourcefile, serverModules, serverMod
|
|
|
2270
2295
|
},
|
|
2271
2296
|
}
|
|
2272
2297
|
: {}),
|
|
2298
|
+
...(usesPrebuiltCompiledCode ? { resolveDir: dirname(sourcefile) } : {}),
|
|
2273
2299
|
sourcefile,
|
|
2274
2300
|
vitePlugins,
|
|
2275
2301
|
});
|