vsn 0.1.137 → 0.1.139
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/resources/xhr-memory-leak-test.html +2 -586
- package/demo/vsn.js +2 -2
- package/dist/AST/ArithmeticNode.d.ts +1 -1
- package/dist/AST/ArithmeticNode.js +1 -1
- package/dist/AST/ArithmeticNode.js.map +1 -1
- package/dist/AST/ArrayNode.d.ts +1 -1
- package/dist/AST/ArrayNode.js +1 -1
- package/dist/AST/ArrayNode.js.map +1 -1
- package/dist/AST/AsNode.d.ts +1 -1
- package/dist/AST/AsNode.js +1 -1
- package/dist/AST/AsNode.js.map +1 -1
- package/dist/AST/AssignmentNode.d.ts +1 -1
- package/dist/AST/AssignmentNode.js +1 -1
- package/dist/AST/AssignmentNode.js.map +1 -1
- package/dist/AST/BlockNode.d.ts +1 -1
- package/dist/AST/BlockNode.js +1 -1
- package/dist/AST/BlockNode.js.map +1 -1
- package/dist/AST/ClassNode.d.ts +1 -1
- package/dist/AST/ClassNode.js +1 -1
- package/dist/AST/ClassNode.js.map +1 -1
- package/dist/AST/ComparisonNode.d.ts +1 -1
- package/dist/AST/ComparisonNode.js +1 -1
- package/dist/AST/ComparisonNode.js.map +1 -1
- package/dist/AST/ConditionalNode.d.ts +1 -1
- package/dist/AST/ConditionalNode.js +1 -1
- package/dist/AST/ConditionalNode.js.map +1 -1
- package/dist/AST/DispatchEventNode.d.ts +1 -1
- package/dist/AST/DispatchEventNode.js +1 -1
- package/dist/AST/DispatchEventNode.js.map +1 -1
- package/dist/AST/ElementAttributeNode.d.ts +1 -1
- package/dist/AST/ElementAttributeNode.js +1 -1
- package/dist/AST/ElementAttributeNode.js.map +1 -1
- package/dist/AST/ElementQueryNode.d.ts +1 -0
- package/dist/AST/ElementQueryNode.js +15 -0
- package/dist/AST/ElementQueryNode.js.map +1 -1
- package/dist/AST/ElementStyleNode.d.ts +1 -1
- package/dist/AST/ElementStyleNode.js +1 -1
- package/dist/AST/ElementStyleNode.js.map +1 -1
- package/dist/AST/ForStatementNode.d.ts +1 -1
- package/dist/AST/ForStatementNode.js +1 -1
- package/dist/AST/ForStatementNode.js.map +1 -1
- package/dist/AST/FunctionArgumentNode.d.ts +1 -1
- package/dist/AST/FunctionArgumentNode.js +1 -1
- package/dist/AST/FunctionArgumentNode.js.map +1 -1
- package/dist/AST/FunctionCallNode.d.ts +1 -1
- package/dist/AST/FunctionCallNode.js +1 -1
- package/dist/AST/FunctionCallNode.js.map +1 -1
- package/dist/AST/FunctionNode.d.ts +1 -1
- package/dist/AST/FunctionNode.js +1 -1
- package/dist/AST/FunctionNode.js.map +1 -1
- package/dist/AST/IfStatementNode.d.ts +1 -1
- package/dist/AST/IfStatementNode.js +1 -1
- package/dist/AST/IfStatementNode.js.map +1 -1
- package/dist/AST/InNode.d.ts +1 -1
- package/dist/AST/InNode.js +1 -1
- package/dist/AST/InNode.js.map +1 -1
- package/dist/AST/IndexNode.d.ts +1 -1
- package/dist/AST/IndexNode.js +1 -1
- package/dist/AST/IndexNode.js.map +1 -1
- package/dist/AST/LiteralNode.d.ts +1 -1
- package/dist/AST/LiteralNode.js +1 -1
- package/dist/AST/LiteralNode.js.map +1 -1
- package/dist/AST/ModifierNode.d.ts +1 -1
- package/dist/AST/ModifierNode.js +1 -1
- package/dist/AST/ModifierNode.js.map +1 -1
- package/dist/AST/NamedStackNode.d.ts +1 -1
- package/dist/AST/NamedStackNode.js +1 -1
- package/dist/AST/NamedStackNode.js.map +1 -1
- package/dist/AST/Node.d.ts +2 -1
- package/dist/AST/Node.js +19 -0
- package/dist/AST/Node.js.map +1 -1
- package/dist/AST/NotNode.d.ts +1 -1
- package/dist/AST/NotNode.js +1 -1
- package/dist/AST/NotNode.js.map +1 -1
- package/dist/AST/ObjectNode.d.ts +1 -1
- package/dist/AST/ObjectNode.js +1 -1
- package/dist/AST/ObjectNode.js.map +1 -1
- package/dist/AST/RootScopeMemberNode.d.ts +1 -1
- package/dist/AST/RootScopeMemberNode.js +1 -1
- package/dist/AST/RootScopeMemberNode.js.map +1 -1
- package/dist/AST/ScopeMemberNode.d.ts +1 -1
- package/dist/AST/ScopeMemberNode.js +1 -1
- package/dist/AST/ScopeMemberNode.js.map +1 -1
- package/dist/AST/StringFormatNode.d.ts +1 -1
- package/dist/AST/StringFormatNode.js +1 -1
- package/dist/AST/StringFormatNode.js.map +1 -1
- package/dist/AST/WithNode.d.ts +1 -1
- package/dist/AST/WithNode.js +1 -1
- package/dist/AST/WithNode.js.map +1 -1
- package/dist/AST/XHRNode.d.ts +1 -1
- package/dist/AST/XHRNode.js +1 -1
- package/dist/AST/XHRNode.js.map +1 -1
- package/dist/DOM/DOMObject.js +0 -1
- package/dist/DOM/DOMObject.js.map +1 -1
- package/dist/EventDispatcher.js +2 -1
- package/dist/EventDispatcher.js.map +1 -1
- package/dist/Scope/ScopeDataAbstract.js +1 -1
- package/dist/Scope/ScopeDataAbstract.js.map +1 -1
- package/dist/Scope.js +27 -13
- package/dist/Scope.js.map +1 -1
- package/dist/Tag.d.ts +3 -2
- package/dist/Tag.js +8 -0
- package/dist/Tag.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/AST/ArithmeticNode.ts +1 -1
- package/src/AST/ArrayNode.ts +1 -1
- package/src/AST/AsNode.ts +1 -1
- package/src/AST/AssignmentNode.ts +1 -1
- package/src/AST/BlockNode.ts +1 -1
- package/src/AST/ClassNode.ts +1 -1
- package/src/AST/ComparisonNode.ts +1 -1
- package/src/AST/ConditionalNode.ts +1 -1
- package/src/AST/DispatchEventNode.ts +1 -1
- package/src/AST/ElementAttributeNode.ts +1 -1
- package/src/AST/ElementQueryNode.ts +8 -2
- package/src/AST/ElementStyleNode.ts +1 -1
- package/src/AST/ForStatementNode.ts +1 -1
- package/src/AST/FunctionArgumentNode.ts +1 -1
- package/src/AST/FunctionCallNode.ts +1 -1
- package/src/AST/FunctionNode.ts +1 -1
- package/src/AST/IfStatementNode.ts +1 -1
- package/src/AST/InNode.ts +1 -1
- package/src/AST/IndexNode.ts +1 -1
- package/src/AST/LiteralNode.ts +1 -1
- package/src/AST/ModifierNode.ts +1 -1
- package/src/AST/NamedStackNode.ts +1 -1
- package/src/AST/Node.ts +9 -2
- package/src/AST/NotNode.ts +1 -1
- package/src/AST/ObjectNode.ts +1 -1
- package/src/AST/RootScopeMemberNode.ts +1 -1
- package/src/AST/ScopeMemberNode.ts +1 -1
- package/src/AST/StringFormatNode.ts +1 -1
- package/src/AST/WithNode.ts +1 -1
- package/src/AST/XHRNode.ts +1 -1
- package/src/DOM/DOMObject.ts +0 -1
- package/src/EventDispatcher.ts +2 -1
- package/src/Scope/ScopeDataAbstract.ts +2 -1
- package/src/Scope.ts +6 -1
- package/src/Tag.ts +7 -0
- package/src/version.ts +1 -1
package/src/AST/ModifierNode.ts
CHANGED
|
@@ -32,7 +32,7 @@ export class NamedStackNode extends Node implements TreeNode {
|
|
|
32
32
|
]
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
protected async _evaluate(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
36
36
|
if (scope instanceof FunctionScope) { // NamedStackNode doesn't work with FunctionScope
|
|
37
37
|
scope = scope.parentScope;
|
|
38
38
|
}
|
package/src/AST/Node.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Scope} from "../Scope";
|
|
2
2
|
import {DOM} from "../DOM";
|
|
3
|
-
import {Tag} from "../Tag";
|
|
3
|
+
import {Tag, TagState} from "../Tag";
|
|
4
4
|
import {Token, TokenType, TreeNode} from "../AST";
|
|
5
5
|
import {Modifiers} from "../Modifiers";
|
|
6
6
|
|
|
@@ -14,7 +14,14 @@ export abstract class Node implements TreeNode {
|
|
|
14
14
|
protected childNodes: Node[];
|
|
15
15
|
protected nodeCache: {[key: string]: Node[]} = {};
|
|
16
16
|
public readonly modifiers: Modifiers = new Modifiers();
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
async evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<any> {
|
|
19
|
+
if (scope.isGarbage || (tag && tag.state === TagState.Deconstructed))
|
|
20
|
+
return;
|
|
21
|
+
return await this._evaluate(scope, dom, tag);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected async _evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<any> {}
|
|
18
25
|
|
|
19
26
|
isPreparationRequired(): boolean {
|
|
20
27
|
if (this.requiresPrep)
|
package/src/AST/NotNode.ts
CHANGED
|
@@ -11,7 +11,7 @@ export class NotNode extends Node implements TreeNode {
|
|
|
11
11
|
super();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
protected async _evaluate(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
15
15
|
const flipping = await this.toFlip.evaluate(scope, dom, tag);
|
|
16
16
|
return !flipping;
|
|
17
17
|
}
|
package/src/AST/ObjectNode.ts
CHANGED
|
@@ -16,7 +16,7 @@ export class ObjectNode extends Node implements TreeNode {
|
|
|
16
16
|
return new Array(...this.values);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
async
|
|
19
|
+
protected async _evaluate(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
20
20
|
const obj: Scope = new Scope();
|
|
21
21
|
for (let i = 0; i < this.values.length; i++) {
|
|
22
22
|
const key = this.keys[i];
|
|
@@ -18,7 +18,7 @@ export class RootScopeMemberNode<T = any> extends ScopeNodeAbstract implements T
|
|
|
18
18
|
]
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
async
|
|
21
|
+
protected async _evaluate(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
22
22
|
const name = await this.name.evaluate(scope, dom, tag);
|
|
23
23
|
await this.applyModifiers(name, scope, dom, tag);
|
|
24
24
|
const value = scope.get(name);
|
|
@@ -25,7 +25,7 @@ export class ScopeMemberNode extends ScopeNodeAbstract implements TreeNode {
|
|
|
25
25
|
]
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async
|
|
28
|
+
protected async _evaluate(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
29
29
|
let scopes = [];
|
|
30
30
|
const values = [];
|
|
31
31
|
if (this.scope instanceof ElementQueryNode) {
|
|
@@ -16,7 +16,7 @@ export class StringFormatNode extends Node implements TreeNode {
|
|
|
16
16
|
return this.segments && Object.values(this.segments) || [];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
async
|
|
19
|
+
protected async _evaluate(scope: Scope, dom: DOM, tag?: Tag) {
|
|
20
20
|
let value = this.value;
|
|
21
21
|
for (const key in this.segments) {
|
|
22
22
|
const segment = this.segments[key];
|
package/src/AST/WithNode.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class WithNode extends Node implements TreeNode {
|
|
|
23
23
|
]
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
protected async _evaluate(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
27
27
|
const context = await this.context.evaluate(scope, dom, tag);
|
|
28
28
|
let tags = [];
|
|
29
29
|
if (context instanceof TagList) {
|
package/src/AST/XHRNode.ts
CHANGED
|
@@ -22,7 +22,7 @@ export class XHRNode extends Node implements TreeNode {
|
|
|
22
22
|
return nodes;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
async
|
|
25
|
+
protected async _evaluate(scope: Scope, dom: DOM, tag?: Tag) {
|
|
26
26
|
let url = await this.url.evaluate(scope, dom, tag);
|
|
27
27
|
let method: string;
|
|
28
28
|
let data = this.left ? await this.left.evaluate(scope, dom, tag) : {};
|
package/src/DOM/DOMObject.ts
CHANGED
package/src/EventDispatcher.ts
CHANGED
|
@@ -51,8 +51,9 @@ export class EventDispatcher {
|
|
|
51
51
|
deconstruct() {
|
|
52
52
|
this.dispatch('deconstruct', this);
|
|
53
53
|
const sourceIndex = EventDispatcher.sources.indexOf(this);
|
|
54
|
-
if (sourceIndex > -1)
|
|
54
|
+
if (sourceIndex > -1) {
|
|
55
55
|
EventDispatcher.sources.splice(sourceIndex, 1);
|
|
56
|
+
}
|
|
56
57
|
|
|
57
58
|
for (const k in this._listeners) {
|
|
58
59
|
for (const cb of this._listeners[k]) {
|
|
@@ -25,7 +25,7 @@ export class ScopeDataAbstract extends EventDispatcher {
|
|
|
25
25
|
deconstruct() {
|
|
26
26
|
super.deconstruct();
|
|
27
27
|
this._lastData = null;
|
|
28
|
-
for (const prop of this.__properties__) {
|
|
28
|
+
for (const prop of Array.from(this.__properties__)) {
|
|
29
29
|
this.removeProperty(prop);
|
|
30
30
|
}
|
|
31
31
|
this.__properties__.length = 0;
|
|
@@ -39,6 +39,7 @@ export class ScopeDataAbstract extends EventDispatcher {
|
|
|
39
39
|
if (this.hasProperty(name)) {
|
|
40
40
|
return this.getProperty(name);
|
|
41
41
|
}
|
|
42
|
+
|
|
42
43
|
config = config || {};
|
|
43
44
|
const instance = new propertyType(config.default, config);
|
|
44
45
|
const propDesc = Object.getOwnPropertyDescriptor(this, name);
|
package/src/Scope.ts
CHANGED
|
@@ -29,12 +29,17 @@ export class Scope extends ScopeAbstract {
|
|
|
29
29
|
deconstruct() {
|
|
30
30
|
super.deconstruct();
|
|
31
31
|
this.collectGarbage(true);
|
|
32
|
+
|
|
32
33
|
this.wrapped = null;
|
|
33
34
|
if (this._data)
|
|
34
35
|
this._data.deconstruct();
|
|
35
36
|
this._data = null;
|
|
37
|
+
|
|
38
|
+
for (const child of this.children) {
|
|
39
|
+
child.deconstruct();
|
|
40
|
+
}
|
|
36
41
|
this.children.length = 0;
|
|
37
|
-
this.
|
|
42
|
+
this.parentScope = null;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
public get data(): ScopeData {
|
package/src/Tag.ts
CHANGED
|
@@ -19,6 +19,7 @@ export enum TagState {
|
|
|
19
19
|
AttributesExtracted,
|
|
20
20
|
AttributesConnected,
|
|
21
21
|
Built,
|
|
22
|
+
Deconstructed,
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export class Tag extends DOMObject {
|
|
@@ -412,6 +413,7 @@ export class Tag extends DOMObject {
|
|
|
412
413
|
}
|
|
413
414
|
|
|
414
415
|
public setElementAttribute(key: string, value: any) {
|
|
416
|
+
if (!this.element) return null;
|
|
415
417
|
if (this.isMagicAttribute(key)) {
|
|
416
418
|
if (key === '@text')
|
|
417
419
|
this.element.innerText = value;
|
|
@@ -441,6 +443,7 @@ export class Tag extends DOMObject {
|
|
|
441
443
|
}
|
|
442
444
|
|
|
443
445
|
public getElementAttribute(key: string): any {
|
|
446
|
+
if (!this.element) return null;
|
|
444
447
|
if (this.isMagicAttribute(key)) {
|
|
445
448
|
if (key === '@text')
|
|
446
449
|
return this.element.innerText;
|
|
@@ -620,6 +623,9 @@ export class Tag extends DOMObject {
|
|
|
620
623
|
}
|
|
621
624
|
|
|
622
625
|
protected handleEvent(eventType: string, e) {
|
|
626
|
+
if (this.state === TagState.Deconstructed)
|
|
627
|
+
return
|
|
628
|
+
|
|
623
629
|
if (e)
|
|
624
630
|
e.stopPropagation();
|
|
625
631
|
|
|
@@ -809,6 +815,7 @@ export class Tag extends DOMObject {
|
|
|
809
815
|
}
|
|
810
816
|
|
|
811
817
|
deconstruct() {
|
|
818
|
+
this._state = TagState.Deconstructed
|
|
812
819
|
const dom = this.dom || DOM.instance;
|
|
813
820
|
if (dom) {
|
|
814
821
|
dom.removedQueued(this.element);
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.1.
|
|
1
|
+
export const VERSION = '0.1.139';
|
|
2
2
|
|