@savvy-web/pnpm-plugin-silk 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/pnpmfile.cjs CHANGED
@@ -1,163 +1,1680 @@
1
+ /*! For license information please see pnpmfile.cjs.LICENSE.txt */
1
2
  "use strict";
2
- var __webpack_exports__ = {};
3
- const silkCatalogs = {
4
- silk: {
5
- "@changesets/cli": "^2.29.8",
6
- "@commitlint/cli": "^20.4.1",
7
- "@commitlint/config-conventional": "^20.4.1",
8
- "@microsoft/api-extractor": "^7.56.2",
9
- "@rslib/core": "^0.19.4",
10
- "@types/node": "^25.2.0",
11
- "@typescript/native-preview": "^7.0.0-dev.20260203.1",
12
- "@vitest/coverage-v8": "^4.0.18",
13
- commitizen: "^4.3.1",
14
- husky: "^9.1.7",
15
- "lint-staged": "^16.2.7",
16
- "markdownlint-cli2": "^0.20.0",
17
- "markdownlint-cli2-formatter-codequality": "^0.0.7",
18
- tsx: "^4.21.0",
19
- turbo: "^2.8.3",
20
- typescript: "^5.9.3",
21
- vitest: "^4.0.18"
22
- },
23
- silkPeers: {
24
- "@biomejs/biome": "^2.3.12",
25
- "@commitlint/cli": "^20.4.1",
26
- "@commitlint/config-conventional": "^20.4.1",
27
- "@microsoft/api-extractor": "^7.56.2",
28
- "@types/node": "^25.0.10",
29
- "@typescript/native-preview": "^7.0.0-dev.20260124.1",
30
- commitizen: "^4.3.1",
31
- husky: "^9.1.7",
32
- typescript: "^5.9.3"
33
- },
34
- silkOverrides: {
35
- "@isaacs/brace-expansion": ">=5.0.1",
36
- lodash: ">=4.17.23",
37
- tmp: ">=0.2.4"
3
+ var __webpack_modules__ = {
4
+ "./node_modules/.pnpm/parse-gitignore@2.0.0/node_modules/parse-gitignore/index.js" (module1, __unused_rspack_exports, __webpack_require__) {
5
+ /*!
6
+ * parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>
7
+ * Copyright (c) 2015-present, Jon Schlinkert.
8
+ * Released under the MIT License.
9
+ */ const fs = __webpack_require__("fs");
10
+ const isObject = (v)=>null !== v && 'object' == typeof v && !Array.isArray(v);
11
+ const INVALID_PATH_CHARS_REGEX = /[<>:"|?*\n\r\t\f\x00-\x1F]/;
12
+ const GLOBSTAR_REGEX = /(?:^|\/)[*]{2}($|\/)/;
13
+ const MAX_PATH_LENGTH = 248;
14
+ const isValidPath = (input)=>{
15
+ if ('string' == typeof input) return input.length <= MAX_PATH_LENGTH && !INVALID_PATH_CHARS_REGEX.test(input);
16
+ return false;
17
+ };
18
+ const split = (str)=>String(str).split(/\r\n?|\n/);
19
+ const isComment = (str)=>str.startsWith('#');
20
+ const isParsed = (input)=>isObject(input) && input.patterns && input.sections;
21
+ const patterns = (input)=>split(input).map((l)=>l.trim()).filter((line)=>'' !== line && !isComment(line));
22
+ const parse = (input, options = {})=>{
23
+ let filepath = options.path;
24
+ if (isParsed(input)) return input;
25
+ if (isValidPath(input) && fs.existsSync(input)) {
26
+ filepath = input;
27
+ input = fs.readFileSync(input);
28
+ }
29
+ const lines = split(input);
30
+ const names = new Map();
31
+ let parsed = {
32
+ sections: [],
33
+ patterns: []
34
+ };
35
+ let section = {
36
+ name: 'default',
37
+ patterns: []
38
+ };
39
+ let prev;
40
+ for (const line of lines){
41
+ const value = line.trim();
42
+ if (value.startsWith('#')) {
43
+ const [, name] = /^#+\s*(.*)\s*$/.exec(value);
44
+ if (prev) {
45
+ names.delete(prev.name);
46
+ prev.comment += value ? `\n${value}` : '';
47
+ prev.name = name ? `${prev.name.trim()}\n${name.trim()}` : prev.name.trim();
48
+ names.set(prev.name.toLowerCase().trim(), prev);
49
+ continue;
50
+ }
51
+ section = {
52
+ name: name.trim(),
53
+ comment: value,
54
+ patterns: []
55
+ };
56
+ names.set(section.name.toLowerCase(), section);
57
+ parsed.sections.push(section);
58
+ prev = section;
59
+ continue;
60
+ }
61
+ if ('' !== value) {
62
+ section.patterns.push(value);
63
+ parsed.patterns.push(value);
64
+ }
65
+ prev = null;
66
+ }
67
+ if (true === options.dedupe || true === options.unique) parsed = dedupe(parsed, {
68
+ ...options,
69
+ format: false
70
+ });
71
+ parsed.path = filepath;
72
+ parsed.input = Buffer.from(input);
73
+ parsed.format = (opts)=>format(parsed, {
74
+ ...options,
75
+ ...opts
76
+ });
77
+ parsed.dedupe = (opts)=>dedupe(parsed, {
78
+ ...options,
79
+ ...opts
80
+ });
81
+ parsed.globs = (opts)=>globs(parsed, {
82
+ path: filepath,
83
+ ...options,
84
+ ...opts
85
+ });
86
+ return parsed;
87
+ };
88
+ const parseFile = (filepath, options)=>parse(fs.readFileSync(filepath, 'utf8'), options);
89
+ const dedupe = (input, options)=>{
90
+ const parsed = parse(input, {
91
+ ...options,
92
+ dedupe: false
93
+ });
94
+ const names = new Map();
95
+ const res = {
96
+ sections: [],
97
+ patterns: new Set()
98
+ };
99
+ let current;
100
+ for (const section of parsed.sections){
101
+ const { name = '', comment, patterns } = section;
102
+ const key = name.trim().toLowerCase();
103
+ for (const pattern of patterns)res.patterns.add(pattern);
104
+ if (name && names.has(key)) {
105
+ current = names.get(key);
106
+ current.patterns = [
107
+ ...current.patterns,
108
+ ...patterns
109
+ ];
110
+ } else {
111
+ current = {
112
+ name,
113
+ comment,
114
+ patterns
115
+ };
116
+ res.sections.push(current);
117
+ names.set(key, current);
118
+ }
119
+ }
120
+ for (const section of res.sections)section.patterns = [
121
+ ...new Set(section.patterns)
122
+ ];
123
+ res.patterns = [
124
+ ...res.patterns
125
+ ];
126
+ return res;
127
+ };
128
+ const glob = (pattern, options)=>{
129
+ if (GLOBSTAR_REGEX.test(pattern)) return pattern;
130
+ let relative = false;
131
+ if (pattern.startsWith('/')) {
132
+ pattern = pattern.slice(1);
133
+ relative = true;
134
+ } else if (pattern.slice(1, pattern.length - 1).includes('/')) relative = true;
135
+ pattern += pattern.endsWith('/') ? '**/' : '/**';
136
+ return relative ? pattern : `**/${pattern}`;
137
+ };
138
+ const globs = (input, options = {})=>{
139
+ const parsed = parse(input, options);
140
+ const result = [];
141
+ let index = 0;
142
+ const patterns = parsed.patterns.concat(options.ignore || []).concat((options.unignore || []).map((p)=>p.startsWith('!') ? p : '!' + p));
143
+ const push = (prefix, pattern)=>{
144
+ const prev = result[result.length - 1];
145
+ const type = prefix ? 'unignore' : 'ignore';
146
+ if (prev && prev.type === type) {
147
+ if (!prev.patterns.includes(pattern)) prev.patterns.push(pattern);
148
+ } else {
149
+ result.push({
150
+ type,
151
+ path: options.path || null,
152
+ patterns: [
153
+ pattern
154
+ ],
155
+ index
156
+ });
157
+ index++;
158
+ }
159
+ };
160
+ for (let pattern of patterns){
161
+ let prefix = '';
162
+ if (pattern.startsWith('!')) {
163
+ pattern = pattern.slice(1);
164
+ prefix = '!';
165
+ }
166
+ push(prefix, pattern.startsWith('/') ? pattern.slice(1) : pattern);
167
+ push(prefix, glob(pattern));
168
+ }
169
+ return result;
170
+ };
171
+ const formatSection = (section = {})=>{
172
+ const output = [
173
+ section.comment || ''
174
+ ];
175
+ if (section.patterns?.length) {
176
+ output.push(section.patterns.join('\n'));
177
+ output.push('');
178
+ }
179
+ return output.join('\n');
180
+ };
181
+ const format = (input, options = {})=>{
182
+ const parsed = parse(input, options);
183
+ const fn = options.formatSection || formatSection;
184
+ const sections = parsed.sections || parsed;
185
+ const output = [];
186
+ for (const section of [].concat(sections))output.push(fn(section));
187
+ return output.join('\n');
188
+ };
189
+ parse.file = parseFile;
190
+ parse.parse = parse;
191
+ parse.dedupe = dedupe;
192
+ parse.format = format;
193
+ parse.globs = globs;
194
+ parse.formatSection = formatSection;
195
+ parse.patterns = patterns;
196
+ module1.exports = parse;
38
197
  },
39
- silkOnlyBuiltDependencies: [
40
- "@parcel/watcher",
41
- "@savvy-web/commitlint",
42
- "@savvy-web/lint-staged",
43
- "core-js",
44
- "esbuild",
45
- "msgpackr-extract"
46
- ],
47
- silkPublicHoistPattern: [
48
- "@commitlint/cli",
49
- "@commitlint/config-conventional",
50
- "@commitlint/cz-commitlint",
51
- "@microsoft/api-extractor",
52
- "@rslib/core",
53
- "@typescript/native-preview",
54
- "husky",
55
- "lint-staged",
56
- "markdownlint-cli2",
57
- "markdownlint-cli2-formatter-codequality",
58
- "turbo",
59
- "typescript"
60
- ]
61
- };
62
- const WARNING_BOX_WIDTH = 75;
63
- function formatOverrideWarning(overrides) {
64
- if (0 === overrides.length) return "";
65
- const lines = [];
66
- const border = "─".repeat(WARNING_BOX_WIDTH - 2);
67
- lines.push(`┌${border}┐`);
68
- lines.push(`│ ⚠️ SILK CATALOG OVERRIDE DETECTED${" ".repeat(WARNING_BOX_WIDTH - 39)}│`);
69
- lines.push(`├${border}┤`);
70
- lines.push(`│ The following entries override Silk-managed versions:${" ".repeat(WARNING_BOX_WIDTH - 58)}│`);
71
- lines.push(`│${" ".repeat(WARNING_BOX_WIDTH - 2)}│`);
72
- for (const override of overrides){
73
- const catalogPath = `catalogs.${override.catalog}.${override.package}`;
74
- const silkLine = ` Silk version: ${override.silkVersion}`;
75
- const localLine = ` Local override: ${override.localVersion}`;
76
- lines.push(`│ ${catalogPath}${" ".repeat(WARNING_BOX_WIDTH - catalogPath.length - 4)}│`);
77
- lines.push(`│${silkLine}${" ".repeat(WARNING_BOX_WIDTH - silkLine.length - 2)}│`);
78
- lines.push(`│${localLine}${" ".repeat(WARNING_BOX_WIDTH - localLine.length - 2)}│`);
79
- lines.push(`│${" ".repeat(WARNING_BOX_WIDTH - 2)}│`);
198
+ fs (module1) {
199
+ module1.exports = require("fs");
80
200
  }
81
- lines.push(`│ Local versions will be used. To use Silk defaults, remove these${" ".repeat(WARNING_BOX_WIDTH - 69)}│`);
82
- lines.push(`│ entries from your pnpm-workspace.yaml catalogs section.${" ".repeat(WARNING_BOX_WIDTH - 62)}│`);
83
- lines.push(`└${border}┘`);
84
- return lines.join("\n");
85
- }
86
- function warnOverrides(overrides) {
87
- if (overrides.length > 0) console.warn(formatOverrideWarning(overrides));
201
+ };
202
+ var __webpack_module_cache__ = {};
203
+ function __webpack_require__(moduleId) {
204
+ var cachedModule = __webpack_module_cache__[moduleId];
205
+ if (void 0 !== cachedModule) return cachedModule.exports;
206
+ var module1 = __webpack_module_cache__[moduleId] = {
207
+ exports: {}
208
+ };
209
+ __webpack_modules__[moduleId](module1, module1.exports, __webpack_require__);
210
+ return module1.exports;
88
211
  }
89
- function mergeSingleCatalog(catalogName, silkCatalog, localCatalog, overrides) {
90
- const merged = {
91
- ...silkCatalog
212
+ (()=>{
213
+ __webpack_require__.n = (module1)=>{
214
+ var getter = module1 && module1.__esModule ? ()=>module1['default'] : ()=>module1;
215
+ __webpack_require__.d(getter, {
216
+ a: getter
217
+ });
218
+ return getter;
92
219
  };
93
- if (!localCatalog) return merged;
94
- for (const [pkg, localVersion] of Object.entries(localCatalog)){
95
- const silkVersion = silkCatalog[pkg];
96
- if (void 0 !== silkVersion && silkVersion !== localVersion) overrides.push({
97
- catalog: catalogName,
98
- package: pkg,
99
- silkVersion,
100
- localVersion
220
+ })();
221
+ (()=>{
222
+ __webpack_require__.d = (exports1, definition)=>{
223
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
224
+ enumerable: true,
225
+ get: definition[key]
101
226
  });
102
- merged[pkg] = localVersion;
227
+ };
228
+ })();
229
+ (()=>{
230
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
231
+ })();
232
+ var __webpack_exports__ = {};
233
+ (()=>{
234
+ const silkCatalogs = {
235
+ silk: {
236
+ "@biomejs/biome": "2.3.14",
237
+ "@changesets/cli": "^2.29.8",
238
+ "@commitlint/cli": "^20.4.1",
239
+ "@commitlint/config-conventional": "^20.4.1",
240
+ "@microsoft/api-extractor": "^7.56.3",
241
+ "@rslib/core": "^0.19.5",
242
+ "@types/node": "^25.2.1",
243
+ "@typescript/native-preview": "7.0.0-dev.20260207.1",
244
+ "@vitest/coverage-v8": "^4.0.18",
245
+ commitizen: "^4.3.1",
246
+ husky: "^9.1.7",
247
+ "lint-staged": "^16.2.7",
248
+ "markdownlint-cli2": "^0.20.0",
249
+ "markdownlint-cli2-formatter-codequality": "^0.0.7",
250
+ tsx: "^4.21.0",
251
+ turbo: "^2.8.3",
252
+ typescript: "^5.9.3",
253
+ vitest: "^4.0.18"
254
+ },
255
+ silkPeers: {
256
+ "@biomejs/biome": "2.3.14",
257
+ "@commitlint/cli": "^20.4.1",
258
+ "@commitlint/config-conventional": "^20.4.1",
259
+ "@microsoft/api-extractor": "^7.56.2",
260
+ "@types/node": "^25.0.10",
261
+ "@typescript/native-preview": "^7.0.0-dev.20260124.1",
262
+ commitizen: "^4.3.1",
263
+ husky: "^9.1.7",
264
+ typescript: "^5.9.3"
265
+ },
266
+ silkOverrides: {
267
+ "@isaacs/brace-expansion": ">=5.0.1",
268
+ lodash: ">=4.17.23",
269
+ tmp: ">=0.2.4"
270
+ },
271
+ silkOnlyBuiltDependencies: [
272
+ "@parcel/watcher",
273
+ "@savvy-web/commitlint",
274
+ "@savvy-web/lint-staged",
275
+ "core-js",
276
+ "esbuild",
277
+ "msgpackr-extract"
278
+ ],
279
+ silkPublicHoistPattern: [
280
+ "@commitlint/cli",
281
+ "@commitlint/config-conventional",
282
+ "@commitlint/cz-commitlint",
283
+ "@microsoft/api-extractor",
284
+ "@rslib/core",
285
+ "@typescript/native-preview",
286
+ "husky",
287
+ "lint-staged",
288
+ "markdownlint-cli2",
289
+ "markdownlint-cli2-formatter-codequality",
290
+ "turbo",
291
+ "typescript"
292
+ ]
293
+ };
294
+ const promises_namespaceObject = require("node:fs/promises");
295
+ const external_node_path_namespaceObject = require("node:path");
296
+ function createScanner(text, ignoreTrivia = false) {
297
+ const len = text.length;
298
+ let pos = 0, value = '', tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
299
+ function scanHexDigits(count, exact) {
300
+ let digits = 0;
301
+ let value = 0;
302
+ while(digits < count || !exact){
303
+ let ch = text.charCodeAt(pos);
304
+ if (ch >= 48 && ch <= 57) value = 16 * value + ch - 48;
305
+ else if (ch >= 65 && ch <= 70) value = 16 * value + ch - 65 + 10;
306
+ else if (ch >= 97 && ch <= 102) value = 16 * value + ch - 97 + 10;
307
+ else break;
308
+ pos++;
309
+ digits++;
310
+ }
311
+ if (digits < count) value = -1;
312
+ return value;
313
+ }
314
+ function setPosition(newPosition) {
315
+ pos = newPosition;
316
+ value = '';
317
+ tokenOffset = 0;
318
+ token = 16;
319
+ scanError = 0;
320
+ }
321
+ function scanNumber() {
322
+ let start = pos;
323
+ if (48 === text.charCodeAt(pos)) pos++;
324
+ else {
325
+ pos++;
326
+ while(pos < text.length && isDigit(text.charCodeAt(pos)))pos++;
327
+ }
328
+ if (pos < text.length && 46 === text.charCodeAt(pos)) {
329
+ pos++;
330
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
331
+ pos++;
332
+ while(pos < text.length && isDigit(text.charCodeAt(pos)))pos++;
333
+ } else {
334
+ scanError = 3;
335
+ return text.substring(start, pos);
336
+ }
337
+ }
338
+ let end = pos;
339
+ if (pos < text.length && (69 === text.charCodeAt(pos) || 101 === text.charCodeAt(pos))) {
340
+ pos++;
341
+ if (pos < text.length && 43 === text.charCodeAt(pos) || 45 === text.charCodeAt(pos)) pos++;
342
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
343
+ pos++;
344
+ while(pos < text.length && isDigit(text.charCodeAt(pos)))pos++;
345
+ end = pos;
346
+ } else scanError = 3;
347
+ }
348
+ return text.substring(start, end);
349
+ }
350
+ function scanString() {
351
+ let result = '', start = pos;
352
+ while(true){
353
+ if (pos >= len) {
354
+ result += text.substring(start, pos);
355
+ scanError = 2;
356
+ break;
357
+ }
358
+ const ch = text.charCodeAt(pos);
359
+ if (34 === ch) {
360
+ result += text.substring(start, pos);
361
+ pos++;
362
+ break;
363
+ }
364
+ if (92 === ch) {
365
+ result += text.substring(start, pos);
366
+ pos++;
367
+ if (pos >= len) {
368
+ scanError = 2;
369
+ break;
370
+ }
371
+ const ch2 = text.charCodeAt(pos++);
372
+ switch(ch2){
373
+ case 34:
374
+ result += '\"';
375
+ break;
376
+ case 92:
377
+ result += '\\';
378
+ break;
379
+ case 47:
380
+ result += '/';
381
+ break;
382
+ case 98:
383
+ result += '\b';
384
+ break;
385
+ case 102:
386
+ result += '\f';
387
+ break;
388
+ case 110:
389
+ result += '\n';
390
+ break;
391
+ case 114:
392
+ result += '\r';
393
+ break;
394
+ case 116:
395
+ result += '\t';
396
+ break;
397
+ case 117:
398
+ const ch3 = scanHexDigits(4, true);
399
+ if (ch3 >= 0) result += String.fromCharCode(ch3);
400
+ else scanError = 4;
401
+ break;
402
+ default:
403
+ scanError = 5;
404
+ }
405
+ start = pos;
406
+ continue;
407
+ }
408
+ if (ch >= 0 && ch <= 0x1f) if (isLineBreak(ch)) {
409
+ result += text.substring(start, pos);
410
+ scanError = 2;
411
+ break;
412
+ } else scanError = 6;
413
+ pos++;
414
+ }
415
+ return result;
416
+ }
417
+ function scanNext() {
418
+ value = '';
419
+ scanError = 0;
420
+ tokenOffset = pos;
421
+ lineStartOffset = lineNumber;
422
+ prevTokenLineStartOffset = tokenLineStartOffset;
423
+ if (pos >= len) {
424
+ tokenOffset = len;
425
+ return token = 17;
426
+ }
427
+ let code = text.charCodeAt(pos);
428
+ if (isWhiteSpace(code)) {
429
+ do {
430
+ pos++;
431
+ value += String.fromCharCode(code);
432
+ code = text.charCodeAt(pos);
433
+ }while (isWhiteSpace(code));
434
+ return token = 15;
435
+ }
436
+ if (isLineBreak(code)) {
437
+ pos++;
438
+ value += String.fromCharCode(code);
439
+ if (13 === code && 10 === text.charCodeAt(pos)) {
440
+ pos++;
441
+ value += '\n';
442
+ }
443
+ lineNumber++;
444
+ tokenLineStartOffset = pos;
445
+ return token = 14;
446
+ }
447
+ switch(code){
448
+ case 123:
449
+ pos++;
450
+ return token = 1;
451
+ case 125:
452
+ pos++;
453
+ return token = 2;
454
+ case 91:
455
+ pos++;
456
+ return token = 3;
457
+ case 93:
458
+ pos++;
459
+ return token = 4;
460
+ case 58:
461
+ pos++;
462
+ return token = 6;
463
+ case 44:
464
+ pos++;
465
+ return token = 5;
466
+ case 34:
467
+ pos++;
468
+ value = scanString();
469
+ return token = 10;
470
+ case 47:
471
+ const start = pos - 1;
472
+ if (47 === text.charCodeAt(pos + 1)) {
473
+ pos += 2;
474
+ while(pos < len){
475
+ if (isLineBreak(text.charCodeAt(pos))) break;
476
+ pos++;
477
+ }
478
+ value = text.substring(start, pos);
479
+ return token = 12;
480
+ }
481
+ if (42 === text.charCodeAt(pos + 1)) {
482
+ pos += 2;
483
+ const safeLength = len - 1;
484
+ let commentClosed = false;
485
+ while(pos < safeLength){
486
+ const ch = text.charCodeAt(pos);
487
+ if (42 === ch && 47 === text.charCodeAt(pos + 1)) {
488
+ pos += 2;
489
+ commentClosed = true;
490
+ break;
491
+ }
492
+ pos++;
493
+ if (isLineBreak(ch)) {
494
+ if (13 === ch && 10 === text.charCodeAt(pos)) pos++;
495
+ lineNumber++;
496
+ tokenLineStartOffset = pos;
497
+ }
498
+ }
499
+ if (!commentClosed) {
500
+ pos++;
501
+ scanError = 1;
502
+ }
503
+ value = text.substring(start, pos);
504
+ return token = 13;
505
+ }
506
+ value += String.fromCharCode(code);
507
+ pos++;
508
+ return token = 16;
509
+ case 45:
510
+ value += String.fromCharCode(code);
511
+ pos++;
512
+ if (pos === len || !isDigit(text.charCodeAt(pos))) return token = 16;
513
+ case 48:
514
+ case 49:
515
+ case 50:
516
+ case 51:
517
+ case 52:
518
+ case 53:
519
+ case 54:
520
+ case 55:
521
+ case 56:
522
+ case 57:
523
+ value += scanNumber();
524
+ return token = 11;
525
+ default:
526
+ while(pos < len && isUnknownContentCharacter(code)){
527
+ pos++;
528
+ code = text.charCodeAt(pos);
529
+ }
530
+ if (tokenOffset !== pos) {
531
+ value = text.substring(tokenOffset, pos);
532
+ switch(value){
533
+ case 'true':
534
+ return token = 8;
535
+ case 'false':
536
+ return token = 9;
537
+ case 'null':
538
+ return token = 7;
539
+ }
540
+ return token = 16;
541
+ }
542
+ value += String.fromCharCode(code);
543
+ pos++;
544
+ return token = 16;
545
+ }
546
+ }
547
+ function isUnknownContentCharacter(code) {
548
+ if (isWhiteSpace(code) || isLineBreak(code)) return false;
549
+ switch(code){
550
+ case 125:
551
+ case 93:
552
+ case 123:
553
+ case 91:
554
+ case 34:
555
+ case 58:
556
+ case 44:
557
+ case 47:
558
+ return false;
559
+ }
560
+ return true;
561
+ }
562
+ function scanNextNonTrivia() {
563
+ let result;
564
+ do result = scanNext();
565
+ while (result >= 12 && result <= 15);
566
+ return result;
567
+ }
568
+ return {
569
+ setPosition: setPosition,
570
+ getPosition: ()=>pos,
571
+ scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
572
+ getToken: ()=>token,
573
+ getTokenValue: ()=>value,
574
+ getTokenOffset: ()=>tokenOffset,
575
+ getTokenLength: ()=>pos - tokenOffset,
576
+ getTokenStartLine: ()=>lineStartOffset,
577
+ getTokenStartCharacter: ()=>tokenOffset - prevTokenLineStartOffset,
578
+ getTokenError: ()=>scanError
579
+ };
103
580
  }
104
- return merged;
105
- }
106
- function mergeOverrides(silkOverrides, localOverrides, overrideWarnings) {
107
- const merged = {
108
- ...silkOverrides
581
+ function isWhiteSpace(ch) {
582
+ return 32 === ch || 9 === ch;
583
+ }
584
+ function isLineBreak(ch) {
585
+ return 10 === ch || 13 === ch;
586
+ }
587
+ function isDigit(ch) {
588
+ return ch >= 48 && ch <= 57;
589
+ }
590
+ var scanner_CharacterCodes;
591
+ (function(CharacterCodes) {
592
+ CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
593
+ CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
594
+ CharacterCodes[CharacterCodes["space"] = 32] = "space";
595
+ CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
596
+ CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
597
+ CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
598
+ CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
599
+ CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
600
+ CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
601
+ CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
602
+ CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
603
+ CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
604
+ CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
605
+ CharacterCodes[CharacterCodes["a"] = 97] = "a";
606
+ CharacterCodes[CharacterCodes["b"] = 98] = "b";
607
+ CharacterCodes[CharacterCodes["c"] = 99] = "c";
608
+ CharacterCodes[CharacterCodes["d"] = 100] = "d";
609
+ CharacterCodes[CharacterCodes["e"] = 101] = "e";
610
+ CharacterCodes[CharacterCodes["f"] = 102] = "f";
611
+ CharacterCodes[CharacterCodes["g"] = 103] = "g";
612
+ CharacterCodes[CharacterCodes["h"] = 104] = "h";
613
+ CharacterCodes[CharacterCodes["i"] = 105] = "i";
614
+ CharacterCodes[CharacterCodes["j"] = 106] = "j";
615
+ CharacterCodes[CharacterCodes["k"] = 107] = "k";
616
+ CharacterCodes[CharacterCodes["l"] = 108] = "l";
617
+ CharacterCodes[CharacterCodes["m"] = 109] = "m";
618
+ CharacterCodes[CharacterCodes["n"] = 110] = "n";
619
+ CharacterCodes[CharacterCodes["o"] = 111] = "o";
620
+ CharacterCodes[CharacterCodes["p"] = 112] = "p";
621
+ CharacterCodes[CharacterCodes["q"] = 113] = "q";
622
+ CharacterCodes[CharacterCodes["r"] = 114] = "r";
623
+ CharacterCodes[CharacterCodes["s"] = 115] = "s";
624
+ CharacterCodes[CharacterCodes["t"] = 116] = "t";
625
+ CharacterCodes[CharacterCodes["u"] = 117] = "u";
626
+ CharacterCodes[CharacterCodes["v"] = 118] = "v";
627
+ CharacterCodes[CharacterCodes["w"] = 119] = "w";
628
+ CharacterCodes[CharacterCodes["x"] = 120] = "x";
629
+ CharacterCodes[CharacterCodes["y"] = 121] = "y";
630
+ CharacterCodes[CharacterCodes["z"] = 122] = "z";
631
+ CharacterCodes[CharacterCodes["A"] = 65] = "A";
632
+ CharacterCodes[CharacterCodes["B"] = 66] = "B";
633
+ CharacterCodes[CharacterCodes["C"] = 67] = "C";
634
+ CharacterCodes[CharacterCodes["D"] = 68] = "D";
635
+ CharacterCodes[CharacterCodes["E"] = 69] = "E";
636
+ CharacterCodes[CharacterCodes["F"] = 70] = "F";
637
+ CharacterCodes[CharacterCodes["G"] = 71] = "G";
638
+ CharacterCodes[CharacterCodes["H"] = 72] = "H";
639
+ CharacterCodes[CharacterCodes["I"] = 73] = "I";
640
+ CharacterCodes[CharacterCodes["J"] = 74] = "J";
641
+ CharacterCodes[CharacterCodes["K"] = 75] = "K";
642
+ CharacterCodes[CharacterCodes["L"] = 76] = "L";
643
+ CharacterCodes[CharacterCodes["M"] = 77] = "M";
644
+ CharacterCodes[CharacterCodes["N"] = 78] = "N";
645
+ CharacterCodes[CharacterCodes["O"] = 79] = "O";
646
+ CharacterCodes[CharacterCodes["P"] = 80] = "P";
647
+ CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
648
+ CharacterCodes[CharacterCodes["R"] = 82] = "R";
649
+ CharacterCodes[CharacterCodes["S"] = 83] = "S";
650
+ CharacterCodes[CharacterCodes["T"] = 84] = "T";
651
+ CharacterCodes[CharacterCodes["U"] = 85] = "U";
652
+ CharacterCodes[CharacterCodes["V"] = 86] = "V";
653
+ CharacterCodes[CharacterCodes["W"] = 87] = "W";
654
+ CharacterCodes[CharacterCodes["X"] = 88] = "X";
655
+ CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
656
+ CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
657
+ CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
658
+ CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
659
+ CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
660
+ CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
661
+ CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
662
+ CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
663
+ CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
664
+ CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
665
+ CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
666
+ CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
667
+ CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
668
+ CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
669
+ CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
670
+ CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
671
+ CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
672
+ })(scanner_CharacterCodes || (scanner_CharacterCodes = {}));
673
+ const cachedSpaces = new Array(20).fill(0).map((_, index)=>' '.repeat(index));
674
+ const maxCachedValues = 200;
675
+ const cachedBreakLinesWithSpaces = {
676
+ ' ': {
677
+ '\n': new Array(maxCachedValues).fill(0).map((_, index)=>'\n' + ' '.repeat(index)),
678
+ '\r': new Array(maxCachedValues).fill(0).map((_, index)=>'\r' + ' '.repeat(index)),
679
+ '\r\n': new Array(maxCachedValues).fill(0).map((_, index)=>'\r\n' + ' '.repeat(index))
680
+ },
681
+ '\t': {
682
+ '\n': new Array(maxCachedValues).fill(0).map((_, index)=>'\n' + '\t'.repeat(index)),
683
+ '\r': new Array(maxCachedValues).fill(0).map((_, index)=>'\r' + '\t'.repeat(index)),
684
+ '\r\n': new Array(maxCachedValues).fill(0).map((_, index)=>'\r\n' + '\t'.repeat(index))
685
+ }
109
686
  };
110
- if (!localOverrides) return merged;
111
- for (const [pkg, localVersion] of Object.entries(localOverrides)){
112
- const silkVersion = silkOverrides[pkg];
113
- if (void 0 !== silkVersion && silkVersion !== localVersion) overrideWarnings.push({
114
- catalog: "overrides",
115
- package: pkg,
116
- silkVersion,
117
- localVersion
118
- });
119
- merged[pkg] = localVersion;
687
+ const supportedEols = [
688
+ '\n',
689
+ '\r',
690
+ '\r\n'
691
+ ];
692
+ function format(documentText, range, options) {
693
+ let initialIndentLevel;
694
+ let formatText;
695
+ let formatTextStart;
696
+ let rangeStart;
697
+ let rangeEnd;
698
+ if (range) {
699
+ rangeStart = range.offset;
700
+ rangeEnd = rangeStart + range.length;
701
+ formatTextStart = rangeStart;
702
+ while(formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1))formatTextStart--;
703
+ let endOffset = rangeEnd;
704
+ while(endOffset < documentText.length && !isEOL(documentText, endOffset))endOffset++;
705
+ formatText = documentText.substring(formatTextStart, endOffset);
706
+ initialIndentLevel = computeIndentLevel(formatText, options);
707
+ } else {
708
+ formatText = documentText;
709
+ initialIndentLevel = 0;
710
+ formatTextStart = 0;
711
+ rangeStart = 0;
712
+ rangeEnd = documentText.length;
713
+ }
714
+ const eol = getEOL(options, documentText);
715
+ const eolFastPathSupported = supportedEols.includes(eol);
716
+ let numberLineBreaks = 0;
717
+ let indentLevel = 0;
718
+ let indentValue;
719
+ indentValue = options.insertSpaces ? cachedSpaces[options.tabSize || 4] ?? repeat(cachedSpaces["1"], options.tabSize || 4) : '\t';
720
+ const indentType = '\t' === indentValue ? '\t' : ' ';
721
+ let scanner = createScanner(formatText, false);
722
+ let hasError = false;
723
+ function newLinesAndIndent() {
724
+ if (numberLineBreaks > 1) return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
725
+ const amountOfSpaces = indentValue.length * (initialIndentLevel + indentLevel);
726
+ if (!eolFastPathSupported || amountOfSpaces > cachedBreakLinesWithSpaces[indentType][eol].length) return eol + repeat(indentValue, initialIndentLevel + indentLevel);
727
+ if (amountOfSpaces <= 0) return eol;
728
+ return cachedBreakLinesWithSpaces[indentType][eol][amountOfSpaces];
729
+ }
730
+ function scanNext() {
731
+ let token = scanner.scan();
732
+ numberLineBreaks = 0;
733
+ while(15 === token || 14 === token){
734
+ if (14 === token && options.keepLines) numberLineBreaks += 1;
735
+ else if (14 === token) numberLineBreaks = 1;
736
+ token = scanner.scan();
737
+ }
738
+ hasError = 16 === token || 0 !== scanner.getTokenError();
739
+ return token;
740
+ }
741
+ const editOperations = [];
742
+ function addEdit(text, startOffset, endOffset) {
743
+ if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !== text) editOperations.push({
744
+ offset: startOffset,
745
+ length: endOffset - startOffset,
746
+ content: text
747
+ });
748
+ }
749
+ let firstToken = scanNext();
750
+ if (options.keepLines && numberLineBreaks > 0) addEdit(repeat(eol, numberLineBreaks), 0, 0);
751
+ if (17 !== firstToken) {
752
+ let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
753
+ let initialIndent = indentValue.length * initialIndentLevel < 20 && options.insertSpaces ? cachedSpaces[indentValue.length * initialIndentLevel] : repeat(indentValue, initialIndentLevel);
754
+ addEdit(initialIndent, formatTextStart, firstTokenStart);
755
+ }
756
+ while(17 !== firstToken){
757
+ let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
758
+ let secondToken = scanNext();
759
+ let replaceContent = '';
760
+ let needsLineBreak = false;
761
+ while(0 === numberLineBreaks && (12 === secondToken || 13 === secondToken)){
762
+ let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
763
+ addEdit(cachedSpaces["1"], firstTokenEnd, commentTokenStart);
764
+ firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
765
+ needsLineBreak = 12 === secondToken;
766
+ replaceContent = needsLineBreak ? newLinesAndIndent() : '';
767
+ secondToken = scanNext();
768
+ }
769
+ if (2 === secondToken) {
770
+ if (1 !== firstToken) indentLevel--;
771
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && 1 !== firstToken) replaceContent = newLinesAndIndent();
772
+ else if (options.keepLines) replaceContent = cachedSpaces["1"];
773
+ } else if (4 === secondToken) {
774
+ if (3 !== firstToken) indentLevel--;
775
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && 3 !== firstToken) replaceContent = newLinesAndIndent();
776
+ else if (options.keepLines) replaceContent = cachedSpaces["1"];
777
+ } else {
778
+ switch(firstToken){
779
+ case 3:
780
+ case 1:
781
+ indentLevel++;
782
+ replaceContent = options.keepLines && numberLineBreaks > 0 || !options.keepLines ? newLinesAndIndent() : cachedSpaces["1"];
783
+ break;
784
+ case 5:
785
+ replaceContent = options.keepLines && numberLineBreaks > 0 || !options.keepLines ? newLinesAndIndent() : cachedSpaces["1"];
786
+ break;
787
+ case 12:
788
+ replaceContent = newLinesAndIndent();
789
+ break;
790
+ case 13:
791
+ if (numberLineBreaks > 0) replaceContent = newLinesAndIndent();
792
+ else if (!needsLineBreak) replaceContent = cachedSpaces["1"];
793
+ break;
794
+ case 6:
795
+ if (options.keepLines && numberLineBreaks > 0) replaceContent = newLinesAndIndent();
796
+ else if (!needsLineBreak) replaceContent = cachedSpaces["1"];
797
+ break;
798
+ case 10:
799
+ if (options.keepLines && numberLineBreaks > 0) replaceContent = newLinesAndIndent();
800
+ else if (6 === secondToken && !needsLineBreak) replaceContent = '';
801
+ break;
802
+ case 7:
803
+ case 8:
804
+ case 9:
805
+ case 11:
806
+ case 2:
807
+ case 4:
808
+ if (options.keepLines && numberLineBreaks > 0) replaceContent = newLinesAndIndent();
809
+ else if (12 !== secondToken && 13 !== secondToken || needsLineBreak) {
810
+ if (5 !== secondToken && 17 !== secondToken) hasError = true;
811
+ } else replaceContent = cachedSpaces["1"];
812
+ break;
813
+ case 16:
814
+ hasError = true;
815
+ break;
816
+ }
817
+ if (numberLineBreaks > 0 && (12 === secondToken || 13 === secondToken)) replaceContent = newLinesAndIndent();
818
+ }
819
+ if (17 === secondToken) replaceContent = options.keepLines && numberLineBreaks > 0 ? newLinesAndIndent() : options.insertFinalNewline ? eol : '';
820
+ const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
821
+ addEdit(replaceContent, firstTokenEnd, secondTokenStart);
822
+ firstToken = secondToken;
823
+ }
824
+ return editOperations;
120
825
  }
121
- return merged;
122
- }
123
- function mergeStringArrays(silkArray, localArray) {
124
- const merged = new Set(silkArray);
125
- if (localArray) for (const item of localArray)merged.add(item);
126
- return [
127
- ...merged
128
- ].sort((a, b)=>a.localeCompare(b));
129
- }
130
- function updateConfig(config) {
131
- try {
132
- const warnings = [];
133
- const existingCatalogs = config.catalogs ?? {};
134
- const mergedSilk = mergeSingleCatalog("silk", silkCatalogs.silk, existingCatalogs.silk, warnings);
135
- const mergedSilkPeers = mergeSingleCatalog("silkPeers", silkCatalogs.silkPeers, existingCatalogs.silkPeers, warnings);
136
- const mergedOverrides = mergeOverrides(silkCatalogs.silkOverrides, config.overrides, warnings);
137
- const mergedOnlyBuiltDependencies = mergeStringArrays(silkCatalogs.silkOnlyBuiltDependencies, config.onlyBuiltDependencies);
138
- const mergedPublicHoistPattern = mergeStringArrays(silkCatalogs.silkPublicHoistPattern, config.publicHoistPattern);
139
- warnOverrides(warnings);
140
- return {
141
- ...config,
142
- catalogs: {
143
- ...existingCatalogs,
144
- silk: mergedSilk,
145
- silkPeers: mergedSilkPeers
826
+ function repeat(s, count) {
827
+ let result = '';
828
+ for(let i = 0; i < count; i++)result += s;
829
+ return result;
830
+ }
831
+ function computeIndentLevel(content, options) {
832
+ let i = 0;
833
+ let nChars = 0;
834
+ const tabSize = options.tabSize || 4;
835
+ while(i < content.length){
836
+ let ch = content.charAt(i);
837
+ if (ch === cachedSpaces["1"]) nChars++;
838
+ else if ('\t' === ch) nChars += tabSize;
839
+ else break;
840
+ i++;
841
+ }
842
+ return Math.floor(nChars / tabSize);
843
+ }
844
+ function getEOL(options, text) {
845
+ for(let i = 0; i < text.length; i++){
846
+ const ch = text.charAt(i);
847
+ if ('\r' === ch) {
848
+ if (i + 1 < text.length && '\n' === text.charAt(i + 1)) return '\r\n';
849
+ return '\r';
850
+ }
851
+ if ('\n' === ch) return '\n';
852
+ }
853
+ return options && options.eol || '\n';
854
+ }
855
+ function isEOL(text, offset) {
856
+ return -1 !== '\r\n'.indexOf(text.charAt(offset));
857
+ }
858
+ var parser_ParseOptions;
859
+ (function(ParseOptions) {
860
+ ParseOptions.DEFAULT = {
861
+ allowTrailingComma: false
862
+ };
863
+ })(parser_ParseOptions || (parser_ParseOptions = {}));
864
+ function parse(text, errors = [], options = parser_ParseOptions.DEFAULT) {
865
+ let currentProperty = null;
866
+ let currentParent = [];
867
+ const previousParents = [];
868
+ function onValue(value) {
869
+ if (Array.isArray(currentParent)) currentParent.push(value);
870
+ else if (null !== currentProperty) currentParent[currentProperty] = value;
871
+ }
872
+ const visitor = {
873
+ onObjectBegin: ()=>{
874
+ const object = {};
875
+ onValue(object);
876
+ previousParents.push(currentParent);
877
+ currentParent = object;
878
+ currentProperty = null;
879
+ },
880
+ onObjectProperty: (name)=>{
881
+ currentProperty = name;
882
+ },
883
+ onObjectEnd: ()=>{
884
+ currentParent = previousParents.pop();
885
+ },
886
+ onArrayBegin: ()=>{
887
+ const array = [];
888
+ onValue(array);
889
+ previousParents.push(currentParent);
890
+ currentParent = array;
891
+ currentProperty = null;
892
+ },
893
+ onArrayEnd: ()=>{
894
+ currentParent = previousParents.pop();
146
895
  },
147
- overrides: mergedOverrides,
148
- onlyBuiltDependencies: mergedOnlyBuiltDependencies,
149
- publicHoistPattern: mergedPublicHoistPattern
896
+ onLiteralValue: onValue,
897
+ onError: (error, offset, length)=>{
898
+ errors.push({
899
+ error,
900
+ offset,
901
+ length
902
+ });
903
+ }
150
904
  };
151
- } catch (error) {
152
- console.warn("[pnpm-plugin-silk] Error merging catalogs, using local config only:", error instanceof Error ? error.message : String(error));
153
- return config;
905
+ visit(text, visitor, options);
906
+ return currentParent[0];
154
907
  }
155
- }
156
- module.exports = {
157
- hooks: {
158
- updateConfig: updateConfig
908
+ function parseTree(text, errors = [], options = parser_ParseOptions.DEFAULT) {
909
+ let currentParent = {
910
+ type: 'array',
911
+ offset: -1,
912
+ length: -1,
913
+ children: [],
914
+ parent: void 0
915
+ };
916
+ function ensurePropertyComplete(endOffset) {
917
+ if ('property' === currentParent.type) {
918
+ currentParent.length = endOffset - currentParent.offset;
919
+ currentParent = currentParent.parent;
920
+ }
921
+ }
922
+ function onValue(valueNode) {
923
+ currentParent.children.push(valueNode);
924
+ return valueNode;
925
+ }
926
+ const visitor = {
927
+ onObjectBegin: (offset)=>{
928
+ currentParent = onValue({
929
+ type: 'object',
930
+ offset,
931
+ length: -1,
932
+ parent: currentParent,
933
+ children: []
934
+ });
935
+ },
936
+ onObjectProperty: (name, offset, length)=>{
937
+ currentParent = onValue({
938
+ type: 'property',
939
+ offset,
940
+ length: -1,
941
+ parent: currentParent,
942
+ children: []
943
+ });
944
+ currentParent.children.push({
945
+ type: 'string',
946
+ value: name,
947
+ offset,
948
+ length,
949
+ parent: currentParent
950
+ });
951
+ },
952
+ onObjectEnd: (offset, length)=>{
953
+ ensurePropertyComplete(offset + length);
954
+ currentParent.length = offset + length - currentParent.offset;
955
+ currentParent = currentParent.parent;
956
+ ensurePropertyComplete(offset + length);
957
+ },
958
+ onArrayBegin: (offset, length)=>{
959
+ currentParent = onValue({
960
+ type: 'array',
961
+ offset,
962
+ length: -1,
963
+ parent: currentParent,
964
+ children: []
965
+ });
966
+ },
967
+ onArrayEnd: (offset, length)=>{
968
+ currentParent.length = offset + length - currentParent.offset;
969
+ currentParent = currentParent.parent;
970
+ ensurePropertyComplete(offset + length);
971
+ },
972
+ onLiteralValue: (value, offset, length)=>{
973
+ onValue({
974
+ type: getNodeType(value),
975
+ offset,
976
+ length,
977
+ parent: currentParent,
978
+ value
979
+ });
980
+ ensurePropertyComplete(offset + length);
981
+ },
982
+ onSeparator: (sep, offset, length)=>{
983
+ if ('property' === currentParent.type) {
984
+ if (':' === sep) currentParent.colonOffset = offset;
985
+ else if (',' === sep) ensurePropertyComplete(offset);
986
+ }
987
+ },
988
+ onError: (error, offset, length)=>{
989
+ errors.push({
990
+ error,
991
+ offset,
992
+ length
993
+ });
994
+ }
995
+ };
996
+ visit(text, visitor, options);
997
+ const result = currentParent.children[0];
998
+ if (result) delete result.parent;
999
+ return result;
159
1000
  }
160
- };
1001
+ function findNodeAtLocation(root, path) {
1002
+ if (!root) return;
1003
+ let node = root;
1004
+ for (let segment of path)if ('string' == typeof segment) {
1005
+ if ('object' !== node.type || !Array.isArray(node.children)) return;
1006
+ let found = false;
1007
+ for (const propertyNode of node.children)if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && 2 === propertyNode.children.length) {
1008
+ node = propertyNode.children[1];
1009
+ found = true;
1010
+ break;
1011
+ }
1012
+ if (!found) return;
1013
+ } else {
1014
+ const index = segment;
1015
+ if ('array' !== node.type || index < 0 || !Array.isArray(node.children) || index >= node.children.length) return;
1016
+ node = node.children[index];
1017
+ }
1018
+ return node;
1019
+ }
1020
+ function visit(text, visitor, options = parser_ParseOptions.DEFAULT) {
1021
+ const _scanner = createScanner(text, false);
1022
+ const _jsonPath = [];
1023
+ let suppressedCallbacks = 0;
1024
+ function toNoArgVisit(visitFunction) {
1025
+ return visitFunction ? ()=>0 === suppressedCallbacks && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : ()=>true;
1026
+ }
1027
+ function toOneArgVisit(visitFunction) {
1028
+ return visitFunction ? (arg)=>0 === suppressedCallbacks && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : ()=>true;
1029
+ }
1030
+ function toOneArgVisitWithPath(visitFunction) {
1031
+ return visitFunction ? (arg)=>0 === suppressedCallbacks && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), ()=>_jsonPath.slice()) : ()=>true;
1032
+ }
1033
+ function toBeginVisit(visitFunction) {
1034
+ return visitFunction ? ()=>{
1035
+ if (suppressedCallbacks > 0) suppressedCallbacks++;
1036
+ else {
1037
+ let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), ()=>_jsonPath.slice());
1038
+ if (false === cbReturn) suppressedCallbacks = 1;
1039
+ }
1040
+ } : ()=>true;
1041
+ }
1042
+ function toEndVisit(visitFunction) {
1043
+ return visitFunction ? ()=>{
1044
+ if (suppressedCallbacks > 0) suppressedCallbacks--;
1045
+ if (0 === suppressedCallbacks) visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
1046
+ } : ()=>true;
1047
+ }
1048
+ const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
1049
+ const disallowComments = options && options.disallowComments;
1050
+ const allowTrailingComma = options && options.allowTrailingComma;
1051
+ function scanNext() {
1052
+ while(true){
1053
+ const token = _scanner.scan();
1054
+ switch(_scanner.getTokenError()){
1055
+ case 4:
1056
+ handleError(14);
1057
+ break;
1058
+ case 5:
1059
+ handleError(15);
1060
+ break;
1061
+ case 3:
1062
+ handleError(13);
1063
+ break;
1064
+ case 1:
1065
+ if (!disallowComments) handleError(11);
1066
+ break;
1067
+ case 2:
1068
+ handleError(12);
1069
+ break;
1070
+ case 6:
1071
+ handleError(16);
1072
+ break;
1073
+ }
1074
+ switch(token){
1075
+ case 12:
1076
+ case 13:
1077
+ if (disallowComments) handleError(10);
1078
+ else onComment();
1079
+ break;
1080
+ case 16:
1081
+ handleError(1);
1082
+ break;
1083
+ case 15:
1084
+ case 14:
1085
+ break;
1086
+ default:
1087
+ return token;
1088
+ }
1089
+ }
1090
+ }
1091
+ function handleError(error, skipUntilAfter = [], skipUntil = []) {
1092
+ onError(error);
1093
+ if (skipUntilAfter.length + skipUntil.length > 0) {
1094
+ let token = _scanner.getToken();
1095
+ while(17 !== token){
1096
+ if (-1 !== skipUntilAfter.indexOf(token)) {
1097
+ scanNext();
1098
+ break;
1099
+ }
1100
+ if (-1 !== skipUntil.indexOf(token)) break;
1101
+ token = scanNext();
1102
+ }
1103
+ }
1104
+ }
1105
+ function parseString(isValue) {
1106
+ const value = _scanner.getTokenValue();
1107
+ if (isValue) onLiteralValue(value);
1108
+ else {
1109
+ onObjectProperty(value);
1110
+ _jsonPath.push(value);
1111
+ }
1112
+ scanNext();
1113
+ return true;
1114
+ }
1115
+ function parseLiteral() {
1116
+ switch(_scanner.getToken()){
1117
+ case 11:
1118
+ const tokenValue = _scanner.getTokenValue();
1119
+ let value = Number(tokenValue);
1120
+ if (isNaN(value)) {
1121
+ handleError(2);
1122
+ value = 0;
1123
+ }
1124
+ onLiteralValue(value);
1125
+ break;
1126
+ case 7:
1127
+ onLiteralValue(null);
1128
+ break;
1129
+ case 8:
1130
+ onLiteralValue(true);
1131
+ break;
1132
+ case 9:
1133
+ onLiteralValue(false);
1134
+ break;
1135
+ default:
1136
+ return false;
1137
+ }
1138
+ scanNext();
1139
+ return true;
1140
+ }
1141
+ function parseProperty() {
1142
+ if (10 !== _scanner.getToken()) {
1143
+ handleError(3, [], [
1144
+ 2,
1145
+ 5
1146
+ ]);
1147
+ return false;
1148
+ }
1149
+ parseString(false);
1150
+ if (6 === _scanner.getToken()) {
1151
+ onSeparator(':');
1152
+ scanNext();
1153
+ if (!parseValue()) handleError(4, [], [
1154
+ 2,
1155
+ 5
1156
+ ]);
1157
+ } else handleError(5, [], [
1158
+ 2,
1159
+ 5
1160
+ ]);
1161
+ _jsonPath.pop();
1162
+ return true;
1163
+ }
1164
+ function parseObject() {
1165
+ onObjectBegin();
1166
+ scanNext();
1167
+ let needsComma = false;
1168
+ while(2 !== _scanner.getToken() && 17 !== _scanner.getToken()){
1169
+ if (5 === _scanner.getToken()) {
1170
+ if (!needsComma) handleError(4, [], []);
1171
+ onSeparator(',');
1172
+ scanNext();
1173
+ if (2 === _scanner.getToken() && allowTrailingComma) break;
1174
+ } else if (needsComma) handleError(6, [], []);
1175
+ if (!parseProperty()) handleError(4, [], [
1176
+ 2,
1177
+ 5
1178
+ ]);
1179
+ needsComma = true;
1180
+ }
1181
+ onObjectEnd();
1182
+ if (2 !== _scanner.getToken()) handleError(7, [
1183
+ 2
1184
+ ], []);
1185
+ else scanNext();
1186
+ return true;
1187
+ }
1188
+ function parseArray() {
1189
+ onArrayBegin();
1190
+ scanNext();
1191
+ let isFirstElement = true;
1192
+ let needsComma = false;
1193
+ while(4 !== _scanner.getToken() && 17 !== _scanner.getToken()){
1194
+ if (5 === _scanner.getToken()) {
1195
+ if (!needsComma) handleError(4, [], []);
1196
+ onSeparator(',');
1197
+ scanNext();
1198
+ if (4 === _scanner.getToken() && allowTrailingComma) break;
1199
+ } else if (needsComma) handleError(6, [], []);
1200
+ if (isFirstElement) {
1201
+ _jsonPath.push(0);
1202
+ isFirstElement = false;
1203
+ } else _jsonPath[_jsonPath.length - 1]++;
1204
+ if (!parseValue()) handleError(4, [], [
1205
+ 4,
1206
+ 5
1207
+ ]);
1208
+ needsComma = true;
1209
+ }
1210
+ onArrayEnd();
1211
+ if (!isFirstElement) _jsonPath.pop();
1212
+ if (4 !== _scanner.getToken()) handleError(8, [
1213
+ 4
1214
+ ], []);
1215
+ else scanNext();
1216
+ return true;
1217
+ }
1218
+ function parseValue() {
1219
+ switch(_scanner.getToken()){
1220
+ case 3:
1221
+ return parseArray();
1222
+ case 1:
1223
+ return parseObject();
1224
+ case 10:
1225
+ return parseString(true);
1226
+ default:
1227
+ return parseLiteral();
1228
+ }
1229
+ }
1230
+ scanNext();
1231
+ if (17 === _scanner.getToken()) {
1232
+ if (options.allowEmptyContent) return true;
1233
+ handleError(4, [], []);
1234
+ return false;
1235
+ }
1236
+ if (!parseValue()) {
1237
+ handleError(4, [], []);
1238
+ return false;
1239
+ }
1240
+ if (17 !== _scanner.getToken()) handleError(9, [], []);
1241
+ return true;
1242
+ }
1243
+ function getNodeType(value) {
1244
+ switch(typeof value){
1245
+ case 'boolean':
1246
+ return 'boolean';
1247
+ case 'number':
1248
+ return 'number';
1249
+ case 'string':
1250
+ return 'string';
1251
+ case 'object':
1252
+ if (!value) return 'null';
1253
+ if (Array.isArray(value)) return 'array';
1254
+ return 'object';
1255
+ default:
1256
+ return 'null';
1257
+ }
1258
+ }
1259
+ function setProperty(text, originalPath, value, options) {
1260
+ const path = originalPath.slice();
1261
+ const errors = [];
1262
+ const root = parseTree(text, errors);
1263
+ let parent;
1264
+ let lastSegment;
1265
+ while(path.length > 0){
1266
+ lastSegment = path.pop();
1267
+ parent = findNodeAtLocation(root, path);
1268
+ if (void 0 === parent && void 0 !== value) value = 'string' == typeof lastSegment ? {
1269
+ [lastSegment]: value
1270
+ } : [
1271
+ value
1272
+ ];
1273
+ else break;
1274
+ }
1275
+ if (parent) if ('object' === parent.type && 'string' == typeof lastSegment && Array.isArray(parent.children)) {
1276
+ const existing = findNodeAtLocation(parent, [
1277
+ lastSegment
1278
+ ]);
1279
+ if (void 0 !== existing) if (void 0 !== value) return withFormatting(text, {
1280
+ offset: existing.offset,
1281
+ length: existing.length,
1282
+ content: JSON.stringify(value)
1283
+ }, options);
1284
+ else {
1285
+ if (!existing.parent) throw new Error('Malformed AST');
1286
+ const propertyIndex = parent.children.indexOf(existing.parent);
1287
+ let removeBegin;
1288
+ let removeEnd = existing.parent.offset + existing.parent.length;
1289
+ if (propertyIndex > 0) {
1290
+ let previous = parent.children[propertyIndex - 1];
1291
+ removeBegin = previous.offset + previous.length;
1292
+ } else {
1293
+ removeBegin = parent.offset + 1;
1294
+ if (parent.children.length > 1) {
1295
+ let next = parent.children[1];
1296
+ removeEnd = next.offset;
1297
+ }
1298
+ }
1299
+ return withFormatting(text, {
1300
+ offset: removeBegin,
1301
+ length: removeEnd - removeBegin,
1302
+ content: ''
1303
+ }, options);
1304
+ }
1305
+ {
1306
+ if (void 0 === value) return [];
1307
+ const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
1308
+ const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map((p)=>p.children[0].value)) : parent.children.length;
1309
+ let edit;
1310
+ if (index > 0) {
1311
+ let previous = parent.children[index - 1];
1312
+ edit = {
1313
+ offset: previous.offset + previous.length,
1314
+ length: 0,
1315
+ content: ',' + newProperty
1316
+ };
1317
+ } else edit = 0 === parent.children.length ? {
1318
+ offset: parent.offset + 1,
1319
+ length: 0,
1320
+ content: newProperty
1321
+ } : {
1322
+ offset: parent.offset + 1,
1323
+ length: 0,
1324
+ content: newProperty + ','
1325
+ };
1326
+ return withFormatting(text, edit, options);
1327
+ }
1328
+ } else if ('array' === parent.type && 'number' == typeof lastSegment && Array.isArray(parent.children)) {
1329
+ const insertIndex = lastSegment;
1330
+ if (-1 === insertIndex) {
1331
+ const newProperty = `${JSON.stringify(value)}`;
1332
+ let edit;
1333
+ if (0 === parent.children.length) edit = {
1334
+ offset: parent.offset + 1,
1335
+ length: 0,
1336
+ content: newProperty
1337
+ };
1338
+ else {
1339
+ const previous = parent.children[parent.children.length - 1];
1340
+ edit = {
1341
+ offset: previous.offset + previous.length,
1342
+ length: 0,
1343
+ content: ',' + newProperty
1344
+ };
1345
+ }
1346
+ return withFormatting(text, edit, options);
1347
+ }
1348
+ if (void 0 === value && parent.children.length >= 0) {
1349
+ const removalIndex = lastSegment;
1350
+ const toRemove = parent.children[removalIndex];
1351
+ let edit;
1352
+ if (1 === parent.children.length) edit = {
1353
+ offset: parent.offset + 1,
1354
+ length: parent.length - 2,
1355
+ content: ''
1356
+ };
1357
+ else if (parent.children.length - 1 === removalIndex) {
1358
+ let previous = parent.children[removalIndex - 1];
1359
+ let offset = previous.offset + previous.length;
1360
+ let parentEndOffset = parent.offset + parent.length;
1361
+ edit = {
1362
+ offset,
1363
+ length: parentEndOffset - 2 - offset,
1364
+ content: ''
1365
+ };
1366
+ } else edit = {
1367
+ offset: toRemove.offset,
1368
+ length: parent.children[removalIndex + 1].offset - toRemove.offset,
1369
+ content: ''
1370
+ };
1371
+ return withFormatting(text, edit, options);
1372
+ }
1373
+ if (void 0 !== value) {
1374
+ let edit;
1375
+ const newProperty = `${JSON.stringify(value)}`;
1376
+ if (!options.isArrayInsertion && parent.children.length > lastSegment) {
1377
+ const toModify = parent.children[lastSegment];
1378
+ edit = {
1379
+ offset: toModify.offset,
1380
+ length: toModify.length,
1381
+ content: newProperty
1382
+ };
1383
+ } else if (0 === parent.children.length || 0 === lastSegment) edit = {
1384
+ offset: parent.offset + 1,
1385
+ length: 0,
1386
+ content: 0 === parent.children.length ? newProperty : newProperty + ','
1387
+ };
1388
+ else {
1389
+ const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
1390
+ const previous = parent.children[index - 1];
1391
+ edit = {
1392
+ offset: previous.offset + previous.length,
1393
+ length: 0,
1394
+ content: ',' + newProperty
1395
+ };
1396
+ }
1397
+ return withFormatting(text, edit, options);
1398
+ } else throw new Error(`Can not ${void 0 === value ? 'remove' : options.isArrayInsertion ? 'insert' : 'modify'} Array index ${insertIndex} as length is not sufficient`);
1399
+ } else throw new Error(`Can not add ${'number' != typeof lastSegment ? 'index' : 'property'} to parent of type ${parent.type}`);
1400
+ if (void 0 === value) throw new Error('Can not delete in empty document');
1401
+ return withFormatting(text, {
1402
+ offset: root ? root.offset : 0,
1403
+ length: root ? root.length : 0,
1404
+ content: JSON.stringify(value)
1405
+ }, options);
1406
+ }
1407
+ function withFormatting(text, edit, options) {
1408
+ if (!options.formattingOptions) return [
1409
+ edit
1410
+ ];
1411
+ let newText = applyEdit(text, edit);
1412
+ let begin = edit.offset;
1413
+ let end = edit.offset + edit.content.length;
1414
+ if (0 === edit.length || 0 === edit.content.length) {
1415
+ while(begin > 0 && !isEOL(newText, begin - 1))begin--;
1416
+ while(end < newText.length && !isEOL(newText, end))end++;
1417
+ }
1418
+ const edits = format(newText, {
1419
+ offset: begin,
1420
+ length: end - begin
1421
+ }, {
1422
+ ...options.formattingOptions,
1423
+ keepLines: false
1424
+ });
1425
+ for(let i = edits.length - 1; i >= 0; i--){
1426
+ const edit = edits[i];
1427
+ newText = applyEdit(newText, edit);
1428
+ begin = Math.min(begin, edit.offset);
1429
+ end = Math.max(end, edit.offset + edit.length);
1430
+ end += edit.content.length - edit.length;
1431
+ }
1432
+ const editLength = text.length - (newText.length - end) - begin;
1433
+ return [
1434
+ {
1435
+ offset: begin,
1436
+ length: editLength,
1437
+ content: newText.substring(begin, end)
1438
+ }
1439
+ ];
1440
+ }
1441
+ function applyEdit(text, edit) {
1442
+ return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
1443
+ }
1444
+ var main_ScanError;
1445
+ (function(ScanError) {
1446
+ ScanError[ScanError["None"] = 0] = "None";
1447
+ ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
1448
+ ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
1449
+ ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
1450
+ ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
1451
+ ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
1452
+ ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
1453
+ })(main_ScanError || (main_ScanError = {}));
1454
+ var main_SyntaxKind;
1455
+ (function(SyntaxKind) {
1456
+ SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
1457
+ SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
1458
+ SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
1459
+ SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
1460
+ SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
1461
+ SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
1462
+ SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
1463
+ SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
1464
+ SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
1465
+ SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
1466
+ SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
1467
+ SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
1468
+ SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
1469
+ SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
1470
+ SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
1471
+ SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
1472
+ SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
1473
+ })(main_SyntaxKind || (main_SyntaxKind = {}));
1474
+ const main_parse = parse;
1475
+ var main_ParseErrorCode;
1476
+ (function(ParseErrorCode) {
1477
+ ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
1478
+ ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
1479
+ ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
1480
+ ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
1481
+ ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
1482
+ ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
1483
+ ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
1484
+ ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
1485
+ ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
1486
+ ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
1487
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
1488
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
1489
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
1490
+ ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
1491
+ ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
1492
+ ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
1493
+ })(main_ParseErrorCode || (main_ParseErrorCode = {}));
1494
+ function modify(text, path, value, options) {
1495
+ return setProperty(text, path, value, options);
1496
+ }
1497
+ function applyEdits(text, edits) {
1498
+ let sortedEdits = edits.slice(0).sort((a, b)=>{
1499
+ const diff = a.offset - b.offset;
1500
+ if (0 === diff) return a.length - b.length;
1501
+ return diff;
1502
+ });
1503
+ let lastModifiedOffset = text.length;
1504
+ for(let i = sortedEdits.length - 1; i >= 0; i--){
1505
+ let e = sortedEdits[i];
1506
+ if (e.offset + e.length <= lastModifiedOffset) text = applyEdit(text, e);
1507
+ else throw new Error('Overlapping edit');
1508
+ lastModifiedOffset = e.offset;
1509
+ }
1510
+ return text;
1511
+ }
1512
+ var parse_gitignore = __webpack_require__("./node_modules/.pnpm/parse-gitignore@2.0.0/node_modules/parse-gitignore/index.js");
1513
+ var parse_gitignore_default = /*#__PURE__*/ __webpack_require__.n(parse_gitignore);
1514
+ const SCHEMA_URL_PREFIX = "https://biomejs.dev/schemas/";
1515
+ const SCHEMA_URL_SUFFIX = "/schema.json";
1516
+ const BIOME_GLOB_PATTERN = "**/biome.{json,jsonc}";
1517
+ function extractSemver(versionRange) {
1518
+ return versionRange.replace(/^[^\d]*/, "");
1519
+ }
1520
+ async function shouldSyncBiomeSchema(workspaceRoot) {
1521
+ try {
1522
+ const pkgPath = (0, external_node_path_namespaceObject.join)(workspaceRoot, "package.json");
1523
+ const pkgJson = JSON.parse(await (0, promises_namespaceObject.readFile)(pkgPath, "utf-8"));
1524
+ return pkgJson.dependencies?.["@savvy-web/lint-staged"] !== void 0 || pkgJson.devDependencies?.["@savvy-web/lint-staged"] !== void 0;
1525
+ } catch {
1526
+ return false;
1527
+ }
1528
+ }
1529
+ async function parseGitignorePatterns(workspaceRoot) {
1530
+ try {
1531
+ const content = await (0, promises_namespaceObject.readFile)((0, external_node_path_namespaceObject.join)(workspaceRoot, ".gitignore"), "utf-8");
1532
+ return parse_gitignore_default()(content).patterns;
1533
+ } catch {
1534
+ return [];
1535
+ }
1536
+ }
1537
+ async function findBiomeConfigs(workspaceRoot) {
1538
+ const ignorePatterns = await parseGitignorePatterns(workspaceRoot);
1539
+ const results = [];
1540
+ for await (const entry of (0, promises_namespaceObject.glob)(BIOME_GLOB_PATTERN, {
1541
+ cwd: workspaceRoot,
1542
+ exclude: (name)=>ignorePatterns.some((pattern)=>(0, external_node_path_namespaceObject.matchesGlob)(name, pattern))
1543
+ }))results.push(entry);
1544
+ return results;
1545
+ }
1546
+ function buildSchemaUrl(version) {
1547
+ return `${SCHEMA_URL_PREFIX}${version}${SCHEMA_URL_SUFFIX}`;
1548
+ }
1549
+ async function syncBiomeSchema(workspaceRoot, biomeVersion) {
1550
+ try {
1551
+ if (!await shouldSyncBiomeSchema(workspaceRoot)) return;
1552
+ const version = extractSemver(biomeVersion);
1553
+ const expectedUrl = buildSchemaUrl(version);
1554
+ const configs = await findBiomeConfigs(workspaceRoot);
1555
+ for (const relativePath of configs){
1556
+ const configPath = (0, external_node_path_namespaceObject.join)(workspaceRoot, relativePath);
1557
+ const content = await (0, promises_namespaceObject.readFile)(configPath, "utf-8");
1558
+ const parsed = main_parse(content);
1559
+ if ("string" != typeof parsed?.$schema) continue;
1560
+ if (parsed.$schema === expectedUrl) continue;
1561
+ if (!parsed.$schema.startsWith(SCHEMA_URL_PREFIX)) continue;
1562
+ const edits = modify(content, [
1563
+ "$schema"
1564
+ ], expectedUrl, {});
1565
+ const updated = applyEdits(content, edits);
1566
+ await (0, promises_namespaceObject.writeFile)(configPath, updated, "utf-8");
1567
+ console.warn(`[pnpm-plugin-silk] Updated biome schema in ${relativePath} to v${version}`);
1568
+ }
1569
+ } catch (error) {
1570
+ console.warn("[pnpm-plugin-silk] Error syncing biome schema:", error instanceof Error ? error.message : String(error));
1571
+ }
1572
+ }
1573
+ const WARNING_BOX_WIDTH = 75;
1574
+ function formatOverrideWarning(overrides) {
1575
+ if (0 === overrides.length) return "";
1576
+ const lines = [];
1577
+ const border = "─".repeat(WARNING_BOX_WIDTH - 2);
1578
+ lines.push(`┌${border}┐`);
1579
+ lines.push(`│ ⚠️ SILK CATALOG OVERRIDE DETECTED${" ".repeat(WARNING_BOX_WIDTH - 39)}│`);
1580
+ lines.push(`├${border}┤`);
1581
+ lines.push(`│ The following entries override Silk-managed versions:${" ".repeat(WARNING_BOX_WIDTH - 58)}│`);
1582
+ lines.push(`│${" ".repeat(WARNING_BOX_WIDTH - 2)}│`);
1583
+ for (const override of overrides){
1584
+ const catalogPath = `catalogs.${override.catalog}.${override.package}`;
1585
+ const silkLine = ` Silk version: ${override.silkVersion}`;
1586
+ const localLine = ` Local override: ${override.localVersion}`;
1587
+ lines.push(`│ ${catalogPath}${" ".repeat(WARNING_BOX_WIDTH - catalogPath.length - 4)}│`);
1588
+ lines.push(`│${silkLine}${" ".repeat(WARNING_BOX_WIDTH - silkLine.length - 2)}│`);
1589
+ lines.push(`│${localLine}${" ".repeat(WARNING_BOX_WIDTH - localLine.length - 2)}│`);
1590
+ lines.push(`│${" ".repeat(WARNING_BOX_WIDTH - 2)}│`);
1591
+ }
1592
+ lines.push(`│ Local versions will be used. To use Silk defaults, remove these${" ".repeat(WARNING_BOX_WIDTH - 69)}│`);
1593
+ lines.push(`│ entries from your pnpm-workspace.yaml catalogs section.${" ".repeat(WARNING_BOX_WIDTH - 62)}│`);
1594
+ lines.push(`└${border}┘`);
1595
+ return lines.join("\n");
1596
+ }
1597
+ function warnOverrides(overrides) {
1598
+ if (overrides.length > 0) console.warn(formatOverrideWarning(overrides));
1599
+ }
1600
+ function mergeSingleCatalog(catalogName, silkCatalog, localCatalog, overrides) {
1601
+ const merged = {
1602
+ ...silkCatalog
1603
+ };
1604
+ if (!localCatalog) return merged;
1605
+ for (const [pkg, localVersion] of Object.entries(localCatalog)){
1606
+ const silkVersion = silkCatalog[pkg];
1607
+ if (void 0 !== silkVersion && silkVersion !== localVersion) overrides.push({
1608
+ catalog: catalogName,
1609
+ package: pkg,
1610
+ silkVersion,
1611
+ localVersion
1612
+ });
1613
+ merged[pkg] = localVersion;
1614
+ }
1615
+ return merged;
1616
+ }
1617
+ function mergeOverrides(silkOverrides, localOverrides, overrideWarnings) {
1618
+ const merged = {
1619
+ ...silkOverrides
1620
+ };
1621
+ if (!localOverrides) return merged;
1622
+ for (const [pkg, localVersion] of Object.entries(localOverrides)){
1623
+ const silkVersion = silkOverrides[pkg];
1624
+ if (void 0 !== silkVersion && silkVersion !== localVersion) overrideWarnings.push({
1625
+ catalog: "overrides",
1626
+ package: pkg,
1627
+ silkVersion,
1628
+ localVersion
1629
+ });
1630
+ merged[pkg] = localVersion;
1631
+ }
1632
+ return merged;
1633
+ }
1634
+ function mergeStringArrays(silkArray, localArray) {
1635
+ const merged = new Set(silkArray);
1636
+ if (localArray) for (const item of localArray)merged.add(item);
1637
+ return [
1638
+ ...merged
1639
+ ].sort((a, b)=>a.localeCompare(b));
1640
+ }
1641
+ function updateConfig(config) {
1642
+ try {
1643
+ const warnings = [];
1644
+ const existingCatalogs = config.catalogs ?? {};
1645
+ const mergedSilk = mergeSingleCatalog("silk", silkCatalogs.silk, existingCatalogs.silk, warnings);
1646
+ const mergedSilkPeers = mergeSingleCatalog("silkPeers", silkCatalogs.silkPeers, existingCatalogs.silkPeers, warnings);
1647
+ const mergedOverrides = mergeOverrides(silkCatalogs.silkOverrides, config.overrides, warnings);
1648
+ const mergedOnlyBuiltDependencies = mergeStringArrays(silkCatalogs.silkOnlyBuiltDependencies, config.onlyBuiltDependencies);
1649
+ const mergedPublicHoistPattern = mergeStringArrays(silkCatalogs.silkPublicHoistPattern, config.publicHoistPattern);
1650
+ warnOverrides(warnings);
1651
+ return {
1652
+ ...config,
1653
+ catalogs: {
1654
+ ...existingCatalogs,
1655
+ silk: mergedSilk,
1656
+ silkPeers: mergedSilkPeers
1657
+ },
1658
+ overrides: mergedOverrides,
1659
+ onlyBuiltDependencies: mergedOnlyBuiltDependencies,
1660
+ publicHoistPattern: mergedPublicHoistPattern
1661
+ };
1662
+ } catch (error) {
1663
+ console.warn("[pnpm-plugin-silk] Error merging catalogs, using local config only:", error instanceof Error ? error.message : String(error));
1664
+ return config;
1665
+ }
1666
+ }
1667
+ module.exports = {
1668
+ hooks: {
1669
+ async updateConfig (config) {
1670
+ const updatedConfig = updateConfig(config);
1671
+ const biomeVersion = silkCatalogs.silk["@biomejs/biome"] ?? silkCatalogs.silkPeers["@biomejs/biome"];
1672
+ if (biomeVersion) await syncBiomeSchema(process.cwd(), biomeVersion);
1673
+ return updatedConfig;
1674
+ }
1675
+ }
1676
+ };
1677
+ })();
161
1678
  for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
162
1679
  Object.defineProperty(exports, '__esModule', {
163
1680
  value: true