@camstack/addon-benchmark 0.1.14 → 0.1.15
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/{__mfe_internal__addon_benchmark_page__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.mjs-CCBTZBOa.mjs → __mfe_internal__addon_benchmark_page__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.mjs-h5aXOPSA.mjs} +1 -1
- package/dist/__mfe_internal__addon_benchmark_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-BDmWQEu5.mjs +16 -0
- package/dist/{__mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.mjs-D0mCkXl6.mjs → __mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.mjs-DrODo4jp.mjs} +8 -8
- package/dist/{__mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.mjs_commonjs-proxy-Y5C1IdnH.mjs → __mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.mjs_commonjs-proxy-JW-pexXa.mjs} +1 -1
- package/dist/{__mfe_internal__addon_benchmark_page__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-DHyNsEqy.mjs → __mfe_internal__addon_benchmark_page__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-B7BvuptH.mjs} +1 -1
- package/dist/_stub.js +8176 -3997
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_benchmark_page-Cc3NF30a.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_benchmark_page-BeLfGVa1.mjs} +10 -11
- package/dist/addon-benchmark.css +1 -1
- package/dist/{client-CcDLM_13.mjs → client-DFXd_CTL.mjs} +2 -2
- package/dist/{hostInit-CAVqKr6S.mjs → hostInit-CVXvnQQ4.mjs} +12 -12
- package/dist/{index-DaSo_2kE.mjs → index-B3DDm3f_.mjs} +1 -1
- package/dist/index-B9MIeX8E.mjs +1617 -0
- package/dist/index-BHDPHRYK.mjs +19109 -0
- package/dist/{index-DnFVXz0U.mjs → index-CRN37Hr9.mjs} +12367 -11334
- package/dist/{index-Dh5vmX_b.mjs → index-CwX5nq5R.mjs} +1 -1
- package/dist/{index-BJiPhUp0.mjs → index-DIVnrURN.mjs} +1 -1
- package/dist/{index-DDFHp1Wk.mjs → index-DqipDAUg.mjs} +1 -1
- package/dist/{jsx-runtime-Dnzp-FK_.mjs → jsx-runtime-BblBcpPM.mjs} +1 -1
- package/dist/remoteEntry.js +2933 -45
- package/package.json +6 -2
- package/dist/__mfe_internal__addon_benchmark_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-DqxRPOgh.mjs +0 -16
- package/dist/index-BumDn7Si.mjs +0 -3402
- package/dist/index-C3iAUQqS.mjs +0 -533
- package/dist/index-CMtMiC4k.mjs +0 -2464
- package/dist/index-CWhCtlI6.mjs +0 -14567
- package/dist/index-D0dNM7_R.mjs +0 -2892
|
@@ -0,0 +1,1617 @@
|
|
|
1
|
+
import { i as _e, b as x, A as be, n as ve } from "./__mfe_internal__addon_benchmark_page__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-jq0dGk3x.mjs";
|
|
2
|
+
import { b as V, c as Ee } from "./__mfe_internal__addon_benchmark_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-BDmWQEu5.mjs";
|
|
3
|
+
class Pe {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.keyToValue = /* @__PURE__ */ new Map(), this.valueToKey = /* @__PURE__ */ new Map();
|
|
6
|
+
}
|
|
7
|
+
set(t, r) {
|
|
8
|
+
this.keyToValue.set(t, r), this.valueToKey.set(r, t);
|
|
9
|
+
}
|
|
10
|
+
getByKey(t) {
|
|
11
|
+
return this.keyToValue.get(t);
|
|
12
|
+
}
|
|
13
|
+
getByValue(t) {
|
|
14
|
+
return this.valueToKey.get(t);
|
|
15
|
+
}
|
|
16
|
+
clear() {
|
|
17
|
+
this.keyToValue.clear(), this.valueToKey.clear();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
class q {
|
|
21
|
+
constructor(t) {
|
|
22
|
+
this.generateIdentifier = t, this.kv = new Pe();
|
|
23
|
+
}
|
|
24
|
+
register(t, r) {
|
|
25
|
+
this.kv.getByValue(t) || (r || (r = this.generateIdentifier(t)), this.kv.set(r, t));
|
|
26
|
+
}
|
|
27
|
+
clear() {
|
|
28
|
+
this.kv.clear();
|
|
29
|
+
}
|
|
30
|
+
getIdentifier(t) {
|
|
31
|
+
return this.kv.getByValue(t);
|
|
32
|
+
}
|
|
33
|
+
getValue(t) {
|
|
34
|
+
return this.kv.getByKey(t);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
class Ce extends q {
|
|
38
|
+
constructor() {
|
|
39
|
+
super((t) => t.name), this.classToAllowedProps = /* @__PURE__ */ new Map();
|
|
40
|
+
}
|
|
41
|
+
register(t, r) {
|
|
42
|
+
typeof r == "object" ? (r.allowProps && this.classToAllowedProps.set(t, r.allowProps), super.register(t, r.identifier)) : super.register(t, r);
|
|
43
|
+
}
|
|
44
|
+
getAllowedProps(t) {
|
|
45
|
+
return this.classToAllowedProps.get(t);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function ke(e) {
|
|
49
|
+
if ("values" in Object)
|
|
50
|
+
return Object.values(e);
|
|
51
|
+
const t = [];
|
|
52
|
+
for (const r in e)
|
|
53
|
+
e.hasOwnProperty(r) && t.push(e[r]);
|
|
54
|
+
return t;
|
|
55
|
+
}
|
|
56
|
+
function Se(e, t) {
|
|
57
|
+
const r = ke(e);
|
|
58
|
+
if ("find" in r)
|
|
59
|
+
return r.find(t);
|
|
60
|
+
const s = r;
|
|
61
|
+
for (let n = 0; n < s.length; n++) {
|
|
62
|
+
const i = s[n];
|
|
63
|
+
if (t(i))
|
|
64
|
+
return i;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function v(e, t) {
|
|
68
|
+
Object.entries(e).forEach(([r, s]) => t(s, r));
|
|
69
|
+
}
|
|
70
|
+
function S(e, t) {
|
|
71
|
+
return e.indexOf(t) !== -1;
|
|
72
|
+
}
|
|
73
|
+
function B(e, t) {
|
|
74
|
+
for (let r = 0; r < e.length; r++) {
|
|
75
|
+
const s = e[r];
|
|
76
|
+
if (t(s))
|
|
77
|
+
return s;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
class Re {
|
|
81
|
+
constructor() {
|
|
82
|
+
this.transfomers = {};
|
|
83
|
+
}
|
|
84
|
+
register(t) {
|
|
85
|
+
this.transfomers[t.name] = t;
|
|
86
|
+
}
|
|
87
|
+
findApplicable(t) {
|
|
88
|
+
return Se(this.transfomers, (r) => r.isApplicable(t));
|
|
89
|
+
}
|
|
90
|
+
findByName(t) {
|
|
91
|
+
return this.transfomers[t];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const Ie = (e) => Object.prototype.toString.call(e).slice(8, -1), W = (e) => typeof e > "u", Te = (e) => e === null, P = (e) => typeof e != "object" || e === null || e === Object.prototype ? !1 : Object.getPrototypeOf(e) === null ? !0 : Object.getPrototypeOf(e) === Object.prototype, T = (e) => P(e) && Object.keys(e).length === 0, g = (e) => Array.isArray(e), Ae = (e) => typeof e == "string", Me = (e) => typeof e == "number" && !isNaN(e), Oe = (e) => typeof e == "boolean", De = (e) => e instanceof RegExp, C = (e) => e instanceof Map, k = (e) => e instanceof Set, K = (e) => Ie(e) === "Symbol", Le = (e) => e instanceof Date && !isNaN(e.valueOf()), Y = (e) => e instanceof Error, U = (e) => typeof e == "number" && isNaN(e), Ne = (e) => Oe(e) || Te(e) || W(e) || Me(e) || Ae(e) || K(e), xe = (e) => typeof e == "bigint", Ve = (e) => e === 1 / 0 || e === -1 / 0, Be = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView), Ue = (e) => e instanceof URL, A = (e) => e.replace(/\\/g, "\\\\").replace(/\./g, "\\."), I = (e) => e.map(String).map(A).join("."), E = (e, t) => {
|
|
95
|
+
const r = [];
|
|
96
|
+
let s = "";
|
|
97
|
+
for (let i = 0; i < e.length; i++) {
|
|
98
|
+
let o = e.charAt(i);
|
|
99
|
+
if (!t && o === "\\") {
|
|
100
|
+
const f = e.charAt(i + 1);
|
|
101
|
+
if (f === "\\") {
|
|
102
|
+
s += "\\", i++;
|
|
103
|
+
continue;
|
|
104
|
+
} else if (f !== ".")
|
|
105
|
+
throw Error("invalid path");
|
|
106
|
+
}
|
|
107
|
+
if (o === "\\" && e.charAt(i + 1) === ".") {
|
|
108
|
+
s += ".", i++;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (o === ".") {
|
|
112
|
+
r.push(s), s = "";
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
s += o;
|
|
116
|
+
}
|
|
117
|
+
const n = s;
|
|
118
|
+
return r.push(n), r;
|
|
119
|
+
};
|
|
120
|
+
function y(e, t, r, s) {
|
|
121
|
+
return {
|
|
122
|
+
isApplicable: e,
|
|
123
|
+
annotation: t,
|
|
124
|
+
transform: r,
|
|
125
|
+
untransform: s
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const G = [
|
|
129
|
+
y(W, "undefined", () => null, () => {
|
|
130
|
+
}),
|
|
131
|
+
y(xe, "bigint", (e) => e.toString(), (e) => typeof BigInt < "u" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
|
|
132
|
+
y(Le, "Date", (e) => e.toISOString(), (e) => new Date(e)),
|
|
133
|
+
y(Y, "Error", (e, t) => {
|
|
134
|
+
const r = {
|
|
135
|
+
name: e.name,
|
|
136
|
+
message: e.message
|
|
137
|
+
};
|
|
138
|
+
return "cause" in e && (r.cause = e.cause), t.allowedErrorProps.forEach((s) => {
|
|
139
|
+
r[s] = e[s];
|
|
140
|
+
}), r;
|
|
141
|
+
}, (e, t) => {
|
|
142
|
+
const r = new Error(e.message, { cause: e.cause });
|
|
143
|
+
return r.name = e.name, r.stack = e.stack, t.allowedErrorProps.forEach((s) => {
|
|
144
|
+
r[s] = e[s];
|
|
145
|
+
}), r;
|
|
146
|
+
}),
|
|
147
|
+
y(De, "regexp", (e) => "" + e, (e) => {
|
|
148
|
+
const t = e.slice(1, e.lastIndexOf("/")), r = e.slice(e.lastIndexOf("/") + 1);
|
|
149
|
+
return new RegExp(t, r);
|
|
150
|
+
}),
|
|
151
|
+
y(
|
|
152
|
+
k,
|
|
153
|
+
"set",
|
|
154
|
+
// (sets only exist in es6+)
|
|
155
|
+
// eslint-disable-next-line es5/no-es6-methods
|
|
156
|
+
(e) => [...e.values()],
|
|
157
|
+
(e) => new Set(e)
|
|
158
|
+
),
|
|
159
|
+
y(C, "map", (e) => [...e.entries()], (e) => new Map(e)),
|
|
160
|
+
y((e) => U(e) || Ve(e), "number", (e) => U(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
|
|
161
|
+
y((e) => e === 0 && 1 / e === -1 / 0, "number", () => "-0", Number),
|
|
162
|
+
y(Ue, "URL", (e) => e.toString(), (e) => new URL(e))
|
|
163
|
+
];
|
|
164
|
+
function R(e, t, r, s) {
|
|
165
|
+
return {
|
|
166
|
+
isApplicable: e,
|
|
167
|
+
annotation: t,
|
|
168
|
+
transform: r,
|
|
169
|
+
untransform: s
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const H = R((e, t) => K(e) ? !!t.symbolRegistry.getIdentifier(e) : !1, (e, t) => ["symbol", t.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, t, r) => {
|
|
173
|
+
const s = r.symbolRegistry.getValue(t[1]);
|
|
174
|
+
if (!s)
|
|
175
|
+
throw new Error("Trying to deserialize unknown symbol");
|
|
176
|
+
return s;
|
|
177
|
+
}), ze = [
|
|
178
|
+
Int8Array,
|
|
179
|
+
Uint8Array,
|
|
180
|
+
Int16Array,
|
|
181
|
+
Uint16Array,
|
|
182
|
+
Int32Array,
|
|
183
|
+
Uint32Array,
|
|
184
|
+
Float32Array,
|
|
185
|
+
Float64Array,
|
|
186
|
+
Uint8ClampedArray
|
|
187
|
+
].reduce((e, t) => (e[t.name] = t, e), {}), X = R(Be, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, t) => {
|
|
188
|
+
const r = ze[t[1]];
|
|
189
|
+
if (!r)
|
|
190
|
+
throw new Error("Trying to deserialize unknown typed array");
|
|
191
|
+
return new r(e);
|
|
192
|
+
});
|
|
193
|
+
function Z(e, t) {
|
|
194
|
+
return e?.constructor ? !!t.classRegistry.getIdentifier(e.constructor) : !1;
|
|
195
|
+
}
|
|
196
|
+
const Q = R(Z, (e, t) => ["class", t.classRegistry.getIdentifier(e.constructor)], (e, t) => {
|
|
197
|
+
const r = t.classRegistry.getAllowedProps(e.constructor);
|
|
198
|
+
if (!r)
|
|
199
|
+
return { ...e };
|
|
200
|
+
const s = {};
|
|
201
|
+
return r.forEach((n) => {
|
|
202
|
+
s[n] = e[n];
|
|
203
|
+
}), s;
|
|
204
|
+
}, (e, t, r) => {
|
|
205
|
+
const s = r.classRegistry.getValue(t[1]);
|
|
206
|
+
if (!s)
|
|
207
|
+
throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
|
|
208
|
+
return Object.assign(Object.create(s.prototype), e);
|
|
209
|
+
}), j = R((e, t) => !!t.customTransformerRegistry.findApplicable(e), (e, t) => ["custom", t.customTransformerRegistry.findApplicable(e).name], (e, t) => t.customTransformerRegistry.findApplicable(e).serialize(e), (e, t, r) => {
|
|
210
|
+
const s = r.customTransformerRegistry.findByName(t[1]);
|
|
211
|
+
if (!s)
|
|
212
|
+
throw new Error("Trying to deserialize unknown custom value");
|
|
213
|
+
return s.deserialize(e);
|
|
214
|
+
}), Fe = [Q, H, j, X], z = (e, t) => {
|
|
215
|
+
const r = B(Fe, (n) => n.isApplicable(e, t));
|
|
216
|
+
if (r)
|
|
217
|
+
return {
|
|
218
|
+
value: r.transform(e, t),
|
|
219
|
+
type: r.annotation(e, t)
|
|
220
|
+
};
|
|
221
|
+
const s = B(G, (n) => n.isApplicable(e, t));
|
|
222
|
+
if (s)
|
|
223
|
+
return {
|
|
224
|
+
value: s.transform(e, t),
|
|
225
|
+
type: s.annotation
|
|
226
|
+
};
|
|
227
|
+
}, J = {};
|
|
228
|
+
G.forEach((e) => {
|
|
229
|
+
J[e.annotation] = e;
|
|
230
|
+
});
|
|
231
|
+
const $e = (e, t, r) => {
|
|
232
|
+
if (g(t))
|
|
233
|
+
switch (t[0]) {
|
|
234
|
+
case "symbol":
|
|
235
|
+
return H.untransform(e, t, r);
|
|
236
|
+
case "class":
|
|
237
|
+
return Q.untransform(e, t, r);
|
|
238
|
+
case "custom":
|
|
239
|
+
return j.untransform(e, t, r);
|
|
240
|
+
case "typed-array":
|
|
241
|
+
return X.untransform(e, t, r);
|
|
242
|
+
default:
|
|
243
|
+
throw new Error("Unknown transformation: " + t);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
const s = J[t];
|
|
247
|
+
if (!s)
|
|
248
|
+
throw new Error("Unknown transformation: " + t);
|
|
249
|
+
return s.untransform(e, r);
|
|
250
|
+
}
|
|
251
|
+
}, b = (e, t) => {
|
|
252
|
+
if (t > e.size)
|
|
253
|
+
throw new Error("index out of bounds");
|
|
254
|
+
const r = e.keys();
|
|
255
|
+
for (; t > 0; )
|
|
256
|
+
r.next(), t--;
|
|
257
|
+
return r.next().value;
|
|
258
|
+
};
|
|
259
|
+
function ee(e) {
|
|
260
|
+
if (S(e, "__proto__"))
|
|
261
|
+
throw new Error("__proto__ is not allowed as a property");
|
|
262
|
+
if (S(e, "prototype"))
|
|
263
|
+
throw new Error("prototype is not allowed as a property");
|
|
264
|
+
if (S(e, "constructor"))
|
|
265
|
+
throw new Error("constructor is not allowed as a property");
|
|
266
|
+
}
|
|
267
|
+
const qe = (e, t) => {
|
|
268
|
+
ee(t);
|
|
269
|
+
for (let r = 0; r < t.length; r++) {
|
|
270
|
+
const s = t[r];
|
|
271
|
+
if (k(e))
|
|
272
|
+
e = b(e, +s);
|
|
273
|
+
else if (C(e)) {
|
|
274
|
+
const n = +s, i = +t[++r] == 0 ? "key" : "value", o = b(e, n);
|
|
275
|
+
switch (i) {
|
|
276
|
+
case "key":
|
|
277
|
+
e = o;
|
|
278
|
+
break;
|
|
279
|
+
case "value":
|
|
280
|
+
e = e.get(o);
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
} else
|
|
284
|
+
e = e[s];
|
|
285
|
+
}
|
|
286
|
+
return e;
|
|
287
|
+
}, M = (e, t, r) => {
|
|
288
|
+
if (ee(t), t.length === 0)
|
|
289
|
+
return r(e);
|
|
290
|
+
let s = e;
|
|
291
|
+
for (let i = 0; i < t.length - 1; i++) {
|
|
292
|
+
const o = t[i];
|
|
293
|
+
if (g(s)) {
|
|
294
|
+
const a = +o;
|
|
295
|
+
s = s[a];
|
|
296
|
+
} else if (P(s))
|
|
297
|
+
s = s[o];
|
|
298
|
+
else if (k(s)) {
|
|
299
|
+
const a = +o;
|
|
300
|
+
s = b(s, a);
|
|
301
|
+
} else if (C(s)) {
|
|
302
|
+
if (i === t.length - 2)
|
|
303
|
+
break;
|
|
304
|
+
const c = +o, f = +t[++i] == 0 ? "key" : "value", h = b(s, c);
|
|
305
|
+
switch (f) {
|
|
306
|
+
case "key":
|
|
307
|
+
s = h;
|
|
308
|
+
break;
|
|
309
|
+
case "value":
|
|
310
|
+
s = s.get(h);
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const n = t[t.length - 1];
|
|
316
|
+
if (g(s) ? s[+n] = r(s[+n]) : P(s) && (s[n] = r(s[n])), k(s)) {
|
|
317
|
+
const i = b(s, +n), o = r(i);
|
|
318
|
+
i !== o && (s.delete(i), s.add(o));
|
|
319
|
+
}
|
|
320
|
+
if (C(s)) {
|
|
321
|
+
const i = +t[t.length - 2], o = b(s, i);
|
|
322
|
+
switch (+n == 0 ? "key" : "value") {
|
|
323
|
+
case "key": {
|
|
324
|
+
const c = r(o);
|
|
325
|
+
s.set(c, s.get(o)), c !== o && s.delete(o);
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case "value": {
|
|
329
|
+
s.set(o, r(s.get(o)));
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return e;
|
|
335
|
+
}, te = (e) => e < 1;
|
|
336
|
+
function O(e, t, r, s = []) {
|
|
337
|
+
if (!e)
|
|
338
|
+
return;
|
|
339
|
+
const n = te(r);
|
|
340
|
+
if (!g(e)) {
|
|
341
|
+
v(e, (a, c) => O(a, t, r, [
|
|
342
|
+
...s,
|
|
343
|
+
...E(c, n)
|
|
344
|
+
]));
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const [i, o] = e;
|
|
348
|
+
o && v(o, (a, c) => {
|
|
349
|
+
O(a, t, r, [
|
|
350
|
+
...s,
|
|
351
|
+
...E(c, n)
|
|
352
|
+
]);
|
|
353
|
+
}), t(i, s);
|
|
354
|
+
}
|
|
355
|
+
function We(e, t, r, s) {
|
|
356
|
+
return O(t, (n, i) => {
|
|
357
|
+
e = M(e, i, (o) => $e(o, n, s));
|
|
358
|
+
}, r), e;
|
|
359
|
+
}
|
|
360
|
+
function Ke(e, t, r) {
|
|
361
|
+
const s = te(r);
|
|
362
|
+
function n(i, o) {
|
|
363
|
+
const a = qe(e, E(o, s));
|
|
364
|
+
i.map((c) => E(c, s)).forEach((c) => {
|
|
365
|
+
e = M(e, c, () => a);
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (g(t)) {
|
|
369
|
+
const [i, o] = t;
|
|
370
|
+
i.forEach((a) => {
|
|
371
|
+
e = M(e, E(a, s), () => e);
|
|
372
|
+
}), o && v(o, n);
|
|
373
|
+
} else
|
|
374
|
+
v(t, n);
|
|
375
|
+
return e;
|
|
376
|
+
}
|
|
377
|
+
const Ye = (e, t) => P(e) || g(e) || C(e) || k(e) || Y(e) || Z(e, t);
|
|
378
|
+
function Ge(e, t, r) {
|
|
379
|
+
const s = r.get(e);
|
|
380
|
+
s ? s.push(t) : r.set(e, [t]);
|
|
381
|
+
}
|
|
382
|
+
function He(e, t) {
|
|
383
|
+
const r = {};
|
|
384
|
+
let s;
|
|
385
|
+
return e.forEach((n) => {
|
|
386
|
+
if (n.length <= 1)
|
|
387
|
+
return;
|
|
388
|
+
t || (n = n.map((a) => a.map(String)).sort((a, c) => a.length - c.length));
|
|
389
|
+
const [i, ...o] = n;
|
|
390
|
+
i.length === 0 ? s = o.map(I) : r[I(i)] = o.map(I);
|
|
391
|
+
}), s ? T(r) ? [s] : [s, r] : T(r) ? void 0 : r;
|
|
392
|
+
}
|
|
393
|
+
const re = (e, t, r, s, n = [], i = [], o = /* @__PURE__ */ new Map()) => {
|
|
394
|
+
const a = Ne(e);
|
|
395
|
+
if (!a) {
|
|
396
|
+
Ge(e, n, t);
|
|
397
|
+
const u = o.get(e);
|
|
398
|
+
if (u)
|
|
399
|
+
return s ? {
|
|
400
|
+
transformedValue: null
|
|
401
|
+
} : u;
|
|
402
|
+
}
|
|
403
|
+
if (!Ye(e, r)) {
|
|
404
|
+
const u = z(e, r), m = u ? {
|
|
405
|
+
transformedValue: u.value,
|
|
406
|
+
annotations: [u.type]
|
|
407
|
+
} : {
|
|
408
|
+
transformedValue: e
|
|
409
|
+
};
|
|
410
|
+
return a || o.set(e, m), m;
|
|
411
|
+
}
|
|
412
|
+
if (S(i, e))
|
|
413
|
+
return {
|
|
414
|
+
transformedValue: null
|
|
415
|
+
};
|
|
416
|
+
const c = z(e, r), f = c?.value ?? e, h = g(f) ? [] : {}, p = {};
|
|
417
|
+
v(f, (u, m) => {
|
|
418
|
+
if (m === "__proto__" || m === "constructor" || m === "prototype")
|
|
419
|
+
throw new Error(`Detected property ${m}. This is a prototype pollution risk, please remove it from your object.`);
|
|
420
|
+
const _ = re(u, t, r, s, [...n, m], [...i, e], o);
|
|
421
|
+
h[m] = _.transformedValue, g(_.annotations) ? p[A(m)] = _.annotations : P(_.annotations) && v(_.annotations, (w, we) => {
|
|
422
|
+
p[A(m) + "." + we] = w;
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
const d = T(p) ? {
|
|
426
|
+
transformedValue: h,
|
|
427
|
+
annotations: c ? [c.type] : void 0
|
|
428
|
+
} : {
|
|
429
|
+
transformedValue: h,
|
|
430
|
+
annotations: c ? [c.type, p] : p
|
|
431
|
+
};
|
|
432
|
+
return a || o.set(e, d), d;
|
|
433
|
+
};
|
|
434
|
+
function se(e) {
|
|
435
|
+
return Object.prototype.toString.call(e).slice(8, -1);
|
|
436
|
+
}
|
|
437
|
+
function F(e) {
|
|
438
|
+
return se(e) === "Array";
|
|
439
|
+
}
|
|
440
|
+
function Xe(e) {
|
|
441
|
+
if (se(e) !== "Object")
|
|
442
|
+
return !1;
|
|
443
|
+
const t = Object.getPrototypeOf(e);
|
|
444
|
+
return !!t && t.constructor === Object && t === Object.prototype;
|
|
445
|
+
}
|
|
446
|
+
function Ze(e, t, r, s, n) {
|
|
447
|
+
const i = {}.propertyIsEnumerable.call(s, t) ? "enumerable" : "nonenumerable";
|
|
448
|
+
i === "enumerable" && (e[t] = r), n && i === "nonenumerable" && Object.defineProperty(e, t, {
|
|
449
|
+
value: r,
|
|
450
|
+
enumerable: !1,
|
|
451
|
+
writable: !0,
|
|
452
|
+
configurable: !0
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
function D(e, t = {}) {
|
|
456
|
+
if (F(e))
|
|
457
|
+
return e.map((n) => D(n, t));
|
|
458
|
+
if (!Xe(e))
|
|
459
|
+
return e;
|
|
460
|
+
const r = Object.getOwnPropertyNames(e), s = Object.getOwnPropertySymbols(e);
|
|
461
|
+
return [...r, ...s].reduce((n, i) => {
|
|
462
|
+
if (i === "__proto__" || F(t.props) && !t.props.includes(i))
|
|
463
|
+
return n;
|
|
464
|
+
const o = e[i], a = D(o, t);
|
|
465
|
+
return Ze(n, i, a, e, t.nonenumerable), n;
|
|
466
|
+
}, {});
|
|
467
|
+
}
|
|
468
|
+
class l {
|
|
469
|
+
/**
|
|
470
|
+
* @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
|
|
471
|
+
*/
|
|
472
|
+
constructor({ dedupe: t = !1 } = {}) {
|
|
473
|
+
this.classRegistry = new Ce(), this.symbolRegistry = new q((r) => r.description ?? ""), this.customTransformerRegistry = new Re(), this.allowedErrorProps = [], this.dedupe = t;
|
|
474
|
+
}
|
|
475
|
+
serialize(t) {
|
|
476
|
+
const r = /* @__PURE__ */ new Map(), s = re(t, r, this, this.dedupe), n = {
|
|
477
|
+
json: s.transformedValue
|
|
478
|
+
};
|
|
479
|
+
s.annotations && (n.meta = {
|
|
480
|
+
...n.meta,
|
|
481
|
+
values: s.annotations
|
|
482
|
+
});
|
|
483
|
+
const i = He(r, this.dedupe);
|
|
484
|
+
return i && (n.meta = {
|
|
485
|
+
...n.meta,
|
|
486
|
+
referentialEqualities: i
|
|
487
|
+
}), n.meta && (n.meta.v = 1), n;
|
|
488
|
+
}
|
|
489
|
+
deserialize(t, r) {
|
|
490
|
+
const { json: s, meta: n } = t;
|
|
491
|
+
let i = r?.inPlace ? s : D(s);
|
|
492
|
+
return n?.values && (i = We(i, n.values, n.v ?? 0, this)), n?.referentialEqualities && (i = Ke(i, n.referentialEqualities, n.v ?? 0)), i;
|
|
493
|
+
}
|
|
494
|
+
stringify(t) {
|
|
495
|
+
return JSON.stringify(this.serialize(t));
|
|
496
|
+
}
|
|
497
|
+
parse(t) {
|
|
498
|
+
return this.deserialize(JSON.parse(t), { inPlace: !0 });
|
|
499
|
+
}
|
|
500
|
+
registerClass(t, r) {
|
|
501
|
+
this.classRegistry.register(t, r);
|
|
502
|
+
}
|
|
503
|
+
registerSymbol(t, r) {
|
|
504
|
+
this.symbolRegistry.register(t, r);
|
|
505
|
+
}
|
|
506
|
+
registerCustom(t, r) {
|
|
507
|
+
this.customTransformerRegistry.register({
|
|
508
|
+
name: r,
|
|
509
|
+
...t
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
allowErrorProps(...t) {
|
|
513
|
+
this.allowedErrorProps.push(...t);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
l.defaultInstance = new l();
|
|
517
|
+
l.serialize = l.defaultInstance.serialize.bind(l.defaultInstance);
|
|
518
|
+
l.deserialize = l.defaultInstance.deserialize.bind(l.defaultInstance);
|
|
519
|
+
l.stringify = l.defaultInstance.stringify.bind(l.defaultInstance);
|
|
520
|
+
l.parse = l.defaultInstance.parse.bind(l.defaultInstance);
|
|
521
|
+
l.registerClass = l.defaultInstance.registerClass.bind(l.defaultInstance);
|
|
522
|
+
l.registerSymbol = l.defaultInstance.registerSymbol.bind(l.defaultInstance);
|
|
523
|
+
l.registerCustom = l.defaultInstance.registerCustom.bind(l.defaultInstance);
|
|
524
|
+
l.allowErrorProps = l.defaultInstance.allowErrorProps.bind(l.defaultInstance);
|
|
525
|
+
l.serialize;
|
|
526
|
+
l.deserialize;
|
|
527
|
+
l.stringify;
|
|
528
|
+
l.parse;
|
|
529
|
+
l.registerClass;
|
|
530
|
+
l.registerCustom;
|
|
531
|
+
l.registerSymbol;
|
|
532
|
+
l.allowErrorProps;
|
|
533
|
+
const Qe = 1e4, je = 3e3, Je = 2e3, et = 3e4;
|
|
534
|
+
class tt {
|
|
535
|
+
/** Active server base URL. Mutable via `switchServerUrl()` so the
|
|
536
|
+
* endpoint-race helper can pivot the transport onto a LAN candidate
|
|
537
|
+
* after the initial public-URL bootstrap. */
|
|
538
|
+
_serverUrl;
|
|
539
|
+
useWs;
|
|
540
|
+
baseRetryMs;
|
|
541
|
+
maxRetryMs;
|
|
542
|
+
onConnectionChange;
|
|
543
|
+
token;
|
|
544
|
+
_trpcClient;
|
|
545
|
+
_wsClient = null;
|
|
546
|
+
// Mirror — owns binding cache + state mirror + lifecycle listeners.
|
|
547
|
+
// Lazily initialised on `init()`. Subsequent `reconnect()` disposes
|
|
548
|
+
// the old mirror and rebuilds against the new tRPC client.
|
|
549
|
+
mirror = null;
|
|
550
|
+
mirrorInit = null;
|
|
551
|
+
// Transport-readiness probe state. `connected` flips true the first
|
|
552
|
+
// time `auth.me` succeeds against the current tRPC client; resets
|
|
553
|
+
// on every `reconnect()` / `close()` so the next consumer waits for
|
|
554
|
+
// a fresh handshake before issuing queries.
|
|
555
|
+
connected = !1;
|
|
556
|
+
connectedPromise = null;
|
|
557
|
+
// System-cap namespaces — populated in the constructor from
|
|
558
|
+
// `createSystemProxy(api)`. Each namespace is a `Pick<InferProvider<typeof cap>, …>`
|
|
559
|
+
// shape generated by `scripts/generate-system-proxy.ts`.
|
|
560
|
+
_systemProxy;
|
|
561
|
+
// Connection-version + listener bookkeeping for the admin UI's
|
|
562
|
+
// reconnect watchdog.
|
|
563
|
+
_connectionVersion = 0;
|
|
564
|
+
connectionListeners = /* @__PURE__ */ new Set();
|
|
565
|
+
constructor(t) {
|
|
566
|
+
this._serverUrl = t.serverUrl.replace(/\/+$/, ""), this.token = t.token;
|
|
567
|
+
const r = typeof window < "u";
|
|
568
|
+
this.useWs = t.useWebSocket ?? r, this.onConnectionChange = t.onConnectionChange, this.baseRetryMs = t.retryDelayMs ?? Je, this.maxRetryMs = t.maxRetryDelayMs ?? et, this._trpcClient = this.buildTrpcClient(), this._systemProxy = V(this._trpcClient);
|
|
569
|
+
}
|
|
570
|
+
// ── Connection state ─────────────────────────────────────────────
|
|
571
|
+
/** Active server base URL (no trailing slash). */
|
|
572
|
+
get serverUrl() {
|
|
573
|
+
return this._serverUrl;
|
|
574
|
+
}
|
|
575
|
+
get connectionVersion() {
|
|
576
|
+
return this._connectionVersion;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Subscribe to connection-state transitions. Called with `('connected'
|
|
580
|
+
* | 'disconnected' | 'connecting', version)` whenever the SDK opens,
|
|
581
|
+
* closes, or starts a manual reconnect. Listener errors are swallowed
|
|
582
|
+
* so a misbehaving consumer cannot break the SDK's event loop.
|
|
583
|
+
*/
|
|
584
|
+
subscribeConnectionEvents(t) {
|
|
585
|
+
return this.connectionListeners.add(t), () => {
|
|
586
|
+
this.connectionListeners.delete(t);
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
emitConnectionEvent(t) {
|
|
590
|
+
try {
|
|
591
|
+
this.onConnectionChange?.(t);
|
|
592
|
+
} catch {
|
|
593
|
+
}
|
|
594
|
+
for (const r of this.connectionListeners)
|
|
595
|
+
try {
|
|
596
|
+
r(t, this._connectionVersion);
|
|
597
|
+
} catch {
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
// ── Lifecycle ────────────────────────────────────────────────────
|
|
601
|
+
/**
|
|
602
|
+
* Wait until the underlying tRPC transport is connected AND the
|
|
603
|
+
* server has responded to a cheap auth round-trip (`auth.me`). This
|
|
604
|
+
* is the canonical "ready to issue queries" gate.
|
|
605
|
+
*
|
|
606
|
+
* Why a probe, not just `ws.readyState === OPEN`?
|
|
607
|
+
* The WS handshake completes asynchronously: tRPC's `wsLink`
|
|
608
|
+
* queues outgoing messages and only flushes them after `open()`
|
|
609
|
+
* resolves (post `connectionParams` send). On the server, the
|
|
610
|
+
* tRPC context is created lazily once the connectionParams
|
|
611
|
+
* message is received. A query fired between WS-open and
|
|
612
|
+
* connection-params-processed is technically queued by tRPC, but
|
|
613
|
+
* the auth context for that query is only resolved once the
|
|
614
|
+
* handshake message is decoded server-side. A probe round-trip is
|
|
615
|
+
* the safest way to confirm both sides have agreed on the auth
|
|
616
|
+
* identity before the React tree starts firing parallel queries
|
|
617
|
+
* (which can otherwise land before any addon-side service
|
|
618
|
+
* discovery has settled, returning empty results that get cached).
|
|
619
|
+
*
|
|
620
|
+
* Idempotent — concurrent callers await the same in-flight Promise.
|
|
621
|
+
* Bounded by `timeoutMs` (default 15s) — beyond which a
|
|
622
|
+
* `Error('System.awaitConnected: probe timed out after Xms')` is
|
|
623
|
+
* thrown so the host can render a clear error state instead of
|
|
624
|
+
* hanging on a bricked socket.
|
|
625
|
+
*/
|
|
626
|
+
async awaitConnected(t) {
|
|
627
|
+
if (this.connected) return;
|
|
628
|
+
if (this.connectedPromise) return this.connectedPromise;
|
|
629
|
+
const r = t ?? 15e3;
|
|
630
|
+
this.connectedPromise = (async () => {
|
|
631
|
+
const s = this._trpcClient.auth.me.query();
|
|
632
|
+
Number.isFinite(r) ? await new Promise((n, i) => {
|
|
633
|
+
const o = setTimeout(
|
|
634
|
+
() => i(new Error(`System.awaitConnected: probe timed out after ${r}ms`)),
|
|
635
|
+
r
|
|
636
|
+
);
|
|
637
|
+
s.then(
|
|
638
|
+
() => {
|
|
639
|
+
clearTimeout(o), n();
|
|
640
|
+
},
|
|
641
|
+
(a) => {
|
|
642
|
+
clearTimeout(o), i(a instanceof Error ? a : new Error(String(a)));
|
|
643
|
+
}
|
|
644
|
+
);
|
|
645
|
+
}) : await s, this.connected = !0;
|
|
646
|
+
})();
|
|
647
|
+
try {
|
|
648
|
+
await this.connectedPromise;
|
|
649
|
+
} finally {
|
|
650
|
+
this.connectedPromise = null;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Warm-boot the device mirror. Awaits the transport probe first
|
|
655
|
+
* (`awaitConnected`) so the three mirror round-trips
|
|
656
|
+
* (`getAllBindings` + `getAllSnapshots` + `listAll`) cannot race
|
|
657
|
+
* against the WS auth handshake. Subsequent `getDevice(id)` calls
|
|
658
|
+
* are sync; live `device.*` event subscriptions keep the caches
|
|
659
|
+
* fresh.
|
|
660
|
+
*
|
|
661
|
+
* Idempotent — concurrent callers await the same in-flight Promise.
|
|
662
|
+
*/
|
|
663
|
+
async init(t) {
|
|
664
|
+
if (this.mirror?.isReady()) return;
|
|
665
|
+
if (this.mirrorInit) return this.mirrorInit;
|
|
666
|
+
const r = new Ee(this._trpcClient);
|
|
667
|
+
return this.mirror = r, this.mirrorInit = (async () => {
|
|
668
|
+
await this.awaitConnected(t), await r.init(t);
|
|
669
|
+
})().finally(() => {
|
|
670
|
+
this.mirrorInit = null;
|
|
671
|
+
}), this.mirrorInit;
|
|
672
|
+
}
|
|
673
|
+
/** Promise that resolves once `init()` has completed. */
|
|
674
|
+
async awaitReady() {
|
|
675
|
+
if (!this.mirror?.isReady())
|
|
676
|
+
return this.mirrorInit ? this.mirrorInit : this.init();
|
|
677
|
+
}
|
|
678
|
+
/** True after `init()` resolves. */
|
|
679
|
+
isReady() {
|
|
680
|
+
return this.mirror?.isReady() ?? !1;
|
|
681
|
+
}
|
|
682
|
+
/** True after the transport probe has succeeded at least once. */
|
|
683
|
+
isConnected() {
|
|
684
|
+
return this.connected;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Force a fresh WebSocket handshake. Tears down the wsClient + tRPC
|
|
688
|
+
* client + mirror (the mirror captures the tRPC reference at
|
|
689
|
+
* construction time and would otherwise dispatch through a closed
|
|
690
|
+
* client) and rebuilds them. No-op for HTTP transport.
|
|
691
|
+
*/
|
|
692
|
+
reconnect() {
|
|
693
|
+
this.useWs && (this.emitConnectionEvent("connecting"), this._wsClient?.close(), this.disposeMirror(), this.connected = !1, this.connectedPromise = null, this._trpcClient = this.buildTrpcClient(), this._systemProxy = V(this._trpcClient));
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Pivot the underlying tRPC transport onto a different base URL.
|
|
697
|
+
* Used by the endpoint-race flow: the SDK opens against the public
|
|
698
|
+
* URL the operator provided, calls `localNetwork.getConnectionEndpoints`
|
|
699
|
+
* to discover LAN candidates, races them, and (when a faster one wins)
|
|
700
|
+
* calls `switchServerUrl(winner)` to migrate every subsequent query
|
|
701
|
+
* onto the LAN path without losing auth state.
|
|
702
|
+
*
|
|
703
|
+
* Keeps the auth token. Tears down the WS + mirror and rebuilds them
|
|
704
|
+
* against the new URL — same machinery as `reconnect()` but with a
|
|
705
|
+
* different target.
|
|
706
|
+
*/
|
|
707
|
+
switchServerUrl(t) {
|
|
708
|
+
const r = t.replace(/\/+$/, "");
|
|
709
|
+
r !== this._serverUrl && (this._serverUrl = r, this.reconnect());
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Race the candidate base URLs reported by the hub's `local-network`
|
|
713
|
+
* cap, pick the fastest one that responds, and (if it's different
|
|
714
|
+
* from the current URL) pivot the transport onto it.
|
|
715
|
+
*
|
|
716
|
+
* Flow:
|
|
717
|
+
* 1. Query `localNetwork.getConnectionEndpoints({ port })` over the
|
|
718
|
+
* already-authenticated tRPC channel — the cap is auth-gated,
|
|
719
|
+
* so the LAN IPs never leak to anonymous callers.
|
|
720
|
+
* 2. For each candidate, fire a HEAD on `{baseUrl}/trpc/health`
|
|
721
|
+
* with a short timeout (default 1500ms). The first 2xx wins.
|
|
722
|
+
* 3. If the winner differs from `this.serverUrl`, call
|
|
723
|
+
* `switchServerUrl(winner)` and return it. Otherwise return
|
|
724
|
+
* the current URL unchanged.
|
|
725
|
+
*
|
|
726
|
+
* Bounded — if every candidate times out we keep the current URL.
|
|
727
|
+
* Idempotent — safe to call on every connect / reconnect / network
|
|
728
|
+
* change event.
|
|
729
|
+
*/
|
|
730
|
+
async raceConnectionEndpoints(t) {
|
|
731
|
+
const r = t?.perCandidateTimeoutMs ?? 1500, s = (() => {
|
|
732
|
+
try {
|
|
733
|
+
return new URL(this._serverUrl);
|
|
734
|
+
} catch {
|
|
735
|
+
return null;
|
|
736
|
+
}
|
|
737
|
+
})(), n = s?.port ? Number(s.port) : s?.protocol === "https:" ? 443 : 80, i = s?.protocol === "https:" ? "https" : "http", a = this._trpcClient.localNetwork?.getConnectionEndpoints;
|
|
738
|
+
if (!a)
|
|
739
|
+
return { winner: this._serverUrl, switched: !1 };
|
|
740
|
+
let c = [];
|
|
741
|
+
try {
|
|
742
|
+
c = (await a.query({ port: n, ipv4Only: t?.ipv4Only, scheme: i })).endpoints;
|
|
743
|
+
} catch {
|
|
744
|
+
return { winner: this._serverUrl, switched: !1 };
|
|
745
|
+
}
|
|
746
|
+
if (c.length === 0)
|
|
747
|
+
return { winner: this._serverUrl, switched: !1 };
|
|
748
|
+
const f = await rt(c.map((h) => h.baseUrl), r);
|
|
749
|
+
return !f || f === this._serverUrl ? { winner: f ?? this._serverUrl, switched: !1 } : (this.switchServerUrl(f), { winner: f, switched: !0 });
|
|
750
|
+
}
|
|
751
|
+
/** Tear down WS connection + mirror. The instance is unusable afterwards. */
|
|
752
|
+
close() {
|
|
753
|
+
this.disposeMirror(), this.connected = !1, this.connectedPromise = null, this._wsClient?.close();
|
|
754
|
+
}
|
|
755
|
+
disposeMirror() {
|
|
756
|
+
this.mirror?.dispose(), this.mirror = null, this.mirrorInit = null;
|
|
757
|
+
}
|
|
758
|
+
// ── Auth ──────────────────────────────────────────────────────────
|
|
759
|
+
async login(t, r) {
|
|
760
|
+
const s = await this._trpcClient.auth.login.mutate({ username: t, password: r });
|
|
761
|
+
if (typeof s == "object" && s !== null && "token" in s) {
|
|
762
|
+
const n = s.token;
|
|
763
|
+
typeof n == "string" && this.setToken(n);
|
|
764
|
+
}
|
|
765
|
+
return s;
|
|
766
|
+
}
|
|
767
|
+
async logout() {
|
|
768
|
+
await this._trpcClient.auth.logout.mutate();
|
|
769
|
+
}
|
|
770
|
+
async getMe() {
|
|
771
|
+
return await this._trpcClient.auth.me.query();
|
|
772
|
+
}
|
|
773
|
+
/** Update the auth token (e.g. after login or token refresh). */
|
|
774
|
+
setToken(t) {
|
|
775
|
+
this.token = t;
|
|
776
|
+
}
|
|
777
|
+
// ── Devices ──────────────────────────────────────────────────────
|
|
778
|
+
/**
|
|
779
|
+
* Synchronous snapshot of every device matching the optional filters.
|
|
780
|
+
* Backed by the `SystemMirror` warm-boot cache — call `init()` first
|
|
781
|
+
* (or `awaitReady()`) before invoking. Returns an empty array if the
|
|
782
|
+
* mirror has not yet been booted.
|
|
783
|
+
*
|
|
784
|
+
* Each returned proxy has `binding` populated from the mirror's
|
|
785
|
+
* binding cache (Phase 5 dedup), so consumers no longer need to
|
|
786
|
+
* make a separate `deviceManager.getBindings` round-trip.
|
|
787
|
+
*/
|
|
788
|
+
listDevices(t) {
|
|
789
|
+
return this.mirror ? (t ? this.mirror.query(t) : this.mirror.getAllDevices()).map((s) => this.attachBinding(s)) : [];
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Sync lookup by numeric id. `null` if the mirror has not been booted
|
|
793
|
+
* or the device is unknown.
|
|
794
|
+
*/
|
|
795
|
+
getDevice(t) {
|
|
796
|
+
const r = this.mirror?.getDeviceById(t) ?? null;
|
|
797
|
+
return r ? this.attachBinding(r) : null;
|
|
798
|
+
}
|
|
799
|
+
/** Sync lookup by display name (exact match). */
|
|
800
|
+
getDeviceByName(t) {
|
|
801
|
+
const r = this.mirror?.getDeviceByName(t) ?? null;
|
|
802
|
+
return r ? this.attachBinding(r) : null;
|
|
803
|
+
}
|
|
804
|
+
/** Sync lookup by stableId. */
|
|
805
|
+
getDeviceByStableId(t) {
|
|
806
|
+
const r = this.mirror?.getDeviceByStableId(t) ?? null;
|
|
807
|
+
return r ? this.attachBinding(r) : null;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Resolve when a device with `deviceId` becomes available. Resolves
|
|
811
|
+
* immediately if already known; rejects with a timeout error
|
|
812
|
+
* otherwise (default 30s).
|
|
813
|
+
*/
|
|
814
|
+
async waitForDevice(t, r) {
|
|
815
|
+
this.mirror || await this.init();
|
|
816
|
+
const s = await this.mirror.waitForDevice(t, r ?? 3e4);
|
|
817
|
+
return this.attachBinding(s);
|
|
818
|
+
}
|
|
819
|
+
/** Subscribe to `device.registered` events. */
|
|
820
|
+
onDeviceAdded(t) {
|
|
821
|
+
if (!this.mirror)
|
|
822
|
+
throw new Error("System.onDeviceAdded: call init() before subscribing");
|
|
823
|
+
return this.mirror.onDeviceAdded(t);
|
|
824
|
+
}
|
|
825
|
+
/** Subscribe to `device.unregistered` events. */
|
|
826
|
+
onDeviceRemoved(t) {
|
|
827
|
+
if (!this.mirror)
|
|
828
|
+
throw new Error("System.onDeviceRemoved: call init() before subscribing");
|
|
829
|
+
return this.mirror.onDeviceRemoved(t);
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Patch the proxy's `binding` field from the mirror's cache. The
|
|
833
|
+
* generated `createDeviceProxy()` already sets `binding` to the
|
|
834
|
+
* binding it was constructed with — this is a defensive overwrite
|
|
835
|
+
* that uses the latest cached entry in case a `binding-changed`
|
|
836
|
+
* event landed between proxy creation and access.
|
|
837
|
+
*/
|
|
838
|
+
attachBinding(t) {
|
|
839
|
+
const r = this.lookupBinding(t.deviceId);
|
|
840
|
+
if (r === t.binding) return t;
|
|
841
|
+
const s = t;
|
|
842
|
+
return s.binding = r, t;
|
|
843
|
+
}
|
|
844
|
+
/** Fetch the latest cached binding from the mirror, or `null`. */
|
|
845
|
+
lookupBinding(t) {
|
|
846
|
+
return this.mirror ? this.mirror.getDeviceById(t)?.binding ?? null : null;
|
|
847
|
+
}
|
|
848
|
+
// ── System caps ──────────────────────────────────────────────────
|
|
849
|
+
//
|
|
850
|
+
// One getter per `scope: 'system'` capability. The actual surface
|
|
851
|
+
// comes from `createSystemProxy(api)` (codegen). Adding a new
|
|
852
|
+
// system cap regenerates the proxy and the new namespace surfaces
|
|
853
|
+
// automatically via `system.<newCap>.<method>(input)`.
|
|
854
|
+
get addonPages() {
|
|
855
|
+
return this._systemProxy.addonPages;
|
|
856
|
+
}
|
|
857
|
+
get addonSettings() {
|
|
858
|
+
return this._systemProxy.addonSettings;
|
|
859
|
+
}
|
|
860
|
+
get alerts() {
|
|
861
|
+
return this._systemProxy.alerts;
|
|
862
|
+
}
|
|
863
|
+
get audioAnalyzer() {
|
|
864
|
+
return this._systemProxy.audioAnalyzer;
|
|
865
|
+
}
|
|
866
|
+
get audioCodec() {
|
|
867
|
+
return this._systemProxy.audioCodec;
|
|
868
|
+
}
|
|
869
|
+
get backup() {
|
|
870
|
+
return this._systemProxy.backup;
|
|
871
|
+
}
|
|
872
|
+
get decoder() {
|
|
873
|
+
return this._systemProxy.decoder;
|
|
874
|
+
}
|
|
875
|
+
get deviceManager() {
|
|
876
|
+
return this._systemProxy.deviceManager;
|
|
877
|
+
}
|
|
878
|
+
get deviceProvider() {
|
|
879
|
+
return this._systemProxy.deviceProvider;
|
|
880
|
+
}
|
|
881
|
+
get deviceState() {
|
|
882
|
+
return this._systemProxy.deviceState;
|
|
883
|
+
}
|
|
884
|
+
get metricsProvider() {
|
|
885
|
+
return this._systemProxy.metricsProvider;
|
|
886
|
+
}
|
|
887
|
+
get notificationOutput() {
|
|
888
|
+
return this._systemProxy.notificationOutput;
|
|
889
|
+
}
|
|
890
|
+
get pipelineExecutor() {
|
|
891
|
+
return this._systemProxy.pipelineExecutor;
|
|
892
|
+
}
|
|
893
|
+
get pipelineOrchestrator() {
|
|
894
|
+
return this._systemProxy.pipelineOrchestrator;
|
|
895
|
+
}
|
|
896
|
+
get pipelineRunner() {
|
|
897
|
+
return this._systemProxy.pipelineRunner;
|
|
898
|
+
}
|
|
899
|
+
get platformProbe() {
|
|
900
|
+
return this._systemProxy.platformProbe;
|
|
901
|
+
}
|
|
902
|
+
get recordingEngine() {
|
|
903
|
+
return this._systemProxy.recordingEngine;
|
|
904
|
+
}
|
|
905
|
+
get settingsStore() {
|
|
906
|
+
return this._systemProxy.settingsStore;
|
|
907
|
+
}
|
|
908
|
+
get storage() {
|
|
909
|
+
return this._systemProxy.storage;
|
|
910
|
+
}
|
|
911
|
+
get streamBroker() {
|
|
912
|
+
return this._systemProxy.streamBroker;
|
|
913
|
+
}
|
|
914
|
+
get turnProvider() {
|
|
915
|
+
return this._systemProxy.turnProvider;
|
|
916
|
+
}
|
|
917
|
+
get userManagement() {
|
|
918
|
+
return this._systemProxy.userManagement;
|
|
919
|
+
}
|
|
920
|
+
// ── Live events ──────────────────────────────────────────────────
|
|
921
|
+
/**
|
|
922
|
+
* Subscribe to a single event category. Returns an unsubscribe
|
|
923
|
+
* handle. Errors thrown by the listener are swallowed so a single
|
|
924
|
+
* misbehaving consumer cannot tear down the WS subscription.
|
|
925
|
+
*
|
|
926
|
+
* Categories should be values from the `EventCategory` enum
|
|
927
|
+
* (`@camstack/types`) — passing a raw string works for forward-compat
|
|
928
|
+
* but loses type safety. The SDK forwards the value verbatim to the
|
|
929
|
+
* server's `live.onEvent` subscription.
|
|
930
|
+
*/
|
|
931
|
+
subscribeEvent(t, r) {
|
|
932
|
+
const s = this._trpcClient.live.onEvent.subscribe(
|
|
933
|
+
{ category: t },
|
|
934
|
+
{
|
|
935
|
+
onData: (n) => {
|
|
936
|
+
try {
|
|
937
|
+
r(n);
|
|
938
|
+
} catch {
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
);
|
|
943
|
+
return () => {
|
|
944
|
+
try {
|
|
945
|
+
s.unsubscribe();
|
|
946
|
+
} catch {
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
// ── Escape hatches ───────────────────────────────────────────────
|
|
951
|
+
//
|
|
952
|
+
// Kept public so the ui-library `<TrpcProvider>` can seed React
|
|
953
|
+
// Query with the same WebSocket connection during Phase 2. Phase 4
|
|
954
|
+
// is expected to revisit whether either field can be hidden.
|
|
955
|
+
/** Direct tRPC client. Read once per call; rebuilt on `reconnect()`. */
|
|
956
|
+
get trpcClient() {
|
|
957
|
+
return this._trpcClient;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Underlying WSClient (or `null` for HTTP transport). Used by
|
|
961
|
+
* advanced consumers that need direct access to the WebSocket
|
|
962
|
+
* (e.g. for keep-alive metrics). Rebuilt on `reconnect()`.
|
|
963
|
+
*/
|
|
964
|
+
get wsClient() {
|
|
965
|
+
return this._wsClient;
|
|
966
|
+
}
|
|
967
|
+
// ── Internals ────────────────────────────────────────────────────
|
|
968
|
+
buildTrpcClient() {
|
|
969
|
+
const t = () => {
|
|
970
|
+
const r = {};
|
|
971
|
+
return this.token && (r.Authorization = `Bearer ${this.token}`), r;
|
|
972
|
+
};
|
|
973
|
+
if (this.useWs) {
|
|
974
|
+
const r = this._serverUrl.replace(/^http/, "ws") + "/trpc", s = this.baseRetryMs, n = this.maxRetryMs;
|
|
975
|
+
return this._wsClient = _e({
|
|
976
|
+
url: r,
|
|
977
|
+
connectionParams: () => ({ token: this.token }),
|
|
978
|
+
retryDelayMs: (i) => Math.min(s * Math.pow(2, i), n),
|
|
979
|
+
keepAlive: {
|
|
980
|
+
enabled: !0,
|
|
981
|
+
intervalMs: Qe,
|
|
982
|
+
pongTimeoutMs: je
|
|
983
|
+
},
|
|
984
|
+
onOpen: () => {
|
|
985
|
+
this._connectionVersion += 1, this.emitConnectionEvent("connected");
|
|
986
|
+
},
|
|
987
|
+
onClose: () => {
|
|
988
|
+
this.emitConnectionEvent("disconnected");
|
|
989
|
+
}
|
|
990
|
+
}), x({
|
|
991
|
+
links: [be({ client: this._wsClient, transformer: l })]
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
return this._wsClient = null, x({
|
|
995
|
+
links: [ve({ url: `${this._serverUrl}/trpc`, headers: t, transformer: l })]
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
function ft(e) {
|
|
1000
|
+
return new tt(e);
|
|
1001
|
+
}
|
|
1002
|
+
async function rt(e, t) {
|
|
1003
|
+
if (e.length === 0) return null;
|
|
1004
|
+
if (typeof fetch != "function") return e[0] ?? null;
|
|
1005
|
+
const s = typeof window < "u" && typeof window.location < "u" && window.location.protocol === "https:" ? e.filter((o) => o.toLowerCase().startsWith("https://")) : e;
|
|
1006
|
+
if (s.length === 0) return null;
|
|
1007
|
+
const n = s.map(() => new AbortController()), i = s.map(async (o, a) => {
|
|
1008
|
+
const c = n[a], f = setTimeout(() => c.abort(), t);
|
|
1009
|
+
try {
|
|
1010
|
+
const h = await fetch(`${o.replace(/\/+$/, "")}/trpc/health`, {
|
|
1011
|
+
method: "GET",
|
|
1012
|
+
signal: c.signal,
|
|
1013
|
+
// Cross-origin probes from a browser sandbox are fine — the
|
|
1014
|
+
// /trpc/health response is open-CORS by the Fastify default.
|
|
1015
|
+
// No credentials needed (this is a transport-quality probe,
|
|
1016
|
+
// not an auth round-trip).
|
|
1017
|
+
credentials: "omit"
|
|
1018
|
+
});
|
|
1019
|
+
if (!h.ok) throw new Error(`${h.status}`);
|
|
1020
|
+
return o;
|
|
1021
|
+
} finally {
|
|
1022
|
+
clearTimeout(f);
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
try {
|
|
1026
|
+
const o = await Promise.any(i);
|
|
1027
|
+
for (const a of n)
|
|
1028
|
+
try {
|
|
1029
|
+
a.abort();
|
|
1030
|
+
} catch {
|
|
1031
|
+
}
|
|
1032
|
+
return o;
|
|
1033
|
+
} catch {
|
|
1034
|
+
return null;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
var ne = /* @__PURE__ */ ((e) => (e.Motion = "motion", e.Person = "person", e.Vehicle = "vehicle", e.Animal = "animal", e.Audio = "audio", e.Face = "face", e.Plate = "plate", e.Package = "package", e.Doorbell = "doorbell", e.Sensor = "sensor", e))(ne || {});
|
|
1038
|
+
const ie = [
|
|
1039
|
+
"animal",
|
|
1040
|
+
"dog_cat",
|
|
1041
|
+
"dog",
|
|
1042
|
+
"cat",
|
|
1043
|
+
"horse",
|
|
1044
|
+
"sheep",
|
|
1045
|
+
"cow",
|
|
1046
|
+
"elephant",
|
|
1047
|
+
"bear",
|
|
1048
|
+
"zebra",
|
|
1049
|
+
"giraffe",
|
|
1050
|
+
"mouse",
|
|
1051
|
+
"rabbit",
|
|
1052
|
+
"deer",
|
|
1053
|
+
"lion",
|
|
1054
|
+
"tiger",
|
|
1055
|
+
"bird",
|
|
1056
|
+
"eagle",
|
|
1057
|
+
"owl",
|
|
1058
|
+
"pigeon",
|
|
1059
|
+
"fish",
|
|
1060
|
+
"whale",
|
|
1061
|
+
"dolphin",
|
|
1062
|
+
"snake",
|
|
1063
|
+
"turtle",
|
|
1064
|
+
"lizard"
|
|
1065
|
+
], oe = [
|
|
1066
|
+
"person",
|
|
1067
|
+
"people",
|
|
1068
|
+
"pedestrian",
|
|
1069
|
+
"rider",
|
|
1070
|
+
"driver",
|
|
1071
|
+
"cyclist",
|
|
1072
|
+
"skier",
|
|
1073
|
+
"skateboarder",
|
|
1074
|
+
"face",
|
|
1075
|
+
"hand",
|
|
1076
|
+
"head",
|
|
1077
|
+
"body"
|
|
1078
|
+
], ae = [
|
|
1079
|
+
"vehicle",
|
|
1080
|
+
"car",
|
|
1081
|
+
"truck",
|
|
1082
|
+
"bus",
|
|
1083
|
+
"motorcycle",
|
|
1084
|
+
"bicycle",
|
|
1085
|
+
"van",
|
|
1086
|
+
"ambulance",
|
|
1087
|
+
"police_car",
|
|
1088
|
+
"fire_truck",
|
|
1089
|
+
"train",
|
|
1090
|
+
"subway",
|
|
1091
|
+
"tram",
|
|
1092
|
+
"airplane",
|
|
1093
|
+
"boat",
|
|
1094
|
+
"ship",
|
|
1095
|
+
"helicopter"
|
|
1096
|
+
], le = [
|
|
1097
|
+
"face",
|
|
1098
|
+
"eyes",
|
|
1099
|
+
"nose",
|
|
1100
|
+
"mouth",
|
|
1101
|
+
"ears",
|
|
1102
|
+
"eyebrows",
|
|
1103
|
+
"left_eye",
|
|
1104
|
+
"right_eye",
|
|
1105
|
+
"pupil",
|
|
1106
|
+
"iris",
|
|
1107
|
+
"eyelid",
|
|
1108
|
+
"eye_corner",
|
|
1109
|
+
"upper_lip",
|
|
1110
|
+
"lower_lip",
|
|
1111
|
+
"teeth",
|
|
1112
|
+
"chin",
|
|
1113
|
+
"cheek",
|
|
1114
|
+
"forehead",
|
|
1115
|
+
"jaw",
|
|
1116
|
+
"glasses",
|
|
1117
|
+
"sunglasses",
|
|
1118
|
+
"facial_hair",
|
|
1119
|
+
"beard",
|
|
1120
|
+
"mustache",
|
|
1121
|
+
"facial_landmark",
|
|
1122
|
+
"facial_keypoint"
|
|
1123
|
+
], ce = [
|
|
1124
|
+
"plate",
|
|
1125
|
+
"license_plate",
|
|
1126
|
+
"front_plate",
|
|
1127
|
+
"rear_plate",
|
|
1128
|
+
"motorcycle_plate",
|
|
1129
|
+
"temporary_plate",
|
|
1130
|
+
"dealer_plate",
|
|
1131
|
+
"licensePlate",
|
|
1132
|
+
"plate_number",
|
|
1133
|
+
"plate_character",
|
|
1134
|
+
"plate_digit",
|
|
1135
|
+
"plate_letter",
|
|
1136
|
+
"plate_symbol",
|
|
1137
|
+
"plate_region",
|
|
1138
|
+
"plate_country_identifier",
|
|
1139
|
+
"plate_frame",
|
|
1140
|
+
"plate_bolt",
|
|
1141
|
+
"plate_sticker",
|
|
1142
|
+
"plate_validation_tag",
|
|
1143
|
+
"damaged_plate",
|
|
1144
|
+
"obscured_plate",
|
|
1145
|
+
"dirty_plate"
|
|
1146
|
+
], ue = ["motion", "movement", "other"], de = ["package", "packet"], fe = [
|
|
1147
|
+
"audio"
|
|
1148
|
+
/* Audio */
|
|
1149
|
+
], me = [
|
|
1150
|
+
"speech",
|
|
1151
|
+
"scream",
|
|
1152
|
+
"babbling",
|
|
1153
|
+
"yell",
|
|
1154
|
+
"bellow",
|
|
1155
|
+
"whoop",
|
|
1156
|
+
"whispering",
|
|
1157
|
+
"laughter",
|
|
1158
|
+
"snicker",
|
|
1159
|
+
"crying",
|
|
1160
|
+
"cry",
|
|
1161
|
+
"sigh",
|
|
1162
|
+
"singing",
|
|
1163
|
+
"choir",
|
|
1164
|
+
"chant",
|
|
1165
|
+
"mantra",
|
|
1166
|
+
"child_singing",
|
|
1167
|
+
"rapping",
|
|
1168
|
+
"humming",
|
|
1169
|
+
"groan",
|
|
1170
|
+
"grunt",
|
|
1171
|
+
"whistling",
|
|
1172
|
+
"breathing",
|
|
1173
|
+
"wheeze",
|
|
1174
|
+
"snoring",
|
|
1175
|
+
"gasp",
|
|
1176
|
+
"pant",
|
|
1177
|
+
"snort",
|
|
1178
|
+
"cough",
|
|
1179
|
+
"throat_clearing",
|
|
1180
|
+
"sneeze",
|
|
1181
|
+
"sniff",
|
|
1182
|
+
"cheering",
|
|
1183
|
+
"applause",
|
|
1184
|
+
"chatter",
|
|
1185
|
+
"crowd",
|
|
1186
|
+
"children_playing",
|
|
1187
|
+
"bark",
|
|
1188
|
+
"yip",
|
|
1189
|
+
"howl",
|
|
1190
|
+
"bow-wow",
|
|
1191
|
+
"growling",
|
|
1192
|
+
"whimper_dog",
|
|
1193
|
+
"purr",
|
|
1194
|
+
"meow",
|
|
1195
|
+
"hiss",
|
|
1196
|
+
"caterwaul",
|
|
1197
|
+
"pets",
|
|
1198
|
+
"livestock",
|
|
1199
|
+
"doorbell",
|
|
1200
|
+
"ding-dong",
|
|
1201
|
+
"door",
|
|
1202
|
+
"slam",
|
|
1203
|
+
"knock",
|
|
1204
|
+
"alarm",
|
|
1205
|
+
"telephone",
|
|
1206
|
+
"music",
|
|
1207
|
+
"dog",
|
|
1208
|
+
"dogs"
|
|
1209
|
+
], he = ["doorbell", "ring"], pe = [
|
|
1210
|
+
"lock",
|
|
1211
|
+
"binary",
|
|
1212
|
+
"flood",
|
|
1213
|
+
"entry",
|
|
1214
|
+
"door",
|
|
1215
|
+
"leak",
|
|
1216
|
+
"door_open",
|
|
1217
|
+
"flooded",
|
|
1218
|
+
"entry_open"
|
|
1219
|
+
], ye = {
|
|
1220
|
+
...ie.reduce((e, t) => ({
|
|
1221
|
+
...e,
|
|
1222
|
+
[t]: "animal"
|
|
1223
|
+
/* Animal */
|
|
1224
|
+
}), {}),
|
|
1225
|
+
...oe.reduce((e, t) => ({
|
|
1226
|
+
...e,
|
|
1227
|
+
[t]: "person"
|
|
1228
|
+
/* Person */
|
|
1229
|
+
}), {}),
|
|
1230
|
+
...ae.reduce((e, t) => ({
|
|
1231
|
+
...e,
|
|
1232
|
+
[t]: "vehicle"
|
|
1233
|
+
/* Vehicle */
|
|
1234
|
+
}), {}),
|
|
1235
|
+
...ue.reduce((e, t) => ({
|
|
1236
|
+
...e,
|
|
1237
|
+
[t]: "motion"
|
|
1238
|
+
/* Motion */
|
|
1239
|
+
}), {}),
|
|
1240
|
+
...de.reduce((e, t) => ({
|
|
1241
|
+
...e,
|
|
1242
|
+
[t]: "package"
|
|
1243
|
+
/* Package */
|
|
1244
|
+
}), {}),
|
|
1245
|
+
...le.reduce((e, t) => ({
|
|
1246
|
+
...e,
|
|
1247
|
+
[t]: "face"
|
|
1248
|
+
/* Face */
|
|
1249
|
+
}), {}),
|
|
1250
|
+
...ce.reduce((e, t) => ({
|
|
1251
|
+
...e,
|
|
1252
|
+
[t]: "plate"
|
|
1253
|
+
/* Plate */
|
|
1254
|
+
}), {}),
|
|
1255
|
+
...fe.reduce((e, t) => ({
|
|
1256
|
+
...e,
|
|
1257
|
+
[t]: "audio"
|
|
1258
|
+
/* Audio */
|
|
1259
|
+
}), {}),
|
|
1260
|
+
...me.reduce((e, t) => ({
|
|
1261
|
+
...e,
|
|
1262
|
+
[t]: "audio"
|
|
1263
|
+
/* Audio */
|
|
1264
|
+
}), {}),
|
|
1265
|
+
...he.reduce((e, t) => ({
|
|
1266
|
+
...e,
|
|
1267
|
+
[t]: "doorbell"
|
|
1268
|
+
/* Doorbell */
|
|
1269
|
+
}), {}),
|
|
1270
|
+
...pe.reduce((e, t) => ({
|
|
1271
|
+
...e,
|
|
1272
|
+
[t]: "sensor"
|
|
1273
|
+
/* Sensor */
|
|
1274
|
+
}), {})
|
|
1275
|
+
}, st = (e) => le.includes(e), nt = (e) => ce.includes(e), mt = (e) => ie.includes(e), ht = (e) => oe.includes(e), pt = (e) => ae.includes(e), yt = (e) => ue.includes(e), gt = (e) => he.includes(e), wt = (e) => de.includes(e), _t = (e) => fe.includes(e) || me.includes(e), bt = (e) => pe.includes(e), vt = (e) => st(e) || nt(e), Et = (e) => ye[e], Pt = (e) => {
|
|
1276
|
+
const { className: t } = e, r = {
|
|
1277
|
+
face: "person",
|
|
1278
|
+
plate: "vehicle"
|
|
1279
|
+
/* Vehicle */
|
|
1280
|
+
}, s = ye[t];
|
|
1281
|
+
return s && s !== t ? s : r[t];
|
|
1282
|
+
}, it = Object.values(ne), L = it.filter(
|
|
1283
|
+
(e) => e !== "motion"
|
|
1284
|
+
/* Motion */
|
|
1285
|
+
), ge = [
|
|
1286
|
+
"person",
|
|
1287
|
+
"doorbell",
|
|
1288
|
+
"package"
|
|
1289
|
+
/* Package */
|
|
1290
|
+
], ot = [
|
|
1291
|
+
...ge,
|
|
1292
|
+
"vehicle",
|
|
1293
|
+
"animal",
|
|
1294
|
+
"audio",
|
|
1295
|
+
"face",
|
|
1296
|
+
"plate"
|
|
1297
|
+
/* Plate */
|
|
1298
|
+
], at = [...L];
|
|
1299
|
+
function Ct(e, t) {
|
|
1300
|
+
switch (e) {
|
|
1301
|
+
case "critical":
|
|
1302
|
+
return ge;
|
|
1303
|
+
case "important":
|
|
1304
|
+
return ot;
|
|
1305
|
+
case "all":
|
|
1306
|
+
return at;
|
|
1307
|
+
case "custom":
|
|
1308
|
+
return t?.length ? t : L;
|
|
1309
|
+
default:
|
|
1310
|
+
return L;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
const $ = {
|
|
1314
|
+
// Scrypted PascalCase
|
|
1315
|
+
Light: "light",
|
|
1316
|
+
Switch: "switch",
|
|
1317
|
+
WindowCovering: "cover",
|
|
1318
|
+
Lock: "lock",
|
|
1319
|
+
SecuritySystem: "alarm",
|
|
1320
|
+
Buttons: "button",
|
|
1321
|
+
Select: "select",
|
|
1322
|
+
Siren: "siren",
|
|
1323
|
+
Sensor: "sensor",
|
|
1324
|
+
Entry: "entry",
|
|
1325
|
+
Program: "script",
|
|
1326
|
+
MediaPlayer: "media_player",
|
|
1327
|
+
Outlet: "switch",
|
|
1328
|
+
// Home Assistant lowercase domains
|
|
1329
|
+
light: "light",
|
|
1330
|
+
switch: "switch",
|
|
1331
|
+
input_boolean: "switch",
|
|
1332
|
+
cover: "cover",
|
|
1333
|
+
lock: "lock",
|
|
1334
|
+
alarm_control_panel: "alarm",
|
|
1335
|
+
input_button: "button",
|
|
1336
|
+
button: "button",
|
|
1337
|
+
input_select: "select",
|
|
1338
|
+
select: "select",
|
|
1339
|
+
siren: "siren",
|
|
1340
|
+
sensor: "sensor",
|
|
1341
|
+
media_player: "media_player",
|
|
1342
|
+
script: "script"
|
|
1343
|
+
}, kt = {
|
|
1344
|
+
light: "light",
|
|
1345
|
+
switch: "switch",
|
|
1346
|
+
input_boolean: "switch",
|
|
1347
|
+
cover: "cover",
|
|
1348
|
+
lock: "lock",
|
|
1349
|
+
alarm_control_panel: "alarm",
|
|
1350
|
+
input_button: "button",
|
|
1351
|
+
button: "button",
|
|
1352
|
+
input_select: "select",
|
|
1353
|
+
select: "select",
|
|
1354
|
+
siren: "siren",
|
|
1355
|
+
sensor: "sensor",
|
|
1356
|
+
binary_sensor: "sensor",
|
|
1357
|
+
media_player: "media_player",
|
|
1358
|
+
script: "script",
|
|
1359
|
+
climate: "climate",
|
|
1360
|
+
camera: "camera",
|
|
1361
|
+
fan: "fan",
|
|
1362
|
+
vacuum: "vacuum",
|
|
1363
|
+
automation: "automation",
|
|
1364
|
+
scene: "scene",
|
|
1365
|
+
input_number: "sensor",
|
|
1366
|
+
person: "person",
|
|
1367
|
+
device_tracker: "tracker",
|
|
1368
|
+
weather: "weather",
|
|
1369
|
+
water_heater: "climate"
|
|
1370
|
+
}, St = {
|
|
1371
|
+
Light: "light",
|
|
1372
|
+
Switch: "switch",
|
|
1373
|
+
WindowCovering: "cover",
|
|
1374
|
+
Lock: "lock",
|
|
1375
|
+
SecuritySystem: "alarm",
|
|
1376
|
+
Buttons: "button",
|
|
1377
|
+
Select: "select",
|
|
1378
|
+
Siren: "siren",
|
|
1379
|
+
Sensor: "sensor",
|
|
1380
|
+
Entry: "entry",
|
|
1381
|
+
Program: "script",
|
|
1382
|
+
MediaPlayer: "media_player",
|
|
1383
|
+
Camera: "camera",
|
|
1384
|
+
Doorbell: "doorbell",
|
|
1385
|
+
Fan: "fan",
|
|
1386
|
+
Outlet: "switch"
|
|
1387
|
+
};
|
|
1388
|
+
function Rt(e) {
|
|
1389
|
+
const t = $[e];
|
|
1390
|
+
if (t) return t;
|
|
1391
|
+
const r = e.toLowerCase();
|
|
1392
|
+
return $[r] ?? null;
|
|
1393
|
+
}
|
|
1394
|
+
const lt = [
|
|
1395
|
+
"Entry",
|
|
1396
|
+
"Light",
|
|
1397
|
+
"Switch",
|
|
1398
|
+
"Lock",
|
|
1399
|
+
"SecuritySystem",
|
|
1400
|
+
"Buttons",
|
|
1401
|
+
"WindowCovering",
|
|
1402
|
+
"Siren",
|
|
1403
|
+
"Sensor",
|
|
1404
|
+
"Select",
|
|
1405
|
+
"Program"
|
|
1406
|
+
], It = new Set(lt), ct = [
|
|
1407
|
+
"light",
|
|
1408
|
+
"switch",
|
|
1409
|
+
"input_boolean",
|
|
1410
|
+
"cover",
|
|
1411
|
+
"lock",
|
|
1412
|
+
"alarm_control_panel",
|
|
1413
|
+
"input_button",
|
|
1414
|
+
"button",
|
|
1415
|
+
"input_select",
|
|
1416
|
+
"select",
|
|
1417
|
+
"siren",
|
|
1418
|
+
"media_player",
|
|
1419
|
+
"script"
|
|
1420
|
+
], Tt = new Set(ct), N = [
|
|
1421
|
+
{
|
|
1422
|
+
id: "liveStream",
|
|
1423
|
+
label: "Live Stream",
|
|
1424
|
+
sources: { frigate: !0, scrypted: !0, rtsp: !0 },
|
|
1425
|
+
adapterMethod: "getLiveStream"
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
id: "multiResolution",
|
|
1429
|
+
label: "Multi-Resolution",
|
|
1430
|
+
sources: { frigate: !0, scrypted: !0, rtsp: !1 },
|
|
1431
|
+
adapterMethod: "getResolutions"
|
|
1432
|
+
},
|
|
1433
|
+
{
|
|
1434
|
+
id: "motion",
|
|
1435
|
+
label: "Motion Detection",
|
|
1436
|
+
sources: { frigate: !1, scrypted: !0, rtsp: !1 },
|
|
1437
|
+
adapterMethod: "getMotion"
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
id: "objectDetection",
|
|
1441
|
+
label: "Object Detection",
|
|
1442
|
+
sources: { frigate: !1, scrypted: !0, rtsp: !1 },
|
|
1443
|
+
adapterMethod: "getObjectDetections"
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
id: "audioVolume",
|
|
1447
|
+
label: "Audio Level",
|
|
1448
|
+
sources: { frigate: !1, scrypted: !0, rtsp: !1 },
|
|
1449
|
+
adapterMethod: "getAudioVolume"
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
id: "audioVolumes",
|
|
1453
|
+
label: "Audio Volumes (dBFS)",
|
|
1454
|
+
sources: { frigate: !1, scrypted: !0, rtsp: !1 },
|
|
1455
|
+
adapterMethod: "getAudioVolumes"
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
id: "ptz",
|
|
1459
|
+
label: "PTZ Control",
|
|
1460
|
+
sources: { frigate: !1, scrypted: !0, rtsp: !1 },
|
|
1461
|
+
adapterMethod: "getPTZ"
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
id: "intercom",
|
|
1465
|
+
label: "Intercom (Mic)",
|
|
1466
|
+
sources: { frigate: !1, scrypted: !0, rtsp: !1 },
|
|
1467
|
+
adapterMethod: "getIntercomSupport"
|
|
1468
|
+
},
|
|
1469
|
+
{
|
|
1470
|
+
id: "deviceStatus",
|
|
1471
|
+
label: "Device Status",
|
|
1472
|
+
sources: { frigate: !1, scrypted: !0, rtsp: !1 },
|
|
1473
|
+
adapterMethod: "getStatus"
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
id: "timeline",
|
|
1477
|
+
label: "Detection Timeline",
|
|
1478
|
+
sources: { frigate: !0, scrypted: !0, rtsp: !1 },
|
|
1479
|
+
adapterMethod: "getCameraDayData"
|
|
1480
|
+
},
|
|
1481
|
+
{
|
|
1482
|
+
id: "clusteredTimeline",
|
|
1483
|
+
label: "Clustered Timeline",
|
|
1484
|
+
sources: { frigate: !0, scrypted: !0, rtsp: !1 },
|
|
1485
|
+
requiresBackend: !0,
|
|
1486
|
+
adapterMethod: "getClusteredDayData"
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
id: "detectionClasses",
|
|
1490
|
+
label: "Detection Classes",
|
|
1491
|
+
sources: { frigate: !0, scrypted: !0, rtsp: !1 },
|
|
1492
|
+
adapterMethod: "getDetectionClasses"
|
|
1493
|
+
},
|
|
1494
|
+
{
|
|
1495
|
+
id: "videoClips",
|
|
1496
|
+
label: "Video Clips",
|
|
1497
|
+
sources: { frigate: !0, scrypted: !0, rtsp: !1 },
|
|
1498
|
+
adapterMethod: "getVideoClips"
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
id: "nvrPlayback",
|
|
1502
|
+
label: "NVR Playback",
|
|
1503
|
+
sources: { frigate: !0, scrypted: !0, rtsp: !1 },
|
|
1504
|
+
adapterMethod: "getNvrPlaybackSupported"
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
id: "nvrScrub",
|
|
1508
|
+
label: "NVR Scrub/Seek",
|
|
1509
|
+
sources: { frigate: !1, scrypted: !0, rtsp: !1 },
|
|
1510
|
+
adapterMethod: "seekRecordingStream"
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
id: "recordingThumbnail",
|
|
1514
|
+
label: "Recording Thumbnails",
|
|
1515
|
+
sources: { frigate: !0, scrypted: !0, rtsp: !1 },
|
|
1516
|
+
adapterMethod: "getRecordingStreamThumbnail"
|
|
1517
|
+
},
|
|
1518
|
+
{
|
|
1519
|
+
id: "nvrSeekToLive",
|
|
1520
|
+
label: "Seek to Live",
|
|
1521
|
+
sources: { frigate: !1, scrypted: !0, rtsp: !1 },
|
|
1522
|
+
adapterMethod: "seekNvrToLive"
|
|
1523
|
+
}
|
|
1524
|
+
];
|
|
1525
|
+
function At(e, t, r) {
|
|
1526
|
+
const s = N.find((n) => n.id === e);
|
|
1527
|
+
return !(!s || !s.sources[t] || s.platforms && s.platforms[r] === !1);
|
|
1528
|
+
}
|
|
1529
|
+
function Mt(e) {
|
|
1530
|
+
return N.filter((t) => t.sources[e]);
|
|
1531
|
+
}
|
|
1532
|
+
function Ot() {
|
|
1533
|
+
return N.filter((e) => e.requiresBackend);
|
|
1534
|
+
}
|
|
1535
|
+
function Dt(e, t, r) {
|
|
1536
|
+
if (e.length === 0) return null;
|
|
1537
|
+
const s = t.viewportWidth * t.viewportHeight * (t.pixelRatio ?? 1), n = t.bandwidthMbps ?? 100, i = t.packetLoss ?? 0, o = t.rttMs ?? 50;
|
|
1538
|
+
let a = "high";
|
|
1539
|
+
t.maxResolution === "low" || t.isCellular || n < 1 || i > 0.05 ? a = "low" : t.maxResolution === "medium" || n < 5 || s < 5e5 || o > 200 ? a = "medium" : (t.maxResolution === "high" || s > 2e6) && (a = "high");
|
|
1540
|
+
const c = {
|
|
1541
|
+
main: "high",
|
|
1542
|
+
sub: "medium",
|
|
1543
|
+
ext: "low"
|
|
1544
|
+
}, f = r ?? "native", h = e.map((d) => {
|
|
1545
|
+
let u = 0;
|
|
1546
|
+
const m = c[d.profile] ?? "medium";
|
|
1547
|
+
if (m === a ? u += 100 : (a === "high" && m === "medium" || a === "medium" && m === "high" || a === "medium" && m === "low" || a === "low" && m === "medium") && (u += 50), d.transport === f ? u += 30 : d.transport === "native" ? u += 20 : d.transport === "rtsp" ? u += 15 : d.transport === "rtmp" && (u += 10), d.metadata?.width && d.metadata?.height) {
|
|
1548
|
+
const w = d.metadata.width * d.metadata.height / Math.max(s, 1);
|
|
1549
|
+
w >= 0.8 && w <= 2 ? u += 25 : w >= 0.5 && w <= 3 && (u += 15), w > 4 && n < 10 && (u -= 20);
|
|
1550
|
+
}
|
|
1551
|
+
return d.metadata?.codec && (n < 5 && d.metadata.codec.includes("265") && (u += 10), n >= 10 && d.metadata.codec.includes("264") && (u += 5)), { ...d, score: u, targetTier: a };
|
|
1552
|
+
});
|
|
1553
|
+
h.sort((d, u) => u.score - d.score);
|
|
1554
|
+
const p = h[0];
|
|
1555
|
+
return {
|
|
1556
|
+
streamName: p.streamName,
|
|
1557
|
+
profile: p.profile,
|
|
1558
|
+
transport: p.transport,
|
|
1559
|
+
label: p.label,
|
|
1560
|
+
metadata: p.metadata,
|
|
1561
|
+
reason: `${p.targetTier} quality → ${p.profile}/${p.transport} (score: ${p.score})`
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
function Lt(e, t) {
|
|
1565
|
+
return t ? 10 : e.isCellular || (e.packetLoss ?? 0) > 0.02 ? 15 : 30;
|
|
1566
|
+
}
|
|
1567
|
+
export {
|
|
1568
|
+
L as DEFAULT_ENABLED_CLASSES,
|
|
1569
|
+
ne as DetectionClass,
|
|
1570
|
+
ct as ELIGIBLE_HA_DOMAINS,
|
|
1571
|
+
Tt as ELIGIBLE_HA_DOMAINS_SET,
|
|
1572
|
+
lt as ELIGIBLE_SCRYPTED_DEVICE_TYPES,
|
|
1573
|
+
It as ELIGIBLE_SCRYPTED_DEVICE_TYPES_SET,
|
|
1574
|
+
N as FEATURE_MATRIX,
|
|
1575
|
+
kt as HA_DOMAIN_TYPE_MAP,
|
|
1576
|
+
$ as RAW_TO_CANONICAL,
|
|
1577
|
+
St as SCRYPTED_TYPE_TO_CANONICAL,
|
|
1578
|
+
tt as System,
|
|
1579
|
+
at as TIMELINE_PRESET_ALL,
|
|
1580
|
+
ge as TIMELINE_PRESET_CRITICAL,
|
|
1581
|
+
ot as TIMELINE_PRESET_IMPORTANT,
|
|
1582
|
+
ie as animalClasses,
|
|
1583
|
+
fe as audioClasses,
|
|
1584
|
+
me as audioLabelClasses,
|
|
1585
|
+
ft as createSystem,
|
|
1586
|
+
it as defaultDetectionClasses,
|
|
1587
|
+
ye as detectionClassesDefaultMap,
|
|
1588
|
+
he as doorbellClasses,
|
|
1589
|
+
le as faceClasses,
|
|
1590
|
+
Ot as getBackendRequiredFeatures,
|
|
1591
|
+
Rt as getCanonicalDeviceType,
|
|
1592
|
+
Ct as getClassesForTimelinePreset,
|
|
1593
|
+
Lt as getNextEvalInterval,
|
|
1594
|
+
Et as getParentClass,
|
|
1595
|
+
Pt as getParentDetectionClass,
|
|
1596
|
+
Mt as getSourceFeatures,
|
|
1597
|
+
mt as isAnimalClassname,
|
|
1598
|
+
_t as isAudioClassname,
|
|
1599
|
+
gt as isDoorbellClassname,
|
|
1600
|
+
st as isFaceClassname,
|
|
1601
|
+
At as isFeatureAvailable,
|
|
1602
|
+
vt as isLabelDetection,
|
|
1603
|
+
yt as isMotionClassname,
|
|
1604
|
+
wt as isPackageClassname,
|
|
1605
|
+
ht as isPersonClassname,
|
|
1606
|
+
nt as isPlateClassname,
|
|
1607
|
+
bt as isSensorLabelClassname,
|
|
1608
|
+
pt as isVehicleClassname,
|
|
1609
|
+
ce as licensePlateClasses,
|
|
1610
|
+
ue as motionClasses,
|
|
1611
|
+
de as packageClasses,
|
|
1612
|
+
oe as personClasses,
|
|
1613
|
+
rt as raceFastestEndpoint,
|
|
1614
|
+
Dt as selectOptimalStream,
|
|
1615
|
+
pe as sensorLabelClasses,
|
|
1616
|
+
ae as vehicleClasses
|
|
1617
|
+
};
|