@netlify/plugin-nextjs 5.1.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/build/advanced-api-routes.js +121 -4
  2. package/dist/build/cache.js +25 -4
  3. package/dist/build/content/prerendered.js +234 -8
  4. package/dist/build/content/server.js +259 -14
  5. package/dist/build/content/static.js +96 -11
  6. package/dist/build/functions/edge.js +511 -5
  7. package/dist/build/functions/server.js +131 -12
  8. package/dist/build/image-cdn.js +1626 -3
  9. package/dist/build/plugin-context.js +236 -5
  10. package/dist/build/templates/handler-monorepo.tmpl.js +3 -0
  11. package/dist/build/templates/handler.tmpl.js +3 -0
  12. package/dist/build/verification.js +81 -8
  13. package/dist/esm-chunks/{package-YB7ERSH4.js → package-ZBRSUKN7.js} +6 -6
  14. package/dist/index.js +25 -36
  15. package/dist/run/config.js +25 -6
  16. package/dist/run/constants.js +7 -5
  17. package/dist/run/handlers/cache.cjs +6 -567
  18. package/dist/run/handlers/request-context.cjs +8 -1
  19. package/dist/run/handlers/server.js +20 -22
  20. package/dist/run/handlers/tracing.js +1 -1
  21. package/dist/run/headers.js +198 -8
  22. package/dist/run/next.cjs +49 -567
  23. package/dist/{esm-chunks/chunk-PMRBBOBY.js → run/regional-blob-store.cjs} +117 -263
  24. package/dist/run/revalidate.js +17 -3
  25. package/dist/run/systemlog.js +94 -3
  26. package/dist/shared/blobkey.js +15 -3
  27. package/package.json +1 -1
  28. package/dist/esm-chunks/chunk-3NYX5FXN.js +0 -188
  29. package/dist/esm-chunks/chunk-3SUDZQ7L.js +0 -40
  30. package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
  31. package/dist/esm-chunks/chunk-74THQNRG.js +0 -110
  32. package/dist/esm-chunks/chunk-BG455SFE.js +0 -133
  33. package/dist/esm-chunks/chunk-F5VQRN6L.js +0 -127
  34. package/dist/esm-chunks/chunk-HYBEXB2Z.js +0 -105
  35. package/dist/esm-chunks/chunk-MCEOSJH6.js +0 -1637
  36. package/dist/esm-chunks/chunk-MRD3XSKD.js +0 -248
  37. package/dist/esm-chunks/chunk-OBKVBMAL.js +0 -524
  38. package/dist/esm-chunks/chunk-PH26UF2W.js +0 -86
  39. package/dist/esm-chunks/chunk-RL4K4CVH.js +0 -27
  40. package/dist/esm-chunks/chunk-TYCYFZ22.js +0 -25
  41. package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
  42. package/dist/esm-chunks/chunk-ZKJEJNSJ.js +0 -278
@@ -1,1637 +0,0 @@
1
-
2
- var require = await (async () => {
3
- var { createRequire } = await import("node:module");
4
- return createRequire(import.meta.url);
5
- })();
6
-
7
- import {
8
- __commonJS,
9
- __require,
10
- __toESM
11
- } from "./chunk-5JVNISGM.js";
12
-
13
- // node_modules/picomatch/lib/constants.js
14
- var require_constants = __commonJS({
15
- "node_modules/picomatch/lib/constants.js"(exports, module) {
16
- "use strict";
17
- var WIN_SLASH = "\\\\/";
18
- var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
19
- var DOT_LITERAL = "\\.";
20
- var PLUS_LITERAL = "\\+";
21
- var QMARK_LITERAL = "\\?";
22
- var SLASH_LITERAL = "\\/";
23
- var ONE_CHAR = "(?=.)";
24
- var QMARK = "[^/]";
25
- var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
26
- var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
27
- var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
28
- var NO_DOT = `(?!${DOT_LITERAL})`;
29
- var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
30
- var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
31
- var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
32
- var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
33
- var STAR = `${QMARK}*?`;
34
- var SEP = "/";
35
- var POSIX_CHARS = {
36
- DOT_LITERAL,
37
- PLUS_LITERAL,
38
- QMARK_LITERAL,
39
- SLASH_LITERAL,
40
- ONE_CHAR,
41
- QMARK,
42
- END_ANCHOR,
43
- DOTS_SLASH,
44
- NO_DOT,
45
- NO_DOTS,
46
- NO_DOT_SLASH,
47
- NO_DOTS_SLASH,
48
- QMARK_NO_DOT,
49
- STAR,
50
- START_ANCHOR,
51
- SEP
52
- };
53
- var WINDOWS_CHARS = {
54
- ...POSIX_CHARS,
55
- SLASH_LITERAL: `[${WIN_SLASH}]`,
56
- QMARK: WIN_NO_SLASH,
57
- STAR: `${WIN_NO_SLASH}*?`,
58
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
59
- NO_DOT: `(?!${DOT_LITERAL})`,
60
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
61
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
62
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
63
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
64
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
65
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
66
- SEP: "\\"
67
- };
68
- var POSIX_REGEX_SOURCE = {
69
- alnum: "a-zA-Z0-9",
70
- alpha: "a-zA-Z",
71
- ascii: "\\x00-\\x7F",
72
- blank: " \\t",
73
- cntrl: "\\x00-\\x1F\\x7F",
74
- digit: "0-9",
75
- graph: "\\x21-\\x7E",
76
- lower: "a-z",
77
- print: "\\x20-\\x7E ",
78
- punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
79
- space: " \\t\\r\\n\\v\\f",
80
- upper: "A-Z",
81
- word: "A-Za-z0-9_",
82
- xdigit: "A-Fa-f0-9"
83
- };
84
- module.exports = {
85
- MAX_LENGTH: 1024 * 64,
86
- POSIX_REGEX_SOURCE,
87
- // regular expressions
88
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
89
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
90
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
91
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
92
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
93
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
94
- // Replace globs with equivalent patterns to reduce parsing time.
95
- REPLACEMENTS: {
96
- "***": "*",
97
- "**/**": "**",
98
- "**/**/**": "**"
99
- },
100
- // Digits
101
- CHAR_0: 48,
102
- /* 0 */
103
- CHAR_9: 57,
104
- /* 9 */
105
- // Alphabet chars.
106
- CHAR_UPPERCASE_A: 65,
107
- /* A */
108
- CHAR_LOWERCASE_A: 97,
109
- /* a */
110
- CHAR_UPPERCASE_Z: 90,
111
- /* Z */
112
- CHAR_LOWERCASE_Z: 122,
113
- /* z */
114
- CHAR_LEFT_PARENTHESES: 40,
115
- /* ( */
116
- CHAR_RIGHT_PARENTHESES: 41,
117
- /* ) */
118
- CHAR_ASTERISK: 42,
119
- /* * */
120
- // Non-alphabetic chars.
121
- CHAR_AMPERSAND: 38,
122
- /* & */
123
- CHAR_AT: 64,
124
- /* @ */
125
- CHAR_BACKWARD_SLASH: 92,
126
- /* \ */
127
- CHAR_CARRIAGE_RETURN: 13,
128
- /* \r */
129
- CHAR_CIRCUMFLEX_ACCENT: 94,
130
- /* ^ */
131
- CHAR_COLON: 58,
132
- /* : */
133
- CHAR_COMMA: 44,
134
- /* , */
135
- CHAR_DOT: 46,
136
- /* . */
137
- CHAR_DOUBLE_QUOTE: 34,
138
- /* " */
139
- CHAR_EQUAL: 61,
140
- /* = */
141
- CHAR_EXCLAMATION_MARK: 33,
142
- /* ! */
143
- CHAR_FORM_FEED: 12,
144
- /* \f */
145
- CHAR_FORWARD_SLASH: 47,
146
- /* / */
147
- CHAR_GRAVE_ACCENT: 96,
148
- /* ` */
149
- CHAR_HASH: 35,
150
- /* # */
151
- CHAR_HYPHEN_MINUS: 45,
152
- /* - */
153
- CHAR_LEFT_ANGLE_BRACKET: 60,
154
- /* < */
155
- CHAR_LEFT_CURLY_BRACE: 123,
156
- /* { */
157
- CHAR_LEFT_SQUARE_BRACKET: 91,
158
- /* [ */
159
- CHAR_LINE_FEED: 10,
160
- /* \n */
161
- CHAR_NO_BREAK_SPACE: 160,
162
- /* \u00A0 */
163
- CHAR_PERCENT: 37,
164
- /* % */
165
- CHAR_PLUS: 43,
166
- /* + */
167
- CHAR_QUESTION_MARK: 63,
168
- /* ? */
169
- CHAR_RIGHT_ANGLE_BRACKET: 62,
170
- /* > */
171
- CHAR_RIGHT_CURLY_BRACE: 125,
172
- /* } */
173
- CHAR_RIGHT_SQUARE_BRACKET: 93,
174
- /* ] */
175
- CHAR_SEMICOLON: 59,
176
- /* ; */
177
- CHAR_SINGLE_QUOTE: 39,
178
- /* ' */
179
- CHAR_SPACE: 32,
180
- /* */
181
- CHAR_TAB: 9,
182
- /* \t */
183
- CHAR_UNDERSCORE: 95,
184
- /* _ */
185
- CHAR_VERTICAL_LINE: 124,
186
- /* | */
187
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
188
- /* \uFEFF */
189
- /**
190
- * Create EXTGLOB_CHARS
191
- */
192
- extglobChars(chars) {
193
- return {
194
- "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
195
- "?": { type: "qmark", open: "(?:", close: ")?" },
196
- "+": { type: "plus", open: "(?:", close: ")+" },
197
- "*": { type: "star", open: "(?:", close: ")*" },
198
- "@": { type: "at", open: "(?:", close: ")" }
199
- };
200
- },
201
- /**
202
- * Create GLOB_CHARS
203
- */
204
- globChars(win32) {
205
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
206
- }
207
- };
208
- }
209
- });
210
-
211
- // node_modules/picomatch/lib/utils.js
212
- var require_utils = __commonJS({
213
- "node_modules/picomatch/lib/utils.js"(exports) {
214
- "use strict";
215
- var {
216
- REGEX_BACKSLASH,
217
- REGEX_REMOVE_BACKSLASH,
218
- REGEX_SPECIAL_CHARS,
219
- REGEX_SPECIAL_CHARS_GLOBAL
220
- } = require_constants();
221
- exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
222
- exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
223
- exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
224
- exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
225
- exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
226
- exports.removeBackslashes = (str) => {
227
- return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
228
- return match === "\\" ? "" : match;
229
- });
230
- };
231
- exports.supportsLookbehinds = () => {
232
- if (typeof process !== "undefined") {
233
- const segs = process.version.slice(1).split(".").map(Number);
234
- if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
235
- return true;
236
- }
237
- }
238
- return false;
239
- };
240
- exports.escapeLast = (input, char, lastIdx) => {
241
- const idx = input.lastIndexOf(char, lastIdx);
242
- if (idx === -1)
243
- return input;
244
- if (input[idx - 1] === "\\")
245
- return exports.escapeLast(input, char, idx - 1);
246
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
247
- };
248
- exports.removePrefix = (input, state = {}) => {
249
- let output = input;
250
- if (output.startsWith("./")) {
251
- output = output.slice(2);
252
- state.prefix = "./";
253
- }
254
- return output;
255
- };
256
- exports.wrapOutput = (input, state = {}, options = {}) => {
257
- const prepend = options.contains ? "" : "^";
258
- const append = options.contains ? "" : "$";
259
- let output = `${prepend}(?:${input})${append}`;
260
- if (state.negated === true) {
261
- output = `(?:^(?!${output}).*$)`;
262
- }
263
- return output;
264
- };
265
- exports.basename = (path, { windows } = {}) => {
266
- const segs = path.split(windows ? /[\\/]/ : "/");
267
- const last = segs[segs.length - 1];
268
- if (last === "") {
269
- return segs[segs.length - 2];
270
- }
271
- return last;
272
- };
273
- }
274
- });
275
-
276
- // node_modules/picomatch/lib/scan.js
277
- var require_scan = __commonJS({
278
- "node_modules/picomatch/lib/scan.js"(exports, module) {
279
- "use strict";
280
- var utils = require_utils();
281
- var {
282
- CHAR_ASTERISK,
283
- /* * */
284
- CHAR_AT,
285
- /* @ */
286
- CHAR_BACKWARD_SLASH,
287
- /* \ */
288
- CHAR_COMMA,
289
- /* , */
290
- CHAR_DOT,
291
- /* . */
292
- CHAR_EXCLAMATION_MARK,
293
- /* ! */
294
- CHAR_FORWARD_SLASH,
295
- /* / */
296
- CHAR_LEFT_CURLY_BRACE,
297
- /* { */
298
- CHAR_LEFT_PARENTHESES,
299
- /* ( */
300
- CHAR_LEFT_SQUARE_BRACKET,
301
- /* [ */
302
- CHAR_PLUS,
303
- /* + */
304
- CHAR_QUESTION_MARK,
305
- /* ? */
306
- CHAR_RIGHT_CURLY_BRACE,
307
- /* } */
308
- CHAR_RIGHT_PARENTHESES,
309
- /* ) */
310
- CHAR_RIGHT_SQUARE_BRACKET
311
- /* ] */
312
- } = require_constants();
313
- var isPathSeparator = (code) => {
314
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
315
- };
316
- var depth = (token) => {
317
- if (token.isPrefix !== true) {
318
- token.depth = token.isGlobstar ? Infinity : 1;
319
- }
320
- };
321
- var scan = (input, options) => {
322
- const opts = options || {};
323
- const length = input.length - 1;
324
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
325
- const slashes = [];
326
- const tokens = [];
327
- const parts = [];
328
- let str = input;
329
- let index = -1;
330
- let start = 0;
331
- let lastIndex = 0;
332
- let isBrace = false;
333
- let isBracket = false;
334
- let isGlob = false;
335
- let isExtglob = false;
336
- let isGlobstar = false;
337
- let braceEscaped = false;
338
- let backslashes = false;
339
- let negated = false;
340
- let negatedExtglob = false;
341
- let finished = false;
342
- let braces = 0;
343
- let prev;
344
- let code;
345
- let token = { value: "", depth: 0, isGlob: false };
346
- const eos = () => index >= length;
347
- const peek = () => str.charCodeAt(index + 1);
348
- const advance = () => {
349
- prev = code;
350
- return str.charCodeAt(++index);
351
- };
352
- while (index < length) {
353
- code = advance();
354
- let next;
355
- if (code === CHAR_BACKWARD_SLASH) {
356
- backslashes = token.backslashes = true;
357
- code = advance();
358
- if (code === CHAR_LEFT_CURLY_BRACE) {
359
- braceEscaped = true;
360
- }
361
- continue;
362
- }
363
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
364
- braces++;
365
- while (eos() !== true && (code = advance())) {
366
- if (code === CHAR_BACKWARD_SLASH) {
367
- backslashes = token.backslashes = true;
368
- advance();
369
- continue;
370
- }
371
- if (code === CHAR_LEFT_CURLY_BRACE) {
372
- braces++;
373
- continue;
374
- }
375
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
376
- isBrace = token.isBrace = true;
377
- isGlob = token.isGlob = true;
378
- finished = true;
379
- if (scanToEnd === true) {
380
- continue;
381
- }
382
- break;
383
- }
384
- if (braceEscaped !== true && code === CHAR_COMMA) {
385
- isBrace = token.isBrace = true;
386
- isGlob = token.isGlob = true;
387
- finished = true;
388
- if (scanToEnd === true) {
389
- continue;
390
- }
391
- break;
392
- }
393
- if (code === CHAR_RIGHT_CURLY_BRACE) {
394
- braces--;
395
- if (braces === 0) {
396
- braceEscaped = false;
397
- isBrace = token.isBrace = true;
398
- finished = true;
399
- break;
400
- }
401
- }
402
- }
403
- if (scanToEnd === true) {
404
- continue;
405
- }
406
- break;
407
- }
408
- if (code === CHAR_FORWARD_SLASH) {
409
- slashes.push(index);
410
- tokens.push(token);
411
- token = { value: "", depth: 0, isGlob: false };
412
- if (finished === true)
413
- continue;
414
- if (prev === CHAR_DOT && index === start + 1) {
415
- start += 2;
416
- continue;
417
- }
418
- lastIndex = index + 1;
419
- continue;
420
- }
421
- if (opts.noext !== true) {
422
- const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
423
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
424
- isGlob = token.isGlob = true;
425
- isExtglob = token.isExtglob = true;
426
- finished = true;
427
- if (code === CHAR_EXCLAMATION_MARK && index === start) {
428
- negatedExtglob = true;
429
- }
430
- if (scanToEnd === true) {
431
- while (eos() !== true && (code = advance())) {
432
- if (code === CHAR_BACKWARD_SLASH) {
433
- backslashes = token.backslashes = true;
434
- code = advance();
435
- continue;
436
- }
437
- if (code === CHAR_RIGHT_PARENTHESES) {
438
- isGlob = token.isGlob = true;
439
- finished = true;
440
- break;
441
- }
442
- }
443
- continue;
444
- }
445
- break;
446
- }
447
- }
448
- if (code === CHAR_ASTERISK) {
449
- if (prev === CHAR_ASTERISK)
450
- isGlobstar = token.isGlobstar = true;
451
- isGlob = token.isGlob = true;
452
- finished = true;
453
- if (scanToEnd === true) {
454
- continue;
455
- }
456
- break;
457
- }
458
- if (code === CHAR_QUESTION_MARK) {
459
- isGlob = token.isGlob = true;
460
- finished = true;
461
- if (scanToEnd === true) {
462
- continue;
463
- }
464
- break;
465
- }
466
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
467
- while (eos() !== true && (next = advance())) {
468
- if (next === CHAR_BACKWARD_SLASH) {
469
- backslashes = token.backslashes = true;
470
- advance();
471
- continue;
472
- }
473
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
474
- isBracket = token.isBracket = true;
475
- isGlob = token.isGlob = true;
476
- finished = true;
477
- break;
478
- }
479
- }
480
- if (scanToEnd === true) {
481
- continue;
482
- }
483
- break;
484
- }
485
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
486
- negated = token.negated = true;
487
- start++;
488
- continue;
489
- }
490
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
491
- isGlob = token.isGlob = true;
492
- if (scanToEnd === true) {
493
- while (eos() !== true && (code = advance())) {
494
- if (code === CHAR_LEFT_PARENTHESES) {
495
- backslashes = token.backslashes = true;
496
- code = advance();
497
- continue;
498
- }
499
- if (code === CHAR_RIGHT_PARENTHESES) {
500
- finished = true;
501
- break;
502
- }
503
- }
504
- continue;
505
- }
506
- break;
507
- }
508
- if (isGlob === true) {
509
- finished = true;
510
- if (scanToEnd === true) {
511
- continue;
512
- }
513
- break;
514
- }
515
- }
516
- if (opts.noext === true) {
517
- isExtglob = false;
518
- isGlob = false;
519
- }
520
- let base = str;
521
- let prefix = "";
522
- let glob = "";
523
- if (start > 0) {
524
- prefix = str.slice(0, start);
525
- str = str.slice(start);
526
- lastIndex -= start;
527
- }
528
- if (base && isGlob === true && lastIndex > 0) {
529
- base = str.slice(0, lastIndex);
530
- glob = str.slice(lastIndex);
531
- } else if (isGlob === true) {
532
- base = "";
533
- glob = str;
534
- } else {
535
- base = str;
536
- }
537
- if (base && base !== "" && base !== "/" && base !== str) {
538
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
539
- base = base.slice(0, -1);
540
- }
541
- }
542
- if (opts.unescape === true) {
543
- if (glob)
544
- glob = utils.removeBackslashes(glob);
545
- if (base && backslashes === true) {
546
- base = utils.removeBackslashes(base);
547
- }
548
- }
549
- const state = {
550
- prefix,
551
- input,
552
- start,
553
- base,
554
- glob,
555
- isBrace,
556
- isBracket,
557
- isGlob,
558
- isExtglob,
559
- isGlobstar,
560
- negated,
561
- negatedExtglob
562
- };
563
- if (opts.tokens === true) {
564
- state.maxDepth = 0;
565
- if (!isPathSeparator(code)) {
566
- tokens.push(token);
567
- }
568
- state.tokens = tokens;
569
- }
570
- if (opts.parts === true || opts.tokens === true) {
571
- let prevIndex;
572
- for (let idx = 0; idx < slashes.length; idx++) {
573
- const n = prevIndex ? prevIndex + 1 : start;
574
- const i = slashes[idx];
575
- const value = input.slice(n, i);
576
- if (opts.tokens) {
577
- if (idx === 0 && start !== 0) {
578
- tokens[idx].isPrefix = true;
579
- tokens[idx].value = prefix;
580
- } else {
581
- tokens[idx].value = value;
582
- }
583
- depth(tokens[idx]);
584
- state.maxDepth += tokens[idx].depth;
585
- }
586
- if (idx !== 0 || value !== "") {
587
- parts.push(value);
588
- }
589
- prevIndex = i;
590
- }
591
- if (prevIndex && prevIndex + 1 < input.length) {
592
- const value = input.slice(prevIndex + 1);
593
- parts.push(value);
594
- if (opts.tokens) {
595
- tokens[tokens.length - 1].value = value;
596
- depth(tokens[tokens.length - 1]);
597
- state.maxDepth += tokens[tokens.length - 1].depth;
598
- }
599
- }
600
- state.slashes = slashes;
601
- state.parts = parts;
602
- }
603
- return state;
604
- };
605
- module.exports = scan;
606
- }
607
- });
608
-
609
- // node_modules/picomatch/lib/parse.js
610
- var require_parse = __commonJS({
611
- "node_modules/picomatch/lib/parse.js"(exports, module) {
612
- "use strict";
613
- var constants = require_constants();
614
- var utils = require_utils();
615
- var {
616
- MAX_LENGTH,
617
- POSIX_REGEX_SOURCE,
618
- REGEX_NON_SPECIAL_CHARS,
619
- REGEX_SPECIAL_CHARS_BACKREF,
620
- REPLACEMENTS
621
- } = constants;
622
- var expandRange = (args, options) => {
623
- if (typeof options.expandRange === "function") {
624
- return options.expandRange(...args, options);
625
- }
626
- args.sort();
627
- const value = `[${args.join("-")}]`;
628
- try {
629
- new RegExp(value);
630
- } catch (ex) {
631
- return args.map((v) => utils.escapeRegex(v)).join("..");
632
- }
633
- return value;
634
- };
635
- var syntaxError = (type, char) => {
636
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
637
- };
638
- var parse = (input, options) => {
639
- if (typeof input !== "string") {
640
- throw new TypeError("Expected a string");
641
- }
642
- input = REPLACEMENTS[input] || input;
643
- const opts = { ...options };
644
- const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
645
- let len = input.length;
646
- if (len > max) {
647
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
648
- }
649
- const bos = { type: "bos", value: "", output: opts.prepend || "" };
650
- const tokens = [bos];
651
- const capture = opts.capture ? "" : "?:";
652
- const PLATFORM_CHARS = constants.globChars(opts.windows);
653
- const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
654
- const {
655
- DOT_LITERAL,
656
- PLUS_LITERAL,
657
- SLASH_LITERAL,
658
- ONE_CHAR,
659
- DOTS_SLASH,
660
- NO_DOT,
661
- NO_DOT_SLASH,
662
- NO_DOTS_SLASH,
663
- QMARK,
664
- QMARK_NO_DOT,
665
- STAR,
666
- START_ANCHOR
667
- } = PLATFORM_CHARS;
668
- const globstar = (opts2) => {
669
- return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
670
- };
671
- const nodot = opts.dot ? "" : NO_DOT;
672
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
673
- let star = opts.bash === true ? globstar(opts) : STAR;
674
- if (opts.capture) {
675
- star = `(${star})`;
676
- }
677
- if (typeof opts.noext === "boolean") {
678
- opts.noextglob = opts.noext;
679
- }
680
- const state = {
681
- input,
682
- index: -1,
683
- start: 0,
684
- dot: opts.dot === true,
685
- consumed: "",
686
- output: "",
687
- prefix: "",
688
- backtrack: false,
689
- negated: false,
690
- brackets: 0,
691
- braces: 0,
692
- parens: 0,
693
- quotes: 0,
694
- globstar: false,
695
- tokens
696
- };
697
- input = utils.removePrefix(input, state);
698
- len = input.length;
699
- const extglobs = [];
700
- const braces = [];
701
- const stack = [];
702
- let prev = bos;
703
- let value;
704
- const eos = () => state.index === len - 1;
705
- const peek = state.peek = (n = 1) => input[state.index + n];
706
- const advance = state.advance = () => input[++state.index] || "";
707
- const remaining = () => input.slice(state.index + 1);
708
- const consume = (value2 = "", num = 0) => {
709
- state.consumed += value2;
710
- state.index += num;
711
- };
712
- const append = (token) => {
713
- state.output += token.output != null ? token.output : token.value;
714
- consume(token.value);
715
- };
716
- const negate = () => {
717
- let count = 1;
718
- while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
719
- advance();
720
- state.start++;
721
- count++;
722
- }
723
- if (count % 2 === 0) {
724
- return false;
725
- }
726
- state.negated = true;
727
- state.start++;
728
- return true;
729
- };
730
- const increment = (type) => {
731
- state[type]++;
732
- stack.push(type);
733
- };
734
- const decrement = (type) => {
735
- state[type]--;
736
- stack.pop();
737
- };
738
- const push = (tok) => {
739
- if (prev.type === "globstar") {
740
- const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
741
- const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
742
- if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
743
- state.output = state.output.slice(0, -prev.output.length);
744
- prev.type = "star";
745
- prev.value = "*";
746
- prev.output = star;
747
- state.output += prev.output;
748
- }
749
- }
750
- if (extglobs.length && tok.type !== "paren") {
751
- extglobs[extglobs.length - 1].inner += tok.value;
752
- }
753
- if (tok.value || tok.output)
754
- append(tok);
755
- if (prev && prev.type === "text" && tok.type === "text") {
756
- prev.value += tok.value;
757
- prev.output = (prev.output || "") + tok.value;
758
- return;
759
- }
760
- tok.prev = prev;
761
- tokens.push(tok);
762
- prev = tok;
763
- };
764
- const extglobOpen = (type, value2) => {
765
- const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
766
- token.prev = prev;
767
- token.parens = state.parens;
768
- token.output = state.output;
769
- const output = (opts.capture ? "(" : "") + token.open;
770
- increment("parens");
771
- push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
772
- push({ type: "paren", extglob: true, value: advance(), output });
773
- extglobs.push(token);
774
- };
775
- const extglobClose = (token) => {
776
- let output = token.close + (opts.capture ? ")" : "");
777
- let rest;
778
- if (token.type === "negate") {
779
- let extglobStar = star;
780
- if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
781
- extglobStar = globstar(opts);
782
- }
783
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
784
- output = token.close = `)$))${extglobStar}`;
785
- }
786
- if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
787
- const expression = parse(rest, { ...options, fastpaths: false }).output;
788
- output = token.close = `)${expression})${extglobStar})`;
789
- }
790
- if (token.prev.type === "bos") {
791
- state.negatedExtglob = true;
792
- }
793
- }
794
- push({ type: "paren", extglob: true, value, output });
795
- decrement("parens");
796
- };
797
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
798
- let backslashes = false;
799
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
800
- if (first === "\\") {
801
- backslashes = true;
802
- return m;
803
- }
804
- if (first === "?") {
805
- if (esc) {
806
- return esc + first + (rest ? QMARK.repeat(rest.length) : "");
807
- }
808
- if (index === 0) {
809
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
810
- }
811
- return QMARK.repeat(chars.length);
812
- }
813
- if (first === ".") {
814
- return DOT_LITERAL.repeat(chars.length);
815
- }
816
- if (first === "*") {
817
- if (esc) {
818
- return esc + first + (rest ? star : "");
819
- }
820
- return star;
821
- }
822
- return esc ? m : `\\${m}`;
823
- });
824
- if (backslashes === true) {
825
- if (opts.unescape === true) {
826
- output = output.replace(/\\/g, "");
827
- } else {
828
- output = output.replace(/\\+/g, (m) => {
829
- return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
830
- });
831
- }
832
- }
833
- if (output === input && opts.contains === true) {
834
- state.output = input;
835
- return state;
836
- }
837
- state.output = utils.wrapOutput(output, state, options);
838
- return state;
839
- }
840
- while (!eos()) {
841
- value = advance();
842
- if (value === "\0") {
843
- continue;
844
- }
845
- if (value === "\\") {
846
- const next = peek();
847
- if (next === "/" && opts.bash !== true) {
848
- continue;
849
- }
850
- if (next === "." || next === ";") {
851
- continue;
852
- }
853
- if (!next) {
854
- value += "\\";
855
- push({ type: "text", value });
856
- continue;
857
- }
858
- const match = /^\\+/.exec(remaining());
859
- let slashes = 0;
860
- if (match && match[0].length > 2) {
861
- slashes = match[0].length;
862
- state.index += slashes;
863
- if (slashes % 2 !== 0) {
864
- value += "\\";
865
- }
866
- }
867
- if (opts.unescape === true) {
868
- value = advance();
869
- } else {
870
- value += advance();
871
- }
872
- if (state.brackets === 0) {
873
- push({ type: "text", value });
874
- continue;
875
- }
876
- }
877
- if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
878
- if (opts.posix !== false && value === ":") {
879
- const inner = prev.value.slice(1);
880
- if (inner.includes("[")) {
881
- prev.posix = true;
882
- if (inner.includes(":")) {
883
- const idx = prev.value.lastIndexOf("[");
884
- const pre = prev.value.slice(0, idx);
885
- const rest2 = prev.value.slice(idx + 2);
886
- const posix = POSIX_REGEX_SOURCE[rest2];
887
- if (posix) {
888
- prev.value = pre + posix;
889
- state.backtrack = true;
890
- advance();
891
- if (!bos.output && tokens.indexOf(prev) === 1) {
892
- bos.output = ONE_CHAR;
893
- }
894
- continue;
895
- }
896
- }
897
- }
898
- }
899
- if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
900
- value = `\\${value}`;
901
- }
902
- if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
903
- value = `\\${value}`;
904
- }
905
- if (opts.posix === true && value === "!" && prev.value === "[") {
906
- value = "^";
907
- }
908
- prev.value += value;
909
- append({ value });
910
- continue;
911
- }
912
- if (state.quotes === 1 && value !== '"') {
913
- value = utils.escapeRegex(value);
914
- prev.value += value;
915
- append({ value });
916
- continue;
917
- }
918
- if (value === '"') {
919
- state.quotes = state.quotes === 1 ? 0 : 1;
920
- if (opts.keepQuotes === true) {
921
- push({ type: "text", value });
922
- }
923
- continue;
924
- }
925
- if (value === "(") {
926
- increment("parens");
927
- push({ type: "paren", value });
928
- continue;
929
- }
930
- if (value === ")") {
931
- if (state.parens === 0 && opts.strictBrackets === true) {
932
- throw new SyntaxError(syntaxError("opening", "("));
933
- }
934
- const extglob = extglobs[extglobs.length - 1];
935
- if (extglob && state.parens === extglob.parens + 1) {
936
- extglobClose(extglobs.pop());
937
- continue;
938
- }
939
- push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
940
- decrement("parens");
941
- continue;
942
- }
943
- if (value === "[") {
944
- if (opts.nobracket === true || !remaining().includes("]")) {
945
- if (opts.nobracket !== true && opts.strictBrackets === true) {
946
- throw new SyntaxError(syntaxError("closing", "]"));
947
- }
948
- value = `\\${value}`;
949
- } else {
950
- increment("brackets");
951
- }
952
- push({ type: "bracket", value });
953
- continue;
954
- }
955
- if (value === "]") {
956
- if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
957
- push({ type: "text", value, output: `\\${value}` });
958
- continue;
959
- }
960
- if (state.brackets === 0) {
961
- if (opts.strictBrackets === true) {
962
- throw new SyntaxError(syntaxError("opening", "["));
963
- }
964
- push({ type: "text", value, output: `\\${value}` });
965
- continue;
966
- }
967
- decrement("brackets");
968
- const prevValue = prev.value.slice(1);
969
- if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
970
- value = `/${value}`;
971
- }
972
- prev.value += value;
973
- append({ value });
974
- if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
975
- continue;
976
- }
977
- const escaped = utils.escapeRegex(prev.value);
978
- state.output = state.output.slice(0, -prev.value.length);
979
- if (opts.literalBrackets === true) {
980
- state.output += escaped;
981
- prev.value = escaped;
982
- continue;
983
- }
984
- prev.value = `(${capture}${escaped}|${prev.value})`;
985
- state.output += prev.value;
986
- continue;
987
- }
988
- if (value === "{" && opts.nobrace !== true) {
989
- increment("braces");
990
- const open = {
991
- type: "brace",
992
- value,
993
- output: "(",
994
- outputIndex: state.output.length,
995
- tokensIndex: state.tokens.length
996
- };
997
- braces.push(open);
998
- push(open);
999
- continue;
1000
- }
1001
- if (value === "}") {
1002
- const brace = braces[braces.length - 1];
1003
- if (opts.nobrace === true || !brace) {
1004
- push({ type: "text", value, output: value });
1005
- continue;
1006
- }
1007
- let output = ")";
1008
- if (brace.dots === true) {
1009
- const arr = tokens.slice();
1010
- const range = [];
1011
- for (let i = arr.length - 1; i >= 0; i--) {
1012
- tokens.pop();
1013
- if (arr[i].type === "brace") {
1014
- break;
1015
- }
1016
- if (arr[i].type !== "dots") {
1017
- range.unshift(arr[i].value);
1018
- }
1019
- }
1020
- output = expandRange(range, opts);
1021
- state.backtrack = true;
1022
- }
1023
- if (brace.comma !== true && brace.dots !== true) {
1024
- const out = state.output.slice(0, brace.outputIndex);
1025
- const toks = state.tokens.slice(brace.tokensIndex);
1026
- brace.value = brace.output = "\\{";
1027
- value = output = "\\}";
1028
- state.output = out;
1029
- for (const t of toks) {
1030
- state.output += t.output || t.value;
1031
- }
1032
- }
1033
- push({ type: "brace", value, output });
1034
- decrement("braces");
1035
- braces.pop();
1036
- continue;
1037
- }
1038
- if (value === "|") {
1039
- if (extglobs.length > 0) {
1040
- extglobs[extglobs.length - 1].conditions++;
1041
- }
1042
- push({ type: "text", value });
1043
- continue;
1044
- }
1045
- if (value === ",") {
1046
- let output = value;
1047
- const brace = braces[braces.length - 1];
1048
- if (brace && stack[stack.length - 1] === "braces") {
1049
- brace.comma = true;
1050
- output = "|";
1051
- }
1052
- push({ type: "comma", value, output });
1053
- continue;
1054
- }
1055
- if (value === "/") {
1056
- if (prev.type === "dot" && state.index === state.start + 1) {
1057
- state.start = state.index + 1;
1058
- state.consumed = "";
1059
- state.output = "";
1060
- tokens.pop();
1061
- prev = bos;
1062
- continue;
1063
- }
1064
- push({ type: "slash", value, output: SLASH_LITERAL });
1065
- continue;
1066
- }
1067
- if (value === ".") {
1068
- if (state.braces > 0 && prev.type === "dot") {
1069
- if (prev.value === ".")
1070
- prev.output = DOT_LITERAL;
1071
- const brace = braces[braces.length - 1];
1072
- prev.type = "dots";
1073
- prev.output += value;
1074
- prev.value += value;
1075
- brace.dots = true;
1076
- continue;
1077
- }
1078
- if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1079
- push({ type: "text", value, output: DOT_LITERAL });
1080
- continue;
1081
- }
1082
- push({ type: "dot", value, output: DOT_LITERAL });
1083
- continue;
1084
- }
1085
- if (value === "?") {
1086
- const isGroup = prev && prev.value === "(";
1087
- if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1088
- extglobOpen("qmark", value);
1089
- continue;
1090
- }
1091
- if (prev && prev.type === "paren") {
1092
- const next = peek();
1093
- let output = value;
1094
- if (next === "<" && !utils.supportsLookbehinds()) {
1095
- throw new Error("Node.js v10 or higher is required for regex lookbehinds");
1096
- }
1097
- if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
1098
- output = `\\${value}`;
1099
- }
1100
- push({ type: "text", value, output });
1101
- continue;
1102
- }
1103
- if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1104
- push({ type: "qmark", value, output: QMARK_NO_DOT });
1105
- continue;
1106
- }
1107
- push({ type: "qmark", value, output: QMARK });
1108
- continue;
1109
- }
1110
- if (value === "!") {
1111
- if (opts.noextglob !== true && peek() === "(") {
1112
- if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1113
- extglobOpen("negate", value);
1114
- continue;
1115
- }
1116
- }
1117
- if (opts.nonegate !== true && state.index === 0) {
1118
- negate();
1119
- continue;
1120
- }
1121
- }
1122
- if (value === "+") {
1123
- if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1124
- extglobOpen("plus", value);
1125
- continue;
1126
- }
1127
- if (prev && prev.value === "(" || opts.regex === false) {
1128
- push({ type: "plus", value, output: PLUS_LITERAL });
1129
- continue;
1130
- }
1131
- if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1132
- push({ type: "plus", value });
1133
- continue;
1134
- }
1135
- push({ type: "plus", value: PLUS_LITERAL });
1136
- continue;
1137
- }
1138
- if (value === "@") {
1139
- if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1140
- push({ type: "at", extglob: true, value, output: "" });
1141
- continue;
1142
- }
1143
- push({ type: "text", value });
1144
- continue;
1145
- }
1146
- if (value !== "*") {
1147
- if (value === "$" || value === "^") {
1148
- value = `\\${value}`;
1149
- }
1150
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1151
- if (match) {
1152
- value += match[0];
1153
- state.index += match[0].length;
1154
- }
1155
- push({ type: "text", value });
1156
- continue;
1157
- }
1158
- if (prev && (prev.type === "globstar" || prev.star === true)) {
1159
- prev.type = "star";
1160
- prev.star = true;
1161
- prev.value += value;
1162
- prev.output = star;
1163
- state.backtrack = true;
1164
- state.globstar = true;
1165
- consume(value);
1166
- continue;
1167
- }
1168
- let rest = remaining();
1169
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1170
- extglobOpen("star", value);
1171
- continue;
1172
- }
1173
- if (prev.type === "star") {
1174
- if (opts.noglobstar === true) {
1175
- consume(value);
1176
- continue;
1177
- }
1178
- const prior = prev.prev;
1179
- const before = prior.prev;
1180
- const isStart = prior.type === "slash" || prior.type === "bos";
1181
- const afterStar = before && (before.type === "star" || before.type === "globstar");
1182
- if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1183
- push({ type: "star", value, output: "" });
1184
- continue;
1185
- }
1186
- const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1187
- const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1188
- if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1189
- push({ type: "star", value, output: "" });
1190
- continue;
1191
- }
1192
- while (rest.slice(0, 3) === "/**") {
1193
- const after = input[state.index + 4];
1194
- if (after && after !== "/") {
1195
- break;
1196
- }
1197
- rest = rest.slice(3);
1198
- consume("/**", 3);
1199
- }
1200
- if (prior.type === "bos" && eos()) {
1201
- prev.type = "globstar";
1202
- prev.value += value;
1203
- prev.output = globstar(opts);
1204
- state.output = prev.output;
1205
- state.globstar = true;
1206
- consume(value);
1207
- continue;
1208
- }
1209
- if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1210
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1211
- prior.output = `(?:${prior.output}`;
1212
- prev.type = "globstar";
1213
- prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1214
- prev.value += value;
1215
- state.globstar = true;
1216
- state.output += prior.output + prev.output;
1217
- consume(value);
1218
- continue;
1219
- }
1220
- if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1221
- const end = rest[1] !== void 0 ? "|$" : "";
1222
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1223
- prior.output = `(?:${prior.output}`;
1224
- prev.type = "globstar";
1225
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
1226
- prev.value += value;
1227
- state.output += prior.output + prev.output;
1228
- state.globstar = true;
1229
- consume(value + advance());
1230
- push({ type: "slash", value: "/", output: "" });
1231
- continue;
1232
- }
1233
- if (prior.type === "bos" && rest[0] === "/") {
1234
- prev.type = "globstar";
1235
- prev.value += value;
1236
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1237
- state.output = prev.output;
1238
- state.globstar = true;
1239
- consume(value + advance());
1240
- push({ type: "slash", value: "/", output: "" });
1241
- continue;
1242
- }
1243
- state.output = state.output.slice(0, -prev.output.length);
1244
- prev.type = "globstar";
1245
- prev.output = globstar(opts);
1246
- prev.value += value;
1247
- state.output += prev.output;
1248
- state.globstar = true;
1249
- consume(value);
1250
- continue;
1251
- }
1252
- const token = { type: "star", value, output: star };
1253
- if (opts.bash === true) {
1254
- token.output = ".*?";
1255
- if (prev.type === "bos" || prev.type === "slash") {
1256
- token.output = nodot + token.output;
1257
- }
1258
- push(token);
1259
- continue;
1260
- }
1261
- if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1262
- token.output = value;
1263
- push(token);
1264
- continue;
1265
- }
1266
- if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1267
- if (prev.type === "dot") {
1268
- state.output += NO_DOT_SLASH;
1269
- prev.output += NO_DOT_SLASH;
1270
- } else if (opts.dot === true) {
1271
- state.output += NO_DOTS_SLASH;
1272
- prev.output += NO_DOTS_SLASH;
1273
- } else {
1274
- state.output += nodot;
1275
- prev.output += nodot;
1276
- }
1277
- if (peek() !== "*") {
1278
- state.output += ONE_CHAR;
1279
- prev.output += ONE_CHAR;
1280
- }
1281
- }
1282
- push(token);
1283
- }
1284
- while (state.brackets > 0) {
1285
- if (opts.strictBrackets === true)
1286
- throw new SyntaxError(syntaxError("closing", "]"));
1287
- state.output = utils.escapeLast(state.output, "[");
1288
- decrement("brackets");
1289
- }
1290
- while (state.parens > 0) {
1291
- if (opts.strictBrackets === true)
1292
- throw new SyntaxError(syntaxError("closing", ")"));
1293
- state.output = utils.escapeLast(state.output, "(");
1294
- decrement("parens");
1295
- }
1296
- while (state.braces > 0) {
1297
- if (opts.strictBrackets === true)
1298
- throw new SyntaxError(syntaxError("closing", "}"));
1299
- state.output = utils.escapeLast(state.output, "{");
1300
- decrement("braces");
1301
- }
1302
- if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
1303
- push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
1304
- }
1305
- if (state.backtrack === true) {
1306
- state.output = "";
1307
- for (const token of state.tokens) {
1308
- state.output += token.output != null ? token.output : token.value;
1309
- if (token.suffix) {
1310
- state.output += token.suffix;
1311
- }
1312
- }
1313
- }
1314
- return state;
1315
- };
1316
- parse.fastpaths = (input, options) => {
1317
- const opts = { ...options };
1318
- const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1319
- const len = input.length;
1320
- if (len > max) {
1321
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1322
- }
1323
- input = REPLACEMENTS[input] || input;
1324
- const {
1325
- DOT_LITERAL,
1326
- SLASH_LITERAL,
1327
- ONE_CHAR,
1328
- DOTS_SLASH,
1329
- NO_DOT,
1330
- NO_DOTS,
1331
- NO_DOTS_SLASH,
1332
- STAR,
1333
- START_ANCHOR
1334
- } = constants.globChars(opts.windows);
1335
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
1336
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1337
- const capture = opts.capture ? "" : "?:";
1338
- const state = { negated: false, prefix: "" };
1339
- let star = opts.bash === true ? ".*?" : STAR;
1340
- if (opts.capture) {
1341
- star = `(${star})`;
1342
- }
1343
- const globstar = (opts2) => {
1344
- if (opts2.noglobstar === true)
1345
- return star;
1346
- return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1347
- };
1348
- const create = (str) => {
1349
- switch (str) {
1350
- case "*":
1351
- return `${nodot}${ONE_CHAR}${star}`;
1352
- case ".*":
1353
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1354
- case "*.*":
1355
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1356
- case "*/*":
1357
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1358
- case "**":
1359
- return nodot + globstar(opts);
1360
- case "**/*":
1361
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1362
- case "**/*.*":
1363
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1364
- case "**/.*":
1365
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1366
- default: {
1367
- const match = /^(.*?)\.(\w+)$/.exec(str);
1368
- if (!match)
1369
- return;
1370
- const source2 = create(match[1]);
1371
- if (!source2)
1372
- return;
1373
- return source2 + DOT_LITERAL + match[2];
1374
- }
1375
- }
1376
- };
1377
- const output = utils.removePrefix(input, state);
1378
- let source = create(output);
1379
- if (source && opts.strictSlashes !== true) {
1380
- source += `${SLASH_LITERAL}?`;
1381
- }
1382
- return source;
1383
- };
1384
- module.exports = parse;
1385
- }
1386
- });
1387
-
1388
- // node_modules/picomatch/lib/picomatch.js
1389
- var require_picomatch = __commonJS({
1390
- "node_modules/picomatch/lib/picomatch.js"(exports, module) {
1391
- "use strict";
1392
- var scan = require_scan();
1393
- var parse = require_parse();
1394
- var utils = require_utils();
1395
- var constants = require_constants();
1396
- var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1397
- var picomatch = (glob, options, returnState = false) => {
1398
- if (Array.isArray(glob)) {
1399
- const fns = glob.map((input) => picomatch(input, options, returnState));
1400
- const arrayMatcher = (str) => {
1401
- for (const isMatch of fns) {
1402
- const state2 = isMatch(str);
1403
- if (state2)
1404
- return state2;
1405
- }
1406
- return false;
1407
- };
1408
- return arrayMatcher;
1409
- }
1410
- const isState = isObject(glob) && glob.tokens && glob.input;
1411
- if (glob === "" || typeof glob !== "string" && !isState) {
1412
- throw new TypeError("Expected pattern to be a non-empty string");
1413
- }
1414
- const opts = options || {};
1415
- const posix = opts.windows;
1416
- const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
1417
- const state = regex.state;
1418
- delete regex.state;
1419
- let isIgnored = () => false;
1420
- if (opts.ignore) {
1421
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
1422
- isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
1423
- }
1424
- const matcher = (input, returnObject = false) => {
1425
- const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
1426
- const result = { glob, state, regex, posix, input, output, match, isMatch };
1427
- if (typeof opts.onResult === "function") {
1428
- opts.onResult(result);
1429
- }
1430
- if (isMatch === false) {
1431
- result.isMatch = false;
1432
- return returnObject ? result : false;
1433
- }
1434
- if (isIgnored(input)) {
1435
- if (typeof opts.onIgnore === "function") {
1436
- opts.onIgnore(result);
1437
- }
1438
- result.isMatch = false;
1439
- return returnObject ? result : false;
1440
- }
1441
- if (typeof opts.onMatch === "function") {
1442
- opts.onMatch(result);
1443
- }
1444
- return returnObject ? result : true;
1445
- };
1446
- if (returnState) {
1447
- matcher.state = state;
1448
- }
1449
- return matcher;
1450
- };
1451
- picomatch.test = (input, regex, options, { glob, posix } = {}) => {
1452
- if (typeof input !== "string") {
1453
- throw new TypeError("Expected input to be a string");
1454
- }
1455
- if (input === "") {
1456
- return { isMatch: false, output: "" };
1457
- }
1458
- const opts = options || {};
1459
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
1460
- let match = input === glob;
1461
- let output = match && format ? format(input) : input;
1462
- if (match === false) {
1463
- output = format ? format(input) : input;
1464
- match = output === glob;
1465
- }
1466
- if (match === false || opts.capture === true) {
1467
- if (opts.matchBase === true || opts.basename === true) {
1468
- match = picomatch.matchBase(input, regex, options, posix);
1469
- } else {
1470
- match = regex.exec(output);
1471
- }
1472
- }
1473
- return { isMatch: Boolean(match), match, output };
1474
- };
1475
- picomatch.matchBase = (input, glob, options) => {
1476
- const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
1477
- return regex.test(utils.basename(input));
1478
- };
1479
- picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
1480
- picomatch.parse = (pattern, options) => {
1481
- if (Array.isArray(pattern))
1482
- return pattern.map((p) => picomatch.parse(p, options));
1483
- return parse(pattern, { ...options, fastpaths: false });
1484
- };
1485
- picomatch.scan = (input, options) => scan(input, options);
1486
- picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
1487
- if (returnOutput === true) {
1488
- return state.output;
1489
- }
1490
- const opts = options || {};
1491
- const prepend = opts.contains ? "" : "^";
1492
- const append = opts.contains ? "" : "$";
1493
- let source = `${prepend}(?:${state.output})${append}`;
1494
- if (state && state.negated === true) {
1495
- source = `^(?!${source}).*$`;
1496
- }
1497
- const regex = picomatch.toRegex(source, options);
1498
- if (returnState === true) {
1499
- regex.state = state;
1500
- }
1501
- return regex;
1502
- };
1503
- picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
1504
- if (!input || typeof input !== "string") {
1505
- throw new TypeError("Expected a non-empty string");
1506
- }
1507
- let parsed = { negated: false, fastpaths: true };
1508
- if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
1509
- parsed.output = parse.fastpaths(input, options);
1510
- }
1511
- if (!parsed.output) {
1512
- parsed = parse(input, options);
1513
- }
1514
- return picomatch.compileRe(parsed, options, returnOutput, returnState);
1515
- };
1516
- picomatch.toRegex = (source, options) => {
1517
- try {
1518
- const opts = options || {};
1519
- return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1520
- } catch (err) {
1521
- if (options && options.debug === true)
1522
- throw err;
1523
- return /$^/;
1524
- }
1525
- };
1526
- picomatch.constants = constants;
1527
- module.exports = picomatch;
1528
- }
1529
- });
1530
-
1531
- // node_modules/picomatch/index.js
1532
- var require_picomatch2 = __commonJS({
1533
- "node_modules/picomatch/index.js"(exports, module) {
1534
- "use strict";
1535
- var os = __require("os");
1536
- var pico = require_picomatch();
1537
- var isWindows = os.platform() === "win32";
1538
- function picomatch(glob, options, returnState = false) {
1539
- if (options && (options.windows === null || options.windows === void 0)) {
1540
- options = { ...options, windows: isWindows };
1541
- }
1542
- return pico(glob, options, returnState);
1543
- }
1544
- module.exports = picomatch;
1545
- module.exports.test = pico.test;
1546
- module.exports.matchBase = pico.matchBase;
1547
- module.exports.isMatch = pico.isMatch;
1548
- module.exports.parse = pico.parse;
1549
- module.exports.scan = pico.scan;
1550
- module.exports.compileRe = pico.compileRe;
1551
- module.exports.toRegex = pico.toRegex;
1552
- module.exports.makeRe = pico.makeRe;
1553
- }
1554
- });
1555
-
1556
- // src/build/image-cdn.ts
1557
- var import_picomatch = __toESM(require_picomatch2(), 1);
1558
- function generateRegexFromPattern(pattern) {
1559
- return (0, import_picomatch.makeRe)(pattern).source;
1560
- }
1561
- var setImageConfig = async (ctx) => {
1562
- const {
1563
- images: { domains, remotePatterns, path: imageEndpointPath, loader: imageLoader }
1564
- } = await ctx.buildConfig;
1565
- if (imageLoader !== "default") {
1566
- return;
1567
- }
1568
- ctx.netlifyConfig.redirects.push(
1569
- {
1570
- from: imageEndpointPath,
1571
- // w and q are too short to be used as params with id-length rule
1572
- // but we are forced to do so because of the next/image loader decides on their names
1573
- // eslint-disable-next-line id-length
1574
- query: { url: ":url", w: ":width", q: ":quality" },
1575
- to: "/.netlify/images?url=:url&w=:width&q=:quality",
1576
- status: 200
1577
- },
1578
- // when migrating from @netlify/plugin-nextjs@4 image redirect to ipx might be cached in the browser
1579
- {
1580
- from: "/_ipx/*",
1581
- // w and q are too short to be used as params with id-length rule
1582
- // but we are forced to do so because of the next/image loader decides on their names
1583
- // eslint-disable-next-line id-length
1584
- query: { url: ":url", w: ":width", q: ":quality" },
1585
- to: "/.netlify/images?url=:url&w=:width&q=:quality",
1586
- status: 200
1587
- }
1588
- );
1589
- if (remotePatterns?.length !== 0 || domains?.length !== 0) {
1590
- ctx.netlifyConfig.images ||= { remote_images: [] };
1591
- ctx.netlifyConfig.images.remote_images ||= [];
1592
- if (remotePatterns && remotePatterns.length !== 0) {
1593
- for (const remotePattern of remotePatterns) {
1594
- let { protocol, hostname, port, pathname } = remotePattern;
1595
- if (pathname) {
1596
- pathname = pathname.startsWith("/") ? pathname : `/${pathname}`;
1597
- }
1598
- const combinedRemotePattern = `${protocol ?? "http?(s)"}://${hostname}${port ? `:${port}` : ""}${pathname ?? "/**"}`;
1599
- try {
1600
- ctx.netlifyConfig.images.remote_images.push(
1601
- generateRegexFromPattern(combinedRemotePattern)
1602
- );
1603
- } catch (error) {
1604
- ctx.failBuild(
1605
- `Failed to generate Image CDN remote image regex from Next.js remote pattern: ${JSON.stringify(
1606
- { remotePattern, combinedRemotePattern },
1607
- null,
1608
- 2
1609
- )}`,
1610
- error
1611
- );
1612
- }
1613
- }
1614
- }
1615
- if (domains && domains.length !== 0) {
1616
- for (const domain of domains) {
1617
- const patternFromDomain = `http?(s)://${domain}/**`;
1618
- try {
1619
- ctx.netlifyConfig.images.remote_images.push(generateRegexFromPattern(patternFromDomain));
1620
- } catch (error) {
1621
- ctx.failBuild(
1622
- `Failed to generate Image CDN remote image regex from Next.js domain: ${JSON.stringify(
1623
- { domain, patternFromDomain },
1624
- null,
1625
- 2
1626
- )}`,
1627
- error
1628
- );
1629
- }
1630
- }
1631
- }
1632
- }
1633
- };
1634
-
1635
- export {
1636
- setImageConfig
1637
- };