@savvy-web/pnpm-plugin-silk 0.5.0 → 0.5.2

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