@danielx/civet 0.5.85 → 0.5.87
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 +274 -142
- package/dist/main.js +274 -142
- package/dist/main.mjs +274 -142
- 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,39 @@ 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.indexOf(outer);
|
|
179
|
+
const indent = getIndent(outer);
|
|
180
|
+
if (indent)
|
|
181
|
+
hoistDec[0][0] = indent;
|
|
182
|
+
expressions.splice(index, 0, hoistDec);
|
|
183
|
+
node.hoistDec = null;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
125
186
|
function isFunction(node) {
|
|
126
187
|
const { type } = node;
|
|
127
188
|
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
@@ -262,13 +323,6 @@ var Civet = (() => {
|
|
|
262
323
|
}
|
|
263
324
|
} else if (forDeclaration) {
|
|
264
325
|
varAssign = varLetAssign = [forDeclaration, " = "];
|
|
265
|
-
blockPrefix = [
|
|
266
|
-
["", {
|
|
267
|
-
type: "AssignmentExpression",
|
|
268
|
-
children: [],
|
|
269
|
-
names: forDeclaration.names
|
|
270
|
-
}]
|
|
271
|
-
];
|
|
272
326
|
}
|
|
273
327
|
const declaration = {
|
|
274
328
|
type: "Declaration",
|
|
@@ -284,6 +338,34 @@ var Civet = (() => {
|
|
|
284
338
|
blockPrefix
|
|
285
339
|
};
|
|
286
340
|
}
|
|
341
|
+
function gatherBindingCode(statements, opts) {
|
|
342
|
+
const thisAssignments = [];
|
|
343
|
+
const splices = [];
|
|
344
|
+
function insertRestSplices(s, p, thisAssignments2) {
|
|
345
|
+
gatherRecursiveAll(s, (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding").forEach((n) => {
|
|
346
|
+
if (n.type === "AtBinding") {
|
|
347
|
+
const { ref } = n, { id } = ref;
|
|
348
|
+
thisAssignments2.push([`this.${id} = `, ref]);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
352
|
+
n.names.forEach((id) => {
|
|
353
|
+
thisAssignments2.push({
|
|
354
|
+
type: "AssignmentExpression",
|
|
355
|
+
children: [`this.${id} = `, id],
|
|
356
|
+
js: true
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const { blockPrefix } = n;
|
|
362
|
+
p.push(blockPrefix);
|
|
363
|
+
insertRestSplices(blockPrefix, p, thisAssignments2);
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
insertRestSplices(statements, splices, thisAssignments);
|
|
367
|
+
return [splices, thisAssignments];
|
|
368
|
+
}
|
|
287
369
|
function modifyString(str) {
|
|
288
370
|
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
289
371
|
}
|
|
@@ -315,22 +397,93 @@ var Civet = (() => {
|
|
|
315
397
|
children: [s, parts, e]
|
|
316
398
|
};
|
|
317
399
|
}
|
|
400
|
+
function processConstAssignmentDeclaration(c, id, suffix, ws, ca, e) {
|
|
401
|
+
c = {
|
|
402
|
+
...c,
|
|
403
|
+
$loc: {
|
|
404
|
+
pos: ca.$loc.pos - 1,
|
|
405
|
+
length: ca.$loc.length + 1
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
let exp;
|
|
409
|
+
if (e.type === "FunctionExpression") {
|
|
410
|
+
exp = e;
|
|
411
|
+
} else {
|
|
412
|
+
exp = e[1];
|
|
413
|
+
}
|
|
414
|
+
if (exp?.children?.[0]?.token?.match(/^\s+$/))
|
|
415
|
+
exp.children.shift();
|
|
416
|
+
if (id.type === "Identifier" && exp?.type === "FunctionExpression" && !exp.id) {
|
|
417
|
+
const i = exp.children.findIndex((c2) => c2?.token === "function") + 1;
|
|
418
|
+
exp = {
|
|
419
|
+
...exp,
|
|
420
|
+
children: [...exp.children.slice(0, i), " ", id, suffix, ws, ...exp.children.slice(i)]
|
|
421
|
+
};
|
|
422
|
+
return {
|
|
423
|
+
type: "Declaration",
|
|
424
|
+
children: [exp],
|
|
425
|
+
names: id.names
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
let [splices, thisAssignments] = gatherBindingCode(id);
|
|
429
|
+
splices = splices.map((s) => [", ", s]);
|
|
430
|
+
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
431
|
+
const binding = [c, id, suffix, ...ws];
|
|
432
|
+
const initializer = [ca, e, ...splices, ...thisAssignments];
|
|
433
|
+
const children = [binding, initializer];
|
|
434
|
+
return {
|
|
435
|
+
type: "Declaration",
|
|
436
|
+
names: id.names,
|
|
437
|
+
children,
|
|
438
|
+
binding,
|
|
439
|
+
initializer
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function processLetAssignmentDeclaration(l, id, suffix, ws, la, e) {
|
|
443
|
+
l = {
|
|
444
|
+
...l,
|
|
445
|
+
$loc: {
|
|
446
|
+
pos: la.$loc.pos - 1,
|
|
447
|
+
length: la.$loc.length + 1
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
let [splices, thisAssignments] = gatherBindingCode(id);
|
|
451
|
+
splices = splices.map((s) => [", ", s]);
|
|
452
|
+
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
453
|
+
const binding = [l, id, suffix, ...ws];
|
|
454
|
+
const initializer = [la, e, ...splices, ...thisAssignments];
|
|
455
|
+
const children = [binding, initializer];
|
|
456
|
+
return {
|
|
457
|
+
type: "Declaration",
|
|
458
|
+
names: id.names,
|
|
459
|
+
children,
|
|
460
|
+
binding,
|
|
461
|
+
initializer
|
|
462
|
+
};
|
|
463
|
+
}
|
|
318
464
|
module.exports = {
|
|
465
|
+
blockWithPrefix,
|
|
319
466
|
clone,
|
|
320
467
|
deepCopy,
|
|
468
|
+
findAncestor,
|
|
321
469
|
forRange,
|
|
470
|
+
gatherBindingCode,
|
|
322
471
|
gatherNodes,
|
|
323
472
|
gatherRecursive,
|
|
324
473
|
gatherRecursiveAll,
|
|
325
474
|
gatherRecursiveWithinFunction,
|
|
475
|
+
getIndent,
|
|
326
476
|
getTrimmingSpace,
|
|
327
477
|
hasAwait,
|
|
328
478
|
hasYield,
|
|
479
|
+
hoistRefDecs,
|
|
329
480
|
insertTrimmingSpace,
|
|
330
481
|
isFunction,
|
|
331
482
|
literalValue,
|
|
332
483
|
modifyString,
|
|
333
484
|
processCoffeeInterpolation,
|
|
485
|
+
processConstAssignmentDeclaration,
|
|
486
|
+
processLetAssignmentDeclaration,
|
|
334
487
|
quoteString,
|
|
335
488
|
removeParentPointers
|
|
336
489
|
};
|
|
@@ -1013,6 +1166,7 @@ ${input.slice(result.pos)}
|
|
|
1013
1166
|
FinallyClause,
|
|
1014
1167
|
CatchParameter,
|
|
1015
1168
|
Condition,
|
|
1169
|
+
DeclarationCondition,
|
|
1016
1170
|
ExpressionWithIndentedApplicationForbidden,
|
|
1017
1171
|
ForbidClassImplicitCall,
|
|
1018
1172
|
AllowClassImplicitCall,
|
|
@@ -1627,7 +1781,12 @@ ${input.slice(result.pos)}
|
|
|
1627
1781
|
var $R65 = $R(new RegExp("[ \\t]*", "suy"));
|
|
1628
1782
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
1629
1783
|
var statements = $4;
|
|
1630
|
-
module.processProgram(
|
|
1784
|
+
module.processProgram({
|
|
1785
|
+
type: "BlockStatement",
|
|
1786
|
+
expressions: statements,
|
|
1787
|
+
children: [statements],
|
|
1788
|
+
bare: true
|
|
1789
|
+
});
|
|
1631
1790
|
return $0;
|
|
1632
1791
|
});
|
|
1633
1792
|
function Program(state) {
|
|
@@ -9234,16 +9393,18 @@ ${input.slice(result.pos)}
|
|
|
9234
9393
|
var clause = $1;
|
|
9235
9394
|
var block = $2;
|
|
9236
9395
|
var e = $3;
|
|
9237
|
-
const children = [...clause.children
|
|
9396
|
+
const children = [...clause.children];
|
|
9397
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9398
|
+
children.push(block);
|
|
9238
9399
|
if (block.bare && e)
|
|
9239
9400
|
children.push(";");
|
|
9240
9401
|
if (e)
|
|
9241
9402
|
children.push(e);
|
|
9242
9403
|
return {
|
|
9243
|
-
|
|
9404
|
+
...clause,
|
|
9405
|
+
children,
|
|
9244
9406
|
then: block,
|
|
9245
|
-
else: e
|
|
9246
|
-
children
|
|
9407
|
+
else: e
|
|
9247
9408
|
};
|
|
9248
9409
|
});
|
|
9249
9410
|
function IfStatement(state) {
|
|
@@ -9292,8 +9453,13 @@ ${input.slice(result.pos)}
|
|
|
9292
9453
|
return result;
|
|
9293
9454
|
}
|
|
9294
9455
|
}
|
|
9295
|
-
var IfClause$0 = $
|
|
9296
|
-
|
|
9456
|
+
var IfClause$0 = $TS($S(If, Condition), function($skip, $loc, $0, $1, $2) {
|
|
9457
|
+
var condition = $2;
|
|
9458
|
+
return {
|
|
9459
|
+
type: "IfStatement",
|
|
9460
|
+
children: $0,
|
|
9461
|
+
condition
|
|
9462
|
+
};
|
|
9297
9463
|
});
|
|
9298
9464
|
function IfClause(state) {
|
|
9299
9465
|
let eventData;
|
|
@@ -9323,7 +9489,8 @@ ${input.slice(result.pos)}
|
|
|
9323
9489
|
kind = { ...kind, token: "if" };
|
|
9324
9490
|
return {
|
|
9325
9491
|
type: "IfStatement",
|
|
9326
|
-
children: [kind, ["(!", condition, ")"]]
|
|
9492
|
+
children: [kind, ["(!", condition, ")"]],
|
|
9493
|
+
condition
|
|
9327
9494
|
};
|
|
9328
9495
|
});
|
|
9329
9496
|
function UnlessClause(state) {
|
|
@@ -9792,8 +9959,9 @@ ${input.slice(result.pos)}
|
|
|
9792
9959
|
var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9793
9960
|
var clause = $1;
|
|
9794
9961
|
var block = $2;
|
|
9962
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9795
9963
|
return {
|
|
9796
|
-
|
|
9964
|
+
...clause,
|
|
9797
9965
|
children: [...clause.children, block],
|
|
9798
9966
|
block
|
|
9799
9967
|
};
|
|
@@ -9823,17 +9991,19 @@ ${input.slice(result.pos)}
|
|
|
9823
9991
|
var WhileClause$0 = $TS($S($C(While, Until), $E(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
|
|
9824
9992
|
var kind = $1;
|
|
9825
9993
|
var ws = $2;
|
|
9826
|
-
var
|
|
9994
|
+
var condition = $3;
|
|
9827
9995
|
if (kind.token === "until") {
|
|
9828
9996
|
kind.token = "while";
|
|
9829
9997
|
return {
|
|
9830
9998
|
type: "IterationStatement",
|
|
9831
|
-
children: [kind, ...ws, ["(!", ...
|
|
9999
|
+
children: [kind, ...ws, ["(!", ...condition.children, ")"]],
|
|
10000
|
+
condition
|
|
9832
10001
|
};
|
|
9833
10002
|
}
|
|
9834
10003
|
return {
|
|
9835
10004
|
type: "IterationStatement",
|
|
9836
|
-
children: [kind, ...ws, ...
|
|
10005
|
+
children: [kind, ...ws, ...condition.children],
|
|
10006
|
+
condition
|
|
9837
10007
|
};
|
|
9838
10008
|
});
|
|
9839
10009
|
function WhileClause(state) {
|
|
@@ -9861,18 +10031,7 @@ ${input.slice(result.pos)}
|
|
|
9861
10031
|
var ForStatement$0 = $TS($S(ForClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9862
10032
|
var clause = $1;
|
|
9863
10033
|
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
|
-
}
|
|
10034
|
+
block = blockWithPrefix(clause.blockPrefix, block);
|
|
9876
10035
|
return {
|
|
9877
10036
|
...clause,
|
|
9878
10037
|
children: [...clause.children, block],
|
|
@@ -10927,10 +11086,31 @@ ${input.slice(result.pos)}
|
|
|
10927
11086
|
return result;
|
|
10928
11087
|
}
|
|
10929
11088
|
}
|
|
10930
|
-
var Condition$0 = $
|
|
11089
|
+
var Condition$0 = $TS($S(OpenParen, $E(_), DeclarationCondition, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
11090
|
+
var open = $1;
|
|
11091
|
+
var ws = $2;
|
|
11092
|
+
var expression = $3;
|
|
11093
|
+
var close = $4;
|
|
11094
|
+
return {
|
|
11095
|
+
type: "ParenthesizedExpression",
|
|
11096
|
+
children: [open, ws, expression, close],
|
|
11097
|
+
expression
|
|
11098
|
+
};
|
|
11099
|
+
});
|
|
11100
|
+
var Condition$1 = $T($S(ParenthesizedExpression, $N($S($E(_), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
|
|
10931
11101
|
return value[0];
|
|
10932
11102
|
});
|
|
10933
|
-
var Condition$
|
|
11103
|
+
var Condition$2 = $TS($S(InsertOpenParen, DeclarationCondition, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
|
|
11104
|
+
var open = $1;
|
|
11105
|
+
var expression = $2;
|
|
11106
|
+
var close = $3;
|
|
11107
|
+
return {
|
|
11108
|
+
type: "ParenthesizedExpression",
|
|
11109
|
+
children: [open, expression, close],
|
|
11110
|
+
expression
|
|
11111
|
+
};
|
|
11112
|
+
});
|
|
11113
|
+
var Condition$3 = $TS($S(InsertOpenParen, ExpressionWithIndentedApplicationForbidden, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
|
|
10934
11114
|
var open = $1;
|
|
10935
11115
|
var expression = $2;
|
|
10936
11116
|
var close = $3;
|
|
@@ -10954,17 +11134,54 @@ ${input.slice(result.pos)}
|
|
|
10954
11134
|
}
|
|
10955
11135
|
}
|
|
10956
11136
|
if (state.tokenize) {
|
|
10957
|
-
const result = $TOKEN("Condition", state, Condition$0(state) || Condition$1(state));
|
|
11137
|
+
const result = $TOKEN("Condition", state, Condition$0(state) || Condition$1(state) || Condition$2(state) || Condition$3(state));
|
|
10958
11138
|
if (state.events)
|
|
10959
11139
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10960
11140
|
return result;
|
|
10961
11141
|
} else {
|
|
10962
|
-
const result = Condition$0(state) || Condition$1(state);
|
|
11142
|
+
const result = Condition$0(state) || Condition$1(state) || Condition$2(state) || Condition$3(state);
|
|
10963
11143
|
if (state.events)
|
|
10964
11144
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10965
11145
|
return result;
|
|
10966
11146
|
}
|
|
10967
11147
|
}
|
|
11148
|
+
var DeclarationCondition$0 = $TV(LexicalDeclaration, function($skip, $loc, $0, $1) {
|
|
11149
|
+
var dec = $0;
|
|
11150
|
+
const ref = {
|
|
11151
|
+
type: "Ref",
|
|
11152
|
+
base: "ref"
|
|
11153
|
+
};
|
|
11154
|
+
const { binding, initializer } = dec;
|
|
11155
|
+
const initCondition = {
|
|
11156
|
+
type: "AssignmentExpression",
|
|
11157
|
+
children: [ref, " ", initializer],
|
|
11158
|
+
hoistDec: [["", ["let ", ref], ";\n"]],
|
|
11159
|
+
blockPrefix: [["", [binding, "= ", ref], ";\n"]]
|
|
11160
|
+
};
|
|
11161
|
+
return initCondition;
|
|
11162
|
+
});
|
|
11163
|
+
function DeclarationCondition(state) {
|
|
11164
|
+
let eventData;
|
|
11165
|
+
if (state.events) {
|
|
11166
|
+
const result = state.events.enter?.("DeclarationCondition", state);
|
|
11167
|
+
if (result) {
|
|
11168
|
+
if (result.cache)
|
|
11169
|
+
return result.cache;
|
|
11170
|
+
eventData = result.data;
|
|
11171
|
+
}
|
|
11172
|
+
}
|
|
11173
|
+
if (state.tokenize) {
|
|
11174
|
+
const result = $TOKEN("DeclarationCondition", state, DeclarationCondition$0(state));
|
|
11175
|
+
if (state.events)
|
|
11176
|
+
state.events.exit?.("DeclarationCondition", state, result, eventData);
|
|
11177
|
+
return result;
|
|
11178
|
+
} else {
|
|
11179
|
+
const result = DeclarationCondition$0(state);
|
|
11180
|
+
if (state.events)
|
|
11181
|
+
state.events.exit?.("DeclarationCondition", state, result, eventData);
|
|
11182
|
+
return result;
|
|
11183
|
+
}
|
|
11184
|
+
}
|
|
10968
11185
|
var ExpressionWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ExtendedExpression), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
|
|
10969
11186
|
var exp = $2;
|
|
10970
11187
|
if (exp)
|
|
@@ -12393,48 +12610,7 @@ ${input.slice(result.pos)}
|
|
|
12393
12610
|
};
|
|
12394
12611
|
});
|
|
12395
12612
|
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
|
-
};
|
|
12613
|
+
return processConstAssignmentDeclaration(...$0);
|
|
12438
12614
|
});
|
|
12439
12615
|
var LexicalDeclaration$2 = $TS($S(InsertLet, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, LetAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
12440
12616
|
var l = $1;
|
|
@@ -12443,22 +12619,7 @@ ${input.slice(result.pos)}
|
|
|
12443
12619
|
var ws = $4;
|
|
12444
12620
|
var la = $5;
|
|
12445
12621
|
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
|
-
};
|
|
12622
|
+
return processLetAssignmentDeclaration(...$0);
|
|
12462
12623
|
});
|
|
12463
12624
|
function LexicalDeclaration(state) {
|
|
12464
12625
|
let eventData;
|
|
@@ -14603,7 +14764,7 @@ ${input.slice(result.pos)}
|
|
|
14603
14764
|
return result;
|
|
14604
14765
|
}
|
|
14605
14766
|
}
|
|
14606
|
-
var Colon$0 = $
|
|
14767
|
+
var Colon$0 = $TS($S($EXPECT($L32, fail, 'Colon ":"'), $N($EXPECT($L2, fail, 'Colon "="'))), function($skip, $loc, $0, $1, $2) {
|
|
14607
14768
|
return { $loc, token: $1 };
|
|
14608
14769
|
});
|
|
14609
14770
|
function Colon(state) {
|
|
@@ -19533,7 +19694,7 @@ ${input.slice(result.pos)}
|
|
|
19533
19694
|
return result;
|
|
19534
19695
|
}
|
|
19535
19696
|
}
|
|
19536
|
-
var ThisType$0 = $T($S($C(This, AtThis), Colon, Type), function(value) {
|
|
19697
|
+
var ThisType$0 = $T($S($C(This, AtThis), Colon, Type, ParameterElementDelimiter), function(value) {
|
|
19537
19698
|
return { "type": "ThisType", "ts": true, "children": value };
|
|
19538
19699
|
});
|
|
19539
19700
|
function ThisType(state) {
|
|
@@ -21013,9 +21174,14 @@ ${input.slice(result.pos)}
|
|
|
21013
21174
|
children: [...pre, ...exp.children, post]
|
|
21014
21175
|
};
|
|
21015
21176
|
default:
|
|
21177
|
+
const expression = {
|
|
21178
|
+
...exp,
|
|
21179
|
+
children: [...pre, "(", exp.children, ")", post]
|
|
21180
|
+
};
|
|
21016
21181
|
return {
|
|
21017
21182
|
type: "ParenthesizedExpression",
|
|
21018
|
-
children: ["(",
|
|
21183
|
+
children: ["(", expression, ")"],
|
|
21184
|
+
expression
|
|
21019
21185
|
};
|
|
21020
21186
|
}
|
|
21021
21187
|
}
|
|
@@ -21256,12 +21422,6 @@ ${input.slice(result.pos)}
|
|
|
21256
21422
|
return;
|
|
21257
21423
|
}
|
|
21258
21424
|
}
|
|
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
21425
|
function insertReturn(node) {
|
|
21266
21426
|
if (!node)
|
|
21267
21427
|
return;
|
|
@@ -21690,14 +21850,6 @@ ${input.slice(result.pos)}
|
|
|
21690
21850
|
}
|
|
21691
21851
|
}
|
|
21692
21852
|
}
|
|
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
21853
|
module.replaceNodes = (root, predicate, replacer) => {
|
|
21702
21854
|
if (root == null)
|
|
21703
21855
|
return root;
|
|
@@ -21864,7 +22016,7 @@ ${input.slice(result.pos)}
|
|
|
21864
22016
|
}
|
|
21865
22017
|
function processBindingPatternLHS(lhs, tail) {
|
|
21866
22018
|
adjustAtBindings(lhs, true);
|
|
21867
|
-
const [splices, thisAssignments] =
|
|
22019
|
+
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
21868
22020
|
tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
|
|
21869
22021
|
}
|
|
21870
22022
|
function processAssignments(statements) {
|
|
@@ -22454,14 +22606,16 @@ ${input.slice(result.pos)}
|
|
|
22454
22606
|
addParentPointers(s, s.parent);
|
|
22455
22607
|
});
|
|
22456
22608
|
}
|
|
22457
|
-
module.processProgram = function(
|
|
22458
|
-
addParentPointers(
|
|
22609
|
+
module.processProgram = function(root) {
|
|
22610
|
+
addParentPointers(root);
|
|
22611
|
+
const { expressions: statements } = root;
|
|
22459
22612
|
processPipelineExpressions(statements);
|
|
22460
22613
|
processAssignments(statements);
|
|
22461
22614
|
processPatternMatching(statements);
|
|
22462
22615
|
processFunctions(statements);
|
|
22463
22616
|
processSwitchExpressions(statements);
|
|
22464
22617
|
processTryExpressions(statements);
|
|
22618
|
+
hoistRefDecs(statements);
|
|
22465
22619
|
gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
|
|
22466
22620
|
checkSpliceRef(statements);
|
|
22467
22621
|
statements.unshift(...module.prelude);
|
|
@@ -22621,35 +22775,6 @@ ${input.slice(result.pos)}
|
|
|
22621
22775
|
scopes.pop();
|
|
22622
22776
|
statements.splice(0, statements.length, targetStatements);
|
|
22623
22777
|
}
|
|
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
22778
|
module.constructInvocation = function(fn, arg) {
|
|
22654
22779
|
const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
|
|
22655
22780
|
let expr = fn.expr;
|
|
@@ -22991,21 +23116,28 @@ ${input.slice(result.pos)}
|
|
|
22991
23116
|
exports.parse = parse2;
|
|
22992
23117
|
exports.default = { parse: parse2 };
|
|
22993
23118
|
var {
|
|
23119
|
+
blockWithPrefix,
|
|
22994
23120
|
clone,
|
|
22995
23121
|
deepCopy,
|
|
23122
|
+
findAncestor,
|
|
22996
23123
|
forRange,
|
|
23124
|
+
gatherBindingCode,
|
|
22997
23125
|
gatherNodes,
|
|
22998
23126
|
gatherRecursive,
|
|
22999
23127
|
gatherRecursiveAll,
|
|
23000
23128
|
gatherRecursiveWithinFunction,
|
|
23129
|
+
getIndent,
|
|
23001
23130
|
getTrimmingSpace,
|
|
23002
23131
|
hasAwait,
|
|
23003
23132
|
hasYield,
|
|
23133
|
+
hoistRefDecs,
|
|
23004
23134
|
insertTrimmingSpace,
|
|
23005
23135
|
isFunction,
|
|
23006
23136
|
literalValue,
|
|
23007
23137
|
modifyString,
|
|
23008
23138
|
processCoffeeInterpolation,
|
|
23139
|
+
processConstAssignmentDeclaration,
|
|
23140
|
+
processLetAssignmentDeclaration,
|
|
23009
23141
|
quoteString,
|
|
23010
23142
|
removeParentPointers
|
|
23011
23143
|
} = require_lib();
|