vinext 0.0.24 → 0.0.26
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 +30 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +6 -5
- package/dist/check.js.map +1 -1
- package/dist/cli.js +32 -1
- package/dist/cli.js.map +1 -1
- package/dist/client/entry.js +1 -1
- package/dist/client/entry.js.map +1 -1
- package/dist/client/vinext-next-data.d.ts +22 -0
- package/dist/client/vinext-next-data.d.ts.map +1 -0
- package/dist/client/vinext-next-data.js +2 -0
- package/dist/client/vinext-next-data.js.map +1 -0
- package/dist/config/config-matchers.d.ts +21 -0
- package/dist/config/config-matchers.d.ts.map +1 -1
- package/dist/config/config-matchers.js +52 -8
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.d.ts +39 -6
- package/dist/config/next-config.d.ts.map +1 -1
- package/dist/config/next-config.js +241 -48
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.d.ts +21 -0
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +94 -41
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +9 -0
- package/dist/entries/app-browser-entry.d.ts.map +1 -0
- package/dist/entries/app-browser-entry.js +340 -0
- package/dist/entries/app-browser-entry.js.map +1 -0
- package/dist/{server/app-dev-server.d.ts → entries/app-rsc-entry.d.ts} +6 -19
- package/dist/entries/app-rsc-entry.d.ts.map +1 -0
- package/dist/{server/app-dev-server.js → entries/app-rsc-entry.js} +572 -1293
- package/dist/entries/app-rsc-entry.js.map +1 -0
- package/dist/entries/app-ssr-entry.d.ts +8 -0
- package/dist/entries/app-ssr-entry.d.ts.map +1 -0
- package/dist/entries/app-ssr-entry.js +449 -0
- package/dist/entries/app-ssr-entry.js.map +1 -0
- package/dist/entries/pages-client-entry.d.ts +4 -0
- package/dist/entries/pages-client-entry.d.ts.map +1 -0
- package/dist/entries/pages-client-entry.js +94 -0
- package/dist/entries/pages-client-entry.js.map +1 -0
- package/dist/entries/pages-entry-helpers.d.ts +7 -0
- package/dist/entries/pages-entry-helpers.d.ts.map +1 -0
- package/dist/entries/pages-entry-helpers.js +18 -0
- package/dist/entries/pages-entry-helpers.js.map +1 -0
- package/dist/entries/pages-server-entry.d.ts +8 -0
- package/dist/entries/pages-server-entry.d.ts.map +1 -0
- package/dist/entries/pages-server-entry.js +993 -0
- package/dist/entries/pages-server-entry.js.map +1 -0
- package/dist/index.d.ts +4 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +345 -1227
- package/dist/index.js.map +1 -1
- package/dist/plugins/async-hooks-stub.d.ts +16 -0
- package/dist/plugins/async-hooks-stub.d.ts.map +1 -0
- package/dist/plugins/async-hooks-stub.js +45 -0
- package/dist/plugins/async-hooks-stub.js.map +1 -0
- package/dist/routing/app-router.d.ts +12 -6
- package/dist/routing/app-router.d.ts.map +1 -1
- package/dist/routing/app-router.js +19 -40
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/pages-router.d.ts.map +1 -1
- package/dist/routing/pages-router.js +3 -9
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/routing/utils.d.ts +9 -0
- package/dist/routing/utils.d.ts.map +1 -1
- package/dist/routing/utils.js +10 -0
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.d.ts.map +1 -1
- package/dist/server/api-handler.js +6 -0
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/dev-module-runner.d.ts +84 -0
- package/dist/server/dev-module-runner.d.ts.map +1 -0
- package/dist/server/dev-module-runner.js +105 -0
- package/dist/server/dev-module-runner.js.map +1 -0
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/instrumentation.d.ts +52 -9
- package/dist/server/instrumentation.d.ts.map +1 -1
- package/dist/server/instrumentation.js +52 -15
- package/dist/server/instrumentation.js.map +1 -1
- package/dist/server/middleware-codegen.d.ts +1 -1
- package/dist/server/middleware-codegen.js +1 -1
- package/dist/server/middleware-codegen.js.map +1 -1
- package/dist/server/middleware.d.ts +7 -3
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +16 -6
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/prod-server.d.ts.map +1 -1
- package/dist/server/prod-server.js +33 -28
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +92 -0
- package/dist/server/request-pipeline.d.ts.map +1 -0
- package/dist/server/request-pipeline.js +202 -0
- package/dist/server/request-pipeline.js.map +1 -0
- package/dist/shims/cache.d.ts.map +1 -1
- package/dist/shims/cache.js +14 -2
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/constants.d.ts +120 -3
- package/dist/shims/constants.d.ts.map +1 -1
- package/dist/shims/constants.js +170 -3
- package/dist/shims/constants.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts.map +1 -1
- package/dist/shims/fetch-cache.js +139 -29
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/form.d.ts.map +1 -1
- package/dist/shims/form.js +2 -3
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/headers.d.ts.map +1 -1
- package/dist/shims/headers.js +1 -0
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/layout-segment-context.d.ts +5 -4
- package/dist/shims/layout-segment-context.d.ts.map +1 -1
- package/dist/shims/layout-segment-context.js +6 -5
- package/dist/shims/layout-segment-context.js.map +1 -1
- package/dist/shims/link.d.ts.map +1 -1
- package/dist/shims/link.js +33 -18
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +7 -1
- package/dist/shims/metadata.d.ts.map +1 -1
- package/dist/shims/metadata.js +9 -3
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +14 -11
- package/dist/shims/navigation.d.ts.map +1 -1
- package/dist/shims/navigation.js +122 -102
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/og.d.ts +6 -6
- package/dist/shims/og.js +6 -6
- package/dist/shims/og.js.map +1 -1
- package/dist/shims/router.d.ts.map +1 -1
- package/dist/shims/router.js +37 -21
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/server.d.ts +2 -0
- package/dist/shims/server.d.ts.map +1 -1
- package/dist/shims/server.js +4 -0
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/url-utils.d.ts +13 -0
- package/dist/shims/url-utils.d.ts.map +1 -0
- package/dist/shims/url-utils.js +28 -0
- package/dist/shims/url-utils.js.map +1 -0
- package/dist/utils/project.d.ts +15 -0
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +48 -0
- package/dist/utils/project.js.map +1 -1
- package/package.json +1 -1
- package/dist/server/app-dev-server.d.ts.map +0 -1
- package/dist/server/app-dev-server.js.map +0 -1
package/dist/shims/constants.js
CHANGED
|
@@ -4,10 +4,177 @@
|
|
|
4
4
|
* Provides build/runtime phase constants used by next.config.js
|
|
5
5
|
* and some third-party libraries.
|
|
6
6
|
*/
|
|
7
|
+
export const MODERN_BROWSERSLIST_TARGET = [
|
|
8
|
+
"chrome 111",
|
|
9
|
+
"edge 111",
|
|
10
|
+
"firefox 111",
|
|
11
|
+
"safari 16.4",
|
|
12
|
+
];
|
|
13
|
+
export const COMPILER_NAMES = {
|
|
14
|
+
client: "client",
|
|
15
|
+
server: "server",
|
|
16
|
+
edgeServer: "edge-server",
|
|
17
|
+
};
|
|
18
|
+
export const COMPILER_INDEXES = {
|
|
19
|
+
[COMPILER_NAMES.client]: 0,
|
|
20
|
+
[COMPILER_NAMES.server]: 1,
|
|
21
|
+
[COMPILER_NAMES.edgeServer]: 2,
|
|
22
|
+
};
|
|
23
|
+
// Re-export entry constants for backward compatibility
|
|
24
|
+
export const UNDERSCORE_NOT_FOUND_ROUTE = "/_not-found";
|
|
25
|
+
export const UNDERSCORE_NOT_FOUND_ROUTE_ENTRY = `${UNDERSCORE_NOT_FOUND_ROUTE}/page`;
|
|
26
|
+
export const UNDERSCORE_GLOBAL_ERROR_ROUTE = "/_global-error";
|
|
27
|
+
export const UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY = `${UNDERSCORE_GLOBAL_ERROR_ROUTE}/page`;
|
|
28
|
+
export var AdapterOutputType;
|
|
29
|
+
(function (AdapterOutputType) {
|
|
30
|
+
/**
|
|
31
|
+
* `PAGES` represents all the React pages that are under `pages/`.
|
|
32
|
+
*/
|
|
33
|
+
AdapterOutputType["PAGES"] = "PAGES";
|
|
34
|
+
/**
|
|
35
|
+
* `PAGES_API` represents all the API routes under `pages/api/`.
|
|
36
|
+
*/
|
|
37
|
+
AdapterOutputType["PAGES_API"] = "PAGES_API";
|
|
38
|
+
/**
|
|
39
|
+
* `APP_PAGE` represents all the React pages that are under `app/` with the
|
|
40
|
+
* filename of `page.{j,t}s{,x}`.
|
|
41
|
+
*/
|
|
42
|
+
AdapterOutputType["APP_PAGE"] = "APP_PAGE";
|
|
43
|
+
/**
|
|
44
|
+
* `APP_ROUTE` represents all the API routes and metadata routes that are under `app/` with the
|
|
45
|
+
* filename of `route.{j,t}s{,x}`.
|
|
46
|
+
*/
|
|
47
|
+
AdapterOutputType["APP_ROUTE"] = "APP_ROUTE";
|
|
48
|
+
/**
|
|
49
|
+
* `PRERENDER` represents an ISR enabled route that might
|
|
50
|
+
* have a seeded cache entry or fallback generated during build
|
|
51
|
+
*/
|
|
52
|
+
AdapterOutputType["PRERENDER"] = "PRERENDER";
|
|
53
|
+
/**
|
|
54
|
+
* `STATIC_FILE` represents a static file (ie /_next/static)
|
|
55
|
+
*/
|
|
56
|
+
AdapterOutputType["STATIC_FILE"] = "STATIC_FILE";
|
|
57
|
+
/**
|
|
58
|
+
* `MIDDLEWARE` represents the middleware output if present
|
|
59
|
+
*/
|
|
60
|
+
AdapterOutputType["MIDDLEWARE"] = "MIDDLEWARE";
|
|
61
|
+
})(AdapterOutputType || (AdapterOutputType = {}));
|
|
62
|
+
export const PHASE_EXPORT = "phase-export";
|
|
63
|
+
export const PHASE_ANALYZE = "phase-analyze";
|
|
7
64
|
export const PHASE_PRODUCTION_BUILD = "phase-production-build";
|
|
8
|
-
export const PHASE_DEVELOPMENT_SERVER = "phase-development-server";
|
|
9
65
|
export const PHASE_PRODUCTION_SERVER = "phase-production-server";
|
|
10
|
-
export const
|
|
11
|
-
export const PHASE_INFO = "phase-info";
|
|
66
|
+
export const PHASE_DEVELOPMENT_SERVER = "phase-development-server";
|
|
12
67
|
export const PHASE_TEST = "phase-test";
|
|
68
|
+
export const PHASE_INFO = "phase-info";
|
|
69
|
+
export const PAGES_MANIFEST = "pages-manifest.json";
|
|
70
|
+
export const WEBPACK_STATS = "webpack-stats.json";
|
|
71
|
+
export const APP_PATHS_MANIFEST = "app-paths-manifest.json";
|
|
72
|
+
export const APP_PATH_ROUTES_MANIFEST = "app-path-routes-manifest.json";
|
|
73
|
+
export const BUILD_MANIFEST = "build-manifest.json";
|
|
74
|
+
export const FUNCTIONS_CONFIG_MANIFEST = "functions-config-manifest.json";
|
|
75
|
+
export const SUBRESOURCE_INTEGRITY_MANIFEST = "subresource-integrity-manifest";
|
|
76
|
+
export const NEXT_FONT_MANIFEST = "next-font-manifest";
|
|
77
|
+
export const EXPORT_MARKER = "export-marker.json";
|
|
78
|
+
export const EXPORT_DETAIL = "export-detail.json";
|
|
79
|
+
export const PRERENDER_MANIFEST = "prerender-manifest.json";
|
|
80
|
+
export const ROUTES_MANIFEST = "routes-manifest.json";
|
|
81
|
+
export const IMAGES_MANIFEST = "images-manifest.json";
|
|
82
|
+
export const SERVER_FILES_MANIFEST = "required-server-files";
|
|
83
|
+
export const DEV_CLIENT_PAGES_MANIFEST = "_devPagesManifest.json";
|
|
84
|
+
export const MIDDLEWARE_MANIFEST = "middleware-manifest.json";
|
|
85
|
+
export const TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST = "_clientMiddlewareManifest.json";
|
|
86
|
+
export const TURBOPACK_CLIENT_BUILD_MANIFEST = "client-build-manifest.json";
|
|
87
|
+
export const DEV_CLIENT_MIDDLEWARE_MANIFEST = "_devMiddlewareManifest.json";
|
|
88
|
+
export const REACT_LOADABLE_MANIFEST = "react-loadable-manifest.json";
|
|
89
|
+
export const SERVER_DIRECTORY = "server";
|
|
90
|
+
export const CONFIG_FILES = [
|
|
91
|
+
"next.config.js",
|
|
92
|
+
"next.config.mjs",
|
|
93
|
+
"next.config.ts",
|
|
94
|
+
// process.features can be undefined on Edge runtime
|
|
95
|
+
// TODO: Remove `as any` once we bump @types/node to v22.10.0+
|
|
96
|
+
...(process?.features?.typescript ? ["next.config.mts"] : []),
|
|
97
|
+
];
|
|
98
|
+
export const BUILD_ID_FILE = "BUILD_ID";
|
|
99
|
+
export const BLOCKED_PAGES = ["/_document", "/_app", "/_error"];
|
|
100
|
+
export const CLIENT_PUBLIC_FILES_PATH = "public";
|
|
101
|
+
export const CLIENT_STATIC_FILES_PATH = "static";
|
|
102
|
+
export const STRING_LITERAL_DROP_BUNDLE = "__NEXT_DROP_CLIENT_FILE__";
|
|
103
|
+
export const NEXT_BUILTIN_DOCUMENT = "__NEXT_BUILTIN_DOCUMENT__";
|
|
104
|
+
export const BARREL_OPTIMIZATION_PREFIX = "__barrel_optimize__";
|
|
105
|
+
// server/[entry]/page_client-reference-manifest.js
|
|
106
|
+
export const CLIENT_REFERENCE_MANIFEST = "client-reference-manifest";
|
|
107
|
+
// server/server-reference-manifest
|
|
108
|
+
export const SERVER_REFERENCE_MANIFEST = "server-reference-manifest";
|
|
109
|
+
// server/middleware-build-manifest.js
|
|
110
|
+
export const MIDDLEWARE_BUILD_MANIFEST = "middleware-build-manifest";
|
|
111
|
+
// server/middleware-react-loadable-manifest.js
|
|
112
|
+
export const MIDDLEWARE_REACT_LOADABLE_MANIFEST = "middleware-react-loadable-manifest";
|
|
113
|
+
// server/interception-route-rewrite-manifest.js
|
|
114
|
+
export const INTERCEPTION_ROUTE_REWRITE_MANIFEST = "interception-route-rewrite-manifest";
|
|
115
|
+
// server/dynamic-css-manifest.js
|
|
116
|
+
export const DYNAMIC_CSS_MANIFEST = "dynamic-css-manifest";
|
|
117
|
+
// static/runtime/main.js
|
|
118
|
+
export const CLIENT_STATIC_FILES_RUNTIME_MAIN = `main`;
|
|
119
|
+
export const CLIENT_STATIC_FILES_RUNTIME_MAIN_APP = `${CLIENT_STATIC_FILES_RUNTIME_MAIN}-app`;
|
|
120
|
+
// next internal client components chunk for layouts
|
|
121
|
+
export const APP_CLIENT_INTERNALS = "app-pages-internals";
|
|
122
|
+
// static/runtime/react-refresh.js
|
|
123
|
+
export const CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH = `react-refresh`;
|
|
124
|
+
// static/runtime/webpack.js
|
|
125
|
+
export const CLIENT_STATIC_FILES_RUNTIME_WEBPACK = `webpack`;
|
|
126
|
+
// static/runtime/polyfills.js
|
|
127
|
+
export const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS = "polyfills";
|
|
128
|
+
export const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL = Symbol(CLIENT_STATIC_FILES_RUNTIME_POLYFILLS);
|
|
129
|
+
export const DEFAULT_RUNTIME_WEBPACK = "webpack-runtime";
|
|
130
|
+
export const EDGE_RUNTIME_WEBPACK = "edge-runtime-webpack";
|
|
131
|
+
export const STATIC_PROPS_ID = "__N_SSG";
|
|
132
|
+
export const SERVER_PROPS_ID = "__N_SSP";
|
|
133
|
+
export const DEFAULT_SERIF_FONT = {
|
|
134
|
+
name: "Times New Roman",
|
|
135
|
+
xAvgCharWidth: 821,
|
|
136
|
+
azAvgWidth: 854.3953488372093,
|
|
137
|
+
unitsPerEm: 2048,
|
|
138
|
+
};
|
|
139
|
+
export const DEFAULT_SANS_SERIF_FONT = {
|
|
140
|
+
name: "Arial",
|
|
141
|
+
xAvgCharWidth: 904,
|
|
142
|
+
azAvgWidth: 934.5116279069767,
|
|
143
|
+
unitsPerEm: 2048,
|
|
144
|
+
};
|
|
145
|
+
export const STATIC_STATUS_PAGES = ["/500"];
|
|
146
|
+
export const TRACE_OUTPUT_VERSION = 1;
|
|
147
|
+
// in `MB`
|
|
148
|
+
export const TURBO_TRACE_DEFAULT_MEMORY_LIMIT = 6000;
|
|
149
|
+
export const RSC_MODULE_TYPES = {
|
|
150
|
+
client: "client",
|
|
151
|
+
server: "server",
|
|
152
|
+
};
|
|
153
|
+
// comparing
|
|
154
|
+
// https://nextjs.org/docs/api-reference/edge-runtime
|
|
155
|
+
// with
|
|
156
|
+
// https://nodejs.org/docs/latest/api/globals.html
|
|
157
|
+
export const EDGE_UNSUPPORTED_NODE_APIS = [
|
|
158
|
+
"clearImmediate",
|
|
159
|
+
"setImmediate",
|
|
160
|
+
"BroadcastChannel",
|
|
161
|
+
"ByteLengthQueuingStrategy",
|
|
162
|
+
"CompressionStream",
|
|
163
|
+
"CountQueuingStrategy",
|
|
164
|
+
"DecompressionStream",
|
|
165
|
+
"DomException",
|
|
166
|
+
"MessageChannel",
|
|
167
|
+
"MessageEvent",
|
|
168
|
+
"MessagePort",
|
|
169
|
+
"ReadableByteStreamController",
|
|
170
|
+
"ReadableStreamBYOBRequest",
|
|
171
|
+
"ReadableStreamDefaultController",
|
|
172
|
+
"TransformStreamDefaultController",
|
|
173
|
+
"WritableStreamDefaultController",
|
|
174
|
+
];
|
|
175
|
+
export const SYSTEM_ENTRYPOINTS = new Set([
|
|
176
|
+
CLIENT_STATIC_FILES_RUNTIME_MAIN,
|
|
177
|
+
CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH,
|
|
178
|
+
CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,
|
|
179
|
+
]);
|
|
13
180
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/shims/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AACjE,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AACvC,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC","sourcesContent":["/**\n * next/constants shim\n *\n * Provides build/runtime phase constants used by next.config.js\n * and some third-party libraries.\n */\n\nexport const PHASE_PRODUCTION_BUILD = \"phase-production-build\";\nexport const PHASE_DEVELOPMENT_SERVER = \"phase-development-server\";\nexport const PHASE_PRODUCTION_SERVER = \"phase-production-server\";\nexport const PHASE_EXPORT = \"phase-export\";\nexport const PHASE_INFO = \"phase-info\";\nexport const PHASE_TEST = \"phase-test\";\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/shims/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,YAAY;IACZ,UAAU;IACV,aAAa;IACb,aAAa;CACd,CAAC;AAIF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,aAAa;CACjB,CAAC;AAIX,MAAM,CAAC,MAAM,gBAAgB,GAEzB;IACF,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;IAC1B,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;IAC1B,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;CACtB,CAAC;AAEX,uDAAuD;AACvD,MAAM,CAAC,MAAM,0BAA0B,GAAG,aAAa,CAAC;AACxD,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,0BAA0B,OAAO,CAAC;AACrF,MAAM,CAAC,MAAM,6BAA6B,GAAG,gBAAgB,CAAC;AAC9D,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,6BAA6B,OAAO,CAAC;AAE3F,MAAM,CAAN,IAAY,iBAqCX;AArCD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aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,IAAI;CACjB,CAAC;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAM,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,UAAU;AACV,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,CAAC;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX,YAAY;AACZ,qDAAqD;AACrD,OAAO;AACP,kDAAkD;AAClD,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,gBAAgB;IAChB,cAAc;IACd,kBAAkB;IAClB,2BAA2B;IAC3B,mBAAmB;IACnB,sBAAsB;IACtB,qBAAqB;IACrB,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,aAAa;IACb,8BAA8B;IAC9B,2BAA2B;IAC3B,iCAAiC;IACjC,kCAAkC;IAClC,iCAAiC;CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAS;IAChD,gCAAgC;IAChC,yCAAyC;IACzC,oCAAoC;CACrC,CAAC,CAAC","sourcesContent":["/**\n * next/constants shim\n *\n * Provides build/runtime phase constants used by next.config.js\n * and some third-party libraries.\n */\n\nexport const MODERN_BROWSERSLIST_TARGET = [\n \"chrome 111\",\n \"edge 111\",\n \"firefox 111\",\n \"safari 16.4\",\n];\n\nexport type ValueOf<T> = Required<T>[keyof T];\n\nexport const COMPILER_NAMES = {\n client: \"client\",\n server: \"server\",\n edgeServer: \"edge-server\",\n} as const;\n\nexport type CompilerNameValues = ValueOf<typeof COMPILER_NAMES>;\n\nexport const COMPILER_INDEXES: {\n [compilerKey in CompilerNameValues]: number;\n} = {\n [COMPILER_NAMES.client]: 0,\n [COMPILER_NAMES.server]: 1,\n [COMPILER_NAMES.edgeServer]: 2,\n} as const;\n\n// Re-export entry constants for backward compatibility\nexport const UNDERSCORE_NOT_FOUND_ROUTE = \"/_not-found\";\nexport const UNDERSCORE_NOT_FOUND_ROUTE_ENTRY = `${UNDERSCORE_NOT_FOUND_ROUTE}/page`;\nexport const UNDERSCORE_GLOBAL_ERROR_ROUTE = \"/_global-error\";\nexport const UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY = `${UNDERSCORE_GLOBAL_ERROR_ROUTE}/page`;\n\nexport enum AdapterOutputType {\n /**\n * `PAGES` represents all the React pages that are under `pages/`.\n */\n PAGES = \"PAGES\",\n\n /**\n * `PAGES_API` represents all the API routes under `pages/api/`.\n */\n PAGES_API = \"PAGES_API\",\n /**\n * `APP_PAGE` represents all the React pages that are under `app/` with the\n * filename of `page.{j,t}s{,x}`.\n */\n APP_PAGE = \"APP_PAGE\",\n\n /**\n * `APP_ROUTE` represents all the API routes and metadata routes that are under `app/` with the\n * filename of `route.{j,t}s{,x}`.\n */\n APP_ROUTE = \"APP_ROUTE\",\n\n /**\n * `PRERENDER` represents an ISR enabled route that might\n * have a seeded cache entry or fallback generated during build\n */\n PRERENDER = \"PRERENDER\",\n\n /**\n * `STATIC_FILE` represents a static file (ie /_next/static)\n */\n STATIC_FILE = \"STATIC_FILE\",\n\n /**\n * `MIDDLEWARE` represents the middleware output if present\n */\n MIDDLEWARE = \"MIDDLEWARE\",\n}\n\nexport const PHASE_EXPORT = \"phase-export\";\nexport const PHASE_ANALYZE = \"phase-analyze\";\nexport const PHASE_PRODUCTION_BUILD = \"phase-production-build\";\nexport const PHASE_PRODUCTION_SERVER = \"phase-production-server\";\nexport const PHASE_DEVELOPMENT_SERVER = \"phase-development-server\";\nexport const PHASE_TEST = \"phase-test\";\nexport const PHASE_INFO = \"phase-info\";\n\nexport type PHASE_TYPE =\n | typeof PHASE_INFO\n | typeof PHASE_TEST\n | typeof PHASE_EXPORT\n | typeof PHASE_ANALYZE\n | typeof PHASE_PRODUCTION_BUILD\n | typeof PHASE_PRODUCTION_SERVER\n | typeof PHASE_DEVELOPMENT_SERVER;\n\nexport const PAGES_MANIFEST = \"pages-manifest.json\";\nexport const WEBPACK_STATS = \"webpack-stats.json\";\nexport const APP_PATHS_MANIFEST = \"app-paths-manifest.json\";\nexport const APP_PATH_ROUTES_MANIFEST = \"app-path-routes-manifest.json\";\nexport const BUILD_MANIFEST = \"build-manifest.json\";\nexport const FUNCTIONS_CONFIG_MANIFEST = \"functions-config-manifest.json\";\nexport const SUBRESOURCE_INTEGRITY_MANIFEST = \"subresource-integrity-manifest\";\nexport const NEXT_FONT_MANIFEST = \"next-font-manifest\";\nexport const EXPORT_MARKER = \"export-marker.json\";\nexport const EXPORT_DETAIL = \"export-detail.json\";\nexport const PRERENDER_MANIFEST = \"prerender-manifest.json\";\nexport const ROUTES_MANIFEST = \"routes-manifest.json\";\nexport const IMAGES_MANIFEST = \"images-manifest.json\";\nexport const SERVER_FILES_MANIFEST = \"required-server-files\";\nexport const DEV_CLIENT_PAGES_MANIFEST = \"_devPagesManifest.json\";\nexport const MIDDLEWARE_MANIFEST = \"middleware-manifest.json\";\nexport const TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST =\n \"_clientMiddlewareManifest.json\";\nexport const TURBOPACK_CLIENT_BUILD_MANIFEST = \"client-build-manifest.json\";\nexport const DEV_CLIENT_MIDDLEWARE_MANIFEST = \"_devMiddlewareManifest.json\";\nexport const REACT_LOADABLE_MANIFEST = \"react-loadable-manifest.json\";\nexport const SERVER_DIRECTORY = \"server\";\nexport const CONFIG_FILES = [\n \"next.config.js\",\n \"next.config.mjs\",\n \"next.config.ts\",\n // process.features can be undefined on Edge runtime\n // TODO: Remove `as any` once we bump @types/node to v22.10.0+\n ...((process?.features as any)?.typescript ? [\"next.config.mts\"] : []),\n];\nexport const BUILD_ID_FILE = \"BUILD_ID\";\nexport const BLOCKED_PAGES = [\"/_document\", \"/_app\", \"/_error\"];\nexport const CLIENT_PUBLIC_FILES_PATH = \"public\";\nexport const CLIENT_STATIC_FILES_PATH = \"static\";\nexport const STRING_LITERAL_DROP_BUNDLE = \"__NEXT_DROP_CLIENT_FILE__\";\nexport const NEXT_BUILTIN_DOCUMENT = \"__NEXT_BUILTIN_DOCUMENT__\";\nexport const BARREL_OPTIMIZATION_PREFIX = \"__barrel_optimize__\";\n\n// server/[entry]/page_client-reference-manifest.js\nexport const CLIENT_REFERENCE_MANIFEST = \"client-reference-manifest\";\n// server/server-reference-manifest\nexport const SERVER_REFERENCE_MANIFEST = \"server-reference-manifest\";\n// server/middleware-build-manifest.js\nexport const MIDDLEWARE_BUILD_MANIFEST = \"middleware-build-manifest\";\n// server/middleware-react-loadable-manifest.js\nexport const MIDDLEWARE_REACT_LOADABLE_MANIFEST =\n \"middleware-react-loadable-manifest\";\n// server/interception-route-rewrite-manifest.js\nexport const INTERCEPTION_ROUTE_REWRITE_MANIFEST =\n \"interception-route-rewrite-manifest\";\n// server/dynamic-css-manifest.js\nexport const DYNAMIC_CSS_MANIFEST = \"dynamic-css-manifest\";\n\n// static/runtime/main.js\nexport const CLIENT_STATIC_FILES_RUNTIME_MAIN = `main`;\nexport const CLIENT_STATIC_FILES_RUNTIME_MAIN_APP = `${CLIENT_STATIC_FILES_RUNTIME_MAIN}-app`;\n// next internal client components chunk for layouts\nexport const APP_CLIENT_INTERNALS = \"app-pages-internals\";\n// static/runtime/react-refresh.js\nexport const CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH = `react-refresh`;\n// static/runtime/webpack.js\nexport const CLIENT_STATIC_FILES_RUNTIME_WEBPACK = `webpack`;\n// static/runtime/polyfills.js\nexport const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS = \"polyfills\";\nexport const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL = Symbol(\n CLIENT_STATIC_FILES_RUNTIME_POLYFILLS,\n);\nexport const DEFAULT_RUNTIME_WEBPACK = \"webpack-runtime\";\nexport const EDGE_RUNTIME_WEBPACK = \"edge-runtime-webpack\";\nexport const STATIC_PROPS_ID = \"__N_SSG\";\nexport const SERVER_PROPS_ID = \"__N_SSP\";\nexport const DEFAULT_SERIF_FONT = {\n name: \"Times New Roman\",\n xAvgCharWidth: 821,\n azAvgWidth: 854.3953488372093,\n unitsPerEm: 2048,\n};\nexport const DEFAULT_SANS_SERIF_FONT = {\n name: \"Arial\",\n xAvgCharWidth: 904,\n azAvgWidth: 934.5116279069767,\n unitsPerEm: 2048,\n};\nexport const STATIC_STATUS_PAGES = [\"/500\"];\nexport const TRACE_OUTPUT_VERSION = 1;\n// in `MB`\nexport const TURBO_TRACE_DEFAULT_MEMORY_LIMIT = 6000;\n\nexport const RSC_MODULE_TYPES = {\n client: \"client\",\n server: \"server\",\n} as const;\n\n// comparing\n// https://nextjs.org/docs/api-reference/edge-runtime\n// with\n// https://nodejs.org/docs/latest/api/globals.html\nexport const EDGE_UNSUPPORTED_NODE_APIS = [\n \"clearImmediate\",\n \"setImmediate\",\n \"BroadcastChannel\",\n \"ByteLengthQueuingStrategy\",\n \"CompressionStream\",\n \"CountQueuingStrategy\",\n \"DecompressionStream\",\n \"DomException\",\n \"MessageChannel\",\n \"MessageEvent\",\n \"MessagePort\",\n \"ReadableByteStreamController\",\n \"ReadableStreamBYOBRequest\",\n \"ReadableStreamDefaultController\",\n \"TransformStreamDefaultController\",\n \"WritableStreamDefaultController\",\n];\n\nexport const SYSTEM_ENTRYPOINTS = new Set<string>([\n CLIENT_STATIC_FILES_RUNTIME_MAIN,\n CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH,\n CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,\n]);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-cache.d.ts","sourceRoot":"","sources":["../../src/shims/fetch-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"fetch-cache.d.ts","sourceRoot":"","sources":["../../src/shims/fetch-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AA0WH,UAAU,gBAAgB;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,WAAW;QACnB,IAAI,CAAC,EAAE,gBAAgB,CAAC;KACzB;CACF;AA0CD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD;AAoOD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,IAAI,MAAM,IAAI,CAO3C;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAG3E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,UAAU,CAAC,KAAK,CAE1D"}
|
|
@@ -30,13 +30,18 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
30
30
|
*/
|
|
31
31
|
const HEADER_BLOCKLIST = ["traceparent", "tracestate"];
|
|
32
32
|
// Cache key version — bump when changing the key format to bust stale entries
|
|
33
|
-
const CACHE_KEY_PREFIX = "
|
|
33
|
+
const CACHE_KEY_PREFIX = "v3";
|
|
34
34
|
const MAX_CACHE_KEY_BODY_BYTES = 1024 * 1024; // 1 MiB
|
|
35
35
|
class BodyTooLargeForCacheKeyError extends Error {
|
|
36
36
|
constructor() {
|
|
37
37
|
super("Fetch body too large for cache key generation");
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
class SkipCacheKeyGenerationError extends Error {
|
|
41
|
+
constructor() {
|
|
42
|
+
super("Fetch body could not be serialized for cache key generation");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
40
45
|
/**
|
|
41
46
|
* Collect all headers from the request, excluding the blocklist.
|
|
42
47
|
* Merges headers from both the Request object and the init object,
|
|
@@ -71,19 +76,91 @@ function hasAuthHeaders(input, init) {
|
|
|
71
76
|
const headers = collectHeaders(input, init);
|
|
72
77
|
return AUTH_HEADERS.some((name) => name in headers);
|
|
73
78
|
}
|
|
79
|
+
async function serializeFormData(formData, pushBodyChunk, getTotalBodyBytes) {
|
|
80
|
+
for (const [key, val] of formData.entries()) {
|
|
81
|
+
if (typeof val === "string") {
|
|
82
|
+
pushBodyChunk(JSON.stringify([key, { kind: "string", value: val }]));
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (val.size > MAX_CACHE_KEY_BODY_BYTES || getTotalBodyBytes() + val.size > MAX_CACHE_KEY_BODY_BYTES) {
|
|
86
|
+
throw new BodyTooLargeForCacheKeyError();
|
|
87
|
+
}
|
|
88
|
+
pushBodyChunk(JSON.stringify([key, {
|
|
89
|
+
kind: "file",
|
|
90
|
+
name: val.name,
|
|
91
|
+
type: val.type,
|
|
92
|
+
value: await val.text(),
|
|
93
|
+
}]));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function getParsedFormContentType(contentType) {
|
|
97
|
+
const mediaType = contentType?.split(";")[0]?.trim().toLowerCase();
|
|
98
|
+
if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") {
|
|
99
|
+
return mediaType;
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
function stripMultipartBoundary(contentType) {
|
|
104
|
+
const [type, ...params] = contentType.split(";");
|
|
105
|
+
const keptParams = params
|
|
106
|
+
.map((param) => param.trim())
|
|
107
|
+
.filter(Boolean)
|
|
108
|
+
.filter((param) => !/^boundary\s*=/i.test(param));
|
|
109
|
+
const normalizedType = type.trim().toLowerCase();
|
|
110
|
+
return keptParams.length > 0
|
|
111
|
+
? `${normalizedType}; ${keptParams.join("; ")}`
|
|
112
|
+
: normalizedType;
|
|
113
|
+
}
|
|
114
|
+
async function readRequestBodyChunksWithinLimit(request) {
|
|
115
|
+
const contentLengthHeader = request.headers.get("content-length");
|
|
116
|
+
if (contentLengthHeader) {
|
|
117
|
+
const contentLength = Number(contentLengthHeader);
|
|
118
|
+
if (Number.isFinite(contentLength) && contentLength > MAX_CACHE_KEY_BODY_BYTES) {
|
|
119
|
+
throw new BodyTooLargeForCacheKeyError();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const requestClone = request.clone();
|
|
123
|
+
const contentType = requestClone.headers.get("content-type") ?? undefined;
|
|
124
|
+
const reader = requestClone.body?.getReader();
|
|
125
|
+
if (!reader) {
|
|
126
|
+
return { chunks: [], contentType };
|
|
127
|
+
}
|
|
128
|
+
const chunks = [];
|
|
129
|
+
let totalBodyBytes = 0;
|
|
130
|
+
try {
|
|
131
|
+
while (true) {
|
|
132
|
+
const { done, value } = await reader.read();
|
|
133
|
+
if (done)
|
|
134
|
+
break;
|
|
135
|
+
totalBodyBytes += value.byteLength;
|
|
136
|
+
if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) {
|
|
137
|
+
throw new BodyTooLargeForCacheKeyError();
|
|
138
|
+
}
|
|
139
|
+
chunks.push(value);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
void reader.cancel().catch(() => { });
|
|
144
|
+
throw err;
|
|
145
|
+
}
|
|
146
|
+
return { chunks, contentType };
|
|
147
|
+
}
|
|
74
148
|
/**
|
|
75
149
|
* Serialize request body into string chunks for cache key inclusion.
|
|
76
|
-
* Handles all body types: string, Uint8Array, ReadableStream, FormData, Blob
|
|
150
|
+
* Handles all body types: string, Uint8Array, ReadableStream, FormData, Blob,
|
|
151
|
+
* and Request object bodies.
|
|
77
152
|
* Returns the serialized body chunks and optionally stashes the original body
|
|
78
153
|
* on init as `_ogBody` so it can still be used after stream consumption.
|
|
79
154
|
*/
|
|
80
|
-
async function serializeBody(init) {
|
|
81
|
-
if (!init?.body)
|
|
82
|
-
return [];
|
|
155
|
+
async function serializeBody(input, init) {
|
|
156
|
+
if (!init?.body && !(input instanceof Request && input.body)) {
|
|
157
|
+
return { bodyChunks: [] };
|
|
158
|
+
}
|
|
83
159
|
const bodyChunks = [];
|
|
84
160
|
const encoder = new TextEncoder();
|
|
85
161
|
const decoder = new TextDecoder();
|
|
86
162
|
let totalBodyBytes = 0;
|
|
163
|
+
let canonicalizedContentType;
|
|
87
164
|
const pushBodyChunk = (chunk) => {
|
|
88
165
|
totalBodyBytes += encoder.encode(chunk).byteLength;
|
|
89
166
|
if (totalBodyBytes > MAX_CACHE_KEY_BODY_BYTES) {
|
|
@@ -91,14 +168,15 @@ async function serializeBody(init) {
|
|
|
91
168
|
}
|
|
92
169
|
bodyChunks.push(chunk);
|
|
93
170
|
};
|
|
94
|
-
|
|
171
|
+
const getTotalBodyBytes = () => totalBodyBytes;
|
|
172
|
+
if (init?.body instanceof Uint8Array) {
|
|
95
173
|
if (init.body.byteLength > MAX_CACHE_KEY_BODY_BYTES) {
|
|
96
174
|
throw new BodyTooLargeForCacheKeyError();
|
|
97
175
|
}
|
|
98
176
|
pushBodyChunk(decoder.decode(init.body));
|
|
99
177
|
init._ogBody = init.body;
|
|
100
178
|
}
|
|
101
|
-
else if (typeof init.body.getReader === "function") {
|
|
179
|
+
else if (init?.body && typeof init.body.getReader === "function") {
|
|
102
180
|
// ReadableStream
|
|
103
181
|
const readableBody = init.body;
|
|
104
182
|
const [bodyForHashing, bodyForFetch] = readableBody.tee();
|
|
@@ -132,34 +210,21 @@ async function serializeBody(init) {
|
|
|
132
210
|
if (err instanceof BodyTooLargeForCacheKeyError) {
|
|
133
211
|
throw err;
|
|
134
212
|
}
|
|
135
|
-
|
|
213
|
+
throw new SkipCacheKeyGenerationError();
|
|
136
214
|
}
|
|
137
215
|
}
|
|
138
|
-
else if (init
|
|
216
|
+
else if (init?.body instanceof URLSearchParams) {
|
|
139
217
|
// URLSearchParams — .toString() gives a stable serialization
|
|
140
218
|
init._ogBody = init.body;
|
|
141
219
|
pushBodyChunk(init.body.toString());
|
|
142
220
|
}
|
|
143
|
-
else if (typeof init.body.keys === "function") {
|
|
221
|
+
else if (init?.body && typeof init.body.keys === "function") {
|
|
144
222
|
// FormData
|
|
145
223
|
const formData = init.body;
|
|
146
224
|
init._ogBody = init.body;
|
|
147
|
-
|
|
148
|
-
const values = formData.getAll(key);
|
|
149
|
-
const serializedValues = await Promise.all(values.map(async (val) => {
|
|
150
|
-
if (typeof val === "string")
|
|
151
|
-
return val;
|
|
152
|
-
if (val.size > MAX_CACHE_KEY_BODY_BYTES || totalBodyBytes + val.size > MAX_CACHE_KEY_BODY_BYTES) {
|
|
153
|
-
throw new BodyTooLargeForCacheKeyError();
|
|
154
|
-
}
|
|
155
|
-
// Note: File name/type/lastModified are not included — only content.
|
|
156
|
-
// Two Files with identical content but different names produce the same key.
|
|
157
|
-
return await val.text();
|
|
158
|
-
}));
|
|
159
|
-
pushBodyChunk(`${key}=${serializedValues.join(",")}`);
|
|
160
|
-
}
|
|
225
|
+
await serializeFormData(formData, pushBodyChunk, getTotalBodyBytes);
|
|
161
226
|
}
|
|
162
|
-
else if (typeof init.body.arrayBuffer === "function") {
|
|
227
|
+
else if (init?.body && typeof init.body.arrayBuffer === "function") {
|
|
163
228
|
// Blob
|
|
164
229
|
const blob = init.body;
|
|
165
230
|
if (blob.size > MAX_CACHE_KEY_BODY_BYTES) {
|
|
@@ -169,7 +234,7 @@ async function serializeBody(init) {
|
|
|
169
234
|
const arrayBuffer = await blob.arrayBuffer();
|
|
170
235
|
init._ogBody = new Blob([arrayBuffer], { type: blob.type });
|
|
171
236
|
}
|
|
172
|
-
else if (typeof init
|
|
237
|
+
else if (typeof init?.body === "string") {
|
|
173
238
|
// String length is always <= UTF-8 byte length, so this is a
|
|
174
239
|
// cheap lower-bound check that avoids encoder.encode() for huge strings.
|
|
175
240
|
if (init.body.length > MAX_CACHE_KEY_BODY_BYTES) {
|
|
@@ -178,7 +243,49 @@ async function serializeBody(init) {
|
|
|
178
243
|
pushBodyChunk(init.body);
|
|
179
244
|
init._ogBody = init.body;
|
|
180
245
|
}
|
|
181
|
-
|
|
246
|
+
else if (input instanceof Request && input.body) {
|
|
247
|
+
let chunks;
|
|
248
|
+
let contentType;
|
|
249
|
+
try {
|
|
250
|
+
({ chunks, contentType } = await readRequestBodyChunksWithinLimit(input));
|
|
251
|
+
}
|
|
252
|
+
catch (err) {
|
|
253
|
+
if (err instanceof BodyTooLargeForCacheKeyError) {
|
|
254
|
+
throw err;
|
|
255
|
+
}
|
|
256
|
+
throw new SkipCacheKeyGenerationError();
|
|
257
|
+
}
|
|
258
|
+
const formContentType = getParsedFormContentType(contentType);
|
|
259
|
+
if (formContentType) {
|
|
260
|
+
try {
|
|
261
|
+
const boundedRequest = new Request(input.url, {
|
|
262
|
+
method: input.method,
|
|
263
|
+
headers: contentType ? { "content-type": contentType } : undefined,
|
|
264
|
+
body: new Blob(chunks),
|
|
265
|
+
});
|
|
266
|
+
const formData = await boundedRequest.formData();
|
|
267
|
+
await serializeFormData(formData, pushBodyChunk, getTotalBodyBytes);
|
|
268
|
+
canonicalizedContentType = formContentType === "multipart/form-data" && contentType
|
|
269
|
+
? stripMultipartBoundary(contentType)
|
|
270
|
+
: undefined;
|
|
271
|
+
return { bodyChunks, canonicalizedContentType };
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
274
|
+
if (err instanceof BodyTooLargeForCacheKeyError) {
|
|
275
|
+
throw err;
|
|
276
|
+
}
|
|
277
|
+
throw new SkipCacheKeyGenerationError();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
for (const chunk of chunks) {
|
|
281
|
+
pushBodyChunk(decoder.decode(chunk, { stream: true }));
|
|
282
|
+
}
|
|
283
|
+
const finalChunk = decoder.decode();
|
|
284
|
+
if (finalChunk) {
|
|
285
|
+
pushBodyChunk(finalChunk);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return { bodyChunks, canonicalizedContentType };
|
|
182
289
|
}
|
|
183
290
|
/**
|
|
184
291
|
* Generate a deterministic cache key from a fetch request.
|
|
@@ -204,7 +311,10 @@ async function buildFetchCacheKey(input, init) {
|
|
|
204
311
|
if (init?.method)
|
|
205
312
|
method = init.method;
|
|
206
313
|
const headers = collectHeaders(input, init);
|
|
207
|
-
const bodyChunks = await serializeBody(init);
|
|
314
|
+
const { bodyChunks, canonicalizedContentType } = await serializeBody(input, init);
|
|
315
|
+
if (canonicalizedContentType) {
|
|
316
|
+
headers["content-type"] = canonicalizedContentType;
|
|
317
|
+
}
|
|
208
318
|
const cacheString = JSON.stringify([
|
|
209
319
|
CACHE_KEY_PREFIX,
|
|
210
320
|
url,
|
|
@@ -331,7 +441,7 @@ function createPatchedFetch() {
|
|
|
331
441
|
cacheKey = await buildFetchCacheKey(input, init);
|
|
332
442
|
}
|
|
333
443
|
catch (err) {
|
|
334
|
-
if (err instanceof BodyTooLargeForCacheKeyError) {
|
|
444
|
+
if (err instanceof BodyTooLargeForCacheKeyError || err instanceof SkipCacheKeyGenerationError) {
|
|
335
445
|
const cleanInit = stripNextFromInit(init);
|
|
336
446
|
return originalFetch(input, cleanInit);
|
|
337
447
|
}
|