@moq/publish 0.1.0 → 0.1.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/element.js +53 -53
- package/element.js.map +1 -1
- package/index.js +2 -2
- package/package.json +3 -3
- package/{screen-BCioRZHS.js → screen-Dz_GBTAe.js} +31 -24
- package/{screen-BCioRZHS.js.map → screen-Dz_GBTAe.js.map} +1 -1
- package/support/element.js +6 -6
- package/support/element.js.map +1 -1
- package/ui/index.js +60 -60
- package/ui/index.js.map +1 -1
package/element.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as l from "@moq/lite";
|
|
2
2
|
import { Signal as n, Effect as d } from "@moq/signals";
|
|
3
|
-
import { B as
|
|
4
|
-
const
|
|
5
|
-
class
|
|
6
|
-
static observedAttributes =
|
|
3
|
+
import { B as u, C as h, M as b, S as v, F as g } from "./screen-Dz_GBTAe.js";
|
|
4
|
+
const p = ["url", "name", "path", "muted", "invisible", "source"], w = new FinalizationRegistry((c) => c.close());
|
|
5
|
+
class m extends HTMLElement {
|
|
6
|
+
static observedAttributes = p;
|
|
7
7
|
url = new n(void 0);
|
|
8
8
|
path = new n(void 0);
|
|
9
9
|
source = new n(void 0);
|
|
@@ -19,20 +19,20 @@ class w extends HTMLElement {
|
|
|
19
19
|
// The inverse of the `muted` and `invisible` signals.
|
|
20
20
|
#s;
|
|
21
21
|
#e;
|
|
22
|
-
#
|
|
22
|
+
#i;
|
|
23
23
|
// Set when the element is connected to the DOM.
|
|
24
|
-
#
|
|
24
|
+
#t = new n(!1);
|
|
25
25
|
signals = new d();
|
|
26
26
|
constructor() {
|
|
27
|
-
super(),
|
|
27
|
+
super(), w.register(this, this.signals), this.connection = new l.Connection.Reload({
|
|
28
28
|
url: this.url,
|
|
29
|
-
enabled: this.#
|
|
30
|
-
}), this.signals.cleanup(() => this.connection.close()), this.#s = new n(!1), this.#e = new n(!1), this.#
|
|
31
|
-
const e = s.get(this.muted),
|
|
32
|
-
this.#s.set(!
|
|
33
|
-
}), this.broadcast = new
|
|
29
|
+
enabled: this.#t
|
|
30
|
+
}), this.signals.cleanup(() => this.connection.close()), this.#s = new n(!1), this.#e = new n(!1), this.#i = new n(!1), this.signals.run((s) => {
|
|
31
|
+
const e = s.get(this.muted), t = s.get(this.invisible);
|
|
32
|
+
this.#s.set(!t), this.#e.set(!e), this.#i.set(!e || !t);
|
|
33
|
+
}), this.broadcast = new u({
|
|
34
34
|
connection: this.connection.established,
|
|
35
|
-
enabled: this.#
|
|
35
|
+
enabled: this.#t,
|
|
36
36
|
path: this.path,
|
|
37
37
|
audio: {
|
|
38
38
|
enabled: this.#e
|
|
@@ -43,89 +43,89 @@ class w extends HTMLElement {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}), this.signals.cleanup(() => this.broadcast.close());
|
|
46
|
-
const
|
|
46
|
+
const i = () => {
|
|
47
47
|
this.#o.set(this.querySelector("video"));
|
|
48
|
-
}, o = new MutationObserver(
|
|
49
|
-
o.observe(this, { childList: !0, subtree: !0 }), this.signals.cleanup(() => o.disconnect()),
|
|
48
|
+
}, o = new MutationObserver(i);
|
|
49
|
+
o.observe(this, { childList: !0, subtree: !0 }), this.signals.cleanup(() => o.disconnect()), i(), this.signals.run((s) => {
|
|
50
50
|
const e = s.get(this.#o);
|
|
51
51
|
if (!e) return;
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
52
|
+
const t = s.get(this.broadcast.video.source);
|
|
53
|
+
if (!t) {
|
|
54
54
|
e.style.display = "none";
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
e.srcObject = new MediaStream([
|
|
57
|
+
e.srcObject = new MediaStream([t]), e.style.display = "block", s.cleanup(() => {
|
|
58
58
|
e.srcObject = null;
|
|
59
59
|
});
|
|
60
|
-
}), this.signals.
|
|
60
|
+
}), this.signals.run(this.#n.bind(this));
|
|
61
61
|
}
|
|
62
62
|
connectedCallback() {
|
|
63
|
-
this.#
|
|
63
|
+
this.#t.set(!0);
|
|
64
64
|
}
|
|
65
65
|
disconnectedCallback() {
|
|
66
|
-
this.#
|
|
66
|
+
this.#t.set(!1);
|
|
67
67
|
}
|
|
68
|
-
attributeChangedCallback(
|
|
68
|
+
attributeChangedCallback(i, o, s) {
|
|
69
69
|
if (o !== s)
|
|
70
|
-
if (
|
|
70
|
+
if (i === "url")
|
|
71
71
|
this.url.set(s ? new URL(s) : void 0);
|
|
72
|
-
else if (
|
|
72
|
+
else if (i === "name" || i === "path")
|
|
73
73
|
this.path.set(s ? l.Path.from(s) : void 0);
|
|
74
|
-
else if (
|
|
74
|
+
else if (i === "source")
|
|
75
75
|
if (s === "camera" || s === "screen" || s === "file" || s === null)
|
|
76
76
|
this.source.set(s);
|
|
77
77
|
else
|
|
78
78
|
throw new Error(`Invalid source: ${s}`);
|
|
79
|
-
else if (
|
|
79
|
+
else if (i === "muted")
|
|
80
80
|
this.muted.set(s !== null);
|
|
81
|
-
else if (
|
|
81
|
+
else if (i === "invisible")
|
|
82
82
|
this.invisible.set(s !== null);
|
|
83
83
|
else {
|
|
84
|
-
const e =
|
|
84
|
+
const e = i;
|
|
85
85
|
throw new Error(`Invalid attribute: ${e}`);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
#n(
|
|
89
|
-
const o =
|
|
88
|
+
#n(i) {
|
|
89
|
+
const o = i.get(this.source);
|
|
90
90
|
if (!o) return;
|
|
91
91
|
if (o === "camera") {
|
|
92
|
-
const e = new
|
|
93
|
-
this.signals.
|
|
94
|
-
const
|
|
95
|
-
this.broadcast.video.source.set(
|
|
92
|
+
const e = new h({ enabled: this.#s });
|
|
93
|
+
this.signals.run((r) => {
|
|
94
|
+
const a = r.get(e.source);
|
|
95
|
+
this.broadcast.video.source.set(a);
|
|
96
96
|
});
|
|
97
|
-
const
|
|
98
|
-
this.signals.
|
|
99
|
-
const
|
|
100
|
-
this.broadcast.audio.source.set(
|
|
101
|
-
}),
|
|
102
|
-
e.close(),
|
|
97
|
+
const t = new b({ enabled: this.#e });
|
|
98
|
+
this.signals.run((r) => {
|
|
99
|
+
const a = r.get(t.source);
|
|
100
|
+
this.broadcast.audio.source.set(a);
|
|
101
|
+
}), i.set(this.video, e), i.set(this.audio, t), i.cleanup(() => {
|
|
102
|
+
e.close(), t.close();
|
|
103
103
|
});
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
if (o === "screen") {
|
|
107
107
|
const e = new v({
|
|
108
|
-
enabled: this.#
|
|
108
|
+
enabled: this.#i
|
|
109
109
|
});
|
|
110
|
-
this.signals.
|
|
111
|
-
const r =
|
|
112
|
-
r && (
|
|
113
|
-
}),
|
|
110
|
+
this.signals.run((t) => {
|
|
111
|
+
const r = t.get(e.source);
|
|
112
|
+
r && (t.set(this.broadcast.video.source, r.video), t.set(this.broadcast.audio.source, r.audio));
|
|
113
|
+
}), i.set(this.video, e), i.set(this.audio, e), i.cleanup(() => {
|
|
114
114
|
e.close();
|
|
115
115
|
});
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
if (o === "file" || o instanceof File) {
|
|
119
|
-
const e = new
|
|
119
|
+
const e = new g({
|
|
120
120
|
// If a File is provided, use it directly.
|
|
121
121
|
// TODO: Show a file picker otherwise.
|
|
122
122
|
file: o instanceof File ? o : void 0,
|
|
123
|
-
enabled: this.#
|
|
123
|
+
enabled: this.#i
|
|
124
124
|
});
|
|
125
|
-
this.signals.
|
|
126
|
-
const r =
|
|
125
|
+
this.signals.run((t) => {
|
|
126
|
+
const r = t.get(e.source);
|
|
127
127
|
this.broadcast.video.source.set(r.video), this.broadcast.audio.source.set(r.audio);
|
|
128
|
-
}),
|
|
128
|
+
}), i.cleanup(() => {
|
|
129
129
|
e.close();
|
|
130
130
|
});
|
|
131
131
|
return;
|
|
@@ -134,8 +134,8 @@ class w extends HTMLElement {
|
|
|
134
134
|
throw new Error(`Invalid source: ${s}`);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
customElements.define("moq-publish",
|
|
137
|
+
customElements.define("moq-publish", m);
|
|
138
138
|
export {
|
|
139
|
-
|
|
139
|
+
m as default
|
|
140
140
|
};
|
|
141
141
|
//# sourceMappingURL=element.js.map
|
package/element.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","sources":["../src/element.ts"],"sourcesContent":["import * as Moq from \"@moq/lite\";\nimport { Effect, Signal } from \"@moq/signals\";\nimport { Broadcast } from \"./broadcast\";\nimport * as Source from \"./source\";\n\n// TODO remove name; replaced with path\nconst OBSERVED = [\"url\", \"name\", \"path\", \"muted\", \"invisible\", \"source\"] as const;\ntype Observed = (typeof OBSERVED)[number];\n\ntype SourceType = \"camera\" | \"screen\" | \"file\";\n\n// Close everything when this element is garbage collected.\n// This is primarily to avoid a console.warn that we didn't close() before GC.\n// There's no destructor for web components so this is the best we can do.\nconst cleanup = new FinalizationRegistry<Effect>((signals) => signals.close());\n\nexport default class MoqPublish extends HTMLElement {\n\tstatic observedAttributes = OBSERVED;\n\n\turl = new Signal<URL | undefined>(undefined);\n\tpath = new Signal<Moq.Path.Valid | undefined>(undefined);\n\tsource = new Signal<SourceType | File | undefined>(undefined);\n\n\t// Controls whether audio/video is enabled.\n\tmuted = new Signal(false);\n\tinvisible = new Signal(false);\n\n\tconnection: Moq.Connection.Reload;\n\tbroadcast: Broadcast;\n\n\t#preview = new Signal<HTMLVideoElement | undefined>(undefined);\n\n\tvideo = new Signal<Source.Camera | Source.Screen | undefined>(undefined);\n\taudio = new Signal<Source.Microphone | Source.Screen | undefined>(undefined);\n\tfile = new Signal<Source.File | undefined>(undefined);\n\n\t// The inverse of the `muted` and `invisible` signals.\n\t#videoEnabled: Signal<boolean>;\n\t#audioEnabled: Signal<boolean>;\n\t#eitherEnabled: Signal<boolean>;\n\n\t// Set when the element is connected to the DOM.\n\t#enabled = new Signal(false);\n\n\tsignals = new Effect();\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tcleanup.register(this, this.signals);\n\n\t\tthis.connection = new Moq.Connection.Reload({\n\t\t\turl: this.url,\n\t\t\tenabled: this.#enabled,\n\t\t});\n\t\tthis.signals.cleanup(() => this.connection.close());\n\n\t\t// The inverse of the `muted` and `invisible` signals.\n\t\t// TODO make this.signals.computed to simplify the code.\n\t\tthis.#videoEnabled = new Signal(false);\n\t\tthis.#audioEnabled = new Signal(false);\n\t\tthis.#eitherEnabled = new Signal(false);\n\n\t\tthis.signals.effect((effect) => {\n\t\t\tconst muted = effect.get(this.muted);\n\t\t\tconst invisible = effect.get(this.invisible);\n\t\t\tthis.#videoEnabled.set(!invisible);\n\t\t\tthis.#audioEnabled.set(!muted);\n\t\t\tthis.#eitherEnabled.set(!muted || !invisible);\n\t\t});\n\n\t\tthis.broadcast = new Broadcast({\n\t\t\tconnection: this.connection.established,\n\t\t\tenabled: this.#enabled,\n\t\t\tpath: this.path,\n\n\t\t\taudio: {\n\t\t\t\tenabled: this.#audioEnabled,\n\t\t\t},\n\t\t\tvideo: {\n\t\t\t\thd: {\n\t\t\t\t\tenabled: this.#videoEnabled,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.signals.cleanup(() => this.broadcast.close());\n\n\t\t// Watch to see if the preview element is added or removed.\n\t\tconst setPreview = () => {\n\t\t\tthis.#preview.set(this.querySelector(\"video\") as HTMLVideoElement | undefined);\n\t\t};\n\t\tconst observer = new MutationObserver(setPreview);\n\t\tobserver.observe(this, { childList: true, subtree: true });\n\t\tthis.signals.cleanup(() => observer.disconnect());\n\t\tsetPreview();\n\n\t\tthis.signals.effect((effect) => {\n\t\t\tconst preview = effect.get(this.#preview);\n\t\t\tif (!preview) return;\n\n\t\t\tconst source = effect.get(this.broadcast.video.source);\n\t\t\tif (!source) {\n\t\t\t\tpreview.style.display = \"none\";\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tpreview.srcObject = new MediaStream([source]);\n\t\t\tpreview.style.display = \"block\";\n\n\t\t\teffect.cleanup(() => {\n\t\t\t\tpreview.srcObject = null;\n\t\t\t});\n\t\t});\n\n\t\tthis.signals.effect(this.#runSource.bind(this));\n\t}\n\n\tconnectedCallback() {\n\t\tthis.#enabled.set(true);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.#enabled.set(false);\n\t}\n\n\tattributeChangedCallback(name: Observed, oldValue: string | null, newValue: string | null) {\n\t\tif (oldValue === newValue) return;\n\n\t\tif (name === \"url\") {\n\t\t\tthis.url.set(newValue ? new URL(newValue) : undefined);\n\t\t} else if (name === \"name\" || name === \"path\") {\n\t\t\tthis.path.set(newValue ? Moq.Path.from(newValue) : undefined);\n\t\t} else if (name === \"source\") {\n\t\t\tif (newValue === \"camera\" || newValue === \"screen\" || newValue === \"file\" || newValue === null) {\n\t\t\t\tthis.source.set(newValue as SourceType | undefined);\n\t\t\t} else {\n\t\t\t\tthrow new Error(`Invalid source: ${newValue}`);\n\t\t\t}\n\t\t} else if (name === \"muted\") {\n\t\t\tthis.muted.set(newValue !== null);\n\t\t} else if (name === \"invisible\") {\n\t\t\tthis.invisible.set(newValue !== null);\n\t\t} else {\n\t\t\tconst exhaustive: never = name;\n\t\t\tthrow new Error(`Invalid attribute: ${exhaustive}`);\n\t\t}\n\t}\n\n\t#runSource(effect: Effect) {\n\t\tconst source = effect.get(this.source);\n\t\tif (!source) return;\n\n\t\tif (source === \"camera\") {\n\t\t\tconst video = new Source.Camera({ enabled: this.#videoEnabled });\n\t\t\tthis.signals.effect((effect) => {\n\t\t\t\tconst source = effect.get(video.source);\n\t\t\t\tthis.broadcast.video.source.set(source);\n\t\t\t});\n\n\t\t\tconst audio = new Source.Microphone({ enabled: this.#audioEnabled });\n\t\t\tthis.signals.effect((effect) => {\n\t\t\t\tconst source = effect.get(audio.source);\n\t\t\t\tthis.broadcast.audio.source.set(source);\n\t\t\t});\n\n\t\t\teffect.set(this.video, video);\n\t\t\teffect.set(this.audio, audio);\n\n\t\t\teffect.cleanup(() => {\n\t\t\t\tvideo.close();\n\t\t\t\taudio.close();\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (source === \"screen\") {\n\t\t\tconst screen = new Source.Screen({\n\t\t\t\tenabled: this.#eitherEnabled,\n\t\t\t});\n\n\t\t\tthis.signals.effect((effect) => {\n\t\t\t\tconst source = effect.get(screen.source);\n\t\t\t\tif (!source) return;\n\n\t\t\t\teffect.set(this.broadcast.video.source, source.video);\n\t\t\t\teffect.set(this.broadcast.audio.source, source.audio);\n\t\t\t});\n\n\t\t\teffect.set(this.video, screen);\n\t\t\teffect.set(this.audio, screen);\n\n\t\t\teffect.cleanup(() => {\n\t\t\t\tscreen.close();\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (source === \"file\" || source instanceof File) {\n\t\t\tconst fileSource = new Source.File({\n\t\t\t\t// If a File is provided, use it directly.\n\t\t\t\t// TODO: Show a file picker otherwise.\n\t\t\t\tfile: source instanceof File ? source : undefined,\n\t\t\t\tenabled: this.#eitherEnabled,\n\t\t\t});\n\n\t\t\tthis.signals.effect((effect) => {\n\t\t\t\tconst source = effect.get(fileSource.source);\n\t\t\t\tthis.broadcast.video.source.set(source.video);\n\t\t\t\tthis.broadcast.audio.source.set(source.audio);\n\t\t\t});\n\n\t\t\teffect.cleanup(() => {\n\t\t\t\tfileSource.close();\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst exhaustive: never = source;\n\t\tthrow new Error(`Invalid source: ${exhaustive}`);\n\t}\n}\n\ncustomElements.define(\"moq-publish\", MoqPublish);\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"moq-publish\": MoqPublish;\n\t}\n}\n"],"names":["OBSERVED","cleanup","signals","MoqPublish","Signal","#preview","#videoEnabled","#audioEnabled","#eitherEnabled","#enabled","Effect","Moq","effect","muted","invisible","Broadcast","setPreview","observer","preview","source","#runSource","name","oldValue","newValue","exhaustive","video","Source.Camera","audio","Source.Microphone","screen","Source.Screen","fileSource","Source.File"],"mappings":";;;AAMA,MAAMA,IAAW,CAAC,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":["import * as Moq from \"@moq/lite\";\nimport { Effect, Signal } from \"@moq/signals\";\nimport { Broadcast } from \"./broadcast\";\nimport * as Source from \"./source\";\n\n// TODO remove name; replaced with path\nconst OBSERVED = [\"url\", \"name\", \"path\", \"muted\", \"invisible\", \"source\"] as const;\ntype Observed = (typeof OBSERVED)[number];\n\ntype SourceType = \"camera\" | \"screen\" | \"file\";\n\n// Close everything when this element is garbage collected.\n// This is primarily to avoid a console.warn that we didn't close() before GC.\n// There's no destructor for web components so this is the best we can do.\nconst cleanup = new FinalizationRegistry<Effect>((signals) => signals.close());\n\nexport default class MoqPublish extends HTMLElement {\n\tstatic observedAttributes = OBSERVED;\n\n\turl = new Signal<URL | undefined>(undefined);\n\tpath = new Signal<Moq.Path.Valid | undefined>(undefined);\n\tsource = new Signal<SourceType | File | undefined>(undefined);\n\n\t// Controls whether audio/video is enabled.\n\tmuted = new Signal(false);\n\tinvisible = new Signal(false);\n\n\tconnection: Moq.Connection.Reload;\n\tbroadcast: Broadcast;\n\n\t#preview = new Signal<HTMLVideoElement | undefined>(undefined);\n\n\tvideo = new Signal<Source.Camera | Source.Screen | undefined>(undefined);\n\taudio = new Signal<Source.Microphone | Source.Screen | undefined>(undefined);\n\tfile = new Signal<Source.File | undefined>(undefined);\n\n\t// The inverse of the `muted` and `invisible` signals.\n\t#videoEnabled: Signal<boolean>;\n\t#audioEnabled: Signal<boolean>;\n\t#eitherEnabled: Signal<boolean>;\n\n\t// Set when the element is connected to the DOM.\n\t#enabled = new Signal(false);\n\n\tsignals = new Effect();\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tcleanup.register(this, this.signals);\n\n\t\tthis.connection = new Moq.Connection.Reload({\n\t\t\turl: this.url,\n\t\t\tenabled: this.#enabled,\n\t\t});\n\t\tthis.signals.cleanup(() => this.connection.close());\n\n\t\t// The inverse of the `muted` and `invisible` signals.\n\t\t// TODO make this.signals.computed to simplify the code.\n\t\tthis.#videoEnabled = new Signal(false);\n\t\tthis.#audioEnabled = new Signal(false);\n\t\tthis.#eitherEnabled = new Signal(false);\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst muted = effect.get(this.muted);\n\t\t\tconst invisible = effect.get(this.invisible);\n\t\t\tthis.#videoEnabled.set(!invisible);\n\t\t\tthis.#audioEnabled.set(!muted);\n\t\t\tthis.#eitherEnabled.set(!muted || !invisible);\n\t\t});\n\n\t\tthis.broadcast = new Broadcast({\n\t\t\tconnection: this.connection.established,\n\t\t\tenabled: this.#enabled,\n\t\t\tpath: this.path,\n\n\t\t\taudio: {\n\t\t\t\tenabled: this.#audioEnabled,\n\t\t\t},\n\t\t\tvideo: {\n\t\t\t\thd: {\n\t\t\t\t\tenabled: this.#videoEnabled,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.signals.cleanup(() => this.broadcast.close());\n\n\t\t// Watch to see if the preview element is added or removed.\n\t\tconst setPreview = () => {\n\t\t\tthis.#preview.set(this.querySelector(\"video\") as HTMLVideoElement | undefined);\n\t\t};\n\t\tconst observer = new MutationObserver(setPreview);\n\t\tobserver.observe(this, { childList: true, subtree: true });\n\t\tthis.signals.cleanup(() => observer.disconnect());\n\t\tsetPreview();\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst preview = effect.get(this.#preview);\n\t\t\tif (!preview) return;\n\n\t\t\tconst source = effect.get(this.broadcast.video.source);\n\t\t\tif (!source) {\n\t\t\t\tpreview.style.display = \"none\";\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tpreview.srcObject = new MediaStream([source]);\n\t\t\tpreview.style.display = \"block\";\n\n\t\t\teffect.cleanup(() => {\n\t\t\t\tpreview.srcObject = null;\n\t\t\t});\n\t\t});\n\n\t\tthis.signals.run(this.#runSource.bind(this));\n\t}\n\n\tconnectedCallback() {\n\t\tthis.#enabled.set(true);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.#enabled.set(false);\n\t}\n\n\tattributeChangedCallback(name: Observed, oldValue: string | null, newValue: string | null) {\n\t\tif (oldValue === newValue) return;\n\n\t\tif (name === \"url\") {\n\t\t\tthis.url.set(newValue ? new URL(newValue) : undefined);\n\t\t} else if (name === \"name\" || name === \"path\") {\n\t\t\tthis.path.set(newValue ? Moq.Path.from(newValue) : undefined);\n\t\t} else if (name === \"source\") {\n\t\t\tif (newValue === \"camera\" || newValue === \"screen\" || newValue === \"file\" || newValue === null) {\n\t\t\t\tthis.source.set(newValue as SourceType | undefined);\n\t\t\t} else {\n\t\t\t\tthrow new Error(`Invalid source: ${newValue}`);\n\t\t\t}\n\t\t} else if (name === \"muted\") {\n\t\t\tthis.muted.set(newValue !== null);\n\t\t} else if (name === \"invisible\") {\n\t\t\tthis.invisible.set(newValue !== null);\n\t\t} else {\n\t\t\tconst exhaustive: never = name;\n\t\t\tthrow new Error(`Invalid attribute: ${exhaustive}`);\n\t\t}\n\t}\n\n\t#runSource(effect: Effect) {\n\t\tconst source = effect.get(this.source);\n\t\tif (!source) return;\n\n\t\tif (source === \"camera\") {\n\t\t\tconst video = new Source.Camera({ enabled: this.#videoEnabled });\n\t\t\tthis.signals.run((effect) => {\n\t\t\t\tconst source = effect.get(video.source);\n\t\t\t\tthis.broadcast.video.source.set(source);\n\t\t\t});\n\n\t\t\tconst audio = new Source.Microphone({ enabled: this.#audioEnabled });\n\t\t\tthis.signals.run((effect) => {\n\t\t\t\tconst source = effect.get(audio.source);\n\t\t\t\tthis.broadcast.audio.source.set(source);\n\t\t\t});\n\n\t\t\teffect.set(this.video, video);\n\t\t\teffect.set(this.audio, audio);\n\n\t\t\teffect.cleanup(() => {\n\t\t\t\tvideo.close();\n\t\t\t\taudio.close();\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (source === \"screen\") {\n\t\t\tconst screen = new Source.Screen({\n\t\t\t\tenabled: this.#eitherEnabled,\n\t\t\t});\n\n\t\t\tthis.signals.run((effect) => {\n\t\t\t\tconst source = effect.get(screen.source);\n\t\t\t\tif (!source) return;\n\n\t\t\t\teffect.set(this.broadcast.video.source, source.video);\n\t\t\t\teffect.set(this.broadcast.audio.source, source.audio);\n\t\t\t});\n\n\t\t\teffect.set(this.video, screen);\n\t\t\teffect.set(this.audio, screen);\n\n\t\t\teffect.cleanup(() => {\n\t\t\t\tscreen.close();\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (source === \"file\" || source instanceof File) {\n\t\t\tconst fileSource = new Source.File({\n\t\t\t\t// If a File is provided, use it directly.\n\t\t\t\t// TODO: Show a file picker otherwise.\n\t\t\t\tfile: source instanceof File ? source : undefined,\n\t\t\t\tenabled: this.#eitherEnabled,\n\t\t\t});\n\n\t\t\tthis.signals.run((effect) => {\n\t\t\t\tconst source = effect.get(fileSource.source);\n\t\t\t\tthis.broadcast.video.source.set(source.video);\n\t\t\t\tthis.broadcast.audio.source.set(source.audio);\n\t\t\t});\n\n\t\t\teffect.cleanup(() => {\n\t\t\t\tfileSource.close();\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst exhaustive: never = source;\n\t\tthrow new Error(`Invalid source: ${exhaustive}`);\n\t}\n}\n\ncustomElements.define(\"moq-publish\", MoqPublish);\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"moq-publish\": MoqPublish;\n\t}\n}\n"],"names":["OBSERVED","cleanup","signals","MoqPublish","Signal","#preview","#videoEnabled","#audioEnabled","#eitherEnabled","#enabled","Effect","Moq","effect","muted","invisible","Broadcast","setPreview","observer","preview","source","#runSource","name","oldValue","newValue","exhaustive","video","Source.Camera","audio","Source.Microphone","screen","Source.Screen","fileSource","Source.File"],"mappings":";;;AAMA,MAAMA,IAAW,CAAC,OAAO,QAAQ,QAAQ,SAAS,aAAa,QAAQ,GAQjEC,IAAU,IAAI,qBAA6B,CAACC,MAAYA,EAAQ,OAAO;AAE7E,MAAqBC,UAAmB,YAAY;AAAA,EACnD,OAAO,qBAAqBH;AAAA,EAE5B,MAAM,IAAII,EAAwB,MAAS;AAAA,EAC3C,OAAO,IAAIA,EAAmC,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IAAI,CAACI,MAAW;AAC5B,cAAMO,IAASP,EAAO,IAAIiB,EAAO,MAAM;AACvC,QAAKV,MAELP,EAAO,IAAI,KAAK,UAAU,MAAM,QAAQO,EAAO,KAAK,GACpDP,EAAO,IAAI,KAAK,UAAU,MAAM,QAAQO,EAAO,KAAK;AAAA,MACrD,CAAC,GAEDP,EAAO,IAAI,KAAK,OAAOiB,CAAM,GAC7BjB,EAAO,IAAI,KAAK,OAAOiB,CAAM,GAE7BjB,EAAO,QAAQ,MAAM;AACpB,QAAAiB,EAAO,MAAA;AAAA,MACR,CAAC;AAED;AAAA,IACD;AAEA,QAAIV,MAAW,UAAUA,aAAkB,MAAM;AAChD,YAAMY,IAAa,IAAIC,EAAY;AAAA;AAAA;AAAA,QAGlC,MAAMb,aAAkB,OAAOA,IAAS;AAAA,QACxC,SAAS,KAAKX;AAAA,MAAA,CACd;AAED,WAAK,QAAQ,IAAI,CAACI,MAAW;AAC5B,cAAMO,IAASP,EAAO,IAAImB,EAAW,MAAM;AAC3C,aAAK,UAAU,MAAM,OAAO,IAAIZ,EAAO,KAAK,GAC5C,KAAK,UAAU,MAAM,OAAO,IAAIA,EAAO,KAAK;AAAA,MAC7C,CAAC,GAEDP,EAAO,QAAQ,MAAM;AACpB,QAAAmB,EAAW,MAAA;AAAA,MACZ,CAAC;AAED;AAAA,IACD;AAEA,UAAMP,IAAoBL;AAC1B,UAAM,IAAI,MAAM,mBAAmBK,CAAU,EAAE;AAAA,EAChD;AACD;AAEA,eAAe,OAAO,eAAerB,CAAU;"}
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as e, C as o, D as a, F as r, M as t, S as s } from "./screen-
|
|
2
|
-
import { B as u, i as p, a as _, P as b, u as S, b as f } from "./screen-
|
|
1
|
+
import { E as e, C as o, D as a, F as r, M as t, S as s } from "./screen-Dz_GBTAe.js";
|
|
2
|
+
import { B as u, i as p, a as _, P as b, u as S, b as f } from "./screen-Dz_GBTAe.js";
|
|
3
3
|
const n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4
4
|
__proto__: null,
|
|
5
5
|
Encoder: e
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moq/publish",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "Publish media to Media over QUIC streams",
|
|
6
6
|
"license": "(MIT OR Apache-2.0)",
|
|
7
7
|
"repository": "github:moq-dev/moq",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"./support/element.js"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@moq/hang": "^0.
|
|
36
|
+
"@moq/hang": "^0.2.0",
|
|
37
37
|
"@moq/lite": "^0.1.3",
|
|
38
|
-
"@moq/signals": "^0.1.
|
|
38
|
+
"@moq/signals": "^0.1.3",
|
|
39
39
|
"@moq/ui-core": "^0.1.0"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -3469,6 +3469,9 @@ var Effect = class _Effect {
|
|
|
3469
3469
|
this.#scheduled = false;
|
|
3470
3470
|
if (this.#fn) {
|
|
3471
3471
|
this.#fn(this);
|
|
3472
|
+
if (DEV && this.#unwatch.length === 0) {
|
|
3473
|
+
console.warn("Effect did not subscribe to any signals; it will never rerun.", this.#stack);
|
|
3474
|
+
}
|
|
3472
3475
|
}
|
|
3473
3476
|
}
|
|
3474
3477
|
// Get the current value of a signal, monitoring it for changes (via ===) and rerunning on change.
|
|
@@ -3578,7 +3581,7 @@ var Effect = class _Effect {
|
|
|
3578
3581
|
this.cleanup(() => clearInterval(interval));
|
|
3579
3582
|
}
|
|
3580
3583
|
// Create a nested effect that can be rerun independently.
|
|
3581
|
-
|
|
3584
|
+
run(fn) {
|
|
3582
3585
|
if (this.#dispose === void 0) {
|
|
3583
3586
|
if (DEV) {
|
|
3584
3587
|
console.warn("Effect.nested called when closed, ignoring");
|
|
@@ -3588,6 +3591,10 @@ var Effect = class _Effect {
|
|
|
3588
3591
|
const effect = new _Effect(fn);
|
|
3589
3592
|
this.#dispose.push(() => effect.close());
|
|
3590
3593
|
}
|
|
3594
|
+
// Backwards compatibility with the old name.
|
|
3595
|
+
effect(fn) {
|
|
3596
|
+
return this.run(fn);
|
|
3597
|
+
}
|
|
3591
3598
|
// Get the values of multiple signals, returning undefined if any are falsy.
|
|
3592
3599
|
getAll(signals) {
|
|
3593
3600
|
const values = [];
|
|
@@ -3607,7 +3614,7 @@ var Effect = class _Effect {
|
|
|
3607
3614
|
fn(signal.peek());
|
|
3608
3615
|
return;
|
|
3609
3616
|
}
|
|
3610
|
-
this.
|
|
3617
|
+
this.run((effect) => {
|
|
3611
3618
|
const value = effect.get(signal);
|
|
3612
3619
|
fn(value);
|
|
3613
3620
|
});
|
|
@@ -5657,7 +5664,7 @@ let dn = class Bn {
|
|
|
5657
5664
|
active = new f(!1);
|
|
5658
5665
|
#s = new P();
|
|
5659
5666
|
constructor(n) {
|
|
5660
|
-
this.source = f.from(n?.source), this.enabled = f.from(n?.enabled ?? !1), this.muted = f.from(n?.muted ?? !1), this.volume = f.from(n?.volume ?? 1), this.maxLatency = n?.maxLatency ?? 100, this.#s.
|
|
5667
|
+
this.source = f.from(n?.source), this.enabled = f.from(n?.enabled ?? !1), this.muted = f.from(n?.muted ?? !1), this.volume = f.from(n?.volume ?? 1), this.maxLatency = n?.maxLatency ?? 100, this.#s.run(this.#o.bind(this)), this.#s.run(this.#i.bind(this)), this.#s.run(this.#a.bind(this)), this.#s.run(this.#c.bind(this));
|
|
5661
5668
|
}
|
|
5662
5669
|
#o(n) {
|
|
5663
5670
|
const t = n.getAll([this.enabled, this.source]);
|
|
@@ -5763,7 +5770,7 @@ class se {
|
|
|
5763
5770
|
catalog = new f(void 0);
|
|
5764
5771
|
#e = new P();
|
|
5765
5772
|
constructor(n) {
|
|
5766
|
-
this.enabled = f.from(n?.enabled ?? !1), this.latest = new f(""), this.#e.
|
|
5773
|
+
this.enabled = f.from(n?.enabled ?? !1), this.latest = new f(""), this.#e.run((t) => {
|
|
5767
5774
|
t.get(this.enabled) && t.set(this.catalog, { name: se.TRACK });
|
|
5768
5775
|
});
|
|
5769
5776
|
}
|
|
@@ -5785,7 +5792,7 @@ class oe {
|
|
|
5785
5792
|
catalog = new f(void 0);
|
|
5786
5793
|
#e = new P();
|
|
5787
5794
|
constructor(n) {
|
|
5788
|
-
this.enabled = f.from(n?.enabled ?? !1), this.active = new f(!1), this.#e.
|
|
5795
|
+
this.enabled = f.from(n?.enabled ?? !1), this.active = new f(!1), this.#e.run((t) => {
|
|
5789
5796
|
t.get(this.enabled) && t.set(this.catalog, { name: oe.TRACK });
|
|
5790
5797
|
});
|
|
5791
5798
|
}
|
|
@@ -5805,7 +5812,7 @@ let Gn = class {
|
|
|
5805
5812
|
catalog = this.#e;
|
|
5806
5813
|
#n = new P();
|
|
5807
5814
|
constructor(n) {
|
|
5808
|
-
this.message = new se(n?.message), this.typing = new oe(n?.typing), this.#n.
|
|
5815
|
+
this.message = new se(n?.message), this.typing = new oe(n?.typing), this.#n.run((t) => {
|
|
5809
5816
|
this.#e.set({
|
|
5810
5817
|
message: t.get(this.message.catalog),
|
|
5811
5818
|
typing: t.get(this.typing.catalog)
|
|
@@ -5834,7 +5841,7 @@ class ie {
|
|
|
5834
5841
|
catalog = new f(void 0);
|
|
5835
5842
|
signals = new P();
|
|
5836
5843
|
constructor(n) {
|
|
5837
|
-
this.enabled = f.from(n?.enabled ?? !1), this.positions = f.from(n?.positions ?? {}), this.signals.
|
|
5844
|
+
this.enabled = f.from(n?.enabled ?? !1), this.positions = f.from(n?.positions ?? {}), this.signals.run((t) => {
|
|
5838
5845
|
t.get(this.enabled) && t.set(this.catalog, { name: ie.TRACK });
|
|
5839
5846
|
});
|
|
5840
5847
|
}
|
|
@@ -5858,7 +5865,7 @@ class ae {
|
|
|
5858
5865
|
catalog = new f(void 0);
|
|
5859
5866
|
signals = new P();
|
|
5860
5867
|
constructor(n) {
|
|
5861
|
-
this.enabled = f.from(n?.enabled ?? !1), this.position = f.from(n?.position ?? void 0), this.handle = f.from(n?.handle ?? void 0), this.signals.
|
|
5868
|
+
this.enabled = f.from(n?.enabled ?? !1), this.position = f.from(n?.position ?? void 0), this.handle = f.from(n?.handle ?? void 0), this.signals.run((t) => {
|
|
5862
5869
|
t.get(this.enabled) && t.set(this.catalog, {
|
|
5863
5870
|
initial: this.position.peek(),
|
|
5864
5871
|
track: { name: ae.TRACK },
|
|
@@ -5882,7 +5889,7 @@ let Wn = class {
|
|
|
5882
5889
|
catalog = new f(void 0);
|
|
5883
5890
|
signals = new P();
|
|
5884
5891
|
constructor(n) {
|
|
5885
|
-
this.window = new ae(n?.window), this.peers = new ie(n?.peers), this.signals.
|
|
5892
|
+
this.window = new ae(n?.window), this.peers = new ie(n?.peers), this.signals.run(this.#e.bind(this));
|
|
5886
5893
|
}
|
|
5887
5894
|
#e(n) {
|
|
5888
5895
|
const t = n.get(this.window.catalog), r = n.get(this.peers.catalog);
|
|
@@ -5909,7 +5916,7 @@ class pe {
|
|
|
5909
5916
|
catalog = new f(void 0);
|
|
5910
5917
|
signals = new P();
|
|
5911
5918
|
constructor(n) {
|
|
5912
|
-
this.enabled = f.from(n?.enabled ?? !1), this.info = f.from(n?.info), this.signals.
|
|
5919
|
+
this.enabled = f.from(n?.enabled ?? !1), this.info = f.from(n?.info), this.signals.run((t) => {
|
|
5913
5920
|
t.get(this.enabled) && t.set(this.catalog, { name: pe.TRACK });
|
|
5914
5921
|
});
|
|
5915
5922
|
}
|
|
@@ -5932,7 +5939,7 @@ class Kn {
|
|
|
5932
5939
|
catalog = new f(void 0);
|
|
5933
5940
|
signals = new P();
|
|
5934
5941
|
constructor(n) {
|
|
5935
|
-
this.enabled = f.from(n?.enabled ?? !1), this.id = f.from(n?.id), this.name = f.from(n?.name), this.avatar = f.from(n?.avatar), this.color = f.from(n?.color), this.signals.
|
|
5942
|
+
this.enabled = f.from(n?.enabled ?? !1), this.id = f.from(n?.id), this.name = f.from(n?.name), this.avatar = f.from(n?.avatar), this.color = f.from(n?.color), this.signals.run((t) => {
|
|
5936
5943
|
t.get(this.enabled) && t.set(this.catalog, {
|
|
5937
5944
|
id: t.get(this.id),
|
|
5938
5945
|
name: t.get(this.name),
|
|
@@ -5965,7 +5972,7 @@ class Pe {
|
|
|
5965
5972
|
// True when the encoder is actively serving a track.
|
|
5966
5973
|
active = new f(!1);
|
|
5967
5974
|
constructor(n, t, r) {
|
|
5968
|
-
this.frame = n, this.source = t, this.enabled = f.from(r?.enabled ?? !1), this.config = f.from(r?.config), this.#n.
|
|
5975
|
+
this.frame = n, this.source = t, this.enabled = f.from(r?.enabled ?? !1), this.config = f.from(r?.config), this.#n.run(this.#s.bind(this)), this.#n.run(this.#o.bind(this)), this.#n.run(this.#i.bind(this));
|
|
5969
5976
|
}
|
|
5970
5977
|
serve(n, t) {
|
|
5971
5978
|
if (!t.get(this.enabled)) return;
|
|
@@ -5981,10 +5988,10 @@ class Pe {
|
|
|
5981
5988
|
r.close(o);
|
|
5982
5989
|
}
|
|
5983
5990
|
});
|
|
5984
|
-
t.cleanup(() => i.close()), t.
|
|
5991
|
+
t.cleanup(() => i.close()), t.run(() => {
|
|
5985
5992
|
const o = t.get(this.#r);
|
|
5986
5993
|
o && i.configure(o);
|
|
5987
|
-
}), t.
|
|
5994
|
+
}), t.run((o) => {
|
|
5988
5995
|
const a = o.get(this.frame);
|
|
5989
5996
|
if (!a || i.state !== "configured") return;
|
|
5990
5997
|
const c = this.config.peek()?.keyframeInterval ?? L.Milli.fromSecond(2), u = !s || s + L.Micro.fromMilli(c) <= a.timestamp;
|
|
@@ -6190,7 +6197,7 @@ class B {
|
|
|
6190
6197
|
flip = new f(!1);
|
|
6191
6198
|
signals = new P();
|
|
6192
6199
|
constructor(n) {
|
|
6193
|
-
this.source = f.from(n?.source), this.hd = new Pe(this.frame, this.source, n?.hd), this.sd = new Pe(this.frame, this.source, n?.sd), this.flip = f.from(n?.flip ?? !1), this.signals.
|
|
6200
|
+
this.source = f.from(n?.source), this.hd = new Pe(this.frame, this.source, n?.hd), this.sd = new Pe(this.frame, this.source, n?.sd), this.flip = f.from(n?.flip ?? !1), this.signals.run(this.#n.bind(this)), this.signals.run(this.#e.bind(this));
|
|
6194
6201
|
}
|
|
6195
6202
|
#e(n) {
|
|
6196
6203
|
const t = n.get(this.source);
|
|
@@ -6248,7 +6255,7 @@ class Xn {
|
|
|
6248
6255
|
user;
|
|
6249
6256
|
signals = new P();
|
|
6250
6257
|
constructor(n) {
|
|
6251
|
-
this.connection = f.from(n?.connection), this.enabled = f.from(n?.enabled ?? !1), this.path = f.from(n?.path), this.audio = new dn(n?.audio), this.video = new B(n?.video), this.location = new Wn(n?.location), this.chat = new Gn(n?.chat), this.preview = new pe(n?.preview), this.user = new Kn(n?.user), this.signals.
|
|
6258
|
+
this.connection = f.from(n?.connection), this.enabled = f.from(n?.enabled ?? !1), this.path = f.from(n?.path), this.audio = new dn(n?.audio), this.video = new B(n?.video), this.location = new Wn(n?.location), this.chat = new Gn(n?.chat), this.preview = new pe(n?.preview), this.user = new Kn(n?.user), this.signals.run(this.#e.bind(this));
|
|
6252
6259
|
}
|
|
6253
6260
|
#e(n) {
|
|
6254
6261
|
const t = n.getAll([this.enabled, this.connection]);
|
|
@@ -6262,7 +6269,7 @@ class Xn {
|
|
|
6262
6269
|
for (; ; ) {
|
|
6263
6270
|
const r = await n.requested();
|
|
6264
6271
|
if (!r) break;
|
|
6265
|
-
t.cleanup(() => r.track.close()), t.
|
|
6272
|
+
t.cleanup(() => r.track.close()), t.run((s) => {
|
|
6266
6273
|
if (!s.get(r.track.state.closed))
|
|
6267
6274
|
switch (r.track.name) {
|
|
6268
6275
|
case Xn.CATALOG_TRACK:
|
|
@@ -6337,9 +6344,9 @@ class Hn {
|
|
|
6337
6344
|
requested = this.#t;
|
|
6338
6345
|
signals = new P();
|
|
6339
6346
|
constructor(n, t) {
|
|
6340
|
-
this.kind = n, this.preferred = f.from(t?.preferred), this.signals.
|
|
6347
|
+
this.kind = n, this.preferred = f.from(t?.preferred), this.signals.run((r) => {
|
|
6341
6348
|
r.spawn(this.#r.bind(this, r)), r.event(navigator.mediaDevices, "devicechange", () => r.reload());
|
|
6342
|
-
}), this.signals.
|
|
6349
|
+
}), this.signals.run(this.#s.bind(this));
|
|
6343
6350
|
}
|
|
6344
6351
|
async #r(n) {
|
|
6345
6352
|
n.get(this.permission);
|
|
@@ -6391,7 +6398,7 @@ class ha {
|
|
|
6391
6398
|
source = new f(void 0);
|
|
6392
6399
|
signals = new P();
|
|
6393
6400
|
constructor(n) {
|
|
6394
|
-
this.device = new Hn("video", n?.device), this.enabled = f.from(n?.enabled ?? !1), this.constraints = f.from(n?.constraints), this.signals.
|
|
6401
|
+
this.device = new Hn("video", n?.device), this.enabled = f.from(n?.enabled ?? !1), this.constraints = f.from(n?.constraints), this.signals.run(this.#e.bind(this));
|
|
6395
6402
|
}
|
|
6396
6403
|
#e(n) {
|
|
6397
6404
|
if (!n.get(this.enabled)) return;
|
|
@@ -6428,7 +6435,7 @@ let fa = class {
|
|
|
6428
6435
|
source = new f({});
|
|
6429
6436
|
enabled;
|
|
6430
6437
|
constructor(n) {
|
|
6431
|
-
this.enabled = f.from(n.enabled ?? !1), this.file = f.from(n.file), this.signals.
|
|
6438
|
+
this.enabled = f.from(n.enabled ?? !1), this.file = f.from(n.file), this.signals.run((t) => {
|
|
6432
6439
|
const r = t.getAll([this.file, this.enabled]);
|
|
6433
6440
|
if (!r) return;
|
|
6434
6441
|
const [s] = r;
|
|
@@ -6493,7 +6500,7 @@ class ma {
|
|
|
6493
6500
|
source = new f(void 0);
|
|
6494
6501
|
signals = new P();
|
|
6495
6502
|
constructor(n) {
|
|
6496
|
-
this.device = new Hn("audio", n?.device), this.enabled = f.from(n?.enabled ?? !1), this.constraints = f.from(n?.constraints), this.signals.
|
|
6503
|
+
this.device = new Hn("audio", n?.device), this.enabled = f.from(n?.enabled ?? !1), this.constraints = f.from(n?.constraints), this.signals.run(this.#e.bind(this));
|
|
6497
6504
|
}
|
|
6498
6505
|
#e(n) {
|
|
6499
6506
|
if (!n.get(this.enabled)) return;
|
|
@@ -6531,7 +6538,7 @@ class wa {
|
|
|
6531
6538
|
source = new f(void 0);
|
|
6532
6539
|
signals = new P();
|
|
6533
6540
|
constructor(n) {
|
|
6534
|
-
this.enabled = f.from(n?.enabled ?? !1), this.video = f.from(n?.video), this.audio = f.from(n?.audio), this.signals.
|
|
6541
|
+
this.enabled = f.from(n?.enabled ?? !1), this.video = f.from(n?.video), this.audio = f.from(n?.audio), this.signals.run(this.#e.bind(this));
|
|
6535
6542
|
}
|
|
6536
6543
|
#e(n) {
|
|
6537
6544
|
if (!n.get(this.enabled)) return;
|
|
@@ -6576,4 +6583,4 @@ export {
|
|
|
6576
6583
|
aa as i,
|
|
6577
6584
|
da as u
|
|
6578
6585
|
};
|
|
6579
|
-
//# sourceMappingURL=screen-
|
|
6586
|
+
//# sourceMappingURL=screen-Dz_GBTAe.js.map
|