Skip to main content

session

Functions​

getNodeCatalog()​

function getNodeCatalog(document?, registry?): MaterialXNodeSpec[];

Parameters​

ParameterType
document?MaterialXDocument
registry?MaterialXNodeSpec[]

Returns​

MaterialXNodeSpec[]


graphScopes()​

function graphScopes(document): string[];

Parameters​

ParameterType
documentMaterialXDocument

Returns​

string[]


readGraph()​

function readGraph(
document,
scope?,
catalog?
): object;

Resolve the nodes and connections in a scope without adding viewer state or default positions.

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
scope?string''
catalog?MaterialXNodeSpec[]...

Returns​

object

NameType
nodesGraphNode[]
edgesGraphEdge[]

isStructural()​

function isStructural(spec): boolean;

Parameters​

ParameterType
specMaterialXNodeSpec

Returns​

boolean


addNode()​

function addNode(
document,
spec,
position?,
scope?
): MaterialXDocument;

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
specMaterialXNodeSpecundefined
position?Pointundefined
scope?string''

Returns​

MaterialXDocument


setInterfacePort()​

function setInterfacePort(
document,
id,
changes,
scope?
): MaterialXDocument;

Retype an interface input or output of a node graph, or set the input's default value. A new type drops the old value.

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
idstringundefined
changes{ type?: string; value?: string; }undefined
changes.type?stringundefined
changes.value?stringundefined
scope?string''

Returns​

MaterialXDocument


cloneNode()​

function cloneNode(
document,
id,
position?,
scope?
): MaterialXDocument;

Copy a node's values and incoming connections, leaving downstream connections unchanged.

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
idstringundefined
position?Pointundefined
scope?string''

Returns​

MaterialXDocument


pasteNodes()​

function pasteNodes(
document,
elements,
scope?,
offset?
): MaterialXDocument;

Insert copies of nodes into a scope: colliding names get suffixed, wires among them are kept, wires to anything else are dropped.

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
elementsreadonly MaterialXElement[]undefined
scope?string''
offset?Point...

Returns​

MaterialXDocument


setInputValue()​

function setInputValue(
document,
node,
input,
value,
scope?,
catalog?,
valueType?
): MaterialXDocument;

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
nodestringundefined
inputstringundefined
valuestringundefined
scope?string''
catalog?MaterialXNodeSpec[]...
valueType?stringundefined

Returns​

MaterialXDocument


resetInput()​

function resetInput(
document,
node,
input,
scope?
): MaterialXDocument;

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
nodestringundefined
inputstringundefined
scope?string''

Returns​

MaterialXDocument


connectionError()​

function connectionError(
document,
connection,
scope?,
catalog?
): string | undefined;

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
connectionGraphConnectionundefined
scope?string''
catalog?MaterialXNodeSpec[]...

Returns​

string | undefined


connectNodes()​

function connectNodes(
document,
connection,
scope?,
catalog?
): MaterialXDocument;

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
connectionGraphConnectionundefined
scope?string''
catalog?MaterialXNodeSpec[]...

Returns​

MaterialXDocument


disconnectInput()​

function disconnectInput(
document,
target,
input,
scope?
): MaterialXDocument;

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
targetstringundefined
inputstringundefined
scope?string''

Returns​

MaterialXDocument


removeNodes()​

function removeNodes(
document,
ids,
scope?
): MaterialXDocument;

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
idsstring[]undefined
scope?string''

Returns​

MaterialXDocument


groupNodes()​

function groupNodes(
document,
ids,
catalog?
): MaterialXDocument;

Collapse root-scope nodes into a new node graph. Wires crossing the boundary become interface inputs and outputs.

Parameters​

ParameterType
documentMaterialXDocument
idsstring[]
catalog?MaterialXNodeSpec[]

Returns​

MaterialXDocument


moveNodes()​

function moveNodes(
document,
positions,
scope?
): MaterialXDocument;

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
positionsRecord<string, Point>undefined
scope?string''

Returns​

MaterialXDocument


renameNode()​

function renameNode(
document,
id,
name,
scope?
): MaterialXDocument;

Rename a node and every reference to it: sibling wires, interface names, nested graph paths, and material assignments.

Parameters​

ParameterTypeDefault value
documentMaterialXDocumentundefined
idstringundefined
namestringundefined
scope?string''

Returns​

MaterialXDocument


getNodeFamilies()​

function getNodeFamilies(catalog): NodeFamily[];

Preserve catalog order: it determines the fallback definition and its implicit defaults.

Parameters​

ParameterType
catalogMaterialXNodeSpec[]

Returns​

NodeFamily[]


findNodeFamily()​

function findNodeFamily(element, catalog): NodeFamily | undefined;

Stored nodedef/type identify an interface family, never constrain its type variants.

Parameters​

ParameterType
elementMaterialXElement
catalogMaterialXNodeSpec[]

Returns​

NodeFamily | undefined


createEditorSession()​

function createEditorSession(options): EditorSession;

Parameters​

ParameterType
optionsEditorSessionOptions

Returns​

EditorSession


resolutionKey()​

function resolutionKey(scope, id): string;

Parameters​

ParameterType
scopestring
idstring

Returns​

string


invalidateTypeResolution()​

function invalidateTypeResolution(document): void;

Parameters​

ParameterType
documentMaterialXDocument

Returns​

void


resolveTypes()​

function resolveTypes(document, catalog?): TypeResolution;

Parameters​

ParameterType
documentMaterialXDocument
catalog?MaterialXNodeSpec[]

Returns​

TypeResolution


materializeDocument()​

function materializeDocument(document, catalog?): MaterialXDocument;

Resolve a copy for consumers of concrete MaterialX. Never author defaults or pin inferred types.

Parameters​

ParameterType
documentMaterialXDocument
catalog?MaterialXNodeSpec[]

Returns​

MaterialXDocument

Classes​

EditorError​

Extends​

  • Error

Constructors​

Constructor​
new EditorError(diagnostic): EditorError;
Parameters​
ParameterType
diagnosticEditorDiagnostic
Returns​

EditorError

Overrides​

Error.constructor

Properties​

code​
readonly code: string;
scope?​
readonly scope?: string;
node?​
readonly node?: string;
input?​
readonly input?: string;

EditorSession​

Headless editing state. Only successful commits publish immutable snapshots.

Constructors​

Constructor​
new EditorSession(options): EditorSession;
Parameters​
ParameterType
optionsEditorSessionOptions
Returns​

EditorSession

Methods​

getDocument()​
getDocument(): ReadonlyMaterialXDocument;

Reads inside a transaction see its working snapshot. Subscribers see getSnapshot().

Returns​

ReadonlyMaterialXDocument

getCatalog()​
getCatalog(): readonly DeepReadonly<MaterialXNodeSpec>[];
Returns​

readonly DeepReadonly<MaterialXNodeSpec>[]

getSnapshot()​
getSnapshot(): EditorSnapshot;
Returns​

EditorSnapshot

toXml()​
toXml(): string;
Returns​

string

markClean()​
markClean(): void;

Treat the current document as saved; dirty clears until the next edit.

Returns​

void

subscribe()​
subscribe(listener): () => void;
Parameters​
ParameterType
listener() => void
Returns​

() => void

setScope()​
setScope(scope): void;

Show the given scope; selection belongs to a scope, so it clears.

Parameters​
ParameterType
scopestring
Returns​

void

select()​
select(ids): void;
Parameters​
ParameterType
idsreadonly string[]
Returns​

void

setError()​
setError(message?): void;

Record a failed command for whichever surface shows errors; no argument clears it.

Parameters​
ParameterType
message?string
Returns​

void

transaction()​
transaction<T>(label, operation): T;

Synchronous transactions support nested savepoints; an uncaught error rolls back the enclosing transaction.

Type Parameters​
Type Parameter
T
Parameters​
ParameterType
labelstring
operation() => T extends PromiseLike<unknown> ? never : T
Returns​

T

replaceDocument()​
replaceDocument(document): void;

Loading a document accepts existing diagnostics and clears undo/redo. Input ownership stays with the caller.

Parameters​
ParameterType
documentReadonlyMaterialXDocument
Returns​

void

undo()​
undo(): void;
Returns​

void

redo()​
redo(): void;
Returns​

void

getDiagnostics()​
getDiagnostics(): readonly EditorDiagnostic[];
Returns​

readonly EditorDiagnostic[]

listScopes()​
listScopes(): readonly string[];
Returns​

readonly string[]

graph()​
graph(scope?): Readonly<{
scope: string;
listNodes: () => readonly DeepReadonly<GraphNode>[];
getNode: (id) => DeepReadonly<GraphNode>;
getInputs: (id) => readonly DeepReadonly<MaterialXNodePortSpec>[];
getOutputs: (id) => readonly DeepReadonly<MaterialXNodePortSpec>[];
getConnection: (target) => Readonly<OutputRef> | undefined;
addNode: (__namedParameters) => string;
cloneNode: (id) => string;
pasteNodes: (elements, offset?) => string[];
removeNodes: (ids) => void;
groupNodes: (ids) => string;
renameNode: (id, name) => void;
setInterfacePort: (id, changes) => void;
setInputValue: (id, input, value, options) => void;
resetInput: (id, input) => void;
disconnectInput: (id, input) => void;
checkConnection: (source, target) => EditorDiagnostic | undefined;
connect: (source, target) => void;
}>;

Graph handles resolve against current state, so they remain useful across commits and undo.

Parameters​
ParameterTypeDefault value
scope?string''
Returns​

Readonly<{ scope: string; listNodes: () => readonly DeepReadonly<GraphNode>[]; getNode: (id) => DeepReadonly<GraphNode>; getInputs: (id) => readonly DeepReadonly<MaterialXNodePortSpec>[]; getOutputs: (id) => readonly DeepReadonly<MaterialXNodePortSpec>[]; getConnection: (target) => Readonly<OutputRef> | undefined; addNode: (__namedParameters) => string; cloneNode: (id) => string; pasteNodes: (elements, offset?) => string[]; removeNodes: (ids) => void; groupNodes: (ids) => string; renameNode: (id, name) => void; setInterfacePort: (id, changes) => void; setInputValue: (id, input, value, options) => void; resetInput: (id, input) => void; disconnectInput: (id, input) => void; checkConnection: (source, target) => EditorDiagnostic | undefined; connect: (source, target) => void; }>

Properties​

layout​
readonly layout: object;

Positions remain a separate view operation, but share atomic commits and undo history.

moveNodes​
moveNodes: (positions, scope) => void;
Parameters​
ParameterTypeDefault value
positionsReadonly<Record<string, Point>>undefined
scope?string''
Returns​

void

Interfaces​

Point​

Persisted node coordinates; default placement belongs to the viewer.

Properties​

PropertyType
xnumber
ynumber

GraphConnection​

Extended by​

Properties​

PropertyType
sourcestring
sourceHandlestring
targetstring
targetHandlestring

GraphNode​

Semantic graph node. Contains authored XML metadata, without canvas placement or interaction state.

Properties​

PropertyTypeDescription
idstring-
elementMaterialXElement-
inputsMaterialXNodePortSpec[]-
outputsMaterialXNodePortSpec[]-
type?stringInferred output type; absent while the family is ambiguous.
definition?MaterialXNodeSpecConcrete fallback for implicit defaults. Does not constrain the inferred type.
candidates?MaterialXNodeSpec[]Compatible definition variants for this node.
compoundScope?stringDocument scope containing this compound node’s implementation, when available.

GraphEdge​

Extends​

Properties​

PropertyTypeInherited from
sourcestringGraphConnection.source
sourceHandlestringGraphConnection.sourceHandle
targetstringGraphConnection.target
targetHandlestringGraphConnection.targetHandle
idstring-

NodeFamily​

Properties​

PropertyTypeDescription
idstringA representative nodedef identifies the family.
variantsMaterialXNodeSpec[]-

OutputRef​

Properties​

PropertyType
nodestring
outputstring

InputRef​

Properties​

PropertyType
nodestring
inputstring

EditorDiagnostic​

Properties​

PropertyModifierType
codereadonlystring
messagereadonlystring
scope?readonlystring
node?readonlystring
input?readonlystring

EditorSnapshot​

Properties​

PropertyModifierTypeDescription
documentreadonlyReadonlyMaterialXDocument-
canUndoreadonlyboolean-
canRedoreadonlyboolean-
dirtyreadonlybooleanWhether the document differs from the one last loaded or marked clean.
undoLabel?readonlystring-
redoLabel?readonlystring-
scopereadonlystringView state shared by every surface (canvas, toolbar, inspector); never part of undo history.
selectionreadonlyreadonly string[]Selected node ids in the current scope, in selection order. Ids of removed nodes drop out.
error?readonlystringMessage from the last failed command, until the next command succeeds or clears it.

EditorSessionOptions​

Properties​

PropertyTypeDescription
documentReadonlyMaterialXDocument-
catalog?readonly DeepReadonly<MaterialXNodeSpec>[]A complete catalog; otherwise derive it from the document and standard registry.
historyLimit?number-

ResolvedNode​

Properties​

PropertyTypeDescription
elementMaterialXElement-
scopestring-
family?NodeFamily-
candidatesMaterialXNodeSpec[]-
definition?MaterialXNodeSpecA jointly compatible fallback; never an inference constraint.
type?string-
inputsMaterialXNodePortSpec[]-
outputsMaterialXNodePortSpec[]-
conflictboolean-

TypeResolution​

Properties​

PropertyType
nodesMap<string, ResolvedNode>
conflictsobject[]

References​

DeepReadonly​

Re-exports DeepReadonly


ReadonlyMaterialXDocument​

Re-exports ReadonlyMaterialXDocument

Type Aliases​

InputValue​

type InputValue = string | number | boolean | readonly number[];

EditorGraph​

type EditorGraph = ReturnType<EditorSession["graph"]>;

Variables​

structuralSpecs​

const structuralSpecs: readonly MaterialXNodeSpec[];

Compound-graph structure the editor adds without a nodedef: a node graph and its interface ports. Ports are untyped until placed.


nonNodes​

const nonNodes: Set<string>;

Element tags that never appear as graph nodes.