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