@camstack/sdk 0.1.36 → 0.1.37
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/__tests__/race-endpoints.spec.d.ts +1 -0
- package/dist/index.cjs +1076 -2130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1022 -1994
- package/dist/index.js.map +1 -1
- package/dist/system.d.ts +68 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,1862 +1,787 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const client = require("@trpc/client");
|
|
4
|
+
const types = require("@camstack/types");
|
|
5
|
+
class DoubleIndexedKV {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.keyToValue = /* @__PURE__ */ new Map();
|
|
8
|
+
this.valueToKey = /* @__PURE__ */ new Map();
|
|
18
9
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var index_exports = {};
|
|
33
|
-
__export(index_exports, {
|
|
34
|
-
DEFAULT_ENABLED_CLASSES: () => DEFAULT_ENABLED_CLASSES,
|
|
35
|
-
DetectionClass: () => DetectionClass,
|
|
36
|
-
ELIGIBLE_HA_DOMAINS: () => ELIGIBLE_HA_DOMAINS,
|
|
37
|
-
ELIGIBLE_HA_DOMAINS_SET: () => ELIGIBLE_HA_DOMAINS_SET,
|
|
38
|
-
ELIGIBLE_SCRYPTED_DEVICE_TYPES: () => ELIGIBLE_SCRYPTED_DEVICE_TYPES,
|
|
39
|
-
ELIGIBLE_SCRYPTED_DEVICE_TYPES_SET: () => ELIGIBLE_SCRYPTED_DEVICE_TYPES_SET,
|
|
40
|
-
FEATURE_MATRIX: () => FEATURE_MATRIX,
|
|
41
|
-
HA_DOMAIN_TYPE_MAP: () => HA_DOMAIN_TYPE_MAP,
|
|
42
|
-
RAW_TO_CANONICAL: () => RAW_TO_CANONICAL,
|
|
43
|
-
SCRYPTED_TYPE_TO_CANONICAL: () => SCRYPTED_TYPE_TO_CANONICAL,
|
|
44
|
-
System: () => System,
|
|
45
|
-
TIMELINE_PRESET_ALL: () => TIMELINE_PRESET_ALL,
|
|
46
|
-
TIMELINE_PRESET_CRITICAL: () => TIMELINE_PRESET_CRITICAL,
|
|
47
|
-
TIMELINE_PRESET_IMPORTANT: () => TIMELINE_PRESET_IMPORTANT,
|
|
48
|
-
animalClasses: () => animalClasses,
|
|
49
|
-
audioClasses: () => audioClasses,
|
|
50
|
-
audioLabelClasses: () => audioLabelClasses,
|
|
51
|
-
createSystem: () => createSystem,
|
|
52
|
-
defaultDetectionClasses: () => defaultDetectionClasses,
|
|
53
|
-
detectionClassesDefaultMap: () => detectionClassesDefaultMap,
|
|
54
|
-
doorbellClasses: () => doorbellClasses,
|
|
55
|
-
faceClasses: () => faceClasses,
|
|
56
|
-
getBackendRequiredFeatures: () => getBackendRequiredFeatures,
|
|
57
|
-
getCanonicalDeviceType: () => getCanonicalDeviceType,
|
|
58
|
-
getClassesForTimelinePreset: () => getClassesForTimelinePreset,
|
|
59
|
-
getNextEvalInterval: () => getNextEvalInterval,
|
|
60
|
-
getParentClass: () => getParentClass,
|
|
61
|
-
getParentDetectionClass: () => getParentDetectionClass,
|
|
62
|
-
getSourceFeatures: () => getSourceFeatures,
|
|
63
|
-
isAnimalClassname: () => isAnimalClassname,
|
|
64
|
-
isAudioClassname: () => isAudioClassname,
|
|
65
|
-
isDoorbellClassname: () => isDoorbellClassname,
|
|
66
|
-
isFaceClassname: () => isFaceClassname,
|
|
67
|
-
isFeatureAvailable: () => isFeatureAvailable,
|
|
68
|
-
isLabelDetection: () => isLabelDetection,
|
|
69
|
-
isMotionClassname: () => isMotionClassname,
|
|
70
|
-
isPackageClassname: () => isPackageClassname,
|
|
71
|
-
isPersonClassname: () => isPersonClassname,
|
|
72
|
-
isPlateClassname: () => isPlateClassname,
|
|
73
|
-
isSensorLabelClassname: () => isSensorLabelClassname,
|
|
74
|
-
isVehicleClassname: () => isVehicleClassname,
|
|
75
|
-
licensePlateClasses: () => licensePlateClasses,
|
|
76
|
-
motionClasses: () => motionClasses,
|
|
77
|
-
packageClasses: () => packageClasses,
|
|
78
|
-
personClasses: () => personClasses,
|
|
79
|
-
selectOptimalStream: () => selectOptimalStream,
|
|
80
|
-
sensorLabelClasses: () => sensorLabelClasses,
|
|
81
|
-
vehicleClasses: () => vehicleClasses
|
|
82
|
-
});
|
|
83
|
-
module.exports = __toCommonJS(index_exports);
|
|
84
|
-
|
|
85
|
-
// ../../node_modules/@trpc/client/dist/objectSpread2-BvkFp-_Y.mjs
|
|
86
|
-
var __create2 = Object.create;
|
|
87
|
-
var __defProp2 = Object.defineProperty;
|
|
88
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
89
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
90
|
-
var __getProtoOf2 = Object.getPrototypeOf;
|
|
91
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
92
|
-
var __commonJS = /* @__PURE__ */ __name((cb, mod) => function() {
|
|
93
|
-
return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
94
|
-
}, "__commonJS");
|
|
95
|
-
var __copyProps2 = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
96
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames2(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
97
|
-
key = keys[i];
|
|
98
|
-
if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
|
|
99
|
-
get: ((k) => from[k]).bind(null, key),
|
|
100
|
-
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
101
|
-
});
|
|
10
|
+
set(key, value) {
|
|
11
|
+
this.keyToValue.set(key, value);
|
|
12
|
+
this.valueToKey.set(value, key);
|
|
102
13
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
value
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return module2.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
113
|
-
return typeof o$1;
|
|
114
|
-
} : function(o$1) {
|
|
115
|
-
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
116
|
-
}, module2.exports.__esModule = true, module2.exports["default"] = module2.exports, _typeof$2(o);
|
|
117
|
-
}
|
|
118
|
-
__name(_typeof$2, "_typeof$2");
|
|
119
|
-
module2.exports = _typeof$2, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
120
|
-
} });
|
|
121
|
-
var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports2, module2) {
|
|
122
|
-
var _typeof$1 = require_typeof()["default"];
|
|
123
|
-
function toPrimitive$1(t, r) {
|
|
124
|
-
if ("object" != _typeof$1(t) || !t) return t;
|
|
125
|
-
var e = t[Symbol.toPrimitive];
|
|
126
|
-
if (void 0 !== e) {
|
|
127
|
-
var i = e.call(t, r || "default");
|
|
128
|
-
if ("object" != _typeof$1(i)) return i;
|
|
129
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
130
|
-
}
|
|
131
|
-
return ("string" === r ? String : Number)(t);
|
|
132
|
-
}
|
|
133
|
-
__name(toPrimitive$1, "toPrimitive$1");
|
|
134
|
-
module2.exports = toPrimitive$1, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
135
|
-
} });
|
|
136
|
-
var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports2, module2) {
|
|
137
|
-
var _typeof = require_typeof()["default"];
|
|
138
|
-
var toPrimitive = require_toPrimitive();
|
|
139
|
-
function toPropertyKey$1(t) {
|
|
140
|
-
var i = toPrimitive(t, "string");
|
|
141
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
142
|
-
}
|
|
143
|
-
__name(toPropertyKey$1, "toPropertyKey$1");
|
|
144
|
-
module2.exports = toPropertyKey$1, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
145
|
-
} });
|
|
146
|
-
var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports2, module2) {
|
|
147
|
-
var toPropertyKey = require_toPropertyKey();
|
|
148
|
-
function _defineProperty(e, r, t) {
|
|
149
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
150
|
-
value: t,
|
|
151
|
-
enumerable: true,
|
|
152
|
-
configurable: true,
|
|
153
|
-
writable: true
|
|
154
|
-
}) : e[r] = t, e;
|
|
155
|
-
}
|
|
156
|
-
__name(_defineProperty, "_defineProperty");
|
|
157
|
-
module2.exports = _defineProperty, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
158
|
-
} });
|
|
159
|
-
var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports2, module2) {
|
|
160
|
-
var defineProperty = require_defineProperty();
|
|
161
|
-
function ownKeys(e, r) {
|
|
162
|
-
var t = Object.keys(e);
|
|
163
|
-
if (Object.getOwnPropertySymbols) {
|
|
164
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
165
|
-
r && (o = o.filter(function(r$1) {
|
|
166
|
-
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
167
|
-
})), t.push.apply(t, o);
|
|
168
|
-
}
|
|
169
|
-
return t;
|
|
170
|
-
}
|
|
171
|
-
__name(ownKeys, "ownKeys");
|
|
172
|
-
function _objectSpread2(e) {
|
|
173
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
174
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
175
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r$1) {
|
|
176
|
-
defineProperty(e, r$1, t[r$1]);
|
|
177
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
178
|
-
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
return e;
|
|
14
|
+
getByKey(key) {
|
|
15
|
+
return this.keyToValue.get(key);
|
|
16
|
+
}
|
|
17
|
+
getByValue(value) {
|
|
18
|
+
return this.valueToKey.get(value);
|
|
19
|
+
}
|
|
20
|
+
clear() {
|
|
21
|
+
this.keyToValue.clear();
|
|
22
|
+
this.valueToKey.clear();
|
|
182
23
|
}
|
|
183
|
-
__name(_objectSpread2, "_objectSpread2");
|
|
184
|
-
module2.exports = _objectSpread2, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
185
|
-
} });
|
|
186
|
-
|
|
187
|
-
// ../../node_modules/@trpc/server/dist/observable-UMO3vUa_.mjs
|
|
188
|
-
function observable(subscribe) {
|
|
189
|
-
const self = {
|
|
190
|
-
subscribe(observer) {
|
|
191
|
-
let teardownRef = null;
|
|
192
|
-
let isDone = false;
|
|
193
|
-
let unsubscribed = false;
|
|
194
|
-
let teardownImmediately = false;
|
|
195
|
-
function unsubscribe() {
|
|
196
|
-
if (teardownRef === null) {
|
|
197
|
-
teardownImmediately = true;
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
if (unsubscribed) return;
|
|
201
|
-
unsubscribed = true;
|
|
202
|
-
if (typeof teardownRef === "function") teardownRef();
|
|
203
|
-
else if (teardownRef) teardownRef.unsubscribe();
|
|
204
|
-
}
|
|
205
|
-
__name(unsubscribe, "unsubscribe");
|
|
206
|
-
teardownRef = subscribe({
|
|
207
|
-
next(value) {
|
|
208
|
-
var _observer$next;
|
|
209
|
-
if (isDone) return;
|
|
210
|
-
(_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value);
|
|
211
|
-
},
|
|
212
|
-
error(err) {
|
|
213
|
-
var _observer$error;
|
|
214
|
-
if (isDone) return;
|
|
215
|
-
isDone = true;
|
|
216
|
-
(_observer$error = observer.error) === null || _observer$error === void 0 || _observer$error.call(observer, err);
|
|
217
|
-
unsubscribe();
|
|
218
|
-
},
|
|
219
|
-
complete() {
|
|
220
|
-
var _observer$complete;
|
|
221
|
-
if (isDone) return;
|
|
222
|
-
isDone = true;
|
|
223
|
-
(_observer$complete = observer.complete) === null || _observer$complete === void 0 || _observer$complete.call(observer);
|
|
224
|
-
unsubscribe();
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
if (teardownImmediately) unsubscribe();
|
|
228
|
-
return { unsubscribe };
|
|
229
|
-
},
|
|
230
|
-
pipe(...operations) {
|
|
231
|
-
return operations.reduce(pipeReducer, self);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
return self;
|
|
235
|
-
}
|
|
236
|
-
__name(observable, "observable");
|
|
237
|
-
function pipeReducer(prev, fn) {
|
|
238
|
-
return fn(prev);
|
|
239
24
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
obs$.unsubscribe();
|
|
25
|
+
class Registry {
|
|
26
|
+
constructor(generateIdentifier) {
|
|
27
|
+
this.generateIdentifier = generateIdentifier;
|
|
28
|
+
this.kv = new DoubleIndexedKV();
|
|
29
|
+
}
|
|
30
|
+
register(value, identifier) {
|
|
31
|
+
if (this.kv.getByValue(value)) {
|
|
32
|
+
return;
|
|
249
33
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
reject(ac.signal.reason);
|
|
253
|
-
});
|
|
254
|
-
const obs$ = observable$1.subscribe({
|
|
255
|
-
next(data) {
|
|
256
|
-
isDone = true;
|
|
257
|
-
resolve(data);
|
|
258
|
-
onDone();
|
|
259
|
-
},
|
|
260
|
-
error(data) {
|
|
261
|
-
reject(data);
|
|
262
|
-
},
|
|
263
|
-
complete() {
|
|
264
|
-
ac.abort();
|
|
265
|
-
onDone();
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
return promise;
|
|
270
|
-
}
|
|
271
|
-
__name(observableToPromise, "observableToPromise");
|
|
272
|
-
|
|
273
|
-
// ../../node_modules/@trpc/server/dist/observable-CUiPknO-.mjs
|
|
274
|
-
function share(_opts) {
|
|
275
|
-
return (source) => {
|
|
276
|
-
let refCount = 0;
|
|
277
|
-
let subscription = null;
|
|
278
|
-
const observers = [];
|
|
279
|
-
function startIfNeeded() {
|
|
280
|
-
if (subscription) return;
|
|
281
|
-
subscription = source.subscribe({
|
|
282
|
-
next(value) {
|
|
283
|
-
for (const observer of observers) {
|
|
284
|
-
var _observer$next;
|
|
285
|
-
(_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value);
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
error(error) {
|
|
289
|
-
for (const observer of observers) {
|
|
290
|
-
var _observer$error;
|
|
291
|
-
(_observer$error = observer.error) === null || _observer$error === void 0 || _observer$error.call(observer, error);
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
complete() {
|
|
295
|
-
for (const observer of observers) {
|
|
296
|
-
var _observer$complete;
|
|
297
|
-
(_observer$complete = observer.complete) === null || _observer$complete === void 0 || _observer$complete.call(observer);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
});
|
|
34
|
+
if (!identifier) {
|
|
35
|
+
identifier = this.generateIdentifier(value);
|
|
301
36
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
37
|
+
this.kv.set(identifier, value);
|
|
38
|
+
}
|
|
39
|
+
clear() {
|
|
40
|
+
this.kv.clear();
|
|
41
|
+
}
|
|
42
|
+
getIdentifier(value) {
|
|
43
|
+
return this.kv.getByValue(value);
|
|
44
|
+
}
|
|
45
|
+
getValue(identifier) {
|
|
46
|
+
return this.kv.getByKey(identifier);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class ClassRegistry extends Registry {
|
|
50
|
+
constructor() {
|
|
51
|
+
super((c) => c.name);
|
|
52
|
+
this.classToAllowedProps = /* @__PURE__ */ new Map();
|
|
53
|
+
}
|
|
54
|
+
register(value, options) {
|
|
55
|
+
if (typeof options === "object") {
|
|
56
|
+
if (options.allowProps) {
|
|
57
|
+
this.classToAllowedProps.set(value, options.allowProps);
|
|
308
58
|
}
|
|
59
|
+
super.register(value, options.identifier);
|
|
60
|
+
} else {
|
|
61
|
+
super.register(value, options);
|
|
309
62
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
startIfNeeded();
|
|
315
|
-
return { unsubscribe() {
|
|
316
|
-
refCount--;
|
|
317
|
-
resetIfNeeded();
|
|
318
|
-
const index = observers.findIndex((v) => v === subscriber);
|
|
319
|
-
if (index > -1) observers.splice(index, 1);
|
|
320
|
-
} };
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
__name(share, "share");
|
|
325
|
-
function behaviorSubject(initialValue) {
|
|
326
|
-
let value = initialValue;
|
|
327
|
-
const observerList = [];
|
|
328
|
-
const addObserver = /* @__PURE__ */ __name((observer) => {
|
|
329
|
-
if (value !== void 0) observer.next(value);
|
|
330
|
-
observerList.push(observer);
|
|
331
|
-
}, "addObserver");
|
|
332
|
-
const removeObserver = /* @__PURE__ */ __name((observer) => {
|
|
333
|
-
observerList.splice(observerList.indexOf(observer), 1);
|
|
334
|
-
}, "removeObserver");
|
|
335
|
-
const obs = observable((observer) => {
|
|
336
|
-
addObserver(observer);
|
|
337
|
-
return () => {
|
|
338
|
-
removeObserver(observer);
|
|
339
|
-
};
|
|
340
|
-
});
|
|
341
|
-
obs.next = (nextValue) => {
|
|
342
|
-
if (value === nextValue) return;
|
|
343
|
-
value = nextValue;
|
|
344
|
-
for (const observer of observerList) observer.next(nextValue);
|
|
345
|
-
};
|
|
346
|
-
obs.get = () => value;
|
|
347
|
-
return obs;
|
|
63
|
+
}
|
|
64
|
+
getAllowedProps(value) {
|
|
65
|
+
return this.classToAllowedProps.get(value);
|
|
66
|
+
}
|
|
348
67
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const subscription = next({
|
|
358
|
-
op,
|
|
359
|
-
next(nextOp) {
|
|
360
|
-
const nextObserver = execute(index + 1, nextOp);
|
|
361
|
-
return nextObserver;
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
return subscription;
|
|
68
|
+
function valuesOfObj(record) {
|
|
69
|
+
if ("values" in Object) {
|
|
70
|
+
return Object.values(record);
|
|
71
|
+
}
|
|
72
|
+
const values = [];
|
|
73
|
+
for (const key in record) {
|
|
74
|
+
if (record.hasOwnProperty(key)) {
|
|
75
|
+
values.push(record[key]);
|
|
365
76
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return obs$.subscribe(observer);
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
__name(createChain, "createChain");
|
|
372
|
-
|
|
373
|
-
// ../../node_modules/@trpc/server/dist/codes-DagpWZLc.mjs
|
|
374
|
-
function isObject(value) {
|
|
375
|
-
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
77
|
+
}
|
|
78
|
+
return values;
|
|
376
79
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
80
|
+
function find(record, predicate) {
|
|
81
|
+
const values = valuesOfObj(record);
|
|
82
|
+
if ("find" in values) {
|
|
83
|
+
return values.find(predicate);
|
|
84
|
+
}
|
|
85
|
+
const valuesNotNever = values;
|
|
86
|
+
for (let i = 0; i < valuesNotNever.length; i++) {
|
|
87
|
+
const value = valuesNotNever[i];
|
|
88
|
+
if (predicate(value)) {
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return void 0;
|
|
380
93
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
function sleep(ms = 0) {
|
|
384
|
-
return new Promise((res) => setTimeout(res, ms));
|
|
94
|
+
function forEach(record, run) {
|
|
95
|
+
Object.entries(record).forEach(([key, value]) => run(value, key));
|
|
385
96
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
PARSE_ERROR: -32700,
|
|
389
|
-
BAD_REQUEST: -32600,
|
|
390
|
-
INTERNAL_SERVER_ERROR: -32603,
|
|
391
|
-
NOT_IMPLEMENTED: -32603,
|
|
392
|
-
BAD_GATEWAY: -32603,
|
|
393
|
-
SERVICE_UNAVAILABLE: -32603,
|
|
394
|
-
GATEWAY_TIMEOUT: -32603,
|
|
395
|
-
UNAUTHORIZED: -32001,
|
|
396
|
-
PAYMENT_REQUIRED: -32002,
|
|
397
|
-
FORBIDDEN: -32003,
|
|
398
|
-
NOT_FOUND: -32004,
|
|
399
|
-
METHOD_NOT_SUPPORTED: -32005,
|
|
400
|
-
TIMEOUT: -32008,
|
|
401
|
-
CONFLICT: -32009,
|
|
402
|
-
PRECONDITION_FAILED: -32012,
|
|
403
|
-
PAYLOAD_TOO_LARGE: -32013,
|
|
404
|
-
UNSUPPORTED_MEDIA_TYPE: -32015,
|
|
405
|
-
UNPROCESSABLE_CONTENT: -32022,
|
|
406
|
-
PRECONDITION_REQUIRED: -32028,
|
|
407
|
-
TOO_MANY_REQUESTS: -32029,
|
|
408
|
-
CLIENT_CLOSED_REQUEST: -32099
|
|
409
|
-
};
|
|
410
|
-
var retryableRpcCodes = [
|
|
411
|
-
TRPC_ERROR_CODES_BY_KEY.BAD_GATEWAY,
|
|
412
|
-
TRPC_ERROR_CODES_BY_KEY.SERVICE_UNAVAILABLE,
|
|
413
|
-
TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,
|
|
414
|
-
TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR
|
|
415
|
-
];
|
|
416
|
-
|
|
417
|
-
// ../../node_modules/@trpc/server/dist/getErrorShape-BPSzUA7W.mjs
|
|
418
|
-
var __create3 = Object.create;
|
|
419
|
-
var __defProp3 = Object.defineProperty;
|
|
420
|
-
var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
|
|
421
|
-
var __getOwnPropNames3 = Object.getOwnPropertyNames;
|
|
422
|
-
var __getProtoOf3 = Object.getPrototypeOf;
|
|
423
|
-
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
424
|
-
var __commonJS2 = /* @__PURE__ */ __name((cb, mod) => function() {
|
|
425
|
-
return mod || (0, cb[__getOwnPropNames3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
426
|
-
}, "__commonJS");
|
|
427
|
-
var __copyProps3 = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
428
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames3(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
429
|
-
key = keys[i];
|
|
430
|
-
if (!__hasOwnProp3.call(to, key) && key !== except) __defProp3(to, key, {
|
|
431
|
-
get: ((k) => from[k]).bind(null, key),
|
|
432
|
-
enumerable: !(desc = __getOwnPropDesc3(from, key)) || desc.enumerable
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
return to;
|
|
436
|
-
}, "__copyProps");
|
|
437
|
-
var __toESM3 = /* @__PURE__ */ __name((mod, isNodeMode, target) => (target = mod != null ? __create3(__getProtoOf3(mod)) : {}, __copyProps3(isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", {
|
|
438
|
-
value: mod,
|
|
439
|
-
enumerable: true
|
|
440
|
-
}) : target, mod)), "__toESM");
|
|
441
|
-
var noop = /* @__PURE__ */ __name(() => {
|
|
442
|
-
}, "noop");
|
|
443
|
-
var freezeIfAvailable = /* @__PURE__ */ __name((obj) => {
|
|
444
|
-
if (Object.freeze) Object.freeze(obj);
|
|
445
|
-
}, "freezeIfAvailable");
|
|
446
|
-
function createInnerProxy(callback, path, memo) {
|
|
447
|
-
var _memo$cacheKey;
|
|
448
|
-
const cacheKey = path.join(".");
|
|
449
|
-
(_memo$cacheKey = memo[cacheKey]) !== null && _memo$cacheKey !== void 0 || (memo[cacheKey] = new Proxy(noop, {
|
|
450
|
-
get(_obj, key) {
|
|
451
|
-
if (typeof key !== "string" || key === "then") return void 0;
|
|
452
|
-
return createInnerProxy(callback, [...path, key], memo);
|
|
453
|
-
},
|
|
454
|
-
apply(_1, _2, args) {
|
|
455
|
-
const lastOfPath = path[path.length - 1];
|
|
456
|
-
if (lastOfPath === "valueOf" || lastOfPath === "toString" || lastOfPath === "toJSON") {
|
|
457
|
-
const debugPath = path.slice(0, -1).join(".");
|
|
458
|
-
return `tRPC.proxy(${debugPath})`;
|
|
459
|
-
}
|
|
460
|
-
let opts = {
|
|
461
|
-
args,
|
|
462
|
-
path
|
|
463
|
-
};
|
|
464
|
-
if (lastOfPath === "call") opts = {
|
|
465
|
-
args: args.length >= 2 ? [args[1]] : [],
|
|
466
|
-
path: path.slice(0, -1)
|
|
467
|
-
};
|
|
468
|
-
else if (lastOfPath === "apply") opts = {
|
|
469
|
-
args: args.length >= 2 ? args[1] : [],
|
|
470
|
-
path: path.slice(0, -1)
|
|
471
|
-
};
|
|
472
|
-
freezeIfAvailable(opts.args);
|
|
473
|
-
freezeIfAvailable(opts.path);
|
|
474
|
-
return callback(opts);
|
|
475
|
-
}
|
|
476
|
-
}));
|
|
477
|
-
return memo[cacheKey];
|
|
97
|
+
function includes(arr, value) {
|
|
98
|
+
return arr.indexOf(value) !== -1;
|
|
478
99
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
return callback(name);
|
|
485
|
-
} });
|
|
486
|
-
}, "createFlatProxy");
|
|
487
|
-
var require_typeof2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports2, module2) {
|
|
488
|
-
function _typeof$2(o) {
|
|
489
|
-
"@babel/helpers - typeof";
|
|
490
|
-
return module2.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
491
|
-
return typeof o$1;
|
|
492
|
-
} : function(o$1) {
|
|
493
|
-
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
494
|
-
}, module2.exports.__esModule = true, module2.exports["default"] = module2.exports, _typeof$2(o);
|
|
495
|
-
}
|
|
496
|
-
__name(_typeof$2, "_typeof$2");
|
|
497
|
-
module2.exports = _typeof$2, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
498
|
-
} });
|
|
499
|
-
var require_toPrimitive2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports2, module2) {
|
|
500
|
-
var _typeof$1 = require_typeof2()["default"];
|
|
501
|
-
function toPrimitive$1(t, r) {
|
|
502
|
-
if ("object" != _typeof$1(t) || !t) return t;
|
|
503
|
-
var e = t[Symbol.toPrimitive];
|
|
504
|
-
if (void 0 !== e) {
|
|
505
|
-
var i = e.call(t, r || "default");
|
|
506
|
-
if ("object" != _typeof$1(i)) return i;
|
|
507
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
508
|
-
}
|
|
509
|
-
return ("string" === r ? String : Number)(t);
|
|
510
|
-
}
|
|
511
|
-
__name(toPrimitive$1, "toPrimitive$1");
|
|
512
|
-
module2.exports = toPrimitive$1, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
513
|
-
} });
|
|
514
|
-
var require_toPropertyKey2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports2, module2) {
|
|
515
|
-
var _typeof = require_typeof2()["default"];
|
|
516
|
-
var toPrimitive = require_toPrimitive2();
|
|
517
|
-
function toPropertyKey$1(t) {
|
|
518
|
-
var i = toPrimitive(t, "string");
|
|
519
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
520
|
-
}
|
|
521
|
-
__name(toPropertyKey$1, "toPropertyKey$1");
|
|
522
|
-
module2.exports = toPropertyKey$1, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
523
|
-
} });
|
|
524
|
-
var require_defineProperty2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports2, module2) {
|
|
525
|
-
var toPropertyKey = require_toPropertyKey2();
|
|
526
|
-
function _defineProperty(e, r, t) {
|
|
527
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
528
|
-
value: t,
|
|
529
|
-
enumerable: true,
|
|
530
|
-
configurable: true,
|
|
531
|
-
writable: true
|
|
532
|
-
}) : e[r] = t, e;
|
|
533
|
-
}
|
|
534
|
-
__name(_defineProperty, "_defineProperty");
|
|
535
|
-
module2.exports = _defineProperty, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
536
|
-
} });
|
|
537
|
-
var require_objectSpread22 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports2, module2) {
|
|
538
|
-
var defineProperty = require_defineProperty2();
|
|
539
|
-
function ownKeys(e, r) {
|
|
540
|
-
var t = Object.keys(e);
|
|
541
|
-
if (Object.getOwnPropertySymbols) {
|
|
542
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
543
|
-
r && (o = o.filter(function(r$1) {
|
|
544
|
-
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
545
|
-
})), t.push.apply(t, o);
|
|
546
|
-
}
|
|
547
|
-
return t;
|
|
548
|
-
}
|
|
549
|
-
__name(ownKeys, "ownKeys");
|
|
550
|
-
function _objectSpread2(e) {
|
|
551
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
552
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
553
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r$1) {
|
|
554
|
-
defineProperty(e, r$1, t[r$1]);
|
|
555
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
556
|
-
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
557
|
-
});
|
|
100
|
+
function findArr(record, predicate) {
|
|
101
|
+
for (let i = 0; i < record.length; i++) {
|
|
102
|
+
const value = record[i];
|
|
103
|
+
if (predicate(value)) {
|
|
104
|
+
return value;
|
|
558
105
|
}
|
|
559
|
-
return e;
|
|
560
|
-
}
|
|
561
|
-
__name(_objectSpread2, "_objectSpread2");
|
|
562
|
-
module2.exports = _objectSpread2, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
563
|
-
} });
|
|
564
|
-
var import_objectSpread2 = __toESM3(require_objectSpread22(), 1);
|
|
565
|
-
|
|
566
|
-
// ../../node_modules/@trpc/server/dist/tracked-DWInO6EQ.mjs
|
|
567
|
-
var import_defineProperty = __toESM3(require_defineProperty2(), 1);
|
|
568
|
-
var import_objectSpread2$1 = __toESM3(require_objectSpread22(), 1);
|
|
569
|
-
function transformResultInner(response, transformer) {
|
|
570
|
-
if ("error" in response) {
|
|
571
|
-
const error = transformer.deserialize(response.error);
|
|
572
|
-
return {
|
|
573
|
-
ok: false,
|
|
574
|
-
error: (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, response), {}, { error })
|
|
575
|
-
};
|
|
576
106
|
}
|
|
577
|
-
|
|
578
|
-
type: "data",
|
|
579
|
-
data: transformer.deserialize(response.result.data)
|
|
580
|
-
});
|
|
581
|
-
return {
|
|
582
|
-
ok: true,
|
|
583
|
-
result
|
|
584
|
-
};
|
|
107
|
+
return void 0;
|
|
585
108
|
}
|
|
586
|
-
|
|
587
|
-
var TransformResultError = class extends Error {
|
|
588
|
-
static {
|
|
589
|
-
__name(this, "TransformResultError");
|
|
590
|
-
}
|
|
109
|
+
class CustomTransformerRegistry {
|
|
591
110
|
constructor() {
|
|
592
|
-
|
|
111
|
+
this.transfomers = {};
|
|
593
112
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
}
|
|
600
|
-
|
|
113
|
+
register(transformer) {
|
|
114
|
+
this.transfomers[transformer.name] = transformer;
|
|
115
|
+
}
|
|
116
|
+
findApplicable(v) {
|
|
117
|
+
return find(this.transfomers, (transformer) => transformer.isApplicable(v));
|
|
118
|
+
}
|
|
119
|
+
findByName(name) {
|
|
120
|
+
return this.transfomers[name];
|
|
601
121
|
}
|
|
602
|
-
if (!result.ok && (!isObject(result.error.error) || typeof result.error.error["code"] !== "number")) throw new TransformResultError();
|
|
603
|
-
if (result.ok && !isObject(result.result)) throw new TransformResultError();
|
|
604
|
-
return result;
|
|
605
|
-
}
|
|
606
|
-
__name(transformResult, "transformResult");
|
|
607
|
-
var import_objectSpread22 = __toESM3(require_objectSpread22(), 1);
|
|
608
|
-
|
|
609
|
-
// ../../node_modules/@trpc/client/dist/TRPCClientError-apv8gw59.mjs
|
|
610
|
-
var import_defineProperty2 = __toESM2(require_defineProperty(), 1);
|
|
611
|
-
var import_objectSpread23 = __toESM2(require_objectSpread2(), 1);
|
|
612
|
-
function isTRPCClientError(cause) {
|
|
613
|
-
return cause instanceof TRPCClientError;
|
|
614
|
-
}
|
|
615
|
-
__name(isTRPCClientError, "isTRPCClientError");
|
|
616
|
-
function isTRPCErrorResponse(obj) {
|
|
617
|
-
return isObject(obj) && isObject(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string";
|
|
618
|
-
}
|
|
619
|
-
__name(isTRPCErrorResponse, "isTRPCErrorResponse");
|
|
620
|
-
function getMessageFromUnknownError(err, fallback) {
|
|
621
|
-
if (typeof err === "string") return err;
|
|
622
|
-
if (isObject(err) && typeof err["message"] === "string") return err["message"];
|
|
623
|
-
return fallback;
|
|
624
122
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
123
|
+
const getType$1 = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
|
|
124
|
+
const isUndefined = (payload) => typeof payload === "undefined";
|
|
125
|
+
const isNull = (payload) => payload === null;
|
|
126
|
+
const isPlainObject$1 = (payload) => {
|
|
127
|
+
if (typeof payload !== "object" || payload === null)
|
|
128
|
+
return false;
|
|
129
|
+
if (payload === Object.prototype)
|
|
130
|
+
return false;
|
|
131
|
+
if (Object.getPrototypeOf(payload) === null)
|
|
132
|
+
return true;
|
|
133
|
+
return Object.getPrototypeOf(payload) === Object.prototype;
|
|
134
|
+
};
|
|
135
|
+
const isEmptyObject = (payload) => isPlainObject$1(payload) && Object.keys(payload).length === 0;
|
|
136
|
+
const isArray$1 = (payload) => Array.isArray(payload);
|
|
137
|
+
const isString = (payload) => typeof payload === "string";
|
|
138
|
+
const isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
|
|
139
|
+
const isBoolean = (payload) => typeof payload === "boolean";
|
|
140
|
+
const isRegExp = (payload) => payload instanceof RegExp;
|
|
141
|
+
const isMap = (payload) => payload instanceof Map;
|
|
142
|
+
const isSet = (payload) => payload instanceof Set;
|
|
143
|
+
const isSymbol = (payload) => getType$1(payload) === "Symbol";
|
|
144
|
+
const isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
|
|
145
|
+
const isError = (payload) => payload instanceof Error;
|
|
146
|
+
const isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
|
|
147
|
+
const isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
|
|
148
|
+
const isBigint = (payload) => typeof payload === "bigint";
|
|
149
|
+
const isInfinite = (payload) => payload === Infinity || payload === -Infinity;
|
|
150
|
+
const isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
|
|
151
|
+
const isURL = (payload) => payload instanceof URL;
|
|
152
|
+
const escapeKey = (key) => key.replace(/\\/g, "\\\\").replace(/\./g, "\\.");
|
|
153
|
+
const stringifyPath = (path) => path.map(String).map(escapeKey).join(".");
|
|
154
|
+
const parsePath = (string, legacyPaths) => {
|
|
155
|
+
const result = [];
|
|
156
|
+
let segment = "";
|
|
157
|
+
for (let i = 0; i < string.length; i++) {
|
|
158
|
+
let char = string.charAt(i);
|
|
159
|
+
if (!legacyPaths && char === "\\") {
|
|
160
|
+
const escaped = string.charAt(i + 1);
|
|
161
|
+
if (escaped === "\\") {
|
|
162
|
+
segment += "\\";
|
|
163
|
+
i++;
|
|
164
|
+
continue;
|
|
165
|
+
} else if (escaped !== ".") {
|
|
166
|
+
throw Error("invalid path");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const isEscapedDot = char === "\\" && string.charAt(i + 1) === ".";
|
|
170
|
+
if (isEscapedDot) {
|
|
171
|
+
segment += ".";
|
|
172
|
+
i++;
|
|
173
|
+
continue;
|
|
650
174
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
175
|
+
const isEndOfSegment = char === ".";
|
|
176
|
+
if (isEndOfSegment) {
|
|
177
|
+
result.push(segment);
|
|
178
|
+
segment = "";
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
segment += char;
|
|
656
182
|
}
|
|
183
|
+
const lastSegment = segment;
|
|
184
|
+
result.push(lastSegment);
|
|
185
|
+
return result;
|
|
657
186
|
};
|
|
658
|
-
|
|
659
|
-
// ../../node_modules/@trpc/client/dist/unstable-internals-Bg7n9BBj.mjs
|
|
660
|
-
function getTransformer(transformer) {
|
|
661
|
-
const _transformer = transformer;
|
|
662
|
-
if (!_transformer) return {
|
|
663
|
-
input: {
|
|
664
|
-
serialize: /* @__PURE__ */ __name((data) => data, "serialize"),
|
|
665
|
-
deserialize: /* @__PURE__ */ __name((data) => data, "deserialize")
|
|
666
|
-
},
|
|
667
|
-
output: {
|
|
668
|
-
serialize: /* @__PURE__ */ __name((data) => data, "serialize"),
|
|
669
|
-
deserialize: /* @__PURE__ */ __name((data) => data, "deserialize")
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
if ("input" in _transformer) return _transformer;
|
|
187
|
+
function simpleTransformation(isApplicable, annotation, transform, untransform) {
|
|
673
188
|
return {
|
|
674
|
-
|
|
675
|
-
|
|
189
|
+
isApplicable,
|
|
190
|
+
annotation,
|
|
191
|
+
transform,
|
|
192
|
+
untransform
|
|
676
193
|
};
|
|
677
194
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
195
|
+
const simpleRules = [
|
|
196
|
+
simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
|
|
197
|
+
simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
|
|
198
|
+
if (typeof BigInt !== "undefined") {
|
|
199
|
+
return BigInt(v);
|
|
200
|
+
}
|
|
201
|
+
console.error("Please add a BigInt polyfill.");
|
|
202
|
+
return v;
|
|
203
|
+
}),
|
|
204
|
+
simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
|
|
205
|
+
simpleTransformation(isError, "Error", (v, superJson) => {
|
|
206
|
+
const baseError = {
|
|
207
|
+
name: v.name,
|
|
208
|
+
message: v.message
|
|
209
|
+
};
|
|
210
|
+
if ("cause" in v) {
|
|
211
|
+
baseError.cause = v.cause;
|
|
212
|
+
}
|
|
213
|
+
superJson.allowedErrorProps.forEach((prop) => {
|
|
214
|
+
baseError[prop] = v[prop];
|
|
215
|
+
});
|
|
216
|
+
return baseError;
|
|
217
|
+
}, (v, superJson) => {
|
|
218
|
+
const e = new Error(v.message, { cause: v.cause });
|
|
219
|
+
e.name = v.name;
|
|
220
|
+
e.stack = v.stack;
|
|
221
|
+
superJson.allowedErrorProps.forEach((prop) => {
|
|
222
|
+
e[prop] = v[prop];
|
|
223
|
+
});
|
|
224
|
+
return e;
|
|
225
|
+
}),
|
|
226
|
+
simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
|
|
227
|
+
const body = regex.slice(1, regex.lastIndexOf("/"));
|
|
228
|
+
const flags = regex.slice(regex.lastIndexOf("/") + 1);
|
|
229
|
+
return new RegExp(body, flags);
|
|
230
|
+
}),
|
|
231
|
+
simpleTransformation(
|
|
232
|
+
isSet,
|
|
233
|
+
"set",
|
|
234
|
+
// (sets only exist in es6+)
|
|
235
|
+
// eslint-disable-next-line es5/no-es6-methods
|
|
236
|
+
(v) => [...v.values()],
|
|
237
|
+
(v) => new Set(v)
|
|
238
|
+
),
|
|
239
|
+
simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
|
|
240
|
+
simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
|
|
241
|
+
if (isNaNValue(v)) {
|
|
242
|
+
return "NaN";
|
|
243
|
+
}
|
|
244
|
+
if (v > 0) {
|
|
245
|
+
return "Infinity";
|
|
246
|
+
} else {
|
|
247
|
+
return "-Infinity";
|
|
248
|
+
}
|
|
249
|
+
}, Number),
|
|
250
|
+
simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
|
|
251
|
+
return "-0";
|
|
252
|
+
}, Number),
|
|
253
|
+
simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
|
|
254
|
+
];
|
|
255
|
+
function compositeTransformation(isApplicable, annotation, transform, untransform) {
|
|
691
256
|
return {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
257
|
+
isApplicable,
|
|
258
|
+
annotation,
|
|
259
|
+
transform,
|
|
260
|
+
untransform
|
|
696
261
|
};
|
|
697
262
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
263
|
+
const symbolRule = compositeTransformation((s, superJson) => {
|
|
264
|
+
if (isSymbol(s)) {
|
|
265
|
+
const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
|
|
266
|
+
return isRegistered;
|
|
267
|
+
}
|
|
268
|
+
return false;
|
|
269
|
+
}, (s, superJson) => {
|
|
270
|
+
const identifier = superJson.symbolRegistry.getIdentifier(s);
|
|
271
|
+
return ["symbol", identifier];
|
|
272
|
+
}, (v) => v.description, (_, a, superJson) => {
|
|
273
|
+
const value = superJson.symbolRegistry.getValue(a[1]);
|
|
274
|
+
if (!value) {
|
|
275
|
+
throw new Error("Trying to deserialize unknown symbol");
|
|
276
|
+
}
|
|
277
|
+
return value;
|
|
278
|
+
});
|
|
279
|
+
const constructorToName = [
|
|
280
|
+
Int8Array,
|
|
281
|
+
Uint8Array,
|
|
282
|
+
Int16Array,
|
|
283
|
+
Uint16Array,
|
|
284
|
+
Int32Array,
|
|
285
|
+
Uint32Array,
|
|
286
|
+
Float32Array,
|
|
287
|
+
Float64Array,
|
|
288
|
+
Uint8ClampedArray
|
|
289
|
+
].reduce((obj, ctor) => {
|
|
290
|
+
obj[ctor.name] = ctor;
|
|
291
|
+
return obj;
|
|
292
|
+
}, {});
|
|
293
|
+
const typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
|
|
294
|
+
const ctor = constructorToName[a[1]];
|
|
295
|
+
if (!ctor) {
|
|
296
|
+
throw new Error("Trying to deserialize unknown typed array");
|
|
297
|
+
}
|
|
298
|
+
return new ctor(v);
|
|
299
|
+
});
|
|
300
|
+
function isInstanceOfRegisteredClass(potentialClass, superJson) {
|
|
301
|
+
if (potentialClass?.constructor) {
|
|
302
|
+
const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
|
|
303
|
+
return isRegistered;
|
|
304
|
+
}
|
|
305
|
+
return false;
|
|
715
306
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
const input = getInput(opts);
|
|
734
|
-
return input !== void 0 ? JSON.stringify(input) : void 0;
|
|
735
|
-
}, "getBody");
|
|
736
|
-
var jsonHttpRequester = /* @__PURE__ */ __name((opts) => {
|
|
737
|
-
return httpRequest((0, import_objectSpread24.default)((0, import_objectSpread24.default)({}, opts), {}, {
|
|
738
|
-
contentTypeHeader: "application/json",
|
|
739
|
-
getUrl,
|
|
740
|
-
getBody
|
|
741
|
-
}));
|
|
742
|
-
}, "jsonHttpRequester");
|
|
743
|
-
var AbortError = class extends Error {
|
|
744
|
-
static {
|
|
745
|
-
__name(this, "AbortError");
|
|
307
|
+
const classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
|
|
308
|
+
const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
|
|
309
|
+
return ["class", identifier];
|
|
310
|
+
}, (clazz, superJson) => {
|
|
311
|
+
const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
|
|
312
|
+
if (!allowedProps) {
|
|
313
|
+
return { ...clazz };
|
|
314
|
+
}
|
|
315
|
+
const result = {};
|
|
316
|
+
allowedProps.forEach((prop) => {
|
|
317
|
+
result[prop] = clazz[prop];
|
|
318
|
+
});
|
|
319
|
+
return result;
|
|
320
|
+
}, (v, a, superJson) => {
|
|
321
|
+
const clazz = superJson.classRegistry.getValue(a[1]);
|
|
322
|
+
if (!clazz) {
|
|
323
|
+
throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
|
|
746
324
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
325
|
+
return Object.assign(Object.create(clazz.prototype), v);
|
|
326
|
+
});
|
|
327
|
+
const customRule = compositeTransformation((value, superJson) => {
|
|
328
|
+
return !!superJson.customTransformerRegistry.findApplicable(value);
|
|
329
|
+
}, (value, superJson) => {
|
|
330
|
+
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
|
331
|
+
return ["custom", transformer.name];
|
|
332
|
+
}, (value, superJson) => {
|
|
333
|
+
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
|
334
|
+
return transformer.serialize(value);
|
|
335
|
+
}, (v, a, superJson) => {
|
|
336
|
+
const transformer = superJson.customTransformerRegistry.findByName(a[1]);
|
|
337
|
+
if (!transformer) {
|
|
338
|
+
throw new Error("Trying to deserialize unknown custom value");
|
|
339
|
+
}
|
|
340
|
+
return transformer.deserialize(v);
|
|
341
|
+
});
|
|
342
|
+
const compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
|
|
343
|
+
const transformValue = (value, superJson) => {
|
|
344
|
+
const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
|
|
345
|
+
if (applicableCompositeRule) {
|
|
346
|
+
return {
|
|
347
|
+
value: applicableCompositeRule.transform(value, superJson),
|
|
348
|
+
type: applicableCompositeRule.annotation(value, superJson)
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
|
|
352
|
+
if (applicableSimpleRule) {
|
|
353
|
+
return {
|
|
354
|
+
value: applicableSimpleRule.transform(value, superJson),
|
|
355
|
+
type: applicableSimpleRule.annotation
|
|
356
|
+
};
|
|
752
357
|
}
|
|
358
|
+
return void 0;
|
|
753
359
|
};
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
})();
|
|
772
|
-
const headers = (0, import_objectSpread24.default)((0, import_objectSpread24.default)((0, import_objectSpread24.default)({}, opts.contentTypeHeader && method !== "GET" ? { "content-type": opts.contentTypeHeader } : {}), opts.trpcAcceptHeader ? { [(_opts$trpcAcceptHeade = opts.trpcAcceptHeaderKey) !== null && _opts$trpcAcceptHeade !== void 0 ? _opts$trpcAcceptHeade : "trpc-accept"]: opts.trpcAcceptHeader } : void 0), resolvedHeaders);
|
|
773
|
-
return getFetch(opts.fetch)(url, {
|
|
774
|
-
method,
|
|
775
|
-
signal: opts.signal,
|
|
776
|
-
body,
|
|
777
|
-
headers
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
__name(fetchHTTPResponse, "fetchHTTPResponse");
|
|
781
|
-
async function httpRequest(opts) {
|
|
782
|
-
const meta = {};
|
|
783
|
-
const res = await fetchHTTPResponse(opts);
|
|
784
|
-
meta.response = res;
|
|
785
|
-
const json = await res.json();
|
|
786
|
-
meta.responseJSON = json;
|
|
787
|
-
return {
|
|
788
|
-
json,
|
|
789
|
-
meta
|
|
790
|
-
};
|
|
791
|
-
}
|
|
792
|
-
__name(httpRequest, "httpRequest");
|
|
793
|
-
|
|
794
|
-
// ../../node_modules/@trpc/client/dist/httpLink-lG_6juPY.mjs
|
|
795
|
-
function isOctetType(input) {
|
|
796
|
-
return input instanceof Uint8Array || input instanceof Blob;
|
|
797
|
-
}
|
|
798
|
-
__name(isOctetType, "isOctetType");
|
|
799
|
-
function isFormData(input) {
|
|
800
|
-
return input instanceof FormData;
|
|
801
|
-
}
|
|
802
|
-
__name(isFormData, "isFormData");
|
|
803
|
-
var import_objectSpread25 = __toESM2(require_objectSpread2(), 1);
|
|
804
|
-
var universalRequester = /* @__PURE__ */ __name((opts) => {
|
|
805
|
-
if ("input" in opts) {
|
|
806
|
-
const { input } = opts;
|
|
807
|
-
if (isFormData(input)) {
|
|
808
|
-
if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("FormData is only supported for mutations");
|
|
809
|
-
return httpRequest((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, opts), {}, {
|
|
810
|
-
contentTypeHeader: void 0,
|
|
811
|
-
getUrl,
|
|
812
|
-
getBody: /* @__PURE__ */ __name(() => input, "getBody")
|
|
813
|
-
}));
|
|
360
|
+
const simpleRulesByAnnotation = {};
|
|
361
|
+
simpleRules.forEach((rule) => {
|
|
362
|
+
simpleRulesByAnnotation[rule.annotation] = rule;
|
|
363
|
+
});
|
|
364
|
+
const untransformValue = (json, type, superJson) => {
|
|
365
|
+
if (isArray$1(type)) {
|
|
366
|
+
switch (type[0]) {
|
|
367
|
+
case "symbol":
|
|
368
|
+
return symbolRule.untransform(json, type, superJson);
|
|
369
|
+
case "class":
|
|
370
|
+
return classRule.untransform(json, type, superJson);
|
|
371
|
+
case "custom":
|
|
372
|
+
return customRule.untransform(json, type, superJson);
|
|
373
|
+
case "typed-array":
|
|
374
|
+
return typedArrayRule.untransform(json, type, superJson);
|
|
375
|
+
default:
|
|
376
|
+
throw new Error("Unknown transformation: " + type);
|
|
814
377
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
getUrl,
|
|
820
|
-
getBody: /* @__PURE__ */ __name(() => input, "getBody")
|
|
821
|
-
}));
|
|
378
|
+
} else {
|
|
379
|
+
const transformation = simpleRulesByAnnotation[type];
|
|
380
|
+
if (!transformation) {
|
|
381
|
+
throw new Error("Unknown transformation: " + type);
|
|
822
382
|
}
|
|
383
|
+
return transformation.untransform(json, superJson);
|
|
823
384
|
}
|
|
824
|
-
return jsonHttpRequester(opts);
|
|
825
|
-
}, "universalRequester");
|
|
826
|
-
function httpLink(opts) {
|
|
827
|
-
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
828
|
-
return () => {
|
|
829
|
-
return (operationOpts) => {
|
|
830
|
-
const { op } = operationOpts;
|
|
831
|
-
return observable((observer) => {
|
|
832
|
-
const { path, input, type } = op;
|
|
833
|
-
if (type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
|
|
834
|
-
const request = universalRequester((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, resolvedOpts), {}, {
|
|
835
|
-
type,
|
|
836
|
-
path,
|
|
837
|
-
input,
|
|
838
|
-
signal: op.signal,
|
|
839
|
-
headers() {
|
|
840
|
-
if (!opts.headers) return {};
|
|
841
|
-
if (typeof opts.headers === "function") return opts.headers({ op });
|
|
842
|
-
return opts.headers;
|
|
843
|
-
}
|
|
844
|
-
}));
|
|
845
|
-
let meta = void 0;
|
|
846
|
-
request.then((res) => {
|
|
847
|
-
meta = res.meta;
|
|
848
|
-
const transformed = transformResult(res.json, resolvedOpts.transformer.output);
|
|
849
|
-
if (!transformed.ok) {
|
|
850
|
-
observer.error(TRPCClientError.from(transformed.error, { meta }));
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
observer.next({
|
|
854
|
-
context: res.meta,
|
|
855
|
-
result: transformed.result
|
|
856
|
-
});
|
|
857
|
-
observer.complete();
|
|
858
|
-
}).catch((cause) => {
|
|
859
|
-
observer.error(TRPCClientError.from(cause, { meta }));
|
|
860
|
-
});
|
|
861
|
-
return () => {
|
|
862
|
-
};
|
|
863
|
-
});
|
|
864
|
-
};
|
|
865
|
-
};
|
|
866
|
-
}
|
|
867
|
-
__name(httpLink, "httpLink");
|
|
868
|
-
|
|
869
|
-
// ../../node_modules/@trpc/client/dist/httpBatchLink-LhidKAPw.mjs
|
|
870
|
-
var import_objectSpread26 = __toESM2(require_objectSpread2(), 1);
|
|
871
|
-
|
|
872
|
-
// ../../node_modules/@trpc/client/dist/loggerLink-ineCN1PO.mjs
|
|
873
|
-
var import_objectSpread27 = __toESM2(require_objectSpread2(), 1);
|
|
874
|
-
|
|
875
|
-
// ../../node_modules/@trpc/client/dist/wsLink-DSf4KOdW.mjs
|
|
876
|
-
var jsonEncoder = {
|
|
877
|
-
encode: /* @__PURE__ */ __name((data) => JSON.stringify(data), "encode"),
|
|
878
|
-
decode: /* @__PURE__ */ __name((data) => {
|
|
879
|
-
if (typeof data !== "string") throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");
|
|
880
|
-
return JSON.parse(data);
|
|
881
|
-
}, "decode")
|
|
882
|
-
};
|
|
883
|
-
var lazyDefaults = {
|
|
884
|
-
enabled: false,
|
|
885
|
-
closeMs: 0
|
|
886
|
-
};
|
|
887
|
-
var keepAliveDefaults = {
|
|
888
|
-
enabled: false,
|
|
889
|
-
pongTimeoutMs: 1e3,
|
|
890
|
-
intervalMs: 5e3
|
|
891
385
|
};
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
__name(this, "TRPCWebSocketClosedError");
|
|
902
|
-
}
|
|
903
|
-
constructor(opts) {
|
|
904
|
-
super(opts.message, { cause: opts.cause });
|
|
905
|
-
this.name = "TRPCWebSocketClosedError";
|
|
906
|
-
Object.setPrototypeOf(this, TRPCWebSocketClosedError2.prototype);
|
|
907
|
-
}
|
|
386
|
+
const getNthKey = (value, n) => {
|
|
387
|
+
if (n > value.size)
|
|
388
|
+
throw new Error("index out of bounds");
|
|
389
|
+
const keys = value.keys();
|
|
390
|
+
while (n > 0) {
|
|
391
|
+
keys.next();
|
|
392
|
+
n--;
|
|
393
|
+
}
|
|
394
|
+
return keys.next().value;
|
|
908
395
|
};
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
396
|
+
function validatePath(path) {
|
|
397
|
+
if (includes(path, "__proto__")) {
|
|
398
|
+
throw new Error("__proto__ is not allowed as a property");
|
|
912
399
|
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
this.timeoutMs = timeoutMs;
|
|
916
|
-
(0, import_defineProperty$3.default)(this, "timeout", void 0);
|
|
400
|
+
if (includes(path, "prototype")) {
|
|
401
|
+
throw new Error("prototype is not allowed as a property");
|
|
917
402
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
* Does nothing if no timeout is active.
|
|
921
|
-
*/
|
|
922
|
-
reset() {
|
|
923
|
-
if (!this.timeout) return;
|
|
924
|
-
clearTimeout(this.timeout);
|
|
925
|
-
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
|
926
|
-
}
|
|
927
|
-
start() {
|
|
928
|
-
clearTimeout(this.timeout);
|
|
929
|
-
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
|
930
|
-
}
|
|
931
|
-
stop() {
|
|
932
|
-
clearTimeout(this.timeout);
|
|
933
|
-
this.timeout = void 0;
|
|
403
|
+
if (includes(path, "constructor")) {
|
|
404
|
+
throw new Error("constructor is not allowed as a property");
|
|
934
405
|
}
|
|
935
|
-
};
|
|
936
|
-
function withResolvers() {
|
|
937
|
-
let resolve;
|
|
938
|
-
let reject;
|
|
939
|
-
const promise = new Promise((res, rej) => {
|
|
940
|
-
resolve = res;
|
|
941
|
-
reject = rej;
|
|
942
|
-
});
|
|
943
|
-
return {
|
|
944
|
-
promise,
|
|
945
|
-
resolve,
|
|
946
|
-
reject
|
|
947
|
-
};
|
|
948
406
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
var import_defineProperty$2 = __toESM2(require_defineProperty(), 1);
|
|
967
|
-
var RequestManager = class {
|
|
968
|
-
static {
|
|
969
|
-
__name(this, "RequestManager");
|
|
970
|
-
}
|
|
971
|
-
constructor() {
|
|
972
|
-
(0, import_defineProperty$2.default)(this, "outgoingRequests", new Array());
|
|
973
|
-
(0, import_defineProperty$2.default)(this, "pendingRequests", {});
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Registers a new request by adding it to the outgoing queue and setting up
|
|
977
|
-
* callbacks for lifecycle events such as completion or error.
|
|
978
|
-
*
|
|
979
|
-
* @param message - The outgoing message to be sent.
|
|
980
|
-
* @param callbacks - Callback functions to observe the request's state.
|
|
981
|
-
* @returns A cleanup function to manually remove the request.
|
|
982
|
-
*/
|
|
983
|
-
register(message, callbacks) {
|
|
984
|
-
const { promise: end, resolve } = withResolvers();
|
|
985
|
-
this.outgoingRequests.push({
|
|
986
|
-
id: String(message.id),
|
|
987
|
-
message,
|
|
988
|
-
end,
|
|
989
|
-
callbacks: {
|
|
990
|
-
next: callbacks.next,
|
|
991
|
-
complete: /* @__PURE__ */ __name(() => {
|
|
992
|
-
callbacks.complete();
|
|
993
|
-
resolve();
|
|
994
|
-
}, "complete"),
|
|
995
|
-
error: /* @__PURE__ */ __name((e) => {
|
|
996
|
-
callbacks.error(e);
|
|
997
|
-
resolve();
|
|
998
|
-
}, "error")
|
|
407
|
+
const getDeep = (object, path) => {
|
|
408
|
+
validatePath(path);
|
|
409
|
+
for (let i = 0; i < path.length; i++) {
|
|
410
|
+
const key = path[i];
|
|
411
|
+
if (isSet(object)) {
|
|
412
|
+
object = getNthKey(object, +key);
|
|
413
|
+
} else if (isMap(object)) {
|
|
414
|
+
const row = +key;
|
|
415
|
+
const type = +path[++i] === 0 ? "key" : "value";
|
|
416
|
+
const keyOfRow = getNthKey(object, row);
|
|
417
|
+
switch (type) {
|
|
418
|
+
case "key":
|
|
419
|
+
object = keyOfRow;
|
|
420
|
+
break;
|
|
421
|
+
case "value":
|
|
422
|
+
object = object.get(keyOfRow);
|
|
423
|
+
break;
|
|
999
424
|
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
callbacks.complete();
|
|
1004
|
-
resolve();
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
|
-
/**
|
|
1008
|
-
* Deletes a request from both the outgoing and pending collections, if it exists.
|
|
1009
|
-
*/
|
|
1010
|
-
delete(messageId) {
|
|
1011
|
-
if (messageId === null) return;
|
|
1012
|
-
this.outgoingRequests = this.outgoingRequests.filter(({ id }) => id !== String(messageId));
|
|
1013
|
-
delete this.pendingRequests[String(messageId)];
|
|
1014
|
-
}
|
|
1015
|
-
/**
|
|
1016
|
-
* Moves all outgoing requests to the pending state and clears the outgoing queue.
|
|
1017
|
-
*
|
|
1018
|
-
* The caller is expected to handle the actual sending of the requests
|
|
1019
|
-
* (e.g., sending them over the network) after this method is called.
|
|
1020
|
-
*
|
|
1021
|
-
* @returns The list of requests that were transitioned to the pending state.
|
|
1022
|
-
*/
|
|
1023
|
-
flush() {
|
|
1024
|
-
const requests = this.outgoingRequests;
|
|
1025
|
-
this.outgoingRequests = [];
|
|
1026
|
-
for (const request of requests) this.pendingRequests[request.id] = request;
|
|
1027
|
-
return requests;
|
|
425
|
+
} else {
|
|
426
|
+
object = object[key];
|
|
427
|
+
}
|
|
1028
428
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
return
|
|
429
|
+
return object;
|
|
430
|
+
};
|
|
431
|
+
const setDeep = (object, path, mapper) => {
|
|
432
|
+
validatePath(path);
|
|
433
|
+
if (path.length === 0) {
|
|
434
|
+
return mapper(object);
|
|
435
|
+
}
|
|
436
|
+
let parent = object;
|
|
437
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
438
|
+
const key = path[i];
|
|
439
|
+
if (isArray$1(parent)) {
|
|
440
|
+
const index = +key;
|
|
441
|
+
parent = parent[index];
|
|
442
|
+
} else if (isPlainObject$1(parent)) {
|
|
443
|
+
parent = parent[key];
|
|
444
|
+
} else if (isSet(parent)) {
|
|
445
|
+
const row = +key;
|
|
446
|
+
parent = getNthKey(parent, row);
|
|
447
|
+
} else if (isMap(parent)) {
|
|
448
|
+
const isEnd = i === path.length - 2;
|
|
449
|
+
if (isEnd) {
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
const row = +key;
|
|
453
|
+
const type = +path[++i] === 0 ? "key" : "value";
|
|
454
|
+
const keyOfRow = getNthKey(parent, row);
|
|
455
|
+
switch (type) {
|
|
456
|
+
case "key":
|
|
457
|
+
parent = keyOfRow;
|
|
458
|
+
break;
|
|
459
|
+
case "value":
|
|
460
|
+
parent = parent.get(keyOfRow);
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
1035
464
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
465
|
+
const lastKey = path[path.length - 1];
|
|
466
|
+
if (isArray$1(parent)) {
|
|
467
|
+
parent[+lastKey] = mapper(parent[+lastKey]);
|
|
468
|
+
} else if (isPlainObject$1(parent)) {
|
|
469
|
+
parent[lastKey] = mapper(parent[lastKey]);
|
|
470
|
+
}
|
|
471
|
+
if (isSet(parent)) {
|
|
472
|
+
const oldValue = getNthKey(parent, +lastKey);
|
|
473
|
+
const newValue = mapper(oldValue);
|
|
474
|
+
if (oldValue !== newValue) {
|
|
475
|
+
parent.delete(oldValue);
|
|
476
|
+
parent.add(newValue);
|
|
477
|
+
}
|
|
1042
478
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
479
|
+
if (isMap(parent)) {
|
|
480
|
+
const row = +path[path.length - 2];
|
|
481
|
+
const keyToRow = getNthKey(parent, row);
|
|
482
|
+
const type = +lastKey === 0 ? "key" : "value";
|
|
483
|
+
switch (type) {
|
|
484
|
+
case "key": {
|
|
485
|
+
const newKey = mapper(keyToRow);
|
|
486
|
+
parent.set(newKey, parent.get(keyToRow));
|
|
487
|
+
if (newKey !== keyToRow) {
|
|
488
|
+
parent.delete(keyToRow);
|
|
489
|
+
}
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
case "value": {
|
|
493
|
+
parent.set(keyToRow, mapper(parent.get(keyToRow)));
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
1048
497
|
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
498
|
+
return object;
|
|
499
|
+
};
|
|
500
|
+
const enableLegacyPaths = (version) => version < 1;
|
|
501
|
+
function traverse(tree, walker2, version, origin = []) {
|
|
502
|
+
if (!tree) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
const legacyPaths = enableLegacyPaths(version);
|
|
506
|
+
if (!isArray$1(tree)) {
|
|
507
|
+
forEach(tree, (subtree, key) => traverse(subtree, walker2, version, [
|
|
508
|
+
...origin,
|
|
509
|
+
...parsePath(key, legacyPaths)
|
|
510
|
+
]));
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const [nodeValue, children] = tree;
|
|
514
|
+
if (children) {
|
|
515
|
+
forEach(children, (child, key) => {
|
|
516
|
+
traverse(child, walker2, version, [
|
|
517
|
+
...origin,
|
|
518
|
+
...parsePath(key, legacyPaths)
|
|
519
|
+
]);
|
|
520
|
+
});
|
|
1066
521
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
522
|
+
walker2(nodeValue, origin);
|
|
523
|
+
}
|
|
524
|
+
function applyValueAnnotations(plain, annotations, version, superJson) {
|
|
525
|
+
traverse(annotations, (type, path) => {
|
|
526
|
+
plain = setDeep(plain, path, (v) => untransformValue(v, type, superJson));
|
|
527
|
+
}, version);
|
|
528
|
+
return plain;
|
|
529
|
+
}
|
|
530
|
+
function applyReferentialEqualityAnnotations(plain, annotations, version) {
|
|
531
|
+
const legacyPaths = enableLegacyPaths(version);
|
|
532
|
+
function apply(identicalPaths, path) {
|
|
533
|
+
const object = getDeep(plain, parsePath(path, legacyPaths));
|
|
534
|
+
identicalPaths.map((path2) => parsePath(path2, legacyPaths)).forEach((identicalObjectPath) => {
|
|
535
|
+
plain = setDeep(plain, identicalObjectPath, () => object);
|
|
536
|
+
});
|
|
1072
537
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
538
|
+
if (isArray$1(annotations)) {
|
|
539
|
+
const [root, other] = annotations;
|
|
540
|
+
root.forEach((identicalPath) => {
|
|
541
|
+
plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
|
|
542
|
+
});
|
|
543
|
+
if (other) {
|
|
544
|
+
forEach(other, apply);
|
|
545
|
+
}
|
|
546
|
+
} else {
|
|
547
|
+
forEach(annotations, apply);
|
|
1078
548
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
549
|
+
return plain;
|
|
550
|
+
}
|
|
551
|
+
const isDeep = (object, superJson) => isPlainObject$1(object) || isArray$1(object) || isMap(object) || isSet(object) || isError(object) || isInstanceOfRegisteredClass(object, superJson);
|
|
552
|
+
function addIdentity(object, path, identities) {
|
|
553
|
+
const existingSet = identities.get(object);
|
|
554
|
+
if (existingSet) {
|
|
555
|
+
existingSet.push(path);
|
|
556
|
+
} else {
|
|
557
|
+
identities.set(object, [path]);
|
|
1084
558
|
}
|
|
1085
|
-
};
|
|
1086
|
-
var import_defineProperty$1 = __toESM2(require_defineProperty(), 1);
|
|
1087
|
-
function asyncWsOpen(ws) {
|
|
1088
|
-
const { promise, resolve, reject } = withResolvers();
|
|
1089
|
-
ws.addEventListener("open", () => {
|
|
1090
|
-
ws.removeEventListener("error", reject);
|
|
1091
|
-
resolve();
|
|
1092
|
-
});
|
|
1093
|
-
ws.addEventListener("error", reject);
|
|
1094
|
-
return promise;
|
|
1095
559
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
let
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
}
|
|
1113
|
-
__name(reset, "reset");
|
|
1114
|
-
function pong() {
|
|
1115
|
-
clearTimeout(pongTimeout);
|
|
1116
|
-
reset();
|
|
1117
|
-
}
|
|
1118
|
-
__name(pong, "pong");
|
|
1119
|
-
ws.addEventListener("open", start);
|
|
1120
|
-
ws.addEventListener("message", ({ data }) => {
|
|
1121
|
-
clearTimeout(pingTimeout);
|
|
1122
|
-
start();
|
|
1123
|
-
if (data === "PONG") pong();
|
|
1124
|
-
});
|
|
1125
|
-
ws.addEventListener("close", () => {
|
|
1126
|
-
clearTimeout(pingTimeout);
|
|
1127
|
-
clearTimeout(pongTimeout);
|
|
560
|
+
function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
561
|
+
const result = {};
|
|
562
|
+
let rootEqualityPaths = void 0;
|
|
563
|
+
identitites.forEach((paths) => {
|
|
564
|
+
if (paths.length <= 1) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
if (!dedupe) {
|
|
568
|
+
paths = paths.map((path) => path.map(String)).sort((a, b) => a.length - b.length);
|
|
569
|
+
}
|
|
570
|
+
const [representativePath, ...identicalPaths] = paths;
|
|
571
|
+
if (representativePath.length === 0) {
|
|
572
|
+
rootEqualityPaths = identicalPaths.map(stringifyPath);
|
|
573
|
+
} else {
|
|
574
|
+
result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
|
|
575
|
+
}
|
|
1128
576
|
});
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
(0, import_defineProperty$1.default)(this, "id", ++WsConnection2.connectCount);
|
|
1138
|
-
(0, import_defineProperty$1.default)(this, "WebSocketPonyfill", void 0);
|
|
1139
|
-
(0, import_defineProperty$1.default)(this, "urlOptions", void 0);
|
|
1140
|
-
(0, import_defineProperty$1.default)(this, "keepAliveOpts", void 0);
|
|
1141
|
-
(0, import_defineProperty$1.default)(this, "encoder", void 0);
|
|
1142
|
-
(0, import_defineProperty$1.default)(this, "wsObservable", behaviorSubject(null));
|
|
1143
|
-
(0, import_defineProperty$1.default)(this, "openPromise", null);
|
|
1144
|
-
this.WebSocketPonyfill = (_opts$WebSocketPonyfi = opts.WebSocketPonyfill) !== null && _opts$WebSocketPonyfi !== void 0 ? _opts$WebSocketPonyfi : WebSocket;
|
|
1145
|
-
if (!this.WebSocketPonyfill) throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
|
|
1146
|
-
this.urlOptions = opts.urlOptions;
|
|
1147
|
-
this.keepAliveOpts = opts.keepAlive;
|
|
1148
|
-
this.encoder = opts.encoder;
|
|
1149
|
-
}
|
|
1150
|
-
get ws() {
|
|
1151
|
-
return this.wsObservable.get();
|
|
1152
|
-
}
|
|
1153
|
-
set ws(ws) {
|
|
1154
|
-
this.wsObservable.next(ws);
|
|
1155
|
-
}
|
|
1156
|
-
/**
|
|
1157
|
-
* Checks if the WebSocket connection is open and ready to communicate.
|
|
1158
|
-
*/
|
|
1159
|
-
isOpen() {
|
|
1160
|
-
return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
|
|
577
|
+
if (rootEqualityPaths) {
|
|
578
|
+
if (isEmptyObject(result)) {
|
|
579
|
+
return [rootEqualityPaths];
|
|
580
|
+
} else {
|
|
581
|
+
return [rootEqualityPaths, result];
|
|
582
|
+
}
|
|
583
|
+
} else {
|
|
584
|
+
return isEmptyObject(result) ? void 0 : result;
|
|
1161
585
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
const wsPromise = prepareUrl(_this.urlOptions).then((url) => new _this.WebSocketPonyfill(url));
|
|
1173
|
-
_this.openPromise = wsPromise.then(async (ws) => {
|
|
1174
|
-
_this.ws = ws;
|
|
1175
|
-
ws.binaryType = "arraybuffer";
|
|
1176
|
-
ws.addEventListener("message", function({ data }) {
|
|
1177
|
-
if (data === "PING") this.send("PONG");
|
|
1178
|
-
});
|
|
1179
|
-
if (_this.keepAliveOpts.enabled) setupPingInterval(ws, _this.keepAliveOpts);
|
|
1180
|
-
ws.addEventListener("close", () => {
|
|
1181
|
-
if (_this.ws === ws) _this.ws = null;
|
|
1182
|
-
});
|
|
1183
|
-
await asyncWsOpen(ws);
|
|
1184
|
-
if (_this.urlOptions.connectionParams) ws.send(await buildConnectionMessage(_this.urlOptions.connectionParams, _this.encoder));
|
|
1185
|
-
});
|
|
1186
|
-
try {
|
|
1187
|
-
await _this.openPromise;
|
|
1188
|
-
} finally {
|
|
1189
|
-
_this.openPromise = null;
|
|
586
|
+
}
|
|
587
|
+
const walker = (object, identities, superJson, dedupe, path = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
|
|
588
|
+
const primitive = isPrimitive(object);
|
|
589
|
+
if (!primitive) {
|
|
590
|
+
addIdentity(object, path, identities);
|
|
591
|
+
const seen = seenObjects.get(object);
|
|
592
|
+
if (seen) {
|
|
593
|
+
return dedupe ? {
|
|
594
|
+
transformedValue: null
|
|
595
|
+
} : seen;
|
|
1190
596
|
}
|
|
1191
597
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
(_this$ws = _this2.ws) === null || _this$ws === void 0 || _this$ws.close();
|
|
598
|
+
if (!isDeep(object, superJson)) {
|
|
599
|
+
const transformed2 = transformValue(object, superJson);
|
|
600
|
+
const result2 = transformed2 ? {
|
|
601
|
+
transformedValue: transformed2.value,
|
|
602
|
+
annotations: [transformed2.type]
|
|
603
|
+
} : {
|
|
604
|
+
transformedValue: object
|
|
605
|
+
};
|
|
606
|
+
if (!primitive) {
|
|
607
|
+
seenObjects.set(object, result2);
|
|
1203
608
|
}
|
|
609
|
+
return result2;
|
|
1204
610
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
if (connection.isOpen()) return {
|
|
1209
|
-
id: connection.id,
|
|
1210
|
-
state: "open",
|
|
1211
|
-
ws: connection.ws
|
|
1212
|
-
};
|
|
1213
|
-
if (connection.isClosed()) return {
|
|
1214
|
-
id: connection.id,
|
|
1215
|
-
state: "closed",
|
|
1216
|
-
ws: connection.ws
|
|
1217
|
-
};
|
|
1218
|
-
if (!connection.ws) return null;
|
|
1219
|
-
return {
|
|
1220
|
-
id: connection.id,
|
|
1221
|
-
state: "connecting",
|
|
1222
|
-
ws: connection.ws
|
|
1223
|
-
};
|
|
1224
|
-
}
|
|
1225
|
-
__name(backwardCompatibility, "backwardCompatibility");
|
|
1226
|
-
var import_defineProperty3 = __toESM2(require_defineProperty(), 1);
|
|
1227
|
-
var import_objectSpread28 = __toESM2(require_objectSpread2(), 1);
|
|
1228
|
-
var WsClient = class {
|
|
1229
|
-
static {
|
|
1230
|
-
__name(this, "WsClient");
|
|
1231
|
-
}
|
|
1232
|
-
constructor(opts) {
|
|
1233
|
-
var _opts$experimental_en, _opts$retryDelayMs;
|
|
1234
|
-
(0, import_defineProperty3.default)(this, "connectionState", void 0);
|
|
1235
|
-
(0, import_defineProperty3.default)(this, "allowReconnect", false);
|
|
1236
|
-
(0, import_defineProperty3.default)(this, "requestManager", new RequestManager());
|
|
1237
|
-
(0, import_defineProperty3.default)(this, "activeConnection", void 0);
|
|
1238
|
-
(0, import_defineProperty3.default)(this, "reconnectRetryDelay", void 0);
|
|
1239
|
-
(0, import_defineProperty3.default)(this, "inactivityTimeout", void 0);
|
|
1240
|
-
(0, import_defineProperty3.default)(this, "callbacks", void 0);
|
|
1241
|
-
(0, import_defineProperty3.default)(this, "lazyMode", void 0);
|
|
1242
|
-
(0, import_defineProperty3.default)(this, "encoder", void 0);
|
|
1243
|
-
(0, import_defineProperty3.default)(this, "reconnecting", null);
|
|
1244
|
-
this.encoder = (_opts$experimental_en = opts.experimental_encoder) !== null && _opts$experimental_en !== void 0 ? _opts$experimental_en : jsonEncoder;
|
|
1245
|
-
this.callbacks = {
|
|
1246
|
-
onOpen: opts.onOpen,
|
|
1247
|
-
onClose: opts.onClose,
|
|
1248
|
-
onError: opts.onError
|
|
611
|
+
if (includes(objectsInThisPath, object)) {
|
|
612
|
+
return {
|
|
613
|
+
transformedValue: null
|
|
1249
614
|
};
|
|
1250
|
-
const lazyOptions = (0, import_objectSpread28.default)((0, import_objectSpread28.default)({}, lazyDefaults), opts.lazy);
|
|
1251
|
-
this.inactivityTimeout = new ResettableTimeout(() => {
|
|
1252
|
-
if (this.requestManager.hasOutgoingRequests() || this.requestManager.hasPendingRequests()) {
|
|
1253
|
-
this.inactivityTimeout.reset();
|
|
1254
|
-
return;
|
|
1255
|
-
}
|
|
1256
|
-
this.close().catch(() => null);
|
|
1257
|
-
}, lazyOptions.closeMs);
|
|
1258
|
-
this.activeConnection = new WsConnection({
|
|
1259
|
-
WebSocketPonyfill: opts.WebSocket,
|
|
1260
|
-
urlOptions: opts,
|
|
1261
|
-
keepAlive: (0, import_objectSpread28.default)((0, import_objectSpread28.default)({}, keepAliveDefaults), opts.keepAlive),
|
|
1262
|
-
encoder: this.encoder
|
|
1263
|
-
});
|
|
1264
|
-
this.activeConnection.wsObservable.subscribe({ next: /* @__PURE__ */ __name((ws) => {
|
|
1265
|
-
if (!ws) return;
|
|
1266
|
-
this.setupWebSocketListeners(ws);
|
|
1267
|
-
}, "next") });
|
|
1268
|
-
this.reconnectRetryDelay = (_opts$retryDelayMs = opts.retryDelayMs) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : exponentialBackoff;
|
|
1269
|
-
this.lazyMode = lazyOptions.enabled;
|
|
1270
|
-
this.connectionState = behaviorSubject({
|
|
1271
|
-
type: "state",
|
|
1272
|
-
state: lazyOptions.enabled ? "idle" : "connecting",
|
|
1273
|
-
error: null
|
|
1274
|
-
});
|
|
1275
|
-
if (!this.lazyMode) this.open().catch(() => null);
|
|
1276
615
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
if (_this.connectionState.get().state === "idle") _this.connectionState.next({
|
|
1285
|
-
type: "state",
|
|
1286
|
-
state: "connecting",
|
|
1287
|
-
error: null
|
|
1288
|
-
});
|
|
1289
|
-
try {
|
|
1290
|
-
await _this.activeConnection.open();
|
|
1291
|
-
} catch (error) {
|
|
1292
|
-
_this.reconnect(new TRPCWebSocketClosedError({
|
|
1293
|
-
message: "Initialization error",
|
|
1294
|
-
cause: error
|
|
1295
|
-
}));
|
|
1296
|
-
return _this.reconnecting;
|
|
616
|
+
const transformationResult = transformValue(object, superJson);
|
|
617
|
+
const transformed = transformationResult?.value ?? object;
|
|
618
|
+
const transformedValue = isArray$1(transformed) ? [] : {};
|
|
619
|
+
const innerAnnotations = {};
|
|
620
|
+
forEach(transformed, (value, index) => {
|
|
621
|
+
if (index === "__proto__" || index === "constructor" || index === "prototype") {
|
|
622
|
+
throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
|
|
1297
623
|
}
|
|
624
|
+
const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
|
|
625
|
+
transformedValue[index] = recursiveResult.transformedValue;
|
|
626
|
+
if (isArray$1(recursiveResult.annotations)) {
|
|
627
|
+
innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
|
|
628
|
+
} else if (isPlainObject$1(recursiveResult.annotations)) {
|
|
629
|
+
forEach(recursiveResult.annotations, (tree, key) => {
|
|
630
|
+
innerAnnotations[escapeKey(index) + "." + key] = tree;
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
const result = isEmptyObject(innerAnnotations) ? {
|
|
635
|
+
transformedValue,
|
|
636
|
+
annotations: !!transformationResult ? [transformationResult.type] : void 0
|
|
637
|
+
} : {
|
|
638
|
+
transformedValue,
|
|
639
|
+
annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
|
|
640
|
+
};
|
|
641
|
+
if (!primitive) {
|
|
642
|
+
seenObjects.set(object, result);
|
|
1298
643
|
}
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
644
|
+
return result;
|
|
645
|
+
};
|
|
646
|
+
function getType(payload) {
|
|
647
|
+
return Object.prototype.toString.call(payload).slice(8, -1);
|
|
648
|
+
}
|
|
649
|
+
function isArray(payload) {
|
|
650
|
+
return getType(payload) === "Array";
|
|
651
|
+
}
|
|
652
|
+
function isPlainObject(payload) {
|
|
653
|
+
if (getType(payload) !== "Object")
|
|
654
|
+
return false;
|
|
655
|
+
const prototype = Object.getPrototypeOf(payload);
|
|
656
|
+
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
|
|
657
|
+
}
|
|
658
|
+
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
|
|
659
|
+
const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
|
|
660
|
+
if (propType === "enumerable")
|
|
661
|
+
carry[key] = newVal;
|
|
662
|
+
if (includeNonenumerable && propType === "nonenumerable") {
|
|
663
|
+
Object.defineProperty(carry, key, {
|
|
664
|
+
value: newVal,
|
|
665
|
+
enumerable: false,
|
|
666
|
+
writable: true,
|
|
667
|
+
configurable: true
|
|
1317
668
|
});
|
|
1318
669
|
}
|
|
670
|
+
}
|
|
671
|
+
function copy(target, options = {}) {
|
|
672
|
+
if (isArray(target)) {
|
|
673
|
+
return target.map((item) => copy(item, options));
|
|
674
|
+
}
|
|
675
|
+
if (!isPlainObject(target)) {
|
|
676
|
+
return target;
|
|
677
|
+
}
|
|
678
|
+
const props = Object.getOwnPropertyNames(target);
|
|
679
|
+
const symbols = Object.getOwnPropertySymbols(target);
|
|
680
|
+
return [...props, ...symbols].reduce((carry, key) => {
|
|
681
|
+
if (key === "__proto__")
|
|
682
|
+
return carry;
|
|
683
|
+
if (isArray(options.props) && !options.props.includes(key)) {
|
|
684
|
+
return carry;
|
|
685
|
+
}
|
|
686
|
+
const val = target[key];
|
|
687
|
+
const newVal = copy(val, options);
|
|
688
|
+
assignProp(carry, key, newVal, target, options.nonenumerable);
|
|
689
|
+
return carry;
|
|
690
|
+
}, {});
|
|
691
|
+
}
|
|
692
|
+
class SuperJSON {
|
|
1319
693
|
/**
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
}, (0, import_objectSpread28.default)((0, import_objectSpread28.default)({}, observer), {}, { next(event) {
|
|
1340
|
-
const transformed = transformResult(event, transformer.output);
|
|
1341
|
-
if (!transformed.ok) {
|
|
1342
|
-
observer.error(TRPCClientError.from(transformed.error));
|
|
1343
|
-
return;
|
|
1344
|
-
}
|
|
1345
|
-
observer.next({ result: transformed.result });
|
|
1346
|
-
} }));
|
|
1347
|
-
return () => {
|
|
1348
|
-
abort();
|
|
1349
|
-
if (type === "subscription" && this.activeConnection.isOpen()) this.send({
|
|
1350
|
-
id,
|
|
1351
|
-
method: "subscription.stop"
|
|
1352
|
-
});
|
|
1353
|
-
signal === null || signal === void 0 || signal.removeEventListener("abort", abort);
|
|
694
|
+
* @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
|
|
695
|
+
*/
|
|
696
|
+
constructor({ dedupe = false } = {}) {
|
|
697
|
+
this.classRegistry = new ClassRegistry();
|
|
698
|
+
this.symbolRegistry = new Registry((s) => s.description ?? "");
|
|
699
|
+
this.customTransformerRegistry = new CustomTransformerRegistry();
|
|
700
|
+
this.allowedErrorProps = [];
|
|
701
|
+
this.dedupe = dedupe;
|
|
702
|
+
}
|
|
703
|
+
serialize(object) {
|
|
704
|
+
const identities = /* @__PURE__ */ new Map();
|
|
705
|
+
const output = walker(object, identities, this, this.dedupe);
|
|
706
|
+
const res = {
|
|
707
|
+
json: output.transformedValue
|
|
708
|
+
};
|
|
709
|
+
if (output.annotations) {
|
|
710
|
+
res.meta = {
|
|
711
|
+
...res.meta,
|
|
712
|
+
values: output.annotations
|
|
1354
713
|
};
|
|
1355
|
-
});
|
|
1356
|
-
}
|
|
1357
|
-
get connection() {
|
|
1358
|
-
return backwardCompatibility(this.activeConnection);
|
|
1359
|
-
}
|
|
1360
|
-
reconnect(closedError) {
|
|
1361
|
-
var _this3 = this;
|
|
1362
|
-
this.connectionState.next({
|
|
1363
|
-
type: "state",
|
|
1364
|
-
state: "connecting",
|
|
1365
|
-
error: TRPCClientError.from(closedError)
|
|
1366
|
-
});
|
|
1367
|
-
if (this.reconnecting) return;
|
|
1368
|
-
const tryReconnect = /* @__PURE__ */ __name(async (attemptIndex) => {
|
|
1369
|
-
try {
|
|
1370
|
-
await sleep(_this3.reconnectRetryDelay(attemptIndex));
|
|
1371
|
-
if (_this3.allowReconnect) {
|
|
1372
|
-
await _this3.activeConnection.close();
|
|
1373
|
-
await _this3.activeConnection.open();
|
|
1374
|
-
if (_this3.requestManager.hasPendingRequests()) _this3.send(_this3.requestManager.getPendingRequests().map(({ message }) => message));
|
|
1375
|
-
}
|
|
1376
|
-
_this3.reconnecting = null;
|
|
1377
|
-
} catch (_unused) {
|
|
1378
|
-
await tryReconnect(attemptIndex + 1);
|
|
1379
|
-
}
|
|
1380
|
-
}, "tryReconnect");
|
|
1381
|
-
this.reconnecting = tryReconnect(0);
|
|
1382
|
-
}
|
|
1383
|
-
setupWebSocketListeners(ws) {
|
|
1384
|
-
var _this4 = this;
|
|
1385
|
-
const handleCloseOrError = /* @__PURE__ */ __name((cause) => {
|
|
1386
|
-
const reqs = this.requestManager.getPendingRequests();
|
|
1387
|
-
for (const { message, callbacks } of reqs) {
|
|
1388
|
-
if (message.method === "subscription") continue;
|
|
1389
|
-
callbacks.error(TRPCClientError.from(cause !== null && cause !== void 0 ? cause : new TRPCWebSocketClosedError({
|
|
1390
|
-
message: "WebSocket closed",
|
|
1391
|
-
cause
|
|
1392
|
-
})));
|
|
1393
|
-
this.requestManager.delete(message.id);
|
|
1394
|
-
}
|
|
1395
|
-
}, "handleCloseOrError");
|
|
1396
|
-
ws.addEventListener("open", () => {
|
|
1397
|
-
run(async () => {
|
|
1398
|
-
var _this$callbacks$onOpe, _this$callbacks;
|
|
1399
|
-
if (_this4.lazyMode) _this4.inactivityTimeout.start();
|
|
1400
|
-
(_this$callbacks$onOpe = (_this$callbacks = _this4.callbacks).onOpen) === null || _this$callbacks$onOpe === void 0 || _this$callbacks$onOpe.call(_this$callbacks);
|
|
1401
|
-
_this4.connectionState.next({
|
|
1402
|
-
type: "state",
|
|
1403
|
-
state: "pending",
|
|
1404
|
-
error: null
|
|
1405
|
-
});
|
|
1406
|
-
}).catch((error) => {
|
|
1407
|
-
ws.close(3e3);
|
|
1408
|
-
handleCloseOrError(error);
|
|
1409
|
-
});
|
|
1410
|
-
});
|
|
1411
|
-
ws.addEventListener("message", ({ data }) => {
|
|
1412
|
-
this.inactivityTimeout.reset();
|
|
1413
|
-
if (["PING", "PONG"].includes(data)) return;
|
|
1414
|
-
const incomingMessage = this.encoder.decode(data);
|
|
1415
|
-
if ("method" in incomingMessage) {
|
|
1416
|
-
this.handleIncomingRequest(incomingMessage);
|
|
1417
|
-
return;
|
|
1418
|
-
}
|
|
1419
|
-
this.handleResponseMessage(incomingMessage);
|
|
1420
|
-
});
|
|
1421
|
-
ws.addEventListener("close", (event) => {
|
|
1422
|
-
var _this$callbacks$onClo, _this$callbacks2;
|
|
1423
|
-
handleCloseOrError(event);
|
|
1424
|
-
(_this$callbacks$onClo = (_this$callbacks2 = this.callbacks).onClose) === null || _this$callbacks$onClo === void 0 || _this$callbacks$onClo.call(_this$callbacks2, event);
|
|
1425
|
-
if (!this.lazyMode || this.requestManager.hasPendingSubscriptions()) this.reconnect(new TRPCWebSocketClosedError({
|
|
1426
|
-
message: "WebSocket closed",
|
|
1427
|
-
cause: event
|
|
1428
|
-
}));
|
|
1429
|
-
});
|
|
1430
|
-
ws.addEventListener("error", (event) => {
|
|
1431
|
-
var _this$callbacks$onErr, _this$callbacks3;
|
|
1432
|
-
handleCloseOrError(event);
|
|
1433
|
-
(_this$callbacks$onErr = (_this$callbacks3 = this.callbacks).onError) === null || _this$callbacks$onErr === void 0 || _this$callbacks$onErr.call(_this$callbacks3, event);
|
|
1434
|
-
this.reconnect(new TRPCWebSocketClosedError({
|
|
1435
|
-
message: "WebSocket closed",
|
|
1436
|
-
cause: event
|
|
1437
|
-
}));
|
|
1438
|
-
});
|
|
1439
|
-
}
|
|
1440
|
-
handleResponseMessage(message) {
|
|
1441
|
-
const request = this.requestManager.getPendingRequest(message.id);
|
|
1442
|
-
if (!request) return;
|
|
1443
|
-
request.callbacks.next(message);
|
|
1444
|
-
let completed = true;
|
|
1445
|
-
if ("result" in message && request.message.method === "subscription") {
|
|
1446
|
-
if (message.result.type === "data") request.message.params.lastEventId = message.result.id;
|
|
1447
|
-
if (message.result.type !== "stopped") completed = false;
|
|
1448
714
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
715
|
+
const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
|
|
716
|
+
if (equalityAnnotations) {
|
|
717
|
+
res.meta = {
|
|
718
|
+
...res.meta,
|
|
719
|
+
referentialEqualities: equalityAnnotations
|
|
720
|
+
};
|
|
1452
721
|
}
|
|
722
|
+
if (res.meta)
|
|
723
|
+
res.meta.v = 1;
|
|
724
|
+
return res;
|
|
725
|
+
}
|
|
726
|
+
deserialize(payload, options) {
|
|
727
|
+
const { json, meta } = payload;
|
|
728
|
+
let result = options?.inPlace ? json : copy(json);
|
|
729
|
+
if (meta?.values) {
|
|
730
|
+
result = applyValueAnnotations(result, meta.values, meta.v ?? 0, this);
|
|
731
|
+
}
|
|
732
|
+
if (meta?.referentialEqualities) {
|
|
733
|
+
result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities, meta.v ?? 0);
|
|
734
|
+
}
|
|
735
|
+
return result;
|
|
1453
736
|
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
}
|
|
1457
|
-
/**
|
|
1458
|
-
* Sends a message or batch of messages directly to the server.
|
|
1459
|
-
*/
|
|
1460
|
-
send(messageOrMessages) {
|
|
1461
|
-
if (!this.activeConnection.isOpen()) throw new Error("Active connection is not open");
|
|
1462
|
-
const messages = messageOrMessages instanceof Array ? messageOrMessages : [messageOrMessages];
|
|
1463
|
-
this.activeConnection.ws.send(this.encoder.encode(messages.length === 1 ? messages[0] : messages));
|
|
737
|
+
stringify(object) {
|
|
738
|
+
return JSON.stringify(this.serialize(object));
|
|
1464
739
|
}
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
*
|
|
1468
|
-
* @returns A function to abort the batched request.
|
|
1469
|
-
*/
|
|
1470
|
-
batchSend(message, callbacks) {
|
|
1471
|
-
var _this5 = this;
|
|
1472
|
-
this.inactivityTimeout.reset();
|
|
1473
|
-
run(async () => {
|
|
1474
|
-
if (!_this5.activeConnection.isOpen()) await _this5.open();
|
|
1475
|
-
await sleep(0);
|
|
1476
|
-
if (!_this5.requestManager.hasOutgoingRequests()) return;
|
|
1477
|
-
_this5.send(_this5.requestManager.flush().map(({ message: message$1 }) => message$1));
|
|
1478
|
-
}).catch((err) => {
|
|
1479
|
-
this.requestManager.delete(message.id);
|
|
1480
|
-
callbacks.error(TRPCClientError.from(err));
|
|
1481
|
-
});
|
|
1482
|
-
return this.requestManager.register(message, callbacks);
|
|
740
|
+
parse(string) {
|
|
741
|
+
return this.deserialize(JSON.parse(string), { inPlace: true });
|
|
1483
742
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
return new WsClient(opts);
|
|
1487
|
-
}
|
|
1488
|
-
__name(createWSClient, "createWSClient");
|
|
1489
|
-
function wsLink(opts) {
|
|
1490
|
-
const { client } = opts;
|
|
1491
|
-
const transformer = getTransformer(opts.transformer);
|
|
1492
|
-
return () => {
|
|
1493
|
-
return ({ op }) => {
|
|
1494
|
-
return observable((observer) => {
|
|
1495
|
-
const connStateSubscription = op.type === "subscription" ? client.connectionState.subscribe({ next(result) {
|
|
1496
|
-
observer.next({
|
|
1497
|
-
result,
|
|
1498
|
-
context: op.context
|
|
1499
|
-
});
|
|
1500
|
-
} }) : null;
|
|
1501
|
-
const requestSubscription = client.request({
|
|
1502
|
-
op,
|
|
1503
|
-
transformer
|
|
1504
|
-
}).subscribe(observer);
|
|
1505
|
-
return () => {
|
|
1506
|
-
requestSubscription.unsubscribe();
|
|
1507
|
-
connStateSubscription === null || connStateSubscription === void 0 || connStateSubscription.unsubscribe();
|
|
1508
|
-
};
|
|
1509
|
-
});
|
|
1510
|
-
};
|
|
1511
|
-
};
|
|
1512
|
-
}
|
|
1513
|
-
__name(wsLink, "wsLink");
|
|
1514
|
-
|
|
1515
|
-
// ../../node_modules/@trpc/client/dist/index.mjs
|
|
1516
|
-
var import_defineProperty4 = __toESM2(require_defineProperty(), 1);
|
|
1517
|
-
var import_objectSpread2$4 = __toESM2(require_objectSpread2(), 1);
|
|
1518
|
-
var TRPCUntypedClient = class {
|
|
1519
|
-
static {
|
|
1520
|
-
__name(this, "TRPCUntypedClient");
|
|
1521
|
-
}
|
|
1522
|
-
constructor(opts) {
|
|
1523
|
-
(0, import_defineProperty4.default)(this, "links", void 0);
|
|
1524
|
-
(0, import_defineProperty4.default)(this, "runtime", void 0);
|
|
1525
|
-
(0, import_defineProperty4.default)(this, "requestId", void 0);
|
|
1526
|
-
this.requestId = 0;
|
|
1527
|
-
this.runtime = {};
|
|
1528
|
-
this.links = opts.links.map((link) => link(this.runtime));
|
|
1529
|
-
}
|
|
1530
|
-
$request(opts) {
|
|
1531
|
-
var _opts$context;
|
|
1532
|
-
const chain$ = createChain({
|
|
1533
|
-
links: this.links,
|
|
1534
|
-
op: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
|
|
1535
|
-
context: (_opts$context = opts.context) !== null && _opts$context !== void 0 ? _opts$context : {},
|
|
1536
|
-
id: ++this.requestId
|
|
1537
|
-
})
|
|
1538
|
-
});
|
|
1539
|
-
return chain$.pipe(share());
|
|
743
|
+
registerClass(v, options) {
|
|
744
|
+
this.classRegistry.register(v, options);
|
|
1540
745
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
try {
|
|
1544
|
-
const req$ = _this.$request(opts);
|
|
1545
|
-
const envelope = await observableToPromise(req$);
|
|
1546
|
-
const data = envelope.result.data;
|
|
1547
|
-
return data;
|
|
1548
|
-
} catch (err) {
|
|
1549
|
-
throw TRPCClientError.from(err);
|
|
1550
|
-
}
|
|
746
|
+
registerSymbol(v, identifier) {
|
|
747
|
+
this.symbolRegistry.register(v, identifier);
|
|
1551
748
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
input,
|
|
1557
|
-
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
|
1558
|
-
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
|
749
|
+
registerCustom(transformer, name) {
|
|
750
|
+
this.customTransformerRegistry.register({
|
|
751
|
+
name,
|
|
752
|
+
...transformer
|
|
1559
753
|
});
|
|
1560
754
|
}
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
type: "mutation",
|
|
1564
|
-
path,
|
|
1565
|
-
input,
|
|
1566
|
-
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
|
1567
|
-
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
|
1568
|
-
});
|
|
755
|
+
allowErrorProps(...props) {
|
|
756
|
+
this.allowedErrorProps.push(...props);
|
|
1569
757
|
}
|
|
1570
|
-
subscription(path, input, opts) {
|
|
1571
|
-
const observable$ = this.$request({
|
|
1572
|
-
type: "subscription",
|
|
1573
|
-
path,
|
|
1574
|
-
input,
|
|
1575
|
-
context: opts.context,
|
|
1576
|
-
signal: opts.signal
|
|
1577
|
-
});
|
|
1578
|
-
return observable$.subscribe({
|
|
1579
|
-
next(envelope) {
|
|
1580
|
-
switch (envelope.result.type) {
|
|
1581
|
-
case "state": {
|
|
1582
|
-
var _opts$onConnectionSta;
|
|
1583
|
-
(_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === void 0 || _opts$onConnectionSta.call(opts, envelope.result);
|
|
1584
|
-
break;
|
|
1585
|
-
}
|
|
1586
|
-
case "started": {
|
|
1587
|
-
var _opts$onStarted;
|
|
1588
|
-
(_opts$onStarted = opts.onStarted) === null || _opts$onStarted === void 0 || _opts$onStarted.call(opts, { context: envelope.context });
|
|
1589
|
-
break;
|
|
1590
|
-
}
|
|
1591
|
-
case "stopped": {
|
|
1592
|
-
var _opts$onStopped;
|
|
1593
|
-
(_opts$onStopped = opts.onStopped) === null || _opts$onStopped === void 0 || _opts$onStopped.call(opts);
|
|
1594
|
-
break;
|
|
1595
|
-
}
|
|
1596
|
-
case "data":
|
|
1597
|
-
case void 0: {
|
|
1598
|
-
var _opts$onData;
|
|
1599
|
-
(_opts$onData = opts.onData) === null || _opts$onData === void 0 || _opts$onData.call(opts, envelope.result.data);
|
|
1600
|
-
break;
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
},
|
|
1604
|
-
error(err) {
|
|
1605
|
-
var _opts$onError;
|
|
1606
|
-
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, err);
|
|
1607
|
-
},
|
|
1608
|
-
complete() {
|
|
1609
|
-
var _opts$onComplete;
|
|
1610
|
-
(_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 || _opts$onComplete.call(opts);
|
|
1611
|
-
}
|
|
1612
|
-
});
|
|
1613
|
-
}
|
|
1614
|
-
};
|
|
1615
|
-
var untypedClientSymbol = /* @__PURE__ */ Symbol.for("trpc_untypedClient");
|
|
1616
|
-
var clientCallTypeMap = {
|
|
1617
|
-
query: "query",
|
|
1618
|
-
mutate: "mutation",
|
|
1619
|
-
subscribe: "subscription"
|
|
1620
|
-
};
|
|
1621
|
-
var clientCallTypeToProcedureType = /* @__PURE__ */ __name((clientCallType) => {
|
|
1622
|
-
return clientCallTypeMap[clientCallType];
|
|
1623
|
-
}, "clientCallTypeToProcedureType");
|
|
1624
|
-
function createTRPCClientProxy(client) {
|
|
1625
|
-
const proxy = createRecursiveProxy(({ path, args }) => {
|
|
1626
|
-
const pathCopy = [...path];
|
|
1627
|
-
const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
|
|
1628
|
-
const fullPath = pathCopy.join(".");
|
|
1629
|
-
return client[procedureType](fullPath, ...args);
|
|
1630
|
-
});
|
|
1631
|
-
return createFlatProxy((key) => {
|
|
1632
|
-
if (key === untypedClientSymbol) return client;
|
|
1633
|
-
return proxy[key];
|
|
1634
|
-
});
|
|
1635
758
|
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
value: r$2,
|
|
1663
|
-
done: n
|
|
1664
|
-
};
|
|
1665
|
-
});
|
|
1666
|
-
}
|
|
1667
|
-
__name(AsyncFromSyncIteratorContinuation, "AsyncFromSyncIteratorContinuation");
|
|
1668
|
-
return AsyncFromSyncIterator = /* @__PURE__ */ __name(function AsyncFromSyncIterator$1(r$1) {
|
|
1669
|
-
this.s = r$1, this.n = r$1.next;
|
|
1670
|
-
}, "AsyncFromSyncIterator$1"), AsyncFromSyncIterator.prototype = {
|
|
1671
|
-
s: null,
|
|
1672
|
-
n: null,
|
|
1673
|
-
next: /* @__PURE__ */ __name(function next() {
|
|
1674
|
-
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
1675
|
-
}, "next"),
|
|
1676
|
-
"return": /* @__PURE__ */ __name(function _return(r$1) {
|
|
1677
|
-
var n = this.s["return"];
|
|
1678
|
-
return void 0 === n ? Promise.resolve({
|
|
1679
|
-
value: r$1,
|
|
1680
|
-
done: true
|
|
1681
|
-
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
1682
|
-
}, "_return"),
|
|
1683
|
-
"throw": /* @__PURE__ */ __name(function _throw(r$1) {
|
|
1684
|
-
var n = this.s["return"];
|
|
1685
|
-
return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
1686
|
-
}, "_throw")
|
|
1687
|
-
}, new AsyncFromSyncIterator(r);
|
|
1688
|
-
}
|
|
1689
|
-
__name(AsyncFromSyncIterator, "AsyncFromSyncIterator");
|
|
1690
|
-
module2.exports = _asyncIterator$1, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
1691
|
-
} });
|
|
1692
|
-
var import_asyncIterator = __toESM2(require_asyncIterator(), 1);
|
|
1693
|
-
var import_objectSpread2$12 = __toESM2(require_objectSpread2(), 1);
|
|
1694
|
-
var require_usingCtx = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports2, module2) {
|
|
1695
|
-
function _usingCtx() {
|
|
1696
|
-
var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
|
|
1697
|
-
var n$1 = Error();
|
|
1698
|
-
return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
|
|
1699
|
-
}, e = {}, n = [];
|
|
1700
|
-
function using(r$1, e$1) {
|
|
1701
|
-
if (null != e$1) {
|
|
1702
|
-
if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
1703
|
-
if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
|
1704
|
-
if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
|
|
1705
|
-
if ("function" != typeof o) throw new TypeError("Object is not disposable.");
|
|
1706
|
-
t && (o = /* @__PURE__ */ __name(function o$1() {
|
|
1707
|
-
try {
|
|
1708
|
-
t.call(e$1);
|
|
1709
|
-
} catch (r$2) {
|
|
1710
|
-
return Promise.reject(r$2);
|
|
1711
|
-
}
|
|
1712
|
-
}, "o$1")), n.push({
|
|
1713
|
-
v: e$1,
|
|
1714
|
-
d: o,
|
|
1715
|
-
a: r$1
|
|
1716
|
-
});
|
|
1717
|
-
} else r$1 && n.push({
|
|
1718
|
-
d: e$1,
|
|
1719
|
-
a: r$1
|
|
1720
|
-
});
|
|
1721
|
-
return e$1;
|
|
1722
|
-
}
|
|
1723
|
-
__name(using, "using");
|
|
1724
|
-
return {
|
|
1725
|
-
e,
|
|
1726
|
-
u: using.bind(null, false),
|
|
1727
|
-
a: using.bind(null, true),
|
|
1728
|
-
d: /* @__PURE__ */ __name(function d() {
|
|
1729
|
-
var o, t = this.e, s = 0;
|
|
1730
|
-
function next() {
|
|
1731
|
-
for (; o = n.pop(); ) try {
|
|
1732
|
-
if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
|
|
1733
|
-
if (o.d) {
|
|
1734
|
-
var r$1 = o.d.call(o.v);
|
|
1735
|
-
if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
|
|
1736
|
-
} else s |= 1;
|
|
1737
|
-
} catch (r$2) {
|
|
1738
|
-
return err(r$2);
|
|
1739
|
-
}
|
|
1740
|
-
if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
|
|
1741
|
-
if (t !== e) throw t;
|
|
1742
|
-
}
|
|
1743
|
-
__name(next, "next");
|
|
1744
|
-
function err(n$1) {
|
|
1745
|
-
return t = t !== e ? new r(n$1, t) : n$1, next();
|
|
1746
|
-
}
|
|
1747
|
-
__name(err, "err");
|
|
1748
|
-
return next();
|
|
1749
|
-
}, "d")
|
|
1750
|
-
};
|
|
1751
|
-
}
|
|
1752
|
-
__name(_usingCtx, "_usingCtx");
|
|
1753
|
-
module2.exports = _usingCtx, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
1754
|
-
} });
|
|
1755
|
-
var require_OverloadYield = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports2, module2) {
|
|
1756
|
-
function _OverloadYield(e, d) {
|
|
1757
|
-
this.v = e, this.k = d;
|
|
1758
|
-
}
|
|
1759
|
-
__name(_OverloadYield, "_OverloadYield");
|
|
1760
|
-
module2.exports = _OverloadYield, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
1761
|
-
} });
|
|
1762
|
-
var require_awaitAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports2, module2) {
|
|
1763
|
-
var OverloadYield$1 = require_OverloadYield();
|
|
1764
|
-
function _awaitAsyncGenerator$1(e) {
|
|
1765
|
-
return new OverloadYield$1(e, 0);
|
|
1766
|
-
}
|
|
1767
|
-
__name(_awaitAsyncGenerator$1, "_awaitAsyncGenerator$1");
|
|
1768
|
-
module2.exports = _awaitAsyncGenerator$1, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
1769
|
-
} });
|
|
1770
|
-
var require_wrapAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports2, module2) {
|
|
1771
|
-
var OverloadYield = require_OverloadYield();
|
|
1772
|
-
function _wrapAsyncGenerator$1(e) {
|
|
1773
|
-
return function() {
|
|
1774
|
-
return new AsyncGenerator(e.apply(this, arguments));
|
|
1775
|
-
};
|
|
1776
|
-
}
|
|
1777
|
-
__name(_wrapAsyncGenerator$1, "_wrapAsyncGenerator$1");
|
|
1778
|
-
function AsyncGenerator(e) {
|
|
1779
|
-
var r, t;
|
|
1780
|
-
function resume(r$1, t$1) {
|
|
1781
|
-
try {
|
|
1782
|
-
var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield;
|
|
1783
|
-
Promise.resolve(u ? o.v : o).then(function(t$2) {
|
|
1784
|
-
if (u) {
|
|
1785
|
-
var i = "return" === r$1 ? "return" : "next";
|
|
1786
|
-
if (!o.k || t$2.done) return resume(i, t$2);
|
|
1787
|
-
t$2 = e[i](t$2).value;
|
|
1788
|
-
}
|
|
1789
|
-
settle(n.done ? "return" : "normal", t$2);
|
|
1790
|
-
}, function(e$1) {
|
|
1791
|
-
resume("throw", e$1);
|
|
1792
|
-
});
|
|
1793
|
-
} catch (e$1) {
|
|
1794
|
-
settle("throw", e$1);
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
__name(resume, "resume");
|
|
1798
|
-
function settle(e$1, n) {
|
|
1799
|
-
switch (e$1) {
|
|
1800
|
-
case "return":
|
|
1801
|
-
r.resolve({
|
|
1802
|
-
value: n,
|
|
1803
|
-
done: true
|
|
1804
|
-
});
|
|
1805
|
-
break;
|
|
1806
|
-
case "throw":
|
|
1807
|
-
r.reject(n);
|
|
1808
|
-
break;
|
|
1809
|
-
default:
|
|
1810
|
-
r.resolve({
|
|
1811
|
-
value: n,
|
|
1812
|
-
done: false
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
(r = r.next) ? resume(r.key, r.arg) : t = null;
|
|
1816
|
-
}
|
|
1817
|
-
__name(settle, "settle");
|
|
1818
|
-
this._invoke = function(e$1, n) {
|
|
1819
|
-
return new Promise(function(o, u) {
|
|
1820
|
-
var i = {
|
|
1821
|
-
key: e$1,
|
|
1822
|
-
arg: n,
|
|
1823
|
-
resolve: o,
|
|
1824
|
-
reject: u,
|
|
1825
|
-
next: null
|
|
1826
|
-
};
|
|
1827
|
-
t ? t = t.next = i : (r = t = i, resume(e$1, n));
|
|
1828
|
-
});
|
|
1829
|
-
}, "function" != typeof e["return"] && (this["return"] = void 0);
|
|
1830
|
-
}
|
|
1831
|
-
__name(AsyncGenerator, "AsyncGenerator");
|
|
1832
|
-
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
1833
|
-
return this;
|
|
1834
|
-
}, AsyncGenerator.prototype.next = function(e) {
|
|
1835
|
-
return this._invoke("next", e);
|
|
1836
|
-
}, AsyncGenerator.prototype["throw"] = function(e) {
|
|
1837
|
-
return this._invoke("throw", e);
|
|
1838
|
-
}, AsyncGenerator.prototype["return"] = function(e) {
|
|
1839
|
-
return this._invoke("return", e);
|
|
1840
|
-
};
|
|
1841
|
-
module2.exports = _wrapAsyncGenerator$1, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
|
|
1842
|
-
} });
|
|
1843
|
-
var import_usingCtx = __toESM2(require_usingCtx(), 1);
|
|
1844
|
-
var import_awaitAsyncGenerator = __toESM2(require_awaitAsyncGenerator(), 1);
|
|
1845
|
-
var import_wrapAsyncGenerator = __toESM2(require_wrapAsyncGenerator(), 1);
|
|
1846
|
-
var import_objectSpread29 = __toESM2(require_objectSpread2(), 1);
|
|
1847
|
-
|
|
1848
|
-
// src/system.ts
|
|
1849
|
-
var import_superjson = __toESM(require("superjson"), 1);
|
|
1850
|
-
var import_types = require("@camstack/types");
|
|
1851
|
-
var WS_KEEP_ALIVE_INTERVAL_MS = 1e4;
|
|
1852
|
-
var WS_KEEP_ALIVE_PONG_TIMEOUT_MS = 3e3;
|
|
1853
|
-
var WS_RECONNECT_RETRY_DELAY_MS = 2e3;
|
|
1854
|
-
var WS_RECONNECT_MAX_RETRY_DELAY_MS = 3e4;
|
|
1855
|
-
var System = class {
|
|
1856
|
-
static {
|
|
1857
|
-
__name(this, "System");
|
|
1858
|
-
}
|
|
1859
|
-
serverUrl;
|
|
759
|
+
SuperJSON.defaultInstance = new SuperJSON();
|
|
760
|
+
SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
|
|
761
|
+
SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
|
|
762
|
+
SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
|
|
763
|
+
SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
|
|
764
|
+
SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
|
|
765
|
+
SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
|
|
766
|
+
SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
|
|
767
|
+
SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
|
|
768
|
+
SuperJSON.serialize;
|
|
769
|
+
SuperJSON.deserialize;
|
|
770
|
+
SuperJSON.stringify;
|
|
771
|
+
SuperJSON.parse;
|
|
772
|
+
SuperJSON.registerClass;
|
|
773
|
+
SuperJSON.registerCustom;
|
|
774
|
+
SuperJSON.registerSymbol;
|
|
775
|
+
SuperJSON.allowErrorProps;
|
|
776
|
+
const WS_KEEP_ALIVE_INTERVAL_MS = 1e4;
|
|
777
|
+
const WS_KEEP_ALIVE_PONG_TIMEOUT_MS = 3e3;
|
|
778
|
+
const WS_RECONNECT_RETRY_DELAY_MS = 2e3;
|
|
779
|
+
const WS_RECONNECT_MAX_RETRY_DELAY_MS = 3e4;
|
|
780
|
+
class System {
|
|
781
|
+
/** Active server base URL. Mutable via `switchServerUrl()` so the
|
|
782
|
+
* endpoint-race helper can pivot the transport onto a LAN candidate
|
|
783
|
+
* after the initial public-URL bootstrap. */
|
|
784
|
+
_serverUrl;
|
|
1860
785
|
useWs;
|
|
1861
786
|
baseRetryMs;
|
|
1862
787
|
maxRetryMs;
|
|
@@ -1884,7 +809,7 @@ var System = class {
|
|
|
1884
809
|
_connectionVersion = 0;
|
|
1885
810
|
connectionListeners = /* @__PURE__ */ new Set();
|
|
1886
811
|
constructor(config) {
|
|
1887
|
-
this.
|
|
812
|
+
this._serverUrl = config.serverUrl.replace(/\/+$/, "");
|
|
1888
813
|
this.token = config.token;
|
|
1889
814
|
const isBrowser = typeof window !== "undefined";
|
|
1890
815
|
this.useWs = config.useWebSocket ?? isBrowser;
|
|
@@ -1892,18 +817,22 @@ var System = class {
|
|
|
1892
817
|
this.baseRetryMs = config.retryDelayMs ?? WS_RECONNECT_RETRY_DELAY_MS;
|
|
1893
818
|
this.maxRetryMs = config.maxRetryDelayMs ?? WS_RECONNECT_MAX_RETRY_DELAY_MS;
|
|
1894
819
|
this._trpcClient = this.buildTrpcClient();
|
|
1895
|
-
this._systemProxy =
|
|
820
|
+
this._systemProxy = types.createSystemProxy(this._trpcClient);
|
|
1896
821
|
}
|
|
1897
822
|
// ── Connection state ─────────────────────────────────────────────
|
|
823
|
+
/** Active server base URL (no trailing slash). */
|
|
824
|
+
get serverUrl() {
|
|
825
|
+
return this._serverUrl;
|
|
826
|
+
}
|
|
1898
827
|
get connectionVersion() {
|
|
1899
828
|
return this._connectionVersion;
|
|
1900
829
|
}
|
|
1901
830
|
/**
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
831
|
+
* Subscribe to connection-state transitions. Called with `('connected'
|
|
832
|
+
* | 'disconnected' | 'connecting', version)` whenever the SDK opens,
|
|
833
|
+
* closes, or starts a manual reconnect. Listener errors are swallowed
|
|
834
|
+
* so a misbehaving consumer cannot break the SDK's event loop.
|
|
835
|
+
*/
|
|
1907
836
|
subscribeConnectionEvents(cb) {
|
|
1908
837
|
this.connectionListeners.add(cb);
|
|
1909
838
|
return () => {
|
|
@@ -1924,30 +853,30 @@ var System = class {
|
|
|
1924
853
|
}
|
|
1925
854
|
// ── Lifecycle ────────────────────────────────────────────────────
|
|
1926
855
|
/**
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
856
|
+
* Wait until the underlying tRPC transport is connected AND the
|
|
857
|
+
* server has responded to a cheap auth round-trip (`auth.me`). This
|
|
858
|
+
* is the canonical "ready to issue queries" gate.
|
|
859
|
+
*
|
|
860
|
+
* Why a probe, not just `ws.readyState === OPEN`?
|
|
861
|
+
* The WS handshake completes asynchronously: tRPC's `wsLink`
|
|
862
|
+
* queues outgoing messages and only flushes them after `open()`
|
|
863
|
+
* resolves (post `connectionParams` send). On the server, the
|
|
864
|
+
* tRPC context is created lazily once the connectionParams
|
|
865
|
+
* message is received. A query fired between WS-open and
|
|
866
|
+
* connection-params-processed is technically queued by tRPC, but
|
|
867
|
+
* the auth context for that query is only resolved once the
|
|
868
|
+
* handshake message is decoded server-side. A probe round-trip is
|
|
869
|
+
* the safest way to confirm both sides have agreed on the auth
|
|
870
|
+
* identity before the React tree starts firing parallel queries
|
|
871
|
+
* (which can otherwise land before any addon-side service
|
|
872
|
+
* discovery has settled, returning empty results that get cached).
|
|
873
|
+
*
|
|
874
|
+
* Idempotent — concurrent callers await the same in-flight Promise.
|
|
875
|
+
* Bounded by `timeoutMs` (default 15s) — beyond which a
|
|
876
|
+
* `Error('System.awaitConnected: probe timed out after Xms')` is
|
|
877
|
+
* thrown so the host can render a clear error state instead of
|
|
878
|
+
* hanging on a bricked socket.
|
|
879
|
+
*/
|
|
1951
880
|
async awaitConnected(timeoutMs) {
|
|
1952
881
|
if (this.connected) return;
|
|
1953
882
|
if (this.connectedPromise) return this.connectedPromise;
|
|
@@ -1958,14 +887,20 @@ var System = class {
|
|
|
1958
887
|
await probe;
|
|
1959
888
|
} else {
|
|
1960
889
|
await new Promise((resolve, reject) => {
|
|
1961
|
-
const timer = setTimeout(
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
890
|
+
const timer = setTimeout(
|
|
891
|
+
() => reject(new Error(`System.awaitConnected: probe timed out after ${effectiveTimeoutMs}ms`)),
|
|
892
|
+
effectiveTimeoutMs
|
|
893
|
+
);
|
|
894
|
+
probe.then(
|
|
895
|
+
() => {
|
|
896
|
+
clearTimeout(timer);
|
|
897
|
+
resolve();
|
|
898
|
+
},
|
|
899
|
+
(err) => {
|
|
900
|
+
clearTimeout(timer);
|
|
901
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
902
|
+
}
|
|
903
|
+
);
|
|
1969
904
|
});
|
|
1970
905
|
}
|
|
1971
906
|
this.connected = true;
|
|
@@ -1977,19 +912,19 @@ var System = class {
|
|
|
1977
912
|
}
|
|
1978
913
|
}
|
|
1979
914
|
/**
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
915
|
+
* Warm-boot the device mirror. Awaits the transport probe first
|
|
916
|
+
* (`awaitConnected`) so the three mirror round-trips
|
|
917
|
+
* (`getAllBindings` + `getAllSnapshots` + `listAll`) cannot race
|
|
918
|
+
* against the WS auth handshake. Subsequent `getDevice(id)` calls
|
|
919
|
+
* are sync; live `device.*` event subscriptions keep the caches
|
|
920
|
+
* fresh.
|
|
921
|
+
*
|
|
922
|
+
* Idempotent — concurrent callers await the same in-flight Promise.
|
|
923
|
+
*/
|
|
1989
924
|
async init(timeoutMs) {
|
|
1990
925
|
if (this.mirror?.isReady()) return;
|
|
1991
926
|
if (this.mirrorInit) return this.mirrorInit;
|
|
1992
|
-
const m = new
|
|
927
|
+
const m = new types.SystemMirror(this._trpcClient);
|
|
1993
928
|
this.mirror = m;
|
|
1994
929
|
this.mirrorInit = (async () => {
|
|
1995
930
|
await this.awaitConnected(timeoutMs);
|
|
@@ -2014,11 +949,11 @@ var System = class {
|
|
|
2014
949
|
return this.connected;
|
|
2015
950
|
}
|
|
2016
951
|
/**
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
952
|
+
* Force a fresh WebSocket handshake. Tears down the wsClient + tRPC
|
|
953
|
+
* client + mirror (the mirror captures the tRPC reference at
|
|
954
|
+
* construction time and would otherwise dispatch through a closed
|
|
955
|
+
* client) and rebuilds them. No-op for HTTP transport.
|
|
956
|
+
*/
|
|
2022
957
|
reconnect() {
|
|
2023
958
|
if (!this.useWs) return;
|
|
2024
959
|
this.emitConnectionEvent("connecting");
|
|
@@ -2027,7 +962,77 @@ var System = class {
|
|
|
2027
962
|
this.connected = false;
|
|
2028
963
|
this.connectedPromise = null;
|
|
2029
964
|
this._trpcClient = this.buildTrpcClient();
|
|
2030
|
-
this._systemProxy =
|
|
965
|
+
this._systemProxy = types.createSystemProxy(this._trpcClient);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Pivot the underlying tRPC transport onto a different base URL.
|
|
969
|
+
* Used by the endpoint-race flow: the SDK opens against the public
|
|
970
|
+
* URL the operator provided, calls `localNetwork.getConnectionEndpoints`
|
|
971
|
+
* to discover LAN candidates, races them, and (when a faster one wins)
|
|
972
|
+
* calls `switchServerUrl(winner)` to migrate every subsequent query
|
|
973
|
+
* onto the LAN path without losing auth state.
|
|
974
|
+
*
|
|
975
|
+
* Keeps the auth token. Tears down the WS + mirror and rebuilds them
|
|
976
|
+
* against the new URL — same machinery as `reconnect()` but with a
|
|
977
|
+
* different target.
|
|
978
|
+
*/
|
|
979
|
+
switchServerUrl(nextUrl) {
|
|
980
|
+
const normalized = nextUrl.replace(/\/+$/, "");
|
|
981
|
+
if (normalized === this._serverUrl) return;
|
|
982
|
+
this._serverUrl = normalized;
|
|
983
|
+
this.reconnect();
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Race the candidate base URLs reported by the hub's `local-network`
|
|
987
|
+
* cap, pick the fastest one that responds, and (if it's different
|
|
988
|
+
* from the current URL) pivot the transport onto it.
|
|
989
|
+
*
|
|
990
|
+
* Flow:
|
|
991
|
+
* 1. Query `localNetwork.getConnectionEndpoints({ port })` over the
|
|
992
|
+
* already-authenticated tRPC channel — the cap is auth-gated,
|
|
993
|
+
* so the LAN IPs never leak to anonymous callers.
|
|
994
|
+
* 2. For each candidate, fire a HEAD on `{baseUrl}/trpc/health`
|
|
995
|
+
* with a short timeout (default 1500ms). The first 2xx wins.
|
|
996
|
+
* 3. If the winner differs from `this.serverUrl`, call
|
|
997
|
+
* `switchServerUrl(winner)` and return it. Otherwise return
|
|
998
|
+
* the current URL unchanged.
|
|
999
|
+
*
|
|
1000
|
+
* Bounded — if every candidate times out we keep the current URL.
|
|
1001
|
+
* Idempotent — safe to call on every connect / reconnect / network
|
|
1002
|
+
* change event.
|
|
1003
|
+
*/
|
|
1004
|
+
async raceConnectionEndpoints(options) {
|
|
1005
|
+
const timeoutMs = options?.perCandidateTimeoutMs ?? 1500;
|
|
1006
|
+
const url = (() => {
|
|
1007
|
+
try {
|
|
1008
|
+
return new URL(this._serverUrl);
|
|
1009
|
+
} catch {
|
|
1010
|
+
return null;
|
|
1011
|
+
}
|
|
1012
|
+
})();
|
|
1013
|
+
const port = url?.port ? Number(url.port) : url?.protocol === "https:" ? 443 : 80;
|
|
1014
|
+
const scheme = url?.protocol === "https:" ? "https" : "http";
|
|
1015
|
+
const proxy = this._trpcClient;
|
|
1016
|
+
const cap = proxy.localNetwork?.getConnectionEndpoints;
|
|
1017
|
+
if (!cap) {
|
|
1018
|
+
return { winner: this._serverUrl, switched: false };
|
|
1019
|
+
}
|
|
1020
|
+
let endpoints = [];
|
|
1021
|
+
try {
|
|
1022
|
+
const res = await cap.query({ port, ipv4Only: options?.ipv4Only, scheme });
|
|
1023
|
+
endpoints = res.endpoints;
|
|
1024
|
+
} catch {
|
|
1025
|
+
return { winner: this._serverUrl, switched: false };
|
|
1026
|
+
}
|
|
1027
|
+
if (endpoints.length === 0) {
|
|
1028
|
+
return { winner: this._serverUrl, switched: false };
|
|
1029
|
+
}
|
|
1030
|
+
const winner = await raceFastestEndpoint(endpoints.map((e) => e.baseUrl), timeoutMs);
|
|
1031
|
+
if (!winner || winner === this._serverUrl) {
|
|
1032
|
+
return { winner: winner ?? this._serverUrl, switched: false };
|
|
1033
|
+
}
|
|
1034
|
+
this.switchServerUrl(winner);
|
|
1035
|
+
return { winner, switched: true };
|
|
2031
1036
|
}
|
|
2032
1037
|
/** Tear down WS connection + mirror. The instance is unusable afterwards. */
|
|
2033
1038
|
close() {
|
|
@@ -2043,10 +1048,7 @@ var System = class {
|
|
|
2043
1048
|
}
|
|
2044
1049
|
// ── Auth ──────────────────────────────────────────────────────────
|
|
2045
1050
|
async login(username, password) {
|
|
2046
|
-
const result = await this._trpcClient.auth.login.mutate({
|
|
2047
|
-
username,
|
|
2048
|
-
password
|
|
2049
|
-
});
|
|
1051
|
+
const result = await this._trpcClient.auth.login.mutate({ username, password });
|
|
2050
1052
|
if (typeof result === "object" && result !== null && "token" in result) {
|
|
2051
1053
|
const token = result.token;
|
|
2052
1054
|
if (typeof token === "string") this.setToken(token);
|
|
@@ -2066,24 +1068,24 @@ var System = class {
|
|
|
2066
1068
|
}
|
|
2067
1069
|
// ── Devices ──────────────────────────────────────────────────────
|
|
2068
1070
|
/**
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
1071
|
+
* Synchronous snapshot of every device matching the optional filters.
|
|
1072
|
+
* Backed by the `SystemMirror` warm-boot cache — call `init()` first
|
|
1073
|
+
* (or `awaitReady()`) before invoking. Returns an empty array if the
|
|
1074
|
+
* mirror has not yet been booted.
|
|
1075
|
+
*
|
|
1076
|
+
* Each returned proxy has `binding` populated from the mirror's
|
|
1077
|
+
* binding cache (Phase 5 dedup), so consumers no longer need to
|
|
1078
|
+
* make a separate `deviceManager.getBindings` round-trip.
|
|
1079
|
+
*/
|
|
2078
1080
|
listDevices(filters) {
|
|
2079
1081
|
if (!this.mirror) return [];
|
|
2080
1082
|
const proxies = filters ? this.mirror.query(filters) : this.mirror.getAllDevices();
|
|
2081
1083
|
return proxies.map((p) => this.attachBinding(p));
|
|
2082
1084
|
}
|
|
2083
1085
|
/**
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
1086
|
+
* Sync lookup by numeric id. `null` if the mirror has not been booted
|
|
1087
|
+
* or the device is unknown.
|
|
1088
|
+
*/
|
|
2087
1089
|
getDevice(deviceId) {
|
|
2088
1090
|
const proxy = this.mirror?.getDeviceById(deviceId) ?? null;
|
|
2089
1091
|
return proxy ? this.attachBinding(proxy) : null;
|
|
@@ -2099,10 +1101,10 @@ var System = class {
|
|
|
2099
1101
|
return proxy ? this.attachBinding(proxy) : null;
|
|
2100
1102
|
}
|
|
2101
1103
|
/**
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
1104
|
+
* Resolve when a device with `deviceId` becomes available. Resolves
|
|
1105
|
+
* immediately if already known; rejects with a timeout error
|
|
1106
|
+
* otherwise (default 30s).
|
|
1107
|
+
*/
|
|
2106
1108
|
async waitForDevice(deviceId, timeoutMs) {
|
|
2107
1109
|
if (!this.mirror) await this.init();
|
|
2108
1110
|
const proxy = await this.mirror.waitForDevice(deviceId, timeoutMs ?? 3e4);
|
|
@@ -2123,12 +1125,12 @@ var System = class {
|
|
|
2123
1125
|
return this.mirror.onDeviceRemoved(cb);
|
|
2124
1126
|
}
|
|
2125
1127
|
/**
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
1128
|
+
* Patch the proxy's `binding` field from the mirror's cache. The
|
|
1129
|
+
* generated `createDeviceProxy()` already sets `binding` to the
|
|
1130
|
+
* binding it was constructed with — this is a defensive overwrite
|
|
1131
|
+
* that uses the latest cached entry in case a `binding-changed`
|
|
1132
|
+
* event landed between proxy creation and access.
|
|
1133
|
+
*/
|
|
2132
1134
|
attachBinding(proxy) {
|
|
2133
1135
|
const binding = this.lookupBinding(proxy.deviceId);
|
|
2134
1136
|
if (binding === proxy.binding) return proxy;
|
|
@@ -2216,26 +1218,27 @@ var System = class {
|
|
|
2216
1218
|
}
|
|
2217
1219
|
// ── Live events ──────────────────────────────────────────────────
|
|
2218
1220
|
/**
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
1221
|
+
* Subscribe to a single event category. Returns an unsubscribe
|
|
1222
|
+
* handle. Errors thrown by the listener are swallowed so a single
|
|
1223
|
+
* misbehaving consumer cannot tear down the WS subscription.
|
|
1224
|
+
*
|
|
1225
|
+
* Categories should be values from the `EventCategory` enum
|
|
1226
|
+
* (`@camstack/types`) — passing a raw string works for forward-compat
|
|
1227
|
+
* but loses type safety. The SDK forwards the value verbatim to the
|
|
1228
|
+
* server's `live.onEvent` subscription.
|
|
1229
|
+
*/
|
|
2228
1230
|
subscribeEvent(category, cb) {
|
|
2229
|
-
const sub = this._trpcClient.live.onEvent.subscribe(
|
|
2230
|
-
category
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
1231
|
+
const sub = this._trpcClient.live.onEvent.subscribe(
|
|
1232
|
+
{ category },
|
|
1233
|
+
{
|
|
1234
|
+
onData: (event) => {
|
|
1235
|
+
try {
|
|
1236
|
+
cb(event);
|
|
1237
|
+
} catch {
|
|
1238
|
+
}
|
|
2236
1239
|
}
|
|
2237
|
-
}
|
|
2238
|
-
|
|
1240
|
+
}
|
|
1241
|
+
);
|
|
2239
1242
|
return () => {
|
|
2240
1243
|
try {
|
|
2241
1244
|
sub.unsubscribe();
|
|
@@ -2253,71 +1256,94 @@ var System = class {
|
|
|
2253
1256
|
return this._trpcClient;
|
|
2254
1257
|
}
|
|
2255
1258
|
/**
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
1259
|
+
* Underlying WSClient (or `null` for HTTP transport). Used by
|
|
1260
|
+
* advanced consumers that need direct access to the WebSocket
|
|
1261
|
+
* (e.g. for keep-alive metrics). Rebuilt on `reconnect()`.
|
|
1262
|
+
*/
|
|
2260
1263
|
get wsClient() {
|
|
2261
1264
|
return this._wsClient;
|
|
2262
1265
|
}
|
|
2263
1266
|
// ── Internals ────────────────────────────────────────────────────
|
|
2264
1267
|
buildTrpcClient() {
|
|
2265
|
-
const headers =
|
|
1268
|
+
const headers = () => {
|
|
2266
1269
|
const h = {};
|
|
2267
1270
|
if (this.token) h["Authorization"] = `Bearer ${this.token}`;
|
|
2268
1271
|
return h;
|
|
2269
|
-
}
|
|
1272
|
+
};
|
|
2270
1273
|
if (this.useWs) {
|
|
2271
|
-
const wsUrl = this.
|
|
1274
|
+
const wsUrl = this._serverUrl.replace(/^http/, "ws") + "/trpc";
|
|
2272
1275
|
const baseRetryMs = this.baseRetryMs;
|
|
2273
1276
|
const maxRetryMs = this.maxRetryMs;
|
|
2274
|
-
this._wsClient = createWSClient({
|
|
1277
|
+
this._wsClient = client.createWSClient({
|
|
2275
1278
|
url: wsUrl,
|
|
2276
|
-
connectionParams:
|
|
2277
|
-
|
|
2278
|
-
}), "connectionParams"),
|
|
2279
|
-
retryDelayMs: /* @__PURE__ */ __name((attemptIndex) => Math.min(baseRetryMs * Math.pow(2, attemptIndex), maxRetryMs), "retryDelayMs"),
|
|
1279
|
+
connectionParams: () => ({ token: this.token }),
|
|
1280
|
+
retryDelayMs: (attemptIndex) => Math.min(baseRetryMs * Math.pow(2, attemptIndex), maxRetryMs),
|
|
2280
1281
|
keepAlive: {
|
|
2281
1282
|
enabled: true,
|
|
2282
1283
|
intervalMs: WS_KEEP_ALIVE_INTERVAL_MS,
|
|
2283
1284
|
pongTimeoutMs: WS_KEEP_ALIVE_PONG_TIMEOUT_MS
|
|
2284
1285
|
},
|
|
2285
|
-
onOpen:
|
|
1286
|
+
onOpen: () => {
|
|
2286
1287
|
this._connectionVersion += 1;
|
|
2287
1288
|
this.emitConnectionEvent("connected");
|
|
2288
|
-
},
|
|
2289
|
-
onClose:
|
|
1289
|
+
},
|
|
1290
|
+
onClose: () => {
|
|
2290
1291
|
this.emitConnectionEvent("disconnected");
|
|
2291
|
-
}
|
|
1292
|
+
}
|
|
2292
1293
|
});
|
|
2293
|
-
return createTRPCClient({
|
|
2294
|
-
links: [
|
|
2295
|
-
wsLink({
|
|
2296
|
-
client: this._wsClient,
|
|
2297
|
-
transformer: import_superjson.default
|
|
2298
|
-
})
|
|
2299
|
-
]
|
|
1294
|
+
return client.createTRPCClient({
|
|
1295
|
+
links: [client.wsLink({ client: this._wsClient, transformer: SuperJSON })]
|
|
2300
1296
|
});
|
|
2301
1297
|
}
|
|
2302
1298
|
this._wsClient = null;
|
|
2303
|
-
return createTRPCClient({
|
|
2304
|
-
links: [
|
|
2305
|
-
httpLink({
|
|
2306
|
-
url: `${this.serverUrl}/trpc`,
|
|
2307
|
-
headers,
|
|
2308
|
-
transformer: import_superjson.default
|
|
2309
|
-
})
|
|
2310
|
-
]
|
|
1299
|
+
return client.createTRPCClient({
|
|
1300
|
+
links: [client.httpLink({ url: `${this._serverUrl}/trpc`, headers, transformer: SuperJSON })]
|
|
2311
1301
|
});
|
|
2312
1302
|
}
|
|
2313
|
-
}
|
|
1303
|
+
}
|
|
2314
1304
|
function createSystem(config) {
|
|
2315
1305
|
return new System(config);
|
|
2316
1306
|
}
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
1307
|
+
async function raceFastestEndpoint(candidates, timeoutMs) {
|
|
1308
|
+
if (candidates.length === 0) return null;
|
|
1309
|
+
if (typeof fetch !== "function") return candidates[0] ?? null;
|
|
1310
|
+
const pageIsHttps = typeof window !== "undefined" && typeof window.location !== "undefined" && window.location.protocol === "https:";
|
|
1311
|
+
const reachable = pageIsHttps ? candidates.filter((u) => u.toLowerCase().startsWith("https://")) : candidates;
|
|
1312
|
+
if (reachable.length === 0) return null;
|
|
1313
|
+
const controllers = reachable.map(() => new AbortController());
|
|
1314
|
+
const probes = reachable.map(async (baseUrl, i) => {
|
|
1315
|
+
const ctrl = controllers[i];
|
|
1316
|
+
const timer = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
1317
|
+
try {
|
|
1318
|
+
const res = await fetch(`${baseUrl.replace(/\/+$/, "")}/trpc/health`, {
|
|
1319
|
+
method: "GET",
|
|
1320
|
+
signal: ctrl.signal,
|
|
1321
|
+
// Cross-origin probes from a browser sandbox are fine — the
|
|
1322
|
+
// /trpc/health response is open-CORS by the Fastify default.
|
|
1323
|
+
// No credentials needed (this is a transport-quality probe,
|
|
1324
|
+
// not an auth round-trip).
|
|
1325
|
+
credentials: "omit"
|
|
1326
|
+
});
|
|
1327
|
+
if (!res.ok) throw new Error(`${res.status}`);
|
|
1328
|
+
return baseUrl;
|
|
1329
|
+
} finally {
|
|
1330
|
+
clearTimeout(timer);
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
try {
|
|
1334
|
+
const winner = await Promise.any(probes);
|
|
1335
|
+
for (const c of controllers) {
|
|
1336
|
+
try {
|
|
1337
|
+
c.abort();
|
|
1338
|
+
} catch {
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
return winner;
|
|
1342
|
+
} catch {
|
|
1343
|
+
return null;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
var DetectionClass = /* @__PURE__ */ ((DetectionClass2) => {
|
|
2321
1347
|
DetectionClass2["Motion"] = "motion";
|
|
2322
1348
|
DetectionClass2["Person"] = "person";
|
|
2323
1349
|
DetectionClass2["Vehicle"] = "vehicle";
|
|
@@ -2329,8 +1355,8 @@ var DetectionClass = /* @__PURE__ */ (function(DetectionClass2) {
|
|
|
2329
1355
|
DetectionClass2["Doorbell"] = "doorbell";
|
|
2330
1356
|
DetectionClass2["Sensor"] = "sensor";
|
|
2331
1357
|
return DetectionClass2;
|
|
2332
|
-
})({});
|
|
2333
|
-
|
|
1358
|
+
})(DetectionClass || {});
|
|
1359
|
+
const animalClasses = [
|
|
2334
1360
|
"animal",
|
|
2335
1361
|
"dog_cat",
|
|
2336
1362
|
"dog",
|
|
@@ -2358,7 +1384,7 @@ var animalClasses = [
|
|
|
2358
1384
|
"turtle",
|
|
2359
1385
|
"lizard"
|
|
2360
1386
|
];
|
|
2361
|
-
|
|
1387
|
+
const personClasses = [
|
|
2362
1388
|
"person",
|
|
2363
1389
|
"people",
|
|
2364
1390
|
"pedestrian",
|
|
@@ -2372,7 +1398,7 @@ var personClasses = [
|
|
|
2372
1398
|
"head",
|
|
2373
1399
|
"body"
|
|
2374
1400
|
];
|
|
2375
|
-
|
|
1401
|
+
const vehicleClasses = [
|
|
2376
1402
|
"vehicle",
|
|
2377
1403
|
"car",
|
|
2378
1404
|
"truck",
|
|
@@ -2391,7 +1417,7 @@ var vehicleClasses = [
|
|
|
2391
1417
|
"ship",
|
|
2392
1418
|
"helicopter"
|
|
2393
1419
|
];
|
|
2394
|
-
|
|
1420
|
+
const faceClasses = [
|
|
2395
1421
|
"face",
|
|
2396
1422
|
"eyes",
|
|
2397
1423
|
"nose",
|
|
@@ -2419,7 +1445,7 @@ var faceClasses = [
|
|
|
2419
1445
|
"facial_landmark",
|
|
2420
1446
|
"facial_keypoint"
|
|
2421
1447
|
];
|
|
2422
|
-
|
|
1448
|
+
const licensePlateClasses = [
|
|
2423
1449
|
"plate",
|
|
2424
1450
|
"license_plate",
|
|
2425
1451
|
"front_plate",
|
|
@@ -2443,19 +1469,13 @@ var licensePlateClasses = [
|
|
|
2443
1469
|
"obscured_plate",
|
|
2444
1470
|
"dirty_plate"
|
|
2445
1471
|
];
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
"other"
|
|
2450
|
-
];
|
|
2451
|
-
var packageClasses = [
|
|
2452
|
-
"package",
|
|
2453
|
-
"packet"
|
|
2454
|
-
];
|
|
2455
|
-
var audioClasses = [
|
|
1472
|
+
const motionClasses = ["motion", "movement", "other"];
|
|
1473
|
+
const packageClasses = ["package", "packet"];
|
|
1474
|
+
const audioClasses = [
|
|
2456
1475
|
"audio"
|
|
1476
|
+
/* Audio */
|
|
2457
1477
|
];
|
|
2458
|
-
|
|
1478
|
+
const audioLabelClasses = [
|
|
2459
1479
|
"speech",
|
|
2460
1480
|
"scream",
|
|
2461
1481
|
"babbling",
|
|
@@ -2516,11 +1536,8 @@ var audioLabelClasses = [
|
|
|
2516
1536
|
"dog",
|
|
2517
1537
|
"dogs"
|
|
2518
1538
|
];
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
"ring"
|
|
2522
|
-
];
|
|
2523
|
-
var sensorLabelClasses = [
|
|
1539
|
+
const doorbellClasses = ["doorbell", "ring"];
|
|
1540
|
+
const sensorLabelClasses = [
|
|
2524
1541
|
"lock",
|
|
2525
1542
|
"binary",
|
|
2526
1543
|
"flood",
|
|
@@ -2531,92 +1548,113 @@ var sensorLabelClasses = [
|
|
|
2531
1548
|
"flooded",
|
|
2532
1549
|
"entry_open"
|
|
2533
1550
|
];
|
|
2534
|
-
|
|
1551
|
+
const detectionClassesDefaultMap = {
|
|
2535
1552
|
...animalClasses.reduce((tot, curr) => ({
|
|
2536
1553
|
...tot,
|
|
2537
1554
|
[curr]: "animal"
|
|
1555
|
+
/* Animal */
|
|
2538
1556
|
}), {}),
|
|
2539
1557
|
...personClasses.reduce((tot, curr) => ({
|
|
2540
1558
|
...tot,
|
|
2541
1559
|
[curr]: "person"
|
|
1560
|
+
/* Person */
|
|
2542
1561
|
}), {}),
|
|
2543
1562
|
...vehicleClasses.reduce((tot, curr) => ({
|
|
2544
1563
|
...tot,
|
|
2545
1564
|
[curr]: "vehicle"
|
|
1565
|
+
/* Vehicle */
|
|
2546
1566
|
}), {}),
|
|
2547
1567
|
...motionClasses.reduce((tot, curr) => ({
|
|
2548
1568
|
...tot,
|
|
2549
1569
|
[curr]: "motion"
|
|
1570
|
+
/* Motion */
|
|
2550
1571
|
}), {}),
|
|
2551
1572
|
...packageClasses.reduce((tot, curr) => ({
|
|
2552
1573
|
...tot,
|
|
2553
1574
|
[curr]: "package"
|
|
1575
|
+
/* Package */
|
|
2554
1576
|
}), {}),
|
|
2555
1577
|
...faceClasses.reduce((tot, curr) => ({
|
|
2556
1578
|
...tot,
|
|
2557
1579
|
[curr]: "face"
|
|
1580
|
+
/* Face */
|
|
2558
1581
|
}), {}),
|
|
2559
1582
|
...licensePlateClasses.reduce((tot, curr) => ({
|
|
2560
1583
|
...tot,
|
|
2561
1584
|
[curr]: "plate"
|
|
1585
|
+
/* Plate */
|
|
2562
1586
|
}), {}),
|
|
2563
1587
|
...audioClasses.reduce((tot, curr) => ({
|
|
2564
1588
|
...tot,
|
|
2565
1589
|
[curr]: "audio"
|
|
1590
|
+
/* Audio */
|
|
2566
1591
|
}), {}),
|
|
2567
1592
|
...audioLabelClasses.reduce((tot, curr) => ({
|
|
2568
1593
|
...tot,
|
|
2569
1594
|
[curr]: "audio"
|
|
1595
|
+
/* Audio */
|
|
2570
1596
|
}), {}),
|
|
2571
1597
|
...doorbellClasses.reduce((tot, curr) => ({
|
|
2572
1598
|
...tot,
|
|
2573
1599
|
[curr]: "doorbell"
|
|
1600
|
+
/* Doorbell */
|
|
2574
1601
|
}), {}),
|
|
2575
1602
|
...sensorLabelClasses.reduce((tot, curr) => ({
|
|
2576
1603
|
...tot,
|
|
2577
1604
|
[curr]: "sensor"
|
|
1605
|
+
/* Sensor */
|
|
2578
1606
|
}), {})
|
|
2579
1607
|
};
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
1608
|
+
const isFaceClassname = (c) => faceClasses.includes(c);
|
|
1609
|
+
const isPlateClassname = (c) => licensePlateClasses.includes(c);
|
|
1610
|
+
const isAnimalClassname = (c) => animalClasses.includes(c);
|
|
1611
|
+
const isPersonClassname = (c) => personClasses.includes(c);
|
|
1612
|
+
const isVehicleClassname = (c) => vehicleClasses.includes(c);
|
|
1613
|
+
const isMotionClassname = (c) => motionClasses.includes(c);
|
|
1614
|
+
const isDoorbellClassname = (c) => doorbellClasses.includes(c);
|
|
1615
|
+
const isPackageClassname = (c) => packageClasses.includes(c);
|
|
1616
|
+
const isAudioClassname = (c) => audioClasses.includes(c) || audioLabelClasses.includes(c);
|
|
1617
|
+
const isSensorLabelClassname = (c) => sensorLabelClasses.includes(c);
|
|
1618
|
+
const isLabelDetection = (c) => isFaceClassname(c) || isPlateClassname(c);
|
|
1619
|
+
const getParentClass = (className) => detectionClassesDefaultMap[className];
|
|
1620
|
+
const getParentDetectionClass = (det) => {
|
|
2593
1621
|
const { className } = det;
|
|
2594
1622
|
const baseMap = {
|
|
2595
|
-
[
|
|
2596
|
-
|
|
1623
|
+
[
|
|
1624
|
+
"face"
|
|
1625
|
+
/* Face */
|
|
1626
|
+
]: "person",
|
|
1627
|
+
[
|
|
1628
|
+
"plate"
|
|
1629
|
+
/* Plate */
|
|
1630
|
+
]: "vehicle"
|
|
1631
|
+
/* Vehicle */
|
|
2597
1632
|
};
|
|
2598
1633
|
const parentGroup = detectionClassesDefaultMap[className];
|
|
2599
1634
|
if (parentGroup && parentGroup !== className) return parentGroup;
|
|
2600
1635
|
return baseMap[className];
|
|
2601
|
-
}
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
1636
|
+
};
|
|
1637
|
+
const defaultDetectionClasses = Object.values(DetectionClass);
|
|
1638
|
+
const DEFAULT_ENABLED_CLASSES = defaultDetectionClasses.filter(
|
|
1639
|
+
(c) => c !== "motion"
|
|
1640
|
+
/* Motion */
|
|
1641
|
+
);
|
|
1642
|
+
const TIMELINE_PRESET_CRITICAL = [
|
|
2605
1643
|
"person",
|
|
2606
1644
|
"doorbell",
|
|
2607
1645
|
"package"
|
|
1646
|
+
/* Package */
|
|
2608
1647
|
];
|
|
2609
|
-
|
|
1648
|
+
const TIMELINE_PRESET_IMPORTANT = [
|
|
2610
1649
|
...TIMELINE_PRESET_CRITICAL,
|
|
2611
1650
|
"vehicle",
|
|
2612
1651
|
"animal",
|
|
2613
1652
|
"audio",
|
|
2614
1653
|
"face",
|
|
2615
1654
|
"plate"
|
|
1655
|
+
/* Plate */
|
|
2616
1656
|
];
|
|
2617
|
-
|
|
2618
|
-
...DEFAULT_ENABLED_CLASSES
|
|
2619
|
-
];
|
|
1657
|
+
const TIMELINE_PRESET_ALL = [...DEFAULT_ENABLED_CLASSES];
|
|
2620
1658
|
function getClassesForTimelinePreset(preset, customClasses) {
|
|
2621
1659
|
switch (preset) {
|
|
2622
1660
|
case "critical":
|
|
@@ -2631,10 +1669,7 @@ function getClassesForTimelinePreset(preset, customClasses) {
|
|
|
2631
1669
|
return DEFAULT_ENABLED_CLASSES;
|
|
2632
1670
|
}
|
|
2633
1671
|
}
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
// src/devices.ts
|
|
2637
|
-
var RAW_TO_CANONICAL = {
|
|
1672
|
+
const RAW_TO_CANONICAL = {
|
|
2638
1673
|
// Scrypted PascalCase
|
|
2639
1674
|
Light: "light",
|
|
2640
1675
|
Switch: "switch",
|
|
@@ -2665,7 +1700,7 @@ var RAW_TO_CANONICAL = {
|
|
|
2665
1700
|
media_player: "media_player",
|
|
2666
1701
|
script: "script"
|
|
2667
1702
|
};
|
|
2668
|
-
|
|
1703
|
+
const HA_DOMAIN_TYPE_MAP = {
|
|
2669
1704
|
light: "light",
|
|
2670
1705
|
switch: "switch",
|
|
2671
1706
|
input_boolean: "switch",
|
|
@@ -2693,7 +1728,7 @@ var HA_DOMAIN_TYPE_MAP = {
|
|
|
2693
1728
|
weather: "weather",
|
|
2694
1729
|
water_heater: "climate"
|
|
2695
1730
|
};
|
|
2696
|
-
|
|
1731
|
+
const SCRYPTED_TYPE_TO_CANONICAL = {
|
|
2697
1732
|
Light: "light",
|
|
2698
1733
|
Switch: "switch",
|
|
2699
1734
|
WindowCovering: "cover",
|
|
@@ -2717,8 +1752,7 @@ function getCanonicalDeviceType(rawType) {
|
|
|
2717
1752
|
const lower = rawType.toLowerCase();
|
|
2718
1753
|
return RAW_TO_CANONICAL[lower] ?? null;
|
|
2719
1754
|
}
|
|
2720
|
-
|
|
2721
|
-
var ELIGIBLE_SCRYPTED_DEVICE_TYPES = [
|
|
1755
|
+
const ELIGIBLE_SCRYPTED_DEVICE_TYPES = [
|
|
2722
1756
|
"Entry",
|
|
2723
1757
|
"Light",
|
|
2724
1758
|
"Switch",
|
|
@@ -2731,8 +1765,8 @@ var ELIGIBLE_SCRYPTED_DEVICE_TYPES = [
|
|
|
2731
1765
|
"Select",
|
|
2732
1766
|
"Program"
|
|
2733
1767
|
];
|
|
2734
|
-
|
|
2735
|
-
|
|
1768
|
+
const ELIGIBLE_SCRYPTED_DEVICE_TYPES_SET = new Set(ELIGIBLE_SCRYPTED_DEVICE_TYPES);
|
|
1769
|
+
const ELIGIBLE_HA_DOMAINS = [
|
|
2736
1770
|
"light",
|
|
2737
1771
|
"switch",
|
|
2738
1772
|
"input_boolean",
|
|
@@ -2747,179 +1781,109 @@ var ELIGIBLE_HA_DOMAINS = [
|
|
|
2747
1781
|
"media_player",
|
|
2748
1782
|
"script"
|
|
2749
1783
|
];
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
// src/features.ts
|
|
2753
|
-
var FEATURE_MATRIX = [
|
|
1784
|
+
const ELIGIBLE_HA_DOMAINS_SET = new Set(ELIGIBLE_HA_DOMAINS);
|
|
1785
|
+
const FEATURE_MATRIX = [
|
|
2754
1786
|
{
|
|
2755
1787
|
id: "liveStream",
|
|
2756
1788
|
label: "Live Stream",
|
|
2757
|
-
sources: {
|
|
2758
|
-
frigate: true,
|
|
2759
|
-
scrypted: true,
|
|
2760
|
-
rtsp: true
|
|
2761
|
-
},
|
|
1789
|
+
sources: { frigate: true, scrypted: true, rtsp: true },
|
|
2762
1790
|
adapterMethod: "getLiveStream"
|
|
2763
1791
|
},
|
|
2764
1792
|
{
|
|
2765
1793
|
id: "multiResolution",
|
|
2766
1794
|
label: "Multi-Resolution",
|
|
2767
|
-
sources: {
|
|
2768
|
-
frigate: true,
|
|
2769
|
-
scrypted: true,
|
|
2770
|
-
rtsp: false
|
|
2771
|
-
},
|
|
1795
|
+
sources: { frigate: true, scrypted: true, rtsp: false },
|
|
2772
1796
|
adapterMethod: "getResolutions"
|
|
2773
1797
|
},
|
|
2774
1798
|
{
|
|
2775
1799
|
id: "motion",
|
|
2776
1800
|
label: "Motion Detection",
|
|
2777
|
-
sources: {
|
|
2778
|
-
frigate: false,
|
|
2779
|
-
scrypted: true,
|
|
2780
|
-
rtsp: false
|
|
2781
|
-
},
|
|
1801
|
+
sources: { frigate: false, scrypted: true, rtsp: false },
|
|
2782
1802
|
adapterMethod: "getMotion"
|
|
2783
1803
|
},
|
|
2784
1804
|
{
|
|
2785
1805
|
id: "objectDetection",
|
|
2786
1806
|
label: "Object Detection",
|
|
2787
|
-
sources: {
|
|
2788
|
-
frigate: false,
|
|
2789
|
-
scrypted: true,
|
|
2790
|
-
rtsp: false
|
|
2791
|
-
},
|
|
1807
|
+
sources: { frigate: false, scrypted: true, rtsp: false },
|
|
2792
1808
|
adapterMethod: "getObjectDetections"
|
|
2793
1809
|
},
|
|
2794
1810
|
{
|
|
2795
1811
|
id: "audioVolume",
|
|
2796
1812
|
label: "Audio Level",
|
|
2797
|
-
sources: {
|
|
2798
|
-
frigate: false,
|
|
2799
|
-
scrypted: true,
|
|
2800
|
-
rtsp: false
|
|
2801
|
-
},
|
|
1813
|
+
sources: { frigate: false, scrypted: true, rtsp: false },
|
|
2802
1814
|
adapterMethod: "getAudioVolume"
|
|
2803
1815
|
},
|
|
2804
1816
|
{
|
|
2805
1817
|
id: "audioVolumes",
|
|
2806
1818
|
label: "Audio Volumes (dBFS)",
|
|
2807
|
-
sources: {
|
|
2808
|
-
frigate: false,
|
|
2809
|
-
scrypted: true,
|
|
2810
|
-
rtsp: false
|
|
2811
|
-
},
|
|
1819
|
+
sources: { frigate: false, scrypted: true, rtsp: false },
|
|
2812
1820
|
adapterMethod: "getAudioVolumes"
|
|
2813
1821
|
},
|
|
2814
1822
|
{
|
|
2815
1823
|
id: "ptz",
|
|
2816
1824
|
label: "PTZ Control",
|
|
2817
|
-
sources: {
|
|
2818
|
-
frigate: false,
|
|
2819
|
-
scrypted: true,
|
|
2820
|
-
rtsp: false
|
|
2821
|
-
},
|
|
1825
|
+
sources: { frigate: false, scrypted: true, rtsp: false },
|
|
2822
1826
|
adapterMethod: "getPTZ"
|
|
2823
1827
|
},
|
|
2824
1828
|
{
|
|
2825
1829
|
id: "intercom",
|
|
2826
1830
|
label: "Intercom (Mic)",
|
|
2827
|
-
sources: {
|
|
2828
|
-
frigate: false,
|
|
2829
|
-
scrypted: true,
|
|
2830
|
-
rtsp: false
|
|
2831
|
-
},
|
|
1831
|
+
sources: { frigate: false, scrypted: true, rtsp: false },
|
|
2832
1832
|
adapterMethod: "getIntercomSupport"
|
|
2833
1833
|
},
|
|
2834
1834
|
{
|
|
2835
1835
|
id: "deviceStatus",
|
|
2836
1836
|
label: "Device Status",
|
|
2837
|
-
sources: {
|
|
2838
|
-
frigate: false,
|
|
2839
|
-
scrypted: true,
|
|
2840
|
-
rtsp: false
|
|
2841
|
-
},
|
|
1837
|
+
sources: { frigate: false, scrypted: true, rtsp: false },
|
|
2842
1838
|
adapterMethod: "getStatus"
|
|
2843
1839
|
},
|
|
2844
1840
|
{
|
|
2845
1841
|
id: "timeline",
|
|
2846
1842
|
label: "Detection Timeline",
|
|
2847
|
-
sources: {
|
|
2848
|
-
frigate: true,
|
|
2849
|
-
scrypted: true,
|
|
2850
|
-
rtsp: false
|
|
2851
|
-
},
|
|
1843
|
+
sources: { frigate: true, scrypted: true, rtsp: false },
|
|
2852
1844
|
adapterMethod: "getCameraDayData"
|
|
2853
1845
|
},
|
|
2854
1846
|
{
|
|
2855
1847
|
id: "clusteredTimeline",
|
|
2856
1848
|
label: "Clustered Timeline",
|
|
2857
|
-
sources: {
|
|
2858
|
-
frigate: true,
|
|
2859
|
-
scrypted: true,
|
|
2860
|
-
rtsp: false
|
|
2861
|
-
},
|
|
1849
|
+
sources: { frigate: true, scrypted: true, rtsp: false },
|
|
2862
1850
|
requiresBackend: true,
|
|
2863
1851
|
adapterMethod: "getClusteredDayData"
|
|
2864
1852
|
},
|
|
2865
1853
|
{
|
|
2866
1854
|
id: "detectionClasses",
|
|
2867
1855
|
label: "Detection Classes",
|
|
2868
|
-
sources: {
|
|
2869
|
-
frigate: true,
|
|
2870
|
-
scrypted: true,
|
|
2871
|
-
rtsp: false
|
|
2872
|
-
},
|
|
1856
|
+
sources: { frigate: true, scrypted: true, rtsp: false },
|
|
2873
1857
|
adapterMethod: "getDetectionClasses"
|
|
2874
1858
|
},
|
|
2875
1859
|
{
|
|
2876
1860
|
id: "videoClips",
|
|
2877
1861
|
label: "Video Clips",
|
|
2878
|
-
sources: {
|
|
2879
|
-
frigate: true,
|
|
2880
|
-
scrypted: true,
|
|
2881
|
-
rtsp: false
|
|
2882
|
-
},
|
|
1862
|
+
sources: { frigate: true, scrypted: true, rtsp: false },
|
|
2883
1863
|
adapterMethod: "getVideoClips"
|
|
2884
1864
|
},
|
|
2885
1865
|
{
|
|
2886
1866
|
id: "nvrPlayback",
|
|
2887
1867
|
label: "NVR Playback",
|
|
2888
|
-
sources: {
|
|
2889
|
-
frigate: true,
|
|
2890
|
-
scrypted: true,
|
|
2891
|
-
rtsp: false
|
|
2892
|
-
},
|
|
1868
|
+
sources: { frigate: true, scrypted: true, rtsp: false },
|
|
2893
1869
|
adapterMethod: "getNvrPlaybackSupported"
|
|
2894
1870
|
},
|
|
2895
1871
|
{
|
|
2896
1872
|
id: "nvrScrub",
|
|
2897
1873
|
label: "NVR Scrub/Seek",
|
|
2898
|
-
sources: {
|
|
2899
|
-
frigate: false,
|
|
2900
|
-
scrypted: true,
|
|
2901
|
-
rtsp: false
|
|
2902
|
-
},
|
|
1874
|
+
sources: { frigate: false, scrypted: true, rtsp: false },
|
|
2903
1875
|
adapterMethod: "seekRecordingStream"
|
|
2904
1876
|
},
|
|
2905
1877
|
{
|
|
2906
1878
|
id: "recordingThumbnail",
|
|
2907
1879
|
label: "Recording Thumbnails",
|
|
2908
|
-
sources: {
|
|
2909
|
-
frigate: true,
|
|
2910
|
-
scrypted: true,
|
|
2911
|
-
rtsp: false
|
|
2912
|
-
},
|
|
1880
|
+
sources: { frigate: true, scrypted: true, rtsp: false },
|
|
2913
1881
|
adapterMethod: "getRecordingStreamThumbnail"
|
|
2914
1882
|
},
|
|
2915
1883
|
{
|
|
2916
1884
|
id: "nvrSeekToLive",
|
|
2917
1885
|
label: "Seek to Live",
|
|
2918
|
-
sources: {
|
|
2919
|
-
frigate: false,
|
|
2920
|
-
scrypted: true,
|
|
2921
|
-
rtsp: false
|
|
2922
|
-
},
|
|
1886
|
+
sources: { frigate: false, scrypted: true, rtsp: false },
|
|
2923
1887
|
adapterMethod: "seekNvrToLive"
|
|
2924
1888
|
}
|
|
2925
1889
|
];
|
|
@@ -2930,17 +1894,12 @@ function isFeatureAvailable(featureId, source, platform) {
|
|
|
2930
1894
|
if (entry.platforms && entry.platforms[platform] === false) return false;
|
|
2931
1895
|
return true;
|
|
2932
1896
|
}
|
|
2933
|
-
__name(isFeatureAvailable, "isFeatureAvailable");
|
|
2934
1897
|
function getSourceFeatures(source) {
|
|
2935
1898
|
return FEATURE_MATRIX.filter((f) => f.sources[source]);
|
|
2936
1899
|
}
|
|
2937
|
-
__name(getSourceFeatures, "getSourceFeatures");
|
|
2938
1900
|
function getBackendRequiredFeatures() {
|
|
2939
1901
|
return FEATURE_MATRIX.filter((f) => f.requiresBackend);
|
|
2940
1902
|
}
|
|
2941
|
-
__name(getBackendRequiredFeatures, "getBackendRequiredFeatures");
|
|
2942
|
-
|
|
2943
|
-
// src/adaptive-stream.ts
|
|
2944
1903
|
function selectOptimalStream(streams, constraints, defaultTransport) {
|
|
2945
1904
|
if (streams.length === 0) return null;
|
|
2946
1905
|
const viewportPixels = constraints.viewportWidth * constraints.viewportHeight * (constraints.pixelRatio ?? 1);
|
|
@@ -2981,11 +1940,7 @@ function selectOptimalStream(streams, constraints, defaultTransport) {
|
|
|
2981
1940
|
if (bw < 5 && s.metadata.codec.includes("265")) score += 10;
|
|
2982
1941
|
if (bw >= 10 && s.metadata.codec.includes("264")) score += 5;
|
|
2983
1942
|
}
|
|
2984
|
-
return {
|
|
2985
|
-
...s,
|
|
2986
|
-
score,
|
|
2987
|
-
targetTier
|
|
2988
|
-
};
|
|
1943
|
+
return { ...s, score, targetTier };
|
|
2989
1944
|
});
|
|
2990
1945
|
scored.sort((a, b) => b.score - a.score);
|
|
2991
1946
|
const best = scored[0];
|
|
@@ -2995,71 +1950,62 @@ function selectOptimalStream(streams, constraints, defaultTransport) {
|
|
|
2995
1950
|
transport: best.transport,
|
|
2996
1951
|
label: best.label,
|
|
2997
1952
|
metadata: best.metadata,
|
|
2998
|
-
reason: `${best.targetTier} quality
|
|
1953
|
+
reason: `${best.targetTier} quality → ${best.profile}/${best.transport} (score: ${best.score})`
|
|
2999
1954
|
};
|
|
3000
1955
|
}
|
|
3001
|
-
__name(selectOptimalStream, "selectOptimalStream");
|
|
3002
1956
|
function getNextEvalInterval(constraints, wasSwitch) {
|
|
3003
1957
|
if (wasSwitch) return 10;
|
|
3004
1958
|
if (constraints.isCellular) return 15;
|
|
3005
1959
|
if ((constraints.packetLoss ?? 0) > 0.02) return 15;
|
|
3006
1960
|
return 30;
|
|
3007
1961
|
}
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
vehicleClasses
|
|
3059
|
-
});
|
|
3060
|
-
/*! Bundled license information:
|
|
3061
|
-
|
|
3062
|
-
@trpc/client/dist/httpLink-lG_6juPY.mjs:
|
|
3063
|
-
(* istanbul ignore if -- @preserve *)
|
|
3064
|
-
*/
|
|
3065
|
-
//# sourceMappingURL=index.cjs.map
|
|
1962
|
+
exports.DEFAULT_ENABLED_CLASSES = DEFAULT_ENABLED_CLASSES;
|
|
1963
|
+
exports.DetectionClass = DetectionClass;
|
|
1964
|
+
exports.ELIGIBLE_HA_DOMAINS = ELIGIBLE_HA_DOMAINS;
|
|
1965
|
+
exports.ELIGIBLE_HA_DOMAINS_SET = ELIGIBLE_HA_DOMAINS_SET;
|
|
1966
|
+
exports.ELIGIBLE_SCRYPTED_DEVICE_TYPES = ELIGIBLE_SCRYPTED_DEVICE_TYPES;
|
|
1967
|
+
exports.ELIGIBLE_SCRYPTED_DEVICE_TYPES_SET = ELIGIBLE_SCRYPTED_DEVICE_TYPES_SET;
|
|
1968
|
+
exports.FEATURE_MATRIX = FEATURE_MATRIX;
|
|
1969
|
+
exports.HA_DOMAIN_TYPE_MAP = HA_DOMAIN_TYPE_MAP;
|
|
1970
|
+
exports.RAW_TO_CANONICAL = RAW_TO_CANONICAL;
|
|
1971
|
+
exports.SCRYPTED_TYPE_TO_CANONICAL = SCRYPTED_TYPE_TO_CANONICAL;
|
|
1972
|
+
exports.System = System;
|
|
1973
|
+
exports.TIMELINE_PRESET_ALL = TIMELINE_PRESET_ALL;
|
|
1974
|
+
exports.TIMELINE_PRESET_CRITICAL = TIMELINE_PRESET_CRITICAL;
|
|
1975
|
+
exports.TIMELINE_PRESET_IMPORTANT = TIMELINE_PRESET_IMPORTANT;
|
|
1976
|
+
exports.animalClasses = animalClasses;
|
|
1977
|
+
exports.audioClasses = audioClasses;
|
|
1978
|
+
exports.audioLabelClasses = audioLabelClasses;
|
|
1979
|
+
exports.createSystem = createSystem;
|
|
1980
|
+
exports.defaultDetectionClasses = defaultDetectionClasses;
|
|
1981
|
+
exports.detectionClassesDefaultMap = detectionClassesDefaultMap;
|
|
1982
|
+
exports.doorbellClasses = doorbellClasses;
|
|
1983
|
+
exports.faceClasses = faceClasses;
|
|
1984
|
+
exports.getBackendRequiredFeatures = getBackendRequiredFeatures;
|
|
1985
|
+
exports.getCanonicalDeviceType = getCanonicalDeviceType;
|
|
1986
|
+
exports.getClassesForTimelinePreset = getClassesForTimelinePreset;
|
|
1987
|
+
exports.getNextEvalInterval = getNextEvalInterval;
|
|
1988
|
+
exports.getParentClass = getParentClass;
|
|
1989
|
+
exports.getParentDetectionClass = getParentDetectionClass;
|
|
1990
|
+
exports.getSourceFeatures = getSourceFeatures;
|
|
1991
|
+
exports.isAnimalClassname = isAnimalClassname;
|
|
1992
|
+
exports.isAudioClassname = isAudioClassname;
|
|
1993
|
+
exports.isDoorbellClassname = isDoorbellClassname;
|
|
1994
|
+
exports.isFaceClassname = isFaceClassname;
|
|
1995
|
+
exports.isFeatureAvailable = isFeatureAvailable;
|
|
1996
|
+
exports.isLabelDetection = isLabelDetection;
|
|
1997
|
+
exports.isMotionClassname = isMotionClassname;
|
|
1998
|
+
exports.isPackageClassname = isPackageClassname;
|
|
1999
|
+
exports.isPersonClassname = isPersonClassname;
|
|
2000
|
+
exports.isPlateClassname = isPlateClassname;
|
|
2001
|
+
exports.isSensorLabelClassname = isSensorLabelClassname;
|
|
2002
|
+
exports.isVehicleClassname = isVehicleClassname;
|
|
2003
|
+
exports.licensePlateClasses = licensePlateClasses;
|
|
2004
|
+
exports.motionClasses = motionClasses;
|
|
2005
|
+
exports.packageClasses = packageClasses;
|
|
2006
|
+
exports.personClasses = personClasses;
|
|
2007
|
+
exports.raceFastestEndpoint = raceFastestEndpoint;
|
|
2008
|
+
exports.selectOptimalStream = selectOptimalStream;
|
|
2009
|
+
exports.sensorLabelClasses = sensorLabelClasses;
|
|
2010
|
+
exports.vehicleClasses = vehicleClasses;
|
|
2011
|
+
//# sourceMappingURL=index.cjs.map
|