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