vsn 0.1.26 → 0.1.29
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/demo/vsn.js +1 -1
- package/dist/AST/ArithmeticAssignmentNode.d.ts +23 -0
- package/dist/AST/ArithmeticAssignmentNode.js +313 -0
- package/dist/AST/ArithmeticAssignmentNode.js.map +1 -0
- package/dist/AST/ArithmeticNode.d.ts +15 -0
- package/dist/AST/ArithmeticNode.js +114 -0
- package/dist/AST/ArithmeticNode.js.map +1 -0
- package/dist/AST/ArrayNode.d.ts +14 -0
- package/dist/AST/ArrayNode.js +114 -0
- package/dist/AST/ArrayNode.js.map +1 -0
- package/dist/AST/BlockNode.d.ts +11 -0
- package/dist/AST/BlockNode.js +98 -0
- package/dist/AST/BlockNode.js.map +1 -0
- package/dist/AST/BooleanLiteralNode.d.ts +5 -0
- package/dist/AST/BooleanLiteralNode.js +31 -0
- package/dist/AST/BooleanLiteralNode.js.map +1 -0
- package/dist/AST/ComparisonNode.d.ts +15 -0
- package/dist/AST/ComparisonNode.js +120 -0
- package/dist/AST/ComparisonNode.js.map +1 -0
- package/dist/AST/ConditionalNode.d.ts +13 -0
- package/dist/AST/ConditionalNode.js +95 -0
- package/dist/AST/ConditionalNode.js.map +1 -0
- package/dist/AST/ElementAttributeNode.d.ts +18 -0
- package/dist/AST/ElementAttributeNode.js +159 -0
- package/dist/AST/ElementAttributeNode.js.map +1 -0
- package/dist/AST/ElementQueryNode.d.ts +12 -0
- package/dist/AST/ElementQueryNode.js +111 -0
- package/dist/AST/ElementQueryNode.js.map +1 -0
- package/dist/AST/ElementStyleNode.d.ts +18 -0
- package/dist/AST/ElementStyleNode.js +159 -0
- package/dist/AST/ElementStyleNode.js.map +1 -0
- package/dist/AST/ForStatementNode.d.ts +17 -0
- package/dist/AST/ForStatementNode.js +121 -0
- package/dist/AST/ForStatementNode.js.map +1 -0
- package/dist/AST/FunctionArgumentNode.d.ts +11 -0
- package/dist/AST/FunctionArgumentNode.js +100 -0
- package/dist/AST/FunctionArgumentNode.js.map +1 -0
- package/dist/AST/FunctionCallNode.d.ts +13 -0
- package/dist/AST/FunctionCallNode.js +102 -0
- package/dist/AST/FunctionCallNode.js.map +1 -0
- package/dist/AST/IfStatementNode.d.ts +14 -0
- package/dist/AST/IfStatementNode.js +128 -0
- package/dist/AST/IfStatementNode.js.map +1 -0
- package/dist/AST/InNode.d.ts +15 -0
- package/dist/AST/InNode.js +107 -0
- package/dist/AST/InNode.js.map +1 -0
- package/dist/AST/IndexNode.d.ts +16 -0
- package/dist/AST/IndexNode.js +126 -0
- package/dist/AST/IndexNode.js.map +1 -0
- package/dist/AST/LiteralNode.d.ts +10 -0
- package/dist/AST/LiteralNode.js +74 -0
- package/dist/AST/LiteralNode.js.map +1 -0
- package/dist/AST/Node.d.ts +19 -0
- package/dist/AST/Node.js +117 -0
- package/dist/AST/Node.js.map +1 -0
- package/dist/AST/NotNode.d.ts +12 -0
- package/dist/AST/NotNode.js +103 -0
- package/dist/AST/NotNode.js.map +1 -0
- package/dist/AST/NumberLiteralNode.d.ts +5 -0
- package/dist/AST/NumberLiteralNode.js +36 -0
- package/dist/AST/NumberLiteralNode.js.map +1 -0
- package/dist/AST/ObjectNode.d.ts +14 -0
- package/dist/AST/ObjectNode.js +131 -0
- package/dist/AST/ObjectNode.js.map +1 -0
- package/dist/AST/RootScopeMemberNode.d.ts +11 -0
- package/dist/AST/RootScopeMemberNode.js +87 -0
- package/dist/AST/RootScopeMemberNode.js.map +1 -0
- package/dist/AST/ScopeMemberNode.d.ts +12 -0
- package/dist/AST/ScopeMemberNode.js +128 -0
- package/dist/AST/ScopeMemberNode.js.map +1 -0
- package/dist/AST/UnitLiteralNode.d.ts +15 -0
- package/dist/AST/UnitLiteralNode.js +72 -0
- package/dist/AST/UnitLiteralNode.js.map +1 -0
- package/dist/AST.d.ts +7 -60
- package/dist/AST.js +778 -0
- package/dist/AST.js.map +1 -0
- package/dist/Attribute.d.ts +1 -1
- package/dist/Attribute.js +187 -0
- package/dist/Attribute.js.map +1 -0
- package/dist/Bencmark.js +179 -0
- package/dist/Bencmark.js.map +1 -0
- package/dist/Configuration.d.ts +1 -1
- package/dist/Configuration.js +64 -0
- package/dist/Configuration.js.map +1 -0
- package/dist/Controller.d.ts +4 -2
- package/dist/Controller.js +62 -0
- package/dist/Controller.js.map +1 -0
- package/dist/DOM/DOMObject.d.ts +1 -1
- package/dist/DOM/DOMObject.js +47 -0
- package/dist/DOM/DOMObject.js.map +1 -0
- package/dist/DOM/WrappedDocument.js +34 -0
- package/dist/DOM/WrappedDocument.js.map +1 -0
- package/dist/DOM/WrappedWindow.js +45 -0
- package/dist/DOM/WrappedWindow.js.map +1 -0
- package/dist/DOM.d.ts +1 -1
- package/dist/DOM.js +547 -0
- package/dist/DOM.js.map +1 -0
- package/dist/EventDispatcher.d.ts +29 -0
- package/dist/EventDispatcher.js +132 -0
- package/dist/EventDispatcher.js.map +1 -0
- package/dist/Formats.js +44 -0
- package/dist/Formats.js.map +1 -0
- package/dist/MessageList.d.ts +15 -0
- package/dist/MessageList.js +96 -0
- package/dist/MessageList.js.map +1 -0
- package/dist/Model/Field.d.ts +8 -0
- package/dist/Model/Field.js +38 -0
- package/dist/Model/Field.js.map +1 -0
- package/dist/Model.d.ts +12 -0
- package/dist/Model.js +61 -0
- package/dist/Model.js.map +1 -0
- package/dist/Query.js +66 -0
- package/dist/Query.js.map +1 -0
- package/dist/Registry.d.ts +5 -2
- package/dist/Registry.js +139 -0
- package/dist/Registry.js.map +1 -0
- package/dist/Scope/DynamicScopeData.d.ts +6 -0
- package/dist/Scope/DynamicScopeData.js +54 -0
- package/dist/Scope/DynamicScopeData.js.map +1 -0
- package/dist/Scope/QueryReference.d.ts +10 -0
- package/dist/Scope/QueryReference.js +103 -0
- package/dist/Scope/QueryReference.js.map +1 -0
- package/dist/Scope/ScopeData.d.ts +4 -0
- package/dist/Scope/ScopeData.js +40 -0
- package/dist/Scope/ScopeData.js.map +1 -0
- package/dist/Scope/ScopeDataAbstract.d.ts +22 -0
- package/dist/Scope/ScopeDataAbstract.js +137 -0
- package/dist/Scope/ScopeDataAbstract.js.map +1 -0
- package/dist/Scope/ScopeReference.d.ts +10 -0
- package/dist/Scope/ScopeReference.js +73 -0
- package/dist/Scope/ScopeReference.js.map +1 -0
- package/dist/Scope/ScopedVariableType.d.ts +6 -0
- package/dist/Scope/ScopedVariableType.js +14 -0
- package/dist/Scope/ScopedVariableType.js.map +1 -0
- package/dist/Scope/WrappedArray.d.ts +16 -0
- package/dist/Scope/WrappedArray.js +121 -0
- package/dist/Scope/WrappedArray.js.map +1 -0
- package/dist/Scope/properties/Property.d.ts +18 -0
- package/dist/Scope/properties/Property.js +93 -0
- package/dist/Scope/properties/Property.js.map +1 -0
- package/dist/Scope.d.ts +4 -48
- package/dist/Scope.js +227 -0
- package/dist/Scope.js.map +1 -0
- package/dist/SimplePromise.d.ts +42 -0
- package/dist/SimplePromise.js +217 -0
- package/dist/SimplePromise.js.map +1 -0
- package/dist/Tag/List.js +85 -0
- package/dist/Tag/List.js.map +1 -0
- package/dist/Tag.js +770 -0
- package/dist/Tag.js.map +1 -0
- package/dist/Types.d.ts +1 -0
- package/dist/Types.js +54 -0
- package/dist/Types.js.map +1 -0
- package/dist/Validators.d.ts +7 -0
- package/dist/Validators.js +54 -0
- package/dist/Validators.js.map +1 -0
- package/dist/attributes/AddClassIf.js +93 -0
- package/dist/attributes/AddClassIf.js.map +1 -0
- package/dist/attributes/Bind.js +272 -0
- package/dist/attributes/Bind.js.map +1 -0
- package/dist/attributes/ClassConstructor.d.ts +1 -0
- package/dist/attributes/ClassConstructor.js +104 -0
- package/dist/attributes/ClassConstructor.js.map +1 -0
- package/dist/attributes/ClickRemoveClass.js +114 -0
- package/dist/attributes/ClickRemoveClass.js.map +1 -0
- package/dist/attributes/ClickToggleClass.js +114 -0
- package/dist/attributes/ClickToggleClass.js.map +1 -0
- package/dist/attributes/ControllerAttribute.js +28 -0
- package/dist/attributes/ControllerAttribute.js.map +1 -0
- package/dist/attributes/DisableIf.js +94 -0
- package/dist/attributes/DisableIf.js.map +1 -0
- package/dist/attributes/Exec.js +108 -0
- package/dist/attributes/Exec.js.map +1 -0
- package/dist/attributes/Format.js +99 -0
- package/dist/attributes/Format.js.map +1 -0
- package/dist/attributes/If.js +159 -0
- package/dist/attributes/If.js.map +1 -0
- package/dist/attributes/JSONAttribute.js +118 -0
- package/dist/attributes/JSONAttribute.js.map +1 -0
- package/dist/attributes/KeyAbstract.js +117 -0
- package/dist/attributes/KeyAbstract.js.map +1 -0
- package/dist/attributes/KeyDown.js +88 -0
- package/dist/attributes/KeyDown.js.map +1 -0
- package/dist/attributes/KeyUp.js +88 -0
- package/dist/attributes/KeyUp.js.map +1 -0
- package/dist/attributes/List.js +282 -0
- package/dist/attributes/List.js.map +1 -0
- package/dist/attributes/ListItem.js +138 -0
- package/dist/attributes/ListItem.js.map +1 -0
- package/dist/attributes/ListItemModel.js +39 -0
- package/dist/attributes/ListItemModel.js.map +1 -0
- package/dist/attributes/ModelAttribute.js +29 -0
- package/dist/attributes/ModelAttribute.js.map +1 -0
- package/dist/attributes/Name.js +88 -0
- package/dist/attributes/Name.js.map +1 -0
- package/dist/attributes/On.js +135 -0
- package/dist/attributes/On.js.map +1 -0
- package/dist/attributes/Radio.js +174 -0
- package/dist/attributes/Radio.js.map +1 -0
- package/dist/attributes/Referenced.js +38 -0
- package/dist/attributes/Referenced.js.map +1 -0
- package/dist/attributes/RootAttribute.js +91 -0
- package/dist/attributes/RootAttribute.js.map +1 -0
- package/dist/attributes/ScopeAttribute.js +40 -0
- package/dist/attributes/ScopeAttribute.js.map +1 -0
- package/dist/attributes/ScopeChange.js +130 -0
- package/dist/attributes/ScopeChange.js.map +1 -0
- package/dist/attributes/SetAttribute.js +133 -0
- package/dist/attributes/SetAttribute.js.map +1 -0
- package/dist/attributes/StandardAttribute.js +186 -0
- package/dist/attributes/StandardAttribute.js.map +1 -0
- package/dist/attributes/StyleAttribute.js +183 -0
- package/dist/attributes/StyleAttribute.js.map +1 -0
- package/dist/attributes/Template.js +39 -0
- package/dist/attributes/Template.js.map +1 -0
- package/dist/attributes/TypeAttribute.js +104 -0
- package/dist/attributes/TypeAttribute.js.map +1 -0
- package/dist/attributes/_imports.js +60 -0
- package/dist/attributes/_imports.js.map +1 -0
- package/dist/helpers/DOMHelper.js +81 -0
- package/dist/helpers/DOMHelper.js.map +1 -0
- package/dist/helpers/ElementHelper.js +25 -0
- package/dist/helpers/ElementHelper.js.map +1 -0
- package/dist/helpers/VisionHelper.js +71 -0
- package/dist/helpers/VisionHelper.js.map +1 -0
- package/dist/helpers/decorators.js +38 -0
- package/dist/helpers/decorators.js.map +1 -0
- package/dist/vsn.d.ts +11 -2
- package/dist/vsn.js +181 -0
- package/dist/vsn.js.map +1 -0
- package/package.json +2 -6
- package/src/AST/ArithmeticAssignmentNode.ts +236 -0
- package/src/AST/ArithmeticNode.ts +52 -0
- package/src/AST/ArrayNode.ts +39 -0
- package/src/AST/BlockNode.ts +25 -0
- package/src/AST/BooleanLiteralNode.ts +10 -0
- package/src/AST/ComparisonNode.ts +57 -0
- package/src/AST/ConditionalNode.ts +36 -0
- package/src/AST/ElementAttributeNode.ts +63 -0
- package/src/AST/ElementQueryNode.ts +25 -0
- package/src/AST/ElementStyleNode.ts +63 -0
- package/src/AST/ForStatementNode.ts +59 -0
- package/src/AST/FunctionArgumentNode.ts +27 -0
- package/src/AST/FunctionCallNode.ts +32 -0
- package/src/AST/IfStatementNode.ts +67 -0
- package/src/AST/InNode.ts +46 -0
- package/src/AST/IndexNode.ts +61 -0
- package/src/AST/LiteralNode.ts +17 -0
- package/src/AST/Node.ts +71 -0
- package/src/AST/NotNode.ts +41 -0
- package/src/AST/NumberLiteralNode.ts +14 -0
- package/src/AST/ObjectNode.ts +55 -0
- package/src/AST/RootScopeMemberNode.ts +25 -0
- package/src/AST/ScopeMemberNode.ts +53 -0
- package/src/AST/UnitLiteralNode.ts +51 -0
- package/src/AST.ts +34 -1094
- package/src/Attribute.ts +2 -2
- package/src/Configuration.ts +3 -3
- package/src/Controller.ts +10 -2
- package/src/DOM/DOMObject.ts +1 -1
- package/src/DOM.ts +3 -3
- package/src/EventDispatcher.ts +134 -0
- package/src/Formats.ts +2 -2
- package/src/MessageList.ts +85 -0
- package/src/Model/Field.ts +20 -0
- package/src/Model.ts +43 -0
- package/src/Registry.ts +13 -3
- package/src/Scope/DynamicScopeData.ts +29 -0
- package/src/Scope/QueryReference.ts +29 -0
- package/src/Scope/ScopeData.ts +21 -0
- package/src/Scope/ScopeDataAbstract.ts +126 -0
- package/src/Scope/ScopeReference.ts +30 -0
- package/src/Scope/ScopedVariableType.ts +7 -0
- package/src/Scope/WrappedArray.ts +88 -0
- package/src/Scope/properties/Property.ts +79 -0
- package/src/Scope.ts +31 -252
- package/src/SimplePromise.ts +219 -0
- package/src/Tag.ts +3 -3
- package/src/Types.ts +6 -1
- package/src/Validators.ts +45 -0
- package/src/attributes/Bind.ts +4 -4
- package/src/attributes/ClassConstructor.ts +2 -1
- package/src/attributes/JSONAttribute.ts +2 -1
- package/src/attributes/List.ts +4 -4
- package/src/attributes/Radio.ts +3 -2
- package/src/attributes/ScopeChange.ts +2 -2
- package/src/attributes/SetAttribute.ts +2 -1
- package/src/attributes/StandardAttribute.ts +1 -1
- package/src/attributes/StyleAttribute.ts +3 -2
- package/src/attributes/TypeAttribute.ts +1 -1
- package/src/vsn.ts +16 -5
- package/test/AST/ArithmeticAssignmentNode.spec.ts +47 -0
- package/test/AST.spec.ts +3 -2
- package/test/Controller.spec.ts +44 -0
- package/test/MessageList.spec.ts +101 -0
- package/test/Model/DataModel.spec.ts +0 -0
- package/test/Scope/DynamicScopeData.spec.ts +141 -0
- package/test/Scope.spec.ts +15 -3
- package/test/SimplePromise.spec.ts +271 -0
- package/test/Tag/TagList.spec.ts +1 -1
- package/test/attributes/Bind.spec.ts +5 -5
- package/test/attributes/ListItem.spec.ts +1 -1
- package/dist/vsn.min.js +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
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.ScopeMemberNode = void 0;
|
|
55
|
+
var Scope_1 = require("../Scope");
|
|
56
|
+
var List_1 = require("../Tag/List");
|
|
57
|
+
var DOMObject_1 = require("../DOM/DOMObject");
|
|
58
|
+
var Node_1 = require("./Node");
|
|
59
|
+
var ElementQueryNode_1 = require("./ElementQueryNode");
|
|
60
|
+
var ScopeMemberNode = /** @class */ (function (_super) {
|
|
61
|
+
__extends(ScopeMemberNode, _super);
|
|
62
|
+
function ScopeMemberNode(scope, name) {
|
|
63
|
+
var _this = _super.call(this) || this;
|
|
64
|
+
_this.scope = scope;
|
|
65
|
+
_this.name = name;
|
|
66
|
+
return _this;
|
|
67
|
+
}
|
|
68
|
+
ScopeMemberNode.prototype._getChildNodes = function () {
|
|
69
|
+
return [
|
|
70
|
+
this.scope,
|
|
71
|
+
this.name
|
|
72
|
+
];
|
|
73
|
+
};
|
|
74
|
+
ScopeMemberNode.prototype.evaluate = function (scope, dom, tag) {
|
|
75
|
+
if (tag === void 0) { tag = null; }
|
|
76
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
+
var scopes, values, evalScope, _i, scopes_1, parent_1, _a, _b, name_1, value;
|
|
78
|
+
return __generator(this, function (_c) {
|
|
79
|
+
switch (_c.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
scopes = [];
|
|
82
|
+
values = [];
|
|
83
|
+
if (!(this.scope instanceof ElementQueryNode_1.ElementQueryNode)) return [3 /*break*/, 2];
|
|
84
|
+
return [4 /*yield*/, this.scope.evaluate(scope, dom, tag)];
|
|
85
|
+
case 1:
|
|
86
|
+
scopes = _c.sent();
|
|
87
|
+
return [3 /*break*/, 4];
|
|
88
|
+
case 2: return [4 /*yield*/, this.scope.evaluate(scope, dom, tag)];
|
|
89
|
+
case 3:
|
|
90
|
+
evalScope = _c.sent();
|
|
91
|
+
if (evalScope instanceof List_1.TagList) {
|
|
92
|
+
scopes = evalScope;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
scopes.push(evalScope);
|
|
96
|
+
}
|
|
97
|
+
_c.label = 4;
|
|
98
|
+
case 4:
|
|
99
|
+
_i = 0, scopes_1 = scopes;
|
|
100
|
+
_c.label = 5;
|
|
101
|
+
case 5:
|
|
102
|
+
if (!(_i < scopes_1.length)) return [3 /*break*/, 10];
|
|
103
|
+
parent_1 = scopes_1[_i];
|
|
104
|
+
if (parent_1 instanceof DOMObject_1.DOMObject)
|
|
105
|
+
parent_1 = parent_1.scope;
|
|
106
|
+
if (!!parent_1) return [3 /*break*/, 7];
|
|
107
|
+
_a = Error;
|
|
108
|
+
_b = "Cannot access \"";
|
|
109
|
+
return [4 /*yield*/, this.name.evaluate(scope, dom, tag)];
|
|
110
|
+
case 6: throw _a.apply(void 0, [_b + (_c.sent()) + "\" of undefined."]);
|
|
111
|
+
case 7: return [4 /*yield*/, this.name.evaluate(scope, dom, tag)];
|
|
112
|
+
case 8:
|
|
113
|
+
name_1 = _c.sent();
|
|
114
|
+
value = parent_1.get(name_1, false);
|
|
115
|
+
values.push(value instanceof Scope_1.Scope && value.wrapped || value);
|
|
116
|
+
_c.label = 9;
|
|
117
|
+
case 9:
|
|
118
|
+
_i++;
|
|
119
|
+
return [3 /*break*/, 5];
|
|
120
|
+
case 10: return [2 /*return*/, values.length === 1 ? values[0] : values];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
return ScopeMemberNode;
|
|
126
|
+
}(Node_1.Node));
|
|
127
|
+
exports.ScopeMemberNode = ScopeMemberNode;
|
|
128
|
+
//# sourceMappingURL=ScopeMemberNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScopeMemberNode.js","sourceRoot":"","sources":["../../src/AST/ScopeMemberNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAA+B;AAG/B,oCAAoC;AACpC,8CAA2C;AAE3C,+BAA4B;AAC5B,uDAAoD;AAEpD;IAAqC,mCAAI;IACrC,yBACoB,KAAsB,EACtB,IAAsB;QAF1C,YAII,iBAAO,SACV;QAJmB,WAAK,GAAL,KAAK,CAAiB;QACtB,UAAI,GAAJ,IAAI,CAAkB;;IAG1C,CAAC;IAES,wCAAc,GAAxB;QACI,OAAO;YACH,IAAI,CAAC,KAAa;YAClB,IAAI,CAAC,IAAY;SACpB,CAAA;IACL,CAAC;IAEK,kCAAQ,GAAd,UAAe,KAAY,EAAE,GAAQ,EAAE,GAAe;QAAf,oBAAA,EAAA,UAAe;;;;;;wBAC9C,MAAM,GAAG,EAAE,CAAC;wBACV,MAAM,GAAG,EAAE,CAAC;6BAEd,CAAA,IAAI,CAAC,KAAK,YAAY,mCAAgB,CAAA,EAAtC,wBAAsC;wBAC7B,qBAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAA;;wBAAnD,MAAM,GAAG,SAA0C,CAAC;;4BAElC,qBAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAA;;wBAAtD,SAAS,GAAG,SAA0C;wBAC5D,IAAI,SAAS,YAAY,cAAO,EAAE;4BAC9B,MAAM,GAAG,SAAS,CAAC;yBACtB;6BAAM;4BACH,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;yBAC1B;;;8BAGoB,EAAN,iBAAM;;;6BAAN,CAAA,oBAAM,CAAA;wBAApB;wBACD,IAAI,QAAM,YAAY,qBAAS;4BAC3B,QAAM,GAAG,QAAM,CAAC,KAAK,CAAC;6BAEtB,CAAC,QAAM,EAAP,wBAAO;wBACD,KAAA,KAAK,CAAA;;wBAAmB,qBAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAA;4BAAvE,MAAM,kBAAM,MAAkB,SAAyC,sBAAiB,EAAC,CAAC;4BAEjF,qBAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAA;;wBAAhD,SAAO,SAAyC;wBAChD,KAAK,GAAQ,QAAM,CAAC,GAAG,CAAC,MAAI,EAAE,KAAK,CAAC,CAAC;wBAC3C,MAAM,CAAC,IAAI,CAAC,KAAK,YAAY,aAAK,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;;;wBAT/C,IAAM,CAAA;;6BAWzB,sBAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAC;;;;KACnD;IACL,sBAAC;AAAD,CAAC,AA3CD,CAAqC,WAAI,GA2CxC;AA3CY,0CAAe"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LiteralNode } from "./LiteralNode";
|
|
2
|
+
export declare class UnitLiteral {
|
|
3
|
+
protected _value: any;
|
|
4
|
+
protected _amount: number;
|
|
5
|
+
protected _unit: string;
|
|
6
|
+
constructor(_value: any);
|
|
7
|
+
get amount(): number;
|
|
8
|
+
get unit(): string;
|
|
9
|
+
get value(): string;
|
|
10
|
+
set value(value: string);
|
|
11
|
+
toString(): string;
|
|
12
|
+
}
|
|
13
|
+
export declare class UnitLiteralNode extends LiteralNode<UnitLiteral> {
|
|
14
|
+
constructor(_value: any);
|
|
15
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.UnitLiteralNode = exports.UnitLiteral = void 0;
|
|
19
|
+
var LiteralNode_1 = require("./LiteralNode");
|
|
20
|
+
var UnitLiteral = /** @class */ (function () {
|
|
21
|
+
function UnitLiteral(_value) {
|
|
22
|
+
this._value = _value;
|
|
23
|
+
this.value = this._value;
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(UnitLiteral.prototype, "amount", {
|
|
26
|
+
get: function () {
|
|
27
|
+
return this._amount;
|
|
28
|
+
},
|
|
29
|
+
enumerable: false,
|
|
30
|
+
configurable: true
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(UnitLiteral.prototype, "unit", {
|
|
33
|
+
get: function () {
|
|
34
|
+
return this._unit;
|
|
35
|
+
},
|
|
36
|
+
enumerable: false,
|
|
37
|
+
configurable: true
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(UnitLiteral.prototype, "value", {
|
|
40
|
+
get: function () {
|
|
41
|
+
return "" + this._amount + this._unit;
|
|
42
|
+
},
|
|
43
|
+
set: function (value) {
|
|
44
|
+
if (value.indexOf('.') > -1) {
|
|
45
|
+
this._amount = parseFloat(value);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this._amount = parseInt(value);
|
|
49
|
+
}
|
|
50
|
+
if (isNaN(this._amount))
|
|
51
|
+
this._amount = 0;
|
|
52
|
+
var unit = /[^\d.]+$/.exec(value);
|
|
53
|
+
this._unit = unit && unit[0] || '';
|
|
54
|
+
},
|
|
55
|
+
enumerable: false,
|
|
56
|
+
configurable: true
|
|
57
|
+
});
|
|
58
|
+
UnitLiteral.prototype.toString = function () {
|
|
59
|
+
return this.value;
|
|
60
|
+
};
|
|
61
|
+
return UnitLiteral;
|
|
62
|
+
}());
|
|
63
|
+
exports.UnitLiteral = UnitLiteral;
|
|
64
|
+
var UnitLiteralNode = /** @class */ (function (_super) {
|
|
65
|
+
__extends(UnitLiteralNode, _super);
|
|
66
|
+
function UnitLiteralNode(_value) {
|
|
67
|
+
return _super.call(this, new UnitLiteral(_value)) || this;
|
|
68
|
+
}
|
|
69
|
+
return UnitLiteralNode;
|
|
70
|
+
}(LiteralNode_1.LiteralNode));
|
|
71
|
+
exports.UnitLiteralNode = UnitLiteralNode;
|
|
72
|
+
//# sourceMappingURL=UnitLiteralNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnitLiteralNode.js","sourceRoot":"","sources":["../../src/AST/UnitLiteralNode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6CAA0C;AAE1C;IAII,qBACc,MAAW;QAAX,WAAM,GAAN,MAAM,CAAK;QAErB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,sBAAI,+BAAM;aAAV;YACI,OAAO,IAAI,CAAC,OAAO,CAAC;QACxB,CAAC;;;OAAA;IAED,sBAAI,6BAAI;aAAR;YACI,OAAO,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC;;;OAAA;IAED,sBAAI,8BAAK;aAAT;YACI,OAAO,KAAG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAO,CAAC;QAC1C,CAAC;aAED,UAAU,KAAa;YACnB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;aACnC;iBAAM;gBACH,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;aAClC;YAED,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;gBACnB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YAErB,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;;;OAdA;IAgBM,8BAAQ,GAAf;QACI,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IACL,kBAAC;AAAD,CAAC,AAvCD,IAuCC;AAvCY,kCAAW;AA0CxB;IAAqC,mCAAwB;IACzD,yBACI,MAAW;eAEX,kBAAM,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACL,sBAAC;AAAD,CAAC,AAND,CAAqC,yBAAW,GAM/C;AANY,0CAAe"}
|
package/dist/AST.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Scope } from "./Scope";
|
|
2
2
|
import { DOM } from "./DOM";
|
|
3
|
-
import { TagList } from "./Tag/List";
|
|
4
3
|
import { Tag } from "./Tag";
|
|
4
|
+
import { RootScopeMemberNode } from "./AST/RootScopeMemberNode";
|
|
5
|
+
import { ScopeMemberNode } from "./AST/ScopeMemberNode";
|
|
6
|
+
import { ElementAttributeNode } from "./AST/ElementAttributeNode";
|
|
7
|
+
import { Node } from "./AST/Node";
|
|
8
|
+
import { BlockNode } from "./AST/BlockNode";
|
|
5
9
|
export interface Token {
|
|
6
10
|
type: TokenType;
|
|
7
11
|
value: string;
|
|
@@ -72,63 +76,6 @@ export interface TreeNode<T = any> {
|
|
|
72
76
|
evaluate(scope: Scope, dom: DOM, tag?: Tag): any;
|
|
73
77
|
prepare(scope: Scope, dom: DOM, tag?: Tag): any;
|
|
74
78
|
}
|
|
75
|
-
export declare abstract class Node implements TreeNode {
|
|
76
|
-
protected requiresPrep: boolean;
|
|
77
|
-
protected _isPreparationRequired: boolean;
|
|
78
|
-
protected childNodes: Node[];
|
|
79
|
-
protected nodeCache: {
|
|
80
|
-
[key: string]: Node[];
|
|
81
|
-
};
|
|
82
|
-
abstract evaluate(scope: Scope, dom: DOM, tag?: Tag): any;
|
|
83
|
-
isPreparationRequired(): boolean;
|
|
84
|
-
prepare(scope: Scope, dom: DOM, tag?: Tag): Promise<void>;
|
|
85
|
-
protected _getChildNodes(): Node[];
|
|
86
|
-
getChildNodes(): Node[];
|
|
87
|
-
findChildrenByType<T = Node>(t: any): T[];
|
|
88
|
-
findChildrenByTypes<T = Node>(types: any[], cacheKey?: string): T[];
|
|
89
|
-
}
|
|
90
|
-
export declare class BlockNode extends Node implements TreeNode {
|
|
91
|
-
readonly statements: Node[];
|
|
92
|
-
constructor(statements: Node[]);
|
|
93
|
-
protected _getChildNodes(): Node[];
|
|
94
|
-
evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<any>;
|
|
95
|
-
}
|
|
96
|
-
declare class LiteralNode<T = any> extends Node implements TreeNode {
|
|
97
|
-
readonly value: T;
|
|
98
|
-
constructor(value: T);
|
|
99
|
-
evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<T>;
|
|
100
|
-
}
|
|
101
|
-
declare class ScopeMemberNode extends Node implements TreeNode {
|
|
102
|
-
readonly scope: TreeNode<Scope>;
|
|
103
|
-
readonly name: TreeNode<string>;
|
|
104
|
-
constructor(scope: TreeNode<Scope>, name: TreeNode<string>);
|
|
105
|
-
protected _getChildNodes(): Node[];
|
|
106
|
-
evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<any>;
|
|
107
|
-
}
|
|
108
|
-
declare class RootScopeMemberNode<T = any> extends Node implements TreeNode {
|
|
109
|
-
readonly name: TreeNode<string>;
|
|
110
|
-
constructor(name: TreeNode<string>);
|
|
111
|
-
protected _getChildNodes(): Node[];
|
|
112
|
-
evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<any>;
|
|
113
|
-
}
|
|
114
|
-
declare class ElementQueryNode extends Node implements TreeNode {
|
|
115
|
-
readonly query: string;
|
|
116
|
-
protected requiresPrep: boolean;
|
|
117
|
-
constructor(query: string);
|
|
118
|
-
evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<TagList>;
|
|
119
|
-
prepare(scope: Scope, dom: DOM, tag?: Tag): Promise<void>;
|
|
120
|
-
}
|
|
121
|
-
declare class ElementAttributeNode extends Node implements TreeNode {
|
|
122
|
-
readonly elementRef: ElementQueryNode | null;
|
|
123
|
-
readonly attr: string;
|
|
124
|
-
protected requiresPrep: boolean;
|
|
125
|
-
constructor(elementRef: ElementQueryNode | null, attr: string);
|
|
126
|
-
get name(): LiteralNode<string>;
|
|
127
|
-
protected _getChildNodes(): Node[];
|
|
128
|
-
get attributeName(): string;
|
|
129
|
-
evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<any>;
|
|
130
|
-
prepare(scope: Scope, dom: DOM, tag?: Tag): Promise<void>;
|
|
131
|
-
}
|
|
132
79
|
export interface IBlockInfo {
|
|
133
80
|
type: BlockType;
|
|
134
81
|
open: TokenType;
|
|
@@ -136,7 +83,7 @@ export interface IBlockInfo {
|
|
|
136
83
|
openCharacter: string;
|
|
137
84
|
closeCharacter: string;
|
|
138
85
|
}
|
|
139
|
-
export declare const AttributableNodes: (typeof
|
|
86
|
+
export declare const AttributableNodes: (typeof RootScopeMemberNode | typeof ScopeMemberNode | typeof ElementAttributeNode)[];
|
|
140
87
|
export declare class Tree {
|
|
141
88
|
readonly code: string;
|
|
142
89
|
protected static cache: {
|
|
@@ -157,5 +104,5 @@ export declare class Tree {
|
|
|
157
104
|
static getBlockTokens(tokens: Token[], groupBy?: TokenType | null): Token[][];
|
|
158
105
|
static getTokensUntil(tokens: Token[], terminator?: TokenType, consumeTerminator?: boolean, includeTerminator?: boolean, validIfTerminatorNotFound?: boolean, blockInfo?: IBlockInfo): Token[];
|
|
159
106
|
static consumeTypes(tokens: Token[], types: TokenType[]): Token[];
|
|
107
|
+
static apply(code: string, scope: Scope, dom: DOM, tag: Tag): Promise<any>;
|
|
160
108
|
}
|
|
161
|
-
export {};
|