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 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);
@@ -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 projectionOrder;
14
- private routeVersion;
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
- * Takes a new snapshot of every source in the route a projection just wrote its output to. The
57
- * write cleared that route's snapshot, but nothing the projection read changed between its read
58
- * and the write, so without this the next run would read everything again for nothing.
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
- private RefreshSources;
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
- * Reads every route a wildcard path matches. While no route instance was added or removed since
73
- * the last read, the matches are the same, and a match whose route has the same snapshot keeps
74
- * the value it read.
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
- private ReadWildcard;
77
- private ReadMatch;
52
+ Snapshot(path: string): any;
78
53
  }