@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.
- package/README.md +70 -0
- package/dist/agent-cli-sdk.js +34975 -0
- package/dist/agent-cli-sdk.umd.cjs +150 -0
- package/dist/cdn/agent-cli-sdk.js +32945 -0
- package/dist/cdn/agent-cli-sdk.umd.cjs +140 -0
- package/dist/cdn/src/AgentPlugin.d.ts +17 -0
- package/dist/cdn/src/AgentSession.d.ts +8 -0
- package/dist/cdn/src/BotClient.d.ts +46 -0
- package/dist/cdn/src/Config.d.ts +32 -0
- package/dist/cdn/src/DialogSession.d.ts +21 -0
- package/dist/cdn/src/EventBus.d.ts +23 -0
- package/dist/cdn/src/Logger.d.ts +12 -0
- package/dist/cdn/src/PayloadTypes.d.ts +84 -0
- package/dist/cdn/src/Session.d.ts +156 -0
- package/dist/cdn/src/__ tests __/AgentClient.spec.d.ts +1 -0
- package/dist/cdn/src/__ tests __/AgentSession.spec.d.ts +1 -0
- package/dist/cdn/src/__ tests __/DialogClient.spec.d.ts +1 -0
- package/dist/cdn/src/api/fetchEventSource/fetch.d.ts +44 -0
- package/dist/cdn/src/api/fetchEventSource/index.d.ts +1 -0
- package/dist/cdn/src/api/fetchEventSource/parse.d.ts +36 -0
- package/dist/cdn/src/api/index.d.ts +2 -0
- package/dist/cdn/src/index.d.ts +5 -0
- package/dist/cdn/src/utils.d.ts +4 -0
- package/dist/es/AgentPlugin.mjs +20 -0
- package/dist/es/AgentSession.mjs +243 -0
- package/dist/es/BotClient.mjs +242 -0
- package/dist/es/Config.mjs +34 -0
- package/dist/es/DialogSession.mjs +281 -0
- package/dist/es/EventBus.mjs +64 -0
- package/dist/es/Logger.mjs +31 -0
- package/dist/es/PayloadTypes.mjs +4 -0
- package/dist/es/Session.mjs +527 -0
- package/dist/es/_virtual/_commonjsHelpers.mjs +4 -0
- package/dist/es/_virtual/index.mjs +4 -0
- package/dist/es/_virtual/index2.mjs +4 -0
- package/dist/es/_virtual/index3.mjs +4 -0
- package/dist/es/_virtual/minio-zj.mjs +4 -0
- package/dist/es/api/fetchEventSource/fetch.mjs +112 -0
- package/dist/es/api/fetchEventSource/parse.mjs +97 -0
- package/dist/es/api/index.mjs +48 -0
- package/dist/es/index.mjs +11 -0
- package/dist/es/node_modules/@glodon-aiot/minio/dist/minio-zj.mjs +26485 -0
- package/dist/es/node_modules/@socket.io/component-emitter/lib/esm/index.mjs +54 -0
- package/dist/es/node_modules/base64-js/index.mjs +47 -0
- package/dist/es/node_modules/buffer/index.mjs +927 -0
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/has-cors.mjs +9 -0
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseqs.mjs +18 -0
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseuri.mjs +24 -0
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/yeast.mjs +19 -0
- package/dist/es/node_modules/engine.io-client/build/esm/globalThis.browser.mjs +4 -0
- package/dist/es/node_modules/engine.io-client/build/esm/socket.mjs +317 -0
- package/dist/es/node_modules/engine.io-client/build/esm/transport.mjs +113 -0
- package/dist/es/node_modules/engine.io-client/build/esm/transports/index.mjs +11 -0
- package/dist/es/node_modules/engine.io-client/build/esm/transports/polling.mjs +273 -0
- package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs +8 -0
- package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket.mjs +87 -0
- package/dist/es/node_modules/engine.io-client/build/esm/transports/webtransport.mjs +52 -0
- package/dist/es/node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.mjs +21 -0
- package/dist/es/node_modules/engine.io-client/build/esm/util.mjs +23 -0
- package/dist/es/node_modules/engine.io-parser/build/esm/commons.mjs +21 -0
- package/dist/es/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs +14 -0
- package/dist/es/node_modules/engine.io-parser/build/esm/decodePacket.browser.mjs +39 -0
- package/dist/es/node_modules/engine.io-parser/build/esm/encodePacket.browser.mjs +28 -0
- package/dist/es/node_modules/engine.io-parser/build/esm/index.mjs +105 -0
- package/dist/es/node_modules/ieee754/index.mjs +28 -0
- package/dist/es/node_modules/js-base64/base64.mjs +31 -0
- package/dist/es/node_modules/socket.io-client/build/esm/contrib/backo2.mjs +26 -0
- package/dist/es/node_modules/socket.io-client/build/esm/index.mjs +25 -0
- package/dist/es/node_modules/socket.io-client/build/esm/manager.mjs +242 -0
- package/dist/es/node_modules/socket.io-client/build/esm/on.mjs +8 -0
- package/dist/es/node_modules/socket.io-client/build/esm/socket.mjs +608 -0
- package/dist/es/node_modules/socket.io-client/build/esm/url.mjs +19 -0
- package/dist/es/node_modules/socket.io-parser/build/esm/binary.mjs +52 -0
- package/dist/es/node_modules/socket.io-parser/build/esm/index.mjs +203 -0
- package/dist/es/node_modules/socket.io-parser/build/esm/is-binary.mjs +26 -0
- package/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +6 -0
- package/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +10 -0
- package/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +9 -0
- package/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +19 -0
- package/dist/es/packages/apis/dist/es/aecpilot/model.mjs +4 -0
- package/dist/es/packages/apis/dist/es/aecpilotui/index.mjs +8 -0
- package/dist/es/packages/apis/dist/es/agentcliui/index.mjs +8 -0
- package/dist/es/packages/apis/dist/es/base/index.mjs +154 -0
- package/dist/es/packages/apis/dist/es/cvforce/index.mjs +431 -0
- package/dist/es/packages/apis/dist/es/cvforce/model.mjs +5 -0
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +1 -0
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +3 -0
- package/dist/es/utils.mjs +11 -0
- package/dist/lib/index.js +126 -0
- package/dist/src/AgentPlugin.d.ts +17 -0
- package/dist/src/AgentSession.d.ts +8 -0
- package/dist/src/BotClient.d.ts +46 -0
- package/dist/src/Config.d.ts +32 -0
- package/dist/src/DialogSession.d.ts +21 -0
- package/dist/src/EventBus.d.ts +23 -0
- package/dist/src/Logger.d.ts +12 -0
- package/dist/src/PayloadTypes.d.ts +84 -0
- package/dist/src/Session.d.ts +155 -0
- package/dist/src/__ tests __/AgentClient.spec.d.ts +1 -0
- package/dist/src/__ tests __/AgentSession.spec.d.ts +1 -0
- package/dist/src/__ tests __/DialogClient.spec.d.ts +1 -0
- package/dist/src/api/fetchEventSource/fetch.d.ts +44 -0
- package/dist/src/api/fetchEventSource/index.d.ts +1 -0
- package/dist/src/api/fetchEventSource/parse.d.ts +36 -0
- package/dist/src/api/index.d.ts +2 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/utils.d.ts +4 -0
- package/package.json +102 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { Transport as d } from "../transport.mjs";
|
|
2
|
+
import { yeast as l } from "../contrib/yeast.mjs";
|
|
3
|
+
import { decodePayload as c, encodePayload as p } from "../../../../engine.io-parser/build/esm/index.mjs";
|
|
4
|
+
import { XHR as a, createCookieJar as u } from "./xmlhttprequest.browser.mjs";
|
|
5
|
+
import { Emitter as f } from "../../../../@socket.io/component-emitter/lib/esm/index.mjs";
|
|
6
|
+
import { installTimerFunctions as m, pick as y } from "../util.mjs";
|
|
7
|
+
import { globalThisShim as x } from "../globalThis.browser.mjs";
|
|
8
|
+
function q() {
|
|
9
|
+
}
|
|
10
|
+
const v = function() {
|
|
11
|
+
return new a({
|
|
12
|
+
xdomain: !1
|
|
13
|
+
}).responseType != null;
|
|
14
|
+
}();
|
|
15
|
+
class S extends d {
|
|
16
|
+
/**
|
|
17
|
+
* XHR Polling constructor.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} opts
|
|
20
|
+
* @package
|
|
21
|
+
*/
|
|
22
|
+
constructor(t) {
|
|
23
|
+
if (super(t), this.polling = !1, typeof location != "undefined") {
|
|
24
|
+
const e = location.protocol === "https:";
|
|
25
|
+
let i = location.port;
|
|
26
|
+
i || (i = e ? "443" : "80"), this.xd = typeof location != "undefined" && t.hostname !== location.hostname || i !== t.port;
|
|
27
|
+
}
|
|
28
|
+
const s = t && t.forceBase64;
|
|
29
|
+
this.supportsBinary = v && !s, this.opts.withCredentials && (this.cookieJar = u());
|
|
30
|
+
}
|
|
31
|
+
get name() {
|
|
32
|
+
return "polling";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Opens the socket (triggers polling). We write a PING message to determine
|
|
36
|
+
* when the transport is open.
|
|
37
|
+
*
|
|
38
|
+
* @protected
|
|
39
|
+
*/
|
|
40
|
+
doOpen() {
|
|
41
|
+
this.poll();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Pauses polling.
|
|
45
|
+
*
|
|
46
|
+
* @param {Function} onPause - callback upon buffers are flushed and transport is paused
|
|
47
|
+
* @package
|
|
48
|
+
*/
|
|
49
|
+
pause(t) {
|
|
50
|
+
this.readyState = "pausing";
|
|
51
|
+
const s = () => {
|
|
52
|
+
this.readyState = "paused", t();
|
|
53
|
+
};
|
|
54
|
+
if (this.polling || !this.writable) {
|
|
55
|
+
let e = 0;
|
|
56
|
+
this.polling && (e++, this.once("pollComplete", function() {
|
|
57
|
+
--e || s();
|
|
58
|
+
})), this.writable || (e++, this.once("drain", function() {
|
|
59
|
+
--e || s();
|
|
60
|
+
}));
|
|
61
|
+
} else
|
|
62
|
+
s();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Starts polling cycle.
|
|
66
|
+
*
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
poll() {
|
|
70
|
+
this.polling = !0, this.doPoll(), this.emitReserved("poll");
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Overloads onData to detect payloads.
|
|
74
|
+
*
|
|
75
|
+
* @protected
|
|
76
|
+
*/
|
|
77
|
+
onData(t) {
|
|
78
|
+
const s = (e) => {
|
|
79
|
+
if (this.readyState === "opening" && e.type === "open" && this.onOpen(), e.type === "close")
|
|
80
|
+
return this.onClose({
|
|
81
|
+
description: "transport closed by the server"
|
|
82
|
+
}), !1;
|
|
83
|
+
this.onPacket(e);
|
|
84
|
+
};
|
|
85
|
+
c(t, this.socket.binaryType).forEach(s), this.readyState !== "closed" && (this.polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this.poll());
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* For polling, send a close packet.
|
|
89
|
+
*
|
|
90
|
+
* @protected
|
|
91
|
+
*/
|
|
92
|
+
doClose() {
|
|
93
|
+
const t = () => {
|
|
94
|
+
this.write([{
|
|
95
|
+
type: "close"
|
|
96
|
+
}]);
|
|
97
|
+
};
|
|
98
|
+
this.readyState === "open" ? t() : this.once("open", t);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Writes a packets payload.
|
|
102
|
+
*
|
|
103
|
+
* @param {Array} packets - data packets
|
|
104
|
+
* @protected
|
|
105
|
+
*/
|
|
106
|
+
write(t) {
|
|
107
|
+
this.writable = !1, p(t, (s) => {
|
|
108
|
+
this.doWrite(s, () => {
|
|
109
|
+
this.writable = !0, this.emitReserved("drain");
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Generates uri for connection.
|
|
115
|
+
*
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
118
|
+
uri() {
|
|
119
|
+
const t = this.opts.secure ? "https" : "http", s = this.query || {};
|
|
120
|
+
return this.opts.timestampRequests !== !1 && (s[this.opts.timestampParam] = l()), !this.supportsBinary && !s.sid && (s.b64 = 1), this.createUri(t, s);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Creates a request.
|
|
124
|
+
*
|
|
125
|
+
* @param {String} method
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
128
|
+
request(t = {}) {
|
|
129
|
+
return Object.assign(t, {
|
|
130
|
+
xd: this.xd,
|
|
131
|
+
cookieJar: this.cookieJar
|
|
132
|
+
}, this.opts), new o(this.uri(), t);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Sends data.
|
|
136
|
+
*
|
|
137
|
+
* @param {String} data to send.
|
|
138
|
+
* @param {Function} called upon flush.
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
doWrite(t, s) {
|
|
142
|
+
const e = this.request({
|
|
143
|
+
method: "POST",
|
|
144
|
+
data: t
|
|
145
|
+
});
|
|
146
|
+
e.on("success", s), e.on("error", (i, h) => {
|
|
147
|
+
this.onError("xhr post error", i, h);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Starts a poll cycle.
|
|
152
|
+
*
|
|
153
|
+
* @private
|
|
154
|
+
*/
|
|
155
|
+
doPoll() {
|
|
156
|
+
const t = this.request();
|
|
157
|
+
t.on("data", this.onData.bind(this)), t.on("error", (s, e) => {
|
|
158
|
+
this.onError("xhr poll error", s, e);
|
|
159
|
+
}), this.pollXhr = t;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
class o extends f {
|
|
163
|
+
/**
|
|
164
|
+
* Request constructor
|
|
165
|
+
*
|
|
166
|
+
* @param {Object} options
|
|
167
|
+
* @package
|
|
168
|
+
*/
|
|
169
|
+
constructor(t, s) {
|
|
170
|
+
super(), m(this, s), this.opts = s, this.method = s.method || "GET", this.uri = t, this.data = s.data !== void 0 ? s.data : null, this.create();
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Creates the XHR object and sends the request.
|
|
174
|
+
*
|
|
175
|
+
* @private
|
|
176
|
+
*/
|
|
177
|
+
create() {
|
|
178
|
+
var t;
|
|
179
|
+
const s = y(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
180
|
+
s.xdomain = !!this.opts.xd;
|
|
181
|
+
const e = this.xhr = new a(s);
|
|
182
|
+
try {
|
|
183
|
+
e.open(this.method, this.uri, !0);
|
|
184
|
+
try {
|
|
185
|
+
if (this.opts.extraHeaders) {
|
|
186
|
+
e.setDisableHeaderCheck && e.setDisableHeaderCheck(!0);
|
|
187
|
+
for (let i in this.opts.extraHeaders)
|
|
188
|
+
this.opts.extraHeaders.hasOwnProperty(i) && e.setRequestHeader(i, this.opts.extraHeaders[i]);
|
|
189
|
+
}
|
|
190
|
+
} catch (i) {
|
|
191
|
+
}
|
|
192
|
+
if (this.method === "POST")
|
|
193
|
+
try {
|
|
194
|
+
e.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
|
|
195
|
+
} catch (i) {
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
e.setRequestHeader("Accept", "*/*");
|
|
199
|
+
} catch (i) {
|
|
200
|
+
}
|
|
201
|
+
(t = this.opts.cookieJar) === null || t === void 0 || t.addCookies(e), "withCredentials" in e && (e.withCredentials = this.opts.withCredentials), this.opts.requestTimeout && (e.timeout = this.opts.requestTimeout), e.onreadystatechange = () => {
|
|
202
|
+
var i;
|
|
203
|
+
e.readyState === 3 && ((i = this.opts.cookieJar) === null || i === void 0 || i.parseCookies(e)), e.readyState === 4 && (e.status === 200 || e.status === 1223 ? this.onLoad() : this.setTimeoutFn(() => {
|
|
204
|
+
this.onError(typeof e.status == "number" ? e.status : 0);
|
|
205
|
+
}, 0));
|
|
206
|
+
}, e.send(this.data);
|
|
207
|
+
} catch (i) {
|
|
208
|
+
this.setTimeoutFn(() => {
|
|
209
|
+
this.onError(i);
|
|
210
|
+
}, 0);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
typeof document != "undefined" && (this.index = o.requestsCount++, o.requests[this.index] = this);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Called upon error.
|
|
217
|
+
*
|
|
218
|
+
* @private
|
|
219
|
+
*/
|
|
220
|
+
onError(t) {
|
|
221
|
+
this.emitReserved("error", t, this.xhr), this.cleanup(!0);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Cleans up house.
|
|
225
|
+
*
|
|
226
|
+
* @private
|
|
227
|
+
*/
|
|
228
|
+
cleanup(t) {
|
|
229
|
+
if (!(typeof this.xhr == "undefined" || this.xhr === null)) {
|
|
230
|
+
if (this.xhr.onreadystatechange = q, t)
|
|
231
|
+
try {
|
|
232
|
+
this.xhr.abort();
|
|
233
|
+
} catch (s) {
|
|
234
|
+
}
|
|
235
|
+
typeof document != "undefined" && delete o.requests[this.index], this.xhr = null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Called upon load.
|
|
240
|
+
*
|
|
241
|
+
* @private
|
|
242
|
+
*/
|
|
243
|
+
onLoad() {
|
|
244
|
+
const t = this.xhr.responseText;
|
|
245
|
+
t !== null && (this.emitReserved("data", t), this.emitReserved("success"), this.cleanup());
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Aborts the request.
|
|
249
|
+
*
|
|
250
|
+
* @package
|
|
251
|
+
*/
|
|
252
|
+
abort() {
|
|
253
|
+
this.cleanup();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
o.requestsCount = 0;
|
|
257
|
+
o.requests = {};
|
|
258
|
+
if (typeof document != "undefined") {
|
|
259
|
+
if (typeof attachEvent == "function")
|
|
260
|
+
attachEvent("onunload", n);
|
|
261
|
+
else if (typeof addEventListener == "function") {
|
|
262
|
+
const r = "onpagehide" in x ? "pagehide" : "unload";
|
|
263
|
+
addEventListener(r, n, !1);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function n() {
|
|
267
|
+
for (let r in o.requests)
|
|
268
|
+
o.requests.hasOwnProperty(r) && o.requests[r].abort();
|
|
269
|
+
}
|
|
270
|
+
export {
|
|
271
|
+
S as Polling,
|
|
272
|
+
o as Request
|
|
273
|
+
};
|
package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { globalThisShim as o } from "../globalThis.browser.mjs";
|
|
2
|
+
const s = (() => typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, r) => r(e, 0))(), n = o.WebSocket || o.MozWebSocket, c = !0, l = "arraybuffer";
|
|
3
|
+
export {
|
|
4
|
+
n as WebSocket,
|
|
5
|
+
l as defaultBinaryType,
|
|
6
|
+
s as nextTick,
|
|
7
|
+
c as usingBrowserWebSocket
|
|
8
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Transport as c } from "../transport.mjs";
|
|
2
|
+
import { yeast as h } from "../contrib/yeast.mjs";
|
|
3
|
+
import { pick as p } from "../util.mjs";
|
|
4
|
+
import { usingBrowserWebSocket as i, WebSocket as r, nextTick as d } from "./websocket-constructor.browser.mjs";
|
|
5
|
+
import { encodePacket as u } from "../../../../engine.io-parser/build/esm/encodePacket.browser.mjs";
|
|
6
|
+
import "../../../../engine.io-parser/build/esm/commons.mjs";
|
|
7
|
+
import "../../../../engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs";
|
|
8
|
+
const n = typeof navigator != "undefined" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
9
|
+
class B extends c {
|
|
10
|
+
/**
|
|
11
|
+
* WebSocket transport constructor.
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} opts - connection options
|
|
14
|
+
* @protected
|
|
15
|
+
*/
|
|
16
|
+
constructor(t) {
|
|
17
|
+
super(t), this.supportsBinary = !t.forceBase64;
|
|
18
|
+
}
|
|
19
|
+
get name() {
|
|
20
|
+
return "websocket";
|
|
21
|
+
}
|
|
22
|
+
doOpen() {
|
|
23
|
+
if (!this.check())
|
|
24
|
+
return;
|
|
25
|
+
const t = this.uri(), e = this.opts.protocols, s = n ? {} : p(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
26
|
+
this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
|
|
27
|
+
try {
|
|
28
|
+
this.ws = i && !n ? e ? new r(t, e) : new r(t) : new r(t, e, s);
|
|
29
|
+
} catch (o) {
|
|
30
|
+
return this.emitReserved("error", o);
|
|
31
|
+
}
|
|
32
|
+
this.ws.binaryType = this.socket.binaryType, this.addEventListeners();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Adds event listeners to the socket
|
|
36
|
+
*
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
addEventListeners() {
|
|
40
|
+
this.ws.onopen = () => {
|
|
41
|
+
this.opts.autoUnref && this.ws._socket.unref(), this.onOpen();
|
|
42
|
+
}, this.ws.onclose = (t) => this.onClose({
|
|
43
|
+
description: "websocket connection closed",
|
|
44
|
+
context: t
|
|
45
|
+
}), this.ws.onmessage = (t) => this.onData(t.data), this.ws.onerror = (t) => this.onError("websocket error", t);
|
|
46
|
+
}
|
|
47
|
+
write(t) {
|
|
48
|
+
this.writable = !1;
|
|
49
|
+
for (let e = 0; e < t.length; e++) {
|
|
50
|
+
const s = t[e], o = e === t.length - 1;
|
|
51
|
+
u(s, this.supportsBinary, (a) => {
|
|
52
|
+
const m = {};
|
|
53
|
+
try {
|
|
54
|
+
i && this.ws.send(a);
|
|
55
|
+
} catch (w) {
|
|
56
|
+
}
|
|
57
|
+
o && d(() => {
|
|
58
|
+
this.writable = !0, this.emitReserved("drain");
|
|
59
|
+
}, this.setTimeoutFn);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
doClose() {
|
|
64
|
+
typeof this.ws != "undefined" && (this.ws.close(), this.ws = null);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generates uri for connection.
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
uri() {
|
|
72
|
+
const t = this.opts.secure ? "wss" : "ws", e = this.query || {};
|
|
73
|
+
return this.opts.timestampRequests && (e[this.opts.timestampParam] = h()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Feature detection for WebSocket.
|
|
77
|
+
*
|
|
78
|
+
* @return {Boolean} whether this transport is available.
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
check() {
|
|
82
|
+
return !!r;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
B as WS
|
|
87
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Transport as h } from "../transport.mjs";
|
|
2
|
+
import { nextTick as c } from "./websocket-constructor.browser.mjs";
|
|
3
|
+
import { createPacketDecoderStream as p, createPacketEncoderStream as d } from "../../../../engine.io-parser/build/esm/index.mjs";
|
|
4
|
+
class f extends h {
|
|
5
|
+
get name() {
|
|
6
|
+
return "webtransport";
|
|
7
|
+
}
|
|
8
|
+
doOpen() {
|
|
9
|
+
typeof WebTransport == "function" && (this.transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]), this.transport.closed.then(() => {
|
|
10
|
+
this.onClose();
|
|
11
|
+
}).catch((t) => {
|
|
12
|
+
this.onError("webtransport error", t);
|
|
13
|
+
}), this.transport.ready.then(() => {
|
|
14
|
+
this.transport.createBidirectionalStream().then((t) => {
|
|
15
|
+
const e = p(Number.MAX_SAFE_INTEGER, this.socket.binaryType), i = t.readable.pipeThrough(e).getReader(), r = d();
|
|
16
|
+
r.readable.pipeTo(t.writable), this.writer = r.writable.getWriter();
|
|
17
|
+
const s = () => {
|
|
18
|
+
i.read().then(({
|
|
19
|
+
done: n,
|
|
20
|
+
value: a
|
|
21
|
+
}) => {
|
|
22
|
+
n || (this.onPacket(a), s());
|
|
23
|
+
}).catch((n) => {
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
s();
|
|
27
|
+
const o = {
|
|
28
|
+
type: "open"
|
|
29
|
+
};
|
|
30
|
+
this.query.sid && (o.data = `{"sid":"${this.query.sid}"}`), this.writer.write(o).then(() => this.onOpen());
|
|
31
|
+
});
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
write(t) {
|
|
35
|
+
this.writable = !1;
|
|
36
|
+
for (let e = 0; e < t.length; e++) {
|
|
37
|
+
const i = t[e], r = e === t.length - 1;
|
|
38
|
+
this.writer.write(i).then(() => {
|
|
39
|
+
r && c(() => {
|
|
40
|
+
this.writable = !0, this.emitReserved("drain");
|
|
41
|
+
}, this.setTimeoutFn);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
doClose() {
|
|
46
|
+
var t;
|
|
47
|
+
(t = this.transport) === null || t === void 0 || t.close();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
f as WT
|
|
52
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { hasCORS as i } from "../contrib/has-cors.mjs";
|
|
2
|
+
import { globalThisShim as n } from "../globalThis.browser.mjs";
|
|
3
|
+
function a(e) {
|
|
4
|
+
const t = e.xdomain;
|
|
5
|
+
try {
|
|
6
|
+
if (typeof XMLHttpRequest != "undefined" && (!t || i))
|
|
7
|
+
return new XMLHttpRequest();
|
|
8
|
+
} catch (o) {
|
|
9
|
+
}
|
|
10
|
+
if (!t)
|
|
11
|
+
try {
|
|
12
|
+
return new n[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
13
|
+
} catch (o) {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function f() {
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
a as XHR,
|
|
20
|
+
f as createCookieJar
|
|
21
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { globalThisShim as r } from "./globalThis.browser.mjs";
|
|
2
|
+
function f(e, ...t) {
|
|
3
|
+
return t.reduce((i, n) => (e.hasOwnProperty(n) && (i[n] = e[n]), i), {});
|
|
4
|
+
}
|
|
5
|
+
const l = r.setTimeout, s = r.clearTimeout;
|
|
6
|
+
function m(e, t) {
|
|
7
|
+
t.useNativeTimers ? (e.setTimeoutFn = l.bind(r), e.clearTimeoutFn = s.bind(r)) : (e.setTimeoutFn = r.setTimeout.bind(r), e.clearTimeoutFn = r.clearTimeout.bind(r));
|
|
8
|
+
}
|
|
9
|
+
const T = 1.33;
|
|
10
|
+
function h(e) {
|
|
11
|
+
return typeof e == "string" ? o(e) : Math.ceil((e.byteLength || e.size) * T);
|
|
12
|
+
}
|
|
13
|
+
function o(e) {
|
|
14
|
+
let t = 0, i = 0;
|
|
15
|
+
for (let n = 0, u = e.length; n < u; n++)
|
|
16
|
+
t = e.charCodeAt(n), t < 128 ? i += 1 : t < 2048 ? i += 2 : t < 55296 || t >= 57344 ? i += 3 : (n++, i += 4);
|
|
17
|
+
return i;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
h as byteLength,
|
|
21
|
+
m as installTimerFunctions,
|
|
22
|
+
f as pick
|
|
23
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const e = /* @__PURE__ */ Object.create(null);
|
|
2
|
+
e.open = "0";
|
|
3
|
+
e.close = "1";
|
|
4
|
+
e.ping = "2";
|
|
5
|
+
e.pong = "3";
|
|
6
|
+
e.message = "4";
|
|
7
|
+
e.upgrade = "5";
|
|
8
|
+
e.noop = "6";
|
|
9
|
+
const o = /* @__PURE__ */ Object.create(null);
|
|
10
|
+
Object.keys(e).forEach((r) => {
|
|
11
|
+
o[e[r]] = r;
|
|
12
|
+
});
|
|
13
|
+
const t = {
|
|
14
|
+
type: "error",
|
|
15
|
+
data: "parser error"
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
t as ERROR_PACKET,
|
|
19
|
+
e as PACKET_TYPES,
|
|
20
|
+
o as PACKET_TYPES_REVERSE
|
|
21
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", r = typeof Uint8Array == "undefined" ? [] : new Uint8Array(256);
|
|
2
|
+
for (let e = 0; e < i.length; e++)
|
|
3
|
+
r[i.charCodeAt(e)] = e;
|
|
4
|
+
const g = (e) => {
|
|
5
|
+
let t = e.length * 0.75, y = e.length, n, o = 0, h, d, c, l;
|
|
6
|
+
e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
|
|
7
|
+
const A = new ArrayBuffer(t), f = new Uint8Array(A);
|
|
8
|
+
for (n = 0; n < y; n += 4)
|
|
9
|
+
h = r[e.charCodeAt(n)], d = r[e.charCodeAt(n + 1)], c = r[e.charCodeAt(n + 2)], l = r[e.charCodeAt(n + 3)], f[o++] = h << 2 | d >> 4, f[o++] = (d & 15) << 4 | c >> 2, f[o++] = (c & 3) << 6 | l & 63;
|
|
10
|
+
return A;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
g as decode
|
|
14
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PACKET_TYPES_REVERSE as s, ERROR_PACKET as n } from "./commons.mjs";
|
|
2
|
+
import { decode as u } from "./contrib/base64-arraybuffer.mjs";
|
|
3
|
+
const o = typeof ArrayBuffer == "function", a = (r, e) => {
|
|
4
|
+
if (typeof r != "string")
|
|
5
|
+
return {
|
|
6
|
+
type: "message",
|
|
7
|
+
data: f(r, e)
|
|
8
|
+
};
|
|
9
|
+
const t = r.charAt(0);
|
|
10
|
+
return t === "b" ? {
|
|
11
|
+
type: "message",
|
|
12
|
+
data: i(r.substring(1), e)
|
|
13
|
+
} : s[t] ? r.length > 1 ? {
|
|
14
|
+
type: s[t],
|
|
15
|
+
data: r.substring(1)
|
|
16
|
+
} : {
|
|
17
|
+
type: s[t]
|
|
18
|
+
} : n;
|
|
19
|
+
}, i = (r, e) => {
|
|
20
|
+
if (o) {
|
|
21
|
+
const t = u(r);
|
|
22
|
+
return f(t, e);
|
|
23
|
+
} else
|
|
24
|
+
return {
|
|
25
|
+
base64: !0,
|
|
26
|
+
data: r
|
|
27
|
+
};
|
|
28
|
+
}, f = (r, e) => {
|
|
29
|
+
switch (e) {
|
|
30
|
+
case "blob":
|
|
31
|
+
return r instanceof Blob ? r : new Blob([r]);
|
|
32
|
+
case "arraybuffer":
|
|
33
|
+
default:
|
|
34
|
+
return r instanceof ArrayBuffer ? r : r.buffer;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
a as decodePacket
|
|
39
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PACKET_TYPES as B } from "./commons.mjs";
|
|
2
|
+
const u = typeof Blob == "function" || typeof Blob != "undefined" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", s = typeof ArrayBuffer == "function", y = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, c = ({
|
|
3
|
+
type: e,
|
|
4
|
+
data: r
|
|
5
|
+
}, n, t) => u && r instanceof Blob ? n ? t(r) : o(r, t) : s && (r instanceof ArrayBuffer || y(r)) ? n ? t(r) : o(new Blob([r]), t) : t(B[e] + (r || "")), o = (e, r) => {
|
|
6
|
+
const n = new FileReader();
|
|
7
|
+
return n.onload = function() {
|
|
8
|
+
const t = n.result.split(",")[1];
|
|
9
|
+
r("b" + (t || ""));
|
|
10
|
+
}, n.readAsDataURL(e);
|
|
11
|
+
};
|
|
12
|
+
function i(e) {
|
|
13
|
+
return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
14
|
+
}
|
|
15
|
+
let f;
|
|
16
|
+
function l(e, r) {
|
|
17
|
+
if (u && e.data instanceof Blob)
|
|
18
|
+
return e.data.arrayBuffer().then(i).then(r);
|
|
19
|
+
if (s && (e.data instanceof ArrayBuffer || y(e.data)))
|
|
20
|
+
return r(i(e.data));
|
|
21
|
+
c(e, !1, (n) => {
|
|
22
|
+
f || (f = new TextEncoder()), r(f.encode(n));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
c as encodePacket,
|
|
27
|
+
l as encodePacketToBinary
|
|
28
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { encodePacket as b, encodePacketToBinary as m } from "./encodePacket.browser.mjs";
|
|
2
|
+
import { decodePacket as h } from "./decodePacket.browser.mjs";
|
|
3
|
+
import { ERROR_PACKET as g } from "./commons.mjs";
|
|
4
|
+
const y = String.fromCharCode(30), A = (r, a) => {
|
|
5
|
+
const n = r.length, t = new Array(n);
|
|
6
|
+
let e = 0;
|
|
7
|
+
r.forEach((i, l) => {
|
|
8
|
+
b(i, !1, (f) => {
|
|
9
|
+
t[l] = f, ++e === n && a(t.join(y));
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
}, D = (r, a) => {
|
|
13
|
+
const n = r.split(y), t = [];
|
|
14
|
+
for (let e = 0; e < n.length; e++) {
|
|
15
|
+
const i = h(n[e], a);
|
|
16
|
+
if (t.push(i), i.type === "error")
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
function E() {
|
|
22
|
+
return new TransformStream({
|
|
23
|
+
transform(r, a) {
|
|
24
|
+
m(r, (n) => {
|
|
25
|
+
const t = n.length;
|
|
26
|
+
let e;
|
|
27
|
+
if (t < 126)
|
|
28
|
+
e = new Uint8Array(1), new DataView(e.buffer).setUint8(0, t);
|
|
29
|
+
else if (t < 65536) {
|
|
30
|
+
e = new Uint8Array(3);
|
|
31
|
+
const i = new DataView(e.buffer);
|
|
32
|
+
i.setUint8(0, 126), i.setUint16(1, t);
|
|
33
|
+
} else {
|
|
34
|
+
e = new Uint8Array(9);
|
|
35
|
+
const i = new DataView(e.buffer);
|
|
36
|
+
i.setUint8(0, 127), i.setBigUint64(1, BigInt(t));
|
|
37
|
+
}
|
|
38
|
+
r.data && typeof r.data != "string" && (e[0] |= 128), a.enqueue(e), a.enqueue(n);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
let d;
|
|
44
|
+
function s(r) {
|
|
45
|
+
return r.reduce((a, n) => a + n.length, 0);
|
|
46
|
+
}
|
|
47
|
+
function c(r, a) {
|
|
48
|
+
if (r[0].length === a)
|
|
49
|
+
return r.shift();
|
|
50
|
+
const n = new Uint8Array(a);
|
|
51
|
+
let t = 0;
|
|
52
|
+
for (let e = 0; e < a; e++)
|
|
53
|
+
n[e] = r[0][t++], t === r[0].length && (r.shift(), t = 0);
|
|
54
|
+
return r.length && t < r[0].length && (r[0] = r[0].slice(t)), n;
|
|
55
|
+
}
|
|
56
|
+
function T(r, a) {
|
|
57
|
+
d || (d = new TextDecoder());
|
|
58
|
+
const n = [];
|
|
59
|
+
let t = 0, e = -1, i = !1;
|
|
60
|
+
return new TransformStream({
|
|
61
|
+
transform(l, f) {
|
|
62
|
+
for (n.push(l); ; ) {
|
|
63
|
+
if (t === 0) {
|
|
64
|
+
if (s(n) < 1)
|
|
65
|
+
break;
|
|
66
|
+
const o = c(n, 1);
|
|
67
|
+
i = (o[0] & 128) === 128, e = o[0] & 127, e < 126 ? t = 3 : e === 126 ? t = 1 : t = 2;
|
|
68
|
+
} else if (t === 1) {
|
|
69
|
+
if (s(n) < 2)
|
|
70
|
+
break;
|
|
71
|
+
const o = c(n, 2);
|
|
72
|
+
e = new DataView(o.buffer, o.byteOffset, o.length).getUint16(0), t = 3;
|
|
73
|
+
} else if (t === 2) {
|
|
74
|
+
if (s(n) < 8)
|
|
75
|
+
break;
|
|
76
|
+
const o = c(n, 8), u = new DataView(o.buffer, o.byteOffset, o.length), w = u.getUint32(0);
|
|
77
|
+
if (w > Math.pow(2, 53 - 32) - 1) {
|
|
78
|
+
f.enqueue(g);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
e = w * Math.pow(2, 32) + u.getUint32(4), t = 3;
|
|
82
|
+
} else {
|
|
83
|
+
if (s(n) < e)
|
|
84
|
+
break;
|
|
85
|
+
const o = c(n, e);
|
|
86
|
+
f.enqueue(h(i ? o : d.decode(o), a)), t = 0;
|
|
87
|
+
}
|
|
88
|
+
if (e === 0 || e > r) {
|
|
89
|
+
f.enqueue(g);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const x = 4;
|
|
97
|
+
export {
|
|
98
|
+
T as createPacketDecoderStream,
|
|
99
|
+
E as createPacketEncoderStream,
|
|
100
|
+
h as decodePacket,
|
|
101
|
+
D as decodePayload,
|
|
102
|
+
b as encodePacket,
|
|
103
|
+
A as encodePayload,
|
|
104
|
+
x as protocol
|
|
105
|
+
};
|