You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// So, to read the content that was just inserted, the original object can be used and there is no need to read via the parent:
16
14
returnpoint;
@@ -22,83 +20,29 @@ function addPoint(curve: Curve, x: number, y: number): Point {
22
20
23
21
This feature is supported by doing some bookkeeping to ensure that the simple-tree objects,
24
22
flex tree nodes and anchor nodes in the tree get associated and disassociated at the right times.
25
-
There are three states that a node simple-tree node can be in: "raw", "marinated" and "cooked".
23
+
There are three states that a node simple-tree node can be in: "Unhydrated", "hydrating" and "Hydrated".
26
24
27
-
Note from the public API perspective, `Unhydrated` nodes are "raw", and hydrated nodes are either "marinated" or "cooked".
25
+
### Unhydrated Nodes
28
26
29
-
### Raw Proxies
30
-
31
-
A newly created simple-tree node, a.k.a. a **raw** simple-tree node. A raw simple-tree node is produced by invoking the schema-provided constructor for a node:
32
-
33
-
```ts
34
-
const rawPoint =newPoint({ x: 3, y: 3 });
35
-
```
36
-
37
-
Such a simple-tree node will be raw until it is inserted into the tree and becomes "marinated" (see below).
38
-
As raw nodes can be read or mutated.
39
-
40
-
### Marinated Proxies
41
-
42
-
Proxies become **marinated** as soon as they are inserted into the tree.
43
-
44
-
This happens whether proxies are inserted directly, as the root of the content subtree...
27
+
A newly created simple-tree node, a.k.a. an **unhydrated** simple-tree node. An unhydrated simple-tree node is produced by invoking the schema-provided constructor for a node:
45
28
46
29
```ts
47
-
// Upon insertion, `rawPoint` transitions from "raw" to the next state, "marinated"
48
-
app.graph.curves[0].insertAtEnd(rawPoint);
30
+
const unhydratedPoint =newPoint({ x: 3, y: 3 });
49
31
```
50
32
51
-
...or proxies are inserted indirectly, making up some arbitrary portion of the content subtree.
33
+
Such a simple-tree node will be unhydrated until it is inserted into the tree and becomes "hydrated" (see below).
34
+
Unhydrated nodes can be read or mutated just like hydrated ones.
52
35
53
-
```ts
54
-
// Upon insertion, `rawPoint` transitions from "raw" to the next state, "marinated"
A marinated simple-tree node, by definition, is bound bi-directionally to an `AnchorNode`.
64
-
When insertion occurs, an `AnchorNode` will be created (if not already present) for the location of the new content.
65
-
The simple-tree node for that content will then be mapped to the `AnchorNode` (via its kernel) and the `AnchorNode` will be mapped to the simple-tree node.
66
-
Note that the `AnchorNode` may not yet have a `FlexTreeNode` associated with it - that happens when the node becomes "cooked" (see below).
38
+
Between insertion edit and the change callback which updates the node to "Hydrated" (see [prepareForInsertion.ts](../prepareForInsertion.ts)),
39
+
the node is in a poorly defined "hydrating" state and should not be interacted with.
67
40
68
-
### Cooked Proxies
41
+
### Hydrated Nodes
69
42
70
-
A simple-tree node is fully cooked when it finally associates itself with a `FlexTreeNode`.
71
-
This happens lazily on demand, if/when a marinated simple-tree node is read or mutated (by the local client).
43
+
A simple-tree node is fully hydrated when it is associated with a `HydratedFlexTreeNode`.
72
44
73
45
```ts
74
-
const point =newPoint({ x: 3, y: 3 }); // `point` is raw
This laziness prevents the simple-tree node tree from generating unnecessary `FlexTreeNodes`.
80
-
81
-
Cooking a marinated simple-tree node works as follows:
82
-
83
-
1. Get the `AnchorNode` associated with the marinated simple-tree node.
84
-
2. Get or create a `FlexTreeNode` for the anchor.
85
-
3. This will cause the `FlexTreeNode` to be generated which corresponds to the simple-tree node.
86
-
87
-
### Mappings
88
-
89
-
```mermaid
90
-
graph LR;
91
-
AnchorNode(AnchorNode)<-->|Cooked and sometimes when Marinated|FlexTreeNode(FlexTreeNode)
92
-
AnchorNode<--->|Marinated or Cooked|TreeNode(TreeNode)-.->|Raw|RawTreeNode(RawTreeNode)
93
-
linkStyle 0 stroke:#0f0
94
-
linkStyle 1 stroke:#00f
95
-
linkStyle 2 stroke:#f00
96
-
```
97
-
98
-
Note that it is possible for the `Cooked` mappings between an `AnchorNode` and a `FlexTreeNode` to exist regardless of whether there is also a simple-tree node yet created for that node.
99
-
In that case, when that simple-tree node is created it will immediately be given its `Marinated` mappings and therefore already be cooked.
100
-
101
-
`RawTreeNode`s, which implement the `FlexTreeNode` interface (or at least, as of 2024-03-21, pretend to), are substitutes for the true `FlexTreeNode`s that don't yet exist for a raw node.
102
-
The `Raw` mapping is removed when a simple-tree node is marinated, and the `RawTreeNode` is forgotten.
103
-
104
-
See [proxyBinding.ts](./proxyBinding.ts) for more details.
0 commit comments