@soda-gql/codegen 0.11.13 → 0.11.14

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.
@@ -0,0 +1,2712 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+
28
+ //#endregion
29
+ let graphql = require("graphql");
30
+
31
+ //#region node_modules/picomatch/lib/constants.js
32
+ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
33
+ const WIN_SLASH = "\\\\/";
34
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
35
+ /**
36
+ * Posix glob regex
37
+ */
38
+ const DOT_LITERAL = "\\.";
39
+ const PLUS_LITERAL = "\\+";
40
+ const QMARK_LITERAL = "\\?";
41
+ const SLASH_LITERAL = "\\/";
42
+ const ONE_CHAR = "(?=.)";
43
+ const QMARK = "[^/]";
44
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
45
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
46
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
47
+ const NO_DOT = `(?!${DOT_LITERAL})`;
48
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
49
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
50
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
51
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
52
+ const STAR = `${QMARK}*?`;
53
+ const SEP = "/";
54
+ const POSIX_CHARS = {
55
+ DOT_LITERAL,
56
+ PLUS_LITERAL,
57
+ QMARK_LITERAL,
58
+ SLASH_LITERAL,
59
+ ONE_CHAR,
60
+ QMARK,
61
+ END_ANCHOR,
62
+ DOTS_SLASH,
63
+ NO_DOT,
64
+ NO_DOTS,
65
+ NO_DOT_SLASH,
66
+ NO_DOTS_SLASH,
67
+ QMARK_NO_DOT,
68
+ STAR,
69
+ START_ANCHOR,
70
+ SEP
71
+ };
72
+ /**
73
+ * Windows glob regex
74
+ */
75
+ const WINDOWS_CHARS = {
76
+ ...POSIX_CHARS,
77
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
78
+ QMARK: WIN_NO_SLASH,
79
+ STAR: `${WIN_NO_SLASH}*?`,
80
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
81
+ NO_DOT: `(?!${DOT_LITERAL})`,
82
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
83
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
84
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
85
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
86
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
87
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
88
+ SEP: "\\"
89
+ };
90
+ /**
91
+ * POSIX Bracket Regex
92
+ */
93
+ const POSIX_REGEX_SOURCE$1 = {
94
+ alnum: "a-zA-Z0-9",
95
+ alpha: "a-zA-Z",
96
+ ascii: "\\x00-\\x7F",
97
+ blank: " \\t",
98
+ cntrl: "\\x00-\\x1F\\x7F",
99
+ digit: "0-9",
100
+ graph: "\\x21-\\x7E",
101
+ lower: "a-z",
102
+ print: "\\x20-\\x7E ",
103
+ punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
104
+ space: " \\t\\r\\n\\v\\f",
105
+ upper: "A-Z",
106
+ word: "A-Za-z0-9_",
107
+ xdigit: "A-Fa-f0-9"
108
+ };
109
+ module.exports = {
110
+ MAX_LENGTH: 1024 * 64,
111
+ POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
112
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
113
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
114
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
115
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
116
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
117
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
118
+ REPLACEMENTS: {
119
+ __proto__: null,
120
+ "***": "*",
121
+ "**/**": "**",
122
+ "**/**/**": "**"
123
+ },
124
+ CHAR_0: 48,
125
+ CHAR_9: 57,
126
+ CHAR_UPPERCASE_A: 65,
127
+ CHAR_LOWERCASE_A: 97,
128
+ CHAR_UPPERCASE_Z: 90,
129
+ CHAR_LOWERCASE_Z: 122,
130
+ CHAR_LEFT_PARENTHESES: 40,
131
+ CHAR_RIGHT_PARENTHESES: 41,
132
+ CHAR_ASTERISK: 42,
133
+ CHAR_AMPERSAND: 38,
134
+ CHAR_AT: 64,
135
+ CHAR_BACKWARD_SLASH: 92,
136
+ CHAR_CARRIAGE_RETURN: 13,
137
+ CHAR_CIRCUMFLEX_ACCENT: 94,
138
+ CHAR_COLON: 58,
139
+ CHAR_COMMA: 44,
140
+ CHAR_DOT: 46,
141
+ CHAR_DOUBLE_QUOTE: 34,
142
+ CHAR_EQUAL: 61,
143
+ CHAR_EXCLAMATION_MARK: 33,
144
+ CHAR_FORM_FEED: 12,
145
+ CHAR_FORWARD_SLASH: 47,
146
+ CHAR_GRAVE_ACCENT: 96,
147
+ CHAR_HASH: 35,
148
+ CHAR_HYPHEN_MINUS: 45,
149
+ CHAR_LEFT_ANGLE_BRACKET: 60,
150
+ CHAR_LEFT_CURLY_BRACE: 123,
151
+ CHAR_LEFT_SQUARE_BRACKET: 91,
152
+ CHAR_LINE_FEED: 10,
153
+ CHAR_NO_BREAK_SPACE: 160,
154
+ CHAR_PERCENT: 37,
155
+ CHAR_PLUS: 43,
156
+ CHAR_QUESTION_MARK: 63,
157
+ CHAR_RIGHT_ANGLE_BRACKET: 62,
158
+ CHAR_RIGHT_CURLY_BRACE: 125,
159
+ CHAR_RIGHT_SQUARE_BRACKET: 93,
160
+ CHAR_SEMICOLON: 59,
161
+ CHAR_SINGLE_QUOTE: 39,
162
+ CHAR_SPACE: 32,
163
+ CHAR_TAB: 9,
164
+ CHAR_UNDERSCORE: 95,
165
+ CHAR_VERTICAL_LINE: 124,
166
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
167
+ extglobChars(chars) {
168
+ return {
169
+ "!": {
170
+ type: "negate",
171
+ open: "(?:(?!(?:",
172
+ close: `))${chars.STAR})`
173
+ },
174
+ "?": {
175
+ type: "qmark",
176
+ open: "(?:",
177
+ close: ")?"
178
+ },
179
+ "+": {
180
+ type: "plus",
181
+ open: "(?:",
182
+ close: ")+"
183
+ },
184
+ "*": {
185
+ type: "star",
186
+ open: "(?:",
187
+ close: ")*"
188
+ },
189
+ "@": {
190
+ type: "at",
191
+ open: "(?:",
192
+ close: ")"
193
+ }
194
+ };
195
+ },
196
+ globChars(win32) {
197
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
198
+ }
199
+ };
200
+ }));
201
+
202
+ //#endregion
203
+ //#region node_modules/picomatch/lib/utils.js
204
+ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
205
+ const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
206
+ exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
207
+ exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
208
+ exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
209
+ exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
210
+ exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
211
+ exports.isWindows = () => {
212
+ if (typeof navigator !== "undefined" && navigator.platform) {
213
+ const platform = navigator.platform.toLowerCase();
214
+ return platform === "win32" || platform === "windows";
215
+ }
216
+ if (typeof process !== "undefined" && process.platform) {
217
+ return process.platform === "win32";
218
+ }
219
+ return false;
220
+ };
221
+ exports.removeBackslashes = (str) => {
222
+ return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
223
+ return match === "\\" ? "" : match;
224
+ });
225
+ };
226
+ exports.escapeLast = (input, char, lastIdx) => {
227
+ const idx = input.lastIndexOf(char, lastIdx);
228
+ if (idx === -1) return input;
229
+ if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
230
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
231
+ };
232
+ exports.removePrefix = (input, state = {}) => {
233
+ let output = input;
234
+ if (output.startsWith("./")) {
235
+ output = output.slice(2);
236
+ state.prefix = "./";
237
+ }
238
+ return output;
239
+ };
240
+ exports.wrapOutput = (input, state = {}, options = {}) => {
241
+ const prepend = options.contains ? "" : "^";
242
+ const append = options.contains ? "" : "$";
243
+ let output = `${prepend}(?:${input})${append}`;
244
+ if (state.negated === true) {
245
+ output = `(?:^(?!${output}).*$)`;
246
+ }
247
+ return output;
248
+ };
249
+ exports.basename = (path, { windows } = {}) => {
250
+ const segs = path.split(windows ? /[\\/]/ : "/");
251
+ const last = segs[segs.length - 1];
252
+ if (last === "") {
253
+ return segs[segs.length - 2];
254
+ }
255
+ return last;
256
+ };
257
+ }));
258
+
259
+ //#endregion
260
+ //#region node_modules/picomatch/lib/scan.js
261
+ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
262
+ const utils$3 = require_utils();
263
+ 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 } = require_constants();
264
+ const isPathSeparator = (code) => {
265
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
266
+ };
267
+ const depth = (token) => {
268
+ if (token.isPrefix !== true) {
269
+ token.depth = token.isGlobstar ? Infinity : 1;
270
+ }
271
+ };
272
+ /**
273
+ * Quickly scans a glob pattern and returns an object with a handful of
274
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
275
+ * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
276
+ * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
277
+ *
278
+ * ```js
279
+ * const pm = require('picomatch');
280
+ * console.log(pm.scan('foo/bar/*.js'));
281
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
282
+ * ```
283
+ * @param {String} `str`
284
+ * @param {Object} `options`
285
+ * @return {Object} Returns an object with tokens and regex source string.
286
+ * @api public
287
+ */
288
+ const scan$1 = (input, options) => {
289
+ const opts = options || {};
290
+ const length = input.length - 1;
291
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
292
+ const slashes = [];
293
+ const tokens = [];
294
+ const parts = [];
295
+ let str = input;
296
+ let index = -1;
297
+ let start = 0;
298
+ let lastIndex = 0;
299
+ let isBrace = false;
300
+ let isBracket = false;
301
+ let isGlob = false;
302
+ let isExtglob = false;
303
+ let isGlobstar = false;
304
+ let braceEscaped = false;
305
+ let backslashes = false;
306
+ let negated = false;
307
+ let negatedExtglob = false;
308
+ let finished = false;
309
+ let braces = 0;
310
+ let prev;
311
+ let code;
312
+ let token = {
313
+ value: "",
314
+ depth: 0,
315
+ isGlob: false
316
+ };
317
+ const eos = () => index >= length;
318
+ const peek = () => str.charCodeAt(index + 1);
319
+ const advance = () => {
320
+ prev = code;
321
+ return str.charCodeAt(++index);
322
+ };
323
+ while (index < length) {
324
+ code = advance();
325
+ let next;
326
+ if (code === CHAR_BACKWARD_SLASH) {
327
+ backslashes = token.backslashes = true;
328
+ code = advance();
329
+ if (code === CHAR_LEFT_CURLY_BRACE) {
330
+ braceEscaped = true;
331
+ }
332
+ continue;
333
+ }
334
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
335
+ braces++;
336
+ while (eos() !== true && (code = advance())) {
337
+ if (code === CHAR_BACKWARD_SLASH) {
338
+ backslashes = token.backslashes = true;
339
+ advance();
340
+ continue;
341
+ }
342
+ if (code === CHAR_LEFT_CURLY_BRACE) {
343
+ braces++;
344
+ continue;
345
+ }
346
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
347
+ isBrace = token.isBrace = true;
348
+ isGlob = token.isGlob = true;
349
+ finished = true;
350
+ if (scanToEnd === true) {
351
+ continue;
352
+ }
353
+ break;
354
+ }
355
+ if (braceEscaped !== true && code === CHAR_COMMA) {
356
+ isBrace = token.isBrace = true;
357
+ isGlob = token.isGlob = true;
358
+ finished = true;
359
+ if (scanToEnd === true) {
360
+ continue;
361
+ }
362
+ break;
363
+ }
364
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
365
+ braces--;
366
+ if (braces === 0) {
367
+ braceEscaped = false;
368
+ isBrace = token.isBrace = true;
369
+ finished = true;
370
+ break;
371
+ }
372
+ }
373
+ }
374
+ if (scanToEnd === true) {
375
+ continue;
376
+ }
377
+ break;
378
+ }
379
+ if (code === CHAR_FORWARD_SLASH) {
380
+ slashes.push(index);
381
+ tokens.push(token);
382
+ token = {
383
+ value: "",
384
+ depth: 0,
385
+ isGlob: false
386
+ };
387
+ if (finished === true) continue;
388
+ if (prev === CHAR_DOT && index === start + 1) {
389
+ start += 2;
390
+ continue;
391
+ }
392
+ lastIndex = index + 1;
393
+ continue;
394
+ }
395
+ if (opts.noext !== true) {
396
+ const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
397
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
398
+ isGlob = token.isGlob = true;
399
+ isExtglob = token.isExtglob = true;
400
+ finished = true;
401
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
402
+ negatedExtglob = true;
403
+ }
404
+ if (scanToEnd === true) {
405
+ while (eos() !== true && (code = advance())) {
406
+ if (code === CHAR_BACKWARD_SLASH) {
407
+ backslashes = token.backslashes = true;
408
+ code = advance();
409
+ continue;
410
+ }
411
+ if (code === CHAR_RIGHT_PARENTHESES) {
412
+ isGlob = token.isGlob = true;
413
+ finished = true;
414
+ break;
415
+ }
416
+ }
417
+ continue;
418
+ }
419
+ break;
420
+ }
421
+ }
422
+ if (code === CHAR_ASTERISK) {
423
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
424
+ isGlob = token.isGlob = true;
425
+ finished = true;
426
+ if (scanToEnd === true) {
427
+ continue;
428
+ }
429
+ break;
430
+ }
431
+ if (code === CHAR_QUESTION_MARK) {
432
+ isGlob = token.isGlob = true;
433
+ finished = true;
434
+ if (scanToEnd === true) {
435
+ continue;
436
+ }
437
+ break;
438
+ }
439
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
440
+ while (eos() !== true && (next = advance())) {
441
+ if (next === CHAR_BACKWARD_SLASH) {
442
+ backslashes = token.backslashes = true;
443
+ advance();
444
+ continue;
445
+ }
446
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
447
+ isBracket = token.isBracket = true;
448
+ isGlob = token.isGlob = true;
449
+ finished = true;
450
+ break;
451
+ }
452
+ }
453
+ if (scanToEnd === true) {
454
+ continue;
455
+ }
456
+ break;
457
+ }
458
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
459
+ negated = token.negated = true;
460
+ start++;
461
+ continue;
462
+ }
463
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
464
+ isGlob = token.isGlob = true;
465
+ if (scanToEnd === true) {
466
+ while (eos() !== true && (code = advance())) {
467
+ if (code === CHAR_LEFT_PARENTHESES) {
468
+ backslashes = token.backslashes = true;
469
+ code = advance();
470
+ continue;
471
+ }
472
+ if (code === CHAR_RIGHT_PARENTHESES) {
473
+ finished = true;
474
+ break;
475
+ }
476
+ }
477
+ continue;
478
+ }
479
+ break;
480
+ }
481
+ if (isGlob === true) {
482
+ finished = true;
483
+ if (scanToEnd === true) {
484
+ continue;
485
+ }
486
+ break;
487
+ }
488
+ }
489
+ if (opts.noext === true) {
490
+ isExtglob = false;
491
+ isGlob = false;
492
+ }
493
+ let base = str;
494
+ let prefix = "";
495
+ let glob = "";
496
+ if (start > 0) {
497
+ prefix = str.slice(0, start);
498
+ str = str.slice(start);
499
+ lastIndex -= start;
500
+ }
501
+ if (base && isGlob === true && lastIndex > 0) {
502
+ base = str.slice(0, lastIndex);
503
+ glob = str.slice(lastIndex);
504
+ } else if (isGlob === true) {
505
+ base = "";
506
+ glob = str;
507
+ } else {
508
+ base = str;
509
+ }
510
+ if (base && base !== "" && base !== "/" && base !== str) {
511
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
512
+ base = base.slice(0, -1);
513
+ }
514
+ }
515
+ if (opts.unescape === true) {
516
+ if (glob) glob = utils$3.removeBackslashes(glob);
517
+ if (base && backslashes === true) {
518
+ base = utils$3.removeBackslashes(base);
519
+ }
520
+ }
521
+ const state = {
522
+ prefix,
523
+ input,
524
+ start,
525
+ base,
526
+ glob,
527
+ isBrace,
528
+ isBracket,
529
+ isGlob,
530
+ isExtglob,
531
+ isGlobstar,
532
+ negated,
533
+ negatedExtglob
534
+ };
535
+ if (opts.tokens === true) {
536
+ state.maxDepth = 0;
537
+ if (!isPathSeparator(code)) {
538
+ tokens.push(token);
539
+ }
540
+ state.tokens = tokens;
541
+ }
542
+ if (opts.parts === true || opts.tokens === true) {
543
+ let prevIndex;
544
+ for (let idx = 0; idx < slashes.length; idx++) {
545
+ const n = prevIndex ? prevIndex + 1 : start;
546
+ const i = slashes[idx];
547
+ const value = input.slice(n, i);
548
+ if (opts.tokens) {
549
+ if (idx === 0 && start !== 0) {
550
+ tokens[idx].isPrefix = true;
551
+ tokens[idx].value = prefix;
552
+ } else {
553
+ tokens[idx].value = value;
554
+ }
555
+ depth(tokens[idx]);
556
+ state.maxDepth += tokens[idx].depth;
557
+ }
558
+ if (idx !== 0 || value !== "") {
559
+ parts.push(value);
560
+ }
561
+ prevIndex = i;
562
+ }
563
+ if (prevIndex && prevIndex + 1 < input.length) {
564
+ const value = input.slice(prevIndex + 1);
565
+ parts.push(value);
566
+ if (opts.tokens) {
567
+ tokens[tokens.length - 1].value = value;
568
+ depth(tokens[tokens.length - 1]);
569
+ state.maxDepth += tokens[tokens.length - 1].depth;
570
+ }
571
+ }
572
+ state.slashes = slashes;
573
+ state.parts = parts;
574
+ }
575
+ return state;
576
+ };
577
+ module.exports = scan$1;
578
+ }));
579
+
580
+ //#endregion
581
+ //#region node_modules/picomatch/lib/parse.js
582
+ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
583
+ const constants$1 = require_constants();
584
+ const utils$2 = require_utils();
585
+ /**
586
+ * Constants
587
+ */
588
+ const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants$1;
589
+ /**
590
+ * Helpers
591
+ */
592
+ const expandRange = (args, options) => {
593
+ if (typeof options.expandRange === "function") {
594
+ return options.expandRange(...args, options);
595
+ }
596
+ args.sort();
597
+ const value = `[${args.join("-")}]`;
598
+ try {
599
+ new RegExp(value);
600
+ } catch (ex) {
601
+ return args.map((v) => utils$2.escapeRegex(v)).join("..");
602
+ }
603
+ return value;
604
+ };
605
+ /**
606
+ * Create the message for a syntax error
607
+ */
608
+ const syntaxError = (type, char) => {
609
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
610
+ };
611
+ /**
612
+ * Parse the given input string.
613
+ * @param {String} input
614
+ * @param {Object} options
615
+ * @return {Object}
616
+ */
617
+ const parse$1 = (input, options) => {
618
+ if (typeof input !== "string") {
619
+ throw new TypeError("Expected a string");
620
+ }
621
+ input = REPLACEMENTS[input] || input;
622
+ const opts = { ...options };
623
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
624
+ let len = input.length;
625
+ if (len > max) {
626
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
627
+ }
628
+ const bos = {
629
+ type: "bos",
630
+ value: "",
631
+ output: opts.prepend || ""
632
+ };
633
+ const tokens = [bos];
634
+ const capture = opts.capture ? "" : "?:";
635
+ const PLATFORM_CHARS = constants$1.globChars(opts.windows);
636
+ const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
637
+ const { DOT_LITERAL: DOT_LITERAL$1, PLUS_LITERAL: PLUS_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT: NO_DOT$1, NO_DOT_SLASH: NO_DOT_SLASH$1, NO_DOTS_SLASH: NO_DOTS_SLASH$1, QMARK: QMARK$1, QMARK_NO_DOT: QMARK_NO_DOT$1, STAR: STAR$1, START_ANCHOR: START_ANCHOR$1 } = PLATFORM_CHARS;
638
+ const globstar = (opts$1) => {
639
+ return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
640
+ };
641
+ const nodot = opts.dot ? "" : NO_DOT$1;
642
+ const qmarkNoDot = opts.dot ? QMARK$1 : QMARK_NO_DOT$1;
643
+ let star = opts.bash === true ? globstar(opts) : STAR$1;
644
+ if (opts.capture) {
645
+ star = `(${star})`;
646
+ }
647
+ if (typeof opts.noext === "boolean") {
648
+ opts.noextglob = opts.noext;
649
+ }
650
+ const state = {
651
+ input,
652
+ index: -1,
653
+ start: 0,
654
+ dot: opts.dot === true,
655
+ consumed: "",
656
+ output: "",
657
+ prefix: "",
658
+ backtrack: false,
659
+ negated: false,
660
+ brackets: 0,
661
+ braces: 0,
662
+ parens: 0,
663
+ quotes: 0,
664
+ globstar: false,
665
+ tokens
666
+ };
667
+ input = utils$2.removePrefix(input, state);
668
+ len = input.length;
669
+ const extglobs = [];
670
+ const braces = [];
671
+ const stack = [];
672
+ let prev = bos;
673
+ let value;
674
+ /**
675
+ * Tokenizing helpers
676
+ */
677
+ const eos = () => state.index === len - 1;
678
+ const peek = state.peek = (n = 1) => input[state.index + n];
679
+ const advance = state.advance = () => input[++state.index] || "";
680
+ const remaining = () => input.slice(state.index + 1);
681
+ const consume = (value$1 = "", num = 0) => {
682
+ state.consumed += value$1;
683
+ state.index += num;
684
+ };
685
+ const append = (token) => {
686
+ state.output += token.output != null ? token.output : token.value;
687
+ consume(token.value);
688
+ };
689
+ const negate = () => {
690
+ let count = 1;
691
+ while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
692
+ advance();
693
+ state.start++;
694
+ count++;
695
+ }
696
+ if (count % 2 === 0) {
697
+ return false;
698
+ }
699
+ state.negated = true;
700
+ state.start++;
701
+ return true;
702
+ };
703
+ const increment = (type) => {
704
+ state[type]++;
705
+ stack.push(type);
706
+ };
707
+ const decrement = (type) => {
708
+ state[type]--;
709
+ stack.pop();
710
+ };
711
+ /**
712
+ * Push tokens onto the tokens array. This helper speeds up
713
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
714
+ * and 2) helping us avoid creating extra tokens when consecutive
715
+ * characters are plain text. This improves performance and simplifies
716
+ * lookbehinds.
717
+ */
718
+ const push = (tok) => {
719
+ if (prev.type === "globstar") {
720
+ const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
721
+ const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
722
+ if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
723
+ state.output = state.output.slice(0, -prev.output.length);
724
+ prev.type = "star";
725
+ prev.value = "*";
726
+ prev.output = star;
727
+ state.output += prev.output;
728
+ }
729
+ }
730
+ if (extglobs.length && tok.type !== "paren") {
731
+ extglobs[extglobs.length - 1].inner += tok.value;
732
+ }
733
+ if (tok.value || tok.output) append(tok);
734
+ if (prev && prev.type === "text" && tok.type === "text") {
735
+ prev.output = (prev.output || prev.value) + tok.value;
736
+ prev.value += tok.value;
737
+ return;
738
+ }
739
+ tok.prev = prev;
740
+ tokens.push(tok);
741
+ prev = tok;
742
+ };
743
+ const extglobOpen = (type, value$1) => {
744
+ const token = {
745
+ ...EXTGLOB_CHARS[value$1],
746
+ conditions: 1,
747
+ inner: ""
748
+ };
749
+ token.prev = prev;
750
+ token.parens = state.parens;
751
+ token.output = state.output;
752
+ const output = (opts.capture ? "(" : "") + token.open;
753
+ increment("parens");
754
+ push({
755
+ type,
756
+ value: value$1,
757
+ output: state.output ? "" : ONE_CHAR$1
758
+ });
759
+ push({
760
+ type: "paren",
761
+ extglob: true,
762
+ value: advance(),
763
+ output
764
+ });
765
+ extglobs.push(token);
766
+ };
767
+ const extglobClose = (token) => {
768
+ let output = token.close + (opts.capture ? ")" : "");
769
+ let rest;
770
+ if (token.type === "negate") {
771
+ let extglobStar = star;
772
+ if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
773
+ extglobStar = globstar(opts);
774
+ }
775
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
776
+ output = token.close = `)$))${extglobStar}`;
777
+ }
778
+ if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
779
+ const expression = parse$1(rest, {
780
+ ...options,
781
+ fastpaths: false
782
+ }).output;
783
+ output = token.close = `)${expression})${extglobStar})`;
784
+ }
785
+ if (token.prev.type === "bos") {
786
+ state.negatedExtglob = true;
787
+ }
788
+ }
789
+ push({
790
+ type: "paren",
791
+ extglob: true,
792
+ value,
793
+ output
794
+ });
795
+ decrement("parens");
796
+ };
797
+ /**
798
+ * Fast paths
799
+ */
800
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
801
+ let backslashes = false;
802
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
803
+ if (first === "\\") {
804
+ backslashes = true;
805
+ return m;
806
+ }
807
+ if (first === "?") {
808
+ if (esc) {
809
+ return esc + first + (rest ? QMARK$1.repeat(rest.length) : "");
810
+ }
811
+ if (index === 0) {
812
+ return qmarkNoDot + (rest ? QMARK$1.repeat(rest.length) : "");
813
+ }
814
+ return QMARK$1.repeat(chars.length);
815
+ }
816
+ if (first === ".") {
817
+ return DOT_LITERAL$1.repeat(chars.length);
818
+ }
819
+ if (first === "*") {
820
+ if (esc) {
821
+ return esc + first + (rest ? star : "");
822
+ }
823
+ return star;
824
+ }
825
+ return esc ? m : `\\${m}`;
826
+ });
827
+ if (backslashes === true) {
828
+ if (opts.unescape === true) {
829
+ output = output.replace(/\\/g, "");
830
+ } else {
831
+ output = output.replace(/\\+/g, (m) => {
832
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
833
+ });
834
+ }
835
+ }
836
+ if (output === input && opts.contains === true) {
837
+ state.output = input;
838
+ return state;
839
+ }
840
+ state.output = utils$2.wrapOutput(output, state, options);
841
+ return state;
842
+ }
843
+ /**
844
+ * Tokenize input until we reach end-of-string
845
+ */
846
+ while (!eos()) {
847
+ value = advance();
848
+ if (value === "\0") {
849
+ continue;
850
+ }
851
+ /**
852
+ * Escaped characters
853
+ */
854
+ if (value === "\\") {
855
+ const next = peek();
856
+ if (next === "/" && opts.bash !== true) {
857
+ continue;
858
+ }
859
+ if (next === "." || next === ";") {
860
+ continue;
861
+ }
862
+ if (!next) {
863
+ value += "\\";
864
+ push({
865
+ type: "text",
866
+ value
867
+ });
868
+ continue;
869
+ }
870
+ const match = /^\\+/.exec(remaining());
871
+ let slashes = 0;
872
+ if (match && match[0].length > 2) {
873
+ slashes = match[0].length;
874
+ state.index += slashes;
875
+ if (slashes % 2 !== 0) {
876
+ value += "\\";
877
+ }
878
+ }
879
+ if (opts.unescape === true) {
880
+ value = advance();
881
+ } else {
882
+ value += advance();
883
+ }
884
+ if (state.brackets === 0) {
885
+ push({
886
+ type: "text",
887
+ value
888
+ });
889
+ continue;
890
+ }
891
+ }
892
+ /**
893
+ * If we're inside a regex character class, continue
894
+ * until we reach the closing bracket.
895
+ */
896
+ if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
897
+ if (opts.posix !== false && value === ":") {
898
+ const inner = prev.value.slice(1);
899
+ if (inner.includes("[")) {
900
+ prev.posix = true;
901
+ if (inner.includes(":")) {
902
+ const idx = prev.value.lastIndexOf("[");
903
+ const pre = prev.value.slice(0, idx);
904
+ const rest$1 = prev.value.slice(idx + 2);
905
+ const posix = POSIX_REGEX_SOURCE[rest$1];
906
+ if (posix) {
907
+ prev.value = pre + posix;
908
+ state.backtrack = true;
909
+ advance();
910
+ if (!bos.output && tokens.indexOf(prev) === 1) {
911
+ bos.output = ONE_CHAR$1;
912
+ }
913
+ continue;
914
+ }
915
+ }
916
+ }
917
+ }
918
+ if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
919
+ value = `\\${value}`;
920
+ }
921
+ if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
922
+ value = `\\${value}`;
923
+ }
924
+ if (opts.posix === true && value === "!" && prev.value === "[") {
925
+ value = "^";
926
+ }
927
+ prev.value += value;
928
+ append({ value });
929
+ continue;
930
+ }
931
+ /**
932
+ * If we're inside a quoted string, continue
933
+ * until we reach the closing double quote.
934
+ */
935
+ if (state.quotes === 1 && value !== "\"") {
936
+ value = utils$2.escapeRegex(value);
937
+ prev.value += value;
938
+ append({ value });
939
+ continue;
940
+ }
941
+ /**
942
+ * Double quotes
943
+ */
944
+ if (value === "\"") {
945
+ state.quotes = state.quotes === 1 ? 0 : 1;
946
+ if (opts.keepQuotes === true) {
947
+ push({
948
+ type: "text",
949
+ value
950
+ });
951
+ }
952
+ continue;
953
+ }
954
+ /**
955
+ * Parentheses
956
+ */
957
+ if (value === "(") {
958
+ increment("parens");
959
+ push({
960
+ type: "paren",
961
+ value
962
+ });
963
+ continue;
964
+ }
965
+ if (value === ")") {
966
+ if (state.parens === 0 && opts.strictBrackets === true) {
967
+ throw new SyntaxError(syntaxError("opening", "("));
968
+ }
969
+ const extglob = extglobs[extglobs.length - 1];
970
+ if (extglob && state.parens === extglob.parens + 1) {
971
+ extglobClose(extglobs.pop());
972
+ continue;
973
+ }
974
+ push({
975
+ type: "paren",
976
+ value,
977
+ output: state.parens ? ")" : "\\)"
978
+ });
979
+ decrement("parens");
980
+ continue;
981
+ }
982
+ /**
983
+ * Square brackets
984
+ */
985
+ if (value === "[") {
986
+ if (opts.nobracket === true || !remaining().includes("]")) {
987
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
988
+ throw new SyntaxError(syntaxError("closing", "]"));
989
+ }
990
+ value = `\\${value}`;
991
+ } else {
992
+ increment("brackets");
993
+ }
994
+ push({
995
+ type: "bracket",
996
+ value
997
+ });
998
+ continue;
999
+ }
1000
+ if (value === "]") {
1001
+ if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
1002
+ push({
1003
+ type: "text",
1004
+ value,
1005
+ output: `\\${value}`
1006
+ });
1007
+ continue;
1008
+ }
1009
+ if (state.brackets === 0) {
1010
+ if (opts.strictBrackets === true) {
1011
+ throw new SyntaxError(syntaxError("opening", "["));
1012
+ }
1013
+ push({
1014
+ type: "text",
1015
+ value,
1016
+ output: `\\${value}`
1017
+ });
1018
+ continue;
1019
+ }
1020
+ decrement("brackets");
1021
+ const prevValue = prev.value.slice(1);
1022
+ if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
1023
+ value = `/${value}`;
1024
+ }
1025
+ prev.value += value;
1026
+ append({ value });
1027
+ if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) {
1028
+ continue;
1029
+ }
1030
+ const escaped = utils$2.escapeRegex(prev.value);
1031
+ state.output = state.output.slice(0, -prev.value.length);
1032
+ if (opts.literalBrackets === true) {
1033
+ state.output += escaped;
1034
+ prev.value = escaped;
1035
+ continue;
1036
+ }
1037
+ prev.value = `(${capture}${escaped}|${prev.value})`;
1038
+ state.output += prev.value;
1039
+ continue;
1040
+ }
1041
+ /**
1042
+ * Braces
1043
+ */
1044
+ if (value === "{" && opts.nobrace !== true) {
1045
+ increment("braces");
1046
+ const open = {
1047
+ type: "brace",
1048
+ value,
1049
+ output: "(",
1050
+ outputIndex: state.output.length,
1051
+ tokensIndex: state.tokens.length
1052
+ };
1053
+ braces.push(open);
1054
+ push(open);
1055
+ continue;
1056
+ }
1057
+ if (value === "}") {
1058
+ const brace = braces[braces.length - 1];
1059
+ if (opts.nobrace === true || !brace) {
1060
+ push({
1061
+ type: "text",
1062
+ value,
1063
+ output: value
1064
+ });
1065
+ continue;
1066
+ }
1067
+ let output = ")";
1068
+ if (brace.dots === true) {
1069
+ const arr = tokens.slice();
1070
+ const range = [];
1071
+ for (let i = arr.length - 1; i >= 0; i--) {
1072
+ tokens.pop();
1073
+ if (arr[i].type === "brace") {
1074
+ break;
1075
+ }
1076
+ if (arr[i].type !== "dots") {
1077
+ range.unshift(arr[i].value);
1078
+ }
1079
+ }
1080
+ output = expandRange(range, opts);
1081
+ state.backtrack = true;
1082
+ }
1083
+ if (brace.comma !== true && brace.dots !== true) {
1084
+ const out = state.output.slice(0, brace.outputIndex);
1085
+ const toks = state.tokens.slice(brace.tokensIndex);
1086
+ brace.value = brace.output = "\\{";
1087
+ value = output = "\\}";
1088
+ state.output = out;
1089
+ for (const t of toks) {
1090
+ state.output += t.output || t.value;
1091
+ }
1092
+ }
1093
+ push({
1094
+ type: "brace",
1095
+ value,
1096
+ output
1097
+ });
1098
+ decrement("braces");
1099
+ braces.pop();
1100
+ continue;
1101
+ }
1102
+ /**
1103
+ * Pipes
1104
+ */
1105
+ if (value === "|") {
1106
+ if (extglobs.length > 0) {
1107
+ extglobs[extglobs.length - 1].conditions++;
1108
+ }
1109
+ push({
1110
+ type: "text",
1111
+ value
1112
+ });
1113
+ continue;
1114
+ }
1115
+ /**
1116
+ * Commas
1117
+ */
1118
+ if (value === ",") {
1119
+ let output = value;
1120
+ const brace = braces[braces.length - 1];
1121
+ if (brace && stack[stack.length - 1] === "braces") {
1122
+ brace.comma = true;
1123
+ output = "|";
1124
+ }
1125
+ push({
1126
+ type: "comma",
1127
+ value,
1128
+ output
1129
+ });
1130
+ continue;
1131
+ }
1132
+ /**
1133
+ * Slashes
1134
+ */
1135
+ if (value === "/") {
1136
+ if (prev.type === "dot" && state.index === state.start + 1) {
1137
+ state.start = state.index + 1;
1138
+ state.consumed = "";
1139
+ state.output = "";
1140
+ tokens.pop();
1141
+ prev = bos;
1142
+ continue;
1143
+ }
1144
+ push({
1145
+ type: "slash",
1146
+ value,
1147
+ output: SLASH_LITERAL$1
1148
+ });
1149
+ continue;
1150
+ }
1151
+ /**
1152
+ * Dots
1153
+ */
1154
+ if (value === ".") {
1155
+ if (state.braces > 0 && prev.type === "dot") {
1156
+ if (prev.value === ".") prev.output = DOT_LITERAL$1;
1157
+ const brace = braces[braces.length - 1];
1158
+ prev.type = "dots";
1159
+ prev.output += value;
1160
+ prev.value += value;
1161
+ brace.dots = true;
1162
+ continue;
1163
+ }
1164
+ if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1165
+ push({
1166
+ type: "text",
1167
+ value,
1168
+ output: DOT_LITERAL$1
1169
+ });
1170
+ continue;
1171
+ }
1172
+ push({
1173
+ type: "dot",
1174
+ value,
1175
+ output: DOT_LITERAL$1
1176
+ });
1177
+ continue;
1178
+ }
1179
+ /**
1180
+ * Question marks
1181
+ */
1182
+ if (value === "?") {
1183
+ const isGroup = prev && prev.value === "(";
1184
+ if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1185
+ extglobOpen("qmark", value);
1186
+ continue;
1187
+ }
1188
+ if (prev && prev.type === "paren") {
1189
+ const next = peek();
1190
+ let output = value;
1191
+ if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
1192
+ output = `\\${value}`;
1193
+ }
1194
+ push({
1195
+ type: "text",
1196
+ value,
1197
+ output
1198
+ });
1199
+ continue;
1200
+ }
1201
+ if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1202
+ push({
1203
+ type: "qmark",
1204
+ value,
1205
+ output: QMARK_NO_DOT$1
1206
+ });
1207
+ continue;
1208
+ }
1209
+ push({
1210
+ type: "qmark",
1211
+ value,
1212
+ output: QMARK$1
1213
+ });
1214
+ continue;
1215
+ }
1216
+ /**
1217
+ * Exclamation
1218
+ */
1219
+ if (value === "!") {
1220
+ if (opts.noextglob !== true && peek() === "(") {
1221
+ if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1222
+ extglobOpen("negate", value);
1223
+ continue;
1224
+ }
1225
+ }
1226
+ if (opts.nonegate !== true && state.index === 0) {
1227
+ negate();
1228
+ continue;
1229
+ }
1230
+ }
1231
+ /**
1232
+ * Plus
1233
+ */
1234
+ if (value === "+") {
1235
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1236
+ extglobOpen("plus", value);
1237
+ continue;
1238
+ }
1239
+ if (prev && prev.value === "(" || opts.regex === false) {
1240
+ push({
1241
+ type: "plus",
1242
+ value,
1243
+ output: PLUS_LITERAL$1
1244
+ });
1245
+ continue;
1246
+ }
1247
+ if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1248
+ push({
1249
+ type: "plus",
1250
+ value
1251
+ });
1252
+ continue;
1253
+ }
1254
+ push({
1255
+ type: "plus",
1256
+ value: PLUS_LITERAL$1
1257
+ });
1258
+ continue;
1259
+ }
1260
+ /**
1261
+ * Plain text
1262
+ */
1263
+ if (value === "@") {
1264
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1265
+ push({
1266
+ type: "at",
1267
+ extglob: true,
1268
+ value,
1269
+ output: ""
1270
+ });
1271
+ continue;
1272
+ }
1273
+ push({
1274
+ type: "text",
1275
+ value
1276
+ });
1277
+ continue;
1278
+ }
1279
+ /**
1280
+ * Plain text
1281
+ */
1282
+ if (value !== "*") {
1283
+ if (value === "$" || value === "^") {
1284
+ value = `\\${value}`;
1285
+ }
1286
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1287
+ if (match) {
1288
+ value += match[0];
1289
+ state.index += match[0].length;
1290
+ }
1291
+ push({
1292
+ type: "text",
1293
+ value
1294
+ });
1295
+ continue;
1296
+ }
1297
+ /**
1298
+ * Stars
1299
+ */
1300
+ if (prev && (prev.type === "globstar" || prev.star === true)) {
1301
+ prev.type = "star";
1302
+ prev.star = true;
1303
+ prev.value += value;
1304
+ prev.output = star;
1305
+ state.backtrack = true;
1306
+ state.globstar = true;
1307
+ consume(value);
1308
+ continue;
1309
+ }
1310
+ let rest = remaining();
1311
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1312
+ extglobOpen("star", value);
1313
+ continue;
1314
+ }
1315
+ if (prev.type === "star") {
1316
+ if (opts.noglobstar === true) {
1317
+ consume(value);
1318
+ continue;
1319
+ }
1320
+ const prior = prev.prev;
1321
+ const before = prior.prev;
1322
+ const isStart = prior.type === "slash" || prior.type === "bos";
1323
+ const afterStar = before && (before.type === "star" || before.type === "globstar");
1324
+ if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1325
+ push({
1326
+ type: "star",
1327
+ value,
1328
+ output: ""
1329
+ });
1330
+ continue;
1331
+ }
1332
+ const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1333
+ const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1334
+ if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1335
+ push({
1336
+ type: "star",
1337
+ value,
1338
+ output: ""
1339
+ });
1340
+ continue;
1341
+ }
1342
+ while (rest.slice(0, 3) === "/**") {
1343
+ const after = input[state.index + 4];
1344
+ if (after && after !== "/") {
1345
+ break;
1346
+ }
1347
+ rest = rest.slice(3);
1348
+ consume("/**", 3);
1349
+ }
1350
+ if (prior.type === "bos" && eos()) {
1351
+ prev.type = "globstar";
1352
+ prev.value += value;
1353
+ prev.output = globstar(opts);
1354
+ state.output = prev.output;
1355
+ state.globstar = true;
1356
+ consume(value);
1357
+ continue;
1358
+ }
1359
+ if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1360
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1361
+ prior.output = `(?:${prior.output}`;
1362
+ prev.type = "globstar";
1363
+ prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1364
+ prev.value += value;
1365
+ state.globstar = true;
1366
+ state.output += prior.output + prev.output;
1367
+ consume(value);
1368
+ continue;
1369
+ }
1370
+ if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1371
+ const end = rest[1] !== void 0 ? "|$" : "";
1372
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1373
+ prior.output = `(?:${prior.output}`;
1374
+ prev.type = "globstar";
1375
+ prev.output = `${globstar(opts)}${SLASH_LITERAL$1}|${SLASH_LITERAL$1}${end})`;
1376
+ prev.value += value;
1377
+ state.output += prior.output + prev.output;
1378
+ state.globstar = true;
1379
+ consume(value + advance());
1380
+ push({
1381
+ type: "slash",
1382
+ value: "/",
1383
+ output: ""
1384
+ });
1385
+ continue;
1386
+ }
1387
+ if (prior.type === "bos" && rest[0] === "/") {
1388
+ prev.type = "globstar";
1389
+ prev.value += value;
1390
+ prev.output = `(?:^|${SLASH_LITERAL$1}|${globstar(opts)}${SLASH_LITERAL$1})`;
1391
+ state.output = prev.output;
1392
+ state.globstar = true;
1393
+ consume(value + advance());
1394
+ push({
1395
+ type: "slash",
1396
+ value: "/",
1397
+ output: ""
1398
+ });
1399
+ continue;
1400
+ }
1401
+ state.output = state.output.slice(0, -prev.output.length);
1402
+ prev.type = "globstar";
1403
+ prev.output = globstar(opts);
1404
+ prev.value += value;
1405
+ state.output += prev.output;
1406
+ state.globstar = true;
1407
+ consume(value);
1408
+ continue;
1409
+ }
1410
+ const token = {
1411
+ type: "star",
1412
+ value,
1413
+ output: star
1414
+ };
1415
+ if (opts.bash === true) {
1416
+ token.output = ".*?";
1417
+ if (prev.type === "bos" || prev.type === "slash") {
1418
+ token.output = nodot + token.output;
1419
+ }
1420
+ push(token);
1421
+ continue;
1422
+ }
1423
+ if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1424
+ token.output = value;
1425
+ push(token);
1426
+ continue;
1427
+ }
1428
+ if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1429
+ if (prev.type === "dot") {
1430
+ state.output += NO_DOT_SLASH$1;
1431
+ prev.output += NO_DOT_SLASH$1;
1432
+ } else if (opts.dot === true) {
1433
+ state.output += NO_DOTS_SLASH$1;
1434
+ prev.output += NO_DOTS_SLASH$1;
1435
+ } else {
1436
+ state.output += nodot;
1437
+ prev.output += nodot;
1438
+ }
1439
+ if (peek() !== "*") {
1440
+ state.output += ONE_CHAR$1;
1441
+ prev.output += ONE_CHAR$1;
1442
+ }
1443
+ }
1444
+ push(token);
1445
+ }
1446
+ while (state.brackets > 0) {
1447
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1448
+ state.output = utils$2.escapeLast(state.output, "[");
1449
+ decrement("brackets");
1450
+ }
1451
+ while (state.parens > 0) {
1452
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
1453
+ state.output = utils$2.escapeLast(state.output, "(");
1454
+ decrement("parens");
1455
+ }
1456
+ while (state.braces > 0) {
1457
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
1458
+ state.output = utils$2.escapeLast(state.output, "{");
1459
+ decrement("braces");
1460
+ }
1461
+ if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
1462
+ push({
1463
+ type: "maybe_slash",
1464
+ value: "",
1465
+ output: `${SLASH_LITERAL$1}?`
1466
+ });
1467
+ }
1468
+ if (state.backtrack === true) {
1469
+ state.output = "";
1470
+ for (const token of state.tokens) {
1471
+ state.output += token.output != null ? token.output : token.value;
1472
+ if (token.suffix) {
1473
+ state.output += token.suffix;
1474
+ }
1475
+ }
1476
+ }
1477
+ return state;
1478
+ };
1479
+ /**
1480
+ * Fast paths for creating regular expressions for common glob patterns.
1481
+ * This can significantly speed up processing and has very little downside
1482
+ * impact when none of the fast paths match.
1483
+ */
1484
+ parse$1.fastpaths = (input, options) => {
1485
+ const opts = { ...options };
1486
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1487
+ const len = input.length;
1488
+ if (len > max) {
1489
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1490
+ }
1491
+ input = REPLACEMENTS[input] || input;
1492
+ const { DOT_LITERAL: DOT_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT: NO_DOT$1, NO_DOTS: NO_DOTS$1, NO_DOTS_SLASH: NO_DOTS_SLASH$1, STAR: STAR$1, START_ANCHOR: START_ANCHOR$1 } = constants$1.globChars(opts.windows);
1493
+ const nodot = opts.dot ? NO_DOTS$1 : NO_DOT$1;
1494
+ const slashDot = opts.dot ? NO_DOTS_SLASH$1 : NO_DOT$1;
1495
+ const capture = opts.capture ? "" : "?:";
1496
+ const state = {
1497
+ negated: false,
1498
+ prefix: ""
1499
+ };
1500
+ let star = opts.bash === true ? ".*?" : STAR$1;
1501
+ if (opts.capture) {
1502
+ star = `(${star})`;
1503
+ }
1504
+ const globstar = (opts$1) => {
1505
+ if (opts$1.noglobstar === true) return star;
1506
+ return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
1507
+ };
1508
+ const create = (str) => {
1509
+ switch (str) {
1510
+ case "*": return `${nodot}${ONE_CHAR$1}${star}`;
1511
+ case ".*": return `${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1512
+ case "*.*": return `${nodot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1513
+ case "*/*": return `${nodot}${star}${SLASH_LITERAL$1}${ONE_CHAR$1}${slashDot}${star}`;
1514
+ case "**": return nodot + globstar(opts);
1515
+ case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${ONE_CHAR$1}${star}`;
1516
+ case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1517
+ case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1518
+ default: {
1519
+ const match = /^(.*?)\.(\w+)$/.exec(str);
1520
+ if (!match) return;
1521
+ const source$1 = create(match[1]);
1522
+ if (!source$1) return;
1523
+ return source$1 + DOT_LITERAL$1 + match[2];
1524
+ }
1525
+ }
1526
+ };
1527
+ const output = utils$2.removePrefix(input, state);
1528
+ let source = create(output);
1529
+ if (source && opts.strictSlashes !== true) {
1530
+ source += `${SLASH_LITERAL$1}?`;
1531
+ }
1532
+ return source;
1533
+ };
1534
+ module.exports = parse$1;
1535
+ }));
1536
+
1537
+ //#endregion
1538
+ //#region node_modules/picomatch/lib/picomatch.js
1539
+ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1540
+ const scan = require_scan();
1541
+ const parse = require_parse();
1542
+ const utils$1 = require_utils();
1543
+ const constants = require_constants();
1544
+ const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1545
+ /**
1546
+ * Creates a matcher function from one or more glob patterns. The
1547
+ * returned function takes a string to match as its first argument,
1548
+ * and returns true if the string is a match. The returned matcher
1549
+ * function also takes a boolean as the second argument that, when true,
1550
+ * returns an object with additional information.
1551
+ *
1552
+ * ```js
1553
+ * const picomatch = require('picomatch');
1554
+ * // picomatch(glob[, options]);
1555
+ *
1556
+ * const isMatch = picomatch('*.!(*a)');
1557
+ * console.log(isMatch('a.a')); //=> false
1558
+ * console.log(isMatch('a.b')); //=> true
1559
+ * ```
1560
+ * @name picomatch
1561
+ * @param {String|Array} `globs` One or more glob patterns.
1562
+ * @param {Object=} `options`
1563
+ * @return {Function=} Returns a matcher function.
1564
+ * @api public
1565
+ */
1566
+ const picomatch$2 = (glob, options, returnState = false) => {
1567
+ if (Array.isArray(glob)) {
1568
+ const fns = glob.map((input) => picomatch$2(input, options, returnState));
1569
+ const arrayMatcher = (str) => {
1570
+ for (const isMatch of fns) {
1571
+ const state$1 = isMatch(str);
1572
+ if (state$1) return state$1;
1573
+ }
1574
+ return false;
1575
+ };
1576
+ return arrayMatcher;
1577
+ }
1578
+ const isState = isObject(glob) && glob.tokens && glob.input;
1579
+ if (glob === "" || typeof glob !== "string" && !isState) {
1580
+ throw new TypeError("Expected pattern to be a non-empty string");
1581
+ }
1582
+ const opts = options || {};
1583
+ const posix = opts.windows;
1584
+ const regex = isState ? picomatch$2.compileRe(glob, options) : picomatch$2.makeRe(glob, options, false, true);
1585
+ const state = regex.state;
1586
+ delete regex.state;
1587
+ let isIgnored = () => false;
1588
+ if (opts.ignore) {
1589
+ const ignoreOpts = {
1590
+ ...options,
1591
+ ignore: null,
1592
+ onMatch: null,
1593
+ onResult: null
1594
+ };
1595
+ isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
1596
+ }
1597
+ const matcher = (input, returnObject = false) => {
1598
+ const { isMatch, match, output } = picomatch$2.test(input, regex, options, {
1599
+ glob,
1600
+ posix
1601
+ });
1602
+ const result = {
1603
+ glob,
1604
+ state,
1605
+ regex,
1606
+ posix,
1607
+ input,
1608
+ output,
1609
+ match,
1610
+ isMatch
1611
+ };
1612
+ if (typeof opts.onResult === "function") {
1613
+ opts.onResult(result);
1614
+ }
1615
+ if (isMatch === false) {
1616
+ result.isMatch = false;
1617
+ return returnObject ? result : false;
1618
+ }
1619
+ if (isIgnored(input)) {
1620
+ if (typeof opts.onIgnore === "function") {
1621
+ opts.onIgnore(result);
1622
+ }
1623
+ result.isMatch = false;
1624
+ return returnObject ? result : false;
1625
+ }
1626
+ if (typeof opts.onMatch === "function") {
1627
+ opts.onMatch(result);
1628
+ }
1629
+ return returnObject ? result : true;
1630
+ };
1631
+ if (returnState) {
1632
+ matcher.state = state;
1633
+ }
1634
+ return matcher;
1635
+ };
1636
+ /**
1637
+ * Test `input` with the given `regex`. This is used by the main
1638
+ * `picomatch()` function to test the input string.
1639
+ *
1640
+ * ```js
1641
+ * const picomatch = require('picomatch');
1642
+ * // picomatch.test(input, regex[, options]);
1643
+ *
1644
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
1645
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
1646
+ * ```
1647
+ * @param {String} `input` String to test.
1648
+ * @param {RegExp} `regex`
1649
+ * @return {Object} Returns an object with matching info.
1650
+ * @api public
1651
+ */
1652
+ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
1653
+ if (typeof input !== "string") {
1654
+ throw new TypeError("Expected input to be a string");
1655
+ }
1656
+ if (input === "") {
1657
+ return {
1658
+ isMatch: false,
1659
+ output: ""
1660
+ };
1661
+ }
1662
+ const opts = options || {};
1663
+ const format = opts.format || (posix ? utils$1.toPosixSlashes : null);
1664
+ let match = input === glob;
1665
+ let output = match && format ? format(input) : input;
1666
+ if (match === false) {
1667
+ output = format ? format(input) : input;
1668
+ match = output === glob;
1669
+ }
1670
+ if (match === false || opts.capture === true) {
1671
+ if (opts.matchBase === true || opts.basename === true) {
1672
+ match = picomatch$2.matchBase(input, regex, options, posix);
1673
+ } else {
1674
+ match = regex.exec(output);
1675
+ }
1676
+ }
1677
+ return {
1678
+ isMatch: Boolean(match),
1679
+ match,
1680
+ output
1681
+ };
1682
+ };
1683
+ /**
1684
+ * Match the basename of a filepath.
1685
+ *
1686
+ * ```js
1687
+ * const picomatch = require('picomatch');
1688
+ * // picomatch.matchBase(input, glob[, options]);
1689
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
1690
+ * ```
1691
+ * @param {String} `input` String to test.
1692
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
1693
+ * @return {Boolean}
1694
+ * @api public
1695
+ */
1696
+ picomatch$2.matchBase = (input, glob, options) => {
1697
+ const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
1698
+ return regex.test(utils$1.basename(input));
1699
+ };
1700
+ /**
1701
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
1702
+ *
1703
+ * ```js
1704
+ * const picomatch = require('picomatch');
1705
+ * // picomatch.isMatch(string, patterns[, options]);
1706
+ *
1707
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
1708
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
1709
+ * ```
1710
+ * @param {String|Array} str The string to test.
1711
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
1712
+ * @param {Object} [options] See available [options](#options).
1713
+ * @return {Boolean} Returns true if any patterns match `str`
1714
+ * @api public
1715
+ */
1716
+ picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
1717
+ /**
1718
+ * Parse a glob pattern to create the source string for a regular
1719
+ * expression.
1720
+ *
1721
+ * ```js
1722
+ * const picomatch = require('picomatch');
1723
+ * const result = picomatch.parse(pattern[, options]);
1724
+ * ```
1725
+ * @param {String} `pattern`
1726
+ * @param {Object} `options`
1727
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
1728
+ * @api public
1729
+ */
1730
+ picomatch$2.parse = (pattern, options) => {
1731
+ if (Array.isArray(pattern)) return pattern.map((p) => picomatch$2.parse(p, options));
1732
+ return parse(pattern, {
1733
+ ...options,
1734
+ fastpaths: false
1735
+ });
1736
+ };
1737
+ /**
1738
+ * Scan a glob pattern to separate the pattern into segments.
1739
+ *
1740
+ * ```js
1741
+ * const picomatch = require('picomatch');
1742
+ * // picomatch.scan(input[, options]);
1743
+ *
1744
+ * const result = picomatch.scan('!./foo/*.js');
1745
+ * console.log(result);
1746
+ * { prefix: '!./',
1747
+ * input: '!./foo/*.js',
1748
+ * start: 3,
1749
+ * base: 'foo',
1750
+ * glob: '*.js',
1751
+ * isBrace: false,
1752
+ * isBracket: false,
1753
+ * isGlob: true,
1754
+ * isExtglob: false,
1755
+ * isGlobstar: false,
1756
+ * negated: true }
1757
+ * ```
1758
+ * @param {String} `input` Glob pattern to scan.
1759
+ * @param {Object} `options`
1760
+ * @return {Object} Returns an object with
1761
+ * @api public
1762
+ */
1763
+ picomatch$2.scan = (input, options) => scan(input, options);
1764
+ /**
1765
+ * Compile a regular expression from the `state` object returned by the
1766
+ * [parse()](#parse) method.
1767
+ *
1768
+ * @param {Object} `state`
1769
+ * @param {Object} `options`
1770
+ * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
1771
+ * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
1772
+ * @return {RegExp}
1773
+ * @api public
1774
+ */
1775
+ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
1776
+ if (returnOutput === true) {
1777
+ return state.output;
1778
+ }
1779
+ const opts = options || {};
1780
+ const prepend = opts.contains ? "" : "^";
1781
+ const append = opts.contains ? "" : "$";
1782
+ let source = `${prepend}(?:${state.output})${append}`;
1783
+ if (state && state.negated === true) {
1784
+ source = `^(?!${source}).*$`;
1785
+ }
1786
+ const regex = picomatch$2.toRegex(source, options);
1787
+ if (returnState === true) {
1788
+ regex.state = state;
1789
+ }
1790
+ return regex;
1791
+ };
1792
+ /**
1793
+ * Create a regular expression from a parsed glob pattern.
1794
+ *
1795
+ * ```js
1796
+ * const picomatch = require('picomatch');
1797
+ * const state = picomatch.parse('*.js');
1798
+ * // picomatch.compileRe(state[, options]);
1799
+ *
1800
+ * console.log(picomatch.compileRe(state));
1801
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
1802
+ * ```
1803
+ * @param {String} `state` The object returned from the `.parse` method.
1804
+ * @param {Object} `options`
1805
+ * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
1806
+ * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
1807
+ * @return {RegExp} Returns a regex created from the given pattern.
1808
+ * @api public
1809
+ */
1810
+ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
1811
+ if (!input || typeof input !== "string") {
1812
+ throw new TypeError("Expected a non-empty string");
1813
+ }
1814
+ let parsed = {
1815
+ negated: false,
1816
+ fastpaths: true
1817
+ };
1818
+ if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
1819
+ parsed.output = parse.fastpaths(input, options);
1820
+ }
1821
+ if (!parsed.output) {
1822
+ parsed = parse(input, options);
1823
+ }
1824
+ return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
1825
+ };
1826
+ /**
1827
+ * Create a regular expression from the given regex source string.
1828
+ *
1829
+ * ```js
1830
+ * const picomatch = require('picomatch');
1831
+ * // picomatch.toRegex(source[, options]);
1832
+ *
1833
+ * const { output } = picomatch.parse('*.js');
1834
+ * console.log(picomatch.toRegex(output));
1835
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
1836
+ * ```
1837
+ * @param {String} `source` Regular expression source string.
1838
+ * @param {Object} `options`
1839
+ * @return {RegExp}
1840
+ * @api public
1841
+ */
1842
+ picomatch$2.toRegex = (source, options) => {
1843
+ try {
1844
+ const opts = options || {};
1845
+ return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1846
+ } catch (err) {
1847
+ if (options && options.debug === true) throw err;
1848
+ return /$^/;
1849
+ }
1850
+ };
1851
+ /**
1852
+ * Picomatch constants.
1853
+ * @return {Object}
1854
+ */
1855
+ picomatch$2.constants = constants;
1856
+ /**
1857
+ * Expose "picomatch"
1858
+ */
1859
+ module.exports = picomatch$2;
1860
+ }));
1861
+
1862
+ //#endregion
1863
+ //#region node_modules/picomatch/index.js
1864
+ var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1865
+ const pico = require_picomatch$1();
1866
+ const utils = require_utils();
1867
+ function picomatch$1(glob, options, returnState = false) {
1868
+ if (options && (options.windows === null || options.windows === undefined)) {
1869
+ options = {
1870
+ ...options,
1871
+ windows: utils.isWindows()
1872
+ };
1873
+ }
1874
+ return pico(glob, options, returnState);
1875
+ }
1876
+ Object.assign(picomatch$1, pico);
1877
+ module.exports = picomatch$1;
1878
+ }));
1879
+
1880
+ //#endregion
1881
+ //#region packages/codegen/src/type-filter.ts
1882
+ var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
1883
+ const compileRule = (rule) => {
1884
+ const matcher = (0, import_picomatch.default)(rule.pattern);
1885
+ const categories = rule.category ? Array.isArray(rule.category) ? rule.category : [rule.category] : null;
1886
+ return (context) => {
1887
+ if (categories && !categories.includes(context.category)) {
1888
+ return true;
1889
+ }
1890
+ return !matcher(context.name);
1891
+ };
1892
+ };
1893
+ const compileTypeFilter = (config) => {
1894
+ if (!config) {
1895
+ return () => true;
1896
+ }
1897
+ if (typeof config === "function") {
1898
+ return config;
1899
+ }
1900
+ const rules = config.exclude.map(compileRule);
1901
+ return (context) => rules.every((rule) => rule(context));
1902
+ };
1903
+ const buildExclusionSet = (filter, typeNames) => {
1904
+ const excluded = new Set();
1905
+ for (const [category, names] of typeNames) {
1906
+ for (const name of names) {
1907
+ if (!filter({
1908
+ name,
1909
+ category
1910
+ })) {
1911
+ excluded.add(name);
1912
+ }
1913
+ }
1914
+ }
1915
+ return excluded;
1916
+ };
1917
+
1918
+ //#endregion
1919
+ //#region packages/codegen/src/generator.ts
1920
+ const builtinScalarTypes = new Map([
1921
+ ["ID", {
1922
+ input: "string",
1923
+ output: "string"
1924
+ }],
1925
+ ["String", {
1926
+ input: "string",
1927
+ output: "string"
1928
+ }],
1929
+ ["Int", {
1930
+ input: "number",
1931
+ output: "number"
1932
+ }],
1933
+ ["Float", {
1934
+ input: "number",
1935
+ output: "number"
1936
+ }],
1937
+ ["Boolean", {
1938
+ input: "boolean",
1939
+ output: "boolean"
1940
+ }]
1941
+ ]);
1942
+ const ensureRecord = (collection, key, factory) => {
1943
+ const existing = collection.get(key);
1944
+ if (existing) {
1945
+ return existing;
1946
+ }
1947
+ const created = factory(key);
1948
+ collection.set(key, created);
1949
+ return created;
1950
+ };
1951
+ const addObjectFields = (target, fields) => {
1952
+ if (!fields) {
1953
+ return;
1954
+ }
1955
+ for (const field of fields) {
1956
+ target.set(field.name.value, field);
1957
+ }
1958
+ };
1959
+ const addInputFields = (target, fields) => {
1960
+ if (!fields) {
1961
+ return;
1962
+ }
1963
+ for (const field of fields) {
1964
+ target.set(field.name.value, field);
1965
+ }
1966
+ };
1967
+ const addEnumValues = (target, values) => {
1968
+ if (!values) {
1969
+ return;
1970
+ }
1971
+ for (const value of values) {
1972
+ target.set(value.name.value, value);
1973
+ }
1974
+ };
1975
+ const addUnionMembers = (target, members) => {
1976
+ if (!members) {
1977
+ return;
1978
+ }
1979
+ for (const member of members) {
1980
+ target.set(member.name.value, member);
1981
+ }
1982
+ };
1983
+ const mergeDirectives = (existing, incoming, precedence) => {
1984
+ const current = existing ?? [];
1985
+ const next = incoming ? Array.from(incoming) : [];
1986
+ return precedence === "definition" ? [...next, ...current] : [...current, ...next];
1987
+ };
1988
+ const updateOperationTypes = (operationTypes, definition) => {
1989
+ for (const operation of definition.operationTypes ?? []) {
1990
+ const typeName = operation.type.name.value;
1991
+ switch (operation.operation) {
1992
+ case "query":
1993
+ operationTypes.query = typeName;
1994
+ break;
1995
+ case "mutation":
1996
+ operationTypes.mutation = typeName;
1997
+ break;
1998
+ case "subscription":
1999
+ operationTypes.subscription = typeName;
2000
+ break;
2001
+ default: break;
2002
+ }
2003
+ }
2004
+ };
2005
+ const addDirectiveArgs = (target, args) => {
2006
+ if (!args) {
2007
+ return;
2008
+ }
2009
+ for (const arg of args) {
2010
+ target.set(arg.name.value, arg);
2011
+ }
2012
+ };
2013
+ const createSchemaIndex = (document) => {
2014
+ const objects = new Map();
2015
+ const inputs = new Map();
2016
+ const enums = new Map();
2017
+ const unions = new Map();
2018
+ const scalars = new Map();
2019
+ const directives = new Map();
2020
+ const operationTypes = {};
2021
+ for (const definition of document.definitions) {
2022
+ switch (definition.kind) {
2023
+ case graphql.Kind.OBJECT_TYPE_DEFINITION:
2024
+ case graphql.Kind.OBJECT_TYPE_EXTENSION: {
2025
+ const precedence = definition.kind === graphql.Kind.OBJECT_TYPE_DEFINITION ? "definition" : "extension";
2026
+ const record = ensureRecord(objects, definition.name.value, (name) => ({
2027
+ name,
2028
+ fields: new Map(),
2029
+ directives: []
2030
+ }));
2031
+ addObjectFields(record.fields, definition.fields);
2032
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2033
+ break;
2034
+ }
2035
+ case graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION:
2036
+ case graphql.Kind.INPUT_OBJECT_TYPE_EXTENSION: {
2037
+ const precedence = definition.kind === graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION ? "definition" : "extension";
2038
+ const record = ensureRecord(inputs, definition.name.value, (name) => ({
2039
+ name,
2040
+ fields: new Map(),
2041
+ directives: []
2042
+ }));
2043
+ addInputFields(record.fields, definition.fields);
2044
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2045
+ break;
2046
+ }
2047
+ case graphql.Kind.ENUM_TYPE_DEFINITION:
2048
+ case graphql.Kind.ENUM_TYPE_EXTENSION: {
2049
+ const precedence = definition.kind === graphql.Kind.ENUM_TYPE_DEFINITION ? "definition" : "extension";
2050
+ const record = ensureRecord(enums, definition.name.value, (name) => ({
2051
+ name,
2052
+ values: new Map(),
2053
+ directives: []
2054
+ }));
2055
+ addEnumValues(record.values, definition.values);
2056
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2057
+ break;
2058
+ }
2059
+ case graphql.Kind.UNION_TYPE_DEFINITION:
2060
+ case graphql.Kind.UNION_TYPE_EXTENSION: {
2061
+ const precedence = definition.kind === graphql.Kind.UNION_TYPE_DEFINITION ? "definition" : "extension";
2062
+ const record = ensureRecord(unions, definition.name.value, (name) => ({
2063
+ name,
2064
+ members: new Map(),
2065
+ directives: []
2066
+ }));
2067
+ addUnionMembers(record.members, definition.types);
2068
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2069
+ break;
2070
+ }
2071
+ case graphql.Kind.SCALAR_TYPE_DEFINITION:
2072
+ case graphql.Kind.SCALAR_TYPE_EXTENSION: {
2073
+ const precedence = definition.kind === graphql.Kind.SCALAR_TYPE_DEFINITION ? "definition" : "extension";
2074
+ const record = ensureRecord(scalars, definition.name.value, (name) => ({
2075
+ name,
2076
+ directives: []
2077
+ }));
2078
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2079
+ break;
2080
+ }
2081
+ case graphql.Kind.DIRECTIVE_DEFINITION: {
2082
+ const name = definition.name.value;
2083
+ if (name === "skip" || name === "include" || name === "deprecated" || name === "specifiedBy") {
2084
+ break;
2085
+ }
2086
+ const args = new Map();
2087
+ addDirectiveArgs(args, definition.arguments);
2088
+ directives.set(name, {
2089
+ name,
2090
+ locations: definition.locations.map((loc) => loc.value),
2091
+ args,
2092
+ isRepeatable: definition.repeatable
2093
+ });
2094
+ break;
2095
+ }
2096
+ case graphql.Kind.SCHEMA_DEFINITION:
2097
+ case graphql.Kind.SCHEMA_EXTENSION:
2098
+ updateOperationTypes(operationTypes, definition);
2099
+ break;
2100
+ default: break;
2101
+ }
2102
+ }
2103
+ if (!operationTypes.query && objects.has("Query")) {
2104
+ operationTypes.query = "Query";
2105
+ }
2106
+ if (!operationTypes.mutation && objects.has("Mutation")) {
2107
+ operationTypes.mutation = "Mutation";
2108
+ }
2109
+ if (!operationTypes.subscription && objects.has("Subscription")) {
2110
+ operationTypes.subscription = "Subscription";
2111
+ }
2112
+ return {
2113
+ objects,
2114
+ inputs,
2115
+ enums,
2116
+ unions,
2117
+ scalars,
2118
+ directives,
2119
+ operationTypes
2120
+ };
2121
+ };
2122
+ const collectTypeLevels = (type, nonNull = false, levels = []) => {
2123
+ if (type.kind === graphql.Kind.NON_NULL_TYPE) {
2124
+ return collectTypeLevels(type.type, true, levels);
2125
+ }
2126
+ if (type.kind === graphql.Kind.LIST_TYPE) {
2127
+ levels.push({
2128
+ kind: "list",
2129
+ nonNull
2130
+ });
2131
+ return collectTypeLevels(type.type, false, levels);
2132
+ }
2133
+ levels.push({
2134
+ kind: "named",
2135
+ nonNull
2136
+ });
2137
+ return {
2138
+ name: type.name.value,
2139
+ levels
2140
+ };
2141
+ };
2142
+ const buildTypeModifier = (levels) => {
2143
+ let modifier = "?";
2144
+ for (const level of levels.slice().reverse()) {
2145
+ if (level.kind === "named") {
2146
+ modifier = level.nonNull ? "!" : "?";
2147
+ continue;
2148
+ }
2149
+ const listSuffix = level.nonNull ? "[]!" : "[]?";
2150
+ modifier = `${modifier}${listSuffix}`;
2151
+ }
2152
+ return modifier;
2153
+ };
2154
+ const parseTypeReference = (type) => {
2155
+ const { name, levels } = collectTypeLevels(type);
2156
+ return {
2157
+ name,
2158
+ modifier: buildTypeModifier(levels)
2159
+ };
2160
+ };
2161
+ const isScalarName = (schema, name) => builtinScalarTypes.has(name) || schema.scalars.has(name);
2162
+ const isEnumName = (schema, name) => schema.enums.has(name);
2163
+ const _isInputName = (schema, name) => schema.inputs.has(name);
2164
+ const isUnionName = (schema, name) => schema.unions.has(name);
2165
+ const isObjectName = (schema, name) => schema.objects.has(name);
2166
+ const renderConstValue = (value) => {
2167
+ switch (value.kind) {
2168
+ case graphql.Kind.NULL: return "null";
2169
+ case graphql.Kind.INT:
2170
+ case graphql.Kind.FLOAT: return value.value;
2171
+ case graphql.Kind.STRING:
2172
+ case graphql.Kind.ENUM: return JSON.stringify(value.value);
2173
+ case graphql.Kind.BOOLEAN: return value.value ? "true" : "false";
2174
+ case graphql.Kind.LIST: return `[${value.values.map((item) => renderConstValue(item)).join(", ")}]`;
2175
+ case graphql.Kind.OBJECT: {
2176
+ if (value.fields.length === 0) {
2177
+ return "{}";
2178
+ }
2179
+ const entries = value.fields.map((field) => `${field.name.value}: ${renderConstValue(field.value)}`);
2180
+ return `{ ${entries.join(", ")} }`;
2181
+ }
2182
+ }
2183
+ };
2184
+ const renderInputRef = (schema, definition, excluded) => {
2185
+ const { name, modifier } = parseTypeReference(definition.type);
2186
+ const defaultValue = definition.defaultValue;
2187
+ if (excluded.has(name)) {
2188
+ if (defaultValue) {
2189
+ return `{ kind: "excluded", name: "${name}", modifier: "${modifier}", defaultValue: { default: ${renderConstValue(defaultValue)} } }`;
2190
+ }
2191
+ return `{ kind: "excluded", name: "${name}", modifier: "${modifier}" }`;
2192
+ }
2193
+ let kind;
2194
+ if (isScalarName(schema, name)) {
2195
+ kind = "scalar";
2196
+ } else if (isEnumName(schema, name)) {
2197
+ kind = "enum";
2198
+ } else {
2199
+ kind = "input";
2200
+ }
2201
+ if (defaultValue) {
2202
+ return `{ kind: "${kind}", name: "${name}", modifier: "${modifier}", defaultValue: { default: ${renderConstValue(defaultValue)} } }`;
2203
+ }
2204
+ return `{ kind: "${kind}", name: "${name}", modifier: "${modifier}" }`;
2205
+ };
2206
+ const renderArgumentMap = (schema, args, excluded) => {
2207
+ const entries = [...args ?? []].sort((left, right) => left.name.value.localeCompare(right.name.value)).map((arg) => `${arg.name.value}: ${renderInputRef(schema, arg, excluded)}`);
2208
+ return renderPropertyLines({
2209
+ entries,
2210
+ indentSize: 8
2211
+ });
2212
+ };
2213
+ const renderOutputRef = (schema, type, args, excluded) => {
2214
+ const { name, modifier } = parseTypeReference(type);
2215
+ const argumentMap = renderArgumentMap(schema, args, excluded);
2216
+ if (excluded.has(name)) {
2217
+ return `{ kind: "excluded", name: "${name}", modifier: "${modifier}", arguments: ${argumentMap} }`;
2218
+ }
2219
+ let kind;
2220
+ if (isScalarName(schema, name)) {
2221
+ kind = "scalar";
2222
+ } else if (isEnumName(schema, name)) {
2223
+ kind = "enum";
2224
+ } else if (isUnionName(schema, name)) {
2225
+ kind = "union";
2226
+ } else if (isObjectName(schema, name)) {
2227
+ kind = "object";
2228
+ } else {
2229
+ kind = "scalar";
2230
+ }
2231
+ return `{ kind: "${kind}", name: "${name}", modifier: "${modifier}", arguments: ${argumentMap} }`;
2232
+ };
2233
+ const renderPropertyLines = ({ entries, indentSize }) => {
2234
+ if (entries.length === 0) {
2235
+ return "{}";
2236
+ }
2237
+ const indent = " ".repeat(indentSize);
2238
+ const lastIndent = " ".repeat(indentSize - 2);
2239
+ return [
2240
+ "{",
2241
+ `${indent}${entries.join(`,\n${indent}`)},`,
2242
+ `${lastIndent}}`
2243
+ ].join(`\n`);
2244
+ };
2245
+ const renderObjectFields = (schema, fields, excluded) => {
2246
+ const entries = Array.from(fields.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments, excluded)}`);
2247
+ return renderPropertyLines({
2248
+ entries,
2249
+ indentSize: 6
2250
+ });
2251
+ };
2252
+ const renderInputFields = (schema, fields, excluded) => {
2253
+ const entries = Array.from(fields.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((field) => `${field.name.value}: ${renderInputRef(schema, field, excluded)}`);
2254
+ return renderPropertyLines({
2255
+ entries,
2256
+ indentSize: 6
2257
+ });
2258
+ };
2259
+ const renderScalarVar = (schemaName, record) => {
2260
+ const typeInfo = builtinScalarTypes.get(record.name) ?? {
2261
+ input: "string",
2262
+ output: "string"
2263
+ };
2264
+ return `const scalar_${schemaName}_${record.name} = { name: "${record.name}", $type: {} as { input: ${typeInfo.input}; output: ${typeInfo.output}; inputProfile: { kind: "scalar"; name: "${record.name}"; value: ${typeInfo.input} }; outputProfile: { kind: "scalar"; name: "${record.name}"; value: ${typeInfo.output} } } } as const;`;
2265
+ };
2266
+ const renderEnumVar = (schemaName, record) => {
2267
+ const valueNames = Array.from(record.values.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((value) => value.name.value);
2268
+ const valuesObj = valueNames.length === 0 ? "{}" : `{ ${valueNames.map((v) => `${v}: true`).join(", ")} }`;
2269
+ const valueUnion = valueNames.length === 0 ? "never" : valueNames.map((v) => `"${v}"`).join(" | ");
2270
+ return `const enum_${schemaName}_${record.name} = defineEnum<"${record.name}", ${valueUnion}>("${record.name}", ${valuesObj});`;
2271
+ };
2272
+ const renderInputVar = (schemaName, schema, record, excluded) => {
2273
+ const fields = renderInputFields(schema, record.fields, excluded);
2274
+ return `const input_${schemaName}_${record.name} = { name: "${record.name}", fields: ${fields} } as const;`;
2275
+ };
2276
+ const renderObjectVar = (schemaName, schema, record, excluded) => {
2277
+ const fields = renderObjectFields(schema, record.fields, excluded);
2278
+ return `const object_${schemaName}_${record.name} = { name: "${record.name}", fields: ${fields} } as const;`;
2279
+ };
2280
+ const renderUnionVar = (schemaName, record, excluded) => {
2281
+ const memberNames = Array.from(record.members.values()).filter((member) => !excluded.has(member.name.value)).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((member) => member.name.value);
2282
+ const typesObj = memberNames.length === 0 ? "{}" : `{ ${memberNames.map((m) => `${m}: true`).join(", ")} }`;
2283
+ return `const union_${schemaName}_${record.name} = { name: "${record.name}", types: ${typesObj} } as const;`;
2284
+ };
2285
+ const collectObjectTypeNames = (schema) => Array.from(schema.objects.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2286
+ const renderFragmentBuildersType = (objectTypeNames, schemaName, adapterTypeName) => {
2287
+ if (objectTypeNames.length === 0) {
2288
+ return `type FragmentBuilders_${schemaName} = Record<string, never>;`;
2289
+ }
2290
+ const adapterPart = adapterTypeName ? `, ExtractMetadataAdapter<${adapterTypeName}>` : "";
2291
+ const entries = objectTypeNames.map((name) => ` readonly ${name}: FragmentBuilderFor<Schema_${schemaName}, "${name}"${adapterPart}>`);
2292
+ return `type FragmentBuilders_${schemaName} = {\n${entries.join(";\n")};\n};`;
2293
+ };
2294
+ const collectInputTypeNames = (schema) => Array.from(schema.inputs.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2295
+ const collectEnumTypeNames = (schema) => Array.from(schema.enums.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2296
+ const collectUnionTypeNames = (schema) => Array.from(schema.unions.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2297
+ const collectScalarNames = (schema) => Array.from(schema.scalars.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2298
+ const collectDirectiveNames = (schema) => Array.from(schema.directives.keys()).sort((left, right) => left.localeCompare(right));
2299
+ const renderInputTypeMethod = (factoryVar, kind, typeName) => `${typeName}: ${factoryVar}("${kind}", "${typeName}")`;
2300
+ const renderInputTypeMethods = (schema, factoryVar, excluded) => {
2301
+ const scalarMethods = Array.from(builtinScalarTypes.keys()).concat(collectScalarNames(schema).filter((name) => !builtinScalarTypes.has(name))).filter((name) => !excluded.has(name)).map((name) => renderInputTypeMethod(factoryVar, "scalar", name));
2302
+ const enumMethods = collectEnumTypeNames(schema).filter((name) => !excluded.has(name)).map((name) => renderInputTypeMethod(factoryVar, "enum", name));
2303
+ const inputMethods = collectInputTypeNames(schema).filter((name) => !excluded.has(name)).map((name) => renderInputTypeMethod(factoryVar, "input", name));
2304
+ const allMethods = [
2305
+ ...scalarMethods,
2306
+ ...enumMethods,
2307
+ ...inputMethods
2308
+ ].sort((left, right) => {
2309
+ const leftName = left.split(":")[0] ?? "";
2310
+ const rightName = right.split(":")[0] ?? "";
2311
+ return leftName.localeCompare(rightName);
2312
+ });
2313
+ return renderPropertyLines({
2314
+ entries: allMethods,
2315
+ indentSize: 2
2316
+ });
2317
+ };
2318
+ /**
2319
+ * Renders argument specifiers for a directive.
2320
+ * Returns null if the directive has no arguments.
2321
+ */
2322
+ const renderDirectiveArgsSpec = (schema, args, excluded) => {
2323
+ if (args.size === 0) return null;
2324
+ const entries = Array.from(args.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((arg) => `${arg.name.value}: ${renderInputRef(schema, arg, excluded)}`);
2325
+ return renderPropertyLines({
2326
+ entries,
2327
+ indentSize: 4
2328
+ });
2329
+ };
2330
+ const renderDirectiveMethod = (schema, record, excluded) => {
2331
+ const locationsJson = JSON.stringify(record.locations);
2332
+ const argsSpec = renderDirectiveArgsSpec(schema, record.args, excluded);
2333
+ if (argsSpec === null) {
2334
+ return `${record.name}: createDirectiveMethod("${record.name}", ${locationsJson} as const)`;
2335
+ }
2336
+ return `${record.name}: createTypedDirectiveMethod("${record.name}", ${locationsJson} as const, ${argsSpec})`;
2337
+ };
2338
+ const renderDirectiveMethods = (schema, excluded) => {
2339
+ const directiveNames = collectDirectiveNames(schema);
2340
+ if (directiveNames.length === 0) {
2341
+ return "{}";
2342
+ }
2343
+ const methods = directiveNames.map((name) => {
2344
+ const record = schema.directives.get(name);
2345
+ return record ? renderDirectiveMethod(schema, record, excluded) : null;
2346
+ }).filter((method) => method !== null);
2347
+ return renderPropertyLines({
2348
+ entries: methods,
2349
+ indentSize: 2
2350
+ });
2351
+ };
2352
+ /**
2353
+ * Generates the _internal-injects.ts module code.
2354
+ * This file contains only adapter imports (scalar, adapter) to keep it lightweight.
2355
+ * The heavy schema types remain in _internal.ts.
2356
+ */
2357
+ const generateInjectsCode = (injection) => {
2358
+ const imports = [];
2359
+ const exports$1 = [];
2360
+ const typeExports = [];
2361
+ const importsByPath = new Map();
2362
+ for (const [schemaName, config] of injection) {
2363
+ const scalarAlias = `scalar_${schemaName}`;
2364
+ const scalarSpecifiers = importsByPath.get(config.scalarImportPath) ?? [];
2365
+ if (!importsByPath.has(config.scalarImportPath)) {
2366
+ importsByPath.set(config.scalarImportPath, scalarSpecifiers);
2367
+ }
2368
+ scalarSpecifiers.push(`scalar as ${scalarAlias}`);
2369
+ exports$1.push(`export { ${scalarAlias} };`);
2370
+ typeExports.push(`export type Scalar_${schemaName} = typeof ${scalarAlias};`);
2371
+ if (config.adapterImportPath) {
2372
+ const adapterAlias = `adapter_${schemaName}`;
2373
+ const adapterSpecifiers = importsByPath.get(config.adapterImportPath) ?? [];
2374
+ if (!importsByPath.has(config.adapterImportPath)) {
2375
+ importsByPath.set(config.adapterImportPath, adapterSpecifiers);
2376
+ }
2377
+ adapterSpecifiers.push(`adapter as ${adapterAlias}`);
2378
+ exports$1.push(`export { ${adapterAlias} };`);
2379
+ typeExports.push(`export type Adapter_${schemaName} = typeof ${adapterAlias} & { _?: never };`);
2380
+ }
2381
+ }
2382
+ for (const [path, specifiers] of importsByPath) {
2383
+ if (specifiers.length === 1) {
2384
+ imports.push(`import { ${specifiers[0]} } from "${path}";`);
2385
+ } else {
2386
+ imports.push(`import {\n ${specifiers.join(",\n ")},\n} from "${path}";`);
2387
+ }
2388
+ }
2389
+ return `\
2390
+ /**
2391
+ * Adapter injections for schema.
2392
+ * Separated to allow lightweight imports for prebuilt module.
2393
+ * @generated by @soda-gql/codegen
2394
+ */
2395
+
2396
+ ${imports.join("\n")}
2397
+
2398
+ // Value exports
2399
+ ${exports$1.join("\n")}
2400
+
2401
+ // Type exports
2402
+ ${typeExports.join("\n")}
2403
+ `;
2404
+ };
2405
+ const multiRuntimeTemplate = ($$) => {
2406
+ const imports = [];
2407
+ const scalarAliases = new Map();
2408
+ const adapterAliases = new Map();
2409
+ if ($$.injection.mode === "inject") {
2410
+ const injectsImports = [];
2411
+ for (const [schemaName, injection] of $$.injection.perSchema) {
2412
+ const scalarAlias = `scalar_${schemaName}`;
2413
+ scalarAliases.set(schemaName, scalarAlias);
2414
+ injectsImports.push(scalarAlias);
2415
+ if (injection.adapterImportPath) {
2416
+ const adapterAlias = `adapter_${schemaName}`;
2417
+ adapterAliases.set(schemaName, adapterAlias);
2418
+ injectsImports.push(adapterAlias);
2419
+ }
2420
+ }
2421
+ imports.push(`import { ${injectsImports.join(", ")} } from "${$$.injection.injectsModulePath}";`);
2422
+ }
2423
+ {
2424
+ const { importPaths } = $$.splitting;
2425
+ for (const [name, config] of Object.entries($$.schemas)) {
2426
+ if (config.enumNames.length > 0) {
2427
+ const enumImports = config.enumNames.map((n) => `enum_${name}_${n}`).join(", ");
2428
+ imports.push(`import { ${enumImports} } from "${importPaths.enums}";`);
2429
+ }
2430
+ if (config.inputNames.length > 0) {
2431
+ const inputImports = config.inputNames.map((n) => `input_${name}_${n}`).join(", ");
2432
+ imports.push(`import { ${inputImports} } from "${importPaths.inputs}";`);
2433
+ }
2434
+ if (config.objectNames.length > 0) {
2435
+ const objectImports = config.objectNames.map((n) => `object_${name}_${n}`).join(", ");
2436
+ imports.push(`import { ${objectImports} } from "${importPaths.objects}";`);
2437
+ }
2438
+ if (config.unionNames.length > 0) {
2439
+ const unionImports = config.unionNames.map((n) => `union_${name}_${n}`).join(", ");
2440
+ imports.push(`import { ${unionImports} } from "${importPaths.unions}";`);
2441
+ }
2442
+ }
2443
+ }
2444
+ const extraImports = imports.length > 0 ? `${imports.join("\n")}\n` : "";
2445
+ const schemaBlocks = [];
2446
+ const gqlEntries = [];
2447
+ for (const [name, config] of Object.entries($$.schemas)) {
2448
+ const schemaVar = `${name}Schema`;
2449
+ const adapterVar = adapterAliases.get(name);
2450
+ const typeExports = [`export type Schema_${name} = typeof ${schemaVar} & { _?: never };`];
2451
+ if (adapterVar) {
2452
+ typeExports.push(`export type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);
2453
+ }
2454
+ typeExports.push(config.fragmentBuildersTypeBlock);
2455
+ const inputTypeMethodsVar = `inputTypeMethods_${name}`;
2456
+ const factoryVar = `createMethod_${name}`;
2457
+ const customDirectivesVar = `customDirectives_${name}`;
2458
+ const defaultDepthBlock = config.defaultInputDepth !== undefined && config.defaultInputDepth !== 3 ? `\n __defaultInputDepth: ${config.defaultInputDepth},` : "";
2459
+ const depthOverridesBlock = config.inputDepthOverrides && Object.keys(config.inputDepthOverrides).length > 0 ? `\n __inputDepthOverrides: ${JSON.stringify(config.inputDepthOverrides)},` : "";
2460
+ const isSplitMode = true;
2461
+ const scalarVarsBlock = config.scalarVars.join("\n");
2462
+ const enumVarsBlock = isSplitMode ? "// (enums imported)" : config.enumVars.length > 0 ? config.enumVars.join("\n") : "// (no enums)";
2463
+ const inputVarsBlock = isSplitMode ? "// (inputs imported)" : config.inputVars.length > 0 ? config.inputVars.join("\n") : "// (no inputs)";
2464
+ const objectVarsBlock = isSplitMode ? "// (objects imported)" : config.objectVars.length > 0 ? config.objectVars.join("\n") : "// (no objects)";
2465
+ const unionVarsBlock = isSplitMode ? "// (unions imported)" : config.unionVars.length > 0 ? config.unionVars.join("\n") : "// (no unions)";
2466
+ const scalarAssembly = $$.injection.mode === "inject" ? scalarAliases.get(name) ?? "{}" : config.scalarNames.length > 0 ? `{ ${config.scalarNames.map((n) => `${n}: scalar_${name}_${n}`).join(", ")} }` : "{}";
2467
+ const enumAssembly = config.enumNames.length > 0 ? `{ ${config.enumNames.map((n) => `${n}: enum_${name}_${n}`).join(", ")} }` : "{}";
2468
+ const inputAssembly = config.inputNames.length > 0 ? `{ ${config.inputNames.map((n) => `${n}: input_${name}_${n}`).join(", ")} }` : "{}";
2469
+ const objectAssembly = config.objectNames.length > 0 ? `{ ${config.objectNames.map((n) => `${n}: object_${name}_${n}`).join(", ")} }` : "{}";
2470
+ const unionAssembly = config.unionNames.length > 0 ? `{ ${config.unionNames.map((n) => `${n}: union_${name}_${n}`).join(", ")} }` : "{}";
2471
+ const scalarVarsSection = $$.injection.mode === "inject" ? "// (scalars imported)" : scalarVarsBlock;
2472
+ const scalarAssemblyLine = $$.injection.mode === "inject" ? `// scalar_${name} is imported directly` : `const scalar_${name} = ${scalarAssembly} as const;`;
2473
+ const scalarRef = $$.injection.mode === "inject" ? scalarAliases.get(name) ?? `scalar_${name}` : `scalar_${name}`;
2474
+ schemaBlocks.push(`
2475
+ // Individual scalar definitions
2476
+ ${scalarVarsSection}
2477
+
2478
+ // Individual enum definitions
2479
+ ${enumVarsBlock}
2480
+
2481
+ // Individual input definitions
2482
+ ${inputVarsBlock}
2483
+
2484
+ // Individual object definitions
2485
+ ${objectVarsBlock}
2486
+
2487
+ // Individual union definitions
2488
+ ${unionVarsBlock}
2489
+
2490
+ // Category assembly
2491
+ ${scalarAssemblyLine}
2492
+ const enum_${name} = ${enumAssembly} as const;
2493
+ const input_${name} = ${inputAssembly} as const;
2494
+ const object_${name} = ${objectAssembly} as const;
2495
+ const union_${name} = ${unionAssembly} as const;
2496
+
2497
+ // Schema assembly
2498
+ const ${schemaVar} = {
2499
+ label: "${name}" as const,
2500
+ operations: { query: "${config.queryType}", mutation: "${config.mutationType}", subscription: "${config.subscriptionType}" } as const,
2501
+ scalar: ${scalarRef},
2502
+ enum: enum_${name},
2503
+ input: input_${name},
2504
+ object: object_${name},
2505
+ union: union_${name},${defaultDepthBlock}${depthOverridesBlock}
2506
+ } as const;
2507
+
2508
+ const ${factoryVar} = createVarMethodFactory<typeof ${schemaVar}>();
2509
+ const ${inputTypeMethodsVar} = ${config.inputTypeMethodsBlock};
2510
+ const ${customDirectivesVar} = { ...createStandardDirectives(), ...${config.directiveMethodsBlock} };
2511
+
2512
+ ${typeExports.join("\n")}`);
2513
+ const gqlVarName = `gql_${name}`;
2514
+ if (adapterVar) {
2515
+ const typeParams = `<Schema_${name}, FragmentBuilders_${name}, typeof ${customDirectivesVar}, Adapter_${name}>`;
2516
+ schemaBlocks.push(`const ${gqlVarName} = createGqlElementComposer${typeParams}(${schemaVar}, { adapter: ${adapterVar}, inputTypeMethods: ${inputTypeMethodsVar}, directiveMethods: ${customDirectivesVar} });`);
2517
+ } else {
2518
+ const typeParams = `<Schema_${name}, FragmentBuilders_${name}, typeof ${customDirectivesVar}>`;
2519
+ schemaBlocks.push(`const ${gqlVarName} = createGqlElementComposer${typeParams}(${schemaVar}, { inputTypeMethods: ${inputTypeMethodsVar}, directiveMethods: ${customDirectivesVar} });`);
2520
+ }
2521
+ schemaBlocks.push(`export type Context_${name} = Parameters<typeof ${gqlVarName}>[0] extends (ctx: infer C) => unknown ? C : never;`);
2522
+ const prebuiltExports = [
2523
+ `export { ${schemaVar} as __schema_${name} }`,
2524
+ `export { ${inputTypeMethodsVar} as __inputTypeMethods_${name} }`,
2525
+ `export { ${customDirectivesVar} as __directiveMethods_${name} }`
2526
+ ];
2527
+ if (adapterVar) {
2528
+ prebuiltExports.push(`export { ${adapterVar} as __adapter_${name} }`);
2529
+ }
2530
+ schemaBlocks.push(`${prebuiltExports.join(";\n")};`);
2531
+ gqlEntries.push(` ${name}: ${gqlVarName}`);
2532
+ }
2533
+ const needsDefineEnum = false;
2534
+ return `\
2535
+ import {${needsDefineEnum ? "\n defineEnum," : ""}
2536
+ type ExtractMetadataAdapter,
2537
+ type FragmentBuilderFor,
2538
+ createDirectiveMethod,
2539
+ createTypedDirectiveMethod,
2540
+ createGqlElementComposer,
2541
+ createStandardDirectives,
2542
+ createVarMethodFactory,
2543
+ } from "@soda-gql/core";
2544
+ ${extraImports}
2545
+ ${schemaBlocks.join("\n")}
2546
+
2547
+ export const gql = {
2548
+ ${gqlEntries.join(",\n")}
2549
+ };
2550
+ `;
2551
+ };
2552
+ const generateMultiSchemaModule = (schemas, options) => {
2553
+ const schemaConfigs = {};
2554
+ const allStats = {
2555
+ objects: 0,
2556
+ enums: 0,
2557
+ inputs: 0,
2558
+ unions: 0
2559
+ };
2560
+ for (const [name, document] of schemas.entries()) {
2561
+ const schema = createSchemaIndex(document);
2562
+ const typeFilterConfig = options?.typeFilters?.get(name);
2563
+ const typeFilter = compileTypeFilter(typeFilterConfig);
2564
+ const allTypeNames = new Map([
2565
+ ["object", Array.from(schema.objects.keys()).filter((n) => !n.startsWith("__"))],
2566
+ ["input", Array.from(schema.inputs.keys()).filter((n) => !n.startsWith("__"))],
2567
+ ["enum", Array.from(schema.enums.keys()).filter((n) => !n.startsWith("__"))],
2568
+ ["union", Array.from(schema.unions.keys()).filter((n) => !n.startsWith("__"))],
2569
+ ["scalar", Array.from(schema.scalars.keys()).filter((n) => !n.startsWith("__"))]
2570
+ ]);
2571
+ const excluded = buildExclusionSet(typeFilter, allTypeNames);
2572
+ const objectTypeNames = collectObjectTypeNames(schema).filter((n) => !excluded.has(n));
2573
+ const enumTypeNames = collectEnumTypeNames(schema).filter((n) => !excluded.has(n));
2574
+ const inputTypeNames = collectInputTypeNames(schema).filter((n) => !excluded.has(n));
2575
+ const unionTypeNames = collectUnionTypeNames(schema).filter((n) => !excluded.has(n));
2576
+ const customScalarNames = collectScalarNames(schema).filter((n) => !builtinScalarTypes.has(n) && !excluded.has(n));
2577
+ const scalarVars = [];
2578
+ const enumVars = [];
2579
+ const inputVars = [];
2580
+ const objectVars = [];
2581
+ const unionVars = [];
2582
+ for (const scalarName of builtinScalarTypes.keys()) {
2583
+ const record = schema.scalars.get(scalarName) ?? {
2584
+ name: scalarName,
2585
+ directives: []
2586
+ };
2587
+ scalarVars.push(renderScalarVar(name, record));
2588
+ }
2589
+ for (const scalarName of customScalarNames) {
2590
+ const record = schema.scalars.get(scalarName);
2591
+ if (record) {
2592
+ scalarVars.push(renderScalarVar(name, record));
2593
+ }
2594
+ }
2595
+ for (const enumName of enumTypeNames) {
2596
+ const record = schema.enums.get(enumName);
2597
+ if (record) {
2598
+ enumVars.push(renderEnumVar(name, record));
2599
+ }
2600
+ }
2601
+ for (const inputName of inputTypeNames) {
2602
+ const record = schema.inputs.get(inputName);
2603
+ if (record) {
2604
+ inputVars.push(renderInputVar(name, schema, record, excluded));
2605
+ }
2606
+ }
2607
+ for (const objectName of objectTypeNames) {
2608
+ const record = schema.objects.get(objectName);
2609
+ if (record) {
2610
+ objectVars.push(renderObjectVar(name, schema, record, excluded));
2611
+ }
2612
+ }
2613
+ for (const unionName of unionTypeNames) {
2614
+ const record = schema.unions.get(unionName);
2615
+ if (record) {
2616
+ unionVars.push(renderUnionVar(name, record, excluded));
2617
+ }
2618
+ }
2619
+ const allScalarNames = [...builtinScalarTypes.keys(), ...customScalarNames];
2620
+ const factoryVar = `createMethod_${name}`;
2621
+ const inputTypeMethodsBlock = renderInputTypeMethods(schema, factoryVar, excluded);
2622
+ const directiveMethodsBlock = renderDirectiveMethods(schema, excluded);
2623
+ const adapterTypeName = options?.injection?.get(name)?.adapterImportPath ? `Adapter_${name}` : undefined;
2624
+ const fragmentBuildersTypeBlock = renderFragmentBuildersType(objectTypeNames, name, adapterTypeName);
2625
+ const queryType = schema.operationTypes.query ?? "Query";
2626
+ const mutationType = schema.operationTypes.mutation ?? "Mutation";
2627
+ const subscriptionType = schema.operationTypes.subscription ?? "Subscription";
2628
+ schemaConfigs[name] = {
2629
+ queryType,
2630
+ mutationType,
2631
+ subscriptionType,
2632
+ scalarVars,
2633
+ enumVars,
2634
+ inputVars,
2635
+ objectVars,
2636
+ unionVars,
2637
+ scalarNames: allScalarNames,
2638
+ enumNames: enumTypeNames,
2639
+ inputNames: inputTypeNames,
2640
+ objectNames: objectTypeNames,
2641
+ unionNames: unionTypeNames,
2642
+ inputTypeMethodsBlock,
2643
+ directiveMethodsBlock,
2644
+ fragmentBuildersTypeBlock,
2645
+ defaultInputDepth: options?.defaultInputDepth?.get(name),
2646
+ inputDepthOverrides: options?.inputDepthOverrides?.get(name)
2647
+ };
2648
+ allStats.objects += objectVars.length;
2649
+ allStats.enums += enumVars.length;
2650
+ allStats.inputs += inputVars.length;
2651
+ allStats.unions += unionVars.length;
2652
+ }
2653
+ const injection = options?.injection ? {
2654
+ mode: "inject",
2655
+ perSchema: options.injection,
2656
+ injectsModulePath: "./_internal-injects"
2657
+ } : { mode: "inline" };
2658
+ const splitting = { importPaths: {
2659
+ enums: "./_defs/enums",
2660
+ inputs: "./_defs/inputs",
2661
+ objects: "./_defs/objects",
2662
+ unions: "./_defs/unions"
2663
+ } };
2664
+ const code = multiRuntimeTemplate({
2665
+ schemas: schemaConfigs,
2666
+ injection,
2667
+ splitting
2668
+ });
2669
+ const injectsCode = options?.injection ? generateInjectsCode(options.injection) : undefined;
2670
+ const categoryVarsResult = Object.fromEntries(Object.entries(schemaConfigs).map(([schemaName, config]) => {
2671
+ const toDefVar = (code$1, prefix) => {
2672
+ const match = code$1.match(new RegExp(`const (${prefix}_${schemaName}_(\\w+))`));
2673
+ return {
2674
+ name: match?.[1] ?? "",
2675
+ code: code$1
2676
+ };
2677
+ };
2678
+ return [schemaName, {
2679
+ enums: config.enumVars.map((c) => toDefVar(c, "enum")),
2680
+ inputs: config.inputVars.map((c) => toDefVar(c, "input")),
2681
+ objects: config.objectVars.map((c) => toDefVar(c, "object")),
2682
+ unions: config.unionVars.map((c) => toDefVar(c, "union"))
2683
+ }];
2684
+ }));
2685
+ return {
2686
+ code,
2687
+ injectsCode,
2688
+ categoryVars: categoryVarsResult,
2689
+ stats: allStats
2690
+ };
2691
+ };
2692
+
2693
+ //#endregion
2694
+ Object.defineProperty(exports, '__toESM', {
2695
+ enumerable: true,
2696
+ get: function () {
2697
+ return __toESM;
2698
+ }
2699
+ });
2700
+ Object.defineProperty(exports, 'createSchemaIndex', {
2701
+ enumerable: true,
2702
+ get: function () {
2703
+ return createSchemaIndex;
2704
+ }
2705
+ });
2706
+ Object.defineProperty(exports, 'generateMultiSchemaModule', {
2707
+ enumerable: true,
2708
+ get: function () {
2709
+ return generateMultiSchemaModule;
2710
+ }
2711
+ });
2712
+ //# sourceMappingURL=generator-Bnw2f2xB.cjs.map