@huukhanhnguyen/model / nodes/BaseNode
nodes/BaseNode
BaseNode
Extends
Extended by
Constructors
Constructor
new BaseNode():
BaseNode
Returns
Inherited from
_dependents
_dependents:
Set<BaseNode>
_epoch
_epoch:
number=0
Bumped on every dirty (see setDirty/markDirty) — a stale async settle compares its captured epoch against the current one and discards itself on mismatch (a newer edit superseded it while it was in flight).
_hooks?
optional_hooks?:NodeHooks
Lifecycle observers attached to THIS node — see nodes/hooks.ts. Also carried by an DataDefinition, the declaration surface a node's hooks can be attached to before the node exists.
_reads
_reads:
Set<BaseNode>
Reverse index of nodes this node currently reads (static expression refs + dynamic dependOn edges). Cleared at the start of every dirty recompute and on dispose so a dropped Table.get/sampleTexture edge stops cascading markDirty (and a disposed node is not retained).
attributes
attributes:
Record<string,unknown> ={}
Inherited from
collection
collection:
BaseCollection
Inherited from
error?
optionalerror?:string=""
Last error message; empty string when valid, undefined after a successful eval.
id
id:
string
Inherited from
isDirty
isDirty:
boolean=true
True when the node needs re-evaluation before its value can be trusted.
parent?
optionalparent?:any
Inherited from
pending
pending:
boolean=false
True while an async compute() is in flight (its result hasn't settled yet).
sourceId
sourceId:
string=""
Inherited from
value
value:
unknown=undefined
Cached evaluated value; undefined when the node is in an error state.
Accessors
dependents
Get Signature
get dependents():
Set<BaseNode>
Returns
Set<BaseNode>
errorLogPrefix
Get Signature
get
protectederrorLogPrefix():string
console.error prefix on a compute failure — override to match a subclass's existing log message (includes node-specific context).
Returns
string
model
Get Signature
get model():
any
Returns
any
Inherited from
owner
Get Signature
get owner():
any
Walk up to the nearest owner that has a nodes collection (ModelScope).
Returns
any
symbol
Get Signature
get symbol():
string
Returns
string
valueType
Get Signature
get valueType():
string
Returns
string
Methods
_commit()
protected_commit(raw,isAsync,settle?):void
Protected (not private): ExpressionNode/ContainerNode's evaluate() overrides call this directly to reuse the exact same commit path for a volatile step that bypasses the isDirty gate.
Parameters
raw
unknown
isAsync
boolean
settle?
Returns
void
_dispose()
_dispose():
void
Returns
void
Inherited from
_fail()
protected_fail(err,isAsync,settle?):void
Protected (not private) — see _commit's doc.
Parameters
err
unknown
isAsync
boolean
settle?
Returns
void
addListener()
addListener(
event,listener): () =>void
Parameters
event
string
listener
Returns
() => void
Inherited from
compute()
compute():
unknown
Compute the raw value for this node; override in subclasses to produce actual output.
Returns
unknown
copy()
copy():
any
Duplicate this node in its collection, inserting it right after the original.
Returns
any
display()
display(
listener?):string
Return the human-readable display string for this node's value (or its error message).
Parameters
listener?
() => void
Returns
string
errorValue()
protectederrorValue():unknown
Value to fall back to when compute()/postCompute() throws. Override for a node whose "empty" isn't undefined (ContainerNode: []).
Returns
unknown
evaluate()
evaluate(
listener?):unknown
Evaluate this node, cache the result, and notify dependents; returns the cached value. When compute() returns a thenable, this returns the prior (stale) value synchronously and settles later — see core/maybeAsync.ts.
Parameters
listener?
() => void
Returns
unknown
finishInit()
finishInit():
void
Assembly is complete: this node has its full structure and its children. Every assembly path calls it at the point wiring is genuinely done, which is NOT one line:
- the classes that take everything as constructor parameters (the LaneNode family, ExpressionNode, OptionNode, ArgumentNode) call it at the end of their own constructor;
DataNodecalls it after its args are pushed —fromRegistryandcopy, never its constructor, which sets only method+definition;ContainerNodeafter its children are attached,ParameterNodeafter its args are wired (NodeCollection: createFromJSON, addContainer, addEntry).
Guarded to fire at most once. That is what makes NESTED assembly safe — createFromJSON delegates to fromRegistry, and one node must see one init, not two — and makes a redundant call harmless rather than wrong.
Returns
void
getError()
getError(
listener?):string|undefined
Parameters
listener?
() => void
Returns
string | undefined
isPending()
isPending(
listener?):boolean
True while an async compute() is still settling (see pending).
Parameters
listener?
() => void
Returns
boolean
isValid()
isValid(
listener?):boolean
Parameters
listener?
() => void
Returns
boolean
notify()
notify(
event, ...args):void
Parameters
event
string
args
...unknown[]
Returns
void
Inherited from
postCompute()
protectedpostCompute(raw):unknown
Post-process compute()'s raw result into this.value; throw to signal a failure (caught by evaluate()'s template, same as a compute() throw). Override for a node whose value isn't a sanitizer-typed scalar: ContainerNode returns the data list as-is; ArgumentNode routes through the domain coercion pipeline (nodeMethods/parameter.ts + data/ asset resolution) instead of convert/validate.
Parameters
raw
unknown
Returns
unknown
remove()
remove():
void
The removal door. BaseObject.remove() detaches from the collection and notifies "remove"; the pair brackets that, so beforeRemove still sees the node in its collection with its read edges intact.
afterRemove means "AFTER THE NODE LEFT ITS COLLECTION" — it does NOT promise the node's read edges are gone. Deliberately does not retractReads(): removing a node does not retract its edges today, only the disposal call sites do (tables.ts), and adding it here would be a behaviour change rather than an observation point.
Not anchored at retractReads() — that runs on EVERY dirty recompute (3 of its 6 call sites: evaluate, LaneNode.pull, evaluateStep), so hooks there would report a live node as removed on every evaluate.
Returns
void
Overrides
removeListener()
removeListener(
event,listener):void
Parameters
event
string
listener
Returns
void
Inherited from
retractReads()
retractReads():
void
Drop every reverse read edge recorded in _reads.
Returns
void
setError()
setError(
message):void
Set an error message on this node and notify listeners. Fires "error" (specific) and "change" (the universal event — see ParameterNode.setKey's doc).
Parameters
message
string
Returns
void
toJSON()
toJSON():
BaseObjectJSON
Returns
Overrides
markDependentsDirty()
markDependentsDirty(
node):void
Dirty a node's dependents/parent chain WITHOUT re-dirtying the node itself — used after an async settle: this node just computed its fresh value, so what needs re-computing is whatever reads it, not the node itself.
Parameters
node
Returns
void
markDirty()
markDirty(
node,visited?,source?):void
Parameters
node
visited?
Set<DirtyTarget> = ...
source?
DirtyTarget = node
Returns
void
setDirty()
setDirty(
node,source?):void
Dirty a single node (no cascade) — the epoch-bumping counterpart to a bare node.isDirty = true write. Every direct dirty write in the engine must go through this (or markDirty) so an in-flight async compute is invalidated.
Parameters
node
source?
DirtyTarget = node
Returns
void