vinext 0.0.43 → 0.0.45
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/build/google-fonts/build-url.d.ts +10 -0
- package/dist/build/google-fonts/build-url.js +30 -0
- package/dist/build/google-fonts/build-url.js.map +1 -0
- package/dist/build/google-fonts/font-data.js +24985 -0
- package/dist/build/google-fonts/font-data.js.map +1 -0
- package/dist/build/google-fonts/font-metadata.d.ts +17 -0
- package/dist/build/google-fonts/font-metadata.js +7 -0
- package/dist/build/google-fonts/font-metadata.js.map +1 -0
- package/dist/build/google-fonts/get-axes.d.ts +7 -0
- package/dist/build/google-fonts/get-axes.js +39 -0
- package/dist/build/google-fonts/get-axes.js.map +1 -0
- package/dist/build/google-fonts/sort-variants.d.ts +5 -0
- package/dist/build/google-fonts/sort-variants.js +14 -0
- package/dist/build/google-fonts/sort-variants.js.map +1 -0
- package/dist/build/google-fonts/validate.d.ts +28 -0
- package/dist/build/google-fonts/validate.js +56 -0
- package/dist/build/google-fonts/validate.js.map +1 -0
- package/dist/build/layout-classification.d.ts +1 -1
- package/dist/build/layout-classification.js.map +1 -1
- package/dist/build/nitro-route-rules.d.ts +1 -1
- package/dist/build/nitro-route-rules.js.map +1 -1
- package/dist/build/precompress.d.ts +1 -1
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +1 -7
- package/dist/build/prerender.js +7 -3
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/run-prerender.d.ts +1 -13
- package/dist/build/run-prerender.js +5 -1
- package/dist/build/run-prerender.js.map +1 -1
- package/dist/build/standalone.d.ts +1 -1
- package/dist/build/standalone.js.map +1 -1
- package/dist/client/vinext-next-data.d.ts +1 -3
- package/dist/cloudflare/kv-cache-handler.d.ts +5 -0
- package/dist/cloudflare/kv-cache-handler.js +56 -35
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/cloudflare/tpr.d.ts +1 -16
- package/dist/cloudflare/tpr.js +1 -1
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/dotenv.d.ts +1 -1
- package/dist/config/dotenv.js.map +1 -1
- package/dist/deploy.d.ts +1 -1
- package/dist/deploy.js +21 -4
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-rsc-entry.js +93 -15
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js.map +1 -1
- package/dist/plugins/async-hooks-stub.d.ts +1 -2
- package/dist/plugins/async-hooks-stub.js +2 -2
- package/dist/plugins/async-hooks-stub.js.map +1 -1
- package/dist/plugins/fonts.d.ts +1 -20
- package/dist/plugins/fonts.js +42 -21
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/server-externals-manifest.d.ts +1 -11
- package/dist/plugins/server-externals-manifest.js +1 -1
- package/dist/plugins/server-externals-manifest.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -1
- package/dist/routing/app-router.js +12 -6
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.d.ts +1 -3
- package/dist/routing/file-matcher.js +1 -1
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/utils.d.ts +1 -29
- package/dist/routing/utils.js +1 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/app-browser-entry.js +183 -99
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-state.d.ts +1 -1
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +1 -1
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-elements.d.ts +1 -2
- package/dist/server/app-elements.js +1 -1
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-page-boundary-render.d.ts +3 -1
- package/dist/server/app-page-boundary-render.js +2 -0
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +2 -1
- package/dist/server/app-page-boundary.js +10 -5
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +1 -1
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +4 -2
- package/dist/server/app-page-execution.js +19 -4
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-probe.d.ts +1 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render.d.ts +2 -2
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +1 -1
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.d.ts +1 -1
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +2 -8
- package/dist/server/app-page-route-wiring.js +13 -3
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +2 -1
- package/dist/server/app-page-stream.js +5 -3
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-route-handler-cache.d.ts +1 -1
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +1 -1
- package/dist/server/app-route-handler-execution.js +9 -4
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-policy.d.ts +6 -2
- package/dist/server/app-route-handler-policy.js +8 -3
- package/dist/server/app-route-handler-policy.js.map +1 -1
- package/dist/server/app-route-handler-response.d.ts +1 -1
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-route-handler-runtime.d.ts +1 -1
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-route-handler-runtime.js.map +1 -1
- package/dist/server/app-router-entry.js +8 -1
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +35 -0
- package/dist/server/app-server-action-execution.js +105 -0
- package/dist/server/app-server-action-execution.js.map +1 -0
- package/dist/server/app-ssr-entry.js +2 -1
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +1 -1
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/csp.d.ts +1 -2
- package/dist/server/csp.js +1 -1
- package/dist/server/csp.js.map +1 -1
- package/dist/server/dev-module-runner.d.ts +1 -1
- package/dist/server/dev-module-runner.js.map +1 -1
- package/dist/server/middleware-request-headers.d.ts +1 -3
- package/dist/server/middleware-request-headers.js +4 -4
- package/dist/server/middleware-request-headers.js.map +1 -1
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +1 -1
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-i18n.d.ts +2 -3
- package/dist/server/pages-i18n.js +1 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-node-compat.d.ts +1 -2
- package/dist/server/pages-node-compat.js +1 -1
- package/dist/server/pages-node-compat.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +1 -1
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +1 -1
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prod-server.js +18 -13
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +33 -1
- package/dist/server/request-pipeline.js +44 -2
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/socket-error-backstop.d.ts +17 -0
- package/dist/server/socket-error-backstop.js +129 -0
- package/dist/server/socket-error-backstop.js.map +1 -0
- package/dist/server/static-file-cache.d.ts +1 -1
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/cache-runtime.js +16 -3
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +3 -1
- package/dist/shims/cache.js +83 -22
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +1 -1
- package/dist/shims/fetch-cache.d.ts +10 -1
- package/dist/shims/fetch-cache.js +24 -4
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +16 -18
- package/dist/shims/font-google-base.js +25 -16
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/form.js +1 -1
- package/dist/shims/link.js +1 -1
- package/dist/shims/navigation.d.ts +7 -3
- package/dist/shims/navigation.js +28 -5
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/server.d.ts +2 -0
- package/dist/shims/server.js +18 -5
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/url-safety.d.ts +3 -1
- package/dist/shims/url-safety.js +5 -1
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/utils/error-cause.d.ts +5 -0
- package/dist/utils/error-cause.js +97 -0
- package/dist/utils/error-cause.js.map +1 -0
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/entry.d.ts +0 -1
- package/dist/client/entry.js +0 -60
- package/dist/client/entry.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-data.js","names":[],"sources":["../../../src/build/google-fonts/font-data.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/build/google-fonts/font-metadata.d.ts
|
|
2
|
+
type VariableAxisDescriptor = {
|
|
3
|
+
tag: string;
|
|
4
|
+
min: number;
|
|
5
|
+
max: number;
|
|
6
|
+
defaultValue: number;
|
|
7
|
+
};
|
|
8
|
+
type FontFamilyMetadata = {
|
|
9
|
+
/** Available weight values, plus the literal "variable" if a variable face exists. */weights: string[]; /** Available styles, e.g. ["normal"], ["italic"], or both. */
|
|
10
|
+
styles: string[]; /** Variable axes for this family. Absent when the family has no variable face. */
|
|
11
|
+
axes?: VariableAxisDescriptor[]; /** Preloadable subsets (e.g. "latin", "latin-ext", "vietnamese"). */
|
|
12
|
+
subsets: string[];
|
|
13
|
+
};
|
|
14
|
+
declare const googleFontsMetadata: Record<string, FontFamilyMetadata>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { googleFontsMetadata };
|
|
17
|
+
//# sourceMappingURL=font-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-metadata.js","names":["rawFontData"],"sources":["../../../src/build/google-fonts/font-metadata.ts"],"sourcesContent":["// Typed wrapper around the vendored Google Fonts metadata.\n//\n// `font-data.json` is vendored from vercel/next.js\n// (`packages/font/src/google/font-data.json`, MIT License,\n// Copyright (c) Vercel, Inc.). Refresh by re-copying that file. Both Next.js\n// and vinext are MIT licensed, so the file is redistributed under the same\n// terms.\n\nimport rawFontData from \"./font-data.json\" with { type: \"json\" };\n\ntype VariableAxisDescriptor = {\n tag: string;\n min: number;\n max: number;\n defaultValue: number;\n};\n\ntype FontFamilyMetadata = {\n /** Available weight values, plus the literal \"variable\" if a variable face exists. */\n weights: string[];\n /** Available styles, e.g. [\"normal\"], [\"italic\"], or both. */\n styles: string[];\n /** Variable axes for this family. Absent when the family has no variable face. */\n axes?: VariableAxisDescriptor[];\n /** Preloadable subsets (e.g. \"latin\", \"latin-ext\", \"vietnamese\"). */\n subsets: string[];\n};\n\n// Strongly typed view of the JSON. The repo bans `as` casts, so the type is\n// imposed via an explicit annotation on the export. TypeScript still\n// structurally verifies that the JSON's shape is assignable to\n// `Record<string, FontFamilyMetadata>`.\nexport const googleFontsMetadata: Record<string, FontFamilyMetadata> = rawFontData;\n"],"mappings":";;AAgCA,MAAa,sBAA0DA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FontAxes } from "./build-url.js";
|
|
2
|
+
|
|
3
|
+
//#region src/build/google-fonts/get-axes.d.ts
|
|
4
|
+
declare function getFontAxes(fontFamily: string, weights: string[], styles: string[], selectedVariableAxes?: string[]): FontAxes;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { getFontAxes };
|
|
7
|
+
//# sourceMappingURL=get-axes.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { googleFontsMetadata } from "./font-metadata.js";
|
|
2
|
+
//#region src/build/google-fonts/get-axes.ts
|
|
3
|
+
const formatAvailableValues = (values) => values.map((val) => `\`${val}\``).join(", ");
|
|
4
|
+
function getFontAxes(fontFamily, weights, styles, selectedVariableAxes) {
|
|
5
|
+
const hasItalic = styles.includes("italic");
|
|
6
|
+
const hasNormal = styles.includes("normal");
|
|
7
|
+
const ital = hasItalic ? [...hasNormal ? ["0"] : [], "1"] : void 0;
|
|
8
|
+
if (weights[0] === "variable") {
|
|
9
|
+
const allAxes = googleFontsMetadata[fontFamily].axes;
|
|
10
|
+
if (!allAxes) throw new Error("invariant variable font without axes");
|
|
11
|
+
if (selectedVariableAxes) {
|
|
12
|
+
const definableAxes = allAxes.map(({ tag }) => tag).filter((tag) => tag !== "wght");
|
|
13
|
+
if (definableAxes.length === 0) throw new Error(`Font \`${fontFamily}\` has no definable \`axes\``);
|
|
14
|
+
if (!Array.isArray(selectedVariableAxes)) throw new Error(`Invalid axes value for font \`${fontFamily}\`, expected an array of axes.\nAvailable axes: ${formatAvailableValues(definableAxes)}`);
|
|
15
|
+
for (const key of selectedVariableAxes) if (!definableAxes.includes(key)) throw new Error(`Invalid axes value \`${key}\` for font \`${fontFamily}\`.\nAvailable axes: ${formatAvailableValues(definableAxes)}`);
|
|
16
|
+
}
|
|
17
|
+
let weightAxis;
|
|
18
|
+
let variableAxes;
|
|
19
|
+
for (const { tag, min, max } of allAxes) if (tag === "wght") weightAxis = `${min}..${max}`;
|
|
20
|
+
else if (selectedVariableAxes?.includes(tag)) {
|
|
21
|
+
if (!variableAxes) variableAxes = [];
|
|
22
|
+
variableAxes.push([tag, `${min}..${max}`]);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
wght: weightAxis ? [weightAxis] : void 0,
|
|
26
|
+
ital,
|
|
27
|
+
variableAxes
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
wght: weights,
|
|
32
|
+
ital,
|
|
33
|
+
variableAxes: void 0
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { getFontAxes };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=get-axes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-axes.js","names":[],"sources":["../../../src/build/google-fonts/get-axes.ts"],"sourcesContent":["// Ported from Next.js: packages/font/src/google/get-font-axes.ts\n// https://github.com/vercel/next.js/blob/canary/packages/font/src/google/get-font-axes.ts\n//\n// Resolves the axis values that belong in a Google Fonts URL given the\n// caller's requested weights, styles, and (optional) selected variable axes.\n// For variable fonts this is the only place that turns the literal sentinel\n// `\"variable\"` into the actual `min..max` range from the bundled metadata.\n\nimport { googleFontsMetadata } from \"./font-metadata.js\";\nimport type { FontAxes } from \"./build-url.js\";\n\nconst formatAvailableValues = (values: string[]): string =>\n values.map((val) => `\\`${val}\\``).join(\", \");\n\nexport function getFontAxes(\n fontFamily: string,\n weights: string[],\n styles: string[],\n selectedVariableAxes?: string[],\n): FontAxes {\n const hasItalic = styles.includes(\"italic\");\n const hasNormal = styles.includes(\"normal\");\n // Google treats omitted ital as ital=0, so italic-only requests do not need\n // to enumerate ital=0; just ['1'] suffices.\n const ital = hasItalic ? [...(hasNormal ? [\"0\"] : []), \"1\"] : undefined;\n\n // Variable-font sentinel: a single \"variable\" entry means the caller wants\n // the full axis range from metadata, not a list of explicit weights.\n if (weights[0] === \"variable\") {\n const allAxes = googleFontsMetadata[fontFamily].axes;\n if (!allAxes) {\n // Reaching this branch means validate accepted a \"variable\" weight for\n // a non-variable font, which should be impossible because the\n // metadata-based validator rejects this earlier. Treat as an internal\n // invariant.\n throw new Error(\"invariant variable font without axes\");\n }\n\n if (selectedVariableAxes) {\n const definableAxes = allAxes.map(({ tag }) => tag).filter((tag) => tag !== \"wght\");\n if (definableAxes.length === 0) {\n throw new Error(`Font \\`${fontFamily}\\` has no definable \\`axes\\``);\n }\n if (!Array.isArray(selectedVariableAxes)) {\n throw new Error(\n `Invalid axes value for font \\`${fontFamily}\\`, expected an array of axes.\\nAvailable axes: ${formatAvailableValues(definableAxes)}`,\n );\n }\n for (const key of selectedVariableAxes) {\n if (!definableAxes.includes(key)) {\n throw new Error(\n `Invalid axes value \\`${key}\\` for font \\`${fontFamily}\\`.\\nAvailable axes: ${formatAvailableValues(definableAxes)}`,\n );\n }\n }\n }\n\n let weightAxis: string | undefined;\n let variableAxes: [string, string][] | undefined;\n for (const { tag, min, max } of allAxes) {\n if (tag === \"wght\") {\n weightAxis = `${min}..${max}`;\n } else if (selectedVariableAxes?.includes(tag)) {\n if (!variableAxes) variableAxes = [];\n variableAxes.push([tag, `${min}..${max}`]);\n }\n }\n\n return {\n wght: weightAxis ? [weightAxis] : undefined,\n ital,\n variableAxes,\n };\n }\n\n // Non-variable path: weights are explicit face values that the URL builder\n // emits verbatim.\n return {\n wght: weights,\n ital,\n variableAxes: undefined,\n };\n}\n"],"mappings":";;AAWA,MAAM,yBAAyB,WAC7B,OAAO,KAAK,QAAQ,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK;AAE9C,SAAgB,YACd,YACA,SACA,QACA,sBACU;CACV,MAAM,YAAY,OAAO,SAAS,SAAS;CAC3C,MAAM,YAAY,OAAO,SAAS,SAAS;CAG3C,MAAM,OAAO,YAAY,CAAC,GAAI,YAAY,CAAC,IAAI,GAAG,EAAE,EAAG,IAAI,GAAG,KAAA;AAI9D,KAAI,QAAQ,OAAO,YAAY;EAC7B,MAAM,UAAU,oBAAoB,YAAY;AAChD,MAAI,CAAC,QAKH,OAAM,IAAI,MAAM,uCAAuC;AAGzD,MAAI,sBAAsB;GACxB,MAAM,gBAAgB,QAAQ,KAAK,EAAE,UAAU,IAAI,CAAC,QAAQ,QAAQ,QAAQ,OAAO;AACnF,OAAI,cAAc,WAAW,EAC3B,OAAM,IAAI,MAAM,UAAU,WAAW,8BAA8B;AAErE,OAAI,CAAC,MAAM,QAAQ,qBAAqB,CACtC,OAAM,IAAI,MACR,iCAAiC,WAAW,kDAAkD,sBAAsB,cAAc,GACnI;AAEH,QAAK,MAAM,OAAO,qBAChB,KAAI,CAAC,cAAc,SAAS,IAAI,CAC9B,OAAM,IAAI,MACR,wBAAwB,IAAI,gBAAgB,WAAW,uBAAuB,sBAAsB,cAAc,GACnH;;EAKP,IAAI;EACJ,IAAI;AACJ,OAAK,MAAM,EAAE,KAAK,KAAK,SAAS,QAC9B,KAAI,QAAQ,OACV,cAAa,GAAG,IAAI,IAAI;WACf,sBAAsB,SAAS,IAAI,EAAE;AAC9C,OAAI,CAAC,aAAc,gBAAe,EAAE;AACpC,gBAAa,KAAK,CAAC,KAAK,GAAG,IAAI,IAAI,MAAM,CAAC;;AAI9C,SAAO;GACL,MAAM,aAAa,CAAC,WAAW,GAAG,KAAA;GAClC;GACA;GACD;;AAKH,QAAO;EACL,MAAM;EACN;EACA,cAAc,KAAA;EACf"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/build/google-fonts/sort-variants.ts
|
|
2
|
+
function sortFontsVariantValues(valA, valB) {
|
|
3
|
+
if (valA.includes(",") && valB.includes(",")) {
|
|
4
|
+
const [aPrefix, aSuffix] = valA.split(",", 2);
|
|
5
|
+
const [bPrefix, bSuffix] = valB.split(",", 2);
|
|
6
|
+
if (aPrefix === bPrefix) return parseInt(aSuffix) - parseInt(bSuffix);
|
|
7
|
+
return parseInt(aPrefix) - parseInt(bPrefix);
|
|
8
|
+
}
|
|
9
|
+
return parseInt(valA) - parseInt(valB);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { sortFontsVariantValues };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=sort-variants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-variants.js","names":[],"sources":["../../../src/build/google-fonts/sort-variants.ts"],"sourcesContent":["// Ported from Next.js: packages/font/src/google/sort-fonts-variant-values.ts\n// https://github.com/vercel/next.js/blob/canary/packages/font/src/google/sort-fonts-variant-values.ts\n//\n// Comparator used by `Array.prototype.sort` when assembling the variant\n// segment of a Google Fonts URL. Google's CSS API requires variant values to\n// be ordered numerically, not lexically. The string ordering of\n// `[\"100\",\"1000\",\"300\"]` would put 1000 before 300, and `[\"1,100\",\"0,200\"]`\n// would put the higher ital prefix first; both produce HTTP 400.\n\nexport function sortFontsVariantValues(valA: string, valB: string): number {\n // \"ital,wght\" pair format: compare ital first, then wght when ital matches.\n if (valA.includes(\",\") && valB.includes(\",\")) {\n const [aPrefix, aSuffix] = valA.split(\",\", 2);\n const [bPrefix, bSuffix] = valB.split(\",\", 2);\n\n if (aPrefix === bPrefix) {\n return parseInt(aSuffix) - parseInt(bSuffix);\n }\n return parseInt(aPrefix) - parseInt(bPrefix);\n }\n\n // Plain weight string: numeric compare.\n return parseInt(valA) - parseInt(valB);\n}\n"],"mappings":";AASA,SAAgB,uBAAuB,MAAc,MAAsB;AAEzE,KAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI,EAAE;EAC5C,MAAM,CAAC,SAAS,WAAW,KAAK,MAAM,KAAK,EAAE;EAC7C,MAAM,CAAC,SAAS,WAAW,KAAK,MAAM,KAAK,EAAE;AAE7C,MAAI,YAAY,QACd,QAAO,SAAS,QAAQ,GAAG,SAAS,QAAQ;AAE9C,SAAO,SAAS,QAAQ,GAAG,SAAS,QAAQ;;AAI9C,QAAO,SAAS,KAAK,GAAG,SAAS,KAAK"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/build/google-fonts/validate.d.ts
|
|
2
|
+
type GoogleFontOptions = {
|
|
3
|
+
weight?: string | string[];
|
|
4
|
+
style?: string | string[];
|
|
5
|
+
preload?: boolean;
|
|
6
|
+
display?: string;
|
|
7
|
+
axes?: string[];
|
|
8
|
+
fallback?: string[];
|
|
9
|
+
adjustFontFallback?: boolean;
|
|
10
|
+
variable?: string;
|
|
11
|
+
subsets?: string[];
|
|
12
|
+
};
|
|
13
|
+
type ValidatedGoogleFontOptions = {
|
|
14
|
+
fontFamily: string;
|
|
15
|
+
weights: string[];
|
|
16
|
+
styles: string[];
|
|
17
|
+
display: string;
|
|
18
|
+
preload: boolean;
|
|
19
|
+
selectedVariableAxes?: string[];
|
|
20
|
+
fallback?: string[];
|
|
21
|
+
adjustFontFallback: boolean;
|
|
22
|
+
variable?: string;
|
|
23
|
+
subsets: string[];
|
|
24
|
+
};
|
|
25
|
+
declare function validateGoogleFontOptions(fontFamily: string, options: GoogleFontOptions): ValidatedGoogleFontOptions;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { validateGoogleFontOptions };
|
|
28
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { googleFontsMetadata } from "./font-metadata.js";
|
|
2
|
+
//#region src/build/google-fonts/validate.ts
|
|
3
|
+
const ALLOWED_DISPLAY_VALUES = [
|
|
4
|
+
"auto",
|
|
5
|
+
"block",
|
|
6
|
+
"swap",
|
|
7
|
+
"fallback",
|
|
8
|
+
"optional"
|
|
9
|
+
];
|
|
10
|
+
const formatAvailableValues = (values) => values.map((val) => `\`${val}\``).join(", ");
|
|
11
|
+
const dedupe = (values) => Array.from(new Set(values));
|
|
12
|
+
function validateGoogleFontOptions(fontFamily, options) {
|
|
13
|
+
const { weight, style, display = "swap", axes, fallback, adjustFontFallback = true, variable, subsets = [] } = options;
|
|
14
|
+
let preload = options.preload ?? true;
|
|
15
|
+
const fontFamilyData = googleFontsMetadata[fontFamily];
|
|
16
|
+
if (!fontFamilyData) throw new Error(`Unknown font \`${fontFamily}\``);
|
|
17
|
+
if (axes !== void 0 && !Array.isArray(axes)) throw new Error(`Invalid axes value for font \`${fontFamily}\`, expected an array of axis names.`);
|
|
18
|
+
const availableSubsets = fontFamilyData.subsets;
|
|
19
|
+
if (availableSubsets.length === 0) preload = false;
|
|
20
|
+
else if (preload) {
|
|
21
|
+
if (subsets.length === 0) throw new Error(`Preload is enabled but no subsets were specified for font \`${fontFamily}\`. Please specify subsets or disable preloading if your intended subset can't be preloaded.\nAvailable subsets: ${formatAvailableValues(availableSubsets)}`);
|
|
22
|
+
for (const subset of subsets) if (!availableSubsets.includes(subset)) throw new Error(`Unknown subset \`${subset}\` for font \`${fontFamily}\`.\nAvailable subsets: ${formatAvailableValues(availableSubsets)}`);
|
|
23
|
+
}
|
|
24
|
+
const fontWeights = fontFamilyData.weights;
|
|
25
|
+
const fontStyles = fontFamilyData.styles;
|
|
26
|
+
const weights = !weight ? [] : dedupe(Array.isArray(weight) ? weight : [weight]);
|
|
27
|
+
const styles = !style ? [] : dedupe(Array.isArray(style) ? style : [style]);
|
|
28
|
+
if (weights.length === 0) if (fontWeights.includes("variable")) weights.push("variable");
|
|
29
|
+
else throw new Error(`Missing weight for font \`${fontFamily}\`.\nAvailable weights: ${formatAvailableValues(fontWeights)}`);
|
|
30
|
+
if (weights.length > 1 && weights.includes("variable")) throw new Error(`Unexpected \`variable\` in weight array for font \`${fontFamily}\`. You only need \`variable\`, it includes all available weights.`);
|
|
31
|
+
for (const selectedWeight of weights) if (!fontWeights.includes(selectedWeight)) throw new Error(`Unknown weight \`${selectedWeight}\` for font \`${fontFamily}\`.\nAvailable weights: ${formatAvailableValues(fontWeights)}`);
|
|
32
|
+
if (styles.length === 0) if (fontStyles.length === 1) styles.push(fontStyles[0]);
|
|
33
|
+
else styles.push("normal");
|
|
34
|
+
for (const selectedStyle of styles) if (!fontStyles.includes(selectedStyle)) throw new Error(`Unknown style \`${selectedStyle}\` for font \`${fontFamily}\`.\nAvailable styles: ${formatAvailableValues(fontStyles)}`);
|
|
35
|
+
if (!ALLOWED_DISPLAY_VALUES.includes(display)) throw new Error(`Invalid display value \`${display}\` for font \`${fontFamily}\`.\nAvailable display values: ${formatAvailableValues(ALLOWED_DISPLAY_VALUES)}`);
|
|
36
|
+
if (axes) {
|
|
37
|
+
if (!fontWeights.includes("variable")) throw new Error("Axes can only be defined for variable fonts.");
|
|
38
|
+
if (weights[0] !== "variable") throw new Error("Axes can only be defined for variable fonts when the weight property is nonexistent or set to `variable`.");
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
fontFamily,
|
|
42
|
+
weights,
|
|
43
|
+
styles,
|
|
44
|
+
display,
|
|
45
|
+
preload,
|
|
46
|
+
selectedVariableAxes: axes,
|
|
47
|
+
fallback,
|
|
48
|
+
adjustFontFallback,
|
|
49
|
+
variable,
|
|
50
|
+
subsets
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { validateGoogleFontOptions };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","names":[],"sources":["../../../src/build/google-fonts/validate.ts"],"sourcesContent":["// Ported from Next.js: packages/font/src/google/validate-google-font-function-call.ts\n// https://github.com/vercel/next.js/blob/canary/packages/font/src/google/validate-google-font-function-call.ts\n//\n// Vinext drops Next's SWC-coupled `(functionName, fontFunctionArgument)`\n// calling convention because the plugin already knows the family at parse\n// time. Behaviour is otherwise identical: validate the caller's options\n// against the bundled metadata, default missing fields, and reject anything\n// Google Fonts would reject at request time.\n\nimport { googleFontsMetadata } from \"./font-metadata.js\";\n\nconst ALLOWED_DISPLAY_VALUES = [\"auto\", \"block\", \"swap\", \"fallback\", \"optional\"];\n\ntype GoogleFontOptions = {\n weight?: string | string[];\n style?: string | string[];\n preload?: boolean;\n display?: string;\n axes?: string[];\n fallback?: string[];\n adjustFontFallback?: boolean;\n variable?: string;\n subsets?: string[];\n};\n\ntype ValidatedGoogleFontOptions = {\n fontFamily: string;\n weights: string[];\n styles: string[];\n display: string;\n preload: boolean;\n selectedVariableAxes?: string[];\n fallback?: string[];\n adjustFontFallback: boolean;\n variable?: string;\n subsets: string[];\n};\n\nconst formatAvailableValues = (values: string[]): string =>\n values.map((val) => `\\`${val}\\``).join(\", \");\n\nconst dedupe = (values: string[]): string[] => Array.from(new Set(values));\n\nexport function validateGoogleFontOptions(\n fontFamily: string,\n options: GoogleFontOptions,\n): ValidatedGoogleFontOptions {\n const {\n weight,\n style,\n display = \"swap\",\n axes,\n fallback,\n adjustFontFallback = true,\n variable,\n subsets = [],\n } = options;\n let preload = options.preload ?? true;\n\n const fontFamilyData = googleFontsMetadata[fontFamily];\n if (!fontFamilyData) {\n throw new Error(`Unknown font \\`${fontFamily}\\``);\n }\n\n if (axes !== undefined && !Array.isArray(axes)) {\n throw new Error(\n `Invalid axes value for font \\`${fontFamily}\\`, expected an array of axis names.`,\n );\n }\n\n const availableSubsets = fontFamilyData.subsets;\n if (availableSubsets.length === 0) {\n // No preloadable subsets means preload is meaningless. Silently disable\n // it rather than forcing the caller to opt out.\n preload = false;\n } else if (preload) {\n // Deliberate parity gap: Next.js uses `if (!subsets)` so an explicit\n // `subsets: []` passes silently. vinext rejects it as well, since an\n // empty subsets array with preload enabled is always a caller mistake.\n if (subsets.length === 0) {\n throw new Error(\n `Preload is enabled but no subsets were specified for font \\`${fontFamily}\\`. Please specify subsets or disable preloading if your intended subset can't be preloaded.\\nAvailable subsets: ${formatAvailableValues(availableSubsets)}`,\n );\n }\n for (const subset of subsets) {\n if (!availableSubsets.includes(subset)) {\n throw new Error(\n `Unknown subset \\`${subset}\\` for font \\`${fontFamily}\\`.\\nAvailable subsets: ${formatAvailableValues(availableSubsets)}`,\n );\n }\n }\n }\n\n const fontWeights = fontFamilyData.weights;\n const fontStyles = fontFamilyData.styles;\n\n const weights = !weight ? [] : dedupe(Array.isArray(weight) ? weight : [weight]);\n const styles = !style ? [] : dedupe(Array.isArray(style) ? style : [style]);\n\n if (weights.length === 0) {\n if (fontWeights.includes(\"variable\")) {\n // Caller said \"any weight\" and the font has a variable face, so use it.\n weights.push(\"variable\");\n } else {\n throw new Error(\n `Missing weight for font \\`${fontFamily}\\`.\\nAvailable weights: ${formatAvailableValues(fontWeights)}`,\n );\n }\n }\n\n if (weights.length > 1 && weights.includes(\"variable\")) {\n throw new Error(\n `Unexpected \\`variable\\` in weight array for font \\`${fontFamily}\\`. You only need \\`variable\\`, it includes all available weights.`,\n );\n }\n\n for (const selectedWeight of weights) {\n if (!fontWeights.includes(selectedWeight)) {\n throw new Error(\n `Unknown weight \\`${selectedWeight}\\` for font \\`${fontFamily}\\`.\\nAvailable weights: ${formatAvailableValues(fontWeights)}`,\n );\n }\n }\n\n if (styles.length === 0) {\n if (fontStyles.length === 1) {\n // Italic-only fonts (rare) have no normal face, so use that face.\n styles.push(fontStyles[0]);\n } else {\n styles.push(\"normal\");\n }\n }\n\n for (const selectedStyle of styles) {\n if (!fontStyles.includes(selectedStyle)) {\n throw new Error(\n `Unknown style \\`${selectedStyle}\\` for font \\`${fontFamily}\\`.\\nAvailable styles: ${formatAvailableValues(fontStyles)}`,\n );\n }\n }\n\n if (!ALLOWED_DISPLAY_VALUES.includes(display)) {\n throw new Error(\n `Invalid display value \\`${display}\\` for font \\`${fontFamily}\\`.\\nAvailable display values: ${formatAvailableValues(ALLOWED_DISPLAY_VALUES)}`,\n );\n }\n\n if (axes) {\n if (!fontWeights.includes(\"variable\")) {\n throw new Error(\"Axes can only be defined for variable fonts.\");\n }\n if (weights[0] !== \"variable\") {\n throw new Error(\n \"Axes can only be defined for variable fonts when the weight property is nonexistent or set to `variable`.\",\n );\n }\n }\n\n return {\n fontFamily,\n weights,\n styles,\n display,\n preload,\n selectedVariableAxes: axes,\n fallback,\n adjustFontFallback,\n variable,\n subsets,\n };\n}\n"],"mappings":";;AAWA,MAAM,yBAAyB;CAAC;CAAQ;CAAS;CAAQ;CAAY;CAAW;AA2BhF,MAAM,yBAAyB,WAC7B,OAAO,KAAK,QAAQ,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK;AAE9C,MAAM,UAAU,WAA+B,MAAM,KAAK,IAAI,IAAI,OAAO,CAAC;AAE1E,SAAgB,0BACd,YACA,SAC4B;CAC5B,MAAM,EACJ,QACA,OACA,UAAU,QACV,MACA,UACA,qBAAqB,MACrB,UACA,UAAU,EAAE,KACV;CACJ,IAAI,UAAU,QAAQ,WAAW;CAEjC,MAAM,iBAAiB,oBAAoB;AAC3C,KAAI,CAAC,eACH,OAAM,IAAI,MAAM,kBAAkB,WAAW,IAAI;AAGnD,KAAI,SAAS,KAAA,KAAa,CAAC,MAAM,QAAQ,KAAK,CAC5C,OAAM,IAAI,MACR,iCAAiC,WAAW,sCAC7C;CAGH,MAAM,mBAAmB,eAAe;AACxC,KAAI,iBAAiB,WAAW,EAG9B,WAAU;UACD,SAAS;AAIlB,MAAI,QAAQ,WAAW,EACrB,OAAM,IAAI,MACR,+DAA+D,WAAW,mHAAmH,sBAAsB,iBAAiB,GACrO;AAEH,OAAK,MAAM,UAAU,QACnB,KAAI,CAAC,iBAAiB,SAAS,OAAO,CACpC,OAAM,IAAI,MACR,oBAAoB,OAAO,gBAAgB,WAAW,0BAA0B,sBAAsB,iBAAiB,GACxH;;CAKP,MAAM,cAAc,eAAe;CACnC,MAAM,aAAa,eAAe;CAElC,MAAM,UAAU,CAAC,SAAS,EAAE,GAAG,OAAO,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;CAChF,MAAM,SAAS,CAAC,QAAQ,EAAE,GAAG,OAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;AAE3E,KAAI,QAAQ,WAAW,EACrB,KAAI,YAAY,SAAS,WAAW,CAElC,SAAQ,KAAK,WAAW;KAExB,OAAM,IAAI,MACR,6BAA6B,WAAW,0BAA0B,sBAAsB,YAAY,GACrG;AAIL,KAAI,QAAQ,SAAS,KAAK,QAAQ,SAAS,WAAW,CACpD,OAAM,IAAI,MACR,sDAAsD,WAAW,oEAClE;AAGH,MAAK,MAAM,kBAAkB,QAC3B,KAAI,CAAC,YAAY,SAAS,eAAe,CACvC,OAAM,IAAI,MACR,oBAAoB,eAAe,gBAAgB,WAAW,0BAA0B,sBAAsB,YAAY,GAC3H;AAIL,KAAI,OAAO,WAAW,EACpB,KAAI,WAAW,WAAW,EAExB,QAAO,KAAK,WAAW,GAAG;KAE1B,QAAO,KAAK,SAAS;AAIzB,MAAK,MAAM,iBAAiB,OAC1B,KAAI,CAAC,WAAW,SAAS,cAAc,CACrC,OAAM,IAAI,MACR,mBAAmB,cAAc,gBAAgB,WAAW,yBAAyB,sBAAsB,WAAW,GACvH;AAIL,KAAI,CAAC,uBAAuB,SAAS,QAAQ,CAC3C,OAAM,IAAI,MACR,2BAA2B,QAAQ,gBAAgB,WAAW,iCAAiC,sBAAsB,uBAAuB,GAC7I;AAGH,KAAI,MAAM;AACR,MAAI,CAAC,YAAY,SAAS,WAAW,CACnC,OAAM,IAAI,MAAM,+CAA+C;AAEjE,MAAI,QAAQ,OAAO,WACjB,OAAM,IAAI,MACR,4GACD;;AAIL,QAAO;EACL;EACA;EACA;EACA;EACA;EACA,sBAAsB;EACtB;EACA;EACA;EACA;EACD"}
|
|
@@ -56,5 +56,5 @@ declare function isStaticModuleGraphResult(graphResult: ModuleGraphClassificatio
|
|
|
56
56
|
*/
|
|
57
57
|
declare function classifyAllRouteLayouts(routes: readonly RouteForClassification[], dynamicShimPaths: ReadonlySet<string>, moduleInfo: ModuleInfoProvider): Map<string, LayoutBuildClassification>;
|
|
58
58
|
//#endregion
|
|
59
|
-
export {
|
|
59
|
+
export { ModuleInfoProvider, classifyAllRouteLayouts, classifyLayoutByModuleGraph, isStaticModuleGraphResult, moduleGraphReason };
|
|
60
60
|
//# sourceMappingURL=layout-classification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-classification.js","names":[],"sources":["../../src/build/layout-classification.ts"],"sourcesContent":["/**\n * Layout classification — determines whether each layout in an App Router\n * route tree is static or dynamic via two complementary detection layers:\n *\n * Layer 1: Segment config (`export const dynamic`, `export const revalidate`)\n * Layer 2: Module graph traversal (checks for transitive dynamic shim imports)\n *\n * Layer 3 (probe-based runtime detection) is handled separately in\n * `app-page-execution.ts` at request time.\n *\n * Every result is carried as a `LayoutBuildClassification` tagged variant so\n * operators can trace which layer produced a decision via the structured\n * `ClassificationReason` sidecar without that metadata leaking onto the wire.\n */\n\nimport { classifyLayoutSegmentConfig } from \"./report.js\";\nimport { createAppPageTreePath } from \"../server/app-page-route-wiring.js\";\nimport type {\n ClassificationReason,\n LayoutBuildClassification,\n ModuleGraphStaticReason,\n} from \"./layout-classification-types.js\";\n\
|
|
1
|
+
{"version":3,"file":"layout-classification.js","names":[],"sources":["../../src/build/layout-classification.ts"],"sourcesContent":["/**\n * Layout classification — determines whether each layout in an App Router\n * route tree is static or dynamic via two complementary detection layers:\n *\n * Layer 1: Segment config (`export const dynamic`, `export const revalidate`)\n * Layer 2: Module graph traversal (checks for transitive dynamic shim imports)\n *\n * Layer 3 (probe-based runtime detection) is handled separately in\n * `app-page-execution.ts` at request time.\n *\n * Every result is carried as a `LayoutBuildClassification` tagged variant so\n * operators can trace which layer produced a decision via the structured\n * `ClassificationReason` sidecar without that metadata leaking onto the wire.\n */\n\nimport { classifyLayoutSegmentConfig } from \"./report.js\";\nimport { createAppPageTreePath } from \"../server/app-page-route-wiring.js\";\nimport type {\n ClassificationReason,\n LayoutBuildClassification,\n ModuleGraphStaticReason,\n} from \"./layout-classification-types.js\";\n\ntype ModuleGraphClassification = \"static\" | \"needs-probe\";\n\ntype ModuleGraphClassificationResult = {\n result: ModuleGraphClassification;\n /** First dynamic shim module ID encountered during BFS, when any. */\n firstShimMatch?: string;\n};\n\nexport type ModuleInfoProvider = {\n getModuleInfo(id: string): {\n importedIds: string[];\n dynamicImportedIds: string[];\n } | null;\n};\n\ntype LayoutEntry = {\n /** Rollup/Vite module ID for the layout file. */\n moduleId: string;\n /** Directory depth from the app root, used to build the stable layout ID. */\n treePosition: number;\n /** Segment config source code extracted at build time, or null when absent. */\n segmentConfig?: { code: string } | null;\n};\n\ntype RouteForClassification = {\n layouts: readonly LayoutEntry[];\n routeSegments: string[];\n};\n\n/**\n * BFS traversal of a layout's dependency tree. If any transitive import\n * resolves to a dynamic shim path (headers, cache, server), the layout\n * cannot be proven static at build time and needs a runtime probe.\n *\n * The returned object carries the classification plus the first matching\n * shim module ID (when any). Operators use the shim ID via the debug\n * channel to trace why a layout was flagged for probing.\n */\nexport function classifyLayoutByModuleGraph(\n layoutModuleId: string,\n dynamicShimPaths: ReadonlySet<string>,\n moduleInfo: ModuleInfoProvider,\n): ModuleGraphClassificationResult {\n const visited = new Set<string>();\n const queue: string[] = [layoutModuleId];\n let head = 0;\n\n while (head < queue.length) {\n const currentId = queue[head++]!;\n\n if (visited.has(currentId)) continue;\n visited.add(currentId);\n\n if (dynamicShimPaths.has(currentId)) {\n return { result: \"needs-probe\", firstShimMatch: currentId };\n }\n\n const info = moduleInfo.getModuleInfo(currentId);\n if (!info) continue;\n\n for (const importedId of info.importedIds) {\n if (!visited.has(importedId)) queue.push(importedId);\n }\n for (const dynamicId of info.dynamicImportedIds) {\n if (!visited.has(dynamicId)) queue.push(dynamicId);\n }\n }\n\n return { result: \"static\" };\n}\n\nexport function moduleGraphReason(\n graphResult: ModuleGraphClassificationResult & { result: \"static\" },\n): ModuleGraphStaticReason;\nexport function moduleGraphReason(\n graphResult: ModuleGraphClassificationResult,\n): ClassificationReason;\nexport function moduleGraphReason(\n graphResult: ModuleGraphClassificationResult,\n): ClassificationReason {\n if (graphResult.firstShimMatch === undefined) {\n return { layer: \"module-graph\", result: graphResult.result };\n }\n return {\n layer: \"module-graph\",\n result: graphResult.result,\n firstShimMatch: graphResult.firstShimMatch,\n };\n}\n\nexport function isStaticModuleGraphResult(\n graphResult: ModuleGraphClassificationResult,\n): graphResult is ModuleGraphClassificationResult & { result: \"static\" } {\n return graphResult.result === \"static\";\n}\n\n/**\n * Classifies all layouts across all routes using a two-layer strategy:\n *\n * 1. Segment config (Layer 1) — short-circuits to \"static\" or \"dynamic\"\n * 2. Module graph (Layer 2) — BFS for dynamic shim imports → \"static\" or \"needs-probe\"\n *\n * Shared layouts (same file appearing in multiple routes) are classified once\n * and deduplicated by layout ID.\n *\n * @internal Not called by production code. The `generateBundle` hook in\n * `index.ts` calls `classifyLayoutByModuleGraph` directly and composes\n * via the numeric-index manifest in `route-classification-manifest.ts`.\n * Used only by `tests/layout-classification.test.ts`.\n */\nexport function classifyAllRouteLayouts(\n routes: readonly RouteForClassification[],\n dynamicShimPaths: ReadonlySet<string>,\n moduleInfo: ModuleInfoProvider,\n): Map<string, LayoutBuildClassification> {\n const result = new Map<string, LayoutBuildClassification>();\n\n for (const route of routes) {\n for (const layout of route.layouts) {\n const layoutId = `layout:${createAppPageTreePath(route.routeSegments, layout.treePosition)}`;\n\n if (result.has(layoutId)) continue;\n\n // Layer 1: segment config\n if (layout.segmentConfig) {\n const configResult = classifyLayoutSegmentConfig(layout.segmentConfig.code);\n if (configResult.kind !== \"absent\") {\n result.set(layoutId, configResult);\n continue;\n }\n }\n\n // Layer 2: module graph\n const graphResult = classifyLayoutByModuleGraph(\n layout.moduleId,\n dynamicShimPaths,\n moduleInfo,\n );\n const reason = moduleGraphReason(graphResult);\n result.set(layoutId, { kind: graphResult.result, reason });\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,4BACd,gBACA,kBACA,YACiC;CACjC,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,QAAkB,CAAC,eAAe;CACxC,IAAI,OAAO;AAEX,QAAO,OAAO,MAAM,QAAQ;EAC1B,MAAM,YAAY,MAAM;AAExB,MAAI,QAAQ,IAAI,UAAU,CAAE;AAC5B,UAAQ,IAAI,UAAU;AAEtB,MAAI,iBAAiB,IAAI,UAAU,CACjC,QAAO;GAAE,QAAQ;GAAe,gBAAgB;GAAW;EAG7D,MAAM,OAAO,WAAW,cAAc,UAAU;AAChD,MAAI,CAAC,KAAM;AAEX,OAAK,MAAM,cAAc,KAAK,YAC5B,KAAI,CAAC,QAAQ,IAAI,WAAW,CAAE,OAAM,KAAK,WAAW;AAEtD,OAAK,MAAM,aAAa,KAAK,mBAC3B,KAAI,CAAC,QAAQ,IAAI,UAAU,CAAE,OAAM,KAAK,UAAU;;AAItD,QAAO,EAAE,QAAQ,UAAU;;AAS7B,SAAgB,kBACd,aACsB;AACtB,KAAI,YAAY,mBAAmB,KAAA,EACjC,QAAO;EAAE,OAAO;EAAgB,QAAQ,YAAY;EAAQ;AAE9D,QAAO;EACL,OAAO;EACP,QAAQ,YAAY;EACpB,gBAAgB,YAAY;EAC7B;;AAGH,SAAgB,0BACd,aACuE;AACvE,QAAO,YAAY,WAAW;;;;;;;;;;;;;;;;AAiBhC,SAAgB,wBACd,QACA,kBACA,YACwC;CACxC,MAAM,yBAAS,IAAI,KAAwC;AAE3D,MAAK,MAAM,SAAS,OAClB,MAAK,MAAM,UAAU,MAAM,SAAS;EAClC,MAAM,WAAW,UAAU,sBAAsB,MAAM,eAAe,OAAO,aAAa;AAE1F,MAAI,OAAO,IAAI,SAAS,CAAE;AAG1B,MAAI,OAAO,eAAe;GACxB,MAAM,eAAe,4BAA4B,OAAO,cAAc,KAAK;AAC3E,OAAI,aAAa,SAAS,UAAU;AAClC,WAAO,IAAI,UAAU,aAAa;AAClC;;;EAKJ,MAAM,cAAc,4BAClB,OAAO,UACP,kBACA,WACD;EACD,MAAM,SAAS,kBAAkB,YAAY;AAC7C,SAAO,IAAI,UAAU;GAAE,MAAM,YAAY;GAAQ;GAAQ,CAAC;;AAI9D,QAAO"}
|
|
@@ -46,5 +46,5 @@ declare function mergeNitroRouteRules(existingRouteRules: Record<string, NitroRo
|
|
|
46
46
|
skippedRoutes: string[];
|
|
47
47
|
};
|
|
48
48
|
//#endregion
|
|
49
|
-
export { NitroRouteRuleConfig,
|
|
49
|
+
export { NitroRouteRuleConfig, collectNitroRouteRules, convertToNitroPattern, generateNitroRouteRules, mergeNitroRouteRules };
|
|
50
50
|
//# sourceMappingURL=nitro-route-rules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nitro-route-rules.js","names":[],"sources":["../../src/build/nitro-route-rules.ts"],"sourcesContent":["import { appRouter, type AppRoute } from \"../routing/app-router.js\";\nimport { apiRouter, pagesRouter, type Route } from \"../routing/pages-router.js\";\nimport { buildReportRows, type RouteRow } from \"./report.js\";\n\n// Mirrors Nitro's NitroRouteConfig — hand-rolled because nitropack is not a direct dependency.\nexport type NitroRouteRuleConfig = Record<string, unknown> & {\n swr?: boolean | number;\n cache?: unknown;\n static?: boolean;\n isr?: boolean | number;\n prerender?: boolean;\n};\n\
|
|
1
|
+
{"version":3,"file":"nitro-route-rules.js","names":[],"sources":["../../src/build/nitro-route-rules.ts"],"sourcesContent":["import { appRouter, type AppRoute } from \"../routing/app-router.js\";\nimport { apiRouter, pagesRouter, type Route } from \"../routing/pages-router.js\";\nimport { buildReportRows, type RouteRow } from \"./report.js\";\n\n// Mirrors Nitro's NitroRouteConfig — hand-rolled because nitropack is not a direct dependency.\nexport type NitroRouteRuleConfig = Record<string, unknown> & {\n swr?: boolean | number;\n cache?: unknown;\n static?: boolean;\n isr?: boolean | number;\n prerender?: boolean;\n};\n\ntype NitroRouteRules = Record<string, { swr: number }>;\n\n/**\n * Scans the filesystem for route files and generates Nitro `routeRules` for ISR routes.\n *\n * Note: this duplicates the filesystem scanning that `printBuildReport` also performs.\n * The `nitro.setup` hook runs during Nitro initialization (before the build), while\n * `printBuildReport` runs after the build, so sharing results is non-trivial. This is\n * a future optimization target.\n *\n * Unlike `printBuildReport`, this path does not receive `prerenderResult`, so routes\n * classified as `unknown` by static analysis (which `printBuildReport` might upgrade\n * to `static` via speculative prerender) are skipped here.\n */\nexport async function collectNitroRouteRules(options: {\n appDir?: string | null;\n pagesDir?: string | null;\n pageExtensions: string[];\n}): Promise<NitroRouteRules> {\n const { appDir, pageExtensions, pagesDir } = options;\n\n let appRoutes: AppRoute[] = [];\n let pageRoutes: Route[] = [];\n let apiRoutes: Route[] = [];\n\n if (appDir) {\n appRoutes = await appRouter(appDir, pageExtensions);\n }\n\n if (pagesDir) {\n const [pages, apis] = await Promise.all([\n pagesRouter(pagesDir, pageExtensions),\n apiRouter(pagesDir, pageExtensions),\n ]);\n pageRoutes = pages;\n apiRoutes = apis;\n }\n\n return generateNitroRouteRules(buildReportRows({ appRoutes, pageRoutes, apiRoutes }));\n}\n\nexport function generateNitroRouteRules(rows: RouteRow[]): NitroRouteRules {\n const rules: NitroRouteRules = {};\n\n for (const row of rows) {\n if (\n row.type === \"isr\" &&\n typeof row.revalidate === \"number\" &&\n Number.isFinite(row.revalidate) &&\n row.revalidate > 0\n ) {\n rules[convertToNitroPattern(row.pattern)] = { swr: row.revalidate };\n }\n }\n\n return rules;\n}\n\n/**\n * Converts vinext's internal `:param` route syntax to Nitro's rou3\n * pattern format. Nitro uses `rou3` for routeRules matching, which\n * supports `*` (single-segment) and `**` (multi-segment) wildcards.\n *\n * /blog/:slug -> /blog/* (single segment)\n * /docs/:slug+ -> /docs/** (one or more segments — catch-all)\n * /docs/:slug* -> /docs/** (zero or more segments — optional catch-all)\n * /about -> /about (unchanged)\n * /:a/:b produces `/*`/`/*` (consecutive single-segment params)\n */\nexport function convertToNitroPattern(pattern: string): string {\n return pattern\n .split(\"/\")\n .map((segment) => {\n if (segment.startsWith(\":\")) {\n // Catch-all (:param+) and optional catch-all (:param*) match multiple segments → **\n // Single dynamic param (:param) matches one segment → *\n return segment.endsWith(\"+\") || segment.endsWith(\"*\") ? \"**\" : \"*\";\n }\n return segment;\n })\n .join(\"/\");\n}\n\nexport function mergeNitroRouteRules(\n existingRouteRules: Record<string, NitroRouteRuleConfig> | undefined,\n generatedRouteRules: NitroRouteRules,\n): {\n routeRules: Record<string, NitroRouteRuleConfig>;\n skippedRoutes: string[];\n} {\n const routeRules = { ...existingRouteRules };\n const skippedRoutes: string[] = [];\n\n for (const [route, generatedRule] of Object.entries(generatedRouteRules)) {\n const existingRule = routeRules[route];\n\n if (existingRule && hasUserDefinedCacheRule(existingRule)) {\n skippedRoutes.push(route);\n continue;\n }\n\n routeRules[route] = {\n ...existingRule,\n ...generatedRule,\n };\n }\n\n return { routeRules, skippedRoutes };\n}\n\nfunction hasUserDefinedCacheRule(rule: NitroRouteRuleConfig): boolean {\n return (\n rule.swr !== undefined ||\n rule.cache !== undefined ||\n rule.static !== undefined ||\n rule.isr !== undefined ||\n rule.prerender !== undefined\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,eAAsB,uBAAuB,SAIhB;CAC3B,MAAM,EAAE,QAAQ,gBAAgB,aAAa;CAE7C,IAAI,YAAwB,EAAE;CAC9B,IAAI,aAAsB,EAAE;CAC5B,IAAI,YAAqB,EAAE;AAE3B,KAAI,OACF,aAAY,MAAM,UAAU,QAAQ,eAAe;AAGrD,KAAI,UAAU;EACZ,MAAM,CAAC,OAAO,QAAQ,MAAM,QAAQ,IAAI,CACtC,YAAY,UAAU,eAAe,EACrC,UAAU,UAAU,eAAe,CACpC,CAAC;AACF,eAAa;AACb,cAAY;;AAGd,QAAO,wBAAwB,gBAAgB;EAAE;EAAW;EAAY;EAAW,CAAC,CAAC;;AAGvF,SAAgB,wBAAwB,MAAmC;CACzE,MAAM,QAAyB,EAAE;AAEjC,MAAK,MAAM,OAAO,KAChB,KACE,IAAI,SAAS,SACb,OAAO,IAAI,eAAe,YAC1B,OAAO,SAAS,IAAI,WAAW,IAC/B,IAAI,aAAa,EAEjB,OAAM,sBAAsB,IAAI,QAAQ,IAAI,EAAE,KAAK,IAAI,YAAY;AAIvE,QAAO;;;;;;;;;;;;;AAcT,SAAgB,sBAAsB,SAAyB;AAC7D,QAAO,QACJ,MAAM,IAAI,CACV,KAAK,YAAY;AAChB,MAAI,QAAQ,WAAW,IAAI,CAGzB,QAAO,QAAQ,SAAS,IAAI,IAAI,QAAQ,SAAS,IAAI,GAAG,OAAO;AAEjE,SAAO;GACP,CACD,KAAK,IAAI;;AAGd,SAAgB,qBACd,oBACA,qBAIA;CACA,MAAM,aAAa,EAAE,GAAG,oBAAoB;CAC5C,MAAM,gBAA0B,EAAE;AAElC,MAAK,MAAM,CAAC,OAAO,kBAAkB,OAAO,QAAQ,oBAAoB,EAAE;EACxE,MAAM,eAAe,WAAW;AAEhC,MAAI,gBAAgB,wBAAwB,aAAa,EAAE;AACzD,iBAAc,KAAK,MAAM;AACzB;;AAGF,aAAW,SAAS;GAClB,GAAG;GACH,GAAG;GACJ;;AAGH,QAAO;EAAE;EAAY;EAAe;;AAGtC,SAAS,wBAAwB,MAAqC;AACpE,QACE,KAAK,QAAQ,KAAA,KACb,KAAK,UAAU,KAAA,KACf,KAAK,WAAW,KAAA,KAChB,KAAK,QAAQ,KAAA,KACb,KAAK,cAAc,KAAA"}
|
|
@@ -13,5 +13,5 @@ type PrecompressResult = {
|
|
|
13
13
|
*/
|
|
14
14
|
declare function precompressAssets(clientDir: string, onProgress?: (completed: number, total: number, file: string) => void): Promise<PrecompressResult>;
|
|
15
15
|
//#endregion
|
|
16
|
-
export {
|
|
16
|
+
export { precompressAssets };
|
|
17
17
|
//# sourceMappingURL=precompress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"precompress.js","names":[],"sources":["../../src/build/precompress.ts"],"sourcesContent":["/**\n * Build-time precompression for hashed static assets.\n *\n * Generates .br (brotli q5), .gz (gzip l8), and .zst (zstd l8) files\n * alongside compressible assets in dist/client/assets/. Served directly by\n * the production server — no per-request compression needed for immutable\n * build output.\n *\n * Only targets assets/ (hashed, immutable) — public directory files use\n * on-the-fly compression since they may change between deploys.\n */\nimport fsp from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport zlib from \"node:zlib\";\nimport { promisify } from \"node:util\";\n\nconst brotliCompress = promisify(zlib.brotliCompress);\nconst gzip = promisify(zlib.gzip);\nconst zstdCompress = typeof zlib.zstdCompress === \"function\" ? promisify(zlib.zstdCompress) : null;\n\n/** File extensions worth compressing (text-based, not already compressed). */\nconst COMPRESSIBLE_EXTENSIONS = new Set([\n \".js\",\n \".mjs\",\n \".css\",\n \".html\",\n \".json\",\n \".xml\",\n \".svg\",\n \".txt\",\n \".map\",\n \".wasm\",\n]);\n\n/** Below this size, compression overhead exceeds savings. */\nconst MIN_SIZE = 1024;\n\n/**\n * Past ~8 parallel files, mixed-size asset sets spend more time queueing zlib\n * work than making forward progress. Keep the batch size bounded even on\n * higher-core machines.\n */\nconst CONCURRENCY = Math.min(os.availableParallelism(), 8);\n\
|
|
1
|
+
{"version":3,"file":"precompress.js","names":[],"sources":["../../src/build/precompress.ts"],"sourcesContent":["/**\n * Build-time precompression for hashed static assets.\n *\n * Generates .br (brotli q5), .gz (gzip l8), and .zst (zstd l8) files\n * alongside compressible assets in dist/client/assets/. Served directly by\n * the production server — no per-request compression needed for immutable\n * build output.\n *\n * Only targets assets/ (hashed, immutable) — public directory files use\n * on-the-fly compression since they may change between deploys.\n */\nimport fsp from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport zlib from \"node:zlib\";\nimport { promisify } from \"node:util\";\n\nconst brotliCompress = promisify(zlib.brotliCompress);\nconst gzip = promisify(zlib.gzip);\nconst zstdCompress = typeof zlib.zstdCompress === \"function\" ? promisify(zlib.zstdCompress) : null;\n\n/** File extensions worth compressing (text-based, not already compressed). */\nconst COMPRESSIBLE_EXTENSIONS = new Set([\n \".js\",\n \".mjs\",\n \".css\",\n \".html\",\n \".json\",\n \".xml\",\n \".svg\",\n \".txt\",\n \".map\",\n \".wasm\",\n]);\n\n/** Below this size, compression overhead exceeds savings. */\nconst MIN_SIZE = 1024;\n\n/**\n * Past ~8 parallel files, mixed-size asset sets spend more time queueing zlib\n * work than making forward progress. Keep the batch size bounded even on\n * higher-core machines.\n */\nconst CONCURRENCY = Math.min(os.availableParallelism(), 8);\n\ntype PrecompressResult = {\n filesCompressed: number;\n totalOriginalBytes: number;\n /** Sum of brotli-compressed sizes (used for compression ratio reporting). */\n totalBrotliBytes: number;\n};\n\n/**\n * Walk a directory recursively, yielding relative paths for regular files.\n */\nasync function* walkFiles(dir: string, base: string = dir): AsyncGenerator<string> {\n let entries;\n try {\n entries = await fsp.readdir(dir, { withFileTypes: true });\n } catch {\n return; // directory doesn't exist\n }\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n yield* walkFiles(fullPath, base);\n } else if (entry.isFile()) {\n yield path.relative(base, fullPath);\n }\n }\n}\n\n/**\n * Precompress all compressible hashed assets under `clientDir/assets/`.\n *\n * Writes `.br`, `.gz`, and `.zst` files alongside each original.\n * Safe to re-run — overwrites existing compressed variants with identical\n * output, and never compresses `.br`, `.gz`, or `.zst` files themselves.\n */\nexport async function precompressAssets(\n clientDir: string,\n onProgress?: (completed: number, total: number, file: string) => void,\n): Promise<PrecompressResult> {\n const assetsDir = path.join(clientDir, \"assets\");\n const result: PrecompressResult = {\n filesCompressed: 0,\n totalOriginalBytes: 0,\n totalBrotliBytes: 0,\n };\n\n // Collect compressible file paths, then read + compress in bounded chunks\n // to keep peak memory at O(CONCURRENCY * max_file_size) instead of\n // O(total_assets).\n const filePaths: string[] = [];\n\n for await (const relativePath of walkFiles(assetsDir)) {\n const ext = path.extname(relativePath).toLowerCase();\n\n if (!COMPRESSIBLE_EXTENSIONS.has(ext)) continue;\n // .br/.gz/.zst are intentionally absent from COMPRESSIBLE_EXTENSIONS, so\n // precompressed variants generated by a previous run are never re-compressed.\n\n filePaths.push(path.join(assetsDir, relativePath));\n }\n\n let processed = 0;\n for (let i = 0; i < filePaths.length; i += CONCURRENCY) {\n const chunk = filePaths.slice(i, i + CONCURRENCY);\n await Promise.all(\n chunk.map(async (fullPath) => {\n const content = await fsp.readFile(fullPath);\n // readFile already done before this check — stat()-first would save\n // the read for tiny files but costs an extra syscall per file;\n // sub-1KB hashed assets are rare enough that read-first is cheaper.\n if (content.length < MIN_SIZE) return;\n\n // Compress all variants concurrently within each file\n const compressions: Promise<Buffer>[] = [\n brotliCompress(content, {\n params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 },\n }),\n gzip(content, { level: 8 }),\n ];\n if (zstdCompress) {\n compressions.push(\n zstdCompress(content, {\n params: { [zlib.constants.ZSTD_c_compressionLevel]: 8 },\n }),\n );\n }\n\n const results = await Promise.all(compressions);\n const [brContent, gzContent, zstdContent] = results;\n\n const writes = [\n fsp.writeFile(fullPath + \".br\", brContent),\n fsp.writeFile(fullPath + \".gz\", gzContent),\n ];\n if (zstdContent) {\n writes.push(fsp.writeFile(fullPath + \".zst\", zstdContent));\n }\n await Promise.all(writes);\n\n // Increment counters only after all writes succeed, so partial\n // failures (e.g. ENOSPC mid-write) don't inflate the reported totals.\n result.filesCompressed++;\n result.totalOriginalBytes += content.length;\n result.totalBrotliBytes += brContent.length;\n }),\n );\n // Report progress once per chunk to avoid non-deterministic ordering\n // within Promise.all (smaller files complete before larger ones).\n // Progress tracks all files (including skipped ones below MIN_SIZE),\n // which differs from filesCompressed (only files actually compressed).\n processed += chunk.length;\n onProgress?.(processed, filePaths.length, path.basename(chunk[chunk.length - 1]));\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,iBAAiB,UAAU,KAAK,eAAe;AACrD,MAAM,OAAO,UAAU,KAAK,KAAK;AACjC,MAAM,eAAe,OAAO,KAAK,iBAAiB,aAAa,UAAU,KAAK,aAAa,GAAG;;AAG9F,MAAM,0BAA0B,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;AAGF,MAAM,WAAW;;;;;;AAOjB,MAAM,cAAc,KAAK,IAAI,GAAG,sBAAsB,EAAE,EAAE;;;;AAY1D,gBAAgB,UAAU,KAAa,OAAe,KAA6B;CACjF,IAAI;AACJ,KAAI;AACF,YAAU,MAAM,IAAI,QAAQ,KAAK,EAAE,eAAe,MAAM,CAAC;SACnD;AACN;;AAEF,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,WAAW,KAAK,KAAK,KAAK,MAAM,KAAK;AAC3C,MAAI,MAAM,aAAa,CACrB,QAAO,UAAU,UAAU,KAAK;WACvB,MAAM,QAAQ,CACvB,OAAM,KAAK,SAAS,MAAM,SAAS;;;;;;;;;;AAYzC,eAAsB,kBACpB,WACA,YAC4B;CAC5B,MAAM,YAAY,KAAK,KAAK,WAAW,SAAS;CAChD,MAAM,SAA4B;EAChC,iBAAiB;EACjB,oBAAoB;EACpB,kBAAkB;EACnB;CAKD,MAAM,YAAsB,EAAE;AAE9B,YAAW,MAAM,gBAAgB,UAAU,UAAU,EAAE;EACrD,MAAM,MAAM,KAAK,QAAQ,aAAa,CAAC,aAAa;AAEpD,MAAI,CAAC,wBAAwB,IAAI,IAAI,CAAE;AAIvC,YAAU,KAAK,KAAK,KAAK,WAAW,aAAa,CAAC;;CAGpD,IAAI,YAAY;AAChB,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK,aAAa;EACtD,MAAM,QAAQ,UAAU,MAAM,GAAG,IAAI,YAAY;AACjD,QAAM,QAAQ,IACZ,MAAM,IAAI,OAAO,aAAa;GAC5B,MAAM,UAAU,MAAM,IAAI,SAAS,SAAS;AAI5C,OAAI,QAAQ,SAAS,SAAU;GAG/B,MAAM,eAAkC,CACtC,eAAe,SAAS,EACtB,QAAQ,GAAG,KAAK,UAAU,uBAAuB,GAAG,EACrD,CAAC,EACF,KAAK,SAAS,EAAE,OAAO,GAAG,CAAC,CAC5B;AACD,OAAI,aACF,cAAa,KACX,aAAa,SAAS,EACpB,QAAQ,GAAG,KAAK,UAAU,0BAA0B,GAAG,EACxD,CAAC,CACH;GAIH,MAAM,CAAC,WAAW,WAAW,eADb,MAAM,QAAQ,IAAI,aAAa;GAG/C,MAAM,SAAS,CACb,IAAI,UAAU,WAAW,OAAO,UAAU,EAC1C,IAAI,UAAU,WAAW,OAAO,UAAU,CAC3C;AACD,OAAI,YACF,QAAO,KAAK,IAAI,UAAU,WAAW,QAAQ,YAAY,CAAC;AAE5D,SAAM,QAAQ,IAAI,OAAO;AAIzB,UAAO;AACP,UAAO,sBAAsB,QAAQ;AACrC,UAAO,oBAAoB,UAAU;IACrC,CACH;AAKD,eAAa,MAAM;AACnB,eAAa,WAAW,UAAU,QAAQ,KAAK,SAAS,MAAM,MAAM,SAAS,GAAG,CAAC;;AAGnF,QAAO"}
|
|
@@ -106,12 +106,6 @@ type PrerenderAppOptionsInternal = PrerenderAppOptions & {
|
|
|
106
106
|
port: number;
|
|
107
107
|
};
|
|
108
108
|
};
|
|
109
|
-
/**
|
|
110
|
-
* Build a URL path from a route pattern and params.
|
|
111
|
-
* "/posts/:id" + { id: "42" } → "/posts/42"
|
|
112
|
-
* "/docs/:slug+" + { slug: ["a", "b"] } → "/docs/a/b"
|
|
113
|
-
*/
|
|
114
|
-
declare function buildUrlFromParams(pattern: string, params: Record<string, string | string[]>): string;
|
|
115
109
|
/**
|
|
116
110
|
* Determine the HTML output file path for a URL.
|
|
117
111
|
* Respects trailingSlash config.
|
|
@@ -194,5 +188,5 @@ declare function writePrerenderIndex(routes: PrerenderRouteResult[], outDir: str
|
|
|
194
188
|
trailingSlash?: boolean;
|
|
195
189
|
}): void;
|
|
196
190
|
//#endregion
|
|
197
|
-
export {
|
|
191
|
+
export { PrerenderResult, PrerenderRouteResult, StaticParamsMap, getOutputPath, getRscOutputPath, prerenderApp, prerenderPages, readPrerenderSecret, resolveParentParams, writePrerenderIndex };
|
|
198
192
|
//# sourceMappingURL=prerender.d.ts.map
|
package/dist/build/prerender.js
CHANGED
|
@@ -149,6 +149,7 @@ async function prerenderPages({ routes, apiRoutes, pagesDir, outDir, config, mod
|
|
|
149
149
|
});
|
|
150
150
|
const previousHandler = getCacheHandler();
|
|
151
151
|
setCacheHandler(new NoOpCacheHandler());
|
|
152
|
+
const previousPrerenderFlag = process.env.VINEXT_PRERENDER;
|
|
152
153
|
process.env.VINEXT_PRERENDER = "1";
|
|
153
154
|
let ownedProdServerHandle = null;
|
|
154
155
|
try {
|
|
@@ -324,7 +325,8 @@ async function prerenderPages({ routes, apiRoutes, pagesDir, outDir, config, mod
|
|
|
324
325
|
return { routes: results };
|
|
325
326
|
} finally {
|
|
326
327
|
setCacheHandler(previousHandler);
|
|
327
|
-
delete process.env.VINEXT_PRERENDER;
|
|
328
|
+
if (previousPrerenderFlag === void 0) delete process.env.VINEXT_PRERENDER;
|
|
329
|
+
else process.env.VINEXT_PRERENDER = previousPrerenderFlag;
|
|
328
330
|
if (ownedProdServerHandle) await new Promise((resolve) => ownedProdServerHandle.server.close(() => resolve()));
|
|
329
331
|
}
|
|
330
332
|
}
|
|
@@ -354,6 +356,7 @@ async function prerenderApp({ routes, outDir, config, mode, rscBundlePath, ...op
|
|
|
354
356
|
fs.mkdirSync(outDir, { recursive: true });
|
|
355
357
|
const previousHandler = getCacheHandler();
|
|
356
358
|
setCacheHandler(new NoOpCacheHandler());
|
|
359
|
+
const previousPrerenderFlag = process.env.VINEXT_PRERENDER;
|
|
357
360
|
process.env.VINEXT_PRERENDER = "1";
|
|
358
361
|
const serverDir = path.dirname(rscBundlePath);
|
|
359
362
|
let rscHandler;
|
|
@@ -639,7 +642,8 @@ async function prerenderApp({ routes, outDir, config, mode, rscBundlePath, ...op
|
|
|
639
642
|
return { routes: results };
|
|
640
643
|
} finally {
|
|
641
644
|
setCacheHandler(previousHandler);
|
|
642
|
-
delete process.env.VINEXT_PRERENDER;
|
|
645
|
+
if (previousPrerenderFlag === void 0) delete process.env.VINEXT_PRERENDER;
|
|
646
|
+
else process.env.VINEXT_PRERENDER = previousPrerenderFlag;
|
|
643
647
|
if (ownedProdServerHandle) await new Promise((resolve) => ownedProdServerHandle.server.close(() => resolve()));
|
|
644
648
|
}
|
|
645
649
|
}
|
|
@@ -688,6 +692,6 @@ function writePrerenderIndex(routes, outDir, options) {
|
|
|
688
692
|
fs.writeFileSync(path.join(outDir, "vinext-prerender.json"), JSON.stringify(index, null, 2), "utf-8");
|
|
689
693
|
}
|
|
690
694
|
//#endregion
|
|
691
|
-
export {
|
|
695
|
+
export { getOutputPath, getRscOutputPath, prerenderApp, prerenderPages, readPrerenderSecret, resolveParentParams, writePrerenderIndex };
|
|
692
696
|
|
|
693
697
|
//# sourceMappingURL=prerender.js.map
|