@zaflun/lumio-sdk 0.3.0 → 0.6.6
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 +207 -3
- package/dist/index.js +286 -55
- package/dist/lumio-runtime.global.js +9060 -138
- package/dist/server.d.ts +165 -1
- package/dist/server.js +26 -0
- package/package.json +14 -10
package/dist/index.js
CHANGED
|
@@ -3,6 +3,15 @@ import { createRoot } from "react-dom/client";
|
|
|
3
3
|
var RENDER_TIMEOUT_MS = 1e4;
|
|
4
4
|
var hasRendered = false;
|
|
5
5
|
var renderTimeout = null;
|
|
6
|
+
function hostOrigin() {
|
|
7
|
+
try {
|
|
8
|
+
if (typeof document !== "undefined" && document.referrer) {
|
|
9
|
+
return new URL(document.referrer).origin;
|
|
10
|
+
}
|
|
11
|
+
} catch {
|
|
12
|
+
}
|
|
13
|
+
return "*";
|
|
14
|
+
}
|
|
6
15
|
function startRenderTimeout() {
|
|
7
16
|
if (renderTimeout) return;
|
|
8
17
|
renderTimeout = setTimeout(() => {
|
|
@@ -16,7 +25,7 @@ function startRenderTimeout() {
|
|
|
16
25
|
code: "RENDER_TIMEOUT",
|
|
17
26
|
message: "Extension did not render within 10 seconds"
|
|
18
27
|
},
|
|
19
|
-
|
|
28
|
+
hostOrigin()
|
|
20
29
|
);
|
|
21
30
|
}
|
|
22
31
|
}, RENDER_TIMEOUT_MS);
|
|
@@ -39,7 +48,7 @@ var Lumio = {
|
|
|
39
48
|
}
|
|
40
49
|
const root = createRoot(rootElement);
|
|
41
50
|
root.render(element);
|
|
42
|
-
window.parent.postMessage({ type: "READY" },
|
|
51
|
+
window.parent.postMessage({ type: "READY" }, hostOrigin());
|
|
43
52
|
void options;
|
|
44
53
|
}
|
|
45
54
|
};
|
|
@@ -242,8 +251,116 @@ function Slider({ label, value, onChange, min, max, step = 1 }) {
|
|
|
242
251
|
return React14.createElement("Slider", { label, value, onChange, min, max, step });
|
|
243
252
|
}
|
|
244
253
|
|
|
245
|
-
// src/
|
|
246
|
-
import
|
|
254
|
+
// src/components/IconPicker.tsx
|
|
255
|
+
import React15 from "react";
|
|
256
|
+
function IconPicker({
|
|
257
|
+
value,
|
|
258
|
+
onChange,
|
|
259
|
+
sources,
|
|
260
|
+
size,
|
|
261
|
+
placeholder
|
|
262
|
+
}) {
|
|
263
|
+
return React15.createElement("IconPicker", {
|
|
264
|
+
value,
|
|
265
|
+
onChange,
|
|
266
|
+
sources,
|
|
267
|
+
size,
|
|
268
|
+
placeholder
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// src/components/IconDisplay.tsx
|
|
273
|
+
import React16 from "react";
|
|
274
|
+
function IconDisplay({ icon, size, className }) {
|
|
275
|
+
return React16.createElement("IconDisplay", { icon, size, className });
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// src/components/EditorInput.tsx
|
|
279
|
+
import React17 from "react";
|
|
280
|
+
function EditorInput({ value, onChange, placeholder, type, min, max, step, unit, label, id }) {
|
|
281
|
+
return React17.createElement("EditorInput", { value, onChange, placeholder, type, min, max, step, unit, label, id });
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// src/components/EditorTextarea.tsx
|
|
285
|
+
import React18 from "react";
|
|
286
|
+
function EditorTextarea({ value, onChange, placeholder, rows, label, id }) {
|
|
287
|
+
return React18.createElement("EditorTextarea", { value, onChange, placeholder, rows, label, id });
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/components/EditorSelect.tsx
|
|
291
|
+
import React19 from "react";
|
|
292
|
+
function EditorSelect({ value, onChange, options, label, id }) {
|
|
293
|
+
return React19.createElement("EditorSelect", { value, onChange, options, label, id });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// src/components/EditorCheckbox.tsx
|
|
297
|
+
import React20 from "react";
|
|
298
|
+
function EditorCheckbox({ checked, onChange, label, id }) {
|
|
299
|
+
return React20.createElement("EditorCheckbox", { checked, onChange, label, id });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/components/EditorSlider.tsx
|
|
303
|
+
import React21 from "react";
|
|
304
|
+
function EditorSlider({ value, onChange, min, max, step, unit, label, id }) {
|
|
305
|
+
return React21.createElement("EditorSlider", { value, onChange, min, max, step, unit, label, id });
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// src/components/EditorColorPicker.tsx
|
|
309
|
+
import React22 from "react";
|
|
310
|
+
function EditorColorPicker(props) {
|
|
311
|
+
return React22.createElement("EditorColorPicker", props);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/components/EditorGroup.tsx
|
|
315
|
+
import React23 from "react";
|
|
316
|
+
function EditorGroup({ label, collapsed, children }) {
|
|
317
|
+
return React23.createElement("EditorGroup", { label, collapsed }, children);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/components/EditorLabel.tsx
|
|
321
|
+
import React24 from "react";
|
|
322
|
+
function EditorLabel({ text, htmlFor, required }) {
|
|
323
|
+
return React24.createElement("EditorLabel", { text, htmlFor, required });
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/components/EditorDivider.tsx
|
|
327
|
+
import React25 from "react";
|
|
328
|
+
function EditorDivider() {
|
|
329
|
+
return React25.createElement("EditorDivider", {});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// src/components/EditorInfo.tsx
|
|
333
|
+
import React26 from "react";
|
|
334
|
+
function EditorInfo({ content }) {
|
|
335
|
+
return React26.createElement("EditorInfo", { content });
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// src/components/EditorFontRow.tsx
|
|
339
|
+
import React27 from "react";
|
|
340
|
+
function EditorFontRow(props) {
|
|
341
|
+
return React27.createElement("EditorFontRow", props);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// src/components/EditorButton.tsx
|
|
345
|
+
import React28 from "react";
|
|
346
|
+
function EditorButton(props) {
|
|
347
|
+
return React28.createElement("EditorButton", props);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// src/components/EditorFontPicker.tsx
|
|
351
|
+
import React29 from "react";
|
|
352
|
+
function EditorFontPicker(props) {
|
|
353
|
+
return React29.createElement("EditorFontPicker", props);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// src/components/EditorChannelRow.tsx
|
|
357
|
+
import React30 from "react";
|
|
358
|
+
function EditorChannelRow(props) {
|
|
359
|
+
return React30.createElement("EditorChannelRow", props);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// src/hooks/useEditorAction.ts
|
|
363
|
+
import { useCallback } from "react";
|
|
247
364
|
|
|
248
365
|
// src/renderer/bridge-context.ts
|
|
249
366
|
var bridgeInstance = null;
|
|
@@ -254,10 +371,44 @@ function getBridge() {
|
|
|
254
371
|
return bridgeInstance;
|
|
255
372
|
}
|
|
256
373
|
|
|
374
|
+
// src/hooks/useEditorAction.ts
|
|
375
|
+
function useEditorAction() {
|
|
376
|
+
const dispatch = useCallback((action, payload) => {
|
|
377
|
+
const bridge = getBridge();
|
|
378
|
+
bridge.notify("ui.action", { action, ...payload });
|
|
379
|
+
}, []);
|
|
380
|
+
return { dispatch };
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// src/hooks/useIconPicker.ts
|
|
384
|
+
import { useState, useCallback as useCallback2 } from "react";
|
|
385
|
+
var DEFAULT_SOURCES = ["lucide", "emoji", "emote", "upload"];
|
|
386
|
+
function useIconPicker(options) {
|
|
387
|
+
const sources = options?.sources ?? DEFAULT_SOURCES;
|
|
388
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
389
|
+
const [selected, setSelected] = useState(null);
|
|
390
|
+
const open = useCallback2(() => setIsOpen(true), []);
|
|
391
|
+
const close = useCallback2(() => setIsOpen(false), []);
|
|
392
|
+
const select = useCallback2(
|
|
393
|
+
(icon) => {
|
|
394
|
+
setSelected(icon);
|
|
395
|
+
setIsOpen(false);
|
|
396
|
+
options?.onSelect?.(icon);
|
|
397
|
+
},
|
|
398
|
+
[options?.onSelect]
|
|
399
|
+
);
|
|
400
|
+
const clear = useCallback2(() => {
|
|
401
|
+
setSelected(null);
|
|
402
|
+
options?.onSelect?.(null);
|
|
403
|
+
}, [options?.onSelect]);
|
|
404
|
+
return { isOpen, selected, open, close, select, clear, sources };
|
|
405
|
+
}
|
|
406
|
+
|
|
257
407
|
// src/hooks/useExtensionStorage.ts
|
|
408
|
+
import { useState as useState2, useEffect, useCallback as useCallback3 } from "react";
|
|
258
409
|
import { HOST_METHODS, WORKER_METHODS } from "@zaflun/lumio-protocol";
|
|
259
410
|
function useExtensionStorage(key, initialValue) {
|
|
260
|
-
const [storage, setStorageState] =
|
|
411
|
+
const [storage, setStorageState] = useState2(initialValue);
|
|
261
412
|
useEffect(() => {
|
|
262
413
|
const bridge = getBridge();
|
|
263
414
|
const unsub = bridge.onNotification(
|
|
@@ -278,7 +429,7 @@ function useExtensionStorage(key, initialValue) {
|
|
|
278
429
|
});
|
|
279
430
|
return unsub;
|
|
280
431
|
}, [key]);
|
|
281
|
-
const setStorage =
|
|
432
|
+
const setStorage = useCallback3(
|
|
282
433
|
(value) => {
|
|
283
434
|
setStorageState(value);
|
|
284
435
|
const bridge = getBridge();
|
|
@@ -290,10 +441,10 @@ function useExtensionStorage(key, initialValue) {
|
|
|
290
441
|
}
|
|
291
442
|
|
|
292
443
|
// src/hooks/useVisionState.ts
|
|
293
|
-
import { useState as
|
|
444
|
+
import { useState as useState3, useEffect as useEffect2, useCallback as useCallback4 } from "react";
|
|
294
445
|
import { HOST_METHODS as HOST_METHODS2, WORKER_METHODS as WORKER_METHODS2 } from "@zaflun/lumio-protocol";
|
|
295
446
|
function useVisionState(key, defaultValue) {
|
|
296
|
-
const [value, setValueState] =
|
|
447
|
+
const [value, setValueState] = useState3(defaultValue);
|
|
297
448
|
useEffect2(() => {
|
|
298
449
|
const bridge = getBridge();
|
|
299
450
|
const unsub = bridge.onNotification(
|
|
@@ -314,7 +465,7 @@ function useVisionState(key, defaultValue) {
|
|
|
314
465
|
});
|
|
315
466
|
return unsub;
|
|
316
467
|
}, [key]);
|
|
317
|
-
const setValue =
|
|
468
|
+
const setValue = useCallback4(
|
|
318
469
|
(newValue) => {
|
|
319
470
|
setValueState(newValue);
|
|
320
471
|
const bridge = getBridge();
|
|
@@ -326,7 +477,7 @@ function useVisionState(key, defaultValue) {
|
|
|
326
477
|
}
|
|
327
478
|
|
|
328
479
|
// src/hooks/useExtensionContext.ts
|
|
329
|
-
import { useState as
|
|
480
|
+
import { useState as useState4, useEffect as useEffect3 } from "react";
|
|
330
481
|
import { HOST_METHODS as HOST_METHODS3 } from "@zaflun/lumio-protocol";
|
|
331
482
|
var defaultContext = {
|
|
332
483
|
extensionId: null,
|
|
@@ -335,7 +486,7 @@ var defaultContext = {
|
|
|
335
486
|
interactiveUrl: null
|
|
336
487
|
};
|
|
337
488
|
function useExtensionContext() {
|
|
338
|
-
const [context, setContext] =
|
|
489
|
+
const [context, setContext] = useState4(defaultContext);
|
|
339
490
|
useEffect3(() => {
|
|
340
491
|
const bridge = getBridge();
|
|
341
492
|
const unsub = bridge.onNotification(
|
|
@@ -356,10 +507,10 @@ function useExtensionContext() {
|
|
|
356
507
|
}
|
|
357
508
|
|
|
358
509
|
// src/hooks/useLumioEvent.ts
|
|
359
|
-
import { useState as
|
|
510
|
+
import { useState as useState5, useEffect as useEffect4 } from "react";
|
|
360
511
|
import { HOST_METHODS as HOST_METHODS4 } from "@zaflun/lumio-protocol";
|
|
361
512
|
function useLumioEvent(eventType) {
|
|
362
|
-
const [eventData, setEventData] =
|
|
513
|
+
const [eventData, setEventData] = useState5(null);
|
|
363
514
|
useEffect4(() => {
|
|
364
515
|
const bridge = getBridge();
|
|
365
516
|
const unsub = bridge.onNotification(
|
|
@@ -377,11 +528,24 @@ function useLumioEvent(eventType) {
|
|
|
377
528
|
}
|
|
378
529
|
|
|
379
530
|
// src/hooks/useLumioConfig.ts
|
|
380
|
-
import { useState as
|
|
381
|
-
import { HOST_METHODS as HOST_METHODS5 } from "@zaflun/lumio-protocol";
|
|
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";
|
|
533
|
+
function hasShim() {
|
|
534
|
+
return typeof window !== "undefined" && typeof window.__lumio_config === "function";
|
|
535
|
+
}
|
|
382
536
|
function useLumioConfig() {
|
|
383
|
-
const [config, setConfigState] =
|
|
537
|
+
const [config, setConfigState] = useState6(() => {
|
|
538
|
+
if (hasShim()) return window.__lumio_config();
|
|
539
|
+
return {};
|
|
540
|
+
});
|
|
384
541
|
useEffect5(() => {
|
|
542
|
+
if (hasShim()) {
|
|
543
|
+
const unsub2 = window.__lumio_on_config((newConfig) => {
|
|
544
|
+
setConfigState(newConfig);
|
|
545
|
+
});
|
|
546
|
+
setConfigState(window.__lumio_config());
|
|
547
|
+
return unsub2;
|
|
548
|
+
}
|
|
385
549
|
const bridge = getBridge();
|
|
386
550
|
const unsub = bridge.onNotification(
|
|
387
551
|
HOST_METHODS5.LIFECYCLE_INIT,
|
|
@@ -397,11 +561,30 @@ function useLumioConfig() {
|
|
|
397
561
|
});
|
|
398
562
|
}
|
|
399
563
|
);
|
|
400
|
-
|
|
564
|
+
const unsubConfig = bridge.onNotification(
|
|
565
|
+
HOST_METHODS5.CONFIG_UPDATE,
|
|
566
|
+
(params) => {
|
|
567
|
+
const p = params;
|
|
568
|
+
setConfigState(p);
|
|
569
|
+
}
|
|
570
|
+
);
|
|
571
|
+
return () => {
|
|
572
|
+
unsub();
|
|
573
|
+
unsubConfig();
|
|
574
|
+
};
|
|
401
575
|
}, []);
|
|
402
|
-
const setConfig =
|
|
403
|
-
(
|
|
404
|
-
setConfigState(
|
|
576
|
+
const setConfig = useCallback5(
|
|
577
|
+
(newConfigOrUpdater) => {
|
|
578
|
+
setConfigState((prev) => {
|
|
579
|
+
const next = typeof newConfigOrUpdater === "function" ? newConfigOrUpdater(prev) : newConfigOrUpdater;
|
|
580
|
+
if (hasShim()) {
|
|
581
|
+
window.__lumio_set_config(next);
|
|
582
|
+
} else {
|
|
583
|
+
const bridge = getBridge();
|
|
584
|
+
bridge.notify(WORKER_METHODS3.CONFIG_UPDATE, next);
|
|
585
|
+
}
|
|
586
|
+
return next;
|
|
587
|
+
});
|
|
405
588
|
},
|
|
406
589
|
[]
|
|
407
590
|
);
|
|
@@ -409,7 +592,7 @@ function useLumioConfig() {
|
|
|
409
592
|
}
|
|
410
593
|
|
|
411
594
|
// src/hooks/useLumioTheme.ts
|
|
412
|
-
import { useState as
|
|
595
|
+
import { useState as useState7, useEffect as useEffect6 } from "react";
|
|
413
596
|
import { HOST_METHODS as HOST_METHODS6 } from "@zaflun/lumio-protocol";
|
|
414
597
|
var DEFAULT_THEME = {
|
|
415
598
|
colors: {
|
|
@@ -434,7 +617,7 @@ var DEFAULT_THEME = {
|
|
|
434
617
|
spacing: 8
|
|
435
618
|
};
|
|
436
619
|
function useLumioTheme() {
|
|
437
|
-
const [theme, setTheme] =
|
|
620
|
+
const [theme, setTheme] = useState7(DEFAULT_THEME);
|
|
438
621
|
useEffect6(() => {
|
|
439
622
|
const bridge = getBridge();
|
|
440
623
|
const unsubInit = bridge.onNotification(
|
|
@@ -464,7 +647,7 @@ function useLumioTheme() {
|
|
|
464
647
|
}
|
|
465
648
|
|
|
466
649
|
// src/hooks/useLumioIdentity.ts
|
|
467
|
-
import { useState as
|
|
650
|
+
import { useState as useState8, useEffect as useEffect7 } from "react";
|
|
468
651
|
import { HOST_METHODS as HOST_METHODS7 } from "@zaflun/lumio-protocol";
|
|
469
652
|
var defaultIdentity = {
|
|
470
653
|
userId: null,
|
|
@@ -472,7 +655,7 @@ var defaultIdentity = {
|
|
|
472
655
|
role: null
|
|
473
656
|
};
|
|
474
657
|
function useLumioIdentity() {
|
|
475
|
-
const [identity, setIdentity] =
|
|
658
|
+
const [identity, setIdentity] = useState8(defaultIdentity);
|
|
476
659
|
useEffect7(() => {
|
|
477
660
|
const bridge = getBridge();
|
|
478
661
|
const unsub = bridge.onNotification(
|
|
@@ -492,14 +675,14 @@ function useLumioIdentity() {
|
|
|
492
675
|
}
|
|
493
676
|
|
|
494
677
|
// src/hooks/useLumioAction.ts
|
|
495
|
-
import { useState as
|
|
678
|
+
import { useState as useState9, useCallback as useCallback6, useRef } from "react";
|
|
496
679
|
function useLumioAction(action) {
|
|
497
|
-
const [data, setData] =
|
|
498
|
-
const [isLoading, setIsLoading] =
|
|
499
|
-
const [error, setError] =
|
|
680
|
+
const [data, setData] = useState9(null);
|
|
681
|
+
const [isLoading, setIsLoading] = useState9(false);
|
|
682
|
+
const [error, setError] = useState9(null);
|
|
500
683
|
const actionRef = useRef(action);
|
|
501
684
|
actionRef.current = action;
|
|
502
|
-
const execute =
|
|
685
|
+
const execute = useCallback6(
|
|
503
686
|
(params = {}) => {
|
|
504
687
|
setIsLoading(true);
|
|
505
688
|
setError(null);
|
|
@@ -519,20 +702,40 @@ function useLumioAction(action) {
|
|
|
519
702
|
return { execute, data, isLoading, error };
|
|
520
703
|
}
|
|
521
704
|
|
|
705
|
+
// src/hooks/useLumioSound.ts
|
|
706
|
+
import { useCallback as useCallback7 } from "react";
|
|
707
|
+
import { WORKER_METHODS as WORKER_METHODS4 } from "@zaflun/lumio-protocol";
|
|
708
|
+
function useLumioSound() {
|
|
709
|
+
const playSound = useCallback7(async (soundId, volume) => {
|
|
710
|
+
const bridge = getBridge();
|
|
711
|
+
await bridge.request(WORKER_METHODS4.SOUND_PLAY, { sound_id: soundId, volume });
|
|
712
|
+
}, []);
|
|
713
|
+
const stopSound = useCallback7(async (soundId) => {
|
|
714
|
+
const bridge = getBridge();
|
|
715
|
+
await bridge.request(WORKER_METHODS4.SOUND_STOP, { sound_id: soundId });
|
|
716
|
+
}, []);
|
|
717
|
+
const getSounds = useCallback7(async () => {
|
|
718
|
+
const bridge = getBridge();
|
|
719
|
+
const result = await bridge.request(WORKER_METHODS4.SOUND_LIST, {});
|
|
720
|
+
return result ?? [];
|
|
721
|
+
}, []);
|
|
722
|
+
return { playSound, stopSound, getSounds };
|
|
723
|
+
}
|
|
724
|
+
|
|
522
725
|
// src/hooks/useQuery.ts
|
|
523
|
-
import { useState as
|
|
524
|
-
import { WORKER_METHODS as
|
|
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";
|
|
525
728
|
function useQuery(functionName, params) {
|
|
526
|
-
const [data, setData] =
|
|
527
|
-
const [isLoading, setIsLoading] =
|
|
528
|
-
const [error, setError] =
|
|
729
|
+
const [data, setData] = useState10(null);
|
|
730
|
+
const [isLoading, setIsLoading] = useState10(false);
|
|
731
|
+
const [error, setError] = useState10(null);
|
|
529
732
|
const fnRef = useRef2(functionName);
|
|
530
733
|
fnRef.current = functionName;
|
|
531
|
-
const sendQuery =
|
|
734
|
+
const sendQuery = useCallback8(() => {
|
|
532
735
|
setIsLoading(true);
|
|
533
736
|
setError(null);
|
|
534
737
|
const bridge = getBridge();
|
|
535
|
-
bridge.request(
|
|
738
|
+
bridge.request(WORKER_METHODS5.SERVER_QUERY, { fn: functionName, params: params ?? {} }).then((result) => {
|
|
536
739
|
setIsLoading(false);
|
|
537
740
|
setData(result ?? null);
|
|
538
741
|
setError(null);
|
|
@@ -549,18 +752,18 @@ function useQuery(functionName, params) {
|
|
|
549
752
|
}
|
|
550
753
|
|
|
551
754
|
// src/hooks/useMutation.ts
|
|
552
|
-
import { useState as
|
|
553
|
-
import { WORKER_METHODS as
|
|
755
|
+
import { useState as useState11, useCallback as useCallback9 } from "react";
|
|
756
|
+
import { WORKER_METHODS as WORKER_METHODS6 } from "@zaflun/lumio-protocol";
|
|
554
757
|
function useMutation(functionName) {
|
|
555
|
-
const [data, setData] =
|
|
556
|
-
const [isLoading, setIsLoading] =
|
|
557
|
-
const [error, setError] =
|
|
558
|
-
const sendMutation =
|
|
758
|
+
const [data, setData] = useState11(null);
|
|
759
|
+
const [isLoading, setIsLoading] = useState11(false);
|
|
760
|
+
const [error, setError] = useState11(null);
|
|
761
|
+
const sendMutation = useCallback9(
|
|
559
762
|
(params = {}) => {
|
|
560
763
|
setIsLoading(true);
|
|
561
764
|
setError(null);
|
|
562
765
|
const bridge = getBridge();
|
|
563
|
-
return bridge.request(
|
|
766
|
+
return bridge.request(WORKER_METHODS6.SERVER_MUTATION, { fn: functionName, params }).then((result) => {
|
|
564
767
|
setIsLoading(false);
|
|
565
768
|
setData(result ?? null);
|
|
566
769
|
setError(null);
|
|
@@ -575,11 +778,11 @@ function useMutation(functionName) {
|
|
|
575
778
|
},
|
|
576
779
|
[functionName]
|
|
577
780
|
);
|
|
578
|
-
const mutateAsync =
|
|
781
|
+
const mutateAsync = useCallback9(
|
|
579
782
|
(params) => sendMutation(params),
|
|
580
783
|
[sendMutation]
|
|
581
784
|
);
|
|
582
|
-
const mutate =
|
|
785
|
+
const mutate = useCallback9(
|
|
583
786
|
(params) => {
|
|
584
787
|
sendMutation(params).catch(() => {
|
|
585
788
|
});
|
|
@@ -675,7 +878,7 @@ function getPreset(name) {
|
|
|
675
878
|
}
|
|
676
879
|
|
|
677
880
|
// src/animation/Animated.tsx
|
|
678
|
-
import
|
|
881
|
+
import React31, { useEffect as useEffect9, useRef as useRef3, useState as useState12 } from "react";
|
|
679
882
|
function resolveAnimation(name) {
|
|
680
883
|
if (name === void 0) return void 0;
|
|
681
884
|
try {
|
|
@@ -696,7 +899,7 @@ function Animated({
|
|
|
696
899
|
visible = true,
|
|
697
900
|
onAnimationEnd
|
|
698
901
|
}) {
|
|
699
|
-
const [phase, setPhase] =
|
|
902
|
+
const [phase, setPhase] = useState12(() => visible ? "in" : "idle");
|
|
700
903
|
const prevVisibleRef = useRef3(visible);
|
|
701
904
|
const timerRef = useRef3(null);
|
|
702
905
|
function clearTimer() {
|
|
@@ -770,11 +973,11 @@ function Animated({
|
|
|
770
973
|
animationStyles.animationIterationCount = 1;
|
|
771
974
|
}
|
|
772
975
|
}
|
|
773
|
-
return
|
|
976
|
+
return React31.createElement("Box", { style: animationStyles }, children);
|
|
774
977
|
}
|
|
775
978
|
|
|
776
979
|
// src/animation/useAnimation.ts
|
|
777
|
-
import { useState as
|
|
980
|
+
import { useState as useState13, useCallback as useCallback10 } from "react";
|
|
778
981
|
function resolvePreset(name) {
|
|
779
982
|
try {
|
|
780
983
|
return getPreset(name);
|
|
@@ -783,10 +986,10 @@ function resolvePreset(name) {
|
|
|
783
986
|
}
|
|
784
987
|
}
|
|
785
988
|
function useAnimation() {
|
|
786
|
-
const [isAnimating, setIsAnimating] =
|
|
787
|
-
const [currentAnimation, setCurrentAnimation] =
|
|
788
|
-
const [style, setStyle] =
|
|
789
|
-
const trigger =
|
|
989
|
+
const [isAnimating, setIsAnimating] = useState13(false);
|
|
990
|
+
const [currentAnimation, setCurrentAnimation] = useState13(null);
|
|
991
|
+
const [style, setStyle] = useState13({});
|
|
992
|
+
const trigger = useCallback10((preset, duration = 300) => {
|
|
790
993
|
const animationName = resolvePreset(preset);
|
|
791
994
|
setIsAnimating(true);
|
|
792
995
|
setCurrentAnimation(preset);
|
|
@@ -797,7 +1000,7 @@ function useAnimation() {
|
|
|
797
1000
|
});
|
|
798
1001
|
return animationName;
|
|
799
1002
|
}, []);
|
|
800
|
-
const reset =
|
|
1003
|
+
const reset = useCallback10(() => {
|
|
801
1004
|
setIsAnimating(false);
|
|
802
1005
|
setCurrentAnimation(null);
|
|
803
1006
|
setStyle({});
|
|
@@ -813,12 +1016,21 @@ function formatFromPath(path) {
|
|
|
813
1016
|
if (lower.endsWith(".woff")) return "woff";
|
|
814
1017
|
return "truetype";
|
|
815
1018
|
}
|
|
1019
|
+
var FAMILY_RE = /^[\w -]+$/;
|
|
1020
|
+
function escapeCssUrl(src) {
|
|
1021
|
+
return src.replace(/[\\"\n\r\f]/g, (c) => `\\${c}`);
|
|
1022
|
+
}
|
|
816
1023
|
function buildFontFace(family, src, display, weight, style) {
|
|
1024
|
+
if (!FAMILY_RE.test(family)) {
|
|
1025
|
+
throw new Error(
|
|
1026
|
+
`Invalid font family "${family}": only letters, digits, spaces, "-" and "_" are allowed.`
|
|
1027
|
+
);
|
|
1028
|
+
}
|
|
817
1029
|
const format = formatFromPath(src);
|
|
818
1030
|
const lines = [
|
|
819
1031
|
"@font-face {",
|
|
820
1032
|
` font-family: "${family}";`,
|
|
821
|
-
` src: url("${src}") format("${format}");`,
|
|
1033
|
+
` src: url("${escapeCssUrl(src)}") format("${format}");`,
|
|
822
1034
|
` font-display: ${display};`
|
|
823
1035
|
];
|
|
824
1036
|
if (weight !== void 0) {
|
|
@@ -866,7 +1078,23 @@ export {
|
|
|
866
1078
|
Button,
|
|
867
1079
|
CompactView,
|
|
868
1080
|
Dropdown,
|
|
1081
|
+
EditorButton,
|
|
1082
|
+
EditorChannelRow,
|
|
1083
|
+
EditorCheckbox,
|
|
1084
|
+
EditorColorPicker,
|
|
1085
|
+
EditorDivider,
|
|
1086
|
+
EditorFontPicker,
|
|
1087
|
+
EditorFontRow,
|
|
1088
|
+
EditorGroup,
|
|
1089
|
+
EditorInfo,
|
|
1090
|
+
EditorInput,
|
|
1091
|
+
EditorLabel,
|
|
1092
|
+
EditorSelect,
|
|
1093
|
+
EditorSlider,
|
|
1094
|
+
EditorTextarea,
|
|
869
1095
|
HStack,
|
|
1096
|
+
IconDisplay,
|
|
1097
|
+
IconPicker,
|
|
870
1098
|
Image,
|
|
871
1099
|
List,
|
|
872
1100
|
Lumio,
|
|
@@ -883,12 +1111,15 @@ export {
|
|
|
883
1111
|
getPreset,
|
|
884
1112
|
localFont,
|
|
885
1113
|
useAnimation,
|
|
1114
|
+
useEditorAction,
|
|
886
1115
|
useExtensionContext,
|
|
887
1116
|
useExtensionStorage,
|
|
1117
|
+
useIconPicker,
|
|
888
1118
|
useLumioAction,
|
|
889
1119
|
useLumioConfig,
|
|
890
1120
|
useLumioEvent,
|
|
891
1121
|
useLumioIdentity,
|
|
1122
|
+
useLumioSound,
|
|
892
1123
|
useLumioTheme,
|
|
893
1124
|
useMutation,
|
|
894
1125
|
useQuery,
|