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,103 +0,0 @@
|
|
|
1
|
-
import { ArtifactCompatibilityEnvelope } from "./artifact-compatibility.js";
|
|
2
|
-
//#region src/server/client-reuse-manifest.d.ts
|
|
3
|
-
export declare const CLIENT_REUSE_MANIFEST_SCHEMA_VERSION = 1;
|
|
4
|
-
type ClientReuseManifestSchemaVersion = 1;
|
|
5
|
-
export declare const CLIENT_REUSE_MANIFEST_HASH_ALGORITHM = "fnv1a64";
|
|
6
|
-
type ClientReuseManifestHashAlgorithm = typeof CLIENT_REUSE_MANIFEST_HASH_ALGORITHM;
|
|
7
|
-
type ClientReuseManifestLimits = Readonly<{
|
|
8
|
-
maxEntryCount: number;
|
|
9
|
-
maxEntryIdLength: number;
|
|
10
|
-
maxManifestBytes: number;
|
|
11
|
-
maxPayloadHashLength: number;
|
|
12
|
-
maxVariantCacheKeyLength: number;
|
|
13
|
-
}>;
|
|
14
|
-
export declare const DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS: {
|
|
15
|
-
maxEntryCount: number;
|
|
16
|
-
maxEntryIdLength: number;
|
|
17
|
-
maxManifestBytes: number;
|
|
18
|
-
maxPayloadHashLength: number;
|
|
19
|
-
maxVariantCacheKeyLength: number;
|
|
20
|
-
};
|
|
21
|
-
export declare const CLIENT_REUSE_MANIFEST_SKIP_VERIFICATION_ENTRY_BUDGET = 8;
|
|
22
|
-
type ClientReuseManifestEntryKind = "layout" | "page" | "route" | "slot" | "template";
|
|
23
|
-
type ClientReuseManifestEntryPrivacy = "private" | "public";
|
|
24
|
-
type ClientReuseManifestReplayWindow = Readonly<{
|
|
25
|
-
validFromVisibleCommitVersion: number;
|
|
26
|
-
validUntilVisibleCommitVersion: number;
|
|
27
|
-
}>;
|
|
28
|
-
export type ClientReuseManifestEntry = Readonly<{
|
|
29
|
-
artifactCompatibility: ArtifactCompatibilityEnvelope;
|
|
30
|
-
id: string;
|
|
31
|
-
kind: ClientReuseManifestEntryKind;
|
|
32
|
-
payloadHash: string;
|
|
33
|
-
privacy: "public";
|
|
34
|
-
variantCacheKey: string;
|
|
35
|
-
}>;
|
|
36
|
-
type ClientReuseManifestWireEntry = Readonly<{
|
|
37
|
-
artifactCompatibility: ArtifactCompatibilityEnvelope;
|
|
38
|
-
id: string;
|
|
39
|
-
payloadHash: string;
|
|
40
|
-
privacy: ClientReuseManifestEntryPrivacy;
|
|
41
|
-
variantCacheKey: string;
|
|
42
|
-
}>;
|
|
43
|
-
type ClientReuseManifest = Readonly<{
|
|
44
|
-
entries: readonly ClientReuseManifestEntry[];
|
|
45
|
-
hashAlgorithm: ClientReuseManifestHashAlgorithm;
|
|
46
|
-
replayWindow: ClientReuseManifestReplayWindow;
|
|
47
|
-
schemaVersion: ClientReuseManifestSchemaVersion;
|
|
48
|
-
visibleCommitVersion: number;
|
|
49
|
-
}>;
|
|
50
|
-
type ClientReuseManifestWire = Readonly<{
|
|
51
|
-
entries: readonly ClientReuseManifestWireEntry[];
|
|
52
|
-
hashAlgorithm: ClientReuseManifestHashAlgorithm;
|
|
53
|
-
replayWindow: ClientReuseManifestReplayWindow;
|
|
54
|
-
schemaVersion: ClientReuseManifestSchemaVersion;
|
|
55
|
-
visibleCommitVersion: number;
|
|
56
|
-
}>;
|
|
57
|
-
type CreateClientReuseManifestInput = Readonly<{
|
|
58
|
-
entries: readonly ClientReuseManifestWireEntry[];
|
|
59
|
-
replayWindow?: ClientReuseManifestReplayWindow;
|
|
60
|
-
visibleCommitVersion: number;
|
|
61
|
-
}>;
|
|
62
|
-
export type ClientReuseManifestRejectionCode = "SKIP_CACHE_ARTIFACT_COMPATIBILITY_INCOMPATIBLE" | "SKIP_CACHE_ARTIFACT_COMPATIBILITY_UNKNOWN" | "SKIP_CACHE_ARTIFACT_PROOF_MISMATCH" | "SKIP_CACHE_ENTRY_ID_MISMATCH" | "SKIP_CACHE_INVALIDATED" | "SKIP_CACHE_INVALIDATION_UNKNOWN" | "SKIP_CACHE_PAYLOAD_HASH_MISMATCH" | "SKIP_CACHE_PAYLOAD_HASH_MISSING" | "SKIP_CACHE_PROOF_MISSING" | "SKIP_CACHE_PROOF_REJECTED" | "SKIP_CACHE_REUSE_CLASS_UNSUPPORTED" | "SKIP_CACHE_VARIANT_MISMATCH" | "SKIP_LAYOUT_CACHE_LIFE_OBSERVED" | "SKIP_LAYOUT_CACHE_TAGS_OBSERVED" | "SKIP_LAYOUT_CACHEABLE_FETCHES_OBSERVED" | "SKIP_LAYOUT_DYNAMIC_FETCHES_OBSERVED" | "SKIP_LAYOUT_DYNAMIC_USAGE_OBSERVED" | "SKIP_LAYOUT_PARAMS_OBSERVED" | "SKIP_LAYOUT_PARAMS_OBSERVATION_INCOMPLETE" | "SKIP_LAYOUT_PARAMS_PRESENT" | "SKIP_LAYOUT_REVALIDATE_PRESENT" | "SKIP_LAYOUT_REQUEST_API_OBSERVED" | "SKIP_LAYOUT_UNSTABLE_CACHE_OBSERVED" | "SKIP_ARTIFACT_COMPATIBILITY_INVALID" | "SKIP_ENTRY_COUNT_EXCEEDED" | "SKIP_VERIFICATION_BUDGET_EXCEEDED" | "SKIP_ENTRY_HASH_INVALID" | "SKIP_ENTRY_ID_INVALID" | "SKIP_ENTRY_ID_TOO_LONG" | "SKIP_ENTRY_MALFORMED" | "SKIP_ENTRY_ORDER_NON_CANONICAL" | "SKIP_HASH_ALGORITHM_UNSUPPORTED" | "SKIP_MANIFEST_MALFORMED" | "SKIP_MANIFEST_SCHEMA_UNSUPPORTED" | "SKIP_MANIFEST_TOO_LARGE" | "SKIP_PRIVATE_ENTRY" | "SKIP_REPLAY_WINDOW_INVALID" | "SKIP_UNKNOWN_ENTRY" | "SKIP_VARIANT_CACHE_KEY_INVALID" | "SKIP_VARIANT_CACHE_KEY_TOO_LONG" | "SKIP_VISIBLE_COMMIT_VERSION_INVALID" | "SKIP_VISIBLE_COMMIT_VERSION_MISMATCH";
|
|
63
|
-
type ClientReuseManifestTraceFieldValue = string | number | boolean | null | readonly string[];
|
|
64
|
-
export type ClientReuseManifestTraceFields = Readonly<Record<string, ClientReuseManifestTraceFieldValue>>;
|
|
65
|
-
export type ClientReuseManifestRejection = Readonly<{
|
|
66
|
-
code: ClientReuseManifestRejectionCode;
|
|
67
|
-
fields: ClientReuseManifestTraceFields;
|
|
68
|
-
}>;
|
|
69
|
-
export type ClientReuseManifestEntryRejection = ClientReuseManifestRejection & Readonly<{
|
|
70
|
-
entryId: string | null;
|
|
71
|
-
}>;
|
|
72
|
-
export type ClientReuseManifestSkipDisposition = Readonly<{
|
|
73
|
-
code: "SKIP_MODEL_DISABLED";
|
|
74
|
-
enabled: false;
|
|
75
|
-
mode: "renderAndSend";
|
|
76
|
-
}> | Readonly<{
|
|
77
|
-
code: "SKIP_STATIC_LAYOUT_VERIFIED";
|
|
78
|
-
enabled: true;
|
|
79
|
-
mode: "skipStaticLayout";
|
|
80
|
-
skippedEntryIds: readonly string[];
|
|
81
|
-
}>;
|
|
82
|
-
export type ClientReuseManifestParseResult = Readonly<{
|
|
83
|
-
kind: "absent";
|
|
84
|
-
}> | Readonly<{
|
|
85
|
-
kind: "rejected";
|
|
86
|
-
rejection: ClientReuseManifestRejection;
|
|
87
|
-
}> | Readonly<{
|
|
88
|
-
entryRejections: readonly ClientReuseManifestEntryRejection[];
|
|
89
|
-
kind: "parsed";
|
|
90
|
-
manifest: ClientReuseManifest;
|
|
91
|
-
skipDisposition: ClientReuseManifestSkipDisposition;
|
|
92
|
-
}>;
|
|
93
|
-
type ParseClientReuseManifestOptions = Readonly<{
|
|
94
|
-
currentVisibleCommitVersion?: number;
|
|
95
|
-
limits?: ClientReuseManifestLimits;
|
|
96
|
-
}>;
|
|
97
|
-
export declare function countUtf8Bytes(input: string): number;
|
|
98
|
-
export declare function createClientReusePayloadHash(input: string): string;
|
|
99
|
-
export declare function createClientReuseManifest(input: CreateClientReuseManifestInput): ClientReuseManifestWire;
|
|
100
|
-
export declare function serializeClientReuseManifest(input: CreateClientReuseManifestInput): string;
|
|
101
|
-
export declare function parseClientReuseManifestHeader(rawHeader: string | null | undefined, options?: ParseClientReuseManifestOptions): ClientReuseManifestParseResult;
|
|
102
|
-
//#endregion
|
|
103
|
-
export {};
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { isUnknownRecord } from "../utils/record.js";
|
|
2
|
-
import { parseAppElementsWireElementKey } from "./app-elements-wire-key.js";
|
|
3
|
-
import { fnv1a64 } from "../utils/hash.js";
|
|
4
|
-
import { parseArtifactCompatibilityEnvelope } from "./artifact-compatibility.js";
|
|
5
|
-
import { isNonNegativeSafeInteger } from "../utils/number.js";
|
|
6
|
-
//#region src/server/client-reuse-manifest.ts
|
|
7
|
-
const CLIENT_REUSE_MANIFEST_SCHEMA_VERSION = 1;
|
|
8
|
-
const CLIENT_REUSE_MANIFEST_HASH_ALGORITHM = "fnv1a64";
|
|
9
|
-
const DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS = {
|
|
10
|
-
maxEntryCount: 64,
|
|
11
|
-
maxEntryIdLength: 512,
|
|
12
|
-
maxManifestBytes: 4096,
|
|
13
|
-
maxPayloadHashLength: 16,
|
|
14
|
-
maxVariantCacheKeyLength: 256
|
|
15
|
-
};
|
|
16
|
-
const CLIENT_REUSE_MANIFEST_SKIP_VERIFICATION_ENTRY_BUDGET = 8;
|
|
17
|
-
const HASH_DIGEST_PATTERN = /^[0-9a-z]+$/;
|
|
18
|
-
const textEncoder = new TextEncoder();
|
|
19
|
-
function createRejection(code, fields = {}) {
|
|
20
|
-
return {
|
|
21
|
-
code,
|
|
22
|
-
fields
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function rejectManifest(code, fields = {}) {
|
|
26
|
-
return {
|
|
27
|
-
kind: "rejected",
|
|
28
|
-
rejection: createRejection(code, fields)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function rejectEntry(code, entryId, fields = {}) {
|
|
32
|
-
return {
|
|
33
|
-
code,
|
|
34
|
-
entryId,
|
|
35
|
-
fields
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function compareManifestEntries(left, right) {
|
|
39
|
-
if (left.id < right.id) return -1;
|
|
40
|
-
if (left.id > right.id) return 1;
|
|
41
|
-
return 0;
|
|
42
|
-
}
|
|
43
|
-
function createCanonicalWireEntries(entries) {
|
|
44
|
-
const entriesById = /* @__PURE__ */ new Map();
|
|
45
|
-
for (const entry of entries) if (!entriesById.has(entry.id)) entriesById.set(entry.id, entry);
|
|
46
|
-
return Array.from(entriesById.values()).sort(compareManifestEntries);
|
|
47
|
-
}
|
|
48
|
-
function countUtf8Bytes(input) {
|
|
49
|
-
return textEncoder.encode(input).length;
|
|
50
|
-
}
|
|
51
|
-
function parseReplayWindow(value, visibleCommitVersion) {
|
|
52
|
-
if (!isUnknownRecord(value)) return {
|
|
53
|
-
kind: "rejected",
|
|
54
|
-
rejection: createRejection("SKIP_REPLAY_WINDOW_INVALID", { field: "replayWindow" })
|
|
55
|
-
};
|
|
56
|
-
const validFromVisibleCommitVersion = value.validFromVisibleCommitVersion;
|
|
57
|
-
const validUntilVisibleCommitVersion = value.validUntilVisibleCommitVersion;
|
|
58
|
-
if (!isNonNegativeSafeInteger(validFromVisibleCommitVersion) || !isNonNegativeSafeInteger(validUntilVisibleCommitVersion) || validFromVisibleCommitVersion > validUntilVisibleCommitVersion || visibleCommitVersion < validFromVisibleCommitVersion || visibleCommitVersion > validUntilVisibleCommitVersion) return {
|
|
59
|
-
kind: "rejected",
|
|
60
|
-
rejection: createRejection("SKIP_REPLAY_WINDOW_INVALID", {
|
|
61
|
-
validFromVisibleCommitVersion: isNonNegativeSafeInteger(validFromVisibleCommitVersion) ? validFromVisibleCommitVersion : null,
|
|
62
|
-
validUntilVisibleCommitVersion: isNonNegativeSafeInteger(validUntilVisibleCommitVersion) ? validUntilVisibleCommitVersion : null,
|
|
63
|
-
visibleCommitVersion
|
|
64
|
-
})
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
kind: "parsed",
|
|
68
|
-
replayWindow: {
|
|
69
|
-
validFromVisibleCommitVersion,
|
|
70
|
-
validUntilVisibleCommitVersion
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function currentCommitVersionMatchesReplayWindow(currentVisibleCommitVersion, replayWindow) {
|
|
75
|
-
if (currentVisibleCommitVersion === void 0) return true;
|
|
76
|
-
return currentVisibleCommitVersion >= replayWindow.validFromVisibleCommitVersion && currentVisibleCommitVersion <= replayWindow.validUntilVisibleCommitVersion;
|
|
77
|
-
}
|
|
78
|
-
function parseEntryKind(id) {
|
|
79
|
-
const parsed = parseAppElementsWireElementKey(id);
|
|
80
|
-
if (parsed === null) return null;
|
|
81
|
-
return parsed.kind;
|
|
82
|
-
}
|
|
83
|
-
function isValidPayloadHash(value, limits) {
|
|
84
|
-
return typeof value === "string" && value.length > 0 && value.length <= limits.maxPayloadHashLength && HASH_DIGEST_PATTERN.test(value);
|
|
85
|
-
}
|
|
86
|
-
function parseManifestEntry(value, limits, index) {
|
|
87
|
-
if (!isUnknownRecord(value)) return rejectEntry("SKIP_ENTRY_MALFORMED", null, { index });
|
|
88
|
-
const id = value.id;
|
|
89
|
-
if (typeof id !== "string" || id.length === 0) return rejectEntry("SKIP_ENTRY_ID_INVALID", null, { index });
|
|
90
|
-
if (id.length > limits.maxEntryIdLength) return rejectEntry("SKIP_ENTRY_ID_TOO_LONG", id, {
|
|
91
|
-
idHash: createClientReusePayloadHash(id),
|
|
92
|
-
maxEntryIdLength: limits.maxEntryIdLength
|
|
93
|
-
});
|
|
94
|
-
const kind = parseEntryKind(id);
|
|
95
|
-
if (kind === null) return rejectEntry("SKIP_UNKNOWN_ENTRY", id, { idHash: createClientReusePayloadHash(id) });
|
|
96
|
-
const privacy = value.privacy;
|
|
97
|
-
if (privacy === "private") return rejectEntry("SKIP_PRIVATE_ENTRY", id, { privacy });
|
|
98
|
-
if (privacy !== "public") return rejectEntry("SKIP_ENTRY_MALFORMED", id, { field: "privacy" });
|
|
99
|
-
const payloadHash = value.payloadHash;
|
|
100
|
-
if (!isValidPayloadHash(payloadHash, limits)) return rejectEntry("SKIP_ENTRY_HASH_INVALID", id, { maxPayloadHashLength: limits.maxPayloadHashLength });
|
|
101
|
-
const variantCacheKey = value.variantCacheKey;
|
|
102
|
-
if (typeof variantCacheKey !== "string" || variantCacheKey.length === 0) return rejectEntry("SKIP_VARIANT_CACHE_KEY_INVALID", id, { field: "variantCacheKey" });
|
|
103
|
-
if (variantCacheKey.length > limits.maxVariantCacheKeyLength) return rejectEntry("SKIP_VARIANT_CACHE_KEY_TOO_LONG", id, {
|
|
104
|
-
maxVariantCacheKeyLength: limits.maxVariantCacheKeyLength,
|
|
105
|
-
variantCacheKeyHash: createClientReusePayloadHash(variantCacheKey)
|
|
106
|
-
});
|
|
107
|
-
const artifactCompatibility = parseArtifactCompatibilityEnvelope(value.artifactCompatibility);
|
|
108
|
-
if (artifactCompatibility === null) return rejectEntry("SKIP_ARTIFACT_COMPATIBILITY_INVALID", id, { field: "artifactCompatibility" });
|
|
109
|
-
return {
|
|
110
|
-
artifactCompatibility,
|
|
111
|
-
id,
|
|
112
|
-
kind,
|
|
113
|
-
payloadHash,
|
|
114
|
-
privacy,
|
|
115
|
-
variantCacheKey
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function createClientReusePayloadHash(input) {
|
|
119
|
-
return fnv1a64(input);
|
|
120
|
-
}
|
|
121
|
-
function createClientReuseManifest(input) {
|
|
122
|
-
const replayWindow = input.replayWindow ?? {
|
|
123
|
-
validFromVisibleCommitVersion: input.visibleCommitVersion,
|
|
124
|
-
validUntilVisibleCommitVersion: input.visibleCommitVersion
|
|
125
|
-
};
|
|
126
|
-
return {
|
|
127
|
-
entries: createCanonicalWireEntries(input.entries),
|
|
128
|
-
hashAlgorithm: CLIENT_REUSE_MANIFEST_HASH_ALGORITHM,
|
|
129
|
-
replayWindow,
|
|
130
|
-
schemaVersion: 1,
|
|
131
|
-
visibleCommitVersion: input.visibleCommitVersion
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function serializeClientReuseManifest(input) {
|
|
135
|
-
return JSON.stringify(createClientReuseManifest(input));
|
|
136
|
-
}
|
|
137
|
-
function parseClientReuseManifestHeader(rawHeader, options = {}) {
|
|
138
|
-
const header = rawHeader?.trim();
|
|
139
|
-
if (!header) return { kind: "absent" };
|
|
140
|
-
const limits = options.limits ?? DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS;
|
|
141
|
-
const manifestBytes = countUtf8Bytes(header);
|
|
142
|
-
if (manifestBytes > limits.maxManifestBytes) return rejectManifest("SKIP_MANIFEST_TOO_LARGE", {
|
|
143
|
-
manifestBytes,
|
|
144
|
-
maxManifestBytes: limits.maxManifestBytes
|
|
145
|
-
});
|
|
146
|
-
let decoded;
|
|
147
|
-
try {
|
|
148
|
-
decoded = JSON.parse(header);
|
|
149
|
-
} catch {
|
|
150
|
-
return rejectManifest("SKIP_MANIFEST_MALFORMED");
|
|
151
|
-
}
|
|
152
|
-
if (!isUnknownRecord(decoded)) return rejectManifest("SKIP_MANIFEST_MALFORMED", { field: "manifest" });
|
|
153
|
-
if (decoded.schemaVersion !== 1) return rejectManifest("SKIP_MANIFEST_SCHEMA_UNSUPPORTED", { schemaVersion: typeof decoded.schemaVersion === "number" || typeof decoded.schemaVersion === "string" ? decoded.schemaVersion : null });
|
|
154
|
-
if (decoded.hashAlgorithm !== "fnv1a64") return rejectManifest("SKIP_HASH_ALGORITHM_UNSUPPORTED", { hashAlgorithm: typeof decoded.hashAlgorithm === "string" ? decoded.hashAlgorithm : null });
|
|
155
|
-
const visibleCommitVersion = decoded.visibleCommitVersion;
|
|
156
|
-
if (!isNonNegativeSafeInteger(visibleCommitVersion)) return rejectManifest("SKIP_VISIBLE_COMMIT_VERSION_INVALID", { visibleCommitVersion: null });
|
|
157
|
-
const replayWindowResult = parseReplayWindow(decoded.replayWindow, visibleCommitVersion);
|
|
158
|
-
if (replayWindowResult.kind === "rejected") return {
|
|
159
|
-
kind: "rejected",
|
|
160
|
-
rejection: replayWindowResult.rejection
|
|
161
|
-
};
|
|
162
|
-
const { replayWindow } = replayWindowResult;
|
|
163
|
-
if (!currentCommitVersionMatchesReplayWindow(options.currentVisibleCommitVersion, replayWindow)) return rejectManifest("SKIP_VISIBLE_COMMIT_VERSION_MISMATCH", {
|
|
164
|
-
currentVisibleCommitVersion: options.currentVisibleCommitVersion ?? null,
|
|
165
|
-
validFromVisibleCommitVersion: replayWindow.validFromVisibleCommitVersion,
|
|
166
|
-
validUntilVisibleCommitVersion: replayWindow.validUntilVisibleCommitVersion,
|
|
167
|
-
visibleCommitVersion
|
|
168
|
-
});
|
|
169
|
-
const entriesValue = decoded.entries;
|
|
170
|
-
if (!Array.isArray(entriesValue)) return rejectManifest("SKIP_MANIFEST_MALFORMED", { field: "entries" });
|
|
171
|
-
if (entriesValue.length > limits.maxEntryCount) return rejectManifest("SKIP_ENTRY_COUNT_EXCEEDED", {
|
|
172
|
-
entryCount: entriesValue.length,
|
|
173
|
-
maxEntryCount: limits.maxEntryCount
|
|
174
|
-
});
|
|
175
|
-
const entries = [];
|
|
176
|
-
const entryRejections = [];
|
|
177
|
-
let previousEntryId = null;
|
|
178
|
-
for (let index = 0; index < entriesValue.length; index++) {
|
|
179
|
-
const value = entriesValue[index];
|
|
180
|
-
if (isUnknownRecord(value) && typeof value.id === "string") {
|
|
181
|
-
if (previousEntryId !== null && value.id <= previousEntryId) return rejectManifest("SKIP_ENTRY_ORDER_NON_CANONICAL", {
|
|
182
|
-
entryIdHash: createClientReusePayloadHash(value.id),
|
|
183
|
-
previousEntryIdHash: createClientReusePayloadHash(previousEntryId)
|
|
184
|
-
});
|
|
185
|
-
previousEntryId = value.id;
|
|
186
|
-
}
|
|
187
|
-
const parsedEntry = parseManifestEntry(value, limits, index);
|
|
188
|
-
if ("code" in parsedEntry) entryRejections.push(parsedEntry);
|
|
189
|
-
else entries.push(parsedEntry);
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
entryRejections,
|
|
193
|
-
kind: "parsed",
|
|
194
|
-
manifest: {
|
|
195
|
-
entries,
|
|
196
|
-
hashAlgorithm: CLIENT_REUSE_MANIFEST_HASH_ALGORITHM,
|
|
197
|
-
replayWindow,
|
|
198
|
-
schemaVersion: 1,
|
|
199
|
-
visibleCommitVersion
|
|
200
|
-
},
|
|
201
|
-
skipDisposition: {
|
|
202
|
-
code: "SKIP_MODEL_DISABLED",
|
|
203
|
-
enabled: false,
|
|
204
|
-
mode: "renderAndSend"
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
//#endregion
|
|
209
|
-
export { CLIENT_REUSE_MANIFEST_HASH_ALGORITHM, CLIENT_REUSE_MANIFEST_SCHEMA_VERSION, CLIENT_REUSE_MANIFEST_SKIP_VERIFICATION_ENTRY_BUDGET, DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS, countUtf8Bytes, createClientReuseManifest, createClientReusePayloadHash, parseClientReuseManifestHeader, serializeClientReuseManifest };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { ArtifactCompatibilityEnvelope, ArtifactCompatibilityEvaluationOptions } from "./artifact-compatibility.js";
|
|
2
|
-
import { StaticLayoutArtifactReuseDecision } from "./cache-proof.js";
|
|
3
|
-
import { ClientReuseManifestEntry, ClientReuseManifestEntryRejection, ClientReuseManifestParseResult, ClientReuseManifestRejection, ClientReuseManifestSkipDisposition, ClientReuseManifestTraceFields } from "./client-reuse-manifest.js";
|
|
4
|
-
import { createStaticLayoutClientReuseArtifactCompatibility, createStaticLayoutClientReusePayloadHash, createStaticLayoutClientReuseRouteId } from "./static-layout-client-reuse-proof.js";
|
|
5
|
-
//#region src/server/skip-cache-proof.d.ts
|
|
6
|
-
export type SkipCacheInvalidationProof = Readonly<{
|
|
7
|
-
kind: "invalidated";
|
|
8
|
-
invalidationEpoch: string | null;
|
|
9
|
-
}> | Readonly<{
|
|
10
|
-
kind: "unknown";
|
|
11
|
-
}> | Readonly<{
|
|
12
|
-
kind: "valid";
|
|
13
|
-
}>;
|
|
14
|
-
type SkipCacheArtifactProof = Readonly<{
|
|
15
|
-
compatibility: ArtifactCompatibilityEnvelope;
|
|
16
|
-
invalidation: SkipCacheInvalidationProof;
|
|
17
|
-
payloadHash: string | null;
|
|
18
|
-
}>;
|
|
19
|
-
type SkipCacheCrossCheckAcceptanceCode = "SKIP_CACHE_CROSS_CHECK_PASSED";
|
|
20
|
-
type SkipCacheCrossCheckVerified = Readonly<{
|
|
21
|
-
code: SkipCacheCrossCheckAcceptanceCode;
|
|
22
|
-
entryId: string;
|
|
23
|
-
fields: ClientReuseManifestTraceFields;
|
|
24
|
-
kind: "verified";
|
|
25
|
-
skipDisposition: ClientReuseManifestSkipDisposition;
|
|
26
|
-
}>;
|
|
27
|
-
type SkipCacheCrossCheckRejected = Readonly<{
|
|
28
|
-
kind: "rejected";
|
|
29
|
-
rejection: ClientReuseManifestEntryRejection;
|
|
30
|
-
skipDisposition: ClientReuseManifestSkipDisposition;
|
|
31
|
-
}>;
|
|
32
|
-
type SkipCacheCrossCheckResult = SkipCacheCrossCheckRejected | SkipCacheCrossCheckVerified;
|
|
33
|
-
type CrossCheckClientReuseManifestEntryWithCacheInput = Readonly<{
|
|
34
|
-
artifact: SkipCacheArtifactProof;
|
|
35
|
-
cacheDecision: StaticLayoutArtifactReuseDecision | null;
|
|
36
|
-
entry: ClientReuseManifestEntry;
|
|
37
|
-
}> & ArtifactCompatibilityEvaluationOptions;
|
|
38
|
-
type ClientReuseSkipTransportPlan = Readonly<{
|
|
39
|
-
entryRejections: readonly ClientReuseManifestEntryRejection[];
|
|
40
|
-
kind: "renderAndSend";
|
|
41
|
-
manifestRejection?: ClientReuseManifestRejection;
|
|
42
|
-
skipDisposition: ClientReuseManifestSkipDisposition;
|
|
43
|
-
skipIneligibleEntryIds: readonly string[];
|
|
44
|
-
skippedEntryIds: readonly string[];
|
|
45
|
-
}> | Readonly<{
|
|
46
|
-
entryRejections: readonly ClientReuseManifestEntryRejection[];
|
|
47
|
-
kind: "skip";
|
|
48
|
-
skipDisposition: ClientReuseManifestSkipDisposition;
|
|
49
|
-
skipIneligibleEntryIds: readonly string[];
|
|
50
|
-
skippedEntryIds: readonly string[];
|
|
51
|
-
}>;
|
|
52
|
-
type CreateClientReuseSkipTransportPlanInput = Readonly<{
|
|
53
|
-
manifest: ClientReuseManifestParseResult;
|
|
54
|
-
maxWireEntriesToVerify?: number;
|
|
55
|
-
verifyEntry: (entry: ClientReuseManifestEntry) => SkipCacheCrossCheckResult;
|
|
56
|
-
}>;
|
|
57
|
-
export declare function crossCheckClientReuseManifestEntryWithCache(input: CrossCheckClientReuseManifestEntryWithCacheInput): SkipCacheCrossCheckResult;
|
|
58
|
-
export declare function createClientReuseSkipTransportPlan(input: CreateClientReuseSkipTransportPlanInput): ClientReuseSkipTransportPlan;
|
|
59
|
-
//#endregion
|
|
60
|
-
export { createStaticLayoutClientReuseArtifactCompatibility, createStaticLayoutClientReusePayloadHash, createStaticLayoutClientReuseRouteId };
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { ARTIFACT_COMPATIBILITY_PROOF_FIELDS, evaluateArtifactCompatibility } from "./artifact-compatibility.js";
|
|
2
|
-
import { createClientReusePayloadHash } from "./client-reuse-manifest.js";
|
|
3
|
-
import { createStaticLayoutClientReuseArtifactCompatibility, createStaticLayoutClientReusePayloadHash, createStaticLayoutClientReuseRouteId } from "./static-layout-client-reuse-proof.js";
|
|
4
|
-
//#region src/server/skip-cache-proof.ts
|
|
5
|
-
function createDisabledSkipDisposition() {
|
|
6
|
-
return {
|
|
7
|
-
code: "SKIP_MODEL_DISABLED",
|
|
8
|
-
enabled: false,
|
|
9
|
-
mode: "renderAndSend"
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function createStaticLayoutSkipDisposition(skippedEntryIds) {
|
|
13
|
-
return {
|
|
14
|
-
code: "SKIP_STATIC_LAYOUT_VERIFIED",
|
|
15
|
-
enabled: true,
|
|
16
|
-
mode: "skipStaticLayout",
|
|
17
|
-
skippedEntryIds: [...skippedEntryIds]
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function rejectSkipCacheCrossCheck(entry, code, fields = {}) {
|
|
21
|
-
return {
|
|
22
|
-
kind: "rejected",
|
|
23
|
-
rejection: {
|
|
24
|
-
code,
|
|
25
|
-
entryId: entry.id,
|
|
26
|
-
fields
|
|
27
|
-
},
|
|
28
|
-
skipDisposition: createDisabledSkipDisposition()
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function collectArtifactCompatibilityProofMismatches(artifactCompatibility, proofCompatibility) {
|
|
32
|
-
const mismatchedFields = [];
|
|
33
|
-
for (const field of ARTIFACT_COMPATIBILITY_PROOF_FIELDS) if (artifactCompatibility[field] !== proofCompatibility[field]) mismatchedFields.push(field);
|
|
34
|
-
return mismatchedFields;
|
|
35
|
-
}
|
|
36
|
-
function isExactArtifactCompatibility(artifactCompatibility, entryCompatibility) {
|
|
37
|
-
return collectArtifactCompatibilityProofMismatches(artifactCompatibility, entryCompatibility).length === 0;
|
|
38
|
-
}
|
|
39
|
-
function assertNever(value) {
|
|
40
|
-
throw new Error(`Unhandled skip/cache proof state: ${String(value)}`);
|
|
41
|
-
}
|
|
42
|
-
function createRenderAndSendPlan(options) {
|
|
43
|
-
return {
|
|
44
|
-
kind: "renderAndSend",
|
|
45
|
-
entryRejections: options.entryRejections ?? [],
|
|
46
|
-
...options.manifestRejection ? { manifestRejection: options.manifestRejection } : {},
|
|
47
|
-
skipDisposition: createDisabledSkipDisposition(),
|
|
48
|
-
skipIneligibleEntryIds: options.skipIneligibleEntryIds ?? [],
|
|
49
|
-
skippedEntryIds: []
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function createVerificationBudgetExceededRejection(totalWireEntries, maxWireEntriesToVerify) {
|
|
53
|
-
return {
|
|
54
|
-
code: "SKIP_VERIFICATION_BUDGET_EXCEEDED",
|
|
55
|
-
fields: {
|
|
56
|
-
totalWireEntries,
|
|
57
|
-
maxWireEntriesToVerify
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function crossCheckInvalidationProof(entry, invalidation) {
|
|
62
|
-
switch (invalidation.kind) {
|
|
63
|
-
case "valid": return null;
|
|
64
|
-
case "unknown": return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_INVALIDATION_UNKNOWN");
|
|
65
|
-
case "invalidated": return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_INVALIDATED", { invalidationEpoch: invalidation.invalidationEpoch });
|
|
66
|
-
default: return assertNever(invalidation);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function crossCheckClientReuseManifestEntryWithCache(input) {
|
|
70
|
-
const { cacheDecision, entry } = input;
|
|
71
|
-
if (cacheDecision === null) return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_PROOF_MISSING");
|
|
72
|
-
if (cacheDecision.kind === "fallback") return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_PROOF_REJECTED", {
|
|
73
|
-
cacheProofCode: cacheDecision.fallback.code,
|
|
74
|
-
cacheProofMode: cacheDecision.fallback.mode,
|
|
75
|
-
cacheProofScope: cacheDecision.fallback.scope
|
|
76
|
-
});
|
|
77
|
-
const { proof } = cacheDecision;
|
|
78
|
-
if (entry.kind !== "layout" || proof.reuseClass !== "static-layout") return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_REUSE_CLASS_UNSUPPORTED", {
|
|
79
|
-
entryKind: entry.kind,
|
|
80
|
-
reuseClass: proof.reuseClass
|
|
81
|
-
});
|
|
82
|
-
if (entry.id !== proof.candidateOutput.layoutId) return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_ENTRY_ID_MISMATCH", {
|
|
83
|
-
cacheEntryId: proof.candidateOutput.layoutId,
|
|
84
|
-
manifestEntryId: entry.id
|
|
85
|
-
});
|
|
86
|
-
const artifactProofMismatches = collectArtifactCompatibilityProofMismatches(input.artifact.compatibility, proof.candidateArtifactCompatibility);
|
|
87
|
-
if (artifactProofMismatches.length > 0) return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_ARTIFACT_PROOF_MISMATCH", { mismatchedFields: artifactProofMismatches });
|
|
88
|
-
const artifactCompatibility = evaluateArtifactCompatibility(input.artifact.compatibility, entry.artifactCompatibility, { compatibilityMap: input.compatibilityMap });
|
|
89
|
-
if (artifactCompatibility.kind === "unknown") return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_ARTIFACT_COMPATIBILITY_UNKNOWN", {
|
|
90
|
-
compatibilityFallback: artifactCompatibility.fallback,
|
|
91
|
-
reason: artifactCompatibility.reason
|
|
92
|
-
});
|
|
93
|
-
if (artifactCompatibility.kind === "incompatible") return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_ARTIFACT_COMPATIBILITY_INCOMPATIBLE", {
|
|
94
|
-
compatibilityFallback: artifactCompatibility.fallback,
|
|
95
|
-
reason: artifactCompatibility.reason
|
|
96
|
-
});
|
|
97
|
-
if (entry.variantCacheKey !== proof.variant.cacheKey) return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_VARIANT_MISMATCH", {
|
|
98
|
-
cacheVariantCacheKeyHash: createClientReusePayloadHash(proof.variant.cacheKey),
|
|
99
|
-
entryVariantCacheKeyHash: createClientReusePayloadHash(entry.variantCacheKey)
|
|
100
|
-
});
|
|
101
|
-
if (input.artifact.payloadHash === null) return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_PAYLOAD_HASH_MISSING");
|
|
102
|
-
if (entry.payloadHash !== input.artifact.payloadHash) return rejectSkipCacheCrossCheck(entry, "SKIP_CACHE_PAYLOAD_HASH_MISMATCH", {
|
|
103
|
-
cachePayloadHash: input.artifact.payloadHash,
|
|
104
|
-
entryPayloadHash: entry.payloadHash
|
|
105
|
-
});
|
|
106
|
-
const invalidationRejection = crossCheckInvalidationProof(entry, input.artifact.invalidation);
|
|
107
|
-
if (invalidationRejection) return invalidationRejection;
|
|
108
|
-
const skipDisposition = isExactArtifactCompatibility(input.artifact.compatibility, entry.artifactCompatibility) ? createStaticLayoutSkipDisposition([entry.id]) : createDisabledSkipDisposition();
|
|
109
|
-
return {
|
|
110
|
-
kind: "verified",
|
|
111
|
-
code: "SKIP_CACHE_CROSS_CHECK_PASSED",
|
|
112
|
-
entryId: entry.id,
|
|
113
|
-
fields: {
|
|
114
|
-
entryKind: entry.kind,
|
|
115
|
-
reuseClass: proof.reuseClass,
|
|
116
|
-
variantCacheKeyHash: createClientReusePayloadHash(proof.variant.cacheKey)
|
|
117
|
-
},
|
|
118
|
-
skipDisposition
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function createClientReuseSkipTransportPlan(input) {
|
|
122
|
-
const { manifest } = input;
|
|
123
|
-
if (manifest.kind === "absent") return createRenderAndSendPlan({});
|
|
124
|
-
if (manifest.kind === "rejected") return createRenderAndSendPlan({ manifestRejection: manifest.rejection });
|
|
125
|
-
const maxWireEntriesToVerify = input.maxWireEntriesToVerify ?? 8;
|
|
126
|
-
if (!Number.isSafeInteger(maxWireEntriesToVerify) || maxWireEntriesToVerify < 0) throw new RangeError("maxWireEntriesToVerify must be a non-negative safe integer");
|
|
127
|
-
const totalWireEntries = manifest.manifest.entries.length + manifest.entryRejections.length;
|
|
128
|
-
if (totalWireEntries > maxWireEntriesToVerify) return createRenderAndSendPlan({
|
|
129
|
-
entryRejections: manifest.entryRejections,
|
|
130
|
-
manifestRejection: createVerificationBudgetExceededRejection(totalWireEntries, maxWireEntriesToVerify)
|
|
131
|
-
});
|
|
132
|
-
const skippedEntryIds = [];
|
|
133
|
-
const skipIneligibleEntryIds = [];
|
|
134
|
-
const entryRejections = [...manifest.entryRejections];
|
|
135
|
-
for (const entry of manifest.manifest.entries) {
|
|
136
|
-
const verification = input.verifyEntry(entry);
|
|
137
|
-
if (verification.kind === "rejected") {
|
|
138
|
-
entryRejections.push(verification.rejection);
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (verification.entryId !== entry.id) {
|
|
142
|
-
entryRejections.push({
|
|
143
|
-
code: "SKIP_CACHE_ENTRY_ID_MISMATCH",
|
|
144
|
-
entryId: entry.id,
|
|
145
|
-
fields: {
|
|
146
|
-
verifierEntryId: verification.entryId,
|
|
147
|
-
manifestEntryId: entry.id
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
if (verification.skipDisposition.enabled) skippedEntryIds.push(entry.id);
|
|
153
|
-
else skipIneligibleEntryIds.push(entry.id);
|
|
154
|
-
}
|
|
155
|
-
if (skippedEntryIds.length === 0) return createRenderAndSendPlan({
|
|
156
|
-
entryRejections,
|
|
157
|
-
skipIneligibleEntryIds
|
|
158
|
-
});
|
|
159
|
-
return {
|
|
160
|
-
kind: "skip",
|
|
161
|
-
entryRejections,
|
|
162
|
-
skipDisposition: createStaticLayoutSkipDisposition(skippedEntryIds),
|
|
163
|
-
skipIneligibleEntryIds,
|
|
164
|
-
skippedEntryIds
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
//#endregion
|
|
168
|
-
export { createClientReuseSkipTransportPlan, createStaticLayoutClientReuseArtifactCompatibility, createStaticLayoutClientReusePayloadHash, createStaticLayoutClientReuseRouteId, crossCheckClientReuseManifestEntryWithCache };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ArtifactCompatibilityEnvelope } from "./artifact-compatibility.js";
|
|
2
|
-
//#region src/server/static-layout-client-reuse-proof.d.ts
|
|
3
|
-
type StaticLayoutClientReuseProofInput = Readonly<{
|
|
4
|
-
artifactCompatibility: ArtifactCompatibilityEnvelope;
|
|
5
|
-
layoutId: string;
|
|
6
|
-
rootBoundaryId: string | null;
|
|
7
|
-
routeId: string;
|
|
8
|
-
variantCacheKey: string;
|
|
9
|
-
}>;
|
|
10
|
-
export declare function createStaticLayoutClientReuseRouteId(layoutId: string): string;
|
|
11
|
-
export declare function createStaticLayoutClientReusePayloadHash(input: StaticLayoutClientReuseProofInput): string;
|
|
12
|
-
export declare function createStaticLayoutClientReuseArtifactCompatibility(input: StaticLayoutClientReuseProofInput): ArtifactCompatibilityEnvelope;
|
|
13
|
-
//#endregion
|
|
14
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ARTIFACT_COMPATIBILITY_PROOF_FIELDS } from "./artifact-compatibility.js";
|
|
2
|
-
import { createClientReusePayloadHash } from "./client-reuse-manifest.js";
|
|
3
|
-
//#region src/server/static-layout-client-reuse-proof.ts
|
|
4
|
-
function createStaticLayoutClientReuseRouteId(layoutId) {
|
|
5
|
-
return `static-layout:${createClientReusePayloadHash(layoutId)}`;
|
|
6
|
-
}
|
|
7
|
-
function createCanonicalProofPairs(input) {
|
|
8
|
-
return ARTIFACT_COMPATIBILITY_PROOF_FIELDS.map((field) => [field, input.artifactCompatibility[field]]);
|
|
9
|
-
}
|
|
10
|
-
function createStaticLayoutClientReusePayloadHash(input) {
|
|
11
|
-
return createClientReusePayloadHash(JSON.stringify({
|
|
12
|
-
artifactCompatibilityPairs: createCanonicalProofPairs(input),
|
|
13
|
-
layoutId: input.layoutId,
|
|
14
|
-
rootBoundaryId: input.rootBoundaryId,
|
|
15
|
-
variantCacheKey: input.variantCacheKey
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
function createStaticLayoutClientReuseArtifactCompatibility(input) {
|
|
19
|
-
return {
|
|
20
|
-
...input.artifactCompatibility,
|
|
21
|
-
graphVersion: `static-layout-graph:${createClientReusePayloadHash(JSON.stringify({
|
|
22
|
-
layoutId: input.layoutId,
|
|
23
|
-
rootBoundaryId: input.rootBoundaryId
|
|
24
|
-
}))}`,
|
|
25
|
-
renderEpoch: `static-layout:${createClientReusePayloadHash(JSON.stringify({
|
|
26
|
-
layoutId: input.layoutId,
|
|
27
|
-
rootBoundaryId: input.rootBoundaryId,
|
|
28
|
-
variantCacheKey: input.variantCacheKey
|
|
29
|
-
}))}`
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { createStaticLayoutClientReuseArtifactCompatibility, createStaticLayoutClientReusePayloadHash, createStaticLayoutClientReuseRouteId };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region src/utils/sorted-array.d.ts
|
|
2
|
-
type SortedStringPosition = Readonly<{
|
|
3
|
-
found: boolean;
|
|
4
|
-
index: number;
|
|
5
|
-
}>;
|
|
6
|
-
export declare function findSortedStringPosition(values: readonly string[], candidate: string): SortedStringPosition;
|
|
7
|
-
//#endregion
|
|
8
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//#region src/utils/sorted-array.ts
|
|
2
|
-
function findSortedStringPosition(values, candidate) {
|
|
3
|
-
let lower = 0;
|
|
4
|
-
let upper = values.length;
|
|
5
|
-
while (lower < upper) {
|
|
6
|
-
const middle = lower + Math.floor((upper - lower) / 2);
|
|
7
|
-
if (values[middle] === candidate) return {
|
|
8
|
-
found: true,
|
|
9
|
-
index: middle
|
|
10
|
-
};
|
|
11
|
-
if (values[middle] < candidate) lower = middle + 1;
|
|
12
|
-
else upper = middle;
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
found: false,
|
|
16
|
-
index: lower
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { findSortedStringPosition };
|