@synergenius/flow-weaver 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/compile.js +1 -3
- package/dist/api/generate.js +7 -3
- package/dist/api/inline-runtime.d.ts +11 -2
- package/dist/api/inline-runtime.js +31 -4
- package/dist/cli/flow-weaver.mjs +2623 -177
- package/dist/generated-version.d.ts +2 -0
- package/dist/generated-version.js +3 -0
- package/package.json +2 -1
package/dist/cli/flow-weaver.mjs
CHANGED
|
@@ -3127,13 +3127,39 @@ var init_unescape = __esm({
|
|
|
3127
3127
|
});
|
|
3128
3128
|
|
|
3129
3129
|
// node_modules/minimatch/dist/esm/ast.js
|
|
3130
|
-
var types, isExtglobType, startNoTraversal, startNoDot, addPatternStart, justDots, reSpecials, regExpEscape, qmark, star, starNoEmpty, AST;
|
|
3130
|
+
var _a, types, isExtglobType, isExtglobAST, adoptionMap, adoptionWithSpaceMap, adoptionAnyMap, usurpMap, startNoTraversal, startNoDot, addPatternStart, justDots, reSpecials, regExpEscape, qmark, star, starNoEmpty, AST;
|
|
3131
3131
|
var init_ast = __esm({
|
|
3132
3132
|
"node_modules/minimatch/dist/esm/ast.js"() {
|
|
3133
3133
|
init_brace_expressions();
|
|
3134
3134
|
init_unescape();
|
|
3135
3135
|
types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
|
|
3136
3136
|
isExtglobType = (c) => types.has(c);
|
|
3137
|
+
isExtglobAST = (c) => isExtglobType(c.type);
|
|
3138
|
+
adoptionMap = /* @__PURE__ */ new Map([
|
|
3139
|
+
["!", ["@"]],
|
|
3140
|
+
["?", ["?", "@"]],
|
|
3141
|
+
["@", ["@"]],
|
|
3142
|
+
["*", ["*", "+", "?", "@"]],
|
|
3143
|
+
["+", ["+", "@"]]
|
|
3144
|
+
]);
|
|
3145
|
+
adoptionWithSpaceMap = /* @__PURE__ */ new Map([
|
|
3146
|
+
["!", ["?"]],
|
|
3147
|
+
["@", ["?"]],
|
|
3148
|
+
["+", ["?", "*"]]
|
|
3149
|
+
]);
|
|
3150
|
+
adoptionAnyMap = /* @__PURE__ */ new Map([
|
|
3151
|
+
["!", ["?", "@"]],
|
|
3152
|
+
["?", ["?", "@"]],
|
|
3153
|
+
["@", ["?", "@"]],
|
|
3154
|
+
["*", ["*", "+", "?", "@"]],
|
|
3155
|
+
["+", ["+", "@", "?", "*"]]
|
|
3156
|
+
]);
|
|
3157
|
+
usurpMap = /* @__PURE__ */ new Map([
|
|
3158
|
+
["!", /* @__PURE__ */ new Map([["!", "@"]])],
|
|
3159
|
+
["?", /* @__PURE__ */ new Map([["*", "*"], ["+", "*"]])],
|
|
3160
|
+
["@", /* @__PURE__ */ new Map([["!", "!"], ["?", "?"], ["@", "@"], ["*", "*"], ["+", "+"]])],
|
|
3161
|
+
["+", /* @__PURE__ */ new Map([["?", "*"], ["*", "*"]])]
|
|
3162
|
+
]);
|
|
3137
3163
|
startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
3138
3164
|
startNoDot = "(?!\\.)";
|
|
3139
3165
|
addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
@@ -3143,7 +3169,7 @@ var init_ast = __esm({
|
|
|
3143
3169
|
qmark = "[^/]";
|
|
3144
3170
|
star = qmark + "*?";
|
|
3145
3171
|
starNoEmpty = qmark + "+?";
|
|
3146
|
-
AST = class
|
|
3172
|
+
AST = class {
|
|
3147
3173
|
type;
|
|
3148
3174
|
#root;
|
|
3149
3175
|
#hasMagic;
|
|
@@ -3223,7 +3249,7 @@ var init_ast = __esm({
|
|
|
3223
3249
|
for (const p of parts2) {
|
|
3224
3250
|
if (p === "")
|
|
3225
3251
|
continue;
|
|
3226
|
-
if (typeof p !== "string" && !(p instanceof
|
|
3252
|
+
if (typeof p !== "string" && !(p instanceof _a && p.#parent === this)) {
|
|
3227
3253
|
throw new Error("invalid part: " + p);
|
|
3228
3254
|
}
|
|
3229
3255
|
this.#parts.push(p);
|
|
@@ -3248,7 +3274,7 @@ var init_ast = __esm({
|
|
|
3248
3274
|
const p = this.#parent;
|
|
3249
3275
|
for (let i = 0; i < this.#parentIndex; i++) {
|
|
3250
3276
|
const pp = p.#parts[i];
|
|
3251
|
-
if (!(pp instanceof
|
|
3277
|
+
if (!(pp instanceof _a && pp.type === "!")) {
|
|
3252
3278
|
return false;
|
|
3253
3279
|
}
|
|
3254
3280
|
}
|
|
@@ -3273,13 +3299,14 @@ var init_ast = __esm({
|
|
|
3273
3299
|
this.push(part.clone(this));
|
|
3274
3300
|
}
|
|
3275
3301
|
clone(parent) {
|
|
3276
|
-
const c = new
|
|
3302
|
+
const c = new _a(this.type, parent);
|
|
3277
3303
|
for (const p of this.#parts) {
|
|
3278
3304
|
c.copyIn(p);
|
|
3279
3305
|
}
|
|
3280
3306
|
return c;
|
|
3281
3307
|
}
|
|
3282
|
-
static #parseAST(str2, ast, pos, opt) {
|
|
3308
|
+
static #parseAST(str2, ast, pos, opt, extDepth) {
|
|
3309
|
+
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
3283
3310
|
let escaping = false;
|
|
3284
3311
|
let inBrace = false;
|
|
3285
3312
|
let braceStart = -1;
|
|
@@ -3311,11 +3338,12 @@ var init_ast = __esm({
|
|
|
3311
3338
|
acc2 += c;
|
|
3312
3339
|
continue;
|
|
3313
3340
|
}
|
|
3314
|
-
|
|
3341
|
+
const doRecurse = !opt.noext && isExtglobType(c) && str2.charAt(i2) === "(" && extDepth <= maxDepth;
|
|
3342
|
+
if (doRecurse) {
|
|
3315
3343
|
ast.push(acc2);
|
|
3316
3344
|
acc2 = "";
|
|
3317
|
-
const ext2 = new
|
|
3318
|
-
i2 =
|
|
3345
|
+
const ext2 = new _a(c, ast);
|
|
3346
|
+
i2 = _a.#parseAST(str2, ext2, i2, opt, extDepth + 1);
|
|
3319
3347
|
ast.push(ext2);
|
|
3320
3348
|
continue;
|
|
3321
3349
|
}
|
|
@@ -3325,7 +3353,7 @@ var init_ast = __esm({
|
|
|
3325
3353
|
return i2;
|
|
3326
3354
|
}
|
|
3327
3355
|
let i = pos + 1;
|
|
3328
|
-
let part = new
|
|
3356
|
+
let part = new _a(null, ast);
|
|
3329
3357
|
const parts2 = [];
|
|
3330
3358
|
let acc = "";
|
|
3331
3359
|
while (i < str2.length) {
|
|
@@ -3352,19 +3380,22 @@ var init_ast = __esm({
|
|
|
3352
3380
|
acc += c;
|
|
3353
3381
|
continue;
|
|
3354
3382
|
}
|
|
3355
|
-
|
|
3383
|
+
const doRecurse = isExtglobType(c) && str2.charAt(i) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
|
|
3384
|
+
(extDepth <= maxDepth || ast && ast.#canAdoptType(c));
|
|
3385
|
+
if (doRecurse) {
|
|
3386
|
+
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
3356
3387
|
part.push(acc);
|
|
3357
3388
|
acc = "";
|
|
3358
|
-
const ext2 = new
|
|
3389
|
+
const ext2 = new _a(c, part);
|
|
3359
3390
|
part.push(ext2);
|
|
3360
|
-
i =
|
|
3391
|
+
i = _a.#parseAST(str2, ext2, i, opt, extDepth + depthAdd);
|
|
3361
3392
|
continue;
|
|
3362
3393
|
}
|
|
3363
3394
|
if (c === "|") {
|
|
3364
3395
|
part.push(acc);
|
|
3365
3396
|
acc = "";
|
|
3366
3397
|
parts2.push(part);
|
|
3367
|
-
part = new
|
|
3398
|
+
part = new _a(null, ast);
|
|
3368
3399
|
continue;
|
|
3369
3400
|
}
|
|
3370
3401
|
if (c === ")") {
|
|
@@ -3383,9 +3414,101 @@ var init_ast = __esm({
|
|
|
3383
3414
|
ast.#parts = [str2.substring(pos - 1)];
|
|
3384
3415
|
return i;
|
|
3385
3416
|
}
|
|
3417
|
+
#canAdoptWithSpace(child) {
|
|
3418
|
+
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
3419
|
+
}
|
|
3420
|
+
#canAdopt(child, map3 = adoptionMap) {
|
|
3421
|
+
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) {
|
|
3422
|
+
return false;
|
|
3423
|
+
}
|
|
3424
|
+
const gc = child.#parts[0];
|
|
3425
|
+
if (!gc || typeof gc !== "object" || gc.type === null) {
|
|
3426
|
+
return false;
|
|
3427
|
+
}
|
|
3428
|
+
return this.#canAdoptType(gc.type, map3);
|
|
3429
|
+
}
|
|
3430
|
+
#canAdoptType(c, map3 = adoptionAnyMap) {
|
|
3431
|
+
return !!map3.get(this.type)?.includes(c);
|
|
3432
|
+
}
|
|
3433
|
+
#adoptWithSpace(child, index) {
|
|
3434
|
+
const gc = child.#parts[0];
|
|
3435
|
+
const blank = new _a(null, gc, this.options);
|
|
3436
|
+
blank.#parts.push("");
|
|
3437
|
+
gc.push(blank);
|
|
3438
|
+
this.#adopt(child, index);
|
|
3439
|
+
}
|
|
3440
|
+
#adopt(child, index) {
|
|
3441
|
+
const gc = child.#parts[0];
|
|
3442
|
+
this.#parts.splice(index, 1, ...gc.#parts);
|
|
3443
|
+
for (const p of gc.#parts) {
|
|
3444
|
+
if (typeof p === "object")
|
|
3445
|
+
p.#parent = this;
|
|
3446
|
+
}
|
|
3447
|
+
this.#toString = void 0;
|
|
3448
|
+
}
|
|
3449
|
+
#canUsurpType(c) {
|
|
3450
|
+
const m = usurpMap.get(this.type);
|
|
3451
|
+
return !!m?.has(c);
|
|
3452
|
+
}
|
|
3453
|
+
#canUsurp(child) {
|
|
3454
|
+
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) {
|
|
3455
|
+
return false;
|
|
3456
|
+
}
|
|
3457
|
+
const gc = child.#parts[0];
|
|
3458
|
+
if (!gc || typeof gc !== "object" || gc.type === null) {
|
|
3459
|
+
return false;
|
|
3460
|
+
}
|
|
3461
|
+
return this.#canUsurpType(gc.type);
|
|
3462
|
+
}
|
|
3463
|
+
#usurp(child) {
|
|
3464
|
+
const m = usurpMap.get(this.type);
|
|
3465
|
+
const gc = child.#parts[0];
|
|
3466
|
+
const nt = m?.get(gc.type);
|
|
3467
|
+
if (!nt)
|
|
3468
|
+
return false;
|
|
3469
|
+
this.#parts = gc.#parts;
|
|
3470
|
+
for (const p of this.#parts) {
|
|
3471
|
+
if (typeof p === "object")
|
|
3472
|
+
p.#parent = this;
|
|
3473
|
+
}
|
|
3474
|
+
this.type = nt;
|
|
3475
|
+
this.#toString = void 0;
|
|
3476
|
+
this.#emptyExt = false;
|
|
3477
|
+
}
|
|
3478
|
+
#flatten() {
|
|
3479
|
+
if (!isExtglobAST(this)) {
|
|
3480
|
+
for (const p of this.#parts) {
|
|
3481
|
+
if (typeof p === "object")
|
|
3482
|
+
p.#flatten();
|
|
3483
|
+
}
|
|
3484
|
+
} else {
|
|
3485
|
+
let iterations = 0;
|
|
3486
|
+
let done = false;
|
|
3487
|
+
do {
|
|
3488
|
+
done = true;
|
|
3489
|
+
for (let i = 0; i < this.#parts.length; i++) {
|
|
3490
|
+
const c = this.#parts[i];
|
|
3491
|
+
if (typeof c === "object") {
|
|
3492
|
+
c.#flatten();
|
|
3493
|
+
if (this.#canAdopt(c)) {
|
|
3494
|
+
done = false;
|
|
3495
|
+
this.#adopt(c, i);
|
|
3496
|
+
} else if (this.#canAdoptWithSpace(c)) {
|
|
3497
|
+
done = false;
|
|
3498
|
+
this.#adoptWithSpace(c, i);
|
|
3499
|
+
} else if (this.#canUsurp(c)) {
|
|
3500
|
+
done = false;
|
|
3501
|
+
this.#usurp(c);
|
|
3502
|
+
}
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
} while (!done && ++iterations < 10);
|
|
3506
|
+
}
|
|
3507
|
+
this.#toString = void 0;
|
|
3508
|
+
}
|
|
3386
3509
|
static fromGlob(pattern, options = {}) {
|
|
3387
|
-
const ast = new
|
|
3388
|
-
|
|
3510
|
+
const ast = new _a(null, void 0, options);
|
|
3511
|
+
_a.#parseAST(pattern, ast, 0, options, 0);
|
|
3389
3512
|
return ast;
|
|
3390
3513
|
}
|
|
3391
3514
|
// returns the regular expression if there's magic, or the unescaped
|
|
@@ -3479,12 +3602,14 @@ var init_ast = __esm({
|
|
|
3479
3602
|
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
3480
3603
|
toRegExpSource(allowDot) {
|
|
3481
3604
|
const dot = allowDot ?? !!this.#options.dot;
|
|
3482
|
-
if (this.#root === this)
|
|
3605
|
+
if (this.#root === this) {
|
|
3606
|
+
this.#flatten();
|
|
3483
3607
|
this.#fillNegs();
|
|
3484
|
-
|
|
3608
|
+
}
|
|
3609
|
+
if (!isExtglobAST(this)) {
|
|
3485
3610
|
const noEmpty = this.isStart() && this.isEnd();
|
|
3486
3611
|
const src = this.#parts.map((p) => {
|
|
3487
|
-
const [re2, _, hasMagic2, uflag] = typeof p === "string" ?
|
|
3612
|
+
const [re2, _, hasMagic2, uflag] = typeof p === "string" ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
3488
3613
|
this.#hasMagic = this.#hasMagic || hasMagic2;
|
|
3489
3614
|
this.#uflag = this.#uflag || uflag;
|
|
3490
3615
|
return re2;
|
|
@@ -3523,9 +3648,10 @@ var init_ast = __esm({
|
|
|
3523
3648
|
let body = this.#partsToRegExp(dot);
|
|
3524
3649
|
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
3525
3650
|
const s = this.toString();
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3651
|
+
const me = this;
|
|
3652
|
+
me.#parts = [s];
|
|
3653
|
+
me.type = null;
|
|
3654
|
+
me.#hasMagic = void 0;
|
|
3529
3655
|
return [s, unescape2(this.toString()), false, false];
|
|
3530
3656
|
}
|
|
3531
3657
|
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
|
|
@@ -3566,11 +3692,13 @@ var init_ast = __esm({
|
|
|
3566
3692
|
let escaping = false;
|
|
3567
3693
|
let re2 = "";
|
|
3568
3694
|
let uflag = false;
|
|
3695
|
+
let inStar = false;
|
|
3569
3696
|
for (let i = 0; i < glob2.length; i++) {
|
|
3570
3697
|
const c = glob2.charAt(i);
|
|
3571
3698
|
if (escaping) {
|
|
3572
3699
|
escaping = false;
|
|
3573
3700
|
re2 += (reSpecials.has(c) ? "\\" : "") + c;
|
|
3701
|
+
inStar = false;
|
|
3574
3702
|
continue;
|
|
3575
3703
|
}
|
|
3576
3704
|
if (c === "\\") {
|
|
@@ -3588,16 +3716,19 @@ var init_ast = __esm({
|
|
|
3588
3716
|
uflag = uflag || needUflag;
|
|
3589
3717
|
i += consumed - 1;
|
|
3590
3718
|
hasMagic2 = hasMagic2 || magic;
|
|
3719
|
+
inStar = false;
|
|
3591
3720
|
continue;
|
|
3592
3721
|
}
|
|
3593
3722
|
}
|
|
3594
3723
|
if (c === "*") {
|
|
3595
|
-
if (
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3724
|
+
if (inStar)
|
|
3725
|
+
continue;
|
|
3726
|
+
inStar = true;
|
|
3727
|
+
re2 += noEmpty && /^[*]+$/.test(glob2) ? starNoEmpty : star;
|
|
3599
3728
|
hasMagic2 = true;
|
|
3600
3729
|
continue;
|
|
3730
|
+
} else {
|
|
3731
|
+
inStar = false;
|
|
3601
3732
|
}
|
|
3602
3733
|
if (c === "?") {
|
|
3603
3734
|
re2 += qmark;
|
|
@@ -3609,6 +3740,7 @@ var init_ast = __esm({
|
|
|
3609
3740
|
return [re2, unescape2(glob2), !!hasMagic2, uflag];
|
|
3610
3741
|
}
|
|
3611
3742
|
};
|
|
3743
|
+
_a = AST;
|
|
3612
3744
|
}
|
|
3613
3745
|
});
|
|
3614
3746
|
|
|
@@ -3782,11 +3914,13 @@ var init_esm = __esm({
|
|
|
3782
3914
|
isWindows;
|
|
3783
3915
|
platform;
|
|
3784
3916
|
windowsNoMagicRoot;
|
|
3917
|
+
maxGlobstarRecursion;
|
|
3785
3918
|
regexp;
|
|
3786
3919
|
constructor(pattern, options = {}) {
|
|
3787
3920
|
assertValidPattern(pattern);
|
|
3788
3921
|
options = options || {};
|
|
3789
3922
|
this.options = options;
|
|
3923
|
+
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
3790
3924
|
this.pattern = pattern;
|
|
3791
3925
|
this.platform = options.platform || defaultPlatform;
|
|
3792
3926
|
this.isWindows = this.platform === "win32";
|
|
@@ -4119,7 +4253,8 @@ var init_esm = __esm({
|
|
|
4119
4253
|
// out of pattern, then that's fine, as long as all
|
|
4120
4254
|
// the parts match.
|
|
4121
4255
|
matchOne(file, pattern, partial2 = false) {
|
|
4122
|
-
|
|
4256
|
+
let fileStartIndex = 0;
|
|
4257
|
+
let patternStartIndex = 0;
|
|
4123
4258
|
if (this.isWindows) {
|
|
4124
4259
|
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
4125
4260
|
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
@@ -4128,14 +4263,14 @@ var init_esm = __esm({
|
|
|
4128
4263
|
const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
|
|
4129
4264
|
const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
|
|
4130
4265
|
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
4131
|
-
const [fd, pd] = [
|
|
4266
|
+
const [fd, pd] = [
|
|
4267
|
+
file[fdi],
|
|
4268
|
+
pattern[pdi]
|
|
4269
|
+
];
|
|
4132
4270
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
4133
4271
|
pattern[pdi] = fd;
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
} else if (fdi > pdi) {
|
|
4137
|
-
file = file.slice(fdi);
|
|
4138
|
-
}
|
|
4272
|
+
patternStartIndex = pdi;
|
|
4273
|
+
fileStartIndex = fdi;
|
|
4139
4274
|
}
|
|
4140
4275
|
}
|
|
4141
4276
|
}
|
|
@@ -4143,51 +4278,118 @@ var init_esm = __esm({
|
|
|
4143
4278
|
if (optimizationLevel >= 2) {
|
|
4144
4279
|
file = this.levelTwoFileOptimize(file);
|
|
4145
4280
|
}
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4281
|
+
if (pattern.includes(GLOBSTAR)) {
|
|
4282
|
+
return this.#matchGlobstar(file, pattern, partial2, fileStartIndex, patternStartIndex);
|
|
4283
|
+
}
|
|
4284
|
+
return this.#matchOne(file, pattern, partial2, fileStartIndex, patternStartIndex);
|
|
4285
|
+
}
|
|
4286
|
+
#matchGlobstar(file, pattern, partial2, fileIndex, patternIndex) {
|
|
4287
|
+
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
|
4288
|
+
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
4289
|
+
const [head2, body, tail] = partial2 ? [
|
|
4290
|
+
pattern.slice(patternIndex, firstgs),
|
|
4291
|
+
pattern.slice(firstgs + 1),
|
|
4292
|
+
[]
|
|
4293
|
+
] : [
|
|
4294
|
+
pattern.slice(patternIndex, firstgs),
|
|
4295
|
+
pattern.slice(firstgs + 1, lastgs),
|
|
4296
|
+
pattern.slice(lastgs + 1)
|
|
4297
|
+
];
|
|
4298
|
+
if (head2.length) {
|
|
4299
|
+
const fileHead = file.slice(fileIndex, fileIndex + head2.length);
|
|
4300
|
+
if (!this.#matchOne(fileHead, head2, partial2, 0, 0))
|
|
4154
4301
|
return false;
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
return
|
|
4302
|
+
fileIndex += head2.length;
|
|
4303
|
+
}
|
|
4304
|
+
let fileTailMatch = 0;
|
|
4305
|
+
if (tail.length) {
|
|
4306
|
+
if (tail.length + fileIndex > file.length)
|
|
4307
|
+
return false;
|
|
4308
|
+
let tailStart = file.length - tail.length;
|
|
4309
|
+
if (this.#matchOne(file, tail, partial2, tailStart, 0)) {
|
|
4310
|
+
fileTailMatch = tail.length;
|
|
4311
|
+
} else {
|
|
4312
|
+
if (file[file.length - 1] !== "" || fileIndex + tail.length === file.length) {
|
|
4313
|
+
return false;
|
|
4167
4314
|
}
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
}
|
|
4315
|
+
tailStart--;
|
|
4316
|
+
if (!this.#matchOne(file, tail, partial2, tailStart, 0))
|
|
4317
|
+
return false;
|
|
4318
|
+
fileTailMatch = tail.length + 1;
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4321
|
+
if (!body.length) {
|
|
4322
|
+
let sawSome = !!fileTailMatch;
|
|
4323
|
+
for (let i2 = fileIndex; i2 < file.length - fileTailMatch; i2++) {
|
|
4324
|
+
const f = String(file[i2]);
|
|
4325
|
+
sawSome = true;
|
|
4326
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
|
|
4327
|
+
return false;
|
|
4182
4328
|
}
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4329
|
+
}
|
|
4330
|
+
return partial2 || sawSome;
|
|
4331
|
+
}
|
|
4332
|
+
const bodySegments = [[[], 0]];
|
|
4333
|
+
let currentBody = bodySegments[0];
|
|
4334
|
+
let nonGsParts = 0;
|
|
4335
|
+
const nonGsPartsSums = [0];
|
|
4336
|
+
for (const b of body) {
|
|
4337
|
+
if (b === GLOBSTAR) {
|
|
4338
|
+
nonGsPartsSums.push(nonGsParts);
|
|
4339
|
+
currentBody = [[], 0];
|
|
4340
|
+
bodySegments.push(currentBody);
|
|
4341
|
+
} else {
|
|
4342
|
+
currentBody[0].push(b);
|
|
4343
|
+
nonGsParts++;
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
let i = bodySegments.length - 1;
|
|
4347
|
+
const fileLength = file.length - fileTailMatch;
|
|
4348
|
+
for (const b of bodySegments) {
|
|
4349
|
+
b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
4350
|
+
}
|
|
4351
|
+
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial2, 0, !!fileTailMatch);
|
|
4352
|
+
}
|
|
4353
|
+
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial2, globStarDepth, sawTail) {
|
|
4354
|
+
const bs = bodySegments[bodyIndex];
|
|
4355
|
+
if (!bs) {
|
|
4356
|
+
for (let i = fileIndex; i < file.length; i++) {
|
|
4357
|
+
sawTail = true;
|
|
4358
|
+
const f = file[i];
|
|
4359
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
|
|
4360
|
+
return false;
|
|
4188
4361
|
}
|
|
4362
|
+
}
|
|
4363
|
+
return sawTail;
|
|
4364
|
+
}
|
|
4365
|
+
const [body, after] = bs;
|
|
4366
|
+
while (fileIndex <= after) {
|
|
4367
|
+
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial2, fileIndex, 0);
|
|
4368
|
+
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
4369
|
+
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial2, globStarDepth + 1, sawTail);
|
|
4370
|
+
if (sub !== false)
|
|
4371
|
+
return sub;
|
|
4372
|
+
}
|
|
4373
|
+
const f = file[fileIndex];
|
|
4374
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
|
|
4189
4375
|
return false;
|
|
4190
4376
|
}
|
|
4377
|
+
fileIndex++;
|
|
4378
|
+
}
|
|
4379
|
+
return partial2 || null;
|
|
4380
|
+
}
|
|
4381
|
+
#matchOne(file, pattern, partial2, fileIndex, patternIndex) {
|
|
4382
|
+
let fi;
|
|
4383
|
+
let pi;
|
|
4384
|
+
let pl;
|
|
4385
|
+
let fl;
|
|
4386
|
+
for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
4387
|
+
this.debug("matchOne loop");
|
|
4388
|
+
let p = pattern[pi];
|
|
4389
|
+
let f = file[fi];
|
|
4390
|
+
this.debug(pattern, p, f);
|
|
4391
|
+
if (p === false || p === GLOBSTAR)
|
|
4392
|
+
return false;
|
|
4191
4393
|
let hit;
|
|
4192
4394
|
if (typeof p === "string") {
|
|
4193
4395
|
hit = f === p;
|
|
@@ -9464,6 +9666,15 @@ var init_esm5 = __esm({
|
|
|
9464
9666
|
}
|
|
9465
9667
|
});
|
|
9466
9668
|
|
|
9669
|
+
// src/generated-version.ts
|
|
9670
|
+
var VERSION;
|
|
9671
|
+
var init_generated_version = __esm({
|
|
9672
|
+
"src/generated-version.ts"() {
|
|
9673
|
+
"use strict";
|
|
9674
|
+
VERSION = "0.12.2";
|
|
9675
|
+
}
|
|
9676
|
+
});
|
|
9677
|
+
|
|
9467
9678
|
// src/constants.ts
|
|
9468
9679
|
function isReservedNodeName(name) {
|
|
9469
9680
|
return Object.values(RESERVED_NODE_NAMES).includes(name);
|
|
@@ -14465,8 +14676,2232 @@ var init_generated_branding = __esm({
|
|
|
14465
14676
|
}
|
|
14466
14677
|
});
|
|
14467
14678
|
|
|
14679
|
+
// node_modules/esbuild/lib/main.js
|
|
14680
|
+
var require_main = __commonJS({
|
|
14681
|
+
"node_modules/esbuild/lib/main.js"(exports2, module2) {
|
|
14682
|
+
"use strict";
|
|
14683
|
+
var __defProp2 = Object.defineProperty;
|
|
14684
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
14685
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
14686
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
14687
|
+
var __export2 = (target, all) => {
|
|
14688
|
+
for (var name in all)
|
|
14689
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
14690
|
+
};
|
|
14691
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
14692
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14693
|
+
for (let key of __getOwnPropNames2(from))
|
|
14694
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
14695
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
14696
|
+
}
|
|
14697
|
+
return to;
|
|
14698
|
+
};
|
|
14699
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
14700
|
+
var node_exports = {};
|
|
14701
|
+
__export2(node_exports, {
|
|
14702
|
+
analyzeMetafile: () => analyzeMetafile,
|
|
14703
|
+
analyzeMetafileSync: () => analyzeMetafileSync,
|
|
14704
|
+
build: () => build,
|
|
14705
|
+
buildSync: () => buildSync,
|
|
14706
|
+
context: () => context,
|
|
14707
|
+
default: () => node_default,
|
|
14708
|
+
formatMessages: () => formatMessages,
|
|
14709
|
+
formatMessagesSync: () => formatMessagesSync,
|
|
14710
|
+
initialize: () => initialize,
|
|
14711
|
+
stop: () => stop,
|
|
14712
|
+
transform: () => transform2,
|
|
14713
|
+
transformSync: () => transformSync2,
|
|
14714
|
+
version: () => version3
|
|
14715
|
+
});
|
|
14716
|
+
module2.exports = __toCommonJS(node_exports);
|
|
14717
|
+
function encodePacket2(packet) {
|
|
14718
|
+
let visit = (value2) => {
|
|
14719
|
+
if (value2 === null) {
|
|
14720
|
+
bb.write8(0);
|
|
14721
|
+
} else if (typeof value2 === "boolean") {
|
|
14722
|
+
bb.write8(1);
|
|
14723
|
+
bb.write8(+value2);
|
|
14724
|
+
} else if (typeof value2 === "number") {
|
|
14725
|
+
bb.write8(2);
|
|
14726
|
+
bb.write32(value2 | 0);
|
|
14727
|
+
} else if (typeof value2 === "string") {
|
|
14728
|
+
bb.write8(3);
|
|
14729
|
+
bb.write(encodeUTF8(value2));
|
|
14730
|
+
} else if (value2 instanceof Uint8Array) {
|
|
14731
|
+
bb.write8(4);
|
|
14732
|
+
bb.write(value2);
|
|
14733
|
+
} else if (value2 instanceof Array) {
|
|
14734
|
+
bb.write8(5);
|
|
14735
|
+
bb.write32(value2.length);
|
|
14736
|
+
for (let item of value2) {
|
|
14737
|
+
visit(item);
|
|
14738
|
+
}
|
|
14739
|
+
} else {
|
|
14740
|
+
let keys2 = Object.keys(value2);
|
|
14741
|
+
bb.write8(6);
|
|
14742
|
+
bb.write32(keys2.length);
|
|
14743
|
+
for (let key of keys2) {
|
|
14744
|
+
bb.write(encodeUTF8(key));
|
|
14745
|
+
visit(value2[key]);
|
|
14746
|
+
}
|
|
14747
|
+
}
|
|
14748
|
+
};
|
|
14749
|
+
let bb = new ByteBuffer();
|
|
14750
|
+
bb.write32(0);
|
|
14751
|
+
bb.write32(packet.id << 1 | +!packet.isRequest);
|
|
14752
|
+
visit(packet.value);
|
|
14753
|
+
writeUInt32LE(bb.buf, bb.len - 4, 0);
|
|
14754
|
+
return bb.buf.subarray(0, bb.len);
|
|
14755
|
+
}
|
|
14756
|
+
function decodePacket2(bytes) {
|
|
14757
|
+
let visit = () => {
|
|
14758
|
+
switch (bb.read8()) {
|
|
14759
|
+
case 0:
|
|
14760
|
+
return null;
|
|
14761
|
+
case 1:
|
|
14762
|
+
return !!bb.read8();
|
|
14763
|
+
case 2:
|
|
14764
|
+
return bb.read32();
|
|
14765
|
+
case 3:
|
|
14766
|
+
return decodeUTF8(bb.read());
|
|
14767
|
+
case 4:
|
|
14768
|
+
return bb.read();
|
|
14769
|
+
case 5: {
|
|
14770
|
+
let count = bb.read32();
|
|
14771
|
+
let value22 = [];
|
|
14772
|
+
for (let i = 0; i < count; i++) {
|
|
14773
|
+
value22.push(visit());
|
|
14774
|
+
}
|
|
14775
|
+
return value22;
|
|
14776
|
+
}
|
|
14777
|
+
case 6: {
|
|
14778
|
+
let count = bb.read32();
|
|
14779
|
+
let value22 = {};
|
|
14780
|
+
for (let i = 0; i < count; i++) {
|
|
14781
|
+
value22[decodeUTF8(bb.read())] = visit();
|
|
14782
|
+
}
|
|
14783
|
+
return value22;
|
|
14784
|
+
}
|
|
14785
|
+
default:
|
|
14786
|
+
throw new Error("Invalid packet");
|
|
14787
|
+
}
|
|
14788
|
+
};
|
|
14789
|
+
let bb = new ByteBuffer(bytes);
|
|
14790
|
+
let id = bb.read32();
|
|
14791
|
+
let isRequest = (id & 1) === 0;
|
|
14792
|
+
id >>>= 1;
|
|
14793
|
+
let value2 = visit();
|
|
14794
|
+
if (bb.ptr !== bytes.length) {
|
|
14795
|
+
throw new Error("Invalid packet");
|
|
14796
|
+
}
|
|
14797
|
+
return { id, isRequest, value: value2 };
|
|
14798
|
+
}
|
|
14799
|
+
var ByteBuffer = class {
|
|
14800
|
+
constructor(buf = new Uint8Array(1024)) {
|
|
14801
|
+
this.buf = buf;
|
|
14802
|
+
this.len = 0;
|
|
14803
|
+
this.ptr = 0;
|
|
14804
|
+
}
|
|
14805
|
+
_write(delta) {
|
|
14806
|
+
if (this.len + delta > this.buf.length) {
|
|
14807
|
+
let clone3 = new Uint8Array((this.len + delta) * 2);
|
|
14808
|
+
clone3.set(this.buf);
|
|
14809
|
+
this.buf = clone3;
|
|
14810
|
+
}
|
|
14811
|
+
this.len += delta;
|
|
14812
|
+
return this.len - delta;
|
|
14813
|
+
}
|
|
14814
|
+
write8(value2) {
|
|
14815
|
+
let offset = this._write(1);
|
|
14816
|
+
this.buf[offset] = value2;
|
|
14817
|
+
}
|
|
14818
|
+
write32(value2) {
|
|
14819
|
+
let offset = this._write(4);
|
|
14820
|
+
writeUInt32LE(this.buf, value2, offset);
|
|
14821
|
+
}
|
|
14822
|
+
write(bytes) {
|
|
14823
|
+
let offset = this._write(4 + bytes.length);
|
|
14824
|
+
writeUInt32LE(this.buf, bytes.length, offset);
|
|
14825
|
+
this.buf.set(bytes, offset + 4);
|
|
14826
|
+
}
|
|
14827
|
+
_read(delta) {
|
|
14828
|
+
if (this.ptr + delta > this.buf.length) {
|
|
14829
|
+
throw new Error("Invalid packet");
|
|
14830
|
+
}
|
|
14831
|
+
this.ptr += delta;
|
|
14832
|
+
return this.ptr - delta;
|
|
14833
|
+
}
|
|
14834
|
+
read8() {
|
|
14835
|
+
return this.buf[this._read(1)];
|
|
14836
|
+
}
|
|
14837
|
+
read32() {
|
|
14838
|
+
return readUInt32LE(this.buf, this._read(4));
|
|
14839
|
+
}
|
|
14840
|
+
read() {
|
|
14841
|
+
let length = this.read32();
|
|
14842
|
+
let bytes = new Uint8Array(length);
|
|
14843
|
+
let ptr = this._read(bytes.length);
|
|
14844
|
+
bytes.set(this.buf.subarray(ptr, ptr + length));
|
|
14845
|
+
return bytes;
|
|
14846
|
+
}
|
|
14847
|
+
};
|
|
14848
|
+
var encodeUTF8;
|
|
14849
|
+
var decodeUTF8;
|
|
14850
|
+
var encodeInvariant;
|
|
14851
|
+
if (typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined") {
|
|
14852
|
+
let encoder = new TextEncoder();
|
|
14853
|
+
let decoder = new TextDecoder();
|
|
14854
|
+
encodeUTF8 = (text) => encoder.encode(text);
|
|
14855
|
+
decodeUTF8 = (bytes) => decoder.decode(bytes);
|
|
14856
|
+
encodeInvariant = 'new TextEncoder().encode("")';
|
|
14857
|
+
} else if (typeof Buffer !== "undefined") {
|
|
14858
|
+
encodeUTF8 = (text) => Buffer.from(text);
|
|
14859
|
+
decodeUTF8 = (bytes) => {
|
|
14860
|
+
let { buffer, byteOffset, byteLength: byteLength2 } = bytes;
|
|
14861
|
+
return Buffer.from(buffer, byteOffset, byteLength2).toString();
|
|
14862
|
+
};
|
|
14863
|
+
encodeInvariant = 'Buffer.from("")';
|
|
14864
|
+
} else {
|
|
14865
|
+
throw new Error("No UTF-8 codec found");
|
|
14866
|
+
}
|
|
14867
|
+
if (!(encodeUTF8("") instanceof Uint8Array))
|
|
14868
|
+
throw new Error(`Invariant violation: "${encodeInvariant} instanceof Uint8Array" is incorrectly false
|
|
14869
|
+
|
|
14870
|
+
This indicates that your JavaScript environment is broken. You cannot use
|
|
14871
|
+
esbuild in this environment because esbuild relies on this invariant. This
|
|
14872
|
+
is not a problem with esbuild. You need to fix your environment instead.
|
|
14873
|
+
`);
|
|
14874
|
+
function readUInt32LE(buffer, offset) {
|
|
14875
|
+
return buffer[offset++] | buffer[offset++] << 8 | buffer[offset++] << 16 | buffer[offset++] << 24;
|
|
14876
|
+
}
|
|
14877
|
+
function writeUInt32LE(buffer, value2, offset) {
|
|
14878
|
+
buffer[offset++] = value2;
|
|
14879
|
+
buffer[offset++] = value2 >> 8;
|
|
14880
|
+
buffer[offset++] = value2 >> 16;
|
|
14881
|
+
buffer[offset++] = value2 >> 24;
|
|
14882
|
+
}
|
|
14883
|
+
var quote = JSON.stringify;
|
|
14884
|
+
var buildLogLevelDefault = "warning";
|
|
14885
|
+
var transformLogLevelDefault = "silent";
|
|
14886
|
+
function validateAndJoinStringArray(values2, what) {
|
|
14887
|
+
const toJoin = [];
|
|
14888
|
+
for (const value2 of values2) {
|
|
14889
|
+
validateStringValue(value2, what);
|
|
14890
|
+
if (value2.indexOf(",") >= 0) throw new Error(`Invalid ${what}: ${value2}`);
|
|
14891
|
+
toJoin.push(value2);
|
|
14892
|
+
}
|
|
14893
|
+
return toJoin.join(",");
|
|
14894
|
+
}
|
|
14895
|
+
var canBeAnything = () => null;
|
|
14896
|
+
var mustBeBoolean = (value2) => typeof value2 === "boolean" ? null : "a boolean";
|
|
14897
|
+
var mustBeString = (value2) => typeof value2 === "string" ? null : "a string";
|
|
14898
|
+
var mustBeRegExp = (value2) => value2 instanceof RegExp ? null : "a RegExp object";
|
|
14899
|
+
var mustBeInteger = (value2) => typeof value2 === "number" && value2 === (value2 | 0) ? null : "an integer";
|
|
14900
|
+
var mustBeValidPortNumber = (value2) => typeof value2 === "number" && value2 === (value2 | 0) && value2 >= 0 && value2 <= 65535 ? null : "a valid port number";
|
|
14901
|
+
var mustBeFunction = (value2) => typeof value2 === "function" ? null : "a function";
|
|
14902
|
+
var mustBeArray = (value2) => Array.isArray(value2) ? null : "an array";
|
|
14903
|
+
var mustBeArrayOfStrings = (value2) => Array.isArray(value2) && value2.every((x) => typeof x === "string") ? null : "an array of strings";
|
|
14904
|
+
var mustBeObject = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2) ? null : "an object";
|
|
14905
|
+
var mustBeEntryPoints = (value2) => typeof value2 === "object" && value2 !== null ? null : "an array or an object";
|
|
14906
|
+
var mustBeWebAssemblyModule = (value2) => value2 instanceof WebAssembly.Module ? null : "a WebAssembly.Module";
|
|
14907
|
+
var mustBeObjectOrNull = (value2) => typeof value2 === "object" && !Array.isArray(value2) ? null : "an object or null";
|
|
14908
|
+
var mustBeStringOrBoolean = (value2) => typeof value2 === "string" || typeof value2 === "boolean" ? null : "a string or a boolean";
|
|
14909
|
+
var mustBeStringOrObject = (value2) => typeof value2 === "string" || typeof value2 === "object" && value2 !== null && !Array.isArray(value2) ? null : "a string or an object";
|
|
14910
|
+
var mustBeStringOrArrayOfStrings = (value2) => typeof value2 === "string" || Array.isArray(value2) && value2.every((x) => typeof x === "string") ? null : "a string or an array of strings";
|
|
14911
|
+
var mustBeStringOrUint8Array = (value2) => typeof value2 === "string" || value2 instanceof Uint8Array ? null : "a string or a Uint8Array";
|
|
14912
|
+
var mustBeStringOrURL = (value2) => typeof value2 === "string" || value2 instanceof URL ? null : "a string or a URL";
|
|
14913
|
+
function getFlag(object3, keys2, key, mustBeFn) {
|
|
14914
|
+
let value2 = object3[key];
|
|
14915
|
+
keys2[key + ""] = true;
|
|
14916
|
+
if (value2 === void 0) return void 0;
|
|
14917
|
+
let mustBe = mustBeFn(value2);
|
|
14918
|
+
if (mustBe !== null) throw new Error(`${quote(key)} must be ${mustBe}`);
|
|
14919
|
+
return value2;
|
|
14920
|
+
}
|
|
14921
|
+
function checkForInvalidFlags(object3, keys2, where) {
|
|
14922
|
+
for (let key in object3) {
|
|
14923
|
+
if (!(key in keys2)) {
|
|
14924
|
+
throw new Error(`Invalid option ${where}: ${quote(key)}`);
|
|
14925
|
+
}
|
|
14926
|
+
}
|
|
14927
|
+
}
|
|
14928
|
+
function validateInitializeOptions(options) {
|
|
14929
|
+
let keys2 = /* @__PURE__ */ Object.create(null);
|
|
14930
|
+
let wasmURL = getFlag(options, keys2, "wasmURL", mustBeStringOrURL);
|
|
14931
|
+
let wasmModule = getFlag(options, keys2, "wasmModule", mustBeWebAssemblyModule);
|
|
14932
|
+
let worker = getFlag(options, keys2, "worker", mustBeBoolean);
|
|
14933
|
+
checkForInvalidFlags(options, keys2, "in initialize() call");
|
|
14934
|
+
return {
|
|
14935
|
+
wasmURL,
|
|
14936
|
+
wasmModule,
|
|
14937
|
+
worker
|
|
14938
|
+
};
|
|
14939
|
+
}
|
|
14940
|
+
function validateMangleCache(mangleCache) {
|
|
14941
|
+
let validated;
|
|
14942
|
+
if (mangleCache !== void 0) {
|
|
14943
|
+
validated = /* @__PURE__ */ Object.create(null);
|
|
14944
|
+
for (let key in mangleCache) {
|
|
14945
|
+
let value2 = mangleCache[key];
|
|
14946
|
+
if (typeof value2 === "string" || value2 === false) {
|
|
14947
|
+
validated[key] = value2;
|
|
14948
|
+
} else {
|
|
14949
|
+
throw new Error(`Expected ${quote(key)} in mangle cache to map to either a string or false`);
|
|
14950
|
+
}
|
|
14951
|
+
}
|
|
14952
|
+
}
|
|
14953
|
+
return validated;
|
|
14954
|
+
}
|
|
14955
|
+
function pushLogFlags(flags, options, keys2, isTTY2, logLevelDefault) {
|
|
14956
|
+
let color = getFlag(options, keys2, "color", mustBeBoolean);
|
|
14957
|
+
let logLevel = getFlag(options, keys2, "logLevel", mustBeString);
|
|
14958
|
+
let logLimit = getFlag(options, keys2, "logLimit", mustBeInteger);
|
|
14959
|
+
if (color !== void 0) flags.push(`--color=${color}`);
|
|
14960
|
+
else if (isTTY2) flags.push(`--color=true`);
|
|
14961
|
+
flags.push(`--log-level=${logLevel || logLevelDefault}`);
|
|
14962
|
+
flags.push(`--log-limit=${logLimit || 0}`);
|
|
14963
|
+
}
|
|
14964
|
+
function validateStringValue(value2, what, key) {
|
|
14965
|
+
if (typeof value2 !== "string") {
|
|
14966
|
+
throw new Error(`Expected value for ${what}${key !== void 0 ? " " + quote(key) : ""} to be a string, got ${typeof value2} instead`);
|
|
14967
|
+
}
|
|
14968
|
+
return value2;
|
|
14969
|
+
}
|
|
14970
|
+
function pushCommonFlags(flags, options, keys2) {
|
|
14971
|
+
let legalComments = getFlag(options, keys2, "legalComments", mustBeString);
|
|
14972
|
+
let sourceRoot = getFlag(options, keys2, "sourceRoot", mustBeString);
|
|
14973
|
+
let sourcesContent = getFlag(options, keys2, "sourcesContent", mustBeBoolean);
|
|
14974
|
+
let target = getFlag(options, keys2, "target", mustBeStringOrArrayOfStrings);
|
|
14975
|
+
let format = getFlag(options, keys2, "format", mustBeString);
|
|
14976
|
+
let globalName = getFlag(options, keys2, "globalName", mustBeString);
|
|
14977
|
+
let mangleProps = getFlag(options, keys2, "mangleProps", mustBeRegExp);
|
|
14978
|
+
let reserveProps = getFlag(options, keys2, "reserveProps", mustBeRegExp);
|
|
14979
|
+
let mangleQuoted = getFlag(options, keys2, "mangleQuoted", mustBeBoolean);
|
|
14980
|
+
let minify = getFlag(options, keys2, "minify", mustBeBoolean);
|
|
14981
|
+
let minifySyntax = getFlag(options, keys2, "minifySyntax", mustBeBoolean);
|
|
14982
|
+
let minifyWhitespace = getFlag(options, keys2, "minifyWhitespace", mustBeBoolean);
|
|
14983
|
+
let minifyIdentifiers = getFlag(options, keys2, "minifyIdentifiers", mustBeBoolean);
|
|
14984
|
+
let lineLimit = getFlag(options, keys2, "lineLimit", mustBeInteger);
|
|
14985
|
+
let drop2 = getFlag(options, keys2, "drop", mustBeArrayOfStrings);
|
|
14986
|
+
let dropLabels = getFlag(options, keys2, "dropLabels", mustBeArrayOfStrings);
|
|
14987
|
+
let charset = getFlag(options, keys2, "charset", mustBeString);
|
|
14988
|
+
let treeShaking = getFlag(options, keys2, "treeShaking", mustBeBoolean);
|
|
14989
|
+
let ignoreAnnotations = getFlag(options, keys2, "ignoreAnnotations", mustBeBoolean);
|
|
14990
|
+
let jsx = getFlag(options, keys2, "jsx", mustBeString);
|
|
14991
|
+
let jsxFactory = getFlag(options, keys2, "jsxFactory", mustBeString);
|
|
14992
|
+
let jsxFragment = getFlag(options, keys2, "jsxFragment", mustBeString);
|
|
14993
|
+
let jsxImportSource = getFlag(options, keys2, "jsxImportSource", mustBeString);
|
|
14994
|
+
let jsxDev = getFlag(options, keys2, "jsxDev", mustBeBoolean);
|
|
14995
|
+
let jsxSideEffects = getFlag(options, keys2, "jsxSideEffects", mustBeBoolean);
|
|
14996
|
+
let define = getFlag(options, keys2, "define", mustBeObject);
|
|
14997
|
+
let logOverride = getFlag(options, keys2, "logOverride", mustBeObject);
|
|
14998
|
+
let supported = getFlag(options, keys2, "supported", mustBeObject);
|
|
14999
|
+
let pure = getFlag(options, keys2, "pure", mustBeArrayOfStrings);
|
|
15000
|
+
let keepNames = getFlag(options, keys2, "keepNames", mustBeBoolean);
|
|
15001
|
+
let platform = getFlag(options, keys2, "platform", mustBeString);
|
|
15002
|
+
let tsconfigRaw = getFlag(options, keys2, "tsconfigRaw", mustBeStringOrObject);
|
|
15003
|
+
let absPaths = getFlag(options, keys2, "absPaths", mustBeArrayOfStrings);
|
|
15004
|
+
if (legalComments) flags.push(`--legal-comments=${legalComments}`);
|
|
15005
|
+
if (sourceRoot !== void 0) flags.push(`--source-root=${sourceRoot}`);
|
|
15006
|
+
if (sourcesContent !== void 0) flags.push(`--sources-content=${sourcesContent}`);
|
|
15007
|
+
if (target) flags.push(`--target=${validateAndJoinStringArray(Array.isArray(target) ? target : [target], "target")}`);
|
|
15008
|
+
if (format) flags.push(`--format=${format}`);
|
|
15009
|
+
if (globalName) flags.push(`--global-name=${globalName}`);
|
|
15010
|
+
if (platform) flags.push(`--platform=${platform}`);
|
|
15011
|
+
if (tsconfigRaw) flags.push(`--tsconfig-raw=${typeof tsconfigRaw === "string" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);
|
|
15012
|
+
if (minify) flags.push("--minify");
|
|
15013
|
+
if (minifySyntax) flags.push("--minify-syntax");
|
|
15014
|
+
if (minifyWhitespace) flags.push("--minify-whitespace");
|
|
15015
|
+
if (minifyIdentifiers) flags.push("--minify-identifiers");
|
|
15016
|
+
if (lineLimit) flags.push(`--line-limit=${lineLimit}`);
|
|
15017
|
+
if (charset) flags.push(`--charset=${charset}`);
|
|
15018
|
+
if (treeShaking !== void 0) flags.push(`--tree-shaking=${treeShaking}`);
|
|
15019
|
+
if (ignoreAnnotations) flags.push(`--ignore-annotations`);
|
|
15020
|
+
if (drop2) for (let what of drop2) flags.push(`--drop:${validateStringValue(what, "drop")}`);
|
|
15021
|
+
if (dropLabels) flags.push(`--drop-labels=${validateAndJoinStringArray(dropLabels, "drop label")}`);
|
|
15022
|
+
if (absPaths) flags.push(`--abs-paths=${validateAndJoinStringArray(absPaths, "abs paths")}`);
|
|
15023
|
+
if (mangleProps) flags.push(`--mangle-props=${jsRegExpToGoRegExp(mangleProps)}`);
|
|
15024
|
+
if (reserveProps) flags.push(`--reserve-props=${jsRegExpToGoRegExp(reserveProps)}`);
|
|
15025
|
+
if (mangleQuoted !== void 0) flags.push(`--mangle-quoted=${mangleQuoted}`);
|
|
15026
|
+
if (jsx) flags.push(`--jsx=${jsx}`);
|
|
15027
|
+
if (jsxFactory) flags.push(`--jsx-factory=${jsxFactory}`);
|
|
15028
|
+
if (jsxFragment) flags.push(`--jsx-fragment=${jsxFragment}`);
|
|
15029
|
+
if (jsxImportSource) flags.push(`--jsx-import-source=${jsxImportSource}`);
|
|
15030
|
+
if (jsxDev) flags.push(`--jsx-dev`);
|
|
15031
|
+
if (jsxSideEffects) flags.push(`--jsx-side-effects`);
|
|
15032
|
+
if (define) {
|
|
15033
|
+
for (let key in define) {
|
|
15034
|
+
if (key.indexOf("=") >= 0) throw new Error(`Invalid define: ${key}`);
|
|
15035
|
+
flags.push(`--define:${key}=${validateStringValue(define[key], "define", key)}`);
|
|
15036
|
+
}
|
|
15037
|
+
}
|
|
15038
|
+
if (logOverride) {
|
|
15039
|
+
for (let key in logOverride) {
|
|
15040
|
+
if (key.indexOf("=") >= 0) throw new Error(`Invalid log override: ${key}`);
|
|
15041
|
+
flags.push(`--log-override:${key}=${validateStringValue(logOverride[key], "log override", key)}`);
|
|
15042
|
+
}
|
|
15043
|
+
}
|
|
15044
|
+
if (supported) {
|
|
15045
|
+
for (let key in supported) {
|
|
15046
|
+
if (key.indexOf("=") >= 0) throw new Error(`Invalid supported: ${key}`);
|
|
15047
|
+
const value2 = supported[key];
|
|
15048
|
+
if (typeof value2 !== "boolean") throw new Error(`Expected value for supported ${quote(key)} to be a boolean, got ${typeof value2} instead`);
|
|
15049
|
+
flags.push(`--supported:${key}=${value2}`);
|
|
15050
|
+
}
|
|
15051
|
+
}
|
|
15052
|
+
if (pure) for (let fn of pure) flags.push(`--pure:${validateStringValue(fn, "pure")}`);
|
|
15053
|
+
if (keepNames) flags.push(`--keep-names`);
|
|
15054
|
+
}
|
|
15055
|
+
function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeDefault) {
|
|
15056
|
+
var _a22;
|
|
15057
|
+
let flags = [];
|
|
15058
|
+
let entries = [];
|
|
15059
|
+
let keys2 = /* @__PURE__ */ Object.create(null);
|
|
15060
|
+
let stdinContents = null;
|
|
15061
|
+
let stdinResolveDir = null;
|
|
15062
|
+
pushLogFlags(flags, options, keys2, isTTY2, logLevelDefault);
|
|
15063
|
+
pushCommonFlags(flags, options, keys2);
|
|
15064
|
+
let sourcemap = getFlag(options, keys2, "sourcemap", mustBeStringOrBoolean);
|
|
15065
|
+
let bundle = getFlag(options, keys2, "bundle", mustBeBoolean);
|
|
15066
|
+
let splitting = getFlag(options, keys2, "splitting", mustBeBoolean);
|
|
15067
|
+
let preserveSymlinks = getFlag(options, keys2, "preserveSymlinks", mustBeBoolean);
|
|
15068
|
+
let metafile = getFlag(options, keys2, "metafile", mustBeBoolean);
|
|
15069
|
+
let outfile = getFlag(options, keys2, "outfile", mustBeString);
|
|
15070
|
+
let outdir = getFlag(options, keys2, "outdir", mustBeString);
|
|
15071
|
+
let outbase = getFlag(options, keys2, "outbase", mustBeString);
|
|
15072
|
+
let tsconfig = getFlag(options, keys2, "tsconfig", mustBeString);
|
|
15073
|
+
let resolveExtensions = getFlag(options, keys2, "resolveExtensions", mustBeArrayOfStrings);
|
|
15074
|
+
let nodePathsInput = getFlag(options, keys2, "nodePaths", mustBeArrayOfStrings);
|
|
15075
|
+
let mainFields = getFlag(options, keys2, "mainFields", mustBeArrayOfStrings);
|
|
15076
|
+
let conditions = getFlag(options, keys2, "conditions", mustBeArrayOfStrings);
|
|
15077
|
+
let external = getFlag(options, keys2, "external", mustBeArrayOfStrings);
|
|
15078
|
+
let packages = getFlag(options, keys2, "packages", mustBeString);
|
|
15079
|
+
let alias = getFlag(options, keys2, "alias", mustBeObject);
|
|
15080
|
+
let loader2 = getFlag(options, keys2, "loader", mustBeObject);
|
|
15081
|
+
let outExtension = getFlag(options, keys2, "outExtension", mustBeObject);
|
|
15082
|
+
let publicPath = getFlag(options, keys2, "publicPath", mustBeString);
|
|
15083
|
+
let entryNames = getFlag(options, keys2, "entryNames", mustBeString);
|
|
15084
|
+
let chunkNames = getFlag(options, keys2, "chunkNames", mustBeString);
|
|
15085
|
+
let assetNames = getFlag(options, keys2, "assetNames", mustBeString);
|
|
15086
|
+
let inject = getFlag(options, keys2, "inject", mustBeArrayOfStrings);
|
|
15087
|
+
let banner = getFlag(options, keys2, "banner", mustBeObject);
|
|
15088
|
+
let footer = getFlag(options, keys2, "footer", mustBeObject);
|
|
15089
|
+
let entryPoints = getFlag(options, keys2, "entryPoints", mustBeEntryPoints);
|
|
15090
|
+
let absWorkingDir = getFlag(options, keys2, "absWorkingDir", mustBeString);
|
|
15091
|
+
let stdin = getFlag(options, keys2, "stdin", mustBeObject);
|
|
15092
|
+
let write = (_a22 = getFlag(options, keys2, "write", mustBeBoolean)) != null ? _a22 : writeDefault;
|
|
15093
|
+
let allowOverwrite = getFlag(options, keys2, "allowOverwrite", mustBeBoolean);
|
|
15094
|
+
let mangleCache = getFlag(options, keys2, "mangleCache", mustBeObject);
|
|
15095
|
+
keys2.plugins = true;
|
|
15096
|
+
checkForInvalidFlags(options, keys2, `in ${callName}() call`);
|
|
15097
|
+
if (sourcemap) flags.push(`--sourcemap${sourcemap === true ? "" : `=${sourcemap}`}`);
|
|
15098
|
+
if (bundle) flags.push("--bundle");
|
|
15099
|
+
if (allowOverwrite) flags.push("--allow-overwrite");
|
|
15100
|
+
if (splitting) flags.push("--splitting");
|
|
15101
|
+
if (preserveSymlinks) flags.push("--preserve-symlinks");
|
|
15102
|
+
if (metafile) flags.push(`--metafile`);
|
|
15103
|
+
if (outfile) flags.push(`--outfile=${outfile}`);
|
|
15104
|
+
if (outdir) flags.push(`--outdir=${outdir}`);
|
|
15105
|
+
if (outbase) flags.push(`--outbase=${outbase}`);
|
|
15106
|
+
if (tsconfig) flags.push(`--tsconfig=${tsconfig}`);
|
|
15107
|
+
if (packages) flags.push(`--packages=${packages}`);
|
|
15108
|
+
if (resolveExtensions) flags.push(`--resolve-extensions=${validateAndJoinStringArray(resolveExtensions, "resolve extension")}`);
|
|
15109
|
+
if (publicPath) flags.push(`--public-path=${publicPath}`);
|
|
15110
|
+
if (entryNames) flags.push(`--entry-names=${entryNames}`);
|
|
15111
|
+
if (chunkNames) flags.push(`--chunk-names=${chunkNames}`);
|
|
15112
|
+
if (assetNames) flags.push(`--asset-names=${assetNames}`);
|
|
15113
|
+
if (mainFields) flags.push(`--main-fields=${validateAndJoinStringArray(mainFields, "main field")}`);
|
|
15114
|
+
if (conditions) flags.push(`--conditions=${validateAndJoinStringArray(conditions, "condition")}`);
|
|
15115
|
+
if (external) for (let name of external) flags.push(`--external:${validateStringValue(name, "external")}`);
|
|
15116
|
+
if (alias) {
|
|
15117
|
+
for (let old in alias) {
|
|
15118
|
+
if (old.indexOf("=") >= 0) throw new Error(`Invalid package name in alias: ${old}`);
|
|
15119
|
+
flags.push(`--alias:${old}=${validateStringValue(alias[old], "alias", old)}`);
|
|
15120
|
+
}
|
|
15121
|
+
}
|
|
15122
|
+
if (banner) {
|
|
15123
|
+
for (let type2 in banner) {
|
|
15124
|
+
if (type2.indexOf("=") >= 0) throw new Error(`Invalid banner file type: ${type2}`);
|
|
15125
|
+
flags.push(`--banner:${type2}=${validateStringValue(banner[type2], "banner", type2)}`);
|
|
15126
|
+
}
|
|
15127
|
+
}
|
|
15128
|
+
if (footer) {
|
|
15129
|
+
for (let type2 in footer) {
|
|
15130
|
+
if (type2.indexOf("=") >= 0) throw new Error(`Invalid footer file type: ${type2}`);
|
|
15131
|
+
flags.push(`--footer:${type2}=${validateStringValue(footer[type2], "footer", type2)}`);
|
|
15132
|
+
}
|
|
15133
|
+
}
|
|
15134
|
+
if (inject) for (let path310 of inject) flags.push(`--inject:${validateStringValue(path310, "inject")}`);
|
|
15135
|
+
if (loader2) {
|
|
15136
|
+
for (let ext2 in loader2) {
|
|
15137
|
+
if (ext2.indexOf("=") >= 0) throw new Error(`Invalid loader extension: ${ext2}`);
|
|
15138
|
+
flags.push(`--loader:${ext2}=${validateStringValue(loader2[ext2], "loader", ext2)}`);
|
|
15139
|
+
}
|
|
15140
|
+
}
|
|
15141
|
+
if (outExtension) {
|
|
15142
|
+
for (let ext2 in outExtension) {
|
|
15143
|
+
if (ext2.indexOf("=") >= 0) throw new Error(`Invalid out extension: ${ext2}`);
|
|
15144
|
+
flags.push(`--out-extension:${ext2}=${validateStringValue(outExtension[ext2], "out extension", ext2)}`);
|
|
15145
|
+
}
|
|
15146
|
+
}
|
|
15147
|
+
if (entryPoints) {
|
|
15148
|
+
if (Array.isArray(entryPoints)) {
|
|
15149
|
+
for (let i = 0, n = entryPoints.length; i < n; i++) {
|
|
15150
|
+
let entryPoint = entryPoints[i];
|
|
15151
|
+
if (typeof entryPoint === "object" && entryPoint !== null) {
|
|
15152
|
+
let entryPointKeys = /* @__PURE__ */ Object.create(null);
|
|
15153
|
+
let input = getFlag(entryPoint, entryPointKeys, "in", mustBeString);
|
|
15154
|
+
let output = getFlag(entryPoint, entryPointKeys, "out", mustBeString);
|
|
15155
|
+
checkForInvalidFlags(entryPoint, entryPointKeys, "in entry point at index " + i);
|
|
15156
|
+
if (input === void 0) throw new Error('Missing property "in" for entry point at index ' + i);
|
|
15157
|
+
if (output === void 0) throw new Error('Missing property "out" for entry point at index ' + i);
|
|
15158
|
+
entries.push([output, input]);
|
|
15159
|
+
} else {
|
|
15160
|
+
entries.push(["", validateStringValue(entryPoint, "entry point at index " + i)]);
|
|
15161
|
+
}
|
|
15162
|
+
}
|
|
15163
|
+
} else {
|
|
15164
|
+
for (let key in entryPoints) {
|
|
15165
|
+
entries.push([key, validateStringValue(entryPoints[key], "entry point", key)]);
|
|
15166
|
+
}
|
|
15167
|
+
}
|
|
15168
|
+
}
|
|
15169
|
+
if (stdin) {
|
|
15170
|
+
let stdinKeys = /* @__PURE__ */ Object.create(null);
|
|
15171
|
+
let contents = getFlag(stdin, stdinKeys, "contents", mustBeStringOrUint8Array);
|
|
15172
|
+
let resolveDir = getFlag(stdin, stdinKeys, "resolveDir", mustBeString);
|
|
15173
|
+
let sourcefile = getFlag(stdin, stdinKeys, "sourcefile", mustBeString);
|
|
15174
|
+
let loader22 = getFlag(stdin, stdinKeys, "loader", mustBeString);
|
|
15175
|
+
checkForInvalidFlags(stdin, stdinKeys, 'in "stdin" object');
|
|
15176
|
+
if (sourcefile) flags.push(`--sourcefile=${sourcefile}`);
|
|
15177
|
+
if (loader22) flags.push(`--loader=${loader22}`);
|
|
15178
|
+
if (resolveDir) stdinResolveDir = resolveDir;
|
|
15179
|
+
if (typeof contents === "string") stdinContents = encodeUTF8(contents);
|
|
15180
|
+
else if (contents instanceof Uint8Array) stdinContents = contents;
|
|
15181
|
+
}
|
|
15182
|
+
let nodePaths = [];
|
|
15183
|
+
if (nodePathsInput) {
|
|
15184
|
+
for (let value2 of nodePathsInput) {
|
|
15185
|
+
value2 += "";
|
|
15186
|
+
nodePaths.push(value2);
|
|
15187
|
+
}
|
|
15188
|
+
}
|
|
15189
|
+
return {
|
|
15190
|
+
entries,
|
|
15191
|
+
flags,
|
|
15192
|
+
write,
|
|
15193
|
+
stdinContents,
|
|
15194
|
+
stdinResolveDir,
|
|
15195
|
+
absWorkingDir,
|
|
15196
|
+
nodePaths,
|
|
15197
|
+
mangleCache: validateMangleCache(mangleCache)
|
|
15198
|
+
};
|
|
15199
|
+
}
|
|
15200
|
+
function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
|
|
15201
|
+
let flags = [];
|
|
15202
|
+
let keys2 = /* @__PURE__ */ Object.create(null);
|
|
15203
|
+
pushLogFlags(flags, options, keys2, isTTY2, logLevelDefault);
|
|
15204
|
+
pushCommonFlags(flags, options, keys2);
|
|
15205
|
+
let sourcemap = getFlag(options, keys2, "sourcemap", mustBeStringOrBoolean);
|
|
15206
|
+
let sourcefile = getFlag(options, keys2, "sourcefile", mustBeString);
|
|
15207
|
+
let loader2 = getFlag(options, keys2, "loader", mustBeString);
|
|
15208
|
+
let banner = getFlag(options, keys2, "banner", mustBeString);
|
|
15209
|
+
let footer = getFlag(options, keys2, "footer", mustBeString);
|
|
15210
|
+
let mangleCache = getFlag(options, keys2, "mangleCache", mustBeObject);
|
|
15211
|
+
checkForInvalidFlags(options, keys2, `in ${callName}() call`);
|
|
15212
|
+
if (sourcemap) flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
|
|
15213
|
+
if (sourcefile) flags.push(`--sourcefile=${sourcefile}`);
|
|
15214
|
+
if (loader2) flags.push(`--loader=${loader2}`);
|
|
15215
|
+
if (banner) flags.push(`--banner=${banner}`);
|
|
15216
|
+
if (footer) flags.push(`--footer=${footer}`);
|
|
15217
|
+
return {
|
|
15218
|
+
flags,
|
|
15219
|
+
mangleCache: validateMangleCache(mangleCache)
|
|
15220
|
+
};
|
|
15221
|
+
}
|
|
15222
|
+
function createChannel(streamIn) {
|
|
15223
|
+
const requestCallbacksByKey = {};
|
|
15224
|
+
const closeData = { didClose: false, reason: "" };
|
|
15225
|
+
let responseCallbacks = {};
|
|
15226
|
+
let nextRequestID = 0;
|
|
15227
|
+
let nextBuildKey = 0;
|
|
15228
|
+
let stdout = new Uint8Array(16 * 1024);
|
|
15229
|
+
let stdoutUsed = 0;
|
|
15230
|
+
let readFromStdout = (chunk) => {
|
|
15231
|
+
let limit = stdoutUsed + chunk.length;
|
|
15232
|
+
if (limit > stdout.length) {
|
|
15233
|
+
let swap = new Uint8Array(limit * 2);
|
|
15234
|
+
swap.set(stdout);
|
|
15235
|
+
stdout = swap;
|
|
15236
|
+
}
|
|
15237
|
+
stdout.set(chunk, stdoutUsed);
|
|
15238
|
+
stdoutUsed += chunk.length;
|
|
15239
|
+
let offset = 0;
|
|
15240
|
+
while (offset + 4 <= stdoutUsed) {
|
|
15241
|
+
let length = readUInt32LE(stdout, offset);
|
|
15242
|
+
if (offset + 4 + length > stdoutUsed) {
|
|
15243
|
+
break;
|
|
15244
|
+
}
|
|
15245
|
+
offset += 4;
|
|
15246
|
+
handleIncomingPacket(stdout.subarray(offset, offset + length));
|
|
15247
|
+
offset += length;
|
|
15248
|
+
}
|
|
15249
|
+
if (offset > 0) {
|
|
15250
|
+
stdout.copyWithin(0, offset, stdoutUsed);
|
|
15251
|
+
stdoutUsed -= offset;
|
|
15252
|
+
}
|
|
15253
|
+
};
|
|
15254
|
+
let afterClose = (error2) => {
|
|
15255
|
+
closeData.didClose = true;
|
|
15256
|
+
if (error2) closeData.reason = ": " + (error2.message || error2);
|
|
15257
|
+
const text = "The service was stopped" + closeData.reason;
|
|
15258
|
+
for (let id in responseCallbacks) {
|
|
15259
|
+
responseCallbacks[id](text, null);
|
|
15260
|
+
}
|
|
15261
|
+
responseCallbacks = {};
|
|
15262
|
+
};
|
|
15263
|
+
let sendRequest = (refs, value2, callback) => {
|
|
15264
|
+
if (closeData.didClose) return callback("The service is no longer running" + closeData.reason, null);
|
|
15265
|
+
let id = nextRequestID++;
|
|
15266
|
+
responseCallbacks[id] = (error2, response) => {
|
|
15267
|
+
try {
|
|
15268
|
+
callback(error2, response);
|
|
15269
|
+
} finally {
|
|
15270
|
+
if (refs) refs.unref();
|
|
15271
|
+
}
|
|
15272
|
+
};
|
|
15273
|
+
if (refs) refs.ref();
|
|
15274
|
+
streamIn.writeToStdin(encodePacket2({ id, isRequest: true, value: value2 }));
|
|
15275
|
+
};
|
|
15276
|
+
let sendResponse = (id, value2) => {
|
|
15277
|
+
if (closeData.didClose) throw new Error("The service is no longer running" + closeData.reason);
|
|
15278
|
+
streamIn.writeToStdin(encodePacket2({ id, isRequest: false, value: value2 }));
|
|
15279
|
+
};
|
|
15280
|
+
let handleRequest = async (id, request) => {
|
|
15281
|
+
try {
|
|
15282
|
+
if (request.command === "ping") {
|
|
15283
|
+
sendResponse(id, {});
|
|
15284
|
+
return;
|
|
15285
|
+
}
|
|
15286
|
+
if (typeof request.key === "number") {
|
|
15287
|
+
const requestCallbacks = requestCallbacksByKey[request.key];
|
|
15288
|
+
if (!requestCallbacks) {
|
|
15289
|
+
return;
|
|
15290
|
+
}
|
|
15291
|
+
const callback = requestCallbacks[request.command];
|
|
15292
|
+
if (callback) {
|
|
15293
|
+
await callback(id, request);
|
|
15294
|
+
return;
|
|
15295
|
+
}
|
|
15296
|
+
}
|
|
15297
|
+
throw new Error(`Invalid command: ` + request.command);
|
|
15298
|
+
} catch (e) {
|
|
15299
|
+
const errors2 = [extractErrorMessageV8(e, streamIn, null, void 0, "")];
|
|
15300
|
+
try {
|
|
15301
|
+
sendResponse(id, { errors: errors2 });
|
|
15302
|
+
} catch {
|
|
15303
|
+
}
|
|
15304
|
+
}
|
|
15305
|
+
};
|
|
15306
|
+
let isFirstPacket = true;
|
|
15307
|
+
let handleIncomingPacket = (bytes) => {
|
|
15308
|
+
if (isFirstPacket) {
|
|
15309
|
+
isFirstPacket = false;
|
|
15310
|
+
let binaryVersion = String.fromCharCode(...bytes);
|
|
15311
|
+
if (binaryVersion !== "0.27.3") {
|
|
15312
|
+
throw new Error(`Cannot start service: Host version "${"0.27.3"}" does not match binary version ${quote(binaryVersion)}`);
|
|
15313
|
+
}
|
|
15314
|
+
return;
|
|
15315
|
+
}
|
|
15316
|
+
let packet = decodePacket2(bytes);
|
|
15317
|
+
if (packet.isRequest) {
|
|
15318
|
+
handleRequest(packet.id, packet.value);
|
|
15319
|
+
} else {
|
|
15320
|
+
let callback = responseCallbacks[packet.id];
|
|
15321
|
+
delete responseCallbacks[packet.id];
|
|
15322
|
+
if (packet.value.error) callback(packet.value.error, {});
|
|
15323
|
+
else callback(null, packet.value);
|
|
15324
|
+
}
|
|
15325
|
+
};
|
|
15326
|
+
let buildOrContext = ({ callName, refs, options, isTTY: isTTY2, defaultWD: defaultWD2, callback }) => {
|
|
15327
|
+
let refCount = 0;
|
|
15328
|
+
const buildKey = nextBuildKey++;
|
|
15329
|
+
const requestCallbacks = {};
|
|
15330
|
+
const buildRefs = {
|
|
15331
|
+
ref() {
|
|
15332
|
+
if (++refCount === 1) {
|
|
15333
|
+
if (refs) refs.ref();
|
|
15334
|
+
}
|
|
15335
|
+
},
|
|
15336
|
+
unref() {
|
|
15337
|
+
if (--refCount === 0) {
|
|
15338
|
+
delete requestCallbacksByKey[buildKey];
|
|
15339
|
+
if (refs) refs.unref();
|
|
15340
|
+
}
|
|
15341
|
+
}
|
|
15342
|
+
};
|
|
15343
|
+
requestCallbacksByKey[buildKey] = requestCallbacks;
|
|
15344
|
+
buildRefs.ref();
|
|
15345
|
+
buildOrContextImpl(
|
|
15346
|
+
callName,
|
|
15347
|
+
buildKey,
|
|
15348
|
+
sendRequest,
|
|
15349
|
+
sendResponse,
|
|
15350
|
+
buildRefs,
|
|
15351
|
+
streamIn,
|
|
15352
|
+
requestCallbacks,
|
|
15353
|
+
options,
|
|
15354
|
+
isTTY2,
|
|
15355
|
+
defaultWD2,
|
|
15356
|
+
(err, res) => {
|
|
15357
|
+
try {
|
|
15358
|
+
callback(err, res);
|
|
15359
|
+
} finally {
|
|
15360
|
+
buildRefs.unref();
|
|
15361
|
+
}
|
|
15362
|
+
}
|
|
15363
|
+
);
|
|
15364
|
+
};
|
|
15365
|
+
let transform22 = ({ callName, refs, input, options, isTTY: isTTY2, fs: fs310, callback }) => {
|
|
15366
|
+
const details = createObjectStash();
|
|
15367
|
+
let start = (inputPath) => {
|
|
15368
|
+
try {
|
|
15369
|
+
if (typeof input !== "string" && !(input instanceof Uint8Array))
|
|
15370
|
+
throw new Error('The input to "transform" must be a string or a Uint8Array');
|
|
15371
|
+
let {
|
|
15372
|
+
flags,
|
|
15373
|
+
mangleCache
|
|
15374
|
+
} = flagsForTransformOptions(callName, options, isTTY2, transformLogLevelDefault);
|
|
15375
|
+
let request = {
|
|
15376
|
+
command: "transform",
|
|
15377
|
+
flags,
|
|
15378
|
+
inputFS: inputPath !== null,
|
|
15379
|
+
input: inputPath !== null ? encodeUTF8(inputPath) : typeof input === "string" ? encodeUTF8(input) : input
|
|
15380
|
+
};
|
|
15381
|
+
if (mangleCache) request.mangleCache = mangleCache;
|
|
15382
|
+
sendRequest(refs, request, (error2, response) => {
|
|
15383
|
+
if (error2) return callback(new Error(error2), null);
|
|
15384
|
+
let errors2 = replaceDetailsInMessages(response.errors, details);
|
|
15385
|
+
let warnings = replaceDetailsInMessages(response.warnings, details);
|
|
15386
|
+
let outstanding = 1;
|
|
15387
|
+
let next = () => {
|
|
15388
|
+
if (--outstanding === 0) {
|
|
15389
|
+
let result = {
|
|
15390
|
+
warnings,
|
|
15391
|
+
code: response.code,
|
|
15392
|
+
map: response.map,
|
|
15393
|
+
mangleCache: void 0,
|
|
15394
|
+
legalComments: void 0
|
|
15395
|
+
};
|
|
15396
|
+
if ("legalComments" in response) result.legalComments = response == null ? void 0 : response.legalComments;
|
|
15397
|
+
if (response.mangleCache) result.mangleCache = response == null ? void 0 : response.mangleCache;
|
|
15398
|
+
callback(null, result);
|
|
15399
|
+
}
|
|
15400
|
+
};
|
|
15401
|
+
if (errors2.length > 0) return callback(failureErrorWithLog("Transform failed", errors2, warnings), null);
|
|
15402
|
+
if (response.codeFS) {
|
|
15403
|
+
outstanding++;
|
|
15404
|
+
fs310.readFile(response.code, (err, contents) => {
|
|
15405
|
+
if (err !== null) {
|
|
15406
|
+
callback(err, null);
|
|
15407
|
+
} else {
|
|
15408
|
+
response.code = contents;
|
|
15409
|
+
next();
|
|
15410
|
+
}
|
|
15411
|
+
});
|
|
15412
|
+
}
|
|
15413
|
+
if (response.mapFS) {
|
|
15414
|
+
outstanding++;
|
|
15415
|
+
fs310.readFile(response.map, (err, contents) => {
|
|
15416
|
+
if (err !== null) {
|
|
15417
|
+
callback(err, null);
|
|
15418
|
+
} else {
|
|
15419
|
+
response.map = contents;
|
|
15420
|
+
next();
|
|
15421
|
+
}
|
|
15422
|
+
});
|
|
15423
|
+
}
|
|
15424
|
+
next();
|
|
15425
|
+
});
|
|
15426
|
+
} catch (e) {
|
|
15427
|
+
let flags = [];
|
|
15428
|
+
try {
|
|
15429
|
+
pushLogFlags(flags, options, {}, isTTY2, transformLogLevelDefault);
|
|
15430
|
+
} catch {
|
|
15431
|
+
}
|
|
15432
|
+
const error2 = extractErrorMessageV8(e, streamIn, details, void 0, "");
|
|
15433
|
+
sendRequest(refs, { command: "error", flags, error: error2 }, () => {
|
|
15434
|
+
error2.detail = details.load(error2.detail);
|
|
15435
|
+
callback(failureErrorWithLog("Transform failed", [error2], []), null);
|
|
15436
|
+
});
|
|
15437
|
+
}
|
|
15438
|
+
};
|
|
15439
|
+
if ((typeof input === "string" || input instanceof Uint8Array) && input.length > 1024 * 1024) {
|
|
15440
|
+
let next = start;
|
|
15441
|
+
start = () => fs310.writeFile(input, next);
|
|
15442
|
+
}
|
|
15443
|
+
start(null);
|
|
15444
|
+
};
|
|
15445
|
+
let formatMessages2 = ({ callName, refs, messages, options, callback }) => {
|
|
15446
|
+
if (!options) throw new Error(`Missing second argument in ${callName}() call`);
|
|
15447
|
+
let keys2 = {};
|
|
15448
|
+
let kind = getFlag(options, keys2, "kind", mustBeString);
|
|
15449
|
+
let color = getFlag(options, keys2, "color", mustBeBoolean);
|
|
15450
|
+
let terminalWidth = getFlag(options, keys2, "terminalWidth", mustBeInteger);
|
|
15451
|
+
checkForInvalidFlags(options, keys2, `in ${callName}() call`);
|
|
15452
|
+
if (kind === void 0) throw new Error(`Missing "kind" in ${callName}() call`);
|
|
15453
|
+
if (kind !== "error" && kind !== "warning") throw new Error(`Expected "kind" to be "error" or "warning" in ${callName}() call`);
|
|
15454
|
+
let request = {
|
|
15455
|
+
command: "format-msgs",
|
|
15456
|
+
messages: sanitizeMessages(messages, "messages", null, "", terminalWidth),
|
|
15457
|
+
isWarning: kind === "warning"
|
|
15458
|
+
};
|
|
15459
|
+
if (color !== void 0) request.color = color;
|
|
15460
|
+
if (terminalWidth !== void 0) request.terminalWidth = terminalWidth;
|
|
15461
|
+
sendRequest(refs, request, (error2, response) => {
|
|
15462
|
+
if (error2) return callback(new Error(error2), null);
|
|
15463
|
+
callback(null, response.messages);
|
|
15464
|
+
});
|
|
15465
|
+
};
|
|
15466
|
+
let analyzeMetafile2 = ({ callName, refs, metafile, options, callback }) => {
|
|
15467
|
+
if (options === void 0) options = {};
|
|
15468
|
+
let keys2 = {};
|
|
15469
|
+
let color = getFlag(options, keys2, "color", mustBeBoolean);
|
|
15470
|
+
let verbose = getFlag(options, keys2, "verbose", mustBeBoolean);
|
|
15471
|
+
checkForInvalidFlags(options, keys2, `in ${callName}() call`);
|
|
15472
|
+
let request = {
|
|
15473
|
+
command: "analyze-metafile",
|
|
15474
|
+
metafile
|
|
15475
|
+
};
|
|
15476
|
+
if (color !== void 0) request.color = color;
|
|
15477
|
+
if (verbose !== void 0) request.verbose = verbose;
|
|
15478
|
+
sendRequest(refs, request, (error2, response) => {
|
|
15479
|
+
if (error2) return callback(new Error(error2), null);
|
|
15480
|
+
callback(null, response.result);
|
|
15481
|
+
});
|
|
15482
|
+
};
|
|
15483
|
+
return {
|
|
15484
|
+
readFromStdout,
|
|
15485
|
+
afterClose,
|
|
15486
|
+
service: {
|
|
15487
|
+
buildOrContext,
|
|
15488
|
+
transform: transform22,
|
|
15489
|
+
formatMessages: formatMessages2,
|
|
15490
|
+
analyzeMetafile: analyzeMetafile2
|
|
15491
|
+
}
|
|
15492
|
+
};
|
|
15493
|
+
}
|
|
15494
|
+
function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, options, isTTY2, defaultWD2, callback) {
|
|
15495
|
+
const details = createObjectStash();
|
|
15496
|
+
const isContext = callName === "context";
|
|
15497
|
+
const handleError = (e, pluginName) => {
|
|
15498
|
+
const flags = [];
|
|
15499
|
+
try {
|
|
15500
|
+
pushLogFlags(flags, options, {}, isTTY2, buildLogLevelDefault);
|
|
15501
|
+
} catch {
|
|
15502
|
+
}
|
|
15503
|
+
const message = extractErrorMessageV8(e, streamIn, details, void 0, pluginName);
|
|
15504
|
+
sendRequest(refs, { command: "error", flags, error: message }, () => {
|
|
15505
|
+
message.detail = details.load(message.detail);
|
|
15506
|
+
callback(failureErrorWithLog(isContext ? "Context failed" : "Build failed", [message], []), null);
|
|
15507
|
+
});
|
|
15508
|
+
};
|
|
15509
|
+
let plugins2;
|
|
15510
|
+
if (typeof options === "object") {
|
|
15511
|
+
const value2 = options.plugins;
|
|
15512
|
+
if (value2 !== void 0) {
|
|
15513
|
+
if (!Array.isArray(value2)) return handleError(new Error(`"plugins" must be an array`), "");
|
|
15514
|
+
plugins2 = value2;
|
|
15515
|
+
}
|
|
15516
|
+
}
|
|
15517
|
+
if (plugins2 && plugins2.length > 0) {
|
|
15518
|
+
if (streamIn.isSync) return handleError(new Error("Cannot use plugins in synchronous API calls"), "");
|
|
15519
|
+
handlePlugins(
|
|
15520
|
+
buildKey,
|
|
15521
|
+
sendRequest,
|
|
15522
|
+
sendResponse,
|
|
15523
|
+
refs,
|
|
15524
|
+
streamIn,
|
|
15525
|
+
requestCallbacks,
|
|
15526
|
+
options,
|
|
15527
|
+
plugins2,
|
|
15528
|
+
details
|
|
15529
|
+
).then(
|
|
15530
|
+
(result) => {
|
|
15531
|
+
if (!result.ok) return handleError(result.error, result.pluginName);
|
|
15532
|
+
try {
|
|
15533
|
+
buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks, result.scheduleOnDisposeCallbacks);
|
|
15534
|
+
} catch (e) {
|
|
15535
|
+
handleError(e, "");
|
|
15536
|
+
}
|
|
15537
|
+
},
|
|
15538
|
+
(e) => handleError(e, "")
|
|
15539
|
+
);
|
|
15540
|
+
return;
|
|
15541
|
+
}
|
|
15542
|
+
try {
|
|
15543
|
+
buildOrContextContinue(null, (result, done) => done([], []), () => {
|
|
15544
|
+
});
|
|
15545
|
+
} catch (e) {
|
|
15546
|
+
handleError(e, "");
|
|
15547
|
+
}
|
|
15548
|
+
function buildOrContextContinue(requestPlugins, runOnEndCallbacks, scheduleOnDisposeCallbacks) {
|
|
15549
|
+
const writeDefault = streamIn.hasFS;
|
|
15550
|
+
const {
|
|
15551
|
+
entries,
|
|
15552
|
+
flags,
|
|
15553
|
+
write,
|
|
15554
|
+
stdinContents,
|
|
15555
|
+
stdinResolveDir,
|
|
15556
|
+
absWorkingDir,
|
|
15557
|
+
nodePaths,
|
|
15558
|
+
mangleCache
|
|
15559
|
+
} = flagsForBuildOptions(callName, options, isTTY2, buildLogLevelDefault, writeDefault);
|
|
15560
|
+
if (write && !streamIn.hasFS) throw new Error(`The "write" option is unavailable in this environment`);
|
|
15561
|
+
const request = {
|
|
15562
|
+
command: "build",
|
|
15563
|
+
key: buildKey,
|
|
15564
|
+
entries,
|
|
15565
|
+
flags,
|
|
15566
|
+
write,
|
|
15567
|
+
stdinContents,
|
|
15568
|
+
stdinResolveDir,
|
|
15569
|
+
absWorkingDir: absWorkingDir || defaultWD2,
|
|
15570
|
+
nodePaths,
|
|
15571
|
+
context: isContext
|
|
15572
|
+
};
|
|
15573
|
+
if (requestPlugins) request.plugins = requestPlugins;
|
|
15574
|
+
if (mangleCache) request.mangleCache = mangleCache;
|
|
15575
|
+
const buildResponseToResult = (response, callback2) => {
|
|
15576
|
+
const result = {
|
|
15577
|
+
errors: replaceDetailsInMessages(response.errors, details),
|
|
15578
|
+
warnings: replaceDetailsInMessages(response.warnings, details),
|
|
15579
|
+
outputFiles: void 0,
|
|
15580
|
+
metafile: void 0,
|
|
15581
|
+
mangleCache: void 0
|
|
15582
|
+
};
|
|
15583
|
+
const originalErrors = result.errors.slice();
|
|
15584
|
+
const originalWarnings = result.warnings.slice();
|
|
15585
|
+
if (response.outputFiles) result.outputFiles = response.outputFiles.map(convertOutputFiles);
|
|
15586
|
+
if (response.metafile) result.metafile = JSON.parse(response.metafile);
|
|
15587
|
+
if (response.mangleCache) result.mangleCache = response.mangleCache;
|
|
15588
|
+
if (response.writeToStdout !== void 0) console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
|
|
15589
|
+
runOnEndCallbacks(result, (onEndErrors, onEndWarnings) => {
|
|
15590
|
+
if (originalErrors.length > 0 || onEndErrors.length > 0) {
|
|
15591
|
+
const error2 = failureErrorWithLog("Build failed", originalErrors.concat(onEndErrors), originalWarnings.concat(onEndWarnings));
|
|
15592
|
+
return callback2(error2, null, onEndErrors, onEndWarnings);
|
|
15593
|
+
}
|
|
15594
|
+
callback2(null, result, onEndErrors, onEndWarnings);
|
|
15595
|
+
});
|
|
15596
|
+
};
|
|
15597
|
+
let latestResultPromise;
|
|
15598
|
+
let provideLatestResult;
|
|
15599
|
+
if (isContext)
|
|
15600
|
+
requestCallbacks["on-end"] = (id, request2) => new Promise((resolve35) => {
|
|
15601
|
+
buildResponseToResult(request2, (err, result, onEndErrors, onEndWarnings) => {
|
|
15602
|
+
const response = {
|
|
15603
|
+
errors: onEndErrors,
|
|
15604
|
+
warnings: onEndWarnings
|
|
15605
|
+
};
|
|
15606
|
+
if (provideLatestResult) provideLatestResult(err, result);
|
|
15607
|
+
latestResultPromise = void 0;
|
|
15608
|
+
provideLatestResult = void 0;
|
|
15609
|
+
sendResponse(id, response);
|
|
15610
|
+
resolve35();
|
|
15611
|
+
});
|
|
15612
|
+
});
|
|
15613
|
+
sendRequest(refs, request, (error2, response) => {
|
|
15614
|
+
if (error2) return callback(new Error(error2), null);
|
|
15615
|
+
if (!isContext) {
|
|
15616
|
+
return buildResponseToResult(response, (err, res) => {
|
|
15617
|
+
scheduleOnDisposeCallbacks();
|
|
15618
|
+
return callback(err, res);
|
|
15619
|
+
});
|
|
15620
|
+
}
|
|
15621
|
+
if (response.errors.length > 0) {
|
|
15622
|
+
return callback(failureErrorWithLog("Context failed", response.errors, response.warnings), null);
|
|
15623
|
+
}
|
|
15624
|
+
let didDispose = false;
|
|
15625
|
+
const result = {
|
|
15626
|
+
rebuild: () => {
|
|
15627
|
+
if (!latestResultPromise) latestResultPromise = new Promise((resolve35, reject2) => {
|
|
15628
|
+
let settlePromise;
|
|
15629
|
+
provideLatestResult = (err, result2) => {
|
|
15630
|
+
if (!settlePromise) settlePromise = () => err ? reject2(err) : resolve35(result2);
|
|
15631
|
+
};
|
|
15632
|
+
const triggerAnotherBuild = () => {
|
|
15633
|
+
const request2 = {
|
|
15634
|
+
command: "rebuild",
|
|
15635
|
+
key: buildKey
|
|
15636
|
+
};
|
|
15637
|
+
sendRequest(refs, request2, (error22, response2) => {
|
|
15638
|
+
if (error22) {
|
|
15639
|
+
reject2(new Error(error22));
|
|
15640
|
+
} else if (settlePromise) {
|
|
15641
|
+
settlePromise();
|
|
15642
|
+
} else {
|
|
15643
|
+
triggerAnotherBuild();
|
|
15644
|
+
}
|
|
15645
|
+
});
|
|
15646
|
+
};
|
|
15647
|
+
triggerAnotherBuild();
|
|
15648
|
+
});
|
|
15649
|
+
return latestResultPromise;
|
|
15650
|
+
},
|
|
15651
|
+
watch: (options2 = {}) => new Promise((resolve35, reject2) => {
|
|
15652
|
+
if (!streamIn.hasFS) throw new Error(`Cannot use the "watch" API in this environment`);
|
|
15653
|
+
const keys2 = {};
|
|
15654
|
+
const delay = getFlag(options2, keys2, "delay", mustBeInteger);
|
|
15655
|
+
checkForInvalidFlags(options2, keys2, `in watch() call`);
|
|
15656
|
+
const request2 = {
|
|
15657
|
+
command: "watch",
|
|
15658
|
+
key: buildKey
|
|
15659
|
+
};
|
|
15660
|
+
if (delay) request2.delay = delay;
|
|
15661
|
+
sendRequest(refs, request2, (error22) => {
|
|
15662
|
+
if (error22) reject2(new Error(error22));
|
|
15663
|
+
else resolve35(void 0);
|
|
15664
|
+
});
|
|
15665
|
+
}),
|
|
15666
|
+
serve: (options2 = {}) => new Promise((resolve35, reject2) => {
|
|
15667
|
+
if (!streamIn.hasFS) throw new Error(`Cannot use the "serve" API in this environment`);
|
|
15668
|
+
const keys2 = {};
|
|
15669
|
+
const port = getFlag(options2, keys2, "port", mustBeValidPortNumber);
|
|
15670
|
+
const host = getFlag(options2, keys2, "host", mustBeString);
|
|
15671
|
+
const servedir = getFlag(options2, keys2, "servedir", mustBeString);
|
|
15672
|
+
const keyfile = getFlag(options2, keys2, "keyfile", mustBeString);
|
|
15673
|
+
const certfile = getFlag(options2, keys2, "certfile", mustBeString);
|
|
15674
|
+
const fallback = getFlag(options2, keys2, "fallback", mustBeString);
|
|
15675
|
+
const cors = getFlag(options2, keys2, "cors", mustBeObject);
|
|
15676
|
+
const onRequest = getFlag(options2, keys2, "onRequest", mustBeFunction);
|
|
15677
|
+
checkForInvalidFlags(options2, keys2, `in serve() call`);
|
|
15678
|
+
const request2 = {
|
|
15679
|
+
command: "serve",
|
|
15680
|
+
key: buildKey,
|
|
15681
|
+
onRequest: !!onRequest
|
|
15682
|
+
};
|
|
15683
|
+
if (port !== void 0) request2.port = port;
|
|
15684
|
+
if (host !== void 0) request2.host = host;
|
|
15685
|
+
if (servedir !== void 0) request2.servedir = servedir;
|
|
15686
|
+
if (keyfile !== void 0) request2.keyfile = keyfile;
|
|
15687
|
+
if (certfile !== void 0) request2.certfile = certfile;
|
|
15688
|
+
if (fallback !== void 0) request2.fallback = fallback;
|
|
15689
|
+
if (cors) {
|
|
15690
|
+
const corsKeys = {};
|
|
15691
|
+
const origin = getFlag(cors, corsKeys, "origin", mustBeStringOrArrayOfStrings);
|
|
15692
|
+
checkForInvalidFlags(cors, corsKeys, `on "cors" object`);
|
|
15693
|
+
if (Array.isArray(origin)) request2.corsOrigin = origin;
|
|
15694
|
+
else if (origin !== void 0) request2.corsOrigin = [origin];
|
|
15695
|
+
}
|
|
15696
|
+
sendRequest(refs, request2, (error22, response2) => {
|
|
15697
|
+
if (error22) return reject2(new Error(error22));
|
|
15698
|
+
if (onRequest) {
|
|
15699
|
+
requestCallbacks["serve-request"] = (id, request3) => {
|
|
15700
|
+
onRequest(request3.args);
|
|
15701
|
+
sendResponse(id, {});
|
|
15702
|
+
};
|
|
15703
|
+
}
|
|
15704
|
+
resolve35(response2);
|
|
15705
|
+
});
|
|
15706
|
+
}),
|
|
15707
|
+
cancel: () => new Promise((resolve35) => {
|
|
15708
|
+
if (didDispose) return resolve35();
|
|
15709
|
+
const request2 = {
|
|
15710
|
+
command: "cancel",
|
|
15711
|
+
key: buildKey
|
|
15712
|
+
};
|
|
15713
|
+
sendRequest(refs, request2, () => {
|
|
15714
|
+
resolve35();
|
|
15715
|
+
});
|
|
15716
|
+
}),
|
|
15717
|
+
dispose: () => new Promise((resolve35) => {
|
|
15718
|
+
if (didDispose) return resolve35();
|
|
15719
|
+
didDispose = true;
|
|
15720
|
+
const request2 = {
|
|
15721
|
+
command: "dispose",
|
|
15722
|
+
key: buildKey
|
|
15723
|
+
};
|
|
15724
|
+
sendRequest(refs, request2, () => {
|
|
15725
|
+
resolve35();
|
|
15726
|
+
scheduleOnDisposeCallbacks();
|
|
15727
|
+
refs.unref();
|
|
15728
|
+
});
|
|
15729
|
+
})
|
|
15730
|
+
};
|
|
15731
|
+
refs.ref();
|
|
15732
|
+
callback(null, result);
|
|
15733
|
+
});
|
|
15734
|
+
}
|
|
15735
|
+
}
|
|
15736
|
+
var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, initialOptions, plugins2, details) => {
|
|
15737
|
+
let onStartCallbacks = [];
|
|
15738
|
+
let onEndCallbacks = [];
|
|
15739
|
+
let onResolveCallbacks = {};
|
|
15740
|
+
let onLoadCallbacks = {};
|
|
15741
|
+
let onDisposeCallbacks = [];
|
|
15742
|
+
let nextCallbackID = 0;
|
|
15743
|
+
let i = 0;
|
|
15744
|
+
let requestPlugins = [];
|
|
15745
|
+
let isSetupDone = false;
|
|
15746
|
+
plugins2 = [...plugins2];
|
|
15747
|
+
for (let item of plugins2) {
|
|
15748
|
+
let keys2 = {};
|
|
15749
|
+
if (typeof item !== "object") throw new Error(`Plugin at index ${i} must be an object`);
|
|
15750
|
+
const name = getFlag(item, keys2, "name", mustBeString);
|
|
15751
|
+
if (typeof name !== "string" || name === "") throw new Error(`Plugin at index ${i} is missing a name`);
|
|
15752
|
+
try {
|
|
15753
|
+
let setup = getFlag(item, keys2, "setup", mustBeFunction);
|
|
15754
|
+
if (typeof setup !== "function") throw new Error(`Plugin is missing a setup function`);
|
|
15755
|
+
checkForInvalidFlags(item, keys2, `on plugin ${quote(name)}`);
|
|
15756
|
+
let plugin = {
|
|
15757
|
+
name,
|
|
15758
|
+
onStart: false,
|
|
15759
|
+
onEnd: false,
|
|
15760
|
+
onResolve: [],
|
|
15761
|
+
onLoad: []
|
|
15762
|
+
};
|
|
15763
|
+
i++;
|
|
15764
|
+
let resolve35 = (path310, options = {}) => {
|
|
15765
|
+
if (!isSetupDone) throw new Error('Cannot call "resolve" before plugin setup has completed');
|
|
15766
|
+
if (typeof path310 !== "string") throw new Error(`The path to resolve must be a string`);
|
|
15767
|
+
let keys22 = /* @__PURE__ */ Object.create(null);
|
|
15768
|
+
let pluginName = getFlag(options, keys22, "pluginName", mustBeString);
|
|
15769
|
+
let importer = getFlag(options, keys22, "importer", mustBeString);
|
|
15770
|
+
let namespace = getFlag(options, keys22, "namespace", mustBeString);
|
|
15771
|
+
let resolveDir = getFlag(options, keys22, "resolveDir", mustBeString);
|
|
15772
|
+
let kind = getFlag(options, keys22, "kind", mustBeString);
|
|
15773
|
+
let pluginData = getFlag(options, keys22, "pluginData", canBeAnything);
|
|
15774
|
+
let importAttributes = getFlag(options, keys22, "with", mustBeObject);
|
|
15775
|
+
checkForInvalidFlags(options, keys22, "in resolve() call");
|
|
15776
|
+
return new Promise((resolve210, reject2) => {
|
|
15777
|
+
const request = {
|
|
15778
|
+
command: "resolve",
|
|
15779
|
+
path: path310,
|
|
15780
|
+
key: buildKey,
|
|
15781
|
+
pluginName: name
|
|
15782
|
+
};
|
|
15783
|
+
if (pluginName != null) request.pluginName = pluginName;
|
|
15784
|
+
if (importer != null) request.importer = importer;
|
|
15785
|
+
if (namespace != null) request.namespace = namespace;
|
|
15786
|
+
if (resolveDir != null) request.resolveDir = resolveDir;
|
|
15787
|
+
if (kind != null) request.kind = kind;
|
|
15788
|
+
else throw new Error(`Must specify "kind" when calling "resolve"`);
|
|
15789
|
+
if (pluginData != null) request.pluginData = details.store(pluginData);
|
|
15790
|
+
if (importAttributes != null) request.with = sanitizeStringMap(importAttributes, "with");
|
|
15791
|
+
sendRequest(refs, request, (error2, response) => {
|
|
15792
|
+
if (error2 !== null) reject2(new Error(error2));
|
|
15793
|
+
else resolve210({
|
|
15794
|
+
errors: replaceDetailsInMessages(response.errors, details),
|
|
15795
|
+
warnings: replaceDetailsInMessages(response.warnings, details),
|
|
15796
|
+
path: response.path,
|
|
15797
|
+
external: response.external,
|
|
15798
|
+
sideEffects: response.sideEffects,
|
|
15799
|
+
namespace: response.namespace,
|
|
15800
|
+
suffix: response.suffix,
|
|
15801
|
+
pluginData: details.load(response.pluginData)
|
|
15802
|
+
});
|
|
15803
|
+
});
|
|
15804
|
+
});
|
|
15805
|
+
};
|
|
15806
|
+
let promise = setup({
|
|
15807
|
+
initialOptions,
|
|
15808
|
+
resolve: resolve35,
|
|
15809
|
+
onStart(callback) {
|
|
15810
|
+
let registeredText = `This error came from the "onStart" callback registered here:`;
|
|
15811
|
+
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onStart");
|
|
15812
|
+
onStartCallbacks.push({ name, callback, note: registeredNote });
|
|
15813
|
+
plugin.onStart = true;
|
|
15814
|
+
},
|
|
15815
|
+
onEnd(callback) {
|
|
15816
|
+
let registeredText = `This error came from the "onEnd" callback registered here:`;
|
|
15817
|
+
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onEnd");
|
|
15818
|
+
onEndCallbacks.push({ name, callback, note: registeredNote });
|
|
15819
|
+
plugin.onEnd = true;
|
|
15820
|
+
},
|
|
15821
|
+
onResolve(options, callback) {
|
|
15822
|
+
let registeredText = `This error came from the "onResolve" callback registered here:`;
|
|
15823
|
+
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onResolve");
|
|
15824
|
+
let keys22 = {};
|
|
15825
|
+
let filter3 = getFlag(options, keys22, "filter", mustBeRegExp);
|
|
15826
|
+
let namespace = getFlag(options, keys22, "namespace", mustBeString);
|
|
15827
|
+
checkForInvalidFlags(options, keys22, `in onResolve() call for plugin ${quote(name)}`);
|
|
15828
|
+
if (filter3 == null) throw new Error(`onResolve() call is missing a filter`);
|
|
15829
|
+
let id = nextCallbackID++;
|
|
15830
|
+
onResolveCallbacks[id] = { name, callback, note: registeredNote };
|
|
15831
|
+
plugin.onResolve.push({ id, filter: jsRegExpToGoRegExp(filter3), namespace: namespace || "" });
|
|
15832
|
+
},
|
|
15833
|
+
onLoad(options, callback) {
|
|
15834
|
+
let registeredText = `This error came from the "onLoad" callback registered here:`;
|
|
15835
|
+
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onLoad");
|
|
15836
|
+
let keys22 = {};
|
|
15837
|
+
let filter3 = getFlag(options, keys22, "filter", mustBeRegExp);
|
|
15838
|
+
let namespace = getFlag(options, keys22, "namespace", mustBeString);
|
|
15839
|
+
checkForInvalidFlags(options, keys22, `in onLoad() call for plugin ${quote(name)}`);
|
|
15840
|
+
if (filter3 == null) throw new Error(`onLoad() call is missing a filter`);
|
|
15841
|
+
let id = nextCallbackID++;
|
|
15842
|
+
onLoadCallbacks[id] = { name, callback, note: registeredNote };
|
|
15843
|
+
plugin.onLoad.push({ id, filter: jsRegExpToGoRegExp(filter3), namespace: namespace || "" });
|
|
15844
|
+
},
|
|
15845
|
+
onDispose(callback) {
|
|
15846
|
+
onDisposeCallbacks.push(callback);
|
|
15847
|
+
},
|
|
15848
|
+
esbuild: streamIn.esbuild
|
|
15849
|
+
});
|
|
15850
|
+
if (promise) await promise;
|
|
15851
|
+
requestPlugins.push(plugin);
|
|
15852
|
+
} catch (e) {
|
|
15853
|
+
return { ok: false, error: e, pluginName: name };
|
|
15854
|
+
}
|
|
15855
|
+
}
|
|
15856
|
+
requestCallbacks["on-start"] = async (id, request) => {
|
|
15857
|
+
details.clear();
|
|
15858
|
+
let response = { errors: [], warnings: [] };
|
|
15859
|
+
await Promise.all(onStartCallbacks.map(async ({ name, callback, note }) => {
|
|
15860
|
+
try {
|
|
15861
|
+
let result = await callback();
|
|
15862
|
+
if (result != null) {
|
|
15863
|
+
if (typeof result !== "object") throw new Error(`Expected onStart() callback in plugin ${quote(name)} to return an object`);
|
|
15864
|
+
let keys2 = {};
|
|
15865
|
+
let errors2 = getFlag(result, keys2, "errors", mustBeArray);
|
|
15866
|
+
let warnings = getFlag(result, keys2, "warnings", mustBeArray);
|
|
15867
|
+
checkForInvalidFlags(result, keys2, `from onStart() callback in plugin ${quote(name)}`);
|
|
15868
|
+
if (errors2 != null) response.errors.push(...sanitizeMessages(errors2, "errors", details, name, void 0));
|
|
15869
|
+
if (warnings != null) response.warnings.push(...sanitizeMessages(warnings, "warnings", details, name, void 0));
|
|
15870
|
+
}
|
|
15871
|
+
} catch (e) {
|
|
15872
|
+
response.errors.push(extractErrorMessageV8(e, streamIn, details, note && note(), name));
|
|
15873
|
+
}
|
|
15874
|
+
}));
|
|
15875
|
+
sendResponse(id, response);
|
|
15876
|
+
};
|
|
15877
|
+
requestCallbacks["on-resolve"] = async (id, request) => {
|
|
15878
|
+
let response = {}, name = "", callback, note;
|
|
15879
|
+
for (let id2 of request.ids) {
|
|
15880
|
+
try {
|
|
15881
|
+
({ name, callback, note } = onResolveCallbacks[id2]);
|
|
15882
|
+
let result = await callback({
|
|
15883
|
+
path: request.path,
|
|
15884
|
+
importer: request.importer,
|
|
15885
|
+
namespace: request.namespace,
|
|
15886
|
+
resolveDir: request.resolveDir,
|
|
15887
|
+
kind: request.kind,
|
|
15888
|
+
pluginData: details.load(request.pluginData),
|
|
15889
|
+
with: request.with
|
|
15890
|
+
});
|
|
15891
|
+
if (result != null) {
|
|
15892
|
+
if (typeof result !== "object") throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);
|
|
15893
|
+
let keys2 = {};
|
|
15894
|
+
let pluginName = getFlag(result, keys2, "pluginName", mustBeString);
|
|
15895
|
+
let path310 = getFlag(result, keys2, "path", mustBeString);
|
|
15896
|
+
let namespace = getFlag(result, keys2, "namespace", mustBeString);
|
|
15897
|
+
let suffix = getFlag(result, keys2, "suffix", mustBeString);
|
|
15898
|
+
let external = getFlag(result, keys2, "external", mustBeBoolean);
|
|
15899
|
+
let sideEffects = getFlag(result, keys2, "sideEffects", mustBeBoolean);
|
|
15900
|
+
let pluginData = getFlag(result, keys2, "pluginData", canBeAnything);
|
|
15901
|
+
let errors2 = getFlag(result, keys2, "errors", mustBeArray);
|
|
15902
|
+
let warnings = getFlag(result, keys2, "warnings", mustBeArray);
|
|
15903
|
+
let watchFiles = getFlag(result, keys2, "watchFiles", mustBeArrayOfStrings);
|
|
15904
|
+
let watchDirs = getFlag(result, keys2, "watchDirs", mustBeArrayOfStrings);
|
|
15905
|
+
checkForInvalidFlags(result, keys2, `from onResolve() callback in plugin ${quote(name)}`);
|
|
15906
|
+
response.id = id2;
|
|
15907
|
+
if (pluginName != null) response.pluginName = pluginName;
|
|
15908
|
+
if (path310 != null) response.path = path310;
|
|
15909
|
+
if (namespace != null) response.namespace = namespace;
|
|
15910
|
+
if (suffix != null) response.suffix = suffix;
|
|
15911
|
+
if (external != null) response.external = external;
|
|
15912
|
+
if (sideEffects != null) response.sideEffects = sideEffects;
|
|
15913
|
+
if (pluginData != null) response.pluginData = details.store(pluginData);
|
|
15914
|
+
if (errors2 != null) response.errors = sanitizeMessages(errors2, "errors", details, name, void 0);
|
|
15915
|
+
if (warnings != null) response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
|
|
15916
|
+
if (watchFiles != null) response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
|
|
15917
|
+
if (watchDirs != null) response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
|
|
15918
|
+
break;
|
|
15919
|
+
}
|
|
15920
|
+
} catch (e) {
|
|
15921
|
+
response = { id: id2, errors: [extractErrorMessageV8(e, streamIn, details, note && note(), name)] };
|
|
15922
|
+
break;
|
|
15923
|
+
}
|
|
15924
|
+
}
|
|
15925
|
+
sendResponse(id, response);
|
|
15926
|
+
};
|
|
15927
|
+
requestCallbacks["on-load"] = async (id, request) => {
|
|
15928
|
+
let response = {}, name = "", callback, note;
|
|
15929
|
+
for (let id2 of request.ids) {
|
|
15930
|
+
try {
|
|
15931
|
+
({ name, callback, note } = onLoadCallbacks[id2]);
|
|
15932
|
+
let result = await callback({
|
|
15933
|
+
path: request.path,
|
|
15934
|
+
namespace: request.namespace,
|
|
15935
|
+
suffix: request.suffix,
|
|
15936
|
+
pluginData: details.load(request.pluginData),
|
|
15937
|
+
with: request.with
|
|
15938
|
+
});
|
|
15939
|
+
if (result != null) {
|
|
15940
|
+
if (typeof result !== "object") throw new Error(`Expected onLoad() callback in plugin ${quote(name)} to return an object`);
|
|
15941
|
+
let keys2 = {};
|
|
15942
|
+
let pluginName = getFlag(result, keys2, "pluginName", mustBeString);
|
|
15943
|
+
let contents = getFlag(result, keys2, "contents", mustBeStringOrUint8Array);
|
|
15944
|
+
let resolveDir = getFlag(result, keys2, "resolveDir", mustBeString);
|
|
15945
|
+
let pluginData = getFlag(result, keys2, "pluginData", canBeAnything);
|
|
15946
|
+
let loader2 = getFlag(result, keys2, "loader", mustBeString);
|
|
15947
|
+
let errors2 = getFlag(result, keys2, "errors", mustBeArray);
|
|
15948
|
+
let warnings = getFlag(result, keys2, "warnings", mustBeArray);
|
|
15949
|
+
let watchFiles = getFlag(result, keys2, "watchFiles", mustBeArrayOfStrings);
|
|
15950
|
+
let watchDirs = getFlag(result, keys2, "watchDirs", mustBeArrayOfStrings);
|
|
15951
|
+
checkForInvalidFlags(result, keys2, `from onLoad() callback in plugin ${quote(name)}`);
|
|
15952
|
+
response.id = id2;
|
|
15953
|
+
if (pluginName != null) response.pluginName = pluginName;
|
|
15954
|
+
if (contents instanceof Uint8Array) response.contents = contents;
|
|
15955
|
+
else if (contents != null) response.contents = encodeUTF8(contents);
|
|
15956
|
+
if (resolveDir != null) response.resolveDir = resolveDir;
|
|
15957
|
+
if (pluginData != null) response.pluginData = details.store(pluginData);
|
|
15958
|
+
if (loader2 != null) response.loader = loader2;
|
|
15959
|
+
if (errors2 != null) response.errors = sanitizeMessages(errors2, "errors", details, name, void 0);
|
|
15960
|
+
if (warnings != null) response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
|
|
15961
|
+
if (watchFiles != null) response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
|
|
15962
|
+
if (watchDirs != null) response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
|
|
15963
|
+
break;
|
|
15964
|
+
}
|
|
15965
|
+
} catch (e) {
|
|
15966
|
+
response = { id: id2, errors: [extractErrorMessageV8(e, streamIn, details, note && note(), name)] };
|
|
15967
|
+
break;
|
|
15968
|
+
}
|
|
15969
|
+
}
|
|
15970
|
+
sendResponse(id, response);
|
|
15971
|
+
};
|
|
15972
|
+
let runOnEndCallbacks = (result, done) => done([], []);
|
|
15973
|
+
if (onEndCallbacks.length > 0) {
|
|
15974
|
+
runOnEndCallbacks = (result, done) => {
|
|
15975
|
+
(async () => {
|
|
15976
|
+
const onEndErrors = [];
|
|
15977
|
+
const onEndWarnings = [];
|
|
15978
|
+
for (const { name, callback, note } of onEndCallbacks) {
|
|
15979
|
+
let newErrors;
|
|
15980
|
+
let newWarnings;
|
|
15981
|
+
try {
|
|
15982
|
+
const value2 = await callback(result);
|
|
15983
|
+
if (value2 != null) {
|
|
15984
|
+
if (typeof value2 !== "object") throw new Error(`Expected onEnd() callback in plugin ${quote(name)} to return an object`);
|
|
15985
|
+
let keys2 = {};
|
|
15986
|
+
let errors2 = getFlag(value2, keys2, "errors", mustBeArray);
|
|
15987
|
+
let warnings = getFlag(value2, keys2, "warnings", mustBeArray);
|
|
15988
|
+
checkForInvalidFlags(value2, keys2, `from onEnd() callback in plugin ${quote(name)}`);
|
|
15989
|
+
if (errors2 != null) newErrors = sanitizeMessages(errors2, "errors", details, name, void 0);
|
|
15990
|
+
if (warnings != null) newWarnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
|
|
15991
|
+
}
|
|
15992
|
+
} catch (e) {
|
|
15993
|
+
newErrors = [extractErrorMessageV8(e, streamIn, details, note && note(), name)];
|
|
15994
|
+
}
|
|
15995
|
+
if (newErrors) {
|
|
15996
|
+
onEndErrors.push(...newErrors);
|
|
15997
|
+
try {
|
|
15998
|
+
result.errors.push(...newErrors);
|
|
15999
|
+
} catch {
|
|
16000
|
+
}
|
|
16001
|
+
}
|
|
16002
|
+
if (newWarnings) {
|
|
16003
|
+
onEndWarnings.push(...newWarnings);
|
|
16004
|
+
try {
|
|
16005
|
+
result.warnings.push(...newWarnings);
|
|
16006
|
+
} catch {
|
|
16007
|
+
}
|
|
16008
|
+
}
|
|
16009
|
+
}
|
|
16010
|
+
done(onEndErrors, onEndWarnings);
|
|
16011
|
+
})();
|
|
16012
|
+
};
|
|
16013
|
+
}
|
|
16014
|
+
let scheduleOnDisposeCallbacks = () => {
|
|
16015
|
+
for (const cb of onDisposeCallbacks) {
|
|
16016
|
+
setTimeout(() => cb(), 0);
|
|
16017
|
+
}
|
|
16018
|
+
};
|
|
16019
|
+
isSetupDone = true;
|
|
16020
|
+
return {
|
|
16021
|
+
ok: true,
|
|
16022
|
+
requestPlugins,
|
|
16023
|
+
runOnEndCallbacks,
|
|
16024
|
+
scheduleOnDisposeCallbacks
|
|
16025
|
+
};
|
|
16026
|
+
};
|
|
16027
|
+
function createObjectStash() {
|
|
16028
|
+
const map3 = /* @__PURE__ */ new Map();
|
|
16029
|
+
let nextID = 0;
|
|
16030
|
+
return {
|
|
16031
|
+
clear() {
|
|
16032
|
+
map3.clear();
|
|
16033
|
+
},
|
|
16034
|
+
load(id) {
|
|
16035
|
+
return map3.get(id);
|
|
16036
|
+
},
|
|
16037
|
+
store(value2) {
|
|
16038
|
+
if (value2 === void 0) return -1;
|
|
16039
|
+
const id = nextID++;
|
|
16040
|
+
map3.set(id, value2);
|
|
16041
|
+
return id;
|
|
16042
|
+
}
|
|
16043
|
+
};
|
|
16044
|
+
}
|
|
16045
|
+
function extractCallerV8(e, streamIn, ident) {
|
|
16046
|
+
let note;
|
|
16047
|
+
let tried = false;
|
|
16048
|
+
return () => {
|
|
16049
|
+
if (tried) return note;
|
|
16050
|
+
tried = true;
|
|
16051
|
+
try {
|
|
16052
|
+
let lines = (e.stack + "").split("\n");
|
|
16053
|
+
lines.splice(1, 1);
|
|
16054
|
+
let location2 = parseStackLinesV8(streamIn, lines, ident);
|
|
16055
|
+
if (location2) {
|
|
16056
|
+
note = { text: e.message, location: location2 };
|
|
16057
|
+
return note;
|
|
16058
|
+
}
|
|
16059
|
+
} catch {
|
|
16060
|
+
}
|
|
16061
|
+
};
|
|
16062
|
+
}
|
|
16063
|
+
function extractErrorMessageV8(e, streamIn, stash, note, pluginName) {
|
|
16064
|
+
let text = "Internal error";
|
|
16065
|
+
let location2 = null;
|
|
16066
|
+
try {
|
|
16067
|
+
text = (e && e.message || e) + "";
|
|
16068
|
+
} catch {
|
|
16069
|
+
}
|
|
16070
|
+
try {
|
|
16071
|
+
location2 = parseStackLinesV8(streamIn, (e.stack + "").split("\n"), "");
|
|
16072
|
+
} catch {
|
|
16073
|
+
}
|
|
16074
|
+
return { id: "", pluginName, text, location: location2, notes: note ? [note] : [], detail: stash ? stash.store(e) : -1 };
|
|
16075
|
+
}
|
|
16076
|
+
function parseStackLinesV8(streamIn, lines, ident) {
|
|
16077
|
+
let at = " at ";
|
|
16078
|
+
if (streamIn.readFileSync && !lines[0].startsWith(at) && lines[1].startsWith(at)) {
|
|
16079
|
+
for (let i = 1; i < lines.length; i++) {
|
|
16080
|
+
let line = lines[i];
|
|
16081
|
+
if (!line.startsWith(at)) continue;
|
|
16082
|
+
line = line.slice(at.length);
|
|
16083
|
+
while (true) {
|
|
16084
|
+
let match2 = /^(?:new |async )?\S+ \((.*)\)$/.exec(line);
|
|
16085
|
+
if (match2) {
|
|
16086
|
+
line = match2[1];
|
|
16087
|
+
continue;
|
|
16088
|
+
}
|
|
16089
|
+
match2 = /^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(line);
|
|
16090
|
+
if (match2) {
|
|
16091
|
+
line = match2[1];
|
|
16092
|
+
continue;
|
|
16093
|
+
}
|
|
16094
|
+
match2 = /^(\S+):(\d+):(\d+)$/.exec(line);
|
|
16095
|
+
if (match2) {
|
|
16096
|
+
let contents;
|
|
16097
|
+
try {
|
|
16098
|
+
contents = streamIn.readFileSync(match2[1], "utf8");
|
|
16099
|
+
} catch {
|
|
16100
|
+
break;
|
|
16101
|
+
}
|
|
16102
|
+
let lineText = contents.split(/\r\n|\r|\n|\u2028|\u2029/)[+match2[2] - 1] || "";
|
|
16103
|
+
let column = +match2[3] - 1;
|
|
16104
|
+
let length = lineText.slice(column, column + ident.length) === ident ? ident.length : 0;
|
|
16105
|
+
return {
|
|
16106
|
+
file: match2[1],
|
|
16107
|
+
namespace: "file",
|
|
16108
|
+
line: +match2[2],
|
|
16109
|
+
column: encodeUTF8(lineText.slice(0, column)).length,
|
|
16110
|
+
length: encodeUTF8(lineText.slice(column, column + length)).length,
|
|
16111
|
+
lineText: lineText + "\n" + lines.slice(1).join("\n"),
|
|
16112
|
+
suggestion: ""
|
|
16113
|
+
};
|
|
16114
|
+
}
|
|
16115
|
+
break;
|
|
16116
|
+
}
|
|
16117
|
+
}
|
|
16118
|
+
}
|
|
16119
|
+
return null;
|
|
16120
|
+
}
|
|
16121
|
+
function failureErrorWithLog(text, errors2, warnings) {
|
|
16122
|
+
let limit = 5;
|
|
16123
|
+
text += errors2.length < 1 ? "" : ` with ${errors2.length} error${errors2.length < 2 ? "" : "s"}:` + errors2.slice(0, limit + 1).map((e, i) => {
|
|
16124
|
+
if (i === limit) return "\n...";
|
|
16125
|
+
if (!e.location) return `
|
|
16126
|
+
error: ${e.text}`;
|
|
16127
|
+
let { file, line, column } = e.location;
|
|
16128
|
+
let pluginText = e.pluginName ? `[plugin: ${e.pluginName}] ` : "";
|
|
16129
|
+
return `
|
|
16130
|
+
${file}:${line}:${column}: ERROR: ${pluginText}${e.text}`;
|
|
16131
|
+
}).join("");
|
|
16132
|
+
let error2 = new Error(text);
|
|
16133
|
+
for (const [key, value2] of [["errors", errors2], ["warnings", warnings]]) {
|
|
16134
|
+
Object.defineProperty(error2, key, {
|
|
16135
|
+
configurable: true,
|
|
16136
|
+
enumerable: true,
|
|
16137
|
+
get: () => value2,
|
|
16138
|
+
set: (value22) => Object.defineProperty(error2, key, {
|
|
16139
|
+
configurable: true,
|
|
16140
|
+
enumerable: true,
|
|
16141
|
+
value: value22
|
|
16142
|
+
})
|
|
16143
|
+
});
|
|
16144
|
+
}
|
|
16145
|
+
return error2;
|
|
16146
|
+
}
|
|
16147
|
+
function replaceDetailsInMessages(messages, stash) {
|
|
16148
|
+
for (const message of messages) {
|
|
16149
|
+
message.detail = stash.load(message.detail);
|
|
16150
|
+
}
|
|
16151
|
+
return messages;
|
|
16152
|
+
}
|
|
16153
|
+
function sanitizeLocation(location2, where, terminalWidth) {
|
|
16154
|
+
if (location2 == null) return null;
|
|
16155
|
+
let keys2 = {};
|
|
16156
|
+
let file = getFlag(location2, keys2, "file", mustBeString);
|
|
16157
|
+
let namespace = getFlag(location2, keys2, "namespace", mustBeString);
|
|
16158
|
+
let line = getFlag(location2, keys2, "line", mustBeInteger);
|
|
16159
|
+
let column = getFlag(location2, keys2, "column", mustBeInteger);
|
|
16160
|
+
let length = getFlag(location2, keys2, "length", mustBeInteger);
|
|
16161
|
+
let lineText = getFlag(location2, keys2, "lineText", mustBeString);
|
|
16162
|
+
let suggestion = getFlag(location2, keys2, "suggestion", mustBeString);
|
|
16163
|
+
checkForInvalidFlags(location2, keys2, where);
|
|
16164
|
+
if (lineText) {
|
|
16165
|
+
const relevantASCII = lineText.slice(
|
|
16166
|
+
0,
|
|
16167
|
+
(column && column > 0 ? column : 0) + (length && length > 0 ? length : 0) + (terminalWidth && terminalWidth > 0 ? terminalWidth : 80)
|
|
16168
|
+
);
|
|
16169
|
+
if (!/[\x7F-\uFFFF]/.test(relevantASCII) && !/\n/.test(lineText)) {
|
|
16170
|
+
lineText = relevantASCII;
|
|
16171
|
+
}
|
|
16172
|
+
}
|
|
16173
|
+
return {
|
|
16174
|
+
file: file || "",
|
|
16175
|
+
namespace: namespace || "",
|
|
16176
|
+
line: line || 0,
|
|
16177
|
+
column: column || 0,
|
|
16178
|
+
length: length || 0,
|
|
16179
|
+
lineText: lineText || "",
|
|
16180
|
+
suggestion: suggestion || ""
|
|
16181
|
+
};
|
|
16182
|
+
}
|
|
16183
|
+
function sanitizeMessages(messages, property2, stash, fallbackPluginName, terminalWidth) {
|
|
16184
|
+
let messagesClone = [];
|
|
16185
|
+
let index = 0;
|
|
16186
|
+
for (const message of messages) {
|
|
16187
|
+
let keys2 = {};
|
|
16188
|
+
let id = getFlag(message, keys2, "id", mustBeString);
|
|
16189
|
+
let pluginName = getFlag(message, keys2, "pluginName", mustBeString);
|
|
16190
|
+
let text = getFlag(message, keys2, "text", mustBeString);
|
|
16191
|
+
let location2 = getFlag(message, keys2, "location", mustBeObjectOrNull);
|
|
16192
|
+
let notes = getFlag(message, keys2, "notes", mustBeArray);
|
|
16193
|
+
let detail = getFlag(message, keys2, "detail", canBeAnything);
|
|
16194
|
+
let where = `in element ${index} of "${property2}"`;
|
|
16195
|
+
checkForInvalidFlags(message, keys2, where);
|
|
16196
|
+
let notesClone = [];
|
|
16197
|
+
if (notes) {
|
|
16198
|
+
for (const note of notes) {
|
|
16199
|
+
let noteKeys = {};
|
|
16200
|
+
let noteText = getFlag(note, noteKeys, "text", mustBeString);
|
|
16201
|
+
let noteLocation = getFlag(note, noteKeys, "location", mustBeObjectOrNull);
|
|
16202
|
+
checkForInvalidFlags(note, noteKeys, where);
|
|
16203
|
+
notesClone.push({
|
|
16204
|
+
text: noteText || "",
|
|
16205
|
+
location: sanitizeLocation(noteLocation, where, terminalWidth)
|
|
16206
|
+
});
|
|
16207
|
+
}
|
|
16208
|
+
}
|
|
16209
|
+
messagesClone.push({
|
|
16210
|
+
id: id || "",
|
|
16211
|
+
pluginName: pluginName || fallbackPluginName,
|
|
16212
|
+
text: text || "",
|
|
16213
|
+
location: sanitizeLocation(location2, where, terminalWidth),
|
|
16214
|
+
notes: notesClone,
|
|
16215
|
+
detail: stash ? stash.store(detail) : -1
|
|
16216
|
+
});
|
|
16217
|
+
index++;
|
|
16218
|
+
}
|
|
16219
|
+
return messagesClone;
|
|
16220
|
+
}
|
|
16221
|
+
function sanitizeStringArray(values2, property2) {
|
|
16222
|
+
const result = [];
|
|
16223
|
+
for (const value2 of values2) {
|
|
16224
|
+
if (typeof value2 !== "string") throw new Error(`${quote(property2)} must be an array of strings`);
|
|
16225
|
+
result.push(value2);
|
|
16226
|
+
}
|
|
16227
|
+
return result;
|
|
16228
|
+
}
|
|
16229
|
+
function sanitizeStringMap(map3, property2) {
|
|
16230
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
16231
|
+
for (const key in map3) {
|
|
16232
|
+
const value2 = map3[key];
|
|
16233
|
+
if (typeof value2 !== "string") throw new Error(`key ${quote(key)} in object ${quote(property2)} must be a string`);
|
|
16234
|
+
result[key] = value2;
|
|
16235
|
+
}
|
|
16236
|
+
return result;
|
|
16237
|
+
}
|
|
16238
|
+
function convertOutputFiles({ path: path310, contents, hash }) {
|
|
16239
|
+
let text = null;
|
|
16240
|
+
return {
|
|
16241
|
+
path: path310,
|
|
16242
|
+
contents,
|
|
16243
|
+
hash,
|
|
16244
|
+
get text() {
|
|
16245
|
+
const binary2 = this.contents;
|
|
16246
|
+
if (text === null || binary2 !== contents) {
|
|
16247
|
+
contents = binary2;
|
|
16248
|
+
text = decodeUTF8(binary2);
|
|
16249
|
+
}
|
|
16250
|
+
return text;
|
|
16251
|
+
}
|
|
16252
|
+
};
|
|
16253
|
+
}
|
|
16254
|
+
function jsRegExpToGoRegExp(regexp) {
|
|
16255
|
+
let result = regexp.source;
|
|
16256
|
+
if (regexp.flags) result = `(?${regexp.flags})${result}`;
|
|
16257
|
+
return result;
|
|
16258
|
+
}
|
|
16259
|
+
var fs51 = __require("fs");
|
|
16260
|
+
var os4 = __require("os");
|
|
16261
|
+
var path51 = __require("path");
|
|
16262
|
+
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
|
|
16263
|
+
var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
|
|
16264
|
+
var packageDarwin_arm64 = "@esbuild/darwin-arm64";
|
|
16265
|
+
var packageDarwin_x64 = "@esbuild/darwin-x64";
|
|
16266
|
+
var knownWindowsPackages = {
|
|
16267
|
+
"win32 arm64 LE": "@esbuild/win32-arm64",
|
|
16268
|
+
"win32 ia32 LE": "@esbuild/win32-ia32",
|
|
16269
|
+
"win32 x64 LE": "@esbuild/win32-x64"
|
|
16270
|
+
};
|
|
16271
|
+
var knownUnixlikePackages = {
|
|
16272
|
+
"aix ppc64 BE": "@esbuild/aix-ppc64",
|
|
16273
|
+
"android arm64 LE": "@esbuild/android-arm64",
|
|
16274
|
+
"darwin arm64 LE": "@esbuild/darwin-arm64",
|
|
16275
|
+
"darwin x64 LE": "@esbuild/darwin-x64",
|
|
16276
|
+
"freebsd arm64 LE": "@esbuild/freebsd-arm64",
|
|
16277
|
+
"freebsd x64 LE": "@esbuild/freebsd-x64",
|
|
16278
|
+
"linux arm LE": "@esbuild/linux-arm",
|
|
16279
|
+
"linux arm64 LE": "@esbuild/linux-arm64",
|
|
16280
|
+
"linux ia32 LE": "@esbuild/linux-ia32",
|
|
16281
|
+
"linux mips64el LE": "@esbuild/linux-mips64el",
|
|
16282
|
+
"linux ppc64 LE": "@esbuild/linux-ppc64",
|
|
16283
|
+
"linux riscv64 LE": "@esbuild/linux-riscv64",
|
|
16284
|
+
"linux s390x BE": "@esbuild/linux-s390x",
|
|
16285
|
+
"linux x64 LE": "@esbuild/linux-x64",
|
|
16286
|
+
"linux loong64 LE": "@esbuild/linux-loong64",
|
|
16287
|
+
"netbsd arm64 LE": "@esbuild/netbsd-arm64",
|
|
16288
|
+
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
|
16289
|
+
"openbsd arm64 LE": "@esbuild/openbsd-arm64",
|
|
16290
|
+
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
|
16291
|
+
"sunos x64 LE": "@esbuild/sunos-x64"
|
|
16292
|
+
};
|
|
16293
|
+
var knownWebAssemblyFallbackPackages = {
|
|
16294
|
+
"android arm LE": "@esbuild/android-arm",
|
|
16295
|
+
"android x64 LE": "@esbuild/android-x64",
|
|
16296
|
+
"openharmony arm64 LE": "@esbuild/openharmony-arm64"
|
|
16297
|
+
};
|
|
16298
|
+
function pkgAndSubpathForCurrentPlatform() {
|
|
16299
|
+
let pkg;
|
|
16300
|
+
let subpath;
|
|
16301
|
+
let isWASM = false;
|
|
16302
|
+
let platformKey = `${process.platform} ${os4.arch()} ${os4.endianness()}`;
|
|
16303
|
+
if (platformKey in knownWindowsPackages) {
|
|
16304
|
+
pkg = knownWindowsPackages[platformKey];
|
|
16305
|
+
subpath = "esbuild.exe";
|
|
16306
|
+
} else if (platformKey in knownUnixlikePackages) {
|
|
16307
|
+
pkg = knownUnixlikePackages[platformKey];
|
|
16308
|
+
subpath = "bin/esbuild";
|
|
16309
|
+
} else if (platformKey in knownWebAssemblyFallbackPackages) {
|
|
16310
|
+
pkg = knownWebAssemblyFallbackPackages[platformKey];
|
|
16311
|
+
subpath = "bin/esbuild";
|
|
16312
|
+
isWASM = true;
|
|
16313
|
+
} else {
|
|
16314
|
+
throw new Error(`Unsupported platform: ${platformKey}`);
|
|
16315
|
+
}
|
|
16316
|
+
return { pkg, subpath, isWASM };
|
|
16317
|
+
}
|
|
16318
|
+
function pkgForSomeOtherPlatform() {
|
|
16319
|
+
const libMainJS = __require.resolve("esbuild");
|
|
16320
|
+
const nodeModulesDirectory = path51.dirname(path51.dirname(path51.dirname(libMainJS)));
|
|
16321
|
+
if (path51.basename(nodeModulesDirectory) === "node_modules") {
|
|
16322
|
+
for (const unixKey in knownUnixlikePackages) {
|
|
16323
|
+
try {
|
|
16324
|
+
const pkg = knownUnixlikePackages[unixKey];
|
|
16325
|
+
if (fs51.existsSync(path51.join(nodeModulesDirectory, pkg))) return pkg;
|
|
16326
|
+
} catch {
|
|
16327
|
+
}
|
|
16328
|
+
}
|
|
16329
|
+
for (const windowsKey in knownWindowsPackages) {
|
|
16330
|
+
try {
|
|
16331
|
+
const pkg = knownWindowsPackages[windowsKey];
|
|
16332
|
+
if (fs51.existsSync(path51.join(nodeModulesDirectory, pkg))) return pkg;
|
|
16333
|
+
} catch {
|
|
16334
|
+
}
|
|
16335
|
+
}
|
|
16336
|
+
}
|
|
16337
|
+
return null;
|
|
16338
|
+
}
|
|
16339
|
+
function downloadedBinPath(pkg, subpath) {
|
|
16340
|
+
const esbuildLibDir = path51.dirname(__require.resolve("esbuild"));
|
|
16341
|
+
return path51.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path51.basename(subpath)}`);
|
|
16342
|
+
}
|
|
16343
|
+
function generateBinPath() {
|
|
16344
|
+
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
|
|
16345
|
+
if (!fs51.existsSync(ESBUILD_BINARY_PATH)) {
|
|
16346
|
+
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
|
|
16347
|
+
} else {
|
|
16348
|
+
return { binPath: ESBUILD_BINARY_PATH, isWASM: false };
|
|
16349
|
+
}
|
|
16350
|
+
}
|
|
16351
|
+
const { pkg, subpath, isWASM } = pkgAndSubpathForCurrentPlatform();
|
|
16352
|
+
let binPath;
|
|
16353
|
+
try {
|
|
16354
|
+
binPath = __require.resolve(`${pkg}/${subpath}`);
|
|
16355
|
+
} catch (e) {
|
|
16356
|
+
binPath = downloadedBinPath(pkg, subpath);
|
|
16357
|
+
if (!fs51.existsSync(binPath)) {
|
|
16358
|
+
try {
|
|
16359
|
+
__require.resolve(pkg);
|
|
16360
|
+
} catch {
|
|
16361
|
+
const otherPkg = pkgForSomeOtherPlatform();
|
|
16362
|
+
if (otherPkg) {
|
|
16363
|
+
let suggestions = `
|
|
16364
|
+
Specifically the "${otherPkg}" package is present but this platform
|
|
16365
|
+
needs the "${pkg}" package instead. People often get into this
|
|
16366
|
+
situation by installing esbuild on Windows or macOS and copying "node_modules"
|
|
16367
|
+
into a Docker image that runs Linux, or by copying "node_modules" between
|
|
16368
|
+
Windows and WSL environments.
|
|
16369
|
+
|
|
16370
|
+
If you are installing with npm, you can try not copying the "node_modules"
|
|
16371
|
+
directory when you copy the files over, and running "npm ci" or "npm install"
|
|
16372
|
+
on the destination platform after the copy. Or you could consider using yarn
|
|
16373
|
+
instead of npm which has built-in support for installing a package on multiple
|
|
16374
|
+
platforms simultaneously.
|
|
16375
|
+
|
|
16376
|
+
If you are installing with yarn, you can try listing both this platform and the
|
|
16377
|
+
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
|
|
16378
|
+
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
16379
|
+
Keep in mind that this means multiple copies of esbuild will be present.
|
|
16380
|
+
`;
|
|
16381
|
+
if (pkg === packageDarwin_x64 && otherPkg === packageDarwin_arm64 || pkg === packageDarwin_arm64 && otherPkg === packageDarwin_x64) {
|
|
16382
|
+
suggestions = `
|
|
16383
|
+
Specifically the "${otherPkg}" package is present but this platform
|
|
16384
|
+
needs the "${pkg}" package instead. People often get into this
|
|
16385
|
+
situation by installing esbuild with npm running inside of Rosetta 2 and then
|
|
16386
|
+
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
|
|
16387
|
+
2 is Apple's on-the-fly x86_64-to-arm64 translation service).
|
|
16388
|
+
|
|
16389
|
+
If you are installing with npm, you can try ensuring that both npm and node are
|
|
16390
|
+
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
|
|
16391
|
+
changing how you installed npm and/or node. For example, installing node with
|
|
16392
|
+
the universal installer here should work: https://nodejs.org/en/download/. Or
|
|
16393
|
+
you could consider using yarn instead of npm which has built-in support for
|
|
16394
|
+
installing a package on multiple platforms simultaneously.
|
|
16395
|
+
|
|
16396
|
+
If you are installing with yarn, you can try listing both "arm64" and "x64"
|
|
16397
|
+
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
|
|
16398
|
+
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
16399
|
+
Keep in mind that this means multiple copies of esbuild will be present.
|
|
16400
|
+
`;
|
|
16401
|
+
}
|
|
16402
|
+
throw new Error(`
|
|
16403
|
+
You installed esbuild for another platform than the one you're currently using.
|
|
16404
|
+
This won't work because esbuild is written with native code and needs to
|
|
16405
|
+
install a platform-specific binary executable.
|
|
16406
|
+
${suggestions}
|
|
16407
|
+
Another alternative is to use the "esbuild-wasm" package instead, which works
|
|
16408
|
+
the same way on all platforms. But it comes with a heavy performance cost and
|
|
16409
|
+
can sometimes be 10x slower than the "esbuild" package, so you may also not
|
|
16410
|
+
want to do that.
|
|
16411
|
+
`);
|
|
16412
|
+
}
|
|
16413
|
+
throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
|
|
16414
|
+
|
|
16415
|
+
If you are installing esbuild with npm, make sure that you don't specify the
|
|
16416
|
+
"--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
|
|
16417
|
+
of "package.json" is used by esbuild to install the correct binary executable
|
|
16418
|
+
for your current platform.`);
|
|
16419
|
+
}
|
|
16420
|
+
throw e;
|
|
16421
|
+
}
|
|
16422
|
+
}
|
|
16423
|
+
if (/\.zip\//.test(binPath)) {
|
|
16424
|
+
let pnpapi;
|
|
16425
|
+
try {
|
|
16426
|
+
pnpapi = __require("pnpapi");
|
|
16427
|
+
} catch (e) {
|
|
16428
|
+
}
|
|
16429
|
+
if (pnpapi) {
|
|
16430
|
+
const root2 = pnpapi.getPackageInformation(pnpapi.topLevel).packageLocation;
|
|
16431
|
+
const binTargetPath = path51.join(
|
|
16432
|
+
root2,
|
|
16433
|
+
"node_modules",
|
|
16434
|
+
".cache",
|
|
16435
|
+
"esbuild",
|
|
16436
|
+
`pnpapi-${pkg.replace("/", "-")}-${"0.27.3"}-${path51.basename(subpath)}`
|
|
16437
|
+
);
|
|
16438
|
+
if (!fs51.existsSync(binTargetPath)) {
|
|
16439
|
+
fs51.mkdirSync(path51.dirname(binTargetPath), { recursive: true });
|
|
16440
|
+
fs51.copyFileSync(binPath, binTargetPath);
|
|
16441
|
+
fs51.chmodSync(binTargetPath, 493);
|
|
16442
|
+
}
|
|
16443
|
+
return { binPath: binTargetPath, isWASM };
|
|
16444
|
+
}
|
|
16445
|
+
}
|
|
16446
|
+
return { binPath, isWASM };
|
|
16447
|
+
}
|
|
16448
|
+
var child_process = __require("child_process");
|
|
16449
|
+
var crypto2 = __require("crypto");
|
|
16450
|
+
var path210 = __require("path");
|
|
16451
|
+
var fs210 = __require("fs");
|
|
16452
|
+
var os22 = __require("os");
|
|
16453
|
+
var tty = __require("tty");
|
|
16454
|
+
var worker_threads;
|
|
16455
|
+
if (process.env.ESBUILD_WORKER_THREADS !== "0") {
|
|
16456
|
+
try {
|
|
16457
|
+
worker_threads = __require("worker_threads");
|
|
16458
|
+
} catch {
|
|
16459
|
+
}
|
|
16460
|
+
let [major, minor] = process.versions.node.split(".");
|
|
16461
|
+
if (
|
|
16462
|
+
// <v12.17.0 does not work
|
|
16463
|
+
+major < 12 || +major === 12 && +minor < 17 || +major === 13 && +minor < 13
|
|
16464
|
+
) {
|
|
16465
|
+
worker_threads = void 0;
|
|
16466
|
+
}
|
|
16467
|
+
}
|
|
16468
|
+
var _a2;
|
|
16469
|
+
var isInternalWorkerThread = ((_a2 = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a2.esbuildVersion) === "0.27.3";
|
|
16470
|
+
var esbuildCommandAndArgs = () => {
|
|
16471
|
+
if ((!ESBUILD_BINARY_PATH || false) && (path210.basename(__filename) !== "main.js" || path210.basename(__dirname) !== "lib")) {
|
|
16472
|
+
throw new Error(
|
|
16473
|
+
`The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.
|
|
16474
|
+
|
|
16475
|
+
More information: The file containing the code for esbuild's JavaScript API (${__filename}) does not appear to be inside the esbuild package on the file system, which usually means that the esbuild package was bundled into another file. This is problematic because the API needs to run a binary executable inside the esbuild package which is located using a relative path from the API code to the executable. If the esbuild package is bundled, the relative path will be incorrect and the executable won't be found.`
|
|
16476
|
+
);
|
|
16477
|
+
}
|
|
16478
|
+
if (false) {
|
|
16479
|
+
return ["node", [path210.join(__dirname, "..", "bin", "esbuild")]];
|
|
16480
|
+
} else {
|
|
16481
|
+
const { binPath, isWASM } = generateBinPath();
|
|
16482
|
+
if (isWASM) {
|
|
16483
|
+
return ["node", [binPath]];
|
|
16484
|
+
} else {
|
|
16485
|
+
return [binPath, []];
|
|
16486
|
+
}
|
|
16487
|
+
}
|
|
16488
|
+
};
|
|
16489
|
+
var isTTY = () => tty.isatty(2);
|
|
16490
|
+
var fsSync = {
|
|
16491
|
+
readFile(tempFile, callback) {
|
|
16492
|
+
try {
|
|
16493
|
+
let contents = fs210.readFileSync(tempFile, "utf8");
|
|
16494
|
+
try {
|
|
16495
|
+
fs210.unlinkSync(tempFile);
|
|
16496
|
+
} catch {
|
|
16497
|
+
}
|
|
16498
|
+
callback(null, contents);
|
|
16499
|
+
} catch (err) {
|
|
16500
|
+
callback(err, null);
|
|
16501
|
+
}
|
|
16502
|
+
},
|
|
16503
|
+
writeFile(contents, callback) {
|
|
16504
|
+
try {
|
|
16505
|
+
let tempFile = randomFileName();
|
|
16506
|
+
fs210.writeFileSync(tempFile, contents);
|
|
16507
|
+
callback(tempFile);
|
|
16508
|
+
} catch {
|
|
16509
|
+
callback(null);
|
|
16510
|
+
}
|
|
16511
|
+
}
|
|
16512
|
+
};
|
|
16513
|
+
var fsAsync = {
|
|
16514
|
+
readFile(tempFile, callback) {
|
|
16515
|
+
try {
|
|
16516
|
+
fs210.readFile(tempFile, "utf8", (err, contents) => {
|
|
16517
|
+
try {
|
|
16518
|
+
fs210.unlink(tempFile, () => callback(err, contents));
|
|
16519
|
+
} catch {
|
|
16520
|
+
callback(err, contents);
|
|
16521
|
+
}
|
|
16522
|
+
});
|
|
16523
|
+
} catch (err) {
|
|
16524
|
+
callback(err, null);
|
|
16525
|
+
}
|
|
16526
|
+
},
|
|
16527
|
+
writeFile(contents, callback) {
|
|
16528
|
+
try {
|
|
16529
|
+
let tempFile = randomFileName();
|
|
16530
|
+
fs210.writeFile(tempFile, contents, (err) => err !== null ? callback(null) : callback(tempFile));
|
|
16531
|
+
} catch {
|
|
16532
|
+
callback(null);
|
|
16533
|
+
}
|
|
16534
|
+
}
|
|
16535
|
+
};
|
|
16536
|
+
var version3 = "0.27.3";
|
|
16537
|
+
var build = (options) => ensureServiceIsRunning().build(options);
|
|
16538
|
+
var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
|
|
16539
|
+
var transform2 = (input, options) => ensureServiceIsRunning().transform(input, options);
|
|
16540
|
+
var formatMessages = (messages, options) => ensureServiceIsRunning().formatMessages(messages, options);
|
|
16541
|
+
var analyzeMetafile = (messages, options) => ensureServiceIsRunning().analyzeMetafile(messages, options);
|
|
16542
|
+
var buildSync = (options) => {
|
|
16543
|
+
if (worker_threads && !isInternalWorkerThread) {
|
|
16544
|
+
if (!workerThreadService) workerThreadService = startWorkerThreadService(worker_threads);
|
|
16545
|
+
return workerThreadService.buildSync(options);
|
|
16546
|
+
}
|
|
16547
|
+
let result;
|
|
16548
|
+
runServiceSync((service) => service.buildOrContext({
|
|
16549
|
+
callName: "buildSync",
|
|
16550
|
+
refs: null,
|
|
16551
|
+
options,
|
|
16552
|
+
isTTY: isTTY(),
|
|
16553
|
+
defaultWD,
|
|
16554
|
+
callback: (err, res) => {
|
|
16555
|
+
if (err) throw err;
|
|
16556
|
+
result = res;
|
|
16557
|
+
}
|
|
16558
|
+
}));
|
|
16559
|
+
return result;
|
|
16560
|
+
};
|
|
16561
|
+
var transformSync2 = (input, options) => {
|
|
16562
|
+
if (worker_threads && !isInternalWorkerThread) {
|
|
16563
|
+
if (!workerThreadService) workerThreadService = startWorkerThreadService(worker_threads);
|
|
16564
|
+
return workerThreadService.transformSync(input, options);
|
|
16565
|
+
}
|
|
16566
|
+
let result;
|
|
16567
|
+
runServiceSync((service) => service.transform({
|
|
16568
|
+
callName: "transformSync",
|
|
16569
|
+
refs: null,
|
|
16570
|
+
input,
|
|
16571
|
+
options: options || {},
|
|
16572
|
+
isTTY: isTTY(),
|
|
16573
|
+
fs: fsSync,
|
|
16574
|
+
callback: (err, res) => {
|
|
16575
|
+
if (err) throw err;
|
|
16576
|
+
result = res;
|
|
16577
|
+
}
|
|
16578
|
+
}));
|
|
16579
|
+
return result;
|
|
16580
|
+
};
|
|
16581
|
+
var formatMessagesSync = (messages, options) => {
|
|
16582
|
+
if (worker_threads && !isInternalWorkerThread) {
|
|
16583
|
+
if (!workerThreadService) workerThreadService = startWorkerThreadService(worker_threads);
|
|
16584
|
+
return workerThreadService.formatMessagesSync(messages, options);
|
|
16585
|
+
}
|
|
16586
|
+
let result;
|
|
16587
|
+
runServiceSync((service) => service.formatMessages({
|
|
16588
|
+
callName: "formatMessagesSync",
|
|
16589
|
+
refs: null,
|
|
16590
|
+
messages,
|
|
16591
|
+
options,
|
|
16592
|
+
callback: (err, res) => {
|
|
16593
|
+
if (err) throw err;
|
|
16594
|
+
result = res;
|
|
16595
|
+
}
|
|
16596
|
+
}));
|
|
16597
|
+
return result;
|
|
16598
|
+
};
|
|
16599
|
+
var analyzeMetafileSync = (metafile, options) => {
|
|
16600
|
+
if (worker_threads && !isInternalWorkerThread) {
|
|
16601
|
+
if (!workerThreadService) workerThreadService = startWorkerThreadService(worker_threads);
|
|
16602
|
+
return workerThreadService.analyzeMetafileSync(metafile, options);
|
|
16603
|
+
}
|
|
16604
|
+
let result;
|
|
16605
|
+
runServiceSync((service) => service.analyzeMetafile({
|
|
16606
|
+
callName: "analyzeMetafileSync",
|
|
16607
|
+
refs: null,
|
|
16608
|
+
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
|
16609
|
+
options,
|
|
16610
|
+
callback: (err, res) => {
|
|
16611
|
+
if (err) throw err;
|
|
16612
|
+
result = res;
|
|
16613
|
+
}
|
|
16614
|
+
}));
|
|
16615
|
+
return result;
|
|
16616
|
+
};
|
|
16617
|
+
var stop = () => {
|
|
16618
|
+
if (stopService) stopService();
|
|
16619
|
+
if (workerThreadService) workerThreadService.stop();
|
|
16620
|
+
return Promise.resolve();
|
|
16621
|
+
};
|
|
16622
|
+
var initializeWasCalled = false;
|
|
16623
|
+
var initialize = (options) => {
|
|
16624
|
+
options = validateInitializeOptions(options || {});
|
|
16625
|
+
if (options.wasmURL) throw new Error(`The "wasmURL" option only works in the browser`);
|
|
16626
|
+
if (options.wasmModule) throw new Error(`The "wasmModule" option only works in the browser`);
|
|
16627
|
+
if (options.worker) throw new Error(`The "worker" option only works in the browser`);
|
|
16628
|
+
if (initializeWasCalled) throw new Error('Cannot call "initialize" more than once');
|
|
16629
|
+
ensureServiceIsRunning();
|
|
16630
|
+
initializeWasCalled = true;
|
|
16631
|
+
return Promise.resolve();
|
|
16632
|
+
};
|
|
16633
|
+
var defaultWD = process.cwd();
|
|
16634
|
+
var longLivedService;
|
|
16635
|
+
var stopService;
|
|
16636
|
+
var ensureServiceIsRunning = () => {
|
|
16637
|
+
if (longLivedService) return longLivedService;
|
|
16638
|
+
let [command, args] = esbuildCommandAndArgs();
|
|
16639
|
+
let child = child_process.spawn(command, args.concat(`--service=${"0.27.3"}`, "--ping"), {
|
|
16640
|
+
windowsHide: true,
|
|
16641
|
+
stdio: ["pipe", "pipe", "inherit"],
|
|
16642
|
+
cwd: defaultWD
|
|
16643
|
+
});
|
|
16644
|
+
let { readFromStdout, afterClose, service } = createChannel({
|
|
16645
|
+
writeToStdin(bytes) {
|
|
16646
|
+
child.stdin.write(bytes, (err) => {
|
|
16647
|
+
if (err) afterClose(err);
|
|
16648
|
+
});
|
|
16649
|
+
},
|
|
16650
|
+
readFileSync: fs210.readFileSync,
|
|
16651
|
+
isSync: false,
|
|
16652
|
+
hasFS: true,
|
|
16653
|
+
esbuild: node_exports
|
|
16654
|
+
});
|
|
16655
|
+
child.stdin.on("error", afterClose);
|
|
16656
|
+
child.on("error", afterClose);
|
|
16657
|
+
const stdin = child.stdin;
|
|
16658
|
+
const stdout = child.stdout;
|
|
16659
|
+
stdout.on("data", readFromStdout);
|
|
16660
|
+
stdout.on("end", afterClose);
|
|
16661
|
+
stopService = () => {
|
|
16662
|
+
stdin.destroy();
|
|
16663
|
+
stdout.destroy();
|
|
16664
|
+
child.kill();
|
|
16665
|
+
initializeWasCalled = false;
|
|
16666
|
+
longLivedService = void 0;
|
|
16667
|
+
stopService = void 0;
|
|
16668
|
+
};
|
|
16669
|
+
let refCount = 0;
|
|
16670
|
+
child.unref();
|
|
16671
|
+
if (stdin.unref) {
|
|
16672
|
+
stdin.unref();
|
|
16673
|
+
}
|
|
16674
|
+
if (stdout.unref) {
|
|
16675
|
+
stdout.unref();
|
|
16676
|
+
}
|
|
16677
|
+
const refs = {
|
|
16678
|
+
ref() {
|
|
16679
|
+
if (++refCount === 1) child.ref();
|
|
16680
|
+
},
|
|
16681
|
+
unref() {
|
|
16682
|
+
if (--refCount === 0) child.unref();
|
|
16683
|
+
}
|
|
16684
|
+
};
|
|
16685
|
+
longLivedService = {
|
|
16686
|
+
build: (options) => new Promise((resolve35, reject2) => {
|
|
16687
|
+
service.buildOrContext({
|
|
16688
|
+
callName: "build",
|
|
16689
|
+
refs,
|
|
16690
|
+
options,
|
|
16691
|
+
isTTY: isTTY(),
|
|
16692
|
+
defaultWD,
|
|
16693
|
+
callback: (err, res) => err ? reject2(err) : resolve35(res)
|
|
16694
|
+
});
|
|
16695
|
+
}),
|
|
16696
|
+
context: (options) => new Promise((resolve35, reject2) => service.buildOrContext({
|
|
16697
|
+
callName: "context",
|
|
16698
|
+
refs,
|
|
16699
|
+
options,
|
|
16700
|
+
isTTY: isTTY(),
|
|
16701
|
+
defaultWD,
|
|
16702
|
+
callback: (err, res) => err ? reject2(err) : resolve35(res)
|
|
16703
|
+
})),
|
|
16704
|
+
transform: (input, options) => new Promise((resolve35, reject2) => service.transform({
|
|
16705
|
+
callName: "transform",
|
|
16706
|
+
refs,
|
|
16707
|
+
input,
|
|
16708
|
+
options: options || {},
|
|
16709
|
+
isTTY: isTTY(),
|
|
16710
|
+
fs: fsAsync,
|
|
16711
|
+
callback: (err, res) => err ? reject2(err) : resolve35(res)
|
|
16712
|
+
})),
|
|
16713
|
+
formatMessages: (messages, options) => new Promise((resolve35, reject2) => service.formatMessages({
|
|
16714
|
+
callName: "formatMessages",
|
|
16715
|
+
refs,
|
|
16716
|
+
messages,
|
|
16717
|
+
options,
|
|
16718
|
+
callback: (err, res) => err ? reject2(err) : resolve35(res)
|
|
16719
|
+
})),
|
|
16720
|
+
analyzeMetafile: (metafile, options) => new Promise((resolve35, reject2) => service.analyzeMetafile({
|
|
16721
|
+
callName: "analyzeMetafile",
|
|
16722
|
+
refs,
|
|
16723
|
+
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
|
16724
|
+
options,
|
|
16725
|
+
callback: (err, res) => err ? reject2(err) : resolve35(res)
|
|
16726
|
+
}))
|
|
16727
|
+
};
|
|
16728
|
+
return longLivedService;
|
|
16729
|
+
};
|
|
16730
|
+
var runServiceSync = (callback) => {
|
|
16731
|
+
let [command, args] = esbuildCommandAndArgs();
|
|
16732
|
+
let stdin = new Uint8Array();
|
|
16733
|
+
let { readFromStdout, afterClose, service } = createChannel({
|
|
16734
|
+
writeToStdin(bytes) {
|
|
16735
|
+
if (stdin.length !== 0) throw new Error("Must run at most one command");
|
|
16736
|
+
stdin = bytes;
|
|
16737
|
+
},
|
|
16738
|
+
isSync: true,
|
|
16739
|
+
hasFS: true,
|
|
16740
|
+
esbuild: node_exports
|
|
16741
|
+
});
|
|
16742
|
+
callback(service);
|
|
16743
|
+
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.27.3"}`), {
|
|
16744
|
+
cwd: defaultWD,
|
|
16745
|
+
windowsHide: true,
|
|
16746
|
+
input: stdin,
|
|
16747
|
+
// We don't know how large the output could be. If it's too large, the
|
|
16748
|
+
// command will fail with ENOBUFS. Reserve 16mb for now since that feels
|
|
16749
|
+
// like it should be enough. Also allow overriding this with an environment
|
|
16750
|
+
// variable.
|
|
16751
|
+
maxBuffer: +process.env.ESBUILD_MAX_BUFFER || 16 * 1024 * 1024
|
|
16752
|
+
});
|
|
16753
|
+
readFromStdout(stdout);
|
|
16754
|
+
afterClose(null);
|
|
16755
|
+
};
|
|
16756
|
+
var randomFileName = () => {
|
|
16757
|
+
return path210.join(os22.tmpdir(), `esbuild-${crypto2.randomBytes(32).toString("hex")}`);
|
|
16758
|
+
};
|
|
16759
|
+
var workerThreadService = null;
|
|
16760
|
+
var startWorkerThreadService = (worker_threads2) => {
|
|
16761
|
+
let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
|
|
16762
|
+
let worker = new worker_threads2.Worker(__filename, {
|
|
16763
|
+
workerData: { workerPort, defaultWD, esbuildVersion: "0.27.3" },
|
|
16764
|
+
transferList: [workerPort],
|
|
16765
|
+
// From node's documentation: https://nodejs.org/api/worker_threads.html
|
|
16766
|
+
//
|
|
16767
|
+
// Take care when launching worker threads from preload scripts (scripts loaded
|
|
16768
|
+
// and run using the `-r` command line flag). Unless the `execArgv` option is
|
|
16769
|
+
// explicitly set, new Worker threads automatically inherit the command line flags
|
|
16770
|
+
// from the running process and will preload the same preload scripts as the main
|
|
16771
|
+
// thread. If the preload script unconditionally launches a worker thread, every
|
|
16772
|
+
// thread spawned will spawn another until the application crashes.
|
|
16773
|
+
//
|
|
16774
|
+
execArgv: []
|
|
16775
|
+
});
|
|
16776
|
+
let nextID = 0;
|
|
16777
|
+
let fakeBuildError = (text) => {
|
|
16778
|
+
let error2 = new Error(`Build failed with 1 error:
|
|
16779
|
+
error: ${text}`);
|
|
16780
|
+
let errors2 = [{ id: "", pluginName: "", text, location: null, notes: [], detail: void 0 }];
|
|
16781
|
+
error2.errors = errors2;
|
|
16782
|
+
error2.warnings = [];
|
|
16783
|
+
return error2;
|
|
16784
|
+
};
|
|
16785
|
+
let validateBuildSyncOptions = (options) => {
|
|
16786
|
+
if (!options) return;
|
|
16787
|
+
let plugins2 = options.plugins;
|
|
16788
|
+
if (plugins2 && plugins2.length > 0) throw fakeBuildError(`Cannot use plugins in synchronous API calls`);
|
|
16789
|
+
};
|
|
16790
|
+
let applyProperties = (object3, properties) => {
|
|
16791
|
+
for (let key in properties) {
|
|
16792
|
+
object3[key] = properties[key];
|
|
16793
|
+
}
|
|
16794
|
+
};
|
|
16795
|
+
let runCallSync = (command, args) => {
|
|
16796
|
+
let id = nextID++;
|
|
16797
|
+
let sharedBuffer = new SharedArrayBuffer(8);
|
|
16798
|
+
let sharedBufferView = new Int32Array(sharedBuffer);
|
|
16799
|
+
let msg = { sharedBuffer, id, command, args };
|
|
16800
|
+
worker.postMessage(msg);
|
|
16801
|
+
let status = Atomics.wait(sharedBufferView, 0, 0);
|
|
16802
|
+
if (status !== "ok" && status !== "not-equal") throw new Error("Internal error: Atomics.wait() failed: " + status);
|
|
16803
|
+
let { message: { id: id2, resolve: resolve35, reject: reject2, properties } } = worker_threads2.receiveMessageOnPort(mainPort);
|
|
16804
|
+
if (id !== id2) throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
|
16805
|
+
if (reject2) {
|
|
16806
|
+
applyProperties(reject2, properties);
|
|
16807
|
+
throw reject2;
|
|
16808
|
+
}
|
|
16809
|
+
return resolve35;
|
|
16810
|
+
};
|
|
16811
|
+
worker.unref();
|
|
16812
|
+
return {
|
|
16813
|
+
buildSync(options) {
|
|
16814
|
+
validateBuildSyncOptions(options);
|
|
16815
|
+
return runCallSync("build", [options]);
|
|
16816
|
+
},
|
|
16817
|
+
transformSync(input, options) {
|
|
16818
|
+
return runCallSync("transform", [input, options]);
|
|
16819
|
+
},
|
|
16820
|
+
formatMessagesSync(messages, options) {
|
|
16821
|
+
return runCallSync("formatMessages", [messages, options]);
|
|
16822
|
+
},
|
|
16823
|
+
analyzeMetafileSync(metafile, options) {
|
|
16824
|
+
return runCallSync("analyzeMetafile", [metafile, options]);
|
|
16825
|
+
},
|
|
16826
|
+
stop() {
|
|
16827
|
+
worker.terminate();
|
|
16828
|
+
workerThreadService = null;
|
|
16829
|
+
}
|
|
16830
|
+
};
|
|
16831
|
+
};
|
|
16832
|
+
var startSyncServiceWorker = () => {
|
|
16833
|
+
let workerPort = worker_threads.workerData.workerPort;
|
|
16834
|
+
let parentPort = worker_threads.parentPort;
|
|
16835
|
+
let extractProperties = (object3) => {
|
|
16836
|
+
let properties = {};
|
|
16837
|
+
if (object3 && typeof object3 === "object") {
|
|
16838
|
+
for (let key in object3) {
|
|
16839
|
+
properties[key] = object3[key];
|
|
16840
|
+
}
|
|
16841
|
+
}
|
|
16842
|
+
return properties;
|
|
16843
|
+
};
|
|
16844
|
+
try {
|
|
16845
|
+
let service = ensureServiceIsRunning();
|
|
16846
|
+
defaultWD = worker_threads.workerData.defaultWD;
|
|
16847
|
+
parentPort.on("message", (msg) => {
|
|
16848
|
+
(async () => {
|
|
16849
|
+
let { sharedBuffer, id, command, args } = msg;
|
|
16850
|
+
let sharedBufferView = new Int32Array(sharedBuffer);
|
|
16851
|
+
try {
|
|
16852
|
+
switch (command) {
|
|
16853
|
+
case "build":
|
|
16854
|
+
workerPort.postMessage({ id, resolve: await service.build(args[0]) });
|
|
16855
|
+
break;
|
|
16856
|
+
case "transform":
|
|
16857
|
+
workerPort.postMessage({ id, resolve: await service.transform(args[0], args[1]) });
|
|
16858
|
+
break;
|
|
16859
|
+
case "formatMessages":
|
|
16860
|
+
workerPort.postMessage({ id, resolve: await service.formatMessages(args[0], args[1]) });
|
|
16861
|
+
break;
|
|
16862
|
+
case "analyzeMetafile":
|
|
16863
|
+
workerPort.postMessage({ id, resolve: await service.analyzeMetafile(args[0], args[1]) });
|
|
16864
|
+
break;
|
|
16865
|
+
default:
|
|
16866
|
+
throw new Error(`Invalid command: ${command}`);
|
|
16867
|
+
}
|
|
16868
|
+
} catch (reject2) {
|
|
16869
|
+
workerPort.postMessage({ id, reject: reject2, properties: extractProperties(reject2) });
|
|
16870
|
+
}
|
|
16871
|
+
Atomics.add(sharedBufferView, 0, 1);
|
|
16872
|
+
Atomics.notify(sharedBufferView, 0, Infinity);
|
|
16873
|
+
})();
|
|
16874
|
+
});
|
|
16875
|
+
} catch (reject2) {
|
|
16876
|
+
parentPort.on("message", (msg) => {
|
|
16877
|
+
let { sharedBuffer, id } = msg;
|
|
16878
|
+
let sharedBufferView = new Int32Array(sharedBuffer);
|
|
16879
|
+
workerPort.postMessage({ id, reject: reject2, properties: extractProperties(reject2) });
|
|
16880
|
+
Atomics.add(sharedBufferView, 0, 1);
|
|
16881
|
+
Atomics.notify(sharedBufferView, 0, Infinity);
|
|
16882
|
+
});
|
|
16883
|
+
}
|
|
16884
|
+
};
|
|
16885
|
+
if (isInternalWorkerThread) {
|
|
16886
|
+
startSyncServiceWorker();
|
|
16887
|
+
}
|
|
16888
|
+
var node_default = node_exports;
|
|
16889
|
+
}
|
|
16890
|
+
});
|
|
16891
|
+
|
|
14468
16892
|
// src/api/inline-runtime.ts
|
|
14469
|
-
function
|
|
16893
|
+
function stripTypeScript(code) {
|
|
16894
|
+
const result = (0, import_esbuild.transformSync)(code, {
|
|
16895
|
+
loader: "ts",
|
|
16896
|
+
target: "es2020",
|
|
16897
|
+
// Keep the code readable (no minification)
|
|
16898
|
+
minify: false,
|
|
16899
|
+
// Preserve formatting as much as possible
|
|
16900
|
+
keepNames: true
|
|
16901
|
+
});
|
|
16902
|
+
return result.code;
|
|
16903
|
+
}
|
|
16904
|
+
function generateInlineRuntime(production, exportClasses = false, outputFormat = "typescript") {
|
|
14470
16905
|
const exportKeyword = exportClasses ? "export " : "";
|
|
14471
16906
|
const lines = [];
|
|
14472
16907
|
lines.push("// ============================================================================");
|
|
@@ -14910,9 +17345,13 @@ function generateInlineRuntime(production, exportClasses = false) {
|
|
|
14910
17345
|
}
|
|
14911
17346
|
lines.push("}");
|
|
14912
17347
|
lines.push("");
|
|
14913
|
-
|
|
17348
|
+
const output = lines.join("\n");
|
|
17349
|
+
if (outputFormat === "javascript") {
|
|
17350
|
+
return stripTypeScript(output);
|
|
17351
|
+
}
|
|
17352
|
+
return output;
|
|
14914
17353
|
}
|
|
14915
|
-
function generateInlineDebugClient(moduleFormat = "esm") {
|
|
17354
|
+
function generateInlineDebugClient(moduleFormat = "esm", outputFormat = "typescript") {
|
|
14916
17355
|
const lines = [];
|
|
14917
17356
|
lines.push("// ============================================================================");
|
|
14918
17357
|
lines.push("// Inline Debug Client (auto-created from FLOW_WEAVER_DEBUG env var)");
|
|
@@ -14985,7 +17424,11 @@ function generateInlineDebugClient(moduleFormat = "esm") {
|
|
|
14985
17424
|
lines.push("}");
|
|
14986
17425
|
lines.push("/* eslint-enable @typescript-eslint/no-explicit-any, no-console */");
|
|
14987
17426
|
lines.push("");
|
|
14988
|
-
|
|
17427
|
+
const output = lines.join("\n");
|
|
17428
|
+
if (outputFormat === "javascript") {
|
|
17429
|
+
return stripTypeScript(output);
|
|
17430
|
+
}
|
|
17431
|
+
return output;
|
|
14989
17432
|
}
|
|
14990
17433
|
function generateStandaloneRuntimeModule(production, moduleFormat = "esm") {
|
|
14991
17434
|
const lines = [];
|
|
@@ -15020,10 +17463,12 @@ function generateStandaloneRuntimeModule(production, moduleFormat = "esm") {
|
|
|
15020
17463
|
lines.push("");
|
|
15021
17464
|
return lines.join("\n");
|
|
15022
17465
|
}
|
|
17466
|
+
var import_esbuild;
|
|
15023
17467
|
var init_inline_runtime = __esm({
|
|
15024
17468
|
"src/api/inline-runtime.ts"() {
|
|
15025
17469
|
"use strict";
|
|
15026
17470
|
init_generated_branding();
|
|
17471
|
+
import_esbuild = __toESM(require_main(), 1);
|
|
15027
17472
|
}
|
|
15028
17473
|
});
|
|
15029
17474
|
|
|
@@ -15135,7 +17580,8 @@ function generateCode(ast, options) {
|
|
|
15135
17580
|
externalRuntimePath,
|
|
15136
17581
|
constants = [],
|
|
15137
17582
|
externalNodeTypes = {},
|
|
15138
|
-
generateStubs = false
|
|
17583
|
+
generateStubs = false,
|
|
17584
|
+
outputFormat = "typescript"
|
|
15139
17585
|
} = options || {};
|
|
15140
17586
|
const stubNodeTypes = ast.nodeTypes.filter((nt) => nt.variant === "STUB");
|
|
15141
17587
|
if (stubNodeTypes.length > 0 && !generateStubs) {
|
|
@@ -15484,7 +17930,10 @@ function generateCode(ast, options) {
|
|
|
15484
17930
|
lines.push(generateModuleExports([ast.functionName]));
|
|
15485
17931
|
addLine();
|
|
15486
17932
|
}
|
|
15487
|
-
|
|
17933
|
+
let code = lines.join("\n");
|
|
17934
|
+
if (outputFormat === "javascript") {
|
|
17935
|
+
code = stripTypeScript(code);
|
|
17936
|
+
}
|
|
15488
17937
|
if (sourceMapGenerator && ast.sourceFile) {
|
|
15489
17938
|
const sourceContent = fs2.readFileSync(ast.sourceFile, "utf8");
|
|
15490
17939
|
sourceMapGenerator.setSourceContent(ast.sourceFile, sourceContent);
|
|
@@ -17576,10 +20025,10 @@ var init_string_distance = __esm({
|
|
|
17576
20025
|
});
|
|
17577
20026
|
|
|
17578
20027
|
// node_modules/chevrotain/lib/src/version.js
|
|
17579
|
-
var
|
|
20028
|
+
var VERSION2;
|
|
17580
20029
|
var init_version = __esm({
|
|
17581
20030
|
"node_modules/chevrotain/lib/src/version.js"() {
|
|
17582
|
-
|
|
20031
|
+
VERSION2 = "11.1.1";
|
|
17583
20032
|
}
|
|
17584
20033
|
});
|
|
17585
20034
|
|
|
@@ -26896,8 +29345,8 @@ var init_llk_lookahead = __esm({
|
|
|
26896
29345
|
init_lookahead();
|
|
26897
29346
|
LLkLookaheadStrategy = class {
|
|
26898
29347
|
constructor(options) {
|
|
26899
|
-
var
|
|
26900
|
-
this.maxLookahead = (
|
|
29348
|
+
var _a2;
|
|
29349
|
+
this.maxLookahead = (_a2 = options === null || options === void 0 ? void 0 : options.maxLookahead) !== null && _a2 !== void 0 ? _a2 : DEFAULT_PARSER_CONFIG.maxLookahead;
|
|
26901
29350
|
}
|
|
26902
29351
|
validate(options) {
|
|
26903
29352
|
const leftRecursionErrors = this.validateNoLeftRecursion(options.rules);
|
|
@@ -28766,8 +31215,8 @@ var init_parser = __esm({
|
|
|
28766
31215
|
});
|
|
28767
31216
|
}
|
|
28768
31217
|
this.TRACE_INIT("ComputeLookaheadFunctions", () => {
|
|
28769
|
-
var
|
|
28770
|
-
(_b = (
|
|
31218
|
+
var _a2, _b;
|
|
31219
|
+
(_b = (_a2 = this.lookaheadStrategy).initialize) === null || _b === void 0 ? void 0 : _b.call(_a2, {
|
|
28771
31220
|
rules: values_default(this.gastProductionsCache)
|
|
28772
31221
|
});
|
|
28773
31222
|
this.preComputeLookaheadFunctions(values_default(this.gastProductionsCache));
|
|
@@ -28844,7 +31293,7 @@ var init_api4 = __esm({
|
|
|
28844
31293
|
});
|
|
28845
31294
|
|
|
28846
31295
|
// node_modules/chevrotain/lib/src/diagrams/render_public.js
|
|
28847
|
-
function createSyntaxDiagramsCode(grammar, { resourceBase = `https://unpkg.com/chevrotain@${
|
|
31296
|
+
function createSyntaxDiagramsCode(grammar, { resourceBase = `https://unpkg.com/chevrotain@${VERSION2}/diagrams/`, css = `https://unpkg.com/chevrotain@${VERSION2}/diagrams/diagrams.css` } = {}) {
|
|
28848
31297
|
const header = `
|
|
28849
31298
|
<!-- This is a generated file -->
|
|
28850
31299
|
<!DOCTYPE html>
|
|
@@ -36948,7 +39397,6 @@ var init_serialization_node = __esm({
|
|
|
36948
39397
|
|
|
36949
39398
|
// src/api/compile.ts
|
|
36950
39399
|
import * as fs8 from "node:fs/promises";
|
|
36951
|
-
import { createRequire } from "node:module";
|
|
36952
39400
|
import * as path7 from "node:path";
|
|
36953
39401
|
async function compileWorkflow(filePath, options = {}) {
|
|
36954
39402
|
const startTime = Date.now();
|
|
@@ -37010,7 +39458,7 @@ ${errorMessages.join("\n")}`);
|
|
|
37010
39458
|
sourceFile: filePath,
|
|
37011
39459
|
outputFile,
|
|
37012
39460
|
compiledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
37013
|
-
compilerVersion:
|
|
39461
|
+
compilerVersion: VERSION,
|
|
37014
39462
|
generationTime: Date.now() - startTime
|
|
37015
39463
|
}
|
|
37016
39464
|
};
|
|
@@ -37021,15 +39469,13 @@ function getDefaultOutputFile(sourceFile) {
|
|
|
37021
39469
|
const basename19 = path7.basename(sourceFile, ".ts");
|
|
37022
39470
|
return path7.join(dir, `${basename19}.generated.ts`);
|
|
37023
39471
|
}
|
|
37024
|
-
var require2, COMPILER_VERSION;
|
|
37025
39472
|
var init_compile = __esm({
|
|
37026
39473
|
"src/api/compile.ts"() {
|
|
37027
39474
|
"use strict";
|
|
39475
|
+
init_generated_version();
|
|
37028
39476
|
init_generate();
|
|
37029
39477
|
init_generate_in_place();
|
|
37030
39478
|
init_parse();
|
|
37031
|
-
require2 = createRequire(import.meta.url);
|
|
37032
|
-
({ version: COMPILER_VERSION } = require2("../../package.json"));
|
|
37033
39479
|
}
|
|
37034
39480
|
});
|
|
37035
39481
|
|
|
@@ -57618,12 +60064,12 @@ var require_code = __commonJS({
|
|
|
57618
60064
|
return item === "" || item === '""';
|
|
57619
60065
|
}
|
|
57620
60066
|
get str() {
|
|
57621
|
-
var
|
|
57622
|
-
return (
|
|
60067
|
+
var _a2;
|
|
60068
|
+
return (_a2 = this._str) !== null && _a2 !== void 0 ? _a2 : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
|
|
57623
60069
|
}
|
|
57624
60070
|
get names() {
|
|
57625
|
-
var
|
|
57626
|
-
return (
|
|
60071
|
+
var _a2;
|
|
60072
|
+
return (_a2 = this._names) !== null && _a2 !== void 0 ? _a2 : this._names = this._items.reduce((names, c) => {
|
|
57627
60073
|
if (c instanceof Name)
|
|
57628
60074
|
names[c.str] = (names[c.str] || 0) + 1;
|
|
57629
60075
|
return names;
|
|
@@ -57769,8 +60215,8 @@ var require_scope = __commonJS({
|
|
|
57769
60215
|
return `${prefix}${ng.index++}`;
|
|
57770
60216
|
}
|
|
57771
60217
|
_nameGroup(prefix) {
|
|
57772
|
-
var
|
|
57773
|
-
if (((_b = (
|
|
60218
|
+
var _a2, _b;
|
|
60219
|
+
if (((_b = (_a2 = this._parent) === null || _a2 === void 0 ? void 0 : _a2._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
|
|
57774
60220
|
throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
|
|
57775
60221
|
}
|
|
57776
60222
|
return this._names[prefix] = { prefix, index: 0 };
|
|
@@ -57803,12 +60249,12 @@ var require_scope = __commonJS({
|
|
|
57803
60249
|
return new ValueScopeName(prefix, this._newName(prefix));
|
|
57804
60250
|
}
|
|
57805
60251
|
value(nameOrPrefix, value2) {
|
|
57806
|
-
var
|
|
60252
|
+
var _a2;
|
|
57807
60253
|
if (value2.ref === void 0)
|
|
57808
60254
|
throw new Error("CodeGen: ref must be passed in value");
|
|
57809
60255
|
const name = this.toName(nameOrPrefix);
|
|
57810
60256
|
const { prefix } = name;
|
|
57811
|
-
const valueKey = (
|
|
60257
|
+
const valueKey = (_a2 = value2.key) !== null && _a2 !== void 0 ? _a2 : value2.ref;
|
|
57812
60258
|
let vs = this._values[prefix];
|
|
57813
60259
|
if (vs) {
|
|
57814
60260
|
const _name = vs.get(valueKey);
|
|
@@ -58126,8 +60572,8 @@ var require_codegen = __commonJS({
|
|
|
58126
60572
|
return this;
|
|
58127
60573
|
}
|
|
58128
60574
|
optimizeNames(names, constants) {
|
|
58129
|
-
var
|
|
58130
|
-
this.else = (
|
|
60575
|
+
var _a2;
|
|
60576
|
+
this.else = (_a2 = this.else) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names, constants);
|
|
58131
60577
|
if (!(super.optimizeNames(names, constants) || this.else))
|
|
58132
60578
|
return;
|
|
58133
60579
|
this.condition = optimizeExpr(this.condition, names, constants);
|
|
@@ -58231,16 +60677,16 @@ var require_codegen = __commonJS({
|
|
|
58231
60677
|
return code;
|
|
58232
60678
|
}
|
|
58233
60679
|
optimizeNodes() {
|
|
58234
|
-
var
|
|
60680
|
+
var _a2, _b;
|
|
58235
60681
|
super.optimizeNodes();
|
|
58236
|
-
(
|
|
60682
|
+
(_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNodes();
|
|
58237
60683
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
58238
60684
|
return this;
|
|
58239
60685
|
}
|
|
58240
60686
|
optimizeNames(names, constants) {
|
|
58241
|
-
var
|
|
60687
|
+
var _a2, _b;
|
|
58242
60688
|
super.optimizeNames(names, constants);
|
|
58243
|
-
(
|
|
60689
|
+
(_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names, constants);
|
|
58244
60690
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
|
|
58245
60691
|
return this;
|
|
58246
60692
|
}
|
|
@@ -59020,8 +61466,8 @@ var require_applicability = __commonJS({
|
|
|
59020
61466
|
}
|
|
59021
61467
|
exports2.shouldUseGroup = shouldUseGroup;
|
|
59022
61468
|
function shouldUseRule(schema2, rule) {
|
|
59023
|
-
var
|
|
59024
|
-
return schema2[rule.keyword] !== void 0 || ((
|
|
61469
|
+
var _a2;
|
|
61470
|
+
return schema2[rule.keyword] !== void 0 || ((_a2 = rule.definition.implements) === null || _a2 === void 0 ? void 0 : _a2.some((kwd) => schema2[kwd] !== void 0));
|
|
59025
61471
|
}
|
|
59026
61472
|
exports2.shouldUseRule = shouldUseRule;
|
|
59027
61473
|
}
|
|
@@ -59409,14 +61855,14 @@ var require_keyword = __commonJS({
|
|
|
59409
61855
|
}
|
|
59410
61856
|
exports2.macroKeywordCode = macroKeywordCode;
|
|
59411
61857
|
function funcKeywordCode(cxt, def) {
|
|
59412
|
-
var
|
|
61858
|
+
var _a2;
|
|
59413
61859
|
const { gen, keyword, schema: schema2, parentSchema, $data, it } = cxt;
|
|
59414
61860
|
checkAsyncKeyword(it, def);
|
|
59415
61861
|
const validate = !$data && def.compile ? def.compile.call(it.self, schema2, parentSchema, it) : def.validate;
|
|
59416
61862
|
const validateRef = useKeyword(gen, keyword, validate);
|
|
59417
61863
|
const valid = gen.let("valid");
|
|
59418
61864
|
cxt.block$data(valid, validateKeyword);
|
|
59419
|
-
cxt.ok((
|
|
61865
|
+
cxt.ok((_a2 = def.valid) !== null && _a2 !== void 0 ? _a2 : valid);
|
|
59420
61866
|
function validateKeyword() {
|
|
59421
61867
|
if (def.errors === false) {
|
|
59422
61868
|
assignValid();
|
|
@@ -59447,8 +61893,8 @@ var require_keyword = __commonJS({
|
|
|
59447
61893
|
gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
|
59448
61894
|
}
|
|
59449
61895
|
function reportErrs(errors2) {
|
|
59450
|
-
var
|
|
59451
|
-
gen.if((0, codegen_1.not)((
|
|
61896
|
+
var _a3;
|
|
61897
|
+
gen.if((0, codegen_1.not)((_a3 = def.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
|
|
59452
61898
|
}
|
|
59453
61899
|
}
|
|
59454
61900
|
exports2.funcKeywordCode = funcKeywordCode;
|
|
@@ -60416,7 +62862,7 @@ var require_compile = __commonJS({
|
|
|
60416
62862
|
var validate_1 = require_validate();
|
|
60417
62863
|
var SchemaEnv = class {
|
|
60418
62864
|
constructor(env) {
|
|
60419
|
-
var
|
|
62865
|
+
var _a2;
|
|
60420
62866
|
this.refs = {};
|
|
60421
62867
|
this.dynamicAnchors = {};
|
|
60422
62868
|
let schema2;
|
|
@@ -60425,7 +62871,7 @@ var require_compile = __commonJS({
|
|
|
60425
62871
|
this.schema = env.schema;
|
|
60426
62872
|
this.schemaId = env.schemaId;
|
|
60427
62873
|
this.root = env.root || this;
|
|
60428
|
-
this.baseId = (
|
|
62874
|
+
this.baseId = (_a2 = env.baseId) !== null && _a2 !== void 0 ? _a2 : (0, resolve_1.normalizeId)(schema2 === null || schema2 === void 0 ? void 0 : schema2[env.schemaId || "$id"]);
|
|
60429
62875
|
this.schemaPath = env.schemaPath;
|
|
60430
62876
|
this.localRefs = env.localRefs;
|
|
60431
62877
|
this.meta = env.meta;
|
|
@@ -60521,14 +62967,14 @@ var require_compile = __commonJS({
|
|
|
60521
62967
|
}
|
|
60522
62968
|
exports2.compileSchema = compileSchema;
|
|
60523
62969
|
function resolveRef(root2, baseId, ref) {
|
|
60524
|
-
var
|
|
62970
|
+
var _a2;
|
|
60525
62971
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
60526
62972
|
const schOrFunc = root2.refs[ref];
|
|
60527
62973
|
if (schOrFunc)
|
|
60528
62974
|
return schOrFunc;
|
|
60529
62975
|
let _sch = resolve35.call(this, root2, ref);
|
|
60530
62976
|
if (_sch === void 0) {
|
|
60531
|
-
const schema2 = (
|
|
62977
|
+
const schema2 = (_a2 = root2.localRefs) === null || _a2 === void 0 ? void 0 : _a2[ref];
|
|
60532
62978
|
const { schemaId } = this.opts;
|
|
60533
62979
|
if (schema2)
|
|
60534
62980
|
_sch = new SchemaEnv({ schema: schema2, schemaId, root: root2, baseId });
|
|
@@ -60597,8 +63043,8 @@ var require_compile = __commonJS({
|
|
|
60597
63043
|
"definitions"
|
|
60598
63044
|
]);
|
|
60599
63045
|
function getJsonPointer(parsedRef, { baseId, schema: schema2, root: root2 }) {
|
|
60600
|
-
var
|
|
60601
|
-
if (((
|
|
63046
|
+
var _a2;
|
|
63047
|
+
if (((_a2 = parsedRef.fragment) === null || _a2 === void 0 ? void 0 : _a2[0]) !== "/")
|
|
60602
63048
|
return;
|
|
60603
63049
|
for (const part of parsedRef.fragment.slice(1).split("/")) {
|
|
60604
63050
|
if (typeof schema2 === "boolean")
|
|
@@ -61459,9 +63905,9 @@ var require_core = __commonJS({
|
|
|
61459
63905
|
};
|
|
61460
63906
|
var MAX_EXPRESSION = 200;
|
|
61461
63907
|
function requiredOptions(o) {
|
|
61462
|
-
var
|
|
63908
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
61463
63909
|
const s = o.strict;
|
|
61464
|
-
const _optz = (
|
|
63910
|
+
const _optz = (_a2 = o.code) === null || _a2 === void 0 ? void 0 : _a2.optimize;
|
|
61465
63911
|
const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
|
|
61466
63912
|
const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
|
|
61467
63913
|
const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
|
|
@@ -61935,7 +64381,7 @@ var require_core = __commonJS({
|
|
|
61935
64381
|
}
|
|
61936
64382
|
}
|
|
61937
64383
|
function addRule(keyword, definition, dataType) {
|
|
61938
|
-
var
|
|
64384
|
+
var _a2;
|
|
61939
64385
|
const post = definition === null || definition === void 0 ? void 0 : definition.post;
|
|
61940
64386
|
if (dataType && post)
|
|
61941
64387
|
throw new Error('keyword with "post" flag cannot have "type"');
|
|
@@ -61961,7 +64407,7 @@ var require_core = __commonJS({
|
|
|
61961
64407
|
else
|
|
61962
64408
|
ruleGroup.rules.push(rule);
|
|
61963
64409
|
RULES.all[keyword] = rule;
|
|
61964
|
-
(
|
|
64410
|
+
(_a2 = definition.implements) === null || _a2 === void 0 ? void 0 : _a2.forEach((kwd) => this.addKeyword(kwd));
|
|
61965
64411
|
}
|
|
61966
64412
|
function addBeforeRule(ruleGroup, rule, before) {
|
|
61967
64413
|
const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
|
|
@@ -62095,10 +64541,10 @@ var require_ref = __commonJS({
|
|
|
62095
64541
|
gen.assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`);
|
|
62096
64542
|
}
|
|
62097
64543
|
function addEvaluatedFrom(source) {
|
|
62098
|
-
var
|
|
64544
|
+
var _a2;
|
|
62099
64545
|
if (!it.opts.unevaluated)
|
|
62100
64546
|
return;
|
|
62101
|
-
const schEvaluated = (
|
|
64547
|
+
const schEvaluated = (_a2 = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a2 === void 0 ? void 0 : _a2.evaluated;
|
|
62102
64548
|
if (it.props !== true) {
|
|
62103
64549
|
if (schEvaluated && !schEvaluated.dynamicProps) {
|
|
62104
64550
|
if (schEvaluated.props !== void 0) {
|
|
@@ -63749,7 +66195,7 @@ var require_discriminator = __commonJS({
|
|
|
63749
66195
|
return _valid;
|
|
63750
66196
|
}
|
|
63751
66197
|
function getMapping() {
|
|
63752
|
-
var
|
|
66198
|
+
var _a2;
|
|
63753
66199
|
const oneOfMapping = {};
|
|
63754
66200
|
const topRequired = hasRequired(parentSchema);
|
|
63755
66201
|
let tagRequired = true;
|
|
@@ -63763,7 +66209,7 @@ var require_discriminator = __commonJS({
|
|
|
63763
66209
|
if (sch === void 0)
|
|
63764
66210
|
throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref);
|
|
63765
66211
|
}
|
|
63766
|
-
const propSch = (
|
|
66212
|
+
const propSch = (_a2 = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a2 === void 0 ? void 0 : _a2[tagName];
|
|
63767
66213
|
if (typeof propSch != "object") {
|
|
63768
66214
|
throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`);
|
|
63769
66215
|
}
|
|
@@ -64332,9 +66778,9 @@ var require_dist = __commonJS({
|
|
|
64332
66778
|
return f;
|
|
64333
66779
|
};
|
|
64334
66780
|
function addFormats(ajv, list, fs51, exportName) {
|
|
64335
|
-
var
|
|
66781
|
+
var _a2;
|
|
64336
66782
|
var _b;
|
|
64337
|
-
(
|
|
66783
|
+
(_a2 = (_b = ajv.opts.code).formats) !== null && _a2 !== void 0 ? _a2 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
64338
66784
|
for (const f of list)
|
|
64339
66785
|
ajv.addFormat(f, fs51[f]);
|
|
64340
66786
|
}
|
|
@@ -75294,8 +77740,8 @@ var CookieJar = class {
|
|
|
75294
77740
|
get cookies() {
|
|
75295
77741
|
const now = Date.now();
|
|
75296
77742
|
this._cookies.forEach((cookie, name) => {
|
|
75297
|
-
var
|
|
75298
|
-
if (((
|
|
77743
|
+
var _a2;
|
|
77744
|
+
if (((_a2 = cookie.expires) === null || _a2 === void 0 ? void 0 : _a2.getTime()) < now) {
|
|
75299
77745
|
this._cookies.delete(name);
|
|
75300
77746
|
}
|
|
75301
77747
|
});
|
|
@@ -75756,7 +78202,7 @@ var Request = class _Request extends import_component_emitter2.Emitter {
|
|
|
75756
78202
|
* @private
|
|
75757
78203
|
*/
|
|
75758
78204
|
_create() {
|
|
75759
|
-
var
|
|
78205
|
+
var _a2;
|
|
75760
78206
|
const opts = pick(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
75761
78207
|
opts.xdomain = !!this._opts.xd;
|
|
75762
78208
|
const xhr = this._xhr = this.createRequest(opts);
|
|
@@ -75784,7 +78230,7 @@ var Request = class _Request extends import_component_emitter2.Emitter {
|
|
|
75784
78230
|
xhr.setRequestHeader("Accept", "*/*");
|
|
75785
78231
|
} catch (e) {
|
|
75786
78232
|
}
|
|
75787
|
-
(
|
|
78233
|
+
(_a2 = this._opts.cookieJar) === null || _a2 === void 0 ? void 0 : _a2.addCookies(xhr);
|
|
75788
78234
|
if ("withCredentials" in xhr) {
|
|
75789
78235
|
xhr.withCredentials = this._opts.withCredentials;
|
|
75790
78236
|
}
|
|
@@ -75792,9 +78238,9 @@ var Request = class _Request extends import_component_emitter2.Emitter {
|
|
|
75792
78238
|
xhr.timeout = this._opts.requestTimeout;
|
|
75793
78239
|
}
|
|
75794
78240
|
xhr.onreadystatechange = () => {
|
|
75795
|
-
var
|
|
78241
|
+
var _a3;
|
|
75796
78242
|
if (xhr.readyState === 3) {
|
|
75797
|
-
(
|
|
78243
|
+
(_a3 = this._opts.cookieJar) === null || _a3 === void 0 ? void 0 : _a3.parseCookies(
|
|
75798
78244
|
// @ts-ignore
|
|
75799
78245
|
xhr.getResponseHeader("set-cookie")
|
|
75800
78246
|
);
|
|
@@ -75917,8 +78363,8 @@ function newRequest(opts) {
|
|
|
75917
78363
|
var XMLHttpRequest2 = XMLHttpRequestModule.default || XMLHttpRequestModule;
|
|
75918
78364
|
var XHR = class extends BaseXHR {
|
|
75919
78365
|
request(opts = {}) {
|
|
75920
|
-
var
|
|
75921
|
-
Object.assign(opts, { xd: this.xd, cookieJar: (
|
|
78366
|
+
var _a2;
|
|
78367
|
+
Object.assign(opts, { xd: this.xd, cookieJar: (_a2 = this.socket) === null || _a2 === void 0 ? void 0 : _a2._cookieJar }, this.opts);
|
|
75922
78368
|
return new Request((opts2) => new XMLHttpRequest2(opts2), this.uri(), opts);
|
|
75923
78369
|
}
|
|
75924
78370
|
};
|
|
@@ -76022,8 +78468,8 @@ var WebSocketCtor = globalThisShim.WebSocket || globalThisShim.MozWebSocket;
|
|
|
76022
78468
|
// node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js
|
|
76023
78469
|
var WS = class extends BaseWS {
|
|
76024
78470
|
createSocket(uri, protocols, opts) {
|
|
76025
|
-
var
|
|
76026
|
-
if ((
|
|
78471
|
+
var _a2;
|
|
78472
|
+
if ((_a2 = this.socket) === null || _a2 === void 0 ? void 0 : _a2._cookieJar) {
|
|
76027
78473
|
opts.headers = opts.headers || {};
|
|
76028
78474
|
opts.headers.cookie = typeof opts.headers.cookie === "string" ? [opts.headers.cookie] : opts.headers.cookie || [];
|
|
76029
78475
|
for (const [name, cookie] of this.socket._cookieJar.cookies) {
|
|
@@ -76115,8 +78561,8 @@ var WT = class extends Transport {
|
|
|
76115
78561
|
}
|
|
76116
78562
|
}
|
|
76117
78563
|
doClose() {
|
|
76118
|
-
var
|
|
76119
|
-
(
|
|
78564
|
+
var _a2;
|
|
78565
|
+
(_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.close();
|
|
76120
78566
|
}
|
|
76121
78567
|
};
|
|
76122
78568
|
|
|
@@ -77395,7 +79841,7 @@ var Socket2 = class extends import_component_emitter5.Emitter {
|
|
|
77395
79841
|
* @return self
|
|
77396
79842
|
*/
|
|
77397
79843
|
emit(ev, ...args) {
|
|
77398
|
-
var
|
|
79844
|
+
var _a2, _b, _c;
|
|
77399
79845
|
if (RESERVED_EVENTS2.hasOwnProperty(ev)) {
|
|
77400
79846
|
throw new Error('"' + ev.toString() + '" is a reserved event name');
|
|
77401
79847
|
}
|
|
@@ -77417,7 +79863,7 @@ var Socket2 = class extends import_component_emitter5.Emitter {
|
|
|
77417
79863
|
this._registerAckCallback(id, ack);
|
|
77418
79864
|
packet.id = id;
|
|
77419
79865
|
}
|
|
77420
|
-
const isTransportWritable = (_b = (
|
|
79866
|
+
const isTransportWritable = (_b = (_a2 = this.io.engine) === null || _a2 === void 0 ? void 0 : _a2.transport) === null || _b === void 0 ? void 0 : _b.writable;
|
|
77421
79867
|
const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired());
|
|
77422
79868
|
const discardPacket = this.flags.volatile && !isTransportWritable;
|
|
77423
79869
|
if (discardPacket) {
|
|
@@ -77435,8 +79881,8 @@ var Socket2 = class extends import_component_emitter5.Emitter {
|
|
|
77435
79881
|
* @private
|
|
77436
79882
|
*/
|
|
77437
79883
|
_registerAckCallback(id, ack) {
|
|
77438
|
-
var
|
|
77439
|
-
const timeout = (
|
|
79884
|
+
var _a2;
|
|
79885
|
+
const timeout = (_a2 = this.flags.timeout) !== null && _a2 !== void 0 ? _a2 : this._opts.ackTimeout;
|
|
77440
79886
|
if (timeout === void 0) {
|
|
77441
79887
|
this.acks[id] = ack;
|
|
77442
79888
|
return;
|
|
@@ -78074,7 +80520,7 @@ var import_debug10 = __toESM(require_src(), 1);
|
|
|
78074
80520
|
var debug10 = (0, import_debug10.default)("socket.io-client:manager");
|
|
78075
80521
|
var Manager = class extends import_component_emitter6.Emitter {
|
|
78076
80522
|
constructor(uri, opts) {
|
|
78077
|
-
var
|
|
80523
|
+
var _a2;
|
|
78078
80524
|
super();
|
|
78079
80525
|
this.nsps = {};
|
|
78080
80526
|
this.subs = [];
|
|
@@ -78090,7 +80536,7 @@ var Manager = class extends import_component_emitter6.Emitter {
|
|
|
78090
80536
|
this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
|
|
78091
80537
|
this.reconnectionDelay(opts.reconnectionDelay || 1e3);
|
|
78092
80538
|
this.reconnectionDelayMax(opts.reconnectionDelayMax || 5e3);
|
|
78093
|
-
this.randomizationFactor((
|
|
80539
|
+
this.randomizationFactor((_a2 = opts.randomizationFactor) !== null && _a2 !== void 0 ? _a2 : 0.5);
|
|
78094
80540
|
this.backoff = new Backoff({
|
|
78095
80541
|
min: this.reconnectionDelay(),
|
|
78096
80542
|
max: this.reconnectionDelayMax(),
|
|
@@ -78122,27 +80568,27 @@ var Manager = class extends import_component_emitter6.Emitter {
|
|
|
78122
80568
|
return this;
|
|
78123
80569
|
}
|
|
78124
80570
|
reconnectionDelay(v) {
|
|
78125
|
-
var
|
|
80571
|
+
var _a2;
|
|
78126
80572
|
if (v === void 0)
|
|
78127
80573
|
return this._reconnectionDelay;
|
|
78128
80574
|
this._reconnectionDelay = v;
|
|
78129
|
-
(
|
|
80575
|
+
(_a2 = this.backoff) === null || _a2 === void 0 ? void 0 : _a2.setMin(v);
|
|
78130
80576
|
return this;
|
|
78131
80577
|
}
|
|
78132
80578
|
randomizationFactor(v) {
|
|
78133
|
-
var
|
|
80579
|
+
var _a2;
|
|
78134
80580
|
if (v === void 0)
|
|
78135
80581
|
return this._randomizationFactor;
|
|
78136
80582
|
this._randomizationFactor = v;
|
|
78137
|
-
(
|
|
80583
|
+
(_a2 = this.backoff) === null || _a2 === void 0 ? void 0 : _a2.setJitter(v);
|
|
78138
80584
|
return this;
|
|
78139
80585
|
}
|
|
78140
80586
|
reconnectionDelayMax(v) {
|
|
78141
|
-
var
|
|
80587
|
+
var _a2;
|
|
78142
80588
|
if (v === void 0)
|
|
78143
80589
|
return this._reconnectionDelayMax;
|
|
78144
80590
|
this._reconnectionDelayMax = v;
|
|
78145
|
-
(
|
|
80591
|
+
(_a2 = this.backoff) === null || _a2 === void 0 ? void 0 : _a2.setMax(v);
|
|
78146
80592
|
return this;
|
|
78147
80593
|
}
|
|
78148
80594
|
timeout(v) {
|
|
@@ -78369,10 +80815,10 @@ var Manager = class extends import_component_emitter6.Emitter {
|
|
|
78369
80815
|
* @private
|
|
78370
80816
|
*/
|
|
78371
80817
|
onclose(reason, description) {
|
|
78372
|
-
var
|
|
80818
|
+
var _a2;
|
|
78373
80819
|
debug10("closed due to %s", reason);
|
|
78374
80820
|
this.cleanup();
|
|
78375
|
-
(
|
|
80821
|
+
(_a2 = this.engine) === null || _a2 === void 0 ? void 0 : _a2.close();
|
|
78376
80822
|
this.backoff.reset();
|
|
78377
80823
|
this._readyState = "closed";
|
|
78378
80824
|
this.emitReserved("close", reason, description);
|
|
@@ -83735,12 +86181,12 @@ var NEVER2 = Object.freeze({
|
|
|
83735
86181
|
// @__NO_SIDE_EFFECTS__
|
|
83736
86182
|
function $constructor(name, initializer3, params) {
|
|
83737
86183
|
function init(inst, def) {
|
|
83738
|
-
var
|
|
86184
|
+
var _a2;
|
|
83739
86185
|
Object.defineProperty(inst, "_zod", {
|
|
83740
86186
|
value: inst._zod ?? {},
|
|
83741
86187
|
enumerable: false
|
|
83742
86188
|
});
|
|
83743
|
-
(
|
|
86189
|
+
(_a2 = inst._zod).traits ?? (_a2.traits = /* @__PURE__ */ new Set());
|
|
83744
86190
|
inst._zod.traits.add(name);
|
|
83745
86191
|
initializer3(inst, def);
|
|
83746
86192
|
for (const k in _.prototype) {
|
|
@@ -83755,10 +86201,10 @@ function $constructor(name, initializer3, params) {
|
|
|
83755
86201
|
}
|
|
83756
86202
|
Object.defineProperty(Definition, "name", { value: name });
|
|
83757
86203
|
function _(def) {
|
|
83758
|
-
var
|
|
86204
|
+
var _a2;
|
|
83759
86205
|
const inst = params?.Parent ? new Definition() : this;
|
|
83760
86206
|
init(inst, def);
|
|
83761
|
-
(
|
|
86207
|
+
(_a2 = inst._zod).deferred ?? (_a2.deferred = []);
|
|
83762
86208
|
for (const fn of inst._zod.deferred) {
|
|
83763
86209
|
fn();
|
|
83764
86210
|
}
|
|
@@ -84248,8 +86694,8 @@ function aborted(x, startIndex = 0) {
|
|
|
84248
86694
|
}
|
|
84249
86695
|
function prefixIssues(path51, issues) {
|
|
84250
86696
|
return issues.map((iss) => {
|
|
84251
|
-
var
|
|
84252
|
-
(
|
|
86697
|
+
var _a2;
|
|
86698
|
+
(_a2 = iss).path ?? (_a2.path = []);
|
|
84253
86699
|
iss.path.unshift(path51);
|
|
84254
86700
|
return iss;
|
|
84255
86701
|
});
|
|
@@ -84495,10 +86941,10 @@ var uppercase = /^[^a-z]*$/;
|
|
|
84495
86941
|
|
|
84496
86942
|
// node_modules/zod/v4/core/checks.js
|
|
84497
86943
|
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
84498
|
-
var
|
|
86944
|
+
var _a2;
|
|
84499
86945
|
inst._zod ?? (inst._zod = {});
|
|
84500
86946
|
inst._zod.def = def;
|
|
84501
|
-
(
|
|
86947
|
+
(_a2 = inst._zod).onattach ?? (_a2.onattach = []);
|
|
84502
86948
|
});
|
|
84503
86949
|
var numericOriginMap = {
|
|
84504
86950
|
number: "number",
|
|
@@ -84564,8 +87010,8 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
|
|
|
84564
87010
|
var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
84565
87011
|
$ZodCheck.init(inst, def);
|
|
84566
87012
|
inst._zod.onattach.push((inst2) => {
|
|
84567
|
-
var
|
|
84568
|
-
(
|
|
87013
|
+
var _a2;
|
|
87014
|
+
(_a2 = inst2._zod.bag).multipleOf ?? (_a2.multipleOf = def.value);
|
|
84569
87015
|
});
|
|
84570
87016
|
inst._zod.check = (payload) => {
|
|
84571
87017
|
if (typeof payload.value !== typeof def.value)
|
|
@@ -84658,9 +87104,9 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
84658
87104
|
};
|
|
84659
87105
|
});
|
|
84660
87106
|
var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
84661
|
-
var
|
|
87107
|
+
var _a2;
|
|
84662
87108
|
$ZodCheck.init(inst, def);
|
|
84663
|
-
(
|
|
87109
|
+
(_a2 = inst._zod.def).when ?? (_a2.when = (payload) => {
|
|
84664
87110
|
const val = payload.value;
|
|
84665
87111
|
return !nullish(val) && val.length !== void 0;
|
|
84666
87112
|
});
|
|
@@ -84687,9 +87133,9 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
|
|
|
84687
87133
|
};
|
|
84688
87134
|
});
|
|
84689
87135
|
var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
84690
|
-
var
|
|
87136
|
+
var _a2;
|
|
84691
87137
|
$ZodCheck.init(inst, def);
|
|
84692
|
-
(
|
|
87138
|
+
(_a2 = inst._zod.def).when ?? (_a2.when = (payload) => {
|
|
84693
87139
|
const val = payload.value;
|
|
84694
87140
|
return !nullish(val) && val.length !== void 0;
|
|
84695
87141
|
});
|
|
@@ -84716,9 +87162,9 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
|
|
|
84716
87162
|
};
|
|
84717
87163
|
});
|
|
84718
87164
|
var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
84719
|
-
var
|
|
87165
|
+
var _a2;
|
|
84720
87166
|
$ZodCheck.init(inst, def);
|
|
84721
|
-
(
|
|
87167
|
+
(_a2 = inst._zod.def).when ?? (_a2.when = (payload) => {
|
|
84722
87168
|
const val = payload.value;
|
|
84723
87169
|
return !nullish(val) && val.length !== void 0;
|
|
84724
87170
|
});
|
|
@@ -84747,7 +87193,7 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
|
|
|
84747
87193
|
};
|
|
84748
87194
|
});
|
|
84749
87195
|
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
84750
|
-
var
|
|
87196
|
+
var _a2, _b;
|
|
84751
87197
|
$ZodCheck.init(inst, def);
|
|
84752
87198
|
inst._zod.onattach.push((inst2) => {
|
|
84753
87199
|
const bag = inst2._zod.bag;
|
|
@@ -84758,7 +87204,7 @@ var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat"
|
|
|
84758
87204
|
}
|
|
84759
87205
|
});
|
|
84760
87206
|
if (def.pattern)
|
|
84761
|
-
(
|
|
87207
|
+
(_a2 = inst._zod).check ?? (_a2.check = (payload) => {
|
|
84762
87208
|
def.pattern.lastIndex = 0;
|
|
84763
87209
|
if (def.pattern.test(payload.value))
|
|
84764
87210
|
return;
|
|
@@ -84923,7 +87369,7 @@ var version = {
|
|
|
84923
87369
|
|
|
84924
87370
|
// node_modules/zod/v4/core/schemas.js
|
|
84925
87371
|
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
84926
|
-
var
|
|
87372
|
+
var _a2;
|
|
84927
87373
|
inst ?? (inst = {});
|
|
84928
87374
|
inst._zod.def = def;
|
|
84929
87375
|
inst._zod.bag = inst._zod.bag || {};
|
|
@@ -84938,7 +87384,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
84938
87384
|
}
|
|
84939
87385
|
}
|
|
84940
87386
|
if (checks.length === 0) {
|
|
84941
|
-
(
|
|
87387
|
+
(_a2 = inst._zod).deferred ?? (_a2.deferred = []);
|
|
84942
87388
|
inst._zod.deferred?.push(() => {
|
|
84943
87389
|
inst._zod.run = inst._zod.parse;
|
|
84944
87390
|
});
|
|
@@ -86777,7 +89223,7 @@ var JSONSchemaGenerator = class {
|
|
|
86777
89223
|
this.seen = /* @__PURE__ */ new Map();
|
|
86778
89224
|
}
|
|
86779
89225
|
process(schema2, _params = { path: [], schemaPath: [] }) {
|
|
86780
|
-
var
|
|
89226
|
+
var _a2;
|
|
86781
89227
|
const def = schema2._zod.def;
|
|
86782
89228
|
const formatMap = {
|
|
86783
89229
|
guid: "uuid",
|
|
@@ -87239,7 +89685,7 @@ var JSONSchemaGenerator = class {
|
|
|
87239
89685
|
delete result.schema.default;
|
|
87240
89686
|
}
|
|
87241
89687
|
if (this.io === "input" && result.schema._prefault)
|
|
87242
|
-
(
|
|
89688
|
+
(_a2 = result.schema).default ?? (_a2.default = result.schema._prefault);
|
|
87243
89689
|
delete result.schema._prefault;
|
|
87244
89690
|
const _result = this.seen.get(schema2);
|
|
87245
89691
|
return _result.schema;
|
|
@@ -104982,8 +107428,8 @@ Outputs:
|
|
|
104982
107428
|
`;
|
|
104983
107429
|
|
|
104984
107430
|
// src/export/index.ts
|
|
104985
|
-
var
|
|
104986
|
-
var __dirname2 = path42.dirname(
|
|
107431
|
+
var __filename2 = fileURLToPath4(import.meta.url);
|
|
107432
|
+
var __dirname2 = path42.dirname(__filename2);
|
|
104987
107433
|
async function exportMultiWorkflow(options) {
|
|
104988
107434
|
const inputPath = path42.resolve(options.input);
|
|
104989
107435
|
const outputDir = path42.resolve(options.output);
|
|
@@ -107590,7 +110036,7 @@ async function mcpSetupCommand(options, deps) {
|
|
|
107590
110036
|
|
|
107591
110037
|
// src/cli/index.ts
|
|
107592
110038
|
init_error_utils();
|
|
107593
|
-
var version2 = true ? "0.12.
|
|
110039
|
+
var version2 = true ? "0.12.2" : "0.0.0-dev";
|
|
107594
110040
|
var program2 = new Command();
|
|
107595
110041
|
program2.name("flow-weaver").description("Flow Weaver Annotations - Compile and validate workflow files").version(version2, "-v, --version", "Output the current version");
|
|
107596
110042
|
program2.configureOutput({
|