@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.js
CHANGED
|
@@ -641,6 +641,7 @@ ${input.slice(result.pos)}
|
|
|
641
641
|
StatementListItem,
|
|
642
642
|
PostfixedStatement,
|
|
643
643
|
PostfixedExpression,
|
|
644
|
+
NonPipelinePostfixedExpression,
|
|
644
645
|
PostfixStatement,
|
|
645
646
|
Statement,
|
|
646
647
|
EmptyStatement,
|
|
@@ -664,6 +665,7 @@ ${input.slice(result.pos)}
|
|
|
664
665
|
LoopStatement,
|
|
665
666
|
LoopClause,
|
|
666
667
|
DoWhileStatement,
|
|
668
|
+
DoStatement,
|
|
667
669
|
WhileStatement,
|
|
668
670
|
WhileClause,
|
|
669
671
|
ForStatement,
|
|
@@ -1037,6 +1039,7 @@ ${input.slice(result.pos)}
|
|
|
1037
1039
|
TrackIndented,
|
|
1038
1040
|
Samedent,
|
|
1039
1041
|
IndentedFurther,
|
|
1042
|
+
NotDedented,
|
|
1040
1043
|
PushIndent,
|
|
1041
1044
|
PopIndent,
|
|
1042
1045
|
Nested
|
|
@@ -1965,7 +1968,7 @@ ${input.slice(result.pos)}
|
|
|
1965
1968
|
var rhs = $2;
|
|
1966
1969
|
return [[], op, [], rhs];
|
|
1967
1970
|
});
|
|
1968
|
-
var BinaryOpRHS$1 = $S(
|
|
1971
|
+
var BinaryOpRHS$1 = $S(NotDedented, BinaryOp, $C(_, $S(EOS, __)), RHS);
|
|
1969
1972
|
function BinaryOpRHS(state) {
|
|
1970
1973
|
let eventData;
|
|
1971
1974
|
if (state.events) {
|
|
@@ -2447,7 +2450,7 @@ ${input.slice(result.pos)}
|
|
|
2447
2450
|
return result;
|
|
2448
2451
|
}
|
|
2449
2452
|
}
|
|
2450
|
-
var FatArrowBody$0 = $T($S($N(EOS),
|
|
2453
|
+
var FatArrowBody$0 = $T($S($N(EOS), NonPipelinePostfixedExpression, $N(SemicolonDelimiter)), function(value) {
|
|
2451
2454
|
var exp = value[1];
|
|
2452
2455
|
return exp;
|
|
2453
2456
|
});
|
|
@@ -2578,12 +2581,13 @@ ${input.slice(result.pos)}
|
|
|
2578
2581
|
return result;
|
|
2579
2582
|
}
|
|
2580
2583
|
}
|
|
2581
|
-
var PipelineExpression$0 = $TS($S(PipelineHeadItem, $P($S(
|
|
2582
|
-
var
|
|
2583
|
-
var
|
|
2584
|
+
var PipelineExpression$0 = $TS($S($E(_), PipelineHeadItem, $P($S(NotDedented, Pipe, __, PipelineTailItem))), function($skip, $loc, $0, $1, $2, $3) {
|
|
2585
|
+
var ws = $1;
|
|
2586
|
+
var head = $2;
|
|
2587
|
+
var body = $3;
|
|
2584
2588
|
return {
|
|
2585
2589
|
type: "PipelineExpression",
|
|
2586
|
-
children: [head, body]
|
|
2590
|
+
children: [ws, head, body]
|
|
2587
2591
|
};
|
|
2588
2592
|
});
|
|
2589
2593
|
function PipelineExpression(state) {
|
|
@@ -8364,6 +8368,35 @@ ${input.slice(result.pos)}
|
|
|
8364
8368
|
return result;
|
|
8365
8369
|
}
|
|
8366
8370
|
}
|
|
8371
|
+
var NonPipelinePostfixedExpression$0 = $TS($S(NonPipelineExtendedExpression, $E($S($Q(TrailingComment), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
|
|
8372
|
+
var expression = $1;
|
|
8373
|
+
var post = $2;
|
|
8374
|
+
if (post)
|
|
8375
|
+
return module2.attachPostfixStatementAsExpression(expression, post);
|
|
8376
|
+
return expression;
|
|
8377
|
+
});
|
|
8378
|
+
function NonPipelinePostfixedExpression(state) {
|
|
8379
|
+
let eventData;
|
|
8380
|
+
if (state.events) {
|
|
8381
|
+
const result = state.events.enter?.("NonPipelinePostfixedExpression", state);
|
|
8382
|
+
if (result) {
|
|
8383
|
+
if (result.cache)
|
|
8384
|
+
return result.cache;
|
|
8385
|
+
eventData = result.data;
|
|
8386
|
+
}
|
|
8387
|
+
}
|
|
8388
|
+
if (state.tokenize) {
|
|
8389
|
+
const result = $TOKEN("NonPipelinePostfixedExpression", state, NonPipelinePostfixedExpression$0(state));
|
|
8390
|
+
if (state.events)
|
|
8391
|
+
state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
|
|
8392
|
+
return result;
|
|
8393
|
+
} else {
|
|
8394
|
+
const result = NonPipelinePostfixedExpression$0(state);
|
|
8395
|
+
if (state.events)
|
|
8396
|
+
state.events.exit?.("NonPipelinePostfixedExpression", state, result, eventData);
|
|
8397
|
+
return result;
|
|
8398
|
+
}
|
|
8399
|
+
}
|
|
8367
8400
|
var PostfixStatement$0 = ForClause;
|
|
8368
8401
|
var PostfixStatement$1 = IfClause;
|
|
8369
8402
|
var PostfixStatement$2 = LoopClause;
|
|
@@ -8900,8 +8933,11 @@ ${input.slice(result.pos)}
|
|
|
8900
8933
|
var IterationStatement$1 = $T($S($N(CoffeeDoEnabled), DoWhileStatement), function(value) {
|
|
8901
8934
|
return value[1];
|
|
8902
8935
|
});
|
|
8903
|
-
var IterationStatement$2 =
|
|
8904
|
-
|
|
8936
|
+
var IterationStatement$2 = $T($S($N(CoffeeDoEnabled), DoStatement), function(value) {
|
|
8937
|
+
return value[1];
|
|
8938
|
+
});
|
|
8939
|
+
var IterationStatement$3 = WhileStatement;
|
|
8940
|
+
var IterationStatement$4 = ForStatement;
|
|
8905
8941
|
function IterationStatement(state) {
|
|
8906
8942
|
let eventData;
|
|
8907
8943
|
if (state.events) {
|
|
@@ -8913,12 +8949,12 @@ ${input.slice(result.pos)}
|
|
|
8913
8949
|
}
|
|
8914
8950
|
}
|
|
8915
8951
|
if (state.tokenize) {
|
|
8916
|
-
const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state));
|
|
8952
|
+
const result = $TOKEN("IterationStatement", state, IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state));
|
|
8917
8953
|
if (state.events)
|
|
8918
8954
|
state.events.exit?.("IterationStatement", state, result, eventData);
|
|
8919
8955
|
return result;
|
|
8920
8956
|
} else {
|
|
8921
|
-
const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state);
|
|
8957
|
+
const result = IterationStatement$0(state) || IterationStatement$1(state) || IterationStatement$2(state) || IterationStatement$3(state) || IterationStatement$4(state);
|
|
8922
8958
|
if (state.events)
|
|
8923
8959
|
state.events.exit?.("IterationStatement", state, result, eventData);
|
|
8924
8960
|
return result;
|
|
@@ -8927,6 +8963,7 @@ ${input.slice(result.pos)}
|
|
|
8927
8963
|
var IterationExpression$0 = $TS($S(IterationStatement), function($skip, $loc, $0, $1) {
|
|
8928
8964
|
return {
|
|
8929
8965
|
type: "IterationExpression",
|
|
8966
|
+
subtype: $1.type,
|
|
8930
8967
|
children: [$1],
|
|
8931
8968
|
block: $1.block
|
|
8932
8969
|
};
|
|
@@ -9035,6 +9072,37 @@ ${input.slice(result.pos)}
|
|
|
9035
9072
|
return result;
|
|
9036
9073
|
}
|
|
9037
9074
|
}
|
|
9075
|
+
var DoStatement$0 = $TS($S(Do, NoPostfixBracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
9076
|
+
var block = $2;
|
|
9077
|
+
block = module2.insertTrimmingSpace(block, "");
|
|
9078
|
+
return {
|
|
9079
|
+
type: "DoStatement",
|
|
9080
|
+
children: [block],
|
|
9081
|
+
block
|
|
9082
|
+
};
|
|
9083
|
+
});
|
|
9084
|
+
function DoStatement(state) {
|
|
9085
|
+
let eventData;
|
|
9086
|
+
if (state.events) {
|
|
9087
|
+
const result = state.events.enter?.("DoStatement", state);
|
|
9088
|
+
if (result) {
|
|
9089
|
+
if (result.cache)
|
|
9090
|
+
return result.cache;
|
|
9091
|
+
eventData = result.data;
|
|
9092
|
+
}
|
|
9093
|
+
}
|
|
9094
|
+
if (state.tokenize) {
|
|
9095
|
+
const result = $TOKEN("DoStatement", state, DoStatement$0(state));
|
|
9096
|
+
if (state.events)
|
|
9097
|
+
state.events.exit?.("DoStatement", state, result, eventData);
|
|
9098
|
+
return result;
|
|
9099
|
+
} else {
|
|
9100
|
+
const result = DoStatement$0(state);
|
|
9101
|
+
if (state.events)
|
|
9102
|
+
state.events.exit?.("DoStatement", state, result, eventData);
|
|
9103
|
+
return result;
|
|
9104
|
+
}
|
|
9105
|
+
}
|
|
9038
9106
|
var WhileStatement$0 = $TS($S(WhileClause, Block), function($skip, $loc, $0, $1, $2) {
|
|
9039
9107
|
var clause = $1;
|
|
9040
9108
|
var block = $2;
|
|
@@ -9976,13 +10044,31 @@ ${input.slice(result.pos)}
|
|
|
9976
10044
|
var c = $3;
|
|
9977
10045
|
var f = $4;
|
|
9978
10046
|
if (!c && !f) {
|
|
10047
|
+
const e = [];
|
|
10048
|
+
const emptyCatchBlock = {
|
|
10049
|
+
type: "BlockStatement",
|
|
10050
|
+
expressions: e,
|
|
10051
|
+
children: ["{", e, "}"],
|
|
10052
|
+
bare: false,
|
|
10053
|
+
empty: true
|
|
10054
|
+
};
|
|
10055
|
+
c = {
|
|
10056
|
+
type: "CatchClause",
|
|
10057
|
+
children: [" catch(e) ", emptyCatchBlock],
|
|
10058
|
+
block: emptyCatchBlock
|
|
10059
|
+
};
|
|
9979
10060
|
return {
|
|
9980
10061
|
type: "TryStatement",
|
|
9981
|
-
|
|
10062
|
+
blocks: [b, emptyCatchBlock],
|
|
10063
|
+
children: [t, b, c]
|
|
9982
10064
|
};
|
|
9983
10065
|
}
|
|
10066
|
+
const blocks = [b];
|
|
10067
|
+
if (c)
|
|
10068
|
+
blocks.push(c.block);
|
|
9984
10069
|
return {
|
|
9985
10070
|
type: "TryStatement",
|
|
10071
|
+
blocks,
|
|
9986
10072
|
children: [t, b, c, f]
|
|
9987
10073
|
};
|
|
9988
10074
|
});
|
|
@@ -10012,7 +10098,7 @@ ${input.slice(result.pos)}
|
|
|
10012
10098
|
var t = $0;
|
|
10013
10099
|
return {
|
|
10014
10100
|
type: "TryExpression",
|
|
10015
|
-
blocks:
|
|
10101
|
+
blocks: t.blocks,
|
|
10016
10102
|
children: ["(()=>{", t, "})()"]
|
|
10017
10103
|
};
|
|
10018
10104
|
});
|
|
@@ -10038,7 +10124,14 @@ ${input.slice(result.pos)}
|
|
|
10038
10124
|
return result;
|
|
10039
10125
|
}
|
|
10040
10126
|
}
|
|
10041
|
-
var CatchClause$0 = $S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock))
|
|
10127
|
+
var CatchClause$0 = $TS($S($C(Samedent, _), Catch, $E(CatchBind), $C(ThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
10128
|
+
var block = $4;
|
|
10129
|
+
return {
|
|
10130
|
+
type: "CatchClause",
|
|
10131
|
+
children: $0,
|
|
10132
|
+
block
|
|
10133
|
+
};
|
|
10134
|
+
});
|
|
10042
10135
|
function CatchClause(state) {
|
|
10043
10136
|
let eventData;
|
|
10044
10137
|
if (state.events) {
|
|
@@ -13220,7 +13313,7 @@ ${input.slice(result.pos)}
|
|
|
13220
13313
|
}
|
|
13221
13314
|
}
|
|
13222
13315
|
var StatementDelimiter$0 = SemicolonDelimiter;
|
|
13223
|
-
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);
|
|
13316
|
+
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);
|
|
13224
13317
|
var StatementDelimiter$2 = $Y(EOS);
|
|
13225
13318
|
function StatementDelimiter(state) {
|
|
13226
13319
|
let eventData;
|
|
@@ -17453,6 +17546,9 @@ ${input.slice(result.pos)}
|
|
|
17453
17546
|
var TypeSuffix$1 = $T($S(QuestionMark, $E(_)), function(value) {
|
|
17454
17547
|
return { "type": "TypeSuffix", "ts": true, "children": value };
|
|
17455
17548
|
});
|
|
17549
|
+
var TypeSuffix$2 = $T($S(NonNullAssertion, $E(_), $E($S(Colon, Type))), function(value) {
|
|
17550
|
+
return { "type": "TypeSuffix", "ts": true, "children": value };
|
|
17551
|
+
});
|
|
17456
17552
|
function TypeSuffix(state) {
|
|
17457
17553
|
let eventData;
|
|
17458
17554
|
if (state.events) {
|
|
@@ -17464,12 +17560,12 @@ ${input.slice(result.pos)}
|
|
|
17464
17560
|
}
|
|
17465
17561
|
}
|
|
17466
17562
|
if (state.tokenize) {
|
|
17467
|
-
const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state) || TypeSuffix$1(state));
|
|
17563
|
+
const result = $TOKEN("TypeSuffix", state, TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state));
|
|
17468
17564
|
if (state.events)
|
|
17469
17565
|
state.events.exit?.("TypeSuffix", state, result, eventData);
|
|
17470
17566
|
return result;
|
|
17471
17567
|
} else {
|
|
17472
|
-
const result = TypeSuffix$0(state) || TypeSuffix$1(state);
|
|
17568
|
+
const result = TypeSuffix$0(state) || TypeSuffix$1(state) || TypeSuffix$2(state);
|
|
17473
17569
|
if (state.events)
|
|
17474
17570
|
state.events.exit?.("TypeSuffix", state, result, eventData);
|
|
17475
17571
|
return result;
|
|
@@ -19874,15 +19970,29 @@ ${input.slice(result.pos)}
|
|
|
19874
19970
|
return post;
|
|
19875
19971
|
};
|
|
19876
19972
|
function expressionizeIteration(exp) {
|
|
19973
|
+
const i = exp.children.indexOf(exp.block);
|
|
19974
|
+
if (exp.subtype === "DoStatement") {
|
|
19975
|
+
insertReturn(exp.block);
|
|
19976
|
+
exp.children.splice(i, 1, "(()=>", ...exp.children, ")()");
|
|
19977
|
+
return;
|
|
19978
|
+
}
|
|
19877
19979
|
const resultsRef = {
|
|
19878
19980
|
type: "Ref",
|
|
19879
19981
|
base: "results",
|
|
19880
19982
|
id: "results"
|
|
19881
19983
|
};
|
|
19882
19984
|
insertPush(exp.block, resultsRef);
|
|
19883
|
-
exp.children
|
|
19985
|
+
exp.children.splice(i, 1, "(()=>{const ", resultsRef, "=[];", ...exp.children, "; return ", resultsRef, "})()");
|
|
19884
19986
|
}
|
|
19885
19987
|
function wrapIterationReturningResults(statement, outerRef) {
|
|
19988
|
+
if (statement.type === "DoStatement") {
|
|
19989
|
+
if (outerRef) {
|
|
19990
|
+
insertPush(statement.block, outerRef);
|
|
19991
|
+
} else {
|
|
19992
|
+
insertReturn(statement.block);
|
|
19993
|
+
}
|
|
19994
|
+
return;
|
|
19995
|
+
}
|
|
19886
19996
|
const resultsRef = {
|
|
19887
19997
|
type: "Ref",
|
|
19888
19998
|
base: "results",
|
|
@@ -19905,7 +20015,12 @@ ${input.slice(result.pos)}
|
|
|
19905
20015
|
return;
|
|
19906
20016
|
switch (node.type) {
|
|
19907
20017
|
case "BlockStatement":
|
|
19908
|
-
|
|
20018
|
+
if (node.expressions.length) {
|
|
20019
|
+
const last = node.expressions[node.expressions.length - 1];
|
|
20020
|
+
insertPush(last, ref);
|
|
20021
|
+
} else {
|
|
20022
|
+
node.expressions.push([ref, ".push(void 0);"]);
|
|
20023
|
+
}
|
|
19909
20024
|
return;
|
|
19910
20025
|
case "CaseBlock":
|
|
19911
20026
|
node.clauses.forEach((clause) => {
|
|
@@ -19938,6 +20053,7 @@ ${input.slice(result.pos)}
|
|
|
19938
20053
|
return;
|
|
19939
20054
|
case "ForStatement":
|
|
19940
20055
|
case "IterationStatement":
|
|
20056
|
+
case "DoStatement":
|
|
19941
20057
|
wrapIterationReturningResults(exp, ref);
|
|
19942
20058
|
return;
|
|
19943
20059
|
case "BlockStatement":
|
|
@@ -19957,9 +20073,7 @@ ${input.slice(result.pos)}
|
|
|
19957
20073
|
insertPush(exp.children[2], ref);
|
|
19958
20074
|
return;
|
|
19959
20075
|
case "TryStatement":
|
|
19960
|
-
insertPush(
|
|
19961
|
-
if (exp.children[2])
|
|
19962
|
-
insertPush(exp.children[2][2], ref);
|
|
20076
|
+
exp.blocks.forEach((block) => insertPush(block, ref));
|
|
19963
20077
|
return;
|
|
19964
20078
|
}
|
|
19965
20079
|
node.splice(1, 0, ref, ".push(");
|
|
@@ -19995,7 +20109,14 @@ ${input.slice(result.pos)}
|
|
|
19995
20109
|
return;
|
|
19996
20110
|
switch (node.type) {
|
|
19997
20111
|
case "BlockStatement":
|
|
19998
|
-
|
|
20112
|
+
if (node.expressions.length) {
|
|
20113
|
+
const last = node.expressions[node.expressions.length - 1];
|
|
20114
|
+
insertReturn(last);
|
|
20115
|
+
} else {
|
|
20116
|
+
if (node.parent.type === "CatchClause") {
|
|
20117
|
+
node.expressions.push(["return"]);
|
|
20118
|
+
}
|
|
20119
|
+
}
|
|
19999
20120
|
return;
|
|
20000
20121
|
case "WhenClause":
|
|
20001
20122
|
node.children.splice(node.children.indexOf(node.break), 1);
|
|
@@ -20028,6 +20149,7 @@ ${input.slice(result.pos)}
|
|
|
20028
20149
|
return;
|
|
20029
20150
|
case "ForStatement":
|
|
20030
20151
|
case "IterationStatement":
|
|
20152
|
+
case "DoStatement":
|
|
20031
20153
|
wrapIterationReturningResults(exp);
|
|
20032
20154
|
return;
|
|
20033
20155
|
case "BlockStatement":
|
|
@@ -20047,9 +20169,7 @@ ${input.slice(result.pos)}
|
|
|
20047
20169
|
insertSwitchReturns(exp);
|
|
20048
20170
|
return;
|
|
20049
20171
|
case "TryStatement":
|
|
20050
|
-
|
|
20051
|
-
if (exp.children[2])
|
|
20052
|
-
insertReturn(exp.children[2][3]);
|
|
20172
|
+
exp.blocks.forEach((block) => insertReturn(block));
|
|
20053
20173
|
return;
|
|
20054
20174
|
}
|
|
20055
20175
|
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
@@ -20225,10 +20345,12 @@ ${input.slice(result.pos)}
|
|
|
20225
20345
|
if (Array.isArray(target)) {
|
|
20226
20346
|
if (target.length === 1) {
|
|
20227
20347
|
return module2.skipIfOnlyWS(target[0]);
|
|
20348
|
+
} else if (target.every((e) => module2.skipIfOnlyWS(e) === void 0)) {
|
|
20349
|
+
return void 0;
|
|
20228
20350
|
}
|
|
20229
20351
|
return target;
|
|
20230
20352
|
}
|
|
20231
|
-
if (target.token && target.token.trim() === "") {
|
|
20353
|
+
if (target.token != null && target.token.trim() === "") {
|
|
20232
20354
|
return void 0;
|
|
20233
20355
|
}
|
|
20234
20356
|
return target;
|
|
@@ -20763,8 +20885,9 @@ ${input.slice(result.pos)}
|
|
|
20763
20885
|
module2.attachPostfixStatementAsExpression = function(exp, post) {
|
|
20764
20886
|
let clause;
|
|
20765
20887
|
switch (post[1].type) {
|
|
20766
|
-
case "IterationStatement":
|
|
20767
20888
|
case "ForStatement":
|
|
20889
|
+
case "IterationStatement":
|
|
20890
|
+
case "DoStatement":
|
|
20768
20891
|
clause = module2.addPostfixStatement(exp, ...post);
|
|
20769
20892
|
return {
|
|
20770
20893
|
type: "IterationExpression",
|
|
@@ -20969,6 +21092,37 @@ ${input.slice(result.pos)}
|
|
|
20969
21092
|
return pattern;
|
|
20970
21093
|
}
|
|
20971
21094
|
}
|
|
21095
|
+
function aggregateDuplicateBindings(bindings) {
|
|
21096
|
+
const props2 = gatherRecursiveAll(bindings, (n) => n.type === "BindingMatchProperty");
|
|
21097
|
+
const declarations = [];
|
|
21098
|
+
const propsGroupedByName = /* @__PURE__ */ new Map();
|
|
21099
|
+
for (const p of props2) {
|
|
21100
|
+
const { name } = p;
|
|
21101
|
+
const key = name.name;
|
|
21102
|
+
if (propsGroupedByName.has(key)) {
|
|
21103
|
+
propsGroupedByName.get(key).push(p);
|
|
21104
|
+
} else {
|
|
21105
|
+
propsGroupedByName.set(key, [p]);
|
|
21106
|
+
}
|
|
21107
|
+
}
|
|
21108
|
+
propsGroupedByName.forEach((shared, key) => {
|
|
21109
|
+
if (shared.length === 1)
|
|
21110
|
+
return;
|
|
21111
|
+
const refs = shared.map((p) => {
|
|
21112
|
+
const ref = {
|
|
21113
|
+
type: "Ref",
|
|
21114
|
+
base: key,
|
|
21115
|
+
id: key
|
|
21116
|
+
};
|
|
21117
|
+
p.children.push(": ", ref);
|
|
21118
|
+
return ref;
|
|
21119
|
+
});
|
|
21120
|
+
declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
|
|
21121
|
+
return i === 0 ? r : [", ", r];
|
|
21122
|
+
}), "]"]);
|
|
21123
|
+
});
|
|
21124
|
+
return declarations;
|
|
21125
|
+
}
|
|
20972
21126
|
function processPatternMatching(statements) {
|
|
20973
21127
|
gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement" || n.type === "SwitchExpression").forEach((s) => {
|
|
20974
21128
|
const { caseBlock } = s;
|
|
@@ -21035,10 +21189,13 @@ ${input.slice(result.pos)}
|
|
|
21035
21189
|
if (pattern.properties?.length === 0)
|
|
21036
21190
|
break;
|
|
21037
21191
|
let [splices, thisAssignments] = gatherBindingCode(pattern);
|
|
21192
|
+
const patternBindings = nonMatcherBindings(pattern);
|
|
21038
21193
|
splices = splices.map((s2) => [", ", nonMatcherBindings(s2)]);
|
|
21039
21194
|
thisAssignments = thisAssignments.map((a) => [indent, a, ";\n"]);
|
|
21040
|
-
|
|
21195
|
+
const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices]);
|
|
21196
|
+
prefix.push([indent, "const ", patternBindings, " = ", ref, splices, ";\n"]);
|
|
21041
21197
|
prefix.push(...thisAssignments);
|
|
21198
|
+
prefix.push(...duplicateDeclarations.map((d) => [indent, d, ";\n"]));
|
|
21042
21199
|
break;
|
|
21043
21200
|
}
|
|
21044
21201
|
}
|
|
@@ -21070,10 +21227,10 @@ ${input.slice(result.pos)}
|
|
|
21070
21227
|
}
|
|
21071
21228
|
function processPipelineExpressions(statements) {
|
|
21072
21229
|
gatherRecursiveAll(statements, (n) => n.type === "PipelineExpression").forEach((s) => {
|
|
21073
|
-
const [, body] = s.children;
|
|
21074
|
-
let [arg] = s.children;
|
|
21230
|
+
const [ws, , body] = s.children;
|
|
21231
|
+
let [, arg] = s.children;
|
|
21075
21232
|
let i = 0, l = body.length;
|
|
21076
|
-
const children = [];
|
|
21233
|
+
const children = [ws];
|
|
21077
21234
|
for (i = 0; i < l; i++) {
|
|
21078
21235
|
const step = body[i];
|
|
21079
21236
|
const [leadingComment, pipe, trailingComment, expr] = step;
|
|
@@ -21098,7 +21255,17 @@ ${input.slice(result.pos)}
|
|
|
21098
21255
|
returns ? arg : null
|
|
21099
21256
|
);
|
|
21100
21257
|
if (result.type === "ReturnStatement") {
|
|
21258
|
+
if (i < l - 1) {
|
|
21259
|
+
result.children.push({
|
|
21260
|
+
type: "Error",
|
|
21261
|
+
message: "Can't continue a pipeline after returning"
|
|
21262
|
+
});
|
|
21263
|
+
}
|
|
21101
21264
|
arg = result;
|
|
21265
|
+
if (children[children.length - 1] === ",") {
|
|
21266
|
+
children.pop();
|
|
21267
|
+
children.push(";");
|
|
21268
|
+
}
|
|
21102
21269
|
break;
|
|
21103
21270
|
}
|
|
21104
21271
|
if (returning) {
|
|
@@ -21529,6 +21696,36 @@ ${input.slice(result.pos)}
|
|
|
21529
21696
|
return result;
|
|
21530
21697
|
}
|
|
21531
21698
|
}
|
|
21699
|
+
var NotDedented$0 = $TS($S($E($C(Samedent, IndentedFurther)), $E(_)), function($skip, $loc, $0, $1, $2) {
|
|
21700
|
+
const ws = [];
|
|
21701
|
+
if ($1)
|
|
21702
|
+
ws.push(...$1);
|
|
21703
|
+
if ($2)
|
|
21704
|
+
ws.push(...$2);
|
|
21705
|
+
return ws.flat(Infinity).filter(Boolean);
|
|
21706
|
+
});
|
|
21707
|
+
function NotDedented(state) {
|
|
21708
|
+
let eventData;
|
|
21709
|
+
if (state.events) {
|
|
21710
|
+
const result = state.events.enter?.("NotDedented", state);
|
|
21711
|
+
if (result) {
|
|
21712
|
+
if (result.cache)
|
|
21713
|
+
return result.cache;
|
|
21714
|
+
eventData = result.data;
|
|
21715
|
+
}
|
|
21716
|
+
}
|
|
21717
|
+
if (state.tokenize) {
|
|
21718
|
+
const result = $TOKEN("NotDedented", state, NotDedented$0(state));
|
|
21719
|
+
if (state.events)
|
|
21720
|
+
state.events.exit?.("NotDedented", state, result, eventData);
|
|
21721
|
+
return result;
|
|
21722
|
+
} else {
|
|
21723
|
+
const result = NotDedented$0(state);
|
|
21724
|
+
if (state.events)
|
|
21725
|
+
state.events.exit?.("NotDedented", state, result, eventData);
|
|
21726
|
+
return result;
|
|
21727
|
+
}
|
|
21728
|
+
}
|
|
21532
21729
|
var PushIndent$0 = $Y($S(EOS, TrackIndented));
|
|
21533
21730
|
function PushIndent(state) {
|
|
21534
21731
|
let eventData;
|
|
@@ -22057,7 +22254,7 @@ var parse;
|
|
|
22057
22254
|
var uncacheable;
|
|
22058
22255
|
({ parse } = import_parser.default);
|
|
22059
22256
|
({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
|
|
22060
|
-
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"]);
|
|
22257
|
+
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"]);
|
|
22061
22258
|
var compile = function(src, options) {
|
|
22062
22259
|
var ast, code, events, filename, ref, result, sm, srcMapJSON;
|
|
22063
22260
|
if (!options) {
|