@soda-gql/codegen 0.12.0 → 0.12.2

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