@danielx/civet 0.5.86 → 0.5.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +276 -141
- package/dist/main.js +276 -141
- package/dist/main.mjs +276 -141
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -31,6 +31,32 @@ var Civet = (() => {
|
|
|
31
31
|
var require_lib = __commonJS({
|
|
32
32
|
"source/lib.js"(exports, module) {
|
|
33
33
|
"use strict";
|
|
34
|
+
function blockWithPrefix(prefixStatements, block) {
|
|
35
|
+
if (prefixStatements && prefixStatements.length) {
|
|
36
|
+
const indent = getIndent(block.expressions[0]);
|
|
37
|
+
if (indent) {
|
|
38
|
+
prefixStatements = prefixStatements.map((statement) => [indent, ...statement.slice(1)]);
|
|
39
|
+
}
|
|
40
|
+
const expressions = [...prefixStatements, ...block.expressions];
|
|
41
|
+
block = {
|
|
42
|
+
...block,
|
|
43
|
+
expressions,
|
|
44
|
+
children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
|
|
45
|
+
};
|
|
46
|
+
if (block.bare) {
|
|
47
|
+
block.children = [[" {\n", indent], ...block.children, "}"];
|
|
48
|
+
block.bare = false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return block;
|
|
52
|
+
}
|
|
53
|
+
function closest(node, types) {
|
|
54
|
+
do {
|
|
55
|
+
if (types.includes(node.type)) {
|
|
56
|
+
return node;
|
|
57
|
+
}
|
|
58
|
+
} while (node = node.parent);
|
|
59
|
+
}
|
|
34
60
|
function clone(node) {
|
|
35
61
|
removeParentPointers(node);
|
|
36
62
|
return deepCopy(node);
|
|
@@ -67,6 +93,14 @@ var Civet = (() => {
|
|
|
67
93
|
}
|
|
68
94
|
}
|
|
69
95
|
}
|
|
96
|
+
function findAncestor(node, predicate, stopPredicate) {
|
|
97
|
+
node = node.parent;
|
|
98
|
+
while (node && !stopPredicate?.(node)) {
|
|
99
|
+
if (predicate(node))
|
|
100
|
+
return node;
|
|
101
|
+
node = node.parent;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
70
104
|
function gatherNodes(node, predicate) {
|
|
71
105
|
if (node == null)
|
|
72
106
|
return [];
|
|
@@ -116,12 +150,40 @@ var Civet = (() => {
|
|
|
116
150
|
}
|
|
117
151
|
return nodes;
|
|
118
152
|
}
|
|
153
|
+
function getIndent(statement) {
|
|
154
|
+
let indent = statement?.[0];
|
|
155
|
+
if (Array.isArray(indent))
|
|
156
|
+
indent = indent[indent.length - 1];
|
|
157
|
+
return indent;
|
|
158
|
+
}
|
|
119
159
|
function hasAwait(exp) {
|
|
120
160
|
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
|
|
121
161
|
}
|
|
122
162
|
function hasYield(exp) {
|
|
123
163
|
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
|
|
124
164
|
}
|
|
165
|
+
function hoistRefDecs(statements) {
|
|
166
|
+
gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
|
|
167
|
+
const { hoistDec } = node;
|
|
168
|
+
const outer = closest(node, ["IfStatement", "IterationStatement"]);
|
|
169
|
+
if (!outer) {
|
|
170
|
+
node.children.push({
|
|
171
|
+
type: "Error",
|
|
172
|
+
message: "Can't hoist declarations inside expressions yet."
|
|
173
|
+
});
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const block = outer.parent;
|
|
177
|
+
const { expressions } = block;
|
|
178
|
+
const index = expressions.findIndex(([, s]) => outer === s);
|
|
179
|
+
if (index < 0)
|
|
180
|
+
throw new Error("Couldn't find expression in block for hoistable declaration.");
|
|
181
|
+
const indent = expressions[index][0];
|
|
182
|
+
hoistDec[0][0] = indent;
|
|
183
|
+
expressions.splice(index, 0, hoistDec);
|
|
184
|
+
node.hoistDec = null;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
125
187
|
function isFunction(node) {
|
|
126
188
|
const { type } = node;
|
|
127
189
|
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
@@ -262,13 +324,6 @@ var Civet = (() => {
|
|
|
262
324
|
}
|
|
263
325
|
} else if (forDeclaration) {
|
|
264
326
|
varAssign = varLetAssign = [forDeclaration, " = "];
|
|
265
|
-
blockPrefix = [
|
|
266
|
-
["", {
|
|
267
|
-
type: "AssignmentExpression",
|
|
268
|
-
children: [],
|
|
269
|
-
names: forDeclaration.names
|
|
270
|
-
}]
|
|
271
|
-
];
|
|
272
327
|
}
|
|
273
328
|
const declaration = {
|
|
274
329
|
type: "Declaration",
|
|
@@ -284,6 +339,34 @@ var Civet = (() => {
|
|
|
284
339
|
blockPrefix
|
|
285
340
|
};
|
|
286
341
|
}
|
|
342
|
+
function gatherBindingCode(statements, opts) {
|
|
343
|
+
const thisAssignments = [];
|
|
344
|
+
const splices = [];
|
|
345
|
+
function insertRestSplices(s, p, thisAssignments2) {
|
|
346
|
+
gatherRecursiveAll(s, (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding").forEach((n) => {
|
|
347
|
+
if (n.type === "AtBinding") {
|
|
348
|
+
const { ref } = n, { id } = ref;
|
|
349
|
+
thisAssignments2.push([`this.${id} = `, ref]);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
353
|
+
n.names.forEach((id) => {
|
|
354
|
+
thisAssignments2.push({
|
|
355
|
+
type: "AssignmentExpression",
|
|
356
|
+
children: [`this.${id} = `, id],
|
|
357
|
+
js: true
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const { blockPrefix } = n;
|
|
363
|
+
p.push(blockPrefix);
|
|
364
|
+
insertRestSplices(blockPrefix, p, thisAssignments2);
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
insertRestSplices(statements, splices, thisAssignments);
|
|
368
|
+
return [splices, thisAssignments];
|
|
369
|
+
}
|
|
287
370
|
function modifyString(str) {
|
|
288
371
|
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
289
372
|
}
|
|
@@ -315,22 +398,93 @@ var Civet = (() => {
|
|
|
315
398
|
children: [s, parts, e]
|
|
316
399
|
};
|
|
317
400
|
}
|
|
401
|
+
function processConstAssignmentDeclaration(c, id, suffix, ws, ca, e) {
|
|
402
|
+
c = {
|
|
403
|
+
...c,
|
|
404
|
+
$loc: {
|
|
405
|
+
pos: ca.$loc.pos - 1,
|
|
406
|
+
length: ca.$loc.length + 1
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
let exp;
|
|
410
|
+
if (e.type === "FunctionExpression") {
|
|
411
|
+
exp = e;
|
|
412
|
+
} else {
|
|
413
|
+
exp = e[1];
|
|
414
|
+
}
|
|
415
|
+
if (exp?.children?.[0]?.token?.match(/^\s+$/))
|
|
416
|
+
exp.children.shift();
|
|
417
|
+
if (id.type === "Identifier" && exp?.type === "FunctionExpression" && !exp.id) {
|
|
418
|
+
const i = exp.children.findIndex((c2) => c2?.token === "function") + 1;
|
|
419
|
+
exp = {
|
|
420
|
+
...exp,
|
|
421
|
+
children: [...exp.children.slice(0, i), " ", id, suffix, ws, ...exp.children.slice(i)]
|
|
422
|
+
};
|
|
423
|
+
return {
|
|
424
|
+
type: "Declaration",
|
|
425
|
+
children: [exp],
|
|
426
|
+
names: id.names
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
let [splices, thisAssignments] = gatherBindingCode(id);
|
|
430
|
+
splices = splices.map((s) => [", ", s]);
|
|
431
|
+
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
432
|
+
const binding = [c, id, suffix, ...ws];
|
|
433
|
+
const initializer = [ca, e, ...splices, ...thisAssignments];
|
|
434
|
+
const children = [binding, initializer];
|
|
435
|
+
return {
|
|
436
|
+
type: "Declaration",
|
|
437
|
+
names: id.names,
|
|
438
|
+
children,
|
|
439
|
+
binding,
|
|
440
|
+
initializer
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
function processLetAssignmentDeclaration(l, id, suffix, ws, la, e) {
|
|
444
|
+
l = {
|
|
445
|
+
...l,
|
|
446
|
+
$loc: {
|
|
447
|
+
pos: la.$loc.pos - 1,
|
|
448
|
+
length: la.$loc.length + 1
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
let [splices, thisAssignments] = gatherBindingCode(id);
|
|
452
|
+
splices = splices.map((s) => [", ", s]);
|
|
453
|
+
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
454
|
+
const binding = [l, id, suffix, ...ws];
|
|
455
|
+
const initializer = [la, e, ...splices, ...thisAssignments];
|
|
456
|
+
const children = [binding, initializer];
|
|
457
|
+
return {
|
|
458
|
+
type: "Declaration",
|
|
459
|
+
names: id.names,
|
|
460
|
+
children,
|
|
461
|
+
binding,
|
|
462
|
+
initializer
|
|
463
|
+
};
|
|
464
|
+
}
|
|
318
465
|
module.exports = {
|
|
466
|
+
blockWithPrefix,
|
|
319
467
|
clone,
|
|
320
468
|
deepCopy,
|
|
469
|
+
findAncestor,
|
|
321
470
|
forRange,
|
|
471
|
+
gatherBindingCode,
|
|
322
472
|
gatherNodes,
|
|
323
473
|
gatherRecursive,
|
|
324
474
|
gatherRecursiveAll,
|
|
325
475
|
gatherRecursiveWithinFunction,
|
|
476
|
+
getIndent,
|
|
326
477
|
getTrimmingSpace,
|
|
327
478
|
hasAwait,
|
|
328
479
|
hasYield,
|
|
480
|
+
hoistRefDecs,
|
|
329
481
|
insertTrimmingSpace,
|
|
330
482
|
isFunction,
|
|
331
483
|
literalValue,
|
|
332
484
|
modifyString,
|
|
333
485
|
processCoffeeInterpolation,
|
|
486
|
+
processConstAssignmentDeclaration,
|
|
487
|
+
processLetAssignmentDeclaration,
|
|
334
488
|
quoteString,
|
|
335
489
|
removeParentPointers
|
|
336
490
|
};
|
|
@@ -1013,6 +1167,7 @@ ${input.slice(result.pos)}
|
|
|
1013
1167
|
FinallyClause,
|
|
1014
1168
|
CatchParameter,
|
|
1015
1169
|
Condition,
|
|
1170
|
+
DeclarationCondition,
|
|
1016
1171
|
ExpressionWithIndentedApplicationForbidden,
|
|
1017
1172
|
ForbidClassImplicitCall,
|
|
1018
1173
|
AllowClassImplicitCall,
|
|
@@ -1627,7 +1782,12 @@ ${input.slice(result.pos)}
|
|
|
1627
1782
|
var $R65 = $R(new RegExp("[ \\t]*", "suy"));
|
|
1628
1783
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
1629
1784
|
var statements = $4;
|
|
1630
|
-
module.processProgram(
|
|
1785
|
+
module.processProgram({
|
|
1786
|
+
type: "BlockStatement",
|
|
1787
|
+
expressions: statements,
|
|
1788
|
+
children: [statements],
|
|
1789
|
+
bare: true
|
|
1790
|
+
});
|
|
1631
1791
|
return $0;
|
|
1632
1792
|
});
|
|
1633
1793
|
function Program(state) {
|
|
@@ -9234,16 +9394,18 @@ ${input.slice(result.pos)}
|
|
|
9234
9394
|
var clause = $1;
|
|
9235
9395
|
var block = $2;
|
|
9236
9396
|
var e = $3;
|
|
9237
|
-
const children = [...clause.children
|
|
9397
|
+
const children = [...clause.children];
|
|
9398
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9399
|
+
children.push(block);
|
|
9238
9400
|
if (block.bare && e)
|
|
9239
9401
|
children.push(";");
|
|
9240
9402
|
if (e)
|
|
9241
9403
|
children.push(e);
|
|
9242
9404
|
return {
|
|
9243
|
-
|
|
9405
|
+
...clause,
|
|
9406
|
+
children,
|
|
9244
9407
|
then: block,
|
|
9245
|
-
else: e
|
|
9246
|
-
children
|
|
9408
|
+
else: e
|
|
9247
9409
|
};
|
|
9248
9410
|
});
|
|
9249
9411
|
function IfStatement(state) {
|
|
@@ -9292,8 +9454,13 @@ ${input.slice(result.pos)}
|
|
|
9292
9454
|
return result;
|
|
9293
9455
|
}
|
|
9294
9456
|
}
|
|
9295
|
-
var IfClause$0 = $
|
|
9296
|
-
|
|
9457
|
+
var IfClause$0 = $TS($S(If, Condition), function($skip, $loc, $0, $1, $2) {
|
|
9458
|
+
var condition = $2;
|
|
9459
|
+
return {
|
|
9460
|
+
type: "IfStatement",
|
|
9461
|
+
children: $0,
|
|
9462
|
+
condition
|
|
9463
|
+
};
|
|
9297
9464
|
});
|
|
9298
9465
|
function IfClause(state) {
|
|
9299
9466
|
let eventData;
|
|
@@ -9323,7 +9490,8 @@ ${input.slice(result.pos)}
|
|
|
9323
9490
|
kind = { ...kind, token: "if" };
|
|
9324
9491
|
return {
|
|
9325
9492
|
type: "IfStatement",
|
|
9326
|
-
children: [kind, ["(!", condition, ")"]]
|
|
9493
|
+
children: [kind, ["(!", condition, ")"]],
|
|
9494
|
+
condition
|
|
9327
9495
|
};
|
|
9328
9496
|
});
|
|
9329
9497
|
function UnlessClause(state) {
|
|
@@ -9792,8 +9960,9 @@ ${input.slice(result.pos)}
|
|
|
9792
9960
|
var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9793
9961
|
var clause = $1;
|
|
9794
9962
|
var block = $2;
|
|
9963
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9795
9964
|
return {
|
|
9796
|
-
|
|
9965
|
+
...clause,
|
|
9797
9966
|
children: [...clause.children, block],
|
|
9798
9967
|
block
|
|
9799
9968
|
};
|
|
@@ -9823,17 +9992,19 @@ ${input.slice(result.pos)}
|
|
|
9823
9992
|
var WhileClause$0 = $TS($S($C(While, Until), $E(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
|
|
9824
9993
|
var kind = $1;
|
|
9825
9994
|
var ws = $2;
|
|
9826
|
-
var
|
|
9995
|
+
var condition = $3;
|
|
9827
9996
|
if (kind.token === "until") {
|
|
9828
9997
|
kind.token = "while";
|
|
9829
9998
|
return {
|
|
9830
9999
|
type: "IterationStatement",
|
|
9831
|
-
children: [kind, ...ws, ["(!", ...
|
|
10000
|
+
children: [kind, ...ws, ["(!", ...condition.children, ")"]],
|
|
10001
|
+
condition
|
|
9832
10002
|
};
|
|
9833
10003
|
}
|
|
9834
10004
|
return {
|
|
9835
10005
|
type: "IterationStatement",
|
|
9836
|
-
children: [kind, ...ws, ...
|
|
10006
|
+
children: [kind, ...ws, ...condition.children],
|
|
10007
|
+
condition
|
|
9837
10008
|
};
|
|
9838
10009
|
});
|
|
9839
10010
|
function WhileClause(state) {
|
|
@@ -9861,18 +10032,7 @@ ${input.slice(result.pos)}
|
|
|
9861
10032
|
var ForStatement$0 = $TS($S(ForClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9862
10033
|
var clause = $1;
|
|
9863
10034
|
var block = $2;
|
|
9864
|
-
|
|
9865
|
-
const expressions = [...clause.blockPrefix, ...block.expressions];
|
|
9866
|
-
block = {
|
|
9867
|
-
...block,
|
|
9868
|
-
expressions,
|
|
9869
|
-
children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
|
|
9870
|
-
};
|
|
9871
|
-
if (block.bare) {
|
|
9872
|
-
block.children = [" {\n", ...block.children, "\n}"];
|
|
9873
|
-
block.bare = false;
|
|
9874
|
-
}
|
|
9875
|
-
}
|
|
10035
|
+
block = blockWithPrefix(clause.blockPrefix, block);
|
|
9876
10036
|
return {
|
|
9877
10037
|
...clause,
|
|
9878
10038
|
children: [...clause.children, block],
|
|
@@ -10927,10 +11087,31 @@ ${input.slice(result.pos)}
|
|
|
10927
11087
|
return result;
|
|
10928
11088
|
}
|
|
10929
11089
|
}
|
|
10930
|
-
var Condition$0 = $
|
|
11090
|
+
var Condition$0 = $TS($S(OpenParen, $E(_), DeclarationCondition, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
11091
|
+
var open = $1;
|
|
11092
|
+
var ws = $2;
|
|
11093
|
+
var expression = $3;
|
|
11094
|
+
var close = $4;
|
|
11095
|
+
return {
|
|
11096
|
+
type: "ParenthesizedExpression",
|
|
11097
|
+
children: [open, ws, expression, close],
|
|
11098
|
+
expression
|
|
11099
|
+
};
|
|
11100
|
+
});
|
|
11101
|
+
var Condition$1 = $T($S(ParenthesizedExpression, $N($S($E(_), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
|
|
10931
11102
|
return value[0];
|
|
10932
11103
|
});
|
|
10933
|
-
var Condition$
|
|
11104
|
+
var Condition$2 = $TS($S(InsertOpenParen, DeclarationCondition, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
|
|
11105
|
+
var open = $1;
|
|
11106
|
+
var expression = $2;
|
|
11107
|
+
var close = $3;
|
|
11108
|
+
return {
|
|
11109
|
+
type: "ParenthesizedExpression",
|
|
11110
|
+
children: [open, expression, close],
|
|
11111
|
+
expression
|
|
11112
|
+
};
|
|
11113
|
+
});
|
|
11114
|
+
var Condition$3 = $TS($S(InsertOpenParen, ExpressionWithIndentedApplicationForbidden, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
|
|
10934
11115
|
var open = $1;
|
|
10935
11116
|
var expression = $2;
|
|
10936
11117
|
var close = $3;
|
|
@@ -10954,17 +11135,54 @@ ${input.slice(result.pos)}
|
|
|
10954
11135
|
}
|
|
10955
11136
|
}
|
|
10956
11137
|
if (state.tokenize) {
|
|
10957
|
-
const result = $TOKEN("Condition", state, Condition$0(state) || Condition$1(state));
|
|
11138
|
+
const result = $TOKEN("Condition", state, Condition$0(state) || Condition$1(state) || Condition$2(state) || Condition$3(state));
|
|
10958
11139
|
if (state.events)
|
|
10959
11140
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10960
11141
|
return result;
|
|
10961
11142
|
} else {
|
|
10962
|
-
const result = Condition$0(state) || Condition$1(state);
|
|
11143
|
+
const result = Condition$0(state) || Condition$1(state) || Condition$2(state) || Condition$3(state);
|
|
10963
11144
|
if (state.events)
|
|
10964
11145
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10965
11146
|
return result;
|
|
10966
11147
|
}
|
|
10967
11148
|
}
|
|
11149
|
+
var DeclarationCondition$0 = $TV(LexicalDeclaration, function($skip, $loc, $0, $1) {
|
|
11150
|
+
var dec = $0;
|
|
11151
|
+
const ref = {
|
|
11152
|
+
type: "Ref",
|
|
11153
|
+
base: "ref"
|
|
11154
|
+
};
|
|
11155
|
+
const { binding, initializer } = dec;
|
|
11156
|
+
const initCondition = {
|
|
11157
|
+
type: "AssignmentExpression",
|
|
11158
|
+
children: [ref, " ", initializer],
|
|
11159
|
+
hoistDec: [["", ["let ", ref], ";"]],
|
|
11160
|
+
blockPrefix: [["", [binding, "= ", ref], ";\n"]]
|
|
11161
|
+
};
|
|
11162
|
+
return initCondition;
|
|
11163
|
+
});
|
|
11164
|
+
function DeclarationCondition(state) {
|
|
11165
|
+
let eventData;
|
|
11166
|
+
if (state.events) {
|
|
11167
|
+
const result = state.events.enter?.("DeclarationCondition", state);
|
|
11168
|
+
if (result) {
|
|
11169
|
+
if (result.cache)
|
|
11170
|
+
return result.cache;
|
|
11171
|
+
eventData = result.data;
|
|
11172
|
+
}
|
|
11173
|
+
}
|
|
11174
|
+
if (state.tokenize) {
|
|
11175
|
+
const result = $TOKEN("DeclarationCondition", state, DeclarationCondition$0(state));
|
|
11176
|
+
if (state.events)
|
|
11177
|
+
state.events.exit?.("DeclarationCondition", state, result, eventData);
|
|
11178
|
+
return result;
|
|
11179
|
+
} else {
|
|
11180
|
+
const result = DeclarationCondition$0(state);
|
|
11181
|
+
if (state.events)
|
|
11182
|
+
state.events.exit?.("DeclarationCondition", state, result, eventData);
|
|
11183
|
+
return result;
|
|
11184
|
+
}
|
|
11185
|
+
}
|
|
10968
11186
|
var ExpressionWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ExtendedExpression), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
|
|
10969
11187
|
var exp = $2;
|
|
10970
11188
|
if (exp)
|
|
@@ -12393,48 +12611,7 @@ ${input.slice(result.pos)}
|
|
|
12393
12611
|
};
|
|
12394
12612
|
});
|
|
12395
12613
|
var LexicalDeclaration$1 = $TS($S(InsertConst, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
12396
|
-
|
|
12397
|
-
var id = $2;
|
|
12398
|
-
var suffix = $3;
|
|
12399
|
-
var ws = $4;
|
|
12400
|
-
var ca = $5;
|
|
12401
|
-
var e = $6;
|
|
12402
|
-
c = {
|
|
12403
|
-
...c,
|
|
12404
|
-
$loc: {
|
|
12405
|
-
pos: ca.$loc.pos - 1,
|
|
12406
|
-
length: ca.$loc.length + 1
|
|
12407
|
-
}
|
|
12408
|
-
};
|
|
12409
|
-
let exp;
|
|
12410
|
-
if (e.type === "FunctionExpression") {
|
|
12411
|
-
exp = e;
|
|
12412
|
-
} else {
|
|
12413
|
-
exp = e[1];
|
|
12414
|
-
}
|
|
12415
|
-
if (exp?.children?.[0]?.token?.match(/^\s+$/))
|
|
12416
|
-
exp.children.shift();
|
|
12417
|
-
if (id.type === "Identifier" && exp?.type === "FunctionExpression" && !exp.id) {
|
|
12418
|
-
const i = exp.children.findIndex((c2) => c2?.token === "function") + 1;
|
|
12419
|
-
exp = {
|
|
12420
|
-
...exp,
|
|
12421
|
-
children: [...exp.children.slice(0, i), " ", id, $3, $4, ...exp.children.slice(i)]
|
|
12422
|
-
};
|
|
12423
|
-
return {
|
|
12424
|
-
type: "Declaration",
|
|
12425
|
-
children: [exp],
|
|
12426
|
-
names: id.names
|
|
12427
|
-
};
|
|
12428
|
-
}
|
|
12429
|
-
let [splices, thisAssignments] = module.gatherBindingCode(id);
|
|
12430
|
-
splices = splices.map((s) => [", ", s]);
|
|
12431
|
-
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
12432
|
-
const children = [c, id, suffix, ...ws, ca, e, ...splices, ...thisAssignments];
|
|
12433
|
-
return {
|
|
12434
|
-
type: "Declaration",
|
|
12435
|
-
names: id.names,
|
|
12436
|
-
children
|
|
12437
|
-
};
|
|
12614
|
+
return processConstAssignmentDeclaration(...$0);
|
|
12438
12615
|
});
|
|
12439
12616
|
var LexicalDeclaration$2 = $TS($S(InsertLet, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, LetAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
12440
12617
|
var l = $1;
|
|
@@ -12443,22 +12620,7 @@ ${input.slice(result.pos)}
|
|
|
12443
12620
|
var ws = $4;
|
|
12444
12621
|
var la = $5;
|
|
12445
12622
|
var e = $6;
|
|
12446
|
-
|
|
12447
|
-
...l,
|
|
12448
|
-
$loc: {
|
|
12449
|
-
pos: la.$loc.pos - 1,
|
|
12450
|
-
length: la.$loc.length + 1
|
|
12451
|
-
}
|
|
12452
|
-
};
|
|
12453
|
-
let [splices, thisAssignments] = module.gatherBindingCode(id);
|
|
12454
|
-
splices = splices.map((s) => [", ", s]);
|
|
12455
|
-
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
12456
|
-
const children = [l, id, suffix, ...ws, la, e, ...splices, ...thisAssignments];
|
|
12457
|
-
return {
|
|
12458
|
-
type: "Declaration",
|
|
12459
|
-
names: id.names,
|
|
12460
|
-
children
|
|
12461
|
-
};
|
|
12623
|
+
return processLetAssignmentDeclaration(...$0);
|
|
12462
12624
|
});
|
|
12463
12625
|
function LexicalDeclaration(state) {
|
|
12464
12626
|
let eventData;
|
|
@@ -14603,7 +14765,7 @@ ${input.slice(result.pos)}
|
|
|
14603
14765
|
return result;
|
|
14604
14766
|
}
|
|
14605
14767
|
}
|
|
14606
|
-
var Colon$0 = $
|
|
14768
|
+
var Colon$0 = $TS($S($EXPECT($L32, fail, 'Colon ":"'), $N($EXPECT($L2, fail, 'Colon "="'))), function($skip, $loc, $0, $1, $2) {
|
|
14607
14769
|
return { $loc, token: $1 };
|
|
14608
14770
|
});
|
|
14609
14771
|
function Colon(state) {
|
|
@@ -21013,9 +21175,14 @@ ${input.slice(result.pos)}
|
|
|
21013
21175
|
children: [...pre, ...exp.children, post]
|
|
21014
21176
|
};
|
|
21015
21177
|
default:
|
|
21178
|
+
const expression = {
|
|
21179
|
+
...exp,
|
|
21180
|
+
children: [...pre, "(", exp.children, ")", post]
|
|
21181
|
+
};
|
|
21016
21182
|
return {
|
|
21017
21183
|
type: "ParenthesizedExpression",
|
|
21018
|
-
children: ["(",
|
|
21184
|
+
children: ["(", expression, ")"],
|
|
21185
|
+
expression
|
|
21019
21186
|
};
|
|
21020
21187
|
}
|
|
21021
21188
|
}
|
|
@@ -21234,6 +21401,8 @@ ${input.slice(result.pos)}
|
|
|
21234
21401
|
exp.blocks.forEach((block) => insertPush(block, ref));
|
|
21235
21402
|
return;
|
|
21236
21403
|
}
|
|
21404
|
+
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
21405
|
+
return;
|
|
21237
21406
|
node.splice(1, 0, ref, ".push(");
|
|
21238
21407
|
node.push(")");
|
|
21239
21408
|
}
|
|
@@ -21256,12 +21425,6 @@ ${input.slice(result.pos)}
|
|
|
21256
21425
|
return;
|
|
21257
21426
|
}
|
|
21258
21427
|
}
|
|
21259
|
-
function getIndent(statement) {
|
|
21260
|
-
let indent = statement?.[0];
|
|
21261
|
-
if (Array.isArray(indent))
|
|
21262
|
-
indent = indent[indent.length - 1];
|
|
21263
|
-
return indent;
|
|
21264
|
-
}
|
|
21265
21428
|
function insertReturn(node) {
|
|
21266
21429
|
if (!node)
|
|
21267
21430
|
return;
|
|
@@ -21690,14 +21853,6 @@ ${input.slice(result.pos)}
|
|
|
21690
21853
|
}
|
|
21691
21854
|
}
|
|
21692
21855
|
}
|
|
21693
|
-
function findAncestor(node, predicate, stopPredicate) {
|
|
21694
|
-
node = node.parent;
|
|
21695
|
-
while (node && !stopPredicate?.(node)) {
|
|
21696
|
-
if (predicate(node))
|
|
21697
|
-
return node;
|
|
21698
|
-
node = node.parent;
|
|
21699
|
-
}
|
|
21700
|
-
}
|
|
21701
21856
|
module.replaceNodes = (root, predicate, replacer) => {
|
|
21702
21857
|
if (root == null)
|
|
21703
21858
|
return root;
|
|
@@ -21864,7 +22019,7 @@ ${input.slice(result.pos)}
|
|
|
21864
22019
|
}
|
|
21865
22020
|
function processBindingPatternLHS(lhs, tail) {
|
|
21866
22021
|
adjustAtBindings(lhs, true);
|
|
21867
|
-
const [splices, thisAssignments] =
|
|
22022
|
+
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
21868
22023
|
tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
|
|
21869
22024
|
}
|
|
21870
22025
|
function processAssignments(statements) {
|
|
@@ -22454,14 +22609,16 @@ ${input.slice(result.pos)}
|
|
|
22454
22609
|
addParentPointers(s, s.parent);
|
|
22455
22610
|
});
|
|
22456
22611
|
}
|
|
22457
|
-
module.processProgram = function(
|
|
22458
|
-
addParentPointers(
|
|
22612
|
+
module.processProgram = function(root) {
|
|
22613
|
+
addParentPointers(root);
|
|
22614
|
+
const { expressions: statements } = root;
|
|
22459
22615
|
processPipelineExpressions(statements);
|
|
22460
22616
|
processAssignments(statements);
|
|
22461
22617
|
processPatternMatching(statements);
|
|
22462
22618
|
processFunctions(statements);
|
|
22463
22619
|
processSwitchExpressions(statements);
|
|
22464
22620
|
processTryExpressions(statements);
|
|
22621
|
+
hoistRefDecs(statements);
|
|
22465
22622
|
gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
|
|
22466
22623
|
checkSpliceRef(statements);
|
|
22467
22624
|
statements.unshift(...module.prelude);
|
|
@@ -22621,35 +22778,6 @@ ${input.slice(result.pos)}
|
|
|
22621
22778
|
scopes.pop();
|
|
22622
22779
|
statements.splice(0, statements.length, targetStatements);
|
|
22623
22780
|
}
|
|
22624
|
-
function gatherBindingCode(statements, opts) {
|
|
22625
|
-
const thisAssignments = [];
|
|
22626
|
-
const splices = [];
|
|
22627
|
-
function insertRestSplices(s, p, thisAssignments2) {
|
|
22628
|
-
gatherRecursiveAll(s, (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding").forEach((n) => {
|
|
22629
|
-
if (n.type === "AtBinding") {
|
|
22630
|
-
const { ref } = n, { id } = ref;
|
|
22631
|
-
thisAssignments2.push([`this.${id} = `, ref]);
|
|
22632
|
-
return;
|
|
22633
|
-
}
|
|
22634
|
-
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
22635
|
-
n.names.forEach((id) => {
|
|
22636
|
-
thisAssignments2.push({
|
|
22637
|
-
type: "AssignmentExpression",
|
|
22638
|
-
children: [`this.${id} = `, id],
|
|
22639
|
-
js: true
|
|
22640
|
-
});
|
|
22641
|
-
});
|
|
22642
|
-
return;
|
|
22643
|
-
}
|
|
22644
|
-
const { blockPrefix } = n;
|
|
22645
|
-
p.push(blockPrefix);
|
|
22646
|
-
insertRestSplices(blockPrefix, p, thisAssignments2);
|
|
22647
|
-
});
|
|
22648
|
-
}
|
|
22649
|
-
insertRestSplices(statements, splices, thisAssignments);
|
|
22650
|
-
return [splices, thisAssignments];
|
|
22651
|
-
}
|
|
22652
|
-
module.gatherBindingCode = gatherBindingCode;
|
|
22653
22781
|
module.constructInvocation = function(fn, arg) {
|
|
22654
22782
|
const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
|
|
22655
22783
|
let expr = fn.expr;
|
|
@@ -22991,21 +23119,28 @@ ${input.slice(result.pos)}
|
|
|
22991
23119
|
exports.parse = parse2;
|
|
22992
23120
|
exports.default = { parse: parse2 };
|
|
22993
23121
|
var {
|
|
23122
|
+
blockWithPrefix,
|
|
22994
23123
|
clone,
|
|
22995
23124
|
deepCopy,
|
|
23125
|
+
findAncestor,
|
|
22996
23126
|
forRange,
|
|
23127
|
+
gatherBindingCode,
|
|
22997
23128
|
gatherNodes,
|
|
22998
23129
|
gatherRecursive,
|
|
22999
23130
|
gatherRecursiveAll,
|
|
23000
23131
|
gatherRecursiveWithinFunction,
|
|
23132
|
+
getIndent,
|
|
23001
23133
|
getTrimmingSpace,
|
|
23002
23134
|
hasAwait,
|
|
23003
23135
|
hasYield,
|
|
23136
|
+
hoistRefDecs,
|
|
23004
23137
|
insertTrimmingSpace,
|
|
23005
23138
|
isFunction,
|
|
23006
23139
|
literalValue,
|
|
23007
23140
|
modifyString,
|
|
23008
23141
|
processCoffeeInterpolation,
|
|
23142
|
+
processConstAssignmentDeclaration,
|
|
23143
|
+
processLetAssignmentDeclaration,
|
|
23009
23144
|
quoteString,
|
|
23010
23145
|
removeParentPointers
|
|
23011
23146
|
} = require_lib();
|