vinext 1.3.1 → 1.4.1
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 +25 -22
- package/THIRD_PARTY_LICENSES.md +47 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -2
- package/dist/build/prerender.js +4 -3
- package/dist/build/report.d.ts +0 -14
- package/dist/build/report.js +1 -51
- package/dist/check.js +4 -7
- package/dist/cli.js +3 -0
- package/dist/client/dev-error-overlay-store.d.ts +1 -0
- package/dist/client/dev-error-overlay.d.ts +2 -0
- package/dist/client/dev-error-overlay.js +20 -4
- package/dist/client/navigation-runtime.d.ts +13 -1
- package/dist/client/navigation-runtime.js +1 -1
- package/dist/config/config-matchers.js +2 -0
- package/dist/config/destination-params.d.ts +2 -1
- package/dist/config/destination-params.js +52 -2
- package/dist/config/next-config.d.ts +25 -0
- package/dist/config/next-config.js +82 -4
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-codec.js +327 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/dbcs-data.js +123 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/index.js +29 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/internal.js +134 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-codec.js +50 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data-generated.js +455 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/sbcs-data.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/big5-added.json.js +169 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp936.json.js +2584 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp949.json.js +2220 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/cp950.json.js +227 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/eucjp.json.js +425 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gb18030-ranges.json.js +427 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/gbk-added.json.js +229 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/tables/shiftjis.json.js +292 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf16.js +106 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/encodings/utf7.js +182 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/bom-handling.js +42 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/extend-node.js +147 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/index.js +94 -0
- package/dist/deps/.pnpm/iconv-lite@0.4.24/deps/iconv-lite/lib/streams.js +95 -0
- package/dist/deps/.pnpm/safer-buffer@2.1.2/deps/safer-buffer/safer.js +45 -0
- package/dist/entries/app-rsc-entry.js +17 -49
- package/dist/entries/app-rsc-manifest.js +3 -4
- package/dist/entries/app-ssr-entry.js +1 -0
- package/dist/entries/pages-server-entry.js +36 -9
- package/dist/index.js +112 -90
- package/dist/init-cloudflare.d.ts +1 -3
- package/dist/init-cloudflare.js +10 -48
- package/dist/init-platform.d.ts +2 -0
- package/dist/init-platform.js +4 -0
- package/dist/plugins/extensionless-dynamic-import.js +6 -2
- package/dist/plugins/next-intl-catalog.d.ts +12 -0
- package/dist/plugins/next-intl-catalog.js +85 -0
- package/dist/plugins/pages-node-externals.d.ts +1 -0
- package/dist/plugins/pages-node-externals.js +1 -1
- package/dist/plugins/strip-server-exports.js +2 -1
- package/dist/plugins/use-cache-callable.d.ts +1 -1
- package/dist/plugins/use-cache-callable.js +136 -94
- package/dist/routing/app-route-graph.d.ts +6 -0
- package/dist/routing/app-route-graph.js +9 -1
- package/dist/server/api-handler.js +21 -5
- package/dist/server/app-bfcache-identity.js +1 -1
- package/dist/server/app-browser-entry.js +86 -66
- package/dist/server/app-browser-history-controller.d.ts +5 -4
- package/dist/server/app-browser-history-controller.js +93 -15
- package/dist/server/app-browser-navigation-controller.d.ts +2 -2
- package/dist/server/app-browser-navigation-controller.js +1 -2
- package/dist/server/app-browser-rsc-redirect.js +7 -7
- package/dist/server/app-browser-server-action-client.d.ts +2 -0
- package/dist/server/app-browser-server-action-client.js +5 -4
- package/dist/server/app-browser-state.d.ts +2 -4
- package/dist/server/app-browser-state.js +9 -4
- package/dist/server/app-browser-supplemental-refresh.js +16 -1
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-browser-visible-commit.js +4 -14
- package/dist/server/app-elements-wire.d.ts +6 -38
- package/dist/server/app-elements-wire.js +4 -41
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-history-state.d.ts +2 -2
- package/dist/server/app-history-state.js +5 -2
- package/dist/server/app-mounted-layouts.d.ts +21 -0
- package/dist/server/app-mounted-layouts.js +67 -0
- package/dist/server/app-optimistic-routing.d.ts +19 -1
- package/dist/server/app-optimistic-routing.js +43 -4
- package/dist/server/app-page-boundary-render.js +10 -14
- package/dist/server/app-page-boundary.js +2 -2
- package/dist/server/app-page-cache-finalizer.d.ts +12 -1
- package/dist/server/app-page-cache-finalizer.js +70 -29
- package/dist/server/app-page-cache.d.ts +13 -1
- package/dist/server/app-page-cache.js +31 -9
- package/dist/server/app-page-dispatch.d.ts +5 -11
- package/dist/server/app-page-dispatch.js +84 -155
- package/dist/server/app-page-element-builder.d.ts +2 -2
- package/dist/server/app-page-element-builder.js +13 -12
- package/dist/server/app-page-execution.d.ts +17 -52
- package/dist/server/app-page-execution.js +102 -95
- package/dist/server/app-page-head.d.ts +13 -0
- package/dist/server/app-page-head.js +44 -16
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +1 -0
- package/dist/server/app-page-http-access-fallback-metadata.js +2 -2
- package/dist/server/app-page-layout-gate.d.ts +35 -0
- package/dist/server/app-page-layout-gate.js +50 -0
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-params.js +1 -14
- package/dist/server/app-page-probe.d.ts +3 -21
- package/dist/server/app-page-probe.js +4 -37
- package/dist/server/app-page-render.d.ts +2 -13
- package/dist/server/app-page-render.js +103 -234
- package/dist/server/app-page-request.d.ts +1 -3
- package/dist/server/app-page-request.js +1 -1
- package/dist/server/app-page-response.js +3 -3
- package/dist/server/app-page-route-wiring.d.ts +13 -6
- package/dist/server/app-page-route-wiring.js +86 -63
- package/dist/server/app-page-rsc-render-status.d.ts +27 -1
- package/dist/server/app-page-rsc-render-status.js +121 -13
- package/dist/server/app-page-stream.d.ts +12 -8
- package/dist/server/app-page-stream.js +4 -3
- package/dist/server/app-pages-bridge.d.ts +4 -0
- package/dist/server/app-pages-bridge.js +7 -3
- package/dist/server/app-render-dependency.d.ts +11 -4
- package/dist/server/app-render-dependency.js +86 -38
- package/dist/server/app-request-stage-dispatch.js +1 -1
- package/dist/server/app-request-stage-independent-entry.js +1 -1
- package/dist/server/app-route-handler-cache.js +2 -2
- package/dist/server/app-route-handler-dispatch.js +14 -9
- package/dist/server/app-route-handler-execution.js +11 -5
- package/dist/server/app-route-handler-policy.d.ts +1 -1
- package/dist/server/app-route-handler-policy.js +3 -3
- package/dist/server/app-route-handler-response.js +1 -1
- package/dist/server/app-route-handler-runtime.d.ts +1 -1
- package/dist/server/app-route-handler-runtime.js +28 -11
- package/dist/server/app-router-entry.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +12 -12
- package/dist/server/app-rsc-cache-busting.js +31 -72
- package/dist/server/app-rsc-error-handler.d.ts +2 -1
- package/dist/server/app-rsc-error-handler.js +10 -2
- package/dist/server/app-rsc-errors.d.ts +8 -0
- package/dist/server/app-rsc-errors.js +11 -1
- package/dist/server/app-rsc-handler.d.ts +5 -5
- package/dist/server/app-rsc-handler.js +80 -83
- package/dist/server/app-rsc-request-normalization.d.ts +10 -16
- package/dist/server/app-rsc-request-normalization.js +12 -18
- package/dist/server/app-rsc-response-finalizer.js +2 -2
- package/dist/server/app-rsc-response-stage.js +9 -15
- package/dist/server/app-server-action-execution.d.ts +3 -1
- package/dist/server/app-server-action-execution.js +15 -8
- package/dist/server/app-ssr-entry.d.ts +8 -0
- package/dist/server/app-ssr-entry.js +22 -16
- package/dist/server/app-ssr-stream.js +1 -1
- package/dist/server/app-visited-response-cache.d.ts +36 -1
- package/dist/server/app-visited-response-cache.js +46 -5
- package/dist/server/app-worker-stages.d.ts +37 -6
- package/dist/server/app-worker-stages.js +81 -9
- package/dist/server/artifact-compatibility.d.ts +0 -1
- package/dist/server/artifact-compatibility.js +1 -10
- package/dist/server/bfcache-identity.d.ts +7 -0
- package/dist/server/bfcache-identity.js +10 -1
- package/dist/server/cache-proof.d.ts +1 -115
- package/dist/server/cache-proof.js +1 -544
- package/dist/server/cacheability-manifest.js +1 -2
- package/dist/server/cacheability-request.js +13 -8
- package/dist/server/dev-origin-check.d.ts +2 -1
- package/dist/server/dev-origin-check.js +2 -1
- package/dist/server/dev-server.js +6 -4
- package/dist/server/headers.d.ts +6 -3
- package/dist/server/headers.js +9 -5
- package/dist/server/image-optimization.d.ts +5 -0
- package/dist/server/image-optimization.js +6 -1
- package/dist/server/isr-cache.d.ts +8 -2
- package/dist/server/isr-cache.js +30 -2
- package/dist/server/metadata-route-response.js +32 -15
- package/dist/server/middleware-matcher.js +19 -6
- package/dist/server/middleware-runtime.js +6 -2
- package/dist/server/multi-stage.d.ts +57 -12
- package/dist/server/multi-stage.js +13 -1
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/pages-api-route.js +28 -19
- package/dist/server/pages-media-type.d.ts +21 -1
- package/dist/server/pages-media-type.js +69 -5
- package/dist/server/pages-node-compat.d.ts +1 -1
- package/dist/server/pages-node-compat.js +54 -27
- package/dist/server/pages-page-data.js +2 -1
- package/dist/server/pages-page-handler.js +28 -26
- package/dist/server/pages-page-response.d.ts +9 -0
- package/dist/server/pages-page-response.js +18 -4
- package/dist/server/pages-request-pipeline.d.ts +8 -0
- package/dist/server/pages-request-pipeline.js +2 -2
- package/dist/server/pages-request-stage-entry.js +36 -14
- package/dist/server/pages-response-stage-entry.js +9 -3
- package/dist/server/pages-router-entry.js +3 -2
- package/dist/server/prod-server.d.ts +2 -2
- package/dist/server/prod-server.js +47 -9
- package/dist/server/request-error-log.d.ts +9 -0
- package/dist/server/request-error-log.js +13 -0
- package/dist/server/request-pipeline.d.ts +15 -4
- package/dist/server/request-pipeline.js +43 -15
- package/dist/server/rsc-completion-metadata.js +3 -0
- package/dist/server/shared-cache-identity.d.ts +23 -0
- package/dist/server/shared-cache-identity.js +36 -0
- package/dist/server/static-file-cache.d.ts +9 -0
- package/dist/server/static-file-cache.js +13 -2
- package/dist/server/worker-stages.d.ts +16 -3
- package/dist/server/worker-stages.js +23 -4
- package/dist/shims/cache-handler.js +2 -2
- package/dist/shims/cache-request-state.d.ts +23 -26
- package/dist/shims/cache-request-state.js +22 -57
- package/dist/shims/cache-runtime.d.ts +3 -1
- package/dist/shims/cache-runtime.js +94 -48
- package/dist/shims/cache.d.ts +16 -10
- package/dist/shims/cache.js +47 -36
- package/dist/shims/cacheability-classification.d.ts +2 -0
- package/dist/shims/cdn-cache.d.ts +22 -5
- package/dist/shims/client-hook-error.d.ts +2 -0
- package/dist/shims/client-hook-error.js +16 -1
- package/dist/shims/client-page-root.js +2 -2
- package/dist/shims/dynamic.js +9 -6
- package/dist/shims/error-boundary.js +2 -2
- package/dist/shims/fetch-cache-state.d.ts +5 -1
- package/dist/shims/fetch-cache-state.js +1 -3
- package/dist/shims/fetch-cache.d.ts +2 -1
- package/dist/shims/fetch-cache.js +39 -25
- package/dist/shims/form.js +2 -2
- package/dist/shims/headers.d.ts +10 -24
- package/dist/shims/headers.js +22 -70
- package/dist/shims/internal/cache-context-accessor.d.ts +1 -1
- package/dist/shims/internal/navigation-untracked.js +1 -1
- package/dist/shims/link.js +8 -11
- package/dist/shims/metadata.d.ts +23 -21
- package/dist/shims/metadata.js +62 -24
- package/dist/shims/navigation-server.js +1 -1
- package/dist/shims/navigation.d.ts +74 -7
- package/dist/shims/navigation.js +184 -31
- package/dist/shims/navigation.react-server.js +2 -2
- package/dist/shims/request-state-types.d.ts +3 -2
- package/dist/shims/slot.d.ts +16 -0
- package/dist/shims/slot.js +44 -9
- package/dist/shims/unified-request-context.d.ts +7 -1
- package/dist/shims/unified-request-context.js +3 -3
- package/dist/utils/cache-control-metadata.d.ts +5 -0
- package/dist/utils/cache-control-metadata.js +9 -1
- package/dist/utils/cache-life-profiles.d.ts +33 -0
- package/dist/utils/cache-life-profiles.js +111 -0
- package/dist/utils/middleware-request-headers.d.ts +14 -3
- package/dist/utils/middleware-request-headers.js +54 -7
- package/dist/utils/project.d.ts +2 -2
- package/dist/utils/project.js +3 -16
- package/dist/utils/regex.d.ts +5 -0
- package/dist/utils/regex.js +11 -1
- package/dist/utils/text-stream.d.ts +10 -5
- package/dist/utils/text-stream.js +6 -6
- package/package.json +2 -1
- package/dist/build/layout-classification-types.d.ts +0 -60
- package/dist/build/layout-classification-types.js +0 -1
- package/dist/build/layout-classification.d.ts +0 -62
- package/dist/build/layout-classification.js +0 -98
- package/dist/build/route-classification-injector.d.ts +0 -33
- package/dist/build/route-classification-injector.js +0 -59
- package/dist/build/route-classification-manifest.d.ts +0 -54
- package/dist/build/route-classification-manifest.js +0 -143
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -11
- package/dist/server/app-browser-client-reuse-manifest.js +0 -101
- package/dist/server/app-layout-param-observation.d.ts +0 -42
- package/dist/server/app-layout-param-observation.js +0 -168
- package/dist/server/client-reuse-manifest.d.ts +0 -103
- package/dist/server/client-reuse-manifest.js +0 -209
- package/dist/server/skip-cache-proof.d.ts +0 -60
- package/dist/server/skip-cache-proof.js +0 -168
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -14
- package/dist/server/static-layout-client-reuse-proof.js +0 -33
- package/dist/utils/sorted-array.d.ts +0 -8
- package/dist/utils/sorted-array.js +0 -20
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { buildClassificationReplacement, buildReasonsReplacement } from "./route-classification-manifest.js";
|
|
2
|
-
import { classifyLayoutByModuleGraph, isStaticModuleGraphResult, moduleGraphReason } from "./layout-classification.js";
|
|
3
|
-
//#region src/build/route-classification-injector.ts
|
|
4
|
-
const CLASS_STUB_RE = /function __VINEXT_CLASS\(routeIdx\)\s*\{\s*return null;?\s*\}/;
|
|
5
|
-
const REASONS_STUB_RE = /function __VINEXT_CLASS_REASONS\(routeIdx\)\s*\{\s*return null;?\s*\}/;
|
|
6
|
-
function identityPath(path) {
|
|
7
|
-
return path;
|
|
8
|
-
}
|
|
9
|
-
function findClassificationChunk(chunks) {
|
|
10
|
-
const chunksMentioningStub = chunks.filter((chunk) => chunk.code.includes("__VINEXT_CLASS"));
|
|
11
|
-
const chunksWithStubBody = chunksMentioningStub.filter((chunk) => CLASS_STUB_RE.test(chunk.code));
|
|
12
|
-
const chunkWithStubBody = chunksWithStubBody[0];
|
|
13
|
-
if (chunksMentioningStub.length === 0) return null;
|
|
14
|
-
if (chunkWithStubBody === void 0) throw new Error(`vinext: build-time classification — __VINEXT_CLASS is referenced in ${chunksMentioningStub.map((chunk) => chunk.fileName).join(", ")} but no chunk contains the stub body. The generator and the classification injector have drifted.`);
|
|
15
|
-
if (chunksWithStubBody.length > 1) throw new Error(`vinext: build-time classification — expected __VINEXT_CLASS stub in exactly one RSC chunk, found ${chunksWithStubBody.length}`);
|
|
16
|
-
return chunkWithStubBody;
|
|
17
|
-
}
|
|
18
|
-
function buildLayer2Classifications(options) {
|
|
19
|
-
const canonicalizeLayoutPath = options.canonicalizeLayoutPath ?? identityPath;
|
|
20
|
-
const layer2PerRoute = /* @__PURE__ */ new Map();
|
|
21
|
-
const graphCache = /* @__PURE__ */ new Map();
|
|
22
|
-
for (let routeIdx = 0; routeIdx < options.manifest.routes.length; routeIdx++) {
|
|
23
|
-
const route = options.manifest.routes[routeIdx];
|
|
24
|
-
const perRoute = /* @__PURE__ */ new Map();
|
|
25
|
-
for (let layoutIdx = 0; layoutIdx < route.layoutPaths.length; layoutIdx++) {
|
|
26
|
-
if (route.layer1.has(layoutIdx)) continue;
|
|
27
|
-
const layoutModuleId = canonicalizeLayoutPath(route.layoutPaths[layoutIdx]);
|
|
28
|
-
if (!options.moduleInfo.getModuleInfo(layoutModuleId)) continue;
|
|
29
|
-
let graphResult = graphCache.get(layoutModuleId);
|
|
30
|
-
if (graphResult === void 0) {
|
|
31
|
-
graphResult = classifyLayoutByModuleGraph(layoutModuleId, options.dynamicShimPaths, options.moduleInfo);
|
|
32
|
-
graphCache.set(layoutModuleId, graphResult);
|
|
33
|
-
}
|
|
34
|
-
if (isStaticModuleGraphResult(graphResult)) perRoute.set(layoutIdx, moduleGraphReason(graphResult));
|
|
35
|
-
}
|
|
36
|
-
if (perRoute.size > 0) layer2PerRoute.set(routeIdx, perRoute);
|
|
37
|
-
}
|
|
38
|
-
return layer2PerRoute;
|
|
39
|
-
}
|
|
40
|
-
function planRouteClassificationInjection(options) {
|
|
41
|
-
const target = findClassificationChunk(options.chunks);
|
|
42
|
-
if (!target) return { kind: "skip" };
|
|
43
|
-
if (options.enableDebugReasons && !REASONS_STUB_RE.test(target.code)) throw new Error("vinext: build-time classification — __VINEXT_CLASS_REASONS stub is missing alongside __VINEXT_CLASS. The generator and the classification injector have drifted.");
|
|
44
|
-
const layer2PerRoute = buildLayer2Classifications(options);
|
|
45
|
-
const patchedBody = `function __VINEXT_CLASS(routeIdx) { return (${buildClassificationReplacement(options.manifest, layer2PerRoute)})(routeIdx); }`;
|
|
46
|
-
let code = target.code.replace(CLASS_STUB_RE, patchedBody);
|
|
47
|
-
if (options.enableDebugReasons) {
|
|
48
|
-
const patchedReasonsBody = `function __VINEXT_CLASS_REASONS(routeIdx) { return (${buildReasonsReplacement(options.manifest, layer2PerRoute)})(routeIdx); }`;
|
|
49
|
-
code = code.replace(REASONS_STUB_RE, patchedReasonsBody);
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
code,
|
|
53
|
-
fileName: target.fileName,
|
|
54
|
-
kind: "patch",
|
|
55
|
-
map: null
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
export { planRouteClassificationInjection };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { AppRoute } from "../routing/app-route-graph.js";
|
|
2
|
-
import { ClassificationReason, ModuleGraphStaticReason } from "./layout-classification-types.js";
|
|
3
|
-
//#region src/build/route-classification-manifest.d.ts
|
|
4
|
-
type Layer1Class = "static" | "dynamic";
|
|
5
|
-
type RouteManifestEntry = {
|
|
6
|
-
/** Route pattern for diagnostics (e.g. "/blog/:slug"). */
|
|
7
|
-
pattern: string;
|
|
8
|
-
/** Absolute file paths for each layout, ordered root → leaf. */
|
|
9
|
-
layoutPaths: string[];
|
|
10
|
-
/** Layer 1 (segment config) results keyed by numeric layout index. */
|
|
11
|
-
layer1: Map<number, Layer1Class>;
|
|
12
|
-
/**
|
|
13
|
-
* Structured reasons for every Layer 1 decision, keyed by the same layout
|
|
14
|
-
* index. Always populated in lockstep with `layer1` so the debug channel
|
|
15
|
-
* can surface which segment-config field produced the decision.
|
|
16
|
-
*/
|
|
17
|
-
layer1Reasons: Map<number, ClassificationReason>;
|
|
18
|
-
};
|
|
19
|
-
export type RouteClassificationManifest = {
|
|
20
|
-
routes: RouteManifestEntry[];
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Reads each layout's source at build time and runs Layer 1 segment-config
|
|
24
|
-
* classification. Fails loudly if any layout file is missing — a missing
|
|
25
|
-
* layout means the routing scan and the filesystem have drifted, and shipping
|
|
26
|
-
* a build in that state would silently break layout rendering.
|
|
27
|
-
*/
|
|
28
|
-
export declare function collectRouteClassificationManifest(routes: readonly AppRoute[]): RouteClassificationManifest;
|
|
29
|
-
/**
|
|
30
|
-
* Builds a JavaScript arrow-function expression that dispatches route index
|
|
31
|
-
* to a pre-computed `Map<layoutIndex, "static" | "dynamic">` of build-time
|
|
32
|
-
* classifications. The returned string is suitable for embedding into the
|
|
33
|
-
* generated RSC entry via the `renderChunk` hook.
|
|
34
|
-
*
|
|
35
|
-
* `layer2PerRoute` is typed to only carry `"static"` entries — the
|
|
36
|
-
* module-graph classifier can only prove static, so "needs-probe" results
|
|
37
|
-
* are omitted by the caller before this map is constructed.
|
|
38
|
-
*/
|
|
39
|
-
export declare function buildClassificationReplacement(manifest: RouteClassificationManifest, layer2PerRoute: ReadonlyMap<number, ReadonlyMap<number, ModuleGraphStaticReason>>): string;
|
|
40
|
-
/**
|
|
41
|
-
* Sibling of `buildClassificationReplacement`: emits a dispatch function
|
|
42
|
-
* that returns `Map<layoutIndex, ClassificationReason>` per route.
|
|
43
|
-
*
|
|
44
|
-
* The runtime consults this map only when `VINEXT_DEBUG_CLASSIFICATION` is
|
|
45
|
-
* set, and the plugin only patches this dispatcher into the built bundle when
|
|
46
|
-
* that env var is present at build time.
|
|
47
|
-
*
|
|
48
|
-
* Layer 1 priority applies the same way as in `buildClassificationReplacement`:
|
|
49
|
-
* a segment-config reason must override a module-graph reason for the same
|
|
50
|
-
* layout index.
|
|
51
|
-
*/
|
|
52
|
-
export declare function buildReasonsReplacement(manifest: RouteClassificationManifest, layer2PerRoute: ReadonlyMap<number, ReadonlyMap<number, ModuleGraphStaticReason>>): string;
|
|
53
|
-
//#endregion
|
|
54
|
-
export {};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { classifyLayoutSegmentConfig } from "./report.js";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
//#region src/build/route-classification-manifest.ts
|
|
4
|
-
/**
|
|
5
|
-
* Build-time layout classification manifest.
|
|
6
|
-
*
|
|
7
|
-
* Bridges the classifier in `./layout-classification.ts` with the RSC entry
|
|
8
|
-
* codegen so that the per-layout static/dynamic classifications produced at
|
|
9
|
-
* build time are visible to the runtime probe loop in
|
|
10
|
-
* `server/app-page-execution.ts`.
|
|
11
|
-
*
|
|
12
|
-
* The runtime probe looks up entries by numeric `layoutIndex`, so this module
|
|
13
|
-
* is responsible for flattening the classifier's string-keyed layout IDs into
|
|
14
|
-
* a per-route, index-keyed structure that can be emitted from codegen.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Reads each layout's source at build time and runs Layer 1 segment-config
|
|
18
|
-
* classification. Fails loudly if any layout file is missing — a missing
|
|
19
|
-
* layout means the routing scan and the filesystem have drifted, and shipping
|
|
20
|
-
* a build in that state would silently break layout rendering.
|
|
21
|
-
*/
|
|
22
|
-
function collectRouteClassificationManifest(routes) {
|
|
23
|
-
const manifestRoutes = [];
|
|
24
|
-
const sourceCache = /* @__PURE__ */ new Map();
|
|
25
|
-
for (const route of routes) {
|
|
26
|
-
const layer1 = /* @__PURE__ */ new Map();
|
|
27
|
-
const layer1Reasons = /* @__PURE__ */ new Map();
|
|
28
|
-
for (let layoutIndex = 0; layoutIndex < route.layouts.length; layoutIndex++) {
|
|
29
|
-
const layoutPath = route.layouts[layoutIndex];
|
|
30
|
-
let source = sourceCache.get(layoutPath);
|
|
31
|
-
if (source === void 0) try {
|
|
32
|
-
source = fs.readFileSync(layoutPath, "utf8");
|
|
33
|
-
sourceCache.set(layoutPath, source);
|
|
34
|
-
} catch (cause) {
|
|
35
|
-
throw new Error(`vinext: failed to read layout for route ${route.pattern} at ${layoutPath}`, { cause });
|
|
36
|
-
}
|
|
37
|
-
const result = classifyLayoutSegmentConfig(source);
|
|
38
|
-
if (result.kind === "static" || result.kind === "dynamic") {
|
|
39
|
-
layer1.set(layoutIndex, result.kind);
|
|
40
|
-
layer1Reasons.set(layoutIndex, result.reason);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
manifestRoutes.push({
|
|
44
|
-
pattern: route.pattern,
|
|
45
|
-
layoutPaths: [...route.layouts],
|
|
46
|
-
layer1,
|
|
47
|
-
layer1Reasons
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return { routes: manifestRoutes };
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Merges Layer 1 (segment config) and Layer 2 (module graph) into a single
|
|
54
|
-
* per-route map, applying the Layer-1-wins priority rule.
|
|
55
|
-
*
|
|
56
|
-
* Layer 1 always takes priority over Layer 2 for the same layout index:
|
|
57
|
-
* segment config is a user-authored guarantee, so a layout that explicitly
|
|
58
|
-
* says `force-dynamic` must never be demoted to "static" because its module
|
|
59
|
-
* graph happened to be clean.
|
|
60
|
-
*/
|
|
61
|
-
function mergeLayersForRoute(route, layer2) {
|
|
62
|
-
const merged = /* @__PURE__ */ new Map();
|
|
63
|
-
if (layer2) for (const [layoutIdx, reason] of layer2) merged.set(layoutIdx, {
|
|
64
|
-
kind: "static",
|
|
65
|
-
reason
|
|
66
|
-
});
|
|
67
|
-
for (const [layoutIdx, kind] of route.layer1) {
|
|
68
|
-
const reason = route.layer1Reasons.get(layoutIdx);
|
|
69
|
-
if (reason === void 0) throw new Error(`vinext: layout ${layoutIdx} in route ${route.pattern} has a Layer 1 decision without a reason`);
|
|
70
|
-
merged.set(layoutIdx, {
|
|
71
|
-
kind,
|
|
72
|
-
reason
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return merged;
|
|
76
|
-
}
|
|
77
|
-
function serializeReasonExpression(reason) {
|
|
78
|
-
switch (reason.layer) {
|
|
79
|
-
case "segment-config": {
|
|
80
|
-
const value = reason.value === Infinity ? "Infinity" : JSON.stringify(reason.value);
|
|
81
|
-
return `{ layer: "segment-config", key: ${JSON.stringify(reason.key)}, value: ${value} }`;
|
|
82
|
-
}
|
|
83
|
-
case "module-graph": {
|
|
84
|
-
const props = [`layer: "module-graph"`, `result: ${JSON.stringify(reason.result)}`];
|
|
85
|
-
if (reason.firstShimMatch !== void 0) props.push(`firstShimMatch: ${JSON.stringify(reason.firstShimMatch)}`);
|
|
86
|
-
return `{ ${props.join(", ")} }`;
|
|
87
|
-
}
|
|
88
|
-
case "runtime-probe": {
|
|
89
|
-
const props = [`layer: "runtime-probe"`, `outcome: ${JSON.stringify(reason.outcome)}`];
|
|
90
|
-
if (reason.error !== void 0) props.push(`error: ${JSON.stringify(reason.error)}`);
|
|
91
|
-
return `{ ${props.join(", ")} }`;
|
|
92
|
-
}
|
|
93
|
-
case "no-classifier": return `{ layer: "no-classifier" }`;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function buildRouteDispatchReplacement(manifest, layer2PerRoute, serializeEntry) {
|
|
97
|
-
const cases = [];
|
|
98
|
-
for (let routeIdx = 0; routeIdx < manifest.routes.length; routeIdx++) {
|
|
99
|
-
const route = manifest.routes[routeIdx];
|
|
100
|
-
const merged = mergeLayersForRoute(route, layer2PerRoute.get(routeIdx));
|
|
101
|
-
if (merged.size === 0) continue;
|
|
102
|
-
const entries = [...merged.entries()].sort((a, b) => a[0] - b[0]).map(([idx, value]) => `[${idx}, ${serializeEntry(value)}]`).join(", ");
|
|
103
|
-
cases.push(` case ${routeIdx}: return new Map([${entries}]);`);
|
|
104
|
-
}
|
|
105
|
-
return [
|
|
106
|
-
"(routeIdx) => {",
|
|
107
|
-
" switch (routeIdx) {",
|
|
108
|
-
...cases,
|
|
109
|
-
" default: return null;",
|
|
110
|
-
" }",
|
|
111
|
-
" }"
|
|
112
|
-
].join("\n");
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Builds a JavaScript arrow-function expression that dispatches route index
|
|
116
|
-
* to a pre-computed `Map<layoutIndex, "static" | "dynamic">` of build-time
|
|
117
|
-
* classifications. The returned string is suitable for embedding into the
|
|
118
|
-
* generated RSC entry via the `renderChunk` hook.
|
|
119
|
-
*
|
|
120
|
-
* `layer2PerRoute` is typed to only carry `"static"` entries — the
|
|
121
|
-
* module-graph classifier can only prove static, so "needs-probe" results
|
|
122
|
-
* are omitted by the caller before this map is constructed.
|
|
123
|
-
*/
|
|
124
|
-
function buildClassificationReplacement(manifest, layer2PerRoute) {
|
|
125
|
-
return buildRouteDispatchReplacement(manifest, layer2PerRoute, (value) => JSON.stringify(value.kind));
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Sibling of `buildClassificationReplacement`: emits a dispatch function
|
|
129
|
-
* that returns `Map<layoutIndex, ClassificationReason>` per route.
|
|
130
|
-
*
|
|
131
|
-
* The runtime consults this map only when `VINEXT_DEBUG_CLASSIFICATION` is
|
|
132
|
-
* set, and the plugin only patches this dispatcher into the built bundle when
|
|
133
|
-
* that env var is present at build time.
|
|
134
|
-
*
|
|
135
|
-
* Layer 1 priority applies the same way as in `buildClassificationReplacement`:
|
|
136
|
-
* a segment-config reason must override a module-graph reason for the same
|
|
137
|
-
* layout index.
|
|
138
|
-
*/
|
|
139
|
-
function buildReasonsReplacement(manifest, layer2PerRoute) {
|
|
140
|
-
return buildRouteDispatchReplacement(manifest, layer2PerRoute, (value) => serializeReasonExpression(value.reason));
|
|
141
|
-
}
|
|
142
|
-
//#endregion
|
|
143
|
-
export { buildClassificationReplacement, buildReasonsReplacement, collectRouteClassificationManifest };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS } from "./client-reuse-manifest.js";
|
|
2
|
-
import { AppRouterState } from "./app-browser-state.js";
|
|
3
|
-
//#region src/server/app-browser-client-reuse-manifest.d.ts
|
|
4
|
-
type ClientReuseManifestLimits = typeof DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS;
|
|
5
|
-
type VisibleAppState = Pick<AppRouterState, "elements" | "visibleCommitVersion">;
|
|
6
|
-
type CreateClientReuseManifestHeaderOptions = Readonly<{
|
|
7
|
-
limits?: ClientReuseManifestLimits;
|
|
8
|
-
}>;
|
|
9
|
-
export declare function createClientReuseManifestHeaderFromVisibleAppState(state: VisibleAppState, options?: CreateClientReuseManifestHeaderOptions): string | null;
|
|
10
|
-
//#endregion
|
|
11
|
-
export {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { AppElementsWire } from "./app-elements-wire.js";
|
|
2
|
-
import "./app-elements.js";
|
|
3
|
-
import { DEFAULT_CACHE_VARIANT_BUDGET, buildCacheVariantWithRouteBudget } from "./cache-proof.js";
|
|
4
|
-
import { DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS, countUtf8Bytes, serializeClientReuseManifest } from "./client-reuse-manifest.js";
|
|
5
|
-
import { createStaticLayoutClientReuseArtifactCompatibility, createStaticLayoutClientReusePayloadHash, createStaticLayoutClientReuseRouteId } from "./static-layout-client-reuse-proof.js";
|
|
6
|
-
//#region src/server/app-browser-client-reuse-manifest.ts
|
|
7
|
-
function capClientReuseManifestProducerLimits(limits) {
|
|
8
|
-
return {
|
|
9
|
-
...limits,
|
|
10
|
-
maxEntryCount: Math.min(limits.maxEntryCount, 8)
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function serializeBoundedClientReuseManifest(input) {
|
|
14
|
-
const entries = input.entries.slice(0, input.limits.maxEntryCount);
|
|
15
|
-
let low = 1;
|
|
16
|
-
let high = entries.length;
|
|
17
|
-
let best = null;
|
|
18
|
-
while (low <= high) {
|
|
19
|
-
const size = Math.floor((low + high) / 2);
|
|
20
|
-
const serialized = serializeClientReuseManifest({
|
|
21
|
-
entries: entries.slice(0, size),
|
|
22
|
-
replayWindow: {
|
|
23
|
-
validFromVisibleCommitVersion: input.visibleCommitVersion,
|
|
24
|
-
validUntilVisibleCommitVersion: input.visibleCommitVersion
|
|
25
|
-
},
|
|
26
|
-
visibleCommitVersion: input.visibleCommitVersion
|
|
27
|
-
});
|
|
28
|
-
if (countUtf8Bytes(serialized) <= input.limits.maxManifestBytes) {
|
|
29
|
-
best = serialized;
|
|
30
|
-
low = size + 1;
|
|
31
|
-
} else high = size - 1;
|
|
32
|
-
}
|
|
33
|
-
return best;
|
|
34
|
-
}
|
|
35
|
-
function hasRetainedElement(elements, elementId) {
|
|
36
|
-
return Object.hasOwn(elements, elementId);
|
|
37
|
-
}
|
|
38
|
-
function createStaticLayoutEntry(input) {
|
|
39
|
-
const routeId = createStaticLayoutClientReuseRouteId(input.layoutId);
|
|
40
|
-
const output = {
|
|
41
|
-
kind: "layout",
|
|
42
|
-
layoutId: input.layoutId,
|
|
43
|
-
rootBoundaryId: input.artifactCompatibility.rootBoundaryId,
|
|
44
|
-
routeId
|
|
45
|
-
};
|
|
46
|
-
const candidateVariant = buildCacheVariantWithRouteBudget({
|
|
47
|
-
budget: DEFAULT_CACHE_VARIANT_BUDGET,
|
|
48
|
-
dimensions: [],
|
|
49
|
-
output,
|
|
50
|
-
routeBudget: {
|
|
51
|
-
routeId: output.routeId,
|
|
52
|
-
variantCacheKeys: []
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
if (candidateVariant.kind !== "variant") return null;
|
|
56
|
-
const artifactCompatibility = createStaticLayoutClientReuseArtifactCompatibility({
|
|
57
|
-
artifactCompatibility: input.artifactCompatibility,
|
|
58
|
-
layoutId: input.layoutId,
|
|
59
|
-
rootBoundaryId: output.rootBoundaryId,
|
|
60
|
-
routeId: output.routeId,
|
|
61
|
-
variantCacheKey: candidateVariant.variant.cacheKey
|
|
62
|
-
});
|
|
63
|
-
return {
|
|
64
|
-
artifactCompatibility,
|
|
65
|
-
id: input.layoutId,
|
|
66
|
-
payloadHash: createStaticLayoutClientReusePayloadHash({
|
|
67
|
-
artifactCompatibility,
|
|
68
|
-
layoutId: input.layoutId,
|
|
69
|
-
rootBoundaryId: output.rootBoundaryId,
|
|
70
|
-
routeId: output.routeId,
|
|
71
|
-
variantCacheKey: candidateVariant.variant.cacheKey
|
|
72
|
-
}),
|
|
73
|
-
privacy: "public",
|
|
74
|
-
variantCacheKey: candidateVariant.variant.cacheKey
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function createClientReuseManifestHeaderFromVisibleAppState(state, options = {}) {
|
|
78
|
-
const limits = capClientReuseManifestProducerLimits(options.limits ?? DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS);
|
|
79
|
-
const metadata = AppElementsWire.readMetadata(state.elements);
|
|
80
|
-
const entries = [];
|
|
81
|
-
for (const layoutId of metadata.layoutIds) {
|
|
82
|
-
if (entries.length >= limits.maxEntryCount) break;
|
|
83
|
-
if (layoutId.length > limits.maxEntryIdLength) continue;
|
|
84
|
-
if (metadata.layoutFlags[layoutId] !== "s") continue;
|
|
85
|
-
if (!hasRetainedElement(state.elements, layoutId)) continue;
|
|
86
|
-
if (AppElementsWire.parseElementKey(layoutId)?.kind !== "layout") continue;
|
|
87
|
-
const entry = createStaticLayoutEntry({
|
|
88
|
-
artifactCompatibility: metadata.artifactCompatibility,
|
|
89
|
-
layoutId
|
|
90
|
-
});
|
|
91
|
-
if (entry) entries.push(entry);
|
|
92
|
-
}
|
|
93
|
-
if (entries.length === 0) return null;
|
|
94
|
-
return serializeBoundedClientReuseManifest({
|
|
95
|
-
entries,
|
|
96
|
-
limits,
|
|
97
|
-
visibleCommitVersion: state.visibleCommitVersion
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
//#endregion
|
|
101
|
-
export { createClientReuseManifestHeaderFromVisibleAppState };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { RenderRequestApiKind } from "./cache-proof.js";
|
|
2
|
-
import { ClientReuseManifestRejectionCode, ClientReuseManifestTraceFields } from "./client-reuse-manifest.js";
|
|
3
|
-
import { ThenableParamsObserver } from "../shims/thenable-params.js";
|
|
4
|
-
import { UnstableCacheObservation } from "../shims/cache-request-state.js";
|
|
5
|
-
//#region src/server/app-layout-param-observation.d.ts
|
|
6
|
-
export type AppLayoutParamAccessObservation = Readonly<{
|
|
7
|
-
cacheLifeObserved: boolean;
|
|
8
|
-
cacheTags: readonly string[];
|
|
9
|
-
cacheableFetchCount: number;
|
|
10
|
-
completeness: "complete" | "unknown";
|
|
11
|
-
dynamicFetchCount: number;
|
|
12
|
-
/**
|
|
13
|
-
* `markDynamicUsage()` fired during the probe (e.g. `"use cache: private"`,
|
|
14
|
-
* `connection()`) with no other observable trace. Folded in from the
|
|
15
|
-
* isolated probe scope so this signal can't diverge from the Layer-3
|
|
16
|
-
* `dynamicDetected` path it replaced.
|
|
17
|
-
*/
|
|
18
|
-
dynamicUsageObserved: boolean;
|
|
19
|
-
finiteRevalidateSeconds: number | null;
|
|
20
|
-
keys: readonly string[];
|
|
21
|
-
observed: boolean;
|
|
22
|
-
paramScopeKeys: readonly string[];
|
|
23
|
-
requestApis: readonly RenderRequestApiKind[];
|
|
24
|
-
unstableCaches: readonly UnstableCacheObservation[];
|
|
25
|
-
}>;
|
|
26
|
-
export type AppLayoutParamAccessTracker = Readonly<{
|
|
27
|
-
createThenableParamsObserver: (layoutId: string) => ThenableParamsObserver;
|
|
28
|
-
getLayoutObservation: (layoutId: string) => AppLayoutParamAccessObservation;
|
|
29
|
-
recordLayoutFiniteRevalidate: (layoutId: string, revalidateSeconds: number) => void;
|
|
30
|
-
recordLayoutParamScope: (layoutId: string, paramScopeKeys: readonly string[]) => void;
|
|
31
|
-
runLayoutProbe: (layoutId: string, probe: () => unknown) => unknown;
|
|
32
|
-
}>;
|
|
33
|
-
type StaticLayoutObservationSkipCode = Extract<ClientReuseManifestRejectionCode, `SKIP_LAYOUT_${string}`>;
|
|
34
|
-
export type StaticLayoutObservationSkipRejection = Readonly<{
|
|
35
|
-
code: StaticLayoutObservationSkipCode;
|
|
36
|
-
fields: ClientReuseManifestTraceFields;
|
|
37
|
-
}>;
|
|
38
|
-
export declare function getStaticLayoutObservationSkipRejection(observation: AppLayoutParamAccessObservation): StaticLayoutObservationSkipRejection | null;
|
|
39
|
-
export declare function isAppLayoutObservationUnsafeForStaticReuse(observation: AppLayoutParamAccessObservation): boolean;
|
|
40
|
-
export declare function createAppLayoutParamAccessTracker(): AppLayoutParamAccessTracker;
|
|
41
|
-
//#endregion
|
|
42
|
-
export {};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { isInsideUnifiedScope, runWithUnifiedStateMutation } from "../shims/unified-request-context.js";
|
|
2
|
-
import { isPromiseLike } from "../utils/promise.js";
|
|
3
|
-
import { peekDynamicUsage, peekRenderRequestApiUsage } from "../shims/headers.js";
|
|
4
|
-
import { _peekRequestScopedCacheLife, _peekUnstableCacheObservations } from "../shims/cache-request-state.js";
|
|
5
|
-
import { getCollectedFetchTags, peekCacheableFetchObservations, peekDynamicFetchObservations } from "../shims/fetch-cache.js";
|
|
6
|
-
//#region src/server/app-layout-param-observation.ts
|
|
7
|
-
const STATIC_LAYOUT_OBSERVATION_SKIP_RULES = [
|
|
8
|
-
["SKIP_LAYOUT_PARAMS_OBSERVATION_INCOMPLETE", (observation) => observation.completeness !== "complete"],
|
|
9
|
-
["SKIP_LAYOUT_PARAMS_PRESENT", (observation) => observation.paramScopeKeys.length > 0],
|
|
10
|
-
["SKIP_LAYOUT_PARAMS_OBSERVED", (observation) => observation.observed],
|
|
11
|
-
["SKIP_LAYOUT_DYNAMIC_USAGE_OBSERVED", (observation) => observation.dynamicUsageObserved],
|
|
12
|
-
["SKIP_LAYOUT_REQUEST_API_OBSERVED", (observation) => observation.requestApis.length > 0],
|
|
13
|
-
["SKIP_LAYOUT_REVALIDATE_PRESENT", (observation) => observation.finiteRevalidateSeconds !== null],
|
|
14
|
-
["SKIP_LAYOUT_CACHE_LIFE_OBSERVED", (observation) => observation.cacheLifeObserved],
|
|
15
|
-
["SKIP_LAYOUT_UNSTABLE_CACHE_OBSERVED", (observation) => observation.unstableCaches.length > 0],
|
|
16
|
-
["SKIP_LAYOUT_CACHE_TAGS_OBSERVED", (observation) => observation.cacheTags.length > 0],
|
|
17
|
-
["SKIP_LAYOUT_CACHEABLE_FETCHES_OBSERVED", (observation) => observation.cacheableFetchCount > 0],
|
|
18
|
-
["SKIP_LAYOUT_DYNAMIC_FETCHES_OBSERVED", (observation) => observation.dynamicFetchCount > 0]
|
|
19
|
-
];
|
|
20
|
-
function createStaticLayoutObservationTraceFields(observation) {
|
|
21
|
-
return {
|
|
22
|
-
cacheLifeObserved: observation.cacheLifeObserved,
|
|
23
|
-
cacheTags: observation.cacheTags,
|
|
24
|
-
cacheableFetchCount: observation.cacheableFetchCount,
|
|
25
|
-
dynamicFetchCount: observation.dynamicFetchCount,
|
|
26
|
-
dynamicUsageObserved: observation.dynamicUsageObserved,
|
|
27
|
-
finiteRevalidateSeconds: observation.finiteRevalidateSeconds,
|
|
28
|
-
observedParamKeys: observation.keys,
|
|
29
|
-
paramScopeKeys: observation.paramScopeKeys,
|
|
30
|
-
requestApis: observation.requestApis,
|
|
31
|
-
unstableCacheCount: observation.unstableCaches.length,
|
|
32
|
-
unstableCacheKeyHashes: observation.unstableCaches.map((cache) => cache.keyHash),
|
|
33
|
-
unstableCacheRevalidates: observation.unstableCaches.map((cache) => String(cache.revalidate)),
|
|
34
|
-
unstableCacheTagCounts: observation.unstableCaches.map((cache) => String(cache.tagCount)),
|
|
35
|
-
unstableCacheTagHashes: observation.unstableCaches.map((cache) => cache.tagHash ?? "none")
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function getStaticLayoutObservationSkipRejection(observation) {
|
|
39
|
-
for (const [code, matches] of STATIC_LAYOUT_OBSERVATION_SKIP_RULES) if (matches(observation)) return {
|
|
40
|
-
code,
|
|
41
|
-
fields: createStaticLayoutObservationTraceFields(observation)
|
|
42
|
-
};
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
function isAppLayoutObservationUnsafeForStaticReuse(observation) {
|
|
46
|
-
return getStaticLayoutObservationSkipRejection(observation) !== null;
|
|
47
|
-
}
|
|
48
|
-
function createAppLayoutParamAccessTracker() {
|
|
49
|
-
const observations = /* @__PURE__ */ new Map();
|
|
50
|
-
const ensureObservation = (layoutId) => {
|
|
51
|
-
const existing = observations.get(layoutId);
|
|
52
|
-
if (existing) return existing;
|
|
53
|
-
const created = {
|
|
54
|
-
cacheLifeObserved: false,
|
|
55
|
-
cacheTags: /* @__PURE__ */ new Set(),
|
|
56
|
-
cacheableFetches: /* @__PURE__ */ new Set(),
|
|
57
|
-
dynamicFetches: /* @__PURE__ */ new Set(),
|
|
58
|
-
dynamicUsageObserved: false,
|
|
59
|
-
finiteRevalidateSeconds: null,
|
|
60
|
-
keys: /* @__PURE__ */ new Set(),
|
|
61
|
-
observed: false,
|
|
62
|
-
paramScopeKeys: /* @__PURE__ */ new Set(),
|
|
63
|
-
probeComplete: false,
|
|
64
|
-
requestApis: /* @__PURE__ */ new Set(),
|
|
65
|
-
unstableCaches: /* @__PURE__ */ new Map()
|
|
66
|
-
};
|
|
67
|
-
observations.set(layoutId, created);
|
|
68
|
-
return created;
|
|
69
|
-
};
|
|
70
|
-
const markObserved = (layoutId, keys) => {
|
|
71
|
-
const observation = ensureObservation(layoutId);
|
|
72
|
-
observation.observed = true;
|
|
73
|
-
for (const key of keys) observation.keys.add(key);
|
|
74
|
-
};
|
|
75
|
-
const markProbeComplete = (layoutId) => {
|
|
76
|
-
ensureObservation(layoutId).probeComplete = true;
|
|
77
|
-
};
|
|
78
|
-
const runWithIsolatedProbeDependencies = (probe) => {
|
|
79
|
-
if (!isInsideUnifiedScope()) return probe();
|
|
80
|
-
return runWithUnifiedStateMutation((ctx) => {
|
|
81
|
-
ctx.cacheableFetchUrls = /* @__PURE__ */ new Set();
|
|
82
|
-
ctx.currentRequestTags = [];
|
|
83
|
-
ctx.currentFetchSoftTags = [];
|
|
84
|
-
ctx.dynamicFetchUrls = /* @__PURE__ */ new Set();
|
|
85
|
-
ctx.dynamicUsageDetected = false;
|
|
86
|
-
ctx.renderRequestApiUsage = /* @__PURE__ */ new Set();
|
|
87
|
-
ctx.requestScopedCacheLife = null;
|
|
88
|
-
ctx.unstableCacheObservations = /* @__PURE__ */ new Map();
|
|
89
|
-
}, probe);
|
|
90
|
-
};
|
|
91
|
-
const recordProbeDependencies = (layoutId) => {
|
|
92
|
-
const observation = ensureObservation(layoutId);
|
|
93
|
-
if (peekDynamicUsage()) observation.dynamicUsageObserved = true;
|
|
94
|
-
if (_peekRequestScopedCacheLife() !== null) observation.cacheLifeObserved = true;
|
|
95
|
-
for (const tag of getCollectedFetchTags()) observation.cacheTags.add(tag);
|
|
96
|
-
for (const url of peekCacheableFetchObservations()) observation.cacheableFetches.add(url);
|
|
97
|
-
for (const url of peekDynamicFetchObservations()) observation.dynamicFetches.add(url);
|
|
98
|
-
for (const requestApi of peekRenderRequestApiUsage()) observation.requestApis.add(requestApi);
|
|
99
|
-
for (const unstableCache of _peekUnstableCacheObservations()) observation.unstableCaches.set(unstableCache.keyHash, unstableCache);
|
|
100
|
-
};
|
|
101
|
-
return {
|
|
102
|
-
createThenableParamsObserver(layoutId) {
|
|
103
|
-
return { observeParamAccess(keys) {
|
|
104
|
-
markObserved(layoutId, keys);
|
|
105
|
-
} };
|
|
106
|
-
},
|
|
107
|
-
getLayoutObservation(layoutId) {
|
|
108
|
-
const observation = observations.get(layoutId);
|
|
109
|
-
if (!observation) return {
|
|
110
|
-
cacheLifeObserved: false,
|
|
111
|
-
cacheTags: [],
|
|
112
|
-
cacheableFetchCount: 0,
|
|
113
|
-
completeness: "unknown",
|
|
114
|
-
dynamicFetchCount: 0,
|
|
115
|
-
dynamicUsageObserved: false,
|
|
116
|
-
finiteRevalidateSeconds: null,
|
|
117
|
-
keys: [],
|
|
118
|
-
observed: false,
|
|
119
|
-
paramScopeKeys: [],
|
|
120
|
-
requestApis: [],
|
|
121
|
-
unstableCaches: []
|
|
122
|
-
};
|
|
123
|
-
return {
|
|
124
|
-
cacheLifeObserved: observation.cacheLifeObserved,
|
|
125
|
-
cacheTags: [...observation.cacheTags].sort(),
|
|
126
|
-
cacheableFetchCount: observation.cacheableFetches.size,
|
|
127
|
-
completeness: observation.probeComplete ? "complete" : "unknown",
|
|
128
|
-
dynamicFetchCount: observation.dynamicFetches.size,
|
|
129
|
-
dynamicUsageObserved: observation.dynamicUsageObserved,
|
|
130
|
-
finiteRevalidateSeconds: observation.finiteRevalidateSeconds,
|
|
131
|
-
keys: [...observation.keys].sort(),
|
|
132
|
-
observed: observation.observed,
|
|
133
|
-
paramScopeKeys: [...observation.paramScopeKeys].sort(),
|
|
134
|
-
requestApis: [...observation.requestApis].sort(),
|
|
135
|
-
unstableCaches: [...observation.unstableCaches.values()].sort((a, b) => a.keyHash.localeCompare(b.keyHash))
|
|
136
|
-
};
|
|
137
|
-
},
|
|
138
|
-
recordLayoutFiniteRevalidate(layoutId, revalidateSeconds) {
|
|
139
|
-
if (!Number.isFinite(revalidateSeconds) || revalidateSeconds <= 0) return;
|
|
140
|
-
const observation = ensureObservation(layoutId);
|
|
141
|
-
observation.finiteRevalidateSeconds = observation.finiteRevalidateSeconds === null ? revalidateSeconds : Math.min(observation.finiteRevalidateSeconds, revalidateSeconds);
|
|
142
|
-
},
|
|
143
|
-
recordLayoutParamScope(layoutId, paramScopeKeys) {
|
|
144
|
-
const observation = ensureObservation(layoutId);
|
|
145
|
-
for (const key of paramScopeKeys) observation.paramScopeKeys.add(key);
|
|
146
|
-
},
|
|
147
|
-
runLayoutProbe(layoutId, probe) {
|
|
148
|
-
return runWithIsolatedProbeDependencies(() => {
|
|
149
|
-
const result = probe();
|
|
150
|
-
if (!isPromiseLike(result)) {
|
|
151
|
-
recordProbeDependencies(layoutId);
|
|
152
|
-
markProbeComplete(layoutId);
|
|
153
|
-
return result;
|
|
154
|
-
}
|
|
155
|
-
return Promise.resolve(result).then((resolved) => {
|
|
156
|
-
recordProbeDependencies(layoutId);
|
|
157
|
-
markProbeComplete(layoutId);
|
|
158
|
-
return resolved;
|
|
159
|
-
}, (error) => {
|
|
160
|
-
recordProbeDependencies(layoutId);
|
|
161
|
-
throw error;
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
//#endregion
|
|
168
|
-
export { createAppLayoutParamAccessTracker, getStaticLayoutObservationSkipRejection, isAppLayoutObservationUnsafeForStaticReuse };
|