@rspack/dev-server 2.0.0 → 2.0.2

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 (43) hide show
  1. package/package.json +28 -29
  2. package/client/clients/WebSocketClient.d.ts +0 -17
  3. package/client/clients/WebSocketClient.js +0 -32
  4. package/client/index.d.ts +0 -17
  5. package/client/index.js +0 -356
  6. package/client/modules/logger/Logger.d.ts +0 -39
  7. package/client/modules/logger/Logger.js +0 -121
  8. package/client/modules/logger/createConsoleLogger.d.ts +0 -12
  9. package/client/modules/logger/createConsoleLogger.js +0 -119
  10. package/client/modules/logger/index.d.ts +0 -26
  11. package/client/modules/logger/index.js +0 -32
  12. package/client/modules/types.d.ts +0 -45
  13. package/client/modules/types.js +0 -17
  14. package/client/overlay.d.ts +0 -47
  15. package/client/overlay.js +0 -454
  16. package/client/progress.d.ts +0 -11
  17. package/client/progress.js +0 -197
  18. package/client/socket.d.ts +0 -15
  19. package/client/socket.js +0 -34
  20. package/client/type.d.ts +0 -15
  21. package/client/type.js +0 -1
  22. package/client/utils/ansiHTML.d.ts +0 -30
  23. package/client/utils/ansiHTML.js +0 -195
  24. package/client/utils/log.d.ts +0 -13
  25. package/client/utils/log.js +0 -11
  26. package/client/utils/sendMessage.d.ts +0 -11
  27. package/client/utils/sendMessage.js +0 -8
  28. package/dist/0~chokidar.js +0 -1477
  29. package/dist/0~chokidar.js.LICENSE.txt +0 -1
  30. package/dist/0~connect-history-api-fallback.js +0 -76
  31. package/dist/0~connect-next.js +0 -1245
  32. package/dist/0~connect-next.js.LICENSE.txt +0 -57
  33. package/dist/0~debug.js +0 -621
  34. package/dist/0~http-proxy-middleware.js +0 -3777
  35. package/dist/0~http-proxy-middleware.js.LICENSE.txt +0 -34
  36. package/dist/0~launch-editor.js +0 -601
  37. package/dist/0~open.js +0 -555
  38. package/dist/0~p-retry.js +0 -161
  39. package/dist/0~serve-static.js +0 -1595
  40. package/dist/0~serve-static.js.LICENSE.txt +0 -108
  41. package/dist/198.js +0 -5113
  42. package/dist/index.d.ts +0 -587
  43. package/dist/index.js +0 -1
@@ -1,3777 +0,0 @@
1
- /*! LICENSE: 0~http-proxy-middleware.js.LICENSE.txt */
2
- import node_http from "node:http";
3
- import node_https from "node:https";
4
- import node_http2 from "node:http2";
5
- import { EventEmitter } from "node:events";
6
- import "node:net";
7
- import "node:stream";
8
- import { URL as external_node_url_URL } from "node:url";
9
- import "node:zlib";
10
- import "node:querystring";
11
- import { __webpack_require__ } from "./198.js";
12
- import "./0~debug.js";
13
- import "./198.js";
14
- __webpack_require__.add({
15
- "./node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js" (module, __unused_rspack_exports, __webpack_require__) {
16
- const stringify = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js");
17
- const compile = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/compile.js");
18
- const expand = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/expand.js");
19
- const parse = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/parse.js");
20
- const braces = (input, options = {})=>{
21
- let output = [];
22
- if (Array.isArray(input)) for (const pattern of input){
23
- const result = braces.create(pattern, options);
24
- if (Array.isArray(result)) output.push(...result);
25
- else output.push(result);
26
- }
27
- else output = [].concat(braces.create(input, options));
28
- if (options && true === options.expand && true === options.nodupes) output = [
29
- ...new Set(output)
30
- ];
31
- return output;
32
- };
33
- braces.parse = (input, options = {})=>parse(input, options);
34
- braces.stringify = (input, options = {})=>{
35
- if ('string' == typeof input) return stringify(braces.parse(input, options), options);
36
- return stringify(input, options);
37
- };
38
- braces.compile = (input, options = {})=>{
39
- if ('string' == typeof input) input = braces.parse(input, options);
40
- return compile(input, options);
41
- };
42
- braces.expand = (input, options = {})=>{
43
- if ('string' == typeof input) input = braces.parse(input, options);
44
- let result = expand(input, options);
45
- if (true === options.noempty) result = result.filter(Boolean);
46
- if (true === options.nodupes) result = [
47
- ...new Set(result)
48
- ];
49
- return result;
50
- };
51
- braces.create = (input, options = {})=>{
52
- if ('' === input || input.length < 3) return [
53
- input
54
- ];
55
- return true !== options.expand ? braces.compile(input, options) : braces.expand(input, options);
56
- };
57
- module.exports = braces;
58
- },
59
- "./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/compile.js" (module, __unused_rspack_exports, __webpack_require__) {
60
- const fill = __webpack_require__("./node_modules/.pnpm/fill-range@7.1.1/node_modules/fill-range/index.js");
61
- const utils = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/utils.js");
62
- const compile = (ast, options = {})=>{
63
- const walk = (node, parent = {})=>{
64
- const invalidBlock = utils.isInvalidBrace(parent);
65
- const invalidNode = true === node.invalid && true === options.escapeInvalid;
66
- const invalid = true === invalidBlock || true === invalidNode;
67
- const prefix = true === options.escapeInvalid ? '\\' : '';
68
- let output = '';
69
- if (true === node.isOpen) return prefix + node.value;
70
- if (true === node.isClose) {
71
- console.log('node.isClose', prefix, node.value);
72
- return prefix + node.value;
73
- }
74
- if ('open' === node.type) return invalid ? prefix + node.value : '(';
75
- if ('close' === node.type) return invalid ? prefix + node.value : ')';
76
- if ('comma' === node.type) return 'comma' === node.prev.type ? '' : invalid ? node.value : '|';
77
- if (node.value) return node.value;
78
- if (node.nodes && node.ranges > 0) {
79
- const args = utils.reduce(node.nodes);
80
- const range = fill(...args, {
81
- ...options,
82
- wrap: false,
83
- toRegex: true,
84
- strictZeros: true
85
- });
86
- if (0 !== range.length) return args.length > 1 && range.length > 1 ? `(${range})` : range;
87
- }
88
- if (node.nodes) for (const child of node.nodes)output += walk(child, node);
89
- return output;
90
- };
91
- return walk(ast);
92
- };
93
- module.exports = compile;
94
- },
95
- "./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/constants.js" (module) {
96
- module.exports = {
97
- MAX_LENGTH: 10000,
98
- CHAR_0: '0',
99
- CHAR_9: '9',
100
- CHAR_UPPERCASE_A: 'A',
101
- CHAR_LOWERCASE_A: 'a',
102
- CHAR_UPPERCASE_Z: 'Z',
103
- CHAR_LOWERCASE_Z: 'z',
104
- CHAR_LEFT_PARENTHESES: '(',
105
- CHAR_RIGHT_PARENTHESES: ')',
106
- CHAR_ASTERISK: '*',
107
- CHAR_AMPERSAND: '&',
108
- CHAR_AT: '@',
109
- CHAR_BACKSLASH: '\\',
110
- CHAR_BACKTICK: '`',
111
- CHAR_CARRIAGE_RETURN: '\r',
112
- CHAR_CIRCUMFLEX_ACCENT: '^',
113
- CHAR_COLON: ':',
114
- CHAR_COMMA: ',',
115
- CHAR_DOLLAR: '$',
116
- CHAR_DOT: '.',
117
- CHAR_DOUBLE_QUOTE: '"',
118
- CHAR_EQUAL: '=',
119
- CHAR_EXCLAMATION_MARK: '!',
120
- CHAR_FORM_FEED: '\f',
121
- CHAR_FORWARD_SLASH: '/',
122
- CHAR_HASH: '#',
123
- CHAR_HYPHEN_MINUS: '-',
124
- CHAR_LEFT_ANGLE_BRACKET: '<',
125
- CHAR_LEFT_CURLY_BRACE: '{',
126
- CHAR_LEFT_SQUARE_BRACKET: '[',
127
- CHAR_LINE_FEED: '\n',
128
- CHAR_NO_BREAK_SPACE: '\u00A0',
129
- CHAR_PERCENT: '%',
130
- CHAR_PLUS: '+',
131
- CHAR_QUESTION_MARK: '?',
132
- CHAR_RIGHT_ANGLE_BRACKET: '>',
133
- CHAR_RIGHT_CURLY_BRACE: '}',
134
- CHAR_RIGHT_SQUARE_BRACKET: ']',
135
- CHAR_SEMICOLON: ';',
136
- CHAR_SINGLE_QUOTE: '\'',
137
- CHAR_SPACE: ' ',
138
- CHAR_TAB: '\t',
139
- CHAR_UNDERSCORE: '_',
140
- CHAR_VERTICAL_LINE: '|',
141
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF'
142
- };
143
- },
144
- "./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/expand.js" (module, __unused_rspack_exports, __webpack_require__) {
145
- const fill = __webpack_require__("./node_modules/.pnpm/fill-range@7.1.1/node_modules/fill-range/index.js");
146
- const stringify = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js");
147
- const utils = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/utils.js");
148
- const append = (queue = '', stash = '', enclose = false)=>{
149
- const result = [];
150
- queue = [].concat(queue);
151
- stash = [].concat(stash);
152
- if (!stash.length) return queue;
153
- if (!queue.length) return enclose ? utils.flatten(stash).map((ele)=>`{${ele}}`) : stash;
154
- for (const item of queue)if (Array.isArray(item)) for (const value of item)result.push(append(value, stash, enclose));
155
- else for (let ele of stash){
156
- if (true === enclose && 'string' == typeof ele) ele = `{${ele}}`;
157
- result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
158
- }
159
- return utils.flatten(result);
160
- };
161
- const expand = (ast, options = {})=>{
162
- const rangeLimit = void 0 === options.rangeLimit ? 1000 : options.rangeLimit;
163
- const walk = (node, parent = {})=>{
164
- node.queue = [];
165
- let p = parent;
166
- let q = parent.queue;
167
- while('brace' !== p.type && 'root' !== p.type && p.parent){
168
- p = p.parent;
169
- q = p.queue;
170
- }
171
- if (node.invalid || node.dollar) return void q.push(append(q.pop(), stringify(node, options)));
172
- if ('brace' === node.type && true !== node.invalid && 2 === node.nodes.length) return void q.push(append(q.pop(), [
173
- '{}'
174
- ]));
175
- if (node.nodes && node.ranges > 0) {
176
- const args = utils.reduce(node.nodes);
177
- if (utils.exceedsLimit(...args, options.step, rangeLimit)) throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
178
- let range = fill(...args, options);
179
- if (0 === range.length) range = stringify(node, options);
180
- q.push(append(q.pop(), range));
181
- node.nodes = [];
182
- return;
183
- }
184
- const enclose = utils.encloseBrace(node);
185
- let queue = node.queue;
186
- let block = node;
187
- while('brace' !== block.type && 'root' !== block.type && block.parent){
188
- block = block.parent;
189
- queue = block.queue;
190
- }
191
- for(let i = 0; i < node.nodes.length; i++){
192
- const child = node.nodes[i];
193
- if ('comma' === child.type && 'brace' === node.type) {
194
- if (1 === i) queue.push('');
195
- queue.push('');
196
- continue;
197
- }
198
- if ('close' === child.type) {
199
- q.push(append(q.pop(), queue, enclose));
200
- continue;
201
- }
202
- if (child.value && 'open' !== child.type) {
203
- queue.push(append(queue.pop(), child.value));
204
- continue;
205
- }
206
- if (child.nodes) walk(child, node);
207
- }
208
- return queue;
209
- };
210
- return utils.flatten(walk(ast));
211
- };
212
- module.exports = expand;
213
- },
214
- "./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
215
- const stringify = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js");
216
- const { MAX_LENGTH, CHAR_BACKSLASH, CHAR_BACKTICK, CHAR_COMMA, CHAR_DOT, CHAR_LEFT_PARENTHESES, CHAR_RIGHT_PARENTHESES, CHAR_LEFT_CURLY_BRACE, CHAR_RIGHT_CURLY_BRACE, CHAR_LEFT_SQUARE_BRACKET, CHAR_RIGHT_SQUARE_BRACKET, CHAR_DOUBLE_QUOTE, CHAR_SINGLE_QUOTE, CHAR_NO_BREAK_SPACE, CHAR_ZERO_WIDTH_NOBREAK_SPACE } = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/constants.js");
217
- const parse = (input, options = {})=>{
218
- if ('string' != typeof input) throw new TypeError('Expected a string');
219
- const opts = options || {};
220
- const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
221
- if (input.length > max) throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
222
- const ast = {
223
- type: 'root',
224
- input,
225
- nodes: []
226
- };
227
- const stack = [
228
- ast
229
- ];
230
- let block = ast;
231
- let prev = ast;
232
- let brackets = 0;
233
- const length = input.length;
234
- let index = 0;
235
- let depth = 0;
236
- let value;
237
- const advance = ()=>input[index++];
238
- const push = (node)=>{
239
- if ('text' === node.type && 'dot' === prev.type) prev.type = 'text';
240
- if (prev && 'text' === prev.type && 'text' === node.type) {
241
- prev.value += node.value;
242
- return;
243
- }
244
- block.nodes.push(node);
245
- node.parent = block;
246
- node.prev = prev;
247
- prev = node;
248
- return node;
249
- };
250
- push({
251
- type: 'bos'
252
- });
253
- while(index < length){
254
- block = stack[stack.length - 1];
255
- value = advance();
256
- if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) continue;
257
- if (value === CHAR_BACKSLASH) {
258
- push({
259
- type: 'text',
260
- value: (options.keepEscaping ? value : '') + advance()
261
- });
262
- continue;
263
- }
264
- if (value === CHAR_RIGHT_SQUARE_BRACKET) {
265
- push({
266
- type: 'text',
267
- value: '\\' + value
268
- });
269
- continue;
270
- }
271
- if (value === CHAR_LEFT_SQUARE_BRACKET) {
272
- brackets++;
273
- let next;
274
- while(index < length && (next = advance())){
275
- value += next;
276
- if (next === CHAR_LEFT_SQUARE_BRACKET) {
277
- brackets++;
278
- continue;
279
- }
280
- if (next === CHAR_BACKSLASH) {
281
- value += advance();
282
- continue;
283
- }
284
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
285
- brackets--;
286
- if (0 === brackets) break;
287
- }
288
- }
289
- push({
290
- type: 'text',
291
- value
292
- });
293
- continue;
294
- }
295
- if (value === CHAR_LEFT_PARENTHESES) {
296
- block = push({
297
- type: 'paren',
298
- nodes: []
299
- });
300
- stack.push(block);
301
- push({
302
- type: 'text',
303
- value
304
- });
305
- continue;
306
- }
307
- if (value === CHAR_RIGHT_PARENTHESES) {
308
- if ('paren' !== block.type) {
309
- push({
310
- type: 'text',
311
- value
312
- });
313
- continue;
314
- }
315
- block = stack.pop();
316
- push({
317
- type: 'text',
318
- value
319
- });
320
- block = stack[stack.length - 1];
321
- continue;
322
- }
323
- if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
324
- const open = value;
325
- let next;
326
- if (true !== options.keepQuotes) value = '';
327
- while(index < length && (next = advance())){
328
- if (next === CHAR_BACKSLASH) {
329
- value += next + advance();
330
- continue;
331
- }
332
- if (next === open) {
333
- if (true === options.keepQuotes) value += next;
334
- break;
335
- }
336
- value += next;
337
- }
338
- push({
339
- type: 'text',
340
- value
341
- });
342
- continue;
343
- }
344
- if (value === CHAR_LEFT_CURLY_BRACE) {
345
- depth++;
346
- const dollar = prev.value && '$' === prev.value.slice(-1) || true === block.dollar;
347
- const brace = {
348
- type: 'brace',
349
- open: true,
350
- close: false,
351
- dollar,
352
- depth,
353
- commas: 0,
354
- ranges: 0,
355
- nodes: []
356
- };
357
- block = push(brace);
358
- stack.push(block);
359
- push({
360
- type: 'open',
361
- value
362
- });
363
- continue;
364
- }
365
- if (value === CHAR_RIGHT_CURLY_BRACE) {
366
- if ('brace' !== block.type) {
367
- push({
368
- type: 'text',
369
- value
370
- });
371
- continue;
372
- }
373
- const type = 'close';
374
- block = stack.pop();
375
- block.close = true;
376
- push({
377
- type,
378
- value
379
- });
380
- depth--;
381
- block = stack[stack.length - 1];
382
- continue;
383
- }
384
- if (value === CHAR_COMMA && depth > 0) {
385
- if (block.ranges > 0) {
386
- block.ranges = 0;
387
- const open = block.nodes.shift();
388
- block.nodes = [
389
- open,
390
- {
391
- type: 'text',
392
- value: stringify(block)
393
- }
394
- ];
395
- }
396
- push({
397
- type: 'comma',
398
- value
399
- });
400
- block.commas++;
401
- continue;
402
- }
403
- if (value === CHAR_DOT && depth > 0 && 0 === block.commas) {
404
- const siblings = block.nodes;
405
- if (0 === depth || 0 === siblings.length) {
406
- push({
407
- type: 'text',
408
- value
409
- });
410
- continue;
411
- }
412
- if ('dot' === prev.type) {
413
- block.range = [];
414
- prev.value += value;
415
- prev.type = 'range';
416
- if (3 !== block.nodes.length && 5 !== block.nodes.length) {
417
- block.invalid = true;
418
- block.ranges = 0;
419
- prev.type = 'text';
420
- continue;
421
- }
422
- block.ranges++;
423
- block.args = [];
424
- continue;
425
- }
426
- if ('range' === prev.type) {
427
- siblings.pop();
428
- const before = siblings[siblings.length - 1];
429
- before.value += prev.value + value;
430
- prev = before;
431
- block.ranges--;
432
- continue;
433
- }
434
- push({
435
- type: 'dot',
436
- value
437
- });
438
- continue;
439
- }
440
- push({
441
- type: 'text',
442
- value
443
- });
444
- }
445
- do {
446
- block = stack.pop();
447
- if ('root' !== block.type) {
448
- block.nodes.forEach((node)=>{
449
- if (!node.nodes) {
450
- if ('open' === node.type) node.isOpen = true;
451
- if ('close' === node.type) node.isClose = true;
452
- if (!node.nodes) node.type = 'text';
453
- node.invalid = true;
454
- }
455
- });
456
- const parent = stack[stack.length - 1];
457
- const index = parent.nodes.indexOf(block);
458
- parent.nodes.splice(index, 1, ...block.nodes);
459
- }
460
- }while (stack.length > 0);
461
- push({
462
- type: 'eos'
463
- });
464
- return ast;
465
- };
466
- module.exports = parse;
467
- },
468
- "./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js" (module, __unused_rspack_exports, __webpack_require__) {
469
- const utils = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/utils.js");
470
- module.exports = (ast, options = {})=>{
471
- const stringify = (node, parent = {})=>{
472
- const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
473
- const invalidNode = true === node.invalid && true === options.escapeInvalid;
474
- let output = '';
475
- if (node.value) {
476
- if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) return '\\' + node.value;
477
- return node.value;
478
- }
479
- if (node.value) return node.value;
480
- if (node.nodes) for (const child of node.nodes)output += stringify(child);
481
- return output;
482
- };
483
- return stringify(ast);
484
- };
485
- },
486
- "./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/utils.js" (__unused_rspack_module, exports) {
487
- exports.isInteger = (num)=>{
488
- if ('number' == typeof num) return Number.isInteger(num);
489
- if ('string' == typeof num && '' !== num.trim()) return Number.isInteger(Number(num));
490
- return false;
491
- };
492
- exports.find = (node, type)=>node.nodes.find((node)=>node.type === type);
493
- exports.exceedsLimit = (min, max, step = 1, limit)=>{
494
- if (false === limit) return false;
495
- if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
496
- return (Number(max) - Number(min)) / Number(step) >= limit;
497
- };
498
- exports.escapeNode = (block, n = 0, type)=>{
499
- const node = block.nodes[n];
500
- if (!node) return;
501
- if (type && node.type === type || 'open' === node.type || 'close' === node.type) {
502
- if (true !== node.escaped) {
503
- node.value = '\\' + node.value;
504
- node.escaped = true;
505
- }
506
- }
507
- };
508
- exports.encloseBrace = (node)=>{
509
- if ('brace' !== node.type) return false;
510
- if (node.commas >> 0 + node.ranges === 0) {
511
- node.invalid = true;
512
- return true;
513
- }
514
- return false;
515
- };
516
- exports.isInvalidBrace = (block)=>{
517
- if ('brace' !== block.type) return false;
518
- if (true === block.invalid || block.dollar) return true;
519
- if (block.commas >> 0 + block.ranges === 0) {
520
- block.invalid = true;
521
- return true;
522
- }
523
- if (true !== block.open || true !== block.close) {
524
- block.invalid = true;
525
- return true;
526
- }
527
- return false;
528
- };
529
- exports.isOpenOrClose = (node)=>{
530
- if ('open' === node.type || 'close' === node.type) return true;
531
- return true === node.open || true === node.close;
532
- };
533
- exports.reduce = (nodes)=>nodes.reduce((acc, node)=>{
534
- if ('text' === node.type) acc.push(node.value);
535
- if ('range' === node.type) node.type = 'text';
536
- return acc;
537
- }, []);
538
- exports.flatten = (...args)=>{
539
- const result = [];
540
- const flat = (arr)=>{
541
- for(let i = 0; i < arr.length; i++){
542
- const ele = arr[i];
543
- if (Array.isArray(ele)) {
544
- flat(ele);
545
- continue;
546
- }
547
- if (void 0 !== ele) result.push(ele);
548
- }
549
- return result;
550
- };
551
- flat(args);
552
- return result;
553
- };
554
- },
555
- "./node_modules/.pnpm/fill-range@7.1.1/node_modules/fill-range/index.js" (module, __unused_rspack_exports, __webpack_require__) {
556
- /*!
557
- * fill-range <https://github.com/jonschlinkert/fill-range>
558
- *
559
- * Copyright (c) 2014-present, Jon Schlinkert.
560
- * Licensed under the MIT License.
561
- */ const util = __webpack_require__("util");
562
- const toRegexRange = __webpack_require__("./node_modules/.pnpm/to-regex-range@5.0.1/node_modules/to-regex-range/index.js");
563
- const isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
564
- const transform = (toNumber)=>(value)=>true === toNumber ? Number(value) : String(value);
565
- const isValidValue = (value)=>'number' == typeof value || 'string' == typeof value && '' !== value;
566
- const isNumber = (num)=>Number.isInteger(+num);
567
- const zeros = (input)=>{
568
- let value = `${input}`;
569
- let index = -1;
570
- if ('-' === value[0]) value = value.slice(1);
571
- if ('0' === value) return false;
572
- while('0' === value[++index]);
573
- return index > 0;
574
- };
575
- const stringify = (start, end, options)=>{
576
- if ('string' == typeof start || 'string' == typeof end) return true;
577
- return true === options.stringify;
578
- };
579
- const pad = (input, maxLength, toNumber)=>{
580
- if (maxLength > 0) {
581
- let dash = '-' === input[0] ? '-' : '';
582
- if (dash) input = input.slice(1);
583
- input = dash + input.padStart(dash ? maxLength - 1 : maxLength, '0');
584
- }
585
- if (false === toNumber) return String(input);
586
- return input;
587
- };
588
- const toMaxLen = (input, maxLength)=>{
589
- let negative = '-' === input[0] ? '-' : '';
590
- if (negative) {
591
- input = input.slice(1);
592
- maxLength--;
593
- }
594
- while(input.length < maxLength)input = '0' + input;
595
- return negative ? '-' + input : input;
596
- };
597
- const toSequence = (parts, options, maxLen)=>{
598
- parts.negatives.sort((a, b)=>a < b ? -1 : a > b ? 1 : 0);
599
- parts.positives.sort((a, b)=>a < b ? -1 : a > b ? 1 : 0);
600
- let prefix = options.capture ? '' : '?:';
601
- let positives = '';
602
- let negatives = '';
603
- let result;
604
- if (parts.positives.length) positives = parts.positives.map((v)=>toMaxLen(String(v), maxLen)).join('|');
605
- if (parts.negatives.length) negatives = `-(${prefix}${parts.negatives.map((v)=>toMaxLen(String(v), maxLen)).join('|')})`;
606
- result = positives && negatives ? `${positives}|${negatives}` : positives || negatives;
607
- if (options.wrap) return `(${prefix}${result})`;
608
- return result;
609
- };
610
- const toRange = (a, b, isNumbers, options)=>{
611
- if (isNumbers) return toRegexRange(a, b, {
612
- wrap: false,
613
- ...options
614
- });
615
- let start = String.fromCharCode(a);
616
- if (a === b) return start;
617
- let stop = String.fromCharCode(b);
618
- return `[${start}-${stop}]`;
619
- };
620
- const toRegex = (start, end, options)=>{
621
- if (Array.isArray(start)) {
622
- let wrap = true === options.wrap;
623
- let prefix = options.capture ? '' : '?:';
624
- return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
625
- }
626
- return toRegexRange(start, end, options);
627
- };
628
- const rangeError = (...args)=>new RangeError('Invalid range arguments: ' + util.inspect(...args));
629
- const invalidRange = (start, end, options)=>{
630
- if (true === options.strictRanges) throw rangeError([
631
- start,
632
- end
633
- ]);
634
- return [];
635
- };
636
- const invalidStep = (step, options)=>{
637
- if (true === options.strictRanges) throw new TypeError(`Expected step "${step}" to be a number`);
638
- return [];
639
- };
640
- const fillNumbers = (start, end, step = 1, options = {})=>{
641
- let a = Number(start);
642
- let b = Number(end);
643
- if (!Number.isInteger(a) || !Number.isInteger(b)) {
644
- if (true === options.strictRanges) throw rangeError([
645
- start,
646
- end
647
- ]);
648
- return [];
649
- }
650
- if (0 === a) a = 0;
651
- if (0 === b) b = 0;
652
- let descending = a > b;
653
- let startString = String(start);
654
- let endString = String(end);
655
- let stepString = String(step);
656
- step = Math.max(Math.abs(step), 1);
657
- let padded = zeros(startString) || zeros(endString) || zeros(stepString);
658
- let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
659
- let toNumber = false === padded && false === stringify(start, end, options);
660
- let format = options.transform || transform(toNumber);
661
- if (options.toRegex && 1 === step) return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
662
- let parts = {
663
- negatives: [],
664
- positives: []
665
- };
666
- let push = (num)=>parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
667
- let range = [];
668
- let index = 0;
669
- while(descending ? a >= b : a <= b){
670
- if (true === options.toRegex && step > 1) push(a);
671
- else range.push(pad(format(a, index), maxLen, toNumber));
672
- a = descending ? a - step : a + step;
673
- index++;
674
- }
675
- if (true === options.toRegex) return step > 1 ? toSequence(parts, options, maxLen) : toRegex(range, null, {
676
- wrap: false,
677
- ...options
678
- });
679
- return range;
680
- };
681
- const fillLetters = (start, end, step = 1, options = {})=>{
682
- if (!isNumber(start) && start.length > 1 || !isNumber(end) && end.length > 1) return invalidRange(start, end, options);
683
- let format = options.transform || ((val)=>String.fromCharCode(val));
684
- let a = `${start}`.charCodeAt(0);
685
- let b = `${end}`.charCodeAt(0);
686
- let descending = a > b;
687
- let min = Math.min(a, b);
688
- let max = Math.max(a, b);
689
- if (options.toRegex && 1 === step) return toRange(min, max, false, options);
690
- let range = [];
691
- let index = 0;
692
- while(descending ? a >= b : a <= b){
693
- range.push(format(a, index));
694
- a = descending ? a - step : a + step;
695
- index++;
696
- }
697
- if (true === options.toRegex) return toRegex(range, null, {
698
- wrap: false,
699
- options
700
- });
701
- return range;
702
- };
703
- const fill = (start, end, step, options = {})=>{
704
- if (null == end && isValidValue(start)) return [
705
- start
706
- ];
707
- if (!isValidValue(start) || !isValidValue(end)) return invalidRange(start, end, options);
708
- if ('function' == typeof step) return fill(start, end, 1, {
709
- transform: step
710
- });
711
- if (isObject(step)) return fill(start, end, 0, step);
712
- let opts = {
713
- ...options
714
- };
715
- if (true === opts.capture) opts.wrap = true;
716
- step = step || opts.step || 1;
717
- if (!isNumber(step)) {
718
- if (null != step && !isObject(step)) return invalidStep(step, opts);
719
- return fill(start, end, 1, step);
720
- }
721
- if (isNumber(start) && isNumber(end)) return fillNumbers(start, end, step, opts);
722
- return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
723
- };
724
- module.exports = fill;
725
- },
726
- "./node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js" (module) {
727
- /*!
728
- * is-extglob <https://github.com/jonschlinkert/is-extglob>
729
- *
730
- * Copyright (c) 2014-2016, Jon Schlinkert.
731
- * Licensed under the MIT License.
732
- */ module.exports = function(str) {
733
- if ('string' != typeof str || '' === str) return false;
734
- var match;
735
- while(match = /(\\).|([@?!+*]\(.*\))/g.exec(str)){
736
- if (match[2]) return true;
737
- str = str.slice(match.index + match[0].length);
738
- }
739
- return false;
740
- };
741
- },
742
- "./node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js" (module, __unused_rspack_exports, __webpack_require__) {
743
- /*!
744
- * is-glob <https://github.com/jonschlinkert/is-glob>
745
- *
746
- * Copyright (c) 2014-2017, Jon Schlinkert.
747
- * Released under the MIT License.
748
- */ var isExtglob = __webpack_require__("./node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js");
749
- var chars = {
750
- '{': '}',
751
- '(': ')',
752
- '[': ']'
753
- };
754
- var strictCheck = function(str) {
755
- if ('!' === str[0]) return true;
756
- var index = 0;
757
- var pipeIndex = -2;
758
- var closeSquareIndex = -2;
759
- var closeCurlyIndex = -2;
760
- var closeParenIndex = -2;
761
- var backSlashIndex = -2;
762
- while(index < str.length){
763
- if ('*' === str[index]) return true;
764
- if ('?' === str[index + 1] && /[\].+)]/.test(str[index])) return true;
765
- if (-1 !== closeSquareIndex && '[' === str[index] && ']' !== str[index + 1]) {
766
- if (closeSquareIndex < index) closeSquareIndex = str.indexOf(']', index);
767
- if (closeSquareIndex > index) {
768
- if (-1 === backSlashIndex || backSlashIndex > closeSquareIndex) return true;
769
- backSlashIndex = str.indexOf('\\', index);
770
- if (-1 === backSlashIndex || backSlashIndex > closeSquareIndex) return true;
771
- }
772
- }
773
- if (-1 !== closeCurlyIndex && '{' === str[index] && '}' !== str[index + 1]) {
774
- closeCurlyIndex = str.indexOf('}', index);
775
- if (closeCurlyIndex > index) {
776
- backSlashIndex = str.indexOf('\\', index);
777
- if (-1 === backSlashIndex || backSlashIndex > closeCurlyIndex) return true;
778
- }
779
- }
780
- if (-1 !== closeParenIndex && '(' === str[index] && '?' === str[index + 1] && /[:!=]/.test(str[index + 2]) && ')' !== str[index + 3]) {
781
- closeParenIndex = str.indexOf(')', index);
782
- if (closeParenIndex > index) {
783
- backSlashIndex = str.indexOf('\\', index);
784
- if (-1 === backSlashIndex || backSlashIndex > closeParenIndex) return true;
785
- }
786
- }
787
- if (-1 !== pipeIndex && '(' === str[index] && '|' !== str[index + 1]) {
788
- if (pipeIndex < index) pipeIndex = str.indexOf('|', index);
789
- if (-1 !== pipeIndex && ')' !== str[pipeIndex + 1]) {
790
- closeParenIndex = str.indexOf(')', pipeIndex);
791
- if (closeParenIndex > pipeIndex) {
792
- backSlashIndex = str.indexOf('\\', pipeIndex);
793
- if (-1 === backSlashIndex || backSlashIndex > closeParenIndex) return true;
794
- }
795
- }
796
- }
797
- if ('\\' === str[index]) {
798
- var open = str[index + 1];
799
- index += 2;
800
- var close = chars[open];
801
- if (close) {
802
- var n = str.indexOf(close, index);
803
- if (-1 !== n) index = n + 1;
804
- }
805
- if ('!' === str[index]) return true;
806
- } else index++;
807
- }
808
- return false;
809
- };
810
- var relaxedCheck = function(str) {
811
- if ('!' === str[0]) return true;
812
- var index = 0;
813
- while(index < str.length){
814
- if (/[*?{}()[\]]/.test(str[index])) return true;
815
- if ('\\' === str[index]) {
816
- var open = str[index + 1];
817
- index += 2;
818
- var close = chars[open];
819
- if (close) {
820
- var n = str.indexOf(close, index);
821
- if (-1 !== n) index = n + 1;
822
- }
823
- if ('!' === str[index]) return true;
824
- } else index++;
825
- }
826
- return false;
827
- };
828
- module.exports = function(str, options) {
829
- if ('string' != typeof str || '' === str) return false;
830
- if (isExtglob(str)) return true;
831
- var check = strictCheck;
832
- if (options && false === options.strict) check = relaxedCheck;
833
- return check(str);
834
- };
835
- },
836
- "./node_modules/.pnpm/is-number@7.0.0/node_modules/is-number/index.js" (module) {
837
- /*!
838
- * is-number <https://github.com/jonschlinkert/is-number>
839
- *
840
- * Copyright (c) 2014-present, Jon Schlinkert.
841
- * Released under the MIT License.
842
- */ module.exports = function(num) {
843
- if ('number' == typeof num) return num - num === 0;
844
- if ('string' == typeof num && '' !== num.trim()) return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
845
- return false;
846
- };
847
- },
848
- "./node_modules/.pnpm/micromatch@4.0.8/node_modules/micromatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
849
- const util = __webpack_require__("util");
850
- const braces = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js");
851
- const picomatch = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/index.js");
852
- const utils = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
853
- const isEmptyString = (v)=>'' === v || './' === v;
854
- const hasBraces = (v)=>{
855
- const index = v.indexOf('{');
856
- return index > -1 && v.indexOf('}', index) > -1;
857
- };
858
- const micromatch = (list, patterns, options)=>{
859
- patterns = [].concat(patterns);
860
- list = [].concat(list);
861
- let omit = new Set();
862
- let keep = new Set();
863
- let items = new Set();
864
- let negatives = 0;
865
- let onResult = (state)=>{
866
- items.add(state.output);
867
- if (options && options.onResult) options.onResult(state);
868
- };
869
- for(let i = 0; i < patterns.length; i++){
870
- let isMatch = picomatch(String(patterns[i]), {
871
- ...options,
872
- onResult
873
- }, true);
874
- let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
875
- if (negated) negatives++;
876
- for (let item of list){
877
- let matched = isMatch(item, true);
878
- let match = negated ? !matched.isMatch : matched.isMatch;
879
- if (match) if (negated) omit.add(matched.output);
880
- else {
881
- omit.delete(matched.output);
882
- keep.add(matched.output);
883
- }
884
- }
885
- }
886
- let result = negatives === patterns.length ? [
887
- ...items
888
- ] : [
889
- ...keep
890
- ];
891
- let matches = result.filter((item)=>!omit.has(item));
892
- if (options && 0 === matches.length) {
893
- if (true === options.failglob) throw new Error(`No matches found for "${patterns.join(', ')}"`);
894
- if (true === options.nonull || true === options.nullglob) return options.unescape ? patterns.map((p)=>p.replace(/\\/g, '')) : patterns;
895
- }
896
- return matches;
897
- };
898
- micromatch.match = micromatch;
899
- micromatch.matcher = (pattern, options)=>picomatch(pattern, options);
900
- micromatch.isMatch = (str, patterns, options)=>picomatch(patterns, options)(str);
901
- micromatch.any = micromatch.isMatch;
902
- micromatch.not = (list, patterns, options = {})=>{
903
- patterns = [].concat(patterns).map(String);
904
- let result = new Set();
905
- let items = [];
906
- let onResult = (state)=>{
907
- if (options.onResult) options.onResult(state);
908
- items.push(state.output);
909
- };
910
- let matches = new Set(micromatch(list, patterns, {
911
- ...options,
912
- onResult
913
- }));
914
- for (let item of items)if (!matches.has(item)) result.add(item);
915
- return [
916
- ...result
917
- ];
918
- };
919
- micromatch.contains = (str, pattern, options)=>{
920
- if ('string' != typeof str) throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
921
- if (Array.isArray(pattern)) return pattern.some((p)=>micromatch.contains(str, p, options));
922
- if ('string' == typeof pattern) {
923
- if (isEmptyString(str) || isEmptyString(pattern)) return false;
924
- if (str.includes(pattern) || str.startsWith('./') && str.slice(2).includes(pattern)) return true;
925
- }
926
- return micromatch.isMatch(str, pattern, {
927
- ...options,
928
- contains: true
929
- });
930
- };
931
- micromatch.matchKeys = (obj, patterns, options)=>{
932
- if (!utils.isObject(obj)) throw new TypeError('Expected the first argument to be an object');
933
- let keys = micromatch(Object.keys(obj), patterns, options);
934
- let res = {};
935
- for (let key of keys)res[key] = obj[key];
936
- return res;
937
- };
938
- micromatch.some = (list, patterns, options)=>{
939
- let items = [].concat(list);
940
- for (let pattern of [].concat(patterns)){
941
- let isMatch = picomatch(String(pattern), options);
942
- if (items.some((item)=>isMatch(item))) return true;
943
- }
944
- return false;
945
- };
946
- micromatch.every = (list, patterns, options)=>{
947
- let items = [].concat(list);
948
- for (let pattern of [].concat(patterns)){
949
- let isMatch = picomatch(String(pattern), options);
950
- if (!items.every((item)=>isMatch(item))) return false;
951
- }
952
- return true;
953
- };
954
- micromatch.all = (str, patterns, options)=>{
955
- if ('string' != typeof str) throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
956
- return [].concat(patterns).every((p)=>picomatch(p, options)(str));
957
- };
958
- micromatch.capture = (glob, input, options)=>{
959
- let posix = utils.isWindows(options);
960
- let regex = picomatch.makeRe(String(glob), {
961
- ...options,
962
- capture: true
963
- });
964
- let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
965
- if (match) return match.slice(1).map((v)=>void 0 === v ? '' : v);
966
- };
967
- micromatch.makeRe = (...args)=>picomatch.makeRe(...args);
968
- micromatch.scan = (...args)=>picomatch.scan(...args);
969
- micromatch.parse = (patterns, options)=>{
970
- let res = [];
971
- for (let pattern of [].concat(patterns || []))for (let str of braces(String(pattern), options))res.push(picomatch.parse(str, options));
972
- return res;
973
- };
974
- micromatch.braces = (pattern, options)=>{
975
- if ('string' != typeof pattern) throw new TypeError('Expected a string');
976
- if (options && true === options.nobrace || !hasBraces(pattern)) return [
977
- pattern
978
- ];
979
- return braces(pattern, options);
980
- };
981
- micromatch.braceExpand = (pattern, options)=>{
982
- if ('string' != typeof pattern) throw new TypeError('Expected a string');
983
- return micromatch.braces(pattern, {
984
- ...options,
985
- expand: true
986
- });
987
- };
988
- micromatch.hasBraces = hasBraces;
989
- module.exports = micromatch;
990
- },
991
- "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
992
- module.exports = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js");
993
- },
994
- "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js" (module, __unused_rspack_exports, __webpack_require__) {
995
- const path = __webpack_require__("path");
996
- const WIN_SLASH = '\\\\/';
997
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
998
- const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
999
- const DOT_LITERAL = '\\.';
1000
- const PLUS_LITERAL = '\\+';
1001
- const QMARK_LITERAL = '\\?';
1002
- const SLASH_LITERAL = '\\/';
1003
- const ONE_CHAR = '(?=.)';
1004
- const QMARK = '[^/]';
1005
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
1006
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
1007
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
1008
- const NO_DOT = `(?!${DOT_LITERAL})`;
1009
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
1010
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
1011
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
1012
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
1013
- const STAR = `${QMARK}*?`;
1014
- const POSIX_CHARS = {
1015
- DOT_LITERAL,
1016
- PLUS_LITERAL,
1017
- QMARK_LITERAL,
1018
- SLASH_LITERAL,
1019
- ONE_CHAR,
1020
- QMARK,
1021
- END_ANCHOR,
1022
- DOTS_SLASH,
1023
- NO_DOT,
1024
- NO_DOTS,
1025
- NO_DOT_SLASH,
1026
- NO_DOTS_SLASH,
1027
- QMARK_NO_DOT,
1028
- STAR,
1029
- START_ANCHOR
1030
- };
1031
- const WINDOWS_CHARS = {
1032
- ...POSIX_CHARS,
1033
- SLASH_LITERAL: `[${WIN_SLASH}]`,
1034
- QMARK: WIN_NO_SLASH,
1035
- STAR: `${WIN_NO_SLASH}*?`,
1036
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
1037
- NO_DOT: `(?!${DOT_LITERAL})`,
1038
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1039
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
1040
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1041
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
1042
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
1043
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
1044
- };
1045
- const POSIX_REGEX_SOURCE = {
1046
- __proto__: null,
1047
- alnum: 'a-zA-Z0-9',
1048
- alpha: 'a-zA-Z',
1049
- ascii: '\\x00-\\x7F',
1050
- blank: ' \\t',
1051
- cntrl: '\\x00-\\x1F\\x7F',
1052
- digit: '0-9',
1053
- graph: '\\x21-\\x7E',
1054
- lower: 'a-z',
1055
- print: '\\x20-\\x7E ',
1056
- punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
1057
- space: ' \\t\\r\\n\\v\\f',
1058
- upper: 'A-Z',
1059
- word: 'A-Za-z0-9_',
1060
- xdigit: 'A-Fa-f0-9'
1061
- };
1062
- module.exports = {
1063
- DEFAULT_MAX_EXTGLOB_RECURSION,
1064
- MAX_LENGTH: 65536,
1065
- POSIX_REGEX_SOURCE,
1066
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
1067
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
1068
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
1069
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
1070
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
1071
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
1072
- REPLACEMENTS: {
1073
- __proto__: null,
1074
- '***': '*',
1075
- '**/**': '**',
1076
- '**/**/**': '**'
1077
- },
1078
- CHAR_0: 48,
1079
- CHAR_9: 57,
1080
- CHAR_UPPERCASE_A: 65,
1081
- CHAR_LOWERCASE_A: 97,
1082
- CHAR_UPPERCASE_Z: 90,
1083
- CHAR_LOWERCASE_Z: 122,
1084
- CHAR_LEFT_PARENTHESES: 40,
1085
- CHAR_RIGHT_PARENTHESES: 41,
1086
- CHAR_ASTERISK: 42,
1087
- CHAR_AMPERSAND: 38,
1088
- CHAR_AT: 64,
1089
- CHAR_BACKWARD_SLASH: 92,
1090
- CHAR_CARRIAGE_RETURN: 13,
1091
- CHAR_CIRCUMFLEX_ACCENT: 94,
1092
- CHAR_COLON: 58,
1093
- CHAR_COMMA: 44,
1094
- CHAR_DOT: 46,
1095
- CHAR_DOUBLE_QUOTE: 34,
1096
- CHAR_EQUAL: 61,
1097
- CHAR_EXCLAMATION_MARK: 33,
1098
- CHAR_FORM_FEED: 12,
1099
- CHAR_FORWARD_SLASH: 47,
1100
- CHAR_GRAVE_ACCENT: 96,
1101
- CHAR_HASH: 35,
1102
- CHAR_HYPHEN_MINUS: 45,
1103
- CHAR_LEFT_ANGLE_BRACKET: 60,
1104
- CHAR_LEFT_CURLY_BRACE: 123,
1105
- CHAR_LEFT_SQUARE_BRACKET: 91,
1106
- CHAR_LINE_FEED: 10,
1107
- CHAR_NO_BREAK_SPACE: 160,
1108
- CHAR_PERCENT: 37,
1109
- CHAR_PLUS: 43,
1110
- CHAR_QUESTION_MARK: 63,
1111
- CHAR_RIGHT_ANGLE_BRACKET: 62,
1112
- CHAR_RIGHT_CURLY_BRACE: 125,
1113
- CHAR_RIGHT_SQUARE_BRACKET: 93,
1114
- CHAR_SEMICOLON: 59,
1115
- CHAR_SINGLE_QUOTE: 39,
1116
- CHAR_SPACE: 32,
1117
- CHAR_TAB: 9,
1118
- CHAR_UNDERSCORE: 95,
1119
- CHAR_VERTICAL_LINE: 124,
1120
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
1121
- SEP: path.sep,
1122
- extglobChars (chars) {
1123
- return {
1124
- '!': {
1125
- type: 'negate',
1126
- open: '(?:(?!(?:',
1127
- close: `))${chars.STAR})`
1128
- },
1129
- '?': {
1130
- type: 'qmark',
1131
- open: '(?:',
1132
- close: ')?'
1133
- },
1134
- '+': {
1135
- type: 'plus',
1136
- open: '(?:',
1137
- close: ')+'
1138
- },
1139
- '*': {
1140
- type: 'star',
1141
- open: '(?:',
1142
- close: ')*'
1143
- },
1144
- '@': {
1145
- type: 'at',
1146
- open: '(?:',
1147
- close: ')'
1148
- }
1149
- };
1150
- },
1151
- globChars (win32) {
1152
- return true === win32 ? WINDOWS_CHARS : POSIX_CHARS;
1153
- }
1154
- };
1155
- },
1156
- "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
1157
- const constants = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js");
1158
- const utils = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
1159
- const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
1160
- const expandRange = (args, options)=>{
1161
- if ('function' == typeof options.expandRange) return options.expandRange(...args, options);
1162
- args.sort();
1163
- const value = `[${args.join('-')}]`;
1164
- try {
1165
- new RegExp(value);
1166
- } catch (ex) {
1167
- return args.map((v)=>utils.escapeRegex(v)).join('..');
1168
- }
1169
- return value;
1170
- };
1171
- const syntaxError = (type, char)=>`Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
1172
- const splitTopLevel = (input)=>{
1173
- const parts = [];
1174
- let bracket = 0;
1175
- let paren = 0;
1176
- let quote = 0;
1177
- let value = '';
1178
- let escaped = false;
1179
- for (const ch of input){
1180
- if (true === escaped) {
1181
- value += ch;
1182
- escaped = false;
1183
- continue;
1184
- }
1185
- if ('\\' === ch) {
1186
- value += ch;
1187
- escaped = true;
1188
- continue;
1189
- }
1190
- if ('"' === ch) {
1191
- quote = 1 === quote ? 0 : 1;
1192
- value += ch;
1193
- continue;
1194
- }
1195
- if (0 === quote) {
1196
- if ('[' === ch) bracket++;
1197
- else if (']' === ch && bracket > 0) bracket--;
1198
- else if (0 === bracket) {
1199
- if ('(' === ch) paren++;
1200
- else if (')' === ch && paren > 0) paren--;
1201
- else if ('|' === ch && 0 === paren) {
1202
- parts.push(value);
1203
- value = '';
1204
- continue;
1205
- }
1206
- }
1207
- }
1208
- value += ch;
1209
- }
1210
- parts.push(value);
1211
- return parts;
1212
- };
1213
- const isPlainBranch = (branch)=>{
1214
- let escaped = false;
1215
- for (const ch of branch){
1216
- if (true === escaped) {
1217
- escaped = false;
1218
- continue;
1219
- }
1220
- if ('\\' === ch) {
1221
- escaped = true;
1222
- continue;
1223
- }
1224
- if (/[?*+@!()[\]{}]/.test(ch)) return false;
1225
- }
1226
- return true;
1227
- };
1228
- const normalizeSimpleBranch = (branch)=>{
1229
- let value = branch.trim();
1230
- let changed = true;
1231
- while(true === changed){
1232
- changed = false;
1233
- if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
1234
- value = value.slice(2, -1);
1235
- changed = true;
1236
- }
1237
- }
1238
- if (!isPlainBranch(value)) return;
1239
- return value.replace(/\\(.)/g, '$1');
1240
- };
1241
- const hasRepeatedCharPrefixOverlap = (branches)=>{
1242
- const values = branches.map(normalizeSimpleBranch).filter(Boolean);
1243
- for(let i = 0; i < values.length; i++)for(let j = i + 1; j < values.length; j++){
1244
- const a = values[i];
1245
- const b = values[j];
1246
- const char = a[0];
1247
- if (char && a === char.repeat(a.length) && b === char.repeat(b.length)) {
1248
- if (a === b || a.startsWith(b) || b.startsWith(a)) return true;
1249
- }
1250
- }
1251
- return false;
1252
- };
1253
- const parseRepeatedExtglob = (pattern, requireEnd = true)=>{
1254
- if ('+' !== pattern[0] && '*' !== pattern[0] || '(' !== pattern[1]) return;
1255
- let bracket = 0;
1256
- let paren = 0;
1257
- let quote = 0;
1258
- let escaped = false;
1259
- for(let i = 1; i < pattern.length; i++){
1260
- const ch = pattern[i];
1261
- if (true === escaped) {
1262
- escaped = false;
1263
- continue;
1264
- }
1265
- if ('\\' === ch) {
1266
- escaped = true;
1267
- continue;
1268
- }
1269
- if ('"' === ch) {
1270
- quote = 1 === quote ? 0 : 1;
1271
- continue;
1272
- }
1273
- if (1 !== quote) {
1274
- if ('[' === ch) {
1275
- bracket++;
1276
- continue;
1277
- }
1278
- if (']' === ch && bracket > 0) {
1279
- bracket--;
1280
- continue;
1281
- }
1282
- if (!(bracket > 0)) {
1283
- if ('(' === ch) {
1284
- paren++;
1285
- continue;
1286
- }
1287
- if (')' === ch) {
1288
- paren--;
1289
- if (0 === paren) {
1290
- if (true === requireEnd && i !== pattern.length - 1) return;
1291
- return {
1292
- type: pattern[0],
1293
- body: pattern.slice(2, i),
1294
- end: i
1295
- };
1296
- }
1297
- }
1298
- }
1299
- }
1300
- }
1301
- };
1302
- const getStarExtglobSequenceOutput = (pattern)=>{
1303
- let index = 0;
1304
- const chars = [];
1305
- while(index < pattern.length){
1306
- const match = parseRepeatedExtglob(pattern.slice(index), false);
1307
- if (!match || '*' !== match.type) return;
1308
- const branches = splitTopLevel(match.body).map((branch)=>branch.trim());
1309
- if (1 !== branches.length) return;
1310
- const branch = normalizeSimpleBranch(branches[0]);
1311
- if (!branch || 1 !== branch.length) return;
1312
- chars.push(branch);
1313
- index += match.end + 1;
1314
- }
1315
- if (chars.length < 1) return;
1316
- const source = 1 === chars.length ? utils.escapeRegex(chars[0]) : `[${chars.map((ch)=>utils.escapeRegex(ch)).join('')}]`;
1317
- return `${source}*`;
1318
- };
1319
- const repeatedExtglobRecursion = (pattern)=>{
1320
- let depth = 0;
1321
- let value = pattern.trim();
1322
- let match = parseRepeatedExtglob(value);
1323
- while(match){
1324
- depth++;
1325
- value = match.body.trim();
1326
- match = parseRepeatedExtglob(value);
1327
- }
1328
- return depth;
1329
- };
1330
- const analyzeRepeatedExtglob = (body, options)=>{
1331
- if (false === options.maxExtglobRecursion) return {
1332
- risky: false
1333
- };
1334
- const max = 'number' == typeof options.maxExtglobRecursion ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
1335
- const branches = splitTopLevel(body).map((branch)=>branch.trim());
1336
- if (branches.length > 1) {
1337
- if (branches.some((branch)=>'' === branch) || branches.some((branch)=>/^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) return {
1338
- risky: true
1339
- };
1340
- }
1341
- for (const branch of branches){
1342
- const safeOutput = getStarExtglobSequenceOutput(branch);
1343
- if (safeOutput) return {
1344
- risky: true,
1345
- safeOutput
1346
- };
1347
- if (repeatedExtglobRecursion(branch) > max) return {
1348
- risky: true
1349
- };
1350
- }
1351
- return {
1352
- risky: false
1353
- };
1354
- };
1355
- const parse = (input, options)=>{
1356
- if ('string' != typeof input) throw new TypeError('Expected a string');
1357
- input = REPLACEMENTS[input] || input;
1358
- const opts = {
1359
- ...options
1360
- };
1361
- const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1362
- let len = input.length;
1363
- if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1364
- const bos = {
1365
- type: 'bos',
1366
- value: '',
1367
- output: opts.prepend || ''
1368
- };
1369
- const tokens = [
1370
- bos
1371
- ];
1372
- const capture = opts.capture ? '' : '?:';
1373
- const win32 = utils.isWindows(options);
1374
- const PLATFORM_CHARS = constants.globChars(win32);
1375
- const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
1376
- const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
1377
- const globstar = (opts)=>`(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1378
- const nodot = opts.dot ? '' : NO_DOT;
1379
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
1380
- let star = true === opts.bash ? globstar(opts) : STAR;
1381
- if (opts.capture) star = `(${star})`;
1382
- if ('boolean' == typeof opts.noext) opts.noextglob = opts.noext;
1383
- const state = {
1384
- input,
1385
- index: -1,
1386
- start: 0,
1387
- dot: true === opts.dot,
1388
- consumed: '',
1389
- output: '',
1390
- prefix: '',
1391
- backtrack: false,
1392
- negated: false,
1393
- brackets: 0,
1394
- braces: 0,
1395
- parens: 0,
1396
- quotes: 0,
1397
- globstar: false,
1398
- tokens
1399
- };
1400
- input = utils.removePrefix(input, state);
1401
- len = input.length;
1402
- const extglobs = [];
1403
- const braces = [];
1404
- const stack = [];
1405
- let prev = bos;
1406
- let value;
1407
- const eos = ()=>state.index === len - 1;
1408
- const peek = state.peek = (n = 1)=>input[state.index + n];
1409
- const advance = state.advance = ()=>input[++state.index] || '';
1410
- const remaining = ()=>input.slice(state.index + 1);
1411
- const consume = (value = '', num = 0)=>{
1412
- state.consumed += value;
1413
- state.index += num;
1414
- };
1415
- const append = (token)=>{
1416
- state.output += null != token.output ? token.output : token.value;
1417
- consume(token.value);
1418
- };
1419
- const negate = ()=>{
1420
- let count = 1;
1421
- while('!' === peek() && ('(' !== peek(2) || '?' === peek(3))){
1422
- advance();
1423
- state.start++;
1424
- count++;
1425
- }
1426
- if (count % 2 === 0) return false;
1427
- state.negated = true;
1428
- state.start++;
1429
- return true;
1430
- };
1431
- const increment = (type)=>{
1432
- state[type]++;
1433
- stack.push(type);
1434
- };
1435
- const decrement = (type)=>{
1436
- state[type]--;
1437
- stack.pop();
1438
- };
1439
- const push = (tok)=>{
1440
- if ('globstar' === prev.type) {
1441
- const isBrace = state.braces > 0 && ('comma' === tok.type || 'brace' === tok.type);
1442
- const isExtglob = true === tok.extglob || extglobs.length && ('pipe' === tok.type || 'paren' === tok.type);
1443
- if ('slash' !== tok.type && 'paren' !== tok.type && !isBrace && !isExtglob) {
1444
- state.output = state.output.slice(0, -prev.output.length);
1445
- prev.type = 'star';
1446
- prev.value = '*';
1447
- prev.output = star;
1448
- state.output += prev.output;
1449
- }
1450
- }
1451
- if (extglobs.length && 'paren' !== tok.type) extglobs[extglobs.length - 1].inner += tok.value;
1452
- if (tok.value || tok.output) append(tok);
1453
- if (prev && 'text' === prev.type && 'text' === tok.type) {
1454
- prev.value += tok.value;
1455
- prev.output = (prev.output || '') + tok.value;
1456
- return;
1457
- }
1458
- tok.prev = prev;
1459
- tokens.push(tok);
1460
- prev = tok;
1461
- };
1462
- const extglobOpen = (type, value)=>{
1463
- const token = {
1464
- ...EXTGLOB_CHARS[value],
1465
- conditions: 1,
1466
- inner: ''
1467
- };
1468
- token.prev = prev;
1469
- token.parens = state.parens;
1470
- token.output = state.output;
1471
- token.startIndex = state.index;
1472
- token.tokensIndex = tokens.length;
1473
- const output = (opts.capture ? '(' : '') + token.open;
1474
- increment('parens');
1475
- push({
1476
- type,
1477
- value,
1478
- output: state.output ? '' : ONE_CHAR
1479
- });
1480
- push({
1481
- type: 'paren',
1482
- extglob: true,
1483
- value: advance(),
1484
- output
1485
- });
1486
- extglobs.push(token);
1487
- };
1488
- const extglobClose = (token)=>{
1489
- const literal = input.slice(token.startIndex, state.index + 1);
1490
- const body = input.slice(token.startIndex + 2, state.index);
1491
- const analysis = analyzeRepeatedExtglob(body, opts);
1492
- if (('plus' === token.type || 'star' === token.type) && analysis.risky) {
1493
- const safeOutput = analysis.safeOutput ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
1494
- const open = tokens[token.tokensIndex];
1495
- open.type = 'text';
1496
- open.value = literal;
1497
- open.output = safeOutput || utils.escapeRegex(literal);
1498
- for(let i = token.tokensIndex + 1; i < tokens.length; i++){
1499
- tokens[i].value = '';
1500
- tokens[i].output = '';
1501
- delete tokens[i].suffix;
1502
- }
1503
- state.output = token.output + open.output;
1504
- state.backtrack = true;
1505
- push({
1506
- type: 'paren',
1507
- extglob: true,
1508
- value,
1509
- output: ''
1510
- });
1511
- decrement('parens');
1512
- return;
1513
- }
1514
- let output = token.close + (opts.capture ? ')' : '');
1515
- let rest;
1516
- if ('negate' === token.type) {
1517
- let extglobStar = star;
1518
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) extglobStar = globstar(opts);
1519
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
1520
- if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
1521
- const expression = parse(rest, {
1522
- ...options,
1523
- fastpaths: false
1524
- }).output;
1525
- output = token.close = `)${expression})${extglobStar})`;
1526
- }
1527
- if ('bos' === token.prev.type) state.negatedExtglob = true;
1528
- }
1529
- push({
1530
- type: 'paren',
1531
- extglob: true,
1532
- value,
1533
- output
1534
- });
1535
- decrement('parens');
1536
- };
1537
- if (false !== opts.fastpaths && !/(^[*!]|[/()[\]{}"])/.test(input)) {
1538
- let backslashes = false;
1539
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index)=>{
1540
- if ('\\' === first) {
1541
- backslashes = true;
1542
- return m;
1543
- }
1544
- if ('?' === first) {
1545
- if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : '');
1546
- if (0 === index) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
1547
- return QMARK.repeat(chars.length);
1548
- }
1549
- if ('.' === first) return DOT_LITERAL.repeat(chars.length);
1550
- if ('*' === first) {
1551
- if (esc) return esc + first + (rest ? star : '');
1552
- return star;
1553
- }
1554
- return esc ? m : `\\${m}`;
1555
- });
1556
- if (true === backslashes) output = true === opts.unescape ? output.replace(/\\/g, '') : output.replace(/\\+/g, (m)=>m.length % 2 === 0 ? '\\\\' : m ? '\\' : '');
1557
- if (output === input && true === opts.contains) {
1558
- state.output = input;
1559
- return state;
1560
- }
1561
- state.output = utils.wrapOutput(output, state, options);
1562
- return state;
1563
- }
1564
- while(!eos()){
1565
- value = advance();
1566
- if ('\u0000' === value) continue;
1567
- if ('\\' === value) {
1568
- const next = peek();
1569
- if ('/' === next && true !== opts.bash) continue;
1570
- if ('.' === next || ';' === next) continue;
1571
- if (!next) {
1572
- value += '\\';
1573
- push({
1574
- type: 'text',
1575
- value
1576
- });
1577
- continue;
1578
- }
1579
- const match = /^\\+/.exec(remaining());
1580
- let slashes = 0;
1581
- if (match && match[0].length > 2) {
1582
- slashes = match[0].length;
1583
- state.index += slashes;
1584
- if (slashes % 2 !== 0) value += '\\';
1585
- }
1586
- if (true === opts.unescape) value = advance();
1587
- else value += advance();
1588
- if (0 === state.brackets) {
1589
- push({
1590
- type: 'text',
1591
- value
1592
- });
1593
- continue;
1594
- }
1595
- }
1596
- if (state.brackets > 0 && (']' !== value || '[' === prev.value || '[^' === prev.value)) {
1597
- if (false !== opts.posix && ':' === value) {
1598
- const inner = prev.value.slice(1);
1599
- if (inner.includes('[')) {
1600
- prev.posix = true;
1601
- if (inner.includes(':')) {
1602
- const idx = prev.value.lastIndexOf('[');
1603
- const pre = prev.value.slice(0, idx);
1604
- const rest = prev.value.slice(idx + 2);
1605
- const posix = POSIX_REGEX_SOURCE[rest];
1606
- if (posix) {
1607
- prev.value = pre + posix;
1608
- state.backtrack = true;
1609
- advance();
1610
- if (!bos.output && 1 === tokens.indexOf(prev)) bos.output = ONE_CHAR;
1611
- continue;
1612
- }
1613
- }
1614
- }
1615
- }
1616
- if ('[' === value && ':' !== peek() || '-' === value && ']' === peek()) value = `\\${value}`;
1617
- if (']' === value && ('[' === prev.value || '[^' === prev.value)) value = `\\${value}`;
1618
- if (true === opts.posix && '!' === value && '[' === prev.value) value = '^';
1619
- prev.value += value;
1620
- append({
1621
- value
1622
- });
1623
- continue;
1624
- }
1625
- if (1 === state.quotes && '"' !== value) {
1626
- value = utils.escapeRegex(value);
1627
- prev.value += value;
1628
- append({
1629
- value
1630
- });
1631
- continue;
1632
- }
1633
- if ('"' === value) {
1634
- state.quotes = 1 === state.quotes ? 0 : 1;
1635
- if (true === opts.keepQuotes) push({
1636
- type: 'text',
1637
- value
1638
- });
1639
- continue;
1640
- }
1641
- if ('(' === value) {
1642
- increment('parens');
1643
- push({
1644
- type: 'paren',
1645
- value
1646
- });
1647
- continue;
1648
- }
1649
- if (')' === value) {
1650
- if (0 === state.parens && true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '('));
1651
- const extglob = extglobs[extglobs.length - 1];
1652
- if (extglob && state.parens === extglob.parens + 1) {
1653
- extglobClose(extglobs.pop());
1654
- continue;
1655
- }
1656
- push({
1657
- type: 'paren',
1658
- value,
1659
- output: state.parens ? ')' : '\\)'
1660
- });
1661
- decrement('parens');
1662
- continue;
1663
- }
1664
- if ('[' === value) {
1665
- if (true !== opts.nobracket && remaining().includes(']')) increment('brackets');
1666
- else {
1667
- if (true !== opts.nobracket && true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
1668
- value = `\\${value}`;
1669
- }
1670
- push({
1671
- type: 'bracket',
1672
- value
1673
- });
1674
- continue;
1675
- }
1676
- if (']' === value) {
1677
- if (true === opts.nobracket || prev && 'bracket' === prev.type && 1 === prev.value.length) {
1678
- push({
1679
- type: 'text',
1680
- value,
1681
- output: `\\${value}`
1682
- });
1683
- continue;
1684
- }
1685
- if (0 === state.brackets) {
1686
- if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '['));
1687
- push({
1688
- type: 'text',
1689
- value,
1690
- output: `\\${value}`
1691
- });
1692
- continue;
1693
- }
1694
- decrement('brackets');
1695
- const prevValue = prev.value.slice(1);
1696
- if (true !== prev.posix && '^' === prevValue[0] && !prevValue.includes('/')) value = `/${value}`;
1697
- prev.value += value;
1698
- append({
1699
- value
1700
- });
1701
- if (false === opts.literalBrackets || utils.hasRegexChars(prevValue)) continue;
1702
- const escaped = utils.escapeRegex(prev.value);
1703
- state.output = state.output.slice(0, -prev.value.length);
1704
- if (true === opts.literalBrackets) {
1705
- state.output += escaped;
1706
- prev.value = escaped;
1707
- continue;
1708
- }
1709
- prev.value = `(${capture}${escaped}|${prev.value})`;
1710
- state.output += prev.value;
1711
- continue;
1712
- }
1713
- if ('{' === value && true !== opts.nobrace) {
1714
- increment('braces');
1715
- const open = {
1716
- type: 'brace',
1717
- value,
1718
- output: '(',
1719
- outputIndex: state.output.length,
1720
- tokensIndex: state.tokens.length
1721
- };
1722
- braces.push(open);
1723
- push(open);
1724
- continue;
1725
- }
1726
- if ('}' === value) {
1727
- const brace = braces[braces.length - 1];
1728
- if (true === opts.nobrace || !brace) {
1729
- push({
1730
- type: 'text',
1731
- value,
1732
- output: value
1733
- });
1734
- continue;
1735
- }
1736
- let output = ')';
1737
- if (true === brace.dots) {
1738
- const arr = tokens.slice();
1739
- const range = [];
1740
- for(let i = arr.length - 1; i >= 0; i--){
1741
- tokens.pop();
1742
- if ('brace' === arr[i].type) break;
1743
- if ('dots' !== arr[i].type) range.unshift(arr[i].value);
1744
- }
1745
- output = expandRange(range, opts);
1746
- state.backtrack = true;
1747
- }
1748
- if (true !== brace.comma && true !== brace.dots) {
1749
- const out = state.output.slice(0, brace.outputIndex);
1750
- const toks = state.tokens.slice(brace.tokensIndex);
1751
- brace.value = brace.output = '\\{';
1752
- value = output = '\\}';
1753
- state.output = out;
1754
- for (const t of toks)state.output += t.output || t.value;
1755
- }
1756
- push({
1757
- type: 'brace',
1758
- value,
1759
- output
1760
- });
1761
- decrement('braces');
1762
- braces.pop();
1763
- continue;
1764
- }
1765
- if ('|' === value) {
1766
- if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
1767
- push({
1768
- type: 'text',
1769
- value
1770
- });
1771
- continue;
1772
- }
1773
- if (',' === value) {
1774
- let output = value;
1775
- const brace = braces[braces.length - 1];
1776
- if (brace && 'braces' === stack[stack.length - 1]) {
1777
- brace.comma = true;
1778
- output = '|';
1779
- }
1780
- push({
1781
- type: 'comma',
1782
- value,
1783
- output
1784
- });
1785
- continue;
1786
- }
1787
- if ('/' === value) {
1788
- if ('dot' === prev.type && state.index === state.start + 1) {
1789
- state.start = state.index + 1;
1790
- state.consumed = '';
1791
- state.output = '';
1792
- tokens.pop();
1793
- prev = bos;
1794
- continue;
1795
- }
1796
- push({
1797
- type: 'slash',
1798
- value,
1799
- output: SLASH_LITERAL
1800
- });
1801
- continue;
1802
- }
1803
- if ('.' === value) {
1804
- if (state.braces > 0 && 'dot' === prev.type) {
1805
- if ('.' === prev.value) prev.output = DOT_LITERAL;
1806
- const brace = braces[braces.length - 1];
1807
- prev.type = 'dots';
1808
- prev.output += value;
1809
- prev.value += value;
1810
- brace.dots = true;
1811
- continue;
1812
- }
1813
- if (state.braces + state.parens === 0 && 'bos' !== prev.type && 'slash' !== prev.type) {
1814
- push({
1815
- type: 'text',
1816
- value,
1817
- output: DOT_LITERAL
1818
- });
1819
- continue;
1820
- }
1821
- push({
1822
- type: 'dot',
1823
- value,
1824
- output: DOT_LITERAL
1825
- });
1826
- continue;
1827
- }
1828
- if ('?' === value) {
1829
- const isGroup = prev && '(' === prev.value;
1830
- if (!isGroup && true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
1831
- extglobOpen('qmark', value);
1832
- continue;
1833
- }
1834
- if (prev && 'paren' === prev.type) {
1835
- const next = peek();
1836
- let output = value;
1837
- if ('<' === next && !utils.supportsLookbehinds()) throw new Error('Node.js v10 or higher is required for regex lookbehinds');
1838
- if ('(' === prev.value && !/[!=<:]/.test(next) || '<' === next && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
1839
- push({
1840
- type: 'text',
1841
- value,
1842
- output
1843
- });
1844
- continue;
1845
- }
1846
- if (true !== opts.dot && ('slash' === prev.type || 'bos' === prev.type)) {
1847
- push({
1848
- type: 'qmark',
1849
- value,
1850
- output: QMARK_NO_DOT
1851
- });
1852
- continue;
1853
- }
1854
- push({
1855
- type: 'qmark',
1856
- value,
1857
- output: QMARK
1858
- });
1859
- continue;
1860
- }
1861
- if ('!' === value) {
1862
- if (true !== opts.noextglob && '(' === peek()) {
1863
- if ('?' !== peek(2) || !/[!=<:]/.test(peek(3))) {
1864
- extglobOpen('negate', value);
1865
- continue;
1866
- }
1867
- }
1868
- if (true !== opts.nonegate && 0 === state.index) {
1869
- negate();
1870
- continue;
1871
- }
1872
- }
1873
- if ('+' === value) {
1874
- if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
1875
- extglobOpen('plus', value);
1876
- continue;
1877
- }
1878
- if (prev && '(' === prev.value || false === opts.regex) {
1879
- push({
1880
- type: 'plus',
1881
- value,
1882
- output: PLUS_LITERAL
1883
- });
1884
- continue;
1885
- }
1886
- if (prev && ('bracket' === prev.type || 'paren' === prev.type || 'brace' === prev.type) || state.parens > 0) {
1887
- push({
1888
- type: 'plus',
1889
- value
1890
- });
1891
- continue;
1892
- }
1893
- push({
1894
- type: 'plus',
1895
- value: PLUS_LITERAL
1896
- });
1897
- continue;
1898
- }
1899
- if ('@' === value) {
1900
- if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
1901
- push({
1902
- type: 'at',
1903
- extglob: true,
1904
- value,
1905
- output: ''
1906
- });
1907
- continue;
1908
- }
1909
- push({
1910
- type: 'text',
1911
- value
1912
- });
1913
- continue;
1914
- }
1915
- if ('*' !== value) {
1916
- if ('$' === value || '^' === value) value = `\\${value}`;
1917
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1918
- if (match) {
1919
- value += match[0];
1920
- state.index += match[0].length;
1921
- }
1922
- push({
1923
- type: 'text',
1924
- value
1925
- });
1926
- continue;
1927
- }
1928
- if (prev && ('globstar' === prev.type || true === prev.star)) {
1929
- prev.type = 'star';
1930
- prev.star = true;
1931
- prev.value += value;
1932
- prev.output = star;
1933
- state.backtrack = true;
1934
- state.globstar = true;
1935
- consume(value);
1936
- continue;
1937
- }
1938
- let rest = remaining();
1939
- if (true !== opts.noextglob && /^\([^?]/.test(rest)) {
1940
- extglobOpen('star', value);
1941
- continue;
1942
- }
1943
- if ('star' === prev.type) {
1944
- if (true === opts.noglobstar) {
1945
- consume(value);
1946
- continue;
1947
- }
1948
- const prior = prev.prev;
1949
- const before = prior.prev;
1950
- const isStart = 'slash' === prior.type || 'bos' === prior.type;
1951
- const afterStar = before && ('star' === before.type || 'globstar' === before.type);
1952
- if (true === opts.bash && (!isStart || rest[0] && '/' !== rest[0])) {
1953
- push({
1954
- type: 'star',
1955
- value,
1956
- output: ''
1957
- });
1958
- continue;
1959
- }
1960
- const isBrace = state.braces > 0 && ('comma' === prior.type || 'brace' === prior.type);
1961
- const isExtglob = extglobs.length && ('pipe' === prior.type || 'paren' === prior.type);
1962
- if (!isStart && 'paren' !== prior.type && !isBrace && !isExtglob) {
1963
- push({
1964
- type: 'star',
1965
- value,
1966
- output: ''
1967
- });
1968
- continue;
1969
- }
1970
- while('/**' === rest.slice(0, 3)){
1971
- const after = input[state.index + 4];
1972
- if (after && '/' !== after) break;
1973
- rest = rest.slice(3);
1974
- consume('/**', 3);
1975
- }
1976
- if ('bos' === prior.type && eos()) {
1977
- prev.type = 'globstar';
1978
- prev.value += value;
1979
- prev.output = globstar(opts);
1980
- state.output = prev.output;
1981
- state.globstar = true;
1982
- consume(value);
1983
- continue;
1984
- }
1985
- if ('slash' === prior.type && 'bos' !== prior.prev.type && !afterStar && eos()) {
1986
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1987
- prior.output = `(?:${prior.output}`;
1988
- prev.type = 'globstar';
1989
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
1990
- prev.value += value;
1991
- state.globstar = true;
1992
- state.output += prior.output + prev.output;
1993
- consume(value);
1994
- continue;
1995
- }
1996
- if ('slash' === prior.type && 'bos' !== prior.prev.type && '/' === rest[0]) {
1997
- const end = void 0 !== rest[1] ? '|$' : '';
1998
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1999
- prior.output = `(?:${prior.output}`;
2000
- prev.type = 'globstar';
2001
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
2002
- prev.value += value;
2003
- state.output += prior.output + prev.output;
2004
- state.globstar = true;
2005
- consume(value + advance());
2006
- push({
2007
- type: 'slash',
2008
- value: '/',
2009
- output: ''
2010
- });
2011
- continue;
2012
- }
2013
- if ('bos' === prior.type && '/' === rest[0]) {
2014
- prev.type = 'globstar';
2015
- prev.value += value;
2016
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
2017
- state.output = prev.output;
2018
- state.globstar = true;
2019
- consume(value + advance());
2020
- push({
2021
- type: 'slash',
2022
- value: '/',
2023
- output: ''
2024
- });
2025
- continue;
2026
- }
2027
- state.output = state.output.slice(0, -prev.output.length);
2028
- prev.type = 'globstar';
2029
- prev.output = globstar(opts);
2030
- prev.value += value;
2031
- state.output += prev.output;
2032
- state.globstar = true;
2033
- consume(value);
2034
- continue;
2035
- }
2036
- const token = {
2037
- type: 'star',
2038
- value,
2039
- output: star
2040
- };
2041
- if (true === opts.bash) {
2042
- token.output = '.*?';
2043
- if ('bos' === prev.type || 'slash' === prev.type) token.output = nodot + token.output;
2044
- push(token);
2045
- continue;
2046
- }
2047
- if (prev && ('bracket' === prev.type || 'paren' === prev.type) && true === opts.regex) {
2048
- token.output = value;
2049
- push(token);
2050
- continue;
2051
- }
2052
- if (state.index === state.start || 'slash' === prev.type || 'dot' === prev.type) {
2053
- if ('dot' === prev.type) {
2054
- state.output += NO_DOT_SLASH;
2055
- prev.output += NO_DOT_SLASH;
2056
- } else if (true === opts.dot) {
2057
- state.output += NO_DOTS_SLASH;
2058
- prev.output += NO_DOTS_SLASH;
2059
- } else {
2060
- state.output += nodot;
2061
- prev.output += nodot;
2062
- }
2063
- if ('*' !== peek()) {
2064
- state.output += ONE_CHAR;
2065
- prev.output += ONE_CHAR;
2066
- }
2067
- }
2068
- push(token);
2069
- }
2070
- while(state.brackets > 0){
2071
- if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
2072
- state.output = utils.escapeLast(state.output, '[');
2073
- decrement('brackets');
2074
- }
2075
- while(state.parens > 0){
2076
- if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ')'));
2077
- state.output = utils.escapeLast(state.output, '(');
2078
- decrement('parens');
2079
- }
2080
- while(state.braces > 0){
2081
- if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', '}'));
2082
- state.output = utils.escapeLast(state.output, '{');
2083
- decrement('braces');
2084
- }
2085
- if (true !== opts.strictSlashes && ('star' === prev.type || 'bracket' === prev.type)) push({
2086
- type: 'maybe_slash',
2087
- value: '',
2088
- output: `${SLASH_LITERAL}?`
2089
- });
2090
- if (true === state.backtrack) {
2091
- state.output = '';
2092
- for (const token of state.tokens){
2093
- state.output += null != token.output ? token.output : token.value;
2094
- if (token.suffix) state.output += token.suffix;
2095
- }
2096
- }
2097
- return state;
2098
- };
2099
- parse.fastpaths = (input, options)=>{
2100
- const opts = {
2101
- ...options
2102
- };
2103
- const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
2104
- const len = input.length;
2105
- if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
2106
- input = REPLACEMENTS[input] || input;
2107
- const win32 = utils.isWindows(options);
2108
- const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(win32);
2109
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
2110
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
2111
- const capture = opts.capture ? '' : '?:';
2112
- const state = {
2113
- negated: false,
2114
- prefix: ''
2115
- };
2116
- let star = true === opts.bash ? '.*?' : STAR;
2117
- if (opts.capture) star = `(${star})`;
2118
- const globstar = (opts)=>{
2119
- if (true === opts.noglobstar) return star;
2120
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2121
- };
2122
- const create = (str)=>{
2123
- switch(str){
2124
- case '*':
2125
- return `${nodot}${ONE_CHAR}${star}`;
2126
- case '.*':
2127
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
2128
- case '*.*':
2129
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2130
- case '*/*':
2131
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
2132
- case '**':
2133
- return nodot + globstar(opts);
2134
- case '**/*':
2135
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
2136
- case '**/*.*':
2137
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2138
- case '**/.*':
2139
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
2140
- default:
2141
- {
2142
- const match = /^(.*?)\.(\w+)$/.exec(str);
2143
- if (!match) return;
2144
- const source = create(match[1]);
2145
- if (!source) return;
2146
- return source + DOT_LITERAL + match[2];
2147
- }
2148
- }
2149
- };
2150
- const output = utils.removePrefix(input, state);
2151
- let source = create(output);
2152
- if (source && true !== opts.strictSlashes) source += `${SLASH_LITERAL}?`;
2153
- return source;
2154
- };
2155
- module.exports = parse;
2156
- },
2157
- "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
2158
- const path = __webpack_require__("path");
2159
- const scan = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/scan.js");
2160
- const parse = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/parse.js");
2161
- const utils = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
2162
- const constants = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js");
2163
- const isObject = (val)=>val && 'object' == typeof val && !Array.isArray(val);
2164
- const picomatch = (glob, options, returnState = false)=>{
2165
- if (Array.isArray(glob)) {
2166
- const fns = glob.map((input)=>picomatch(input, options, returnState));
2167
- const arrayMatcher = (str)=>{
2168
- for (const isMatch of fns){
2169
- const state = isMatch(str);
2170
- if (state) return state;
2171
- }
2172
- return false;
2173
- };
2174
- return arrayMatcher;
2175
- }
2176
- const isState = isObject(glob) && glob.tokens && glob.input;
2177
- if ('' === glob || 'string' != typeof glob && !isState) throw new TypeError('Expected pattern to be a non-empty string');
2178
- const opts = options || {};
2179
- const posix = utils.isWindows(options);
2180
- const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
2181
- const state = regex.state;
2182
- delete regex.state;
2183
- let isIgnored = ()=>false;
2184
- if (opts.ignore) {
2185
- const ignoreOpts = {
2186
- ...options,
2187
- ignore: null,
2188
- onMatch: null,
2189
- onResult: null
2190
- };
2191
- isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
2192
- }
2193
- const matcher = (input, returnObject = false)=>{
2194
- const { isMatch, match, output } = picomatch.test(input, regex, options, {
2195
- glob,
2196
- posix
2197
- });
2198
- const result = {
2199
- glob,
2200
- state,
2201
- regex,
2202
- posix,
2203
- input,
2204
- output,
2205
- match,
2206
- isMatch
2207
- };
2208
- if ('function' == typeof opts.onResult) opts.onResult(result);
2209
- if (false === isMatch) {
2210
- result.isMatch = false;
2211
- return returnObject ? result : false;
2212
- }
2213
- if (isIgnored(input)) {
2214
- if ('function' == typeof opts.onIgnore) opts.onIgnore(result);
2215
- result.isMatch = false;
2216
- return returnObject ? result : false;
2217
- }
2218
- if ('function' == typeof opts.onMatch) opts.onMatch(result);
2219
- return returnObject ? result : true;
2220
- };
2221
- if (returnState) matcher.state = state;
2222
- return matcher;
2223
- };
2224
- picomatch.test = (input, regex, options, { glob, posix } = {})=>{
2225
- if ('string' != typeof input) throw new TypeError('Expected input to be a string');
2226
- if ('' === input) return {
2227
- isMatch: false,
2228
- output: ''
2229
- };
2230
- const opts = options || {};
2231
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
2232
- let match = input === glob;
2233
- let output = match && format ? format(input) : input;
2234
- if (false === match) {
2235
- output = format ? format(input) : input;
2236
- match = output === glob;
2237
- }
2238
- if (false === match || true === opts.capture) match = true === opts.matchBase || true === opts.basename ? picomatch.matchBase(input, regex, options, posix) : regex.exec(output);
2239
- return {
2240
- isMatch: Boolean(match),
2241
- match,
2242
- output
2243
- };
2244
- };
2245
- picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options))=>{
2246
- const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
2247
- return regex.test(path.basename(input));
2248
- };
2249
- picomatch.isMatch = (str, patterns, options)=>picomatch(patterns, options)(str);
2250
- picomatch.parse = (pattern, options)=>{
2251
- if (Array.isArray(pattern)) return pattern.map((p)=>picomatch.parse(p, options));
2252
- return parse(pattern, {
2253
- ...options,
2254
- fastpaths: false
2255
- });
2256
- };
2257
- picomatch.scan = (input, options)=>scan(input, options);
2258
- picomatch.compileRe = (state, options, returnOutput = false, returnState = false)=>{
2259
- if (true === returnOutput) return state.output;
2260
- const opts = options || {};
2261
- const prepend = opts.contains ? '' : '^';
2262
- const append = opts.contains ? '' : '$';
2263
- let source = `${prepend}(?:${state.output})${append}`;
2264
- if (state && true === state.negated) source = `^(?!${source}).*$`;
2265
- const regex = picomatch.toRegex(source, options);
2266
- if (true === returnState) regex.state = state;
2267
- return regex;
2268
- };
2269
- picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false)=>{
2270
- if (!input || 'string' != typeof input) throw new TypeError('Expected a non-empty string');
2271
- let parsed = {
2272
- negated: false,
2273
- fastpaths: true
2274
- };
2275
- if (false !== options.fastpaths && ('.' === input[0] || '*' === input[0])) parsed.output = parse.fastpaths(input, options);
2276
- if (!parsed.output) parsed = parse(input, options);
2277
- return picomatch.compileRe(parsed, options, returnOutput, returnState);
2278
- };
2279
- picomatch.toRegex = (source, options)=>{
2280
- try {
2281
- const opts = options || {};
2282
- return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
2283
- } catch (err) {
2284
- if (options && true === options.debug) throw err;
2285
- return /$^/;
2286
- }
2287
- };
2288
- picomatch.constants = constants;
2289
- module.exports = picomatch;
2290
- },
2291
- "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
2292
- const utils = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
2293
- const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js");
2294
- const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
2295
- const depth = (token)=>{
2296
- if (true !== token.isPrefix) token.depth = token.isGlobstar ? 1 / 0 : 1;
2297
- };
2298
- const scan = (input, options)=>{
2299
- const opts = options || {};
2300
- const length = input.length - 1;
2301
- const scanToEnd = true === opts.parts || true === opts.scanToEnd;
2302
- const slashes = [];
2303
- const tokens = [];
2304
- const parts = [];
2305
- let str = input;
2306
- let index = -1;
2307
- let start = 0;
2308
- let lastIndex = 0;
2309
- let isBrace = false;
2310
- let isBracket = false;
2311
- let isGlob = false;
2312
- let isExtglob = false;
2313
- let isGlobstar = false;
2314
- let braceEscaped = false;
2315
- let backslashes = false;
2316
- let negated = false;
2317
- let negatedExtglob = false;
2318
- let finished = false;
2319
- let braces = 0;
2320
- let prev;
2321
- let code;
2322
- let token = {
2323
- value: '',
2324
- depth: 0,
2325
- isGlob: false
2326
- };
2327
- const eos = ()=>index >= length;
2328
- const peek = ()=>str.charCodeAt(index + 1);
2329
- const advance = ()=>{
2330
- prev = code;
2331
- return str.charCodeAt(++index);
2332
- };
2333
- while(index < length){
2334
- code = advance();
2335
- let next;
2336
- if (code === CHAR_BACKWARD_SLASH) {
2337
- backslashes = token.backslashes = true;
2338
- code = advance();
2339
- if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
2340
- continue;
2341
- }
2342
- if (true === braceEscaped || code === CHAR_LEFT_CURLY_BRACE) {
2343
- braces++;
2344
- while(true !== eos() && (code = advance())){
2345
- if (code === CHAR_BACKWARD_SLASH) {
2346
- backslashes = token.backslashes = true;
2347
- advance();
2348
- continue;
2349
- }
2350
- if (code === CHAR_LEFT_CURLY_BRACE) {
2351
- braces++;
2352
- continue;
2353
- }
2354
- if (true !== braceEscaped && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
2355
- isBrace = token.isBrace = true;
2356
- isGlob = token.isGlob = true;
2357
- finished = true;
2358
- if (true === scanToEnd) continue;
2359
- break;
2360
- }
2361
- if (true !== braceEscaped && code === CHAR_COMMA) {
2362
- isBrace = token.isBrace = true;
2363
- isGlob = token.isGlob = true;
2364
- finished = true;
2365
- if (true === scanToEnd) continue;
2366
- break;
2367
- }
2368
- if (code === CHAR_RIGHT_CURLY_BRACE) {
2369
- braces--;
2370
- if (0 === braces) {
2371
- braceEscaped = false;
2372
- isBrace = token.isBrace = true;
2373
- finished = true;
2374
- break;
2375
- }
2376
- }
2377
- }
2378
- if (true === scanToEnd) continue;
2379
- break;
2380
- }
2381
- if (code === CHAR_FORWARD_SLASH) {
2382
- slashes.push(index);
2383
- tokens.push(token);
2384
- token = {
2385
- value: '',
2386
- depth: 0,
2387
- isGlob: false
2388
- };
2389
- if (true === finished) continue;
2390
- if (prev === CHAR_DOT && index === start + 1) {
2391
- start += 2;
2392
- continue;
2393
- }
2394
- lastIndex = index + 1;
2395
- continue;
2396
- }
2397
- if (true !== opts.noext) {
2398
- const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
2399
- if (true === isExtglobChar && peek() === CHAR_LEFT_PARENTHESES) {
2400
- isGlob = token.isGlob = true;
2401
- isExtglob = token.isExtglob = true;
2402
- finished = true;
2403
- if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
2404
- if (true === scanToEnd) {
2405
- while(true !== eos() && (code = advance())){
2406
- if (code === CHAR_BACKWARD_SLASH) {
2407
- backslashes = token.backslashes = true;
2408
- code = advance();
2409
- continue;
2410
- }
2411
- if (code === CHAR_RIGHT_PARENTHESES) {
2412
- isGlob = token.isGlob = true;
2413
- finished = true;
2414
- break;
2415
- }
2416
- }
2417
- continue;
2418
- }
2419
- break;
2420
- }
2421
- }
2422
- if (code === CHAR_ASTERISK) {
2423
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
2424
- isGlob = token.isGlob = true;
2425
- finished = true;
2426
- if (true === scanToEnd) continue;
2427
- break;
2428
- }
2429
- if (code === CHAR_QUESTION_MARK) {
2430
- isGlob = token.isGlob = true;
2431
- finished = true;
2432
- if (true === scanToEnd) continue;
2433
- break;
2434
- }
2435
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
2436
- while(true !== eos() && (next = advance())){
2437
- if (next === CHAR_BACKWARD_SLASH) {
2438
- backslashes = token.backslashes = true;
2439
- advance();
2440
- continue;
2441
- }
2442
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
2443
- isBracket = token.isBracket = true;
2444
- isGlob = token.isGlob = true;
2445
- finished = true;
2446
- break;
2447
- }
2448
- }
2449
- if (true === scanToEnd) continue;
2450
- break;
2451
- }
2452
- if (true !== opts.nonegate && code === CHAR_EXCLAMATION_MARK && index === start) {
2453
- negated = token.negated = true;
2454
- start++;
2455
- continue;
2456
- }
2457
- if (true !== opts.noparen && code === CHAR_LEFT_PARENTHESES) {
2458
- isGlob = token.isGlob = true;
2459
- if (true === scanToEnd) {
2460
- while(true !== eos() && (code = advance())){
2461
- if (code === CHAR_LEFT_PARENTHESES) {
2462
- backslashes = token.backslashes = true;
2463
- code = advance();
2464
- continue;
2465
- }
2466
- if (code === CHAR_RIGHT_PARENTHESES) {
2467
- finished = true;
2468
- break;
2469
- }
2470
- }
2471
- continue;
2472
- }
2473
- break;
2474
- }
2475
- if (true === isGlob) {
2476
- finished = true;
2477
- if (true === scanToEnd) continue;
2478
- break;
2479
- }
2480
- }
2481
- if (true === opts.noext) {
2482
- isExtglob = false;
2483
- isGlob = false;
2484
- }
2485
- let base = str;
2486
- let prefix = '';
2487
- let glob = '';
2488
- if (start > 0) {
2489
- prefix = str.slice(0, start);
2490
- str = str.slice(start);
2491
- lastIndex -= start;
2492
- }
2493
- if (base && true === isGlob && lastIndex > 0) {
2494
- base = str.slice(0, lastIndex);
2495
- glob = str.slice(lastIndex);
2496
- } else if (true === isGlob) {
2497
- base = '';
2498
- glob = str;
2499
- } else base = str;
2500
- if (base && '' !== base && '/' !== base && base !== str) {
2501
- if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
2502
- }
2503
- if (true === opts.unescape) {
2504
- if (glob) glob = utils.removeBackslashes(glob);
2505
- if (base && true === backslashes) base = utils.removeBackslashes(base);
2506
- }
2507
- const state = {
2508
- prefix,
2509
- input,
2510
- start,
2511
- base,
2512
- glob,
2513
- isBrace,
2514
- isBracket,
2515
- isGlob,
2516
- isExtglob,
2517
- isGlobstar,
2518
- negated,
2519
- negatedExtglob
2520
- };
2521
- if (true === opts.tokens) {
2522
- state.maxDepth = 0;
2523
- if (!isPathSeparator(code)) tokens.push(token);
2524
- state.tokens = tokens;
2525
- }
2526
- if (true === opts.parts || true === opts.tokens) {
2527
- let prevIndex;
2528
- for(let idx = 0; idx < slashes.length; idx++){
2529
- const n = prevIndex ? prevIndex + 1 : start;
2530
- const i = slashes[idx];
2531
- const value = input.slice(n, i);
2532
- if (opts.tokens) {
2533
- if (0 === idx && 0 !== start) {
2534
- tokens[idx].isPrefix = true;
2535
- tokens[idx].value = prefix;
2536
- } else tokens[idx].value = value;
2537
- depth(tokens[idx]);
2538
- state.maxDepth += tokens[idx].depth;
2539
- }
2540
- if (0 !== idx || '' !== value) parts.push(value);
2541
- prevIndex = i;
2542
- }
2543
- if (prevIndex && prevIndex + 1 < input.length) {
2544
- const value = input.slice(prevIndex + 1);
2545
- parts.push(value);
2546
- if (opts.tokens) {
2547
- tokens[tokens.length - 1].value = value;
2548
- depth(tokens[tokens.length - 1]);
2549
- state.maxDepth += tokens[tokens.length - 1].depth;
2550
- }
2551
- }
2552
- state.slashes = slashes;
2553
- state.parts = parts;
2554
- }
2555
- return state;
2556
- };
2557
- module.exports = scan;
2558
- },
2559
- "./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
2560
- const path = __webpack_require__("path");
2561
- const win32 = 'win32' === process.platform;
2562
- const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js");
2563
- exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
2564
- exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
2565
- exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str);
2566
- exports.escapeRegex = (str)=>str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
2567
- exports.toPosixSlashes = (str)=>str.replace(REGEX_BACKSLASH, '/');
2568
- exports.removeBackslashes = (str)=>str.replace(REGEX_REMOVE_BACKSLASH, (match)=>'\\' === match ? '' : match);
2569
- exports.supportsLookbehinds = ()=>{
2570
- const segs = process.version.slice(1).split('.').map(Number);
2571
- if (3 === segs.length && segs[0] >= 9 || 8 === segs[0] && segs[1] >= 10) return true;
2572
- return false;
2573
- };
2574
- exports.isWindows = (options)=>{
2575
- if (options && 'boolean' == typeof options.windows) return options.windows;
2576
- return true === win32 || '\\' === path.sep;
2577
- };
2578
- exports.escapeLast = (input, char, lastIdx)=>{
2579
- const idx = input.lastIndexOf(char, lastIdx);
2580
- if (-1 === idx) return input;
2581
- if ('\\' === input[idx - 1]) return exports.escapeLast(input, char, idx - 1);
2582
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
2583
- };
2584
- exports.removePrefix = (input, state = {})=>{
2585
- let output = input;
2586
- if (output.startsWith('./')) {
2587
- output = output.slice(2);
2588
- state.prefix = './';
2589
- }
2590
- return output;
2591
- };
2592
- exports.wrapOutput = (input, state = {}, options = {})=>{
2593
- const prepend = options.contains ? '' : '^';
2594
- const append = options.contains ? '' : '$';
2595
- let output = `${prepend}(?:${input})${append}`;
2596
- if (true === state.negated) output = `(?:^(?!${output}).*$)`;
2597
- return output;
2598
- };
2599
- },
2600
- "./node_modules/.pnpm/to-regex-range@5.0.1/node_modules/to-regex-range/index.js" (module, __unused_rspack_exports, __webpack_require__) {
2601
- /*!
2602
- * to-regex-range <https://github.com/micromatch/to-regex-range>
2603
- *
2604
- * Copyright (c) 2015-present, Jon Schlinkert.
2605
- * Released under the MIT License.
2606
- */ const isNumber = __webpack_require__("./node_modules/.pnpm/is-number@7.0.0/node_modules/is-number/index.js");
2607
- const toRegexRange = (min, max, options)=>{
2608
- if (false === isNumber(min)) throw new TypeError('toRegexRange: expected the first argument to be a number');
2609
- if (void 0 === max || min === max) return String(min);
2610
- if (false === isNumber(max)) throw new TypeError('toRegexRange: expected the second argument to be a number.');
2611
- let opts = {
2612
- relaxZeros: true,
2613
- ...options
2614
- };
2615
- if ('boolean' == typeof opts.strictZeros) opts.relaxZeros = false === opts.strictZeros;
2616
- let relax = String(opts.relaxZeros);
2617
- let shorthand = String(opts.shorthand);
2618
- let capture = String(opts.capture);
2619
- let wrap = String(opts.wrap);
2620
- let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
2621
- if (toRegexRange.cache.hasOwnProperty(cacheKey)) return toRegexRange.cache[cacheKey].result;
2622
- let a = Math.min(min, max);
2623
- let b = Math.max(min, max);
2624
- if (1 === Math.abs(a - b)) {
2625
- let result = min + '|' + max;
2626
- if (opts.capture) return `(${result})`;
2627
- if (false === opts.wrap) return result;
2628
- return `(?:${result})`;
2629
- }
2630
- let isPadded = hasPadding(min) || hasPadding(max);
2631
- let state = {
2632
- min,
2633
- max,
2634
- a,
2635
- b
2636
- };
2637
- let positives = [];
2638
- let negatives = [];
2639
- if (isPadded) {
2640
- state.isPadded = isPadded;
2641
- state.maxLen = String(state.max).length;
2642
- }
2643
- if (a < 0) {
2644
- let newMin = b < 0 ? Math.abs(b) : 1;
2645
- negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
2646
- a = state.a = 0;
2647
- }
2648
- if (b >= 0) positives = splitToPatterns(a, b, state, opts);
2649
- state.negatives = negatives;
2650
- state.positives = positives;
2651
- state.result = collatePatterns(negatives, positives, opts);
2652
- if (true === opts.capture) state.result = `(${state.result})`;
2653
- else if (false !== opts.wrap && positives.length + negatives.length > 1) state.result = `(?:${state.result})`;
2654
- toRegexRange.cache[cacheKey] = state;
2655
- return state.result;
2656
- };
2657
- function collatePatterns(neg, pos, options) {
2658
- let onlyNegative = filterPatterns(neg, pos, '-', false, options) || [];
2659
- let onlyPositive = filterPatterns(pos, neg, '', false, options) || [];
2660
- let intersected = filterPatterns(neg, pos, '-?', true, options) || [];
2661
- let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
2662
- return subpatterns.join('|');
2663
- }
2664
- function splitToRanges(min, max) {
2665
- let nines = 1;
2666
- let zeros = 1;
2667
- let stop = countNines(min, nines);
2668
- let stops = new Set([
2669
- max
2670
- ]);
2671
- while(min <= stop && stop <= max){
2672
- stops.add(stop);
2673
- nines += 1;
2674
- stop = countNines(min, nines);
2675
- }
2676
- stop = countZeros(max + 1, zeros) - 1;
2677
- while(min < stop && stop <= max){
2678
- stops.add(stop);
2679
- zeros += 1;
2680
- stop = countZeros(max + 1, zeros) - 1;
2681
- }
2682
- stops = [
2683
- ...stops
2684
- ];
2685
- stops.sort(compare);
2686
- return stops;
2687
- }
2688
- function rangeToPattern(start, stop, options) {
2689
- if (start === stop) return {
2690
- pattern: start,
2691
- count: [],
2692
- digits: 0
2693
- };
2694
- let zipped = zip(start, stop);
2695
- let digits = zipped.length;
2696
- let pattern = '';
2697
- let count = 0;
2698
- for(let i = 0; i < digits; i++){
2699
- let [startDigit, stopDigit] = zipped[i];
2700
- if (startDigit === stopDigit) pattern += startDigit;
2701
- else if ('0' !== startDigit || '9' !== stopDigit) pattern += toCharacterClass(startDigit, stopDigit, options);
2702
- else count++;
2703
- }
2704
- if (count) pattern += true === options.shorthand ? '\\d' : '[0-9]';
2705
- return {
2706
- pattern,
2707
- count: [
2708
- count
2709
- ],
2710
- digits
2711
- };
2712
- }
2713
- function splitToPatterns(min, max, tok, options) {
2714
- let ranges = splitToRanges(min, max);
2715
- let tokens = [];
2716
- let start = min;
2717
- let prev;
2718
- for(let i = 0; i < ranges.length; i++){
2719
- let max = ranges[i];
2720
- let obj = rangeToPattern(String(start), String(max), options);
2721
- let zeros = '';
2722
- if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
2723
- if (prev.count.length > 1) prev.count.pop();
2724
- prev.count.push(obj.count[0]);
2725
- prev.string = prev.pattern + toQuantifier(prev.count);
2726
- start = max + 1;
2727
- continue;
2728
- }
2729
- if (tok.isPadded) zeros = padZeros(max, tok, options);
2730
- obj.string = zeros + obj.pattern + toQuantifier(obj.count);
2731
- tokens.push(obj);
2732
- start = max + 1;
2733
- prev = obj;
2734
- }
2735
- return tokens;
2736
- }
2737
- function filterPatterns(arr, comparison, prefix, intersection, options) {
2738
- let result = [];
2739
- for (let ele of arr){
2740
- let { string } = ele;
2741
- if (!intersection && !contains(comparison, 'string', string)) result.push(prefix + string);
2742
- if (intersection && contains(comparison, 'string', string)) result.push(prefix + string);
2743
- }
2744
- return result;
2745
- }
2746
- function zip(a, b) {
2747
- let arr = [];
2748
- for(let i = 0; i < a.length; i++)arr.push([
2749
- a[i],
2750
- b[i]
2751
- ]);
2752
- return arr;
2753
- }
2754
- function compare(a, b) {
2755
- return a > b ? 1 : b > a ? -1 : 0;
2756
- }
2757
- function contains(arr, key, val) {
2758
- return arr.some((ele)=>ele[key] === val);
2759
- }
2760
- function countNines(min, len) {
2761
- return Number(String(min).slice(0, -len) + '9'.repeat(len));
2762
- }
2763
- function countZeros(integer, zeros) {
2764
- return integer - integer % Math.pow(10, zeros);
2765
- }
2766
- function toQuantifier(digits) {
2767
- let [start = 0, stop = ''] = digits;
2768
- if (stop || start > 1) return `{${start + (stop ? ',' + stop : '')}}`;
2769
- return '';
2770
- }
2771
- function toCharacterClass(a, b, options) {
2772
- return `[${a}${b - a === 1 ? '' : '-'}${b}]`;
2773
- }
2774
- function hasPadding(str) {
2775
- return /^-?(0+)\d/.test(str);
2776
- }
2777
- function padZeros(value, tok, options) {
2778
- if (!tok.isPadded) return value;
2779
- let diff = Math.abs(tok.maxLen - String(value).length);
2780
- let relax = false !== options.relaxZeros;
2781
- switch(diff){
2782
- case 0:
2783
- return '';
2784
- case 1:
2785
- return relax ? '0?' : '0';
2786
- case 2:
2787
- return relax ? '0{0,2}' : '00';
2788
- default:
2789
- return relax ? `0{0,${diff}}` : `0{${diff}}`;
2790
- }
2791
- }
2792
- toRegexRange.cache = {};
2793
- toRegexRange.clearCache = ()=>toRegexRange.cache = {};
2794
- module.exports = toRegexRange;
2795
- }
2796
- });
2797
- const upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i;
2798
- const defaultAgents = {
2799
- http: new node_http.Agent({
2800
- keepAlive: true,
2801
- maxSockets: 256,
2802
- maxFreeSockets: 64
2803
- }),
2804
- https: new node_https.Agent({
2805
- keepAlive: true,
2806
- maxSockets: 256,
2807
- maxFreeSockets: 64
2808
- })
2809
- };
2810
- const isSSL = /^https|wss/;
2811
- const HTTP2_HEADER_BLACKLIST = [
2812
- ":method",
2813
- ":path",
2814
- ":scheme",
2815
- ":authority"
2816
- ];
2817
- function setupOutgoing(outgoing, options, req, forward) {
2818
- outgoing.port = options[forward || "target"].port || (isSSL.test(options[forward || "target"].protocol ?? "http") ? 443 : 80);
2819
- for (const e of [
2820
- "host",
2821
- "hostname",
2822
- "socketPath",
2823
- "pfx",
2824
- "key",
2825
- "passphrase",
2826
- "cert",
2827
- "ca",
2828
- "ciphers",
2829
- "secureProtocol"
2830
- ]){
2831
- const value = options[forward || "target"][e];
2832
- if (void 0 !== value) outgoing[e] = value;
2833
- }
2834
- outgoing.method = options.method || req.method;
2835
- outgoing.headers = {
2836
- ...req.headers
2837
- };
2838
- if (req.headers?.[":authority"]) outgoing.headers.host = req.headers[":authority"];
2839
- if (options.headers) for (const key of Object.keys(options.headers))outgoing.headers[key] = options.headers[key];
2840
- if (req.httpVersionMajor > 1) for (const header of HTTP2_HEADER_BLACKLIST)delete outgoing.headers[header];
2841
- if (options.auth) outgoing.auth = options.auth;
2842
- if (options.ca) outgoing.ca = options.ca;
2843
- if (isSSL.test(options[forward || "target"].protocol ?? "http")) outgoing.rejectUnauthorized = void 0 === options.secure ? true : options.secure;
2844
- if (void 0 !== options.agent) outgoing.agent = options.agent || false;
2845
- else if (req.httpVersionMajor > 1) outgoing.agent = false;
2846
- else {
2847
- const targetProto = options[forward || "target"].protocol ?? "http";
2848
- outgoing.agent = isSSL.test(targetProto) ? defaultAgents.https : defaultAgents.http;
2849
- }
2850
- outgoing.localAddress = options.localAddress;
2851
- if (!outgoing.agent) {
2852
- outgoing.headers = outgoing.headers || {};
2853
- if ("string" != typeof outgoing.headers.connection || !upgradeHeader.test(outgoing.headers.connection)) outgoing.headers.connection = "close";
2854
- }
2855
- const target = options[forward || "target"];
2856
- const targetPath = target && false !== options.prependPath ? target.pathname || "" : "";
2857
- const targetSearch = target instanceof URL && false !== options.prependPath ? target.search || "" : "";
2858
- const reqUrl = req.url || "";
2859
- const qIdx = reqUrl.indexOf("?");
2860
- const reqPath = -1 === qIdx ? reqUrl : reqUrl.slice(0, qIdx);
2861
- const reqSearch = -1 === qIdx ? "" : reqUrl.slice(qIdx);
2862
- const normalizedPath = reqPath ? "/" === reqPath[0] ? reqPath : "/" + reqPath : "/";
2863
- let outgoingPath = options.toProxy ? "/" + reqUrl : normalizedPath + reqSearch;
2864
- outgoingPath = options.ignorePath ? "" : outgoingPath;
2865
- let fullPath = joinURL(targetPath, outgoingPath);
2866
- if (targetSearch) fullPath = fullPath.includes("?") ? fullPath.replace("?", targetSearch + "&") : fullPath + targetSearch;
2867
- outgoing.path = fullPath;
2868
- if (options.changeOrigin) outgoing.headers.host = requiresPort(outgoing.port, options[forward || "target"].protocol) && !hasPort(outgoing.host) ? outgoing.host + ":" + outgoing.port : outgoing.host ?? void 0;
2869
- return outgoing;
2870
- }
2871
- function joinURL(base, path) {
2872
- if (!base || "/" === base) return path || "/";
2873
- if (!path || "/" === path) return base || "/";
2874
- const baseHasTrailing = "/" === base[base.length - 1];
2875
- const pathHasLeading = "/" === path[0];
2876
- if (baseHasTrailing && pathHasLeading) return base + path.slice(1);
2877
- if (!baseHasTrailing && !pathHasLeading) return base + "/" + path;
2878
- return base + path;
2879
- }
2880
- function setupSocket(socket) {
2881
- socket.setTimeout(0);
2882
- socket.setNoDelay(true);
2883
- socket.setKeepAlive(true, 0);
2884
- return socket;
2885
- }
2886
- function getPort(req) {
2887
- const hostHeader = req.headers[":authority"] || req.headers.host;
2888
- const res = hostHeader ? hostHeader.match(/:(\d+)/) : "";
2889
- if (res) return res[1];
2890
- return hasEncryptedConnection(req) ? "443" : "80";
2891
- }
2892
- function hasEncryptedConnection(req) {
2893
- const socket = req.socket;
2894
- return !!socket && "encrypted" in socket && socket.encrypted;
2895
- }
2896
- function rewriteCookieProperty(header, config, property) {
2897
- if (Array.isArray(header)) return header.map(function(headerElement) {
2898
- return rewriteCookieProperty(headerElement, config, property);
2899
- });
2900
- return header.replace(new RegExp(String.raw`(;\s*` + property + "=)([^;]+)", "i"), function(match, prefix, previousValue) {
2901
- let newValue;
2902
- if (previousValue in config) newValue = config[previousValue];
2903
- else {
2904
- if (!("*" in config)) return match;
2905
- newValue = config["*"];
2906
- }
2907
- return newValue ? prefix + newValue : "";
2908
- });
2909
- }
2910
- function hasPort(host) {
2911
- return host ? !!~host.indexOf(":") : false;
2912
- }
2913
- function requiresPort(_port, _protocol) {
2914
- const protocol = _protocol?.split(":")[0];
2915
- const port = +_port;
2916
- if (!port) return false;
2917
- switch(protocol){
2918
- case "http":
2919
- case "ws":
2920
- return 80 !== port;
2921
- case "https":
2922
- case "wss":
2923
- return 443 !== port;
2924
- case "ftp":
2925
- return 21 !== port;
2926
- case "gopher":
2927
- return 70 !== port;
2928
- case "file":
2929
- return false;
2930
- }
2931
- return 0 !== port;
2932
- }
2933
- function defineProxyMiddleware(m) {
2934
- return m;
2935
- }
2936
- function defineProxyOutgoingMiddleware(m) {
2937
- return m;
2938
- }
2939
- const redirectRegex = /^201|30([12378])$/;
2940
- const webOutgoingMiddleware = [
2941
- defineProxyOutgoingMiddleware((req, res, proxyRes)=>{
2942
- if ("1.0" === req.httpVersion || req.httpVersionMajor >= 2 || 204 === proxyRes.statusCode || 304 === proxyRes.statusCode) delete proxyRes.headers["transfer-encoding"];
2943
- }),
2944
- defineProxyOutgoingMiddleware((req, res, proxyRes)=>{
2945
- if ("1.0" === req.httpVersion) proxyRes.headers.connection = req.headers.connection || "close";
2946
- else if (req.httpVersionMajor < 2 && !proxyRes.headers.connection) proxyRes.headers.connection = req.headers.connection || "keep-alive";
2947
- else if (req.httpVersionMajor >= 2) delete proxyRes.headers.connection;
2948
- }),
2949
- defineProxyOutgoingMiddleware((req, res, proxyRes, options)=>{
2950
- if ((options.hostRewrite || options.autoRewrite || options.protocolRewrite) && proxyRes.headers.location && redirectRegex.test(String(proxyRes.statusCode))) {
2951
- const target = _toURL(options.target);
2952
- const u = new URL(proxyRes.headers.location, target);
2953
- if (target.host !== u.host) return;
2954
- if (options.hostRewrite) u.host = options.hostRewrite;
2955
- else if (options.autoRewrite) {
2956
- if (req.headers[":authority"]) u.host = req.headers[":authority"];
2957
- else if (req.headers.host) u.host = req.headers.host;
2958
- }
2959
- if (options.protocolRewrite) u.protocol = options.protocolRewrite;
2960
- proxyRes.headers.location = u.toString();
2961
- }
2962
- }),
2963
- defineProxyOutgoingMiddleware((req, res, proxyRes, options)=>{
2964
- const rewriteCookieDomainConfig = "string" == typeof options.cookieDomainRewrite ? {
2965
- "*": options.cookieDomainRewrite
2966
- } : options.cookieDomainRewrite;
2967
- const rewriteCookiePathConfig = "string" == typeof options.cookiePathRewrite ? {
2968
- "*": options.cookiePathRewrite
2969
- } : options.cookiePathRewrite;
2970
- const preserveHeaderKeyCase = options.preserveHeaderKeyCase;
2971
- let rawHeaderKeyMap;
2972
- const setHeader = function(key, header) {
2973
- if (void 0 === header || !String(key).trim()) return;
2974
- if (rewriteCookieDomainConfig && "set-cookie" === key.toLowerCase()) header = rewriteCookieProperty(header, rewriteCookieDomainConfig, "domain");
2975
- if (rewriteCookiePathConfig && "set-cookie" === key.toLowerCase()) header = rewriteCookieProperty(header, rewriteCookiePathConfig, "path");
2976
- try {
2977
- res.setHeader(String(key).trim(), header);
2978
- } catch {}
2979
- };
2980
- if (preserveHeaderKeyCase && void 0 !== proxyRes.rawHeaders) {
2981
- rawHeaderKeyMap = {};
2982
- for(let i = 0; i < proxyRes.rawHeaders.length; i += 2){
2983
- const key = proxyRes.rawHeaders[i];
2984
- rawHeaderKeyMap[key.toLowerCase()] = key;
2985
- }
2986
- }
2987
- for (let key of Object.keys(proxyRes.headers)){
2988
- const header = proxyRes.headers[key];
2989
- if (preserveHeaderKeyCase && rawHeaderKeyMap) key = rawHeaderKeyMap[key] || key;
2990
- setHeader(key, header);
2991
- }
2992
- }),
2993
- defineProxyOutgoingMiddleware((req, res, proxyRes)=>{
2994
- res.statusCode = proxyRes.statusCode;
2995
- if (proxyRes.statusMessage && req.httpVersionMajor < 2) res.statusMessage = proxyRes.statusMessage;
2996
- })
2997
- ];
2998
- function _toURL(target) {
2999
- if (target instanceof URL) return target;
3000
- if ("string" == typeof target) return new URL(target);
3001
- const protocol = target.protocol || "http:";
3002
- const host = target.host || target.hostname || "localhost";
3003
- const port = target.port;
3004
- return new URL(`${protocol}//${host}${port ? ":" + port : ""}`);
3005
- }
3006
- const nativeAgents = {
3007
- http: node_http,
3008
- https: node_https
3009
- };
3010
- const redirectStatuses = new Set([
3011
- 301,
3012
- 302,
3013
- 303,
3014
- 307,
3015
- 308
3016
- ]);
3017
- const webIncomingMiddleware = [
3018
- defineProxyMiddleware((req)=>{
3019
- if (("DELETE" === req.method || "OPTIONS" === req.method) && !req.headers["content-length"]) {
3020
- req.headers["content-length"] = "0";
3021
- delete req.headers["transfer-encoding"];
3022
- }
3023
- }),
3024
- defineProxyMiddleware((req, res, options)=>{
3025
- if (options.timeout) req.socket.setTimeout(options.timeout, ()=>{
3026
- req.socket.destroy();
3027
- });
3028
- }),
3029
- defineProxyMiddleware((req, res, options)=>{
3030
- if (!options.xfwd) return;
3031
- const encrypted = req.isSpdy || hasEncryptedConnection(req);
3032
- const values = {
3033
- for: req.connection.remoteAddress || req.socket.remoteAddress,
3034
- port: getPort(req),
3035
- proto: encrypted ? "https" : "http"
3036
- };
3037
- for (const header of [
3038
- "for",
3039
- "port",
3040
- "proto"
3041
- ]){
3042
- const key = "x-forwarded-" + header;
3043
- if (!req.headers[key]) req.headers[key] = values[header];
3044
- }
3045
- req.headers["x-forwarded-host"] = req.headers["x-forwarded-host"] || req.headers[":authority"] || req.headers.host || "";
3046
- }),
3047
- defineProxyMiddleware((req, res, options, server, head, callback)=>{
3048
- server.emit("start", req, res, options.target || options.forward);
3049
- const http = nativeAgents.http;
3050
- const https = nativeAgents.https;
3051
- const maxRedirects = "number" == typeof options.followRedirects ? options.followRedirects : options.followRedirects ? 5 : 0;
3052
- if (options.forward) {
3053
- const forwardReq = (isSSL.test(options.forward.protocol || "http") ? https : http).request(setupOutgoing(options.ssl || {}, options, req, "forward"));
3054
- const forwardError = createErrorHandler(forwardReq, options.forward);
3055
- req.on("error", forwardError);
3056
- forwardReq.on("error", forwardError);
3057
- (options.buffer || req).pipe(forwardReq);
3058
- if (!options.target) return void res.end();
3059
- }
3060
- const proxyReq = (isSSL.test(options.target.protocol || "http") ? https : http).request(setupOutgoing(options.ssl || {}, options, req));
3061
- proxyReq.on("socket", (_socket)=>{
3062
- if (server && !proxyReq.getHeader("expect")) server.emit("proxyReq", proxyReq, req, res, options);
3063
- });
3064
- if (options.proxyTimeout) proxyReq.setTimeout(options.proxyTimeout, function() {
3065
- proxyReq.destroy();
3066
- });
3067
- res.on("close", function() {
3068
- if (!res.writableFinished) proxyReq.destroy();
3069
- });
3070
- const proxyError = createErrorHandler(proxyReq, options.target);
3071
- req.on("error", proxyError);
3072
- proxyReq.on("error", proxyError);
3073
- function createErrorHandler(proxyReq, url) {
3074
- return function(err) {
3075
- if (!req.socket?.writable && "ECONNRESET" === err.code) {
3076
- server.emit("econnreset", err, req, res, url);
3077
- return proxyReq.destroy();
3078
- }
3079
- if (callback) callback(err, req, res, url);
3080
- else server.emit("error", err, req, res, url);
3081
- };
3082
- }
3083
- let bodyBuffer;
3084
- if (maxRedirects > 0) {
3085
- const chunks = [];
3086
- const source = options.buffer || req;
3087
- source.on("data", (chunk)=>{
3088
- chunks.push("string" == typeof chunk ? Buffer.from(chunk) : chunk);
3089
- proxyReq.write(chunk);
3090
- });
3091
- source.on("end", ()=>{
3092
- bodyBuffer = Buffer.concat(chunks);
3093
- proxyReq.end();
3094
- });
3095
- source.on("error", (err)=>{
3096
- proxyReq.destroy(err);
3097
- });
3098
- } else proxyReq.on("socket", (socket)=>{
3099
- if (socket.pending) socket.on("connect", ()=>(options.buffer || req).pipe(proxyReq));
3100
- else (options.buffer || req).pipe(proxyReq);
3101
- });
3102
- function handleResponse(proxyRes, redirectCount, currentUrl) {
3103
- const statusCode = proxyRes.statusCode;
3104
- if (maxRedirects > 0 && redirectStatuses.has(statusCode) && redirectCount < maxRedirects && proxyRes.headers.location) {
3105
- proxyRes.resume();
3106
- const location = new URL(proxyRes.headers.location, currentUrl);
3107
- const preserveMethod = 307 === statusCode || 308 === statusCode;
3108
- const redirectMethod = preserveMethod ? req.method || "GET" : "GET";
3109
- const isHTTPS = isSSL.test(location.protocol);
3110
- const agent = isHTTPS ? https : http;
3111
- const redirectHeaders = {
3112
- ...req.headers
3113
- };
3114
- if (options.headers) Object.assign(redirectHeaders, options.headers);
3115
- redirectHeaders.host = location.host;
3116
- if (location.host !== currentUrl.host) {
3117
- delete redirectHeaders.authorization;
3118
- delete redirectHeaders.cookie;
3119
- }
3120
- if (!preserveMethod) {
3121
- delete redirectHeaders["content-length"];
3122
- delete redirectHeaders["content-type"];
3123
- delete redirectHeaders["transfer-encoding"];
3124
- }
3125
- const redirectOpts = {
3126
- hostname: location.hostname,
3127
- port: location.port || (isHTTPS ? 443 : 80),
3128
- path: location.pathname + location.search,
3129
- method: redirectMethod,
3130
- headers: redirectHeaders,
3131
- agent: options.agent || false
3132
- };
3133
- if (isHTTPS) redirectOpts.rejectUnauthorized = void 0 === options.secure ? true : options.secure;
3134
- const redirectReq = agent.request(redirectOpts);
3135
- if (server && !redirectReq.getHeader("expect")) server.emit("proxyReq", redirectReq, req, res, options);
3136
- if (options.proxyTimeout) redirectReq.setTimeout(options.proxyTimeout, ()=>{
3137
- redirectReq.destroy();
3138
- });
3139
- const redirectError = createErrorHandler(redirectReq, location);
3140
- redirectReq.on("error", redirectError);
3141
- redirectReq.on("response", (nextRes)=>{
3142
- handleResponse(nextRes, redirectCount + 1, location);
3143
- });
3144
- if (preserveMethod && bodyBuffer && bodyBuffer.length > 0) redirectReq.end(bodyBuffer);
3145
- else redirectReq.end();
3146
- return;
3147
- }
3148
- if (server) server.emit("proxyRes", proxyRes, req, res);
3149
- if (!res.headersSent && !options.selfHandleResponse) {
3150
- for (const pass of webOutgoingMiddleware)if (pass(req, res, proxyRes, options)) break;
3151
- }
3152
- if (res.finished) {
3153
- if (server) server.emit("end", req, res, proxyRes);
3154
- } else {
3155
- res.on("close", function() {
3156
- proxyRes.destroy();
3157
- });
3158
- proxyRes.on("close", function() {
3159
- if (!proxyRes.complete && !res.destroyed) res.destroy();
3160
- });
3161
- proxyRes.on("error", function(err) {
3162
- if (!res.destroyed) res.destroy(err);
3163
- if (server.listenerCount("error") > 0) server.emit("error", err, req, res, currentUrl);
3164
- });
3165
- proxyRes.on("end", function() {
3166
- if (server) server.emit("end", req, res, proxyRes);
3167
- });
3168
- if (!options.selfHandleResponse) proxyRes.pipe(res);
3169
- }
3170
- }
3171
- proxyReq.on("response", function(proxyRes) {
3172
- handleResponse(proxyRes, 0, options.target);
3173
- });
3174
- })
3175
- ];
3176
- const websocketIncomingMiddleware = [
3177
- defineProxyMiddleware((req, socket)=>{
3178
- if ("GET" !== req.method || !req.headers.upgrade) {
3179
- socket.destroy();
3180
- return true;
3181
- }
3182
- if ("websocket" !== req.headers.upgrade.toLowerCase()) {
3183
- socket.destroy();
3184
- return true;
3185
- }
3186
- }),
3187
- defineProxyMiddleware((req, socket, options)=>{
3188
- if (!options.xfwd) return;
3189
- const values = {
3190
- for: req.connection.remoteAddress || req.socket.remoteAddress,
3191
- port: getPort(req),
3192
- proto: hasEncryptedConnection(req) ? "wss" : "ws"
3193
- };
3194
- for (const header of [
3195
- "for",
3196
- "port",
3197
- "proto"
3198
- ]){
3199
- const key = "x-forwarded-" + header;
3200
- if (!req.headers[key]) req.headers[key] = values[header];
3201
- }
3202
- }),
3203
- defineProxyMiddleware((req, socket, options, server, head, callback)=>{
3204
- const createHttpHeader = function(line, headers) {
3205
- return Object.keys(headers).reduce(function(head, key) {
3206
- const value = headers[key];
3207
- if (!Array.isArray(value)) {
3208
- head.push(key + ": " + value);
3209
- return head;
3210
- }
3211
- for (const element of value)head.push(key + ": " + element);
3212
- return head;
3213
- }, [
3214
- line
3215
- ]).join("\r\n") + "\r\n\r\n";
3216
- };
3217
- setupSocket(socket);
3218
- if (head && head.length > 0) socket.unshift(head);
3219
- socket.on("error", onSocketError);
3220
- const proxyReq = (isSSL.test(options.target.protocol || "http") ? node_https : node_http).request(setupOutgoing(options.ssl || {}, options, req));
3221
- if (server) server.emit("proxyReqWs", proxyReq, req, socket, options, head);
3222
- proxyReq.on("error", onOutgoingError);
3223
- proxyReq.on("response", function(res) {
3224
- if (!res.upgrade) if (!socket.destroyed && socket.writable) {
3225
- socket.write(createHttpHeader("HTTP/" + res.httpVersion + " " + res.statusCode + " " + res.statusMessage, res.headers));
3226
- res.on("error", onOutgoingError);
3227
- res.pipe(socket);
3228
- } else res.resume();
3229
- });
3230
- proxyReq.on("upgrade", function(proxyRes, proxySocket, proxyHead) {
3231
- proxySocket.on("error", onOutgoingError);
3232
- proxySocket.on("end", function() {
3233
- server.emit("close", proxyRes, proxySocket, proxyHead);
3234
- });
3235
- socket.removeListener("error", onSocketError);
3236
- socket.on("error", function() {
3237
- proxySocket.end();
3238
- });
3239
- setupSocket(proxySocket);
3240
- if (proxyHead && proxyHead.length > 0) proxySocket.unshift(proxyHead);
3241
- socket.write(createHttpHeader("HTTP/1.1 101 Switching Protocols", proxyRes.headers));
3242
- proxySocket.pipe(socket).pipe(proxySocket);
3243
- server.emit("open", proxySocket);
3244
- server.emit("proxySocket", proxySocket);
3245
- });
3246
- proxyReq.end();
3247
- function onSocketError(err) {
3248
- if (callback) callback(err, req, socket);
3249
- else server.emit("error", err, req, socket);
3250
- proxyReq.destroy();
3251
- }
3252
- function onOutgoingError(err) {
3253
- if (callback) callback(err, req, socket);
3254
- else server.emit("error", err, req, socket);
3255
- socket.end();
3256
- }
3257
- })
3258
- ];
3259
- var ProxyServer = class extends EventEmitter {
3260
- _server;
3261
- _webPasses = [
3262
- ...webIncomingMiddleware
3263
- ];
3264
- _wsPasses = [
3265
- ...websocketIncomingMiddleware
3266
- ];
3267
- options;
3268
- web;
3269
- ws;
3270
- constructor(options = {}){
3271
- super();
3272
- this.options = options || {};
3273
- this.options.prependPath = false !== options.prependPath;
3274
- this.web = _createProxyFn("web", this);
3275
- this.ws = _createProxyFn("ws", this);
3276
- }
3277
- listen(port, hostname) {
3278
- const closure = (req, res)=>this.web(req, res);
3279
- if (this.options.http2) {
3280
- if (!this.options.ssl) throw new Error("HTTP/2 requires ssl option");
3281
- this._server = node_http2.createSecureServer({
3282
- ...this.options.ssl,
3283
- allowHTTP1: true
3284
- }, closure);
3285
- } else if (this.options.ssl) this._server = node_https.createServer(this.options.ssl, closure);
3286
- else this._server = node_http.createServer(closure);
3287
- if (this.options.ws) this._server.on("upgrade", (req, socket, head)=>{
3288
- this.ws(req, socket, this.options, head).catch(()=>{});
3289
- });
3290
- this._server.listen(port, hostname);
3291
- return this;
3292
- }
3293
- close(callback) {
3294
- if (this._server) this._server.close((...args)=>{
3295
- this._server = void 0;
3296
- if (callback) Reflect.apply(callback, void 0, args);
3297
- });
3298
- }
3299
- before(type, passName, pass) {
3300
- if ("ws" !== type && "web" !== type) throw new Error("type must be `web` or `ws`");
3301
- const passes = this._getPasses(type);
3302
- let i = false;
3303
- for (const [idx, v] of passes.entries())if (v.name === passName) i = idx;
3304
- if (false === i) throw new Error("No such pass");
3305
- passes.splice(i, 0, pass);
3306
- }
3307
- after(type, passName, pass) {
3308
- if ("ws" !== type && "web" !== type) throw new Error("type must be `web` or `ws`");
3309
- const passes = this._getPasses(type);
3310
- let i = false;
3311
- for (const [idx, v] of passes.entries())if (v.name === passName) i = idx;
3312
- if (false === i) throw new Error("No such pass");
3313
- passes.splice(i++, 0, pass);
3314
- }
3315
- _getPasses(type) {
3316
- return "ws" === type ? this._wsPasses : this._webPasses;
3317
- }
3318
- };
3319
- function createProxyServer(options = {}) {
3320
- return new ProxyServer(options);
3321
- }
3322
- function _createProxyFn(type, server) {
3323
- return function(req, res, opts, head) {
3324
- const requestOptions = {
3325
- ...opts,
3326
- ...server.options
3327
- };
3328
- for (const key of [
3329
- "target",
3330
- "forward"
3331
- ])if ("string" == typeof requestOptions[key]) requestOptions[key] = new URL(requestOptions[key]);
3332
- if (!requestOptions.target && !requestOptions.forward) {
3333
- this.emit("error", /* @__PURE__ */ new Error("Must provide a proper URL as target"));
3334
- return Promise.resolve();
3335
- }
3336
- let _resolve;
3337
- let _reject;
3338
- const callbackPromise = new Promise((resolve, reject)=>{
3339
- _resolve = resolve;
3340
- _reject = reject;
3341
- });
3342
- res.on("close", ()=>{
3343
- _resolve();
3344
- });
3345
- res.on("error", (error)=>{
3346
- _reject(error);
3347
- });
3348
- for (const pass of server._getPasses(type)){
3349
- let stop;
3350
- try {
3351
- stop = pass(req, res, requestOptions, server, head, (error)=>{
3352
- if (server.listenerCount("error") > 0) {
3353
- server.emit("error", error, req, res);
3354
- _resolve();
3355
- } else _reject(error);
3356
- });
3357
- } catch (error) {
3358
- if (server.listenerCount("error") > 0) {
3359
- server.emit("error", error, req, res);
3360
- _resolve();
3361
- } else _reject(error);
3362
- break;
3363
- }
3364
- if (stop) {
3365
- _resolve();
3366
- break;
3367
- }
3368
- }
3369
- return callbackPromise;
3370
- };
3371
- }
3372
- new Set([
3373
- 301,
3374
- 302,
3375
- 303,
3376
- 307,
3377
- 308
3378
- ]);
3379
- var errors_ERRORS;
3380
- (function(ERRORS) {
3381
- ERRORS["ERR_CONFIG_FACTORY_TARGET_MISSING"] = "[HPM] Missing \"target\" option. Example: {target: \"http://www.example.org\"}";
3382
- ERRORS["ERR_CONTEXT_MATCHER_GENERIC"] = "[HPM] Invalid pathFilter. Expecting something like: \"/api\" or [\"/api\", \"/ajax\"]";
3383
- ERRORS["ERR_CONTEXT_MATCHER_INVALID_ARRAY"] = "[HPM] Invalid pathFilter. Plain paths (e.g. \"/api\") can not be mixed with globs (e.g. \"/api/**\"). Expecting something like: [\"/api\", \"/ajax\"] or [\"/api/**\", \"!**.html\"].";
3384
- ERRORS["ERR_PATH_REWRITER_CONFIG"] = "[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function";
3385
- })(errors_ERRORS || (errors_ERRORS = {}));
3386
- function verifyConfig(options) {
3387
- if (!options.target && !options.router) throw new Error(errors_ERRORS.ERR_CONFIG_FACTORY_TARGET_MISSING);
3388
- }
3389
- const src = __webpack_require__("./node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js");
3390
- const Debug = src('http-proxy-middleware');
3391
- const debug = Debug.extend('debug-proxy-errors-plugin');
3392
- const debugProxyErrorsPlugin = (proxyServer)=>{
3393
- proxyServer.on('error', (error, req, res, target)=>{
3394
- debug(`http-proxy error event: \n%O`, error);
3395
- });
3396
- proxyServer.on('proxyReq', (proxyReq, req, socket)=>{
3397
- socket.on('error', (error)=>{
3398
- debug('Socket error in proxyReq event: \n%O', error);
3399
- });
3400
- });
3401
- proxyServer.on('proxyRes', (proxyRes, req, res)=>{
3402
- res.on('close', ()=>{
3403
- if (!res.writableEnded) {
3404
- debug('Destroying proxyRes in proxyRes close event');
3405
- proxyRes.destroy();
3406
- }
3407
- });
3408
- });
3409
- proxyServer.on('proxyReqWs', (proxyReq, req, socket)=>{
3410
- socket.on('error', (error)=>{
3411
- debug('Socket error in proxyReqWs event: \n%O', error);
3412
- });
3413
- });
3414
- proxyServer.on('open', (proxySocket)=>{
3415
- proxySocket.on('error', (error)=>{
3416
- debug('Socket error in open event: \n%O', error);
3417
- });
3418
- });
3419
- proxyServer.on('close', (req, socket, head)=>{
3420
- socket.on('error', (error)=>{
3421
- debug('Socket error in close event: \n%O', error);
3422
- });
3423
- });
3424
- proxyServer.on('econnreset', (error, req, res, target)=>{
3425
- debug(`http-proxy econnreset event: \n%O`, error);
3426
- });
3427
- };
3428
- function getStatusCode(errorCode) {
3429
- let statusCode;
3430
- if (/HPE_INVALID/.test(errorCode)) statusCode = 502;
3431
- else switch(errorCode){
3432
- case 'ECONNRESET':
3433
- case 'ENOTFOUND':
3434
- case 'ECONNREFUSED':
3435
- case 'ETIMEDOUT':
3436
- statusCode = 504;
3437
- break;
3438
- default:
3439
- statusCode = 500;
3440
- break;
3441
- }
3442
- return statusCode;
3443
- }
3444
- function sanitize(input) {
3445
- return input?.replace(/[<>]/g, (i)=>encodeURIComponent(i)) ?? '';
3446
- }
3447
- function isResponseLike(obj) {
3448
- return obj && 'function' == typeof obj.writeHead;
3449
- }
3450
- function isSocketLike(obj) {
3451
- return obj && 'function' == typeof obj.write && !('writeHead' in obj);
3452
- }
3453
- const errorResponsePlugin = (proxyServer, options)=>{
3454
- proxyServer.on('error', (err, req, res, target)=>{
3455
- if (!req || !res) throw err;
3456
- if (isResponseLike(res)) {
3457
- if (!res.headersSent) {
3458
- const statusCode = getStatusCode(err.code);
3459
- res.writeHead(statusCode);
3460
- }
3461
- const host = req.headers && req.headers.host;
3462
- res.end(`Error occurred while trying to proxy: ${sanitize(host)}${sanitize(req.url)}`);
3463
- } else if (isSocketLike(res)) res.destroy();
3464
- });
3465
- };
3466
- const noopLogger = {
3467
- info: ()=>{},
3468
- warn: ()=>{},
3469
- error: ()=>{}
3470
- };
3471
- function logger_getLogger(options) {
3472
- return options.logger || noopLogger;
3473
- }
3474
- function logger_plugin_getPort(sockets) {
3475
- return Object.keys(sockets || {})?.[0]?.split(':')[1];
3476
- }
3477
- const loggerPlugin = (proxyServer, options)=>{
3478
- const logger = logger_getLogger(options);
3479
- proxyServer.on('error', (err, req, res, target)=>{
3480
- const hostname = req?.headers?.host;
3481
- const requestHref = `${hostname}${req?.url}`;
3482
- const targetHref = `${target?.href}`;
3483
- const errorMessage = '[HPM] Error occurred while proxying request %s to %s [%s] (%s)';
3484
- const errReference = 'https://nodejs.org/api/errors.html#errors_common_system_errors';
3485
- logger.error(errorMessage, requestHref, targetHref, err.code || err, errReference);
3486
- });
3487
- proxyServer.on('proxyRes', (proxyRes, req, res)=>{
3488
- const originalUrl = req.originalUrl ?? `${req.baseUrl || ''}${req.url}`;
3489
- let target;
3490
- try {
3491
- const port = logger_plugin_getPort(proxyRes.req?.agent?.sockets);
3492
- const obj = {
3493
- protocol: proxyRes.req.protocol,
3494
- host: proxyRes.req.host,
3495
- pathname: proxyRes.req.path
3496
- };
3497
- target = new external_node_url_URL(`${obj.protocol}//${obj.host}${obj.pathname}`);
3498
- if (port) target.port = port;
3499
- } catch (err) {
3500
- target = new external_node_url_URL(options.target);
3501
- target.pathname = proxyRes.req.path;
3502
- }
3503
- const targetUrl = target.toString();
3504
- const exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
3505
- logger.info(exchange);
3506
- });
3507
- proxyServer.on('open', (socket)=>{
3508
- logger.info('[HPM] Client connected: %o', socket.address());
3509
- });
3510
- proxyServer.on('close', (req, proxySocket, proxyHead)=>{
3511
- logger.info('[HPM] Client disconnected: %o', proxySocket.address());
3512
- });
3513
- };
3514
- function function_getFunctionName(fn) {
3515
- return fn.name || '[anonymous Function]';
3516
- }
3517
- const proxy_events_debug = Debug.extend('proxy-events-plugin');
3518
- const proxyEventsPlugin = (proxyServer, options)=>{
3519
- if (!options.on) return;
3520
- let eventName;
3521
- for(eventName in options.on)if (Object.prototype.hasOwnProperty.call(options.on, eventName)) {
3522
- const handler = options.on[eventName];
3523
- if (!handler) continue;
3524
- proxy_events_debug(`register event handler: "${eventName}" -> "${function_getFunctionName(handler)}"`);
3525
- proxyServer.on(eventName, handler);
3526
- }
3527
- };
3528
- function getPlugins(options) {
3529
- const maybeErrorResponsePlugin = options.on?.error ? [] : [
3530
- errorResponsePlugin
3531
- ];
3532
- const defaultPlugins = options.ejectPlugins ? [] : [
3533
- debugProxyErrorsPlugin,
3534
- proxyEventsPlugin,
3535
- loggerPlugin,
3536
- ...maybeErrorResponsePlugin
3537
- ];
3538
- const userPlugins = options.plugins ?? [];
3539
- return [
3540
- ...defaultPlugins,
3541
- ...userPlugins
3542
- ];
3543
- }
3544
- const is_glob = __webpack_require__("./node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js");
3545
- const micromatch = __webpack_require__("./node_modules/.pnpm/micromatch@4.0.8/node_modules/micromatch/index.js");
3546
- function matchPathFilter(pathFilter = '/', uri, req) {
3547
- if (isStringPath(pathFilter)) return matchSingleStringPath(pathFilter, uri);
3548
- if (isGlobPath(pathFilter)) return matchSingleGlobPath(pathFilter, uri);
3549
- if (Array.isArray(pathFilter)) {
3550
- if (pathFilter.every(isStringPath)) return matchMultiPath(pathFilter, uri);
3551
- if (pathFilter.every(isGlobPath)) return matchMultiGlobPath(pathFilter, uri);
3552
- throw new Error(errors_ERRORS.ERR_CONTEXT_MATCHER_INVALID_ARRAY);
3553
- }
3554
- if ('function' == typeof pathFilter) {
3555
- const pathname = getUrlPathName(uri);
3556
- return pathFilter(pathname, req);
3557
- }
3558
- throw new Error(errors_ERRORS.ERR_CONTEXT_MATCHER_GENERIC);
3559
- }
3560
- function matchSingleStringPath(pathFilter, uri) {
3561
- const pathname = getUrlPathName(uri);
3562
- return pathname?.indexOf(pathFilter) === 0;
3563
- }
3564
- function matchSingleGlobPath(pattern, uri) {
3565
- const pathname = getUrlPathName(uri);
3566
- const matches = micromatch([
3567
- pathname
3568
- ], pattern);
3569
- return matches && matches.length > 0;
3570
- }
3571
- function matchMultiGlobPath(patternList, uri) {
3572
- return matchSingleGlobPath(patternList, uri);
3573
- }
3574
- function matchMultiPath(pathFilterList, uri) {
3575
- let isMultiPath = false;
3576
- for (const context of pathFilterList)if (matchSingleStringPath(context, uri)) {
3577
- isMultiPath = true;
3578
- break;
3579
- }
3580
- return isMultiPath;
3581
- }
3582
- function getUrlPathName(uri) {
3583
- return uri && new URL(uri, 'http://0.0.0.0').pathname;
3584
- }
3585
- function isStringPath(pathFilter) {
3586
- return 'string' == typeof pathFilter && !is_glob(pathFilter);
3587
- }
3588
- function isGlobPath(pathFilter) {
3589
- return is_glob(pathFilter);
3590
- }
3591
- function isPlainObject(value) {
3592
- if ('object' != typeof value || null === value) return false;
3593
- const prototype = Object.getPrototypeOf(value);
3594
- return (null === prototype || prototype === Object.prototype || null === Object.getPrototypeOf(prototype)) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
3595
- }
3596
- const path_rewriter_debug = Debug.extend('path-rewriter');
3597
- function createPathRewriter(rewriteConfig) {
3598
- let rulesCache;
3599
- if (!isValidRewriteConfig(rewriteConfig)) return;
3600
- if ('function' == typeof rewriteConfig) {
3601
- const customRewriteFn = rewriteConfig;
3602
- return customRewriteFn;
3603
- }
3604
- rulesCache = parsePathRewriteRules(rewriteConfig);
3605
- return rewritePath;
3606
- function rewritePath(path) {
3607
- let result = path;
3608
- for (const rule of rulesCache)if (rule.regex.test(path)) {
3609
- result = result.replace(rule.regex, rule.value);
3610
- path_rewriter_debug('rewriting path from "%s" to "%s"', path, result);
3611
- break;
3612
- }
3613
- return result;
3614
- }
3615
- }
3616
- function isValidRewriteConfig(rewriteConfig) {
3617
- if ('function' == typeof rewriteConfig) return true;
3618
- if (isPlainObject(rewriteConfig)) return 0 !== Object.keys(rewriteConfig).length;
3619
- if (null == rewriteConfig) return false;
3620
- throw new Error(errors_ERRORS.ERR_PATH_REWRITER_CONFIG);
3621
- }
3622
- function parsePathRewriteRules(rewriteConfig) {
3623
- const rules = [];
3624
- if (isPlainObject(rewriteConfig)) for (const [key, value] of Object.entries(rewriteConfig)){
3625
- rules.push({
3626
- regex: new RegExp(key),
3627
- value: value
3628
- });
3629
- path_rewriter_debug('rewrite rule created: "%s" ~> "%s"', key, value);
3630
- }
3631
- return rules;
3632
- }
3633
- const router_debug = Debug.extend('router');
3634
- async function getTarget(req, config) {
3635
- let newTarget;
3636
- const router = config.router;
3637
- if (isPlainObject(router)) newTarget = getTargetFromProxyTable(req, router);
3638
- else if ('function' == typeof router) newTarget = await router(req);
3639
- return newTarget;
3640
- }
3641
- function getTargetFromProxyTable(req, table) {
3642
- let result;
3643
- const host = req.headers.host;
3644
- const path = req.url;
3645
- const hostAndPath = host + path;
3646
- for (const [key, value] of Object.entries(table))if (containsPath(key)) {
3647
- if (hostAndPath.indexOf(key) > -1) {
3648
- result = value;
3649
- router_debug('match: "%s" -> "%s"', key, result);
3650
- break;
3651
- }
3652
- } else if (key === host) {
3653
- result = value;
3654
- router_debug('match: "%s" -> "%s"', host, result);
3655
- break;
3656
- }
3657
- return result;
3658
- }
3659
- function containsPath(v) {
3660
- return v.indexOf('/') > -1;
3661
- }
3662
- class HttpProxyMiddleware {
3663
- wsInternalSubscribed = false;
3664
- serverOnCloseSubscribed = false;
3665
- proxyOptions;
3666
- proxy;
3667
- pathRewriter;
3668
- logger;
3669
- constructor(options){
3670
- verifyConfig(options);
3671
- this.proxyOptions = options;
3672
- this.logger = logger_getLogger(options);
3673
- Debug("create proxy server");
3674
- this.proxy = createProxyServer({});
3675
- this.registerPlugins(this.proxy, this.proxyOptions);
3676
- this.pathRewriter = createPathRewriter(this.proxyOptions.pathRewrite);
3677
- this.middleware.upgrade = (req, socket, head)=>{
3678
- if (!this.wsInternalSubscribed) this.handleUpgrade(req, socket, head);
3679
- };
3680
- }
3681
- middleware = async (req, res, next)=>{
3682
- if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
3683
- let activeProxyOptions;
3684
- try {
3685
- activeProxyOptions = await this.prepareProxyRequest(req);
3686
- if (!activeProxyOptions.target && !activeProxyOptions.forward) throw new Error('Must provide a proper URL as target');
3687
- } catch (err) {
3688
- next?.(err);
3689
- return;
3690
- }
3691
- try {
3692
- Debug("proxy request to target: %O", activeProxyOptions.target);
3693
- await this.proxy.web(req, res, activeProxyOptions);
3694
- } catch (err) {
3695
- this.proxy.emit('error', err, req, res, activeProxyOptions.target);
3696
- next?.(err);
3697
- }
3698
- } else next?.();
3699
- const server = req.socket?.server;
3700
- if (server && !this.serverOnCloseSubscribed) {
3701
- server.on('close', ()=>{
3702
- Debug('server close signal received: closing proxy server');
3703
- this.proxy.close(()=>{
3704
- Debug('proxy server closed');
3705
- });
3706
- });
3707
- this.serverOnCloseSubscribed = true;
3708
- }
3709
- if (true === this.proxyOptions.ws && server) this.catchUpgradeRequest(server);
3710
- };
3711
- registerPlugins(proxy, options) {
3712
- const plugins = getPlugins(options);
3713
- plugins.forEach((plugin)=>{
3714
- Debug(`register plugin: "${function_getFunctionName(plugin)}"`);
3715
- plugin(proxy, options);
3716
- });
3717
- }
3718
- catchUpgradeRequest = (server)=>{
3719
- if (!this.wsInternalSubscribed) {
3720
- Debug('subscribing to server upgrade event');
3721
- server.on('upgrade', this.handleUpgrade);
3722
- this.wsInternalSubscribed = true;
3723
- }
3724
- };
3725
- handleUpgrade = async (req, socket, head)=>{
3726
- try {
3727
- if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
3728
- const proxiedReq = req;
3729
- const activeProxyOptions = await this.prepareProxyRequest(proxiedReq);
3730
- await this.proxy.ws(proxiedReq, socket, activeProxyOptions, head);
3731
- Debug('server upgrade event received. Proxying WebSocket');
3732
- }
3733
- } catch (err) {
3734
- this.proxy.emit('error', err, req, socket);
3735
- }
3736
- };
3737
- shouldProxy = (pathFilter, req)=>{
3738
- try {
3739
- return matchPathFilter(pathFilter, req.url, req);
3740
- } catch (err) {
3741
- Debug('Error: matchPathFilter() called with request url: ', `"${req.url}"`);
3742
- this.logger.error(err);
3743
- return false;
3744
- }
3745
- };
3746
- prepareProxyRequest = async (req)=>{
3747
- const newProxyOptions = Object.assign({}, this.proxyOptions);
3748
- await this.applyRouter(req, newProxyOptions);
3749
- await this.applyPathRewrite(req, this.pathRewriter);
3750
- return newProxyOptions;
3751
- };
3752
- applyRouter = async (req, options)=>{
3753
- let newTarget;
3754
- if (options.router) {
3755
- newTarget = await getTarget(req, options);
3756
- if (newTarget) {
3757
- Debug('router new target: "%s"', newTarget);
3758
- options.target = newTarget;
3759
- }
3760
- }
3761
- };
3762
- applyPathRewrite = async (req, pathRewriter)=>{
3763
- if (pathRewriter) {
3764
- const path = await pathRewriter(req.url, req);
3765
- if ('string' == typeof path) {
3766
- Debug('pathRewrite new path: %s', path);
3767
- req.url = path;
3768
- } else Debug('pathRewrite: no rewritten path found: %s', req.url);
3769
- }
3770
- };
3771
- }
3772
- function factory_createProxyMiddleware(options) {
3773
- const { middleware } = new HttpProxyMiddleware(options);
3774
- return middleware;
3775
- }
3776
- Debug.extend('response-interceptor');
3777
- export { factory_createProxyMiddleware as createProxyMiddleware };