@zaflun/lumio-sdk 0.1.0 → 0.3.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.ts +1 -1
- package/dist/index.js +49 -29
- package/dist/lumio-runtime.global.js +787 -1470
- package/dist/server.d.ts +86 -1
- package/dist/server.js +43 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -193,7 +193,7 @@ interface OverlayTheme {
|
|
|
193
193
|
*
|
|
194
194
|
* Extensions use this to style themselves consistently with the
|
|
195
195
|
* overlay or widget they're rendered in. Only relevant for `layer`
|
|
196
|
-
* and `interactive` targets (
|
|
196
|
+
* and `interactive` targets (stream overlay, widget pages).
|
|
197
197
|
*
|
|
198
198
|
* Theme is provided via lifecycle.init and updated via theme.change when
|
|
199
199
|
* the user switches the overlay/widget theme.
|
package/dist/index.js
CHANGED
|
@@ -290,10 +290,30 @@ function useExtensionStorage(key, initialValue) {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
// src/hooks/useVisionState.ts
|
|
293
|
-
import { useState as useState2, useCallback as useCallback2 } from "react";
|
|
294
|
-
import { WORKER_METHODS as WORKER_METHODS2 } from "@zaflun/lumio-protocol";
|
|
293
|
+
import { useState as useState2, useEffect as useEffect2, useCallback as useCallback2 } from "react";
|
|
294
|
+
import { HOST_METHODS as HOST_METHODS2, WORKER_METHODS as WORKER_METHODS2 } from "@zaflun/lumio-protocol";
|
|
295
295
|
function useVisionState(key, defaultValue) {
|
|
296
296
|
const [value, setValueState] = useState2(defaultValue);
|
|
297
|
+
useEffect2(() => {
|
|
298
|
+
const bridge = getBridge();
|
|
299
|
+
const unsub = bridge.onNotification(
|
|
300
|
+
HOST_METHODS2.STORAGE_UPDATE,
|
|
301
|
+
(params) => {
|
|
302
|
+
const p = params;
|
|
303
|
+
if (p.key === key) {
|
|
304
|
+
setValueState(p.value);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
bridge.request(WORKER_METHODS2.STORAGE_GET, { key }).then((result) => {
|
|
309
|
+
const r = result;
|
|
310
|
+
if (r && r.value !== void 0) {
|
|
311
|
+
setValueState(r.value);
|
|
312
|
+
}
|
|
313
|
+
}).catch(() => {
|
|
314
|
+
});
|
|
315
|
+
return unsub;
|
|
316
|
+
}, [key]);
|
|
297
317
|
const setValue = useCallback2(
|
|
298
318
|
(newValue) => {
|
|
299
319
|
setValueState(newValue);
|
|
@@ -306,8 +326,8 @@ function useVisionState(key, defaultValue) {
|
|
|
306
326
|
}
|
|
307
327
|
|
|
308
328
|
// src/hooks/useExtensionContext.ts
|
|
309
|
-
import { useState as useState3, useEffect as
|
|
310
|
-
import { HOST_METHODS as
|
|
329
|
+
import { useState as useState3, useEffect as useEffect3 } from "react";
|
|
330
|
+
import { HOST_METHODS as HOST_METHODS3 } from "@zaflun/lumio-protocol";
|
|
311
331
|
var defaultContext = {
|
|
312
332
|
extensionId: null,
|
|
313
333
|
target: null,
|
|
@@ -316,10 +336,10 @@ var defaultContext = {
|
|
|
316
336
|
};
|
|
317
337
|
function useExtensionContext() {
|
|
318
338
|
const [context, setContext] = useState3(defaultContext);
|
|
319
|
-
|
|
339
|
+
useEffect3(() => {
|
|
320
340
|
const bridge = getBridge();
|
|
321
341
|
const unsub = bridge.onNotification(
|
|
322
|
-
|
|
342
|
+
HOST_METHODS3.LIFECYCLE_INIT,
|
|
323
343
|
(params) => {
|
|
324
344
|
const p = params;
|
|
325
345
|
setContext({
|
|
@@ -336,14 +356,14 @@ function useExtensionContext() {
|
|
|
336
356
|
}
|
|
337
357
|
|
|
338
358
|
// src/hooks/useLumioEvent.ts
|
|
339
|
-
import { useState as useState4, useEffect as
|
|
340
|
-
import { HOST_METHODS as
|
|
359
|
+
import { useState as useState4, useEffect as useEffect4 } from "react";
|
|
360
|
+
import { HOST_METHODS as HOST_METHODS4 } from "@zaflun/lumio-protocol";
|
|
341
361
|
function useLumioEvent(eventType) {
|
|
342
362
|
const [eventData, setEventData] = useState4(null);
|
|
343
|
-
|
|
363
|
+
useEffect4(() => {
|
|
344
364
|
const bridge = getBridge();
|
|
345
365
|
const unsub = bridge.onNotification(
|
|
346
|
-
|
|
366
|
+
HOST_METHODS4.EVENT_PLATFORM,
|
|
347
367
|
(params) => {
|
|
348
368
|
const p = params;
|
|
349
369
|
if (p.eventType === eventType) {
|
|
@@ -357,14 +377,14 @@ function useLumioEvent(eventType) {
|
|
|
357
377
|
}
|
|
358
378
|
|
|
359
379
|
// src/hooks/useLumioConfig.ts
|
|
360
|
-
import { useState as useState5, useEffect as
|
|
361
|
-
import { HOST_METHODS as
|
|
380
|
+
import { useState as useState5, useEffect as useEffect5, useCallback as useCallback3 } from "react";
|
|
381
|
+
import { HOST_METHODS as HOST_METHODS5 } from "@zaflun/lumio-protocol";
|
|
362
382
|
function useLumioConfig() {
|
|
363
383
|
const [config, setConfigState] = useState5({});
|
|
364
|
-
|
|
384
|
+
useEffect5(() => {
|
|
365
385
|
const bridge = getBridge();
|
|
366
386
|
const unsub = bridge.onNotification(
|
|
367
|
-
|
|
387
|
+
HOST_METHODS5.LIFECYCLE_INIT,
|
|
368
388
|
(params) => {
|
|
369
389
|
const p = params;
|
|
370
390
|
setConfigState({
|
|
@@ -389,8 +409,8 @@ function useLumioConfig() {
|
|
|
389
409
|
}
|
|
390
410
|
|
|
391
411
|
// src/hooks/useLumioTheme.ts
|
|
392
|
-
import { useState as useState6, useEffect as
|
|
393
|
-
import { HOST_METHODS as
|
|
412
|
+
import { useState as useState6, useEffect as useEffect6 } from "react";
|
|
413
|
+
import { HOST_METHODS as HOST_METHODS6 } from "@zaflun/lumio-protocol";
|
|
394
414
|
var DEFAULT_THEME = {
|
|
395
415
|
colors: {
|
|
396
416
|
primary: "#6366f1",
|
|
@@ -415,10 +435,10 @@ var DEFAULT_THEME = {
|
|
|
415
435
|
};
|
|
416
436
|
function useLumioTheme() {
|
|
417
437
|
const [theme, setTheme] = useState6(DEFAULT_THEME);
|
|
418
|
-
|
|
438
|
+
useEffect6(() => {
|
|
419
439
|
const bridge = getBridge();
|
|
420
440
|
const unsubInit = bridge.onNotification(
|
|
421
|
-
|
|
441
|
+
HOST_METHODS6.LIFECYCLE_INIT,
|
|
422
442
|
(params) => {
|
|
423
443
|
const p = params;
|
|
424
444
|
if (p.theme) {
|
|
@@ -427,7 +447,7 @@ function useLumioTheme() {
|
|
|
427
447
|
}
|
|
428
448
|
);
|
|
429
449
|
const unsubTheme = bridge.onNotification(
|
|
430
|
-
|
|
450
|
+
HOST_METHODS6.THEME_CHANGE,
|
|
431
451
|
(params) => {
|
|
432
452
|
const p = params;
|
|
433
453
|
if (p.theme) {
|
|
@@ -444,8 +464,8 @@ function useLumioTheme() {
|
|
|
444
464
|
}
|
|
445
465
|
|
|
446
466
|
// src/hooks/useLumioIdentity.ts
|
|
447
|
-
import { useState as useState7, useEffect as
|
|
448
|
-
import { HOST_METHODS as
|
|
467
|
+
import { useState as useState7, useEffect as useEffect7 } from "react";
|
|
468
|
+
import { HOST_METHODS as HOST_METHODS7 } from "@zaflun/lumio-protocol";
|
|
449
469
|
var defaultIdentity = {
|
|
450
470
|
userId: null,
|
|
451
471
|
accountId: null,
|
|
@@ -453,10 +473,10 @@ var defaultIdentity = {
|
|
|
453
473
|
};
|
|
454
474
|
function useLumioIdentity() {
|
|
455
475
|
const [identity, setIdentity] = useState7(defaultIdentity);
|
|
456
|
-
|
|
476
|
+
useEffect7(() => {
|
|
457
477
|
const bridge = getBridge();
|
|
458
478
|
const unsub = bridge.onNotification(
|
|
459
|
-
|
|
479
|
+
HOST_METHODS7.LIFECYCLE_INIT,
|
|
460
480
|
(params) => {
|
|
461
481
|
const p = params;
|
|
462
482
|
setIdentity({
|
|
@@ -500,7 +520,7 @@ function useLumioAction(action) {
|
|
|
500
520
|
}
|
|
501
521
|
|
|
502
522
|
// src/hooks/useQuery.ts
|
|
503
|
-
import { useState as useState9, useEffect as
|
|
523
|
+
import { useState as useState9, useEffect as useEffect8, useCallback as useCallback5, useRef as useRef2 } from "react";
|
|
504
524
|
import { WORKER_METHODS as WORKER_METHODS3 } from "@zaflun/lumio-protocol";
|
|
505
525
|
function useQuery(functionName, params) {
|
|
506
526
|
const [data, setData] = useState9(null);
|
|
@@ -522,9 +542,9 @@ function useQuery(functionName, params) {
|
|
|
522
542
|
setData(null);
|
|
523
543
|
});
|
|
524
544
|
}, [functionName, params]);
|
|
525
|
-
|
|
545
|
+
useEffect8(() => {
|
|
526
546
|
sendQuery();
|
|
527
|
-
}, [
|
|
547
|
+
}, [sendQuery]);
|
|
528
548
|
return { data, isLoading, error, refetch: sendQuery };
|
|
529
549
|
}
|
|
530
550
|
|
|
@@ -655,7 +675,7 @@ function getPreset(name) {
|
|
|
655
675
|
}
|
|
656
676
|
|
|
657
677
|
// src/animation/Animated.tsx
|
|
658
|
-
import React15, { useEffect as
|
|
678
|
+
import React15, { useEffect as useEffect9, useRef as useRef3, useState as useState11 } from "react";
|
|
659
679
|
function resolveAnimation(name) {
|
|
660
680
|
if (name === void 0) return void 0;
|
|
661
681
|
try {
|
|
@@ -685,7 +705,7 @@ function Animated({
|
|
|
685
705
|
timerRef.current = null;
|
|
686
706
|
}
|
|
687
707
|
}
|
|
688
|
-
|
|
708
|
+
useEffect9(() => {
|
|
689
709
|
const prevVisible = prevVisibleRef.current;
|
|
690
710
|
prevVisibleRef.current = visible;
|
|
691
711
|
if (visible && !prevVisible) {
|
|
@@ -696,7 +716,7 @@ function Animated({
|
|
|
696
716
|
setPhase("out");
|
|
697
717
|
}
|
|
698
718
|
}, [visible]);
|
|
699
|
-
|
|
719
|
+
useEffect9(() => {
|
|
700
720
|
if (phase === "in") {
|
|
701
721
|
const totalDuration = duration + delay;
|
|
702
722
|
if (loopProp !== void 0) {
|