@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.mjs
CHANGED
|
@@ -28,6 +28,32 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var require_lib = __commonJS({
|
|
29
29
|
"source/lib.js"(exports, module) {
|
|
30
30
|
"use strict";
|
|
31
|
+
function blockWithPrefix(prefixStatements, block) {
|
|
32
|
+
if (prefixStatements && prefixStatements.length) {
|
|
33
|
+
const indent = getIndent(block.expressions[0]);
|
|
34
|
+
if (indent) {
|
|
35
|
+
prefixStatements = prefixStatements.map((statement) => [indent, ...statement.slice(1)]);
|
|
36
|
+
}
|
|
37
|
+
const expressions = [...prefixStatements, ...block.expressions];
|
|
38
|
+
block = {
|
|
39
|
+
...block,
|
|
40
|
+
expressions,
|
|
41
|
+
children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
|
|
42
|
+
};
|
|
43
|
+
if (block.bare) {
|
|
44
|
+
block.children = [[" {\n", indent], ...block.children, "}"];
|
|
45
|
+
block.bare = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return block;
|
|
49
|
+
}
|
|
50
|
+
function closest(node, types) {
|
|
51
|
+
do {
|
|
52
|
+
if (types.includes(node.type)) {
|
|
53
|
+
return node;
|
|
54
|
+
}
|
|
55
|
+
} while (node = node.parent);
|
|
56
|
+
}
|
|
31
57
|
function clone(node) {
|
|
32
58
|
removeParentPointers(node);
|
|
33
59
|
return deepCopy(node);
|
|
@@ -64,6 +90,14 @@ var require_lib = __commonJS({
|
|
|
64
90
|
}
|
|
65
91
|
}
|
|
66
92
|
}
|
|
93
|
+
function findAncestor(node, predicate, stopPredicate) {
|
|
94
|
+
node = node.parent;
|
|
95
|
+
while (node && !stopPredicate?.(node)) {
|
|
96
|
+
if (predicate(node))
|
|
97
|
+
return node;
|
|
98
|
+
node = node.parent;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
67
101
|
function gatherNodes(node, predicate) {
|
|
68
102
|
if (node == null)
|
|
69
103
|
return [];
|
|
@@ -113,12 +147,40 @@ var require_lib = __commonJS({
|
|
|
113
147
|
}
|
|
114
148
|
return nodes;
|
|
115
149
|
}
|
|
150
|
+
function getIndent(statement) {
|
|
151
|
+
let indent = statement?.[0];
|
|
152
|
+
if (Array.isArray(indent))
|
|
153
|
+
indent = indent[indent.length - 1];
|
|
154
|
+
return indent;
|
|
155
|
+
}
|
|
116
156
|
function hasAwait(exp) {
|
|
117
157
|
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
|
|
118
158
|
}
|
|
119
159
|
function hasYield(exp) {
|
|
120
160
|
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
|
|
121
161
|
}
|
|
162
|
+
function hoistRefDecs(statements) {
|
|
163
|
+
gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
|
|
164
|
+
const { hoistDec } = node;
|
|
165
|
+
const outer = closest(node, ["IfStatement", "IterationStatement"]);
|
|
166
|
+
if (!outer) {
|
|
167
|
+
node.children.push({
|
|
168
|
+
type: "Error",
|
|
169
|
+
message: "Can't hoist declarations inside expressions yet."
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const block = outer.parent;
|
|
174
|
+
const { expressions } = block;
|
|
175
|
+
const index = expressions.findIndex(([, s]) => outer === s);
|
|
176
|
+
if (index < 0)
|
|
177
|
+
throw new Error("Couldn't find expression in block for hoistable declaration.");
|
|
178
|
+
const indent = expressions[index][0];
|
|
179
|
+
hoistDec[0][0] = indent;
|
|
180
|
+
expressions.splice(index, 0, hoistDec);
|
|
181
|
+
node.hoistDec = null;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
122
184
|
function isFunction(node) {
|
|
123
185
|
const { type } = node;
|
|
124
186
|
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
@@ -259,13 +321,6 @@ var require_lib = __commonJS({
|
|
|
259
321
|
}
|
|
260
322
|
} else if (forDeclaration) {
|
|
261
323
|
varAssign = varLetAssign = [forDeclaration, " = "];
|
|
262
|
-
blockPrefix = [
|
|
263
|
-
["", {
|
|
264
|
-
type: "AssignmentExpression",
|
|
265
|
-
children: [],
|
|
266
|
-
names: forDeclaration.names
|
|
267
|
-
}]
|
|
268
|
-
];
|
|
269
324
|
}
|
|
270
325
|
const declaration = {
|
|
271
326
|
type: "Declaration",
|
|
@@ -281,6 +336,34 @@ var require_lib = __commonJS({
|
|
|
281
336
|
blockPrefix
|
|
282
337
|
};
|
|
283
338
|
}
|
|
339
|
+
function gatherBindingCode(statements, opts) {
|
|
340
|
+
const thisAssignments = [];
|
|
341
|
+
const splices = [];
|
|
342
|
+
function insertRestSplices(s, p, thisAssignments2) {
|
|
343
|
+
gatherRecursiveAll(s, (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding").forEach((n) => {
|
|
344
|
+
if (n.type === "AtBinding") {
|
|
345
|
+
const { ref } = n, { id } = ref;
|
|
346
|
+
thisAssignments2.push([`this.${id} = `, ref]);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
350
|
+
n.names.forEach((id) => {
|
|
351
|
+
thisAssignments2.push({
|
|
352
|
+
type: "AssignmentExpression",
|
|
353
|
+
children: [`this.${id} = `, id],
|
|
354
|
+
js: true
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const { blockPrefix } = n;
|
|
360
|
+
p.push(blockPrefix);
|
|
361
|
+
insertRestSplices(blockPrefix, p, thisAssignments2);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
insertRestSplices(statements, splices, thisAssignments);
|
|
365
|
+
return [splices, thisAssignments];
|
|
366
|
+
}
|
|
284
367
|
function modifyString(str) {
|
|
285
368
|
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
286
369
|
}
|
|
@@ -312,22 +395,93 @@ var require_lib = __commonJS({
|
|
|
312
395
|
children: [s, parts, e]
|
|
313
396
|
};
|
|
314
397
|
}
|
|
398
|
+
function processConstAssignmentDeclaration(c, id, suffix, ws, ca, e) {
|
|
399
|
+
c = {
|
|
400
|
+
...c,
|
|
401
|
+
$loc: {
|
|
402
|
+
pos: ca.$loc.pos - 1,
|
|
403
|
+
length: ca.$loc.length + 1
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
let exp;
|
|
407
|
+
if (e.type === "FunctionExpression") {
|
|
408
|
+
exp = e;
|
|
409
|
+
} else {
|
|
410
|
+
exp = e[1];
|
|
411
|
+
}
|
|
412
|
+
if (exp?.children?.[0]?.token?.match(/^\s+$/))
|
|
413
|
+
exp.children.shift();
|
|
414
|
+
if (id.type === "Identifier" && exp?.type === "FunctionExpression" && !exp.id) {
|
|
415
|
+
const i = exp.children.findIndex((c2) => c2?.token === "function") + 1;
|
|
416
|
+
exp = {
|
|
417
|
+
...exp,
|
|
418
|
+
children: [...exp.children.slice(0, i), " ", id, suffix, ws, ...exp.children.slice(i)]
|
|
419
|
+
};
|
|
420
|
+
return {
|
|
421
|
+
type: "Declaration",
|
|
422
|
+
children: [exp],
|
|
423
|
+
names: id.names
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
let [splices, thisAssignments] = gatherBindingCode(id);
|
|
427
|
+
splices = splices.map((s) => [", ", s]);
|
|
428
|
+
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
429
|
+
const binding = [c, id, suffix, ...ws];
|
|
430
|
+
const initializer = [ca, e, ...splices, ...thisAssignments];
|
|
431
|
+
const children = [binding, initializer];
|
|
432
|
+
return {
|
|
433
|
+
type: "Declaration",
|
|
434
|
+
names: id.names,
|
|
435
|
+
children,
|
|
436
|
+
binding,
|
|
437
|
+
initializer
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
function processLetAssignmentDeclaration(l, id, suffix, ws, la, e) {
|
|
441
|
+
l = {
|
|
442
|
+
...l,
|
|
443
|
+
$loc: {
|
|
444
|
+
pos: la.$loc.pos - 1,
|
|
445
|
+
length: la.$loc.length + 1
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
let [splices, thisAssignments] = gatherBindingCode(id);
|
|
449
|
+
splices = splices.map((s) => [", ", s]);
|
|
450
|
+
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
451
|
+
const binding = [l, id, suffix, ...ws];
|
|
452
|
+
const initializer = [la, e, ...splices, ...thisAssignments];
|
|
453
|
+
const children = [binding, initializer];
|
|
454
|
+
return {
|
|
455
|
+
type: "Declaration",
|
|
456
|
+
names: id.names,
|
|
457
|
+
children,
|
|
458
|
+
binding,
|
|
459
|
+
initializer
|
|
460
|
+
};
|
|
461
|
+
}
|
|
315
462
|
module.exports = {
|
|
463
|
+
blockWithPrefix,
|
|
316
464
|
clone,
|
|
317
465
|
deepCopy,
|
|
466
|
+
findAncestor,
|
|
318
467
|
forRange,
|
|
468
|
+
gatherBindingCode,
|
|
319
469
|
gatherNodes,
|
|
320
470
|
gatherRecursive,
|
|
321
471
|
gatherRecursiveAll,
|
|
322
472
|
gatherRecursiveWithinFunction,
|
|
473
|
+
getIndent,
|
|
323
474
|
getTrimmingSpace,
|
|
324
475
|
hasAwait,
|
|
325
476
|
hasYield,
|
|
477
|
+
hoistRefDecs,
|
|
326
478
|
insertTrimmingSpace,
|
|
327
479
|
isFunction,
|
|
328
480
|
literalValue,
|
|
329
481
|
modifyString,
|
|
330
482
|
processCoffeeInterpolation,
|
|
483
|
+
processConstAssignmentDeclaration,
|
|
484
|
+
processLetAssignmentDeclaration,
|
|
331
485
|
quoteString,
|
|
332
486
|
removeParentPointers
|
|
333
487
|
};
|
|
@@ -1010,6 +1164,7 @@ ${input.slice(result.pos)}
|
|
|
1010
1164
|
FinallyClause,
|
|
1011
1165
|
CatchParameter,
|
|
1012
1166
|
Condition,
|
|
1167
|
+
DeclarationCondition,
|
|
1013
1168
|
ExpressionWithIndentedApplicationForbidden,
|
|
1014
1169
|
ForbidClassImplicitCall,
|
|
1015
1170
|
AllowClassImplicitCall,
|
|
@@ -1624,7 +1779,12 @@ ${input.slice(result.pos)}
|
|
|
1624
1779
|
var $R65 = $R(new RegExp("[ \\t]*", "suy"));
|
|
1625
1780
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
1626
1781
|
var statements = $4;
|
|
1627
|
-
module.processProgram(
|
|
1782
|
+
module.processProgram({
|
|
1783
|
+
type: "BlockStatement",
|
|
1784
|
+
expressions: statements,
|
|
1785
|
+
children: [statements],
|
|
1786
|
+
bare: true
|
|
1787
|
+
});
|
|
1628
1788
|
return $0;
|
|
1629
1789
|
});
|
|
1630
1790
|
function Program(state) {
|
|
@@ -9231,16 +9391,18 @@ ${input.slice(result.pos)}
|
|
|
9231
9391
|
var clause = $1;
|
|
9232
9392
|
var block = $2;
|
|
9233
9393
|
var e = $3;
|
|
9234
|
-
const children = [...clause.children
|
|
9394
|
+
const children = [...clause.children];
|
|
9395
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9396
|
+
children.push(block);
|
|
9235
9397
|
if (block.bare && e)
|
|
9236
9398
|
children.push(";");
|
|
9237
9399
|
if (e)
|
|
9238
9400
|
children.push(e);
|
|
9239
9401
|
return {
|
|
9240
|
-
|
|
9402
|
+
...clause,
|
|
9403
|
+
children,
|
|
9241
9404
|
then: block,
|
|
9242
|
-
else: e
|
|
9243
|
-
children
|
|
9405
|
+
else: e
|
|
9244
9406
|
};
|
|
9245
9407
|
});
|
|
9246
9408
|
function IfStatement(state) {
|
|
@@ -9289,8 +9451,13 @@ ${input.slice(result.pos)}
|
|
|
9289
9451
|
return result;
|
|
9290
9452
|
}
|
|
9291
9453
|
}
|
|
9292
|
-
var IfClause$0 = $
|
|
9293
|
-
|
|
9454
|
+
var IfClause$0 = $TS($S(If, Condition), function($skip, $loc, $0, $1, $2) {
|
|
9455
|
+
var condition = $2;
|
|
9456
|
+
return {
|
|
9457
|
+
type: "IfStatement",
|
|
9458
|
+
children: $0,
|
|
9459
|
+
condition
|
|
9460
|
+
};
|
|
9294
9461
|
});
|
|
9295
9462
|
function IfClause(state) {
|
|
9296
9463
|
let eventData;
|
|
@@ -9320,7 +9487,8 @@ ${input.slice(result.pos)}
|
|
|
9320
9487
|
kind = { ...kind, token: "if" };
|
|
9321
9488
|
return {
|
|
9322
9489
|
type: "IfStatement",
|
|
9323
|
-
children: [kind, ["(!", condition, ")"]]
|
|
9490
|
+
children: [kind, ["(!", condition, ")"]],
|
|
9491
|
+
condition
|
|
9324
9492
|
};
|
|
9325
9493
|
});
|
|
9326
9494
|
function UnlessClause(state) {
|
|
@@ -9789,8 +9957,9 @@ ${input.slice(result.pos)}
|
|
|
9789
9957
|
var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9790
9958
|
var clause = $1;
|
|
9791
9959
|
var block = $2;
|
|
9960
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9792
9961
|
return {
|
|
9793
|
-
|
|
9962
|
+
...clause,
|
|
9794
9963
|
children: [...clause.children, block],
|
|
9795
9964
|
block
|
|
9796
9965
|
};
|
|
@@ -9820,17 +9989,19 @@ ${input.slice(result.pos)}
|
|
|
9820
9989
|
var WhileClause$0 = $TS($S($C(While, Until), $E(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
|
|
9821
9990
|
var kind = $1;
|
|
9822
9991
|
var ws = $2;
|
|
9823
|
-
var
|
|
9992
|
+
var condition = $3;
|
|
9824
9993
|
if (kind.token === "until") {
|
|
9825
9994
|
kind.token = "while";
|
|
9826
9995
|
return {
|
|
9827
9996
|
type: "IterationStatement",
|
|
9828
|
-
children: [kind, ...ws, ["(!", ...
|
|
9997
|
+
children: [kind, ...ws, ["(!", ...condition.children, ")"]],
|
|
9998
|
+
condition
|
|
9829
9999
|
};
|
|
9830
10000
|
}
|
|
9831
10001
|
return {
|
|
9832
10002
|
type: "IterationStatement",
|
|
9833
|
-
children: [kind, ...ws, ...
|
|
10003
|
+
children: [kind, ...ws, ...condition.children],
|
|
10004
|
+
condition
|
|
9834
10005
|
};
|
|
9835
10006
|
});
|
|
9836
10007
|
function WhileClause(state) {
|
|
@@ -9858,18 +10029,7 @@ ${input.slice(result.pos)}
|
|
|
9858
10029
|
var ForStatement$0 = $TS($S(ForClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9859
10030
|
var clause = $1;
|
|
9860
10031
|
var block = $2;
|
|
9861
|
-
|
|
9862
|
-
const expressions = [...clause.blockPrefix, ...block.expressions];
|
|
9863
|
-
block = {
|
|
9864
|
-
...block,
|
|
9865
|
-
expressions,
|
|
9866
|
-
children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
|
|
9867
|
-
};
|
|
9868
|
-
if (block.bare) {
|
|
9869
|
-
block.children = [" {\n", ...block.children, "\n}"];
|
|
9870
|
-
block.bare = false;
|
|
9871
|
-
}
|
|
9872
|
-
}
|
|
10032
|
+
block = blockWithPrefix(clause.blockPrefix, block);
|
|
9873
10033
|
return {
|
|
9874
10034
|
...clause,
|
|
9875
10035
|
children: [...clause.children, block],
|
|
@@ -10924,10 +11084,31 @@ ${input.slice(result.pos)}
|
|
|
10924
11084
|
return result;
|
|
10925
11085
|
}
|
|
10926
11086
|
}
|
|
10927
|
-
var Condition$0 = $
|
|
11087
|
+
var Condition$0 = $TS($S(OpenParen, $E(_), DeclarationCondition, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
11088
|
+
var open = $1;
|
|
11089
|
+
var ws = $2;
|
|
11090
|
+
var expression = $3;
|
|
11091
|
+
var close = $4;
|
|
11092
|
+
return {
|
|
11093
|
+
type: "ParenthesizedExpression",
|
|
11094
|
+
children: [open, ws, expression, close],
|
|
11095
|
+
expression
|
|
11096
|
+
};
|
|
11097
|
+
});
|
|
11098
|
+
var Condition$1 = $T($S(ParenthesizedExpression, $N($S($E(_), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
|
|
10928
11099
|
return value[0];
|
|
10929
11100
|
});
|
|
10930
|
-
var Condition$
|
|
11101
|
+
var Condition$2 = $TS($S(InsertOpenParen, DeclarationCondition, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
|
|
11102
|
+
var open = $1;
|
|
11103
|
+
var expression = $2;
|
|
11104
|
+
var close = $3;
|
|
11105
|
+
return {
|
|
11106
|
+
type: "ParenthesizedExpression",
|
|
11107
|
+
children: [open, expression, close],
|
|
11108
|
+
expression
|
|
11109
|
+
};
|
|
11110
|
+
});
|
|
11111
|
+
var Condition$3 = $TS($S(InsertOpenParen, ExpressionWithIndentedApplicationForbidden, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
|
|
10931
11112
|
var open = $1;
|
|
10932
11113
|
var expression = $2;
|
|
10933
11114
|
var close = $3;
|
|
@@ -10951,17 +11132,54 @@ ${input.slice(result.pos)}
|
|
|
10951
11132
|
}
|
|
10952
11133
|
}
|
|
10953
11134
|
if (state.tokenize) {
|
|
10954
|
-
const result = $TOKEN("Condition", state, Condition$0(state) || Condition$1(state));
|
|
11135
|
+
const result = $TOKEN("Condition", state, Condition$0(state) || Condition$1(state) || Condition$2(state) || Condition$3(state));
|
|
10955
11136
|
if (state.events)
|
|
10956
11137
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10957
11138
|
return result;
|
|
10958
11139
|
} else {
|
|
10959
|
-
const result = Condition$0(state) || Condition$1(state);
|
|
11140
|
+
const result = Condition$0(state) || Condition$1(state) || Condition$2(state) || Condition$3(state);
|
|
10960
11141
|
if (state.events)
|
|
10961
11142
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10962
11143
|
return result;
|
|
10963
11144
|
}
|
|
10964
11145
|
}
|
|
11146
|
+
var DeclarationCondition$0 = $TV(LexicalDeclaration, function($skip, $loc, $0, $1) {
|
|
11147
|
+
var dec = $0;
|
|
11148
|
+
const ref = {
|
|
11149
|
+
type: "Ref",
|
|
11150
|
+
base: "ref"
|
|
11151
|
+
};
|
|
11152
|
+
const { binding, initializer } = dec;
|
|
11153
|
+
const initCondition = {
|
|
11154
|
+
type: "AssignmentExpression",
|
|
11155
|
+
children: [ref, " ", initializer],
|
|
11156
|
+
hoistDec: [["", ["let ", ref], ";"]],
|
|
11157
|
+
blockPrefix: [["", [binding, "= ", ref], ";\n"]]
|
|
11158
|
+
};
|
|
11159
|
+
return initCondition;
|
|
11160
|
+
});
|
|
11161
|
+
function DeclarationCondition(state) {
|
|
11162
|
+
let eventData;
|
|
11163
|
+
if (state.events) {
|
|
11164
|
+
const result = state.events.enter?.("DeclarationCondition", state);
|
|
11165
|
+
if (result) {
|
|
11166
|
+
if (result.cache)
|
|
11167
|
+
return result.cache;
|
|
11168
|
+
eventData = result.data;
|
|
11169
|
+
}
|
|
11170
|
+
}
|
|
11171
|
+
if (state.tokenize) {
|
|
11172
|
+
const result = $TOKEN("DeclarationCondition", state, DeclarationCondition$0(state));
|
|
11173
|
+
if (state.events)
|
|
11174
|
+
state.events.exit?.("DeclarationCondition", state, result, eventData);
|
|
11175
|
+
return result;
|
|
11176
|
+
} else {
|
|
11177
|
+
const result = DeclarationCondition$0(state);
|
|
11178
|
+
if (state.events)
|
|
11179
|
+
state.events.exit?.("DeclarationCondition", state, result, eventData);
|
|
11180
|
+
return result;
|
|
11181
|
+
}
|
|
11182
|
+
}
|
|
10965
11183
|
var ExpressionWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ExtendedExpression), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
|
|
10966
11184
|
var exp = $2;
|
|
10967
11185
|
if (exp)
|
|
@@ -12390,48 +12608,7 @@ ${input.slice(result.pos)}
|
|
|
12390
12608
|
};
|
|
12391
12609
|
});
|
|
12392
12610
|
var LexicalDeclaration$1 = $TS($S(InsertConst, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
12393
|
-
|
|
12394
|
-
var id = $2;
|
|
12395
|
-
var suffix = $3;
|
|
12396
|
-
var ws = $4;
|
|
12397
|
-
var ca = $5;
|
|
12398
|
-
var e = $6;
|
|
12399
|
-
c = {
|
|
12400
|
-
...c,
|
|
12401
|
-
$loc: {
|
|
12402
|
-
pos: ca.$loc.pos - 1,
|
|
12403
|
-
length: ca.$loc.length + 1
|
|
12404
|
-
}
|
|
12405
|
-
};
|
|
12406
|
-
let exp;
|
|
12407
|
-
if (e.type === "FunctionExpression") {
|
|
12408
|
-
exp = e;
|
|
12409
|
-
} else {
|
|
12410
|
-
exp = e[1];
|
|
12411
|
-
}
|
|
12412
|
-
if (exp?.children?.[0]?.token?.match(/^\s+$/))
|
|
12413
|
-
exp.children.shift();
|
|
12414
|
-
if (id.type === "Identifier" && exp?.type === "FunctionExpression" && !exp.id) {
|
|
12415
|
-
const i = exp.children.findIndex((c2) => c2?.token === "function") + 1;
|
|
12416
|
-
exp = {
|
|
12417
|
-
...exp,
|
|
12418
|
-
children: [...exp.children.slice(0, i), " ", id, $3, $4, ...exp.children.slice(i)]
|
|
12419
|
-
};
|
|
12420
|
-
return {
|
|
12421
|
-
type: "Declaration",
|
|
12422
|
-
children: [exp],
|
|
12423
|
-
names: id.names
|
|
12424
|
-
};
|
|
12425
|
-
}
|
|
12426
|
-
let [splices, thisAssignments] = module.gatherBindingCode(id);
|
|
12427
|
-
splices = splices.map((s) => [", ", s]);
|
|
12428
|
-
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
12429
|
-
const children = [c, id, suffix, ...ws, ca, e, ...splices, ...thisAssignments];
|
|
12430
|
-
return {
|
|
12431
|
-
type: "Declaration",
|
|
12432
|
-
names: id.names,
|
|
12433
|
-
children
|
|
12434
|
-
};
|
|
12611
|
+
return processConstAssignmentDeclaration(...$0);
|
|
12435
12612
|
});
|
|
12436
12613
|
var LexicalDeclaration$2 = $TS($S(InsertLet, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, LetAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
12437
12614
|
var l = $1;
|
|
@@ -12440,22 +12617,7 @@ ${input.slice(result.pos)}
|
|
|
12440
12617
|
var ws = $4;
|
|
12441
12618
|
var la = $5;
|
|
12442
12619
|
var e = $6;
|
|
12443
|
-
|
|
12444
|
-
...l,
|
|
12445
|
-
$loc: {
|
|
12446
|
-
pos: la.$loc.pos - 1,
|
|
12447
|
-
length: la.$loc.length + 1
|
|
12448
|
-
}
|
|
12449
|
-
};
|
|
12450
|
-
let [splices, thisAssignments] = module.gatherBindingCode(id);
|
|
12451
|
-
splices = splices.map((s) => [", ", s]);
|
|
12452
|
-
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
12453
|
-
const children = [l, id, suffix, ...ws, la, e, ...splices, ...thisAssignments];
|
|
12454
|
-
return {
|
|
12455
|
-
type: "Declaration",
|
|
12456
|
-
names: id.names,
|
|
12457
|
-
children
|
|
12458
|
-
};
|
|
12620
|
+
return processLetAssignmentDeclaration(...$0);
|
|
12459
12621
|
});
|
|
12460
12622
|
function LexicalDeclaration(state) {
|
|
12461
12623
|
let eventData;
|
|
@@ -14600,7 +14762,7 @@ ${input.slice(result.pos)}
|
|
|
14600
14762
|
return result;
|
|
14601
14763
|
}
|
|
14602
14764
|
}
|
|
14603
|
-
var Colon$0 = $
|
|
14765
|
+
var Colon$0 = $TS($S($EXPECT($L32, fail, 'Colon ":"'), $N($EXPECT($L2, fail, 'Colon "="'))), function($skip, $loc, $0, $1, $2) {
|
|
14604
14766
|
return { $loc, token: $1 };
|
|
14605
14767
|
});
|
|
14606
14768
|
function Colon(state) {
|
|
@@ -21010,9 +21172,14 @@ ${input.slice(result.pos)}
|
|
|
21010
21172
|
children: [...pre, ...exp.children, post]
|
|
21011
21173
|
};
|
|
21012
21174
|
default:
|
|
21175
|
+
const expression = {
|
|
21176
|
+
...exp,
|
|
21177
|
+
children: [...pre, "(", exp.children, ")", post]
|
|
21178
|
+
};
|
|
21013
21179
|
return {
|
|
21014
21180
|
type: "ParenthesizedExpression",
|
|
21015
|
-
children: ["(",
|
|
21181
|
+
children: ["(", expression, ")"],
|
|
21182
|
+
expression
|
|
21016
21183
|
};
|
|
21017
21184
|
}
|
|
21018
21185
|
}
|
|
@@ -21231,6 +21398,8 @@ ${input.slice(result.pos)}
|
|
|
21231
21398
|
exp.blocks.forEach((block) => insertPush(block, ref));
|
|
21232
21399
|
return;
|
|
21233
21400
|
}
|
|
21401
|
+
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
21402
|
+
return;
|
|
21234
21403
|
node.splice(1, 0, ref, ".push(");
|
|
21235
21404
|
node.push(")");
|
|
21236
21405
|
}
|
|
@@ -21253,12 +21422,6 @@ ${input.slice(result.pos)}
|
|
|
21253
21422
|
return;
|
|
21254
21423
|
}
|
|
21255
21424
|
}
|
|
21256
|
-
function getIndent(statement) {
|
|
21257
|
-
let indent = statement?.[0];
|
|
21258
|
-
if (Array.isArray(indent))
|
|
21259
|
-
indent = indent[indent.length - 1];
|
|
21260
|
-
return indent;
|
|
21261
|
-
}
|
|
21262
21425
|
function insertReturn(node) {
|
|
21263
21426
|
if (!node)
|
|
21264
21427
|
return;
|
|
@@ -21687,14 +21850,6 @@ ${input.slice(result.pos)}
|
|
|
21687
21850
|
}
|
|
21688
21851
|
}
|
|
21689
21852
|
}
|
|
21690
|
-
function findAncestor(node, predicate, stopPredicate) {
|
|
21691
|
-
node = node.parent;
|
|
21692
|
-
while (node && !stopPredicate?.(node)) {
|
|
21693
|
-
if (predicate(node))
|
|
21694
|
-
return node;
|
|
21695
|
-
node = node.parent;
|
|
21696
|
-
}
|
|
21697
|
-
}
|
|
21698
21853
|
module.replaceNodes = (root, predicate, replacer) => {
|
|
21699
21854
|
if (root == null)
|
|
21700
21855
|
return root;
|
|
@@ -21861,7 +22016,7 @@ ${input.slice(result.pos)}
|
|
|
21861
22016
|
}
|
|
21862
22017
|
function processBindingPatternLHS(lhs, tail) {
|
|
21863
22018
|
adjustAtBindings(lhs, true);
|
|
21864
|
-
const [splices, thisAssignments] =
|
|
22019
|
+
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
21865
22020
|
tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
|
|
21866
22021
|
}
|
|
21867
22022
|
function processAssignments(statements) {
|
|
@@ -22451,14 +22606,16 @@ ${input.slice(result.pos)}
|
|
|
22451
22606
|
addParentPointers(s, s.parent);
|
|
22452
22607
|
});
|
|
22453
22608
|
}
|
|
22454
|
-
module.processProgram = function(
|
|
22455
|
-
addParentPointers(
|
|
22609
|
+
module.processProgram = function(root) {
|
|
22610
|
+
addParentPointers(root);
|
|
22611
|
+
const { expressions: statements } = root;
|
|
22456
22612
|
processPipelineExpressions(statements);
|
|
22457
22613
|
processAssignments(statements);
|
|
22458
22614
|
processPatternMatching(statements);
|
|
22459
22615
|
processFunctions(statements);
|
|
22460
22616
|
processSwitchExpressions(statements);
|
|
22461
22617
|
processTryExpressions(statements);
|
|
22618
|
+
hoistRefDecs(statements);
|
|
22462
22619
|
gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
|
|
22463
22620
|
checkSpliceRef(statements);
|
|
22464
22621
|
statements.unshift(...module.prelude);
|
|
@@ -22618,35 +22775,6 @@ ${input.slice(result.pos)}
|
|
|
22618
22775
|
scopes.pop();
|
|
22619
22776
|
statements.splice(0, statements.length, targetStatements);
|
|
22620
22777
|
}
|
|
22621
|
-
function gatherBindingCode(statements, opts) {
|
|
22622
|
-
const thisAssignments = [];
|
|
22623
|
-
const splices = [];
|
|
22624
|
-
function insertRestSplices(s, p, thisAssignments2) {
|
|
22625
|
-
gatherRecursiveAll(s, (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding").forEach((n) => {
|
|
22626
|
-
if (n.type === "AtBinding") {
|
|
22627
|
-
const { ref } = n, { id } = ref;
|
|
22628
|
-
thisAssignments2.push([`this.${id} = `, ref]);
|
|
22629
|
-
return;
|
|
22630
|
-
}
|
|
22631
|
-
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
22632
|
-
n.names.forEach((id) => {
|
|
22633
|
-
thisAssignments2.push({
|
|
22634
|
-
type: "AssignmentExpression",
|
|
22635
|
-
children: [`this.${id} = `, id],
|
|
22636
|
-
js: true
|
|
22637
|
-
});
|
|
22638
|
-
});
|
|
22639
|
-
return;
|
|
22640
|
-
}
|
|
22641
|
-
const { blockPrefix } = n;
|
|
22642
|
-
p.push(blockPrefix);
|
|
22643
|
-
insertRestSplices(blockPrefix, p, thisAssignments2);
|
|
22644
|
-
});
|
|
22645
|
-
}
|
|
22646
|
-
insertRestSplices(statements, splices, thisAssignments);
|
|
22647
|
-
return [splices, thisAssignments];
|
|
22648
|
-
}
|
|
22649
|
-
module.gatherBindingCode = gatherBindingCode;
|
|
22650
22778
|
module.constructInvocation = function(fn, arg) {
|
|
22651
22779
|
const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
|
|
22652
22780
|
let expr = fn.expr;
|
|
@@ -22988,21 +23116,28 @@ ${input.slice(result.pos)}
|
|
|
22988
23116
|
exports.parse = parse2;
|
|
22989
23117
|
exports.default = { parse: parse2 };
|
|
22990
23118
|
var {
|
|
23119
|
+
blockWithPrefix,
|
|
22991
23120
|
clone,
|
|
22992
23121
|
deepCopy,
|
|
23122
|
+
findAncestor,
|
|
22993
23123
|
forRange,
|
|
23124
|
+
gatherBindingCode,
|
|
22994
23125
|
gatherNodes,
|
|
22995
23126
|
gatherRecursive,
|
|
22996
23127
|
gatherRecursiveAll,
|
|
22997
23128
|
gatherRecursiveWithinFunction,
|
|
23129
|
+
getIndent,
|
|
22998
23130
|
getTrimmingSpace,
|
|
22999
23131
|
hasAwait,
|
|
23000
23132
|
hasYield,
|
|
23133
|
+
hoistRefDecs,
|
|
23001
23134
|
insertTrimmingSpace,
|
|
23002
23135
|
isFunction,
|
|
23003
23136
|
literalValue,
|
|
23004
23137
|
modifyString,
|
|
23005
23138
|
processCoffeeInterpolation,
|
|
23139
|
+
processConstAssignmentDeclaration,
|
|
23140
|
+
processLetAssignmentDeclaration,
|
|
23006
23141
|
quoteString,
|
|
23007
23142
|
removeParentPointers
|
|
23008
23143
|
} = require_lib();
|