j-templates 8.1.1 → 8.1.2
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/Diff/diffSync.js +3 -1
- package/Store/Diff/diffTree.js +14 -4
- package/package.json +1 -1
package/Store/Diff/diffSync.js
CHANGED
|
@@ -35,7 +35,9 @@ export class DiffSync {
|
|
|
35
35
|
}
|
|
36
36
|
SplicePath(path, start, deleteCount, items) {
|
|
37
37
|
const spliceResult = this.diffTree.SplicePath(path, start, deleteCount, items);
|
|
38
|
-
|
|
38
|
+
const projectionDiff = this.diffTree.RunProjections();
|
|
39
|
+
spliceResult.diffResult = spliceResult.diffResult.concat(projectionDiff);
|
|
40
|
+
// spliceResult.diffResult.push(...this.diffTree.RunProjections());
|
|
39
41
|
return spliceResult;
|
|
40
42
|
}
|
|
41
43
|
}
|
package/Store/Diff/diffTree.js
CHANGED
|
@@ -214,7 +214,7 @@ function BuildProjectionOrder(projections) {
|
|
|
214
214
|
* @returns Diff entries for every projection whose result changed
|
|
215
215
|
*/
|
|
216
216
|
function RunProjections(source, keyFunc, projections, memo) {
|
|
217
|
-
|
|
217
|
+
let diffResult = [];
|
|
218
218
|
for (let x = 0; x < projections.length; x++) {
|
|
219
219
|
const { id, reads, projection } = projections[x];
|
|
220
220
|
const values = [];
|
|
@@ -244,10 +244,19 @@ function RunProjections(source, keyFunc, projections, memo) {
|
|
|
244
244
|
if (!ArraysEqual(priorValues, values)) {
|
|
245
245
|
const result = projection(keys, ...values);
|
|
246
246
|
memo.set(id, values);
|
|
247
|
+
const diff = UpdateSource(source, PROJECTION_PREFIX + id, result, keyFunc);
|
|
248
|
+
diffResult = diffResult.concat(diff);
|
|
247
249
|
// The same diff-and-apply UpdateSource uses for any other write, so a keyed entity
|
|
248
250
|
// embedded in a projection's result is flattened to its own root like any other write,
|
|
249
251
|
// and the diff reported here is unfiltered, the same as DiffPath returns.
|
|
250
|
-
diffResult.push(
|
|
252
|
+
/* diffResult.push(
|
|
253
|
+
...UpdateSource(
|
|
254
|
+
source,
|
|
255
|
+
PROJECTION_PREFIX + id,
|
|
256
|
+
result,
|
|
257
|
+
keyFunc,
|
|
258
|
+
),
|
|
259
|
+
); */
|
|
251
260
|
}
|
|
252
261
|
}
|
|
253
262
|
}
|
|
@@ -294,12 +303,13 @@ function ResolveKeyPath(source, path, keyFunc) {
|
|
|
294
303
|
* @returns Diff results showing all changes made
|
|
295
304
|
*/
|
|
296
305
|
function UpdateSource(source, path, value, keyFunc) {
|
|
297
|
-
|
|
306
|
+
let diffResult = [];
|
|
298
307
|
if (keyFunc) {
|
|
299
308
|
const keyPath = ResolveKeyPath(source, path, keyFunc);
|
|
300
309
|
if (keyPath !== path) {
|
|
301
310
|
const keyDiffResult = UpdateSource(source, keyPath, value, keyFunc);
|
|
302
|
-
diffResult.
|
|
311
|
+
diffResult = diffResult.concat(keyDiffResult);
|
|
312
|
+
// diffResult.push(...keyDiffResult);
|
|
303
313
|
}
|
|
304
314
|
}
|
|
305
315
|
const [sourceValue] = GetPathValue(source, path);
|