vinext 0.1.2 → 0.1.4
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/client-build-config.d.ts +11 -2
- package/dist/build/client-build-config.js +17 -6
- package/dist/build/prerender.d.ts +9 -1
- package/dist/build/prerender.js +42 -12
- package/dist/build/run-prerender.d.ts +10 -2
- package/dist/build/run-prerender.js +15 -1
- package/dist/client/app-nav-failure-handler.d.ts +8 -0
- package/dist/client/app-nav-failure-handler.js +44 -0
- package/dist/client/pages-router-link-navigation.d.ts +33 -7
- package/dist/client/pages-router-link-navigation.js +32 -2
- package/dist/client/vinext-next-data.d.ts +18 -1
- package/dist/client/vinext-next-data.js +2 -0
- package/dist/client/window-next.d.ts +2 -1
- package/dist/client/window-next.js +12 -1
- package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +6 -1
- package/dist/config/config-matchers.d.ts +11 -1
- package/dist/config/config-matchers.js +87 -16
- package/dist/config/next-config.d.ts +46 -4
- package/dist/config/next-config.js +147 -48
- package/dist/config/tsconfig-paths.js +14 -1
- package/dist/deploy.d.ts +30 -11
- package/dist/deploy.js +200 -112
- package/dist/entries/app-browser-entry.d.ts +9 -3
- package/dist/entries/app-browser-entry.js +21 -3
- package/dist/entries/app-rsc-entry.d.ts +2 -0
- package/dist/entries/app-rsc-entry.js +65 -5
- package/dist/entries/app-rsc-manifest.js +2 -0
- package/dist/entries/app-ssr-entry.js +1 -1
- package/dist/entries/pages-client-entry.js +66 -20
- package/dist/entries/pages-server-entry.js +47 -31
- package/dist/index.js +417 -102
- package/dist/plugins/dynamic-preload-metadata.js +2 -4
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +152 -0
- package/dist/plugins/fonts.js +5 -4
- package/dist/plugins/optimize-imports.d.ts +2 -1
- package/dist/plugins/optimize-imports.js +11 -9
- package/dist/plugins/postcss.js +7 -7
- package/dist/plugins/strip-server-exports.d.ts +9 -7
- package/dist/plugins/strip-server-exports.js +493 -46
- package/dist/plugins/typeof-window.d.ts +14 -0
- package/dist/plugins/typeof-window.js +150 -0
- package/dist/routing/app-route-graph.d.ts +2 -1
- package/dist/routing/app-route-graph.js +46 -16
- package/dist/routing/file-matcher.d.ts +10 -1
- package/dist/routing/file-matcher.js +22 -1
- package/dist/routing/pages-router.js +3 -3
- package/dist/routing/utils.d.ts +35 -6
- package/dist/routing/utils.js +59 -7
- package/dist/server/api-handler.d.ts +6 -1
- package/dist/server/api-handler.js +21 -15
- package/dist/server/app-browser-action-result.d.ts +19 -6
- package/dist/server/app-browser-action-result.js +20 -11
- package/dist/server/app-browser-entry.js +175 -91
- package/dist/server/app-browser-error.d.ts +10 -6
- package/dist/server/app-browser-error.js +43 -8
- package/dist/server/app-browser-hydration.d.ts +2 -0
- package/dist/server/app-browser-hydration.js +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +5 -3
- package/dist/server/app-browser-navigation-controller.js +23 -2
- package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
- package/dist/server/app-browser-server-action-navigation.js +9 -0
- package/dist/server/app-browser-state.d.ts +1 -1
- package/dist/server/app-browser-state.js +19 -11
- package/dist/server/app-browser-stream.js +86 -43
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-elements-wire.d.ts +6 -1
- package/dist/server/app-elements-wire.js +14 -4
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-fallback-renderer.d.ts +1 -0
- package/dist/server/app-fallback-renderer.js +3 -1
- package/dist/server/app-optimistic-routing.js +2 -2
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +27 -14
- package/dist/server/app-page-cache-render.d.ts +53 -0
- package/dist/server/app-page-cache-render.js +91 -0
- package/dist/server/app-page-cache.d.ts +16 -2
- package/dist/server/app-page-cache.js +62 -1
- package/dist/server/app-page-dispatch.d.ts +26 -0
- package/dist/server/app-page-dispatch.js +149 -92
- package/dist/server/app-page-element-builder.d.ts +1 -0
- package/dist/server/app-page-element-builder.js +5 -2
- package/dist/server/app-page-execution.d.ts +6 -1
- package/dist/server/app-page-execution.js +21 -1
- package/dist/server/app-page-probe.d.ts +1 -0
- package/dist/server/app-page-probe.js +4 -0
- package/dist/server/app-page-render-observation.d.ts +3 -1
- package/dist/server/app-page-render-observation.js +17 -1
- package/dist/server/app-page-render.d.ts +12 -1
- package/dist/server/app-page-render.js +42 -4
- package/dist/server/app-page-request.d.ts +2 -0
- package/dist/server/app-page-request.js +2 -1
- package/dist/server/app-page-route-wiring.d.ts +3 -1
- package/dist/server/app-page-route-wiring.js +14 -5
- package/dist/server/app-page-stream.d.ts +15 -3
- package/dist/server/app-page-stream.js +11 -5
- package/dist/server/app-pages-bridge.d.ts +23 -1
- package/dist/server/app-pages-bridge.js +26 -17
- package/dist/server/app-ppr-fallback-shell-render.d.ts +17 -0
- package/dist/server/app-ppr-fallback-shell-render.js +26 -0
- package/dist/server/app-ppr-fallback-shell.d.ts +13 -1
- package/dist/server/app-ppr-fallback-shell.js +8 -1
- package/dist/server/app-route-handler-dispatch.js +9 -2
- package/dist/server/app-route-handler-policy.d.ts +1 -0
- package/dist/server/app-router-entry.js +5 -0
- package/dist/server/app-rsc-cache-busting.js +2 -0
- package/dist/server/app-rsc-handler.d.ts +28 -0
- package/dist/server/app-rsc-handler.js +195 -59
- package/dist/server/app-rsc-route-matching.d.ts +3 -0
- package/dist/server/app-rsc-route-matching.js +8 -2
- package/dist/server/app-segment-config.d.ts +9 -1
- package/dist/server/app-segment-config.js +12 -3
- package/dist/server/app-server-action-execution.d.ts +1 -0
- package/dist/server/app-server-action-execution.js +47 -15
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +84 -39
- package/dist/server/before-interactive-head.d.ts +17 -0
- package/dist/server/before-interactive-head.js +35 -0
- package/dist/server/cache-control.js +4 -0
- package/dist/server/csp.js +1 -4
- package/dist/server/dev-server.d.ts +2 -2
- package/dist/server/dev-server.js +321 -83
- package/dist/server/hybrid-route-priority.d.ts +22 -0
- package/dist/server/hybrid-route-priority.js +33 -0
- package/dist/server/image-optimization.d.ts +18 -9
- package/dist/server/image-optimization.js +37 -23
- package/dist/server/implicit-tags.d.ts +2 -1
- package/dist/server/implicit-tags.js +4 -1
- package/dist/server/middleware-matcher.js +12 -3
- package/dist/server/middleware-runtime.d.ts +3 -4
- package/dist/server/middleware-runtime.js +2 -0
- package/dist/server/navigation-planner.d.ts +135 -41
- package/dist/server/navigation-planner.js +138 -0
- package/dist/server/navigation-trace.d.ts +9 -1
- package/dist/server/navigation-trace.js +9 -1
- package/dist/server/operation-token.d.ts +40 -0
- package/dist/server/operation-token.js +85 -0
- package/dist/server/pages-api-route.d.ts +6 -0
- package/dist/server/pages-api-route.js +13 -2
- package/dist/server/pages-asset-tags.d.ts +2 -1
- package/dist/server/pages-asset-tags.js +6 -2
- package/dist/server/pages-data-route.d.ts +9 -2
- package/dist/server/pages-data-route.js +18 -6
- package/dist/server/pages-dev-module-url.d.ts +4 -0
- package/dist/server/pages-dev-module-url.js +15 -0
- package/dist/server/pages-document-initial-props.d.ts +4 -15
- package/dist/server/pages-document-initial-props.js +27 -56
- package/dist/server/pages-get-initial-props.d.ts +54 -4
- package/dist/server/pages-get-initial-props.js +43 -1
- package/dist/server/pages-i18n.js +2 -2
- package/dist/server/pages-node-compat.js +2 -2
- package/dist/server/pages-page-data.d.ts +11 -2
- package/dist/server/pages-page-data.js +207 -34
- package/dist/server/pages-page-handler.d.ts +4 -2
- package/dist/server/pages-page-handler.js +62 -23
- package/dist/server/pages-page-response.d.ts +4 -1
- package/dist/server/pages-page-response.js +11 -8
- package/dist/server/pages-readiness.js +1 -1
- package/dist/server/pages-request-pipeline.d.ts +8 -7
- package/dist/server/pages-request-pipeline.js +126 -47
- package/dist/server/pregenerated-concrete-paths.d.ts +1 -17
- package/dist/server/pregenerated-concrete-paths.js +2 -19
- package/dist/server/prerender-manifest.d.ts +33 -0
- package/dist/server/prerender-manifest.js +54 -0
- package/dist/server/prerender-route-params.d.ts +1 -2
- package/dist/server/prod-server.d.ts +3 -1
- package/dist/server/prod-server.js +50 -13
- package/dist/server/request-pipeline.d.ts +3 -15
- package/dist/server/request-pipeline.js +58 -47
- package/dist/server/rsc-stream-hints.d.ts +5 -1
- package/dist/server/rsc-stream-hints.js +6 -1
- package/dist/server/seed-cache.js +10 -18
- package/dist/server/static-file-cache.js +16 -4
- package/dist/shims/app-router-scroll-state.d.ts +3 -1
- package/dist/shims/app-router-scroll-state.js +14 -2
- package/dist/shims/app-router-scroll.d.ts +3 -0
- package/dist/shims/app-router-scroll.js +28 -18
- package/dist/shims/before-interactive-context.d.ts +14 -3
- package/dist/shims/cache-runtime.js +3 -2
- package/dist/shims/cache.d.ts +1 -0
- package/dist/shims/cache.js +1 -1
- package/dist/shims/cdn-cache.d.ts +5 -5
- package/dist/shims/document.d.ts +15 -20
- package/dist/shims/document.js +5 -8
- package/dist/shims/dynamic-preload-chunks.js +6 -4
- package/dist/shims/error-boundary.d.ts +2 -0
- package/dist/shims/error-boundary.js +7 -0
- package/dist/shims/error.js +3 -2
- package/dist/shims/error.react-server.d.ts +9 -0
- package/dist/shims/error.react-server.js +6 -0
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +45 -20
- package/dist/shims/hash-scroll.js +6 -1
- package/dist/shims/headers.js +29 -4
- package/dist/shims/image.js +9 -2
- package/dist/shims/internal/als-registry.js +28 -1
- package/dist/shims/internal/app-route-detection.js +8 -17
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
- package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
- package/dist/shims/internal/navigation-untracked.d.ts +35 -0
- package/dist/shims/internal/navigation-untracked.js +55 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +6 -7
- package/dist/shims/internal/pages-data-fetch-dedup.js +67 -14
- package/dist/shims/internal/pages-data-target.d.ts +7 -2
- package/dist/shims/internal/pages-data-target.js +17 -8
- package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
- package/dist/shims/internal/pages-router-accessor.js +13 -0
- package/dist/shims/internal/router-context.d.ts +2 -1
- package/dist/shims/internal/router-context.js +3 -1
- package/dist/shims/link.js +47 -19
- package/dist/shims/metadata.js +4 -4
- package/dist/shims/navigation.d.ts +8 -2
- package/dist/shims/navigation.js +63 -31
- package/dist/shims/ppr-fallback-shell.d.ts +5 -1
- package/dist/shims/ppr-fallback-shell.js +28 -7
- package/dist/shims/router.d.ts +18 -3
- package/dist/shims/router.js +512 -142
- package/dist/shims/script.js +8 -4
- package/dist/shims/server.d.ts +16 -1
- package/dist/shims/server.js +44 -12
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/built-asset-url.d.ts +4 -0
- package/dist/utils/built-asset-url.js +11 -0
- package/dist/utils/commonjs-loader.d.ts +16 -0
- package/dist/utils/commonjs-loader.js +100 -0
- package/dist/utils/deployment-id.d.ts +8 -0
- package/dist/utils/deployment-id.js +22 -0
- package/dist/utils/has-trailing-comma.d.ts +24 -0
- package/dist/utils/has-trailing-comma.js +62 -0
- package/dist/utils/html-limited-bots.d.ts +18 -1
- package/dist/utils/html-limited-bots.js +23 -1
- package/dist/utils/parse-cookie.d.ts +13 -0
- package/dist/utils/parse-cookie.js +52 -0
- package/dist/utils/path.d.ts +7 -1
- package/dist/utils/path.js +9 -1
- package/dist/utils/text-stream.d.ts +1 -1
- package/dist/utils/text-stream.js +2 -2
- package/dist/utils/vite-version.d.ts +12 -1
- package/dist/utils/vite-version.js +9 -1
- package/package.json +2 -2
- package/dist/shims/internal/parse-cookie-header.d.ts +0 -14
- package/dist/shims/internal/parse-cookie-header.js +0 -30
package/dist/shims/cache.d.ts
CHANGED
package/dist/shims/cache.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getOrCreateAls } from "./internal/als-registry.js";
|
|
2
2
|
import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
|
|
3
3
|
import { getRequestExecutionContext, runWithExecutionContext } from "./request-context.js";
|
|
4
|
+
import { makeHangingPromise } from "./internal/make-hanging-promise.js";
|
|
4
5
|
import { getHeadersAccessPhase, markDynamicUsage } from "./headers.js";
|
|
5
6
|
import { fnv1a64 } from "../utils/hash.js";
|
|
6
7
|
import { workUnitAsyncStorage } from "./internal/work-unit-async-storage.js";
|
|
7
|
-
import { makeHangingPromise } from "./internal/make-hanging-promise.js";
|
|
8
8
|
import { readCacheControlNumberField } from "../utils/cache-control-metadata.js";
|
|
9
9
|
import { encodeCacheTag, encodeCacheTags } from "../utils/encode-cache-tag.js";
|
|
10
10
|
import { getCdnCacheAdapter } from "./cdn-cache.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CacheHandlerValue, IncrementalCacheValue } from "./cache.js";
|
|
2
2
|
|
|
3
3
|
//#region src/shims/cdn-cache.d.ts
|
|
4
|
-
/** A map of response header name -> value the adapter wants applied. */
|
|
5
|
-
type CdnResponseHeaders = Record<string, string>;
|
|
4
|
+
/** A map of response header name -> value the adapter wants applied or removed. */
|
|
5
|
+
type CdnResponseHeaders = Record<string, string | null>;
|
|
6
6
|
type CdnCacheableHeaderInput = {
|
|
7
7
|
/**
|
|
8
8
|
* The cacheable `Cache-Control` value the framework computed for shared
|
|
@@ -50,9 +50,9 @@ type CdnCacheAdapter = {
|
|
|
50
50
|
*/
|
|
51
51
|
set(key: string, data: IncrementalCacheValue | null, ctx?: Record<string, unknown>): Promise<void>;
|
|
52
52
|
/**
|
|
53
|
-
* Build the response cache headers for a given
|
|
54
|
-
*
|
|
55
|
-
* `CDN-Cache-Control`)
|
|
53
|
+
* Build the response cache headers for a given policy. Returns a map so an
|
|
54
|
+
* adapter can emit more than one header (e.g. `Cache-Control` +
|
|
55
|
+
* `CDN-Cache-Control`) and remove stale adapter-owned headers with `null`.
|
|
56
56
|
*/
|
|
57
57
|
buildResponseHeaders(input: CdnCacheableHeaderInput): CdnResponseHeaders;
|
|
58
58
|
/**
|
package/dist/shims/document.d.ts
CHANGED
|
@@ -34,25 +34,23 @@ declare function Main(): React.JSX.Element;
|
|
|
34
34
|
*/
|
|
35
35
|
declare function NextScript(): React.JSX.Element;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* The
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* the same shape they'd see under real Next.js.
|
|
37
|
+
* Stand-ins for Next.js's `DocumentContext` / `DocumentInitialProps`.
|
|
38
|
+
* The signatures match Next.js so custom `_document.tsx` subclasses can use
|
|
39
|
+
* `ctx.renderPage()` enhancers and delegate through
|
|
40
|
+
* `await Document.getInitialProps(ctx)` with the expected public types.
|
|
42
41
|
*
|
|
43
42
|
* @see https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/utils.ts
|
|
44
43
|
*/
|
|
45
44
|
type DocumentContext = {
|
|
46
|
-
renderPage
|
|
45
|
+
renderPage: (options?: {
|
|
47
46
|
enhanceApp?: (App: React.ComponentType<{
|
|
48
47
|
children?: React.ReactNode;
|
|
49
|
-
}>) =>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
defaultGetInitialProps?: (ctx: DocumentContext, options?: {
|
|
48
|
+
}>) => React.ComponentType<{
|
|
49
|
+
children?: React.ReactNode;
|
|
50
|
+
}>;
|
|
51
|
+
enhanceComponent?: (Comp: React.ComponentType<unknown>) => React.ComponentType<unknown>;
|
|
52
|
+
} | ((Comp: React.ComponentType<unknown>) => React.ComponentType<unknown>)) => DocumentInitialProps | Promise<DocumentInitialProps>;
|
|
53
|
+
defaultGetInitialProps: (ctx: DocumentContext, options?: {
|
|
56
54
|
nonce?: string;
|
|
57
55
|
}) => Promise<DocumentInitialProps>;
|
|
58
56
|
pathname?: string;
|
|
@@ -83,14 +81,11 @@ declare class Document<P = {}> extends React.Component<P & {
|
|
|
83
81
|
children?: React.ReactNode;
|
|
84
82
|
}> {
|
|
85
83
|
/**
|
|
86
|
-
* `getInitialProps` is invoked by the SSR pipeline. The
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* delegate via `await Document.getInitialProps(ctx)` receive an empty shell
|
|
90
|
-
* (`html: ""`). This matches the runtime contract user code expects without
|
|
91
|
-
* pretending the chain is wired up.
|
|
84
|
+
* `getInitialProps` is invoked by the SSR pipeline. The runtime-provided
|
|
85
|
+
* `ctx.defaultGetInitialProps()` owns the page render and style collection,
|
|
86
|
+
* matching Next.js's canonical CSS-in-JS integration path.
|
|
92
87
|
*/
|
|
93
|
-
static getInitialProps(
|
|
88
|
+
static getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps>;
|
|
94
89
|
render(): React.ReactNode;
|
|
95
90
|
}
|
|
96
91
|
//#endregion
|
package/dist/shims/document.js
CHANGED
|
@@ -61,15 +61,12 @@ function NextScript() {
|
|
|
61
61
|
*/
|
|
62
62
|
var Document = class extends React.Component {
|
|
63
63
|
/**
|
|
64
|
-
* `getInitialProps` is invoked by the SSR pipeline. The
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* delegate via `await Document.getInitialProps(ctx)` receive an empty shell
|
|
68
|
-
* (`html: ""`). This matches the runtime contract user code expects without
|
|
69
|
-
* pretending the chain is wired up.
|
|
64
|
+
* `getInitialProps` is invoked by the SSR pipeline. The runtime-provided
|
|
65
|
+
* `ctx.defaultGetInitialProps()` owns the page render and style collection,
|
|
66
|
+
* matching Next.js's canonical CSS-in-JS integration path.
|
|
70
67
|
*/
|
|
71
|
-
static
|
|
72
|
-
return
|
|
68
|
+
static getInitialProps(ctx) {
|
|
69
|
+
return ctx.defaultGetInitialProps(ctx);
|
|
73
70
|
}
|
|
74
71
|
render() {
|
|
75
72
|
return /* @__PURE__ */ jsxs(Html, { children: [/* @__PURE__ */ jsx(Head, {}), /* @__PURE__ */ jsxs("body", { children: [/* @__PURE__ */ jsx(Main, {}), /* @__PURE__ */ jsx(NextScript, {})] })] });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { appendAssetDeploymentIdQuery } from "../utils/deployment-id.js";
|
|
2
3
|
import { useScriptNonce } from "./script-nonce-context.js";
|
|
3
4
|
import React from "react";
|
|
4
5
|
import * as ReactDOM from "react-dom";
|
|
@@ -51,8 +52,9 @@ function DynamicPreloadChunks(props) {
|
|
|
51
52
|
if (files.length === 0) return null;
|
|
52
53
|
const stylesheets = [];
|
|
53
54
|
for (const file of files) {
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
55
|
+
const assetHref = dynamicPreloadHref(file);
|
|
56
|
+
if (assetHref.endsWith(".css")) {
|
|
57
|
+
const href = appendAssetDeploymentIdQuery(assetHref);
|
|
56
58
|
stylesheets.push(React.createElement("link", {
|
|
57
59
|
key: href,
|
|
58
60
|
rel: "stylesheet",
|
|
@@ -62,13 +64,13 @@ function DynamicPreloadChunks(props) {
|
|
|
62
64
|
}));
|
|
63
65
|
continue;
|
|
64
66
|
}
|
|
65
|
-
if (
|
|
67
|
+
if (assetHref.endsWith(".js") && typeof ReactDOM.preload === "function") {
|
|
66
68
|
const preloadOptions = {
|
|
67
69
|
as: "script",
|
|
68
70
|
fetchPriority: "low",
|
|
69
71
|
nonce
|
|
70
72
|
};
|
|
71
|
-
ReactDOM.preload(
|
|
73
|
+
ReactDOM.preload(assetHref, preloadOptions);
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
return stylesheets.length > 0 ? React.createElement(React.Fragment, null, ...stylesheets) : null;
|
|
@@ -17,6 +17,7 @@ type RedirectBoundaryState = {
|
|
|
17
17
|
redirectType: "push" | "replace" | null;
|
|
18
18
|
};
|
|
19
19
|
type ErrorBoundaryInnerProps = {
|
|
20
|
+
isImplicitRootErrorBoundary?: boolean;
|
|
20
21
|
pathname: string | null;
|
|
21
22
|
} & ErrorBoundaryProps;
|
|
22
23
|
type ErrorBoundaryState = {
|
|
@@ -131,6 +132,7 @@ declare function UnauthorizedBoundary({
|
|
|
131
132
|
resetKey
|
|
132
133
|
}: UnauthorizedBoundaryProps): React.JSX.Element;
|
|
133
134
|
type DevRecoveryBoundaryProps = {
|
|
135
|
+
isImplicitRootErrorBoundary?: boolean;
|
|
134
136
|
resetKey: number;
|
|
135
137
|
onCatch?: (resetKey: number) => void;
|
|
136
138
|
children?: React.ReactNode;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { handleAppNavigationFailure } from "../client/app-nav-failure-handler.js";
|
|
2
3
|
import { decodeRedirectError, isRedirectError, usePathname, useRouter } from "./navigation.js";
|
|
4
|
+
import DefaultGlobalError from "./default-global-error.js";
|
|
3
5
|
import { VINEXT_DEV_ERROR_RECOVERY_EVENT } from "../utils/dev-error-recovery-event.js";
|
|
4
6
|
import { isNavigationSignalError } from "../utils/navigation-signal.js";
|
|
5
7
|
import React from "react";
|
|
@@ -98,6 +100,10 @@ var ErrorBoundaryInner = class extends React.Component {
|
|
|
98
100
|
}
|
|
99
101
|
static getDerivedStateFromProps(props, state) {
|
|
100
102
|
const nextResetState = readBoundaryResetState(props);
|
|
103
|
+
if (state.error && handleAppNavigationFailure(state.error.thrownValue)) return {
|
|
104
|
+
error: null,
|
|
105
|
+
...nextResetState
|
|
106
|
+
};
|
|
101
107
|
if (state.error && shouldResetBoundary(nextResetState, state)) return {
|
|
102
108
|
error: null,
|
|
103
109
|
...nextResetState
|
|
@@ -150,6 +156,7 @@ function GlobalErrorBoundary({ fallback, children }) {
|
|
|
150
156
|
return /* @__PURE__ */ jsx(ErrorBoundaryInner, {
|
|
151
157
|
pathname: usePathname(),
|
|
152
158
|
fallback,
|
|
159
|
+
isImplicitRootErrorBoundary: fallback === DefaultGlobalError,
|
|
153
160
|
children
|
|
154
161
|
});
|
|
155
162
|
}
|
package/dist/shims/error.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
2
2
|
import { RouterContext } from "./internal/router-context.js";
|
|
3
|
-
import { isNextRouterError
|
|
3
|
+
import { isNextRouterError } from "./navigation.js";
|
|
4
|
+
import { useUntrackedPathname } from "./internal/navigation-untracked.js";
|
|
4
5
|
import React from "react";
|
|
5
6
|
//#region src/shims/error.tsx
|
|
6
7
|
/**
|
|
@@ -104,7 +105,7 @@ function unstable_catchError(fallback) {
|
|
|
104
105
|
Fallback.displayName = fallback.name || "CatchErrorFallback";
|
|
105
106
|
function CatchErrorBoundary(allProps) {
|
|
106
107
|
const { children, ...rest } = allProps;
|
|
107
|
-
const pathname =
|
|
108
|
+
const pathname = useUntrackedPathname();
|
|
108
109
|
const isPagesRouter = React.useContext(RouterContext) !== null;
|
|
109
110
|
const forwardedProps = rest;
|
|
110
111
|
return React.createElement(_CatchError, {
|
|
@@ -40,6 +40,7 @@ type FetchCacheState = {
|
|
|
40
40
|
currentRequestTags: string[];
|
|
41
41
|
currentFetchSoftTags: string[];
|
|
42
42
|
currentFetchCacheMode: FetchCacheMode | null;
|
|
43
|
+
currentForceDynamicFetchDefault: boolean;
|
|
43
44
|
dynamicFetchUrls: Set<string>;
|
|
44
45
|
isFetchDedupeActive: boolean;
|
|
45
46
|
currentFetchDedupeEntries: Map<string, FetchDedupeEntry[]>;
|
|
@@ -84,6 +85,7 @@ declare function setCurrentFetchSoftTags(tags: string[]): void;
|
|
|
84
85
|
*/
|
|
85
86
|
declare function getCurrentFetchSoftTags(): string[];
|
|
86
87
|
declare function setCurrentFetchCacheMode(mode: FetchCacheMode | null): void;
|
|
88
|
+
declare function setCurrentForceDynamicFetchDefault(enabled: boolean): void;
|
|
87
89
|
/**
|
|
88
90
|
* Install the patched fetch and reset per-request tag state.
|
|
89
91
|
* Returns a cleanup function that clears tags.
|
|
@@ -131,4 +133,4 @@ declare function ensureFetchPatch(): void;
|
|
|
131
133
|
*/
|
|
132
134
|
declare function getOriginalFetch(): typeof globalThis.fetch;
|
|
133
135
|
//#endregion
|
|
134
|
-
export { FetchCacheMode, FetchCacheState, _resetPendingRefetches, addCollectedRequestTags, consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, getCurrentFetchSoftTags, getOriginalFetch, peekCacheableFetchObservations, peekDynamicFetchObservations, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, withFetchCache };
|
|
136
|
+
export { FetchCacheMode, FetchCacheState, _resetPendingRefetches, addCollectedRequestTags, consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, getCurrentFetchSoftTags, getOriginalFetch, peekCacheableFetchObservations, peekDynamicFetchObservations, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault, withFetchCache };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getOrCreateAls } from "./internal/als-registry.js";
|
|
2
2
|
import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
|
|
3
3
|
import { getRequestExecutionContext } from "./request-context.js";
|
|
4
|
+
import { markDynamicUsage } from "./headers.js";
|
|
4
5
|
import { encodeCacheTags } from "../utils/encode-cache-tag.js";
|
|
5
6
|
import { getDataCacheHandler } from "./cache.js";
|
|
6
7
|
//#region src/shims/fetch-cache.ts
|
|
@@ -32,6 +33,7 @@ import { getDataCacheHandler } from "./cache.js";
|
|
|
32
33
|
const HEADER_BLOCKLIST = ["traceparent", "tracestate"];
|
|
33
34
|
const CACHE_KEY_PREFIX = "v3";
|
|
34
35
|
const MAX_CACHE_KEY_BODY_BYTES = 1024 * 1024;
|
|
36
|
+
const ONE_YEAR_SECONDS = 31536e3;
|
|
35
37
|
var BodyTooLargeForCacheKeyError = class extends Error {
|
|
36
38
|
constructor() {
|
|
37
39
|
super("Fetch body too large for cache key generation");
|
|
@@ -292,6 +294,7 @@ const _fallbackState = _g[_FALLBACK_KEY] ??= {
|
|
|
292
294
|
currentRequestTags: [],
|
|
293
295
|
currentFetchSoftTags: [],
|
|
294
296
|
currentFetchCacheMode: null,
|
|
297
|
+
currentForceDynamicFetchDefault: false,
|
|
295
298
|
dynamicFetchUrls: /* @__PURE__ */ new Set(),
|
|
296
299
|
isFetchDedupeActive: false,
|
|
297
300
|
currentFetchDedupeEntries: /* @__PURE__ */ new Map()
|
|
@@ -309,6 +312,7 @@ function _resetFallbackState(isFetchDedupeActive) {
|
|
|
309
312
|
_fallbackState.currentRequestTags = [];
|
|
310
313
|
_fallbackState.currentFetchSoftTags = [];
|
|
311
314
|
_fallbackState.currentFetchCacheMode = null;
|
|
315
|
+
_fallbackState.currentForceDynamicFetchDefault = false;
|
|
312
316
|
_fallbackState.dynamicFetchUrls = /* @__PURE__ */ new Set();
|
|
313
317
|
_fallbackState.isFetchDedupeActive = isFetchDedupeActive;
|
|
314
318
|
_fallbackState.currentFetchDedupeEntries = /* @__PURE__ */ new Map();
|
|
@@ -319,6 +323,10 @@ function getFetchObservationUrl(input) {
|
|
|
319
323
|
function recordDynamicFetchObservation(input) {
|
|
320
324
|
_getState().dynamicFetchUrls.add(getFetchObservationUrl(input));
|
|
321
325
|
}
|
|
326
|
+
function markUncachedFetchForPageOutput(input) {
|
|
327
|
+
recordDynamicFetchObservation(input);
|
|
328
|
+
markDynamicUsage();
|
|
329
|
+
}
|
|
322
330
|
function recordCacheableFetchObservation(input) {
|
|
323
331
|
_getState().cacheableFetchUrls.add(getFetchObservationUrl(input));
|
|
324
332
|
}
|
|
@@ -382,16 +390,23 @@ function getCurrentFetchSoftTags() {
|
|
|
382
390
|
function setCurrentFetchCacheMode(mode) {
|
|
383
391
|
_getState().currentFetchCacheMode = mode;
|
|
384
392
|
}
|
|
393
|
+
function setCurrentForceDynamicFetchDefault(enabled) {
|
|
394
|
+
_getState().currentForceDynamicFetchDefault = enabled;
|
|
395
|
+
}
|
|
385
396
|
function isNoStoreFetch(cacheDirective, nextOpts) {
|
|
386
|
-
return cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate ===
|
|
397
|
+
return cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate === 0;
|
|
387
398
|
}
|
|
388
399
|
function isCacheableFetch(cacheDirective, nextOpts) {
|
|
389
|
-
return cacheDirective === "force-cache" || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0;
|
|
400
|
+
return cacheDirective === "force-cache" || nextOpts?.revalidate === false || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0;
|
|
390
401
|
}
|
|
391
402
|
function hasExplicitRevalidateValue(nextOpts) {
|
|
392
403
|
return nextOpts?.revalidate !== void 0;
|
|
393
404
|
}
|
|
394
|
-
function
|
|
405
|
+
function isFalsyRevalidate(nextOpts) {
|
|
406
|
+
return !nextOpts?.revalidate;
|
|
407
|
+
}
|
|
408
|
+
function resolveSegmentCacheDirective(cacheDirective, nextOpts, mode, forceDynamicFetchDefault) {
|
|
409
|
+
if (forceDynamicFetchDefault && (!mode || mode === "auto") && (cacheDirective === void 0 || cacheDirective === "default") && isFalsyRevalidate(nextOpts)) return "no-store";
|
|
395
410
|
if (!mode || mode === "auto") return cacheDirective;
|
|
396
411
|
switch (mode) {
|
|
397
412
|
case "force-cache": return "force-cache";
|
|
@@ -457,6 +472,20 @@ function cloneDedupeResponse(response) {
|
|
|
457
472
|
const [body1, body2] = response.body.tee();
|
|
458
473
|
return [buildDedupeClone(body1, response), buildDedupeClone(body2, response)];
|
|
459
474
|
}
|
|
475
|
+
function buildCachedFetchResponse(data, input) {
|
|
476
|
+
const response = new Response(data.body, {
|
|
477
|
+
status: data.status ?? 200,
|
|
478
|
+
headers: data.headers
|
|
479
|
+
});
|
|
480
|
+
Object.defineProperty(response, "url", {
|
|
481
|
+
value: data.url ?? getFetchObservationUrl(input),
|
|
482
|
+
configurable: true,
|
|
483
|
+
enumerable: true,
|
|
484
|
+
writable: false
|
|
485
|
+
});
|
|
486
|
+
if (_responseBodyRegistry && response.body) _responseBodyRegistry.register(response, new WeakRef(response.body));
|
|
487
|
+
return response;
|
|
488
|
+
}
|
|
460
489
|
function dedupeFetch(input, init) {
|
|
461
490
|
const state = _getState();
|
|
462
491
|
if (!state.isFetchDedupeActive) return originalFetch(input, init);
|
|
@@ -507,25 +536,26 @@ function dedupeFetch(input, init) {
|
|
|
507
536
|
function createPatchedFetch() {
|
|
508
537
|
return async function patchedFetch(input, init) {
|
|
509
538
|
const nextOpts = init?.next;
|
|
510
|
-
const cacheDirective = resolveSegmentCacheDirective(getFetchCacheDirective(input, init), nextOpts, _getState().currentFetchCacheMode);
|
|
539
|
+
const cacheDirective = resolveSegmentCacheDirective(getFetchCacheDirective(input, init), nextOpts, _getState().currentFetchCacheMode, _getState().currentForceDynamicFetchDefault);
|
|
511
540
|
if (!nextOpts && !cacheDirective) {
|
|
512
541
|
recordDynamicFetchObservation(input);
|
|
513
542
|
return dedupeFetch(input, init);
|
|
514
543
|
}
|
|
515
|
-
if (cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate ===
|
|
544
|
+
if (cacheDirective === "no-store" || cacheDirective === "no-cache" || nextOpts?.revalidate === 0) {
|
|
516
545
|
const cleanInit = stripNextFromInit(init, cacheDirective);
|
|
517
|
-
|
|
546
|
+
markUncachedFetchForPageOutput(input);
|
|
518
547
|
return dedupeFetch(input, cleanInit);
|
|
519
548
|
}
|
|
520
|
-
if (!(cacheDirective === "force-cache" || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0) && hasAuthHeaders(input, init)) {
|
|
549
|
+
if (!(cacheDirective === "force-cache" || nextOpts?.revalidate === false || typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0) && hasAuthHeaders(input, init)) {
|
|
521
550
|
const cleanInit = stripNextFromInit(init, cacheDirective);
|
|
522
551
|
recordDynamicFetchObservation(input);
|
|
523
552
|
return dedupeFetch(input, cleanInit);
|
|
524
553
|
}
|
|
525
554
|
let revalidateSeconds;
|
|
526
|
-
if (cacheDirective === "force-cache") revalidateSeconds = nextOpts?.revalidate && typeof nextOpts.revalidate === "number" ? nextOpts.revalidate :
|
|
555
|
+
if (cacheDirective === "force-cache") revalidateSeconds = nextOpts?.revalidate && typeof nextOpts.revalidate === "number" ? nextOpts.revalidate : ONE_YEAR_SECONDS;
|
|
556
|
+
else if (nextOpts?.revalidate === false) revalidateSeconds = ONE_YEAR_SECONDS;
|
|
527
557
|
else if (typeof nextOpts?.revalidate === "number" && nextOpts.revalidate > 0) revalidateSeconds = nextOpts.revalidate;
|
|
528
|
-
else if (nextOpts?.tags && nextOpts.tags.length > 0) revalidateSeconds =
|
|
558
|
+
else if (nextOpts?.tags && nextOpts.tags.length > 0) revalidateSeconds = ONE_YEAR_SECONDS;
|
|
529
559
|
else {
|
|
530
560
|
const cleanInit = stripNextFromInit(init, cacheDirective);
|
|
531
561
|
recordDynamicFetchObservation(input);
|
|
@@ -560,10 +590,7 @@ function createPatchedFetch() {
|
|
|
560
590
|
});
|
|
561
591
|
if (cached?.value && cached.value.kind === "FETCH" && cached.cacheState !== "stale") {
|
|
562
592
|
const cachedData = cached.value.data;
|
|
563
|
-
return
|
|
564
|
-
status: cachedData.status ?? 200,
|
|
565
|
-
headers: cachedData.headers
|
|
566
|
-
});
|
|
593
|
+
return buildCachedFetchResponse(cachedData, input);
|
|
567
594
|
}
|
|
568
595
|
if (cached?.value && cached.value.kind === "FETCH" && cached.cacheState === "stale") {
|
|
569
596
|
const staleData = cached.value.data;
|
|
@@ -581,7 +608,7 @@ function createPatchedFetch() {
|
|
|
581
608
|
data: {
|
|
582
609
|
headers: freshHeaders,
|
|
583
610
|
body: freshBody,
|
|
584
|
-
url:
|
|
611
|
+
url: freshResp.url,
|
|
585
612
|
status: freshResp.status
|
|
586
613
|
},
|
|
587
614
|
tags,
|
|
@@ -605,10 +632,7 @@ function createPatchedFetch() {
|
|
|
605
632
|
}, DEDUP_TIMEOUT_MS);
|
|
606
633
|
getRequestExecutionContext()?.waitUntil(refetchPromise);
|
|
607
634
|
}
|
|
608
|
-
return
|
|
609
|
-
status: staleData.status ?? 200,
|
|
610
|
-
headers: staleData.headers
|
|
611
|
-
});
|
|
635
|
+
return buildCachedFetchResponse(staleData, input);
|
|
612
636
|
}
|
|
613
637
|
} catch (cacheErr) {
|
|
614
638
|
console.error("[vinext] fetch cache read error:", cacheErr);
|
|
@@ -627,7 +651,7 @@ function createPatchedFetch() {
|
|
|
627
651
|
data: {
|
|
628
652
|
headers,
|
|
629
653
|
body,
|
|
630
|
-
url:
|
|
654
|
+
url: response.url,
|
|
631
655
|
status: cloned.status
|
|
632
656
|
},
|
|
633
657
|
tags,
|
|
@@ -700,6 +724,7 @@ async function runWithFetchCache(fn) {
|
|
|
700
724
|
currentRequestTags: [],
|
|
701
725
|
currentFetchSoftTags: [],
|
|
702
726
|
currentFetchCacheMode: null,
|
|
727
|
+
currentForceDynamicFetchDefault: false,
|
|
703
728
|
dynamicFetchUrls: /* @__PURE__ */ new Set(),
|
|
704
729
|
isFetchDedupeActive: true,
|
|
705
730
|
currentFetchDedupeEntries: /* @__PURE__ */ new Map()
|
|
@@ -738,4 +763,4 @@ function getOriginalFetch() {
|
|
|
738
763
|
return originalFetch;
|
|
739
764
|
}
|
|
740
765
|
//#endregion
|
|
741
|
-
export { _resetPendingRefetches, addCollectedRequestTags, consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, getCurrentFetchSoftTags, getOriginalFetch, peekCacheableFetchObservations, peekDynamicFetchObservations, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, withFetchCache };
|
|
766
|
+
export { _resetPendingRefetches, addCollectedRequestTags, consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, getCurrentFetchSoftTags, getOriginalFetch, peekCacheableFetchObservations, peekDynamicFetchObservations, runWithFetchCache, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags, setCurrentForceDynamicFetchDefault, withFetchCache };
|
|
@@ -17,7 +17,12 @@ function scrollToHashTarget(hash) {
|
|
|
17
17
|
idElement.scrollIntoView({ behavior: "auto" });
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
document.getElementsByName(fragment)[0]
|
|
20
|
+
const namedElement = document.getElementsByName(fragment)[0];
|
|
21
|
+
if (namedElement) {
|
|
22
|
+
namedElement.scrollIntoView({ behavior: "auto" });
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
window.scrollTo(0, 0);
|
|
21
26
|
}
|
|
22
27
|
function scrollToHashTargetOnNextFrame(hash) {
|
|
23
28
|
requestAnimationFrame(() => {
|
package/dist/shims/headers.js
CHANGED
|
@@ -3,7 +3,8 @@ import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation }
|
|
|
3
3
|
import { MIDDLEWARE_SET_COOKIE_HEADER } from "../server/headers.js";
|
|
4
4
|
import { buildRequestHeadersFromMiddlewareResponse } from "../server/middleware-request-headers.js";
|
|
5
5
|
import { serializeSetCookie, validateCookieAttributeValue, validateCookieName } from "./internal/cookie-serialize.js";
|
|
6
|
-
import {
|
|
6
|
+
import { parseEdgeRequestCookieHeader } from "../utils/parse-cookie.js";
|
|
7
|
+
import { createPprFallbackShellSuspensePromise } from "./ppr-fallback-shell.js";
|
|
7
8
|
//#region src/shims/headers.ts
|
|
8
9
|
/**
|
|
9
10
|
* next/headers shim
|
|
@@ -81,7 +82,7 @@ function setCookieNameValue(setCookie) {
|
|
|
81
82
|
function rebuildCookiesFromHeader(ctx, cookieHeader) {
|
|
82
83
|
ctx.cookies.clear();
|
|
83
84
|
if (cookieHeader === null) return;
|
|
84
|
-
const nextCookies =
|
|
85
|
+
const nextCookies = parseEdgeRequestCookieHeader(cookieHeader);
|
|
85
86
|
for (const [name, value] of nextCookies) ctx.cookies.set(name, value);
|
|
86
87
|
}
|
|
87
88
|
function mergeMiddlewareSetCookies(ctx, rawHeader) {
|
|
@@ -414,6 +415,26 @@ function _decorateRejectedRequestApiPromise(error) {
|
|
|
414
415
|
throw normalizedError;
|
|
415
416
|
} }));
|
|
416
417
|
}
|
|
418
|
+
function _decorateSuspendingRequestApiPromise(promise) {
|
|
419
|
+
return new Proxy(promise, {
|
|
420
|
+
get(promiseTarget, prop) {
|
|
421
|
+
if (prop === "then" || prop === "catch" || prop === "finally") {
|
|
422
|
+
const value = Reflect.get(promiseTarget, prop, promiseTarget);
|
|
423
|
+
return typeof value === "function" ? value.bind(promiseTarget) : value;
|
|
424
|
+
}
|
|
425
|
+
throw promise;
|
|
426
|
+
},
|
|
427
|
+
getOwnPropertyDescriptor() {
|
|
428
|
+
throw promise;
|
|
429
|
+
},
|
|
430
|
+
has() {
|
|
431
|
+
throw promise;
|
|
432
|
+
},
|
|
433
|
+
ownKeys() {
|
|
434
|
+
throw promise;
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
417
438
|
function _sealHeaders(headers) {
|
|
418
439
|
return new Proxy(headers, { get(target, prop) {
|
|
419
440
|
if (typeof prop === "string" && _HEADERS_MUTATING_METHODS.has(prop)) throw new ReadonlyHeadersError();
|
|
@@ -485,7 +506,7 @@ function headersContextFromRequest(request, options) {
|
|
|
485
506
|
let _cookies = null;
|
|
486
507
|
function getCookies() {
|
|
487
508
|
if (_cookies) return _cookies;
|
|
488
|
-
_cookies =
|
|
509
|
+
_cookies = parseEdgeRequestCookieHeader(headersProxy.get("cookie") || "");
|
|
489
510
|
return _cookies;
|
|
490
511
|
}
|
|
491
512
|
return {
|
|
@@ -512,6 +533,8 @@ function headers() {
|
|
|
512
533
|
if (!state.headersContext) return _decorateRejectedRequestApiPromise(/* @__PURE__ */ new Error("headers() can only be called from a Server Component, Route Handler, or Server Action. Make sure you're not calling it from a Client Component."));
|
|
513
534
|
if (state.headersContext.accessError) return _decorateRejectedRequestApiPromise(state.headersContext.accessError);
|
|
514
535
|
markDynamicUsage();
|
|
536
|
+
const fallbackShellPromise = createPprFallbackShellSuspensePromise("`headers()`");
|
|
537
|
+
if (fallbackShellPromise) return _decorateSuspendingRequestApiPromise(fallbackShellPromise);
|
|
515
538
|
return _getOrCreateDecoratedRequestApiPromise(_decoratedHeadersPromises, _getReadonlyHeaders(state.headersContext));
|
|
516
539
|
}
|
|
517
540
|
/**
|
|
@@ -529,6 +552,8 @@ function cookies() {
|
|
|
529
552
|
if (!state.headersContext) return _decorateRejectedRequestApiPromise(/* @__PURE__ */ new Error("cookies() can only be called from a Server Component, Route Handler, or Server Action."));
|
|
530
553
|
if (state.headersContext.accessError) return _decorateRejectedRequestApiPromise(state.headersContext.accessError);
|
|
531
554
|
markDynamicUsage();
|
|
555
|
+
const fallbackShellPromise = createPprFallbackShellSuspensePromise("`cookies()`");
|
|
556
|
+
if (fallbackShellPromise) return _decorateSuspendingRequestApiPromise(fallbackShellPromise);
|
|
532
557
|
return _getOrCreateDecoratedRequestApiPromise(_decoratedCookiesPromises, _areCookiesMutableInCurrentPhase() ? _getMutableCookies(state.headersContext) : _getReadonlyCookies(state.headersContext));
|
|
533
558
|
}
|
|
534
559
|
/** Accumulated Set-Cookie headers from cookies().set() / .delete() calls */
|
|
@@ -572,7 +597,7 @@ function ensureContextDraftModeSecret(ctx) {
|
|
|
572
597
|
function isDraftModeRequest(request, draftModeSecret) {
|
|
573
598
|
const cookieHeader = request.headers.get("cookie");
|
|
574
599
|
if (!cookieHeader) return false;
|
|
575
|
-
return
|
|
600
|
+
return parseEdgeRequestCookieHeader(cookieHeader).get(DRAFT_MODE_COOKIE) === validateDraftModeSecret(draftModeSecret);
|
|
576
601
|
}
|
|
577
602
|
function draftModeCookieAttributes() {
|
|
578
603
|
if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") return "Path=/; HttpOnly; SameSite=Lax";
|
package/dist/shims/image.js
CHANGED
|
@@ -175,6 +175,13 @@ function sanitizeBlurDataURL(url) {
|
|
|
175
175
|
function isRemoteUrl(src) {
|
|
176
176
|
return src.startsWith("http://") || src.startsWith("https://") || src.startsWith("//");
|
|
177
177
|
}
|
|
178
|
+
function isSvgUrl(src) {
|
|
179
|
+
try {
|
|
180
|
+
return new URL(src, "http://vinext.local").pathname.toLowerCase().endsWith(".svg");
|
|
181
|
+
} catch {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
178
185
|
function getFillStyle(style, backgroundStyle) {
|
|
179
186
|
return {
|
|
180
187
|
position: "absolute",
|
|
@@ -414,7 +421,7 @@ const Image = forwardRef(function Image({ src: srcProp, alt, width, height, fill
|
|
|
414
421
|
}
|
|
415
422
|
}
|
|
416
423
|
const imgQuality = quality ?? 75;
|
|
417
|
-
const isSvg = src
|
|
424
|
+
const isSvg = isSvgUrl(src);
|
|
418
425
|
const skipOptimization = _unoptimized === true || isSvg && !__dangerouslyAllowSVG;
|
|
419
426
|
const srcSet = imgWidth && !fill && !skipOptimization ? generateSrcSet(src, imgWidth, imgQuality) : imgWidth && !fill ? RESPONSIVE_WIDTHS.filter((w) => w <= imgWidth * 2).map((w) => `${src} ${w}w`).join(", ") || `${src} ${imgWidth}w` : void 0;
|
|
420
427
|
const optimizedSrc = skipOptimization ? src : imgWidth ? imageOptimizationUrl(src, imgWidth, imgQuality) : imageOptimizationUrl(src, RESPONSIVE_WIDTHS[0], imgQuality);
|
|
@@ -483,7 +490,7 @@ function getImageProps(props) {
|
|
|
483
490
|
width: imgWidth ?? 0,
|
|
484
491
|
quality: imgQuality
|
|
485
492
|
}) : src;
|
|
486
|
-
const isSvg = resolvedSrc
|
|
493
|
+
const isSvg = isSvgUrl(resolvedSrc);
|
|
487
494
|
const skipOpt = _unoptimized === true || isSvg && !__dangerouslyAllowSVG || blockedInProd || !!loader || isRemoteUrl(resolvedSrc);
|
|
488
495
|
const optimizedSrc = skipOpt ? resolvedSrc : imgWidth ? imageOptimizationUrl(resolvedSrc, imgWidth, imgQuality) : imageOptimizationUrl(resolvedSrc, RESPONSIVE_WIDTHS[0], imgQuality);
|
|
489
496
|
const srcSet = imgWidth && !fill && !isRemoteUrl(resolvedSrc) && !loader && !skipOpt ? generateSrcSet(resolvedSrc, imgWidth, imgQuality) : void 0;
|
|
@@ -38,6 +38,33 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
38
38
|
*/
|
|
39
39
|
const _g = globalThis;
|
|
40
40
|
/**
|
|
41
|
+
* No-op AsyncLocalStorage used when the runtime does not provide a usable
|
|
42
|
+
* `AsyncLocalStorage` constructor.
|
|
43
|
+
*
|
|
44
|
+
* In browser/client bundles `node:async_hooks` can resolve to a stub without a
|
|
45
|
+
* usable constructor (e.g. Vite's `__vite-browser-external`). Constructing such
|
|
46
|
+
* a value with `new` throws `TypeError: AsyncLocalStorage is not a constructor`
|
|
47
|
+
* at module-eval time, crashing every client-reachable shim that calls
|
|
48
|
+
* `getOrCreateAls` on import (request-context, headers, cache, …).
|
|
49
|
+
*
|
|
50
|
+
* Mirrors Next.js' `FakeAsyncLocalStorage` (and this repo's
|
|
51
|
+
* `async-hooks-stub.ts` client virtual module): `getStore()` returns
|
|
52
|
+
* `undefined` so shims fall back to their non-ALS code path, and the mutating
|
|
53
|
+
* methods are best-effort no-ops that still invoke the callback.
|
|
54
|
+
* See: https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/async-local-storage.ts
|
|
55
|
+
*/
|
|
56
|
+
var NoopAsyncLocalStorage = class {
|
|
57
|
+
getStore() {}
|
|
58
|
+
run(_store, fn, ...args) {
|
|
59
|
+
return fn(...args);
|
|
60
|
+
}
|
|
61
|
+
exit(fn, ...args) {
|
|
62
|
+
return fn(...args);
|
|
63
|
+
}
|
|
64
|
+
enterWith(_store) {}
|
|
65
|
+
disable() {}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
41
68
|
* Get (or lazily create) the AsyncLocalStorage registered on `globalThis`
|
|
42
69
|
* under `Symbol.for(key)`. Multiple callers — including callers in different
|
|
43
70
|
* module instances — that pass the same `key` receive the same ALS instance.
|
|
@@ -47,7 +74,7 @@ const _g = globalThis;
|
|
|
47
74
|
*/
|
|
48
75
|
function getOrCreateAls(key) {
|
|
49
76
|
const sym = Symbol.for(key);
|
|
50
|
-
return _g[sym] ??= new AsyncLocalStorage();
|
|
77
|
+
return _g[sym] ??= typeof AsyncLocalStorage === "function" ? new AsyncLocalStorage() : new NoopAsyncLocalStorage();
|
|
51
78
|
}
|
|
52
79
|
//#endregion
|
|
53
80
|
export { getOrCreateAls };
|