@vizij/node-graph-authoring 0.0.4 → 0.1.0

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/dist/index.d.cts CHANGED
@@ -1,40 +1,11 @@
1
- import { NodeType, GraphSpec } from '@vizij/node-graph-wasm';
2
- import { RigBindingDefinition, RigBindingSlot, BindingValueType, AnimatableComponent, StandardRigInput, RemapSettings, AnimatableValue } from '@vizij/utils';
1
+ import { GraphSpec, NodeType } from '@vizij/node-graph-wasm';
2
+ import { RigBindingDefinition, RigBindingSlot, BindingValueType, AnimatableComponent, StandardRigInput, AnimatableValue, RigBindingMetadata } from '@vizij/utils';
3
3
  export { BindingValueType } from '@vizij/utils';
4
4
 
5
- type BindingOperatorType = "spring" | "damp" | "slew";
6
- interface BindingOperatorState {
7
- type: BindingOperatorType;
8
- enabled: boolean;
9
- params: Record<string, number>;
10
- }
11
- interface BindingOperatorParamDefinition {
12
- id: string;
13
- label: string;
14
- doc?: string;
15
- min?: number;
16
- max?: number;
17
- defaultValue: number;
18
- }
19
- interface BindingOperatorDefinition {
20
- type: BindingOperatorType;
21
- nodeType: NodeType;
22
- label: string;
23
- description?: string;
24
- inputs: string[];
25
- params: BindingOperatorParamDefinition[];
26
- }
27
- declare function getBindingOperatorDefinition(type: BindingOperatorType): BindingOperatorDefinition;
28
- declare const bindingOperatorDefinitions: BindingOperatorDefinition[];
29
- declare function createDefaultOperatorSettings(type: BindingOperatorType): BindingOperatorState;
30
- declare function ensureOperatorParams(operator: BindingOperatorState): BindingOperatorState;
31
- declare const bindingOperatorTypes: readonly BindingOperatorType[];
32
-
33
5
  type AnimatableBindingSlot = RigBindingSlot;
34
6
  interface AnimatableBinding extends RigBindingDefinition {
35
7
  targetId: string;
36
8
  slots: AnimatableBindingSlot[];
37
- operators?: BindingOperator[];
38
9
  }
39
10
  interface BindingTarget {
40
11
  id: string;
@@ -52,8 +23,6 @@ type InputBindingMap = Record<string, AnimatableBinding>;
52
23
  type StandardInputValues = Record<string, number>;
53
24
  declare const PRIMARY_SLOT_ID = "s1";
54
25
  declare const PRIMARY_SLOT_ALIAS = "s1";
55
- type BindingOperator = BindingOperatorState;
56
- declare function createDefaultRemap(target: BindingTarget): RemapSettings;
57
26
  declare function createDefaultBindings(components: BindingTarget[]): BindingMap;
58
27
  declare function createDefaultBinding(component: BindingTarget): AnimatableBinding;
59
28
  declare function createDefaultParentBinding(component: BindingTarget): AnimatableBinding;
@@ -63,17 +32,113 @@ declare function getPrimaryBindingSlot(binding: AnimatableBinding): AnimatableBi
63
32
  declare function addBindingSlot(binding: AnimatableBinding, target: BindingTarget): AnimatableBinding;
64
33
  declare function removeBindingSlot(binding: AnimatableBinding, target: BindingTarget, slotId: string): AnimatableBinding;
65
34
  declare function updateBindingSlotAlias(binding: AnimatableBinding, target: BindingTarget, slotId: string, nextAlias: string): AnimatableBinding;
66
- declare function setBindingOperatorEnabled(binding: AnimatableBinding, type: BindingOperatorType, enabled: boolean): AnimatableBinding;
67
- declare function updateBindingOperatorParam(binding: AnimatableBinding, type: BindingOperatorType, paramId: string, value: number): AnimatableBinding;
35
+ declare function updateBindingSlotValueType(binding: AnimatableBinding, target: BindingTarget, slotId: string, nextValueType: BindingValueType): AnimatableBinding;
68
36
  declare function updateBindingExpression(binding: AnimatableBinding, target: BindingTarget, expression: string): AnimatableBinding;
69
- declare function updateBindingSlotRemap(binding: AnimatableBinding, target: BindingTarget, slotId: string, field: keyof RemapSettings, value: number): AnimatableBinding;
70
37
  declare function updateBindingWithInput(binding: AnimatableBinding, target: BindingTarget, input: StandardRigInput | undefined, slotId?: string): AnimatableBinding;
71
- declare function remapValue(value: number, remap: RemapSettings): number;
72
38
  declare function reconcileBindings(previous: BindingMap, components: BindingTarget[]): BindingMap;
73
39
  declare function bindingToDefinition(binding: AnimatableBinding): RigBindingDefinition;
74
40
  declare function bindingFromDefinition(target: BindingTarget, definition: RigBindingDefinition | null | undefined): AnimatableBinding;
41
+ declare function buildCanonicalBindingExpression(binding: AnimatableBinding): string;
42
+
43
+ type IrValueType = "scalar" | "vector" | "boolean" | "color" | "quaternion" | "transform" | "unknown";
44
+ interface IrPortRef {
45
+ nodeId: string;
46
+ portId?: string;
47
+ component?: string;
48
+ }
49
+ interface IrNodeInput {
50
+ id: string;
51
+ valueType: IrValueType;
52
+ cardinality?: "single" | "variadic";
53
+ required?: boolean;
54
+ }
55
+ interface IrNodeOutput {
56
+ id: string;
57
+ valueType: IrValueType;
58
+ cardinality?: "single" | "variadic";
59
+ }
60
+ interface IrNode {
61
+ id: string;
62
+ type: string;
63
+ category?: string;
64
+ label?: string;
65
+ description?: string;
66
+ params?: Record<string, unknown>;
67
+ inputDefaults?: Record<string, unknown>;
68
+ metadata?: Record<string, unknown>;
69
+ }
70
+ interface IrEdge {
71
+ id?: string;
72
+ from: IrPortRef;
73
+ to: IrPortRef;
74
+ metadata?: Record<string, unknown>;
75
+ }
76
+ interface IrConstant {
77
+ id: string;
78
+ value: number;
79
+ valueType: IrValueType;
80
+ metadata?: Record<string, unknown>;
81
+ }
82
+ interface IrIssue {
83
+ id: string;
84
+ severity: "error" | "warning" | "info";
85
+ message: string;
86
+ targetId?: string;
87
+ tags?: string[];
88
+ details?: Record<string, unknown>;
89
+ }
90
+ interface IrBindingSummary {
91
+ targetId: string;
92
+ animatableId: string;
93
+ component?: string;
94
+ slotId: string;
95
+ slotAlias: string;
96
+ inputId: string | null;
97
+ expression: string;
98
+ valueType: "scalar" | "vector";
99
+ nodeId: string;
100
+ expressionNodeId: string;
101
+ issues?: string[];
102
+ }
103
+ interface IrGraphSummary {
104
+ faceId: string;
105
+ inputs: string[];
106
+ outputs: string[];
107
+ bindings: IrBindingSummary[];
108
+ }
109
+ interface IrGraphMetadata {
110
+ source: string;
111
+ registryVersion?: string;
112
+ generatedAt?: string;
113
+ annotations?: Record<string, unknown>;
114
+ }
115
+ interface IrLegacyArtifacts {
116
+ spec?: GraphSpec;
117
+ }
118
+ interface IrGraph {
119
+ id: string;
120
+ faceId: string;
121
+ nodes: IrNode[];
122
+ edges: IrEdge[];
123
+ constants: IrConstant[];
124
+ issues: IrIssue[];
125
+ summary: IrGraphSummary;
126
+ metadata: IrGraphMetadata;
127
+ legacy?: IrLegacyArtifacts;
128
+ }
129
+ interface IrCompileOptions {
130
+ preferLegacySpec?: boolean;
131
+ }
132
+ interface IrCompileResult {
133
+ spec: GraphSpec;
134
+ issues: IrIssue[];
135
+ }
75
136
 
76
137
  type VectorComponent = "x" | "y" | "z" | "r" | "g" | "b";
138
+ interface InputExportMetadata {
139
+ source?: "auto" | "custom" | "preset";
140
+ root?: string;
141
+ }
77
142
  interface BuildGraphOptions {
78
143
  faceId: string;
79
144
  animatables: Record<string, AnimatableValue>;
@@ -81,6 +146,7 @@ interface BuildGraphOptions {
81
146
  bindings: BindingMap;
82
147
  inputsById: Map<string, StandardRigInput>;
83
148
  inputBindings: InputBindingMap;
149
+ inputMetadata?: Map<string, InputExportMetadata>;
84
150
  }
85
151
  interface GraphBindingSummary {
86
152
  targetId: string;
@@ -89,10 +155,12 @@ interface GraphBindingSummary {
89
155
  slotId: string;
90
156
  slotAlias: string;
91
157
  inputId: string | null;
92
- remap: RemapSettings;
93
158
  expression: string;
94
159
  valueType: BindingValueType;
160
+ nodeId: string;
161
+ expressionNodeId: string;
95
162
  issues?: string[];
163
+ metadata?: RigBindingMetadata;
96
164
  }
97
165
  interface BuildGraphResult {
98
166
  spec: GraphSpec;
@@ -106,12 +174,19 @@ interface BuildGraphResult {
106
174
  byTarget: Record<string, string[]>;
107
175
  fatal: string[];
108
176
  };
177
+ ir?: {
178
+ graph: IrGraph;
179
+ compile: (options?: IrCompileOptions) => IrCompileResult;
180
+ };
109
181
  }
110
- declare function buildRigGraphSpec({ faceId, animatables, components, bindings, inputsById, inputBindings, }: BuildGraphOptions): BuildGraphResult;
182
+ declare function buildRigGraphSpec({ faceId, animatables, components, bindings, inputsById, inputBindings, inputMetadata, }: BuildGraphOptions): BuildGraphResult;
111
183
 
112
184
  type ControlExpressionNode = {
113
185
  type: "Literal";
114
186
  value: number;
187
+ } | {
188
+ type: "VectorLiteral";
189
+ values: number[];
115
190
  } | {
116
191
  type: "Reference";
117
192
  name: string;
@@ -143,4 +218,269 @@ declare function parseControlExpression(expression: string): ExpressionParseResu
143
218
  declare function collectExpressionReferences(node: ControlExpressionNode | null, target?: Set<string>): Set<string>;
144
219
  declare function mapExpression(node: ControlExpressionNode, visit: (node: ControlExpressionNode) => void): void;
145
220
 
146
- export { type AnimatableBinding, type AnimatableBindingSlot, type BindingMap, type BindingOperator, type BindingOperatorDefinition, type BindingOperatorParamDefinition, type BindingOperatorState, type BindingOperatorType, type BindingTarget, type BuildGraphResult, type ControlExpressionNode, type ExpressionParseError, type ExpressionParseResult, type GraphBindingSummary, type InputBindingMap, PRIMARY_SLOT_ALIAS, PRIMARY_SLOT_ID, type StandardInputValues, addBindingSlot, bindingFromDefinition, bindingOperatorDefinitions, bindingOperatorTypes, bindingTargetFromComponent, bindingTargetFromInput, bindingToDefinition, buildRigGraphSpec, collectExpressionReferences, createDefaultBinding, createDefaultBindings, createDefaultInputValues, createDefaultOperatorSettings, createDefaultParentBinding, createDefaultRemap, ensureBindingStructure, ensureOperatorParams, getBindingOperatorDefinition, getPrimaryBindingSlot, mapExpression, parseControlExpression, reconcileBindings, remapValue, removeBindingSlot, setBindingOperatorEnabled, updateBindingExpression, updateBindingOperatorParam, updateBindingSlotAlias, updateBindingSlotRemap, updateBindingWithInput };
221
+ type ExpressionVariableKind = "slot" | "reserved";
222
+ interface SlotVariableMetadata {
223
+ slotId: string;
224
+ slotAlias: string;
225
+ inputId: string | null;
226
+ targetId: string;
227
+ animatableId: string;
228
+ component?: string;
229
+ valueType: BindingValueType;
230
+ }
231
+ interface ReservedVariableMetadata {
232
+ targetId?: string;
233
+ animatableId?: string;
234
+ component?: string;
235
+ }
236
+ interface ExpressionVariableEntry {
237
+ name: string;
238
+ kind: ExpressionVariableKind;
239
+ nodeId: string | null;
240
+ metadata?: SlotVariableMetadata | ReservedVariableMetadata;
241
+ description?: string;
242
+ }
243
+ interface RegisterSlotVariableOptions extends SlotVariableMetadata {
244
+ name: string;
245
+ nodeId: string;
246
+ }
247
+ interface RegisterReservedVariableOptions extends ReservedVariableMetadata {
248
+ name: string;
249
+ nodeId: string | null;
250
+ description?: string;
251
+ }
252
+ interface ExpressionVariableMissing {
253
+ name: string;
254
+ reason: "unknown" | "unresolved";
255
+ entry?: ExpressionVariableEntry;
256
+ }
257
+ interface ExpressionVariableTable {
258
+ registerSlotVariable(options: RegisterSlotVariableOptions): void;
259
+ registerReservedVariable(options: RegisterReservedVariableOptions): void;
260
+ resolve(name: string): ExpressionVariableEntry | null;
261
+ resolveNodeId(name: string): string | null;
262
+ entries(): ExpressionVariableEntry[];
263
+ firstNodeId(): string | null;
264
+ missing(names: Iterable<string>): ExpressionVariableMissing[];
265
+ }
266
+ declare function createExpressionVariableTable(): ExpressionVariableTable;
267
+
268
+ type ExpressionFunctionCategory = "math" | "logic" | "time" | "utility" | "vector";
269
+ type ExpressionValueType = "scalar" | "vector" | "boolean" | "any";
270
+ interface OrderedInputSpec {
271
+ id: string;
272
+ optional: boolean;
273
+ valueType: ExpressionValueType;
274
+ }
275
+ interface VariadicInputSpec {
276
+ id: string;
277
+ min: number;
278
+ max: number | null;
279
+ valueType: ExpressionValueType;
280
+ }
281
+ interface ParamArgumentSpec {
282
+ id: string;
283
+ label: string;
284
+ doc?: string;
285
+ optional: boolean;
286
+ valueType: ExpressionValueType;
287
+ min?: number;
288
+ max?: number;
289
+ }
290
+ interface ScalarFunctionDefinition {
291
+ nodeType: NodeType;
292
+ inputs: OrderedInputSpec[];
293
+ variadic: VariadicInputSpec | null;
294
+ params: ParamArgumentSpec[];
295
+ minArgs: number;
296
+ maxArgs: number | null;
297
+ resultValueType: ExpressionValueType;
298
+ }
299
+ interface ScalarFunctionVocabularyEntry {
300
+ name: string;
301
+ aliases: string[];
302
+ nodeType: NodeType;
303
+ category: ExpressionFunctionCategory;
304
+ description?: string;
305
+ }
306
+ declare const SCALAR_FUNCTIONS: Map<string, ScalarFunctionDefinition>;
307
+ declare const SCALAR_FUNCTION_VOCABULARY: ScalarFunctionVocabularyEntry[];
308
+
309
+ type ReservedExpressionScope = "binding" | "graph";
310
+ interface ReservedExpressionVariableDefinition {
311
+ name: string;
312
+ description: string;
313
+ scope: ReservedExpressionScope;
314
+ defaultValueType?: BindingValueType;
315
+ available?: boolean;
316
+ }
317
+ declare const RESERVED_EXPRESSION_VARIABLES: ReservedExpressionVariableDefinition[];
318
+ declare const EXPRESSION_FUNCTION_VOCABULARY: ScalarFunctionVocabularyEntry[];
319
+
320
+ interface IrGraphBuilderOptions {
321
+ faceId: string;
322
+ source?: string;
323
+ registryVersion?: string;
324
+ generatedAt?: string;
325
+ annotations?: Record<string, unknown>;
326
+ }
327
+ interface IrGraphBuilder {
328
+ addNode(node: IrNode): IrNode;
329
+ addEdge(edge: IrEdge): IrEdge;
330
+ addConstant(constant: IrConstant): IrConstant;
331
+ addIssue(issue: IrIssue): IrIssue;
332
+ setSummary(summary: IrGraphSummary): void;
333
+ updateMetadata(metadata: Partial<IrGraphMetadata>): void;
334
+ build(): IrGraph;
335
+ }
336
+ declare function createIrGraphBuilder(options: IrGraphBuilderOptions): IrGraphBuilder;
337
+ interface LegacyIrGraphPayload {
338
+ faceId: string;
339
+ summary: IrGraphSummary;
340
+ issues?: IrIssue[];
341
+ registryVersion?: string;
342
+ source?: string;
343
+ annotations?: Record<string, unknown>;
344
+ spec: GraphSpec;
345
+ }
346
+ declare function createLegacyIrGraph(payload: LegacyIrGraphPayload): IrGraph;
347
+ declare function toIrBindingSummary(summaries: {
348
+ targetId: string;
349
+ animatableId: string;
350
+ component?: string;
351
+ slotId: string;
352
+ slotAlias: string;
353
+ inputId: string | null;
354
+ expression: string;
355
+ valueType: "scalar" | "vector";
356
+ issues?: string[];
357
+ nodeId: string;
358
+ expressionNodeId: string;
359
+ }[]): IrBindingSummary[];
360
+
361
+ /**
362
+ * Compile an IR graph into a runtime-ready GraphSpec. The current implementation
363
+ * falls back to any legacy GraphSpec that was attached during migration,
364
+ * allowing the IR surface to land incrementally while the dedicated compiler
365
+ * is built.
366
+ */
367
+ declare function compileIrGraph(graph: IrGraph, options?: IrCompileOptions): IrCompileResult;
368
+
369
+ declare const MACHINE_REPORT_VERSION = 1;
370
+ interface MachineReport {
371
+ reportVersion: number;
372
+ faceId: string;
373
+ summary: MachineSummary;
374
+ issues: MachineIssues;
375
+ irGraph?: NormalizedIrGraph;
376
+ }
377
+ interface MachineSummary {
378
+ faceId: string;
379
+ inputs: string[];
380
+ outputs: string[];
381
+ bindings: MachineBindingSummary[];
382
+ }
383
+ interface MachineBindingSummary {
384
+ targetId: string;
385
+ animatableId: string;
386
+ component?: string;
387
+ slotId: string;
388
+ slotAlias: string;
389
+ inputId: string | null;
390
+ expression: string;
391
+ valueType: "scalar" | "vector";
392
+ nodeId: string;
393
+ expressionNodeId: string;
394
+ issues?: string[];
395
+ metadata?: RigBindingMetadata;
396
+ }
397
+ interface MachineIssues {
398
+ fatal: string[];
399
+ byTarget: Record<string, string[]>;
400
+ }
401
+ interface NormalizedIrGraph {
402
+ id: string;
403
+ faceId: string;
404
+ nodes: NormalizedIrNode[];
405
+ edges: NormalizedIrEdge[];
406
+ constants: NormalizedIrConstant[];
407
+ issues: NormalizedIrIssue[];
408
+ summary: NormalizedIrGraphSummary;
409
+ metadata: NormalizedIrGraphMetadata;
410
+ }
411
+ interface NormalizedIrNode extends IrNode {
412
+ annotations?: NodeInspectionAnnotations;
413
+ }
414
+ type NormalizedIrEdge = IrEdge;
415
+ type NormalizedIrConstant = IrConstant;
416
+ type NormalizedIrIssue = IrIssue & {
417
+ tags?: string[];
418
+ };
419
+ interface NormalizedIrGraphSummary extends IrGraphSummary {
420
+ bindings: NormalizedIrBindingSummary[];
421
+ }
422
+ type NormalizedIrBindingSummary = IrBindingSummary & {
423
+ issues?: string[];
424
+ };
425
+ interface NormalizedIrGraphMetadata {
426
+ source: string;
427
+ registryVersion?: string;
428
+ annotations?: Record<string, unknown>;
429
+ }
430
+ interface NodeInspectionAnnotations {
431
+ registry?: NormalizedRegistrySignature;
432
+ }
433
+ interface NormalizedRegistrySignature {
434
+ typeId: NodeType;
435
+ name: string;
436
+ category: string;
437
+ doc?: string;
438
+ inputs: NormalizedRegistryPortSpec[];
439
+ variadicInputs?: NormalizedRegistryVariadicSpec;
440
+ outputs: NormalizedRegistryPortSpec[];
441
+ variadicOutputs?: NormalizedRegistryVariadicSpec;
442
+ params: NormalizedRegistryParamSpec[];
443
+ }
444
+ interface NormalizedRegistryPortSpec {
445
+ id: string;
446
+ label: string;
447
+ doc?: string;
448
+ optional?: boolean;
449
+ type: string;
450
+ }
451
+ interface NormalizedRegistryVariadicSpec {
452
+ id: string;
453
+ label: string;
454
+ doc?: string;
455
+ type: string;
456
+ min: number;
457
+ max?: number;
458
+ }
459
+ interface NormalizedRegistryParamSpec {
460
+ id: string;
461
+ label: string;
462
+ doc?: string;
463
+ type: string;
464
+ defaultValue?: unknown;
465
+ min?: number;
466
+ max?: number;
467
+ }
468
+ type DiffKind = "mismatch" | "missing" | "unexpected";
469
+ interface MachineDiffEntry {
470
+ kind: DiffKind;
471
+ path: string;
472
+ actual?: unknown;
473
+ expected?: unknown;
474
+ }
475
+ interface MachineDiffResult {
476
+ equal: boolean;
477
+ differences: MachineDiffEntry[];
478
+ limitReached: boolean;
479
+ }
480
+ interface MachineDiffOptions {
481
+ limit?: number;
482
+ }
483
+ declare function buildMachineReport(result: BuildGraphResult): MachineReport;
484
+ declare function diffMachineReports(actual: MachineReport, expected: MachineReport, options?: MachineDiffOptions): MachineDiffResult;
485
+
486
+ export { type AnimatableBinding, type AnimatableBindingSlot, type BindingMap, type BindingTarget, type BuildGraphOptions, type BuildGraphResult, type ControlExpressionNode, type DiffKind, EXPRESSION_FUNCTION_VOCABULARY, type ExpressionFunctionCategory, type ExpressionParseError, type ExpressionParseResult, type ExpressionValueType, type ExpressionVariableEntry, type ExpressionVariableKind, type ExpressionVariableMissing, type ExpressionVariableTable, type GraphBindingSummary, type InputBindingMap, type IrBindingSummary, type IrCompileOptions, type IrCompileResult, type IrConstant, type IrEdge, type IrGraph, type IrGraphBuilder, type IrGraphBuilderOptions, type IrGraphMetadata, type IrGraphSummary, type IrIssue, type IrLegacyArtifacts, type IrNode, type IrNodeInput, type IrNodeOutput, type IrPortRef, type IrValueType, type LegacyIrGraphPayload, MACHINE_REPORT_VERSION, type MachineBindingSummary, type MachineDiffEntry, type MachineDiffOptions, type MachineDiffResult, type MachineIssues, type MachineReport, type MachineSummary, type NodeInspectionAnnotations, type NormalizedIrBindingSummary, type NormalizedIrConstant, type NormalizedIrEdge, type NormalizedIrGraph, type NormalizedIrGraphMetadata, type NormalizedIrGraphSummary, type NormalizedIrIssue, type NormalizedIrNode, type NormalizedRegistryParamSpec, type NormalizedRegistryPortSpec, type NormalizedRegistrySignature, type NormalizedRegistryVariadicSpec, PRIMARY_SLOT_ALIAS, PRIMARY_SLOT_ID, RESERVED_EXPRESSION_VARIABLES, type RegisterReservedVariableOptions, type RegisterSlotVariableOptions, type ReservedExpressionScope, type ReservedExpressionVariableDefinition, type ReservedVariableMetadata, SCALAR_FUNCTIONS, SCALAR_FUNCTION_VOCABULARY, type ScalarFunctionDefinition, type ScalarFunctionVocabularyEntry, type SlotVariableMetadata, type StandardInputValues, addBindingSlot, bindingFromDefinition, bindingTargetFromComponent, bindingTargetFromInput, bindingToDefinition, buildCanonicalBindingExpression, buildMachineReport, buildRigGraphSpec, collectExpressionReferences, compileIrGraph, createDefaultBinding, createDefaultBindings, createDefaultInputValues, createDefaultParentBinding, createExpressionVariableTable, createIrGraphBuilder, createLegacyIrGraph, diffMachineReports, ensureBindingStructure, getPrimaryBindingSlot, mapExpression, parseControlExpression, reconcileBindings, removeBindingSlot, toIrBindingSummary, updateBindingExpression, updateBindingSlotAlias, updateBindingSlotValueType, updateBindingWithInput };