opencode-dotenv 0.3.8 → 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/README.md +173 -27
- package/dist/index.js +1024 -316
- package/package.json +26 -28
package/dist/index.js
CHANGED
|
@@ -1,380 +1,1088 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/plugin.ts
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { appendFile, mkdir } from "fs/promises";
|
|
5
|
+
|
|
6
|
+
// node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
7
|
+
function createScanner(text, ignoreTrivia = false) {
|
|
8
|
+
const len = text.length;
|
|
9
|
+
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
|
|
10
|
+
function scanHexDigits(count, exact) {
|
|
11
|
+
let digits = 0;
|
|
12
|
+
let value2 = 0;
|
|
13
|
+
while (digits < count || !exact) {
|
|
14
|
+
let ch = text.charCodeAt(pos);
|
|
15
|
+
if (ch >= 48 && ch <= 57) {
|
|
16
|
+
value2 = value2 * 16 + ch - 48;
|
|
17
|
+
} else if (ch >= 65 && ch <= 70) {
|
|
18
|
+
value2 = value2 * 16 + ch - 65 + 10;
|
|
19
|
+
} else if (ch >= 97 && ch <= 102) {
|
|
20
|
+
value2 = value2 * 16 + ch - 97 + 10;
|
|
21
|
+
} else {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
pos++;
|
|
25
|
+
digits++;
|
|
26
|
+
}
|
|
27
|
+
if (digits < count) {
|
|
28
|
+
value2 = -1;
|
|
29
|
+
}
|
|
30
|
+
return value2;
|
|
31
|
+
}
|
|
32
|
+
function setPosition(newPosition) {
|
|
33
|
+
pos = newPosition;
|
|
34
|
+
value = "";
|
|
35
|
+
tokenOffset = 0;
|
|
36
|
+
token = 16;
|
|
37
|
+
scanError = 0;
|
|
38
|
+
}
|
|
39
|
+
function scanNumber() {
|
|
40
|
+
let start = pos;
|
|
41
|
+
if (text.charCodeAt(pos) === 48) {
|
|
42
|
+
pos++;
|
|
43
|
+
} else {
|
|
44
|
+
pos++;
|
|
45
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
46
|
+
pos++;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (pos < text.length && text.charCodeAt(pos) === 46) {
|
|
50
|
+
pos++;
|
|
51
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
52
|
+
pos++;
|
|
53
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
54
|
+
pos++;
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
scanError = 3;
|
|
58
|
+
return text.substring(start, pos);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
let end = pos;
|
|
62
|
+
if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
|
|
63
|
+
pos++;
|
|
64
|
+
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
|
|
65
|
+
pos++;
|
|
66
|
+
}
|
|
67
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
68
|
+
pos++;
|
|
69
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
70
|
+
pos++;
|
|
71
|
+
}
|
|
72
|
+
end = pos;
|
|
73
|
+
} else {
|
|
74
|
+
scanError = 3;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return text.substring(start, end);
|
|
78
|
+
}
|
|
79
|
+
function scanString() {
|
|
80
|
+
let result = "", start = pos;
|
|
81
|
+
while (true) {
|
|
82
|
+
if (pos >= len) {
|
|
83
|
+
result += text.substring(start, pos);
|
|
84
|
+
scanError = 2;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
const ch = text.charCodeAt(pos);
|
|
88
|
+
if (ch === 34) {
|
|
89
|
+
result += text.substring(start, pos);
|
|
90
|
+
pos++;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (ch === 92) {
|
|
94
|
+
result += text.substring(start, pos);
|
|
95
|
+
pos++;
|
|
96
|
+
if (pos >= len) {
|
|
97
|
+
scanError = 2;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
const ch2 = text.charCodeAt(pos++);
|
|
101
|
+
switch (ch2) {
|
|
102
|
+
case 34:
|
|
103
|
+
result += '"';
|
|
104
|
+
break;
|
|
105
|
+
case 92:
|
|
106
|
+
result += "\\";
|
|
107
|
+
break;
|
|
108
|
+
case 47:
|
|
109
|
+
result += "/";
|
|
110
|
+
break;
|
|
111
|
+
case 98:
|
|
112
|
+
result += "\b";
|
|
113
|
+
break;
|
|
114
|
+
case 102:
|
|
115
|
+
result += "\f";
|
|
116
|
+
break;
|
|
117
|
+
case 110:
|
|
118
|
+
result += `
|
|
119
|
+
`;
|
|
120
|
+
break;
|
|
121
|
+
case 114:
|
|
122
|
+
result += "\r";
|
|
123
|
+
break;
|
|
124
|
+
case 116:
|
|
125
|
+
result += "\t";
|
|
126
|
+
break;
|
|
127
|
+
case 117:
|
|
128
|
+
const ch3 = scanHexDigits(4, true);
|
|
129
|
+
if (ch3 >= 0) {
|
|
130
|
+
result += String.fromCharCode(ch3);
|
|
131
|
+
} else {
|
|
132
|
+
scanError = 4;
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
scanError = 5;
|
|
137
|
+
}
|
|
138
|
+
start = pos;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (ch >= 0 && ch <= 31) {
|
|
142
|
+
if (isLineBreak(ch)) {
|
|
143
|
+
result += text.substring(start, pos);
|
|
144
|
+
scanError = 2;
|
|
145
|
+
break;
|
|
146
|
+
} else {
|
|
147
|
+
scanError = 6;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
pos++;
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
function scanNext() {
|
|
155
|
+
value = "";
|
|
156
|
+
scanError = 0;
|
|
157
|
+
tokenOffset = pos;
|
|
158
|
+
lineStartOffset = lineNumber;
|
|
159
|
+
prevTokenLineStartOffset = tokenLineStartOffset;
|
|
160
|
+
if (pos >= len) {
|
|
161
|
+
tokenOffset = len;
|
|
162
|
+
return token = 17;
|
|
163
|
+
}
|
|
164
|
+
let code = text.charCodeAt(pos);
|
|
165
|
+
if (isWhiteSpace(code)) {
|
|
166
|
+
do {
|
|
167
|
+
pos++;
|
|
168
|
+
value += String.fromCharCode(code);
|
|
169
|
+
code = text.charCodeAt(pos);
|
|
170
|
+
} while (isWhiteSpace(code));
|
|
171
|
+
return token = 15;
|
|
172
|
+
}
|
|
173
|
+
if (isLineBreak(code)) {
|
|
174
|
+
pos++;
|
|
175
|
+
value += String.fromCharCode(code);
|
|
176
|
+
if (code === 13 && text.charCodeAt(pos) === 10) {
|
|
177
|
+
pos++;
|
|
178
|
+
value += `
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
lineNumber++;
|
|
182
|
+
tokenLineStartOffset = pos;
|
|
183
|
+
return token = 14;
|
|
184
|
+
}
|
|
185
|
+
switch (code) {
|
|
186
|
+
case 123:
|
|
187
|
+
pos++;
|
|
188
|
+
return token = 1;
|
|
189
|
+
case 125:
|
|
190
|
+
pos++;
|
|
191
|
+
return token = 2;
|
|
192
|
+
case 91:
|
|
193
|
+
pos++;
|
|
194
|
+
return token = 3;
|
|
195
|
+
case 93:
|
|
196
|
+
pos++;
|
|
197
|
+
return token = 4;
|
|
198
|
+
case 58:
|
|
199
|
+
pos++;
|
|
200
|
+
return token = 6;
|
|
201
|
+
case 44:
|
|
202
|
+
pos++;
|
|
203
|
+
return token = 5;
|
|
204
|
+
case 34:
|
|
205
|
+
pos++;
|
|
206
|
+
value = scanString();
|
|
207
|
+
return token = 10;
|
|
208
|
+
case 47:
|
|
209
|
+
const start = pos - 1;
|
|
210
|
+
if (text.charCodeAt(pos + 1) === 47) {
|
|
211
|
+
pos += 2;
|
|
212
|
+
while (pos < len) {
|
|
213
|
+
if (isLineBreak(text.charCodeAt(pos))) {
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
pos++;
|
|
217
|
+
}
|
|
218
|
+
value = text.substring(start, pos);
|
|
219
|
+
return token = 12;
|
|
220
|
+
}
|
|
221
|
+
if (text.charCodeAt(pos + 1) === 42) {
|
|
222
|
+
pos += 2;
|
|
223
|
+
const safeLength = len - 1;
|
|
224
|
+
let commentClosed = false;
|
|
225
|
+
while (pos < safeLength) {
|
|
226
|
+
const ch = text.charCodeAt(pos);
|
|
227
|
+
if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
|
|
228
|
+
pos += 2;
|
|
229
|
+
commentClosed = true;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
pos++;
|
|
233
|
+
if (isLineBreak(ch)) {
|
|
234
|
+
if (ch === 13 && text.charCodeAt(pos) === 10) {
|
|
235
|
+
pos++;
|
|
236
|
+
}
|
|
237
|
+
lineNumber++;
|
|
238
|
+
tokenLineStartOffset = pos;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (!commentClosed) {
|
|
242
|
+
pos++;
|
|
243
|
+
scanError = 1;
|
|
244
|
+
}
|
|
245
|
+
value = text.substring(start, pos);
|
|
246
|
+
return token = 13;
|
|
247
|
+
}
|
|
248
|
+
value += String.fromCharCode(code);
|
|
249
|
+
pos++;
|
|
250
|
+
return token = 16;
|
|
251
|
+
case 45:
|
|
252
|
+
value += String.fromCharCode(code);
|
|
253
|
+
pos++;
|
|
254
|
+
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
255
|
+
return token = 16;
|
|
256
|
+
}
|
|
257
|
+
case 48:
|
|
258
|
+
case 49:
|
|
259
|
+
case 50:
|
|
260
|
+
case 51:
|
|
261
|
+
case 52:
|
|
262
|
+
case 53:
|
|
263
|
+
case 54:
|
|
264
|
+
case 55:
|
|
265
|
+
case 56:
|
|
266
|
+
case 57:
|
|
267
|
+
value += scanNumber();
|
|
268
|
+
return token = 11;
|
|
269
|
+
default:
|
|
270
|
+
while (pos < len && isUnknownContentCharacter(code)) {
|
|
271
|
+
pos++;
|
|
272
|
+
code = text.charCodeAt(pos);
|
|
273
|
+
}
|
|
274
|
+
if (tokenOffset !== pos) {
|
|
275
|
+
value = text.substring(tokenOffset, pos);
|
|
276
|
+
switch (value) {
|
|
277
|
+
case "true":
|
|
278
|
+
return token = 8;
|
|
279
|
+
case "false":
|
|
280
|
+
return token = 9;
|
|
281
|
+
case "null":
|
|
282
|
+
return token = 7;
|
|
283
|
+
}
|
|
284
|
+
return token = 16;
|
|
285
|
+
}
|
|
286
|
+
value += String.fromCharCode(code);
|
|
287
|
+
pos++;
|
|
288
|
+
return token = 16;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function isUnknownContentCharacter(code) {
|
|
292
|
+
if (isWhiteSpace(code) || isLineBreak(code)) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
switch (code) {
|
|
296
|
+
case 125:
|
|
297
|
+
case 93:
|
|
298
|
+
case 123:
|
|
299
|
+
case 91:
|
|
300
|
+
case 34:
|
|
301
|
+
case 58:
|
|
302
|
+
case 44:
|
|
303
|
+
case 47:
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
function scanNextNonTrivia() {
|
|
309
|
+
let result;
|
|
310
|
+
do {
|
|
311
|
+
result = scanNext();
|
|
312
|
+
} while (result >= 12 && result <= 15);
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
setPosition,
|
|
317
|
+
getPosition: () => pos,
|
|
318
|
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
319
|
+
getToken: () => token,
|
|
320
|
+
getTokenValue: () => value,
|
|
321
|
+
getTokenOffset: () => tokenOffset,
|
|
322
|
+
getTokenLength: () => pos - tokenOffset,
|
|
323
|
+
getTokenStartLine: () => lineStartOffset,
|
|
324
|
+
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
|
325
|
+
getTokenError: () => scanError
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function isWhiteSpace(ch) {
|
|
329
|
+
return ch === 32 || ch === 9;
|
|
330
|
+
}
|
|
331
|
+
function isLineBreak(ch) {
|
|
332
|
+
return ch === 10 || ch === 13;
|
|
333
|
+
}
|
|
334
|
+
function isDigit(ch) {
|
|
335
|
+
return ch >= 48 && ch <= 57;
|
|
336
|
+
}
|
|
337
|
+
var CharacterCodes;
|
|
338
|
+
(function(CharacterCodes2) {
|
|
339
|
+
CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
|
|
340
|
+
CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
|
|
341
|
+
CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
|
|
342
|
+
CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
|
|
343
|
+
CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
|
|
344
|
+
CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
|
|
345
|
+
CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
|
|
346
|
+
CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
|
|
347
|
+
CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
|
|
348
|
+
CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
|
|
349
|
+
CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
|
|
350
|
+
CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
|
|
351
|
+
CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
|
|
352
|
+
CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
|
|
353
|
+
CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
|
|
354
|
+
CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
|
|
355
|
+
CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
|
|
356
|
+
CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
|
|
357
|
+
CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
|
|
358
|
+
CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
|
|
359
|
+
CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
|
|
360
|
+
CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
|
|
361
|
+
CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
|
|
362
|
+
CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
|
|
363
|
+
CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
|
|
364
|
+
CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
|
|
365
|
+
CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
|
|
366
|
+
CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
|
|
367
|
+
CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
|
|
368
|
+
CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
|
|
369
|
+
CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
|
|
370
|
+
CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
|
|
371
|
+
CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
|
|
372
|
+
CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
|
|
373
|
+
CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
|
|
374
|
+
CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
|
|
375
|
+
CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
|
|
376
|
+
CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
|
|
377
|
+
CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
|
|
378
|
+
CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
|
|
379
|
+
CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
|
|
380
|
+
CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
|
|
381
|
+
CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
|
|
382
|
+
CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
|
|
383
|
+
CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
|
|
384
|
+
CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
|
|
385
|
+
CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
|
|
386
|
+
CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
|
|
387
|
+
CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
|
|
388
|
+
CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
|
|
389
|
+
CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
|
|
390
|
+
CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
|
|
391
|
+
CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
|
|
392
|
+
CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
|
|
393
|
+
CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
|
|
394
|
+
CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
|
|
395
|
+
CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
|
|
396
|
+
CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
|
|
397
|
+
CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
|
|
398
|
+
CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
|
|
399
|
+
CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
|
|
400
|
+
CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
|
|
401
|
+
CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
|
|
402
|
+
CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
|
|
403
|
+
CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
|
|
404
|
+
CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
|
|
405
|
+
CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
|
|
406
|
+
CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
|
|
407
|
+
CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
|
|
408
|
+
CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
|
|
409
|
+
CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
|
|
410
|
+
CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
|
|
411
|
+
CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
|
|
412
|
+
CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
|
|
413
|
+
CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
|
|
414
|
+
CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
|
|
415
|
+
CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
|
|
416
|
+
CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
|
|
417
|
+
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
|
|
418
|
+
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
|
|
419
|
+
})(CharacterCodes || (CharacterCodes = {}));
|
|
420
|
+
|
|
421
|
+
// node_modules/jsonc-parser/lib/esm/impl/string-intern.js
|
|
422
|
+
var cachedSpaces = new Array(20).fill(0).map((_, index) => {
|
|
423
|
+
return " ".repeat(index);
|
|
424
|
+
});
|
|
425
|
+
var maxCachedValues = 200;
|
|
426
|
+
var cachedBreakLinesWithSpaces = {
|
|
427
|
+
" ": {
|
|
428
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
429
|
+
return `
|
|
430
|
+
` + " ".repeat(index);
|
|
431
|
+
}),
|
|
432
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
433
|
+
return "\r" + " ".repeat(index);
|
|
434
|
+
}),
|
|
435
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
436
|
+
return `\r
|
|
437
|
+
` + " ".repeat(index);
|
|
438
|
+
})
|
|
439
|
+
},
|
|
440
|
+
"\t": {
|
|
441
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
442
|
+
return `
|
|
443
|
+
` + "\t".repeat(index);
|
|
444
|
+
}),
|
|
445
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
446
|
+
return "\r" + "\t".repeat(index);
|
|
447
|
+
}),
|
|
448
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
449
|
+
return `\r
|
|
450
|
+
` + "\t".repeat(index);
|
|
451
|
+
})
|
|
452
|
+
}
|
|
17
453
|
};
|
|
18
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
20
454
|
|
|
21
|
-
// node_modules/jsonc-parser/lib/
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
455
|
+
// node_modules/jsonc-parser/lib/esm/impl/parser.js
|
|
456
|
+
var ParseOptions;
|
|
457
|
+
(function(ParseOptions2) {
|
|
458
|
+
ParseOptions2.DEFAULT = {
|
|
459
|
+
allowTrailingComma: false
|
|
460
|
+
};
|
|
461
|
+
})(ParseOptions || (ParseOptions = {}));
|
|
462
|
+
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
463
|
+
let currentProperty = null;
|
|
464
|
+
let currentParent = [];
|
|
465
|
+
const previousParents = [];
|
|
466
|
+
function onValue(value) {
|
|
467
|
+
if (Array.isArray(currentParent)) {
|
|
468
|
+
currentParent.push(value);
|
|
469
|
+
} else if (currentProperty !== null) {
|
|
470
|
+
currentParent[currentProperty] = value;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
const visitor = {
|
|
474
|
+
onObjectBegin: () => {
|
|
475
|
+
const object = {};
|
|
476
|
+
onValue(object);
|
|
477
|
+
previousParents.push(currentParent);
|
|
478
|
+
currentParent = object;
|
|
479
|
+
currentProperty = null;
|
|
480
|
+
},
|
|
481
|
+
onObjectProperty: (name) => {
|
|
482
|
+
currentProperty = name;
|
|
483
|
+
},
|
|
484
|
+
onObjectEnd: () => {
|
|
485
|
+
currentParent = previousParents.pop();
|
|
486
|
+
},
|
|
487
|
+
onArrayBegin: () => {
|
|
488
|
+
const array = [];
|
|
489
|
+
onValue(array);
|
|
490
|
+
previousParents.push(currentParent);
|
|
491
|
+
currentParent = array;
|
|
492
|
+
currentProperty = null;
|
|
493
|
+
},
|
|
494
|
+
onArrayEnd: () => {
|
|
495
|
+
currentParent = previousParents.pop();
|
|
496
|
+
},
|
|
497
|
+
onLiteralValue: onValue,
|
|
498
|
+
onError: (error, offset, length) => {
|
|
499
|
+
errors.push({ error, offset, length });
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
visit(text, visitor, options);
|
|
503
|
+
return currentParent[0];
|
|
504
|
+
}
|
|
505
|
+
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
506
|
+
const _scanner = createScanner(text, false);
|
|
507
|
+
const _jsonPath = [];
|
|
508
|
+
let suppressedCallbacks = 0;
|
|
509
|
+
function toNoArgVisit(visitFunction) {
|
|
510
|
+
return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
511
|
+
}
|
|
512
|
+
function toOneArgVisit(visitFunction) {
|
|
513
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
514
|
+
}
|
|
515
|
+
function toOneArgVisitWithPath(visitFunction) {
|
|
516
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
517
|
+
}
|
|
518
|
+
function toBeginVisit(visitFunction) {
|
|
519
|
+
return visitFunction ? () => {
|
|
520
|
+
if (suppressedCallbacks > 0) {
|
|
521
|
+
suppressedCallbacks++;
|
|
522
|
+
} else {
|
|
523
|
+
let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
|
|
524
|
+
if (cbReturn === false) {
|
|
525
|
+
suppressedCallbacks = 1;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
} : () => true;
|
|
529
|
+
}
|
|
530
|
+
function toEndVisit(visitFunction) {
|
|
531
|
+
return visitFunction ? () => {
|
|
532
|
+
if (suppressedCallbacks > 0) {
|
|
533
|
+
suppressedCallbacks--;
|
|
534
|
+
}
|
|
535
|
+
if (suppressedCallbacks === 0) {
|
|
536
|
+
visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
|
|
537
|
+
}
|
|
538
|
+
} : () => true;
|
|
539
|
+
}
|
|
540
|
+
const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
541
|
+
const disallowComments = options && options.disallowComments;
|
|
542
|
+
const allowTrailingComma = options && options.allowTrailingComma;
|
|
543
|
+
function scanNext() {
|
|
544
|
+
while (true) {
|
|
545
|
+
const token = _scanner.scan();
|
|
546
|
+
switch (_scanner.getTokenError()) {
|
|
105
547
|
case 4:
|
|
106
|
-
|
|
548
|
+
handleError(14);
|
|
549
|
+
break;
|
|
107
550
|
case 5:
|
|
108
|
-
|
|
551
|
+
handleError(15);
|
|
552
|
+
break;
|
|
553
|
+
case 3:
|
|
554
|
+
handleError(13);
|
|
555
|
+
break;
|
|
556
|
+
case 1:
|
|
557
|
+
if (!disallowComments) {
|
|
558
|
+
handleError(11);
|
|
559
|
+
}
|
|
560
|
+
break;
|
|
561
|
+
case 2:
|
|
562
|
+
handleError(12);
|
|
563
|
+
break;
|
|
109
564
|
case 6:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return "CloseBracketExpected";
|
|
115
|
-
case 9:
|
|
116
|
-
return "EndOfFileExpected";
|
|
117
|
-
case 10:
|
|
118
|
-
return "InvalidCommentToken";
|
|
119
|
-
case 11:
|
|
120
|
-
return "UnexpectedEndOfComment";
|
|
565
|
+
handleError(16);
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
switch (token) {
|
|
121
569
|
case 12:
|
|
122
|
-
return "UnexpectedEndOfString";
|
|
123
570
|
case 13:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
571
|
+
if (disallowComments) {
|
|
572
|
+
handleError(10);
|
|
573
|
+
} else {
|
|
574
|
+
onComment();
|
|
575
|
+
}
|
|
576
|
+
break;
|
|
129
577
|
case 16:
|
|
130
|
-
|
|
578
|
+
handleError(1);
|
|
579
|
+
break;
|
|
580
|
+
case 15:
|
|
581
|
+
case 14:
|
|
582
|
+
break;
|
|
583
|
+
default:
|
|
584
|
+
return token;
|
|
131
585
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
let sortedEdits = edits.slice(0).sort((a, b) => {
|
|
145
|
-
const diff = a.offset - b.offset;
|
|
146
|
-
if (diff === 0) {
|
|
147
|
-
return a.length - b.length;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
589
|
+
onError(error);
|
|
590
|
+
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
591
|
+
let token = _scanner.getToken();
|
|
592
|
+
while (token !== 17) {
|
|
593
|
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
594
|
+
scanNext();
|
|
595
|
+
break;
|
|
596
|
+
} else if (skipUntil.indexOf(token) !== -1) {
|
|
597
|
+
break;
|
|
148
598
|
}
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
599
|
+
token = scanNext();
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
function parseString(isValue) {
|
|
604
|
+
const value = _scanner.getTokenValue();
|
|
605
|
+
if (isValue) {
|
|
606
|
+
onLiteralValue(value);
|
|
607
|
+
} else {
|
|
608
|
+
onObjectProperty(value);
|
|
609
|
+
_jsonPath.push(value);
|
|
610
|
+
}
|
|
611
|
+
scanNext();
|
|
612
|
+
return true;
|
|
613
|
+
}
|
|
614
|
+
function parseLiteral() {
|
|
615
|
+
switch (_scanner.getToken()) {
|
|
616
|
+
case 11:
|
|
617
|
+
const tokenValue = _scanner.getTokenValue();
|
|
618
|
+
let value = Number(tokenValue);
|
|
619
|
+
if (isNaN(value)) {
|
|
620
|
+
handleError(2);
|
|
621
|
+
value = 0;
|
|
158
622
|
}
|
|
159
|
-
|
|
623
|
+
onLiteralValue(value);
|
|
624
|
+
break;
|
|
625
|
+
case 7:
|
|
626
|
+
onLiteralValue(null);
|
|
627
|
+
break;
|
|
628
|
+
case 8:
|
|
629
|
+
onLiteralValue(true);
|
|
630
|
+
break;
|
|
631
|
+
case 9:
|
|
632
|
+
onLiteralValue(false);
|
|
633
|
+
break;
|
|
634
|
+
default:
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
scanNext();
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
640
|
+
function parseProperty() {
|
|
641
|
+
if (_scanner.getToken() !== 10) {
|
|
642
|
+
handleError(3, [], [2, 5]);
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
parseString(false);
|
|
646
|
+
if (_scanner.getToken() === 6) {
|
|
647
|
+
onSeparator(":");
|
|
648
|
+
scanNext();
|
|
649
|
+
if (!parseValue()) {
|
|
650
|
+
handleError(4, [], [2, 5]);
|
|
160
651
|
}
|
|
161
|
-
|
|
652
|
+
} else {
|
|
653
|
+
handleError(5, [], [2, 5]);
|
|
162
654
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (!line || line.startsWith("#"))
|
|
188
|
-
continue;
|
|
189
|
-
while (line.endsWith("\\") && i < lines.length) {
|
|
190
|
-
line = line.slice(0, -1) + lines[i];
|
|
191
|
-
i++;
|
|
655
|
+
_jsonPath.pop();
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
function parseObject() {
|
|
659
|
+
onObjectBegin();
|
|
660
|
+
scanNext();
|
|
661
|
+
let needsComma = false;
|
|
662
|
+
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
|
|
663
|
+
if (_scanner.getToken() === 5) {
|
|
664
|
+
if (!needsComma) {
|
|
665
|
+
handleError(4, [], []);
|
|
666
|
+
}
|
|
667
|
+
onSeparator(",");
|
|
668
|
+
scanNext();
|
|
669
|
+
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
} else if (needsComma) {
|
|
673
|
+
handleError(6, [], []);
|
|
674
|
+
}
|
|
675
|
+
if (!parseProperty()) {
|
|
676
|
+
handleError(4, [], [2, 5]);
|
|
677
|
+
}
|
|
678
|
+
needsComma = true;
|
|
192
679
|
}
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
|
|
680
|
+
onObjectEnd();
|
|
681
|
+
if (_scanner.getToken() !== 2) {
|
|
682
|
+
handleError(7, [2], []);
|
|
683
|
+
} else {
|
|
684
|
+
scanNext();
|
|
196
685
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
686
|
+
return true;
|
|
687
|
+
}
|
|
688
|
+
function parseArray() {
|
|
689
|
+
onArrayBegin();
|
|
690
|
+
scanNext();
|
|
691
|
+
let isFirstElement = true;
|
|
692
|
+
let needsComma = false;
|
|
693
|
+
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
|
|
694
|
+
if (_scanner.getToken() === 5) {
|
|
695
|
+
if (!needsComma) {
|
|
696
|
+
handleError(4, [], []);
|
|
697
|
+
}
|
|
698
|
+
onSeparator(",");
|
|
699
|
+
scanNext();
|
|
700
|
+
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
} else if (needsComma) {
|
|
704
|
+
handleError(6, [], []);
|
|
705
|
+
}
|
|
706
|
+
if (isFirstElement) {
|
|
707
|
+
_jsonPath.push(0);
|
|
708
|
+
isFirstElement = false;
|
|
709
|
+
} else {
|
|
710
|
+
_jsonPath[_jsonPath.length - 1]++;
|
|
711
|
+
}
|
|
712
|
+
if (!parseValue()) {
|
|
713
|
+
handleError(4, [], [4, 5]);
|
|
714
|
+
}
|
|
715
|
+
needsComma = true;
|
|
204
716
|
}
|
|
717
|
+
onArrayEnd();
|
|
718
|
+
if (!isFirstElement) {
|
|
719
|
+
_jsonPath.pop();
|
|
720
|
+
}
|
|
721
|
+
if (_scanner.getToken() !== 4) {
|
|
722
|
+
handleError(8, [4], []);
|
|
723
|
+
} else {
|
|
724
|
+
scanNext();
|
|
725
|
+
}
|
|
726
|
+
return true;
|
|
205
727
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return value.replace(/\\n/g, `
|
|
217
|
-
`).replace(/\\r/g, "\r").replace(/\\t/g, "\t").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
218
|
-
}
|
|
219
|
-
return value;
|
|
220
|
-
}
|
|
221
|
-
if (value.startsWith("'")) {
|
|
222
|
-
const endQuote = findClosingQuote(value, "'");
|
|
223
|
-
if (endQuote !== -1) {
|
|
224
|
-
return value.substring(1, endQuote);
|
|
225
|
-
}
|
|
226
|
-
return value;
|
|
227
|
-
}
|
|
228
|
-
const inlineCommentIndex = value.indexOf(" #");
|
|
229
|
-
if (inlineCommentIndex !== -1) {
|
|
230
|
-
value = value.substring(0, inlineCommentIndex);
|
|
231
|
-
}
|
|
232
|
-
return value.trim();
|
|
233
|
-
}
|
|
234
|
-
function findClosingQuote(str, quote) {
|
|
235
|
-
let i = 1;
|
|
236
|
-
while (i < str.length) {
|
|
237
|
-
if (str[i] === "\\" && i + 1 < str.length) {
|
|
238
|
-
i += 2;
|
|
239
|
-
continue;
|
|
728
|
+
function parseValue() {
|
|
729
|
+
switch (_scanner.getToken()) {
|
|
730
|
+
case 3:
|
|
731
|
+
return parseArray();
|
|
732
|
+
case 1:
|
|
733
|
+
return parseObject();
|
|
734
|
+
case 10:
|
|
735
|
+
return parseString(true);
|
|
736
|
+
default:
|
|
737
|
+
return parseLiteral();
|
|
240
738
|
}
|
|
241
|
-
|
|
242
|
-
|
|
739
|
+
}
|
|
740
|
+
scanNext();
|
|
741
|
+
if (_scanner.getToken() === 17) {
|
|
742
|
+
if (options.allowEmptyContent) {
|
|
743
|
+
return true;
|
|
243
744
|
}
|
|
244
|
-
|
|
745
|
+
handleError(4, [], []);
|
|
746
|
+
return false;
|
|
747
|
+
}
|
|
748
|
+
if (!parseValue()) {
|
|
749
|
+
handleError(4, [], []);
|
|
750
|
+
return false;
|
|
751
|
+
}
|
|
752
|
+
if (_scanner.getToken() !== 17) {
|
|
753
|
+
handleError(9, [], []);
|
|
245
754
|
}
|
|
246
|
-
return
|
|
755
|
+
return true;
|
|
247
756
|
}
|
|
248
|
-
|
|
249
|
-
|
|
757
|
+
|
|
758
|
+
// node_modules/jsonc-parser/lib/esm/main.js
|
|
759
|
+
var ScanError;
|
|
760
|
+
(function(ScanError2) {
|
|
761
|
+
ScanError2[ScanError2["None"] = 0] = "None";
|
|
762
|
+
ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
|
763
|
+
ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
|
764
|
+
ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
|
765
|
+
ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
|
|
766
|
+
ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
|
767
|
+
ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
|
|
768
|
+
})(ScanError || (ScanError = {}));
|
|
769
|
+
var SyntaxKind;
|
|
770
|
+
(function(SyntaxKind2) {
|
|
771
|
+
SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
|
|
772
|
+
SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
|
|
773
|
+
SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
|
|
774
|
+
SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
|
|
775
|
+
SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
|
|
776
|
+
SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
|
|
777
|
+
SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
|
|
778
|
+
SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
|
|
779
|
+
SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
|
|
780
|
+
SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
|
|
781
|
+
SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
|
|
782
|
+
SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
|
783
|
+
SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
|
784
|
+
SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
|
785
|
+
SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
|
|
786
|
+
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
|
|
787
|
+
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
|
|
788
|
+
})(SyntaxKind || (SyntaxKind = {}));
|
|
789
|
+
var parse2 = parse;
|
|
790
|
+
var ParseErrorCode;
|
|
791
|
+
(function(ParseErrorCode2) {
|
|
792
|
+
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
793
|
+
ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
|
794
|
+
ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
|
795
|
+
ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
|
|
796
|
+
ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
|
|
797
|
+
ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
|
|
798
|
+
ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
|
799
|
+
ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
|
800
|
+
ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
|
801
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
|
802
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
|
803
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
|
804
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
|
805
|
+
ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
|
|
806
|
+
ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
|
807
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
808
|
+
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
809
|
+
|
|
810
|
+
// src/profiler/profiler.ts
|
|
811
|
+
function percentile(sorted, p) {
|
|
812
|
+
if (sorted.length === 0)
|
|
813
|
+
return 0;
|
|
814
|
+
const index = Math.ceil(p / 100 * sorted.length) - 1;
|
|
815
|
+
return sorted[Math.max(0, index)];
|
|
250
816
|
}
|
|
251
|
-
function
|
|
252
|
-
if (
|
|
817
|
+
function calculateStats(measurements) {
|
|
818
|
+
if (measurements.length === 0)
|
|
253
819
|
return null;
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
820
|
+
const sorted = [...measurements].sort((a, b) => a - b);
|
|
821
|
+
const total = sorted.reduce((sum, v) => sum + v, 0);
|
|
822
|
+
return {
|
|
823
|
+
count: sorted.length,
|
|
824
|
+
min: sorted[0],
|
|
825
|
+
max: sorted[sorted.length - 1],
|
|
826
|
+
avg: total / sorted.length,
|
|
827
|
+
p50: percentile(sorted, 50),
|
|
828
|
+
p95: percentile(sorted, 95),
|
|
829
|
+
p99: percentile(sorted, 99),
|
|
830
|
+
total
|
|
831
|
+
};
|
|
262
832
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
833
|
+
|
|
834
|
+
class Profiler {
|
|
835
|
+
marks = new Map;
|
|
836
|
+
measures = new Map;
|
|
837
|
+
fileMetrics = [];
|
|
838
|
+
initStartTime = null;
|
|
839
|
+
initEndTime = null;
|
|
840
|
+
initState = "idle";
|
|
841
|
+
configLoadTime = null;
|
|
842
|
+
configPath = null;
|
|
843
|
+
totalVars = 0;
|
|
844
|
+
startTime = performance.now();
|
|
845
|
+
mark(name) {
|
|
846
|
+
this.marks.set(name, performance.now());
|
|
847
|
+
}
|
|
848
|
+
measure(name, startMark) {
|
|
849
|
+
const start = this.marks.get(startMark);
|
|
850
|
+
if (start === undefined) {
|
|
851
|
+
return -1;
|
|
852
|
+
}
|
|
853
|
+
const duration = performance.now() - start;
|
|
854
|
+
const existing = this.measures.get(name) || [];
|
|
855
|
+
existing.push(duration);
|
|
856
|
+
this.measures.set(name, existing);
|
|
857
|
+
return duration;
|
|
858
|
+
}
|
|
859
|
+
record(name, duration) {
|
|
860
|
+
const existing = this.measures.get(name) || [];
|
|
861
|
+
existing.push(duration);
|
|
862
|
+
this.measures.set(name, existing);
|
|
863
|
+
}
|
|
864
|
+
getStats(name) {
|
|
865
|
+
const measurements = this.measures.get(name);
|
|
866
|
+
if (!measurements)
|
|
867
|
+
return null;
|
|
868
|
+
return calculateStats(measurements);
|
|
869
|
+
}
|
|
870
|
+
initStart() {
|
|
871
|
+
this.initStartTime = performance.now();
|
|
872
|
+
this.initState = "loading";
|
|
873
|
+
}
|
|
874
|
+
initComplete(state) {
|
|
875
|
+
this.initEndTime = performance.now();
|
|
876
|
+
this.initState = state;
|
|
877
|
+
}
|
|
878
|
+
recordConfigLoad(duration, path) {
|
|
879
|
+
this.configLoadTime = duration;
|
|
880
|
+
this.configPath = path;
|
|
881
|
+
}
|
|
882
|
+
recordFileLoad(path, duration, varCount, success, error) {
|
|
883
|
+
this.fileMetrics.push({
|
|
884
|
+
path,
|
|
885
|
+
duration,
|
|
886
|
+
varCount,
|
|
887
|
+
success,
|
|
888
|
+
error
|
|
889
|
+
});
|
|
890
|
+
if (success) {
|
|
891
|
+
this.totalVars += varCount;
|
|
892
|
+
this.record("file.load", duration);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
getInitState() {
|
|
896
|
+
return this.initState;
|
|
897
|
+
}
|
|
898
|
+
getInitDuration() {
|
|
899
|
+
if (this.initStartTime === null)
|
|
900
|
+
return null;
|
|
901
|
+
if (this.initEndTime !== null) {
|
|
902
|
+
return this.initEndTime - this.initStartTime;
|
|
903
|
+
}
|
|
904
|
+
return performance.now() - this.initStartTime;
|
|
905
|
+
}
|
|
906
|
+
getTotalVars() {
|
|
907
|
+
return this.totalVars;
|
|
908
|
+
}
|
|
909
|
+
getFileMetrics() {
|
|
910
|
+
return [...this.fileMetrics];
|
|
911
|
+
}
|
|
912
|
+
export() {
|
|
913
|
+
return {
|
|
914
|
+
timestamp: new Date().toISOString(),
|
|
915
|
+
uptime: performance.now() - this.startTime,
|
|
916
|
+
initialization: {
|
|
917
|
+
startTime: this.initStartTime || 0,
|
|
918
|
+
endTime: this.initEndTime,
|
|
919
|
+
duration: this.getInitDuration(),
|
|
920
|
+
state: this.initState
|
|
921
|
+
},
|
|
922
|
+
config: {
|
|
923
|
+
loadTime: this.configLoadTime,
|
|
924
|
+
path: this.configPath
|
|
925
|
+
},
|
|
926
|
+
files: {
|
|
927
|
+
loadTimes: this.getStats("file.load"),
|
|
928
|
+
details: this.fileMetrics,
|
|
929
|
+
totalVars: this.totalVars
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
reset() {
|
|
934
|
+
this.marks.clear();
|
|
935
|
+
this.measures.clear();
|
|
936
|
+
this.fileMetrics = [];
|
|
937
|
+
this.initStartTime = null;
|
|
938
|
+
this.initEndTime = null;
|
|
939
|
+
this.initState = "idle";
|
|
940
|
+
this.configLoadTime = null;
|
|
941
|
+
this.configPath = null;
|
|
942
|
+
this.totalVars = 0;
|
|
943
|
+
}
|
|
944
|
+
startTimer(name) {
|
|
945
|
+
const start = performance.now();
|
|
946
|
+
return () => {
|
|
947
|
+
const duration = performance.now() - start;
|
|
948
|
+
this.record(name, duration);
|
|
949
|
+
return duration;
|
|
950
|
+
};
|
|
274
951
|
}
|
|
275
952
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
953
|
+
var globalProfiler = new Profiler;
|
|
954
|
+
// src/plugin.ts
|
|
955
|
+
var CONFIG_NAME = "dotenv.jsonc";
|
|
956
|
+
var LOG_DIR = `${homedir()}/.local/share/opencode`;
|
|
957
|
+
var LOG_FILE = `${LOG_DIR}/dotenv.log`;
|
|
958
|
+
var LOAD_GUARD = "__opencodeDotenvLoaded";
|
|
959
|
+
var isTestEnv = !!process.env.BUN_TEST;
|
|
960
|
+
var loggingEnabled = false;
|
|
961
|
+
function log(message) {
|
|
962
|
+
if (!loggingEnabled || isTestEnv)
|
|
279
963
|
return;
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
`) + `
|
|
964
|
+
const timestamp = new Date().toISOString();
|
|
965
|
+
const line = `[${timestamp}] ${message}
|
|
283
966
|
`;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
967
|
+
mkdir(LOG_DIR, { recursive: true }).then(() => appendFile(LOG_FILE, line)).catch(() => {});
|
|
968
|
+
}
|
|
969
|
+
function parseDotenv(content) {
|
|
970
|
+
const result = {};
|
|
971
|
+
if (typeof content !== "string")
|
|
972
|
+
return result;
|
|
973
|
+
for (const line of content.split(`
|
|
974
|
+
`)) {
|
|
975
|
+
const trimmed = line.trim();
|
|
976
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
977
|
+
continue;
|
|
978
|
+
const match = trimmed.match(/^export\s+([^=]+)=(.*)$/);
|
|
979
|
+
const key = match ? match[1] : trimmed.split("=")[0];
|
|
980
|
+
if (!key)
|
|
981
|
+
continue;
|
|
982
|
+
const value = match ? match[2] : trimmed.substring(key.length + 1);
|
|
983
|
+
if (value === undefined)
|
|
984
|
+
continue;
|
|
985
|
+
let parsedValue = value.trim();
|
|
986
|
+
if (!parsedValue.startsWith('"') && !parsedValue.startsWith("'")) {
|
|
987
|
+
const inlineCommentIndex = parsedValue.indexOf(" #");
|
|
988
|
+
if (inlineCommentIndex !== -1) {
|
|
989
|
+
parsedValue = parsedValue.substring(0, inlineCommentIndex).trim();
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
if (parsedValue.startsWith('"') && parsedValue.endsWith('"') || parsedValue.startsWith("'") && parsedValue.endsWith("'")) {
|
|
993
|
+
parsedValue = parsedValue.slice(1, -1);
|
|
994
|
+
}
|
|
995
|
+
result[key.trim()] = parsedValue;
|
|
292
996
|
}
|
|
997
|
+
return result;
|
|
998
|
+
}
|
|
999
|
+
function expandPath(path) {
|
|
1000
|
+
return path.replace(/^~/, homedir());
|
|
293
1001
|
}
|
|
294
1002
|
async function loadConfig() {
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
1003
|
+
const timer = globalProfiler.startTimer("config.load");
|
|
1004
|
+
const configPaths = [
|
|
1005
|
+
`${process.cwd()}/${CONFIG_NAME}`,
|
|
1006
|
+
`${homedir()}/.config/opencode/${CONFIG_NAME}`
|
|
1007
|
+
];
|
|
1008
|
+
for (const configPath of configPaths) {
|
|
1009
|
+
try {
|
|
1010
|
+
const file = Bun.file(configPath);
|
|
299
1011
|
const content = await file.text();
|
|
300
|
-
|
|
1012
|
+
if (!content || typeof content !== "string") {
|
|
1013
|
+
continue;
|
|
1014
|
+
}
|
|
1015
|
+
const config = parse2(content, [], {
|
|
301
1016
|
allowTrailingComma: true
|
|
302
1017
|
});
|
|
303
|
-
if (
|
|
304
|
-
|
|
305
|
-
|
|
1018
|
+
if (config && typeof config === "object" && Array.isArray(config.files)) {
|
|
1019
|
+
loggingEnabled = config.logging?.enabled === true;
|
|
1020
|
+
const duration = timer();
|
|
1021
|
+
globalProfiler.recordConfigLoad(duration, configPath);
|
|
1022
|
+
return { config, path: configPath };
|
|
306
1023
|
}
|
|
307
|
-
|
|
308
|
-
return config;
|
|
309
|
-
}
|
|
310
|
-
} catch (e) {
|
|
311
|
-
logToFile(`Failed to load config: ${e}`);
|
|
1024
|
+
} catch {}
|
|
312
1025
|
}
|
|
313
|
-
|
|
1026
|
+
timer();
|
|
1027
|
+
return { config: { files: [], load_cwd_env: true }, path: null };
|
|
314
1028
|
}
|
|
315
|
-
async function loadDotenvFile(filePath
|
|
1029
|
+
async function loadDotenvFile(filePath) {
|
|
1030
|
+
const start = performance.now();
|
|
316
1031
|
try {
|
|
317
1032
|
const file = Bun.file(filePath);
|
|
318
|
-
|
|
319
|
-
|
|
1033
|
+
const content = await file.text();
|
|
1034
|
+
if (typeof content !== "string" || !content) {
|
|
1035
|
+
const duration2 = performance.now() - start;
|
|
1036
|
+
globalProfiler.recordFileLoad(filePath, duration2, 0, false, "Empty or invalid content");
|
|
1037
|
+
log(`Invalid or empty content from ${filePath}`);
|
|
320
1038
|
return { count: 0, success: false };
|
|
321
1039
|
}
|
|
322
|
-
const content = await file.text();
|
|
323
1040
|
const envVars = parseDotenv(content);
|
|
1041
|
+
const count = Object.keys(envVars).length;
|
|
324
1042
|
for (const [key, value] of Object.entries(envVars)) {
|
|
325
|
-
|
|
326
|
-
process.env[envKey] = value;
|
|
1043
|
+
process.env[key] = value;
|
|
327
1044
|
}
|
|
328
|
-
|
|
1045
|
+
const duration = performance.now() - start;
|
|
1046
|
+
globalProfiler.recordFileLoad(filePath, duration, count, true);
|
|
1047
|
+
return { count, success: true };
|
|
329
1048
|
} catch (error) {
|
|
330
|
-
|
|
1049
|
+
const duration = performance.now() - start;
|
|
1050
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
1051
|
+
globalProfiler.recordFileLoad(filePath, duration, 0, false, errorMsg);
|
|
1052
|
+
log(`Failed to load ${filePath}: ${errorMsg}`);
|
|
331
1053
|
return { count: 0, success: false };
|
|
332
1054
|
}
|
|
333
1055
|
}
|
|
334
|
-
var DotEnvPlugin = async (
|
|
1056
|
+
var DotEnvPlugin = async (_ctx) => {
|
|
335
1057
|
if (globalThis[LOAD_GUARD]) {
|
|
336
1058
|
return {};
|
|
337
1059
|
}
|
|
338
1060
|
globalThis[LOAD_GUARD] = true;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
1061
|
+
globalProfiler.initStart();
|
|
1062
|
+
log("Plugin started");
|
|
1063
|
+
const { config, path: configPath } = await loadConfig();
|
|
1064
|
+
log(`Config loaded from ${configPath || "default"}: ${config.files.length} files, load_cwd_env=${config.load_cwd_env}, logging=${loggingEnabled}`);
|
|
1065
|
+
const filesToLoad = [...config.files.map(expandPath)];
|
|
1066
|
+
if (config.load_cwd_env !== false) {
|
|
1067
|
+
filesToLoad.push(`${process.cwd()}/.env`);
|
|
1068
|
+
}
|
|
342
1069
|
let totalFiles = 0;
|
|
343
1070
|
let totalVars = 0;
|
|
344
|
-
for (const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
logToFile(`SECURITY: Rejected path outside allowed directories: ${rawPath}`);
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
logToFile(`Loading: ${filePath}`);
|
|
351
|
-
const result = await loadDotenvFile(filePath, config.prefix);
|
|
352
|
-
if (result.success) {
|
|
353
|
-
totalFiles++;
|
|
354
|
-
totalVars += result.count;
|
|
355
|
-
logToFile(`Loaded ${result.count} vars`);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
if (config.load_cwd_env !== false) {
|
|
359
|
-
const cwdEnvPath = `${process.cwd()}/.env`;
|
|
360
|
-
logToFile(`Loading cwd: ${cwdEnvPath}`);
|
|
361
|
-
const result = await loadDotenvFile(cwdEnvPath, config.prefix);
|
|
1071
|
+
for (const filePath of filesToLoad) {
|
|
1072
|
+
log(`Loading: ${filePath}`);
|
|
1073
|
+
const result = await loadDotenvFile(filePath);
|
|
362
1074
|
if (result.success) {
|
|
363
1075
|
totalFiles++;
|
|
364
1076
|
totalVars += result.count;
|
|
365
|
-
|
|
1077
|
+
log(`Loaded ${result.count} vars from ${filePath}`);
|
|
366
1078
|
}
|
|
367
1079
|
}
|
|
368
|
-
|
|
369
|
-
|
|
1080
|
+
globalProfiler.initComplete("ready");
|
|
1081
|
+
const initDuration = globalProfiler.getInitDuration();
|
|
1082
|
+
log(`Plugin finished: ${totalFiles} files, ${totalVars} vars in ${initDuration?.toFixed(2)}ms`);
|
|
370
1083
|
return {};
|
|
371
1084
|
};
|
|
372
|
-
var src_default = DotEnvPlugin;
|
|
373
1085
|
export {
|
|
374
|
-
|
|
375
|
-
parseDotenv,
|
|
376
|
-
isValidEnvKey,
|
|
377
|
-
expandPath,
|
|
378
|
-
src_default as default,
|
|
1086
|
+
DotEnvPlugin as default,
|
|
379
1087
|
DotEnvPlugin
|
|
380
1088
|
};
|