vue-streaming 2.0.1 → 2.0.2
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/WebSocketStream.vue_vue_type_script_setup_true_lang-D5IiGqMS.cjs +2 -0
- package/dist/WebSocketStream.vue_vue_type_script_setup_true_lang-D5IiGqMS.cjs.map +1 -0
- package/dist/WebSocketStream.vue_vue_type_script_setup_true_lang-D5yjtuTd.js +1240 -0
- package/dist/WebSocketStream.vue_vue_type_script_setup_true_lang-D5yjtuTd.js.map +1 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +3 -2
- package/dist/composables/index.cjs +1 -1
- package/dist/composables/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +53 -51
- package/dist/useWebSocket--HDylHpA.cjs +4 -0
- package/dist/useWebSocket--HDylHpA.cjs.map +1 -0
- package/dist/useWebSocket-C3JPFBmy.js +1328 -0
- package/dist/useWebSocket-C3JPFBmy.js.map +1 -0
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js +48 -38
- package/dist/utils/index.js.map +1 -1
- package/dist/vue-streaming.css +1 -1
- package/package.json +9 -2
- package/dist/WebSocketStream.vue_vue_type_script_setup_true_lang-BzBWoH8H.js +0 -1083
- package/dist/WebSocketStream.vue_vue_type_script_setup_true_lang-BzBWoH8H.js.map +0 -1
- package/dist/WebSocketStream.vue_vue_type_script_setup_true_lang-C7Kci1ME.cjs +0 -2
- package/dist/WebSocketStream.vue_vue_type_script_setup_true_lang-C7Kci1ME.cjs.map +0 -1
- package/dist/useWebSocket-8VThnC_J.cjs +0 -4
- package/dist/useWebSocket-8VThnC_J.cjs.map +0 -1
- package/dist/useWebSocket-D1Rqm0H7.js +0 -1278
- package/dist/useWebSocket-D1Rqm0H7.js.map +0 -1
|
@@ -1,1278 +0,0 @@
|
|
|
1
|
-
import { ref as d, onUnmounted as H } from "vue";
|
|
2
|
-
import { parseArrayBboxFormat as K, normalizeBboxes as V, bboxesToDetectionFrame as q, parsePointCloudJSON as J, parsePointCloudBinary as Q, createReconnectManager as U } from "./utils/index.js";
|
|
3
|
-
const X = {
|
|
4
|
-
autoPlay: !0,
|
|
5
|
-
startLevel: -1,
|
|
6
|
-
lowLatencyMode: !1,
|
|
7
|
-
maxBufferLength: 30,
|
|
8
|
-
maxMaxBufferLength: 600,
|
|
9
|
-
enableWorker: !0,
|
|
10
|
-
startPosition: -1,
|
|
11
|
-
hlsConfig: {}
|
|
12
|
-
};
|
|
13
|
-
function se(M, e = {}) {
|
|
14
|
-
const t = { ...X, ...M }, h = d("idle"), a = d(!1), l = d(!1), c = d([]), R = d(-1), m = d(!0), v = d(0), u = d(0), y = d(0), w = d(1), C = d(!1), A = d({
|
|
15
|
-
bandwidth: 0,
|
|
16
|
-
currentLevel: -1,
|
|
17
|
-
bufferedDuration: 0,
|
|
18
|
-
droppedFrames: 0,
|
|
19
|
-
latency: 0
|
|
20
|
-
}), x = d(null), F = d(!1);
|
|
21
|
-
let S = null, I = null, p = null, T = null;
|
|
22
|
-
async function n() {
|
|
23
|
-
if (I) return I;
|
|
24
|
-
try {
|
|
25
|
-
const g = await import("hls.js");
|
|
26
|
-
return I = g.default || g, F.value = I.isSupported(), I;
|
|
27
|
-
} catch {
|
|
28
|
-
return console.error("[useHLS] hls.js not installed. Run: npm install hls.js"), null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function f() {
|
|
32
|
-
if (p && (v.value = p.currentTime, u.value = p.duration || 0, p.buffered.length > 0)) {
|
|
33
|
-
const g = p.buffered.end(
|
|
34
|
-
p.buffered.length - 1
|
|
35
|
-
);
|
|
36
|
-
y.value = u.value > 0 ? g / u.value * 100 : 0, A.value.bufferedDuration = g - p.currentTime;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function o(g) {
|
|
40
|
-
g.onplay = () => {
|
|
41
|
-
var E;
|
|
42
|
-
a.value = !0, h.value = "playing", (E = e.onPlaybackStarted) == null || E.call(e);
|
|
43
|
-
}, g.onpause = () => {
|
|
44
|
-
a.value = !1, h.value = "paused";
|
|
45
|
-
}, g.onended = () => {
|
|
46
|
-
var E;
|
|
47
|
-
a.value = !1, h.value = "ended", (E = e.onPlaybackEnded) == null || E.call(e);
|
|
48
|
-
}, g.onwaiting = () => {
|
|
49
|
-
var E;
|
|
50
|
-
l.value = !0, h.value = "buffering", (E = e.onBuffering) == null || E.call(e, !0);
|
|
51
|
-
}, g.onplaying = () => {
|
|
52
|
-
var E;
|
|
53
|
-
l.value = !1, h.value === "buffering" && (h.value = "playing"), (E = e.onBuffering) == null || E.call(e, !1);
|
|
54
|
-
}, g.onseeking = () => {
|
|
55
|
-
h.value = "seeking";
|
|
56
|
-
}, g.onseeked = () => {
|
|
57
|
-
h.value = a.value ? "playing" : "paused";
|
|
58
|
-
}, g.onvolumechange = () => {
|
|
59
|
-
w.value = g.volume, C.value = g.muted;
|
|
60
|
-
}, g.onerror = () => {
|
|
61
|
-
var B, _;
|
|
62
|
-
const E = new Error(((B = g.error) == null ? void 0 : B.message) || "Video playback error");
|
|
63
|
-
x.value = E, h.value = "error", (_ = e.onError) == null || _.call(e, E, !0);
|
|
64
|
-
}, T = setInterval(f, 250);
|
|
65
|
-
}
|
|
66
|
-
function i() {
|
|
67
|
-
!S || !I || (S.on(
|
|
68
|
-
I.Events.MANIFEST_PARSED,
|
|
69
|
-
(g, E) => {
|
|
70
|
-
var B;
|
|
71
|
-
c.value = E.levels.map((_, z) => ({
|
|
72
|
-
index: z,
|
|
73
|
-
bitrate: _.bitrate,
|
|
74
|
-
width: _.width,
|
|
75
|
-
height: _.height,
|
|
76
|
-
codec: _.codec,
|
|
77
|
-
name: `${_.height}p`
|
|
78
|
-
})), h.value = "loaded", (B = e.onManifestLoaded) == null || B.call(e, c.value);
|
|
79
|
-
}
|
|
80
|
-
), S.on(
|
|
81
|
-
I.Events.LEVEL_SWITCHED,
|
|
82
|
-
(g, E) => {
|
|
83
|
-
var B;
|
|
84
|
-
R.value = E.level, A.value.currentLevel = E.level, (B = e.onLevelSwitched) == null || B.call(e, E.level);
|
|
85
|
-
}
|
|
86
|
-
), S.on(
|
|
87
|
-
I.Events.FRAG_LOADED,
|
|
88
|
-
(g, E) => {
|
|
89
|
-
A.value.bandwidth = E.frag.duration * 8 * 1e6 / (E.stats.loading.end - E.stats.loading.start);
|
|
90
|
-
}
|
|
91
|
-
), S.on(
|
|
92
|
-
I.Events.ERROR,
|
|
93
|
-
(g, E) => {
|
|
94
|
-
var _;
|
|
95
|
-
const B = new Error(`HLS Error: ${E.type} - ${E.details}`);
|
|
96
|
-
E.fatal && (x.value = B, h.value = "error", E.type === I.ErrorTypes.MEDIA_ERROR && (S == null || S.recoverMediaError())), (_ = e.onError) == null || _.call(e, B, E.fatal);
|
|
97
|
-
}
|
|
98
|
-
));
|
|
99
|
-
}
|
|
100
|
-
async function r(g) {
|
|
101
|
-
const E = await n();
|
|
102
|
-
if (!E)
|
|
103
|
-
throw new Error("HLS.js is not available");
|
|
104
|
-
if (!E.isSupported()) {
|
|
105
|
-
if (g.canPlayType("application/vnd.apple.mpegurl")) {
|
|
106
|
-
g.src = t.url, p = g, o(g), h.value = "loaded", t.autoPlay && await N();
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
throw new Error("HLS is not supported in this browser");
|
|
110
|
-
}
|
|
111
|
-
p = g, h.value = "loading", S = new E({
|
|
112
|
-
startLevel: t.startLevel,
|
|
113
|
-
lowLatencyMode: t.lowLatencyMode,
|
|
114
|
-
maxBufferLength: t.maxBufferLength,
|
|
115
|
-
enableWorker: t.enableWorker,
|
|
116
|
-
startPosition: t.startPosition
|
|
117
|
-
}), i(), o(g), S.loadSource(t.url), S.attachMedia(g), t.autoPlay && S.on(E.Events.MANIFEST_PARSED, () => {
|
|
118
|
-
N();
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function s() {
|
|
122
|
-
S && S.detachMedia(), T && (clearInterval(T), T = null), p = null;
|
|
123
|
-
}
|
|
124
|
-
function P(g) {
|
|
125
|
-
const E = g || t.url;
|
|
126
|
-
S ? S.loadSource(E) : p && (p.src = E), h.value = "loading";
|
|
127
|
-
}
|
|
128
|
-
async function N() {
|
|
129
|
-
if (!p)
|
|
130
|
-
throw new Error("No video element attached");
|
|
131
|
-
try {
|
|
132
|
-
await p.play();
|
|
133
|
-
} catch (g) {
|
|
134
|
-
if (g.name === "NotAllowedError")
|
|
135
|
-
C.value = !0, p.muted = !0, await p.play();
|
|
136
|
-
else
|
|
137
|
-
throw g;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function L() {
|
|
141
|
-
p == null || p.pause();
|
|
142
|
-
}
|
|
143
|
-
function D() {
|
|
144
|
-
S && S.stopLoad(), p && (p.pause(), p.currentTime = 0), a.value = !1, h.value = "idle";
|
|
145
|
-
}
|
|
146
|
-
function O(g) {
|
|
147
|
-
p && (p.currentTime = g);
|
|
148
|
-
}
|
|
149
|
-
function $(g) {
|
|
150
|
-
S && (S.currentLevel = g, m.value = g === -1);
|
|
151
|
-
}
|
|
152
|
-
function j(g) {
|
|
153
|
-
p && (p.volume = Math.max(0, Math.min(1, g)));
|
|
154
|
-
}
|
|
155
|
-
function G() {
|
|
156
|
-
p && (p.muted = !p.muted);
|
|
157
|
-
}
|
|
158
|
-
function W() {
|
|
159
|
-
T && (clearInterval(T), T = null), S && (S.destroy(), S = null), p = null, h.value = "idle", c.value = [], R.value = -1;
|
|
160
|
-
}
|
|
161
|
-
return H(() => {
|
|
162
|
-
W();
|
|
163
|
-
}), {
|
|
164
|
-
state: h,
|
|
165
|
-
isPlaying: a,
|
|
166
|
-
isBuffering: l,
|
|
167
|
-
levels: c,
|
|
168
|
-
currentLevel: R,
|
|
169
|
-
autoLevelEnabled: m,
|
|
170
|
-
currentTime: v,
|
|
171
|
-
duration: u,
|
|
172
|
-
buffered: y,
|
|
173
|
-
volume: w,
|
|
174
|
-
muted: C,
|
|
175
|
-
stats: A,
|
|
176
|
-
error: x,
|
|
177
|
-
isSupported: F,
|
|
178
|
-
attach: r,
|
|
179
|
-
detach: s,
|
|
180
|
-
load: P,
|
|
181
|
-
play: N,
|
|
182
|
-
pause: L,
|
|
183
|
-
stop: D,
|
|
184
|
-
seek: O,
|
|
185
|
-
setLevel: $,
|
|
186
|
-
setVolume: j,
|
|
187
|
-
toggleMute: G,
|
|
188
|
-
destroy: W
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
const Y = {
|
|
192
|
-
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
|
|
193
|
-
iceGatheringTimeout: 2e3,
|
|
194
|
-
enablePointCloud: !0,
|
|
195
|
-
enableDetections: !0,
|
|
196
|
-
autoReconnect: !0,
|
|
197
|
-
maxReconnectAttempts: 5,
|
|
198
|
-
reconnectDelay: 3e3
|
|
199
|
-
};
|
|
200
|
-
function Z(M, e) {
|
|
201
|
-
return new Promise((t) => {
|
|
202
|
-
if (M.iceGatheringState === "complete") {
|
|
203
|
-
t();
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const h = setTimeout(() => {
|
|
207
|
-
t();
|
|
208
|
-
}, e);
|
|
209
|
-
M.onicegatheringstatechange = () => {
|
|
210
|
-
M.iceGatheringState === "complete" && (clearTimeout(h), t());
|
|
211
|
-
};
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
function fe(M, e = {}) {
|
|
215
|
-
const t = { ...Y, ...M }, h = d(!1), a = d("idle"), l = d(/* @__PURE__ */ new Map()), c = d(null), R = d(null), m = d([]), v = d(null);
|
|
216
|
-
let u = null, y = null, w = null, C = null, A = 0, x = null;
|
|
217
|
-
function F(r, s) {
|
|
218
|
-
if (!y || y.readyState !== "open") return;
|
|
219
|
-
const P = { type: "control", stream: r, enabled: s };
|
|
220
|
-
y.send(JSON.stringify(P));
|
|
221
|
-
}
|
|
222
|
-
function S(r, s) {
|
|
223
|
-
const P = l.value.get(r);
|
|
224
|
-
if (!P || P.readyState !== "open")
|
|
225
|
-
return console.warn(`[useWebRTC] Channel ${r} not available`), !1;
|
|
226
|
-
try {
|
|
227
|
-
return P.send(s), !0;
|
|
228
|
-
} catch (N) {
|
|
229
|
-
return console.error(`[useWebRTC] Send error on ${r}:`, N), !1;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
function I(r) {
|
|
233
|
-
var s;
|
|
234
|
-
switch (l.value.set(r.label, r), (s = e.onDataChannel) == null || s.call(e, r), r.label) {
|
|
235
|
-
case "pointcloud":
|
|
236
|
-
p(r);
|
|
237
|
-
break;
|
|
238
|
-
case "pointcloud_b":
|
|
239
|
-
case "bbox":
|
|
240
|
-
case "bounding_boxes":
|
|
241
|
-
case "detections":
|
|
242
|
-
T(r);
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
function p(r) {
|
|
247
|
-
w = r, w.binaryType = "arraybuffer", w.onopen = () => {
|
|
248
|
-
var s;
|
|
249
|
-
(s = e.onStatus) == null || s.call(e, "Pointcloud channel open"), t.enablePointCloud && F("pointcloud", !0);
|
|
250
|
-
}, w.onmessage = (s) => {
|
|
251
|
-
var P, N;
|
|
252
|
-
try {
|
|
253
|
-
let L = [];
|
|
254
|
-
if (s.data instanceof ArrayBuffer && s.data.byteLength > 0) {
|
|
255
|
-
const D = s.data;
|
|
256
|
-
(P = e.onPointCloudData) == null || P.call(e, D);
|
|
257
|
-
try {
|
|
258
|
-
const O = new TextDecoder().decode(D);
|
|
259
|
-
if (O.startsWith("[") || O.startsWith("{")) {
|
|
260
|
-
const $ = J(O);
|
|
261
|
-
$ && $.length > 0 && (L = $);
|
|
262
|
-
}
|
|
263
|
-
} catch {
|
|
264
|
-
}
|
|
265
|
-
L.length === 0 && (L = Q(D));
|
|
266
|
-
} else if (typeof s.data == "string") {
|
|
267
|
-
const D = J(s.data);
|
|
268
|
-
D && (L = D);
|
|
269
|
-
}
|
|
270
|
-
if (L.length > 0) {
|
|
271
|
-
const D = {
|
|
272
|
-
points: L,
|
|
273
|
-
timestamp: Date.now(),
|
|
274
|
-
format: "parsed"
|
|
275
|
-
};
|
|
276
|
-
c.value = D, (N = e.onPointCloudFrame) == null || N.call(e, D);
|
|
277
|
-
}
|
|
278
|
-
} catch (L) {
|
|
279
|
-
console.error("[useWebRTC] Error parsing pointcloud data:", L);
|
|
280
|
-
}
|
|
281
|
-
}, w.onerror = (s) => {
|
|
282
|
-
var P;
|
|
283
|
-
console.error("[useWebRTC] Pointcloud channel error:", s), (P = e.onStatus) == null || P.call(e, "Pointcloud channel error");
|
|
284
|
-
}, w.onclose = () => {
|
|
285
|
-
var s;
|
|
286
|
-
(s = e.onStatus) == null || s.call(e, "Pointcloud channel closed");
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
function T(r) {
|
|
290
|
-
C = r, C.binaryType = "arraybuffer", C.onopen = () => {
|
|
291
|
-
var s;
|
|
292
|
-
(s = e.onStatus) == null || s.call(e, "BBox channel open"), t.enableDetections && F("bbox", !0);
|
|
293
|
-
}, C.onmessage = (s) => {
|
|
294
|
-
var P, N;
|
|
295
|
-
try {
|
|
296
|
-
let L;
|
|
297
|
-
if (typeof s.data == "string")
|
|
298
|
-
L = JSON.parse(s.data);
|
|
299
|
-
else if (s.data instanceof ArrayBuffer) {
|
|
300
|
-
const D = new TextDecoder().decode(s.data);
|
|
301
|
-
try {
|
|
302
|
-
L = JSON.parse(D);
|
|
303
|
-
} catch {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
} else
|
|
307
|
-
return;
|
|
308
|
-
if (Array.isArray(L)) {
|
|
309
|
-
let D;
|
|
310
|
-
if (L.length > 0 && Array.isArray(L[0]) && typeof L[0][0] == "number" ? D = K(L) : D = V(L), D.length > 0) {
|
|
311
|
-
m.value = D, (P = e.onBoundingBoxData) == null || P.call(e, D);
|
|
312
|
-
const O = q(D);
|
|
313
|
-
R.value = O, (N = e.onDetectionFrame) == null || N.call(e, O);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
} catch (L) {
|
|
317
|
-
console.error("[useWebRTC] Error parsing bbox data:", L);
|
|
318
|
-
}
|
|
319
|
-
}, C.onerror = (s) => {
|
|
320
|
-
console.error("[useWebRTC] BBox channel error:", s);
|
|
321
|
-
}, C.onclose = () => {
|
|
322
|
-
var s;
|
|
323
|
-
(s = e.onStatus) == null || s.call(e, "BBox channel closed");
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
async function n() {
|
|
327
|
-
var r, s, P, N, L, D;
|
|
328
|
-
if (!h.value) {
|
|
329
|
-
(r = e.onStatus) == null || r.call(e, "Creating WebRTC connection..."), a.value = "connecting", v.value = null;
|
|
330
|
-
try {
|
|
331
|
-
u && (u.close(), u = null), u = new RTCPeerConnection({
|
|
332
|
-
iceServers: t.iceServers
|
|
333
|
-
}), u.onconnectionstatechange = () => {
|
|
334
|
-
var g, E;
|
|
335
|
-
const W = (u == null ? void 0 : u.connectionState) ?? "closed";
|
|
336
|
-
if (a.value = W, (g = e.onConnectionState) == null || g.call(e, W), W === "failed" || W === "disconnected") {
|
|
337
|
-
const B = new Error(`Connection ${W}`);
|
|
338
|
-
v.value = B, (E = e.onError) == null || E.call(e, B), t.autoReconnect && A < t.maxReconnectAttempts && o();
|
|
339
|
-
}
|
|
340
|
-
W === "connected" && (A = 0);
|
|
341
|
-
}, u.ondatachannel = (W) => {
|
|
342
|
-
I(W.channel);
|
|
343
|
-
}, y = u.createDataChannel("control"), y.onopen = () => {
|
|
344
|
-
var W;
|
|
345
|
-
(W = e.onStatus) == null || W.call(e, "Control channel open"), l.value.set("control", y);
|
|
346
|
-
};
|
|
347
|
-
const O = await u.createOffer();
|
|
348
|
-
await u.setLocalDescription(O), await Z(u, t.iceGatheringTimeout);
|
|
349
|
-
const $ = ((s = u.localDescription) == null ? void 0 : s.sdp) ?? "";
|
|
350
|
-
if (!$) throw new Error("Empty SDP offer");
|
|
351
|
-
const j = await fetch(t.signalingUrl, {
|
|
352
|
-
method: "POST",
|
|
353
|
-
headers: { "Content-Type": "application/json" },
|
|
354
|
-
body: JSON.stringify({ offer: $ })
|
|
355
|
-
});
|
|
356
|
-
if (!j.ok)
|
|
357
|
-
throw new Error(`Signaling failed: HTTP ${j.status}`);
|
|
358
|
-
const G = await j.json();
|
|
359
|
-
if (!G.answer)
|
|
360
|
-
throw new Error("No answer SDP in response");
|
|
361
|
-
await u.setRemoteDescription({ type: "answer", sdp: G.answer }), h.value = !0, (P = e.onStatus) == null || P.call(e, "Connected, waiting for data..."), (N = e.onConnectionState) == null || N.call(e, u.connectionState);
|
|
362
|
-
} catch (O) {
|
|
363
|
-
const $ = O instanceof Error ? O : new Error(String(O));
|
|
364
|
-
v.value = $, a.value = "error", (L = e.onStatus) == null || L.call(e, `Error: ${$.message}`), (D = e.onError) == null || D.call(e, $), f(), t.autoReconnect && A < t.maxReconnectAttempts && o();
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
function f() {
|
|
369
|
-
var r, s;
|
|
370
|
-
h.value = !1, a.value = "closed", (r = e.onStatus) == null || r.call(e, "Stopped"), (s = e.onConnectionState) == null || s.call(e, "closed"), x && (clearTimeout(x), x = null), l.value.forEach((P) => P.close()), l.value.clear(), y = null, w = null, C = null, u && (u.close(), u = null);
|
|
371
|
-
}
|
|
372
|
-
function o() {
|
|
373
|
-
var r;
|
|
374
|
-
x || (A++, (r = e.onStatus) == null || r.call(
|
|
375
|
-
e,
|
|
376
|
-
`Reconnecting in ${t.reconnectDelay / 1e3}s (attempt ${A}/${t.maxReconnectAttempts})...`
|
|
377
|
-
), x = setTimeout(() => {
|
|
378
|
-
x = null, n();
|
|
379
|
-
}, t.reconnectDelay));
|
|
380
|
-
}
|
|
381
|
-
function i() {
|
|
382
|
-
return u;
|
|
383
|
-
}
|
|
384
|
-
return H(() => {
|
|
385
|
-
f();
|
|
386
|
-
}), {
|
|
387
|
-
isRunning: h,
|
|
388
|
-
connectionState: a,
|
|
389
|
-
dataChannels: l,
|
|
390
|
-
lastPointCloudFrame: c,
|
|
391
|
-
lastDetectionFrame: R,
|
|
392
|
-
lastBoundingBoxes: m,
|
|
393
|
-
error: v,
|
|
394
|
-
start: n,
|
|
395
|
-
stop: f,
|
|
396
|
-
sendControl: F,
|
|
397
|
-
sendOnChannel: S,
|
|
398
|
-
getPeerConnection: i
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
const b = {
|
|
402
|
-
transform: (M) => M,
|
|
403
|
-
filter: () => !0,
|
|
404
|
-
bufferSize: 100,
|
|
405
|
-
throttleMs: 0,
|
|
406
|
-
flushInterval: 0,
|
|
407
|
-
deduplicate: !1,
|
|
408
|
-
dedupeKey: null,
|
|
409
|
-
deduplicateKey: null,
|
|
410
|
-
batchSize: 0,
|
|
411
|
-
batchTimeoutMs: 0
|
|
412
|
-
};
|
|
413
|
-
function ae(M = {}, e = {}) {
|
|
414
|
-
const t = { ...b, ...M }, h = d(null), a = d([]), l = d(t.bufferSize), c = d(!1), R = d(0), m = d(0), v = d(null), u = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set();
|
|
415
|
-
let w = 0, C = null, A = null, x = [];
|
|
416
|
-
function F() {
|
|
417
|
-
C || (C = setInterval(() => {
|
|
418
|
-
R.value = w, w = 0;
|
|
419
|
-
}, 1e3));
|
|
420
|
-
}
|
|
421
|
-
function S() {
|
|
422
|
-
C && (clearInterval(C), C = null), R.value = 0;
|
|
423
|
-
}
|
|
424
|
-
function I() {
|
|
425
|
-
!t.flushInterval || t.flushInterval <= 0 || A || (A = setInterval(() => {
|
|
426
|
-
var s;
|
|
427
|
-
x.length > 0 && ((s = e.onBatch) == null || s.call(e, x), x = []);
|
|
428
|
-
}, t.flushInterval));
|
|
429
|
-
}
|
|
430
|
-
function p() {
|
|
431
|
-
var s;
|
|
432
|
-
A && (clearInterval(A), A = null), x.length > 0 && ((s = e.onBatch) == null || s.call(e, x), x = []);
|
|
433
|
-
}
|
|
434
|
-
function T() {
|
|
435
|
-
c.value || (c.value = !0, F(), I());
|
|
436
|
-
}
|
|
437
|
-
function n() {
|
|
438
|
-
c.value = !1, S(), p();
|
|
439
|
-
}
|
|
440
|
-
function f(s) {
|
|
441
|
-
var P, N, L;
|
|
442
|
-
if (c.value)
|
|
443
|
-
try {
|
|
444
|
-
const D = t.transform(s);
|
|
445
|
-
if (t.deduplicate) {
|
|
446
|
-
const O = t.dedupeKey(D);
|
|
447
|
-
if (O && y.has(O))
|
|
448
|
-
return;
|
|
449
|
-
O && (y.add(O), y.size > t.bufferSize * 2 && Array.from(y).slice(0, t.bufferSize).forEach((j) => y.delete(j)));
|
|
450
|
-
}
|
|
451
|
-
h.value = D, m.value++, w++, a.value = [...a.value, D].slice(-t.bufferSize), a.value.length >= t.bufferSize && ((P = e.onBufferFull) == null || P.call(e)), t.flushInterval && t.flushInterval > 0 && x.push(D), (N = e.onData) == null || N.call(e, D), u.forEach((O) => O(D));
|
|
452
|
-
} catch (D) {
|
|
453
|
-
const O = D instanceof Error ? D : new Error(String(D));
|
|
454
|
-
v.value = O, (L = e.onError) == null || L.call(e, O);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
function o() {
|
|
458
|
-
h.value = null, a.value = [], y.clear(), m.value = 0, x = [];
|
|
459
|
-
}
|
|
460
|
-
function i() {
|
|
461
|
-
return [...a.value];
|
|
462
|
-
}
|
|
463
|
-
function r(s) {
|
|
464
|
-
return u.add(s), () => {
|
|
465
|
-
u.delete(s);
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
return H(() => {
|
|
469
|
-
n(), u.clear(), o();
|
|
470
|
-
}), {
|
|
471
|
-
data: h,
|
|
472
|
-
buffer: a,
|
|
473
|
-
bufferSize: l,
|
|
474
|
-
isStreaming: c,
|
|
475
|
-
itemsPerSecond: R,
|
|
476
|
-
totalItems: m,
|
|
477
|
-
error: v,
|
|
478
|
-
start: T,
|
|
479
|
-
stop: n,
|
|
480
|
-
push: f,
|
|
481
|
-
clear: o,
|
|
482
|
-
getBuffer: i,
|
|
483
|
-
subscribe: r
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
const k = {
|
|
487
|
-
method: "GET",
|
|
488
|
-
headers: {},
|
|
489
|
-
credentials: "same-origin",
|
|
490
|
-
autoConnect: !0,
|
|
491
|
-
autoReconnect: !0,
|
|
492
|
-
maxReconnectAttempts: 5,
|
|
493
|
-
reconnectDelay: 1e3,
|
|
494
|
-
maxReconnectDelay: 3e4,
|
|
495
|
-
ndjson: !0
|
|
496
|
-
};
|
|
497
|
-
function de(M, e = {}) {
|
|
498
|
-
const t = { ...k, ...M }, h = d(!1), a = d(!1), l = d("disconnected"), c = d(null), R = d([]), m = d(0), v = d(null), u = d(0);
|
|
499
|
-
let y = null, w = !1;
|
|
500
|
-
const C = U({
|
|
501
|
-
maxAttempts: t.maxReconnectAttempts,
|
|
502
|
-
delay: t.reconnectDelay,
|
|
503
|
-
delayMax: t.maxReconnectDelay,
|
|
504
|
-
onAttempt: (p, T) => {
|
|
505
|
-
var n;
|
|
506
|
-
u.value = p, l.value = "reconnecting", (n = e.onReconnecting) == null || n.call(e, p, T);
|
|
507
|
-
},
|
|
508
|
-
onSuccess: () => {
|
|
509
|
-
var p;
|
|
510
|
-
u.value = 0, (p = e.onReconnected) == null || p.call(e);
|
|
511
|
-
},
|
|
512
|
-
onFailure: () => {
|
|
513
|
-
var p;
|
|
514
|
-
l.value = "failed", (p = e.onReconnectFailed) == null || p.call(e);
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
|
-
function A(p) {
|
|
518
|
-
const T = p.trim();
|
|
519
|
-
if (!T) return null;
|
|
520
|
-
try {
|
|
521
|
-
return JSON.parse(T);
|
|
522
|
-
} catch {
|
|
523
|
-
return T;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
function x(p) {
|
|
527
|
-
var n, f;
|
|
528
|
-
if (!p) return;
|
|
529
|
-
let T;
|
|
530
|
-
if (t.parseChunk)
|
|
531
|
-
T = t.parseChunk(p);
|
|
532
|
-
else if (t.ndjson) {
|
|
533
|
-
const o = p.split(`
|
|
534
|
-
`);
|
|
535
|
-
for (const i of o) {
|
|
536
|
-
const r = A(i);
|
|
537
|
-
r !== null && (c.value = r, R.value.push(r), (n = e.onChunk) == null || n.call(e, r, i));
|
|
538
|
-
}
|
|
539
|
-
return;
|
|
540
|
-
} else
|
|
541
|
-
T = p;
|
|
542
|
-
T != null && (c.value = T, R.value.push(T), (f = e.onChunk) == null || f.call(e, T, p));
|
|
543
|
-
}
|
|
544
|
-
async function F() {
|
|
545
|
-
var p, T, n, f;
|
|
546
|
-
if (!a.value) {
|
|
547
|
-
w = !1, l.value = "connecting", v.value = null, y = new AbortController();
|
|
548
|
-
try {
|
|
549
|
-
const o = {
|
|
550
|
-
method: t.method,
|
|
551
|
-
headers: {
|
|
552
|
-
Accept: "text/event-stream, application/x-ndjson, application/json, text/plain",
|
|
553
|
-
...t.headers
|
|
554
|
-
},
|
|
555
|
-
credentials: t.credentials,
|
|
556
|
-
signal: y.signal
|
|
557
|
-
};
|
|
558
|
-
t.body && ["POST", "PUT", "PATCH"].includes(t.method) && (o.body = typeof t.body == "string" ? t.body : JSON.stringify(t.body));
|
|
559
|
-
const i = await fetch(t.url, o);
|
|
560
|
-
if (!i.ok)
|
|
561
|
-
throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
562
|
-
if (!i.body)
|
|
563
|
-
throw new Error("Response body is not readable");
|
|
564
|
-
h.value = !0, a.value = !0, l.value = "connected", (p = e.onOpen) == null || p.call(e);
|
|
565
|
-
const r = i.body.getReader(), s = new TextDecoder();
|
|
566
|
-
let P = "";
|
|
567
|
-
for (; ; ) {
|
|
568
|
-
const { done: N, value: L } = await r.read();
|
|
569
|
-
if (N) {
|
|
570
|
-
P && x(P);
|
|
571
|
-
break;
|
|
572
|
-
}
|
|
573
|
-
const D = s.decode(L, { stream: !0 });
|
|
574
|
-
m.value += L.length, (T = e.onProgress) == null || T.call(e, m.value), P += D;
|
|
575
|
-
const O = P.lastIndexOf(`
|
|
576
|
-
`);
|
|
577
|
-
if (O !== -1) {
|
|
578
|
-
const $ = P.slice(0, O);
|
|
579
|
-
P = P.slice(O + 1), x($);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
a.value = !1, l.value = "disconnected", (n = e.onComplete) == null || n.call(e);
|
|
583
|
-
} catch (o) {
|
|
584
|
-
if (o.name === "AbortError")
|
|
585
|
-
return;
|
|
586
|
-
v.value = o, h.value = !1, a.value = !1, l.value = "error", (f = e.onError) == null || f.call(e, o), !w && t.autoReconnect && C.scheduleReconnect(async () => {
|
|
587
|
-
try {
|
|
588
|
-
return await F(), !0;
|
|
589
|
-
} catch {
|
|
590
|
-
return !1;
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
function S() {
|
|
597
|
-
w = !0, C.cancel(), y && (y.abort(), y = null), h.value = !1, a.value = !1, l.value = "disconnected";
|
|
598
|
-
}
|
|
599
|
-
function I() {
|
|
600
|
-
R.value = [], c.value = null, m.value = 0;
|
|
601
|
-
}
|
|
602
|
-
return t.autoConnect && F(), H(() => {
|
|
603
|
-
S();
|
|
604
|
-
}), {
|
|
605
|
-
isConnected: h,
|
|
606
|
-
isStreaming: a,
|
|
607
|
-
connectionState: l,
|
|
608
|
-
lastChunk: c,
|
|
609
|
-
chunks: R,
|
|
610
|
-
bytesReceived: m,
|
|
611
|
-
error: v,
|
|
612
|
-
reconnectAttempts: u,
|
|
613
|
-
connect: F,
|
|
614
|
-
disconnect: S,
|
|
615
|
-
clearChunks: I
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
const ee = {
|
|
619
|
-
broadcaster: "pusher",
|
|
620
|
-
wsPort: 6001,
|
|
621
|
-
wssPort: 6001,
|
|
622
|
-
forceTLS: !1,
|
|
623
|
-
disableStats: !1,
|
|
624
|
-
cluster: "mt1",
|
|
625
|
-
authEndpoint: "/broadcasting/auth",
|
|
626
|
-
authHeaders: {},
|
|
627
|
-
auth: { headers: {} },
|
|
628
|
-
enabledTransports: ["ws", "wss"],
|
|
629
|
-
options: {}
|
|
630
|
-
};
|
|
631
|
-
function ve(M, e = {}) {
|
|
632
|
-
const t = { ...ee, ...M }, h = d(!1), a = d("idle"), l = d(null), c = d([]), R = d(null);
|
|
633
|
-
let m = null;
|
|
634
|
-
async function v() {
|
|
635
|
-
if (m) return m;
|
|
636
|
-
try {
|
|
637
|
-
const [{ default: n }, { default: f }] = await Promise.all([
|
|
638
|
-
import("laravel-echo"),
|
|
639
|
-
import("pusher-js")
|
|
640
|
-
]);
|
|
641
|
-
return window.Pusher = f, m = new n({
|
|
642
|
-
broadcaster: "pusher",
|
|
643
|
-
key: t.key,
|
|
644
|
-
wsHost: t.wsHost,
|
|
645
|
-
wsPort: t.wsPort,
|
|
646
|
-
wssPort: t.wssPort,
|
|
647
|
-
forceTLS: t.forceTLS,
|
|
648
|
-
cluster: t.cluster,
|
|
649
|
-
authEndpoint: t.authEndpoint,
|
|
650
|
-
auth: {
|
|
651
|
-
headers: t.authHeaders
|
|
652
|
-
},
|
|
653
|
-
enabledTransports: t.enabledTransports,
|
|
654
|
-
disableStats: !0
|
|
655
|
-
}), m;
|
|
656
|
-
} catch {
|
|
657
|
-
throw new Error(
|
|
658
|
-
"laravel-echo and/or pusher-js not installed. Run: npm install laravel-echo pusher-js"
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
function u(n, f) {
|
|
663
|
-
var i;
|
|
664
|
-
c.value.find((r) => r.name === n) || (c.value = [
|
|
665
|
-
...c.value,
|
|
666
|
-
{ name: n, type: f, subscribedAt: /* @__PURE__ */ new Date() }
|
|
667
|
-
], (i = e.onSubscribed) == null || i.call(e, n));
|
|
668
|
-
}
|
|
669
|
-
function y(n) {
|
|
670
|
-
c.value = c.value.filter((f) => f.name !== n);
|
|
671
|
-
}
|
|
672
|
-
async function w() {
|
|
673
|
-
var n;
|
|
674
|
-
a.value = "connecting", R.value = null;
|
|
675
|
-
try {
|
|
676
|
-
const o = (await v()).connector.pusher;
|
|
677
|
-
o.connection.bind("connected", () => {
|
|
678
|
-
var i;
|
|
679
|
-
h.value = !0, a.value = "connected", l.value = o.connection.socket_id || null, (i = e.onConnected) == null || i.call(e, l.value || "");
|
|
680
|
-
}), o.connection.bind("disconnected", () => {
|
|
681
|
-
var i;
|
|
682
|
-
h.value = !1, a.value = "disconnected", l.value = null, (i = e.onDisconnected) == null || i.call(e);
|
|
683
|
-
}), o.connection.bind("error", (i) => {
|
|
684
|
-
var r;
|
|
685
|
-
R.value = i, a.value = "error", (r = e.onError) == null || r.call(e, i);
|
|
686
|
-
}), o.connection.state === "connected" && (h.value = !0, a.value = "connected", l.value = o.connection.socket_id || null, (n = e.onConnected) == null || n.call(e, l.value || ""));
|
|
687
|
-
} catch (f) {
|
|
688
|
-
const o = f instanceof Error ? f : new Error(String(f));
|
|
689
|
-
throw R.value = o, a.value = "error", o;
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
function C() {
|
|
693
|
-
m && (m.disconnect(), m = null), h.value = !1, a.value = "closed", l.value = null, c.value = [];
|
|
694
|
-
}
|
|
695
|
-
function A(n, f) {
|
|
696
|
-
return {
|
|
697
|
-
listen(o, i) {
|
|
698
|
-
return n.bind(o.startsWith(".") ? o : `.${o}`, i), this;
|
|
699
|
-
},
|
|
700
|
-
stopListening(o, i) {
|
|
701
|
-
return n.unbind(o.startsWith(".") ? o : `.${o}`, i), this;
|
|
702
|
-
},
|
|
703
|
-
listenForWhisper(o, i) {
|
|
704
|
-
return n.bind(`client-${o}`, i), this;
|
|
705
|
-
},
|
|
706
|
-
whisper(o, i) {
|
|
707
|
-
return n.trigger(`client-${o}`, i), this;
|
|
708
|
-
}
|
|
709
|
-
};
|
|
710
|
-
}
|
|
711
|
-
function x(n, f) {
|
|
712
|
-
return {
|
|
713
|
-
...A(n),
|
|
714
|
-
here(i) {
|
|
715
|
-
return n.here(i), this;
|
|
716
|
-
},
|
|
717
|
-
joining(i) {
|
|
718
|
-
return n.joining((r) => {
|
|
719
|
-
var s;
|
|
720
|
-
(s = e.onMemberJoined) == null || s.call(e, f, r), i(r);
|
|
721
|
-
}), this;
|
|
722
|
-
},
|
|
723
|
-
leaving(i) {
|
|
724
|
-
return n.leaving((r) => {
|
|
725
|
-
var s;
|
|
726
|
-
(s = e.onMemberLeft) == null || s.call(e, f, r), i(r);
|
|
727
|
-
}), this;
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
function F(n) {
|
|
732
|
-
if (!m)
|
|
733
|
-
throw new Error("Echo not connected. Call connect() first.");
|
|
734
|
-
const f = m.channel(n);
|
|
735
|
-
return u(n, "public"), A(f);
|
|
736
|
-
}
|
|
737
|
-
function S(n) {
|
|
738
|
-
if (!m)
|
|
739
|
-
throw new Error("Echo not connected. Call connect() first.");
|
|
740
|
-
const f = m.private(n);
|
|
741
|
-
return u(`private-${n}`, "private"), A(f);
|
|
742
|
-
}
|
|
743
|
-
function I(n) {
|
|
744
|
-
if (!m)
|
|
745
|
-
throw new Error("Echo not connected. Call connect() first.");
|
|
746
|
-
const f = m.join(n);
|
|
747
|
-
return u(`presence-${n}`, "presence"), x(f, n);
|
|
748
|
-
}
|
|
749
|
-
function p(n) {
|
|
750
|
-
m && (m.leaveChannel(n), y(n), y(`private-${n}`), y(`presence-${n}`));
|
|
751
|
-
}
|
|
752
|
-
function T() {
|
|
753
|
-
[...c.value.map((f) => f.name)].forEach((f) => p(f));
|
|
754
|
-
}
|
|
755
|
-
return H(() => {
|
|
756
|
-
C();
|
|
757
|
-
}), {
|
|
758
|
-
isConnected: h,
|
|
759
|
-
connectionState: a,
|
|
760
|
-
socketId: l,
|
|
761
|
-
channels: c,
|
|
762
|
-
error: R,
|
|
763
|
-
connect: w,
|
|
764
|
-
disconnect: C,
|
|
765
|
-
channel: F,
|
|
766
|
-
privateChannel: S,
|
|
767
|
-
presenceChannel: I,
|
|
768
|
-
leave: p,
|
|
769
|
-
leaveAll: T
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
const ne = {
|
|
773
|
-
method: "GET",
|
|
774
|
-
headers: {},
|
|
775
|
-
credentials: "same-origin",
|
|
776
|
-
interval: 0,
|
|
777
|
-
timeout: 3e4,
|
|
778
|
-
autoStart: !0,
|
|
779
|
-
autoRestart: !0,
|
|
780
|
-
maxRestartAttempts: 5,
|
|
781
|
-
restartDelay: 1e3,
|
|
782
|
-
maxRestartDelay: 3e4,
|
|
783
|
-
includeTimestamp: !1,
|
|
784
|
-
timestampParam: "since"
|
|
785
|
-
};
|
|
786
|
-
function pe(M, e = {}) {
|
|
787
|
-
const t = { ...ne, ...M }, h = d(!1), a = d("disconnected"), l = d(null), c = d([]), R = d(0), m = d(null), v = d(0);
|
|
788
|
-
let u = null, y = null, w = !1, C = null;
|
|
789
|
-
const A = U({
|
|
790
|
-
maxAttempts: t.maxRestartAttempts,
|
|
791
|
-
delay: t.restartDelay,
|
|
792
|
-
delayMax: t.maxRestartDelay,
|
|
793
|
-
onAttempt: (o, i) => {
|
|
794
|
-
var r;
|
|
795
|
-
v.value = o, a.value = "reconnecting", (r = e.onRestarting) == null || r.call(e, o, i);
|
|
796
|
-
},
|
|
797
|
-
onSuccess: () => {
|
|
798
|
-
var o;
|
|
799
|
-
v.value = 0, (o = e.onRestarted) == null || o.call(e);
|
|
800
|
-
},
|
|
801
|
-
onFailure: () => {
|
|
802
|
-
var o;
|
|
803
|
-
a.value = "failed", (o = e.onRestartFailed) == null || o.call(e);
|
|
804
|
-
}
|
|
805
|
-
});
|
|
806
|
-
function x() {
|
|
807
|
-
if (!t.includeTimestamp || !C)
|
|
808
|
-
return t.url;
|
|
809
|
-
const o = new URL(t.url);
|
|
810
|
-
return o.searchParams.set(t.timestampParam, C.toString()), o.toString();
|
|
811
|
-
}
|
|
812
|
-
async function F() {
|
|
813
|
-
u = new AbortController();
|
|
814
|
-
const o = setTimeout(() => {
|
|
815
|
-
u == null || u.abort();
|
|
816
|
-
}, t.timeout);
|
|
817
|
-
try {
|
|
818
|
-
const i = {
|
|
819
|
-
method: t.method,
|
|
820
|
-
headers: {
|
|
821
|
-
Accept: "application/json",
|
|
822
|
-
...t.headers
|
|
823
|
-
},
|
|
824
|
-
credentials: t.credentials,
|
|
825
|
-
signal: u.signal
|
|
826
|
-
};
|
|
827
|
-
t.body && t.method === "POST" && (i.body = typeof t.body == "string" ? t.body : JSON.stringify(t.body), i.headers = {
|
|
828
|
-
...i.headers,
|
|
829
|
-
"Content-Type": "application/json"
|
|
830
|
-
});
|
|
831
|
-
const r = await fetch(x(), i);
|
|
832
|
-
if (clearTimeout(o), !r.ok)
|
|
833
|
-
throw new Error(`HTTP ${r.status}: ${r.statusText}`);
|
|
834
|
-
return await r.json();
|
|
835
|
-
} catch (i) {
|
|
836
|
-
throw clearTimeout(o), i;
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
async function S() {
|
|
840
|
-
var o, i;
|
|
841
|
-
for (; h.value && !w; )
|
|
842
|
-
try {
|
|
843
|
-
R.value++;
|
|
844
|
-
const r = await F();
|
|
845
|
-
C = Date.now(), l.value = r, c.value.push(r), m.value = null, (o = e.onData) == null || o.call(e, r), t.interval > 0 && h.value && !w && await new Promise((s) => {
|
|
846
|
-
y = setTimeout(s, t.interval);
|
|
847
|
-
});
|
|
848
|
-
} catch (r) {
|
|
849
|
-
if (r.name === "AbortError") {
|
|
850
|
-
if (w)
|
|
851
|
-
break;
|
|
852
|
-
continue;
|
|
853
|
-
}
|
|
854
|
-
if (m.value = r, (i = e.onError) == null || i.call(e, r), !w && t.autoRestart) {
|
|
855
|
-
h.value = !1, a.value = "error", A.scheduleReconnect(async () => {
|
|
856
|
-
try {
|
|
857
|
-
return await I(), !0;
|
|
858
|
-
} catch {
|
|
859
|
-
return !1;
|
|
860
|
-
}
|
|
861
|
-
});
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
864
|
-
break;
|
|
865
|
-
}
|
|
866
|
-
w || (h.value = !1, a.value = "disconnected");
|
|
867
|
-
}
|
|
868
|
-
async function I() {
|
|
869
|
-
var o;
|
|
870
|
-
h.value || (w = !1, h.value = !0, a.value = "connected", m.value = null, (o = e.onStart) == null || o.call(e), S());
|
|
871
|
-
}
|
|
872
|
-
function p() {
|
|
873
|
-
I();
|
|
874
|
-
}
|
|
875
|
-
function T() {
|
|
876
|
-
var o;
|
|
877
|
-
w = !0, A.cancel(), y && (clearTimeout(y), y = null), u && (u.abort(), u = null), h.value = !1, a.value = "disconnected", (o = e.onStop) == null || o.call(e);
|
|
878
|
-
}
|
|
879
|
-
async function n() {
|
|
880
|
-
var i, r;
|
|
881
|
-
const o = h.value;
|
|
882
|
-
y && (clearTimeout(y), y = null);
|
|
883
|
-
try {
|
|
884
|
-
const s = await F();
|
|
885
|
-
C = Date.now(), l.value = s, c.value.push(s), (i = e.onData) == null || i.call(e, s);
|
|
886
|
-
} catch (s) {
|
|
887
|
-
s.name !== "AbortError" && (m.value = s, (r = e.onError) == null || r.call(e, s));
|
|
888
|
-
}
|
|
889
|
-
o && !w && S();
|
|
890
|
-
}
|
|
891
|
-
function f() {
|
|
892
|
-
c.value = [], l.value = null, R.value = 0;
|
|
893
|
-
}
|
|
894
|
-
return t.autoStart && p(), H(() => {
|
|
895
|
-
T();
|
|
896
|
-
}), {
|
|
897
|
-
isPolling: h,
|
|
898
|
-
connectionState: a,
|
|
899
|
-
lastData: l,
|
|
900
|
-
dataHistory: c,
|
|
901
|
-
requestCount: R,
|
|
902
|
-
error: m,
|
|
903
|
-
restartAttempts: v,
|
|
904
|
-
start: p,
|
|
905
|
-
stop: T,
|
|
906
|
-
poll: n,
|
|
907
|
-
clearHistory: f
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
const te = {
|
|
911
|
-
path: "/socket.io",
|
|
912
|
-
namespace: "/",
|
|
913
|
-
reconnection: !0,
|
|
914
|
-
reconnectionAttempts: 5,
|
|
915
|
-
reconnectionDelay: 1e3,
|
|
916
|
-
transports: ["websocket", "polling"],
|
|
917
|
-
extraHeaders: {},
|
|
918
|
-
options: {},
|
|
919
|
-
autoConnect: !0,
|
|
920
|
-
autoReconnect: !0,
|
|
921
|
-
maxReconnectAttempts: 5,
|
|
922
|
-
reconnectDelay: 1e3
|
|
923
|
-
};
|
|
924
|
-
function he(M, e = {}) {
|
|
925
|
-
const t = { ...te, ...M }, h = d(!1), a = d("idle"), l = d(null), c = d([]), R = d(0), m = d(null);
|
|
926
|
-
let v = null, u = null;
|
|
927
|
-
async function y() {
|
|
928
|
-
if (u) return u;
|
|
929
|
-
try {
|
|
930
|
-
const n = await import("socket.io-client");
|
|
931
|
-
return u = n.io || n.default, u;
|
|
932
|
-
} catch {
|
|
933
|
-
throw new Error(
|
|
934
|
-
"socket.io-client is not installed. Run: npm install socket.io-client"
|
|
935
|
-
);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
async function w() {
|
|
939
|
-
if (!(v != null && v.connected))
|
|
940
|
-
return a.value = "connecting", m.value = null, new Promise(async (n, f) => {
|
|
941
|
-
try {
|
|
942
|
-
const o = await y();
|
|
943
|
-
if (!o)
|
|
944
|
-
throw new Error("Socket.IO client not available");
|
|
945
|
-
const i = t.namespace === "/" ? t.url : `${t.url}${t.namespace}`;
|
|
946
|
-
v = o(i, {
|
|
947
|
-
path: t.path,
|
|
948
|
-
auth: t.auth,
|
|
949
|
-
reconnection: t.reconnection,
|
|
950
|
-
reconnectionAttempts: t.reconnectionAttempts,
|
|
951
|
-
reconnectionDelay: t.reconnectionDelay,
|
|
952
|
-
transports: t.transports,
|
|
953
|
-
extraHeaders: t.extraHeaders
|
|
954
|
-
}), v.on("connect", () => {
|
|
955
|
-
var r;
|
|
956
|
-
h.value = !0, a.value = "connected", l.value = (v == null ? void 0 : v.id) || null, R.value = 0, (r = e.onConnect) == null || r.call(e, l.value || ""), n();
|
|
957
|
-
}), v.on("disconnect", (r) => {
|
|
958
|
-
var s;
|
|
959
|
-
h.value = !1, a.value = "disconnected", l.value = null, (s = e.onDisconnect) == null || s.call(e, r);
|
|
960
|
-
}), v.on("connect_error", (r) => {
|
|
961
|
-
var s;
|
|
962
|
-
m.value = r, a.value = "error", (s = e.onError) == null || s.call(e, r), f(r);
|
|
963
|
-
}), v.io.on("reconnect_attempt", (r) => {
|
|
964
|
-
var s;
|
|
965
|
-
R.value = r, a.value = "reconnecting", (s = e.onReconnecting) == null || s.call(e, r);
|
|
966
|
-
}), v.io.on("reconnect_failed", () => {
|
|
967
|
-
var r;
|
|
968
|
-
a.value = "error", (r = e.onReconnectFailed) == null || r.call(e);
|
|
969
|
-
}), v.connect();
|
|
970
|
-
} catch (o) {
|
|
971
|
-
const i = o instanceof Error ? o : new Error(String(o));
|
|
972
|
-
m.value = i, a.value = "error", f(i);
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
function C() {
|
|
977
|
-
v && (v.disconnect(), v = null), h.value = !1, a.value = "closed", l.value = null, c.value = [];
|
|
978
|
-
}
|
|
979
|
-
function A(n, f) {
|
|
980
|
-
if (!(v != null && v.connected)) {
|
|
981
|
-
console.warn("[useSocketIO] Cannot emit: Socket is not connected");
|
|
982
|
-
return;
|
|
983
|
-
}
|
|
984
|
-
v.emit(n, f);
|
|
985
|
-
}
|
|
986
|
-
function x(n, f, o = 5e3) {
|
|
987
|
-
return new Promise((i, r) => {
|
|
988
|
-
if (!(v != null && v.connected)) {
|
|
989
|
-
r(new Error("Socket is not connected"));
|
|
990
|
-
return;
|
|
991
|
-
}
|
|
992
|
-
const s = setTimeout(() => {
|
|
993
|
-
r(new Error(`Emit timeout for event: ${n}`));
|
|
994
|
-
}, o);
|
|
995
|
-
v.emit(n, f, (P) => {
|
|
996
|
-
clearTimeout(s), i(P);
|
|
997
|
-
});
|
|
998
|
-
});
|
|
999
|
-
}
|
|
1000
|
-
function F(n, f) {
|
|
1001
|
-
if (!v) {
|
|
1002
|
-
console.warn("[useSocketIO] Cannot listen: Socket not initialized");
|
|
1003
|
-
return;
|
|
1004
|
-
}
|
|
1005
|
-
v.on(n, f);
|
|
1006
|
-
}
|
|
1007
|
-
function S(n, f) {
|
|
1008
|
-
v && v.off(n, f);
|
|
1009
|
-
}
|
|
1010
|
-
async function I(n) {
|
|
1011
|
-
if (!(v != null && v.connected))
|
|
1012
|
-
throw new Error("Socket is not connected");
|
|
1013
|
-
return new Promise((f, o) => {
|
|
1014
|
-
v.emit("join", n, (i) => {
|
|
1015
|
-
if (i != null && i.error)
|
|
1016
|
-
o(new Error(i.error));
|
|
1017
|
-
else {
|
|
1018
|
-
const r = {
|
|
1019
|
-
name: n,
|
|
1020
|
-
joinedAt: /* @__PURE__ */ new Date()
|
|
1021
|
-
};
|
|
1022
|
-
c.value = [...c.value, r], f();
|
|
1023
|
-
}
|
|
1024
|
-
}), setTimeout(f, 1e3);
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
async function p(n) {
|
|
1028
|
-
if (v != null && v.connected)
|
|
1029
|
-
return new Promise((f) => {
|
|
1030
|
-
v.emit("leave", n, () => {
|
|
1031
|
-
c.value = c.value.filter((o) => o.name !== n), f();
|
|
1032
|
-
}), setTimeout(() => {
|
|
1033
|
-
c.value = c.value.filter((o) => o.name !== n), f();
|
|
1034
|
-
}, 1e3);
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
function T() {
|
|
1038
|
-
return v;
|
|
1039
|
-
}
|
|
1040
|
-
return H(() => {
|
|
1041
|
-
C();
|
|
1042
|
-
}), {
|
|
1043
|
-
isConnected: h,
|
|
1044
|
-
connectionState: a,
|
|
1045
|
-
socketId: l,
|
|
1046
|
-
rooms: c,
|
|
1047
|
-
reconnectAttempts: R,
|
|
1048
|
-
error: m,
|
|
1049
|
-
connect: w,
|
|
1050
|
-
disconnect: C,
|
|
1051
|
-
emit: A,
|
|
1052
|
-
emitWithAck: x,
|
|
1053
|
-
on: F,
|
|
1054
|
-
off: S,
|
|
1055
|
-
join: I,
|
|
1056
|
-
leave: p,
|
|
1057
|
-
getSocket: T
|
|
1058
|
-
};
|
|
1059
|
-
}
|
|
1060
|
-
const oe = {
|
|
1061
|
-
withCredentials: !1,
|
|
1062
|
-
autoConnect: !0,
|
|
1063
|
-
autoReconnect: !0,
|
|
1064
|
-
maxReconnectAttempts: 5,
|
|
1065
|
-
reconnectDelay: 1e3,
|
|
1066
|
-
maxReconnectDelay: 3e4,
|
|
1067
|
-
eventTypes: ["message"]
|
|
1068
|
-
};
|
|
1069
|
-
function me(M, e = {}) {
|
|
1070
|
-
const t = { ...oe, ...M }, h = d(!1), a = d("disconnected"), l = d(null), c = d(""), R = d(null), m = d(null), v = d(0);
|
|
1071
|
-
let u = null, y = !1;
|
|
1072
|
-
const w = /* @__PURE__ */ new Map(), C = U({
|
|
1073
|
-
maxAttempts: t.maxReconnectAttempts,
|
|
1074
|
-
delay: t.reconnectDelay,
|
|
1075
|
-
delayMax: t.maxReconnectDelay,
|
|
1076
|
-
onAttempt: (n, f) => {
|
|
1077
|
-
var o;
|
|
1078
|
-
v.value = n, a.value = "reconnecting", (o = e.onReconnecting) == null || o.call(e, n, f);
|
|
1079
|
-
},
|
|
1080
|
-
onSuccess: () => {
|
|
1081
|
-
var n;
|
|
1082
|
-
v.value = 0, (n = e.onReconnected) == null || n.call(e);
|
|
1083
|
-
},
|
|
1084
|
-
onFailure: () => {
|
|
1085
|
-
var n;
|
|
1086
|
-
a.value = "failed", (n = e.onReconnectFailed) == null || n.call(e);
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1089
|
-
function A(n) {
|
|
1090
|
-
var f, o;
|
|
1091
|
-
try {
|
|
1092
|
-
let i;
|
|
1093
|
-
try {
|
|
1094
|
-
i = JSON.parse(n.data);
|
|
1095
|
-
} catch {
|
|
1096
|
-
i = n.data;
|
|
1097
|
-
}
|
|
1098
|
-
l.value = i, c.value = n.type || "message", R.value = n.lastEventId || null, (f = e.onMessage) == null || f.call(e, i, n), (o = e.onEvent) == null || o.call(e, n.type || "message", i, n);
|
|
1099
|
-
const r = w.get(n.type || "message");
|
|
1100
|
-
r && r.forEach((s) => s(i));
|
|
1101
|
-
} catch (i) {
|
|
1102
|
-
console.error("[useSSE] Error processing message:", i);
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
function x() {
|
|
1106
|
-
var n;
|
|
1107
|
-
h.value = !0, a.value = "connected", m.value = null, C.reset(), (n = e.onOpen) == null || n.call(e);
|
|
1108
|
-
}
|
|
1109
|
-
function F(n) {
|
|
1110
|
-
var f;
|
|
1111
|
-
m.value = n, (f = e.onError) == null || f.call(e, n), (u == null ? void 0 : u.readyState) === EventSource.CLOSED && (h.value = !1, a.value = "error", !y && t.autoReconnect && C.scheduleReconnect(async () => {
|
|
1112
|
-
try {
|
|
1113
|
-
return S(), !0;
|
|
1114
|
-
} catch {
|
|
1115
|
-
return !1;
|
|
1116
|
-
}
|
|
1117
|
-
}));
|
|
1118
|
-
}
|
|
1119
|
-
function S() {
|
|
1120
|
-
var n;
|
|
1121
|
-
if (!(u && u.readyState !== EventSource.CLOSED)) {
|
|
1122
|
-
y = !1, a.value = "connecting";
|
|
1123
|
-
try {
|
|
1124
|
-
u = new EventSource(t.url, {
|
|
1125
|
-
withCredentials: t.withCredentials
|
|
1126
|
-
}), u.onmessage = A, u.onopen = x, u.onerror = F, t.eventTypes.forEach((f) => {
|
|
1127
|
-
f !== "message" && u && u.addEventListener(
|
|
1128
|
-
f,
|
|
1129
|
-
A
|
|
1130
|
-
);
|
|
1131
|
-
});
|
|
1132
|
-
} catch (f) {
|
|
1133
|
-
a.value = "error", m.value = f, (n = e.onError) == null || n.call(e, f);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
function I() {
|
|
1138
|
-
y = !0, C.cancel(), u && (u.close(), u = null), h.value = !1, a.value = "disconnected";
|
|
1139
|
-
}
|
|
1140
|
-
function p(n, f) {
|
|
1141
|
-
w.has(n) || (w.set(n, /* @__PURE__ */ new Set()), u && n !== "message" && u.addEventListener(n, A)), w.get(n).add(f);
|
|
1142
|
-
}
|
|
1143
|
-
function T(n, f) {
|
|
1144
|
-
const o = w.get(n);
|
|
1145
|
-
o && (o.delete(f), o.size === 0 && w.delete(n));
|
|
1146
|
-
}
|
|
1147
|
-
return t.autoConnect && S(), H(() => {
|
|
1148
|
-
I(), w.clear();
|
|
1149
|
-
}), {
|
|
1150
|
-
isConnected: h,
|
|
1151
|
-
connectionState: a,
|
|
1152
|
-
lastMessage: l,
|
|
1153
|
-
lastEventType: c,
|
|
1154
|
-
lastEventId: R,
|
|
1155
|
-
error: m,
|
|
1156
|
-
reconnectAttempts: v,
|
|
1157
|
-
connect: S,
|
|
1158
|
-
disconnect: I,
|
|
1159
|
-
addEventListener: p,
|
|
1160
|
-
removeEventListener: T
|
|
1161
|
-
};
|
|
1162
|
-
}
|
|
1163
|
-
const re = {
|
|
1164
|
-
autoReconnect: !0,
|
|
1165
|
-
maxReconnectAttempts: 5,
|
|
1166
|
-
reconnectDelay: 1e3,
|
|
1167
|
-
reconnectDelayMax: 3e4,
|
|
1168
|
-
pingInterval: 0,
|
|
1169
|
-
binaryType: "arraybuffer"
|
|
1170
|
-
};
|
|
1171
|
-
function le(M, e = {}) {
|
|
1172
|
-
const t = { ...re, ...M }, h = d(!1), a = d("idle"), l = d(WebSocket.CLOSED), c = d(0), R = d(null), m = d(null), v = d(0);
|
|
1173
|
-
let u = null, y = null, w = !1;
|
|
1174
|
-
const C = U({
|
|
1175
|
-
maxAttempts: t.maxReconnectAttempts,
|
|
1176
|
-
delay: t.reconnectDelay,
|
|
1177
|
-
delayMax: t.reconnectDelayMax,
|
|
1178
|
-
onAttempt: (n, f) => {
|
|
1179
|
-
var o;
|
|
1180
|
-
v.value = n, a.value = "reconnecting", (o = e.onReconnecting) == null || o.call(e, n, f);
|
|
1181
|
-
},
|
|
1182
|
-
onSuccess: () => {
|
|
1183
|
-
v.value = 0;
|
|
1184
|
-
},
|
|
1185
|
-
onFailure: () => {
|
|
1186
|
-
var n;
|
|
1187
|
-
a.value = "error", (n = e.onReconnectFailed) == null || n.call(e);
|
|
1188
|
-
}
|
|
1189
|
-
});
|
|
1190
|
-
function A() {
|
|
1191
|
-
!t.pingInterval || t.pingInterval <= 0 || (y = setInterval(() => {
|
|
1192
|
-
u && u.readyState === WebSocket.OPEN && u.send(JSON.stringify({ type: "ping", timestamp: Date.now() }));
|
|
1193
|
-
}, t.pingInterval));
|
|
1194
|
-
}
|
|
1195
|
-
function x() {
|
|
1196
|
-
y && (clearInterval(y), y = null);
|
|
1197
|
-
}
|
|
1198
|
-
function F() {
|
|
1199
|
-
u && (c.value = u.bufferedAmount);
|
|
1200
|
-
}
|
|
1201
|
-
async function S() {
|
|
1202
|
-
if (!(u && u.readyState === WebSocket.OPEN))
|
|
1203
|
-
return w = !1, a.value = "connecting", m.value = null, new Promise((n, f) => {
|
|
1204
|
-
try {
|
|
1205
|
-
u = new WebSocket(t.url, t.protocols), u.binaryType = t.binaryType, u.onopen = () => {
|
|
1206
|
-
var o;
|
|
1207
|
-
h.value = !0, a.value = "connected", l.value = WebSocket.OPEN, C.reset(), v.value = 0, A(), (o = e.onOpen) == null || o.call(e), n();
|
|
1208
|
-
}, u.onclose = (o) => {
|
|
1209
|
-
var i;
|
|
1210
|
-
h.value = !1, a.value = "disconnected", l.value = WebSocket.CLOSED, x(), (i = e.onClose) == null || i.call(e, o.code, o.reason), !w && t.autoReconnect && C.scheduleReconnect(async () => {
|
|
1211
|
-
try {
|
|
1212
|
-
return await S(), !0;
|
|
1213
|
-
} catch {
|
|
1214
|
-
return !1;
|
|
1215
|
-
}
|
|
1216
|
-
});
|
|
1217
|
-
}, u.onerror = (o) => {
|
|
1218
|
-
var i;
|
|
1219
|
-
m.value = o, a.value = "error", (i = e.onError) == null || i.call(e, o), f(o);
|
|
1220
|
-
}, u.onmessage = (o) => {
|
|
1221
|
-
var r;
|
|
1222
|
-
R.value = o.data, F();
|
|
1223
|
-
let i = o.data;
|
|
1224
|
-
if (typeof o.data == "string")
|
|
1225
|
-
try {
|
|
1226
|
-
i = JSON.parse(o.data);
|
|
1227
|
-
} catch {
|
|
1228
|
-
}
|
|
1229
|
-
(r = e.onMessage) == null || r.call(e, i, o);
|
|
1230
|
-
}, l.value = u.readyState;
|
|
1231
|
-
} catch (o) {
|
|
1232
|
-
a.value = "error", f(o);
|
|
1233
|
-
}
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
function I() {
|
|
1237
|
-
w = !0, C.cancel(), x(), u && (u.close(1e3, "Client disconnect"), u = null), h.value = !1, a.value = "closed", l.value = WebSocket.CLOSED;
|
|
1238
|
-
}
|
|
1239
|
-
function p(n) {
|
|
1240
|
-
if (!u || u.readyState !== WebSocket.OPEN)
|
|
1241
|
-
return console.warn("[useWebSocket] Cannot send: WebSocket is not connected"), !1;
|
|
1242
|
-
try {
|
|
1243
|
-
return u.send(n), F(), !0;
|
|
1244
|
-
} catch (f) {
|
|
1245
|
-
return console.error("[useWebSocket] Send error:", f), !1;
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
function T(n) {
|
|
1249
|
-
return p(JSON.stringify(n));
|
|
1250
|
-
}
|
|
1251
|
-
return H(() => {
|
|
1252
|
-
I();
|
|
1253
|
-
}), {
|
|
1254
|
-
isConnected: h,
|
|
1255
|
-
connectionState: a,
|
|
1256
|
-
readyState: l,
|
|
1257
|
-
bufferedAmount: c,
|
|
1258
|
-
lastMessage: R,
|
|
1259
|
-
error: m,
|
|
1260
|
-
reconnectAttempts: v,
|
|
1261
|
-
connect: S,
|
|
1262
|
-
disconnect: I,
|
|
1263
|
-
send: p,
|
|
1264
|
-
sendJSON: T
|
|
1265
|
-
};
|
|
1266
|
-
}
|
|
1267
|
-
export {
|
|
1268
|
-
se as a,
|
|
1269
|
-
de as b,
|
|
1270
|
-
ve as c,
|
|
1271
|
-
pe as d,
|
|
1272
|
-
me as e,
|
|
1273
|
-
he as f,
|
|
1274
|
-
fe as g,
|
|
1275
|
-
le as h,
|
|
1276
|
-
ae as u
|
|
1277
|
-
};
|
|
1278
|
-
//# sourceMappingURL=useWebSocket-D1Rqm0H7.js.map
|