vsn 0.1.43 → 0.1.46
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/demo.html +7 -2
- package/demo/markup.html +2 -0
- package/demo/vsn.js +1 -1
- package/demo/xhr.vsn +4 -0
- package/dist/AST/ArithmeticAssignmentNode.js +8 -1
- package/dist/AST/ArithmeticAssignmentNode.js.map +1 -1
- package/dist/AST/FunctionNode.d.ts +0 -0
- package/dist/AST/FunctionNode.js +1 -0
- package/dist/AST/FunctionNode.js.map +1 -0
- package/dist/AST/StringFormatNode.d.ts +18 -0
- package/dist/{attributes/ClickToggleClass.js → AST/StringFormatNode.js} +49 -49
- package/dist/AST/StringFormatNode.js.map +1 -0
- package/dist/AST/WASM/Context.d.ts +4 -0
- package/dist/AST/WASM/Context.js +18 -0
- package/dist/AST/WASM/Context.js.map +1 -0
- package/dist/AST/WASM/Function.d.ts +22 -0
- package/dist/AST/WASM/Function.js +110 -0
- package/dist/AST/WASM/Function.js.map +1 -0
- package/dist/AST/WASM/Memory.d.ts +12 -0
- package/dist/AST/WASM/Memory.js +22 -0
- package/dist/AST/WASM/Memory.js.map +1 -0
- package/dist/AST/WASM/Section.d.ts +5 -0
- package/dist/AST/WASM/Section.js +11 -0
- package/dist/AST/WASM/Section.js.map +1 -0
- package/dist/AST/WASM.d.ts +58 -0
- package/dist/AST/WASM.js +277 -0
- package/dist/AST/WASM.js.map +1 -0
- package/dist/AST/XHRNode.d.ts +15 -0
- package/dist/AST/XHRNode.js +146 -0
- package/dist/AST/XHRNode.js.map +1 -0
- package/dist/AST.d.ts +62 -55
- package/dist/AST.js +123 -83
- package/dist/AST.js.map +1 -1
- package/dist/DOM/DOMObject.d.ts +1 -0
- package/dist/DOM/DOMObject.js +6 -0
- package/dist/DOM/DOMObject.js.map +1 -1
- package/dist/DOM.js +61 -90
- package/dist/DOM.js.map +1 -1
- package/dist/Registry.d.ts +2 -0
- package/dist/Registry.js +13 -9
- package/dist/Registry.js.map +1 -1
- package/dist/Scope/ScopeDataAbstract.js +2 -2
- package/dist/Scope/ScopeDataAbstract.js.map +1 -1
- package/dist/Scope/properties/Property.d.ts +5 -6
- package/dist/Scope/properties/Property.js +17 -25
- package/dist/Scope/properties/Property.js.map +1 -1
- package/dist/Scope/properties/_imports.d.ts +1 -1
- package/dist/Scope/properties/_imports.js.map +1 -1
- package/dist/Tag.d.ts +1 -0
- package/dist/Tag.js +9 -11
- package/dist/Tag.js.map +1 -1
- package/dist/attributes/StandardAttribute.js +4 -1
- package/dist/attributes/StandardAttribute.js.map +1 -1
- package/dist/attributes/_imports.d.ts +0 -2
- package/dist/attributes/_imports.js +1 -5
- package/dist/attributes/_imports.js.map +1 -1
- package/dist/helpers/VisionHelper.d.ts +1 -0
- package/dist/helpers/VisionHelper.js +17 -0
- package/dist/helpers/VisionHelper.js.map +1 -1
- package/dist/vsn.d.ts +3 -2
- package/dist/vsn.js +7 -3
- package/dist/vsn.js.map +1 -1
- package/package.json +1 -1
- package/src/AST/ArithmeticAssignmentNode.ts +9 -2
- package/src/AST/FunctionNode.ts +0 -0
- package/src/AST/StringFormatNode.ts +43 -0
- package/src/AST/WASM/Context.ts +12 -0
- package/src/AST/WASM/Function.ts +67 -0
- package/src/AST/WASM/Memory.ts +21 -0
- package/src/AST/WASM/Section.ts +6 -0
- package/src/AST/WASM.ts +244 -0
- package/src/AST/XHRNode.ts +81 -0
- package/src/AST.ts +66 -31
- package/src/DOM/DOMObject.ts +6 -0
- package/src/DOM.ts +11 -25
- package/src/Registry.ts +12 -9
- package/src/Scope/ScopeDataAbstract.ts +2 -2
- package/src/Scope/properties/Property.ts +17 -28
- package/src/Scope/properties/_imports.ts +1 -1
- package/src/Tag.ts +10 -9
- package/src/attributes/AddClassIf.ts +1 -1
- package/src/attributes/StandardAttribute.ts +4 -2
- package/src/attributes/_imports.ts +0 -2
- package/src/helpers/VisionHelper.ts +13 -0
- package/src/vsn.ts +3 -2
- package/test/AST/ArithmeticAssignmentNode.spec.ts +0 -2
- package/test/AST/StringFormatNode.spec.ts +12 -0
- package/test/AST/WASM.spec.ts +63 -0
- package/test/AST/XHRNode.spec.ts +10 -0
- package/test/Scope/ScopeData.spec.ts +5 -5
- package/types/vsn-component.d.ts +5 -0
- package/dist/attributes/ClickRemoveClass.d.ts +0 -8
- package/dist/attributes/ClickRemoveClass.js +0 -114
- package/dist/attributes/ClickRemoveClass.js.map +0 -1
- package/dist/attributes/ClickToggleClass.d.ts +0 -8
- package/dist/attributes/ClickToggleClass.js.map +0 -1
- package/src/attributes/ClickRemoveClass.ts +0 -30
- package/src/attributes/ClickToggleClass.ts +0 -30
package/src/DOM.ts
CHANGED
|
@@ -3,8 +3,6 @@ import {ElementHelper} from "./helpers/ElementHelper";
|
|
|
3
3
|
import {Configuration} from "./Configuration";
|
|
4
4
|
import {Tree} from "./AST";
|
|
5
5
|
import {TagList} from "./Tag/List";
|
|
6
|
-
import {benchmarkEnd, benchmarkStart} from "./Bencmark";
|
|
7
|
-
import {VisionHelper} from "./helpers/VisionHelper";
|
|
8
6
|
import {WrappedWindow} from "./DOM/WrappedWindow";
|
|
9
7
|
import {WrappedDocument} from "./DOM/WrappedDocument";
|
|
10
8
|
import {Scope} from "./Scope";
|
|
@@ -50,6 +48,8 @@ export class DOM extends EventDispatcher {
|
|
|
50
48
|
return new TagList(this.window);
|
|
51
49
|
case 'document':
|
|
52
50
|
return new TagList(this.document);
|
|
51
|
+
case 'body':
|
|
52
|
+
return new TagList(this.root);
|
|
53
53
|
default:
|
|
54
54
|
const nodes = this.querySelectorAll(selector, tag);
|
|
55
55
|
return await this.getTagsForElements(Array.from(nodes) as Element[], create);
|
|
@@ -119,6 +119,13 @@ export class DOM extends EventDispatcher {
|
|
|
119
119
|
if (tag) {
|
|
120
120
|
tag.mutate(mutation);
|
|
121
121
|
}
|
|
122
|
+
|
|
123
|
+
for (const ele of Array.from(mutation.removedNodes)) {
|
|
124
|
+
const toRemove: Tag = await this.getTagForElement(ele as HTMLElement);
|
|
125
|
+
if (toRemove) {
|
|
126
|
+
toRemove.deconstruct();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
122
129
|
}
|
|
123
130
|
}
|
|
124
131
|
|
|
@@ -139,7 +146,6 @@ export class DOM extends EventDispatcher {
|
|
|
139
146
|
const toBuild: HTMLElement[] = [];
|
|
140
147
|
const toSkip: HTMLElement[] = [];
|
|
141
148
|
|
|
142
|
-
if (VisionHelper.doBenchmark) benchmarkStart('DOM','findElements');
|
|
143
149
|
if (ele && ele.querySelectorAll) {
|
|
144
150
|
for (const element of (Array.from(ele.querySelectorAll(`*`)) as HTMLElement[])) { // Don't build items more than once
|
|
145
151
|
if (!ElementHelper.hasVisionAttribute(element)) continue;
|
|
@@ -152,9 +158,7 @@ export class DOM extends EventDispatcher {
|
|
|
152
158
|
toBuild.push(element);
|
|
153
159
|
}
|
|
154
160
|
}
|
|
155
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM', 'findElements');
|
|
156
161
|
|
|
157
|
-
if (VisionHelper.doBenchmark) benchmarkStart('DOM', 'buildTags');
|
|
158
162
|
for (const element of toBuild) {
|
|
159
163
|
if (allElements.indexOf(element) > -1) continue;
|
|
160
164
|
const tag: Tag = new Tag(element, this);
|
|
@@ -162,23 +166,17 @@ export class DOM extends EventDispatcher {
|
|
|
162
166
|
newTags.push(tag);
|
|
163
167
|
allElements.push(element as HTMLElement);
|
|
164
168
|
}
|
|
165
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM', 'buildTags');
|
|
166
169
|
|
|
167
170
|
if (isRoot)
|
|
168
171
|
this._root = await this.getTagForElement(document.body);
|
|
169
172
|
|
|
170
173
|
// Configure, setup & execute attributes
|
|
171
|
-
if (VisionHelper.doBenchmark) benchmarkStart('DOM','buildTagAttributes');
|
|
172
174
|
for (const tag of newTags)
|
|
173
175
|
await tag.buildAttributes();
|
|
174
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM','buildTagAttributes');
|
|
175
176
|
|
|
176
|
-
if (VisionHelper.inDevelopment) benchmarkStart('DOM', 'compileAttributes');
|
|
177
177
|
for (const tag of newTags)
|
|
178
178
|
await tag.compileAttributes();
|
|
179
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM','compileAttributes');
|
|
180
179
|
|
|
181
|
-
if (VisionHelper.doBenchmark) benchmarkStart('DOM', 'buildTree');
|
|
182
180
|
for (const tag of newTags) {
|
|
183
181
|
if (tag === this.root)
|
|
184
182
|
continue;
|
|
@@ -198,39 +196,27 @@ export class DOM extends EventDispatcher {
|
|
|
198
196
|
if (!foundParent)
|
|
199
197
|
console.error('Could not find parent for ', tag);
|
|
200
198
|
}
|
|
201
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM', 'buildTree');
|
|
202
199
|
|
|
203
|
-
if (VisionHelper.doBenchmark) benchmarkStart('DOM', 'setupAttributes');
|
|
204
200
|
for (const tag of newTags)
|
|
205
201
|
await tag.setupAttributes();
|
|
206
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM', 'setupAttributes');
|
|
207
202
|
|
|
208
|
-
if (VisionHelper.doBenchmark) benchmarkStart('DOM', 'extractAttributes');
|
|
209
203
|
for (const tag of newTags)
|
|
210
204
|
await tag.extractAttributes();
|
|
211
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM', 'extractAttributes');
|
|
212
205
|
|
|
213
|
-
if (VisionHelper.doBenchmark) benchmarkStart('DOM', 'connectAttributes');
|
|
214
206
|
for (const tag of newTags)
|
|
215
207
|
await tag.connectAttributes();
|
|
216
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM', 'connectAttributes');
|
|
217
208
|
|
|
218
|
-
if (VisionHelper.doBenchmark) benchmarkStart('DOM', 'finalizeTags');
|
|
219
209
|
for (const tag of newTags) {
|
|
220
210
|
await tag.finalize();
|
|
221
211
|
this.queued.splice(this.queued.indexOf(tag.element), 1);
|
|
222
212
|
}
|
|
223
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM', 'finalizeTags');
|
|
224
213
|
|
|
225
|
-
|
|
226
|
-
for (const tag of newTags)
|
|
227
|
-
this.observer.observe(tag.element, {
|
|
214
|
+
newTags.forEach(tag => this.observer.observe(tag.element, {
|
|
228
215
|
attributes: true,
|
|
229
216
|
characterData: true,
|
|
230
217
|
childList: true,
|
|
231
218
|
subtree: true
|
|
232
|
-
});
|
|
233
|
-
if (VisionHelper.doBenchmark) benchmarkEnd('DOM', 'observeTags');
|
|
219
|
+
}));
|
|
234
220
|
|
|
235
221
|
this.dispatch('built');
|
|
236
222
|
}
|
package/src/Registry.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {VisionHelper} from "./helpers/VisionHelper";
|
|
2
1
|
import {EventDispatcher} from "./EventDispatcher";
|
|
3
2
|
import {IDeferred, IPromise, SimplePromise} from "./SimplePromise";
|
|
4
3
|
|
|
@@ -53,6 +52,7 @@ export class RegistryStore extends EventDispatcher {
|
|
|
53
52
|
|
|
54
53
|
export class Registry extends EventDispatcher {
|
|
55
54
|
protected static _instance: Registry;
|
|
55
|
+
public readonly components: RegistryStore;
|
|
56
56
|
public readonly classes: RegistryStore;
|
|
57
57
|
public readonly models: RegistryStore;
|
|
58
58
|
public readonly templates: RegistryStore;
|
|
@@ -63,15 +63,18 @@ export class Registry extends EventDispatcher {
|
|
|
63
63
|
|
|
64
64
|
constructor() {
|
|
65
65
|
super();
|
|
66
|
+
this.components = new RegistryStore();
|
|
67
|
+
this.classes = new RegistryStore();
|
|
68
|
+
this.models = new RegistryStore();
|
|
69
|
+
this.templates = new RegistryStore();
|
|
70
|
+
this.types = new RegistryStore();
|
|
71
|
+
this.validators = new RegistryStore();
|
|
72
|
+
this.formats = new RegistryStore();
|
|
73
|
+
this.attributes = new RegistryStore();
|
|
74
|
+
}
|
|
66
75
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.models = new RegistryStore(w['$models'] || {});
|
|
70
|
-
this.templates = new RegistryStore(w['$templates'] || {});
|
|
71
|
-
this.types = new RegistryStore(w['$types'] || {});
|
|
72
|
-
this.validators = new RegistryStore(w['$validators'] || {});
|
|
73
|
-
this.formats = new RegistryStore(w['$formats'] || {});
|
|
74
|
-
this.attributes = new RegistryStore(w['$attributes'] || {});
|
|
76
|
+
public static component(key: string = null, setup = null) {
|
|
77
|
+
return register('components', key, setup);
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
public static class(key: string = null, setup = null) {
|
|
@@ -65,7 +65,7 @@ export class ScopeDataAbstract extends EventDispatcher {
|
|
|
65
65
|
const keys = [];
|
|
66
66
|
for (const key of this.keys) {
|
|
67
67
|
const property = this.getProperty(key);
|
|
68
|
-
if (property.
|
|
68
|
+
if (property.hasLabels(tags)) {
|
|
69
69
|
keys.push(key);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -86,7 +86,7 @@ export class ScopeDataAbstract extends EventDispatcher {
|
|
|
86
86
|
propLoop: for (const key of this.getProperties()) {
|
|
87
87
|
const property = this['__'+key];
|
|
88
88
|
for (const tag of tags) {
|
|
89
|
-
if (!property.
|
|
89
|
+
if (!property.hasLabel(tag))
|
|
90
90
|
continue propLoop;
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -30,7 +30,7 @@ export interface IPropertyConfig {
|
|
|
30
30
|
type?: string;
|
|
31
31
|
default?: any;
|
|
32
32
|
validators?: TValidator[];
|
|
33
|
-
|
|
33
|
+
labels?: string[];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export class Property<T = any> extends EventDispatcher {
|
|
@@ -41,8 +41,8 @@ export class Property<T = any> extends EventDispatcher {
|
|
|
41
41
|
constructor(value?: T, config?: IPropertyConfig) {
|
|
42
42
|
super();
|
|
43
43
|
this.config = config;
|
|
44
|
-
if (!this.config.
|
|
45
|
-
this.config.
|
|
44
|
+
if (!this.config.labels)
|
|
45
|
+
this.config.labels = [];
|
|
46
46
|
if (!this.config.validators)
|
|
47
47
|
this.config.validators = [];
|
|
48
48
|
this.type = config.type || 'any';
|
|
@@ -109,43 +109,32 @@ export class Property<T = any> extends EventDispatcher {
|
|
|
109
109
|
this.config.validators.push(validator);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
if
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const index = this.config.validators.indexOf(validator);
|
|
118
|
-
if (index != -1)
|
|
119
|
-
this.config.validators.splice(index, 1);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
addTag(tag: string) {
|
|
124
|
-
if(this.config.tags == undefined) {
|
|
125
|
-
this.config.tags = [];
|
|
112
|
+
addLabel(label: string) {
|
|
113
|
+
if(this.config.labels == undefined) {
|
|
114
|
+
this.config.labels = [];
|
|
126
115
|
}
|
|
127
|
-
if(this.config.
|
|
128
|
-
this.config.
|
|
116
|
+
if(this.config.labels.indexOf(label) == -1) {
|
|
117
|
+
this.config.labels.push(label);
|
|
129
118
|
}
|
|
130
119
|
}
|
|
131
120
|
|
|
132
|
-
|
|
133
|
-
if(this.config.
|
|
121
|
+
removeLabel(label: string) {
|
|
122
|
+
if(this.config.labels == undefined) {
|
|
134
123
|
return;
|
|
135
124
|
}
|
|
136
|
-
const index = this.config.
|
|
125
|
+
const index = this.config.labels.indexOf(label);
|
|
137
126
|
if(index != -1) {
|
|
138
|
-
this.config.
|
|
127
|
+
this.config.labels.splice(index, 1);
|
|
139
128
|
}
|
|
140
129
|
}
|
|
141
130
|
|
|
142
|
-
|
|
143
|
-
return this.config.
|
|
131
|
+
hasLabel(label: string) {
|
|
132
|
+
return this.config.labels.indexOf(label) !== -1;
|
|
144
133
|
}
|
|
145
134
|
|
|
146
|
-
|
|
147
|
-
for(const
|
|
148
|
-
if(!this.
|
|
135
|
+
hasLabels(labels: string[]) {
|
|
136
|
+
for(const label of labels) {
|
|
137
|
+
if(!this.hasLabel(label)) {
|
|
149
138
|
return false;
|
|
150
139
|
}
|
|
151
140
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {Property, property} from './Property';
|
|
1
|
+
export {Property, property, IPropertyConfig} from './Property';
|
|
2
2
|
export {ArrayProperty} from './ArrayProperty';
|
package/src/Tag.ts
CHANGED
|
@@ -72,12 +72,7 @@ export class Tag extends DOMObject {
|
|
|
72
72
|
if (this._nonDeferredAttributes.length > 0)
|
|
73
73
|
return this._nonDeferredAttributes;
|
|
74
74
|
|
|
75
|
-
const attrs: Attribute[] =
|
|
76
|
-
for (const attribute of this.attributes) {
|
|
77
|
-
if (attribute.state === AttributeState.Deferred)
|
|
78
|
-
continue;
|
|
79
|
-
attrs.push(attribute);
|
|
80
|
-
}
|
|
75
|
+
const attrs: Attribute[] = this.attributes.filter(attr => attr.state !== AttributeState.Deferred);
|
|
81
76
|
this._nonDeferredAttributes = attrs;
|
|
82
77
|
return attrs;
|
|
83
78
|
}
|
|
@@ -119,9 +114,7 @@ export class Tag extends DOMObject {
|
|
|
119
114
|
}
|
|
120
115
|
|
|
121
116
|
mutate(mutation: MutationRecord): void {
|
|
122
|
-
|
|
123
|
-
attr.mutate(mutation);
|
|
124
|
-
}
|
|
117
|
+
this.attributes.map(attr => attr.mutate(mutation));
|
|
125
118
|
this.dispatch('mutate', mutation);
|
|
126
119
|
}
|
|
127
120
|
|
|
@@ -579,4 +572,12 @@ export class Tag extends DOMObject {
|
|
|
579
572
|
await this.setupAttribute(attr);
|
|
580
573
|
this.deferredAttributes.length = 0;
|
|
581
574
|
}
|
|
575
|
+
|
|
576
|
+
deconstruct() {
|
|
577
|
+
this.attributes.forEach(attr => attr.deconstruct());
|
|
578
|
+
this.attributes.length = 0;
|
|
579
|
+
this._children.forEach(child => child.deconstruct());
|
|
580
|
+
this._children.length = 0;
|
|
581
|
+
super.deconstruct();
|
|
582
|
+
}
|
|
582
583
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Attribute} from "../Attribute";
|
|
2
|
+
import {DOM} from "../DOM";
|
|
2
3
|
|
|
3
4
|
export class StandardAttribute extends Attribute {
|
|
4
5
|
public static readonly canDefer: boolean = false;
|
|
@@ -66,9 +67,10 @@ export class StandardAttribute extends Attribute {
|
|
|
66
67
|
public set value(value: any) {
|
|
67
68
|
if (this.key === '@text')
|
|
68
69
|
this.tag.element.innerText = value;
|
|
69
|
-
else if (this.key === '@html')
|
|
70
|
+
else if (this.key === '@html') {
|
|
70
71
|
this.tag.element.innerHTML = value;
|
|
71
|
-
|
|
72
|
+
DOM.instance.buildFrom(this.tag.element);
|
|
73
|
+
} else if (this.key === '@value')
|
|
72
74
|
this.tag.value = value;
|
|
73
75
|
else if (this.key === '@class' && value) {
|
|
74
76
|
this.tag.element.classList.remove(...Array.from(this.tag.element.classList));
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export {AddClassIf} from "./AddClassIf";
|
|
2
2
|
export {Bind} from "./Bind";
|
|
3
|
-
export {ClickRemoveClass} from "./ClickRemoveClass";
|
|
4
|
-
export {ClickToggleClass} from "./ClickToggleClass";
|
|
5
3
|
export {ControllerAttribute} from "./ControllerAttribute";
|
|
6
4
|
export {DisableIf} from "./DisableIf";
|
|
7
5
|
export {Exec} from "./Exec";
|
|
@@ -47,4 +47,17 @@ export class VisionHelper {
|
|
|
47
47
|
setTimeout(callback, timeout);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
public static get wasmSupport(): boolean {
|
|
52
|
+
try {
|
|
53
|
+
if (typeof WebAssembly === "object"
|
|
54
|
+
&& typeof WebAssembly.instantiate === "function") {
|
|
55
|
+
const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
|
|
56
|
+
if (module instanceof WebAssembly.Module)
|
|
57
|
+
return new WebAssembly.Instance(module) instanceof WebAssembly.Instance;
|
|
58
|
+
}
|
|
59
|
+
} catch (e) {
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
50
63
|
}
|
package/src/vsn.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {DOM} from "./DOM";
|
|
2
2
|
import {WrappedArray} from "./Scope/WrappedArray";
|
|
3
3
|
import {Registry} from "./Registry";
|
|
4
|
-
import "./Types";
|
|
5
|
-
import "./Formats";
|
|
6
4
|
import {Configuration} from "./Configuration";
|
|
7
5
|
import {VisionHelper} from "./helpers/VisionHelper";
|
|
8
6
|
import {Tree} from "./AST";
|
|
@@ -83,4 +81,7 @@ export {EventDispatcher} from './EventDispatcher';
|
|
|
83
81
|
export {MessageList} from './MessageList';
|
|
84
82
|
export {SimplePromise} from './SimplePromise';
|
|
85
83
|
export {Tag} from './Tag';
|
|
84
|
+
export {Formats} from './Formats';
|
|
85
|
+
export {Types} from './Types';
|
|
86
|
+
export {Validators} from './Validators';
|
|
86
87
|
export const vision: Vision = Vision.instance;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {Tree} from "../../src/AST";
|
|
2
|
+
import {Scope} from "../../src/Scope";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
describe('StringFormatNode', () => {
|
|
6
|
+
it("should format simple format strings", async () => {
|
|
7
|
+
const tree = new Tree("`Hello ${name}`");
|
|
8
|
+
const scope = new Scope();
|
|
9
|
+
scope.set("name", "World");
|
|
10
|
+
expect(await tree.evaluate(scope, null, null)).toBe("Hello World");
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {compile, EOpCode, EValueType, run} from "../../src/AST/WASM";
|
|
2
|
+
import {VisionHelper} from "../../src/helpers/VisionHelper";
|
|
3
|
+
import {FunctionSection} from "../../src/AST/WASM/Function";
|
|
4
|
+
|
|
5
|
+
describe('WASM', () => {
|
|
6
|
+
it("should support wasm", async () => {
|
|
7
|
+
expect(VisionHelper.wasmSupport).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("should allow a simple addition function to be made", async () => {
|
|
11
|
+
const main = new FunctionSection("main");
|
|
12
|
+
main.addParam(EValueType.i32);
|
|
13
|
+
main.addParam(EValueType.i32);
|
|
14
|
+
main.addResult(EValueType.i32);
|
|
15
|
+
main.addCode([
|
|
16
|
+
0x00, // local declare count
|
|
17
|
+
EOpCode.get_local,
|
|
18
|
+
0x00, // local var 0
|
|
19
|
+
EOpCode.get_local,
|
|
20
|
+
0x01, // local var 1
|
|
21
|
+
EOpCode.i32_add,
|
|
22
|
+
EOpCode.end
|
|
23
|
+
]);
|
|
24
|
+
expect(await run(main, 10, 15)).toBe(25);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should allow a simple subtraction function to be made", async () => {
|
|
28
|
+
const main = new FunctionSection("main");
|
|
29
|
+
main.addParam(EValueType.i32);
|
|
30
|
+
main.addParam(EValueType.i32);
|
|
31
|
+
main.addResult(EValueType.i32);
|
|
32
|
+
main.addCode([
|
|
33
|
+
0x00, // local declare count
|
|
34
|
+
EOpCode.get_local,
|
|
35
|
+
0x00, // local var 0
|
|
36
|
+
EOpCode.get_local,
|
|
37
|
+
0x01, // local var 1
|
|
38
|
+
EOpCode.i32_sub,
|
|
39
|
+
EOpCode.end
|
|
40
|
+
]);
|
|
41
|
+
expect(await run(main, 10, 15)).toBe(-5);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should allow a simple function to be made", async () => {
|
|
45
|
+
const main = new FunctionSection("main");
|
|
46
|
+
main.addParam(EValueType.i32);
|
|
47
|
+
main.addParam(EValueType.i32);
|
|
48
|
+
main.addResult(EValueType.i32);
|
|
49
|
+
main.addCode([
|
|
50
|
+
0x00, // local declare count
|
|
51
|
+
EOpCode.get_local,
|
|
52
|
+
0x00, // local var 0
|
|
53
|
+
EOpCode.get_local,
|
|
54
|
+
0x01, // local var 1
|
|
55
|
+
EOpCode.i32_sub,
|
|
56
|
+
EOpCode.get_local,
|
|
57
|
+
0x00, // local var 0
|
|
58
|
+
EOpCode.i32_mul,
|
|
59
|
+
EOpCode.end
|
|
60
|
+
]);
|
|
61
|
+
expect(await run(main, 100, 15)).toBe(8500);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -6,15 +6,15 @@ describe('ScopeData', () => {
|
|
|
6
6
|
it("should set tags correctly", async () => {
|
|
7
7
|
const data = new ScopeData();
|
|
8
8
|
data.createProperty('test', Property, {
|
|
9
|
-
|
|
9
|
+
labels: ['test']
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
data.createProperty('test_int', Property, {
|
|
13
|
-
|
|
13
|
+
labels: ['test']
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
data.createProperty('not_test', Property, {
|
|
17
|
-
|
|
17
|
+
labels: ['not_test']
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
data['test'] = 'test';
|
|
@@ -40,7 +40,7 @@ describe('ScopeData', () => {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
const notTestProp = data.getProperty('not_test');
|
|
43
|
-
notTestProp.
|
|
43
|
+
notTestProp.addLabel('test');
|
|
44
44
|
const taggedNotTestData2 = data.getData('test');
|
|
45
45
|
expect(taggedNotTestData2).toEqual({
|
|
46
46
|
test: 'test',
|
|
@@ -48,7 +48,7 @@ describe('ScopeData', () => {
|
|
|
48
48
|
not_test: 'not_test'
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
notTestProp.
|
|
51
|
+
notTestProp.removeLabel('test');
|
|
52
52
|
const taggedNotTestData3 = data.getData('test');
|
|
53
53
|
expect(taggedNotTestData3).toEqual({
|
|
54
54
|
test: 'test',
|
|
@@ -1,114 +0,0 @@
|
|
|
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
33
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
34
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
35
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
36
|
-
function step(op) {
|
|
37
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
38
|
-
while (_) try {
|
|
39
|
-
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;
|
|
40
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
41
|
-
switch (op[0]) {
|
|
42
|
-
case 0: case 1: t = op; break;
|
|
43
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
44
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
45
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
46
|
-
default:
|
|
47
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
48
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
49
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
50
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
51
|
-
if (t[2]) _.ops.pop();
|
|
52
|
-
_.trys.pop(); continue;
|
|
53
|
-
}
|
|
54
|
-
op = body.call(thisArg, _);
|
|
55
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
56
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
-
exports.ClickRemoveClass = void 0;
|
|
61
|
-
var Attribute_1 = require("../Attribute");
|
|
62
|
-
var Registry_1 = require("../Registry");
|
|
63
|
-
var ClickRemoveClass = /** @class */ (function (_super) {
|
|
64
|
-
__extends(ClickRemoveClass, _super);
|
|
65
|
-
function ClickRemoveClass() {
|
|
66
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
67
|
-
_this.cssClass = '';
|
|
68
|
-
_this.target = null;
|
|
69
|
-
return _this;
|
|
70
|
-
}
|
|
71
|
-
ClickRemoveClass.prototype.setup = function () {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
-
return __generator(this, function (_a) {
|
|
74
|
-
switch (_a.label) {
|
|
75
|
-
case 0:
|
|
76
|
-
this.cssClass = this.getAttributeBinding('active');
|
|
77
|
-
this.target = this.getAttributeValue();
|
|
78
|
-
return [4 /*yield*/, _super.prototype.setup.call(this)];
|
|
79
|
-
case 1:
|
|
80
|
-
_a.sent();
|
|
81
|
-
return [2 /*return*/];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
ClickRemoveClass.prototype.connect = function () {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0:
|
|
91
|
-
this.tag.addEventHandler('click', this.getAttributeModifiers(), this.onClick.bind(this));
|
|
92
|
-
return [4 /*yield*/, _super.prototype.connect.call(this)];
|
|
93
|
-
case 1:
|
|
94
|
-
_a.sent();
|
|
95
|
-
return [2 /*return*/];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
ClickRemoveClass.prototype.onClick = function (e) {
|
|
101
|
-
var element = this.tag.element;
|
|
102
|
-
if (!!this.target) {
|
|
103
|
-
element = document.getElementById(this.target);
|
|
104
|
-
}
|
|
105
|
-
if (element)
|
|
106
|
-
element.classList.remove(this.cssClass);
|
|
107
|
-
};
|
|
108
|
-
ClickRemoveClass = __decorate([
|
|
109
|
-
Registry_1.Registry.attribute('vsn-click-remove-class')
|
|
110
|
-
], ClickRemoveClass);
|
|
111
|
-
return ClickRemoveClass;
|
|
112
|
-
}(Attribute_1.Attribute));
|
|
113
|
-
exports.ClickRemoveClass = ClickRemoveClass;
|
|
114
|
-
//# sourceMappingURL=ClickRemoveClass.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClickRemoveClass.js","sourceRoot":"","sources":["../../src/attributes/ClickRemoveClass.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAuC;AACvC,wCAAqC;AAGrC;IAAsC,oCAAS;IAA/C;QAAA,qEAyBC;QAxBa,cAAQ,GAAW,EAAE,CAAC;QACtB,YAAM,GAAW,IAAI,CAAC;;IAuBpC,CAAC;IArBgB,gCAAK,GAAlB;;;;;wBACI,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;wBACnD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;wBACvC,qBAAM,iBAAM,KAAK,WAAE,EAAA;;wBAAnB,SAAmB,CAAC;;;;;KACvB;IAEY,kCAAO,GAApB;;;;;wBACI,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;wBACzF,qBAAM,iBAAM,OAAO,WAAE,EAAA;;wBAArB,SAAqB,CAAC;;;;;KACzB;IAED,kCAAO,GAAP,UAAQ,CAAC;QACL,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAE/B,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE;YACf,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClD;QAED,IAAI,OAAO;YACP,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAxBQ,gBAAgB;QAD5B,mBAAQ,CAAC,SAAS,CAAC,wBAAwB,CAAC;OAChC,gBAAgB,CAyB5B;IAAD,uBAAC;CAAA,AAzBD,CAAsC,qBAAS,GAyB9C;AAzBY,4CAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClickToggleClass.js","sourceRoot":"","sources":["../../src/attributes/ClickToggleClass.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAuC;AACvC,wCAAqC;AAGrC;IAAsC,oCAAS;IAA/C;QAAA,qEAyBC;QAxBa,cAAQ,GAAW,EAAE,CAAC;QACtB,YAAM,GAAW,IAAI,CAAC;;IAuBpC,CAAC;IArBgB,gCAAK,GAAlB;;;;;wBACI,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAE,QAAQ,CAAC,CAAC;wBACpD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;wBACvC,qBAAM,iBAAM,KAAK,WAAE,EAAA;;wBAAnB,SAAmB,CAAC;;;;;KACvB;IAEY,kCAAO,GAApB;;;;;wBACI,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;wBACzF,qBAAM,iBAAM,OAAO,WAAE,EAAA;;wBAArB,SAAqB,CAAC;;;;;KACzB;IAED,kCAAO,GAAP,UAAQ,CAAC;QACL,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE;YAEf,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClD;QAED,IAAI,OAAO;YACP,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAxBQ,gBAAgB;QAD5B,mBAAQ,CAAC,SAAS,CAAC,wBAAwB,CAAC;OAChC,gBAAgB,CAyB5B;IAAD,uBAAC;CAAA,AAzBD,CAAsC,qBAAS,GAyB9C;AAzBY,4CAAgB"}
|