@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.js
CHANGED
|
@@ -30,6 +30,29 @@ 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 aliasBinding(p, ref) {
|
|
34
|
+
if (p.type === "Identifier") {
|
|
35
|
+
p.children[0] = ref;
|
|
36
|
+
} else if (p.type === "BindingRestElement") {
|
|
37
|
+
aliasBinding(p.binding, ref);
|
|
38
|
+
} else if (p.value?.type === "Identifier") {
|
|
39
|
+
aliasBinding(p.value, ref);
|
|
40
|
+
} else {
|
|
41
|
+
p.value = ref;
|
|
42
|
+
p.children.push(": ", ref);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function arrayElementHasTrailingComma(elementNode) {
|
|
46
|
+
const { children } = elementNode, { length } = children;
|
|
47
|
+
const lastChild = children[length - 1];
|
|
48
|
+
if (lastChild) {
|
|
49
|
+
const l2 = lastChild.length;
|
|
50
|
+
if (lastChild[l2 - 1]?.token === ",") {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
33
56
|
function blockWithPrefix(prefixStatements, block) {
|
|
34
57
|
if (prefixStatements && prefixStatements.length) {
|
|
35
58
|
const indent = getIndent(block.expressions[0]);
|
|
@@ -172,7 +195,7 @@ var require_lib = __commonJS({
|
|
|
172
195
|
function hoistRefDecs(statements) {
|
|
173
196
|
gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
|
|
174
197
|
const { hoistDec } = node;
|
|
175
|
-
|
|
198
|
+
let outer = closest(node, ["IfStatement", "IterationStatement"]);
|
|
176
199
|
if (!outer) {
|
|
177
200
|
node.children.push({
|
|
178
201
|
type: "Error",
|
|
@@ -180,7 +203,11 @@ var require_lib = __commonJS({
|
|
|
180
203
|
});
|
|
181
204
|
return;
|
|
182
205
|
}
|
|
183
|
-
|
|
206
|
+
let block = outer.parent;
|
|
207
|
+
if (block.type === "PatternMatchingStatement") {
|
|
208
|
+
outer = block;
|
|
209
|
+
block = block.parent;
|
|
210
|
+
}
|
|
184
211
|
const { expressions } = block;
|
|
185
212
|
const index = expressions.findIndex(([, s]) => outer === s);
|
|
186
213
|
if (index < 0)
|
|
@@ -607,6 +634,8 @@ var require_lib = __commonJS({
|
|
|
607
634
|
};
|
|
608
635
|
}
|
|
609
636
|
module2.exports = {
|
|
637
|
+
aliasBinding,
|
|
638
|
+
arrayElementHasTrailingComma,
|
|
610
639
|
blockWithPrefix,
|
|
611
640
|
clone,
|
|
612
641
|
convertMethodToFunction,
|
|
@@ -1297,6 +1326,8 @@ ${input.slice(result.pos)}
|
|
|
1297
1326
|
NestedCaseClauses,
|
|
1298
1327
|
NestedCaseClause,
|
|
1299
1328
|
CaseClause,
|
|
1329
|
+
PatternExpressionList,
|
|
1330
|
+
ConditionFragment,
|
|
1300
1331
|
CaseExpressionList,
|
|
1301
1332
|
ImpliedColon,
|
|
1302
1333
|
TryStatement,
|
|
@@ -1600,6 +1631,7 @@ ${input.slice(result.pos)}
|
|
|
1600
1631
|
ImportType,
|
|
1601
1632
|
TypeTuple,
|
|
1602
1633
|
TypeList,
|
|
1634
|
+
TypeElement,
|
|
1603
1635
|
NestedTypeList,
|
|
1604
1636
|
NestedType,
|
|
1605
1637
|
TypeConditional,
|
|
@@ -4892,13 +4924,8 @@ ${input.slice(result.pos)}
|
|
|
4892
4924
|
var close = $7;
|
|
4893
4925
|
const names = pes.flatMap((p) => p.names);
|
|
4894
4926
|
if (rest) {
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
restIdentifier = rest.binding.ref;
|
|
4898
|
-
} else {
|
|
4899
|
-
names.push(...rest.names);
|
|
4900
|
-
restIdentifier = rest.names[0];
|
|
4901
|
-
}
|
|
4927
|
+
const restIdentifier = rest.binding.ref || rest.binding;
|
|
4928
|
+
names.push(...rest.names || []);
|
|
4902
4929
|
let blockPrefix;
|
|
4903
4930
|
if (after.length) {
|
|
4904
4931
|
blockPrefix = {
|
|
@@ -4956,7 +4983,7 @@ ${input.slice(result.pos)}
|
|
|
4956
4983
|
type: "FunctionRestParameter",
|
|
4957
4984
|
children: $0,
|
|
4958
4985
|
names: id.names,
|
|
4959
|
-
binding: id
|
|
4986
|
+
binding: id.binding
|
|
4960
4987
|
};
|
|
4961
4988
|
});
|
|
4962
4989
|
function FunctionRestParameter(state) {
|
|
@@ -5720,8 +5747,11 @@ ${input.slice(result.pos)}
|
|
|
5720
5747
|
var dots = $2;
|
|
5721
5748
|
var binding = $3;
|
|
5722
5749
|
return {
|
|
5723
|
-
|
|
5724
|
-
children: [...ws || [], dots,
|
|
5750
|
+
type: "BindingRestElement",
|
|
5751
|
+
children: [...ws || [], dots, binding],
|
|
5752
|
+
binding,
|
|
5753
|
+
name: binding.name,
|
|
5754
|
+
names: binding.names,
|
|
5725
5755
|
rest: true
|
|
5726
5756
|
};
|
|
5727
5757
|
});
|
|
@@ -5730,8 +5760,11 @@ ${input.slice(result.pos)}
|
|
|
5730
5760
|
var binding = $2;
|
|
5731
5761
|
var dots = $3;
|
|
5732
5762
|
return {
|
|
5733
|
-
|
|
5734
|
-
children: [...ws || [], dots,
|
|
5763
|
+
type: "BindingRestElement",
|
|
5764
|
+
children: [...ws || [], dots, binding],
|
|
5765
|
+
binding,
|
|
5766
|
+
name: binding.name,
|
|
5767
|
+
names: binding.names,
|
|
5735
5768
|
rest: true
|
|
5736
5769
|
};
|
|
5737
5770
|
});
|
|
@@ -10609,33 +10642,20 @@ ${input.slice(result.pos)}
|
|
|
10609
10642
|
return result;
|
|
10610
10643
|
}
|
|
10611
10644
|
}
|
|
10612
|
-
var CaseClause$0 = $TS($S(
|
|
10613
|
-
var
|
|
10645
|
+
var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
|
|
10646
|
+
var patterns = $1;
|
|
10614
10647
|
var block = $2;
|
|
10615
10648
|
return {
|
|
10616
10649
|
type: "PatternClause",
|
|
10617
10650
|
children: $0,
|
|
10618
10651
|
block,
|
|
10619
|
-
|
|
10652
|
+
patterns
|
|
10620
10653
|
};
|
|
10621
10654
|
});
|
|
10622
|
-
var CaseClause$1 = $
|
|
10623
|
-
var pattern = $1;
|
|
10624
|
-
var block = $2;
|
|
10625
|
-
return {
|
|
10626
|
-
type: "PatternClause",
|
|
10627
|
-
children: $0,
|
|
10628
|
-
block,
|
|
10629
|
-
pattern: {
|
|
10630
|
-
type: "ConditionFragment",
|
|
10631
|
-
children: pattern
|
|
10632
|
-
}
|
|
10633
|
-
};
|
|
10634
|
-
});
|
|
10635
|
-
var CaseClause$2 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
|
|
10655
|
+
var CaseClause$1 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
|
|
10636
10656
|
return { "type": "CaseClause", "children": value };
|
|
10637
10657
|
});
|
|
10638
|
-
var CaseClause$
|
|
10658
|
+
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) {
|
|
10639
10659
|
var cases = $2;
|
|
10640
10660
|
var block = $4;
|
|
10641
10661
|
var b = $5;
|
|
@@ -10647,7 +10667,7 @@ ${input.slice(result.pos)}
|
|
|
10647
10667
|
children: $0
|
|
10648
10668
|
};
|
|
10649
10669
|
});
|
|
10650
|
-
var CaseClause$
|
|
10670
|
+
var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
|
|
10651
10671
|
var block = $3;
|
|
10652
10672
|
return {
|
|
10653
10673
|
type: "DefaultClause",
|
|
@@ -10655,7 +10675,7 @@ ${input.slice(result.pos)}
|
|
|
10655
10675
|
children: $0
|
|
10656
10676
|
};
|
|
10657
10677
|
});
|
|
10658
|
-
var CaseClause$
|
|
10678
|
+
var CaseClause$4 = $TS($S(Else, ImpliedColon, $C(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
|
|
10659
10679
|
var block = $3;
|
|
10660
10680
|
$1.token = "default";
|
|
10661
10681
|
return {
|
|
@@ -10675,17 +10695,74 @@ ${input.slice(result.pos)}
|
|
|
10675
10695
|
}
|
|
10676
10696
|
}
|
|
10677
10697
|
if (state.tokenize) {
|
|
10678
|
-
const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state)
|
|
10698
|
+
const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state));
|
|
10679
10699
|
if (state.events)
|
|
10680
10700
|
state.events.exit?.("CaseClause", state, result, eventData);
|
|
10681
10701
|
return result;
|
|
10682
10702
|
} else {
|
|
10683
|
-
const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state)
|
|
10703
|
+
const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state);
|
|
10684
10704
|
if (state.events)
|
|
10685
10705
|
state.events.exit?.("CaseClause", state, result, eventData);
|
|
10686
10706
|
return result;
|
|
10687
10707
|
}
|
|
10688
10708
|
}
|
|
10709
|
+
var PatternExpressionList$0 = $TS($S(ConditionFragment, $Q($S($E(_), Comma, $E(_), ConditionFragment))), function($skip, $loc, $0, $1, $2) {
|
|
10710
|
+
var first = $1;
|
|
10711
|
+
var rest = $2;
|
|
10712
|
+
return [first, ...rest.map(([, , , p]) => p)];
|
|
10713
|
+
});
|
|
10714
|
+
function PatternExpressionList(state) {
|
|
10715
|
+
let eventData;
|
|
10716
|
+
if (state.events) {
|
|
10717
|
+
const result = state.events.enter?.("PatternExpressionList", state);
|
|
10718
|
+
if (result) {
|
|
10719
|
+
if (result.cache)
|
|
10720
|
+
return result.cache;
|
|
10721
|
+
eventData = result.data;
|
|
10722
|
+
}
|
|
10723
|
+
}
|
|
10724
|
+
if (state.tokenize) {
|
|
10725
|
+
const result = $TOKEN("PatternExpressionList", state, PatternExpressionList$0(state));
|
|
10726
|
+
if (state.events)
|
|
10727
|
+
state.events.exit?.("PatternExpressionList", state, result, eventData);
|
|
10728
|
+
return result;
|
|
10729
|
+
} else {
|
|
10730
|
+
const result = PatternExpressionList$0(state);
|
|
10731
|
+
if (state.events)
|
|
10732
|
+
state.events.exit?.("PatternExpressionList", state, result, eventData);
|
|
10733
|
+
return result;
|
|
10734
|
+
}
|
|
10735
|
+
}
|
|
10736
|
+
var ConditionFragment$0 = BindingPattern;
|
|
10737
|
+
var ConditionFragment$1 = $TV($P(SingleLineBinaryOpRHS), function($skip, $loc, $0, $1) {
|
|
10738
|
+
var pattern = $0;
|
|
10739
|
+
return {
|
|
10740
|
+
type: "ConditionFragment",
|
|
10741
|
+
children: pattern
|
|
10742
|
+
};
|
|
10743
|
+
});
|
|
10744
|
+
function ConditionFragment(state) {
|
|
10745
|
+
let eventData;
|
|
10746
|
+
if (state.events) {
|
|
10747
|
+
const result = state.events.enter?.("ConditionFragment", state);
|
|
10748
|
+
if (result) {
|
|
10749
|
+
if (result.cache)
|
|
10750
|
+
return result.cache;
|
|
10751
|
+
eventData = result.data;
|
|
10752
|
+
}
|
|
10753
|
+
}
|
|
10754
|
+
if (state.tokenize) {
|
|
10755
|
+
const result = $TOKEN("ConditionFragment", state, ConditionFragment$0(state) || ConditionFragment$1(state));
|
|
10756
|
+
if (state.events)
|
|
10757
|
+
state.events.exit?.("ConditionFragment", state, result, eventData);
|
|
10758
|
+
return result;
|
|
10759
|
+
} else {
|
|
10760
|
+
const result = ConditionFragment$0(state) || ConditionFragment$1(state);
|
|
10761
|
+
if (state.events)
|
|
10762
|
+
state.events.exit?.("ConditionFragment", state, result, eventData);
|
|
10763
|
+
return result;
|
|
10764
|
+
}
|
|
10765
|
+
}
|
|
10689
10766
|
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) {
|
|
10690
10767
|
var first = $2;
|
|
10691
10768
|
var rest = $3;
|
|
@@ -19182,7 +19259,7 @@ ${input.slice(result.pos)}
|
|
|
19182
19259
|
return result;
|
|
19183
19260
|
}
|
|
19184
19261
|
}
|
|
19185
|
-
var TypeList$0 = $S(
|
|
19262
|
+
var TypeList$0 = $S(TypeElement, $Q($S(__, Comma, TypeElement)));
|
|
19186
19263
|
function TypeList(state) {
|
|
19187
19264
|
let eventData;
|
|
19188
19265
|
if (state.events) {
|
|
@@ -19205,6 +19282,39 @@ ${input.slice(result.pos)}
|
|
|
19205
19282
|
return result;
|
|
19206
19283
|
}
|
|
19207
19284
|
}
|
|
19285
|
+
var TypeElement$0 = $S($S(__, DotDotDot, __), Type);
|
|
19286
|
+
var TypeElement$1 = $TS($S(Type, $E($S($E(_), DotDotDot))), function($skip, $loc, $0, $1, $2) {
|
|
19287
|
+
var type = $1;
|
|
19288
|
+
var dots = $2;
|
|
19289
|
+
if (!dots)
|
|
19290
|
+
return type;
|
|
19291
|
+
const ws = getTrimmingSpace(type);
|
|
19292
|
+
if (!ws)
|
|
19293
|
+
return [dots[1], dots[0], type];
|
|
19294
|
+
return [ws, dots[1], dots[0], insertTrimmingSpace(type, "")];
|
|
19295
|
+
});
|
|
19296
|
+
function TypeElement(state) {
|
|
19297
|
+
let eventData;
|
|
19298
|
+
if (state.events) {
|
|
19299
|
+
const result = state.events.enter?.("TypeElement", state);
|
|
19300
|
+
if (result) {
|
|
19301
|
+
if (result.cache)
|
|
19302
|
+
return result.cache;
|
|
19303
|
+
eventData = result.data;
|
|
19304
|
+
}
|
|
19305
|
+
}
|
|
19306
|
+
if (state.tokenize) {
|
|
19307
|
+
const result = $TOKEN("TypeElement", state, TypeElement$0(state) || TypeElement$1(state));
|
|
19308
|
+
if (state.events)
|
|
19309
|
+
state.events.exit?.("TypeElement", state, result, eventData);
|
|
19310
|
+
return result;
|
|
19311
|
+
} else {
|
|
19312
|
+
const result = TypeElement$0(state) || TypeElement$1(state);
|
|
19313
|
+
if (state.events)
|
|
19314
|
+
state.events.exit?.("TypeElement", state, result, eventData);
|
|
19315
|
+
return result;
|
|
19316
|
+
}
|
|
19317
|
+
}
|
|
19208
19318
|
var NestedTypeList$0 = $TS($S(PushIndent, $Q(NestedType), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
|
|
19209
19319
|
var types = $2;
|
|
19210
19320
|
if (types.length)
|
|
@@ -21343,20 +21453,27 @@ ${input.slice(result.pos)}
|
|
|
21343
21453
|
module2.wrapIIFE = (exp, async) => {
|
|
21344
21454
|
let prefix, suffix;
|
|
21345
21455
|
if (async) {
|
|
21346
|
-
prefix = "(async ()=>
|
|
21347
|
-
suffix = "
|
|
21456
|
+
prefix = "(async ()=>";
|
|
21457
|
+
suffix = ")()";
|
|
21348
21458
|
} else if (hasAwait(exp)) {
|
|
21349
|
-
prefix = "(await (async ()=>
|
|
21350
|
-
suffix = "
|
|
21459
|
+
prefix = "(await (async ()=>";
|
|
21460
|
+
suffix = ")())";
|
|
21351
21461
|
} else {
|
|
21352
|
-
prefix = "(()=>
|
|
21353
|
-
suffix = "
|
|
21354
|
-
}
|
|
21355
|
-
if (Array.isArray(exp)) {
|
|
21356
|
-
return [prefix, ...exp, suffix];
|
|
21357
|
-
} else {
|
|
21358
|
-
return [prefix, exp, suffix];
|
|
21462
|
+
prefix = "(()=>";
|
|
21463
|
+
suffix = ")()";
|
|
21359
21464
|
}
|
|
21465
|
+
const expressions = Array.isArray(exp) ? [[...exp]] : [exp];
|
|
21466
|
+
const block = {
|
|
21467
|
+
type: "BlockStatement",
|
|
21468
|
+
expressions,
|
|
21469
|
+
children: ["{", expressions, "}"],
|
|
21470
|
+
bare: false
|
|
21471
|
+
};
|
|
21472
|
+
return [
|
|
21473
|
+
prefix,
|
|
21474
|
+
block,
|
|
21475
|
+
suffix
|
|
21476
|
+
];
|
|
21360
21477
|
};
|
|
21361
21478
|
function wrapIterationReturningResults(statement, outerRef) {
|
|
21362
21479
|
if (statement.type === "DoStatement") {
|
|
@@ -21794,8 +21911,8 @@ ${input.slice(result.pos)}
|
|
|
21794
21911
|
module2.adjustBindingElements = function(elements) {
|
|
21795
21912
|
const names = elements.flatMap((p) => p.names || []), { length } = elements;
|
|
21796
21913
|
let blockPrefix, restIndex = -1, restCount = 0;
|
|
21797
|
-
elements.forEach(({
|
|
21798
|
-
if (
|
|
21914
|
+
elements.forEach(({ type }, i) => {
|
|
21915
|
+
if (type === "BindingRestElement") {
|
|
21799
21916
|
if (restIndex < 0)
|
|
21800
21917
|
restIndex = i;
|
|
21801
21918
|
restCount++;
|
|
@@ -21811,17 +21928,15 @@ ${input.slice(result.pos)}
|
|
|
21811
21928
|
} else if (restCount === 1) {
|
|
21812
21929
|
const rest = elements[restIndex];
|
|
21813
21930
|
const after = elements.slice(restIndex + 1);
|
|
21814
|
-
|
|
21815
|
-
|
|
21816
|
-
|
|
21817
|
-
|
|
21818
|
-
|
|
21819
|
-
|
|
21820
|
-
}
|
|
21821
|
-
if (after.length) {
|
|
21931
|
+
const restIdentifier = rest.binding.ref || rest.binding;
|
|
21932
|
+
names.push(...rest.names || []);
|
|
21933
|
+
let l = after.length;
|
|
21934
|
+
if (l) {
|
|
21935
|
+
if (arrayElementHasTrailingComma(after[l - 1]))
|
|
21936
|
+
l++;
|
|
21822
21937
|
blockPrefix = {
|
|
21823
21938
|
type: "PostRestBindingElements",
|
|
21824
|
-
children: ["[", insertTrimmingSpace(after, ""), "] = ", restIdentifier, ".splice(-",
|
|
21939
|
+
children: ["[", insertTrimmingSpace(after, ""), "] = ", restIdentifier, ".splice(-", l.toString(), ")"],
|
|
21825
21940
|
names: after.flatMap((p) => p.names)
|
|
21826
21941
|
};
|
|
21827
21942
|
}
|
|
@@ -22291,7 +22406,11 @@ ${input.slice(result.pos)}
|
|
|
22291
22406
|
}
|
|
22292
22407
|
}
|
|
22293
22408
|
function elideMatchersFromArrayBindings(elements) {
|
|
22294
|
-
return elements.map((
|
|
22409
|
+
return elements.map((el) => {
|
|
22410
|
+
if (el.type === "BindingRestElement") {
|
|
22411
|
+
return ["", el, void 0];
|
|
22412
|
+
}
|
|
22413
|
+
const { children: [ws, e, sep] } = el;
|
|
22295
22414
|
switch (e.type) {
|
|
22296
22415
|
case "Literal":
|
|
22297
22416
|
case "RegularExpressionLiteral":
|
|
@@ -22338,8 +22457,15 @@ ${input.slice(result.pos)}
|
|
|
22338
22457
|
}
|
|
22339
22458
|
function nonMatcherBindings(pattern) {
|
|
22340
22459
|
switch (pattern.type) {
|
|
22341
|
-
case "ArrayBindingPattern":
|
|
22342
|
-
|
|
22460
|
+
case "ArrayBindingPattern": {
|
|
22461
|
+
const elements = elideMatchersFromArrayBindings(pattern.elements);
|
|
22462
|
+
const children = ["[", elements, "]"];
|
|
22463
|
+
return {
|
|
22464
|
+
...pattern,
|
|
22465
|
+
children,
|
|
22466
|
+
elements
|
|
22467
|
+
};
|
|
22468
|
+
}
|
|
22343
22469
|
case "PostRestBindingElements": {
|
|
22344
22470
|
const els = elideMatchersFromArrayBindings(pattern.children[1]);
|
|
22345
22471
|
return {
|
|
@@ -22359,11 +22485,25 @@ ${input.slice(result.pos)}
|
|
|
22359
22485
|
}
|
|
22360
22486
|
function aggregateDuplicateBindings(bindings) {
|
|
22361
22487
|
const props = gatherRecursiveAll(bindings, (n) => n.type === "BindingProperty");
|
|
22488
|
+
const arrayBindings = gatherRecursiveAll(bindings, (n) => n.type === "ArrayBindingPattern");
|
|
22489
|
+
arrayBindings.forEach((a) => {
|
|
22490
|
+
const { elements } = a;
|
|
22491
|
+
elements.forEach((element) => {
|
|
22492
|
+
if (Array.isArray(element)) {
|
|
22493
|
+
const [, e] = element;
|
|
22494
|
+
if (e.type === "Identifier") {
|
|
22495
|
+
props.push(e);
|
|
22496
|
+
} else if (e.type === "BindingRestElement") {
|
|
22497
|
+
props.push(e);
|
|
22498
|
+
}
|
|
22499
|
+
}
|
|
22500
|
+
});
|
|
22501
|
+
});
|
|
22362
22502
|
const declarations = [];
|
|
22363
22503
|
const propsGroupedByName = /* @__PURE__ */ new Map();
|
|
22364
22504
|
for (const p of props) {
|
|
22365
22505
|
const { name, value } = p;
|
|
22366
|
-
const key = value?.name || name
|
|
22506
|
+
const key = value?.name || name?.name || name;
|
|
22367
22507
|
if (propsGroupedByName.has(key)) {
|
|
22368
22508
|
propsGroupedByName.get(key).push(p);
|
|
22369
22509
|
} else {
|
|
@@ -22383,7 +22523,7 @@ ${input.slice(result.pos)}
|
|
|
22383
22523
|
base: `_${key}`,
|
|
22384
22524
|
id: key
|
|
22385
22525
|
};
|
|
22386
|
-
p
|
|
22526
|
+
aliasBinding(p, ref);
|
|
22387
22527
|
});
|
|
22388
22528
|
return;
|
|
22389
22529
|
}
|
|
@@ -22395,7 +22535,7 @@ ${input.slice(result.pos)}
|
|
|
22395
22535
|
base: key,
|
|
22396
22536
|
id: key
|
|
22397
22537
|
};
|
|
22398
|
-
p
|
|
22538
|
+
aliasBinding(p, ref);
|
|
22399
22539
|
return ref;
|
|
22400
22540
|
});
|
|
22401
22541
|
declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
|
|
@@ -22429,6 +22569,7 @@ ${input.slice(result.pos)}
|
|
|
22429
22569
|
expression = expression.expression;
|
|
22430
22570
|
}
|
|
22431
22571
|
let ref = module2.needsRef(expression, "m") || expression;
|
|
22572
|
+
let hoistDec = ref !== expression ? [["", ["const ", ref, " = ", expression], ";"]] : void 0;
|
|
22432
22573
|
let prev = [], root = prev;
|
|
22433
22574
|
const l = clauses.length;
|
|
22434
22575
|
clauses.forEach((c, i) => {
|
|
@@ -22436,18 +22577,28 @@ ${input.slice(result.pos)}
|
|
|
22436
22577
|
prev.push(c.block);
|
|
22437
22578
|
return;
|
|
22438
22579
|
}
|
|
22439
|
-
let {
|
|
22580
|
+
let { patterns, block } = c;
|
|
22581
|
+
let pattern = patterns[0];
|
|
22440
22582
|
const indent = block.expressions?.[0]?.[0] || "";
|
|
22441
|
-
const
|
|
22442
|
-
|
|
22443
|
-
|
|
22444
|
-
|
|
22445
|
-
|
|
22446
|
-
|
|
22583
|
+
const alternativeConditions = patterns.map((pattern2, i2) => {
|
|
22584
|
+
const conditions = [];
|
|
22585
|
+
getPatternConditions(pattern2, ref, conditions);
|
|
22586
|
+
return conditions;
|
|
22587
|
+
});
|
|
22588
|
+
const conditionExpression = alternativeConditions.map((conditions, i2) => {
|
|
22589
|
+
const conditionArray = conditions.map((c2, i3) => {
|
|
22590
|
+
if (i3 === 0)
|
|
22447
22591
|
return c2;
|
|
22448
22592
|
return [" && ", ...c2];
|
|
22449
|
-
})
|
|
22450
|
-
|
|
22593
|
+
});
|
|
22594
|
+
if (i2 === 0)
|
|
22595
|
+
return conditionArray;
|
|
22596
|
+
return [" || ", ...conditionArray];
|
|
22597
|
+
});
|
|
22598
|
+
const condition = {
|
|
22599
|
+
type: "ParenthesizedExpression",
|
|
22600
|
+
children: ["(", conditionExpression, ")"],
|
|
22601
|
+
expression: conditionExpression
|
|
22451
22602
|
};
|
|
22452
22603
|
const prefix = [];
|
|
22453
22604
|
switch (pattern.type) {
|
|
@@ -22481,8 +22632,10 @@ ${input.slice(result.pos)}
|
|
|
22481
22632
|
type: "IfStatement",
|
|
22482
22633
|
children: ["if", condition, block, next],
|
|
22483
22634
|
then: block,
|
|
22484
|
-
else: next
|
|
22635
|
+
else: next,
|
|
22636
|
+
hoistDec
|
|
22485
22637
|
}]);
|
|
22638
|
+
hoistDec = void 0;
|
|
22486
22639
|
prev = next;
|
|
22487
22640
|
});
|
|
22488
22641
|
if (module2.config.implicitReturns && s.type === "SwitchExpression") {
|
|
@@ -23161,6 +23314,8 @@ ${input.slice(result.pos)}
|
|
|
23161
23314
|
exports.parse = parse2;
|
|
23162
23315
|
exports.default = { parse: parse2 };
|
|
23163
23316
|
var {
|
|
23317
|
+
aliasBinding,
|
|
23318
|
+
arrayElementHasTrailingComma,
|
|
23164
23319
|
blockWithPrefix,
|
|
23165
23320
|
clone,
|
|
23166
23321
|
convertMethodToFunction,
|
|
@@ -23633,7 +23788,7 @@ var parse;
|
|
|
23633
23788
|
var uncacheable;
|
|
23634
23789
|
({ parse } = import_parser.default);
|
|
23635
23790
|
({ SourceMap: SourceMap2 } = util_exports);
|
|
23636
|
-
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"]);
|
|
23791
|
+
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"]);
|
|
23637
23792
|
var compile = function(src, options) {
|
|
23638
23793
|
var ast, code, events, filename, ref, result, sm;
|
|
23639
23794
|
if (!options) {
|