@danielx/civet 0.5.73 → 0.5.74
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/README.md +15 -5
- package/dist/browser.js +229 -32
- package/dist/civet +0 -0
- package/dist/main.js +229 -32
- package/dist/main.mjs +229 -32
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -639,6 +639,7 @@ ${input.slice(result.pos)}
|
|
|
639
639
|
StatementListItem,
|
|
640
640
|
PostfixedStatement,
|
|
641
641
|
PostfixedExpression,
|
|
642
|
+
NonPipelinePostfixedExpression,
|
|
642
643
|
PostfixStatement,
|
|
643
644
|
Statement,
|
|
644
645
|
EmptyStatement,
|
|
@@ -662,6 +663,7 @@ ${input.slice(result.pos)}
|
|
|
662
663
|
LoopStatement,
|
|
663
664
|
LoopClause,
|
|
664
665
|
DoWhileStatement,
|
|
666
|
+
DoStatement,
|
|
665
667
|
WhileStatement,
|
|
666
668
|
WhileClause,
|
|
667
669
|
ForStatement,
|
|
@@ -1035,6 +1037,7 @@ ${input.slice(result.pos)}
|
|
|
1035
1037
|
TrackIndented,
|
|
1036
1038
|
Samedent,
|
|
1037
1039
|
IndentedFurther,
|
|
1040
|
+
NotDedented,
|
|
1038
1041
|
PushIndent,
|
|
1039
1042
|
PopIndent,
|
|
1040
1043
|
Nested
|
|
@@ -1963,7 +1966,7 @@ ${input.slice(result.pos)}
|
|
|
1963
1966
|
var rhs = $2;
|
|
1964
1967
|
return [[], op, [], rhs];
|
|
1965
1968
|
});
|
|
1966
|
-
var BinaryOpRHS$1 = $S(
|
|
1969
|
+
var BinaryOpRHS$1 = $S(NotDedented, BinaryOp, $C(_, $S(EOS, __)), RHS);
|
|
1967
1970
|
function BinaryOpRHS(state) {
|
|
1968
1971
|
let eventData;
|
|
1969
1972
|
if (state.events) {
|
|
@@ -2445,7 +2448,7 @@ ${input.slice(result.pos)}
|
|
|
2445
2448
|
return result;
|
|
2446
2449
|
}
|
|
2447
2450
|
}
|
|
2448
|
-
var FatArrowBody$0 = $T($S($N(EOS),
|
|
2451
|
+
var FatArrowBody$0 = $T($S($N(EOS), NonPipelinePostfixedExpression, $N(SemicolonDelimiter)), function(value) {
|
|
2449
2452
|
var exp = value[1];
|
|
2450
2453
|
return exp;
|
|
2451
2454
|
});
|
|
@@ -2576,12 +2579,13 @@ ${input.slice(result.pos)}
|
|
|
2576
2579
|
return result;
|
|
2577
2580
|
}
|
|
2578
2581
|
}
|
|
2579
|
-
var PipelineExpression$0 = $TS($S(PipelineHeadItem, $P($S(
|
|
2580
|
-
var
|
|
2581
|
-
var
|
|
2582
|
+
var PipelineExpression$0 = $TS($S($E(_), PipelineHeadItem, $P($S(NotDedented, Pipe, __, PipelineTailItem))), function($skip, $loc, $0, $1, $2, $3) {
|
|
2583
|
+
var ws = $1;
|
|
2584
|
+
var head = $2;
|
|
2585
|
+
var body = $3;
|
|
2582
2586
|
return {
|
|
2583
2587
|
type: "PipelineExpression",
|
|
2584
|
-
children: [head, body]
|
|
2588
|
+
children: [ws, head, body]
|
|
2585
2589
|
};
|
|
2586
2590
|
});
|
|
2587
2591
|
function PipelineExpression(state) {
|
|
@@ -8362,6 +8366,35 @@ ${input.slice(result.pos)}
|
|
|
8362
8366
|
return result;
|
|
8363
8367
|
}
|
|
8364
8368
|
}
|
|
8369
|
+
var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
|
|
8370
|
+
var expression = $1;
|
|
8371
|
+
var post = $2;
|
|
8372
|
+
if (post)
|
|
8373
|
+
return module.attachPostfixStatementAsExpression(expression, post);
|
|
8374
|
+
return expression;
|
|
8375
|
+
});
|
|
8376
|
+
function NonPipelinePostfixedExpression(state) {
|
|
8377
|
+
let eventData;
|
|
8378
|
+
if (state.events) {
|
|
8379
|
+
const result = state.events.enter?.("NonPipelinePostfixedExpression", state);
|
|
8380
|
+
if (result) {
|
|
8381
|
+
if (result.cache)
|
|
8382
|
+
return result.cache;
|
|
8383
|
+
eventData = result.data;
|
|
8384
|
+
}
|
|
8385
|
+
}
|
|
8386
|
+
if (state.tokenize) {
|
|
8387
|
+
const result = $TOKEN("NonPipelinePostfixedExpression", state, NonPipelinePostfixedExpression$0(state));
|
|
8388
|
+
if (state.events)
|
|
8389
|
+
state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
|
|
8390
|
+
return result;
|
|
8391
|
+
} else {
|
|
8392
|
+
const result = NonPipelinePostfixedExpression$0(state);
|
|
8393
|
+
if (state.events)
|
|
8394
|
+
state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
|
|
8395
|
+
return result;
|
|
8396
|
+
}
|
|
8397
|
+
}
|
|
8365
8398
|
var PostfixStatement$0 = ForClause;
|
|
8366
8399
|
var PostfixStatement$1 = IfClause;
|
|
8367
8400
|
var PostfixStatement$2 = LoopClause;
|
|
@@ -8898,8 +8931,11 @@ ${input.slice(result.pos)}
|
|
|
8898
8931
|
var IterationStatement$1 = $T($S($N(CoffeeDoEnabled), DoWhileStatement), function(value) {
|
|
8899
8932
|
return value[1];
|
|
8900
8933
|
});
|
|
8901
|
-
var IterationStatement$2 =
|
|
8902
|
-
|
|
8934
|
+
var IterationStatement$2 = $T($S($N(CoffeeDoEnabled), DoStatement), function(value) {
|
|
8935
|
+
return value[1];
|
|
8936
|
+
});
|
|
8937
|
+
var IterationStatement$3 = WhileStatement;
|
|
8938
|
+
var IterationStatement$4 = ForStatement;
|
|
8903
8939
|
function IterationStatement(state) {
|
|
8904
8940
|
let eventData;
|
|
8905
8941
|
if (state.events) {
|
|
@@ -8911,12 +8947,12 @@ ${input.slice(result.pos)}
|
|
|
8911
8947
|
}
|
|
8912
8948
|
}
|
|
8913
8949
|
if (state.tokenize) {
|
|
8914
|
-
const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state));
|
|
8950
|
+
const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state));
|
|
8915
8951
|
if (state.events)
|
|
8916
8952
|
state.events.exit?.("IterationStatement", state, result, eventData);
|
|
8917
8953
|
return result;
|
|
8918
8954
|
} else {
|
|
8919
|
-
const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state);
|
|
8955
|
+
const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state);
|
|
8920
8956
|
if (state.events)
|
|
8921
8957
|
state.events.exit?.("IterationStatement", state, result, eventData);
|
|
8922
8958
|
return result;
|
|
@@ -8925,6 +8961,7 @@ ${input.slice(result.pos)}
|
|
|
8925
8961
|
var IterationExpression$0 = $TS($S(IterationStatement), function($skip, $loc, $0, $1) {
|
|
8926
8962
|
return {
|
|
8927
8963
|
type: "IterationExpression",
|
|
8964
|
+
subtype: $1.type,
|
|
8928
8965
|
children: [$1],
|
|
8929
8966
|
block: $1.block
|
|
8930
8967
|
};
|
|
@@ -9033,6 +9070,37 @@ ${input.slice(result.pos)}
|
|
|
9033
9070
|
return result;
|
|
9034
9071
|
}
|
|
9035
9072
|
}
|
|
9073
|
+
var DoStatement$0 = $TS($S(Do, NoPostfixBracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
9074
|
+
var block = $2;
|
|
9075
|
+
block = module.insertTrimmingSpace(block, "");
|
|
9076
|
+
return {
|
|
9077
|
+
type: "DoStatement",
|
|
9078
|
+
children: [block],
|
|
9079
|
+
block
|
|
9080
|
+
};
|
|
9081
|
+
});
|
|
9082
|
+
function DoStatement(state) {
|
|
9083
|
+
let eventData;
|
|
9084
|
+
if (state.events) {
|
|
9085
|
+
const result = state.events.enter?.("DoStatement", state);
|
|
9086
|
+
if (result) {
|
|
9087
|
+
if (result.cache)
|
|
9088
|
+
return result.cache;
|
|
9089
|
+
eventData = result.data;
|
|
9090
|
+
}
|
|
9091
|
+
}
|
|
9092
|
+
if (state.tokenize) {
|
|
9093
|
+
const result = $TOKEN("DoStatement", state, DoStatement$0(state));
|
|
9094
|
+
if (state.events)
|
|
9095
|
+
state.events.exit?.("DoStatement", state, result, eventData);
|
|
9096
|
+
return result;
|
|
9097
|
+
} else {
|
|
9098
|
+
const result = DoStatement$0(state);
|
|
9099
|
+
if (state.events)
|
|
9100
|
+
state.events.exit?.("DoStatement", state, result, eventData);
|
|
9101
|
+
return result;
|
|
9102
|
+
}
|
|
9103
|
+
}
|
|
9036
9104
|
var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9037
9105
|
var clause = $1;
|
|
9038
9106
|
var block = $2;
|
|
@@ -9974,13 +10042,31 @@ ${input.slice(result.pos)}
|
|
|
9974
10042
|
var c = $3;
|
|
9975
10043
|
var f = $4;
|
|
9976
10044
|
if (!c && !f) {
|
|
10045
|
+
const e = [];
|
|
10046
|
+
const emptyCatchBlock = {
|
|
10047
|
+
type: "BlockStatement",
|
|
10048
|
+
expressions: e,
|
|
10049
|
+
children: ["{", e, "}"],
|
|
10050
|
+
bare: false,
|
|
10051
|
+
empty: true
|
|
10052
|
+
};
|
|
10053
|
+
c = {
|
|
10054
|
+
type: "CatchClause",
|
|
10055
|
+
children: [" catch(e) ", emptyCatchBlock],
|
|
10056
|
+
block: emptyCatchBlock
|
|
10057
|
+
};
|
|
9977
10058
|
return {
|
|
9978
10059
|
type: "TryStatement",
|
|
9979
|
-
|
|
10060
|
+
blocks: [b, emptyCatchBlock],
|
|
10061
|
+
children: [t, b, c]
|
|
9980
10062
|
};
|
|
9981
10063
|
}
|
|
10064
|
+
const blocks = [b];
|
|
10065
|
+
if (c)
|
|
10066
|
+
blocks.push(c.block);
|
|
9982
10067
|
return {
|
|
9983
10068
|
type: "TryStatement",
|
|
10069
|
+
blocks,
|
|
9984
10070
|
children: [t, b, c, f]
|
|
9985
10071
|
};
|
|
9986
10072
|
});
|
|
@@ -10010,7 +10096,7 @@ ${input.slice(result.pos)}
|
|
|
10010
10096
|
var t = $0;
|
|
10011
10097
|
return {
|
|
10012
10098
|
type: "TryExpression",
|
|
10013
|
-
blocks:
|
|
10099
|
+
blocks: t.blocks,
|
|
10014
10100
|
children: ["(()=>{", t, "})()"]
|
|
10015
10101
|
};
|
|
10016
10102
|
});
|
|
@@ -10036,7 +10122,14 @@ ${input.slice(result.pos)}
|
|
|
10036
10122
|
return result;
|
|
10037
10123
|
}
|
|
10038
10124
|
}
|
|
10039
|
-
var CatchClause$0 = $S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock))
|
|
10125
|
+
var CatchClause$0 = $TS($S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
10126
|
+
var block = $4;
|
|
10127
|
+
return {
|
|
10128
|
+
type: "CatchClause",
|
|
10129
|
+
children: $0,
|
|
10130
|
+
block
|
|
10131
|
+
};
|
|
10132
|
+
});
|
|
10040
10133
|
function CatchClause(state) {
|
|
10041
10134
|
let eventData;
|
|
10042
10135
|
if (state.events) {
|
|
@@ -13218,7 +13311,7 @@ ${input.slice(result.pos)}
|
|
|
13218
13311
|
}
|
|
13219
13312
|
}
|
|
13220
13313
|
var StatementDelimiter$0 = SemicolonDelimiter;
|
|
13221
|
-
var StatementDelimiter$1 = $S($Y($S(Samedent, $C($EXPECT($L2, fail, 'StatementDelimiter "("'), $EXPECT($L97, fail, 'StatementDelimiter "["'), $EXPECT($L98, fail, 'StatementDelimiter "`"'), $EXPECT($L58, fail, 'StatementDelimiter "+"'), $EXPECT($L17, fail, 'StatementDelimiter "-"'), $EXPECT($L54, fail, 'StatementDelimiter "*"'), $EXPECT($L55, fail, 'StatementDelimiter "/"'), ObjectLiteral, Arrow, $S(Function, $E($S($E(_), Star)), $E(_), $EXPECT($L2, fail, 'StatementDelimiter "("'))))), InsertSemicolon);
|
|
13314
|
+
var StatementDelimiter$1 = $S($Y($S(Samedent, $C($EXPECT($L2, fail, 'StatementDelimiter "("'), $EXPECT($L97, fail, 'StatementDelimiter "["'), $EXPECT($L98, fail, 'StatementDelimiter "`"'), $EXPECT($L58, fail, 'StatementDelimiter "+"'), $EXPECT($L17, fail, 'StatementDelimiter "-"'), $EXPECT($L54, fail, 'StatementDelimiter "*"'), $EXPECT($L55, fail, 'StatementDelimiter "/"'), ObjectLiteral, Arrow, FatArrow, $S(Function, $E($S($E(_), Star)), $E(_), $EXPECT($L2, fail, 'StatementDelimiter "("'))))), InsertSemicolon);
|
|
13222
13315
|
var StatementDelimiter$2 = $Y(EOS);
|
|
13223
13316
|
function StatementDelimiter(state) {
|
|
13224
13317
|
let eventData;
|
|
@@ -17451,6 +17544,9 @@ ${input.slice(result.pos)}
|
|
|
17451
17544
|
var TypeSuffix$1 = $T($S(QuestionMark, $E(_)), function(value) {
|
|
17452
17545
|
return { "type": "TypeSuffix", "ts": true, "children": value };
|
|
17453
17546
|
});
|
|
17547
|
+
var TypeSuffix$2 = $T($S(NonNullAssertion, $E(_), $E($S(Colon, Type))), function(value) {
|
|
17548
|
+
return { "type": "TypeSuffix", "ts": true, "children": value };
|
|
17549
|
+
});
|
|
17454
17550
|
function TypeSuffix(state) {
|
|
17455
17551
|
let eventData;
|
|
17456
17552
|
if (state.events) {
|
|
@@ -17462,12 +17558,12 @@ ${input.slice(result.pos)}
|
|
|
17462
17558
|
}
|
|
17463
17559
|
}
|
|
17464
17560
|
if (state.tokenize) {
|
|
17465
|
-
const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state) || TypeSuffix$1(state));
|
|
17561
|
+
const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state));
|
|
17466
17562
|
if (state.events)
|
|
17467
17563
|
state.events.exit?.("TypeSuffix", state, result, eventData);
|
|
17468
17564
|
return result;
|
|
17469
17565
|
} else {
|
|
17470
|
-
const result = TypeSuffix$0(state) || TypeSuffix$1(state);
|
|
17566
|
+
const result = TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state);
|
|
17471
17567
|
if (state.events)
|
|
17472
17568
|
state.events.exit?.("TypeSuffix", state, result, eventData);
|
|
17473
17569
|
return result;
|
|
@@ -19872,15 +19968,29 @@ ${input.slice(result.pos)}
|
|
|
19872
19968
|
return post;
|
|
19873
19969
|
};
|
|
19874
19970
|
function expressionizeIteration(exp) {
|
|
19971
|
+
const i = exp.children.indexOf(exp.block);
|
|
19972
|
+
if (exp.subtype === "DoStatement") {
|
|
19973
|
+
insertReturn(exp.block);
|
|
19974
|
+
exp.children.splice(i, 1, "(()=>", ...exp.children, ")()");
|
|
19975
|
+
return;
|
|
19976
|
+
}
|
|
19875
19977
|
const resultsRef = {
|
|
19876
19978
|
type: "Ref",
|
|
19877
19979
|
base: "results",
|
|
19878
19980
|
id: "results"
|
|
19879
19981
|
};
|
|
19880
19982
|
insertPush(exp.block, resultsRef);
|
|
19881
|
-
exp.children
|
|
19983
|
+
exp.children.splice(i, 1, "(()=>{const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef, "})()");
|
|
19882
19984
|
}
|
|
19883
19985
|
function wrapIterationReturningResults(statement, outerRef) {
|
|
19986
|
+
if (statement.type === "DoStatement") {
|
|
19987
|
+
if (outerRef) {
|
|
19988
|
+
insertPush(statement.block, outerRef);
|
|
19989
|
+
} else {
|
|
19990
|
+
insertReturn(statement.block);
|
|
19991
|
+
}
|
|
19992
|
+
return;
|
|
19993
|
+
}
|
|
19884
19994
|
const resultsRef = {
|
|
19885
19995
|
type: "Ref",
|
|
19886
19996
|
base: "results",
|
|
@@ -19903,7 +20013,12 @@ ${input.slice(result.pos)}
|
|
|
19903
20013
|
return;
|
|
19904
20014
|
switch (node.type) {
|
|
19905
20015
|
case "BlockStatement":
|
|
19906
|
-
|
|
20016
|
+
if (node.expressions.length) {
|
|
20017
|
+
const last = node.expressions[node.expressions.length - 1];
|
|
20018
|
+
insertPush(last, ref);
|
|
20019
|
+
} else {
|
|
20020
|
+
node.expressions.push([ref, ".push(void 0);"]);
|
|
20021
|
+
}
|
|
19907
20022
|
return;
|
|
19908
20023
|
case "CaseBlock":
|
|
19909
20024
|
node.clauses.forEach((clause) => {
|
|
@@ -19936,6 +20051,7 @@ ${input.slice(result.pos)}
|
|
|
19936
20051
|
return;
|
|
19937
20052
|
case "ForStatement":
|
|
19938
20053
|
case "IterationStatement":
|
|
20054
|
+
case "DoStatement":
|
|
19939
20055
|
wrapIterationReturningResults(exp, ref);
|
|
19940
20056
|
return;
|
|
19941
20057
|
case "BlockStatement":
|
|
@@ -19955,9 +20071,7 @@ ${input.slice(result.pos)}
|
|
|
19955
20071
|
insertPush(exp.children[2], ref);
|
|
19956
20072
|
return;
|
|
19957
20073
|
case "TryStatement":
|
|
19958
|
-
insertPush(
|
|
19959
|
-
if (exp.children[2])
|
|
19960
|
-
insertPush(exp.children[2][2], ref);
|
|
20074
|
+
exp.blocks.forEach((block) => insertPush(block, ref));
|
|
19961
20075
|
return;
|
|
19962
20076
|
}
|
|
19963
20077
|
node.splice(1, 0, ref, ".push(");
|
|
@@ -19993,7 +20107,14 @@ ${input.slice(result.pos)}
|
|
|
19993
20107
|
return;
|
|
19994
20108
|
switch (node.type) {
|
|
19995
20109
|
case "BlockStatement":
|
|
19996
|
-
|
|
20110
|
+
if (node.expressions.length) {
|
|
20111
|
+
const last = node.expressions[node.expressions.length - 1];
|
|
20112
|
+
insertReturn(last);
|
|
20113
|
+
} else {
|
|
20114
|
+
if (node.parent.type === "CatchClause") {
|
|
20115
|
+
node.expressions.push(["return"]);
|
|
20116
|
+
}
|
|
20117
|
+
}
|
|
19997
20118
|
return;
|
|
19998
20119
|
case "WhenClause":
|
|
19999
20120
|
node.children.splice(node.children.indexOf(node.break), 1);
|
|
@@ -20026,6 +20147,7 @@ ${input.slice(result.pos)}
|
|
|
20026
20147
|
return;
|
|
20027
20148
|
case "ForStatement":
|
|
20028
20149
|
case "IterationStatement":
|
|
20150
|
+
case "DoStatement":
|
|
20029
20151
|
wrapIterationReturningResults(exp);
|
|
20030
20152
|
return;
|
|
20031
20153
|
case "BlockStatement":
|
|
@@ -20045,9 +20167,7 @@ ${input.slice(result.pos)}
|
|
|
20045
20167
|
insertSwitchReturns(exp);
|
|
20046
20168
|
return;
|
|
20047
20169
|
case "TryStatement":
|
|
20048
|
-
|
|
20049
|
-
if (exp.children[2])
|
|
20050
|
-
insertReturn(exp.children[2][3]);
|
|
20170
|
+
exp.blocks.forEach((block) => insertReturn(block));
|
|
20051
20171
|
return;
|
|
20052
20172
|
}
|
|
20053
20173
|
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
@@ -20223,10 +20343,12 @@ ${input.slice(result.pos)}
|
|
|
20223
20343
|
if (Array.isArray(target)) {
|
|
20224
20344
|
if (target.length === 1) {
|
|
20225
20345
|
return module.skipIfOnlyWS(target[0]);
|
|
20346
|
+
} else if (target.every((e) => module.skipIfOnlyWS(e) === void 0)) {
|
|
20347
|
+
return void 0;
|
|
20226
20348
|
}
|
|
20227
20349
|
return target;
|
|
20228
20350
|
}
|
|
20229
|
-
if (target.token && target.token.trim() === "") {
|
|
20351
|
+
if (target.token != null && target.token.trim() === "") {
|
|
20230
20352
|
return void 0;
|
|
20231
20353
|
}
|
|
20232
20354
|
return target;
|
|
@@ -20761,8 +20883,9 @@ ${input.slice(result.pos)}
|
|
|
20761
20883
|
module.attachPostfixStatementAsExpression = function(exp, post) {
|
|
20762
20884
|
let clause;
|
|
20763
20885
|
switch (post[1].type) {
|
|
20764
|
-
case "IterationStatement":
|
|
20765
20886
|
case "ForStatement":
|
|
20887
|
+
case "IterationStatement":
|
|
20888
|
+
case "DoStatement":
|
|
20766
20889
|
clause = module.addPostfixStatement(exp, ...post);
|
|
20767
20890
|
return {
|
|
20768
20891
|
type: "IterationExpression",
|
|
@@ -20967,6 +21090,37 @@ ${input.slice(result.pos)}
|
|
|
20967
21090
|
return pattern;
|
|
20968
21091
|
}
|
|
20969
21092
|
}
|
|
21093
|
+
function aggregateDuplicateBindings(bindings) {
|
|
21094
|
+
const props2 = gatherRecursiveAll(bindings, (n) => n.type === "BindingMatchProperty");
|
|
21095
|
+
const declarations = [];
|
|
21096
|
+
const propsGroupedByName = /* @__PURE__ */ new Map();
|
|
21097
|
+
for (const p of props2) {
|
|
21098
|
+
const { name } = p;
|
|
21099
|
+
const key = name.name;
|
|
21100
|
+
if (propsGroupedByName.has(key)) {
|
|
21101
|
+
propsGroupedByName.get(key).push(p);
|
|
21102
|
+
} else {
|
|
21103
|
+
propsGroupedByName.set(key, [p]);
|
|
21104
|
+
}
|
|
21105
|
+
}
|
|
21106
|
+
propsGroupedByName.forEach((shared, key) => {
|
|
21107
|
+
if (shared.length === 1)
|
|
21108
|
+
return;
|
|
21109
|
+
const refs = shared.map((p) => {
|
|
21110
|
+
const ref = {
|
|
21111
|
+
type: "Ref",
|
|
21112
|
+
base: key,
|
|
21113
|
+
id: key
|
|
21114
|
+
};
|
|
21115
|
+
p.children.push(": ", ref);
|
|
21116
|
+
return ref;
|
|
21117
|
+
});
|
|
21118
|
+
declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
|
|
21119
|
+
return i === 0 ? r : [", ", r];
|
|
21120
|
+
}), "]"]);
|
|
21121
|
+
});
|
|
21122
|
+
return declarations;
|
|
21123
|
+
}
|
|
20970
21124
|
function processPatternMatching(statements) {
|
|
20971
21125
|
gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement" || n.type === "SwitchExpression").forEach((s) => {
|
|
20972
21126
|
const { caseBlock } = s;
|
|
@@ -21033,10 +21187,13 @@ ${input.slice(result.pos)}
|
|
|
21033
21187
|
if (pattern.properties?.length === 0)
|
|
21034
21188
|
break;
|
|
21035
21189
|
let [splices, thisAssignments] = gatherBindingCode(pattern);
|
|
21190
|
+
const patternBindings = nonMatcherBindings(pattern);
|
|
21036
21191
|
splices = splices.map((s2) => [", ", nonMatcherBindings(s2)]);
|
|
21037
21192
|
thisAssignments = thisAssignments.map((a) => [indent, a, ";\n"]);
|
|
21038
|
-
|
|
21193
|
+
const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices]);
|
|
21194
|
+
prefix.push([indent, "const ", patternBindings, " = ", ref, splices, ";\n"]);
|
|
21039
21195
|
prefix.push(...thisAssignments);
|
|
21196
|
+
prefix.push(...duplicateDeclarations.map((d) => [indent, d, ";\n"]));
|
|
21040
21197
|
break;
|
|
21041
21198
|
}
|
|
21042
21199
|
}
|
|
@@ -21068,10 +21225,10 @@ ${input.slice(result.pos)}
|
|
|
21068
21225
|
}
|
|
21069
21226
|
function processPipelineExpressions(statements) {
|
|
21070
21227
|
gatherRecursiveAll(statements, (n) => n.type === "PipelineExpression").forEach((s) => {
|
|
21071
|
-
const [, body] = s.children;
|
|
21072
|
-
let [arg] = s.children;
|
|
21228
|
+
const [ws, , body] = s.children;
|
|
21229
|
+
let [, arg] = s.children;
|
|
21073
21230
|
let i = 0, l = body.length;
|
|
21074
|
-
const children = [];
|
|
21231
|
+
const children = [ws];
|
|
21075
21232
|
for (i = 0; i < l; i++) {
|
|
21076
21233
|
const step = body[i];
|
|
21077
21234
|
const [leadingComment, pipe, trailingComment, expr] = step;
|
|
@@ -21096,7 +21253,17 @@ ${input.slice(result.pos)}
|
|
|
21096
21253
|
returns ? arg : null
|
|
21097
21254
|
);
|
|
21098
21255
|
if (result.type === "ReturnStatement") {
|
|
21256
|
+
if (i < l - 1) {
|
|
21257
|
+
result.children.push({
|
|
21258
|
+
type: "Error",
|
|
21259
|
+
message: "Can't continue a pipeline after returning"
|
|
21260
|
+
});
|
|
21261
|
+
}
|
|
21099
21262
|
arg = result;
|
|
21263
|
+
if (children[children.length - 1] === ",") {
|
|
21264
|
+
children.pop();
|
|
21265
|
+
children.push(";");
|
|
21266
|
+
}
|
|
21100
21267
|
break;
|
|
21101
21268
|
}
|
|
21102
21269
|
if (returning) {
|
|
@@ -21527,6 +21694,36 @@ ${input.slice(result.pos)}
|
|
|
21527
21694
|
return result;
|
|
21528
21695
|
}
|
|
21529
21696
|
}
|
|
21697
|
+
var NotDedented$0 = $TS($S($E($C(Samedent, IndentedFurther)), $E(_)), function($skip, $loc, $0, $1, $2) {
|
|
21698
|
+
const ws = [];
|
|
21699
|
+
if ($1)
|
|
21700
|
+
ws.push(...$1);
|
|
21701
|
+
if ($2)
|
|
21702
|
+
ws.push(...$2);
|
|
21703
|
+
return ws.flat(Infinity).filter(Boolean);
|
|
21704
|
+
});
|
|
21705
|
+
function NotDedented(state) {
|
|
21706
|
+
let eventData;
|
|
21707
|
+
if (state.events) {
|
|
21708
|
+
const result = state.events.enter?.("NotDedented", state);
|
|
21709
|
+
if (result) {
|
|
21710
|
+
if (result.cache)
|
|
21711
|
+
return result.cache;
|
|
21712
|
+
eventData = result.data;
|
|
21713
|
+
}
|
|
21714
|
+
}
|
|
21715
|
+
if (state.tokenize) {
|
|
21716
|
+
const result = $TOKEN("NotDedented", state, NotDedented$0(state));
|
|
21717
|
+
if (state.events)
|
|
21718
|
+
state.events.exit?.("NotDedented", state, result, eventData);
|
|
21719
|
+
return result;
|
|
21720
|
+
} else {
|
|
21721
|
+
const result = NotDedented$0(state);
|
|
21722
|
+
if (state.events)
|
|
21723
|
+
state.events.exit?.("NotDedented", state, result, eventData);
|
|
21724
|
+
return result;
|
|
21725
|
+
}
|
|
21726
|
+
}
|
|
21530
21727
|
var PushIndent$0 = $Y($S(EOS, TrackIndented));
|
|
21531
21728
|
function PushIndent(state) {
|
|
21532
21729
|
let eventData;
|
|
@@ -22045,7 +22242,7 @@ var parse;
|
|
|
22045
22242
|
var uncacheable;
|
|
22046
22243
|
({ parse } = import_parser.default);
|
|
22047
22244
|
({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
|
|
22048
|
-
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "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", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
22245
|
+
uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidIndentedApplication", "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", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
|
|
22049
22246
|
var compile = function(src, options) {
|
|
22050
22247
|
var ast, code, events, filename, ref, result, sm, srcMapJSON;
|
|
22051
22248
|
if (!options) {
|