j-templates 5.0.46 → 5.0.48
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.d.ts +2 -2
- package/DOM/domNodeConfig.js +91 -82
- package/DOM/elements.d.ts +24 -24
- package/DOM/elements.js +96 -96
- package/DOM/index.d.ts +3 -3
- package/DOM/index.js +19 -19
- package/DOM/svgElements.d.ts +4 -4
- package/DOM/svgElements.js +17 -17
- package/DOM/utils.d.ts +1 -1
- package/DOM/utils.js +47 -47
- package/DOM/window.d.ts +1 -1
- package/DOM/window.js +4 -4
- package/Node/boundNode.d.ts +4 -4
- package/Node/boundNode.js +99 -94
- package/Node/boundNode.types.d.ts +43 -43
- package/Node/boundNode.types.js +2 -2
- package/Node/component.d.ts +34 -34
- package/Node/component.js +80 -80
- package/Node/componentNode.d.ts +7 -7
- package/Node/componentNode.js +115 -115
- package/Node/componentNode.types.d.ts +35 -35
- package/Node/componentNode.types.js +2 -2
- package/Node/elementNode.d.ts +5 -5
- package/Node/elementNode.js +177 -158
- package/Node/elementNode.types.d.ts +39 -34
- package/Node/elementNode.types.js +2 -2
- package/Node/nodeConfig.d.ts +25 -22
- package/Node/nodeConfig.js +5 -5
- package/Node/nodeRef.d.ts +23 -21
- package/Node/nodeRef.js +182 -157
- package/Node/nodeRef.types.d.ts +21 -21
- package/Node/nodeRef.types.js +2 -2
- package/Store/Diff/diffAsync.d.ts +17 -17
- package/Store/Diff/diffAsync.js +36 -36
- package/Store/Diff/diffSync.d.ts +14 -14
- package/Store/Diff/diffSync.js +27 -27
- package/Store/Diff/diffTree.d.ts +24 -24
- package/Store/Diff/diffTree.js +232 -221
- package/Store/Diff/diffWorker.d.ts +3 -3
- package/Store/Diff/diffWorker.js +19 -19
- package/Store/Diff/workerQueue.d.ts +7 -7
- package/Store/Diff/workerQueue.js +35 -35
- package/Store/Store/store.d.ts +14 -14
- package/Store/Store/store.js +31 -31
- package/Store/Store/storeAsync.d.ts +20 -20
- package/Store/Store/storeAsync.js +49 -49
- package/Store/Store/storeAsyncWriter.d.ts +15 -15
- package/Store/Store/storeAsyncWriter.js +52 -52
- package/Store/Store/storeSync.d.ts +15 -15
- package/Store/Store/storeSync.js +33 -33
- package/Store/Store/storeSyncWriter.d.ts +12 -12
- package/Store/Store/storeSyncWriter.js +41 -41
- package/Store/Store/storeWriter.d.ts +9 -9
- package/Store/Store/storeWriter.js +30 -30
- package/Store/Tree/observableScope.d.ts +57 -56
- package/Store/Tree/observableScope.js +168 -164
- package/Store/Tree/observableTree.d.ts +34 -33
- package/Store/Tree/observableTree.js +233 -214
- package/Store/index.d.ts +4 -4
- package/Store/index.js +11 -11
- package/Utils/animation.d.ts +29 -29
- package/Utils/animation.js +108 -108
- package/Utils/asyncQueue.d.ts +8 -8
- package/Utils/asyncQueue.js +42 -42
- package/Utils/decorators.d.ts +37 -37
- package/Utils/decorators.js +310 -300
- package/Utils/emitter.d.ts +12 -12
- package/Utils/emitter.js +24 -24
- package/Utils/index.d.ts +2 -2
- package/Utils/index.js +18 -18
- package/Utils/injector.d.ts +13 -13
- package/Utils/injector.js +38 -38
- package/Utils/list.d.ts +26 -23
- package/Utils/list.js +158 -120
- package/Utils/router.d.ts +23 -23
- package/Utils/router.js +116 -116
- package/Utils/thread.d.ts +16 -16
- package/Utils/thread.js +108 -108
- package/Utils/utils.types.d.ts +3 -3
- package/Utils/utils.types.js +2 -2
- package/index.d.ts +2 -2
- package/index.js +5 -5
- package/jTemplates.js +2769 -2629
- package/jTemplates.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +1 -1
- package/web.export.d.ts +4 -4
- package/web.export.js +24 -24
- package/web.js +5 -5
package/Store/Diff/diffTree.js
CHANGED
|
@@ -1,221 +1,232 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DiffTreeScope = void 0;
|
|
4
|
-
function DiffTreeScope(worker) {
|
|
5
|
-
const ctx = this;
|
|
6
|
-
if (ctx && worker) {
|
|
7
|
-
let diffTree = null;
|
|
8
|
-
ctx.onmessage = function (event) {
|
|
9
|
-
var data = event.data;
|
|
10
|
-
switch (data.method) {
|
|
11
|
-
case "create":
|
|
12
|
-
var keyFunc = data.arguments[0] ? eval(data.arguments[0]) : undefined;
|
|
13
|
-
diffTree = new DiffTree(keyFunc);
|
|
14
|
-
ctx.postMessage(null);
|
|
15
|
-
break;
|
|
16
|
-
case "diffpath":
|
|
17
|
-
var diff = diffTree.DiffPath(data.arguments[0], data.arguments[1]);
|
|
18
|
-
ctx.postMessage(diff);
|
|
19
|
-
break;
|
|
20
|
-
case "diffbatch":
|
|
21
|
-
var diff = diffTree.DiffBatch(data.arguments[0]);
|
|
22
|
-
ctx.postMessage(diff);
|
|
23
|
-
break;
|
|
24
|
-
case "updatepath":
|
|
25
|
-
diffTree.UpdatePath(data.arguments[0], data.arguments[1]);
|
|
26
|
-
ctx.postMessage(null);
|
|
27
|
-
break;
|
|
28
|
-
case "getpath":
|
|
29
|
-
var ret = diffTree.GetPath(data.arguments[0]);
|
|
30
|
-
ctx.postMessage(ret);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
const jsonConstructor = {}.constructor;
|
|
36
|
-
function IsValue(value) {
|
|
37
|
-
if (!value)
|
|
38
|
-
return true;
|
|
39
|
-
return !(jsonConstructor === value.constructor || Array.isArray(value));
|
|
40
|
-
}
|
|
41
|
-
let Type;
|
|
42
|
-
(function (Type) {
|
|
43
|
-
Type[Type["Value"] = 0] = "Value";
|
|
44
|
-
Type[Type["Object"] = 1] = "Object";
|
|
45
|
-
Type[Type["Array"] = 2] = "Array";
|
|
46
|
-
})(Type || (Type = {}));
|
|
47
|
-
function TypeOf(value) {
|
|
48
|
-
if (!value)
|
|
49
|
-
return Type.Value;
|
|
50
|
-
if (jsonConstructor === value.constructor)
|
|
51
|
-
return Type.Object;
|
|
52
|
-
if (Array.isArray(value))
|
|
53
|
-
return Type.Array;
|
|
54
|
-
return Type.Value;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiffTreeScope = void 0;
|
|
4
|
+
function DiffTreeScope(worker) {
|
|
5
|
+
const ctx = this;
|
|
6
|
+
if (ctx && worker) {
|
|
7
|
+
let diffTree = null;
|
|
8
|
+
ctx.onmessage = function (event) {
|
|
9
|
+
var data = event.data;
|
|
10
|
+
switch (data.method) {
|
|
11
|
+
case "create":
|
|
12
|
+
var keyFunc = data.arguments[0] ? eval(data.arguments[0]) : undefined;
|
|
13
|
+
diffTree = new DiffTree(keyFunc);
|
|
14
|
+
ctx.postMessage(null);
|
|
15
|
+
break;
|
|
16
|
+
case "diffpath":
|
|
17
|
+
var diff = diffTree.DiffPath(data.arguments[0], data.arguments[1]);
|
|
18
|
+
ctx.postMessage(diff);
|
|
19
|
+
break;
|
|
20
|
+
case "diffbatch":
|
|
21
|
+
var diff = diffTree.DiffBatch(data.arguments[0]);
|
|
22
|
+
ctx.postMessage(diff);
|
|
23
|
+
break;
|
|
24
|
+
case "updatepath":
|
|
25
|
+
diffTree.UpdatePath(data.arguments[0], data.arguments[1]);
|
|
26
|
+
ctx.postMessage(null);
|
|
27
|
+
break;
|
|
28
|
+
case "getpath":
|
|
29
|
+
var ret = diffTree.GetPath(data.arguments[0]);
|
|
30
|
+
ctx.postMessage(ret);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const jsonConstructor = {}.constructor;
|
|
36
|
+
function IsValue(value) {
|
|
37
|
+
if (!value)
|
|
38
|
+
return true;
|
|
39
|
+
return !(jsonConstructor === value.constructor || Array.isArray(value));
|
|
40
|
+
}
|
|
41
|
+
let Type;
|
|
42
|
+
(function (Type) {
|
|
43
|
+
Type[Type["Value"] = 0] = "Value";
|
|
44
|
+
Type[Type["Object"] = 1] = "Object";
|
|
45
|
+
Type[Type["Array"] = 2] = "Array";
|
|
46
|
+
})(Type || (Type = {}));
|
|
47
|
+
function TypeOf(value) {
|
|
48
|
+
if (!value)
|
|
49
|
+
return Type.Value;
|
|
50
|
+
if (jsonConstructor === value.constructor)
|
|
51
|
+
return Type.Object;
|
|
52
|
+
if (Array.isArray(value))
|
|
53
|
+
return Type.Array;
|
|
54
|
+
return Type.Value;
|
|
55
|
+
}
|
|
56
|
+
function JsonDiffRecursive(path, newValue, oldValue, resp) {
|
|
57
|
+
if (newValue === oldValue)
|
|
58
|
+
return false;
|
|
59
|
+
const newType = TypeOf(newValue);
|
|
60
|
+
const oldType = TypeOf(oldValue);
|
|
61
|
+
const changedPathLength = resp.length;
|
|
62
|
+
let allChildrenChanged = true;
|
|
63
|
+
if (newType === oldType)
|
|
64
|
+
switch (newType) {
|
|
65
|
+
case Type.Array: {
|
|
66
|
+
allChildrenChanged = JsonDiffArrays(path, newValue, oldValue, resp);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
case Type.Object: {
|
|
70
|
+
allChildrenChanged = JsonDiffObjects(path, newValue, oldValue, resp);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (allChildrenChanged) {
|
|
75
|
+
resp.splice(changedPathLength);
|
|
76
|
+
resp.push({
|
|
77
|
+
path,
|
|
78
|
+
value: newValue
|
|
79
|
+
});
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
function JsonDiffArrays(path, newValue, oldValue, resp) {
|
|
85
|
+
let allChildrenChanged = true;
|
|
86
|
+
if (newValue.length !== oldValue.length)
|
|
87
|
+
resp.push({
|
|
88
|
+
path: path ? `${path}.length` : 'length',
|
|
89
|
+
value: newValue.length
|
|
90
|
+
});
|
|
91
|
+
if (newValue.length > 0 || oldValue.length > 0) {
|
|
92
|
+
for (let y = 0; y < newValue.length; y++) {
|
|
93
|
+
const arrayPath = path ? `${path}.${y}` : `${y}`;
|
|
94
|
+
allChildrenChanged = JsonDiffRecursive(arrayPath, newValue[y], oldValue[y], resp) && allChildrenChanged;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else
|
|
98
|
+
allChildrenChanged = false;
|
|
99
|
+
return allChildrenChanged;
|
|
100
|
+
}
|
|
101
|
+
function JsonDiffObjects(path, newValue, oldValue, resp) {
|
|
102
|
+
let allChildrenChanged = true;
|
|
103
|
+
const newKeys = Object.keys(newValue);
|
|
104
|
+
const oldKeys = Object.keys(oldValue);
|
|
105
|
+
if (newKeys.length === 0 && oldKeys.length === 0) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (newKeys.length >= oldKeys.length) {
|
|
109
|
+
let newKeyIndex = 0;
|
|
110
|
+
let oldKeyIndex = 0;
|
|
111
|
+
while (newKeyIndex < newKeys.length) {
|
|
112
|
+
const childPath = path ? `${path}.${newKeys[newKeyIndex]}` : newKeys[newKeyIndex];
|
|
113
|
+
if (oldKeyIndex < oldKeys.length && newKeys[newKeyIndex] === oldKeys[oldKeyIndex]) {
|
|
114
|
+
allChildrenChanged =
|
|
115
|
+
JsonDiffRecursive(childPath, newValue[newKeys[newKeyIndex]], oldValue[oldKeys[oldKeyIndex]], resp) &&
|
|
116
|
+
allChildrenChanged;
|
|
117
|
+
oldKeyIndex++;
|
|
118
|
+
}
|
|
119
|
+
else if (newValue[newKeys[newKeyIndex]] !== undefined) {
|
|
120
|
+
resp.push({
|
|
121
|
+
path: childPath,
|
|
122
|
+
value: newValue[newKeys[newKeyIndex]]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
newKeyIndex++;
|
|
126
|
+
}
|
|
127
|
+
if (oldKeyIndex < oldKeys.length)
|
|
128
|
+
allChildrenChanged = true;
|
|
129
|
+
}
|
|
130
|
+
return allChildrenChanged;
|
|
131
|
+
}
|
|
132
|
+
function BreakUpValue(path, parent, keyFunc, prop, map) {
|
|
133
|
+
const value = prop ? parent[prop] : parent;
|
|
134
|
+
const isValue = IsValue(value);
|
|
135
|
+
if (!map && isValue)
|
|
136
|
+
return new Map([[path, value]]);
|
|
137
|
+
map = map || new Map();
|
|
138
|
+
if (isValue)
|
|
139
|
+
return map;
|
|
140
|
+
const key = keyFunc ? keyFunc(value) : null;
|
|
141
|
+
const keyRef = key && DiffTree.GetKeyRef(key);
|
|
142
|
+
if (key && key !== path) {
|
|
143
|
+
if (prop)
|
|
144
|
+
parent[prop] = keyRef;
|
|
145
|
+
BreakUpValue(key, value, keyFunc, null, map);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
for (const subProp in value) {
|
|
149
|
+
const childPath = `${path}.${subProp}`;
|
|
150
|
+
BreakUpValue(childPath, value, keyFunc, subProp, map);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (!prop)
|
|
154
|
+
map.set(path, key === path ? value : keyRef || value);
|
|
155
|
+
return map;
|
|
156
|
+
}
|
|
157
|
+
class DiffTree {
|
|
158
|
+
keyFunc;
|
|
159
|
+
rootStateMap = new Map();
|
|
160
|
+
constructor(keyFunc) {
|
|
161
|
+
this.keyFunc = keyFunc;
|
|
162
|
+
}
|
|
163
|
+
static GetKeyRef(key) {
|
|
164
|
+
return `___DiffTreeKeyRef.${key}`;
|
|
165
|
+
}
|
|
166
|
+
static ReadKeyRef(ref) {
|
|
167
|
+
if (!ref)
|
|
168
|
+
return undefined;
|
|
169
|
+
var matches = ref.match(/^___DiffTreeKeyRef\.([^.]+$)/);
|
|
170
|
+
if (!matches)
|
|
171
|
+
return undefined;
|
|
172
|
+
return matches[1];
|
|
173
|
+
}
|
|
174
|
+
DiffBatch(data) {
|
|
175
|
+
var resp = [];
|
|
176
|
+
;
|
|
177
|
+
for (var x = 0; x < data.length; x++)
|
|
178
|
+
this.RunDiff(data[x].path, data[x].value, resp);
|
|
179
|
+
return resp;
|
|
180
|
+
}
|
|
181
|
+
DiffPath(path, value) {
|
|
182
|
+
var resp = [];
|
|
183
|
+
this.RunDiff(path, value, resp);
|
|
184
|
+
return resp;
|
|
185
|
+
}
|
|
186
|
+
UpdatePath(path, value) {
|
|
187
|
+
this.SetPathValue(path, value);
|
|
188
|
+
}
|
|
189
|
+
GetPath(path) {
|
|
190
|
+
return this.GetPathValue(path);
|
|
191
|
+
}
|
|
192
|
+
RunDiff(path, value, diffResp) {
|
|
193
|
+
var breakupMap = this.GetBreakUpMap(path, value);
|
|
194
|
+
var resp = diffResp || [];
|
|
195
|
+
breakupMap.forEach((value, key) => {
|
|
196
|
+
var currentValue = key.split(".").reduce((pre, curr, index) => {
|
|
197
|
+
if (index === 0)
|
|
198
|
+
return this.rootStateMap.get(curr);
|
|
199
|
+
return pre && pre[curr];
|
|
200
|
+
}, null);
|
|
201
|
+
JsonDiffRecursive(key, value, currentValue, resp);
|
|
202
|
+
});
|
|
203
|
+
for (var x = 0; x < resp.length; x++)
|
|
204
|
+
this.SetPathValue(resp[x].path, resp[x].value);
|
|
205
|
+
}
|
|
206
|
+
GetPathValue(path) {
|
|
207
|
+
var parts = path.split(".");
|
|
208
|
+
var curr = this.rootStateMap.get(parts[0]);
|
|
209
|
+
for (var x = 1; x < parts.length; x++)
|
|
210
|
+
curr = curr && curr[parts[x]];
|
|
211
|
+
return curr;
|
|
212
|
+
}
|
|
213
|
+
SetPathValue(path, value) {
|
|
214
|
+
var parts = path.split(".");
|
|
215
|
+
if (parts.length === 1)
|
|
216
|
+
this.rootStateMap.set(parts[0], value);
|
|
217
|
+
else {
|
|
218
|
+
var curr = this.rootStateMap.get(parts[0]);
|
|
219
|
+
for (var x = 1; x < parts.length - 1; x++)
|
|
220
|
+
curr = curr[parts[x]];
|
|
221
|
+
curr[parts[parts.length - 1]] = value;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
GetBreakUpMap(path, value) {
|
|
225
|
+
if (!this.keyFunc)
|
|
226
|
+
return new Map([[path, value]]);
|
|
227
|
+
return BreakUpValue(path, value, this.keyFunc);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return DiffTree;
|
|
231
|
+
}
|
|
232
|
+
exports.DiffTreeScope = DiffTreeScope;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare namespace DiffWorker {
|
|
2
|
-
function Create(): Worker;
|
|
3
|
-
}
|
|
1
|
+
export declare namespace DiffWorker {
|
|
2
|
+
function Create(): Worker;
|
|
3
|
+
}
|
package/Store/Diff/diffWorker.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DiffWorker = void 0;
|
|
4
|
-
const diffTree_1 = require("./diffTree");
|
|
5
|
-
var DiffWorker;
|
|
6
|
-
(function (DiffWorker) {
|
|
7
|
-
var workerConstructor = null;
|
|
8
|
-
var workerParameter = null;
|
|
9
|
-
if (typeof Worker !== 'undefined') {
|
|
10
|
-
workerConstructor = Worker;
|
|
11
|
-
workerParameter = URL.createObjectURL(new Blob([`(${diffTree_1.DiffTreeScope}).call(this, true)`]));
|
|
12
|
-
}
|
|
13
|
-
function Create() {
|
|
14
|
-
if (!workerConstructor)
|
|
15
|
-
throw "Worker is not available";
|
|
16
|
-
return new workerConstructor(workerParameter);
|
|
17
|
-
}
|
|
18
|
-
DiffWorker.Create = Create;
|
|
19
|
-
})(DiffWorker
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiffWorker = void 0;
|
|
4
|
+
const diffTree_1 = require("./diffTree");
|
|
5
|
+
var DiffWorker;
|
|
6
|
+
(function (DiffWorker) {
|
|
7
|
+
var workerConstructor = null;
|
|
8
|
+
var workerParameter = null;
|
|
9
|
+
if (typeof Worker !== 'undefined') {
|
|
10
|
+
workerConstructor = Worker;
|
|
11
|
+
workerParameter = URL.createObjectURL(new Blob([`(${diffTree_1.DiffTreeScope}).call(this, true)`]));
|
|
12
|
+
}
|
|
13
|
+
function Create() {
|
|
14
|
+
if (!workerConstructor)
|
|
15
|
+
throw "Worker is not available";
|
|
16
|
+
return new workerConstructor(workerParameter);
|
|
17
|
+
}
|
|
18
|
+
DiffWorker.Create = Create;
|
|
19
|
+
})(DiffWorker || (exports.DiffWorker = DiffWorker = {}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare class WorkerQueue<S, R> {
|
|
2
|
-
private callbacks;
|
|
3
|
-
private worker;
|
|
4
|
-
constructor(worker: Worker);
|
|
5
|
-
Push(message: S): Promise<R>;
|
|
6
|
-
Destroy(): void;
|
|
7
|
-
}
|
|
1
|
+
export declare class WorkerQueue<S, R> {
|
|
2
|
+
private callbacks;
|
|
3
|
+
private worker;
|
|
4
|
+
constructor(worker: Worker);
|
|
5
|
+
Push(message: S): Promise<R>;
|
|
6
|
+
Destroy(): void;
|
|
7
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WorkerQueue = void 0;
|
|
4
|
-
const list_1 = require("../../Utils/list");
|
|
5
|
-
class WorkerQueue {
|
|
6
|
-
callbacks;
|
|
7
|
-
worker;
|
|
8
|
-
constructor(worker) {
|
|
9
|
-
this.worker = worker;
|
|
10
|
-
this.callbacks = list_1.List.Create();
|
|
11
|
-
this.worker.onerror = (err) => {
|
|
12
|
-
var cb = list_1.List.Pop(this.callbacks);
|
|
13
|
-
cb && cb(null, err);
|
|
14
|
-
};
|
|
15
|
-
this.worker.onmessage = (message) => {
|
|
16
|
-
var cb = list_1.List.Pop(this.callbacks);
|
|
17
|
-
cb && cb(message.data);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
Push(message) {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
list_1.List.Add(this.callbacks, function (data, err) {
|
|
23
|
-
if (err)
|
|
24
|
-
reject(err);
|
|
25
|
-
else
|
|
26
|
-
resolve(data);
|
|
27
|
-
});
|
|
28
|
-
this.worker.postMessage(message);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
Destroy() {
|
|
32
|
-
this.worker.terminate();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.WorkerQueue = WorkerQueue;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkerQueue = void 0;
|
|
4
|
+
const list_1 = require("../../Utils/list");
|
|
5
|
+
class WorkerQueue {
|
|
6
|
+
callbacks;
|
|
7
|
+
worker;
|
|
8
|
+
constructor(worker) {
|
|
9
|
+
this.worker = worker;
|
|
10
|
+
this.callbacks = list_1.List.Create();
|
|
11
|
+
this.worker.onerror = (err) => {
|
|
12
|
+
var cb = list_1.List.Pop(this.callbacks);
|
|
13
|
+
cb && cb(null, err);
|
|
14
|
+
};
|
|
15
|
+
this.worker.onmessage = (message) => {
|
|
16
|
+
var cb = list_1.List.Pop(this.callbacks);
|
|
17
|
+
cb && cb(message.data);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
Push(message) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
list_1.List.Add(this.callbacks, function (data, err) {
|
|
23
|
+
if (err)
|
|
24
|
+
reject(err);
|
|
25
|
+
else
|
|
26
|
+
resolve(data);
|
|
27
|
+
});
|
|
28
|
+
this.worker.postMessage(message);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
Destroy() {
|
|
32
|
+
this.worker.terminate();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.WorkerQueue = WorkerQueue;
|
package/Store/Store/store.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { StoreWriter } from "./storeWriter";
|
|
2
|
-
export declare class Store<T> {
|
|
3
|
-
private observableTree;
|
|
4
|
-
private storeWriter;
|
|
5
|
-
private rootScope;
|
|
6
|
-
get Root(): import("..").ObservableScope<T>;
|
|
7
|
-
constructor(init?: T);
|
|
8
|
-
Action(action: {
|
|
9
|
-
(root: T, writer: StoreWriter): void;
|
|
10
|
-
}): void;
|
|
11
|
-
Write(data: T): void;
|
|
12
|
-
Merge(data: Partial<T>): void;
|
|
13
|
-
Destroy(): void;
|
|
14
|
-
}
|
|
1
|
+
import { StoreWriter } from "./storeWriter";
|
|
2
|
+
export declare class Store<T> {
|
|
3
|
+
private observableTree;
|
|
4
|
+
private storeWriter;
|
|
5
|
+
private rootScope;
|
|
6
|
+
get Root(): import("..").ObservableScope<T>;
|
|
7
|
+
constructor(init?: T);
|
|
8
|
+
Action(action: {
|
|
9
|
+
(root: T, writer: StoreWriter): void;
|
|
10
|
+
}): void;
|
|
11
|
+
Write(data: T): void;
|
|
12
|
+
Merge(data: Partial<T>): void;
|
|
13
|
+
Destroy(): void;
|
|
14
|
+
}
|