j-templates 8.2.0 → 9.0.1
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/Node/vNode.js +2 -0
- package/Store/Diff/diffTree.d.ts +24 -49
- package/Store/Diff/diffTree.js +112 -511
- package/Store/Diff/index.d.ts +1 -0
- package/Store/Diff/index.js +1 -0
- package/Store/Diff/utils/diffTree.types.d.ts +6 -1
- package/Store/Diff/utils/homes.d.ts +46 -0
- package/Store/Diff/utils/homes.js +213 -0
- package/Store/Diff/utils/paths.d.ts +42 -0
- package/Store/Diff/utils/paths.js +87 -0
- package/Store/Diff/utils/projections.d.ts +55 -0
- package/Store/Diff/utils/projections.js +290 -0
- package/Store/Diff/utils/routes.d.ts +27 -0
- package/Store/Diff/utils/routes.js +168 -0
- package/Store/Diff/utils/state.d.ts +56 -0
- package/Store/Diff/utils/state.js +155 -0
- package/Store/Store/store.d.ts +8 -0
- package/Store/Store/store.js +13 -0
- package/Store/Store/storeAsync.js +7 -6
- package/Store/Store/storeSync.js +3 -3
- package/Store/Tree/observableNode.js +18 -15
- package/Store/Tree/observableScope.d.ts +1 -0
- package/Store/Tree/observableScope.js +4 -0
- package/Store/Tree/snapshot.d.ts +19 -21
- package/Store/Tree/snapshot.js +29 -23
- package/Utils/json.d.ts +166 -26
- package/Utils/json.js +510 -183
- package/package.json +1 -1
- package/Store/Diff/utils/diffTree.utils.d.ts +0 -79
- package/Store/Diff/utils/diffTree.utils.js +0 -398
package/Node/vNode.js
CHANGED
|
@@ -312,6 +312,8 @@ function ScheduledAssignment(assign) {
|
|
|
312
312
|
return;
|
|
313
313
|
scheduled = true;
|
|
314
314
|
NodeConfig.scheduleUpdate(function () {
|
|
315
|
+
if (ObservableScope.IsDestroyed(scope))
|
|
316
|
+
return;
|
|
315
317
|
scheduled = false;
|
|
316
318
|
const value = ObservableScope.Peek(scope);
|
|
317
319
|
assign(value);
|
package/Store/Diff/diffTree.d.ts
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { JsonDiffResult } from '../../Utils/json';
|
|
2
2
|
import { IKeyFunc, IRouteDefinitions } from './utils/diffTree.types';
|
|
3
|
+
/**
|
|
4
|
+
* A tree of JSON state in routes, with projections, that tracks its changes as diffs. The work is
|
|
5
|
+
* split across `utils/`:
|
|
6
|
+
* - `homes`: writes, which keep every keyed value at its home
|
|
7
|
+
* - `state`: reading and writing route state, and snapshots of it
|
|
8
|
+
* - `routes`: route instances, created from the route definitions
|
|
9
|
+
* - `projections`: running each route instance's projections
|
|
10
|
+
* - `paths`: path strings
|
|
11
|
+
*/
|
|
3
12
|
export declare class DiffTree {
|
|
4
|
-
private keyFunc?;
|
|
5
|
-
private routeDefinitions;
|
|
6
13
|
private rootState;
|
|
7
|
-
private rootRoute;
|
|
8
|
-
private commitedSnapshot;
|
|
9
|
-
private routeCache;
|
|
10
|
-
private routeKeyFunc;
|
|
11
|
-
private resolver;
|
|
12
14
|
private snapshot;
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
+
private routes;
|
|
16
|
+
private projections;
|
|
17
|
+
/** Each root key's snapshot as of the last commit */
|
|
18
|
+
private commitedSnapshot;
|
|
19
|
+
private writeContext;
|
|
15
20
|
constructor(keyFunc?: IKeyFunc, routeDefinitions?: IRouteDefinitions);
|
|
16
21
|
WritePath(path: string, value: any): void;
|
|
17
22
|
PatchPath(path: string, patch: any): void;
|
|
18
23
|
PushPath(path: string, items: unknown[]): void;
|
|
19
24
|
SplicePath(path: string, start: number, deleteCount: number, items: any[]): void;
|
|
25
|
+
private Splice;
|
|
20
26
|
/**
|
|
21
27
|
* Deletes a route: its state, its child routes and projection outputs, and its route
|
|
22
28
|
* instances. The projection order is rebuilt on the next `RunProjections`, so deleting
|
|
@@ -30,49 +36,18 @@ export declare class DiffTree {
|
|
|
30
36
|
* @returns The value, or undefined when any segment of the path doesn't exist
|
|
31
37
|
*/
|
|
32
38
|
ReadPath(path: string): any;
|
|
33
|
-
/**
|
|
34
|
-
* Runs every projection of every route instance, dependencies first. A projection is skipped
|
|
35
|
-
* when no route it reads through changed since its last run, when a read's parent is missing,
|
|
36
|
-
* or when every read value is the same as its last run. Outputs are written as-is to
|
|
37
|
-
* `$projection_<key>` in their route, without a diff.
|
|
38
|
-
* @throws When projections depend on each other in a cycle
|
|
39
|
-
*/
|
|
39
|
+
/** Runs every projection of every route instance; see `Projections.Run` */
|
|
40
40
|
RunProjections(): void;
|
|
41
|
-
Commit(): JsonDiffResult;
|
|
42
|
-
Snapshot(path: string): any;
|
|
43
|
-
/**
|
|
44
|
-
* Finds the route instance for a route path (the portion of a path before the last `/`), creating it (and any missing
|
|
45
|
-
* parent instances) from the matching definition on first use.
|
|
46
|
-
* @returns The deepest route instance matched by a definition, or the root route when none matches
|
|
47
|
-
*/
|
|
48
|
-
private GetRouteInstance;
|
|
49
|
-
/**
|
|
50
|
-
* Whether every route a projection's reads resolved through on its last full read still has
|
|
51
|
-
* the snapshot it read: a write anywhere under a route clears its cached snapshot, so then no
|
|
52
|
-
* read can have changed. A wildcard read also needs the same route instances to exist.
|
|
53
|
-
*/
|
|
54
|
-
private SourcesUnchanged;
|
|
55
41
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
42
|
+
* The changes since the last commit. The root is a flat record of keys, so each key's snapshot
|
|
43
|
+
* is taken and compared on its own, without building a snapshot of the whole root: a key no
|
|
44
|
+
* write touched has the same cached snapshot as the last commit, and is skipped.
|
|
59
45
|
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Snapshots of the values at each path, read through the route's root object so keyed
|
|
63
|
-
* values resolve through their own copy.
|
|
64
|
-
* @param sources Filled with what each read resolved through; a read after a missing one is left undefined
|
|
65
|
-
* @param previous The sources of the last full read, so a wildcard read reuses its unchanged matches
|
|
66
|
-
* @returns The values, or undefined when any of them is missing
|
|
67
|
-
*/
|
|
68
|
-
private ReadValues;
|
|
69
|
-
/** The value at a path, whether it was found, and the route it was read through, when there is one */
|
|
70
|
-
private ReadValue;
|
|
46
|
+
Commit(): JsonDiffResult;
|
|
71
47
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* the
|
|
48
|
+
* The snapshot of the value at a path. Only the path's first property is snapshotted, not
|
|
49
|
+
* its whole route.
|
|
50
|
+
* @returns The snapshot, or undefined when any segment of the path doesn't exist
|
|
75
51
|
*/
|
|
76
|
-
|
|
77
|
-
private ReadMatch;
|
|
52
|
+
Snapshot(path: string): any;
|
|
78
53
|
}
|