@thatopen/services 0.19.0 → 0.20.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 +59 -1
- package/dist/cli.js +1382 -904
- package/dist/cli.js.map +1 -1
- package/dist/core/client.d.ts +14 -0
- package/dist/core/examples/history.d.ts +4 -0
- package/dist/core/history.d.ts +204 -0
- package/dist/core/recipes.d.ts +98 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1635 -1205
- package/dist/index.es.js.map +1 -1
- package/docs/ai-quickstart.md +5 -2
- package/docs/client/paths.json +4 -0
- package/package.json +1 -1
- package/src/built-in/GISManager/example.ts +29 -0
- package/src/built-in/UIManager/src/settings-panel/example.ts +4 -1
- package/src/built-in/index.ts +59 -3
- package/src/core/examples/history.ts +103 -0
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Xe = Object.defineProperty;
|
|
2
|
+
var fe = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var T = (n,
|
|
7
|
-
var
|
|
5
|
+
var ze = (n, t, e) => t in n ? Xe(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
6
|
+
var T = (n, t, e) => ze(n, typeof t != "symbol" ? t + "" : t, e), Nt = (n, t, e) => t.has(n) || fe("Cannot " + e);
|
|
7
|
+
var l = (n, t, e) => (Nt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), _ = (n, t, e) => t.has(n) ? fe("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), b = (n, t, e, s) => (Nt(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), a = (n, t, e) => (Nt(n, t, "access private method"), e);
|
|
8
8
|
const P = /* @__PURE__ */ Object.create(null);
|
|
9
9
|
P.open = "0";
|
|
10
10
|
P.close = "1";
|
|
@@ -13,92 +13,92 @@ P.pong = "3";
|
|
|
13
13
|
P.message = "4";
|
|
14
14
|
P.upgrade = "5";
|
|
15
15
|
P.noop = "6";
|
|
16
|
-
const
|
|
16
|
+
const bt = /* @__PURE__ */ Object.create(null);
|
|
17
17
|
Object.keys(P).forEach((n) => {
|
|
18
|
-
|
|
18
|
+
bt[P[n]] = n;
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
const s =
|
|
24
|
-
|
|
25
|
-
},
|
|
20
|
+
const Dt = { type: "error", data: "parser error" }, xe = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ie = typeof ArrayBuffer == "function", $e = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, ie = ({ type: n, data: t }, e, s) => xe && t instanceof Blob ? e ? s(t) : pe(t, s) : Ie && (t instanceof ArrayBuffer || $e(t)) ? e ? s(t) : pe(new Blob([t]), s) : s(P[n] + (t || "")), pe = (n, t) => {
|
|
21
|
+
const e = new FileReader();
|
|
22
|
+
return e.onload = function() {
|
|
23
|
+
const s = e.result.split(",")[1];
|
|
24
|
+
t("b" + (s || ""));
|
|
25
|
+
}, e.readAsDataURL(n);
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function ye(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
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
let Pt;
|
|
31
|
+
function Qe(n, t) {
|
|
32
|
+
if (xe && n.data instanceof Blob)
|
|
33
|
+
return n.data.arrayBuffer().then(ye).then(t);
|
|
34
|
+
if (Ie && (n.data instanceof ArrayBuffer || $e(n.data)))
|
|
35
|
+
return t(ye(n.data));
|
|
36
|
+
ie(n, !1, (e) => {
|
|
37
|
+
Pt || (Pt = new TextEncoder()), t(Pt.encode(e));
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
for (let n = 0; n <
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
let
|
|
45
|
-
n[n.length - 1] === "=" && (
|
|
46
|
-
const
|
|
47
|
-
for (s = 0; s <
|
|
48
|
-
i =
|
|
49
|
-
return
|
|
50
|
-
},
|
|
40
|
+
const me = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ot = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
41
|
+
for (let n = 0; n < me.length; n++)
|
|
42
|
+
ot[me.charCodeAt(n)] = n;
|
|
43
|
+
const Ze = (n) => {
|
|
44
|
+
let t = n.length * 0.75, e = n.length, s, r = 0, i, o, h, u;
|
|
45
|
+
n[n.length - 1] === "=" && (t--, n[n.length - 2] === "=" && t--);
|
|
46
|
+
const f = new ArrayBuffer(t), y = new Uint8Array(f);
|
|
47
|
+
for (s = 0; s < e; s += 4)
|
|
48
|
+
i = ot[n.charCodeAt(s)], o = ot[n.charCodeAt(s + 1)], h = ot[n.charCodeAt(s + 2)], u = ot[n.charCodeAt(s + 3)], y[r++] = i << 2 | o >> 4, y[r++] = (o & 15) << 4 | h >> 2, y[r++] = (h & 3) << 6 | u & 63;
|
|
49
|
+
return f;
|
|
50
|
+
}, ts = typeof ArrayBuffer == "function", oe = (n, t) => {
|
|
51
51
|
if (typeof n != "string")
|
|
52
52
|
return {
|
|
53
53
|
type: "message",
|
|
54
|
-
data:
|
|
54
|
+
data: Re(n, t)
|
|
55
55
|
};
|
|
56
|
-
const
|
|
57
|
-
return
|
|
56
|
+
const e = n.charAt(0);
|
|
57
|
+
return e === "b" ? {
|
|
58
58
|
type: "message",
|
|
59
|
-
data:
|
|
60
|
-
} :
|
|
61
|
-
type:
|
|
59
|
+
data: es(n.substring(1), t)
|
|
60
|
+
} : bt[e] ? n.length > 1 ? {
|
|
61
|
+
type: bt[e],
|
|
62
62
|
data: n.substring(1)
|
|
63
63
|
} : {
|
|
64
|
-
type:
|
|
65
|
-
} :
|
|
66
|
-
},
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
return
|
|
64
|
+
type: bt[e]
|
|
65
|
+
} : Dt;
|
|
66
|
+
}, es = (n, t) => {
|
|
67
|
+
if (ts) {
|
|
68
|
+
const e = Ze(n);
|
|
69
|
+
return Re(e, t);
|
|
70
70
|
} else
|
|
71
71
|
return { base64: !0, data: n };
|
|
72
|
-
},
|
|
73
|
-
switch (
|
|
72
|
+
}, Re = (n, t) => {
|
|
73
|
+
switch (t) {
|
|
74
74
|
case "blob":
|
|
75
75
|
return n instanceof Blob ? n : new Blob([n]);
|
|
76
76
|
case "arraybuffer":
|
|
77
77
|
default:
|
|
78
78
|
return n instanceof ArrayBuffer ? n : n.buffer;
|
|
79
79
|
}
|
|
80
|
-
},
|
|
81
|
-
const
|
|
80
|
+
}, Ce = "", ss = (n, t) => {
|
|
81
|
+
const e = n.length, s = new Array(e);
|
|
82
82
|
let r = 0;
|
|
83
83
|
n.forEach((i, o) => {
|
|
84
|
-
|
|
85
|
-
s[o] = h, ++r ===
|
|
84
|
+
ie(i, !1, (h) => {
|
|
85
|
+
s[o] = h, ++r === e && t(s.join(Ce));
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
-
},
|
|
89
|
-
const
|
|
90
|
-
for (let r = 0; r <
|
|
91
|
-
const i =
|
|
88
|
+
}, ns = (n, t) => {
|
|
89
|
+
const e = n.split(Ce), s = [];
|
|
90
|
+
for (let r = 0; r < e.length; r++) {
|
|
91
|
+
const i = oe(e[r], t);
|
|
92
92
|
if (s.push(i), i.type === "error")
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
95
|
return s;
|
|
96
96
|
};
|
|
97
|
-
function
|
|
97
|
+
function rs() {
|
|
98
98
|
return new TransformStream({
|
|
99
|
-
transform(n,
|
|
100
|
-
|
|
101
|
-
const s =
|
|
99
|
+
transform(n, t) {
|
|
100
|
+
Qe(n, (e) => {
|
|
101
|
+
const s = e.length;
|
|
102
102
|
let r;
|
|
103
103
|
if (s < 126)
|
|
104
104
|
r = new Uint8Array(1), new DataView(r.buffer).setUint8(0, s);
|
|
@@ -111,163 +111,163 @@ function $t() {
|
|
|
111
111
|
const i = new DataView(r.buffer);
|
|
112
112
|
i.setUint8(0, 127), i.setBigUint64(1, BigInt(s));
|
|
113
113
|
}
|
|
114
|
-
n.data && typeof n.data != "string" && (r[0] |= 128),
|
|
114
|
+
n.data && typeof n.data != "string" && (r[0] |= 128), t.enqueue(r), t.enqueue(e);
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
let
|
|
120
|
-
function
|
|
121
|
-
return n.reduce((
|
|
119
|
+
let Bt;
|
|
120
|
+
function gt(n) {
|
|
121
|
+
return n.reduce((t, e) => t + e.length, 0);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
if (n[0].length ===
|
|
123
|
+
function wt(n, t) {
|
|
124
|
+
if (n[0].length === t)
|
|
125
125
|
return n.shift();
|
|
126
|
-
const
|
|
126
|
+
const e = new Uint8Array(t);
|
|
127
127
|
let s = 0;
|
|
128
|
-
for (let r = 0; r <
|
|
129
|
-
|
|
130
|
-
return n.length && s < n[0].length && (n[0] = n[0].slice(s)),
|
|
128
|
+
for (let r = 0; r < t; r++)
|
|
129
|
+
e[r] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
|
|
130
|
+
return n.length && s < n[0].length && (n[0] = n[0].slice(s)), e;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
134
|
-
const
|
|
132
|
+
function is(n, t) {
|
|
133
|
+
Bt || (Bt = new TextDecoder());
|
|
134
|
+
const e = [];
|
|
135
135
|
let s = 0, r = -1, i = !1;
|
|
136
136
|
return new TransformStream({
|
|
137
137
|
transform(o, h) {
|
|
138
|
-
for (
|
|
138
|
+
for (e.push(o); ; ) {
|
|
139
139
|
if (s === 0) {
|
|
140
|
-
if (
|
|
140
|
+
if (gt(e) < 1)
|
|
141
141
|
break;
|
|
142
|
-
const
|
|
143
|
-
i = (
|
|
142
|
+
const u = wt(e, 1);
|
|
143
|
+
i = (u[0] & 128) === 128, r = u[0] & 127, r < 126 ? s = 3 : r === 126 ? s = 1 : s = 2;
|
|
144
144
|
} else if (s === 1) {
|
|
145
|
-
if (
|
|
145
|
+
if (gt(e) < 2)
|
|
146
146
|
break;
|
|
147
|
-
const
|
|
148
|
-
r = new DataView(
|
|
147
|
+
const u = wt(e, 2);
|
|
148
|
+
r = new DataView(u.buffer, u.byteOffset, u.length).getUint16(0), s = 3;
|
|
149
149
|
} else if (s === 2) {
|
|
150
|
-
if (
|
|
150
|
+
if (gt(e) < 8)
|
|
151
151
|
break;
|
|
152
|
-
const
|
|
152
|
+
const u = wt(e, 8), f = new DataView(u.buffer, u.byteOffset, u.length), y = f.getUint32(0);
|
|
153
153
|
if (y > Math.pow(2, 21) - 1) {
|
|
154
|
-
h.enqueue(
|
|
154
|
+
h.enqueue(Dt);
|
|
155
155
|
break;
|
|
156
156
|
}
|
|
157
|
-
r = y * Math.pow(2, 32) +
|
|
157
|
+
r = y * Math.pow(2, 32) + f.getUint32(4), s = 3;
|
|
158
158
|
} else {
|
|
159
|
-
if (
|
|
159
|
+
if (gt(e) < r)
|
|
160
160
|
break;
|
|
161
|
-
const
|
|
162
|
-
h.enqueue(
|
|
161
|
+
const u = wt(e, r);
|
|
162
|
+
h.enqueue(oe(i ? u : Bt.decode(u), t)), s = 0;
|
|
163
163
|
}
|
|
164
164
|
if (r === 0 || r > n) {
|
|
165
|
-
h.enqueue(
|
|
165
|
+
h.enqueue(Dt);
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
const
|
|
173
|
-
function
|
|
174
|
-
if (n) return
|
|
172
|
+
const Ne = 4;
|
|
173
|
+
function E(n) {
|
|
174
|
+
if (n) return os(n);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
for (var
|
|
178
|
-
n[
|
|
176
|
+
function os(n) {
|
|
177
|
+
for (var t in E.prototype)
|
|
178
|
+
n[t] = E.prototype[t];
|
|
179
179
|
return n;
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(
|
|
181
|
+
E.prototype.on = E.prototype.addEventListener = function(n, t) {
|
|
182
|
+
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(t), this;
|
|
183
183
|
};
|
|
184
|
-
|
|
185
|
-
function
|
|
186
|
-
this.off(n,
|
|
184
|
+
E.prototype.once = function(n, t) {
|
|
185
|
+
function e() {
|
|
186
|
+
this.off(n, e), t.apply(this, arguments);
|
|
187
187
|
}
|
|
188
|
-
return
|
|
188
|
+
return e.fn = t, this.on(n, e), this;
|
|
189
189
|
};
|
|
190
|
-
|
|
190
|
+
E.prototype.off = E.prototype.removeListener = E.prototype.removeAllListeners = E.prototype.removeEventListener = function(n, t) {
|
|
191
191
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
|
|
192
192
|
return this._callbacks = {}, this;
|
|
193
|
-
var
|
|
194
|
-
if (!
|
|
193
|
+
var e = this._callbacks["$" + n];
|
|
194
|
+
if (!e) return this;
|
|
195
195
|
if (arguments.length == 1)
|
|
196
196
|
return delete this._callbacks["$" + n], this;
|
|
197
|
-
for (var s, r = 0; r <
|
|
198
|
-
if (s =
|
|
199
|
-
|
|
197
|
+
for (var s, r = 0; r < e.length; r++)
|
|
198
|
+
if (s = e[r], s === t || s.fn === t) {
|
|
199
|
+
e.splice(r, 1);
|
|
200
200
|
break;
|
|
201
201
|
}
|
|
202
|
-
return
|
|
202
|
+
return e.length === 0 && delete this._callbacks["$" + n], this;
|
|
203
203
|
};
|
|
204
|
-
|
|
204
|
+
E.prototype.emit = function(n) {
|
|
205
205
|
this._callbacks = this._callbacks || {};
|
|
206
|
-
for (var
|
|
207
|
-
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
for (var s = 0, r =
|
|
211
|
-
|
|
206
|
+
for (var t = new Array(arguments.length - 1), e = this._callbacks["$" + n], s = 1; s < arguments.length; s++)
|
|
207
|
+
t[s - 1] = arguments[s];
|
|
208
|
+
if (e) {
|
|
209
|
+
e = e.slice(0);
|
|
210
|
+
for (var s = 0, r = e.length; s < r; ++s)
|
|
211
|
+
e[s].apply(this, t);
|
|
212
212
|
}
|
|
213
213
|
return this;
|
|
214
214
|
};
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
E.prototype.emitReserved = E.prototype.emit;
|
|
216
|
+
E.prototype.listeners = function(n) {
|
|
217
217
|
return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || [];
|
|
218
218
|
};
|
|
219
|
-
|
|
219
|
+
E.prototype.hasListeners = function(n) {
|
|
220
220
|
return !!this.listeners(n).length;
|
|
221
221
|
};
|
|
222
|
-
const
|
|
223
|
-
function
|
|
224
|
-
return
|
|
222
|
+
const Rt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), A = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), as = "arraybuffer";
|
|
223
|
+
function Pe(n, ...t) {
|
|
224
|
+
return t.reduce((e, s) => (n.hasOwnProperty(s) && (e[s] = n[s]), e), {});
|
|
225
225
|
}
|
|
226
|
-
const
|
|
227
|
-
function
|
|
228
|
-
|
|
226
|
+
const cs = A.setTimeout, hs = A.clearTimeout;
|
|
227
|
+
function Ct(n, t) {
|
|
228
|
+
t.useNativeTimers ? (n.setTimeoutFn = cs.bind(A), n.clearTimeoutFn = hs.bind(A)) : (n.setTimeoutFn = A.setTimeout.bind(A), n.clearTimeoutFn = A.clearTimeout.bind(A));
|
|
229
229
|
}
|
|
230
|
-
const
|
|
231
|
-
function
|
|
232
|
-
return typeof n == "string" ?
|
|
230
|
+
const ls = 1.33;
|
|
231
|
+
function us(n) {
|
|
232
|
+
return typeof n == "string" ? ds(n) : Math.ceil((n.byteLength || n.size) * ls);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
235
|
-
let
|
|
234
|
+
function ds(n) {
|
|
235
|
+
let t = 0, e = 0;
|
|
236
236
|
for (let s = 0, r = n.length; s < r; s++)
|
|
237
|
-
|
|
238
|
-
return
|
|
237
|
+
t = n.charCodeAt(s), t < 128 ? e += 1 : t < 2048 ? e += 2 : t < 55296 || t >= 57344 ? e += 3 : (s++, e += 4);
|
|
238
|
+
return e;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function Be() {
|
|
241
241
|
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
let
|
|
245
|
-
for (let
|
|
246
|
-
n.hasOwnProperty(
|
|
247
|
-
return
|
|
243
|
+
function fs(n) {
|
|
244
|
+
let t = "";
|
|
245
|
+
for (let e in n)
|
|
246
|
+
n.hasOwnProperty(e) && (t.length && (t += "&"), t += encodeURIComponent(e) + "=" + encodeURIComponent(n[e]));
|
|
247
|
+
return t;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
let
|
|
251
|
-
for (let s = 0, r =
|
|
252
|
-
let i =
|
|
253
|
-
|
|
249
|
+
function ps(n) {
|
|
250
|
+
let t = {}, e = n.split("&");
|
|
251
|
+
for (let s = 0, r = e.length; s < r; s++) {
|
|
252
|
+
let i = e[s].split("=");
|
|
253
|
+
t[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
|
|
254
254
|
}
|
|
255
|
-
return
|
|
255
|
+
return t;
|
|
256
256
|
}
|
|
257
|
-
class
|
|
258
|
-
constructor(
|
|
259
|
-
super(
|
|
257
|
+
class ys extends Error {
|
|
258
|
+
constructor(t, e, s) {
|
|
259
|
+
super(t), this.description = e, this.context = s, this.type = "TransportError";
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
class
|
|
262
|
+
class ae extends E {
|
|
263
263
|
/**
|
|
264
264
|
* Transport abstract constructor.
|
|
265
265
|
*
|
|
266
266
|
* @param {Object} opts - options
|
|
267
267
|
* @protected
|
|
268
268
|
*/
|
|
269
|
-
constructor(
|
|
270
|
-
super(), this.writable = !1,
|
|
269
|
+
constructor(t) {
|
|
270
|
+
super(), this.writable = !1, Ct(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* Emits an error.
|
|
@@ -278,8 +278,8 @@ class Me extends w {
|
|
|
278
278
|
* @return {Transport} for chaining
|
|
279
279
|
* @protected
|
|
280
280
|
*/
|
|
281
|
-
onError(
|
|
282
|
-
return super.emitReserved("error", new
|
|
281
|
+
onError(t, e, s) {
|
|
282
|
+
return super.emitReserved("error", new ys(t, e, s)), this;
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* Opens the transport.
|
|
@@ -298,8 +298,8 @@ class Me extends w {
|
|
|
298
298
|
*
|
|
299
299
|
* @param {Array} packets
|
|
300
300
|
*/
|
|
301
|
-
send(
|
|
302
|
-
this.readyState === "open" && this.write(
|
|
301
|
+
send(t) {
|
|
302
|
+
this.readyState === "open" && this.write(t);
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
305
|
* Called upon open
|
|
@@ -315,49 +315,49 @@ class Me extends w {
|
|
|
315
315
|
* @param {String} data
|
|
316
316
|
* @protected
|
|
317
317
|
*/
|
|
318
|
-
onData(
|
|
319
|
-
const
|
|
320
|
-
this.onPacket(
|
|
318
|
+
onData(t) {
|
|
319
|
+
const e = oe(t, this.socket.binaryType);
|
|
320
|
+
this.onPacket(e);
|
|
321
321
|
}
|
|
322
322
|
/**
|
|
323
323
|
* Called with a decoded packet.
|
|
324
324
|
*
|
|
325
325
|
* @protected
|
|
326
326
|
*/
|
|
327
|
-
onPacket(
|
|
328
|
-
super.emitReserved("packet",
|
|
327
|
+
onPacket(t) {
|
|
328
|
+
super.emitReserved("packet", t);
|
|
329
329
|
}
|
|
330
330
|
/**
|
|
331
331
|
* Called upon close.
|
|
332
332
|
*
|
|
333
333
|
* @protected
|
|
334
334
|
*/
|
|
335
|
-
onClose(
|
|
336
|
-
this.readyState = "closed", super.emitReserved("close",
|
|
335
|
+
onClose(t) {
|
|
336
|
+
this.readyState = "closed", super.emitReserved("close", t);
|
|
337
337
|
}
|
|
338
338
|
/**
|
|
339
339
|
* Pauses the transport, in order not to lose packets during an upgrade.
|
|
340
340
|
*
|
|
341
341
|
* @param onPause
|
|
342
342
|
*/
|
|
343
|
-
pause(
|
|
343
|
+
pause(t) {
|
|
344
344
|
}
|
|
345
|
-
createUri(
|
|
346
|
-
return
|
|
345
|
+
createUri(t, e = {}) {
|
|
346
|
+
return t + "://" + this._hostname() + this._port() + this.opts.path + this._query(e);
|
|
347
347
|
}
|
|
348
348
|
_hostname() {
|
|
349
|
-
const
|
|
350
|
-
return
|
|
349
|
+
const t = this.opts.hostname;
|
|
350
|
+
return t.indexOf(":") === -1 ? t : "[" + t + "]";
|
|
351
351
|
}
|
|
352
352
|
_port() {
|
|
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
|
-
_query(
|
|
356
|
-
const
|
|
357
|
-
return
|
|
355
|
+
_query(t) {
|
|
356
|
+
const e = fs(t);
|
|
357
|
+
return e.length ? "?" + e : "";
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
class
|
|
360
|
+
class ms extends ae {
|
|
361
361
|
constructor() {
|
|
362
362
|
super(...arguments), this._polling = !1;
|
|
363
363
|
}
|
|
@@ -379,20 +379,20 @@ class Ht extends Me {
|
|
|
379
379
|
* @param {Function} onPause - callback upon buffers are flushed and transport is paused
|
|
380
380
|
* @package
|
|
381
381
|
*/
|
|
382
|
-
pause(
|
|
382
|
+
pause(t) {
|
|
383
383
|
this.readyState = "pausing";
|
|
384
|
-
const
|
|
385
|
-
this.readyState = "paused",
|
|
384
|
+
const e = () => {
|
|
385
|
+
this.readyState = "paused", t();
|
|
386
386
|
};
|
|
387
387
|
if (this._polling || !this.writable) {
|
|
388
388
|
let s = 0;
|
|
389
389
|
this._polling && (s++, this.once("pollComplete", function() {
|
|
390
|
-
--s ||
|
|
390
|
+
--s || e();
|
|
391
391
|
})), this.writable || (s++, this.once("drain", function() {
|
|
392
|
-
--s ||
|
|
392
|
+
--s || e();
|
|
393
393
|
}));
|
|
394
394
|
} else
|
|
395
|
-
|
|
395
|
+
e();
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
398
398
|
* Starts polling cycle.
|
|
@@ -407,13 +407,13 @@ class Ht extends Me {
|
|
|
407
407
|
*
|
|
408
408
|
* @protected
|
|
409
409
|
*/
|
|
410
|
-
onData(
|
|
411
|
-
const
|
|
410
|
+
onData(t) {
|
|
411
|
+
const e = (s) => {
|
|
412
412
|
if (this.readyState === "opening" && s.type === "open" && this.onOpen(), s.type === "close")
|
|
413
413
|
return this.onClose({ description: "transport closed by the server" }), !1;
|
|
414
414
|
this.onPacket(s);
|
|
415
415
|
};
|
|
416
|
-
|
|
416
|
+
ns(t, this.socket.binaryType).forEach(e), 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.
|
|
@@ -421,10 +421,10 @@ class Ht extends Me {
|
|
|
421
421
|
* @protected
|
|
422
422
|
*/
|
|
423
423
|
doClose() {
|
|
424
|
-
const
|
|
424
|
+
const t = () => {
|
|
425
425
|
this.write([{ type: "close" }]);
|
|
426
426
|
};
|
|
427
|
-
this.readyState === "open" ?
|
|
427
|
+
this.readyState === "open" ? t() : this.once("open", t);
|
|
428
428
|
}
|
|
429
429
|
/**
|
|
430
430
|
* Writes a packets payload.
|
|
@@ -432,9 +432,9 @@ class Ht extends Me {
|
|
|
432
432
|
* @param {Array} packets - data packets
|
|
433
433
|
* @protected
|
|
434
434
|
*/
|
|
435
|
-
write(
|
|
436
|
-
this.writable = !1,
|
|
437
|
-
this.doWrite(
|
|
435
|
+
write(t) {
|
|
436
|
+
this.writable = !1, ss(t, (e) => {
|
|
437
|
+
this.doWrite(e, () => {
|
|
438
438
|
this.writable = !0, this.emitReserved("drain");
|
|
439
439
|
});
|
|
440
440
|
});
|
|
@@ -445,30 +445,30 @@ class Ht extends Me {
|
|
|
445
445
|
* @private
|
|
446
446
|
*/
|
|
447
447
|
uri() {
|
|
448
|
-
const
|
|
449
|
-
return this.opts.timestampRequests !== !1 && (
|
|
448
|
+
const t = this.opts.secure ? "https" : "http", e = this.query || {};
|
|
449
|
+
return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = Be()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
let
|
|
452
|
+
let Le = !1;
|
|
453
453
|
try {
|
|
454
|
-
|
|
454
|
+
Le = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
455
455
|
} catch {
|
|
456
456
|
}
|
|
457
|
-
const
|
|
458
|
-
function
|
|
457
|
+
const gs = Le;
|
|
458
|
+
function ws() {
|
|
459
459
|
}
|
|
460
|
-
class
|
|
460
|
+
class _s extends ms {
|
|
461
461
|
/**
|
|
462
462
|
* XHR Polling constructor.
|
|
463
463
|
*
|
|
464
464
|
* @param {Object} opts
|
|
465
465
|
* @package
|
|
466
466
|
*/
|
|
467
|
-
constructor(
|
|
468
|
-
if (super(
|
|
469
|
-
const
|
|
467
|
+
constructor(t) {
|
|
468
|
+
if (super(t), typeof location < "u") {
|
|
469
|
+
const e = location.protocol === "https:";
|
|
470
470
|
let s = location.port;
|
|
471
|
-
s || (s =
|
|
471
|
+
s || (s = e ? "443" : "80"), this.xd = typeof location < "u" && t.hostname !== location.hostname || s !== t.port;
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
/**
|
|
@@ -478,12 +478,12 @@ class Jt extends Ht {
|
|
|
478
478
|
* @param {Function} fn - called upon flush.
|
|
479
479
|
* @private
|
|
480
480
|
*/
|
|
481
|
-
doWrite(
|
|
481
|
+
doWrite(t, e) {
|
|
482
482
|
const s = this.request({
|
|
483
483
|
method: "POST",
|
|
484
|
-
data:
|
|
484
|
+
data: t
|
|
485
485
|
});
|
|
486
|
-
s.on("success",
|
|
486
|
+
s.on("success", e), s.on("error", (r, i) => {
|
|
487
487
|
this.onError("xhr post error", r, i);
|
|
488
488
|
});
|
|
489
489
|
}
|
|
@@ -493,21 +493,21 @@ class Jt extends Ht {
|
|
|
493
493
|
* @private
|
|
494
494
|
*/
|
|
495
495
|
doPoll() {
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
this.onError("xhr poll error",
|
|
499
|
-
}), this.pollXhr =
|
|
496
|
+
const t = this.request();
|
|
497
|
+
t.on("data", this.onData.bind(this)), t.on("error", (e, s) => {
|
|
498
|
+
this.onError("xhr poll error", e, s);
|
|
499
|
+
}), this.pollXhr = t;
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
|
-
class N extends
|
|
502
|
+
class N extends E {
|
|
503
503
|
/**
|
|
504
504
|
* Request constructor
|
|
505
505
|
*
|
|
506
506
|
* @param {Object} options
|
|
507
507
|
* @package
|
|
508
508
|
*/
|
|
509
|
-
constructor(
|
|
510
|
-
super(), this.createRequest =
|
|
509
|
+
constructor(t, e, s) {
|
|
510
|
+
super(), this.createRequest = t, Ct(this, s), this._opts = s, this._method = s.method || "GET", this._uri = e, 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.
|
|
@@ -515,10 +515,10 @@ class N extends w {
|
|
|
515
515
|
* @private
|
|
516
516
|
*/
|
|
517
517
|
_create() {
|
|
518
|
-
var
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
const s = this._xhr = this.createRequest(
|
|
518
|
+
var t;
|
|
519
|
+
const e = Pe(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
520
|
+
e.xdomain = !!this._opts.xd;
|
|
521
|
+
const s = this._xhr = this.createRequest(e);
|
|
522
522
|
try {
|
|
523
523
|
s.open(this._method, this._uri, !0);
|
|
524
524
|
try {
|
|
@@ -538,7 +538,7 @@ class N extends w {
|
|
|
538
538
|
s.setRequestHeader("Accept", "*/*");
|
|
539
539
|
} catch {
|
|
540
540
|
}
|
|
541
|
-
(
|
|
541
|
+
(t = this._opts.cookieJar) === null || t === void 0 || t.addCookies(s), "withCredentials" in s && (s.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (s.timeout = this._opts.requestTimeout), s.onreadystatechange = () => {
|
|
542
542
|
var r;
|
|
543
543
|
s.readyState === 3 && ((r = this._opts.cookieJar) === null || r === void 0 || r.parseCookies(
|
|
544
544
|
// @ts-ignore
|
|
@@ -560,17 +560,17 @@ class N extends w {
|
|
|
560
560
|
*
|
|
561
561
|
* @private
|
|
562
562
|
*/
|
|
563
|
-
_onError(
|
|
564
|
-
this.emitReserved("error",
|
|
563
|
+
_onError(t) {
|
|
564
|
+
this.emitReserved("error", t, this._xhr), this._cleanup(!0);
|
|
565
565
|
}
|
|
566
566
|
/**
|
|
567
567
|
* Cleans up house.
|
|
568
568
|
*
|
|
569
569
|
* @private
|
|
570
570
|
*/
|
|
571
|
-
_cleanup(
|
|
571
|
+
_cleanup(t) {
|
|
572
572
|
if (!(typeof this._xhr > "u" || this._xhr === null)) {
|
|
573
|
-
if (this._xhr.onreadystatechange =
|
|
573
|
+
if (this._xhr.onreadystatechange = ws, t)
|
|
574
574
|
try {
|
|
575
575
|
this._xhr.abort();
|
|
576
576
|
} catch {
|
|
@@ -584,8 +584,8 @@ class N extends w {
|
|
|
584
584
|
* @private
|
|
585
585
|
*/
|
|
586
586
|
_onLoad() {
|
|
587
|
-
const
|
|
588
|
-
|
|
587
|
+
const t = this._xhr.responseText;
|
|
588
|
+
t !== null && (this.emitReserved("data", t), this.emitReserved("success"), this._cleanup());
|
|
589
589
|
}
|
|
590
590
|
/**
|
|
591
591
|
* Aborts the request.
|
|
@@ -600,55 +600,55 @@ N.requestsCount = 0;
|
|
|
600
600
|
N.requests = {};
|
|
601
601
|
if (typeof document < "u") {
|
|
602
602
|
if (typeof attachEvent == "function")
|
|
603
|
-
attachEvent("onunload",
|
|
603
|
+
attachEvent("onunload", ge);
|
|
604
604
|
else if (typeof addEventListener == "function") {
|
|
605
|
-
const n = "onpagehide" in
|
|
606
|
-
addEventListener(n,
|
|
605
|
+
const n = "onpagehide" in A ? "pagehide" : "unload";
|
|
606
|
+
addEventListener(n, ge, !1);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
function
|
|
609
|
+
function ge() {
|
|
610
610
|
for (let n in N.requests)
|
|
611
611
|
N.requests.hasOwnProperty(n) && N.requests[n].abort();
|
|
612
612
|
}
|
|
613
|
-
const
|
|
614
|
-
const n =
|
|
613
|
+
const bs = function() {
|
|
614
|
+
const n = qe({
|
|
615
615
|
xdomain: !1
|
|
616
616
|
});
|
|
617
617
|
return n && n.responseType !== null;
|
|
618
618
|
}();
|
|
619
|
-
class
|
|
620
|
-
constructor(
|
|
621
|
-
super(
|
|
622
|
-
const
|
|
623
|
-
this.supportsBinary =
|
|
619
|
+
class Es extends _s {
|
|
620
|
+
constructor(t) {
|
|
621
|
+
super(t);
|
|
622
|
+
const e = t && t.forceBase64;
|
|
623
|
+
this.supportsBinary = bs && !e;
|
|
624
624
|
}
|
|
625
|
-
request(
|
|
626
|
-
return Object.assign(
|
|
625
|
+
request(t = {}) {
|
|
626
|
+
return Object.assign(t, { xd: this.xd }, this.opts), new N(qe, this.uri(), t);
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
|
-
function
|
|
630
|
-
const
|
|
629
|
+
function qe(n) {
|
|
630
|
+
const t = n.xdomain;
|
|
631
631
|
try {
|
|
632
|
-
if (typeof XMLHttpRequest < "u" && (!
|
|
632
|
+
if (typeof XMLHttpRequest < "u" && (!t || gs))
|
|
633
633
|
return new XMLHttpRequest();
|
|
634
634
|
} catch {
|
|
635
635
|
}
|
|
636
|
-
if (!
|
|
636
|
+
if (!t)
|
|
637
637
|
try {
|
|
638
|
-
return new
|
|
638
|
+
return new A[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
639
639
|
} catch {
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
const
|
|
643
|
-
class
|
|
642
|
+
const Fe = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
643
|
+
class vs extends ae {
|
|
644
644
|
get name() {
|
|
645
645
|
return "websocket";
|
|
646
646
|
}
|
|
647
647
|
doOpen() {
|
|
648
|
-
const
|
|
648
|
+
const t = this.uri(), e = this.opts.protocols, s = Fe ? {} : Pe(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
|
-
this.ws = this.createSocket(
|
|
651
|
+
this.ws = this.createSocket(t, e, s);
|
|
652
652
|
} catch (r) {
|
|
653
653
|
return this.emitReserved("error", r);
|
|
654
654
|
}
|
|
@@ -662,21 +662,21 @@ class Wt extends Me {
|
|
|
662
662
|
addEventListeners() {
|
|
663
663
|
this.ws.onopen = () => {
|
|
664
664
|
this.opts.autoUnref && this.ws._socket.unref(), this.onOpen();
|
|
665
|
-
}, this.ws.onclose = (
|
|
665
|
+
}, this.ws.onclose = (t) => this.onClose({
|
|
666
666
|
description: "websocket connection closed",
|
|
667
|
-
context:
|
|
668
|
-
}), this.ws.onmessage = (
|
|
667
|
+
context: t
|
|
668
|
+
}), this.ws.onmessage = (t) => this.onData(t.data), this.ws.onerror = (t) => this.onError("websocket error", t);
|
|
669
669
|
}
|
|
670
|
-
write(
|
|
670
|
+
write(t) {
|
|
671
671
|
this.writable = !1;
|
|
672
|
-
for (let
|
|
673
|
-
const s = e
|
|
674
|
-
|
|
672
|
+
for (let e = 0; e < t.length; e++) {
|
|
673
|
+
const s = t[e], r = e === t.length - 1;
|
|
674
|
+
ie(s, this.supportsBinary, (i) => {
|
|
675
675
|
try {
|
|
676
676
|
this.doWrite(s, i);
|
|
677
677
|
} catch {
|
|
678
678
|
}
|
|
679
|
-
r &&
|
|
679
|
+
r && Rt(() => {
|
|
680
680
|
this.writable = !0, this.emitReserved("drain");
|
|
681
681
|
}, this.setTimeoutFn);
|
|
682
682
|
});
|
|
@@ -692,40 +692,40 @@ class Wt extends Me {
|
|
|
692
692
|
* @private
|
|
693
693
|
*/
|
|
694
694
|
uri() {
|
|
695
|
-
const
|
|
696
|
-
return this.opts.timestampRequests && (
|
|
695
|
+
const t = this.opts.secure ? "wss" : "ws", e = this.query || {};
|
|
696
|
+
return this.opts.timestampRequests && (e[this.opts.timestampParam] = Be()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
|
-
const
|
|
700
|
-
class
|
|
701
|
-
createSocket(
|
|
702
|
-
return
|
|
699
|
+
const Lt = A.WebSocket || A.MozWebSocket;
|
|
700
|
+
class Ts extends vs {
|
|
701
|
+
createSocket(t, e, s) {
|
|
702
|
+
return Fe ? new Lt(t, e, s) : e ? new Lt(t, e) : new Lt(t);
|
|
703
703
|
}
|
|
704
|
-
doWrite(
|
|
705
|
-
this.ws.send(
|
|
704
|
+
doWrite(t, e) {
|
|
705
|
+
this.ws.send(e);
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
|
-
class
|
|
708
|
+
class Ss extends ae {
|
|
709
709
|
get name() {
|
|
710
710
|
return "webtransport";
|
|
711
711
|
}
|
|
712
712
|
doOpen() {
|
|
713
713
|
try {
|
|
714
714
|
this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
|
|
715
|
-
} catch (
|
|
716
|
-
return this.emitReserved("error",
|
|
715
|
+
} catch (t) {
|
|
716
|
+
return this.emitReserved("error", t);
|
|
717
717
|
}
|
|
718
718
|
this._transport.closed.then(() => {
|
|
719
719
|
this.onClose();
|
|
720
|
-
}).catch((
|
|
721
|
-
this.onError("webtransport error",
|
|
720
|
+
}).catch((t) => {
|
|
721
|
+
this.onError("webtransport error", t);
|
|
722
722
|
}), this._transport.ready.then(() => {
|
|
723
|
-
this._transport.createBidirectionalStream().then((
|
|
724
|
-
const
|
|
725
|
-
r.readable.pipeTo(
|
|
723
|
+
this._transport.createBidirectionalStream().then((t) => {
|
|
724
|
+
const e = is(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), r = rs();
|
|
725
|
+
r.readable.pipeTo(t.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: u }) => {
|
|
728
|
+
h || (this.onPacket(u), i());
|
|
729
729
|
}).catch((h) => {
|
|
730
730
|
});
|
|
731
731
|
};
|
|
@@ -735,27 +735,27 @@ class zt extends Me {
|
|
|
735
735
|
});
|
|
736
736
|
});
|
|
737
737
|
}
|
|
738
|
-
write(
|
|
738
|
+
write(t) {
|
|
739
739
|
this.writable = !1;
|
|
740
|
-
for (let
|
|
741
|
-
const s = e
|
|
740
|
+
for (let e = 0; e < t.length; e++) {
|
|
741
|
+
const s = t[e], r = e === t.length - 1;
|
|
742
742
|
this._writer.write(s).then(() => {
|
|
743
|
-
r &&
|
|
743
|
+
r && Rt(() => {
|
|
744
744
|
this.writable = !0, this.emitReserved("drain");
|
|
745
745
|
}, this.setTimeoutFn);
|
|
746
746
|
});
|
|
747
747
|
}
|
|
748
748
|
}
|
|
749
749
|
doClose() {
|
|
750
|
-
var
|
|
751
|
-
(
|
|
750
|
+
var t;
|
|
751
|
+
(t = this._transport) === null || t === void 0 || t.close();
|
|
752
752
|
}
|
|
753
753
|
}
|
|
754
|
-
const
|
|
755
|
-
websocket:
|
|
756
|
-
webtransport:
|
|
757
|
-
polling:
|
|
758
|
-
},
|
|
754
|
+
const ks = {
|
|
755
|
+
websocket: Ts,
|
|
756
|
+
webtransport: Ss,
|
|
757
|
+
polling: Es
|
|
758
|
+
}, Os = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, As = [
|
|
759
759
|
"source",
|
|
760
760
|
"protocol",
|
|
761
761
|
"authority",
|
|
@@ -771,43 +771,43 @@ const Xt = {
|
|
|
771
771
|
"query",
|
|
772
772
|
"anchor"
|
|
773
773
|
];
|
|
774
|
-
function
|
|
774
|
+
function jt(n) {
|
|
775
775
|
if (n.length > 8e3)
|
|
776
776
|
throw "URI too long";
|
|
777
|
-
const
|
|
778
|
-
|
|
779
|
-
let r =
|
|
777
|
+
const t = n, e = n.indexOf("["), s = n.indexOf("]");
|
|
778
|
+
e != -1 && s != -1 && (n = n.substring(0, e) + n.substring(e, s).replace(/:/g, ";") + n.substring(s, n.length));
|
|
779
|
+
let r = Os.exec(n || ""), i = {}, o = 14;
|
|
780
780
|
for (; o--; )
|
|
781
|
-
i[
|
|
782
|
-
return
|
|
781
|
+
i[As[o]] = r[o] || "";
|
|
782
|
+
return e != -1 && s != -1 && (i.source = t, 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 = xs(i, i.path), i.queryKey = Is(i, i.query), i;
|
|
783
783
|
}
|
|
784
|
-
function
|
|
785
|
-
const
|
|
786
|
-
return (
|
|
784
|
+
function xs(n, t) {
|
|
785
|
+
const e = /\/{2,9}/g, s = t.replace(e, "/").split("/");
|
|
786
|
+
return (t.slice(0, 1) == "/" || t.length === 0) && s.splice(0, 1), t.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
|
|
787
787
|
}
|
|
788
|
-
function
|
|
789
|
-
const
|
|
790
|
-
return
|
|
791
|
-
r && (
|
|
792
|
-
}),
|
|
788
|
+
function Is(n, t) {
|
|
789
|
+
const e = {};
|
|
790
|
+
return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, r, i) {
|
|
791
|
+
r && (e[r] = i);
|
|
792
|
+
}), e;
|
|
793
793
|
}
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
794
|
+
const Mt = typeof addEventListener == "function" && typeof removeEventListener == "function", Et = [];
|
|
795
|
+
Mt && addEventListener("offline", () => {
|
|
796
|
+
Et.forEach((n) => n());
|
|
797
797
|
}, !1);
|
|
798
|
-
class
|
|
798
|
+
class V extends E {
|
|
799
799
|
/**
|
|
800
800
|
* Socket constructor.
|
|
801
801
|
*
|
|
802
802
|
* @param {String|Object} uri - uri or options
|
|
803
803
|
* @param {Object} opts - options
|
|
804
804
|
*/
|
|
805
|
-
constructor(
|
|
806
|
-
if (super(), this.binaryType =
|
|
807
|
-
const s =
|
|
808
|
-
|
|
809
|
-
} else
|
|
810
|
-
|
|
805
|
+
constructor(t, e) {
|
|
806
|
+
if (super(), this.binaryType = as, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, t && typeof t == "object" && (e = t, t = null), t) {
|
|
807
|
+
const s = jt(t);
|
|
808
|
+
e.hostname = s.host, e.secure = s.protocol === "https" || s.protocol === "wss", e.port = s.port, s.query && (e.query = s.query);
|
|
809
|
+
} else e.host && (e.hostname = jt(e.host).host);
|
|
810
|
+
Ct(this, e), this.secure = e.secure != null ? e.secure : typeof location < "u" && location.protocol === "https:", e.hostname && !e.port && (e.port = this.secure ? "443" : "80"), this.hostname = e.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = e.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, e.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 M extends w {
|
|
|
824
824
|
},
|
|
825
825
|
transportOptions: {},
|
|
826
826
|
closeOnBeforeunload: !1
|
|
827
|
-
},
|
|
827
|
+
}, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = ps(this.opts.query)), Mt && (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
|
+
}, Et.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
|
|
834
834
|
}
|
|
835
835
|
/**
|
|
836
836
|
* Creates transport of the given type.
|
|
@@ -839,17 +839,17 @@ class M extends w {
|
|
|
839
839
|
* @return {Transport}
|
|
840
840
|
* @private
|
|
841
841
|
*/
|
|
842
|
-
createTransport(
|
|
843
|
-
const
|
|
844
|
-
|
|
842
|
+
createTransport(t) {
|
|
843
|
+
const e = Object.assign({}, this.opts.query);
|
|
844
|
+
e.EIO = Ne, e.transport = t, this.id && (e.sid = this.id);
|
|
845
845
|
const s = Object.assign({}, this.opts, {
|
|
846
|
-
query:
|
|
846
|
+
query: e,
|
|
847
847
|
socket: this,
|
|
848
848
|
hostname: this.hostname,
|
|
849
849
|
secure: this.secure,
|
|
850
850
|
port: this.port
|
|
851
|
-
}, this.opts.transportOptions[
|
|
852
|
-
return new this._transportsByName[
|
|
851
|
+
}, this.opts.transportOptions[t]);
|
|
852
|
+
return new this._transportsByName[t](s);
|
|
853
853
|
}
|
|
854
854
|
/**
|
|
855
855
|
* Initializes transport to use and starts probe.
|
|
@@ -863,18 +863,18 @@ class M extends w {
|
|
|
863
863
|
}, 0);
|
|
864
864
|
return;
|
|
865
865
|
}
|
|
866
|
-
const
|
|
866
|
+
const t = this.opts.rememberUpgrade && V.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
|
|
867
867
|
this.readyState = "opening";
|
|
868
|
-
const
|
|
869
|
-
|
|
868
|
+
const e = this.createTransport(t);
|
|
869
|
+
e.open(), this.setTransport(e);
|
|
870
870
|
}
|
|
871
871
|
/**
|
|
872
872
|
* Sets the current transport. Disables the existing one (if any).
|
|
873
873
|
*
|
|
874
874
|
* @private
|
|
875
875
|
*/
|
|
876
|
-
setTransport(
|
|
877
|
-
this.transport && this.transport.removeAllListeners(), this.transport =
|
|
876
|
+
setTransport(t) {
|
|
877
|
+
this.transport && this.transport.removeAllListeners(), this.transport = t, t.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (e) => this._onClose("transport close", e));
|
|
878
878
|
}
|
|
879
879
|
/**
|
|
880
880
|
* Called when connection is deemed open.
|
|
@@ -882,28 +882,28 @@ class M extends w {
|
|
|
882
882
|
* @private
|
|
883
883
|
*/
|
|
884
884
|
onOpen() {
|
|
885
|
-
this.readyState = "open",
|
|
885
|
+
this.readyState = "open", V.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
|
|
886
886
|
}
|
|
887
887
|
/**
|
|
888
888
|
* Handles a packet.
|
|
889
889
|
*
|
|
890
890
|
* @private
|
|
891
891
|
*/
|
|
892
|
-
_onPacket(
|
|
892
|
+
_onPacket(t) {
|
|
893
893
|
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing")
|
|
894
|
-
switch (this.emitReserved("packet",
|
|
894
|
+
switch (this.emitReserved("packet", t), this.emitReserved("heartbeat"), t.type) {
|
|
895
895
|
case "open":
|
|
896
|
-
this.onHandshake(JSON.parse(
|
|
896
|
+
this.onHandshake(JSON.parse(t.data));
|
|
897
897
|
break;
|
|
898
898
|
case "ping":
|
|
899
899
|
this._sendPacket("pong"), this.emitReserved("ping"), this.emitReserved("pong"), this._resetPingTimeout();
|
|
900
900
|
break;
|
|
901
901
|
case "error":
|
|
902
|
-
const
|
|
903
|
-
|
|
902
|
+
const e = new Error("server error");
|
|
903
|
+
e.code = t.data, this._onError(e);
|
|
904
904
|
break;
|
|
905
905
|
case "message":
|
|
906
|
-
this.emitReserved("data",
|
|
906
|
+
this.emitReserved("data", t.data), this.emitReserved("message", t.data);
|
|
907
907
|
break;
|
|
908
908
|
}
|
|
909
909
|
}
|
|
@@ -913,8 +913,8 @@ class M extends w {
|
|
|
913
913
|
* @param {Object} data - handshake obj
|
|
914
914
|
* @private
|
|
915
915
|
*/
|
|
916
|
-
onHandshake(
|
|
917
|
-
this.emitReserved("handshake",
|
|
916
|
+
onHandshake(t) {
|
|
917
|
+
this.emitReserved("handshake", t), this.id = t.sid, this.transport.query.sid = t.sid, this._pingInterval = t.pingInterval, this._pingTimeout = t.pingTimeout, this._maxPayload = t.maxPayload, this.onOpen(), this.readyState !== "closed" && this._resetPingTimeout();
|
|
918
918
|
}
|
|
919
919
|
/**
|
|
920
920
|
* Sets and resets ping timeout timer based on server pings.
|
|
@@ -923,10 +923,10 @@ class M extends w {
|
|
|
923
923
|
*/
|
|
924
924
|
_resetPingTimeout() {
|
|
925
925
|
this.clearTimeoutFn(this._pingTimeoutTimer);
|
|
926
|
-
const
|
|
927
|
-
this._pingTimeoutTime = Date.now() +
|
|
926
|
+
const t = this._pingInterval + this._pingTimeout;
|
|
927
|
+
this._pingTimeoutTime = Date.now() + t, this._pingTimeoutTimer = this.setTimeoutFn(() => {
|
|
928
928
|
this._onClose("ping timeout");
|
|
929
|
-
},
|
|
929
|
+
}, t), this.opts.autoUnref && this._pingTimeoutTimer.unref();
|
|
930
930
|
}
|
|
931
931
|
/**
|
|
932
932
|
* Called on `drain` event
|
|
@@ -943,8 +943,8 @@ class M extends w {
|
|
|
943
943
|
*/
|
|
944
944
|
flush() {
|
|
945
945
|
if (this.readyState !== "closed" && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
|
|
946
|
-
const
|
|
947
|
-
this.transport.send(
|
|
946
|
+
const t = this._getWritablePackets();
|
|
947
|
+
this.transport.send(t), this._prevBufferLen = t.length, this.emitReserved("flush");
|
|
948
948
|
}
|
|
949
949
|
}
|
|
950
950
|
/**
|
|
@@ -956,12 +956,12 @@ class M extends w {
|
|
|
956
956
|
_getWritablePackets() {
|
|
957
957
|
if (!(this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1))
|
|
958
958
|
return this.writeBuffer;
|
|
959
|
-
let
|
|
959
|
+
let e = 1;
|
|
960
960
|
for (let s = 0; s < this.writeBuffer.length; s++) {
|
|
961
961
|
const r = this.writeBuffer[s].data;
|
|
962
|
-
if (r && (
|
|
962
|
+
if (r && (e += us(r)), s > 0 && e > this._maxPayload)
|
|
963
963
|
return this.writeBuffer.slice(0, s);
|
|
964
|
-
|
|
964
|
+
e += 2;
|
|
965
965
|
}
|
|
966
966
|
return this.writeBuffer;
|
|
967
967
|
}
|
|
@@ -978,10 +978,10 @@ class M extends w {
|
|
|
978
978
|
_hasPingExpired() {
|
|
979
979
|
if (!this._pingTimeoutTime)
|
|
980
980
|
return !0;
|
|
981
|
-
const
|
|
982
|
-
return
|
|
981
|
+
const t = Date.now() > this._pingTimeoutTime;
|
|
982
|
+
return t && (this._pingTimeoutTime = 0, Rt(() => {
|
|
983
983
|
this._onClose("ping timeout");
|
|
984
|
-
}, this.setTimeoutFn)),
|
|
984
|
+
}, this.setTimeoutFn)), t;
|
|
985
985
|
}
|
|
986
986
|
/**
|
|
987
987
|
* Sends a message.
|
|
@@ -991,8 +991,8 @@ class M extends w {
|
|
|
991
991
|
* @param {Function} fn - callback function.
|
|
992
992
|
* @return {Socket} for chaining.
|
|
993
993
|
*/
|
|
994
|
-
write(
|
|
995
|
-
return this._sendPacket("message",
|
|
994
|
+
write(t, e, s) {
|
|
995
|
+
return this._sendPacket("message", t, e, s), this;
|
|
996
996
|
}
|
|
997
997
|
/**
|
|
998
998
|
* Sends a message. Alias of {@link Socket#write}.
|
|
@@ -1002,8 +1002,8 @@ class M extends w {
|
|
|
1002
1002
|
* @param {Function} fn - callback function.
|
|
1003
1003
|
* @return {Socket} for chaining.
|
|
1004
1004
|
*/
|
|
1005
|
-
send(
|
|
1006
|
-
return this._sendPacket("message",
|
|
1005
|
+
send(t, e, s) {
|
|
1006
|
+
return this._sendPacket("message", t, e, s), this;
|
|
1007
1007
|
}
|
|
1008
1008
|
/**
|
|
1009
1009
|
* Sends a packet.
|
|
@@ -1014,13 +1014,13 @@ class M extends w {
|
|
|
1014
1014
|
* @param {Function} fn - callback function.
|
|
1015
1015
|
* @private
|
|
1016
1016
|
*/
|
|
1017
|
-
_sendPacket(
|
|
1018
|
-
if (typeof
|
|
1017
|
+
_sendPacket(t, e, s, r) {
|
|
1018
|
+
if (typeof e == "function" && (r = e, e = void 0), typeof s == "function" && (r = s, s = null), this.readyState === "closing" || this.readyState === "closed")
|
|
1019
1019
|
return;
|
|
1020
1020
|
s = s || {}, s.compress = s.compress !== !1;
|
|
1021
1021
|
const i = {
|
|
1022
|
-
type:
|
|
1023
|
-
data:
|
|
1022
|
+
type: t,
|
|
1023
|
+
data: e,
|
|
1024
1024
|
options: s
|
|
1025
1025
|
};
|
|
1026
1026
|
this.emitReserved("packetCreate", i), this.writeBuffer.push(i), r && this.once("flush", r), this.flush();
|
|
@@ -1029,51 +1029,51 @@ class M extends w {
|
|
|
1029
1029
|
* Closes the connection.
|
|
1030
1030
|
*/
|
|
1031
1031
|
close() {
|
|
1032
|
-
const
|
|
1032
|
+
const t = () => {
|
|
1033
1033
|
this._onClose("forced close"), this.transport.close();
|
|
1034
|
-
},
|
|
1035
|
-
this.off("upgrade",
|
|
1034
|
+
}, e = () => {
|
|
1035
|
+
this.off("upgrade", e), this.off("upgradeError", e), t();
|
|
1036
1036
|
}, s = () => {
|
|
1037
|
-
this.once("upgrade",
|
|
1037
|
+
this.once("upgrade", e), this.once("upgradeError", e);
|
|
1038
1038
|
};
|
|
1039
1039
|
return (this.readyState === "opening" || this.readyState === "open") && (this.readyState = "closing", this.writeBuffer.length ? this.once("drain", () => {
|
|
1040
|
-
this.upgrading ? s() :
|
|
1041
|
-
}) : this.upgrading ? s() :
|
|
1040
|
+
this.upgrading ? s() : t();
|
|
1041
|
+
}) : this.upgrading ? s() : t()), this;
|
|
1042
1042
|
}
|
|
1043
1043
|
/**
|
|
1044
1044
|
* Called upon transport error
|
|
1045
1045
|
*
|
|
1046
1046
|
* @private
|
|
1047
1047
|
*/
|
|
1048
|
-
_onError(
|
|
1049
|
-
if (
|
|
1048
|
+
_onError(t) {
|
|
1049
|
+
if (V.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
|
|
1050
1050
|
return this.transports.shift(), this._open();
|
|
1051
|
-
this.emitReserved("error",
|
|
1051
|
+
this.emitReserved("error", t), this._onClose("transport error", t);
|
|
1052
1052
|
}
|
|
1053
1053
|
/**
|
|
1054
1054
|
* Called upon transport close.
|
|
1055
1055
|
*
|
|
1056
1056
|
* @private
|
|
1057
1057
|
*/
|
|
1058
|
-
_onClose(
|
|
1058
|
+
_onClose(t, e) {
|
|
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(), Mt && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
1061
|
+
const s = Et.indexOf(this._offlineEventListener);
|
|
1062
|
+
s !== -1 && Et.splice(s, 1);
|
|
1063
1063
|
}
|
|
1064
|
-
this.readyState = "closed", this.id = null, this.emitReserved("close",
|
|
1064
|
+
this.readyState = "closed", this.id = null, this.emitReserved("close", t, e), this.writeBuffer = [], this._prevBufferLen = 0;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
1067
|
}
|
|
1068
|
-
|
|
1069
|
-
class
|
|
1068
|
+
V.protocol = Ne;
|
|
1069
|
+
class $s extends V {
|
|
1070
1070
|
constructor() {
|
|
1071
1071
|
super(...arguments), this._upgrades = [];
|
|
1072
1072
|
}
|
|
1073
1073
|
onOpen() {
|
|
1074
1074
|
if (super.onOpen(), this.readyState === "open" && this.opts.upgrade)
|
|
1075
|
-
for (let
|
|
1076
|
-
this._probe(this._upgrades[
|
|
1075
|
+
for (let t = 0; t < this._upgrades.length; t++)
|
|
1076
|
+
this._probe(this._upgrades[t]);
|
|
1077
1077
|
}
|
|
1078
1078
|
/**
|
|
1079
1079
|
* Probes a transport.
|
|
@@ -1081,49 +1081,49 @@ class ss extends M {
|
|
|
1081
1081
|
* @param {String} name - transport name
|
|
1082
1082
|
* @private
|
|
1083
1083
|
*/
|
|
1084
|
-
_probe(
|
|
1085
|
-
let
|
|
1086
|
-
|
|
1084
|
+
_probe(t) {
|
|
1085
|
+
let e = this.createTransport(t), s = !1;
|
|
1086
|
+
V.priorWebsocketSuccess = !1;
|
|
1087
1087
|
const r = () => {
|
|
1088
|
-
s || (
|
|
1088
|
+
s || (e.send([{ type: "ping", data: "probe" }]), e.once("packet", (w) => {
|
|
1089
1089
|
if (!s)
|
|
1090
|
-
if (
|
|
1091
|
-
if (this.upgrading = !0, this.emitReserved("upgrading",
|
|
1090
|
+
if (w.type === "pong" && w.data === "probe") {
|
|
1091
|
+
if (this.upgrading = !0, this.emitReserved("upgrading", e), !e)
|
|
1092
1092
|
return;
|
|
1093
|
-
|
|
1094
|
-
s || this.readyState !== "closed" && (y(), this.setTransport(
|
|
1093
|
+
V.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
|
|
1094
|
+
s || this.readyState !== "closed" && (y(), this.setTransport(e), e.send([{ type: "upgrade" }]), this.emitReserved("upgrade", e), e = null, this.upgrading = !1, this.flush());
|
|
1095
1095
|
});
|
|
1096
1096
|
} else {
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1097
|
+
const R = new Error("probe error");
|
|
1098
|
+
R.transport = e.name, this.emitReserved("upgradeError", R);
|
|
1099
1099
|
}
|
|
1100
1100
|
}));
|
|
1101
1101
|
};
|
|
1102
1102
|
function i() {
|
|
1103
|
-
s || (s = !0, y(),
|
|
1103
|
+
s || (s = !0, y(), e.close(), e = null);
|
|
1104
1104
|
}
|
|
1105
|
-
const o = (
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1105
|
+
const o = (w) => {
|
|
1106
|
+
const R = new Error("probe error: " + w);
|
|
1107
|
+
R.transport = e.name, i(), this.emitReserved("upgradeError", R);
|
|
1108
1108
|
};
|
|
1109
1109
|
function h() {
|
|
1110
1110
|
o("transport closed");
|
|
1111
1111
|
}
|
|
1112
|
-
function
|
|
1112
|
+
function u() {
|
|
1113
1113
|
o("socket closed");
|
|
1114
1114
|
}
|
|
1115
|
-
function
|
|
1116
|
-
|
|
1115
|
+
function f(w) {
|
|
1116
|
+
e && w.name !== e.name && i();
|
|
1117
1117
|
}
|
|
1118
1118
|
const y = () => {
|
|
1119
|
-
|
|
1119
|
+
e.removeListener("open", r), e.removeListener("error", o), e.removeListener("close", h), this.off("close", u), this.off("upgrading", f);
|
|
1120
1120
|
};
|
|
1121
|
-
|
|
1122
|
-
s ||
|
|
1123
|
-
}, 200) :
|
|
1121
|
+
e.once("open", r), e.once("error", o), e.once("close", h), this.once("close", u), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && t !== "webtransport" ? this.setTimeoutFn(() => {
|
|
1122
|
+
s || e.open();
|
|
1123
|
+
}, 200) : e.open();
|
|
1124
1124
|
}
|
|
1125
|
-
onHandshake(
|
|
1126
|
-
this._upgrades = this._filterUpgrades(
|
|
1125
|
+
onHandshake(t) {
|
|
1126
|
+
this._upgrades = this._filterUpgrades(t.upgrades), super.onHandshake(t);
|
|
1127
1127
|
}
|
|
1128
1128
|
/**
|
|
1129
1129
|
* Filters upgrades, returning only those matching client transports.
|
|
@@ -1131,89 +1131,89 @@ class ss extends M {
|
|
|
1131
1131
|
* @param {Array} upgrades - server upgrades
|
|
1132
1132
|
* @private
|
|
1133
1133
|
*/
|
|
1134
|
-
_filterUpgrades(
|
|
1135
|
-
const
|
|
1136
|
-
for (let s = 0; s <
|
|
1137
|
-
~this.transports.indexOf(
|
|
1138
|
-
return
|
|
1134
|
+
_filterUpgrades(t) {
|
|
1135
|
+
const e = [];
|
|
1136
|
+
for (let s = 0; s < t.length; s++)
|
|
1137
|
+
~this.transports.indexOf(t[s]) && e.push(t[s]);
|
|
1138
|
+
return e;
|
|
1139
1139
|
}
|
|
1140
1140
|
}
|
|
1141
|
-
let
|
|
1142
|
-
constructor(
|
|
1143
|
-
const s = typeof
|
|
1144
|
-
(!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) =>
|
|
1141
|
+
let Rs = class extends $s {
|
|
1142
|
+
constructor(t, e = {}) {
|
|
1143
|
+
const s = typeof t == "object", r = s ? { ...t } : { ...e };
|
|
1144
|
+
(!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => ks[i]).filter((i) => !!i)), super(s ? r : t, r);
|
|
1145
1145
|
}
|
|
1146
1146
|
};
|
|
1147
|
-
function
|
|
1147
|
+
function Cs(n, t = "", e) {
|
|
1148
1148
|
let s = n;
|
|
1149
|
-
|
|
1149
|
+
e = e || typeof location < "u" && location, n == null && (n = e.protocol + "//" + e.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = e.protocol + n : n = e.host + n), /^(https?|wss?):\/\//.test(n) || (typeof e < "u" ? n = e.protocol + "//" + n : n = "https://" + n), s = jt(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
|
-
return s.id = s.protocol + "://" + i + ":" + s.port +
|
|
1151
|
+
return s.id = s.protocol + "://" + i + ":" + s.port + t, s.href = s.protocol + "://" + i + (e && e.port === s.port ? "" : ":" + s.port), s;
|
|
1152
1152
|
}
|
|
1153
|
-
const
|
|
1154
|
-
function
|
|
1155
|
-
return
|
|
1153
|
+
const Ns = typeof ArrayBuffer == "function", Ps = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, Ue = Object.prototype.toString, Bs = typeof Blob == "function" || typeof Blob < "u" && Ue.call(Blob) === "[object BlobConstructor]", Ls = typeof File == "function" || typeof File < "u" && Ue.call(File) === "[object FileConstructor]";
|
|
1154
|
+
function ce(n) {
|
|
1155
|
+
return Ns && (n instanceof ArrayBuffer || Ps(n)) || Bs && n instanceof Blob || Ls && n instanceof File;
|
|
1156
1156
|
}
|
|
1157
|
-
function
|
|
1157
|
+
function vt(n, t) {
|
|
1158
1158
|
if (!n || typeof n != "object")
|
|
1159
1159
|
return !1;
|
|
1160
1160
|
if (Array.isArray(n)) {
|
|
1161
|
-
for (let
|
|
1162
|
-
if (
|
|
1161
|
+
for (let e = 0, s = n.length; e < s; e++)
|
|
1162
|
+
if (vt(n[e]))
|
|
1163
1163
|
return !0;
|
|
1164
1164
|
return !1;
|
|
1165
1165
|
}
|
|
1166
|
-
if (
|
|
1166
|
+
if (ce(n))
|
|
1167
1167
|
return !0;
|
|
1168
1168
|
if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
|
|
1169
|
-
return
|
|
1170
|
-
for (const
|
|
1171
|
-
if (Object.prototype.hasOwnProperty.call(n,
|
|
1169
|
+
return vt(n.toJSON(), !0);
|
|
1170
|
+
for (const e in n)
|
|
1171
|
+
if (Object.prototype.hasOwnProperty.call(n, e) && vt(n[e]))
|
|
1172
1172
|
return !0;
|
|
1173
1173
|
return !1;
|
|
1174
1174
|
}
|
|
1175
|
-
function
|
|
1176
|
-
const
|
|
1177
|
-
return s.data =
|
|
1175
|
+
function qs(n) {
|
|
1176
|
+
const t = [], e = n.data, s = n;
|
|
1177
|
+
return s.data = Ht(e, t), s.attachments = t.length, { packet: s, buffers: t };
|
|
1178
1178
|
}
|
|
1179
|
-
function
|
|
1179
|
+
function Ht(n, t) {
|
|
1180
1180
|
if (!n)
|
|
1181
1181
|
return n;
|
|
1182
|
-
if (
|
|
1183
|
-
const
|
|
1184
|
-
return
|
|
1182
|
+
if (ce(n)) {
|
|
1183
|
+
const e = { _placeholder: !0, num: t.length };
|
|
1184
|
+
return t.push(n), e;
|
|
1185
1185
|
} else if (Array.isArray(n)) {
|
|
1186
|
-
const
|
|
1186
|
+
const e = new Array(n.length);
|
|
1187
1187
|
for (let s = 0; s < n.length; s++)
|
|
1188
|
-
|
|
1189
|
-
return
|
|
1188
|
+
e[s] = Ht(n[s], t);
|
|
1189
|
+
return e;
|
|
1190
1190
|
} else if (typeof n == "object" && !(n instanceof Date)) {
|
|
1191
|
-
const
|
|
1191
|
+
const e = {};
|
|
1192
1192
|
for (const s in n)
|
|
1193
|
-
Object.prototype.hasOwnProperty.call(n, s) && (
|
|
1194
|
-
return
|
|
1193
|
+
Object.prototype.hasOwnProperty.call(n, s) && (e[s] = Ht(n[s], t));
|
|
1194
|
+
return e;
|
|
1195
1195
|
}
|
|
1196
1196
|
return n;
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1199
|
-
return n.data =
|
|
1198
|
+
function Fs(n, t) {
|
|
1199
|
+
return n.data = Gt(n.data, t), delete n.attachments, n;
|
|
1200
1200
|
}
|
|
1201
|
-
function
|
|
1201
|
+
function Gt(n, t) {
|
|
1202
1202
|
if (!n)
|
|
1203
1203
|
return n;
|
|
1204
1204
|
if (n && n._placeholder === !0) {
|
|
1205
|
-
if (typeof n.num == "number" && n.num >= 0 && n.num <
|
|
1206
|
-
return
|
|
1205
|
+
if (typeof n.num == "number" && n.num >= 0 && n.num < t.length)
|
|
1206
|
+
return t[n.num];
|
|
1207
1207
|
throw new Error("illegal attachments");
|
|
1208
1208
|
} else if (Array.isArray(n))
|
|
1209
|
-
for (let
|
|
1210
|
-
n[
|
|
1209
|
+
for (let e = 0; e < n.length; e++)
|
|
1210
|
+
n[e] = Gt(n[e], t);
|
|
1211
1211
|
else if (typeof n == "object")
|
|
1212
|
-
for (const
|
|
1213
|
-
Object.prototype.hasOwnProperty.call(n,
|
|
1212
|
+
for (const e in n)
|
|
1213
|
+
Object.prototype.hasOwnProperty.call(n, e) && (n[e] = Gt(n[e], t));
|
|
1214
1214
|
return n;
|
|
1215
1215
|
}
|
|
1216
|
-
const
|
|
1216
|
+
const Us = [
|
|
1217
1217
|
"connect",
|
|
1218
1218
|
// used on the client side
|
|
1219
1219
|
"connect_error",
|
|
@@ -1227,18 +1227,18 @@ const ls = [
|
|
|
1227
1227
|
"removeListener"
|
|
1228
1228
|
// used by the Node.js EventEmitter
|
|
1229
1229
|
];
|
|
1230
|
-
var
|
|
1230
|
+
var g;
|
|
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
|
-
})(
|
|
1234
|
-
class
|
|
1233
|
+
})(g || (g = {}));
|
|
1234
|
+
class Ds {
|
|
1235
1235
|
/**
|
|
1236
1236
|
* Encoder constructor
|
|
1237
1237
|
*
|
|
1238
1238
|
* @param {function} replacer - custom replacer to pass down to JSON.parse
|
|
1239
1239
|
*/
|
|
1240
|
-
constructor(
|
|
1241
|
-
this.replacer =
|
|
1240
|
+
constructor(t) {
|
|
1241
|
+
this.replacer = t;
|
|
1242
1242
|
}
|
|
1243
1243
|
/**
|
|
1244
1244
|
* Encode a packet as a single string if non-binary, or as a
|
|
@@ -1246,61 +1246,61 @@ class fs {
|
|
|
1246
1246
|
*
|
|
1247
1247
|
* @param {Object} obj - packet object
|
|
1248
1248
|
*/
|
|
1249
|
-
encode(
|
|
1250
|
-
return (
|
|
1251
|
-
type:
|
|
1252
|
-
nsp:
|
|
1253
|
-
data:
|
|
1254
|
-
id:
|
|
1255
|
-
}) : [this.encodeAsString(
|
|
1249
|
+
encode(t) {
|
|
1250
|
+
return (t.type === g.EVENT || t.type === g.ACK) && vt(t) ? this.encodeAsBinary({
|
|
1251
|
+
type: t.type === g.EVENT ? g.BINARY_EVENT : g.BINARY_ACK,
|
|
1252
|
+
nsp: t.nsp,
|
|
1253
|
+
data: t.data,
|
|
1254
|
+
id: t.id
|
|
1255
|
+
}) : [this.encodeAsString(t)];
|
|
1256
1256
|
}
|
|
1257
1257
|
/**
|
|
1258
1258
|
* Encode packet as string.
|
|
1259
1259
|
*/
|
|
1260
|
-
encodeAsString(
|
|
1261
|
-
let
|
|
1262
|
-
return (
|
|
1260
|
+
encodeAsString(t) {
|
|
1261
|
+
let e = "" + t.type;
|
|
1262
|
+
return (t.type === g.BINARY_EVENT || t.type === g.BINARY_ACK) && (e += t.attachments + "-"), t.nsp && t.nsp !== "/" && (e += t.nsp + ","), t.id != null && (e += t.id), t.data != null && (e += JSON.stringify(t.data, this.replacer)), e;
|
|
1263
1263
|
}
|
|
1264
1264
|
/**
|
|
1265
1265
|
* Encode packet as 'buffer sequence' by removing blobs, and
|
|
1266
1266
|
* deconstructing packet into object with placeholders and
|
|
1267
1267
|
* a list of buffers.
|
|
1268
1268
|
*/
|
|
1269
|
-
encodeAsBinary(
|
|
1270
|
-
const
|
|
1269
|
+
encodeAsBinary(t) {
|
|
1270
|
+
const e = qs(t), s = this.encodeAsString(e.packet), r = e.buffers;
|
|
1271
1271
|
return r.unshift(s), r;
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
|
-
class
|
|
1274
|
+
class he extends E {
|
|
1275
1275
|
/**
|
|
1276
1276
|
* Decoder constructor
|
|
1277
1277
|
*/
|
|
1278
|
-
constructor(
|
|
1278
|
+
constructor(t) {
|
|
1279
1279
|
super(), this.opts = Object.assign({
|
|
1280
1280
|
reviver: void 0,
|
|
1281
1281
|
maxAttachments: 10
|
|
1282
|
-
}, typeof
|
|
1282
|
+
}, typeof t == "function" ? { reviver: t } : t);
|
|
1283
1283
|
}
|
|
1284
1284
|
/**
|
|
1285
1285
|
* Decodes an encoded packet string into packet JSON.
|
|
1286
1286
|
*
|
|
1287
1287
|
* @param {String} obj - encoded packet
|
|
1288
1288
|
*/
|
|
1289
|
-
add(
|
|
1290
|
-
let
|
|
1291
|
-
if (typeof
|
|
1289
|
+
add(t) {
|
|
1290
|
+
let e;
|
|
1291
|
+
if (typeof t == "string") {
|
|
1292
1292
|
if (this.reconstructor)
|
|
1293
1293
|
throw new Error("got plaintext data when reconstructing a packet");
|
|
1294
|
-
|
|
1295
|
-
const s =
|
|
1296
|
-
s ||
|
|
1297
|
-
} else if (
|
|
1294
|
+
e = this.decodeString(t);
|
|
1295
|
+
const s = e.type === g.BINARY_EVENT;
|
|
1296
|
+
s || e.type === g.BINARY_ACK ? (e.type = s ? g.EVENT : g.ACK, this.reconstructor = new js(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
|
|
1297
|
+
} else if (ce(t) || t.base64)
|
|
1298
1298
|
if (this.reconstructor)
|
|
1299
|
-
|
|
1299
|
+
e = this.reconstructor.takeBinaryData(t), e && (this.reconstructor = null, super.emitReserved("decoded", e));
|
|
1300
1300
|
else
|
|
1301
1301
|
throw new Error("got binary data when not reconstructing a packet");
|
|
1302
1302
|
else
|
|
1303
|
-
throw new Error("Unknown type: " +
|
|
1303
|
+
throw new Error("Unknown type: " + t);
|
|
1304
1304
|
}
|
|
1305
1305
|
/**
|
|
1306
1306
|
* Decode a packet String (JSON data)
|
|
@@ -1308,78 +1308,78 @@ class je extends w {
|
|
|
1308
1308
|
* @param {String} str
|
|
1309
1309
|
* @return {Object} packet
|
|
1310
1310
|
*/
|
|
1311
|
-
decodeString(
|
|
1312
|
-
let
|
|
1311
|
+
decodeString(t) {
|
|
1312
|
+
let e = 0;
|
|
1313
1313
|
const s = {
|
|
1314
|
-
type: Number(
|
|
1314
|
+
type: Number(t.charAt(0))
|
|
1315
1315
|
};
|
|
1316
|
-
if (
|
|
1316
|
+
if (g[s.type] === void 0)
|
|
1317
1317
|
throw new Error("unknown packet type " + s.type);
|
|
1318
|
-
if (s.type ===
|
|
1319
|
-
const i =
|
|
1320
|
-
for (;
|
|
1318
|
+
if (s.type === g.BINARY_EVENT || s.type === g.BINARY_ACK) {
|
|
1319
|
+
const i = e + 1;
|
|
1320
|
+
for (; t.charAt(++e) !== "-" && e != t.length; )
|
|
1321
1321
|
;
|
|
1322
|
-
const o =
|
|
1323
|
-
if (o != Number(o) ||
|
|
1322
|
+
const o = t.substring(i, e);
|
|
1323
|
+
if (o != Number(o) || t.charAt(e) !== "-")
|
|
1324
1324
|
throw new Error("Illegal attachments");
|
|
1325
1325
|
const h = Number(o);
|
|
1326
|
-
if (!
|
|
1326
|
+
if (!Ms(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");
|
|
1330
1330
|
s.attachments = h;
|
|
1331
1331
|
}
|
|
1332
|
-
if (
|
|
1333
|
-
const i =
|
|
1334
|
-
for (; ++
|
|
1332
|
+
if (t.charAt(e + 1) === "/") {
|
|
1333
|
+
const i = e + 1;
|
|
1334
|
+
for (; ++e && !(t.charAt(e) === "," || e === t.length); )
|
|
1335
1335
|
;
|
|
1336
|
-
s.nsp =
|
|
1336
|
+
s.nsp = t.substring(i, e);
|
|
1337
1337
|
} else
|
|
1338
1338
|
s.nsp = "/";
|
|
1339
|
-
const r =
|
|
1339
|
+
const r = t.charAt(e + 1);
|
|
1340
1340
|
if (r !== "" && Number(r) == r) {
|
|
1341
|
-
const i =
|
|
1342
|
-
for (; ++
|
|
1343
|
-
const o =
|
|
1341
|
+
const i = e + 1;
|
|
1342
|
+
for (; ++e; ) {
|
|
1343
|
+
const o = t.charAt(e);
|
|
1344
1344
|
if (o == null || Number(o) != o) {
|
|
1345
|
-
--
|
|
1345
|
+
--e;
|
|
1346
1346
|
break;
|
|
1347
1347
|
}
|
|
1348
|
-
if (
|
|
1348
|
+
if (e === t.length)
|
|
1349
1349
|
break;
|
|
1350
1350
|
}
|
|
1351
|
-
s.id = Number(
|
|
1351
|
+
s.id = Number(t.substring(i, e + 1));
|
|
1352
1352
|
}
|
|
1353
|
-
if (
|
|
1354
|
-
const i = this.tryParse(
|
|
1355
|
-
if (
|
|
1353
|
+
if (t.charAt(++e)) {
|
|
1354
|
+
const i = this.tryParse(t.substr(e));
|
|
1355
|
+
if (he.isPayloadValid(s.type, i))
|
|
1356
1356
|
s.data = i;
|
|
1357
1357
|
else
|
|
1358
1358
|
throw new Error("invalid payload");
|
|
1359
1359
|
}
|
|
1360
1360
|
return s;
|
|
1361
1361
|
}
|
|
1362
|
-
tryParse(
|
|
1362
|
+
tryParse(t) {
|
|
1363
1363
|
try {
|
|
1364
|
-
return JSON.parse(
|
|
1364
|
+
return JSON.parse(t, this.opts.reviver);
|
|
1365
1365
|
} catch {
|
|
1366
1366
|
return !1;
|
|
1367
1367
|
}
|
|
1368
1368
|
}
|
|
1369
|
-
static isPayloadValid(
|
|
1370
|
-
switch (
|
|
1371
|
-
case
|
|
1372
|
-
return
|
|
1373
|
-
case
|
|
1374
|
-
return
|
|
1375
|
-
case
|
|
1376
|
-
return typeof
|
|
1377
|
-
case
|
|
1378
|
-
case
|
|
1379
|
-
return Array.isArray(
|
|
1380
|
-
case
|
|
1381
|
-
case
|
|
1382
|
-
return Array.isArray(
|
|
1369
|
+
static isPayloadValid(t, e) {
|
|
1370
|
+
switch (t) {
|
|
1371
|
+
case g.CONNECT:
|
|
1372
|
+
return we(e);
|
|
1373
|
+
case g.DISCONNECT:
|
|
1374
|
+
return e === void 0;
|
|
1375
|
+
case g.CONNECT_ERROR:
|
|
1376
|
+
return typeof e == "string" || we(e);
|
|
1377
|
+
case g.EVENT:
|
|
1378
|
+
case g.BINARY_EVENT:
|
|
1379
|
+
return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Us.indexOf(e[0]) === -1);
|
|
1380
|
+
case g.ACK:
|
|
1381
|
+
case g.BINARY_ACK:
|
|
1382
|
+
return Array.isArray(e);
|
|
1383
1383
|
}
|
|
1384
1384
|
}
|
|
1385
1385
|
/**
|
|
@@ -1389,9 +1389,9 @@ class je extends w {
|
|
|
1389
1389
|
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
1392
|
-
class
|
|
1393
|
-
constructor(
|
|
1394
|
-
this.packet =
|
|
1392
|
+
class js {
|
|
1393
|
+
constructor(t) {
|
|
1394
|
+
this.packet = t, this.buffers = [], this.reconPack = t;
|
|
1395
1395
|
}
|
|
1396
1396
|
/**
|
|
1397
1397
|
* Method to be called when binary data received from connection
|
|
@@ -1401,10 +1401,10 @@ class ds {
|
|
|
1401
1401
|
* @return {null | Object} returns null if more binary data is expected or
|
|
1402
1402
|
* a reconstructed packet object if all buffers have been received.
|
|
1403
1403
|
*/
|
|
1404
|
-
takeBinaryData(
|
|
1405
|
-
if (this.buffers.push(
|
|
1406
|
-
const
|
|
1407
|
-
return this.finishedReconstruction(),
|
|
1404
|
+
takeBinaryData(t) {
|
|
1405
|
+
if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
|
|
1406
|
+
const e = Fs(this.reconPack, this.buffers);
|
|
1407
|
+
return this.finishedReconstruction(), e;
|
|
1408
1408
|
}
|
|
1409
1409
|
return null;
|
|
1410
1410
|
}
|
|
@@ -1415,26 +1415,26 @@ class ds {
|
|
|
1415
1415
|
this.reconPack = null, this.buffers = [];
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
|
-
const
|
|
1418
|
+
const Ms = Number.isInteger || function(n) {
|
|
1419
1419
|
return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
|
|
1420
1420
|
};
|
|
1421
|
-
function
|
|
1421
|
+
function we(n) {
|
|
1422
1422
|
return Object.prototype.toString.call(n) === "[object Object]";
|
|
1423
1423
|
}
|
|
1424
|
-
const
|
|
1424
|
+
const Hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1425
1425
|
__proto__: null,
|
|
1426
|
-
Decoder:
|
|
1427
|
-
Encoder:
|
|
1426
|
+
Decoder: he,
|
|
1427
|
+
Encoder: Ds,
|
|
1428
1428
|
get PacketType() {
|
|
1429
|
-
return
|
|
1429
|
+
return g;
|
|
1430
1430
|
}
|
|
1431
1431
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1432
|
-
function
|
|
1433
|
-
return n.on(
|
|
1434
|
-
n.off(
|
|
1432
|
+
function $(n, t, e) {
|
|
1433
|
+
return n.on(t, e), function() {
|
|
1434
|
+
n.off(t, e);
|
|
1435
1435
|
};
|
|
1436
1436
|
}
|
|
1437
|
-
const
|
|
1437
|
+
const Gs = Object.freeze({
|
|
1438
1438
|
connect: 1,
|
|
1439
1439
|
connect_error: 1,
|
|
1440
1440
|
disconnect: 1,
|
|
@@ -1443,12 +1443,12 @@ const ms = Object.freeze({
|
|
|
1443
1443
|
newListener: 1,
|
|
1444
1444
|
removeListener: 1
|
|
1445
1445
|
});
|
|
1446
|
-
class
|
|
1446
|
+
class De extends E {
|
|
1447
1447
|
/**
|
|
1448
1448
|
* `Socket` constructor.
|
|
1449
1449
|
*/
|
|
1450
|
-
constructor(
|
|
1451
|
-
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io =
|
|
1450
|
+
constructor(t, e, s) {
|
|
1451
|
+
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = t, this.nsp = e, s && s.auth && (this.auth = s.auth), this._opts = Object.assign({}, s), this.io._autoConnect && this.open();
|
|
1452
1452
|
}
|
|
1453
1453
|
/**
|
|
1454
1454
|
* Whether the socket is currently disconnected
|
|
@@ -1475,12 +1475,12 @@ class pt extends w {
|
|
|
1475
1475
|
subEvents() {
|
|
1476
1476
|
if (this.subs)
|
|
1477
1477
|
return;
|
|
1478
|
-
const
|
|
1478
|
+
const t = this.io;
|
|
1479
1479
|
this.subs = [
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1480
|
+
$(t, "open", this.onopen.bind(this)),
|
|
1481
|
+
$(t, "packet", this.onpacket.bind(this)),
|
|
1482
|
+
$(t, "error", this.onerror.bind(this)),
|
|
1483
|
+
$(t, "close", this.onclose.bind(this))
|
|
1484
1484
|
];
|
|
1485
1485
|
}
|
|
1486
1486
|
/**
|
|
@@ -1537,8 +1537,8 @@ class pt extends w {
|
|
|
1537
1537
|
*
|
|
1538
1538
|
* @return self
|
|
1539
1539
|
*/
|
|
1540
|
-
send(...
|
|
1541
|
-
return
|
|
1540
|
+
send(...t) {
|
|
1541
|
+
return t.unshift("message"), this.emit.apply(this, t), this;
|
|
1542
1542
|
}
|
|
1543
1543
|
/**
|
|
1544
1544
|
* Override `emit`.
|
|
@@ -1557,42 +1557,42 @@ class pt extends w {
|
|
|
1557
1557
|
*
|
|
1558
1558
|
* @return self
|
|
1559
1559
|
*/
|
|
1560
|
-
emit(
|
|
1560
|
+
emit(t, ...e) {
|
|
1561
1561
|
var s, r, i;
|
|
1562
|
-
if (
|
|
1563
|
-
throw new Error('"' +
|
|
1564
|
-
if (
|
|
1565
|
-
return this._addToQueue(
|
|
1562
|
+
if (Gs.hasOwnProperty(t))
|
|
1563
|
+
throw new Error('"' + t.toString() + '" is a reserved event name');
|
|
1564
|
+
if (e.unshift(t), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
|
|
1565
|
+
return this._addToQueue(e), this;
|
|
1566
1566
|
const o = {
|
|
1567
|
-
type:
|
|
1568
|
-
data:
|
|
1567
|
+
type: g.EVENT,
|
|
1568
|
+
data: e
|
|
1569
1569
|
};
|
|
1570
|
-
if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof
|
|
1571
|
-
const y = this.ids++,
|
|
1572
|
-
this._registerAckCallback(y,
|
|
1570
|
+
if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof e[e.length - 1] == "function") {
|
|
1571
|
+
const y = this.ids++, w = e.pop();
|
|
1572
|
+
this._registerAckCallback(y, w), 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, u = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
|
|
1575
|
+
return this.flags.volatile && !h || (u ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
|
|
1576
1576
|
}
|
|
1577
1577
|
/**
|
|
1578
1578
|
* @private
|
|
1579
1579
|
*/
|
|
1580
|
-
_registerAckCallback(
|
|
1580
|
+
_registerAckCallback(t, e) {
|
|
1581
1581
|
var s;
|
|
1582
1582
|
const r = (s = this.flags.timeout) !== null && s !== void 0 ? s : this._opts.ackTimeout;
|
|
1583
1583
|
if (r === void 0) {
|
|
1584
|
-
this.acks[
|
|
1584
|
+
this.acks[t] = e;
|
|
1585
1585
|
return;
|
|
1586
1586
|
}
|
|
1587
1587
|
const i = this.io.setTimeoutFn(() => {
|
|
1588
|
-
delete this.acks[
|
|
1588
|
+
delete this.acks[t];
|
|
1589
1589
|
for (let h = 0; h < this.sendBuffer.length; h++)
|
|
1590
|
-
this.sendBuffer[h].id ===
|
|
1591
|
-
|
|
1590
|
+
this.sendBuffer[h].id === t && this.sendBuffer.splice(h, 1);
|
|
1591
|
+
e.call(this, new Error("operation has timed out"));
|
|
1592
1592
|
}, r), o = (...h) => {
|
|
1593
|
-
this.io.clearTimeoutFn(i),
|
|
1593
|
+
this.io.clearTimeoutFn(i), e.apply(this, h);
|
|
1594
1594
|
};
|
|
1595
|
-
o.withError = !0, this.acks[
|
|
1595
|
+
o.withError = !0, this.acks[t] = o;
|
|
1596
1596
|
}
|
|
1597
1597
|
/**
|
|
1598
1598
|
* Emits an event and waits for an acknowledgement
|
|
@@ -1610,10 +1610,10 @@ class pt extends w {
|
|
|
1610
1610
|
*
|
|
1611
1611
|
* @return a Promise that will be fulfilled when the server acknowledges the event
|
|
1612
1612
|
*/
|
|
1613
|
-
emitWithAck(
|
|
1613
|
+
emitWithAck(t, ...e) {
|
|
1614
1614
|
return new Promise((s, r) => {
|
|
1615
1615
|
const i = (o, h) => o ? r(o) : s(h);
|
|
1616
|
-
i.withError = !0,
|
|
1616
|
+
i.withError = !0, e.push(i), this.emit(t, ...e);
|
|
1617
1617
|
});
|
|
1618
1618
|
}
|
|
1619
1619
|
/**
|
|
@@ -1621,17 +1621,17 @@ class pt extends w {
|
|
|
1621
1621
|
* @param args
|
|
1622
1622
|
* @private
|
|
1623
1623
|
*/
|
|
1624
|
-
_addToQueue(
|
|
1625
|
-
let
|
|
1626
|
-
typeof
|
|
1624
|
+
_addToQueue(t) {
|
|
1625
|
+
let e;
|
|
1626
|
+
typeof t[t.length - 1] == "function" && (e = t.pop());
|
|
1627
1627
|
const s = {
|
|
1628
1628
|
id: this._queueSeq++,
|
|
1629
1629
|
tryCount: 0,
|
|
1630
1630
|
pending: !1,
|
|
1631
|
-
args:
|
|
1631
|
+
args: t,
|
|
1632
1632
|
flags: Object.assign({ fromQueue: !0 }, this.flags)
|
|
1633
1633
|
};
|
|
1634
|
-
|
|
1634
|
+
t.push((r, ...i) => (this._queue[0], r !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), e && e(r)) : (this._queue.shift(), e && e(null, ...i)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
|
|
1635
1635
|
}
|
|
1636
1636
|
/**
|
|
1637
1637
|
* Send the first packet of the queue, and wait for an acknowledgement from the server.
|
|
@@ -1639,11 +1639,11 @@ class pt extends w {
|
|
|
1639
1639
|
*
|
|
1640
1640
|
* @private
|
|
1641
1641
|
*/
|
|
1642
|
-
_drainQueue(
|
|
1642
|
+
_drainQueue(t = !1) {
|
|
1643
1643
|
if (!this.connected || this._queue.length === 0)
|
|
1644
1644
|
return;
|
|
1645
|
-
const
|
|
1646
|
-
|
|
1645
|
+
const e = this._queue[0];
|
|
1646
|
+
e.pending && !t || (e.pending = !0, e.tryCount++, this.flags = e.flags, this.emit.apply(this, e.args));
|
|
1647
1647
|
}
|
|
1648
1648
|
/**
|
|
1649
1649
|
* Sends a packet.
|
|
@@ -1651,8 +1651,8 @@ class pt extends w {
|
|
|
1651
1651
|
* @param packet
|
|
1652
1652
|
* @private
|
|
1653
1653
|
*/
|
|
1654
|
-
packet(
|
|
1655
|
-
|
|
1654
|
+
packet(t) {
|
|
1655
|
+
t.nsp = this.nsp, this.io._packet(t);
|
|
1656
1656
|
}
|
|
1657
1657
|
/**
|
|
1658
1658
|
* Called upon engine `open`.
|
|
@@ -1660,8 +1660,8 @@ class pt extends w {
|
|
|
1660
1660
|
* @private
|
|
1661
1661
|
*/
|
|
1662
1662
|
onopen() {
|
|
1663
|
-
typeof this.auth == "function" ? this.auth((
|
|
1664
|
-
this._sendConnectPacket(
|
|
1663
|
+
typeof this.auth == "function" ? this.auth((t) => {
|
|
1664
|
+
this._sendConnectPacket(t);
|
|
1665
1665
|
}) : this._sendConnectPacket(this.auth);
|
|
1666
1666
|
}
|
|
1667
1667
|
/**
|
|
@@ -1670,10 +1670,10 @@ class pt extends w {
|
|
|
1670
1670
|
* @param data
|
|
1671
1671
|
* @private
|
|
1672
1672
|
*/
|
|
1673
|
-
_sendConnectPacket(
|
|
1673
|
+
_sendConnectPacket(t) {
|
|
1674
1674
|
this.packet({
|
|
1675
|
-
type:
|
|
1676
|
-
data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset },
|
|
1675
|
+
type: g.CONNECT,
|
|
1676
|
+
data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, t) : t
|
|
1677
1677
|
});
|
|
1678
1678
|
}
|
|
1679
1679
|
/**
|
|
@@ -1682,8 +1682,8 @@ class pt extends w {
|
|
|
1682
1682
|
* @param err
|
|
1683
1683
|
* @private
|
|
1684
1684
|
*/
|
|
1685
|
-
onerror(
|
|
1686
|
-
this.connected || this.emitReserved("connect_error",
|
|
1685
|
+
onerror(t) {
|
|
1686
|
+
this.connected || this.emitReserved("connect_error", t);
|
|
1687
1687
|
}
|
|
1688
1688
|
/**
|
|
1689
1689
|
* Called upon engine `close`.
|
|
@@ -1692,8 +1692,8 @@ class pt extends w {
|
|
|
1692
1692
|
* @param description
|
|
1693
1693
|
* @private
|
|
1694
1694
|
*/
|
|
1695
|
-
onclose(
|
|
1696
|
-
this.connected = !1, delete this.id, this.emitReserved("disconnect",
|
|
1695
|
+
onclose(t, e) {
|
|
1696
|
+
this.connected = !1, delete this.id, this.emitReserved("disconnect", t, e), this._clearAcks();
|
|
1697
1697
|
}
|
|
1698
1698
|
/**
|
|
1699
1699
|
* Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
|
|
@@ -1702,10 +1702,10 @@ class pt extends w {
|
|
|
1702
1702
|
* @private
|
|
1703
1703
|
*/
|
|
1704
1704
|
_clearAcks() {
|
|
1705
|
-
Object.keys(this.acks).forEach((
|
|
1706
|
-
if (!this.sendBuffer.some((s) => String(s.id) ===
|
|
1707
|
-
const s = this.acks[
|
|
1708
|
-
delete this.acks[
|
|
1705
|
+
Object.keys(this.acks).forEach((t) => {
|
|
1706
|
+
if (!this.sendBuffer.some((s) => String(s.id) === t)) {
|
|
1707
|
+
const s = this.acks[t];
|
|
1708
|
+
delete this.acks[t], s.withError && s.call(this, new Error("socket has been disconnected"));
|
|
1709
1709
|
}
|
|
1710
1710
|
});
|
|
1711
1711
|
}
|
|
@@ -1715,27 +1715,27 @@ class pt extends w {
|
|
|
1715
1715
|
* @param packet
|
|
1716
1716
|
* @private
|
|
1717
1717
|
*/
|
|
1718
|
-
onpacket(
|
|
1719
|
-
if (
|
|
1720
|
-
switch (
|
|
1721
|
-
case
|
|
1722
|
-
|
|
1718
|
+
onpacket(t) {
|
|
1719
|
+
if (t.nsp === this.nsp)
|
|
1720
|
+
switch (t.type) {
|
|
1721
|
+
case g.CONNECT:
|
|
1722
|
+
t.data && t.data.sid ? this.onconnect(t.data.sid, t.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
|
|
1723
1723
|
break;
|
|
1724
|
-
case
|
|
1725
|
-
case
|
|
1726
|
-
this.onevent(
|
|
1724
|
+
case g.EVENT:
|
|
1725
|
+
case g.BINARY_EVENT:
|
|
1726
|
+
this.onevent(t);
|
|
1727
1727
|
break;
|
|
1728
|
-
case
|
|
1729
|
-
case
|
|
1730
|
-
this.onack(
|
|
1728
|
+
case g.ACK:
|
|
1729
|
+
case g.BINARY_ACK:
|
|
1730
|
+
this.onack(t);
|
|
1731
1731
|
break;
|
|
1732
|
-
case
|
|
1732
|
+
case g.DISCONNECT:
|
|
1733
1733
|
this.ondisconnect();
|
|
1734
1734
|
break;
|
|
1735
|
-
case
|
|
1735
|
+
case g.CONNECT_ERROR:
|
|
1736
1736
|
this.destroy();
|
|
1737
|
-
const s = new Error(
|
|
1738
|
-
s.data =
|
|
1737
|
+
const s = new Error(t.data.message);
|
|
1738
|
+
s.data = t.data.data, this.emitReserved("connect_error", s);
|
|
1739
1739
|
break;
|
|
1740
1740
|
}
|
|
1741
1741
|
}
|
|
@@ -1745,30 +1745,30 @@ class pt extends w {
|
|
|
1745
1745
|
* @param packet
|
|
1746
1746
|
* @private
|
|
1747
1747
|
*/
|
|
1748
|
-
onevent(
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1748
|
+
onevent(t) {
|
|
1749
|
+
const e = t.data || [];
|
|
1750
|
+
t.id != null && e.push(this.ack(t.id)), this.connected ? this.emitEvent(e) : this.receiveBuffer.push(Object.freeze(e));
|
|
1751
1751
|
}
|
|
1752
|
-
emitEvent(
|
|
1752
|
+
emitEvent(t) {
|
|
1753
1753
|
if (this._anyListeners && this._anyListeners.length) {
|
|
1754
|
-
const
|
|
1755
|
-
for (const s of
|
|
1756
|
-
s.apply(this,
|
|
1754
|
+
const e = this._anyListeners.slice();
|
|
1755
|
+
for (const s of e)
|
|
1756
|
+
s.apply(this, t);
|
|
1757
1757
|
}
|
|
1758
|
-
super.emit.apply(this,
|
|
1758
|
+
super.emit.apply(this, t), this._pid && t.length && typeof t[t.length - 1] == "string" && (this._lastOffset = t[t.length - 1]);
|
|
1759
1759
|
}
|
|
1760
1760
|
/**
|
|
1761
1761
|
* Produces an ack callback to emit with an event.
|
|
1762
1762
|
*
|
|
1763
1763
|
* @private
|
|
1764
1764
|
*/
|
|
1765
|
-
ack(
|
|
1766
|
-
const
|
|
1765
|
+
ack(t) {
|
|
1766
|
+
const e = this;
|
|
1767
1767
|
let s = !1;
|
|
1768
1768
|
return function(...r) {
|
|
1769
|
-
s || (s = !0,
|
|
1770
|
-
type:
|
|
1771
|
-
id:
|
|
1769
|
+
s || (s = !0, e.packet({
|
|
1770
|
+
type: g.ACK,
|
|
1771
|
+
id: t,
|
|
1772
1772
|
data: r
|
|
1773
1773
|
}));
|
|
1774
1774
|
};
|
|
@@ -1779,17 +1779,17 @@ class pt extends w {
|
|
|
1779
1779
|
* @param packet
|
|
1780
1780
|
* @private
|
|
1781
1781
|
*/
|
|
1782
|
-
onack(
|
|
1783
|
-
const
|
|
1784
|
-
typeof
|
|
1782
|
+
onack(t) {
|
|
1783
|
+
const e = this.acks[t.id];
|
|
1784
|
+
typeof e == "function" && (delete this.acks[t.id], e.withError && t.data.unshift(null), e.apply(this, t.data));
|
|
1785
1785
|
}
|
|
1786
1786
|
/**
|
|
1787
1787
|
* Called upon server connect.
|
|
1788
1788
|
*
|
|
1789
1789
|
* @private
|
|
1790
1790
|
*/
|
|
1791
|
-
onconnect(
|
|
1792
|
-
this.id =
|
|
1791
|
+
onconnect(t, e) {
|
|
1792
|
+
this.id = t, this.recovered = e && this._pid === e, this._pid = e, this.connected = !0, this.emitBuffered(), this._drainQueue(!0), this.emitReserved("connect");
|
|
1793
1793
|
}
|
|
1794
1794
|
/**
|
|
1795
1795
|
* Emit buffered events (received and emitted).
|
|
@@ -1797,8 +1797,8 @@ class pt extends w {
|
|
|
1797
1797
|
* @private
|
|
1798
1798
|
*/
|
|
1799
1799
|
emitBuffered() {
|
|
1800
|
-
this.receiveBuffer.forEach((
|
|
1801
|
-
this.notifyOutgoingListeners(
|
|
1800
|
+
this.receiveBuffer.forEach((t) => this.emitEvent(t)), this.receiveBuffer = [], this.sendBuffer.forEach((t) => {
|
|
1801
|
+
this.notifyOutgoingListeners(t), this.packet(t);
|
|
1802
1802
|
}), this.sendBuffer = [];
|
|
1803
1803
|
}
|
|
1804
1804
|
/**
|
|
@@ -1817,7 +1817,7 @@ class pt extends w {
|
|
|
1817
1817
|
* @private
|
|
1818
1818
|
*/
|
|
1819
1819
|
destroy() {
|
|
1820
|
-
this.subs && (this.subs.forEach((
|
|
1820
|
+
this.subs && (this.subs.forEach((t) => t()), this.subs = void 0), this.io._destroy(this);
|
|
1821
1821
|
}
|
|
1822
1822
|
/**
|
|
1823
1823
|
* Disconnects the socket manually. In that case, the socket will not try to reconnect.
|
|
@@ -1836,7 +1836,7 @@ class pt extends w {
|
|
|
1836
1836
|
* @return self
|
|
1837
1837
|
*/
|
|
1838
1838
|
disconnect() {
|
|
1839
|
-
return this.connected && this.packet({ type:
|
|
1839
|
+
return this.connected && this.packet({ type: g.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
|
|
1840
1840
|
}
|
|
1841
1841
|
/**
|
|
1842
1842
|
* Alias for {@link disconnect()}.
|
|
@@ -1855,8 +1855,8 @@ class pt extends w {
|
|
|
1855
1855
|
* @param compress - if `true`, compresses the sending data
|
|
1856
1856
|
* @return self
|
|
1857
1857
|
*/
|
|
1858
|
-
compress(
|
|
1859
|
-
return this.flags.compress =
|
|
1858
|
+
compress(t) {
|
|
1859
|
+
return this.flags.compress = t, this;
|
|
1860
1860
|
}
|
|
1861
1861
|
/**
|
|
1862
1862
|
* Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
|
|
@@ -1883,8 +1883,8 @@ class pt extends w {
|
|
|
1883
1883
|
*
|
|
1884
1884
|
* @returns self
|
|
1885
1885
|
*/
|
|
1886
|
-
timeout(
|
|
1887
|
-
return this.flags.timeout =
|
|
1886
|
+
timeout(t) {
|
|
1887
|
+
return this.flags.timeout = t, this;
|
|
1888
1888
|
}
|
|
1889
1889
|
/**
|
|
1890
1890
|
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
@@ -1897,8 +1897,8 @@ class pt extends w {
|
|
|
1897
1897
|
*
|
|
1898
1898
|
* @param listener
|
|
1899
1899
|
*/
|
|
1900
|
-
onAny(
|
|
1901
|
-
return this._anyListeners = this._anyListeners || [], this._anyListeners.push(
|
|
1900
|
+
onAny(t) {
|
|
1901
|
+
return this._anyListeners = this._anyListeners || [], this._anyListeners.push(t), this;
|
|
1902
1902
|
}
|
|
1903
1903
|
/**
|
|
1904
1904
|
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
@@ -1911,8 +1911,8 @@ class pt extends w {
|
|
|
1911
1911
|
*
|
|
1912
1912
|
* @param listener
|
|
1913
1913
|
*/
|
|
1914
|
-
prependAny(
|
|
1915
|
-
return this._anyListeners = this._anyListeners || [], this._anyListeners.unshift(
|
|
1914
|
+
prependAny(t) {
|
|
1915
|
+
return this._anyListeners = this._anyListeners || [], this._anyListeners.unshift(t), this;
|
|
1916
1916
|
}
|
|
1917
1917
|
/**
|
|
1918
1918
|
* Removes the listener that will be fired when any event is emitted.
|
|
@@ -1932,14 +1932,14 @@ class pt extends w {
|
|
|
1932
1932
|
*
|
|
1933
1933
|
* @param listener
|
|
1934
1934
|
*/
|
|
1935
|
-
offAny(
|
|
1935
|
+
offAny(t) {
|
|
1936
1936
|
if (!this._anyListeners)
|
|
1937
1937
|
return this;
|
|
1938
|
-
if (
|
|
1939
|
-
const
|
|
1940
|
-
for (let s = 0; s <
|
|
1941
|
-
if (
|
|
1942
|
-
return
|
|
1938
|
+
if (t) {
|
|
1939
|
+
const e = this._anyListeners;
|
|
1940
|
+
for (let s = 0; s < e.length; s++)
|
|
1941
|
+
if (t === e[s])
|
|
1942
|
+
return e.splice(s, 1), this;
|
|
1943
1943
|
} else
|
|
1944
1944
|
this._anyListeners = [];
|
|
1945
1945
|
return this;
|
|
@@ -1964,8 +1964,8 @@ class pt extends w {
|
|
|
1964
1964
|
*
|
|
1965
1965
|
* @param listener
|
|
1966
1966
|
*/
|
|
1967
|
-
onAnyOutgoing(
|
|
1968
|
-
return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.push(
|
|
1967
|
+
onAnyOutgoing(t) {
|
|
1968
|
+
return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.push(t), this;
|
|
1969
1969
|
}
|
|
1970
1970
|
/**
|
|
1971
1971
|
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
@@ -1980,8 +1980,8 @@ class pt extends w {
|
|
|
1980
1980
|
*
|
|
1981
1981
|
* @param listener
|
|
1982
1982
|
*/
|
|
1983
|
-
prependAnyOutgoing(
|
|
1984
|
-
return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.unshift(
|
|
1983
|
+
prependAnyOutgoing(t) {
|
|
1984
|
+
return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.unshift(t), this;
|
|
1985
1985
|
}
|
|
1986
1986
|
/**
|
|
1987
1987
|
* Removes the listener that will be fired when any event is emitted.
|
|
@@ -2001,14 +2001,14 @@ class pt extends w {
|
|
|
2001
2001
|
*
|
|
2002
2002
|
* @param [listener] - the catch-all listener (optional)
|
|
2003
2003
|
*/
|
|
2004
|
-
offAnyOutgoing(
|
|
2004
|
+
offAnyOutgoing(t) {
|
|
2005
2005
|
if (!this._anyOutgoingListeners)
|
|
2006
2006
|
return this;
|
|
2007
|
-
if (
|
|
2008
|
-
const
|
|
2009
|
-
for (let s = 0; s <
|
|
2010
|
-
if (
|
|
2011
|
-
return
|
|
2007
|
+
if (t) {
|
|
2008
|
+
const e = this._anyOutgoingListeners;
|
|
2009
|
+
for (let s = 0; s < e.length; s++)
|
|
2010
|
+
if (t === e[s])
|
|
2011
|
+
return e.splice(s, 1), this;
|
|
2012
2012
|
} else
|
|
2013
2013
|
this._anyOutgoingListeners = [];
|
|
2014
2014
|
return this;
|
|
@@ -2027,68 +2027,68 @@ class pt extends w {
|
|
|
2027
2027
|
*
|
|
2028
2028
|
* @private
|
|
2029
2029
|
*/
|
|
2030
|
-
notifyOutgoingListeners(
|
|
2030
|
+
notifyOutgoingListeners(t) {
|
|
2031
2031
|
if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
|
|
2032
|
-
const
|
|
2033
|
-
for (const s of
|
|
2034
|
-
s.apply(this,
|
|
2032
|
+
const e = this._anyOutgoingListeners.slice();
|
|
2033
|
+
for (const s of e)
|
|
2034
|
+
s.apply(this, t.data);
|
|
2035
2035
|
}
|
|
2036
2036
|
}
|
|
2037
2037
|
}
|
|
2038
|
-
function
|
|
2038
|
+
function nt(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
|
+
nt.prototype.duration = function() {
|
|
2042
2042
|
var n = this.ms * Math.pow(this.factor, this.attempts++);
|
|
2043
2043
|
if (this.jitter) {
|
|
2044
|
-
var
|
|
2045
|
-
n = Math.floor(
|
|
2044
|
+
var t = Math.random(), e = Math.floor(t * this.jitter * n);
|
|
2045
|
+
n = Math.floor(t * 10) & 1 ? n + e : n - e;
|
|
2046
2046
|
}
|
|
2047
2047
|
return Math.min(n, this.max) | 0;
|
|
2048
2048
|
};
|
|
2049
|
-
|
|
2049
|
+
nt.prototype.reset = function() {
|
|
2050
2050
|
this.attempts = 0;
|
|
2051
2051
|
};
|
|
2052
|
-
|
|
2052
|
+
nt.prototype.setMin = function(n) {
|
|
2053
2053
|
this.ms = n;
|
|
2054
2054
|
};
|
|
2055
|
-
|
|
2055
|
+
nt.prototype.setMax = function(n) {
|
|
2056
2056
|
this.max = n;
|
|
2057
2057
|
};
|
|
2058
|
-
|
|
2058
|
+
nt.prototype.setJitter = function(n) {
|
|
2059
2059
|
this.jitter = n;
|
|
2060
2060
|
};
|
|
2061
|
-
class
|
|
2062
|
-
constructor(
|
|
2061
|
+
class Vt extends E {
|
|
2062
|
+
constructor(t, e) {
|
|
2063
2063
|
var s;
|
|
2064
|
-
super(), this.nsps = {}, this.subs = [],
|
|
2064
|
+
super(), this.nsps = {}, this.subs = [], t && typeof t == "object" && (e = t, t = void 0), e = e || {}, e.path = e.path || "/socket.io", this.opts = e, Ct(this, e), this.reconnection(e.reconnection !== !1), this.reconnectionAttempts(e.reconnectionAttempts || 1 / 0), this.reconnectionDelay(e.reconnectionDelay || 1e3), this.reconnectionDelayMax(e.reconnectionDelayMax || 5e3), this.randomizationFactor((s = e.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new nt({
|
|
2065
2065
|
min: this.reconnectionDelay(),
|
|
2066
2066
|
max: this.reconnectionDelayMax(),
|
|
2067
2067
|
jitter: this.randomizationFactor()
|
|
2068
|
-
}), this.timeout(
|
|
2069
|
-
const r =
|
|
2070
|
-
this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect =
|
|
2068
|
+
}), this.timeout(e.timeout == null ? 2e4 : e.timeout), this._readyState = "closed", this.uri = t;
|
|
2069
|
+
const r = e.parser || Hs;
|
|
2070
|
+
this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = e.autoConnect !== !1, this._autoConnect && this.open();
|
|
2071
2071
|
}
|
|
2072
|
-
reconnection(
|
|
2073
|
-
return arguments.length ? (this._reconnection = !!
|
|
2072
|
+
reconnection(t) {
|
|
2073
|
+
return arguments.length ? (this._reconnection = !!t, t || (this.skipReconnect = !0), this) : this._reconnection;
|
|
2074
2074
|
}
|
|
2075
|
-
reconnectionAttempts(
|
|
2076
|
-
return
|
|
2075
|
+
reconnectionAttempts(t) {
|
|
2076
|
+
return t === void 0 ? this._reconnectionAttempts : (this._reconnectionAttempts = t, this);
|
|
2077
2077
|
}
|
|
2078
|
-
reconnectionDelay(
|
|
2079
|
-
var
|
|
2080
|
-
return
|
|
2078
|
+
reconnectionDelay(t) {
|
|
2079
|
+
var e;
|
|
2080
|
+
return t === void 0 ? this._reconnectionDelay : (this._reconnectionDelay = t, (e = this.backoff) === null || e === void 0 || e.setMin(t), this);
|
|
2081
2081
|
}
|
|
2082
|
-
randomizationFactor(
|
|
2083
|
-
var
|
|
2084
|
-
return
|
|
2082
|
+
randomizationFactor(t) {
|
|
2083
|
+
var e;
|
|
2084
|
+
return t === void 0 ? this._randomizationFactor : (this._randomizationFactor = t, (e = this.backoff) === null || e === void 0 || e.setJitter(t), this);
|
|
2085
2085
|
}
|
|
2086
|
-
reconnectionDelayMax(
|
|
2087
|
-
var
|
|
2088
|
-
return
|
|
2086
|
+
reconnectionDelayMax(t) {
|
|
2087
|
+
var e;
|
|
2088
|
+
return t === void 0 ? this._reconnectionDelayMax : (this._reconnectionDelayMax = t, (e = this.backoff) === null || e === void 0 || e.setMax(t), this);
|
|
2089
2089
|
}
|
|
2090
|
-
timeout(
|
|
2091
|
-
return arguments.length ? (this._timeout =
|
|
2090
|
+
timeout(t) {
|
|
2091
|
+
return arguments.length ? (this._timeout = t, this) : this._timeout;
|
|
2092
2092
|
}
|
|
2093
2093
|
/**
|
|
2094
2094
|
* Starts trying to reconnect if reconnection is enabled and we have not
|
|
@@ -2106,23 +2106,23 @@ class Ce extends w {
|
|
|
2106
2106
|
* @return self
|
|
2107
2107
|
* @public
|
|
2108
2108
|
*/
|
|
2109
|
-
open(
|
|
2109
|
+
open(t) {
|
|
2110
2110
|
if (~this._readyState.indexOf("open"))
|
|
2111
2111
|
return this;
|
|
2112
|
-
this.engine = new
|
|
2113
|
-
const
|
|
2112
|
+
this.engine = new Rs(this.uri, this.opts);
|
|
2113
|
+
const e = this.engine, s = this;
|
|
2114
2114
|
this._readyState = "opening", this.skipReconnect = !1;
|
|
2115
|
-
const r =
|
|
2116
|
-
s.onopen(),
|
|
2115
|
+
const r = $(e, "open", function() {
|
|
2116
|
+
s.onopen(), t && t();
|
|
2117
2117
|
}), i = (h) => {
|
|
2118
|
-
this.cleanup(), this._readyState = "closed", this.emitReserved("error", h),
|
|
2119
|
-
}, o =
|
|
2118
|
+
this.cleanup(), this._readyState = "closed", this.emitReserved("error", h), t ? t(h) : this.maybeReconnectOnOpen();
|
|
2119
|
+
}, o = $(e, "error", i);
|
|
2120
2120
|
if (this._timeout !== !1) {
|
|
2121
|
-
const h = this._timeout,
|
|
2122
|
-
r(), i(new Error("timeout")),
|
|
2121
|
+
const h = this._timeout, u = this.setTimeoutFn(() => {
|
|
2122
|
+
r(), i(new Error("timeout")), e.close();
|
|
2123
2123
|
}, h);
|
|
2124
|
-
this.opts.autoUnref &&
|
|
2125
|
-
this.clearTimeoutFn(
|
|
2124
|
+
this.opts.autoUnref && u.unref(), this.subs.push(() => {
|
|
2125
|
+
this.clearTimeoutFn(u);
|
|
2126
2126
|
});
|
|
2127
2127
|
}
|
|
2128
2128
|
return this.subs.push(r), this.subs.push(o), this;
|
|
@@ -2133,8 +2133,8 @@ class Ce extends w {
|
|
|
2133
2133
|
* @return self
|
|
2134
2134
|
* @public
|
|
2135
2135
|
*/
|
|
2136
|
-
connect(
|
|
2137
|
-
return this.open(
|
|
2136
|
+
connect(t) {
|
|
2137
|
+
return this.open(t);
|
|
2138
2138
|
}
|
|
2139
2139
|
/**
|
|
2140
2140
|
* Called upon transport open.
|
|
@@ -2143,14 +2143,14 @@ class Ce extends w {
|
|
|
2143
2143
|
*/
|
|
2144
2144
|
onopen() {
|
|
2145
2145
|
this.cleanup(), this._readyState = "open", this.emitReserved("open");
|
|
2146
|
-
const
|
|
2146
|
+
const t = this.engine;
|
|
2147
2147
|
this.subs.push(
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2148
|
+
$(t, "ping", this.onping.bind(this)),
|
|
2149
|
+
$(t, "data", this.ondata.bind(this)),
|
|
2150
|
+
$(t, "error", this.onerror.bind(this)),
|
|
2151
|
+
$(t, "close", this.onclose.bind(this)),
|
|
2152
2152
|
// @ts-ignore
|
|
2153
|
-
|
|
2153
|
+
$(this.decoder, "decoded", this.ondecoded.bind(this))
|
|
2154
2154
|
);
|
|
2155
2155
|
}
|
|
2156
2156
|
/**
|
|
@@ -2166,11 +2166,11 @@ class Ce extends w {
|
|
|
2166
2166
|
*
|
|
2167
2167
|
* @private
|
|
2168
2168
|
*/
|
|
2169
|
-
ondata(
|
|
2169
|
+
ondata(t) {
|
|
2170
2170
|
try {
|
|
2171
|
-
this.decoder.add(
|
|
2172
|
-
} catch (
|
|
2173
|
-
this.onclose("parse error",
|
|
2171
|
+
this.decoder.add(t);
|
|
2172
|
+
} catch (e) {
|
|
2173
|
+
this.onclose("parse error", e);
|
|
2174
2174
|
}
|
|
2175
2175
|
}
|
|
2176
2176
|
/**
|
|
@@ -2178,9 +2178,9 @@ class Ce extends w {
|
|
|
2178
2178
|
*
|
|
2179
2179
|
* @private
|
|
2180
2180
|
*/
|
|
2181
|
-
ondecoded(
|
|
2182
|
-
|
|
2183
|
-
this.emitReserved("packet",
|
|
2181
|
+
ondecoded(t) {
|
|
2182
|
+
Rt(() => {
|
|
2183
|
+
this.emitReserved("packet", t);
|
|
2184
2184
|
}, this.setTimeoutFn);
|
|
2185
2185
|
}
|
|
2186
2186
|
/**
|
|
@@ -2188,8 +2188,8 @@ class Ce extends w {
|
|
|
2188
2188
|
*
|
|
2189
2189
|
* @private
|
|
2190
2190
|
*/
|
|
2191
|
-
onerror(
|
|
2192
|
-
this.emitReserved("error",
|
|
2191
|
+
onerror(t) {
|
|
2192
|
+
this.emitReserved("error", t);
|
|
2193
2193
|
}
|
|
2194
2194
|
/**
|
|
2195
2195
|
* Creates a new socket for the given `nsp`.
|
|
@@ -2197,9 +2197,9 @@ class Ce extends w {
|
|
|
2197
2197
|
* @return {Socket}
|
|
2198
2198
|
* @public
|
|
2199
2199
|
*/
|
|
2200
|
-
socket(
|
|
2201
|
-
let s = this.nsps[
|
|
2202
|
-
return s ? this._autoConnect && !s.active && s.connect() : (s = new
|
|
2200
|
+
socket(t, e) {
|
|
2201
|
+
let s = this.nsps[t];
|
|
2202
|
+
return s ? this._autoConnect && !s.active && s.connect() : (s = new De(this, t, e), this.nsps[t] = s), s;
|
|
2203
2203
|
}
|
|
2204
2204
|
/**
|
|
2205
2205
|
* Called upon a socket close.
|
|
@@ -2207,9 +2207,9 @@ class Ce extends w {
|
|
|
2207
2207
|
* @param socket
|
|
2208
2208
|
* @private
|
|
2209
2209
|
*/
|
|
2210
|
-
_destroy(
|
|
2211
|
-
const
|
|
2212
|
-
for (const s of
|
|
2210
|
+
_destroy(t) {
|
|
2211
|
+
const e = Object.keys(this.nsps);
|
|
2212
|
+
for (const s of e)
|
|
2213
2213
|
if (this.nsps[s].active)
|
|
2214
2214
|
return;
|
|
2215
2215
|
this._close();
|
|
@@ -2220,10 +2220,10 @@ class Ce extends w {
|
|
|
2220
2220
|
* @param packet
|
|
2221
2221
|
* @private
|
|
2222
2222
|
*/
|
|
2223
|
-
_packet(
|
|
2224
|
-
const
|
|
2225
|
-
for (let s = 0; s <
|
|
2226
|
-
this.engine.write(
|
|
2223
|
+
_packet(t) {
|
|
2224
|
+
const e = this.encoder.encode(t);
|
|
2225
|
+
for (let s = 0; s < e.length; s++)
|
|
2226
|
+
this.engine.write(e[s], t.options);
|
|
2227
2227
|
}
|
|
2228
2228
|
/**
|
|
2229
2229
|
* Clean up transport subscriptions and packet buffer.
|
|
@@ -2231,7 +2231,7 @@ class Ce extends w {
|
|
|
2231
2231
|
* @private
|
|
2232
2232
|
*/
|
|
2233
2233
|
cleanup() {
|
|
2234
|
-
this.subs.forEach((
|
|
2234
|
+
this.subs.forEach((t) => t()), this.subs.length = 0, this.decoder.destroy();
|
|
2235
2235
|
}
|
|
2236
2236
|
/**
|
|
2237
2237
|
* Close the current socket.
|
|
@@ -2258,9 +2258,9 @@ class Ce extends w {
|
|
|
2258
2258
|
*
|
|
2259
2259
|
* @private
|
|
2260
2260
|
*/
|
|
2261
|
-
onclose(
|
|
2261
|
+
onclose(t, e) {
|
|
2262
2262
|
var s;
|
|
2263
|
-
this.cleanup(), (s = this.engine) === null || s === void 0 || s.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close",
|
|
2263
|
+
this.cleanup(), (s = this.engine) === null || s === void 0 || s.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", t, e), this._reconnection && !this.skipReconnect && this.reconnect();
|
|
2264
2264
|
}
|
|
2265
2265
|
/**
|
|
2266
2266
|
* Attempt a reconnection.
|
|
@@ -2270,17 +2270,17 @@ class Ce extends w {
|
|
|
2270
2270
|
reconnect() {
|
|
2271
2271
|
if (this._reconnecting || this.skipReconnect)
|
|
2272
2272
|
return this;
|
|
2273
|
-
const
|
|
2273
|
+
const t = this;
|
|
2274
2274
|
if (this.backoff.attempts >= this._reconnectionAttempts)
|
|
2275
2275
|
this.backoff.reset(), this.emitReserved("reconnect_failed"), this._reconnecting = !1;
|
|
2276
2276
|
else {
|
|
2277
|
-
const
|
|
2277
|
+
const e = this.backoff.duration();
|
|
2278
2278
|
this._reconnecting = !0;
|
|
2279
2279
|
const s = this.setTimeoutFn(() => {
|
|
2280
|
-
|
|
2281
|
-
r ? (
|
|
2280
|
+
t.skipReconnect || (this.emitReserved("reconnect_attempt", t.backoff.attempts), !t.skipReconnect && t.open((r) => {
|
|
2281
|
+
r ? (t._reconnecting = !1, t.reconnect(), this.emitReserved("reconnect_error", r)) : t.onreconnect();
|
|
2282
2282
|
}));
|
|
2283
|
-
},
|
|
2283
|
+
}, e);
|
|
2284
2284
|
this.opts.autoUnref && s.unref(), this.subs.push(() => {
|
|
2285
2285
|
this.clearTimeoutFn(s);
|
|
2286
2286
|
});
|
|
@@ -2292,48 +2292,455 @@ class Ce extends w {
|
|
|
2292
2292
|
* @private
|
|
2293
2293
|
*/
|
|
2294
2294
|
onreconnect() {
|
|
2295
|
-
const
|
|
2296
|
-
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect",
|
|
2295
|
+
const t = this.backoff.attempts;
|
|
2296
|
+
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
|
|
2297
2297
|
}
|
|
2298
2298
|
}
|
|
2299
|
-
const
|
|
2300
|
-
function
|
|
2301
|
-
typeof n == "object" && (
|
|
2302
|
-
const
|
|
2303
|
-
let
|
|
2304
|
-
return h ?
|
|
2299
|
+
const rt = {};
|
|
2300
|
+
function ut(n, t) {
|
|
2301
|
+
typeof n == "object" && (t = n, n = void 0), t = t || {};
|
|
2302
|
+
const e = Cs(n, t.path || "/socket.io"), s = e.source, r = e.id, i = e.path, o = rt[r] && i in rt[r].nsps, h = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
|
|
2303
|
+
let u;
|
|
2304
|
+
return h ? u = new Vt(s, t) : (rt[r] || (rt[r] = new Vt(s, t)), u = rt[r]), e.query && !t.query && (t.query = e.queryKey), u.socket(e.path, t);
|
|
2305
2305
|
}
|
|
2306
|
-
Object.assign(
|
|
2307
|
-
Manager:
|
|
2308
|
-
Socket:
|
|
2309
|
-
io:
|
|
2310
|
-
connect:
|
|
2306
|
+
Object.assign(ut, {
|
|
2307
|
+
Manager: Vt,
|
|
2308
|
+
Socket: De,
|
|
2309
|
+
io: ut,
|
|
2310
|
+
connect: ut
|
|
2311
2311
|
});
|
|
2312
|
-
|
|
2313
|
-
|
|
2312
|
+
class _e extends Error {
|
|
2313
|
+
constructor(t, e) {
|
|
2314
|
+
super(
|
|
2315
|
+
`The document history advanced while this version was being prepared: expected head ${t}, found ${e ?? "none"}. Read the timeline again and rebuild on the new head.`
|
|
2316
|
+
), this.expectedGuid = t, this.actualGuid = e, this.name = "StaleHistoryError";
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
const be = "bimterop", Ee = "revitflow_history.json", it = "revitflow_ops.json", ve = "revitflow/ops@1", Vs = "revitflow_model.frag", Js = "revitflow_", _t = () => `v-${Date.now()}`;
|
|
2320
|
+
function Y(n) {
|
|
2321
|
+
return String(n._id ?? n.id ?? "");
|
|
2322
|
+
}
|
|
2323
|
+
var I, dt, Jt;
|
|
2324
|
+
class Ys {
|
|
2325
|
+
constructor(t, e) {
|
|
2326
|
+
_(this, dt);
|
|
2327
|
+
_(this, I);
|
|
2328
|
+
this.client = t, this.projectId = e;
|
|
2329
|
+
}
|
|
2330
|
+
/** The project's connected documents. */
|
|
2331
|
+
async docs() {
|
|
2332
|
+
const t = await a(this, dt, Jt).call(this);
|
|
2333
|
+
if (!t) return [];
|
|
2334
|
+
const e = await this.client.listFolders({
|
|
2335
|
+
parentFolderId: t,
|
|
2336
|
+
projectId: this.projectId
|
|
2337
|
+
}), s = [];
|
|
2338
|
+
for (const r of e) {
|
|
2339
|
+
const i = String(r.name ?? ""), o = i.indexOf("-");
|
|
2340
|
+
o <= 0 || s.push({
|
|
2341
|
+
source: i.slice(0, o),
|
|
2342
|
+
docId: i.slice(o + 1),
|
|
2343
|
+
modelName: void 0
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
return s;
|
|
2347
|
+
}
|
|
2348
|
+
/** One document's history. `source` and `docId` as {@link docs} lists them. */
|
|
2349
|
+
doc(t, e) {
|
|
2350
|
+
return new Ws(this.client, this, t, e);
|
|
2351
|
+
}
|
|
2352
|
+
/** @internal The `bimterop` folder id, resolved once. */
|
|
2353
|
+
async rootFolderId(t = !1) {
|
|
2354
|
+
if (l(this, I)) return l(this, I);
|
|
2355
|
+
const e = await a(this, dt, Jt).call(this);
|
|
2356
|
+
if (e) return e;
|
|
2357
|
+
if (!t) return;
|
|
2358
|
+
const s = await this.client.createFolder(
|
|
2359
|
+
be,
|
|
2360
|
+
void 0,
|
|
2361
|
+
this.projectId
|
|
2362
|
+
);
|
|
2363
|
+
return b(this, I, Y(s)), l(this, I);
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
I = new WeakMap(), dt = new WeakSet(), Jt = async function() {
|
|
2367
|
+
if (l(this, I)) return l(this, I);
|
|
2368
|
+
const e = (await this.client.listFolders({
|
|
2369
|
+
projectId: this.projectId
|
|
2370
|
+
})).find(
|
|
2371
|
+
(s) => String(s.name ?? "") === be && !s.parentId
|
|
2372
|
+
);
|
|
2373
|
+
return e && b(this, I, Y(e)), l(this, I);
|
|
2374
|
+
};
|
|
2375
|
+
var L, p, at, ct, Yt, Tt, St, Wt, kt, ht, Ot, Kt, je;
|
|
2376
|
+
class Ws {
|
|
2377
|
+
constructor(t, e, s, r) {
|
|
2378
|
+
_(this, p);
|
|
2379
|
+
_(this, L);
|
|
2380
|
+
this.client = t, this.project = e, this.source = s, this.docId = r;
|
|
2381
|
+
}
|
|
2382
|
+
// ─── Reading ───────────────────────────────────────────────────────────────
|
|
2383
|
+
/**
|
|
2384
|
+
* The document's versions, oldest first, ordered by the parent graph (not
|
|
2385
|
+
* by array position, which concurrent writers do not keep meaningful).
|
|
2386
|
+
* Each version gets its `ordinal` filled in.
|
|
2387
|
+
*/
|
|
2388
|
+
async timeline() {
|
|
2389
|
+
const t = await a(this, p, kt).call(this);
|
|
2390
|
+
return Me((t == null ? void 0 : t.commits) ?? []);
|
|
2391
|
+
}
|
|
2392
|
+
/** The head of the timeline, or null before the first sync. */
|
|
2393
|
+
async latest() {
|
|
2394
|
+
const t = await this.timeline();
|
|
2395
|
+
return t.length ? t[t.length - 1] : null;
|
|
2396
|
+
}
|
|
2397
|
+
/**
|
|
2398
|
+
* A version's delta geometry as a .frag. The baseline (`full`) versions have
|
|
2399
|
+
* no delta: their geometry IS the model file — use {@link model}.
|
|
2400
|
+
*/
|
|
2401
|
+
async delta(t) {
|
|
2402
|
+
if (!t.deltaId)
|
|
2403
|
+
throw new Error(
|
|
2404
|
+
`Version ${t.guid} carries no delta: it is a full export — read model() instead.`
|
|
2405
|
+
);
|
|
2406
|
+
return await (await this.client.downloadHiddenFile(t.deltaId)).blob();
|
|
2407
|
+
}
|
|
2408
|
+
/** The visible model .frag as last fully exported. */
|
|
2409
|
+
async model() {
|
|
2410
|
+
const t = await a(this, p, St).call(this);
|
|
2411
|
+
if (!t)
|
|
2412
|
+
throw new Error(
|
|
2413
|
+
`Document ${this.source}-${this.docId} has no model file yet.`
|
|
2414
|
+
);
|
|
2415
|
+
return await (await this.client.downloadFile(t.id)).blob();
|
|
2416
|
+
}
|
|
2417
|
+
// ─── Writing versions ─────────────────────────────────────────────────────
|
|
2418
|
+
/**
|
|
2419
|
+
* Appends one version: uploads the geometry it carries, then the updated
|
|
2420
|
+
* history. Give `expectedLatestGuid` whenever you built on a head you read,
|
|
2421
|
+
* so a concurrent writer surfaces as {@link StaleHistoryError} instead of a
|
|
2422
|
+
* silent fork.
|
|
2423
|
+
*/
|
|
2424
|
+
async sync(t) {
|
|
2425
|
+
var h;
|
|
2426
|
+
const e = await a(this, p, ct).call(this, !0);
|
|
2427
|
+
let s = await a(this, p, kt).call(this) ?? {
|
|
2428
|
+
model: this.docId,
|
|
2429
|
+
commits: []
|
|
2430
|
+
};
|
|
2431
|
+
const r = Te(s.commits);
|
|
2432
|
+
if (t.expectedLatestGuid !== void 0 && (r == null ? void 0 : r.guid) !== t.expectedLatestGuid)
|
|
2433
|
+
throw new _e(t.expectedLatestGuid, r == null ? void 0 : r.guid);
|
|
2434
|
+
const i = {
|
|
2435
|
+
guid: Se(),
|
|
2436
|
+
...r ? { parents: [r.guid] } : {},
|
|
2437
|
+
author: t.author,
|
|
2438
|
+
source: t.source,
|
|
2439
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2440
|
+
...t.message ? { message: t.message } : {},
|
|
2441
|
+
...t.userId ? { userId: t.userId } : {},
|
|
2442
|
+
...(h = t.appliedOps) != null && h.length ? { appliedOps: t.appliedOps } : {},
|
|
2443
|
+
changes: t.changes,
|
|
2444
|
+
counts: Ks(t.changes)
|
|
2445
|
+
};
|
|
2446
|
+
if (t.model && (await a(this, p, je).call(this, e, t.model), i.full = !0), t.delta) {
|
|
2447
|
+
const u = await a(this, p, St).call(this);
|
|
2448
|
+
if (!u)
|
|
2449
|
+
throw new Error(
|
|
2450
|
+
"A delta needs the model file to hang from: sync a full model first."
|
|
2451
|
+
);
|
|
2452
|
+
const f = await this.client.createHiddenFile(
|
|
2453
|
+
t.delta,
|
|
2454
|
+
u.id
|
|
2455
|
+
);
|
|
2456
|
+
i.deltaId = String(
|
|
2457
|
+
f._id ?? f.id
|
|
2458
|
+
);
|
|
2459
|
+
}
|
|
2460
|
+
const o = await a(this, p, kt).call(this);
|
|
2461
|
+
if (o) {
|
|
2462
|
+
s = o;
|
|
2463
|
+
const u = Te(s.commits);
|
|
2464
|
+
if (t.expectedLatestGuid !== void 0 && (u == null ? void 0 : u.guid) !== t.expectedLatestGuid)
|
|
2465
|
+
throw new _e(t.expectedLatestGuid, u == null ? void 0 : u.guid);
|
|
2466
|
+
u && !i.parents && (i.parents = [u.guid]);
|
|
2467
|
+
}
|
|
2468
|
+
return s.commits.push(i), await a(this, p, Ot).call(this, e, Ee, s), i;
|
|
2469
|
+
}
|
|
2470
|
+
// ─── Suggestions (change requests) ────────────────────────────────────────
|
|
2471
|
+
/** Every suggestion in the document's queue, pending or resolved. */
|
|
2472
|
+
async suggestions() {
|
|
2473
|
+
const t = await a(this, p, ht).call(this);
|
|
2474
|
+
return (t == null ? void 0 : t.ops) ?? [];
|
|
2475
|
+
}
|
|
2476
|
+
/** The suggestions still waiting for the owner, oldest first. */
|
|
2477
|
+
async pendingSuggestions() {
|
|
2478
|
+
return (await this.suggestions()).filter((t) => t.state === "pending");
|
|
2479
|
+
}
|
|
2480
|
+
/**
|
|
2481
|
+
* Queues a change request for this document. The payload, when given, is
|
|
2482
|
+
* uploaded as a hidden file under the suggestions index.
|
|
2483
|
+
*/
|
|
2484
|
+
async suggest(t) {
|
|
2485
|
+
const e = await a(this, p, ct).call(this, !0), s = await a(this, p, ht).call(this) ?? { schema: ve, ops: [] }, r = await a(this, p, Tt).call(this, it), i = {
|
|
2486
|
+
opId: Se(),
|
|
2487
|
+
title: t.title,
|
|
2488
|
+
verb: t.verb,
|
|
2489
|
+
author: t.author,
|
|
2490
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2491
|
+
state: "pending",
|
|
2492
|
+
...t.targets !== void 0 ? { targets: t.targets } : {},
|
|
2493
|
+
...t.batchId ? { batchId: t.batchId } : {},
|
|
2494
|
+
...t.userId ? { userId: t.userId } : {},
|
|
2495
|
+
...t.baseCommitGuid ? { baseCommitGuid: t.baseCommitGuid } : {}
|
|
2496
|
+
};
|
|
2497
|
+
if (t.payload) {
|
|
2498
|
+
const h = r ?? await a(this, p, Kt).call(this, e, it, s), u = await this.client.createHiddenFile(
|
|
2499
|
+
t.payload,
|
|
2500
|
+
h.id
|
|
2501
|
+
);
|
|
2502
|
+
i.fragId = String(
|
|
2503
|
+
u._id ?? u.id
|
|
2504
|
+
);
|
|
2505
|
+
}
|
|
2506
|
+
const o = await a(this, p, ht).call(this) ?? s;
|
|
2507
|
+
return o.schema ?? (o.schema = ve), o.ops.push(i), await a(this, p, Ot).call(this, e, it, o), i;
|
|
2508
|
+
}
|
|
2509
|
+
/** A suggestion's .frag payload. */
|
|
2510
|
+
async suggestionPayload(t) {
|
|
2511
|
+
if (!t.fragId)
|
|
2512
|
+
throw new Error(`Suggestion ${t.opId} carries no payload.`);
|
|
2513
|
+
return await (await this.client.downloadHiddenFile(t.fragId)).blob();
|
|
2514
|
+
}
|
|
2515
|
+
/**
|
|
2516
|
+
* Marks a suggestion applied (naming the version that materialised it) or
|
|
2517
|
+
* discarded. The native plugins do this themselves when they apply; apps
|
|
2518
|
+
* use it for `discarded`.
|
|
2519
|
+
*/
|
|
2520
|
+
async resolveSuggestion(t, e) {
|
|
2521
|
+
const s = await a(this, p, ct).call(this, !1);
|
|
2522
|
+
if (!s) throw new Error("This document has no suggestion queue.");
|
|
2523
|
+
const r = await a(this, p, ht).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === t);
|
|
2524
|
+
if (!r || !i)
|
|
2525
|
+
throw new Error(`No suggestion ${t} in this document's queue.`);
|
|
2526
|
+
return Object.assign(i, e), await a(this, p, Ot).call(this, s, it, r), i;
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
L = new WeakMap(), p = new WeakSet(), at = function() {
|
|
2530
|
+
return `${this.source}-${this.docId}`;
|
|
2531
|
+
}, ct = async function(t) {
|
|
2532
|
+
if (l(this, L)) return l(this, L);
|
|
2533
|
+
const e = await this.project.rootFolderId(t);
|
|
2534
|
+
if (!e)
|
|
2535
|
+
throw new Error(
|
|
2536
|
+
`Project ${this.project.projectId} has no connected documents yet.`
|
|
2537
|
+
);
|
|
2538
|
+
const r = (await this.client.listFolders({
|
|
2539
|
+
parentFolderId: e,
|
|
2540
|
+
projectId: this.project.projectId
|
|
2541
|
+
})).find(
|
|
2542
|
+
(o) => String(o.name ?? "") === l(this, p, at)
|
|
2543
|
+
);
|
|
2544
|
+
if (r)
|
|
2545
|
+
return b(this, L, Y(r)), l(this, L);
|
|
2546
|
+
if (!t)
|
|
2547
|
+
throw new Error(
|
|
2548
|
+
`Document ${l(this, p, at)} does not exist in this project.`
|
|
2549
|
+
);
|
|
2550
|
+
const i = await this.client.createFolder(
|
|
2551
|
+
l(this, p, at),
|
|
2552
|
+
e,
|
|
2553
|
+
this.project.projectId
|
|
2554
|
+
);
|
|
2555
|
+
return b(this, L, Y(i)), l(this, L);
|
|
2556
|
+
}, Yt = async function() {
|
|
2557
|
+
const t = await a(this, p, ct).call(this, !1);
|
|
2558
|
+
return (await this.client.listFiles({ folderId: t })).map((s) => ({
|
|
2559
|
+
id: Y(s),
|
|
2560
|
+
name: String(s.name ?? "")
|
|
2561
|
+
}));
|
|
2562
|
+
}, Tt = async function(t) {
|
|
2563
|
+
try {
|
|
2564
|
+
return (await a(this, p, Yt).call(this)).find((e) => e.name === t);
|
|
2565
|
+
} catch {
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
}, St = async function() {
|
|
2569
|
+
try {
|
|
2570
|
+
const t = await a(this, p, Yt).call(this);
|
|
2571
|
+
return t.find((e) => e.name === Vs) ?? t.find(
|
|
2572
|
+
(e) => e.name.endsWith(".frag") && !e.name.startsWith(Js)
|
|
2573
|
+
);
|
|
2574
|
+
} catch {
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
}, Wt = async function(t) {
|
|
2578
|
+
const e = await a(this, p, Tt).call(this, t);
|
|
2579
|
+
if (!e) return;
|
|
2580
|
+
const r = await (await this.client.downloadFile(e.id)).text();
|
|
2581
|
+
if (r.trim())
|
|
2582
|
+
return JSON.parse(r);
|
|
2583
|
+
}, kt = function() {
|
|
2584
|
+
return a(this, p, Wt).call(this, Ee);
|
|
2585
|
+
}, ht = function() {
|
|
2586
|
+
return a(this, p, Wt).call(this, it);
|
|
2587
|
+
}, Ot = async function(t, e, s) {
|
|
2588
|
+
const r = new Blob([JSON.stringify(s)], {
|
|
2589
|
+
type: "application/json"
|
|
2590
|
+
}), i = await a(this, p, Tt).call(this, e);
|
|
2591
|
+
return i ? (await this.client.updateFile(i.id, {
|
|
2592
|
+
file: r,
|
|
2593
|
+
versionTag: _t()
|
|
2594
|
+
}), i) : await a(this, p, Kt).call(this, t, e, s);
|
|
2595
|
+
}, Kt = async function(t, e, s) {
|
|
2596
|
+
const r = new Blob([JSON.stringify(s)], {
|
|
2597
|
+
type: "application/json"
|
|
2598
|
+
}), i = await this.client.createFile({
|
|
2599
|
+
file: r,
|
|
2600
|
+
name: e,
|
|
2601
|
+
versionTag: _t(),
|
|
2602
|
+
parentFolderId: t,
|
|
2603
|
+
projectId: this.project.projectId
|
|
2604
|
+
}), o = i.item;
|
|
2605
|
+
return { id: Y(o ?? i), name: e };
|
|
2606
|
+
}, je = async function(t, e) {
|
|
2607
|
+
const s = await a(this, p, St).call(this);
|
|
2608
|
+
if (s)
|
|
2609
|
+
return await this.client.updateFile(s.id, {
|
|
2610
|
+
file: e,
|
|
2611
|
+
versionTag: _t()
|
|
2612
|
+
}), s;
|
|
2613
|
+
const r = `${l(this, p, at)}.frag`, i = await this.client.createFile({
|
|
2614
|
+
file: e,
|
|
2615
|
+
name: r,
|
|
2616
|
+
versionTag: _t(),
|
|
2617
|
+
parentFolderId: t,
|
|
2618
|
+
projectId: this.project.projectId
|
|
2619
|
+
}), o = i.item;
|
|
2620
|
+
return { id: Y(o ?? i), name: r };
|
|
2621
|
+
};
|
|
2622
|
+
function Ks(n) {
|
|
2623
|
+
const t = { added: 0, modified: 0, removed: 0 };
|
|
2624
|
+
for (const e of n)
|
|
2625
|
+
e.type === "create" ? t.added++ : e.type === "delete" ? t.removed++ : t.modified++;
|
|
2626
|
+
return t;
|
|
2627
|
+
}
|
|
2628
|
+
function Me(n) {
|
|
2629
|
+
var u;
|
|
2630
|
+
if (n.length <= 1)
|
|
2631
|
+
return n.forEach((f, y) => f.ordinal = y), [...n];
|
|
2632
|
+
const t = new Map(n.map((f) => [f.guid, f])), e = /* @__PURE__ */ new Map(), s = [];
|
|
2633
|
+
for (const f of n) {
|
|
2634
|
+
const y = (u = f.parents) == null ? void 0 : u[0];
|
|
2635
|
+
if (y && t.has(y)) {
|
|
2636
|
+
const w = e.get(y) ?? [];
|
|
2637
|
+
w.push(f), e.set(y, w);
|
|
2638
|
+
} else
|
|
2639
|
+
s.push(f);
|
|
2640
|
+
}
|
|
2641
|
+
const r = (f, y) => String(f.timestamp).localeCompare(String(y.timestamp));
|
|
2642
|
+
s.sort(r);
|
|
2643
|
+
const i = [], o = [...s].reverse(), h = /* @__PURE__ */ new Set();
|
|
2644
|
+
for (; o.length; ) {
|
|
2645
|
+
const f = o.pop();
|
|
2646
|
+
if (h.has(f.guid)) continue;
|
|
2647
|
+
h.add(f.guid), i.push(f);
|
|
2648
|
+
const y = (e.get(f.guid) ?? []).sort(r);
|
|
2649
|
+
for (let w = y.length - 1; w >= 0; w--) o.push(y[w]);
|
|
2650
|
+
}
|
|
2651
|
+
for (const f of n)
|
|
2652
|
+
h.has(f.guid) || i.push(f);
|
|
2653
|
+
return i.forEach((f, y) => f.ordinal = y), i;
|
|
2654
|
+
}
|
|
2655
|
+
function Te(n) {
|
|
2656
|
+
const t = Me(n);
|
|
2657
|
+
return t[t.length - 1];
|
|
2658
|
+
}
|
|
2659
|
+
function Se() {
|
|
2660
|
+
const n = globalThis.crypto;
|
|
2661
|
+
return n != null && n.randomUUID ? n.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
|
|
2662
|
+
const e = Math.random() * 16 | 0;
|
|
2663
|
+
return (t === "x" ? e : e & 3 | 8).toString(16);
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
var j;
|
|
2667
|
+
class Xs {
|
|
2668
|
+
constructor(t) {
|
|
2669
|
+
_(this, j, /* @__PURE__ */ new Map());
|
|
2670
|
+
this.client = t;
|
|
2671
|
+
}
|
|
2672
|
+
/** Registers a recipe. One per name; a second with the same name throws. */
|
|
2673
|
+
register(t) {
|
|
2674
|
+
if (l(this, j).has(t.name))
|
|
2675
|
+
throw new Error(`A recipe named "${t.name}" is already registered.`);
|
|
2676
|
+
l(this, j).set(t.name, t);
|
|
2677
|
+
}
|
|
2678
|
+
/** The registered recipes, optionally filtered by target application. */
|
|
2679
|
+
list(t) {
|
|
2680
|
+
return [...l(this, j).values()].filter(
|
|
2681
|
+
(s) => (!(t != null && t.to) || s.to === t.to) && (!(t != null && t.input) || s.inputs.includes(t.input))
|
|
2682
|
+
);
|
|
2683
|
+
}
|
|
2684
|
+
/** A registered recipe by name, or undefined. */
|
|
2685
|
+
get(t) {
|
|
2686
|
+
return l(this, j).get(t);
|
|
2687
|
+
}
|
|
2688
|
+
/**
|
|
2689
|
+
* Runs a recipe and queues its suggestion on the target document. Safe to
|
|
2690
|
+
* call freely: nothing touches the native application until its owner
|
|
2691
|
+
* accepts the suggestion there.
|
|
2692
|
+
*/
|
|
2693
|
+
async run(t, e) {
|
|
2694
|
+
const s = l(this, j).get(t);
|
|
2695
|
+
if (!s) throw new Error(`No recipe named "${t}" is registered.`);
|
|
2696
|
+
if (s.to !== e.target.source)
|
|
2697
|
+
throw new Error(
|
|
2698
|
+
`Recipe "${t}" writes ${s.to}, but the target document belongs to ${e.target.source}.`
|
|
2699
|
+
);
|
|
2700
|
+
const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o = await s.run({
|
|
2701
|
+
client: this.client,
|
|
2702
|
+
projectId: e.projectId,
|
|
2703
|
+
targetDoc: r,
|
|
2704
|
+
input: e.input,
|
|
2705
|
+
settings: e.settings ?? {}
|
|
2706
|
+
});
|
|
2707
|
+
return { suggestion: await r.suggest({
|
|
2708
|
+
title: o.title,
|
|
2709
|
+
verb: o.verb,
|
|
2710
|
+
author: e.author,
|
|
2711
|
+
payload: o.payload,
|
|
2712
|
+
targets: o.targets,
|
|
2713
|
+
userId: e.userId,
|
|
2714
|
+
baseCommitGuid: i == null ? void 0 : i.guid
|
|
2715
|
+
}), result: o };
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
j = new WeakMap();
|
|
2719
|
+
const ke = 100;
|
|
2720
|
+
function zs(n) {
|
|
2314
2721
|
try {
|
|
2315
|
-
const
|
|
2316
|
-
if (
|
|
2317
|
-
const
|
|
2722
|
+
const t = JSON.parse(n);
|
|
2723
|
+
if (t && typeof t == "object") {
|
|
2724
|
+
const e = t;
|
|
2318
2725
|
return {
|
|
2319
|
-
message: typeof
|
|
2320
|
-
code: typeof
|
|
2321
|
-
details:
|
|
2726
|
+
message: typeof e.message == "string" ? e.message : void 0,
|
|
2727
|
+
code: typeof e.code == "string" ? e.code : void 0,
|
|
2728
|
+
details: e.details
|
|
2322
2729
|
};
|
|
2323
2730
|
}
|
|
2324
2731
|
} catch {
|
|
2325
2732
|
}
|
|
2326
2733
|
return {};
|
|
2327
2734
|
}
|
|
2328
|
-
function
|
|
2735
|
+
function Qs(n) {
|
|
2329
2736
|
if (!n || typeof n != "object") return;
|
|
2330
|
-
const
|
|
2331
|
-
return typeof
|
|
2737
|
+
const t = n.retryAfter;
|
|
2738
|
+
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
|
|
2332
2739
|
}
|
|
2333
|
-
class
|
|
2334
|
-
constructor(
|
|
2335
|
-
const o =
|
|
2336
|
-
super(o.message ?? `${s || "Request failed"} (${
|
|
2740
|
+
class le extends Error {
|
|
2741
|
+
constructor(e, s, r, i) {
|
|
2742
|
+
const o = zs(r);
|
|
2743
|
+
super(o.message ?? `${s || "Request failed"} (${e})`);
|
|
2337
2744
|
T(this, "status");
|
|
2338
2745
|
T(this, "code");
|
|
2339
2746
|
T(this, "details");
|
|
@@ -2343,32 +2750,32 @@ class Ve extends Error {
|
|
|
2343
2750
|
* from `details.retryAfter`. Only present on rate-limited (429) responses.
|
|
2344
2751
|
*/
|
|
2345
2752
|
T(this, "retryAfter");
|
|
2346
|
-
this.name = "RequestError", this.status =
|
|
2753
|
+
this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? Qs(o.details);
|
|
2347
2754
|
}
|
|
2348
2755
|
}
|
|
2349
|
-
const
|
|
2350
|
-
function
|
|
2756
|
+
const C = "item/folder", m = "item", U = "processor", Zs = "npm-registry", B = "hidden", qt = "FILE", Ft = "TOOL", Ut = "APP", tn = 500, Oe = 3e4, en = 0.25, sn = (n) => new Promise((t) => setTimeout(t, n));
|
|
2757
|
+
function nn(n) {
|
|
2351
2758
|
var r, i;
|
|
2352
|
-
const
|
|
2353
|
-
if (!
|
|
2354
|
-
const
|
|
2355
|
-
if (Number.isFinite(
|
|
2356
|
-
const s = Date.parse(
|
|
2759
|
+
const t = (i = (r = n.headers) == null ? void 0 : r.get) == null ? void 0 : i.call(r, "Retry-After");
|
|
2760
|
+
if (!t) return;
|
|
2761
|
+
const e = Number(t);
|
|
2762
|
+
if (Number.isFinite(e)) return Math.max(0, e);
|
|
2763
|
+
const s = Date.parse(t);
|
|
2357
2764
|
if (!Number.isNaN(s))
|
|
2358
2765
|
return Math.max(0, (s - Date.now()) / 1e3);
|
|
2359
2766
|
}
|
|
2360
|
-
function
|
|
2361
|
-
return n instanceof
|
|
2767
|
+
function rn(n) {
|
|
2768
|
+
return n instanceof le ? n.status === 429 || n.status >= 500 : !0;
|
|
2362
2769
|
}
|
|
2363
|
-
function
|
|
2364
|
-
const
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
), s =
|
|
2368
|
-
return r != null ? Math.min(r,
|
|
2770
|
+
function on(n, t) {
|
|
2771
|
+
const e = Math.min(
|
|
2772
|
+
tn * 2 ** t,
|
|
2773
|
+
Oe
|
|
2774
|
+
), s = e * en * Math.random(), r = n instanceof le && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
|
|
2775
|
+
return r != null ? Math.min(r, Oe) + s : e + s;
|
|
2369
2776
|
}
|
|
2370
|
-
var c,
|
|
2371
|
-
const
|
|
2777
|
+
var c, zt, d, D, ft, lt, At, xt, Qt, Zt, He;
|
|
2778
|
+
const ue = class ue {
|
|
2372
2779
|
/**
|
|
2373
2780
|
* Creates a new EngineServicesClient instance.
|
|
2374
2781
|
* @param accessToken - API access token (obtained from the platform dashboard)
|
|
@@ -2376,7 +2783,7 @@ const Je = class Je {
|
|
|
2376
2783
|
* @param apiUrl - Base URL of the API (e.g. "https://api.thatopen.com").
|
|
2377
2784
|
* @param props - Optional configuration (retry count, auth mode, etc.).
|
|
2378
2785
|
*/
|
|
2379
|
-
constructor(
|
|
2786
|
+
constructor(t, e, s) {
|
|
2380
2787
|
_(this, c);
|
|
2381
2788
|
T(this, "apiUrl");
|
|
2382
2789
|
T(this, "accessToken");
|
|
@@ -2396,11 +2803,12 @@ const Je = class Je {
|
|
|
2396
2803
|
* Populated automatically when using {@link fromPlatformContext}.
|
|
2397
2804
|
*/
|
|
2398
2805
|
T(this, "context");
|
|
2806
|
+
_(this, ft);
|
|
2399
2807
|
const { retries: r = 0, useBearer: i = !1, localServerUrl: o } = s || {};
|
|
2400
|
-
let h =
|
|
2401
|
-
if (h.charAt(h.length - 1) === "/" && (h = h.slice(0, -1)), this.apiUrl = `${h}/api`, this.accessToken =
|
|
2402
|
-
let
|
|
2403
|
-
|
|
2808
|
+
let h = e;
|
|
2809
|
+
if (h.charAt(h.length - 1) === "/" && (h = h.slice(0, -1)), this.apiUrl = `${h}/api`, this.accessToken = t, this.wsUrl = h, this.retries = r, this.useBearer = i, this.context = { appId: "", projectId: "", accessToken: t, apiUrl: e }, o) {
|
|
2810
|
+
let u = o;
|
|
2811
|
+
u.charAt(u.length - 1) === "/" && (u = u.slice(0, -1)), this.localServerUrl = u;
|
|
2404
2812
|
}
|
|
2405
2813
|
}
|
|
2406
2814
|
/**
|
|
@@ -2419,12 +2827,12 @@ const Je = class Je {
|
|
|
2419
2827
|
* console.log(client.context.projectId);
|
|
2420
2828
|
* ```
|
|
2421
2829
|
*/
|
|
2422
|
-
static fromPlatformContext(
|
|
2423
|
-
const
|
|
2424
|
-
...
|
|
2830
|
+
static fromPlatformContext(t) {
|
|
2831
|
+
const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new ue(e.accessToken, e.apiUrl, {
|
|
2832
|
+
...t,
|
|
2425
2833
|
useBearer: !0
|
|
2426
2834
|
});
|
|
2427
|
-
return s.context =
|
|
2835
|
+
return s.context = e, s;
|
|
2428
2836
|
}
|
|
2429
2837
|
/**
|
|
2430
2838
|
* Sets the number of automatic retries for failed requests. Retries use
|
|
@@ -2432,8 +2840,8 @@ const Je = class Je {
|
|
|
2432
2840
|
* failures, 429s and 5xx are retried.
|
|
2433
2841
|
* @param retries - Number of retries (0 = no retries).
|
|
2434
2842
|
*/
|
|
2435
|
-
setRetries(
|
|
2436
|
-
this.retries =
|
|
2843
|
+
setRetries(t) {
|
|
2844
|
+
this.retries = t;
|
|
2437
2845
|
}
|
|
2438
2846
|
/**
|
|
2439
2847
|
* Registers the global libraries that built-in components need at runtime.
|
|
@@ -2466,8 +2874,8 @@ const Je = class Je {
|
|
|
2466
2874
|
* await client.initBuiltInComponent(ModelsPanel, components);
|
|
2467
2875
|
* ```
|
|
2468
2876
|
*/
|
|
2469
|
-
setBuiltInGlobals(
|
|
2470
|
-
this.builtInGlobals =
|
|
2877
|
+
setBuiltInGlobals(t) {
|
|
2878
|
+
this.builtInGlobals = t;
|
|
2471
2879
|
}
|
|
2472
2880
|
/**
|
|
2473
2881
|
* Protected extension point for subclasses that need dynamic tokens
|
|
@@ -2495,8 +2903,8 @@ const Je = class Je {
|
|
|
2495
2903
|
* to the private `#requestApi` implementation so retry / auth / query-
|
|
2496
2904
|
* cleaning logic is applied identically.
|
|
2497
2905
|
*/
|
|
2498
|
-
async request(
|
|
2499
|
-
return a(this, c,
|
|
2906
|
+
async request(t, e, s) {
|
|
2907
|
+
return a(this, c, d).call(this, t, e, s);
|
|
2500
2908
|
}
|
|
2501
2909
|
// ─── Files ───────────────────────────────────────────────────────
|
|
2502
2910
|
/**
|
|
@@ -2504,11 +2912,11 @@ const Je = class Je {
|
|
|
2504
2912
|
* @param filters - Optional filters for folder and archive status.
|
|
2505
2913
|
* @returns Array of file items.
|
|
2506
2914
|
*/
|
|
2507
|
-
async listFiles(
|
|
2508
|
-
const { folderId:
|
|
2509
|
-
return
|
|
2915
|
+
async listFiles(t) {
|
|
2916
|
+
const { folderId: e, archived: s, projectId: r } = t || {};
|
|
2917
|
+
return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, { query: { itemType: qt, archived: s } }) : await a(this, c, d).call(this, "GET", `${m}`, {
|
|
2510
2918
|
query: {
|
|
2511
|
-
itemType:
|
|
2919
|
+
itemType: qt,
|
|
2512
2920
|
archived: s,
|
|
2513
2921
|
...r && { projectId: r }
|
|
2514
2922
|
}
|
|
@@ -2520,16 +2928,16 @@ const Je = class Je {
|
|
|
2520
2928
|
* @param props - Options such as whether to include versions.
|
|
2521
2929
|
* @returns The file item, optionally with version history.
|
|
2522
2930
|
*/
|
|
2523
|
-
async getFile(
|
|
2524
|
-
return await a(this, c,
|
|
2931
|
+
async getFile(t, e) {
|
|
2932
|
+
return await a(this, c, Zt).call(this, t, e);
|
|
2525
2933
|
}
|
|
2526
2934
|
/**
|
|
2527
2935
|
* Uploads a new file.
|
|
2528
2936
|
* @param fileData - File content, name, and version tag.
|
|
2529
2937
|
* @returns The created item and its first version.
|
|
2530
2938
|
*/
|
|
2531
|
-
async createFile(
|
|
2532
|
-
return await a(this, c,
|
|
2939
|
+
async createFile(t) {
|
|
2940
|
+
return await a(this, c, xt).call(this, t, qt);
|
|
2533
2941
|
}
|
|
2534
2942
|
/**
|
|
2535
2943
|
* Updates an existing file. Can rename, move to a different folder,
|
|
@@ -2538,22 +2946,22 @@ const Je = class Je {
|
|
|
2538
2946
|
* @param fileData - Properties to update (name, folderId, file, versionTag).
|
|
2539
2947
|
* @returns The updated item and/or the new version.
|
|
2540
2948
|
*/
|
|
2541
|
-
async updateFile(
|
|
2542
|
-
return await a(this, c,
|
|
2949
|
+
async updateFile(t, e) {
|
|
2950
|
+
return await a(this, c, Qt).call(this, t, e);
|
|
2543
2951
|
}
|
|
2544
2952
|
/**
|
|
2545
2953
|
* Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
|
|
2546
2954
|
* @param fileId - The file's unique identifier.
|
|
2547
2955
|
*/
|
|
2548
|
-
async archiveFile(
|
|
2549
|
-
return await a(this, c,
|
|
2956
|
+
async archiveFile(t) {
|
|
2957
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
|
|
2550
2958
|
}
|
|
2551
2959
|
/**
|
|
2552
2960
|
* Recovers a previously archived file.
|
|
2553
2961
|
* @param fileId - The file's unique identifier.
|
|
2554
2962
|
*/
|
|
2555
|
-
async recoverFile(
|
|
2556
|
-
return await a(this, c,
|
|
2963
|
+
async recoverFile(t) {
|
|
2964
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${t}/recover`);
|
|
2557
2965
|
}
|
|
2558
2966
|
/**
|
|
2559
2967
|
* Downloads a file's content. Returns the raw fetch Response.
|
|
@@ -2561,8 +2969,8 @@ const Je = class Je {
|
|
|
2561
2969
|
* @param params - Optional version selection parameters.
|
|
2562
2970
|
* @returns A fetch Response containing the file data.
|
|
2563
2971
|
*/
|
|
2564
|
-
async downloadFile(
|
|
2565
|
-
return await a(this, c,
|
|
2972
|
+
async downloadFile(t, e) {
|
|
2973
|
+
return await a(this, c, At).call(this, t, e);
|
|
2566
2974
|
}
|
|
2567
2975
|
/**
|
|
2568
2976
|
* Retrieves the free-JSON metadata for a specific file version.
|
|
@@ -2571,9 +2979,9 @@ const Je = class Je {
|
|
|
2571
2979
|
* @param versionTag - The version tag (e.g. "v1").
|
|
2572
2980
|
* @param params - Optional flags such as `withDraft`.
|
|
2573
2981
|
*/
|
|
2574
|
-
async getFileVersionMetadata(
|
|
2982
|
+
async getFileVersionMetadata(t, e, s) {
|
|
2575
2983
|
const { withDraft: r } = s || {};
|
|
2576
|
-
return await a(this, c,
|
|
2984
|
+
return await a(this, c, d).call(this, "GET", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
|
|
2577
2985
|
query: {
|
|
2578
2986
|
...r && { withDraft: "true" }
|
|
2579
2987
|
}
|
|
@@ -2585,8 +2993,8 @@ const Je = class Je {
|
|
|
2585
2993
|
* @param versionTag - The version tag.
|
|
2586
2994
|
* @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
|
|
2587
2995
|
*/
|
|
2588
|
-
async updateFileVersionMetadata(
|
|
2589
|
-
return await a(this, c,
|
|
2996
|
+
async updateFileVersionMetadata(t, e, s) {
|
|
2997
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
|
|
2590
2998
|
body: JSON.stringify({ metadata: s }),
|
|
2591
2999
|
contentType: "application/json"
|
|
2592
3000
|
});
|
|
@@ -2596,8 +3004,8 @@ const Je = class Je {
|
|
|
2596
3004
|
* @param fileId - The file's unique identifier.
|
|
2597
3005
|
* @param versionTag - The version tag.
|
|
2598
3006
|
*/
|
|
2599
|
-
async deleteFileVersionMetadata(
|
|
2600
|
-
return await a(this, c,
|
|
3007
|
+
async deleteFileVersionMetadata(t, e) {
|
|
3008
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`);
|
|
2601
3009
|
}
|
|
2602
3010
|
/**
|
|
2603
3011
|
* Batch variant of {@link getFileVersionMetadata}. Reads the metadata of
|
|
@@ -2612,9 +3020,9 @@ const Je = class Je {
|
|
|
2612
3020
|
* @param entries - The `{ itemId, versionTag }` pairs to read.
|
|
2613
3021
|
* @param params - Optional flags such as `withDraft`.
|
|
2614
3022
|
*/
|
|
2615
|
-
async getFileVersionMetadataBatch(
|
|
2616
|
-
const { withDraft: s } =
|
|
2617
|
-
return await a(this, c,
|
|
3023
|
+
async getFileVersionMetadataBatch(t, e) {
|
|
3024
|
+
const { withDraft: s } = e || {};
|
|
3025
|
+
return await a(this, c, lt).call(this, t, async (r) => (await a(this, c, d).call(this, "POST", `${m}/batch/version-metadata`, {
|
|
2618
3026
|
body: JSON.stringify({
|
|
2619
3027
|
entries: r,
|
|
2620
3028
|
...s !== void 0 && { withDraft: s }
|
|
@@ -2628,12 +3036,12 @@ const Je = class Je {
|
|
|
2628
3036
|
* @param params - Optional filters for parent folder and archive status.
|
|
2629
3037
|
* @returns Array of folder items.
|
|
2630
3038
|
*/
|
|
2631
|
-
async listFolders(
|
|
2632
|
-
const { archived:
|
|
2633
|
-
return await a(this, c,
|
|
3039
|
+
async listFolders(t) {
|
|
3040
|
+
const { archived: e, parentFolderId: s, projectId: r } = t || {};
|
|
3041
|
+
return await a(this, c, d).call(this, "GET", C, {
|
|
2634
3042
|
query: {
|
|
2635
3043
|
parentFolderId: s,
|
|
2636
|
-
archived:
|
|
3044
|
+
archived: e,
|
|
2637
3045
|
...r && { projectId: r }
|
|
2638
3046
|
}
|
|
2639
3047
|
});
|
|
@@ -2642,8 +3050,8 @@ const Je = class Je {
|
|
|
2642
3050
|
* Gets a single folder by ID.
|
|
2643
3051
|
* @param folderId - The folder's unique identifier.
|
|
2644
3052
|
*/
|
|
2645
|
-
async getFolder(
|
|
2646
|
-
return await a(this, c,
|
|
3053
|
+
async getFolder(t) {
|
|
3054
|
+
return await a(this, c, d).call(this, "GET", `${C}/${t}`);
|
|
2647
3055
|
}
|
|
2648
3056
|
/**
|
|
2649
3057
|
* Batch variant of {@link getFolder}. Resolves a known set of folder ids in
|
|
@@ -2658,9 +3066,9 @@ const Je = class Je {
|
|
|
2658
3066
|
*
|
|
2659
3067
|
* @param folderIds - The folder ids to resolve.
|
|
2660
3068
|
*/
|
|
2661
|
-
async getFoldersBatch(
|
|
2662
|
-
return await a(this, c,
|
|
2663
|
-
body: JSON.stringify({ folderIds:
|
|
3069
|
+
async getFoldersBatch(t) {
|
|
3070
|
+
return await a(this, c, lt).call(this, t, async (e) => (await a(this, c, d).call(this, "POST", `${m}/batch/folders`, {
|
|
3071
|
+
body: JSON.stringify({ folderIds: e }),
|
|
2664
3072
|
contentType: "application/json"
|
|
2665
3073
|
})).results);
|
|
2666
3074
|
}
|
|
@@ -2670,11 +3078,11 @@ const Je = class Je {
|
|
|
2670
3078
|
* @param parentId - Optional parent folder ID for nesting.
|
|
2671
3079
|
* @returns The created folder.
|
|
2672
3080
|
*/
|
|
2673
|
-
async createFolder(
|
|
2674
|
-
return await a(this, c,
|
|
3081
|
+
async createFolder(t, e, s) {
|
|
3082
|
+
return await a(this, c, d).call(this, "POST", C, {
|
|
2675
3083
|
body: JSON.stringify({
|
|
2676
|
-
name:
|
|
2677
|
-
...
|
|
3084
|
+
name: t,
|
|
3085
|
+
...e && { parentId: e },
|
|
2678
3086
|
...s && { projectId: s }
|
|
2679
3087
|
}),
|
|
2680
3088
|
contentType: "application/json"
|
|
@@ -2686,9 +3094,9 @@ const Je = class Je {
|
|
|
2686
3094
|
* @param updateFolderParams - New name for the folder.
|
|
2687
3095
|
* @returns The updated folder.
|
|
2688
3096
|
*/
|
|
2689
|
-
async updateFolder(
|
|
2690
|
-
const { name: s } =
|
|
2691
|
-
return await a(this, c,
|
|
3097
|
+
async updateFolder(t, e) {
|
|
3098
|
+
const { name: s } = e;
|
|
3099
|
+
return await a(this, c, d).call(this, "PUT", `${C}/${t}`, {
|
|
2692
3100
|
body: JSON.stringify({ name: s }),
|
|
2693
3101
|
contentType: "application/json"
|
|
2694
3102
|
});
|
|
@@ -2697,23 +3105,23 @@ const Je = class Je {
|
|
|
2697
3105
|
* Archives (soft-deletes) a folder. Can be recovered with {@link recoverFolder}.
|
|
2698
3106
|
* @param folderId - The folder's unique identifier.
|
|
2699
3107
|
*/
|
|
2700
|
-
async archiveFolder(
|
|
2701
|
-
return await a(this, c,
|
|
3108
|
+
async archiveFolder(t) {
|
|
3109
|
+
return await a(this, c, d).call(this, "DELETE", `${C}/${t}`);
|
|
2702
3110
|
}
|
|
2703
3111
|
/**
|
|
2704
3112
|
* Recovers a previously archived folder.
|
|
2705
3113
|
* @param folderId - The folder's unique identifier.
|
|
2706
3114
|
*/
|
|
2707
|
-
async recoverFolder(
|
|
2708
|
-
return await a(this, c,
|
|
3115
|
+
async recoverFolder(t) {
|
|
3116
|
+
return await a(this, c, d).call(this, "PUT", `${C}/${t}/recover`);
|
|
2709
3117
|
}
|
|
2710
3118
|
/**
|
|
2711
3119
|
* Downloads an entire folder as a ZIP archive.
|
|
2712
3120
|
* @param folderId - The folder's unique identifier.
|
|
2713
3121
|
* @returns A fetch Response containing the ZIP data.
|
|
2714
3122
|
*/
|
|
2715
|
-
async downloadFolder(
|
|
2716
|
-
return await a(this, c,
|
|
3123
|
+
async downloadFolder(t) {
|
|
3124
|
+
return await a(this, c, D).call(this, `${C}/${t}/download`);
|
|
2717
3125
|
}
|
|
2718
3126
|
// ─── Components ──────────────────────────────────────────────────
|
|
2719
3127
|
/**
|
|
@@ -2721,16 +3129,16 @@ const Je = class Je {
|
|
|
2721
3129
|
* @param params - Optional filters for folder and version inclusion.
|
|
2722
3130
|
* @returns Array of component items.
|
|
2723
3131
|
*/
|
|
2724
|
-
async listComponents(
|
|
2725
|
-
const { folderId:
|
|
2726
|
-
return
|
|
3132
|
+
async listComponents(t) {
|
|
3133
|
+
const { folderId: e, ShowVersions: s, projectId: r } = t || {};
|
|
3134
|
+
return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, {
|
|
2727
3135
|
query: {
|
|
2728
|
-
itemType:
|
|
3136
|
+
itemType: Ft,
|
|
2729
3137
|
...s && { ShowVersions: s }
|
|
2730
3138
|
}
|
|
2731
|
-
}) : await a(this, c,
|
|
3139
|
+
}) : await a(this, c, d).call(this, "GET", `${m}`, {
|
|
2732
3140
|
query: {
|
|
2733
|
-
itemType:
|
|
3141
|
+
itemType: Ft,
|
|
2734
3142
|
...s && { ShowVersions: s },
|
|
2735
3143
|
...r && { projectId: r }
|
|
2736
3144
|
}
|
|
@@ -2741,17 +3149,17 @@ const Je = class Je {
|
|
|
2741
3149
|
* @param componentId - The component's unique identifier.
|
|
2742
3150
|
* @param props - Options such as whether to include versions.
|
|
2743
3151
|
*/
|
|
2744
|
-
async getComponent(
|
|
2745
|
-
return await a(this, c,
|
|
3152
|
+
async getComponent(t, e) {
|
|
3153
|
+
return await a(this, c, Zt).call(this, t, e);
|
|
2746
3154
|
}
|
|
2747
3155
|
/**
|
|
2748
3156
|
* Creates a new component with the given file and version properties.
|
|
2749
3157
|
* @param componentData - File content, name, version tag, and component-specific props.
|
|
2750
3158
|
* @returns The created component item and its first version.
|
|
2751
3159
|
*/
|
|
2752
|
-
async createComponent(
|
|
2753
|
-
const { componentProps:
|
|
2754
|
-
return await a(this, c,
|
|
3160
|
+
async createComponent(t) {
|
|
3161
|
+
const { componentProps: e } = t;
|
|
3162
|
+
return await a(this, c, xt).call(this, t, Ft, e);
|
|
2755
3163
|
}
|
|
2756
3164
|
/**
|
|
2757
3165
|
* Updates an existing component. Can rename, move, and/or upload a new version.
|
|
@@ -2759,9 +3167,9 @@ const Je = class Je {
|
|
|
2759
3167
|
* @param componentData - Properties to update, including optional new componentProps.
|
|
2760
3168
|
* @returns The updated item and/or new version.
|
|
2761
3169
|
*/
|
|
2762
|
-
async updateComponent(
|
|
2763
|
-
const { componentProps: s } =
|
|
2764
|
-
return await a(this, c,
|
|
3170
|
+
async updateComponent(t, e) {
|
|
3171
|
+
const { componentProps: s } = e;
|
|
3172
|
+
return await a(this, c, Qt).call(this, t, e, s);
|
|
2765
3173
|
}
|
|
2766
3174
|
/**
|
|
2767
3175
|
* Downloads a component's full ZIP file. Returns the raw fetch Response.
|
|
@@ -2769,8 +3177,8 @@ const Je = class Je {
|
|
|
2769
3177
|
* @param params - Optional version selection parameters.
|
|
2770
3178
|
* @returns A fetch Response containing the ZIP data.
|
|
2771
3179
|
*/
|
|
2772
|
-
async downloadComponent(
|
|
2773
|
-
return await a(this, c,
|
|
3180
|
+
async downloadComponent(t, e) {
|
|
3181
|
+
return await a(this, c, At).call(this, t, e);
|
|
2774
3182
|
}
|
|
2775
3183
|
/**
|
|
2776
3184
|
* Downloads only the JavaScript bundle from a component's ZIP.
|
|
@@ -2779,9 +3187,9 @@ const Je = class Je {
|
|
|
2779
3187
|
* @param params - Optional version selection parameters.
|
|
2780
3188
|
* @returns A fetch Response containing the bundle JavaScript text.
|
|
2781
3189
|
*/
|
|
2782
|
-
async downloadComponentBundle(
|
|
2783
|
-
const { versionTag: s, withDraft: r } =
|
|
2784
|
-
return await a(this, c,
|
|
3190
|
+
async downloadComponentBundle(t, e) {
|
|
3191
|
+
const { versionTag: s, withDraft: r } = e || {};
|
|
3192
|
+
return await a(this, c, D).call(this, `${m}/${t}/download/bundle`, {
|
|
2785
3193
|
query: {
|
|
2786
3194
|
...s && { versionTag: s },
|
|
2787
3195
|
...r && { withDraft: r }
|
|
@@ -2792,15 +3200,15 @@ const Je = class Je {
|
|
|
2792
3200
|
* Archives (soft-deletes) a component. Can be recovered with {@link recoverComponent}.
|
|
2793
3201
|
* @param componentId - The component's unique identifier.
|
|
2794
3202
|
*/
|
|
2795
|
-
async archiveComponent(
|
|
2796
|
-
return await a(this, c,
|
|
3203
|
+
async archiveComponent(t) {
|
|
3204
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
|
|
2797
3205
|
}
|
|
2798
3206
|
/**
|
|
2799
3207
|
* Recovers a previously archived component.
|
|
2800
3208
|
* @param componentId - The component's unique identifier.
|
|
2801
3209
|
*/
|
|
2802
|
-
async recoverComponent(
|
|
2803
|
-
return await a(this, c,
|
|
3210
|
+
async recoverComponent(t) {
|
|
3211
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${t}/recover`);
|
|
2804
3212
|
}
|
|
2805
3213
|
// ─── Built-in Components ─────────────────────────────────────────
|
|
2806
3214
|
/**
|
|
@@ -2808,8 +3216,8 @@ const Je = class Je {
|
|
|
2808
3216
|
* @param name - The built-in component name (e.g. "hello-world").
|
|
2809
3217
|
* @returns The component's JavaScript source code as a string.
|
|
2810
3218
|
*/
|
|
2811
|
-
async getBuiltInComponent(
|
|
2812
|
-
return await (await a(this, c,
|
|
3219
|
+
async getBuiltInComponent(t) {
|
|
3220
|
+
return await (await a(this, c, D).call(this, `built-in/${t}/bundle`)).text();
|
|
2813
3221
|
}
|
|
2814
3222
|
/**
|
|
2815
3223
|
* Fetches a built-in component bundle, evaluates it, and registers it
|
|
@@ -2837,10 +3245,10 @@ const Je = class Je {
|
|
|
2837
3245
|
* await client.initBuiltInComponent(HelloWorld, components, { OBC, BUI });
|
|
2838
3246
|
* ```
|
|
2839
3247
|
*/
|
|
2840
|
-
async initBuiltInComponent(
|
|
2841
|
-
const r = await this.getBuiltInComponent(
|
|
2842
|
-
return main;`)(...h), y = (
|
|
2843
|
-
|
|
3248
|
+
async initBuiltInComponent(t, e, s) {
|
|
3249
|
+
const r = await this.getBuiltInComponent(t.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), h = o.map((w) => i[w]), f = new Function(...o, `${r}
|
|
3250
|
+
return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
3251
|
+
e.get(y);
|
|
2844
3252
|
}
|
|
2845
3253
|
/**
|
|
2846
3254
|
* Loads multiple built-in components in parallel.
|
|
@@ -2856,9 +3264,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2856
3264
|
* await client.initBuiltInComponents(components, AppManager, ViewportManager);
|
|
2857
3265
|
* ```
|
|
2858
3266
|
*/
|
|
2859
|
-
async initBuiltInComponents(
|
|
3267
|
+
async initBuiltInComponents(t, ...e) {
|
|
2860
3268
|
await Promise.all(
|
|
2861
|
-
|
|
3269
|
+
e.map((s) => this.initBuiltInComponent(s, t))
|
|
2862
3270
|
);
|
|
2863
3271
|
}
|
|
2864
3272
|
/**
|
|
@@ -2881,23 +3289,23 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2881
3289
|
* const { element, world } = await viewports.create();
|
|
2882
3290
|
* ```
|
|
2883
3291
|
*/
|
|
2884
|
-
async setup(
|
|
3292
|
+
async setup(t, ...e) {
|
|
2885
3293
|
var o, h;
|
|
2886
|
-
const s =
|
|
3294
|
+
const s = t.OBC, r = t.BUI;
|
|
2887
3295
|
if (!(s != null && s.Components))
|
|
2888
3296
|
throw new Error("globals.OBC must include Components");
|
|
2889
3297
|
if (!(r != null && r.Manager)) throw new Error("globals.BUI must include Manager");
|
|
2890
3298
|
const i = new s.Components();
|
|
2891
|
-
return r.Manager.init(), this.setBuiltInGlobals(
|
|
3299
|
+
return r.Manager.init(), this.setBuiltInGlobals(t), await this.initBuiltInComponents(i, ...e), i.init(), (h = (o = this.context.appEventOrchestrator) == null ? void 0 : o.appLoaded) == null || h.call(o), { components: i };
|
|
2892
3300
|
}
|
|
2893
3301
|
/**
|
|
2894
3302
|
* Reports an error to the platform via the {@link AppEventOrchestrator.appError} callback.
|
|
2895
3303
|
* @param code - Numeric error code.
|
|
2896
3304
|
* @param data - Arbitrary error data to send to the platform.
|
|
2897
3305
|
*/
|
|
2898
|
-
throwError(
|
|
3306
|
+
throwError(t, e) {
|
|
2899
3307
|
var s, r;
|
|
2900
|
-
(r = (s = this.context.appEventOrchestrator) == null ? void 0 : s.appError) == null || r.call(s,
|
|
3308
|
+
(r = (s = this.context.appEventOrchestrator) == null ? void 0 : s.appError) == null || r.call(s, t, e);
|
|
2901
3309
|
}
|
|
2902
3310
|
// ─── Apps ────────────────────────────────────────────────────────
|
|
2903
3311
|
/**
|
|
@@ -2905,16 +3313,16 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2905
3313
|
* @param params - Optional filters for folder and version inclusion.
|
|
2906
3314
|
* @returns Array of app items.
|
|
2907
3315
|
*/
|
|
2908
|
-
async listApps(
|
|
2909
|
-
const { folderId:
|
|
2910
|
-
return
|
|
3316
|
+
async listApps(t) {
|
|
3317
|
+
const { folderId: e, ShowVersions: s, projectId: r } = t || {};
|
|
3318
|
+
return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, {
|
|
2911
3319
|
query: {
|
|
2912
|
-
itemType:
|
|
3320
|
+
itemType: Ut,
|
|
2913
3321
|
...s && { ShowVersions: s }
|
|
2914
3322
|
}
|
|
2915
|
-
}) : await a(this, c,
|
|
3323
|
+
}) : await a(this, c, d).call(this, "GET", `${m}`, {
|
|
2916
3324
|
query: {
|
|
2917
|
-
itemType:
|
|
3325
|
+
itemType: Ut,
|
|
2918
3326
|
...s && { ShowVersions: s },
|
|
2919
3327
|
...r && { projectId: r }
|
|
2920
3328
|
}
|
|
@@ -2925,9 +3333,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2925
3333
|
* @param appData - File content, name, version tag, and optional app-specific props.
|
|
2926
3334
|
* @returns The created app item and its first version.
|
|
2927
3335
|
*/
|
|
2928
|
-
async createApp(
|
|
2929
|
-
const { appProps:
|
|
2930
|
-
return await a(this, c,
|
|
3336
|
+
async createApp(t) {
|
|
3337
|
+
const { appProps: e } = t;
|
|
3338
|
+
return await a(this, c, xt).call(this, t, Ut, e);
|
|
2931
3339
|
}
|
|
2932
3340
|
/**
|
|
2933
3341
|
* Downloads an app's full ZIP file. Returns the raw fetch Response.
|
|
@@ -2935,8 +3343,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2935
3343
|
* @param params - Optional version selection parameters.
|
|
2936
3344
|
* @returns A fetch Response containing the ZIP data.
|
|
2937
3345
|
*/
|
|
2938
|
-
async downloadApp(
|
|
2939
|
-
return await a(this, c,
|
|
3346
|
+
async downloadApp(t, e) {
|
|
3347
|
+
return await a(this, c, At).call(this, t, e);
|
|
2940
3348
|
}
|
|
2941
3349
|
/**
|
|
2942
3350
|
* Downloads only the JavaScript bundle from an app's ZIP.
|
|
@@ -2945,9 +3353,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2945
3353
|
* @param params - Optional version selection parameters.
|
|
2946
3354
|
* @returns A fetch Response containing the bundle JavaScript text.
|
|
2947
3355
|
*/
|
|
2948
|
-
async downloadAppBundle(
|
|
2949
|
-
const { versionTag: s, withDraft: r } =
|
|
2950
|
-
return await a(this, c,
|
|
3356
|
+
async downloadAppBundle(t, e) {
|
|
3357
|
+
const { versionTag: s, withDraft: r } = e || {};
|
|
3358
|
+
return await a(this, c, D).call(this, `${m}/${t}/download/bundle`, {
|
|
2951
3359
|
query: {
|
|
2952
3360
|
...s && { versionTag: s },
|
|
2953
3361
|
...r && { withDraft: r }
|
|
@@ -2958,8 +3366,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2958
3366
|
* Archives (soft-deletes) an app.
|
|
2959
3367
|
* @param appId - The app's unique identifier.
|
|
2960
3368
|
*/
|
|
2961
|
-
async archiveApp(
|
|
2962
|
-
return await a(this, c,
|
|
3369
|
+
async archiveApp(t) {
|
|
3370
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
|
|
2963
3371
|
}
|
|
2964
3372
|
// ─── NPM Registry ────────────────────────────────────────────────
|
|
2965
3373
|
/**
|
|
@@ -2971,7 +3379,7 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2971
3379
|
* @returns The registry, scope, read-only token, and assembled `.npmrc`.
|
|
2972
3380
|
*/
|
|
2973
3381
|
async getNpmCredentials() {
|
|
2974
|
-
return await a(this, c,
|
|
3382
|
+
return await a(this, c, d).call(this, "GET", `${Zs}/credentials`);
|
|
2975
3383
|
}
|
|
2976
3384
|
// ─── Execution ───────────────────────────────────────────────────
|
|
2977
3385
|
/**
|
|
@@ -2988,12 +3396,12 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2988
3396
|
* @param versionTag - Optional version to execute (defaults to latest).
|
|
2989
3397
|
* @returns An object containing the `executionId` to track progress.
|
|
2990
3398
|
*/
|
|
2991
|
-
async executeComponent(
|
|
3399
|
+
async executeComponent(t, e, s) {
|
|
2992
3400
|
if (this.localServerUrl) {
|
|
2993
|
-
const r = `${this.localServerUrl}/api/${
|
|
3401
|
+
const r = `${this.localServerUrl}/api/${U}/${t}/execute`, i = await fetch(r, {
|
|
2994
3402
|
method: "POST",
|
|
2995
3403
|
headers: { "Content-Type": "application/json" },
|
|
2996
|
-
body: JSON.stringify(
|
|
3404
|
+
body: JSON.stringify(e)
|
|
2997
3405
|
});
|
|
2998
3406
|
if (!i.ok) {
|
|
2999
3407
|
const o = await i.text().catch(() => "");
|
|
@@ -3003,8 +3411,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3003
3411
|
}
|
|
3004
3412
|
return await i.json();
|
|
3005
3413
|
}
|
|
3006
|
-
return await a(this, c,
|
|
3007
|
-
body: JSON.stringify(
|
|
3414
|
+
return await a(this, c, d).call(this, "POST", `${U}/${t}/execute`, {
|
|
3415
|
+
body: JSON.stringify(e),
|
|
3008
3416
|
query: { ...s && { versionTag: s } },
|
|
3009
3417
|
contentType: "application/json"
|
|
3010
3418
|
});
|
|
@@ -3013,9 +3421,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3013
3421
|
* Aborts a running execution.
|
|
3014
3422
|
* @param executionId - The execution's unique identifier.
|
|
3015
3423
|
*/
|
|
3016
|
-
async abortExecution(
|
|
3424
|
+
async abortExecution(t) {
|
|
3017
3425
|
if (this.localServerUrl) {
|
|
3018
|
-
const
|
|
3426
|
+
const e = `${this.localServerUrl}/api/${U}/progress/${t}/abort`, s = await fetch(e, { method: "POST" });
|
|
3019
3427
|
if (!s.ok) {
|
|
3020
3428
|
const r = await s.text().catch(() => "");
|
|
3021
3429
|
throw new Error(
|
|
@@ -3024,7 +3432,7 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3024
3432
|
}
|
|
3025
3433
|
return await s.json();
|
|
3026
3434
|
}
|
|
3027
|
-
return await a(this, c,
|
|
3435
|
+
return await a(this, c, d).call(this, "POST", `${U}/progress/${t}/abort`);
|
|
3028
3436
|
}
|
|
3029
3437
|
/**
|
|
3030
3438
|
* Lists all executions for a given component.
|
|
@@ -3039,9 +3447,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3039
3447
|
* @param projectId - Optional project scope.
|
|
3040
3448
|
* @returns Array of execution entities.
|
|
3041
3449
|
*/
|
|
3042
|
-
async listExecutions(
|
|
3450
|
+
async listExecutions(t, e) {
|
|
3043
3451
|
if (this.localServerUrl) {
|
|
3044
|
-
const s =
|
|
3452
|
+
const s = e ? `?projectId=${encodeURIComponent(e)}` : "", r = `${this.localServerUrl}/api/${U}/${t}/progress${s}`, i = await fetch(r);
|
|
3045
3453
|
if (!i.ok) {
|
|
3046
3454
|
const o = await i.text().catch(() => "");
|
|
3047
3455
|
throw new Error(
|
|
@@ -3050,16 +3458,16 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3050
3458
|
}
|
|
3051
3459
|
return await i.json();
|
|
3052
3460
|
}
|
|
3053
|
-
return await a(this, c,
|
|
3461
|
+
return await a(this, c, d).call(this, "GET", `${U}/${t}/progress`, { query: { ...e && { projectId: e } } });
|
|
3054
3462
|
}
|
|
3055
3463
|
/**
|
|
3056
3464
|
* Gets details of a specific execution, including its messages.
|
|
3057
3465
|
* @param executionId - The execution's unique identifier.
|
|
3058
3466
|
* @returns The execution entity with progress and result info.
|
|
3059
3467
|
*/
|
|
3060
|
-
async getExecution(
|
|
3468
|
+
async getExecution(t) {
|
|
3061
3469
|
if (this.localServerUrl) {
|
|
3062
|
-
const
|
|
3470
|
+
const e = `${this.localServerUrl}/api/${U}/progress/${t}`, s = await fetch(e);
|
|
3063
3471
|
if (!s.ok) {
|
|
3064
3472
|
const r = await s.text().catch(() => "");
|
|
3065
3473
|
throw new Error(
|
|
@@ -3068,7 +3476,7 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3068
3476
|
}
|
|
3069
3477
|
return await s.json();
|
|
3070
3478
|
}
|
|
3071
|
-
return await a(this, c,
|
|
3479
|
+
return await a(this, c, d).call(this, "GET", `${U}/progress/${t}`);
|
|
3072
3480
|
}
|
|
3073
3481
|
/**
|
|
3074
3482
|
* Subscribes to real-time execution progress via WebSocket.
|
|
@@ -3076,19 +3484,36 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3076
3484
|
* @param executionId - The execution's unique identifier.
|
|
3077
3485
|
* @param onUpdateCallback - Callback invoked on each progress/result event.
|
|
3078
3486
|
*/
|
|
3079
|
-
async onExecutionProgress(
|
|
3080
|
-
const s = this.localServerUrl ?? this.wsUrl, r = await
|
|
3487
|
+
async onExecutionProgress(t, e) {
|
|
3488
|
+
const s = this.localServerUrl ?? this.wsUrl, r = await ut(s, {
|
|
3081
3489
|
auth: { accessToken: this.accessToken },
|
|
3082
3490
|
transports: ["websocket"]
|
|
3083
3491
|
});
|
|
3084
3492
|
r.on("connect", function() {
|
|
3085
|
-
r.emit("executionSubscription", JSON.stringify({ executionId:
|
|
3086
|
-
|
|
3493
|
+
r.emit("executionSubscription", JSON.stringify({ executionId: t })), r.on("execution", (i) => {
|
|
3494
|
+
e(i);
|
|
3087
3495
|
});
|
|
3088
3496
|
}), r.on("connect_error", function(i) {
|
|
3089
3497
|
console.log(i);
|
|
3090
3498
|
});
|
|
3091
3499
|
}
|
|
3500
|
+
// ─── History & Recipes ───────────────────────────────────────────
|
|
3501
|
+
/**
|
|
3502
|
+
* A project's history of connected documents (Revit models, AutoCAD
|
|
3503
|
+
* drawings…): their version timelines and their change requests. See
|
|
3504
|
+
* `src/core/history.ts` — this surface is the only supported way to read
|
|
3505
|
+
* or write it; the storage underneath is private and will move.
|
|
3506
|
+
*/
|
|
3507
|
+
history(t) {
|
|
3508
|
+
return new Ys(this, t);
|
|
3509
|
+
}
|
|
3510
|
+
/**
|
|
3511
|
+
* The recipe registry and runner: scripts that write change requests in a
|
|
3512
|
+
* native application's language. See `src/core/recipes.ts`.
|
|
3513
|
+
*/
|
|
3514
|
+
get recipes() {
|
|
3515
|
+
return l(this, ft) ?? b(this, ft, new Xs(this)), l(this, ft);
|
|
3516
|
+
}
|
|
3092
3517
|
// ─── Hidden Files ────────────────────────────────────────────────
|
|
3093
3518
|
/**
|
|
3094
3519
|
* Creates a hidden file attached to a parent item (e.g., dependencies, assets).
|
|
@@ -3099,9 +3524,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3099
3524
|
* letters, digits and `:._-`, starting with a letter or digit.
|
|
3100
3525
|
* @returns The hidden file ID.
|
|
3101
3526
|
*/
|
|
3102
|
-
async createHiddenFile(
|
|
3527
|
+
async createHiddenFile(t, e, s) {
|
|
3103
3528
|
const r = new FormData();
|
|
3104
|
-
return r.append("file",
|
|
3529
|
+
return r.append("file", t), r.append("parentItemId", e), s != null && r.append("tag", s), await a(this, c, d).call(this, "POST", `${m}/${B}`, {
|
|
3105
3530
|
body: r
|
|
3106
3531
|
});
|
|
3107
3532
|
}
|
|
@@ -3115,11 +3540,11 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3115
3540
|
* applies to every file in the batch.
|
|
3116
3541
|
* @returns One result per uploaded file, in order, each with its hidden file ID.
|
|
3117
3542
|
*/
|
|
3118
|
-
async createHiddenFilesBatch(
|
|
3543
|
+
async createHiddenFilesBatch(t, e, s) {
|
|
3119
3544
|
const r = new FormData();
|
|
3120
|
-
for (const i of
|
|
3545
|
+
for (const i of t)
|
|
3121
3546
|
r.append("files", i);
|
|
3122
|
-
return r.append("parentItemId",
|
|
3547
|
+
return r.append("parentItemId", e), s != null && r.append("tag", s), await a(this, c, d).call(this, "POST", `${m}/${B}/batch`, {
|
|
3123
3548
|
body: r
|
|
3124
3549
|
});
|
|
3125
3550
|
}
|
|
@@ -3127,22 +3552,22 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3127
3552
|
* Deletes a hidden file by its ID.
|
|
3128
3553
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3129
3554
|
*/
|
|
3130
|
-
async deleteHiddenFile(
|
|
3131
|
-
return await a(this, c,
|
|
3555
|
+
async deleteHiddenFile(t) {
|
|
3556
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${B}/${t}`);
|
|
3132
3557
|
}
|
|
3133
3558
|
/**
|
|
3134
3559
|
* Gets metadata for a hidden file.
|
|
3135
3560
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3136
3561
|
*/
|
|
3137
|
-
async getHiddenFile(
|
|
3138
|
-
return await a(this, c,
|
|
3562
|
+
async getHiddenFile(t) {
|
|
3563
|
+
return await a(this, c, d).call(this, "GET", `${m}/${B}/${t}`);
|
|
3139
3564
|
}
|
|
3140
3565
|
/**
|
|
3141
3566
|
* Downloads a hidden file's content. Returns the raw fetch Response.
|
|
3142
3567
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3143
3568
|
*/
|
|
3144
|
-
async downloadHiddenFile(
|
|
3145
|
-
return await a(this, c,
|
|
3569
|
+
async downloadHiddenFile(t) {
|
|
3570
|
+
return await a(this, c, D).call(this, `${m}/${B}/${t}/download`);
|
|
3146
3571
|
}
|
|
3147
3572
|
/**
|
|
3148
3573
|
* Mints a short-lived presigned URL for a hidden file so the browser can
|
|
@@ -3161,8 +3586,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3161
3586
|
* @returns `{ url, expiresAt }` — `url` is the presigned GET URL, `expiresAt`
|
|
3162
3587
|
* an ISO timestamp when it stops working.
|
|
3163
3588
|
*/
|
|
3164
|
-
async getHiddenFileSignedUrl(
|
|
3165
|
-
return await a(this, c,
|
|
3589
|
+
async getHiddenFileSignedUrl(t, e) {
|
|
3590
|
+
return await a(this, c, d).call(this, "GET", `${m}/${B}/${t}/signed-url`, { ...e != null && { query: { expiresIn: e } } });
|
|
3166
3591
|
}
|
|
3167
3592
|
/**
|
|
3168
3593
|
* Batch variant of {@link getHiddenFileSignedUrl}. Mints presigned URLs for
|
|
@@ -3182,11 +3607,11 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3182
3607
|
* @param expiresIn - Desired URL lifetime in seconds (60–3600). Defaults to
|
|
3183
3608
|
* 900 (15 min) server-side; values are clamped to that range.
|
|
3184
3609
|
*/
|
|
3185
|
-
async getHiddenFileSignedUrlsBatch(
|
|
3186
|
-
return await a(this, c,
|
|
3610
|
+
async getHiddenFileSignedUrlsBatch(t, e) {
|
|
3611
|
+
return await a(this, c, lt).call(this, t, async (s) => (await a(this, c, d).call(this, "POST", `${m}/${B}/signed-url/batch`, {
|
|
3187
3612
|
body: JSON.stringify({
|
|
3188
3613
|
hiddenFileIds: s,
|
|
3189
|
-
...
|
|
3614
|
+
...e != null && { expiresIn: e }
|
|
3190
3615
|
}),
|
|
3191
3616
|
contentType: "application/json"
|
|
3192
3617
|
})).results);
|
|
@@ -3198,15 +3623,15 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3198
3623
|
* tagged listing comes back in creation order.
|
|
3199
3624
|
* @returns Array of hidden file entities.
|
|
3200
3625
|
*/
|
|
3201
|
-
async getHiddenFilesByParent(
|
|
3202
|
-
return await a(this, c,
|
|
3626
|
+
async getHiddenFilesByParent(t, e) {
|
|
3627
|
+
return await a(this, c, d).call(this, "GET", `${m}/${t}/${B}`, { ...e != null && { query: { tag: e } } });
|
|
3203
3628
|
}
|
|
3204
3629
|
/**
|
|
3205
3630
|
* Deletes all hidden files attached to a parent item.
|
|
3206
3631
|
* @param parentFileId - The parent item's unique identifier.
|
|
3207
3632
|
*/
|
|
3208
|
-
async deleteHiddenFilesByParent(
|
|
3209
|
-
return await a(this, c,
|
|
3633
|
+
async deleteHiddenFilesByParent(t) {
|
|
3634
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}/${B}`);
|
|
3210
3635
|
}
|
|
3211
3636
|
// ─── Icons ───────────────────────────────────────────────────────
|
|
3212
3637
|
/**
|
|
@@ -3216,9 +3641,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3216
3641
|
* @param icon - The icon image file (File in browsers, Blob in Node.js).
|
|
3217
3642
|
* @returns The updated item with `iconFileId` and `iconMimeType` set.
|
|
3218
3643
|
*/
|
|
3219
|
-
async uploadItemIcon(
|
|
3644
|
+
async uploadItemIcon(t, e) {
|
|
3220
3645
|
const s = new FormData();
|
|
3221
|
-
return s.append("icon",
|
|
3646
|
+
return s.append("icon", e), await a(this, c, d).call(this, "PUT", `${m}/${t}/icon`, {
|
|
3222
3647
|
body: s
|
|
3223
3648
|
});
|
|
3224
3649
|
}
|
|
@@ -3227,16 +3652,16 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3227
3652
|
* @param itemId - The item's unique identifier.
|
|
3228
3653
|
* @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
|
|
3229
3654
|
*/
|
|
3230
|
-
async getItemIcon(
|
|
3231
|
-
return await a(this, c,
|
|
3655
|
+
async getItemIcon(t) {
|
|
3656
|
+
return await a(this, c, D).call(this, `${m}/${t}/icon`);
|
|
3232
3657
|
}
|
|
3233
3658
|
/**
|
|
3234
3659
|
* Removes the icon from an item.
|
|
3235
3660
|
* @param itemId - The item's unique identifier.
|
|
3236
3661
|
* @returns The updated item with icon fields removed.
|
|
3237
3662
|
*/
|
|
3238
|
-
async removeItemIcon(
|
|
3239
|
-
return await a(this, c,
|
|
3663
|
+
async removeItemIcon(t) {
|
|
3664
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}/icon`);
|
|
3240
3665
|
}
|
|
3241
3666
|
// ─── General Item Operations ─────────────────────────────────────
|
|
3242
3667
|
/**
|
|
@@ -3245,9 +3670,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3245
3670
|
* @param params - New name and/or new folder ID.
|
|
3246
3671
|
* @returns The updated item.
|
|
3247
3672
|
*/
|
|
3248
|
-
async updateItem(
|
|
3249
|
-
return await a(this, c,
|
|
3250
|
-
body: JSON.stringify(
|
|
3673
|
+
async updateItem(t, e) {
|
|
3674
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
|
|
3675
|
+
body: JSON.stringify(e),
|
|
3251
3676
|
contentType: "application/json"
|
|
3252
3677
|
});
|
|
3253
3678
|
}
|
|
@@ -3261,9 +3686,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3261
3686
|
* @param metadata - Optional free-JSON metadata to store on the new version.
|
|
3262
3687
|
* @returns The created version.
|
|
3263
3688
|
*/
|
|
3264
|
-
async createVersion(
|
|
3689
|
+
async createVersion(t, e, s, r, i) {
|
|
3265
3690
|
const o = new FormData();
|
|
3266
|
-
return o.append("file",
|
|
3691
|
+
return o.append("file", e), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await a(this, c, d).call(this, "POST", `${m}/${t}/version`, { body: o });
|
|
3267
3692
|
}
|
|
3268
3693
|
/**
|
|
3269
3694
|
* Lists versions of an item. Pass `archived: true` to fetch only archived
|
|
@@ -3272,8 +3697,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3272
3697
|
* @param params - Optional `{ archived }` filter.
|
|
3273
3698
|
* @returns Array of versions, sorted by creation date descending.
|
|
3274
3699
|
*/
|
|
3275
|
-
async listVersions(
|
|
3276
|
-
return await a(this, c,
|
|
3700
|
+
async listVersions(t, e = {}) {
|
|
3701
|
+
return await a(this, c, d).call(this, "GET", `${m}/${encodeURIComponent(t)}/versions`, { query: e });
|
|
3277
3702
|
}
|
|
3278
3703
|
/**
|
|
3279
3704
|
* Batch variant of {@link listVersions}. Lists the versions of many items in
|
|
@@ -3290,9 +3715,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3290
3715
|
* @param itemIds - The items whose versions to list.
|
|
3291
3716
|
* @param params - Optional `{ archived }` filter, applied to every item.
|
|
3292
3717
|
*/
|
|
3293
|
-
async listVersionsBatch(
|
|
3294
|
-
const { archived: s } =
|
|
3295
|
-
return await a(this, c,
|
|
3718
|
+
async listVersionsBatch(t, e = {}) {
|
|
3719
|
+
const { archived: s } = e;
|
|
3720
|
+
return await a(this, c, lt).call(this, t, async (r) => (await a(this, c, d).call(this, "POST", `${m}/batch/versions`, {
|
|
3296
3721
|
body: JSON.stringify({
|
|
3297
3722
|
itemIds: r,
|
|
3298
3723
|
...s !== void 0 && { archived: s }
|
|
@@ -3309,8 +3734,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3309
3734
|
* @param versionTag - The version's tag (e.g. "v2").
|
|
3310
3735
|
* @returns The archived version.
|
|
3311
3736
|
*/
|
|
3312
|
-
async archiveVersion(
|
|
3313
|
-
return await a(this, c,
|
|
3737
|
+
async archiveVersion(t, e) {
|
|
3738
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/archive`);
|
|
3314
3739
|
}
|
|
3315
3740
|
/**
|
|
3316
3741
|
* Recovers a previously archived version, restoring it to the active list.
|
|
@@ -3318,8 +3743,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3318
3743
|
* @param versionTag - The version's tag (e.g. "v2").
|
|
3319
3744
|
* @returns The recovered version.
|
|
3320
3745
|
*/
|
|
3321
|
-
async recoverVersion(
|
|
3322
|
-
return await a(this, c,
|
|
3746
|
+
async recoverVersion(t, e) {
|
|
3747
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/recover`);
|
|
3323
3748
|
}
|
|
3324
3749
|
/**
|
|
3325
3750
|
* Permanently deletes a version, including its file in object storage.
|
|
@@ -3327,55 +3752,55 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3327
3752
|
* @param itemId - The item's unique identifier.
|
|
3328
3753
|
* @param versionTag - The version's tag (e.g. "v2").
|
|
3329
3754
|
*/
|
|
3330
|
-
async deleteVersion(
|
|
3331
|
-
return await a(this, c,
|
|
3755
|
+
async deleteVersion(t, e) {
|
|
3756
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
|
|
3332
3757
|
}
|
|
3333
3758
|
};
|
|
3334
|
-
c = new WeakSet(),
|
|
3335
|
-
return `${this.apiUrl}/${
|
|
3336
|
-
},
|
|
3337
|
-
const { body: r, query: i, contentType: o, retries: h, responseType:
|
|
3338
|
-
...
|
|
3339
|
-
...this.useBearer ? {} : { accessToken:
|
|
3759
|
+
c = new WeakSet(), zt = function(t) {
|
|
3760
|
+
return `${this.apiUrl}/${t}`;
|
|
3761
|
+
}, d = async function(t, e, s) {
|
|
3762
|
+
const { body: r, query: i, contentType: o, retries: h, responseType: u, retryAttempt: f } = s || {}, y = a(this, c, zt).call(this, e), w = a(this, c, He).call(this, i), R = await this.resolveAccessToken(), Ke = {
|
|
3763
|
+
...w,
|
|
3764
|
+
...this.useBearer ? {} : { accessToken: R }
|
|
3340
3765
|
};
|
|
3341
3766
|
try {
|
|
3342
|
-
const
|
|
3343
|
-
y + "?" + new URLSearchParams(
|
|
3767
|
+
const x = await fetch(
|
|
3768
|
+
y + "?" + new URLSearchParams(Ke).toString(),
|
|
3344
3769
|
{
|
|
3345
|
-
method:
|
|
3770
|
+
method: t,
|
|
3346
3771
|
headers: {
|
|
3347
3772
|
Accept: "application/json",
|
|
3348
3773
|
...o && { "Content-Type": o },
|
|
3349
|
-
...this.useBearer && { Authorization: `Bearer ${
|
|
3774
|
+
...this.useBearer && { Authorization: `Bearer ${R}` }
|
|
3350
3775
|
},
|
|
3351
3776
|
...r && { body: r }
|
|
3352
3777
|
}
|
|
3353
3778
|
);
|
|
3354
|
-
if (!
|
|
3355
|
-
const
|
|
3356
|
-
throw new
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3779
|
+
if (!x.ok) {
|
|
3780
|
+
const K = await x.text().then((mt) => mt).catch(() => "");
|
|
3781
|
+
throw new le(
|
|
3782
|
+
x.status,
|
|
3783
|
+
x.statusText,
|
|
3784
|
+
K,
|
|
3785
|
+
nn(x)
|
|
3361
3786
|
);
|
|
3362
3787
|
}
|
|
3363
|
-
return
|
|
3788
|
+
return u === "blob" ? await x.blob() : x.json().then((K) => K).catch(() => {
|
|
3364
3789
|
});
|
|
3365
|
-
} catch (
|
|
3366
|
-
const
|
|
3367
|
-
if (
|
|
3368
|
-
const
|
|
3369
|
-
return await
|
|
3790
|
+
} catch (x) {
|
|
3791
|
+
const K = h ?? this.retries;
|
|
3792
|
+
if (K > 0 && rn(x)) {
|
|
3793
|
+
const mt = f ?? 0;
|
|
3794
|
+
return await sn(on(x, mt)), await a(this, c, d).call(this, t, e, {
|
|
3370
3795
|
...s,
|
|
3371
|
-
retries:
|
|
3372
|
-
retryAttempt:
|
|
3796
|
+
retries: K - 1,
|
|
3797
|
+
retryAttempt: mt + 1
|
|
3373
3798
|
});
|
|
3374
3799
|
}
|
|
3375
|
-
throw
|
|
3800
|
+
throw x;
|
|
3376
3801
|
}
|
|
3377
|
-
},
|
|
3378
|
-
const { query: s } =
|
|
3802
|
+
}, D = async function(t, e) {
|
|
3803
|
+
const { query: s } = e || {}, r = a(this, c, zt).call(this, t), i = await this.resolveAccessToken(), o = {
|
|
3379
3804
|
...s,
|
|
3380
3805
|
...this.useBearer ? {} : { accessToken: i }
|
|
3381
3806
|
};
|
|
@@ -3388,58 +3813,58 @@ c = new WeakSet(), Ne = function(e) {
|
|
|
3388
3813
|
}
|
|
3389
3814
|
}
|
|
3390
3815
|
);
|
|
3391
|
-
},
|
|
3392
|
-
if (!
|
|
3816
|
+
}, ft = new WeakMap(), lt = async function(t, e) {
|
|
3817
|
+
if (!t.length) return [];
|
|
3393
3818
|
const s = [];
|
|
3394
|
-
for (let i = 0; i <
|
|
3395
|
-
s.push(
|
|
3396
|
-
return (await Promise.all(s.map(
|
|
3397
|
-
},
|
|
3398
|
-
const { versionTag: s, withDraft: r } =
|
|
3399
|
-
return await a(this, c,
|
|
3819
|
+
for (let i = 0; i < t.length; i += ke)
|
|
3820
|
+
s.push(t.slice(i, i + ke));
|
|
3821
|
+
return (await Promise.all(s.map(e))).flat();
|
|
3822
|
+
}, At = async function(t, e) {
|
|
3823
|
+
const { versionTag: s, withDraft: r } = e || {};
|
|
3824
|
+
return await a(this, c, D).call(this, `${m}/${t}/download`, {
|
|
3400
3825
|
query: {
|
|
3401
3826
|
...s && { versionTag: s },
|
|
3402
3827
|
...r && { withDraft: r }
|
|
3403
3828
|
}
|
|
3404
3829
|
});
|
|
3405
|
-
},
|
|
3406
|
-
const { name: r, versionTag: i, parentFolderId: o, projectId: h, file:
|
|
3407
|
-
return y.append("file",
|
|
3830
|
+
}, xt = async function(t, e, s) {
|
|
3831
|
+
const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: u, metadata: f } = t, y = new FormData();
|
|
3832
|
+
return y.append("file", u), y.append("name", r), y.append("versionTag", i), y.append("itemType", e), o && y.append("folderId", o), h && y.append("projectId", h), s && y.append("extraProps", JSON.stringify(s)), f && y.append("metadata", JSON.stringify(f)), await a(this, c, d).call(this, "POST", m, {
|
|
3408
3833
|
body: y
|
|
3409
3834
|
});
|
|
3410
|
-
},
|
|
3411
|
-
const { name: r, versionTag: i, parentFolderId: o, file: h, metadata:
|
|
3412
|
-
let
|
|
3835
|
+
}, Qt = async function(t, e, s) {
|
|
3836
|
+
const { name: r, versionTag: i, parentFolderId: o, file: h, metadata: u } = e;
|
|
3837
|
+
let f, y;
|
|
3413
3838
|
if (h) {
|
|
3414
|
-
const
|
|
3415
|
-
|
|
3416
|
-
body:
|
|
3839
|
+
const w = new FormData();
|
|
3840
|
+
w.append("file", h), i && w.append("versionTag", i), s && w.append("extraProps", JSON.stringify(s)), u && w.append("metadata", JSON.stringify(u)), y = await a(this, c, d).call(this, "POST", `${m}/${t}/version`, {
|
|
3841
|
+
body: w
|
|
3417
3842
|
});
|
|
3418
3843
|
}
|
|
3419
3844
|
if (r || o) {
|
|
3420
|
-
const
|
|
3845
|
+
const w = {
|
|
3421
3846
|
...r && { name: r },
|
|
3422
3847
|
...o && { folderId: o }
|
|
3423
|
-
},
|
|
3424
|
-
|
|
3425
|
-
body:
|
|
3848
|
+
}, R = JSON.stringify(w);
|
|
3849
|
+
f = await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
|
|
3850
|
+
body: R,
|
|
3426
3851
|
contentType: "application/json"
|
|
3427
3852
|
});
|
|
3428
3853
|
}
|
|
3429
|
-
return { item:
|
|
3430
|
-
},
|
|
3431
|
-
const { showVersions: s = !1 } =
|
|
3432
|
-
return await a(this, c,
|
|
3854
|
+
return { item: f, version: y };
|
|
3855
|
+
}, Zt = async function(t, e) {
|
|
3856
|
+
const { showVersions: s = !1 } = e || {};
|
|
3857
|
+
return await a(this, c, d).call(this, "GET", `${m}/${t}`, {
|
|
3433
3858
|
query: { showVersions: s }
|
|
3434
3859
|
});
|
|
3435
|
-
},
|
|
3436
|
-
return
|
|
3437
|
-
(
|
|
3860
|
+
}, He = function(t) {
|
|
3861
|
+
return t && Object.entries(t).filter(([, e]) => e !== void 0).reduce(
|
|
3862
|
+
(e, [s, r]) => (e[s] = r, e),
|
|
3438
3863
|
{}
|
|
3439
3864
|
);
|
|
3440
3865
|
};
|
|
3441
|
-
let
|
|
3442
|
-
function
|
|
3866
|
+
let Xt = ue;
|
|
3867
|
+
function an() {
|
|
3443
3868
|
if (typeof window > "u" || window.parent === window)
|
|
3444
3869
|
throw new Error(
|
|
3445
3870
|
"client.channel only works inside a That Open app, which runs in an iframe of the platform."
|
|
@@ -3447,165 +3872,165 @@ function Ss() {
|
|
|
3447
3872
|
return {
|
|
3448
3873
|
post: (n) => window.parent.postMessage(n, "*"),
|
|
3449
3874
|
listen: (n) => {
|
|
3450
|
-
const
|
|
3451
|
-
|
|
3875
|
+
const t = (e) => {
|
|
3876
|
+
e.source === window.parent && n(e.data);
|
|
3452
3877
|
};
|
|
3453
|
-
return window.addEventListener("message",
|
|
3878
|
+
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
3454
3879
|
}
|
|
3455
3880
|
};
|
|
3456
3881
|
}
|
|
3457
|
-
const
|
|
3458
|
-
function
|
|
3882
|
+
const te = "channel:", cn = 1e4;
|
|
3883
|
+
function It(n) {
|
|
3459
3884
|
try {
|
|
3460
3885
|
n();
|
|
3461
|
-
} catch (
|
|
3462
|
-
console.error("[channel] a listener threw:",
|
|
3886
|
+
} catch (t) {
|
|
3887
|
+
console.error("[channel] a listener threw:", t);
|
|
3463
3888
|
}
|
|
3464
3889
|
}
|
|
3465
|
-
var
|
|
3466
|
-
class
|
|
3467
|
-
constructor(
|
|
3468
|
-
_(this,
|
|
3469
|
-
_(this,
|
|
3890
|
+
var q, k, O, Q, Z, tt, S, ee, se, z;
|
|
3891
|
+
class Ge {
|
|
3892
|
+
constructor(t, e) {
|
|
3893
|
+
_(this, S);
|
|
3894
|
+
_(this, q, !1);
|
|
3470
3895
|
_(this, k, []);
|
|
3471
|
-
_(this,
|
|
3472
|
-
_(this,
|
|
3473
|
-
_(this,
|
|
3474
|
-
_(this,
|
|
3475
|
-
this.transport =
|
|
3896
|
+
_(this, O, []);
|
|
3897
|
+
_(this, Q, /* @__PURE__ */ new Set());
|
|
3898
|
+
_(this, Z, /* @__PURE__ */ new Set());
|
|
3899
|
+
_(this, tt, /* @__PURE__ */ new Set());
|
|
3900
|
+
this.transport = t, this.controls = e;
|
|
3476
3901
|
}
|
|
3477
3902
|
/** Whether the platform has confirmed this tab is in the room. */
|
|
3478
3903
|
get joined() {
|
|
3479
|
-
return
|
|
3904
|
+
return l(this, q);
|
|
3480
3905
|
}
|
|
3481
3906
|
/** Who else is in the room right now, as the platform last reported. */
|
|
3482
3907
|
get peers() {
|
|
3483
|
-
return
|
|
3908
|
+
return l(this, k);
|
|
3484
3909
|
}
|
|
3485
3910
|
/**
|
|
3486
3911
|
* Enters the room. Resolves when the platform confirms; rejects if it
|
|
3487
3912
|
* refuses or does not answer in time. Joining twice is harmless.
|
|
3488
3913
|
*/
|
|
3489
3914
|
join() {
|
|
3490
|
-
return
|
|
3915
|
+
return l(this, q) ? Promise.resolve() : a(this, S, ee).call(this, "joined", this.controls.join);
|
|
3491
3916
|
}
|
|
3492
3917
|
/** Leaves the room. Handlers stay registered, so `join()` resumes them. */
|
|
3493
3918
|
leave() {
|
|
3494
|
-
return !
|
|
3919
|
+
return !l(this, q) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S, ee).call(this, "left", this.controls.leave);
|
|
3495
3920
|
}
|
|
3496
3921
|
/** Fires when `joined` or `peers` changes. Returns a function that stops it. */
|
|
3497
|
-
onChange(
|
|
3498
|
-
return
|
|
3922
|
+
onChange(t) {
|
|
3923
|
+
return l(this, Q).add(t), () => void l(this, Q).delete(t);
|
|
3499
3924
|
}
|
|
3500
|
-
onPeerJoined(
|
|
3501
|
-
return
|
|
3925
|
+
onPeerJoined(t) {
|
|
3926
|
+
return l(this, Z).add(t), () => void l(this, Z).delete(t);
|
|
3502
3927
|
}
|
|
3503
|
-
onPeerLeft(
|
|
3504
|
-
return
|
|
3928
|
+
onPeerLeft(t) {
|
|
3929
|
+
return l(this, tt).add(t), () => void l(this, tt).delete(t);
|
|
3505
3930
|
}
|
|
3506
3931
|
/** @internal */
|
|
3507
3932
|
applyJoined() {
|
|
3508
|
-
|
|
3933
|
+
b(this, q, !0), a(this, S, se).call(this, "joined"), a(this, S, z).call(this);
|
|
3509
3934
|
}
|
|
3510
3935
|
/** @internal */
|
|
3511
3936
|
applyLeft() {
|
|
3512
|
-
|
|
3937
|
+
b(this, q, !1), b(this, k, []), a(this, S, se).call(this, "left"), a(this, S, z).call(this);
|
|
3513
3938
|
}
|
|
3514
3939
|
/** @internal */
|
|
3515
|
-
applyPeers(
|
|
3516
|
-
|
|
3940
|
+
applyPeers(t) {
|
|
3941
|
+
b(this, k, t), a(this, S, z).call(this);
|
|
3517
3942
|
}
|
|
3518
3943
|
/** @internal */
|
|
3519
|
-
applyPeerJoined(
|
|
3520
|
-
!
|
|
3944
|
+
applyPeerJoined(t) {
|
|
3945
|
+
!l(this, q) || l(this, k).some((e) => e.from === t.from) || (b(this, k, [...l(this, k), t]), l(this, Z).forEach((e) => It(() => e(t))), a(this, S, z).call(this));
|
|
3521
3946
|
}
|
|
3522
3947
|
/** @internal */
|
|
3523
|
-
applyPeerLeft(
|
|
3524
|
-
const
|
|
3525
|
-
|
|
3948
|
+
applyPeerLeft(t) {
|
|
3949
|
+
const e = l(this, k).find((s) => s.from === t);
|
|
3950
|
+
e && (b(this, k, l(this, k).filter((s) => s.from !== t)), l(this, tt).forEach((s) => It(() => s(e))), a(this, S, z).call(this));
|
|
3526
3951
|
}
|
|
3527
3952
|
/** @internal */
|
|
3528
|
-
failPending(
|
|
3529
|
-
const
|
|
3530
|
-
return
|
|
3531
|
-
clearTimeout(s.timer), s.reject(
|
|
3532
|
-
}),
|
|
3953
|
+
failPending(t) {
|
|
3954
|
+
const e = l(this, O);
|
|
3955
|
+
return b(this, O, []), e.forEach((s) => {
|
|
3956
|
+
clearTimeout(s.timer), s.reject(t);
|
|
3957
|
+
}), e.length > 0;
|
|
3533
3958
|
}
|
|
3534
|
-
post(
|
|
3535
|
-
this.transport.post(
|
|
3959
|
+
post(t) {
|
|
3960
|
+
this.transport.post(t);
|
|
3536
3961
|
}
|
|
3537
3962
|
}
|
|
3538
|
-
|
|
3963
|
+
q = new WeakMap(), k = new WeakMap(), O = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), S = new WeakSet(), ee = function(t, e) {
|
|
3539
3964
|
return new Promise((s, r) => {
|
|
3540
3965
|
const i = {
|
|
3541
|
-
want:
|
|
3966
|
+
want: t,
|
|
3542
3967
|
resolve: s,
|
|
3543
3968
|
reject: r,
|
|
3544
3969
|
timer: setTimeout(() => {
|
|
3545
|
-
|
|
3970
|
+
b(this, O, l(this, O).filter((o) => o !== i)), r(
|
|
3546
3971
|
new Error(
|
|
3547
|
-
`The platform did not confirm ${
|
|
3972
|
+
`The platform did not confirm ${t === "joined" ? "joining" : "leaving"} in time.`
|
|
3548
3973
|
)
|
|
3549
3974
|
);
|
|
3550
|
-
},
|
|
3975
|
+
}, cn)
|
|
3551
3976
|
};
|
|
3552
|
-
|
|
3977
|
+
l(this, O).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
|
|
3553
3978
|
});
|
|
3554
|
-
},
|
|
3555
|
-
const
|
|
3556
|
-
|
|
3979
|
+
}, se = function(t) {
|
|
3980
|
+
const e = l(this, O).filter((s) => s.want === t);
|
|
3981
|
+
b(this, O, l(this, O).filter((s) => s.want !== t)), e.forEach((s) => {
|
|
3557
3982
|
clearTimeout(s.timer), s.resolve();
|
|
3558
3983
|
});
|
|
3559
|
-
},
|
|
3560
|
-
|
|
3984
|
+
}, z = function() {
|
|
3985
|
+
l(this, Q).forEach((t) => It(t));
|
|
3561
3986
|
};
|
|
3562
|
-
var
|
|
3563
|
-
class
|
|
3987
|
+
var et;
|
|
3988
|
+
class hn extends Ge {
|
|
3564
3989
|
/** @internal Use `client.channel.collab()`. */
|
|
3565
|
-
constructor(
|
|
3566
|
-
super(
|
|
3990
|
+
constructor(e) {
|
|
3991
|
+
super(e, {
|
|
3567
3992
|
join: { action: "joinCollab" },
|
|
3568
3993
|
leave: { action: "leaveCollab" }
|
|
3569
3994
|
});
|
|
3570
|
-
_(this,
|
|
3995
|
+
_(this, et, /* @__PURE__ */ new Map());
|
|
3571
3996
|
}
|
|
3572
3997
|
/**
|
|
3573
3998
|
* Listens for an event other tabs send. Any number of listeners per event.
|
|
3574
3999
|
* @returns a function that removes the listener.
|
|
3575
4000
|
*/
|
|
3576
|
-
on(
|
|
3577
|
-
const r =
|
|
3578
|
-
return r.add(s),
|
|
4001
|
+
on(e, s) {
|
|
4002
|
+
const r = l(this, et).get(e) ?? /* @__PURE__ */ new Set();
|
|
4003
|
+
return r.add(s), l(this, et).set(e, r), () => void r.delete(s);
|
|
3579
4004
|
}
|
|
3580
4005
|
/**
|
|
3581
4006
|
* Sends an event to the other tabs in the room. Does nothing while this tab
|
|
3582
4007
|
* is not in it, matching what the platform does with a message from outside.
|
|
3583
4008
|
*/
|
|
3584
|
-
send(
|
|
3585
|
-
if (
|
|
3586
|
-
throw new Error(`Message types starting with '${
|
|
3587
|
-
this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type:
|
|
4009
|
+
send(e, s) {
|
|
4010
|
+
if (e.startsWith(te))
|
|
4011
|
+
throw new Error(`Message types starting with '${te}' are reserved.`);
|
|
4012
|
+
this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: e, payload: s } });
|
|
3588
4013
|
}
|
|
3589
|
-
accepts(
|
|
3590
|
-
return
|
|
4014
|
+
accepts(e) {
|
|
4015
|
+
return e === void 0 || e === "collab";
|
|
3591
4016
|
}
|
|
3592
|
-
async handle(
|
|
3593
|
-
const s =
|
|
4017
|
+
async handle(e) {
|
|
4018
|
+
const s = l(this, et).get(e.type);
|
|
3594
4019
|
if (!(s != null && s.size)) return { handled: !1 };
|
|
3595
|
-
const r =
|
|
3596
|
-
return s.forEach((i) =>
|
|
4020
|
+
const r = Ve(e);
|
|
4021
|
+
return s.forEach((i) => It(() => i(e.payload, r))), { handled: !0 };
|
|
3597
4022
|
}
|
|
3598
4023
|
}
|
|
3599
|
-
|
|
3600
|
-
var
|
|
3601
|
-
class
|
|
4024
|
+
et = new WeakMap();
|
|
4025
|
+
var M;
|
|
4026
|
+
class ln extends Ge {
|
|
3602
4027
|
/** @internal Use `client.channel.external(kind)`. */
|
|
3603
|
-
constructor(
|
|
3604
|
-
super(
|
|
4028
|
+
constructor(e, s) {
|
|
4029
|
+
super(e, {
|
|
3605
4030
|
join: { action: "joinExternal", kind: s },
|
|
3606
4031
|
leave: { action: "leaveExternal", kind: s }
|
|
3607
4032
|
});
|
|
3608
|
-
_(this,
|
|
4033
|
+
_(this, M, /* @__PURE__ */ new Map());
|
|
3609
4034
|
this.kind = s;
|
|
3610
4035
|
}
|
|
3611
4036
|
/**
|
|
@@ -3618,25 +4043,25 @@ class Cs extends mt {
|
|
|
3618
4043
|
* would both try to answer.
|
|
3619
4044
|
* @returns a function that removes the handler.
|
|
3620
4045
|
*/
|
|
3621
|
-
on(
|
|
3622
|
-
if (
|
|
4046
|
+
on(e, s) {
|
|
4047
|
+
if (l(this, M).has(e))
|
|
3623
4048
|
throw new Error(
|
|
3624
|
-
`"${
|
|
4049
|
+
`"${e}" already has a handler in this room. Remove it first.`
|
|
3625
4050
|
);
|
|
3626
|
-
return
|
|
4051
|
+
return l(this, M).set(e, s), () => void l(this, M).delete(e);
|
|
3627
4052
|
}
|
|
3628
|
-
accepts(
|
|
3629
|
-
return
|
|
4053
|
+
accepts(e, s) {
|
|
4054
|
+
return e !== void 0 && e !== "external" ? !1 : this.kind === void 0 || e === void 0 || this.kind === s;
|
|
3630
4055
|
}
|
|
3631
4056
|
/** @internal Whether this room has any handler at all. */
|
|
3632
4057
|
get hasHandlers() {
|
|
3633
|
-
return
|
|
4058
|
+
return l(this, M).size > 0;
|
|
3634
4059
|
}
|
|
3635
|
-
async handle(
|
|
3636
|
-
const s =
|
|
4060
|
+
async handle(e) {
|
|
4061
|
+
const s = l(this, M).get(e.type);
|
|
3637
4062
|
if (!s) return { handled: !1 };
|
|
3638
4063
|
try {
|
|
3639
|
-
return { handled: !0, value: await s(
|
|
4064
|
+
return { handled: !0, value: await s(e.payload, Ve(e)) };
|
|
3640
4065
|
} catch (r) {
|
|
3641
4066
|
return {
|
|
3642
4067
|
handled: !0,
|
|
@@ -3645,8 +4070,8 @@ class Cs extends mt {
|
|
|
3645
4070
|
}
|
|
3646
4071
|
}
|
|
3647
4072
|
}
|
|
3648
|
-
|
|
3649
|
-
function
|
|
4073
|
+
M = new WeakMap();
|
|
4074
|
+
function Ve(n) {
|
|
3650
4075
|
return {
|
|
3651
4076
|
from: n.from,
|
|
3652
4077
|
at: n.at,
|
|
@@ -3654,118 +4079,118 @@ function gt(n) {
|
|
|
3654
4079
|
kind: n.kind
|
|
3655
4080
|
};
|
|
3656
4081
|
}
|
|
3657
|
-
function
|
|
3658
|
-
const
|
|
3659
|
-
if ((
|
|
3660
|
-
const
|
|
3661
|
-
return !
|
|
3662
|
-
type:
|
|
3663
|
-
requestId: typeof
|
|
3664
|
-
payload:
|
|
3665
|
-
at: typeof
|
|
3666
|
-
from: typeof
|
|
3667
|
-
scope:
|
|
3668
|
-
kind: typeof
|
|
4082
|
+
function un(n) {
|
|
4083
|
+
const t = n;
|
|
4084
|
+
if ((t == null ? void 0 : t.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
|
|
4085
|
+
const e = t.message;
|
|
4086
|
+
return !e || typeof e.type != "string" ? null : {
|
|
4087
|
+
type: e.type,
|
|
4088
|
+
requestId: typeof e.requestId == "string" ? e.requestId : void 0,
|
|
4089
|
+
payload: e.payload,
|
|
4090
|
+
at: typeof e.at == "number" ? e.at : Date.now(),
|
|
4091
|
+
from: typeof e.from == "string" ? e.from : "",
|
|
4092
|
+
scope: e.scope === "collab" || e.scope === "external" ? e.scope : void 0,
|
|
4093
|
+
kind: typeof e.kind == "string" ? e.kind : void 0
|
|
3669
4094
|
};
|
|
3670
4095
|
}
|
|
3671
|
-
var
|
|
3672
|
-
class
|
|
3673
|
-
constructor(
|
|
3674
|
-
_(this,
|
|
3675
|
-
_(this,
|
|
3676
|
-
_(this,
|
|
3677
|
-
_(this,
|
|
3678
|
-
_(this,
|
|
3679
|
-
_(this,
|
|
3680
|
-
|
|
4096
|
+
var W, pt, F, H, G, v, ne, $t, Je, Ye, We, re;
|
|
4097
|
+
class dn {
|
|
4098
|
+
constructor(t) {
|
|
4099
|
+
_(this, v);
|
|
4100
|
+
_(this, W);
|
|
4101
|
+
_(this, pt);
|
|
4102
|
+
_(this, F);
|
|
4103
|
+
_(this, H, /* @__PURE__ */ new Map());
|
|
4104
|
+
_(this, G, /* @__PURE__ */ new Set());
|
|
4105
|
+
b(this, W, t), b(this, pt, t.listen((e) => void a(this, v, Je).call(this, e)));
|
|
3681
4106
|
}
|
|
3682
4107
|
/** The collaboration room for this app. Always the same instance. */
|
|
3683
4108
|
collab() {
|
|
3684
|
-
return
|
|
4109
|
+
return l(this, F) ?? b(this, F, new hn(l(this, W))), l(this, F);
|
|
3685
4110
|
}
|
|
3686
4111
|
/**
|
|
3687
4112
|
* The room for commands from this account's external tools of one `kind`
|
|
3688
4113
|
* (`'mcp'`, `'cli'`, `'revit'`…), or from any of them when `kind` is omitted.
|
|
3689
4114
|
* Always the same instance for the same kind.
|
|
3690
4115
|
*/
|
|
3691
|
-
external(
|
|
3692
|
-
const
|
|
3693
|
-
let s =
|
|
3694
|
-
return s || (s = new
|
|
4116
|
+
external(t) {
|
|
4117
|
+
const e = t ?? "";
|
|
4118
|
+
let s = l(this, H).get(e);
|
|
4119
|
+
return s || (s = new ln(l(this, W), t), l(this, H).set(e, s)), s;
|
|
3695
4120
|
}
|
|
3696
4121
|
/** Stops listening. For tests and teardown; an app normally never calls it. */
|
|
3697
4122
|
dispose() {
|
|
3698
|
-
|
|
4123
|
+
l(this, pt).call(this);
|
|
3699
4124
|
}
|
|
3700
4125
|
}
|
|
3701
|
-
|
|
3702
|
-
return [...
|
|
3703
|
-
},
|
|
3704
|
-
if (
|
|
3705
|
-
if (
|
|
3706
|
-
return
|
|
3707
|
-
},
|
|
3708
|
-
const
|
|
3709
|
-
if (
|
|
3710
|
-
if (
|
|
3711
|
-
a(this,
|
|
4126
|
+
W = new WeakMap(), pt = new WeakMap(), F = new WeakMap(), H = new WeakMap(), G = new WeakMap(), v = new WeakSet(), ne = function() {
|
|
4127
|
+
return [...l(this, F) ? [l(this, F)] : [], ...l(this, H).values()];
|
|
4128
|
+
}, $t = function(t, e) {
|
|
4129
|
+
if (t === "collab") return l(this, F);
|
|
4130
|
+
if (t === "external")
|
|
4131
|
+
return l(this, H).get(typeof e == "string" ? e : "");
|
|
4132
|
+
}, Je = async function(t) {
|
|
4133
|
+
const e = un(t);
|
|
4134
|
+
if (e) {
|
|
4135
|
+
if (e.type.startsWith(te)) {
|
|
4136
|
+
a(this, v, Ye).call(this, e);
|
|
3712
4137
|
return;
|
|
3713
4138
|
}
|
|
3714
|
-
await a(this,
|
|
4139
|
+
await a(this, v, We).call(this, e);
|
|
3715
4140
|
}
|
|
3716
|
-
},
|
|
4141
|
+
}, Ye = function(t) {
|
|
3717
4142
|
var s, r, i;
|
|
3718
|
-
const
|
|
3719
|
-
switch (
|
|
4143
|
+
const e = t.payload ?? {};
|
|
4144
|
+
switch (t.type) {
|
|
3720
4145
|
case "channel:joined":
|
|
3721
|
-
(s = a(this,
|
|
4146
|
+
(s = a(this, v, $t).call(this, e.scope, e.kind)) == null || s.applyJoined();
|
|
3722
4147
|
break;
|
|
3723
4148
|
case "channel:left":
|
|
3724
|
-
(r = a(this,
|
|
4149
|
+
(r = a(this, v, $t).call(this, e.scope, e.kind)) == null || r.applyLeft();
|
|
3725
4150
|
break;
|
|
3726
4151
|
case "channel:peers":
|
|
3727
|
-
(i = a(this,
|
|
4152
|
+
(i = a(this, v, $t).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
|
|
3728
4153
|
break;
|
|
3729
4154
|
case "channel:peer-joined":
|
|
3730
4155
|
case "channel:peer-left": {
|
|
3731
|
-
if (!
|
|
3732
|
-
const o =
|
|
3733
|
-
(h) => h.accepts("external",
|
|
4156
|
+
if (!e.from) break;
|
|
4157
|
+
const o = e.scope === "collab" ? [l(this, F)] : [...l(this, H).values()].filter(
|
|
4158
|
+
(h) => h.accepts("external", e.kind)
|
|
3734
4159
|
);
|
|
3735
4160
|
for (const h of o)
|
|
3736
|
-
|
|
4161
|
+
t.type === "channel:peer-joined" ? h == null || h.applyPeerJoined({ from: e.from, kind: e.kind }) : h == null || h.applyPeerLeft(e.from);
|
|
3737
4162
|
break;
|
|
3738
4163
|
}
|
|
3739
4164
|
case "channel:error": {
|
|
3740
|
-
const o = new Error(String(
|
|
3741
|
-
a(this,
|
|
4165
|
+
const o = new Error(String(t.payload));
|
|
4166
|
+
a(this, v, ne).call(this).map((u) => u.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
|
|
3742
4167
|
break;
|
|
3743
4168
|
}
|
|
3744
4169
|
}
|
|
3745
|
-
},
|
|
3746
|
-
const
|
|
4170
|
+
}, We = async function(t) {
|
|
4171
|
+
const e = a(this, v, ne).call(this).filter((i) => i.accepts(t.scope, t.kind));
|
|
3747
4172
|
let s = !1;
|
|
3748
|
-
for (const i of
|
|
3749
|
-
const o = await i.handle(
|
|
3750
|
-
o.handled && (s = !0,
|
|
4173
|
+
for (const i of e) {
|
|
4174
|
+
const o = await i.handle(t);
|
|
4175
|
+
o.handled && (s = !0, t.requestId && a(this, v, re).call(this, t.requestId, o));
|
|
3751
4176
|
}
|
|
3752
|
-
|
|
4177
|
+
t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v, re).call(this, t.requestId, {
|
|
3753
4178
|
handled: !0,
|
|
3754
|
-
error: `No handler for "${
|
|
4179
|
+
error: `No handler for "${t.type}".`
|
|
3755
4180
|
});
|
|
3756
|
-
},
|
|
3757
|
-
|
|
4181
|
+
}, re = function(t, e) {
|
|
4182
|
+
l(this, G).has(t) || (l(this, G).add(t), l(this, G).size > 500 && l(this, G).delete(l(this, G).values().next().value), l(this, W).post({
|
|
3758
4183
|
type: "APP_CHANNEL_PUBLISH",
|
|
3759
4184
|
message: {
|
|
3760
|
-
type:
|
|
3761
|
-
requestId:
|
|
3762
|
-
payload:
|
|
4185
|
+
type: e.error === void 0 ? "reply" : "reply-error",
|
|
4186
|
+
requestId: t,
|
|
4187
|
+
payload: e.error === void 0 ? e.value : { error: e.error }
|
|
3763
4188
|
}
|
|
3764
4189
|
}));
|
|
3765
4190
|
};
|
|
3766
|
-
const
|
|
3767
|
-
var
|
|
3768
|
-
const
|
|
4191
|
+
const J = "project", X = "notifications";
|
|
4192
|
+
var st, yt;
|
|
4193
|
+
const de = class de extends Xt {
|
|
3769
4194
|
/**
|
|
3770
4195
|
* @param token - A bearer JWT, OR a function returning the current JWT
|
|
3771
4196
|
* (sync or async). When a function is passed, it's invoked before every
|
|
@@ -3774,14 +4199,14 @@ const Ge = class Ge extends $e {
|
|
|
3774
4199
|
* @param props - Optional client configuration. `useBearer` is forced to
|
|
3775
4200
|
* `true` and cannot be overridden.
|
|
3776
4201
|
*/
|
|
3777
|
-
constructor(
|
|
3778
|
-
super(typeof
|
|
3779
|
-
_(this,
|
|
3780
|
-
_(this,
|
|
3781
|
-
typeof
|
|
4202
|
+
constructor(e, s, r) {
|
|
4203
|
+
super(typeof e == "string" ? e : "", s, { ...r, useBearer: !0 });
|
|
4204
|
+
_(this, st);
|
|
4205
|
+
_(this, yt);
|
|
4206
|
+
typeof e == "function" && b(this, st, e);
|
|
3782
4207
|
}
|
|
3783
4208
|
async resolveAccessToken() {
|
|
3784
|
-
return
|
|
4209
|
+
return l(this, st) ? await l(this, st).call(this) : super.resolveAccessToken();
|
|
3785
4210
|
}
|
|
3786
4211
|
/**
|
|
3787
4212
|
* Creates a client from the platform context injected into
|
|
@@ -3789,8 +4214,8 @@ const Ge = class Ge extends $e {
|
|
|
3789
4214
|
* entry point for apps running inside the platform's iframe — the context
|
|
3790
4215
|
* carries a fresh JWT on every navigation.
|
|
3791
4216
|
*/
|
|
3792
|
-
static fromPlatformContext(
|
|
3793
|
-
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new
|
|
4217
|
+
static fromPlatformContext(e) {
|
|
4218
|
+
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new de(s.accessToken, s.apiUrl, e);
|
|
3794
4219
|
return r.context = s, r;
|
|
3795
4220
|
}
|
|
3796
4221
|
/**
|
|
@@ -3818,7 +4243,7 @@ const Ge = class Ge extends $e {
|
|
|
3818
4243
|
* ```
|
|
3819
4244
|
*/
|
|
3820
4245
|
get channel() {
|
|
3821
|
-
return
|
|
4246
|
+
return l(this, yt) ?? b(this, yt, new dn(an())), l(this, yt);
|
|
3822
4247
|
}
|
|
3823
4248
|
// ─── Projects (JWT-only backend routes) ──────────────────────────
|
|
3824
4249
|
/**
|
|
@@ -3837,23 +4262,23 @@ const Ge = class Ge extends $e {
|
|
|
3837
4262
|
* ```
|
|
3838
4263
|
*/
|
|
3839
4264
|
async listProjects() {
|
|
3840
|
-
return await this.request("GET",
|
|
4265
|
+
return await this.request("GET", J);
|
|
3841
4266
|
}
|
|
3842
4267
|
/**
|
|
3843
4268
|
* Gets a project by ID. JWT-only — lives here because
|
|
3844
4269
|
* `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
|
|
3845
4270
|
*/
|
|
3846
|
-
async getProject(
|
|
3847
|
-
return await this.request("GET", `${
|
|
4271
|
+
async getProject(e) {
|
|
4272
|
+
return await this.request("GET", `${J}/${e}`);
|
|
3848
4273
|
}
|
|
3849
4274
|
/**
|
|
3850
4275
|
* Gets the full project data (users, roles, files, folders) for a project.
|
|
3851
4276
|
* User data is stripped of sensitive fields server-side.
|
|
3852
4277
|
*/
|
|
3853
|
-
async getProjectData(
|
|
4278
|
+
async getProjectData(e) {
|
|
3854
4279
|
return await this.request(
|
|
3855
4280
|
"GET",
|
|
3856
|
-
`${
|
|
4281
|
+
`${J}/${e}/data`
|
|
3857
4282
|
);
|
|
3858
4283
|
}
|
|
3859
4284
|
// ─── Account ──────────────────────────────────────────────────────
|
|
@@ -3863,8 +4288,8 @@ const Ge = class Ge extends $e {
|
|
|
3863
4288
|
* an `<img src>` — turn the blob into an object URL with
|
|
3864
4289
|
* `URL.createObjectURL(blob)`. Rejects when the account has no avatar.
|
|
3865
4290
|
*/
|
|
3866
|
-
async getAvatar(
|
|
3867
|
-
return await this.request("GET", `account/${
|
|
4291
|
+
async getAvatar(e) {
|
|
4292
|
+
return await this.request("GET", `account/${e}/avatar`, {
|
|
3868
4293
|
responseType: "blob"
|
|
3869
4294
|
});
|
|
3870
4295
|
}
|
|
@@ -3875,20 +4300,20 @@ const Ge = class Ge extends $e {
|
|
|
3875
4300
|
* admin/owner, `'project'` for a role broad grant, `'entity'` for a
|
|
3876
4301
|
* per-entity override, `'none'` for denied.
|
|
3877
4302
|
*/
|
|
3878
|
-
async checkPermission(
|
|
4303
|
+
async checkPermission(e) {
|
|
3879
4304
|
return await this.request(
|
|
3880
4305
|
"GET",
|
|
3881
|
-
`${
|
|
3882
|
-
{ query:
|
|
4306
|
+
`${J}/permissions/check`,
|
|
4307
|
+
{ query: e }
|
|
3883
4308
|
);
|
|
3884
4309
|
}
|
|
3885
4310
|
/**
|
|
3886
4311
|
* Batch variant of {@link checkPermission}. Evaluates multiple checks in a
|
|
3887
4312
|
* single round-trip; results come back in the same order as `checks`.
|
|
3888
4313
|
*/
|
|
3889
|
-
async checkPermissionBatch(
|
|
3890
|
-
return (await this.request("POST", `${
|
|
3891
|
-
body: JSON.stringify({ checks:
|
|
4314
|
+
async checkPermissionBatch(e) {
|
|
4315
|
+
return (await this.request("POST", `${J}/permissions/check/batch`, {
|
|
4316
|
+
body: JSON.stringify({ checks: e }),
|
|
3892
4317
|
contentType: "application/json"
|
|
3893
4318
|
})).results;
|
|
3894
4319
|
}
|
|
@@ -3914,11 +4339,11 @@ const Ge = class Ge extends $e {
|
|
|
3914
4339
|
* } while (cursor);
|
|
3915
4340
|
* ```
|
|
3916
4341
|
*/
|
|
3917
|
-
async getNotifications(
|
|
3918
|
-
return await this.request("GET",
|
|
4342
|
+
async getNotifications(e) {
|
|
4343
|
+
return await this.request("GET", X, {
|
|
3919
4344
|
query: {
|
|
3920
|
-
...(
|
|
3921
|
-
...(
|
|
4345
|
+
...(e == null ? void 0 : e.cursor) !== void 0 && { cursor: e.cursor },
|
|
4346
|
+
...(e == null ? void 0 : e.limit) !== void 0 && { limit: String(e.limit) }
|
|
3922
4347
|
}
|
|
3923
4348
|
});
|
|
3924
4349
|
}
|
|
@@ -3929,7 +4354,7 @@ const Ge = class Ge extends $e {
|
|
|
3929
4354
|
async getUnreadNotificationCount() {
|
|
3930
4355
|
return (await this.request(
|
|
3931
4356
|
"GET",
|
|
3932
|
-
`${
|
|
4357
|
+
`${X}/unread-count`
|
|
3933
4358
|
)).count;
|
|
3934
4359
|
}
|
|
3935
4360
|
/**
|
|
@@ -3937,12 +4362,12 @@ const Ge = class Ge extends $e {
|
|
|
3937
4362
|
* ignored rather than rejected, so `updated` can be lower than the number
|
|
3938
4363
|
* passed in.
|
|
3939
4364
|
*/
|
|
3940
|
-
async markNotificationsRead(
|
|
4365
|
+
async markNotificationsRead(e) {
|
|
3941
4366
|
return await this.request(
|
|
3942
4367
|
"POST",
|
|
3943
|
-
`${
|
|
4368
|
+
`${X}/mark-read`,
|
|
3944
4369
|
{
|
|
3945
|
-
body: JSON.stringify({ ids:
|
|
4370
|
+
body: JSON.stringify({ ids: e }),
|
|
3946
4371
|
contentType: "application/json"
|
|
3947
4372
|
}
|
|
3948
4373
|
);
|
|
@@ -3951,7 +4376,7 @@ const Ge = class Ge extends $e {
|
|
|
3951
4376
|
async markAllNotificationsRead() {
|
|
3952
4377
|
return await this.request(
|
|
3953
4378
|
"POST",
|
|
3954
|
-
`${
|
|
4379
|
+
`${X}/mark-all-read`
|
|
3955
4380
|
);
|
|
3956
4381
|
}
|
|
3957
4382
|
/**
|
|
@@ -3961,7 +4386,7 @@ const Ge = class Ge extends $e {
|
|
|
3961
4386
|
async getNotificationSubscriptions() {
|
|
3962
4387
|
return await this.request(
|
|
3963
4388
|
"GET",
|
|
3964
|
-
`${
|
|
4389
|
+
`${X}/subscriptions`
|
|
3965
4390
|
);
|
|
3966
4391
|
}
|
|
3967
4392
|
/**
|
|
@@ -3972,10 +4397,10 @@ const Ge = class Ge extends $e {
|
|
|
3972
4397
|
* automation itself is gone — opting out must never be the thing that
|
|
3973
4398
|
* fails.
|
|
3974
4399
|
*/
|
|
3975
|
-
async unsubscribeFromAutomation(
|
|
4400
|
+
async unsubscribeFromAutomation(e) {
|
|
3976
4401
|
return await this.request(
|
|
3977
4402
|
"DELETE",
|
|
3978
|
-
`${
|
|
4403
|
+
`${X}/subscriptions/${e}`
|
|
3979
4404
|
);
|
|
3980
4405
|
}
|
|
3981
4406
|
/**
|
|
@@ -3996,10 +4421,10 @@ const Ge = class Ge extends $e {
|
|
|
3996
4421
|
* });
|
|
3997
4422
|
* ```
|
|
3998
4423
|
*/
|
|
3999
|
-
async subscribeToAutomation(
|
|
4424
|
+
async subscribeToAutomation(e, s, r) {
|
|
4000
4425
|
return await this.request(
|
|
4001
4426
|
"POST",
|
|
4002
|
-
`${
|
|
4427
|
+
`${J}/${e}/events/hooks/${s}/subscription`,
|
|
4003
4428
|
{
|
|
4004
4429
|
body: JSON.stringify(r ?? {}),
|
|
4005
4430
|
contentType: "application/json"
|
|
@@ -4013,10 +4438,10 @@ const Ge = class Ge extends $e {
|
|
|
4013
4438
|
* Throws if the user is not subscribed; use {@link subscribeToAutomation}
|
|
4014
4439
|
* to create one.
|
|
4015
4440
|
*/
|
|
4016
|
-
async updateAutomationSubscription(
|
|
4441
|
+
async updateAutomationSubscription(e, s, r) {
|
|
4017
4442
|
return await this.request(
|
|
4018
4443
|
"PATCH",
|
|
4019
|
-
`${
|
|
4444
|
+
`${J}/${e}/events/hooks/${s}/subscription`,
|
|
4020
4445
|
{
|
|
4021
4446
|
body: JSON.stringify(r),
|
|
4022
4447
|
contentType: "application/json"
|
|
@@ -4049,49 +4474,54 @@ const Ge = class Ge extends $e {
|
|
|
4049
4474
|
* stop();
|
|
4050
4475
|
* ```
|
|
4051
4476
|
*/
|
|
4052
|
-
async onNotification(
|
|
4053
|
-
const s = await this.resolveAccessToken(), r =
|
|
4477
|
+
async onNotification(e) {
|
|
4478
|
+
const s = await this.resolveAccessToken(), r = ut(`${this.socketOrigin}/notifications`, {
|
|
4054
4479
|
auth: { accessToken: s },
|
|
4055
4480
|
transports: ["websocket"]
|
|
4056
4481
|
});
|
|
4057
4482
|
return r.on(
|
|
4058
4483
|
"notification.created",
|
|
4059
|
-
(i) =>
|
|
4484
|
+
(i) => e({ type: "created", id: i == null ? void 0 : i.id })
|
|
4060
4485
|
), r.on(
|
|
4061
4486
|
"notification.read",
|
|
4062
|
-
(i) =>
|
|
4487
|
+
(i) => e({ type: "read", id: i == null ? void 0 : i.id })
|
|
4063
4488
|
), r.on(
|
|
4064
4489
|
"notifications.allRead",
|
|
4065
|
-
(i) =>
|
|
4490
|
+
(i) => e({ type: "allRead", batch: i == null ? void 0 : i.batch })
|
|
4066
4491
|
), () => r.disconnect();
|
|
4067
4492
|
}
|
|
4068
4493
|
};
|
|
4069
|
-
|
|
4070
|
-
let
|
|
4071
|
-
const
|
|
4494
|
+
st = new WeakMap(), yt = new WeakMap();
|
|
4495
|
+
let Ae = de;
|
|
4496
|
+
const yn = {
|
|
4072
4497
|
MAX_FIELDS: 200,
|
|
4073
4498
|
MAX_KEY_LENGTH: 50,
|
|
4074
4499
|
MAX_VALUE_LENGTH: 50
|
|
4075
|
-
},
|
|
4500
|
+
}, mn = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, gn = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, wn = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, _n = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, bn = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, En = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, vn = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, Tn = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, Sn = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
|
|
4076
4501
|
export {
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4502
|
+
mn as CDEManager,
|
|
4503
|
+
dn as ChannelClient,
|
|
4504
|
+
Ge as ChannelRoom,
|
|
4505
|
+
gn as ClashesManager,
|
|
4506
|
+
hn as CollabRoom,
|
|
4507
|
+
Xt as EngineServicesClient,
|
|
4508
|
+
ln as ExternalRoom,
|
|
4509
|
+
wn as FileList,
|
|
4510
|
+
Ws as FlowDoc,
|
|
4511
|
+
_n as GISManager,
|
|
4512
|
+
bn as GitHistoryManager,
|
|
4513
|
+
En as HelloWorld,
|
|
4514
|
+
yn as METADATA_LIMITS,
|
|
4515
|
+
Ae as PlatformClient,
|
|
4516
|
+
Ys as ProjectHistory,
|
|
4517
|
+
vn as ProjectManager,
|
|
4518
|
+
Xs as Recipes,
|
|
4519
|
+
le as RequestError,
|
|
4520
|
+
ke as STORAGE_BATCH_MAX,
|
|
4521
|
+
_e as StaleHistoryError,
|
|
4522
|
+
Tn as TopicsManager,
|
|
4523
|
+
Sn as UIManager,
|
|
4524
|
+
Me as orderByGraph,
|
|
4525
|
+
an as windowTransport
|
|
4096
4526
|
};
|
|
4097
4527
|
//# sourceMappingURL=index.es.js.map
|