vinext 1.3.0 → 1.4.0
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 +5 -2
- package/THIRD_PARTY_LICENSES.md +47 -0
- package/dist/_virtual/_rolldown/runtime.js +4 -3
- package/dist/build/action-owner-manifest.d.ts +3 -2
- package/dist/build/action-owner-manifest.js +18 -2
- package/dist/build/app-page-static-eligibility.d.ts +17 -1
- package/dist/build/app-page-static-eligibility.js +80 -13
- package/dist/build/clean-output.d.ts +2 -1
- package/dist/build/client-build-config.d.ts +13 -3
- package/dist/build/client-build-config.js +46 -9
- package/dist/build/client-reference-async.d.ts +48 -0
- package/dist/build/client-reference-async.js +123 -0
- package/dist/build/client-reference-chunks.d.ts +32 -0
- package/dist/build/client-reference-chunks.js +111 -0
- package/dist/build/client-reference-groups.d.ts +9 -1
- package/dist/build/client-reference-groups.js +40 -2
- package/dist/build/css-url-assets.d.ts +2 -1
- package/dist/build/google-fonts/fallback-metrics.d.ts +2 -1
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +1 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +17 -4
- package/dist/build/google-fonts/font-metadata.d.ts +2 -1
- package/dist/build/google-fonts/validate.d.ts +2 -1
- package/dist/build/inline-css.d.ts +2 -1
- package/dist/build/module-dependency-cache.d.ts +2 -1
- package/dist/build/next-client-runtime-manifests.d.ts +2 -1
- package/dist/build/precompress.d.ts +2 -1
- package/dist/build/precompress.js +1 -1
- package/dist/build/prerender-paths.d.ts +2 -1
- package/dist/build/prerender-phase.d.ts +2 -1
- package/dist/build/prerender-server-pool.js +1 -1
- package/dist/build/prerender.d.ts +3 -2
- package/dist/build/prerender.js +6 -5
- package/dist/build/report.d.ts +2 -15
- package/dist/build/report.js +1 -51
- package/dist/build/run-prerender.d.ts +2 -1
- package/dist/build/server-actions-encryption-key.d.ts +2 -1
- package/dist/build/ssr-manifest.js +25 -2
- package/dist/build/standalone.d.ts +2 -1
- package/dist/cache/cache-adapters-virtual.d.ts +2 -1
- package/dist/cache.js +1 -2
- package/dist/check.d.ts +2 -1
- package/dist/check.js +5 -1
- package/dist/cli-args.d.ts +2 -1
- package/dist/cli.js +5 -0
- package/dist/client/client-redirect-matcher.js +2 -1
- package/dist/client/client-redirects.d.ts +4 -3
- package/dist/client/client-redirects.js +2 -1
- package/dist/client/client-rewrites.d.ts +2 -1
- package/dist/client/dev-error-overlay-store.d.ts +2 -1
- package/dist/client/dev-error-overlay.js +1 -1
- package/dist/client/index.js +1 -2
- package/dist/client/instrumentation-client-state.js +5 -5
- package/dist/client/navigation-runtime.d.ts +16 -2
- package/dist/client/navigation-runtime.js +2 -2
- package/dist/client/pages-router-link-navigation.d.ts +2 -1
- package/dist/client/vinext-next-data.d.ts +25 -1
- package/dist/client/window-next.d.ts +2 -1
- package/dist/config/config-matchers.d.ts +12 -1
- package/dist/config/config-matchers.js +111 -16
- package/dist/config/dotenv.d.ts +2 -1
- package/dist/config/next-config.d.ts +32 -1
- package/dist/config/next-config.js +93 -5
- package/dist/config/tsconfig-paths.d.ts +2 -1
- 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/image-size@2.0.4/deps/image-size/dist/esm/detector.js +23 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/index.js +2 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/lookup.js +25 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/bmp.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/cur.js +15 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/dds.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/gif.js +12 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/heif.js +55 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/icns.js +76 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ico.js +39 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/index.js +46 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/j2c.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jp2.js +21 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jpg.js +71 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl-stream.js +42 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/jxl.js +46 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/ktx.js +19 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/png.js +28 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/pnm.js +54 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/psd.js +11 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/svg.js +79 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tga.js +15 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/tiff.js +96 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/utils.js +53 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/types/webp.js +45 -0
- package/dist/deps/.pnpm/image-size@2.0.4/deps/image-size/dist/esm/utils/bit-reader.js +38 -0
- package/dist/deps/.pnpm/safer-buffer@2.1.2/deps/safer-buffer/safer.js +45 -0
- package/dist/deps/.pnpm/ua-parser-js@1.0.35/deps/ua-parser-js/src/ua-parser.js +2 -2
- package/dist/entries/app-browser-entry.d.ts +20 -5
- package/dist/entries/app-browser-entry.js +79 -6
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +59 -60
- package/dist/entries/app-rsc-manifest.d.ts +2 -1
- package/dist/entries/app-rsc-manifest.js +56 -4
- package/dist/entries/app-ssr-entry.js +1 -0
- package/dist/entries/pages-entry-helpers.js +1 -2
- package/dist/entries/pages-server-entry.d.ts +2 -1
- package/dist/entries/pages-server-entry.js +34 -9
- package/dist/entries/runtime-entry-module.d.ts +1 -0
- package/dist/entries/runtime-entry-module.js +4 -1
- package/dist/image/image-adapters-virtual.d.ts +2 -1
- package/dist/index.js +184 -103
- 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/client-compile-hints.d.ts +30 -0
- package/dist/plugins/client-compile-hints.js +88 -0
- package/dist/plugins/client-reference-dedup.d.ts +2 -1
- package/dist/plugins/cloudflare-dev-module-urls.d.ts +2 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +3 -1
- package/dist/plugins/dynamic-preload-metadata.js +1 -1
- package/dist/plugins/environment.d.ts +2 -1
- package/dist/plugins/extensionless-dynamic-import.js +6 -2
- package/dist/plugins/fonts.js +9 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -1
- package/dist/plugins/import-meta-url.d.ts +2 -1
- package/dist/plugins/next-intl-catalog.d.ts +12 -0
- package/dist/plugins/next-intl-catalog.js +85 -0
- package/dist/plugins/og-assets.d.ts +2 -1
- package/dist/plugins/og-assets.js +2 -3
- package/dist/plugins/optimize-imports.d.ts +2 -1
- package/dist/plugins/pages-node-externals.d.ts +3 -1
- package/dist/plugins/pages-node-externals.js +1 -1
- package/dist/plugins/remove-console.d.ts +2 -1
- package/dist/plugins/require-condition-resolution.d.ts +2 -1
- package/dist/plugins/rsc-client-reference-loaders.d.ts +8 -0
- package/dist/plugins/rsc-client-reference-loaders.js +170 -68
- package/dist/plugins/rsc-client-shim-excludes.js +2 -0
- package/dist/plugins/sass.d.ts +2 -1
- package/dist/plugins/strip-server-exports.d.ts +2 -1
- package/dist/plugins/styled-jsx.d.ts +2 -1
- package/dist/plugins/transform-result.d.ts +2 -1
- package/dist/plugins/typeof-window.d.ts +2 -1
- package/dist/plugins/use-cache-callable.d.ts +1 -1
- package/dist/plugins/use-cache-callable.js +136 -94
- package/dist/plugins/worker-image-imports.js +1 -1
- package/dist/plugins/worker-use-server.d.ts +2 -1
- package/dist/routing/app-route-graph.d.ts +46 -0
- package/dist/routing/app-route-graph.js +131 -51
- package/dist/routing/browser-route-manifest.d.ts +2 -1
- package/dist/routing/optimistic-route-trie.d.ts +2 -1
- package/dist/routing/route-matching.d.ts +2 -1
- package/dist/routing/route-pattern.d.ts +2 -1
- package/dist/server/accept-encoding.d.ts +2 -1
- package/dist/server/api-handler.js +19 -4
- package/dist/server/app-action-forwarding.d.ts +2 -1
- package/dist/server/app-bfcache-identity.d.ts +2 -1
- package/dist/server/app-bfcache-identity.js +1 -1
- package/dist/server/app-browser-action-result.d.ts +2 -1
- package/dist/server/app-browser-entry.js +106 -66
- package/dist/server/app-browser-error.d.ts +2 -1
- package/dist/server/app-browser-history-controller.d.ts +7 -5
- package/dist/server/app-browser-history-controller.js +93 -15
- package/dist/server/app-browser-hydration.d.ts +2 -1
- package/dist/server/app-browser-interception-context.d.ts +2 -1
- package/dist/server/app-browser-navigation-controller.d.ts +2 -2
- package/dist/server/app-browser-navigation-controller.js +16 -12
- package/dist/server/app-browser-popstate.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.js +4 -4
- package/dist/server/app-browser-server-action-client.d.ts +4 -1
- package/dist/server/app-browser-server-action-client.js +4 -3
- package/dist/server/app-browser-state.d.ts +2 -4
- package/dist/server/app-browser-state.js +9 -4
- package/dist/server/app-browser-stream.d.ts +2 -1
- package/dist/server/app-browser-supplemental-refresh.js +16 -1
- package/dist/server/app-browser-visible-commit.d.ts +3 -2
- package/dist/server/app-browser-visible-commit.js +2 -12
- package/dist/server/app-client-reference-manifest.d.ts +31 -0
- package/dist/server/app-client-reference-manifest.js +46 -0
- package/dist/server/app-client-reference-preloader.d.ts +25 -5
- package/dist/server/app-client-reference-preloader.js +22 -7
- package/dist/server/app-elements-wire.d.ts +8 -39
- package/dist/server/app-elements-wire.js +4 -41
- package/dist/server/app-elements.d.ts +4 -2
- package/dist/server/app-elements.js +4 -2
- package/dist/server/app-fallback-renderer.d.ts +9 -2
- package/dist/server/app-fallback-renderer.js +4 -1
- package/dist/server/app-history-state.d.ts +4 -3
- package/dist/server/app-history-state.js +5 -2
- package/dist/server/app-inline-css-client.d.ts +2 -1
- package/dist/server/app-metadata-tracing.d.ts +2 -1
- 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 +37 -2
- package/dist/server/app-optimistic-routing.js +75 -2
- package/dist/server/app-page-boundary-render.d.ts +20 -2
- package/dist/server/app-page-boundary-render.js +224 -40
- package/dist/server/app-page-boundary.d.ts +34 -5
- package/dist/server/app-page-boundary.js +41 -8
- package/dist/server/app-page-cache-finalizer.d.ts +14 -2
- package/dist/server/app-page-cache-finalizer.js +71 -30
- package/dist/server/app-page-cache-render.d.ts +10 -2
- package/dist/server/app-page-cache-render.js +14 -2
- package/dist/server/app-page-cache.d.ts +13 -1
- package/dist/server/app-page-cache.js +33 -11
- package/dist/server/app-page-dispatch.d.ts +39 -11
- package/dist/server/app-page-dispatch.js +236 -177
- package/dist/server/app-page-element-builder.d.ts +19 -3
- package/dist/server/app-page-element-builder.js +193 -71
- package/dist/server/app-page-execution.d.ts +43 -51
- package/dist/server/app-page-execution.js +205 -92
- package/dist/server/app-page-head.d.ts +108 -3
- package/dist/server/app-page-head.js +337 -154
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +49 -2
- package/dist/server/app-page-http-access-fallback-metadata.js +77 -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-method.d.ts +2 -1
- 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 +5 -22
- package/dist/server/app-page-probe.js +4 -37
- package/dist/server/app-page-render-identity.d.ts +2 -1
- package/dist/server/app-page-render.d.ts +9 -13
- package/dist/server/app-page-render.js +108 -214
- package/dist/server/app-page-request.d.ts +15 -4
- package/dist/server/app-page-request.js +2 -2
- package/dist/server/app-page-response.js +3 -3
- package/dist/server/app-page-route-wiring.d.ts +65 -8
- package/dist/server/app-page-route-wiring.js +259 -103
- package/dist/server/app-page-rsc-render-status.d.ts +29 -2
- package/dist/server/app-page-rsc-render-status.js +121 -13
- package/dist/server/app-page-search-params-observation.d.ts +7 -2
- package/dist/server/app-page-search-params-observation.js +8 -1
- package/dist/server/app-page-segment-plan.d.ts +2 -1
- package/dist/server/app-page-stream.d.ts +33 -1
- package/dist/server/app-page-stream.js +25 -6
- package/dist/server/app-pages-bridge.d.ts +6 -1
- package/dist/server/app-pages-bridge.js +7 -3
- package/dist/server/app-ppr-fallback-shell-render.d.ts +2 -1
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -1
- package/dist/server/app-prerender-endpoints.d.ts +2 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-render-dependency.d.ts +21 -4
- package/dist/server/app-render-dependency.js +100 -33
- package/dist/server/app-request-stage-dispatch.js +1 -1
- package/dist/server/app-request-stage-independent-entry.d.ts +2 -1
- package/dist/server/app-response-stage-entry.d.ts +2 -1
- package/dist/server/app-route-handler-cache.d.ts +2 -1
- package/dist/server/app-route-handler-cache.js +2 -2
- package/dist/server/app-route-handler-dispatch.d.ts +2 -1
- package/dist/server/app-route-handler-dispatch.js +15 -10
- package/dist/server/app-route-handler-execution.d.ts +2 -1
- package/dist/server/app-route-handler-execution.js +8 -3
- 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.d.ts +2 -1
- package/dist/server/app-route-handler-response.js +1 -1
- package/dist/server/app-route-handler-runtime.d.ts +2 -1
- package/dist/server/app-route-handler-runtime.js +17 -4
- package/dist/server/app-route-module-loader.d.ts +18 -1
- package/dist/server/app-route-module-loader.js +8 -0
- package/dist/server/app-route-tree-prefetch.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.d.ts +2 -2
- package/dist/server/app-rsc-cache-busting.js +4 -4
- package/dist/server/app-rsc-error-handler.d.ts +4 -2
- package/dist/server/app-rsc-error-handler.js +9 -1
- package/dist/server/app-rsc-errors.d.ts +10 -1
- package/dist/server/app-rsc-errors.js +8 -1
- package/dist/server/app-rsc-handler.d.ts +7 -6
- package/dist/server/app-rsc-handler.js +36 -34
- package/dist/server/app-rsc-request-normalization.d.ts +0 -4
- package/dist/server/app-rsc-request-normalization.js +1 -4
- package/dist/server/app-rsc-response-finalizer.d.ts +2 -1
- package/dist/server/app-rsc-response-finalizer.js +2 -2
- package/dist/server/app-rsc-response-stage.js +5 -3
- package/dist/server/app-rsc-route-matching.d.ts +38 -1
- package/dist/server/app-rsc-route-matching.js +24 -0
- package/dist/server/app-segment-config.d.ts +2 -1
- package/dist/server/app-segment-config.js +1 -14
- package/dist/server/app-server-action-execution.d.ts +5 -2
- package/dist/server/app-server-action-execution.js +10 -7
- package/dist/server/app-ssr-entry.d.ts +8 -0
- package/dist/server/app-ssr-entry.js +98 -50
- package/dist/server/app-ssr-error-meta.d.ts +2 -1
- package/dist/server/app-ssr-search-params-gate.d.ts +2 -1
- package/dist/server/app-ssr-stream.d.ts +22 -10
- package/dist/server/app-ssr-stream.js +300 -68
- package/dist/server/app-static-generation.d.ts +2 -1
- package/dist/server/app-streamed-client-references.d.ts +39 -0
- package/dist/server/app-streamed-client-references.js +156 -0
- package/dist/server/app-visited-response-cache.d.ts +38 -2
- package/dist/server/app-visited-response-cache.js +46 -5
- package/dist/server/app-worker-stages.d.ts +27 -4
- package/dist/server/app-worker-stages.js +45 -6
- package/dist/server/artifact-compatibility.d.ts +2 -2
- package/dist/server/artifact-compatibility.js +1 -10
- package/dist/server/bfcache-identity.d.ts +2 -1
- package/dist/server/cache-headers.d.ts +2 -1
- package/dist/server/cache-proof.d.ts +1 -115
- package/dist/server/cache-proof.js +1 -544
- package/dist/server/cacheability-request.d.ts +2 -1
- package/dist/server/cacheability-request.js +13 -8
- package/dist/server/config-headers.d.ts +2 -1
- package/dist/server/csp.d.ts +2 -1
- package/dist/server/default-global-not-found-module.d.ts +2 -1
- package/dist/server/default-http-access-fallback-modules.d.ts +33 -0
- package/dist/server/default-http-access-fallback-modules.js +31 -0
- package/dist/server/defer-until-stream-consumed.d.ts +34 -0
- package/dist/server/defer-until-stream-consumed.js +154 -21
- package/dist/server/dev-lockfile.d.ts +32 -2
- package/dist/server/dev-lockfile.js +46 -2
- package/dist/server/dev-module-runner.d.ts +2 -1
- package/dist/server/dev-server.js +14 -6
- package/dist/server/fetch-handler.js +1 -2
- package/dist/server/file-based-metadata.d.ts +2 -1
- package/dist/server/framework-tracer.d.ts +2 -1
- package/dist/server/headers.d.ts +6 -3
- package/dist/server/headers.js +9 -5
- package/dist/server/html.d.ts +1 -0
- package/dist/server/html.js +19 -1
- package/dist/server/http-conditional.d.ts +2 -1
- package/dist/server/http-error-responses.d.ts +2 -1
- package/dist/server/implicit-tags.d.ts +2 -1
- package/dist/server/isr-cache.d.ts +8 -2
- package/dist/server/isr-cache.js +26 -1
- package/dist/server/metadata-route-build-data.d.ts +2 -1
- package/dist/server/metadata-route-build-data.js +1 -1
- package/dist/server/metadata-route-response.d.ts +2 -1
- package/dist/server/metadata-route-response.js +32 -15
- package/dist/server/metadata-routes.d.ts +2 -1
- package/dist/server/middleware-runtime.d.ts +2 -1
- package/dist/server/multi-stage.d.ts +52 -11
- package/dist/server/multi-stage.js +13 -1
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/navigation-trace.d.ts +2 -1
- package/dist/server/next-error-digest.d.ts +2 -1
- package/dist/server/nitro-public-files-plugin.d.ts +2 -1
- package/dist/server/nitro-public-files.d.ts +2 -1
- package/dist/server/opentelemetry-api.d.ts +2 -1
- package/dist/server/operation-token.d.ts +2 -1
- package/dist/server/pages-api-route.d.ts +2 -1
- package/dist/server/pages-api-route.js +28 -19
- package/dist/server/pages-asset-tags.d.ts +2 -1
- package/dist/server/pages-body-parser-config.d.ts +2 -1
- package/dist/server/pages-client-assets.d.ts +4 -0
- package/dist/server/pages-data-route.d.ts +2 -1
- package/dist/server/pages-document-asset-props.d.ts +2 -1
- package/dist/server/pages-document-initial-props.d.ts +2 -1
- package/dist/server/pages-execution-tracing.d.ts +2 -1
- package/dist/server/pages-execution-tracing.js +1 -1
- package/dist/server/pages-get-initial-props.d.ts +2 -1
- 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.js +52 -27
- package/dist/server/pages-page-data.d.ts +7 -1
- package/dist/server/pages-page-data.js +35 -12
- package/dist/server/pages-page-handler.d.ts +3 -2
- package/dist/server/pages-page-handler.js +27 -27
- package/dist/server/pages-page-method.d.ts +2 -1
- package/dist/server/pages-page-response.d.ts +2 -1
- package/dist/server/pages-preview.d.ts +2 -1
- package/dist/server/pages-readiness.d.ts +2 -1
- package/dist/server/pages-request-pipeline.d.ts +10 -1
- package/dist/server/pages-request-pipeline.js +6 -7
- package/dist/server/pages-request-stage-entry.d.ts +2 -1
- package/dist/server/pages-request-stage-entry.js +14 -12
- package/dist/server/pages-response-stage-entry.d.ts +2 -1
- package/dist/server/pages-response-stage-entry.js +9 -3
- package/dist/server/pages-route-data-kind.d.ts +2 -1
- package/dist/server/prerender-cache-life-header.d.ts +2 -1
- package/dist/server/prerender-route-params.d.ts +2 -1
- package/dist/server/prod-server.js +14 -4
- package/dist/server/request-log.d.ts +2 -1
- package/dist/server/request-pipeline.d.ts +6 -0
- package/dist/server/request-pipeline.js +21 -1
- package/dist/server/request-tracing.d.ts +2 -1
- package/dist/server/request-tracing.js +1 -1
- package/dist/server/response-start-tracing.js +7 -29
- package/dist/server/rsc-render-stream.d.ts +4 -0
- package/dist/server/rsc-render-stream.js +25 -0
- package/dist/server/seed-cache.d.ts +2 -1
- package/dist/server/seed-cache.js +1 -1
- 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 +2 -1
- package/dist/server/static-file-cache.js +1 -0
- package/dist/server/worker-revalidation-context.d.ts +2 -1
- package/dist/server/worker-stages.d.ts +18 -4
- package/dist/server/worker-stages.js +23 -4
- package/dist/shims/app.d.ts +2 -1
- package/dist/shims/cache-callable-runtime.d.ts +2 -1
- package/dist/shims/cache-handler.d.ts +8 -3
- package/dist/shims/cache-handler.js +31 -11
- package/dist/shims/cache-request-state.d.ts +17 -20
- package/dist/shims/cache-request-state.js +16 -21
- package/dist/shims/cache-runtime.js +27 -11
- package/dist/shims/cache.d.ts +8 -7
- package/dist/shims/cache.js +17 -19
- package/dist/shims/cacheability-classification.d.ts +2 -0
- package/dist/shims/caught-not-found-boundaries.d.ts +15 -0
- package/dist/shims/caught-not-found-boundaries.js +48 -0
- package/dist/shims/cdn-cache.d.ts +22 -5
- package/dist/shims/cdn-purge-routes.d.ts +2 -1
- package/dist/shims/client-locale.js +2 -1
- package/dist/shims/client-page-root.d.ts +2 -1
- package/dist/shims/client-page-root.js +2 -2
- package/dist/shims/config.d.ts +2 -1
- package/dist/shims/default-forbidden.d.ts +4 -0
- package/dist/shims/default-forbidden.js +18 -0
- package/dist/shims/default-not-found.d.ts +0 -5
- package/dist/shims/default-not-found.js +5 -41
- package/dist/shims/default-unauthorized.d.ts +4 -0
- package/dist/shims/default-unauthorized.js +18 -0
- package/dist/shims/dynamic.js +9 -6
- package/dist/shims/error-boundary.d.ts +39 -3
- package/dist/shims/error-boundary.js +33 -18
- 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 +34 -24
- package/dist/shims/font-google.js +1 -2
- package/dist/shims/font-utils.d.ts +3 -2
- package/dist/shims/font-utils.js +5 -3
- package/dist/shims/form.js +3 -3
- package/dist/shims/headers.d.ts +8 -23
- package/dist/shims/headers.js +17 -67
- package/dist/shims/http-access-error-fallback.d.ts +7 -0
- package/dist/shims/http-access-error-fallback.js +47 -0
- package/dist/shims/image.d.ts +1 -22
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +22 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.js +71 -18
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +14 -3
- package/dist/shims/internal/app-route-prefetch-policy.js +29 -4
- package/dist/shims/internal/cache-context-accessor.d.ts +2 -1
- package/dist/shims/internal/client-reference-loader.d.ts +7 -0
- package/dist/shims/internal/client-reference-loader.js +91 -0
- package/dist/shims/internal/cookie-serialize.d.ts +2 -1
- package/dist/shims/internal/cookies.js +1 -2
- package/dist/shims/internal/headers-state.d.ts +2 -0
- package/dist/shims/internal/headers-state.js +6 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +2 -1
- package/dist/shims/internal/interpolate-as.d.ts +2 -1
- package/dist/shims/internal/navigation-untracked.js +1 -1
- package/dist/shims/internal/pages-data-target.d.ts +2 -1
- package/dist/shims/internal/pages-data-url.d.ts +2 -1
- package/dist/shims/internal/thenable-well-known-properties.d.ts +2 -1
- package/dist/shims/link.js +197 -52
- package/dist/shims/metadata.d.ts +52 -29
- package/dist/shims/metadata.js +142 -42
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation-server.js +1 -1
- package/dist/shims/navigation.d.ts +95 -8
- package/dist/shims/navigation.js +255 -47
- package/dist/shims/navigation.react-server.js +2 -2
- package/dist/shims/pages-router-runtime.d.ts +2 -1
- package/dist/shims/ppr-fallback-shell.d.ts +2 -1
- package/dist/shims/request-state-types.d.ts +2 -2
- package/dist/shims/router.js +14 -3
- package/dist/shims/slot.d.ts +12 -0
- package/dist/shims/slot.js +37 -9
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +5 -6
- package/dist/typegen.d.ts +2 -1
- package/dist/utils/cache-control-metadata.d.ts +5 -0
- package/dist/utils/cache-control-metadata.js +9 -1
- package/dist/utils/client-build-manifest.d.ts +4 -1
- package/dist/utils/client-build-manifest.js +9 -2
- package/dist/utils/client-entry-manifest.d.ts +13 -0
- package/dist/utils/client-entry-manifest.js +20 -1
- package/dist/utils/client-reference-chunks.d.ts +45 -0
- package/dist/utils/client-reference-chunks.js +30 -0
- package/dist/utils/client-runtime-metadata.d.ts +9 -1
- package/dist/utils/client-runtime-metadata.js +40 -9
- package/dist/utils/compare.d.ts +9 -0
- package/dist/utils/compare.js +15 -1
- package/dist/utils/lazy-chunks.d.ts +14 -0
- package/dist/utils/lazy-chunks.js +27 -1
- package/dist/utils/middleware-request-headers.d.ts +2 -1
- package/dist/utils/project.d.ts +4 -3
- package/dist/utils/project.js +12 -17
- package/dist/utils/query.d.ts +2 -1
- 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/dist/utils/vite-cli-invocation.d.ts +2 -1
- package/package.json +6 -5
- 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 -61
- package/dist/build/layout-classification.js +0 -98
- package/dist/build/route-classification-injector.d.ts +0 -32
- package/dist/build/route-classification-injector.js +0 -59
- package/dist/build/route-classification-manifest.d.ts +0 -53
- package/dist/build/route-classification-manifest.js +0 -143
- package/dist/deps/.pnpm/image-size@2.0.2/deps/image-size/dist/index.js +0 -808
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -10
- package/dist/server/app-browser-client-reuse-manifest.js +0 -101
- package/dist/server/app-layout-param-observation.d.ts +0 -41
- package/dist/server/app-layout-param-observation.js +0 -168
- package/dist/server/client-reuse-manifest.d.ts +0 -102
- package/dist/server/client-reuse-manifest.js +0 -209
- package/dist/server/default-not-found-module.d.ts +0 -19
- package/dist/server/default-not-found-module.js +0 -18
- package/dist/server/rsc-stream-hints.d.ts +0 -21
- package/dist/server/rsc-stream-hints.js +0 -227
- 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 -13
- package/dist/server/static-layout-client-reuse-proof.js +0 -33
- package/dist/utils/sorted-array.d.ts +0 -7
- package/dist/utils/sorted-array.js +0 -20
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shareIsolatePromise } from "../server/isolate-shared-promise.js";
|
|
2
|
-
import { readCacheControlNumberField, readCacheControlRevalidateField } from "../utils/cache-control-metadata.js";
|
|
2
|
+
import { readCacheControlNumberField, readCacheControlRevalidateField, readCacheTimestamp } from "../utils/cache-control-metadata.js";
|
|
3
3
|
//#region src/shims/cache-handler.ts
|
|
4
4
|
var NoOpCacheHandler = class {
|
|
5
5
|
async get(_key, _ctx) {
|
|
@@ -48,7 +48,7 @@ function readPositiveNumberField(ctx, field) {
|
|
|
48
48
|
}
|
|
49
49
|
var MemoryCacheHandler = class {
|
|
50
50
|
store = /* @__PURE__ */ new Map();
|
|
51
|
-
|
|
51
|
+
tagsManifest = /* @__PURE__ */ new Map();
|
|
52
52
|
maxMemoryCacheSize;
|
|
53
53
|
currentMemoryCacheSize = 0;
|
|
54
54
|
constructor(options) {
|
|
@@ -77,19 +77,20 @@ var MemoryCacheHandler = class {
|
|
|
77
77
|
async get(key, ctx) {
|
|
78
78
|
const entry = this.store.get(key);
|
|
79
79
|
if (!entry) return null;
|
|
80
|
+
const now = Date.now();
|
|
81
|
+
let hasStaleTag = false;
|
|
80
82
|
for (const tag of entry.tags) {
|
|
81
|
-
|
|
82
|
-
if (revalidatedAt && revalidatedAt >= entry.lastModified) {
|
|
83
|
+
if (this.isTagExpired(tag, entry.lastModified, now)) {
|
|
83
84
|
this.deleteEntry(key);
|
|
84
85
|
return null;
|
|
85
86
|
}
|
|
87
|
+
hasStaleTag ||= this.isTagStale(tag, entry.lastModified);
|
|
86
88
|
}
|
|
87
89
|
for (const tag of readStringArrayField(ctx, "softTags")) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
if (this.isTagExpired(tag, entry.lastModified, now)) return null;
|
|
91
|
+
hasStaleTag ||= this.isTagStale(tag, entry.lastModified);
|
|
90
92
|
}
|
|
91
93
|
this.touchEntry(key, entry);
|
|
92
|
-
const now = Date.now();
|
|
93
94
|
if (entry.expireAt !== null && now > entry.expireAt) return {
|
|
94
95
|
lastModified: entry.lastModified,
|
|
95
96
|
value: entry.value,
|
|
@@ -98,7 +99,7 @@ var MemoryCacheHandler = class {
|
|
|
98
99
|
};
|
|
99
100
|
const requestedRevalidate = readPositiveNumberField(ctx, "revalidate");
|
|
100
101
|
const requestedRevalidateAt = requestedRevalidate === void 0 ? null : entry.lastModified + requestedRevalidate * 1e3;
|
|
101
|
-
if (entry.revalidateAt !== null && now > entry.revalidateAt || requestedRevalidateAt !== null && now > requestedRevalidateAt) return {
|
|
102
|
+
if (hasStaleTag || entry.revalidateAt !== null && now > entry.revalidateAt || requestedRevalidateAt !== null && now > requestedRevalidateAt) return {
|
|
102
103
|
lastModified: entry.lastModified,
|
|
103
104
|
value: entry.value,
|
|
104
105
|
cacheState: "stale",
|
|
@@ -121,7 +122,7 @@ var MemoryCacheHandler = class {
|
|
|
121
122
|
if (data && "revalidate" in data && typeof data.revalidate === "number") effectiveRevalidate = data.revalidate;
|
|
122
123
|
else if (data && "revalidate" in data && data.revalidate === false) effectiveRevalidate ??= false;
|
|
123
124
|
if (effectiveRevalidate === 0) return;
|
|
124
|
-
const now = Date.now();
|
|
125
|
+
const now = readCacheTimestamp(ctx, Date.now());
|
|
125
126
|
const revalidateAt = typeof effectiveRevalidate === "number" && effectiveRevalidate > 0 ? now + effectiveRevalidate * 1e3 : null;
|
|
126
127
|
const expireAt = typeof effectiveExpire === "number" && effectiveExpire > 0 ? now + effectiveExpire * 1e3 : null;
|
|
127
128
|
const cacheControl = typeof effectiveRevalidate === "number" || effectiveRevalidate === false ? {
|
|
@@ -148,10 +149,29 @@ var MemoryCacheHandler = class {
|
|
|
148
149
|
this.currentMemoryCacheSize += entrySize;
|
|
149
150
|
this.evictLeastRecentlyUsed();
|
|
150
151
|
}
|
|
151
|
-
async revalidateTag(tags) {
|
|
152
|
+
async revalidateTag(tags, durations) {
|
|
152
153
|
const tagList = Array.isArray(tags) ? tags : [tags];
|
|
153
154
|
const now = Date.now();
|
|
154
|
-
for (const tag of tagList)
|
|
155
|
+
for (const tag of tagList) {
|
|
156
|
+
const existing = this.tagsManifest.get(tag) ?? {};
|
|
157
|
+
if (durations) this.tagsManifest.set(tag, {
|
|
158
|
+
...existing,
|
|
159
|
+
stale: now,
|
|
160
|
+
...durations.expire === void 0 ? {} : { expired: now + durations.expire * 1e3 }
|
|
161
|
+
});
|
|
162
|
+
else this.tagsManifest.set(tag, {
|
|
163
|
+
...existing,
|
|
164
|
+
expired: now
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
isTagExpired(tag, lastModified, now) {
|
|
169
|
+
const expired = this.tagsManifest.get(tag)?.expired;
|
|
170
|
+
return expired !== void 0 && expired <= now && expired >= lastModified;
|
|
171
|
+
}
|
|
172
|
+
isTagStale(tag, lastModified) {
|
|
173
|
+
const stale = this.tagsManifest.get(tag)?.stale;
|
|
174
|
+
return stale !== void 0 && stale > lastModified;
|
|
155
175
|
}
|
|
156
176
|
resetRequestCache() {}
|
|
157
177
|
};
|
|
@@ -8,21 +8,6 @@ export type CacheLifeConfig = {
|
|
|
8
8
|
export declare const cacheLifeProfiles: Record<string, CacheLifeConfig>;
|
|
9
9
|
export type UnstableCacheRevalidationMode = "foreground" | "background";
|
|
10
10
|
export type ActionRevalidationKind = 0 | 1 | 2;
|
|
11
|
-
export type UnstableCacheObservation = Readonly<{
|
|
12
|
-
kind: "unstable_cache";
|
|
13
|
-
keyHash: string;
|
|
14
|
-
revalidate: number | false | null;
|
|
15
|
-
tagCount: number;
|
|
16
|
-
tagHash: string | null;
|
|
17
|
-
}>;
|
|
18
|
-
/**
|
|
19
|
-
* Collects the cacheLife claims made anywhere below the scope that installed
|
|
20
|
-
* it, including nested scopes that reset `requestScopedCacheLife`. Shallow
|
|
21
|
-
* scope clones share it by reference.
|
|
22
|
-
*/
|
|
23
|
-
export type CacheLifeSink = {
|
|
24
|
-
cacheLife: CacheLifeConfig | null;
|
|
25
|
-
};
|
|
26
11
|
type TagInvalidationDurations = {
|
|
27
12
|
expire?: number;
|
|
28
13
|
} | undefined;
|
|
@@ -34,12 +19,17 @@ export type PendingCdnTagInvalidation = Readonly<{
|
|
|
34
19
|
}>;
|
|
35
20
|
export type CacheState = {
|
|
36
21
|
actionRevalidationKind: ActionRevalidationKind;
|
|
37
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The request is an authorized on-demand revalidation (`res.revalidate()`).
|
|
24
|
+
* Like Next.js's `workStore.isOnDemandRevalidate`, the data caches then skip
|
|
25
|
+
* their reads but still execute and store fresh results. Set once when the
|
|
26
|
+
* request context is created; nested scopes inherit it.
|
|
27
|
+
*/
|
|
28
|
+
isOnDemandRevalidate: boolean;
|
|
38
29
|
pendingCdnTagInvalidations: PendingCdnTagInvalidation[];
|
|
39
30
|
pendingRevalidatedTags: Set<string>;
|
|
40
31
|
pendingRevalidations: Set<Promise<void>>;
|
|
41
32
|
requestScopedCacheLife: CacheLifeConfig | null;
|
|
42
|
-
unstableCacheObservations: Map<string, UnstableCacheObservation>;
|
|
43
33
|
unstableCacheRevalidation: UnstableCacheRevalidationMode;
|
|
44
34
|
};
|
|
45
35
|
export declare const ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC = 1;
|
|
@@ -47,6 +37,15 @@ export declare const ACTION_DID_REVALIDATE_DYNAMIC_ONLY = 2;
|
|
|
47
37
|
export declare function _runWithCacheState<T>(fn: () => Promise<T>): Promise<T>;
|
|
48
38
|
export declare function _runWithCacheState<T>(fn: () => T | Promise<T>): T | Promise<T>;
|
|
49
39
|
export declare function _initRequestScopedCacheState(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the current request is an authorized on-demand revalidation, so the
|
|
42
|
+
* data caches must skip their reads (not their writes). Mirrors Next.js's
|
|
43
|
+
* `workStore.isOnDemandRevalidate` checks in use-cache-wrapper, patch-fetch
|
|
44
|
+
* and unstable-cache.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare function _isOnDemandRevalidate(): boolean;
|
|
50
49
|
export declare function markActionRevalidation(kind: ActionRevalidationKind): void;
|
|
51
50
|
export declare function getAndClearActionRevalidationKind(): ActionRevalidationKind;
|
|
52
51
|
/** @internal */
|
|
@@ -114,11 +113,9 @@ export declare function _captureRequestScopedCacheLifeAccessors(): {
|
|
|
114
113
|
consume: () => CacheLifeConfig | null;
|
|
115
114
|
peek: () => CacheLifeConfig | null;
|
|
116
115
|
};
|
|
117
|
-
export declare function recordUnstableCacheObservation(observation: UnstableCacheObservation): void;
|
|
118
|
-
export declare function _peekUnstableCacheObservations(): UnstableCacheObservation[];
|
|
119
116
|
/**
|
|
120
117
|
* Run `fn` with the request's cache settings, including its revalidation mode,
|
|
121
|
-
* but its own record of cache lives
|
|
118
|
+
* but its own record of cache lives, so work
|
|
122
119
|
* done on the request's behalf after the fact leaves the request untouched.
|
|
123
120
|
*/
|
|
124
121
|
export declare function runWithDetachedCacheObservations<T>(fn: () => Promise<T>): Promise<T>;
|
|
@@ -48,12 +48,11 @@ const ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC = 1;
|
|
|
48
48
|
const ACTION_DID_REVALIDATE_DYNAMIC_ONLY = 2;
|
|
49
49
|
const fallbackState = globalState[FALLBACK_KEY] ??= {
|
|
50
50
|
actionRevalidationKind: ACTION_DID_NOT_REVALIDATE,
|
|
51
|
-
|
|
51
|
+
isOnDemandRevalidate: false,
|
|
52
52
|
pendingCdnTagInvalidations: [],
|
|
53
53
|
pendingRevalidatedTags: /* @__PURE__ */ new Set(),
|
|
54
54
|
pendingRevalidations: /* @__PURE__ */ new Set(),
|
|
55
55
|
requestScopedCacheLife: null,
|
|
56
|
-
unstableCacheObservations: /* @__PURE__ */ new Map(),
|
|
57
56
|
unstableCacheRevalidation: "foreground"
|
|
58
57
|
};
|
|
59
58
|
function getCacheState() {
|
|
@@ -63,19 +62,16 @@ function getCacheState() {
|
|
|
63
62
|
function _runWithCacheState(fn) {
|
|
64
63
|
if (isInsideUnifiedScope()) return runWithUnifiedStateMutation((context) => {
|
|
65
64
|
context.actionRevalidationKind = ACTION_DID_NOT_REVALIDATE;
|
|
66
|
-
context.cacheLifeSink = null;
|
|
67
65
|
context.requestScopedCacheLife = null;
|
|
68
|
-
context.unstableCacheObservations = /* @__PURE__ */ new Map();
|
|
69
66
|
context.unstableCacheRevalidation = "foreground";
|
|
70
67
|
}, fn);
|
|
71
68
|
const state = {
|
|
72
69
|
actionRevalidationKind: ACTION_DID_NOT_REVALIDATE,
|
|
73
|
-
|
|
70
|
+
isOnDemandRevalidate: false,
|
|
74
71
|
pendingCdnTagInvalidations: [],
|
|
75
72
|
pendingRevalidatedTags: /* @__PURE__ */ new Set(),
|
|
76
73
|
pendingRevalidations: /* @__PURE__ */ new Set(),
|
|
77
74
|
requestScopedCacheLife: null,
|
|
78
|
-
unstableCacheObservations: /* @__PURE__ */ new Map(),
|
|
79
75
|
unstableCacheRevalidation: "foreground"
|
|
80
76
|
};
|
|
81
77
|
return cacheAls.run(state, fn);
|
|
@@ -84,7 +80,17 @@ function _initRequestScopedCacheState() {
|
|
|
84
80
|
const state = getCacheState();
|
|
85
81
|
state.actionRevalidationKind = ACTION_DID_NOT_REVALIDATE;
|
|
86
82
|
state.requestScopedCacheLife = null;
|
|
87
|
-
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Whether the current request is an authorized on-demand revalidation, so the
|
|
86
|
+
* data caches must skip their reads (not their writes). Mirrors Next.js's
|
|
87
|
+
* `workStore.isOnDemandRevalidate` checks in use-cache-wrapper, patch-fetch
|
|
88
|
+
* and unstable-cache.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
function _isOnDemandRevalidate() {
|
|
93
|
+
return getCacheState().isOnDemandRevalidate === true;
|
|
88
94
|
}
|
|
89
95
|
function markActionRevalidation(kind) {
|
|
90
96
|
if (getHeadersAccessPhase() !== "action") return;
|
|
@@ -224,7 +230,6 @@ function mergeCacheLife(current, config) {
|
|
|
224
230
|
function _setRequestScopedCacheLife(config) {
|
|
225
231
|
const state = getCacheState();
|
|
226
232
|
state.requestScopedCacheLife = mergeCacheLife(state.requestScopedCacheLife, config);
|
|
227
|
-
if (state.cacheLifeSink) state.cacheLifeSink.cacheLife = mergeCacheLife(state.cacheLifeSink.cacheLife, config);
|
|
228
233
|
}
|
|
229
234
|
function _peekRequestScopedCacheLife() {
|
|
230
235
|
const config = getCacheState().requestScopedCacheLife;
|
|
@@ -257,32 +262,22 @@ function _captureRequestScopedCacheLifeAccessors() {
|
|
|
257
262
|
}
|
|
258
263
|
};
|
|
259
264
|
}
|
|
260
|
-
function recordUnstableCacheObservation(observation) {
|
|
261
|
-
getCacheState().unstableCacheObservations.set(observation.keyHash, observation);
|
|
262
|
-
}
|
|
263
|
-
function _peekUnstableCacheObservations() {
|
|
264
|
-
return [...getCacheState().unstableCacheObservations.values()].sort((a, b) => a.keyHash.localeCompare(b.keyHash));
|
|
265
|
-
}
|
|
266
265
|
/**
|
|
267
266
|
* Run `fn` with the request's cache settings, including its revalidation mode,
|
|
268
|
-
* but its own record of cache lives
|
|
267
|
+
* but its own record of cache lives, so work
|
|
269
268
|
* done on the request's behalf after the fact leaves the request untouched.
|
|
270
269
|
*/
|
|
271
270
|
function runWithDetachedCacheObservations(fn) {
|
|
272
271
|
if (isInsideUnifiedScope()) return runWithUnifiedStateMutation((context) => {
|
|
273
|
-
context.cacheLifeSink = null;
|
|
274
272
|
context.requestScopedCacheLife = null;
|
|
275
|
-
context.unstableCacheObservations = /* @__PURE__ */ new Map();
|
|
276
273
|
}, fn);
|
|
277
274
|
return cacheAls.run({
|
|
278
275
|
...getCacheState(),
|
|
279
|
-
|
|
280
|
-
requestScopedCacheLife: null,
|
|
281
|
-
unstableCacheObservations: /* @__PURE__ */ new Map()
|
|
276
|
+
requestScopedCacheLife: null
|
|
282
277
|
}, fn);
|
|
283
278
|
}
|
|
284
279
|
function shouldServeStaleUnstableCacheEntry() {
|
|
285
280
|
return getCacheState().unstableCacheRevalidation === "background";
|
|
286
281
|
}
|
|
287
282
|
//#endregion
|
|
288
|
-
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife,
|
|
283
|
+
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _isOnDemandRevalidate, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _queuePendingCdnTagInvalidation, _queuePendingRevalidation, _recordUseCacheRootParamRead, _registerCacheContextAccessor, _revalidateCdnTags, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, runWithDetachedCacheObservations, shouldServeStaleUnstableCacheEntry };
|
|
@@ -11,7 +11,7 @@ import { createPprFallbackShellSuspensePromise, trackPprFallbackShellCacheTask }
|
|
|
11
11
|
import { createUseCacheAccessError, markDynamicUsage, recordInvalidDynamicUsageError } from "./internal/headers-state.js";
|
|
12
12
|
import { isDraftModeEnabled } from "./headers.js";
|
|
13
13
|
import { _registerCacheContextAccessor } from "./internal/cache-context-accessor.js";
|
|
14
|
-
import { _hasPendingRevalidatedTag, _setRequestScopedCacheLife, cacheLifeProfiles, runWithDetachedCacheObservations, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
|
|
14
|
+
import { _hasPendingRevalidatedTag, _isOnDemandRevalidate, _setRequestScopedCacheLife, cacheLifeProfiles, runWithDetachedCacheObservations, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
|
|
15
15
|
import "./fetch-cache.js";
|
|
16
16
|
import { hasUseCacheLayoutMarker, hasUseCachePageMarker, isUseCacheFunctionReference, withoutUseCacheSegmentMarker } from "./internal/app-page-props-cache-key.js";
|
|
17
17
|
import { isWellKnownProperty } from "./internal/thenable-well-known-properties.js";
|
|
@@ -389,7 +389,7 @@ function registerCachedFunction(fn, id, variant, options = {}) {
|
|
|
389
389
|
if (knownRootParamNames && rootParams) cacheKey += computeRootParamsCacheKeySuffix(rootParams, knownRootParamNames);
|
|
390
390
|
const softTags = getCurrentFetchSoftTags();
|
|
391
391
|
let existing = null;
|
|
392
|
-
if (!_hasPendingRevalidatedTag(softTags)) try {
|
|
392
|
+
if (!_hasPendingRevalidatedTag(softTags) && !_isOnDemandRevalidate()) try {
|
|
393
393
|
existing = await handler.get(cacheKey, {
|
|
394
394
|
kind: "FETCH",
|
|
395
395
|
softTags
|
|
@@ -398,8 +398,10 @@ function registerCachedFunction(fn, id, variant, options = {}) {
|
|
|
398
398
|
console.error("[vinext] use cache: handler.get failed; treating as a cache miss:", error);
|
|
399
399
|
}
|
|
400
400
|
const redirectValue = existing?.value;
|
|
401
|
+
let staleRedirect;
|
|
401
402
|
if (isRootParamRedirect(existing) && isServableCacheState(existing?.cacheState) && rootParams && redirectValue?.kind === "FETCH" && !_hasPendingRevalidatedTag([...redirectValue.tags ?? [], ...softTags])) {
|
|
402
403
|
cacheKey = coarseCacheKey + computeRootParamsCacheKeySuffix(rootParams, addKnownRootParamNames(id, rootParamNamesFromTags(redirectValue.tags)));
|
|
404
|
+
if (existing?.cacheState) staleRedirect = existing;
|
|
403
405
|
try {
|
|
404
406
|
existing = await handler.get(cacheKey, {
|
|
405
407
|
kind: "FETCH",
|
|
@@ -410,7 +412,8 @@ function registerCachedFunction(fn, id, variant, options = {}) {
|
|
|
410
412
|
existing = null;
|
|
411
413
|
}
|
|
412
414
|
}
|
|
413
|
-
const generate = async (propagate) => {
|
|
415
|
+
const generate = async (propagate, staleEntry) => {
|
|
416
|
+
const timestamp = Date.now();
|
|
414
417
|
const { result, ctx, effectiveLife, collectedResult } = await runCachedFunctionWithContext(callFn, callArgs, cacheVariant, (value) => serializeCacheResult(value, rsc));
|
|
415
418
|
const rootParamNames = ctx.readRootParamNames && ctx.readRootParamNames.size > 0 ? addKnownRootParamNames(id, ctx.readRootParamNames) : knownRootParamsByFunctionId.get(id);
|
|
416
419
|
if (propagate) {
|
|
@@ -442,6 +445,7 @@ function registerCachedFunction(fn, id, variant, options = {}) {
|
|
|
442
445
|
const cacheContext = {
|
|
443
446
|
fetchCache: true,
|
|
444
447
|
tags: ctx.tags,
|
|
448
|
+
timestamp,
|
|
445
449
|
...cacheFunctionInvocation ? { cacheFunctionInvocation } : {},
|
|
446
450
|
cacheControl: {
|
|
447
451
|
revalidate: revalidateSeconds,
|
|
@@ -463,11 +467,18 @@ function registerCachedFunction(fn, id, variant, options = {}) {
|
|
|
463
467
|
revalidate: revalidateSeconds
|
|
464
468
|
}, {
|
|
465
469
|
...cacheContext,
|
|
466
|
-
tags: redirectTags
|
|
470
|
+
tags: redirectTags,
|
|
471
|
+
...coarseCacheKey === cacheKey ? staleEntry && { staleEntry } : staleRedirect && { staleEntry: staleRedirect }
|
|
467
472
|
});
|
|
468
473
|
cacheValue.data.url = specificCacheKey;
|
|
469
|
-
await handler.set(specificCacheKey, cacheValue,
|
|
470
|
-
|
|
474
|
+
await handler.set(specificCacheKey, cacheValue, {
|
|
475
|
+
...cacheContext,
|
|
476
|
+
...staleEntry && specificCacheKey === cacheKey ? { staleEntry } : {}
|
|
477
|
+
});
|
|
478
|
+
} else await handler.set(cacheKey, cacheValue, {
|
|
479
|
+
...cacheContext,
|
|
480
|
+
...staleEntry ? { staleEntry } : {}
|
|
481
|
+
});
|
|
471
482
|
} catch {}
|
|
472
483
|
return collectedResult ? collectedResult.result : result;
|
|
473
484
|
};
|
|
@@ -476,10 +487,13 @@ function registerCachedFunction(fn, id, variant, options = {}) {
|
|
|
476
487
|
propagateCacheTagsToRequest(existing.value.tags);
|
|
477
488
|
const result = await rsc.createFromReadableStream(uint8ToStream(base64ToUint8(existing.value.data.body)), {}, { preserveServerReferences: true });
|
|
478
489
|
recordRequestScopedCacheControl(existing.cacheControl);
|
|
479
|
-
if (existing.cacheState === "stale")
|
|
490
|
+
if (existing.cacheState === "stale") {
|
|
491
|
+
const staleEntry = existing;
|
|
492
|
+
regenerateInBackground(id, () => generate(false, staleEntry));
|
|
493
|
+
}
|
|
480
494
|
return result;
|
|
481
495
|
} catch {}
|
|
482
|
-
return generate(true);
|
|
496
|
+
return generate(true, existing?.cacheState ? existing : void 0);
|
|
483
497
|
}, cacheVariant);
|
|
484
498
|
};
|
|
485
499
|
const cachedFn = memoizeInCacheScope((...args) => invoke(args));
|
|
@@ -589,9 +603,11 @@ async function runCachedFunctionWithContext(fn, args, variant, collectResult) {
|
|
|
589
603
|
let collectedResult;
|
|
590
604
|
const workUnitType = variant === "private" ? "private-cache" : "cache";
|
|
591
605
|
const result = await workUnitAsyncStorage.run({ type: workUnitType }, () => cacheContextStorage.run(ctx, async () => {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
606
|
+
if (!collectResult) return await fn(...args);
|
|
607
|
+
let value;
|
|
608
|
+
const lazyValue = { then: (onFulfilled, onRejected) => (value ??= new Promise((resolve) => resolve(fn(...args)))).then(onFulfilled, onRejected) };
|
|
609
|
+
collectedResult = await collectResult(lazyValue, ctx);
|
|
610
|
+
return await lazyValue;
|
|
595
611
|
}));
|
|
596
612
|
if (ctx.invalidDynamicUsageError) throw ctx.invalidDynamicUsageError;
|
|
597
613
|
const effectiveLife = resolveCacheLife(ctx.lifeConfigs);
|
package/dist/shims/cache.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExecutionContextLike, getRequestExecutionContext, runWithExecutionContext } from "./request-context.js";
|
|
2
|
-
import { _recordUseCacheRootParamRead, _registerCacheContextAccessor, getRegisteredCacheContext } from "./internal/cache-context-accessor.js";
|
|
3
|
-
import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheLifeConfig, CacheLifeSink, CacheState, PendingCdnTagInvalidation, UnstableCacheObservation, UnstableCacheRevalidationMode, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _queuePendingCdnTagInvalidation, _queuePendingRevalidation, _revalidateCdnTags, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, markActionRevalidation, recordUnstableCacheObservation, runWithDetachedCacheObservations, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
|
|
4
2
|
import { CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CachedAppPageValue, CachedFetchValue, CachedImageValue, CachedPagesValue, CachedRedirectValue, CachedRouteValue, IncrementalCacheValue, MemoryCacheHandler, NoOpCacheHandler, configureMemoryCacheHandler, getCacheHandler, getDataCacheHandler, registerDataCacheHandler, registerLazyDataCacheHandler, setCacheHandler, setDataCacheHandler } from "./cache-handler.js";
|
|
3
|
+
import { _recordUseCacheRootParamRead, _registerCacheContextAccessor, getRegisteredCacheContext } from "./internal/cache-context-accessor.js";
|
|
4
|
+
import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheLifeConfig, CacheState, PendingCdnTagInvalidation, UnstableCacheRevalidationMode, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _isOnDemandRevalidate, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _queuePendingCdnTagInvalidation, _queuePendingRevalidation, _revalidateCdnTags, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, markActionRevalidation, runWithDetachedCacheObservations, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
|
|
5
5
|
//#region src/shims/cache.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Revalidate cached data associated with a specific cache tag.
|
|
@@ -61,10 +61,11 @@ export declare function updateTag(tag: string): undefined;
|
|
|
61
61
|
/**
|
|
62
62
|
* Opt out of static rendering and indicate a particular component should not be cached.
|
|
63
63
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
64
|
+
* Without Cache Components this marks the render dynamic, so the page is not
|
|
65
|
+
* stored. With Cache Components it does nothing, as in Next.js: its prerenders
|
|
66
|
+
* ignore it, and on a request it doesn't make the page dynamic, so the page
|
|
67
|
+
* stays static and cacheable.
|
|
68
|
+
* Source: https://github.com/vercel/next.js/blob/canary/packages/next/src/server/web/spec-extension/unstable-no-store.ts
|
|
68
69
|
*/
|
|
69
70
|
export declare function unstable_noStore(): void;
|
|
70
71
|
/**
|
|
@@ -142,4 +143,4 @@ type UnstableCacheOptions = {
|
|
|
142
143
|
*/
|
|
143
144
|
export declare function unstable_cache<T extends (...args: any[]) => Promise<any>>(fn: T, keyParts?: string[], options?: UnstableCacheOptions): T;
|
|
144
145
|
//#endregion
|
|
145
|
-
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CacheLifeConfig,
|
|
146
|
+
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CacheLifeConfig, CacheState, CachedAppPageValue, CachedFetchValue, CachedImageValue, CachedPagesValue, CachedRedirectValue, CachedRouteValue, type ExecutionContextLike, IncrementalCacheValue, MemoryCacheHandler, NoOpCacheHandler, PendingCdnTagInvalidation, UnstableCacheRevalidationMode, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _isOnDemandRevalidate, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _queuePendingCdnTagInvalidation, _queuePendingRevalidation, _recordUseCacheRootParamRead, _registerCacheContextAccessor, _revalidateCdnTags, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, configureMemoryCacheHandler, getAndClearActionRevalidationKind, getCacheHandler, getDataCacheHandler, getRegisteredCacheContext, getRequestExecutionContext, markActionRevalidation, unstable_noStore as noStore, registerDataCacheHandler, registerLazyDataCacheHandler, runWithDetachedCacheObservations, runWithExecutionContext, setCacheHandler, setDataCacheHandler, shouldServeStaleUnstableCacheEntry };
|
package/dist/shims/cache.js
CHANGED
|
@@ -6,13 +6,13 @@ import { workUnitAsyncStorage } from "./internal/work-unit-async-storage.js";
|
|
|
6
6
|
import { isStagedCacheabilityProbeActive } from "./cacheability-classification.js";
|
|
7
7
|
import { MemoryCacheHandler, NoOpCacheHandler, configureMemoryCacheHandler, getCacheHandler, getDataCacheHandler, registerDataCacheHandler, registerLazyDataCacheHandler, setCacheHandler, setDataCacheHandler } from "./cache-handler.js";
|
|
8
8
|
import { encodeCacheTag, encodeCacheTags } from "../utils/encode-cache-tag.js";
|
|
9
|
-
import {
|
|
9
|
+
import { sha256Hex } from "../utils/hash.js";
|
|
10
10
|
import { addCollectedRequestTags, getCurrentFetchSoftTags, runWithDetachedFetchObservations } from "./fetch-cache-state.js";
|
|
11
11
|
import { makeHangingPromise } from "./internal/make-hanging-promise.js";
|
|
12
12
|
import { getHeadersAccessPhase, markDynamicUsage } from "./internal/headers-state.js";
|
|
13
13
|
import { isDraftModeEnabled } from "./headers.js";
|
|
14
14
|
import { _recordUseCacheRootParamRead, _registerCacheContextAccessor, getRegisteredCacheContext } from "./internal/cache-context-accessor.js";
|
|
15
|
-
import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife,
|
|
15
|
+
import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _isOnDemandRevalidate, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _queuePendingCdnTagInvalidation, _queuePendingRevalidation, _revalidateCdnTags, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, markActionRevalidation, runWithDetachedCacheObservations, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
|
|
16
16
|
import { isPathKnownNotEdgeCached } from "./cdn-purge-routes.js";
|
|
17
17
|
//#region src/shims/cache.ts
|
|
18
18
|
/**
|
|
@@ -154,13 +154,15 @@ function updateTag(tag) {
|
|
|
154
154
|
/**
|
|
155
155
|
* Opt out of static rendering and indicate a particular component should not be cached.
|
|
156
156
|
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
157
|
+
* Without Cache Components this marks the render dynamic, so the page is not
|
|
158
|
+
* stored. With Cache Components it does nothing, as in Next.js: its prerenders
|
|
159
|
+
* ignore it, and on a request it doesn't make the page dynamic, so the page
|
|
160
|
+
* stays static and cacheable.
|
|
161
|
+
* Source: https://github.com/vercel/next.js/blob/canary/packages/next/src/server/web/spec-extension/unstable-no-store.ts
|
|
161
162
|
*/
|
|
162
163
|
function unstable_noStore() {
|
|
163
164
|
if (isInsideUnstableCacheScope()) return;
|
|
165
|
+
if (String(process.env.__NEXT_CACHE_COMPONENTS) === "true") return;
|
|
164
166
|
markDynamicUsage();
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
@@ -394,7 +396,7 @@ function scheduleUnstableCacheBackgroundRevalidation(cacheKey, refresh) {
|
|
|
394
396
|
pending.set(cacheKey, trackedRevalidation);
|
|
395
397
|
waitUntilUnstableCacheRevalidation(trackedRevalidation);
|
|
396
398
|
}
|
|
397
|
-
async function refreshUnstableCacheResult(fn, args, keyedArgs, cacheKey, tags, revalidateSeconds) {
|
|
399
|
+
async function refreshUnstableCacheResult(fn, args, keyedArgs, cacheKey, tags, revalidateSeconds, staleEntry) {
|
|
398
400
|
const argsUnchanged = serializeArgsOrNull(args) === keyedArgs;
|
|
399
401
|
const result = await _unstableCacheAls.run(true, () => _unstableCacheCallbackAls.run({ useCacheContext: _useCacheContextAls.getStore() }, () => fn(...args)));
|
|
400
402
|
if (!argsUnchanged) return result;
|
|
@@ -411,7 +413,8 @@ async function refreshUnstableCacheResult(fn, args, keyedArgs, cacheKey, tags, r
|
|
|
411
413
|
await getDataCacheHandler().set(cacheKey, cacheValue, {
|
|
412
414
|
fetchCache: true,
|
|
413
415
|
tags,
|
|
414
|
-
revalidate: revalidateSeconds
|
|
416
|
+
revalidate: revalidateSeconds,
|
|
417
|
+
...staleEntry ? { staleEntry } : {}
|
|
415
418
|
});
|
|
416
419
|
return result;
|
|
417
420
|
}
|
|
@@ -439,16 +442,10 @@ function unstable_cache(fn, keyParts, options) {
|
|
|
439
442
|
const keyedArgs = JSON.stringify(args);
|
|
440
443
|
const invocationKey = `${fixedKey}${keyedArgs}`;
|
|
441
444
|
addCollectedRequestTags(tags);
|
|
442
|
-
recordUnstableCacheObservation({
|
|
443
|
-
kind: "unstable_cache",
|
|
444
|
-
keyHash: fnv1a64(invocationKey),
|
|
445
|
-
revalidate: typeof revalidateSeconds === "number" ? revalidateSeconds : revalidateSeconds === false ? false : null,
|
|
446
|
-
tagCount: tags.length,
|
|
447
|
-
tagHash: tags.length > 0 ? fnv1a64(JSON.stringify(tags)) : null
|
|
448
|
-
});
|
|
449
445
|
const cacheKey = `${UNSTABLE_CACHE_KEY_PREFIX}:${await sha256Hex(invocationKey)}`;
|
|
450
446
|
const isDraftMode = isDraftModeEnabled();
|
|
451
|
-
|
|
447
|
+
let staleEntry;
|
|
448
|
+
if (!isDraftMode && !isNestedUnstableCacheCall() && !_isOnDemandRevalidate()) {
|
|
452
449
|
const softTags = getCurrentFetchSoftTags();
|
|
453
450
|
const existing = _hasPendingRevalidatedTag([...tags, ...softTags]) ? null : await getDataCacheHandler().get(cacheKey, {
|
|
454
451
|
kind: "FETCH",
|
|
@@ -457,10 +454,11 @@ function unstable_cache(fn, keyParts, options) {
|
|
|
457
454
|
});
|
|
458
455
|
if (existing?.value && existing.value.kind === "FETCH") {
|
|
459
456
|
const cached = tryDeserializeUnstableCacheResult(existing.value.data.body);
|
|
457
|
+
if (existing.cacheState === "stale") staleEntry = existing;
|
|
460
458
|
if (cached.ok) {
|
|
461
459
|
if (existing.cacheState === "stale") {
|
|
462
460
|
if (shouldServeStaleUnstableCacheEntry()) {
|
|
463
|
-
scheduleUnstableCacheBackgroundRevalidation(cacheKey, () => refreshUnstableCacheResult(fn, args, keyedArgs, cacheKey, tags, revalidateSeconds));
|
|
461
|
+
scheduleUnstableCacheBackgroundRevalidation(cacheKey, () => refreshUnstableCacheResult(fn, args, keyedArgs, cacheKey, tags, revalidateSeconds, staleEntry));
|
|
464
462
|
return cached.value;
|
|
465
463
|
}
|
|
466
464
|
} else return cached.value;
|
|
@@ -468,9 +466,9 @@ function unstable_cache(fn, keyParts, options) {
|
|
|
468
466
|
}
|
|
469
467
|
}
|
|
470
468
|
if (isDraftMode) return await _unstableCacheAls.run(true, () => fn(...args));
|
|
471
|
-
return await refreshUnstableCacheResult(fn, args, keyedArgs, cacheKey, tags, revalidateSeconds);
|
|
469
|
+
return await refreshUnstableCacheResult(fn, args, keyedArgs, cacheKey, tags, revalidateSeconds, staleEntry);
|
|
472
470
|
};
|
|
473
471
|
return cachedFn;
|
|
474
472
|
}
|
|
475
473
|
//#endregion
|
|
476
|
-
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, MemoryCacheHandler, NoOpCacheHandler, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _markPendingRevalidatedTag, _peekRequestScopedCacheLife,
|
|
474
|
+
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, MemoryCacheHandler, NoOpCacheHandler, _captureRequestScopedCacheLifeAccessors, _consumeRequestScopedCacheLife, _drainPendingRevalidations, _hasPendingRevalidatedTag, _initRequestScopedCacheState, _isOnDemandRevalidate, _markPendingRevalidatedTag, _peekRequestScopedCacheLife, _queuePendingCdnTagInvalidation, _queuePendingRevalidation, _recordUseCacheRootParamRead, _registerCacheContextAccessor, _revalidateCdnTags, _runWithCacheState, _setRequestScopedCacheLife, cacheLife, cacheLifeProfiles, cacheTag, configureMemoryCacheHandler, getAndClearActionRevalidationKind, getCacheHandler, getDataCacheHandler, getRegisteredCacheContext, getRequestExecutionContext, io, isInsideUnstableCacheScope, markActionRevalidation, unstable_noStore as noStore, unstable_noStore, refresh, registerDataCacheHandler, registerLazyDataCacheHandler, revalidatePath, revalidateTag, runWithDetachedCacheObservations, runWithExecutionContext, setCacheHandler, setDataCacheHandler, shouldServeStaleUnstableCacheEntry, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_io, updateTag };
|
|
@@ -17,6 +17,8 @@ export type RouteCacheabilityOutcome = {
|
|
|
17
17
|
*/
|
|
18
18
|
status?: number;
|
|
19
19
|
headers?: Readonly<Record<string, string>>;
|
|
20
|
+
/** App pages: the client-router stale time from the completed render's cacheLife. */
|
|
21
|
+
staleTimeSeconds?: number;
|
|
20
22
|
tags?: readonly string[];
|
|
21
23
|
};
|
|
22
24
|
export type RouteCacheabilityState = {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
//#region src/shims/caught-not-found-boundaries.d.ts
|
|
3
|
+
export declare const CAUGHT_NOT_FOUND_BOUNDARIES_GLOBAL = "__VINEXT_CAUGHT_NOT_FOUND__";
|
|
4
|
+
/** The boundaries that caught, and those of them the document rendered. */
|
|
5
|
+
export type CaughtNotFoundBoundaries = {
|
|
6
|
+
ids: ReadonlySet<string>;
|
|
7
|
+
rendered: Set<string>;
|
|
8
|
+
};
|
|
9
|
+
export declare const CaughtNotFoundBoundariesContext: React.Context<CaughtNotFoundBoundaries | null> | null;
|
|
10
|
+
export declare function withCaughtNotFoundBoundaries(boundaries: CaughtNotFoundBoundaries, children: React.ReactElement): React.ReactElement;
|
|
11
|
+
/** Whether the boundary with this id caught a notFound() in the document. */
|
|
12
|
+
export declare function useCaughtNotFoundBoundary(id: string | undefined): boolean;
|
|
13
|
+
/** A hydrated boundary consumes its id, so a later mount renders its children. */
|
|
14
|
+
export declare function consumeCaughtNotFoundBoundary(id: string | undefined): void;
|
|
15
|
+
//#endregion
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
//#region src/shims/caught-not-found-boundaries.ts
|
|
3
|
+
/**
|
|
4
|
+
* The parallel slot not-found boundaries that caught a slot's notFound() in
|
|
5
|
+
* the document. Fizz has no error boundaries, so a slot page's notFound()
|
|
6
|
+
* rejects the shell; the App Router SSR entry then renders the document again
|
|
7
|
+
* from the same Flight payload, with the boundaries that would have caught it
|
|
8
|
+
* on the client rendering their fallback (Next.js renders them in the browser
|
|
9
|
+
* after an empty error shell). The browser reads the same ids from
|
|
10
|
+
* `self.__VINEXT_CAUGHT_NOT_FOUND__`, so those boundaries hydrate caught. Only
|
|
11
|
+
* the boundaries the document rendered are sent, since one inside another
|
|
12
|
+
* caught boundary never mounts to consume its id.
|
|
13
|
+
*
|
|
14
|
+
* Stored on a global symbol so duplicate module instances share one context,
|
|
15
|
+
* and null in react-server, which has no createContext.
|
|
16
|
+
*/
|
|
17
|
+
const CAUGHT_NOT_FOUND_BOUNDARIES_CONTEXT_KEY = Symbol.for("vinext.caughtNotFoundBoundariesContext");
|
|
18
|
+
const CAUGHT_NOT_FOUND_BOUNDARIES_GLOBAL = "__VINEXT_CAUGHT_NOT_FOUND__";
|
|
19
|
+
function getCaughtNotFoundBoundariesContext() {
|
|
20
|
+
if (typeof React.createContext !== "function") return null;
|
|
21
|
+
const globalState = globalThis;
|
|
22
|
+
globalState[CAUGHT_NOT_FOUND_BOUNDARIES_CONTEXT_KEY] ??= React.createContext(null);
|
|
23
|
+
return globalState[CAUGHT_NOT_FOUND_BOUNDARIES_CONTEXT_KEY];
|
|
24
|
+
}
|
|
25
|
+
const CaughtNotFoundBoundariesContext = getCaughtNotFoundBoundariesContext();
|
|
26
|
+
function withCaughtNotFoundBoundaries(boundaries, children) {
|
|
27
|
+
return CaughtNotFoundBoundariesContext ? React.createElement(CaughtNotFoundBoundariesContext.Provider, { value: boundaries }, children) : children;
|
|
28
|
+
}
|
|
29
|
+
/** Whether the boundary with this id caught a notFound() in the document. */
|
|
30
|
+
function useCaughtNotFoundBoundary(id) {
|
|
31
|
+
const serverBoundaries = React.useContext(CaughtNotFoundBoundariesContext);
|
|
32
|
+
if (id === void 0) return false;
|
|
33
|
+
if (typeof window === "undefined") {
|
|
34
|
+
if (serverBoundaries?.ids.has(id) !== true) return false;
|
|
35
|
+
serverBoundaries.rendered.add(id);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return globalThis[CAUGHT_NOT_FOUND_BOUNDARIES_GLOBAL]?.includes(id) === true;
|
|
39
|
+
}
|
|
40
|
+
/** A hydrated boundary consumes its id, so a later mount renders its children. */
|
|
41
|
+
function consumeCaughtNotFoundBoundary(id) {
|
|
42
|
+
if (id === void 0 || typeof window === "undefined") return;
|
|
43
|
+
const ids = globalThis[CAUGHT_NOT_FOUND_BOUNDARIES_GLOBAL];
|
|
44
|
+
const index = ids?.indexOf(id) ?? -1;
|
|
45
|
+
if (index !== -1) ids.splice(index, 1);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { CAUGHT_NOT_FOUND_BOUNDARIES_GLOBAL, CaughtNotFoundBoundariesContext, consumeCaughtNotFoundBoundary, useCaughtNotFoundBoundary, withCaughtNotFoundBoundaries };
|
|
@@ -32,6 +32,12 @@ export type CdnCacheableHeaderInput = {
|
|
|
32
32
|
*/
|
|
33
33
|
tags?: readonly string[];
|
|
34
34
|
};
|
|
35
|
+
/** A page's document, rendered from an RSC request's payload. */
|
|
36
|
+
export type CdnAppPageDocument = {
|
|
37
|
+
html: string;
|
|
38
|
+
/** The renderer's own `Link` header. */
|
|
39
|
+
linkHeader?: string;
|
|
40
|
+
};
|
|
35
41
|
export type CdnResponsePolicy = {
|
|
36
42
|
/** Whether a provider-specific response header controls shared caching. */
|
|
37
43
|
isHeader(name: string): boolean;
|
|
@@ -76,12 +82,15 @@ export type CdnCacheAdapter = {
|
|
|
76
82
|
*/
|
|
77
83
|
readonly requiresCompletedResponseAdmission?: boolean;
|
|
78
84
|
/**
|
|
79
|
-
* This adapter's response-stage transport keys shared
|
|
80
|
-
* `VinextResponseStageDispatchOptions.cacheIdentity` when core supplies
|
|
81
|
-
* Core supplies it only when completed-response admission is also
|
|
82
|
-
* because that admission is what makes a
|
|
85
|
+
* This adapter's response-stage transport keys shared dispatches by
|
|
86
|
+
* `VinextResponseStageDispatchOptions.cacheIdentity` when core supplies
|
|
87
|
+
* one. Core supplies it only when completed-response admission is also
|
|
88
|
+
* required, because that admission is what makes a host-free identity, and
|
|
89
|
+
* a page's query-free one, safe. `"query-free"` also drops the user query
|
|
90
|
+
* from App page identities; `"host-free"` keeps every dispatch's query, for
|
|
91
|
+
* a transport whose cache keys the dispatched query itself.
|
|
83
92
|
*/
|
|
84
|
-
readonly responseStageCacheIdentity?: "query-free";
|
|
93
|
+
readonly responseStageCacheIdentity?: "host-free" | "query-free";
|
|
85
94
|
/**
|
|
86
95
|
* Optionally return a foreground page response while completed-response
|
|
87
96
|
* admission continues on an independent body branch. Returning `null` keeps
|
|
@@ -90,6 +99,14 @@ export type CdnCacheAdapter = {
|
|
|
90
99
|
deferCompletedPageResponseAdmission?(response: Response, complete: (response: Response) => Promise<Response>): Response | null;
|
|
91
100
|
/** Capture the full-route RSC side stream while admitting a completed HTML response. */
|
|
92
101
|
captureAppPageRscData?(rscData: Promise<ArrayBuffer>): void;
|
|
102
|
+
/**
|
|
103
|
+
* Store the page's document beside an RSC request's completed response, as
|
|
104
|
+
* Next.js keeps a page's document and RSC payload in one entry. Returns the
|
|
105
|
+
* callback admission calls with the document the render rendered from its
|
|
106
|
+
* payload, or with `null` when the page has no document to store, or
|
|
107
|
+
* `undefined` when this render's response stores no document.
|
|
108
|
+
*/
|
|
109
|
+
captureAppPageDocument?(): ((document: CdnAppPageDocument | null) => void) | undefined;
|
|
93
110
|
/**
|
|
94
111
|
* Whether this adapter sends the 304 for a Pages render whose If-None-Match
|
|
95
112
|
* matches. When it does, the render returns the page, so an adapter that
|