@vercel/build-utils 7.1.0 → 7.1.1

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/lambda.js CHANGED
@@ -1,160 +1,224 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
4
11
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getLambdaOptionsFromFunction = exports.createZip = exports.createLambda = exports.Lambda = void 0;
7
- const assert_1 = __importDefault(require("assert"));
8
- const async_sema_1 = __importDefault(require("async-sema"));
9
- const yazl_1 = require("yazl");
10
- const minimatch_1 = __importDefault(require("minimatch"));
11
- const fs_extra_1 = require("fs-extra");
12
- const download_1 = require("./fs/download");
13
- const stream_to_buffer_1 = __importDefault(require("./fs/stream-to-buffer"));
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var lambda_exports = {};
30
+ __export(lambda_exports, {
31
+ Lambda: () => Lambda,
32
+ createLambda: () => createLambda,
33
+ createZip: () => createZip,
34
+ getLambdaOptionsFromFunction: () => getLambdaOptionsFromFunction
35
+ });
36
+ module.exports = __toCommonJS(lambda_exports);
37
+ var import_assert = __toESM(require("assert"));
38
+ var import_async_sema = __toESM(require("async-sema"));
39
+ var import_yazl = require("yazl");
40
+ var import_minimatch = __toESM(require("minimatch"));
41
+ var import_fs_extra = require("fs-extra");
42
+ var import_download = require("./fs/download");
43
+ var import_stream_to_buffer = __toESM(require("./fs/stream-to-buffer"));
14
44
  class Lambda {
15
- constructor(opts) {
16
- const { handler, runtime, maxDuration, architecture, memory, environment = {}, allowQuery, regions, supportsMultiPayloads, supportsWrapper, supportsResponseStreaming, experimentalResponseStreaming, operationType, framework, } = opts;
17
- if ('files' in opts) {
18
- (0, assert_1.default)(typeof opts.files === 'object', '"files" must be an object');
19
- }
20
- if ('zipBuffer' in opts) {
21
- (0, assert_1.default)(Buffer.isBuffer(opts.zipBuffer), '"zipBuffer" must be a Buffer');
22
- }
23
- (0, assert_1.default)(typeof handler === 'string', '"handler" is not a string');
24
- (0, assert_1.default)(typeof runtime === 'string', '"runtime" is not a string');
25
- (0, assert_1.default)(typeof environment === 'object', '"environment" is not an object');
26
- if (architecture !== undefined) {
27
- (0, assert_1.default)(architecture === 'x86_64' || architecture === 'arm64', '"architecture" must be either "x86_64" or "arm64"');
28
- }
29
- if (memory !== undefined) {
30
- (0, assert_1.default)(typeof memory === 'number', '"memory" is not a number');
31
- }
32
- if (maxDuration !== undefined) {
33
- (0, assert_1.default)(typeof maxDuration === 'number', '"maxDuration" is not a number');
34
- }
35
- if (allowQuery !== undefined) {
36
- (0, assert_1.default)(Array.isArray(allowQuery), '"allowQuery" is not an Array');
37
- (0, assert_1.default)(allowQuery.every(q => typeof q === 'string'), '"allowQuery" is not a string Array');
38
- }
39
- if (supportsMultiPayloads !== undefined) {
40
- (0, assert_1.default)(typeof supportsMultiPayloads === 'boolean', '"supportsMultiPayloads" is not a boolean');
41
- }
42
- if (supportsWrapper !== undefined) {
43
- (0, assert_1.default)(typeof supportsWrapper === 'boolean', '"supportsWrapper" is not a boolean');
44
- }
45
- if (regions !== undefined) {
46
- (0, assert_1.default)(Array.isArray(regions), '"regions" is not an Array');
47
- (0, assert_1.default)(regions.every(r => typeof r === 'string'), '"regions" is not a string Array');
48
- }
49
- if (framework !== undefined) {
50
- (0, assert_1.default)(typeof framework === 'object', '"framework" is not an object');
51
- (0, assert_1.default)(typeof framework.slug === 'string', '"framework.slug" is not a string');
52
- if (framework.version !== undefined) {
53
- (0, assert_1.default)(typeof framework.version === 'string', '"framework.version" is not a string');
54
- }
55
- }
56
- this.type = 'Lambda';
57
- this.operationType = operationType;
58
- this.files = 'files' in opts ? opts.files : undefined;
59
- this.handler = handler;
60
- this.runtime = runtime;
61
- this.architecture = architecture;
62
- this.memory = memory;
63
- this.maxDuration = maxDuration;
64
- this.environment = environment;
65
- this.allowQuery = allowQuery;
66
- this.regions = regions;
67
- this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined;
68
- this.supportsMultiPayloads = supportsMultiPayloads;
69
- this.supportsWrapper = supportsWrapper;
70
- this.supportsResponseStreaming =
71
- supportsResponseStreaming ?? experimentalResponseStreaming;
72
- this.framework = framework;
45
+ constructor(opts) {
46
+ const {
47
+ handler,
48
+ runtime,
49
+ maxDuration,
50
+ architecture,
51
+ memory,
52
+ environment = {},
53
+ allowQuery,
54
+ regions,
55
+ supportsMultiPayloads,
56
+ supportsWrapper,
57
+ supportsResponseStreaming,
58
+ experimentalResponseStreaming,
59
+ operationType,
60
+ framework
61
+ } = opts;
62
+ if ("files" in opts) {
63
+ (0, import_assert.default)(typeof opts.files === "object", '"files" must be an object');
64
+ }
65
+ if ("zipBuffer" in opts) {
66
+ (0, import_assert.default)(Buffer.isBuffer(opts.zipBuffer), '"zipBuffer" must be a Buffer');
67
+ }
68
+ (0, import_assert.default)(typeof handler === "string", '"handler" is not a string');
69
+ (0, import_assert.default)(typeof runtime === "string", '"runtime" is not a string');
70
+ (0, import_assert.default)(typeof environment === "object", '"environment" is not an object');
71
+ if (architecture !== void 0) {
72
+ (0, import_assert.default)(
73
+ architecture === "x86_64" || architecture === "arm64",
74
+ '"architecture" must be either "x86_64" or "arm64"'
75
+ );
76
+ }
77
+ if (memory !== void 0) {
78
+ (0, import_assert.default)(typeof memory === "number", '"memory" is not a number');
79
+ }
80
+ if (maxDuration !== void 0) {
81
+ (0, import_assert.default)(typeof maxDuration === "number", '"maxDuration" is not a number');
82
+ }
83
+ if (allowQuery !== void 0) {
84
+ (0, import_assert.default)(Array.isArray(allowQuery), '"allowQuery" is not an Array');
85
+ (0, import_assert.default)(
86
+ allowQuery.every((q) => typeof q === "string"),
87
+ '"allowQuery" is not a string Array'
88
+ );
73
89
  }
74
- async createZip() {
75
- let { zipBuffer } = this;
76
- if (!zipBuffer) {
77
- if (!this.files) {
78
- throw new Error('`files` is not defined');
79
- }
80
- await sema.acquire();
81
- try {
82
- zipBuffer = await createZip(this.files);
83
- }
84
- finally {
85
- sema.release();
86
- }
87
- }
88
- return zipBuffer;
90
+ if (supportsMultiPayloads !== void 0) {
91
+ (0, import_assert.default)(
92
+ typeof supportsMultiPayloads === "boolean",
93
+ '"supportsMultiPayloads" is not a boolean'
94
+ );
89
95
  }
90
- /**
91
- * @deprecated Use the `supportsResponseStreaming` property instead.
92
- */
93
- get experimentalResponseStreaming() {
94
- return this.supportsResponseStreaming;
96
+ if (supportsWrapper !== void 0) {
97
+ (0, import_assert.default)(
98
+ typeof supportsWrapper === "boolean",
99
+ '"supportsWrapper" is not a boolean'
100
+ );
95
101
  }
96
- set experimentalResponseStreaming(v) {
97
- this.supportsResponseStreaming = v;
102
+ if (regions !== void 0) {
103
+ (0, import_assert.default)(Array.isArray(regions), '"regions" is not an Array');
104
+ (0, import_assert.default)(
105
+ regions.every((r) => typeof r === "string"),
106
+ '"regions" is not a string Array'
107
+ );
98
108
  }
109
+ if (framework !== void 0) {
110
+ (0, import_assert.default)(typeof framework === "object", '"framework" is not an object');
111
+ (0, import_assert.default)(
112
+ typeof framework.slug === "string",
113
+ '"framework.slug" is not a string'
114
+ );
115
+ if (framework.version !== void 0) {
116
+ (0, import_assert.default)(
117
+ typeof framework.version === "string",
118
+ '"framework.version" is not a string'
119
+ );
120
+ }
121
+ }
122
+ this.type = "Lambda";
123
+ this.operationType = operationType;
124
+ this.files = "files" in opts ? opts.files : void 0;
125
+ this.handler = handler;
126
+ this.runtime = runtime;
127
+ this.architecture = architecture;
128
+ this.memory = memory;
129
+ this.maxDuration = maxDuration;
130
+ this.environment = environment;
131
+ this.allowQuery = allowQuery;
132
+ this.regions = regions;
133
+ this.zipBuffer = "zipBuffer" in opts ? opts.zipBuffer : void 0;
134
+ this.supportsMultiPayloads = supportsMultiPayloads;
135
+ this.supportsWrapper = supportsWrapper;
136
+ this.supportsResponseStreaming = supportsResponseStreaming ?? experimentalResponseStreaming;
137
+ this.framework = framework;
138
+ }
139
+ async createZip() {
140
+ let { zipBuffer } = this;
141
+ if (!zipBuffer) {
142
+ if (!this.files) {
143
+ throw new Error("`files` is not defined");
144
+ }
145
+ await sema.acquire();
146
+ try {
147
+ zipBuffer = await createZip(this.files);
148
+ } finally {
149
+ sema.release();
150
+ }
151
+ }
152
+ return zipBuffer;
153
+ }
154
+ /**
155
+ * @deprecated Use the `supportsResponseStreaming` property instead.
156
+ */
157
+ get experimentalResponseStreaming() {
158
+ return this.supportsResponseStreaming;
159
+ }
160
+ set experimentalResponseStreaming(v) {
161
+ this.supportsResponseStreaming = v;
162
+ }
99
163
  }
100
- exports.Lambda = Lambda;
101
- const sema = new async_sema_1.default(10);
102
- const mtime = new Date(1540000000000);
103
- /**
104
- * @deprecated Use `new Lambda()` instead.
105
- */
164
+ const sema = new import_async_sema.default(10);
165
+ const mtime = /* @__PURE__ */ new Date(154e10);
106
166
  async function createLambda(opts) {
107
- const lambda = new Lambda(opts);
108
- // backwards compat
109
- lambda.zipBuffer = await lambda.createZip();
110
- return lambda;
167
+ const lambda = new Lambda(opts);
168
+ lambda.zipBuffer = await lambda.createZip();
169
+ return lambda;
111
170
  }
112
- exports.createLambda = createLambda;
113
171
  async function createZip(files) {
114
- const names = Object.keys(files).sort();
115
- const symlinkTargets = new Map();
172
+ const names = Object.keys(files).sort();
173
+ const symlinkTargets = /* @__PURE__ */ new Map();
174
+ for (const name of names) {
175
+ const file = files[name];
176
+ if (file.mode && (0, import_download.isSymbolicLink)(file.mode) && file.type === "FileFsRef") {
177
+ const symlinkTarget = await (0, import_fs_extra.readlink)(file.fsPath);
178
+ symlinkTargets.set(name, symlinkTarget);
179
+ }
180
+ }
181
+ const zipFile = new import_yazl.ZipFile();
182
+ const zipBuffer = await new Promise((resolve, reject) => {
116
183
  for (const name of names) {
117
- const file = files[name];
118
- if (file.mode && (0, download_1.isSymbolicLink)(file.mode) && file.type === 'FileFsRef') {
119
- const symlinkTarget = await (0, fs_extra_1.readlink)(file.fsPath);
120
- symlinkTargets.set(name, symlinkTarget);
121
- }
184
+ const file = files[name];
185
+ const opts = { mode: file.mode, mtime };
186
+ const symlinkTarget = symlinkTargets.get(name);
187
+ if (typeof symlinkTarget === "string") {
188
+ zipFile.addBuffer(Buffer.from(symlinkTarget, "utf8"), name, opts);
189
+ } else if (file.mode && (0, import_download.isDirectory)(file.mode)) {
190
+ zipFile.addEmptyDirectory(name, opts);
191
+ } else {
192
+ const stream = file.toStream();
193
+ stream.on("error", reject);
194
+ zipFile.addReadStream(stream, name, opts);
195
+ }
122
196
  }
123
- const zipFile = new yazl_1.ZipFile();
124
- const zipBuffer = await new Promise((resolve, reject) => {
125
- for (const name of names) {
126
- const file = files[name];
127
- const opts = { mode: file.mode, mtime };
128
- const symlinkTarget = symlinkTargets.get(name);
129
- if (typeof symlinkTarget === 'string') {
130
- zipFile.addBuffer(Buffer.from(symlinkTarget, 'utf8'), name, opts);
131
- }
132
- else if (file.mode && (0, download_1.isDirectory)(file.mode)) {
133
- zipFile.addEmptyDirectory(name, opts);
134
- }
135
- else {
136
- const stream = file.toStream();
137
- stream.on('error', reject);
138
- zipFile.addReadStream(stream, name, opts);
139
- }
140
- }
141
- zipFile.end();
142
- (0, stream_to_buffer_1.default)(zipFile.outputStream).then(resolve).catch(reject);
143
- });
144
- return zipBuffer;
197
+ zipFile.end();
198
+ (0, import_stream_to_buffer.default)(zipFile.outputStream).then(resolve).catch(reject);
199
+ });
200
+ return zipBuffer;
145
201
  }
146
- exports.createZip = createZip;
147
- async function getLambdaOptionsFromFunction({ sourceFile, config, }) {
148
- if (config?.functions) {
149
- for (const [pattern, fn] of Object.entries(config.functions)) {
150
- if (sourceFile === pattern || (0, minimatch_1.default)(sourceFile, pattern)) {
151
- return {
152
- memory: fn.memory,
153
- maxDuration: fn.maxDuration,
154
- };
155
- }
156
- }
202
+ async function getLambdaOptionsFromFunction({
203
+ sourceFile,
204
+ config
205
+ }) {
206
+ if (config?.functions) {
207
+ for (const [pattern, fn] of Object.entries(config.functions)) {
208
+ if (sourceFile === pattern || (0, import_minimatch.default)(sourceFile, pattern)) {
209
+ return {
210
+ memory: fn.memory,
211
+ maxDuration: fn.maxDuration
212
+ };
213
+ }
157
214
  }
158
- return {};
215
+ }
216
+ return {};
159
217
  }
160
- exports.getLambdaOptionsFromFunction = getLambdaOptionsFromFunction;
218
+ // Annotate the CommonJS export names for ESM import in node:
219
+ 0 && (module.exports = {
220
+ Lambda,
221
+ createLambda,
222
+ createZip,
223
+ getLambdaOptionsFromFunction
224
+ });
@@ -1,14 +1,42 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NodejsLambda = void 0;
4
- const lambda_1 = require("./lambda");
5
- class NodejsLambda extends lambda_1.Lambda {
6
- constructor({ shouldAddHelpers, shouldAddSourcemapSupport, awsLambdaHandler, ...opts }) {
7
- super(opts);
8
- this.launcherType = 'Nodejs';
9
- this.shouldAddHelpers = shouldAddHelpers;
10
- this.shouldAddSourcemapSupport = shouldAddSourcemapSupport;
11
- this.awsLambdaHandler = awsLambdaHandler;
12
- }
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var nodejs_lambda_exports = {};
20
+ __export(nodejs_lambda_exports, {
21
+ NodejsLambda: () => NodejsLambda
22
+ });
23
+ module.exports = __toCommonJS(nodejs_lambda_exports);
24
+ var import_lambda = require("./lambda");
25
+ class NodejsLambda extends import_lambda.Lambda {
26
+ constructor({
27
+ shouldAddHelpers,
28
+ shouldAddSourcemapSupport,
29
+ awsLambdaHandler,
30
+ ...opts
31
+ }) {
32
+ super(opts);
33
+ this.launcherType = "Nodejs";
34
+ this.shouldAddHelpers = shouldAddHelpers;
35
+ this.shouldAddSourcemapSupport = shouldAddSourcemapSupport;
36
+ this.awsLambdaHandler = awsLambdaHandler;
37
+ }
13
38
  }
14
- exports.NodejsLambda = NodejsLambda;
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ NodejsLambda
42
+ });
package/dist/prerender.js CHANGED
@@ -1,68 +1,113 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Prerender = void 0;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var prerender_exports = {};
20
+ __export(prerender_exports, {
21
+ Prerender: () => Prerender
22
+ });
23
+ module.exports = __toCommonJS(prerender_exports);
4
24
  class Prerender {
5
- constructor({ expiration, lambda, fallback, group, bypassToken, allowQuery, initialHeaders, initialStatus, passQuery, sourcePath, }) {
6
- this.type = 'Prerender';
7
- this.expiration = expiration;
8
- this.sourcePath = sourcePath;
9
- this.lambda = lambda;
10
- if (this.lambda) {
11
- // "ISR" is the platform default lambda label for prerender functions
12
- this.lambda.operationType = this.lambda.operationType || 'ISR';
13
- }
14
- if (typeof group !== 'undefined' &&
15
- (group <= 0 || !Number.isInteger(group))) {
16
- throw new Error('The `group` argument for `Prerender` needs to be a natural number.');
17
- }
18
- this.group = group;
19
- if (passQuery === true) {
20
- this.passQuery = true;
21
- }
22
- else if (typeof passQuery !== 'boolean' &&
23
- typeof passQuery !== 'undefined') {
24
- throw new Error(`The \`passQuery\` argument for \`Prerender\` must be a boolean.`);
25
- }
26
- if (bypassToken == null) {
27
- this.bypassToken = null;
28
- }
29
- else if (typeof bypassToken === 'string') {
30
- if (bypassToken.length < 32) {
31
- // Enforce 128 bits of entropy for safety reasons (UUIDv4 size)
32
- throw new Error('The `bypassToken` argument for `Prerender` must be 32 characters or more.');
33
- }
34
- this.bypassToken = bypassToken;
35
- }
36
- else {
37
- throw new Error('The `bypassToken` argument for `Prerender` must be a `string`.');
38
- }
39
- if (typeof fallback === 'undefined') {
40
- throw new Error('The `fallback` argument for `Prerender` needs to be a `FileBlob`, `FileFsRef`, `FileRef`, or null.');
41
- }
42
- this.fallback = fallback;
43
- if (initialHeaders !== undefined) {
44
- if (!initialHeaders ||
45
- typeof initialHeaders !== 'object' ||
46
- Object.entries(initialHeaders).some(([key, value]) => typeof key !== 'string' || typeof value !== 'string')) {
47
- throw new Error(`The \`initialHeaders\` argument for \`Prerender\` must be an object with string key/values`);
48
- }
49
- this.initialHeaders = initialHeaders;
50
- }
51
- if (initialStatus !== undefined) {
52
- if (initialStatus <= 0 || !Number.isInteger(initialStatus)) {
53
- throw new Error(`The \`initialStatus\` argument for \`Prerender\` must be a natural number.`);
54
- }
55
- this.initialStatus = initialStatus;
56
- }
57
- if (allowQuery !== undefined) {
58
- if (!Array.isArray(allowQuery)) {
59
- throw new Error('The `allowQuery` argument for `Prerender` must be Array.');
60
- }
61
- if (!allowQuery.every(q => typeof q === 'string')) {
62
- throw new Error('The `allowQuery` argument for `Prerender` must be Array of strings.');
63
- }
64
- this.allowQuery = allowQuery;
65
- }
25
+ constructor({
26
+ expiration,
27
+ lambda,
28
+ fallback,
29
+ group,
30
+ bypassToken,
31
+ allowQuery,
32
+ initialHeaders,
33
+ initialStatus,
34
+ passQuery,
35
+ sourcePath
36
+ }) {
37
+ this.type = "Prerender";
38
+ this.expiration = expiration;
39
+ this.sourcePath = sourcePath;
40
+ this.lambda = lambda;
41
+ if (this.lambda) {
42
+ this.lambda.operationType = this.lambda.operationType || "ISR";
66
43
  }
44
+ if (typeof group !== "undefined" && (group <= 0 || !Number.isInteger(group))) {
45
+ throw new Error(
46
+ "The `group` argument for `Prerender` needs to be a natural number."
47
+ );
48
+ }
49
+ this.group = group;
50
+ if (passQuery === true) {
51
+ this.passQuery = true;
52
+ } else if (typeof passQuery !== "boolean" && typeof passQuery !== "undefined") {
53
+ throw new Error(
54
+ `The \`passQuery\` argument for \`Prerender\` must be a boolean.`
55
+ );
56
+ }
57
+ if (bypassToken == null) {
58
+ this.bypassToken = null;
59
+ } else if (typeof bypassToken === "string") {
60
+ if (bypassToken.length < 32) {
61
+ throw new Error(
62
+ "The `bypassToken` argument for `Prerender` must be 32 characters or more."
63
+ );
64
+ }
65
+ this.bypassToken = bypassToken;
66
+ } else {
67
+ throw new Error(
68
+ "The `bypassToken` argument for `Prerender` must be a `string`."
69
+ );
70
+ }
71
+ if (typeof fallback === "undefined") {
72
+ throw new Error(
73
+ "The `fallback` argument for `Prerender` needs to be a `FileBlob`, `FileFsRef`, `FileRef`, or null."
74
+ );
75
+ }
76
+ this.fallback = fallback;
77
+ if (initialHeaders !== void 0) {
78
+ if (!initialHeaders || typeof initialHeaders !== "object" || Object.entries(initialHeaders).some(
79
+ ([key, value]) => typeof key !== "string" || typeof value !== "string"
80
+ )) {
81
+ throw new Error(
82
+ `The \`initialHeaders\` argument for \`Prerender\` must be an object with string key/values`
83
+ );
84
+ }
85
+ this.initialHeaders = initialHeaders;
86
+ }
87
+ if (initialStatus !== void 0) {
88
+ if (initialStatus <= 0 || !Number.isInteger(initialStatus)) {
89
+ throw new Error(
90
+ `The \`initialStatus\` argument for \`Prerender\` must be a natural number.`
91
+ );
92
+ }
93
+ this.initialStatus = initialStatus;
94
+ }
95
+ if (allowQuery !== void 0) {
96
+ if (!Array.isArray(allowQuery)) {
97
+ throw new Error(
98
+ "The `allowQuery` argument for `Prerender` must be Array."
99
+ );
100
+ }
101
+ if (!allowQuery.every((q) => typeof q === "string")) {
102
+ throw new Error(
103
+ "The `allowQuery` argument for `Prerender` must be Array of strings."
104
+ );
105
+ }
106
+ this.allowQuery = allowQuery;
107
+ }
108
+ }
67
109
  }
68
- exports.Prerender = Prerender;
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
112
+ Prerender
113
+ });