@danielx/civet 0.5.86 → 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 +273 -141
- package/dist/main.js +273 -141
- package/dist/main.mjs +273 -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,39 @@ 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.indexOf(outer);
|
|
176
|
+
const indent = getIndent(outer);
|
|
177
|
+
if (indent)
|
|
178
|
+
hoistDec[0][0] = indent;
|
|
179
|
+
expressions.splice(index, 0, hoistDec);
|
|
180
|
+
node.hoistDec = null;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
122
183
|
function isFunction(node) {
|
|
123
184
|
const { type } = node;
|
|
124
185
|
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
@@ -259,13 +320,6 @@ var require_lib = __commonJS({
|
|
|
259
320
|
}
|
|
260
321
|
} else if (forDeclaration) {
|
|
261
322
|
varAssign = varLetAssign = [forDeclaration, " = "];
|
|
262
|
-
blockPrefix = [
|
|
263
|
-
["", {
|
|
264
|
-
type: "AssignmentExpression",
|
|
265
|
-
children: [],
|
|
266
|
-
names: forDeclaration.names
|
|
267
|
-
}]
|
|
268
|
-
];
|
|
269
323
|
}
|
|
270
324
|
const declaration = {
|
|
271
325
|
type: "Declaration",
|
|
@@ -281,6 +335,34 @@ var require_lib = __commonJS({
|
|
|
281
335
|
blockPrefix
|
|
282
336
|
};
|
|
283
337
|
}
|
|
338
|
+
function gatherBindingCode(statements, opts) {
|
|
339
|
+
const thisAssignments = [];
|
|
340
|
+
const splices = [];
|
|
341
|
+
function insertRestSplices(s, p, thisAssignments2) {
|
|
342
|
+
gatherRecursiveAll(s, (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding").forEach((n) => {
|
|
343
|
+
if (n.type === "AtBinding") {
|
|
344
|
+
const { ref } = n, { id } = ref;
|
|
345
|
+
thisAssignments2.push([`this.${id} = `, ref]);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
349
|
+
n.names.forEach((id) => {
|
|
350
|
+
thisAssignments2.push({
|
|
351
|
+
type: "AssignmentExpression",
|
|
352
|
+
children: [`this.${id} = `, id],
|
|
353
|
+
js: true
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const { blockPrefix } = n;
|
|
359
|
+
p.push(blockPrefix);
|
|
360
|
+
insertRestSplices(blockPrefix, p, thisAssignments2);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
insertRestSplices(statements, splices, thisAssignments);
|
|
364
|
+
return [splices, thisAssignments];
|
|
365
|
+
}
|
|
284
366
|
function modifyString(str) {
|
|
285
367
|
return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
|
|
286
368
|
}
|
|
@@ -312,22 +394,93 @@ var require_lib = __commonJS({
|
|
|
312
394
|
children: [s, parts, e]
|
|
313
395
|
};
|
|
314
396
|
}
|
|
397
|
+
function processConstAssignmentDeclaration(c, id, suffix, ws, ca, e) {
|
|
398
|
+
c = {
|
|
399
|
+
...c,
|
|
400
|
+
$loc: {
|
|
401
|
+
pos: ca.$loc.pos - 1,
|
|
402
|
+
length: ca.$loc.length + 1
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
let exp;
|
|
406
|
+
if (e.type === "FunctionExpression") {
|
|
407
|
+
exp = e;
|
|
408
|
+
} else {
|
|
409
|
+
exp = e[1];
|
|
410
|
+
}
|
|
411
|
+
if (exp?.children?.[0]?.token?.match(/^\s+$/))
|
|
412
|
+
exp.children.shift();
|
|
413
|
+
if (id.type === "Identifier" && exp?.type === "FunctionExpression" && !exp.id) {
|
|
414
|
+
const i = exp.children.findIndex((c2) => c2?.token === "function") + 1;
|
|
415
|
+
exp = {
|
|
416
|
+
...exp,
|
|
417
|
+
children: [...exp.children.slice(0, i), " ", id, suffix, ws, ...exp.children.slice(i)]
|
|
418
|
+
};
|
|
419
|
+
return {
|
|
420
|
+
type: "Declaration",
|
|
421
|
+
children: [exp],
|
|
422
|
+
names: id.names
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
let [splices, thisAssignments] = gatherBindingCode(id);
|
|
426
|
+
splices = splices.map((s) => [", ", s]);
|
|
427
|
+
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
428
|
+
const binding = [c, id, suffix, ...ws];
|
|
429
|
+
const initializer = [ca, e, ...splices, ...thisAssignments];
|
|
430
|
+
const children = [binding, initializer];
|
|
431
|
+
return {
|
|
432
|
+
type: "Declaration",
|
|
433
|
+
names: id.names,
|
|
434
|
+
children,
|
|
435
|
+
binding,
|
|
436
|
+
initializer
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function processLetAssignmentDeclaration(l, id, suffix, ws, la, e) {
|
|
440
|
+
l = {
|
|
441
|
+
...l,
|
|
442
|
+
$loc: {
|
|
443
|
+
pos: la.$loc.pos - 1,
|
|
444
|
+
length: la.$loc.length + 1
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
let [splices, thisAssignments] = gatherBindingCode(id);
|
|
448
|
+
splices = splices.map((s) => [", ", s]);
|
|
449
|
+
thisAssignments = thisAssignments.map((a) => [";", a]);
|
|
450
|
+
const binding = [l, id, suffix, ...ws];
|
|
451
|
+
const initializer = [la, e, ...splices, ...thisAssignments];
|
|
452
|
+
const children = [binding, initializer];
|
|
453
|
+
return {
|
|
454
|
+
type: "Declaration",
|
|
455
|
+
names: id.names,
|
|
456
|
+
children,
|
|
457
|
+
binding,
|
|
458
|
+
initializer
|
|
459
|
+
};
|
|
460
|
+
}
|
|
315
461
|
module.exports = {
|
|
462
|
+
blockWithPrefix,
|
|
316
463
|
clone,
|
|
317
464
|
deepCopy,
|
|
465
|
+
findAncestor,
|
|
318
466
|
forRange,
|
|
467
|
+
gatherBindingCode,
|
|
319
468
|
gatherNodes,
|
|
320
469
|
gatherRecursive,
|
|
321
470
|
gatherRecursiveAll,
|
|
322
471
|
gatherRecursiveWithinFunction,
|
|
472
|
+
getIndent,
|
|
323
473
|
getTrimmingSpace,
|
|
324
474
|
hasAwait,
|
|
325
475
|
hasYield,
|
|
476
|
+
hoistRefDecs,
|
|
326
477
|
insertTrimmingSpace,
|
|
327
478
|
isFunction,
|
|
328
479
|
literalValue,
|
|
329
480
|
modifyString,
|
|
330
481
|
processCoffeeInterpolation,
|
|
482
|
+
processConstAssignmentDeclaration,
|
|
483
|
+
processLetAssignmentDeclaration,
|
|
331
484
|
quoteString,
|
|
332
485
|
removeParentPointers
|
|
333
486
|
};
|
|
@@ -1010,6 +1163,7 @@ ${input.slice(result.pos)}
|
|
|
1010
1163
|
FinallyClause,
|
|
1011
1164
|
CatchParameter,
|
|
1012
1165
|
Condition,
|
|
1166
|
+
DeclarationCondition,
|
|
1013
1167
|
ExpressionWithIndentedApplicationForbidden,
|
|
1014
1168
|
ForbidClassImplicitCall,
|
|
1015
1169
|
AllowClassImplicitCall,
|
|
@@ -1624,7 +1778,12 @@ ${input.slice(result.pos)}
|
|
|
1624
1778
|
var $R65 = $R(new RegExp("[ \\t]*", "suy"));
|
|
1625
1779
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
1626
1780
|
var statements = $4;
|
|
1627
|
-
module.processProgram(
|
|
1781
|
+
module.processProgram({
|
|
1782
|
+
type: "BlockStatement",
|
|
1783
|
+
expressions: statements,
|
|
1784
|
+
children: [statements],
|
|
1785
|
+
bare: true
|
|
1786
|
+
});
|
|
1628
1787
|
return $0;
|
|
1629
1788
|
});
|
|
1630
1789
|
function Program(state) {
|
|
@@ -9231,16 +9390,18 @@ ${input.slice(result.pos)}
|
|
|
9231
9390
|
var clause = $1;
|
|
9232
9391
|
var block = $2;
|
|
9233
9392
|
var e = $3;
|
|
9234
|
-
const children = [...clause.children
|
|
9393
|
+
const children = [...clause.children];
|
|
9394
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9395
|
+
children.push(block);
|
|
9235
9396
|
if (block.bare && e)
|
|
9236
9397
|
children.push(";");
|
|
9237
9398
|
if (e)
|
|
9238
9399
|
children.push(e);
|
|
9239
9400
|
return {
|
|
9240
|
-
|
|
9401
|
+
...clause,
|
|
9402
|
+
children,
|
|
9241
9403
|
then: block,
|
|
9242
|
-
else: e
|
|
9243
|
-
children
|
|
9404
|
+
else: e
|
|
9244
9405
|
};
|
|
9245
9406
|
});
|
|
9246
9407
|
function IfStatement(state) {
|
|
@@ -9289,8 +9450,13 @@ ${input.slice(result.pos)}
|
|
|
9289
9450
|
return result;
|
|
9290
9451
|
}
|
|
9291
9452
|
}
|
|
9292
|
-
var IfClause$0 = $
|
|
9293
|
-
|
|
9453
|
+
var IfClause$0 = $TS($S(If, Condition), function($skip, $loc, $0, $1, $2) {
|
|
9454
|
+
var condition = $2;
|
|
9455
|
+
return {
|
|
9456
|
+
type: "IfStatement",
|
|
9457
|
+
children: $0,
|
|
9458
|
+
condition
|
|
9459
|
+
};
|
|
9294
9460
|
});
|
|
9295
9461
|
function IfClause(state) {
|
|
9296
9462
|
let eventData;
|
|
@@ -9320,7 +9486,8 @@ ${input.slice(result.pos)}
|
|
|
9320
9486
|
kind = { ...kind, token: "if" };
|
|
9321
9487
|
return {
|
|
9322
9488
|
type: "IfStatement",
|
|
9323
|
-
children: [kind, ["(!", condition, ")"]]
|
|
9489
|
+
children: [kind, ["(!", condition, ")"]],
|
|
9490
|
+
condition
|
|
9324
9491
|
};
|
|
9325
9492
|
});
|
|
9326
9493
|
function UnlessClause(state) {
|
|
@@ -9789,8 +9956,9 @@ ${input.slice(result.pos)}
|
|
|
9789
9956
|
var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9790
9957
|
var clause = $1;
|
|
9791
9958
|
var block = $2;
|
|
9959
|
+
block = blockWithPrefix(clause.condition.expression.blockPrefix, block);
|
|
9792
9960
|
return {
|
|
9793
|
-
|
|
9961
|
+
...clause,
|
|
9794
9962
|
children: [...clause.children, block],
|
|
9795
9963
|
block
|
|
9796
9964
|
};
|
|
@@ -9820,17 +9988,19 @@ ${input.slice(result.pos)}
|
|
|
9820
9988
|
var WhileClause$0 = $TS($S($C(While, Until), $E(_), Condition), function($skip, $loc, $0, $1, $2, $3) {
|
|
9821
9989
|
var kind = $1;
|
|
9822
9990
|
var ws = $2;
|
|
9823
|
-
var
|
|
9991
|
+
var condition = $3;
|
|
9824
9992
|
if (kind.token === "until") {
|
|
9825
9993
|
kind.token = "while";
|
|
9826
9994
|
return {
|
|
9827
9995
|
type: "IterationStatement",
|
|
9828
|
-
children: [kind, ...ws, ["(!", ...
|
|
9996
|
+
children: [kind, ...ws, ["(!", ...condition.children, ")"]],
|
|
9997
|
+
condition
|
|
9829
9998
|
};
|
|
9830
9999
|
}
|
|
9831
10000
|
return {
|
|
9832
10001
|
type: "IterationStatement",
|
|
9833
|
-
children: [kind, ...ws, ...
|
|
10002
|
+
children: [kind, ...ws, ...condition.children],
|
|
10003
|
+
condition
|
|
9834
10004
|
};
|
|
9835
10005
|
});
|
|
9836
10006
|
function WhileClause(state) {
|
|
@@ -9858,18 +10028,7 @@ ${input.slice(result.pos)}
|
|
|
9858
10028
|
var ForStatement$0 = $TS($S(ForClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9859
10029
|
var clause = $1;
|
|
9860
10030
|
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
|
-
}
|
|
10031
|
+
block = blockWithPrefix(clause.blockPrefix, block);
|
|
9873
10032
|
return {
|
|
9874
10033
|
...clause,
|
|
9875
10034
|
children: [...clause.children, block],
|
|
@@ -10924,10 +11083,31 @@ ${input.slice(result.pos)}
|
|
|
10924
11083
|
return result;
|
|
10925
11084
|
}
|
|
10926
11085
|
}
|
|
10927
|
-
var Condition$0 = $
|
|
11086
|
+
var Condition$0 = $TS($S(OpenParen, $E(_), DeclarationCondition, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
11087
|
+
var open = $1;
|
|
11088
|
+
var ws = $2;
|
|
11089
|
+
var expression = $3;
|
|
11090
|
+
var close = $4;
|
|
11091
|
+
return {
|
|
11092
|
+
type: "ParenthesizedExpression",
|
|
11093
|
+
children: [open, ws, expression, close],
|
|
11094
|
+
expression
|
|
11095
|
+
};
|
|
11096
|
+
});
|
|
11097
|
+
var Condition$1 = $T($S(ParenthesizedExpression, $N($S($E(_), $C(BinaryOp, AssignmentOp, Dot, QuestionMark))), $N($S(_, OperatorAssignmentOp))), function(value) {
|
|
10928
11098
|
return value[0];
|
|
10929
11099
|
});
|
|
10930
|
-
var Condition$
|
|
11100
|
+
var Condition$2 = $TS($S(InsertOpenParen, DeclarationCondition, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
|
|
11101
|
+
var open = $1;
|
|
11102
|
+
var expression = $2;
|
|
11103
|
+
var close = $3;
|
|
11104
|
+
return {
|
|
11105
|
+
type: "ParenthesizedExpression",
|
|
11106
|
+
children: [open, expression, close],
|
|
11107
|
+
expression
|
|
11108
|
+
};
|
|
11109
|
+
});
|
|
11110
|
+
var Condition$3 = $TS($S(InsertOpenParen, ExpressionWithIndentedApplicationForbidden, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3) {
|
|
10931
11111
|
var open = $1;
|
|
10932
11112
|
var expression = $2;
|
|
10933
11113
|
var close = $3;
|
|
@@ -10951,17 +11131,54 @@ ${input.slice(result.pos)}
|
|
|
10951
11131
|
}
|
|
10952
11132
|
}
|
|
10953
11133
|
if (state.tokenize) {
|
|
10954
|
-
const result = $TOKEN("Condition", state, Condition$0(state) || Condition$1(state));
|
|
11134
|
+
const result = $TOKEN("Condition", state, Condition$0(state) || Condition$1(state) || Condition$2(state) || Condition$3(state));
|
|
10955
11135
|
if (state.events)
|
|
10956
11136
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10957
11137
|
return result;
|
|
10958
11138
|
} else {
|
|
10959
|
-
const result = Condition$0(state) || Condition$1(state);
|
|
11139
|
+
const result = Condition$0(state) || Condition$1(state) || Condition$2(state) || Condition$3(state);
|
|
10960
11140
|
if (state.events)
|
|
10961
11141
|
state.events.exit?.("Condition", state, result, eventData);
|
|
10962
11142
|
return result;
|
|
10963
11143
|
}
|
|
10964
11144
|
}
|
|
11145
|
+
var DeclarationCondition$0 = $TV(LexicalDeclaration, function($skip, $loc, $0, $1) {
|
|
11146
|
+
var dec = $0;
|
|
11147
|
+
const ref = {
|
|
11148
|
+
type: "Ref",
|
|
11149
|
+
base: "ref"
|
|
11150
|
+
};
|
|
11151
|
+
const { binding, initializer } = dec;
|
|
11152
|
+
const initCondition = {
|
|
11153
|
+
type: "AssignmentExpression",
|
|
11154
|
+
children: [ref, " ", initializer],
|
|
11155
|
+
hoistDec: [["", ["let ", ref], ";\n"]],
|
|
11156
|
+
blockPrefix: [["", [binding, "= ", ref], ";\n"]]
|
|
11157
|
+
};
|
|
11158
|
+
return initCondition;
|
|
11159
|
+
});
|
|
11160
|
+
function DeclarationCondition(state) {
|
|
11161
|
+
let eventData;
|
|
11162
|
+
if (state.events) {
|
|
11163
|
+
const result = state.events.enter?.("DeclarationCondition", state);
|
|
11164
|
+
if (result) {
|
|
11165
|
+
if (result.cache)
|
|
11166
|
+
return result.cache;
|
|
11167
|
+
eventData = result.data;
|
|
11168
|
+
}
|
|
11169
|
+
}
|
|
11170
|
+
if (state.tokenize) {
|
|
11171
|
+
const result = $TOKEN("DeclarationCondition", state, DeclarationCondition$0(state));
|
|
11172
|
+
if (state.events)
|
|
11173
|
+
state.events.exit?.("DeclarationCondition", state, result, eventData);
|
|
11174
|
+
return result;
|
|
11175
|
+
} else {
|
|
11176
|
+
const result = DeclarationCondition$0(state);
|
|
11177
|
+
if (state.events)
|
|
11178
|
+
state.events.exit?.("DeclarationCondition", state, result, eventData);
|
|
11179
|
+
return result;
|
|
11180
|
+
}
|
|
11181
|
+
}
|
|
10965
11182
|
var ExpressionWithIndentedApplicationForbidden$0 = $TS($S(ForbidIndentedApplication, $E(ExtendedExpression), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
|
|
10966
11183
|
var exp = $2;
|
|
10967
11184
|
if (exp)
|
|
@@ -12390,48 +12607,7 @@ ${input.slice(result.pos)}
|
|
|
12390
12607
|
};
|
|
12391
12608
|
});
|
|
12392
12609
|
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
|
-
};
|
|
12610
|
+
return processConstAssignmentDeclaration(...$0);
|
|
12435
12611
|
});
|
|
12436
12612
|
var LexicalDeclaration$2 = $TS($S(InsertLet, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, LetAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
12437
12613
|
var l = $1;
|
|
@@ -12440,22 +12616,7 @@ ${input.slice(result.pos)}
|
|
|
12440
12616
|
var ws = $4;
|
|
12441
12617
|
var la = $5;
|
|
12442
12618
|
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
|
-
};
|
|
12619
|
+
return processLetAssignmentDeclaration(...$0);
|
|
12459
12620
|
});
|
|
12460
12621
|
function LexicalDeclaration(state) {
|
|
12461
12622
|
let eventData;
|
|
@@ -14600,7 +14761,7 @@ ${input.slice(result.pos)}
|
|
|
14600
14761
|
return result;
|
|
14601
14762
|
}
|
|
14602
14763
|
}
|
|
14603
|
-
var Colon$0 = $
|
|
14764
|
+
var Colon$0 = $TS($S($EXPECT($L32, fail, 'Colon ":"'), $N($EXPECT($L2, fail, 'Colon "="'))), function($skip, $loc, $0, $1, $2) {
|
|
14604
14765
|
return { $loc, token: $1 };
|
|
14605
14766
|
});
|
|
14606
14767
|
function Colon(state) {
|
|
@@ -21010,9 +21171,14 @@ ${input.slice(result.pos)}
|
|
|
21010
21171
|
children: [...pre, ...exp.children, post]
|
|
21011
21172
|
};
|
|
21012
21173
|
default:
|
|
21174
|
+
const expression = {
|
|
21175
|
+
...exp,
|
|
21176
|
+
children: [...pre, "(", exp.children, ")", post]
|
|
21177
|
+
};
|
|
21013
21178
|
return {
|
|
21014
21179
|
type: "ParenthesizedExpression",
|
|
21015
|
-
children: ["(",
|
|
21180
|
+
children: ["(", expression, ")"],
|
|
21181
|
+
expression
|
|
21016
21182
|
};
|
|
21017
21183
|
}
|
|
21018
21184
|
}
|
|
@@ -21253,12 +21419,6 @@ ${input.slice(result.pos)}
|
|
|
21253
21419
|
return;
|
|
21254
21420
|
}
|
|
21255
21421
|
}
|
|
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
21422
|
function insertReturn(node) {
|
|
21263
21423
|
if (!node)
|
|
21264
21424
|
return;
|
|
@@ -21687,14 +21847,6 @@ ${input.slice(result.pos)}
|
|
|
21687
21847
|
}
|
|
21688
21848
|
}
|
|
21689
21849
|
}
|
|
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
21850
|
module.replaceNodes = (root, predicate, replacer) => {
|
|
21699
21851
|
if (root == null)
|
|
21700
21852
|
return root;
|
|
@@ -21861,7 +22013,7 @@ ${input.slice(result.pos)}
|
|
|
21861
22013
|
}
|
|
21862
22014
|
function processBindingPatternLHS(lhs, tail) {
|
|
21863
22015
|
adjustAtBindings(lhs, true);
|
|
21864
|
-
const [splices, thisAssignments] =
|
|
22016
|
+
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
21865
22017
|
tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
|
|
21866
22018
|
}
|
|
21867
22019
|
function processAssignments(statements) {
|
|
@@ -22451,14 +22603,16 @@ ${input.slice(result.pos)}
|
|
|
22451
22603
|
addParentPointers(s, s.parent);
|
|
22452
22604
|
});
|
|
22453
22605
|
}
|
|
22454
|
-
module.processProgram = function(
|
|
22455
|
-
addParentPointers(
|
|
22606
|
+
module.processProgram = function(root) {
|
|
22607
|
+
addParentPointers(root);
|
|
22608
|
+
const { expressions: statements } = root;
|
|
22456
22609
|
processPipelineExpressions(statements);
|
|
22457
22610
|
processAssignments(statements);
|
|
22458
22611
|
processPatternMatching(statements);
|
|
22459
22612
|
processFunctions(statements);
|
|
22460
22613
|
processSwitchExpressions(statements);
|
|
22461
22614
|
processTryExpressions(statements);
|
|
22615
|
+
hoistRefDecs(statements);
|
|
22462
22616
|
gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
|
|
22463
22617
|
checkSpliceRef(statements);
|
|
22464
22618
|
statements.unshift(...module.prelude);
|
|
@@ -22618,35 +22772,6 @@ ${input.slice(result.pos)}
|
|
|
22618
22772
|
scopes.pop();
|
|
22619
22773
|
statements.splice(0, statements.length, targetStatements);
|
|
22620
22774
|
}
|
|
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
22775
|
module.constructInvocation = function(fn, arg) {
|
|
22651
22776
|
const fnArr = [fn.leadingComment, fn.expr, fn.trailingComment];
|
|
22652
22777
|
let expr = fn.expr;
|
|
@@ -22988,21 +23113,28 @@ ${input.slice(result.pos)}
|
|
|
22988
23113
|
exports.parse = parse2;
|
|
22989
23114
|
exports.default = { parse: parse2 };
|
|
22990
23115
|
var {
|
|
23116
|
+
blockWithPrefix,
|
|
22991
23117
|
clone,
|
|
22992
23118
|
deepCopy,
|
|
23119
|
+
findAncestor,
|
|
22993
23120
|
forRange,
|
|
23121
|
+
gatherBindingCode,
|
|
22994
23122
|
gatherNodes,
|
|
22995
23123
|
gatherRecursive,
|
|
22996
23124
|
gatherRecursiveAll,
|
|
22997
23125
|
gatherRecursiveWithinFunction,
|
|
23126
|
+
getIndent,
|
|
22998
23127
|
getTrimmingSpace,
|
|
22999
23128
|
hasAwait,
|
|
23000
23129
|
hasYield,
|
|
23130
|
+
hoistRefDecs,
|
|
23001
23131
|
insertTrimmingSpace,
|
|
23002
23132
|
isFunction,
|
|
23003
23133
|
literalValue,
|
|
23004
23134
|
modifyString,
|
|
23005
23135
|
processCoffeeInterpolation,
|
|
23136
|
+
processConstAssignmentDeclaration,
|
|
23137
|
+
processLetAssignmentDeclaration,
|
|
23006
23138
|
quoteString,
|
|
23007
23139
|
removeParentPointers
|
|
23008
23140
|
} = require_lib();
|