bobe 0.0.33 → 0.0.35
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/bobe.cjs.js +48 -29
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +48 -29
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +48 -29
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +48 -29
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +13 -9
- package/dist/index.umd.js +48 -29
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/bobe.cjs.js
CHANGED
|
@@ -599,24 +599,6 @@ class Tokenizer {
|
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
|
|
602
|
-
var NodeType = function (NodeType) {
|
|
603
|
-
NodeType["Element"] = "Element";
|
|
604
|
-
NodeType["Text"] = "Text";
|
|
605
|
-
NodeType["Interpolation"] = "Interpolation";
|
|
606
|
-
NodeType["Property"] = "Property";
|
|
607
|
-
NodeType["PropertyKey"] = "PropertyKey";
|
|
608
|
-
NodeType["StaticValue"] = "StaticValue";
|
|
609
|
-
NodeType["DynamicValue"] = "DynamicValue";
|
|
610
|
-
NodeType["Program"] = "Program";
|
|
611
|
-
NodeType["If"] = "If";
|
|
612
|
-
NodeType["Else"] = "Else";
|
|
613
|
-
NodeType["Fail"] = "Fail";
|
|
614
|
-
NodeType["For"] = "For";
|
|
615
|
-
NodeType["Component"] = "Component";
|
|
616
|
-
NodeType["Fragment"] = "Fragment";
|
|
617
|
-
return NodeType;
|
|
618
|
-
}(NodeType || {});
|
|
619
|
-
|
|
620
602
|
function _applyDecs2311(e, t, n, r, o, i) {
|
|
621
603
|
var a,
|
|
622
604
|
c,
|
|
@@ -833,10 +815,28 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
833
815
|
}
|
|
834
816
|
}
|
|
835
817
|
|
|
818
|
+
var NodeType = function (NodeType) {
|
|
819
|
+
NodeType["Element"] = "Element";
|
|
820
|
+
NodeType["Text"] = "Text";
|
|
821
|
+
NodeType["Interpolation"] = "Interpolation";
|
|
822
|
+
NodeType["Property"] = "Property";
|
|
823
|
+
NodeType["PropertyKey"] = "PropertyKey";
|
|
824
|
+
NodeType["StaticValue"] = "StaticValue";
|
|
825
|
+
NodeType["DynamicValue"] = "DynamicValue";
|
|
826
|
+
NodeType["Program"] = "Program";
|
|
827
|
+
NodeType["If"] = "If";
|
|
828
|
+
NodeType["Else"] = "Else";
|
|
829
|
+
NodeType["Fail"] = "Fail";
|
|
830
|
+
NodeType["For"] = "For";
|
|
831
|
+
NodeType["Component"] = "Component";
|
|
832
|
+
NodeType["Fragment"] = "Fragment";
|
|
833
|
+
return NodeType;
|
|
834
|
+
}(NodeType || {});
|
|
835
|
+
|
|
836
836
|
let _initProto;
|
|
837
837
|
class Compiler {
|
|
838
838
|
static {
|
|
839
|
-
var _applyDecs$e = _slicedToArray(_applyDecs2311(this, [], [[NodeHook, 2, "parseProgram"], [[NodeHook, NodeLoc], 2, "parseComponentNode"], [[NodeHook, NodeLoc], 2, "parseElementNode"], [[NodeHook, NodeLoc], 2, "parseConditionalNode"], [[NodeHook, NodeLoc], 2, "parseLoopNode"], [NodeHook, 2, "parseProperty"], [[NodeHook, TokenLoc], 2, "parsePropertyKey"], [[NodeHook, TokenLoc], 2, "parsePropertyValue"]]).e, 1);
|
|
839
|
+
var _applyDecs$e = _slicedToArray(_applyDecs2311(this, [], [[NodeHook, 2, "parseProgram"], [[NodeHook, NodeLoc], 2, "parseComponentNode"], [[NodeHook, NodeLoc], 2, "parseElementNode"], [[NodeHook, NodeLoc], 2, "parseConditionalNode"], [[NodeHook, NodeLoc], 2, "parseLoopNode"], [NodeHook, 2, "parseProperty"], [[NodeHook, TokenLoc], 2, "parsePropertyKey"], [[NodeHook, TokenLoc], 2, "parsePropertyValue"], [[NodeHook, TokenLoc], 2, "parseName"]]).e, 1);
|
|
840
840
|
_initProto = _applyDecs$e[0];
|
|
841
841
|
}
|
|
842
842
|
constructor(tokenizer, hooks = {}) {
|
|
@@ -905,12 +905,11 @@ class Compiler {
|
|
|
905
905
|
return this.parseElementNode();
|
|
906
906
|
}
|
|
907
907
|
parseComponentNode(node) {
|
|
908
|
-
const
|
|
909
|
-
const tagName = tagToken.value;
|
|
908
|
+
const name = this.parseName();
|
|
910
909
|
this.tokenizer.nextToken();
|
|
911
910
|
const props = this.headerLineAndExtensions();
|
|
912
911
|
node.type = NodeType.Component;
|
|
913
|
-
node.componentName =
|
|
912
|
+
node.componentName = name;
|
|
914
913
|
node.props = props;
|
|
915
914
|
this.hooks.parseComponentNode?.propsAdded?.call(this, node);
|
|
916
915
|
const children = this.handleChildren();
|
|
@@ -932,8 +931,8 @@ class Compiler {
|
|
|
932
931
|
}
|
|
933
932
|
parseConditionalNode(node) {
|
|
934
933
|
const keyword = this.tokenizer.token.value;
|
|
935
|
-
|
|
936
|
-
const condition =
|
|
934
|
+
this.tokenizer.condExp();
|
|
935
|
+
const condition = this.parsePropertyValue();
|
|
937
936
|
this.tokenizer.nextToken();
|
|
938
937
|
this.tokenizer.nextToken();
|
|
939
938
|
node.type = keyword === 'if' ? NodeType.If : keyword === 'else' ? NodeType.Else : NodeType.Fail;
|
|
@@ -944,22 +943,33 @@ class Compiler {
|
|
|
944
943
|
return node;
|
|
945
944
|
}
|
|
946
945
|
parseLoopNode(node) {
|
|
947
|
-
|
|
946
|
+
this.tokenizer.nextToken();
|
|
947
|
+
const collection = this.parsePropertyValue();
|
|
948
948
|
this.tokenizer.nextToken();
|
|
949
949
|
const itemToken = this.tokenizer.nextToken();
|
|
950
950
|
const isDestruct = itemToken.type === TokenType.InsertionExp;
|
|
951
|
-
|
|
951
|
+
if (isDestruct) {
|
|
952
|
+
itemToken.value = '{' + itemToken.value + '}';
|
|
953
|
+
}
|
|
954
|
+
const item = this.parsePropertyValue();
|
|
952
955
|
let char = this.tokenizer.peekChar(),
|
|
953
956
|
key,
|
|
954
957
|
index;
|
|
955
958
|
if (char === ';') {
|
|
956
959
|
this.tokenizer.nextToken();
|
|
957
|
-
if (this.tokenizer.peekChar() !== '\n')
|
|
960
|
+
if (this.tokenizer.peekChar() !== '\n') {
|
|
961
|
+
this.tokenizer.jsExp();
|
|
962
|
+
key = this.parsePropertyValue();
|
|
963
|
+
}
|
|
958
964
|
} else if (char === '\n') ; else {
|
|
959
|
-
|
|
965
|
+
this.tokenizer.nextToken();
|
|
966
|
+
index = this.parsePropertyValue();
|
|
960
967
|
if (this.tokenizer.peekChar() === ';') {
|
|
961
968
|
this.tokenizer.nextToken();
|
|
962
|
-
if (this.tokenizer.peekChar() !== '\n')
|
|
969
|
+
if (this.tokenizer.peekChar() !== '\n') {
|
|
970
|
+
this.tokenizer.jsExp();
|
|
971
|
+
key = this.parsePropertyValue();
|
|
972
|
+
}
|
|
963
973
|
}
|
|
964
974
|
}
|
|
965
975
|
this.tokenizer.nextToken();
|
|
@@ -1024,6 +1034,15 @@ class Compiler {
|
|
|
1024
1034
|
node.value = value;
|
|
1025
1035
|
return node;
|
|
1026
1036
|
}
|
|
1037
|
+
parseName(node) {
|
|
1038
|
+
const _this$tokenizer$_hook5 = this.tokenizer._hook({}),
|
|
1039
|
+
_this$tokenizer$_hook6 = _slicedToArray(_this$tokenizer$_hook5, 2),
|
|
1040
|
+
hookType = _this$tokenizer$_hook6[0],
|
|
1041
|
+
value = _this$tokenizer$_hook6[1];
|
|
1042
|
+
node.type = hookType === 'dynamic' ? NodeType.DynamicValue : NodeType.StaticValue;
|
|
1043
|
+
node.value = value;
|
|
1044
|
+
return node;
|
|
1045
|
+
}
|
|
1027
1046
|
}
|
|
1028
1047
|
function NodeLoc(target, context) {
|
|
1029
1048
|
return function (_node) {
|