@camstack/sdk 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1769 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1764 -1
- package/dist/index.js.map +1 -1
- package/dist/sdk/src/adaptive-stream.d.ts +91 -0
- package/dist/sdk/src/backend-client.d.ts +306 -0
- package/dist/sdk/src/backend-router.d.ts +5 -0
- package/dist/sdk/src/camera.d.ts +37 -0
- package/dist/sdk/src/detection.d.ts +58 -0
- package/dist/sdk/src/devices.d.ts +147 -0
- package/dist/sdk/src/features.d.ts +31 -0
- package/dist/sdk/src/index.d.ts +15 -0
- package/dist/sdk/src/nvr.d.ts +285 -0
- package/dist/sdk/src/timeline.d.ts +177 -0
- package/dist/sdk/src/types.d.ts +44 -0
- package/dist/types/src/catalogs/coco-classmap.d.ts +4 -0
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/generated/addon-api.d.ts +4869 -0
- package/dist/types/src/index.d.ts +81 -0
- package/dist/types/src/interfaces/addon-i18n.d.ts +40 -0
- package/dist/types/src/interfaces/addon-routes.d.ts +49 -0
- package/dist/types/src/interfaces/addon.d.ts +293 -0
- package/dist/types/src/interfaces/advanced-notifier.d.ts +58 -0
- package/dist/types/src/interfaces/agent-protocol.d.ts +188 -0
- package/dist/types/src/interfaces/agent.d.ts +86 -0
- package/dist/types/src/interfaces/analysis-persistence.d.ts +277 -0
- package/dist/types/src/interfaces/analysis.d.ts +26 -0
- package/dist/types/src/interfaces/api-shared.d.ts +167 -0
- package/dist/types/src/interfaces/auth-provider.d.ts +38 -0
- package/dist/types/src/interfaces/auth.d.ts +46 -0
- package/dist/types/src/interfaces/camera-pipeline.d.ts +120 -0
- package/dist/types/src/interfaces/capability.d.ts +83 -0
- package/dist/types/src/interfaces/classifier.d.ts +7 -0
- package/dist/types/src/interfaces/config-ui.d.ts +151 -0
- package/dist/types/src/interfaces/context.d.ts +43 -0
- package/dist/types/src/interfaces/cropper.d.ts +7 -0
- package/dist/types/src/interfaces/decoder.d.ts +26 -0
- package/dist/types/src/interfaces/detection-addon.d.ts +14 -0
- package/dist/types/src/interfaces/detector.d.ts +7 -0
- package/dist/types/src/interfaces/device-capabilities/accessory.d.ts +13 -0
- package/dist/types/src/interfaces/device-capabilities/audio-detector.d.ts +11 -0
- package/dist/types/src/interfaces/device-capabilities/camera.d.ts +21 -0
- package/dist/types/src/interfaces/device-capabilities/doorbell.d.ts +9 -0
- package/dist/types/src/interfaces/device-capabilities/events.d.ts +46 -0
- package/dist/types/src/interfaces/device-capabilities/index.d.ts +14 -0
- package/dist/types/src/interfaces/device-capabilities/motion-sensor.d.ts +6 -0
- package/dist/types/src/interfaces/device-capabilities/native-detection.d.ts +13 -0
- package/dist/types/src/interfaces/device-capabilities/object-detector.d.ts +58 -0
- package/dist/types/src/interfaces/device-capabilities/pan-tilt-zoom.d.ts +28 -0
- package/dist/types/src/interfaces/device-capabilities/recording.d.ts +17 -0
- package/dist/types/src/interfaces/device-capabilities/siren.d.ts +7 -0
- package/dist/types/src/interfaces/device-capabilities/status-light.d.ts +6 -0
- package/dist/types/src/interfaces/device-capabilities/switch.d.ts +7 -0
- package/dist/types/src/interfaces/device-capabilities/two-way-audio.d.ts +7 -0
- package/dist/types/src/interfaces/device-capability.d.ts +13 -0
- package/dist/types/src/interfaces/device-provider.d.ts +42 -0
- package/dist/types/src/interfaces/device.d.ts +39 -0
- package/dist/types/src/interfaces/event-bus.d.ts +21 -0
- package/dist/types/src/interfaces/feature-flags.d.ts +13 -0
- package/dist/types/src/interfaces/ffmpeg.d.ts +9 -0
- package/dist/types/src/interfaces/inference-capabilities.d.ts +100 -0
- package/dist/types/src/interfaces/inference-engine.d.ts +16 -0
- package/dist/types/src/interfaces/lifecycle.d.ts +18 -0
- package/dist/types/src/interfaces/logging.d.ts +32 -0
- package/dist/types/src/interfaces/model-catalog.d.ts +24 -0
- package/dist/types/src/interfaces/network-quality.d.ts +24 -0
- package/dist/types/src/interfaces/network.d.ts +42 -0
- package/dist/types/src/interfaces/notification.d.ts +52 -0
- package/dist/types/src/interfaces/pipeline-runner.d.ts +22 -0
- package/dist/types/src/interfaces/pipeline-slot.d.ts +9 -0
- package/dist/types/src/interfaces/platform.d.ts +54 -0
- package/dist/types/src/interfaces/process.d.ts +40 -0
- package/dist/types/src/interfaces/python-env.d.ts +19 -0
- package/dist/types/src/interfaces/refiner.d.ts +7 -0
- package/dist/types/src/interfaces/repl.d.ts +25 -0
- package/dist/types/src/interfaces/repositories.d.ts +19 -0
- package/dist/types/src/interfaces/restreamer.d.ts +23 -0
- package/dist/types/src/interfaces/router.d.ts +29 -0
- package/dist/types/src/interfaces/scene-intelligence.d.ts +20 -0
- package/dist/types/src/interfaces/scoped-token.d.ts +21 -0
- package/dist/types/src/interfaces/server-analysis.d.ts +145 -0
- package/dist/types/src/interfaces/server-network.d.ts +77 -0
- package/dist/types/src/interfaces/storage-backend.d.ts +26 -0
- package/dist/types/src/interfaces/storage.d.ts +173 -0
- package/dist/types/src/interfaces/stream-broker.d.ts +91 -0
- package/dist/types/src/interfaces/streaming.d.ts +28 -0
- package/dist/types/src/interfaces/task-handler.d.ts +45 -0
- package/dist/types/src/interfaces/webrtc-provider.d.ts +10 -0
- package/dist/types/src/interfaces/worker-protocol.d.ts +109 -0
- package/dist/types/src/schemas/system-settings-schemas.d.ts +26 -0
- package/dist/types/src/types/analytics.d.ts +74 -0
- package/dist/types/src/types/benchmark.d.ts +111 -0
- package/dist/types/src/types/camera-detection.d.ts +33 -0
- package/dist/types/src/types/config.d.ts +36 -0
- package/dist/types/src/types/detection.d.ts +92 -0
- package/dist/types/src/types/device-type.d.ts +9 -0
- package/dist/types/src/types/entities.d.ts +34 -0
- package/dist/types/src/types/events.d.ts +34 -0
- package/dist/types/src/types/io.d.ts +24 -0
- package/dist/types/src/types/labels.d.ts +11 -0
- package/dist/types/src/types/live-state.d.ts +46 -0
- package/dist/types/src/types/models.d.ts +78 -0
- package/dist/types/src/types/pipeline-schema.d.ts +77 -0
- package/dist/types/src/types/pipeline.d.ts +41 -0
- package/dist/types/src/types/tracked.d.ts +20 -0
- package/dist/types/src/types/zones.d.ts +47 -0
- package/dist/types/src/utils/cosine-similarity.d.ts +2 -0
- package/dist/types/src/utils/hf-url.d.ts +1 -0
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -1,8 +1,1766 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
+
// node_modules/@trpc/client/dist/objectSpread2-BvkFp-_Y.mjs
|
|
5
|
+
var __create = Object.create;
|
|
6
|
+
var __defProp2 = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __commonJS = /* @__PURE__ */ __name((cb, mod) => function() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
}, "__commonJS");
|
|
14
|
+
var __copyProps = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
|
+
key = keys[i];
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp2(to, key, {
|
|
18
|
+
get: ((k) => from[k]).bind(null, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
}, "__copyProps");
|
|
24
|
+
var __toESM = /* @__PURE__ */ __name((mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod)), "__toESM");
|
|
28
|
+
var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
|
29
|
+
function _typeof$2(o) {
|
|
30
|
+
"@babel/helpers - typeof";
|
|
31
|
+
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
32
|
+
return typeof o$1;
|
|
33
|
+
} : function(o$1) {
|
|
34
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
35
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
|
36
|
+
}
|
|
37
|
+
__name(_typeof$2, "_typeof$2");
|
|
38
|
+
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
39
|
+
} });
|
|
40
|
+
var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
|
41
|
+
var _typeof$1 = require_typeof()["default"];
|
|
42
|
+
function toPrimitive$1(t, r) {
|
|
43
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
44
|
+
var e = t[Symbol.toPrimitive];
|
|
45
|
+
if (void 0 !== e) {
|
|
46
|
+
var i = e.call(t, r || "default");
|
|
47
|
+
if ("object" != _typeof$1(i)) return i;
|
|
48
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
49
|
+
}
|
|
50
|
+
return ("string" === r ? String : Number)(t);
|
|
51
|
+
}
|
|
52
|
+
__name(toPrimitive$1, "toPrimitive$1");
|
|
53
|
+
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
54
|
+
} });
|
|
55
|
+
var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
|
56
|
+
var _typeof = require_typeof()["default"];
|
|
57
|
+
var toPrimitive = require_toPrimitive();
|
|
58
|
+
function toPropertyKey$1(t) {
|
|
59
|
+
var i = toPrimitive(t, "string");
|
|
60
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
61
|
+
}
|
|
62
|
+
__name(toPropertyKey$1, "toPropertyKey$1");
|
|
63
|
+
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
64
|
+
} });
|
|
65
|
+
var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
|
66
|
+
var toPropertyKey = require_toPropertyKey();
|
|
67
|
+
function _defineProperty(e, r, t) {
|
|
68
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
69
|
+
value: t,
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true
|
|
73
|
+
}) : e[r] = t, e;
|
|
74
|
+
}
|
|
75
|
+
__name(_defineProperty, "_defineProperty");
|
|
76
|
+
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
77
|
+
} });
|
|
78
|
+
var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
|
|
79
|
+
var defineProperty = require_defineProperty();
|
|
80
|
+
function ownKeys(e, r) {
|
|
81
|
+
var t = Object.keys(e);
|
|
82
|
+
if (Object.getOwnPropertySymbols) {
|
|
83
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
84
|
+
r && (o = o.filter(function(r$1) {
|
|
85
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
86
|
+
})), t.push.apply(t, o);
|
|
87
|
+
}
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
__name(ownKeys, "ownKeys");
|
|
91
|
+
function _objectSpread2(e) {
|
|
92
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
93
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
94
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r$1) {
|
|
95
|
+
defineProperty(e, r$1, t[r$1]);
|
|
96
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
97
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return e;
|
|
101
|
+
}
|
|
102
|
+
__name(_objectSpread2, "_objectSpread2");
|
|
103
|
+
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
104
|
+
} });
|
|
105
|
+
|
|
106
|
+
// node_modules/@trpc/server/dist/observable-UMO3vUa_.mjs
|
|
107
|
+
function observable(subscribe) {
|
|
108
|
+
const self = {
|
|
109
|
+
subscribe(observer) {
|
|
110
|
+
let teardownRef = null;
|
|
111
|
+
let isDone = false;
|
|
112
|
+
let unsubscribed = false;
|
|
113
|
+
let teardownImmediately = false;
|
|
114
|
+
function unsubscribe() {
|
|
115
|
+
if (teardownRef === null) {
|
|
116
|
+
teardownImmediately = true;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (unsubscribed) return;
|
|
120
|
+
unsubscribed = true;
|
|
121
|
+
if (typeof teardownRef === "function") teardownRef();
|
|
122
|
+
else if (teardownRef) teardownRef.unsubscribe();
|
|
123
|
+
}
|
|
124
|
+
__name(unsubscribe, "unsubscribe");
|
|
125
|
+
teardownRef = subscribe({
|
|
126
|
+
next(value) {
|
|
127
|
+
var _observer$next;
|
|
128
|
+
if (isDone) return;
|
|
129
|
+
(_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value);
|
|
130
|
+
},
|
|
131
|
+
error(err) {
|
|
132
|
+
var _observer$error;
|
|
133
|
+
if (isDone) return;
|
|
134
|
+
isDone = true;
|
|
135
|
+
(_observer$error = observer.error) === null || _observer$error === void 0 || _observer$error.call(observer, err);
|
|
136
|
+
unsubscribe();
|
|
137
|
+
},
|
|
138
|
+
complete() {
|
|
139
|
+
var _observer$complete;
|
|
140
|
+
if (isDone) return;
|
|
141
|
+
isDone = true;
|
|
142
|
+
(_observer$complete = observer.complete) === null || _observer$complete === void 0 || _observer$complete.call(observer);
|
|
143
|
+
unsubscribe();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
if (teardownImmediately) unsubscribe();
|
|
147
|
+
return { unsubscribe };
|
|
148
|
+
},
|
|
149
|
+
pipe(...operations) {
|
|
150
|
+
return operations.reduce(pipeReducer, self);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return self;
|
|
154
|
+
}
|
|
155
|
+
__name(observable, "observable");
|
|
156
|
+
function pipeReducer(prev, fn) {
|
|
157
|
+
return fn(prev);
|
|
158
|
+
}
|
|
159
|
+
__name(pipeReducer, "pipeReducer");
|
|
160
|
+
function observableToPromise(observable$1) {
|
|
161
|
+
const ac = new AbortController();
|
|
162
|
+
const promise = new Promise((resolve, reject) => {
|
|
163
|
+
let isDone = false;
|
|
164
|
+
function onDone() {
|
|
165
|
+
if (isDone) return;
|
|
166
|
+
isDone = true;
|
|
167
|
+
obs$.unsubscribe();
|
|
168
|
+
}
|
|
169
|
+
__name(onDone, "onDone");
|
|
170
|
+
ac.signal.addEventListener("abort", () => {
|
|
171
|
+
reject(ac.signal.reason);
|
|
172
|
+
});
|
|
173
|
+
const obs$ = observable$1.subscribe({
|
|
174
|
+
next(data) {
|
|
175
|
+
isDone = true;
|
|
176
|
+
resolve(data);
|
|
177
|
+
onDone();
|
|
178
|
+
},
|
|
179
|
+
error(data) {
|
|
180
|
+
reject(data);
|
|
181
|
+
},
|
|
182
|
+
complete() {
|
|
183
|
+
ac.abort();
|
|
184
|
+
onDone();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
return promise;
|
|
189
|
+
}
|
|
190
|
+
__name(observableToPromise, "observableToPromise");
|
|
191
|
+
|
|
192
|
+
// node_modules/@trpc/server/dist/observable-CUiPknO-.mjs
|
|
193
|
+
function share(_opts) {
|
|
194
|
+
return (source) => {
|
|
195
|
+
let refCount = 0;
|
|
196
|
+
let subscription = null;
|
|
197
|
+
const observers = [];
|
|
198
|
+
function startIfNeeded() {
|
|
199
|
+
if (subscription) return;
|
|
200
|
+
subscription = source.subscribe({
|
|
201
|
+
next(value) {
|
|
202
|
+
for (const observer of observers) {
|
|
203
|
+
var _observer$next;
|
|
204
|
+
(_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
error(error) {
|
|
208
|
+
for (const observer of observers) {
|
|
209
|
+
var _observer$error;
|
|
210
|
+
(_observer$error = observer.error) === null || _observer$error === void 0 || _observer$error.call(observer, error);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
complete() {
|
|
214
|
+
for (const observer of observers) {
|
|
215
|
+
var _observer$complete;
|
|
216
|
+
(_observer$complete = observer.complete) === null || _observer$complete === void 0 || _observer$complete.call(observer);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
__name(startIfNeeded, "startIfNeeded");
|
|
222
|
+
function resetIfNeeded() {
|
|
223
|
+
if (refCount === 0 && subscription) {
|
|
224
|
+
const _sub = subscription;
|
|
225
|
+
subscription = null;
|
|
226
|
+
_sub.unsubscribe();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
__name(resetIfNeeded, "resetIfNeeded");
|
|
230
|
+
return observable((subscriber) => {
|
|
231
|
+
refCount++;
|
|
232
|
+
observers.push(subscriber);
|
|
233
|
+
startIfNeeded();
|
|
234
|
+
return { unsubscribe() {
|
|
235
|
+
refCount--;
|
|
236
|
+
resetIfNeeded();
|
|
237
|
+
const index = observers.findIndex((v) => v === subscriber);
|
|
238
|
+
if (index > -1) observers.splice(index, 1);
|
|
239
|
+
} };
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
__name(share, "share");
|
|
244
|
+
function behaviorSubject(initialValue) {
|
|
245
|
+
let value = initialValue;
|
|
246
|
+
const observerList = [];
|
|
247
|
+
const addObserver = /* @__PURE__ */ __name((observer) => {
|
|
248
|
+
if (value !== void 0) observer.next(value);
|
|
249
|
+
observerList.push(observer);
|
|
250
|
+
}, "addObserver");
|
|
251
|
+
const removeObserver = /* @__PURE__ */ __name((observer) => {
|
|
252
|
+
observerList.splice(observerList.indexOf(observer), 1);
|
|
253
|
+
}, "removeObserver");
|
|
254
|
+
const obs = observable((observer) => {
|
|
255
|
+
addObserver(observer);
|
|
256
|
+
return () => {
|
|
257
|
+
removeObserver(observer);
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
obs.next = (nextValue) => {
|
|
261
|
+
if (value === nextValue) return;
|
|
262
|
+
value = nextValue;
|
|
263
|
+
for (const observer of observerList) observer.next(nextValue);
|
|
264
|
+
};
|
|
265
|
+
obs.get = () => value;
|
|
266
|
+
return obs;
|
|
267
|
+
}
|
|
268
|
+
__name(behaviorSubject, "behaviorSubject");
|
|
269
|
+
|
|
270
|
+
// node_modules/@trpc/client/dist/splitLink-B7Cuf2c_.mjs
|
|
271
|
+
function createChain(opts) {
|
|
272
|
+
return observable((observer) => {
|
|
273
|
+
function execute(index = 0, op = opts.op) {
|
|
274
|
+
const next = opts.links[index];
|
|
275
|
+
if (!next) throw new Error("No more links to execute - did you forget to add an ending link?");
|
|
276
|
+
const subscription = next({
|
|
277
|
+
op,
|
|
278
|
+
next(nextOp) {
|
|
279
|
+
const nextObserver = execute(index + 1, nextOp);
|
|
280
|
+
return nextObserver;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
return subscription;
|
|
284
|
+
}
|
|
285
|
+
__name(execute, "execute");
|
|
286
|
+
const obs$ = execute();
|
|
287
|
+
return obs$.subscribe(observer);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
__name(createChain, "createChain");
|
|
291
|
+
|
|
292
|
+
// node_modules/@trpc/server/dist/codes-DagpWZLc.mjs
|
|
293
|
+
function isObject(value) {
|
|
294
|
+
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
295
|
+
}
|
|
296
|
+
__name(isObject, "isObject");
|
|
297
|
+
function emptyObject() {
|
|
298
|
+
return /* @__PURE__ */ Object.create(null);
|
|
299
|
+
}
|
|
300
|
+
__name(emptyObject, "emptyObject");
|
|
301
|
+
var run = /* @__PURE__ */ __name((fn) => fn(), "run");
|
|
302
|
+
function sleep(ms = 0) {
|
|
303
|
+
return new Promise((res) => setTimeout(res, ms));
|
|
304
|
+
}
|
|
305
|
+
__name(sleep, "sleep");
|
|
306
|
+
var TRPC_ERROR_CODES_BY_KEY = {
|
|
307
|
+
PARSE_ERROR: -32700,
|
|
308
|
+
BAD_REQUEST: -32600,
|
|
309
|
+
INTERNAL_SERVER_ERROR: -32603,
|
|
310
|
+
NOT_IMPLEMENTED: -32603,
|
|
311
|
+
BAD_GATEWAY: -32603,
|
|
312
|
+
SERVICE_UNAVAILABLE: -32603,
|
|
313
|
+
GATEWAY_TIMEOUT: -32603,
|
|
314
|
+
UNAUTHORIZED: -32001,
|
|
315
|
+
PAYMENT_REQUIRED: -32002,
|
|
316
|
+
FORBIDDEN: -32003,
|
|
317
|
+
NOT_FOUND: -32004,
|
|
318
|
+
METHOD_NOT_SUPPORTED: -32005,
|
|
319
|
+
TIMEOUT: -32008,
|
|
320
|
+
CONFLICT: -32009,
|
|
321
|
+
PRECONDITION_FAILED: -32012,
|
|
322
|
+
PAYLOAD_TOO_LARGE: -32013,
|
|
323
|
+
UNSUPPORTED_MEDIA_TYPE: -32015,
|
|
324
|
+
UNPROCESSABLE_CONTENT: -32022,
|
|
325
|
+
PRECONDITION_REQUIRED: -32028,
|
|
326
|
+
TOO_MANY_REQUESTS: -32029,
|
|
327
|
+
CLIENT_CLOSED_REQUEST: -32099
|
|
328
|
+
};
|
|
329
|
+
var retryableRpcCodes = [
|
|
330
|
+
TRPC_ERROR_CODES_BY_KEY.BAD_GATEWAY,
|
|
331
|
+
TRPC_ERROR_CODES_BY_KEY.SERVICE_UNAVAILABLE,
|
|
332
|
+
TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,
|
|
333
|
+
TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR
|
|
334
|
+
];
|
|
335
|
+
|
|
336
|
+
// node_modules/@trpc/server/dist/getErrorShape-vC8mUXJD.mjs
|
|
337
|
+
var __create2 = Object.create;
|
|
338
|
+
var __defProp3 = Object.defineProperty;
|
|
339
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
340
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
341
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
342
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
343
|
+
var __commonJS2 = /* @__PURE__ */ __name((cb, mod) => function() {
|
|
344
|
+
return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
345
|
+
}, "__commonJS");
|
|
346
|
+
var __copyProps2 = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
347
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames2(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
348
|
+
key = keys[i];
|
|
349
|
+
if (!__hasOwnProp2.call(to, key) && key !== except) __defProp3(to, key, {
|
|
350
|
+
get: ((k) => from[k]).bind(null, key),
|
|
351
|
+
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
return to;
|
|
355
|
+
}, "__copyProps");
|
|
356
|
+
var __toESM2 = /* @__PURE__ */ __name((mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", {
|
|
357
|
+
value: mod,
|
|
358
|
+
enumerable: true
|
|
359
|
+
}) : target, mod)), "__toESM");
|
|
360
|
+
var noop = /* @__PURE__ */ __name(() => {
|
|
361
|
+
}, "noop");
|
|
362
|
+
var freezeIfAvailable = /* @__PURE__ */ __name((obj) => {
|
|
363
|
+
if (Object.freeze) Object.freeze(obj);
|
|
364
|
+
}, "freezeIfAvailable");
|
|
365
|
+
function createInnerProxy(callback, path, memo) {
|
|
366
|
+
var _memo$cacheKey;
|
|
367
|
+
const cacheKey = path.join(".");
|
|
368
|
+
(_memo$cacheKey = memo[cacheKey]) !== null && _memo$cacheKey !== void 0 || (memo[cacheKey] = new Proxy(noop, {
|
|
369
|
+
get(_obj, key) {
|
|
370
|
+
if (typeof key !== "string" || key === "then") return void 0;
|
|
371
|
+
return createInnerProxy(callback, [...path, key], memo);
|
|
372
|
+
},
|
|
373
|
+
apply(_1, _2, args) {
|
|
374
|
+
const lastOfPath = path[path.length - 1];
|
|
375
|
+
let opts = {
|
|
376
|
+
args,
|
|
377
|
+
path
|
|
378
|
+
};
|
|
379
|
+
if (lastOfPath === "call") opts = {
|
|
380
|
+
args: args.length >= 2 ? [args[1]] : [],
|
|
381
|
+
path: path.slice(0, -1)
|
|
382
|
+
};
|
|
383
|
+
else if (lastOfPath === "apply") opts = {
|
|
384
|
+
args: args.length >= 2 ? args[1] : [],
|
|
385
|
+
path: path.slice(0, -1)
|
|
386
|
+
};
|
|
387
|
+
freezeIfAvailable(opts.args);
|
|
388
|
+
freezeIfAvailable(opts.path);
|
|
389
|
+
return callback(opts);
|
|
390
|
+
}
|
|
391
|
+
}));
|
|
392
|
+
return memo[cacheKey];
|
|
393
|
+
}
|
|
394
|
+
__name(createInnerProxy, "createInnerProxy");
|
|
395
|
+
var createRecursiveProxy = /* @__PURE__ */ __name((callback) => createInnerProxy(callback, [], emptyObject()), "createRecursiveProxy");
|
|
396
|
+
var createFlatProxy = /* @__PURE__ */ __name((callback) => {
|
|
397
|
+
return new Proxy(noop, { get(_obj, name) {
|
|
398
|
+
if (name === "then") return void 0;
|
|
399
|
+
return callback(name);
|
|
400
|
+
} });
|
|
401
|
+
}, "createFlatProxy");
|
|
402
|
+
var require_typeof2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
|
403
|
+
function _typeof$2(o) {
|
|
404
|
+
"@babel/helpers - typeof";
|
|
405
|
+
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
406
|
+
return typeof o$1;
|
|
407
|
+
} : function(o$1) {
|
|
408
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
409
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
|
410
|
+
}
|
|
411
|
+
__name(_typeof$2, "_typeof$2");
|
|
412
|
+
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
413
|
+
} });
|
|
414
|
+
var require_toPrimitive2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
|
415
|
+
var _typeof$1 = require_typeof2()["default"];
|
|
416
|
+
function toPrimitive$1(t, r) {
|
|
417
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
418
|
+
var e = t[Symbol.toPrimitive];
|
|
419
|
+
if (void 0 !== e) {
|
|
420
|
+
var i = e.call(t, r || "default");
|
|
421
|
+
if ("object" != _typeof$1(i)) return i;
|
|
422
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
423
|
+
}
|
|
424
|
+
return ("string" === r ? String : Number)(t);
|
|
425
|
+
}
|
|
426
|
+
__name(toPrimitive$1, "toPrimitive$1");
|
|
427
|
+
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
428
|
+
} });
|
|
429
|
+
var require_toPropertyKey2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
|
430
|
+
var _typeof = require_typeof2()["default"];
|
|
431
|
+
var toPrimitive = require_toPrimitive2();
|
|
432
|
+
function toPropertyKey$1(t) {
|
|
433
|
+
var i = toPrimitive(t, "string");
|
|
434
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
435
|
+
}
|
|
436
|
+
__name(toPropertyKey$1, "toPropertyKey$1");
|
|
437
|
+
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
438
|
+
} });
|
|
439
|
+
var require_defineProperty2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
|
440
|
+
var toPropertyKey = require_toPropertyKey2();
|
|
441
|
+
function _defineProperty(e, r, t) {
|
|
442
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
443
|
+
value: t,
|
|
444
|
+
enumerable: true,
|
|
445
|
+
configurable: true,
|
|
446
|
+
writable: true
|
|
447
|
+
}) : e[r] = t, e;
|
|
448
|
+
}
|
|
449
|
+
__name(_defineProperty, "_defineProperty");
|
|
450
|
+
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
451
|
+
} });
|
|
452
|
+
var require_objectSpread22 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
|
|
453
|
+
var defineProperty = require_defineProperty2();
|
|
454
|
+
function ownKeys(e, r) {
|
|
455
|
+
var t = Object.keys(e);
|
|
456
|
+
if (Object.getOwnPropertySymbols) {
|
|
457
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
458
|
+
r && (o = o.filter(function(r$1) {
|
|
459
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
460
|
+
})), t.push.apply(t, o);
|
|
461
|
+
}
|
|
462
|
+
return t;
|
|
463
|
+
}
|
|
464
|
+
__name(ownKeys, "ownKeys");
|
|
465
|
+
function _objectSpread2(e) {
|
|
466
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
467
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
468
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r$1) {
|
|
469
|
+
defineProperty(e, r$1, t[r$1]);
|
|
470
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
471
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
return e;
|
|
475
|
+
}
|
|
476
|
+
__name(_objectSpread2, "_objectSpread2");
|
|
477
|
+
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
478
|
+
} });
|
|
479
|
+
var import_objectSpread2 = __toESM2(require_objectSpread22(), 1);
|
|
480
|
+
|
|
481
|
+
// node_modules/@trpc/server/dist/tracked-DiE3uR1B.mjs
|
|
482
|
+
var import_defineProperty = __toESM2(require_defineProperty2(), 1);
|
|
483
|
+
var import_objectSpread2$1 = __toESM2(require_objectSpread22(), 1);
|
|
484
|
+
function transformResultInner(response, transformer) {
|
|
485
|
+
if ("error" in response) {
|
|
486
|
+
const error = transformer.deserialize(response.error);
|
|
487
|
+
return {
|
|
488
|
+
ok: false,
|
|
489
|
+
error: (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, response), {}, { error })
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
const result = (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, response.result), (!response.result.type || response.result.type === "data") && {
|
|
493
|
+
type: "data",
|
|
494
|
+
data: transformer.deserialize(response.result.data)
|
|
495
|
+
});
|
|
496
|
+
return {
|
|
497
|
+
ok: true,
|
|
498
|
+
result
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
__name(transformResultInner, "transformResultInner");
|
|
502
|
+
var TransformResultError = class extends Error {
|
|
503
|
+
static {
|
|
504
|
+
__name(this, "TransformResultError");
|
|
505
|
+
}
|
|
506
|
+
constructor() {
|
|
507
|
+
super("Unable to transform response from server");
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
function transformResult(response, transformer) {
|
|
511
|
+
let result;
|
|
512
|
+
try {
|
|
513
|
+
result = transformResultInner(response, transformer);
|
|
514
|
+
} catch (_unused) {
|
|
515
|
+
throw new TransformResultError();
|
|
516
|
+
}
|
|
517
|
+
if (!result.ok && (!isObject(result.error.error) || typeof result.error.error["code"] !== "number")) throw new TransformResultError();
|
|
518
|
+
if (result.ok && !isObject(result.result)) throw new TransformResultError();
|
|
519
|
+
return result;
|
|
520
|
+
}
|
|
521
|
+
__name(transformResult, "transformResult");
|
|
522
|
+
var import_objectSpread22 = __toESM2(require_objectSpread22(), 1);
|
|
523
|
+
|
|
524
|
+
// node_modules/@trpc/client/dist/TRPCClientError-apv8gw59.mjs
|
|
525
|
+
var import_defineProperty2 = __toESM(require_defineProperty(), 1);
|
|
526
|
+
var import_objectSpread23 = __toESM(require_objectSpread2(), 1);
|
|
527
|
+
function isTRPCClientError(cause) {
|
|
528
|
+
return cause instanceof TRPCClientError;
|
|
529
|
+
}
|
|
530
|
+
__name(isTRPCClientError, "isTRPCClientError");
|
|
531
|
+
function isTRPCErrorResponse(obj) {
|
|
532
|
+
return isObject(obj) && isObject(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string";
|
|
533
|
+
}
|
|
534
|
+
__name(isTRPCErrorResponse, "isTRPCErrorResponse");
|
|
535
|
+
function getMessageFromUnknownError(err, fallback) {
|
|
536
|
+
if (typeof err === "string") return err;
|
|
537
|
+
if (isObject(err) && typeof err["message"] === "string") return err["message"];
|
|
538
|
+
return fallback;
|
|
539
|
+
}
|
|
540
|
+
__name(getMessageFromUnknownError, "getMessageFromUnknownError");
|
|
541
|
+
var TRPCClientError = class TRPCClientError2 extends Error {
|
|
542
|
+
static {
|
|
543
|
+
__name(this, "TRPCClientError");
|
|
544
|
+
}
|
|
545
|
+
constructor(message, opts) {
|
|
546
|
+
var _opts$result, _opts$result2;
|
|
547
|
+
const cause = opts === null || opts === void 0 ? void 0 : opts.cause;
|
|
548
|
+
super(message, { cause });
|
|
549
|
+
(0, import_defineProperty2.default)(this, "cause", void 0);
|
|
550
|
+
(0, import_defineProperty2.default)(this, "shape", void 0);
|
|
551
|
+
(0, import_defineProperty2.default)(this, "data", void 0);
|
|
552
|
+
(0, import_defineProperty2.default)(this, "meta", void 0);
|
|
553
|
+
this.meta = opts === null || opts === void 0 ? void 0 : opts.meta;
|
|
554
|
+
this.cause = cause;
|
|
555
|
+
this.shape = opts === null || opts === void 0 || (_opts$result = opts.result) === null || _opts$result === void 0 ? void 0 : _opts$result.error;
|
|
556
|
+
this.data = opts === null || opts === void 0 || (_opts$result2 = opts.result) === null || _opts$result2 === void 0 ? void 0 : _opts$result2.error.data;
|
|
557
|
+
this.name = "TRPCClientError";
|
|
558
|
+
Object.setPrototypeOf(this, TRPCClientError2.prototype);
|
|
559
|
+
}
|
|
560
|
+
static from(_cause, opts = {}) {
|
|
561
|
+
const cause = _cause;
|
|
562
|
+
if (isTRPCClientError(cause)) {
|
|
563
|
+
if (opts.meta) cause.meta = (0, import_objectSpread23.default)((0, import_objectSpread23.default)({}, cause.meta), opts.meta);
|
|
564
|
+
return cause;
|
|
565
|
+
}
|
|
566
|
+
if (isTRPCErrorResponse(cause)) return new TRPCClientError2(cause.error.message, (0, import_objectSpread23.default)((0, import_objectSpread23.default)({}, opts), {}, {
|
|
567
|
+
result: cause,
|
|
568
|
+
cause: opts.cause
|
|
569
|
+
}));
|
|
570
|
+
return new TRPCClientError2(getMessageFromUnknownError(cause, "Unknown error"), (0, import_objectSpread23.default)((0, import_objectSpread23.default)({}, opts), {}, { cause }));
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
// node_modules/@trpc/client/dist/unstable-internals-Bg7n9BBj.mjs
|
|
575
|
+
function getTransformer(transformer) {
|
|
576
|
+
const _transformer = transformer;
|
|
577
|
+
if (!_transformer) return {
|
|
578
|
+
input: {
|
|
579
|
+
serialize: /* @__PURE__ */ __name((data) => data, "serialize"),
|
|
580
|
+
deserialize: /* @__PURE__ */ __name((data) => data, "deserialize")
|
|
581
|
+
},
|
|
582
|
+
output: {
|
|
583
|
+
serialize: /* @__PURE__ */ __name((data) => data, "serialize"),
|
|
584
|
+
deserialize: /* @__PURE__ */ __name((data) => data, "deserialize")
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
if ("input" in _transformer) return _transformer;
|
|
588
|
+
return {
|
|
589
|
+
input: _transformer,
|
|
590
|
+
output: _transformer
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
__name(getTransformer, "getTransformer");
|
|
594
|
+
|
|
595
|
+
// node_modules/@trpc/client/dist/httpUtils-BNq9QC3d.mjs
|
|
596
|
+
var isFunction2 = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
|
|
597
|
+
function getFetch(customFetchImpl) {
|
|
598
|
+
if (customFetchImpl) return customFetchImpl;
|
|
599
|
+
if (typeof window !== "undefined" && isFunction2(window.fetch)) return window.fetch;
|
|
600
|
+
if (typeof globalThis !== "undefined" && isFunction2(globalThis.fetch)) return globalThis.fetch;
|
|
601
|
+
throw new Error("No fetch implementation found");
|
|
602
|
+
}
|
|
603
|
+
__name(getFetch, "getFetch");
|
|
604
|
+
var import_objectSpread24 = __toESM(require_objectSpread2());
|
|
605
|
+
function resolveHTTPLinkOptions(opts) {
|
|
606
|
+
return {
|
|
607
|
+
url: opts.url.toString(),
|
|
608
|
+
fetch: opts.fetch,
|
|
609
|
+
transformer: getTransformer(opts.transformer),
|
|
610
|
+
methodOverride: opts.methodOverride
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
__name(resolveHTTPLinkOptions, "resolveHTTPLinkOptions");
|
|
614
|
+
function arrayToDict(array) {
|
|
615
|
+
const dict = {};
|
|
616
|
+
for (let index = 0; index < array.length; index++) {
|
|
617
|
+
const element = array[index];
|
|
618
|
+
dict[index] = element;
|
|
619
|
+
}
|
|
620
|
+
return dict;
|
|
621
|
+
}
|
|
622
|
+
__name(arrayToDict, "arrayToDict");
|
|
623
|
+
var METHOD = {
|
|
624
|
+
query: "GET",
|
|
625
|
+
mutation: "POST",
|
|
626
|
+
subscription: "PATCH"
|
|
627
|
+
};
|
|
628
|
+
function getInput(opts) {
|
|
629
|
+
return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input)));
|
|
630
|
+
}
|
|
631
|
+
__name(getInput, "getInput");
|
|
632
|
+
var getUrl = /* @__PURE__ */ __name((opts) => {
|
|
633
|
+
const parts = opts.url.split("?");
|
|
634
|
+
const base = parts[0].replace(/\/$/, "");
|
|
635
|
+
let url = base + "/" + opts.path;
|
|
636
|
+
const queryParts = [];
|
|
637
|
+
if (parts[1]) queryParts.push(parts[1]);
|
|
638
|
+
if ("inputs" in opts) queryParts.push("batch=1");
|
|
639
|
+
if (opts.type === "query" || opts.type === "subscription") {
|
|
640
|
+
const input = getInput(opts);
|
|
641
|
+
if (input !== void 0 && opts.methodOverride !== "POST") queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
|
|
642
|
+
}
|
|
643
|
+
if (queryParts.length) url += "?" + queryParts.join("&");
|
|
644
|
+
return url;
|
|
645
|
+
}, "getUrl");
|
|
646
|
+
var getBody = /* @__PURE__ */ __name((opts) => {
|
|
647
|
+
if (opts.type === "query" && opts.methodOverride !== "POST") return void 0;
|
|
648
|
+
const input = getInput(opts);
|
|
649
|
+
return input !== void 0 ? JSON.stringify(input) : void 0;
|
|
650
|
+
}, "getBody");
|
|
651
|
+
var jsonHttpRequester = /* @__PURE__ */ __name((opts) => {
|
|
652
|
+
return httpRequest((0, import_objectSpread24.default)((0, import_objectSpread24.default)({}, opts), {}, {
|
|
653
|
+
contentTypeHeader: "application/json",
|
|
654
|
+
getUrl,
|
|
655
|
+
getBody
|
|
656
|
+
}));
|
|
657
|
+
}, "jsonHttpRequester");
|
|
658
|
+
var AbortError = class extends Error {
|
|
659
|
+
static {
|
|
660
|
+
__name(this, "AbortError");
|
|
661
|
+
}
|
|
662
|
+
constructor() {
|
|
663
|
+
const name = "AbortError";
|
|
664
|
+
super(name);
|
|
665
|
+
this.name = name;
|
|
666
|
+
this.message = name;
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
var throwIfAborted = /* @__PURE__ */ __name((signal) => {
|
|
670
|
+
var _signal$throwIfAborte;
|
|
671
|
+
if (!(signal === null || signal === void 0 ? void 0 : signal.aborted)) return;
|
|
672
|
+
(_signal$throwIfAborte = signal.throwIfAborted) === null || _signal$throwIfAborte === void 0 || _signal$throwIfAborte.call(signal);
|
|
673
|
+
if (typeof DOMException !== "undefined") throw new DOMException("AbortError", "AbortError");
|
|
674
|
+
throw new AbortError();
|
|
675
|
+
}, "throwIfAborted");
|
|
676
|
+
async function fetchHTTPResponse(opts) {
|
|
677
|
+
var _opts$methodOverride, _opts$trpcAcceptHeade;
|
|
678
|
+
throwIfAborted(opts.signal);
|
|
679
|
+
const url = opts.getUrl(opts);
|
|
680
|
+
const body = opts.getBody(opts);
|
|
681
|
+
const method = (_opts$methodOverride = opts.methodOverride) !== null && _opts$methodOverride !== void 0 ? _opts$methodOverride : METHOD[opts.type];
|
|
682
|
+
const resolvedHeaders = await (async () => {
|
|
683
|
+
const heads = await opts.headers();
|
|
684
|
+
if (Symbol.iterator in heads) return Object.fromEntries(heads);
|
|
685
|
+
return heads;
|
|
686
|
+
})();
|
|
687
|
+
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);
|
|
688
|
+
return getFetch(opts.fetch)(url, {
|
|
689
|
+
method,
|
|
690
|
+
signal: opts.signal,
|
|
691
|
+
body,
|
|
692
|
+
headers
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
__name(fetchHTTPResponse, "fetchHTTPResponse");
|
|
696
|
+
async function httpRequest(opts) {
|
|
697
|
+
const meta = {};
|
|
698
|
+
const res = await fetchHTTPResponse(opts);
|
|
699
|
+
meta.response = res;
|
|
700
|
+
const json = await res.json();
|
|
701
|
+
meta.responseJSON = json;
|
|
702
|
+
return {
|
|
703
|
+
json,
|
|
704
|
+
meta
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
__name(httpRequest, "httpRequest");
|
|
708
|
+
|
|
709
|
+
// node_modules/@trpc/client/dist/httpLink-oiU8eqFi.mjs
|
|
710
|
+
function isOctetType(input) {
|
|
711
|
+
return input instanceof Uint8Array || input instanceof Blob;
|
|
712
|
+
}
|
|
713
|
+
__name(isOctetType, "isOctetType");
|
|
714
|
+
function isFormData(input) {
|
|
715
|
+
return input instanceof FormData;
|
|
716
|
+
}
|
|
717
|
+
__name(isFormData, "isFormData");
|
|
718
|
+
var import_objectSpread25 = __toESM(require_objectSpread2(), 1);
|
|
719
|
+
var universalRequester = /* @__PURE__ */ __name((opts) => {
|
|
720
|
+
if ("input" in opts) {
|
|
721
|
+
const { input } = opts;
|
|
722
|
+
if (isFormData(input)) {
|
|
723
|
+
if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("FormData is only supported for mutations");
|
|
724
|
+
return httpRequest((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, opts), {}, {
|
|
725
|
+
contentTypeHeader: void 0,
|
|
726
|
+
getUrl,
|
|
727
|
+
getBody: /* @__PURE__ */ __name(() => input, "getBody")
|
|
728
|
+
}));
|
|
729
|
+
}
|
|
730
|
+
if (isOctetType(input)) {
|
|
731
|
+
if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("Octet type input is only supported for mutations");
|
|
732
|
+
return httpRequest((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, opts), {}, {
|
|
733
|
+
contentTypeHeader: "application/octet-stream",
|
|
734
|
+
getUrl,
|
|
735
|
+
getBody: /* @__PURE__ */ __name(() => input, "getBody")
|
|
736
|
+
}));
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return jsonHttpRequester(opts);
|
|
740
|
+
}, "universalRequester");
|
|
741
|
+
function httpLink(opts) {
|
|
742
|
+
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
743
|
+
return () => {
|
|
744
|
+
return (operationOpts) => {
|
|
745
|
+
const { op } = operationOpts;
|
|
746
|
+
return observable((observer) => {
|
|
747
|
+
const { path, input, type } = op;
|
|
748
|
+
if (type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
|
|
749
|
+
const request = universalRequester((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, resolvedOpts), {}, {
|
|
750
|
+
type,
|
|
751
|
+
path,
|
|
752
|
+
input,
|
|
753
|
+
signal: op.signal,
|
|
754
|
+
headers() {
|
|
755
|
+
if (!opts.headers) return {};
|
|
756
|
+
if (typeof opts.headers === "function") return opts.headers({ op });
|
|
757
|
+
return opts.headers;
|
|
758
|
+
}
|
|
759
|
+
}));
|
|
760
|
+
let meta = void 0;
|
|
761
|
+
request.then((res) => {
|
|
762
|
+
meta = res.meta;
|
|
763
|
+
const transformed = transformResult(res.json, resolvedOpts.transformer.output);
|
|
764
|
+
if (!transformed.ok) {
|
|
765
|
+
observer.error(TRPCClientError.from(transformed.error, { meta }));
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
observer.next({
|
|
769
|
+
context: res.meta,
|
|
770
|
+
result: transformed.result
|
|
771
|
+
});
|
|
772
|
+
observer.complete();
|
|
773
|
+
}).catch((cause) => {
|
|
774
|
+
observer.error(TRPCClientError.from(cause, { meta }));
|
|
775
|
+
});
|
|
776
|
+
return () => {
|
|
777
|
+
};
|
|
778
|
+
});
|
|
779
|
+
};
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
__name(httpLink, "httpLink");
|
|
783
|
+
|
|
784
|
+
// node_modules/@trpc/client/dist/httpBatchLink-CaWjh1oW.mjs
|
|
785
|
+
var import_objectSpread26 = __toESM(require_objectSpread2(), 1);
|
|
786
|
+
|
|
787
|
+
// node_modules/@trpc/client/dist/loggerLink-ineCN1PO.mjs
|
|
788
|
+
var import_objectSpread27 = __toESM(require_objectSpread2(), 1);
|
|
789
|
+
|
|
790
|
+
// node_modules/@trpc/client/dist/wsLink-DSf4KOdW.mjs
|
|
791
|
+
var jsonEncoder = {
|
|
792
|
+
encode: /* @__PURE__ */ __name((data) => JSON.stringify(data), "encode"),
|
|
793
|
+
decode: /* @__PURE__ */ __name((data) => {
|
|
794
|
+
if (typeof data !== "string") throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");
|
|
795
|
+
return JSON.parse(data);
|
|
796
|
+
}, "decode")
|
|
797
|
+
};
|
|
798
|
+
var lazyDefaults = {
|
|
799
|
+
enabled: false,
|
|
800
|
+
closeMs: 0
|
|
801
|
+
};
|
|
802
|
+
var keepAliveDefaults = {
|
|
803
|
+
enabled: false,
|
|
804
|
+
pongTimeoutMs: 1e3,
|
|
805
|
+
intervalMs: 5e3
|
|
806
|
+
};
|
|
807
|
+
var exponentialBackoff = /* @__PURE__ */ __name((attemptIndex) => {
|
|
808
|
+
return attemptIndex === 0 ? 0 : Math.min(1e3 * 2 ** attemptIndex, 3e4);
|
|
809
|
+
}, "exponentialBackoff");
|
|
810
|
+
var resultOf = /* @__PURE__ */ __name((value, ...args) => {
|
|
811
|
+
return typeof value === "function" ? value(...args) : value;
|
|
812
|
+
}, "resultOf");
|
|
813
|
+
var import_defineProperty$3 = __toESM(require_defineProperty(), 1);
|
|
814
|
+
var TRPCWebSocketClosedError = class TRPCWebSocketClosedError2 extends Error {
|
|
815
|
+
static {
|
|
816
|
+
__name(this, "TRPCWebSocketClosedError");
|
|
817
|
+
}
|
|
818
|
+
constructor(opts) {
|
|
819
|
+
super(opts.message, { cause: opts.cause });
|
|
820
|
+
this.name = "TRPCWebSocketClosedError";
|
|
821
|
+
Object.setPrototypeOf(this, TRPCWebSocketClosedError2.prototype);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
var ResettableTimeout = class {
|
|
825
|
+
static {
|
|
826
|
+
__name(this, "ResettableTimeout");
|
|
827
|
+
}
|
|
828
|
+
constructor(onTimeout, timeoutMs) {
|
|
829
|
+
this.onTimeout = onTimeout;
|
|
830
|
+
this.timeoutMs = timeoutMs;
|
|
831
|
+
(0, import_defineProperty$3.default)(this, "timeout", void 0);
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Resets the current timeout, restarting it with the same duration.
|
|
835
|
+
* Does nothing if no timeout is active.
|
|
836
|
+
*/
|
|
837
|
+
reset() {
|
|
838
|
+
if (!this.timeout) return;
|
|
839
|
+
clearTimeout(this.timeout);
|
|
840
|
+
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
|
841
|
+
}
|
|
842
|
+
start() {
|
|
843
|
+
clearTimeout(this.timeout);
|
|
844
|
+
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
|
845
|
+
}
|
|
846
|
+
stop() {
|
|
847
|
+
clearTimeout(this.timeout);
|
|
848
|
+
this.timeout = void 0;
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
function withResolvers() {
|
|
852
|
+
let resolve;
|
|
853
|
+
let reject;
|
|
854
|
+
const promise = new Promise((res, rej) => {
|
|
855
|
+
resolve = res;
|
|
856
|
+
reject = rej;
|
|
857
|
+
});
|
|
858
|
+
return {
|
|
859
|
+
promise,
|
|
860
|
+
resolve,
|
|
861
|
+
reject
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
__name(withResolvers, "withResolvers");
|
|
865
|
+
async function prepareUrl(urlOptions) {
|
|
866
|
+
const url = await resultOf(urlOptions.url);
|
|
867
|
+
if (!urlOptions.connectionParams) return url;
|
|
868
|
+
const prefix = url.includes("?") ? "&" : "?";
|
|
869
|
+
const connectionParams = `${prefix}connectionParams=1`;
|
|
870
|
+
return url + connectionParams;
|
|
871
|
+
}
|
|
872
|
+
__name(prepareUrl, "prepareUrl");
|
|
873
|
+
async function buildConnectionMessage(connectionParams, encoder) {
|
|
874
|
+
const message = {
|
|
875
|
+
method: "connectionParams",
|
|
876
|
+
data: await resultOf(connectionParams)
|
|
877
|
+
};
|
|
878
|
+
return encoder.encode(message);
|
|
879
|
+
}
|
|
880
|
+
__name(buildConnectionMessage, "buildConnectionMessage");
|
|
881
|
+
var import_defineProperty$2 = __toESM(require_defineProperty(), 1);
|
|
882
|
+
var RequestManager = class {
|
|
883
|
+
static {
|
|
884
|
+
__name(this, "RequestManager");
|
|
885
|
+
}
|
|
886
|
+
constructor() {
|
|
887
|
+
(0, import_defineProperty$2.default)(this, "outgoingRequests", new Array());
|
|
888
|
+
(0, import_defineProperty$2.default)(this, "pendingRequests", {});
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Registers a new request by adding it to the outgoing queue and setting up
|
|
892
|
+
* callbacks for lifecycle events such as completion or error.
|
|
893
|
+
*
|
|
894
|
+
* @param message - The outgoing message to be sent.
|
|
895
|
+
* @param callbacks - Callback functions to observe the request's state.
|
|
896
|
+
* @returns A cleanup function to manually remove the request.
|
|
897
|
+
*/
|
|
898
|
+
register(message, callbacks) {
|
|
899
|
+
const { promise: end, resolve } = withResolvers();
|
|
900
|
+
this.outgoingRequests.push({
|
|
901
|
+
id: String(message.id),
|
|
902
|
+
message,
|
|
903
|
+
end,
|
|
904
|
+
callbacks: {
|
|
905
|
+
next: callbacks.next,
|
|
906
|
+
complete: /* @__PURE__ */ __name(() => {
|
|
907
|
+
callbacks.complete();
|
|
908
|
+
resolve();
|
|
909
|
+
}, "complete"),
|
|
910
|
+
error: /* @__PURE__ */ __name((e) => {
|
|
911
|
+
callbacks.error(e);
|
|
912
|
+
resolve();
|
|
913
|
+
}, "error")
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
return () => {
|
|
917
|
+
this.delete(message.id);
|
|
918
|
+
callbacks.complete();
|
|
919
|
+
resolve();
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Deletes a request from both the outgoing and pending collections, if it exists.
|
|
924
|
+
*/
|
|
925
|
+
delete(messageId) {
|
|
926
|
+
if (messageId === null) return;
|
|
927
|
+
this.outgoingRequests = this.outgoingRequests.filter(({ id }) => id !== String(messageId));
|
|
928
|
+
delete this.pendingRequests[String(messageId)];
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Moves all outgoing requests to the pending state and clears the outgoing queue.
|
|
932
|
+
*
|
|
933
|
+
* The caller is expected to handle the actual sending of the requests
|
|
934
|
+
* (e.g., sending them over the network) after this method is called.
|
|
935
|
+
*
|
|
936
|
+
* @returns The list of requests that were transitioned to the pending state.
|
|
937
|
+
*/
|
|
938
|
+
flush() {
|
|
939
|
+
const requests = this.outgoingRequests;
|
|
940
|
+
this.outgoingRequests = [];
|
|
941
|
+
for (const request of requests) this.pendingRequests[request.id] = request;
|
|
942
|
+
return requests;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Retrieves all currently pending requests, which are in flight awaiting responses
|
|
946
|
+
* or handling ongoing subscriptions.
|
|
947
|
+
*/
|
|
948
|
+
getPendingRequests() {
|
|
949
|
+
return Object.values(this.pendingRequests);
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Retrieves a specific pending request by its message ID.
|
|
953
|
+
*/
|
|
954
|
+
getPendingRequest(messageId) {
|
|
955
|
+
if (messageId === null) return null;
|
|
956
|
+
return this.pendingRequests[String(messageId)];
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Retrieves all outgoing requests, which are waiting to be sent.
|
|
960
|
+
*/
|
|
961
|
+
getOutgoingRequests() {
|
|
962
|
+
return this.outgoingRequests;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Retrieves all requests, both outgoing and pending, with their respective states.
|
|
966
|
+
*
|
|
967
|
+
* @returns An array of all requests with their state ("outgoing" or "pending").
|
|
968
|
+
*/
|
|
969
|
+
getRequests() {
|
|
970
|
+
return [...this.getOutgoingRequests().map((request) => ({
|
|
971
|
+
state: "outgoing",
|
|
972
|
+
message: request.message,
|
|
973
|
+
end: request.end,
|
|
974
|
+
callbacks: request.callbacks
|
|
975
|
+
})), ...this.getPendingRequests().map((request) => ({
|
|
976
|
+
state: "pending",
|
|
977
|
+
message: request.message,
|
|
978
|
+
end: request.end,
|
|
979
|
+
callbacks: request.callbacks
|
|
980
|
+
}))];
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Checks if there are any pending requests, including ongoing subscriptions.
|
|
984
|
+
*/
|
|
985
|
+
hasPendingRequests() {
|
|
986
|
+
return this.getPendingRequests().length > 0;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Checks if there are any pending subscriptions
|
|
990
|
+
*/
|
|
991
|
+
hasPendingSubscriptions() {
|
|
992
|
+
return this.getPendingRequests().some((request) => request.message.method === "subscription");
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Checks if there are any outgoing requests waiting to be sent.
|
|
996
|
+
*/
|
|
997
|
+
hasOutgoingRequests() {
|
|
998
|
+
return this.outgoingRequests.length > 0;
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
var import_defineProperty$1 = __toESM(require_defineProperty(), 1);
|
|
1002
|
+
function asyncWsOpen(ws) {
|
|
1003
|
+
const { promise, resolve, reject } = withResolvers();
|
|
1004
|
+
ws.addEventListener("open", () => {
|
|
1005
|
+
ws.removeEventListener("error", reject);
|
|
1006
|
+
resolve();
|
|
1007
|
+
});
|
|
1008
|
+
ws.addEventListener("error", reject);
|
|
1009
|
+
return promise;
|
|
1010
|
+
}
|
|
1011
|
+
__name(asyncWsOpen, "asyncWsOpen");
|
|
1012
|
+
function setupPingInterval(ws, { intervalMs, pongTimeoutMs }) {
|
|
1013
|
+
let pingTimeout;
|
|
1014
|
+
let pongTimeout;
|
|
1015
|
+
function start() {
|
|
1016
|
+
pingTimeout = setTimeout(() => {
|
|
1017
|
+
ws.send("PING");
|
|
1018
|
+
pongTimeout = setTimeout(() => {
|
|
1019
|
+
ws.close();
|
|
1020
|
+
}, pongTimeoutMs);
|
|
1021
|
+
}, intervalMs);
|
|
1022
|
+
}
|
|
1023
|
+
__name(start, "start");
|
|
1024
|
+
function reset() {
|
|
1025
|
+
clearTimeout(pingTimeout);
|
|
1026
|
+
start();
|
|
1027
|
+
}
|
|
1028
|
+
__name(reset, "reset");
|
|
1029
|
+
function pong() {
|
|
1030
|
+
clearTimeout(pongTimeout);
|
|
1031
|
+
reset();
|
|
1032
|
+
}
|
|
1033
|
+
__name(pong, "pong");
|
|
1034
|
+
ws.addEventListener("open", start);
|
|
1035
|
+
ws.addEventListener("message", ({ data }) => {
|
|
1036
|
+
clearTimeout(pingTimeout);
|
|
1037
|
+
start();
|
|
1038
|
+
if (data === "PONG") pong();
|
|
1039
|
+
});
|
|
1040
|
+
ws.addEventListener("close", () => {
|
|
1041
|
+
clearTimeout(pingTimeout);
|
|
1042
|
+
clearTimeout(pongTimeout);
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
__name(setupPingInterval, "setupPingInterval");
|
|
1046
|
+
var WsConnection = class WsConnection2 {
|
|
1047
|
+
static {
|
|
1048
|
+
__name(this, "WsConnection");
|
|
1049
|
+
}
|
|
1050
|
+
constructor(opts) {
|
|
1051
|
+
var _opts$WebSocketPonyfi;
|
|
1052
|
+
(0, import_defineProperty$1.default)(this, "id", ++WsConnection2.connectCount);
|
|
1053
|
+
(0, import_defineProperty$1.default)(this, "WebSocketPonyfill", void 0);
|
|
1054
|
+
(0, import_defineProperty$1.default)(this, "urlOptions", void 0);
|
|
1055
|
+
(0, import_defineProperty$1.default)(this, "keepAliveOpts", void 0);
|
|
1056
|
+
(0, import_defineProperty$1.default)(this, "encoder", void 0);
|
|
1057
|
+
(0, import_defineProperty$1.default)(this, "wsObservable", behaviorSubject(null));
|
|
1058
|
+
(0, import_defineProperty$1.default)(this, "openPromise", null);
|
|
1059
|
+
this.WebSocketPonyfill = (_opts$WebSocketPonyfi = opts.WebSocketPonyfill) !== null && _opts$WebSocketPonyfi !== void 0 ? _opts$WebSocketPonyfi : WebSocket;
|
|
1060
|
+
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");
|
|
1061
|
+
this.urlOptions = opts.urlOptions;
|
|
1062
|
+
this.keepAliveOpts = opts.keepAlive;
|
|
1063
|
+
this.encoder = opts.encoder;
|
|
1064
|
+
}
|
|
1065
|
+
get ws() {
|
|
1066
|
+
return this.wsObservable.get();
|
|
1067
|
+
}
|
|
1068
|
+
set ws(ws) {
|
|
1069
|
+
this.wsObservable.next(ws);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Checks if the WebSocket connection is open and ready to communicate.
|
|
1073
|
+
*/
|
|
1074
|
+
isOpen() {
|
|
1075
|
+
return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Checks if the WebSocket connection is closed or in the process of closing.
|
|
1079
|
+
*/
|
|
1080
|
+
isClosed() {
|
|
1081
|
+
return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED);
|
|
1082
|
+
}
|
|
1083
|
+
async open() {
|
|
1084
|
+
var _this = this;
|
|
1085
|
+
if (_this.openPromise) return _this.openPromise;
|
|
1086
|
+
_this.id = ++WsConnection2.connectCount;
|
|
1087
|
+
const wsPromise = prepareUrl(_this.urlOptions).then((url) => new _this.WebSocketPonyfill(url));
|
|
1088
|
+
_this.openPromise = wsPromise.then(async (ws) => {
|
|
1089
|
+
_this.ws = ws;
|
|
1090
|
+
ws.binaryType = "arraybuffer";
|
|
1091
|
+
ws.addEventListener("message", function({ data }) {
|
|
1092
|
+
if (data === "PING") this.send("PONG");
|
|
1093
|
+
});
|
|
1094
|
+
if (_this.keepAliveOpts.enabled) setupPingInterval(ws, _this.keepAliveOpts);
|
|
1095
|
+
ws.addEventListener("close", () => {
|
|
1096
|
+
if (_this.ws === ws) _this.ws = null;
|
|
1097
|
+
});
|
|
1098
|
+
await asyncWsOpen(ws);
|
|
1099
|
+
if (_this.urlOptions.connectionParams) ws.send(await buildConnectionMessage(_this.urlOptions.connectionParams, _this.encoder));
|
|
1100
|
+
});
|
|
1101
|
+
try {
|
|
1102
|
+
await _this.openPromise;
|
|
1103
|
+
} finally {
|
|
1104
|
+
_this.openPromise = null;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Closes the WebSocket connection gracefully.
|
|
1109
|
+
* Waits for any ongoing open operation to complete before closing.
|
|
1110
|
+
*/
|
|
1111
|
+
async close() {
|
|
1112
|
+
var _this2 = this;
|
|
1113
|
+
try {
|
|
1114
|
+
await _this2.openPromise;
|
|
1115
|
+
} finally {
|
|
1116
|
+
var _this$ws;
|
|
1117
|
+
(_this$ws = _this2.ws) === null || _this$ws === void 0 || _this$ws.close();
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
(0, import_defineProperty$1.default)(WsConnection, "connectCount", 0);
|
|
1122
|
+
function backwardCompatibility(connection) {
|
|
1123
|
+
if (connection.isOpen()) return {
|
|
1124
|
+
id: connection.id,
|
|
1125
|
+
state: "open",
|
|
1126
|
+
ws: connection.ws
|
|
1127
|
+
};
|
|
1128
|
+
if (connection.isClosed()) return {
|
|
1129
|
+
id: connection.id,
|
|
1130
|
+
state: "closed",
|
|
1131
|
+
ws: connection.ws
|
|
1132
|
+
};
|
|
1133
|
+
if (!connection.ws) return null;
|
|
1134
|
+
return {
|
|
1135
|
+
id: connection.id,
|
|
1136
|
+
state: "connecting",
|
|
1137
|
+
ws: connection.ws
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
__name(backwardCompatibility, "backwardCompatibility");
|
|
1141
|
+
var import_defineProperty3 = __toESM(require_defineProperty(), 1);
|
|
1142
|
+
var import_objectSpread28 = __toESM(require_objectSpread2(), 1);
|
|
1143
|
+
var WsClient = class {
|
|
1144
|
+
static {
|
|
1145
|
+
__name(this, "WsClient");
|
|
1146
|
+
}
|
|
1147
|
+
constructor(opts) {
|
|
1148
|
+
var _opts$experimental_en, _opts$retryDelayMs;
|
|
1149
|
+
(0, import_defineProperty3.default)(this, "connectionState", void 0);
|
|
1150
|
+
(0, import_defineProperty3.default)(this, "allowReconnect", false);
|
|
1151
|
+
(0, import_defineProperty3.default)(this, "requestManager", new RequestManager());
|
|
1152
|
+
(0, import_defineProperty3.default)(this, "activeConnection", void 0);
|
|
1153
|
+
(0, import_defineProperty3.default)(this, "reconnectRetryDelay", void 0);
|
|
1154
|
+
(0, import_defineProperty3.default)(this, "inactivityTimeout", void 0);
|
|
1155
|
+
(0, import_defineProperty3.default)(this, "callbacks", void 0);
|
|
1156
|
+
(0, import_defineProperty3.default)(this, "lazyMode", void 0);
|
|
1157
|
+
(0, import_defineProperty3.default)(this, "encoder", void 0);
|
|
1158
|
+
(0, import_defineProperty3.default)(this, "reconnecting", null);
|
|
1159
|
+
this.encoder = (_opts$experimental_en = opts.experimental_encoder) !== null && _opts$experimental_en !== void 0 ? _opts$experimental_en : jsonEncoder;
|
|
1160
|
+
this.callbacks = {
|
|
1161
|
+
onOpen: opts.onOpen,
|
|
1162
|
+
onClose: opts.onClose,
|
|
1163
|
+
onError: opts.onError
|
|
1164
|
+
};
|
|
1165
|
+
const lazyOptions = (0, import_objectSpread28.default)((0, import_objectSpread28.default)({}, lazyDefaults), opts.lazy);
|
|
1166
|
+
this.inactivityTimeout = new ResettableTimeout(() => {
|
|
1167
|
+
if (this.requestManager.hasOutgoingRequests() || this.requestManager.hasPendingRequests()) {
|
|
1168
|
+
this.inactivityTimeout.reset();
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
this.close().catch(() => null);
|
|
1172
|
+
}, lazyOptions.closeMs);
|
|
1173
|
+
this.activeConnection = new WsConnection({
|
|
1174
|
+
WebSocketPonyfill: opts.WebSocket,
|
|
1175
|
+
urlOptions: opts,
|
|
1176
|
+
keepAlive: (0, import_objectSpread28.default)((0, import_objectSpread28.default)({}, keepAliveDefaults), opts.keepAlive),
|
|
1177
|
+
encoder: this.encoder
|
|
1178
|
+
});
|
|
1179
|
+
this.activeConnection.wsObservable.subscribe({ next: /* @__PURE__ */ __name((ws) => {
|
|
1180
|
+
if (!ws) return;
|
|
1181
|
+
this.setupWebSocketListeners(ws);
|
|
1182
|
+
}, "next") });
|
|
1183
|
+
this.reconnectRetryDelay = (_opts$retryDelayMs = opts.retryDelayMs) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : exponentialBackoff;
|
|
1184
|
+
this.lazyMode = lazyOptions.enabled;
|
|
1185
|
+
this.connectionState = behaviorSubject({
|
|
1186
|
+
type: "state",
|
|
1187
|
+
state: lazyOptions.enabled ? "idle" : "connecting",
|
|
1188
|
+
error: null
|
|
1189
|
+
});
|
|
1190
|
+
if (!this.lazyMode) this.open().catch(() => null);
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Opens the WebSocket connection. Handles reconnection attempts and updates
|
|
1194
|
+
* the connection state accordingly.
|
|
1195
|
+
*/
|
|
1196
|
+
async open() {
|
|
1197
|
+
var _this = this;
|
|
1198
|
+
_this.allowReconnect = true;
|
|
1199
|
+
if (_this.connectionState.get().state === "idle") _this.connectionState.next({
|
|
1200
|
+
type: "state",
|
|
1201
|
+
state: "connecting",
|
|
1202
|
+
error: null
|
|
1203
|
+
});
|
|
1204
|
+
try {
|
|
1205
|
+
await _this.activeConnection.open();
|
|
1206
|
+
} catch (error) {
|
|
1207
|
+
_this.reconnect(new TRPCWebSocketClosedError({
|
|
1208
|
+
message: "Initialization error",
|
|
1209
|
+
cause: error
|
|
1210
|
+
}));
|
|
1211
|
+
return _this.reconnecting;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Closes the WebSocket connection and stops managing requests.
|
|
1216
|
+
* Ensures all outgoing and pending requests are properly finalized.
|
|
1217
|
+
*/
|
|
1218
|
+
async close() {
|
|
1219
|
+
var _this2 = this;
|
|
1220
|
+
_this2.allowReconnect = false;
|
|
1221
|
+
_this2.inactivityTimeout.stop();
|
|
1222
|
+
const requestsToAwait = [];
|
|
1223
|
+
for (const request of _this2.requestManager.getRequests()) if (request.message.method === "subscription") request.callbacks.complete();
|
|
1224
|
+
else if (request.state === "outgoing") request.callbacks.error(TRPCClientError.from(new TRPCWebSocketClosedError({ message: "Closed before connection was established" })));
|
|
1225
|
+
else requestsToAwait.push(request.end);
|
|
1226
|
+
await Promise.all(requestsToAwait).catch(() => null);
|
|
1227
|
+
await _this2.activeConnection.close().catch(() => null);
|
|
1228
|
+
_this2.connectionState.next({
|
|
1229
|
+
type: "state",
|
|
1230
|
+
state: "idle",
|
|
1231
|
+
error: null
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Method to request the server.
|
|
1236
|
+
* Handles data transformation, batching of requests, and subscription lifecycle.
|
|
1237
|
+
*
|
|
1238
|
+
* @param op - The operation details including id, type, path, input and signal
|
|
1239
|
+
* @param transformer - Data transformer for serializing requests and deserializing responses
|
|
1240
|
+
* @param lastEventId - Optional ID of the last received event for subscriptions
|
|
1241
|
+
*
|
|
1242
|
+
* @returns An observable that emits operation results and handles cleanup
|
|
1243
|
+
*/
|
|
1244
|
+
request({ op: { id, type, path, input, signal }, transformer, lastEventId }) {
|
|
1245
|
+
return observable((observer) => {
|
|
1246
|
+
const abort = this.batchSend({
|
|
1247
|
+
id,
|
|
1248
|
+
method: type,
|
|
1249
|
+
params: {
|
|
1250
|
+
input: transformer.input.serialize(input),
|
|
1251
|
+
path,
|
|
1252
|
+
lastEventId
|
|
1253
|
+
}
|
|
1254
|
+
}, (0, import_objectSpread28.default)((0, import_objectSpread28.default)({}, observer), {}, { next(event) {
|
|
1255
|
+
const transformed = transformResult(event, transformer.output);
|
|
1256
|
+
if (!transformed.ok) {
|
|
1257
|
+
observer.error(TRPCClientError.from(transformed.error));
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
observer.next({ result: transformed.result });
|
|
1261
|
+
} }));
|
|
1262
|
+
return () => {
|
|
1263
|
+
abort();
|
|
1264
|
+
if (type === "subscription" && this.activeConnection.isOpen()) this.send({
|
|
1265
|
+
id,
|
|
1266
|
+
method: "subscription.stop"
|
|
1267
|
+
});
|
|
1268
|
+
signal === null || signal === void 0 || signal.removeEventListener("abort", abort);
|
|
1269
|
+
};
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
get connection() {
|
|
1273
|
+
return backwardCompatibility(this.activeConnection);
|
|
1274
|
+
}
|
|
1275
|
+
reconnect(closedError) {
|
|
1276
|
+
var _this3 = this;
|
|
1277
|
+
this.connectionState.next({
|
|
1278
|
+
type: "state",
|
|
1279
|
+
state: "connecting",
|
|
1280
|
+
error: TRPCClientError.from(closedError)
|
|
1281
|
+
});
|
|
1282
|
+
if (this.reconnecting) return;
|
|
1283
|
+
const tryReconnect = /* @__PURE__ */ __name(async (attemptIndex) => {
|
|
1284
|
+
try {
|
|
1285
|
+
await sleep(_this3.reconnectRetryDelay(attemptIndex));
|
|
1286
|
+
if (_this3.allowReconnect) {
|
|
1287
|
+
await _this3.activeConnection.close();
|
|
1288
|
+
await _this3.activeConnection.open();
|
|
1289
|
+
if (_this3.requestManager.hasPendingRequests()) _this3.send(_this3.requestManager.getPendingRequests().map(({ message }) => message));
|
|
1290
|
+
}
|
|
1291
|
+
_this3.reconnecting = null;
|
|
1292
|
+
} catch (_unused) {
|
|
1293
|
+
await tryReconnect(attemptIndex + 1);
|
|
1294
|
+
}
|
|
1295
|
+
}, "tryReconnect");
|
|
1296
|
+
this.reconnecting = tryReconnect(0);
|
|
1297
|
+
}
|
|
1298
|
+
setupWebSocketListeners(ws) {
|
|
1299
|
+
var _this4 = this;
|
|
1300
|
+
const handleCloseOrError = /* @__PURE__ */ __name((cause) => {
|
|
1301
|
+
const reqs = this.requestManager.getPendingRequests();
|
|
1302
|
+
for (const { message, callbacks } of reqs) {
|
|
1303
|
+
if (message.method === "subscription") continue;
|
|
1304
|
+
callbacks.error(TRPCClientError.from(cause !== null && cause !== void 0 ? cause : new TRPCWebSocketClosedError({
|
|
1305
|
+
message: "WebSocket closed",
|
|
1306
|
+
cause
|
|
1307
|
+
})));
|
|
1308
|
+
this.requestManager.delete(message.id);
|
|
1309
|
+
}
|
|
1310
|
+
}, "handleCloseOrError");
|
|
1311
|
+
ws.addEventListener("open", () => {
|
|
1312
|
+
run(async () => {
|
|
1313
|
+
var _this$callbacks$onOpe, _this$callbacks;
|
|
1314
|
+
if (_this4.lazyMode) _this4.inactivityTimeout.start();
|
|
1315
|
+
(_this$callbacks$onOpe = (_this$callbacks = _this4.callbacks).onOpen) === null || _this$callbacks$onOpe === void 0 || _this$callbacks$onOpe.call(_this$callbacks);
|
|
1316
|
+
_this4.connectionState.next({
|
|
1317
|
+
type: "state",
|
|
1318
|
+
state: "pending",
|
|
1319
|
+
error: null
|
|
1320
|
+
});
|
|
1321
|
+
}).catch((error) => {
|
|
1322
|
+
ws.close(3e3);
|
|
1323
|
+
handleCloseOrError(error);
|
|
1324
|
+
});
|
|
1325
|
+
});
|
|
1326
|
+
ws.addEventListener("message", ({ data }) => {
|
|
1327
|
+
this.inactivityTimeout.reset();
|
|
1328
|
+
if (["PING", "PONG"].includes(data)) return;
|
|
1329
|
+
const incomingMessage = this.encoder.decode(data);
|
|
1330
|
+
if ("method" in incomingMessage) {
|
|
1331
|
+
this.handleIncomingRequest(incomingMessage);
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
this.handleResponseMessage(incomingMessage);
|
|
1335
|
+
});
|
|
1336
|
+
ws.addEventListener("close", (event) => {
|
|
1337
|
+
var _this$callbacks$onClo, _this$callbacks2;
|
|
1338
|
+
handleCloseOrError(event);
|
|
1339
|
+
(_this$callbacks$onClo = (_this$callbacks2 = this.callbacks).onClose) === null || _this$callbacks$onClo === void 0 || _this$callbacks$onClo.call(_this$callbacks2, event);
|
|
1340
|
+
if (!this.lazyMode || this.requestManager.hasPendingSubscriptions()) this.reconnect(new TRPCWebSocketClosedError({
|
|
1341
|
+
message: "WebSocket closed",
|
|
1342
|
+
cause: event
|
|
1343
|
+
}));
|
|
1344
|
+
});
|
|
1345
|
+
ws.addEventListener("error", (event) => {
|
|
1346
|
+
var _this$callbacks$onErr, _this$callbacks3;
|
|
1347
|
+
handleCloseOrError(event);
|
|
1348
|
+
(_this$callbacks$onErr = (_this$callbacks3 = this.callbacks).onError) === null || _this$callbacks$onErr === void 0 || _this$callbacks$onErr.call(_this$callbacks3, event);
|
|
1349
|
+
this.reconnect(new TRPCWebSocketClosedError({
|
|
1350
|
+
message: "WebSocket closed",
|
|
1351
|
+
cause: event
|
|
1352
|
+
}));
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
handleResponseMessage(message) {
|
|
1356
|
+
const request = this.requestManager.getPendingRequest(message.id);
|
|
1357
|
+
if (!request) return;
|
|
1358
|
+
request.callbacks.next(message);
|
|
1359
|
+
let completed = true;
|
|
1360
|
+
if ("result" in message && request.message.method === "subscription") {
|
|
1361
|
+
if (message.result.type === "data") request.message.params.lastEventId = message.result.id;
|
|
1362
|
+
if (message.result.type !== "stopped") completed = false;
|
|
1363
|
+
}
|
|
1364
|
+
if (completed) {
|
|
1365
|
+
request.callbacks.complete();
|
|
1366
|
+
this.requestManager.delete(message.id);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
handleIncomingRequest(message) {
|
|
1370
|
+
if (message.method === "reconnect") this.reconnect(new TRPCWebSocketClosedError({ message: "Server requested reconnect" }));
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Sends a message or batch of messages directly to the server.
|
|
1374
|
+
*/
|
|
1375
|
+
send(messageOrMessages) {
|
|
1376
|
+
if (!this.activeConnection.isOpen()) throw new Error("Active connection is not open");
|
|
1377
|
+
const messages = messageOrMessages instanceof Array ? messageOrMessages : [messageOrMessages];
|
|
1378
|
+
this.activeConnection.ws.send(this.encoder.encode(messages.length === 1 ? messages[0] : messages));
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Groups requests for batch sending.
|
|
1382
|
+
*
|
|
1383
|
+
* @returns A function to abort the batched request.
|
|
1384
|
+
*/
|
|
1385
|
+
batchSend(message, callbacks) {
|
|
1386
|
+
var _this5 = this;
|
|
1387
|
+
this.inactivityTimeout.reset();
|
|
1388
|
+
run(async () => {
|
|
1389
|
+
if (!_this5.activeConnection.isOpen()) await _this5.open();
|
|
1390
|
+
await sleep(0);
|
|
1391
|
+
if (!_this5.requestManager.hasOutgoingRequests()) return;
|
|
1392
|
+
_this5.send(_this5.requestManager.flush().map(({ message: message$1 }) => message$1));
|
|
1393
|
+
}).catch((err) => {
|
|
1394
|
+
this.requestManager.delete(message.id);
|
|
1395
|
+
callbacks.error(TRPCClientError.from(err));
|
|
1396
|
+
});
|
|
1397
|
+
return this.requestManager.register(message, callbacks);
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
function createWSClient(opts) {
|
|
1401
|
+
return new WsClient(opts);
|
|
1402
|
+
}
|
|
1403
|
+
__name(createWSClient, "createWSClient");
|
|
1404
|
+
function wsLink(opts) {
|
|
1405
|
+
const { client } = opts;
|
|
1406
|
+
const transformer = getTransformer(opts.transformer);
|
|
1407
|
+
return () => {
|
|
1408
|
+
return ({ op }) => {
|
|
1409
|
+
return observable((observer) => {
|
|
1410
|
+
const connStateSubscription = op.type === "subscription" ? client.connectionState.subscribe({ next(result) {
|
|
1411
|
+
observer.next({
|
|
1412
|
+
result,
|
|
1413
|
+
context: op.context
|
|
1414
|
+
});
|
|
1415
|
+
} }) : null;
|
|
1416
|
+
const requestSubscription = client.request({
|
|
1417
|
+
op,
|
|
1418
|
+
transformer
|
|
1419
|
+
}).subscribe(observer);
|
|
1420
|
+
return () => {
|
|
1421
|
+
requestSubscription.unsubscribe();
|
|
1422
|
+
connStateSubscription === null || connStateSubscription === void 0 || connStateSubscription.unsubscribe();
|
|
1423
|
+
};
|
|
1424
|
+
});
|
|
1425
|
+
};
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
__name(wsLink, "wsLink");
|
|
1429
|
+
|
|
1430
|
+
// node_modules/@trpc/client/dist/index.mjs
|
|
1431
|
+
var import_defineProperty4 = __toESM(require_defineProperty(), 1);
|
|
1432
|
+
var import_objectSpread2$4 = __toESM(require_objectSpread2(), 1);
|
|
1433
|
+
var TRPCUntypedClient = class {
|
|
1434
|
+
static {
|
|
1435
|
+
__name(this, "TRPCUntypedClient");
|
|
1436
|
+
}
|
|
1437
|
+
constructor(opts) {
|
|
1438
|
+
(0, import_defineProperty4.default)(this, "links", void 0);
|
|
1439
|
+
(0, import_defineProperty4.default)(this, "runtime", void 0);
|
|
1440
|
+
(0, import_defineProperty4.default)(this, "requestId", void 0);
|
|
1441
|
+
this.requestId = 0;
|
|
1442
|
+
this.runtime = {};
|
|
1443
|
+
this.links = opts.links.map((link) => link(this.runtime));
|
|
1444
|
+
}
|
|
1445
|
+
$request(opts) {
|
|
1446
|
+
var _opts$context;
|
|
1447
|
+
const chain$ = createChain({
|
|
1448
|
+
links: this.links,
|
|
1449
|
+
op: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
|
|
1450
|
+
context: (_opts$context = opts.context) !== null && _opts$context !== void 0 ? _opts$context : {},
|
|
1451
|
+
id: ++this.requestId
|
|
1452
|
+
})
|
|
1453
|
+
});
|
|
1454
|
+
return chain$.pipe(share());
|
|
1455
|
+
}
|
|
1456
|
+
async requestAsPromise(opts) {
|
|
1457
|
+
var _this = this;
|
|
1458
|
+
try {
|
|
1459
|
+
const req$ = _this.$request(opts);
|
|
1460
|
+
const envelope = await observableToPromise(req$);
|
|
1461
|
+
const data = envelope.result.data;
|
|
1462
|
+
return data;
|
|
1463
|
+
} catch (err) {
|
|
1464
|
+
throw TRPCClientError.from(err);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
query(path, input, opts) {
|
|
1468
|
+
return this.requestAsPromise({
|
|
1469
|
+
type: "query",
|
|
1470
|
+
path,
|
|
1471
|
+
input,
|
|
1472
|
+
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
|
1473
|
+
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
mutation(path, input, opts) {
|
|
1477
|
+
return this.requestAsPromise({
|
|
1478
|
+
type: "mutation",
|
|
1479
|
+
path,
|
|
1480
|
+
input,
|
|
1481
|
+
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
|
1482
|
+
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
subscription(path, input, opts) {
|
|
1486
|
+
const observable$ = this.$request({
|
|
1487
|
+
type: "subscription",
|
|
1488
|
+
path,
|
|
1489
|
+
input,
|
|
1490
|
+
context: opts.context,
|
|
1491
|
+
signal: opts.signal
|
|
1492
|
+
});
|
|
1493
|
+
return observable$.subscribe({
|
|
1494
|
+
next(envelope) {
|
|
1495
|
+
switch (envelope.result.type) {
|
|
1496
|
+
case "state": {
|
|
1497
|
+
var _opts$onConnectionSta;
|
|
1498
|
+
(_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === void 0 || _opts$onConnectionSta.call(opts, envelope.result);
|
|
1499
|
+
break;
|
|
1500
|
+
}
|
|
1501
|
+
case "started": {
|
|
1502
|
+
var _opts$onStarted;
|
|
1503
|
+
(_opts$onStarted = opts.onStarted) === null || _opts$onStarted === void 0 || _opts$onStarted.call(opts, { context: envelope.context });
|
|
1504
|
+
break;
|
|
1505
|
+
}
|
|
1506
|
+
case "stopped": {
|
|
1507
|
+
var _opts$onStopped;
|
|
1508
|
+
(_opts$onStopped = opts.onStopped) === null || _opts$onStopped === void 0 || _opts$onStopped.call(opts);
|
|
1509
|
+
break;
|
|
1510
|
+
}
|
|
1511
|
+
case "data":
|
|
1512
|
+
case void 0: {
|
|
1513
|
+
var _opts$onData;
|
|
1514
|
+
(_opts$onData = opts.onData) === null || _opts$onData === void 0 || _opts$onData.call(opts, envelope.result.data);
|
|
1515
|
+
break;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
},
|
|
1519
|
+
error(err) {
|
|
1520
|
+
var _opts$onError;
|
|
1521
|
+
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, err);
|
|
1522
|
+
},
|
|
1523
|
+
complete() {
|
|
1524
|
+
var _opts$onComplete;
|
|
1525
|
+
(_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 || _opts$onComplete.call(opts);
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1530
|
+
var untypedClientSymbol = /* @__PURE__ */ Symbol.for("trpc_untypedClient");
|
|
1531
|
+
var clientCallTypeMap = {
|
|
1532
|
+
query: "query",
|
|
1533
|
+
mutate: "mutation",
|
|
1534
|
+
subscribe: "subscription"
|
|
1535
|
+
};
|
|
1536
|
+
var clientCallTypeToProcedureType = /* @__PURE__ */ __name((clientCallType) => {
|
|
1537
|
+
return clientCallTypeMap[clientCallType];
|
|
1538
|
+
}, "clientCallTypeToProcedureType");
|
|
1539
|
+
function createTRPCClientProxy(client) {
|
|
1540
|
+
const proxy = createRecursiveProxy(({ path, args }) => {
|
|
1541
|
+
const pathCopy = [...path];
|
|
1542
|
+
const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
|
|
1543
|
+
const fullPath = pathCopy.join(".");
|
|
1544
|
+
return client[procedureType](fullPath, ...args);
|
|
1545
|
+
});
|
|
1546
|
+
return createFlatProxy((key) => {
|
|
1547
|
+
if (key === untypedClientSymbol) return client;
|
|
1548
|
+
return proxy[key];
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
__name(createTRPCClientProxy, "createTRPCClientProxy");
|
|
1552
|
+
function createTRPCClient(opts) {
|
|
1553
|
+
const client = new TRPCUntypedClient(opts);
|
|
1554
|
+
const proxy = createTRPCClientProxy(client);
|
|
1555
|
+
return proxy;
|
|
1556
|
+
}
|
|
1557
|
+
__name(createTRPCClient, "createTRPCClient");
|
|
1558
|
+
var import_objectSpread2$3 = __toESM(require_objectSpread2(), 1);
|
|
1559
|
+
var import_objectSpread2$2 = __toESM(require_objectSpread2(), 1);
|
|
1560
|
+
var require_asyncIterator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
|
|
1561
|
+
function _asyncIterator$1(r) {
|
|
1562
|
+
var n, t, o, e = 2;
|
|
1563
|
+
for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--; ) {
|
|
1564
|
+
if (t && null != (n = r[t])) return n.call(r);
|
|
1565
|
+
if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
|
1566
|
+
t = "@@asyncIterator", o = "@@iterator";
|
|
1567
|
+
}
|
|
1568
|
+
throw new TypeError("Object is not async iterable");
|
|
1569
|
+
}
|
|
1570
|
+
__name(_asyncIterator$1, "_asyncIterator$1");
|
|
1571
|
+
function AsyncFromSyncIterator(r) {
|
|
1572
|
+
function AsyncFromSyncIteratorContinuation(r$1) {
|
|
1573
|
+
if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
|
|
1574
|
+
var n = r$1.done;
|
|
1575
|
+
return Promise.resolve(r$1.value).then(function(r$2) {
|
|
1576
|
+
return {
|
|
1577
|
+
value: r$2,
|
|
1578
|
+
done: n
|
|
1579
|
+
};
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
__name(AsyncFromSyncIteratorContinuation, "AsyncFromSyncIteratorContinuation");
|
|
1583
|
+
return AsyncFromSyncIterator = /* @__PURE__ */ __name(function AsyncFromSyncIterator$1(r$1) {
|
|
1584
|
+
this.s = r$1, this.n = r$1.next;
|
|
1585
|
+
}, "AsyncFromSyncIterator$1"), AsyncFromSyncIterator.prototype = {
|
|
1586
|
+
s: null,
|
|
1587
|
+
n: null,
|
|
1588
|
+
next: /* @__PURE__ */ __name(function next() {
|
|
1589
|
+
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
1590
|
+
}, "next"),
|
|
1591
|
+
"return": /* @__PURE__ */ __name(function _return(r$1) {
|
|
1592
|
+
var n = this.s["return"];
|
|
1593
|
+
return void 0 === n ? Promise.resolve({
|
|
1594
|
+
value: r$1,
|
|
1595
|
+
done: true
|
|
1596
|
+
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
1597
|
+
}, "_return"),
|
|
1598
|
+
"throw": /* @__PURE__ */ __name(function _throw(r$1) {
|
|
1599
|
+
var n = this.s["return"];
|
|
1600
|
+
return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
1601
|
+
}, "_throw")
|
|
1602
|
+
}, new AsyncFromSyncIterator(r);
|
|
1603
|
+
}
|
|
1604
|
+
__name(AsyncFromSyncIterator, "AsyncFromSyncIterator");
|
|
1605
|
+
module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1606
|
+
} });
|
|
1607
|
+
var import_asyncIterator = __toESM(require_asyncIterator(), 1);
|
|
1608
|
+
var import_objectSpread2$12 = __toESM(require_objectSpread2(), 1);
|
|
1609
|
+
var require_usingCtx = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
|
|
1610
|
+
function _usingCtx() {
|
|
1611
|
+
var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
|
|
1612
|
+
var n$1 = Error();
|
|
1613
|
+
return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
|
|
1614
|
+
}, e = {}, n = [];
|
|
1615
|
+
function using(r$1, e$1) {
|
|
1616
|
+
if (null != e$1) {
|
|
1617
|
+
if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
1618
|
+
if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
|
1619
|
+
if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
|
|
1620
|
+
if ("function" != typeof o) throw new TypeError("Object is not disposable.");
|
|
1621
|
+
t && (o = /* @__PURE__ */ __name(function o$1() {
|
|
1622
|
+
try {
|
|
1623
|
+
t.call(e$1);
|
|
1624
|
+
} catch (r$2) {
|
|
1625
|
+
return Promise.reject(r$2);
|
|
1626
|
+
}
|
|
1627
|
+
}, "o$1")), n.push({
|
|
1628
|
+
v: e$1,
|
|
1629
|
+
d: o,
|
|
1630
|
+
a: r$1
|
|
1631
|
+
});
|
|
1632
|
+
} else r$1 && n.push({
|
|
1633
|
+
d: e$1,
|
|
1634
|
+
a: r$1
|
|
1635
|
+
});
|
|
1636
|
+
return e$1;
|
|
1637
|
+
}
|
|
1638
|
+
__name(using, "using");
|
|
1639
|
+
return {
|
|
1640
|
+
e,
|
|
1641
|
+
u: using.bind(null, false),
|
|
1642
|
+
a: using.bind(null, true),
|
|
1643
|
+
d: /* @__PURE__ */ __name(function d() {
|
|
1644
|
+
var o, t = this.e, s = 0;
|
|
1645
|
+
function next() {
|
|
1646
|
+
for (; o = n.pop(); ) try {
|
|
1647
|
+
if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
|
|
1648
|
+
if (o.d) {
|
|
1649
|
+
var r$1 = o.d.call(o.v);
|
|
1650
|
+
if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
|
|
1651
|
+
} else s |= 1;
|
|
1652
|
+
} catch (r$2) {
|
|
1653
|
+
return err(r$2);
|
|
1654
|
+
}
|
|
1655
|
+
if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
|
|
1656
|
+
if (t !== e) throw t;
|
|
1657
|
+
}
|
|
1658
|
+
__name(next, "next");
|
|
1659
|
+
function err(n$1) {
|
|
1660
|
+
return t = t !== e ? new r(n$1, t) : n$1, next();
|
|
1661
|
+
}
|
|
1662
|
+
__name(err, "err");
|
|
1663
|
+
return next();
|
|
1664
|
+
}, "d")
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1667
|
+
__name(_usingCtx, "_usingCtx");
|
|
1668
|
+
module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1669
|
+
} });
|
|
1670
|
+
var require_OverloadYield = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports, module) {
|
|
1671
|
+
function _OverloadYield(e, d) {
|
|
1672
|
+
this.v = e, this.k = d;
|
|
1673
|
+
}
|
|
1674
|
+
__name(_OverloadYield, "_OverloadYield");
|
|
1675
|
+
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1676
|
+
} });
|
|
1677
|
+
var require_awaitAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports, module) {
|
|
1678
|
+
var OverloadYield$1 = require_OverloadYield();
|
|
1679
|
+
function _awaitAsyncGenerator$1(e) {
|
|
1680
|
+
return new OverloadYield$1(e, 0);
|
|
1681
|
+
}
|
|
1682
|
+
__name(_awaitAsyncGenerator$1, "_awaitAsyncGenerator$1");
|
|
1683
|
+
module.exports = _awaitAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1684
|
+
} });
|
|
1685
|
+
var require_wrapAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports, module) {
|
|
1686
|
+
var OverloadYield = require_OverloadYield();
|
|
1687
|
+
function _wrapAsyncGenerator$1(e) {
|
|
1688
|
+
return function() {
|
|
1689
|
+
return new AsyncGenerator(e.apply(this, arguments));
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
__name(_wrapAsyncGenerator$1, "_wrapAsyncGenerator$1");
|
|
1693
|
+
function AsyncGenerator(e) {
|
|
1694
|
+
var r, t;
|
|
1695
|
+
function resume(r$1, t$1) {
|
|
1696
|
+
try {
|
|
1697
|
+
var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield;
|
|
1698
|
+
Promise.resolve(u ? o.v : o).then(function(t$2) {
|
|
1699
|
+
if (u) {
|
|
1700
|
+
var i = "return" === r$1 ? "return" : "next";
|
|
1701
|
+
if (!o.k || t$2.done) return resume(i, t$2);
|
|
1702
|
+
t$2 = e[i](t$2).value;
|
|
1703
|
+
}
|
|
1704
|
+
settle(n.done ? "return" : "normal", t$2);
|
|
1705
|
+
}, function(e$1) {
|
|
1706
|
+
resume("throw", e$1);
|
|
1707
|
+
});
|
|
1708
|
+
} catch (e$1) {
|
|
1709
|
+
settle("throw", e$1);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
__name(resume, "resume");
|
|
1713
|
+
function settle(e$1, n) {
|
|
1714
|
+
switch (e$1) {
|
|
1715
|
+
case "return":
|
|
1716
|
+
r.resolve({
|
|
1717
|
+
value: n,
|
|
1718
|
+
done: true
|
|
1719
|
+
});
|
|
1720
|
+
break;
|
|
1721
|
+
case "throw":
|
|
1722
|
+
r.reject(n);
|
|
1723
|
+
break;
|
|
1724
|
+
default:
|
|
1725
|
+
r.resolve({
|
|
1726
|
+
value: n,
|
|
1727
|
+
done: false
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
(r = r.next) ? resume(r.key, r.arg) : t = null;
|
|
1731
|
+
}
|
|
1732
|
+
__name(settle, "settle");
|
|
1733
|
+
this._invoke = function(e$1, n) {
|
|
1734
|
+
return new Promise(function(o, u) {
|
|
1735
|
+
var i = {
|
|
1736
|
+
key: e$1,
|
|
1737
|
+
arg: n,
|
|
1738
|
+
resolve: o,
|
|
1739
|
+
reject: u,
|
|
1740
|
+
next: null
|
|
1741
|
+
};
|
|
1742
|
+
t ? t = t.next = i : (r = t = i, resume(e$1, n));
|
|
1743
|
+
});
|
|
1744
|
+
}, "function" != typeof e["return"] && (this["return"] = void 0);
|
|
1745
|
+
}
|
|
1746
|
+
__name(AsyncGenerator, "AsyncGenerator");
|
|
1747
|
+
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
1748
|
+
return this;
|
|
1749
|
+
}, AsyncGenerator.prototype.next = function(e) {
|
|
1750
|
+
return this._invoke("next", e);
|
|
1751
|
+
}, AsyncGenerator.prototype["throw"] = function(e) {
|
|
1752
|
+
return this._invoke("throw", e);
|
|
1753
|
+
}, AsyncGenerator.prototype["return"] = function(e) {
|
|
1754
|
+
return this._invoke("return", e);
|
|
1755
|
+
};
|
|
1756
|
+
module.exports = _wrapAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1757
|
+
} });
|
|
1758
|
+
var import_usingCtx = __toESM(require_usingCtx(), 1);
|
|
1759
|
+
var import_awaitAsyncGenerator = __toESM(require_awaitAsyncGenerator(), 1);
|
|
1760
|
+
var import_wrapAsyncGenerator = __toESM(require_wrapAsyncGenerator(), 1);
|
|
1761
|
+
var import_objectSpread29 = __toESM(require_objectSpread2(), 1);
|
|
1762
|
+
|
|
4
1763
|
// src/backend-client.ts
|
|
5
|
-
import { createTRPCClient, createWSClient, wsLink, httpLink } from "@trpc/client";
|
|
6
1764
|
import superjson from "superjson";
|
|
7
1765
|
var BackendClient = class {
|
|
8
1766
|
static {
|
|
@@ -1084,4 +2842,9 @@ export {
|
|
|
1084
2842
|
sensorLabelClasses,
|
|
1085
2843
|
vehicleClasses
|
|
1086
2844
|
};
|
|
2845
|
+
/*! Bundled license information:
|
|
2846
|
+
|
|
2847
|
+
@trpc/client/dist/httpLink-oiU8eqFi.mjs:
|
|
2848
|
+
(* istanbul ignore if -- @preserve *)
|
|
2849
|
+
*/
|
|
1087
2850
|
//# sourceMappingURL=index.js.map
|