vinext 0.0.51 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/precompress.d.ts +7 -7
- package/dist/build/precompress.js +18 -17
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +3 -14
- package/dist/build/prerender.js +40 -40
- package/dist/build/prerender.js.map +1 -1
- package/dist/check.js +4 -0
- package/dist/check.js.map +1 -1
- package/dist/cli-args.d.ts +1 -0
- package/dist/cli-args.js +5 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli.js +39 -0
- package/dist/cli.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +47 -0
- package/dist/client/navigation-runtime.js +156 -0
- package/dist/client/navigation-runtime.js.map +1 -0
- package/dist/client/pages-router-link-navigation.d.ts +26 -0
- package/dist/client/pages-router-link-navigation.js +14 -0
- package/dist/client/pages-router-link-navigation.js.map +1 -0
- package/dist/client/vinext-next-data.d.ts +12 -2
- package/dist/client/vinext-next-data.js +50 -1
- package/dist/client/vinext-next-data.js.map +1 -0
- package/dist/cloudflare/kv-cache-handler.js +2 -1
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/config/config-matchers.d.ts +63 -16
- package/dist/config/config-matchers.js +143 -8
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.d.ts +20 -2
- package/dist/config/next-config.js +11 -1
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +101 -39
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.js +9 -3
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.js +53 -13
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +1 -0
- package/dist/entries/app-rsc-manifest.js +53 -6
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +3 -3
- package/dist/entries/app-ssr-entry.js +4 -4
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.js +18 -2
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +58 -8
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +2 -1
- package/dist/entries/runtime-entry-module.js +9 -3
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +132 -40
- package/dist/index.js.map +1 -1
- package/dist/plugins/css-data-url.d.ts +7 -0
- package/dist/plugins/css-data-url.js +81 -0
- package/dist/plugins/css-data-url.js.map +1 -0
- package/dist/plugins/fonts.js +5 -3
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/middleware-server-only.d.ts +54 -0
- package/dist/plugins/middleware-server-only.js +91 -0
- package/dist/plugins/middleware-server-only.js.map +1 -0
- package/dist/plugins/optimize-imports.js +4 -4
- package/dist/plugins/optimize-imports.js.map +1 -1
- package/dist/plugins/strip-server-exports.js +5 -8
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +20 -1
- package/dist/routing/app-route-graph.js +58 -6
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -2
- package/dist/routing/app-router.js +2 -2
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/utils.d.ts +2 -1
- package/dist/routing/utils.js +4 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +139 -37
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-entry.js +293 -149
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +32 -0
- package/dist/server/app-browser-interception-context.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +3 -1
- package/dist/server/app-browser-navigation-controller.js +5 -1
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.js +2 -2
- package/dist/server/app-browser-rsc-redirect.js.map +1 -1
- package/dist/server/app-browser-state.d.ts +18 -1
- package/dist/server/app-browser-state.js +19 -1
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +5 -14
- package/dist/server/app-browser-stream.js +13 -7
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +2 -1
- package/dist/server/app-browser-visible-commit.js +1 -0
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +10 -5
- package/dist/server/app-elements-wire.js +84 -2
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +3 -2
- package/dist/server/app-elements.js +3 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.js +5 -3
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-middleware.d.ts +13 -0
- package/dist/server/app-middleware.js +3 -1
- package/dist/server/app-middleware.js.map +1 -1
- package/dist/server/app-optimistic-routing.d.ts +54 -0
- package/dist/server/app-optimistic-routing.js +200 -0
- package/dist/server/app-optimistic-routing.js.map +1 -0
- package/dist/server/app-page-cache.d.ts +13 -1
- package/dist/server/app-page-cache.js +61 -6
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +2 -0
- package/dist/server/app-page-dispatch.js +28 -1
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.js +2 -1
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +28 -1
- package/dist/server/app-page-execution.js +89 -4
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.js +21 -2
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render.d.ts +2 -0
- package/dist/server/app-page-render.js +2 -1
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-response.js +4 -3
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.js +17 -10
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +3 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +44 -8
- package/dist/server/app-prerender-static-params.js.map +1 -1
- package/dist/server/app-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +3 -2
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +6 -1
- package/dist/server/app-route-handler-dispatch.js +1 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +17 -2
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +5 -4
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-router-entry.js +6 -2
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +9 -1
- package/dist/server/app-rsc-handler.js +32 -14
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +4 -3
- package/dist/server/app-rsc-render-mode.js +7 -1
- package/dist/server/app-rsc-render-mode.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +4 -1
- package/dist/server/app-rsc-request-normalization.js +4 -1
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +8 -1
- package/dist/server/app-rsc-response-finalizer.js +10 -3
- package/dist/server/app-rsc-response-finalizer.js.map +1 -1
- package/dist/server/app-rsc-route-matching.js +2 -2
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-server-action-execution.js +1 -1
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +56 -55
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +6 -1
- package/dist/server/app-ssr-stream.js +17 -3
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +1 -1
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-headers.d.ts +7 -0
- package/dist/server/cache-headers.js +19 -0
- package/dist/server/cache-headers.js.map +1 -0
- package/dist/server/cache-proof.d.ts +49 -3
- package/dist/server/cache-proof.js +78 -22
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/client-reuse-manifest.d.ts +99 -0
- package/dist/server/client-reuse-manifest.js +212 -0
- package/dist/server/client-reuse-manifest.js.map +1 -0
- package/dist/server/default-global-error-module.d.ts +20 -0
- package/dist/server/default-global-error-module.js +20 -0
- package/dist/server/default-global-error-module.js.map +1 -0
- package/dist/server/dev-server.d.ts +9 -1
- package/dist/server/dev-server.js +76 -29
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/edge-api-runtime.d.ts +5 -0
- package/dist/server/edge-api-runtime.js +8 -0
- package/dist/server/edge-api-runtime.js.map +1 -0
- package/dist/server/headers.d.ts +18 -1
- package/dist/server/headers.js +18 -1
- package/dist/server/headers.js.map +1 -1
- package/dist/server/http-error-responses.d.ts +16 -1
- package/dist/server/http-error-responses.js +21 -1
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/isr-cache.d.ts +6 -2
- package/dist/server/isr-cache.js +20 -4
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +15 -0
- package/dist/server/middleware-runtime.js +59 -7
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js +4 -2
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +9 -3
- package/dist/server/navigation-planner.js +98 -25
- package/dist/server/navigation-planner.js.map +1 -1
- package/dist/server/navigation-trace.d.ts +2 -1
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +27 -1
- package/dist/server/pages-api-route.js +24 -3
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-data-route.d.ts +77 -0
- package/dist/server/pages-data-route.js +97 -0
- package/dist/server/pages-data-route.js.map +1 -0
- package/dist/server/pages-i18n.d.ts +51 -1
- package/dist/server/pages-i18n.js +61 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +29 -2
- package/dist/server/pages-page-data.js +31 -17
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +11 -1
- package/dist/server/pages-page-response.js +5 -3
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prod-server.d.ts +13 -15
- package/dist/server/prod-server.js +109 -56
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +11 -2
- package/dist/server/request-pipeline.js +28 -11
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.d.ts +12 -31
- package/dist/server/seed-cache.js +22 -35
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.js +8 -3
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/skip-cache-proof.d.ts +41 -0
- package/dist/server/skip-cache-proof.js +101 -0
- package/dist/server/skip-cache-proof.js.map +1 -0
- package/dist/server/static-file-cache.d.ts +1 -1
- package/dist/server/static-file-cache.js +7 -6
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/client-locale.d.ts +15 -0
- package/dist/shims/client-locale.js +13 -0
- package/dist/shims/client-locale.js.map +1 -0
- package/dist/shims/default-global-error.d.ts +32 -0
- package/dist/shims/default-global-error.js +181 -0
- package/dist/shims/default-global-error.js.map +1 -0
- package/dist/shims/document.d.ts +59 -3
- package/dist/shims/document.js +36 -5
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +2 -2
- package/dist/shims/form.js +13 -6
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/link.d.ts +21 -3
- package/dist/shims/link.js +131 -22
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.js +4 -4
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +8 -2
- package/dist/shims/navigation.js +36 -15
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/og.d.ts +18 -2
- package/dist/shims/og.js +49 -1
- package/dist/shims/og.js.map +1 -0
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +11 -3
- package/dist/shims/root-params.js.map +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +12 -5
- package/dist/shims/router.js +172 -22
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/server.d.ts +21 -4
- package/dist/shims/server.js +29 -9
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.js +5 -1
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/url-safety.d.ts +23 -1
- package/dist/shims/url-safety.js +29 -2
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/typegen.d.ts +10 -0
- package/dist/typegen.js +242 -0
- package/dist/typegen.js.map +1 -0
- package/dist/utils/asset-prefix.d.ts +33 -5
- package/dist/utils/asset-prefix.js +39 -6
- package/dist/utils/asset-prefix.js.map +1 -1
- package/dist/utils/cache-control-metadata.d.ts +2 -1
- package/dist/utils/cache-control-metadata.js +1 -3
- package/dist/utils/cache-control-metadata.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +2 -1
- package/dist/utils/domain-locale.js +9 -1
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/prerender-output-paths.d.ts +15 -0
- package/dist/utils/prerender-output-paths.js +24 -0
- package/dist/utils/prerender-output-paths.js.map +1 -0
- package/dist/utils/query.d.ts +17 -1
- package/dist/utils/query.js +36 -1
- package/dist/utils/query.js.map +1 -1
- package/dist/utils/record.d.ts +5 -0
- package/dist/utils/record.js +8 -0
- package/dist/utils/record.js.map +1 -0
- package/package.json +11 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-reuse-manifest.js","names":[],"sources":["../../src/server/client-reuse-manifest.ts"],"sourcesContent":["import {\n parseArtifactCompatibilityEnvelope,\n type ArtifactCompatibilityEnvelope,\n} from \"./artifact-compatibility.js\";\nimport { AppElementsWire } from \"./app-elements-wire.js\";\nimport { fnv1a64 } from \"../utils/hash.js\";\nimport { isUnknownRecord } from \"../utils/record.js\";\n\nexport const CLIENT_REUSE_MANIFEST_SCHEMA_VERSION = 1;\nexport type ClientReuseManifestSchemaVersion = 1;\n\nexport const CLIENT_REUSE_MANIFEST_HASH_ALGORITHM = \"fnv1a64\";\nexport type ClientReuseManifestHashAlgorithm = typeof CLIENT_REUSE_MANIFEST_HASH_ALGORITHM;\n\ntype ClientReuseManifestLimits = Readonly<{\n maxEntryCount: number;\n maxEntryIdLength: number;\n maxManifestBytes: number;\n maxPayloadHashLength: number;\n maxVariantCacheKeyLength: number;\n}>;\n\nexport const DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS = {\n maxEntryCount: 64,\n maxEntryIdLength: 512,\n maxManifestBytes: 4096,\n maxPayloadHashLength: 16,\n maxVariantCacheKeyLength: 256,\n} satisfies ClientReuseManifestLimits;\n\nexport type ClientReuseManifestEntryKind = \"layout\" | \"page\" | \"route\" | \"slot\" | \"template\";\ntype ClientReuseManifestEntryPrivacy = \"private\" | \"public\";\n\nexport type ClientReuseManifestReplayWindow = Readonly<{\n validFromVisibleCommitVersion: number;\n validUntilVisibleCommitVersion: number;\n}>;\n\nexport type ClientReuseManifestEntry = Readonly<{\n artifactCompatibility: ArtifactCompatibilityEnvelope;\n id: string;\n kind: ClientReuseManifestEntryKind;\n payloadHash: string;\n privacy: \"public\";\n variantCacheKey: string;\n}>;\n\ntype ClientReuseManifestWireEntry = Readonly<{\n artifactCompatibility: ArtifactCompatibilityEnvelope;\n id: string;\n payloadHash: string;\n privacy: ClientReuseManifestEntryPrivacy;\n variantCacheKey: string;\n}>;\n\nexport type ClientReuseManifest = Readonly<{\n entries: readonly ClientReuseManifestEntry[];\n hashAlgorithm: ClientReuseManifestHashAlgorithm;\n replayWindow: ClientReuseManifestReplayWindow;\n schemaVersion: ClientReuseManifestSchemaVersion;\n visibleCommitVersion: number;\n}>;\n\n// Internal: createClientReuseManifest returns wire shape while parsing decides\n// which client-declared entries can participate in future reuse.\ntype ClientReuseManifestWire = Readonly<{\n entries: readonly ClientReuseManifestWireEntry[];\n hashAlgorithm: ClientReuseManifestHashAlgorithm;\n replayWindow: ClientReuseManifestReplayWindow;\n schemaVersion: ClientReuseManifestSchemaVersion;\n visibleCommitVersion: number;\n}>;\n\ntype CreateClientReuseManifestInput = Readonly<{\n entries: readonly ClientReuseManifestWireEntry[];\n replayWindow?: ClientReuseManifestReplayWindow;\n visibleCommitVersion: number;\n}>;\n\nexport type ClientReuseManifestRejectionCode =\n | \"SKIP_CACHE_ARTIFACT_COMPATIBILITY_INCOMPATIBLE\"\n | \"SKIP_CACHE_ARTIFACT_COMPATIBILITY_UNKNOWN\"\n | \"SKIP_CACHE_ARTIFACT_PROOF_MISMATCH\"\n | \"SKIP_CACHE_ENTRY_ID_MISMATCH\"\n | \"SKIP_CACHE_INVALIDATED\"\n | \"SKIP_CACHE_INVALIDATION_UNKNOWN\"\n | \"SKIP_CACHE_PAYLOAD_HASH_MISMATCH\"\n | \"SKIP_CACHE_PAYLOAD_HASH_MISSING\"\n | \"SKIP_CACHE_PROOF_MISSING\"\n | \"SKIP_CACHE_PROOF_REJECTED\"\n | \"SKIP_CACHE_REUSE_CLASS_UNSUPPORTED\"\n | \"SKIP_CACHE_VARIANT_MISMATCH\"\n | \"SKIP_ARTIFACT_COMPATIBILITY_INVALID\"\n | \"SKIP_ENTRY_COUNT_EXCEEDED\"\n | \"SKIP_ENTRY_HASH_INVALID\"\n | \"SKIP_ENTRY_ID_INVALID\"\n | \"SKIP_ENTRY_ID_TOO_LONG\"\n | \"SKIP_ENTRY_MALFORMED\"\n | \"SKIP_ENTRY_ORDER_NON_CANONICAL\"\n | \"SKIP_HASH_ALGORITHM_UNSUPPORTED\"\n | \"SKIP_MANIFEST_MALFORMED\"\n | \"SKIP_MANIFEST_SCHEMA_UNSUPPORTED\"\n | \"SKIP_MANIFEST_TOO_LARGE\"\n | \"SKIP_PRIVATE_ENTRY\"\n | \"SKIP_REPLAY_WINDOW_INVALID\"\n | \"SKIP_UNKNOWN_ENTRY\"\n | \"SKIP_VARIANT_CACHE_KEY_INVALID\"\n | \"SKIP_VARIANT_CACHE_KEY_TOO_LONG\"\n | \"SKIP_VISIBLE_COMMIT_VERSION_INVALID\"\n | \"SKIP_VISIBLE_COMMIT_VERSION_MISMATCH\";\n\nexport type ClientReuseManifestDispositionCode = \"SKIP_MODEL_DISABLED\";\n\nexport type ClientReuseManifestTraceFieldValue =\n | string\n | number\n | boolean\n | null\n | readonly string[];\n\nexport type ClientReuseManifestTraceFields = Readonly<\n Record<string, ClientReuseManifestTraceFieldValue>\n>;\n\nexport type ClientReuseManifestRejection = Readonly<{\n code: ClientReuseManifestRejectionCode;\n fields: ClientReuseManifestTraceFields;\n}>;\n\nexport type ClientReuseManifestEntryRejection = ClientReuseManifestRejection &\n Readonly<{\n entryId: string | null;\n }>;\n\nexport type ClientReuseManifestSkipDisposition = Readonly<{\n code: ClientReuseManifestDispositionCode;\n enabled: false;\n mode: \"renderAndSend\";\n}>;\n\nexport type ClientReuseManifestParseResult =\n | Readonly<{ kind: \"absent\" }>\n | Readonly<{ kind: \"rejected\"; rejection: ClientReuseManifestRejection }>\n | Readonly<{\n entryRejections: readonly ClientReuseManifestEntryRejection[];\n kind: \"parsed\";\n manifest: ClientReuseManifest;\n skipDisposition: ClientReuseManifestSkipDisposition;\n }>;\n\ntype ParseClientReuseManifestOptions = Readonly<{\n currentVisibleCommitVersion?: number;\n limits?: ClientReuseManifestLimits;\n}>;\n\nconst HASH_DIGEST_PATTERN = /^[0-9a-z]+$/;\nconst textEncoder = new TextEncoder();\n\ntype ParseReplayWindowResult =\n | Readonly<{ kind: \"parsed\"; replayWindow: ClientReuseManifestReplayWindow }>\n | Readonly<{ kind: \"rejected\"; rejection: ClientReuseManifestRejection }>;\n\nfunction createRejection(\n code: ClientReuseManifestRejectionCode,\n fields: ClientReuseManifestTraceFields = {},\n): ClientReuseManifestRejection {\n return { code, fields };\n}\n\nfunction rejectManifest(\n code: ClientReuseManifestRejectionCode,\n fields: ClientReuseManifestTraceFields = {},\n): ClientReuseManifestParseResult {\n return { kind: \"rejected\", rejection: createRejection(code, fields) };\n}\n\nfunction rejectEntry(\n code: ClientReuseManifestRejectionCode,\n entryId: string | null,\n fields: ClientReuseManifestTraceFields = {},\n): ClientReuseManifestEntryRejection {\n return { code, entryId, fields };\n}\n\nfunction compareManifestEntries(\n left: Pick<ClientReuseManifestWireEntry, \"id\">,\n right: Pick<ClientReuseManifestWireEntry, \"id\">,\n): number {\n if (left.id < right.id) return -1;\n if (left.id > right.id) return 1;\n return 0;\n}\n\nfunction createCanonicalWireEntries(\n entries: readonly ClientReuseManifestWireEntry[],\n): ClientReuseManifestWireEntry[] {\n const entriesById = new Map<string, ClientReuseManifestWireEntry>();\n for (const entry of entries) {\n if (!entriesById.has(entry.id)) {\n entriesById.set(entry.id, entry);\n }\n }\n\n return Array.from(entriesById.values()).sort(compareManifestEntries);\n}\n\n// The manifest byte budget is enforced once at the untrusted header boundary.\nfunction countUtf8Bytes(input: string): number {\n return textEncoder.encode(input).length;\n}\n\nfunction isVisibleCommitVersion(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0;\n}\n\nfunction parseReplayWindow(value: unknown, visibleCommitVersion: number): ParseReplayWindowResult {\n if (!isUnknownRecord(value)) {\n return {\n kind: \"rejected\",\n rejection: createRejection(\"SKIP_REPLAY_WINDOW_INVALID\", { field: \"replayWindow\" }),\n };\n }\n\n const validFromVisibleCommitVersion = value.validFromVisibleCommitVersion;\n const validUntilVisibleCommitVersion = value.validUntilVisibleCommitVersion;\n if (\n !isVisibleCommitVersion(validFromVisibleCommitVersion) ||\n !isVisibleCommitVersion(validUntilVisibleCommitVersion) ||\n validFromVisibleCommitVersion > validUntilVisibleCommitVersion ||\n visibleCommitVersion < validFromVisibleCommitVersion ||\n visibleCommitVersion > validUntilVisibleCommitVersion\n ) {\n return {\n kind: \"rejected\",\n rejection: createRejection(\"SKIP_REPLAY_WINDOW_INVALID\", {\n validFromVisibleCommitVersion: isVisibleCommitVersion(validFromVisibleCommitVersion)\n ? validFromVisibleCommitVersion\n : null,\n validUntilVisibleCommitVersion: isVisibleCommitVersion(validUntilVisibleCommitVersion)\n ? validUntilVisibleCommitVersion\n : null,\n visibleCommitVersion,\n }),\n };\n }\n\n return {\n kind: \"parsed\",\n replayWindow: {\n validFromVisibleCommitVersion,\n validUntilVisibleCommitVersion,\n },\n };\n}\n\nfunction currentCommitVersionMatchesReplayWindow(\n currentVisibleCommitVersion: number | undefined,\n replayWindow: ClientReuseManifestReplayWindow,\n): boolean {\n if (currentVisibleCommitVersion === undefined) return true;\n return (\n currentVisibleCommitVersion >= replayWindow.validFromVisibleCommitVersion &&\n currentVisibleCommitVersion <= replayWindow.validUntilVisibleCommitVersion\n );\n}\n\nfunction parseEntryKind(id: string): ClientReuseManifestEntryKind | null {\n const parsed = AppElementsWire.parseElementKey(id);\n if (parsed === null) return null;\n return parsed.kind;\n}\n\nfunction isValidPayloadHash(value: unknown, limits: ClientReuseManifestLimits): value is string {\n return (\n typeof value === \"string\" &&\n value.length > 0 &&\n value.length <= limits.maxPayloadHashLength &&\n HASH_DIGEST_PATTERN.test(value)\n );\n}\n\nfunction parseManifestEntry(\n value: unknown,\n limits: ClientReuseManifestLimits,\n index: number,\n): ClientReuseManifestEntry | ClientReuseManifestEntryRejection {\n if (!isUnknownRecord(value)) {\n return rejectEntry(\"SKIP_ENTRY_MALFORMED\", null, { index });\n }\n\n const id = value.id;\n if (typeof id !== \"string\" || id.length === 0) {\n return rejectEntry(\"SKIP_ENTRY_ID_INVALID\", null, { index });\n }\n if (id.length > limits.maxEntryIdLength) {\n return rejectEntry(\"SKIP_ENTRY_ID_TOO_LONG\", id, {\n idHash: createClientReusePayloadHash(id),\n maxEntryIdLength: limits.maxEntryIdLength,\n });\n }\n\n const kind = parseEntryKind(id);\n if (kind === null) {\n return rejectEntry(\"SKIP_UNKNOWN_ENTRY\", id, { idHash: createClientReusePayloadHash(id) });\n }\n\n const privacy = value.privacy;\n if (privacy === \"private\") {\n return rejectEntry(\"SKIP_PRIVATE_ENTRY\", id, { privacy });\n }\n if (privacy !== \"public\") {\n return rejectEntry(\"SKIP_ENTRY_MALFORMED\", id, { field: \"privacy\" });\n }\n\n const payloadHash = value.payloadHash;\n if (!isValidPayloadHash(payloadHash, limits)) {\n return rejectEntry(\"SKIP_ENTRY_HASH_INVALID\", id, {\n maxPayloadHashLength: limits.maxPayloadHashLength,\n });\n }\n\n const variantCacheKey = value.variantCacheKey;\n if (typeof variantCacheKey !== \"string\" || variantCacheKey.length === 0) {\n return rejectEntry(\"SKIP_VARIANT_CACHE_KEY_INVALID\", id, { field: \"variantCacheKey\" });\n }\n if (variantCacheKey.length > limits.maxVariantCacheKeyLength) {\n return rejectEntry(\"SKIP_VARIANT_CACHE_KEY_TOO_LONG\", id, {\n maxVariantCacheKeyLength: limits.maxVariantCacheKeyLength,\n variantCacheKeyHash: createClientReusePayloadHash(variantCacheKey),\n });\n }\n\n const artifactCompatibility = parseArtifactCompatibilityEnvelope(value.artifactCompatibility);\n if (artifactCompatibility === null) {\n return rejectEntry(\"SKIP_ARTIFACT_COMPATIBILITY_INVALID\", id, {\n field: \"artifactCompatibility\",\n });\n }\n\n return {\n artifactCompatibility,\n id,\n kind,\n payloadHash,\n privacy,\n variantCacheKey,\n };\n}\n\nexport function createClientReusePayloadHash(input: string): string {\n return fnv1a64(input);\n}\n\nexport function createClientReuseManifest(\n input: CreateClientReuseManifestInput,\n): ClientReuseManifestWire {\n const replayWindow =\n input.replayWindow ??\n ({\n validFromVisibleCommitVersion: input.visibleCommitVersion,\n validUntilVisibleCommitVersion: input.visibleCommitVersion,\n } satisfies ClientReuseManifestReplayWindow);\n\n return {\n entries: createCanonicalWireEntries(input.entries),\n hashAlgorithm: CLIENT_REUSE_MANIFEST_HASH_ALGORITHM,\n replayWindow,\n schemaVersion: CLIENT_REUSE_MANIFEST_SCHEMA_VERSION,\n visibleCommitVersion: input.visibleCommitVersion,\n };\n}\n\nexport function serializeClientReuseManifest(input: CreateClientReuseManifestInput): string {\n return JSON.stringify(createClientReuseManifest(input));\n}\n\nexport function parseClientReuseManifestHeader(\n rawHeader: string | null | undefined,\n options: ParseClientReuseManifestOptions = {},\n): ClientReuseManifestParseResult {\n const header = rawHeader?.trim();\n if (!header) return { kind: \"absent\" };\n\n const limits = options.limits ?? DEFAULT_CLIENT_REUSE_MANIFEST_LIMITS;\n const manifestBytes = countUtf8Bytes(header);\n if (manifestBytes > limits.maxManifestBytes) {\n return rejectManifest(\"SKIP_MANIFEST_TOO_LARGE\", {\n manifestBytes,\n maxManifestBytes: limits.maxManifestBytes,\n });\n }\n\n let decoded: unknown;\n try {\n decoded = JSON.parse(header);\n } catch {\n return rejectManifest(\"SKIP_MANIFEST_MALFORMED\");\n }\n\n if (!isUnknownRecord(decoded)) {\n return rejectManifest(\"SKIP_MANIFEST_MALFORMED\", { field: \"manifest\" });\n }\n\n if (decoded.schemaVersion !== CLIENT_REUSE_MANIFEST_SCHEMA_VERSION) {\n return rejectManifest(\"SKIP_MANIFEST_SCHEMA_UNSUPPORTED\", {\n schemaVersion:\n typeof decoded.schemaVersion === \"number\" || typeof decoded.schemaVersion === \"string\"\n ? decoded.schemaVersion\n : null,\n });\n }\n\n if (decoded.hashAlgorithm !== CLIENT_REUSE_MANIFEST_HASH_ALGORITHM) {\n return rejectManifest(\"SKIP_HASH_ALGORITHM_UNSUPPORTED\", {\n hashAlgorithm: typeof decoded.hashAlgorithm === \"string\" ? decoded.hashAlgorithm : null,\n });\n }\n\n const visibleCommitVersion = decoded.visibleCommitVersion;\n if (!isVisibleCommitVersion(visibleCommitVersion)) {\n return rejectManifest(\"SKIP_VISIBLE_COMMIT_VERSION_INVALID\", {\n visibleCommitVersion: null,\n });\n }\n\n const replayWindowResult = parseReplayWindow(decoded.replayWindow, visibleCommitVersion);\n if (replayWindowResult.kind === \"rejected\") {\n return { kind: \"rejected\", rejection: replayWindowResult.rejection };\n }\n const { replayWindow } = replayWindowResult;\n if (!currentCommitVersionMatchesReplayWindow(options.currentVisibleCommitVersion, replayWindow)) {\n return rejectManifest(\"SKIP_VISIBLE_COMMIT_VERSION_MISMATCH\", {\n currentVisibleCommitVersion: options.currentVisibleCommitVersion ?? null,\n validFromVisibleCommitVersion: replayWindow.validFromVisibleCommitVersion,\n validUntilVisibleCommitVersion: replayWindow.validUntilVisibleCommitVersion,\n visibleCommitVersion,\n });\n }\n\n const entriesValue = decoded.entries;\n if (!Array.isArray(entriesValue)) {\n return rejectManifest(\"SKIP_MANIFEST_MALFORMED\", { field: \"entries\" });\n }\n if (entriesValue.length > limits.maxEntryCount) {\n return rejectManifest(\"SKIP_ENTRY_COUNT_EXCEEDED\", {\n entryCount: entriesValue.length,\n maxEntryCount: limits.maxEntryCount,\n });\n }\n\n const entries: ClientReuseManifestEntry[] = [];\n const entryRejections: ClientReuseManifestEntryRejection[] = [];\n let previousEntryId: string | null = null;\n\n for (let index = 0; index < entriesValue.length; index++) {\n const value = entriesValue[index];\n if (isUnknownRecord(value) && typeof value.id === \"string\") {\n // Canonical ordering is enforced over entries with string IDs. Malformed\n // entries cannot advance previousEntryId, so interleaving them cannot hide\n // an ordering violation between valid checkpoints. <= rejects both\n // out-of-order and duplicate IDs.\n if (previousEntryId !== null && value.id <= previousEntryId) {\n return rejectManifest(\"SKIP_ENTRY_ORDER_NON_CANONICAL\", {\n entryIdHash: createClientReusePayloadHash(value.id),\n previousEntryIdHash: createClientReusePayloadHash(previousEntryId),\n });\n }\n previousEntryId = value.id;\n }\n\n const parsedEntry = parseManifestEntry(value, limits, index);\n if (\"code\" in parsedEntry) {\n entryRejections.push(parsedEntry);\n } else {\n entries.push(parsedEntry);\n }\n }\n\n return {\n entryRejections,\n kind: \"parsed\",\n manifest: {\n entries,\n hashAlgorithm: CLIENT_REUSE_MANIFEST_HASH_ALGORITHM,\n replayWindow,\n schemaVersion: CLIENT_REUSE_MANIFEST_SCHEMA_VERSION,\n visibleCommitVersion,\n },\n skipDisposition: {\n code: \"SKIP_MODEL_DISABLED\",\n enabled: false,\n mode: \"renderAndSend\",\n },\n };\n}\n"],"mappings":";;;;;AAQA,MAAa,uCAAuC;AAGpD,MAAa,uCAAuC;AAWpD,MAAa,uCAAuC;CAClD,eAAe;CACf,kBAAkB;CAClB,kBAAkB;CAClB,sBAAsB;CACtB,0BAA0B;CAC3B;AA+HD,MAAM,sBAAsB;AAC5B,MAAM,cAAc,IAAI,aAAa;AAMrC,SAAS,gBACP,MACA,SAAyC,EAAE,EACb;CAC9B,OAAO;EAAE;EAAM;EAAQ;;AAGzB,SAAS,eACP,MACA,SAAyC,EAAE,EACX;CAChC,OAAO;EAAE,MAAM;EAAY,WAAW,gBAAgB,MAAM,OAAO;EAAE;;AAGvE,SAAS,YACP,MACA,SACA,SAAyC,EAAE,EACR;CACnC,OAAO;EAAE;EAAM;EAAS;EAAQ;;AAGlC,SAAS,uBACP,MACA,OACQ;CACR,IAAI,KAAK,KAAK,MAAM,IAAI,OAAO;CAC/B,IAAI,KAAK,KAAK,MAAM,IAAI,OAAO;CAC/B,OAAO;;AAGT,SAAS,2BACP,SACgC;CAChC,MAAM,8BAAc,IAAI,KAA2C;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
|
|
4
|
+
* component. Used as the fallback when an app does not define its own
|
|
5
|
+
* `app/global-error.tsx`. The runtime treats any `{ default: Component }`
|
|
6
|
+
* record as a "global error module", so wrapping the component this way lets
|
|
7
|
+
* us thread the default through the existing `globalErrorModule` plumbing
|
|
8
|
+
* without introducing a parallel code path.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors Next.js's `defaultGlobalErrorPath`
|
|
11
|
+
* (`next/dist/client/components/builtin/global-error.js`), which is selected
|
|
12
|
+
* automatically when the user has not supplied a custom global error file:
|
|
13
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/build/webpack/loaders/next-app-loader/index.ts
|
|
14
|
+
*/
|
|
15
|
+
declare const DEFAULT_GLOBAL_ERROR_MODULE: {
|
|
16
|
+
readonly default: any;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { DEFAULT_GLOBAL_ERROR_MODULE };
|
|
20
|
+
//# sourceMappingURL=default-global-error-module.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import DefaultGlobalError from "../shims/default-global-error.js";
|
|
2
|
+
//#region src/server/default-global-error-module.ts
|
|
3
|
+
/**
|
|
4
|
+
* Module-shaped wrapper around vinext's built-in default global error
|
|
5
|
+
* component. Used as the fallback when an app does not define its own
|
|
6
|
+
* `app/global-error.tsx`. The runtime treats any `{ default: Component }`
|
|
7
|
+
* record as a "global error module", so wrapping the component this way lets
|
|
8
|
+
* us thread the default through the existing `globalErrorModule` plumbing
|
|
9
|
+
* without introducing a parallel code path.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors Next.js's `defaultGlobalErrorPath`
|
|
12
|
+
* (`next/dist/client/components/builtin/global-error.js`), which is selected
|
|
13
|
+
* automatically when the user has not supplied a custom global error file:
|
|
14
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/build/webpack/loaders/next-app-loader/index.ts
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_GLOBAL_ERROR_MODULE = { default: DefaultGlobalError };
|
|
17
|
+
//#endregion
|
|
18
|
+
export { DEFAULT_GLOBAL_ERROR_MODULE };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=default-global-error-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-global-error-module.js","names":[],"sources":["../../src/server/default-global-error-module.ts"],"sourcesContent":["import DefaultGlobalError from \"vinext/shims/default-global-error\";\n\n/**\n * Module-shaped wrapper around vinext's built-in default global error\n * component. Used as the fallback when an app does not define its own\n * `app/global-error.tsx`. The runtime treats any `{ default: Component }`\n * record as a \"global error module\", so wrapping the component this way lets\n * us thread the default through the existing `globalErrorModule` plumbing\n * without introducing a parallel code path.\n *\n * Mirrors Next.js's `defaultGlobalErrorPath`\n * (`next/dist/client/components/builtin/global-error.js`), which is selected\n * automatically when the user has not supplied a custom global error file:\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/build/webpack/loaders/next-app-loader/index.ts\n */\nexport const DEFAULT_GLOBAL_ERROR_MODULE = {\n default: DefaultGlobalError,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,8BAA8B,EACzC,SAAS,oBACV"}
|
|
@@ -38,7 +38,15 @@ declare function parseCookieLocale(req: IncomingMessage, i18nConfig: NextI18nCon
|
|
|
38
38
|
*/
|
|
39
39
|
declare function createSSRHandler(server: ViteDevServer, runner: ModuleImporter, routes: Route[], pagesDir: string, i18nConfig?: NextI18nConfig | null, fileMatcher?: ValidFileMatcher, basePath?: string, trailingSlash?: boolean): (req: IncomingMessage, res: ServerResponse, url: string, /** Status code override — propagated from middleware rewrite status. */
|
|
40
40
|
|
|
41
|
-
statusCode?: number
|
|
41
|
+
statusCode?: number,
|
|
42
|
+
/**
|
|
43
|
+
* True when the request originated as `/_next/data/<buildId>/<page>.json`.
|
|
44
|
+
* When true the handler emits a `{ pageProps }` JSON envelope instead of
|
|
45
|
+
* rendering the React tree to HTML — matching Next.js' behavior for
|
|
46
|
+
* client-side navigations in the Pages Router.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
isDataReq?: boolean) => Promise<void>;
|
|
42
50
|
//#endregion
|
|
43
51
|
export { createSSRHandler, detectLocaleFromHeaders, extractLocaleFromUrl, parseCookieLocale };
|
|
44
52
|
//# sourceMappingURL=dev-server.d.ts.map
|
|
@@ -2,14 +2,14 @@ import { createRequestContext, runWithRequestContext } from "../shims/unified-re
|
|
|
2
2
|
import { createValidFileMatcher, findFileWithExtensions } from "../routing/file-matcher.js";
|
|
3
3
|
import { patternToNextFormat } from "../routing/route-validation.js";
|
|
4
4
|
import { matchRoute } from "../routing/pages-router.js";
|
|
5
|
-
import {
|
|
5
|
+
import { mergeRouteParamsIntoQuery, parseQueryString } from "../utils/query.js";
|
|
6
6
|
import { normalizeStaticPathname } from "../routing/route-pattern.js";
|
|
7
7
|
import { importModule, reportRequestError } from "./instrumentation.js";
|
|
8
|
+
import { buildCacheStateHeaders } from "./cache-headers.js";
|
|
8
9
|
import { _runWithCacheState } from "../shims/cache.js";
|
|
9
10
|
import { buildPagesCacheValue, getRevalidateDuration, isrCacheKey, isrGet, isrSet, setRevalidateDuration, triggerBackgroundRegeneration } from "./isr-cache.js";
|
|
10
11
|
import { runWithPrivateCache } from "../shims/cache-runtime.js";
|
|
11
12
|
import { ensureFetchPatch, runWithFetchCache } from "../shims/fetch-cache.js";
|
|
12
|
-
import { mergeRouteParamsIntoQuery, parseQueryString } from "../utils/query.js";
|
|
13
13
|
import "../shims/router-state.js";
|
|
14
14
|
import { runWithHeadState } from "../shims/head-state.js";
|
|
15
15
|
import { runWithServerInsertedHTMLState } from "../shims/navigation-state.js";
|
|
@@ -136,7 +136,7 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
136
136
|
const matcher = fileMatcher ?? createValidFileMatcher();
|
|
137
137
|
const _alsRegistration = Promise.all([runner.import("vinext/head-state"), runner.import("vinext/router-state")]);
|
|
138
138
|
_alsRegistration.catch(() => {});
|
|
139
|
-
return async (req, res, url, statusCode) => {
|
|
139
|
+
return async (req, res, url, statusCode, isDataReq = false) => {
|
|
140
140
|
const _reqStart = now();
|
|
141
141
|
let _compileEnd;
|
|
142
142
|
let _renderEnd;
|
|
@@ -170,10 +170,16 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
170
170
|
}
|
|
171
171
|
const match = matchRoute(localeStrippedUrl, routes);
|
|
172
172
|
if (!match) {
|
|
173
|
+
if (isDataReq) {
|
|
174
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
175
|
+
res.end("{}");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
173
178
|
await renderErrorPage(server, runner, req, res, url, pagesDir, 404, void 0, matcher);
|
|
174
179
|
return;
|
|
175
180
|
}
|
|
176
181
|
const { route, params } = match;
|
|
182
|
+
const userFacingParams = route.isDynamic ? params : null;
|
|
177
183
|
const query = mergeRouteParamsIntoQuery(parseQueryString(url), params);
|
|
178
184
|
return runWithRequestContext(createRequestContext(), async () => {
|
|
179
185
|
ensureFetchPatch();
|
|
@@ -211,34 +217,53 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
211
217
|
}
|
|
212
218
|
let pageProps = {};
|
|
213
219
|
let isrRevalidateSeconds = null;
|
|
220
|
+
let isFallbackRender = false;
|
|
214
221
|
if (typeof pageModule.getStaticPaths === "function" && route.isDynamic) {
|
|
215
222
|
const pathsResult = await pageModule.getStaticPaths({
|
|
216
223
|
locales: i18nConfig?.locales ?? [],
|
|
217
224
|
defaultLocale: currentDefaultLocale ?? ""
|
|
218
225
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
226
|
+
const fallback = pathsResult?.fallback ?? false;
|
|
227
|
+
const paths = pathsResult?.paths ?? [];
|
|
228
|
+
const currentPathname = normalizeStaticPathname(url);
|
|
229
|
+
const isValidPath = paths.some((p) => {
|
|
230
|
+
if (typeof p === "string") return normalizeStaticPathname(p) === currentPathname;
|
|
231
|
+
const entryParams = p.params;
|
|
232
|
+
if (entryParams === void 0 || entryParams === null) return false;
|
|
233
|
+
return Object.entries(entryParams).every(([key, val]) => {
|
|
234
|
+
const actual = params[key];
|
|
235
|
+
if (Array.isArray(val)) return Array.isArray(actual) && val.join("/") === actual.join("/");
|
|
236
|
+
return String(val) === String(actual);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
if (fallback === false && !isValidPath) {
|
|
240
|
+
if (isDataReq) {
|
|
241
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
242
|
+
res.end("{}");
|
|
233
243
|
return;
|
|
234
244
|
}
|
|
245
|
+
await renderErrorPage(server, runner, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext, matcher);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (fallback === true && !isValidPath && !isDataReq) {
|
|
249
|
+
isFallbackRender = true;
|
|
250
|
+
if (typeof routerShim.setSSRContext === "function") routerShim.setSSRContext({
|
|
251
|
+
pathname: patternToNextFormat(route.pattern),
|
|
252
|
+
query,
|
|
253
|
+
asPath: url,
|
|
254
|
+
locale: locale ?? currentDefaultLocale,
|
|
255
|
+
locales: i18nConfig?.locales,
|
|
256
|
+
defaultLocale: currentDefaultLocale,
|
|
257
|
+
domainLocales,
|
|
258
|
+
isFallback: true
|
|
259
|
+
});
|
|
235
260
|
}
|
|
236
261
|
}
|
|
237
262
|
const gsspExtraHeaders = {};
|
|
238
|
-
if (typeof pageModule.getServerSideProps === "function") {
|
|
263
|
+
if (typeof pageModule.getServerSideProps === "function" && !isFallbackRender) {
|
|
239
264
|
const headersBeforeGSSP = new Set(Object.keys(res.getHeaders()));
|
|
240
265
|
const context = {
|
|
241
|
-
params,
|
|
266
|
+
params: userFacingParams,
|
|
242
267
|
req,
|
|
243
268
|
res,
|
|
244
269
|
query,
|
|
@@ -260,6 +285,11 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
260
285
|
return;
|
|
261
286
|
}
|
|
262
287
|
if (result && "notFound" in result && result.notFound) {
|
|
288
|
+
if (isDataReq) {
|
|
289
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
290
|
+
res.end("{}");
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
263
293
|
await renderErrorPage(server, runner, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);
|
|
264
294
|
return;
|
|
265
295
|
}
|
|
@@ -283,16 +313,16 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
283
313
|
if (typeof fontLocalEarly.getSSRFontPreloads === "function") earlyPreloads.push(...fontLocalEarly.getSSRFontPreloads());
|
|
284
314
|
if (earlyPreloads.length > 0) earlyFontLinkHeader = earlyPreloads.map((p) => `<${p.href}>; rel=preload; as=font; type=${p.type}; crossorigin`).join(", ");
|
|
285
315
|
} catch {}
|
|
286
|
-
if (typeof pageModule.getStaticProps === "function") {
|
|
316
|
+
if (typeof pageModule.getStaticProps === "function" && !isFallbackRender) {
|
|
287
317
|
const cacheKey = isrCacheKey("pages", url.split("?")[0], process.env.__VINEXT_BUILD_ID);
|
|
288
318
|
const cached = await isrGet(cacheKey);
|
|
289
|
-
if (cached && !cached.isStale && cached.value.value?.kind === "PAGES" && !scriptNonce) {
|
|
319
|
+
if (cached && !cached.isStale && cached.value.value?.kind === "PAGES" && !scriptNonce && !isDataReq) {
|
|
290
320
|
const cachedHtml = cached.value.value.html;
|
|
291
321
|
const transformedHtml = await server.transformIndexHtml(url, cachedHtml);
|
|
292
322
|
const revalidateSecs = getRevalidateDuration(cacheKey) ?? 60;
|
|
293
323
|
const hitHeaders = {
|
|
294
324
|
"Content-Type": "text/html",
|
|
295
|
-
|
|
325
|
+
...buildCacheStateHeaders("HIT"),
|
|
296
326
|
"Cache-Control": `s-maxage=${revalidateSecs}, stale-while-revalidate`
|
|
297
327
|
};
|
|
298
328
|
if (earlyFontLinkHeader) hitHeaders["Link"] = earlyFontLinkHeader;
|
|
@@ -300,14 +330,14 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
300
330
|
res.end(transformedHtml);
|
|
301
331
|
return;
|
|
302
332
|
}
|
|
303
|
-
if (cached && cached.isStale && cached.value.value?.kind === "PAGES" && !scriptNonce) {
|
|
333
|
+
if (cached && cached.isStale && cached.value.value?.kind === "PAGES" && !scriptNonce && !isDataReq) {
|
|
304
334
|
const cachedHtml = cached.value.value.html;
|
|
305
335
|
const transformedHtml = await server.transformIndexHtml(url, cachedHtml);
|
|
306
336
|
triggerBackgroundRegeneration(cacheKey, async () => {
|
|
307
337
|
return runWithRequestContext(createRequestContext({ executionContext: null }), async () => {
|
|
308
338
|
ensureFetchPatch();
|
|
309
339
|
const freshResult = await pageModule.getStaticProps({
|
|
310
|
-
params,
|
|
340
|
+
params: userFacingParams,
|
|
311
341
|
locale: locale ?? currentDefaultLocale,
|
|
312
342
|
locales: i18nConfig?.locales,
|
|
313
343
|
defaultLocale: currentDefaultLocale
|
|
@@ -377,7 +407,7 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
377
407
|
const revalidateSecs = getRevalidateDuration(cacheKey) ?? 60;
|
|
378
408
|
const staleHeaders = {
|
|
379
409
|
"Content-Type": "text/html",
|
|
380
|
-
|
|
410
|
+
...buildCacheStateHeaders("STALE"),
|
|
381
411
|
"Cache-Control": `s-maxage=${revalidateSecs}, stale-while-revalidate`
|
|
382
412
|
};
|
|
383
413
|
if (earlyFontLinkHeader) staleHeaders["Link"] = earlyFontLinkHeader;
|
|
@@ -386,7 +416,7 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
386
416
|
return;
|
|
387
417
|
}
|
|
388
418
|
const context = {
|
|
389
|
-
params,
|
|
419
|
+
params: userFacingParams,
|
|
390
420
|
locale: locale ?? currentDefaultLocale,
|
|
391
421
|
locales: i18nConfig?.locales,
|
|
392
422
|
defaultLocale: currentDefaultLocale
|
|
@@ -403,11 +433,24 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
403
433
|
return;
|
|
404
434
|
}
|
|
405
435
|
if (result && "notFound" in result && result.notFound) {
|
|
436
|
+
if (isDataReq) {
|
|
437
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
438
|
+
res.end("{}");
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
406
441
|
await renderErrorPage(server, runner, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);
|
|
407
442
|
return;
|
|
408
443
|
}
|
|
409
444
|
if (typeof result?.revalidate === "number" && result.revalidate > 0) isrRevalidateSeconds = result.revalidate;
|
|
410
445
|
}
|
|
446
|
+
if (isDataReq) {
|
|
447
|
+
const dataHeaders = { "Content-Type": "application/json" };
|
|
448
|
+
if (gsspExtraHeaders) for (const [k, v] of Object.entries(gsspExtraHeaders)) dataHeaders[k] = v;
|
|
449
|
+
res.writeHead(statusCode ?? 200, dataHeaders);
|
|
450
|
+
res.end(JSON.stringify({ pageProps }));
|
|
451
|
+
_renderEnd = now();
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
411
454
|
let AppComponent = null;
|
|
412
455
|
const appPath = path.join(pagesDir, "_app");
|
|
413
456
|
if (findFileWithExtensions(appPath, matcher)) try {
|
|
@@ -483,7 +526,11 @@ async function hydrate() {
|
|
|
483
526
|
const root = hydrateRoot(document.getElementById("__next"), element);
|
|
484
527
|
window.__VINEXT_ROOT__ = root;
|
|
485
528
|
installPagesRouterRuntime();
|
|
486
|
-
|
|
529
|
+
const hydratedAt = performance.now();
|
|
530
|
+
window.__VINEXT_HYDRATED_AT = hydratedAt;
|
|
531
|
+
window.__NEXT_HYDRATED = true;
|
|
532
|
+
window.__NEXT_HYDRATED_AT = hydratedAt;
|
|
533
|
+
window.__NEXT_HYDRATED_CB?.();
|
|
487
534
|
}
|
|
488
535
|
hydrate();
|
|
489
536
|
<\/script>`;
|
|
@@ -492,7 +539,7 @@ hydrate();
|
|
|
492
539
|
page: patternToNextFormat(route.pattern),
|
|
493
540
|
query: params,
|
|
494
541
|
buildId: process.env.__VINEXT_BUILD_ID,
|
|
495
|
-
isFallback:
|
|
542
|
+
isFallback: isFallbackRender,
|
|
496
543
|
locale: locale ?? currentDefaultLocale,
|
|
497
544
|
locales: i18nConfig?.locales,
|
|
498
545
|
defaultLocale: currentDefaultLocale,
|
|
@@ -512,7 +559,7 @@ hydrate();
|
|
|
512
559
|
if (isrRevalidateSeconds) if (scriptNonce) extraHeaders["Cache-Control"] = "no-store, must-revalidate";
|
|
513
560
|
else {
|
|
514
561
|
extraHeaders["Cache-Control"] = `s-maxage=${isrRevalidateSeconds}, stale-while-revalidate`;
|
|
515
|
-
extraHeaders
|
|
562
|
+
Object.assign(extraHeaders, buildCacheStateHeaders("MISS"));
|
|
516
563
|
}
|
|
517
564
|
if (allFontPreloads.length > 0) extraHeaders["Link"] = allFontPreloads.map((p) => `<${p.href}>; rel=preload; as=font; type=${p.type}; crossorigin`).join(", ");
|
|
518
565
|
await streamPageToResponse(res, withScriptNonce(element, scriptNonce), {
|