@thatopen/services 0.13.0 → 0.15.0
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/built-in/index.d.ts +73 -63
- package/dist/core/channel.d.ts +198 -0
- package/dist/core/channel.test.d.ts +7 -0
- package/dist/core/examples/channel.d.ts +31 -0
- package/dist/core/platform-client.d.ts +26 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +837 -480
- package/docs/client/paths.json +4 -0
- package/package.json +1 -1
- package/src/built-in/ProjectManager/example.ts +4 -43
- package/src/built-in/index.ts +73 -63
package/dist/index.es.js
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Tt = Object.defineProperty;
|
|
2
|
+
var Ye = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
Object.keys(
|
|
18
|
-
|
|
5
|
+
var vt = (n, e, t) => e in n ? Tt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
6
|
+
var T = (n, e, t) => vt(n, typeof e != "symbol" ? e + "" : e, t), ge = (n, e, t) => e.has(n) || Ye("Cannot " + t);
|
|
7
|
+
var u = (n, e, t) => (ge(n, e, "read from private field"), t ? t.call(n) : e.get(n)), _ = (n, e, t) => e.has(n) ? Ye("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), E = (n, e, t, s) => (ge(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t), a = (n, e, t) => (ge(n, e, "access private method"), t);
|
|
8
|
+
const P = /* @__PURE__ */ Object.create(null);
|
|
9
|
+
P.open = "0";
|
|
10
|
+
P.close = "1";
|
|
11
|
+
P.ping = "2";
|
|
12
|
+
P.pong = "3";
|
|
13
|
+
P.message = "4";
|
|
14
|
+
P.upgrade = "5";
|
|
15
|
+
P.noop = "6";
|
|
16
|
+
const ce = /* @__PURE__ */ Object.create(null);
|
|
17
|
+
Object.keys(P).forEach((n) => {
|
|
18
|
+
ce[P[n]] = n;
|
|
19
19
|
});
|
|
20
|
-
const
|
|
20
|
+
const ke = { type: "error", data: "parser error" }, st = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", nt = typeof ArrayBuffer == "function", rt = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, De = ({ type: n, data: e }, t, s) => st && e instanceof Blob ? t ? s(e) : We(e, s) : nt && (e instanceof ArrayBuffer || rt(e)) ? t ? s(e) : We(new Blob([e]), s) : s(P[n] + (e || "")), We = (n, e) => {
|
|
21
21
|
const t = new FileReader();
|
|
22
22
|
return t.onload = function() {
|
|
23
23
|
const s = t.result.split(",")[1];
|
|
24
24
|
e("b" + (s || ""));
|
|
25
25
|
}, t.readAsDataURL(n);
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function Ke(n) {
|
|
28
28
|
return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
|
|
29
29
|
}
|
|
30
|
-
let
|
|
31
|
-
function
|
|
32
|
-
if (
|
|
33
|
-
return n.data.arrayBuffer().then(
|
|
34
|
-
if (
|
|
35
|
-
return e(
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
let we;
|
|
31
|
+
function kt(n, e) {
|
|
32
|
+
if (st && n.data instanceof Blob)
|
|
33
|
+
return n.data.arrayBuffer().then(Ke).then(e);
|
|
34
|
+
if (nt && (n.data instanceof ArrayBuffer || rt(n.data)))
|
|
35
|
+
return e(Ke(n.data));
|
|
36
|
+
De(n, !1, (t) => {
|
|
37
|
+
we || (we = new TextEncoder()), e(we.encode(t));
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
for (let n = 0; n <
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
let e = n.length * 0.75, t = n.length, s, r = 0, i, o, h,
|
|
40
|
+
const ze = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ee = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
41
|
+
for (let n = 0; n < ze.length; n++)
|
|
42
|
+
ee[ze.charCodeAt(n)] = n;
|
|
43
|
+
const At = (n) => {
|
|
44
|
+
let e = n.length * 0.75, t = n.length, s, r = 0, i, o, h, f;
|
|
45
45
|
n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--);
|
|
46
|
-
const
|
|
46
|
+
const m = new ArrayBuffer(e), y = new Uint8Array(m);
|
|
47
47
|
for (s = 0; s < t; s += 4)
|
|
48
|
-
i =
|
|
49
|
-
return
|
|
50
|
-
},
|
|
48
|
+
i = ee[n.charCodeAt(s)], o = ee[n.charCodeAt(s + 1)], h = ee[n.charCodeAt(s + 2)], f = ee[n.charCodeAt(s + 3)], y[r++] = i << 2 | o >> 4, y[r++] = (o & 15) << 4 | h >> 2, y[r++] = (h & 3) << 6 | f & 63;
|
|
49
|
+
return m;
|
|
50
|
+
}, St = typeof ArrayBuffer == "function", Fe = (n, e) => {
|
|
51
51
|
if (typeof n != "string")
|
|
52
52
|
return {
|
|
53
53
|
type: "message",
|
|
54
|
-
data:
|
|
54
|
+
data: it(n, e)
|
|
55
55
|
};
|
|
56
56
|
const t = n.charAt(0);
|
|
57
57
|
return t === "b" ? {
|
|
58
58
|
type: "message",
|
|
59
|
-
data:
|
|
60
|
-
} :
|
|
61
|
-
type:
|
|
59
|
+
data: Ot(n.substring(1), e)
|
|
60
|
+
} : ce[t] ? n.length > 1 ? {
|
|
61
|
+
type: ce[t],
|
|
62
62
|
data: n.substring(1)
|
|
63
63
|
} : {
|
|
64
|
-
type:
|
|
65
|
-
} :
|
|
66
|
-
},
|
|
67
|
-
if (
|
|
68
|
-
const t =
|
|
69
|
-
return
|
|
64
|
+
type: ce[t]
|
|
65
|
+
} : ke;
|
|
66
|
+
}, Ot = (n, e) => {
|
|
67
|
+
if (St) {
|
|
68
|
+
const t = At(n);
|
|
69
|
+
return it(t, e);
|
|
70
70
|
} else
|
|
71
71
|
return { base64: !0, data: n };
|
|
72
|
-
},
|
|
72
|
+
}, it = (n, e) => {
|
|
73
73
|
switch (e) {
|
|
74
74
|
case "blob":
|
|
75
75
|
return n instanceof Blob ? n : new Blob([n]);
|
|
@@ -77,27 +77,27 @@ const Xe = (n) => {
|
|
|
77
77
|
default:
|
|
78
78
|
return n instanceof ArrayBuffer ? n : n.buffer;
|
|
79
79
|
}
|
|
80
|
-
},
|
|
80
|
+
}, ot = "", $t = (n, e) => {
|
|
81
81
|
const t = n.length, s = new Array(t);
|
|
82
82
|
let r = 0;
|
|
83
83
|
n.forEach((i, o) => {
|
|
84
|
-
|
|
85
|
-
s[o] = h, ++r === t && e(s.join(
|
|
84
|
+
De(i, !1, (h) => {
|
|
85
|
+
s[o] = h, ++r === t && e(s.join(ot));
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
-
},
|
|
89
|
-
const t = n.split(
|
|
88
|
+
}, Rt = (n, e) => {
|
|
89
|
+
const t = n.split(ot), s = [];
|
|
90
90
|
for (let r = 0; r < t.length; r++) {
|
|
91
|
-
const i =
|
|
91
|
+
const i = Fe(t[r], e);
|
|
92
92
|
if (s.push(i), i.type === "error")
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
95
|
return s;
|
|
96
96
|
};
|
|
97
|
-
function
|
|
97
|
+
function Ct() {
|
|
98
98
|
return new TransformStream({
|
|
99
99
|
transform(n, e) {
|
|
100
|
-
|
|
100
|
+
kt(n, (t) => {
|
|
101
101
|
const s = t.length;
|
|
102
102
|
let r;
|
|
103
103
|
if (s < 126)
|
|
@@ -116,11 +116,11 @@ function tt() {
|
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
let
|
|
120
|
-
function
|
|
119
|
+
let _e;
|
|
120
|
+
function oe(n) {
|
|
121
121
|
return n.reduce((e, t) => e + t.length, 0);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function ae(n, e) {
|
|
124
124
|
if (n[0].length === e)
|
|
125
125
|
return n.shift();
|
|
126
126
|
const t = new Uint8Array(e);
|
|
@@ -129,65 +129,65 @@ function M(n, e) {
|
|
|
129
129
|
t[r] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
|
|
130
130
|
return n.length && s < n[0].length && (n[0] = n[0].slice(s)), t;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
132
|
+
function Nt(n, e) {
|
|
133
|
+
_e || (_e = new TextDecoder());
|
|
134
134
|
const t = [];
|
|
135
135
|
let s = 0, r = -1, i = !1;
|
|
136
136
|
return new TransformStream({
|
|
137
137
|
transform(o, h) {
|
|
138
138
|
for (t.push(o); ; ) {
|
|
139
139
|
if (s === 0) {
|
|
140
|
-
if (
|
|
140
|
+
if (oe(t) < 1)
|
|
141
141
|
break;
|
|
142
|
-
const
|
|
143
|
-
i = (
|
|
142
|
+
const f = ae(t, 1);
|
|
143
|
+
i = (f[0] & 128) === 128, r = f[0] & 127, r < 126 ? s = 3 : r === 126 ? s = 1 : s = 2;
|
|
144
144
|
} else if (s === 1) {
|
|
145
|
-
if (
|
|
145
|
+
if (oe(t) < 2)
|
|
146
146
|
break;
|
|
147
|
-
const
|
|
148
|
-
r = new DataView(
|
|
147
|
+
const f = ae(t, 2);
|
|
148
|
+
r = new DataView(f.buffer, f.byteOffset, f.length).getUint16(0), s = 3;
|
|
149
149
|
} else if (s === 2) {
|
|
150
|
-
if (
|
|
150
|
+
if (oe(t) < 8)
|
|
151
151
|
break;
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
h.enqueue(
|
|
152
|
+
const f = ae(t, 8), m = new DataView(f.buffer, f.byteOffset, f.length), y = m.getUint32(0);
|
|
153
|
+
if (y > Math.pow(2, 21) - 1) {
|
|
154
|
+
h.enqueue(ke);
|
|
155
155
|
break;
|
|
156
156
|
}
|
|
157
|
-
r =
|
|
157
|
+
r = y * Math.pow(2, 32) + m.getUint32(4), s = 3;
|
|
158
158
|
} else {
|
|
159
|
-
if (
|
|
159
|
+
if (oe(t) < r)
|
|
160
160
|
break;
|
|
161
|
-
const
|
|
162
|
-
h.enqueue(
|
|
161
|
+
const f = ae(t, r);
|
|
162
|
+
h.enqueue(Fe(i ? f : _e.decode(f), e)), s = 0;
|
|
163
163
|
}
|
|
164
164
|
if (r === 0 || r > n) {
|
|
165
|
-
h.enqueue(
|
|
165
|
+
h.enqueue(ke);
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
const
|
|
173
|
-
function
|
|
174
|
-
if (n) return
|
|
172
|
+
const at = 4;
|
|
173
|
+
function w(n) {
|
|
174
|
+
if (n) return Pt(n);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
for (var e in
|
|
178
|
-
n[e] =
|
|
176
|
+
function Pt(n) {
|
|
177
|
+
for (var e in w.prototype)
|
|
178
|
+
n[e] = w.prototype[e];
|
|
179
179
|
return n;
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
w.prototype.on = w.prototype.addEventListener = function(n, e) {
|
|
182
182
|
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(e), this;
|
|
183
183
|
};
|
|
184
|
-
|
|
184
|
+
w.prototype.once = function(n, e) {
|
|
185
185
|
function t() {
|
|
186
186
|
this.off(n, t), e.apply(this, arguments);
|
|
187
187
|
}
|
|
188
188
|
return t.fn = e, this.on(n, t), this;
|
|
189
189
|
};
|
|
190
|
-
|
|
190
|
+
w.prototype.off = w.prototype.removeListener = w.prototype.removeAllListeners = w.prototype.removeEventListener = function(n, e) {
|
|
191
191
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
|
|
192
192
|
return this._callbacks = {}, this;
|
|
193
193
|
var t = this._callbacks["$" + n];
|
|
@@ -201,7 +201,7 @@ g.prototype.off = g.prototype.removeListener = g.prototype.removeAllListeners =
|
|
|
201
201
|
}
|
|
202
202
|
return t.length === 0 && delete this._callbacks["$" + n], this;
|
|
203
203
|
};
|
|
204
|
-
|
|
204
|
+
w.prototype.emit = function(n) {
|
|
205
205
|
this._callbacks = this._callbacks || {};
|
|
206
206
|
for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + n], s = 1; s < arguments.length; s++)
|
|
207
207
|
e[s - 1] = arguments[s];
|
|
@@ -212,41 +212,41 @@ g.prototype.emit = function(n) {
|
|
|
212
212
|
}
|
|
213
213
|
return this;
|
|
214
214
|
};
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
w.prototype.emitReserved = w.prototype.emit;
|
|
216
|
+
w.prototype.listeners = function(n) {
|
|
217
217
|
return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || [];
|
|
218
218
|
};
|
|
219
|
-
|
|
219
|
+
w.prototype.hasListeners = function(n) {
|
|
220
220
|
return !!this.listeners(n).length;
|
|
221
221
|
};
|
|
222
|
-
const
|
|
223
|
-
function
|
|
222
|
+
const ye = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), S = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Bt = "arraybuffer";
|
|
223
|
+
function ct(n, ...e) {
|
|
224
224
|
return e.reduce((t, s) => (n.hasOwnProperty(s) && (t[s] = n[s]), t), {});
|
|
225
225
|
}
|
|
226
|
-
const
|
|
227
|
-
function
|
|
228
|
-
e.useNativeTimers ? (n.setTimeoutFn =
|
|
226
|
+
const xt = S.setTimeout, It = S.clearTimeout;
|
|
227
|
+
function me(n, e) {
|
|
228
|
+
e.useNativeTimers ? (n.setTimeoutFn = xt.bind(S), n.clearTimeoutFn = It.bind(S)) : (n.setTimeoutFn = S.setTimeout.bind(S), n.clearTimeoutFn = S.clearTimeout.bind(S));
|
|
229
229
|
}
|
|
230
|
-
const
|
|
231
|
-
function
|
|
232
|
-
return typeof n == "string" ?
|
|
230
|
+
const Lt = 1.33;
|
|
231
|
+
function qt(n) {
|
|
232
|
+
return typeof n == "string" ? Ut(n) : Math.ceil((n.byteLength || n.size) * Lt);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function Ut(n) {
|
|
235
235
|
let e = 0, t = 0;
|
|
236
236
|
for (let s = 0, r = n.length; s < r; s++)
|
|
237
237
|
e = n.charCodeAt(s), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (s++, t += 4);
|
|
238
238
|
return t;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function ht() {
|
|
241
241
|
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function Dt(n) {
|
|
244
244
|
let e = "";
|
|
245
245
|
for (let t in n)
|
|
246
246
|
n.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(n[t]));
|
|
247
247
|
return e;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function Ft(n) {
|
|
250
250
|
let e = {}, t = n.split("&");
|
|
251
251
|
for (let s = 0, r = t.length; s < r; s++) {
|
|
252
252
|
let i = t[s].split("=");
|
|
@@ -254,12 +254,12 @@ function lt(n) {
|
|
|
254
254
|
}
|
|
255
255
|
return e;
|
|
256
256
|
}
|
|
257
|
-
class
|
|
257
|
+
class Mt extends Error {
|
|
258
258
|
constructor(e, t, s) {
|
|
259
259
|
super(e), this.description = t, this.context = s, this.type = "TransportError";
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
class
|
|
262
|
+
class Me extends w {
|
|
263
263
|
/**
|
|
264
264
|
* Transport abstract constructor.
|
|
265
265
|
*
|
|
@@ -267,7 +267,7 @@ class me extends g {
|
|
|
267
267
|
* @protected
|
|
268
268
|
*/
|
|
269
269
|
constructor(e) {
|
|
270
|
-
super(), this.writable = !1,
|
|
270
|
+
super(), this.writable = !1, me(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* Emits an error.
|
|
@@ -279,7 +279,7 @@ class me extends g {
|
|
|
279
279
|
* @protected
|
|
280
280
|
*/
|
|
281
281
|
onError(e, t, s) {
|
|
282
|
-
return super.emitReserved("error", new
|
|
282
|
+
return super.emitReserved("error", new Mt(e, t, s)), this;
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* Opens the transport.
|
|
@@ -316,7 +316,7 @@ class me extends g {
|
|
|
316
316
|
* @protected
|
|
317
317
|
*/
|
|
318
318
|
onData(e) {
|
|
319
|
-
const t =
|
|
319
|
+
const t = Fe(e, this.socket.binaryType);
|
|
320
320
|
this.onPacket(t);
|
|
321
321
|
}
|
|
322
322
|
/**
|
|
@@ -353,11 +353,11 @@ class me extends g {
|
|
|
353
353
|
return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
|
|
354
354
|
}
|
|
355
355
|
_query(e) {
|
|
356
|
-
const t =
|
|
356
|
+
const t = Dt(e);
|
|
357
357
|
return t.length ? "?" + t : "";
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
class
|
|
360
|
+
class Ht extends Me {
|
|
361
361
|
constructor() {
|
|
362
362
|
super(...arguments), this._polling = !1;
|
|
363
363
|
}
|
|
@@ -413,7 +413,7 @@ class pt extends me {
|
|
|
413
413
|
return this.onClose({ description: "transport closed by the server" }), !1;
|
|
414
414
|
this.onPacket(s);
|
|
415
415
|
};
|
|
416
|
-
|
|
416
|
+
Rt(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
|
|
417
417
|
}
|
|
418
418
|
/**
|
|
419
419
|
* For polling, send a close packet.
|
|
@@ -433,7 +433,7 @@ class pt extends me {
|
|
|
433
433
|
* @protected
|
|
434
434
|
*/
|
|
435
435
|
write(e) {
|
|
436
|
-
this.writable = !1,
|
|
436
|
+
this.writable = !1, $t(e, (t) => {
|
|
437
437
|
this.doWrite(t, () => {
|
|
438
438
|
this.writable = !0, this.emitReserved("drain");
|
|
439
439
|
});
|
|
@@ -446,18 +446,18 @@ class pt extends me {
|
|
|
446
446
|
*/
|
|
447
447
|
uri() {
|
|
448
448
|
const e = this.opts.secure ? "https" : "http", t = this.query || {};
|
|
449
|
-
return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] =
|
|
449
|
+
return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = ht()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
let
|
|
452
|
+
let ut = !1;
|
|
453
453
|
try {
|
|
454
|
-
|
|
454
|
+
ut = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
455
455
|
} catch {
|
|
456
456
|
}
|
|
457
|
-
const
|
|
458
|
-
function
|
|
457
|
+
const jt = ut;
|
|
458
|
+
function Vt() {
|
|
459
459
|
}
|
|
460
|
-
class
|
|
460
|
+
class Jt extends Ht {
|
|
461
461
|
/**
|
|
462
462
|
* XHR Polling constructor.
|
|
463
463
|
*
|
|
@@ -499,7 +499,7 @@ class mt extends pt {
|
|
|
499
499
|
}), this.pollXhr = e;
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
|
-
class
|
|
502
|
+
class N extends w {
|
|
503
503
|
/**
|
|
504
504
|
* Request constructor
|
|
505
505
|
*
|
|
@@ -507,7 +507,7 @@ class k extends g {
|
|
|
507
507
|
* @package
|
|
508
508
|
*/
|
|
509
509
|
constructor(e, t, s) {
|
|
510
|
-
super(), this.createRequest = e,
|
|
510
|
+
super(), this.createRequest = e, me(this, s), this._opts = s, this._method = s.method || "GET", this._uri = t, this._data = s.data !== void 0 ? s.data : null, this._create();
|
|
511
511
|
}
|
|
512
512
|
/**
|
|
513
513
|
* Creates the XHR object and sends the request.
|
|
@@ -516,7 +516,7 @@ class k extends g {
|
|
|
516
516
|
*/
|
|
517
517
|
_create() {
|
|
518
518
|
var e;
|
|
519
|
-
const t =
|
|
519
|
+
const t = ct(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
520
520
|
t.xdomain = !!this._opts.xd;
|
|
521
521
|
const s = this._xhr = this.createRequest(t);
|
|
522
522
|
try {
|
|
@@ -553,7 +553,7 @@ class k extends g {
|
|
|
553
553
|
}, 0);
|
|
554
554
|
return;
|
|
555
555
|
}
|
|
556
|
-
typeof document < "u" && (this._index =
|
|
556
|
+
typeof document < "u" && (this._index = N.requestsCount++, N.requests[this._index] = this);
|
|
557
557
|
}
|
|
558
558
|
/**
|
|
559
559
|
* Called upon error.
|
|
@@ -570,12 +570,12 @@ class k extends g {
|
|
|
570
570
|
*/
|
|
571
571
|
_cleanup(e) {
|
|
572
572
|
if (!(typeof this._xhr > "u" || this._xhr === null)) {
|
|
573
|
-
if (this._xhr.onreadystatechange =
|
|
573
|
+
if (this._xhr.onreadystatechange = Vt, e)
|
|
574
574
|
try {
|
|
575
575
|
this._xhr.abort();
|
|
576
576
|
} catch {
|
|
577
577
|
}
|
|
578
|
-
typeof document < "u" && delete
|
|
578
|
+
typeof document < "u" && delete N.requests[this._index], this._xhr = null;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
/**
|
|
@@ -596,56 +596,56 @@ class k extends g {
|
|
|
596
596
|
this._cleanup();
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
|
-
|
|
600
|
-
|
|
599
|
+
N.requestsCount = 0;
|
|
600
|
+
N.requests = {};
|
|
601
601
|
if (typeof document < "u") {
|
|
602
602
|
if (typeof attachEvent == "function")
|
|
603
|
-
attachEvent("onunload",
|
|
603
|
+
attachEvent("onunload", Xe);
|
|
604
604
|
else if (typeof addEventListener == "function") {
|
|
605
|
-
const n = "onpagehide" in
|
|
606
|
-
addEventListener(n,
|
|
605
|
+
const n = "onpagehide" in S ? "pagehide" : "unload";
|
|
606
|
+
addEventListener(n, Xe, !1);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
function
|
|
610
|
-
for (let n in
|
|
611
|
-
|
|
609
|
+
function Xe() {
|
|
610
|
+
for (let n in N.requests)
|
|
611
|
+
N.requests.hasOwnProperty(n) && N.requests[n].abort();
|
|
612
612
|
}
|
|
613
|
-
const
|
|
614
|
-
const n =
|
|
613
|
+
const Gt = function() {
|
|
614
|
+
const n = lt({
|
|
615
615
|
xdomain: !1
|
|
616
616
|
});
|
|
617
617
|
return n && n.responseType !== null;
|
|
618
618
|
}();
|
|
619
|
-
class
|
|
619
|
+
class Yt extends Jt {
|
|
620
620
|
constructor(e) {
|
|
621
621
|
super(e);
|
|
622
622
|
const t = e && e.forceBase64;
|
|
623
|
-
this.supportsBinary =
|
|
623
|
+
this.supportsBinary = Gt && !t;
|
|
624
624
|
}
|
|
625
625
|
request(e = {}) {
|
|
626
|
-
return Object.assign(e, { xd: this.xd }, this.opts), new
|
|
626
|
+
return Object.assign(e, { xd: this.xd }, this.opts), new N(lt, this.uri(), e);
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
|
-
function
|
|
629
|
+
function lt(n) {
|
|
630
630
|
const e = n.xdomain;
|
|
631
631
|
try {
|
|
632
|
-
if (typeof XMLHttpRequest < "u" && (!e ||
|
|
632
|
+
if (typeof XMLHttpRequest < "u" && (!e || jt))
|
|
633
633
|
return new XMLHttpRequest();
|
|
634
634
|
} catch {
|
|
635
635
|
}
|
|
636
636
|
if (!e)
|
|
637
637
|
try {
|
|
638
|
-
return new
|
|
638
|
+
return new S[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
639
639
|
} catch {
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
const
|
|
643
|
-
class
|
|
642
|
+
const ft = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
643
|
+
class Wt extends Me {
|
|
644
644
|
get name() {
|
|
645
645
|
return "websocket";
|
|
646
646
|
}
|
|
647
647
|
doOpen() {
|
|
648
|
-
const e = this.uri(), t = this.opts.protocols, s =
|
|
648
|
+
const e = this.uri(), t = this.opts.protocols, s = ft ? {} : ct(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
649
649
|
this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
|
|
650
650
|
try {
|
|
651
651
|
this.ws = this.createSocket(e, t, s);
|
|
@@ -671,12 +671,12 @@ class _t extends me {
|
|
|
671
671
|
this.writable = !1;
|
|
672
672
|
for (let t = 0; t < e.length; t++) {
|
|
673
673
|
const s = e[t], r = t === e.length - 1;
|
|
674
|
-
|
|
674
|
+
De(s, this.supportsBinary, (i) => {
|
|
675
675
|
try {
|
|
676
676
|
this.doWrite(s, i);
|
|
677
677
|
} catch {
|
|
678
678
|
}
|
|
679
|
-
r &&
|
|
679
|
+
r && ye(() => {
|
|
680
680
|
this.writable = !0, this.emitReserved("drain");
|
|
681
681
|
}, this.setTimeoutFn);
|
|
682
682
|
});
|
|
@@ -693,19 +693,19 @@ class _t extends me {
|
|
|
693
693
|
*/
|
|
694
694
|
uri() {
|
|
695
695
|
const e = this.opts.secure ? "wss" : "ws", t = this.query || {};
|
|
696
|
-
return this.opts.timestampRequests && (t[this.opts.timestampParam] =
|
|
696
|
+
return this.opts.timestampRequests && (t[this.opts.timestampParam] = ht()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
|
-
const
|
|
700
|
-
class
|
|
699
|
+
const be = S.WebSocket || S.MozWebSocket;
|
|
700
|
+
class Kt extends Wt {
|
|
701
701
|
createSocket(e, t, s) {
|
|
702
|
-
return
|
|
702
|
+
return ft ? new be(e, t, s) : t ? new be(e, t) : new be(e);
|
|
703
703
|
}
|
|
704
704
|
doWrite(e, t) {
|
|
705
705
|
this.ws.send(t);
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
|
-
class
|
|
708
|
+
class zt extends Me {
|
|
709
709
|
get name() {
|
|
710
710
|
return "webtransport";
|
|
711
711
|
}
|
|
@@ -721,11 +721,11 @@ class Tt extends me {
|
|
|
721
721
|
this.onError("webtransport error", e);
|
|
722
722
|
}), this._transport.ready.then(() => {
|
|
723
723
|
this._transport.createBidirectionalStream().then((e) => {
|
|
724
|
-
const t =
|
|
724
|
+
const t = Nt(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = e.readable.pipeThrough(t).getReader(), r = Ct();
|
|
725
725
|
r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
|
|
726
726
|
const i = () => {
|
|
727
|
-
s.read().then(({ done: h, value:
|
|
728
|
-
h || (this.onPacket(
|
|
727
|
+
s.read().then(({ done: h, value: f }) => {
|
|
728
|
+
h || (this.onPacket(f), i());
|
|
729
729
|
}).catch((h) => {
|
|
730
730
|
});
|
|
731
731
|
};
|
|
@@ -740,7 +740,7 @@ class Tt extends me {
|
|
|
740
740
|
for (let t = 0; t < e.length; t++) {
|
|
741
741
|
const s = e[t], r = t === e.length - 1;
|
|
742
742
|
this._writer.write(s).then(() => {
|
|
743
|
-
r &&
|
|
743
|
+
r && ye(() => {
|
|
744
744
|
this.writable = !0, this.emitReserved("drain");
|
|
745
745
|
}, this.setTimeoutFn);
|
|
746
746
|
});
|
|
@@ -751,11 +751,11 @@ class Tt extends me {
|
|
|
751
751
|
(e = this._transport) === null || e === void 0 || e.close();
|
|
752
752
|
}
|
|
753
753
|
}
|
|
754
|
-
const
|
|
755
|
-
websocket:
|
|
756
|
-
webtransport:
|
|
757
|
-
polling:
|
|
758
|
-
},
|
|
754
|
+
const Xt = {
|
|
755
|
+
websocket: Kt,
|
|
756
|
+
webtransport: zt,
|
|
757
|
+
polling: Yt
|
|
758
|
+
}, Qt = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Zt = [
|
|
759
759
|
"source",
|
|
760
760
|
"protocol",
|
|
761
761
|
"authority",
|
|
@@ -771,31 +771,31 @@ const Et = {
|
|
|
771
771
|
"query",
|
|
772
772
|
"anchor"
|
|
773
773
|
];
|
|
774
|
-
function
|
|
774
|
+
function Ae(n) {
|
|
775
775
|
if (n.length > 8e3)
|
|
776
776
|
throw "URI too long";
|
|
777
777
|
const e = n, t = n.indexOf("["), s = n.indexOf("]");
|
|
778
778
|
t != -1 && s != -1 && (n = n.substring(0, t) + n.substring(t, s).replace(/:/g, ";") + n.substring(s, n.length));
|
|
779
|
-
let r =
|
|
779
|
+
let r = Qt.exec(n || ""), i = {}, o = 14;
|
|
780
780
|
for (; o--; )
|
|
781
|
-
i[
|
|
782
|
-
return t != -1 && s != -1 && (i.source = e, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames =
|
|
781
|
+
i[Zt[o]] = r[o] || "";
|
|
782
|
+
return t != -1 && s != -1 && (i.source = e, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = es(i, i.path), i.queryKey = ts(i, i.query), i;
|
|
783
783
|
}
|
|
784
|
-
function
|
|
784
|
+
function es(n, e) {
|
|
785
785
|
const t = /\/{2,9}/g, s = e.replace(t, "/").split("/");
|
|
786
786
|
return (e.slice(0, 1) == "/" || e.length === 0) && s.splice(0, 1), e.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
|
|
787
787
|
}
|
|
788
|
-
function
|
|
788
|
+
function ts(n, e) {
|
|
789
789
|
const t = {};
|
|
790
790
|
return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, r, i) {
|
|
791
791
|
r && (t[r] = i);
|
|
792
792
|
}), t;
|
|
793
793
|
}
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
794
|
+
const Se = typeof addEventListener == "function" && typeof removeEventListener == "function", he = [];
|
|
795
|
+
Se && addEventListener("offline", () => {
|
|
796
|
+
he.forEach((n) => n());
|
|
797
797
|
}, !1);
|
|
798
|
-
class
|
|
798
|
+
class M extends w {
|
|
799
799
|
/**
|
|
800
800
|
* Socket constructor.
|
|
801
801
|
*
|
|
@@ -803,11 +803,11 @@ class R extends g {
|
|
|
803
803
|
* @param {Object} opts - options
|
|
804
804
|
*/
|
|
805
805
|
constructor(e, t) {
|
|
806
|
-
if (super(), this.binaryType =
|
|
807
|
-
const s =
|
|
806
|
+
if (super(), this.binaryType = Bt, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, e && typeof e == "object" && (t = e, e = null), e) {
|
|
807
|
+
const s = Ae(e);
|
|
808
808
|
t.hostname = s.host, t.secure = s.protocol === "https" || s.protocol === "wss", t.port = s.port, s.query && (t.query = s.query);
|
|
809
|
-
} else t.host && (t.hostname =
|
|
810
|
-
|
|
809
|
+
} else t.host && (t.hostname = Ae(t.host).host);
|
|
810
|
+
me(this, t), this.secure = t.secure != null ? t.secure : typeof location < "u" && location.protocol === "https:", t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((s) => {
|
|
811
811
|
const r = s.prototype.name;
|
|
812
812
|
this.transports.push(r), this._transportsByName[r] = s;
|
|
813
813
|
}), this.opts = Object.assign({
|
|
@@ -824,13 +824,13 @@ class R extends g {
|
|
|
824
824
|
},
|
|
825
825
|
transportOptions: {},
|
|
826
826
|
closeOnBeforeunload: !1
|
|
827
|
-
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query =
|
|
827
|
+
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Ft(this.opts.query)), Se && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
828
828
|
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
829
829
|
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
830
830
|
this._onClose("transport close", {
|
|
831
831
|
description: "network connection lost"
|
|
832
832
|
});
|
|
833
|
-
},
|
|
833
|
+
}, he.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
|
|
834
834
|
}
|
|
835
835
|
/**
|
|
836
836
|
* Creates transport of the given type.
|
|
@@ -841,7 +841,7 @@ class R extends g {
|
|
|
841
841
|
*/
|
|
842
842
|
createTransport(e) {
|
|
843
843
|
const t = Object.assign({}, this.opts.query);
|
|
844
|
-
t.EIO =
|
|
844
|
+
t.EIO = at, t.transport = e, this.id && (t.sid = this.id);
|
|
845
845
|
const s = Object.assign({}, this.opts, {
|
|
846
846
|
query: t,
|
|
847
847
|
socket: this,
|
|
@@ -863,7 +863,7 @@ class R extends g {
|
|
|
863
863
|
}, 0);
|
|
864
864
|
return;
|
|
865
865
|
}
|
|
866
|
-
const e = this.opts.rememberUpgrade &&
|
|
866
|
+
const e = this.opts.rememberUpgrade && M.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
|
|
867
867
|
this.readyState = "opening";
|
|
868
868
|
const t = this.createTransport(e);
|
|
869
869
|
t.open(), this.setTransport(t);
|
|
@@ -882,7 +882,7 @@ class R extends g {
|
|
|
882
882
|
* @private
|
|
883
883
|
*/
|
|
884
884
|
onOpen() {
|
|
885
|
-
this.readyState = "open",
|
|
885
|
+
this.readyState = "open", M.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
|
|
886
886
|
}
|
|
887
887
|
/**
|
|
888
888
|
* Handles a packet.
|
|
@@ -959,7 +959,7 @@ class R extends g {
|
|
|
959
959
|
let t = 1;
|
|
960
960
|
for (let s = 0; s < this.writeBuffer.length; s++) {
|
|
961
961
|
const r = this.writeBuffer[s].data;
|
|
962
|
-
if (r && (t +=
|
|
962
|
+
if (r && (t += qt(r)), s > 0 && t > this._maxPayload)
|
|
963
963
|
return this.writeBuffer.slice(0, s);
|
|
964
964
|
t += 2;
|
|
965
965
|
}
|
|
@@ -979,7 +979,7 @@ class R extends g {
|
|
|
979
979
|
if (!this._pingTimeoutTime)
|
|
980
980
|
return !0;
|
|
981
981
|
const e = Date.now() > this._pingTimeoutTime;
|
|
982
|
-
return e && (this._pingTimeoutTime = 0,
|
|
982
|
+
return e && (this._pingTimeoutTime = 0, ye(() => {
|
|
983
983
|
this._onClose("ping timeout");
|
|
984
984
|
}, this.setTimeoutFn)), e;
|
|
985
985
|
}
|
|
@@ -1046,7 +1046,7 @@ class R extends g {
|
|
|
1046
1046
|
* @private
|
|
1047
1047
|
*/
|
|
1048
1048
|
_onError(e) {
|
|
1049
|
-
if (
|
|
1049
|
+
if (M.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
|
|
1050
1050
|
return this.transports.shift(), this._open();
|
|
1051
1051
|
this.emitReserved("error", e), this._onClose("transport error", e);
|
|
1052
1052
|
}
|
|
@@ -1057,16 +1057,16 @@ class R extends g {
|
|
|
1057
1057
|
*/
|
|
1058
1058
|
_onClose(e, t) {
|
|
1059
1059
|
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
|
|
1060
|
-
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(),
|
|
1061
|
-
const s =
|
|
1062
|
-
s !== -1 &&
|
|
1060
|
+
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Se && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
1061
|
+
const s = he.indexOf(this._offlineEventListener);
|
|
1062
|
+
s !== -1 && he.splice(s, 1);
|
|
1063
1063
|
}
|
|
1064
1064
|
this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
1067
|
}
|
|
1068
|
-
|
|
1069
|
-
class
|
|
1068
|
+
M.protocol = at;
|
|
1069
|
+
class ss extends M {
|
|
1070
1070
|
constructor() {
|
|
1071
1071
|
super(...arguments), this._upgrades = [];
|
|
1072
1072
|
}
|
|
@@ -1083,42 +1083,42 @@ class St extends R {
|
|
|
1083
1083
|
*/
|
|
1084
1084
|
_probe(e) {
|
|
1085
1085
|
let t = this.createTransport(e), s = !1;
|
|
1086
|
-
|
|
1086
|
+
M.priorWebsocketSuccess = !1;
|
|
1087
1087
|
const r = () => {
|
|
1088
|
-
s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (
|
|
1088
|
+
s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (g) => {
|
|
1089
1089
|
if (!s)
|
|
1090
|
-
if (
|
|
1090
|
+
if (g.type === "pong" && g.data === "probe") {
|
|
1091
1091
|
if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
|
|
1092
1092
|
return;
|
|
1093
|
-
|
|
1094
|
-
s || this.readyState !== "closed" && (
|
|
1093
|
+
M.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
|
|
1094
|
+
s || this.readyState !== "closed" && (y(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
|
|
1095
1095
|
});
|
|
1096
1096
|
} else {
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1097
|
+
const R = new Error("probe error");
|
|
1098
|
+
R.transport = t.name, this.emitReserved("upgradeError", R);
|
|
1099
1099
|
}
|
|
1100
1100
|
}));
|
|
1101
1101
|
};
|
|
1102
1102
|
function i() {
|
|
1103
|
-
s || (s = !0,
|
|
1103
|
+
s || (s = !0, y(), t.close(), t = null);
|
|
1104
1104
|
}
|
|
1105
|
-
const o = (
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1105
|
+
const o = (g) => {
|
|
1106
|
+
const R = new Error("probe error: " + g);
|
|
1107
|
+
R.transport = t.name, i(), this.emitReserved("upgradeError", R);
|
|
1108
1108
|
};
|
|
1109
1109
|
function h() {
|
|
1110
1110
|
o("transport closed");
|
|
1111
1111
|
}
|
|
1112
|
-
function
|
|
1112
|
+
function f() {
|
|
1113
1113
|
o("socket closed");
|
|
1114
1114
|
}
|
|
1115
|
-
function
|
|
1116
|
-
t &&
|
|
1115
|
+
function m(g) {
|
|
1116
|
+
t && g.name !== t.name && i();
|
|
1117
1117
|
}
|
|
1118
|
-
const
|
|
1119
|
-
t.removeListener("open", r), t.removeListener("error", o), t.removeListener("close", h), this.off("close",
|
|
1118
|
+
const y = () => {
|
|
1119
|
+
t.removeListener("open", r), t.removeListener("error", o), t.removeListener("close", h), this.off("close", f), this.off("upgrading", m);
|
|
1120
1120
|
};
|
|
1121
|
-
t.once("open", r), t.once("error", o), t.once("close", h), this.once("close",
|
|
1121
|
+
t.once("open", r), t.once("error", o), t.once("close", h), this.once("close", f), this.once("upgrading", m), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
|
|
1122
1122
|
s || t.open();
|
|
1123
1123
|
}, 200) : t.open();
|
|
1124
1124
|
}
|
|
@@ -1138,67 +1138,67 @@ class St extends R {
|
|
|
1138
1138
|
return t;
|
|
1139
1139
|
}
|
|
1140
1140
|
}
|
|
1141
|
-
let
|
|
1141
|
+
let ns = class extends ss {
|
|
1142
1142
|
constructor(e, t = {}) {
|
|
1143
1143
|
const s = typeof e == "object", r = s ? { ...e } : { ...t };
|
|
1144
|
-
(!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) =>
|
|
1144
|
+
(!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => Xt[i]).filter((i) => !!i)), super(s ? r : e, r);
|
|
1145
1145
|
}
|
|
1146
1146
|
};
|
|
1147
|
-
function
|
|
1147
|
+
function rs(n, e = "", t) {
|
|
1148
1148
|
let s = n;
|
|
1149
|
-
t = t || typeof location < "u" && location, n == null && (n = t.protocol + "//" + t.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = t.protocol + n : n = t.host + n), /^(https?|wss?):\/\//.test(n) || (typeof t < "u" ? n = t.protocol + "//" + n : n = "https://" + n), s =
|
|
1149
|
+
t = t || typeof location < "u" && location, n == null && (n = t.protocol + "//" + t.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = t.protocol + n : n = t.host + n), /^(https?|wss?):\/\//.test(n) || (typeof t < "u" ? n = t.protocol + "//" + n : n = "https://" + n), s = Ae(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
|
|
1150
1150
|
const i = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
|
|
1151
1151
|
return s.id = s.protocol + "://" + i + ":" + s.port + e, s.href = s.protocol + "://" + i + (t && t.port === s.port ? "" : ":" + s.port), s;
|
|
1152
1152
|
}
|
|
1153
|
-
const
|
|
1154
|
-
function
|
|
1155
|
-
return
|
|
1153
|
+
const is = typeof ArrayBuffer == "function", os = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, dt = Object.prototype.toString, as = typeof Blob == "function" || typeof Blob < "u" && dt.call(Blob) === "[object BlobConstructor]", cs = typeof File == "function" || typeof File < "u" && dt.call(File) === "[object FileConstructor]";
|
|
1154
|
+
function He(n) {
|
|
1155
|
+
return is && (n instanceof ArrayBuffer || os(n)) || as && n instanceof Blob || cs && n instanceof File;
|
|
1156
1156
|
}
|
|
1157
|
-
function
|
|
1157
|
+
function ue(n, e) {
|
|
1158
1158
|
if (!n || typeof n != "object")
|
|
1159
1159
|
return !1;
|
|
1160
1160
|
if (Array.isArray(n)) {
|
|
1161
1161
|
for (let t = 0, s = n.length; t < s; t++)
|
|
1162
|
-
if (
|
|
1162
|
+
if (ue(n[t]))
|
|
1163
1163
|
return !0;
|
|
1164
1164
|
return !1;
|
|
1165
1165
|
}
|
|
1166
|
-
if (
|
|
1166
|
+
if (He(n))
|
|
1167
1167
|
return !0;
|
|
1168
1168
|
if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
|
|
1169
|
-
return
|
|
1169
|
+
return ue(n.toJSON(), !0);
|
|
1170
1170
|
for (const t in n)
|
|
1171
|
-
if (Object.prototype.hasOwnProperty.call(n, t) &&
|
|
1171
|
+
if (Object.prototype.hasOwnProperty.call(n, t) && ue(n[t]))
|
|
1172
1172
|
return !0;
|
|
1173
1173
|
return !1;
|
|
1174
1174
|
}
|
|
1175
|
-
function
|
|
1175
|
+
function hs(n) {
|
|
1176
1176
|
const e = [], t = n.data, s = n;
|
|
1177
|
-
return s.data =
|
|
1177
|
+
return s.data = Oe(t, e), s.attachments = e.length, { packet: s, buffers: e };
|
|
1178
1178
|
}
|
|
1179
|
-
function
|
|
1179
|
+
function Oe(n, e) {
|
|
1180
1180
|
if (!n)
|
|
1181
1181
|
return n;
|
|
1182
|
-
if (
|
|
1182
|
+
if (He(n)) {
|
|
1183
1183
|
const t = { _placeholder: !0, num: e.length };
|
|
1184
1184
|
return e.push(n), t;
|
|
1185
1185
|
} else if (Array.isArray(n)) {
|
|
1186
1186
|
const t = new Array(n.length);
|
|
1187
1187
|
for (let s = 0; s < n.length; s++)
|
|
1188
|
-
t[s] =
|
|
1188
|
+
t[s] = Oe(n[s], e);
|
|
1189
1189
|
return t;
|
|
1190
1190
|
} else if (typeof n == "object" && !(n instanceof Date)) {
|
|
1191
1191
|
const t = {};
|
|
1192
1192
|
for (const s in n)
|
|
1193
|
-
Object.prototype.hasOwnProperty.call(n, s) && (t[s] =
|
|
1193
|
+
Object.prototype.hasOwnProperty.call(n, s) && (t[s] = Oe(n[s], e));
|
|
1194
1194
|
return t;
|
|
1195
1195
|
}
|
|
1196
1196
|
return n;
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1199
|
-
return n.data =
|
|
1198
|
+
function us(n, e) {
|
|
1199
|
+
return n.data = $e(n.data, e), delete n.attachments, n;
|
|
1200
1200
|
}
|
|
1201
|
-
function
|
|
1201
|
+
function $e(n, e) {
|
|
1202
1202
|
if (!n)
|
|
1203
1203
|
return n;
|
|
1204
1204
|
if (n && n._placeholder === !0) {
|
|
@@ -1207,13 +1207,13 @@ function ce(n, e) {
|
|
|
1207
1207
|
throw new Error("illegal attachments");
|
|
1208
1208
|
} else if (Array.isArray(n))
|
|
1209
1209
|
for (let t = 0; t < n.length; t++)
|
|
1210
|
-
n[t] =
|
|
1210
|
+
n[t] = $e(n[t], e);
|
|
1211
1211
|
else if (typeof n == "object")
|
|
1212
1212
|
for (const t in n)
|
|
1213
|
-
Object.prototype.hasOwnProperty.call(n, t) && (n[t] =
|
|
1213
|
+
Object.prototype.hasOwnProperty.call(n, t) && (n[t] = $e(n[t], e));
|
|
1214
1214
|
return n;
|
|
1215
1215
|
}
|
|
1216
|
-
const
|
|
1216
|
+
const ls = [
|
|
1217
1217
|
"connect",
|
|
1218
1218
|
// used on the client side
|
|
1219
1219
|
"connect_error",
|
|
@@ -1231,7 +1231,7 @@ var p;
|
|
|
1231
1231
|
(function(n) {
|
|
1232
1232
|
n[n.CONNECT = 0] = "CONNECT", n[n.DISCONNECT = 1] = "DISCONNECT", n[n.EVENT = 2] = "EVENT", n[n.ACK = 3] = "ACK", n[n.CONNECT_ERROR = 4] = "CONNECT_ERROR", n[n.BINARY_EVENT = 5] = "BINARY_EVENT", n[n.BINARY_ACK = 6] = "BINARY_ACK";
|
|
1233
1233
|
})(p || (p = {}));
|
|
1234
|
-
class
|
|
1234
|
+
class fs {
|
|
1235
1235
|
/**
|
|
1236
1236
|
* Encoder constructor
|
|
1237
1237
|
*
|
|
@@ -1247,7 +1247,7 @@ class qt {
|
|
|
1247
1247
|
* @param {Object} obj - packet object
|
|
1248
1248
|
*/
|
|
1249
1249
|
encode(e) {
|
|
1250
|
-
return (e.type === p.EVENT || e.type === p.ACK) &&
|
|
1250
|
+
return (e.type === p.EVENT || e.type === p.ACK) && ue(e) ? this.encodeAsBinary({
|
|
1251
1251
|
type: e.type === p.EVENT ? p.BINARY_EVENT : p.BINARY_ACK,
|
|
1252
1252
|
nsp: e.nsp,
|
|
1253
1253
|
data: e.data,
|
|
@@ -1267,11 +1267,11 @@ class qt {
|
|
|
1267
1267
|
* a list of buffers.
|
|
1268
1268
|
*/
|
|
1269
1269
|
encodeAsBinary(e) {
|
|
1270
|
-
const t =
|
|
1270
|
+
const t = hs(e), s = this.encodeAsString(t.packet), r = t.buffers;
|
|
1271
1271
|
return r.unshift(s), r;
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
|
-
class
|
|
1274
|
+
class je extends w {
|
|
1275
1275
|
/**
|
|
1276
1276
|
* Decoder constructor
|
|
1277
1277
|
*/
|
|
@@ -1293,8 +1293,8 @@ class we extends g {
|
|
|
1293
1293
|
throw new Error("got plaintext data when reconstructing a packet");
|
|
1294
1294
|
t = this.decodeString(e);
|
|
1295
1295
|
const s = t.type === p.BINARY_EVENT;
|
|
1296
|
-
s || t.type === p.BINARY_ACK ? (t.type = s ? p.EVENT : p.ACK, this.reconstructor = new
|
|
1297
|
-
} else if (
|
|
1296
|
+
s || t.type === p.BINARY_ACK ? (t.type = s ? p.EVENT : p.ACK, this.reconstructor = new ds(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
|
|
1297
|
+
} else if (He(e) || e.base64)
|
|
1298
1298
|
if (this.reconstructor)
|
|
1299
1299
|
t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
|
|
1300
1300
|
else
|
|
@@ -1323,7 +1323,7 @@ class we extends g {
|
|
|
1323
1323
|
if (o != Number(o) || e.charAt(t) !== "-")
|
|
1324
1324
|
throw new Error("Illegal attachments");
|
|
1325
1325
|
const h = Number(o);
|
|
1326
|
-
if (!
|
|
1326
|
+
if (!ps(h) || h < 0)
|
|
1327
1327
|
throw new Error("Illegal attachments");
|
|
1328
1328
|
if (h > this.opts.maxAttachments)
|
|
1329
1329
|
throw new Error("too many attachments");
|
|
@@ -1352,7 +1352,7 @@ class we extends g {
|
|
|
1352
1352
|
}
|
|
1353
1353
|
if (e.charAt(++t)) {
|
|
1354
1354
|
const i = this.tryParse(e.substr(t));
|
|
1355
|
-
if (
|
|
1355
|
+
if (je.isPayloadValid(s.type, i))
|
|
1356
1356
|
s.data = i;
|
|
1357
1357
|
else
|
|
1358
1358
|
throw new Error("invalid payload");
|
|
@@ -1369,14 +1369,14 @@ class we extends g {
|
|
|
1369
1369
|
static isPayloadValid(e, t) {
|
|
1370
1370
|
switch (e) {
|
|
1371
1371
|
case p.CONNECT:
|
|
1372
|
-
return
|
|
1372
|
+
return Qe(t);
|
|
1373
1373
|
case p.DISCONNECT:
|
|
1374
1374
|
return t === void 0;
|
|
1375
1375
|
case p.CONNECT_ERROR:
|
|
1376
|
-
return typeof t == "string" ||
|
|
1376
|
+
return typeof t == "string" || Qe(t);
|
|
1377
1377
|
case p.EVENT:
|
|
1378
1378
|
case p.BINARY_EVENT:
|
|
1379
|
-
return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" &&
|
|
1379
|
+
return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && ls.indexOf(t[0]) === -1);
|
|
1380
1380
|
case p.ACK:
|
|
1381
1381
|
case p.BINARY_ACK:
|
|
1382
1382
|
return Array.isArray(t);
|
|
@@ -1389,7 +1389,7 @@ class we extends g {
|
|
|
1389
1389
|
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
1392
|
-
class
|
|
1392
|
+
class ds {
|
|
1393
1393
|
constructor(e) {
|
|
1394
1394
|
this.packet = e, this.buffers = [], this.reconPack = e;
|
|
1395
1395
|
}
|
|
@@ -1403,7 +1403,7 @@ class Ut {
|
|
|
1403
1403
|
*/
|
|
1404
1404
|
takeBinaryData(e) {
|
|
1405
1405
|
if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
|
|
1406
|
-
const t =
|
|
1406
|
+
const t = us(this.reconPack, this.buffers);
|
|
1407
1407
|
return this.finishedReconstruction(), t;
|
|
1408
1408
|
}
|
|
1409
1409
|
return null;
|
|
@@ -1415,26 +1415,26 @@ class Ut {
|
|
|
1415
1415
|
this.reconPack = null, this.buffers = [];
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
|
-
const
|
|
1418
|
+
const ps = Number.isInteger || function(n) {
|
|
1419
1419
|
return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
|
|
1420
1420
|
};
|
|
1421
|
-
function
|
|
1421
|
+
function Qe(n) {
|
|
1422
1422
|
return Object.prototype.toString.call(n) === "[object Object]";
|
|
1423
1423
|
}
|
|
1424
|
-
const
|
|
1424
|
+
const ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1425
1425
|
__proto__: null,
|
|
1426
|
-
Decoder:
|
|
1427
|
-
Encoder:
|
|
1426
|
+
Decoder: je,
|
|
1427
|
+
Encoder: fs,
|
|
1428
1428
|
get PacketType() {
|
|
1429
1429
|
return p;
|
|
1430
1430
|
}
|
|
1431
1431
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1432
|
-
function
|
|
1432
|
+
function $(n, e, t) {
|
|
1433
1433
|
return n.on(e, t), function() {
|
|
1434
1434
|
n.off(e, t);
|
|
1435
1435
|
};
|
|
1436
1436
|
}
|
|
1437
|
-
const
|
|
1437
|
+
const ms = Object.freeze({
|
|
1438
1438
|
connect: 1,
|
|
1439
1439
|
connect_error: 1,
|
|
1440
1440
|
disconnect: 1,
|
|
@@ -1443,7 +1443,7 @@ const Mt = Object.freeze({
|
|
|
1443
1443
|
newListener: 1,
|
|
1444
1444
|
removeListener: 1
|
|
1445
1445
|
});
|
|
1446
|
-
class
|
|
1446
|
+
class pt extends w {
|
|
1447
1447
|
/**
|
|
1448
1448
|
* `Socket` constructor.
|
|
1449
1449
|
*/
|
|
@@ -1477,10 +1477,10 @@ class je extends g {
|
|
|
1477
1477
|
return;
|
|
1478
1478
|
const e = this.io;
|
|
1479
1479
|
this.subs = [
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1480
|
+
$(e, "open", this.onopen.bind(this)),
|
|
1481
|
+
$(e, "packet", this.onpacket.bind(this)),
|
|
1482
|
+
$(e, "error", this.onerror.bind(this)),
|
|
1483
|
+
$(e, "close", this.onclose.bind(this))
|
|
1484
1484
|
];
|
|
1485
1485
|
}
|
|
1486
1486
|
/**
|
|
@@ -1559,7 +1559,7 @@ class je extends g {
|
|
|
1559
1559
|
*/
|
|
1560
1560
|
emit(e, ...t) {
|
|
1561
1561
|
var s, r, i;
|
|
1562
|
-
if (
|
|
1562
|
+
if (ms.hasOwnProperty(e))
|
|
1563
1563
|
throw new Error('"' + e.toString() + '" is a reserved event name');
|
|
1564
1564
|
if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
|
|
1565
1565
|
return this._addToQueue(t), this;
|
|
@@ -1568,11 +1568,11 @@ class je extends g {
|
|
|
1568
1568
|
data: t
|
|
1569
1569
|
};
|
|
1570
1570
|
if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
|
|
1571
|
-
const
|
|
1572
|
-
this._registerAckCallback(
|
|
1571
|
+
const y = this.ids++, g = t.pop();
|
|
1572
|
+
this._registerAckCallback(y, g), o.id = y;
|
|
1573
1573
|
}
|
|
1574
|
-
const h = (r = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || r === void 0 ? void 0 : r.writable,
|
|
1575
|
-
return this.flags.volatile && !h || (
|
|
1574
|
+
const h = (r = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || r === void 0 ? void 0 : r.writable, f = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
|
|
1575
|
+
return this.flags.volatile && !h || (f ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
|
|
1576
1576
|
}
|
|
1577
1577
|
/**
|
|
1578
1578
|
* @private
|
|
@@ -2035,10 +2035,10 @@ class je extends g {
|
|
|
2035
2035
|
}
|
|
2036
2036
|
}
|
|
2037
2037
|
}
|
|
2038
|
-
function
|
|
2038
|
+
function Q(n) {
|
|
2039
2039
|
n = n || {}, this.ms = n.min || 100, this.max = n.max || 1e4, this.factor = n.factor || 2, this.jitter = n.jitter > 0 && n.jitter <= 1 ? n.jitter : 0, this.attempts = 0;
|
|
2040
2040
|
}
|
|
2041
|
-
|
|
2041
|
+
Q.prototype.duration = function() {
|
|
2042
2042
|
var n = this.ms * Math.pow(this.factor, this.attempts++);
|
|
2043
2043
|
if (this.jitter) {
|
|
2044
2044
|
var e = Math.random(), t = Math.floor(e * this.jitter * n);
|
|
@@ -2046,27 +2046,27 @@ P.prototype.duration = function() {
|
|
|
2046
2046
|
}
|
|
2047
2047
|
return Math.min(n, this.max) | 0;
|
|
2048
2048
|
};
|
|
2049
|
-
|
|
2049
|
+
Q.prototype.reset = function() {
|
|
2050
2050
|
this.attempts = 0;
|
|
2051
2051
|
};
|
|
2052
|
-
|
|
2052
|
+
Q.prototype.setMin = function(n) {
|
|
2053
2053
|
this.ms = n;
|
|
2054
2054
|
};
|
|
2055
|
-
|
|
2055
|
+
Q.prototype.setMax = function(n) {
|
|
2056
2056
|
this.max = n;
|
|
2057
2057
|
};
|
|
2058
|
-
|
|
2058
|
+
Q.prototype.setJitter = function(n) {
|
|
2059
2059
|
this.jitter = n;
|
|
2060
2060
|
};
|
|
2061
|
-
class
|
|
2061
|
+
class Re extends w {
|
|
2062
2062
|
constructor(e, t) {
|
|
2063
2063
|
var s;
|
|
2064
|
-
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t,
|
|
2064
|
+
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t, me(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor((s = t.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new Q({
|
|
2065
2065
|
min: this.reconnectionDelay(),
|
|
2066
2066
|
max: this.reconnectionDelayMax(),
|
|
2067
2067
|
jitter: this.randomizationFactor()
|
|
2068
2068
|
}), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
|
|
2069
|
-
const r = t.parser ||
|
|
2069
|
+
const r = t.parser || ys;
|
|
2070
2070
|
this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
|
|
2071
2071
|
}
|
|
2072
2072
|
reconnection(e) {
|
|
@@ -2109,20 +2109,20 @@ class he extends g {
|
|
|
2109
2109
|
open(e) {
|
|
2110
2110
|
if (~this._readyState.indexOf("open"))
|
|
2111
2111
|
return this;
|
|
2112
|
-
this.engine = new
|
|
2112
|
+
this.engine = new ns(this.uri, this.opts);
|
|
2113
2113
|
const t = this.engine, s = this;
|
|
2114
2114
|
this._readyState = "opening", this.skipReconnect = !1;
|
|
2115
|
-
const r =
|
|
2115
|
+
const r = $(t, "open", function() {
|
|
2116
2116
|
s.onopen(), e && e();
|
|
2117
2117
|
}), i = (h) => {
|
|
2118
2118
|
this.cleanup(), this._readyState = "closed", this.emitReserved("error", h), e ? e(h) : this.maybeReconnectOnOpen();
|
|
2119
|
-
}, o =
|
|
2119
|
+
}, o = $(t, "error", i);
|
|
2120
2120
|
if (this._timeout !== !1) {
|
|
2121
|
-
const h = this._timeout,
|
|
2121
|
+
const h = this._timeout, f = this.setTimeoutFn(() => {
|
|
2122
2122
|
r(), i(new Error("timeout")), t.close();
|
|
2123
2123
|
}, h);
|
|
2124
|
-
this.opts.autoUnref &&
|
|
2125
|
-
this.clearTimeoutFn(
|
|
2124
|
+
this.opts.autoUnref && f.unref(), this.subs.push(() => {
|
|
2125
|
+
this.clearTimeoutFn(f);
|
|
2126
2126
|
});
|
|
2127
2127
|
}
|
|
2128
2128
|
return this.subs.push(r), this.subs.push(o), this;
|
|
@@ -2145,12 +2145,12 @@ class he extends g {
|
|
|
2145
2145
|
this.cleanup(), this._readyState = "open", this.emitReserved("open");
|
|
2146
2146
|
const e = this.engine;
|
|
2147
2147
|
this.subs.push(
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2148
|
+
$(e, "ping", this.onping.bind(this)),
|
|
2149
|
+
$(e, "data", this.ondata.bind(this)),
|
|
2150
|
+
$(e, "error", this.onerror.bind(this)),
|
|
2151
|
+
$(e, "close", this.onclose.bind(this)),
|
|
2152
2152
|
// @ts-ignore
|
|
2153
|
-
|
|
2153
|
+
$(this.decoder, "decoded", this.ondecoded.bind(this))
|
|
2154
2154
|
);
|
|
2155
2155
|
}
|
|
2156
2156
|
/**
|
|
@@ -2179,7 +2179,7 @@ class he extends g {
|
|
|
2179
2179
|
* @private
|
|
2180
2180
|
*/
|
|
2181
2181
|
ondecoded(e) {
|
|
2182
|
-
|
|
2182
|
+
ye(() => {
|
|
2183
2183
|
this.emitReserved("packet", e);
|
|
2184
2184
|
}, this.setTimeoutFn);
|
|
2185
2185
|
}
|
|
@@ -2199,7 +2199,7 @@ class he extends g {
|
|
|
2199
2199
|
*/
|
|
2200
2200
|
socket(e, t) {
|
|
2201
2201
|
let s = this.nsps[e];
|
|
2202
|
-
return s ? this._autoConnect && !s.active && s.connect() : (s = new
|
|
2202
|
+
return s ? this._autoConnect && !s.active && s.connect() : (s = new pt(this, e, t), this.nsps[e] = s), s;
|
|
2203
2203
|
}
|
|
2204
2204
|
/**
|
|
2205
2205
|
* Called upon a socket close.
|
|
@@ -2296,21 +2296,21 @@ class he extends g {
|
|
|
2296
2296
|
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
|
|
2297
2297
|
}
|
|
2298
2298
|
}
|
|
2299
|
-
const
|
|
2300
|
-
function
|
|
2299
|
+
const Z = {};
|
|
2300
|
+
function se(n, e) {
|
|
2301
2301
|
typeof n == "object" && (e = n, n = void 0), e = e || {};
|
|
2302
|
-
const t =
|
|
2303
|
-
let
|
|
2304
|
-
return h ?
|
|
2305
|
-
}
|
|
2306
|
-
Object.assign(
|
|
2307
|
-
Manager:
|
|
2308
|
-
Socket:
|
|
2309
|
-
io:
|
|
2310
|
-
connect:
|
|
2302
|
+
const t = rs(n, e.path || "/socket.io"), s = t.source, r = t.id, i = t.path, o = Z[r] && i in Z[r].nsps, h = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
|
|
2303
|
+
let f;
|
|
2304
|
+
return h ? f = new Re(s, e) : (Z[r] || (Z[r] = new Re(s, e)), f = Z[r]), t.query && !e.query && (e.query = t.queryKey), f.socket(t.path, e);
|
|
2305
|
+
}
|
|
2306
|
+
Object.assign(se, {
|
|
2307
|
+
Manager: Re,
|
|
2308
|
+
Socket: pt,
|
|
2309
|
+
io: se,
|
|
2310
|
+
connect: se
|
|
2311
2311
|
});
|
|
2312
|
-
const
|
|
2313
|
-
function
|
|
2312
|
+
const Ze = 100;
|
|
2313
|
+
function gs(n) {
|
|
2314
2314
|
try {
|
|
2315
2315
|
const e = JSON.parse(n);
|
|
2316
2316
|
if (e && typeof e == "object") {
|
|
@@ -2325,29 +2325,29 @@ function Vt(n) {
|
|
|
2325
2325
|
}
|
|
2326
2326
|
return {};
|
|
2327
2327
|
}
|
|
2328
|
-
function
|
|
2328
|
+
function ws(n) {
|
|
2329
2329
|
if (!n || typeof n != "object") return;
|
|
2330
2330
|
const e = n.retryAfter;
|
|
2331
2331
|
return typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : void 0;
|
|
2332
2332
|
}
|
|
2333
|
-
class
|
|
2333
|
+
class Ve extends Error {
|
|
2334
2334
|
constructor(t, s, r, i) {
|
|
2335
|
-
const o =
|
|
2335
|
+
const o = gs(r);
|
|
2336
2336
|
super(o.message ?? `${s || "Request failed"} (${t})`);
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2337
|
+
T(this, "status");
|
|
2338
|
+
T(this, "code");
|
|
2339
|
+
T(this, "details");
|
|
2340
|
+
T(this, "body");
|
|
2341
2341
|
/**
|
|
2342
2342
|
* Seconds to wait before retrying, taken from the `Retry-After` header or
|
|
2343
2343
|
* from `details.retryAfter`. Only present on rate-limited (429) responses.
|
|
2344
2344
|
*/
|
|
2345
|
-
|
|
2346
|
-
this.name = "RequestError", this.status = t, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ??
|
|
2345
|
+
T(this, "retryAfter");
|
|
2346
|
+
this.name = "RequestError", this.status = t, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? ws(o.details);
|
|
2347
2347
|
}
|
|
2348
2348
|
}
|
|
2349
|
-
const
|
|
2350
|
-
function
|
|
2349
|
+
const C = "item/folder", d = "item", L = "processor", _s = "npm-registry", B = "hidden", Ee = "FILE", Te = "TOOL", ve = "APP", bs = 500, et = 3e4, Es = 0.25, Ts = (n) => new Promise((e) => setTimeout(e, n));
|
|
2350
|
+
function vs(n) {
|
|
2351
2351
|
var r, i;
|
|
2352
2352
|
const e = (i = (r = n.headers) == null ? void 0 : r.get) == null ? void 0 : i.call(r, "Retry-After");
|
|
2353
2353
|
if (!e) return;
|
|
@@ -2357,18 +2357,18 @@ function Kt(n) {
|
|
|
2357
2357
|
if (!Number.isNaN(s))
|
|
2358
2358
|
return Math.max(0, (s - Date.now()) / 1e3);
|
|
2359
2359
|
}
|
|
2360
|
-
function
|
|
2361
|
-
return n instanceof
|
|
2360
|
+
function ks(n) {
|
|
2361
|
+
return n instanceof Ve ? n.status === 429 || n.status >= 500 : !0;
|
|
2362
2362
|
}
|
|
2363
|
-
function
|
|
2363
|
+
function As(n, e) {
|
|
2364
2364
|
const t = Math.min(
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
), s = t *
|
|
2368
|
-
return r != null ? Math.min(r,
|
|
2365
|
+
bs * 2 ** e,
|
|
2366
|
+
et
|
|
2367
|
+
), s = t * Es * Math.random(), r = n instanceof Ve && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
|
|
2368
|
+
return r != null ? Math.min(r, et) + s : t + s;
|
|
2369
2369
|
}
|
|
2370
|
-
var
|
|
2371
|
-
const
|
|
2370
|
+
var c, Ne, l, q, te, le, fe, Pe, Be, yt;
|
|
2371
|
+
const Je = class Je {
|
|
2372
2372
|
/**
|
|
2373
2373
|
* Creates a new EngineServicesClient instance.
|
|
2374
2374
|
* @param accessToken - API access token (obtained from the platform dashboard)
|
|
@@ -2377,30 +2377,30 @@ const be = class be {
|
|
|
2377
2377
|
* @param props - Optional configuration (retry count, auth mode, etc.).
|
|
2378
2378
|
*/
|
|
2379
2379
|
constructor(e, t, s) {
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2380
|
+
_(this, c);
|
|
2381
|
+
T(this, "apiUrl");
|
|
2382
|
+
T(this, "accessToken");
|
|
2383
|
+
T(this, "wsUrl");
|
|
2384
|
+
T(this, "retries");
|
|
2385
|
+
T(this, "useBearer");
|
|
2386
|
+
T(this, "builtInGlobals", null);
|
|
2387
2387
|
/**
|
|
2388
2388
|
* URL of a local execution server (e.g. `http://localhost:4001`).
|
|
2389
2389
|
* When set, execution methods are routed to this server instead of the cloud API.
|
|
2390
2390
|
* Set to `null` to disable local routing and use the cloud API.
|
|
2391
2391
|
*/
|
|
2392
|
-
|
|
2392
|
+
T(this, "localServerUrl", null);
|
|
2393
2393
|
/**
|
|
2394
2394
|
* The platform context this client was created with.
|
|
2395
2395
|
* Contains `appId`, `projectId`, `accessToken`, and `apiUrl`.
|
|
2396
2396
|
* Populated automatically when using {@link fromPlatformContext}.
|
|
2397
2397
|
*/
|
|
2398
|
-
|
|
2398
|
+
T(this, "context");
|
|
2399
2399
|
const { retries: r = 0, useBearer: i = !1, localServerUrl: o } = s || {};
|
|
2400
2400
|
let h = t;
|
|
2401
2401
|
if (h.charAt(h.length - 1) === "/" && (h = h.slice(0, -1)), this.apiUrl = `${h}/api`, this.accessToken = e, this.wsUrl = `${h}?accessToken=${e}`, this.retries = r, this.useBearer = i, this.context = { appId: "", projectId: "", accessToken: e, apiUrl: t }, o) {
|
|
2402
|
-
let
|
|
2403
|
-
|
|
2402
|
+
let f = o;
|
|
2403
|
+
f.charAt(f.length - 1) === "/" && (f = f.slice(0, -1)), this.localServerUrl = f;
|
|
2404
2404
|
}
|
|
2405
2405
|
}
|
|
2406
2406
|
/**
|
|
@@ -2420,7 +2420,7 @@ const be = class be {
|
|
|
2420
2420
|
* ```
|
|
2421
2421
|
*/
|
|
2422
2422
|
static fromPlatformContext(e) {
|
|
2423
|
-
const t = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new
|
|
2423
|
+
const t = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new Je(t.accessToken, t.apiUrl, {
|
|
2424
2424
|
...e,
|
|
2425
2425
|
useBearer: !0
|
|
2426
2426
|
});
|
|
@@ -2492,7 +2492,7 @@ const be = class be {
|
|
|
2492
2492
|
* cleaning logic is applied identically.
|
|
2493
2493
|
*/
|
|
2494
2494
|
async request(e, t, s) {
|
|
2495
|
-
return
|
|
2495
|
+
return a(this, c, l).call(this, e, t, s);
|
|
2496
2496
|
}
|
|
2497
2497
|
// ─── Files ───────────────────────────────────────────────────────
|
|
2498
2498
|
/**
|
|
@@ -2502,9 +2502,9 @@ const be = class be {
|
|
|
2502
2502
|
*/
|
|
2503
2503
|
async listFiles(e) {
|
|
2504
2504
|
const { folderId: t, archived: s, projectId: r } = e || {};
|
|
2505
|
-
return t ? await
|
|
2505
|
+
return t ? await a(this, c, l).call(this, "GET", `${C}/${t}/items`, { query: { itemType: Ee, archived: s } }) : await a(this, c, l).call(this, "GET", `${d}`, {
|
|
2506
2506
|
query: {
|
|
2507
|
-
itemType:
|
|
2507
|
+
itemType: Ee,
|
|
2508
2508
|
archived: s,
|
|
2509
2509
|
...r && { projectId: r }
|
|
2510
2510
|
}
|
|
@@ -2517,7 +2517,7 @@ const be = class be {
|
|
|
2517
2517
|
* @returns The file item, optionally with version history.
|
|
2518
2518
|
*/
|
|
2519
2519
|
async getFile(e, t) {
|
|
2520
|
-
return await
|
|
2520
|
+
return await a(this, c, Be).call(this, e, t);
|
|
2521
2521
|
}
|
|
2522
2522
|
/**
|
|
2523
2523
|
* Uploads a new file.
|
|
@@ -2525,7 +2525,7 @@ const be = class be {
|
|
|
2525
2525
|
* @returns The created item and its first version.
|
|
2526
2526
|
*/
|
|
2527
2527
|
async createFile(e) {
|
|
2528
|
-
return await
|
|
2528
|
+
return await a(this, c, fe).call(this, e, Ee);
|
|
2529
2529
|
}
|
|
2530
2530
|
/**
|
|
2531
2531
|
* Updates an existing file. Can rename, move to a different folder,
|
|
@@ -2535,21 +2535,21 @@ const be = class be {
|
|
|
2535
2535
|
* @returns The updated item and/or the new version.
|
|
2536
2536
|
*/
|
|
2537
2537
|
async updateFile(e, t) {
|
|
2538
|
-
return await
|
|
2538
|
+
return await a(this, c, Pe).call(this, e, t);
|
|
2539
2539
|
}
|
|
2540
2540
|
/**
|
|
2541
2541
|
* Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
|
|
2542
2542
|
* @param fileId - The file's unique identifier.
|
|
2543
2543
|
*/
|
|
2544
2544
|
async archiveFile(e) {
|
|
2545
|
-
return await
|
|
2545
|
+
return await a(this, c, l).call(this, "DELETE", `${d}/${e}`);
|
|
2546
2546
|
}
|
|
2547
2547
|
/**
|
|
2548
2548
|
* Recovers a previously archived file.
|
|
2549
2549
|
* @param fileId - The file's unique identifier.
|
|
2550
2550
|
*/
|
|
2551
2551
|
async recoverFile(e) {
|
|
2552
|
-
return await
|
|
2552
|
+
return await a(this, c, l).call(this, "PUT", `${d}/${e}/recover`);
|
|
2553
2553
|
}
|
|
2554
2554
|
/**
|
|
2555
2555
|
* Downloads a file's content. Returns the raw fetch Response.
|
|
@@ -2558,7 +2558,7 @@ const be = class be {
|
|
|
2558
2558
|
* @returns A fetch Response containing the file data.
|
|
2559
2559
|
*/
|
|
2560
2560
|
async downloadFile(e, t) {
|
|
2561
|
-
return await
|
|
2561
|
+
return await a(this, c, le).call(this, e, t);
|
|
2562
2562
|
}
|
|
2563
2563
|
/**
|
|
2564
2564
|
* Retrieves the free-JSON metadata for a specific file version.
|
|
@@ -2569,7 +2569,7 @@ const be = class be {
|
|
|
2569
2569
|
*/
|
|
2570
2570
|
async getFileVersionMetadata(e, t, s) {
|
|
2571
2571
|
const { withDraft: r } = s || {};
|
|
2572
|
-
return await
|
|
2572
|
+
return await a(this, c, l).call(this, "GET", `${d}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
|
|
2573
2573
|
query: {
|
|
2574
2574
|
...r && { withDraft: "true" }
|
|
2575
2575
|
}
|
|
@@ -2582,7 +2582,7 @@ const be = class be {
|
|
|
2582
2582
|
* @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
|
|
2583
2583
|
*/
|
|
2584
2584
|
async updateFileVersionMetadata(e, t, s) {
|
|
2585
|
-
return await
|
|
2585
|
+
return await a(this, c, l).call(this, "PUT", `${d}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
|
|
2586
2586
|
body: JSON.stringify({ metadata: s }),
|
|
2587
2587
|
contentType: "application/json"
|
|
2588
2588
|
});
|
|
@@ -2593,7 +2593,7 @@ const be = class be {
|
|
|
2593
2593
|
* @param versionTag - The version tag.
|
|
2594
2594
|
*/
|
|
2595
2595
|
async deleteFileVersionMetadata(e, t) {
|
|
2596
|
-
return await
|
|
2596
|
+
return await a(this, c, l).call(this, "DELETE", `${d}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`);
|
|
2597
2597
|
}
|
|
2598
2598
|
/**
|
|
2599
2599
|
* Batch variant of {@link getFileVersionMetadata}. Reads the metadata of
|
|
@@ -2610,7 +2610,7 @@ const be = class be {
|
|
|
2610
2610
|
*/
|
|
2611
2611
|
async getFileVersionMetadataBatch(e, t) {
|
|
2612
2612
|
const { withDraft: s } = t || {};
|
|
2613
|
-
return await
|
|
2613
|
+
return await a(this, c, te).call(this, e, async (r) => (await a(this, c, l).call(this, "POST", `${d}/batch/version-metadata`, {
|
|
2614
2614
|
body: JSON.stringify({
|
|
2615
2615
|
entries: r,
|
|
2616
2616
|
...s !== void 0 && { withDraft: s }
|
|
@@ -2626,7 +2626,7 @@ const be = class be {
|
|
|
2626
2626
|
*/
|
|
2627
2627
|
async listFolders(e) {
|
|
2628
2628
|
const { archived: t, parentFolderId: s, projectId: r } = e || {};
|
|
2629
|
-
return await
|
|
2629
|
+
return await a(this, c, l).call(this, "GET", C, {
|
|
2630
2630
|
query: {
|
|
2631
2631
|
parentFolderId: s,
|
|
2632
2632
|
archived: t,
|
|
@@ -2639,7 +2639,7 @@ const be = class be {
|
|
|
2639
2639
|
* @param folderId - The folder's unique identifier.
|
|
2640
2640
|
*/
|
|
2641
2641
|
async getFolder(e) {
|
|
2642
|
-
return await
|
|
2642
|
+
return await a(this, c, l).call(this, "GET", `${C}/${e}`);
|
|
2643
2643
|
}
|
|
2644
2644
|
/**
|
|
2645
2645
|
* Batch variant of {@link getFolder}. Resolves a known set of folder ids in
|
|
@@ -2655,7 +2655,7 @@ const be = class be {
|
|
|
2655
2655
|
* @param folderIds - The folder ids to resolve.
|
|
2656
2656
|
*/
|
|
2657
2657
|
async getFoldersBatch(e) {
|
|
2658
|
-
return await
|
|
2658
|
+
return await a(this, c, te).call(this, e, async (t) => (await a(this, c, l).call(this, "POST", `${d}/batch/folders`, {
|
|
2659
2659
|
body: JSON.stringify({ folderIds: t }),
|
|
2660
2660
|
contentType: "application/json"
|
|
2661
2661
|
})).results);
|
|
@@ -2667,7 +2667,7 @@ const be = class be {
|
|
|
2667
2667
|
* @returns The created folder.
|
|
2668
2668
|
*/
|
|
2669
2669
|
async createFolder(e, t, s) {
|
|
2670
|
-
return await
|
|
2670
|
+
return await a(this, c, l).call(this, "POST", C, {
|
|
2671
2671
|
body: JSON.stringify({
|
|
2672
2672
|
name: e,
|
|
2673
2673
|
...t && { parentId: t },
|
|
@@ -2684,7 +2684,7 @@ const be = class be {
|
|
|
2684
2684
|
*/
|
|
2685
2685
|
async updateFolder(e, t) {
|
|
2686
2686
|
const { name: s } = t;
|
|
2687
|
-
return await
|
|
2687
|
+
return await a(this, c, l).call(this, "PUT", `${C}/${e}`, {
|
|
2688
2688
|
body: JSON.stringify({ name: s }),
|
|
2689
2689
|
contentType: "application/json"
|
|
2690
2690
|
});
|
|
@@ -2694,14 +2694,14 @@ const be = class be {
|
|
|
2694
2694
|
* @param folderId - The folder's unique identifier.
|
|
2695
2695
|
*/
|
|
2696
2696
|
async archiveFolder(e) {
|
|
2697
|
-
return await
|
|
2697
|
+
return await a(this, c, l).call(this, "DELETE", `${C}/${e}`);
|
|
2698
2698
|
}
|
|
2699
2699
|
/**
|
|
2700
2700
|
* Recovers a previously archived folder.
|
|
2701
2701
|
* @param folderId - The folder's unique identifier.
|
|
2702
2702
|
*/
|
|
2703
2703
|
async recoverFolder(e) {
|
|
2704
|
-
return await
|
|
2704
|
+
return await a(this, c, l).call(this, "PUT", `${C}/${e}/recover`);
|
|
2705
2705
|
}
|
|
2706
2706
|
/**
|
|
2707
2707
|
* Downloads an entire folder as a ZIP archive.
|
|
@@ -2709,7 +2709,7 @@ const be = class be {
|
|
|
2709
2709
|
* @returns A fetch Response containing the ZIP data.
|
|
2710
2710
|
*/
|
|
2711
2711
|
async downloadFolder(e) {
|
|
2712
|
-
return await
|
|
2712
|
+
return await a(this, c, q).call(this, `${C}/${e}/download`);
|
|
2713
2713
|
}
|
|
2714
2714
|
// ─── Components ──────────────────────────────────────────────────
|
|
2715
2715
|
/**
|
|
@@ -2719,14 +2719,14 @@ const be = class be {
|
|
|
2719
2719
|
*/
|
|
2720
2720
|
async listComponents(e) {
|
|
2721
2721
|
const { folderId: t, ShowVersions: s, projectId: r } = e || {};
|
|
2722
|
-
return t ? await
|
|
2722
|
+
return t ? await a(this, c, l).call(this, "GET", `${C}/${t}/items`, {
|
|
2723
2723
|
query: {
|
|
2724
|
-
itemType:
|
|
2724
|
+
itemType: Te,
|
|
2725
2725
|
...s && { ShowVersions: s }
|
|
2726
2726
|
}
|
|
2727
|
-
}) : await
|
|
2727
|
+
}) : await a(this, c, l).call(this, "GET", `${d}`, {
|
|
2728
2728
|
query: {
|
|
2729
|
-
itemType:
|
|
2729
|
+
itemType: Te,
|
|
2730
2730
|
...s && { ShowVersions: s },
|
|
2731
2731
|
...r && { projectId: r }
|
|
2732
2732
|
}
|
|
@@ -2738,7 +2738,7 @@ const be = class be {
|
|
|
2738
2738
|
* @param props - Options such as whether to include versions.
|
|
2739
2739
|
*/
|
|
2740
2740
|
async getComponent(e, t) {
|
|
2741
|
-
return await
|
|
2741
|
+
return await a(this, c, Be).call(this, e, t);
|
|
2742
2742
|
}
|
|
2743
2743
|
/**
|
|
2744
2744
|
* Creates a new component with the given file and version properties.
|
|
@@ -2747,7 +2747,7 @@ const be = class be {
|
|
|
2747
2747
|
*/
|
|
2748
2748
|
async createComponent(e) {
|
|
2749
2749
|
const { componentProps: t } = e;
|
|
2750
|
-
return await
|
|
2750
|
+
return await a(this, c, fe).call(this, e, Te, t);
|
|
2751
2751
|
}
|
|
2752
2752
|
/**
|
|
2753
2753
|
* Updates an existing component. Can rename, move, and/or upload a new version.
|
|
@@ -2757,7 +2757,7 @@ const be = class be {
|
|
|
2757
2757
|
*/
|
|
2758
2758
|
async updateComponent(e, t) {
|
|
2759
2759
|
const { componentProps: s } = t;
|
|
2760
|
-
return await
|
|
2760
|
+
return await a(this, c, Pe).call(this, e, t, s);
|
|
2761
2761
|
}
|
|
2762
2762
|
/**
|
|
2763
2763
|
* Downloads a component's full ZIP file. Returns the raw fetch Response.
|
|
@@ -2766,7 +2766,7 @@ const be = class be {
|
|
|
2766
2766
|
* @returns A fetch Response containing the ZIP data.
|
|
2767
2767
|
*/
|
|
2768
2768
|
async downloadComponent(e, t) {
|
|
2769
|
-
return await
|
|
2769
|
+
return await a(this, c, le).call(this, e, t);
|
|
2770
2770
|
}
|
|
2771
2771
|
/**
|
|
2772
2772
|
* Downloads only the JavaScript bundle from a component's ZIP.
|
|
@@ -2777,7 +2777,7 @@ const be = class be {
|
|
|
2777
2777
|
*/
|
|
2778
2778
|
async downloadComponentBundle(e, t) {
|
|
2779
2779
|
const { versionTag: s, withDraft: r } = t || {};
|
|
2780
|
-
return await
|
|
2780
|
+
return await a(this, c, q).call(this, `${d}/${e}/download/bundle`, {
|
|
2781
2781
|
query: {
|
|
2782
2782
|
...s && { versionTag: s },
|
|
2783
2783
|
...r && { withDraft: r }
|
|
@@ -2789,14 +2789,14 @@ const be = class be {
|
|
|
2789
2789
|
* @param componentId - The component's unique identifier.
|
|
2790
2790
|
*/
|
|
2791
2791
|
async archiveComponent(e) {
|
|
2792
|
-
return await
|
|
2792
|
+
return await a(this, c, l).call(this, "DELETE", `${d}/${e}`);
|
|
2793
2793
|
}
|
|
2794
2794
|
/**
|
|
2795
2795
|
* Recovers a previously archived component.
|
|
2796
2796
|
* @param componentId - The component's unique identifier.
|
|
2797
2797
|
*/
|
|
2798
2798
|
async recoverComponent(e) {
|
|
2799
|
-
return await
|
|
2799
|
+
return await a(this, c, l).call(this, "PUT", `${d}/${e}/recover`);
|
|
2800
2800
|
}
|
|
2801
2801
|
// ─── Built-in Components ─────────────────────────────────────────
|
|
2802
2802
|
/**
|
|
@@ -2805,7 +2805,7 @@ const be = class be {
|
|
|
2805
2805
|
* @returns The component's JavaScript source code as a string.
|
|
2806
2806
|
*/
|
|
2807
2807
|
async getBuiltInComponent(e) {
|
|
2808
|
-
return await (await
|
|
2808
|
+
return await (await a(this, c, q).call(this, `built-in/${e}/bundle`)).text();
|
|
2809
2809
|
}
|
|
2810
2810
|
/**
|
|
2811
2811
|
* Fetches a built-in component bundle, evaluates it, and registers it
|
|
@@ -2834,9 +2834,9 @@ const be = class be {
|
|
|
2834
2834
|
* ```
|
|
2835
2835
|
*/
|
|
2836
2836
|
async initBuiltInComponent(e, t, s) {
|
|
2837
|
-
const r = await this.getBuiltInComponent(e.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), h = o.map((
|
|
2838
|
-
return main;`)(...h),
|
|
2839
|
-
t.get(
|
|
2837
|
+
const r = await this.getBuiltInComponent(e.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), h = o.map((g) => i[g]), m = new Function(...o, `${r}
|
|
2838
|
+
return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
2839
|
+
t.get(y);
|
|
2840
2840
|
}
|
|
2841
2841
|
/**
|
|
2842
2842
|
* Loads multiple built-in components in parallel.
|
|
@@ -2903,14 +2903,14 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
2903
2903
|
*/
|
|
2904
2904
|
async listApps(e) {
|
|
2905
2905
|
const { folderId: t, ShowVersions: s, projectId: r } = e || {};
|
|
2906
|
-
return t ? await
|
|
2906
|
+
return t ? await a(this, c, l).call(this, "GET", `${C}/${t}/items`, {
|
|
2907
2907
|
query: {
|
|
2908
|
-
itemType:
|
|
2908
|
+
itemType: ve,
|
|
2909
2909
|
...s && { ShowVersions: s }
|
|
2910
2910
|
}
|
|
2911
|
-
}) : await
|
|
2911
|
+
}) : await a(this, c, l).call(this, "GET", `${d}`, {
|
|
2912
2912
|
query: {
|
|
2913
|
-
itemType:
|
|
2913
|
+
itemType: ve,
|
|
2914
2914
|
...s && { ShowVersions: s },
|
|
2915
2915
|
...r && { projectId: r }
|
|
2916
2916
|
}
|
|
@@ -2923,7 +2923,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
2923
2923
|
*/
|
|
2924
2924
|
async createApp(e) {
|
|
2925
2925
|
const { appProps: t } = e;
|
|
2926
|
-
return await
|
|
2926
|
+
return await a(this, c, fe).call(this, e, ve, t);
|
|
2927
2927
|
}
|
|
2928
2928
|
/**
|
|
2929
2929
|
* Downloads an app's full ZIP file. Returns the raw fetch Response.
|
|
@@ -2932,7 +2932,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
2932
2932
|
* @returns A fetch Response containing the ZIP data.
|
|
2933
2933
|
*/
|
|
2934
2934
|
async downloadApp(e, t) {
|
|
2935
|
-
return await
|
|
2935
|
+
return await a(this, c, le).call(this, e, t);
|
|
2936
2936
|
}
|
|
2937
2937
|
/**
|
|
2938
2938
|
* Downloads only the JavaScript bundle from an app's ZIP.
|
|
@@ -2943,7 +2943,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
2943
2943
|
*/
|
|
2944
2944
|
async downloadAppBundle(e, t) {
|
|
2945
2945
|
const { versionTag: s, withDraft: r } = t || {};
|
|
2946
|
-
return await
|
|
2946
|
+
return await a(this, c, q).call(this, `${d}/${e}/download/bundle`, {
|
|
2947
2947
|
query: {
|
|
2948
2948
|
...s && { versionTag: s },
|
|
2949
2949
|
...r && { withDraft: r }
|
|
@@ -2955,7 +2955,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
2955
2955
|
* @param appId - The app's unique identifier.
|
|
2956
2956
|
*/
|
|
2957
2957
|
async archiveApp(e) {
|
|
2958
|
-
return await
|
|
2958
|
+
return await a(this, c, l).call(this, "DELETE", `${d}/${e}`);
|
|
2959
2959
|
}
|
|
2960
2960
|
// ─── NPM Registry ────────────────────────────────────────────────
|
|
2961
2961
|
/**
|
|
@@ -2967,7 +2967,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
2967
2967
|
* @returns The registry, scope, read-only token, and assembled `.npmrc`.
|
|
2968
2968
|
*/
|
|
2969
2969
|
async getNpmCredentials() {
|
|
2970
|
-
return await
|
|
2970
|
+
return await a(this, c, l).call(this, "GET", `${_s}/credentials`);
|
|
2971
2971
|
}
|
|
2972
2972
|
// ─── Execution ───────────────────────────────────────────────────
|
|
2973
2973
|
/**
|
|
@@ -2986,7 +2986,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
2986
2986
|
*/
|
|
2987
2987
|
async executeComponent(e, t, s) {
|
|
2988
2988
|
if (this.localServerUrl) {
|
|
2989
|
-
const r = `${this.localServerUrl}/api/${
|
|
2989
|
+
const r = `${this.localServerUrl}/api/${L}/${e}/execute`, i = await fetch(r, {
|
|
2990
2990
|
method: "POST",
|
|
2991
2991
|
headers: { "Content-Type": "application/json" },
|
|
2992
2992
|
body: JSON.stringify(t)
|
|
@@ -2999,7 +2999,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
2999
2999
|
}
|
|
3000
3000
|
return await i.json();
|
|
3001
3001
|
}
|
|
3002
|
-
return await
|
|
3002
|
+
return await a(this, c, l).call(this, "POST", `${L}/${e}/execute`, {
|
|
3003
3003
|
body: JSON.stringify(t),
|
|
3004
3004
|
query: { ...s && { versionTag: s } },
|
|
3005
3005
|
contentType: "application/json"
|
|
@@ -3011,7 +3011,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3011
3011
|
*/
|
|
3012
3012
|
async abortExecution(e) {
|
|
3013
3013
|
if (this.localServerUrl) {
|
|
3014
|
-
const t = `${this.localServerUrl}/api/${
|
|
3014
|
+
const t = `${this.localServerUrl}/api/${L}/progress/${e}/abort`, s = await fetch(t, { method: "POST" });
|
|
3015
3015
|
if (!s.ok) {
|
|
3016
3016
|
const r = await s.text().catch(() => "");
|
|
3017
3017
|
throw new Error(
|
|
@@ -3020,7 +3020,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3020
3020
|
}
|
|
3021
3021
|
return await s.json();
|
|
3022
3022
|
}
|
|
3023
|
-
return await
|
|
3023
|
+
return await a(this, c, l).call(this, "POST", `${L}/progress/${e}/abort`);
|
|
3024
3024
|
}
|
|
3025
3025
|
/**
|
|
3026
3026
|
* Lists all executions for a given component.
|
|
@@ -3037,7 +3037,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3037
3037
|
*/
|
|
3038
3038
|
async listExecutions(e, t) {
|
|
3039
3039
|
if (this.localServerUrl) {
|
|
3040
|
-
const s = t ? `?projectId=${encodeURIComponent(t)}` : "", r = `${this.localServerUrl}/api/${
|
|
3040
|
+
const s = t ? `?projectId=${encodeURIComponent(t)}` : "", r = `${this.localServerUrl}/api/${L}/${e}/progress${s}`, i = await fetch(r);
|
|
3041
3041
|
if (!i.ok) {
|
|
3042
3042
|
const o = await i.text().catch(() => "");
|
|
3043
3043
|
throw new Error(
|
|
@@ -3046,7 +3046,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3046
3046
|
}
|
|
3047
3047
|
return await i.json();
|
|
3048
3048
|
}
|
|
3049
|
-
return await
|
|
3049
|
+
return await a(this, c, l).call(this, "GET", `${L}/${e}/progress`, { query: { ...t && { projectId: t } } });
|
|
3050
3050
|
}
|
|
3051
3051
|
/**
|
|
3052
3052
|
* Gets details of a specific execution, including its messages.
|
|
@@ -3055,7 +3055,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3055
3055
|
*/
|
|
3056
3056
|
async getExecution(e) {
|
|
3057
3057
|
if (this.localServerUrl) {
|
|
3058
|
-
const t = `${this.localServerUrl}/api/${
|
|
3058
|
+
const t = `${this.localServerUrl}/api/${L}/progress/${e}`, s = await fetch(t);
|
|
3059
3059
|
if (!s.ok) {
|
|
3060
3060
|
const r = await s.text().catch(() => "");
|
|
3061
3061
|
throw new Error(
|
|
@@ -3064,7 +3064,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3064
3064
|
}
|
|
3065
3065
|
return await s.json();
|
|
3066
3066
|
}
|
|
3067
|
-
return await
|
|
3067
|
+
return await a(this, c, l).call(this, "GET", `${L}/progress/${e}`);
|
|
3068
3068
|
}
|
|
3069
3069
|
/**
|
|
3070
3070
|
* Subscribes to real-time execution progress via WebSocket.
|
|
@@ -3073,7 +3073,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3073
3073
|
* @param onUpdateCallback - Callback invoked on each progress/result event.
|
|
3074
3074
|
*/
|
|
3075
3075
|
async onExecutionProgress(e, t) {
|
|
3076
|
-
const s = this.localServerUrl ? `${this.localServerUrl}?accessToken=${this.accessToken}` : this.wsUrl, r = await
|
|
3076
|
+
const s = this.localServerUrl ? `${this.localServerUrl}?accessToken=${this.accessToken}` : this.wsUrl, r = await se(s, {
|
|
3077
3077
|
...this.localServerUrl && { transports: ["websocket"] }
|
|
3078
3078
|
});
|
|
3079
3079
|
r.on("connect", function() {
|
|
@@ -3093,7 +3093,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3093
3093
|
*/
|
|
3094
3094
|
async createHiddenFile(e, t) {
|
|
3095
3095
|
const s = new FormData();
|
|
3096
|
-
return s.append("file", e), s.append("parentItemId", t), await
|
|
3096
|
+
return s.append("file", e), s.append("parentItemId", t), await a(this, c, l).call(this, "POST", `${d}/${B}`, {
|
|
3097
3097
|
body: s
|
|
3098
3098
|
});
|
|
3099
3099
|
}
|
|
@@ -3109,7 +3109,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3109
3109
|
const s = new FormData();
|
|
3110
3110
|
for (const r of e)
|
|
3111
3111
|
s.append("files", r);
|
|
3112
|
-
return s.append("parentItemId", t), await
|
|
3112
|
+
return s.append("parentItemId", t), await a(this, c, l).call(this, "POST", `${d}/${B}/batch`, {
|
|
3113
3113
|
body: s
|
|
3114
3114
|
});
|
|
3115
3115
|
}
|
|
@@ -3118,21 +3118,21 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3118
3118
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3119
3119
|
*/
|
|
3120
3120
|
async deleteHiddenFile(e) {
|
|
3121
|
-
return await
|
|
3121
|
+
return await a(this, c, l).call(this, "DELETE", `${d}/${B}/${e}`);
|
|
3122
3122
|
}
|
|
3123
3123
|
/**
|
|
3124
3124
|
* Gets metadata for a hidden file.
|
|
3125
3125
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3126
3126
|
*/
|
|
3127
3127
|
async getHiddenFile(e) {
|
|
3128
|
-
return await
|
|
3128
|
+
return await a(this, c, l).call(this, "GET", `${d}/${B}/${e}`);
|
|
3129
3129
|
}
|
|
3130
3130
|
/**
|
|
3131
3131
|
* Downloads a hidden file's content. Returns the raw fetch Response.
|
|
3132
3132
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3133
3133
|
*/
|
|
3134
3134
|
async downloadHiddenFile(e) {
|
|
3135
|
-
return await
|
|
3135
|
+
return await a(this, c, q).call(this, `${d}/${B}/${e}/download`);
|
|
3136
3136
|
}
|
|
3137
3137
|
/**
|
|
3138
3138
|
* Mints a short-lived presigned URL for a hidden file so the browser can
|
|
@@ -3152,7 +3152,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3152
3152
|
* an ISO timestamp when it stops working.
|
|
3153
3153
|
*/
|
|
3154
3154
|
async getHiddenFileSignedUrl(e, t) {
|
|
3155
|
-
return await
|
|
3155
|
+
return await a(this, c, l).call(this, "GET", `${d}/${B}/${e}/signed-url`, { ...t != null && { query: { expiresIn: t } } });
|
|
3156
3156
|
}
|
|
3157
3157
|
/**
|
|
3158
3158
|
* Batch variant of {@link getHiddenFileSignedUrl}. Mints presigned URLs for
|
|
@@ -3173,7 +3173,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3173
3173
|
* 900 (15 min) server-side; values are clamped to that range.
|
|
3174
3174
|
*/
|
|
3175
3175
|
async getHiddenFileSignedUrlsBatch(e, t) {
|
|
3176
|
-
return await
|
|
3176
|
+
return await a(this, c, te).call(this, e, async (s) => (await a(this, c, l).call(this, "POST", `${d}/${B}/signed-url/batch`, {
|
|
3177
3177
|
body: JSON.stringify({
|
|
3178
3178
|
hiddenFileIds: s,
|
|
3179
3179
|
...t != null && { expiresIn: t }
|
|
@@ -3187,14 +3187,14 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3187
3187
|
* @returns Array of hidden file entities.
|
|
3188
3188
|
*/
|
|
3189
3189
|
async getHiddenFilesByParent(e) {
|
|
3190
|
-
return await
|
|
3190
|
+
return await a(this, c, l).call(this, "GET", `${d}/${e}/${B}`);
|
|
3191
3191
|
}
|
|
3192
3192
|
/**
|
|
3193
3193
|
* Deletes all hidden files attached to a parent item.
|
|
3194
3194
|
* @param parentFileId - The parent item's unique identifier.
|
|
3195
3195
|
*/
|
|
3196
3196
|
async deleteHiddenFilesByParent(e) {
|
|
3197
|
-
return await
|
|
3197
|
+
return await a(this, c, l).call(this, "DELETE", `${d}/${e}/${B}`);
|
|
3198
3198
|
}
|
|
3199
3199
|
// ─── Icons ───────────────────────────────────────────────────────
|
|
3200
3200
|
/**
|
|
@@ -3206,7 +3206,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3206
3206
|
*/
|
|
3207
3207
|
async uploadItemIcon(e, t) {
|
|
3208
3208
|
const s = new FormData();
|
|
3209
|
-
return s.append("icon", t), await
|
|
3209
|
+
return s.append("icon", t), await a(this, c, l).call(this, "PUT", `${d}/${e}/icon`, {
|
|
3210
3210
|
body: s
|
|
3211
3211
|
});
|
|
3212
3212
|
}
|
|
@@ -3216,7 +3216,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3216
3216
|
* @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
|
|
3217
3217
|
*/
|
|
3218
3218
|
async getItemIcon(e) {
|
|
3219
|
-
return await
|
|
3219
|
+
return await a(this, c, q).call(this, `${d}/${e}/icon`);
|
|
3220
3220
|
}
|
|
3221
3221
|
/**
|
|
3222
3222
|
* Removes the icon from an item.
|
|
@@ -3224,7 +3224,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3224
3224
|
* @returns The updated item with icon fields removed.
|
|
3225
3225
|
*/
|
|
3226
3226
|
async removeItemIcon(e) {
|
|
3227
|
-
return await
|
|
3227
|
+
return await a(this, c, l).call(this, "DELETE", `${d}/${e}/icon`);
|
|
3228
3228
|
}
|
|
3229
3229
|
// ─── General Item Operations ─────────────────────────────────────
|
|
3230
3230
|
/**
|
|
@@ -3234,7 +3234,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3234
3234
|
* @returns The updated item.
|
|
3235
3235
|
*/
|
|
3236
3236
|
async updateItem(e, t) {
|
|
3237
|
-
return await
|
|
3237
|
+
return await a(this, c, l).call(this, "PUT", `${d}/${e}`, {
|
|
3238
3238
|
body: JSON.stringify(t),
|
|
3239
3239
|
contentType: "application/json"
|
|
3240
3240
|
});
|
|
@@ -3251,7 +3251,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3251
3251
|
*/
|
|
3252
3252
|
async createVersion(e, t, s, r, i) {
|
|
3253
3253
|
const o = new FormData();
|
|
3254
|
-
return o.append("file", t), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await
|
|
3254
|
+
return o.append("file", t), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await a(this, c, l).call(this, "POST", `${d}/${e}/version`, { body: o });
|
|
3255
3255
|
}
|
|
3256
3256
|
/**
|
|
3257
3257
|
* Lists versions of an item. Pass `archived: true` to fetch only archived
|
|
@@ -3261,7 +3261,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3261
3261
|
* @returns Array of versions, sorted by creation date descending.
|
|
3262
3262
|
*/
|
|
3263
3263
|
async listVersions(e, t = {}) {
|
|
3264
|
-
return await
|
|
3264
|
+
return await a(this, c, l).call(this, "GET", `${d}/${encodeURIComponent(e)}/versions`, { query: t });
|
|
3265
3265
|
}
|
|
3266
3266
|
/**
|
|
3267
3267
|
* Batch variant of {@link listVersions}. Lists the versions of many items in
|
|
@@ -3280,7 +3280,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3280
3280
|
*/
|
|
3281
3281
|
async listVersionsBatch(e, t = {}) {
|
|
3282
3282
|
const { archived: s } = t;
|
|
3283
|
-
return await
|
|
3283
|
+
return await a(this, c, te).call(this, e, async (r) => (await a(this, c, l).call(this, "POST", `${d}/batch/versions`, {
|
|
3284
3284
|
body: JSON.stringify({
|
|
3285
3285
|
itemIds: r,
|
|
3286
3286
|
...s !== void 0 && { archived: s }
|
|
@@ -3298,7 +3298,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3298
3298
|
* @returns The archived version.
|
|
3299
3299
|
*/
|
|
3300
3300
|
async archiveVersion(e, t) {
|
|
3301
|
-
return await
|
|
3301
|
+
return await a(this, c, l).call(this, "PUT", `${d}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/archive`);
|
|
3302
3302
|
}
|
|
3303
3303
|
/**
|
|
3304
3304
|
* Recovers a previously archived version, restoring it to the active list.
|
|
@@ -3307,7 +3307,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3307
3307
|
* @returns The recovered version.
|
|
3308
3308
|
*/
|
|
3309
3309
|
async recoverVersion(e, t) {
|
|
3310
|
-
return await
|
|
3310
|
+
return await a(this, c, l).call(this, "PUT", `${d}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/recover`);
|
|
3311
3311
|
}
|
|
3312
3312
|
/**
|
|
3313
3313
|
* Permanently deletes a version, including its file in object storage.
|
|
@@ -3316,54 +3316,54 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
|
|
|
3316
3316
|
* @param versionTag - The version's tag (e.g. "v2").
|
|
3317
3317
|
*/
|
|
3318
3318
|
async deleteVersion(e, t) {
|
|
3319
|
-
return await
|
|
3319
|
+
return await a(this, c, l).call(this, "DELETE", `${d}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}`);
|
|
3320
3320
|
}
|
|
3321
3321
|
};
|
|
3322
|
-
|
|
3322
|
+
c = new WeakSet(), Ne = function(e) {
|
|
3323
3323
|
return `${this.apiUrl}/${e}`;
|
|
3324
|
-
},
|
|
3325
|
-
const { body: r, query: i, contentType: o, retries: h, responseType:
|
|
3326
|
-
...
|
|
3327
|
-
...this.useBearer ? {} : { accessToken:
|
|
3324
|
+
}, l = async function(e, t, s) {
|
|
3325
|
+
const { body: r, query: i, contentType: o, retries: h, responseType: f, retryAttempt: m } = s || {}, y = a(this, c, Ne).call(this, t), g = a(this, c, yt).call(this, i), R = await this.resolveAccessToken(), Et = {
|
|
3326
|
+
...g,
|
|
3327
|
+
...this.useBearer ? {} : { accessToken: R }
|
|
3328
3328
|
};
|
|
3329
3329
|
try {
|
|
3330
|
-
const
|
|
3331
|
-
|
|
3330
|
+
const O = await fetch(
|
|
3331
|
+
y + "?" + new URLSearchParams(Et).toString(),
|
|
3332
3332
|
{
|
|
3333
3333
|
method: e,
|
|
3334
3334
|
headers: {
|
|
3335
3335
|
Accept: "application/json",
|
|
3336
3336
|
...o && { "Content-Type": o },
|
|
3337
|
-
...this.useBearer && { Authorization: `Bearer ${
|
|
3337
|
+
...this.useBearer && { Authorization: `Bearer ${R}` }
|
|
3338
3338
|
},
|
|
3339
3339
|
...r && { body: r }
|
|
3340
3340
|
}
|
|
3341
3341
|
);
|
|
3342
|
-
if (!
|
|
3343
|
-
const
|
|
3344
|
-
throw new
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3342
|
+
if (!O.ok) {
|
|
3343
|
+
const j = await O.text().then((ie) => ie).catch(() => "");
|
|
3344
|
+
throw new Ve(
|
|
3345
|
+
O.status,
|
|
3346
|
+
O.statusText,
|
|
3347
|
+
j,
|
|
3348
|
+
vs(O)
|
|
3349
3349
|
);
|
|
3350
3350
|
}
|
|
3351
|
-
return
|
|
3351
|
+
return f === "blob" ? await O.blob() : O.json().then((j) => j).catch(() => {
|
|
3352
3352
|
});
|
|
3353
|
-
} catch (
|
|
3354
|
-
const
|
|
3355
|
-
if (
|
|
3356
|
-
const
|
|
3357
|
-
return await
|
|
3353
|
+
} catch (O) {
|
|
3354
|
+
const j = h ?? this.retries;
|
|
3355
|
+
if (j > 0 && ks(O)) {
|
|
3356
|
+
const ie = m ?? 0;
|
|
3357
|
+
return await Ts(As(O, ie)), await a(this, c, l).call(this, e, t, {
|
|
3358
3358
|
...s,
|
|
3359
|
-
retries:
|
|
3360
|
-
retryAttempt:
|
|
3359
|
+
retries: j - 1,
|
|
3360
|
+
retryAttempt: ie + 1
|
|
3361
3361
|
});
|
|
3362
3362
|
}
|
|
3363
|
-
throw
|
|
3363
|
+
throw O;
|
|
3364
3364
|
}
|
|
3365
|
-
},
|
|
3366
|
-
const { query: s } = t || {}, r =
|
|
3365
|
+
}, q = async function(e, t) {
|
|
3366
|
+
const { query: s } = t || {}, r = a(this, c, Ne).call(this, e), i = await this.resolveAccessToken(), o = {
|
|
3367
3367
|
...s,
|
|
3368
3368
|
...this.useBearer ? {} : { accessToken: i }
|
|
3369
3369
|
};
|
|
@@ -3376,60 +3376,384 @@ a = new WeakSet(), le = function(e) {
|
|
|
3376
3376
|
}
|
|
3377
3377
|
}
|
|
3378
3378
|
);
|
|
3379
|
-
},
|
|
3379
|
+
}, te = async function(e, t) {
|
|
3380
3380
|
if (!e.length) return [];
|
|
3381
3381
|
const s = [];
|
|
3382
|
-
for (let i = 0; i < e.length; i +=
|
|
3383
|
-
s.push(e.slice(i, i +
|
|
3382
|
+
for (let i = 0; i < e.length; i += Ze)
|
|
3383
|
+
s.push(e.slice(i, i + Ze));
|
|
3384
3384
|
return (await Promise.all(s.map(t))).flat();
|
|
3385
|
-
},
|
|
3385
|
+
}, le = async function(e, t) {
|
|
3386
3386
|
const { versionTag: s, withDraft: r } = t || {};
|
|
3387
|
-
return await
|
|
3387
|
+
return await a(this, c, q).call(this, `${d}/${e}/download`, {
|
|
3388
3388
|
query: {
|
|
3389
3389
|
...s && { versionTag: s },
|
|
3390
3390
|
...r && { withDraft: r }
|
|
3391
3391
|
}
|
|
3392
3392
|
});
|
|
3393
|
-
}, J = async function(e, t, s) {
|
|
3394
|
-
const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: l, metadata: y } = e, d = new FormData();
|
|
3395
|
-
return d.append("file", l), d.append("name", r), d.append("versionTag", i), d.append("itemType", t), o && d.append("folderId", o), h && d.append("projectId", h), s && d.append("extraProps", JSON.stringify(s)), y && d.append("metadata", JSON.stringify(y)), await c(this, a, u).call(this, "POST", f, {
|
|
3396
|
-
body: d
|
|
3397
|
-
});
|
|
3398
3393
|
}, fe = async function(e, t, s) {
|
|
3399
|
-
const { name: r, versionTag: i, parentFolderId: o,
|
|
3400
|
-
|
|
3394
|
+
const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: f, metadata: m } = e, y = new FormData();
|
|
3395
|
+
return y.append("file", f), y.append("name", r), y.append("versionTag", i), y.append("itemType", t), o && y.append("folderId", o), h && y.append("projectId", h), s && y.append("extraProps", JSON.stringify(s)), m && y.append("metadata", JSON.stringify(m)), await a(this, c, l).call(this, "POST", d, {
|
|
3396
|
+
body: y
|
|
3397
|
+
});
|
|
3398
|
+
}, Pe = async function(e, t, s) {
|
|
3399
|
+
const { name: r, versionTag: i, parentFolderId: o, file: h, metadata: f } = t;
|
|
3400
|
+
let m, y;
|
|
3401
3401
|
if (h) {
|
|
3402
|
-
const
|
|
3403
|
-
|
|
3404
|
-
body:
|
|
3402
|
+
const g = new FormData();
|
|
3403
|
+
g.append("file", h), i && g.append("versionTag", i), s && g.append("extraProps", JSON.stringify(s)), f && g.append("metadata", JSON.stringify(f)), y = await a(this, c, l).call(this, "POST", `${d}/${e}/version`, {
|
|
3404
|
+
body: g
|
|
3405
3405
|
});
|
|
3406
3406
|
}
|
|
3407
3407
|
if (r || o) {
|
|
3408
|
-
const
|
|
3408
|
+
const g = {
|
|
3409
3409
|
...r && { name: r },
|
|
3410
3410
|
...o && { folderId: o }
|
|
3411
|
-
},
|
|
3412
|
-
|
|
3413
|
-
body:
|
|
3411
|
+
}, R = JSON.stringify(g);
|
|
3412
|
+
m = await a(this, c, l).call(this, "PUT", `${d}/${e}`, {
|
|
3413
|
+
body: R,
|
|
3414
3414
|
contentType: "application/json"
|
|
3415
3415
|
});
|
|
3416
3416
|
}
|
|
3417
|
-
return { item:
|
|
3418
|
-
},
|
|
3417
|
+
return { item: m, version: y };
|
|
3418
|
+
}, Be = async function(e, t) {
|
|
3419
3419
|
const { showVersions: s = !1 } = t || {};
|
|
3420
|
-
return await
|
|
3420
|
+
return await a(this, c, l).call(this, "GET", `${d}/${e}`, {
|
|
3421
3421
|
query: { showVersions: s }
|
|
3422
3422
|
});
|
|
3423
|
-
},
|
|
3423
|
+
}, yt = function(e) {
|
|
3424
3424
|
return e && Object.entries(e).filter(([, t]) => t !== void 0).reduce(
|
|
3425
3425
|
(t, [s, r]) => (t[s] = r, t),
|
|
3426
3426
|
{}
|
|
3427
3427
|
);
|
|
3428
3428
|
};
|
|
3429
|
-
let
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3429
|
+
let Ce = Je;
|
|
3430
|
+
function Ss() {
|
|
3431
|
+
if (typeof window > "u" || window.parent === window)
|
|
3432
|
+
throw new Error(
|
|
3433
|
+
"client.channel only works inside a That Open app, which runs in an iframe of the platform."
|
|
3434
|
+
);
|
|
3435
|
+
return {
|
|
3436
|
+
post: (n) => window.parent.postMessage(n, "*"),
|
|
3437
|
+
listen: (n) => {
|
|
3438
|
+
const e = (t) => {
|
|
3439
|
+
t.source === window.parent && n(t.data);
|
|
3440
|
+
};
|
|
3441
|
+
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
3442
|
+
}
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
const xe = "channel:", Os = 1e4;
|
|
3446
|
+
function de(n) {
|
|
3447
|
+
try {
|
|
3448
|
+
n();
|
|
3449
|
+
} catch (e) {
|
|
3450
|
+
console.error("[channel] a listener threw:", e);
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
var x, k, A, Y, W, K, v, Ie, Le, G;
|
|
3454
|
+
class mt {
|
|
3455
|
+
constructor(e, t) {
|
|
3456
|
+
_(this, v);
|
|
3457
|
+
_(this, x, !1);
|
|
3458
|
+
_(this, k, []);
|
|
3459
|
+
_(this, A, []);
|
|
3460
|
+
_(this, Y, /* @__PURE__ */ new Set());
|
|
3461
|
+
_(this, W, /* @__PURE__ */ new Set());
|
|
3462
|
+
_(this, K, /* @__PURE__ */ new Set());
|
|
3463
|
+
this.transport = e, this.controls = t;
|
|
3464
|
+
}
|
|
3465
|
+
/** Whether the platform has confirmed this tab is in the room. */
|
|
3466
|
+
get joined() {
|
|
3467
|
+
return u(this, x);
|
|
3468
|
+
}
|
|
3469
|
+
/** Who else is in the room right now, as the platform last reported. */
|
|
3470
|
+
get peers() {
|
|
3471
|
+
return u(this, k);
|
|
3472
|
+
}
|
|
3473
|
+
/**
|
|
3474
|
+
* Enters the room. Resolves when the platform confirms; rejects if it
|
|
3475
|
+
* refuses or does not answer in time. Joining twice is harmless.
|
|
3476
|
+
*/
|
|
3477
|
+
join() {
|
|
3478
|
+
return u(this, x) ? Promise.resolve() : a(this, v, Ie).call(this, "joined", this.controls.join);
|
|
3479
|
+
}
|
|
3480
|
+
/** Leaves the room. Handlers stay registered, so `join()` resumes them. */
|
|
3481
|
+
leave() {
|
|
3482
|
+
return !u(this, x) && !u(this, A).some((e) => e.want === "joined") ? Promise.resolve() : a(this, v, Ie).call(this, "left", this.controls.leave);
|
|
3483
|
+
}
|
|
3484
|
+
/** Fires when `joined` or `peers` changes. Returns a function that stops it. */
|
|
3485
|
+
onChange(e) {
|
|
3486
|
+
return u(this, Y).add(e), () => void u(this, Y).delete(e);
|
|
3487
|
+
}
|
|
3488
|
+
onPeerJoined(e) {
|
|
3489
|
+
return u(this, W).add(e), () => void u(this, W).delete(e);
|
|
3490
|
+
}
|
|
3491
|
+
onPeerLeft(e) {
|
|
3492
|
+
return u(this, K).add(e), () => void u(this, K).delete(e);
|
|
3493
|
+
}
|
|
3494
|
+
/** @internal */
|
|
3495
|
+
applyJoined() {
|
|
3496
|
+
E(this, x, !0), a(this, v, Le).call(this, "joined"), a(this, v, G).call(this);
|
|
3497
|
+
}
|
|
3498
|
+
/** @internal */
|
|
3499
|
+
applyLeft() {
|
|
3500
|
+
E(this, x, !1), E(this, k, []), a(this, v, Le).call(this, "left"), a(this, v, G).call(this);
|
|
3501
|
+
}
|
|
3502
|
+
/** @internal */
|
|
3503
|
+
applyPeers(e) {
|
|
3504
|
+
E(this, k, e), a(this, v, G).call(this);
|
|
3505
|
+
}
|
|
3506
|
+
/** @internal */
|
|
3507
|
+
applyPeerJoined(e) {
|
|
3508
|
+
!u(this, x) || u(this, k).some((t) => t.from === e.from) || (E(this, k, [...u(this, k), e]), u(this, W).forEach((t) => de(() => t(e))), a(this, v, G).call(this));
|
|
3509
|
+
}
|
|
3510
|
+
/** @internal */
|
|
3511
|
+
applyPeerLeft(e) {
|
|
3512
|
+
const t = u(this, k).find((s) => s.from === e);
|
|
3513
|
+
t && (E(this, k, u(this, k).filter((s) => s.from !== e)), u(this, K).forEach((s) => de(() => s(t))), a(this, v, G).call(this));
|
|
3514
|
+
}
|
|
3515
|
+
/** @internal */
|
|
3516
|
+
failPending(e) {
|
|
3517
|
+
const t = u(this, A);
|
|
3518
|
+
return E(this, A, []), t.forEach((s) => {
|
|
3519
|
+
clearTimeout(s.timer), s.reject(e);
|
|
3520
|
+
}), t.length > 0;
|
|
3521
|
+
}
|
|
3522
|
+
post(e) {
|
|
3523
|
+
this.transport.post(e);
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
x = new WeakMap(), k = new WeakMap(), A = new WeakMap(), Y = new WeakMap(), W = new WeakMap(), K = new WeakMap(), v = new WeakSet(), Ie = function(e, t) {
|
|
3527
|
+
return new Promise((s, r) => {
|
|
3528
|
+
const i = {
|
|
3529
|
+
want: e,
|
|
3530
|
+
resolve: s,
|
|
3531
|
+
reject: r,
|
|
3532
|
+
timer: setTimeout(() => {
|
|
3533
|
+
E(this, A, u(this, A).filter((o) => o !== i)), r(
|
|
3534
|
+
new Error(
|
|
3535
|
+
`The platform did not confirm ${e === "joined" ? "joining" : "leaving"} in time.`
|
|
3536
|
+
)
|
|
3537
|
+
);
|
|
3538
|
+
}, Os)
|
|
3539
|
+
};
|
|
3540
|
+
u(this, A).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...t });
|
|
3541
|
+
});
|
|
3542
|
+
}, Le = function(e) {
|
|
3543
|
+
const t = u(this, A).filter((s) => s.want === e);
|
|
3544
|
+
E(this, A, u(this, A).filter((s) => s.want !== e)), t.forEach((s) => {
|
|
3545
|
+
clearTimeout(s.timer), s.resolve();
|
|
3546
|
+
});
|
|
3547
|
+
}, G = function() {
|
|
3548
|
+
u(this, Y).forEach((e) => de(e));
|
|
3549
|
+
};
|
|
3550
|
+
var z;
|
|
3551
|
+
class $s extends mt {
|
|
3552
|
+
/** @internal Use `client.channel.collab()`. */
|
|
3553
|
+
constructor(t) {
|
|
3554
|
+
super(t, {
|
|
3555
|
+
join: { action: "joinCollab" },
|
|
3556
|
+
leave: { action: "leaveCollab" }
|
|
3557
|
+
});
|
|
3558
|
+
_(this, z, /* @__PURE__ */ new Map());
|
|
3559
|
+
}
|
|
3560
|
+
/**
|
|
3561
|
+
* Listens for an event other tabs send. Any number of listeners per event.
|
|
3562
|
+
* @returns a function that removes the listener.
|
|
3563
|
+
*/
|
|
3564
|
+
on(t, s) {
|
|
3565
|
+
const r = u(this, z).get(t) ?? /* @__PURE__ */ new Set();
|
|
3566
|
+
return r.add(s), u(this, z).set(t, r), () => void r.delete(s);
|
|
3567
|
+
}
|
|
3568
|
+
/**
|
|
3569
|
+
* Sends an event to the other tabs in the room. Does nothing while this tab
|
|
3570
|
+
* is not in it, matching what the platform does with a message from outside.
|
|
3571
|
+
*/
|
|
3572
|
+
send(t, s) {
|
|
3573
|
+
if (t.startsWith(xe))
|
|
3574
|
+
throw new Error(`Message types starting with '${xe}' are reserved.`);
|
|
3575
|
+
this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: t, payload: s } });
|
|
3576
|
+
}
|
|
3577
|
+
accepts(t) {
|
|
3578
|
+
return t === void 0 || t === "collab";
|
|
3579
|
+
}
|
|
3580
|
+
async handle(t) {
|
|
3581
|
+
const s = u(this, z).get(t.type);
|
|
3582
|
+
if (!(s != null && s.size)) return { handled: !1 };
|
|
3583
|
+
const r = gt(t);
|
|
3584
|
+
return s.forEach((i) => de(() => i(t.payload, r))), { handled: !0 };
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3587
|
+
z = new WeakMap();
|
|
3588
|
+
var U;
|
|
3589
|
+
class Rs extends mt {
|
|
3590
|
+
/** @internal Use `client.channel.external(kind)`. */
|
|
3591
|
+
constructor(t, s) {
|
|
3592
|
+
super(t, {
|
|
3593
|
+
join: { action: "joinExternal", kind: s },
|
|
3594
|
+
leave: { action: "leaveExternal", kind: s }
|
|
3595
|
+
});
|
|
3596
|
+
_(this, U, /* @__PURE__ */ new Map());
|
|
3597
|
+
this.kind = s;
|
|
3598
|
+
}
|
|
3599
|
+
/**
|
|
3600
|
+
* Handles a command. When the sender asked for an answer, what you return
|
|
3601
|
+
* is sent back to it; if you throw, it gets an error instead of waiting for
|
|
3602
|
+
* a timeout. When it did not ask (a notification), the return value is
|
|
3603
|
+
* ignored.
|
|
3604
|
+
*
|
|
3605
|
+
* One handler per command: a second one for the same name throws, since two
|
|
3606
|
+
* would both try to answer.
|
|
3607
|
+
* @returns a function that removes the handler.
|
|
3608
|
+
*/
|
|
3609
|
+
on(t, s) {
|
|
3610
|
+
if (u(this, U).has(t))
|
|
3611
|
+
throw new Error(
|
|
3612
|
+
`"${t}" already has a handler in this room. Remove it first.`
|
|
3613
|
+
);
|
|
3614
|
+
return u(this, U).set(t, s), () => void u(this, U).delete(t);
|
|
3615
|
+
}
|
|
3616
|
+
accepts(t, s) {
|
|
3617
|
+
return t !== void 0 && t !== "external" ? !1 : this.kind === void 0 || t === void 0 || this.kind === s;
|
|
3618
|
+
}
|
|
3619
|
+
/** @internal Whether this room has any handler at all. */
|
|
3620
|
+
get hasHandlers() {
|
|
3621
|
+
return u(this, U).size > 0;
|
|
3622
|
+
}
|
|
3623
|
+
async handle(t) {
|
|
3624
|
+
const s = u(this, U).get(t.type);
|
|
3625
|
+
if (!s) return { handled: !1 };
|
|
3626
|
+
try {
|
|
3627
|
+
return { handled: !0, value: await s(t.payload, gt(t)) };
|
|
3628
|
+
} catch (r) {
|
|
3629
|
+
return {
|
|
3630
|
+
handled: !0,
|
|
3631
|
+
error: r instanceof Error ? r.message : String(r)
|
|
3632
|
+
};
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
U = new WeakMap();
|
|
3637
|
+
function gt(n) {
|
|
3638
|
+
return {
|
|
3639
|
+
from: n.from,
|
|
3640
|
+
at: n.at,
|
|
3641
|
+
requestId: n.requestId,
|
|
3642
|
+
kind: n.kind
|
|
3643
|
+
};
|
|
3644
|
+
}
|
|
3645
|
+
function Cs(n) {
|
|
3646
|
+
const e = n;
|
|
3647
|
+
if ((e == null ? void 0 : e.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
|
|
3648
|
+
const t = e.message;
|
|
3649
|
+
return !t || typeof t.type != "string" ? null : {
|
|
3650
|
+
type: t.type,
|
|
3651
|
+
requestId: typeof t.requestId == "string" ? t.requestId : void 0,
|
|
3652
|
+
payload: t.payload,
|
|
3653
|
+
at: typeof t.at == "number" ? t.at : Date.now(),
|
|
3654
|
+
from: typeof t.from == "string" ? t.from : "",
|
|
3655
|
+
scope: t.scope === "collab" || t.scope === "external" ? t.scope : void 0,
|
|
3656
|
+
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
3657
|
+
};
|
|
3658
|
+
}
|
|
3659
|
+
var H, ne, I, D, F, b, qe, pe, wt, _t, bt, Ue;
|
|
3660
|
+
class Ns {
|
|
3661
|
+
constructor(e) {
|
|
3662
|
+
_(this, b);
|
|
3663
|
+
_(this, H);
|
|
3664
|
+
_(this, ne);
|
|
3665
|
+
_(this, I);
|
|
3666
|
+
_(this, D, /* @__PURE__ */ new Map());
|
|
3667
|
+
_(this, F, /* @__PURE__ */ new Set());
|
|
3668
|
+
E(this, H, e), E(this, ne, e.listen((t) => void a(this, b, wt).call(this, t)));
|
|
3669
|
+
}
|
|
3670
|
+
/** The collaboration room for this app. Always the same instance. */
|
|
3671
|
+
collab() {
|
|
3672
|
+
return u(this, I) ?? E(this, I, new $s(u(this, H))), u(this, I);
|
|
3673
|
+
}
|
|
3674
|
+
/**
|
|
3675
|
+
* The room for commands from this account's external tools of one `kind`
|
|
3676
|
+
* (`'mcp'`, `'cli'`, `'revit'`…), or from any of them when `kind` is omitted.
|
|
3677
|
+
* Always the same instance for the same kind.
|
|
3678
|
+
*/
|
|
3679
|
+
external(e) {
|
|
3680
|
+
const t = e ?? "";
|
|
3681
|
+
let s = u(this, D).get(t);
|
|
3682
|
+
return s || (s = new Rs(u(this, H), e), u(this, D).set(t, s)), s;
|
|
3683
|
+
}
|
|
3684
|
+
/** Stops listening. For tests and teardown; an app normally never calls it. */
|
|
3685
|
+
dispose() {
|
|
3686
|
+
u(this, ne).call(this);
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
H = new WeakMap(), ne = new WeakMap(), I = new WeakMap(), D = new WeakMap(), F = new WeakMap(), b = new WeakSet(), qe = function() {
|
|
3690
|
+
return [...u(this, I) ? [u(this, I)] : [], ...u(this, D).values()];
|
|
3691
|
+
}, pe = function(e, t) {
|
|
3692
|
+
if (e === "collab") return u(this, I);
|
|
3693
|
+
if (e === "external")
|
|
3694
|
+
return u(this, D).get(typeof t == "string" ? t : "");
|
|
3695
|
+
}, wt = async function(e) {
|
|
3696
|
+
const t = Cs(e);
|
|
3697
|
+
if (t) {
|
|
3698
|
+
if (t.type.startsWith(xe)) {
|
|
3699
|
+
a(this, b, _t).call(this, t);
|
|
3700
|
+
return;
|
|
3701
|
+
}
|
|
3702
|
+
await a(this, b, bt).call(this, t);
|
|
3703
|
+
}
|
|
3704
|
+
}, _t = function(e) {
|
|
3705
|
+
var s, r, i;
|
|
3706
|
+
const t = e.payload ?? {};
|
|
3707
|
+
switch (e.type) {
|
|
3708
|
+
case "channel:joined":
|
|
3709
|
+
(s = a(this, b, pe).call(this, t.scope, t.kind)) == null || s.applyJoined();
|
|
3710
|
+
break;
|
|
3711
|
+
case "channel:left":
|
|
3712
|
+
(r = a(this, b, pe).call(this, t.scope, t.kind)) == null || r.applyLeft();
|
|
3713
|
+
break;
|
|
3714
|
+
case "channel:peers":
|
|
3715
|
+
(i = a(this, b, pe).call(this, t.scope, t.kind)) == null || i.applyPeers(t.peers ?? []);
|
|
3716
|
+
break;
|
|
3717
|
+
case "channel:peer-joined":
|
|
3718
|
+
case "channel:peer-left": {
|
|
3719
|
+
if (!t.from) break;
|
|
3720
|
+
const o = t.scope === "collab" ? [u(this, I)] : [...u(this, D).values()].filter(
|
|
3721
|
+
(h) => h.accepts("external", t.kind)
|
|
3722
|
+
);
|
|
3723
|
+
for (const h of o)
|
|
3724
|
+
e.type === "channel:peer-joined" ? h == null || h.applyPeerJoined({ from: t.from, kind: t.kind }) : h == null || h.applyPeerLeft(t.from);
|
|
3725
|
+
break;
|
|
3726
|
+
}
|
|
3727
|
+
case "channel:error": {
|
|
3728
|
+
const o = new Error(String(e.payload));
|
|
3729
|
+
a(this, b, qe).call(this).map((f) => f.failPending(o)).some(Boolean) || console.error("[channel] error:", e.payload);
|
|
3730
|
+
break;
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
}, bt = async function(e) {
|
|
3734
|
+
const t = a(this, b, qe).call(this).filter((i) => i.accepts(e.scope, e.kind));
|
|
3735
|
+
let s = !1;
|
|
3736
|
+
for (const i of t) {
|
|
3737
|
+
const o = await i.handle(e);
|
|
3738
|
+
o.handled && (s = !0, e.requestId && a(this, b, Ue).call(this, e.requestId, o));
|
|
3739
|
+
}
|
|
3740
|
+
e.requestId && e.scope === "external" && t.length > 0 && !s && a(this, b, Ue).call(this, e.requestId, {
|
|
3741
|
+
handled: !0,
|
|
3742
|
+
error: `No handler for "${e.type}".`
|
|
3743
|
+
});
|
|
3744
|
+
}, Ue = function(e, t) {
|
|
3745
|
+
u(this, F).has(e) || (u(this, F).add(e), u(this, F).size > 500 && u(this, F).delete(u(this, F).values().next().value), u(this, H).post({
|
|
3746
|
+
type: "APP_CHANNEL_PUBLISH",
|
|
3747
|
+
message: {
|
|
3748
|
+
type: t.error === void 0 ? "reply" : "reply-error",
|
|
3749
|
+
requestId: e,
|
|
3750
|
+
payload: t.error === void 0 ? t.value : { error: t.error }
|
|
3751
|
+
}
|
|
3752
|
+
}));
|
|
3753
|
+
};
|
|
3754
|
+
const V = "project", J = "notifications";
|
|
3755
|
+
var X, re;
|
|
3756
|
+
const Ge = class Ge extends Ce {
|
|
3433
3757
|
/**
|
|
3434
3758
|
* @param token - A bearer JWT, OR a function returning the current JWT
|
|
3435
3759
|
* (sync or async). When a function is passed, it's invoked before every
|
|
@@ -3440,11 +3764,12 @@ const Te = class Te extends ue {
|
|
|
3440
3764
|
*/
|
|
3441
3765
|
constructor(t, s, r) {
|
|
3442
3766
|
super(typeof t == "string" ? t : "", s, { ...r, useBearer: !0 });
|
|
3443
|
-
|
|
3444
|
-
|
|
3767
|
+
_(this, X);
|
|
3768
|
+
_(this, re);
|
|
3769
|
+
typeof t == "function" && E(this, X, t);
|
|
3445
3770
|
}
|
|
3446
3771
|
async resolveAccessToken() {
|
|
3447
|
-
return
|
|
3772
|
+
return u(this, X) ? await u(this, X).call(this) : super.resolveAccessToken();
|
|
3448
3773
|
}
|
|
3449
3774
|
/**
|
|
3450
3775
|
* Creates a client from the platform context injected into
|
|
@@ -3453,16 +3778,43 @@ const Te = class Te extends ue {
|
|
|
3453
3778
|
* carries a fresh JWT on every navigation.
|
|
3454
3779
|
*/
|
|
3455
3780
|
static fromPlatformContext(t) {
|
|
3456
|
-
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new
|
|
3781
|
+
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new Ge(s.accessToken, s.apiUrl, t);
|
|
3457
3782
|
return r.context = s, r;
|
|
3458
3783
|
}
|
|
3784
|
+
/**
|
|
3785
|
+
* The platform channel, from inside an app: a collaboration room shared with
|
|
3786
|
+
* other users of the app, and rooms for commands from external tools (a CLI,
|
|
3787
|
+
* an MCP server, a Revit plugin). Typed, and built on the `postMessage`
|
|
3788
|
+
* contract with the platform shell — the app never opens a socket.
|
|
3789
|
+
*
|
|
3790
|
+
* Only available in an app running in the platform's iframe; reading it
|
|
3791
|
+
* anywhere else throws. Created on first use.
|
|
3792
|
+
*
|
|
3793
|
+
* @example
|
|
3794
|
+
* ```ts
|
|
3795
|
+
* type McpCommands = {
|
|
3796
|
+
* 'select-by-category': { payload: { category: string }; reply: { count: number } };
|
|
3797
|
+
* };
|
|
3798
|
+
*
|
|
3799
|
+
* const mcp = client.channel.external<McpCommands>('mcp');
|
|
3800
|
+
* mcp.on('select-by-category', async ({ category }) => ({ count: 3 }));
|
|
3801
|
+
* await mcp.join();
|
|
3802
|
+
*
|
|
3803
|
+
* const collab = client.channel.collab();
|
|
3804
|
+
* collab.onPeerLeft(({ from }) => removeAvatar(from));
|
|
3805
|
+
* await collab.join();
|
|
3806
|
+
* ```
|
|
3807
|
+
*/
|
|
3808
|
+
get channel() {
|
|
3809
|
+
return u(this, re) ?? E(this, re, new Ns(Ss())), u(this, re);
|
|
3810
|
+
}
|
|
3459
3811
|
// ─── Projects (JWT-only backend routes) ──────────────────────────
|
|
3460
3812
|
/**
|
|
3461
3813
|
* Gets a project by ID. JWT-only — lives here because
|
|
3462
3814
|
* `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
|
|
3463
3815
|
*/
|
|
3464
3816
|
async getProject(t) {
|
|
3465
|
-
return await this.request("GET", `${
|
|
3817
|
+
return await this.request("GET", `${V}/${t}`);
|
|
3466
3818
|
}
|
|
3467
3819
|
/**
|
|
3468
3820
|
* Gets the full project data (users, roles, files, folders) for a project.
|
|
@@ -3471,7 +3823,7 @@ const Te = class Te extends ue {
|
|
|
3471
3823
|
async getProjectData(t) {
|
|
3472
3824
|
return await this.request(
|
|
3473
3825
|
"GET",
|
|
3474
|
-
`${
|
|
3826
|
+
`${V}/${t}/data`
|
|
3475
3827
|
);
|
|
3476
3828
|
}
|
|
3477
3829
|
// ─── Account ──────────────────────────────────────────────────────
|
|
@@ -3496,7 +3848,7 @@ const Te = class Te extends ue {
|
|
|
3496
3848
|
async checkPermission(t) {
|
|
3497
3849
|
return await this.request(
|
|
3498
3850
|
"GET",
|
|
3499
|
-
`${
|
|
3851
|
+
`${V}/permissions/check`,
|
|
3500
3852
|
{ query: t }
|
|
3501
3853
|
);
|
|
3502
3854
|
}
|
|
@@ -3505,7 +3857,7 @@ const Te = class Te extends ue {
|
|
|
3505
3857
|
* single round-trip; results come back in the same order as `checks`.
|
|
3506
3858
|
*/
|
|
3507
3859
|
async checkPermissionBatch(t) {
|
|
3508
|
-
return (await this.request("POST", `${
|
|
3860
|
+
return (await this.request("POST", `${V}/permissions/check/batch`, {
|
|
3509
3861
|
body: JSON.stringify({ checks: t }),
|
|
3510
3862
|
contentType: "application/json"
|
|
3511
3863
|
})).results;
|
|
@@ -3533,7 +3885,7 @@ const Te = class Te extends ue {
|
|
|
3533
3885
|
* ```
|
|
3534
3886
|
*/
|
|
3535
3887
|
async getNotifications(t) {
|
|
3536
|
-
return await this.request("GET",
|
|
3888
|
+
return await this.request("GET", J, {
|
|
3537
3889
|
query: {
|
|
3538
3890
|
...(t == null ? void 0 : t.cursor) !== void 0 && { cursor: t.cursor },
|
|
3539
3891
|
...(t == null ? void 0 : t.limit) !== void 0 && { limit: String(t.limit) }
|
|
@@ -3547,7 +3899,7 @@ const Te = class Te extends ue {
|
|
|
3547
3899
|
async getUnreadNotificationCount() {
|
|
3548
3900
|
return (await this.request(
|
|
3549
3901
|
"GET",
|
|
3550
|
-
`${
|
|
3902
|
+
`${J}/unread-count`
|
|
3551
3903
|
)).count;
|
|
3552
3904
|
}
|
|
3553
3905
|
/**
|
|
@@ -3558,7 +3910,7 @@ const Te = class Te extends ue {
|
|
|
3558
3910
|
async markNotificationsRead(t) {
|
|
3559
3911
|
return await this.request(
|
|
3560
3912
|
"POST",
|
|
3561
|
-
`${
|
|
3913
|
+
`${J}/mark-read`,
|
|
3562
3914
|
{
|
|
3563
3915
|
body: JSON.stringify({ ids: t }),
|
|
3564
3916
|
contentType: "application/json"
|
|
@@ -3569,7 +3921,7 @@ const Te = class Te extends ue {
|
|
|
3569
3921
|
async markAllNotificationsRead() {
|
|
3570
3922
|
return await this.request(
|
|
3571
3923
|
"POST",
|
|
3572
|
-
`${
|
|
3924
|
+
`${J}/mark-all-read`
|
|
3573
3925
|
);
|
|
3574
3926
|
}
|
|
3575
3927
|
/**
|
|
@@ -3579,7 +3931,7 @@ const Te = class Te extends ue {
|
|
|
3579
3931
|
async getNotificationSubscriptions() {
|
|
3580
3932
|
return await this.request(
|
|
3581
3933
|
"GET",
|
|
3582
|
-
`${
|
|
3934
|
+
`${J}/subscriptions`
|
|
3583
3935
|
);
|
|
3584
3936
|
}
|
|
3585
3937
|
/**
|
|
@@ -3593,7 +3945,7 @@ const Te = class Te extends ue {
|
|
|
3593
3945
|
async unsubscribeFromAutomation(t) {
|
|
3594
3946
|
return await this.request(
|
|
3595
3947
|
"DELETE",
|
|
3596
|
-
`${
|
|
3948
|
+
`${J}/subscriptions/${t}`
|
|
3597
3949
|
);
|
|
3598
3950
|
}
|
|
3599
3951
|
/**
|
|
@@ -3617,7 +3969,7 @@ const Te = class Te extends ue {
|
|
|
3617
3969
|
async subscribeToAutomation(t, s, r) {
|
|
3618
3970
|
return await this.request(
|
|
3619
3971
|
"POST",
|
|
3620
|
-
`${
|
|
3972
|
+
`${V}/${t}/events/hooks/${s}/subscription`,
|
|
3621
3973
|
{
|
|
3622
3974
|
body: JSON.stringify(r ?? {}),
|
|
3623
3975
|
contentType: "application/json"
|
|
@@ -3634,7 +3986,7 @@ const Te = class Te extends ue {
|
|
|
3634
3986
|
async updateAutomationSubscription(t, s, r) {
|
|
3635
3987
|
return await this.request(
|
|
3636
3988
|
"PATCH",
|
|
3637
|
-
`${
|
|
3989
|
+
`${V}/${t}/events/hooks/${s}/subscription`,
|
|
3638
3990
|
{
|
|
3639
3991
|
body: JSON.stringify(r),
|
|
3640
3992
|
contentType: "application/json"
|
|
@@ -3668,7 +4020,7 @@ const Te = class Te extends ue {
|
|
|
3668
4020
|
* ```
|
|
3669
4021
|
*/
|
|
3670
4022
|
async onNotification(t) {
|
|
3671
|
-
const s = await this.resolveAccessToken(), r =
|
|
4023
|
+
const s = await this.resolveAccessToken(), r = se(
|
|
3672
4024
|
`${this.socketOrigin}/notifications?accessToken=${encodeURIComponent(s)}`,
|
|
3673
4025
|
{ transports: ["websocket"] }
|
|
3674
4026
|
);
|
|
@@ -3684,25 +4036,30 @@ const Te = class Te extends ue {
|
|
|
3684
4036
|
), () => r.disconnect();
|
|
3685
4037
|
}
|
|
3686
4038
|
};
|
|
3687
|
-
|
|
3688
|
-
let
|
|
3689
|
-
const
|
|
4039
|
+
X = new WeakMap(), re = new WeakMap();
|
|
4040
|
+
let tt = Ge;
|
|
4041
|
+
const xs = {
|
|
3690
4042
|
MAX_FIELDS: 200,
|
|
3691
4043
|
MAX_KEY_LENGTH: 50,
|
|
3692
4044
|
MAX_VALUE_LENGTH: 50
|
|
3693
|
-
},
|
|
4045
|
+
}, Is = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, Ls = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, qs = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, Us = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, Ds = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, Fs = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, Ms = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, Hs = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
|
|
3694
4046
|
export {
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
4047
|
+
Is as CDEManager,
|
|
4048
|
+
Ns as ChannelClient,
|
|
4049
|
+
mt as ChannelRoom,
|
|
4050
|
+
Ls as ClashesManager,
|
|
4051
|
+
$s as CollabRoom,
|
|
4052
|
+
Ce as EngineServicesClient,
|
|
4053
|
+
Rs as ExternalRoom,
|
|
4054
|
+
qs as FileList,
|
|
4055
|
+
Us as GitHistoryManager,
|
|
4056
|
+
Ds as HelloWorld,
|
|
4057
|
+
xs as METADATA_LIMITS,
|
|
4058
|
+
tt as PlatformClient,
|
|
4059
|
+
Fs as ProjectManager,
|
|
4060
|
+
Ve as RequestError,
|
|
4061
|
+
Ze as STORAGE_BATCH_MAX,
|
|
4062
|
+
Ms as TopicsManager,
|
|
4063
|
+
Hs as UIManager,
|
|
4064
|
+
Ss as windowTransport
|
|
3708
4065
|
};
|