j-templates 5.0.37 → 5.0.38
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/Store/Store/store.js +2 -3
- package/Store/Store/storeAsync.d.ts +1 -1
- package/Store/Store/storeAsync.js +1 -5
- package/Store/Store/storeAsyncWriter.d.ts +4 -5
- package/Store/Store/storeAsyncWriter.js +9 -13
- package/Store/Store/storeSync.js +2 -3
- package/Store/Store/storeSyncWriter.d.ts +4 -5
- package/Store/Store/storeSyncWriter.js +9 -14
- package/Store/Store/storeWriter.d.ts +4 -5
- package/Store/Store/storeWriter.js +11 -14
- package/Store/Tree/observableScope.js +2 -2
- package/Store/Tree/observableTree.d.ts +21 -12
- package/Store/Tree/observableTree.js +191 -67
- package/Utils/thread.d.ts +1 -1
- package/jTemplates.js +227 -412
- package/jTemplates.js.map +1 -1
- package/package.json +1 -1
- package/Store/Tree/observableNode.d.ts +0 -32
- package/Store/Tree/observableNode.js +0 -148
- package/Store/Tree/observableProxy.d.ts +0 -17
- package/Store/Tree/observableProxy.js +0 -119
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ObservableTree } from "./observableTree";
|
|
2
|
-
import { Type } from "./observableProxy";
|
|
3
|
-
export declare class ObservableNode {
|
|
4
|
-
private tree;
|
|
5
|
-
private key;
|
|
6
|
-
private parent;
|
|
7
|
-
private valuePathResolver;
|
|
8
|
-
private destroyed;
|
|
9
|
-
private children;
|
|
10
|
-
private path;
|
|
11
|
-
private scope;
|
|
12
|
-
private arrayScope;
|
|
13
|
-
get Key(): string;
|
|
14
|
-
get Path(): string;
|
|
15
|
-
get Value(): any;
|
|
16
|
-
get Type(): Type;
|
|
17
|
-
get Self(): ObservableNode;
|
|
18
|
-
get Proxy(): any;
|
|
19
|
-
get ProxyArray(): any[];
|
|
20
|
-
get Parent(): ObservableNode;
|
|
21
|
-
get Children(): Map<string, ObservableNode>;
|
|
22
|
-
constructor(tree: ObservableTree, key: string, parent: ObservableNode, valuePathResolver: {
|
|
23
|
-
(value: string): string;
|
|
24
|
-
});
|
|
25
|
-
UpdateKey(newKey: string): void;
|
|
26
|
-
EnsureChild(key: string): ObservableNode;
|
|
27
|
-
Update(): void;
|
|
28
|
-
ArrayUpdate(): void;
|
|
29
|
-
Destroy(): void;
|
|
30
|
-
Push(data: any): number;
|
|
31
|
-
Splice(start: number, deleteCount?: number, ...items: Array<any>): any[];
|
|
32
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const observableProxy_1 = require("./observableProxy");
|
|
4
|
-
const observableScope_1 = require("./observableScope");
|
|
5
|
-
class ObservableNode {
|
|
6
|
-
constructor(tree, key, parent, valuePathResolver) {
|
|
7
|
-
this.tree = tree;
|
|
8
|
-
this.key = key;
|
|
9
|
-
this.parent = parent;
|
|
10
|
-
this.valuePathResolver = valuePathResolver;
|
|
11
|
-
this.destroyed = false;
|
|
12
|
-
this.children = new Map();
|
|
13
|
-
this.path = undefined;
|
|
14
|
-
this.scope = observableScope_1.ObservableScope.Create(() => {
|
|
15
|
-
var value = this.tree.Get(this.Path);
|
|
16
|
-
var type = observableProxy_1.ObservableProxy.TypeOf(value);
|
|
17
|
-
var resolvedPath = this.valuePathResolver && type === observableProxy_1.Type.Value && typeof value === 'string' ? this.valuePathResolver(value) || this.Path : this.Path;
|
|
18
|
-
var self = this.Path === resolvedPath ? this : this.tree.GetNode(resolvedPath);
|
|
19
|
-
var proxy = this === self ?
|
|
20
|
-
type === observableProxy_1.Type.Value ?
|
|
21
|
-
value :
|
|
22
|
-
observableProxy_1.ObservableProxy.CreateFrom(this, type) :
|
|
23
|
-
self.Proxy;
|
|
24
|
-
return {
|
|
25
|
-
value: value,
|
|
26
|
-
type: observableProxy_1.ObservableProxy.TypeOf(value),
|
|
27
|
-
self: self,
|
|
28
|
-
proxy: proxy
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
get Key() {
|
|
33
|
-
return this.key;
|
|
34
|
-
}
|
|
35
|
-
get Path() {
|
|
36
|
-
if (this.path === undefined)
|
|
37
|
-
this.path = (this.parent ? this.parent.Path + "." : "") + this.key;
|
|
38
|
-
return this.path;
|
|
39
|
-
}
|
|
40
|
-
get Value() {
|
|
41
|
-
return observableScope_1.ObservableScope.Value(this.scope).value;
|
|
42
|
-
}
|
|
43
|
-
get Type() {
|
|
44
|
-
return observableScope_1.ObservableScope.Value(this.scope).type;
|
|
45
|
-
}
|
|
46
|
-
get Self() {
|
|
47
|
-
return observableScope_1.ObservableScope.Value(this.scope).self;
|
|
48
|
-
}
|
|
49
|
-
get Proxy() {
|
|
50
|
-
return observableScope_1.ObservableScope.Value(this.scope).proxy;
|
|
51
|
-
}
|
|
52
|
-
get ProxyArray() {
|
|
53
|
-
if (this.Type !== observableProxy_1.Type.Array) {
|
|
54
|
-
this.arrayScope && this.arrayScope.Destroy();
|
|
55
|
-
this.arrayScope = null;
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
this.arrayScope = this.arrayScope || observableScope_1.ObservableScope.Create(() => this.Value.map((c, i) => this.EnsureChild(i.toString()).Proxy));
|
|
59
|
-
return observableScope_1.ObservableScope.Value(this.arrayScope);
|
|
60
|
-
}
|
|
61
|
-
get Parent() {
|
|
62
|
-
return this.parent;
|
|
63
|
-
}
|
|
64
|
-
get Children() {
|
|
65
|
-
return this.children;
|
|
66
|
-
}
|
|
67
|
-
UpdateKey(newKey) {
|
|
68
|
-
if (!this.parent)
|
|
69
|
-
return;
|
|
70
|
-
this.parent.children.delete(this.key);
|
|
71
|
-
this.parent.children.set(newKey, this);
|
|
72
|
-
this.key = newKey;
|
|
73
|
-
this.path = undefined;
|
|
74
|
-
}
|
|
75
|
-
EnsureChild(key) {
|
|
76
|
-
var child = this.children.get(key);
|
|
77
|
-
if (!child) {
|
|
78
|
-
child = new ObservableNode(this.tree, key, this, this.valuePathResolver);
|
|
79
|
-
this.children.set(key, child);
|
|
80
|
-
}
|
|
81
|
-
return child;
|
|
82
|
-
}
|
|
83
|
-
Update() {
|
|
84
|
-
this.children.clear();
|
|
85
|
-
observableScope_1.ObservableScope.Update(this.scope);
|
|
86
|
-
}
|
|
87
|
-
ArrayUpdate() {
|
|
88
|
-
observableScope_1.ObservableScope.Update(this.arrayScope);
|
|
89
|
-
var lengthNode = this.children.get('length');
|
|
90
|
-
if (lengthNode)
|
|
91
|
-
lengthNode.Update();
|
|
92
|
-
observableScope_1.ObservableScope.Emit(this.scope);
|
|
93
|
-
}
|
|
94
|
-
Destroy() {
|
|
95
|
-
this.destroyed = true;
|
|
96
|
-
this.parent && !this.parent.destroyed && this.parent.Children.delete(this.key);
|
|
97
|
-
this.children.forEach(c => c.Destroy());
|
|
98
|
-
observableScope_1.ObservableScope.Destroy(this.scope);
|
|
99
|
-
observableScope_1.ObservableScope.Destroy(this.arrayScope);
|
|
100
|
-
}
|
|
101
|
-
Push(data) {
|
|
102
|
-
var array = this.Value;
|
|
103
|
-
if (!Array.isArray(array))
|
|
104
|
-
throw new Error("Node value is not an array.");
|
|
105
|
-
var ret = array.push(data);
|
|
106
|
-
this.ArrayUpdate();
|
|
107
|
-
return ret;
|
|
108
|
-
}
|
|
109
|
-
Splice(start, deleteCount, ...items) {
|
|
110
|
-
deleteCount = deleteCount || 0;
|
|
111
|
-
var array = this.Value;
|
|
112
|
-
if (!Array.isArray(array))
|
|
113
|
-
throw new Error("Node value is not an array.");
|
|
114
|
-
var startLength = array.length;
|
|
115
|
-
var ret = array.splice(start, deleteCount, ...items);
|
|
116
|
-
var x = start;
|
|
117
|
-
var key = null;
|
|
118
|
-
var newKey = null;
|
|
119
|
-
var child = null;
|
|
120
|
-
for (; x < (start + deleteCount); x++) {
|
|
121
|
-
key = x.toString();
|
|
122
|
-
child = this.Children.get(key);
|
|
123
|
-
if (child)
|
|
124
|
-
child.Destroy();
|
|
125
|
-
}
|
|
126
|
-
if (startLength < array.length)
|
|
127
|
-
for (var y = startLength - 1; y >= x; y--) {
|
|
128
|
-
key = y.toString();
|
|
129
|
-
child = this.Children.get(key);
|
|
130
|
-
if (child) {
|
|
131
|
-
newKey = (y - deleteCount + items.length).toString();
|
|
132
|
-
child.UpdateKey(newKey);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else
|
|
136
|
-
for (; x < startLength; x++) {
|
|
137
|
-
key = x.toString();
|
|
138
|
-
child = this.Children.get(key);
|
|
139
|
-
if (child) {
|
|
140
|
-
newKey = (x - deleteCount + items.length).toString();
|
|
141
|
-
child.UpdateKey(newKey);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
this.ArrayUpdate();
|
|
145
|
-
return ret;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
exports.ObservableNode = ObservableNode;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ObservableNode } from "./observableNode";
|
|
2
|
-
export declare enum Type {
|
|
3
|
-
Value = 0,
|
|
4
|
-
Object = 1,
|
|
5
|
-
Array = 2
|
|
6
|
-
}
|
|
7
|
-
export interface ObservableProxy {
|
|
8
|
-
___storeProxy: boolean;
|
|
9
|
-
___type: Type;
|
|
10
|
-
___node: ObservableNode;
|
|
11
|
-
toJSON(): any;
|
|
12
|
-
}
|
|
13
|
-
export declare namespace ObservableProxy {
|
|
14
|
-
function TypeOf(value: any): Type;
|
|
15
|
-
function CreateFrom(node: ObservableNode, type: Type): any;
|
|
16
|
-
function CopyValue<T>(value: T): T;
|
|
17
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Type;
|
|
4
|
-
(function (Type) {
|
|
5
|
-
Type[Type["Value"] = 0] = "Value";
|
|
6
|
-
Type[Type["Object"] = 1] = "Object";
|
|
7
|
-
Type[Type["Array"] = 2] = "Array";
|
|
8
|
-
})(Type = exports.Type || (exports.Type = {}));
|
|
9
|
-
var ObservableProxy;
|
|
10
|
-
(function (ObservableProxy) {
|
|
11
|
-
function TypeOf(value) {
|
|
12
|
-
if (!value)
|
|
13
|
-
return Type.Value;
|
|
14
|
-
if (Array.isArray(value))
|
|
15
|
-
return Type.Array;
|
|
16
|
-
else if (typeof value === 'object')
|
|
17
|
-
return Type.Object;
|
|
18
|
-
return Type.Value;
|
|
19
|
-
}
|
|
20
|
-
ObservableProxy.TypeOf = TypeOf;
|
|
21
|
-
function CreateFrom(node, type) {
|
|
22
|
-
switch (type) {
|
|
23
|
-
case Type.Array:
|
|
24
|
-
return CreateArrayProxy(node);
|
|
25
|
-
case Type.Object:
|
|
26
|
-
return CreateObjectProxy(node);
|
|
27
|
-
default:
|
|
28
|
-
throw new Error("Can't create proxy from Value type");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
ObservableProxy.CreateFrom = CreateFrom;
|
|
32
|
-
function CopyValue(value) {
|
|
33
|
-
var type = TypeOf(value);
|
|
34
|
-
if (type === Type.Value)
|
|
35
|
-
return value;
|
|
36
|
-
if (typeof value.toJSON === 'function')
|
|
37
|
-
return value.toJSON();
|
|
38
|
-
if (type === Type.Array)
|
|
39
|
-
return value.map(v => CopyValue(v));
|
|
40
|
-
else if (type === Type.Object) {
|
|
41
|
-
var ret = {};
|
|
42
|
-
for (var key in value)
|
|
43
|
-
ret[key] = CopyValue(value[key]);
|
|
44
|
-
return ret;
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
ObservableProxy.CopyValue = CopyValue;
|
|
49
|
-
})(ObservableProxy = exports.ObservableProxy || (exports.ObservableProxy = {}));
|
|
50
|
-
function CreateArrayProxy(node) {
|
|
51
|
-
return new Proxy([], {
|
|
52
|
-
get: (obj, prop) => {
|
|
53
|
-
switch (prop) {
|
|
54
|
-
case '___type':
|
|
55
|
-
return Type.Array;
|
|
56
|
-
case '___storeProxy':
|
|
57
|
-
return true;
|
|
58
|
-
case '___node':
|
|
59
|
-
return node;
|
|
60
|
-
case 'toJSON':
|
|
61
|
-
return () => {
|
|
62
|
-
return CopyNode(node);
|
|
63
|
-
};
|
|
64
|
-
case 'length':
|
|
65
|
-
return node.EnsureChild(prop).Value;
|
|
66
|
-
default:
|
|
67
|
-
if (typeof (prop) === 'symbol')
|
|
68
|
-
return node.ProxyArray[prop];
|
|
69
|
-
if (!isNaN(parseInt(prop)))
|
|
70
|
-
return node.EnsureChild(prop).Proxy;
|
|
71
|
-
var func = obj[prop];
|
|
72
|
-
return func && func.bind(node.ProxyArray);
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
ownKeys: () => {
|
|
76
|
-
return Reflect.ownKeys(node.Value);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function CreateObjectProxy(node) {
|
|
81
|
-
return new Proxy({}, {
|
|
82
|
-
get: (obj, prop) => {
|
|
83
|
-
switch (prop) {
|
|
84
|
-
case '___type':
|
|
85
|
-
return Type.Object;
|
|
86
|
-
case '___storeProxy':
|
|
87
|
-
return true;
|
|
88
|
-
case '___node':
|
|
89
|
-
return node;
|
|
90
|
-
case 'toJSON':
|
|
91
|
-
return () => {
|
|
92
|
-
return CopyNode(node);
|
|
93
|
-
};
|
|
94
|
-
default:
|
|
95
|
-
if (typeof (prop) !== 'symbol')
|
|
96
|
-
return node.EnsureChild(prop).Proxy;
|
|
97
|
-
return obj[prop];
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
ownKeys: () => {
|
|
101
|
-
return Reflect.ownKeys(node.Value);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function CopyNode(node) {
|
|
106
|
-
if (node.Type === Type.Value)
|
|
107
|
-
return node.Value;
|
|
108
|
-
var ret = null;
|
|
109
|
-
if (node.Type === Type.Array)
|
|
110
|
-
ret = node.Value.map((v, i) => CopyNode(node.Self.EnsureChild(i.toString()).Self));
|
|
111
|
-
else {
|
|
112
|
-
ret = {};
|
|
113
|
-
for (var key in node.Value) {
|
|
114
|
-
var child = node.Self.EnsureChild(key);
|
|
115
|
-
ret[key] = CopyNode(child.Self);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return ret;
|
|
119
|
-
}
|