Skip to content

Commit 45dc023

Browse files
committed
add comments answering question from #634
1 parent 6e950b7 commit 45dc023

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

runner/src/cell.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,31 @@ import { type Schema } from "@commontools/builder";
7171
* @param {JSONSchema} schema - Optional schema to apply.
7272
* @returns {Cell<T & {[TYPE]: string | undefined} & {argument: any}>}
7373
*
74-
* @method toJSON Returns a serializable doclink (not the contents) to the cell.
74+
* @method toJSON Returns a serializable cell link (not the contents) to the
75+
* cell. This is used e.g. when creating merkle references that refer to cells.
76+
* It currentlly doesn't contain the space. We'll eventually want to get a
77+
* relative link here, but that will require context toJSON doesn't get.
7578
* @returns {{cell: {"/": string} | undefined, path: PropertyKey[]}}
7679
*
77-
* @method value Returns the current value of the cell.
78-
* @returns {T}
79-
*
80-
* @property cellLink The cell link representing this cell.
81-
* @returns {CellLink}
82-
*
8380
* @property entityId Returns the current entity ID of the cell.
8481
* @returns {EntityId | undefined}
8582
*
8683
* @property schema Optional schema for the cell.
8784
* @returns {JSONSchema | undefined}
85+
*
86+
* @property rootSchema Optional root schema for cell's schema. This differs
87+
* from `schema` when the cell represents a child of the original cell (e.g. via
88+
* `key()`). We need to keep the root schema to resolve `$ref` in the schema.
89+
* @returns {JSONSchema | undefined}
90+
*
91+
* The following are just for debugging and might disappear: (This allows
92+
* clicking on a property in the debugger and getting the value)
93+
*
94+
* @method value Returns the current value of the cell.
95+
* @returns {T}
96+
*
97+
* @property cellLink The cell link representing this cell.
98+
* @returns {CellLink}
8899
*/
89100
export interface Cell<T> {
90101
get(): T;
@@ -139,13 +150,13 @@ export interface Cell<T> {
139150
: { argument: any })
140151
>;
141152
toJSON(): { cell: { "/": string } | undefined; path: PropertyKey[] };
153+
schema?: JSONSchema;
154+
rootSchema?: JSONSchema;
142155
value: T;
143156
cellLink: CellLink;
144157
entityId: EntityId | undefined;
145158
[isCellMarker]: true;
146159
copyTrap: boolean;
147-
schema?: JSONSchema;
148-
rootSchema?: JSONSchema;
149160
}
150161

151162
export interface Stream<T> {

0 commit comments

Comments
 (0)