j-templates 5.0.37 → 5.0.39
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/DOM/domNodeConfig.js +2 -1
- package/DOM/elements.js +1 -0
- package/DOM/index.js +17 -6
- package/DOM/svgElements.js +1 -0
- package/DOM/utils.js +1 -0
- package/DOM/window.js +1 -0
- package/Node/boundNode.js +1 -0
- package/Node/boundNode.types.d.ts +2 -2
- package/Node/component.d.ts +1 -1
- package/Node/component.js +13 -7
- package/Node/componentNode.js +8 -7
- package/Node/componentNode.types.d.ts +2 -2
- package/Node/elementNode.js +7 -6
- package/Node/elementNode.types.d.ts +2 -2
- package/Node/nodeConfig.js +1 -0
- package/Node/nodeRef.js +1 -0
- package/Node/nodeRef.types.d.ts +1 -1
- package/Store/Diff/diffAsync.js +3 -1
- package/Store/Diff/diffSync.js +3 -1
- package/Store/Diff/diffTree.d.ts +1 -1
- package/Store/Diff/diffTree.js +3 -1
- package/Store/Diff/diffWorker.js +1 -0
- package/Store/Diff/workerQueue.js +3 -0
- package/Store/Store/store.js +9 -9
- package/Store/Store/storeAsync.d.ts +1 -1
- package/Store/Store/storeAsync.js +7 -5
- package/Store/Store/storeAsyncWriter.d.ts +4 -5
- package/Store/Store/storeAsyncWriter.js +13 -13
- package/Store/Store/storeSync.js +10 -10
- package/Store/Store/storeSyncWriter.d.ts +4 -5
- package/Store/Store/storeSyncWriter.js +12 -14
- package/Store/Store/storeWriter.d.ts +4 -5
- package/Store/Store/storeWriter.js +13 -14
- package/Store/Tree/observableScope.js +8 -5
- package/Store/Tree/observableTree.d.ts +21 -12
- package/Store/Tree/observableTree.js +194 -67
- package/Store/index.js +5 -4
- package/Utils/animation.js +22 -12
- package/Utils/asyncQueue.js +3 -4
- package/Utils/decorators.d.ts +1 -1
- package/Utils/decorators.js +1 -0
- package/Utils/emitter.d.ts +2 -2
- package/Utils/emitter.js +1 -0
- package/Utils/index.js +16 -5
- package/Utils/injector.js +3 -0
- package/Utils/list.js +1 -0
- package/Utils/router.js +13 -9
- package/Utils/thread.d.ts +1 -1
- package/Utils/thread.js +1 -0
- package/index.js +2 -1
- package/jTemplates.js +521 -735
- package/jTemplates.js.map +1 -1
- package/package.json +1 -1
- package/web.export.js +21 -9
- 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,40 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StoreSyncWriter = void 0;
|
|
3
4
|
class StoreSyncWriter {
|
|
5
|
+
diffSync;
|
|
6
|
+
observableTree;
|
|
4
7
|
constructor(diffSync, observableTree) {
|
|
5
8
|
this.diffSync = diffSync;
|
|
6
9
|
this.observableTree = observableTree;
|
|
7
10
|
}
|
|
8
11
|
Write(source, data) {
|
|
9
|
-
var
|
|
10
|
-
var rootPath = proxy && proxy.___node.Path || "ROOT";
|
|
12
|
+
var rootPath = source && this.observableTree.GetPathOf(source) || "ROOT";
|
|
11
13
|
var diff = this.diffSync.DiffPath(rootPath, data);
|
|
12
14
|
this.ApplyChanges(diff);
|
|
13
15
|
}
|
|
14
16
|
Merge(source, data) {
|
|
15
|
-
var
|
|
16
|
-
var rootPath = proxy.___node.Path;
|
|
17
|
+
var rootPath = this.observableTree.GetPathOf(source);
|
|
17
18
|
var keys = Object.keys(data);
|
|
18
19
|
var message = keys.map(key => ({ path: `${rootPath}.${key}`, value: data[key] }));
|
|
19
20
|
var diff = this.diffSync.DiffBatch(message);
|
|
20
21
|
this.ApplyChanges(diff);
|
|
21
22
|
}
|
|
22
23
|
Push(source, data) {
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var rootPath = proxy.___node.Path;
|
|
26
|
-
var length = array.length;
|
|
24
|
+
var rootPath = this.observableTree.GetPathOf(source);
|
|
25
|
+
var length = source.length;
|
|
27
26
|
this.diffSync.UpdatePath(`${rootPath}.${length}`, data);
|
|
28
|
-
|
|
27
|
+
this.observableTree.Write(`${rootPath}.${length}`, data);
|
|
29
28
|
}
|
|
30
29
|
Splice(source, start, deleteCount, ...items) {
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
array = array.map(val => val);
|
|
30
|
+
var rootPath = this.observableTree.GetPathOf(source);
|
|
31
|
+
var proxy = this.observableTree.Get(rootPath);
|
|
32
|
+
const array = proxy.toJSON().slice();
|
|
35
33
|
array.splice(start, deleteCount, ...items);
|
|
36
34
|
this.diffSync.UpdatePath(rootPath, array);
|
|
37
|
-
|
|
35
|
+
this.observableTree.Write(rootPath, array);
|
|
38
36
|
}
|
|
39
37
|
ApplyChanges(diff) {
|
|
40
38
|
this.observableTree.WriteAll(diff);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ObservableTree } from "../Tree/observableTree";
|
|
2
|
-
import { ObservableProxy } from "../Tree/observableProxy";
|
|
3
2
|
export declare class StoreWriter {
|
|
4
3
|
private observableTree;
|
|
5
4
|
constructor(observableTree: ObservableTree);
|
|
6
|
-
Write<T>(source: T
|
|
7
|
-
Merge<T>(source: T
|
|
8
|
-
Push<T>(source: Array<T
|
|
9
|
-
Splice<T>(source: Array<T
|
|
5
|
+
Write<T>(source: T, data: any): void;
|
|
6
|
+
Merge<T>(source: T, data: Partial<T>): void;
|
|
7
|
+
Push<T>(source: Array<T>, data: T): void;
|
|
8
|
+
Splice<T>(source: Array<T>, start: number, deleteCount?: number, ...items: Array<T>): void;
|
|
10
9
|
}
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.StoreWriter = void 0;
|
|
4
4
|
class StoreWriter {
|
|
5
|
+
observableTree;
|
|
5
6
|
constructor(observableTree) {
|
|
6
7
|
this.observableTree = observableTree;
|
|
7
8
|
}
|
|
8
9
|
Write(source, data) {
|
|
9
|
-
|
|
10
|
-
var rootPath = proxy && proxy.___node.Path || "ROOT";
|
|
10
|
+
const rootPath = source && this.observableTree.GetPathOf(source) || "ROOT";
|
|
11
11
|
this.observableTree.Write(rootPath, data);
|
|
12
12
|
}
|
|
13
13
|
Merge(source, data) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.observableTree.Write(rootPath, data);
|
|
18
|
-
else
|
|
19
|
-
for (var key in data)
|
|
20
|
-
this.observableTree.Write(`${rootPath}.${key}`, data[key]);
|
|
14
|
+
const rootPath = this.observableTree.GetPathOf(source);
|
|
15
|
+
for (const key in data)
|
|
16
|
+
this.observableTree.Write(`${rootPath}.${key}`, data[key]);
|
|
21
17
|
}
|
|
22
18
|
Push(source, data) {
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
const rootPath = this.observableTree.GetPathOf(source);
|
|
20
|
+
this.observableTree.Write(`${rootPath}.${length}`, data);
|
|
25
21
|
}
|
|
26
22
|
Splice(source, start, deleteCount, ...items) {
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const json = source.toJSON();
|
|
24
|
+
const copy = json.slice();
|
|
25
|
+
copy.splice(start, deleteCount, ...items);
|
|
26
|
+
const rootPath = this.observableTree.GetPathOf(source);
|
|
27
|
+
this.observableTree.Write(rootPath, copy);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
exports.StoreWriter = StoreWriter;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObservableScope = exports.ObservableScopeWrapper = exports.ObservableScopeValue = void 0;
|
|
3
4
|
const emitter_1 = require("../../Utils/emitter");
|
|
4
5
|
class ObservableScopeValue {
|
|
5
|
-
|
|
6
|
-
this.scope = scope;
|
|
7
|
-
}
|
|
6
|
+
scope;
|
|
8
7
|
get Value() {
|
|
9
8
|
return ObservableScope.Value(this.scope);
|
|
10
9
|
}
|
|
10
|
+
constructor(scope) {
|
|
11
|
+
this.scope = scope;
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
14
|
exports.ObservableScopeValue = ObservableScopeValue;
|
|
13
15
|
class ObservableScopeWrapper extends ObservableScopeValue {
|
|
16
|
+
scopeEmitter;
|
|
14
17
|
constructor(scope) {
|
|
15
18
|
super(scope);
|
|
16
19
|
if (scope.emitter) {
|
|
@@ -131,8 +134,7 @@ function UpdateValue(scope) {
|
|
|
131
134
|
return;
|
|
132
135
|
scope.dirty = false;
|
|
133
136
|
var value = null;
|
|
134
|
-
var emitters = WatchAction(() => value = scope.getFunction());
|
|
135
|
-
UpdateEmitters(scope, emitters);
|
|
137
|
+
var emitters = scope.getFunction && WatchAction(() => value = scope.getFunction());
|
|
136
138
|
if (scope.async)
|
|
137
139
|
Promise.resolve(value).then(val => {
|
|
138
140
|
scope.value = val;
|
|
@@ -140,6 +142,7 @@ function UpdateValue(scope) {
|
|
|
140
142
|
});
|
|
141
143
|
else
|
|
142
144
|
scope.value = value;
|
|
145
|
+
UpdateEmitters(scope, emitters);
|
|
143
146
|
}
|
|
144
147
|
function DestroyScope(scope) {
|
|
145
148
|
if (!scope)
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ObservableScope } from "./observableScope";
|
|
1
|
+
import { ObservableScope } from "../Tree/observableScope";
|
|
3
2
|
export declare class ObservableTree {
|
|
4
3
|
private valuePathResolver?;
|
|
4
|
+
private undefinedScope;
|
|
5
|
+
private scopeCache;
|
|
6
|
+
private leafScopeCache;
|
|
7
|
+
private proxyCache;
|
|
8
|
+
private pathCache;
|
|
5
9
|
private rootStateMap;
|
|
6
|
-
private rootNodeMap;
|
|
7
10
|
constructor(valuePathResolver?: {
|
|
8
|
-
(value: string): string;
|
|
11
|
+
(value: string): string | undefined;
|
|
9
12
|
});
|
|
13
|
+
Get<O>(path: string): O;
|
|
14
|
+
GetPathOf(value: any): string;
|
|
15
|
+
Scope<O, R = O>(path: string, callback?: {
|
|
16
|
+
(obj: O): R;
|
|
17
|
+
}): ObservableScope<O | R>;
|
|
10
18
|
Write(path: string, value: any): void;
|
|
11
19
|
WriteAll(data: Array<{
|
|
12
20
|
path: string;
|
|
13
21
|
value: any;
|
|
14
22
|
}>): void;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
private GetParentScope;
|
|
24
|
+
private GetPropertyScope;
|
|
25
|
+
private GetValueProxy;
|
|
26
|
+
private ObjectProxyGetter;
|
|
27
|
+
private CreateObjectProxy;
|
|
28
|
+
private ArrayProxyGetter;
|
|
29
|
+
private CreateArrayProxy;
|
|
30
|
+
private CreateProxy;
|
|
22
31
|
private WritePath;
|
|
23
|
-
private
|
|
32
|
+
private UpdatePathCache;
|
|
24
33
|
}
|
|
@@ -1,91 +1,218 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
3
|
+
exports.ObservableTree = void 0;
|
|
4
|
+
const observableScope_1 = require("../Tree/observableScope");
|
|
5
|
+
var Type;
|
|
6
|
+
(function (Type) {
|
|
7
|
+
Type[Type["Value"] = 0] = "Value";
|
|
8
|
+
Type[Type["Object"] = 1] = "Object";
|
|
9
|
+
Type[Type["Array"] = 2] = "Array";
|
|
10
|
+
})(Type || (Type = {}));
|
|
11
|
+
const jsonConstructor = {}.constructor;
|
|
12
|
+
function TypeOf(value) {
|
|
13
|
+
if (!value)
|
|
14
|
+
return Type.Value;
|
|
15
|
+
if (jsonConstructor === value.constructor)
|
|
16
|
+
return Type.Object;
|
|
17
|
+
if (Array.isArray(value))
|
|
18
|
+
return Type.Array;
|
|
19
|
+
return Type.Value;
|
|
20
|
+
}
|
|
6
21
|
class ObservableTree {
|
|
22
|
+
valuePathResolver;
|
|
23
|
+
undefinedScope = observableScope_1.ObservableScope.Create(function () { return undefined; });
|
|
24
|
+
scopeCache = new WeakMap();
|
|
25
|
+
leafScopeCache = new WeakMap();
|
|
26
|
+
proxyCache = new WeakMap();
|
|
27
|
+
pathCache = new WeakMap();
|
|
28
|
+
rootStateMap = new Map();
|
|
7
29
|
constructor(valuePathResolver) {
|
|
8
30
|
this.valuePathResolver = valuePathResolver;
|
|
9
|
-
this.rootStateMap = new Map();
|
|
10
|
-
this.rootNodeMap = new Map();
|
|
11
|
-
}
|
|
12
|
-
Write(path, value) {
|
|
13
|
-
this.WritePath(path, value);
|
|
14
|
-
this.UpdatePathNode(path);
|
|
15
|
-
}
|
|
16
|
-
WriteAll(data) {
|
|
17
|
-
for (var x = 0; x < data.length; x++)
|
|
18
|
-
this.WritePath(data[x].path, data[x].value);
|
|
19
|
-
for (var y = 0; y < data.length; y++)
|
|
20
|
-
this.UpdatePathNode(data[y].path);
|
|
21
31
|
}
|
|
22
32
|
Get(path) {
|
|
23
|
-
|
|
24
|
-
if (index === 0)
|
|
25
|
-
return this.rootStateMap.get(curr);
|
|
26
|
-
return pre && pre[curr];
|
|
27
|
-
}, null);
|
|
28
|
-
}
|
|
29
|
-
GetNode(path) {
|
|
30
|
-
return path.split(".").reduce((pre, curr, index) => {
|
|
33
|
+
const val = path.split(".").reduce((pre, curr, index) => {
|
|
31
34
|
if (index === 0) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.rootNodeMap.set(curr, ret);
|
|
36
|
-
}
|
|
37
|
-
return ret;
|
|
35
|
+
let value = this.rootStateMap.get(curr);
|
|
36
|
+
const scope = this.GetParentScope(value);
|
|
37
|
+
return observableScope_1.ObservableScope.Value(scope);
|
|
38
38
|
}
|
|
39
|
-
return pre
|
|
39
|
+
return pre && pre[curr];
|
|
40
40
|
}, null);
|
|
41
|
+
return val;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
GetPathOf(value) {
|
|
44
|
+
if (value.toJSON && typeof value.toJSON === 'function')
|
|
45
|
+
value = value.toJSON();
|
|
46
|
+
return this.pathCache.get(value);
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
this.rootStateMap.clear();
|
|
48
|
-
this.rootNodeMap.forEach(node => node.Destroy());
|
|
49
|
-
this.rootNodeMap.clear();
|
|
50
|
-
}
|
|
51
|
-
Scope(path, func) {
|
|
48
|
+
Scope(path, callback) {
|
|
52
49
|
return new observableScope_1.ObservableScope(() => {
|
|
53
|
-
|
|
54
|
-
return
|
|
50
|
+
const obj = this.Get(path);
|
|
51
|
+
return callback && callback(obj) || obj;
|
|
55
52
|
});
|
|
56
53
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
Write(path, value) {
|
|
55
|
+
const scope = this.WritePath(path, value);
|
|
56
|
+
observableScope_1.ObservableScope.Update(scope);
|
|
57
|
+
}
|
|
58
|
+
WriteAll(data) {
|
|
59
|
+
const scopeSet = new Set();
|
|
60
|
+
for (var x = 0; x < data.length; x++) {
|
|
61
|
+
const scope = this.WritePath(data[x].path, data[x].value);
|
|
62
|
+
scopeSet.add(scope);
|
|
63
|
+
}
|
|
64
|
+
scopeSet.forEach(scope => observableScope_1.ObservableScope.Update(scope));
|
|
65
|
+
}
|
|
66
|
+
GetParentScope(value) {
|
|
67
|
+
const type = TypeOf(value);
|
|
68
|
+
if (type === Type.Value) {
|
|
69
|
+
if (this.valuePathResolver && typeof value === 'string') {
|
|
70
|
+
const path = this.valuePathResolver(value);
|
|
71
|
+
if (path) {
|
|
72
|
+
const val = this.rootStateMap.get(path);
|
|
73
|
+
return this.GetParentScope(val);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return value === undefined ? this.undefinedScope : observableScope_1.ObservableScope.Create(value);
|
|
77
|
+
}
|
|
78
|
+
let scope = this.scopeCache.get(value);
|
|
79
|
+
if (!scope) {
|
|
80
|
+
scope = observableScope_1.ObservableScope.Create(() => this.GetValueProxy(value));
|
|
81
|
+
this.scopeCache.set(value, scope);
|
|
82
|
+
}
|
|
83
|
+
return scope;
|
|
84
|
+
}
|
|
85
|
+
GetPropertyScope(parent, prop) {
|
|
86
|
+
const value = parent[prop];
|
|
87
|
+
const type = TypeOf(value);
|
|
88
|
+
if (type === Type.Value) {
|
|
89
|
+
let leafScopes = this.leafScopeCache.get(parent) || {};
|
|
90
|
+
leafScopes[prop] = leafScopes[prop] || observableScope_1.ObservableScope.Create(() => {
|
|
91
|
+
const parentScope = this.scopeCache.get(parent);
|
|
92
|
+
const parentValue = observableScope_1.ObservableScope.Value(parentScope);
|
|
93
|
+
const parentJson = parentValue.toJSON();
|
|
94
|
+
const currentValue = parentJson[prop];
|
|
95
|
+
let path;
|
|
96
|
+
if (this.valuePathResolver && typeof currentValue === 'string' && (path = this.valuePathResolver(currentValue)))
|
|
97
|
+
return this.Get(path);
|
|
98
|
+
return currentValue;
|
|
99
|
+
});
|
|
100
|
+
this.leafScopeCache.set(parent, leafScopes);
|
|
101
|
+
return leafScopes[prop];
|
|
102
|
+
}
|
|
62
103
|
else {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
104
|
+
let scope = this.scopeCache.get(value);
|
|
105
|
+
if (!scope) {
|
|
106
|
+
scope = observableScope_1.ObservableScope.Create(() => {
|
|
107
|
+
const parentScope = this.scopeCache.get(parent);
|
|
108
|
+
const parentValue = observableScope_1.ObservableScope.Value(parentScope);
|
|
109
|
+
const parentJson = parentValue.toJSON();
|
|
110
|
+
const currentValue = parentJson[prop];
|
|
111
|
+
return this.GetValueProxy(currentValue);
|
|
112
|
+
});
|
|
113
|
+
this.scopeCache.set(value, scope);
|
|
68
114
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
115
|
+
return scope;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
GetValueProxy(value) {
|
|
119
|
+
let proxy = this.proxyCache.get(value);
|
|
120
|
+
if (!proxy) {
|
|
121
|
+
proxy = this.CreateProxy(value);
|
|
122
|
+
this.proxyCache.set(value, proxy);
|
|
72
123
|
}
|
|
124
|
+
return proxy;
|
|
73
125
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
126
|
+
ObjectProxyGetter = (value, prop) => {
|
|
127
|
+
function toJSON() {
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
;
|
|
131
|
+
switch (prop) {
|
|
132
|
+
case "toJSON":
|
|
133
|
+
return toJSON;
|
|
134
|
+
default:
|
|
135
|
+
if (typeof prop === 'symbol')
|
|
136
|
+
return value[prop];
|
|
137
|
+
return observableScope_1.ObservableScope.Value(this.GetPropertyScope(value, prop));
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
CreateObjectProxy(value) {
|
|
141
|
+
return new Proxy(value, {
|
|
142
|
+
get: this.ObjectProxyGetter
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
ArrayProxyGetter = (value, prop) => {
|
|
146
|
+
function toJSON() {
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
;
|
|
150
|
+
switch (prop) {
|
|
151
|
+
case "toJSON":
|
|
152
|
+
return toJSON;
|
|
153
|
+
default:
|
|
154
|
+
if (typeof prop === 'symbol')
|
|
155
|
+
return value[prop];
|
|
156
|
+
if (isNaN(parseInt(prop))) {
|
|
157
|
+
const ret = value[prop];
|
|
158
|
+
if (typeof ret === 'function') {
|
|
159
|
+
const copy = value.map((val, index) => observableScope_1.ObservableScope.Value(this.GetPropertyScope(value, index.toString())));
|
|
160
|
+
return ret.bind(copy);
|
|
161
|
+
}
|
|
162
|
+
return ret;
|
|
86
163
|
}
|
|
87
|
-
|
|
164
|
+
return observableScope_1.ObservableScope.Value(this.GetPropertyScope(value, prop));
|
|
88
165
|
}
|
|
166
|
+
};
|
|
167
|
+
CreateArrayProxy(value) {
|
|
168
|
+
return new Proxy(value, {
|
|
169
|
+
get: this.ArrayProxyGetter
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
CreateProxy(value) {
|
|
173
|
+
const type = TypeOf(value);
|
|
174
|
+
switch (type) {
|
|
175
|
+
case Type.Object:
|
|
176
|
+
return this.CreateObjectProxy(value);
|
|
177
|
+
case Type.Array:
|
|
178
|
+
return this.CreateArrayProxy(value);
|
|
179
|
+
default:
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
WritePath(path, value) {
|
|
184
|
+
this.UpdatePathCache(path, value);
|
|
185
|
+
const pathParts = path.split(".");
|
|
186
|
+
if (pathParts.length === 1) {
|
|
187
|
+
const currentValue = this.rootStateMap.get(pathParts[0]);
|
|
188
|
+
this.rootStateMap.set(pathParts[0], value);
|
|
189
|
+
return currentValue === undefined ? this.undefinedScope : this.scopeCache.get(currentValue);
|
|
190
|
+
}
|
|
191
|
+
let parentValue;
|
|
192
|
+
let x = 0;
|
|
193
|
+
for (; x < pathParts.length - 1 && (x === 0 || parentValue); x++) {
|
|
194
|
+
if (x === 0)
|
|
195
|
+
parentValue = this.rootStateMap.get(pathParts[x]);
|
|
196
|
+
else
|
|
197
|
+
parentValue = parentValue && parentValue[pathParts[x]];
|
|
198
|
+
}
|
|
199
|
+
if (!parentValue)
|
|
200
|
+
throw new Error("Unable to write path: " + path + ". Falsey value found at: " + pathParts.slice(0, x).join("."));
|
|
201
|
+
const prop = pathParts[x];
|
|
202
|
+
const exists = Object.hasOwn(parentValue, prop);
|
|
203
|
+
parentValue[prop] = value;
|
|
204
|
+
const leafScopes = exists && this.leafScopeCache.get(parentValue);
|
|
205
|
+
return leafScopes && leafScopes[prop] || this.scopeCache.get(parentValue);
|
|
206
|
+
}
|
|
207
|
+
UpdatePathCache(path, value) {
|
|
208
|
+
const type = TypeOf(value);
|
|
209
|
+
if (type === Type.Value)
|
|
210
|
+
return;
|
|
211
|
+
this.pathCache.set(value, path);
|
|
212
|
+
const keys = Object.keys(value);
|
|
213
|
+
for (let x = 0; x < keys.length; x++)
|
|
214
|
+
this.UpdatePathCache(`${path}.${keys[x]}`, value[keys[x]]);
|
|
215
|
+
return value;
|
|
89
216
|
}
|
|
90
217
|
}
|
|
91
218
|
exports.ObservableTree = ObservableTree;
|
package/Store/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObservableScope = exports.StoreAsync = exports.StoreSync = exports.Store = void 0;
|
|
3
4
|
var store_1 = require("./Store/store");
|
|
4
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return store_1.Store; } });
|
|
5
6
|
var storeSync_1 = require("./Store/storeSync");
|
|
6
|
-
exports
|
|
7
|
+
Object.defineProperty(exports, "StoreSync", { enumerable: true, get: function () { return storeSync_1.StoreSync; } });
|
|
7
8
|
var storeAsync_1 = require("./Store/storeAsync");
|
|
8
|
-
exports
|
|
9
|
+
Object.defineProperty(exports, "StoreAsync", { enumerable: true, get: function () { return storeAsync_1.StoreAsync; } });
|
|
9
10
|
var observableScope_1 = require("./Tree/observableScope");
|
|
10
|
-
exports
|
|
11
|
+
Object.defineProperty(exports, "ObservableScope", { enumerable: true, get: function () { return observableScope_1.ObservableScope; } });
|
package/Utils/animation.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Animation = exports.AnimationType = void 0;
|
|
3
4
|
var StepFunctions;
|
|
4
5
|
(function (StepFunctions) {
|
|
5
6
|
function* EaseIn(count) {
|
|
@@ -21,6 +22,27 @@ var AnimationType;
|
|
|
21
22
|
AnimationType[AnimationType["EaseIn"] = 1] = "EaseIn";
|
|
22
23
|
})(AnimationType = exports.AnimationType || (exports.AnimationType = {}));
|
|
23
24
|
class Animation {
|
|
25
|
+
type;
|
|
26
|
+
frameCount;
|
|
27
|
+
frameTimings;
|
|
28
|
+
update;
|
|
29
|
+
animationTimeouts;
|
|
30
|
+
running;
|
|
31
|
+
start;
|
|
32
|
+
end;
|
|
33
|
+
enabled;
|
|
34
|
+
get Running() {
|
|
35
|
+
return this.running;
|
|
36
|
+
}
|
|
37
|
+
get Start() {
|
|
38
|
+
return this.start;
|
|
39
|
+
}
|
|
40
|
+
get End() {
|
|
41
|
+
return this.end;
|
|
42
|
+
}
|
|
43
|
+
get Enabled() {
|
|
44
|
+
return this.enabled;
|
|
45
|
+
}
|
|
24
46
|
constructor(type, duration, update) {
|
|
25
47
|
this.running = false;
|
|
26
48
|
this.start = null;
|
|
@@ -35,18 +57,6 @@ class Animation {
|
|
|
35
57
|
this.update = update;
|
|
36
58
|
this.animationTimeouts = [];
|
|
37
59
|
}
|
|
38
|
-
get Running() {
|
|
39
|
-
return this.running;
|
|
40
|
-
}
|
|
41
|
-
get Start() {
|
|
42
|
-
return this.start;
|
|
43
|
-
}
|
|
44
|
-
get End() {
|
|
45
|
-
return this.end;
|
|
46
|
-
}
|
|
47
|
-
get Enabled() {
|
|
48
|
-
return this.enabled;
|
|
49
|
-
}
|
|
50
60
|
Animate(start, end) {
|
|
51
61
|
if (!this.enabled)
|
|
52
62
|
return;
|
package/Utils/asyncQueue.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncQueue = void 0;
|
|
3
4
|
const list_1 = require("./list");
|
|
4
5
|
class AsyncQueue {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.queue = list_1.List.Create();
|
|
8
|
-
}
|
|
6
|
+
running = false;
|
|
7
|
+
queue = list_1.List.Create();
|
|
9
8
|
Next(callback) {
|
|
10
9
|
const ret = new Promise((resolve, reject) => {
|
|
11
10
|
list_1.List.Add(this.queue, async function () {
|
package/Utils/decorators.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare namespace Destroy {
|
|
|
22
22
|
declare function DestroyDecorator<T extends Component<any, any, any> & Record<K, IDestroyable>, K extends string>(target: T, propertyKey: K): any;
|
|
23
23
|
export declare function PreReqTemplate(template: {
|
|
24
24
|
(): NodeRefTypes | NodeRefTypes[];
|
|
25
|
-
}): <T extends Component<any, any, any>>(target: new (...args: any
|
|
25
|
+
}): <T extends Component<any, any, any>>(target: new (...args: Array<any>) => T) => any;
|
|
26
26
|
export declare namespace PreReqTemplate {
|
|
27
27
|
function Get(value: any): NodeRefTypes[];
|
|
28
28
|
}
|
package/Utils/decorators.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreReq = exports.PreReqTemplate = exports.Destroy = exports.Inject = exports.ComputedAsync = exports.Computed = exports.DestroyScope = exports.Scope = exports.StateAsync = exports.StateSync = exports.State = void 0;
|
|
3
4
|
const store_1 = require("../Store/Store/store");
|
|
4
5
|
const Store_1 = require("../Store");
|
|
5
6
|
const observableScope_1 = require("../Store/Tree/observableScope");
|
package/Utils/emitter.d.ts
CHANGED
package/Utils/emitter.js
CHANGED
package/Utils/index.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
__exportStar(require("./decorators"), exports);
|
|
18
|
+
__exportStar(require("./animation"), exports);
|
package/Utils/injector.js
CHANGED