vsn 0.1.27 → 0.1.30

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.
Files changed (244) hide show
  1. package/demo/vsn.js +1 -1
  2. package/dist/AST/ArithmeticAssignmentNode.d.ts +23 -0
  3. package/dist/AST/ArithmeticAssignmentNode.js +324 -0
  4. package/dist/AST/ArithmeticAssignmentNode.js.map +1 -0
  5. package/dist/AST/ArithmeticNode.d.ts +15 -0
  6. package/dist/AST/ArithmeticNode.js +114 -0
  7. package/dist/AST/ArithmeticNode.js.map +1 -0
  8. package/dist/AST/ArrayNode.d.ts +14 -0
  9. package/dist/AST/ArrayNode.js +114 -0
  10. package/dist/AST/ArrayNode.js.map +1 -0
  11. package/dist/AST/BlockNode.d.ts +11 -0
  12. package/dist/AST/BlockNode.js +98 -0
  13. package/dist/AST/BlockNode.js.map +1 -0
  14. package/dist/AST/BooleanLiteralNode.d.ts +5 -0
  15. package/dist/{Model/Collection.js → AST/BooleanLiteralNode.js} +12 -18
  16. package/dist/AST/BooleanLiteralNode.js.map +1 -0
  17. package/dist/AST/ComparisonNode.d.ts +15 -0
  18. package/dist/AST/ComparisonNode.js +120 -0
  19. package/dist/AST/ComparisonNode.js.map +1 -0
  20. package/dist/AST/ConditionalNode.d.ts +13 -0
  21. package/dist/AST/ConditionalNode.js +95 -0
  22. package/dist/AST/ConditionalNode.js.map +1 -0
  23. package/dist/AST/ElementAttributeNode.d.ts +18 -0
  24. package/dist/AST/ElementAttributeNode.js +159 -0
  25. package/dist/AST/ElementAttributeNode.js.map +1 -0
  26. package/dist/AST/ElementQueryNode.d.ts +13 -0
  27. package/dist/AST/ElementQueryNode.js +116 -0
  28. package/dist/AST/ElementQueryNode.js.map +1 -0
  29. package/dist/AST/ElementStyleNode.d.ts +18 -0
  30. package/dist/AST/ElementStyleNode.js +159 -0
  31. package/dist/AST/ElementStyleNode.js.map +1 -0
  32. package/dist/AST/ForStatementNode.d.ts +17 -0
  33. package/dist/AST/ForStatementNode.js +121 -0
  34. package/dist/AST/ForStatementNode.js.map +1 -0
  35. package/dist/AST/FunctionArgumentNode.d.ts +11 -0
  36. package/dist/AST/FunctionArgumentNode.js +100 -0
  37. package/dist/AST/FunctionArgumentNode.js.map +1 -0
  38. package/dist/AST/FunctionCallNode.d.ts +13 -0
  39. package/dist/AST/FunctionCallNode.js +102 -0
  40. package/dist/AST/FunctionCallNode.js.map +1 -0
  41. package/dist/AST/IfStatementNode.d.ts +14 -0
  42. package/dist/AST/IfStatementNode.js +128 -0
  43. package/dist/AST/IfStatementNode.js.map +1 -0
  44. package/dist/AST/InNode.d.ts +15 -0
  45. package/dist/AST/InNode.js +107 -0
  46. package/dist/AST/InNode.js.map +1 -0
  47. package/dist/AST/IndexNode.d.ts +16 -0
  48. package/dist/AST/IndexNode.js +126 -0
  49. package/dist/AST/IndexNode.js.map +1 -0
  50. package/dist/AST/LiteralNode.d.ts +10 -0
  51. package/dist/AST/LiteralNode.js +74 -0
  52. package/dist/AST/LiteralNode.js.map +1 -0
  53. package/dist/AST/Node.d.ts +19 -0
  54. package/dist/AST/Node.js +117 -0
  55. package/dist/AST/Node.js.map +1 -0
  56. package/dist/AST/NotNode.d.ts +12 -0
  57. package/dist/AST/NotNode.js +103 -0
  58. package/dist/AST/NotNode.js.map +1 -0
  59. package/dist/AST/NumberLiteralNode.d.ts +5 -0
  60. package/dist/{Model/fields/EmailField.js → AST/NumberLiteralNode.js} +17 -17
  61. package/dist/AST/NumberLiteralNode.js.map +1 -0
  62. package/dist/AST/ObjectNode.d.ts +14 -0
  63. package/dist/AST/ObjectNode.js +131 -0
  64. package/dist/AST/ObjectNode.js.map +1 -0
  65. package/dist/AST/RootScopeMemberNode.d.ts +11 -0
  66. package/dist/AST/RootScopeMemberNode.js +87 -0
  67. package/dist/AST/RootScopeMemberNode.js.map +1 -0
  68. package/dist/AST/ScopeMemberNode.d.ts +12 -0
  69. package/dist/AST/ScopeMemberNode.js +134 -0
  70. package/dist/AST/ScopeMemberNode.js.map +1 -0
  71. package/dist/AST/UnitLiteralNode.d.ts +15 -0
  72. package/dist/AST/UnitLiteralNode.js +72 -0
  73. package/dist/AST/UnitLiteralNode.js.map +1 -0
  74. package/dist/AST.d.ts +7 -60
  75. package/dist/AST.js +74 -1493
  76. package/dist/AST.js.map +1 -1
  77. package/dist/Controller.d.ts +4 -2
  78. package/dist/Controller.js +10 -2
  79. package/dist/Controller.js.map +1 -1
  80. package/dist/EventDispatcher.d.ts +4 -1
  81. package/dist/EventDispatcher.js +27 -12
  82. package/dist/EventDispatcher.js.map +1 -1
  83. package/dist/MessageList.d.ts +2 -1
  84. package/dist/MessageList.js +9 -1
  85. package/dist/MessageList.js.map +1 -1
  86. package/dist/Model/Field.d.ts +8 -0
  87. package/dist/Model/{fields/StringField.js → Field.js} +19 -24
  88. package/dist/Model/Field.js.map +1 -0
  89. package/dist/Model.d.ts +5 -4
  90. package/dist/Model.js +7 -18
  91. package/dist/Model.js.map +1 -1
  92. package/dist/Registry.d.ts +3 -0
  93. package/dist/Registry.js +11 -0
  94. package/dist/Registry.js.map +1 -1
  95. package/dist/Scope/DynamicScopeData.d.ts +6 -0
  96. package/dist/{Model/DataModel.js → Scope/DynamicScopeData.js} +15 -17
  97. package/dist/Scope/DynamicScopeData.js.map +1 -0
  98. package/dist/Scope/QueryReference.d.ts +10 -0
  99. package/dist/Scope/QueryReference.js +103 -0
  100. package/dist/Scope/QueryReference.js.map +1 -0
  101. package/dist/Scope/ScopeData.d.ts +4 -0
  102. package/dist/Scope/ScopeData.js +40 -0
  103. package/dist/Scope/ScopeData.js.map +1 -0
  104. package/dist/Scope/ScopeDataAbstract.d.ts +22 -0
  105. package/dist/Scope/ScopeDataAbstract.js +138 -0
  106. package/dist/Scope/ScopeDataAbstract.js.map +1 -0
  107. package/dist/Scope/ScopeReference.d.ts +10 -0
  108. package/dist/Scope/ScopeReference.js +73 -0
  109. package/dist/Scope/ScopeReference.js.map +1 -0
  110. package/dist/Scope/ScopedVariableType.d.ts +6 -0
  111. package/dist/Scope/ScopedVariableType.js +14 -0
  112. package/dist/Scope/ScopedVariableType.js.map +1 -0
  113. package/dist/Scope/WrappedArray.d.ts +16 -0
  114. package/dist/Scope/WrappedArray.js +121 -0
  115. package/dist/Scope/WrappedArray.js.map +1 -0
  116. package/dist/Scope/properties/Property.d.ts +18 -0
  117. package/dist/Scope/properties/Property.js +93 -0
  118. package/dist/Scope/properties/Property.js.map +1 -0
  119. package/dist/Scope.d.ts +4 -45
  120. package/dist/Scope.js +31 -266
  121. package/dist/Scope.js.map +1 -1
  122. package/dist/SimplePromise.d.ts +2 -2
  123. package/dist/SimplePromise.js.map +1 -1
  124. package/dist/Tag/List.d.ts +2 -2
  125. package/dist/Tag/List.js +14 -6
  126. package/dist/Tag/List.js.map +1 -1
  127. package/dist/Tag.js +1 -1
  128. package/dist/Tag.js.map +1 -1
  129. package/dist/Types.d.ts +1 -0
  130. package/dist/Types.js +8 -2
  131. package/dist/Types.js.map +1 -1
  132. package/dist/Validators.d.ts +7 -0
  133. package/dist/Validators.js +54 -0
  134. package/dist/Validators.js.map +1 -0
  135. package/dist/attributes/Bind.js +1 -1
  136. package/dist/attributes/Bind.js.map +1 -1
  137. package/dist/attributes/ClassConstructor.d.ts +1 -0
  138. package/dist/attributes/ClassConstructor.js +1 -1
  139. package/dist/attributes/ClassConstructor.js.map +1 -1
  140. package/dist/attributes/JSONAttribute.js.map +1 -1
  141. package/dist/attributes/List.js +4 -4
  142. package/dist/attributes/List.js.map +1 -1
  143. package/dist/attributes/Radio.js.map +1 -1
  144. package/dist/attributes/SetAttribute.js.map +1 -1
  145. package/dist/attributes/StyleAttribute.js.map +1 -1
  146. package/dist/vsn.d.ts +9 -1
  147. package/dist/vsn.js +24 -9
  148. package/dist/vsn.js.map +1 -1
  149. package/package.json +1 -1
  150. package/src/AST/ArithmeticAssignmentNode.ts +243 -0
  151. package/src/AST/ArithmeticNode.ts +52 -0
  152. package/src/AST/ArrayNode.ts +39 -0
  153. package/src/AST/BlockNode.ts +25 -0
  154. package/src/AST/BooleanLiteralNode.ts +10 -0
  155. package/src/AST/ComparisonNode.ts +57 -0
  156. package/src/AST/ConditionalNode.ts +36 -0
  157. package/src/AST/ElementAttributeNode.ts +63 -0
  158. package/src/AST/ElementQueryNode.ts +27 -0
  159. package/src/AST/ElementStyleNode.ts +63 -0
  160. package/src/AST/ForStatementNode.ts +59 -0
  161. package/src/AST/FunctionArgumentNode.ts +27 -0
  162. package/src/AST/FunctionCallNode.ts +32 -0
  163. package/src/AST/IfStatementNode.ts +67 -0
  164. package/src/AST/InNode.ts +46 -0
  165. package/src/AST/IndexNode.ts +61 -0
  166. package/src/AST/LiteralNode.ts +17 -0
  167. package/src/AST/Node.ts +71 -0
  168. package/src/AST/NotNode.ts +41 -0
  169. package/src/AST/NumberLiteralNode.ts +14 -0
  170. package/src/AST/ObjectNode.ts +55 -0
  171. package/src/AST/RootScopeMemberNode.ts +25 -0
  172. package/src/AST/ScopeMemberNode.ts +58 -0
  173. package/src/AST/UnitLiteralNode.ts +51 -0
  174. package/src/AST.ts +34 -1094
  175. package/src/Controller.ts +10 -2
  176. package/src/EventDispatcher.ts +29 -12
  177. package/src/MessageList.ts +5 -1
  178. package/src/Model/Field.ts +20 -0
  179. package/src/Model.ts +8 -22
  180. package/src/Registry.ts +10 -0
  181. package/src/{Model/DataModel.ts → Scope/DynamicScopeData.ts} +8 -10
  182. package/src/Scope/QueryReference.ts +29 -0
  183. package/src/Scope/ScopeData.ts +21 -0
  184. package/src/Scope/ScopeDataAbstract.ts +127 -0
  185. package/src/Scope/ScopeReference.ts +30 -0
  186. package/src/Scope/ScopedVariableType.ts +7 -0
  187. package/src/Scope/WrappedArray.ts +88 -0
  188. package/src/Scope/properties/Property.ts +79 -0
  189. package/src/Scope.ts +28 -194
  190. package/src/SimplePromise.ts +2 -2
  191. package/src/Tag/List.ts +4 -4
  192. package/src/Tag.ts +1 -1
  193. package/src/Types.ts +7 -2
  194. package/src/Validators.ts +45 -0
  195. package/src/attributes/Bind.ts +3 -3
  196. package/src/attributes/ClassConstructor.ts +2 -1
  197. package/src/attributes/JSONAttribute.ts +2 -1
  198. package/src/attributes/List.ts +1 -1
  199. package/src/attributes/Radio.ts +2 -1
  200. package/src/attributes/ScopeChange.ts +1 -1
  201. package/src/attributes/SetAttribute.ts +2 -1
  202. package/src/attributes/StyleAttribute.ts +2 -1
  203. package/src/attributes/TypeAttribute.ts +1 -1
  204. package/src/vsn.ts +14 -4
  205. package/test/AST/ArithmeticAssignmentNode.spec.ts +47 -0
  206. package/test/AST.spec.ts +2 -2
  207. package/test/Controller.spec.ts +44 -0
  208. package/test/MessageList.spec.ts +1 -1
  209. package/test/Model/DataModel.spec.ts +0 -141
  210. package/test/Scope/DynamicScopeData.spec.ts +141 -0
  211. package/test/Scope.spec.ts +13 -1
  212. package/test/Tag/TagList.spec.ts +1 -1
  213. package/dist/Model/Collection.d.ts +0 -5
  214. package/dist/Model/Collection.js.map +0 -1
  215. package/dist/Model/DataModel.d.ts +0 -6
  216. package/dist/Model/DataModel.js.map +0 -1
  217. package/dist/Model/ModelAbstract.d.ts +0 -20
  218. package/dist/Model/ModelAbstract.js +0 -122
  219. package/dist/Model/ModelAbstract.js.map +0 -1
  220. package/dist/Model/fields/BooleanField.d.ts +0 -5
  221. package/dist/Model/fields/BooleanField.js +0 -43
  222. package/dist/Model/fields/BooleanField.js.map +0 -1
  223. package/dist/Model/fields/EmailField.d.ts +0 -5
  224. package/dist/Model/fields/EmailField.js.map +0 -1
  225. package/dist/Model/fields/Field.d.ts +0 -13
  226. package/dist/Model/fields/Field.js +0 -79
  227. package/dist/Model/fields/Field.js.map +0 -1
  228. package/dist/Model/fields/FloatField.d.ts +0 -5
  229. package/dist/Model/fields/FloatField.js +0 -47
  230. package/dist/Model/fields/FloatField.js.map +0 -1
  231. package/dist/Model/fields/PositiveNumberField.d.ts +0 -5
  232. package/dist/Model/fields/PositiveNumberField.js +0 -51
  233. package/dist/Model/fields/PositiveNumberField.js.map +0 -1
  234. package/dist/Model/fields/StringField.d.ts +0 -5
  235. package/dist/Model/fields/StringField.js.map +0 -1
  236. package/src/Model/Collection.ts +0 -13
  237. package/src/Model/ModelAbstract.ts +0 -114
  238. package/src/Model/fields/BooleanField.ts +0 -16
  239. package/src/Model/fields/EmailField.ts +0 -12
  240. package/src/Model/fields/Field.ts +0 -65
  241. package/src/Model/fields/FloatField.ts +0 -22
  242. package/src/Model/fields/PositiveNumberField.ts +0 -24
  243. package/src/Model/fields/StringField.ts +0 -16
  244. package/test/Model.spec.ts +0 -306
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
54
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
55
+ to[j] = from[i];
56
+ return to;
57
+ };
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.BlockNode = void 0;
60
+ var Node_1 = require("./Node");
61
+ var BlockNode = /** @class */ (function (_super) {
62
+ __extends(BlockNode, _super);
63
+ function BlockNode(statements) {
64
+ var _this = _super.call(this) || this;
65
+ _this.statements = statements;
66
+ return _this;
67
+ }
68
+ BlockNode.prototype._getChildNodes = function () {
69
+ return __spreadArray([], this.statements);
70
+ };
71
+ BlockNode.prototype.evaluate = function (scope, dom, tag) {
72
+ if (tag === void 0) { tag = null; }
73
+ return __awaiter(this, void 0, void 0, function () {
74
+ var returnValue, i;
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
77
+ case 0:
78
+ returnValue = null;
79
+ i = 0;
80
+ _a.label = 1;
81
+ case 1:
82
+ if (!(i < this.statements.length)) return [3 /*break*/, 4];
83
+ return [4 /*yield*/, this.statements[i].evaluate(scope, dom, tag)];
84
+ case 2:
85
+ returnValue = _a.sent();
86
+ _a.label = 3;
87
+ case 3:
88
+ i++;
89
+ return [3 /*break*/, 1];
90
+ case 4: return [2 /*return*/, returnValue];
91
+ }
92
+ });
93
+ });
94
+ };
95
+ return BlockNode;
96
+ }(Node_1.Node));
97
+ exports.BlockNode = BlockNode;
98
+ //# sourceMappingURL=BlockNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockNode.js","sourceRoot":"","sources":["../../src/AST/BlockNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,+BAA4B;AAE5B;IAA+B,6BAAI;IAC/B,mBACoB,UAAkB;QADtC,YAGI,iBAAO,SACV;QAHmB,gBAAU,GAAV,UAAU,CAAQ;;IAGtC,CAAC;IAES,kCAAc,GAAxB;QACI,yBAAY,IAAI,CAAC,UAAqB,EAAE;IAC5C,CAAC;IAEY,4BAAQ,GAArB,UAAsB,KAAY,EAAE,GAAQ,EAAE,GAAe;QAAf,oBAAA,EAAA,UAAe;;;;;;wBACrD,WAAW,GAAQ,IAAI,CAAC;wBACnB,CAAC,GAAG,CAAC;;;6BAAE,CAAA,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAA;wBACxB,qBAAM,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAA;;wBAAhE,WAAW,GAAG,SAAkD,CAAC;;;wBADzB,CAAC,EAAE,CAAA;;4BAG/C,sBAAO,WAAW,EAAC;;;;KACtB;IACL,gBAAC;AAAD,CAAC,AAlBD,CAA+B,WAAI,GAkBlC;AAlBY,8BAAS"}
@@ -0,0 +1,5 @@
1
+ import { LiteralNode } from "./LiteralNode";
2
+ export declare class BooleanLiteralNode extends LiteralNode<number> {
3
+ readonly value: any;
4
+ constructor(value: any);
5
+ }
@@ -15,23 +15,17 @@ var __extends = (this && this.__extends) || (function () {
15
15
  };
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.Collection = void 0;
19
- var Collection = /** @class */ (function (_super) {
20
- __extends(Collection, _super);
21
- function Collection() {
22
- var _this = _super !== null && _super.apply(this, arguments) || this;
23
- _this.getData = function () {
24
- // Returns an array of data from all of the models in the collection
25
- var data = [];
26
- for (var _i = 0, _a = _this; _i < _a.length; _i++) {
27
- var item = _a[_i];
28
- data.push(item.getData());
29
- }
30
- return data;
31
- };
18
+ exports.BooleanLiteralNode = void 0;
19
+ var LiteralNode_1 = require("./LiteralNode");
20
+ var BooleanLiteralNode = /** @class */ (function (_super) {
21
+ __extends(BooleanLiteralNode, _super);
22
+ function BooleanLiteralNode(value) {
23
+ var _this = _super.call(this, value) || this;
24
+ _this.value = value;
25
+ _this.value = value === 'true';
32
26
  return _this;
33
27
  }
34
- return Collection;
35
- }(Array));
36
- exports.Collection = Collection;
37
- //# sourceMappingURL=Collection.js.map
28
+ return BooleanLiteralNode;
29
+ }(LiteralNode_1.LiteralNode));
30
+ exports.BooleanLiteralNode = BooleanLiteralNode;
31
+ //# sourceMappingURL=BooleanLiteralNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BooleanLiteralNode.js","sourceRoot":"","sources":["../../src/AST/BooleanLiteralNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6CAA0C;AAE1C;IAAwC,sCAAmB;IACvD,4BACoB,KAAU;QAD9B,YAGI,kBAAM,KAAK,CAAC,SAEf;QAJmB,WAAK,GAAL,KAAK,CAAK;QAG1B,KAAI,CAAC,KAAK,GAAG,KAAK,KAAK,MAAM,CAAC;;IAClC,CAAC;IACL,yBAAC;AAAD,CAAC,AAPD,CAAwC,yBAAW,GAOlD;AAPY,gDAAkB"}
@@ -0,0 +1,15 @@
1
+ import { Scope } from "../Scope";
2
+ import { DOM } from "../DOM";
3
+ import { Tag } from "../Tag";
4
+ import { Token, TokenType, TreeNode } from "../AST";
5
+ import { Node } from "./Node";
6
+ export declare class ComparisonNode extends Node implements TreeNode {
7
+ readonly left: Node;
8
+ readonly right: Node;
9
+ readonly type: TokenType;
10
+ constructor(left: Node, right: Node, type: TokenType);
11
+ protected _getChildNodes(): Node[];
12
+ evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<boolean>;
13
+ static match(tokens: Token[]): boolean;
14
+ static parse(lastNode: any, token: any, tokens: Token[]): ComparisonNode;
15
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.ComparisonNode = void 0;
55
+ var AST_1 = require("../AST");
56
+ var Node_1 = require("./Node");
57
+ var ComparisonNode = /** @class */ (function (_super) {
58
+ __extends(ComparisonNode, _super);
59
+ function ComparisonNode(left, right, type) {
60
+ var _this = _super.call(this) || this;
61
+ _this.left = left;
62
+ _this.right = right;
63
+ _this.type = type;
64
+ return _this;
65
+ }
66
+ ComparisonNode.prototype._getChildNodes = function () {
67
+ return [
68
+ this.left,
69
+ this.right
70
+ ];
71
+ };
72
+ ComparisonNode.prototype.evaluate = function (scope, dom, tag) {
73
+ if (tag === void 0) { tag = null; }
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var left, right;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0: return [4 /*yield*/, this.left.evaluate(scope, dom, tag)];
79
+ case 1:
80
+ left = _a.sent();
81
+ return [4 /*yield*/, this.right.evaluate(scope, dom, tag)];
82
+ case 2:
83
+ right = _a.sent();
84
+ switch (this.type) {
85
+ case AST_1.TokenType.EQUALS:
86
+ return [2 /*return*/, left === right];
87
+ case AST_1.TokenType.NOT_EQUALS:
88
+ return [2 /*return*/, left !== right];
89
+ case AST_1.TokenType.GREATER_THAN:
90
+ return [2 /*return*/, left > right];
91
+ case AST_1.TokenType.LESS_THAN:
92
+ return [2 /*return*/, left < right];
93
+ case AST_1.TokenType.GREATER_THAN_EQUAL:
94
+ return [2 /*return*/, left >= right];
95
+ case AST_1.TokenType.LESS_THAN_EQUAL:
96
+ return [2 /*return*/, left <= right];
97
+ }
98
+ return [2 /*return*/];
99
+ }
100
+ });
101
+ });
102
+ };
103
+ ComparisonNode.match = function (tokens) {
104
+ return [
105
+ AST_1.TokenType.EQUALS,
106
+ AST_1.TokenType.NOT_EQUALS,
107
+ AST_1.TokenType.GREATER_THAN,
108
+ AST_1.TokenType.LESS_THAN,
109
+ AST_1.TokenType.GREATER_THAN_EQUAL,
110
+ AST_1.TokenType.LESS_THAN_EQUAL
111
+ ].indexOf(tokens[0].type) > -1;
112
+ };
113
+ ComparisonNode.parse = function (lastNode, token, tokens) {
114
+ tokens.splice(0, 1); // Remove comparison operator
115
+ return new ComparisonNode(lastNode, AST_1.Tree.processTokens(AST_1.Tree.getNextStatementTokens(tokens)), token.type);
116
+ };
117
+ return ComparisonNode;
118
+ }(Node_1.Node));
119
+ exports.ComparisonNode = ComparisonNode;
120
+ //# sourceMappingURL=ComparisonNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComparisonNode.js","sourceRoot":"","sources":["../../src/AST/ComparisonNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,8BAAwD;AACxD,+BAA4B;AAE5B;IAAoC,kCAAI;IACpC,wBACoB,IAAU,EACV,KAAW,EACX,IAAe;QAHnC,YAKI,iBAAO,SACV;QALmB,UAAI,GAAJ,IAAI,CAAM;QACV,WAAK,GAAL,KAAK,CAAM;QACX,UAAI,GAAJ,IAAI,CAAW;;IAGnC,CAAC;IAES,uCAAc,GAAxB;QACI,OAAO;YACH,IAAI,CAAC,IAAY;YACjB,IAAI,CAAC,KAAa;SACrB,CAAC;IACN,CAAC;IAEY,iCAAQ,GAArB,UAAsB,KAAY,EAAE,GAAQ,EAAE,GAAe;QAAf,oBAAA,EAAA,UAAe;;;;;4BACvC,qBAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAA;;wBAArD,IAAI,GAAQ,SAAyC;wBACxC,qBAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAA;;wBAAvD,KAAK,GAAQ,SAA0C;wBAC7D,QAAQ,IAAI,CAAC,IAAI,EAAE;4BACf,KAAK,eAAS,CAAC,MAAM;gCACjB,sBAAO,IAAI,KAAK,KAAK,EAAC;4BAC1B,KAAK,eAAS,CAAC,UAAU;gCACrB,sBAAO,IAAI,KAAK,KAAK,EAAC;4BAC1B,KAAK,eAAS,CAAC,YAAY;gCACvB,sBAAO,IAAI,GAAG,KAAK,EAAC;4BACxB,KAAK,eAAS,CAAC,SAAS;gCACpB,sBAAO,IAAI,GAAG,KAAK,EAAC;4BACxB,KAAK,eAAS,CAAC,kBAAkB;gCAC7B,sBAAO,IAAI,IAAI,KAAK,EAAC;4BACzB,KAAK,eAAS,CAAC,eAAe;gCAC1B,sBAAO,IAAI,IAAI,KAAK,EAAC;yBAC5B;;;;;KACJ;IAEa,oBAAK,GAAnB,UAAoB,MAAe;QAC/B,OAAO;YACH,eAAS,CAAC,MAAM;YAChB,eAAS,CAAC,UAAU;YACpB,eAAS,CAAC,YAAY;YACtB,eAAS,CAAC,SAAS;YACnB,eAAS,CAAC,kBAAkB;YAC5B,eAAS,CAAC,eAAe;SAC5B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IAClC,CAAC;IAEa,oBAAK,GAAnB,UAAoB,QAAQ,EAAE,KAAK,EAAE,MAAe;QAChD,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,6BAA6B;QAClD,OAAO,IAAI,cAAc,CAAC,QAAQ,EAAE,UAAI,CAAC,aAAa,CAAC,UAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IAC5G,CAAC;IACL,qBAAC;AAAD,CAAC,AAlDD,CAAoC,WAAI,GAkDvC;AAlDY,wCAAc"}
@@ -0,0 +1,13 @@
1
+ import { Scope } from "../Scope";
2
+ import { DOM } from "../DOM";
3
+ import { Tag } from "../Tag";
4
+ import { TreeNode } from "../AST";
5
+ import { BlockNode } from "./BlockNode";
6
+ import { Node } from "./Node";
7
+ export declare class ConditionalNode extends Node implements TreeNode {
8
+ readonly condition: Node;
9
+ readonly block: BlockNode;
10
+ constructor(condition: Node, block: BlockNode);
11
+ protected _getChildNodes(): Node[];
12
+ evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<boolean>;
13
+ }
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.ConditionalNode = void 0;
55
+ var WrappedArray_1 = require("../Scope/WrappedArray");
56
+ var Node_1 = require("./Node");
57
+ var ConditionalNode = /** @class */ (function (_super) {
58
+ __extends(ConditionalNode, _super);
59
+ function ConditionalNode(condition, block) {
60
+ var _this = _super.call(this) || this;
61
+ _this.condition = condition;
62
+ _this.block = block;
63
+ return _this;
64
+ }
65
+ ConditionalNode.prototype._getChildNodes = function () {
66
+ return [
67
+ this.condition,
68
+ this.block
69
+ ];
70
+ };
71
+ ConditionalNode.prototype.evaluate = function (scope, dom, tag) {
72
+ if (tag === void 0) { tag = null; }
73
+ return __awaiter(this, void 0, void 0, function () {
74
+ var condition, evaluation;
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
77
+ case 0: return [4 /*yield*/, this.condition.evaluate(scope, dom, tag)];
78
+ case 1:
79
+ condition = _a.sent();
80
+ evaluation = false;
81
+ if (condition instanceof WrappedArray_1.WrappedArray) {
82
+ evaluation = condition.length > 0;
83
+ }
84
+ else {
85
+ evaluation = !!condition;
86
+ }
87
+ return [2 /*return*/, evaluation];
88
+ }
89
+ });
90
+ });
91
+ };
92
+ return ConditionalNode;
93
+ }(Node_1.Node));
94
+ exports.ConditionalNode = ConditionalNode;
95
+ //# sourceMappingURL=ConditionalNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionalNode.js","sourceRoot":"","sources":["../../src/AST/ConditionalNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sDAAmD;AAGnD,+BAA4B;AAE5B;IAAqC,mCAAI;IACrC,yBACoB,SAAe,EACf,KAAgB;QAFpC,YAII,iBAAO,SACV;QAJmB,eAAS,GAAT,SAAS,CAAM;QACf,WAAK,GAAL,KAAK,CAAW;;IAGpC,CAAC;IAES,wCAAc,GAAxB;QACI,OAAO;YACH,IAAI,CAAC,SAAiB;YACtB,IAAI,CAAC,KAAa;SACrB,CAAC;IACN,CAAC;IAEY,kCAAQ,GAArB,UAAsB,KAAY,EAAE,GAAQ,EAAE,GAAe;QAAf,oBAAA,EAAA,UAAe;;;;;4BACvC,qBAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAA;;wBAA1D,SAAS,GAAG,SAA8C;wBAC5D,UAAU,GAAG,KAAK,CAAC;wBAEvB,IAAI,SAAS,YAAY,2BAAY,EAAE;4BACnC,UAAU,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;yBACrC;6BAAM;4BACH,UAAU,GAAG,CAAC,CAAC,SAAS,CAAC;yBAC5B;wBAED,sBAAO,UAAU,EAAC;;;;KACrB;IACL,sBAAC;AAAD,CAAC,AA3BD,CAAqC,WAAI,GA2BxC;AA3BY,0CAAe"}
@@ -0,0 +1,18 @@
1
+ import { Scope } from "../Scope";
2
+ import { DOM } from "../DOM";
3
+ import { Tag } from "../Tag";
4
+ import { TreeNode } from "../AST";
5
+ import { Node } from "./Node";
6
+ import { ElementQueryNode } from "./ElementQueryNode";
7
+ import { LiteralNode } from "./LiteralNode";
8
+ export declare class ElementAttributeNode extends Node implements TreeNode {
9
+ readonly elementRef: ElementQueryNode | null;
10
+ readonly attr: string;
11
+ protected requiresPrep: boolean;
12
+ constructor(elementRef: ElementQueryNode | null, attr: string);
13
+ get name(): LiteralNode<string>;
14
+ protected _getChildNodes(): Node[];
15
+ get attributeName(): string;
16
+ evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<any>;
17
+ prepare(scope: Scope, dom: DOM, tag?: Tag): Promise<void>;
18
+ }
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.ElementAttributeNode = void 0;
55
+ var List_1 = require("../Tag/List");
56
+ var Node_1 = require("./Node");
57
+ var LiteralNode_1 = require("./LiteralNode");
58
+ var ElementAttributeNode = /** @class */ (function (_super) {
59
+ __extends(ElementAttributeNode, _super);
60
+ function ElementAttributeNode(elementRef, attr) {
61
+ var _this = _super.call(this) || this;
62
+ _this.elementRef = elementRef;
63
+ _this.attr = attr;
64
+ _this.requiresPrep = true;
65
+ return _this;
66
+ }
67
+ Object.defineProperty(ElementAttributeNode.prototype, "name", {
68
+ get: function () {
69
+ return new LiteralNode_1.LiteralNode("@" + this.attributeName);
70
+ },
71
+ enumerable: false,
72
+ configurable: true
73
+ });
74
+ ElementAttributeNode.prototype._getChildNodes = function () {
75
+ var nodes = [];
76
+ if (this.elementRef)
77
+ nodes.push(this.elementRef);
78
+ return nodes;
79
+ };
80
+ Object.defineProperty(ElementAttributeNode.prototype, "attributeName", {
81
+ get: function () {
82
+ if (this.attr.startsWith('.'))
83
+ return this.attr.substring(2);
84
+ return this.attr.substring(1);
85
+ },
86
+ enumerable: false,
87
+ configurable: true
88
+ });
89
+ ElementAttributeNode.prototype.evaluate = function (scope, dom, tag) {
90
+ if (tag === void 0) { tag = null; }
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ var tags;
93
+ var _this = this;
94
+ return __generator(this, function (_a) {
95
+ switch (_a.label) {
96
+ case 0:
97
+ if (!this.elementRef) return [3 /*break*/, 2];
98
+ return [4 /*yield*/, this.elementRef.evaluate(scope, dom, tag, true)];
99
+ case 1:
100
+ tags = _a.sent();
101
+ return [3 /*break*/, 3];
102
+ case 2:
103
+ if (tag) {
104
+ tags = new List_1.TagList(tag);
105
+ }
106
+ else {
107
+ return [2 /*return*/];
108
+ }
109
+ _a.label = 3;
110
+ case 3:
111
+ if (tags.length === 1)
112
+ return [2 /*return*/, tags[0].scope.get("@" + this.attributeName)];
113
+ return [2 /*return*/, tags.map(function (tag) { return tag.scope.get("@" + _this.attributeName); })];
114
+ }
115
+ });
116
+ });
117
+ };
118
+ ElementAttributeNode.prototype.prepare = function (scope, dom, tag) {
119
+ if (tag === void 0) { tag = null; }
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ var tags, _i, tags_1, t;
122
+ return __generator(this, function (_a) {
123
+ switch (_a.label) {
124
+ case 0:
125
+ if (!this.elementRef) return [3 /*break*/, 7];
126
+ return [4 /*yield*/, this.elementRef.prepare(scope, dom, tag)];
127
+ case 1:
128
+ _a.sent();
129
+ return [4 /*yield*/, this.elementRef.evaluate(scope, dom, tag, true)];
130
+ case 2:
131
+ tags = _a.sent();
132
+ _i = 0, tags_1 = tags;
133
+ _a.label = 3;
134
+ case 3:
135
+ if (!(_i < tags_1.length)) return [3 /*break*/, 6];
136
+ t = tags_1[_i];
137
+ return [4 /*yield*/, t.watchAttribute(this.attributeName)];
138
+ case 4:
139
+ _a.sent();
140
+ _a.label = 5;
141
+ case 5:
142
+ _i++;
143
+ return [3 /*break*/, 3];
144
+ case 6: return [3 /*break*/, 9];
145
+ case 7:
146
+ if (!tag) return [3 /*break*/, 9];
147
+ return [4 /*yield*/, tag.watchAttribute(this.attributeName)];
148
+ case 8:
149
+ _a.sent();
150
+ _a.label = 9;
151
+ case 9: return [2 /*return*/];
152
+ }
153
+ });
154
+ });
155
+ };
156
+ return ElementAttributeNode;
157
+ }(Node_1.Node));
158
+ exports.ElementAttributeNode = ElementAttributeNode;
159
+ //# sourceMappingURL=ElementAttributeNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementAttributeNode.js","sourceRoot":"","sources":["../../src/AST/ElementAttributeNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,oCAAoC;AAEpC,+BAA4B;AAE5B,6CAA0C;AAE1C;IAA0C,wCAAI;IAG1C,8BACoB,UAAmC,EACnC,IAAY;QAFhC,YAII,iBAAO,SACV;QAJmB,gBAAU,GAAV,UAAU,CAAyB;QACnC,UAAI,GAAJ,IAAI,CAAQ;QAJtB,kBAAY,GAAY,IAAI,CAAC;;IAOvC,CAAC;IAED,sBAAW,sCAAI;aAAf;YACI,OAAO,IAAI,yBAAW,CAAS,MAAI,IAAI,CAAC,aAAe,CAAC,CAAC;QAC7D,CAAC;;;OAAA;IAES,6CAAc,GAAxB;QACI,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,IAAI,CAAC,UAAU;YACf,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC/B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,sBAAI,+CAAa;aAAjB;YACI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;gBACzB,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAClC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;;;OAAA;IAEK,uCAAQ,GAAd,UAAe,KAAY,EAAE,GAAQ,EAAE,GAAe;QAAf,oBAAA,EAAA,UAAe;;;;;;;6BAE9C,IAAI,CAAC,UAAU,EAAf,wBAAe;wBACR,qBAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAA;;wBAA5D,IAAI,GAAG,SAAqD,CAAC;;;wBAC1D,IAAI,GAAG,EAAE;4BACZ,IAAI,GAAG,IAAI,cAAO,CAAC,GAAG,CAAC,CAAA;yBAC1B;6BAAM;4BACH,sBAAO;yBACV;;;wBAED,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;4BACjB,sBAAO,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,MAAI,IAAI,CAAC,aAAe,CAAC,EAAC;wBAEvD,sBAAO,IAAI,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAI,KAAI,CAAC,aAAe,CAAC,EAAvC,CAAuC,CAAC,EAAC;;;;KACrE;IAEK,sCAAO,GAAb,UAAc,KAAY,EAAE,GAAQ,EAAE,GAAe;QAAf,oBAAA,EAAA,UAAe;;;;;;6BAC7C,IAAI,CAAC,UAAU,EAAf,wBAAe;wBACf,qBAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAA;;wBAA9C,SAA8C,CAAC;wBACzB,qBAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAA;;wBAArE,IAAI,GAAY,SAAqD;8BACvD,EAAJ,aAAI;;;6BAAJ,CAAA,kBAAI,CAAA;wBAAT,CAAC;wBACR,qBAAM,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,EAAA;;wBAA1C,SAA0C,CAAC;;;wBAD/B,IAAI,CAAA;;;;6BAEd,GAAG,EAAH,wBAAG;wBACT,qBAAM,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,EAAA;;wBAA5C,SAA4C,CAAC;;;;;;KAEpD;IACL,2BAAC;AAAD,CAAC,AArDD,CAA0C,WAAI,GAqD7C;AArDY,oDAAoB"}
@@ -0,0 +1,13 @@
1
+ import { Scope } from "../Scope";
2
+ import { DOM } from "../DOM";
3
+ import { Tag } from "../Tag";
4
+ import { TreeNode } from "../AST";
5
+ import { Node } from "./Node";
6
+ export declare class ElementQueryNode extends Node implements TreeNode {
7
+ readonly query: string;
8
+ readonly first: boolean;
9
+ protected requiresPrep: boolean;
10
+ constructor(query: string, first?: boolean);
11
+ evaluate(scope: Scope, dom: DOM, tag?: Tag, forceList?: boolean): Promise<any>;
12
+ prepare(scope: Scope, dom: DOM, tag?: Tag): Promise<void>;
13
+ }