@danielx/civet 0.6.1 → 0.6.3
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 +231 -76
- package/dist/main.js +231 -76
- package/dist/main.mjs +231 -76
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -28,6 +28,29 @@ 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 aliasBinding(p, ref) {
|
|
32
|
+
if (p.type === "Identifier") {
|
|
33
|
+
p.children[0] = ref;
|
|
34
|
+
} else if (p.type === "BindingRestElement") {
|
|
35
|
+
aliasBinding(p.binding, ref);
|
|
36
|
+
} else if (p.value?.type === "Identifier") {
|
|
37
|
+
aliasBinding(p.value, ref);
|
|
38
|
+
} else {
|
|
39
|
+
p.value = ref;
|
|
40
|
+
p.children.push(": ", ref);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function arrayElementHasTrailingComma(elementNode) {
|
|
44
|
+
const { children } = elementNode, { length } = children;
|
|
45
|
+
const lastChild = children[length - 1];
|
|
46
|
+
if (lastChild) {
|
|
47
|
+
const l2 = lastChild.length;
|
|
48
|
+
if (lastChild[l2 - 1]?.token === ",") {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
31
54
|
function blockWithPrefix(prefixStatements, block) {
|
|
32
55
|
if (prefixStatements && prefixStatements.length) {
|
|
33
56
|
const indent = getIndent(block.expressions[0]);
|
|
@@ -170,7 +193,7 @@ var require_lib = __commonJS({
|
|
|
170
193
|
function hoistRefDecs(statements) {
|
|
171
194
|
gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
|
|
172
195
|
const { hoistDec } = node;
|
|
173
|
-
|
|
196
|
+
let outer = closest(node, ["IfStatement", "IterationStatement"]);
|
|
174
197
|
if (!outer) {
|
|
175
198
|
node.children.push({
|
|
176
199
|
type: "Error",
|
|
@@ -178,7 +201,11 @@ var require_lib = __commonJS({
|
|
|
178
201
|
});
|
|
179
202
|
return;
|
|
180
203
|
}
|
|
181
|
-
|
|
204
|
+
let block = outer.parent;
|
|
205
|
+
if (block.type === "PatternMatchingStatement") {
|
|
206
|
+
outer = block;
|
|
207
|
+
block = block.parent;
|
|
208
|
+
}
|
|
182
209
|
const { expressions } = block;
|
|
183
210
|
const index = expressions.findIndex(([, s]) => outer === s);
|
|
184
211
|
if (index < 0)
|
|
@@ -605,6 +632,8 @@ var require_lib = __commonJS({
|
|
|
605
632
|
};
|
|
606
633
|
}
|
|
607
634
|
module.exports = {
|
|
635
|
+
aliasBinding,
|
|
636
|
+
arrayElementHasTrailingComma,
|
|
608
637
|
blockWithPrefix,
|
|
609
638
|
clone,
|
|
610
639
|
convertMethodToFunction,
|
|
@@ -1295,6 +1324,8 @@ ${input.slice(result.pos)}
|
|
|
1295
1324
|
NestedCaseClauses,
|
|
1296
1325
|
NestedCaseClause,
|
|
1297
1326
|
CaseClause,
|
|
1327
|
+
PatternExpressionList,
|
|
1328
|
+
ConditionFragment,
|
|
1298
1329
|
CaseExpressionList,
|
|
1299
1330
|
ImpliedColon,
|
|
1300
1331
|
TryStatement,
|
|
@@ -1598,6 +1629,7 @@ ${input.slice(result.pos)}
|
|
|
1598
1629
|
ImportType,
|
|
1599
1630
|
TypeTuple,
|
|
1600
1631
|
TypeList,
|
|
1632
|
+
TypeElement,
|
|
1601
1633
|
NestedTypeList,
|
|
1602
1634
|
NestedType,
|
|
1603
1635
|
TypeConditional,
|
|
@@ -4890,13 +4922,8 @@ ${input.slice(result.pos)}
|
|
|
4890
4922
|
var close = $7;
|
|
4891
4923
|
const names = pes.flatMap((p) => p.names);
|
|
4892
4924
|
if (rest) {
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
restIdentifier = rest.binding.ref;
|
|
4896
|
-
} else {
|
|
4897
|
-
names.push(...rest.names);
|
|
4898
|
-
restIdentifier = rest.names[0];
|
|
4899
|
-
}
|
|
4925
|
+
const restIdentifier = rest.binding.ref || rest.binding;
|
|
4926
|
+
names.push(...rest.names || []);
|
|
4900
4927
|
let blockPrefix;
|
|
4901
4928
|
if (after.length) {
|
|
4902
4929
|
blockPrefix = {
|
|
@@ -4954,7 +4981,7 @@ ${input.slice(result.pos)}
|
|
|
4954
4981
|
type: "FunctionRestParameter",
|
|
4955
4982
|
children: $0,
|
|
4956
4983
|
names: id.names,
|
|
4957
|
-
binding: id
|
|
4984
|
+
binding: id.binding
|
|
4958
4985
|
};
|
|
4959
4986
|
});
|
|
4960
4987
|
function FunctionRestParameter(state) {
|
|
@@ -5718,8 +5745,11 @@ ${input.slice(result.pos)}
|
|
|
5718
5745
|
var dots = $2;
|
|
5719
5746
|
var binding = $3;
|
|
5720
5747
|
return {
|
|
5721
|
-
|
|
5722
|
-
children: [...ws || [], dots,
|
|
5748
|
+
type: "BindingRestElement",
|
|
5749
|
+
children: [...ws || [], dots, binding],
|
|
5750
|
+
binding,
|
|
5751
|
+
name: binding.name,
|
|
5752
|
+
names: binding.names,
|
|
5723
5753
|
rest: true
|
|
5724
5754
|
};
|
|
5725
5755
|
});
|
|
@@ -5728,8 +5758,11 @@ ${input.slice(result.pos)}
|
|
|
5728
5758
|
var binding = $2;
|
|
5729
5759
|
var dots = $3;
|
|
5730
5760
|
return {
|
|
5731
|
-
|
|
5732
|
-
children: [...ws || [], dots,
|
|
5761
|
+
type: "BindingRestElement",
|
|
5762
|
+
children: [...ws || [], dots, binding],
|
|
5763
|
+
binding,
|
|
5764
|
+
name: binding.name,
|
|
5765
|
+
names: binding.names,
|
|
5733
5766
|
rest: true
|
|
5734
5767
|
};
|
|
5735
5768
|
});
|
|
@@ -10607,33 +10640,20 @@ ${input.slice(result.pos)}
|
|
|
10607
10640
|
return result;
|
|
10608
10641
|
}
|
|
10609
10642
|
}
|
|
10610
|
-
var CaseClause$0 = $TS($S(
|
|
10611
|
-
var
|
|
10643
|
+
var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
|
|
10644
|
+
var patterns = $1;
|
|
10612
10645
|
var block = $2;
|
|
10613
10646
|
return {
|
|
10614
10647
|
type: "PatternClause",
|
|
10615
10648
|
children: $0,
|
|
10616
10649
|
block,
|
|
10617
|
-
|
|
10650
|
+
patterns
|
|
10618
10651
|
};
|
|
10619
10652
|
});
|
|
10620
|
-
var CaseClause$1 = $
|
|
10621
|
-
var pattern = $1;
|
|
10622
|
-
var block = $2;
|
|
10623
|
-
return {
|
|
10624
|
-
type: "PatternClause",
|
|
10625
|
-
children: $0,
|
|
10626
|
-
block,
|
|
10627
|
-
pattern: {
|
|
10628
|
-
type: "ConditionFragment",
|
|
10629
|
-
children: pattern
|
|
10630
|
-
}
|
|
10631
|
-
};
|
|
10632
|
-
});
|
|
10633
|
-
var CaseClause$2 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
|
|
10653
|
+
var CaseClause$1 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
|
|
10634
10654
|
return { "type": "CaseClause", "children": value };
|
|
10635
10655
|
});
|
|
10636
|
-
var CaseClause$
|
|
10656
|
+
var CaseClause$2 = $TS($S(When, CaseExpressionList, InsertOpenBrace, $C(ThenClause, NestedBlockStatements, EmptyBareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
10637
10657
|
var cases = $2;
|
|
10638
10658
|
var block = $4;
|
|
10639
10659
|
var b = $5;
|
|
@@ -10645,7 +10665,7 @@ ${input.slice(result.pos)}
|
|
|
10645
10665
|
children: $0
|
|
10646
10666
|
};
|
|
10647
10667
|
});
|
|
10648
|
-
var CaseClause$
|
|
10668
|
+
var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
|
|
10649
10669
|
var block = $3;
|
|
10650
10670
|
return {
|
|
10651
10671
|
type: "DefaultClause",
|
|
@@ -10653,7 +10673,7 @@ ${input.slice(result.pos)}
|
|
|
10653
10673
|
children: $0
|
|
10654
10674
|
};
|
|
10655
10675
|
});
|
|
10656
|
-
var CaseClause$
|
|
10676
|
+
var CaseClause$4 = $TS($S(Else, ImpliedColon, $C(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
|
|
10657
10677
|
var block = $3;
|
|
10658
10678
|
$1.token = "default";
|
|
10659
10679
|
return {
|
|
@@ -10673,17 +10693,74 @@ ${input.slice(result.pos)}
|
|
|
10673
10693
|
}
|
|
10674
10694
|
}
|
|
10675
10695
|
if (state.tokenize) {
|
|
10676
|
-
const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state)
|
|
10696
|
+
const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state));
|
|
10677
10697
|
if (state.events)
|
|
10678
10698
|
state.events.exit?.("CaseClause", state, result, eventData);
|
|
10679
10699
|
return result;
|
|
10680
10700
|
} else {
|
|
10681
|
-
const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state)
|
|
10701
|
+
const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state);
|
|
10682
10702
|
if (state.events)
|
|
10683
10703
|
state.events.exit?.("CaseClause", state, result, eventData);
|
|
10684
10704
|
return result;
|
|
10685
10705
|
}
|
|
10686
10706
|
}
|
|
10707
|
+
var PatternExpressionList$0 = $TS($S(ConditionFragment, $Q($S($E(_), Comma, $E(_), ConditionFragment))), function($skip, $loc, $0, $1, $2) {
|
|
10708
|
+
var first = $1;
|
|
10709
|
+
var rest = $2;
|
|
10710
|
+
return [first, ...rest.map(([, , , p]) => p)];
|
|
10711
|
+
});
|
|
10712
|
+
function PatternExpressionList(state) {
|
|
10713
|
+
let eventData;
|
|
10714
|
+
if (state.events) {
|
|
10715
|
+
const result = state.events.enter?.("PatternExpressionList", state);
|
|
10716
|
+
if (result) {
|
|
10717
|
+
if (result.cache)
|
|
10718
|
+
return result.cache;
|
|
10719
|
+
eventData = result.data;
|
|
10720
|
+
}
|
|
10721
|
+
}
|
|
10722
|
+
if (state.tokenize) {
|
|
10723
|
+
const result = $TOKEN("PatternExpressionList", state, PatternExpressionList$0(state));
|
|
10724
|
+
if (state.events)
|
|
10725
|
+
state.events.exit?.("PatternExpressionList", state, result, eventData);
|
|
10726
|
+
return result;
|
|
10727
|
+
} else {
|
|
10728
|
+
const result = PatternExpressionList$0(state);
|
|
10729
|
+
if (state.events)
|
|
10730
|
+
state.events.exit?.("PatternExpressionList", state, result, eventData);
|
|
10731
|
+
return result;
|
|
10732
|
+
}
|
|
10733
|
+
}
|
|
10734
|
+
var ConditionFragment$0 = BindingPattern;
|
|
10735
|
+
var ConditionFragment$1 = $TV($P(SingleLineBinaryOpRHS), function($skip, $loc, $0, $1) {
|
|
10736
|
+
var pattern = $0;
|
|
10737
|
+
return {
|
|
10738
|
+
type: "ConditionFragment",
|
|
10739
|
+
children: pattern
|
|
10740
|
+
};
|
|
10741
|
+
});
|
|
10742
|
+
function ConditionFragment(state) {
|
|
10743
|
+
let eventData;
|
|
10744
|
+
if (state.events) {
|
|
10745
|
+
const result = state.events.enter?.("ConditionFragment", state);
|
|
10746
|
+
if (result) {
|
|
10747
|
+
if (result.cache)
|
|
10748
|
+
return result.cache;
|
|
10749
|
+
eventData = result.data;
|
|
10750
|
+
}
|
|
10751
|
+
}
|
|
10752
|
+
if (state.tokenize) {
|
|
10753
|
+
const result = $TOKEN("ConditionFragment", state, ConditionFragment$0(state) || ConditionFragment$1(state));
|
|
10754
|
+
if (state.events)
|
|
10755
|
+
state.events.exit?.("ConditionFragment", state, result, eventData);
|
|
10756
|
+
return result;
|
|
10757
|
+
} else {
|
|
10758
|
+
const result = ConditionFragment$0(state) || ConditionFragment$1(state);
|
|
10759
|
+
if (state.events)
|
|
10760
|
+
state.events.exit?.("ConditionFragment", state, result, eventData);
|
|
10761
|
+
return result;
|
|
10762
|
+
}
|
|
10763
|
+
}
|
|
10687
10764
|
var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($Q(_), ExpressionWithIndentedApplicationForbidden, ImpliedColon)), $Q($S(__, Comma, ExpressionWithIndentedApplicationForbidden, ImpliedColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
10688
10765
|
var first = $2;
|
|
10689
10766
|
var rest = $3;
|
|
@@ -19180,7 +19257,7 @@ ${input.slice(result.pos)}
|
|
|
19180
19257
|
return result;
|
|
19181
19258
|
}
|
|
19182
19259
|
}
|
|
19183
|
-
var TypeList$0 = $S(
|
|
19260
|
+
var TypeList$0 = $S(TypeElement, $Q($S(__, Comma, TypeElement)));
|
|
19184
19261
|
function TypeList(state) {
|
|
19185
19262
|
let eventData;
|
|
19186
19263
|
if (state.events) {
|
|
@@ -19203,6 +19280,39 @@ ${input.slice(result.pos)}
|
|
|
19203
19280
|
return result;
|
|
19204
19281
|
}
|
|
19205
19282
|
}
|
|
19283
|
+
var TypeElement$0 = $S($S(__, DotDotDot, __), Type);
|
|
19284
|
+
var TypeElement$1 = $TS($S(Type, $E($S($E(_), DotDotDot))), function($skip, $loc, $0, $1, $2) {
|
|
19285
|
+
var type = $1;
|
|
19286
|
+
var dots = $2;
|
|
19287
|
+
if (!dots)
|
|
19288
|
+
return type;
|
|
19289
|
+
const ws = getTrimmingSpace(type);
|
|
19290
|
+
if (!ws)
|
|
19291
|
+
return [dots[1], dots[0], type];
|
|
19292
|
+
return [ws, dots[1], dots[0], insertTrimmingSpace(type, "")];
|
|
19293
|
+
});
|
|
19294
|
+
function TypeElement(state) {
|
|
19295
|
+
let eventData;
|
|
19296
|
+
if (state.events) {
|
|
19297
|
+
const result = state.events.enter?.("TypeElement", state);
|
|
19298
|
+
if (result) {
|
|
19299
|
+
if (result.cache)
|
|
19300
|
+
return result.cache;
|
|
19301
|
+
eventData = result.data;
|
|
19302
|
+
}
|
|
19303
|
+
}
|
|
19304
|
+
if (state.tokenize) {
|
|
19305
|
+
const result = $TOKEN("TypeElement", state, TypeElement$0(state) || TypeElement$1(state));
|
|
19306
|
+
if (state.events)
|
|
19307
|
+
state.events.exit?.("TypeElement", state, result, eventData);
|
|
19308
|
+
return result;
|
|
19309
|
+
} else {
|
|
19310
|
+
const result = TypeElement$0(state) || TypeElement$1(state);
|
|
19311
|
+
if (state.events)
|
|
19312
|
+
state.events.exit?.("TypeElement", state, result, eventData);
|
|
19313
|
+
return result;
|
|
19314
|
+
}
|
|
19315
|
+
}
|
|
19206
19316
|
var NestedTypeList$0 = $TS($S(PushIndent, $Q(NestedType), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
|
|
19207
19317
|
var types = $2;
|
|
19208
19318
|
if (types.length)
|
|
@@ -21341,20 +21451,27 @@ ${input.slice(result.pos)}
|
|
|
21341
21451
|
module.wrapIIFE = (exp, async) => {
|
|
21342
21452
|
let prefix, suffix;
|
|
21343
21453
|
if (async) {
|
|
21344
|
-
prefix = "(async ()=>
|
|
21345
|
-
suffix = "
|
|
21454
|
+
prefix = "(async ()=>";
|
|
21455
|
+
suffix = ")()";
|
|
21346
21456
|
} else if (hasAwait(exp)) {
|
|
21347
|
-
prefix = "(await (async ()=>
|
|
21348
|
-
suffix = "
|
|
21457
|
+
prefix = "(await (async ()=>";
|
|
21458
|
+
suffix = ")())";
|
|
21349
21459
|
} else {
|
|
21350
|
-
prefix = "(()=>
|
|
21351
|
-
suffix = "
|
|
21352
|
-
}
|
|
21353
|
-
if (Array.isArray(exp)) {
|
|
21354
|
-
return [prefix, ...exp, suffix];
|
|
21355
|
-
} else {
|
|
21356
|
-
return [prefix, exp, suffix];
|
|
21460
|
+
prefix = "(()=>";
|
|
21461
|
+
suffix = ")()";
|
|
21357
21462
|
}
|
|
21463
|
+
const expressions = Array.isArray(exp) ? [[...exp]] : [exp];
|
|
21464
|
+
const block = {
|
|
21465
|
+
type: "BlockStatement",
|
|
21466
|
+
expressions,
|
|
21467
|
+
children: ["{", expressions, "}"],
|
|
21468
|
+
bare: false
|
|
21469
|
+
};
|
|
21470
|
+
return [
|
|
21471
|
+
prefix,
|
|
21472
|
+
block,
|
|
21473
|
+
suffix
|
|
21474
|
+
];
|
|
21358
21475
|
};
|
|
21359
21476
|
function wrapIterationReturningResults(statement, outerRef) {
|
|
21360
21477
|
if (statement.type === "DoStatement") {
|
|
@@ -21792,8 +21909,8 @@ ${input.slice(result.pos)}
|
|
|
21792
21909
|
module.adjustBindingElements = function(elements) {
|
|
21793
21910
|
const names = elements.flatMap((p) => p.names || []), { length } = elements;
|
|
21794
21911
|
let blockPrefix, restIndex = -1, restCount = 0;
|
|
21795
|
-
elements.forEach(({
|
|
21796
|
-
if (
|
|
21912
|
+
elements.forEach(({ type }, i) => {
|
|
21913
|
+
if (type === "BindingRestElement") {
|
|
21797
21914
|
if (restIndex < 0)
|
|
21798
21915
|
restIndex = i;
|
|
21799
21916
|
restCount++;
|
|
@@ -21809,17 +21926,15 @@ ${input.slice(result.pos)}
|
|
|
21809
21926
|
} else if (restCount === 1) {
|
|
21810
21927
|
const rest = elements[restIndex];
|
|
21811
21928
|
const after = elements.slice(restIndex + 1);
|
|
21812
|
-
|
|
21813
|
-
|
|
21814
|
-
|
|
21815
|
-
|
|
21816
|
-
|
|
21817
|
-
|
|
21818
|
-
}
|
|
21819
|
-
if (after.length) {
|
|
21929
|
+
const restIdentifier = rest.binding.ref || rest.binding;
|
|
21930
|
+
names.push(...rest.names || []);
|
|
21931
|
+
let l = after.length;
|
|
21932
|
+
if (l) {
|
|
21933
|
+
if (arrayElementHasTrailingComma(after[l - 1]))
|
|
21934
|
+
l++;
|
|
21820
21935
|
blockPrefix = {
|
|
21821
21936
|
type: "PostRestBindingElements",
|
|
21822
|
-
children: ["[", insertTrimmingSpace(after, ""), "] = ", restIdentifier, ".splice(-",
|
|
21937
|
+
children: ["[", insertTrimmingSpace(after, ""), "] = ", restIdentifier, ".splice(-", l.toString(), ")"],
|
|
21823
21938
|
names: after.flatMap((p) => p.names)
|
|
21824
21939
|
};
|
|
21825
21940
|
}
|
|
@@ -22289,7 +22404,11 @@ ${input.slice(result.pos)}
|
|
|
22289
22404
|
}
|
|
22290
22405
|
}
|
|
22291
22406
|
function elideMatchersFromArrayBindings(elements) {
|
|
22292
|
-
return elements.map((
|
|
22407
|
+
return elements.map((el) => {
|
|
22408
|
+
if (el.type === "BindingRestElement") {
|
|
22409
|
+
return ["", el, void 0];
|
|
22410
|
+
}
|
|
22411
|
+
const { children: [ws, e, sep] } = el;
|
|
22293
22412
|
switch (e.type) {
|
|
22294
22413
|
case "Literal":
|
|
22295
22414
|
case "RegularExpressionLiteral":
|
|
@@ -22336,8 +22455,15 @@ ${input.slice(result.pos)}
|
|
|
22336
22455
|
}
|
|
22337
22456
|
function nonMatcherBindings(pattern) {
|
|
22338
22457
|
switch (pattern.type) {
|
|
22339
|
-
case "ArrayBindingPattern":
|
|
22340
|
-
|
|
22458
|
+
case "ArrayBindingPattern": {
|
|
22459
|
+
const elements = elideMatchersFromArrayBindings(pattern.elements);
|
|
22460
|
+
const children = ["[", elements, "]"];
|
|
22461
|
+
return {
|
|
22462
|
+
...pattern,
|
|
22463
|
+
children,
|
|
22464
|
+
elements
|
|
22465
|
+
};
|
|
22466
|
+
}
|
|
22341
22467
|
case "PostRestBindingElements": {
|
|
22342
22468
|
const els = elideMatchersFromArrayBindings(pattern.children[1]);
|
|
22343
22469
|
return {
|
|
@@ -22357,11 +22483,25 @@ ${input.slice(result.pos)}
|
|
|
22357
22483
|
}
|
|
22358
22484
|
function aggregateDuplicateBindings(bindings) {
|
|
22359
22485
|
const props = gatherRecursiveAll(bindings, (n) => n.type === "BindingProperty");
|
|
22486
|
+
const arrayBindings = gatherRecursiveAll(bindings, (n) => n.type === "ArrayBindingPattern");
|
|
22487
|
+
arrayBindings.forEach((a) => {
|
|
22488
|
+
const { elements } = a;
|
|
22489
|
+
elements.forEach((element) => {
|
|
22490
|
+
if (Array.isArray(element)) {
|
|
22491
|
+
const [, e] = element;
|
|
22492
|
+
if (e.type === "Identifier") {
|
|
22493
|
+
props.push(e);
|
|
22494
|
+
} else if (e.type === "BindingRestElement") {
|
|
22495
|
+
props.push(e);
|
|
22496
|
+
}
|
|
22497
|
+
}
|
|
22498
|
+
});
|
|
22499
|
+
});
|
|
22360
22500
|
const declarations = [];
|
|
22361
22501
|
const propsGroupedByName = /* @__PURE__ */ new Map();
|
|
22362
22502
|
for (const p of props) {
|
|
22363
22503
|
const { name, value } = p;
|
|
22364
|
-
const key = value?.name || name
|
|
22504
|
+
const key = value?.name || name?.name || name;
|
|
22365
22505
|
if (propsGroupedByName.has(key)) {
|
|
22366
22506
|
propsGroupedByName.get(key).push(p);
|
|
22367
22507
|
} else {
|
|
@@ -22381,7 +22521,7 @@ ${input.slice(result.pos)}
|
|
|
22381
22521
|
base: `_${key}`,
|
|
22382
22522
|
id: key
|
|
22383
22523
|
};
|
|
22384
|
-
p
|
|
22524
|
+
aliasBinding(p, ref);
|
|
22385
22525
|
});
|
|
22386
22526
|
return;
|
|
22387
22527
|
}
|
|
@@ -22393,7 +22533,7 @@ ${input.slice(result.pos)}
|
|
|
22393
22533
|
base: key,
|
|
22394
22534
|
id: key
|
|
22395
22535
|
};
|
|
22396
|
-
p
|
|
22536
|
+
aliasBinding(p, ref);
|
|
22397
22537
|
return ref;
|
|
22398
22538
|
});
|
|
22399
22539
|
declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
|
|
@@ -22427,6 +22567,7 @@ ${input.slice(result.pos)}
|
|
|
22427
22567
|
expression = expression.expression;
|
|
22428
22568
|
}
|
|
22429
22569
|
let ref = module.needsRef(expression, "m") || expression;
|
|
22570
|
+
let hoistDec = ref !== expression ? [["", ["const ", ref, " = ", expression], ";"]] : void 0;
|
|
22430
22571
|
let prev = [], root = prev;
|
|
22431
22572
|
const l = clauses.length;
|
|
22432
22573
|
clauses.forEach((c, i) => {
|
|
@@ -22434,18 +22575,28 @@ ${input.slice(result.pos)}
|
|
|
22434
22575
|
prev.push(c.block);
|
|
22435
22576
|
return;
|
|
22436
22577
|
}
|
|
22437
|
-
let {
|
|
22578
|
+
let { patterns, block } = c;
|
|
22579
|
+
let pattern = patterns[0];
|
|
22438
22580
|
const indent = block.expressions?.[0]?.[0] || "";
|
|
22439
|
-
const
|
|
22440
|
-
|
|
22441
|
-
|
|
22442
|
-
|
|
22443
|
-
|
|
22444
|
-
|
|
22581
|
+
const alternativeConditions = patterns.map((pattern2, i2) => {
|
|
22582
|
+
const conditions = [];
|
|
22583
|
+
getPatternConditions(pattern2, ref, conditions);
|
|
22584
|
+
return conditions;
|
|
22585
|
+
});
|
|
22586
|
+
const conditionExpression = alternativeConditions.map((conditions, i2) => {
|
|
22587
|
+
const conditionArray = conditions.map((c2, i3) => {
|
|
22588
|
+
if (i3 === 0)
|
|
22445
22589
|
return c2;
|
|
22446
22590
|
return [" && ", ...c2];
|
|
22447
|
-
})
|
|
22448
|
-
|
|
22591
|
+
});
|
|
22592
|
+
if (i2 === 0)
|
|
22593
|
+
return conditionArray;
|
|
22594
|
+
return [" || ", ...conditionArray];
|
|
22595
|
+
});
|
|
22596
|
+
const condition = {
|
|
22597
|
+
type: "ParenthesizedExpression",
|
|
22598
|
+
children: ["(", conditionExpression, ")"],
|
|
22599
|
+
expression: conditionExpression
|
|
22449
22600
|
};
|
|
22450
22601
|
const prefix = [];
|
|
22451
22602
|
switch (pattern.type) {
|
|
@@ -22479,8 +22630,10 @@ ${input.slice(result.pos)}
|
|
|
22479
22630
|
type: "IfStatement",
|
|
22480
22631
|
children: ["if", condition, block, next],
|
|
22481
22632
|
then: block,
|
|
22482
|
-
else: next
|
|
22633
|
+
else: next,
|
|
22634
|
+
hoistDec
|
|
22483
22635
|
}]);
|
|
22636
|
+
hoistDec = void 0;
|
|
22484
22637
|
prev = next;
|
|
22485
22638
|
});
|
|
22486
22639
|
if (module.config.implicitReturns && s.type === "SwitchExpression") {
|
|
@@ -23159,6 +23312,8 @@ ${input.slice(result.pos)}
|
|
|
23159
23312
|
exports.parse = parse2;
|
|
23160
23313
|
exports.default = { parse: parse2 };
|
|
23161
23314
|
var {
|
|
23315
|
+
aliasBinding,
|
|
23316
|
+
arrayElementHasTrailingComma,
|
|
23162
23317
|
blockWithPrefix,
|
|
23163
23318
|
clone,
|
|
23164
23319
|
convertMethodToFunction,
|
|
@@ -23621,7 +23776,7 @@ var parse;
|
|
|
23621
23776
|
var uncacheable;
|
|
23622
23777
|
({ parse } = import_parser.default);
|
|
23623
23778
|
({ SourceMap: SourceMap2 } = util_exports);
|
|
23624
|
-
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowMultiLineImplicitObjectLiteral", "AllowNewlineBinaryOp", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "Dedented", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidMultiLineImplicitObjectLiteral", "ForbidNewlineBinaryOp", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedNonAssignmentExtendedExpression", "NestedObject", "NestedPropertyDefinitions", "NewlineBinaryOpAllowed", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreMultiLineImplicitObjectLiteral", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RestoreNewlineBinaryOp", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineBinaryOpRHS", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
23779
|
+
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowMultiLineImplicitObjectLiteral", "AllowNewlineBinaryOp", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "ConditionFragment", "Declaration", "Debugger", "Dedented", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidMultiLineImplicitObjectLiteral", "ForbidNewlineBinaryOp", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedNonAssignmentExtendedExpression", "NestedObject", "NestedPropertyDefinitions", "NewlineBinaryOpAllowed", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PatternExpressionList", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreMultiLineImplicitObjectLiteral", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RestoreNewlineBinaryOp", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineBinaryOpRHS", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
23625
23780
|
var compile = function(src, options) {
|
|
23626
23781
|
var ast, code, events, filename, ref, result, sm;
|
|
23627
23782
|
if (!options) {
|