@glodon-aiot/agent-cli-sdk 2.4.7

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.
Files changed (108) hide show
  1. package/README.md +70 -0
  2. package/dist/agent-cli-sdk.js +34975 -0
  3. package/dist/agent-cli-sdk.umd.cjs +150 -0
  4. package/dist/cdn/agent-cli-sdk.js +32945 -0
  5. package/dist/cdn/agent-cli-sdk.umd.cjs +140 -0
  6. package/dist/cdn/src/AgentPlugin.d.ts +17 -0
  7. package/dist/cdn/src/AgentSession.d.ts +8 -0
  8. package/dist/cdn/src/BotClient.d.ts +46 -0
  9. package/dist/cdn/src/Config.d.ts +32 -0
  10. package/dist/cdn/src/DialogSession.d.ts +21 -0
  11. package/dist/cdn/src/EventBus.d.ts +23 -0
  12. package/dist/cdn/src/Logger.d.ts +12 -0
  13. package/dist/cdn/src/PayloadTypes.d.ts +84 -0
  14. package/dist/cdn/src/Session.d.ts +156 -0
  15. package/dist/cdn/src/__ tests __/AgentClient.spec.d.ts +1 -0
  16. package/dist/cdn/src/__ tests __/AgentSession.spec.d.ts +1 -0
  17. package/dist/cdn/src/__ tests __/DialogClient.spec.d.ts +1 -0
  18. package/dist/cdn/src/api/fetchEventSource/fetch.d.ts +44 -0
  19. package/dist/cdn/src/api/fetchEventSource/index.d.ts +1 -0
  20. package/dist/cdn/src/api/fetchEventSource/parse.d.ts +36 -0
  21. package/dist/cdn/src/api/index.d.ts +2 -0
  22. package/dist/cdn/src/index.d.ts +5 -0
  23. package/dist/cdn/src/utils.d.ts +4 -0
  24. package/dist/es/AgentPlugin.mjs +20 -0
  25. package/dist/es/AgentSession.mjs +243 -0
  26. package/dist/es/BotClient.mjs +242 -0
  27. package/dist/es/Config.mjs +34 -0
  28. package/dist/es/DialogSession.mjs +281 -0
  29. package/dist/es/EventBus.mjs +64 -0
  30. package/dist/es/Logger.mjs +31 -0
  31. package/dist/es/PayloadTypes.mjs +4 -0
  32. package/dist/es/Session.mjs +527 -0
  33. package/dist/es/_virtual/_commonjsHelpers.mjs +4 -0
  34. package/dist/es/_virtual/index.mjs +4 -0
  35. package/dist/es/_virtual/index2.mjs +4 -0
  36. package/dist/es/_virtual/index3.mjs +4 -0
  37. package/dist/es/_virtual/minio-zj.mjs +4 -0
  38. package/dist/es/api/fetchEventSource/fetch.mjs +112 -0
  39. package/dist/es/api/fetchEventSource/parse.mjs +97 -0
  40. package/dist/es/api/index.mjs +48 -0
  41. package/dist/es/index.mjs +11 -0
  42. package/dist/es/node_modules/@glodon-aiot/minio/dist/minio-zj.mjs +26485 -0
  43. package/dist/es/node_modules/@socket.io/component-emitter/lib/esm/index.mjs +54 -0
  44. package/dist/es/node_modules/base64-js/index.mjs +47 -0
  45. package/dist/es/node_modules/buffer/index.mjs +927 -0
  46. package/dist/es/node_modules/engine.io-client/build/esm/contrib/has-cors.mjs +9 -0
  47. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseqs.mjs +18 -0
  48. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseuri.mjs +24 -0
  49. package/dist/es/node_modules/engine.io-client/build/esm/contrib/yeast.mjs +19 -0
  50. package/dist/es/node_modules/engine.io-client/build/esm/globalThis.browser.mjs +4 -0
  51. package/dist/es/node_modules/engine.io-client/build/esm/socket.mjs +317 -0
  52. package/dist/es/node_modules/engine.io-client/build/esm/transport.mjs +113 -0
  53. package/dist/es/node_modules/engine.io-client/build/esm/transports/index.mjs +11 -0
  54. package/dist/es/node_modules/engine.io-client/build/esm/transports/polling.mjs +273 -0
  55. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs +8 -0
  56. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket.mjs +87 -0
  57. package/dist/es/node_modules/engine.io-client/build/esm/transports/webtransport.mjs +52 -0
  58. package/dist/es/node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.mjs +21 -0
  59. package/dist/es/node_modules/engine.io-client/build/esm/util.mjs +23 -0
  60. package/dist/es/node_modules/engine.io-parser/build/esm/commons.mjs +21 -0
  61. package/dist/es/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs +14 -0
  62. package/dist/es/node_modules/engine.io-parser/build/esm/decodePacket.browser.mjs +39 -0
  63. package/dist/es/node_modules/engine.io-parser/build/esm/encodePacket.browser.mjs +28 -0
  64. package/dist/es/node_modules/engine.io-parser/build/esm/index.mjs +105 -0
  65. package/dist/es/node_modules/ieee754/index.mjs +28 -0
  66. package/dist/es/node_modules/js-base64/base64.mjs +31 -0
  67. package/dist/es/node_modules/socket.io-client/build/esm/contrib/backo2.mjs +26 -0
  68. package/dist/es/node_modules/socket.io-client/build/esm/index.mjs +25 -0
  69. package/dist/es/node_modules/socket.io-client/build/esm/manager.mjs +242 -0
  70. package/dist/es/node_modules/socket.io-client/build/esm/on.mjs +8 -0
  71. package/dist/es/node_modules/socket.io-client/build/esm/socket.mjs +608 -0
  72. package/dist/es/node_modules/socket.io-client/build/esm/url.mjs +19 -0
  73. package/dist/es/node_modules/socket.io-parser/build/esm/binary.mjs +52 -0
  74. package/dist/es/node_modules/socket.io-parser/build/esm/index.mjs +203 -0
  75. package/dist/es/node_modules/socket.io-parser/build/esm/is-binary.mjs +26 -0
  76. package/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +6 -0
  77. package/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +10 -0
  78. package/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +9 -0
  79. package/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +19 -0
  80. package/dist/es/packages/apis/dist/es/aecpilot/model.mjs +4 -0
  81. package/dist/es/packages/apis/dist/es/aecpilotui/index.mjs +8 -0
  82. package/dist/es/packages/apis/dist/es/agentcliui/index.mjs +8 -0
  83. package/dist/es/packages/apis/dist/es/base/index.mjs +154 -0
  84. package/dist/es/packages/apis/dist/es/cvforce/index.mjs +431 -0
  85. package/dist/es/packages/apis/dist/es/cvforce/model.mjs +5 -0
  86. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +1 -0
  87. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +3 -0
  88. package/dist/es/utils.mjs +11 -0
  89. package/dist/lib/index.js +126 -0
  90. package/dist/src/AgentPlugin.d.ts +17 -0
  91. package/dist/src/AgentSession.d.ts +8 -0
  92. package/dist/src/BotClient.d.ts +46 -0
  93. package/dist/src/Config.d.ts +32 -0
  94. package/dist/src/DialogSession.d.ts +21 -0
  95. package/dist/src/EventBus.d.ts +23 -0
  96. package/dist/src/Logger.d.ts +12 -0
  97. package/dist/src/PayloadTypes.d.ts +84 -0
  98. package/dist/src/Session.d.ts +155 -0
  99. package/dist/src/__ tests __/AgentClient.spec.d.ts +1 -0
  100. package/dist/src/__ tests __/AgentSession.spec.d.ts +1 -0
  101. package/dist/src/__ tests __/DialogClient.spec.d.ts +1 -0
  102. package/dist/src/api/fetchEventSource/fetch.d.ts +44 -0
  103. package/dist/src/api/fetchEventSource/index.d.ts +1 -0
  104. package/dist/src/api/fetchEventSource/parse.d.ts +36 -0
  105. package/dist/src/api/index.d.ts +2 -0
  106. package/dist/src/index.d.ts +5 -0
  107. package/dist/src/utils.d.ts +4 -0
  108. package/package.json +102 -0
@@ -0,0 +1,608 @@
1
+ import { PacketType as n } from "../../../socket.io-parser/build/esm/index.mjs";
2
+ import { on as c } from "./on.mjs";
3
+ import { Emitter as u } from "../../../@socket.io/component-emitter/lib/esm/index.mjs";
4
+ const a = Object.freeze({
5
+ connect: 1,
6
+ connect_error: 1,
7
+ disconnect: 1,
8
+ disconnecting: 1,
9
+ // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
10
+ newListener: 1,
11
+ removeListener: 1
12
+ });
13
+ class g extends u {
14
+ /**
15
+ * `Socket` constructor.
16
+ */
17
+ constructor(t, e, s) {
18
+ super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = t, this.nsp = e, s && s.auth && (this.auth = s.auth), this._opts = Object.assign({}, s), this.io._autoConnect && this.open();
19
+ }
20
+ /**
21
+ * Whether the socket is currently disconnected
22
+ *
23
+ * @example
24
+ * const socket = io();
25
+ *
26
+ * socket.on("connect", () => {
27
+ * console.log(socket.disconnected); // false
28
+ * });
29
+ *
30
+ * socket.on("disconnect", () => {
31
+ * console.log(socket.disconnected); // true
32
+ * });
33
+ */
34
+ get disconnected() {
35
+ return !this.connected;
36
+ }
37
+ /**
38
+ * Subscribe to open, close and packet events
39
+ *
40
+ * @private
41
+ */
42
+ subEvents() {
43
+ if (this.subs)
44
+ return;
45
+ const t = this.io;
46
+ this.subs = [c(t, "open", this.onopen.bind(this)), c(t, "packet", this.onpacket.bind(this)), c(t, "error", this.onerror.bind(this)), c(t, "close", this.onclose.bind(this))];
47
+ }
48
+ /**
49
+ * Whether the Socket will try to reconnect when its Manager connects or reconnects.
50
+ *
51
+ * @example
52
+ * const socket = io();
53
+ *
54
+ * console.log(socket.active); // true
55
+ *
56
+ * socket.on("disconnect", (reason) => {
57
+ * if (reason === "io server disconnect") {
58
+ * // the disconnection was initiated by the server, you need to manually reconnect
59
+ * console.log(socket.active); // false
60
+ * }
61
+ * // else the socket will automatically try to reconnect
62
+ * console.log(socket.active); // true
63
+ * });
64
+ */
65
+ get active() {
66
+ return !!this.subs;
67
+ }
68
+ /**
69
+ * "Opens" the socket.
70
+ *
71
+ * @example
72
+ * const socket = io({
73
+ * autoConnect: false
74
+ * });
75
+ *
76
+ * socket.connect();
77
+ */
78
+ connect() {
79
+ return this.connected ? this : (this.subEvents(), this.io._reconnecting || this.io.open(), this.io._readyState === "open" && this.onopen(), this);
80
+ }
81
+ /**
82
+ * Alias for {@link connect()}.
83
+ */
84
+ open() {
85
+ return this.connect();
86
+ }
87
+ /**
88
+ * Sends a `message` event.
89
+ *
90
+ * This method mimics the WebSocket.send() method.
91
+ *
92
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
93
+ *
94
+ * @example
95
+ * socket.send("hello");
96
+ *
97
+ * // this is equivalent to
98
+ * socket.emit("message", "hello");
99
+ *
100
+ * @return self
101
+ */
102
+ send(...t) {
103
+ return t.unshift("message"), this.emit.apply(this, t), this;
104
+ }
105
+ /**
106
+ * Override `emit`.
107
+ * If the event is in `events`, it's emitted normally.
108
+ *
109
+ * @example
110
+ * socket.emit("hello", "world");
111
+ *
112
+ * // all serializable datastructures are supported (no need to call JSON.stringify)
113
+ * socket.emit("hello", 1, "2", { 3: ["4"], 5: Uint8Array.from([6]) });
114
+ *
115
+ * // with an acknowledgement from the server
116
+ * socket.emit("hello", "world", (val) => {
117
+ * // ...
118
+ * });
119
+ *
120
+ * @return self
121
+ */
122
+ emit(t, ...e) {
123
+ if (a.hasOwnProperty(t))
124
+ throw new Error('"' + t.toString() + '" is a reserved event name');
125
+ if (e.unshift(t), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
126
+ return this._addToQueue(e), this;
127
+ const s = {
128
+ type: n.EVENT,
129
+ data: e
130
+ };
131
+ if (s.options = {}, s.options.compress = this.flags.compress !== !1, typeof e[e.length - 1] == "function") {
132
+ const o = this.ids++, r = e.pop();
133
+ this._registerAckCallback(o, r), s.id = o;
134
+ }
135
+ const i = this.io.engine && this.io.engine.transport && this.io.engine.transport.writable;
136
+ return this.flags.volatile && (!i || !this.connected) || (this.connected ? (this.notifyOutgoingListeners(s), this.packet(s)) : this.sendBuffer.push(s)), this.flags = {}, this;
137
+ }
138
+ /**
139
+ * @private
140
+ */
141
+ _registerAckCallback(t, e) {
142
+ var s;
143
+ const i = (s = this.flags.timeout) !== null && s !== void 0 ? s : this._opts.ackTimeout;
144
+ if (i === void 0) {
145
+ this.acks[t] = e;
146
+ return;
147
+ }
148
+ const h = this.io.setTimeoutFn(() => {
149
+ delete this.acks[t];
150
+ for (let r = 0; r < this.sendBuffer.length; r++)
151
+ this.sendBuffer[r].id === t && this.sendBuffer.splice(r, 1);
152
+ e.call(this, new Error("operation has timed out"));
153
+ }, i), o = (...r) => {
154
+ this.io.clearTimeoutFn(h), e.apply(this, r);
155
+ };
156
+ o.withError = !0, this.acks[t] = o;
157
+ }
158
+ /**
159
+ * Emits an event and waits for an acknowledgement
160
+ *
161
+ * @example
162
+ * // without timeout
163
+ * const response = await socket.emitWithAck("hello", "world");
164
+ *
165
+ * // with a specific timeout
166
+ * try {
167
+ * const response = await socket.timeout(1000).emitWithAck("hello", "world");
168
+ * } catch (err) {
169
+ * // the server did not acknowledge the event in the given delay
170
+ * }
171
+ *
172
+ * @return a Promise that will be fulfilled when the server acknowledges the event
173
+ */
174
+ emitWithAck(t, ...e) {
175
+ return new Promise((s, i) => {
176
+ const h = (o, r) => o ? i(o) : s(r);
177
+ h.withError = !0, e.push(h), this.emit(t, ...e);
178
+ });
179
+ }
180
+ /**
181
+ * Add the packet to the queue.
182
+ * @param args
183
+ * @private
184
+ */
185
+ _addToQueue(t) {
186
+ let e;
187
+ typeof t[t.length - 1] == "function" && (e = t.pop());
188
+ const s = {
189
+ id: this._queueSeq++,
190
+ tryCount: 0,
191
+ pending: !1,
192
+ args: t,
193
+ flags: Object.assign({
194
+ fromQueue: !0
195
+ }, this.flags)
196
+ };
197
+ t.push((i, ...h) => s !== this._queue[0] ? void 0 : (i !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), e && e(i)) : (this._queue.shift(), e && e(null, ...h)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
198
+ }
199
+ /**
200
+ * Send the first packet of the queue, and wait for an acknowledgement from the server.
201
+ * @param force - whether to resend a packet that has not been acknowledged yet
202
+ *
203
+ * @private
204
+ */
205
+ _drainQueue(t = !1) {
206
+ if (!this.connected || this._queue.length === 0)
207
+ return;
208
+ const e = this._queue[0];
209
+ e.pending && !t || (e.pending = !0, e.tryCount++, this.flags = e.flags, this.emit.apply(this, e.args));
210
+ }
211
+ /**
212
+ * Sends a packet.
213
+ *
214
+ * @param packet
215
+ * @private
216
+ */
217
+ packet(t) {
218
+ t.nsp = this.nsp, this.io._packet(t);
219
+ }
220
+ /**
221
+ * Called upon engine `open`.
222
+ *
223
+ * @private
224
+ */
225
+ onopen() {
226
+ typeof this.auth == "function" ? this.auth((t) => {
227
+ this._sendConnectPacket(t);
228
+ }) : this._sendConnectPacket(this.auth);
229
+ }
230
+ /**
231
+ * Sends a CONNECT packet to initiate the Socket.IO session.
232
+ *
233
+ * @param data
234
+ * @private
235
+ */
236
+ _sendConnectPacket(t) {
237
+ this.packet({
238
+ type: n.CONNECT,
239
+ data: this._pid ? Object.assign({
240
+ pid: this._pid,
241
+ offset: this._lastOffset
242
+ }, t) : t
243
+ });
244
+ }
245
+ /**
246
+ * Called upon engine or manager `error`.
247
+ *
248
+ * @param err
249
+ * @private
250
+ */
251
+ onerror(t) {
252
+ this.connected || this.emitReserved("connect_error", t);
253
+ }
254
+ /**
255
+ * Called upon engine `close`.
256
+ *
257
+ * @param reason
258
+ * @param description
259
+ * @private
260
+ */
261
+ onclose(t, e) {
262
+ this.connected = !1, delete this.id, this.emitReserved("disconnect", t, e), this._clearAcks();
263
+ }
264
+ /**
265
+ * Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
266
+ * the server.
267
+ *
268
+ * @private
269
+ */
270
+ _clearAcks() {
271
+ Object.keys(this.acks).forEach((t) => {
272
+ if (!this.sendBuffer.some((s) => String(s.id) === t)) {
273
+ const s = this.acks[t];
274
+ delete this.acks[t], s.withError && s.call(this, new Error("socket has been disconnected"));
275
+ }
276
+ });
277
+ }
278
+ /**
279
+ * Called with socket packet.
280
+ *
281
+ * @param packet
282
+ * @private
283
+ */
284
+ onpacket(t) {
285
+ if (t.nsp === this.nsp)
286
+ switch (t.type) {
287
+ case n.CONNECT:
288
+ t.data && t.data.sid ? this.onconnect(t.data.sid, t.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
289
+ break;
290
+ case n.EVENT:
291
+ case n.BINARY_EVENT:
292
+ this.onevent(t);
293
+ break;
294
+ case n.ACK:
295
+ case n.BINARY_ACK:
296
+ this.onack(t);
297
+ break;
298
+ case n.DISCONNECT:
299
+ this.ondisconnect();
300
+ break;
301
+ case n.CONNECT_ERROR:
302
+ this.destroy();
303
+ const s = new Error(t.data.message);
304
+ s.data = t.data.data, this.emitReserved("connect_error", s);
305
+ break;
306
+ }
307
+ }
308
+ /**
309
+ * Called upon a server event.
310
+ *
311
+ * @param packet
312
+ * @private
313
+ */
314
+ onevent(t) {
315
+ const e = t.data || [];
316
+ t.id != null && e.push(this.ack(t.id)), this.connected ? this.emitEvent(e) : this.receiveBuffer.push(Object.freeze(e));
317
+ }
318
+ emitEvent(t) {
319
+ if (this._anyListeners && this._anyListeners.length) {
320
+ const e = this._anyListeners.slice();
321
+ for (const s of e)
322
+ s.apply(this, t);
323
+ }
324
+ super.emit.apply(this, t), this._pid && t.length && typeof t[t.length - 1] == "string" && (this._lastOffset = t[t.length - 1]);
325
+ }
326
+ /**
327
+ * Produces an ack callback to emit with an event.
328
+ *
329
+ * @private
330
+ */
331
+ ack(t) {
332
+ const e = this;
333
+ let s = !1;
334
+ return function(...i) {
335
+ s || (s = !0, e.packet({
336
+ type: n.ACK,
337
+ id: t,
338
+ data: i
339
+ }));
340
+ };
341
+ }
342
+ /**
343
+ * Called upon a server acknowledgement.
344
+ *
345
+ * @param packet
346
+ * @private
347
+ */
348
+ onack(t) {
349
+ const e = this.acks[t.id];
350
+ typeof e == "function" && (delete this.acks[t.id], e.withError && t.data.unshift(null), e.apply(this, t.data));
351
+ }
352
+ /**
353
+ * Called upon server connect.
354
+ *
355
+ * @private
356
+ */
357
+ onconnect(t, e) {
358
+ this.id = t, this.recovered = e && this._pid === e, this._pid = e, this.connected = !0, this.emitBuffered(), this.emitReserved("connect"), this._drainQueue(!0);
359
+ }
360
+ /**
361
+ * Emit buffered events (received and emitted).
362
+ *
363
+ * @private
364
+ */
365
+ emitBuffered() {
366
+ this.receiveBuffer.forEach((t) => this.emitEvent(t)), this.receiveBuffer = [], this.sendBuffer.forEach((t) => {
367
+ this.notifyOutgoingListeners(t), this.packet(t);
368
+ }), this.sendBuffer = [];
369
+ }
370
+ /**
371
+ * Called upon server disconnect.
372
+ *
373
+ * @private
374
+ */
375
+ ondisconnect() {
376
+ this.destroy(), this.onclose("io server disconnect");
377
+ }
378
+ /**
379
+ * Called upon forced client/server side disconnections,
380
+ * this method ensures the manager stops tracking us and
381
+ * that reconnections don't get triggered for this.
382
+ *
383
+ * @private
384
+ */
385
+ destroy() {
386
+ this.subs && (this.subs.forEach((t) => t()), this.subs = void 0), this.io._destroy(this);
387
+ }
388
+ /**
389
+ * Disconnects the socket manually. In that case, the socket will not try to reconnect.
390
+ *
391
+ * If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.
392
+ *
393
+ * @example
394
+ * const socket = io();
395
+ *
396
+ * socket.on("disconnect", (reason) => {
397
+ * // console.log(reason); prints "io client disconnect"
398
+ * });
399
+ *
400
+ * socket.disconnect();
401
+ *
402
+ * @return self
403
+ */
404
+ disconnect() {
405
+ return this.connected && this.packet({
406
+ type: n.DISCONNECT
407
+ }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
408
+ }
409
+ /**
410
+ * Alias for {@link disconnect()}.
411
+ *
412
+ * @return self
413
+ */
414
+ close() {
415
+ return this.disconnect();
416
+ }
417
+ /**
418
+ * Sets the compress flag.
419
+ *
420
+ * @example
421
+ * socket.compress(false).emit("hello");
422
+ *
423
+ * @param compress - if `true`, compresses the sending data
424
+ * @return self
425
+ */
426
+ compress(t) {
427
+ return this.flags.compress = t, this;
428
+ }
429
+ /**
430
+ * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
431
+ * ready to send messages.
432
+ *
433
+ * @example
434
+ * socket.volatile.emit("hello"); // the server may or may not receive it
435
+ *
436
+ * @returns self
437
+ */
438
+ get volatile() {
439
+ return this.flags.volatile = !0, this;
440
+ }
441
+ /**
442
+ * Sets a modifier for a subsequent event emission that the callback will be called with an error when the
443
+ * given number of milliseconds have elapsed without an acknowledgement from the server:
444
+ *
445
+ * @example
446
+ * socket.timeout(5000).emit("my-event", (err) => {
447
+ * if (err) {
448
+ * // the server did not acknowledge the event in the given delay
449
+ * }
450
+ * });
451
+ *
452
+ * @returns self
453
+ */
454
+ timeout(t) {
455
+ return this.flags.timeout = t, this;
456
+ }
457
+ /**
458
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
459
+ * callback.
460
+ *
461
+ * @example
462
+ * socket.onAny((event, ...args) => {
463
+ * console.log(`got ${event}`);
464
+ * });
465
+ *
466
+ * @param listener
467
+ */
468
+ onAny(t) {
469
+ return this._anyListeners = this._anyListeners || [], this._anyListeners.push(t), this;
470
+ }
471
+ /**
472
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
473
+ * callback. The listener is added to the beginning of the listeners array.
474
+ *
475
+ * @example
476
+ * socket.prependAny((event, ...args) => {
477
+ * console.log(`got event ${event}`);
478
+ * });
479
+ *
480
+ * @param listener
481
+ */
482
+ prependAny(t) {
483
+ return this._anyListeners = this._anyListeners || [], this._anyListeners.unshift(t), this;
484
+ }
485
+ /**
486
+ * Removes the listener that will be fired when any event is emitted.
487
+ *
488
+ * @example
489
+ * const catchAllListener = (event, ...args) => {
490
+ * console.log(`got event ${event}`);
491
+ * }
492
+ *
493
+ * socket.onAny(catchAllListener);
494
+ *
495
+ * // remove a specific listener
496
+ * socket.offAny(catchAllListener);
497
+ *
498
+ * // or remove all listeners
499
+ * socket.offAny();
500
+ *
501
+ * @param listener
502
+ */
503
+ offAny(t) {
504
+ if (!this._anyListeners)
505
+ return this;
506
+ if (t) {
507
+ const e = this._anyListeners;
508
+ for (let s = 0; s < e.length; s++)
509
+ if (t === e[s])
510
+ return e.splice(s, 1), this;
511
+ } else
512
+ this._anyListeners = [];
513
+ return this;
514
+ }
515
+ /**
516
+ * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
517
+ * e.g. to remove listeners.
518
+ */
519
+ listenersAny() {
520
+ return this._anyListeners || [];
521
+ }
522
+ /**
523
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
524
+ * callback.
525
+ *
526
+ * Note: acknowledgements sent to the server are not included.
527
+ *
528
+ * @example
529
+ * socket.onAnyOutgoing((event, ...args) => {
530
+ * console.log(`sent event ${event}`);
531
+ * });
532
+ *
533
+ * @param listener
534
+ */
535
+ onAnyOutgoing(t) {
536
+ return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.push(t), this;
537
+ }
538
+ /**
539
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
540
+ * callback. The listener is added to the beginning of the listeners array.
541
+ *
542
+ * Note: acknowledgements sent to the server are not included.
543
+ *
544
+ * @example
545
+ * socket.prependAnyOutgoing((event, ...args) => {
546
+ * console.log(`sent event ${event}`);
547
+ * });
548
+ *
549
+ * @param listener
550
+ */
551
+ prependAnyOutgoing(t) {
552
+ return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.unshift(t), this;
553
+ }
554
+ /**
555
+ * Removes the listener that will be fired when any event is emitted.
556
+ *
557
+ * @example
558
+ * const catchAllListener = (event, ...args) => {
559
+ * console.log(`sent event ${event}`);
560
+ * }
561
+ *
562
+ * socket.onAnyOutgoing(catchAllListener);
563
+ *
564
+ * // remove a specific listener
565
+ * socket.offAnyOutgoing(catchAllListener);
566
+ *
567
+ * // or remove all listeners
568
+ * socket.offAnyOutgoing();
569
+ *
570
+ * @param [listener] - the catch-all listener (optional)
571
+ */
572
+ offAnyOutgoing(t) {
573
+ if (!this._anyOutgoingListeners)
574
+ return this;
575
+ if (t) {
576
+ const e = this._anyOutgoingListeners;
577
+ for (let s = 0; s < e.length; s++)
578
+ if (t === e[s])
579
+ return e.splice(s, 1), this;
580
+ } else
581
+ this._anyOutgoingListeners = [];
582
+ return this;
583
+ }
584
+ /**
585
+ * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
586
+ * e.g. to remove listeners.
587
+ */
588
+ listenersAnyOutgoing() {
589
+ return this._anyOutgoingListeners || [];
590
+ }
591
+ /**
592
+ * Notify the listeners for each packet sent
593
+ *
594
+ * @param packet
595
+ *
596
+ * @private
597
+ */
598
+ notifyOutgoingListeners(t) {
599
+ if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
600
+ const e = this._anyOutgoingListeners.slice();
601
+ for (const s of e)
602
+ s.apply(this, t.data);
603
+ }
604
+ }
605
+ }
606
+ export {
607
+ g as Socket
608
+ };
@@ -0,0 +1,19 @@
1
+ import "../../../engine.io-client/build/esm/socket.mjs";
2
+ import "../../../engine.io-parser/build/esm/encodePacket.browser.mjs";
3
+ import "../../../engine.io-parser/build/esm/commons.mjs";
4
+ import "../../../engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs";
5
+ import "../../../@socket.io/component-emitter/lib/esm/index.mjs";
6
+ import "../../../engine.io-client/build/esm/util.mjs";
7
+ import "../../../engine.io-client/build/esm/transports/polling.mjs";
8
+ import "../../../engine.io-client/build/esm/transports/websocket.mjs";
9
+ import "../../../engine.io-client/build/esm/transports/websocket-constructor.browser.mjs";
10
+ import { parse as r } from "../../../engine.io-client/build/esm/contrib/parseuri.mjs";
11
+ function v(o, e = "", p) {
12
+ let t = o;
13
+ p = p || typeof location != "undefined" && location, o == null && (o = p.protocol + "//" + p.host), typeof o == "string" && (o.charAt(0) === "/" && (o.charAt(1) === "/" ? o = p.protocol + o : o = p.host + o), /^(https?|wss?):\/\//.test(o) || (typeof p != "undefined" ? o = p.protocol + "//" + o : o = "https://" + o), t = r(o)), t.port || (/^(http|ws)$/.test(t.protocol) ? t.port = "80" : /^(http|ws)s$/.test(t.protocol) && (t.port = "443")), t.path = t.path || "/";
14
+ const s = t.host.indexOf(":") !== -1 ? "[" + t.host + "]" : t.host;
15
+ return t.id = t.protocol + "://" + s + ":" + t.port + e, t.href = t.protocol + "://" + s + (p && p.port === t.port ? "" : ":" + t.port), t;
16
+ }
17
+ export {
18
+ v as url
19
+ };
@@ -0,0 +1,52 @@
1
+ import { isBinary as i } from "./is-binary.mjs";
2
+ function s(e) {
3
+ const r = [], n = e.data, t = e;
4
+ return t.data = o(n, r), t.attachments = r.length, {
5
+ packet: t,
6
+ buffers: r
7
+ };
8
+ }
9
+ function o(e, r) {
10
+ if (!e)
11
+ return e;
12
+ if (i(e)) {
13
+ const n = {
14
+ _placeholder: !0,
15
+ num: r.length
16
+ };
17
+ return r.push(e), n;
18
+ } else if (Array.isArray(e)) {
19
+ const n = new Array(e.length);
20
+ for (let t = 0; t < e.length; t++)
21
+ n[t] = o(e[t], r);
22
+ return n;
23
+ } else if (typeof e == "object" && !(e instanceof Date)) {
24
+ const n = {};
25
+ for (const t in e)
26
+ Object.prototype.hasOwnProperty.call(e, t) && (n[t] = o(e[t], r));
27
+ return n;
28
+ }
29
+ return e;
30
+ }
31
+ function u(e, r) {
32
+ return e.data = c(e.data, r), delete e.attachments, e;
33
+ }
34
+ function c(e, r) {
35
+ if (!e)
36
+ return e;
37
+ if (e && e._placeholder === !0) {
38
+ if (typeof e.num == "number" && e.num >= 0 && e.num < r.length)
39
+ return r[e.num];
40
+ throw new Error("illegal attachments");
41
+ } else if (Array.isArray(e))
42
+ for (let n = 0; n < e.length; n++)
43
+ e[n] = c(e[n], r);
44
+ else if (typeof e == "object")
45
+ for (const n in e)
46
+ Object.prototype.hasOwnProperty.call(e, n) && (e[n] = c(e[n], r));
47
+ return e;
48
+ }
49
+ export {
50
+ s as deconstructPacket,
51
+ u as reconstructPacket
52
+ };