@glasshome/widget-sdk 1.31.1 → 1.32.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/export-history.json +298 -0
- package/dist/index.js +1 -1
- package/dist/media/camera-stream.d.ts +12 -2
- package/dist/media/camera-stream.js +138 -75
- package/dist/media/drivers/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/export-history.json
CHANGED
|
@@ -6443,5 +6443,303 @@
|
|
|
6443
6443
|
"useWidgetViewer",
|
|
6444
6444
|
"widgetFields",
|
|
6445
6445
|
"z"
|
|
6446
|
+
],
|
|
6447
|
+
"1.32.0": [
|
|
6448
|
+
"Badge",
|
|
6449
|
+
"Button",
|
|
6450
|
+
"ButtonGroup",
|
|
6451
|
+
"CameraSourceContext",
|
|
6452
|
+
"CameraStream",
|
|
6453
|
+
"Carousel",
|
|
6454
|
+
"CarouselContent",
|
|
6455
|
+
"CarouselDots",
|
|
6456
|
+
"CarouselItem",
|
|
6457
|
+
"CarouselNext",
|
|
6458
|
+
"CarouselPrevious",
|
|
6459
|
+
"ColorDisc",
|
|
6460
|
+
"ColorSlider",
|
|
6461
|
+
"ColorWheel",
|
|
6462
|
+
"CountPill",
|
|
6463
|
+
"Icon",
|
|
6464
|
+
"Input",
|
|
6465
|
+
"Label",
|
|
6466
|
+
"PanelEntityRow",
|
|
6467
|
+
"PanelFacts",
|
|
6468
|
+
"PanelRow",
|
|
6469
|
+
"PanelRows",
|
|
6470
|
+
"PanelSection",
|
|
6471
|
+
"Progress",
|
|
6472
|
+
"ResponsiveDialog",
|
|
6473
|
+
"ResponsiveDialogBody",
|
|
6474
|
+
"ResponsiveDialogClose",
|
|
6475
|
+
"ResponsiveDialogContent",
|
|
6476
|
+
"ResponsiveDialogDescription",
|
|
6477
|
+
"ResponsiveDialogFooter",
|
|
6478
|
+
"ResponsiveDialogHeader",
|
|
6479
|
+
"ResponsiveDialogTitle",
|
|
6480
|
+
"SDK_VERSION",
|
|
6481
|
+
"SchemaForm",
|
|
6482
|
+
"SectionIcon",
|
|
6483
|
+
"SectionTitle",
|
|
6484
|
+
"Select",
|
|
6485
|
+
"SelectContent",
|
|
6486
|
+
"SelectItem",
|
|
6487
|
+
"SelectTrigger",
|
|
6488
|
+
"SelectValue",
|
|
6489
|
+
"Slider",
|
|
6490
|
+
"SwatchPicker",
|
|
6491
|
+
"Switch",
|
|
6492
|
+
"Tabs",
|
|
6493
|
+
"TabsContent",
|
|
6494
|
+
"TabsList",
|
|
6495
|
+
"TabsTrigger",
|
|
6496
|
+
"TemperatureBar",
|
|
6497
|
+
"Toggle",
|
|
6498
|
+
"ToggleGroup",
|
|
6499
|
+
"ToggleGroupItem",
|
|
6500
|
+
"ToneSchema",
|
|
6501
|
+
"Widget",
|
|
6502
|
+
"WidgetAction",
|
|
6503
|
+
"WidgetBackdrop",
|
|
6504
|
+
"WidgetChip",
|
|
6505
|
+
"WidgetChoice",
|
|
6506
|
+
"WidgetContent",
|
|
6507
|
+
"WidgetControls",
|
|
6508
|
+
"WidgetCtx",
|
|
6509
|
+
"WidgetDebugTab",
|
|
6510
|
+
"WidgetDebugView",
|
|
6511
|
+
"WidgetDialog",
|
|
6512
|
+
"WidgetGlyph",
|
|
6513
|
+
"WidgetHead",
|
|
6514
|
+
"WidgetHero",
|
|
6515
|
+
"WidgetIcon",
|
|
6516
|
+
"WidgetLayer",
|
|
6517
|
+
"WidgetManifestSchema",
|
|
6518
|
+
"WidgetSizeCtx",
|
|
6519
|
+
"WidgetSliderFill",
|
|
6520
|
+
"WidgetStatus",
|
|
6521
|
+
"WidgetStepper",
|
|
6522
|
+
"WidgetTitle",
|
|
6523
|
+
"WidgetValue",
|
|
6524
|
+
"buildDebugData",
|
|
6525
|
+
"byDomain",
|
|
6526
|
+
"calculateLightGroup",
|
|
6527
|
+
"calculateSensorGroup",
|
|
6528
|
+
"copyText",
|
|
6529
|
+
"countActiveEntities",
|
|
6530
|
+
"defineConfig",
|
|
6531
|
+
"defineWidget",
|
|
6532
|
+
"deprecations",
|
|
6533
|
+
"field",
|
|
6534
|
+
"formatDeprecation",
|
|
6535
|
+
"formatSchemaError",
|
|
6536
|
+
"getEntityAttribute",
|
|
6537
|
+
"getForecasts",
|
|
6538
|
+
"getStream",
|
|
6539
|
+
"getWebRtcClientConfig",
|
|
6540
|
+
"hassMediaUrl",
|
|
6541
|
+
"imagePreset",
|
|
6542
|
+
"imageSrc",
|
|
6543
|
+
"imageUrl",
|
|
6544
|
+
"injectTokens",
|
|
6545
|
+
"isDark",
|
|
6546
|
+
"isEntityActive",
|
|
6547
|
+
"isPanelControllable",
|
|
6548
|
+
"mediaUrl",
|
|
6549
|
+
"monotoneCubicPath",
|
|
6550
|
+
"parseColor",
|
|
6551
|
+
"presetValue",
|
|
6552
|
+
"provideCameraSource",
|
|
6553
|
+
"sendWebRtcCandidate",
|
|
6554
|
+
"startWebRtcSession",
|
|
6555
|
+
"state",
|
|
6556
|
+
"svgColors",
|
|
6557
|
+
"trackEntityHistory",
|
|
6558
|
+
"untrackEntityHistory",
|
|
6559
|
+
"useArea",
|
|
6560
|
+
"useCalendarEvents",
|
|
6561
|
+
"useCamera",
|
|
6562
|
+
"useCameraSource",
|
|
6563
|
+
"useConfirm",
|
|
6564
|
+
"useConnection",
|
|
6565
|
+
"useCopyText",
|
|
6566
|
+
"useCurrency",
|
|
6567
|
+
"useDaylight",
|
|
6568
|
+
"useEntities",
|
|
6569
|
+
"useEntity",
|
|
6570
|
+
"useEntityHistory",
|
|
6571
|
+
"useEntityStatistics",
|
|
6572
|
+
"useForecast",
|
|
6573
|
+
"useHassConfig",
|
|
6574
|
+
"useIntersectionPause",
|
|
6575
|
+
"useLocale",
|
|
6576
|
+
"useMaterial",
|
|
6577
|
+
"useReducedMotion",
|
|
6578
|
+
"useService",
|
|
6579
|
+
"useStore",
|
|
6580
|
+
"useTemperatureUnit",
|
|
6581
|
+
"useToggle",
|
|
6582
|
+
"useTurnOff",
|
|
6583
|
+
"useTurnOn",
|
|
6584
|
+
"useUnitSystem",
|
|
6585
|
+
"useWidgetContext",
|
|
6586
|
+
"useWidgetDashboard",
|
|
6587
|
+
"useWidgetDialog",
|
|
6588
|
+
"useWidgetDimensions",
|
|
6589
|
+
"useWidgetEntityGroup",
|
|
6590
|
+
"useWidgetGestures",
|
|
6591
|
+
"useWidgetState",
|
|
6592
|
+
"useWidgetViewer",
|
|
6593
|
+
"widgetFields",
|
|
6594
|
+
"z"
|
|
6595
|
+
],
|
|
6596
|
+
"1.32.1": [
|
|
6597
|
+
"Badge",
|
|
6598
|
+
"Button",
|
|
6599
|
+
"ButtonGroup",
|
|
6600
|
+
"CameraSourceContext",
|
|
6601
|
+
"CameraStream",
|
|
6602
|
+
"Carousel",
|
|
6603
|
+
"CarouselContent",
|
|
6604
|
+
"CarouselDots",
|
|
6605
|
+
"CarouselItem",
|
|
6606
|
+
"CarouselNext",
|
|
6607
|
+
"CarouselPrevious",
|
|
6608
|
+
"ColorDisc",
|
|
6609
|
+
"ColorSlider",
|
|
6610
|
+
"ColorWheel",
|
|
6611
|
+
"CountPill",
|
|
6612
|
+
"Icon",
|
|
6613
|
+
"Input",
|
|
6614
|
+
"Label",
|
|
6615
|
+
"PanelEntityRow",
|
|
6616
|
+
"PanelFacts",
|
|
6617
|
+
"PanelRow",
|
|
6618
|
+
"PanelRows",
|
|
6619
|
+
"PanelSection",
|
|
6620
|
+
"Progress",
|
|
6621
|
+
"ResponsiveDialog",
|
|
6622
|
+
"ResponsiveDialogBody",
|
|
6623
|
+
"ResponsiveDialogClose",
|
|
6624
|
+
"ResponsiveDialogContent",
|
|
6625
|
+
"ResponsiveDialogDescription",
|
|
6626
|
+
"ResponsiveDialogFooter",
|
|
6627
|
+
"ResponsiveDialogHeader",
|
|
6628
|
+
"ResponsiveDialogTitle",
|
|
6629
|
+
"SDK_VERSION",
|
|
6630
|
+
"SchemaForm",
|
|
6631
|
+
"SectionIcon",
|
|
6632
|
+
"SectionTitle",
|
|
6633
|
+
"Select",
|
|
6634
|
+
"SelectContent",
|
|
6635
|
+
"SelectItem",
|
|
6636
|
+
"SelectTrigger",
|
|
6637
|
+
"SelectValue",
|
|
6638
|
+
"Slider",
|
|
6639
|
+
"SwatchPicker",
|
|
6640
|
+
"Switch",
|
|
6641
|
+
"Tabs",
|
|
6642
|
+
"TabsContent",
|
|
6643
|
+
"TabsList",
|
|
6644
|
+
"TabsTrigger",
|
|
6645
|
+
"TemperatureBar",
|
|
6646
|
+
"Toggle",
|
|
6647
|
+
"ToggleGroup",
|
|
6648
|
+
"ToggleGroupItem",
|
|
6649
|
+
"ToneSchema",
|
|
6650
|
+
"Widget",
|
|
6651
|
+
"WidgetAction",
|
|
6652
|
+
"WidgetBackdrop",
|
|
6653
|
+
"WidgetChip",
|
|
6654
|
+
"WidgetChoice",
|
|
6655
|
+
"WidgetContent",
|
|
6656
|
+
"WidgetControls",
|
|
6657
|
+
"WidgetCtx",
|
|
6658
|
+
"WidgetDebugTab",
|
|
6659
|
+
"WidgetDebugView",
|
|
6660
|
+
"WidgetDialog",
|
|
6661
|
+
"WidgetGlyph",
|
|
6662
|
+
"WidgetHead",
|
|
6663
|
+
"WidgetHero",
|
|
6664
|
+
"WidgetIcon",
|
|
6665
|
+
"WidgetLayer",
|
|
6666
|
+
"WidgetManifestSchema",
|
|
6667
|
+
"WidgetSizeCtx",
|
|
6668
|
+
"WidgetSliderFill",
|
|
6669
|
+
"WidgetStatus",
|
|
6670
|
+
"WidgetStepper",
|
|
6671
|
+
"WidgetTitle",
|
|
6672
|
+
"WidgetValue",
|
|
6673
|
+
"buildDebugData",
|
|
6674
|
+
"byDomain",
|
|
6675
|
+
"calculateLightGroup",
|
|
6676
|
+
"calculateSensorGroup",
|
|
6677
|
+
"copyText",
|
|
6678
|
+
"countActiveEntities",
|
|
6679
|
+
"defineConfig",
|
|
6680
|
+
"defineWidget",
|
|
6681
|
+
"deprecations",
|
|
6682
|
+
"field",
|
|
6683
|
+
"formatDeprecation",
|
|
6684
|
+
"formatSchemaError",
|
|
6685
|
+
"getEntityAttribute",
|
|
6686
|
+
"getForecasts",
|
|
6687
|
+
"getStream",
|
|
6688
|
+
"getWebRtcClientConfig",
|
|
6689
|
+
"hassMediaUrl",
|
|
6690
|
+
"imagePreset",
|
|
6691
|
+
"imageSrc",
|
|
6692
|
+
"imageUrl",
|
|
6693
|
+
"injectTokens",
|
|
6694
|
+
"isDark",
|
|
6695
|
+
"isEntityActive",
|
|
6696
|
+
"isPanelControllable",
|
|
6697
|
+
"mediaUrl",
|
|
6698
|
+
"monotoneCubicPath",
|
|
6699
|
+
"parseColor",
|
|
6700
|
+
"presetValue",
|
|
6701
|
+
"provideCameraSource",
|
|
6702
|
+
"sendWebRtcCandidate",
|
|
6703
|
+
"startWebRtcSession",
|
|
6704
|
+
"state",
|
|
6705
|
+
"svgColors",
|
|
6706
|
+
"trackEntityHistory",
|
|
6707
|
+
"untrackEntityHistory",
|
|
6708
|
+
"useArea",
|
|
6709
|
+
"useCalendarEvents",
|
|
6710
|
+
"useCamera",
|
|
6711
|
+
"useCameraSource",
|
|
6712
|
+
"useConfirm",
|
|
6713
|
+
"useConnection",
|
|
6714
|
+
"useCopyText",
|
|
6715
|
+
"useCurrency",
|
|
6716
|
+
"useDaylight",
|
|
6717
|
+
"useEntities",
|
|
6718
|
+
"useEntity",
|
|
6719
|
+
"useEntityHistory",
|
|
6720
|
+
"useEntityStatistics",
|
|
6721
|
+
"useForecast",
|
|
6722
|
+
"useHassConfig",
|
|
6723
|
+
"useIntersectionPause",
|
|
6724
|
+
"useLocale",
|
|
6725
|
+
"useMaterial",
|
|
6726
|
+
"useReducedMotion",
|
|
6727
|
+
"useService",
|
|
6728
|
+
"useStore",
|
|
6729
|
+
"useTemperatureUnit",
|
|
6730
|
+
"useToggle",
|
|
6731
|
+
"useTurnOff",
|
|
6732
|
+
"useTurnOn",
|
|
6733
|
+
"useUnitSystem",
|
|
6734
|
+
"useWidgetContext",
|
|
6735
|
+
"useWidgetDashboard",
|
|
6736
|
+
"useWidgetDialog",
|
|
6737
|
+
"useWidgetDimensions",
|
|
6738
|
+
"useWidgetEntityGroup",
|
|
6739
|
+
"useWidgetGestures",
|
|
6740
|
+
"useWidgetState",
|
|
6741
|
+
"useWidgetViewer",
|
|
6742
|
+
"widgetFields",
|
|
6743
|
+
"z"
|
|
6446
6744
|
]
|
|
6447
6745
|
}
|
package/dist/index.js
CHANGED
|
@@ -3405,7 +3405,7 @@ function fs(e) {
|
|
|
3405
3405
|
//#region src/version.ts
|
|
3406
3406
|
var ps = {
|
|
3407
3407
|
name: "@glasshome/widget-sdk",
|
|
3408
|
-
version: "1.
|
|
3408
|
+
version: "1.32.1",
|
|
3409
3409
|
description: "SDK for building GlassHome dashboard widgets with SolidJS",
|
|
3410
3410
|
keywords: [
|
|
3411
3411
|
"dashboard",
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { type JSX } from "solid-js";
|
|
2
2
|
export interface CameraStreamProps {
|
|
3
3
|
entityId: string;
|
|
4
|
-
|
|
4
|
+
/** `image` shows `src`, an MJPEG stream or a snapshot, in the same box and full screen. */
|
|
5
|
+
kind: "webrtc" | "hls" | "image";
|
|
6
|
+
/** The picture an `image` stream shows; a new value replaces it in place. */
|
|
7
|
+
src?: string;
|
|
8
|
+
/** A new value restarts the stream in place, so full screen stays. */
|
|
9
|
+
session?: number;
|
|
5
10
|
muted: boolean;
|
|
6
11
|
poster?: string;
|
|
7
12
|
/** How the video fills the stream's box; `cover` by default. */
|
|
8
13
|
fit?: "cover" | "contain";
|
|
9
14
|
/** Shows a full screen control, which fills the screen with the stream from the homeowner's press. */
|
|
10
15
|
fullscreen?: boolean;
|
|
16
|
+
/** Shows a sound control in full screen, which reports through `onMutedChange`. */
|
|
17
|
+
sound?: boolean;
|
|
11
18
|
class?: string;
|
|
12
19
|
onLive?: () => void;
|
|
13
20
|
onAudio?: (has: boolean) => void;
|
|
14
21
|
onError?: (reason: string) => void;
|
|
15
22
|
onStale?: (reason: string) => void;
|
|
23
|
+
/** Where a stream that has not played yet stands, each time that changes. */
|
|
24
|
+
onStage?: (stage: string) => void;
|
|
25
|
+
onMutedChange?: (muted: boolean) => void;
|
|
16
26
|
}
|
|
17
|
-
/** A camera's live
|
|
27
|
+
/** A camera's live picture, over WebRTC, HLS or an image, from the camera source the host provides. */
|
|
18
28
|
export declare function CameraStream(props: CameraStreamProps): JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useCameraSource as e } from "./camera-source.js";
|
|
2
2
|
import { Show as t, createEffect as n, createSignal as r, on as i, onCleanup as a, onMount as o } from "solid-js";
|
|
3
|
-
import { className as s, createComponent as c, effect as l, insert as u,
|
|
4
|
-
import { Button as
|
|
3
|
+
import { className as s, createComponent as c, effect as l, insert as u, memo as d, setAttribute as f, setStyleProperty as p, style as m, template as h, use as g } from "solid-js/web";
|
|
4
|
+
import { Button as _, Icon as v } from "@glasshome/ui/solid";
|
|
5
5
|
//#region src/media/drivers/hls.ts
|
|
6
|
-
var
|
|
7
|
-
function
|
|
6
|
+
var y = 2, b = 2e3, x = (e) => e.audioTracks?.length ?? 0;
|
|
7
|
+
function S(e, t, n) {
|
|
8
8
|
let r = !1, i = null, a, o = () => {
|
|
9
|
-
|
|
9
|
+
x(e) > 0 && n.onAudio(!0), n.onLive();
|
|
10
10
|
}, s = () => n.onError(`native hls error: media error code ${e.error?.code ?? "unknown"}`);
|
|
11
11
|
return e.addEventListener("playing", o), import("hls.js").then(({ default: o }) => {
|
|
12
12
|
if (r) return;
|
|
@@ -25,7 +25,7 @@ function b(e, t, n) {
|
|
|
25
25
|
}), c.on(o.Events.ERROR, (e, t) => {
|
|
26
26
|
if (!t.fatal) return;
|
|
27
27
|
let r = t.response?.code, s = r ? `${t.details} (http ${r})` : t.details;
|
|
28
|
-
clearTimeout(a), t.type === o.ErrorTypes.MEDIA_ERROR && l++ <
|
|
28
|
+
clearTimeout(a), t.type === o.ErrorTypes.MEDIA_ERROR && l++ < y ? c.recoverMediaError() : t.type === o.ErrorTypes.NETWORK_ERROR && u++ < y ? a = setTimeout(() => c.startLoad(), b) : (c.destroy(), i = null, n.onError(`hls ${t.type}: ${s}`));
|
|
29
29
|
}), c.loadSource(t), c.attachMedia(e);
|
|
30
30
|
}).catch(() => {
|
|
31
31
|
r || n.onError("hls player failed to load");
|
|
@@ -35,7 +35,7 @@ function b(e, t, n) {
|
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/media/drivers/types.ts
|
|
38
|
-
function
|
|
38
|
+
function C(e) {
|
|
39
39
|
if (e instanceof Error) return e.message;
|
|
40
40
|
if (typeof e == "object" && e) {
|
|
41
41
|
let { message: t, code: n } = e;
|
|
@@ -46,131 +46,194 @@ function x(e) {
|
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/media/drivers/webrtc.ts
|
|
49
|
-
function
|
|
49
|
+
function w(e, t, n) {
|
|
50
50
|
let r = null, i = null, a = !1, o = !1, s = "config", c = () => {
|
|
51
|
+
a || n.onStage(`stage ${s}, connection ${r?.connectionState ?? "none"}`);
|
|
52
|
+
}, l = (e) => {
|
|
53
|
+
s = e, c();
|
|
54
|
+
};
|
|
55
|
+
c();
|
|
56
|
+
let u = () => {
|
|
51
57
|
o = !0, n.onLive();
|
|
52
58
|
};
|
|
53
|
-
return e.addEventListener("playing",
|
|
59
|
+
return e.addEventListener("playing", u), (async () => {
|
|
54
60
|
try {
|
|
55
|
-
let
|
|
61
|
+
let s = await t.config();
|
|
56
62
|
if (a) return;
|
|
57
|
-
let
|
|
58
|
-
r =
|
|
63
|
+
let u = new RTCPeerConnection(s);
|
|
64
|
+
r = u, u.ontrack = (t) => {
|
|
59
65
|
t.track.kind === "audio" && n.onAudio(!0), t.streams[0] && !a && (e.srcObject = t.streams[0]);
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
let
|
|
64
|
-
if (await
|
|
65
|
-
let
|
|
66
|
-
|
|
66
|
+
}, u.onconnectionstatechange = () => {
|
|
67
|
+
o || c(), u.connectionState === "failed" && (o ? n.onStale("ice connection failed") : n.onError("ice connection failed"));
|
|
68
|
+
}, u.addTransceiver("audio", { direction: "recvonly" }), u.addTransceiver("video", { direction: "recvonly" }), l("local offer");
|
|
69
|
+
let d = await u.createOffer();
|
|
70
|
+
if (await u.setLocalDescription(d), a) return;
|
|
71
|
+
let f = null, p = [], m = (e) => {
|
|
72
|
+
f ? t.candidate(f, e).catch(() => {}) : p.push(e);
|
|
67
73
|
};
|
|
68
|
-
if (
|
|
69
|
-
e.candidate &&
|
|
70
|
-
}, !
|
|
71
|
-
|
|
72
|
-
let
|
|
74
|
+
if (u.onicecandidate = (e) => {
|
|
75
|
+
e.candidate && m(e.candidate.toJSON());
|
|
76
|
+
}, !d.sdp) throw Error("offer has no sdp");
|
|
77
|
+
l("home assistant answer");
|
|
78
|
+
let h = await t.start(d.sdp, (e) => {
|
|
73
79
|
let t = { ...e };
|
|
74
|
-
!t.sdpMid && t.sdpMLineIndex == null && (t.sdpMid = "0"),
|
|
80
|
+
!t.sdpMid && t.sdpMLineIndex == null && (t.sdpMid = "0"), u.addIceCandidate(new RTCIceCandidate(t)).catch(() => {});
|
|
75
81
|
});
|
|
76
|
-
if (i =
|
|
77
|
-
|
|
82
|
+
if (i = h.stop, a) {
|
|
83
|
+
h.stop().catch(() => {});
|
|
78
84
|
return;
|
|
79
85
|
}
|
|
80
|
-
|
|
81
|
-
for (let e of
|
|
82
|
-
|
|
86
|
+
f = h.sessionId;
|
|
87
|
+
for (let e of p.splice(0)) m(e);
|
|
88
|
+
l("remote description"), await u.setRemoteDescription({
|
|
83
89
|
type: "answer",
|
|
84
|
-
sdp:
|
|
90
|
+
sdp: h.answer
|
|
85
91
|
});
|
|
86
92
|
} catch (e) {
|
|
87
|
-
a || n.onError(`${s}: ${
|
|
93
|
+
a || n.onError(`${s}: ${C(e)}`);
|
|
88
94
|
}
|
|
89
|
-
})(), {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
describe: () => `stage ${s}, connection ${r?.connectionState ?? "none"}`
|
|
94
|
-
};
|
|
95
|
+
})(), { stop: () => {
|
|
96
|
+
a = !0, e.removeEventListener("playing", u), e.srcObject = null, i?.().catch(() => {}), i = null, r?.close(), r = null;
|
|
97
|
+
} };
|
|
95
98
|
}
|
|
96
99
|
//#endregion
|
|
97
100
|
//#region src/media/camera-stream.tsx
|
|
98
|
-
var
|
|
101
|
+
var T = /*#__PURE__*/ h("<div style=position:absolute;left:0.75rem;bottom:0.75rem;display:flex;gap:0.5rem>"), E = /*#__PURE__*/ h("<div style=position:relative;overflow:hidden><video autoplay playsinline>"), D = /*#__PURE__*/ h("<img alt>"), O = {
|
|
99
102
|
position: "absolute",
|
|
100
103
|
inset: "0",
|
|
101
104
|
width: "100%",
|
|
102
105
|
height: "100%"
|
|
103
106
|
};
|
|
104
|
-
function
|
|
105
|
-
let
|
|
107
|
+
function k(h) {
|
|
108
|
+
let y = e(), b, x, [k, A] = r(!1), j = typeof document < "u" && document.fullscreenEnabled, M = () => h.kind === "image";
|
|
106
109
|
o(() => {
|
|
107
|
-
n(i([
|
|
110
|
+
n(i([
|
|
111
|
+
() => h.entityId,
|
|
112
|
+
() => h.kind,
|
|
113
|
+
() => h.session
|
|
114
|
+
], ([e, t]) => {
|
|
115
|
+
if (t === "image") return;
|
|
108
116
|
let n = !0, r, i = {
|
|
109
|
-
onLive: () => n &&
|
|
110
|
-
onAudio: (e) => n &&
|
|
111
|
-
onError: (e) => n &&
|
|
112
|
-
onStale: (e) => n &&
|
|
117
|
+
onLive: () => n && h.onLive?.(),
|
|
118
|
+
onAudio: (e) => n && h.onAudio?.(e),
|
|
119
|
+
onError: (e) => n && h.onError?.(e),
|
|
120
|
+
onStale: (e) => n && h.onStale?.(e),
|
|
121
|
+
onStage: (e) => n && h.onStage?.(e)
|
|
113
122
|
};
|
|
114
123
|
if (t === "webrtc") try {
|
|
115
|
-
r =
|
|
124
|
+
r = w(x, y.webrtc(e), i);
|
|
116
125
|
} catch (e) {
|
|
117
|
-
i.onError(`webrtc: ${
|
|
126
|
+
i.onError(`webrtc: ${C(e)}`);
|
|
118
127
|
}
|
|
119
|
-
else Promise.resolve().then(() =>
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
else i.onStage("hls stream request"), Promise.resolve().then(() => y.stream(e, "hls")).then((e) => {
|
|
129
|
+
if (n) {
|
|
130
|
+
if (!e) return i.onError("home assistant returned no hls url");
|
|
131
|
+
i.onStage("hls playlist"), r = S(x, e, i);
|
|
132
|
+
}
|
|
133
|
+
}).catch((e) => i.onError(`hls stream request: ${C(e)}`));
|
|
122
134
|
a(() => {
|
|
123
|
-
n = !1, r?.stop(),
|
|
135
|
+
n = !1, r?.stop(), x.removeAttribute("src"), x.load();
|
|
124
136
|
});
|
|
125
137
|
}));
|
|
126
|
-
let e = () =>
|
|
127
|
-
document.addEventListener("fullscreenchange",
|
|
128
|
-
document.removeEventListener("fullscreenchange",
|
|
138
|
+
let e = () => b.getRootNode().fullscreenElement === b, t = () => A(e());
|
|
139
|
+
document.addEventListener("fullscreenchange", t), a(() => {
|
|
140
|
+
document.removeEventListener("fullscreenchange", t), e() && document.exitFullscreen();
|
|
129
141
|
});
|
|
130
142
|
});
|
|
131
|
-
let
|
|
132
|
-
|
|
143
|
+
let N = () => {
|
|
144
|
+
k() ? document.exitFullscreen() : b.requestFullscreen();
|
|
133
145
|
};
|
|
134
146
|
return (() => {
|
|
135
|
-
var e =
|
|
136
|
-
typeof r == "function" ?
|
|
137
|
-
var i =
|
|
138
|
-
return typeof i == "function" ?
|
|
147
|
+
var e = E(), n = e.firstChild, r = b;
|
|
148
|
+
typeof r == "function" ? g(r, e) : b = e;
|
|
149
|
+
var i = x;
|
|
150
|
+
return typeof i == "function" ? g(i, n) : x = n, u(e, c(t, {
|
|
151
|
+
get when() {
|
|
152
|
+
return d(() => !!M())() && { session: h.session };
|
|
153
|
+
},
|
|
154
|
+
keyed: !0,
|
|
155
|
+
children: (e) => {
|
|
156
|
+
let t = !0, n;
|
|
157
|
+
return a(() => {
|
|
158
|
+
t = !1, n.removeAttribute("src");
|
|
159
|
+
}), (() => {
|
|
160
|
+
var e = D();
|
|
161
|
+
e.addEventListener("error", () => t && h.onError?.("image error")), e.addEventListener("load", () => t && h.onLive?.());
|
|
162
|
+
var r = n;
|
|
163
|
+
return typeof r == "function" ? g(r, e) : n = e, l((t) => {
|
|
164
|
+
var n = h.src, r = {
|
|
165
|
+
...O,
|
|
166
|
+
"object-fit": k() ? "contain" : h.fit ?? "cover"
|
|
167
|
+
};
|
|
168
|
+
return n !== t.e && f(e, "src", t.e = n), t.t = m(e, r, t.t), t;
|
|
169
|
+
}, {
|
|
170
|
+
e: void 0,
|
|
171
|
+
t: void 0
|
|
172
|
+
}), e;
|
|
173
|
+
})();
|
|
174
|
+
}
|
|
175
|
+
}), null), u(e, c(t, {
|
|
139
176
|
get when() {
|
|
140
|
-
return
|
|
177
|
+
return h.fullscreen && j;
|
|
141
178
|
},
|
|
142
179
|
get children() {
|
|
143
|
-
var e =
|
|
144
|
-
return u(e, c(
|
|
180
|
+
var e = T();
|
|
181
|
+
return u(e, c(_, {
|
|
145
182
|
variant: "outline",
|
|
146
183
|
size: "icon",
|
|
147
184
|
get "aria-label"() {
|
|
148
|
-
return
|
|
185
|
+
return k() ? "Exit full screen" : "Full screen";
|
|
149
186
|
},
|
|
150
|
-
onClick:
|
|
187
|
+
onClick: N,
|
|
151
188
|
get children() {
|
|
152
|
-
return c(
|
|
189
|
+
return c(v, {
|
|
153
190
|
get icon() {
|
|
154
|
-
return
|
|
191
|
+
return k() ? "mdi:fullscreen-exit" : "mdi:fullscreen";
|
|
155
192
|
},
|
|
156
193
|
width: 18
|
|
157
194
|
});
|
|
158
195
|
}
|
|
159
|
-
})), e
|
|
196
|
+
}), null), u(e, c(t, {
|
|
197
|
+
get when() {
|
|
198
|
+
return d(() => !!k())() && h.sound;
|
|
199
|
+
},
|
|
200
|
+
get children() {
|
|
201
|
+
return c(_, {
|
|
202
|
+
get variant() {
|
|
203
|
+
return h.muted ? "outline" : "default";
|
|
204
|
+
},
|
|
205
|
+
size: "icon",
|
|
206
|
+
get "aria-label"() {
|
|
207
|
+
return h.muted ? "Turn sound on" : "Turn sound off";
|
|
208
|
+
},
|
|
209
|
+
onClick: () => h.onMutedChange?.(!h.muted),
|
|
210
|
+
get children() {
|
|
211
|
+
return c(v, {
|
|
212
|
+
get icon() {
|
|
213
|
+
return h.muted ? "mdi:volume-off" : "mdi:volume-high";
|
|
214
|
+
},
|
|
215
|
+
width: 18
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}), null), e;
|
|
160
221
|
}
|
|
161
222
|
}), null), l((t) => {
|
|
162
|
-
var r =
|
|
163
|
-
...
|
|
164
|
-
"object-fit":
|
|
223
|
+
var r = h.class, i = k() ? "black" : void 0, a = h.muted, o = M() ? void 0 : h.poster, c = {
|
|
224
|
+
...O,
|
|
225
|
+
"object-fit": h.fit ?? "cover",
|
|
226
|
+
display: M() ? "none" : void 0
|
|
165
227
|
};
|
|
166
|
-
return r !== t.e && s(e, t.e = r), i !== t.t && (
|
|
228
|
+
return r !== t.e && s(e, t.e = r), i !== t.t && p(e, "background", t.t = i), a !== t.a && (n.muted = t.a = a), o !== t.o && f(n, "poster", t.o = o), t.i = m(n, c, t.i), t;
|
|
167
229
|
}, {
|
|
168
230
|
e: void 0,
|
|
169
231
|
t: void 0,
|
|
170
232
|
a: void 0,
|
|
171
|
-
o: void 0
|
|
233
|
+
o: void 0,
|
|
234
|
+
i: void 0
|
|
172
235
|
}), e;
|
|
173
236
|
})();
|
|
174
237
|
}
|
|
175
238
|
//#endregion
|
|
176
|
-
export {
|
|
239
|
+
export { k as CameraStream };
|
|
@@ -3,9 +3,9 @@ export interface StreamCallbacks {
|
|
|
3
3
|
onAudio: (has: boolean) => void;
|
|
4
4
|
onError: (reason: string) => void;
|
|
5
5
|
onStale: (reason: string) => void;
|
|
6
|
+
onStage: (stage: string) => void;
|
|
6
7
|
}
|
|
7
8
|
export interface StreamDriver {
|
|
8
9
|
stop: () => void;
|
|
9
|
-
describe?: () => string;
|
|
10
10
|
}
|
|
11
11
|
export declare function reasonOf(err: unknown): string;
|