@danielx/civet 0.11.1 → 0.11.3
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 +29 -0
- package/README.md +3 -0
- package/dist/browser.js +402 -234
- package/dist/civet +97 -43
- package/dist/config.js +3 -0
- package/dist/config.mjs +3 -0
- package/dist/main.js +511 -265
- package/dist/main.mjs +511 -265
- package/dist/types.d.ts +4 -0
- package/dist/unplugin/unplugin.js +193 -13
- package/dist/unplugin/unplugin.mjs +200 -13
- package/package.json +6 -2
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,
|
|
@@ -2872,20 +2932,7 @@ function wrapTypeInApplication(t, id, raw) {
|
|
|
2872
2932
|
}
|
|
2873
2933
|
function implicitFunctionBlock(f) {
|
|
2874
2934
|
if (f.abstract || f.block || f.signature?.optional) return;
|
|
2875
|
-
|
|
2876
|
-
let ancestor = parent;
|
|
2877
|
-
let child = f;
|
|
2878
|
-
if (ancestor?.type === "ExportDeclaration") {
|
|
2879
|
-
child = ancestor;
|
|
2880
|
-
ancestor = ancestor.parent;
|
|
2881
|
-
}
|
|
2882
|
-
const expressions = ancestor?.expressions ?? ancestor?.elements;
|
|
2883
|
-
const currentIndex = expressions?.findIndex(([, def]) => def === child);
|
|
2884
|
-
let following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
|
|
2885
|
-
if (following?.type === "ExportDeclaration") {
|
|
2886
|
-
following = following.declaration;
|
|
2887
|
-
}
|
|
2888
|
-
if (f.type === following?.type && name != null && name === following.name) {
|
|
2935
|
+
if (followingOverloads(f).length) {
|
|
2889
2936
|
f.ts = true;
|
|
2890
2937
|
} else {
|
|
2891
2938
|
const block = makeEmptyBlock();
|
|
@@ -2895,6 +2942,66 @@ function implicitFunctionBlock(f) {
|
|
|
2895
2942
|
f.ts = false;
|
|
2896
2943
|
}
|
|
2897
2944
|
}
|
|
2945
|
+
function overloadsInDirection(f, direction) {
|
|
2946
|
+
if (!(f.name != null)) {
|
|
2947
|
+
return [];
|
|
2948
|
+
}
|
|
2949
|
+
let ancestor = f.parent;
|
|
2950
|
+
let child = f;
|
|
2951
|
+
if (ancestor?.type === "ExportDeclaration") {
|
|
2952
|
+
child = ancestor;
|
|
2953
|
+
ancestor = ancestor.parent;
|
|
2954
|
+
}
|
|
2955
|
+
if (!(ancestor?.type === "BlockStatement")) {
|
|
2956
|
+
return [];
|
|
2957
|
+
}
|
|
2958
|
+
const { expressions } = ancestor;
|
|
2959
|
+
let index = findChildIndex(expressions, child);
|
|
2960
|
+
if (!(index >= 0)) {
|
|
2961
|
+
return [];
|
|
2962
|
+
}
|
|
2963
|
+
if (direction < 0) {
|
|
2964
|
+
const results1 = [];
|
|
2965
|
+
while (--index >= 0) {
|
|
2966
|
+
let candidate = expressions[index][1];
|
|
2967
|
+
if (!candidate) {
|
|
2968
|
+
break;
|
|
2969
|
+
}
|
|
2970
|
+
if (candidate.type === "ExportDeclaration") {
|
|
2971
|
+
candidate = candidate.declaration;
|
|
2972
|
+
}
|
|
2973
|
+
if (!(candidate && candidate.type === f.type && candidate.name === f.name)) {
|
|
2974
|
+
break;
|
|
2975
|
+
}
|
|
2976
|
+
results1.push(candidate);
|
|
2977
|
+
}
|
|
2978
|
+
;
|
|
2979
|
+
return results1;
|
|
2980
|
+
} else {
|
|
2981
|
+
const results2 = [];
|
|
2982
|
+
while (++index < expressions.length) {
|
|
2983
|
+
let candidate = expressions[index][1];
|
|
2984
|
+
if (!candidate) {
|
|
2985
|
+
break;
|
|
2986
|
+
}
|
|
2987
|
+
if (candidate.type === "ExportDeclaration") {
|
|
2988
|
+
candidate = candidate.declaration;
|
|
2989
|
+
}
|
|
2990
|
+
if (!(candidate && candidate.type === f.type && candidate.name === f.name)) {
|
|
2991
|
+
break;
|
|
2992
|
+
}
|
|
2993
|
+
results2.push(candidate);
|
|
2994
|
+
}
|
|
2995
|
+
;
|
|
2996
|
+
return results2;
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
function precedingOverloads(f) {
|
|
3000
|
+
return overloadsInDirection(f, -1);
|
|
3001
|
+
}
|
|
3002
|
+
function followingOverloads(f) {
|
|
3003
|
+
return overloadsInDirection(f, 1);
|
|
3004
|
+
}
|
|
2898
3005
|
function processReturn(f, implicitReturns) {
|
|
2899
3006
|
let { returnType } = f.signature;
|
|
2900
3007
|
if (returnType && returnType.optional) {
|
|
@@ -3112,19 +3219,23 @@ function patternBindings(pattern) {
|
|
|
3112
3219
|
function assignResults(node, collect) {
|
|
3113
3220
|
if (!node) return;
|
|
3114
3221
|
switch (node.type) {
|
|
3115
|
-
case "BlockStatement":
|
|
3222
|
+
case "BlockStatement": {
|
|
3116
3223
|
if (node.expressions.length) {
|
|
3117
3224
|
let ref5;
|
|
3118
3225
|
assignResults((ref5 = node.expressions)[ref5.length - 1], collect);
|
|
3119
3226
|
} else {
|
|
3120
3227
|
node.expressions.push(["", collect("void 0"), ";"]);
|
|
3228
|
+
updateParentPointers(node);
|
|
3121
3229
|
}
|
|
3122
3230
|
return;
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3231
|
+
}
|
|
3232
|
+
case "CaseBlock": {
|
|
3233
|
+
for (let ref6 = node.clauses, i4 = 0, len3 = ref6.length; i4 < len3; i4++) {
|
|
3234
|
+
const clause = ref6[i4];
|
|
3235
|
+
assignResults(clause, collect);
|
|
3236
|
+
}
|
|
3127
3237
|
return;
|
|
3238
|
+
}
|
|
3128
3239
|
case "WhenClause":
|
|
3129
3240
|
case "DefaultClause":
|
|
3130
3241
|
case "PatternClause": {
|
|
@@ -3150,7 +3261,8 @@ function assignResults(node, collect) {
|
|
|
3150
3261
|
if (exp.type === "LabelledStatement") {
|
|
3151
3262
|
exp = exp.statement;
|
|
3152
3263
|
}
|
|
3153
|
-
let
|
|
3264
|
+
let ref7;
|
|
3265
|
+
let ref8;
|
|
3154
3266
|
let m1;
|
|
3155
3267
|
switch (exp.type) {
|
|
3156
3268
|
case "BreakStatement":
|
|
@@ -3162,18 +3274,19 @@ function assignResults(node, collect) {
|
|
|
3162
3274
|
return;
|
|
3163
3275
|
}
|
|
3164
3276
|
case "Declaration": {
|
|
3165
|
-
let
|
|
3277
|
+
let ref9;
|
|
3166
3278
|
if (exp.bindings?.length) {
|
|
3167
|
-
|
|
3279
|
+
ref9 = patternAsValue((ref7 = exp.bindings)[ref7.length - 1].pattern);
|
|
3168
3280
|
} else {
|
|
3169
|
-
|
|
3281
|
+
ref9 = "void 0";
|
|
3170
3282
|
}
|
|
3171
3283
|
;
|
|
3172
|
-
const value =
|
|
3284
|
+
const value = ref9;
|
|
3173
3285
|
exp.children.push([
|
|
3174
3286
|
"",
|
|
3175
3287
|
[";", collect(value)]
|
|
3176
3288
|
]);
|
|
3289
|
+
updateParentPointers(exp);
|
|
3177
3290
|
return;
|
|
3178
3291
|
}
|
|
3179
3292
|
case "FunctionExpression": {
|
|
@@ -3182,6 +3295,7 @@ function assignResults(node, collect) {
|
|
|
3182
3295
|
"",
|
|
3183
3296
|
[";", collect(exp.id)]
|
|
3184
3297
|
]);
|
|
3298
|
+
updateParentPointers(exp);
|
|
3185
3299
|
return;
|
|
3186
3300
|
}
|
|
3187
3301
|
break;
|
|
@@ -3197,7 +3311,7 @@ function assignResults(node, collect) {
|
|
|
3197
3311
|
if (exp.expressions.some(isExit)) {
|
|
3198
3312
|
return;
|
|
3199
3313
|
}
|
|
3200
|
-
assignResults(exp.expressions[
|
|
3314
|
+
assignResults((ref8 = exp.expressions)[ref8.length - 1], collect);
|
|
3201
3315
|
return;
|
|
3202
3316
|
}
|
|
3203
3317
|
case "IfStatement": {
|
|
@@ -3207,6 +3321,7 @@ function assignResults(node, collect) {
|
|
|
3207
3321
|
} else {
|
|
3208
3322
|
braceBlock(exp.then);
|
|
3209
3323
|
exp.children.push([" else {", collect("void 0"), "}"]);
|
|
3324
|
+
updateParentPointers(exp);
|
|
3210
3325
|
}
|
|
3211
3326
|
return;
|
|
3212
3327
|
}
|
|
@@ -3215,15 +3330,15 @@ function assignResults(node, collect) {
|
|
|
3215
3330
|
return;
|
|
3216
3331
|
}
|
|
3217
3332
|
case "SwitchStatement": {
|
|
3218
|
-
for (let
|
|
3219
|
-
const clause =
|
|
3333
|
+
for (let ref10 = exp.caseBlock.clauses, i5 = 0, len4 = ref10.length; i5 < len4; i5++) {
|
|
3334
|
+
const clause = ref10[i5];
|
|
3220
3335
|
assignResults(clause, collect);
|
|
3221
3336
|
}
|
|
3222
3337
|
return;
|
|
3223
3338
|
}
|
|
3224
3339
|
case "TryStatement": {
|
|
3225
|
-
for (let
|
|
3226
|
-
const block =
|
|
3340
|
+
for (let ref11 = exp.blocks, i6 = 0, len5 = ref11.length; i6 < len5; i6++) {
|
|
3341
|
+
const block = ref11[i6];
|
|
3227
3342
|
assignResults(block, collect);
|
|
3228
3343
|
}
|
|
3229
3344
|
return;
|
|
@@ -3235,6 +3350,7 @@ function assignResults(node, collect) {
|
|
|
3235
3350
|
const semi2 = exp.children.lastIndexOf(";");
|
|
3236
3351
|
if (0 <= semi2 && semi2 < exp.children.length - 1) {
|
|
3237
3352
|
exp.children.splice(semi2 + 1, 1 / 0, ...[collect(exp.children.slice(semi2 + 1))]);
|
|
3353
|
+
updateParentPointers(exp);
|
|
3238
3354
|
return;
|
|
3239
3355
|
}
|
|
3240
3356
|
;
|
|
@@ -3244,7 +3360,11 @@ function assignResults(node, collect) {
|
|
|
3244
3360
|
if (node[node.length - 1]?.type === "SemicolonDelimiter") {
|
|
3245
3361
|
return;
|
|
3246
3362
|
}
|
|
3363
|
+
const parent = node[1].parent;
|
|
3247
3364
|
node[1] = collect(node[1]);
|
|
3365
|
+
if (parent != null) {
|
|
3366
|
+
updateParentPointers(parent);
|
|
3367
|
+
}
|
|
3248
3368
|
}
|
|
3249
3369
|
function insertReturn(node) {
|
|
3250
3370
|
if (!node) return;
|
|
@@ -3275,9 +3395,9 @@ function insertReturn(node) {
|
|
|
3275
3395
|
insertReturn(node.block);
|
|
3276
3396
|
if (!isExit(node.block)) {
|
|
3277
3397
|
const comment = hasTrailingComment(node.block.expressions);
|
|
3278
|
-
let
|
|
3398
|
+
let ref12;
|
|
3279
3399
|
node.block.expressions.push([
|
|
3280
|
-
comment ? (
|
|
3400
|
+
comment ? (ref12 = node.block.expressions)[ref12.length - 1][0] || "\n" : "",
|
|
3281
3401
|
wrapWithReturn(void 0, node, !comment)
|
|
3282
3402
|
]);
|
|
3283
3403
|
}
|
|
@@ -3303,7 +3423,7 @@ function insertReturn(node) {
|
|
|
3303
3423
|
if (exp.type === "LabelledStatement") {
|
|
3304
3424
|
exp = exp.statement;
|
|
3305
3425
|
}
|
|
3306
|
-
let
|
|
3426
|
+
let ref13;
|
|
3307
3427
|
let m3;
|
|
3308
3428
|
switch (exp.type) {
|
|
3309
3429
|
case "BreakStatement":
|
|
@@ -3315,14 +3435,14 @@ function insertReturn(node) {
|
|
|
3315
3435
|
return;
|
|
3316
3436
|
}
|
|
3317
3437
|
case "Declaration": {
|
|
3318
|
-
let
|
|
3438
|
+
let ref14;
|
|
3319
3439
|
if (exp.bindings?.length) {
|
|
3320
|
-
|
|
3440
|
+
ref14 = [" ", patternAsValue((ref13 = exp.bindings)[ref13.length - 1].pattern)];
|
|
3321
3441
|
} else {
|
|
3322
|
-
|
|
3442
|
+
ref14 = [];
|
|
3323
3443
|
}
|
|
3324
3444
|
;
|
|
3325
|
-
const value =
|
|
3445
|
+
const value = ref14;
|
|
3326
3446
|
const parent = outer.parent;
|
|
3327
3447
|
const index = findChildIndex(parent?.expressions, outer);
|
|
3328
3448
|
assert.notEqual(index, -1, "Could not find declaration in parent");
|
|
@@ -3382,15 +3502,15 @@ function insertReturn(node) {
|
|
|
3382
3502
|
return;
|
|
3383
3503
|
}
|
|
3384
3504
|
case "SwitchStatement": {
|
|
3385
|
-
for (let
|
|
3386
|
-
const clause =
|
|
3505
|
+
for (let ref15 = exp.caseBlock.clauses, i7 = 0, len6 = ref15.length; i7 < len6; i7++) {
|
|
3506
|
+
const clause = ref15[i7];
|
|
3387
3507
|
insertReturn(clause);
|
|
3388
3508
|
}
|
|
3389
3509
|
return;
|
|
3390
3510
|
}
|
|
3391
3511
|
case "TryStatement": {
|
|
3392
|
-
for (let
|
|
3393
|
-
const block =
|
|
3512
|
+
for (let ref16 = exp.blocks, i8 = 0, len7 = ref16.length; i8 < len7; i8++) {
|
|
3513
|
+
const block = ref16[i8];
|
|
3394
3514
|
insertReturn(block);
|
|
3395
3515
|
}
|
|
3396
3516
|
return;
|
|
@@ -3642,9 +3762,9 @@ function iterationDefaultBody(statement) {
|
|
|
3642
3762
|
}
|
|
3643
3763
|
const reduction = statement.type === "ForStatement" && statement.reduction;
|
|
3644
3764
|
function fillBlock(expression) {
|
|
3645
|
-
let
|
|
3765
|
+
let ref17;
|
|
3646
3766
|
let m5;
|
|
3647
|
-
if (m5 = (
|
|
3767
|
+
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
3768
|
block.expressions.pop();
|
|
3649
3769
|
}
|
|
3650
3770
|
block.expressions.push(expression);
|
|
@@ -3714,8 +3834,8 @@ function processParams(f) {
|
|
|
3714
3834
|
function append2(p) {
|
|
3715
3835
|
(rest ? after : before).push(p);
|
|
3716
3836
|
}
|
|
3717
|
-
for (let
|
|
3718
|
-
const param =
|
|
3837
|
+
for (let ref18 = parameters.parameters, i9 = 0, len8 = ref18.length; i9 < len8; i9++) {
|
|
3838
|
+
const param = ref18[i9];
|
|
3719
3839
|
switch (param.type) {
|
|
3720
3840
|
case "ThisType": {
|
|
3721
3841
|
if (tt) {
|
|
@@ -3727,8 +3847,8 @@ function processParams(f) {
|
|
|
3727
3847
|
} else {
|
|
3728
3848
|
tt = trimFirstSpace(param);
|
|
3729
3849
|
if (before.length || rest) {
|
|
3730
|
-
let
|
|
3731
|
-
let delim = (
|
|
3850
|
+
let ref19;
|
|
3851
|
+
let delim = (ref19 = tt.children)[ref19.length - 1];
|
|
3732
3852
|
if (Array.isArray(delim)) {
|
|
3733
3853
|
delim = delim[delim.length - 1];
|
|
3734
3854
|
}
|
|
@@ -3915,19 +4035,16 @@ function processParams(f) {
|
|
|
3915
4035
|
const classExpressions = ancestor.body.expressions;
|
|
3916
4036
|
let index2 = findChildIndex(classExpressions, f);
|
|
3917
4037
|
assert.notEqual(index2, -1, "Could not find constructor in class");
|
|
3918
|
-
|
|
3919
|
-
while (m7 = classExpressions[index2 - 1]?.[1], typeof m7 === "object" && m7 != null && "type" in m7 && m7.type === "MethodDefinition" && "name" in m7 && m7.name === "constructor") {
|
|
3920
|
-
index2--;
|
|
3921
|
-
}
|
|
4038
|
+
index2 -= precedingOverloads(f).length;
|
|
3922
4039
|
const fStatement = classExpressions[index2];
|
|
3923
|
-
for (let
|
|
3924
|
-
const parameter =
|
|
4040
|
+
for (let ref20 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i10 = 0, len9 = ref20.length; i10 < len9; i10++) {
|
|
4041
|
+
const parameter = ref20[i10];
|
|
3925
4042
|
const { accessModifier } = parameter;
|
|
3926
4043
|
if (!(accessModifier || parameter.typeSuffix)) {
|
|
3927
4044
|
continue;
|
|
3928
4045
|
}
|
|
3929
|
-
for (let
|
|
3930
|
-
const binding =
|
|
4046
|
+
for (let ref21 = gatherRecursive(parameter, ($15) => $15.type === "AtBinding"), i11 = 0, len10 = ref21.length; i11 < len10; i11++) {
|
|
4047
|
+
const binding = ref21[i11];
|
|
3931
4048
|
const typeSuffix = binding.parent?.typeSuffix;
|
|
3932
4049
|
if (!(accessModifier || typeSuffix)) {
|
|
3933
4050
|
continue;
|
|
@@ -3965,8 +4082,8 @@ function processParams(f) {
|
|
|
3965
4082
|
decl: "const"
|
|
3966
4083
|
}));
|
|
3967
4084
|
}
|
|
3968
|
-
for (let
|
|
3969
|
-
const binding =
|
|
4085
|
+
for (let ref22 = splices, i12 = 0, len11 = ref22.length; i12 < len11; i12++) {
|
|
4086
|
+
const binding = ref22[i12];
|
|
3970
4087
|
assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding");
|
|
3971
4088
|
prefix.push(makeNode({
|
|
3972
4089
|
type: "Declaration",
|
|
@@ -4013,13 +4130,14 @@ function findSuperCall(block) {
|
|
|
4013
4130
|
}
|
|
4014
4131
|
function processSignature(f) {
|
|
4015
4132
|
const { block, signature } = f;
|
|
4133
|
+
let addAsync = false;
|
|
4134
|
+
let addGenerator = false;
|
|
4016
4135
|
if (!f.async?.length && hasAwait(block)) {
|
|
4017
4136
|
if (f.async != null) {
|
|
4018
|
-
|
|
4019
|
-
signature.modifier.async = true;
|
|
4137
|
+
addAsync = true;
|
|
4020
4138
|
} else {
|
|
4021
|
-
for (let
|
|
4022
|
-
const a =
|
|
4139
|
+
for (let ref23 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i13 = 0, len12 = ref23.length; i13 < len12; i13++) {
|
|
4140
|
+
const a = ref23[i13];
|
|
4023
4141
|
const i = findChildIndex(a.parent, a);
|
|
4024
4142
|
a.parent.children.splice(i + 1, 0, {
|
|
4025
4143
|
type: "Error",
|
|
@@ -4030,11 +4148,10 @@ function processSignature(f) {
|
|
|
4030
4148
|
}
|
|
4031
4149
|
if (!f.generator?.length && hasYield(block)) {
|
|
4032
4150
|
if (f.generator != null) {
|
|
4033
|
-
|
|
4034
|
-
signature.modifier.generator = true;
|
|
4151
|
+
addGenerator = true;
|
|
4035
4152
|
} else {
|
|
4036
|
-
for (let
|
|
4037
|
-
const y =
|
|
4153
|
+
for (let ref24 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i14 = 0, len13 = ref24.length; i14 < len13; i14++) {
|
|
4154
|
+
const y = ref24[i14];
|
|
4038
4155
|
const i = y.children.findIndex(($19) => $19.type === "Yield");
|
|
4039
4156
|
y.children.splice(i + 1, 0, {
|
|
4040
4157
|
type: "Error",
|
|
@@ -4043,17 +4160,28 @@ function processSignature(f) {
|
|
|
4043
4160
|
}
|
|
4044
4161
|
}
|
|
4045
4162
|
}
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
signature.
|
|
4051
|
-
|
|
4163
|
+
for (let ref25 = [f, ...precedingOverloads(f)], i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
|
|
4164
|
+
const overload = ref25[i15];
|
|
4165
|
+
if (addAsync && overload.async != null && !overload.async.length) {
|
|
4166
|
+
overload.async.push("async ");
|
|
4167
|
+
overload.signature.modifier.async = true;
|
|
4168
|
+
}
|
|
4169
|
+
if (addGenerator && overload.generator != null && !overload.generator.length) {
|
|
4170
|
+
overload.generator.push("*");
|
|
4171
|
+
overload.signature.modifier.generator = true;
|
|
4172
|
+
}
|
|
4173
|
+
if (overload.signature.modifier.async && !overload.signature.modifier.generator && overload.signature.returnType && !isPromiseType(overload.signature.returnType.t)) {
|
|
4174
|
+
replaceNode(
|
|
4175
|
+
overload.signature.returnType.t,
|
|
4176
|
+
wrapTypeInPromise(overload.signature.returnType.t),
|
|
4177
|
+
overload.signature.returnType
|
|
4178
|
+
);
|
|
4179
|
+
}
|
|
4052
4180
|
}
|
|
4053
4181
|
}
|
|
4054
4182
|
function processFunctions(statements, config2) {
|
|
4055
|
-
for (let
|
|
4056
|
-
const f =
|
|
4183
|
+
for (let ref26 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i16 = 0, len15 = ref26.length; i16 < len15; i16++) {
|
|
4184
|
+
const f = ref26[i16];
|
|
4057
4185
|
if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
|
|
4058
4186
|
implicitFunctionBlock(f);
|
|
4059
4187
|
}
|
|
@@ -4112,9 +4240,9 @@ function expressionizeIteration(exp) {
|
|
|
4112
4240
|
}
|
|
4113
4241
|
let done;
|
|
4114
4242
|
if (!async) {
|
|
4115
|
-
let
|
|
4116
|
-
if ((
|
|
4117
|
-
const { block: parentBlock, index } =
|
|
4243
|
+
let ref27;
|
|
4244
|
+
if ((ref27 = blockContainingStatement(exp)) && typeof ref27 === "object" && "block" in ref27 && "index" in ref27) {
|
|
4245
|
+
const { block: parentBlock, index } = ref27;
|
|
4118
4246
|
statements[0][0] = parentBlock.expressions[index][0];
|
|
4119
4247
|
parentBlock.expressions.splice(index, index + 1 - index, ...statements);
|
|
4120
4248
|
updateParentPointers(parentBlock);
|
|
@@ -4131,8 +4259,8 @@ function expressionizeIteration(exp) {
|
|
|
4131
4259
|
}
|
|
4132
4260
|
}
|
|
4133
4261
|
function processIterationExpressions(statements) {
|
|
4134
|
-
for (let
|
|
4135
|
-
const s =
|
|
4262
|
+
for (let ref28 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i17 = 0, len16 = ref28.length; i17 < len16; i17++) {
|
|
4263
|
+
const s = ref28[i17];
|
|
4136
4264
|
expressionizeIteration(s);
|
|
4137
4265
|
}
|
|
4138
4266
|
}
|
|
@@ -4155,13 +4283,13 @@ function processCoffeeDo(ws, expression) {
|
|
|
4155
4283
|
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "ArrowFunction" || typeof expression === "object" && expression != null && "type" in expression && expression.type === "FunctionExpression") {
|
|
4156
4284
|
let { parameters } = expression;
|
|
4157
4285
|
const parameterList = parameters.parameters;
|
|
4158
|
-
const
|
|
4159
|
-
for (let
|
|
4160
|
-
let parameter = parameterList[
|
|
4286
|
+
const results3 = [];
|
|
4287
|
+
for (let i18 = 0, len17 = parameterList.length; i18 < len17; i18++) {
|
|
4288
|
+
let parameter = parameterList[i18];
|
|
4161
4289
|
if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
|
|
4162
|
-
let
|
|
4163
|
-
if (
|
|
4164
|
-
const initializer =
|
|
4290
|
+
let ref29;
|
|
4291
|
+
if (ref29 = parameter.initializer) {
|
|
4292
|
+
const initializer = ref29;
|
|
4165
4293
|
args.push(initializer.expression, parameter.delim);
|
|
4166
4294
|
parameter = {
|
|
4167
4295
|
...parameter,
|
|
@@ -4174,10 +4302,10 @@ function processCoffeeDo(ws, expression) {
|
|
|
4174
4302
|
));
|
|
4175
4303
|
}
|
|
4176
4304
|
}
|
|
4177
|
-
|
|
4305
|
+
results3.push(parameter);
|
|
4178
4306
|
}
|
|
4179
4307
|
;
|
|
4180
|
-
const newParameterList =
|
|
4308
|
+
const newParameterList = results3;
|
|
4181
4309
|
const newParameters = {
|
|
4182
4310
|
...parameters,
|
|
4183
4311
|
parameters: newParameterList,
|
|
@@ -4291,8 +4419,9 @@ function unbraceBlock(block) {
|
|
|
4291
4419
|
if (block.bare) {
|
|
4292
4420
|
return;
|
|
4293
4421
|
}
|
|
4422
|
+
let m;
|
|
4294
4423
|
let ref;
|
|
4295
|
-
if (block.children[0] === " {" && (ref = block.children)[ref.length - 1] === "}") {
|
|
4424
|
+
if ((m = block.children[0], m === " {" || m === "{") && (ref = block.children)[ref.length - 1] === "}") {
|
|
4296
4425
|
block.children.shift();
|
|
4297
4426
|
block.children.pop();
|
|
4298
4427
|
block.bare = true;
|
|
@@ -4328,17 +4457,6 @@ function makeEmptyBlock() {
|
|
|
4328
4457
|
empty: true
|
|
4329
4458
|
};
|
|
4330
4459
|
}
|
|
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
4460
|
function replaceBlockExpression(node, child, replacement) {
|
|
4343
4461
|
let found = false;
|
|
4344
4462
|
const { expressions } = node;
|
|
@@ -4384,22 +4502,44 @@ function hoistRefDecs(statements) {
|
|
|
4384
4502
|
});
|
|
4385
4503
|
}
|
|
4386
4504
|
function insertHoistDec(block, node, dec) {
|
|
4387
|
-
const
|
|
4388
|
-
|
|
4505
|
+
const statement = ["", dec, ";"];
|
|
4506
|
+
insertBeforeInBlock(block, node, statement);
|
|
4507
|
+
}
|
|
4508
|
+
function insertBeforeInBlock(block, node, ...statements) {
|
|
4509
|
+
const index = findChildIndex(block.expressions, node);
|
|
4389
4510
|
if (index < 0) {
|
|
4390
|
-
throw new Error("
|
|
4511
|
+
throw new Error("insertBeforeInBlock couldn't find existing statement in block");
|
|
4512
|
+
}
|
|
4513
|
+
insertBlockStatements(block, index, ...statements);
|
|
4514
|
+
}
|
|
4515
|
+
function insertBlockStatements(block, index, ...statements) {
|
|
4516
|
+
if (!statements.length) {
|
|
4517
|
+
return;
|
|
4391
4518
|
}
|
|
4392
|
-
const
|
|
4393
|
-
expressions[index]
|
|
4394
|
-
|
|
4395
|
-
|
|
4519
|
+
const { expressions } = block;
|
|
4520
|
+
const before = expressions[index];
|
|
4521
|
+
if (statements[0][0] && before?.[0]) {
|
|
4522
|
+
if (!Array.isArray(statements[0][0])) {
|
|
4523
|
+
statements[0][0] = [statements[0][0]];
|
|
4524
|
+
}
|
|
4525
|
+
if (!Array.isArray(before[0])) {
|
|
4526
|
+
before[0] = [before[0]];
|
|
4527
|
+
}
|
|
4528
|
+
statements[0][0] = [...before[0], ...statements[0][0]];
|
|
4529
|
+
} else {
|
|
4530
|
+
statements[0][0] ||= before?.[0];
|
|
4531
|
+
}
|
|
4532
|
+
before[0] = "";
|
|
4533
|
+
expressions.splice(index, 0, ...statements);
|
|
4534
|
+
updateParentPointers(block);
|
|
4535
|
+
braceBlock(block);
|
|
4396
4536
|
}
|
|
4397
4537
|
function processBlocks(statements) {
|
|
4398
4538
|
insertSemicolon(statements);
|
|
4399
4539
|
for (let ref1 = gatherRecursive(statements, ($) => $.type === "BlockStatement"), i2 = 0, len12 = ref1.length; i2 < len12; i2++) {
|
|
4400
4540
|
const block = ref1[i2];
|
|
4401
|
-
let
|
|
4402
|
-
if (block.unwrapObject && block.expressions.length === 1 && (
|
|
4541
|
+
let m1;
|
|
4542
|
+
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
4543
|
const object = block.expressions[0][1].expression;
|
|
4404
4544
|
if (!(() => {
|
|
4405
4545
|
let results = true;
|
|
@@ -4418,8 +4558,8 @@ function processBlocks(statements) {
|
|
|
4418
4558
|
for (let ref2 = object.properties, i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
|
|
4419
4559
|
const i = i3;
|
|
4420
4560
|
const prop = ref2[i3];
|
|
4421
|
-
let
|
|
4422
|
-
if (
|
|
4561
|
+
let m2;
|
|
4562
|
+
if (m2 = prop.name, typeof m2 === "object" && m2 != null && "type" in m2 && m2.type === "ComputedPropertyName" && "implicit" in m2 && m2.implicit === true) {
|
|
4423
4563
|
replaceNode(prop.name, prop.name.expression, prop);
|
|
4424
4564
|
}
|
|
4425
4565
|
if (prop.delim?.implicit) {
|
|
@@ -4512,8 +4652,8 @@ function needsPrecedingSemicolon(exp) {
|
|
|
4512
4652
|
function blockContainingStatement(exp) {
|
|
4513
4653
|
let child = exp;
|
|
4514
4654
|
let parent = exp.parent;
|
|
4515
|
-
let
|
|
4516
|
-
while (parent != null && (
|
|
4655
|
+
let m3;
|
|
4656
|
+
while (parent != null && (m3 = parent.type, m3 === "StatementExpression" || m3 === "PipelineExpression" || m3 === "UnwrappedExpression")) {
|
|
4517
4657
|
child = parent;
|
|
4518
4658
|
parent = parent.parent;
|
|
4519
4659
|
}
|
|
@@ -5466,22 +5606,23 @@ function processDeclarations(statements) {
|
|
|
5466
5606
|
if (typeSuffix && typeSuffix.optional) {
|
|
5467
5607
|
if (initializer && !typeSuffix.t) {
|
|
5468
5608
|
const expression = trimFirstSpace(initializer.expression);
|
|
5469
|
-
|
|
5470
|
-
if (
|
|
5471
|
-
typeSuffix.children.push(": ", typeSuffix.t = {
|
|
5472
|
-
type: "TypeTypeof",
|
|
5473
|
-
children: ["typeof ", expression],
|
|
5474
|
-
expression
|
|
5475
|
-
});
|
|
5476
|
-
} else if (expression.type === "Literal" || expression.type === "RegularExpressionLiteral" || expression.type === "TemplateLiteral") {
|
|
5477
|
-
typeSuffix.children.push(": ", typeSuffix.t = literalType(expression));
|
|
5478
|
-
} else {
|
|
5609
|
+
typeSuffix.t = typeOfExpression(expression);
|
|
5610
|
+
if (!(typeSuffix.t != null)) {
|
|
5479
5611
|
spliceChild(binding, typeSuffix, 1, {
|
|
5480
5612
|
type: "Error",
|
|
5481
|
-
message:
|
|
5613
|
+
message: (() => {
|
|
5614
|
+
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "Literal" && "subtype" in expression && expression.subtype === "NullLiteral") {
|
|
5615
|
+
return "Optional type can't be inferred from null";
|
|
5616
|
+
} else if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "Identifier" && "name" in expression && expression.name === "undefined") {
|
|
5617
|
+
return "Optional type can't be inferred from undefined";
|
|
5618
|
+
} else {
|
|
5619
|
+
return `Optional type can only be inferred from literals or member expressions, not ${expression.type}`;
|
|
5620
|
+
}
|
|
5621
|
+
})()
|
|
5482
5622
|
});
|
|
5483
5623
|
continue;
|
|
5484
5624
|
}
|
|
5625
|
+
typeSuffix.children.push(": ", typeSuffix.t);
|
|
5485
5626
|
}
|
|
5486
5627
|
if (typeSuffix.t) {
|
|
5487
5628
|
convertOptionalType(typeSuffix);
|
|
@@ -5522,16 +5663,16 @@ function processDeclarations(statements) {
|
|
|
5522
5663
|
function prependStatementExpressionBlock(initializer, statement) {
|
|
5523
5664
|
let { expression: exp } = initializer;
|
|
5524
5665
|
let ws;
|
|
5525
|
-
if (Array.isArray(exp)) {
|
|
5666
|
+
if (Array.isArray(exp) && exp.length === 2 && isWhitespaceOrEmpty(exp[0])) {
|
|
5526
5667
|
ws = exp[0];
|
|
5527
5668
|
exp = exp[1];
|
|
5528
5669
|
}
|
|
5529
5670
|
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")) {
|
|
5530
5671
|
return;
|
|
5531
5672
|
}
|
|
5532
|
-
const pre = [];
|
|
5533
5673
|
const statementExp = exp.statement;
|
|
5534
5674
|
const blockStatement = [ws || "", statementExp, ";"];
|
|
5675
|
+
const pre = [blockStatement];
|
|
5535
5676
|
let ref;
|
|
5536
5677
|
if (statementExp.type === "IterationExpression") {
|
|
5537
5678
|
if (statementExp.async || statementExp.generator) {
|
|
@@ -5547,8 +5688,7 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5547
5688
|
assignResults(blockStatement, (resultNode) => {
|
|
5548
5689
|
return makeNode({
|
|
5549
5690
|
type: "AssignmentExpression",
|
|
5550
|
-
children: [ref, " = ", resultNode]
|
|
5551
|
-
parent: statement2
|
|
5691
|
+
children: [ref, " = ", resultNode]
|
|
5552
5692
|
});
|
|
5553
5693
|
});
|
|
5554
5694
|
const refDec = {
|
|
@@ -5565,8 +5705,7 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5565
5705
|
assignResults(blockStatement, (resultNode) => {
|
|
5566
5706
|
return makeNode({
|
|
5567
5707
|
type: "AssignmentExpression",
|
|
5568
|
-
children: [ref, " = ", resultNode]
|
|
5569
|
-
parent: statement
|
|
5708
|
+
children: [ref, " = ", resultNode]
|
|
5570
5709
|
});
|
|
5571
5710
|
});
|
|
5572
5711
|
const refDec = {
|
|
@@ -5575,8 +5714,12 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5575
5714
|
};
|
|
5576
5715
|
pre.unshift(["", refDec, ";"]);
|
|
5577
5716
|
}
|
|
5578
|
-
|
|
5579
|
-
|
|
5717
|
+
let ref3;
|
|
5718
|
+
if (!((ref3 = blockContainingStatement(statement)) && typeof ref3 === "object" && "block" in ref3 && "index" in ref3)) {
|
|
5719
|
+
throw new Error("Couldn't find block in prependStatementExpressionBlock");
|
|
5720
|
+
}
|
|
5721
|
+
const { block, index } = ref3;
|
|
5722
|
+
insertBlockStatements(block, index, ...pre);
|
|
5580
5723
|
return ref;
|
|
5581
5724
|
}
|
|
5582
5725
|
function processDeclarationCondition(condition, rootCondition, parent) {
|
|
@@ -5675,8 +5818,8 @@ function processDeclarationConditionStatement(s) {
|
|
|
5675
5818
|
if (conditions.length) {
|
|
5676
5819
|
let children = condition.children;
|
|
5677
5820
|
if (s.negated) {
|
|
5678
|
-
let
|
|
5679
|
-
if (!(
|
|
5821
|
+
let m;
|
|
5822
|
+
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")) {
|
|
5680
5823
|
throw new Error("Unsupported negated condition");
|
|
5681
5824
|
}
|
|
5682
5825
|
;
|
|
@@ -5706,11 +5849,11 @@ function processDeclarationConditionStatement(s) {
|
|
|
5706
5849
|
ancestor.expressions.splice(index + 1, 0, ...blockPrefix);
|
|
5707
5850
|
updateParentPointers(ancestor);
|
|
5708
5851
|
braceBlock(ancestor);
|
|
5709
|
-
let
|
|
5852
|
+
let ref4;
|
|
5710
5853
|
switch (s.type) {
|
|
5711
5854
|
case "IfStatement": {
|
|
5712
|
-
if (
|
|
5713
|
-
const elseBlock =
|
|
5855
|
+
if (ref4 = s.else?.block) {
|
|
5856
|
+
const elseBlock = ref4;
|
|
5714
5857
|
if (elseBlock.bare && !elseBlock.semicolon) {
|
|
5715
5858
|
elseBlock.children.push(elseBlock.semicolon = ";");
|
|
5716
5859
|
}
|
|
@@ -5762,38 +5905,19 @@ function processDeclarationConditionStatement(s) {
|
|
|
5762
5905
|
if (!blockPrefix) {
|
|
5763
5906
|
return;
|
|
5764
5907
|
}
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
expression: ref2,
|
|
5769
|
-
parent: s
|
|
5770
|
-
};
|
|
5771
|
-
s.children = s.children.map(function(c) {
|
|
5772
|
-
if (c === s.condition) {
|
|
5773
|
-
return newCondition;
|
|
5774
|
-
} else {
|
|
5775
|
-
return c;
|
|
5776
|
-
}
|
|
5777
|
-
});
|
|
5778
|
-
s.condition = newCondition;
|
|
5779
|
-
updateParentPointers(s);
|
|
5780
|
-
if (statementDeclaration) {
|
|
5781
|
-
const block = makeEmptyBlock();
|
|
5782
|
-
replaceBlockExpression(s.parent, s, block);
|
|
5783
|
-
block.expressions.push(["", s]);
|
|
5784
|
-
s.children.splice(s.children.findIndex(($5) => $5.token === "switch"), 0, blockPrefix);
|
|
5785
|
-
s.parent = block;
|
|
5786
|
-
} else {
|
|
5787
|
-
const block = blockWithPrefix([["", [{
|
|
5908
|
+
replaceNode(s.condition, parenthesizeExpression(ref2), s);
|
|
5909
|
+
if (!statementDeclaration) {
|
|
5910
|
+
const declStatement = ["", [{
|
|
5788
5911
|
type: "Declaration",
|
|
5789
5912
|
children: ["let ", ...condition.expression.children]
|
|
5790
|
-
}], ";"]
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
;
|
|
5913
|
+
}], ";"];
|
|
5914
|
+
blockPrefix.unshift(declStatement);
|
|
5915
|
+
}
|
|
5916
|
+
const block = blockWithPrefix(blockPrefix, makeEmptyBlock());
|
|
5917
|
+
updateParentPointers(block, s.parent);
|
|
5918
|
+
replaceBlockExpression(s.parent, s, block);
|
|
5919
|
+
block.expressions.push(["", s]);
|
|
5920
|
+
s.parent = block;
|
|
5797
5921
|
break;
|
|
5798
5922
|
}
|
|
5799
5923
|
}
|
|
@@ -5801,12 +5925,12 @@ function processDeclarationConditionStatement(s) {
|
|
|
5801
5925
|
function dynamizeFromClause(from) {
|
|
5802
5926
|
from = from.slice(1);
|
|
5803
5927
|
from = trimFirstSpace(from);
|
|
5804
|
-
let
|
|
5805
|
-
if (
|
|
5806
|
-
const assert2 =
|
|
5807
|
-
let
|
|
5808
|
-
|
|
5809
|
-
|
|
5928
|
+
let ref5;
|
|
5929
|
+
if (ref5 = from[from.length - 1]?.assertion) {
|
|
5930
|
+
const assert2 = ref5;
|
|
5931
|
+
let ref6;
|
|
5932
|
+
ref6 = from[from.length - 1];
|
|
5933
|
+
ref6.children = ref6.children.filter((a2) => a2 !== assert2);
|
|
5810
5934
|
from.push(", {", assert2.keyword, ":", assert2.object, "}");
|
|
5811
5935
|
}
|
|
5812
5936
|
return ["(", ...from, ")"];
|
|
@@ -5815,20 +5939,20 @@ function dynamizeImportDeclaration(decl) {
|
|
|
5815
5939
|
const { imports } = decl;
|
|
5816
5940
|
let { star, binding, specifiers } = imports;
|
|
5817
5941
|
const justDefault = binding && !specifiers && !star;
|
|
5818
|
-
let
|
|
5942
|
+
let ref7;
|
|
5819
5943
|
{
|
|
5820
5944
|
if (binding) {
|
|
5821
5945
|
if (specifiers) {
|
|
5822
|
-
|
|
5946
|
+
ref7 = makeRef();
|
|
5823
5947
|
} else {
|
|
5824
|
-
|
|
5948
|
+
ref7 = binding;
|
|
5825
5949
|
}
|
|
5826
5950
|
} else {
|
|
5827
|
-
|
|
5951
|
+
ref7 = convertNamedImportsToObject(imports, true);
|
|
5828
5952
|
}
|
|
5829
5953
|
}
|
|
5830
5954
|
;
|
|
5831
|
-
const pattern =
|
|
5955
|
+
const pattern = ref7;
|
|
5832
5956
|
const c = "const";
|
|
5833
5957
|
const expression = [
|
|
5834
5958
|
justDefault ? "(" : void 0,
|
|
@@ -6819,7 +6943,7 @@ function processForInOf($0) {
|
|
|
6819
6943
|
var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
|
|
6820
6944
|
function findDecs(statements) {
|
|
6821
6945
|
const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
|
|
6822
|
-
const declarationNames = declarations.flatMap((
|
|
6946
|
+
const declarationNames = declarations.flatMap(($1) => $1.names);
|
|
6823
6947
|
const globals = getConfig().globals || [];
|
|
6824
6948
|
return new Set(globals.concat(declarationNames));
|
|
6825
6949
|
}
|
|
@@ -6827,16 +6951,16 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6827
6951
|
function findVarDecs(statements2, decs) {
|
|
6828
6952
|
const declarationNames = gatherRecursive(statements2, (node) => {
|
|
6829
6953
|
return node.type === "Declaration" && node.children && node.children.length > 0 && node.children[0].token && node.children[0].token.startsWith("var") || node.type === "FunctionExpression";
|
|
6830
|
-
}).filter((
|
|
6954
|
+
}).filter(($2) => $2.type === "Declaration").flatMap(($3) => $3.names);
|
|
6831
6955
|
return new Set(declarationNames);
|
|
6832
6956
|
}
|
|
6833
6957
|
let declaredIdentifiers = findVarDecs(statements);
|
|
6834
6958
|
function hasDec(name) {
|
|
6835
|
-
return declaredIdentifiers.has(name) || scopes.some(($
|
|
6959
|
+
return declaredIdentifiers.has(name) || scopes.some(($4) => $4.has(name));
|
|
6836
6960
|
}
|
|
6837
6961
|
function gatherBlockOrOther(statement) {
|
|
6838
|
-
return gatherNodes(statement, (
|
|
6839
|
-
if (node.type
|
|
6962
|
+
return gatherNodes(statement, ($5) => $5.type === "BlockStatement" || $5.type === "AssignmentExpression" || $5.type === "Declaration").flatMap((node) => {
|
|
6963
|
+
if (node.type === "BlockStatement") {
|
|
6840
6964
|
return node.bare ? gatherBlockOrOther(node.expressions) : node;
|
|
6841
6965
|
} else if (node.children && node.children.length) {
|
|
6842
6966
|
return [...gatherBlockOrOther(node.children), node];
|
|
@@ -6848,16 +6972,18 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6848
6972
|
let currentScope = /* @__PURE__ */ new Set();
|
|
6849
6973
|
scopes.push(currentScope);
|
|
6850
6974
|
const fnNodes = gatherNodes(statements, isFunction);
|
|
6851
|
-
const forNodes = gatherNodes(statements, (
|
|
6975
|
+
const forNodes = gatherNodes(statements, ($6) => $6.type === "ForStatement");
|
|
6852
6976
|
let targetStatements = [];
|
|
6853
|
-
for (
|
|
6977
|
+
for (let i1 = 0, len3 = statements.length; i1 < len3; i1++) {
|
|
6978
|
+
const statement = statements[i1];
|
|
6854
6979
|
const nodes = gatherBlockOrOther(statement);
|
|
6855
6980
|
let undeclaredIdentifiers = [];
|
|
6856
|
-
for (
|
|
6857
|
-
|
|
6981
|
+
for (let i2 = 0, len12 = nodes.length; i2 < len12; i2++) {
|
|
6982
|
+
const node = nodes[i2];
|
|
6983
|
+
if (node.type === "BlockStatement") {
|
|
6858
6984
|
let block = node;
|
|
6859
|
-
let fnNode = fnNodes.find((
|
|
6860
|
-
let forNode = forNodes.find((
|
|
6985
|
+
let fnNode = fnNodes.find(($7) => $7.block === block);
|
|
6986
|
+
let forNode = forNodes.find(($8) => $8.block === block);
|
|
6861
6987
|
if (fnNode != null) {
|
|
6862
6988
|
scopes.push(new Set(fnNode.parameters.names));
|
|
6863
6989
|
createConstLetDecs(block.expressions, scopes, letOrConst);
|
|
@@ -6871,21 +6997,26 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6871
6997
|
}
|
|
6872
6998
|
continue;
|
|
6873
6999
|
}
|
|
6874
|
-
if (node.names
|
|
6875
|
-
|
|
6876
|
-
|
|
7000
|
+
if (!(node.names != null)) {
|
|
7001
|
+
continue;
|
|
7002
|
+
}
|
|
7003
|
+
const names = node.names.filter((name) => !hasDec(name));
|
|
7004
|
+
if (node.type === "AssignmentExpression") {
|
|
6877
7005
|
undeclaredIdentifiers.push(...names);
|
|
6878
7006
|
}
|
|
6879
|
-
names.
|
|
7007
|
+
for (let i3 = 0, len22 = names.length; i3 < len22; i3++) {
|
|
7008
|
+
const name = names[i3];
|
|
7009
|
+
currentScope.add(name);
|
|
7010
|
+
}
|
|
6880
7011
|
}
|
|
6881
|
-
if (undeclaredIdentifiers.length
|
|
7012
|
+
if (undeclaredIdentifiers.length) {
|
|
6882
7013
|
let indent = statement[0];
|
|
6883
|
-
let firstIdentifier = gatherNodes(statement[1], (
|
|
6884
|
-
if (undeclaredIdentifiers.length
|
|
7014
|
+
let firstIdentifier = gatherNodes(statement[1], ($9) => $9.type === "Identifier")[0];
|
|
7015
|
+
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) {
|
|
6885
7016
|
statement[1].children.unshift([`${letOrConst} `]);
|
|
6886
7017
|
} else {
|
|
6887
7018
|
let tail = "\n";
|
|
6888
|
-
if (gatherNodes(indent, (
|
|
7019
|
+
if (gatherNodes(indent, ($11) => $11.token && $11.token.endsWith("\n")).length) {
|
|
6889
7020
|
tail = void 0;
|
|
6890
7021
|
}
|
|
6891
7022
|
targetStatements.push([indent, {
|
|
@@ -6902,17 +7033,17 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6902
7033
|
}
|
|
6903
7034
|
function createVarDecs(block, scopes, pushVar) {
|
|
6904
7035
|
function hasDec(name) {
|
|
6905
|
-
return scopes.some(($
|
|
7036
|
+
return scopes.some(($12) => $12.has(name));
|
|
6906
7037
|
}
|
|
6907
7038
|
function findAssignments(statements2, decs2) {
|
|
6908
|
-
let assignmentStatements2 = gatherNodes(statements2, ($
|
|
7039
|
+
let assignmentStatements2 = gatherNodes(statements2, ($13) => $13.type === "AssignmentExpression");
|
|
6909
7040
|
if (assignmentStatements2.length) {
|
|
6910
7041
|
concatAssign2(
|
|
6911
7042
|
assignmentStatements2,
|
|
6912
7043
|
findAssignments(assignmentStatements2.map((s) => s.children), decs2)
|
|
6913
7044
|
);
|
|
6914
7045
|
}
|
|
6915
|
-
return assignmentStatements2.filter(($
|
|
7046
|
+
return assignmentStatements2.filter(($14) => !($14.parent?.type === "CoffeeClassPublic"));
|
|
6916
7047
|
}
|
|
6917
7048
|
pushVar ??= (name) => {
|
|
6918
7049
|
varIds.push(name);
|
|
@@ -6923,7 +7054,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6923
7054
|
scopes.push(decs);
|
|
6924
7055
|
const varIds = [];
|
|
6925
7056
|
const assignmentStatements = findAssignments(statements, scopes);
|
|
6926
|
-
const undeclaredIdentifiers = assignmentStatements.flatMap(($
|
|
7057
|
+
const undeclaredIdentifiers = assignmentStatements.flatMap(($15) => $15?.names || []);
|
|
6927
7058
|
undeclaredIdentifiers.filter((x, i, a) => {
|
|
6928
7059
|
if (!hasDec(x)) return a.indexOf(x) === i;
|
|
6929
7060
|
return;
|
|
@@ -8089,24 +8220,20 @@ function processAssignments(statements) {
|
|
|
8089
8220
|
continue;
|
|
8090
8221
|
}
|
|
8091
8222
|
let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
|
|
8092
|
-
let block;
|
|
8093
8223
|
let ref13;
|
|
8094
8224
|
let ref14;
|
|
8095
8225
|
if (blockContainingStatement(exp) && !(ref13 = $1[$1.length - 1])?.[ref13.length - 1]?.special && !isShortCircuitOp((ref14 = $1[$1.length - 1])?.[ref14.length - 1])) {
|
|
8096
|
-
block = makeBlockFragment();
|
|
8097
8226
|
let ref15;
|
|
8098
8227
|
if (ref15 = prependStatementExpressionBlock(
|
|
8099
8228
|
{ type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
|
|
8100
|
-
|
|
8229
|
+
exp
|
|
8101
8230
|
)) {
|
|
8102
8231
|
const ref = ref15;
|
|
8103
|
-
|
|
8232
|
+
replaceNode($2, ref, exp);
|
|
8104
8233
|
$2 = ref;
|
|
8105
|
-
} else {
|
|
8106
|
-
block = void 0;
|
|
8107
8234
|
}
|
|
8108
8235
|
}
|
|
8109
|
-
if ($1.some(($
|
|
8236
|
+
if ($1.some(($7) => $7[$7.length - 1].special)) {
|
|
8110
8237
|
if ($1.length !== 1) throw new Error("Only one assignment with id= is allowed");
|
|
8111
8238
|
const [, lhs, , op] = $1[0];
|
|
8112
8239
|
const { call, omitLhs } = op;
|
|
@@ -8178,7 +8305,7 @@ function processAssignments(statements) {
|
|
|
8178
8305
|
break;
|
|
8179
8306
|
} else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern" || m3 === "NamedBindingPattern") {
|
|
8180
8307
|
processBindingPatternLHS(lhs, tail);
|
|
8181
|
-
gatherRecursiveAll(lhs, ($
|
|
8308
|
+
gatherRecursiveAll(lhs, ($8) => $8.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
|
|
8182
8309
|
}
|
|
8183
8310
|
}
|
|
8184
8311
|
i--;
|
|
@@ -8210,7 +8337,7 @@ function processAssignments(statements) {
|
|
|
8210
8337
|
}
|
|
8211
8338
|
if (refsToDeclare.size) {
|
|
8212
8339
|
if (exp.hoistDec) {
|
|
8213
|
-
exp.hoistDec.children.push([...refsToDeclare].map(($
|
|
8340
|
+
exp.hoistDec.children.push([...refsToDeclare].map(($9) => [",", $9]));
|
|
8214
8341
|
} else {
|
|
8215
8342
|
exp.hoistDec = {
|
|
8216
8343
|
type: "Declaration",
|
|
@@ -8225,11 +8352,6 @@ function processAssignments(statements) {
|
|
|
8225
8352
|
if (index < 0) throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
8226
8353
|
exp.children.splice(index + 1, 0, ...tail);
|
|
8227
8354
|
}
|
|
8228
|
-
if (block) {
|
|
8229
|
-
replaceNode(exp, block);
|
|
8230
|
-
block.expressions.push(["", exp]);
|
|
8231
|
-
exp.parent = block;
|
|
8232
|
-
}
|
|
8233
8355
|
}
|
|
8234
8356
|
}
|
|
8235
8357
|
function unchainOptionalMemberExpression(exp, ref, innerExp) {
|
|
@@ -8318,7 +8440,7 @@ function attachPostfixStatementAsExpression(exp, post) {
|
|
|
8318
8440
|
}
|
|
8319
8441
|
function processTypes(node) {
|
|
8320
8442
|
const results1 = [];
|
|
8321
|
-
for (let ref17 = gatherRecursiveAll(node, ($
|
|
8443
|
+
for (let ref17 = gatherRecursiveAll(node, ($10) => $10.type === "TypeUnary"), i8 = 0, len7 = ref17.length; i8 < len7; i8++) {
|
|
8322
8444
|
const unary = ref17[i8];
|
|
8323
8445
|
let suffixIndex = unary.suffix.length - 1;
|
|
8324
8446
|
const results2 = [];
|
|
@@ -8446,7 +8568,7 @@ function processTypes(node) {
|
|
|
8446
8568
|
return results1;
|
|
8447
8569
|
}
|
|
8448
8570
|
function processStatementExpressions(statements) {
|
|
8449
|
-
for (let ref19 = gatherRecursiveAll(statements, ($
|
|
8571
|
+
for (let ref19 = gatherRecursiveAll(statements, ($11) => $11.type === "StatementExpression"), i9 = 0, len8 = ref19.length; i9 < len8; i9++) {
|
|
8450
8572
|
const exp = ref19[i9];
|
|
8451
8573
|
const { maybe, statement } = exp;
|
|
8452
8574
|
if ((maybe || statement.type === "ThrowStatement") && blockContainingStatement(exp)) {
|
|
@@ -8594,11 +8716,11 @@ function processBreaksContinues(statements) {
|
|
|
8594
8716
|
}
|
|
8595
8717
|
}
|
|
8596
8718
|
function processCoffeeClasses(statements) {
|
|
8597
|
-
for (let ref23 = gatherRecursiveAll(statements, ($
|
|
8719
|
+
for (let ref23 = gatherRecursiveAll(statements, ($12) => $12.type === "ClassExpression"), i11 = 0, len10 = ref23.length; i11 < len10; i11++) {
|
|
8598
8720
|
const ce = ref23[i11];
|
|
8599
8721
|
const { expressions } = ce.body;
|
|
8600
8722
|
const indent = expressions[0]?.[0] ?? "\n";
|
|
8601
|
-
const autoBinds = expressions.filter(($
|
|
8723
|
+
const autoBinds = expressions.filter(($13) => $13[1]?.autoBind);
|
|
8602
8724
|
if (autoBinds.length) {
|
|
8603
8725
|
let construct;
|
|
8604
8726
|
for (const [, c] of expressions) {
|
|
@@ -8647,17 +8769,17 @@ function processCoffeeClasses(statements) {
|
|
|
8647
8769
|
})()
|
|
8648
8770
|
);
|
|
8649
8771
|
}
|
|
8650
|
-
const public_static_function_assignments = expressions.filter(($
|
|
8772
|
+
const public_static_function_assignments = expressions.filter(($14) => $14[1]?.type === "CoffeeClassPublic" && $14[1].assignment?.expression?.type === "FunctionExpression").map(($15) => $15[1].assignment);
|
|
8651
8773
|
for (const public_static_function_assignment of public_static_function_assignments) {
|
|
8652
8774
|
const id = public_static_function_assignment.lhs[0][1];
|
|
8653
8775
|
replaceNode(public_static_function_assignment, convertFunctionToMethod(id, public_static_function_assignment.expression));
|
|
8654
8776
|
}
|
|
8655
|
-
const public_static_arrow_function_assignments = expressions.filter(($
|
|
8777
|
+
const public_static_arrow_function_assignments = expressions.filter(($16) => $16[1]?.type === "CoffeeClassPublic" && $16[1].assignment?.expression?.type === "ArrowFunction").map(($17) => $17[1].assignment);
|
|
8656
8778
|
for (const public_static_arrow_function_assignment of public_static_arrow_function_assignments) {
|
|
8657
8779
|
const id = public_static_arrow_function_assignment.lhs[0][1];
|
|
8658
8780
|
replaceNode(public_static_arrow_function_assignment, convertArrowFunctionToMethod(id, public_static_arrow_function_assignment.expression));
|
|
8659
8781
|
}
|
|
8660
|
-
const privates = expressions.filter(($
|
|
8782
|
+
const privates = expressions.filter(($18) => $18[1]?.type === "CoffeeClassPrivate");
|
|
8661
8783
|
if (!privates.length) {
|
|
8662
8784
|
continue;
|
|
8663
8785
|
}
|
|
@@ -8722,7 +8844,7 @@ function processProgram(root) {
|
|
|
8722
8844
|
root.topLevelYield ? "*" : void 0
|
|
8723
8845
|
);
|
|
8724
8846
|
statements = [["", rootIIFE]];
|
|
8725
|
-
root.children = root.children.map(($
|
|
8847
|
+
root.children = root.children.map(($19) => $19 === root.expressions ? statements : $19);
|
|
8726
8848
|
root.expressions = statements;
|
|
8727
8849
|
}
|
|
8728
8850
|
hoistRefDecs(statements);
|
|
@@ -8753,9 +8875,9 @@ async function processProgramAsync(root) {
|
|
|
8753
8875
|
await processComptime(statements);
|
|
8754
8876
|
}
|
|
8755
8877
|
function processRepl(root, rootIIFE) {
|
|
8756
|
-
const topBlock = gatherRecursive(rootIIFE, ($
|
|
8878
|
+
const topBlock = gatherRecursive(rootIIFE, ($20) => $20.type === "BlockStatement")[0];
|
|
8757
8879
|
let i = 0;
|
|
8758
|
-
for (let ref24 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8880
|
+
for (let ref24 = gatherRecursiveWithinFunction(topBlock, ($21) => $21.type === "Declaration"), i14 = 0, len12 = ref24.length; i14 < len12; i14++) {
|
|
8759
8881
|
const decl = ref24[i14];
|
|
8760
8882
|
if (!decl.names?.length) {
|
|
8761
8883
|
continue;
|
|
@@ -8769,7 +8891,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8769
8891
|
root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
|
|
8770
8892
|
}
|
|
8771
8893
|
}
|
|
8772
|
-
for (let ref25 = gatherRecursive(topBlock, ($
|
|
8894
|
+
for (let ref25 = gatherRecursive(topBlock, ($22) => $22.type === "FunctionExpression"), i15 = 0, len13 = ref25.length; i15 < len13; i15++) {
|
|
8773
8895
|
const func = ref25[i15];
|
|
8774
8896
|
if (func.name && func.parent?.type === "BlockStatement") {
|
|
8775
8897
|
if (func.parent === topBlock) {
|
|
@@ -8782,7 +8904,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8782
8904
|
}
|
|
8783
8905
|
}
|
|
8784
8906
|
}
|
|
8785
|
-
for (let ref26 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8907
|
+
for (let ref26 = gatherRecursiveWithinFunction(topBlock, ($23) => $23.type === "ClassExpression"), i16 = 0, len14 = ref26.length; i16 < len14; i16++) {
|
|
8786
8908
|
const classExp = ref26[i16];
|
|
8787
8909
|
let m8;
|
|
8788
8910
|
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)) {
|
|
@@ -8794,7 +8916,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8794
8916
|
function processPlaceholders(statements) {
|
|
8795
8917
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
8796
8918
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
8797
|
-
for (let ref27 = gatherRecursiveAll(statements, ($
|
|
8919
|
+
for (let ref27 = gatherRecursiveAll(statements, ($24) => $24.type === "Placeholder"), i17 = 0, len15 = ref27.length; i17 < len15; i17++) {
|
|
8798
8920
|
const exp = ref27[i17];
|
|
8799
8921
|
let ancestor;
|
|
8800
8922
|
if (exp.subtype === ".") {
|
|
@@ -9079,7 +9201,7 @@ function typeOfJSXFragment(node, config2) {
|
|
|
9079
9201
|
if (type.length === 1) {
|
|
9080
9202
|
return type[0];
|
|
9081
9203
|
} else {
|
|
9082
|
-
type = type.flatMap(($
|
|
9204
|
+
type = type.flatMap(($25) => [$25, ", "]);
|
|
9083
9205
|
type.pop();
|
|
9084
9206
|
return ["[", type, "]"];
|
|
9085
9207
|
}
|
|
@@ -9119,12 +9241,16 @@ var grammar = {
|
|
|
9119
9241
|
CommaDelimiter,
|
|
9120
9242
|
OptionalCommaDelimiter,
|
|
9121
9243
|
ArgumentList,
|
|
9244
|
+
PostfixedArgumentList,
|
|
9122
9245
|
NestedArguments,
|
|
9123
9246
|
NestedArgumentList,
|
|
9124
9247
|
NestedArgument,
|
|
9125
9248
|
SingleLineArgumentExpressions,
|
|
9126
9249
|
WArgumentPart,
|
|
9250
|
+
SingleLinePostfixedArgumentExpressions,
|
|
9251
|
+
WPostfixedArgumentPart,
|
|
9127
9252
|
ArgumentPart,
|
|
9253
|
+
PostfixedArgumentPart,
|
|
9128
9254
|
BinaryOpExpression,
|
|
9129
9255
|
BinaryOpNotDedented,
|
|
9130
9256
|
BinaryOpRHS,
|
|
@@ -9144,6 +9270,7 @@ var grammar = {
|
|
|
9144
9270
|
Tuple,
|
|
9145
9271
|
NWTypePostfix,
|
|
9146
9272
|
UpdateExpression,
|
|
9273
|
+
UpdateExpressionPattern,
|
|
9147
9274
|
UpdateExpressionSymbol,
|
|
9148
9275
|
AssignmentExpression,
|
|
9149
9276
|
NonPipelineAssignmentExpression,
|
|
@@ -9279,7 +9406,7 @@ var grammar = {
|
|
|
9279
9406
|
OperatorPrecedence,
|
|
9280
9407
|
OperatorAssociativity,
|
|
9281
9408
|
ThinArrowFunction,
|
|
9282
|
-
|
|
9409
|
+
ThinArrow,
|
|
9283
9410
|
ExplicitBlock,
|
|
9284
9411
|
EmptyBracedContent,
|
|
9285
9412
|
ImplicitNestedBlock,
|
|
@@ -9506,6 +9633,7 @@ var grammar = {
|
|
|
9506
9633
|
Debugger,
|
|
9507
9634
|
MaybeNestedNonPipelineExpression,
|
|
9508
9635
|
MaybeNestedPostfixedExpression,
|
|
9636
|
+
MaybeNestedPostfixedCommaExpression,
|
|
9509
9637
|
NestedPostfixedExpressionNoTrailing,
|
|
9510
9638
|
MaybeNestedExpression,
|
|
9511
9639
|
MaybeParenNestedExpression,
|
|
@@ -10263,7 +10391,7 @@ var $R71 = (0, import_lib2.$R)(new RegExp("#(?!##(?!#))([^\\r\\n]*)", "suy"));
|
|
|
10263
10391
|
var $R72 = (0, import_lib2.$R)(new RegExp("[^]*?###", "suy"));
|
|
10264
10392
|
var $R73 = (0, import_lib2.$R)(new RegExp("###(?!#)", "suy"));
|
|
10265
10393
|
var $R74 = (0, import_lib2.$R)(new RegExp("\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\/", "suy"));
|
|
10266
|
-
var $R75 = (0, import_lib2.$R)(new RegExp("(?=[ \\t
|
|
10394
|
+
var $R75 = (0, import_lib2.$R)(new RegExp("(?=[ \\t\\/\\\\#])", "suy"));
|
|
10267
10395
|
var $R76 = (0, import_lib2.$R)(new RegExp("(?=\\s|\\/|#)", "suy"));
|
|
10268
10396
|
var $R77 = (0, import_lib2.$R)(new RegExp("(?!\\p{ID_Continue})", "suy"));
|
|
10269
10397
|
var $R78 = (0, import_lib2.$R)(new RegExp("[=:]", "suy"));
|
|
@@ -10521,7 +10649,7 @@ var ImplicitArguments$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(ApplicationSt
|
|
|
10521
10649
|
function ImplicitArguments(ctx, state2) {
|
|
10522
10650
|
return (0, import_lib2.$EVENT)(ctx, state2, "ImplicitArguments", ImplicitArguments$0);
|
|
10523
10651
|
}
|
|
10524
|
-
var ExplicitArguments$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(
|
|
10652
|
+
var ExplicitArguments$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(PostfixedArgumentList, (0, import_lib2.$E)((0, import_lib2.$S)(__, Comma)))), __, RestoreAll, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
10525
10653
|
var open = $1;
|
|
10526
10654
|
var args = $3;
|
|
10527
10655
|
var ws = $4;
|
|
@@ -10659,6 +10787,35 @@ var ArgumentList$$ = [ArgumentList$0, ArgumentList$1, ArgumentList$2];
|
|
|
10659
10787
|
function ArgumentList(ctx, state2) {
|
|
10660
10788
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "ArgumentList", ArgumentList$$);
|
|
10661
10789
|
}
|
|
10790
|
+
var PostfixedArgumentList$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(EOS), PostfixedArgumentPart, (0, import_lib2.$Q)((0, import_lib2.$S)(CommaDelimiter, (0, import_lib2.$N)(EOS), (0, import_lib2.$E)(_), PostfixedArgumentPart)), (0, import_lib2.$S)(CommaDelimiter, NestedArguments), (0, import_lib2.$Q)((0, import_lib2.$S)(OptionalCommaDelimiter, NestedArguments))), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
10791
|
+
return [
|
|
10792
|
+
$2,
|
|
10793
|
+
...$3.flatMap(([comma, eos, ws, arg]) => [comma, prepend(ws, arg)]),
|
|
10794
|
+
...Array.isArray($4[1]) ? [$4[0], ...$4[1]] : $4,
|
|
10795
|
+
...$5.flatMap(
|
|
10796
|
+
([comma, args]) => Array.isArray(args) ? [comma, ...args] : [comma, args]
|
|
10797
|
+
)
|
|
10798
|
+
];
|
|
10799
|
+
});
|
|
10800
|
+
var PostfixedArgumentList$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(NestedArguments, (0, import_lib2.$Q)((0, import_lib2.$S)(OptionalCommaDelimiter, NestedArguments))), function($skip, $loc, $0, $1, $2) {
|
|
10801
|
+
if (!Array.isArray($1)) $1 = [$1];
|
|
10802
|
+
return [
|
|
10803
|
+
...trimFirstSpace($1),
|
|
10804
|
+
...$2.flatMap(
|
|
10805
|
+
([comma, args]) => Array.isArray(args) ? [comma, ...args] : [comma, args]
|
|
10806
|
+
)
|
|
10807
|
+
];
|
|
10808
|
+
});
|
|
10809
|
+
var PostfixedArgumentList$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixedArgumentPart, (0, import_lib2.$Q)((0, import_lib2.$S)(CommaDelimiter, (0, import_lib2.$E)(_), PostfixedArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
|
|
10810
|
+
return [
|
|
10811
|
+
prepend($1, $2),
|
|
10812
|
+
...$3.flatMap(([comma, ws, arg]) => [comma, prepend(ws, arg)])
|
|
10813
|
+
];
|
|
10814
|
+
});
|
|
10815
|
+
var PostfixedArgumentList$$ = [PostfixedArgumentList$0, PostfixedArgumentList$1, PostfixedArgumentList$2];
|
|
10816
|
+
function PostfixedArgumentList(ctx, state2) {
|
|
10817
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedArgumentList", PostfixedArgumentList$$);
|
|
10818
|
+
}
|
|
10662
10819
|
var NestedArguments$0 = NestedBulletedArray;
|
|
10663
10820
|
var NestedArguments$1 = NestedImplicitObjectLiteral;
|
|
10664
10821
|
var NestedArguments$2 = NestedArgumentList;
|
|
@@ -10674,7 +10831,7 @@ var NestedArgumentList$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(PushIndent,
|
|
|
10674
10831
|
function NestedArgumentList(ctx, state2) {
|
|
10675
10832
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedArgumentList", NestedArgumentList$0);
|
|
10676
10833
|
}
|
|
10677
|
-
var NestedArgument$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NestedImplicitPropertyDefinition), Nested, (0, import_lib2.$N)(Bullet),
|
|
10834
|
+
var NestedArgument$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NestedImplicitPropertyDefinition), Nested, (0, import_lib2.$N)(Bullet), SingleLinePostfixedArgumentExpressions, ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
10678
10835
|
var indent = $2;
|
|
10679
10836
|
var args = $4;
|
|
10680
10837
|
var comma = $5;
|
|
@@ -10697,6 +10854,18 @@ var WArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$
|
|
|
10697
10854
|
function WArgumentPart(ctx, state2) {
|
|
10698
10855
|
return (0, import_lib2.$EVENT)(ctx, state2, "WArgumentPart", WArgumentPart$0);
|
|
10699
10856
|
}
|
|
10857
|
+
var SingleLinePostfixedArgumentExpressions$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(WPostfixedArgumentPart, (0, import_lib2.$Q)((0, import_lib2.$S)((0, import_lib2.$S)((0, import_lib2.$E)(_), Comma), WPostfixedArgumentPart))), function($skip, $loc, $0, $1, $2) {
|
|
10858
|
+
return [$1, ...$2.flat()];
|
|
10859
|
+
});
|
|
10860
|
+
function SingleLinePostfixedArgumentExpressions(ctx, state2) {
|
|
10861
|
+
return (0, import_lib2.$EVENT)(ctx, state2, "SingleLinePostfixedArgumentExpressions", SingleLinePostfixedArgumentExpressions$0);
|
|
10862
|
+
}
|
|
10863
|
+
var WPostfixedArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixedArgumentPart), function($skip, $loc, $0, $1, $2) {
|
|
10864
|
+
return prepend($1, $2);
|
|
10865
|
+
});
|
|
10866
|
+
function WPostfixedArgumentPart(ctx, state2) {
|
|
10867
|
+
return (0, import_lib2.$EVENT)(ctx, state2, "WPostfixedArgumentPart", WPostfixedArgumentPart$0);
|
|
10868
|
+
}
|
|
10700
10869
|
var ArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(DotDotDot, Expression), function($skip, $loc, $0, $1, $2) {
|
|
10701
10870
|
var spread = $1;
|
|
10702
10871
|
var expression = $2;
|
|
@@ -10721,6 +10890,30 @@ var ArgumentPart$$ = [ArgumentPart$0, ArgumentPart$1];
|
|
|
10721
10890
|
function ArgumentPart(ctx, state2) {
|
|
10722
10891
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "ArgumentPart", ArgumentPart$$);
|
|
10723
10892
|
}
|
|
10893
|
+
var PostfixedArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(DotDotDot, PostfixedExpression), function($skip, $loc, $0, $1, $2) {
|
|
10894
|
+
var spread = $1;
|
|
10895
|
+
var expression = $2;
|
|
10896
|
+
return {
|
|
10897
|
+
type: "Argument",
|
|
10898
|
+
children: $0,
|
|
10899
|
+
expression,
|
|
10900
|
+
spread
|
|
10901
|
+
};
|
|
10902
|
+
});
|
|
10903
|
+
var PostfixedArgumentPart$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(PostfixedExpression, (0, import_lib2.$E)(DotDotDot)), function($skip, $loc, $0, $1, $2) {
|
|
10904
|
+
var expression = $1;
|
|
10905
|
+
var spread = $2;
|
|
10906
|
+
return {
|
|
10907
|
+
type: "Argument",
|
|
10908
|
+
children: spread ? [spread, expression] : [expression],
|
|
10909
|
+
expression,
|
|
10910
|
+
spread
|
|
10911
|
+
};
|
|
10912
|
+
});
|
|
10913
|
+
var PostfixedArgumentPart$$ = [PostfixedArgumentPart$0, PostfixedArgumentPart$1];
|
|
10914
|
+
function PostfixedArgumentPart(ctx, state2) {
|
|
10915
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedArgumentPart", PostfixedArgumentPart$$);
|
|
10916
|
+
}
|
|
10724
10917
|
var BinaryOpExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(UnaryExpression, (0, import_lib2.$Q)(BinaryOpRHS)), function($skip, $loc, $0, $1, $2) {
|
|
10725
10918
|
if (!$2.length) return $1;
|
|
10726
10919
|
return processBinaryOpExpression($0);
|
|
@@ -10753,10 +10946,13 @@ var BinaryOpRHS$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(BinaryOp, RHS), fun
|
|
|
10753
10946
|
var BinaryOpRHS$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(NewlineBinaryOpAllowed, NotDedentedBinaryOp, WRHS), function($skip, $loc, $0, $1, $2, $3) {
|
|
10754
10947
|
var op = $2;
|
|
10755
10948
|
var rhs = $3;
|
|
10949
|
+
if (op[1].token === ">" && op[0].length === 0) return $skip;
|
|
10756
10950
|
return [...op, ...rhs];
|
|
10757
10951
|
});
|
|
10758
|
-
var BinaryOpRHS$3 = (0, import_lib2.$
|
|
10759
|
-
|
|
10952
|
+
var BinaryOpRHS$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NewlineBinaryOpAllowed), SingleLineBinaryOpRHS), function($skip, $loc, $0, $1, $2) {
|
|
10953
|
+
const [ws1, op] = $2;
|
|
10954
|
+
if (op.token === ">" && !ws1.length) return $skip;
|
|
10955
|
+
return $2;
|
|
10760
10956
|
});
|
|
10761
10957
|
var BinaryOpRHS$$ = [BinaryOpRHS$0, BinaryOpRHS$1, BinaryOpRHS$2, BinaryOpRHS$3];
|
|
10762
10958
|
function BinaryOpRHS(ctx, state2) {
|
|
@@ -10950,6 +11146,12 @@ var UpdateExpression$$ = [UpdateExpression$0, UpdateExpression$1];
|
|
|
10950
11146
|
function UpdateExpression(ctx, state2) {
|
|
10951
11147
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "UpdateExpression", UpdateExpression$$);
|
|
10952
11148
|
}
|
|
11149
|
+
var UpdateExpressionPattern$0 = NamedBindingPattern;
|
|
11150
|
+
var UpdateExpressionPattern$1 = UpdateExpression;
|
|
11151
|
+
var UpdateExpressionPattern$$ = [UpdateExpressionPattern$0, UpdateExpressionPattern$1];
|
|
11152
|
+
function UpdateExpressionPattern(ctx, state2) {
|
|
11153
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "UpdateExpressionPattern", UpdateExpressionPattern$$);
|
|
11154
|
+
}
|
|
10953
11155
|
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) {
|
|
10954
11156
|
return { $loc, token: $1 };
|
|
10955
11157
|
});
|
|
@@ -11013,7 +11215,7 @@ var NonPipelineAssignmentExpressionTail$$ = [NonPipelineAssignmentExpressionTail
|
|
|
11013
11215
|
function NonPipelineAssignmentExpressionTail(ctx, state2) {
|
|
11014
11216
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "NonPipelineAssignmentExpressionTail", NonPipelineAssignmentExpressionTail$$);
|
|
11015
11217
|
}
|
|
11016
|
-
var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented,
|
|
11218
|
+
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) {
|
|
11017
11219
|
$1 = $1.map((x) => [x[0], x[1], ...x[2]]);
|
|
11018
11220
|
$0 = [$1, $2];
|
|
11019
11221
|
return {
|
|
@@ -11030,7 +11232,7 @@ var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib
|
|
|
11030
11232
|
function ActualAssignment(ctx, state2) {
|
|
11031
11233
|
return (0, import_lib2.$EVENT)(ctx, state2, "ActualAssignment", ActualAssignment$0);
|
|
11032
11234
|
}
|
|
11033
|
-
var NonPipelineActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented,
|
|
11235
|
+
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) {
|
|
11034
11236
|
$1 = $1.map((x) => [x[0], x[1], ...x[2]]);
|
|
11035
11237
|
$0 = [$1, $2];
|
|
11036
11238
|
return {
|
|
@@ -11209,8 +11411,14 @@ var PipelineExpressionBody$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Pipeline
|
|
|
11209
11411
|
...rest.map(([nested, line]) => [nested, ...line]).flat()
|
|
11210
11412
|
];
|
|
11211
11413
|
});
|
|
11212
|
-
var PipelineExpressionBody$1 = (0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, Pipe, __, PipelineTailItem))
|
|
11213
|
-
|
|
11414
|
+
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) {
|
|
11415
|
+
return value[1];
|
|
11416
|
+
});
|
|
11417
|
+
var PipelineExpressionBody$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NewlineBinaryOpAllowed), PipelineExpressionBodySameLine), function($skip, $loc, $0, $1, $2) {
|
|
11418
|
+
if (!$2.length) return $skip;
|
|
11419
|
+
return $2;
|
|
11420
|
+
});
|
|
11421
|
+
var PipelineExpressionBody$$ = [PipelineExpressionBody$0, PipelineExpressionBody$1, PipelineExpressionBody$2];
|
|
11214
11422
|
function PipelineExpressionBody(ctx, state2) {
|
|
11215
11423
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PipelineExpressionBody", PipelineExpressionBody$$);
|
|
11216
11424
|
}
|
|
@@ -11241,8 +11449,9 @@ var PipelineTailItem$3 = (0, import_lib2.$TS)((0, import_lib2.$S)(NWTypePostfix,
|
|
|
11241
11449
|
body: [" ", $1, ...$2]
|
|
11242
11450
|
});
|
|
11243
11451
|
});
|
|
11244
|
-
var PipelineTailItem$4 = (0, import_lib2.$
|
|
11245
|
-
return
|
|
11452
|
+
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) {
|
|
11453
|
+
if (!$2) return $skip;
|
|
11454
|
+
return $2;
|
|
11246
11455
|
});
|
|
11247
11456
|
var PipelineTailItem$$ = [PipelineTailItem$0, PipelineTailItem$1, PipelineTailItem$2, PipelineTailItem$3, PipelineTailItem$4];
|
|
11248
11457
|
function PipelineTailItem(ctx, state2) {
|
|
@@ -11698,7 +11907,7 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
|
|
|
11698
11907
|
};
|
|
11699
11908
|
}
|
|
11700
11909
|
});
|
|
11701
|
-
var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly, ClassElementName, (0, import_lib2.$E)(TypeSuffix), __, ConstAssignment,
|
|
11910
|
+
var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly, ClassElementName, (0, import_lib2.$E)(TypeSuffix), __, ConstAssignment, MaybeNestedPostfixedCommaExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
11702
11911
|
var readonly = $1;
|
|
11703
11912
|
var id = $2;
|
|
11704
11913
|
var typeSuffix = $3;
|
|
@@ -11839,9 +12048,8 @@ var LeftHandSideExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impo
|
|
|
11839
12048
|
expression
|
|
11840
12049
|
};
|
|
11841
12050
|
});
|
|
11842
|
-
var LeftHandSideExpression$1 =
|
|
11843
|
-
var LeftHandSideExpression
|
|
11844
|
-
var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1, LeftHandSideExpression$2];
|
|
12051
|
+
var LeftHandSideExpression$1 = CallExpression;
|
|
12052
|
+
var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1];
|
|
11845
12053
|
function LeftHandSideExpression(ctx, state2) {
|
|
11846
12054
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "LeftHandSideExpression", LeftHandSideExpression$$);
|
|
11847
12055
|
}
|
|
@@ -13296,14 +13504,21 @@ var OperatorAssociativity$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impor
|
|
|
13296
13504
|
function OperatorAssociativity(ctx, state2) {
|
|
13297
13505
|
return (0, import_lib2.$EVENT)(ctx, state2, "OperatorAssociativity", OperatorAssociativity$0);
|
|
13298
13506
|
}
|
|
13299
|
-
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)(_),
|
|
13507
|
+
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) {
|
|
13300
13508
|
var async = $1;
|
|
13301
13509
|
var parameters = $2;
|
|
13302
13510
|
var returnType = $3;
|
|
13511
|
+
var ws = $4;
|
|
13303
13512
|
var arrow = $5;
|
|
13304
13513
|
var block = $6;
|
|
13305
13514
|
if (!async) async = [];
|
|
13306
13515
|
const generator = [];
|
|
13516
|
+
if ((!parameters.implicit || returnType || ws) && !block.bare) {
|
|
13517
|
+
const [first, ...rest] = block.children;
|
|
13518
|
+
if (first === " {" || first?.[0]?.token === " ") {
|
|
13519
|
+
block = { ...block, children: [first.slice(1), ...rest] };
|
|
13520
|
+
}
|
|
13521
|
+
}
|
|
13307
13522
|
return {
|
|
13308
13523
|
type: "FunctionExpression",
|
|
13309
13524
|
id: void 0,
|
|
@@ -13328,6 +13543,7 @@ var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
13328
13543
|
generator,
|
|
13329
13544
|
parameters,
|
|
13330
13545
|
returnType,
|
|
13546
|
+
ws,
|
|
13331
13547
|
block
|
|
13332
13548
|
]
|
|
13333
13549
|
};
|
|
@@ -13335,11 +13551,11 @@ var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
13335
13551
|
function ThinArrowFunction(ctx, state2) {
|
|
13336
13552
|
return (0, import_lib2.$EVENT)(ctx, state2, "ThinArrowFunction", ThinArrowFunction$0);
|
|
13337
13553
|
}
|
|
13338
|
-
var
|
|
13554
|
+
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) {
|
|
13339
13555
|
return { $loc, token: "->" };
|
|
13340
13556
|
});
|
|
13341
|
-
function
|
|
13342
|
-
return (0, import_lib2.$EVENT)(ctx, state2, "
|
|
13557
|
+
function ThinArrow(ctx, state2) {
|
|
13558
|
+
return (0, import_lib2.$EVENT)(ctx, state2, "ThinArrow", ThinArrow$0);
|
|
13343
13559
|
}
|
|
13344
13560
|
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) {
|
|
13345
13561
|
var ws1 = $1;
|
|
@@ -15459,26 +15675,37 @@ var PostfixedNoCommaStatement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(NoCom
|
|
|
15459
15675
|
function PostfixedNoCommaStatement(ctx, state2) {
|
|
15460
15676
|
return (0, import_lib2.$EVENT)(ctx, state2, "PostfixedNoCommaStatement", PostfixedNoCommaStatement$0);
|
|
15461
15677
|
}
|
|
15462
|
-
var PostfixedExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
15678
|
+
var PostfixedExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(AssignmentExpressionSpread, (0, import_lib2.$E)(_), (0, import_lib2.$N)(IfClause), PostfixStatement), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
15679
|
+
var expression = $1;
|
|
15680
|
+
var ws = $2;
|
|
15681
|
+
var post = $4;
|
|
15682
|
+
return attachPostfixStatementAsExpression(expression, [ws, post]);
|
|
15683
|
+
});
|
|
15684
|
+
var PostfixedExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, (0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement)), function($skip, $loc, $0, $1, $2) {
|
|
15463
15685
|
var expression = $1;
|
|
15464
15686
|
var post = $2;
|
|
15465
|
-
|
|
15466
|
-
return expression;
|
|
15687
|
+
return attachPostfixStatementAsExpression(expression, post);
|
|
15467
15688
|
});
|
|
15689
|
+
var PostfixedExpression$2 = Expression;
|
|
15690
|
+
var PostfixedExpression$$ = [PostfixedExpression$0, PostfixedExpression$1, PostfixedExpression$2];
|
|
15468
15691
|
function PostfixedExpression(ctx, state2) {
|
|
15469
|
-
return (0, import_lib2.$
|
|
15692
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedExpression", PostfixedExpression$$);
|
|
15470
15693
|
}
|
|
15471
|
-
var PostfixedCommaExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
15694
|
+
var PostfixedCommaExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CommaExpressionSpread, (0, import_lib2.$E)(_), (0, import_lib2.$N)(IfClause), PostfixStatement), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
15695
|
+
var expression = $1;
|
|
15696
|
+
var ws = $2;
|
|
15697
|
+
var post = $4;
|
|
15698
|
+
return attachPostfixStatementAsExpression(expression, [ws, post]);
|
|
15699
|
+
});
|
|
15700
|
+
var PostfixedCommaExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, (0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement)), function($skip, $loc, $0, $1, $2) {
|
|
15472
15701
|
var expression = $1;
|
|
15473
15702
|
var post = $2;
|
|
15474
|
-
|
|
15475
|
-
if (post.length === 2 && !Array.isArray(post[1])) {
|
|
15476
|
-
return attachPostfixStatementAsExpression(expression, post);
|
|
15477
|
-
}
|
|
15478
|
-
return $0;
|
|
15703
|
+
return attachPostfixStatementAsExpression(expression, post);
|
|
15479
15704
|
});
|
|
15705
|
+
var PostfixedCommaExpression$2 = CommaExpression;
|
|
15706
|
+
var PostfixedCommaExpression$$ = [PostfixedCommaExpression$0, PostfixedCommaExpression$1, PostfixedCommaExpression$2];
|
|
15480
15707
|
function PostfixedCommaExpression(ctx, state2) {
|
|
15481
|
-
return (0, import_lib2.$
|
|
15708
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedCommaExpression", PostfixedCommaExpression$$);
|
|
15482
15709
|
}
|
|
15483
15710
|
var PostfixStatement$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R31, "PostfixStatement /(?=for|if|loop|unless|until|while)/"), _PostfixStatement), function(value) {
|
|
15484
15711
|
return value[1];
|
|
@@ -16930,6 +17157,22 @@ var MaybeNestedPostfixedExpression$$ = [MaybeNestedPostfixedExpression$0, MaybeN
|
|
|
16930
17157
|
function MaybeNestedPostfixedExpression(ctx, state2) {
|
|
16931
17158
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "MaybeNestedPostfixedExpression", MaybeNestedPostfixedExpression$$);
|
|
16932
17159
|
}
|
|
17160
|
+
var MaybeNestedPostfixedCommaExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NestedBulletedArray), (0, import_lib2.$N)(NestedImplicitObjectLiteral), PushIndent, (0, import_lib2.$E)((0, import_lib2.$S)(Nested, PostfixedCommaExpression)), PopIndent, (0, import_lib2.$E)(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
17161
|
+
var expression = $4;
|
|
17162
|
+
var trailing = $6;
|
|
17163
|
+
if (!expression) return $skip;
|
|
17164
|
+
if (!trailing) return expression;
|
|
17165
|
+
return [expression, trailing];
|
|
17166
|
+
});
|
|
17167
|
+
var MaybeNestedPostfixedCommaExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidImplicitFragment, (0, import_lib2.$E)(PostfixedCommaExpression), RestoreImplicitFragment), function($skip, $loc, $0, $1, $2, $3) {
|
|
17168
|
+
var expression = $2;
|
|
17169
|
+
if (!expression) return $skip;
|
|
17170
|
+
return expression;
|
|
17171
|
+
});
|
|
17172
|
+
var MaybeNestedPostfixedCommaExpression$$ = [MaybeNestedPostfixedCommaExpression$0, MaybeNestedPostfixedCommaExpression$1];
|
|
17173
|
+
function MaybeNestedPostfixedCommaExpression(ctx, state2) {
|
|
17174
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "MaybeNestedPostfixedCommaExpression", MaybeNestedPostfixedCommaExpression$$);
|
|
17175
|
+
}
|
|
16933
17176
|
var NestedPostfixedExpressionNoTrailing$0 = NestedBulletedArray;
|
|
16934
17177
|
var NestedPostfixedExpressionNoTrailing$1 = NestedImplicitObjectLiteral;
|
|
16935
17178
|
var NestedPostfixedExpressionNoTrailing$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(PushIndent, (0, import_lib2.$E)((0, import_lib2.$S)(Nested, PostfixedExpression)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
|
|
@@ -17380,7 +17623,7 @@ var ExportDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
17380
17623
|
}
|
|
17381
17624
|
];
|
|
17382
17625
|
});
|
|
17383
|
-
var ExportDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), Export, __, Default, __, (0, import_lib2.$C)(HoistableDeclaration, ClassDeclaration, InterfaceDeclaration,
|
|
17626
|
+
var ExportDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), Export, __, Default, __, (0, import_lib2.$C)(HoistableDeclaration, ClassDeclaration, InterfaceDeclaration, MaybeNestedPostfixedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
17384
17627
|
var declaration = $6;
|
|
17385
17628
|
return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
|
|
17386
17629
|
});
|
|
@@ -17503,7 +17746,7 @@ var LexicalDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(LetOrConst,
|
|
|
17503
17746
|
thisAssignments: bindings.flatMap((b) => b.thisAssignments)
|
|
17504
17747
|
};
|
|
17505
17748
|
});
|
|
17506
|
-
var LexicalDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Loc, (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(TypeSuffix), __, (0, import_lib2.$C)(ConstAssignment, LetAssignment),
|
|
17749
|
+
var LexicalDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Loc, (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(TypeSuffix), __, (0, import_lib2.$C)(ConstAssignment, LetAssignment), MaybeNestedPostfixedCommaExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
17507
17750
|
var loc = $1;
|
|
17508
17751
|
var assign = $5;
|
|
17509
17752
|
return processAssignmentDeclaration(
|
|
@@ -17569,7 +17812,7 @@ var LexicalBinding$$ = [LexicalBinding$0, LexicalBinding$1];
|
|
|
17569
17812
|
function LexicalBinding(ctx, state2) {
|
|
17570
17813
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "LexicalBinding", LexicalBinding$$);
|
|
17571
17814
|
}
|
|
17572
|
-
var Initializer$0 = (0, import_lib2.$T)((0, import_lib2.$S)(__, Equals,
|
|
17815
|
+
var Initializer$0 = (0, import_lib2.$T)((0, import_lib2.$S)(__, Equals, MaybeNestedPostfixedExpression), function(value) {
|
|
17573
17816
|
var expression = value[2];
|
|
17574
17817
|
return { "type": "Initializer", "expression": expression, "children": value };
|
|
17575
17818
|
});
|
|
@@ -17997,8 +18240,10 @@ function CoffeeHereCommentStart(ctx, state2) {
|
|
|
17997
18240
|
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) {
|
|
17998
18241
|
return { $loc, token: $0 };
|
|
17999
18242
|
});
|
|
18243
|
+
var InlineComment$1 = CoffeeMultiLineComment;
|
|
18244
|
+
var InlineComment$$ = [InlineComment$0, InlineComment$1];
|
|
18000
18245
|
function InlineComment(ctx, state2) {
|
|
18001
|
-
return (0, import_lib2.$
|
|
18246
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "InlineComment", InlineComment$$);
|
|
18002
18247
|
}
|
|
18003
18248
|
var RestOfLine$0 = (0, import_lib2.$S)((0, import_lib2.$Q)((0, import_lib2.$C)(NonNewlineWhitespace, Comment)), EOL);
|
|
18004
18249
|
function RestOfLine(ctx, state2) {
|
|
@@ -18008,7 +18253,7 @@ var TrailingComment$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_l
|
|
|
18008
18253
|
function TrailingComment(ctx, state2) {
|
|
18009
18254
|
return (0, import_lib2.$EVENT)(ctx, state2, "TrailingComment", TrailingComment$0);
|
|
18010
18255
|
}
|
|
18011
|
-
var _$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R75, "_ /(?=[ \\t
|
|
18256
|
+
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) {
|
|
18012
18257
|
return value[1];
|
|
18013
18258
|
});
|
|
18014
18259
|
function _(ctx, state2) {
|
|
@@ -22177,8 +22422,9 @@ ${counts}`;
|
|
|
22177
22422
|
const code = generate_civet_default(ast2, options);
|
|
22178
22423
|
checkErrors();
|
|
22179
22424
|
if (options.inlineMap) {
|
|
22425
|
+
const outputFilename = options.outputFilename ?? (options.js ? filename2 + ".jsx" : filename2 + ".tsx");
|
|
22180
22426
|
return `${code}
|
|
22181
|
-
${options.sourceMap.comment(filename2,
|
|
22427
|
+
${options.sourceMap.comment(filename2, outputFilename)}`;
|
|
22182
22428
|
} else {
|
|
22183
22429
|
return {
|
|
22184
22430
|
code,
|