@danielx/civet 0.5.81 → 0.5.82
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 +159 -77
- package/dist/main.js +159 -77
- package/dist/main.mjs +159 -77
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -116,12 +116,29 @@ var Civet = (() => {
|
|
|
116
116
|
}
|
|
117
117
|
return nodes;
|
|
118
118
|
}
|
|
119
|
+
function hasAwait(exp) {
|
|
120
|
+
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
|
|
121
|
+
}
|
|
122
|
+
function hasYield(exp) {
|
|
123
|
+
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
|
|
124
|
+
}
|
|
125
|
+
function isFunction(node) {
|
|
126
|
+
const { type } = node;
|
|
127
|
+
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
128
|
+
}
|
|
129
|
+
function gatherRecursiveWithinFunction(node, predicate) {
|
|
130
|
+
return gatherRecursive(node, predicate, isFunction);
|
|
131
|
+
}
|
|
119
132
|
module.exports = {
|
|
120
133
|
clone,
|
|
121
134
|
deepCopy,
|
|
122
135
|
gatherNodes,
|
|
123
136
|
gatherRecursive,
|
|
124
137
|
gatherRecursiveAll,
|
|
138
|
+
gatherRecursiveWithinFunction,
|
|
139
|
+
hasAwait,
|
|
140
|
+
hasYield,
|
|
141
|
+
isFunction,
|
|
125
142
|
removeParentPointers
|
|
126
143
|
};
|
|
127
144
|
}
|
|
@@ -569,7 +586,6 @@ ${input.slice(result.pos)}
|
|
|
569
586
|
YieldExpression,
|
|
570
587
|
YieldTail,
|
|
571
588
|
ArrowFunction,
|
|
572
|
-
ArrowFunctionTail,
|
|
573
589
|
FatArrow,
|
|
574
590
|
FatArrowBody,
|
|
575
591
|
ConditionalExpression,
|
|
@@ -2589,53 +2605,36 @@ ${input.slice(result.pos)}
|
|
|
2589
2605
|
return result;
|
|
2590
2606
|
}
|
|
2591
2607
|
}
|
|
2592
|
-
var ArrowFunction$0 =
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
let eventData;
|
|
2601
|
-
if (state.events) {
|
|
2602
|
-
const result = state.events.enter?.("ArrowFunction", state);
|
|
2603
|
-
if (result) {
|
|
2604
|
-
if (result.cache)
|
|
2605
|
-
return result.cache;
|
|
2606
|
-
eventData = result.data;
|
|
2607
|
-
}
|
|
2608
|
+
var ArrowFunction$0 = ThinArrowFunction;
|
|
2609
|
+
var ArrowFunction$1 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
2610
|
+
var async = $1;
|
|
2611
|
+
var parameters = $2;
|
|
2612
|
+
var suffix = $3;
|
|
2613
|
+
var expOrBlock = $5;
|
|
2614
|
+
if (hasAwait(expOrBlock) && !async) {
|
|
2615
|
+
async = "async ";
|
|
2608
2616
|
}
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
const result = ArrowFunction$0(state);
|
|
2616
|
-
if (state.events)
|
|
2617
|
-
state.events.exit?.("ArrowFunction", state, result, eventData);
|
|
2618
|
-
return result;
|
|
2617
|
+
let error;
|
|
2618
|
+
if (hasYield(expOrBlock)) {
|
|
2619
|
+
error = {
|
|
2620
|
+
type: "Error",
|
|
2621
|
+
message: "Can't use yield inside of => arrow function"
|
|
2622
|
+
};
|
|
2619
2623
|
}
|
|
2620
|
-
}
|
|
2621
|
-
var ArrowFunctionTail$0 = ThinArrowFunction;
|
|
2622
|
-
var ArrowFunctionTail$1 = $TS($S(Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
2623
|
-
var parameters = $1;
|
|
2624
|
-
var suffix = $2;
|
|
2625
|
-
var expOrBlock = $4;
|
|
2626
2624
|
return {
|
|
2627
2625
|
type: "ArrowFunction",
|
|
2628
2626
|
parameters,
|
|
2629
2627
|
returnType: suffix,
|
|
2630
2628
|
ts: false,
|
|
2629
|
+
async,
|
|
2631
2630
|
block: expOrBlock,
|
|
2632
|
-
children: $0
|
|
2631
|
+
children: [async, $0.slice(1), error]
|
|
2633
2632
|
};
|
|
2634
2633
|
});
|
|
2635
|
-
function
|
|
2634
|
+
function ArrowFunction(state) {
|
|
2636
2635
|
let eventData;
|
|
2637
2636
|
if (state.events) {
|
|
2638
|
-
const result = state.events.enter?.("
|
|
2637
|
+
const result = state.events.enter?.("ArrowFunction", state);
|
|
2639
2638
|
if (result) {
|
|
2640
2639
|
if (result.cache)
|
|
2641
2640
|
return result.cache;
|
|
@@ -2643,14 +2642,14 @@ ${input.slice(result.pos)}
|
|
|
2643
2642
|
}
|
|
2644
2643
|
}
|
|
2645
2644
|
if (state.tokenize) {
|
|
2646
|
-
const result = $TOKEN("
|
|
2645
|
+
const result = $TOKEN("ArrowFunction", state, ArrowFunction$0(state) || ArrowFunction$1(state));
|
|
2647
2646
|
if (state.events)
|
|
2648
|
-
state.events.exit?.("
|
|
2647
|
+
state.events.exit?.("ArrowFunction", state, result, eventData);
|
|
2649
2648
|
return result;
|
|
2650
2649
|
} else {
|
|
2651
|
-
const result =
|
|
2650
|
+
const result = ArrowFunction$0(state) || ArrowFunction$1(state);
|
|
2652
2651
|
if (state.events)
|
|
2653
|
-
state.events.exit?.("
|
|
2652
|
+
state.events.exit?.("ArrowFunction", state, result, eventData);
|
|
2654
2653
|
return result;
|
|
2655
2654
|
}
|
|
2656
2655
|
}
|
|
@@ -3561,9 +3560,16 @@ ${input.slice(result.pos)}
|
|
|
3561
3560
|
var exp = $6;
|
|
3562
3561
|
switch (exp.type) {
|
|
3563
3562
|
case "FunctionExpression":
|
|
3563
|
+
const fnTokenIndex = exp.children.findIndex((c) => c?.token?.startsWith("function"));
|
|
3564
|
+
const children = exp.children.slice();
|
|
3565
|
+
if (exp.generator) {
|
|
3566
|
+
children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
|
|
3567
|
+
} else {
|
|
3568
|
+
children.splice(fnTokenIndex, 1, id);
|
|
3569
|
+
}
|
|
3564
3570
|
return {
|
|
3565
3571
|
...exp,
|
|
3566
|
-
children
|
|
3572
|
+
children
|
|
3567
3573
|
};
|
|
3568
3574
|
default:
|
|
3569
3575
|
return [id, " = ", exp];
|
|
@@ -5664,22 +5670,28 @@ ${input.slice(result.pos)}
|
|
|
5664
5670
|
return result;
|
|
5665
5671
|
}
|
|
5666
5672
|
}
|
|
5667
|
-
var FunctionSignature$0 = $TS($S($E($S(Async,
|
|
5673
|
+
var FunctionSignature$0 = $TS($S($E($S(Async, _)), Function, $E($S($E(_), Star)), $E($S($E(_), NWBindingIdentifier)), $E(_), Parameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
5668
5674
|
var async = $1;
|
|
5669
5675
|
var func = $2;
|
|
5670
|
-
var
|
|
5676
|
+
var generator = $3;
|
|
5671
5677
|
var wid = $4;
|
|
5672
5678
|
var w = $5;
|
|
5673
5679
|
var parameters = $6;
|
|
5674
5680
|
var suffix = $7;
|
|
5681
|
+
if (!async)
|
|
5682
|
+
async = [];
|
|
5683
|
+
if (!generator)
|
|
5684
|
+
generator = [];
|
|
5675
5685
|
return {
|
|
5676
5686
|
type: "FunctionSignature",
|
|
5677
5687
|
id: wid?.[1],
|
|
5678
5688
|
parameters,
|
|
5679
5689
|
returnType: suffix,
|
|
5680
5690
|
ts: false,
|
|
5691
|
+
async,
|
|
5692
|
+
generator,
|
|
5681
5693
|
block: null,
|
|
5682
|
-
children: !parameters.implicit ? $0 : [async, func,
|
|
5694
|
+
children: !parameters.implicit ? $0 : [async, func, generator, wid, parameters, w, suffix]
|
|
5683
5695
|
};
|
|
5684
5696
|
});
|
|
5685
5697
|
function FunctionSignature(state) {
|
|
@@ -5711,6 +5723,12 @@ ${input.slice(result.pos)}
|
|
|
5711
5723
|
signature.ts = true;
|
|
5712
5724
|
return signature;
|
|
5713
5725
|
}
|
|
5726
|
+
if (hasAwait(block) && !signature.async.length) {
|
|
5727
|
+
signature.async.push("async ");
|
|
5728
|
+
}
|
|
5729
|
+
if (hasYield(block) && !signature.generator.length) {
|
|
5730
|
+
signature.generator.push("*");
|
|
5731
|
+
}
|
|
5714
5732
|
return {
|
|
5715
5733
|
...signature,
|
|
5716
5734
|
type: "FunctionExpression",
|
|
@@ -5759,7 +5777,7 @@ ${input.slice(result.pos)}
|
|
|
5759
5777
|
body = [prefix, rhs];
|
|
5760
5778
|
}
|
|
5761
5779
|
const children = [ref, " => ", ...body];
|
|
5762
|
-
if (
|
|
5780
|
+
if (hasAwait(body)) {
|
|
5763
5781
|
children.unshift("async ");
|
|
5764
5782
|
}
|
|
5765
5783
|
return {
|
|
@@ -5959,20 +5977,32 @@ ${input.slice(result.pos)}
|
|
|
5959
5977
|
return result;
|
|
5960
5978
|
}
|
|
5961
5979
|
}
|
|
5962
|
-
var ThinArrowFunction$0 = $TS($S(Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
5963
|
-
var
|
|
5964
|
-
var
|
|
5965
|
-
var
|
|
5966
|
-
var
|
|
5980
|
+
var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
5981
|
+
var async = $1;
|
|
5982
|
+
var parameters = $2;
|
|
5983
|
+
var suffix = $3;
|
|
5984
|
+
var arrow = $5;
|
|
5985
|
+
var block = $6;
|
|
5986
|
+
if (hasAwait(block) && !async) {
|
|
5987
|
+
async = "async ";
|
|
5988
|
+
}
|
|
5989
|
+
let generator;
|
|
5990
|
+
if (hasYield(block)) {
|
|
5991
|
+
generator = "*";
|
|
5992
|
+
}
|
|
5967
5993
|
return {
|
|
5968
5994
|
type: "FunctionExpression",
|
|
5969
5995
|
id: void 0,
|
|
5970
5996
|
parameters,
|
|
5971
5997
|
returnType: suffix,
|
|
5972
5998
|
ts: false,
|
|
5999
|
+
async,
|
|
6000
|
+
generator,
|
|
5973
6001
|
block,
|
|
5974
6002
|
children: [
|
|
6003
|
+
async,
|
|
5975
6004
|
{ $loc: arrow.$loc, token: "function" },
|
|
6005
|
+
generator,
|
|
5976
6006
|
parameters,
|
|
5977
6007
|
suffix,
|
|
5978
6008
|
block
|
|
@@ -7939,9 +7969,38 @@ ${input.slice(result.pos)}
|
|
|
7939
7969
|
var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
|
|
7940
7970
|
var signature = $1;
|
|
7941
7971
|
var block = $3;
|
|
7972
|
+
let children = $0;
|
|
7973
|
+
let generatorPos = 0;
|
|
7974
|
+
const { modifier } = signature;
|
|
7975
|
+
if (hasAwait(block)) {
|
|
7976
|
+
generatorPos++;
|
|
7977
|
+
children = children.slice();
|
|
7978
|
+
if (modifier?.get || modifier?.set) {
|
|
7979
|
+
children.push({
|
|
7980
|
+
type: "Error",
|
|
7981
|
+
message: "Getters and setters cannot be async"
|
|
7982
|
+
});
|
|
7983
|
+
} else if (modifier?.async) {
|
|
7984
|
+
} else {
|
|
7985
|
+
children.unshift("async ");
|
|
7986
|
+
}
|
|
7987
|
+
}
|
|
7988
|
+
if (hasYield(block)) {
|
|
7989
|
+
if (children === $0)
|
|
7990
|
+
children = children.slice();
|
|
7991
|
+
if (modifier?.get || modifier?.set) {
|
|
7992
|
+
children.push({
|
|
7993
|
+
type: "Error",
|
|
7994
|
+
message: "Getters and setters cannot be generators"
|
|
7995
|
+
});
|
|
7996
|
+
} else if (modifier?.generator) {
|
|
7997
|
+
} else {
|
|
7998
|
+
children.splice(generatorPos, 0, "*");
|
|
7999
|
+
}
|
|
8000
|
+
}
|
|
7942
8001
|
return {
|
|
7943
8002
|
type: "MethodDefinition",
|
|
7944
|
-
children
|
|
8003
|
+
children,
|
|
7945
8004
|
name: signature.name,
|
|
7946
8005
|
signature,
|
|
7947
8006
|
block,
|
|
@@ -7970,9 +8029,37 @@ ${input.slice(result.pos)}
|
|
|
7970
8029
|
return result;
|
|
7971
8030
|
}
|
|
7972
8031
|
}
|
|
7973
|
-
var MethodModifier$0 = $S(GetOrSet, $E(_))
|
|
7974
|
-
|
|
7975
|
-
|
|
8032
|
+
var MethodModifier$0 = $TS($S(GetOrSet, $E(_)), function($skip, $loc, $0, $1, $2) {
|
|
8033
|
+
var kind = $1;
|
|
8034
|
+
return {
|
|
8035
|
+
type: "MethodModifier",
|
|
8036
|
+
async: false,
|
|
8037
|
+
generator: false,
|
|
8038
|
+
get: kind.token === "get",
|
|
8039
|
+
set: kind.token === "set",
|
|
8040
|
+
children: $0
|
|
8041
|
+
};
|
|
8042
|
+
});
|
|
8043
|
+
var MethodModifier$1 = $TS($S($S(Async, __), $E($S(Star, __))), function($skip, $loc, $0, $1, $2) {
|
|
8044
|
+
return {
|
|
8045
|
+
type: "MethodModifier",
|
|
8046
|
+
async: true,
|
|
8047
|
+
get: false,
|
|
8048
|
+
set: false,
|
|
8049
|
+
generator: !!$1,
|
|
8050
|
+
children: $0
|
|
8051
|
+
};
|
|
8052
|
+
});
|
|
8053
|
+
var MethodModifier$2 = $TS($S(Star, __), function($skip, $loc, $0, $1, $2) {
|
|
8054
|
+
return {
|
|
8055
|
+
type: "MethodModifier",
|
|
8056
|
+
async: false,
|
|
8057
|
+
get: false,
|
|
8058
|
+
set: false,
|
|
8059
|
+
generator: true,
|
|
8060
|
+
children: $0
|
|
8061
|
+
};
|
|
8062
|
+
});
|
|
7976
8063
|
function MethodModifier(state) {
|
|
7977
8064
|
let eventData;
|
|
7978
8065
|
if (state.events) {
|
|
@@ -8005,7 +8092,8 @@ ${input.slice(result.pos)}
|
|
|
8005
8092
|
parameters
|
|
8006
8093
|
};
|
|
8007
8094
|
});
|
|
8008
|
-
var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $
|
|
8095
|
+
var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $E(_), NonEmptyParameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
8096
|
+
var modifier = $1;
|
|
8009
8097
|
var name = $2;
|
|
8010
8098
|
var parameters = $4;
|
|
8011
8099
|
var suffix = $5;
|
|
@@ -8018,7 +8106,7 @@ ${input.slice(result.pos)}
|
|
|
8018
8106
|
type: "MethodSignature",
|
|
8019
8107
|
children: $0,
|
|
8020
8108
|
name,
|
|
8021
|
-
modifier
|
|
8109
|
+
modifier,
|
|
8022
8110
|
returnType: suffix,
|
|
8023
8111
|
parameters
|
|
8024
8112
|
};
|
|
@@ -15886,7 +15974,7 @@ ${input.slice(result.pos)}
|
|
|
15886
15974
|
}
|
|
15887
15975
|
}
|
|
15888
15976
|
var Yield$0 = $TS($S($EXPECT($L164, fail, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
15889
|
-
return { $loc, token: $1 };
|
|
15977
|
+
return { $loc, token: $1, type: "Yield" };
|
|
15890
15978
|
});
|
|
15891
15979
|
function Yield(state) {
|
|
15892
15980
|
let eventData;
|
|
@@ -20698,15 +20786,12 @@ ${input.slice(result.pos)}
|
|
|
20698
20786
|
], exp.async)
|
|
20699
20787
|
);
|
|
20700
20788
|
}
|
|
20701
|
-
module.hasAwait = (exp) => {
|
|
20702
|
-
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
|
|
20703
|
-
};
|
|
20704
20789
|
module.wrapIIFE = (exp, async) => {
|
|
20705
20790
|
let prefix, suffix;
|
|
20706
20791
|
if (async) {
|
|
20707
20792
|
prefix = "(async ()=>{";
|
|
20708
20793
|
suffix = "})()";
|
|
20709
|
-
} else if (
|
|
20794
|
+
} else if (hasAwait(exp)) {
|
|
20710
20795
|
prefix = "(await (async ()=>{";
|
|
20711
20796
|
suffix = "})())";
|
|
20712
20797
|
} else {
|
|
@@ -21280,13 +21365,6 @@ ${input.slice(result.pos)}
|
|
|
21280
21365
|
}, props2]
|
|
21281
21366
|
};
|
|
21282
21367
|
};
|
|
21283
|
-
function isFunction(node) {
|
|
21284
|
-
const { type } = node;
|
|
21285
|
-
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
21286
|
-
}
|
|
21287
|
-
function gatherRecursiveWithinFunction(node, predicate) {
|
|
21288
|
-
return gatherRecursive(node, predicate, isFunction);
|
|
21289
|
-
}
|
|
21290
21368
|
function addParentPointers(node, parent) {
|
|
21291
21369
|
if (node == null)
|
|
21292
21370
|
return;
|
|
@@ -21458,7 +21536,7 @@ ${input.slice(result.pos)}
|
|
|
21458
21536
|
const { signature, block } = f;
|
|
21459
21537
|
const isConstructor = signature.name === "constructor";
|
|
21460
21538
|
const isVoid = isVoidType(signature.returnType?.t);
|
|
21461
|
-
const isSet = signature.modifier
|
|
21539
|
+
const isSet = signature.modifier?.set;
|
|
21462
21540
|
if (!isConstructor && !isSet && !isVoid) {
|
|
21463
21541
|
insertReturn(block);
|
|
21464
21542
|
}
|
|
@@ -21619,24 +21697,24 @@ ${input.slice(result.pos)}
|
|
|
21619
21697
|
};
|
|
21620
21698
|
module.convertMethodToFunction = function(method) {
|
|
21621
21699
|
const { signature, block } = method;
|
|
21622
|
-
let
|
|
21623
|
-
if (
|
|
21624
|
-
if (
|
|
21700
|
+
let { modifier } = signature;
|
|
21701
|
+
if (modifier) {
|
|
21702
|
+
if (modifier.get || modifier.set) {
|
|
21625
21703
|
throw new Error("cannot convert get/set method to function");
|
|
21626
|
-
} else if (
|
|
21627
|
-
|
|
21704
|
+
} else if (modifier.async) {
|
|
21705
|
+
modifier = [modifier.children[0][0], " function ", ...modifier.children.slice(1)];
|
|
21628
21706
|
} else {
|
|
21629
|
-
|
|
21707
|
+
modifier = ["function ", ...modifier.children];
|
|
21630
21708
|
}
|
|
21631
21709
|
} else {
|
|
21632
|
-
|
|
21710
|
+
modifier = "function ";
|
|
21633
21711
|
}
|
|
21634
21712
|
return {
|
|
21635
21713
|
...signature,
|
|
21636
21714
|
id: signature.name,
|
|
21637
21715
|
type: "FunctionExpression",
|
|
21638
21716
|
children: [
|
|
21639
|
-
[
|
|
21717
|
+
[modifier, ...signature.children.slice(1)],
|
|
21640
21718
|
block
|
|
21641
21719
|
],
|
|
21642
21720
|
block
|
|
@@ -22611,6 +22689,10 @@ ${input.slice(result.pos)}
|
|
|
22611
22689
|
gatherNodes,
|
|
22612
22690
|
gatherRecursive,
|
|
22613
22691
|
gatherRecursiveAll,
|
|
22692
|
+
gatherRecursiveWithinFunction,
|
|
22693
|
+
hasAwait,
|
|
22694
|
+
hasYield,
|
|
22695
|
+
isFunction,
|
|
22614
22696
|
removeParentPointers
|
|
22615
22697
|
} = require_lib();
|
|
22616
22698
|
}
|
package/dist/main.js
CHANGED
|
@@ -115,12 +115,29 @@ var require_lib = __commonJS({
|
|
|
115
115
|
}
|
|
116
116
|
return nodes;
|
|
117
117
|
}
|
|
118
|
+
function hasAwait(exp) {
|
|
119
|
+
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
|
|
120
|
+
}
|
|
121
|
+
function hasYield(exp) {
|
|
122
|
+
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
|
|
123
|
+
}
|
|
124
|
+
function isFunction(node) {
|
|
125
|
+
const { type } = node;
|
|
126
|
+
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
127
|
+
}
|
|
128
|
+
function gatherRecursiveWithinFunction(node, predicate) {
|
|
129
|
+
return gatherRecursive(node, predicate, isFunction);
|
|
130
|
+
}
|
|
118
131
|
module2.exports = {
|
|
119
132
|
clone,
|
|
120
133
|
deepCopy,
|
|
121
134
|
gatherNodes,
|
|
122
135
|
gatherRecursive,
|
|
123
136
|
gatherRecursiveAll,
|
|
137
|
+
gatherRecursiveWithinFunction,
|
|
138
|
+
hasAwait,
|
|
139
|
+
hasYield,
|
|
140
|
+
isFunction,
|
|
124
141
|
removeParentPointers
|
|
125
142
|
};
|
|
126
143
|
}
|
|
@@ -568,7 +585,6 @@ ${input.slice(result.pos)}
|
|
|
568
585
|
YieldExpression,
|
|
569
586
|
YieldTail,
|
|
570
587
|
ArrowFunction,
|
|
571
|
-
ArrowFunctionTail,
|
|
572
588
|
FatArrow,
|
|
573
589
|
FatArrowBody,
|
|
574
590
|
ConditionalExpression,
|
|
@@ -2588,53 +2604,36 @@ ${input.slice(result.pos)}
|
|
|
2588
2604
|
return result;
|
|
2589
2605
|
}
|
|
2590
2606
|
}
|
|
2591
|
-
var ArrowFunction$0 =
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
let eventData;
|
|
2600
|
-
if (state.events) {
|
|
2601
|
-
const result = state.events.enter?.("ArrowFunction", state);
|
|
2602
|
-
if (result) {
|
|
2603
|
-
if (result.cache)
|
|
2604
|
-
return result.cache;
|
|
2605
|
-
eventData = result.data;
|
|
2606
|
-
}
|
|
2607
|
+
var ArrowFunction$0 = ThinArrowFunction;
|
|
2608
|
+
var ArrowFunction$1 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
2609
|
+
var async = $1;
|
|
2610
|
+
var parameters = $2;
|
|
2611
|
+
var suffix = $3;
|
|
2612
|
+
var expOrBlock = $5;
|
|
2613
|
+
if (hasAwait(expOrBlock) && !async) {
|
|
2614
|
+
async = "async ";
|
|
2607
2615
|
}
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
const result = ArrowFunction$0(state);
|
|
2615
|
-
if (state.events)
|
|
2616
|
-
state.events.exit?.("ArrowFunction", state, result, eventData);
|
|
2617
|
-
return result;
|
|
2616
|
+
let error;
|
|
2617
|
+
if (hasYield(expOrBlock)) {
|
|
2618
|
+
error = {
|
|
2619
|
+
type: "Error",
|
|
2620
|
+
message: "Can't use yield inside of => arrow function"
|
|
2621
|
+
};
|
|
2618
2622
|
}
|
|
2619
|
-
}
|
|
2620
|
-
var ArrowFunctionTail$0 = ThinArrowFunction;
|
|
2621
|
-
var ArrowFunctionTail$1 = $TS($S(Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
2622
|
-
var parameters = $1;
|
|
2623
|
-
var suffix = $2;
|
|
2624
|
-
var expOrBlock = $4;
|
|
2625
2623
|
return {
|
|
2626
2624
|
type: "ArrowFunction",
|
|
2627
2625
|
parameters,
|
|
2628
2626
|
returnType: suffix,
|
|
2629
2627
|
ts: false,
|
|
2628
|
+
async,
|
|
2630
2629
|
block: expOrBlock,
|
|
2631
|
-
children: $0
|
|
2630
|
+
children: [async, $0.slice(1), error]
|
|
2632
2631
|
};
|
|
2633
2632
|
});
|
|
2634
|
-
function
|
|
2633
|
+
function ArrowFunction(state) {
|
|
2635
2634
|
let eventData;
|
|
2636
2635
|
if (state.events) {
|
|
2637
|
-
const result = state.events.enter?.("
|
|
2636
|
+
const result = state.events.enter?.("ArrowFunction", state);
|
|
2638
2637
|
if (result) {
|
|
2639
2638
|
if (result.cache)
|
|
2640
2639
|
return result.cache;
|
|
@@ -2642,14 +2641,14 @@ ${input.slice(result.pos)}
|
|
|
2642
2641
|
}
|
|
2643
2642
|
}
|
|
2644
2643
|
if (state.tokenize) {
|
|
2645
|
-
const result = $TOKEN("
|
|
2644
|
+
const result = $TOKEN("ArrowFunction", state, ArrowFunction$0(state) || ArrowFunction$1(state));
|
|
2646
2645
|
if (state.events)
|
|
2647
|
-
state.events.exit?.("
|
|
2646
|
+
state.events.exit?.("ArrowFunction", state, result, eventData);
|
|
2648
2647
|
return result;
|
|
2649
2648
|
} else {
|
|
2650
|
-
const result =
|
|
2649
|
+
const result = ArrowFunction$0(state) || ArrowFunction$1(state);
|
|
2651
2650
|
if (state.events)
|
|
2652
|
-
state.events.exit?.("
|
|
2651
|
+
state.events.exit?.("ArrowFunction", state, result, eventData);
|
|
2653
2652
|
return result;
|
|
2654
2653
|
}
|
|
2655
2654
|
}
|
|
@@ -3560,9 +3559,16 @@ ${input.slice(result.pos)}
|
|
|
3560
3559
|
var exp = $6;
|
|
3561
3560
|
switch (exp.type) {
|
|
3562
3561
|
case "FunctionExpression":
|
|
3562
|
+
const fnTokenIndex = exp.children.findIndex((c) => c?.token?.startsWith("function"));
|
|
3563
|
+
const children = exp.children.slice();
|
|
3564
|
+
if (exp.generator) {
|
|
3565
|
+
children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
|
|
3566
|
+
} else {
|
|
3567
|
+
children.splice(fnTokenIndex, 1, id);
|
|
3568
|
+
}
|
|
3563
3569
|
return {
|
|
3564
3570
|
...exp,
|
|
3565
|
-
children
|
|
3571
|
+
children
|
|
3566
3572
|
};
|
|
3567
3573
|
default:
|
|
3568
3574
|
return [id, " = ", exp];
|
|
@@ -5663,22 +5669,28 @@ ${input.slice(result.pos)}
|
|
|
5663
5669
|
return result;
|
|
5664
5670
|
}
|
|
5665
5671
|
}
|
|
5666
|
-
var FunctionSignature$0 = $TS($S($E($S(Async,
|
|
5672
|
+
var FunctionSignature$0 = $TS($S($E($S(Async, _)), Function, $E($S($E(_), Star)), $E($S($E(_), NWBindingIdentifier)), $E(_), Parameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
5667
5673
|
var async = $1;
|
|
5668
5674
|
var func = $2;
|
|
5669
|
-
var
|
|
5675
|
+
var generator = $3;
|
|
5670
5676
|
var wid = $4;
|
|
5671
5677
|
var w = $5;
|
|
5672
5678
|
var parameters = $6;
|
|
5673
5679
|
var suffix = $7;
|
|
5680
|
+
if (!async)
|
|
5681
|
+
async = [];
|
|
5682
|
+
if (!generator)
|
|
5683
|
+
generator = [];
|
|
5674
5684
|
return {
|
|
5675
5685
|
type: "FunctionSignature",
|
|
5676
5686
|
id: wid?.[1],
|
|
5677
5687
|
parameters,
|
|
5678
5688
|
returnType: suffix,
|
|
5679
5689
|
ts: false,
|
|
5690
|
+
async,
|
|
5691
|
+
generator,
|
|
5680
5692
|
block: null,
|
|
5681
|
-
children: !parameters.implicit ? $0 : [async, func,
|
|
5693
|
+
children: !parameters.implicit ? $0 : [async, func, generator, wid, parameters, w, suffix]
|
|
5682
5694
|
};
|
|
5683
5695
|
});
|
|
5684
5696
|
function FunctionSignature(state) {
|
|
@@ -5710,6 +5722,12 @@ ${input.slice(result.pos)}
|
|
|
5710
5722
|
signature.ts = true;
|
|
5711
5723
|
return signature;
|
|
5712
5724
|
}
|
|
5725
|
+
if (hasAwait(block) && !signature.async.length) {
|
|
5726
|
+
signature.async.push("async ");
|
|
5727
|
+
}
|
|
5728
|
+
if (hasYield(block) && !signature.generator.length) {
|
|
5729
|
+
signature.generator.push("*");
|
|
5730
|
+
}
|
|
5713
5731
|
return {
|
|
5714
5732
|
...signature,
|
|
5715
5733
|
type: "FunctionExpression",
|
|
@@ -5758,7 +5776,7 @@ ${input.slice(result.pos)}
|
|
|
5758
5776
|
body = [prefix, rhs];
|
|
5759
5777
|
}
|
|
5760
5778
|
const children = [ref, " => ", ...body];
|
|
5761
|
-
if (
|
|
5779
|
+
if (hasAwait(body)) {
|
|
5762
5780
|
children.unshift("async ");
|
|
5763
5781
|
}
|
|
5764
5782
|
return {
|
|
@@ -5958,20 +5976,32 @@ ${input.slice(result.pos)}
|
|
|
5958
5976
|
return result;
|
|
5959
5977
|
}
|
|
5960
5978
|
}
|
|
5961
|
-
var ThinArrowFunction$0 = $TS($S(Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
5962
|
-
var
|
|
5963
|
-
var
|
|
5964
|
-
var
|
|
5965
|
-
var
|
|
5979
|
+
var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
5980
|
+
var async = $1;
|
|
5981
|
+
var parameters = $2;
|
|
5982
|
+
var suffix = $3;
|
|
5983
|
+
var arrow = $5;
|
|
5984
|
+
var block = $6;
|
|
5985
|
+
if (hasAwait(block) && !async) {
|
|
5986
|
+
async = "async ";
|
|
5987
|
+
}
|
|
5988
|
+
let generator;
|
|
5989
|
+
if (hasYield(block)) {
|
|
5990
|
+
generator = "*";
|
|
5991
|
+
}
|
|
5966
5992
|
return {
|
|
5967
5993
|
type: "FunctionExpression",
|
|
5968
5994
|
id: void 0,
|
|
5969
5995
|
parameters,
|
|
5970
5996
|
returnType: suffix,
|
|
5971
5997
|
ts: false,
|
|
5998
|
+
async,
|
|
5999
|
+
generator,
|
|
5972
6000
|
block,
|
|
5973
6001
|
children: [
|
|
6002
|
+
async,
|
|
5974
6003
|
{ $loc: arrow.$loc, token: "function" },
|
|
6004
|
+
generator,
|
|
5975
6005
|
parameters,
|
|
5976
6006
|
suffix,
|
|
5977
6007
|
block
|
|
@@ -7938,9 +7968,38 @@ ${input.slice(result.pos)}
|
|
|
7938
7968
|
var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
|
|
7939
7969
|
var signature = $1;
|
|
7940
7970
|
var block = $3;
|
|
7971
|
+
let children = $0;
|
|
7972
|
+
let generatorPos = 0;
|
|
7973
|
+
const { modifier } = signature;
|
|
7974
|
+
if (hasAwait(block)) {
|
|
7975
|
+
generatorPos++;
|
|
7976
|
+
children = children.slice();
|
|
7977
|
+
if (modifier?.get || modifier?.set) {
|
|
7978
|
+
children.push({
|
|
7979
|
+
type: "Error",
|
|
7980
|
+
message: "Getters and setters cannot be async"
|
|
7981
|
+
});
|
|
7982
|
+
} else if (modifier?.async) {
|
|
7983
|
+
} else {
|
|
7984
|
+
children.unshift("async ");
|
|
7985
|
+
}
|
|
7986
|
+
}
|
|
7987
|
+
if (hasYield(block)) {
|
|
7988
|
+
if (children === $0)
|
|
7989
|
+
children = children.slice();
|
|
7990
|
+
if (modifier?.get || modifier?.set) {
|
|
7991
|
+
children.push({
|
|
7992
|
+
type: "Error",
|
|
7993
|
+
message: "Getters and setters cannot be generators"
|
|
7994
|
+
});
|
|
7995
|
+
} else if (modifier?.generator) {
|
|
7996
|
+
} else {
|
|
7997
|
+
children.splice(generatorPos, 0, "*");
|
|
7998
|
+
}
|
|
7999
|
+
}
|
|
7941
8000
|
return {
|
|
7942
8001
|
type: "MethodDefinition",
|
|
7943
|
-
children
|
|
8002
|
+
children,
|
|
7944
8003
|
name: signature.name,
|
|
7945
8004
|
signature,
|
|
7946
8005
|
block,
|
|
@@ -7969,9 +8028,37 @@ ${input.slice(result.pos)}
|
|
|
7969
8028
|
return result;
|
|
7970
8029
|
}
|
|
7971
8030
|
}
|
|
7972
|
-
var MethodModifier$0 = $S(GetOrSet, $E(_))
|
|
7973
|
-
|
|
7974
|
-
|
|
8031
|
+
var MethodModifier$0 = $TS($S(GetOrSet, $E(_)), function($skip, $loc, $0, $1, $2) {
|
|
8032
|
+
var kind = $1;
|
|
8033
|
+
return {
|
|
8034
|
+
type: "MethodModifier",
|
|
8035
|
+
async: false,
|
|
8036
|
+
generator: false,
|
|
8037
|
+
get: kind.token === "get",
|
|
8038
|
+
set: kind.token === "set",
|
|
8039
|
+
children: $0
|
|
8040
|
+
};
|
|
8041
|
+
});
|
|
8042
|
+
var MethodModifier$1 = $TS($S($S(Async, __), $E($S(Star, __))), function($skip, $loc, $0, $1, $2) {
|
|
8043
|
+
return {
|
|
8044
|
+
type: "MethodModifier",
|
|
8045
|
+
async: true,
|
|
8046
|
+
get: false,
|
|
8047
|
+
set: false,
|
|
8048
|
+
generator: !!$1,
|
|
8049
|
+
children: $0
|
|
8050
|
+
};
|
|
8051
|
+
});
|
|
8052
|
+
var MethodModifier$2 = $TS($S(Star, __), function($skip, $loc, $0, $1, $2) {
|
|
8053
|
+
return {
|
|
8054
|
+
type: "MethodModifier",
|
|
8055
|
+
async: false,
|
|
8056
|
+
get: false,
|
|
8057
|
+
set: false,
|
|
8058
|
+
generator: true,
|
|
8059
|
+
children: $0
|
|
8060
|
+
};
|
|
8061
|
+
});
|
|
7975
8062
|
function MethodModifier(state) {
|
|
7976
8063
|
let eventData;
|
|
7977
8064
|
if (state.events) {
|
|
@@ -8004,7 +8091,8 @@ ${input.slice(result.pos)}
|
|
|
8004
8091
|
parameters
|
|
8005
8092
|
};
|
|
8006
8093
|
});
|
|
8007
|
-
var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $
|
|
8094
|
+
var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $E(_), NonEmptyParameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
8095
|
+
var modifier = $1;
|
|
8008
8096
|
var name = $2;
|
|
8009
8097
|
var parameters = $4;
|
|
8010
8098
|
var suffix = $5;
|
|
@@ -8017,7 +8105,7 @@ ${input.slice(result.pos)}
|
|
|
8017
8105
|
type: "MethodSignature",
|
|
8018
8106
|
children: $0,
|
|
8019
8107
|
name,
|
|
8020
|
-
modifier
|
|
8108
|
+
modifier,
|
|
8021
8109
|
returnType: suffix,
|
|
8022
8110
|
parameters
|
|
8023
8111
|
};
|
|
@@ -15885,7 +15973,7 @@ ${input.slice(result.pos)}
|
|
|
15885
15973
|
}
|
|
15886
15974
|
}
|
|
15887
15975
|
var Yield$0 = $TS($S($EXPECT($L164, fail, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
15888
|
-
return { $loc, token: $1 };
|
|
15976
|
+
return { $loc, token: $1, type: "Yield" };
|
|
15889
15977
|
});
|
|
15890
15978
|
function Yield(state) {
|
|
15891
15979
|
let eventData;
|
|
@@ -20697,15 +20785,12 @@ ${input.slice(result.pos)}
|
|
|
20697
20785
|
], exp.async)
|
|
20698
20786
|
);
|
|
20699
20787
|
}
|
|
20700
|
-
module2.hasAwait = (exp) => {
|
|
20701
|
-
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
|
|
20702
|
-
};
|
|
20703
20788
|
module2.wrapIIFE = (exp, async) => {
|
|
20704
20789
|
let prefix, suffix;
|
|
20705
20790
|
if (async) {
|
|
20706
20791
|
prefix = "(async ()=>{";
|
|
20707
20792
|
suffix = "})()";
|
|
20708
|
-
} else if (
|
|
20793
|
+
} else if (hasAwait(exp)) {
|
|
20709
20794
|
prefix = "(await (async ()=>{";
|
|
20710
20795
|
suffix = "})())";
|
|
20711
20796
|
} else {
|
|
@@ -21279,13 +21364,6 @@ ${input.slice(result.pos)}
|
|
|
21279
21364
|
}, props2]
|
|
21280
21365
|
};
|
|
21281
21366
|
};
|
|
21282
|
-
function isFunction(node) {
|
|
21283
|
-
const { type } = node;
|
|
21284
|
-
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
21285
|
-
}
|
|
21286
|
-
function gatherRecursiveWithinFunction(node, predicate) {
|
|
21287
|
-
return gatherRecursive(node, predicate, isFunction);
|
|
21288
|
-
}
|
|
21289
21367
|
function addParentPointers(node, parent) {
|
|
21290
21368
|
if (node == null)
|
|
21291
21369
|
return;
|
|
@@ -21457,7 +21535,7 @@ ${input.slice(result.pos)}
|
|
|
21457
21535
|
const { signature, block } = f;
|
|
21458
21536
|
const isConstructor = signature.name === "constructor";
|
|
21459
21537
|
const isVoid = isVoidType(signature.returnType?.t);
|
|
21460
|
-
const isSet = signature.modifier
|
|
21538
|
+
const isSet = signature.modifier?.set;
|
|
21461
21539
|
if (!isConstructor && !isSet && !isVoid) {
|
|
21462
21540
|
insertReturn(block);
|
|
21463
21541
|
}
|
|
@@ -21618,24 +21696,24 @@ ${input.slice(result.pos)}
|
|
|
21618
21696
|
};
|
|
21619
21697
|
module2.convertMethodToFunction = function(method) {
|
|
21620
21698
|
const { signature, block } = method;
|
|
21621
|
-
let
|
|
21622
|
-
if (
|
|
21623
|
-
if (
|
|
21699
|
+
let { modifier } = signature;
|
|
21700
|
+
if (modifier) {
|
|
21701
|
+
if (modifier.get || modifier.set) {
|
|
21624
21702
|
throw new Error("cannot convert get/set method to function");
|
|
21625
|
-
} else if (
|
|
21626
|
-
|
|
21703
|
+
} else if (modifier.async) {
|
|
21704
|
+
modifier = [modifier.children[0][0], " function ", ...modifier.children.slice(1)];
|
|
21627
21705
|
} else {
|
|
21628
|
-
|
|
21706
|
+
modifier = ["function ", ...modifier.children];
|
|
21629
21707
|
}
|
|
21630
21708
|
} else {
|
|
21631
|
-
|
|
21709
|
+
modifier = "function ";
|
|
21632
21710
|
}
|
|
21633
21711
|
return {
|
|
21634
21712
|
...signature,
|
|
21635
21713
|
id: signature.name,
|
|
21636
21714
|
type: "FunctionExpression",
|
|
21637
21715
|
children: [
|
|
21638
|
-
[
|
|
21716
|
+
[modifier, ...signature.children.slice(1)],
|
|
21639
21717
|
block
|
|
21640
21718
|
],
|
|
21641
21719
|
block
|
|
@@ -22610,6 +22688,10 @@ ${input.slice(result.pos)}
|
|
|
22610
22688
|
gatherNodes,
|
|
22611
22689
|
gatherRecursive,
|
|
22612
22690
|
gatherRecursiveAll,
|
|
22691
|
+
gatherRecursiveWithinFunction,
|
|
22692
|
+
hasAwait,
|
|
22693
|
+
hasYield,
|
|
22694
|
+
isFunction,
|
|
22613
22695
|
removeParentPointers
|
|
22614
22696
|
} = require_lib();
|
|
22615
22697
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -113,12 +113,29 @@ var require_lib = __commonJS({
|
|
|
113
113
|
}
|
|
114
114
|
return nodes;
|
|
115
115
|
}
|
|
116
|
+
function hasAwait(exp) {
|
|
117
|
+
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
|
|
118
|
+
}
|
|
119
|
+
function hasYield(exp) {
|
|
120
|
+
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
|
|
121
|
+
}
|
|
122
|
+
function isFunction(node) {
|
|
123
|
+
const { type } = node;
|
|
124
|
+
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
125
|
+
}
|
|
126
|
+
function gatherRecursiveWithinFunction(node, predicate) {
|
|
127
|
+
return gatherRecursive(node, predicate, isFunction);
|
|
128
|
+
}
|
|
116
129
|
module.exports = {
|
|
117
130
|
clone,
|
|
118
131
|
deepCopy,
|
|
119
132
|
gatherNodes,
|
|
120
133
|
gatherRecursive,
|
|
121
134
|
gatherRecursiveAll,
|
|
135
|
+
gatherRecursiveWithinFunction,
|
|
136
|
+
hasAwait,
|
|
137
|
+
hasYield,
|
|
138
|
+
isFunction,
|
|
122
139
|
removeParentPointers
|
|
123
140
|
};
|
|
124
141
|
}
|
|
@@ -566,7 +583,6 @@ ${input.slice(result.pos)}
|
|
|
566
583
|
YieldExpression,
|
|
567
584
|
YieldTail,
|
|
568
585
|
ArrowFunction,
|
|
569
|
-
ArrowFunctionTail,
|
|
570
586
|
FatArrow,
|
|
571
587
|
FatArrowBody,
|
|
572
588
|
ConditionalExpression,
|
|
@@ -2586,53 +2602,36 @@ ${input.slice(result.pos)}
|
|
|
2586
2602
|
return result;
|
|
2587
2603
|
}
|
|
2588
2604
|
}
|
|
2589
|
-
var ArrowFunction$0 =
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
let eventData;
|
|
2598
|
-
if (state.events) {
|
|
2599
|
-
const result = state.events.enter?.("ArrowFunction", state);
|
|
2600
|
-
if (result) {
|
|
2601
|
-
if (result.cache)
|
|
2602
|
-
return result.cache;
|
|
2603
|
-
eventData = result.data;
|
|
2604
|
-
}
|
|
2605
|
+
var ArrowFunction$0 = ThinArrowFunction;
|
|
2606
|
+
var ArrowFunction$1 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
2607
|
+
var async = $1;
|
|
2608
|
+
var parameters = $2;
|
|
2609
|
+
var suffix = $3;
|
|
2610
|
+
var expOrBlock = $5;
|
|
2611
|
+
if (hasAwait(expOrBlock) && !async) {
|
|
2612
|
+
async = "async ";
|
|
2605
2613
|
}
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
const result = ArrowFunction$0(state);
|
|
2613
|
-
if (state.events)
|
|
2614
|
-
state.events.exit?.("ArrowFunction", state, result, eventData);
|
|
2615
|
-
return result;
|
|
2614
|
+
let error;
|
|
2615
|
+
if (hasYield(expOrBlock)) {
|
|
2616
|
+
error = {
|
|
2617
|
+
type: "Error",
|
|
2618
|
+
message: "Can't use yield inside of => arrow function"
|
|
2619
|
+
};
|
|
2616
2620
|
}
|
|
2617
|
-
}
|
|
2618
|
-
var ArrowFunctionTail$0 = ThinArrowFunction;
|
|
2619
|
-
var ArrowFunctionTail$1 = $TS($S(Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
2620
|
-
var parameters = $1;
|
|
2621
|
-
var suffix = $2;
|
|
2622
|
-
var expOrBlock = $4;
|
|
2623
2621
|
return {
|
|
2624
2622
|
type: "ArrowFunction",
|
|
2625
2623
|
parameters,
|
|
2626
2624
|
returnType: suffix,
|
|
2627
2625
|
ts: false,
|
|
2626
|
+
async,
|
|
2628
2627
|
block: expOrBlock,
|
|
2629
|
-
children: $0
|
|
2628
|
+
children: [async, $0.slice(1), error]
|
|
2630
2629
|
};
|
|
2631
2630
|
});
|
|
2632
|
-
function
|
|
2631
|
+
function ArrowFunction(state) {
|
|
2633
2632
|
let eventData;
|
|
2634
2633
|
if (state.events) {
|
|
2635
|
-
const result = state.events.enter?.("
|
|
2634
|
+
const result = state.events.enter?.("ArrowFunction", state);
|
|
2636
2635
|
if (result) {
|
|
2637
2636
|
if (result.cache)
|
|
2638
2637
|
return result.cache;
|
|
@@ -2640,14 +2639,14 @@ ${input.slice(result.pos)}
|
|
|
2640
2639
|
}
|
|
2641
2640
|
}
|
|
2642
2641
|
if (state.tokenize) {
|
|
2643
|
-
const result = $TOKEN("
|
|
2642
|
+
const result = $TOKEN("ArrowFunction", state, ArrowFunction$0(state) || ArrowFunction$1(state));
|
|
2644
2643
|
if (state.events)
|
|
2645
|
-
state.events.exit?.("
|
|
2644
|
+
state.events.exit?.("ArrowFunction", state, result, eventData);
|
|
2646
2645
|
return result;
|
|
2647
2646
|
} else {
|
|
2648
|
-
const result =
|
|
2647
|
+
const result = ArrowFunction$0(state) || ArrowFunction$1(state);
|
|
2649
2648
|
if (state.events)
|
|
2650
|
-
state.events.exit?.("
|
|
2649
|
+
state.events.exit?.("ArrowFunction", state, result, eventData);
|
|
2651
2650
|
return result;
|
|
2652
2651
|
}
|
|
2653
2652
|
}
|
|
@@ -3558,9 +3557,16 @@ ${input.slice(result.pos)}
|
|
|
3558
3557
|
var exp = $6;
|
|
3559
3558
|
switch (exp.type) {
|
|
3560
3559
|
case "FunctionExpression":
|
|
3560
|
+
const fnTokenIndex = exp.children.findIndex((c) => c?.token?.startsWith("function"));
|
|
3561
|
+
const children = exp.children.slice();
|
|
3562
|
+
if (exp.generator) {
|
|
3563
|
+
children.splice(fnTokenIndex, 2, children[fnTokenIndex + 1], id);
|
|
3564
|
+
} else {
|
|
3565
|
+
children.splice(fnTokenIndex, 1, id);
|
|
3566
|
+
}
|
|
3561
3567
|
return {
|
|
3562
3568
|
...exp,
|
|
3563
|
-
children
|
|
3569
|
+
children
|
|
3564
3570
|
};
|
|
3565
3571
|
default:
|
|
3566
3572
|
return [id, " = ", exp];
|
|
@@ -5661,22 +5667,28 @@ ${input.slice(result.pos)}
|
|
|
5661
5667
|
return result;
|
|
5662
5668
|
}
|
|
5663
5669
|
}
|
|
5664
|
-
var FunctionSignature$0 = $TS($S($E($S(Async,
|
|
5670
|
+
var FunctionSignature$0 = $TS($S($E($S(Async, _)), Function, $E($S($E(_), Star)), $E($S($E(_), NWBindingIdentifier)), $E(_), Parameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
5665
5671
|
var async = $1;
|
|
5666
5672
|
var func = $2;
|
|
5667
|
-
var
|
|
5673
|
+
var generator = $3;
|
|
5668
5674
|
var wid = $4;
|
|
5669
5675
|
var w = $5;
|
|
5670
5676
|
var parameters = $6;
|
|
5671
5677
|
var suffix = $7;
|
|
5678
|
+
if (!async)
|
|
5679
|
+
async = [];
|
|
5680
|
+
if (!generator)
|
|
5681
|
+
generator = [];
|
|
5672
5682
|
return {
|
|
5673
5683
|
type: "FunctionSignature",
|
|
5674
5684
|
id: wid?.[1],
|
|
5675
5685
|
parameters,
|
|
5676
5686
|
returnType: suffix,
|
|
5677
5687
|
ts: false,
|
|
5688
|
+
async,
|
|
5689
|
+
generator,
|
|
5678
5690
|
block: null,
|
|
5679
|
-
children: !parameters.implicit ? $0 : [async, func,
|
|
5691
|
+
children: !parameters.implicit ? $0 : [async, func, generator, wid, parameters, w, suffix]
|
|
5680
5692
|
};
|
|
5681
5693
|
});
|
|
5682
5694
|
function FunctionSignature(state) {
|
|
@@ -5708,6 +5720,12 @@ ${input.slice(result.pos)}
|
|
|
5708
5720
|
signature.ts = true;
|
|
5709
5721
|
return signature;
|
|
5710
5722
|
}
|
|
5723
|
+
if (hasAwait(block) && !signature.async.length) {
|
|
5724
|
+
signature.async.push("async ");
|
|
5725
|
+
}
|
|
5726
|
+
if (hasYield(block) && !signature.generator.length) {
|
|
5727
|
+
signature.generator.push("*");
|
|
5728
|
+
}
|
|
5711
5729
|
return {
|
|
5712
5730
|
...signature,
|
|
5713
5731
|
type: "FunctionExpression",
|
|
@@ -5756,7 +5774,7 @@ ${input.slice(result.pos)}
|
|
|
5756
5774
|
body = [prefix, rhs];
|
|
5757
5775
|
}
|
|
5758
5776
|
const children = [ref, " => ", ...body];
|
|
5759
|
-
if (
|
|
5777
|
+
if (hasAwait(body)) {
|
|
5760
5778
|
children.unshift("async ");
|
|
5761
5779
|
}
|
|
5762
5780
|
return {
|
|
@@ -5956,20 +5974,32 @@ ${input.slice(result.pos)}
|
|
|
5956
5974
|
return result;
|
|
5957
5975
|
}
|
|
5958
5976
|
}
|
|
5959
|
-
var ThinArrowFunction$0 = $TS($S(Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
5960
|
-
var
|
|
5961
|
-
var
|
|
5962
|
-
var
|
|
5963
|
-
var
|
|
5977
|
+
var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), $Q(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
5978
|
+
var async = $1;
|
|
5979
|
+
var parameters = $2;
|
|
5980
|
+
var suffix = $3;
|
|
5981
|
+
var arrow = $5;
|
|
5982
|
+
var block = $6;
|
|
5983
|
+
if (hasAwait(block) && !async) {
|
|
5984
|
+
async = "async ";
|
|
5985
|
+
}
|
|
5986
|
+
let generator;
|
|
5987
|
+
if (hasYield(block)) {
|
|
5988
|
+
generator = "*";
|
|
5989
|
+
}
|
|
5964
5990
|
return {
|
|
5965
5991
|
type: "FunctionExpression",
|
|
5966
5992
|
id: void 0,
|
|
5967
5993
|
parameters,
|
|
5968
5994
|
returnType: suffix,
|
|
5969
5995
|
ts: false,
|
|
5996
|
+
async,
|
|
5997
|
+
generator,
|
|
5970
5998
|
block,
|
|
5971
5999
|
children: [
|
|
6000
|
+
async,
|
|
5972
6001
|
{ $loc: arrow.$loc, token: "function" },
|
|
6002
|
+
generator,
|
|
5973
6003
|
parameters,
|
|
5974
6004
|
suffix,
|
|
5975
6005
|
block
|
|
@@ -7936,9 +7966,38 @@ ${input.slice(result.pos)}
|
|
|
7936
7966
|
var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
|
|
7937
7967
|
var signature = $1;
|
|
7938
7968
|
var block = $3;
|
|
7969
|
+
let children = $0;
|
|
7970
|
+
let generatorPos = 0;
|
|
7971
|
+
const { modifier } = signature;
|
|
7972
|
+
if (hasAwait(block)) {
|
|
7973
|
+
generatorPos++;
|
|
7974
|
+
children = children.slice();
|
|
7975
|
+
if (modifier?.get || modifier?.set) {
|
|
7976
|
+
children.push({
|
|
7977
|
+
type: "Error",
|
|
7978
|
+
message: "Getters and setters cannot be async"
|
|
7979
|
+
});
|
|
7980
|
+
} else if (modifier?.async) {
|
|
7981
|
+
} else {
|
|
7982
|
+
children.unshift("async ");
|
|
7983
|
+
}
|
|
7984
|
+
}
|
|
7985
|
+
if (hasYield(block)) {
|
|
7986
|
+
if (children === $0)
|
|
7987
|
+
children = children.slice();
|
|
7988
|
+
if (modifier?.get || modifier?.set) {
|
|
7989
|
+
children.push({
|
|
7990
|
+
type: "Error",
|
|
7991
|
+
message: "Getters and setters cannot be generators"
|
|
7992
|
+
});
|
|
7993
|
+
} else if (modifier?.generator) {
|
|
7994
|
+
} else {
|
|
7995
|
+
children.splice(generatorPos, 0, "*");
|
|
7996
|
+
}
|
|
7997
|
+
}
|
|
7939
7998
|
return {
|
|
7940
7999
|
type: "MethodDefinition",
|
|
7941
|
-
children
|
|
8000
|
+
children,
|
|
7942
8001
|
name: signature.name,
|
|
7943
8002
|
signature,
|
|
7944
8003
|
block,
|
|
@@ -7967,9 +8026,37 @@ ${input.slice(result.pos)}
|
|
|
7967
8026
|
return result;
|
|
7968
8027
|
}
|
|
7969
8028
|
}
|
|
7970
|
-
var MethodModifier$0 = $S(GetOrSet, $E(_))
|
|
7971
|
-
|
|
7972
|
-
|
|
8029
|
+
var MethodModifier$0 = $TS($S(GetOrSet, $E(_)), function($skip, $loc, $0, $1, $2) {
|
|
8030
|
+
var kind = $1;
|
|
8031
|
+
return {
|
|
8032
|
+
type: "MethodModifier",
|
|
8033
|
+
async: false,
|
|
8034
|
+
generator: false,
|
|
8035
|
+
get: kind.token === "get",
|
|
8036
|
+
set: kind.token === "set",
|
|
8037
|
+
children: $0
|
|
8038
|
+
};
|
|
8039
|
+
});
|
|
8040
|
+
var MethodModifier$1 = $TS($S($S(Async, __), $E($S(Star, __))), function($skip, $loc, $0, $1, $2) {
|
|
8041
|
+
return {
|
|
8042
|
+
type: "MethodModifier",
|
|
8043
|
+
async: true,
|
|
8044
|
+
get: false,
|
|
8045
|
+
set: false,
|
|
8046
|
+
generator: !!$1,
|
|
8047
|
+
children: $0
|
|
8048
|
+
};
|
|
8049
|
+
});
|
|
8050
|
+
var MethodModifier$2 = $TS($S(Star, __), function($skip, $loc, $0, $1, $2) {
|
|
8051
|
+
return {
|
|
8052
|
+
type: "MethodModifier",
|
|
8053
|
+
async: false,
|
|
8054
|
+
get: false,
|
|
8055
|
+
set: false,
|
|
8056
|
+
generator: true,
|
|
8057
|
+
children: $0
|
|
8058
|
+
};
|
|
8059
|
+
});
|
|
7973
8060
|
function MethodModifier(state) {
|
|
7974
8061
|
let eventData;
|
|
7975
8062
|
if (state.events) {
|
|
@@ -8002,7 +8089,8 @@ ${input.slice(result.pos)}
|
|
|
8002
8089
|
parameters
|
|
8003
8090
|
};
|
|
8004
8091
|
});
|
|
8005
|
-
var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $
|
|
8092
|
+
var MethodSignature$1 = $TS($S($E(MethodModifier), ClassElementName, $E(_), NonEmptyParameters, $E(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
8093
|
+
var modifier = $1;
|
|
8006
8094
|
var name = $2;
|
|
8007
8095
|
var parameters = $4;
|
|
8008
8096
|
var suffix = $5;
|
|
@@ -8015,7 +8103,7 @@ ${input.slice(result.pos)}
|
|
|
8015
8103
|
type: "MethodSignature",
|
|
8016
8104
|
children: $0,
|
|
8017
8105
|
name,
|
|
8018
|
-
modifier
|
|
8106
|
+
modifier,
|
|
8019
8107
|
returnType: suffix,
|
|
8020
8108
|
parameters
|
|
8021
8109
|
};
|
|
@@ -15883,7 +15971,7 @@ ${input.slice(result.pos)}
|
|
|
15883
15971
|
}
|
|
15884
15972
|
}
|
|
15885
15973
|
var Yield$0 = $TS($S($EXPECT($L164, fail, 'Yield "yield"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
15886
|
-
return { $loc, token: $1 };
|
|
15974
|
+
return { $loc, token: $1, type: "Yield" };
|
|
15887
15975
|
});
|
|
15888
15976
|
function Yield(state) {
|
|
15889
15977
|
let eventData;
|
|
@@ -20695,15 +20783,12 @@ ${input.slice(result.pos)}
|
|
|
20695
20783
|
], exp.async)
|
|
20696
20784
|
);
|
|
20697
20785
|
}
|
|
20698
|
-
module.hasAwait = (exp) => {
|
|
20699
|
-
return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
|
|
20700
|
-
};
|
|
20701
20786
|
module.wrapIIFE = (exp, async) => {
|
|
20702
20787
|
let prefix, suffix;
|
|
20703
20788
|
if (async) {
|
|
20704
20789
|
prefix = "(async ()=>{";
|
|
20705
20790
|
suffix = "})()";
|
|
20706
|
-
} else if (
|
|
20791
|
+
} else if (hasAwait(exp)) {
|
|
20707
20792
|
prefix = "(await (async ()=>{";
|
|
20708
20793
|
suffix = "})())";
|
|
20709
20794
|
} else {
|
|
@@ -21277,13 +21362,6 @@ ${input.slice(result.pos)}
|
|
|
21277
21362
|
}, props2]
|
|
21278
21363
|
};
|
|
21279
21364
|
};
|
|
21280
|
-
function isFunction(node) {
|
|
21281
|
-
const { type } = node;
|
|
21282
|
-
return type === "FunctionExpression" || type === "ArrowFunction" || type === "MethodDefinition" || node.async;
|
|
21283
|
-
}
|
|
21284
|
-
function gatherRecursiveWithinFunction(node, predicate) {
|
|
21285
|
-
return gatherRecursive(node, predicate, isFunction);
|
|
21286
|
-
}
|
|
21287
21365
|
function addParentPointers(node, parent) {
|
|
21288
21366
|
if (node == null)
|
|
21289
21367
|
return;
|
|
@@ -21455,7 +21533,7 @@ ${input.slice(result.pos)}
|
|
|
21455
21533
|
const { signature, block } = f;
|
|
21456
21534
|
const isConstructor = signature.name === "constructor";
|
|
21457
21535
|
const isVoid = isVoidType(signature.returnType?.t);
|
|
21458
|
-
const isSet = signature.modifier
|
|
21536
|
+
const isSet = signature.modifier?.set;
|
|
21459
21537
|
if (!isConstructor && !isSet && !isVoid) {
|
|
21460
21538
|
insertReturn(block);
|
|
21461
21539
|
}
|
|
@@ -21616,24 +21694,24 @@ ${input.slice(result.pos)}
|
|
|
21616
21694
|
};
|
|
21617
21695
|
module.convertMethodToFunction = function(method) {
|
|
21618
21696
|
const { signature, block } = method;
|
|
21619
|
-
let
|
|
21620
|
-
if (
|
|
21621
|
-
if (
|
|
21697
|
+
let { modifier } = signature;
|
|
21698
|
+
if (modifier) {
|
|
21699
|
+
if (modifier.get || modifier.set) {
|
|
21622
21700
|
throw new Error("cannot convert get/set method to function");
|
|
21623
|
-
} else if (
|
|
21624
|
-
|
|
21701
|
+
} else if (modifier.async) {
|
|
21702
|
+
modifier = [modifier.children[0][0], " function ", ...modifier.children.slice(1)];
|
|
21625
21703
|
} else {
|
|
21626
|
-
|
|
21704
|
+
modifier = ["function ", ...modifier.children];
|
|
21627
21705
|
}
|
|
21628
21706
|
} else {
|
|
21629
|
-
|
|
21707
|
+
modifier = "function ";
|
|
21630
21708
|
}
|
|
21631
21709
|
return {
|
|
21632
21710
|
...signature,
|
|
21633
21711
|
id: signature.name,
|
|
21634
21712
|
type: "FunctionExpression",
|
|
21635
21713
|
children: [
|
|
21636
|
-
[
|
|
21714
|
+
[modifier, ...signature.children.slice(1)],
|
|
21637
21715
|
block
|
|
21638
21716
|
],
|
|
21639
21717
|
block
|
|
@@ -22608,6 +22686,10 @@ ${input.slice(result.pos)}
|
|
|
22608
22686
|
gatherNodes,
|
|
22609
22687
|
gatherRecursive,
|
|
22610
22688
|
gatherRecursiveAll,
|
|
22689
|
+
gatherRecursiveWithinFunction,
|
|
22690
|
+
hasAwait,
|
|
22691
|
+
hasYield,
|
|
22692
|
+
isFunction,
|
|
22611
22693
|
removeParentPointers
|
|
22612
22694
|
} = require_lib();
|
|
22613
22695
|
}
|