llmz 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/DOCS.md +1 -3
  2. package/dist/_baseForOwn-CFhWe_W6.js +48 -0
  3. package/dist/_baseForOwn-buOZDFbK.cjs +103 -0
  4. package/dist/_baseIteratee-CF4qP2a8.cjs +2377 -0
  5. package/dist/_baseIteratee-P_firB7b.js +2138 -0
  6. package/dist/_getPrototype-CG7Dxrrz.js +6 -0
  7. package/dist/_getPrototype-DQDlNVVM.cjs +10 -0
  8. package/dist/_overArg-C5Hy7oCi.cjs +196 -0
  9. package/dist/_overArg-CRYbj1NH.js +155 -0
  10. package/dist/citations.d.ts +11 -11
  11. package/dist/component-BwixNVH8.cjs +73 -0
  12. package/dist/component-DGG7d_Mz.js +44 -0
  13. package/dist/context.d.ts +8 -8
  14. package/dist/custom-client-BPmEoWKu.cjs +2618 -0
  15. package/dist/custom-client-NUoxrFQh.js +2547 -0
  16. package/dist/dual-modes-D_p-jedw.js +2750 -0
  17. package/dist/dual-modes-wAOAlaBS.cjs +2840 -0
  18. package/dist/errors-C962uJdS.cjs +220 -0
  19. package/dist/errors-Cg1G0Awu.js +161 -0
  20. package/dist/execute-BEaq3jkV.cjs +1003 -0
  21. package/dist/execute-DYvFRs54.js +1001 -0
  22. package/dist/exit-BGi0Kk0y.cjs +428 -0
  23. package/dist/exit-CDdxDBRT.js +417 -0
  24. package/dist/index.cjs +1786 -1489
  25. package/dist/index.d.ts +10 -9
  26. package/dist/index.js +1721 -1479
  27. package/dist/index.workerd.js +17534 -16875
  28. package/dist/isEmpty-BhJRCqIF.js +52 -0
  29. package/dist/isEmpty-LY533Wmh.cjs +57 -0
  30. package/dist/isPlainObject-CSxXVKCk.cjs +56 -0
  31. package/dist/isPlainObject-D39AzPO2.js +51 -0
  32. package/dist/jsx-BWvT6ukg.cjs +75 -0
  33. package/dist/jsx-CIgdGGVs.js +52 -0
  34. package/dist/jsx.d.ts +2 -2
  35. package/dist/prompts/chat-mode/system.md.d.ts +1 -1
  36. package/dist/prompts/chat-mode/user.md.d.ts +1 -1
  37. package/dist/prompts/worker-mode/system.md.d.ts +1 -1
  38. package/dist/prompts/worker-mode/user.md.d.ts +1 -1
  39. package/dist/quickjs-variant-BYhMBpwU.js +45 -0
  40. package/dist/quickjs-variant-CsIwTVFC.cjs +56 -0
  41. package/dist/quickjs-variant.workerd.d.ts +1 -1
  42. package/dist/result.d.ts +12 -12
  43. package/dist/rolldown-runtime-EAsCxrDo.js +14 -0
  44. package/dist/runtime/interpret-result.d.ts +1 -1
  45. package/dist/snapshots.d.ts +5 -5
  46. package/dist/stack-traces-BIE_5Xwf.js +21 -0
  47. package/dist/stack-traces-ntw_qhoy.cjs +26 -0
  48. package/dist/tool-CAo-BQHs.js +643 -0
  49. package/dist/tool-DdPZb0JW.cjs +654 -0
  50. package/dist/tool.d.ts +3 -3
  51. package/dist/truncator-B6aaJaN1.cjs +276 -0
  52. package/dist/truncator-DZqEqnpD.js +253 -0
  53. package/dist/typings-BwAz_TM9.cjs +784 -0
  54. package/dist/typings-CrBa7Tyy.js +743 -0
  55. package/dist/uniq-BYQ7GWwb.js +183 -0
  56. package/dist/uniq-G872RWmE.cjs +200 -0
  57. package/dist/utils-UBeAFeEI.js +950 -0
  58. package/dist/utils-ZpJm00ed.cjs +1075 -0
  59. package/dist/vm/errors.d.ts +2 -2
  60. package/dist/vm-BjkJqSQH.cjs +3438 -0
  61. package/dist/vm-C5vf1LH3.js +3436 -0
  62. package/package.json +7 -7
  63. package/dist/chunk-34GJUS6U.js +0 -3266
  64. package/dist/chunk-3UZKLXAD.cjs +0 -3249
  65. package/dist/chunk-4POZJQXN.js +0 -1530
  66. package/dist/chunk-5WBNTV42.cjs +0 -1530
  67. package/dist/chunk-5ZF6NTYI.cjs +0 -33
  68. package/dist/chunk-72ZWBNZV.js +0 -173
  69. package/dist/chunk-DDSJTR6Q.cjs +0 -257
  70. package/dist/chunk-GDJTKI7J.js +0 -792
  71. package/dist/chunk-GLXADNTR.js +0 -199
  72. package/dist/chunk-GOWPACSK.cjs +0 -199
  73. package/dist/chunk-HB2G32AK.js +0 -257
  74. package/dist/chunk-HC2QZTVT.cjs +0 -3266
  75. package/dist/chunk-HEAQAEFZ.cjs +0 -173
  76. package/dist/chunk-HMMM32RG.cjs +0 -792
  77. package/dist/chunk-I56MPOVG.cjs +0 -62
  78. package/dist/chunk-KIN7Y247.cjs +0 -32
  79. package/dist/chunk-KTDBAJBB.cjs +0 -1685
  80. package/dist/chunk-KWQTYXAT.js +0 -62
  81. package/dist/chunk-LOX7GOR6.js +0 -1685
  82. package/dist/chunk-PK72FAKD.cjs +0 -175
  83. package/dist/chunk-PZE6PIPG.cjs +0 -621
  84. package/dist/chunk-RGUG3UMF.cjs +0 -26
  85. package/dist/chunk-TDALRNGL.js +0 -621
  86. package/dist/chunk-UGHFNCPD.js +0 -26
  87. package/dist/chunk-WSVDMGMR.js +0 -175
  88. package/dist/chunk-XTEHT2TK.js +0 -33
  89. package/dist/chunk-YEAWWJSJ.js +0 -32
  90. package/dist/chunk-YRS7KRKP.js +0 -3249
  91. package/dist/component-2NYFY6CW.cjs +0 -14
  92. package/dist/component-ASNZHQUR.js +0 -14
  93. package/dist/dual-modes-S5TJ5JVJ.js +0 -10
  94. package/dist/dual-modes-TCMWBZIH.cjs +0 -10
  95. package/dist/execute-FF7D46TY.js +0 -1109
  96. package/dist/execute-IK6O4SU2.cjs +0 -1109
  97. package/dist/exit-MX56VN2C.cjs +0 -8
  98. package/dist/exit-UQ3EUX5D.js +0 -8
  99. package/dist/jsx-DDZ63UUF.js +0 -13
  100. package/dist/jsx-ULPWX5TW.cjs +0 -13
  101. package/dist/tool-KD7FL45V.js +0 -11
  102. package/dist/tool-VE2YHIY2.cjs +0 -11
  103. package/dist/truncator-73RCL52Y.js +0 -12
  104. package/dist/truncator-FZNLYSDL.cjs +0 -12
  105. package/dist/typings-E2RROCLT.js +0 -10
  106. package/dist/typings-LQOBZXSO.cjs +0 -10
  107. package/dist/utils-IATCUNKF.js +0 -43
  108. package/dist/utils-ITB4NEL7.cjs +0 -43
  109. package/dist/vm-6D3IIIU7.cjs +0 -12
  110. package/dist/vm-QO5FSGPN.js +0 -12
@@ -1,3249 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
-
3
- var _chunkRGUG3UMFcjs = require('./chunk-RGUG3UMF.cjs');
4
-
5
-
6
-
7
-
8
-
9
-
10
- var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
11
-
12
-
13
- var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
14
-
15
-
16
-
17
-
18
-
19
-
20
- var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
21
-
22
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/base64.js
23
- var require_base64 = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
24
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/base64.js"(exports) {
25
- "use strict";
26
- var intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
27
- exports.encode = function(number) {
28
- if (0 <= number && number < intToCharMap.length) {
29
- return intToCharMap[number];
30
- }
31
- throw new TypeError("Must be between 0 and 63: " + number);
32
- };
33
- exports.decode = function(charCode) {
34
- var bigA = 65;
35
- var bigZ = 90;
36
- var littleA = 97;
37
- var littleZ = 122;
38
- var zero = 48;
39
- var nine = 57;
40
- var plus = 43;
41
- var slash = 47;
42
- var littleOffset = 26;
43
- var numberOffset = 52;
44
- if (bigA <= charCode && charCode <= bigZ) {
45
- return charCode - bigA;
46
- }
47
- if (littleA <= charCode && charCode <= littleZ) {
48
- return charCode - littleA + littleOffset;
49
- }
50
- if (zero <= charCode && charCode <= nine) {
51
- return charCode - zero + numberOffset;
52
- }
53
- if (charCode == plus) {
54
- return 62;
55
- }
56
- if (charCode == slash) {
57
- return 63;
58
- }
59
- return -1;
60
- };
61
- }
62
- });
63
-
64
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/base64-vlq.js
65
- var require_base64_vlq = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
66
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/base64-vlq.js"(exports) {
67
- "use strict";
68
- var base64 = require_base64();
69
- var VLQ_BASE_SHIFT = 5;
70
- var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
71
- var VLQ_BASE_MASK = VLQ_BASE - 1;
72
- var VLQ_CONTINUATION_BIT = VLQ_BASE;
73
- function toVLQSigned(aValue) {
74
- return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0;
75
- }
76
- function fromVLQSigned(aValue) {
77
- var isNegative = (aValue & 1) === 1;
78
- var shifted = aValue >> 1;
79
- return isNegative ? -shifted : shifted;
80
- }
81
- exports.encode = function base64VLQ_encode(aValue) {
82
- var encoded = "";
83
- var digit;
84
- var vlq = toVLQSigned(aValue);
85
- do {
86
- digit = vlq & VLQ_BASE_MASK;
87
- vlq >>>= VLQ_BASE_SHIFT;
88
- if (vlq > 0) {
89
- digit |= VLQ_CONTINUATION_BIT;
90
- }
91
- encoded += base64.encode(digit);
92
- } while (vlq > 0);
93
- return encoded;
94
- };
95
- exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
96
- var strLen = aStr.length;
97
- var result = 0;
98
- var shift = 0;
99
- var continuation, digit;
100
- do {
101
- if (aIndex >= strLen) {
102
- throw new Error("Expected more digits in base 64 VLQ value.");
103
- }
104
- digit = base64.decode(aStr.charCodeAt(aIndex++));
105
- if (digit === -1) {
106
- throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
107
- }
108
- continuation = !!(digit & VLQ_CONTINUATION_BIT);
109
- digit &= VLQ_BASE_MASK;
110
- result = result + (digit << shift);
111
- shift += VLQ_BASE_SHIFT;
112
- } while (continuation);
113
- aOutParam.value = fromVLQSigned(result);
114
- aOutParam.rest = aIndex;
115
- };
116
- }
117
- });
118
-
119
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/util.js
120
- var require_util = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
121
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/util.js"(exports) {
122
- "use strict";
123
- function getArg(aArgs, aName, aDefaultValue) {
124
- if (aName in aArgs) {
125
- return aArgs[aName];
126
- } else if (arguments.length === 3) {
127
- return aDefaultValue;
128
- } else {
129
- throw new Error('"' + aName + '" is a required argument.');
130
- }
131
- }
132
- exports.getArg = getArg;
133
- var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
134
- var dataUrlRegexp = /^data:.+\,.+$/;
135
- function urlParse(aUrl) {
136
- var match = aUrl.match(urlRegexp);
137
- if (!match) {
138
- return null;
139
- }
140
- return {
141
- scheme: match[1],
142
- auth: match[2],
143
- host: match[3],
144
- port: match[4],
145
- path: match[5]
146
- };
147
- }
148
- exports.urlParse = urlParse;
149
- function urlGenerate(aParsedUrl) {
150
- var url = "";
151
- if (aParsedUrl.scheme) {
152
- url += aParsedUrl.scheme + ":";
153
- }
154
- url += "//";
155
- if (aParsedUrl.auth) {
156
- url += aParsedUrl.auth + "@";
157
- }
158
- if (aParsedUrl.host) {
159
- url += aParsedUrl.host;
160
- }
161
- if (aParsedUrl.port) {
162
- url += ":" + aParsedUrl.port;
163
- }
164
- if (aParsedUrl.path) {
165
- url += aParsedUrl.path;
166
- }
167
- return url;
168
- }
169
- exports.urlGenerate = urlGenerate;
170
- var MAX_CACHED_INPUTS = 32;
171
- function lruMemoize(f) {
172
- var cache = [];
173
- return function(input) {
174
- for (var i = 0; i < cache.length; i++) {
175
- if (cache[i].input === input) {
176
- var temp = cache[0];
177
- cache[0] = cache[i];
178
- cache[i] = temp;
179
- return cache[0].result;
180
- }
181
- }
182
- var result = f(input);
183
- cache.unshift({
184
- input,
185
- result
186
- });
187
- if (cache.length > MAX_CACHED_INPUTS) {
188
- cache.pop();
189
- }
190
- return result;
191
- };
192
- }
193
- var normalize = lruMemoize(function normalize2(aPath) {
194
- var path = aPath;
195
- var url = urlParse(aPath);
196
- if (url) {
197
- if (!url.path) {
198
- return aPath;
199
- }
200
- path = url.path;
201
- }
202
- var isAbsolute = exports.isAbsolute(path);
203
- var parts = [];
204
- var start = 0;
205
- var i = 0;
206
- while (true) {
207
- start = i;
208
- i = path.indexOf("/", start);
209
- if (i === -1) {
210
- parts.push(path.slice(start));
211
- break;
212
- } else {
213
- parts.push(path.slice(start, i));
214
- while (i < path.length && path[i] === "/") {
215
- i++;
216
- }
217
- }
218
- }
219
- for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
220
- part = parts[i];
221
- if (part === ".") {
222
- parts.splice(i, 1);
223
- } else if (part === "..") {
224
- up++;
225
- } else if (up > 0) {
226
- if (part === "") {
227
- parts.splice(i + 1, up);
228
- up = 0;
229
- } else {
230
- parts.splice(i, 2);
231
- up--;
232
- }
233
- }
234
- }
235
- path = parts.join("/");
236
- if (path === "") {
237
- path = isAbsolute ? "/" : ".";
238
- }
239
- if (url) {
240
- url.path = path;
241
- return urlGenerate(url);
242
- }
243
- return path;
244
- });
245
- exports.normalize = normalize;
246
- function join(aRoot, aPath) {
247
- if (aRoot === "") {
248
- aRoot = ".";
249
- }
250
- if (aPath === "") {
251
- aPath = ".";
252
- }
253
- var aPathUrl = urlParse(aPath);
254
- var aRootUrl = urlParse(aRoot);
255
- if (aRootUrl) {
256
- aRoot = aRootUrl.path || "/";
257
- }
258
- if (aPathUrl && !aPathUrl.scheme) {
259
- if (aRootUrl) {
260
- aPathUrl.scheme = aRootUrl.scheme;
261
- }
262
- return urlGenerate(aPathUrl);
263
- }
264
- if (aPathUrl || aPath.match(dataUrlRegexp)) {
265
- return aPath;
266
- }
267
- if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
268
- aRootUrl.host = aPath;
269
- return urlGenerate(aRootUrl);
270
- }
271
- var joined = aPath.charAt(0) === "/" ? aPath : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath);
272
- if (aRootUrl) {
273
- aRootUrl.path = joined;
274
- return urlGenerate(aRootUrl);
275
- }
276
- return joined;
277
- }
278
- exports.join = join;
279
- exports.isAbsolute = function(aPath) {
280
- return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
281
- };
282
- function relative(aRoot, aPath) {
283
- if (aRoot === "") {
284
- aRoot = ".";
285
- }
286
- aRoot = aRoot.replace(/\/$/, "");
287
- var level = 0;
288
- while (aPath.indexOf(aRoot + "/") !== 0) {
289
- var index = aRoot.lastIndexOf("/");
290
- if (index < 0) {
291
- return aPath;
292
- }
293
- aRoot = aRoot.slice(0, index);
294
- if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
295
- return aPath;
296
- }
297
- ++level;
298
- }
299
- return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
300
- }
301
- exports.relative = relative;
302
- var supportsNullProto = function() {
303
- var obj = /* @__PURE__ */ Object.create(null);
304
- return !("__proto__" in obj);
305
- }();
306
- function identity(s) {
307
- return s;
308
- }
309
- function toSetString(aStr) {
310
- if (isProtoString(aStr)) {
311
- return "$" + aStr;
312
- }
313
- return aStr;
314
- }
315
- exports.toSetString = supportsNullProto ? identity : toSetString;
316
- function fromSetString(aStr) {
317
- if (isProtoString(aStr)) {
318
- return aStr.slice(1);
319
- }
320
- return aStr;
321
- }
322
- exports.fromSetString = supportsNullProto ? identity : fromSetString;
323
- function isProtoString(s) {
324
- if (!s) {
325
- return false;
326
- }
327
- var length = s.length;
328
- if (length < 9) {
329
- return false;
330
- }
331
- if (s.charCodeAt(length - 1) !== 95 || s.charCodeAt(length - 2) !== 95 || s.charCodeAt(length - 3) !== 111 || s.charCodeAt(length - 4) !== 116 || s.charCodeAt(length - 5) !== 111 || s.charCodeAt(length - 6) !== 114 || s.charCodeAt(length - 7) !== 112 || s.charCodeAt(length - 8) !== 95 || s.charCodeAt(length - 9) !== 95) {
332
- return false;
333
- }
334
- for (var i = length - 10; i >= 0; i--) {
335
- if (s.charCodeAt(i) !== 36) {
336
- return false;
337
- }
338
- }
339
- return true;
340
- }
341
- function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
342
- var cmp = strcmp(mappingA.source, mappingB.source);
343
- if (cmp !== 0) {
344
- return cmp;
345
- }
346
- cmp = mappingA.originalLine - mappingB.originalLine;
347
- if (cmp !== 0) {
348
- return cmp;
349
- }
350
- cmp = mappingA.originalColumn - mappingB.originalColumn;
351
- if (cmp !== 0 || onlyCompareOriginal) {
352
- return cmp;
353
- }
354
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
355
- if (cmp !== 0) {
356
- return cmp;
357
- }
358
- cmp = mappingA.generatedLine - mappingB.generatedLine;
359
- if (cmp !== 0) {
360
- return cmp;
361
- }
362
- return strcmp(mappingA.name, mappingB.name);
363
- }
364
- exports.compareByOriginalPositions = compareByOriginalPositions;
365
- function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
366
- var cmp;
367
- cmp = mappingA.originalLine - mappingB.originalLine;
368
- if (cmp !== 0) {
369
- return cmp;
370
- }
371
- cmp = mappingA.originalColumn - mappingB.originalColumn;
372
- if (cmp !== 0 || onlyCompareOriginal) {
373
- return cmp;
374
- }
375
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
376
- if (cmp !== 0) {
377
- return cmp;
378
- }
379
- cmp = mappingA.generatedLine - mappingB.generatedLine;
380
- if (cmp !== 0) {
381
- return cmp;
382
- }
383
- return strcmp(mappingA.name, mappingB.name);
384
- }
385
- exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
386
- function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
387
- var cmp = mappingA.generatedLine - mappingB.generatedLine;
388
- if (cmp !== 0) {
389
- return cmp;
390
- }
391
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
392
- if (cmp !== 0 || onlyCompareGenerated) {
393
- return cmp;
394
- }
395
- cmp = strcmp(mappingA.source, mappingB.source);
396
- if (cmp !== 0) {
397
- return cmp;
398
- }
399
- cmp = mappingA.originalLine - mappingB.originalLine;
400
- if (cmp !== 0) {
401
- return cmp;
402
- }
403
- cmp = mappingA.originalColumn - mappingB.originalColumn;
404
- if (cmp !== 0) {
405
- return cmp;
406
- }
407
- return strcmp(mappingA.name, mappingB.name);
408
- }
409
- exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
410
- function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
411
- var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
412
- if (cmp !== 0 || onlyCompareGenerated) {
413
- return cmp;
414
- }
415
- cmp = strcmp(mappingA.source, mappingB.source);
416
- if (cmp !== 0) {
417
- return cmp;
418
- }
419
- cmp = mappingA.originalLine - mappingB.originalLine;
420
- if (cmp !== 0) {
421
- return cmp;
422
- }
423
- cmp = mappingA.originalColumn - mappingB.originalColumn;
424
- if (cmp !== 0) {
425
- return cmp;
426
- }
427
- return strcmp(mappingA.name, mappingB.name);
428
- }
429
- exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
430
- function strcmp(aStr1, aStr2) {
431
- if (aStr1 === aStr2) {
432
- return 0;
433
- }
434
- if (aStr1 === null) {
435
- return 1;
436
- }
437
- if (aStr2 === null) {
438
- return -1;
439
- }
440
- if (aStr1 > aStr2) {
441
- return 1;
442
- }
443
- return -1;
444
- }
445
- function compareByGeneratedPositionsInflated(mappingA, mappingB) {
446
- var cmp = mappingA.generatedLine - mappingB.generatedLine;
447
- if (cmp !== 0) {
448
- return cmp;
449
- }
450
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
451
- if (cmp !== 0) {
452
- return cmp;
453
- }
454
- cmp = strcmp(mappingA.source, mappingB.source);
455
- if (cmp !== 0) {
456
- return cmp;
457
- }
458
- cmp = mappingA.originalLine - mappingB.originalLine;
459
- if (cmp !== 0) {
460
- return cmp;
461
- }
462
- cmp = mappingA.originalColumn - mappingB.originalColumn;
463
- if (cmp !== 0) {
464
- return cmp;
465
- }
466
- return strcmp(mappingA.name, mappingB.name);
467
- }
468
- exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
469
- function parseSourceMapInput(str) {
470
- return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
471
- }
472
- exports.parseSourceMapInput = parseSourceMapInput;
473
- function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
474
- sourceURL = sourceURL || "";
475
- if (sourceRoot) {
476
- if (sourceRoot[sourceRoot.length - 1] !== "/" && sourceURL[0] !== "/") {
477
- sourceRoot += "/";
478
- }
479
- sourceURL = sourceRoot + sourceURL;
480
- }
481
- if (sourceMapURL) {
482
- var parsed = urlParse(sourceMapURL);
483
- if (!parsed) {
484
- throw new Error("sourceMapURL could not be parsed");
485
- }
486
- if (parsed.path) {
487
- var index = parsed.path.lastIndexOf("/");
488
- if (index >= 0) {
489
- parsed.path = parsed.path.substring(0, index + 1);
490
- }
491
- }
492
- sourceURL = join(urlGenerate(parsed), sourceURL);
493
- }
494
- return normalize(sourceURL);
495
- }
496
- exports.computeSourceURL = computeSourceURL;
497
- }
498
- });
499
-
500
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/array-set.js
501
- var require_array_set = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
502
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/array-set.js"(exports) {
503
- "use strict";
504
- var util = require_util();
505
- var has = Object.prototype.hasOwnProperty;
506
- var hasNativeMap = typeof Map !== "undefined";
507
- function ArraySet() {
508
- this._array = [];
509
- this._set = hasNativeMap ? /* @__PURE__ */ new Map() : /* @__PURE__ */ Object.create(null);
510
- }
511
- ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
512
- var set = new ArraySet();
513
- for (var i = 0, len = aArray.length; i < len; i++) {
514
- set.add(aArray[i], aAllowDuplicates);
515
- }
516
- return set;
517
- };
518
- ArraySet.prototype.size = function ArraySet_size() {
519
- return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
520
- };
521
- ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
522
- var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
523
- var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
524
- var idx = this._array.length;
525
- if (!isDuplicate || aAllowDuplicates) {
526
- this._array.push(aStr);
527
- }
528
- if (!isDuplicate) {
529
- if (hasNativeMap) {
530
- this._set.set(aStr, idx);
531
- } else {
532
- this._set[sStr] = idx;
533
- }
534
- }
535
- };
536
- ArraySet.prototype.has = function ArraySet_has(aStr) {
537
- if (hasNativeMap) {
538
- return this._set.has(aStr);
539
- } else {
540
- var sStr = util.toSetString(aStr);
541
- return has.call(this._set, sStr);
542
- }
543
- };
544
- ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
545
- if (hasNativeMap) {
546
- var idx = this._set.get(aStr);
547
- if (idx >= 0) {
548
- return idx;
549
- }
550
- } else {
551
- var sStr = util.toSetString(aStr);
552
- if (has.call(this._set, sStr)) {
553
- return this._set[sStr];
554
- }
555
- }
556
- throw new Error('"' + aStr + '" is not in the set.');
557
- };
558
- ArraySet.prototype.at = function ArraySet_at(aIdx) {
559
- if (aIdx >= 0 && aIdx < this._array.length) {
560
- return this._array[aIdx];
561
- }
562
- throw new Error("No element indexed by " + aIdx);
563
- };
564
- ArraySet.prototype.toArray = function ArraySet_toArray() {
565
- return this._array.slice();
566
- };
567
- exports.ArraySet = ArraySet;
568
- }
569
- });
570
-
571
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/mapping-list.js
572
- var require_mapping_list = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
573
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/mapping-list.js"(exports) {
574
- "use strict";
575
- var util = require_util();
576
- function generatedPositionAfter(mappingA, mappingB) {
577
- var lineA = mappingA.generatedLine;
578
- var lineB = mappingB.generatedLine;
579
- var columnA = mappingA.generatedColumn;
580
- var columnB = mappingB.generatedColumn;
581
- return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
582
- }
583
- function MappingList() {
584
- this._array = [];
585
- this._sorted = true;
586
- this._last = { generatedLine: -1, generatedColumn: 0 };
587
- }
588
- MappingList.prototype.unsortedForEach = function MappingList_forEach(aCallback, aThisArg) {
589
- this._array.forEach(aCallback, aThisArg);
590
- };
591
- MappingList.prototype.add = function MappingList_add(aMapping) {
592
- if (generatedPositionAfter(this._last, aMapping)) {
593
- this._last = aMapping;
594
- this._array.push(aMapping);
595
- } else {
596
- this._sorted = false;
597
- this._array.push(aMapping);
598
- }
599
- };
600
- MappingList.prototype.toArray = function MappingList_toArray() {
601
- if (!this._sorted) {
602
- this._array.sort(util.compareByGeneratedPositionsInflated);
603
- this._sorted = true;
604
- }
605
- return this._array;
606
- };
607
- exports.MappingList = MappingList;
608
- }
609
- });
610
-
611
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/source-map-generator.js
612
- var require_source_map_generator = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
613
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/source-map-generator.js"(exports) {
614
- "use strict";
615
- var base64VLQ = require_base64_vlq();
616
- var util = require_util();
617
- var ArraySet = require_array_set().ArraySet;
618
- var MappingList = require_mapping_list().MappingList;
619
- function SourceMapGenerator(aArgs) {
620
- if (!aArgs) {
621
- aArgs = {};
622
- }
623
- this._file = util.getArg(aArgs, "file", null);
624
- this._sourceRoot = util.getArg(aArgs, "sourceRoot", null);
625
- this._skipValidation = util.getArg(aArgs, "skipValidation", false);
626
- this._ignoreInvalidMapping = util.getArg(aArgs, "ignoreInvalidMapping", false);
627
- this._sources = new ArraySet();
628
- this._names = new ArraySet();
629
- this._mappings = new MappingList();
630
- this._sourcesContents = null;
631
- }
632
- SourceMapGenerator.prototype._version = 3;
633
- SourceMapGenerator.fromSourceMap = function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
634
- var sourceRoot = aSourceMapConsumer.sourceRoot;
635
- var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
636
- file: aSourceMapConsumer.file,
637
- sourceRoot
638
- }));
639
- aSourceMapConsumer.eachMapping(function(mapping) {
640
- var newMapping = {
641
- generated: {
642
- line: mapping.generatedLine,
643
- column: mapping.generatedColumn
644
- }
645
- };
646
- if (mapping.source != null) {
647
- newMapping.source = mapping.source;
648
- if (sourceRoot != null) {
649
- newMapping.source = util.relative(sourceRoot, newMapping.source);
650
- }
651
- newMapping.original = {
652
- line: mapping.originalLine,
653
- column: mapping.originalColumn
654
- };
655
- if (mapping.name != null) {
656
- newMapping.name = mapping.name;
657
- }
658
- }
659
- generator.addMapping(newMapping);
660
- });
661
- aSourceMapConsumer.sources.forEach(function(sourceFile) {
662
- var sourceRelative = sourceFile;
663
- if (sourceRoot !== null) {
664
- sourceRelative = util.relative(sourceRoot, sourceFile);
665
- }
666
- if (!generator._sources.has(sourceRelative)) {
667
- generator._sources.add(sourceRelative);
668
- }
669
- var content = aSourceMapConsumer.sourceContentFor(sourceFile);
670
- if (content != null) {
671
- generator.setSourceContent(sourceFile, content);
672
- }
673
- });
674
- return generator;
675
- };
676
- SourceMapGenerator.prototype.addMapping = function SourceMapGenerator_addMapping(aArgs) {
677
- var generated = util.getArg(aArgs, "generated");
678
- var original = util.getArg(aArgs, "original", null);
679
- var source = util.getArg(aArgs, "source", null);
680
- var name = util.getArg(aArgs, "name", null);
681
- if (!this._skipValidation) {
682
- if (this._validateMapping(generated, original, source, name) === false) {
683
- return;
684
- }
685
- }
686
- if (source != null) {
687
- source = String(source);
688
- if (!this._sources.has(source)) {
689
- this._sources.add(source);
690
- }
691
- }
692
- if (name != null) {
693
- name = String(name);
694
- if (!this._names.has(name)) {
695
- this._names.add(name);
696
- }
697
- }
698
- this._mappings.add({
699
- generatedLine: generated.line,
700
- generatedColumn: generated.column,
701
- originalLine: original != null && original.line,
702
- originalColumn: original != null && original.column,
703
- source,
704
- name
705
- });
706
- };
707
- SourceMapGenerator.prototype.setSourceContent = function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
708
- var source = aSourceFile;
709
- if (this._sourceRoot != null) {
710
- source = util.relative(this._sourceRoot, source);
711
- }
712
- if (aSourceContent != null) {
713
- if (!this._sourcesContents) {
714
- this._sourcesContents = /* @__PURE__ */ Object.create(null);
715
- }
716
- this._sourcesContents[util.toSetString(source)] = aSourceContent;
717
- } else if (this._sourcesContents) {
718
- delete this._sourcesContents[util.toSetString(source)];
719
- if (Object.keys(this._sourcesContents).length === 0) {
720
- this._sourcesContents = null;
721
- }
722
- }
723
- };
724
- SourceMapGenerator.prototype.applySourceMap = function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
725
- var sourceFile = aSourceFile;
726
- if (aSourceFile == null) {
727
- if (aSourceMapConsumer.file == null) {
728
- throw new Error(
729
- `SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`
730
- );
731
- }
732
- sourceFile = aSourceMapConsumer.file;
733
- }
734
- var sourceRoot = this._sourceRoot;
735
- if (sourceRoot != null) {
736
- sourceFile = util.relative(sourceRoot, sourceFile);
737
- }
738
- var newSources = new ArraySet();
739
- var newNames = new ArraySet();
740
- this._mappings.unsortedForEach(function(mapping) {
741
- if (mapping.source === sourceFile && mapping.originalLine != null) {
742
- var original = aSourceMapConsumer.originalPositionFor({
743
- line: mapping.originalLine,
744
- column: mapping.originalColumn
745
- });
746
- if (original.source != null) {
747
- mapping.source = original.source;
748
- if (aSourceMapPath != null) {
749
- mapping.source = util.join(aSourceMapPath, mapping.source);
750
- }
751
- if (sourceRoot != null) {
752
- mapping.source = util.relative(sourceRoot, mapping.source);
753
- }
754
- mapping.originalLine = original.line;
755
- mapping.originalColumn = original.column;
756
- if (original.name != null) {
757
- mapping.name = original.name;
758
- }
759
- }
760
- }
761
- var source = mapping.source;
762
- if (source != null && !newSources.has(source)) {
763
- newSources.add(source);
764
- }
765
- var name = mapping.name;
766
- if (name != null && !newNames.has(name)) {
767
- newNames.add(name);
768
- }
769
- }, this);
770
- this._sources = newSources;
771
- this._names = newNames;
772
- aSourceMapConsumer.sources.forEach(function(sourceFile2) {
773
- var content = aSourceMapConsumer.sourceContentFor(sourceFile2);
774
- if (content != null) {
775
- if (aSourceMapPath != null) {
776
- sourceFile2 = util.join(aSourceMapPath, sourceFile2);
777
- }
778
- if (sourceRoot != null) {
779
- sourceFile2 = util.relative(sourceRoot, sourceFile2);
780
- }
781
- this.setSourceContent(sourceFile2, content);
782
- }
783
- }, this);
784
- };
785
- SourceMapGenerator.prototype._validateMapping = function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, aName) {
786
- if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") {
787
- var message = "original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";
788
- if (this._ignoreInvalidMapping) {
789
- if (typeof console !== "undefined" && console.warn) {
790
- console.warn(message);
791
- }
792
- return false;
793
- } else {
794
- throw new Error(message);
795
- }
796
- }
797
- if (aGenerated && "line" in aGenerated && "column" in aGenerated && aGenerated.line > 0 && aGenerated.column >= 0 && !aOriginal && !aSource && !aName) {
798
- return;
799
- } else if (aGenerated && "line" in aGenerated && "column" in aGenerated && aOriginal && "line" in aOriginal && "column" in aOriginal && aGenerated.line > 0 && aGenerated.column >= 0 && aOriginal.line > 0 && aOriginal.column >= 0 && aSource) {
800
- return;
801
- } else {
802
- var message = "Invalid mapping: " + JSON.stringify({
803
- generated: aGenerated,
804
- source: aSource,
805
- original: aOriginal,
806
- name: aName
807
- });
808
- if (this._ignoreInvalidMapping) {
809
- if (typeof console !== "undefined" && console.warn) {
810
- console.warn(message);
811
- }
812
- return false;
813
- } else {
814
- throw new Error(message);
815
- }
816
- }
817
- };
818
- SourceMapGenerator.prototype._serializeMappings = function SourceMapGenerator_serializeMappings() {
819
- var previousGeneratedColumn = 0;
820
- var previousGeneratedLine = 1;
821
- var previousOriginalColumn = 0;
822
- var previousOriginalLine = 0;
823
- var previousName = 0;
824
- var previousSource = 0;
825
- var result = "";
826
- var next;
827
- var mapping;
828
- var nameIdx;
829
- var sourceIdx;
830
- var mappings = this._mappings.toArray();
831
- for (var i = 0, len = mappings.length; i < len; i++) {
832
- mapping = mappings[i];
833
- next = "";
834
- if (mapping.generatedLine !== previousGeneratedLine) {
835
- previousGeneratedColumn = 0;
836
- while (mapping.generatedLine !== previousGeneratedLine) {
837
- next += ";";
838
- previousGeneratedLine++;
839
- }
840
- } else {
841
- if (i > 0) {
842
- if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
843
- continue;
844
- }
845
- next += ",";
846
- }
847
- }
848
- next += base64VLQ.encode(mapping.generatedColumn - previousGeneratedColumn);
849
- previousGeneratedColumn = mapping.generatedColumn;
850
- if (mapping.source != null) {
851
- sourceIdx = this._sources.indexOf(mapping.source);
852
- next += base64VLQ.encode(sourceIdx - previousSource);
853
- previousSource = sourceIdx;
854
- next += base64VLQ.encode(mapping.originalLine - 1 - previousOriginalLine);
855
- previousOriginalLine = mapping.originalLine - 1;
856
- next += base64VLQ.encode(mapping.originalColumn - previousOriginalColumn);
857
- previousOriginalColumn = mapping.originalColumn;
858
- if (mapping.name != null) {
859
- nameIdx = this._names.indexOf(mapping.name);
860
- next += base64VLQ.encode(nameIdx - previousName);
861
- previousName = nameIdx;
862
- }
863
- }
864
- result += next;
865
- }
866
- return result;
867
- };
868
- SourceMapGenerator.prototype._generateSourcesContent = function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
869
- return aSources.map(function(source) {
870
- if (!this._sourcesContents) {
871
- return null;
872
- }
873
- if (aSourceRoot != null) {
874
- source = util.relative(aSourceRoot, source);
875
- }
876
- var key = util.toSetString(source);
877
- return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) ? this._sourcesContents[key] : null;
878
- }, this);
879
- };
880
- SourceMapGenerator.prototype.toJSON = function SourceMapGenerator_toJSON() {
881
- var map = {
882
- version: this._version,
883
- sources: this._sources.toArray(),
884
- names: this._names.toArray(),
885
- mappings: this._serializeMappings()
886
- };
887
- if (this._file != null) {
888
- map.file = this._file;
889
- }
890
- if (this._sourceRoot != null) {
891
- map.sourceRoot = this._sourceRoot;
892
- }
893
- if (this._sourcesContents) {
894
- map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
895
- }
896
- return map;
897
- };
898
- SourceMapGenerator.prototype.toString = function SourceMapGenerator_toString() {
899
- return JSON.stringify(this.toJSON());
900
- };
901
- exports.SourceMapGenerator = SourceMapGenerator;
902
- }
903
- });
904
-
905
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/binary-search.js
906
- var require_binary_search = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
907
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/binary-search.js"(exports) {
908
- "use strict";
909
- exports.GREATEST_LOWER_BOUND = 1;
910
- exports.LEAST_UPPER_BOUND = 2;
911
- function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
912
- var mid = Math.floor((aHigh - aLow) / 2) + aLow;
913
- var cmp = aCompare(aNeedle, aHaystack[mid], true);
914
- if (cmp === 0) {
915
- return mid;
916
- } else if (cmp > 0) {
917
- if (aHigh - mid > 1) {
918
- return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
919
- }
920
- if (aBias == exports.LEAST_UPPER_BOUND) {
921
- return aHigh < aHaystack.length ? aHigh : -1;
922
- } else {
923
- return mid;
924
- }
925
- } else {
926
- if (mid - aLow > 1) {
927
- return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
928
- }
929
- if (aBias == exports.LEAST_UPPER_BOUND) {
930
- return mid;
931
- } else {
932
- return aLow < 0 ? -1 : aLow;
933
- }
934
- }
935
- }
936
- exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
937
- if (aHaystack.length === 0) {
938
- return -1;
939
- }
940
- var index = recursiveSearch(
941
- -1,
942
- aHaystack.length,
943
- aNeedle,
944
- aHaystack,
945
- aCompare,
946
- aBias || exports.GREATEST_LOWER_BOUND
947
- );
948
- if (index < 0) {
949
- return -1;
950
- }
951
- while (index - 1 >= 0) {
952
- if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
953
- break;
954
- }
955
- --index;
956
- }
957
- return index;
958
- };
959
- }
960
- });
961
-
962
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/quick-sort.js
963
- var require_quick_sort = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
964
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/quick-sort.js"(exports) {
965
- "use strict";
966
- function SortTemplate(comparator) {
967
- function swap(ary, x, y) {
968
- var temp = ary[x];
969
- ary[x] = ary[y];
970
- ary[y] = temp;
971
- }
972
- function randomIntInRange(low, high) {
973
- return Math.round(low + Math.random() * (high - low));
974
- }
975
- function doQuickSort(ary, comparator2, p, r) {
976
- if (p < r) {
977
- var pivotIndex = randomIntInRange(p, r);
978
- var i = p - 1;
979
- swap(ary, pivotIndex, r);
980
- var pivot = ary[r];
981
- for (var j = p; j < r; j++) {
982
- if (comparator2(ary[j], pivot, false) <= 0) {
983
- i += 1;
984
- swap(ary, i, j);
985
- }
986
- }
987
- swap(ary, i + 1, j);
988
- var q = i + 1;
989
- doQuickSort(ary, comparator2, p, q - 1);
990
- doQuickSort(ary, comparator2, q + 1, r);
991
- }
992
- }
993
- return doQuickSort;
994
- }
995
- function cloneSort(comparator) {
996
- let templateFn = (...args) => SortTemplate(...args);
997
- return templateFn(comparator);
998
- }
999
- var sortCache = /* @__PURE__ */ new WeakMap();
1000
- exports.quickSort = function(ary, comparator, start = 0) {
1001
- let doQuickSort = sortCache.get(comparator);
1002
- if (doQuickSort === void 0) {
1003
- doQuickSort = cloneSort(comparator);
1004
- sortCache.set(comparator, doQuickSort);
1005
- }
1006
- doQuickSort(ary, comparator, start, ary.length - 1);
1007
- };
1008
- }
1009
- });
1010
-
1011
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/source-map-consumer.js
1012
- var require_source_map_consumer = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
1013
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/source-map-consumer.js"(exports) {
1014
- "use strict";
1015
- var util = require_util();
1016
- var binarySearch = require_binary_search();
1017
- var ArraySet = require_array_set().ArraySet;
1018
- var base64VLQ = require_base64_vlq();
1019
- var quickSort = require_quick_sort().quickSort;
1020
- function SourceMapConsumer2(aSourceMap, aSourceMapURL) {
1021
- var sourceMap = aSourceMap;
1022
- if (typeof aSourceMap === "string") {
1023
- sourceMap = util.parseSourceMapInput(aSourceMap);
1024
- }
1025
- return sourceMap.sections != null ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
1026
- }
1027
- SourceMapConsumer2.fromSourceMap = function(aSourceMap, aSourceMapURL) {
1028
- return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
1029
- };
1030
- SourceMapConsumer2.prototype._version = 3;
1031
- SourceMapConsumer2.prototype.__generatedMappings = null;
1032
- Object.defineProperty(SourceMapConsumer2.prototype, "_generatedMappings", {
1033
- configurable: true,
1034
- enumerable: true,
1035
- get: function() {
1036
- if (!this.__generatedMappings) {
1037
- this._parseMappings(this._mappings, this.sourceRoot);
1038
- }
1039
- return this.__generatedMappings;
1040
- }
1041
- });
1042
- SourceMapConsumer2.prototype.__originalMappings = null;
1043
- Object.defineProperty(SourceMapConsumer2.prototype, "_originalMappings", {
1044
- configurable: true,
1045
- enumerable: true,
1046
- get: function() {
1047
- if (!this.__originalMappings) {
1048
- this._parseMappings(this._mappings, this.sourceRoot);
1049
- }
1050
- return this.__originalMappings;
1051
- }
1052
- });
1053
- SourceMapConsumer2.prototype._charIsMappingSeparator = function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
1054
- var c = aStr.charAt(index);
1055
- return c === ";" || c === ",";
1056
- };
1057
- SourceMapConsumer2.prototype._parseMappings = function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
1058
- throw new Error("Subclasses must implement _parseMappings");
1059
- };
1060
- SourceMapConsumer2.GENERATED_ORDER = 1;
1061
- SourceMapConsumer2.ORIGINAL_ORDER = 2;
1062
- SourceMapConsumer2.GREATEST_LOWER_BOUND = 1;
1063
- SourceMapConsumer2.LEAST_UPPER_BOUND = 2;
1064
- SourceMapConsumer2.prototype.eachMapping = function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
1065
- var context = aContext || null;
1066
- var order = aOrder || SourceMapConsumer2.GENERATED_ORDER;
1067
- var mappings;
1068
- switch (order) {
1069
- case SourceMapConsumer2.GENERATED_ORDER:
1070
- mappings = this._generatedMappings;
1071
- break;
1072
- case SourceMapConsumer2.ORIGINAL_ORDER:
1073
- mappings = this._originalMappings;
1074
- break;
1075
- default:
1076
- throw new Error("Unknown order of iteration.");
1077
- }
1078
- var sourceRoot = this.sourceRoot;
1079
- var boundCallback = aCallback.bind(context);
1080
- var names = this._names;
1081
- var sources = this._sources;
1082
- var sourceMapURL = this._sourceMapURL;
1083
- for (var i = 0, n = mappings.length; i < n; i++) {
1084
- var mapping = mappings[i];
1085
- var source = mapping.source === null ? null : sources.at(mapping.source);
1086
- if (source !== null) {
1087
- source = util.computeSourceURL(sourceRoot, source, sourceMapURL);
1088
- }
1089
- boundCallback({
1090
- source,
1091
- generatedLine: mapping.generatedLine,
1092
- generatedColumn: mapping.generatedColumn,
1093
- originalLine: mapping.originalLine,
1094
- originalColumn: mapping.originalColumn,
1095
- name: mapping.name === null ? null : names.at(mapping.name)
1096
- });
1097
- }
1098
- };
1099
- SourceMapConsumer2.prototype.allGeneratedPositionsFor = function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
1100
- var line = util.getArg(aArgs, "line");
1101
- var needle = {
1102
- source: util.getArg(aArgs, "source"),
1103
- originalLine: line,
1104
- originalColumn: util.getArg(aArgs, "column", 0)
1105
- };
1106
- needle.source = this._findSourceIndex(needle.source);
1107
- if (needle.source < 0) {
1108
- return [];
1109
- }
1110
- var mappings = [];
1111
- var index = this._findMapping(
1112
- needle,
1113
- this._originalMappings,
1114
- "originalLine",
1115
- "originalColumn",
1116
- util.compareByOriginalPositions,
1117
- binarySearch.LEAST_UPPER_BOUND
1118
- );
1119
- if (index >= 0) {
1120
- var mapping = this._originalMappings[index];
1121
- if (aArgs.column === void 0) {
1122
- var originalLine = mapping.originalLine;
1123
- while (mapping && mapping.originalLine === originalLine) {
1124
- mappings.push({
1125
- line: util.getArg(mapping, "generatedLine", null),
1126
- column: util.getArg(mapping, "generatedColumn", null),
1127
- lastColumn: util.getArg(mapping, "lastGeneratedColumn", null)
1128
- });
1129
- mapping = this._originalMappings[++index];
1130
- }
1131
- } else {
1132
- var originalColumn = mapping.originalColumn;
1133
- while (mapping && mapping.originalLine === line && mapping.originalColumn == originalColumn) {
1134
- mappings.push({
1135
- line: util.getArg(mapping, "generatedLine", null),
1136
- column: util.getArg(mapping, "generatedColumn", null),
1137
- lastColumn: util.getArg(mapping, "lastGeneratedColumn", null)
1138
- });
1139
- mapping = this._originalMappings[++index];
1140
- }
1141
- }
1142
- }
1143
- return mappings;
1144
- };
1145
- exports.SourceMapConsumer = SourceMapConsumer2;
1146
- function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
1147
- var sourceMap = aSourceMap;
1148
- if (typeof aSourceMap === "string") {
1149
- sourceMap = util.parseSourceMapInput(aSourceMap);
1150
- }
1151
- var version = util.getArg(sourceMap, "version");
1152
- var sources = util.getArg(sourceMap, "sources");
1153
- var names = util.getArg(sourceMap, "names", []);
1154
- var sourceRoot = util.getArg(sourceMap, "sourceRoot", null);
1155
- var sourcesContent = util.getArg(sourceMap, "sourcesContent", null);
1156
- var mappings = util.getArg(sourceMap, "mappings");
1157
- var file = util.getArg(sourceMap, "file", null);
1158
- if (version != this._version) {
1159
- throw new Error("Unsupported version: " + version);
1160
- }
1161
- if (sourceRoot) {
1162
- sourceRoot = util.normalize(sourceRoot);
1163
- }
1164
- sources = sources.map(String).map(util.normalize).map(function(source) {
1165
- return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) ? util.relative(sourceRoot, source) : source;
1166
- });
1167
- this._names = ArraySet.fromArray(names.map(String), true);
1168
- this._sources = ArraySet.fromArray(sources, true);
1169
- this._absoluteSources = this._sources.toArray().map(function(s) {
1170
- return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
1171
- });
1172
- this.sourceRoot = sourceRoot;
1173
- this.sourcesContent = sourcesContent;
1174
- this._mappings = mappings;
1175
- this._sourceMapURL = aSourceMapURL;
1176
- this.file = file;
1177
- }
1178
- BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer2.prototype);
1179
- BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer2;
1180
- BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
1181
- var relativeSource = aSource;
1182
- if (this.sourceRoot != null) {
1183
- relativeSource = util.relative(this.sourceRoot, relativeSource);
1184
- }
1185
- if (this._sources.has(relativeSource)) {
1186
- return this._sources.indexOf(relativeSource);
1187
- }
1188
- var i;
1189
- for (i = 0; i < this._absoluteSources.length; ++i) {
1190
- if (this._absoluteSources[i] == aSource) {
1191
- return i;
1192
- }
1193
- }
1194
- return -1;
1195
- };
1196
- BasicSourceMapConsumer.fromSourceMap = function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
1197
- var smc = Object.create(BasicSourceMapConsumer.prototype);
1198
- var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
1199
- var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
1200
- smc.sourceRoot = aSourceMap._sourceRoot;
1201
- smc.sourcesContent = aSourceMap._generateSourcesContent(
1202
- smc._sources.toArray(),
1203
- smc.sourceRoot
1204
- );
1205
- smc.file = aSourceMap._file;
1206
- smc._sourceMapURL = aSourceMapURL;
1207
- smc._absoluteSources = smc._sources.toArray().map(function(s) {
1208
- return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
1209
- });
1210
- var generatedMappings = aSourceMap._mappings.toArray().slice();
1211
- var destGeneratedMappings = smc.__generatedMappings = [];
1212
- var destOriginalMappings = smc.__originalMappings = [];
1213
- for (var i = 0, length = generatedMappings.length; i < length; i++) {
1214
- var srcMapping = generatedMappings[i];
1215
- var destMapping = new Mapping();
1216
- destMapping.generatedLine = srcMapping.generatedLine;
1217
- destMapping.generatedColumn = srcMapping.generatedColumn;
1218
- if (srcMapping.source) {
1219
- destMapping.source = sources.indexOf(srcMapping.source);
1220
- destMapping.originalLine = srcMapping.originalLine;
1221
- destMapping.originalColumn = srcMapping.originalColumn;
1222
- if (srcMapping.name) {
1223
- destMapping.name = names.indexOf(srcMapping.name);
1224
- }
1225
- destOriginalMappings.push(destMapping);
1226
- }
1227
- destGeneratedMappings.push(destMapping);
1228
- }
1229
- quickSort(smc.__originalMappings, util.compareByOriginalPositions);
1230
- return smc;
1231
- };
1232
- BasicSourceMapConsumer.prototype._version = 3;
1233
- Object.defineProperty(BasicSourceMapConsumer.prototype, "sources", {
1234
- get: function() {
1235
- return this._absoluteSources.slice();
1236
- }
1237
- });
1238
- function Mapping() {
1239
- this.generatedLine = 0;
1240
- this.generatedColumn = 0;
1241
- this.source = null;
1242
- this.originalLine = null;
1243
- this.originalColumn = null;
1244
- this.name = null;
1245
- }
1246
- var compareGenerated = util.compareByGeneratedPositionsDeflatedNoLine;
1247
- function sortGenerated(array, start) {
1248
- let l = array.length;
1249
- let n = array.length - start;
1250
- if (n <= 1) {
1251
- return;
1252
- } else if (n == 2) {
1253
- let a = array[start];
1254
- let b = array[start + 1];
1255
- if (compareGenerated(a, b) > 0) {
1256
- array[start] = b;
1257
- array[start + 1] = a;
1258
- }
1259
- } else if (n < 20) {
1260
- for (let i = start; i < l; i++) {
1261
- for (let j = i; j > start; j--) {
1262
- let a = array[j - 1];
1263
- let b = array[j];
1264
- if (compareGenerated(a, b) <= 0) {
1265
- break;
1266
- }
1267
- array[j - 1] = b;
1268
- array[j] = a;
1269
- }
1270
- }
1271
- } else {
1272
- quickSort(array, compareGenerated, start);
1273
- }
1274
- }
1275
- BasicSourceMapConsumer.prototype._parseMappings = function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
1276
- var generatedLine = 1;
1277
- var previousGeneratedColumn = 0;
1278
- var previousOriginalLine = 0;
1279
- var previousOriginalColumn = 0;
1280
- var previousSource = 0;
1281
- var previousName = 0;
1282
- var length = aStr.length;
1283
- var index = 0;
1284
- var cachedSegments = {};
1285
- var temp = {};
1286
- var originalMappings = [];
1287
- var generatedMappings = [];
1288
- var mapping, str, segment, end, value;
1289
- let subarrayStart = 0;
1290
- while (index < length) {
1291
- if (aStr.charAt(index) === ";") {
1292
- generatedLine++;
1293
- index++;
1294
- previousGeneratedColumn = 0;
1295
- sortGenerated(generatedMappings, subarrayStart);
1296
- subarrayStart = generatedMappings.length;
1297
- } else if (aStr.charAt(index) === ",") {
1298
- index++;
1299
- } else {
1300
- mapping = new Mapping();
1301
- mapping.generatedLine = generatedLine;
1302
- for (end = index; end < length; end++) {
1303
- if (this._charIsMappingSeparator(aStr, end)) {
1304
- break;
1305
- }
1306
- }
1307
- str = aStr.slice(index, end);
1308
- segment = [];
1309
- while (index < end) {
1310
- base64VLQ.decode(aStr, index, temp);
1311
- value = temp.value;
1312
- index = temp.rest;
1313
- segment.push(value);
1314
- }
1315
- if (segment.length === 2) {
1316
- throw new Error("Found a source, but no line and column");
1317
- }
1318
- if (segment.length === 3) {
1319
- throw new Error("Found a source and line, but no column");
1320
- }
1321
- mapping.generatedColumn = previousGeneratedColumn + segment[0];
1322
- previousGeneratedColumn = mapping.generatedColumn;
1323
- if (segment.length > 1) {
1324
- mapping.source = previousSource + segment[1];
1325
- previousSource += segment[1];
1326
- mapping.originalLine = previousOriginalLine + segment[2];
1327
- previousOriginalLine = mapping.originalLine;
1328
- mapping.originalLine += 1;
1329
- mapping.originalColumn = previousOriginalColumn + segment[3];
1330
- previousOriginalColumn = mapping.originalColumn;
1331
- if (segment.length > 4) {
1332
- mapping.name = previousName + segment[4];
1333
- previousName += segment[4];
1334
- }
1335
- }
1336
- generatedMappings.push(mapping);
1337
- if (typeof mapping.originalLine === "number") {
1338
- let currentSource = mapping.source;
1339
- while (originalMappings.length <= currentSource) {
1340
- originalMappings.push(null);
1341
- }
1342
- if (originalMappings[currentSource] === null) {
1343
- originalMappings[currentSource] = [];
1344
- }
1345
- originalMappings[currentSource].push(mapping);
1346
- }
1347
- }
1348
- }
1349
- sortGenerated(generatedMappings, subarrayStart);
1350
- this.__generatedMappings = generatedMappings;
1351
- for (var i = 0; i < originalMappings.length; i++) {
1352
- if (originalMappings[i] != null) {
1353
- quickSort(originalMappings[i], util.compareByOriginalPositionsNoSource);
1354
- }
1355
- }
1356
- this.__originalMappings = [].concat(...originalMappings);
1357
- };
1358
- BasicSourceMapConsumer.prototype._findMapping = function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, aColumnName, aComparator, aBias) {
1359
- if (aNeedle[aLineName] <= 0) {
1360
- throw new TypeError("Line must be greater than or equal to 1, got " + aNeedle[aLineName]);
1361
- }
1362
- if (aNeedle[aColumnName] < 0) {
1363
- throw new TypeError("Column must be greater than or equal to 0, got " + aNeedle[aColumnName]);
1364
- }
1365
- return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
1366
- };
1367
- BasicSourceMapConsumer.prototype.computeColumnSpans = function SourceMapConsumer_computeColumnSpans() {
1368
- for (var index = 0; index < this._generatedMappings.length; ++index) {
1369
- var mapping = this._generatedMappings[index];
1370
- if (index + 1 < this._generatedMappings.length) {
1371
- var nextMapping = this._generatedMappings[index + 1];
1372
- if (mapping.generatedLine === nextMapping.generatedLine) {
1373
- mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
1374
- continue;
1375
- }
1376
- }
1377
- mapping.lastGeneratedColumn = Infinity;
1378
- }
1379
- };
1380
- BasicSourceMapConsumer.prototype.originalPositionFor = function SourceMapConsumer_originalPositionFor(aArgs) {
1381
- var needle = {
1382
- generatedLine: util.getArg(aArgs, "line"),
1383
- generatedColumn: util.getArg(aArgs, "column")
1384
- };
1385
- var index = this._findMapping(
1386
- needle,
1387
- this._generatedMappings,
1388
- "generatedLine",
1389
- "generatedColumn",
1390
- util.compareByGeneratedPositionsDeflated,
1391
- util.getArg(aArgs, "bias", SourceMapConsumer2.GREATEST_LOWER_BOUND)
1392
- );
1393
- if (index >= 0) {
1394
- var mapping = this._generatedMappings[index];
1395
- if (mapping.generatedLine === needle.generatedLine) {
1396
- var source = util.getArg(mapping, "source", null);
1397
- if (source !== null) {
1398
- source = this._sources.at(source);
1399
- source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
1400
- }
1401
- var name = util.getArg(mapping, "name", null);
1402
- if (name !== null) {
1403
- name = this._names.at(name);
1404
- }
1405
- return {
1406
- source,
1407
- line: util.getArg(mapping, "originalLine", null),
1408
- column: util.getArg(mapping, "originalColumn", null),
1409
- name
1410
- };
1411
- }
1412
- }
1413
- return {
1414
- source: null,
1415
- line: null,
1416
- column: null,
1417
- name: null
1418
- };
1419
- };
1420
- BasicSourceMapConsumer.prototype.hasContentsOfAllSources = function BasicSourceMapConsumer_hasContentsOfAllSources() {
1421
- if (!this.sourcesContent) {
1422
- return false;
1423
- }
1424
- return this.sourcesContent.length >= this._sources.size() && !this.sourcesContent.some(function(sc) {
1425
- return sc == null;
1426
- });
1427
- };
1428
- BasicSourceMapConsumer.prototype.sourceContentFor = function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
1429
- if (!this.sourcesContent) {
1430
- return null;
1431
- }
1432
- var index = this._findSourceIndex(aSource);
1433
- if (index >= 0) {
1434
- return this.sourcesContent[index];
1435
- }
1436
- var relativeSource = aSource;
1437
- if (this.sourceRoot != null) {
1438
- relativeSource = util.relative(this.sourceRoot, relativeSource);
1439
- }
1440
- var url;
1441
- if (this.sourceRoot != null && (url = util.urlParse(this.sourceRoot))) {
1442
- var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
1443
- if (url.scheme == "file" && this._sources.has(fileUriAbsPath)) {
1444
- return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)];
1445
- }
1446
- if ((!url.path || url.path == "/") && this._sources.has("/" + relativeSource)) {
1447
- return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
1448
- }
1449
- }
1450
- if (nullOnMissing) {
1451
- return null;
1452
- } else {
1453
- throw new Error('"' + relativeSource + '" is not in the SourceMap.');
1454
- }
1455
- };
1456
- BasicSourceMapConsumer.prototype.generatedPositionFor = function SourceMapConsumer_generatedPositionFor(aArgs) {
1457
- var source = util.getArg(aArgs, "source");
1458
- source = this._findSourceIndex(source);
1459
- if (source < 0) {
1460
- return {
1461
- line: null,
1462
- column: null,
1463
- lastColumn: null
1464
- };
1465
- }
1466
- var needle = {
1467
- source,
1468
- originalLine: util.getArg(aArgs, "line"),
1469
- originalColumn: util.getArg(aArgs, "column")
1470
- };
1471
- var index = this._findMapping(
1472
- needle,
1473
- this._originalMappings,
1474
- "originalLine",
1475
- "originalColumn",
1476
- util.compareByOriginalPositions,
1477
- util.getArg(aArgs, "bias", SourceMapConsumer2.GREATEST_LOWER_BOUND)
1478
- );
1479
- if (index >= 0) {
1480
- var mapping = this._originalMappings[index];
1481
- if (mapping.source === needle.source) {
1482
- return {
1483
- line: util.getArg(mapping, "generatedLine", null),
1484
- column: util.getArg(mapping, "generatedColumn", null),
1485
- lastColumn: util.getArg(mapping, "lastGeneratedColumn", null)
1486
- };
1487
- }
1488
- }
1489
- return {
1490
- line: null,
1491
- column: null,
1492
- lastColumn: null
1493
- };
1494
- };
1495
- exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
1496
- function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
1497
- var sourceMap = aSourceMap;
1498
- if (typeof aSourceMap === "string") {
1499
- sourceMap = util.parseSourceMapInput(aSourceMap);
1500
- }
1501
- var version = util.getArg(sourceMap, "version");
1502
- var sections = util.getArg(sourceMap, "sections");
1503
- if (version != this._version) {
1504
- throw new Error("Unsupported version: " + version);
1505
- }
1506
- this._sources = new ArraySet();
1507
- this._names = new ArraySet();
1508
- var lastOffset = {
1509
- line: -1,
1510
- column: 0
1511
- };
1512
- this._sections = sections.map(function(s) {
1513
- if (s.url) {
1514
- throw new Error("Support for url field in sections not implemented.");
1515
- }
1516
- var offset = util.getArg(s, "offset");
1517
- var offsetLine = util.getArg(offset, "line");
1518
- var offsetColumn = util.getArg(offset, "column");
1519
- if (offsetLine < lastOffset.line || offsetLine === lastOffset.line && offsetColumn < lastOffset.column) {
1520
- throw new Error("Section offsets must be ordered and non-overlapping.");
1521
- }
1522
- lastOffset = offset;
1523
- return {
1524
- generatedOffset: {
1525
- // The offset fields are 0-based, but we use 1-based indices when
1526
- // encoding/decoding from VLQ.
1527
- generatedLine: offsetLine + 1,
1528
- generatedColumn: offsetColumn + 1
1529
- },
1530
- consumer: new SourceMapConsumer2(util.getArg(s, "map"), aSourceMapURL)
1531
- };
1532
- });
1533
- }
1534
- IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer2.prototype);
1535
- IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer2;
1536
- IndexedSourceMapConsumer.prototype._version = 3;
1537
- Object.defineProperty(IndexedSourceMapConsumer.prototype, "sources", {
1538
- get: function() {
1539
- var sources = [];
1540
- for (var i = 0; i < this._sections.length; i++) {
1541
- for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
1542
- sources.push(this._sections[i].consumer.sources[j]);
1543
- }
1544
- }
1545
- return sources;
1546
- }
1547
- });
1548
- IndexedSourceMapConsumer.prototype.originalPositionFor = function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
1549
- var needle = {
1550
- generatedLine: util.getArg(aArgs, "line"),
1551
- generatedColumn: util.getArg(aArgs, "column")
1552
- };
1553
- var sectionIndex = binarySearch.search(
1554
- needle,
1555
- this._sections,
1556
- function(needle2, section2) {
1557
- var cmp = needle2.generatedLine - section2.generatedOffset.generatedLine;
1558
- if (cmp) {
1559
- return cmp;
1560
- }
1561
- return needle2.generatedColumn - section2.generatedOffset.generatedColumn;
1562
- }
1563
- );
1564
- var section = this._sections[sectionIndex];
1565
- if (!section) {
1566
- return {
1567
- source: null,
1568
- line: null,
1569
- column: null,
1570
- name: null
1571
- };
1572
- }
1573
- return section.consumer.originalPositionFor({
1574
- line: needle.generatedLine - (section.generatedOffset.generatedLine - 1),
1575
- column: needle.generatedColumn - (section.generatedOffset.generatedLine === needle.generatedLine ? section.generatedOffset.generatedColumn - 1 : 0),
1576
- bias: aArgs.bias
1577
- });
1578
- };
1579
- IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = function IndexedSourceMapConsumer_hasContentsOfAllSources() {
1580
- return this._sections.every(function(s) {
1581
- return s.consumer.hasContentsOfAllSources();
1582
- });
1583
- };
1584
- IndexedSourceMapConsumer.prototype.sourceContentFor = function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
1585
- for (var i = 0; i < this._sections.length; i++) {
1586
- var section = this._sections[i];
1587
- var content = section.consumer.sourceContentFor(aSource, true);
1588
- if (content || content === "") {
1589
- return content;
1590
- }
1591
- }
1592
- if (nullOnMissing) {
1593
- return null;
1594
- } else {
1595
- throw new Error('"' + aSource + '" is not in the SourceMap.');
1596
- }
1597
- };
1598
- IndexedSourceMapConsumer.prototype.generatedPositionFor = function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
1599
- for (var i = 0; i < this._sections.length; i++) {
1600
- var section = this._sections[i];
1601
- if (section.consumer._findSourceIndex(util.getArg(aArgs, "source")) === -1) {
1602
- continue;
1603
- }
1604
- var generatedPosition = section.consumer.generatedPositionFor(aArgs);
1605
- if (generatedPosition) {
1606
- var ret = {
1607
- line: generatedPosition.line + (section.generatedOffset.generatedLine - 1),
1608
- column: generatedPosition.column + (section.generatedOffset.generatedLine === generatedPosition.line ? section.generatedOffset.generatedColumn - 1 : 0)
1609
- };
1610
- return ret;
1611
- }
1612
- }
1613
- return {
1614
- line: null,
1615
- column: null
1616
- };
1617
- };
1618
- IndexedSourceMapConsumer.prototype._parseMappings = function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
1619
- this.__generatedMappings = [];
1620
- this.__originalMappings = [];
1621
- for (var i = 0; i < this._sections.length; i++) {
1622
- var section = this._sections[i];
1623
- var sectionMappings = section.consumer._generatedMappings;
1624
- for (var j = 0; j < sectionMappings.length; j++) {
1625
- var mapping = sectionMappings[j];
1626
- var source = section.consumer._sources.at(mapping.source);
1627
- if (source !== null) {
1628
- source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
1629
- }
1630
- this._sources.add(source);
1631
- source = this._sources.indexOf(source);
1632
- var name = null;
1633
- if (mapping.name) {
1634
- name = section.consumer._names.at(mapping.name);
1635
- this._names.add(name);
1636
- name = this._names.indexOf(name);
1637
- }
1638
- var adjustedMapping = {
1639
- source,
1640
- generatedLine: mapping.generatedLine + (section.generatedOffset.generatedLine - 1),
1641
- generatedColumn: mapping.generatedColumn + (section.generatedOffset.generatedLine === mapping.generatedLine ? section.generatedOffset.generatedColumn - 1 : 0),
1642
- originalLine: mapping.originalLine,
1643
- originalColumn: mapping.originalColumn,
1644
- name
1645
- };
1646
- this.__generatedMappings.push(adjustedMapping);
1647
- if (typeof adjustedMapping.originalLine === "number") {
1648
- this.__originalMappings.push(adjustedMapping);
1649
- }
1650
- }
1651
- }
1652
- quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
1653
- quickSort(this.__originalMappings, util.compareByOriginalPositions);
1654
- };
1655
- exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
1656
- }
1657
- });
1658
-
1659
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/source-node.js
1660
- var require_source_node = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
1661
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/lib/source-node.js"(exports) {
1662
- "use strict";
1663
- var SourceMapGenerator = require_source_map_generator().SourceMapGenerator;
1664
- var util = require_util();
1665
- var REGEX_NEWLINE = /(\r?\n)/;
1666
- var NEWLINE_CODE = 10;
1667
- var isSourceNode = "$$$isSourceNode$$$";
1668
- function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
1669
- this.children = [];
1670
- this.sourceContents = {};
1671
- this.line = aLine == null ? null : aLine;
1672
- this.column = aColumn == null ? null : aColumn;
1673
- this.source = aSource == null ? null : aSource;
1674
- this.name = aName == null ? null : aName;
1675
- this[isSourceNode] = true;
1676
- if (aChunks != null)
1677
- this.add(aChunks);
1678
- }
1679
- SourceNode.fromStringWithSourceMap = function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
1680
- var node = new SourceNode();
1681
- var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
1682
- var remainingLinesIndex = 0;
1683
- var shiftNextLine = function() {
1684
- var lineContents = getNextLine();
1685
- var newLine = getNextLine() || "";
1686
- return lineContents + newLine;
1687
- function getNextLine() {
1688
- return remainingLinesIndex < remainingLines.length ? remainingLines[remainingLinesIndex++] : void 0;
1689
- }
1690
- };
1691
- var lastGeneratedLine = 1, lastGeneratedColumn = 0;
1692
- var lastMapping = null;
1693
- aSourceMapConsumer.eachMapping(function(mapping) {
1694
- if (lastMapping !== null) {
1695
- if (lastGeneratedLine < mapping.generatedLine) {
1696
- addMappingWithCode(lastMapping, shiftNextLine());
1697
- lastGeneratedLine++;
1698
- lastGeneratedColumn = 0;
1699
- } else {
1700
- var nextLine = remainingLines[remainingLinesIndex] || "";
1701
- var code = nextLine.substr(0, mapping.generatedColumn - lastGeneratedColumn);
1702
- remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - lastGeneratedColumn);
1703
- lastGeneratedColumn = mapping.generatedColumn;
1704
- addMappingWithCode(lastMapping, code);
1705
- lastMapping = mapping;
1706
- return;
1707
- }
1708
- }
1709
- while (lastGeneratedLine < mapping.generatedLine) {
1710
- node.add(shiftNextLine());
1711
- lastGeneratedLine++;
1712
- }
1713
- if (lastGeneratedColumn < mapping.generatedColumn) {
1714
- var nextLine = remainingLines[remainingLinesIndex] || "";
1715
- node.add(nextLine.substr(0, mapping.generatedColumn));
1716
- remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
1717
- lastGeneratedColumn = mapping.generatedColumn;
1718
- }
1719
- lastMapping = mapping;
1720
- }, this);
1721
- if (remainingLinesIndex < remainingLines.length) {
1722
- if (lastMapping) {
1723
- addMappingWithCode(lastMapping, shiftNextLine());
1724
- }
1725
- node.add(remainingLines.splice(remainingLinesIndex).join(""));
1726
- }
1727
- aSourceMapConsumer.sources.forEach(function(sourceFile) {
1728
- var content = aSourceMapConsumer.sourceContentFor(sourceFile);
1729
- if (content != null) {
1730
- if (aRelativePath != null) {
1731
- sourceFile = util.join(aRelativePath, sourceFile);
1732
- }
1733
- node.setSourceContent(sourceFile, content);
1734
- }
1735
- });
1736
- return node;
1737
- function addMappingWithCode(mapping, code) {
1738
- if (mapping === null || mapping.source === void 0) {
1739
- node.add(code);
1740
- } else {
1741
- var source = aRelativePath ? util.join(aRelativePath, mapping.source) : mapping.source;
1742
- node.add(new SourceNode(
1743
- mapping.originalLine,
1744
- mapping.originalColumn,
1745
- source,
1746
- code,
1747
- mapping.name
1748
- ));
1749
- }
1750
- }
1751
- };
1752
- SourceNode.prototype.add = function SourceNode_add(aChunk) {
1753
- if (Array.isArray(aChunk)) {
1754
- aChunk.forEach(function(chunk) {
1755
- this.add(chunk);
1756
- }, this);
1757
- } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
1758
- if (aChunk) {
1759
- this.children.push(aChunk);
1760
- }
1761
- } else {
1762
- throw new TypeError(
1763
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
1764
- );
1765
- }
1766
- return this;
1767
- };
1768
- SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
1769
- if (Array.isArray(aChunk)) {
1770
- for (var i = aChunk.length - 1; i >= 0; i--) {
1771
- this.prepend(aChunk[i]);
1772
- }
1773
- } else if (aChunk[isSourceNode] || typeof aChunk === "string") {
1774
- this.children.unshift(aChunk);
1775
- } else {
1776
- throw new TypeError(
1777
- "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
1778
- );
1779
- }
1780
- return this;
1781
- };
1782
- SourceNode.prototype.walk = function SourceNode_walk(aFn) {
1783
- var chunk;
1784
- for (var i = 0, len = this.children.length; i < len; i++) {
1785
- chunk = this.children[i];
1786
- if (chunk[isSourceNode]) {
1787
- chunk.walk(aFn);
1788
- } else {
1789
- if (chunk !== "") {
1790
- aFn(chunk, {
1791
- source: this.source,
1792
- line: this.line,
1793
- column: this.column,
1794
- name: this.name
1795
- });
1796
- }
1797
- }
1798
- }
1799
- };
1800
- SourceNode.prototype.join = function SourceNode_join(aSep) {
1801
- var newChildren;
1802
- var i;
1803
- var len = this.children.length;
1804
- if (len > 0) {
1805
- newChildren = [];
1806
- for (i = 0; i < len - 1; i++) {
1807
- newChildren.push(this.children[i]);
1808
- newChildren.push(aSep);
1809
- }
1810
- newChildren.push(this.children[i]);
1811
- this.children = newChildren;
1812
- }
1813
- return this;
1814
- };
1815
- SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
1816
- var lastChild = this.children[this.children.length - 1];
1817
- if (lastChild[isSourceNode]) {
1818
- lastChild.replaceRight(aPattern, aReplacement);
1819
- } else if (typeof lastChild === "string") {
1820
- this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
1821
- } else {
1822
- this.children.push("".replace(aPattern, aReplacement));
1823
- }
1824
- return this;
1825
- };
1826
- SourceNode.prototype.setSourceContent = function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
1827
- this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
1828
- };
1829
- SourceNode.prototype.walkSourceContents = function SourceNode_walkSourceContents(aFn) {
1830
- for (var i = 0, len = this.children.length; i < len; i++) {
1831
- if (this.children[i][isSourceNode]) {
1832
- this.children[i].walkSourceContents(aFn);
1833
- }
1834
- }
1835
- var sources = Object.keys(this.sourceContents);
1836
- for (var i = 0, len = sources.length; i < len; i++) {
1837
- aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
1838
- }
1839
- };
1840
- SourceNode.prototype.toString = function SourceNode_toString() {
1841
- var str = "";
1842
- this.walk(function(chunk) {
1843
- str += chunk;
1844
- });
1845
- return str;
1846
- };
1847
- SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
1848
- var generated = {
1849
- code: "",
1850
- line: 1,
1851
- column: 0
1852
- };
1853
- var map = new SourceMapGenerator(aArgs);
1854
- var sourceMappingActive = false;
1855
- var lastOriginalSource = null;
1856
- var lastOriginalLine = null;
1857
- var lastOriginalColumn = null;
1858
- var lastOriginalName = null;
1859
- this.walk(function(chunk, original) {
1860
- generated.code += chunk;
1861
- if (original.source !== null && original.line !== null && original.column !== null) {
1862
- if (lastOriginalSource !== original.source || lastOriginalLine !== original.line || lastOriginalColumn !== original.column || lastOriginalName !== original.name) {
1863
- map.addMapping({
1864
- source: original.source,
1865
- original: {
1866
- line: original.line,
1867
- column: original.column
1868
- },
1869
- generated: {
1870
- line: generated.line,
1871
- column: generated.column
1872
- },
1873
- name: original.name
1874
- });
1875
- }
1876
- lastOriginalSource = original.source;
1877
- lastOriginalLine = original.line;
1878
- lastOriginalColumn = original.column;
1879
- lastOriginalName = original.name;
1880
- sourceMappingActive = true;
1881
- } else if (sourceMappingActive) {
1882
- map.addMapping({
1883
- generated: {
1884
- line: generated.line,
1885
- column: generated.column
1886
- }
1887
- });
1888
- lastOriginalSource = null;
1889
- sourceMappingActive = false;
1890
- }
1891
- for (var idx = 0, length = chunk.length; idx < length; idx++) {
1892
- if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
1893
- generated.line++;
1894
- generated.column = 0;
1895
- if (idx + 1 === length) {
1896
- lastOriginalSource = null;
1897
- sourceMappingActive = false;
1898
- } else if (sourceMappingActive) {
1899
- map.addMapping({
1900
- source: original.source,
1901
- original: {
1902
- line: original.line,
1903
- column: original.column
1904
- },
1905
- generated: {
1906
- line: generated.line,
1907
- column: generated.column
1908
- },
1909
- name: original.name
1910
- });
1911
- }
1912
- } else {
1913
- generated.column++;
1914
- }
1915
- }
1916
- });
1917
- this.walkSourceContents(function(sourceFile, sourceContent) {
1918
- map.setSourceContent(sourceFile, sourceContent);
1919
- });
1920
- return { code: generated.code, map };
1921
- };
1922
- exports.SourceNode = SourceNode;
1923
- }
1924
- });
1925
-
1926
- // ../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/source-map.js
1927
- var require_source_map = _chunkHC2QZTVTcjs.__commonJS.call(void 0, {
1928
- "../../node_modules/.pnpm/source-map-js@1.2.1_patch_hash=0354139cbc5dbd66e1bc59167ff8e42d3a9a2169038a35f1b7b1b4b843e08a6c/node_modules/source-map-js/source-map.js"(exports) {
1929
- "use strict";
1930
- exports.SourceMapGenerator = require_source_map_generator().SourceMapGenerator;
1931
- exports.SourceMapConsumer = require_source_map_consumer().SourceMapConsumer;
1932
- exports.SourceNode = require_source_node().SourceNode;
1933
- }
1934
- });
1935
-
1936
- // src/vm/index.ts
1937
- var import_source_map_js = _chunkHC2QZTVTcjs.__toESM.call(void 0, require_source_map(), 1);
1938
-
1939
- // src/compiler/compiler.ts
1940
- var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
1941
-
1942
- // src/compiler/ast.ts
1943
- var _acorn = require('acorn');
1944
- var TS_SMELL = /(^|[^:]):\s*(string|number|boolean|any|unknown|void)\b|\bas\s+(const\b|[A-Z])|\binterface\s+[A-Z]|^\s*type\s+[A-Z]|[a-zA-Z)\]]!\.|<(string|number|boolean)[,>]/m;
1945
- function parseScript(code, opts) {
1946
- try {
1947
- return _acorn.parse.call(void 0, code, {
1948
- ecmaVersion: "latest",
1949
- sourceType: "script",
1950
- locations: true,
1951
- allowReturnOutsideFunction: true,
1952
- allowAwaitOutsideFunction: true,
1953
- ...opts,
1954
- onComment: opts == null ? void 0 : opts.comments
1955
- });
1956
- } catch (err) {
1957
- if (err instanceof SyntaxError && TS_SMELL.test(code)) {
1958
- err.message += '. The code must be plain JavaScript: do not use TypeScript syntax (type annotations, "as" casts, generics, interfaces or type aliases).';
1959
- }
1960
- throw err;
1961
- }
1962
- }
1963
- function walk(root, enter) {
1964
- const ancestors = [];
1965
- const visit = (node) => {
1966
- enter(node, _nullishCoalesce(ancestors[ancestors.length - 1], () => ( null)), ancestors);
1967
- ancestors.push(node);
1968
- for (const key of Object.keys(node)) {
1969
- if (key === "loc") {
1970
- continue;
1971
- }
1972
- const value = node[key];
1973
- if (Array.isArray(value)) {
1974
- for (const child of value) {
1975
- if (isNode(child)) {
1976
- visit(child);
1977
- }
1978
- }
1979
- } else if (isNode(value)) {
1980
- visit(value);
1981
- }
1982
- }
1983
- ancestors.pop();
1984
- };
1985
- visit(root);
1986
- }
1987
- var isNode = (value) => !!value && typeof value === "object" && typeof value.type === "string";
1988
- var isStatementContainer = (node) => !!node && (node.type === "Program" || node.type === "BlockStatement" || node.type === "StaticBlock");
1989
- function enclosingStatement(node, ancestors) {
1990
- const chain = [...ancestors, node];
1991
- for (let i = chain.length - 1; i > 0; i--) {
1992
- if (isStatementContainer(chain[i - 1])) {
1993
- return chain[i];
1994
- }
1995
- }
1996
- return null;
1997
- }
1998
- function innermostContaining(ast, start, end) {
1999
- let best = null;
2000
- walk(ast, (node) => {
2001
- if (node.start <= start && node.end >= end) {
2002
- if (!best || node.start >= best.start && node.end <= best.end) {
2003
- best = node;
2004
- }
2005
- }
2006
- });
2007
- return best;
2008
- }
2009
-
2010
- // src/compiler/plugins/async-wrapper.ts
2011
- var Open = "async function __fn__() {";
2012
- var Close = "}";
2013
- var USER_CODE_START_MARKER = "/* __LLMZ_USER_CODE_START__ */";
2014
- var USER_CODE_END_MARKER = "/* __LLMZ_USER_CODE_END__ */";
2015
- var AsyncWrapper = {
2016
- preProcessing: (code) => {
2017
- return `"use strict";
2018
- ${Open}
2019
- ${USER_CODE_START_MARKER}
2020
- ${code}
2021
- ${USER_CODE_END_MARKER}
2022
- ${Close}
2023
- `.trim();
2024
- },
2025
- postProcessing: (code) => {
2026
- code = code.slice(code.indexOf(Open) + Open.length);
2027
- code = code.slice(0, code.lastIndexOf(Close));
2028
- code = code.replace(USER_CODE_START_MARKER, "").replace(USER_CODE_END_MARKER, "");
2029
- return code.trimEnd();
2030
- }
2031
- };
2032
-
2033
- // src/compiler/plugins/line-tracking.ts
2034
- var LineTrackingFnIdentifier = "__track__";
2035
- var TRACKED_TYPES = /* @__PURE__ */ new Set([
2036
- "FunctionDeclaration",
2037
- "MethodDefinition",
2038
- "ReturnStatement",
2039
- "AwaitExpression",
2040
- "ForOfStatement",
2041
- "CallExpression",
2042
- "UnaryExpression",
2043
- "VariableDeclaration",
2044
- "AssignmentExpression"
2045
- ]);
2046
- var SKIPPED_PARENT_TYPES = /* @__PURE__ */ new Set([
2047
- "ArrowFunctionExpression",
2048
- "Property",
2049
- "AwaitExpression",
2050
- "UnaryExpression",
2051
- "ReturnStatement",
2052
- "ForOfStatement",
2053
- "ForStatement",
2054
- "ForInStatement",
2055
- "VariableDeclaration",
2056
- "BinaryExpression",
2057
- "LogicalExpression"
2058
- ]);
2059
- function applyLineTracking(ctx) {
2060
- const trackedLines = /* @__PURE__ */ new Set();
2061
- walk(ctx.ast, (node, parent, ancestors) => {
2062
- if (!parent || !node.loc) {
2063
- return;
2064
- }
2065
- if (!TRACKED_TYPES.has(node.type) && parent.type !== "BlockStatement") {
2066
- return;
2067
- }
2068
- const line = node.loc.start.line;
2069
- if (trackedLines.has(line) || SKIPPED_PARENT_TYPES.has(parent.type)) {
2070
- return;
2071
- }
2072
- const statement = enclosingStatement(node, ancestors);
2073
- if (!statement) {
2074
- return;
2075
- }
2076
- trackedLines.add(line);
2077
- ctx.ms.appendLeft(statement.start, `${LineTrackingFnIdentifier}(${line});`);
2078
- });
2079
- }
2080
-
2081
- // src/compiler/plugins/replace-comment.ts
2082
- var CommentFnIdentifier = "__comment__";
2083
- var MARKER_TAGS = [USER_CODE_START_MARKER, USER_CODE_END_MARKER].map((m) => m.replace(/\/\*|\*\/|\s/g, ""));
2084
- var blank = (ctx, start, end) => {
2085
- ctx.ms.update(start, end, ctx.code.slice(start, end).replace(/[^\n]/g, " "));
2086
- };
2087
- function applyCommentReplacement(ctx, skipRanges) {
2088
- for (const comment of ctx.comments) {
2089
- const text = comment.value.trim();
2090
- if (MARKER_TAGS.some((tag) => text.includes(tag))) {
2091
- blank(ctx, comment.start, comment.end);
2092
- continue;
2093
- }
2094
- if (skipRanges.some(([start, end]) => comment.start >= start && comment.end <= end)) {
2095
- continue;
2096
- }
2097
- const container = innermostContaining(ctx.ast, comment.start, comment.end);
2098
- if (isStatementContainer(container)) {
2099
- const newlines = ctx.code.slice(comment.start, comment.end).replace(/[^\n]/g, "");
2100
- ctx.ms.update(
2101
- comment.start,
2102
- comment.end,
2103
- `;${CommentFnIdentifier}(${JSON.stringify(text)}, ${comment.loc.start.line});${newlines}`
2104
- );
2105
- } else {
2106
- blank(ctx, comment.start, comment.end);
2107
- }
2108
- }
2109
- }
2110
-
2111
- // src/compiler/plugins/return-async.ts
2112
- function planLastLineInstrumentation(ast) {
2113
- const fn = ast.body.find((node) => {
2114
- var _a;
2115
- return node.type === "FunctionDeclaration" && ((_a = node.id) == null ? void 0 : _a.name) === "__fn__";
2116
- });
2117
- if (!fn) {
2118
- return null;
2119
- }
2120
- const statements = fn.body.body;
2121
- const last = statements[statements.length - 1];
2122
- if (!last) {
2123
- return null;
2124
- }
2125
- if (last.type === "ReturnStatement") {
2126
- if (!last.argument) {
2127
- return null;
2128
- }
2129
- return { prefixPos: last.argument.start, prefix: "await (", suffixPos: last.argument.end, suffix: ")" };
2130
- }
2131
- if (last.type === "ExpressionStatement" && (last.expression.type === "CallExpression" || last.expression.type === "AwaitExpression")) {
2132
- return { prefixPos: last.expression.start, prefix: "return await (", suffixPos: last.expression.end, suffix: ")" };
2133
- }
2134
- return null;
2135
- }
2136
-
2137
- // src/compiler/plugins/track-tool-calls.ts
2138
- var ToolCallTrackerFnIdentifier = "__toolc__";
2139
- var ToolTrackerRetIdentifier = "__ret__";
2140
- function applyToolCallTracking(ctx, calls) {
2141
- let callId = 0;
2142
- const wrappedRanges = [];
2143
- const src = ctx.code;
2144
- const sliceOf = (node) => src.slice(node.start, node.end);
2145
- const extractAssignment = (lval) => {
2146
- const source = sliceOf(lval);
2147
- if (lval.type === "Identifier") {
2148
- return { type: "single", left: source, evalFn: `let ${source} = arguments[0]; return { ${source} };` };
2149
- }
2150
- if (lval.type === "ArrayPattern") {
2151
- const elements = lval.elements.map((el) => el ? sliceOf(el) : "").join(", ");
2152
- return {
2153
- type: "array",
2154
- left: elements,
2155
- evalFn: `let [${elements}] = arguments[0] ?? []; return { ${elements} };`
2156
- };
2157
- }
2158
- if (lval.type === "ObjectPattern") {
2159
- return { type: "object", left: source, evalFn: `let ${source} = arguments[0] ?? {}; return ${source};` };
2160
- }
2161
- return { type: "unsupported", left: "", evalFn: "" };
2162
- };
2163
- walk(ctx.ast, (node, parent, ancestors) => {
2164
- var _a;
2165
- if (node.type !== "CallExpression") {
2166
- return;
2167
- }
2168
- if (wrappedRanges.some(([start2, end2]) => node.start >= start2 && node.end <= end2)) {
2169
- return;
2170
- }
2171
- if ((parent == null ? void 0 : parent.type) === "YieldExpression") {
2172
- return;
2173
- }
2174
- const declaration = [...ancestors].reverse().find((n) => n.type === "VariableDeclaration");
2175
- const assignment = [...ancestors].reverse().find((n) => n.type === "AssignmentExpression");
2176
- let lval = null;
2177
- if (declaration) {
2178
- lval = _nullishCoalesce(((_a = declaration.declarations[0]) == null ? void 0 : _a.id), () => ( null));
2179
- }
2180
- if (assignment) {
2181
- lval = assignment.left;
2182
- }
2183
- const isAsync = (parent == null ? void 0 : parent.type) === "AwaitExpression";
2184
- const start = (id) => `${ToolCallTrackerFnIdentifier}(${id}, "start");`;
2185
- const end = (id, value) => `${ToolCallTrackerFnIdentifier}(${id}, "end", ${value});`;
2186
- const prefix = (id) => `(${isAsync ? "async " : ""}() => {try {${start(id)}const ${ToolTrackerRetIdentifier} = ${isAsync ? "await " : ""}`;
2187
- const successSuffix = (id) => `;${end(id, ToolTrackerRetIdentifier)}return ${ToolTrackerRetIdentifier};}`;
2188
- if (!lval) {
2189
- if (!sliceOf(node).trim().length) {
2190
- return;
2191
- }
2192
- const catchClause2 = ` catch (err) {${end(callId, "err")}const __newError = new Error(err.message);__newError.stack = err.stack + ("\\n" + __newError.stack);throw __newError;}})()`;
2193
- ctx.ms.appendLeft(node.start, prefix(callId));
2194
- ctx.ms.appendRight(node.end, successSuffix(callId) + catchClause2);
2195
- wrappedRanges.push([node.start, node.end]);
2196
- callId++;
2197
- return;
2198
- }
2199
- const assign = extractAssignment(lval);
2200
- if (assign.type === "unsupported") {
2201
- return;
2202
- }
2203
- const tryId = callId;
2204
- callId++;
2205
- const callee = node.callee;
2206
- let object = "global";
2207
- let tool = callee.type === "Identifier" ? callee.name : sliceOf(callee);
2208
- if (callee.type === "MemberExpression") {
2209
- object = sliceOf(callee.object);
2210
- const property = callee.property;
2211
- tool = property.type === "Identifier" ? property.name : property.type === "Literal" ? String(property.value) : sliceOf(property);
2212
- }
2213
- const catchClause = ` catch (err) {${end(callId, "err")}throw new Error(err.message);}})()`;
2214
- ctx.ms.appendLeft(node.start, prefix(tryId));
2215
- ctx.ms.appendRight(node.end, successSuffix(tryId) + catchClause);
2216
- wrappedRanges.push([node.start, node.end]);
2217
- calls.set(callId, { object, tool, assignment: assign });
2218
- });
2219
- return wrappedRanges;
2220
- }
2221
-
2222
- // src/compiler/plugins/variable-extraction.ts
2223
- var VariableTrackingFnIdentifier = "__var__";
2224
- function applyVariableTracking(ctx, variables) {
2225
- const trackerFor = (name) => {
2226
- if (name.startsWith("__")) {
2227
- return null;
2228
- }
2229
- variables.add(name);
2230
- return `${VariableTrackingFnIdentifier}(${JSON.stringify(name)}, () => eval(${JSON.stringify(name)}));`;
2231
- };
2232
- const track = (names) => names.map(trackerFor).filter((t) => !!t).join("");
2233
- const declaredNames = (id) => {
2234
- if (id.type === "Identifier") {
2235
- return [id.name];
2236
- }
2237
- if (id.type === "ObjectPattern") {
2238
- const names = [];
2239
- for (const prop of id.properties) {
2240
- if (prop.type !== "Property") {
2241
- continue;
2242
- }
2243
- if (prop.value.type === "Identifier") {
2244
- names.push(prop.value.name);
2245
- } else if (prop.value.type === "ObjectPattern") {
2246
- names.push(...declaredNames(prop.value));
2247
- } else if (prop.value.type === "AssignmentPattern" && prop.value.left.type === "Identifier") {
2248
- names.push(prop.value.left.name);
2249
- }
2250
- }
2251
- return names;
2252
- }
2253
- if (id.type === "ArrayPattern") {
2254
- const names = [];
2255
- for (const element of id.elements) {
2256
- if (!element) {
2257
- continue;
2258
- }
2259
- if (element.type === "Identifier") {
2260
- names.push(element.name);
2261
- } else if (element.type === "RestElement" && element.argument.type === "Identifier") {
2262
- names.push(element.argument.name);
2263
- } else if (element.type === "AssignmentPattern" && element.left.type === "Identifier") {
2264
- names.push(element.left.name);
2265
- }
2266
- }
2267
- return names;
2268
- }
2269
- return [];
2270
- };
2271
- const paramNames = (params) => {
2272
- const names = [];
2273
- for (const param of params) {
2274
- if (param.type === "Identifier") {
2275
- names.push(param.name);
2276
- } else if (param.type === "AssignmentPattern" && param.left.type === "Identifier") {
2277
- names.push(param.left.name);
2278
- } else if (param.type === "ObjectPattern") {
2279
- for (const prop of param.properties) {
2280
- if (prop.type === "Property" && prop.value.type === "Identifier") {
2281
- names.push(prop.value.name);
2282
- }
2283
- }
2284
- } else if (param.type === "ArrayPattern") {
2285
- for (const element of param.elements) {
2286
- if ((element == null ? void 0 : element.type) === "Identifier") {
2287
- names.push(element.name);
2288
- }
2289
- }
2290
- }
2291
- }
2292
- return names;
2293
- };
2294
- walk(ctx.ast, (node, parent) => {
2295
- if (node.type === "VariableDeclaration") {
2296
- if (parent && (parent.type === "ForStatement" || parent.type === "ForInStatement" || parent.type === "ForOfStatement")) {
2297
- return;
2298
- }
2299
- const trackers = track(node.declarations.flatMap((d) => declaredNames(d.id)));
2300
- if (trackers) {
2301
- const semi = ctx.code[node.end - 1] === ";" ? "" : ";";
2302
- ctx.ms.appendRight(node.end, `${semi}${trackers}`);
2303
- }
2304
- return;
2305
- }
2306
- if (node.type === "FunctionDeclaration" || node.type === "ArrowFunctionExpression") {
2307
- const trackers = track(paramNames(node.params));
2308
- if (!trackers) {
2309
- return;
2310
- }
2311
- const body = node.body;
2312
- if (body.type === "BlockStatement") {
2313
- ctx.ms.appendRight(body.start + 1, trackers);
2314
- } else {
2315
- ctx.ms.appendLeft(body.start, `{${trackers}return (`);
2316
- ctx.ms.appendRight(body.end, ");}");
2317
- }
2318
- }
2319
- });
2320
- }
2321
-
2322
- // src/compiler/compiler.ts
2323
- var Identifiers = {
2324
- ConsoleObjIdentifier: "console",
2325
- LineTrackingFnIdentifier,
2326
- VariableTrackingFnIdentifier,
2327
- ToolCallTrackerFnIdentifier,
2328
- ToolTrackerRetIdentifier,
2329
- CommentFnIdentifier
2330
- };
2331
- var FUNCTION_TYPES = /* @__PURE__ */ new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
2332
- function hasTopLevelReturn(code) {
2333
- try {
2334
- const ast = parseScript(code);
2335
- let found = false;
2336
- walk(ast, (node, _parent, ancestors) => {
2337
- if (node.type === "ReturnStatement" && !ancestors.some((a) => FUNCTION_TYPES.has(a.type))) {
2338
- found = true;
2339
- }
2340
- });
2341
- return found;
2342
- } catch (e) {
2343
- return /\breturn\b/.test(code);
2344
- }
2345
- }
2346
- function compile(code) {
2347
- const wrapped = AsyncWrapper.preProcessing(code);
2348
- const comments = [];
2349
- const ast = parseScript(wrapped, { comments });
2350
- const variables = /* @__PURE__ */ new Set();
2351
- const toolCalls = /* @__PURE__ */ new Map();
2352
- const lastLine = planLastLineInstrumentation(ast);
2353
- const msMarkers = new (0, _magicstring2.default)(wrapped);
2354
- if (lastLine) {
2355
- msMarkers.appendLeft(lastLine.prefixPos, lastLine.prefix);
2356
- msMarkers.appendRight(lastLine.suffixPos, lastLine.suffix);
2357
- }
2358
- const codeWithMarkers = msMarkers.toString();
2359
- const ms = new (0, _magicstring2.default)(wrapped);
2360
- const ctx = { code: wrapped, ms, ast, comments };
2361
- applyLineTracking(ctx);
2362
- if (lastLine) {
2363
- ms.appendLeft(lastLine.prefixPos, lastLine.prefix);
2364
- }
2365
- const wrappedRanges = applyToolCallTracking(ctx, toolCalls);
2366
- applyCommentReplacement(ctx, wrappedRanges);
2367
- applyVariableTracking(ctx, variables);
2368
- if (lastLine) {
2369
- ms.appendRight(lastLine.suffixPos, lastLine.suffix);
2370
- }
2371
- const outputCode = AsyncWrapper.postProcessing(ms.toString());
2372
- const map = ms.generateMap({ hires: true, source: "<anonymous>" });
2373
- return {
2374
- code: outputCode,
2375
- codeWithMarkers,
2376
- map,
2377
- variables,
2378
- toolCalls
2379
- };
2380
- }
2381
-
2382
- // src/vm/errors.ts
2383
- var handleErrorQuickJS = (err, code, _consumer, traces, variables, lines_executed, userCodeStartLine, currentToolCall) => {
2384
- err = _chunkPK72FAKDcjs.Signals.maybeDeserializeError(err);
2385
- const lines = code.split("\n");
2386
- const stackTrace = err.stack || "";
2387
- const LINE_OFFSET = 1;
2388
- const regex = /<quickjs>:(\d+)/g;
2389
- const QUICKJS_WRAPPER_OFFSET = 9;
2390
- const matches = Array.from(stackTrace.matchAll(regex)).map((x) => {
2391
- const quickjsLine = Number(x[1]);
2392
- const transformedCodeLine = quickjsLine - QUICKJS_WRAPPER_OFFSET;
2393
- const line = Math.max(1, transformedCodeLine - userCodeStartLine + 1);
2394
- const actualLine = _nullishCoalesce(lines[line - LINE_OFFSET], () => ( ""));
2395
- const whiteSpacesCount = actualLine.length - actualLine.trimStart().length;
2396
- return { line, column: whiteSpacesCount };
2397
- });
2398
- if (matches.length === 0 && lines_executed.size > 0) {
2399
- const lastLine = Math.max(...Array.from(lines_executed.keys()));
2400
- const actualLine = _nullishCoalesce(lines[lastLine - LINE_OFFSET], () => ( ""));
2401
- const whiteSpacesCount = actualLine.length - actualLine.trimStart().length;
2402
- matches.push({ line: lastLine, column: whiteSpacesCount });
2403
- }
2404
- return formatError(err, lines, matches, traces, variables, lines_executed, currentToolCall, code);
2405
- };
2406
- var handleErrorNode = (err, code, consumer, traces, variables, _lines_executed, currentToolCall) => {
2407
- var _a, _b;
2408
- err = _chunkPK72FAKDcjs.Signals.maybeDeserializeError(err);
2409
- const lines = code.split("\n");
2410
- const stackTrace = err.stack || "";
2411
- const LINE_OFFSET = 1;
2412
- const regex = /<anonymous>:(\d+):(\d+)/g;
2413
- const ASYNC_FUNCTION_HEADER_LINES = 2;
2414
- const SLICED_WRAPPER_LINES = 2;
2415
- const KEPT_BLANK_LINES = 1;
2416
- const RUNTIME_TO_MAP_OFFSET = SLICED_WRAPPER_LINES - ASYNC_FUNCTION_HEADER_LINES - KEPT_BLANK_LINES;
2417
- const WRAPPED_HEADER_LINES = 3;
2418
- const matches = [...stackTrace.matchAll(regex)].map((x) => {
2419
- const mapLine = Number(x[1]) + RUNTIME_TO_MAP_OFFSET;
2420
- const originalLine = consumer.originalPositionFor({
2421
- line: mapLine,
2422
- column: Number(x[2])
2423
- });
2424
- const line = (_nullishCoalesce(originalLine.line, () => ( mapLine))) - WRAPPED_HEADER_LINES;
2425
- const actualLine = _nullishCoalesce(lines[line - LINE_OFFSET], () => ( ""));
2426
- const whiteSpacesCount = actualLine.length - actualLine.trimStart().length;
2427
- const minColumn = Math.max(whiteSpacesCount, originalLine.column);
2428
- return { line, column: Math.min(minColumn, Number(x[2])) };
2429
- });
2430
- const { debugUserCode, truncatedCode } = buildDebugCode(lines, matches);
2431
- if (err instanceof _chunkPK72FAKDcjs.VMSignal) {
2432
- err.stack = debugUserCode;
2433
- err.truncatedCode = truncatedCode;
2434
- err.variables = _chunkHC2QZTVTcjs.mapValues_default.call(void 0, variables, (getter) => _chunkHC2QZTVTcjs.isFunction_default.call(void 0, getter) ? getter() : getter);
2435
- err.toolCall = currentToolCall;
2436
- throw err;
2437
- } else {
2438
- traces.push({
2439
- type: "code_execution_exception",
2440
- position: [_nullishCoalesce(((_a = matches[0]) == null ? void 0 : _a.line), () => ( 0)), _nullishCoalesce(((_b = matches[0]) == null ? void 0 : _b.column), () => ( 0))],
2441
- message: err.message,
2442
- stackTrace: debugUserCode,
2443
- started_at: Date.now()
2444
- });
2445
- throw new (0, _chunkPK72FAKDcjs.CodeExecutionError)(err.message, code, debugUserCode);
2446
- }
2447
- };
2448
- var handleCatch = (err, traces, variables, lines_executed) => {
2449
- err = _chunkPK72FAKDcjs.Signals.maybeDeserializeError(err);
2450
- return {
2451
- success: err instanceof _chunkPK72FAKDcjs.VMSignal ? true : false,
2452
- variables: _chunkHC2QZTVTcjs.mapValues_default.call(void 0, variables, (getter) => _chunkHC2QZTVTcjs.isFunction_default.call(void 0, getter) ? getter() : getter),
2453
- error: err,
2454
- signal: err instanceof _chunkPK72FAKDcjs.VMSignal ? err : void 0,
2455
- traces,
2456
- lines_executed: Array.from(lines_executed)
2457
- };
2458
- };
2459
- function buildDebugCode(lines, matches) {
2460
- var _a;
2461
- const LINE_OFFSET = 1;
2462
- const lastLine = _nullishCoalesce(((_a = _chunkHC2QZTVTcjs.maxBy_default.call(void 0, matches, (x) => _nullishCoalesce(x.line, () => ( 0)))) == null ? void 0 : _a.line), () => ( 0));
2463
- let debugUserCode = "";
2464
- let truncatedCode = "";
2465
- let truncated = false;
2466
- const appendCode = (line) => {
2467
- debugUserCode += line;
2468
- if (!truncated) {
2469
- truncatedCode += line;
2470
- }
2471
- };
2472
- for (let i = 0; i < lines.length; i++) {
2473
- const VM_OFFSET = 2;
2474
- const DISPLAY_OFFSET = 0;
2475
- const line = lines[i];
2476
- const correctedStackLineIndex = i + LINE_OFFSET + VM_OFFSET;
2477
- const match = matches.find((x) => x.line + VM_OFFSET === correctedStackLineIndex);
2478
- const paddedLineNumber = String(correctedStackLineIndex - VM_OFFSET - DISPLAY_OFFSET).padStart(3, "0");
2479
- if (match) {
2480
- appendCode(`> ${paddedLineNumber} | ${line}
2481
- `);
2482
- appendCode(` ${" ".repeat(paddedLineNumber.length + match.column)}^^^^^^^^^^
2483
- `);
2484
- if (match.line >= lastLine) {
2485
- truncated = true;
2486
- }
2487
- } else {
2488
- appendCode(` ${paddedLineNumber} | ${line}
2489
- `);
2490
- }
2491
- }
2492
- return {
2493
- debugUserCode: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, debugUserCode).trim(),
2494
- truncatedCode: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, truncatedCode).trim()
2495
- };
2496
- }
2497
- function formatError(err, lines, matches, traces, variables, lines_executed, currentToolCall, code) {
2498
- var _a, _b;
2499
- const { debugUserCode, truncatedCode } = buildDebugCode(lines, matches);
2500
- if (err instanceof _chunkPK72FAKDcjs.VMSignal) {
2501
- const signalError = err;
2502
- signalError.stack = debugUserCode;
2503
- signalError.truncatedCode = truncatedCode;
2504
- signalError.variables = _chunkHC2QZTVTcjs.mapValues_default.call(void 0, variables, (getter) => _chunkHC2QZTVTcjs.isFunction_default.call(void 0, getter) ? getter() : getter);
2505
- signalError.toolCall = currentToolCall;
2506
- return {
2507
- success: true,
2508
- variables: _chunkHC2QZTVTcjs.mapValues_default.call(void 0, variables, (getter) => _chunkHC2QZTVTcjs.isFunction_default.call(void 0, getter) ? getter() : getter),
2509
- signal: err,
2510
- lines_executed: Array.from(lines_executed)
2511
- };
2512
- } else {
2513
- traces.push({
2514
- type: "code_execution_exception",
2515
- position: [_nullishCoalesce(((_a = matches[0]) == null ? void 0 : _a.line), () => ( 0)), _nullishCoalesce(((_b = matches[0]) == null ? void 0 : _b.column), () => ( 0))],
2516
- message: err.message,
2517
- stackTrace: debugUserCode,
2518
- started_at: Date.now()
2519
- });
2520
- const codeError = new (0, _chunkPK72FAKDcjs.CodeExecutionError)(err.message, code, debugUserCode);
2521
- const deserializedError = _chunkPK72FAKDcjs.Signals.maybeDeserializeError(codeError);
2522
- return {
2523
- success: false,
2524
- variables: _chunkHC2QZTVTcjs.mapValues_default.call(void 0, variables, (getter) => _chunkHC2QZTVTcjs.isFunction_default.call(void 0, getter) ? getter() : getter),
2525
- error: deserializedError,
2526
- traces,
2527
- lines_executed: Array.from(lines_executed)
2528
- };
2529
- }
2530
- }
2531
-
2532
- // src/vm/instrument.ts
2533
- var USER_CODE_MARKER_TAG_START = "__LLMZ_USER_CODE_START__";
2534
- var USER_CODE_MARKER_TAG_END = "__LLMZ_USER_CODE_END__";
2535
- var NO_TRACKING = [
2536
- Identifiers.CommentFnIdentifier,
2537
- Identifiers.ToolCallTrackerFnIdentifier,
2538
- Identifiers.ToolTrackerRetIdentifier,
2539
- Identifiers.VariableTrackingFnIdentifier,
2540
- Identifiers.ConsoleObjIdentifier
2541
- ];
2542
- function instrumentContext(context, transformed, traces, variables, lines_executed, consumer, userCodeStartLine) {
2543
- const state = { currentToolCall: void 0 };
2544
- context[Identifiers.CommentFnIdentifier] = (comment, line) => {
2545
- if (comment.includes(USER_CODE_MARKER_TAG_START) || comment.includes(USER_CODE_MARKER_TAG_END)) {
2546
- return;
2547
- }
2548
- traces.push({ type: "comment", comment, line, started_at: Date.now() });
2549
- };
2550
- context[Identifiers.LineTrackingFnIdentifier] = (line) => {
2551
- const originalLine = consumer.originalPositionFor({ line, column: 0 });
2552
- const mappedLine = _nullishCoalesce(originalLine.line, () => ( line));
2553
- const userCodeLine = Math.max(1, mappedLine - userCodeStartLine);
2554
- lines_executed.set(userCodeLine, (_nullishCoalesce(lines_executed.get(userCodeLine), () => ( 0))) + 1);
2555
- };
2556
- context[Identifiers.VariableTrackingFnIdentifier] = (name, getter) => {
2557
- if (NO_TRACKING.includes(name)) {
2558
- return;
2559
- }
2560
- variables[name] = () => {
2561
- try {
2562
- const value = getter();
2563
- if (typeof value === "function") {
2564
- return "[[non-primitive]]";
2565
- }
2566
- return value;
2567
- } catch (e2) {
2568
- return "[[non-primitive]]";
2569
- }
2570
- };
2571
- };
2572
- context[Identifiers.ToolCallTrackerFnIdentifier] = (callId, type, outputOrError) => {
2573
- var _a;
2574
- const temp = _chunkPK72FAKDcjs.Signals.maybeDeserializeError(outputOrError == null ? void 0 : outputOrError.message);
2575
- if (type === "end" && temp instanceof _chunkPK72FAKDcjs.SnapshotSignal && (temp == null ? void 0 : temp.toolCall)) {
2576
- state.currentToolCall = {
2577
- ...temp.toolCall,
2578
- assignment: (_a = transformed.toolCalls.get(callId)) == null ? void 0 : _a.assignment
2579
- };
2580
- }
2581
- };
2582
- context[Identifiers.ConsoleObjIdentifier] = {
2583
- log: (...args) => {
2584
- const message = args.shift();
2585
- traces.push({ type: "log", message, args, started_at: Date.now() });
2586
- }
2587
- };
2588
- return state;
2589
- }
2590
- function findUserCodeStartLine(transformed) {
2591
- var _a;
2592
- const codeWithMarkers = transformed.codeWithMarkers || transformed.code;
2593
- const markerLines = codeWithMarkers.split("\n");
2594
- for (let i = 0; i < markerLines.length; i++) {
2595
- if ((_a = markerLines[i]) == null ? void 0 : _a.includes(USER_CODE_START_MARKER)) {
2596
- return i + 1;
2597
- }
2598
- }
2599
- return -1;
2600
- }
2601
-
2602
- // src/vm/drivers/node.ts
2603
- var NodeDriver = class {
2604
- async execute(ctx) {
2605
- const { transformed, consumer, context, traces, code, lines_executed, variables } = ctx;
2606
- const state = instrumentContext(context, transformed, traces, variables, lines_executed, consumer, 0);
2607
- const AsyncFunction = async function() {
2608
- }.constructor;
2609
- return await (async () => {
2610
- const descriptors = Object.getOwnPropertyDescriptors(context);
2611
- const topLevelProperties = Object.keys(descriptors).filter(
2612
- (x) => !NO_TRACKING.includes(x) && descriptors[x] && typeof descriptors[x].value !== "function" && typeof descriptors[x].value !== "object"
2613
- );
2614
- const __report = (name, value) => {
2615
- if (context[name] !== void 0 && context[name] !== value) {
2616
- context[name] = value;
2617
- }
2618
- };
2619
- context.__report = __report;
2620
- const reportAll = topLevelProperties.map((x) => `__report("${x}", ${x})`).join(";");
2621
- const assigner = `let __${Identifiers.LineTrackingFnIdentifier} = ${Identifiers.LineTrackingFnIdentifier}; ${Identifiers.LineTrackingFnIdentifier} = function(line) { ${reportAll}; __${Identifiers.LineTrackingFnIdentifier}(line);}`;
2622
- const wrapper = `"use strict"; try { ${assigner};${transformed.code} } finally { ${reportAll} };`;
2623
- const fn = AsyncFunction(...Object.keys(context), wrapper);
2624
- return await fn(...Object.values(context));
2625
- })().then((res) => {
2626
- res = _chunkPK72FAKDcjs.Signals.maybeDeserializeError(res);
2627
- return {
2628
- success: true,
2629
- variables: _chunkHC2QZTVTcjs.mapValues_default.call(void 0, variables, (getter) => _chunkHC2QZTVTcjs.isFunction_default.call(void 0, getter) ? getter() : getter),
2630
- signal: res instanceof _chunkPK72FAKDcjs.VMSignal ? res : void 0,
2631
- lines_executed: Array.from(lines_executed),
2632
- return_value: res
2633
- };
2634
- }).catch((err) => handleErrorNode(err, code, consumer, traces, variables, lines_executed, state.currentToolCall)).catch((err) => handleCatch(err, traces, variables, lines_executed));
2635
- }
2636
- };
2637
-
2638
- // src/vm/drivers/quickjs.ts
2639
-
2640
-
2641
-
2642
- var _quickjsemscriptencore = require('quickjs-emscripten-core');
2643
- var _quickJSModule;
2644
- var _loadedVariant;
2645
- var loadQuickJSModule = () => {
2646
- const variant = _chunkRGUG3UMFcjs.getQuickJSVariant.call(void 0, );
2647
- if (!_quickJSModule || _loadedVariant !== variant) {
2648
- _loadedVariant = variant;
2649
- _quickJSModule = _quickjsemscriptencore.newQuickJSWASMModuleFromVariant.call(void 0, variant);
2650
- }
2651
- return _quickJSModule;
2652
- };
2653
- var QuickJSDriver = class {
2654
- async execute(ctx) {
2655
- const { transformed, consumer, context, traces, signal, timeout, code, lines_executed, variables } = ctx;
2656
- const userCodeStartLine = findUserCodeStartLine(transformed);
2657
- const state = instrumentContext(
2658
- context,
2659
- transformed,
2660
- traces,
2661
- variables,
2662
- lines_executed,
2663
- consumer,
2664
- userCodeStartLine
2665
- );
2666
- const QuickJS = await loadQuickJSModule();
2667
- const runtime = QuickJS.newRuntime();
2668
- runtime.setMemoryLimit(128 * 1024 * 1024);
2669
- const startTime = Date.now();
2670
- const timeoutHandler = _quickjsemscriptencore.shouldInterruptAfterDeadline.call(void 0, startTime + timeout);
2671
- runtime.setInterruptHandler(() => {
2672
- if (signal == null ? void 0 : signal.aborted) {
2673
- return true;
2674
- }
2675
- return timeoutHandler(runtime);
2676
- });
2677
- const vm = runtime.newContext();
2678
- const trackedProperties = /* @__PURE__ */ new Set();
2679
- const referenceProperties = /* @__PURE__ */ new Set();
2680
- const pendingPromises = [];
2681
- const toVmValue = (value) => {
2682
- var _a;
2683
- if (typeof value === "string") {
2684
- return vm.newString(value);
2685
- } else if (typeof value === "number") {
2686
- return vm.newNumber(value);
2687
- } else if (typeof value === "boolean") {
2688
- return value ? vm.true : vm.false;
2689
- } else if (value === null) {
2690
- return vm.null;
2691
- } else if (value === void 0) {
2692
- return vm.undefined;
2693
- } else if (Array.isArray(value)) {
2694
- const items = value.map((item) => {
2695
- if (typeof item === "string")
2696
- return JSON.stringify(item);
2697
- else if (typeof item === "number" || typeof item === "boolean")
2698
- return String(item);
2699
- else if (item === null)
2700
- return "null";
2701
- else if (item === void 0)
2702
- return "undefined";
2703
- else if (typeof item === "object")
2704
- return JSON.stringify(item);
2705
- return "undefined";
2706
- });
2707
- const result = vm.evalCode(`[${items.join(",")}]`);
2708
- if ("error" in result) {
2709
- (_a = result.error) == null ? void 0 : _a.dispose();
2710
- return vm.undefined;
2711
- }
2712
- return result.value;
2713
- } else if (typeof value === "object") {
2714
- const obj = vm.newObject();
2715
- for (const [k, v] of Object.entries(value)) {
2716
- if (typeof v !== "function") {
2717
- const propHandle = toVmValue(v);
2718
- vm.setProp(obj, k, propHandle);
2719
- disposeIfNeeded(propHandle);
2720
- }
2721
- }
2722
- return obj;
2723
- }
2724
- return vm.undefined;
2725
- };
2726
- const disposeIfNeeded = (handle) => {
2727
- if (handle !== vm.true && handle !== vm.false && handle !== vm.null && handle !== vm.undefined) {
2728
- ;
2729
- handle.dispose();
2730
- }
2731
- };
2732
- const bridgeFunction = (fn, _fnName = "anonymous") => {
2733
- return (...argHandles) => {
2734
- const args = argHandles.map((h) => vm.dump(h));
2735
- try {
2736
- const result = fn(...args);
2737
- if (result && typeof result.then === "function") {
2738
- const promise = vm.newPromise();
2739
- pendingPromises.push({ hostPromise: result, deferredPromise: promise });
2740
- void promise.settled.then(() => {
2741
- if (runtime.alive) {
2742
- runtime.executePendingJobs();
2743
- }
2744
- });
2745
- return promise.handle;
2746
- }
2747
- return toVmValue(result);
2748
- } catch (err) {
2749
- const serialized = err instanceof Error ? err.message : String(err);
2750
- throw new Error(serialized);
2751
- }
2752
- };
2753
- };
2754
- try {
2755
- bridgeContextToVM(context, vm, trackedProperties, referenceProperties, toVmValue, disposeIfNeeded, bridgeFunction);
2756
- setupVariableTrackingBridge(vm, variables);
2757
- const scriptCode = buildScriptCode(transformed.code);
2758
- const copyBackContextFromVM = () => {
2759
- for (const key of trackedProperties) {
2760
- if (referenceProperties.has(key))
2761
- continue;
2762
- try {
2763
- const valueResult = vm.evalCode(`globalThis['${key}']`);
2764
- const vmValue = vm.dump(valueResult.unwrap());
2765
- valueResult.unwrap().dispose();
2766
- try {
2767
- context[key] = vmValue;
2768
- } catch (e3) {
2769
- }
2770
- } catch (e4) {
2771
- }
2772
- }
2773
- };
2774
- const execResult = vm.evalCode(scriptCode, "<quickjs>");
2775
- if ("error" in execResult) {
2776
- if (execResult.error) {
2777
- const err = vm.dump(execResult.error);
2778
- execResult.error.dispose();
2779
- throw new Error((err == null ? void 0 : err.message) || "Execution failed");
2780
- }
2781
- throw new Error("Execution failed");
2782
- }
2783
- execResult.value.dispose();
2784
- await this._pumpEventLoop(runtime, vm, pendingPromises, signal, toVmValue, disposeIfNeeded);
2785
- const errorResult = vm.evalCode("globalThis.__llmz_error");
2786
- const errorValue = vm.dump(errorResult.unwrap());
2787
- errorResult.unwrap().dispose();
2788
- if (signal == null ? void 0 : signal.aborted) {
2789
- const reason = signal.reason;
2790
- if (reason instanceof Error)
2791
- throw reason;
2792
- throw new Error(reason ? String(reason) : "Execution was aborted");
2793
- }
2794
- if (errorValue !== null && errorValue !== "") {
2795
- try {
2796
- copyBackContextFromVM();
2797
- } catch (e5) {
2798
- }
2799
- const errorStackResult = vm.evalCode("globalThis.__llmz_error_stack");
2800
- const errorStack = vm.dump(errorStackResult.unwrap()) || "";
2801
- errorStackResult.unwrap().dispose();
2802
- const deserializedError = _chunkPK72FAKDcjs.Signals.maybeDeserializeError(errorValue);
2803
- if (deserializedError instanceof _chunkPK72FAKDcjs.VMSignal) {
2804
- deserializedError.stack = errorStack;
2805
- throw deserializedError;
2806
- }
2807
- const error = new Error(errorValue);
2808
- error.stack = errorStack;
2809
- throw error;
2810
- }
2811
- copyBackContextFromVM();
2812
- const resultSetResult = vm.evalCode("globalThis.__llmz_result_set");
2813
- const resultSet = vm.dump(resultSetResult.unwrap());
2814
- resultSetResult.unwrap().dispose();
2815
- let returnValue = void 0;
2816
- if (resultSet) {
2817
- const resultResult = vm.evalCode("globalThis.__llmz_result");
2818
- returnValue = vm.dump(resultResult.unwrap());
2819
- resultResult.unwrap().dispose();
2820
- }
2821
- returnValue = _chunkPK72FAKDcjs.Signals.maybeDeserializeError(returnValue);
2822
- return {
2823
- success: true,
2824
- variables: _chunkHC2QZTVTcjs.mapValues_default.call(void 0, variables, (getter) => _chunkHC2QZTVTcjs.isFunction_default.call(void 0, getter) ? getter() : getter),
2825
- signal: returnValue instanceof _chunkPK72FAKDcjs.VMSignal ? returnValue : void 0,
2826
- lines_executed: Array.from(lines_executed),
2827
- return_value: returnValue
2828
- };
2829
- } catch (err) {
2830
- if (signal == null ? void 0 : signal.aborted) {
2831
- const reason = signal.reason;
2832
- const abortError = reason instanceof Error ? reason : new Error(reason ? String(reason) : "Execution was aborted");
2833
- return handleErrorQuickJS(
2834
- abortError,
2835
- code,
2836
- consumer,
2837
- traces,
2838
- variables,
2839
- lines_executed,
2840
- userCodeStartLine,
2841
- _nullishCoalesce(ctx.currentToolCall, () => ( state.currentToolCall))
2842
- );
2843
- }
2844
- await Promise.all(
2845
- pendingPromises.map(async ({ hostPromise, deferredPromise }) => {
2846
- try {
2847
- const value = await hostPromise;
2848
- const vmValue = toVmValue(value);
2849
- deferredPromise.resolve(vmValue);
2850
- disposeIfNeeded(vmValue);
2851
- } catch (err2) {
2852
- const serialized = err2 instanceof Error ? err2.message : String(err2);
2853
- const errValue = vm.newString(serialized);
2854
- deferredPromise.reject(errValue);
2855
- errValue.dispose();
2856
- }
2857
- })
2858
- ).catch(() => {
2859
- });
2860
- return handleErrorQuickJS(
2861
- err,
2862
- code,
2863
- consumer,
2864
- traces,
2865
- variables,
2866
- lines_executed,
2867
- userCodeStartLine,
2868
- _nullishCoalesce(ctx.currentToolCall, () => ( state.currentToolCall))
2869
- );
2870
- } finally {
2871
- try {
2872
- vm.dispose();
2873
- } catch (e6) {
2874
- }
2875
- try {
2876
- runtime.dispose();
2877
- } catch (e7) {
2878
- }
2879
- }
2880
- }
2881
- // QuickJS has no event loop — we manually drain pending microtasks and resolve
2882
- // host promises in a loop until all async work completes or the signal aborts.
2883
- async _pumpEventLoop(runtime, vm, pendingPromises, signal, toVmValue, disposeIfNeeded) {
2884
- var _a;
2885
- const maxIterations = 1e3;
2886
- let iteration = 0;
2887
- while (iteration < maxIterations) {
2888
- let hasJobs = false;
2889
- const maxJobs = 1e4;
2890
- for (let i = 0; i < maxJobs; i++) {
2891
- const pending = (_a = runtime.executePendingJobs) == null ? void 0 : _a.call(runtime, -1);
2892
- const jobCount = pending === void 0 ? 0 : pending.unwrap();
2893
- if (jobCount <= 0)
2894
- break;
2895
- hasJobs = true;
2896
- }
2897
- const currentPromises = [...pendingPromises];
2898
- pendingPromises.length = 0;
2899
- if (currentPromises.length > 0) {
2900
- if (signal == null ? void 0 : signal.aborted) {
2901
- const reason = signal.reason;
2902
- const abortMessage = reason instanceof Error ? `${reason.name}: ${reason.message}` : reason ? String(reason) : "Execution was aborted";
2903
- for (const { deferredPromise } of currentPromises) {
2904
- const errValue = vm.newString(abortMessage);
2905
- deferredPromise.reject(errValue);
2906
- errValue.dispose();
2907
- }
2908
- runtime.executePendingJobs();
2909
- break;
2910
- }
2911
- let abortListener = null;
2912
- if (signal) {
2913
- abortListener = () => {
2914
- const reason = signal.reason;
2915
- const abortMessage = reason instanceof Error ? `${reason.name}: ${reason.message}` : reason ? String(reason) : "Execution was aborted";
2916
- for (const { deferredPromise } of currentPromises) {
2917
- const errValue = vm.newString(abortMessage);
2918
- deferredPromise.reject(errValue);
2919
- errValue.dispose();
2920
- }
2921
- runtime.executePendingJobs();
2922
- };
2923
- signal.addEventListener("abort", abortListener);
2924
- }
2925
- try {
2926
- await Promise.all(
2927
- currentPromises.map(async ({ hostPromise, deferredPromise }) => {
2928
- if (signal == null ? void 0 : signal.aborted)
2929
- return;
2930
- try {
2931
- const value = await hostPromise;
2932
- if (signal == null ? void 0 : signal.aborted)
2933
- return;
2934
- const vmValue = toVmValue(value);
2935
- deferredPromise.resolve(vmValue);
2936
- disposeIfNeeded(vmValue);
2937
- } catch (err) {
2938
- if (signal == null ? void 0 : signal.aborted)
2939
- return;
2940
- const serialized = err instanceof Error ? err.message : String(err);
2941
- const createErrorResult = vm.evalCode(`new Error(${JSON.stringify(serialized)})`);
2942
- if ("error" in createErrorResult) {
2943
- const errValue = vm.newString(serialized);
2944
- deferredPromise.reject(errValue);
2945
- errValue.dispose();
2946
- } else {
2947
- const errorHandle = createErrorResult.value;
2948
- deferredPromise.reject(errorHandle);
2949
- errorHandle.dispose();
2950
- }
2951
- }
2952
- })
2953
- );
2954
- } finally {
2955
- if (signal && abortListener) {
2956
- signal.removeEventListener("abort", abortListener);
2957
- }
2958
- }
2959
- runtime.executePendingJobs();
2960
- if (signal == null ? void 0 : signal.aborted)
2961
- break;
2962
- }
2963
- if (!hasJobs && pendingPromises.length === 0)
2964
- break;
2965
- iteration++;
2966
- }
2967
- if (iteration >= maxIterations) {
2968
- throw new Error("Maximum event loop iterations exceeded");
2969
- }
2970
- }
2971
- };
2972
- function bridgeContextToVM(context, vm, trackedProperties, referenceProperties, toVmValue, disposeIfNeeded, bridgeFunction) {
2973
- var _a, _b;
2974
- for (const [key, value] of Object.entries(context)) {
2975
- const descriptor = Object.getOwnPropertyDescriptor(context, key);
2976
- if (descriptor && (descriptor.get || descriptor.set)) {
2977
- referenceProperties.add(key);
2978
- trackedProperties.add(key);
2979
- bridgeGetterSetter(vm, key, void 0, descriptor, context, toVmValue);
2980
- continue;
2981
- }
2982
- if (typeof value === "function") {
2983
- const fnHandle = vm.newFunction(key, bridgeFunction(value, key));
2984
- vm.setProp(vm.global, key, fnHandle);
2985
- fnHandle.dispose();
2986
- } else if (Array.isArray(value)) {
2987
- trackedProperties.add(key);
2988
- const arrayHandle = toVmValue(value);
2989
- vm.setProp(vm.global, key, arrayHandle);
2990
- disposeIfNeeded(arrayHandle);
2991
- } else if (typeof value === "object" && value !== null) {
2992
- trackedProperties.add(key);
2993
- const objHandle = vm.newObject();
2994
- const props = /* @__PURE__ */ new Set([...Object.keys(value), ...Object.getOwnPropertyNames(value)]);
2995
- const getterSetterProps = [];
2996
- for (const prop of props) {
2997
- const propDescriptor = Object.getOwnPropertyDescriptor(value, prop);
2998
- if (propDescriptor && (propDescriptor.get || propDescriptor.set)) {
2999
- referenceProperties.add(`${key}.${prop}`);
3000
- getterSetterProps.push({ prop, descriptor: propDescriptor });
3001
- } else if (typeof value[prop] === "function") {
3002
- const propFnHandle = vm.newFunction(prop, bridgeFunction(value[prop], `${key}.${prop}`));
3003
- vm.setProp(objHandle, prop, propFnHandle);
3004
- propFnHandle.dispose();
3005
- } else {
3006
- const propHandle = toVmValue(value[prop]);
3007
- vm.setProp(objHandle, prop, propHandle);
3008
- disposeIfNeeded(propHandle);
3009
- }
3010
- }
3011
- vm.setProp(vm.global, key, objHandle);
3012
- objHandle.dispose();
3013
- for (const { prop, descriptor: descriptor2 } of getterSetterProps) {
3014
- bridgeGetterSetter(vm, key, prop, descriptor2, context, toVmValue);
3015
- }
3016
- if (Object.isSealed(value)) {
3017
- const sealResult = vm.evalCode(`Object.seal(globalThis['${key}']);`);
3018
- if ("error" in sealResult)
3019
- (_a = sealResult.error) == null ? void 0 : _a.dispose();
3020
- else
3021
- sealResult.value.dispose();
3022
- }
3023
- if (!Object.isExtensible(value)) {
3024
- const preventResult = vm.evalCode(`Object.preventExtensions(globalThis['${key}']);`);
3025
- if ("error" in preventResult)
3026
- (_b = preventResult.error) == null ? void 0 : _b.dispose();
3027
- else
3028
- preventResult.value.dispose();
3029
- }
3030
- } else {
3031
- trackedProperties.add(key);
3032
- const valueHandle = toVmValue(value);
3033
- vm.setProp(vm.global, key, valueHandle);
3034
- disposeIfNeeded(valueHandle);
3035
- }
3036
- }
3037
- }
3038
- function bridgeGetterSetter(vm, key, prop, descriptor, context, toVmValue) {
3039
- var _a;
3040
- const target = prop ? `${key}` : "globalThis";
3041
- const propName = _nullishCoalesce(prop, () => ( key));
3042
- const prefix = prop ? `${key}_${prop}` : key;
3043
- let getterCode = "undefined";
3044
- if (descriptor.get) {
3045
- const getterBridge = vm.newFunction(`get_${propName}`, () => {
3046
- try {
3047
- const hostValue = prop ? context[key][prop] : context[key];
3048
- return toVmValue(hostValue);
3049
- } catch (err) {
3050
- throw new Error(err instanceof Error ? err.message : String(err));
3051
- }
3052
- });
3053
- const getterName = `__getter_${prefix}__`;
3054
- vm.setProp(vm.global, getterName, getterBridge);
3055
- getterBridge.dispose();
3056
- getterCode = getterName;
3057
- }
3058
- let setterCode = "undefined";
3059
- if (descriptor.set) {
3060
- const setterBridge = vm.newFunction(`set_${propName}`, (valueHandle) => {
3061
- try {
3062
- const jsValue = vm.dump(valueHandle);
3063
- if (prop) {
3064
- context[key][prop] = jsValue;
3065
- } else {
3066
- context[key] = jsValue;
3067
- }
3068
- return vm.undefined;
3069
- } catch (err) {
3070
- throw new Error(err instanceof Error ? err.message : String(err));
3071
- }
3072
- });
3073
- const setterName = `__setter_${prefix}__`;
3074
- vm.setProp(vm.global, setterName, setterBridge);
3075
- setterBridge.dispose();
3076
- setterCode = setterName;
3077
- }
3078
- const definePropertyCode = `
3079
- Object.defineProperty(${target}, '${propName}', {
3080
- enumerable: true,
3081
- configurable: ${descriptor.configurable !== false},
3082
- get: ${getterCode},
3083
- set: ${setterCode}
3084
- });
3085
- `;
3086
- const result = vm.evalCode(definePropertyCode);
3087
- if ("error" in result)
3088
- (_a = result.error) == null ? void 0 : _a.dispose();
3089
- else
3090
- result.value.dispose();
3091
- }
3092
- function setupVariableTrackingBridge(vm, variables) {
3093
- const varTrackFnHandle = vm.newFunction(
3094
- Identifiers.VariableTrackingFnIdentifier,
3095
- (nameHandle, getterHandle) => {
3096
- var _a;
3097
- const name = vm.getString(nameHandle);
3098
- if (NO_TRACKING.includes(name))
3099
- return;
3100
- try {
3101
- const valueResult = vm.callFunction(getterHandle, vm.undefined);
3102
- if ("error" in valueResult) {
3103
- variables[name] = "[[non-primitive]]";
3104
- (_a = valueResult.error) == null ? void 0 : _a.dispose();
3105
- return;
3106
- }
3107
- const value = vm.dump(valueResult.value);
3108
- valueResult.value.dispose();
3109
- if (typeof value === "function" || typeof value === "string" && value.includes("=>")) {
3110
- variables[name] = "[[non-primitive]]";
3111
- } else {
3112
- variables[name] = value;
3113
- }
3114
- } catch (e8) {
3115
- variables[name] = "[[non-primitive]]";
3116
- }
3117
- }
3118
- );
3119
- vm.setProp(vm.global, Identifiers.VariableTrackingFnIdentifier, varTrackFnHandle);
3120
- varTrackFnHandle.dispose();
3121
- }
3122
- function buildScriptCode(transformedCode) {
3123
- return `
3124
- "use strict";
3125
- globalThis.__llmz_result = undefined;
3126
- globalThis.__llmz_result_set = false;
3127
- globalThis.__llmz_error = null;
3128
- globalThis.__llmz_error_stack = null;
3129
-
3130
- (async () => {
3131
- try {
3132
- async function __fn__() {
3133
- ${transformedCode}
3134
- }
3135
-
3136
- globalThis.__llmz_result = await __fn__();
3137
- globalThis.__llmz_result_set = true;
3138
- } catch (err) {
3139
- globalThis.__llmz_error = typeof err === 'string' ? err : String(err.message || err || '');
3140
- globalThis.__llmz_error_stack = '' + (err.stack || '');
3141
- }
3142
- })();
3143
- `.trim();
3144
- }
3145
-
3146
- // src/vm/index.ts
3147
- var MAX_VM_EXECUTION_TIME = 6e4;
3148
- var useQuickJS = () => {
3149
- var _a;
3150
- return typeof process === "undefined" || ((_a = process == null ? void 0 : process.env) == null ? void 0 : _a.USE_QUICKJS) !== "false";
3151
- };
3152
- var isWorkerd = () => typeof navigator !== "undefined" && (navigator == null ? void 0 : navigator.userAgent) === "Cloudflare-Workers";
3153
- var warmupVM = () => {
3154
- if (useQuickJS()) {
3155
- loadQuickJSModule().catch(() => {
3156
- });
3157
- }
3158
- };
3159
- async function runAsyncFunction(context, code, traces = [], signal = null, timeout = MAX_VM_EXECUTION_TIME) {
3160
- const transformed = (() => {
3161
- try {
3162
- return compile(code);
3163
- } catch (err) {
3164
- traces.push({
3165
- type: "invalid_code_exception",
3166
- message: _nullishCoalesce((err == null ? void 0 : err.message), () => ( "Unknown error")),
3167
- code,
3168
- started_at: Date.now()
3169
- });
3170
- throw new (0, _chunkPK72FAKDcjs.InvalidCodeError)(err.message, code);
3171
- }
3172
- })();
3173
- const lines_executed = /* @__PURE__ */ new Map();
3174
- const variables = {};
3175
- const consumer = new import_source_map_js.SourceMapConsumer({
3176
- version: transformed.map.version.toString(),
3177
- mappings: transformed.map.mappings,
3178
- names: transformed.map.names,
3179
- sources: transformed.map.sources,
3180
- sourcesContent: [transformed.code],
3181
- file: transformed.map.file
3182
- });
3183
- context ??= {};
3184
- for (const name of Array.from(transformed.variables)) {
3185
- delete context[name];
3186
- }
3187
- let driver;
3188
- if (useQuickJS()) {
3189
- try {
3190
- driver = new QuickJSDriver();
3191
- return await driver.execute({
3192
- transformed,
3193
- consumer,
3194
- context,
3195
- traces,
3196
- signal,
3197
- timeout,
3198
- code,
3199
- lines_executed,
3200
- variables,
3201
- currentToolCall: void 0
3202
- });
3203
- } catch (quickjsError) {
3204
- const variant = _chunkRGUG3UMFcjs.getQuickJSVariant.call(void 0, );
3205
- const debugInfo = {
3206
- error: (quickjsError == null ? void 0 : quickjsError.message) || String(quickjsError),
3207
- errorStack: quickjsError == null ? void 0 : quickjsError.stack,
3208
- wasmSource: variant._wasmSource,
3209
- wasmLoadedSuccessfully: variant._wasmLoadedSuccessfully,
3210
- wasmSize: variant._wasmSize,
3211
- wasmLoadError: variant._wasmLoadError,
3212
- nodeVersion: typeof process !== "undefined" && process.version ? process.version : "undefined",
3213
- platform: typeof process !== "undefined" && process.platform ? process.platform : "undefined"
3214
- };
3215
- if (isWorkerd()) {
3216
- console.error("QuickJS failed to load and the node driver is unavailable on Cloudflare Workers.");
3217
- console.error("Debug info:", JSON.stringify(debugInfo, null, 2));
3218
- if (quickjsError instanceof Error) {
3219
- ;
3220
- quickjsError.debugInfo = debugInfo;
3221
- throw quickjsError;
3222
- }
3223
- throw new Error(`QuickJS failed to load on Cloudflare Workers: ${debugInfo.error}`);
3224
- }
3225
- console.warn("QuickJS failed to load, falling back to node driver.");
3226
- console.warn("Error:", (quickjsError == null ? void 0 : quickjsError.message) || quickjsError);
3227
- console.warn("Debug info:", JSON.stringify(debugInfo, null, 2));
3228
- }
3229
- }
3230
- driver = new NodeDriver();
3231
- return await driver.execute({
3232
- transformed,
3233
- consumer,
3234
- context,
3235
- traces,
3236
- signal,
3237
- timeout,
3238
- code,
3239
- lines_executed,
3240
- variables,
3241
- currentToolCall: void 0
3242
- });
3243
- }
3244
-
3245
-
3246
-
3247
-
3248
-
3249
- exports.hasTopLevelReturn = hasTopLevelReturn; exports.warmupVM = warmupVM; exports.runAsyncFunction = runAsyncFunction;