j-templates 5.0.46 → 5.0.47

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