@danielx/civet 0.11.1 → 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 +13 -0
- package/dist/browser.js +250 -193
- package/dist/civet +27 -29
- package/dist/main.js +306 -215
- package/dist/main.mjs +306 -215
- 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.mjs
CHANGED
|
@@ -1071,6 +1071,60 @@ function literalType(literal) {
|
|
|
1071
1071
|
children: [t]
|
|
1072
1072
|
};
|
|
1073
1073
|
}
|
|
1074
|
+
function typeOfExpression(expression) {
|
|
1075
|
+
let t;
|
|
1076
|
+
if (!isASTNodeObject(expression)) {
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
switch (expression.type) {
|
|
1080
|
+
case "Literal": {
|
|
1081
|
+
switch (expression.subtype) {
|
|
1082
|
+
case "NullLiteral": {
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
default: {
|
|
1086
|
+
t = literalType(expression);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
;
|
|
1090
|
+
break;
|
|
1091
|
+
}
|
|
1092
|
+
case "RegularExpressionLiteral":
|
|
1093
|
+
case "TemplateLiteral": {
|
|
1094
|
+
t = literalType(expression);
|
|
1095
|
+
break;
|
|
1096
|
+
}
|
|
1097
|
+
case "Identifier": {
|
|
1098
|
+
if (expression.name === "undefined") {
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
case "MemberExpression": {
|
|
1103
|
+
t = {
|
|
1104
|
+
type: "TypeTypeof",
|
|
1105
|
+
children: ["typeof ", expression],
|
|
1106
|
+
expression
|
|
1107
|
+
};
|
|
1108
|
+
break;
|
|
1109
|
+
}
|
|
1110
|
+
default: {
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
return t;
|
|
1115
|
+
}
|
|
1116
|
+
function typeSuffixForExpression(expression) {
|
|
1117
|
+
const t = typeOfExpression(expression);
|
|
1118
|
+
if (!(t != null)) {
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
return {
|
|
1122
|
+
type: "TypeSuffix",
|
|
1123
|
+
ts: true,
|
|
1124
|
+
t,
|
|
1125
|
+
children: [": ", t]
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1074
1128
|
function makeNumericLiteral(n) {
|
|
1075
1129
|
const s = n.toString();
|
|
1076
1130
|
return {
|
|
@@ -1948,11 +2002,14 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1948
2002
|
const results1 = [];
|
|
1949
2003
|
for (let ref7 = pattern.elements, i7 = 0, len6 = ref7.length; i7 < len6; i7++) {
|
|
1950
2004
|
const elem = ref7[i7];
|
|
1951
|
-
let { typeSuffix } = elem;
|
|
2005
|
+
let { typeSuffix, initializer } = elem;
|
|
1952
2006
|
typeSuffix ??= elem.binding?.typeSuffix;
|
|
1953
2007
|
if (typeSuffix) {
|
|
1954
2008
|
count++;
|
|
1955
2009
|
}
|
|
2010
|
+
if (initializer != null) {
|
|
2011
|
+
typeSuffix ??= typeSuffixForExpression(trimFirstSpace(initializer.expression));
|
|
2012
|
+
}
|
|
1956
2013
|
let typeElement = [typeSuffix?.t, elem.delim];
|
|
1957
2014
|
if (typeSuffix?.optional) {
|
|
1958
2015
|
typeElement[0] = parenthesizeType(typeElement[0]);
|
|
@@ -1987,11 +2044,14 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1987
2044
|
const results2 = [];
|
|
1988
2045
|
for (let ref8 = pattern.properties, i8 = 0, len7 = ref8.length; i8 < len7; i8++) {
|
|
1989
2046
|
const prop = ref8[i8];
|
|
1990
|
-
let { typeSuffix } = prop;
|
|
2047
|
+
let { typeSuffix, initializer } = prop;
|
|
1991
2048
|
typeSuffix ??= prop.value?.typeSuffix;
|
|
1992
2049
|
if (typeSuffix) {
|
|
1993
2050
|
count++;
|
|
1994
2051
|
}
|
|
2052
|
+
if (initializer != null) {
|
|
2053
|
+
typeSuffix ??= typeSuffixForExpression(trimFirstSpace(initializer.expression));
|
|
2054
|
+
}
|
|
1995
2055
|
typeSuffix ??= {
|
|
1996
2056
|
type: "TypeSuffix",
|
|
1997
2057
|
ts: true,
|
|
@@ -3092,19 +3152,23 @@ function patternBindings(pattern) {
|
|
|
3092
3152
|
function assignResults(node, collect) {
|
|
3093
3153
|
if (!node) return;
|
|
3094
3154
|
switch (node.type) {
|
|
3095
|
-
case "BlockStatement":
|
|
3155
|
+
case "BlockStatement": {
|
|
3096
3156
|
if (node.expressions.length) {
|
|
3097
3157
|
let ref5;
|
|
3098
3158
|
assignResults((ref5 = node.expressions)[ref5.length - 1], collect);
|
|
3099
3159
|
} else {
|
|
3100
3160
|
node.expressions.push(["", collect("void 0"), ";"]);
|
|
3161
|
+
updateParentPointers(node);
|
|
3101
3162
|
}
|
|
3102
3163
|
return;
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3164
|
+
}
|
|
3165
|
+
case "CaseBlock": {
|
|
3166
|
+
for (let ref6 = node.clauses, i4 = 0, len3 = ref6.length; i4 < len3; i4++) {
|
|
3167
|
+
const clause = ref6[i4];
|
|
3168
|
+
assignResults(clause, collect);
|
|
3169
|
+
}
|
|
3107
3170
|
return;
|
|
3171
|
+
}
|
|
3108
3172
|
case "WhenClause":
|
|
3109
3173
|
case "DefaultClause":
|
|
3110
3174
|
case "PatternClause": {
|
|
@@ -3130,7 +3194,8 @@ function assignResults(node, collect) {
|
|
|
3130
3194
|
if (exp.type === "LabelledStatement") {
|
|
3131
3195
|
exp = exp.statement;
|
|
3132
3196
|
}
|
|
3133
|
-
let
|
|
3197
|
+
let ref7;
|
|
3198
|
+
let ref8;
|
|
3134
3199
|
let m1;
|
|
3135
3200
|
switch (exp.type) {
|
|
3136
3201
|
case "BreakStatement":
|
|
@@ -3142,18 +3207,19 @@ function assignResults(node, collect) {
|
|
|
3142
3207
|
return;
|
|
3143
3208
|
}
|
|
3144
3209
|
case "Declaration": {
|
|
3145
|
-
let
|
|
3210
|
+
let ref9;
|
|
3146
3211
|
if (exp.bindings?.length) {
|
|
3147
|
-
|
|
3212
|
+
ref9 = patternAsValue((ref7 = exp.bindings)[ref7.length - 1].pattern);
|
|
3148
3213
|
} else {
|
|
3149
|
-
|
|
3214
|
+
ref9 = "void 0";
|
|
3150
3215
|
}
|
|
3151
3216
|
;
|
|
3152
|
-
const value =
|
|
3217
|
+
const value = ref9;
|
|
3153
3218
|
exp.children.push([
|
|
3154
3219
|
"",
|
|
3155
3220
|
[";", collect(value)]
|
|
3156
3221
|
]);
|
|
3222
|
+
updateParentPointers(exp);
|
|
3157
3223
|
return;
|
|
3158
3224
|
}
|
|
3159
3225
|
case "FunctionExpression": {
|
|
@@ -3162,6 +3228,7 @@ function assignResults(node, collect) {
|
|
|
3162
3228
|
"",
|
|
3163
3229
|
[";", collect(exp.id)]
|
|
3164
3230
|
]);
|
|
3231
|
+
updateParentPointers(exp);
|
|
3165
3232
|
return;
|
|
3166
3233
|
}
|
|
3167
3234
|
break;
|
|
@@ -3177,7 +3244,7 @@ function assignResults(node, collect) {
|
|
|
3177
3244
|
if (exp.expressions.some(isExit)) {
|
|
3178
3245
|
return;
|
|
3179
3246
|
}
|
|
3180
|
-
assignResults(exp.expressions[
|
|
3247
|
+
assignResults((ref8 = exp.expressions)[ref8.length - 1], collect);
|
|
3181
3248
|
return;
|
|
3182
3249
|
}
|
|
3183
3250
|
case "IfStatement": {
|
|
@@ -3187,6 +3254,7 @@ function assignResults(node, collect) {
|
|
|
3187
3254
|
} else {
|
|
3188
3255
|
braceBlock(exp.then);
|
|
3189
3256
|
exp.children.push([" else {", collect("void 0"), "}"]);
|
|
3257
|
+
updateParentPointers(exp);
|
|
3190
3258
|
}
|
|
3191
3259
|
return;
|
|
3192
3260
|
}
|
|
@@ -3195,15 +3263,15 @@ function assignResults(node, collect) {
|
|
|
3195
3263
|
return;
|
|
3196
3264
|
}
|
|
3197
3265
|
case "SwitchStatement": {
|
|
3198
|
-
for (let
|
|
3199
|
-
const clause =
|
|
3266
|
+
for (let ref10 = exp.caseBlock.clauses, i5 = 0, len4 = ref10.length; i5 < len4; i5++) {
|
|
3267
|
+
const clause = ref10[i5];
|
|
3200
3268
|
assignResults(clause, collect);
|
|
3201
3269
|
}
|
|
3202
3270
|
return;
|
|
3203
3271
|
}
|
|
3204
3272
|
case "TryStatement": {
|
|
3205
|
-
for (let
|
|
3206
|
-
const block =
|
|
3273
|
+
for (let ref11 = exp.blocks, i6 = 0, len5 = ref11.length; i6 < len5; i6++) {
|
|
3274
|
+
const block = ref11[i6];
|
|
3207
3275
|
assignResults(block, collect);
|
|
3208
3276
|
}
|
|
3209
3277
|
return;
|
|
@@ -3215,6 +3283,7 @@ function assignResults(node, collect) {
|
|
|
3215
3283
|
const semi2 = exp.children.lastIndexOf(";");
|
|
3216
3284
|
if (0 <= semi2 && semi2 < exp.children.length - 1) {
|
|
3217
3285
|
exp.children.splice(semi2 + 1, 1 / 0, ...[collect(exp.children.slice(semi2 + 1))]);
|
|
3286
|
+
updateParentPointers(exp);
|
|
3218
3287
|
return;
|
|
3219
3288
|
}
|
|
3220
3289
|
;
|
|
@@ -3224,7 +3293,11 @@ function assignResults(node, collect) {
|
|
|
3224
3293
|
if (node[node.length - 1]?.type === "SemicolonDelimiter") {
|
|
3225
3294
|
return;
|
|
3226
3295
|
}
|
|
3296
|
+
const parent = node[1].parent;
|
|
3227
3297
|
node[1] = collect(node[1]);
|
|
3298
|
+
if (parent != null) {
|
|
3299
|
+
updateParentPointers(parent);
|
|
3300
|
+
}
|
|
3228
3301
|
}
|
|
3229
3302
|
function insertReturn(node) {
|
|
3230
3303
|
if (!node) return;
|
|
@@ -3255,9 +3328,9 @@ function insertReturn(node) {
|
|
|
3255
3328
|
insertReturn(node.block);
|
|
3256
3329
|
if (!isExit(node.block)) {
|
|
3257
3330
|
const comment = hasTrailingComment(node.block.expressions);
|
|
3258
|
-
let
|
|
3331
|
+
let ref12;
|
|
3259
3332
|
node.block.expressions.push([
|
|
3260
|
-
comment ? (
|
|
3333
|
+
comment ? (ref12 = node.block.expressions)[ref12.length - 1][0] || "\n" : "",
|
|
3261
3334
|
wrapWithReturn(void 0, node, !comment)
|
|
3262
3335
|
]);
|
|
3263
3336
|
}
|
|
@@ -3283,7 +3356,7 @@ function insertReturn(node) {
|
|
|
3283
3356
|
if (exp.type === "LabelledStatement") {
|
|
3284
3357
|
exp = exp.statement;
|
|
3285
3358
|
}
|
|
3286
|
-
let
|
|
3359
|
+
let ref13;
|
|
3287
3360
|
let m3;
|
|
3288
3361
|
switch (exp.type) {
|
|
3289
3362
|
case "BreakStatement":
|
|
@@ -3295,14 +3368,14 @@ function insertReturn(node) {
|
|
|
3295
3368
|
return;
|
|
3296
3369
|
}
|
|
3297
3370
|
case "Declaration": {
|
|
3298
|
-
let
|
|
3371
|
+
let ref14;
|
|
3299
3372
|
if (exp.bindings?.length) {
|
|
3300
|
-
|
|
3373
|
+
ref14 = [" ", patternAsValue((ref13 = exp.bindings)[ref13.length - 1].pattern)];
|
|
3301
3374
|
} else {
|
|
3302
|
-
|
|
3375
|
+
ref14 = [];
|
|
3303
3376
|
}
|
|
3304
3377
|
;
|
|
3305
|
-
const value =
|
|
3378
|
+
const value = ref14;
|
|
3306
3379
|
const parent = outer.parent;
|
|
3307
3380
|
const index = findChildIndex(parent?.expressions, outer);
|
|
3308
3381
|
assert.notEqual(index, -1, "Could not find declaration in parent");
|
|
@@ -3362,15 +3435,15 @@ function insertReturn(node) {
|
|
|
3362
3435
|
return;
|
|
3363
3436
|
}
|
|
3364
3437
|
case "SwitchStatement": {
|
|
3365
|
-
for (let
|
|
3366
|
-
const clause =
|
|
3438
|
+
for (let ref15 = exp.caseBlock.clauses, i7 = 0, len6 = ref15.length; i7 < len6; i7++) {
|
|
3439
|
+
const clause = ref15[i7];
|
|
3367
3440
|
insertReturn(clause);
|
|
3368
3441
|
}
|
|
3369
3442
|
return;
|
|
3370
3443
|
}
|
|
3371
3444
|
case "TryStatement": {
|
|
3372
|
-
for (let
|
|
3373
|
-
const block =
|
|
3445
|
+
for (let ref16 = exp.blocks, i8 = 0, len7 = ref16.length; i8 < len7; i8++) {
|
|
3446
|
+
const block = ref16[i8];
|
|
3374
3447
|
insertReturn(block);
|
|
3375
3448
|
}
|
|
3376
3449
|
return;
|
|
@@ -3622,9 +3695,9 @@ function iterationDefaultBody(statement) {
|
|
|
3622
3695
|
}
|
|
3623
3696
|
const reduction = statement.type === "ForStatement" && statement.reduction;
|
|
3624
3697
|
function fillBlock(expression) {
|
|
3625
|
-
let
|
|
3698
|
+
let ref17;
|
|
3626
3699
|
let m5;
|
|
3627
|
-
if (m5 = (
|
|
3700
|
+
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) {
|
|
3628
3701
|
block.expressions.pop();
|
|
3629
3702
|
}
|
|
3630
3703
|
block.expressions.push(expression);
|
|
@@ -3694,8 +3767,8 @@ function processParams(f) {
|
|
|
3694
3767
|
function append2(p) {
|
|
3695
3768
|
(rest ? after : before).push(p);
|
|
3696
3769
|
}
|
|
3697
|
-
for (let
|
|
3698
|
-
const param =
|
|
3770
|
+
for (let ref18 = parameters.parameters, i9 = 0, len8 = ref18.length; i9 < len8; i9++) {
|
|
3771
|
+
const param = ref18[i9];
|
|
3699
3772
|
switch (param.type) {
|
|
3700
3773
|
case "ThisType": {
|
|
3701
3774
|
if (tt) {
|
|
@@ -3707,8 +3780,8 @@ function processParams(f) {
|
|
|
3707
3780
|
} else {
|
|
3708
3781
|
tt = trimFirstSpace(param);
|
|
3709
3782
|
if (before.length || rest) {
|
|
3710
|
-
let
|
|
3711
|
-
let delim = (
|
|
3783
|
+
let ref19;
|
|
3784
|
+
let delim = (ref19 = tt.children)[ref19.length - 1];
|
|
3712
3785
|
if (Array.isArray(delim)) {
|
|
3713
3786
|
delim = delim[delim.length - 1];
|
|
3714
3787
|
}
|
|
@@ -3900,14 +3973,14 @@ function processParams(f) {
|
|
|
3900
3973
|
index2--;
|
|
3901
3974
|
}
|
|
3902
3975
|
const fStatement = classExpressions[index2];
|
|
3903
|
-
for (let
|
|
3904
|
-
const parameter =
|
|
3976
|
+
for (let ref20 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i10 = 0, len9 = ref20.length; i10 < len9; i10++) {
|
|
3977
|
+
const parameter = ref20[i10];
|
|
3905
3978
|
const { accessModifier } = parameter;
|
|
3906
3979
|
if (!(accessModifier || parameter.typeSuffix)) {
|
|
3907
3980
|
continue;
|
|
3908
3981
|
}
|
|
3909
|
-
for (let
|
|
3910
|
-
const binding =
|
|
3982
|
+
for (let ref21 = gatherRecursive(parameter, ($15) => $15.type === "AtBinding"), i11 = 0, len10 = ref21.length; i11 < len10; i11++) {
|
|
3983
|
+
const binding = ref21[i11];
|
|
3911
3984
|
const typeSuffix = binding.parent?.typeSuffix;
|
|
3912
3985
|
if (!(accessModifier || typeSuffix)) {
|
|
3913
3986
|
continue;
|
|
@@ -3945,8 +4018,8 @@ function processParams(f) {
|
|
|
3945
4018
|
decl: "const"
|
|
3946
4019
|
}));
|
|
3947
4020
|
}
|
|
3948
|
-
for (let
|
|
3949
|
-
const binding =
|
|
4021
|
+
for (let ref22 = splices, i12 = 0, len11 = ref22.length; i12 < len11; i12++) {
|
|
4022
|
+
const binding = ref22[i12];
|
|
3950
4023
|
assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding");
|
|
3951
4024
|
prefix.push(makeNode({
|
|
3952
4025
|
type: "Declaration",
|
|
@@ -3998,8 +4071,8 @@ function processSignature(f) {
|
|
|
3998
4071
|
f.async.push("async ");
|
|
3999
4072
|
signature.modifier.async = true;
|
|
4000
4073
|
} else {
|
|
4001
|
-
for (let
|
|
4002
|
-
const a =
|
|
4074
|
+
for (let ref23 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i13 = 0, len12 = ref23.length; i13 < len12; i13++) {
|
|
4075
|
+
const a = ref23[i13];
|
|
4003
4076
|
const i = findChildIndex(a.parent, a);
|
|
4004
4077
|
a.parent.children.splice(i + 1, 0, {
|
|
4005
4078
|
type: "Error",
|
|
@@ -4013,8 +4086,8 @@ function processSignature(f) {
|
|
|
4013
4086
|
f.generator.push("*");
|
|
4014
4087
|
signature.modifier.generator = true;
|
|
4015
4088
|
} else {
|
|
4016
|
-
for (let
|
|
4017
|
-
const y =
|
|
4089
|
+
for (let ref24 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i14 = 0, len13 = ref24.length; i14 < len13; i14++) {
|
|
4090
|
+
const y = ref24[i14];
|
|
4018
4091
|
const i = y.children.findIndex(($19) => $19.type === "Yield");
|
|
4019
4092
|
y.children.splice(i + 1, 0, {
|
|
4020
4093
|
type: "Error",
|
|
@@ -4032,8 +4105,8 @@ function processSignature(f) {
|
|
|
4032
4105
|
}
|
|
4033
4106
|
}
|
|
4034
4107
|
function processFunctions(statements, config2) {
|
|
4035
|
-
for (let
|
|
4036
|
-
const f =
|
|
4108
|
+
for (let ref25 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
|
|
4109
|
+
const f = ref25[i15];
|
|
4037
4110
|
if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
|
|
4038
4111
|
implicitFunctionBlock(f);
|
|
4039
4112
|
}
|
|
@@ -4092,9 +4165,9 @@ function expressionizeIteration(exp) {
|
|
|
4092
4165
|
}
|
|
4093
4166
|
let done;
|
|
4094
4167
|
if (!async) {
|
|
4095
|
-
let
|
|
4096
|
-
if ((
|
|
4097
|
-
const { block: parentBlock, index } =
|
|
4168
|
+
let ref26;
|
|
4169
|
+
if ((ref26 = blockContainingStatement(exp)) && typeof ref26 === "object" && "block" in ref26 && "index" in ref26) {
|
|
4170
|
+
const { block: parentBlock, index } = ref26;
|
|
4098
4171
|
statements[0][0] = parentBlock.expressions[index][0];
|
|
4099
4172
|
parentBlock.expressions.splice(index, index + 1 - index, ...statements);
|
|
4100
4173
|
updateParentPointers(parentBlock);
|
|
@@ -4111,8 +4184,8 @@ function expressionizeIteration(exp) {
|
|
|
4111
4184
|
}
|
|
4112
4185
|
}
|
|
4113
4186
|
function processIterationExpressions(statements) {
|
|
4114
|
-
for (let
|
|
4115
|
-
const s =
|
|
4187
|
+
for (let ref27 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i16 = 0, len15 = ref27.length; i16 < len15; i16++) {
|
|
4188
|
+
const s = ref27[i16];
|
|
4116
4189
|
expressionizeIteration(s);
|
|
4117
4190
|
}
|
|
4118
4191
|
}
|
|
@@ -4136,12 +4209,12 @@ function processCoffeeDo(ws, expression) {
|
|
|
4136
4209
|
let { parameters } = expression;
|
|
4137
4210
|
const parameterList = parameters.parameters;
|
|
4138
4211
|
const results1 = [];
|
|
4139
|
-
for (let
|
|
4140
|
-
let parameter = parameterList[
|
|
4212
|
+
for (let i17 = 0, len16 = parameterList.length; i17 < len16; i17++) {
|
|
4213
|
+
let parameter = parameterList[i17];
|
|
4141
4214
|
if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
|
|
4142
|
-
let
|
|
4143
|
-
if (
|
|
4144
|
-
const initializer =
|
|
4215
|
+
let ref28;
|
|
4216
|
+
if (ref28 = parameter.initializer) {
|
|
4217
|
+
const initializer = ref28;
|
|
4145
4218
|
args.push(initializer.expression, parameter.delim);
|
|
4146
4219
|
parameter = {
|
|
4147
4220
|
...parameter,
|
|
@@ -4271,8 +4344,9 @@ function unbraceBlock(block) {
|
|
|
4271
4344
|
if (block.bare) {
|
|
4272
4345
|
return;
|
|
4273
4346
|
}
|
|
4347
|
+
let m;
|
|
4274
4348
|
let ref;
|
|
4275
|
-
if (block.children[0] === " {" && (ref = block.children)[ref.length - 1] === "}") {
|
|
4349
|
+
if ((m = block.children[0], m === " {" || m === "{") && (ref = block.children)[ref.length - 1] === "}") {
|
|
4276
4350
|
block.children.shift();
|
|
4277
4351
|
block.children.pop();
|
|
4278
4352
|
block.bare = true;
|
|
@@ -4308,17 +4382,6 @@ function makeEmptyBlock() {
|
|
|
4308
4382
|
empty: true
|
|
4309
4383
|
};
|
|
4310
4384
|
}
|
|
4311
|
-
function makeBlockFragment() {
|
|
4312
|
-
const expressions = [];
|
|
4313
|
-
return {
|
|
4314
|
-
type: "BlockStatement",
|
|
4315
|
-
children: expressions,
|
|
4316
|
-
parent: void 0,
|
|
4317
|
-
expressions,
|
|
4318
|
-
bare: false,
|
|
4319
|
-
root: false
|
|
4320
|
-
};
|
|
4321
|
-
}
|
|
4322
4385
|
function replaceBlockExpression(node, child, replacement) {
|
|
4323
4386
|
let found = false;
|
|
4324
4387
|
const { expressions } = node;
|
|
@@ -4364,22 +4427,44 @@ function hoistRefDecs(statements) {
|
|
|
4364
4427
|
});
|
|
4365
4428
|
}
|
|
4366
4429
|
function insertHoistDec(block, node, dec) {
|
|
4367
|
-
const
|
|
4368
|
-
|
|
4430
|
+
const statement = ["", dec, ";"];
|
|
4431
|
+
insertBeforeInBlock(block, node, statement);
|
|
4432
|
+
}
|
|
4433
|
+
function insertBeforeInBlock(block, node, ...statements) {
|
|
4434
|
+
const index = findChildIndex(block.expressions, node);
|
|
4369
4435
|
if (index < 0) {
|
|
4370
|
-
throw new Error("
|
|
4436
|
+
throw new Error("insertBeforeInBlock couldn't find existing statement in block");
|
|
4437
|
+
}
|
|
4438
|
+
insertBlockStatements(block, index, ...statements);
|
|
4439
|
+
}
|
|
4440
|
+
function insertBlockStatements(block, index, ...statements) {
|
|
4441
|
+
if (!statements.length) {
|
|
4442
|
+
return;
|
|
4443
|
+
}
|
|
4444
|
+
const { expressions } = block;
|
|
4445
|
+
const before = expressions[index];
|
|
4446
|
+
if (statements[0][0] && before?.[0]) {
|
|
4447
|
+
if (!Array.isArray(statements[0][0])) {
|
|
4448
|
+
statements[0][0] = [statements[0][0]];
|
|
4449
|
+
}
|
|
4450
|
+
if (!Array.isArray(before[0])) {
|
|
4451
|
+
before[0] = [before[0]];
|
|
4452
|
+
}
|
|
4453
|
+
statements[0][0] = [...before[0], ...statements[0][0]];
|
|
4454
|
+
} else {
|
|
4455
|
+
statements[0][0] ||= before?.[0];
|
|
4371
4456
|
}
|
|
4372
|
-
|
|
4373
|
-
expressions
|
|
4374
|
-
|
|
4375
|
-
|
|
4457
|
+
before[0] = "";
|
|
4458
|
+
expressions.splice(index, 0, ...statements);
|
|
4459
|
+
updateParentPointers(block);
|
|
4460
|
+
braceBlock(block);
|
|
4376
4461
|
}
|
|
4377
4462
|
function processBlocks(statements) {
|
|
4378
4463
|
insertSemicolon(statements);
|
|
4379
4464
|
for (let ref1 = gatherRecursive(statements, ($) => $.type === "BlockStatement"), i2 = 0, len12 = ref1.length; i2 < len12; i2++) {
|
|
4380
4465
|
const block = ref1[i2];
|
|
4381
|
-
let
|
|
4382
|
-
if (block.unwrapObject && block.expressions.length === 1 && (
|
|
4466
|
+
let m1;
|
|
4467
|
+
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")) {
|
|
4383
4468
|
const object = block.expressions[0][1].expression;
|
|
4384
4469
|
if (!(() => {
|
|
4385
4470
|
let results = true;
|
|
@@ -4398,8 +4483,8 @@ function processBlocks(statements) {
|
|
|
4398
4483
|
for (let ref2 = object.properties, i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
|
|
4399
4484
|
const i = i3;
|
|
4400
4485
|
const prop = ref2[i3];
|
|
4401
|
-
let
|
|
4402
|
-
if (
|
|
4486
|
+
let m2;
|
|
4487
|
+
if (m2 = prop.name, typeof m2 === "object" && m2 != null && "type" in m2 && m2.type === "ComputedPropertyName" && "implicit" in m2 && m2.implicit === true) {
|
|
4403
4488
|
replaceNode(prop.name, prop.name.expression, prop);
|
|
4404
4489
|
}
|
|
4405
4490
|
if (prop.delim?.implicit) {
|
|
@@ -4492,8 +4577,8 @@ function needsPrecedingSemicolon(exp) {
|
|
|
4492
4577
|
function blockContainingStatement(exp) {
|
|
4493
4578
|
let child = exp;
|
|
4494
4579
|
let parent = exp.parent;
|
|
4495
|
-
let
|
|
4496
|
-
while (parent != null && (
|
|
4580
|
+
let m3;
|
|
4581
|
+
while (parent != null && (m3 = parent.type, m3 === "StatementExpression" || m3 === "PipelineExpression" || m3 === "UnwrappedExpression")) {
|
|
4497
4582
|
child = parent;
|
|
4498
4583
|
parent = parent.parent;
|
|
4499
4584
|
}
|
|
@@ -5446,22 +5531,23 @@ function processDeclarations(statements) {
|
|
|
5446
5531
|
if (typeSuffix && typeSuffix.optional) {
|
|
5447
5532
|
if (initializer && !typeSuffix.t) {
|
|
5448
5533
|
const expression = trimFirstSpace(initializer.expression);
|
|
5449
|
-
|
|
5450
|
-
if (
|
|
5451
|
-
typeSuffix.children.push(": ", typeSuffix.t = {
|
|
5452
|
-
type: "TypeTypeof",
|
|
5453
|
-
children: ["typeof ", expression],
|
|
5454
|
-
expression
|
|
5455
|
-
});
|
|
5456
|
-
} else if (expression.type === "Literal" || expression.type === "RegularExpressionLiteral" || expression.type === "TemplateLiteral") {
|
|
5457
|
-
typeSuffix.children.push(": ", typeSuffix.t = literalType(expression));
|
|
5458
|
-
} else {
|
|
5534
|
+
typeSuffix.t = typeOfExpression(expression);
|
|
5535
|
+
if (!(typeSuffix.t != null)) {
|
|
5459
5536
|
spliceChild(binding, typeSuffix, 1, {
|
|
5460
5537
|
type: "Error",
|
|
5461
|
-
message:
|
|
5538
|
+
message: (() => {
|
|
5539
|
+
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "Literal" && "subtype" in expression && expression.subtype === "NullLiteral") {
|
|
5540
|
+
return "Optional type can't be inferred from null";
|
|
5541
|
+
} else if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "Identifier" && "name" in expression && expression.name === "undefined") {
|
|
5542
|
+
return "Optional type can't be inferred from undefined";
|
|
5543
|
+
} else {
|
|
5544
|
+
return `Optional type can only be inferred from literals or member expressions, not ${expression.type}`;
|
|
5545
|
+
}
|
|
5546
|
+
})()
|
|
5462
5547
|
});
|
|
5463
5548
|
continue;
|
|
5464
5549
|
}
|
|
5550
|
+
typeSuffix.children.push(": ", typeSuffix.t);
|
|
5465
5551
|
}
|
|
5466
5552
|
if (typeSuffix.t) {
|
|
5467
5553
|
convertOptionalType(typeSuffix);
|
|
@@ -5502,16 +5588,16 @@ function processDeclarations(statements) {
|
|
|
5502
5588
|
function prependStatementExpressionBlock(initializer, statement) {
|
|
5503
5589
|
let { expression: exp } = initializer;
|
|
5504
5590
|
let ws;
|
|
5505
|
-
if (Array.isArray(exp)) {
|
|
5591
|
+
if (Array.isArray(exp) && exp.length === 2 && isWhitespaceOrEmpty(exp[0])) {
|
|
5506
5592
|
ws = exp[0];
|
|
5507
5593
|
exp = exp[1];
|
|
5508
5594
|
}
|
|
5509
5595
|
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")) {
|
|
5510
5596
|
return;
|
|
5511
5597
|
}
|
|
5512
|
-
const pre = [];
|
|
5513
5598
|
const statementExp = exp.statement;
|
|
5514
5599
|
const blockStatement = [ws || "", statementExp, ";"];
|
|
5600
|
+
const pre = [blockStatement];
|
|
5515
5601
|
let ref;
|
|
5516
5602
|
if (statementExp.type === "IterationExpression") {
|
|
5517
5603
|
if (statementExp.async || statementExp.generator) {
|
|
@@ -5527,8 +5613,7 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5527
5613
|
assignResults(blockStatement, (resultNode) => {
|
|
5528
5614
|
return makeNode({
|
|
5529
5615
|
type: "AssignmentExpression",
|
|
5530
|
-
children: [ref, " = ", resultNode]
|
|
5531
|
-
parent: statement2
|
|
5616
|
+
children: [ref, " = ", resultNode]
|
|
5532
5617
|
});
|
|
5533
5618
|
});
|
|
5534
5619
|
const refDec = {
|
|
@@ -5545,8 +5630,7 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5545
5630
|
assignResults(blockStatement, (resultNode) => {
|
|
5546
5631
|
return makeNode({
|
|
5547
5632
|
type: "AssignmentExpression",
|
|
5548
|
-
children: [ref, " = ", resultNode]
|
|
5549
|
-
parent: statement
|
|
5633
|
+
children: [ref, " = ", resultNode]
|
|
5550
5634
|
});
|
|
5551
5635
|
});
|
|
5552
5636
|
const refDec = {
|
|
@@ -5555,8 +5639,12 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5555
5639
|
};
|
|
5556
5640
|
pre.unshift(["", refDec, ";"]);
|
|
5557
5641
|
}
|
|
5558
|
-
|
|
5559
|
-
|
|
5642
|
+
let ref3;
|
|
5643
|
+
if (!((ref3 = blockContainingStatement(statement)) && typeof ref3 === "object" && "block" in ref3 && "index" in ref3)) {
|
|
5644
|
+
throw new Error("Couldn't find block in prependStatementExpressionBlock");
|
|
5645
|
+
}
|
|
5646
|
+
const { block, index } = ref3;
|
|
5647
|
+
insertBlockStatements(block, index, ...pre);
|
|
5560
5648
|
return ref;
|
|
5561
5649
|
}
|
|
5562
5650
|
function processDeclarationCondition(condition, rootCondition, parent) {
|
|
@@ -5655,8 +5743,8 @@ function processDeclarationConditionStatement(s) {
|
|
|
5655
5743
|
if (conditions.length) {
|
|
5656
5744
|
let children = condition.children;
|
|
5657
5745
|
if (s.negated) {
|
|
5658
|
-
let
|
|
5659
|
-
if (!(
|
|
5746
|
+
let m;
|
|
5747
|
+
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")) {
|
|
5660
5748
|
throw new Error("Unsupported negated condition");
|
|
5661
5749
|
}
|
|
5662
5750
|
;
|
|
@@ -5686,11 +5774,11 @@ function processDeclarationConditionStatement(s) {
|
|
|
5686
5774
|
ancestor.expressions.splice(index + 1, 0, ...blockPrefix);
|
|
5687
5775
|
updateParentPointers(ancestor);
|
|
5688
5776
|
braceBlock(ancestor);
|
|
5689
|
-
let
|
|
5777
|
+
let ref4;
|
|
5690
5778
|
switch (s.type) {
|
|
5691
5779
|
case "IfStatement": {
|
|
5692
|
-
if (
|
|
5693
|
-
const elseBlock =
|
|
5780
|
+
if (ref4 = s.else?.block) {
|
|
5781
|
+
const elseBlock = ref4;
|
|
5694
5782
|
if (elseBlock.bare && !elseBlock.semicolon) {
|
|
5695
5783
|
elseBlock.children.push(elseBlock.semicolon = ";");
|
|
5696
5784
|
}
|
|
@@ -5742,38 +5830,19 @@ function processDeclarationConditionStatement(s) {
|
|
|
5742
5830
|
if (!blockPrefix) {
|
|
5743
5831
|
return;
|
|
5744
5832
|
}
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
expression: ref2,
|
|
5749
|
-
parent: s
|
|
5750
|
-
};
|
|
5751
|
-
s.children = s.children.map(function(c) {
|
|
5752
|
-
if (c === s.condition) {
|
|
5753
|
-
return newCondition;
|
|
5754
|
-
} else {
|
|
5755
|
-
return c;
|
|
5756
|
-
}
|
|
5757
|
-
});
|
|
5758
|
-
s.condition = newCondition;
|
|
5759
|
-
updateParentPointers(s);
|
|
5760
|
-
if (statementDeclaration) {
|
|
5761
|
-
const block = makeEmptyBlock();
|
|
5762
|
-
replaceBlockExpression(s.parent, s, block);
|
|
5763
|
-
block.expressions.push(["", s]);
|
|
5764
|
-
s.children.splice(s.children.findIndex(($5) => $5.token === "switch"), 0, blockPrefix);
|
|
5765
|
-
s.parent = block;
|
|
5766
|
-
} else {
|
|
5767
|
-
const block = blockWithPrefix([["", [{
|
|
5833
|
+
replaceNode(s.condition, parenthesizeExpression(ref2), s);
|
|
5834
|
+
if (!statementDeclaration) {
|
|
5835
|
+
const declStatement = ["", [{
|
|
5768
5836
|
type: "Declaration",
|
|
5769
5837
|
children: ["let ", ...condition.expression.children]
|
|
5770
|
-
}], ";"]
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
;
|
|
5838
|
+
}], ";"];
|
|
5839
|
+
blockPrefix.unshift(declStatement);
|
|
5840
|
+
}
|
|
5841
|
+
const block = blockWithPrefix(blockPrefix, makeEmptyBlock());
|
|
5842
|
+
updateParentPointers(block, s.parent);
|
|
5843
|
+
replaceBlockExpression(s.parent, s, block);
|
|
5844
|
+
block.expressions.push(["", s]);
|
|
5845
|
+
s.parent = block;
|
|
5777
5846
|
break;
|
|
5778
5847
|
}
|
|
5779
5848
|
}
|
|
@@ -5781,12 +5850,12 @@ function processDeclarationConditionStatement(s) {
|
|
|
5781
5850
|
function dynamizeFromClause(from) {
|
|
5782
5851
|
from = from.slice(1);
|
|
5783
5852
|
from = trimFirstSpace(from);
|
|
5784
|
-
let
|
|
5785
|
-
if (
|
|
5786
|
-
const assert2 =
|
|
5787
|
-
let
|
|
5788
|
-
|
|
5789
|
-
|
|
5853
|
+
let ref5;
|
|
5854
|
+
if (ref5 = from[from.length - 1]?.assertion) {
|
|
5855
|
+
const assert2 = ref5;
|
|
5856
|
+
let ref6;
|
|
5857
|
+
ref6 = from[from.length - 1];
|
|
5858
|
+
ref6.children = ref6.children.filter((a2) => a2 !== assert2);
|
|
5790
5859
|
from.push(", {", assert2.keyword, ":", assert2.object, "}");
|
|
5791
5860
|
}
|
|
5792
5861
|
return ["(", ...from, ")"];
|
|
@@ -5795,20 +5864,20 @@ function dynamizeImportDeclaration(decl) {
|
|
|
5795
5864
|
const { imports } = decl;
|
|
5796
5865
|
let { star, binding, specifiers } = imports;
|
|
5797
5866
|
const justDefault = binding && !specifiers && !star;
|
|
5798
|
-
let
|
|
5867
|
+
let ref7;
|
|
5799
5868
|
{
|
|
5800
5869
|
if (binding) {
|
|
5801
5870
|
if (specifiers) {
|
|
5802
|
-
|
|
5871
|
+
ref7 = makeRef();
|
|
5803
5872
|
} else {
|
|
5804
|
-
|
|
5873
|
+
ref7 = binding;
|
|
5805
5874
|
}
|
|
5806
5875
|
} else {
|
|
5807
|
-
|
|
5876
|
+
ref7 = convertNamedImportsToObject(imports, true);
|
|
5808
5877
|
}
|
|
5809
5878
|
}
|
|
5810
5879
|
;
|
|
5811
|
-
const pattern =
|
|
5880
|
+
const pattern = ref7;
|
|
5812
5881
|
const c = "const";
|
|
5813
5882
|
const expression = [
|
|
5814
5883
|
justDefault ? "(" : void 0,
|
|
@@ -6799,7 +6868,7 @@ function processForInOf($0) {
|
|
|
6799
6868
|
var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
|
|
6800
6869
|
function findDecs(statements) {
|
|
6801
6870
|
const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
|
|
6802
|
-
const declarationNames = declarations.flatMap((
|
|
6871
|
+
const declarationNames = declarations.flatMap(($1) => $1.names);
|
|
6803
6872
|
const globals = getConfig().globals || [];
|
|
6804
6873
|
return new Set(globals.concat(declarationNames));
|
|
6805
6874
|
}
|
|
@@ -6807,16 +6876,16 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6807
6876
|
function findVarDecs(statements2, decs) {
|
|
6808
6877
|
const declarationNames = gatherRecursive(statements2, (node) => {
|
|
6809
6878
|
return node.type === "Declaration" && node.children && node.children.length > 0 && node.children[0].token && node.children[0].token.startsWith("var") || node.type === "FunctionExpression";
|
|
6810
|
-
}).filter((
|
|
6879
|
+
}).filter(($2) => $2.type === "Declaration").flatMap(($3) => $3.names);
|
|
6811
6880
|
return new Set(declarationNames);
|
|
6812
6881
|
}
|
|
6813
6882
|
let declaredIdentifiers = findVarDecs(statements);
|
|
6814
6883
|
function hasDec(name) {
|
|
6815
|
-
return declaredIdentifiers.has(name) || scopes.some(($
|
|
6884
|
+
return declaredIdentifiers.has(name) || scopes.some(($4) => $4.has(name));
|
|
6816
6885
|
}
|
|
6817
6886
|
function gatherBlockOrOther(statement) {
|
|
6818
|
-
return gatherNodes(statement, (
|
|
6819
|
-
if (node.type
|
|
6887
|
+
return gatherNodes(statement, ($5) => $5.type === "BlockStatement" || $5.type === "AssignmentExpression" || $5.type === "Declaration").flatMap((node) => {
|
|
6888
|
+
if (node.type === "BlockStatement") {
|
|
6820
6889
|
return node.bare ? gatherBlockOrOther(node.expressions) : node;
|
|
6821
6890
|
} else if (node.children && node.children.length) {
|
|
6822
6891
|
return [...gatherBlockOrOther(node.children), node];
|
|
@@ -6828,16 +6897,18 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6828
6897
|
let currentScope = /* @__PURE__ */ new Set();
|
|
6829
6898
|
scopes.push(currentScope);
|
|
6830
6899
|
const fnNodes = gatherNodes(statements, isFunction);
|
|
6831
|
-
const forNodes = gatherNodes(statements, (
|
|
6900
|
+
const forNodes = gatherNodes(statements, ($6) => $6.type === "ForStatement");
|
|
6832
6901
|
let targetStatements = [];
|
|
6833
|
-
for (
|
|
6902
|
+
for (let i1 = 0, len3 = statements.length; i1 < len3; i1++) {
|
|
6903
|
+
const statement = statements[i1];
|
|
6834
6904
|
const nodes = gatherBlockOrOther(statement);
|
|
6835
6905
|
let undeclaredIdentifiers = [];
|
|
6836
|
-
for (
|
|
6837
|
-
|
|
6906
|
+
for (let i2 = 0, len12 = nodes.length; i2 < len12; i2++) {
|
|
6907
|
+
const node = nodes[i2];
|
|
6908
|
+
if (node.type === "BlockStatement") {
|
|
6838
6909
|
let block = node;
|
|
6839
|
-
let fnNode = fnNodes.find((
|
|
6840
|
-
let forNode = forNodes.find((
|
|
6910
|
+
let fnNode = fnNodes.find(($7) => $7.block === block);
|
|
6911
|
+
let forNode = forNodes.find(($8) => $8.block === block);
|
|
6841
6912
|
if (fnNode != null) {
|
|
6842
6913
|
scopes.push(new Set(fnNode.parameters.names));
|
|
6843
6914
|
createConstLetDecs(block.expressions, scopes, letOrConst);
|
|
@@ -6851,21 +6922,26 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6851
6922
|
}
|
|
6852
6923
|
continue;
|
|
6853
6924
|
}
|
|
6854
|
-
if (node.names
|
|
6855
|
-
|
|
6856
|
-
|
|
6925
|
+
if (!(node.names != null)) {
|
|
6926
|
+
continue;
|
|
6927
|
+
}
|
|
6928
|
+
const names = node.names.filter((name) => !hasDec(name));
|
|
6929
|
+
if (node.type === "AssignmentExpression") {
|
|
6857
6930
|
undeclaredIdentifiers.push(...names);
|
|
6858
6931
|
}
|
|
6859
|
-
names.
|
|
6932
|
+
for (let i3 = 0, len22 = names.length; i3 < len22; i3++) {
|
|
6933
|
+
const name = names[i3];
|
|
6934
|
+
currentScope.add(name);
|
|
6935
|
+
}
|
|
6860
6936
|
}
|
|
6861
|
-
if (undeclaredIdentifiers.length
|
|
6937
|
+
if (undeclaredIdentifiers.length) {
|
|
6862
6938
|
let indent = statement[0];
|
|
6863
|
-
let firstIdentifier = gatherNodes(statement[1], (
|
|
6864
|
-
if (undeclaredIdentifiers.length
|
|
6939
|
+
let firstIdentifier = gatherNodes(statement[1], ($9) => $9.type === "Identifier")[0];
|
|
6940
|
+
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) {
|
|
6865
6941
|
statement[1].children.unshift([`${letOrConst} `]);
|
|
6866
6942
|
} else {
|
|
6867
6943
|
let tail = "\n";
|
|
6868
|
-
if (gatherNodes(indent, (
|
|
6944
|
+
if (gatherNodes(indent, ($11) => $11.token && $11.token.endsWith("\n")).length) {
|
|
6869
6945
|
tail = void 0;
|
|
6870
6946
|
}
|
|
6871
6947
|
targetStatements.push([indent, {
|
|
@@ -6882,17 +6958,17 @@ function createConstLetDecs(statements, scopes, letOrConst) {
|
|
|
6882
6958
|
}
|
|
6883
6959
|
function createVarDecs(block, scopes, pushVar) {
|
|
6884
6960
|
function hasDec(name) {
|
|
6885
|
-
return scopes.some(($
|
|
6961
|
+
return scopes.some(($12) => $12.has(name));
|
|
6886
6962
|
}
|
|
6887
6963
|
function findAssignments(statements2, decs2) {
|
|
6888
|
-
let assignmentStatements2 = gatherNodes(statements2, ($
|
|
6964
|
+
let assignmentStatements2 = gatherNodes(statements2, ($13) => $13.type === "AssignmentExpression");
|
|
6889
6965
|
if (assignmentStatements2.length) {
|
|
6890
6966
|
concatAssign2(
|
|
6891
6967
|
assignmentStatements2,
|
|
6892
6968
|
findAssignments(assignmentStatements2.map((s) => s.children), decs2)
|
|
6893
6969
|
);
|
|
6894
6970
|
}
|
|
6895
|
-
return assignmentStatements2.filter(($
|
|
6971
|
+
return assignmentStatements2.filter(($14) => !($14.parent?.type === "CoffeeClassPublic"));
|
|
6896
6972
|
}
|
|
6897
6973
|
pushVar ??= (name) => {
|
|
6898
6974
|
varIds.push(name);
|
|
@@ -6903,7 +6979,7 @@ function createVarDecs(block, scopes, pushVar) {
|
|
|
6903
6979
|
scopes.push(decs);
|
|
6904
6980
|
const varIds = [];
|
|
6905
6981
|
const assignmentStatements = findAssignments(statements, scopes);
|
|
6906
|
-
const undeclaredIdentifiers = assignmentStatements.flatMap(($
|
|
6982
|
+
const undeclaredIdentifiers = assignmentStatements.flatMap(($15) => $15?.names || []);
|
|
6907
6983
|
undeclaredIdentifiers.filter((x, i, a) => {
|
|
6908
6984
|
if (!hasDec(x)) return a.indexOf(x) === i;
|
|
6909
6985
|
return;
|
|
@@ -8069,24 +8145,20 @@ function processAssignments(statements) {
|
|
|
8069
8145
|
continue;
|
|
8070
8146
|
}
|
|
8071
8147
|
let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
|
|
8072
|
-
let block;
|
|
8073
8148
|
let ref13;
|
|
8074
8149
|
let ref14;
|
|
8075
8150
|
if (blockContainingStatement(exp) && !(ref13 = $1[$1.length - 1])?.[ref13.length - 1]?.special && !isShortCircuitOp((ref14 = $1[$1.length - 1])?.[ref14.length - 1])) {
|
|
8076
|
-
block = makeBlockFragment();
|
|
8077
8151
|
let ref15;
|
|
8078
8152
|
if (ref15 = prependStatementExpressionBlock(
|
|
8079
8153
|
{ type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
|
|
8080
|
-
|
|
8154
|
+
exp
|
|
8081
8155
|
)) {
|
|
8082
8156
|
const ref = ref15;
|
|
8083
|
-
|
|
8157
|
+
replaceNode($2, ref, exp);
|
|
8084
8158
|
$2 = ref;
|
|
8085
|
-
} else {
|
|
8086
|
-
block = void 0;
|
|
8087
8159
|
}
|
|
8088
8160
|
}
|
|
8089
|
-
if ($1.some(($
|
|
8161
|
+
if ($1.some(($7) => $7[$7.length - 1].special)) {
|
|
8090
8162
|
if ($1.length !== 1) throw new Error("Only one assignment with id= is allowed");
|
|
8091
8163
|
const [, lhs, , op] = $1[0];
|
|
8092
8164
|
const { call, omitLhs } = op;
|
|
@@ -8158,7 +8230,7 @@ function processAssignments(statements) {
|
|
|
8158
8230
|
break;
|
|
8159
8231
|
} else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern" || m3 === "NamedBindingPattern") {
|
|
8160
8232
|
processBindingPatternLHS(lhs, tail);
|
|
8161
|
-
gatherRecursiveAll(lhs, ($
|
|
8233
|
+
gatherRecursiveAll(lhs, ($8) => $8.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
|
|
8162
8234
|
}
|
|
8163
8235
|
}
|
|
8164
8236
|
i--;
|
|
@@ -8190,7 +8262,7 @@ function processAssignments(statements) {
|
|
|
8190
8262
|
}
|
|
8191
8263
|
if (refsToDeclare.size) {
|
|
8192
8264
|
if (exp.hoistDec) {
|
|
8193
|
-
exp.hoistDec.children.push([...refsToDeclare].map(($
|
|
8265
|
+
exp.hoistDec.children.push([...refsToDeclare].map(($9) => [",", $9]));
|
|
8194
8266
|
} else {
|
|
8195
8267
|
exp.hoistDec = {
|
|
8196
8268
|
type: "Declaration",
|
|
@@ -8205,11 +8277,6 @@ function processAssignments(statements) {
|
|
|
8205
8277
|
if (index < 0) throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
8206
8278
|
exp.children.splice(index + 1, 0, ...tail);
|
|
8207
8279
|
}
|
|
8208
|
-
if (block) {
|
|
8209
|
-
replaceNode(exp, block);
|
|
8210
|
-
block.expressions.push(["", exp]);
|
|
8211
|
-
exp.parent = block;
|
|
8212
|
-
}
|
|
8213
8280
|
}
|
|
8214
8281
|
}
|
|
8215
8282
|
function unchainOptionalMemberExpression(exp, ref, innerExp) {
|
|
@@ -8298,7 +8365,7 @@ function attachPostfixStatementAsExpression(exp, post) {
|
|
|
8298
8365
|
}
|
|
8299
8366
|
function processTypes(node) {
|
|
8300
8367
|
const results1 = [];
|
|
8301
|
-
for (let ref17 = gatherRecursiveAll(node, ($
|
|
8368
|
+
for (let ref17 = gatherRecursiveAll(node, ($10) => $10.type === "TypeUnary"), i8 = 0, len7 = ref17.length; i8 < len7; i8++) {
|
|
8302
8369
|
const unary = ref17[i8];
|
|
8303
8370
|
let suffixIndex = unary.suffix.length - 1;
|
|
8304
8371
|
const results2 = [];
|
|
@@ -8426,7 +8493,7 @@ function processTypes(node) {
|
|
|
8426
8493
|
return results1;
|
|
8427
8494
|
}
|
|
8428
8495
|
function processStatementExpressions(statements) {
|
|
8429
|
-
for (let ref19 = gatherRecursiveAll(statements, ($
|
|
8496
|
+
for (let ref19 = gatherRecursiveAll(statements, ($11) => $11.type === "StatementExpression"), i9 = 0, len8 = ref19.length; i9 < len8; i9++) {
|
|
8430
8497
|
const exp = ref19[i9];
|
|
8431
8498
|
const { maybe, statement } = exp;
|
|
8432
8499
|
if ((maybe || statement.type === "ThrowStatement") && blockContainingStatement(exp)) {
|
|
@@ -8574,11 +8641,11 @@ function processBreaksContinues(statements) {
|
|
|
8574
8641
|
}
|
|
8575
8642
|
}
|
|
8576
8643
|
function processCoffeeClasses(statements) {
|
|
8577
|
-
for (let ref23 = gatherRecursiveAll(statements, ($
|
|
8644
|
+
for (let ref23 = gatherRecursiveAll(statements, ($12) => $12.type === "ClassExpression"), i11 = 0, len10 = ref23.length; i11 < len10; i11++) {
|
|
8578
8645
|
const ce = ref23[i11];
|
|
8579
8646
|
const { expressions } = ce.body;
|
|
8580
8647
|
const indent = expressions[0]?.[0] ?? "\n";
|
|
8581
|
-
const autoBinds = expressions.filter(($
|
|
8648
|
+
const autoBinds = expressions.filter(($13) => $13[1]?.autoBind);
|
|
8582
8649
|
if (autoBinds.length) {
|
|
8583
8650
|
let construct;
|
|
8584
8651
|
for (const [, c] of expressions) {
|
|
@@ -8627,17 +8694,17 @@ function processCoffeeClasses(statements) {
|
|
|
8627
8694
|
})()
|
|
8628
8695
|
);
|
|
8629
8696
|
}
|
|
8630
|
-
const public_static_function_assignments = expressions.filter(($
|
|
8697
|
+
const public_static_function_assignments = expressions.filter(($14) => $14[1]?.type === "CoffeeClassPublic" && $14[1].assignment?.expression?.type === "FunctionExpression").map(($15) => $15[1].assignment);
|
|
8631
8698
|
for (const public_static_function_assignment of public_static_function_assignments) {
|
|
8632
8699
|
const id = public_static_function_assignment.lhs[0][1];
|
|
8633
8700
|
replaceNode(public_static_function_assignment, convertFunctionToMethod(id, public_static_function_assignment.expression));
|
|
8634
8701
|
}
|
|
8635
|
-
const public_static_arrow_function_assignments = expressions.filter(($
|
|
8702
|
+
const public_static_arrow_function_assignments = expressions.filter(($16) => $16[1]?.type === "CoffeeClassPublic" && $16[1].assignment?.expression?.type === "ArrowFunction").map(($17) => $17[1].assignment);
|
|
8636
8703
|
for (const public_static_arrow_function_assignment of public_static_arrow_function_assignments) {
|
|
8637
8704
|
const id = public_static_arrow_function_assignment.lhs[0][1];
|
|
8638
8705
|
replaceNode(public_static_arrow_function_assignment, convertArrowFunctionToMethod(id, public_static_arrow_function_assignment.expression));
|
|
8639
8706
|
}
|
|
8640
|
-
const privates = expressions.filter(($
|
|
8707
|
+
const privates = expressions.filter(($18) => $18[1]?.type === "CoffeeClassPrivate");
|
|
8641
8708
|
if (!privates.length) {
|
|
8642
8709
|
continue;
|
|
8643
8710
|
}
|
|
@@ -8702,7 +8769,7 @@ function processProgram(root) {
|
|
|
8702
8769
|
root.topLevelYield ? "*" : void 0
|
|
8703
8770
|
);
|
|
8704
8771
|
statements = [["", rootIIFE]];
|
|
8705
|
-
root.children = root.children.map(($
|
|
8772
|
+
root.children = root.children.map(($19) => $19 === root.expressions ? statements : $19);
|
|
8706
8773
|
root.expressions = statements;
|
|
8707
8774
|
}
|
|
8708
8775
|
hoistRefDecs(statements);
|
|
@@ -8733,9 +8800,9 @@ async function processProgramAsync(root) {
|
|
|
8733
8800
|
await processComptime(statements);
|
|
8734
8801
|
}
|
|
8735
8802
|
function processRepl(root, rootIIFE) {
|
|
8736
|
-
const topBlock = gatherRecursive(rootIIFE, ($
|
|
8803
|
+
const topBlock = gatherRecursive(rootIIFE, ($20) => $20.type === "BlockStatement")[0];
|
|
8737
8804
|
let i = 0;
|
|
8738
|
-
for (let ref24 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8805
|
+
for (let ref24 = gatherRecursiveWithinFunction(topBlock, ($21) => $21.type === "Declaration"), i14 = 0, len12 = ref24.length; i14 < len12; i14++) {
|
|
8739
8806
|
const decl = ref24[i14];
|
|
8740
8807
|
if (!decl.names?.length) {
|
|
8741
8808
|
continue;
|
|
@@ -8749,7 +8816,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8749
8816
|
root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
|
|
8750
8817
|
}
|
|
8751
8818
|
}
|
|
8752
|
-
for (let ref25 = gatherRecursive(topBlock, ($
|
|
8819
|
+
for (let ref25 = gatherRecursive(topBlock, ($22) => $22.type === "FunctionExpression"), i15 = 0, len13 = ref25.length; i15 < len13; i15++) {
|
|
8753
8820
|
const func = ref25[i15];
|
|
8754
8821
|
if (func.name && func.parent?.type === "BlockStatement") {
|
|
8755
8822
|
if (func.parent === topBlock) {
|
|
@@ -8762,7 +8829,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8762
8829
|
}
|
|
8763
8830
|
}
|
|
8764
8831
|
}
|
|
8765
|
-
for (let ref26 = gatherRecursiveWithinFunction(topBlock, ($
|
|
8832
|
+
for (let ref26 = gatherRecursiveWithinFunction(topBlock, ($23) => $23.type === "ClassExpression"), i16 = 0, len14 = ref26.length; i16 < len14; i16++) {
|
|
8766
8833
|
const classExp = ref26[i16];
|
|
8767
8834
|
let m8;
|
|
8768
8835
|
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)) {
|
|
@@ -8774,7 +8841,7 @@ function processRepl(root, rootIIFE) {
|
|
|
8774
8841
|
function processPlaceholders(statements) {
|
|
8775
8842
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
8776
8843
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
8777
|
-
for (let ref27 = gatherRecursiveAll(statements, ($
|
|
8844
|
+
for (let ref27 = gatherRecursiveAll(statements, ($24) => $24.type === "Placeholder"), i17 = 0, len15 = ref27.length; i17 < len15; i17++) {
|
|
8778
8845
|
const exp = ref27[i17];
|
|
8779
8846
|
let ancestor;
|
|
8780
8847
|
if (exp.subtype === ".") {
|
|
@@ -9059,7 +9126,7 @@ function typeOfJSXFragment(node, config2) {
|
|
|
9059
9126
|
if (type.length === 1) {
|
|
9060
9127
|
return type[0];
|
|
9061
9128
|
} else {
|
|
9062
|
-
type = type.flatMap(($
|
|
9129
|
+
type = type.flatMap(($25) => [$25, ", "]);
|
|
9063
9130
|
type.pop();
|
|
9064
9131
|
return ["[", type, "]"];
|
|
9065
9132
|
}
|
|
@@ -9124,6 +9191,7 @@ var grammar = {
|
|
|
9124
9191
|
Tuple,
|
|
9125
9192
|
NWTypePostfix,
|
|
9126
9193
|
UpdateExpression,
|
|
9194
|
+
UpdateExpressionPattern,
|
|
9127
9195
|
UpdateExpressionSymbol,
|
|
9128
9196
|
AssignmentExpression,
|
|
9129
9197
|
NonPipelineAssignmentExpression,
|
|
@@ -9259,7 +9327,7 @@ var grammar = {
|
|
|
9259
9327
|
OperatorPrecedence,
|
|
9260
9328
|
OperatorAssociativity,
|
|
9261
9329
|
ThinArrowFunction,
|
|
9262
|
-
|
|
9330
|
+
ThinArrow,
|
|
9263
9331
|
ExplicitBlock,
|
|
9264
9332
|
EmptyBracedContent,
|
|
9265
9333
|
ImplicitNestedBlock,
|
|
@@ -10243,7 +10311,7 @@ var $R71 = (0, import_lib2.$R)(new RegExp("#(?!##(?!#))([^\\r\\n]*)", "suy"));
|
|
|
10243
10311
|
var $R72 = (0, import_lib2.$R)(new RegExp("[^]*?###", "suy"));
|
|
10244
10312
|
var $R73 = (0, import_lib2.$R)(new RegExp("###(?!#)", "suy"));
|
|
10245
10313
|
var $R74 = (0, import_lib2.$R)(new RegExp("\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\/", "suy"));
|
|
10246
|
-
var $R75 = (0, import_lib2.$R)(new RegExp("(?=[ \\t
|
|
10314
|
+
var $R75 = (0, import_lib2.$R)(new RegExp("(?=[ \\t\\/\\\\#])", "suy"));
|
|
10247
10315
|
var $R76 = (0, import_lib2.$R)(new RegExp("(?=\\s|\\/|#)", "suy"));
|
|
10248
10316
|
var $R77 = (0, import_lib2.$R)(new RegExp("(?!\\p{ID_Continue})", "suy"));
|
|
10249
10317
|
var $R78 = (0, import_lib2.$R)(new RegExp("[=:]", "suy"));
|
|
@@ -10930,6 +10998,12 @@ var UpdateExpression$$ = [UpdateExpression$0, UpdateExpression$1];
|
|
|
10930
10998
|
function UpdateExpression(ctx, state2) {
|
|
10931
10999
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "UpdateExpression", UpdateExpression$$);
|
|
10932
11000
|
}
|
|
11001
|
+
var UpdateExpressionPattern$0 = NamedBindingPattern;
|
|
11002
|
+
var UpdateExpressionPattern$1 = UpdateExpression;
|
|
11003
|
+
var UpdateExpressionPattern$$ = [UpdateExpressionPattern$0, UpdateExpressionPattern$1];
|
|
11004
|
+
function UpdateExpressionPattern(ctx, state2) {
|
|
11005
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "UpdateExpressionPattern", UpdateExpressionPattern$$);
|
|
11006
|
+
}
|
|
10933
11007
|
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) {
|
|
10934
11008
|
return { $loc, token: $1 };
|
|
10935
11009
|
});
|
|
@@ -10993,7 +11067,7 @@ var NonPipelineAssignmentExpressionTail$$ = [NonPipelineAssignmentExpressionTail
|
|
|
10993
11067
|
function NonPipelineAssignmentExpressionTail(ctx, state2) {
|
|
10994
11068
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "NonPipelineAssignmentExpressionTail", NonPipelineAssignmentExpressionTail$$);
|
|
10995
11069
|
}
|
|
10996
|
-
var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented,
|
|
11070
|
+
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) {
|
|
10997
11071
|
$1 = $1.map((x) => [x[0], x[1], ...x[2]]);
|
|
10998
11072
|
$0 = [$1, $2];
|
|
10999
11073
|
return {
|
|
@@ -11010,7 +11084,7 @@ var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib
|
|
|
11010
11084
|
function ActualAssignment(ctx, state2) {
|
|
11011
11085
|
return (0, import_lib2.$EVENT)(ctx, state2, "ActualAssignment", ActualAssignment$0);
|
|
11012
11086
|
}
|
|
11013
|
-
var NonPipelineActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented,
|
|
11087
|
+
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) {
|
|
11014
11088
|
$1 = $1.map((x) => [x[0], x[1], ...x[2]]);
|
|
11015
11089
|
$0 = [$1, $2];
|
|
11016
11090
|
return {
|
|
@@ -11189,8 +11263,14 @@ var PipelineExpressionBody$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Pipeline
|
|
|
11189
11263
|
...rest.map(([nested, line]) => [nested, ...line]).flat()
|
|
11190
11264
|
];
|
|
11191
11265
|
});
|
|
11192
|
-
var PipelineExpressionBody$1 = (0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, Pipe, __, PipelineTailItem))
|
|
11193
|
-
|
|
11266
|
+
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) {
|
|
11267
|
+
return value[1];
|
|
11268
|
+
});
|
|
11269
|
+
var PipelineExpressionBody$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NewlineBinaryOpAllowed), PipelineExpressionBodySameLine), function($skip, $loc, $0, $1, $2) {
|
|
11270
|
+
if (!$2.length) return $skip;
|
|
11271
|
+
return $2;
|
|
11272
|
+
});
|
|
11273
|
+
var PipelineExpressionBody$$ = [PipelineExpressionBody$0, PipelineExpressionBody$1, PipelineExpressionBody$2];
|
|
11194
11274
|
function PipelineExpressionBody(ctx, state2) {
|
|
11195
11275
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PipelineExpressionBody", PipelineExpressionBody$$);
|
|
11196
11276
|
}
|
|
@@ -11221,8 +11301,9 @@ var PipelineTailItem$3 = (0, import_lib2.$TS)((0, import_lib2.$S)(NWTypePostfix,
|
|
|
11221
11301
|
body: [" ", $1, ...$2]
|
|
11222
11302
|
});
|
|
11223
11303
|
});
|
|
11224
|
-
var PipelineTailItem$4 = (0, import_lib2.$
|
|
11225
|
-
return
|
|
11304
|
+
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) {
|
|
11305
|
+
if (!$2) return $skip;
|
|
11306
|
+
return $2;
|
|
11226
11307
|
});
|
|
11227
11308
|
var PipelineTailItem$$ = [PipelineTailItem$0, PipelineTailItem$1, PipelineTailItem$2, PipelineTailItem$3, PipelineTailItem$4];
|
|
11228
11309
|
function PipelineTailItem(ctx, state2) {
|
|
@@ -11819,9 +11900,8 @@ var LeftHandSideExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impo
|
|
|
11819
11900
|
expression
|
|
11820
11901
|
};
|
|
11821
11902
|
});
|
|
11822
|
-
var LeftHandSideExpression$1 =
|
|
11823
|
-
var LeftHandSideExpression
|
|
11824
|
-
var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1, LeftHandSideExpression$2];
|
|
11903
|
+
var LeftHandSideExpression$1 = CallExpression;
|
|
11904
|
+
var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1];
|
|
11825
11905
|
function LeftHandSideExpression(ctx, state2) {
|
|
11826
11906
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "LeftHandSideExpression", LeftHandSideExpression$$);
|
|
11827
11907
|
}
|
|
@@ -13276,14 +13356,21 @@ var OperatorAssociativity$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impor
|
|
|
13276
13356
|
function OperatorAssociativity(ctx, state2) {
|
|
13277
13357
|
return (0, import_lib2.$EVENT)(ctx, state2, "OperatorAssociativity", OperatorAssociativity$0);
|
|
13278
13358
|
}
|
|
13279
|
-
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)(_),
|
|
13359
|
+
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) {
|
|
13280
13360
|
var async = $1;
|
|
13281
13361
|
var parameters = $2;
|
|
13282
13362
|
var returnType = $3;
|
|
13363
|
+
var ws = $4;
|
|
13283
13364
|
var arrow = $5;
|
|
13284
13365
|
var block = $6;
|
|
13285
13366
|
if (!async) async = [];
|
|
13286
13367
|
const generator = [];
|
|
13368
|
+
if ((!parameters.implicit || returnType || ws) && !block.bare) {
|
|
13369
|
+
const [first, ...rest] = block.children;
|
|
13370
|
+
if (first === " {" || first?.[0]?.token === " ") {
|
|
13371
|
+
block = { ...block, children: [first.slice(1), ...rest] };
|
|
13372
|
+
}
|
|
13373
|
+
}
|
|
13287
13374
|
return {
|
|
13288
13375
|
type: "FunctionExpression",
|
|
13289
13376
|
id: void 0,
|
|
@@ -13308,6 +13395,7 @@ var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
13308
13395
|
generator,
|
|
13309
13396
|
parameters,
|
|
13310
13397
|
returnType,
|
|
13398
|
+
ws,
|
|
13311
13399
|
block
|
|
13312
13400
|
]
|
|
13313
13401
|
};
|
|
@@ -13315,11 +13403,11 @@ var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
13315
13403
|
function ThinArrowFunction(ctx, state2) {
|
|
13316
13404
|
return (0, import_lib2.$EVENT)(ctx, state2, "ThinArrowFunction", ThinArrowFunction$0);
|
|
13317
13405
|
}
|
|
13318
|
-
var
|
|
13406
|
+
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) {
|
|
13319
13407
|
return { $loc, token: "->" };
|
|
13320
13408
|
});
|
|
13321
|
-
function
|
|
13322
|
-
return (0, import_lib2.$EVENT)(ctx, state2, "
|
|
13409
|
+
function ThinArrow(ctx, state2) {
|
|
13410
|
+
return (0, import_lib2.$EVENT)(ctx, state2, "ThinArrow", ThinArrow$0);
|
|
13323
13411
|
}
|
|
13324
13412
|
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) {
|
|
13325
13413
|
var ws1 = $1;
|
|
@@ -17977,8 +18065,10 @@ function CoffeeHereCommentStart(ctx, state2) {
|
|
|
17977
18065
|
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) {
|
|
17978
18066
|
return { $loc, token: $0 };
|
|
17979
18067
|
});
|
|
18068
|
+
var InlineComment$1 = CoffeeMultiLineComment;
|
|
18069
|
+
var InlineComment$$ = [InlineComment$0, InlineComment$1];
|
|
17980
18070
|
function InlineComment(ctx, state2) {
|
|
17981
|
-
return (0, import_lib2.$
|
|
18071
|
+
return (0, import_lib2.$EVENT_C)(ctx, state2, "InlineComment", InlineComment$$);
|
|
17982
18072
|
}
|
|
17983
18073
|
var RestOfLine$0 = (0, import_lib2.$S)((0, import_lib2.$Q)((0, import_lib2.$C)(NonNewlineWhitespace, Comment)), EOL);
|
|
17984
18074
|
function RestOfLine(ctx, state2) {
|
|
@@ -17988,7 +18078,7 @@ var TrailingComment$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_l
|
|
|
17988
18078
|
function TrailingComment(ctx, state2) {
|
|
17989
18079
|
return (0, import_lib2.$EVENT)(ctx, state2, "TrailingComment", TrailingComment$0);
|
|
17990
18080
|
}
|
|
17991
|
-
var _$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R75, "_ /(?=[ \\t
|
|
18081
|
+
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) {
|
|
17992
18082
|
return value[1];
|
|
17993
18083
|
});
|
|
17994
18084
|
function _(ctx, state2) {
|
|
@@ -22163,8 +22253,9 @@ ${counts}`;
|
|
|
22163
22253
|
const code = generate_civet_default(ast2, options);
|
|
22164
22254
|
checkErrors();
|
|
22165
22255
|
if (options.inlineMap) {
|
|
22256
|
+
const outputFilename = options.outputFilename ?? (options.js ? filename2 + ".jsx" : filename2 + ".tsx");
|
|
22166
22257
|
return `${code}
|
|
22167
|
-
${options.sourceMap.comment(filename2,
|
|
22258
|
+
${options.sourceMap.comment(filename2, outputFilename)}`;
|
|
22168
22259
|
} else {
|
|
22169
22260
|
return {
|
|
22170
22261
|
code,
|