vsn 0.1.144 → 0.1.145
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/memory-leak-test.html +20 -4
- package/demo/resources/xhr-memory-leak-test.html +8 -0
- package/demo/vsn.js +2 -2
- package/dist/AST/FunctionCallNode.js +68 -115
- package/dist/AST/FunctionCallNode.js.map +1 -1
- package/dist/AST.d.ts +1 -1
- package/dist/AST.js +89 -45
- package/dist/AST.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/FunctionCallNode.ts +13 -22
- package/src/AST.ts +17 -9
- package/src/version.ts +1 -1
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -29,23 +29,20 @@ export class FunctionCallNode<T = any> extends Node implements TreeNode {
|
|
|
29
29
|
// @todo: Need to rewrite/refactor this. It's a bit of a mess with element queries.
|
|
30
30
|
let tags: Tag[] = [];
|
|
31
31
|
let functionScope: Scope = scope;
|
|
32
|
-
let functionName: string = '';
|
|
33
|
-
let instanceOfScopeMemberNode = false;
|
|
34
32
|
if (this.fnc instanceof ScopeMemberNode) {
|
|
35
|
-
instanceOfScopeMemberNode = true
|
|
36
|
-
functionScope = await this.fnc.scope.evaluate(scope, dom, tag);
|
|
37
|
-
functionName = await this.fnc.name.evaluate(scope, dom, tag);
|
|
38
33
|
if (this.fnc.scope instanceof ElementQueryNode) {
|
|
39
34
|
const _tags = await this.fnc.scope.evaluate(scope, dom, tag);
|
|
40
35
|
if (_tags instanceof Array) {
|
|
41
36
|
tags = _tags;
|
|
42
37
|
} else if (_tags instanceof Tag) {
|
|
43
38
|
tags = [_tags];
|
|
39
|
+
functionScope = _tags.scope;
|
|
44
40
|
} else {
|
|
45
41
|
throw new Error('Invalid element query result');
|
|
46
42
|
}
|
|
47
43
|
} else {
|
|
48
44
|
tags = [tag];
|
|
45
|
+
functionScope = await this.fnc.scope.evaluate(scope, dom, tag);
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
|
|
@@ -54,28 +51,22 @@ export class FunctionCallNode<T = any> extends Node implements TreeNode {
|
|
|
54
51
|
if (!func || func instanceof Array) {
|
|
55
52
|
const functionName = await (this.fnc as any).name.evaluate(scope, dom, tag);
|
|
56
53
|
const returnValues = [];
|
|
57
|
-
const toCleanup = [];
|
|
58
|
-
let calls = 0;
|
|
59
54
|
|
|
60
55
|
for (const _tag of tags) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
}
|
|
56
|
+
functionScope = _tag.scope;
|
|
57
|
+
func = functionScope.get(functionName);
|
|
58
|
+
if (func instanceof FunctionNode) {
|
|
59
|
+
returnValues.push(await (await func.evaluate(functionScope, dom, _tag) as any)(...values));
|
|
60
|
+
await func.collectGarbage();
|
|
61
|
+
} else if (typeof func === 'function') {
|
|
62
|
+
returnValues.push(func.call(functionScope, ...values));
|
|
63
|
+
await func.collectGarbage();
|
|
64
|
+
} else {
|
|
65
|
+
console.warn(`Function ${functionName} was not found in current scope.`);
|
|
73
66
|
}
|
|
74
67
|
}
|
|
75
68
|
|
|
76
|
-
|
|
77
|
-
await fnc.collectGarbage();
|
|
78
|
-
}
|
|
69
|
+
const calls = returnValues.length;
|
|
79
70
|
if (calls === 1) {
|
|
80
71
|
return returnValues[0];
|
|
81
72
|
} else if (calls === 0) {
|
package/src/AST.ts
CHANGED
|
@@ -558,21 +558,29 @@ export class Tree {
|
|
|
558
558
|
async bindToScopeChanges(scope, fnc, dom: DOM, tag: Tag = null) {
|
|
559
559
|
for (const node of this._root.findChildrenByTypes<ScopeMemberNode | ElementAttributeNode>([RootScopeMemberNode, ScopeMemberNode, ElementAttributeNode], 'ScopeMemberNodes')) {
|
|
560
560
|
let _scope: Scope = scope;
|
|
561
|
-
|
|
561
|
+
const name = await node.name.evaluate(scope, dom, tag);
|
|
562
|
+
if (node instanceof ScopeMemberNode) {
|
|
562
563
|
_scope = await node.scope.evaluate(scope, dom);
|
|
563
|
-
|
|
564
|
-
|
|
564
|
+
_scope.on(`change:${name}`, fnc);
|
|
565
|
+
} else if (node instanceof ElementAttributeNode && node.elementRef) {
|
|
566
|
+
const ref = await node.elementRef.evaluate(scope, dom, tag);
|
|
567
|
+
if (ref instanceof Tag) {
|
|
568
|
+
ref.scope.on(`change:${name}`, fnc);
|
|
569
|
+
} else if (ref instanceof Array) {
|
|
570
|
+
for (const tag of ref) {
|
|
571
|
+
tag.scope.on(`change:${name}`, fnc);
|
|
572
|
+
}
|
|
573
|
+
} else {
|
|
574
|
+
console.warn(`Cannot bind to changes for ${name}.`);
|
|
575
|
+
}
|
|
565
576
|
}
|
|
566
|
-
|
|
567
|
-
const name = await node.name.evaluate(scope, dom, tag);
|
|
568
|
-
_scope.on(`change:${name}`, fnc);
|
|
569
577
|
}
|
|
570
578
|
}
|
|
571
579
|
|
|
572
|
-
public static reprepareExecutingTrees() {
|
|
573
|
-
|
|
580
|
+
public static async reprepareExecutingTrees() {
|
|
581
|
+
for (const context of this.executing) {
|
|
574
582
|
await context.tree.prepare(context.scope, context.dom, context.tag);
|
|
575
|
-
}
|
|
583
|
+
}
|
|
576
584
|
}
|
|
577
585
|
|
|
578
586
|
public static tokenize(code: string): Token[] {
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.1.
|
|
1
|
+
export const VERSION = '0.1.145';
|
|
2
2
|
|