@cloudflare/workers-utils 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.mts +41 -3
- package/dist/browser.mjs +2 -2
- package/dist/{chunk-73TUG5Z7.mjs → chunk-H6ZOCMLW.mjs} +2 -8
- package/dist/{chunk-DCOBXSFB.mjs → chunk-UB4QLUTD.mjs} +7 -1
- package/dist/chunk-WHXYFHDX.mjs +3180 -0
- package/dist/{browser-mD2xO9Bj.d.mts → config-cFPB-c8J.d.mts} +42 -40
- package/dist/index.d.mts +13 -4
- package/dist/index.mjs +213 -3253
- package/dist/metafile-esm.json +1 -1
- package/dist/test-helpers/index.d.mts +10 -1
- package/dist/test-helpers/index.mjs +68 -8
- package/package.json +9 -7
|
@@ -0,0 +1,3180 @@
|
|
|
1
|
+
import { __name, PATH_TO_DEPLOY_CONFIG } from './chunk-UB4QLUTD.mjs';
|
|
2
|
+
import fs, { readFileSync as readFileSync$1, existsSync } from 'node:fs';
|
|
3
|
+
import path3, { resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import process2 from 'node:process';
|
|
6
|
+
|
|
7
|
+
// src/errors.ts
|
|
8
|
+
var UserError = class extends Error {
|
|
9
|
+
static {
|
|
10
|
+
__name(this, "UserError");
|
|
11
|
+
}
|
|
12
|
+
telemetryMessage;
|
|
13
|
+
constructor(message, options) {
|
|
14
|
+
super(message, options);
|
|
15
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16
|
+
this.telemetryMessage = options?.telemetryMessage === true ? message : options?.telemetryMessage;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var DeprecationError = class extends UserError {
|
|
20
|
+
static {
|
|
21
|
+
__name(this, "DeprecationError");
|
|
22
|
+
}
|
|
23
|
+
constructor(message, options) {
|
|
24
|
+
super(`Deprecation:
|
|
25
|
+
${message}`, options);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var FatalError = class extends UserError {
|
|
29
|
+
constructor(message, code, options) {
|
|
30
|
+
super(message, options);
|
|
31
|
+
this.code = code;
|
|
32
|
+
}
|
|
33
|
+
static {
|
|
34
|
+
__name(this, "FatalError");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var CommandLineArgsError = class extends UserError {
|
|
38
|
+
static {
|
|
39
|
+
__name(this, "CommandLineArgsError");
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var JsonFriendlyFatalError = class extends FatalError {
|
|
43
|
+
constructor(message, code, options) {
|
|
44
|
+
super(message, code, options);
|
|
45
|
+
this.code = code;
|
|
46
|
+
}
|
|
47
|
+
static {
|
|
48
|
+
__name(this, "JsonFriendlyFatalError");
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var MissingConfigError = class extends Error {
|
|
52
|
+
static {
|
|
53
|
+
__name(this, "MissingConfigError");
|
|
54
|
+
}
|
|
55
|
+
telemetryMessage;
|
|
56
|
+
constructor(key) {
|
|
57
|
+
super(`Missing config value for ${key}`);
|
|
58
|
+
this.telemetryMessage = `Missing config value for ${key}`;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function createFatalError(message, isJson, code, telemetryMessage) {
|
|
62
|
+
if (isJson) {
|
|
63
|
+
return new JsonFriendlyFatalError(
|
|
64
|
+
JSON.stringify(message),
|
|
65
|
+
code,
|
|
66
|
+
telemetryMessage
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
return new FatalError(`${message}`, code, telemetryMessage);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
__name(createFatalError, "createFatalError");
|
|
73
|
+
|
|
74
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.2.0/node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
75
|
+
function createScanner(text, ignoreTrivia = false) {
|
|
76
|
+
const len = text.length;
|
|
77
|
+
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
|
|
78
|
+
function scanHexDigits(count, exact) {
|
|
79
|
+
let digits = 0;
|
|
80
|
+
let value2 = 0;
|
|
81
|
+
while (digits < count || !exact) {
|
|
82
|
+
let ch = text.charCodeAt(pos);
|
|
83
|
+
if (ch >= 48 && ch <= 57) {
|
|
84
|
+
value2 = value2 * 16 + ch - 48;
|
|
85
|
+
} else if (ch >= 65 && ch <= 70) {
|
|
86
|
+
value2 = value2 * 16 + ch - 65 + 10;
|
|
87
|
+
} else if (ch >= 97 && ch <= 102) {
|
|
88
|
+
value2 = value2 * 16 + ch - 97 + 10;
|
|
89
|
+
} else {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
pos++;
|
|
93
|
+
digits++;
|
|
94
|
+
}
|
|
95
|
+
if (digits < count) {
|
|
96
|
+
value2 = -1;
|
|
97
|
+
}
|
|
98
|
+
return value2;
|
|
99
|
+
}
|
|
100
|
+
__name(scanHexDigits, "scanHexDigits");
|
|
101
|
+
function setPosition(newPosition) {
|
|
102
|
+
pos = newPosition;
|
|
103
|
+
value = "";
|
|
104
|
+
tokenOffset = 0;
|
|
105
|
+
token = 16;
|
|
106
|
+
scanError = 0;
|
|
107
|
+
}
|
|
108
|
+
__name(setPosition, "setPosition");
|
|
109
|
+
function scanNumber() {
|
|
110
|
+
let start = pos;
|
|
111
|
+
if (text.charCodeAt(pos) === 48) {
|
|
112
|
+
pos++;
|
|
113
|
+
} else {
|
|
114
|
+
pos++;
|
|
115
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
116
|
+
pos++;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (pos < text.length && text.charCodeAt(pos) === 46) {
|
|
120
|
+
pos++;
|
|
121
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
122
|
+
pos++;
|
|
123
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
124
|
+
pos++;
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
scanError = 3;
|
|
128
|
+
return text.substring(start, pos);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
let end = pos;
|
|
132
|
+
if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
|
|
133
|
+
pos++;
|
|
134
|
+
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
|
|
135
|
+
pos++;
|
|
136
|
+
}
|
|
137
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
138
|
+
pos++;
|
|
139
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
140
|
+
pos++;
|
|
141
|
+
}
|
|
142
|
+
end = pos;
|
|
143
|
+
} else {
|
|
144
|
+
scanError = 3;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return text.substring(start, end);
|
|
148
|
+
}
|
|
149
|
+
__name(scanNumber, "scanNumber");
|
|
150
|
+
function scanString() {
|
|
151
|
+
let result = "", start = pos;
|
|
152
|
+
while (true) {
|
|
153
|
+
if (pos >= len) {
|
|
154
|
+
result += text.substring(start, pos);
|
|
155
|
+
scanError = 2;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
const ch = text.charCodeAt(pos);
|
|
159
|
+
if (ch === 34) {
|
|
160
|
+
result += text.substring(start, pos);
|
|
161
|
+
pos++;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (ch === 92) {
|
|
165
|
+
result += text.substring(start, pos);
|
|
166
|
+
pos++;
|
|
167
|
+
if (pos >= len) {
|
|
168
|
+
scanError = 2;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
const ch2 = text.charCodeAt(pos++);
|
|
172
|
+
switch (ch2) {
|
|
173
|
+
case 34:
|
|
174
|
+
result += '"';
|
|
175
|
+
break;
|
|
176
|
+
case 92:
|
|
177
|
+
result += "\\";
|
|
178
|
+
break;
|
|
179
|
+
case 47:
|
|
180
|
+
result += "/";
|
|
181
|
+
break;
|
|
182
|
+
case 98:
|
|
183
|
+
result += "\b";
|
|
184
|
+
break;
|
|
185
|
+
case 102:
|
|
186
|
+
result += "\f";
|
|
187
|
+
break;
|
|
188
|
+
case 110:
|
|
189
|
+
result += "\n";
|
|
190
|
+
break;
|
|
191
|
+
case 114:
|
|
192
|
+
result += "\r";
|
|
193
|
+
break;
|
|
194
|
+
case 116:
|
|
195
|
+
result += " ";
|
|
196
|
+
break;
|
|
197
|
+
case 117:
|
|
198
|
+
const ch3 = scanHexDigits(4, true);
|
|
199
|
+
if (ch3 >= 0) {
|
|
200
|
+
result += String.fromCharCode(ch3);
|
|
201
|
+
} else {
|
|
202
|
+
scanError = 4;
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
default:
|
|
206
|
+
scanError = 5;
|
|
207
|
+
}
|
|
208
|
+
start = pos;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (ch >= 0 && ch <= 31) {
|
|
212
|
+
if (isLineBreak(ch)) {
|
|
213
|
+
result += text.substring(start, pos);
|
|
214
|
+
scanError = 2;
|
|
215
|
+
break;
|
|
216
|
+
} else {
|
|
217
|
+
scanError = 6;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
pos++;
|
|
221
|
+
}
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
__name(scanString, "scanString");
|
|
225
|
+
function scanNext() {
|
|
226
|
+
value = "";
|
|
227
|
+
scanError = 0;
|
|
228
|
+
tokenOffset = pos;
|
|
229
|
+
lineStartOffset = lineNumber;
|
|
230
|
+
prevTokenLineStartOffset = tokenLineStartOffset;
|
|
231
|
+
if (pos >= len) {
|
|
232
|
+
tokenOffset = len;
|
|
233
|
+
return token = 17;
|
|
234
|
+
}
|
|
235
|
+
let code = text.charCodeAt(pos);
|
|
236
|
+
if (isWhiteSpace(code)) {
|
|
237
|
+
do {
|
|
238
|
+
pos++;
|
|
239
|
+
value += String.fromCharCode(code);
|
|
240
|
+
code = text.charCodeAt(pos);
|
|
241
|
+
} while (isWhiteSpace(code));
|
|
242
|
+
return token = 15;
|
|
243
|
+
}
|
|
244
|
+
if (isLineBreak(code)) {
|
|
245
|
+
pos++;
|
|
246
|
+
value += String.fromCharCode(code);
|
|
247
|
+
if (code === 13 && text.charCodeAt(pos) === 10) {
|
|
248
|
+
pos++;
|
|
249
|
+
value += "\n";
|
|
250
|
+
}
|
|
251
|
+
lineNumber++;
|
|
252
|
+
tokenLineStartOffset = pos;
|
|
253
|
+
return token = 14;
|
|
254
|
+
}
|
|
255
|
+
switch (code) {
|
|
256
|
+
// tokens: []{}:,
|
|
257
|
+
case 123:
|
|
258
|
+
pos++;
|
|
259
|
+
return token = 1;
|
|
260
|
+
case 125:
|
|
261
|
+
pos++;
|
|
262
|
+
return token = 2;
|
|
263
|
+
case 91:
|
|
264
|
+
pos++;
|
|
265
|
+
return token = 3;
|
|
266
|
+
case 93:
|
|
267
|
+
pos++;
|
|
268
|
+
return token = 4;
|
|
269
|
+
case 58:
|
|
270
|
+
pos++;
|
|
271
|
+
return token = 6;
|
|
272
|
+
case 44:
|
|
273
|
+
pos++;
|
|
274
|
+
return token = 5;
|
|
275
|
+
// strings
|
|
276
|
+
case 34:
|
|
277
|
+
pos++;
|
|
278
|
+
value = scanString();
|
|
279
|
+
return token = 10;
|
|
280
|
+
// comments
|
|
281
|
+
case 47:
|
|
282
|
+
const start = pos - 1;
|
|
283
|
+
if (text.charCodeAt(pos + 1) === 47) {
|
|
284
|
+
pos += 2;
|
|
285
|
+
while (pos < len) {
|
|
286
|
+
if (isLineBreak(text.charCodeAt(pos))) {
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
pos++;
|
|
290
|
+
}
|
|
291
|
+
value = text.substring(start, pos);
|
|
292
|
+
return token = 12;
|
|
293
|
+
}
|
|
294
|
+
if (text.charCodeAt(pos + 1) === 42) {
|
|
295
|
+
pos += 2;
|
|
296
|
+
const safeLength = len - 1;
|
|
297
|
+
let commentClosed = false;
|
|
298
|
+
while (pos < safeLength) {
|
|
299
|
+
const ch = text.charCodeAt(pos);
|
|
300
|
+
if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
|
|
301
|
+
pos += 2;
|
|
302
|
+
commentClosed = true;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
pos++;
|
|
306
|
+
if (isLineBreak(ch)) {
|
|
307
|
+
if (ch === 13 && text.charCodeAt(pos) === 10) {
|
|
308
|
+
pos++;
|
|
309
|
+
}
|
|
310
|
+
lineNumber++;
|
|
311
|
+
tokenLineStartOffset = pos;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (!commentClosed) {
|
|
315
|
+
pos++;
|
|
316
|
+
scanError = 1;
|
|
317
|
+
}
|
|
318
|
+
value = text.substring(start, pos);
|
|
319
|
+
return token = 13;
|
|
320
|
+
}
|
|
321
|
+
value += String.fromCharCode(code);
|
|
322
|
+
pos++;
|
|
323
|
+
return token = 16;
|
|
324
|
+
// numbers
|
|
325
|
+
case 45:
|
|
326
|
+
value += String.fromCharCode(code);
|
|
327
|
+
pos++;
|
|
328
|
+
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
329
|
+
return token = 16;
|
|
330
|
+
}
|
|
331
|
+
// found a minus, followed by a number so
|
|
332
|
+
// we fall through to proceed with scanning
|
|
333
|
+
// numbers
|
|
334
|
+
case 48:
|
|
335
|
+
case 49:
|
|
336
|
+
case 50:
|
|
337
|
+
case 51:
|
|
338
|
+
case 52:
|
|
339
|
+
case 53:
|
|
340
|
+
case 54:
|
|
341
|
+
case 55:
|
|
342
|
+
case 56:
|
|
343
|
+
case 57:
|
|
344
|
+
value += scanNumber();
|
|
345
|
+
return token = 11;
|
|
346
|
+
// literals and unknown symbols
|
|
347
|
+
default:
|
|
348
|
+
while (pos < len && isUnknownContentCharacter(code)) {
|
|
349
|
+
pos++;
|
|
350
|
+
code = text.charCodeAt(pos);
|
|
351
|
+
}
|
|
352
|
+
if (tokenOffset !== pos) {
|
|
353
|
+
value = text.substring(tokenOffset, pos);
|
|
354
|
+
switch (value) {
|
|
355
|
+
case "true":
|
|
356
|
+
return token = 8;
|
|
357
|
+
case "false":
|
|
358
|
+
return token = 9;
|
|
359
|
+
case "null":
|
|
360
|
+
return token = 7;
|
|
361
|
+
}
|
|
362
|
+
return token = 16;
|
|
363
|
+
}
|
|
364
|
+
value += String.fromCharCode(code);
|
|
365
|
+
pos++;
|
|
366
|
+
return token = 16;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
__name(scanNext, "scanNext");
|
|
370
|
+
function isUnknownContentCharacter(code) {
|
|
371
|
+
if (isWhiteSpace(code) || isLineBreak(code)) {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
switch (code) {
|
|
375
|
+
case 125:
|
|
376
|
+
case 93:
|
|
377
|
+
case 123:
|
|
378
|
+
case 91:
|
|
379
|
+
case 34:
|
|
380
|
+
case 58:
|
|
381
|
+
case 44:
|
|
382
|
+
case 47:
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
__name(isUnknownContentCharacter, "isUnknownContentCharacter");
|
|
388
|
+
function scanNextNonTrivia() {
|
|
389
|
+
let result;
|
|
390
|
+
do {
|
|
391
|
+
result = scanNext();
|
|
392
|
+
} while (result >= 12 && result <= 15);
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
__name(scanNextNonTrivia, "scanNextNonTrivia");
|
|
396
|
+
return {
|
|
397
|
+
setPosition,
|
|
398
|
+
getPosition: /* @__PURE__ */ __name(() => pos, "getPosition"),
|
|
399
|
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
400
|
+
getToken: /* @__PURE__ */ __name(() => token, "getToken"),
|
|
401
|
+
getTokenValue: /* @__PURE__ */ __name(() => value, "getTokenValue"),
|
|
402
|
+
getTokenOffset: /* @__PURE__ */ __name(() => tokenOffset, "getTokenOffset"),
|
|
403
|
+
getTokenLength: /* @__PURE__ */ __name(() => pos - tokenOffset, "getTokenLength"),
|
|
404
|
+
getTokenStartLine: /* @__PURE__ */ __name(() => lineStartOffset, "getTokenStartLine"),
|
|
405
|
+
getTokenStartCharacter: /* @__PURE__ */ __name(() => tokenOffset - prevTokenLineStartOffset, "getTokenStartCharacter"),
|
|
406
|
+
getTokenError: /* @__PURE__ */ __name(() => scanError, "getTokenError")
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
__name(createScanner, "createScanner");
|
|
410
|
+
function isWhiteSpace(ch) {
|
|
411
|
+
return ch === 32 || ch === 9;
|
|
412
|
+
}
|
|
413
|
+
__name(isWhiteSpace, "isWhiteSpace");
|
|
414
|
+
function isLineBreak(ch) {
|
|
415
|
+
return ch === 10 || ch === 13;
|
|
416
|
+
}
|
|
417
|
+
__name(isLineBreak, "isLineBreak");
|
|
418
|
+
function isDigit(ch) {
|
|
419
|
+
return ch >= 48 && ch <= 57;
|
|
420
|
+
}
|
|
421
|
+
__name(isDigit, "isDigit");
|
|
422
|
+
var CharacterCodes;
|
|
423
|
+
(function(CharacterCodes2) {
|
|
424
|
+
CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
|
|
425
|
+
CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
|
|
426
|
+
CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
|
|
427
|
+
CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
|
|
428
|
+
CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
|
|
429
|
+
CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
|
|
430
|
+
CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
|
|
431
|
+
CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
|
|
432
|
+
CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
|
|
433
|
+
CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
|
|
434
|
+
CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
|
|
435
|
+
CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
|
|
436
|
+
CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
|
|
437
|
+
CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
|
|
438
|
+
CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
|
|
439
|
+
CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
|
|
440
|
+
CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
|
|
441
|
+
CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
|
|
442
|
+
CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
|
|
443
|
+
CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
|
|
444
|
+
CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
|
|
445
|
+
CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
|
|
446
|
+
CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
|
|
447
|
+
CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
|
|
448
|
+
CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
|
|
449
|
+
CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
|
|
450
|
+
CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
|
|
451
|
+
CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
|
|
452
|
+
CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
|
|
453
|
+
CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
|
|
454
|
+
CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
|
|
455
|
+
CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
|
|
456
|
+
CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
|
|
457
|
+
CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
|
|
458
|
+
CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
|
|
459
|
+
CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
|
|
460
|
+
CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
|
|
461
|
+
CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
|
|
462
|
+
CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
|
|
463
|
+
CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
|
|
464
|
+
CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
|
|
465
|
+
CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
|
|
466
|
+
CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
|
|
467
|
+
CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
|
|
468
|
+
CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
|
|
469
|
+
CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
|
|
470
|
+
CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
|
|
471
|
+
CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
|
|
472
|
+
CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
|
|
473
|
+
CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
|
|
474
|
+
CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
|
|
475
|
+
CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
|
|
476
|
+
CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
|
|
477
|
+
CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
|
|
478
|
+
CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
|
|
479
|
+
CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
|
|
480
|
+
CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
|
|
481
|
+
CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
|
|
482
|
+
CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
|
|
483
|
+
CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
|
|
484
|
+
CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
|
|
485
|
+
CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
|
|
486
|
+
CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
|
|
487
|
+
CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
|
|
488
|
+
CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
|
|
489
|
+
CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
|
|
490
|
+
CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
|
|
491
|
+
CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
|
|
492
|
+
CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
|
|
493
|
+
CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
|
|
494
|
+
CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
|
|
495
|
+
CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
|
|
496
|
+
CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
|
|
497
|
+
CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
|
|
498
|
+
CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
|
|
499
|
+
CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
|
|
500
|
+
CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
|
|
501
|
+
CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
|
|
502
|
+
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
|
|
503
|
+
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
|
|
504
|
+
})(CharacterCodes || (CharacterCodes = {}));
|
|
505
|
+
|
|
506
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.2.0/node_modules/jsonc-parser/lib/esm/impl/format.js
|
|
507
|
+
function format(documentText, range, options) {
|
|
508
|
+
let initialIndentLevel;
|
|
509
|
+
let formatText;
|
|
510
|
+
let formatTextStart;
|
|
511
|
+
let rangeStart;
|
|
512
|
+
let rangeEnd;
|
|
513
|
+
if (range) {
|
|
514
|
+
rangeStart = range.offset;
|
|
515
|
+
rangeEnd = rangeStart + range.length;
|
|
516
|
+
formatTextStart = rangeStart;
|
|
517
|
+
while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
|
|
518
|
+
formatTextStart--;
|
|
519
|
+
}
|
|
520
|
+
let endOffset = rangeEnd;
|
|
521
|
+
while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
|
|
522
|
+
endOffset++;
|
|
523
|
+
}
|
|
524
|
+
formatText = documentText.substring(formatTextStart, endOffset);
|
|
525
|
+
initialIndentLevel = computeIndentLevel(formatText, options);
|
|
526
|
+
} else {
|
|
527
|
+
formatText = documentText;
|
|
528
|
+
initialIndentLevel = 0;
|
|
529
|
+
formatTextStart = 0;
|
|
530
|
+
rangeStart = 0;
|
|
531
|
+
rangeEnd = documentText.length;
|
|
532
|
+
}
|
|
533
|
+
const eol = getEOL(options, documentText);
|
|
534
|
+
let numberLineBreaks = 0;
|
|
535
|
+
let indentLevel = 0;
|
|
536
|
+
let indentValue;
|
|
537
|
+
if (options.insertSpaces) {
|
|
538
|
+
indentValue = repeat(" ", options.tabSize || 4);
|
|
539
|
+
} else {
|
|
540
|
+
indentValue = " ";
|
|
541
|
+
}
|
|
542
|
+
let scanner = createScanner(formatText, false);
|
|
543
|
+
let hasError = false;
|
|
544
|
+
function newLinesAndIndent() {
|
|
545
|
+
if (numberLineBreaks > 1) {
|
|
546
|
+
return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
547
|
+
} else {
|
|
548
|
+
return eol + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
__name(newLinesAndIndent, "newLinesAndIndent");
|
|
552
|
+
function scanNext() {
|
|
553
|
+
let token = scanner.scan();
|
|
554
|
+
numberLineBreaks = 0;
|
|
555
|
+
while (token === 15 || token === 14) {
|
|
556
|
+
if (token === 14 && options.keepLines) {
|
|
557
|
+
numberLineBreaks += 1;
|
|
558
|
+
} else if (token === 14) {
|
|
559
|
+
numberLineBreaks = 1;
|
|
560
|
+
}
|
|
561
|
+
token = scanner.scan();
|
|
562
|
+
}
|
|
563
|
+
hasError = token === 16 || scanner.getTokenError() !== 0;
|
|
564
|
+
return token;
|
|
565
|
+
}
|
|
566
|
+
__name(scanNext, "scanNext");
|
|
567
|
+
const editOperations = [];
|
|
568
|
+
function addEdit(text, startOffset, endOffset) {
|
|
569
|
+
if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !== text) {
|
|
570
|
+
editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
__name(addEdit, "addEdit");
|
|
574
|
+
let firstToken = scanNext();
|
|
575
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
576
|
+
addEdit(repeat(eol, numberLineBreaks), 0, 0);
|
|
577
|
+
}
|
|
578
|
+
if (firstToken !== 17) {
|
|
579
|
+
let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
580
|
+
let initialIndent = repeat(indentValue, initialIndentLevel);
|
|
581
|
+
addEdit(initialIndent, formatTextStart, firstTokenStart);
|
|
582
|
+
}
|
|
583
|
+
while (firstToken !== 17) {
|
|
584
|
+
let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
585
|
+
let secondToken = scanNext();
|
|
586
|
+
let replaceContent = "";
|
|
587
|
+
let needsLineBreak = false;
|
|
588
|
+
while (numberLineBreaks === 0 && (secondToken === 12 || secondToken === 13)) {
|
|
589
|
+
let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
590
|
+
addEdit(" ", firstTokenEnd, commentTokenStart);
|
|
591
|
+
firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
592
|
+
needsLineBreak = secondToken === 12;
|
|
593
|
+
replaceContent = needsLineBreak ? newLinesAndIndent() : "";
|
|
594
|
+
secondToken = scanNext();
|
|
595
|
+
}
|
|
596
|
+
if (secondToken === 2) {
|
|
597
|
+
if (firstToken !== 1) {
|
|
598
|
+
indentLevel--;
|
|
599
|
+
}
|
|
600
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1) {
|
|
601
|
+
replaceContent = newLinesAndIndent();
|
|
602
|
+
} else if (options.keepLines) {
|
|
603
|
+
replaceContent = " ";
|
|
604
|
+
}
|
|
605
|
+
} else if (secondToken === 4) {
|
|
606
|
+
if (firstToken !== 3) {
|
|
607
|
+
indentLevel--;
|
|
608
|
+
}
|
|
609
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3) {
|
|
610
|
+
replaceContent = newLinesAndIndent();
|
|
611
|
+
} else if (options.keepLines) {
|
|
612
|
+
replaceContent = " ";
|
|
613
|
+
}
|
|
614
|
+
} else {
|
|
615
|
+
switch (firstToken) {
|
|
616
|
+
case 3:
|
|
617
|
+
case 1:
|
|
618
|
+
indentLevel++;
|
|
619
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
|
620
|
+
replaceContent = newLinesAndIndent();
|
|
621
|
+
} else {
|
|
622
|
+
replaceContent = " ";
|
|
623
|
+
}
|
|
624
|
+
break;
|
|
625
|
+
case 5:
|
|
626
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
|
627
|
+
replaceContent = newLinesAndIndent();
|
|
628
|
+
} else {
|
|
629
|
+
replaceContent = " ";
|
|
630
|
+
}
|
|
631
|
+
break;
|
|
632
|
+
case 12:
|
|
633
|
+
replaceContent = newLinesAndIndent();
|
|
634
|
+
break;
|
|
635
|
+
case 13:
|
|
636
|
+
if (numberLineBreaks > 0) {
|
|
637
|
+
replaceContent = newLinesAndIndent();
|
|
638
|
+
} else if (!needsLineBreak) {
|
|
639
|
+
replaceContent = " ";
|
|
640
|
+
}
|
|
641
|
+
break;
|
|
642
|
+
case 6:
|
|
643
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
644
|
+
replaceContent = newLinesAndIndent();
|
|
645
|
+
} else if (!needsLineBreak) {
|
|
646
|
+
replaceContent = " ";
|
|
647
|
+
}
|
|
648
|
+
break;
|
|
649
|
+
case 10:
|
|
650
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
651
|
+
replaceContent = newLinesAndIndent();
|
|
652
|
+
} else if (secondToken === 6 && !needsLineBreak) {
|
|
653
|
+
replaceContent = "";
|
|
654
|
+
}
|
|
655
|
+
break;
|
|
656
|
+
case 7:
|
|
657
|
+
case 8:
|
|
658
|
+
case 9:
|
|
659
|
+
case 11:
|
|
660
|
+
case 2:
|
|
661
|
+
case 4:
|
|
662
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
663
|
+
replaceContent = newLinesAndIndent();
|
|
664
|
+
} else {
|
|
665
|
+
if ((secondToken === 12 || secondToken === 13) && !needsLineBreak) {
|
|
666
|
+
replaceContent = " ";
|
|
667
|
+
} else if (secondToken !== 5 && secondToken !== 17) {
|
|
668
|
+
hasError = true;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
break;
|
|
672
|
+
case 16:
|
|
673
|
+
hasError = true;
|
|
674
|
+
break;
|
|
675
|
+
}
|
|
676
|
+
if (numberLineBreaks > 0 && (secondToken === 12 || secondToken === 13)) {
|
|
677
|
+
replaceContent = newLinesAndIndent();
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
if (secondToken === 17) {
|
|
681
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
682
|
+
replaceContent = newLinesAndIndent();
|
|
683
|
+
} else {
|
|
684
|
+
replaceContent = options.insertFinalNewline ? eol : "";
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
688
|
+
addEdit(replaceContent, firstTokenEnd, secondTokenStart);
|
|
689
|
+
firstToken = secondToken;
|
|
690
|
+
}
|
|
691
|
+
return editOperations;
|
|
692
|
+
}
|
|
693
|
+
__name(format, "format");
|
|
694
|
+
function repeat(s, count) {
|
|
695
|
+
let result = "";
|
|
696
|
+
for (let i = 0; i < count; i++) {
|
|
697
|
+
result += s;
|
|
698
|
+
}
|
|
699
|
+
return result;
|
|
700
|
+
}
|
|
701
|
+
__name(repeat, "repeat");
|
|
702
|
+
function computeIndentLevel(content, options) {
|
|
703
|
+
let i = 0;
|
|
704
|
+
let nChars = 0;
|
|
705
|
+
const tabSize = options.tabSize || 4;
|
|
706
|
+
while (i < content.length) {
|
|
707
|
+
let ch = content.charAt(i);
|
|
708
|
+
if (ch === " ") {
|
|
709
|
+
nChars++;
|
|
710
|
+
} else if (ch === " ") {
|
|
711
|
+
nChars += tabSize;
|
|
712
|
+
} else {
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
i++;
|
|
716
|
+
}
|
|
717
|
+
return Math.floor(nChars / tabSize);
|
|
718
|
+
}
|
|
719
|
+
__name(computeIndentLevel, "computeIndentLevel");
|
|
720
|
+
function getEOL(options, text) {
|
|
721
|
+
for (let i = 0; i < text.length; i++) {
|
|
722
|
+
const ch = text.charAt(i);
|
|
723
|
+
if (ch === "\r") {
|
|
724
|
+
if (i + 1 < text.length && text.charAt(i + 1) === "\n") {
|
|
725
|
+
return "\r\n";
|
|
726
|
+
}
|
|
727
|
+
return "\r";
|
|
728
|
+
} else if (ch === "\n") {
|
|
729
|
+
return "\n";
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
return options && options.eol || "\n";
|
|
733
|
+
}
|
|
734
|
+
__name(getEOL, "getEOL");
|
|
735
|
+
function isEOL(text, offset) {
|
|
736
|
+
return "\r\n".indexOf(text.charAt(offset)) !== -1;
|
|
737
|
+
}
|
|
738
|
+
__name(isEOL, "isEOL");
|
|
739
|
+
|
|
740
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.2.0/node_modules/jsonc-parser/lib/esm/impl/parser.js
|
|
741
|
+
var ParseOptions;
|
|
742
|
+
(function(ParseOptions2) {
|
|
743
|
+
ParseOptions2.DEFAULT = {
|
|
744
|
+
allowTrailingComma: false
|
|
745
|
+
};
|
|
746
|
+
})(ParseOptions || (ParseOptions = {}));
|
|
747
|
+
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
748
|
+
let currentProperty = null;
|
|
749
|
+
let currentParent = [];
|
|
750
|
+
const previousParents = [];
|
|
751
|
+
function onValue(value) {
|
|
752
|
+
if (Array.isArray(currentParent)) {
|
|
753
|
+
currentParent.push(value);
|
|
754
|
+
} else if (currentProperty !== null) {
|
|
755
|
+
currentParent[currentProperty] = value;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
__name(onValue, "onValue");
|
|
759
|
+
const visitor = {
|
|
760
|
+
onObjectBegin: /* @__PURE__ */ __name(() => {
|
|
761
|
+
const object = {};
|
|
762
|
+
onValue(object);
|
|
763
|
+
previousParents.push(currentParent);
|
|
764
|
+
currentParent = object;
|
|
765
|
+
currentProperty = null;
|
|
766
|
+
}, "onObjectBegin"),
|
|
767
|
+
onObjectProperty: /* @__PURE__ */ __name((name) => {
|
|
768
|
+
currentProperty = name;
|
|
769
|
+
}, "onObjectProperty"),
|
|
770
|
+
onObjectEnd: /* @__PURE__ */ __name(() => {
|
|
771
|
+
currentParent = previousParents.pop();
|
|
772
|
+
}, "onObjectEnd"),
|
|
773
|
+
onArrayBegin: /* @__PURE__ */ __name(() => {
|
|
774
|
+
const array = [];
|
|
775
|
+
onValue(array);
|
|
776
|
+
previousParents.push(currentParent);
|
|
777
|
+
currentParent = array;
|
|
778
|
+
currentProperty = null;
|
|
779
|
+
}, "onArrayBegin"),
|
|
780
|
+
onArrayEnd: /* @__PURE__ */ __name(() => {
|
|
781
|
+
currentParent = previousParents.pop();
|
|
782
|
+
}, "onArrayEnd"),
|
|
783
|
+
onLiteralValue: onValue,
|
|
784
|
+
onError: /* @__PURE__ */ __name((error, offset, length) => {
|
|
785
|
+
errors.push({ error, offset, length });
|
|
786
|
+
}, "onError")
|
|
787
|
+
};
|
|
788
|
+
visit(text, visitor, options);
|
|
789
|
+
return currentParent[0];
|
|
790
|
+
}
|
|
791
|
+
__name(parse, "parse");
|
|
792
|
+
function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
793
|
+
let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
|
|
794
|
+
function ensurePropertyComplete(endOffset) {
|
|
795
|
+
if (currentParent.type === "property") {
|
|
796
|
+
currentParent.length = endOffset - currentParent.offset;
|
|
797
|
+
currentParent = currentParent.parent;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
__name(ensurePropertyComplete, "ensurePropertyComplete");
|
|
801
|
+
function onValue(valueNode) {
|
|
802
|
+
currentParent.children.push(valueNode);
|
|
803
|
+
return valueNode;
|
|
804
|
+
}
|
|
805
|
+
__name(onValue, "onValue");
|
|
806
|
+
const visitor = {
|
|
807
|
+
onObjectBegin: /* @__PURE__ */ __name((offset) => {
|
|
808
|
+
currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
|
|
809
|
+
}, "onObjectBegin"),
|
|
810
|
+
onObjectProperty: /* @__PURE__ */ __name((name, offset, length) => {
|
|
811
|
+
currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
|
|
812
|
+
currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
|
|
813
|
+
}, "onObjectProperty"),
|
|
814
|
+
onObjectEnd: /* @__PURE__ */ __name((offset, length) => {
|
|
815
|
+
ensurePropertyComplete(offset + length);
|
|
816
|
+
currentParent.length = offset + length - currentParent.offset;
|
|
817
|
+
currentParent = currentParent.parent;
|
|
818
|
+
ensurePropertyComplete(offset + length);
|
|
819
|
+
}, "onObjectEnd"),
|
|
820
|
+
onArrayBegin: /* @__PURE__ */ __name((offset, length) => {
|
|
821
|
+
currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
|
|
822
|
+
}, "onArrayBegin"),
|
|
823
|
+
onArrayEnd: /* @__PURE__ */ __name((offset, length) => {
|
|
824
|
+
currentParent.length = offset + length - currentParent.offset;
|
|
825
|
+
currentParent = currentParent.parent;
|
|
826
|
+
ensurePropertyComplete(offset + length);
|
|
827
|
+
}, "onArrayEnd"),
|
|
828
|
+
onLiteralValue: /* @__PURE__ */ __name((value, offset, length) => {
|
|
829
|
+
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
|
830
|
+
ensurePropertyComplete(offset + length);
|
|
831
|
+
}, "onLiteralValue"),
|
|
832
|
+
onSeparator: /* @__PURE__ */ __name((sep, offset, length) => {
|
|
833
|
+
if (currentParent.type === "property") {
|
|
834
|
+
if (sep === ":") {
|
|
835
|
+
currentParent.colonOffset = offset;
|
|
836
|
+
} else if (sep === ",") {
|
|
837
|
+
ensurePropertyComplete(offset);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}, "onSeparator"),
|
|
841
|
+
onError: /* @__PURE__ */ __name((error, offset, length) => {
|
|
842
|
+
errors.push({ error, offset, length });
|
|
843
|
+
}, "onError")
|
|
844
|
+
};
|
|
845
|
+
visit(text, visitor, options);
|
|
846
|
+
const result = currentParent.children[0];
|
|
847
|
+
if (result) {
|
|
848
|
+
delete result.parent;
|
|
849
|
+
}
|
|
850
|
+
return result;
|
|
851
|
+
}
|
|
852
|
+
__name(parseTree, "parseTree");
|
|
853
|
+
function findNodeAtLocation(root, path4) {
|
|
854
|
+
if (!root) {
|
|
855
|
+
return void 0;
|
|
856
|
+
}
|
|
857
|
+
let node = root;
|
|
858
|
+
for (let segment of path4) {
|
|
859
|
+
if (typeof segment === "string") {
|
|
860
|
+
if (node.type !== "object" || !Array.isArray(node.children)) {
|
|
861
|
+
return void 0;
|
|
862
|
+
}
|
|
863
|
+
let found = false;
|
|
864
|
+
for (const propertyNode of node.children) {
|
|
865
|
+
if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
|
|
866
|
+
node = propertyNode.children[1];
|
|
867
|
+
found = true;
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
if (!found) {
|
|
872
|
+
return void 0;
|
|
873
|
+
}
|
|
874
|
+
} else {
|
|
875
|
+
const index = segment;
|
|
876
|
+
if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
|
|
877
|
+
return void 0;
|
|
878
|
+
}
|
|
879
|
+
node = node.children[index];
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return node;
|
|
883
|
+
}
|
|
884
|
+
__name(findNodeAtLocation, "findNodeAtLocation");
|
|
885
|
+
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
886
|
+
const _scanner = createScanner(text, false);
|
|
887
|
+
const _jsonPath = [];
|
|
888
|
+
function toNoArgVisit(visitFunction) {
|
|
889
|
+
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
890
|
+
}
|
|
891
|
+
__name(toNoArgVisit, "toNoArgVisit");
|
|
892
|
+
function toNoArgVisitWithPath(visitFunction) {
|
|
893
|
+
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
894
|
+
}
|
|
895
|
+
__name(toNoArgVisitWithPath, "toNoArgVisitWithPath");
|
|
896
|
+
function toOneArgVisit(visitFunction) {
|
|
897
|
+
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
898
|
+
}
|
|
899
|
+
__name(toOneArgVisit, "toOneArgVisit");
|
|
900
|
+
function toOneArgVisitWithPath(visitFunction) {
|
|
901
|
+
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
902
|
+
}
|
|
903
|
+
__name(toOneArgVisitWithPath, "toOneArgVisitWithPath");
|
|
904
|
+
const onObjectBegin = toNoArgVisitWithPath(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisitWithPath(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
905
|
+
const disallowComments = options && options.disallowComments;
|
|
906
|
+
const allowTrailingComma = options && options.allowTrailingComma;
|
|
907
|
+
function scanNext() {
|
|
908
|
+
while (true) {
|
|
909
|
+
const token = _scanner.scan();
|
|
910
|
+
switch (_scanner.getTokenError()) {
|
|
911
|
+
case 4:
|
|
912
|
+
handleError(
|
|
913
|
+
14
|
|
914
|
+
/* ParseErrorCode.InvalidUnicode */
|
|
915
|
+
);
|
|
916
|
+
break;
|
|
917
|
+
case 5:
|
|
918
|
+
handleError(
|
|
919
|
+
15
|
|
920
|
+
/* ParseErrorCode.InvalidEscapeCharacter */
|
|
921
|
+
);
|
|
922
|
+
break;
|
|
923
|
+
case 3:
|
|
924
|
+
handleError(
|
|
925
|
+
13
|
|
926
|
+
/* ParseErrorCode.UnexpectedEndOfNumber */
|
|
927
|
+
);
|
|
928
|
+
break;
|
|
929
|
+
case 1:
|
|
930
|
+
if (!disallowComments) {
|
|
931
|
+
handleError(
|
|
932
|
+
11
|
|
933
|
+
/* ParseErrorCode.UnexpectedEndOfComment */
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
break;
|
|
937
|
+
case 2:
|
|
938
|
+
handleError(
|
|
939
|
+
12
|
|
940
|
+
/* ParseErrorCode.UnexpectedEndOfString */
|
|
941
|
+
);
|
|
942
|
+
break;
|
|
943
|
+
case 6:
|
|
944
|
+
handleError(
|
|
945
|
+
16
|
|
946
|
+
/* ParseErrorCode.InvalidCharacter */
|
|
947
|
+
);
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
switch (token) {
|
|
951
|
+
case 12:
|
|
952
|
+
case 13:
|
|
953
|
+
if (disallowComments) {
|
|
954
|
+
handleError(
|
|
955
|
+
10
|
|
956
|
+
/* ParseErrorCode.InvalidCommentToken */
|
|
957
|
+
);
|
|
958
|
+
} else {
|
|
959
|
+
onComment();
|
|
960
|
+
}
|
|
961
|
+
break;
|
|
962
|
+
case 16:
|
|
963
|
+
handleError(
|
|
964
|
+
1
|
|
965
|
+
/* ParseErrorCode.InvalidSymbol */
|
|
966
|
+
);
|
|
967
|
+
break;
|
|
968
|
+
case 15:
|
|
969
|
+
case 14:
|
|
970
|
+
break;
|
|
971
|
+
default:
|
|
972
|
+
return token;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
__name(scanNext, "scanNext");
|
|
977
|
+
function handleError(error, skipUntilAfter = [], skipUntil2 = []) {
|
|
978
|
+
onError(error);
|
|
979
|
+
if (skipUntilAfter.length + skipUntil2.length > 0) {
|
|
980
|
+
let token = _scanner.getToken();
|
|
981
|
+
while (token !== 17) {
|
|
982
|
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
983
|
+
scanNext();
|
|
984
|
+
break;
|
|
985
|
+
} else if (skipUntil2.indexOf(token) !== -1) {
|
|
986
|
+
break;
|
|
987
|
+
}
|
|
988
|
+
token = scanNext();
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
__name(handleError, "handleError");
|
|
993
|
+
function parseString2(isValue) {
|
|
994
|
+
const value = _scanner.getTokenValue();
|
|
995
|
+
if (isValue) {
|
|
996
|
+
onLiteralValue(value);
|
|
997
|
+
} else {
|
|
998
|
+
onObjectProperty(value);
|
|
999
|
+
_jsonPath.push(value);
|
|
1000
|
+
}
|
|
1001
|
+
scanNext();
|
|
1002
|
+
return true;
|
|
1003
|
+
}
|
|
1004
|
+
__name(parseString2, "parseString");
|
|
1005
|
+
function parseLiteral() {
|
|
1006
|
+
switch (_scanner.getToken()) {
|
|
1007
|
+
case 11:
|
|
1008
|
+
const tokenValue = _scanner.getTokenValue();
|
|
1009
|
+
let value = Number(tokenValue);
|
|
1010
|
+
if (isNaN(value)) {
|
|
1011
|
+
handleError(
|
|
1012
|
+
2
|
|
1013
|
+
/* ParseErrorCode.InvalidNumberFormat */
|
|
1014
|
+
);
|
|
1015
|
+
value = 0;
|
|
1016
|
+
}
|
|
1017
|
+
onLiteralValue(value);
|
|
1018
|
+
break;
|
|
1019
|
+
case 7:
|
|
1020
|
+
onLiteralValue(null);
|
|
1021
|
+
break;
|
|
1022
|
+
case 8:
|
|
1023
|
+
onLiteralValue(true);
|
|
1024
|
+
break;
|
|
1025
|
+
case 9:
|
|
1026
|
+
onLiteralValue(false);
|
|
1027
|
+
break;
|
|
1028
|
+
default:
|
|
1029
|
+
return false;
|
|
1030
|
+
}
|
|
1031
|
+
scanNext();
|
|
1032
|
+
return true;
|
|
1033
|
+
}
|
|
1034
|
+
__name(parseLiteral, "parseLiteral");
|
|
1035
|
+
function parseProperty() {
|
|
1036
|
+
if (_scanner.getToken() !== 10) {
|
|
1037
|
+
handleError(3, [], [
|
|
1038
|
+
2,
|
|
1039
|
+
5
|
|
1040
|
+
/* SyntaxKind.CommaToken */
|
|
1041
|
+
]);
|
|
1042
|
+
return false;
|
|
1043
|
+
}
|
|
1044
|
+
parseString2(false);
|
|
1045
|
+
if (_scanner.getToken() === 6) {
|
|
1046
|
+
onSeparator(":");
|
|
1047
|
+
scanNext();
|
|
1048
|
+
if (!parseValue2()) {
|
|
1049
|
+
handleError(4, [], [
|
|
1050
|
+
2,
|
|
1051
|
+
5
|
|
1052
|
+
/* SyntaxKind.CommaToken */
|
|
1053
|
+
]);
|
|
1054
|
+
}
|
|
1055
|
+
} else {
|
|
1056
|
+
handleError(5, [], [
|
|
1057
|
+
2,
|
|
1058
|
+
5
|
|
1059
|
+
/* SyntaxKind.CommaToken */
|
|
1060
|
+
]);
|
|
1061
|
+
}
|
|
1062
|
+
_jsonPath.pop();
|
|
1063
|
+
return true;
|
|
1064
|
+
}
|
|
1065
|
+
__name(parseProperty, "parseProperty");
|
|
1066
|
+
function parseObject() {
|
|
1067
|
+
onObjectBegin();
|
|
1068
|
+
scanNext();
|
|
1069
|
+
let needsComma = false;
|
|
1070
|
+
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
|
|
1071
|
+
if (_scanner.getToken() === 5) {
|
|
1072
|
+
if (!needsComma) {
|
|
1073
|
+
handleError(4, [], []);
|
|
1074
|
+
}
|
|
1075
|
+
onSeparator(",");
|
|
1076
|
+
scanNext();
|
|
1077
|
+
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
1078
|
+
break;
|
|
1079
|
+
}
|
|
1080
|
+
} else if (needsComma) {
|
|
1081
|
+
handleError(6, [], []);
|
|
1082
|
+
}
|
|
1083
|
+
if (!parseProperty()) {
|
|
1084
|
+
handleError(4, [], [
|
|
1085
|
+
2,
|
|
1086
|
+
5
|
|
1087
|
+
/* SyntaxKind.CommaToken */
|
|
1088
|
+
]);
|
|
1089
|
+
}
|
|
1090
|
+
needsComma = true;
|
|
1091
|
+
}
|
|
1092
|
+
onObjectEnd();
|
|
1093
|
+
if (_scanner.getToken() !== 2) {
|
|
1094
|
+
handleError(7, [
|
|
1095
|
+
2
|
|
1096
|
+
/* SyntaxKind.CloseBraceToken */
|
|
1097
|
+
], []);
|
|
1098
|
+
} else {
|
|
1099
|
+
scanNext();
|
|
1100
|
+
}
|
|
1101
|
+
return true;
|
|
1102
|
+
}
|
|
1103
|
+
__name(parseObject, "parseObject");
|
|
1104
|
+
function parseArray2() {
|
|
1105
|
+
onArrayBegin();
|
|
1106
|
+
scanNext();
|
|
1107
|
+
let isFirstElement = true;
|
|
1108
|
+
let needsComma = false;
|
|
1109
|
+
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
|
|
1110
|
+
if (_scanner.getToken() === 5) {
|
|
1111
|
+
if (!needsComma) {
|
|
1112
|
+
handleError(4, [], []);
|
|
1113
|
+
}
|
|
1114
|
+
onSeparator(",");
|
|
1115
|
+
scanNext();
|
|
1116
|
+
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
1117
|
+
break;
|
|
1118
|
+
}
|
|
1119
|
+
} else if (needsComma) {
|
|
1120
|
+
handleError(6, [], []);
|
|
1121
|
+
}
|
|
1122
|
+
if (isFirstElement) {
|
|
1123
|
+
_jsonPath.push(0);
|
|
1124
|
+
isFirstElement = false;
|
|
1125
|
+
} else {
|
|
1126
|
+
_jsonPath[_jsonPath.length - 1]++;
|
|
1127
|
+
}
|
|
1128
|
+
if (!parseValue2()) {
|
|
1129
|
+
handleError(4, [], [
|
|
1130
|
+
4,
|
|
1131
|
+
5
|
|
1132
|
+
/* SyntaxKind.CommaToken */
|
|
1133
|
+
]);
|
|
1134
|
+
}
|
|
1135
|
+
needsComma = true;
|
|
1136
|
+
}
|
|
1137
|
+
onArrayEnd();
|
|
1138
|
+
if (!isFirstElement) {
|
|
1139
|
+
_jsonPath.pop();
|
|
1140
|
+
}
|
|
1141
|
+
if (_scanner.getToken() !== 4) {
|
|
1142
|
+
handleError(8, [
|
|
1143
|
+
4
|
|
1144
|
+
/* SyntaxKind.CloseBracketToken */
|
|
1145
|
+
], []);
|
|
1146
|
+
} else {
|
|
1147
|
+
scanNext();
|
|
1148
|
+
}
|
|
1149
|
+
return true;
|
|
1150
|
+
}
|
|
1151
|
+
__name(parseArray2, "parseArray");
|
|
1152
|
+
function parseValue2() {
|
|
1153
|
+
switch (_scanner.getToken()) {
|
|
1154
|
+
case 3:
|
|
1155
|
+
return parseArray2();
|
|
1156
|
+
case 1:
|
|
1157
|
+
return parseObject();
|
|
1158
|
+
case 10:
|
|
1159
|
+
return parseString2(true);
|
|
1160
|
+
default:
|
|
1161
|
+
return parseLiteral();
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
__name(parseValue2, "parseValue");
|
|
1165
|
+
scanNext();
|
|
1166
|
+
if (_scanner.getToken() === 17) {
|
|
1167
|
+
if (options.allowEmptyContent) {
|
|
1168
|
+
return true;
|
|
1169
|
+
}
|
|
1170
|
+
handleError(4, [], []);
|
|
1171
|
+
return false;
|
|
1172
|
+
}
|
|
1173
|
+
if (!parseValue2()) {
|
|
1174
|
+
handleError(4, [], []);
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
if (_scanner.getToken() !== 17) {
|
|
1178
|
+
handleError(9, [], []);
|
|
1179
|
+
}
|
|
1180
|
+
return true;
|
|
1181
|
+
}
|
|
1182
|
+
__name(visit, "visit");
|
|
1183
|
+
function getNodeType(value) {
|
|
1184
|
+
switch (typeof value) {
|
|
1185
|
+
case "boolean":
|
|
1186
|
+
return "boolean";
|
|
1187
|
+
case "number":
|
|
1188
|
+
return "number";
|
|
1189
|
+
case "string":
|
|
1190
|
+
return "string";
|
|
1191
|
+
case "object": {
|
|
1192
|
+
if (!value) {
|
|
1193
|
+
return "null";
|
|
1194
|
+
} else if (Array.isArray(value)) {
|
|
1195
|
+
return "array";
|
|
1196
|
+
}
|
|
1197
|
+
return "object";
|
|
1198
|
+
}
|
|
1199
|
+
default:
|
|
1200
|
+
return "null";
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
__name(getNodeType, "getNodeType");
|
|
1204
|
+
|
|
1205
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.2.0/node_modules/jsonc-parser/lib/esm/impl/edit.js
|
|
1206
|
+
function setProperty(text, originalPath, value, options) {
|
|
1207
|
+
const path4 = originalPath.slice();
|
|
1208
|
+
const errors = [];
|
|
1209
|
+
const root = parseTree(text, errors);
|
|
1210
|
+
let parent = void 0;
|
|
1211
|
+
let lastSegment = void 0;
|
|
1212
|
+
while (path4.length > 0) {
|
|
1213
|
+
lastSegment = path4.pop();
|
|
1214
|
+
parent = findNodeAtLocation(root, path4);
|
|
1215
|
+
if (parent === void 0 && value !== void 0) {
|
|
1216
|
+
if (typeof lastSegment === "string") {
|
|
1217
|
+
value = { [lastSegment]: value };
|
|
1218
|
+
} else {
|
|
1219
|
+
value = [value];
|
|
1220
|
+
}
|
|
1221
|
+
} else {
|
|
1222
|
+
break;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
if (!parent) {
|
|
1226
|
+
if (value === void 0) {
|
|
1227
|
+
throw new Error("Can not delete in empty document");
|
|
1228
|
+
}
|
|
1229
|
+
return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
|
|
1230
|
+
} else if (parent.type === "object" && typeof lastSegment === "string" && Array.isArray(parent.children)) {
|
|
1231
|
+
const existing = findNodeAtLocation(parent, [lastSegment]);
|
|
1232
|
+
if (existing !== void 0) {
|
|
1233
|
+
if (value === void 0) {
|
|
1234
|
+
if (!existing.parent) {
|
|
1235
|
+
throw new Error("Malformed AST");
|
|
1236
|
+
}
|
|
1237
|
+
const propertyIndex = parent.children.indexOf(existing.parent);
|
|
1238
|
+
let removeBegin;
|
|
1239
|
+
let removeEnd = existing.parent.offset + existing.parent.length;
|
|
1240
|
+
if (propertyIndex > 0) {
|
|
1241
|
+
let previous = parent.children[propertyIndex - 1];
|
|
1242
|
+
removeBegin = previous.offset + previous.length;
|
|
1243
|
+
} else {
|
|
1244
|
+
removeBegin = parent.offset + 1;
|
|
1245
|
+
if (parent.children.length > 1) {
|
|
1246
|
+
let next = parent.children[1];
|
|
1247
|
+
removeEnd = next.offset;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: "" }, options);
|
|
1251
|
+
} else {
|
|
1252
|
+
return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
|
|
1253
|
+
}
|
|
1254
|
+
} else {
|
|
1255
|
+
if (value === void 0) {
|
|
1256
|
+
return [];
|
|
1257
|
+
}
|
|
1258
|
+
const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
|
|
1259
|
+
const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map((p) => p.children[0].value)) : parent.children.length;
|
|
1260
|
+
let edit;
|
|
1261
|
+
if (index > 0) {
|
|
1262
|
+
let previous = parent.children[index - 1];
|
|
1263
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
1264
|
+
} else if (parent.children.length === 0) {
|
|
1265
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
|
1266
|
+
} else {
|
|
1267
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty + "," };
|
|
1268
|
+
}
|
|
1269
|
+
return withFormatting(text, edit, options);
|
|
1270
|
+
}
|
|
1271
|
+
} else if (parent.type === "array" && typeof lastSegment === "number" && Array.isArray(parent.children)) {
|
|
1272
|
+
const insertIndex = lastSegment;
|
|
1273
|
+
if (insertIndex === -1) {
|
|
1274
|
+
const newProperty = `${JSON.stringify(value)}`;
|
|
1275
|
+
let edit;
|
|
1276
|
+
if (parent.children.length === 0) {
|
|
1277
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
|
1278
|
+
} else {
|
|
1279
|
+
const previous = parent.children[parent.children.length - 1];
|
|
1280
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
1281
|
+
}
|
|
1282
|
+
return withFormatting(text, edit, options);
|
|
1283
|
+
} else if (value === void 0 && parent.children.length >= 0) {
|
|
1284
|
+
const removalIndex = lastSegment;
|
|
1285
|
+
const toRemove = parent.children[removalIndex];
|
|
1286
|
+
let edit;
|
|
1287
|
+
if (parent.children.length === 1) {
|
|
1288
|
+
edit = { offset: parent.offset + 1, length: parent.length - 2, content: "" };
|
|
1289
|
+
} else if (parent.children.length - 1 === removalIndex) {
|
|
1290
|
+
let previous = parent.children[removalIndex - 1];
|
|
1291
|
+
let offset = previous.offset + previous.length;
|
|
1292
|
+
let parentEndOffset = parent.offset + parent.length;
|
|
1293
|
+
edit = { offset, length: parentEndOffset - 2 - offset, content: "" };
|
|
1294
|
+
} else {
|
|
1295
|
+
edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: "" };
|
|
1296
|
+
}
|
|
1297
|
+
return withFormatting(text, edit, options);
|
|
1298
|
+
} else if (value !== void 0) {
|
|
1299
|
+
let edit;
|
|
1300
|
+
const newProperty = `${JSON.stringify(value)}`;
|
|
1301
|
+
if (!options.isArrayInsertion && parent.children.length > lastSegment) {
|
|
1302
|
+
const toModify = parent.children[lastSegment];
|
|
1303
|
+
edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
|
|
1304
|
+
} else if (parent.children.length === 0 || lastSegment === 0) {
|
|
1305
|
+
edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + "," };
|
|
1306
|
+
} else {
|
|
1307
|
+
const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
|
|
1308
|
+
const previous = parent.children[index - 1];
|
|
1309
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
1310
|
+
}
|
|
1311
|
+
return withFormatting(text, edit, options);
|
|
1312
|
+
} else {
|
|
1313
|
+
throw new Error(`Can not ${value === void 0 ? "remove" : options.isArrayInsertion ? "insert" : "modify"} Array index ${insertIndex} as length is not sufficient`);
|
|
1314
|
+
}
|
|
1315
|
+
} else {
|
|
1316
|
+
throw new Error(`Can not add ${typeof lastSegment !== "number" ? "index" : "property"} to parent of type ${parent.type}`);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
__name(setProperty, "setProperty");
|
|
1320
|
+
function withFormatting(text, edit, options) {
|
|
1321
|
+
if (!options.formattingOptions) {
|
|
1322
|
+
return [edit];
|
|
1323
|
+
}
|
|
1324
|
+
let newText = applyEdit(text, edit);
|
|
1325
|
+
let begin = edit.offset;
|
|
1326
|
+
let end = edit.offset + edit.content.length;
|
|
1327
|
+
if (edit.length === 0 || edit.content.length === 0) {
|
|
1328
|
+
while (begin > 0 && !isEOL(newText, begin - 1)) {
|
|
1329
|
+
begin--;
|
|
1330
|
+
}
|
|
1331
|
+
while (end < newText.length && !isEOL(newText, end)) {
|
|
1332
|
+
end++;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
const edits = format(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
|
|
1336
|
+
for (let i = edits.length - 1; i >= 0; i--) {
|
|
1337
|
+
const edit2 = edits[i];
|
|
1338
|
+
newText = applyEdit(newText, edit2);
|
|
1339
|
+
begin = Math.min(begin, edit2.offset);
|
|
1340
|
+
end = Math.max(end, edit2.offset + edit2.length);
|
|
1341
|
+
end += edit2.content.length - edit2.length;
|
|
1342
|
+
}
|
|
1343
|
+
const editLength = text.length - (newText.length - end) - begin;
|
|
1344
|
+
return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
|
|
1345
|
+
}
|
|
1346
|
+
__name(withFormatting, "withFormatting");
|
|
1347
|
+
function applyEdit(text, edit) {
|
|
1348
|
+
return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
|
|
1349
|
+
}
|
|
1350
|
+
__name(applyEdit, "applyEdit");
|
|
1351
|
+
|
|
1352
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.2.0/node_modules/jsonc-parser/lib/esm/main.js
|
|
1353
|
+
var ScanError;
|
|
1354
|
+
(function(ScanError2) {
|
|
1355
|
+
ScanError2[ScanError2["None"] = 0] = "None";
|
|
1356
|
+
ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
|
1357
|
+
ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
|
1358
|
+
ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
|
1359
|
+
ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
|
|
1360
|
+
ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
|
1361
|
+
ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
|
|
1362
|
+
})(ScanError || (ScanError = {}));
|
|
1363
|
+
var SyntaxKind;
|
|
1364
|
+
(function(SyntaxKind2) {
|
|
1365
|
+
SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
|
|
1366
|
+
SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
|
|
1367
|
+
SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
|
|
1368
|
+
SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
|
|
1369
|
+
SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
|
|
1370
|
+
SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
|
|
1371
|
+
SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
|
|
1372
|
+
SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
|
|
1373
|
+
SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
|
|
1374
|
+
SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
|
|
1375
|
+
SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
|
|
1376
|
+
SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
|
1377
|
+
SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
|
1378
|
+
SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
|
1379
|
+
SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
|
|
1380
|
+
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
|
|
1381
|
+
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
|
|
1382
|
+
})(SyntaxKind || (SyntaxKind = {}));
|
|
1383
|
+
var parse2 = parse;
|
|
1384
|
+
var ParseErrorCode;
|
|
1385
|
+
(function(ParseErrorCode2) {
|
|
1386
|
+
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
1387
|
+
ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
|
1388
|
+
ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
|
1389
|
+
ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
|
|
1390
|
+
ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
|
|
1391
|
+
ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
|
|
1392
|
+
ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
|
1393
|
+
ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
|
1394
|
+
ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
|
1395
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
|
1396
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
|
1397
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
|
1398
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
|
1399
|
+
ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
|
|
1400
|
+
ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
|
1401
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
1402
|
+
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
1403
|
+
function printParseErrorCode(code) {
|
|
1404
|
+
switch (code) {
|
|
1405
|
+
case 1:
|
|
1406
|
+
return "InvalidSymbol";
|
|
1407
|
+
case 2:
|
|
1408
|
+
return "InvalidNumberFormat";
|
|
1409
|
+
case 3:
|
|
1410
|
+
return "PropertyNameExpected";
|
|
1411
|
+
case 4:
|
|
1412
|
+
return "ValueExpected";
|
|
1413
|
+
case 5:
|
|
1414
|
+
return "ColonExpected";
|
|
1415
|
+
case 6:
|
|
1416
|
+
return "CommaExpected";
|
|
1417
|
+
case 7:
|
|
1418
|
+
return "CloseBraceExpected";
|
|
1419
|
+
case 8:
|
|
1420
|
+
return "CloseBracketExpected";
|
|
1421
|
+
case 9:
|
|
1422
|
+
return "EndOfFileExpected";
|
|
1423
|
+
case 10:
|
|
1424
|
+
return "InvalidCommentToken";
|
|
1425
|
+
case 11:
|
|
1426
|
+
return "UnexpectedEndOfComment";
|
|
1427
|
+
case 12:
|
|
1428
|
+
return "UnexpectedEndOfString";
|
|
1429
|
+
case 13:
|
|
1430
|
+
return "UnexpectedEndOfNumber";
|
|
1431
|
+
case 14:
|
|
1432
|
+
return "InvalidUnicode";
|
|
1433
|
+
case 15:
|
|
1434
|
+
return "InvalidEscapeCharacter";
|
|
1435
|
+
case 16:
|
|
1436
|
+
return "InvalidCharacter";
|
|
1437
|
+
}
|
|
1438
|
+
return "<unknown ParseErrorCode>";
|
|
1439
|
+
}
|
|
1440
|
+
__name(printParseErrorCode, "printParseErrorCode");
|
|
1441
|
+
function format2(documentText, range, options) {
|
|
1442
|
+
return format(documentText, range, options);
|
|
1443
|
+
}
|
|
1444
|
+
__name(format2, "format");
|
|
1445
|
+
function modify(text, path4, value, options) {
|
|
1446
|
+
return setProperty(text, path4, value, options);
|
|
1447
|
+
}
|
|
1448
|
+
__name(modify, "modify");
|
|
1449
|
+
function applyEdits(text, edits) {
|
|
1450
|
+
let sortedEdits = edits.slice(0).sort((a, b) => {
|
|
1451
|
+
const diff = a.offset - b.offset;
|
|
1452
|
+
if (diff === 0) {
|
|
1453
|
+
return a.length - b.length;
|
|
1454
|
+
}
|
|
1455
|
+
return diff;
|
|
1456
|
+
});
|
|
1457
|
+
let lastModifiedOffset = text.length;
|
|
1458
|
+
for (let i = sortedEdits.length - 1; i >= 0; i--) {
|
|
1459
|
+
let e = sortedEdits[i];
|
|
1460
|
+
if (e.offset + e.length <= lastModifiedOffset) {
|
|
1461
|
+
text = applyEdit(text, e);
|
|
1462
|
+
} else {
|
|
1463
|
+
throw new Error("Overlapping edit");
|
|
1464
|
+
}
|
|
1465
|
+
lastModifiedOffset = e.offset;
|
|
1466
|
+
}
|
|
1467
|
+
return text;
|
|
1468
|
+
}
|
|
1469
|
+
__name(applyEdits, "applyEdits");
|
|
1470
|
+
|
|
1471
|
+
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/error.js
|
|
1472
|
+
function getLineColFromPtr(string, ptr) {
|
|
1473
|
+
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
1474
|
+
return [lines.length, lines.pop().length + 1];
|
|
1475
|
+
}
|
|
1476
|
+
__name(getLineColFromPtr, "getLineColFromPtr");
|
|
1477
|
+
function makeCodeBlock(string, line, column) {
|
|
1478
|
+
let lines = string.split(/\r\n|\n|\r/g);
|
|
1479
|
+
let codeblock = "";
|
|
1480
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
1481
|
+
for (let i = line - 1; i <= line + 1; i++) {
|
|
1482
|
+
let l = lines[i - 1];
|
|
1483
|
+
if (!l)
|
|
1484
|
+
continue;
|
|
1485
|
+
codeblock += i.toString().padEnd(numberLen, " ");
|
|
1486
|
+
codeblock += ": ";
|
|
1487
|
+
codeblock += l;
|
|
1488
|
+
codeblock += "\n";
|
|
1489
|
+
if (i === line) {
|
|
1490
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
1491
|
+
codeblock += "^\n";
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
return codeblock;
|
|
1495
|
+
}
|
|
1496
|
+
__name(makeCodeBlock, "makeCodeBlock");
|
|
1497
|
+
var TomlError = class extends Error {
|
|
1498
|
+
static {
|
|
1499
|
+
__name(this, "TomlError");
|
|
1500
|
+
}
|
|
1501
|
+
line;
|
|
1502
|
+
column;
|
|
1503
|
+
codeblock;
|
|
1504
|
+
constructor(message, options) {
|
|
1505
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
1506
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
1507
|
+
super(`Invalid TOML document: ${message}
|
|
1508
|
+
|
|
1509
|
+
${codeblock}`, options);
|
|
1510
|
+
this.line = line;
|
|
1511
|
+
this.column = column;
|
|
1512
|
+
this.codeblock = codeblock;
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
|
|
1516
|
+
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/util.js
|
|
1517
|
+
function isEscaped(str, ptr) {
|
|
1518
|
+
let i = 0;
|
|
1519
|
+
while (str[ptr - ++i] === "\\")
|
|
1520
|
+
;
|
|
1521
|
+
return --i && i % 2;
|
|
1522
|
+
}
|
|
1523
|
+
__name(isEscaped, "isEscaped");
|
|
1524
|
+
function indexOfNewline(str, start = 0, end = str.length) {
|
|
1525
|
+
let idx = str.indexOf("\n", start);
|
|
1526
|
+
if (str[idx - 1] === "\r")
|
|
1527
|
+
idx--;
|
|
1528
|
+
return idx <= end ? idx : -1;
|
|
1529
|
+
}
|
|
1530
|
+
__name(indexOfNewline, "indexOfNewline");
|
|
1531
|
+
function skipComment(str, ptr) {
|
|
1532
|
+
for (let i = ptr; i < str.length; i++) {
|
|
1533
|
+
let c = str[i];
|
|
1534
|
+
if (c === "\n")
|
|
1535
|
+
return i;
|
|
1536
|
+
if (c === "\r" && str[i + 1] === "\n")
|
|
1537
|
+
return i + 1;
|
|
1538
|
+
if (c < " " && c !== " " || c === "\x7F") {
|
|
1539
|
+
throw new TomlError("control characters are not allowed in comments", {
|
|
1540
|
+
toml: str,
|
|
1541
|
+
ptr
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
return str.length;
|
|
1546
|
+
}
|
|
1547
|
+
__name(skipComment, "skipComment");
|
|
1548
|
+
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
1549
|
+
let c;
|
|
1550
|
+
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
|
|
1551
|
+
ptr++;
|
|
1552
|
+
return banComments || c !== "#" ? ptr : skipVoid(str, skipComment(str, ptr), banNewLines);
|
|
1553
|
+
}
|
|
1554
|
+
__name(skipVoid, "skipVoid");
|
|
1555
|
+
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
1556
|
+
if (!end) {
|
|
1557
|
+
ptr = indexOfNewline(str, ptr);
|
|
1558
|
+
return ptr < 0 ? str.length : ptr;
|
|
1559
|
+
}
|
|
1560
|
+
for (let i = ptr; i < str.length; i++) {
|
|
1561
|
+
let c = str[i];
|
|
1562
|
+
if (c === "#") {
|
|
1563
|
+
i = indexOfNewline(str, i);
|
|
1564
|
+
} else if (c === sep) {
|
|
1565
|
+
return i + 1;
|
|
1566
|
+
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
|
|
1567
|
+
return i;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
throw new TomlError("cannot find end of structure", {
|
|
1571
|
+
toml: str,
|
|
1572
|
+
ptr
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
__name(skipUntil, "skipUntil");
|
|
1576
|
+
function getStringEnd(str, seek) {
|
|
1577
|
+
let first = str[seek];
|
|
1578
|
+
let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
|
|
1579
|
+
seek += target.length - 1;
|
|
1580
|
+
do
|
|
1581
|
+
seek = str.indexOf(target, ++seek);
|
|
1582
|
+
while (seek > -1 && first !== "'" && isEscaped(str, seek));
|
|
1583
|
+
if (seek > -1) {
|
|
1584
|
+
seek += target.length;
|
|
1585
|
+
if (target.length > 1) {
|
|
1586
|
+
if (str[seek] === first)
|
|
1587
|
+
seek++;
|
|
1588
|
+
if (str[seek] === first)
|
|
1589
|
+
seek++;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
return seek;
|
|
1593
|
+
}
|
|
1594
|
+
__name(getStringEnd, "getStringEnd");
|
|
1595
|
+
|
|
1596
|
+
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/date.js
|
|
1597
|
+
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
1598
|
+
var TomlDate = class _TomlDate extends Date {
|
|
1599
|
+
static {
|
|
1600
|
+
__name(this, "TomlDate");
|
|
1601
|
+
}
|
|
1602
|
+
#hasDate = false;
|
|
1603
|
+
#hasTime = false;
|
|
1604
|
+
#offset = null;
|
|
1605
|
+
constructor(date) {
|
|
1606
|
+
let hasDate = true;
|
|
1607
|
+
let hasTime = true;
|
|
1608
|
+
let offset = "Z";
|
|
1609
|
+
if (typeof date === "string") {
|
|
1610
|
+
let match = date.match(DATE_TIME_RE);
|
|
1611
|
+
if (match) {
|
|
1612
|
+
if (!match[1]) {
|
|
1613
|
+
hasDate = false;
|
|
1614
|
+
date = `0000-01-01T${date}`;
|
|
1615
|
+
}
|
|
1616
|
+
hasTime = !!match[2];
|
|
1617
|
+
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
1618
|
+
if (match[2] && +match[2] > 23) {
|
|
1619
|
+
date = "";
|
|
1620
|
+
} else {
|
|
1621
|
+
offset = match[3] || null;
|
|
1622
|
+
date = date.toUpperCase();
|
|
1623
|
+
if (!offset && hasTime)
|
|
1624
|
+
date += "Z";
|
|
1625
|
+
}
|
|
1626
|
+
} else {
|
|
1627
|
+
date = "";
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
super(date);
|
|
1631
|
+
if (!isNaN(this.getTime())) {
|
|
1632
|
+
this.#hasDate = hasDate;
|
|
1633
|
+
this.#hasTime = hasTime;
|
|
1634
|
+
this.#offset = offset;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
isDateTime() {
|
|
1638
|
+
return this.#hasDate && this.#hasTime;
|
|
1639
|
+
}
|
|
1640
|
+
isLocal() {
|
|
1641
|
+
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
1642
|
+
}
|
|
1643
|
+
isDate() {
|
|
1644
|
+
return this.#hasDate && !this.#hasTime;
|
|
1645
|
+
}
|
|
1646
|
+
isTime() {
|
|
1647
|
+
return this.#hasTime && !this.#hasDate;
|
|
1648
|
+
}
|
|
1649
|
+
isValid() {
|
|
1650
|
+
return this.#hasDate || this.#hasTime;
|
|
1651
|
+
}
|
|
1652
|
+
toISOString() {
|
|
1653
|
+
let iso = super.toISOString();
|
|
1654
|
+
if (this.isDate())
|
|
1655
|
+
return iso.slice(0, 10);
|
|
1656
|
+
if (this.isTime())
|
|
1657
|
+
return iso.slice(11, 23);
|
|
1658
|
+
if (this.#offset === null)
|
|
1659
|
+
return iso.slice(0, -1);
|
|
1660
|
+
if (this.#offset === "Z")
|
|
1661
|
+
return iso;
|
|
1662
|
+
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
1663
|
+
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
1664
|
+
let offsetDate = new Date(this.getTime() - offset * 6e4);
|
|
1665
|
+
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
1666
|
+
}
|
|
1667
|
+
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
1668
|
+
let date = new _TomlDate(jsDate);
|
|
1669
|
+
date.#offset = offset;
|
|
1670
|
+
return date;
|
|
1671
|
+
}
|
|
1672
|
+
static wrapAsLocalDateTime(jsDate) {
|
|
1673
|
+
let date = new _TomlDate(jsDate);
|
|
1674
|
+
date.#offset = null;
|
|
1675
|
+
return date;
|
|
1676
|
+
}
|
|
1677
|
+
static wrapAsLocalDate(jsDate) {
|
|
1678
|
+
let date = new _TomlDate(jsDate);
|
|
1679
|
+
date.#hasTime = false;
|
|
1680
|
+
date.#offset = null;
|
|
1681
|
+
return date;
|
|
1682
|
+
}
|
|
1683
|
+
static wrapAsLocalTime(jsDate) {
|
|
1684
|
+
let date = new _TomlDate(jsDate);
|
|
1685
|
+
date.#hasDate = false;
|
|
1686
|
+
date.#offset = null;
|
|
1687
|
+
return date;
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
|
|
1691
|
+
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/primitive.js
|
|
1692
|
+
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
1693
|
+
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
1694
|
+
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
1695
|
+
var ESCAPE_REGEX = /^[0-9a-f]{4,8}$/i;
|
|
1696
|
+
var ESC_MAP = {
|
|
1697
|
+
b: "\b",
|
|
1698
|
+
t: " ",
|
|
1699
|
+
n: "\n",
|
|
1700
|
+
f: "\f",
|
|
1701
|
+
r: "\r",
|
|
1702
|
+
'"': '"',
|
|
1703
|
+
"\\": "\\"
|
|
1704
|
+
};
|
|
1705
|
+
function parseString(str, ptr = 0, endPtr = str.length) {
|
|
1706
|
+
let isLiteral = str[ptr] === "'";
|
|
1707
|
+
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
|
|
1708
|
+
if (isMultiline) {
|
|
1709
|
+
endPtr -= 2;
|
|
1710
|
+
if (str[ptr += 2] === "\r")
|
|
1711
|
+
ptr++;
|
|
1712
|
+
if (str[ptr] === "\n")
|
|
1713
|
+
ptr++;
|
|
1714
|
+
}
|
|
1715
|
+
let tmp = 0;
|
|
1716
|
+
let isEscape;
|
|
1717
|
+
let parsed = "";
|
|
1718
|
+
let sliceStart = ptr;
|
|
1719
|
+
while (ptr < endPtr - 1) {
|
|
1720
|
+
let c = str[ptr++];
|
|
1721
|
+
if (c === "\n" || c === "\r" && str[ptr] === "\n") {
|
|
1722
|
+
if (!isMultiline) {
|
|
1723
|
+
throw new TomlError("newlines are not allowed in strings", {
|
|
1724
|
+
toml: str,
|
|
1725
|
+
ptr: ptr - 1
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
} else if (c < " " && c !== " " || c === "\x7F") {
|
|
1729
|
+
throw new TomlError("control characters are not allowed in strings", {
|
|
1730
|
+
toml: str,
|
|
1731
|
+
ptr: ptr - 1
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
if (isEscape) {
|
|
1735
|
+
isEscape = false;
|
|
1736
|
+
if (c === "u" || c === "U") {
|
|
1737
|
+
let code = str.slice(ptr, ptr += c === "u" ? 4 : 8);
|
|
1738
|
+
if (!ESCAPE_REGEX.test(code)) {
|
|
1739
|
+
throw new TomlError("invalid unicode escape", {
|
|
1740
|
+
toml: str,
|
|
1741
|
+
ptr: tmp
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
try {
|
|
1745
|
+
parsed += String.fromCodePoint(parseInt(code, 16));
|
|
1746
|
+
} catch {
|
|
1747
|
+
throw new TomlError("invalid unicode escape", {
|
|
1748
|
+
toml: str,
|
|
1749
|
+
ptr: tmp
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
} else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
|
|
1753
|
+
ptr = skipVoid(str, ptr - 1, true);
|
|
1754
|
+
if (str[ptr] !== "\n" && str[ptr] !== "\r") {
|
|
1755
|
+
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
1756
|
+
toml: str,
|
|
1757
|
+
ptr: tmp
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1760
|
+
ptr = skipVoid(str, ptr);
|
|
1761
|
+
} else if (c in ESC_MAP) {
|
|
1762
|
+
parsed += ESC_MAP[c];
|
|
1763
|
+
} else {
|
|
1764
|
+
throw new TomlError("unrecognized escape sequence", {
|
|
1765
|
+
toml: str,
|
|
1766
|
+
ptr: tmp
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
sliceStart = ptr;
|
|
1770
|
+
} else if (!isLiteral && c === "\\") {
|
|
1771
|
+
tmp = ptr - 1;
|
|
1772
|
+
isEscape = true;
|
|
1773
|
+
parsed += str.slice(sliceStart, tmp);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
return parsed + str.slice(sliceStart, endPtr - 1);
|
|
1777
|
+
}
|
|
1778
|
+
__name(parseString, "parseString");
|
|
1779
|
+
function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
1780
|
+
if (value === "true")
|
|
1781
|
+
return true;
|
|
1782
|
+
if (value === "false")
|
|
1783
|
+
return false;
|
|
1784
|
+
if (value === "-inf")
|
|
1785
|
+
return -Infinity;
|
|
1786
|
+
if (value === "inf" || value === "+inf")
|
|
1787
|
+
return Infinity;
|
|
1788
|
+
if (value === "nan" || value === "+nan" || value === "-nan")
|
|
1789
|
+
return NaN;
|
|
1790
|
+
if (value === "-0")
|
|
1791
|
+
return integersAsBigInt ? 0n : 0;
|
|
1792
|
+
let isInt = INT_REGEX.test(value);
|
|
1793
|
+
if (isInt || FLOAT_REGEX.test(value)) {
|
|
1794
|
+
if (LEADING_ZERO.test(value)) {
|
|
1795
|
+
throw new TomlError("leading zeroes are not allowed", {
|
|
1796
|
+
toml,
|
|
1797
|
+
ptr
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
value = value.replace(/_/g, "");
|
|
1801
|
+
let numeric = +value;
|
|
1802
|
+
if (isNaN(numeric)) {
|
|
1803
|
+
throw new TomlError("invalid number", {
|
|
1804
|
+
toml,
|
|
1805
|
+
ptr
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
if (isInt) {
|
|
1809
|
+
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
1810
|
+
throw new TomlError("integer value cannot be represented losslessly", {
|
|
1811
|
+
toml,
|
|
1812
|
+
ptr
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1815
|
+
if (isInt || integersAsBigInt === true)
|
|
1816
|
+
numeric = BigInt(value);
|
|
1817
|
+
}
|
|
1818
|
+
return numeric;
|
|
1819
|
+
}
|
|
1820
|
+
const date = new TomlDate(value);
|
|
1821
|
+
if (!date.isValid()) {
|
|
1822
|
+
throw new TomlError("invalid value", {
|
|
1823
|
+
toml,
|
|
1824
|
+
ptr
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
return date;
|
|
1828
|
+
}
|
|
1829
|
+
__name(parseValue, "parseValue");
|
|
1830
|
+
|
|
1831
|
+
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/extract.js
|
|
1832
|
+
function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) {
|
|
1833
|
+
let value = str.slice(startPtr, endPtr);
|
|
1834
|
+
let commentIdx = value.indexOf("#");
|
|
1835
|
+
if (commentIdx > -1) {
|
|
1836
|
+
skipComment(str, commentIdx);
|
|
1837
|
+
value = value.slice(0, commentIdx);
|
|
1838
|
+
}
|
|
1839
|
+
let trimmed = value.trimEnd();
|
|
1840
|
+
if (!allowNewLines) {
|
|
1841
|
+
let newlineIdx = value.indexOf("\n", trimmed.length);
|
|
1842
|
+
if (newlineIdx > -1) {
|
|
1843
|
+
throw new TomlError("newlines are not allowed in inline tables", {
|
|
1844
|
+
toml: str,
|
|
1845
|
+
ptr: startPtr + newlineIdx
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
return [trimmed, commentIdx];
|
|
1850
|
+
}
|
|
1851
|
+
__name(sliceAndTrimEndOf, "sliceAndTrimEndOf");
|
|
1852
|
+
function extractValue(str, ptr, end, depth, integersAsBigInt) {
|
|
1853
|
+
if (depth === 0) {
|
|
1854
|
+
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
1855
|
+
toml: str,
|
|
1856
|
+
ptr
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
let c = str[ptr];
|
|
1860
|
+
if (c === "[" || c === "{") {
|
|
1861
|
+
let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
|
|
1862
|
+
let newPtr = end ? skipUntil(str, endPtr2, ",", end) : endPtr2;
|
|
1863
|
+
if (endPtr2 - newPtr && end === "}") {
|
|
1864
|
+
let nextNewLine = indexOfNewline(str, endPtr2, newPtr);
|
|
1865
|
+
if (nextNewLine > -1) {
|
|
1866
|
+
throw new TomlError("newlines are not allowed in inline tables", {
|
|
1867
|
+
toml: str,
|
|
1868
|
+
ptr: nextNewLine
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
return [value, newPtr];
|
|
1873
|
+
}
|
|
1874
|
+
let endPtr;
|
|
1875
|
+
if (c === '"' || c === "'") {
|
|
1876
|
+
endPtr = getStringEnd(str, ptr);
|
|
1877
|
+
let parsed = parseString(str, ptr, endPtr);
|
|
1878
|
+
if (end) {
|
|
1879
|
+
endPtr = skipVoid(str, endPtr, end !== "]");
|
|
1880
|
+
if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
|
|
1881
|
+
throw new TomlError("unexpected character encountered", {
|
|
1882
|
+
toml: str,
|
|
1883
|
+
ptr: endPtr
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
endPtr += +(str[endPtr] === ",");
|
|
1887
|
+
}
|
|
1888
|
+
return [parsed, endPtr];
|
|
1889
|
+
}
|
|
1890
|
+
endPtr = skipUntil(str, ptr, ",", end);
|
|
1891
|
+
let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","), end === "]");
|
|
1892
|
+
if (!slice[0]) {
|
|
1893
|
+
throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
1894
|
+
toml: str,
|
|
1895
|
+
ptr
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
if (end && slice[1] > -1) {
|
|
1899
|
+
endPtr = skipVoid(str, ptr + slice[1]);
|
|
1900
|
+
endPtr += +(str[endPtr] === ",");
|
|
1901
|
+
}
|
|
1902
|
+
return [
|
|
1903
|
+
parseValue(slice[0], str, ptr, integersAsBigInt),
|
|
1904
|
+
endPtr
|
|
1905
|
+
];
|
|
1906
|
+
}
|
|
1907
|
+
__name(extractValue, "extractValue");
|
|
1908
|
+
|
|
1909
|
+
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/struct.js
|
|
1910
|
+
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
1911
|
+
function parseKey(str, ptr, end = "=") {
|
|
1912
|
+
let dot = ptr - 1;
|
|
1913
|
+
let parsed = [];
|
|
1914
|
+
let endPtr = str.indexOf(end, ptr);
|
|
1915
|
+
if (endPtr < 0) {
|
|
1916
|
+
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1917
|
+
toml: str,
|
|
1918
|
+
ptr
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
do {
|
|
1922
|
+
let c = str[ptr = ++dot];
|
|
1923
|
+
if (c !== " " && c !== " ") {
|
|
1924
|
+
if (c === '"' || c === "'") {
|
|
1925
|
+
if (c === str[ptr + 1] && c === str[ptr + 2]) {
|
|
1926
|
+
throw new TomlError("multiline strings are not allowed in keys", {
|
|
1927
|
+
toml: str,
|
|
1928
|
+
ptr
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
let eos = getStringEnd(str, ptr);
|
|
1932
|
+
if (eos < 0) {
|
|
1933
|
+
throw new TomlError("unfinished string encountered", {
|
|
1934
|
+
toml: str,
|
|
1935
|
+
ptr
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
dot = str.indexOf(".", eos);
|
|
1939
|
+
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1940
|
+
let newLine = indexOfNewline(strEnd);
|
|
1941
|
+
if (newLine > -1) {
|
|
1942
|
+
throw new TomlError("newlines are not allowed in keys", {
|
|
1943
|
+
toml: str,
|
|
1944
|
+
ptr: ptr + dot + newLine
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
if (strEnd.trimStart()) {
|
|
1948
|
+
throw new TomlError("found extra tokens after the string part", {
|
|
1949
|
+
toml: str,
|
|
1950
|
+
ptr: eos
|
|
1951
|
+
});
|
|
1952
|
+
}
|
|
1953
|
+
if (endPtr < eos) {
|
|
1954
|
+
endPtr = str.indexOf(end, eos);
|
|
1955
|
+
if (endPtr < 0) {
|
|
1956
|
+
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1957
|
+
toml: str,
|
|
1958
|
+
ptr
|
|
1959
|
+
});
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
parsed.push(parseString(str, ptr, eos));
|
|
1963
|
+
} else {
|
|
1964
|
+
dot = str.indexOf(".", ptr);
|
|
1965
|
+
let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1966
|
+
if (!KEY_PART_RE.test(part)) {
|
|
1967
|
+
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
1968
|
+
toml: str,
|
|
1969
|
+
ptr
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1972
|
+
parsed.push(part.trimEnd());
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
} while (dot + 1 && dot < endPtr);
|
|
1976
|
+
return [parsed, skipVoid(str, endPtr + 1, true, true)];
|
|
1977
|
+
}
|
|
1978
|
+
__name(parseKey, "parseKey");
|
|
1979
|
+
function parseInlineTable(str, ptr, depth, integersAsBigInt) {
|
|
1980
|
+
let res = {};
|
|
1981
|
+
let seen = /* @__PURE__ */ new Set();
|
|
1982
|
+
let c;
|
|
1983
|
+
let comma = 0;
|
|
1984
|
+
ptr++;
|
|
1985
|
+
while ((c = str[ptr++]) !== "}" && c) {
|
|
1986
|
+
let err = { toml: str, ptr: ptr - 1 };
|
|
1987
|
+
if (c === "\n") {
|
|
1988
|
+
throw new TomlError("newlines are not allowed in inline tables", err);
|
|
1989
|
+
} else if (c === "#") {
|
|
1990
|
+
throw new TomlError("inline tables cannot contain comments", err);
|
|
1991
|
+
} else if (c === ",") {
|
|
1992
|
+
throw new TomlError("expected key-value, found comma", err);
|
|
1993
|
+
} else if (c !== " " && c !== " ") {
|
|
1994
|
+
let k;
|
|
1995
|
+
let t = res;
|
|
1996
|
+
let hasOwn = false;
|
|
1997
|
+
let [key, keyEndPtr] = parseKey(str, ptr - 1);
|
|
1998
|
+
for (let i = 0; i < key.length; i++) {
|
|
1999
|
+
if (i)
|
|
2000
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
2001
|
+
k = key[i];
|
|
2002
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
2003
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
2004
|
+
toml: str,
|
|
2005
|
+
ptr
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
if (!hasOwn && k === "__proto__") {
|
|
2009
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
if (hasOwn) {
|
|
2013
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
2014
|
+
toml: str,
|
|
2015
|
+
ptr
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
|
|
2019
|
+
seen.add(value);
|
|
2020
|
+
t[k] = value;
|
|
2021
|
+
ptr = valueEndPtr;
|
|
2022
|
+
comma = str[ptr - 1] === "," ? ptr - 1 : 0;
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
if (comma) {
|
|
2026
|
+
throw new TomlError("trailing commas are not allowed in inline tables", {
|
|
2027
|
+
toml: str,
|
|
2028
|
+
ptr: comma
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
2031
|
+
if (!c) {
|
|
2032
|
+
throw new TomlError("unfinished table encountered", {
|
|
2033
|
+
toml: str,
|
|
2034
|
+
ptr
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
return [res, ptr];
|
|
2038
|
+
}
|
|
2039
|
+
__name(parseInlineTable, "parseInlineTable");
|
|
2040
|
+
function parseArray(str, ptr, depth, integersAsBigInt) {
|
|
2041
|
+
let res = [];
|
|
2042
|
+
let c;
|
|
2043
|
+
ptr++;
|
|
2044
|
+
while ((c = str[ptr++]) !== "]" && c) {
|
|
2045
|
+
if (c === ",") {
|
|
2046
|
+
throw new TomlError("expected value, found comma", {
|
|
2047
|
+
toml: str,
|
|
2048
|
+
ptr: ptr - 1
|
|
2049
|
+
});
|
|
2050
|
+
} else if (c === "#")
|
|
2051
|
+
ptr = skipComment(str, ptr);
|
|
2052
|
+
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
2053
|
+
let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
|
|
2054
|
+
res.push(e[0]);
|
|
2055
|
+
ptr = e[1];
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
if (!c) {
|
|
2059
|
+
throw new TomlError("unfinished array encountered", {
|
|
2060
|
+
toml: str,
|
|
2061
|
+
ptr
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
return [res, ptr];
|
|
2065
|
+
}
|
|
2066
|
+
__name(parseArray, "parseArray");
|
|
2067
|
+
|
|
2068
|
+
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/parse.js
|
|
2069
|
+
function peekTable(key, table, meta, type) {
|
|
2070
|
+
let t = table;
|
|
2071
|
+
let m = meta;
|
|
2072
|
+
let k;
|
|
2073
|
+
let hasOwn = false;
|
|
2074
|
+
let state;
|
|
2075
|
+
for (let i = 0; i < key.length; i++) {
|
|
2076
|
+
if (i) {
|
|
2077
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
2078
|
+
m = (state = m[k]).c;
|
|
2079
|
+
if (type === 0 && (state.t === 1 || state.t === 2)) {
|
|
2080
|
+
return null;
|
|
2081
|
+
}
|
|
2082
|
+
if (state.t === 2) {
|
|
2083
|
+
let l = t.length - 1;
|
|
2084
|
+
t = t[l];
|
|
2085
|
+
m = m[l].c;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
k = key[i];
|
|
2089
|
+
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
|
|
2090
|
+
return null;
|
|
2091
|
+
}
|
|
2092
|
+
if (!hasOwn) {
|
|
2093
|
+
if (k === "__proto__") {
|
|
2094
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
2095
|
+
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
|
|
2096
|
+
}
|
|
2097
|
+
m[k] = {
|
|
2098
|
+
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
2099
|
+
d: false,
|
|
2100
|
+
i: 0,
|
|
2101
|
+
c: {}
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
state = m[k];
|
|
2106
|
+
if (state.t !== type && !(type === 1 && state.t === 3)) {
|
|
2107
|
+
return null;
|
|
2108
|
+
}
|
|
2109
|
+
if (type === 2) {
|
|
2110
|
+
if (!state.d) {
|
|
2111
|
+
state.d = true;
|
|
2112
|
+
t[k] = [];
|
|
2113
|
+
}
|
|
2114
|
+
t[k].push(t = {});
|
|
2115
|
+
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
|
|
2116
|
+
}
|
|
2117
|
+
if (state.d) {
|
|
2118
|
+
return null;
|
|
2119
|
+
}
|
|
2120
|
+
state.d = true;
|
|
2121
|
+
if (type === 1) {
|
|
2122
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
2123
|
+
} else if (type === 0 && hasOwn) {
|
|
2124
|
+
return null;
|
|
2125
|
+
}
|
|
2126
|
+
return [k, t, state.c];
|
|
2127
|
+
}
|
|
2128
|
+
__name(peekTable, "peekTable");
|
|
2129
|
+
function parse3(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
2130
|
+
let res = {};
|
|
2131
|
+
let meta = {};
|
|
2132
|
+
let tbl = res;
|
|
2133
|
+
let m = meta;
|
|
2134
|
+
for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
|
|
2135
|
+
if (toml[ptr] === "[") {
|
|
2136
|
+
let isTableArray = toml[++ptr] === "[";
|
|
2137
|
+
let k = parseKey(toml, ptr += +isTableArray, "]");
|
|
2138
|
+
if (isTableArray) {
|
|
2139
|
+
if (toml[k[1] - 1] !== "]") {
|
|
2140
|
+
throw new TomlError("expected end of table declaration", {
|
|
2141
|
+
toml,
|
|
2142
|
+
ptr: k[1] - 1
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
k[1]++;
|
|
2146
|
+
}
|
|
2147
|
+
let p = peekTable(
|
|
2148
|
+
k[0],
|
|
2149
|
+
res,
|
|
2150
|
+
meta,
|
|
2151
|
+
isTableArray ? 2 : 1
|
|
2152
|
+
/* Type.EXPLICIT */
|
|
2153
|
+
);
|
|
2154
|
+
if (!p) {
|
|
2155
|
+
throw new TomlError("trying to redefine an already defined table or value", {
|
|
2156
|
+
toml,
|
|
2157
|
+
ptr
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
m = p[2];
|
|
2161
|
+
tbl = p[1];
|
|
2162
|
+
ptr = k[1];
|
|
2163
|
+
} else {
|
|
2164
|
+
let k = parseKey(toml, ptr);
|
|
2165
|
+
let p = peekTable(
|
|
2166
|
+
k[0],
|
|
2167
|
+
tbl,
|
|
2168
|
+
m,
|
|
2169
|
+
0
|
|
2170
|
+
/* Type.DOTTED */
|
|
2171
|
+
);
|
|
2172
|
+
if (!p) {
|
|
2173
|
+
throw new TomlError("trying to redefine an already defined table or value", {
|
|
2174
|
+
toml,
|
|
2175
|
+
ptr
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
|
|
2179
|
+
p[1][p[0]] = v[0];
|
|
2180
|
+
ptr = v[1];
|
|
2181
|
+
}
|
|
2182
|
+
ptr = skipVoid(toml, ptr, true);
|
|
2183
|
+
if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
|
|
2184
|
+
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
2185
|
+
toml,
|
|
2186
|
+
ptr
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
ptr = skipVoid(toml, ptr);
|
|
2190
|
+
}
|
|
2191
|
+
return res;
|
|
2192
|
+
}
|
|
2193
|
+
__name(parse3, "parse");
|
|
2194
|
+
|
|
2195
|
+
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/stringify.js
|
|
2196
|
+
var BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
2197
|
+
function extendedTypeOf(obj) {
|
|
2198
|
+
let type = typeof obj;
|
|
2199
|
+
if (type === "object") {
|
|
2200
|
+
if (Array.isArray(obj))
|
|
2201
|
+
return "array";
|
|
2202
|
+
if (obj instanceof Date)
|
|
2203
|
+
return "date";
|
|
2204
|
+
}
|
|
2205
|
+
return type;
|
|
2206
|
+
}
|
|
2207
|
+
__name(extendedTypeOf, "extendedTypeOf");
|
|
2208
|
+
function isArrayOfTables(obj) {
|
|
2209
|
+
for (let i = 0; i < obj.length; i++) {
|
|
2210
|
+
if (extendedTypeOf(obj[i]) !== "object")
|
|
2211
|
+
return false;
|
|
2212
|
+
}
|
|
2213
|
+
return obj.length != 0;
|
|
2214
|
+
}
|
|
2215
|
+
__name(isArrayOfTables, "isArrayOfTables");
|
|
2216
|
+
function formatString(s) {
|
|
2217
|
+
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
2218
|
+
}
|
|
2219
|
+
__name(formatString, "formatString");
|
|
2220
|
+
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
2221
|
+
if (depth === 0) {
|
|
2222
|
+
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
2223
|
+
}
|
|
2224
|
+
if (type === "number") {
|
|
2225
|
+
if (isNaN(val))
|
|
2226
|
+
return "nan";
|
|
2227
|
+
if (val === Infinity)
|
|
2228
|
+
return "inf";
|
|
2229
|
+
if (val === -Infinity)
|
|
2230
|
+
return "-inf";
|
|
2231
|
+
if (numberAsFloat && Number.isInteger(val))
|
|
2232
|
+
return val.toFixed(1);
|
|
2233
|
+
return val.toString();
|
|
2234
|
+
}
|
|
2235
|
+
if (type === "bigint" || type === "boolean") {
|
|
2236
|
+
return val.toString();
|
|
2237
|
+
}
|
|
2238
|
+
if (type === "string") {
|
|
2239
|
+
return formatString(val);
|
|
2240
|
+
}
|
|
2241
|
+
if (type === "date") {
|
|
2242
|
+
if (isNaN(val.getTime())) {
|
|
2243
|
+
throw new TypeError("cannot serialize invalid date");
|
|
2244
|
+
}
|
|
2245
|
+
return val.toISOString();
|
|
2246
|
+
}
|
|
2247
|
+
if (type === "object") {
|
|
2248
|
+
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
2249
|
+
}
|
|
2250
|
+
if (type === "array") {
|
|
2251
|
+
return stringifyArray(val, depth, numberAsFloat);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
__name(stringifyValue, "stringifyValue");
|
|
2255
|
+
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
2256
|
+
let keys = Object.keys(obj);
|
|
2257
|
+
if (keys.length === 0)
|
|
2258
|
+
return "{}";
|
|
2259
|
+
let res = "{ ";
|
|
2260
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2261
|
+
let k = keys[i];
|
|
2262
|
+
if (i)
|
|
2263
|
+
res += ", ";
|
|
2264
|
+
res += BARE_KEY.test(k) ? k : formatString(k);
|
|
2265
|
+
res += " = ";
|
|
2266
|
+
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
|
|
2267
|
+
}
|
|
2268
|
+
return res + " }";
|
|
2269
|
+
}
|
|
2270
|
+
__name(stringifyInlineTable, "stringifyInlineTable");
|
|
2271
|
+
function stringifyArray(array, depth, numberAsFloat) {
|
|
2272
|
+
if (array.length === 0)
|
|
2273
|
+
return "[]";
|
|
2274
|
+
let res = "[ ";
|
|
2275
|
+
for (let i = 0; i < array.length; i++) {
|
|
2276
|
+
if (i)
|
|
2277
|
+
res += ", ";
|
|
2278
|
+
if (array[i] === null || array[i] === void 0) {
|
|
2279
|
+
throw new TypeError("arrays cannot contain null or undefined values");
|
|
2280
|
+
}
|
|
2281
|
+
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
|
|
2282
|
+
}
|
|
2283
|
+
return res + " ]";
|
|
2284
|
+
}
|
|
2285
|
+
__name(stringifyArray, "stringifyArray");
|
|
2286
|
+
function stringifyArrayTable(array, key, depth, numberAsFloat) {
|
|
2287
|
+
if (depth === 0) {
|
|
2288
|
+
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
2289
|
+
}
|
|
2290
|
+
let res = "";
|
|
2291
|
+
for (let i = 0; i < array.length; i++) {
|
|
2292
|
+
res += `${res && "\n"}[[${key}]]
|
|
2293
|
+
`;
|
|
2294
|
+
res += stringifyTable(0, array[i], key, depth, numberAsFloat);
|
|
2295
|
+
}
|
|
2296
|
+
return res;
|
|
2297
|
+
}
|
|
2298
|
+
__name(stringifyArrayTable, "stringifyArrayTable");
|
|
2299
|
+
function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
2300
|
+
if (depth === 0) {
|
|
2301
|
+
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
2302
|
+
}
|
|
2303
|
+
let preamble = "";
|
|
2304
|
+
let tables = "";
|
|
2305
|
+
let keys = Object.keys(obj);
|
|
2306
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2307
|
+
let k = keys[i];
|
|
2308
|
+
if (obj[k] !== null && obj[k] !== void 0) {
|
|
2309
|
+
let type = extendedTypeOf(obj[k]);
|
|
2310
|
+
if (type === "symbol" || type === "function") {
|
|
2311
|
+
throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
2312
|
+
}
|
|
2313
|
+
let key = BARE_KEY.test(k) ? k : formatString(k);
|
|
2314
|
+
if (type === "array" && isArrayOfTables(obj[k])) {
|
|
2315
|
+
tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
2316
|
+
} else if (type === "object") {
|
|
2317
|
+
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
2318
|
+
tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
|
|
2319
|
+
} else {
|
|
2320
|
+
preamble += key;
|
|
2321
|
+
preamble += " = ";
|
|
2322
|
+
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
|
|
2323
|
+
preamble += "\n";
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
if (tableKey && (preamble || !tables))
|
|
2328
|
+
preamble = preamble ? `[${tableKey}]
|
|
2329
|
+
${preamble}` : `[${tableKey}]`;
|
|
2330
|
+
return preamble && tables ? `${preamble}
|
|
2331
|
+
${tables}` : preamble || tables;
|
|
2332
|
+
}
|
|
2333
|
+
__name(stringifyTable, "stringifyTable");
|
|
2334
|
+
function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
2335
|
+
if (extendedTypeOf(obj) !== "object") {
|
|
2336
|
+
throw new TypeError("stringify can only be called with an object");
|
|
2337
|
+
}
|
|
2338
|
+
let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
|
|
2339
|
+
if (str[str.length - 1] !== "\n")
|
|
2340
|
+
return str + "\n";
|
|
2341
|
+
return str;
|
|
2342
|
+
}
|
|
2343
|
+
__name(stringify, "stringify");
|
|
2344
|
+
|
|
2345
|
+
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/index.js
|
|
2346
|
+
var dist_default = { parse: parse3, stringify, TomlDate, TomlError };
|
|
2347
|
+
|
|
2348
|
+
// src/parse.ts
|
|
2349
|
+
var ParseError = class extends UserError {
|
|
2350
|
+
static {
|
|
2351
|
+
__name(this, "ParseError");
|
|
2352
|
+
}
|
|
2353
|
+
text;
|
|
2354
|
+
notes;
|
|
2355
|
+
location;
|
|
2356
|
+
kind;
|
|
2357
|
+
constructor({ text, notes, location, kind, telemetryMessage }) {
|
|
2358
|
+
super(text, { telemetryMessage });
|
|
2359
|
+
this.name = this.constructor.name;
|
|
2360
|
+
this.text = text;
|
|
2361
|
+
this.notes = notes ?? [];
|
|
2362
|
+
this.location = location;
|
|
2363
|
+
this.kind = kind ?? "error";
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
var APIError = class extends ParseError {
|
|
2367
|
+
static {
|
|
2368
|
+
__name(this, "APIError");
|
|
2369
|
+
}
|
|
2370
|
+
#status;
|
|
2371
|
+
code;
|
|
2372
|
+
accountTag;
|
|
2373
|
+
constructor({ status, ...rest }) {
|
|
2374
|
+
super(rest);
|
|
2375
|
+
this.name = this.constructor.name;
|
|
2376
|
+
this.#status = status;
|
|
2377
|
+
}
|
|
2378
|
+
isGatewayError() {
|
|
2379
|
+
if (this.#status !== void 0) {
|
|
2380
|
+
return [524].includes(this.#status);
|
|
2381
|
+
}
|
|
2382
|
+
return false;
|
|
2383
|
+
}
|
|
2384
|
+
isRetryable() {
|
|
2385
|
+
return String(this.#status).startsWith("5");
|
|
2386
|
+
}
|
|
2387
|
+
// Allow `APIError`s to be marked as handled.
|
|
2388
|
+
#reportable = true;
|
|
2389
|
+
get reportable() {
|
|
2390
|
+
return this.#reportable;
|
|
2391
|
+
}
|
|
2392
|
+
preventReport() {
|
|
2393
|
+
this.#reportable = false;
|
|
2394
|
+
}
|
|
2395
|
+
};
|
|
2396
|
+
function parseTOML(input, file) {
|
|
2397
|
+
try {
|
|
2398
|
+
return dist_default.parse(input);
|
|
2399
|
+
} catch (err) {
|
|
2400
|
+
if (!(err instanceof TomlError)) {
|
|
2401
|
+
throw err;
|
|
2402
|
+
}
|
|
2403
|
+
const location = {
|
|
2404
|
+
lineText: input.split("\n")[err.line - 1],
|
|
2405
|
+
line: err.line,
|
|
2406
|
+
column: err.column - 1,
|
|
2407
|
+
file,
|
|
2408
|
+
fileText: input
|
|
2409
|
+
};
|
|
2410
|
+
throw new ParseError({
|
|
2411
|
+
text: err.message.substring(0, err.message.indexOf("\n")),
|
|
2412
|
+
location,
|
|
2413
|
+
telemetryMessage: "TOML parse error"
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
__name(parseTOML, "parseTOML");
|
|
2418
|
+
function parsePackageJSON(input, file) {
|
|
2419
|
+
return parseJSON(input, file);
|
|
2420
|
+
}
|
|
2421
|
+
__name(parsePackageJSON, "parsePackageJSON");
|
|
2422
|
+
function parseJSON(input, file) {
|
|
2423
|
+
return parseJSONC(input, file, {
|
|
2424
|
+
allowEmptyContent: false,
|
|
2425
|
+
allowTrailingComma: false,
|
|
2426
|
+
disallowComments: true
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
__name(parseJSON, "parseJSON");
|
|
2430
|
+
function parseJSONC(input, file, options = { allowTrailingComma: true }) {
|
|
2431
|
+
const errors = [];
|
|
2432
|
+
const data = parse2(input, errors, options);
|
|
2433
|
+
if (errors.length) {
|
|
2434
|
+
throw new ParseError({
|
|
2435
|
+
text: printParseErrorCode(errors[0].error),
|
|
2436
|
+
location: {
|
|
2437
|
+
...indexLocation({ file, fileText: input }, errors[0].offset + 1),
|
|
2438
|
+
length: errors[0].length
|
|
2439
|
+
},
|
|
2440
|
+
telemetryMessage: "JSON(C) parse error"
|
|
2441
|
+
});
|
|
2442
|
+
}
|
|
2443
|
+
return data;
|
|
2444
|
+
}
|
|
2445
|
+
__name(parseJSONC, "parseJSONC");
|
|
2446
|
+
function readFileSyncToBuffer(file) {
|
|
2447
|
+
try {
|
|
2448
|
+
return readFileSync$1(file);
|
|
2449
|
+
} catch (err) {
|
|
2450
|
+
const { message } = err;
|
|
2451
|
+
throw new ParseError({
|
|
2452
|
+
text: `Could not read file: ${file}`,
|
|
2453
|
+
notes: [
|
|
2454
|
+
{
|
|
2455
|
+
text: message.replace(file, resolve(file))
|
|
2456
|
+
}
|
|
2457
|
+
]
|
|
2458
|
+
});
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
__name(readFileSyncToBuffer, "readFileSyncToBuffer");
|
|
2462
|
+
function readFileSync(file) {
|
|
2463
|
+
try {
|
|
2464
|
+
const buffer = readFileSync$1(file);
|
|
2465
|
+
return removeBOMAndValidate(buffer, file);
|
|
2466
|
+
} catch (err) {
|
|
2467
|
+
if (err instanceof ParseError) {
|
|
2468
|
+
throw err;
|
|
2469
|
+
}
|
|
2470
|
+
const { message } = err;
|
|
2471
|
+
throw new ParseError({
|
|
2472
|
+
text: `Could not read file: ${file}`,
|
|
2473
|
+
notes: [
|
|
2474
|
+
{
|
|
2475
|
+
text: message.replace(file, resolve(file))
|
|
2476
|
+
}
|
|
2477
|
+
],
|
|
2478
|
+
telemetryMessage: "Could not read file"
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
__name(readFileSync, "readFileSync");
|
|
2483
|
+
function indexLocation(file, index) {
|
|
2484
|
+
let lineText, line = 0, column = 0, cursor = 0;
|
|
2485
|
+
const { fileText = "" } = file;
|
|
2486
|
+
for (const row of fileText.split("\n")) {
|
|
2487
|
+
line++;
|
|
2488
|
+
cursor += row.length + 1;
|
|
2489
|
+
if (cursor >= index) {
|
|
2490
|
+
lineText = row;
|
|
2491
|
+
column = row.length - (cursor - index);
|
|
2492
|
+
break;
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
return { lineText, line, column, ...file };
|
|
2496
|
+
}
|
|
2497
|
+
__name(indexLocation, "indexLocation");
|
|
2498
|
+
function searchLocation(file, query) {
|
|
2499
|
+
let lineText, length, line = 0, column = 0;
|
|
2500
|
+
const queryText = String(query);
|
|
2501
|
+
const { fileText = "" } = file;
|
|
2502
|
+
for (const content of fileText.split("\n")) {
|
|
2503
|
+
line++;
|
|
2504
|
+
const index = content.indexOf(queryText);
|
|
2505
|
+
if (index >= 0) {
|
|
2506
|
+
lineText = content;
|
|
2507
|
+
column = index;
|
|
2508
|
+
length = queryText.length;
|
|
2509
|
+
break;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
return { lineText, line, column, length, ...file };
|
|
2513
|
+
}
|
|
2514
|
+
__name(searchLocation, "searchLocation");
|
|
2515
|
+
var units = {
|
|
2516
|
+
nanoseconds: 1e-9,
|
|
2517
|
+
nanosecond: 1e-9,
|
|
2518
|
+
microseconds: 1e-6,
|
|
2519
|
+
microsecond: 1e-6,
|
|
2520
|
+
milliseconds: 1e-3,
|
|
2521
|
+
millisecond: 1e-3,
|
|
2522
|
+
seconds: 1,
|
|
2523
|
+
second: 1,
|
|
2524
|
+
minutes: 60,
|
|
2525
|
+
minute: 60,
|
|
2526
|
+
hours: 3600,
|
|
2527
|
+
hour: 3600,
|
|
2528
|
+
days: 86400,
|
|
2529
|
+
day: 86400,
|
|
2530
|
+
weeks: 604800,
|
|
2531
|
+
week: 604800,
|
|
2532
|
+
month: 18144e3,
|
|
2533
|
+
year: 220752e3,
|
|
2534
|
+
nsecs: 1e-9,
|
|
2535
|
+
nsec: 1e-9,
|
|
2536
|
+
usecs: 1e-6,
|
|
2537
|
+
usec: 1e-6,
|
|
2538
|
+
msecs: 1e-3,
|
|
2539
|
+
msec: 1e-3,
|
|
2540
|
+
secs: 1,
|
|
2541
|
+
sec: 1,
|
|
2542
|
+
mins: 60,
|
|
2543
|
+
min: 60,
|
|
2544
|
+
ns: 1e-9,
|
|
2545
|
+
us: 1e-6,
|
|
2546
|
+
ms: 1e-3,
|
|
2547
|
+
mo: 18144e3,
|
|
2548
|
+
yr: 220752e3,
|
|
2549
|
+
s: 1,
|
|
2550
|
+
m: 60,
|
|
2551
|
+
h: 3600,
|
|
2552
|
+
d: 86400,
|
|
2553
|
+
w: 604800,
|
|
2554
|
+
y: 220752e3
|
|
2555
|
+
};
|
|
2556
|
+
function parseHumanDuration(s) {
|
|
2557
|
+
const unitsMap = new Map(Object.entries(units));
|
|
2558
|
+
s = s.trim().toLowerCase();
|
|
2559
|
+
let base = 1;
|
|
2560
|
+
for (const [name, _] of unitsMap) {
|
|
2561
|
+
if (s.endsWith(name)) {
|
|
2562
|
+
s = s.substring(0, s.length - name.length);
|
|
2563
|
+
base = unitsMap.get(name) || 1;
|
|
2564
|
+
break;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
return Number(s) * base;
|
|
2568
|
+
}
|
|
2569
|
+
__name(parseHumanDuration, "parseHumanDuration");
|
|
2570
|
+
function parseNonHyphenedUuid(uuid) {
|
|
2571
|
+
if (uuid == null || uuid.includes("-")) {
|
|
2572
|
+
return uuid;
|
|
2573
|
+
}
|
|
2574
|
+
if (uuid.length != 32) {
|
|
2575
|
+
return null;
|
|
2576
|
+
}
|
|
2577
|
+
const uuid_parts = [];
|
|
2578
|
+
uuid_parts.push(uuid.slice(0, 8));
|
|
2579
|
+
uuid_parts.push(uuid.slice(8, 12));
|
|
2580
|
+
uuid_parts.push(uuid.slice(12, 16));
|
|
2581
|
+
uuid_parts.push(uuid.slice(16, 20));
|
|
2582
|
+
uuid_parts.push(uuid.slice(20));
|
|
2583
|
+
let hyphenated = "";
|
|
2584
|
+
uuid_parts.forEach((part) => hyphenated += part + "-");
|
|
2585
|
+
return hyphenated.slice(0, 36);
|
|
2586
|
+
}
|
|
2587
|
+
__name(parseNonHyphenedUuid, "parseNonHyphenedUuid");
|
|
2588
|
+
function parseByteSize(s, base = void 0) {
|
|
2589
|
+
const match = s.match(
|
|
2590
|
+
/^(\d*\.*\d*)\s*([kKmMgGtTpP]{0,1})([i]{0,1}[bB]{0,1})$/
|
|
2591
|
+
);
|
|
2592
|
+
if (!match) {
|
|
2593
|
+
return NaN;
|
|
2594
|
+
}
|
|
2595
|
+
const size = match[1];
|
|
2596
|
+
if (size.length === 0 || isNaN(Number(size))) {
|
|
2597
|
+
return NaN;
|
|
2598
|
+
}
|
|
2599
|
+
const unit = match[2].toLowerCase();
|
|
2600
|
+
const sizeUnits = {
|
|
2601
|
+
k: 1,
|
|
2602
|
+
m: 2,
|
|
2603
|
+
g: 3,
|
|
2604
|
+
t: 4,
|
|
2605
|
+
p: 5
|
|
2606
|
+
};
|
|
2607
|
+
if (unit.length !== 0 && !(unit in sizeUnits)) {
|
|
2608
|
+
return NaN;
|
|
2609
|
+
}
|
|
2610
|
+
const binary = match[3].toLowerCase() == "ib";
|
|
2611
|
+
if (binary && unit.length === 0) {
|
|
2612
|
+
return NaN;
|
|
2613
|
+
}
|
|
2614
|
+
const pow = sizeUnits[unit] || 0;
|
|
2615
|
+
return Math.floor(
|
|
2616
|
+
Number(size) * Math.pow(base ?? (binary ? 1024 : 1e3), pow)
|
|
2617
|
+
);
|
|
2618
|
+
}
|
|
2619
|
+
__name(parseByteSize, "parseByteSize");
|
|
2620
|
+
var UNSUPPORTED_BOMS = [
|
|
2621
|
+
{
|
|
2622
|
+
buffer: Buffer.from([0, 0, 254, 255]),
|
|
2623
|
+
encoding: "UTF-32 BE"
|
|
2624
|
+
},
|
|
2625
|
+
{
|
|
2626
|
+
buffer: Buffer.from([255, 254, 0, 0]),
|
|
2627
|
+
encoding: "UTF-32 LE"
|
|
2628
|
+
},
|
|
2629
|
+
{
|
|
2630
|
+
buffer: Buffer.from([254, 255]),
|
|
2631
|
+
encoding: "UTF-16 BE"
|
|
2632
|
+
},
|
|
2633
|
+
{
|
|
2634
|
+
buffer: Buffer.from([255, 254]),
|
|
2635
|
+
encoding: "UTF-16 LE"
|
|
2636
|
+
}
|
|
2637
|
+
];
|
|
2638
|
+
function removeBOMAndValidate(buffer, file) {
|
|
2639
|
+
for (const bom of UNSUPPORTED_BOMS) {
|
|
2640
|
+
if (buffer.length >= bom.buffer.length && buffer.subarray(0, bom.buffer.length).equals(bom.buffer)) {
|
|
2641
|
+
throw new ParseError({
|
|
2642
|
+
text: `Configuration file contains ${bom.encoding} byte order marker`,
|
|
2643
|
+
notes: [
|
|
2644
|
+
{
|
|
2645
|
+
text: `The file "${file}" appears to be encoded as ${bom.encoding}. Please save the file as UTF-8 without BOM.`
|
|
2646
|
+
}
|
|
2647
|
+
],
|
|
2648
|
+
location: { file, line: 1, column: 0 },
|
|
2649
|
+
telemetryMessage: `${bom.encoding} BOM detected`
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
const content = buffer.toString("utf-8");
|
|
2654
|
+
if (content.charCodeAt(0) === 65279) {
|
|
2655
|
+
return content.slice(1);
|
|
2656
|
+
}
|
|
2657
|
+
return content;
|
|
2658
|
+
}
|
|
2659
|
+
__name(removeBOMAndValidate, "removeBOMAndValidate");
|
|
2660
|
+
var typeMappings = {
|
|
2661
|
+
directory: "isDirectory",
|
|
2662
|
+
file: "isFile"
|
|
2663
|
+
};
|
|
2664
|
+
function checkType(type) {
|
|
2665
|
+
if (type in typeMappings) {
|
|
2666
|
+
return;
|
|
2667
|
+
}
|
|
2668
|
+
throw new Error(`Invalid type specified: ${type}`);
|
|
2669
|
+
}
|
|
2670
|
+
__name(checkType, "checkType");
|
|
2671
|
+
var matchType = /* @__PURE__ */ __name((type, stat) => type === void 0 || stat[typeMappings[type]](), "matchType");
|
|
2672
|
+
var toPath = /* @__PURE__ */ __name((urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath, "toPath");
|
|
2673
|
+
function locatePathSync(paths, {
|
|
2674
|
+
cwd = process2.cwd(),
|
|
2675
|
+
type = "file",
|
|
2676
|
+
allowSymlinks = true
|
|
2677
|
+
} = {}) {
|
|
2678
|
+
checkType(type);
|
|
2679
|
+
cwd = toPath(cwd);
|
|
2680
|
+
const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
|
|
2681
|
+
for (const path_ of paths) {
|
|
2682
|
+
try {
|
|
2683
|
+
const stat = statFunction(path3.resolve(cwd, path_));
|
|
2684
|
+
if (matchType(type, stat)) {
|
|
2685
|
+
return path_;
|
|
2686
|
+
}
|
|
2687
|
+
} catch {
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
__name(locatePathSync, "locatePathSync");
|
|
2692
|
+
|
|
2693
|
+
// ../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js
|
|
2694
|
+
var toPath2 = /* @__PURE__ */ __name((urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath, "toPath");
|
|
2695
|
+
var findUpStop = Symbol("findUpStop");
|
|
2696
|
+
function findUpMultipleSync(name, options = {}) {
|
|
2697
|
+
let directory = path3.resolve(toPath2(options.cwd) || "");
|
|
2698
|
+
const { root } = path3.parse(directory);
|
|
2699
|
+
const stopAt = options.stopAt || root;
|
|
2700
|
+
const limit = options.limit || Number.POSITIVE_INFINITY;
|
|
2701
|
+
const paths = [name].flat();
|
|
2702
|
+
const runMatcher = /* @__PURE__ */ __name((locateOptions) => {
|
|
2703
|
+
if (typeof name !== "function") {
|
|
2704
|
+
return locatePathSync(paths, locateOptions);
|
|
2705
|
+
}
|
|
2706
|
+
const foundPath = name(locateOptions.cwd);
|
|
2707
|
+
if (typeof foundPath === "string") {
|
|
2708
|
+
return locatePathSync([foundPath], locateOptions);
|
|
2709
|
+
}
|
|
2710
|
+
return foundPath;
|
|
2711
|
+
}, "runMatcher");
|
|
2712
|
+
const matches = [];
|
|
2713
|
+
while (true) {
|
|
2714
|
+
const foundPath = runMatcher({ ...options, cwd: directory });
|
|
2715
|
+
if (foundPath === findUpStop) {
|
|
2716
|
+
break;
|
|
2717
|
+
}
|
|
2718
|
+
if (foundPath) {
|
|
2719
|
+
matches.push(path3.resolve(directory, foundPath));
|
|
2720
|
+
}
|
|
2721
|
+
if (directory === stopAt || matches.length >= limit) {
|
|
2722
|
+
break;
|
|
2723
|
+
}
|
|
2724
|
+
directory = path3.dirname(directory);
|
|
2725
|
+
}
|
|
2726
|
+
return matches;
|
|
2727
|
+
}
|
|
2728
|
+
__name(findUpMultipleSync, "findUpMultipleSync");
|
|
2729
|
+
function findUpSync(name, options = {}) {
|
|
2730
|
+
const matches = findUpMultipleSync(name, { ...options, limit: 1 });
|
|
2731
|
+
return matches[0];
|
|
2732
|
+
}
|
|
2733
|
+
__name(findUpSync, "findUpSync");
|
|
2734
|
+
|
|
2735
|
+
// ../../node_modules/.pnpm/ts-dedent@2.2.0/node_modules/ts-dedent/esm/index.js
|
|
2736
|
+
function dedent(templ) {
|
|
2737
|
+
var values = [];
|
|
2738
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2739
|
+
values[_i - 1] = arguments[_i];
|
|
2740
|
+
}
|
|
2741
|
+
var strings = Array.from(typeof templ === "string" ? [templ] : templ);
|
|
2742
|
+
strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
|
|
2743
|
+
var indentLengths = strings.reduce(function(arr, str) {
|
|
2744
|
+
var matches = str.match(/\n([\t ]+|(?!\s).)/g);
|
|
2745
|
+
if (matches) {
|
|
2746
|
+
return arr.concat(matches.map(function(match) {
|
|
2747
|
+
var _a, _b;
|
|
2748
|
+
return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
2749
|
+
}));
|
|
2750
|
+
}
|
|
2751
|
+
return arr;
|
|
2752
|
+
}, []);
|
|
2753
|
+
if (indentLengths.length) {
|
|
2754
|
+
var pattern_1 = new RegExp("\n[ ]{" + Math.min.apply(Math, indentLengths) + "}", "g");
|
|
2755
|
+
strings = strings.map(function(str) {
|
|
2756
|
+
return str.replace(pattern_1, "\n");
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
strings[0] = strings[0].replace(/^\r?\n/, "");
|
|
2760
|
+
var string = strings[0];
|
|
2761
|
+
values.forEach(function(value, i) {
|
|
2762
|
+
var endentations = string.match(/(?:^|\n)( *)$/);
|
|
2763
|
+
var endentation = endentations ? endentations[1] : "";
|
|
2764
|
+
var indentedValue = value;
|
|
2765
|
+
if (typeof value === "string" && value.includes("\n")) {
|
|
2766
|
+
indentedValue = String(value).split("\n").map(function(str, i2) {
|
|
2767
|
+
return i2 === 0 ? str : "" + endentation + str;
|
|
2768
|
+
}).join("\n");
|
|
2769
|
+
}
|
|
2770
|
+
string += indentedValue + strings[i + 1];
|
|
2771
|
+
});
|
|
2772
|
+
return string;
|
|
2773
|
+
}
|
|
2774
|
+
__name(dedent, "dedent");
|
|
2775
|
+
var esm_default = dedent;
|
|
2776
|
+
|
|
2777
|
+
// src/config/config-helpers.ts
|
|
2778
|
+
function resolveWranglerConfigPath({
|
|
2779
|
+
config,
|
|
2780
|
+
script
|
|
2781
|
+
}, options) {
|
|
2782
|
+
if (config !== void 0) {
|
|
2783
|
+
return {
|
|
2784
|
+
userConfigPath: config,
|
|
2785
|
+
configPath: config,
|
|
2786
|
+
deployConfigPath: void 0,
|
|
2787
|
+
redirected: false
|
|
2788
|
+
};
|
|
2789
|
+
}
|
|
2790
|
+
const leafPath = script !== void 0 ? path3.dirname(script) : process.cwd();
|
|
2791
|
+
return findWranglerConfig(leafPath, options);
|
|
2792
|
+
}
|
|
2793
|
+
__name(resolveWranglerConfigPath, "resolveWranglerConfigPath");
|
|
2794
|
+
function findWranglerConfig(referencePath = process.cwd(), { useRedirectIfAvailable = false } = {}) {
|
|
2795
|
+
const userConfigPath = findUpSync(`wrangler.json`, { cwd: referencePath }) ?? findUpSync(`wrangler.jsonc`, { cwd: referencePath }) ?? findUpSync(`wrangler.toml`, { cwd: referencePath });
|
|
2796
|
+
if (!useRedirectIfAvailable) {
|
|
2797
|
+
return {
|
|
2798
|
+
userConfigPath,
|
|
2799
|
+
configPath: userConfigPath,
|
|
2800
|
+
deployConfigPath: void 0,
|
|
2801
|
+
redirected: false
|
|
2802
|
+
};
|
|
2803
|
+
}
|
|
2804
|
+
const { configPath, deployConfigPath, redirected } = findRedirectedWranglerConfig(referencePath, userConfigPath);
|
|
2805
|
+
return {
|
|
2806
|
+
userConfigPath,
|
|
2807
|
+
configPath,
|
|
2808
|
+
deployConfigPath,
|
|
2809
|
+
redirected
|
|
2810
|
+
};
|
|
2811
|
+
}
|
|
2812
|
+
__name(findWranglerConfig, "findWranglerConfig");
|
|
2813
|
+
function findRedirectedWranglerConfig(cwd, userConfigPath) {
|
|
2814
|
+
const deployConfigPath = findUpSync(PATH_TO_DEPLOY_CONFIG, { cwd });
|
|
2815
|
+
if (deployConfigPath === void 0) {
|
|
2816
|
+
return { configPath: userConfigPath, deployConfigPath, redirected: false };
|
|
2817
|
+
}
|
|
2818
|
+
let redirectedConfigPath;
|
|
2819
|
+
const deployConfigFile = readFileSync(deployConfigPath);
|
|
2820
|
+
try {
|
|
2821
|
+
const deployConfig = parseJSONC(deployConfigFile, deployConfigPath);
|
|
2822
|
+
redirectedConfigPath = deployConfig.configPath && path3.resolve(path3.dirname(deployConfigPath), deployConfig.configPath);
|
|
2823
|
+
} catch (e) {
|
|
2824
|
+
throw new UserError(
|
|
2825
|
+
`Failed to parse the deploy configuration file at ${path3.relative(".", deployConfigPath)}`,
|
|
2826
|
+
{ cause: e }
|
|
2827
|
+
);
|
|
2828
|
+
}
|
|
2829
|
+
if (!redirectedConfigPath) {
|
|
2830
|
+
throw new UserError(esm_default`
|
|
2831
|
+
A deploy configuration file was found at "${path3.relative(".", deployConfigPath)}".
|
|
2832
|
+
But this is not valid - the required "configPath" property was not found.
|
|
2833
|
+
Instead this file contains:
|
|
2834
|
+
\`\`\`
|
|
2835
|
+
${deployConfigFile}
|
|
2836
|
+
\`\`\`
|
|
2837
|
+
`);
|
|
2838
|
+
}
|
|
2839
|
+
if (!existsSync(redirectedConfigPath)) {
|
|
2840
|
+
throw new UserError(esm_default`
|
|
2841
|
+
There is a deploy configuration at "${path3.relative(".", deployConfigPath)}".
|
|
2842
|
+
But the redirected configuration path it points to, "${path3.relative(".", redirectedConfigPath)}", does not exist.
|
|
2843
|
+
`);
|
|
2844
|
+
}
|
|
2845
|
+
if (userConfigPath) {
|
|
2846
|
+
if (path3.join(path3.dirname(userConfigPath), PATH_TO_DEPLOY_CONFIG) !== deployConfigPath) {
|
|
2847
|
+
throw new UserError(esm_default`
|
|
2848
|
+
Found both a user configuration file at "${path3.relative(".", userConfigPath)}"
|
|
2849
|
+
and a deploy configuration file at "${path3.relative(".", deployConfigPath)}".
|
|
2850
|
+
But these do not share the same base path so it is not clear which should be used.
|
|
2851
|
+
`);
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
return {
|
|
2855
|
+
configPath: redirectedConfigPath,
|
|
2856
|
+
deployConfigPath,
|
|
2857
|
+
redirected: true
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
__name(findRedirectedWranglerConfig, "findRedirectedWranglerConfig");
|
|
2861
|
+
function isRedirectedRawConfig(rawConfig, configPath, userConfigPath) {
|
|
2862
|
+
return configPath !== void 0 && configPath !== userConfigPath;
|
|
2863
|
+
}
|
|
2864
|
+
__name(isRedirectedRawConfig, "isRedirectedRawConfig");
|
|
2865
|
+
|
|
2866
|
+
// src/config/index.ts
|
|
2867
|
+
function configFormat(configPath) {
|
|
2868
|
+
if (configPath?.endsWith("toml")) {
|
|
2869
|
+
return "toml";
|
|
2870
|
+
} else if (configPath?.endsWith("json") || configPath?.endsWith("jsonc")) {
|
|
2871
|
+
return "jsonc";
|
|
2872
|
+
}
|
|
2873
|
+
return "none";
|
|
2874
|
+
}
|
|
2875
|
+
__name(configFormat, "configFormat");
|
|
2876
|
+
function configFileName(configPath) {
|
|
2877
|
+
const format3 = configFormat(configPath);
|
|
2878
|
+
if (format3 === "toml") {
|
|
2879
|
+
return "wrangler.toml";
|
|
2880
|
+
} else if (format3 === "jsonc") {
|
|
2881
|
+
return "wrangler.json";
|
|
2882
|
+
} else {
|
|
2883
|
+
return "Wrangler configuration";
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
__name(configFileName, "configFileName");
|
|
2887
|
+
function formatConfigSnippet(snippet, configPath, formatted = true) {
|
|
2888
|
+
const format3 = configFormat(configPath);
|
|
2889
|
+
if (format3 === "toml") {
|
|
2890
|
+
return dist_default.stringify(snippet);
|
|
2891
|
+
} else {
|
|
2892
|
+
return formatted ? JSON.stringify(snippet, null, 2) : JSON.stringify(snippet);
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
__name(formatConfigSnippet, "formatConfigSnippet");
|
|
2896
|
+
var parseRawConfigFile = /* @__PURE__ */ __name((configPath) => {
|
|
2897
|
+
if (configPath.endsWith(".toml")) {
|
|
2898
|
+
return parseTOML(readFileSync(configPath), configPath);
|
|
2899
|
+
}
|
|
2900
|
+
if (configPath.endsWith(".json") || configPath.endsWith(".jsonc")) {
|
|
2901
|
+
return parseJSONC(readFileSync(configPath), configPath);
|
|
2902
|
+
}
|
|
2903
|
+
return {};
|
|
2904
|
+
}, "parseRawConfigFile");
|
|
2905
|
+
var experimental_readRawConfig = /* @__PURE__ */ __name((args, options = {}) => {
|
|
2906
|
+
const { configPath, userConfigPath, deployConfigPath, redirected } = resolveWranglerConfigPath(args, options);
|
|
2907
|
+
const rawConfig = parseRawConfigFile(configPath ?? "");
|
|
2908
|
+
return {
|
|
2909
|
+
rawConfig,
|
|
2910
|
+
configPath,
|
|
2911
|
+
userConfigPath,
|
|
2912
|
+
deployConfigPath,
|
|
2913
|
+
redirected
|
|
2914
|
+
};
|
|
2915
|
+
}, "experimental_readRawConfig");
|
|
2916
|
+
/*! Bundled license information:
|
|
2917
|
+
|
|
2918
|
+
smol-toml/dist/error.js:
|
|
2919
|
+
(*!
|
|
2920
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2921
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2922
|
+
*
|
|
2923
|
+
* Redistribution and use in source and binary forms, with or without
|
|
2924
|
+
* modification, are permitted provided that the following conditions are met:
|
|
2925
|
+
*
|
|
2926
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2927
|
+
* list of conditions and the following disclaimer.
|
|
2928
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2929
|
+
* this list of conditions and the following disclaimer in the
|
|
2930
|
+
* documentation and/or other materials provided with the distribution.
|
|
2931
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2932
|
+
* may be used to endorse or promote products derived from this software without
|
|
2933
|
+
* specific prior written permission.
|
|
2934
|
+
*
|
|
2935
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2936
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2937
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2938
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2939
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2940
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2941
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2942
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2943
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2944
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2945
|
+
*)
|
|
2946
|
+
|
|
2947
|
+
smol-toml/dist/util.js:
|
|
2948
|
+
(*!
|
|
2949
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2950
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2951
|
+
*
|
|
2952
|
+
* Redistribution and use in source and binary forms, with or without
|
|
2953
|
+
* modification, are permitted provided that the following conditions are met:
|
|
2954
|
+
*
|
|
2955
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2956
|
+
* list of conditions and the following disclaimer.
|
|
2957
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2958
|
+
* this list of conditions and the following disclaimer in the
|
|
2959
|
+
* documentation and/or other materials provided with the distribution.
|
|
2960
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2961
|
+
* may be used to endorse or promote products derived from this software without
|
|
2962
|
+
* specific prior written permission.
|
|
2963
|
+
*
|
|
2964
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2965
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2966
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2967
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2968
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2969
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2970
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2971
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2972
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2973
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2974
|
+
*)
|
|
2975
|
+
|
|
2976
|
+
smol-toml/dist/date.js:
|
|
2977
|
+
(*!
|
|
2978
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2979
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2980
|
+
*
|
|
2981
|
+
* Redistribution and use in source and binary forms, with or without
|
|
2982
|
+
* modification, are permitted provided that the following conditions are met:
|
|
2983
|
+
*
|
|
2984
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2985
|
+
* list of conditions and the following disclaimer.
|
|
2986
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2987
|
+
* this list of conditions and the following disclaimer in the
|
|
2988
|
+
* documentation and/or other materials provided with the distribution.
|
|
2989
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2990
|
+
* may be used to endorse or promote products derived from this software without
|
|
2991
|
+
* specific prior written permission.
|
|
2992
|
+
*
|
|
2993
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2994
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2995
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2996
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2997
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2998
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2999
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
3000
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
3001
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
3002
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3003
|
+
*)
|
|
3004
|
+
|
|
3005
|
+
smol-toml/dist/primitive.js:
|
|
3006
|
+
(*!
|
|
3007
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3008
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3009
|
+
*
|
|
3010
|
+
* Redistribution and use in source and binary forms, with or without
|
|
3011
|
+
* modification, are permitted provided that the following conditions are met:
|
|
3012
|
+
*
|
|
3013
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
3014
|
+
* list of conditions and the following disclaimer.
|
|
3015
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
3016
|
+
* this list of conditions and the following disclaimer in the
|
|
3017
|
+
* documentation and/or other materials provided with the distribution.
|
|
3018
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
3019
|
+
* may be used to endorse or promote products derived from this software without
|
|
3020
|
+
* specific prior written permission.
|
|
3021
|
+
*
|
|
3022
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
3023
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
3024
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
3025
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
3026
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
3027
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
3028
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
3029
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
3030
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
3031
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3032
|
+
*)
|
|
3033
|
+
|
|
3034
|
+
smol-toml/dist/extract.js:
|
|
3035
|
+
(*!
|
|
3036
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3037
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3038
|
+
*
|
|
3039
|
+
* Redistribution and use in source and binary forms, with or without
|
|
3040
|
+
* modification, are permitted provided that the following conditions are met:
|
|
3041
|
+
*
|
|
3042
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
3043
|
+
* list of conditions and the following disclaimer.
|
|
3044
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
3045
|
+
* this list of conditions and the following disclaimer in the
|
|
3046
|
+
* documentation and/or other materials provided with the distribution.
|
|
3047
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
3048
|
+
* may be used to endorse or promote products derived from this software without
|
|
3049
|
+
* specific prior written permission.
|
|
3050
|
+
*
|
|
3051
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
3052
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
3053
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
3054
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
3055
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
3056
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
3057
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
3058
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
3059
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
3060
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3061
|
+
*)
|
|
3062
|
+
|
|
3063
|
+
smol-toml/dist/struct.js:
|
|
3064
|
+
(*!
|
|
3065
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3066
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3067
|
+
*
|
|
3068
|
+
* Redistribution and use in source and binary forms, with or without
|
|
3069
|
+
* modification, are permitted provided that the following conditions are met:
|
|
3070
|
+
*
|
|
3071
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
3072
|
+
* list of conditions and the following disclaimer.
|
|
3073
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
3074
|
+
* this list of conditions and the following disclaimer in the
|
|
3075
|
+
* documentation and/or other materials provided with the distribution.
|
|
3076
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
3077
|
+
* may be used to endorse or promote products derived from this software without
|
|
3078
|
+
* specific prior written permission.
|
|
3079
|
+
*
|
|
3080
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
3081
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
3082
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
3083
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
3084
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
3085
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
3086
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
3087
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
3088
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
3089
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3090
|
+
*)
|
|
3091
|
+
|
|
3092
|
+
smol-toml/dist/parse.js:
|
|
3093
|
+
(*!
|
|
3094
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3095
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3096
|
+
*
|
|
3097
|
+
* Redistribution and use in source and binary forms, with or without
|
|
3098
|
+
* modification, are permitted provided that the following conditions are met:
|
|
3099
|
+
*
|
|
3100
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
3101
|
+
* list of conditions and the following disclaimer.
|
|
3102
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
3103
|
+
* this list of conditions and the following disclaimer in the
|
|
3104
|
+
* documentation and/or other materials provided with the distribution.
|
|
3105
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
3106
|
+
* may be used to endorse or promote products derived from this software without
|
|
3107
|
+
* specific prior written permission.
|
|
3108
|
+
*
|
|
3109
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
3110
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
3111
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
3112
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
3113
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
3114
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
3115
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
3116
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
3117
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
3118
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3119
|
+
*)
|
|
3120
|
+
|
|
3121
|
+
smol-toml/dist/stringify.js:
|
|
3122
|
+
(*!
|
|
3123
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3124
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3125
|
+
*
|
|
3126
|
+
* Redistribution and use in source and binary forms, with or without
|
|
3127
|
+
* modification, are permitted provided that the following conditions are met:
|
|
3128
|
+
*
|
|
3129
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
3130
|
+
* list of conditions and the following disclaimer.
|
|
3131
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
3132
|
+
* this list of conditions and the following disclaimer in the
|
|
3133
|
+
* documentation and/or other materials provided with the distribution.
|
|
3134
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
3135
|
+
* may be used to endorse or promote products derived from this software without
|
|
3136
|
+
* specific prior written permission.
|
|
3137
|
+
*
|
|
3138
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
3139
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
3140
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
3141
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
3142
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
3143
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
3144
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
3145
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
3146
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
3147
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3148
|
+
*)
|
|
3149
|
+
|
|
3150
|
+
smol-toml/dist/index.js:
|
|
3151
|
+
(*!
|
|
3152
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3153
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
3154
|
+
*
|
|
3155
|
+
* Redistribution and use in source and binary forms, with or without
|
|
3156
|
+
* modification, are permitted provided that the following conditions are met:
|
|
3157
|
+
*
|
|
3158
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
3159
|
+
* list of conditions and the following disclaimer.
|
|
3160
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
3161
|
+
* this list of conditions and the following disclaimer in the
|
|
3162
|
+
* documentation and/or other materials provided with the distribution.
|
|
3163
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
3164
|
+
* may be used to endorse or promote products derived from this software without
|
|
3165
|
+
* specific prior written permission.
|
|
3166
|
+
*
|
|
3167
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
3168
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
3169
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
3170
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
3171
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
3172
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
3173
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
3174
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
3175
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
3176
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3177
|
+
*)
|
|
3178
|
+
*/
|
|
3179
|
+
|
|
3180
|
+
export { APIError, CommandLineArgsError, DeprecationError, FatalError, JsonFriendlyFatalError, MissingConfigError, ParseError, UserError, applyEdits, configFileName, configFormat, createFatalError, dedent, dist_default, experimental_readRawConfig, findWranglerConfig, format2 as format, formatConfigSnippet, indexLocation, isRedirectedRawConfig, modify, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, resolveWranglerConfigPath, searchLocation };
|