@qzsy/vinext 0.1.12 → 0.1.123
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/check.d.ts +8 -0
- package/dist/check.js +20 -9
- package/dist/cli.js +2 -2
- package/dist/deploy.js +10 -11
- package/dist/entries/app-rsc-entry.js +37 -8
- package/dist/entries/app-rsc-manifest.js +8 -0
- package/dist/entries/pages-client-entry.js +1 -0
- package/dist/entries/pages-server-entry.js +1 -0
- package/dist/index.js +12 -8
- package/dist/init.js +2 -1
- package/dist/plugins/middleware-server-only.d.ts +8 -6
- package/dist/plugins/middleware-server-only.js +8 -7
- package/dist/routing/app-route-graph.d.ts +6 -2
- package/dist/routing/app-route-graph.js +60 -12
- package/dist/routing/app-router.d.ts +5 -0
- package/dist/routing/app-router.js +5 -0
- package/dist/routing/file-matcher.d.ts +5 -0
- package/dist/routing/file-matcher.js +7 -1
- package/dist/server/app-browser-history-controller.d.ts +2 -1
- package/dist/server/app-browser-history-controller.js +6 -2
- package/dist/server/app-fallback-renderer.d.ts +1 -1
- package/dist/server/app-fallback-renderer.js +2 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +12 -3
- package/dist/server/app-page-cache-finalizer.d.ts +1 -0
- package/dist/server/app-page-cache-finalizer.js +8 -2
- package/dist/server/app-page-dispatch.d.ts +11 -3
- package/dist/server/app-page-dispatch.js +54 -15
- package/dist/server/app-page-element-builder.d.ts +5 -1
- package/dist/server/app-page-element-builder.js +55 -19
- package/dist/server/app-page-head.d.ts +12 -0
- package/dist/server/app-page-head.js +42 -19
- package/dist/server/app-page-params.d.ts +2 -1
- package/dist/server/app-page-params.js +8 -1
- package/dist/server/app-page-probe.d.ts +1 -0
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render.d.ts +4 -1
- package/dist/server/app-page-render.js +8 -3
- package/dist/server/app-page-request.d.ts +8 -1
- package/dist/server/app-page-request.js +23 -11
- package/dist/server/app-page-route-wiring.d.ts +6 -1
- package/dist/server/app-page-route-wiring.js +30 -8
- package/dist/server/app-page-search-params-observation.d.ts +4 -2
- package/dist/server/app-page-search-params-observation.js +11 -7
- package/dist/server/app-route-handler-dispatch.js +1 -0
- package/dist/server/app-route-handler-execution.js +2 -1
- package/dist/server/app-route-module-loader.d.ts +2 -0
- package/dist/server/app-route-module-loader.js +1 -0
- package/dist/server/app-router-entry.d.ts +12 -0
- package/dist/server/app-router-entry.js +13 -6
- package/dist/server/app-router-image-optimization.d.ts +37 -0
- package/dist/server/app-router-image-optimization.js +40 -0
- package/dist/server/app-rsc-errors.js +7 -1
- package/dist/server/app-rsc-handler.js +5 -2
- package/dist/server/app-rsc-route-matching.d.ts +7 -0
- package/dist/server/app-rsc-route-matching.js +36 -3
- package/dist/server/app-segment-config.d.ts +1 -0
- package/dist/server/app-segment-config.js +32 -2
- package/dist/server/app-server-action-execution.d.ts +4 -0
- package/dist/server/app-server-action-execution.js +41 -10
- package/dist/server/app-static-generation.d.ts +1 -0
- package/dist/server/app-static-generation.js +1 -0
- package/dist/server/headers.d.ts +3 -1
- package/dist/server/headers.js +3 -1
- package/dist/server/prod-server.js +15 -6
- package/dist/server/worker-utils.d.ts +2 -1
- package/dist/server/worker-utils.js +7 -1
- package/dist/shims/error-boundary.d.ts +19 -1
- package/dist/shims/error-boundary.js +11 -1
- package/dist/shims/headers.d.ts +3 -1
- package/dist/shims/headers.js +16 -5
- package/dist/shims/metadata.d.ts +3 -2
- package/dist/shims/metadata.js +8 -4
- package/dist/shims/router.js +13 -2
- package/dist/typegen.js +6 -5
- package/dist/utils/path.d.ts +2 -1
- package/dist/utils/path.js +1 -1
- package/dist/utils/project.d.ts +4 -0
- package/dist/utils/project.js +5 -1
- package/package.json +1 -1
package/dist/server/headers.js
CHANGED
|
@@ -101,6 +101,8 @@ const NEXT_ROUTER_STATE_TREE_HEADER = "Next-Router-State-Tree";
|
|
|
101
101
|
const NEXT_ROUTER_PREFETCH_HEADER = "Next-Router-Prefetch";
|
|
102
102
|
const NEXT_ROUTER_SEGMENT_PREFETCH_HEADER = "Next-Router-Segment-Prefetch";
|
|
103
103
|
const NEXT_URL_HEADER = "Next-Url";
|
|
104
|
+
const NEXT_REQUEST_ID_HEADER = "x-nextjs-request-id";
|
|
105
|
+
const NEXT_HTML_REQUEST_ID_HEADER = "x-nextjs-html-request-id";
|
|
104
106
|
/** Lowercase flight header variants used in middleware forwarding. */
|
|
105
107
|
const FLIGHT_HEADERS = [
|
|
106
108
|
"rsc",
|
|
@@ -133,4 +135,4 @@ const INTERNAL_HEADERS = [
|
|
|
133
135
|
/** Vinext-only internal headers stripped alongside Next.js protocol internals. */
|
|
134
136
|
const VINEXT_INTERNAL_HEADERS = [VINEXT_PRERENDER_ROUTE_PARAMS_HEADER];
|
|
135
137
|
//#endregion
|
|
136
|
-
export { ACTION_FORWARDED_HEADER, ACTION_REDIRECT_HEADER, ACTION_REDIRECT_STATUS_HEADER, ACTION_REDIRECT_TYPE_HEADER, ACTION_REVALIDATED_HEADER, FLIGHT_HEADERS, INTERNAL_HEADERS, MIDDLEWARE_HEADER_PREFIX, MIDDLEWARE_NEXT_HEADER, MIDDLEWARE_OVERRIDE_HEADERS, MIDDLEWARE_REQUEST_HEADER_PREFIX, MIDDLEWARE_REWRITE_HEADER, MIDDLEWARE_SET_COOKIE_HEADER, NEXTJS_ACTION_NOT_FOUND_HEADER, NEXTJS_CACHE_HEADER, NEXTJS_DEPLOYMENT_ID_HEADER, NEXT_ACTION_HEADER, NEXT_ROUTER_PREFETCH_HEADER, NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, NEXT_ROUTER_STATE_TREE_HEADER, NEXT_URL_HEADER, RSC_ACTION_HEADER, RSC_HEADER, VINEXT_CACHE_HEADER, VINEXT_CLIENT_REUSE_MANIFEST_HEADER, VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_INTERCEPTION_CONTEXT_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_MW_CTX_HEADER, VINEXT_PARAMS_HEADER, VINEXT_PRERENDER_PAGES_STATIC_PATHS_PATH, VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER, VINEXT_PRERENDER_STATIC_PARAMS_PATH, VINEXT_REVALIDATE_HEADER, VINEXT_RSC_MARKER_HEADER, VINEXT_RSC_REDIRECT_HEADER, VINEXT_RSC_RENDER_MODE_HEADER, VINEXT_STATIC_FILE_HEADER, VINEXT_TIMING_HEADER };
|
|
138
|
+
export { ACTION_FORWARDED_HEADER, ACTION_REDIRECT_HEADER, ACTION_REDIRECT_STATUS_HEADER, ACTION_REDIRECT_TYPE_HEADER, ACTION_REVALIDATED_HEADER, FLIGHT_HEADERS, INTERNAL_HEADERS, MIDDLEWARE_HEADER_PREFIX, MIDDLEWARE_NEXT_HEADER, MIDDLEWARE_OVERRIDE_HEADERS, MIDDLEWARE_REQUEST_HEADER_PREFIX, MIDDLEWARE_REWRITE_HEADER, MIDDLEWARE_SET_COOKIE_HEADER, NEXTJS_ACTION_NOT_FOUND_HEADER, NEXTJS_CACHE_HEADER, NEXTJS_DEPLOYMENT_ID_HEADER, NEXT_ACTION_HEADER, NEXT_HTML_REQUEST_ID_HEADER, NEXT_REQUEST_ID_HEADER, NEXT_ROUTER_PREFETCH_HEADER, NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, NEXT_ROUTER_STATE_TREE_HEADER, NEXT_URL_HEADER, RSC_ACTION_HEADER, RSC_HEADER, VINEXT_CACHE_HEADER, VINEXT_CLIENT_REUSE_MANIFEST_HEADER, VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_INTERCEPTION_CONTEXT_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_MW_CTX_HEADER, VINEXT_PARAMS_HEADER, VINEXT_PRERENDER_PAGES_STATIC_PATHS_PATH, VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER, VINEXT_PRERENDER_STATIC_PARAMS_PATH, VINEXT_REVALIDATE_HEADER, VINEXT_RSC_MARKER_HEADER, VINEXT_RSC_REDIRECT_HEADER, VINEXT_RSC_RENDER_MODE_HEADER, VINEXT_STATIC_FILE_HEADER, VINEXT_TIMING_HEADER };
|
|
@@ -819,13 +819,12 @@ async function startAppRouterServer(options) {
|
|
|
819
819
|
return;
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
|
+
let missingBuildAsset = false;
|
|
822
823
|
{
|
|
823
824
|
const assetLookupPath = resolveAppRouterAssetPath(pathname, appAssetPathPrefix, appRouterAssetPrefix);
|
|
824
825
|
if (assetLookupPath) {
|
|
825
826
|
if (await tryServeStatic(req, res, clientDir, assetLookupPath, compress, staticCache)) return;
|
|
826
|
-
|
|
827
|
-
res.end("Not Found");
|
|
828
|
-
return;
|
|
827
|
+
missingBuildAsset = true;
|
|
829
828
|
}
|
|
830
829
|
}
|
|
831
830
|
if (isImageOptimizationPath(pathname)) {
|
|
@@ -868,6 +867,12 @@ async function startAppRouterServer(options) {
|
|
|
868
867
|
await sendWebResponse(notFoundResponse({ headers: toWebHeaders(staticResponseHeaders) }), req, res, compress);
|
|
869
868
|
return;
|
|
870
869
|
}
|
|
870
|
+
if (missingBuildAsset && response.status === 404) {
|
|
871
|
+
cancelResponseBody(response);
|
|
872
|
+
res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
|
|
873
|
+
res.end("Not Found");
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
871
876
|
await sendWebResponse(response, req, res, compress);
|
|
872
877
|
} catch (e) {
|
|
873
878
|
console.error("[vinext] Server error:", e);
|
|
@@ -1000,11 +1005,9 @@ async function startPagesRouterServer(options) {
|
|
|
1000
1005
|
}
|
|
1001
1006
|
const staticLookupPath = stripBasePath(pathname, basePath);
|
|
1002
1007
|
const pagesAssetLookup = resolveAppRouterAssetPath(pathname, pagesAssetPathPrefix, assetPrefix);
|
|
1008
|
+
const missingBuildAsset = pagesAssetLookup !== null;
|
|
1003
1009
|
if (pagesAssetLookup) {
|
|
1004
1010
|
if (await tryServeStatic(req, res, clientDir, pagesAssetLookup, compress, staticCache)) return;
|
|
1005
|
-
res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
|
|
1006
|
-
res.end("Not Found");
|
|
1007
|
-
return;
|
|
1008
1011
|
}
|
|
1009
1012
|
if (isImageOptimizationPath(pathname) || isImageOptimizationPath(staticLookupPath)) {
|
|
1010
1013
|
const params = parseImageParams(new URL(rawUrl, "http://localhost"), allowedImageWidths, pagesImageConfig?.qualities);
|
|
@@ -1089,6 +1092,12 @@ async function startPagesRouterServer(options) {
|
|
|
1089
1092
|
if (result.type === "handled") return;
|
|
1090
1093
|
if (result.type === "response") {
|
|
1091
1094
|
const { response } = result;
|
|
1095
|
+
if (missingBuildAsset && response.status === 404) {
|
|
1096
|
+
cancelResponseBody(response);
|
|
1097
|
+
res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
|
|
1098
|
+
res.end("Not Found");
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1092
1101
|
if (isVinextStreamedHtmlResponse(response) || !response.body || result.defaultContentType === void 0) {
|
|
1093
1102
|
await sendWebResponse(response, req, res, compress);
|
|
1094
1103
|
return;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//#region src/server/worker-utils.d.ts
|
|
2
|
+
declare function finalizeMissingStaticAssetResponse(response: Response, missingBuildAsset: boolean): Response;
|
|
2
3
|
declare function mergeHeaders(response: Response, extraHeaders: Record<string, string | string[]>, statusOverride?: number): Response;
|
|
3
4
|
declare function resolveStaticAssetSignal(signalResponse: Response, options: {
|
|
4
5
|
fetchAsset(path: string): Promise<Response>;
|
|
5
6
|
}): Promise<Response | null>;
|
|
6
7
|
//#endregion
|
|
7
|
-
export { mergeHeaders, resolveStaticAssetSignal };
|
|
8
|
+
export { finalizeMissingStaticAssetResponse, mergeHeaders, resolveStaticAssetSignal };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VINEXT_STATIC_FILE_HEADER } from "./headers.js";
|
|
2
|
+
import { notFoundStaticAssetResponse } from "./http-error-responses.js";
|
|
2
3
|
//#region src/server/worker-utils.ts
|
|
3
4
|
/**
|
|
4
5
|
* Shared utilities for Cloudflare Worker entries.
|
|
@@ -29,6 +30,11 @@ function cancelResponseBody(response) {
|
|
|
29
30
|
if (!body || body.locked) return;
|
|
30
31
|
body.cancel().catch(() => {});
|
|
31
32
|
}
|
|
33
|
+
function finalizeMissingStaticAssetResponse(response, missingBuildAsset) {
|
|
34
|
+
if (!missingBuildAsset || response.status !== 404) return response;
|
|
35
|
+
cancelResponseBody(response);
|
|
36
|
+
return notFoundStaticAssetResponse();
|
|
37
|
+
}
|
|
32
38
|
function buildHeaderRecord(response, omitNames = []) {
|
|
33
39
|
const omitted = new Set(omitNames.map((name) => name.toLowerCase()));
|
|
34
40
|
const headers = {};
|
|
@@ -96,4 +102,4 @@ async function resolveStaticAssetSignal(signalResponse, options) {
|
|
|
96
102
|
return mergeHeaders(assetResponse, extraHeaders, assetResponse.ok && signalResponse.status !== 200 ? signalResponse.status : void 0);
|
|
97
103
|
}
|
|
98
104
|
//#endregion
|
|
99
|
-
export { mergeHeaders, resolveStaticAssetSignal };
|
|
105
|
+
export { finalizeMissingStaticAssetResponse, mergeHeaders, resolveStaticAssetSignal };
|
|
@@ -9,6 +9,24 @@ type ErrorBoundaryProps = {
|
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
resetKey?: string | null;
|
|
11
11
|
};
|
|
12
|
+
type SerializedBoundaryError = {
|
|
13
|
+
digest?: string;
|
|
14
|
+
message: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
stack?: string;
|
|
17
|
+
};
|
|
18
|
+
declare function SerializedErrorBoundary({
|
|
19
|
+
fallback: Fallback,
|
|
20
|
+
error
|
|
21
|
+
}: {
|
|
22
|
+
fallback: React.ComponentType<{
|
|
23
|
+
error: Error & {
|
|
24
|
+
digest?: string;
|
|
25
|
+
};
|
|
26
|
+
reset: () => void;
|
|
27
|
+
}>;
|
|
28
|
+
error: SerializedBoundaryError;
|
|
29
|
+
}): React.JSX.Element;
|
|
12
30
|
type CapturedError = {
|
|
13
31
|
thrownValue: unknown;
|
|
14
32
|
};
|
|
@@ -152,4 +170,4 @@ declare class DevRecoveryBoundary extends React.Component<DevRecoveryBoundaryPro
|
|
|
152
170
|
render(): React.ReactNode;
|
|
153
171
|
}
|
|
154
172
|
//#endregion
|
|
155
|
-
export { DevRecoveryBoundary, DevRecoveryBoundaryProps, ErrorBoundary, ErrorBoundaryInner, ErrorBoundaryProps, ErrorBoundaryState, ForbiddenBoundary, ForbiddenBoundaryInner, GlobalErrorBoundary, NotFoundBoundary, RedirectBoundary, RedirectErrorBoundary, UnauthorizedBoundary, UnauthorizedBoundaryInner };
|
|
173
|
+
export { DevRecoveryBoundary, DevRecoveryBoundaryProps, ErrorBoundary, ErrorBoundaryInner, ErrorBoundaryProps, ErrorBoundaryState, ForbiddenBoundary, ForbiddenBoundaryInner, GlobalErrorBoundary, NotFoundBoundary, RedirectBoundary, RedirectErrorBoundary, SerializedBoundaryError, SerializedErrorBoundary, UnauthorizedBoundary, UnauthorizedBoundaryInner };
|
|
@@ -9,6 +9,16 @@ import { isNavigationSignalError } from "../utils/navigation-signal.js";
|
|
|
9
9
|
import React from "react";
|
|
10
10
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
//#region src/shims/error-boundary.tsx
|
|
12
|
+
function SerializedErrorBoundary({ fallback: Fallback, error }) {
|
|
13
|
+
return /* @__PURE__ */ jsx(Fallback, {
|
|
14
|
+
error: Object.assign(new Error(error.message), {
|
|
15
|
+
digest: error.digest,
|
|
16
|
+
name: error.name ?? "Error",
|
|
17
|
+
stack: error.stack
|
|
18
|
+
}),
|
|
19
|
+
reset: () => globalThis.location?.reload()
|
|
20
|
+
});
|
|
21
|
+
}
|
|
12
22
|
function normalizeBoundaryResetKey(resetKey) {
|
|
13
23
|
return resetKey === void 0 || resetKey === null || resetKey === "" ? null : resetKey;
|
|
14
24
|
}
|
|
@@ -339,4 +349,4 @@ var DevRecoveryBoundary = class extends React.Component {
|
|
|
339
349
|
}
|
|
340
350
|
};
|
|
341
351
|
//#endregion
|
|
342
|
-
export { DevRecoveryBoundary, ErrorBoundary, ErrorBoundaryInner, ForbiddenBoundary, ForbiddenBoundaryInner, GlobalErrorBoundary, NotFoundBoundary, RedirectBoundary, RedirectErrorBoundary, UnauthorizedBoundary, UnauthorizedBoundaryInner };
|
|
352
|
+
export { DevRecoveryBoundary, ErrorBoundary, ErrorBoundaryInner, ForbiddenBoundary, ForbiddenBoundaryInner, GlobalErrorBoundary, NotFoundBoundary, RedirectBoundary, RedirectErrorBoundary, SerializedErrorBoundary, UnauthorizedBoundary, UnauthorizedBoundaryInner };
|
package/dist/shims/headers.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ type HeadersContext = {
|
|
|
5
5
|
headers: Headers;
|
|
6
6
|
cookies: Map<string, string>;
|
|
7
7
|
accessError?: Error;
|
|
8
|
+
draftModeEnabled?: boolean;
|
|
8
9
|
forceStatic?: boolean;
|
|
9
10
|
mutableCookies?: RequestCookies;
|
|
10
11
|
readonlyCookies?: RequestCookies;
|
|
@@ -47,6 +48,7 @@ type ConnectionProbeResult<T> = {
|
|
|
47
48
|
*/
|
|
48
49
|
declare function markDynamicUsage(): void;
|
|
49
50
|
declare function markRenderRequestApiUsage(kind: RenderRequestApiKind): void;
|
|
51
|
+
declare function throwIfStaticGenerationAccessError(): void;
|
|
50
52
|
declare function runWithConnectionProbe<T>(fn: () => T | Promise<T>): Promise<ConnectionProbeResult<T>>;
|
|
51
53
|
declare function suspendConnectionProbe(): Promise<never> | null;
|
|
52
54
|
declare function peekRenderRequestApiUsage(): RenderRequestApiKind[];
|
|
@@ -250,4 +252,4 @@ declare class RequestCookies {
|
|
|
250
252
|
toString(): string;
|
|
251
253
|
}
|
|
252
254
|
//#endregion
|
|
253
|
-
export { HeadersAccessPhase, HeadersContext, type RequestCookies, VinextHeadersShimState, applyMiddlewareRequestHeaders, consumeDynamicUsage, consumeInvalidDynamicUsageError, consumeRenderRequestApiUsage, cookies, draftMode, getAndClearPendingCookies, getDraftModeCookieHeader, getHeadersAccessPhase, getHeadersContext, headers, headersContextFromRequest, isDraftModeRequest, markDynamicUsage, markRenderRequestApiUsage, peekDynamicUsage, peekRenderRequestApiUsage, runWithConnectionProbe, runWithHeadersContext, setHeadersAccessPhase, setHeadersContext, suspendConnectionProbe, throwIfInsideCacheScope };
|
|
255
|
+
export { HeadersAccessPhase, HeadersContext, type RequestCookies, VinextHeadersShimState, applyMiddlewareRequestHeaders, consumeDynamicUsage, consumeInvalidDynamicUsageError, consumeRenderRequestApiUsage, cookies, draftMode, getAndClearPendingCookies, getDraftModeCookieHeader, getHeadersAccessPhase, getHeadersContext, headers, headersContextFromRequest, isDraftModeRequest, markDynamicUsage, markRenderRequestApiUsage, peekDynamicUsage, peekRenderRequestApiUsage, runWithConnectionProbe, runWithHeadersContext, setHeadersAccessPhase, setHeadersContext, suspendConnectionProbe, throwIfInsideCacheScope, throwIfStaticGenerationAccessError };
|
package/dist/shims/headers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getOrCreateAls } from "./internal/als-registry.js";
|
|
2
2
|
import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
|
|
3
|
-
import { MIDDLEWARE_SET_COOKIE_HEADER } from "../server/headers.js";
|
|
3
|
+
import { FLIGHT_HEADERS, MIDDLEWARE_SET_COOKIE_HEADER, NEXT_HTML_REQUEST_ID_HEADER, NEXT_REQUEST_ID_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
6
|
import { parseEdgeRequestCookieHeader } from "../utils/parse-cookie.js";
|
|
@@ -117,6 +117,10 @@ function markDynamicUsage() {
|
|
|
117
117
|
function markRenderRequestApiUsage(kind) {
|
|
118
118
|
_getState().renderRequestApiUsage.add(kind);
|
|
119
119
|
}
|
|
120
|
+
function throwIfStaticGenerationAccessError() {
|
|
121
|
+
const accessError = _getState().headersContext?.accessError;
|
|
122
|
+
if (accessError) throw accessError;
|
|
123
|
+
}
|
|
120
124
|
async function runWithConnectionProbe(fn) {
|
|
121
125
|
const state = _getState();
|
|
122
126
|
const previousProbe = state.connectionProbe;
|
|
@@ -468,7 +472,13 @@ function _getReadonlyCookies(ctx) {
|
|
|
468
472
|
return ctx.readonlyCookies;
|
|
469
473
|
}
|
|
470
474
|
function _getReadonlyHeaders(ctx) {
|
|
471
|
-
if (!ctx.readonlyHeaders)
|
|
475
|
+
if (!ctx.readonlyHeaders) {
|
|
476
|
+
const cleaned = new Headers(ctx.headers);
|
|
477
|
+
for (const header of FLIGHT_HEADERS) cleaned.delete(header);
|
|
478
|
+
cleaned.delete(NEXT_REQUEST_ID_HEADER);
|
|
479
|
+
cleaned.delete(NEXT_HTML_REQUEST_ID_HEADER);
|
|
480
|
+
ctx.readonlyHeaders = _sealHeaders(cleaned);
|
|
481
|
+
}
|
|
472
482
|
return ctx.readonlyHeaders;
|
|
473
483
|
}
|
|
474
484
|
/**
|
|
@@ -631,16 +641,16 @@ async function draftMode() {
|
|
|
631
641
|
const state = _getState();
|
|
632
642
|
const context = state.headersContext;
|
|
633
643
|
if (!context) throw createDraftModeScopeError("draftMode()");
|
|
634
|
-
if (context.accessError) throw context.accessError;
|
|
635
644
|
const secret = ensureContextDraftModeSecret(context);
|
|
636
645
|
return {
|
|
637
646
|
get isEnabled() {
|
|
638
|
-
return context.cookies.get(DRAFT_MODE_COOKIE) === secret;
|
|
647
|
+
return context.draftModeEnabled ?? context.cookies.get(DRAFT_MODE_COOKIE) === secret;
|
|
639
648
|
},
|
|
640
649
|
enable() {
|
|
641
650
|
throwIfInsideCacheScope("draftMode().enable()");
|
|
642
651
|
const activeContext = requireActiveDraftModeContext(state, context, "draftMode().enable()");
|
|
643
652
|
markDynamicUsage();
|
|
653
|
+
activeContext.draftModeEnabled = true;
|
|
644
654
|
activeContext.cookies.set(DRAFT_MODE_COOKIE, secret);
|
|
645
655
|
state.draftModeCookieHeader = `${DRAFT_MODE_COOKIE}=${secret}; ${draftModeCookieAttributes()}`;
|
|
646
656
|
},
|
|
@@ -648,6 +658,7 @@ async function draftMode() {
|
|
|
648
658
|
throwIfInsideCacheScope("draftMode().disable()");
|
|
649
659
|
const activeContext = requireActiveDraftModeContext(state, context, "draftMode().disable()");
|
|
650
660
|
markDynamicUsage();
|
|
661
|
+
activeContext.draftModeEnabled = false;
|
|
651
662
|
activeContext.cookies.delete(DRAFT_MODE_COOKIE);
|
|
652
663
|
state.draftModeCookieHeader = `${DRAFT_MODE_COOKIE}=; ${draftModeCookieAttributes()}; Expires=${DRAFT_MODE_EXPIRED_DATE}`;
|
|
653
664
|
}
|
|
@@ -751,4 +762,4 @@ var RequestCookies = class {
|
|
|
751
762
|
}
|
|
752
763
|
};
|
|
753
764
|
//#endregion
|
|
754
|
-
export { applyMiddlewareRequestHeaders, consumeDynamicUsage, consumeInvalidDynamicUsageError, consumeRenderRequestApiUsage, cookies, draftMode, getAndClearPendingCookies, getDraftModeCookieHeader, getHeadersAccessPhase, getHeadersContext, headers, headersContextFromRequest, isDraftModeRequest, markDynamicUsage, markRenderRequestApiUsage, peekDynamicUsage, peekRenderRequestApiUsage, runWithConnectionProbe, runWithHeadersContext, setHeadersAccessPhase, setHeadersContext, suspendConnectionProbe, throwIfInsideCacheScope };
|
|
765
|
+
export { applyMiddlewareRequestHeaders, consumeDynamicUsage, consumeInvalidDynamicUsageError, consumeRenderRequestApiUsage, cookies, draftMode, getAndClearPendingCookies, getDraftModeCookieHeader, getHeadersAccessPhase, getHeadersContext, headers, headersContextFromRequest, isDraftModeRequest, markDynamicUsage, markRenderRequestApiUsage, peekDynamicUsage, peekRenderRequestApiUsage, runWithConnectionProbe, runWithHeadersContext, setHeadersAccessPhase, setHeadersContext, suspendConnectionProbe, throwIfInsideCacheScope, throwIfStaticGenerationAccessError };
|
package/dist/shims/metadata.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ThenableParamsObserver } from "./thenable-params.js";
|
|
1
2
|
import React from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/shims/metadata.d.ts
|
|
@@ -18,7 +19,7 @@ type Viewport = {
|
|
|
18
19
|
* Resolve viewport config from a module. Handles both static `viewport` export
|
|
19
20
|
* and async `generateViewport()` function.
|
|
20
21
|
*/
|
|
21
|
-
declare function resolveModuleViewport(mod: Record<string, unknown>, params: Record<string, string | string[]
|
|
22
|
+
declare function resolveModuleViewport(mod: Record<string, unknown>, params: Record<string, string | string[]>, searchParams?: Record<string, string | string[]>, searchParamsObserver?: ThenableParamsObserver): Promise<Viewport | null>;
|
|
22
23
|
/**
|
|
23
24
|
* Merge viewport configs from multiple sources (layouts + page).
|
|
24
25
|
* Later entries override earlier ones.
|
|
@@ -267,7 +268,7 @@ declare function mergeMetadataEntries(entries: readonly MetadataMergeEntry[]): M
|
|
|
267
268
|
* resolution approach. If not provided, defaults to a promise that resolves
|
|
268
269
|
* to an empty object (so `await parent` never throws).
|
|
269
270
|
*/
|
|
270
|
-
declare function resolveModuleMetadata(mod: Record<string, unknown>, params?: Record<string, string | string[]>, searchParams?: Record<string, string | string[]>, parent?: Promise<Metadata
|
|
271
|
+
declare function resolveModuleMetadata(mod: Record<string, unknown>, params?: Record<string, string | string[]>, searchParams?: Record<string, string | string[]>, parent?: Promise<Metadata>, searchParamsObserver?: ThenableParamsObserver): Promise<Metadata | null>;
|
|
271
272
|
type MetadataHeadProps = {
|
|
272
273
|
metadata: Metadata;
|
|
273
274
|
pathname?: string;
|
package/dist/shims/metadata.js
CHANGED
|
@@ -13,10 +13,14 @@ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
|
13
13
|
* Resolve viewport config from a module. Handles both static `viewport` export
|
|
14
14
|
* and async `generateViewport()` function.
|
|
15
15
|
*/
|
|
16
|
-
async function resolveModuleViewport(mod, params) {
|
|
16
|
+
async function resolveModuleViewport(mod, params, searchParams, searchParamsObserver) {
|
|
17
17
|
if (typeof mod.generateViewport === "function") {
|
|
18
18
|
const asyncParams = makeThenableParams(params);
|
|
19
|
-
|
|
19
|
+
const props = searchParams === void 0 ? { params: asyncParams } : {
|
|
20
|
+
params: asyncParams,
|
|
21
|
+
searchParams: makeThenableParams(searchParams, searchParamsObserver)
|
|
22
|
+
};
|
|
23
|
+
return await mod.generateViewport(props);
|
|
20
24
|
}
|
|
21
25
|
if (mod.viewport && typeof mod.viewport === "object") return mod.viewport;
|
|
22
26
|
return null;
|
|
@@ -213,12 +217,12 @@ function mergeMetadataEntries(entries) {
|
|
|
213
217
|
* resolution approach. If not provided, defaults to a promise that resolves
|
|
214
218
|
* to an empty object (so `await parent` never throws).
|
|
215
219
|
*/
|
|
216
|
-
async function resolveModuleMetadata(mod, params = {}, searchParams, parent = Promise.resolve({})) {
|
|
220
|
+
async function resolveModuleMetadata(mod, params = {}, searchParams, parent = Promise.resolve({}), searchParamsObserver) {
|
|
217
221
|
if (typeof mod.generateMetadata === "function") {
|
|
218
222
|
const asyncParams = makeThenableParams(params);
|
|
219
223
|
const props = searchParams === void 0 ? { params: asyncParams } : {
|
|
220
224
|
params: asyncParams,
|
|
221
|
-
searchParams: makeThenableParams(searchParams)
|
|
225
|
+
searchParams: makeThenableParams(searchParams, searchParamsObserver)
|
|
222
226
|
};
|
|
223
227
|
return await (mod.generateMetadata.length >= 2 ? mod.generateMetadata(props, parent) : mod.generateMetadata(props));
|
|
224
228
|
}
|
package/dist/shims/router.js
CHANGED
|
@@ -186,6 +186,7 @@ function createPagesRouterRuntimeState() {
|
|
|
186
186
|
activeAbortController: null,
|
|
187
187
|
cancelPendingRenderCommit: null,
|
|
188
188
|
lastPathnameAndSearch: typeof window !== "undefined" ? window.location.pathname + window.location.search : "",
|
|
189
|
+
lastHash: typeof window !== "undefined" ? window.location.hash : "",
|
|
189
190
|
isFirstPopStateEvent: true,
|
|
190
191
|
routerDidNavigate: false,
|
|
191
192
|
deprecatedEventBridgeInstalled: false,
|
|
@@ -941,6 +942,7 @@ async function navigateClientData(url, initialTarget, controller, navId, assertS
|
|
|
941
942
|
if (!redirectedUrl) scheduleHardNavigationAndThrow(softRedirect, "Navigation redirected externally");
|
|
942
943
|
window.history.replaceState(window.history.state ?? {}, "", redirectedUrl);
|
|
943
944
|
routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
945
|
+
routerRuntimeState.lastHash = window.location.hash;
|
|
944
946
|
await navigateClientHtml(redirectedUrl, redirectedUrl, controller, navId, assertStillCurrent);
|
|
945
947
|
return;
|
|
946
948
|
}
|
|
@@ -1099,6 +1101,7 @@ async function navigateClientHtml(url, fetchUrl, controller, navId, assertStillC
|
|
|
1099
1101
|
if (pendingRedirectHistoryUrl) {
|
|
1100
1102
|
window.history.replaceState(window.history.state ?? {}, "", pendingRedirectHistoryUrl);
|
|
1101
1103
|
routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
1104
|
+
routerRuntimeState.lastHash = window.location.hash;
|
|
1102
1105
|
}
|
|
1103
1106
|
window.__NEXT_DATA__ = nextData;
|
|
1104
1107
|
applyVinextLocaleGlobals(window, nextData);
|
|
@@ -1153,6 +1156,7 @@ async function navigateClient(url, fetchUrl = url, options = {}, routeUrl = url)
|
|
|
1153
1156
|
if (!redirectedUrl) scheduleHardNavigationAndThrow(redirectLocation, "Navigation redirected externally");
|
|
1154
1157
|
window.history.replaceState(window.history.state ?? {}, "", redirectedUrl);
|
|
1155
1158
|
routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
1159
|
+
routerRuntimeState.lastHash = window.location.hash;
|
|
1156
1160
|
browserUrl = redirectedUrl;
|
|
1157
1161
|
htmlFetchUrl = redirectedUrl;
|
|
1158
1162
|
} else if (middlewareEffect?.rewriteTarget) {
|
|
@@ -1263,6 +1267,7 @@ function updateHistory(mode, fullUrl, navState) {
|
|
|
1263
1267
|
else window.history.replaceState(state, "", fullUrl);
|
|
1264
1268
|
routerRuntimeState.currentHistoryKey = key;
|
|
1265
1269
|
routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
|
|
1270
|
+
routerRuntimeState.lastHash = window.location.hash;
|
|
1266
1271
|
routerRuntimeState.routerDidNavigate = true;
|
|
1267
1272
|
}
|
|
1268
1273
|
function createHistoryKey() {
|
|
@@ -1519,6 +1524,10 @@ function getRouterStateKey(state) {
|
|
|
1519
1524
|
if (!isNextRouterState(state)) return void 0;
|
|
1520
1525
|
return typeof state.key === "string" ? state.key : void 0;
|
|
1521
1526
|
}
|
|
1527
|
+
function getTrackedPagesRouterAsPath() {
|
|
1528
|
+
const trackedUrl = new URL(routerRuntimeState.lastPathnameAndSearch, window.location.href);
|
|
1529
|
+
return removeNavigationLocalePrefix(stripBasePath(trackedUrl.pathname, __basePath) + trackedUrl.search);
|
|
1530
|
+
}
|
|
1522
1531
|
function handlePagesRouterPopState(e) {
|
|
1523
1532
|
const browserUrl = window.location.pathname + window.location.search;
|
|
1524
1533
|
const appUrl = stripBasePath(window.location.pathname, __basePath) + window.location.search;
|
|
@@ -1528,9 +1537,10 @@ function handlePagesRouterPopState(e) {
|
|
|
1528
1537
|
if (state !== null && state !== void 0 && !isNextRouterState(state)) return;
|
|
1529
1538
|
if (wasFirst && !routerRuntimeState.routerDidNavigate && isNextRouterState(state)) {
|
|
1530
1539
|
const currentLocale = window.__VINEXT_LOCALE__;
|
|
1531
|
-
if (state.options?.locale === currentLocale && typeof state.as === "string" &&
|
|
1540
|
+
if (state.options?.locale === currentLocale && typeof state.as === "string" && state.as === getTrackedPagesRouterAsPath()) return;
|
|
1532
1541
|
}
|
|
1533
|
-
const
|
|
1542
|
+
const currentHash = window.location.hash;
|
|
1543
|
+
const isHashOnly = browserUrl === routerRuntimeState.lastPathnameAndSearch && (currentHash !== routerRuntimeState.lastHash || currentHash !== "");
|
|
1534
1544
|
const targetKey = getRouterStateKey(state);
|
|
1535
1545
|
let forcedScroll;
|
|
1536
1546
|
if (manualScrollRestoration) {
|
|
@@ -1555,6 +1565,7 @@ function handlePagesRouterPopState(e) {
|
|
|
1555
1565
|
}
|
|
1556
1566
|
if (targetKey !== void 0) routerRuntimeState.currentHistoryKey = targetKey;
|
|
1557
1567
|
routerRuntimeState.lastPathnameAndSearch = browserUrl;
|
|
1568
|
+
routerRuntimeState.lastHash = currentHash;
|
|
1558
1569
|
if (isHashOnly) {
|
|
1559
1570
|
const hashUrl = appUrl + window.location.hash;
|
|
1560
1571
|
routerEvents.emit("hashChangeStart", hashUrl, { shallow: false });
|
package/dist/typegen.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { findDir } from "./utils/project.js";
|
|
2
|
+
import { normalizePathSeparators } from "./utils/path.js";
|
|
2
3
|
import { decodeRouteSegment, isInvisibleSegment } from "./routing/utils.js";
|
|
3
4
|
import { patternToNextFormat } from "./routing/route-validation.js";
|
|
4
5
|
import { compareStrings } from "./utils/compare.js";
|
|
@@ -15,17 +16,17 @@ import "./.next/types/routes.d.ts";
|
|
|
15
16
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
|
16
17
|
`;
|
|
17
18
|
async function generateRouteTypes(options) {
|
|
18
|
-
const root = path.resolve(options.root);
|
|
19
|
-
const appDir = options.appDir ? path.resolve(options.appDir) : findDir(root, "app", path.join("src", "app"));
|
|
20
|
-
const outPath = path.join(root, ".next", "types", "routes.d.ts");
|
|
19
|
+
const root = normalizePathSeparators(path.resolve(options.root));
|
|
20
|
+
const appDir = options.appDir ? normalizePathSeparators(path.resolve(options.appDir)) : findDir(root, "app", path.posix.join("src", "app"));
|
|
21
|
+
const outPath = path.posix.join(root, ".next", "types", "routes.d.ts");
|
|
21
22
|
const content = appDir ? renderRouteTypes(await collectRouteTypeModel(appDir, options.pageExtensions)) : renderRouteTypes(emptyRouteTypeModel());
|
|
22
|
-
await fs.mkdir(path.dirname(outPath), { recursive: true });
|
|
23
|
+
await fs.mkdir(path.posix.dirname(outPath), { recursive: true });
|
|
23
24
|
await fs.writeFile(outPath, content, "utf-8");
|
|
24
25
|
await ensureNextEnvFile(root);
|
|
25
26
|
return outPath;
|
|
26
27
|
}
|
|
27
28
|
async function ensureNextEnvFile(root) {
|
|
28
|
-
const envPath = path.join(root, "next-env.d.ts");
|
|
29
|
+
const envPath = path.posix.join(root, "next-env.d.ts");
|
|
29
30
|
try {
|
|
30
31
|
await fs.writeFile(envPath, NEXT_ENV_FILE_CONTENT, {
|
|
31
32
|
encoding: "utf-8",
|
package/dist/utils/path.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/utils/path.d.ts
|
|
2
|
+
declare const isWindows: boolean;
|
|
2
3
|
/**
|
|
3
4
|
* Convert Windows-style backslash path separators to forward slashes.
|
|
4
5
|
*
|
|
@@ -19,4 +20,4 @@ declare function stripViteModuleQuery(id: string): string;
|
|
|
19
20
|
* files like `headers.js.ts`. */
|
|
20
21
|
declare function stripJsExtension(name: string): string;
|
|
21
22
|
//#endregion
|
|
22
|
-
export { normalizePathSeparators, stripJsExtension, stripViteModuleQuery };
|
|
23
|
+
export { isWindows, normalizePathSeparators, stripJsExtension, stripViteModuleQuery };
|
package/dist/utils/path.js
CHANGED
|
@@ -27,4 +27,4 @@ function stripJsExtension(name) {
|
|
|
27
27
|
return name.endsWith(".js") ? name.slice(0, -3) : name;
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
|
-
export { normalizePathSeparators, stripJsExtension, stripViteModuleQuery };
|
|
30
|
+
export { isWindows, normalizePathSeparators, stripJsExtension, stripViteModuleQuery };
|
package/dist/utils/project.d.ts
CHANGED
|
@@ -66,6 +66,10 @@ declare function hasViteConfig(root: string): boolean;
|
|
|
66
66
|
* Return the first candidate directory (resolved against `root`) that exists,
|
|
67
67
|
* or null. Used to locate conventional `app`/`pages` directories that may live
|
|
68
68
|
* at the root or under `src/`.
|
|
69
|
+
*
|
|
70
|
+
* `root` and `candidates` must be forward-slash, and the returned path is
|
|
71
|
+
* forward-slash too: the candidate is joined with `path.posix.join`, which only
|
|
72
|
+
* stays canonical when its inputs already are.
|
|
69
73
|
*/
|
|
70
74
|
declare function findDir(root: string, ...candidates: string[]): string | null;
|
|
71
75
|
/**
|
package/dist/utils/project.js
CHANGED
|
@@ -193,10 +193,14 @@ function hasViteConfig(root) {
|
|
|
193
193
|
* Return the first candidate directory (resolved against `root`) that exists,
|
|
194
194
|
* or null. Used to locate conventional `app`/`pages` directories that may live
|
|
195
195
|
* at the root or under `src/`.
|
|
196
|
+
*
|
|
197
|
+
* `root` and `candidates` must be forward-slash, and the returned path is
|
|
198
|
+
* forward-slash too: the candidate is joined with `path.posix.join`, which only
|
|
199
|
+
* stays canonical when its inputs already are.
|
|
196
200
|
*/
|
|
197
201
|
function findDir(root, ...candidates) {
|
|
198
202
|
for (const candidate of candidates) {
|
|
199
|
-
const full = path.join(root, candidate);
|
|
203
|
+
const full = path.posix.join(root, candidate);
|
|
200
204
|
try {
|
|
201
205
|
if (fs.statSync(full).isDirectory()) return full;
|
|
202
206
|
} catch {}
|