@vizij/orchestrator-react 0.0.1

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.cjs ADDED
@@ -0,0 +1,550 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ OrchestratorProvider: () => OrchestratorProvider,
24
+ OrchestratorRuntime: () => import_orchestrator_wasm3.Orchestrator,
25
+ createOrchestratorRuntime: () => import_orchestrator_wasm3.createOrchestrator,
26
+ initOrchestratorWasm: () => import_orchestrator_wasm3.init,
27
+ listOrchestrationFixtures: () => import_orchestrator_wasm2.listOrchestrationFixtures,
28
+ loadOrchestrationBundle: () => import_orchestrator_wasm2.loadOrchestrationBundle,
29
+ loadOrchestrationDescriptor: () => import_orchestrator_wasm2.loadOrchestrationDescriptor,
30
+ loadOrchestrationJson: () => import_orchestrator_wasm2.loadOrchestrationJson,
31
+ samples: () => samples,
32
+ useOrchFrame: () => useOrchFrame,
33
+ useOrchTarget: () => useOrchTarget,
34
+ useOrchestrator: () => useOrchestrator,
35
+ valueAsBool: () => valueAsBool,
36
+ valueAsNumber: () => valueAsNumber,
37
+ valueAsVec3: () => valueAsVec3
38
+ });
39
+ module.exports = __toCommonJS(index_exports);
40
+ var import_orchestrator_wasm2 = require("@vizij/orchestrator-wasm");
41
+
42
+ // src/OrchestratorProvider.tsx
43
+ var import_react2 = require("react");
44
+ var import_orchestrator_wasm = require("@vizij/orchestrator-wasm");
45
+
46
+ // src/context.ts
47
+ var import_react = require("react");
48
+ var OrchestratorContext = (0, import_react.createContext)(
49
+ null
50
+ );
51
+
52
+ // src/OrchestratorProvider.tsx
53
+ var import_jsx_runtime = require("react/jsx-runtime");
54
+ function normalizeInitInput(input) {
55
+ if (input == null) {
56
+ return void 0;
57
+ }
58
+ if (typeof input === "string") {
59
+ return input;
60
+ }
61
+ if (typeof Uint8Array !== "undefined" && input instanceof Uint8Array) {
62
+ return input;
63
+ }
64
+ if (typeof URL !== "undefined" && input instanceof URL) {
65
+ return input;
66
+ }
67
+ if (typeof input === "object" && "url" in input && typeof input.url === "string") {
68
+ return input.url;
69
+ }
70
+ return void 0;
71
+ }
72
+ function normalizeTypedPath(path) {
73
+ if (typeof path !== "string") {
74
+ throw new Error("Typed paths must be provided as strings.");
75
+ }
76
+ const trimmed = path.trim();
77
+ if (trimmed.length === 0) {
78
+ throw new Error("Typed paths must not be empty.");
79
+ }
80
+ if (/\s/.test(trimmed)) {
81
+ throw new Error(
82
+ "Typed paths may not contain whitespace. Use '/' to separate namespace segments."
83
+ );
84
+ }
85
+ return trimmed;
86
+ }
87
+ var noopUnsubscribe = () => {
88
+ };
89
+ function OrchestratorProvider({
90
+ children,
91
+ initInput,
92
+ autoCreate = true,
93
+ createOptions,
94
+ autostart = false
95
+ }) {
96
+ const mountedRef = (0, import_react2.useRef)(true);
97
+ (0, import_react2.useEffect)(
98
+ () => () => {
99
+ mountedRef.current = false;
100
+ },
101
+ []
102
+ );
103
+ const initPromiseRef = (0, import_react2.useRef)(null);
104
+ const orchestratorRef = (0, import_react2.useRef)(null);
105
+ const createPromiseRef = (0, import_react2.useRef)(null);
106
+ const latestFrameRef = (0, import_react2.useRef)(null);
107
+ const pathCacheRef = (0, import_react2.useRef)(/* @__PURE__ */ new Map());
108
+ const pathSubscribersRef = (0, import_react2.useRef)(/* @__PURE__ */ new Map());
109
+ const frameSubscribersRef = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
110
+ const [ready, setReady] = (0, import_react2.useState)(false);
111
+ const [initError, setInitError] = (0, import_react2.useState)(null);
112
+ const ensureInit = (0, import_react2.useCallback)(() => {
113
+ if (!initPromiseRef.current) {
114
+ const resolved = normalizeInitInput(initInput);
115
+ initPromiseRef.current = (0, import_orchestrator_wasm.init)(resolved).catch((err) => {
116
+ setInitError(err instanceof Error ? err : new Error(String(err)));
117
+ throw err;
118
+ });
119
+ }
120
+ return initPromiseRef.current;
121
+ }, [initInput]);
122
+ const applyFrame = (0, import_react2.useCallback)((frame) => {
123
+ latestFrameRef.current = frame;
124
+ if (frame) {
125
+ const cache = pathCacheRef.current;
126
+ const subscribers = pathSubscribersRef.current;
127
+ for (const write of frame.merged_writes) {
128
+ let pathKey = write.path;
129
+ try {
130
+ pathKey = normalizeTypedPath(write.path);
131
+ } catch (err) {
132
+ console.warn(
133
+ "@vizij/orchestrator-react: received write with invalid path",
134
+ write.path,
135
+ err
136
+ );
137
+ }
138
+ cache.set(pathKey, write.value);
139
+ const listeners = subscribers.get(pathKey);
140
+ if (listeners) {
141
+ listeners.forEach((listener) => listener());
142
+ }
143
+ }
144
+ }
145
+ frameSubscribersRef.current.forEach((listener) => listener());
146
+ }, []);
147
+ const ensureOrchestrator = (0, import_react2.useCallback)(
148
+ async (opts) => {
149
+ if (orchestratorRef.current) {
150
+ return orchestratorRef.current;
151
+ }
152
+ if (!createPromiseRef.current) {
153
+ createPromiseRef.current = (async () => {
154
+ await ensureInit();
155
+ const instance = await (0, import_orchestrator_wasm.createOrchestrator)(
156
+ opts ?? createOptions ?? void 0
157
+ );
158
+ orchestratorRef.current = instance;
159
+ if (mountedRef.current) {
160
+ setReady(true);
161
+ }
162
+ return instance;
163
+ })();
164
+ }
165
+ return createPromiseRef.current;
166
+ },
167
+ [createOptions, ensureInit]
168
+ );
169
+ const requireOrchestrator = (0, import_react2.useCallback)(() => {
170
+ const instance = orchestratorRef.current;
171
+ if (!instance) {
172
+ throw new Error(
173
+ "Orchestrator not created yet. Call createOrchestrator() first."
174
+ );
175
+ }
176
+ return instance;
177
+ }, []);
178
+ const stepRuntime = (0, import_react2.useCallback)(
179
+ (dt) => {
180
+ if (!Number.isFinite(dt)) {
181
+ throw new Error("step(dt) requires a finite number of seconds.");
182
+ }
183
+ const instance = orchestratorRef.current;
184
+ if (!instance) {
185
+ return null;
186
+ }
187
+ const frame = instance.step(dt);
188
+ if (frame) {
189
+ applyFrame(frame);
190
+ return frame;
191
+ }
192
+ return null;
193
+ },
194
+ [applyFrame]
195
+ );
196
+ const createOrchestratorFn = (0, import_react2.useCallback)(
197
+ async (opts) => {
198
+ await ensureOrchestrator(opts);
199
+ },
200
+ [ensureOrchestrator]
201
+ );
202
+ const registerGraph = (0, import_react2.useCallback)(
203
+ (cfg) => {
204
+ const instance = requireOrchestrator();
205
+ return instance.registerGraph(cfg);
206
+ },
207
+ [requireOrchestrator]
208
+ );
209
+ const registerMergedGraph = (0, import_react2.useCallback)(
210
+ (cfg) => {
211
+ const instance = requireOrchestrator();
212
+ return instance.registerMergedGraph(cfg);
213
+ },
214
+ [requireOrchestrator]
215
+ );
216
+ const registerAnimation = (0, import_react2.useCallback)(
217
+ (cfg) => {
218
+ const instance = requireOrchestrator();
219
+ return instance.registerAnimation(cfg);
220
+ },
221
+ [requireOrchestrator]
222
+ );
223
+ const prebind = (0, import_react2.useCallback)(
224
+ (resolver) => {
225
+ const instance = requireOrchestrator();
226
+ instance.prebind(resolver);
227
+ },
228
+ [requireOrchestrator]
229
+ );
230
+ const setInput = (0, import_react2.useCallback)(
231
+ (path, value, shape) => {
232
+ const normalizedPath = normalizeTypedPath(path);
233
+ const instance = requireOrchestrator();
234
+ instance.setInput(normalizedPath, value, shape);
235
+ pathCacheRef.current.set(normalizedPath, value);
236
+ const listeners = pathSubscribersRef.current.get(normalizedPath);
237
+ if (listeners) {
238
+ listeners.forEach((listener) => {
239
+ try {
240
+ listener();
241
+ } catch (err) {
242
+ console.error(
243
+ "@vizij/orchestrator-react: setInput listener error",
244
+ err
245
+ );
246
+ }
247
+ });
248
+ }
249
+ },
250
+ [requireOrchestrator]
251
+ );
252
+ const removeInput = (0, import_react2.useCallback)(
253
+ (path) => {
254
+ const normalizedPath = normalizeTypedPath(path);
255
+ const instance = requireOrchestrator();
256
+ const removed = instance.removeInput(normalizedPath);
257
+ if (removed) {
258
+ pathCacheRef.current.delete(normalizedPath);
259
+ const listeners = pathSubscribersRef.current.get(normalizedPath);
260
+ if (listeners) {
261
+ listeners.forEach((listener) => listener());
262
+ }
263
+ }
264
+ return removed;
265
+ },
266
+ [requireOrchestrator]
267
+ );
268
+ const listControllers = (0, import_react2.useCallback)(() => {
269
+ const instance = orchestratorRef.current;
270
+ if (!instance) {
271
+ return { graphs: [], anims: [] };
272
+ }
273
+ const result = instance.listControllers();
274
+ const graphs = Array.isArray(result?.graphs) ? result?.graphs : [];
275
+ const anims = Array.isArray(result?.anims) ? result?.anims : [];
276
+ return { graphs, anims };
277
+ }, []);
278
+ const removeGraph = (0, import_react2.useCallback)(
279
+ (id) => {
280
+ const instance = requireOrchestrator();
281
+ return instance.removeGraph(id);
282
+ },
283
+ [requireOrchestrator]
284
+ );
285
+ const removeAnimation = (0, import_react2.useCallback)(
286
+ (id) => {
287
+ const instance = requireOrchestrator();
288
+ return instance.removeAnimation(id);
289
+ },
290
+ [requireOrchestrator]
291
+ );
292
+ const normalizeGraphSpec = (0, import_react2.useCallback)(
293
+ async (spec) => {
294
+ const instance = await ensureOrchestrator();
295
+ if (typeof instance.normalizeGraphSpec !== "function") {
296
+ throw new Error(
297
+ "@vizij/orchestrator-wasm does not expose normalizeGraphSpec(). Update to a compatible version."
298
+ );
299
+ }
300
+ return await instance.normalizeGraphSpec(spec);
301
+ },
302
+ [ensureOrchestrator]
303
+ );
304
+ const abiVersion = (0, import_react2.useCallback)(async () => {
305
+ await ensureInit();
306
+ return (0, import_orchestrator_wasm.abi_version)();
307
+ }, [ensureInit]);
308
+ const getLatestFrame = (0, import_react2.useCallback)(() => latestFrameRef.current, []);
309
+ const getFrameSnapshot = (0, import_react2.useCallback)(() => latestFrameRef.current, []);
310
+ const subscribeToFrame = (0, import_react2.useCallback)((cb) => {
311
+ const listeners = frameSubscribersRef.current;
312
+ listeners.add(cb);
313
+ return () => {
314
+ listeners.delete(cb);
315
+ };
316
+ }, []);
317
+ const getPathSnapshot = (0, import_react2.useCallback)((path) => {
318
+ try {
319
+ const normalizedPath = normalizeTypedPath(path);
320
+ return pathCacheRef.current.get(normalizedPath);
321
+ } catch {
322
+ return void 0;
323
+ }
324
+ }, []);
325
+ const subscribeToPath = (0, import_react2.useCallback)((path, cb) => {
326
+ if (!path) {
327
+ return noopUnsubscribe;
328
+ }
329
+ let normalizedPath;
330
+ try {
331
+ normalizedPath = normalizeTypedPath(path);
332
+ } catch (err) {
333
+ console.error(
334
+ "@vizij/orchestrator-react: subscribeToPath received invalid path",
335
+ path,
336
+ err
337
+ );
338
+ return noopUnsubscribe;
339
+ }
340
+ let listeners = pathSubscribersRef.current.get(normalizedPath);
341
+ if (!listeners) {
342
+ listeners = /* @__PURE__ */ new Set();
343
+ pathSubscribersRef.current.set(normalizedPath, listeners);
344
+ }
345
+ listeners.add(cb);
346
+ return () => {
347
+ const current = pathSubscribersRef.current.get(normalizedPath);
348
+ if (!current) return;
349
+ current.delete(cb);
350
+ if (current.size === 0) {
351
+ pathSubscribersRef.current.delete(normalizedPath);
352
+ }
353
+ };
354
+ }, []);
355
+ (0, import_react2.useEffect)(() => {
356
+ let cancelled = false;
357
+ ensureInit().catch((err) => {
358
+ if (!cancelled) {
359
+ console.error("@vizij/orchestrator-react: failed to init wasm", err);
360
+ }
361
+ });
362
+ return () => {
363
+ cancelled = true;
364
+ };
365
+ }, [ensureInit]);
366
+ (0, import_react2.useEffect)(() => {
367
+ if (!autoCreate) {
368
+ return;
369
+ }
370
+ let cancelled = false;
371
+ ensureOrchestrator().catch((err) => {
372
+ if (!cancelled) {
373
+ console.error(
374
+ "@vizij/orchestrator-react: failed to create orchestrator",
375
+ err
376
+ );
377
+ }
378
+ }).finally(() => {
379
+ if (!cancelled && mountedRef.current && autoCreate && orchestratorRef.current) {
380
+ setReady(true);
381
+ }
382
+ });
383
+ return () => {
384
+ cancelled = true;
385
+ };
386
+ }, [autoCreate, ensureOrchestrator]);
387
+ (0, import_react2.useEffect)(() => {
388
+ if (!autostart || !ready) {
389
+ return;
390
+ }
391
+ const globalObj = typeof globalThis !== "undefined" ? globalThis : {};
392
+ const request = globalObj.requestAnimationFrame?.bind(globalObj);
393
+ const cancel = globalObj.cancelAnimationFrame?.bind(globalObj);
394
+ if (!request || !cancel) {
395
+ console.warn(
396
+ "@vizij/orchestrator-react: autostart is enabled but requestAnimationFrame is unavailable."
397
+ );
398
+ return;
399
+ }
400
+ let rafId = null;
401
+ let lastTs = 0;
402
+ const loop = (timestamp) => {
403
+ if (!mountedRef.current) {
404
+ return;
405
+ }
406
+ if (lastTs === 0) {
407
+ lastTs = timestamp;
408
+ }
409
+ const dt = Math.max(0, (timestamp - lastTs) / 1e3);
410
+ lastTs = timestamp;
411
+ stepRuntime(dt || 0);
412
+ rafId = request(loop);
413
+ };
414
+ rafId = request(loop);
415
+ return () => {
416
+ if (rafId !== null) {
417
+ cancel(rafId);
418
+ }
419
+ };
420
+ }, [autostart, ready, stepRuntime]);
421
+ (0, import_react2.useEffect)(() => {
422
+ if (initError) {
423
+ console.error("@vizij/orchestrator-react: init error", initError);
424
+ }
425
+ }, [initError]);
426
+ const contextValue = (0, import_react2.useMemo)(
427
+ () => ({
428
+ ready,
429
+ createOrchestrator: createOrchestratorFn,
430
+ registerGraph,
431
+ registerMergedGraph,
432
+ registerAnimation,
433
+ prebind,
434
+ setInput,
435
+ removeInput,
436
+ step: stepRuntime,
437
+ listControllers,
438
+ removeGraph,
439
+ removeAnimation,
440
+ getLatestFrame,
441
+ subscribeToPath,
442
+ getPathSnapshot,
443
+ subscribeToFrame,
444
+ getFrameSnapshot,
445
+ normalizeGraphSpec,
446
+ abiVersion
447
+ }),
448
+ [
449
+ ready,
450
+ createOrchestratorFn,
451
+ registerGraph,
452
+ registerMergedGraph,
453
+ registerAnimation,
454
+ prebind,
455
+ setInput,
456
+ removeInput,
457
+ stepRuntime,
458
+ listControllers,
459
+ removeGraph,
460
+ removeAnimation,
461
+ getLatestFrame,
462
+ subscribeToPath,
463
+ getPathSnapshot,
464
+ subscribeToFrame,
465
+ getFrameSnapshot,
466
+ normalizeGraphSpec,
467
+ abiVersion
468
+ ]
469
+ );
470
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OrchestratorContext.Provider, { value: contextValue, children });
471
+ }
472
+
473
+ // src/hooks/useOrchestrator.ts
474
+ var import_react3 = require("react");
475
+ function useOrchestrator() {
476
+ const ctx = (0, import_react3.useContext)(OrchestratorContext);
477
+ if (!ctx) {
478
+ throw new Error(
479
+ "useOrchestrator must be used within an OrchestratorProvider."
480
+ );
481
+ }
482
+ return ctx;
483
+ }
484
+
485
+ // src/hooks/useOrchTarget.ts
486
+ var import_react4 = require("react");
487
+ function useOrchTarget(path) {
488
+ const ctx = useOrchestrator();
489
+ return (0, import_react4.useSyncExternalStore)(
490
+ (cb) => {
491
+ if (!path) {
492
+ return () => {
493
+ };
494
+ }
495
+ return ctx.subscribeToPath(path, cb);
496
+ },
497
+ () => path ? ctx.getPathSnapshot(path) : void 0,
498
+ () => path ? ctx.getPathSnapshot(path) : void 0
499
+ );
500
+ }
501
+
502
+ // src/hooks/useOrchFrame.ts
503
+ var import_react5 = require("react");
504
+ function useOrchFrame() {
505
+ const ctx = useOrchestrator();
506
+ return (0, import_react5.useSyncExternalStore)(
507
+ (cb) => ctx.subscribeToFrame(cb),
508
+ () => ctx.getFrameSnapshot(),
509
+ () => ctx.getFrameSnapshot()
510
+ );
511
+ }
512
+
513
+ // src/valueHelpers.ts
514
+ var import_value_json = require("@vizij/value-json");
515
+ function valueAsNumber(value) {
516
+ return (0, import_value_json.valueAsNumber)(value);
517
+ }
518
+ function valueAsVec3(value) {
519
+ return (0, import_value_json.valueAsVec3)(value);
520
+ }
521
+ function valueAsBool(value) {
522
+ return (0, import_value_json.valueAsBool)(value);
523
+ }
524
+
525
+ // src/index.ts
526
+ var import_orchestrator_wasm3 = require("@vizij/orchestrator-wasm");
527
+ var samples = {
528
+ list: import_orchestrator_wasm2.listOrchestrationFixtures,
529
+ load: import_orchestrator_wasm2.loadOrchestrationDescriptor,
530
+ loadJson: import_orchestrator_wasm2.loadOrchestrationJson,
531
+ loadBundle: import_orchestrator_wasm2.loadOrchestrationBundle
532
+ };
533
+ // Annotate the CommonJS export names for ESM import in node:
534
+ 0 && (module.exports = {
535
+ OrchestratorProvider,
536
+ OrchestratorRuntime,
537
+ createOrchestratorRuntime,
538
+ initOrchestratorWasm,
539
+ listOrchestrationFixtures,
540
+ loadOrchestrationBundle,
541
+ loadOrchestrationDescriptor,
542
+ loadOrchestrationJson,
543
+ samples,
544
+ useOrchFrame,
545
+ useOrchTarget,
546
+ useOrchestrator,
547
+ valueAsBool,
548
+ valueAsNumber,
549
+ valueAsVec3
550
+ });
@@ -0,0 +1,113 @@
1
+ import { InitInput as InitInput$1, GraphRegistrationInput as GraphRegistrationInput$1, MergedGraphRegistrationConfig as MergedGraphRegistrationConfig$1, MergeStrategyOptions as MergeStrategyOptions$1, MergeConflictStrategy as MergeConflictStrategy$1, AnimationRegistrationConfig as AnimationRegistrationConfig$1, Value, Shape, OrchestratorFrame as OrchestratorFrame$1, WriteOpJSON, ConflictLog, GraphRegistrationConfig as GraphRegistrationConfig$1, GraphSubscriptions as GraphSubscriptions$1, AnimationSetup as AnimationSetup$1, listOrchestrationFixtures, loadOrchestrationDescriptor, loadOrchestrationJson, loadOrchestrationBundle } from '@vizij/orchestrator-wasm';
2
+ export { Orchestrator as OrchestratorRuntime, AnimationRegistrationConfig as WasmAnimationRegistration, AnimationSetup as WasmAnimationSetup, ConflictLog as WasmConflictLog, GraphRegistrationInput as WasmGraphRegistration, GraphRegistrationConfig as WasmGraphRegistrationConfig, GraphSubscriptions as WasmGraphSubscriptions, MergeConflictStrategy as WasmMergeConflictStrategy, MergeStrategyOptions as WasmMergeStrategyOptions, MergedGraphRegistrationConfig as WasmMergedGraphRegistrationConfig, OrchestratorFrame as WasmOrchestratorFrame, Shape as WasmShape, Value as WasmValue, createOrchestrator as createOrchestratorRuntime, init as initOrchestratorWasm, listOrchestrationFixtures, loadOrchestrationBundle, loadOrchestrationDescriptor, loadOrchestrationJson } from '@vizij/orchestrator-wasm';
3
+ import React from 'react';
4
+
5
+ /**
6
+ * Shared type definitions for the orchestrator React integration.
7
+ * These mirror the public wasm surface while layering on React-specific details.
8
+ */
9
+
10
+ /** Values emitted by the orchestrator writes leverage the wasm union. */
11
+ type ValueJSON = Value;
12
+ /** Optional shape metadata describing the serialized value structure. */
13
+ type ShapeJSON = Shape;
14
+ /** Individual write units emitted from the orchestrator frame merge. */
15
+ type WriteOp = WriteOpJSON & {
16
+ player?: number | string;
17
+ };
18
+ type OrchestratorTimings = OrchestratorFrame$1["timings_ms"] & {
19
+ animations_ms?: number;
20
+ graphs_ms?: number;
21
+ };
22
+ type OrchestratorFrame = Omit<OrchestratorFrame$1, "merged_writes"> & {
23
+ merged_writes: WriteOp[];
24
+ };
25
+ type OrchestratorConflict = ConflictLog;
26
+ type InitInput = InitInput$1 | {
27
+ url?: string;
28
+ };
29
+ type PrebindResolver = (path: string) => string | number | null | undefined;
30
+ type CreateOrchOptions = {
31
+ schedule?: "SinglePass" | "TwoPass" | "RateDecoupled";
32
+ };
33
+ type ControllerId = string;
34
+ type GraphRegistrationInput = GraphRegistrationInput$1;
35
+ type GraphRegistrationConfig = GraphRegistrationConfig$1;
36
+ type GraphSubscriptions = GraphSubscriptions$1;
37
+ /**
38
+ * Extended merge conflict strategies recognised by the wasm bridge.
39
+ * Older builds only exposed "error" | "namespace" | "blend", so we
40
+ * widen the union with the newer additive and weighted blend aliases.
41
+ */
42
+ type MergeConflictStrategy = MergeConflictStrategy$1 | "blend_equal" | "blend_equal_weights" | "add" | "sum" | "blend-sum" | "additive" | "default-blend" | "blend-default" | "blend-weights" | "weights";
43
+ type MergeStrategyOptions = Omit<MergeStrategyOptions$1, "outputs" | "intermediate"> & {
44
+ outputs?: MergeConflictStrategy;
45
+ intermediate?: MergeConflictStrategy;
46
+ };
47
+ type MergedGraphRegistrationConfig = Omit<MergedGraphRegistrationConfig$1, "strategy"> & {
48
+ strategy?: MergeStrategyOptions;
49
+ };
50
+ type AnimationRegistrationConfig = AnimationRegistrationConfig$1;
51
+ type AnimationSetup = AnimationSetup$1;
52
+ type OrchestratorReactCtx = {
53
+ ready: boolean;
54
+ createOrchestrator: (opts?: CreateOrchOptions) => Promise<void>;
55
+ registerGraph: (cfg: GraphRegistrationInput) => ControllerId;
56
+ registerMergedGraph: (cfg: MergedGraphRegistrationConfig) => ControllerId;
57
+ registerAnimation: (cfg: AnimationRegistrationConfig) => ControllerId;
58
+ prebind?: (resolver: PrebindResolver) => void;
59
+ setInput: (path: string, value: ValueJSON, shape?: ShapeJSON) => void;
60
+ removeInput: (path: string) => boolean;
61
+ step: (dt: number) => OrchestratorFrame | null;
62
+ listControllers: () => {
63
+ graphs: ControllerId[];
64
+ anims: ControllerId[];
65
+ };
66
+ removeGraph: (id: ControllerId) => boolean;
67
+ removeAnimation: (id: ControllerId) => boolean;
68
+ getLatestFrame: () => OrchestratorFrame | null;
69
+ subscribeToPath: (path: string, cb: () => void) => () => void;
70
+ getPathSnapshot: (path: string) => ValueJSON | undefined;
71
+ subscribeToFrame: (cb: () => void) => () => void;
72
+ getFrameSnapshot: () => OrchestratorFrame | null;
73
+ normalizeGraphSpec?: (spec: object | string) => Promise<object>;
74
+ abiVersion?: () => Promise<number>;
75
+ };
76
+
77
+ type OrchestratorProviderProps = {
78
+ children: React.ReactNode;
79
+ /** Optional init() input forwarded to the wasm layer. */
80
+ initInput?: InitInput;
81
+ /** Automatically create a runtime orchestration instance on mount. Defaults to true. */
82
+ autoCreate?: boolean;
83
+ /** Options passed to the wasm createOrchestrator helper when auto-creating. */
84
+ createOptions?: CreateOrchOptions;
85
+ /**
86
+ * Start a requestAnimationFrame loop once ready. Defaults to false so tests and
87
+ * demos can opt-in to manual stepping.
88
+ */
89
+ autostart?: boolean;
90
+ };
91
+ declare function OrchestratorProvider({ children, initInput, autoCreate, createOptions, autostart, }: OrchestratorProviderProps): JSX.Element;
92
+
93
+ declare function useOrchestrator(): OrchestratorReactCtx;
94
+
95
+ declare function useOrchTarget(path?: string | null): ValueJSON | undefined;
96
+
97
+ declare function useOrchFrame(): OrchestratorFrame | null;
98
+
99
+ declare function valueAsNumber(value: ValueJSON | undefined): number | undefined;
100
+ declare function valueAsVec3(value: ValueJSON | undefined): [number, number, number] | undefined;
101
+ declare function valueAsBool(value: ValueJSON | undefined): boolean | undefined;
102
+
103
+ /**
104
+ * Standardised access to embedded orchestration samples for quick-start demos and tests.
105
+ */
106
+ declare const samples: {
107
+ readonly list: typeof listOrchestrationFixtures;
108
+ readonly load: typeof loadOrchestrationDescriptor;
109
+ readonly loadJson: typeof loadOrchestrationJson;
110
+ readonly loadBundle: typeof loadOrchestrationBundle;
111
+ };
112
+
113
+ export { type AnimationRegistrationConfig, type AnimationSetup, type ControllerId, type CreateOrchOptions, type GraphRegistrationConfig, type GraphRegistrationInput, type GraphSubscriptions, type InitInput, type MergeConflictStrategy, type MergeStrategyOptions, type MergedGraphRegistrationConfig, type OrchestratorConflict, type OrchestratorFrame, OrchestratorProvider, type OrchestratorProviderProps, type OrchestratorReactCtx, type OrchestratorTimings, type PrebindResolver, type ShapeJSON, type ValueJSON, type WriteOp, samples, useOrchFrame, useOrchTarget, useOrchestrator, valueAsBool, valueAsNumber, valueAsVec3 };