@danielx/civet 0.11.0 → 0.11.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/CHANGELOG.md +16 -0
- package/dist/browser.js +288 -225
- package/dist/civet +27 -29
- package/dist/main.js +358 -253
- package/dist/main.mjs +358 -253
- package/dist/types.d.ts +4 -0
- package/dist/unplugin/unplugin.js +17 -10
- package/dist/unplugin/unplugin.mjs +17 -10
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1091,6 +1091,60 @@ function literalType(literal) {
|
|
|
1091
1091
|
children: [t]
|
|
1092
1092
|
};
|
|
1093
1093
|
}
|
|
1094
|
+
function typeOfExpression(expression) {
|
|
1095
|
+
let t;
|
|
1096
|
+
if (!isASTNodeObject(expression)) {
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
switch (expression.type) {
|
|
1100
|
+
case "Literal": {
|
|
1101
|
+
switch (expression.subtype) {
|
|
1102
|
+
case "NullLiteral": {
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
default: {
|
|
1106
|
+
t = literalType(expression);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
;
|
|
1110
|
+
break;
|
|
1111
|
+
}
|
|
1112
|
+
case "RegularExpressionLiteral":
|
|
1113
|
+
case "TemplateLiteral": {
|
|
1114
|
+
t = literalType(expression);
|
|
1115
|
+
break;
|
|
1116
|
+
}
|
|
1117
|
+
case "Identifier": {
|
|
1118
|
+
if (expression.name === "undefined") {
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
case "MemberExpression": {
|
|
1123
|
+
t = {
|
|
1124
|
+
type: "TypeTypeof",
|
|
1125
|
+
children: ["typeof ", expression],
|
|
1126
|
+
expression
|
|
1127
|
+
};
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
default: {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
return t;
|
|
1135
|
+
}
|
|
1136
|
+
function typeSuffixForExpression(expression) {
|
|
1137
|
+
const t = typeOfExpression(expression);
|
|
1138
|
+
if (!(t != null)) {
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
return {
|
|
1142
|
+
type: "TypeSuffix",
|
|
1143
|
+
ts: true,
|
|
1144
|
+
t,
|
|
1145
|
+
children: [": ", t]
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1094
1148
|
function makeNumericLiteral(n) {
|
|
1095
1149
|
const s = n.toString();
|
|
1096
1150
|
return {
|
|
@@ -1968,11 +2022,14 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1968
2022
|
const results1 = [];
|
|
1969
2023
|
for (let ref7 = pattern.elements, i7 = 0, len6 = ref7.length; i7 < len6; i7++) {
|
|
1970
2024
|
const elem = ref7[i7];
|
|
1971
|
-
let { typeSuffix } = elem;
|
|
2025
|
+
let { typeSuffix, initializer } = elem;
|
|
1972
2026
|
typeSuffix ??= elem.binding?.typeSuffix;
|
|
1973
2027
|
if (typeSuffix) {
|
|
1974
2028
|
count++;
|
|
1975
2029
|
}
|
|
2030
|
+
if (initializer != null) {
|
|
2031
|
+
typeSuffix ??= typeSuffixForExpression(trimFirstSpace(initializer.expression));
|
|
2032
|
+
}
|
|
1976
2033
|
let typeElement = [typeSuffix?.t, elem.delim];
|
|
1977
2034
|
if (typeSuffix?.optional) {
|
|
1978
2035
|
typeElement[0] = parenthesizeType(typeElement[0]);
|
|
@@ -2007,11 +2064,14 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
2007
2064
|
const results2 = [];
|
|
2008
2065
|
for (let ref8 = pattern.properties, i8 = 0, len7 = ref8.length; i8 < len7; i8++) {
|
|
2009
2066
|
const prop = ref8[i8];
|
|
2010
|
-
let { typeSuffix } = prop;
|
|
2067
|
+
let { typeSuffix, initializer } = prop;
|
|
2011
2068
|
typeSuffix ??= prop.value?.typeSuffix;
|
|
2012
2069
|
if (typeSuffix) {
|
|
2013
2070
|
count++;
|
|
2014
2071
|
}
|
|
2072
|
+
if (initializer != null) {
|
|
2073
|
+
typeSuffix ??= typeSuffixForExpression(trimFirstSpace(initializer.expression));
|
|
2074
|
+
}
|
|
2015
2075
|
typeSuffix ??= {
|
|
2016
2076
|
type: "TypeSuffix",
|
|
2017
2077
|
ts: true,
|
|
@@ -3112,19 +3172,23 @@ function patternBindings(pattern) {
|
|
|
3112
3172
|
function assignResults(node, collect) {
|
|
3113
3173
|
if (!node) return;
|
|
3114
3174
|
switch (node.type) {
|
|
3115
|
-
case "BlockStatement":
|
|
3175
|
+
case "BlockStatement": {
|
|
3116
3176
|
if (node.expressions.length) {
|
|
3117
3177
|
let ref5;
|
|
3118
3178
|
assignResults((ref5 = node.expressions)[ref5.length - 1], collect);
|
|
3119
3179
|
} else {
|
|
3120
3180
|
node.expressions.push(["", collect("void 0"), ";"]);
|
|
3181
|
+
updateParentPointers(node);
|
|
3121
3182
|
}
|
|
3122
3183
|
return;
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3184
|
+
}
|
|
3185
|
+
case "CaseBlock": {
|
|
3186
|
+
for (let ref6 = node.clauses, i4 = 0, len3 = ref6.length; i4 < len3; i4++) {
|
|
3187
|
+
const clause = ref6[i4];
|
|
3188
|
+
assignResults(clause, collect);
|
|
3189
|
+
}
|
|
3127
3190
|
return;
|
|
3191
|
+
}
|
|
3128
3192
|
case "WhenClause":
|
|
3129
3193
|
case "DefaultClause":
|
|
3130
3194
|
case "PatternClause": {
|
|
@@ -3150,7 +3214,8 @@ function assignResults(node, collect) {
|
|
|
3150
3214
|
if (exp.type === "LabelledStatement") {
|
|
3151
3215
|
exp = exp.statement;
|
|
3152
3216
|
}
|
|
3153
|
-
let
|
|
3217
|
+
let ref7;
|
|
3218
|
+
let ref8;
|
|
3154
3219
|
let m1;
|
|
3155
3220
|
switch (exp.type) {
|
|
3156
3221
|
case "BreakStatement":
|
|
@@ -3162,18 +3227,19 @@ function assignResults(node, collect) {
|
|
|
3162
3227
|
return;
|
|
3163
3228
|
}
|
|
3164
3229
|
case "Declaration": {
|
|
3165
|
-
let
|
|
3230
|
+
let ref9;
|
|
3166
3231
|
if (exp.bindings?.length) {
|
|
3167
|
-
|
|
3232
|
+
ref9 = patternAsValue((ref7 = exp.bindings)[ref7.length - 1].pattern);
|
|
3168
3233
|
} else {
|
|
3169
|
-
|
|
3234
|
+
ref9 = "void 0";
|
|
3170
3235
|
}
|
|
3171
3236
|
;
|
|
3172
|
-
const value =
|
|
3237
|
+
const value = ref9;
|
|
3173
3238
|
exp.children.push([
|
|
3174
3239
|
"",
|
|
3175
3240
|
[";", collect(value)]
|
|
3176
3241
|
]);
|
|
3242
|
+
updateParentPointers(exp);
|
|
3177
3243
|
return;
|
|
3178
3244
|
}
|
|
3179
3245
|
case "FunctionExpression": {
|
|
@@ -3182,6 +3248,7 @@ function assignResults(node, collect) {
|
|
|
3182
3248
|
"",
|
|
3183
3249
|
[";", collect(exp.id)]
|
|
3184
3250
|
]);
|
|
3251
|
+
updateParentPointers(exp);
|
|
3185
3252
|
return;
|
|
3186
3253
|
}
|
|
3187
3254
|
break;
|
|
@@ -3197,7 +3264,7 @@ function assignResults(node, collect) {
|
|
|
3197
3264
|
if (exp.expressions.some(isExit)) {
|
|
3198
3265
|
return;
|
|
3199
3266
|
}
|
|
3200
|
-
assignResults(exp.expressions[
|
|
3267
|
+
assignResults((ref8 = exp.expressions)[ref8.length - 1], collect);
|
|
3201
3268
|
return;
|
|
3202
3269
|
}
|
|
3203
3270
|
case "IfStatement": {
|
|
@@ -3207,6 +3274,7 @@ function assignResults(node, collect) {
|
|
|
3207
3274
|
} else {
|
|
3208
3275
|
braceBlock(exp.then);
|
|
3209
3276
|
exp.children.push([" else {", collect("void 0"), "}"]);
|
|
3277
|
+
updateParentPointers(exp);
|
|
3210
3278
|
}
|
|
3211
3279
|
return;
|
|
3212
3280
|
}
|
|
@@ -3215,15 +3283,15 @@ function assignResults(node, collect) {
|
|
|
3215
3283
|
return;
|
|
3216
3284
|
}
|
|
3217
3285
|
case "SwitchStatement": {
|
|
3218
|
-
for (let
|
|
3219
|
-
const clause =
|
|
3286
|
+
for (let ref10 = exp.caseBlock.clauses, i5 = 0, len4 = ref10.length; i5 < len4; i5++) {
|
|
3287
|
+
const clause = ref10[i5];
|
|
3220
3288
|
assignResults(clause, collect);
|
|
3221
3289
|
}
|
|
3222
3290
|
return;
|
|
3223
3291
|
}
|
|
3224
3292
|
case "TryStatement": {
|
|
3225
|
-
for (let
|
|
3226
|
-
const block =
|
|
3293
|
+
for (let ref11 = exp.blocks, i6 = 0, len5 = ref11.length; i6 < len5; i6++) {
|
|
3294
|
+
const block = ref11[i6];
|
|
3227
3295
|
assignResults(block, collect);
|
|
3228
3296
|
}
|
|
3229
3297
|
return;
|
|
@@ -3235,6 +3303,7 @@ function assignResults(node, collect) {
|
|
|
3235
3303
|
const semi2 = exp.children.lastIndexOf(";");
|
|
3236
3304
|
if (0 <= semi2 && semi2 < exp.children.length - 1) {
|
|
3237
3305
|
exp.children.splice(semi2 + 1, 1 / 0, ...[collect(exp.children.slice(semi2 + 1))]);
|
|
3306
|
+
updateParentPointers(exp);
|
|
3238
3307
|
return;
|
|
3239
3308
|
}
|
|
3240
3309
|
;
|
|
@@ -3244,7 +3313,11 @@ function assignResults(node, collect) {
|
|
|
3244
3313
|
if (node[node.length - 1]?.type === "SemicolonDelimiter") {
|
|
3245
3314
|
return;
|
|
3246
3315
|
}
|
|
3316
|
+
const parent = node[1].parent;
|
|
3247
3317
|
node[1] = collect(node[1]);
|
|
3318
|
+
if (parent != null) {
|
|
3319
|
+
updateParentPointers(parent);
|
|
3320
|
+
}
|
|
3248
3321
|
}
|
|
3249
3322
|
function insertReturn(node) {
|
|
3250
3323
|
if (!node) return;
|
|
@@ -3275,9 +3348,9 @@ function insertReturn(node) {
|
|
|
3275
3348
|
insertReturn(node.block);
|
|
3276
3349
|
if (!isExit(node.block)) {
|
|
3277
3350
|
const comment = hasTrailingComment(node.block.expressions);
|
|
3278
|
-
let
|
|
3351
|
+
let ref12;
|
|
3279
3352
|
node.block.expressions.push([
|
|
3280
|
-
comment ? (
|
|
3353
|
+
comment ? (ref12 = node.block.expressions)[ref12.length - 1][0] || "\n" : "",
|
|
3281
3354
|
wrapWithReturn(void 0, node, !comment)
|
|
3282
3355
|
]);
|
|
3283
3356
|
}
|
|
@@ -3303,7 +3376,7 @@ function insertReturn(node) {
|
|
|
3303
3376
|
if (exp.type === "LabelledStatement") {
|
|
3304
3377
|
exp = exp.statement;
|
|
3305
3378
|
}
|
|
3306
|
-
let
|
|
3379
|
+
let ref13;
|
|
3307
3380
|
let m3;
|
|
3308
3381
|
switch (exp.type) {
|
|
3309
3382
|
case "BreakStatement":
|
|
@@ -3315,14 +3388,14 @@ function insertReturn(node) {
|
|
|
3315
3388
|
return;
|
|
3316
3389
|
}
|
|
3317
3390
|
case "Declaration": {
|
|
3318
|
-
let
|
|
3391
|
+
let ref14;
|
|
3319
3392
|
if (exp.bindings?.length) {
|
|
3320
|
-
|
|
3393
|
+
ref14 = [" ", patternAsValue((ref13 = exp.bindings)[ref13.length - 1].pattern)];
|
|
3321
3394
|
} else {
|
|
3322
|
-
|
|
3395
|
+
ref14 = [];
|
|
3323
3396
|
}
|
|
3324
3397
|
;
|
|
3325
|
-
const value =
|
|
3398
|
+
const value = ref14;
|
|
3326
3399
|
const parent = outer.parent;
|
|
3327
3400
|
const index = findChildIndex(parent?.expressions, outer);
|
|
3328
3401
|
assert.notEqual(index, -1, "Could not find declaration in parent");
|
|
@@ -3382,15 +3455,15 @@ function insertReturn(node) {
|
|
|
3382
3455
|
return;
|
|
3383
3456
|
}
|
|
3384
3457
|
case "SwitchStatement": {
|
|
3385
|
-
for (let
|
|
3386
|
-
const clause =
|
|
3458
|
+
for (let ref15 = exp.caseBlock.clauses, i7 = 0, len6 = ref15.length; i7 < len6; i7++) {
|
|
3459
|
+
const clause = ref15[i7];
|
|
3387
3460
|
insertReturn(clause);
|
|
3388
3461
|
}
|
|
3389
3462
|
return;
|
|
3390
3463
|
}
|
|
3391
3464
|
case "TryStatement": {
|
|
3392
|
-
for (let
|
|
3393
|
-
const block =
|
|
3465
|
+
for (let ref16 = exp.blocks, i8 = 0, len7 = ref16.length; i8 < len7; i8++) {
|
|
3466
|
+
const block = ref16[i8];
|
|
3394
3467
|
insertReturn(block);
|
|
3395
3468
|
}
|
|
3396
3469
|
return;
|
|
@@ -3642,9 +3715,9 @@ function iterationDefaultBody(statement) {
|
|
|
3642
3715
|
}
|
|
3643
3716
|
const reduction = statement.type === "ForStatement" && statement.reduction;
|
|
3644
3717
|
function fillBlock(expression) {
|
|
3645
|
-
let
|
|
3718
|
+
let ref17;
|
|
3646
3719
|
let m5;
|
|
3647
|
-
if (m5 = (
|
|
3720
|
+
if (m5 = (ref17 = block.expressions)[ref17.length - 1], Array.isArray(m5) && m5.length >= 2 && typeof m5[1] === "object" && m5[1] != null && "type" in m5[1] && m5[1].type === "EmptyStatement" && "implicit" in m5[1] && m5[1].implicit === true) {
|
|
3648
3721
|
block.expressions.pop();
|
|
3649
3722
|
}
|
|
3650
3723
|
block.expressions.push(expression);
|
|
@@ -3714,8 +3787,8 @@ function processParams(f) {
|
|
|
3714
3787
|
function append2(p) {
|
|
3715
3788
|
(rest ? after : before).push(p);
|
|
3716
3789
|
}
|
|
3717
|
-
for (let
|
|
3718
|
-
const param =
|
|
3790
|
+
for (let ref18 = parameters.parameters, i9 = 0, len8 = ref18.length; i9 < len8; i9++) {
|
|
3791
|
+
const param = ref18[i9];
|
|
3719
3792
|
switch (param.type) {
|
|
3720
3793
|
case "ThisType": {
|
|
3721
3794
|
if (tt) {
|
|
@@ -3727,8 +3800,8 @@ function processParams(f) {
|
|
|
3727
3800
|
} else {
|
|
3728
3801
|
tt = trimFirstSpace(param);
|
|
3729
3802
|
if (before.length || rest) {
|
|
3730
|
-
let
|
|
3731
|
-
let delim = (
|
|
3803
|
+
let ref19;
|
|
3804
|
+
let delim = (ref19 = tt.children)[ref19.length - 1];
|
|
3732
3805
|
if (Array.isArray(delim)) {
|
|
3733
3806
|
delim = delim[delim.length - 1];
|
|
3734
3807
|
}
|
|
@@ -3920,14 +3993,14 @@ function processParams(f) {
|
|
|
3920
3993
|
index2--;
|
|
3921
3994
|
}
|
|
3922
3995
|
const fStatement = classExpressions[index2];
|
|
3923
|
-
for (let
|
|
3924
|
-
const parameter =
|
|
3996
|
+
for (let ref20 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i10 = 0, len9 = ref20.length; i10 < len9; i10++) {
|
|
3997
|
+
const parameter = ref20[i10];
|
|
3925
3998
|
const { accessModifier } = parameter;
|
|
3926
3999
|
if (!(accessModifier || parameter.typeSuffix)) {
|
|
3927
4000
|
continue;
|
|
3928
4001
|
}
|
|
3929
|
-
for (let
|
|
3930
|
-
const binding =
|
|
4002
|
+
for (let ref21 = gatherRecursive(parameter, ($15) => $15.type === "AtBinding"), i11 = 0, len10 = ref21.length; i11 < len10; i11++) {
|
|
4003
|
+
const binding = ref21[i11];
|
|
3931
4004
|
const typeSuffix = binding.parent?.typeSuffix;
|
|
3932
4005
|
if (!(accessModifier || typeSuffix)) {
|
|
3933
4006
|
continue;
|
|
@@ -3965,8 +4038,8 @@ function processParams(f) {
|
|
|
3965
4038
|
decl: "const"
|
|
3966
4039
|
}));
|
|
3967
4040
|
}
|
|
3968
|
-
for (let
|
|
3969
|
-
const binding =
|
|
4041
|
+
for (let ref22 = splices, i12 = 0, len11 = ref22.length; i12 < len11; i12++) {
|
|
4042
|
+
const binding = ref22[i12];
|
|
3970
4043
|
assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding");
|
|
3971
4044
|
prefix.push(makeNode({
|
|
3972
4045
|
type: "Declaration",
|
|
@@ -4018,8 +4091,8 @@ function processSignature(f) {
|
|
|
4018
4091
|
f.async.push("async ");
|
|
4019
4092
|
signature.modifier.async = true;
|
|
4020
4093
|
} else {
|
|
4021
|
-
for (let
|
|
4022
|
-
const a =
|
|
4094
|
+
for (let ref23 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i13 = 0, len12 = ref23.length; i13 < len12; i13++) {
|
|
4095
|
+
const a = ref23[i13];
|
|
4023
4096
|
const i = findChildIndex(a.parent, a);
|
|
4024
4097
|
a.parent.children.splice(i + 1, 0, {
|
|
4025
4098
|
type: "Error",
|
|
@@ -4033,8 +4106,8 @@ function processSignature(f) {
|
|
|
4033
4106
|
f.generator.push("*");
|
|
4034
4107
|
signature.modifier.generator = true;
|
|
4035
4108
|
} else {
|
|
4036
|
-
for (let
|
|
4037
|
-
const y =
|
|
4109
|
+
for (let ref24 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i14 = 0, len13 = ref24.length; i14 < len13; i14++) {
|
|
4110
|
+
const y = ref24[i14];
|
|
4038
4111
|
const i = y.children.findIndex(($19) => $19.type === "Yield");
|
|
4039
4112
|
y.children.splice(i + 1, 0, {
|
|
4040
4113
|
type: "Error",
|
|
@@ -4052,8 +4125,8 @@ function processSignature(f) {
|
|
|
4052
4125
|
}
|
|
4053
4126
|
}
|
|
4054
4127
|
function processFunctions(statements, config2) {
|
|
4055
|
-
for (let
|
|
4056
|
-
const f =
|
|
4128
|
+
for (let ref25 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
|
|
4129
|
+
const f = ref25[i15];
|
|
4057
4130
|
if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
|
|
4058
4131
|
implicitFunctionBlock(f);
|
|
4059
4132
|
}
|
|
@@ -4112,9 +4185,9 @@ function expressionizeIteration(exp) {
|
|
|
4112
4185
|
}
|
|
4113
4186
|
let done;
|
|
4114
4187
|
if (!async) {
|
|
4115
|
-
let
|
|
4116
|
-
if ((
|
|
4117
|
-
const { block: parentBlock, index } =
|
|
4188
|
+
let ref26;
|
|
4189
|
+
if ((ref26 = blockContainingStatement(exp)) && typeof ref26 === "object" && "block" in ref26 && "index" in ref26) {
|
|
4190
|
+
const { block: parentBlock, index } = ref26;
|
|
4118
4191
|
statements[0][0] = parentBlock.expressions[index][0];
|
|
4119
4192
|
parentBlock.expressions.splice(index, index + 1 - index, ...statements);
|
|
4120
4193
|
updateParentPointers(parentBlock);
|
|
@@ -4131,8 +4204,8 @@ function expressionizeIteration(exp) {
|
|
|
4131
4204
|
}
|
|
4132
4205
|
}
|
|
4133
4206
|
function processIterationExpressions(statements) {
|
|
4134
|
-
for (let
|
|
4135
|
-
const s =
|
|
4207
|
+
for (let ref27 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i16 = 0, len15 = ref27.length; i16 < len15; i16++) {
|
|
4208
|
+
const s = ref27[i16];
|
|
4136
4209
|
expressionizeIteration(s);
|
|
4137
4210
|
}
|
|
4138
4211
|
}
|
|
@@ -4156,12 +4229,12 @@ function processCoffeeDo(ws, expression) {
|
|
|
4156
4229
|
let { parameters } = expression;
|
|
4157
4230
|
const parameterList = parameters.parameters;
|
|
4158
4231
|
const results1 = [];
|
|
4159
|
-
for (let
|
|
4160
|
-
let parameter = parameterList[
|
|
4232
|
+
for (let i17 = 0, len16 = parameterList.length; i17 < len16; i17++) {
|
|
4233
|
+
let parameter = parameterList[i17];
|
|
4161
4234
|
if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
|
|
4162
|
-
let
|
|
4163
|
-
if (
|
|
4164
|
-
const initializer =
|
|
4235
|
+
let ref28;
|
|
4236
|
+
if (ref28 = parameter.initializer) {
|
|
4237
|
+
const initializer = ref28;
|
|
4165
4238
|
args.push(initializer.expression, parameter.delim);
|
|
4166
4239
|
parameter = {
|
|
4167
4240
|
...parameter,
|
|
@@ -4291,8 +4364,9 @@ function unbraceBlock(block) {
|
|
|
4291
4364
|
if (block.bare) {
|
|
4292
4365
|
return;
|
|
4293
4366
|
}
|
|
4367
|
+
let m;
|
|
4294
4368
|
let ref;
|
|
4295
|
-
if (block.children[0] === " {" && (ref = block.children)[ref.length - 1] === "}") {
|
|
4369
|
+
if ((m = block.children[0], m === " {" || m === "{") && (ref = block.children)[ref.length - 1] === "}") {
|
|
4296
4370
|
block.children.shift();
|
|
4297
4371
|
block.children.pop();
|
|
4298
4372
|
block.bare = true;
|
|
@@ -4328,17 +4402,6 @@ function makeEmptyBlock() {
|
|
|
4328
4402
|
empty: true
|
|
4329
4403
|
};
|
|
4330
4404
|
}
|
|
4331
|
-
function makeBlockFragment() {
|
|
4332
|
-
const expressions = [];
|
|
4333
|
-
return {
|
|
4334
|
-
type: "BlockStatement",
|
|
4335
|
-
children: expressions,
|
|
4336
|
-
parent: void 0,
|
|
4337
|
-
expressions,
|
|
4338
|
-
bare: false,
|
|
4339
|
-
root: false
|
|
4340
|
-
};
|
|
4341
|
-
}
|
|
4342
4405
|
function replaceBlockExpression(node, child, replacement) {
|
|
4343
4406
|
let found = false;
|
|
4344
4407
|
const { expressions } = node;
|
|
@@ -4384,22 +4447,44 @@ function hoistRefDecs(statements) {
|
|
|
4384
4447
|
});
|
|
4385
4448
|
}
|
|
4386
4449
|
function insertHoistDec(block, node, dec) {
|
|
4387
|
-
const
|
|
4388
|
-
|
|
4450
|
+
const statement = ["", dec, ";"];
|
|
4451
|
+
insertBeforeInBlock(block, node, statement);
|
|
4452
|
+
}
|
|
4453
|
+
function insertBeforeInBlock(block, node, ...statements) {
|
|
4454
|
+
const index = findChildIndex(block.expressions, node);
|
|
4389
4455
|
if (index < 0) {
|
|
4390
|
-
throw new Error("
|
|
4456
|
+
throw new Error("insertBeforeInBlock couldn't find existing statement in block");
|
|
4391
4457
|
}
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4458
|
+
insertBlockStatements(block, index, ...statements);
|
|
4459
|
+
}
|
|
4460
|
+
function insertBlockStatements(block, index, ...statements) {
|
|
4461
|
+
if (!statements.length) {
|
|
4462
|
+
return;
|
|
4463
|
+
}
|
|
4464
|
+
const { expressions } = block;
|
|
4465
|
+
const before = expressions[index];
|
|
4466
|
+
if (statements[0][0] && before?.[0]) {
|
|
4467
|
+
if (!Array.isArray(statements[0][0])) {
|
|
4468
|
+
statements[0][0] = [statements[0][0]];
|
|
4469
|
+
}
|
|
4470
|
+
if (!Array.isArray(before[0])) {
|
|
4471
|
+
before[0] = [before[0]];
|
|
4472
|
+
}
|
|
4473
|
+
statements[0][0] = [...before[0], ...statements[0][0]];
|
|
4474
|
+
} else {
|
|
4475
|
+
statements[0][0] ||= before?.[0];
|
|
4476
|
+
}
|
|
4477
|
+
before[0] = "";
|
|
4478
|
+
expressions.splice(index, 0, ...statements);
|
|
4479
|
+
updateParentPointers(block);
|
|
4480
|
+
braceBlock(block);
|
|
4396
4481
|
}
|
|
4397
4482
|
function processBlocks(statements) {
|
|
4398
4483
|
insertSemicolon(statements);
|
|
4399
4484
|
for (let ref1 = gatherRecursive(statements, ($) => $.type === "BlockStatement"), i2 = 0, len12 = ref1.length; i2 < len12; i2++) {
|
|
4400
4485
|
const block = ref1[i2];
|
|
4401
|
-
let
|
|
4402
|
-
if (block.unwrapObject && block.expressions.length === 1 && (
|
|
4486
|
+
let m1;
|
|
4487
|
+
if (block.unwrapObject && block.expressions.length === 1 && (m1 = block.expressions[0][1], typeof m1 === "object" && m1 != null && "type" in m1 && m1.type === "ParenthesizedExpression" && "implicit" in m1 && m1.implicit === true && "expression" in m1 && typeof m1.expression === "object" && m1.expression != null && "type" in m1.expression && m1.expression.type === "ObjectExpression")) {
|
|
4403
4488
|
const object = block.expressions[0][1].expression;
|
|
4404
4489
|
if (!(() => {
|
|
4405
4490
|
let results = true;
|
|
@@ -4418,8 +4503,8 @@ function processBlocks(statements) {
|
|
|
4418
4503
|
for (let ref2 = object.properties, i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
|
|
4419
4504
|
const i = i3;
|
|
4420
4505
|
const prop = ref2[i3];
|
|
4421
|
-
let
|
|
4422
|
-
if (
|
|
4506
|
+
let m2;
|
|
4507
|
+
if (m2 = prop.name, typeof m2 === "object" && m2 != null && "type" in m2 && m2.type === "ComputedPropertyName" && "implicit" in m2 && m2.implicit === true) {
|
|
4423
4508
|
replaceNode(prop.name, prop.name.expression, prop);
|
|
4424
4509
|
}
|
|
4425
4510
|
if (prop.delim?.implicit) {
|
|
@@ -4512,8 +4597,8 @@ function needsPrecedingSemicolon(exp) {
|
|
|
4512
4597
|
function blockContainingStatement(exp) {
|
|
4513
4598
|
let child = exp;
|
|
4514
4599
|
let parent = exp.parent;
|
|
4515
|
-
let
|
|
4516
|
-
while (parent != null && (
|
|
4600
|
+
let m3;
|
|
4601
|
+
while (parent != null && (m3 = parent.type, m3 === "StatementExpression" || m3 === "PipelineExpression" || m3 === "UnwrappedExpression")) {
|
|
4517
4602
|
child = parent;
|
|
4518
4603
|
parent = parent.parent;
|
|
4519
4604
|
}
|
|
@@ -4588,6 +4673,19 @@ function getPrecedence(op) {
|
|
|
4588
4673
|
return precedenceMap.get(op.prec ?? op.token) ?? (op.relational ? precedenceRelational : precedenceCustomDefault);
|
|
4589
4674
|
}
|
|
4590
4675
|
}
|
|
4676
|
+
function isShortCircuitOp(op) {
|
|
4677
|
+
if (op && typeof op === "object" && "token" in op) {
|
|
4678
|
+
const { token } = op;
|
|
4679
|
+
return isShortCircuitOp(token);
|
|
4680
|
+
} else if (typeof op === "string") {
|
|
4681
|
+
if (op.endsWith("=") && !op.endsWith("==")) {
|
|
4682
|
+
op = op.slice(0, -1);
|
|
4683
|
+
}
|
|
4684
|
+
return op === "||" || op === "&&" || op === "??";
|
|
4685
|
+
} else {
|
|
4686
|
+
return false;
|
|
4687
|
+
}
|
|
4688
|
+
}
|
|
4591
4689
|
function processBinaryOpExpression($0) {
|
|
4592
4690
|
return processExpandedBinaryOpExpression(expandChainedComparisons($0));
|
|
4593
4691
|
}
|
|
@@ -5453,22 +5551,23 @@ function processDeclarations(statements) {
|
|
|
5453
5551
|
if (typeSuffix && typeSuffix.optional) {
|
|
5454
5552
|
if (initializer && !typeSuffix.t) {
|
|
5455
5553
|
const expression = trimFirstSpace(initializer.expression);
|
|
5456
|
-
|
|
5457
|
-
if (
|
|
5458
|
-
typeSuffix.children.push(": ", typeSuffix.t = {
|
|
5459
|
-
type: "TypeTypeof",
|
|
5460
|
-
children: ["typeof ", expression],
|
|
5461
|
-
expression
|
|
5462
|
-
});
|
|
5463
|
-
} else if (expression.type === "Literal" || expression.type === "RegularExpressionLiteral" || expression.type === "TemplateLiteral") {
|
|
5464
|
-
typeSuffix.children.push(": ", typeSuffix.t = literalType(expression));
|
|
5465
|
-
} else {
|
|
5554
|
+
typeSuffix.t = typeOfExpression(expression);
|
|
5555
|
+
if (!(typeSuffix.t != null)) {
|
|
5466
5556
|
spliceChild(binding, typeSuffix, 1, {
|
|
5467
5557
|
type: "Error",
|
|
5468
|
-
message:
|
|
5558
|
+
message: (() => {
|
|
5559
|
+
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "Literal" && "subtype" in expression && expression.subtype === "NullLiteral") {
|
|
5560
|
+
return "Optional type can't be inferred from null";
|
|
5561
|
+
} else if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "Identifier" && "name" in expression && expression.name === "undefined") {
|
|
5562
|
+
return "Optional type can't be inferred from undefined";
|
|
5563
|
+
} else {
|
|
5564
|
+
return `Optional type can only be inferred from literals or member expressions, not ${expression.type}`;
|
|
5565
|
+
}
|
|
5566
|
+
})()
|
|
5469
5567
|
});
|
|
5470
5568
|
continue;
|
|
5471
5569
|
}
|
|
5570
|
+
typeSuffix.children.push(": ", typeSuffix.t);
|
|
5472
5571
|
}
|
|
5473
5572
|
if (typeSuffix.t) {
|
|
5474
5573
|
convertOptionalType(typeSuffix);
|
|
@@ -5509,16 +5608,16 @@ function processDeclarations(statements) {
|
|
|
5509
5608
|
function prependStatementExpressionBlock(initializer, statement) {
|
|
5510
5609
|
let { expression: exp } = initializer;
|
|
5511
5610
|
let ws;
|
|
5512
|
-
if (Array.isArray(exp)) {
|
|
5611
|
+
if (Array.isArray(exp) && exp.length === 2 && isWhitespaceOrEmpty(exp[0])) {
|
|
5513
5612
|
ws = exp[0];
|
|
5514
5613
|
exp = exp[1];
|
|
5515
5614
|
}
|
|
5516
5615
|
if (!(typeof exp === "object" && exp != null && "type" in exp && exp.type === "StatementExpression" || typeof exp === "object" && exp != null && "type" in exp && exp.type === "SpreadElement" && "expression" in exp && typeof exp.expression === "object" && exp.expression != null && "type" in exp.expression && exp.expression.type === "StatementExpression")) {
|
|
5517
5616
|
return;
|
|
5518
5617
|
}
|
|
5519
|
-
const pre = [];
|
|
5520
5618
|
const statementExp = exp.statement;
|
|
5521
5619
|
const blockStatement = [ws || "", statementExp, ";"];
|
|
5620
|
+
const pre = [blockStatement];
|
|
5522
5621
|
let ref;
|
|
5523
5622
|
if (statementExp.type === "IterationExpression") {
|
|
5524
5623
|
if (statementExp.async || statementExp.generator) {
|
|
@@ -5534,8 +5633,7 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5534
5633
|
assignResults(blockStatement, (resultNode) => {
|
|
5535
5634
|
return makeNode({
|
|
5536
5635
|
type: "AssignmentExpression",
|
|
5537
|
-
children: [ref, " = ", resultNode]
|
|
5538
|
-
parent: statement2
|
|
5636
|
+
children: [ref, " = ", resultNode]
|
|
5539
5637
|
});
|
|
5540
5638
|
});
|
|
5541
5639
|
const refDec = {
|
|
@@ -5552,8 +5650,7 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5552
5650
|
assignResults(blockStatement, (resultNode) => {
|
|
5553
5651
|
return makeNode({
|
|
5554
5652
|
type: "AssignmentExpression",
|
|
5555
|
-
children: [ref, " = ", resultNode]
|
|
5556
|
-
parent: statement
|
|
5653
|
+
children: [ref, " = ", resultNode]
|
|
5557
5654
|
});
|
|
5558
5655
|
});
|
|
5559
5656
|
const refDec = {
|
|
@@ -5562,8 +5659,12 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5562
5659
|
};
|
|
5563
5660
|
pre.unshift(["", refDec, ";"]);
|
|
5564
5661
|
}
|
|
5565
|
-
|
|
5566
|
-
|
|
5662
|
+
let ref3;
|
|
5663
|
+
if (!((ref3 = blockContainingStatement(statement)) && typeof ref3 === "object" && "block" in ref3 && "index" in ref3)) {
|
|
5664
|
+
throw new Error("Couldn't find block in prependStatementExpressionBlock");
|
|
5665
|
+
}
|
|
5666
|
+
const { block, index } = ref3;
|
|
5667
|
+
insertBlockStatements(block, index, ...pre);
|
|
5567
5668
|
return ref;
|
|
5568
5669
|
}
|
|
5569
5670
|
function processDeclarationCondition(condition, rootCondition, parent) {
|
|
@@ -5662,8 +5763,8 @@ function processDeclarationConditionStatement(s) {
|
|
|
5662
5763
|
if (conditions.length) {
|
|
5663
5764
|
let children = condition.children;
|
|
5664
5765
|
if (s.negated) {
|
|
5665
|
-
let
|
|
5666
|
-
if (!(
|
|
5766
|
+
let m;
|
|
5767
|
+
if (!(m = condition.expression, typeof m === "object" && m != null && "type" in m && m.type === "UnaryExpression" && "children" in m && Array.isArray(m.children) && len2(m.children, 2) && Array.isArray(m.children[0]) && len2(m.children[0], 1) && m.children[0][0] === "!" && typeof m.children[1] === "object" && m.children[1] != null && "type" in m.children[1] && m.children[1].type === "ParenthesizedExpression")) {
|
|
5667
5768
|
throw new Error("Unsupported negated condition");
|
|
5668
5769
|
}
|
|
5669
5770
|
;
|
|
@@ -5693,11 +5794,11 @@ function processDeclarationConditionStatement(s) {
|
|
|
5693
5794
|
ancestor.expressions.splice(index + 1, 0, ...blockPrefix);
|
|
5694
5795
|
updateParentPointers(ancestor);
|
|
5695
5796
|
braceBlock(ancestor);
|
|
5696
|
-
let
|
|
5797
|
+
let ref4;
|
|
5697
5798
|
switch (s.type) {
|
|
5698
5799
|
case "IfStatement": {
|
|
5699
|
-
if (
|
|
5700
|
-
const elseBlock =
|
|
5800
|
+
if (ref4 = s.else?.block) {
|
|
5801
|
+
const elseBlock = ref4;
|
|
5701
5802
|
if (elseBlock.bare && !elseBlock.semicolon) {
|
|
5702
5803
|
elseBlock.children.push(elseBlock.semicolon = ";");
|
|
5703
5804
|
}
|
|
@@ -5749,38 +5850,19 @@ function processDeclarationConditionStatement(s) {
|
|
|
5749
5850
|
if (!blockPrefix) {
|
|
5750
5851
|
return;
|
|
5751
5852
|
}
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
expression: ref2,
|
|
5756
|
-
parent: s
|
|
5757
|
-
};
|
|
5758
|
-
s.children = s.children.map(function(c) {
|
|
5759
|
-
if (c === s.condition) {
|
|
5760
|
-
return newCondition;
|
|
5761
|
-
} else {
|
|
5762
|
-
return c;
|
|
5763
|
-
}
|
|
5764
|
-
});
|
|
5765
|
-
s.condition = newCondition;
|
|
5766
|
-
updateParentPointers(s);
|
|
5767
|
-
if (statementDeclaration) {
|
|
5768
|
-
const block = makeEmptyBlock();
|
|
5769
|
-
replaceBlockExpression(s.parent, s, block);
|
|
5770
|
-
block.expressions.push(["", s]);
|
|
5771
|
-
s.children.splice(s.children.findIndex(($5) => $5.token === "switch"), 0, blockPrefix);
|
|
5772
|
-
s.parent = block;
|
|
5773
|
-
} else {
|
|
5774
|
-
const block = blockWithPrefix([["", [{
|
|
5853
|
+
replaceNode(s.condition, parenthesizeExpression(ref2), s);
|
|
5854
|
+
if (!statementDeclaration) {
|
|
5855
|
+
const declStatement = ["", [{
|
|
5775
5856
|
type: "Declaration",
|
|
5776
5857
|
children: ["let ", ...condition.expression.children]
|
|
5777
|
-
}], ";"]
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
;
|
|
5858
|
+
}], ";"];
|
|
5859
|
+
blockPrefix.unshift(declStatement);
|
|
5860
|
+
}
|
|
5861
|
+
const block = blockWithPrefix(blockPrefix, makeEmptyBlock());
|
|
5862
|
+
updateParentPointers(block, s.parent);
|
|
5863
|
+
replaceBlockExpression(s.parent, s, block);
|
|
5864
|
+
block.expressions.push(["", s]);
|
|
5865
|
+
s.parent = block;
|
|
5784
5866
|
break;
|
|
5785
5867
|
}
|
|
5786
5868
|
}
|
|
@@ -5788,12 +5870,12 @@ function processDeclarationConditionStatement(s) {
|
|
|
5788
5870
|
function dynamizeFromClause(from) {
|
|
5789
5871
|
from = from.slice(1);
|
|
5790
5872
|
from = trimFirstSpace(from);
|
|
5791
|
-
let
|
|
5792
|
-
if (
|
|
5793
|
-
const assert2 =
|
|
5794
|
-
let
|
|
5795
|
-
|
|
5796
|
-
|
|
5873
|
+
let ref5;
|
|
5874
|
+
if (ref5 = from[from.length - 1]?.assertion) {
|
|
5875
|
+
const assert2 = ref5;
|
|
5876
|
+
let ref6;
|
|
5877
|
+
ref6 = from[from.length - 1];
|
|
5878
|
+
ref6.children = ref6.children.filter((a2) => a2 !== assert2);
|
|
5797
5879
|
from.push(", {", assert2.keyword, ":", assert2.object, "}");
|
|
5798
5880
|
}
|
|
5799
5881
|
return ["(", ...from, ")"];
|
|
@@ -5802,20 +5884,20 @@ function dynamizeImportDeclaration(decl) {
|
|
|
5802
5884
|
const { imports } = decl;
|
|
5803
5885
|
let { star, binding, specifiers } = imports;
|
|
5804
5886
|
const justDefault = binding && !specifiers && !star;
|
|
5805
|
-
let
|
|
5887
|
+
let ref7;
|
|
5806
5888
|
{
|
|
5807
5889
|
if (binding) {
|
|
5808
5890
|
if (specifiers) {
|
|
5809
|
-
|
|
5891
|
+
ref7 = makeRef();
|
|
5810
5892
|
} else {
|
|
5811
|
-
|
|
5893
|
+
ref7 = binding;
|
|
5812
5894
|
}
|
|
5813
5895
|
} else {
|
|
5814
|
-
|
|
5896
|
+
ref7 = convertNamedImportsToObject(imports, true);
|
|
5815
5897
|
}
|
|
5816
5898
|
}
|
|
5817
5899
|
;
|
|
5818
|
-
const pattern =
|
|
5900
|
+
const pattern = ref7;
|
|
5819
5901
|
const c = "const";
|
|
5820
5902
|
const expression = [
|
|
5821
5903
|
justDefault ? "(" : void 0,
|
|
@@ -6806,7 +6888,7 @@ function processForInOf($0) {
|
|
|
6806
6888
|
var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
|
|
6807
6889
|
function findDecs(statements) {
|
|
6808
6890
|
const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
|
|
6809
|
-
const declarationNames = declarations.flatMap((
|
|
6891
|
+
const declarationNames = declarations.flatMap(($1) => $1.names);
|
|
6810
6892
|
const globals = getConfig().globals || [];
|
|
6811
6893
|
return new Set(globals.concat(declarationNames));
|
|
6812
6894
|
}
|
|
@@ -6814,16 +6896,16 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6814
6896
|
function findVarDecs(statements2, decs) {
|
|
6815
6897
|
const declarationNames = gatherRecursive(statements2, (node) => {
|
|
6816
6898
|
return node.type === "Declaration" && node.children && node.children.length > 0 && node.children[0].token && node.children[0].token.startsWith("var") || node.type === "FunctionExpression";
|
|
6817
|
-
}).filter((
|
|
6899
|
+
}).filter(($2) => $2.type === "Declaration").flatMap(($3) => $3.names);
|
|
6818
6900
|
return new Set(declarationNames);
|
|
6819
6901
|
}
|
|
6820
6902
|
let declaredIdentifiers = findVarDecs(statements);
|
|
6821
6903
|
function hasDec(name) {
|
|
6822
|
-
return declaredIdentifiers.has(name) || scopes.some(($
|
|
6904
|
+
return declaredIdentifiers.has(name) || scopes.some(($4) => $4.has(name));
|
|
6823
6905
|
}
|
|
6824
6906
|
function gatherBlockOrOther(statement) {
|
|
6825
|
-
return gatherNodes(statement, (
|
|
6826
|
-
if (node.type
|
|
6907
|
+
return gatherNodes(statement, ($5) => $5.type === "BlockStatement" || $5.type === "AssignmentExpression" || $5.type === "Declaration").flatMap((node) => {
|
|
6908
|
+
if (node.type === "BlockStatement") {
|
|
6827
6909
|
return node.bare ? gatherBlockOrOther(node.expressions) : node;
|
|
6828
6910
|
} else if (node.children && node.children.length) {
|
|
6829
6911
|
return [...gatherBlockOrOther(node.children), node];
|
|
@@ -6835,16 +6917,18 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6835
6917
|
let currentScope = /* @__PURE__ */ new Set();
|
|
6836
6918
|
scopes.push(currentScope);
|
|
6837
6919
|
const fnNodes = gatherNodes(statements, isFunction);
|
|
6838
|
-
const forNodes = gatherNodes(statements, (
|
|
6920
|
+
const forNodes = gatherNodes(statements, ($6) => $6.type === "ForStatement");
|
|
6839
6921
|
let targetStatements = [];
|
|
6840
|
-
for (
|
|
6922
|
+
for (let i1 = 0, len3 = statements.length; i1 < len3; i1++) {
|
|
6923
|
+
const statement = statements[i1];
|
|
6841
6924
|
const nodes = gatherBlockOrOther(statement);
|
|
6842
6925
|
let undeclaredIdentifiers = [];
|
|
6843
|
-
for (
|
|
6844
|
-
|
|
6926
|
+
for (let i2 = 0, len12 = nodes.length; i2 < len12; i2++) {
|
|
6927
|
+
const node = nodes[i2];
|
|
6928
|
+
if (node.type === "BlockStatement") {
|
|
6845
6929
|
let block = node;
|
|
6846
|
-
let fnNode = fnNodes.find((
|
|
6847
|
-
let forNode = forNodes.find((
|
|
6930
|
+
let fnNode = fnNodes.find(($7) => $7.block === block);
|
|
6931
|
+
let forNode = forNodes.find(($8) => $8.block === block);
|
|
6848
6932
|
if (fnNode != null) {
|
|
6849
6933
|
scopes.push(new Set(fnNode.parameters.names));
|
|
6850
6934
|
createConstLetDecs(block.expressions, scopes, letOrConst);
|
|
@@ -6858,21 +6942,26 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6858
6942
|
}
|
|
6859
6943
|
continue;
|
|
6860
6944
|
}
|
|
6861
|
-
if (node.names
|
|
6862
|
-
|
|
6863
|
-
|
|
6945
|
+
if (!(node.names != null)) {
|
|
6946
|
+
continue;
|
|
6947
|
+
}
|
|
6948
|
+
const names = node.names.filter((name) => !hasDec(name));
|
|
6949
|
+
if (node.type === "AssignmentExpression") {
|
|
6864
6950
|
undeclaredIdentifiers.push(...names);
|
|
6865
6951
|
}
|
|
6866
|
-
names.
|
|
6952
|
+
for (let i3 = 0, len22 = names.length; i3 < len22; i3++) {
|
|
6953
|
+
const name = names[i3];
|
|
6954
|
+
currentScope.add(name);
|
|
6955
|
+
}
|
|
6867
6956
|
}
|
|
6868
|
-
if (undeclaredIdentifiers.length
|
|
6957
|
+
if (undeclaredIdentifiers.length) {
|
|
6869
6958
|
let indent = statement[0];
|
|
6870
|
-
let firstIdentifier = gatherNodes(statement[1], (
|
|
6871
|
-
if (undeclaredIdentifiers.length
|
|
6959
|
+
let firstIdentifier = gatherNodes(statement[1], ($9) => $9.type === "Identifier")[0];
|
|
6960
|
+
if (undeclaredIdentifiers.length === 1 && statement[1].type === "AssignmentExpression" && statement[1].names.length === 1 && statement[1].names[0] === undeclaredIdentifiers[0] && firstIdentifier && firstIdentifier.names == undeclaredIdentifiers[0] && gatherNodes(statement[1], ($10) => $10.type === "ObjectBindingPattern").length === 0) {
|
|
6872
6961
|
statement[1].children.unshift([`${letOrConst} `]);
|
|
6873
6962
|
} else {
|
|
6874
6963
|
let tail = "\n";
|
|
6875
|
-
if (gatherNodes(indent, (
|
|
6964
|
+
if (gatherNodes(indent, ($11) => $11.token && $11.token.endsWith("\n")).length) {
|
|
6876
6965
|
tail = void 0;
|
|
6877
6966
|
}
|
|
6878
6967
|
targetStatements.push([indent, {
|
|
@@ -6889,17 +6978,17 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6889
6978
|
}
|
|
6890
6979
|
function createVarDecs(block, scopes, pushVar) {
|
|
6891
6980
|
function hasDec(name) {
|
|
6892
|
-
return scopes.some(($
|
|
6981
|
+
return scopes.some(($12) => $12.has(name));
|
|
6893
6982
|
}
|
|
6894
6983
|
function findAssignments(statements2, decs2) {
|
|
6895
|
-
let assignmentStatements2 = gatherNodes(statements2, ($
|
|
6984
|
+
let assignmentStatements2 = gatherNodes(statements2, ($13) => $13.type === "AssignmentExpression");
|
|
6896
6985
|
if (assignmentStatements2.length) {
|
|
6897
6986
|
concatAssign2(
|
|
6898
6987
|
assignmentStatements2,
|
|
6899
6988
|
findAssignments(assignmentStatements2.map((s) => s.children), decs2)
|
|
6900
6989
|
);
|
|
6901
6990
|
}
|
|
6902
|
-
return assignmentStatements2.filter(($
|
|
6991
|
+
return assignmentStatements2.filter(($14) => !($14.parent?.type === "CoffeeClassPublic"));
|
|
6903
6992
|
}
|
|
6904
6993
|
pushVar ??= (name) => {
|
|
6905
6994
|
varIds.push(name);
|
|
@@ -6910,7 +6999,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6910
6999
|
scopes.push(decs);
|
|
6911
7000
|
const varIds = [];
|
|
6912
7001
|
const assignmentStatements = findAssignments(statements, scopes);
|
|
6913
|
-
const undeclaredIdentifiers = assignmentStatements.flatMap(($
|
|
7002
|
+
const undeclaredIdentifiers = assignmentStatements.flatMap(($15) => $15?.names || []);
|
|
6914
7003
|
undeclaredIdentifiers.filter((x, i, a) => {
|
|
6915
7004
|
if (!hasDec(x)) return a.indexOf(x) === i;
|
|
6916
7005
|
return;
|
|
@@ -8076,23 +8165,20 @@ function processAssignments(statements) {
|
|
|
8076
8165
|
continue;
|
|
8077
8166
|
}
|
|
8078
8167
|
let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
|
|
8079
|
-
let block;
|
|
8080
8168
|
let ref13;
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
let
|
|
8084
|
-
if (
|
|
8169
|
+
let ref14;
|
|
8170
|
+
if (blockContainingStatement(exp) && !(ref13 = $1[$1.length - 1])?.[ref13.length - 1]?.special && !isShortCircuitOp((ref14 = $1[$1.length - 1])?.[ref14.length - 1])) {
|
|
8171
|
+
let ref15;
|
|
8172
|
+
if (ref15 = prependStatementExpressionBlock(
|
|
8085
8173
|
{ type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
|
|
8086
|
-
|
|
8174
|
+
exp
|
|
8087
8175
|
)) {
|
|
8088
|
-
const ref =
|
|
8089
|
-
|
|
8176
|
+
const ref = ref15;
|
|
8177
|
+
replaceNode($2, ref, exp);
|
|
8090
8178
|
$2 = ref;
|
|
8091
|
-
} else {
|
|
8092
|
-
block = void 0;
|
|
8093
8179
|
}
|
|
8094
8180
|
}
|
|
8095
|
-
if ($1.some(($
|
|
8181
|
+
if ($1.some(($7) => $7[$7.length - 1].special)) {
|
|
8096
8182
|
if ($1.length !== 1) throw new Error("Only one assignment with id= is allowed");
|
|
8097
8183
|
const [, lhs, , op] = $1[0];
|
|
8098
8184
|
const { call, omitLhs } = op;
|
|
@@ -8164,7 +8250,7 @@ function processAssignments(statements) {
|
|
|
8164
8250
|
break;
|
|
8165
8251
|
} else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern" || m3 === "NamedBindingPattern") {
|
|
8166
8252
|
processBindingPatternLHS(lhs, tail);
|
|
8167
|
-
gatherRecursiveAll(lhs, ($
|
|
8253
|
+
gatherRecursiveAll(lhs, ($8) => $8.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
|
|
8168
8254
|
}
|
|
8169
8255
|
}
|
|
8170
8256
|
i--;
|
|
@@ -8196,7 +8282,7 @@ function processAssignments(statements) {
|
|
|
8196
8282
|
}
|
|
8197
8283
|
if (refsToDeclare.size) {
|
|
8198
8284
|
if (exp.hoistDec) {
|
|
8199
|
-
exp.hoistDec.children.push([...refsToDeclare].map(($
|
|
8285
|
+
exp.hoistDec.children.push([...refsToDeclare].map(($9) => [",", $9]));
|
|
8200
8286
|
} else {
|
|
8201
8287
|
exp.hoistDec = {
|
|
8202
8288
|
type: "Declaration",
|
|
@@ -8211,11 +8297,6 @@ function processAssignments(statements) {
|
|
|
8211
8297
|
if (index < 0) throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
8212
8298
|
exp.children.splice(index + 1, 0, ...tail);
|
|
8213
8299
|
}
|
|
8214
|
-
if (block) {
|
|
8215
|
-
replaceNode(exp, block);
|
|
8216
|
-
block.expressions.push(["", exp]);
|
|
8217
|
-
exp.parent = block;
|
|
8218
|
-
}
|
|
8219
8300
|
}
|
|
8220
8301
|
}
|
|
8221
8302
|
function unchainOptionalMemberExpression(exp, ref, innerExp) {
|
|
@@ -8266,9 +8347,9 @@ function unchainOptionalMemberExpression(exp, ref, innerExp) {
|
|
|
8266
8347
|
}
|
|
8267
8348
|
j++;
|
|
8268
8349
|
}
|
|
8269
|
-
let
|
|
8270
|
-
if (
|
|
8271
|
-
const l =
|
|
8350
|
+
let ref16;
|
|
8351
|
+
if (ref16 = conditions.length) {
|
|
8352
|
+
const l = ref16;
|
|
8272
8353
|
const cs = flatJoin(conditions, " && ");
|
|
8273
8354
|
return {
|
|
8274
8355
|
...exp,
|
|
@@ -8304,8 +8385,8 @@ function attachPostfixStatementAsExpression(exp, post) {
|
|
|
8304
8385
|
}
|
|
8305
8386
|
function processTypes(node) {
|
|
8306
8387
|
const results1 = [];
|
|
8307
|
-
for (let
|
|
8308
|
-
const unary =
|
|
8388
|
+
for (let ref17 = gatherRecursiveAll(node, ($10) => $10.type === "TypeUnary"), i8 = 0, len7 = ref17.length; i8 < len7; i8++) {
|
|
8389
|
+
const unary = ref17[i8];
|
|
8309
8390
|
let suffixIndex = unary.suffix.length - 1;
|
|
8310
8391
|
const results2 = [];
|
|
8311
8392
|
while (suffixIndex >= 0) {
|
|
@@ -8384,10 +8465,10 @@ function processTypes(node) {
|
|
|
8384
8465
|
const outer = unary.suffix.splice(suffixIndex + 1, Infinity);
|
|
8385
8466
|
const space = getTrimmingSpace(unary);
|
|
8386
8467
|
inplaceInsertTrimmingSpace(unary, "");
|
|
8387
|
-
let
|
|
8388
|
-
if (unary.suffix.length)
|
|
8389
|
-
else
|
|
8390
|
-
const t =
|
|
8468
|
+
let ref18;
|
|
8469
|
+
if (unary.suffix.length) ref18 = unary;
|
|
8470
|
+
else ref18 = unary.t;
|
|
8471
|
+
const t = ref18;
|
|
8391
8472
|
const arg = makeNode({
|
|
8392
8473
|
type: "TypeArgument",
|
|
8393
8474
|
ts: true,
|
|
@@ -8432,18 +8513,18 @@ function processTypes(node) {
|
|
|
8432
8513
|
return results1;
|
|
8433
8514
|
}
|
|
8434
8515
|
function processStatementExpressions(statements) {
|
|
8435
|
-
for (let
|
|
8436
|
-
const exp =
|
|
8516
|
+
for (let ref19 = gatherRecursiveAll(statements, ($11) => $11.type === "StatementExpression"), i9 = 0, len8 = ref19.length; i9 < len8; i9++) {
|
|
8517
|
+
const exp = ref19[i9];
|
|
8437
8518
|
const { maybe, statement } = exp;
|
|
8438
8519
|
if ((maybe || statement.type === "ThrowStatement") && blockContainingStatement(exp)) {
|
|
8439
8520
|
replaceNode(exp, statement);
|
|
8440
8521
|
continue;
|
|
8441
8522
|
}
|
|
8442
|
-
let
|
|
8523
|
+
let ref20;
|
|
8443
8524
|
switch (statement.type) {
|
|
8444
8525
|
case "IfStatement": {
|
|
8445
|
-
if (
|
|
8446
|
-
const expression =
|
|
8526
|
+
if (ref20 = expressionizeIfStatement(statement)) {
|
|
8527
|
+
const expression = ref20;
|
|
8447
8528
|
replaceNode(statement, expression, exp);
|
|
8448
8529
|
} else {
|
|
8449
8530
|
replaceNode(statement, wrapIIFE([["", statement]]), exp);
|
|
@@ -8502,13 +8583,13 @@ function processNegativeIndexAccess(statements) {
|
|
|
8502
8583
|
});
|
|
8503
8584
|
}
|
|
8504
8585
|
function processFinallyClauses(statements) {
|
|
8505
|
-
for (let
|
|
8506
|
-
let f =
|
|
8507
|
-
let
|
|
8508
|
-
if (!((
|
|
8586
|
+
for (let ref21 = gatherRecursiveAll(statements, ($) => $.type === "FinallyClause" && $.parent?.type !== "TryStatement"), i10 = 0, len9 = ref21.length; i10 < len9; i10++) {
|
|
8587
|
+
let f = ref21[i10];
|
|
8588
|
+
let ref22;
|
|
8589
|
+
if (!((ref22 = blockContainingStatement(f)) && typeof ref22 === "object" && "block" in ref22 && "index" in ref22)) {
|
|
8509
8590
|
throw new Error("finally clause must be inside try statement or block");
|
|
8510
8591
|
}
|
|
8511
|
-
const { block, index } =
|
|
8592
|
+
const { block, index } = ref22;
|
|
8512
8593
|
const indent = block.expressions[index][0];
|
|
8513
8594
|
const expressions = block.expressions.slice(index + 1);
|
|
8514
8595
|
const t = makeNode({
|
|
@@ -8580,11 +8661,11 @@ function processBreaksContinues(statements) {
|
|
|
8580
8661
|
}
|
|
8581
8662
|
}
|
|
8582
8663
|
function processCoffeeClasses(statements) {
|
|
8583
|
-
for (let
|
|
8584
|
-
const ce =
|
|
8664
|
+
for (let ref23 = gatherRecursiveAll(statements, ($12) => $12.type === "ClassExpression"), i11 = 0, len10 = ref23.length; i11 < len10; i11++) {
|
|
8665
|
+
const ce = ref23[i11];
|
|
8585
8666
|
const { expressions } = ce.body;
|
|
8586
8667
|
const indent = expressions[0]?.[0] ?? "\n";
|
|
8587
|
-
const autoBinds = expressions.filter(($
|
|
8668
|
+
const autoBinds = expressions.filter(($13) => $13[1]?.autoBind);
|
|
8588
8669
|
if (autoBinds.length) {
|
|
8589
8670
|
let construct;
|
|
8590
8671
|
for (const [, c] of expressions) {
|
|
@@ -8633,17 +8714,17 @@ function processCoffeeClasses(statements) {
|
|
|
8633
8714
|
})()
|
|
8634
8715
|
);
|
|
8635
8716
|
}
|
|
8636
|
-
const public_static_function_assignments = expressions.filter(($
|
|
8717
|
+
const public_static_function_assignments = expressions.filter(($14) => $14[1]?.type === "CoffeeClassPublic" && $14[1].assignment?.expression?.type === "FunctionExpression").map(($15) => $15[1].assignment);
|
|
8637
8718
|
for (const public_static_function_assignment of public_static_function_assignments) {
|
|
8638
8719
|
const id = public_static_function_assignment.lhs[0][1];
|
|
8639
8720
|
replaceNode(public_static_function_assignment, convertFunctionToMethod(id, public_static_function_assignment.expression));
|
|
8640
8721
|
}
|
|
8641
|
-
const public_static_arrow_function_assignments = expressions.filter(($
|
|
8722
|
+
const public_static_arrow_function_assignments = expressions.filter(($16) => $16[1]?.type === "CoffeeClassPublic" && $16[1].assignment?.expression?.type === "ArrowFunction").map(($17) => $17[1].assignment);
|
|
8642
8723
|
for (const public_static_arrow_function_assignment of public_static_arrow_function_assignments) {
|
|
8643
8724
|
const id = public_static_arrow_function_assignment.lhs[0][1];
|
|
8644
8725
|
replaceNode(public_static_arrow_function_assignment, convertArrowFunctionToMethod(id, public_static_arrow_function_assignment.expression));
|
|
8645
8726
|
}
|
|
8646
|
-
const privates = expressions.filter(($
|
|
8727
|
+
const privates = expressions.filter(($18) => $18[1]?.type === "CoffeeClassPrivate");
|
|
8647
8728
|
if (!privates.length) {
|
|
8648
8729
|
continue;
|
|
8649
8730
|
}
|
|
@@ -8708,7 +8789,7 @@ function processProgram(root) {
|
|
|
8708
8789
|
root.topLevelYield ? "*" : void 0
|
|
8709
8790
|
);
|
|
8710
8791
|
statements = [["", rootIIFE]];
|
|
8711
|
-
root.children = root.children.map(($
|
|
8792
|
+
root.children = root.children.map(($19) => $19 === root.expressions ? statements : $19);
|
|
8712
8793
|
root.expressions = statements;
|
|
8713
8794
|
}
|
|
8714
8795
|
hoistRefDecs(statements);
|
|
@@ -8739,10 +8820,10 @@ async function processProgramAsync(root) {
|
|
|
8739
8820
|
await processComptime(statements);
|
|
8740
8821
|
}
|
|
8741
8822
|
function processRepl(root, rootIIFE) {
|
|
8742
|
-
const topBlock = gatherRecursive(rootIIFE, ($
|
|
8823
|
+
const topBlock = gatherRecursive(rootIIFE, ($20) => $20.type === "BlockStatement")[0];
|
|
8743
8824
|
let i = 0;
|
|
8744
|
-
for (let
|
|
8745
|
-
const decl =
|
|
8825
|
+
for (let ref24 = gatherRecursiveWithinFunction(topBlock, ($21) => $21.type === "Declaration"), i14 = 0, len12 = ref24.length; i14 < len12; i14++) {
|
|
8826
|
+
const decl = ref24[i14];
|
|
8746
8827
|
if (!decl.names?.length) {
|
|
8747
8828
|
continue;
|
|
8748
8829
|
}
|
|
@@ -8755,8 +8836,8 @@ function processRepl(root, rootIIFE) {
|
|
|
8755
8836
|
root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
|
|
8756
8837
|
}
|
|
8757
8838
|
}
|
|
8758
|
-
for (let
|
|
8759
|
-
const func =
|
|
8839
|
+
for (let ref25 = gatherRecursive(topBlock, ($22) => $22.type === "FunctionExpression"), i15 = 0, len13 = ref25.length; i15 < len13; i15++) {
|
|
8840
|
+
const func = ref25[i15];
|
|
8760
8841
|
if (func.name && func.parent?.type === "BlockStatement") {
|
|
8761
8842
|
if (func.parent === topBlock) {
|
|
8762
8843
|
replaceNode(func, void 0);
|
|
@@ -8768,8 +8849,8 @@ function processRepl(root, rootIIFE) {
|
|
|
8768
8849
|
}
|
|
8769
8850
|
}
|
|
8770
8851
|
}
|
|
8771
|
-
for (let
|
|
8772
|
-
const classExp =
|
|
8852
|
+
for (let ref26 = gatherRecursiveWithinFunction(topBlock, ($23) => $23.type === "ClassExpression"), i16 = 0, len14 = ref26.length; i16 < len14; i16++) {
|
|
8853
|
+
const classExp = ref26[i16];
|
|
8773
8854
|
let m8;
|
|
8774
8855
|
if (classExp.name && classExp.parent === topBlock || (m8 = classExp.parent, typeof m8 === "object" && m8 != null && "type" in m8 && m8.type === "ReturnStatement" && "parent" in m8 && m8.parent === topBlock)) {
|
|
8775
8856
|
classExp.children.unshift(classExp.name, "=");
|
|
@@ -8780,8 +8861,8 @@ function processRepl(root, rootIIFE) {
|
|
|
8780
8861
|
function processPlaceholders(statements) {
|
|
8781
8862
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
8782
8863
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
8783
|
-
for (let
|
|
8784
|
-
const exp =
|
|
8864
|
+
for (let ref27 = gatherRecursiveAll(statements, ($24) => $24.type === "Placeholder"), i17 = 0, len15 = ref27.length; i17 < len15; i17++) {
|
|
8865
|
+
const exp = ref27[i17];
|
|
8785
8866
|
let ancestor;
|
|
8786
8867
|
if (exp.subtype === ".") {
|
|
8787
8868
|
({ ancestor } = findAncestor(
|
|
@@ -8893,8 +8974,8 @@ function processPlaceholders(statements) {
|
|
|
8893
8974
|
for (let i18 = 0, len16 = placeholders.length; i18 < len16; i18++) {
|
|
8894
8975
|
const placeholder = placeholders[i18];
|
|
8895
8976
|
typeSuffix ??= placeholder.typeSuffix;
|
|
8896
|
-
let
|
|
8897
|
-
(
|
|
8977
|
+
let ref28;
|
|
8978
|
+
(ref28 = placeholder.children)[ref28.length - 1] = ref;
|
|
8898
8979
|
}
|
|
8899
8980
|
const { parent } = ancestor;
|
|
8900
8981
|
const body = maybeUnwrap(ancestor);
|
|
@@ -8915,16 +8996,16 @@ function processPlaceholders(statements) {
|
|
|
8915
8996
|
}
|
|
8916
8997
|
case "PipelineExpression": {
|
|
8917
8998
|
const i = findChildIndex(parent, ancestor);
|
|
8918
|
-
let
|
|
8999
|
+
let ref29;
|
|
8919
9000
|
if (i === 1) {
|
|
8920
|
-
|
|
9001
|
+
ref29 = ancestor === parent.children[i];
|
|
8921
9002
|
} else if (i === 2) {
|
|
8922
|
-
|
|
9003
|
+
ref29 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
|
|
8923
9004
|
} else {
|
|
8924
|
-
|
|
9005
|
+
ref29 = void 0;
|
|
8925
9006
|
}
|
|
8926
9007
|
;
|
|
8927
|
-
outer =
|
|
9008
|
+
outer = ref29;
|
|
8928
9009
|
break;
|
|
8929
9010
|
}
|
|
8930
9011
|
case "AssignmentExpression":
|
|
@@ -8942,9 +9023,9 @@ function processPlaceholders(statements) {
|
|
|
8942
9023
|
if (typeof parent === "object" && parent != null && "type" in parent && parent.type === "BlockStatement" && "parent" in parent && typeof parent.parent === "object" && parent.parent != null && "type" in parent.parent && parent.parent.type === "ArrowFunction" && "ampersandBlock" in parent.parent && parent.parent.ampersandBlock === true && "body" in parent.parent && parent.parent.body === body) {
|
|
8943
9024
|
parent.parent.body = fnExp;
|
|
8944
9025
|
}
|
|
8945
|
-
let
|
|
8946
|
-
if (
|
|
8947
|
-
const ws =
|
|
9026
|
+
let ref30;
|
|
9027
|
+
if (ref30 = getTrimmingSpace(body)) {
|
|
9028
|
+
const ws = ref30;
|
|
8948
9029
|
inplaceInsertTrimmingSpace(body, "");
|
|
8949
9030
|
inplacePrepend(ws, fnExp);
|
|
8950
9031
|
}
|
|
@@ -8988,8 +9069,8 @@ function reorderBindingRestProperty(props) {
|
|
|
8988
9069
|
}
|
|
8989
9070
|
];
|
|
8990
9071
|
}
|
|
8991
|
-
let
|
|
8992
|
-
if (Array.isArray(rest.delim) && (
|
|
9072
|
+
let ref31;
|
|
9073
|
+
if (Array.isArray(rest.delim) && (ref31 = rest.delim)[ref31.length - 1]?.token === ",") {
|
|
8993
9074
|
rest.delim = rest.delim.slice(0, -1);
|
|
8994
9075
|
rest.children = [...rest.children.slice(0, -1), rest.delim];
|
|
8995
9076
|
}
|
|
@@ -9065,7 +9146,7 @@ function typeOfJSXFragment(node, config2) {
|
|
|
9065
9146
|
if (type.length === 1) {
|
|
9066
9147
|
return type[0];
|
|
9067
9148
|
} else {
|
|
9068
|
-
type = type.flatMap(($
|
|
9149
|
+
type = type.flatMap(($25) => [$25, ", "]);
|
|
9069
9150
|
type.pop();
|
|
9070
9151
|
return ["[", type, "]"];
|
|
9071
9152
|
}
|
|
@@ -9130,6 +9211,7 @@ var grammar = {
|
|
|
9130
9211
|
Tuple,
|
|
9131
9212
|
NWTypePostfix,
|
|
9132
9213
|
UpdateExpression,
|
|
9214
|
+
UpdateExpressionPattern,
|
|
9133
9215
|
UpdateExpressionSymbol,
|
|
9134
9216
|
AssignmentExpression,
|
|
9135
9217
|
NonPipelineAssignmentExpression,
|
|
@@ -9265,7 +9347,7 @@ var grammar = {
|
|
|
9265
9347
|
OperatorPrecedence,
|
|
9266
9348
|
OperatorAssociativity,
|
|
9267
9349
|
ThinArrowFunction,
|
|
9268
|
-
|
|
9350
|
+
ThinArrow,
|
|
9269
9351
|
ExplicitBlock,
|
|
9270
9352
|
EmptyBracedContent,
|
|
9271
9353
|
ImplicitNestedBlock,
|
|
@@ -10249,7 +10331,7 @@ var $R71 = (0, import_lib2.$R)(new RegExp("#(?!##(?!#))([^\\r\\n]*)", "suy"));
|
|
|
10249
10331
|
var $R72 = (0, import_lib2.$R)(new RegExp("[^]*?###", "suy"));
|
|
10250
10332
|
var $R73 = (0, import_lib2.$R)(new RegExp("###(?!#)", "suy"));
|
|
10251
10333
|
var $R74 = (0, import_lib2.$R)(new RegExp("\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\/", "suy"));
|
|
10252
|
-
var $R75 = (0, import_lib2.$R)(new RegExp("(?=[ \\t
|
|
10334
|
+
var $R75 = (0, import_lib2.$R)(new RegExp("(?=[ \\t\\/\\\\#])", "suy"));
|
|
10253
10335
|
var $R76 = (0, import_lib2.$R)(new RegExp("(?=\\s|\\/|#)", "suy"));
|
|
10254
10336
|
var $R77 = (0, import_lib2.$R)(new RegExp("(?!\\p{ID_Continue})", "suy"));
|
|
10255
10337
|
var $R78 = (0, import_lib2.$R)(new RegExp("[=:]", "suy"));
|
|
@@ -10936,6 +11018,12 @@ var UpdateExpression$$ = [UpdateExpression$0, UpdateExpression$1];
|
|
|
10936
11018
|
function UpdateExpression(ctx, state2) {
|
|
10937
11019
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "UpdateExpression", UpdateExpression$$);
|
|
10938
11020
|
}
|
|
11021
|
+
var UpdateExpressionPattern$0 = NamedBindingPattern;
|
|
11022
|
+
var UpdateExpressionPattern$1 = UpdateExpression;
|
|
11023
|
+
var UpdateExpressionPattern$$ = [UpdateExpressionPattern$0, UpdateExpressionPattern$1];
|
|
11024
|
+
function UpdateExpressionPattern(ctx, state2) {
|
|
11025
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "UpdateExpressionPattern", UpdateExpressionPattern$$);
|
|
11026
|
+
}
|
|
10939
11027
|
var UpdateExpressionSymbol$0 = (0, import_lib2.$TV)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L9, 'UpdateExpressionSymbol "++"'), (0, import_lib2.$EXPECT)($L10, 'UpdateExpressionSymbol "--"')), function($skip, $loc, $0, $1) {
|
|
10940
11028
|
return { $loc, token: $1 };
|
|
10941
11029
|
});
|
|
@@ -10999,7 +11087,7 @@ var NonPipelineAssignmentExpressionTail$$ = [NonPipelineAssignmentExpressionTail
|
|
|
10999
11087
|
function NonPipelineAssignmentExpressionTail(ctx, state2) {
|
|
11000
11088
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "NonPipelineAssignmentExpressionTail", NonPipelineAssignmentExpressionTail$$);
|
|
11001
11089
|
}
|
|
11002
|
-
var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented,
|
|
11090
|
+
var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, UpdateExpressionPattern, WAssignmentOp)), MaybeNestedExpression), function($skip, $loc, $0, $1, $2) {
|
|
11003
11091
|
$1 = $1.map((x) => [x[0], x[1], ...x[2]]);
|
|
11004
11092
|
$0 = [$1, $2];
|
|
11005
11093
|
return {
|
|
@@ -11016,7 +11104,7 @@ var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib
|
|
|
11016
11104
|
function ActualAssignment(ctx, state2) {
|
|
11017
11105
|
return (0, import_lib2.$EVENT)(ctx, state2, "ActualAssignment", ActualAssignment$0);
|
|
11018
11106
|
}
|
|
11019
|
-
var NonPipelineActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented,
|
|
11107
|
+
var NonPipelineActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, UpdateExpressionPattern, WAssignmentOp)), MaybeNestedNonPipelineExpression), function($skip, $loc, $0, $1, $2) {
|
|
11020
11108
|
$1 = $1.map((x) => [x[0], x[1], ...x[2]]);
|
|
11021
11109
|
$0 = [$1, $2];
|
|
11022
11110
|
return {
|
|
@@ -11195,8 +11283,14 @@ var PipelineExpressionBody$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Pipeline
|
|
|
11195
11283
|
...rest.map(([nested, line]) => [nested, ...line]).flat()
|
|
11196
11284
|
];
|
|
11197
11285
|
});
|
|
11198
|
-
var PipelineExpressionBody$1 = (0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, Pipe, __, PipelineTailItem))
|
|
11199
|
-
|
|
11286
|
+
var PipelineExpressionBody$1 = (0, import_lib2.$T)((0, import_lib2.$S)(NewlineBinaryOpAllowed, (0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, Pipe, __, PipelineTailItem))), function(value) {
|
|
11287
|
+
return value[1];
|
|
11288
|
+
});
|
|
11289
|
+
var PipelineExpressionBody$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NewlineBinaryOpAllowed), PipelineExpressionBodySameLine), function($skip, $loc, $0, $1, $2) {
|
|
11290
|
+
if (!$2.length) return $skip;
|
|
11291
|
+
return $2;
|
|
11292
|
+
});
|
|
11293
|
+
var PipelineExpressionBody$$ = [PipelineExpressionBody$0, PipelineExpressionBody$1, PipelineExpressionBody$2];
|
|
11200
11294
|
function PipelineExpressionBody(ctx, state2) {
|
|
11201
11295
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PipelineExpressionBody", PipelineExpressionBody$$);
|
|
11202
11296
|
}
|
|
@@ -11227,8 +11321,9 @@ var PipelineTailItem$3 = (0, import_lib2.$TS)((0, import_lib2.$S)(NWTypePostfix,
|
|
|
11227
11321
|
body: [" ", $1, ...$2]
|
|
11228
11322
|
});
|
|
11229
11323
|
});
|
|
11230
|
-
var PipelineTailItem$4 = (0, import_lib2.$
|
|
11231
|
-
return
|
|
11324
|
+
var PipelineTailItem$4 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidNewlineBinaryOp, (0, import_lib2.$E)(PipelineHeadItem), RestoreNewlineBinaryOp), function($skip, $loc, $0, $1, $2, $3) {
|
|
11325
|
+
if (!$2) return $skip;
|
|
11326
|
+
return $2;
|
|
11232
11327
|
});
|
|
11233
11328
|
var PipelineTailItem$$ = [PipelineTailItem$0, PipelineTailItem$1, PipelineTailItem$2, PipelineTailItem$3, PipelineTailItem$4];
|
|
11234
11329
|
function PipelineTailItem(ctx, state2) {
|
|
@@ -11825,9 +11920,8 @@ var LeftHandSideExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impo
|
|
|
11825
11920
|
expression
|
|
11826
11921
|
};
|
|
11827
11922
|
});
|
|
11828
|
-
var LeftHandSideExpression$1 =
|
|
11829
|
-
var LeftHandSideExpression
|
|
11830
|
-
var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1, LeftHandSideExpression$2];
|
|
11923
|
+
var LeftHandSideExpression$1 = CallExpression;
|
|
11924
|
+
var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1];
|
|
11831
11925
|
function LeftHandSideExpression(ctx, state2) {
|
|
11832
11926
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "LeftHandSideExpression", LeftHandSideExpression$$);
|
|
11833
11927
|
}
|
|
@@ -13282,14 +13376,21 @@ var OperatorAssociativity$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impor
|
|
|
13282
13376
|
function OperatorAssociativity(ctx, state2) {
|
|
13283
13377
|
return (0, import_lib2.$EVENT)(ctx, state2, "OperatorAssociativity", OperatorAssociativity$0);
|
|
13284
13378
|
}
|
|
13285
|
-
var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(Async, _)), ArrowParameters, (0, import_lib2.$E)(ReturnTypeSuffix), (0, import_lib2.$E)(_),
|
|
13379
|
+
var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(Async, _)), ArrowParameters, (0, import_lib2.$E)(ReturnTypeSuffix), (0, import_lib2.$E)(_), ThinArrow, (0, import_lib2.$C)(BracedObjectSingleLineStatements, NoCommaBracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
13286
13380
|
var async = $1;
|
|
13287
13381
|
var parameters = $2;
|
|
13288
13382
|
var returnType = $3;
|
|
13383
|
+
var ws = $4;
|
|
13289
13384
|
var arrow = $5;
|
|
13290
13385
|
var block = $6;
|
|
13291
13386
|
if (!async) async = [];
|
|
13292
13387
|
const generator = [];
|
|
13388
|
+
if ((!parameters.implicit || returnType || ws) && !block.bare) {
|
|
13389
|
+
const [first, ...rest] = block.children;
|
|
13390
|
+
if (first === " {" || first?.[0]?.token === " ") {
|
|
13391
|
+
block = { ...block, children: [first.slice(1), ...rest] };
|
|
13392
|
+
}
|
|
13393
|
+
}
|
|
13293
13394
|
return {
|
|
13294
13395
|
type: "FunctionExpression",
|
|
13295
13396
|
id: void 0,
|
|
@@ -13314,6 +13415,7 @@ var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
13314
13415
|
generator,
|
|
13315
13416
|
parameters,
|
|
13316
13417
|
returnType,
|
|
13418
|
+
ws,
|
|
13317
13419
|
block
|
|
13318
13420
|
]
|
|
13319
13421
|
};
|
|
@@ -13321,11 +13423,11 @@ var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
13321
13423
|
function ThinArrowFunction(ctx, state2) {
|
|
13322
13424
|
return (0, import_lib2.$EVENT)(ctx, state2, "ThinArrowFunction", ThinArrowFunction$0);
|
|
13323
13425
|
}
|
|
13324
|
-
var
|
|
13426
|
+
var ThinArrow$0 = (0, import_lib2.$TV)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L35, 'ThinArrow "->"'), (0, import_lib2.$EXPECT)($L36, 'ThinArrow "\u2192"')), function($skip, $loc, $0, $1) {
|
|
13325
13427
|
return { $loc, token: "->" };
|
|
13326
13428
|
});
|
|
13327
|
-
function
|
|
13328
|
-
return (0, import_lib2.$EVENT)(ctx, state2, "
|
|
13429
|
+
function ThinArrow(ctx, state2) {
|
|
13430
|
+
return (0, import_lib2.$EVENT)(ctx, state2, "ThinArrow", ThinArrow$0);
|
|
13329
13431
|
}
|
|
13330
13432
|
var ExplicitBlock$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), OpenBrace, AllowAll, (0, import_lib2.$E)((0, import_lib2.$C)(NestedBlockStatements, SingleLineStatements, EmptyBracedContent)), RestoreAll, __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
13331
13433
|
var ws1 = $1;
|
|
@@ -17983,8 +18085,10 @@ function CoffeeHereCommentStart(ctx, state2) {
|
|
|
17983
18085
|
var InlineComment$0 = (0, import_lib2.$TR)((0, import_lib2.$EXPECT)($R74, "InlineComment /\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\//"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
17984
18086
|
return { $loc, token: $0 };
|
|
17985
18087
|
});
|
|
18088
|
+
var InlineComment$1 = CoffeeMultiLineComment;
|
|
18089
|
+
var InlineComment$$ = [InlineComment$0, InlineComment$1];
|
|
17986
18090
|
function InlineComment(ctx, state2) {
|
|
17987
|
-
return (0, import_lib2.$
|
|
18091
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "InlineComment", InlineComment$$);
|
|
17988
18092
|
}
|
|
17989
18093
|
var RestOfLine$0 = (0, import_lib2.$S)((0, import_lib2.$Q)((0, import_lib2.$C)(NonNewlineWhitespace, Comment)), EOL);
|
|
17990
18094
|
function RestOfLine(ctx, state2) {
|
|
@@ -17994,7 +18098,7 @@ var TrailingComment$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_l
|
|
|
17994
18098
|
function TrailingComment(ctx, state2) {
|
|
17995
18099
|
return (0, import_lib2.$EVENT)(ctx, state2, "TrailingComment", TrailingComment$0);
|
|
17996
18100
|
}
|
|
17997
|
-
var _$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R75, "_ /(?=[ \\t
|
|
18101
|
+
var _$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R75, "_ /(?=[ \\t\\/\\\\#])/"), (0, import_lib2.$P)((0, import_lib2.$C)(NonNewlineWhitespace, InlineComment))), function(value) {
|
|
17998
18102
|
return value[1];
|
|
17999
18103
|
});
|
|
18000
18104
|
function _(ctx, state2) {
|
|
@@ -22163,8 +22267,9 @@ ${counts}`;
|
|
|
22163
22267
|
const code = generate_civet_default(ast2, options);
|
|
22164
22268
|
checkErrors();
|
|
22165
22269
|
if (options.inlineMap) {
|
|
22270
|
+
const outputFilename = options.outputFilename ?? (options.js ? filename2 + ".jsx" : filename2 + ".tsx");
|
|
22166
22271
|
return `${code}
|
|
22167
|
-
${options.sourceMap.comment(filename2,
|
|
22272
|
+
${options.sourceMap.comment(filename2, outputFilename)}`;
|
|
22168
22273
|
} else {
|
|
22169
22274
|
return {
|
|
22170
22275
|
code,
|