@zaflun/lumio-sdk 0.6.6 → 0.11.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.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import React, { CSSProperties } from 'react';
2
- import { LumioEventType, LumioActionType, Sound } from '@zaflun/lumio-protocol';
2
+ import { LumioEventType, LumioEventPayloadMap, LumioActionType, Sound } from '@zaflun/lumio-protocol';
3
3
  export { Sound } from '@zaflun/lumio-protocol';
4
4
 
5
5
  interface RenderOptions {
6
- target: "editor" | "layer" | "interactive";
6
+ target: "editor" | "layer";
7
7
  }
8
8
  declare const Lumio: {
9
9
  render(element: React.ReactElement, options: RenderOptions): void;
@@ -338,19 +338,37 @@ declare function useVisionState<T>(key: string, defaultValue: T): [T, (value: T)
338
338
 
339
339
  interface ExtensionContext {
340
340
  extensionId: string | null;
341
- target: "editor" | "layer" | "interactive" | null;
341
+ target: "editor" | "layer" | null;
342
342
  overlayId: string | null;
343
- interactiveUrl: string | null;
344
343
  }
344
+ /**
345
+ * The install this surface renders. Set from `lifecycle.init`, which the host
346
+ * sends before the bundle runs, so the first render already has it.
347
+ */
345
348
  declare function useExtensionContext(): ExtensionContext;
346
349
 
347
- declare function useLumioEvent(eventType: LumioEventType): unknown | null;
350
+ /**
351
+ * The latest payload of one platform event type, or `null` until the first
352
+ * one arrives. The payload type follows `type`, e.g.
353
+ * `useLumioEvent("twitch:cheer")?.bits` is a `number`.
354
+ */
355
+ declare function useLumioEvent<K extends LumioEventType>(eventType: K): LumioEventPayloadMap[K] | null;
356
+
357
+ /**
358
+ * Calls `cb` with the payload of every message a handler of this install
359
+ * pushes on `topic` with `ctx.realtime.push(topic, payload)`. Runs on every
360
+ * rendered surface of the install (editor and layer). The host delivers what
361
+ * arrives while the surface is open; nothing is replayed.
362
+ *
363
+ * `cb` may change between renders without re-subscribing.
364
+ */
365
+ declare function useRealtime<T = unknown>(topic: string, cb: (payload: T) => void): void;
348
366
 
349
367
  interface LumioConfig {
350
368
  extension_id?: string;
351
369
  install_id?: string;
352
370
  account_id?: string;
353
- target?: "editor" | "layer" | "interactive";
371
+ target?: "editor" | "layer";
354
372
  permissions?: string[];
355
373
  settings?: Record<string, unknown>;
356
374
  }
@@ -361,6 +379,11 @@ declare global {
361
379
  __lumio_on_config?: (fn: (config: LumioConfig) => void) => () => void;
362
380
  }
363
381
  }
382
+ /**
383
+ * The install's config. Starts from `lifecycle.init`, which the host sends
384
+ * before the bundle runs, so the first render already has it. A
385
+ * `config.update` from the host replaces only the fields it carries.
386
+ */
364
387
  declare function useLumioConfig(): [LumioConfig, (configOrUpdater: LumioConfig | ((prev: LumioConfig) => LumioConfig)) => void];
365
388
 
366
389
  interface OverlayTheme {
@@ -389,11 +412,12 @@ interface OverlayTheme {
389
412
  * Returns the active overlay/widget theme variables.
390
413
  *
391
414
  * Extensions use this to style themselves consistently with the
392
- * overlay or widget they're rendered in. Only relevant for `layer`
393
- * and `interactive` targets (stream overlay, widget pages).
415
+ * overlay or widget they're rendered in. Only relevant for the `layer`
416
+ * target (stream overlay, widget pages).
394
417
  *
395
- * Theme is provided via lifecycle.init and updated via theme.change when
396
- * the user switches the overlay/widget theme.
418
+ * The theme comes from `lifecycle.init`, which the host sends before the
419
+ * bundle runs, so the first render already has it. A `theme.change` from the
420
+ * host updates it.
397
421
  */
398
422
  declare function useLumioTheme(): OverlayTheme;
399
423
 
@@ -402,10 +426,15 @@ interface LumioIdentity {
402
426
  accountId: string | null;
403
427
  role: string | null;
404
428
  }
429
+ /**
430
+ * Who this surface renders for. Set from `lifecycle.init`, which the host
431
+ * sends before the bundle runs, so the first render already has it.
432
+ */
405
433
  declare function useLumioIdentity(): LumioIdentity;
406
434
 
407
435
  interface UseLumioActionResult {
408
- execute: (params?: Record<string, unknown>) => void;
436
+ /** Runs the action. Resolves once it settled; a failure lands in `error`, never as a rejection. */
437
+ execute: (params?: Record<string, unknown>) => Promise<void>;
409
438
  data: unknown | null;
410
439
  isLoading: boolean;
411
440
  error: string | null;
@@ -690,4 +719,5 @@ interface LocalFontDefinition {
690
719
  }
691
720
  declare function localFont(options: LocalFontOptions): LocalFontDefinition;
692
721
 
693
- export { ANIMATION_PRESETS, Animated, type AnimatedProps, type AnimationPresetName, Box, type BoxProps, Button, type ButtonProps, CompactView, type CompactViewProps, Dropdown, type DropdownOption, type DropdownProps, EditorButton, type EditorButtonProps, EditorChannelRow, type EditorChannelRowProps, EditorCheckbox, type EditorCheckboxProps, EditorColorPicker, type EditorColorPickerProps, EditorDivider, EditorFontPicker, type EditorFontPickerProps, EditorFontRow, type EditorFontRowProps, EditorGroup, type EditorGroupProps, EditorInfo, type EditorInfoProps, EditorInput, type EditorInputProps, EditorLabel, type EditorLabelProps, EditorSelect, type EditorSelectOption, type EditorSelectProps, EditorSlider, type EditorSliderProps, EditorTextarea, type EditorTextareaProps, type ExtensionContext, type FontDisplay, type FontSource, HStack, type HStackProps, IconDisplay, type IconDisplayProps, IconPicker, type IconPickerProps, type IconPickerSize, type IconSource, type IconValue, Image, type ImageProps, type KeyframeBlock, type KeyframeDefinition, List, type ListProps, type LocalFontDefinition, type LocalFontOptions, Lumio, type LumioConfig, type LumioIdentity, NumberField, type NumberFieldProps, type OverlayTheme, type RenderOptions, Slider, type SliderProps, Text, TextArea, type TextAreaProps, TextField, type TextFieldProps, type TextProps, Toggle, type ToggleProps, type UseAnimationResult, type UseIconPickerOptions, type UseIconPickerResult, type UseLumioActionResult, type UseLumioSoundResult, type UseMutationResult, type UseQueryResult, VStack, type VStackProps, type VisionStyle, WorkerBridge, defineKeyframes, flushKeyframes, getPreset, localFont, useAnimation, useEditorAction, useExtensionContext, useExtensionStorage, useIconPicker, useLumioAction, useLumioConfig, useLumioEvent, useLumioIdentity, useLumioSound, useLumioTheme, useMutation, useQuery, useVisionState };
722
+ export { ANIMATION_PRESETS, Animated, Box, Button, CompactView, Dropdown, EditorButton, EditorChannelRow, EditorCheckbox, EditorColorPicker, EditorDivider, EditorFontPicker, EditorFontRow, EditorGroup, EditorInfo, EditorInput, EditorLabel, EditorSelect, EditorSlider, EditorTextarea, HStack, IconDisplay, IconPicker, Image, List, Lumio, NumberField, Slider, Text, TextArea, TextField, Toggle, VStack, WorkerBridge, defineKeyframes, flushKeyframes, getPreset, localFont, useAnimation, useEditorAction, useExtensionContext, useExtensionStorage, useIconPicker, useLumioAction, useLumioConfig, useLumioEvent, useLumioIdentity, useLumioSound, useLumioTheme, useMutation, useQuery, useRealtime, useVisionState };
723
+ export type { AnimatedProps, AnimationPresetName, BoxProps, ButtonProps, CompactViewProps, DropdownOption, DropdownProps, EditorButtonProps, EditorChannelRowProps, EditorCheckboxProps, EditorColorPickerProps, EditorFontPickerProps, EditorFontRowProps, EditorGroupProps, EditorInfoProps, EditorInputProps, EditorLabelProps, EditorSelectOption, EditorSelectProps, EditorSliderProps, EditorTextareaProps, ExtensionContext, FontDisplay, FontSource, HStackProps, IconDisplayProps, IconPickerProps, IconPickerSize, IconSource, IconValue, ImageProps, KeyframeBlock, KeyframeDefinition, ListProps, LocalFontDefinition, LocalFontOptions, LumioConfig, LumioIdentity, NumberFieldProps, OverlayTheme, RenderOptions, SliderProps, TextAreaProps, TextFieldProps, TextProps, ToggleProps, UseAnimationResult, UseIconPickerOptions, UseIconPickerResult, UseLumioActionResult, UseLumioSoundResult, UseMutationResult, UseQueryResult, VStackProps, VisionStyle };
package/dist/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ import {
2
+ WorkerBridge,
3
+ getBridge,
4
+ getInitParams
5
+ } from "./chunk-GVAYWB5X.js";
6
+
1
7
  // src/core/lumio.tsx
2
8
  import { createRoot } from "react-dom/client";
3
9
  var RENDER_TIMEOUT_MS = 1e4;
@@ -53,116 +59,6 @@ var Lumio = {
53
59
  }
54
60
  };
55
61
 
56
- // src/bridge/WorkerBridge.ts
57
- var WorkerBridge = class {
58
- notificationHandlers = /* @__PURE__ */ new Map();
59
- requestHandlers = /* @__PURE__ */ new Map();
60
- pendingRequests = /* @__PURE__ */ new Map();
61
- requestCounter = 0;
62
- requestTimeout;
63
- messageListener = null;
64
- destroyed = false;
65
- constructor(options) {
66
- this.requestTimeout = options?.requestTimeout ?? 3e4;
67
- this.messageListener = this.handleMessage.bind(this);
68
- globalThis.addEventListener("message", this.messageListener);
69
- }
70
- notify(method, params) {
71
- const msg = {
72
- jsonrpc: "2.0",
73
- method,
74
- ...params !== void 0 ? { params } : {}
75
- };
76
- globalThis.postMessage(msg);
77
- }
78
- request(method, params) {
79
- const id = `req_${++this.requestCounter}`;
80
- const msg = {
81
- jsonrpc: "2.0",
82
- id,
83
- method,
84
- ...params !== void 0 ? { params } : {}
85
- };
86
- return new Promise((resolve, reject) => {
87
- const timer = setTimeout(() => {
88
- this.pendingRequests.delete(id);
89
- reject(new Error("Request timeout"));
90
- }, this.requestTimeout);
91
- this.pendingRequests.set(id, { resolve, reject, timer });
92
- globalThis.postMessage(msg);
93
- });
94
- }
95
- onNotification(method, handler) {
96
- if (!this.notificationHandlers.has(method)) {
97
- this.notificationHandlers.set(method, /* @__PURE__ */ new Set());
98
- }
99
- this.notificationHandlers.get(method).add(handler);
100
- return () => {
101
- this.notificationHandlers.get(method)?.delete(handler);
102
- };
103
- }
104
- onRequest(method, handler) {
105
- this.requestHandlers.set(method, handler);
106
- }
107
- destroy() {
108
- this.destroyed = true;
109
- if (this.messageListener) {
110
- globalThis.removeEventListener("message", this.messageListener);
111
- this.messageListener = null;
112
- }
113
- for (const { timer, reject } of this.pendingRequests.values()) {
114
- if (timer) clearTimeout(timer);
115
- reject(new Error("Bridge destroyed"));
116
- }
117
- this.pendingRequests.clear();
118
- this.notificationHandlers.clear();
119
- this.requestHandlers.clear();
120
- }
121
- handleMessage(event) {
122
- if (this.destroyed) return;
123
- const data = event.data;
124
- if (!data || typeof data !== "object" || data.jsonrpc !== "2.0") return;
125
- if ("id" in data && !("method" in data)) {
126
- const pending = this.pendingRequests.get(data.id);
127
- if (pending) {
128
- this.pendingRequests.delete(data.id);
129
- if (pending.timer) clearTimeout(pending.timer);
130
- if (data.error) {
131
- pending.reject(new Error(data.error.message));
132
- } else {
133
- pending.resolve(data.result);
134
- }
135
- }
136
- return;
137
- }
138
- if ("id" in data && "method" in data) {
139
- const handler = this.requestHandlers.get(data.method);
140
- if (handler) {
141
- handler(data.params).then((result) => {
142
- const response = { jsonrpc: "2.0", id: data.id, result };
143
- globalThis.postMessage(response);
144
- }).catch((err) => {
145
- const response = {
146
- jsonrpc: "2.0",
147
- id: data.id,
148
- error: { code: -32603, message: err.message }
149
- };
150
- globalThis.postMessage(response);
151
- });
152
- }
153
- return;
154
- }
155
- if ("method" in data && !("id" in data)) {
156
- const handlers = this.notificationHandlers.get(data.method);
157
- if (handlers) {
158
- for (const handler of handlers) {
159
- handler(data.params);
160
- }
161
- }
162
- }
163
- }
164
- };
165
-
166
62
  // src/components/Box.tsx
167
63
  import React from "react";
168
64
  function Box({ children, style }) {
@@ -361,17 +257,6 @@ function EditorChannelRow(props) {
361
257
 
362
258
  // src/hooks/useEditorAction.ts
363
259
  import { useCallback } from "react";
364
-
365
- // src/renderer/bridge-context.ts
366
- var bridgeInstance = null;
367
- function getBridge() {
368
- if (!bridgeInstance) {
369
- bridgeInstance = new WorkerBridge();
370
- }
371
- return bridgeInstance;
372
- }
373
-
374
- // src/hooks/useEditorAction.ts
375
260
  function useEditorAction() {
376
261
  const dispatch = useCallback((action, payload) => {
377
262
  const bridge = getBridge();
@@ -482,24 +367,25 @@ import { HOST_METHODS as HOST_METHODS3 } from "@zaflun/lumio-protocol";
482
367
  var defaultContext = {
483
368
  extensionId: null,
484
369
  target: null,
485
- overlayId: null,
486
- interactiveUrl: null
370
+ overlayId: null
487
371
  };
372
+ function fromInit(p) {
373
+ return {
374
+ extensionId: p.extensionId ?? null,
375
+ target: p.target ?? null,
376
+ overlayId: p.installId ?? null
377
+ };
378
+ }
488
379
  function useExtensionContext() {
489
- const [context, setContext] = useState4(defaultContext);
380
+ const [context, setContext] = useState4(() => {
381
+ const init = getInitParams();
382
+ return init ? fromInit(init) : defaultContext;
383
+ });
490
384
  useEffect3(() => {
491
385
  const bridge = getBridge();
492
386
  const unsub = bridge.onNotification(
493
387
  HOST_METHODS3.LIFECYCLE_INIT,
494
- (params) => {
495
- const p = params;
496
- setContext({
497
- extensionId: p.extensionId ?? null,
498
- target: p.target ?? null,
499
- overlayId: p.installId ?? null,
500
- interactiveUrl: p.interactiveUrl ?? null
501
- });
502
- }
388
+ (params) => setContext(fromInit(params))
503
389
  );
504
390
  return unsub;
505
391
  }, []);
@@ -510,7 +396,9 @@ function useExtensionContext() {
510
396
  import { useState as useState5, useEffect as useEffect4 } from "react";
511
397
  import { HOST_METHODS as HOST_METHODS4 } from "@zaflun/lumio-protocol";
512
398
  function useLumioEvent(eventType) {
513
- const [eventData, setEventData] = useState5(null);
399
+ const [eventData, setEventData] = useState5(
400
+ null
401
+ );
514
402
  useEffect4(() => {
515
403
  const bridge = getBridge();
516
404
  const unsub = bridge.onNotification(
@@ -527,18 +415,46 @@ function useLumioEvent(eventType) {
527
415
  return eventData;
528
416
  }
529
417
 
418
+ // src/hooks/useRealtime.ts
419
+ import { useEffect as useEffect5, useRef } from "react";
420
+ import { HOST_METHODS as HOST_METHODS5 } from "@zaflun/lumio-protocol";
421
+ function useRealtime(topic, cb) {
422
+ const cbRef = useRef(cb);
423
+ cbRef.current = cb;
424
+ useEffect5(() => {
425
+ const bridge = getBridge();
426
+ return bridge.onNotification(HOST_METHODS5.SERVER_REALTIME, (params) => {
427
+ const p = params;
428
+ if (p && p.topic === topic) {
429
+ cbRef.current(p.payload);
430
+ }
431
+ });
432
+ }, [topic]);
433
+ }
434
+
530
435
  // src/hooks/useLumioConfig.ts
531
- import { useState as useState6, useEffect as useEffect5, useCallback as useCallback5 } from "react";
532
- import { HOST_METHODS as HOST_METHODS5, WORKER_METHODS as WORKER_METHODS3 } from "@zaflun/lumio-protocol";
436
+ import { useState as useState6, useEffect as useEffect6, useCallback as useCallback5 } from "react";
437
+ import { HOST_METHODS as HOST_METHODS6, WORKER_METHODS as WORKER_METHODS3 } from "@zaflun/lumio-protocol";
533
438
  function hasShim() {
534
439
  return typeof window !== "undefined" && typeof window.__lumio_config === "function";
535
440
  }
441
+ function fromInit2(p) {
442
+ return {
443
+ extension_id: p.extensionId,
444
+ install_id: p.installId,
445
+ account_id: p.accountId,
446
+ target: p.target,
447
+ permissions: p.permissions,
448
+ settings: p.settings
449
+ };
450
+ }
536
451
  function useLumioConfig() {
537
452
  const [config, setConfigState] = useState6(() => {
538
453
  if (hasShim()) return window.__lumio_config();
539
- return {};
454
+ const init = getInitParams();
455
+ return init ? fromInit2(init) : {};
540
456
  });
541
- useEffect5(() => {
457
+ useEffect6(() => {
542
458
  if (hasShim()) {
543
459
  const unsub2 = window.__lumio_on_config((newConfig) => {
544
460
  setConfigState(newConfig);
@@ -548,24 +464,14 @@ function useLumioConfig() {
548
464
  }
549
465
  const bridge = getBridge();
550
466
  const unsub = bridge.onNotification(
551
- HOST_METHODS5.LIFECYCLE_INIT,
552
- (params) => {
553
- const p = params;
554
- setConfigState({
555
- extension_id: p.extensionId,
556
- install_id: p.installId,
557
- account_id: p.accountId,
558
- target: p.target,
559
- permissions: p.permissions,
560
- settings: p.settings
561
- });
562
- }
467
+ HOST_METHODS6.LIFECYCLE_INIT,
468
+ (params) => setConfigState(fromInit2(params))
563
469
  );
564
470
  const unsubConfig = bridge.onNotification(
565
- HOST_METHODS5.CONFIG_UPDATE,
471
+ HOST_METHODS6.CONFIG_UPDATE,
566
472
  (params) => {
567
473
  const p = params;
568
- setConfigState(p);
474
+ setConfigState((prev) => ({ ...prev, ...p }));
569
475
  }
570
476
  );
571
477
  return () => {
@@ -592,8 +498,8 @@ function useLumioConfig() {
592
498
  }
593
499
 
594
500
  // src/hooks/useLumioTheme.ts
595
- import { useState as useState7, useEffect as useEffect6 } from "react";
596
- import { HOST_METHODS as HOST_METHODS6 } from "@zaflun/lumio-protocol";
501
+ import { useState as useState7, useEffect as useEffect7 } from "react";
502
+ import { HOST_METHODS as HOST_METHODS7 } from "@zaflun/lumio-protocol";
597
503
  var DEFAULT_THEME = {
598
504
  colors: {
599
505
  primary: "#6366f1",
@@ -617,11 +523,14 @@ var DEFAULT_THEME = {
617
523
  spacing: 8
618
524
  };
619
525
  function useLumioTheme() {
620
- const [theme, setTheme] = useState7(DEFAULT_THEME);
621
- useEffect6(() => {
526
+ const [theme, setTheme] = useState7(() => {
527
+ const initTheme = getInitParams()?.theme;
528
+ return initTheme ? { ...DEFAULT_THEME, ...initTheme } : DEFAULT_THEME;
529
+ });
530
+ useEffect7(() => {
622
531
  const bridge = getBridge();
623
532
  const unsubInit = bridge.onNotification(
624
- HOST_METHODS6.LIFECYCLE_INIT,
533
+ HOST_METHODS7.LIFECYCLE_INIT,
625
534
  (params) => {
626
535
  const p = params;
627
536
  if (p.theme) {
@@ -630,7 +539,7 @@ function useLumioTheme() {
630
539
  }
631
540
  );
632
541
  const unsubTheme = bridge.onNotification(
633
- HOST_METHODS6.THEME_CHANGE,
542
+ HOST_METHODS7.THEME_CHANGE,
634
543
  (params) => {
635
544
  const p = params;
636
545
  if (p.theme) {
@@ -647,27 +556,30 @@ function useLumioTheme() {
647
556
  }
648
557
 
649
558
  // src/hooks/useLumioIdentity.ts
650
- import { useState as useState8, useEffect as useEffect7 } from "react";
651
- import { HOST_METHODS as HOST_METHODS7 } from "@zaflun/lumio-protocol";
559
+ import { useState as useState8, useEffect as useEffect8 } from "react";
560
+ import { HOST_METHODS as HOST_METHODS8 } from "@zaflun/lumio-protocol";
652
561
  var defaultIdentity = {
653
562
  userId: null,
654
563
  accountId: null,
655
564
  role: null
656
565
  };
566
+ function fromInit3(p) {
567
+ return {
568
+ userId: p.userId ?? null,
569
+ accountId: p.accountId ?? null,
570
+ role: p.role ?? null
571
+ };
572
+ }
657
573
  function useLumioIdentity() {
658
- const [identity, setIdentity] = useState8(defaultIdentity);
659
- useEffect7(() => {
574
+ const [identity, setIdentity] = useState8(() => {
575
+ const init = getInitParams();
576
+ return init ? fromInit3(init) : defaultIdentity;
577
+ });
578
+ useEffect8(() => {
660
579
  const bridge = getBridge();
661
580
  const unsub = bridge.onNotification(
662
- HOST_METHODS7.LIFECYCLE_INIT,
663
- (params) => {
664
- const p = params;
665
- setIdentity({
666
- userId: p.userId ?? null,
667
- accountId: p.accountId ?? null,
668
- role: p.role ?? null
669
- });
670
- }
581
+ HOST_METHODS8.LIFECYCLE_INIT,
582
+ (params) => setIdentity(fromInit3(params))
671
583
  );
672
584
  return unsub;
673
585
  }, []);
@@ -675,27 +587,27 @@ function useLumioIdentity() {
675
587
  }
676
588
 
677
589
  // src/hooks/useLumioAction.ts
678
- import { useState as useState9, useCallback as useCallback6, useRef } from "react";
590
+ import { useState as useState9, useCallback as useCallback6 } from "react";
591
+ import { WORKER_METHODS as WORKER_METHODS4 } from "@zaflun/lumio-protocol";
679
592
  function useLumioAction(action) {
680
593
  const [data, setData] = useState9(null);
681
594
  const [isLoading, setIsLoading] = useState9(false);
682
595
  const [error, setError] = useState9(null);
683
- const actionRef = useRef(action);
684
- actionRef.current = action;
685
596
  const execute = useCallback6(
686
- (params = {}) => {
597
+ async (params = {}) => {
687
598
  setIsLoading(true);
688
599
  setError(null);
689
- const bridge = getBridge();
690
- bridge.request("action.execute", { action, params }).then((result) => {
691
- setIsLoading(false);
692
- setData(result ?? null);
600
+ const request = { action, params };
601
+ try {
602
+ const result = await getBridge().request(WORKER_METHODS4.ACTION_EXECUTE, request);
603
+ setData(result?.data ?? null);
693
604
  setError(null);
694
- }).catch((err) => {
695
- setIsLoading(false);
605
+ } catch (err) {
696
606
  setError(err instanceof Error ? err.message : "Unknown error");
697
607
  setData(null);
698
- });
608
+ } finally {
609
+ setIsLoading(false);
610
+ }
699
611
  },
700
612
  [action]
701
613
  );
@@ -704,27 +616,27 @@ function useLumioAction(action) {
704
616
 
705
617
  // src/hooks/useLumioSound.ts
706
618
  import { useCallback as useCallback7 } from "react";
707
- import { WORKER_METHODS as WORKER_METHODS4 } from "@zaflun/lumio-protocol";
619
+ import { WORKER_METHODS as WORKER_METHODS5 } from "@zaflun/lumio-protocol";
708
620
  function useLumioSound() {
709
621
  const playSound = useCallback7(async (soundId, volume) => {
710
622
  const bridge = getBridge();
711
- await bridge.request(WORKER_METHODS4.SOUND_PLAY, { sound_id: soundId, volume });
623
+ await bridge.request(WORKER_METHODS5.SOUND_PLAY, { sound_id: soundId, volume });
712
624
  }, []);
713
625
  const stopSound = useCallback7(async (soundId) => {
714
626
  const bridge = getBridge();
715
- await bridge.request(WORKER_METHODS4.SOUND_STOP, { sound_id: soundId });
627
+ await bridge.request(WORKER_METHODS5.SOUND_STOP, { sound_id: soundId });
716
628
  }, []);
717
629
  const getSounds = useCallback7(async () => {
718
630
  const bridge = getBridge();
719
- const result = await bridge.request(WORKER_METHODS4.SOUND_LIST, {});
631
+ const result = await bridge.request(WORKER_METHODS5.SOUND_LIST, {});
720
632
  return result ?? [];
721
633
  }, []);
722
634
  return { playSound, stopSound, getSounds };
723
635
  }
724
636
 
725
637
  // src/hooks/useQuery.ts
726
- import { useState as useState10, useEffect as useEffect8, useCallback as useCallback8, useRef as useRef2 } from "react";
727
- import { WORKER_METHODS as WORKER_METHODS5 } from "@zaflun/lumio-protocol";
638
+ import { useState as useState10, useEffect as useEffect9, useCallback as useCallback8, useRef as useRef2 } from "react";
639
+ import { WORKER_METHODS as WORKER_METHODS6 } from "@zaflun/lumio-protocol";
728
640
  function useQuery(functionName, params) {
729
641
  const [data, setData] = useState10(null);
730
642
  const [isLoading, setIsLoading] = useState10(false);
@@ -735,7 +647,7 @@ function useQuery(functionName, params) {
735
647
  setIsLoading(true);
736
648
  setError(null);
737
649
  const bridge = getBridge();
738
- bridge.request(WORKER_METHODS5.SERVER_QUERY, { fn: functionName, params: params ?? {} }).then((result) => {
650
+ bridge.request(WORKER_METHODS6.SERVER_QUERY, { fn: functionName, params: params ?? {} }).then((result) => {
739
651
  setIsLoading(false);
740
652
  setData(result ?? null);
741
653
  setError(null);
@@ -745,7 +657,7 @@ function useQuery(functionName, params) {
745
657
  setData(null);
746
658
  });
747
659
  }, [functionName, params]);
748
- useEffect8(() => {
660
+ useEffect9(() => {
749
661
  sendQuery();
750
662
  }, [sendQuery]);
751
663
  return { data, isLoading, error, refetch: sendQuery };
@@ -753,7 +665,7 @@ function useQuery(functionName, params) {
753
665
 
754
666
  // src/hooks/useMutation.ts
755
667
  import { useState as useState11, useCallback as useCallback9 } from "react";
756
- import { WORKER_METHODS as WORKER_METHODS6 } from "@zaflun/lumio-protocol";
668
+ import { WORKER_METHODS as WORKER_METHODS7 } from "@zaflun/lumio-protocol";
757
669
  function useMutation(functionName) {
758
670
  const [data, setData] = useState11(null);
759
671
  const [isLoading, setIsLoading] = useState11(false);
@@ -763,7 +675,7 @@ function useMutation(functionName) {
763
675
  setIsLoading(true);
764
676
  setError(null);
765
677
  const bridge = getBridge();
766
- return bridge.request(WORKER_METHODS6.SERVER_MUTATION, { fn: functionName, params }).then((result) => {
678
+ return bridge.request(WORKER_METHODS7.SERVER_MUTATION, { fn: functionName, params }).then((result) => {
767
679
  setIsLoading(false);
768
680
  setData(result ?? null);
769
681
  setError(null);
@@ -878,7 +790,7 @@ function getPreset(name) {
878
790
  }
879
791
 
880
792
  // src/animation/Animated.tsx
881
- import React31, { useEffect as useEffect9, useRef as useRef3, useState as useState12 } from "react";
793
+ import React31, { useEffect as useEffect10, useRef as useRef3, useState as useState12 } from "react";
882
794
  function resolveAnimation(name) {
883
795
  if (name === void 0) return void 0;
884
796
  try {
@@ -908,7 +820,7 @@ function Animated({
908
820
  timerRef.current = null;
909
821
  }
910
822
  }
911
- useEffect9(() => {
823
+ useEffect10(() => {
912
824
  const prevVisible = prevVisibleRef.current;
913
825
  prevVisibleRef.current = visible;
914
826
  if (visible && !prevVisible) {
@@ -919,7 +831,7 @@ function Animated({
919
831
  setPhase("out");
920
832
  }
921
833
  }, [visible]);
922
- useEffect9(() => {
834
+ useEffect10(() => {
923
835
  if (phase === "in") {
924
836
  const totalDuration = duration + delay;
925
837
  if (loopProp !== void 0) {
@@ -1123,5 +1035,6 @@ export {
1123
1035
  useLumioTheme,
1124
1036
  useMutation,
1125
1037
  useQuery,
1038
+ useRealtime,
1126
1039
  useVisionState
1127
1040
  };