@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/main.js
CHANGED
|
@@ -30,6 +30,32 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var require_lib = __commonJS({
|
|
31
31
|
"source/lib.js"(exports, module2) {
|
|
32
32
|
"use strict";
|
|
33
|
+
function blockWithPrefix(prefixStatements, block) {
|
|
34
|
+
if (prefixStatements && prefixStatements.length) {
|
|
35
|
+
const indent = getIndent(block.expressions[0]);
|
|
36
|
+
if (indent) {
|
|
37
|
+
prefixStatements = prefixStatements.map((statement) => [indent, ...statement.slice(1)]);
|
|
38
|
+
}
|
|
39
|
+
const expressions = [...prefixStatements, ...block.expressions];
|
|
40
|
+
block = {
|
|
41
|
+
...block,
|
|
42
|
+
expressions,
|
|
43
|
+
children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
|
|
44
|
+
};
|
|
45
|
+
if (block.bare) {
|
|
46
|
+
block.children = [[" {\n", indent], ...block.children, "}"];
|
|
47
|
+
block.bare = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return block;
|
|
51
|
+
}
|
|
52
|
+
function closest(node, types) {
|
|
53
|
+
do {
|
|
54
|
+
if (types.includes(node.type)) {
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
57
|
+
} while (node = node.parent);
|
|
58
|
+
}
|
|
33
59
|
function clone(node) {
|
|
34
60
|
removeParentPointers(node);
|
|
35
61
|
return deepCopy(node);
|
|
@@ -66,6 +92,14 @@ var require_lib = __commonJS({
|
|
|
66
92
|
}
|
|
67
93
|
}
|
|
68
94
|
}
|
|
95
|
+
function findAncestor(node, predicate, stopPredicate) {
|
|
96
|
+
node = node.parent;
|
|
97
|
+
while (node && !stopPredicate?.(node)) {
|
|
98
|
+
if (predicate(node))
|
|
99
|
+
return node;
|
|
100
|
+
node = node.parent;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
69
103
|
function gatherNodes(node, predicate) {
|
|
70
104
|
if (node == null)
|
|
71
105
|
return [];
|
|
@@ -115,12 +149,40 @@ var require_lib = __commonJS({
|
|
|
115
149
|
}
|
|
116
150
|
return nodes;
|
|
117
151
|
}
|
|
152
|
+
function getIndent(statement) {
|
|
153
|
+
let indent = statement?.[0];
|
|
154
|
+
if (Array.isArray(indent))
|
|
155
|
+
indent = indent[indent.length - 1];
|
|
156
|
+
return indent;
|
|
157
|
+
}
|
|
118
158
|
function hasAwait(exp) {
|
|
119
159
|
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
|
|
120
160
|
}
|
|
121
161
|
function hasYield(exp) {
|
|
122
162
|
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
|
|
123
163
|
}
|
|
164
|
+
function hoistRefDecs(statements) {
|
|
165
|
+
gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
|
|
166
|
+
const { hoistDec } = node;
|
|
167
|
+
const outer = closest(node, ["IfStatement", "IterationStatement"]);
|
|
168
|
+
if (!outer) {
|
|
169
|
+
node.children.push({
|
|
170
|
+
type: "Error",
|
|
171
|
+
message: "Can't hoist declarations inside expressions yet."
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const block = outer.parent;
|
|
176
|
+
const { expressions } = block;
|
|
177
|
+
const index = expressions.findIndex(([, s]) => outer === s);
|
|
178
|
+
if (index < 0)
|
|
179
|
+
throw new Error("Couldn't find expression in block for hoistable declaration.");
|
|
180
|
+
const indent = expressions[index][0];
|
|
181
|
+
hoistDec[0][0] = indent;
|
|
182
|
+
expressions.splice(index, 0, hoistDec);
|
|
183
|
+
node.hoistDec = null;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
124
186
|
function isFunction(node) {
|
|
125
187
|
const { type } = node;
|
|
126
188
|
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
@@ -261,13 +323,6 @@ var require_lib = __commonJS({
|
|
|
261
323
|
}
|
|
262
324
|
} else if (forDeclaration) {
|
|
263
325
|
varAssign = varLetAssign = [forDeclaration, " = "];
|
|
264
|
-
blockPrefix = [
|
|
265
|
-
["", {
|
|
266
|
-
type: "AssignmentExpression",
|
|
267
|
-
children: [],
|
|
268
|
-
names: forDeclaration.names
|
|
269
|
-
}]
|
|
270
|
-
];
|
|
271
326
|
}
|
|
272
327
|
const declaration = {
|
|
273
328
|
type: "Declaration",
|
|
@@ -283,6 +338,34 @@ var require_lib = __commonJS({
|
|
|
283
338
|
blockPrefix
|
|
284
339
|
};
|
|
285
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
|
+
}
|
|
286
369
|
function modifyString(str) {
|
|
287
370
|
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
288
371
|
}
|
|
@@ -314,22 +397,93 @@ var require_lib = __commonJS({
|
|
|
314
397
|
children: [s, parts, e]
|
|
315
398
|
};
|
|
316
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
|
+
}
|
|
317
464
|
module2.exports = {
|
|
465
|
+
blockWithPrefix,
|
|
318
466
|
clone,
|
|
319
467
|
deepCopy,
|
|
468
|
+
findAncestor,
|
|
320
469
|
forRange,
|
|
470
|
+
gatherBindingCode,
|
|
321
471
|
gatherNodes,
|
|
322
472
|
gatherRecursive,
|
|
323
473
|
gatherRecursiveAll,
|
|
324
474
|
gatherRecursiveWithinFunction,
|
|
475
|
+
getIndent,
|
|
325
476
|
getTrimmingSpace,
|
|
326
477
|
hasAwait,
|
|
327
478
|
hasYield,
|
|
479
|
+
hoistRefDecs,
|
|
328
480
|
insertTrimmingSpace,
|
|
329
481
|
isFunction,
|
|
330
482
|
literalValue,
|
|
331
483
|
modifyString,
|
|
332
484
|
processCoffeeInterpolation,
|
|
485
|
+
processConstAssignmentDeclaration,
|
|
486
|
+
processLetAssignmentDeclaration,
|
|
333
487
|
quoteString,
|
|
334
488
|
removeParentPointers
|
|
335
489
|
};
|
|
@@ -1012,6 +1166,7 @@ ${input.slice(result.pos)}
|
|
|
1012
1166
|
FinallyClause,
|
|
1013
1167
|
CatchParameter,
|
|
1014
1168
|
Condition,
|
|
1169
|
+
DeclarationCondition,
|
|
1015
1170
|
ExpressionWithIndentedApplicationForbidden,
|
|
1016
1171
|
ForbidClassImplicitCall,
|
|
1017
1172
|
AllowClassImplicitCall,
|
|
@@ -1626,7 +1781,12 @@ ${input.slice(result.pos)}
|
|
|
1626
1781
|
var $R65 = $R(new RegExp("[ \\t]*", "suy"));
|
|
1627
1782
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
1628
1783
|
var statements = $4;
|
|
1629
|
-
module2.processProgram(
|
|
1784
|
+
module2.processProgram({
|
|
1785
|
+
type: "BlockStatement",
|
|
1786
|
+
expressions: statements,
|
|
1787
|
+
children: [statements],
|
|
1788
|
+
bare: true
|
|
1789
|
+
});
|
|
1630
1790
|
return $0;
|
|
1631
1791
|
});
|
|
1632
1792
|
function Program(state) {
|
|
@@ -9233,16 +9393,18 @@ ${input.slice(result.pos)}
|
|
|
9233
9393
|
var clause = $1;
|
|
9234
9394
|
var block = $2;
|
|
9235
9395
|
var e = $3;
|
|
9236
|
-
const children = [...clause.children
|
|
9396
|
+
const children = [...clause.children];
|
|
9397
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9398
|
+
children.push(block);
|
|
9237
9399
|
if (block.bare && e)
|
|
9238
9400
|
children.push(";");
|
|
9239
9401
|
if (e)
|
|
9240
9402
|
children.push(e);
|
|
9241
9403
|
return {
|
|
9242
|
-
|
|
9404
|
+
...clause,
|
|
9405
|
+
children,
|
|
9243
9406
|
then: block,
|
|
9244
|
-
else: e
|
|
9245
|
-
children
|
|
9407
|
+
else: e
|
|
9246
9408
|
};
|
|
9247
9409
|
});
|
|
9248
9410
|
function IfStatement(state) {
|
|
@@ -9291,8 +9453,13 @@ ${input.slice(result.pos)}
|
|
|
9291
9453
|
return result;
|
|
9292
9454
|
}
|
|
9293
9455
|
}
|
|
9294
|
-
var IfClause$0 = $
|
|
9295
|
-
|
|
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
|
+
};
|
|
9296
9463
|
});
|
|
9297
9464
|
function IfClause(state) {
|
|
9298
9465
|
let eventData;
|
|
@@ -9322,7 +9489,8 @@ ${input.slice(result.pos)}
|
|
|
9322
9489
|
kind = { ...kind, token: "if" };
|
|
9323
9490
|
return {
|
|
9324
9491
|
type: "IfStatement",
|
|
9325
|
-
children: [kind, ["(!", condition, ")"]]
|
|
9492
|
+
children: [kind, ["(!", condition, ")"]],
|
|
9493
|
+
condition
|
|
9326
9494
|
};
|
|
9327
9495
|
});
|
|
9328
9496
|
function UnlessClause(state) {
|
|
@@ -9791,8 +9959,9 @@ ${input.slice(result.pos)}
|
|
|
9791
9959
|
var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9792
9960
|
var clause = $1;
|
|
9793
9961
|
var block = $2;
|
|
9962
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9794
9963
|
return {
|
|
9795
|
-
|
|
9964
|
+
...clause,
|
|
9796
9965
|
children: [...clause.children, block],
|
|
9797
9966
|
block
|
|
9798
9967
|
};
|
|
@@ -9822,17 +9991,19 @@ ${input.slice(result.pos)}
|
|
|
9822
9991
|
var WhileClause$0 = $TS($S($C(While, Until), $E(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
|
|
9823
9992
|
var kind = $1;
|
|
9824
9993
|
var ws = $2;
|
|
9825
|
-
var
|
|
9994
|
+
var condition = $3;
|
|
9826
9995
|
if (kind.token === "until") {
|
|
9827
9996
|
kind.token = "while";
|
|
9828
9997
|
return {
|
|
9829
9998
|
type: "IterationStatement",
|
|
9830
|
-
children: [kind, ...ws, ["(!", ...
|
|
9999
|
+
children: [kind, ...ws, ["(!", ...condition.children, ")"]],
|
|
10000
|
+
condition
|
|
9831
10001
|
};
|
|
9832
10002
|
}
|
|
9833
10003
|
return {
|
|
9834
10004
|
type: "IterationStatement",
|
|
9835
|
-
children: [kind, ...ws, ...
|
|
10005
|
+
children: [kind, ...ws, ...condition.children],
|
|
10006
|
+
condition
|
|
9836
10007
|
};
|
|
9837
10008
|
});
|
|
9838
10009
|
function WhileClause(state) {
|
|
@@ -9860,18 +10031,7 @@ ${input.slice(result.pos)}
|
|
|
9860
10031
|
var ForStatement$0 = $TS($S(ForClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9861
10032
|
var clause = $1;
|
|
9862
10033
|
var block = $2;
|
|
9863
|
-
|
|
9864
|
-
const expressions = [...clause.blockPrefix, ...block.expressions];
|
|
9865
|
-
block = {
|
|
9866
|
-
...block,
|
|
9867
|
-
expressions,
|
|
9868
|
-
children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
|
|
9869
|
-
};
|
|
9870
|
-
if (block.bare) {
|
|
9871
|
-
block.children = [" {\n", ...block.children, "\n}"];
|
|
9872
|
-
block.bare = false;
|
|
9873
|
-
}
|
|
9874
|
-
}
|
|
10034
|
+
block = blockWithPrefix(clause.blockPrefix, block);
|
|
9875
10035
|
return {
|
|
9876
10036
|
...clause,
|
|
9877
10037
|
children: [...clause.children, block],
|
|
@@ -10926,10 +11086,31 @@ ${input.slice(result.pos)}
|
|
|
10926
11086
|
return result;
|
|
10927
11087
|
}
|
|
10928
11088
|
}
|
|
10929
|
-
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) {
|
|
10930
11101
|
return value[0];
|
|
10931
11102
|
});
|
|
10932
|
-
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) {
|
|
10933
11114
|
var open = $1;
|
|
10934
11115
|
var expression = $2;
|
|
10935
11116
|
var close = $3;
|
|
@@ -10953,17 +11134,54 @@ ${input.slice(result.pos)}
|
|
|
10953
11134
|
}
|
|
10954
11135
|
}
|
|
10955
11136
|
if (state.tokenize) {
|
|
10956
|
-
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));
|
|
10957
11138
|
if (state.events)
|
|
10958
11139
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10959
11140
|
return result;
|
|
10960
11141
|
} else {
|
|
10961
|
-
const result = Condition$0(state) || Condition$1(state);
|
|
11142
|
+
const result = Condition$0(state) || Condition$1(state) || Condition$2(state) || Condition$3(state);
|
|
10962
11143
|
if (state.events)
|
|
10963
11144
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10964
11145
|
return result;
|
|
10965
11146
|
}
|
|
10966
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], ";"]],
|
|
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
|
+
}
|
|
10967
11185
|
var ExpressionWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ExtendedExpression), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
|
|
10968
11186
|
var exp = $2;
|
|
10969
11187
|
if (exp)
|
|
@@ -12392,48 +12610,7 @@ ${input.slice(result.pos)}
|
|
|
12392
12610
|
};
|
|
12393
12611
|
});
|
|
12394
12612
|
var LexicalDeclaration$1 = $TS($S(InsertConst, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
12395
|
-
|
|
12396
|
-
var id = $2;
|
|
12397
|
-
var suffix = $3;
|
|
12398
|
-
var ws = $4;
|
|
12399
|
-
var ca = $5;
|
|
12400
|
-
var e = $6;
|
|
12401
|
-
c = {
|
|
12402
|
-
...c,
|
|
12403
|
-
$loc: {
|
|
12404
|
-
pos: ca.$loc.pos - 1,
|
|
12405
|
-
length: ca.$loc.length + 1
|
|
12406
|
-
}
|
|
12407
|
-
};
|
|
12408
|
-
let exp;
|
|
12409
|
-
if (e.type === "FunctionExpression") {
|
|
12410
|
-
exp = e;
|
|
12411
|
-
} else {
|
|
12412
|
-
exp = e[1];
|
|
12413
|
-
}
|
|
12414
|
-
if (exp?.children?.[0]?.token?.match(/^\s+$/))
|
|
12415
|
-
exp.children.shift();
|
|
12416
|
-
if (id.type === "Identifier" && exp?.type === "FunctionExpression" && !exp.id) {
|
|
12417
|
-
const i = exp.children.findIndex((c2) => c2?.token === "function") + 1;
|
|
12418
|
-
exp = {
|
|
12419
|
-
...exp,
|
|
12420
|
-
children: [...exp.children.slice(0, i), " ", id, $3, $4, ...exp.children.slice(i)]
|
|
12421
|
-
};
|
|
12422
|
-
return {
|
|
12423
|
-
type: "Declaration",
|
|
12424
|
-
children: [exp],
|
|
12425
|
-
names: id.names
|
|
12426
|
-
};
|
|
12427
|
-
}
|
|
12428
|
-
let [splices, thisAssignments] = module2.gatherBindingCode(id);
|
|
12429
|
-
splices = splices.map((s) => [", ", s]);
|
|
12430
|
-
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
12431
|
-
const children = [c, id, suffix, ...ws, ca, e, ...splices, ...thisAssignments];
|
|
12432
|
-
return {
|
|
12433
|
-
type: "Declaration",
|
|
12434
|
-
names: id.names,
|
|
12435
|
-
children
|
|
12436
|
-
};
|
|
12613
|
+
return processConstAssignmentDeclaration(...$0);
|
|
12437
12614
|
});
|
|
12438
12615
|
var LexicalDeclaration$2 = $TS($S(InsertLet, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, LetAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
12439
12616
|
var l = $1;
|
|
@@ -12442,22 +12619,7 @@ ${input.slice(result.pos)}
|
|
|
12442
12619
|
var ws = $4;
|
|
12443
12620
|
var la = $5;
|
|
12444
12621
|
var e = $6;
|
|
12445
|
-
|
|
12446
|
-
...l,
|
|
12447
|
-
$loc: {
|
|
12448
|
-
pos: la.$loc.pos - 1,
|
|
12449
|
-
length: la.$loc.length + 1
|
|
12450
|
-
}
|
|
12451
|
-
};
|
|
12452
|
-
let [splices, thisAssignments] = module2.gatherBindingCode(id);
|
|
12453
|
-
splices = splices.map((s) => [", ", s]);
|
|
12454
|
-
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
12455
|
-
const children = [l, id, suffix, ...ws, la, e, ...splices, ...thisAssignments];
|
|
12456
|
-
return {
|
|
12457
|
-
type: "Declaration",
|
|
12458
|
-
names: id.names,
|
|
12459
|
-
children
|
|
12460
|
-
};
|
|
12622
|
+
return processLetAssignmentDeclaration(...$0);
|
|
12461
12623
|
});
|
|
12462
12624
|
function LexicalDeclaration(state) {
|
|
12463
12625
|
let eventData;
|
|
@@ -14602,7 +14764,7 @@ ${input.slice(result.pos)}
|
|
|
14602
14764
|
return result;
|
|
14603
14765
|
}
|
|
14604
14766
|
}
|
|
14605
|
-
var Colon$0 = $
|
|
14767
|
+
var Colon$0 = $TS($S($EXPECT($L32, fail, 'Colon ":"'), $N($EXPECT($L2, fail, 'Colon "="'))), function($skip, $loc, $0, $1, $2) {
|
|
14606
14768
|
return { $loc, token: $1 };
|
|
14607
14769
|
});
|
|
14608
14770
|
function Colon(state) {
|
|
@@ -21012,9 +21174,14 @@ ${input.slice(result.pos)}
|
|
|
21012
21174
|
children: [...pre, ...exp.children, post]
|
|
21013
21175
|
};
|
|
21014
21176
|
default:
|
|
21177
|
+
const expression = {
|
|
21178
|
+
...exp,
|
|
21179
|
+
children: [...pre, "(", exp.children, ")", post]
|
|
21180
|
+
};
|
|
21015
21181
|
return {
|
|
21016
21182
|
type: "ParenthesizedExpression",
|
|
21017
|
-
children: ["(",
|
|
21183
|
+
children: ["(", expression, ")"],
|
|
21184
|
+
expression
|
|
21018
21185
|
};
|
|
21019
21186
|
}
|
|
21020
21187
|
}
|
|
@@ -21233,6 +21400,8 @@ ${input.slice(result.pos)}
|
|
|
21233
21400
|
exp.blocks.forEach((block) => insertPush(block, ref));
|
|
21234
21401
|
return;
|
|
21235
21402
|
}
|
|
21403
|
+
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
21404
|
+
return;
|
|
21236
21405
|
node.splice(1, 0, ref, ".push(");
|
|
21237
21406
|
node.push(")");
|
|
21238
21407
|
}
|
|
@@ -21255,12 +21424,6 @@ ${input.slice(result.pos)}
|
|
|
21255
21424
|
return;
|
|
21256
21425
|
}
|
|
21257
21426
|
}
|
|
21258
|
-
function getIndent(statement) {
|
|
21259
|
-
let indent = statement?.[0];
|
|
21260
|
-
if (Array.isArray(indent))
|
|
21261
|
-
indent = indent[indent.length - 1];
|
|
21262
|
-
return indent;
|
|
21263
|
-
}
|
|
21264
21427
|
function insertReturn(node) {
|
|
21265
21428
|
if (!node)
|
|
21266
21429
|
return;
|
|
@@ -21689,14 +21852,6 @@ ${input.slice(result.pos)}
|
|
|
21689
21852
|
}
|
|
21690
21853
|
}
|
|
21691
21854
|
}
|
|
21692
|
-
function findAncestor(node, predicate, stopPredicate) {
|
|
21693
|
-
node = node.parent;
|
|
21694
|
-
while (node && !stopPredicate?.(node)) {
|
|
21695
|
-
if (predicate(node))
|
|
21696
|
-
return node;
|
|
21697
|
-
node = node.parent;
|
|
21698
|
-
}
|
|
21699
|
-
}
|
|
21700
21855
|
module2.replaceNodes = (root, predicate, replacer) => {
|
|
21701
21856
|
if (root == null)
|
|
21702
21857
|
return root;
|
|
@@ -21863,7 +22018,7 @@ ${input.slice(result.pos)}
|
|
|
21863
22018
|
}
|
|
21864
22019
|
function processBindingPatternLHS(lhs, tail) {
|
|
21865
22020
|
adjustAtBindings(lhs, true);
|
|
21866
|
-
const [splices, thisAssignments] =
|
|
22021
|
+
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
21867
22022
|
tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
|
|
21868
22023
|
}
|
|
21869
22024
|
function processAssignments(statements) {
|
|
@@ -22453,14 +22608,16 @@ ${input.slice(result.pos)}
|
|
|
22453
22608
|
addParentPointers(s, s.parent);
|
|
22454
22609
|
});
|
|
22455
22610
|
}
|
|
22456
|
-
module2.processProgram = function(
|
|
22457
|
-
addParentPointers(
|
|
22611
|
+
module2.processProgram = function(root) {
|
|
22612
|
+
addParentPointers(root);
|
|
22613
|
+
const { expressions: statements } = root;
|
|
22458
22614
|
processPipelineExpressions(statements);
|
|
22459
22615
|
processAssignments(statements);
|
|
22460
22616
|
processPatternMatching(statements);
|
|
22461
22617
|
processFunctions(statements);
|
|
22462
22618
|
processSwitchExpressions(statements);
|
|
22463
22619
|
processTryExpressions(statements);
|
|
22620
|
+
hoistRefDecs(statements);
|
|
22464
22621
|
gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
|
|
22465
22622
|
checkSpliceRef(statements);
|
|
22466
22623
|
statements.unshift(...module2.prelude);
|
|
@@ -22620,35 +22777,6 @@ ${input.slice(result.pos)}
|
|
|
22620
22777
|
scopes.pop();
|
|
22621
22778
|
statements.splice(0, statements.length, targetStatements);
|
|
22622
22779
|
}
|
|
22623
|
-
function gatherBindingCode(statements, opts) {
|
|
22624
|
-
const thisAssignments = [];
|
|
22625
|
-
const splices = [];
|
|
22626
|
-
function insertRestSplices(s, p, thisAssignments2) {
|
|
22627
|
-
gatherRecursiveAll(s, (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding").forEach((n) => {
|
|
22628
|
-
if (n.type === "AtBinding") {
|
|
22629
|
-
const { ref } = n, { id } = ref;
|
|
22630
|
-
thisAssignments2.push([`this.${id} = `, ref]);
|
|
22631
|
-
return;
|
|
22632
|
-
}
|
|
22633
|
-
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
22634
|
-
n.names.forEach((id) => {
|
|
22635
|
-
thisAssignments2.push({
|
|
22636
|
-
type: "AssignmentExpression",
|
|
22637
|
-
children: [`this.${id} = `, id],
|
|
22638
|
-
js: true
|
|
22639
|
-
});
|
|
22640
|
-
});
|
|
22641
|
-
return;
|
|
22642
|
-
}
|
|
22643
|
-
const { blockPrefix } = n;
|
|
22644
|
-
p.push(blockPrefix);
|
|
22645
|
-
insertRestSplices(blockPrefix, p, thisAssignments2);
|
|
22646
|
-
});
|
|
22647
|
-
}
|
|
22648
|
-
insertRestSplices(statements, splices, thisAssignments);
|
|
22649
|
-
return [splices, thisAssignments];
|
|
22650
|
-
}
|
|
22651
|
-
module2.gatherBindingCode = gatherBindingCode;
|
|
22652
22780
|
module2.constructInvocation = function(fn, arg) {
|
|
22653
22781
|
const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
|
|
22654
22782
|
let expr = fn.expr;
|
|
@@ -22990,21 +23118,28 @@ ${input.slice(result.pos)}
|
|
|
22990
23118
|
exports.parse = parse2;
|
|
22991
23119
|
exports.default = { parse: parse2 };
|
|
22992
23120
|
var {
|
|
23121
|
+
blockWithPrefix,
|
|
22993
23122
|
clone,
|
|
22994
23123
|
deepCopy,
|
|
23124
|
+
findAncestor,
|
|
22995
23125
|
forRange,
|
|
23126
|
+
gatherBindingCode,
|
|
22996
23127
|
gatherNodes,
|
|
22997
23128
|
gatherRecursive,
|
|
22998
23129
|
gatherRecursiveAll,
|
|
22999
23130
|
gatherRecursiveWithinFunction,
|
|
23131
|
+
getIndent,
|
|
23000
23132
|
getTrimmingSpace,
|
|
23001
23133
|
hasAwait,
|
|
23002
23134
|
hasYield,
|
|
23135
|
+
hoistRefDecs,
|
|
23003
23136
|
insertTrimmingSpace,
|
|
23004
23137
|
isFunction,
|
|
23005
23138
|
literalValue,
|
|
23006
23139
|
modifyString,
|
|
23007
23140
|
processCoffeeInterpolation,
|
|
23141
|
+
processConstAssignmentDeclaration,
|
|
23142
|
+
processLetAssignmentDeclaration,
|
|
23008
23143
|
quoteString,
|
|
23009
23144
|
removeParentPointers
|
|
23010
23145
|
} = require_lib();
|