@thatopen/services 0.19.0 → 0.21.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 +1406 -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 +212 -0
- package/dist/core/recipes.d.ts +150 -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 +1656 -1205
- package/dist/index.es.js.map +1 -1
- package/docs/ai-quickstart.md +35 -3
- package/docs/client/paths.json +4 -0
- package/docs/flow-plugin-guide.md +7 -0
- package/docs/rhino-interop-quickstart.md +7 -1
- 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 Ze = Object.defineProperty;
|
|
2
|
+
var me = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var T = (n,
|
|
7
|
-
var
|
|
5
|
+
var ts = (n, t, e) => t in n ? Ze(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
6
|
+
var T = (n, t, e) => ts(n, typeof t != "symbol" ? t + "" : t, e), Pt = (n, t, e) => t.has(n) || me("Cannot " + e);
|
|
7
|
+
var l = (n, t, e) => (Pt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), _ = (n, t, e) => t.has(n) ? me("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), b = (n, t, e, s) => (Pt(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), a = (n, t, e) => (Pt(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 Et = /* @__PURE__ */ Object.create(null);
|
|
17
17
|
Object.keys(P).forEach((n) => {
|
|
18
|
-
|
|
18
|
+
Et[P[n]] = n;
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
const s =
|
|
24
|
-
|
|
25
|
-
},
|
|
20
|
+
const jt = { type: "error", data: "parser error" }, $e = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Re = typeof ArrayBuffer == "function", Ce = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, ce = ({ type: n, data: t }, e, s) => $e && t instanceof Blob ? e ? s(t) : ge(t, s) : Re && (t instanceof ArrayBuffer || Ce(t)) ? e ? s(t) : ge(new Blob([t]), s) : s(P[n] + (t || "")), ge = (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 we(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 Bt;
|
|
31
|
+
function es(n, t) {
|
|
32
|
+
if ($e && n.data instanceof Blob)
|
|
33
|
+
return n.data.arrayBuffer().then(we).then(t);
|
|
34
|
+
if (Re && (n.data instanceof ArrayBuffer || Ce(n.data)))
|
|
35
|
+
return t(we(n.data));
|
|
36
|
+
ce(n, !1, (e) => {
|
|
37
|
+
Bt || (Bt = new TextEncoder()), t(Bt.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 _e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ot = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
41
|
+
for (let n = 0; n < _e.length; n++)
|
|
42
|
+
ot[_e.charCodeAt(n)] = n;
|
|
43
|
+
const ss = (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
|
+
}, ns = typeof ArrayBuffer == "function", he = (n, t) => {
|
|
51
51
|
if (typeof n != "string")
|
|
52
52
|
return {
|
|
53
53
|
type: "message",
|
|
54
|
-
data:
|
|
54
|
+
data: Ne(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: rs(n.substring(1), t)
|
|
60
|
+
} : Et[e] ? n.length > 1 ? {
|
|
61
|
+
type: Et[e],
|
|
62
62
|
data: n.substring(1)
|
|
63
63
|
} : {
|
|
64
|
-
type:
|
|
65
|
-
} :
|
|
66
|
-
},
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
return
|
|
64
|
+
type: Et[e]
|
|
65
|
+
} : jt;
|
|
66
|
+
}, rs = (n, t) => {
|
|
67
|
+
if (ns) {
|
|
68
|
+
const e = ss(n);
|
|
69
|
+
return Ne(e, t);
|
|
70
70
|
} else
|
|
71
71
|
return { base64: !0, data: n };
|
|
72
|
-
},
|
|
73
|
-
switch (
|
|
72
|
+
}, Ne = (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
|
+
}, Pe = "", is = (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
|
+
ce(i, !1, (h) => {
|
|
85
|
+
s[o] = h, ++r === e && t(s.join(Pe));
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
-
},
|
|
89
|
-
const
|
|
90
|
-
for (let r = 0; r <
|
|
91
|
-
const i =
|
|
88
|
+
}, os = (n, t) => {
|
|
89
|
+
const e = n.split(Pe), s = [];
|
|
90
|
+
for (let r = 0; r < e.length; r++) {
|
|
91
|
+
const i = he(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 as() {
|
|
98
98
|
return new TransformStream({
|
|
99
|
-
transform(n,
|
|
100
|
-
|
|
101
|
-
const s =
|
|
99
|
+
transform(n, t) {
|
|
100
|
+
es(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 Lt;
|
|
120
|
+
function wt(n) {
|
|
121
|
+
return n.reduce((t, e) => t + e.length, 0);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
if (n[0].length ===
|
|
123
|
+
function _t(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 cs(n, t) {
|
|
133
|
+
Lt || (Lt = 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 (wt(e) < 1)
|
|
141
141
|
break;
|
|
142
|
-
const
|
|
143
|
-
i = (
|
|
142
|
+
const u = _t(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 (wt(e) < 2)
|
|
146
146
|
break;
|
|
147
|
-
const
|
|
148
|
-
r = new DataView(
|
|
147
|
+
const u = _t(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 (wt(e) < 8)
|
|
151
151
|
break;
|
|
152
|
-
const
|
|
152
|
+
const u = _t(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(jt);
|
|
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 (wt(e) < r)
|
|
160
160
|
break;
|
|
161
|
-
const
|
|
162
|
-
h.enqueue(
|
|
161
|
+
const u = _t(e, r);
|
|
162
|
+
h.enqueue(he(i ? u : Lt.decode(u), t)), s = 0;
|
|
163
163
|
}
|
|
164
164
|
if (r === 0 || r > n) {
|
|
165
|
-
h.enqueue(
|
|
165
|
+
h.enqueue(jt);
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
const
|
|
173
|
-
function
|
|
174
|
-
if (n) return
|
|
172
|
+
const Be = 4;
|
|
173
|
+
function E(n) {
|
|
174
|
+
if (n) return hs(n);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
for (var
|
|
178
|
-
n[
|
|
176
|
+
function hs(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 Ct = 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")(), ls = "arraybuffer";
|
|
223
|
+
function Le(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 us = A.setTimeout, ds = A.clearTimeout;
|
|
227
|
+
function Nt(n, t) {
|
|
228
|
+
t.useNativeTimers ? (n.setTimeoutFn = us.bind(A), n.clearTimeoutFn = ds.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 fs = 1.33;
|
|
231
|
+
function ps(n) {
|
|
232
|
+
return typeof n == "string" ? ys(n) : Math.ceil((n.byteLength || n.size) * fs);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
235
|
-
let
|
|
234
|
+
function ys(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 qe() {
|
|
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 ms(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 gs(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 ws 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 le 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, Nt(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 ws(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 = he(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 = ms(t);
|
|
357
|
+
return e.length ? "?" + e : "";
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
class
|
|
360
|
+
class _s extends le {
|
|
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
|
+
os(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, is(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] = qe()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
let
|
|
452
|
+
let Fe = !1;
|
|
453
453
|
try {
|
|
454
|
-
|
|
454
|
+
Fe = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
455
455
|
} catch {
|
|
456
456
|
}
|
|
457
|
-
const
|
|
458
|
-
function
|
|
457
|
+
const bs = Fe;
|
|
458
|
+
function Es() {
|
|
459
459
|
}
|
|
460
|
-
class
|
|
460
|
+
class vs extends _s {
|
|
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, Nt(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 = Le(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 = Es, 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", be);
|
|
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, be, !1);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
function
|
|
609
|
+
function be() {
|
|
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 Ts = function() {
|
|
614
|
+
const n = Ue({
|
|
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 Ss extends vs {
|
|
620
|
+
constructor(t) {
|
|
621
|
+
super(t);
|
|
622
|
+
const e = t && t.forceBase64;
|
|
623
|
+
this.supportsBinary = Ts && !e;
|
|
624
624
|
}
|
|
625
|
-
request(
|
|
626
|
-
return Object.assign(
|
|
625
|
+
request(t = {}) {
|
|
626
|
+
return Object.assign(t, { xd: this.xd }, this.opts), new N(Ue, this.uri(), t);
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
|
-
function
|
|
630
|
-
const
|
|
629
|
+
function Ue(n) {
|
|
630
|
+
const t = n.xdomain;
|
|
631
631
|
try {
|
|
632
|
-
if (typeof XMLHttpRequest < "u" && (!
|
|
632
|
+
if (typeof XMLHttpRequest < "u" && (!t || bs))
|
|
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 De = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
643
|
+
class ks extends le {
|
|
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 = De ? {} : Le(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
|
+
ce(s, this.supportsBinary, (i) => {
|
|
675
675
|
try {
|
|
676
676
|
this.doWrite(s, i);
|
|
677
677
|
} catch {
|
|
678
678
|
}
|
|
679
|
-
r &&
|
|
679
|
+
r && Ct(() => {
|
|
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] = qe()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
|
-
const
|
|
700
|
-
class
|
|
701
|
-
createSocket(
|
|
702
|
-
return
|
|
699
|
+
const qt = A.WebSocket || A.MozWebSocket;
|
|
700
|
+
class Os extends ks {
|
|
701
|
+
createSocket(t, e, s) {
|
|
702
|
+
return De ? new qt(t, e, s) : e ? new qt(t, e) : new qt(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 As extends le {
|
|
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 = cs(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), r = as();
|
|
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 && Ct(() => {
|
|
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 Is = {
|
|
755
|
+
websocket: Os,
|
|
756
|
+
webtransport: As,
|
|
757
|
+
polling: Ss
|
|
758
|
+
}, xs = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, $s = [
|
|
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 Mt(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 = xs.exec(n || ""), i = {}, o = 14;
|
|
780
780
|
for (; o--; )
|
|
781
|
-
i[
|
|
782
|
-
return
|
|
781
|
+
i[$s[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 = Rs(i, i.path), i.queryKey = Cs(i, i.query), i;
|
|
783
783
|
}
|
|
784
|
-
function
|
|
785
|
-
const
|
|
786
|
-
return (
|
|
784
|
+
function Rs(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 Cs(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 Ht = typeof addEventListener == "function" && typeof removeEventListener == "function", vt = [];
|
|
795
|
+
Ht && addEventListener("offline", () => {
|
|
796
|
+
vt.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 = ls, 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 = Mt(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 = Mt(e.host).host);
|
|
810
|
+
Nt(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 = gs(this.opts.query)), Ht && (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
|
+
}, vt.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 = Be, 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 += ps(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, Ct(() => {
|
|
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(), Ht && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
1061
|
+
const s = vt.indexOf(this._offlineEventListener);
|
|
1062
|
+
s !== -1 && vt.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 = Be;
|
|
1069
|
+
class Ns 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 Ps = class extends Ns {
|
|
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) => Is[i]).filter((i) => !!i)), super(s ? r : t, r);
|
|
1145
1145
|
}
|
|
1146
1146
|
};
|
|
1147
|
-
function
|
|
1147
|
+
function Bs(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 = Mt(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 Ls = typeof ArrayBuffer == "function", qs = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, je = Object.prototype.toString, Fs = typeof Blob == "function" || typeof Blob < "u" && je.call(Blob) === "[object BlobConstructor]", Us = typeof File == "function" || typeof File < "u" && je.call(File) === "[object FileConstructor]";
|
|
1154
|
+
function ue(n) {
|
|
1155
|
+
return Ls && (n instanceof ArrayBuffer || qs(n)) || Fs && n instanceof Blob || Us && n instanceof File;
|
|
1156
1156
|
}
|
|
1157
|
-
function
|
|
1157
|
+
function Tt(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 (Tt(n[e]))
|
|
1163
1163
|
return !0;
|
|
1164
1164
|
return !1;
|
|
1165
1165
|
}
|
|
1166
|
-
if (
|
|
1166
|
+
if (ue(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 Tt(n.toJSON(), !0);
|
|
1170
|
+
for (const e in n)
|
|
1171
|
+
if (Object.prototype.hasOwnProperty.call(n, e) && Tt(n[e]))
|
|
1172
1172
|
return !0;
|
|
1173
1173
|
return !1;
|
|
1174
1174
|
}
|
|
1175
|
-
function
|
|
1176
|
-
const
|
|
1177
|
-
return s.data =
|
|
1175
|
+
function Ds(n) {
|
|
1176
|
+
const t = [], e = n.data, s = n;
|
|
1177
|
+
return s.data = Gt(e, t), s.attachments = t.length, { packet: s, buffers: t };
|
|
1178
1178
|
}
|
|
1179
|
-
function
|
|
1179
|
+
function Gt(n, t) {
|
|
1180
1180
|
if (!n)
|
|
1181
1181
|
return n;
|
|
1182
|
-
if (
|
|
1183
|
-
const
|
|
1184
|
-
return
|
|
1182
|
+
if (ue(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] = Gt(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] = Gt(n[s], t));
|
|
1194
|
+
return e;
|
|
1195
1195
|
}
|
|
1196
1196
|
return n;
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1199
|
-
return n.data =
|
|
1198
|
+
function js(n, t) {
|
|
1199
|
+
return n.data = Vt(n.data, t), delete n.attachments, n;
|
|
1200
1200
|
}
|
|
1201
|
-
function
|
|
1201
|
+
function Vt(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] = Vt(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] = Vt(n[e], t));
|
|
1214
1214
|
return n;
|
|
1215
1215
|
}
|
|
1216
|
-
const
|
|
1216
|
+
const Ms = [
|
|
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 Hs {
|
|
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) && Tt(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 = Ds(t), s = this.encodeAsString(e.packet), r = e.buffers;
|
|
1271
1271
|
return r.unshift(s), r;
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
|
-
class
|
|
1274
|
+
class de 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 Gs(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
|
|
1297
|
+
} else if (ue(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 (!Vs(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 (de.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 Ee(e);
|
|
1373
|
+
case g.DISCONNECT:
|
|
1374
|
+
return e === void 0;
|
|
1375
|
+
case g.CONNECT_ERROR:
|
|
1376
|
+
return typeof e == "string" || Ee(e);
|
|
1377
|
+
case g.EVENT:
|
|
1378
|
+
case g.BINARY_EVENT:
|
|
1379
|
+
return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Ms.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 Gs {
|
|
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 = js(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 Vs = Number.isInteger || function(n) {
|
|
1419
1419
|
return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
|
|
1420
1420
|
};
|
|
1421
|
-
function
|
|
1421
|
+
function Ee(n) {
|
|
1422
1422
|
return Object.prototype.toString.call(n) === "[object Object]";
|
|
1423
1423
|
}
|
|
1424
|
-
const
|
|
1424
|
+
const Js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1425
1425
|
__proto__: null,
|
|
1426
|
-
Decoder:
|
|
1427
|
-
Encoder:
|
|
1426
|
+
Decoder: de,
|
|
1427
|
+
Encoder: Hs,
|
|
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 Ys = 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 Me 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 (Ys.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 Jt 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, Nt(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 || Js;
|
|
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 Ps(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
|
+
Ct(() => {
|
|
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 Me(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,475 @@ 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 = Bs(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 Jt(s, t) : (rt[r] || (rt[r] = new Jt(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: Jt,
|
|
2308
|
+
Socket: Me,
|
|
2309
|
+
io: ut,
|
|
2310
|
+
connect: ut
|
|
2311
2311
|
});
|
|
2312
|
-
|
|
2313
|
-
|
|
2312
|
+
class ve 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 Te = "bimterop", Se = "revitflow_history.json", it = "revitflow_ops.json", ke = "revitflow/ops@1", Ws = "revitflow_model.frag", Ks = "revitflow_", bt = () => `v-${Date.now()}`;
|
|
2320
|
+
function He(n, t) {
|
|
2321
|
+
return n.filter((e) => String(e.parentId ?? "") === t);
|
|
2322
|
+
}
|
|
2323
|
+
function Y(n) {
|
|
2324
|
+
return String(n._id ?? n.id ?? "");
|
|
2325
|
+
}
|
|
2326
|
+
var x, dt, Yt;
|
|
2327
|
+
class Xs {
|
|
2328
|
+
constructor(t, e) {
|
|
2329
|
+
_(this, dt);
|
|
2330
|
+
_(this, x);
|
|
2331
|
+
this.client = t, this.projectId = e;
|
|
2332
|
+
}
|
|
2333
|
+
/** The project's connected documents. */
|
|
2334
|
+
async docs() {
|
|
2335
|
+
const t = await a(this, dt, Yt).call(this);
|
|
2336
|
+
if (!t) return [];
|
|
2337
|
+
const e = await this.client.listFolders({
|
|
2338
|
+
parentFolderId: t,
|
|
2339
|
+
projectId: this.projectId
|
|
2340
|
+
}), s = [];
|
|
2341
|
+
for (const r of He(e, t)) {
|
|
2342
|
+
const i = String(r.name ?? ""), o = i.indexOf("-");
|
|
2343
|
+
o <= 0 || s.push({
|
|
2344
|
+
source: i.slice(0, o),
|
|
2345
|
+
docId: i.slice(o + 1),
|
|
2346
|
+
modelName: void 0
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
return s;
|
|
2350
|
+
}
|
|
2351
|
+
/** One document's history. `source` and `docId` as {@link docs} lists them. */
|
|
2352
|
+
doc(t, e) {
|
|
2353
|
+
return new zs(this.client, this, t, e);
|
|
2354
|
+
}
|
|
2355
|
+
/** @internal The `bimterop` folder id, resolved once. */
|
|
2356
|
+
async rootFolderId(t = !1) {
|
|
2357
|
+
if (l(this, x)) return l(this, x);
|
|
2358
|
+
const e = await a(this, dt, Yt).call(this);
|
|
2359
|
+
if (e) return e;
|
|
2360
|
+
if (!t) return;
|
|
2361
|
+
const s = await this.client.createFolder(
|
|
2362
|
+
Te,
|
|
2363
|
+
void 0,
|
|
2364
|
+
this.projectId
|
|
2365
|
+
);
|
|
2366
|
+
return b(this, x, Y(s)), l(this, x);
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
x = new WeakMap(), dt = new WeakSet(), Yt = async function() {
|
|
2370
|
+
if (l(this, x)) return l(this, x);
|
|
2371
|
+
const e = (await this.client.listFolders({
|
|
2372
|
+
projectId: this.projectId
|
|
2373
|
+
})).find(
|
|
2374
|
+
(s) => String(s.name ?? "") === Te && !s.parentId
|
|
2375
|
+
);
|
|
2376
|
+
return e && b(this, x, Y(e)), l(this, x);
|
|
2377
|
+
};
|
|
2378
|
+
var L, p, at, ct, Wt, St, kt, Kt, Ot, ht, At, Xt, Ge;
|
|
2379
|
+
class zs {
|
|
2380
|
+
constructor(t, e, s, r) {
|
|
2381
|
+
_(this, p);
|
|
2382
|
+
_(this, L);
|
|
2383
|
+
this.client = t, this.project = e, this.source = s, this.docId = r;
|
|
2384
|
+
}
|
|
2385
|
+
// ─── Reading ───────────────────────────────────────────────────────────────
|
|
2386
|
+
/**
|
|
2387
|
+
* The document's versions, oldest first, ordered by the parent graph (not
|
|
2388
|
+
* by array position, which concurrent writers do not keep meaningful).
|
|
2389
|
+
* Each version gets its `ordinal` filled in.
|
|
2390
|
+
*/
|
|
2391
|
+
async timeline() {
|
|
2392
|
+
const t = await a(this, p, Ot).call(this);
|
|
2393
|
+
return Ve((t == null ? void 0 : t.commits) ?? []);
|
|
2394
|
+
}
|
|
2395
|
+
/** The head of the timeline, or null before the first sync. */
|
|
2396
|
+
async latest() {
|
|
2397
|
+
const t = await this.timeline();
|
|
2398
|
+
return t.length ? t[t.length - 1] : null;
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* A version's delta geometry as a .frag. The baseline (`full`) versions have
|
|
2402
|
+
* no delta: their geometry IS the model file — use {@link model}.
|
|
2403
|
+
*/
|
|
2404
|
+
async delta(t) {
|
|
2405
|
+
if (!t.deltaId)
|
|
2406
|
+
throw new Error(
|
|
2407
|
+
`Version ${t.guid} carries no delta: it is a full export — read model() instead.`
|
|
2408
|
+
);
|
|
2409
|
+
return await (await this.client.downloadHiddenFile(t.deltaId)).blob();
|
|
2410
|
+
}
|
|
2411
|
+
/** The visible model .frag as last fully exported. */
|
|
2412
|
+
async model() {
|
|
2413
|
+
const t = await a(this, p, kt).call(this);
|
|
2414
|
+
if (!t)
|
|
2415
|
+
throw new Error(
|
|
2416
|
+
`Document ${this.source}-${this.docId} has no model file yet.`
|
|
2417
|
+
);
|
|
2418
|
+
return await (await this.client.downloadFile(t.id)).blob();
|
|
2419
|
+
}
|
|
2420
|
+
// ─── Writing versions ─────────────────────────────────────────────────────
|
|
2421
|
+
/**
|
|
2422
|
+
* Appends one version: uploads the geometry it carries, then the updated
|
|
2423
|
+
* history. Give `expectedLatestGuid` whenever you built on a head you read,
|
|
2424
|
+
* so a concurrent writer surfaces as {@link StaleHistoryError} instead of a
|
|
2425
|
+
* silent fork.
|
|
2426
|
+
*/
|
|
2427
|
+
async sync(t) {
|
|
2428
|
+
var h;
|
|
2429
|
+
const e = await a(this, p, ct).call(this, !0);
|
|
2430
|
+
let s = await a(this, p, Ot).call(this) ?? {
|
|
2431
|
+
model: this.docId,
|
|
2432
|
+
commits: []
|
|
2433
|
+
};
|
|
2434
|
+
const r = Oe(s.commits);
|
|
2435
|
+
if (t.expectedLatestGuid !== void 0 && (r == null ? void 0 : r.guid) !== t.expectedLatestGuid)
|
|
2436
|
+
throw new ve(t.expectedLatestGuid, r == null ? void 0 : r.guid);
|
|
2437
|
+
const i = {
|
|
2438
|
+
guid: zt(),
|
|
2439
|
+
...r ? { parents: [r.guid] } : {},
|
|
2440
|
+
author: t.author,
|
|
2441
|
+
source: t.source,
|
|
2442
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2443
|
+
...t.message ? { message: t.message } : {},
|
|
2444
|
+
...t.userId ? { userId: t.userId } : {},
|
|
2445
|
+
...(h = t.appliedOps) != null && h.length ? { appliedOps: t.appliedOps } : {},
|
|
2446
|
+
changes: t.changes,
|
|
2447
|
+
counts: Qs(t.changes)
|
|
2448
|
+
};
|
|
2449
|
+
if (t.model && (await a(this, p, Ge).call(this, e, t.model), i.full = !0), t.delta) {
|
|
2450
|
+
const u = await a(this, p, kt).call(this);
|
|
2451
|
+
if (!u)
|
|
2452
|
+
throw new Error(
|
|
2453
|
+
"A delta needs the model file to hang from: sync a full model first."
|
|
2454
|
+
);
|
|
2455
|
+
const f = await this.client.createHiddenFile(
|
|
2456
|
+
t.delta,
|
|
2457
|
+
u.id
|
|
2458
|
+
);
|
|
2459
|
+
i.deltaId = String(
|
|
2460
|
+
f._id ?? f.id
|
|
2461
|
+
);
|
|
2462
|
+
}
|
|
2463
|
+
const o = await a(this, p, Ot).call(this);
|
|
2464
|
+
if (o) {
|
|
2465
|
+
s = o;
|
|
2466
|
+
const u = Oe(s.commits);
|
|
2467
|
+
if (t.expectedLatestGuid !== void 0 && (u == null ? void 0 : u.guid) !== t.expectedLatestGuid)
|
|
2468
|
+
throw new ve(t.expectedLatestGuid, u == null ? void 0 : u.guid);
|
|
2469
|
+
u && !i.parents && (i.parents = [u.guid]);
|
|
2470
|
+
}
|
|
2471
|
+
return s.commits.push(i), await a(this, p, At).call(this, e, Se, s), i;
|
|
2472
|
+
}
|
|
2473
|
+
// ─── Suggestions (change requests) ────────────────────────────────────────
|
|
2474
|
+
/** Every suggestion in the document's queue, pending or resolved. */
|
|
2475
|
+
async suggestions() {
|
|
2476
|
+
const t = await a(this, p, ht).call(this);
|
|
2477
|
+
return (t == null ? void 0 : t.ops) ?? [];
|
|
2478
|
+
}
|
|
2479
|
+
/** The suggestions still waiting for the owner, oldest first. */
|
|
2480
|
+
async pendingSuggestions() {
|
|
2481
|
+
return (await this.suggestions()).filter((t) => t.state === "pending");
|
|
2482
|
+
}
|
|
2483
|
+
/**
|
|
2484
|
+
* Queues a change request for this document. The payload, when given, is
|
|
2485
|
+
* uploaded as a hidden file under the suggestions index.
|
|
2486
|
+
*/
|
|
2487
|
+
async suggest(t) {
|
|
2488
|
+
const e = await a(this, p, ct).call(this, !0), s = await a(this, p, ht).call(this) ?? { schema: ke, ops: [] }, r = await a(this, p, St).call(this, it), i = {
|
|
2489
|
+
opId: t.opId ?? zt(),
|
|
2490
|
+
title: t.title,
|
|
2491
|
+
verb: t.verb,
|
|
2492
|
+
author: t.author,
|
|
2493
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2494
|
+
state: "pending",
|
|
2495
|
+
...t.targets !== void 0 ? { targets: t.targets } : {},
|
|
2496
|
+
...t.batchId ? { batchId: t.batchId } : {},
|
|
2497
|
+
...t.userId ? { userId: t.userId } : {},
|
|
2498
|
+
...t.baseCommitGuid ? { baseCommitGuid: t.baseCommitGuid } : {}
|
|
2499
|
+
};
|
|
2500
|
+
if (t.payload) {
|
|
2501
|
+
const h = r ?? await a(this, p, Xt).call(this, e, it, s), u = await this.client.createHiddenFile(
|
|
2502
|
+
t.payload,
|
|
2503
|
+
h.id
|
|
2504
|
+
);
|
|
2505
|
+
i.fragId = String(
|
|
2506
|
+
u._id ?? u.id
|
|
2507
|
+
);
|
|
2508
|
+
}
|
|
2509
|
+
const o = await a(this, p, ht).call(this) ?? s;
|
|
2510
|
+
return o.schema ?? (o.schema = ke), o.ops.push(i), await a(this, p, At).call(this, e, it, o), i;
|
|
2511
|
+
}
|
|
2512
|
+
/** A suggestion's .frag payload. */
|
|
2513
|
+
async suggestionPayload(t) {
|
|
2514
|
+
if (!t.fragId)
|
|
2515
|
+
throw new Error(`Suggestion ${t.opId} carries no payload.`);
|
|
2516
|
+
return await (await this.client.downloadHiddenFile(t.fragId)).blob();
|
|
2517
|
+
}
|
|
2518
|
+
/**
|
|
2519
|
+
* Marks a suggestion applied (naming the version that materialised it) or
|
|
2520
|
+
* discarded. The native plugins do this themselves when they apply; apps
|
|
2521
|
+
* use it for `discarded`.
|
|
2522
|
+
*/
|
|
2523
|
+
async resolveSuggestion(t, e) {
|
|
2524
|
+
const s = await a(this, p, ct).call(this, !1);
|
|
2525
|
+
if (!s) throw new Error("This document has no suggestion queue.");
|
|
2526
|
+
const r = await a(this, p, ht).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === t);
|
|
2527
|
+
if (!r || !i)
|
|
2528
|
+
throw new Error(`No suggestion ${t} in this document's queue.`);
|
|
2529
|
+
return Object.assign(i, e), await a(this, p, At).call(this, s, it, r), i;
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
L = new WeakMap(), p = new WeakSet(), at = function() {
|
|
2533
|
+
return `${this.source}-${this.docId}`;
|
|
2534
|
+
}, ct = async function(t) {
|
|
2535
|
+
if (l(this, L)) return l(this, L);
|
|
2536
|
+
const e = await this.project.rootFolderId(t);
|
|
2537
|
+
if (!e)
|
|
2538
|
+
throw new Error(
|
|
2539
|
+
`Project ${this.project.projectId} has no connected documents yet.`
|
|
2540
|
+
);
|
|
2541
|
+
const s = await this.client.listFolders({
|
|
2542
|
+
parentFolderId: e,
|
|
2543
|
+
projectId: this.project.projectId
|
|
2544
|
+
}), r = He(s, e).find(
|
|
2545
|
+
(o) => String(o.name ?? "") === l(this, p, at)
|
|
2546
|
+
);
|
|
2547
|
+
if (r)
|
|
2548
|
+
return b(this, L, Y(r)), l(this, L);
|
|
2549
|
+
if (!t)
|
|
2550
|
+
throw new Error(
|
|
2551
|
+
`Document ${l(this, p, at)} does not exist in this project.`
|
|
2552
|
+
);
|
|
2553
|
+
const i = await this.client.createFolder(
|
|
2554
|
+
l(this, p, at),
|
|
2555
|
+
e,
|
|
2556
|
+
this.project.projectId
|
|
2557
|
+
);
|
|
2558
|
+
return b(this, L, Y(i)), l(this, L);
|
|
2559
|
+
}, Wt = async function() {
|
|
2560
|
+
const t = await a(this, p, ct).call(this, !1);
|
|
2561
|
+
return (await this.client.listFiles({ folderId: t })).map((s) => ({
|
|
2562
|
+
id: Y(s),
|
|
2563
|
+
name: String(s.name ?? "")
|
|
2564
|
+
}));
|
|
2565
|
+
}, St = async function(t) {
|
|
2314
2566
|
try {
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2567
|
+
return (await a(this, p, Wt).call(this)).find((e) => e.name === t);
|
|
2568
|
+
} catch {
|
|
2569
|
+
return;
|
|
2570
|
+
}
|
|
2571
|
+
}, kt = async function() {
|
|
2572
|
+
try {
|
|
2573
|
+
const t = await a(this, p, Wt).call(this);
|
|
2574
|
+
return t.find((e) => e.name === Ws) ?? t.find(
|
|
2575
|
+
(e) => e.name.endsWith(".frag") && !e.name.startsWith(Ks)
|
|
2576
|
+
);
|
|
2577
|
+
} catch {
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
}, Kt = async function(t) {
|
|
2581
|
+
const e = await a(this, p, St).call(this, t);
|
|
2582
|
+
if (!e) return;
|
|
2583
|
+
const r = await (await this.client.downloadFile(e.id)).text();
|
|
2584
|
+
if (r.trim())
|
|
2585
|
+
return JSON.parse(r);
|
|
2586
|
+
}, Ot = function() {
|
|
2587
|
+
return a(this, p, Kt).call(this, Se);
|
|
2588
|
+
}, ht = function() {
|
|
2589
|
+
return a(this, p, Kt).call(this, it);
|
|
2590
|
+
}, At = async function(t, e, s) {
|
|
2591
|
+
const r = new Blob([JSON.stringify(s)], {
|
|
2592
|
+
type: "application/json"
|
|
2593
|
+
}), i = await a(this, p, St).call(this, e);
|
|
2594
|
+
return i ? (await this.client.updateFile(i.id, {
|
|
2595
|
+
file: r,
|
|
2596
|
+
versionTag: bt()
|
|
2597
|
+
}), i) : await a(this, p, Xt).call(this, t, e, s);
|
|
2598
|
+
}, Xt = async function(t, e, s) {
|
|
2599
|
+
const r = new Blob([JSON.stringify(s)], {
|
|
2600
|
+
type: "application/json"
|
|
2601
|
+
}), i = await this.client.createFile({
|
|
2602
|
+
file: r,
|
|
2603
|
+
name: e,
|
|
2604
|
+
versionTag: bt(),
|
|
2605
|
+
parentFolderId: t,
|
|
2606
|
+
projectId: this.project.projectId
|
|
2607
|
+
}), o = i.item;
|
|
2608
|
+
return { id: Y(o ?? i), name: e };
|
|
2609
|
+
}, Ge = async function(t, e) {
|
|
2610
|
+
const s = await a(this, p, kt).call(this);
|
|
2611
|
+
if (s)
|
|
2612
|
+
return await this.client.updateFile(s.id, {
|
|
2613
|
+
file: e,
|
|
2614
|
+
versionTag: bt()
|
|
2615
|
+
}), s;
|
|
2616
|
+
const r = `${l(this, p, at)}.frag`, i = await this.client.createFile({
|
|
2617
|
+
file: e,
|
|
2618
|
+
name: r,
|
|
2619
|
+
versionTag: bt(),
|
|
2620
|
+
parentFolderId: t,
|
|
2621
|
+
projectId: this.project.projectId
|
|
2622
|
+
}), o = i.item;
|
|
2623
|
+
return { id: Y(o ?? i), name: r };
|
|
2624
|
+
};
|
|
2625
|
+
function Qs(n) {
|
|
2626
|
+
const t = { added: 0, modified: 0, removed: 0 };
|
|
2627
|
+
for (const e of n)
|
|
2628
|
+
e.type === "create" ? t.added++ : e.type === "delete" ? t.removed++ : t.modified++;
|
|
2629
|
+
return t;
|
|
2630
|
+
}
|
|
2631
|
+
function Ve(n) {
|
|
2632
|
+
var u;
|
|
2633
|
+
if (n.length <= 1)
|
|
2634
|
+
return n.forEach((f, y) => f.ordinal = y), [...n];
|
|
2635
|
+
const t = new Map(n.map((f) => [f.guid, f])), e = /* @__PURE__ */ new Map(), s = [];
|
|
2636
|
+
for (const f of n) {
|
|
2637
|
+
const y = (u = f.parents) == null ? void 0 : u[0];
|
|
2638
|
+
if (y && t.has(y)) {
|
|
2639
|
+
const w = e.get(y) ?? [];
|
|
2640
|
+
w.push(f), e.set(y, w);
|
|
2641
|
+
} else
|
|
2642
|
+
s.push(f);
|
|
2643
|
+
}
|
|
2644
|
+
const r = (f, y) => String(f.timestamp).localeCompare(String(y.timestamp));
|
|
2645
|
+
s.sort(r);
|
|
2646
|
+
const i = [], o = [...s].reverse(), h = /* @__PURE__ */ new Set();
|
|
2647
|
+
for (; o.length; ) {
|
|
2648
|
+
const f = o.pop();
|
|
2649
|
+
if (h.has(f.guid)) continue;
|
|
2650
|
+
h.add(f.guid), i.push(f);
|
|
2651
|
+
const y = (e.get(f.guid) ?? []).sort(r);
|
|
2652
|
+
for (let w = y.length - 1; w >= 0; w--) o.push(y[w]);
|
|
2653
|
+
}
|
|
2654
|
+
for (const f of n)
|
|
2655
|
+
h.has(f.guid) || i.push(f);
|
|
2656
|
+
return i.forEach((f, y) => f.ordinal = y), i;
|
|
2657
|
+
}
|
|
2658
|
+
function Oe(n) {
|
|
2659
|
+
const t = Ve(n);
|
|
2660
|
+
return t[t.length - 1];
|
|
2661
|
+
}
|
|
2662
|
+
function zt() {
|
|
2663
|
+
const n = globalThis.crypto;
|
|
2664
|
+
return n != null && n.randomUUID ? n.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
|
|
2665
|
+
const e = Math.random() * 16 | 0;
|
|
2666
|
+
return (t === "x" ? e : e & 3 | 8).toString(16);
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
var j, ft, Qt;
|
|
2670
|
+
class Zs {
|
|
2671
|
+
constructor(t) {
|
|
2672
|
+
_(this, ft);
|
|
2673
|
+
_(this, j, /* @__PURE__ */ new Map());
|
|
2674
|
+
this.client = t;
|
|
2675
|
+
}
|
|
2676
|
+
/** Registers a recipe. One per name; a second with the same name throws. */
|
|
2677
|
+
register(t) {
|
|
2678
|
+
if (l(this, j).has(t.name))
|
|
2679
|
+
throw new Error(`A recipe named "${t.name}" is already registered.`);
|
|
2680
|
+
l(this, j).set(t.name, t);
|
|
2681
|
+
}
|
|
2682
|
+
/** The registered recipes, optionally filtered by target application. */
|
|
2683
|
+
list(t) {
|
|
2684
|
+
return [...l(this, j).values()].filter(
|
|
2685
|
+
(s) => (!(t != null && t.to) || s.to === t.to) && (!(t != null && t.input) || s.inputs.includes(t.input))
|
|
2686
|
+
);
|
|
2687
|
+
}
|
|
2688
|
+
/** A registered recipe by name, or undefined. */
|
|
2689
|
+
get(t) {
|
|
2690
|
+
return l(this, j).get(t);
|
|
2691
|
+
}
|
|
2692
|
+
/**
|
|
2693
|
+
* Runs a recipe WITHOUT queueing anything: the dry pass. Returns the
|
|
2694
|
+
* recipe's result — title, tallies per rule, targets — so an app can show
|
|
2695
|
+
* what would be proposed before anybody confirms. The payload it may have
|
|
2696
|
+
* built is discarded along with its opId.
|
|
2697
|
+
*/
|
|
2698
|
+
async plan(t, e) {
|
|
2699
|
+
const { result: s } = await a(this, ft, Qt).call(this, t, e);
|
|
2700
|
+
return s;
|
|
2701
|
+
}
|
|
2702
|
+
/**
|
|
2703
|
+
* Runs a recipe and queues its suggestion on the target document. Safe to
|
|
2704
|
+
* call freely: nothing touches the native application until its owner
|
|
2705
|
+
* accepts the suggestion there. Use {@link plan} first when the app wants
|
|
2706
|
+
* to show the tallies before queueing.
|
|
2707
|
+
*/
|
|
2708
|
+
async run(t, e) {
|
|
2709
|
+
const { targetDoc: s, base: r, opId: i, result: o } = await a(this, ft, Qt).call(this, t, e);
|
|
2710
|
+
return { suggestion: await s.suggest({
|
|
2711
|
+
opId: i,
|
|
2712
|
+
title: o.title,
|
|
2713
|
+
verb: o.verb,
|
|
2714
|
+
author: e.author,
|
|
2715
|
+
payload: o.payload,
|
|
2716
|
+
targets: o.targets,
|
|
2717
|
+
userId: e.userId,
|
|
2718
|
+
baseCommitGuid: r == null ? void 0 : r.guid
|
|
2719
|
+
}), result: o };
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
j = new WeakMap(), ft = new WeakSet(), Qt = async function(t, e) {
|
|
2723
|
+
const s = l(this, j).get(t);
|
|
2724
|
+
if (!s) throw new Error(`No recipe named "${t}" is registered.`);
|
|
2725
|
+
if (s.to !== e.target.source)
|
|
2726
|
+
throw new Error(
|
|
2727
|
+
`Recipe "${t}" writes ${s.to}, but the target document belongs to ${e.target.source}.`
|
|
2728
|
+
);
|
|
2729
|
+
const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o = zt(), h = await s.run({
|
|
2730
|
+
client: this.client,
|
|
2731
|
+
projectId: e.projectId,
|
|
2732
|
+
targetDoc: r,
|
|
2733
|
+
opId: o,
|
|
2734
|
+
input: e.input,
|
|
2735
|
+
settings: e.settings ?? {}
|
|
2736
|
+
});
|
|
2737
|
+
return { recipe: s, targetDoc: r, base: i, opId: o, result: h };
|
|
2738
|
+
};
|
|
2739
|
+
const Ae = 100;
|
|
2740
|
+
function tn(n) {
|
|
2741
|
+
try {
|
|
2742
|
+
const t = JSON.parse(n);
|
|
2743
|
+
if (t && typeof t == "object") {
|
|
2744
|
+
const e = t;
|
|
2318
2745
|
return {
|
|
2319
|
-
message: typeof
|
|
2320
|
-
code: typeof
|
|
2321
|
-
details:
|
|
2746
|
+
message: typeof e.message == "string" ? e.message : void 0,
|
|
2747
|
+
code: typeof e.code == "string" ? e.code : void 0,
|
|
2748
|
+
details: e.details
|
|
2322
2749
|
};
|
|
2323
2750
|
}
|
|
2324
2751
|
} catch {
|
|
2325
2752
|
}
|
|
2326
2753
|
return {};
|
|
2327
2754
|
}
|
|
2328
|
-
function
|
|
2755
|
+
function en(n) {
|
|
2329
2756
|
if (!n || typeof n != "object") return;
|
|
2330
|
-
const
|
|
2331
|
-
return typeof
|
|
2757
|
+
const t = n.retryAfter;
|
|
2758
|
+
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
|
|
2332
2759
|
}
|
|
2333
|
-
class
|
|
2334
|
-
constructor(
|
|
2335
|
-
const o =
|
|
2336
|
-
super(o.message ?? `${s || "Request failed"} (${
|
|
2760
|
+
class fe extends Error {
|
|
2761
|
+
constructor(e, s, r, i) {
|
|
2762
|
+
const o = tn(r);
|
|
2763
|
+
super(o.message ?? `${s || "Request failed"} (${e})`);
|
|
2337
2764
|
T(this, "status");
|
|
2338
2765
|
T(this, "code");
|
|
2339
2766
|
T(this, "details");
|
|
@@ -2343,32 +2770,32 @@ class Ve extends Error {
|
|
|
2343
2770
|
* from `details.retryAfter`. Only present on rate-limited (429) responses.
|
|
2344
2771
|
*/
|
|
2345
2772
|
T(this, "retryAfter");
|
|
2346
|
-
this.name = "RequestError", this.status =
|
|
2773
|
+
this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? en(o.details);
|
|
2347
2774
|
}
|
|
2348
2775
|
}
|
|
2349
|
-
const
|
|
2350
|
-
function
|
|
2776
|
+
const C = "item/folder", m = "item", U = "processor", sn = "npm-registry", B = "hidden", Ft = "FILE", Ut = "TOOL", Dt = "APP", nn = 500, Ie = 3e4, rn = 0.25, on = (n) => new Promise((t) => setTimeout(t, n));
|
|
2777
|
+
function an(n) {
|
|
2351
2778
|
var r, i;
|
|
2352
|
-
const
|
|
2353
|
-
if (!
|
|
2354
|
-
const
|
|
2355
|
-
if (Number.isFinite(
|
|
2356
|
-
const s = Date.parse(
|
|
2779
|
+
const t = (i = (r = n.headers) == null ? void 0 : r.get) == null ? void 0 : i.call(r, "Retry-After");
|
|
2780
|
+
if (!t) return;
|
|
2781
|
+
const e = Number(t);
|
|
2782
|
+
if (Number.isFinite(e)) return Math.max(0, e);
|
|
2783
|
+
const s = Date.parse(t);
|
|
2357
2784
|
if (!Number.isNaN(s))
|
|
2358
2785
|
return Math.max(0, (s - Date.now()) / 1e3);
|
|
2359
2786
|
}
|
|
2360
|
-
function
|
|
2361
|
-
return n instanceof
|
|
2787
|
+
function cn(n) {
|
|
2788
|
+
return n instanceof fe ? n.status === 429 || n.status >= 500 : !0;
|
|
2362
2789
|
}
|
|
2363
|
-
function
|
|
2364
|
-
const
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
), s =
|
|
2368
|
-
return r != null ? Math.min(r,
|
|
2790
|
+
function hn(n, t) {
|
|
2791
|
+
const e = Math.min(
|
|
2792
|
+
nn * 2 ** t,
|
|
2793
|
+
Ie
|
|
2794
|
+
), s = e * rn * Math.random(), r = n instanceof fe && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
|
|
2795
|
+
return r != null ? Math.min(r, Ie) + s : e + s;
|
|
2369
2796
|
}
|
|
2370
|
-
var c,
|
|
2371
|
-
const
|
|
2797
|
+
var c, te, d, D, pt, lt, It, xt, ee, se, Je;
|
|
2798
|
+
const pe = class pe {
|
|
2372
2799
|
/**
|
|
2373
2800
|
* Creates a new EngineServicesClient instance.
|
|
2374
2801
|
* @param accessToken - API access token (obtained from the platform dashboard)
|
|
@@ -2376,7 +2803,7 @@ const Je = class Je {
|
|
|
2376
2803
|
* @param apiUrl - Base URL of the API (e.g. "https://api.thatopen.com").
|
|
2377
2804
|
* @param props - Optional configuration (retry count, auth mode, etc.).
|
|
2378
2805
|
*/
|
|
2379
|
-
constructor(
|
|
2806
|
+
constructor(t, e, s) {
|
|
2380
2807
|
_(this, c);
|
|
2381
2808
|
T(this, "apiUrl");
|
|
2382
2809
|
T(this, "accessToken");
|
|
@@ -2396,11 +2823,12 @@ const Je = class Je {
|
|
|
2396
2823
|
* Populated automatically when using {@link fromPlatformContext}.
|
|
2397
2824
|
*/
|
|
2398
2825
|
T(this, "context");
|
|
2826
|
+
_(this, pt);
|
|
2399
2827
|
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
|
-
|
|
2828
|
+
let h = e;
|
|
2829
|
+
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) {
|
|
2830
|
+
let u = o;
|
|
2831
|
+
u.charAt(u.length - 1) === "/" && (u = u.slice(0, -1)), this.localServerUrl = u;
|
|
2404
2832
|
}
|
|
2405
2833
|
}
|
|
2406
2834
|
/**
|
|
@@ -2419,12 +2847,12 @@ const Je = class Je {
|
|
|
2419
2847
|
* console.log(client.context.projectId);
|
|
2420
2848
|
* ```
|
|
2421
2849
|
*/
|
|
2422
|
-
static fromPlatformContext(
|
|
2423
|
-
const
|
|
2424
|
-
...
|
|
2850
|
+
static fromPlatformContext(t) {
|
|
2851
|
+
const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new pe(e.accessToken, e.apiUrl, {
|
|
2852
|
+
...t,
|
|
2425
2853
|
useBearer: !0
|
|
2426
2854
|
});
|
|
2427
|
-
return s.context =
|
|
2855
|
+
return s.context = e, s;
|
|
2428
2856
|
}
|
|
2429
2857
|
/**
|
|
2430
2858
|
* Sets the number of automatic retries for failed requests. Retries use
|
|
@@ -2432,8 +2860,8 @@ const Je = class Je {
|
|
|
2432
2860
|
* failures, 429s and 5xx are retried.
|
|
2433
2861
|
* @param retries - Number of retries (0 = no retries).
|
|
2434
2862
|
*/
|
|
2435
|
-
setRetries(
|
|
2436
|
-
this.retries =
|
|
2863
|
+
setRetries(t) {
|
|
2864
|
+
this.retries = t;
|
|
2437
2865
|
}
|
|
2438
2866
|
/**
|
|
2439
2867
|
* Registers the global libraries that built-in components need at runtime.
|
|
@@ -2466,8 +2894,8 @@ const Je = class Je {
|
|
|
2466
2894
|
* await client.initBuiltInComponent(ModelsPanel, components);
|
|
2467
2895
|
* ```
|
|
2468
2896
|
*/
|
|
2469
|
-
setBuiltInGlobals(
|
|
2470
|
-
this.builtInGlobals =
|
|
2897
|
+
setBuiltInGlobals(t) {
|
|
2898
|
+
this.builtInGlobals = t;
|
|
2471
2899
|
}
|
|
2472
2900
|
/**
|
|
2473
2901
|
* Protected extension point for subclasses that need dynamic tokens
|
|
@@ -2495,8 +2923,8 @@ const Je = class Je {
|
|
|
2495
2923
|
* to the private `#requestApi` implementation so retry / auth / query-
|
|
2496
2924
|
* cleaning logic is applied identically.
|
|
2497
2925
|
*/
|
|
2498
|
-
async request(
|
|
2499
|
-
return a(this, c,
|
|
2926
|
+
async request(t, e, s) {
|
|
2927
|
+
return a(this, c, d).call(this, t, e, s);
|
|
2500
2928
|
}
|
|
2501
2929
|
// ─── Files ───────────────────────────────────────────────────────
|
|
2502
2930
|
/**
|
|
@@ -2504,11 +2932,11 @@ const Je = class Je {
|
|
|
2504
2932
|
* @param filters - Optional filters for folder and archive status.
|
|
2505
2933
|
* @returns Array of file items.
|
|
2506
2934
|
*/
|
|
2507
|
-
async listFiles(
|
|
2508
|
-
const { folderId:
|
|
2509
|
-
return
|
|
2935
|
+
async listFiles(t) {
|
|
2936
|
+
const { folderId: e, archived: s, projectId: r } = t || {};
|
|
2937
|
+
return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, { query: { itemType: Ft, archived: s } }) : await a(this, c, d).call(this, "GET", `${m}`, {
|
|
2510
2938
|
query: {
|
|
2511
|
-
itemType:
|
|
2939
|
+
itemType: Ft,
|
|
2512
2940
|
archived: s,
|
|
2513
2941
|
...r && { projectId: r }
|
|
2514
2942
|
}
|
|
@@ -2520,16 +2948,16 @@ const Je = class Je {
|
|
|
2520
2948
|
* @param props - Options such as whether to include versions.
|
|
2521
2949
|
* @returns The file item, optionally with version history.
|
|
2522
2950
|
*/
|
|
2523
|
-
async getFile(
|
|
2524
|
-
return await a(this, c,
|
|
2951
|
+
async getFile(t, e) {
|
|
2952
|
+
return await a(this, c, se).call(this, t, e);
|
|
2525
2953
|
}
|
|
2526
2954
|
/**
|
|
2527
2955
|
* Uploads a new file.
|
|
2528
2956
|
* @param fileData - File content, name, and version tag.
|
|
2529
2957
|
* @returns The created item and its first version.
|
|
2530
2958
|
*/
|
|
2531
|
-
async createFile(
|
|
2532
|
-
return await a(this, c,
|
|
2959
|
+
async createFile(t) {
|
|
2960
|
+
return await a(this, c, xt).call(this, t, Ft);
|
|
2533
2961
|
}
|
|
2534
2962
|
/**
|
|
2535
2963
|
* Updates an existing file. Can rename, move to a different folder,
|
|
@@ -2538,22 +2966,22 @@ const Je = class Je {
|
|
|
2538
2966
|
* @param fileData - Properties to update (name, folderId, file, versionTag).
|
|
2539
2967
|
* @returns The updated item and/or the new version.
|
|
2540
2968
|
*/
|
|
2541
|
-
async updateFile(
|
|
2542
|
-
return await a(this, c,
|
|
2969
|
+
async updateFile(t, e) {
|
|
2970
|
+
return await a(this, c, ee).call(this, t, e);
|
|
2543
2971
|
}
|
|
2544
2972
|
/**
|
|
2545
2973
|
* Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
|
|
2546
2974
|
* @param fileId - The file's unique identifier.
|
|
2547
2975
|
*/
|
|
2548
|
-
async archiveFile(
|
|
2549
|
-
return await a(this, c,
|
|
2976
|
+
async archiveFile(t) {
|
|
2977
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
|
|
2550
2978
|
}
|
|
2551
2979
|
/**
|
|
2552
2980
|
* Recovers a previously archived file.
|
|
2553
2981
|
* @param fileId - The file's unique identifier.
|
|
2554
2982
|
*/
|
|
2555
|
-
async recoverFile(
|
|
2556
|
-
return await a(this, c,
|
|
2983
|
+
async recoverFile(t) {
|
|
2984
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${t}/recover`);
|
|
2557
2985
|
}
|
|
2558
2986
|
/**
|
|
2559
2987
|
* Downloads a file's content. Returns the raw fetch Response.
|
|
@@ -2561,8 +2989,8 @@ const Je = class Je {
|
|
|
2561
2989
|
* @param params - Optional version selection parameters.
|
|
2562
2990
|
* @returns A fetch Response containing the file data.
|
|
2563
2991
|
*/
|
|
2564
|
-
async downloadFile(
|
|
2565
|
-
return await a(this, c,
|
|
2992
|
+
async downloadFile(t, e) {
|
|
2993
|
+
return await a(this, c, It).call(this, t, e);
|
|
2566
2994
|
}
|
|
2567
2995
|
/**
|
|
2568
2996
|
* Retrieves the free-JSON metadata for a specific file version.
|
|
@@ -2571,9 +2999,9 @@ const Je = class Je {
|
|
|
2571
2999
|
* @param versionTag - The version tag (e.g. "v1").
|
|
2572
3000
|
* @param params - Optional flags such as `withDraft`.
|
|
2573
3001
|
*/
|
|
2574
|
-
async getFileVersionMetadata(
|
|
3002
|
+
async getFileVersionMetadata(t, e, s) {
|
|
2575
3003
|
const { withDraft: r } = s || {};
|
|
2576
|
-
return await a(this, c,
|
|
3004
|
+
return await a(this, c, d).call(this, "GET", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
|
|
2577
3005
|
query: {
|
|
2578
3006
|
...r && { withDraft: "true" }
|
|
2579
3007
|
}
|
|
@@ -2585,8 +3013,8 @@ const Je = class Je {
|
|
|
2585
3013
|
* @param versionTag - The version tag.
|
|
2586
3014
|
* @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
|
|
2587
3015
|
*/
|
|
2588
|
-
async updateFileVersionMetadata(
|
|
2589
|
-
return await a(this, c,
|
|
3016
|
+
async updateFileVersionMetadata(t, e, s) {
|
|
3017
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
|
|
2590
3018
|
body: JSON.stringify({ metadata: s }),
|
|
2591
3019
|
contentType: "application/json"
|
|
2592
3020
|
});
|
|
@@ -2596,8 +3024,8 @@ const Je = class Je {
|
|
|
2596
3024
|
* @param fileId - The file's unique identifier.
|
|
2597
3025
|
* @param versionTag - The version tag.
|
|
2598
3026
|
*/
|
|
2599
|
-
async deleteFileVersionMetadata(
|
|
2600
|
-
return await a(this, c,
|
|
3027
|
+
async deleteFileVersionMetadata(t, e) {
|
|
3028
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`);
|
|
2601
3029
|
}
|
|
2602
3030
|
/**
|
|
2603
3031
|
* Batch variant of {@link getFileVersionMetadata}. Reads the metadata of
|
|
@@ -2612,9 +3040,9 @@ const Je = class Je {
|
|
|
2612
3040
|
* @param entries - The `{ itemId, versionTag }` pairs to read.
|
|
2613
3041
|
* @param params - Optional flags such as `withDraft`.
|
|
2614
3042
|
*/
|
|
2615
|
-
async getFileVersionMetadataBatch(
|
|
2616
|
-
const { withDraft: s } =
|
|
2617
|
-
return await a(this, c,
|
|
3043
|
+
async getFileVersionMetadataBatch(t, e) {
|
|
3044
|
+
const { withDraft: s } = e || {};
|
|
3045
|
+
return await a(this, c, lt).call(this, t, async (r) => (await a(this, c, d).call(this, "POST", `${m}/batch/version-metadata`, {
|
|
2618
3046
|
body: JSON.stringify({
|
|
2619
3047
|
entries: r,
|
|
2620
3048
|
...s !== void 0 && { withDraft: s }
|
|
@@ -2628,12 +3056,12 @@ const Je = class Je {
|
|
|
2628
3056
|
* @param params - Optional filters for parent folder and archive status.
|
|
2629
3057
|
* @returns Array of folder items.
|
|
2630
3058
|
*/
|
|
2631
|
-
async listFolders(
|
|
2632
|
-
const { archived:
|
|
2633
|
-
return await a(this, c,
|
|
3059
|
+
async listFolders(t) {
|
|
3060
|
+
const { archived: e, parentFolderId: s, projectId: r } = t || {};
|
|
3061
|
+
return await a(this, c, d).call(this, "GET", C, {
|
|
2634
3062
|
query: {
|
|
2635
3063
|
parentFolderId: s,
|
|
2636
|
-
archived:
|
|
3064
|
+
archived: e,
|
|
2637
3065
|
...r && { projectId: r }
|
|
2638
3066
|
}
|
|
2639
3067
|
});
|
|
@@ -2642,8 +3070,8 @@ const Je = class Je {
|
|
|
2642
3070
|
* Gets a single folder by ID.
|
|
2643
3071
|
* @param folderId - The folder's unique identifier.
|
|
2644
3072
|
*/
|
|
2645
|
-
async getFolder(
|
|
2646
|
-
return await a(this, c,
|
|
3073
|
+
async getFolder(t) {
|
|
3074
|
+
return await a(this, c, d).call(this, "GET", `${C}/${t}`);
|
|
2647
3075
|
}
|
|
2648
3076
|
/**
|
|
2649
3077
|
* Batch variant of {@link getFolder}. Resolves a known set of folder ids in
|
|
@@ -2658,9 +3086,9 @@ const Je = class Je {
|
|
|
2658
3086
|
*
|
|
2659
3087
|
* @param folderIds - The folder ids to resolve.
|
|
2660
3088
|
*/
|
|
2661
|
-
async getFoldersBatch(
|
|
2662
|
-
return await a(this, c,
|
|
2663
|
-
body: JSON.stringify({ folderIds:
|
|
3089
|
+
async getFoldersBatch(t) {
|
|
3090
|
+
return await a(this, c, lt).call(this, t, async (e) => (await a(this, c, d).call(this, "POST", `${m}/batch/folders`, {
|
|
3091
|
+
body: JSON.stringify({ folderIds: e }),
|
|
2664
3092
|
contentType: "application/json"
|
|
2665
3093
|
})).results);
|
|
2666
3094
|
}
|
|
@@ -2670,11 +3098,11 @@ const Je = class Je {
|
|
|
2670
3098
|
* @param parentId - Optional parent folder ID for nesting.
|
|
2671
3099
|
* @returns The created folder.
|
|
2672
3100
|
*/
|
|
2673
|
-
async createFolder(
|
|
2674
|
-
return await a(this, c,
|
|
3101
|
+
async createFolder(t, e, s) {
|
|
3102
|
+
return await a(this, c, d).call(this, "POST", C, {
|
|
2675
3103
|
body: JSON.stringify({
|
|
2676
|
-
name:
|
|
2677
|
-
...
|
|
3104
|
+
name: t,
|
|
3105
|
+
...e && { parentId: e },
|
|
2678
3106
|
...s && { projectId: s }
|
|
2679
3107
|
}),
|
|
2680
3108
|
contentType: "application/json"
|
|
@@ -2686,9 +3114,9 @@ const Je = class Je {
|
|
|
2686
3114
|
* @param updateFolderParams - New name for the folder.
|
|
2687
3115
|
* @returns The updated folder.
|
|
2688
3116
|
*/
|
|
2689
|
-
async updateFolder(
|
|
2690
|
-
const { name: s } =
|
|
2691
|
-
return await a(this, c,
|
|
3117
|
+
async updateFolder(t, e) {
|
|
3118
|
+
const { name: s } = e;
|
|
3119
|
+
return await a(this, c, d).call(this, "PUT", `${C}/${t}`, {
|
|
2692
3120
|
body: JSON.stringify({ name: s }),
|
|
2693
3121
|
contentType: "application/json"
|
|
2694
3122
|
});
|
|
@@ -2697,23 +3125,23 @@ const Je = class Je {
|
|
|
2697
3125
|
* Archives (soft-deletes) a folder. Can be recovered with {@link recoverFolder}.
|
|
2698
3126
|
* @param folderId - The folder's unique identifier.
|
|
2699
3127
|
*/
|
|
2700
|
-
async archiveFolder(
|
|
2701
|
-
return await a(this, c,
|
|
3128
|
+
async archiveFolder(t) {
|
|
3129
|
+
return await a(this, c, d).call(this, "DELETE", `${C}/${t}`);
|
|
2702
3130
|
}
|
|
2703
3131
|
/**
|
|
2704
3132
|
* Recovers a previously archived folder.
|
|
2705
3133
|
* @param folderId - The folder's unique identifier.
|
|
2706
3134
|
*/
|
|
2707
|
-
async recoverFolder(
|
|
2708
|
-
return await a(this, c,
|
|
3135
|
+
async recoverFolder(t) {
|
|
3136
|
+
return await a(this, c, d).call(this, "PUT", `${C}/${t}/recover`);
|
|
2709
3137
|
}
|
|
2710
3138
|
/**
|
|
2711
3139
|
* Downloads an entire folder as a ZIP archive.
|
|
2712
3140
|
* @param folderId - The folder's unique identifier.
|
|
2713
3141
|
* @returns A fetch Response containing the ZIP data.
|
|
2714
3142
|
*/
|
|
2715
|
-
async downloadFolder(
|
|
2716
|
-
return await a(this, c,
|
|
3143
|
+
async downloadFolder(t) {
|
|
3144
|
+
return await a(this, c, D).call(this, `${C}/${t}/download`);
|
|
2717
3145
|
}
|
|
2718
3146
|
// ─── Components ──────────────────────────────────────────────────
|
|
2719
3147
|
/**
|
|
@@ -2721,16 +3149,16 @@ const Je = class Je {
|
|
|
2721
3149
|
* @param params - Optional filters for folder and version inclusion.
|
|
2722
3150
|
* @returns Array of component items.
|
|
2723
3151
|
*/
|
|
2724
|
-
async listComponents(
|
|
2725
|
-
const { folderId:
|
|
2726
|
-
return
|
|
3152
|
+
async listComponents(t) {
|
|
3153
|
+
const { folderId: e, ShowVersions: s, projectId: r } = t || {};
|
|
3154
|
+
return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, {
|
|
2727
3155
|
query: {
|
|
2728
|
-
itemType:
|
|
3156
|
+
itemType: Ut,
|
|
2729
3157
|
...s && { ShowVersions: s }
|
|
2730
3158
|
}
|
|
2731
|
-
}) : await a(this, c,
|
|
3159
|
+
}) : await a(this, c, d).call(this, "GET", `${m}`, {
|
|
2732
3160
|
query: {
|
|
2733
|
-
itemType:
|
|
3161
|
+
itemType: Ut,
|
|
2734
3162
|
...s && { ShowVersions: s },
|
|
2735
3163
|
...r && { projectId: r }
|
|
2736
3164
|
}
|
|
@@ -2741,17 +3169,17 @@ const Je = class Je {
|
|
|
2741
3169
|
* @param componentId - The component's unique identifier.
|
|
2742
3170
|
* @param props - Options such as whether to include versions.
|
|
2743
3171
|
*/
|
|
2744
|
-
async getComponent(
|
|
2745
|
-
return await a(this, c,
|
|
3172
|
+
async getComponent(t, e) {
|
|
3173
|
+
return await a(this, c, se).call(this, t, e);
|
|
2746
3174
|
}
|
|
2747
3175
|
/**
|
|
2748
3176
|
* Creates a new component with the given file and version properties.
|
|
2749
3177
|
* @param componentData - File content, name, version tag, and component-specific props.
|
|
2750
3178
|
* @returns The created component item and its first version.
|
|
2751
3179
|
*/
|
|
2752
|
-
async createComponent(
|
|
2753
|
-
const { componentProps:
|
|
2754
|
-
return await a(this, c,
|
|
3180
|
+
async createComponent(t) {
|
|
3181
|
+
const { componentProps: e } = t;
|
|
3182
|
+
return await a(this, c, xt).call(this, t, Ut, e);
|
|
2755
3183
|
}
|
|
2756
3184
|
/**
|
|
2757
3185
|
* Updates an existing component. Can rename, move, and/or upload a new version.
|
|
@@ -2759,9 +3187,9 @@ const Je = class Je {
|
|
|
2759
3187
|
* @param componentData - Properties to update, including optional new componentProps.
|
|
2760
3188
|
* @returns The updated item and/or new version.
|
|
2761
3189
|
*/
|
|
2762
|
-
async updateComponent(
|
|
2763
|
-
const { componentProps: s } =
|
|
2764
|
-
return await a(this, c,
|
|
3190
|
+
async updateComponent(t, e) {
|
|
3191
|
+
const { componentProps: s } = e;
|
|
3192
|
+
return await a(this, c, ee).call(this, t, e, s);
|
|
2765
3193
|
}
|
|
2766
3194
|
/**
|
|
2767
3195
|
* Downloads a component's full ZIP file. Returns the raw fetch Response.
|
|
@@ -2769,8 +3197,8 @@ const Je = class Je {
|
|
|
2769
3197
|
* @param params - Optional version selection parameters.
|
|
2770
3198
|
* @returns A fetch Response containing the ZIP data.
|
|
2771
3199
|
*/
|
|
2772
|
-
async downloadComponent(
|
|
2773
|
-
return await a(this, c,
|
|
3200
|
+
async downloadComponent(t, e) {
|
|
3201
|
+
return await a(this, c, It).call(this, t, e);
|
|
2774
3202
|
}
|
|
2775
3203
|
/**
|
|
2776
3204
|
* Downloads only the JavaScript bundle from a component's ZIP.
|
|
@@ -2779,9 +3207,9 @@ const Je = class Je {
|
|
|
2779
3207
|
* @param params - Optional version selection parameters.
|
|
2780
3208
|
* @returns A fetch Response containing the bundle JavaScript text.
|
|
2781
3209
|
*/
|
|
2782
|
-
async downloadComponentBundle(
|
|
2783
|
-
const { versionTag: s, withDraft: r } =
|
|
2784
|
-
return await a(this, c,
|
|
3210
|
+
async downloadComponentBundle(t, e) {
|
|
3211
|
+
const { versionTag: s, withDraft: r } = e || {};
|
|
3212
|
+
return await a(this, c, D).call(this, `${m}/${t}/download/bundle`, {
|
|
2785
3213
|
query: {
|
|
2786
3214
|
...s && { versionTag: s },
|
|
2787
3215
|
...r && { withDraft: r }
|
|
@@ -2792,15 +3220,15 @@ const Je = class Je {
|
|
|
2792
3220
|
* Archives (soft-deletes) a component. Can be recovered with {@link recoverComponent}.
|
|
2793
3221
|
* @param componentId - The component's unique identifier.
|
|
2794
3222
|
*/
|
|
2795
|
-
async archiveComponent(
|
|
2796
|
-
return await a(this, c,
|
|
3223
|
+
async archiveComponent(t) {
|
|
3224
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
|
|
2797
3225
|
}
|
|
2798
3226
|
/**
|
|
2799
3227
|
* Recovers a previously archived component.
|
|
2800
3228
|
* @param componentId - The component's unique identifier.
|
|
2801
3229
|
*/
|
|
2802
|
-
async recoverComponent(
|
|
2803
|
-
return await a(this, c,
|
|
3230
|
+
async recoverComponent(t) {
|
|
3231
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${t}/recover`);
|
|
2804
3232
|
}
|
|
2805
3233
|
// ─── Built-in Components ─────────────────────────────────────────
|
|
2806
3234
|
/**
|
|
@@ -2808,8 +3236,8 @@ const Je = class Je {
|
|
|
2808
3236
|
* @param name - The built-in component name (e.g. "hello-world").
|
|
2809
3237
|
* @returns The component's JavaScript source code as a string.
|
|
2810
3238
|
*/
|
|
2811
|
-
async getBuiltInComponent(
|
|
2812
|
-
return await (await a(this, c,
|
|
3239
|
+
async getBuiltInComponent(t) {
|
|
3240
|
+
return await (await a(this, c, D).call(this, `built-in/${t}/bundle`)).text();
|
|
2813
3241
|
}
|
|
2814
3242
|
/**
|
|
2815
3243
|
* Fetches a built-in component bundle, evaluates it, and registers it
|
|
@@ -2837,10 +3265,10 @@ const Je = class Je {
|
|
|
2837
3265
|
* await client.initBuiltInComponent(HelloWorld, components, { OBC, BUI });
|
|
2838
3266
|
* ```
|
|
2839
3267
|
*/
|
|
2840
|
-
async initBuiltInComponent(
|
|
2841
|
-
const r = await this.getBuiltInComponent(
|
|
2842
|
-
return main;`)(...h), y = (
|
|
2843
|
-
|
|
3268
|
+
async initBuiltInComponent(t, e, s) {
|
|
3269
|
+
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}
|
|
3270
|
+
return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
3271
|
+
e.get(y);
|
|
2844
3272
|
}
|
|
2845
3273
|
/**
|
|
2846
3274
|
* Loads multiple built-in components in parallel.
|
|
@@ -2856,9 +3284,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2856
3284
|
* await client.initBuiltInComponents(components, AppManager, ViewportManager);
|
|
2857
3285
|
* ```
|
|
2858
3286
|
*/
|
|
2859
|
-
async initBuiltInComponents(
|
|
3287
|
+
async initBuiltInComponents(t, ...e) {
|
|
2860
3288
|
await Promise.all(
|
|
2861
|
-
|
|
3289
|
+
e.map((s) => this.initBuiltInComponent(s, t))
|
|
2862
3290
|
);
|
|
2863
3291
|
}
|
|
2864
3292
|
/**
|
|
@@ -2881,23 +3309,23 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2881
3309
|
* const { element, world } = await viewports.create();
|
|
2882
3310
|
* ```
|
|
2883
3311
|
*/
|
|
2884
|
-
async setup(
|
|
3312
|
+
async setup(t, ...e) {
|
|
2885
3313
|
var o, h;
|
|
2886
|
-
const s =
|
|
3314
|
+
const s = t.OBC, r = t.BUI;
|
|
2887
3315
|
if (!(s != null && s.Components))
|
|
2888
3316
|
throw new Error("globals.OBC must include Components");
|
|
2889
3317
|
if (!(r != null && r.Manager)) throw new Error("globals.BUI must include Manager");
|
|
2890
3318
|
const i = new s.Components();
|
|
2891
|
-
return r.Manager.init(), this.setBuiltInGlobals(
|
|
3319
|
+
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
3320
|
}
|
|
2893
3321
|
/**
|
|
2894
3322
|
* Reports an error to the platform via the {@link AppEventOrchestrator.appError} callback.
|
|
2895
3323
|
* @param code - Numeric error code.
|
|
2896
3324
|
* @param data - Arbitrary error data to send to the platform.
|
|
2897
3325
|
*/
|
|
2898
|
-
throwError(
|
|
3326
|
+
throwError(t, e) {
|
|
2899
3327
|
var s, r;
|
|
2900
|
-
(r = (s = this.context.appEventOrchestrator) == null ? void 0 : s.appError) == null || r.call(s,
|
|
3328
|
+
(r = (s = this.context.appEventOrchestrator) == null ? void 0 : s.appError) == null || r.call(s, t, e);
|
|
2901
3329
|
}
|
|
2902
3330
|
// ─── Apps ────────────────────────────────────────────────────────
|
|
2903
3331
|
/**
|
|
@@ -2905,16 +3333,16 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2905
3333
|
* @param params - Optional filters for folder and version inclusion.
|
|
2906
3334
|
* @returns Array of app items.
|
|
2907
3335
|
*/
|
|
2908
|
-
async listApps(
|
|
2909
|
-
const { folderId:
|
|
2910
|
-
return
|
|
3336
|
+
async listApps(t) {
|
|
3337
|
+
const { folderId: e, ShowVersions: s, projectId: r } = t || {};
|
|
3338
|
+
return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, {
|
|
2911
3339
|
query: {
|
|
2912
|
-
itemType:
|
|
3340
|
+
itemType: Dt,
|
|
2913
3341
|
...s && { ShowVersions: s }
|
|
2914
3342
|
}
|
|
2915
|
-
}) : await a(this, c,
|
|
3343
|
+
}) : await a(this, c, d).call(this, "GET", `${m}`, {
|
|
2916
3344
|
query: {
|
|
2917
|
-
itemType:
|
|
3345
|
+
itemType: Dt,
|
|
2918
3346
|
...s && { ShowVersions: s },
|
|
2919
3347
|
...r && { projectId: r }
|
|
2920
3348
|
}
|
|
@@ -2925,9 +3353,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2925
3353
|
* @param appData - File content, name, version tag, and optional app-specific props.
|
|
2926
3354
|
* @returns The created app item and its first version.
|
|
2927
3355
|
*/
|
|
2928
|
-
async createApp(
|
|
2929
|
-
const { appProps:
|
|
2930
|
-
return await a(this, c,
|
|
3356
|
+
async createApp(t) {
|
|
3357
|
+
const { appProps: e } = t;
|
|
3358
|
+
return await a(this, c, xt).call(this, t, Dt, e);
|
|
2931
3359
|
}
|
|
2932
3360
|
/**
|
|
2933
3361
|
* Downloads an app's full ZIP file. Returns the raw fetch Response.
|
|
@@ -2935,8 +3363,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2935
3363
|
* @param params - Optional version selection parameters.
|
|
2936
3364
|
* @returns A fetch Response containing the ZIP data.
|
|
2937
3365
|
*/
|
|
2938
|
-
async downloadApp(
|
|
2939
|
-
return await a(this, c,
|
|
3366
|
+
async downloadApp(t, e) {
|
|
3367
|
+
return await a(this, c, It).call(this, t, e);
|
|
2940
3368
|
}
|
|
2941
3369
|
/**
|
|
2942
3370
|
* Downloads only the JavaScript bundle from an app's ZIP.
|
|
@@ -2945,9 +3373,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2945
3373
|
* @param params - Optional version selection parameters.
|
|
2946
3374
|
* @returns A fetch Response containing the bundle JavaScript text.
|
|
2947
3375
|
*/
|
|
2948
|
-
async downloadAppBundle(
|
|
2949
|
-
const { versionTag: s, withDraft: r } =
|
|
2950
|
-
return await a(this, c,
|
|
3376
|
+
async downloadAppBundle(t, e) {
|
|
3377
|
+
const { versionTag: s, withDraft: r } = e || {};
|
|
3378
|
+
return await a(this, c, D).call(this, `${m}/${t}/download/bundle`, {
|
|
2951
3379
|
query: {
|
|
2952
3380
|
...s && { versionTag: s },
|
|
2953
3381
|
...r && { withDraft: r }
|
|
@@ -2958,8 +3386,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2958
3386
|
* Archives (soft-deletes) an app.
|
|
2959
3387
|
* @param appId - The app's unique identifier.
|
|
2960
3388
|
*/
|
|
2961
|
-
async archiveApp(
|
|
2962
|
-
return await a(this, c,
|
|
3389
|
+
async archiveApp(t) {
|
|
3390
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
|
|
2963
3391
|
}
|
|
2964
3392
|
// ─── NPM Registry ────────────────────────────────────────────────
|
|
2965
3393
|
/**
|
|
@@ -2971,7 +3399,7 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2971
3399
|
* @returns The registry, scope, read-only token, and assembled `.npmrc`.
|
|
2972
3400
|
*/
|
|
2973
3401
|
async getNpmCredentials() {
|
|
2974
|
-
return await a(this, c,
|
|
3402
|
+
return await a(this, c, d).call(this, "GET", `${sn}/credentials`);
|
|
2975
3403
|
}
|
|
2976
3404
|
// ─── Execution ───────────────────────────────────────────────────
|
|
2977
3405
|
/**
|
|
@@ -2988,12 +3416,12 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
2988
3416
|
* @param versionTag - Optional version to execute (defaults to latest).
|
|
2989
3417
|
* @returns An object containing the `executionId` to track progress.
|
|
2990
3418
|
*/
|
|
2991
|
-
async executeComponent(
|
|
3419
|
+
async executeComponent(t, e, s) {
|
|
2992
3420
|
if (this.localServerUrl) {
|
|
2993
|
-
const r = `${this.localServerUrl}/api/${
|
|
3421
|
+
const r = `${this.localServerUrl}/api/${U}/${t}/execute`, i = await fetch(r, {
|
|
2994
3422
|
method: "POST",
|
|
2995
3423
|
headers: { "Content-Type": "application/json" },
|
|
2996
|
-
body: JSON.stringify(
|
|
3424
|
+
body: JSON.stringify(e)
|
|
2997
3425
|
});
|
|
2998
3426
|
if (!i.ok) {
|
|
2999
3427
|
const o = await i.text().catch(() => "");
|
|
@@ -3003,8 +3431,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3003
3431
|
}
|
|
3004
3432
|
return await i.json();
|
|
3005
3433
|
}
|
|
3006
|
-
return await a(this, c,
|
|
3007
|
-
body: JSON.stringify(
|
|
3434
|
+
return await a(this, c, d).call(this, "POST", `${U}/${t}/execute`, {
|
|
3435
|
+
body: JSON.stringify(e),
|
|
3008
3436
|
query: { ...s && { versionTag: s } },
|
|
3009
3437
|
contentType: "application/json"
|
|
3010
3438
|
});
|
|
@@ -3013,9 +3441,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3013
3441
|
* Aborts a running execution.
|
|
3014
3442
|
* @param executionId - The execution's unique identifier.
|
|
3015
3443
|
*/
|
|
3016
|
-
async abortExecution(
|
|
3444
|
+
async abortExecution(t) {
|
|
3017
3445
|
if (this.localServerUrl) {
|
|
3018
|
-
const
|
|
3446
|
+
const e = `${this.localServerUrl}/api/${U}/progress/${t}/abort`, s = await fetch(e, { method: "POST" });
|
|
3019
3447
|
if (!s.ok) {
|
|
3020
3448
|
const r = await s.text().catch(() => "");
|
|
3021
3449
|
throw new Error(
|
|
@@ -3024,7 +3452,7 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3024
3452
|
}
|
|
3025
3453
|
return await s.json();
|
|
3026
3454
|
}
|
|
3027
|
-
return await a(this, c,
|
|
3455
|
+
return await a(this, c, d).call(this, "POST", `${U}/progress/${t}/abort`);
|
|
3028
3456
|
}
|
|
3029
3457
|
/**
|
|
3030
3458
|
* Lists all executions for a given component.
|
|
@@ -3039,9 +3467,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3039
3467
|
* @param projectId - Optional project scope.
|
|
3040
3468
|
* @returns Array of execution entities.
|
|
3041
3469
|
*/
|
|
3042
|
-
async listExecutions(
|
|
3470
|
+
async listExecutions(t, e) {
|
|
3043
3471
|
if (this.localServerUrl) {
|
|
3044
|
-
const s =
|
|
3472
|
+
const s = e ? `?projectId=${encodeURIComponent(e)}` : "", r = `${this.localServerUrl}/api/${U}/${t}/progress${s}`, i = await fetch(r);
|
|
3045
3473
|
if (!i.ok) {
|
|
3046
3474
|
const o = await i.text().catch(() => "");
|
|
3047
3475
|
throw new Error(
|
|
@@ -3050,16 +3478,16 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3050
3478
|
}
|
|
3051
3479
|
return await i.json();
|
|
3052
3480
|
}
|
|
3053
|
-
return await a(this, c,
|
|
3481
|
+
return await a(this, c, d).call(this, "GET", `${U}/${t}/progress`, { query: { ...e && { projectId: e } } });
|
|
3054
3482
|
}
|
|
3055
3483
|
/**
|
|
3056
3484
|
* Gets details of a specific execution, including its messages.
|
|
3057
3485
|
* @param executionId - The execution's unique identifier.
|
|
3058
3486
|
* @returns The execution entity with progress and result info.
|
|
3059
3487
|
*/
|
|
3060
|
-
async getExecution(
|
|
3488
|
+
async getExecution(t) {
|
|
3061
3489
|
if (this.localServerUrl) {
|
|
3062
|
-
const
|
|
3490
|
+
const e = `${this.localServerUrl}/api/${U}/progress/${t}`, s = await fetch(e);
|
|
3063
3491
|
if (!s.ok) {
|
|
3064
3492
|
const r = await s.text().catch(() => "");
|
|
3065
3493
|
throw new Error(
|
|
@@ -3068,7 +3496,7 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3068
3496
|
}
|
|
3069
3497
|
return await s.json();
|
|
3070
3498
|
}
|
|
3071
|
-
return await a(this, c,
|
|
3499
|
+
return await a(this, c, d).call(this, "GET", `${U}/progress/${t}`);
|
|
3072
3500
|
}
|
|
3073
3501
|
/**
|
|
3074
3502
|
* Subscribes to real-time execution progress via WebSocket.
|
|
@@ -3076,19 +3504,36 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3076
3504
|
* @param executionId - The execution's unique identifier.
|
|
3077
3505
|
* @param onUpdateCallback - Callback invoked on each progress/result event.
|
|
3078
3506
|
*/
|
|
3079
|
-
async onExecutionProgress(
|
|
3080
|
-
const s = this.localServerUrl ?? this.wsUrl, r = await
|
|
3507
|
+
async onExecutionProgress(t, e) {
|
|
3508
|
+
const s = this.localServerUrl ?? this.wsUrl, r = await ut(s, {
|
|
3081
3509
|
auth: { accessToken: this.accessToken },
|
|
3082
3510
|
transports: ["websocket"]
|
|
3083
3511
|
});
|
|
3084
3512
|
r.on("connect", function() {
|
|
3085
|
-
r.emit("executionSubscription", JSON.stringify({ executionId:
|
|
3086
|
-
|
|
3513
|
+
r.emit("executionSubscription", JSON.stringify({ executionId: t })), r.on("execution", (i) => {
|
|
3514
|
+
e(i);
|
|
3087
3515
|
});
|
|
3088
3516
|
}), r.on("connect_error", function(i) {
|
|
3089
3517
|
console.log(i);
|
|
3090
3518
|
});
|
|
3091
3519
|
}
|
|
3520
|
+
// ─── History & Recipes ───────────────────────────────────────────
|
|
3521
|
+
/**
|
|
3522
|
+
* A project's history of connected documents (Revit models, AutoCAD
|
|
3523
|
+
* drawings…): their version timelines and their change requests. See
|
|
3524
|
+
* `src/core/history.ts` — this surface is the only supported way to read
|
|
3525
|
+
* or write it; the storage underneath is private and will move.
|
|
3526
|
+
*/
|
|
3527
|
+
history(t) {
|
|
3528
|
+
return new Xs(this, t);
|
|
3529
|
+
}
|
|
3530
|
+
/**
|
|
3531
|
+
* The recipe registry and runner: scripts that write change requests in a
|
|
3532
|
+
* native application's language. See `src/core/recipes.ts`.
|
|
3533
|
+
*/
|
|
3534
|
+
get recipes() {
|
|
3535
|
+
return l(this, pt) ?? b(this, pt, new Zs(this)), l(this, pt);
|
|
3536
|
+
}
|
|
3092
3537
|
// ─── Hidden Files ────────────────────────────────────────────────
|
|
3093
3538
|
/**
|
|
3094
3539
|
* Creates a hidden file attached to a parent item (e.g., dependencies, assets).
|
|
@@ -3099,9 +3544,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3099
3544
|
* letters, digits and `:._-`, starting with a letter or digit.
|
|
3100
3545
|
* @returns The hidden file ID.
|
|
3101
3546
|
*/
|
|
3102
|
-
async createHiddenFile(
|
|
3547
|
+
async createHiddenFile(t, e, s) {
|
|
3103
3548
|
const r = new FormData();
|
|
3104
|
-
return r.append("file",
|
|
3549
|
+
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
3550
|
body: r
|
|
3106
3551
|
});
|
|
3107
3552
|
}
|
|
@@ -3115,11 +3560,11 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3115
3560
|
* applies to every file in the batch.
|
|
3116
3561
|
* @returns One result per uploaded file, in order, each with its hidden file ID.
|
|
3117
3562
|
*/
|
|
3118
|
-
async createHiddenFilesBatch(
|
|
3563
|
+
async createHiddenFilesBatch(t, e, s) {
|
|
3119
3564
|
const r = new FormData();
|
|
3120
|
-
for (const i of
|
|
3565
|
+
for (const i of t)
|
|
3121
3566
|
r.append("files", i);
|
|
3122
|
-
return r.append("parentItemId",
|
|
3567
|
+
return r.append("parentItemId", e), s != null && r.append("tag", s), await a(this, c, d).call(this, "POST", `${m}/${B}/batch`, {
|
|
3123
3568
|
body: r
|
|
3124
3569
|
});
|
|
3125
3570
|
}
|
|
@@ -3127,22 +3572,22 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3127
3572
|
* Deletes a hidden file by its ID.
|
|
3128
3573
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3129
3574
|
*/
|
|
3130
|
-
async deleteHiddenFile(
|
|
3131
|
-
return await a(this, c,
|
|
3575
|
+
async deleteHiddenFile(t) {
|
|
3576
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${B}/${t}`);
|
|
3132
3577
|
}
|
|
3133
3578
|
/**
|
|
3134
3579
|
* Gets metadata for a hidden file.
|
|
3135
3580
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3136
3581
|
*/
|
|
3137
|
-
async getHiddenFile(
|
|
3138
|
-
return await a(this, c,
|
|
3582
|
+
async getHiddenFile(t) {
|
|
3583
|
+
return await a(this, c, d).call(this, "GET", `${m}/${B}/${t}`);
|
|
3139
3584
|
}
|
|
3140
3585
|
/**
|
|
3141
3586
|
* Downloads a hidden file's content. Returns the raw fetch Response.
|
|
3142
3587
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3143
3588
|
*/
|
|
3144
|
-
async downloadHiddenFile(
|
|
3145
|
-
return await a(this, c,
|
|
3589
|
+
async downloadHiddenFile(t) {
|
|
3590
|
+
return await a(this, c, D).call(this, `${m}/${B}/${t}/download`);
|
|
3146
3591
|
}
|
|
3147
3592
|
/**
|
|
3148
3593
|
* Mints a short-lived presigned URL for a hidden file so the browser can
|
|
@@ -3161,8 +3606,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3161
3606
|
* @returns `{ url, expiresAt }` — `url` is the presigned GET URL, `expiresAt`
|
|
3162
3607
|
* an ISO timestamp when it stops working.
|
|
3163
3608
|
*/
|
|
3164
|
-
async getHiddenFileSignedUrl(
|
|
3165
|
-
return await a(this, c,
|
|
3609
|
+
async getHiddenFileSignedUrl(t, e) {
|
|
3610
|
+
return await a(this, c, d).call(this, "GET", `${m}/${B}/${t}/signed-url`, { ...e != null && { query: { expiresIn: e } } });
|
|
3166
3611
|
}
|
|
3167
3612
|
/**
|
|
3168
3613
|
* Batch variant of {@link getHiddenFileSignedUrl}. Mints presigned URLs for
|
|
@@ -3182,11 +3627,11 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3182
3627
|
* @param expiresIn - Desired URL lifetime in seconds (60–3600). Defaults to
|
|
3183
3628
|
* 900 (15 min) server-side; values are clamped to that range.
|
|
3184
3629
|
*/
|
|
3185
|
-
async getHiddenFileSignedUrlsBatch(
|
|
3186
|
-
return await a(this, c,
|
|
3630
|
+
async getHiddenFileSignedUrlsBatch(t, e) {
|
|
3631
|
+
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
3632
|
body: JSON.stringify({
|
|
3188
3633
|
hiddenFileIds: s,
|
|
3189
|
-
...
|
|
3634
|
+
...e != null && { expiresIn: e }
|
|
3190
3635
|
}),
|
|
3191
3636
|
contentType: "application/json"
|
|
3192
3637
|
})).results);
|
|
@@ -3198,15 +3643,15 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3198
3643
|
* tagged listing comes back in creation order.
|
|
3199
3644
|
* @returns Array of hidden file entities.
|
|
3200
3645
|
*/
|
|
3201
|
-
async getHiddenFilesByParent(
|
|
3202
|
-
return await a(this, c,
|
|
3646
|
+
async getHiddenFilesByParent(t, e) {
|
|
3647
|
+
return await a(this, c, d).call(this, "GET", `${m}/${t}/${B}`, { ...e != null && { query: { tag: e } } });
|
|
3203
3648
|
}
|
|
3204
3649
|
/**
|
|
3205
3650
|
* Deletes all hidden files attached to a parent item.
|
|
3206
3651
|
* @param parentFileId - The parent item's unique identifier.
|
|
3207
3652
|
*/
|
|
3208
|
-
async deleteHiddenFilesByParent(
|
|
3209
|
-
return await a(this, c,
|
|
3653
|
+
async deleteHiddenFilesByParent(t) {
|
|
3654
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}/${B}`);
|
|
3210
3655
|
}
|
|
3211
3656
|
// ─── Icons ───────────────────────────────────────────────────────
|
|
3212
3657
|
/**
|
|
@@ -3216,9 +3661,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3216
3661
|
* @param icon - The icon image file (File in browsers, Blob in Node.js).
|
|
3217
3662
|
* @returns The updated item with `iconFileId` and `iconMimeType` set.
|
|
3218
3663
|
*/
|
|
3219
|
-
async uploadItemIcon(
|
|
3664
|
+
async uploadItemIcon(t, e) {
|
|
3220
3665
|
const s = new FormData();
|
|
3221
|
-
return s.append("icon",
|
|
3666
|
+
return s.append("icon", e), await a(this, c, d).call(this, "PUT", `${m}/${t}/icon`, {
|
|
3222
3667
|
body: s
|
|
3223
3668
|
});
|
|
3224
3669
|
}
|
|
@@ -3227,16 +3672,16 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3227
3672
|
* @param itemId - The item's unique identifier.
|
|
3228
3673
|
* @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
|
|
3229
3674
|
*/
|
|
3230
|
-
async getItemIcon(
|
|
3231
|
-
return await a(this, c,
|
|
3675
|
+
async getItemIcon(t) {
|
|
3676
|
+
return await a(this, c, D).call(this, `${m}/${t}/icon`);
|
|
3232
3677
|
}
|
|
3233
3678
|
/**
|
|
3234
3679
|
* Removes the icon from an item.
|
|
3235
3680
|
* @param itemId - The item's unique identifier.
|
|
3236
3681
|
* @returns The updated item with icon fields removed.
|
|
3237
3682
|
*/
|
|
3238
|
-
async removeItemIcon(
|
|
3239
|
-
return await a(this, c,
|
|
3683
|
+
async removeItemIcon(t) {
|
|
3684
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${t}/icon`);
|
|
3240
3685
|
}
|
|
3241
3686
|
// ─── General Item Operations ─────────────────────────────────────
|
|
3242
3687
|
/**
|
|
@@ -3245,9 +3690,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3245
3690
|
* @param params - New name and/or new folder ID.
|
|
3246
3691
|
* @returns The updated item.
|
|
3247
3692
|
*/
|
|
3248
|
-
async updateItem(
|
|
3249
|
-
return await a(this, c,
|
|
3250
|
-
body: JSON.stringify(
|
|
3693
|
+
async updateItem(t, e) {
|
|
3694
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
|
|
3695
|
+
body: JSON.stringify(e),
|
|
3251
3696
|
contentType: "application/json"
|
|
3252
3697
|
});
|
|
3253
3698
|
}
|
|
@@ -3261,9 +3706,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3261
3706
|
* @param metadata - Optional free-JSON metadata to store on the new version.
|
|
3262
3707
|
* @returns The created version.
|
|
3263
3708
|
*/
|
|
3264
|
-
async createVersion(
|
|
3709
|
+
async createVersion(t, e, s, r, i) {
|
|
3265
3710
|
const o = new FormData();
|
|
3266
|
-
return o.append("file",
|
|
3711
|
+
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
3712
|
}
|
|
3268
3713
|
/**
|
|
3269
3714
|
* Lists versions of an item. Pass `archived: true` to fetch only archived
|
|
@@ -3272,8 +3717,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3272
3717
|
* @param params - Optional `{ archived }` filter.
|
|
3273
3718
|
* @returns Array of versions, sorted by creation date descending.
|
|
3274
3719
|
*/
|
|
3275
|
-
async listVersions(
|
|
3276
|
-
return await a(this, c,
|
|
3720
|
+
async listVersions(t, e = {}) {
|
|
3721
|
+
return await a(this, c, d).call(this, "GET", `${m}/${encodeURIComponent(t)}/versions`, { query: e });
|
|
3277
3722
|
}
|
|
3278
3723
|
/**
|
|
3279
3724
|
* Batch variant of {@link listVersions}. Lists the versions of many items in
|
|
@@ -3290,9 +3735,9 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3290
3735
|
* @param itemIds - The items whose versions to list.
|
|
3291
3736
|
* @param params - Optional `{ archived }` filter, applied to every item.
|
|
3292
3737
|
*/
|
|
3293
|
-
async listVersionsBatch(
|
|
3294
|
-
const { archived: s } =
|
|
3295
|
-
return await a(this, c,
|
|
3738
|
+
async listVersionsBatch(t, e = {}) {
|
|
3739
|
+
const { archived: s } = e;
|
|
3740
|
+
return await a(this, c, lt).call(this, t, async (r) => (await a(this, c, d).call(this, "POST", `${m}/batch/versions`, {
|
|
3296
3741
|
body: JSON.stringify({
|
|
3297
3742
|
itemIds: r,
|
|
3298
3743
|
...s !== void 0 && { archived: s }
|
|
@@ -3309,8 +3754,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3309
3754
|
* @param versionTag - The version's tag (e.g. "v2").
|
|
3310
3755
|
* @returns The archived version.
|
|
3311
3756
|
*/
|
|
3312
|
-
async archiveVersion(
|
|
3313
|
-
return await a(this, c,
|
|
3757
|
+
async archiveVersion(t, e) {
|
|
3758
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/archive`);
|
|
3314
3759
|
}
|
|
3315
3760
|
/**
|
|
3316
3761
|
* Recovers a previously archived version, restoring it to the active list.
|
|
@@ -3318,8 +3763,8 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3318
3763
|
* @param versionTag - The version's tag (e.g. "v2").
|
|
3319
3764
|
* @returns The recovered version.
|
|
3320
3765
|
*/
|
|
3321
|
-
async recoverVersion(
|
|
3322
|
-
return await a(this, c,
|
|
3766
|
+
async recoverVersion(t, e) {
|
|
3767
|
+
return await a(this, c, d).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/recover`);
|
|
3323
3768
|
}
|
|
3324
3769
|
/**
|
|
3325
3770
|
* Permanently deletes a version, including its file in object storage.
|
|
@@ -3327,55 +3772,55 @@ return main;`)(...h), y = (m == null ? void 0 : m.componentDefinition) ?? m;
|
|
|
3327
3772
|
* @param itemId - The item's unique identifier.
|
|
3328
3773
|
* @param versionTag - The version's tag (e.g. "v2").
|
|
3329
3774
|
*/
|
|
3330
|
-
async deleteVersion(
|
|
3331
|
-
return await a(this, c,
|
|
3775
|
+
async deleteVersion(t, e) {
|
|
3776
|
+
return await a(this, c, d).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
|
|
3332
3777
|
}
|
|
3333
3778
|
};
|
|
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:
|
|
3779
|
+
c = new WeakSet(), te = function(t) {
|
|
3780
|
+
return `${this.apiUrl}/${t}`;
|
|
3781
|
+
}, d = async function(t, e, s) {
|
|
3782
|
+
const { body: r, query: i, contentType: o, retries: h, responseType: u, retryAttempt: f } = s || {}, y = a(this, c, te).call(this, e), w = a(this, c, Je).call(this, i), R = await this.resolveAccessToken(), Qe = {
|
|
3783
|
+
...w,
|
|
3784
|
+
...this.useBearer ? {} : { accessToken: R }
|
|
3340
3785
|
};
|
|
3341
3786
|
try {
|
|
3342
|
-
const
|
|
3343
|
-
y + "?" + new URLSearchParams(
|
|
3787
|
+
const I = await fetch(
|
|
3788
|
+
y + "?" + new URLSearchParams(Qe).toString(),
|
|
3344
3789
|
{
|
|
3345
|
-
method:
|
|
3790
|
+
method: t,
|
|
3346
3791
|
headers: {
|
|
3347
3792
|
Accept: "application/json",
|
|
3348
3793
|
...o && { "Content-Type": o },
|
|
3349
|
-
...this.useBearer && { Authorization: `Bearer ${
|
|
3794
|
+
...this.useBearer && { Authorization: `Bearer ${R}` }
|
|
3350
3795
|
},
|
|
3351
3796
|
...r && { body: r }
|
|
3352
3797
|
}
|
|
3353
3798
|
);
|
|
3354
|
-
if (!
|
|
3355
|
-
const
|
|
3356
|
-
throw new
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3799
|
+
if (!I.ok) {
|
|
3800
|
+
const K = await I.text().then((gt) => gt).catch(() => "");
|
|
3801
|
+
throw new fe(
|
|
3802
|
+
I.status,
|
|
3803
|
+
I.statusText,
|
|
3804
|
+
K,
|
|
3805
|
+
an(I)
|
|
3361
3806
|
);
|
|
3362
3807
|
}
|
|
3363
|
-
return
|
|
3808
|
+
return u === "blob" ? await I.blob() : I.json().then((K) => K).catch(() => {
|
|
3364
3809
|
});
|
|
3365
|
-
} catch (
|
|
3366
|
-
const
|
|
3367
|
-
if (
|
|
3368
|
-
const
|
|
3369
|
-
return await
|
|
3810
|
+
} catch (I) {
|
|
3811
|
+
const K = h ?? this.retries;
|
|
3812
|
+
if (K > 0 && cn(I)) {
|
|
3813
|
+
const gt = f ?? 0;
|
|
3814
|
+
return await on(hn(I, gt)), await a(this, c, d).call(this, t, e, {
|
|
3370
3815
|
...s,
|
|
3371
|
-
retries:
|
|
3372
|
-
retryAttempt:
|
|
3816
|
+
retries: K - 1,
|
|
3817
|
+
retryAttempt: gt + 1
|
|
3373
3818
|
});
|
|
3374
3819
|
}
|
|
3375
|
-
throw
|
|
3820
|
+
throw I;
|
|
3376
3821
|
}
|
|
3377
|
-
},
|
|
3378
|
-
const { query: s } =
|
|
3822
|
+
}, D = async function(t, e) {
|
|
3823
|
+
const { query: s } = e || {}, r = a(this, c, te).call(this, t), i = await this.resolveAccessToken(), o = {
|
|
3379
3824
|
...s,
|
|
3380
3825
|
...this.useBearer ? {} : { accessToken: i }
|
|
3381
3826
|
};
|
|
@@ -3388,58 +3833,58 @@ c = new WeakSet(), Ne = function(e) {
|
|
|
3388
3833
|
}
|
|
3389
3834
|
}
|
|
3390
3835
|
);
|
|
3391
|
-
},
|
|
3392
|
-
if (!
|
|
3836
|
+
}, pt = new WeakMap(), lt = async function(t, e) {
|
|
3837
|
+
if (!t.length) return [];
|
|
3393
3838
|
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,
|
|
3839
|
+
for (let i = 0; i < t.length; i += Ae)
|
|
3840
|
+
s.push(t.slice(i, i + Ae));
|
|
3841
|
+
return (await Promise.all(s.map(e))).flat();
|
|
3842
|
+
}, It = async function(t, e) {
|
|
3843
|
+
const { versionTag: s, withDraft: r } = e || {};
|
|
3844
|
+
return await a(this, c, D).call(this, `${m}/${t}/download`, {
|
|
3400
3845
|
query: {
|
|
3401
3846
|
...s && { versionTag: s },
|
|
3402
3847
|
...r && { withDraft: r }
|
|
3403
3848
|
}
|
|
3404
3849
|
});
|
|
3405
|
-
},
|
|
3406
|
-
const { name: r, versionTag: i, parentFolderId: o, projectId: h, file:
|
|
3407
|
-
return y.append("file",
|
|
3850
|
+
}, xt = async function(t, e, s) {
|
|
3851
|
+
const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: u, metadata: f } = t, y = new FormData();
|
|
3852
|
+
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
3853
|
body: y
|
|
3409
3854
|
});
|
|
3410
|
-
},
|
|
3411
|
-
const { name: r, versionTag: i, parentFolderId: o, file: h, metadata:
|
|
3412
|
-
let
|
|
3855
|
+
}, ee = async function(t, e, s) {
|
|
3856
|
+
const { name: r, versionTag: i, parentFolderId: o, file: h, metadata: u } = e;
|
|
3857
|
+
let f, y;
|
|
3413
3858
|
if (h) {
|
|
3414
|
-
const
|
|
3415
|
-
|
|
3416
|
-
body:
|
|
3859
|
+
const w = new FormData();
|
|
3860
|
+
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`, {
|
|
3861
|
+
body: w
|
|
3417
3862
|
});
|
|
3418
3863
|
}
|
|
3419
3864
|
if (r || o) {
|
|
3420
|
-
const
|
|
3865
|
+
const w = {
|
|
3421
3866
|
...r && { name: r },
|
|
3422
3867
|
...o && { folderId: o }
|
|
3423
|
-
},
|
|
3424
|
-
|
|
3425
|
-
body:
|
|
3868
|
+
}, R = JSON.stringify(w);
|
|
3869
|
+
f = await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
|
|
3870
|
+
body: R,
|
|
3426
3871
|
contentType: "application/json"
|
|
3427
3872
|
});
|
|
3428
3873
|
}
|
|
3429
|
-
return { item:
|
|
3430
|
-
},
|
|
3431
|
-
const { showVersions: s = !1 } =
|
|
3432
|
-
return await a(this, c,
|
|
3874
|
+
return { item: f, version: y };
|
|
3875
|
+
}, se = async function(t, e) {
|
|
3876
|
+
const { showVersions: s = !1 } = e || {};
|
|
3877
|
+
return await a(this, c, d).call(this, "GET", `${m}/${t}`, {
|
|
3433
3878
|
query: { showVersions: s }
|
|
3434
3879
|
});
|
|
3435
|
-
},
|
|
3436
|
-
return
|
|
3437
|
-
(
|
|
3880
|
+
}, Je = function(t) {
|
|
3881
|
+
return t && Object.entries(t).filter(([, e]) => e !== void 0).reduce(
|
|
3882
|
+
(e, [s, r]) => (e[s] = r, e),
|
|
3438
3883
|
{}
|
|
3439
3884
|
);
|
|
3440
3885
|
};
|
|
3441
|
-
let
|
|
3442
|
-
function
|
|
3886
|
+
let Zt = pe;
|
|
3887
|
+
function ln() {
|
|
3443
3888
|
if (typeof window > "u" || window.parent === window)
|
|
3444
3889
|
throw new Error(
|
|
3445
3890
|
"client.channel only works inside a That Open app, which runs in an iframe of the platform."
|
|
@@ -3447,165 +3892,165 @@ function Ss() {
|
|
|
3447
3892
|
return {
|
|
3448
3893
|
post: (n) => window.parent.postMessage(n, "*"),
|
|
3449
3894
|
listen: (n) => {
|
|
3450
|
-
const
|
|
3451
|
-
|
|
3895
|
+
const t = (e) => {
|
|
3896
|
+
e.source === window.parent && n(e.data);
|
|
3452
3897
|
};
|
|
3453
|
-
return window.addEventListener("message",
|
|
3898
|
+
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
3454
3899
|
}
|
|
3455
3900
|
};
|
|
3456
3901
|
}
|
|
3457
|
-
const
|
|
3458
|
-
function
|
|
3902
|
+
const ne = "channel:", un = 1e4;
|
|
3903
|
+
function $t(n) {
|
|
3459
3904
|
try {
|
|
3460
3905
|
n();
|
|
3461
|
-
} catch (
|
|
3462
|
-
console.error("[channel] a listener threw:",
|
|
3906
|
+
} catch (t) {
|
|
3907
|
+
console.error("[channel] a listener threw:", t);
|
|
3463
3908
|
}
|
|
3464
3909
|
}
|
|
3465
|
-
var
|
|
3466
|
-
class
|
|
3467
|
-
constructor(
|
|
3468
|
-
_(this,
|
|
3469
|
-
_(this,
|
|
3910
|
+
var q, k, O, Q, Z, tt, S, re, ie, z;
|
|
3911
|
+
class Ye {
|
|
3912
|
+
constructor(t, e) {
|
|
3913
|
+
_(this, S);
|
|
3914
|
+
_(this, q, !1);
|
|
3470
3915
|
_(this, k, []);
|
|
3471
|
-
_(this,
|
|
3472
|
-
_(this,
|
|
3473
|
-
_(this,
|
|
3474
|
-
_(this,
|
|
3475
|
-
this.transport =
|
|
3916
|
+
_(this, O, []);
|
|
3917
|
+
_(this, Q, /* @__PURE__ */ new Set());
|
|
3918
|
+
_(this, Z, /* @__PURE__ */ new Set());
|
|
3919
|
+
_(this, tt, /* @__PURE__ */ new Set());
|
|
3920
|
+
this.transport = t, this.controls = e;
|
|
3476
3921
|
}
|
|
3477
3922
|
/** Whether the platform has confirmed this tab is in the room. */
|
|
3478
3923
|
get joined() {
|
|
3479
|
-
return
|
|
3924
|
+
return l(this, q);
|
|
3480
3925
|
}
|
|
3481
3926
|
/** Who else is in the room right now, as the platform last reported. */
|
|
3482
3927
|
get peers() {
|
|
3483
|
-
return
|
|
3928
|
+
return l(this, k);
|
|
3484
3929
|
}
|
|
3485
3930
|
/**
|
|
3486
3931
|
* Enters the room. Resolves when the platform confirms; rejects if it
|
|
3487
3932
|
* refuses or does not answer in time. Joining twice is harmless.
|
|
3488
3933
|
*/
|
|
3489
3934
|
join() {
|
|
3490
|
-
return
|
|
3935
|
+
return l(this, q) ? Promise.resolve() : a(this, S, re).call(this, "joined", this.controls.join);
|
|
3491
3936
|
}
|
|
3492
3937
|
/** Leaves the room. Handlers stay registered, so `join()` resumes them. */
|
|
3493
3938
|
leave() {
|
|
3494
|
-
return !
|
|
3939
|
+
return !l(this, q) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S, re).call(this, "left", this.controls.leave);
|
|
3495
3940
|
}
|
|
3496
3941
|
/** Fires when `joined` or `peers` changes. Returns a function that stops it. */
|
|
3497
|
-
onChange(
|
|
3498
|
-
return
|
|
3942
|
+
onChange(t) {
|
|
3943
|
+
return l(this, Q).add(t), () => void l(this, Q).delete(t);
|
|
3499
3944
|
}
|
|
3500
|
-
onPeerJoined(
|
|
3501
|
-
return
|
|
3945
|
+
onPeerJoined(t) {
|
|
3946
|
+
return l(this, Z).add(t), () => void l(this, Z).delete(t);
|
|
3502
3947
|
}
|
|
3503
|
-
onPeerLeft(
|
|
3504
|
-
return
|
|
3948
|
+
onPeerLeft(t) {
|
|
3949
|
+
return l(this, tt).add(t), () => void l(this, tt).delete(t);
|
|
3505
3950
|
}
|
|
3506
3951
|
/** @internal */
|
|
3507
3952
|
applyJoined() {
|
|
3508
|
-
|
|
3953
|
+
b(this, q, !0), a(this, S, ie).call(this, "joined"), a(this, S, z).call(this);
|
|
3509
3954
|
}
|
|
3510
3955
|
/** @internal */
|
|
3511
3956
|
applyLeft() {
|
|
3512
|
-
|
|
3957
|
+
b(this, q, !1), b(this, k, []), a(this, S, ie).call(this, "left"), a(this, S, z).call(this);
|
|
3513
3958
|
}
|
|
3514
3959
|
/** @internal */
|
|
3515
|
-
applyPeers(
|
|
3516
|
-
|
|
3960
|
+
applyPeers(t) {
|
|
3961
|
+
b(this, k, t), a(this, S, z).call(this);
|
|
3517
3962
|
}
|
|
3518
3963
|
/** @internal */
|
|
3519
|
-
applyPeerJoined(
|
|
3520
|
-
!
|
|
3964
|
+
applyPeerJoined(t) {
|
|
3965
|
+
!l(this, q) || l(this, k).some((e) => e.from === t.from) || (b(this, k, [...l(this, k), t]), l(this, Z).forEach((e) => $t(() => e(t))), a(this, S, z).call(this));
|
|
3521
3966
|
}
|
|
3522
3967
|
/** @internal */
|
|
3523
|
-
applyPeerLeft(
|
|
3524
|
-
const
|
|
3525
|
-
|
|
3968
|
+
applyPeerLeft(t) {
|
|
3969
|
+
const e = l(this, k).find((s) => s.from === t);
|
|
3970
|
+
e && (b(this, k, l(this, k).filter((s) => s.from !== t)), l(this, tt).forEach((s) => $t(() => s(e))), a(this, S, z).call(this));
|
|
3526
3971
|
}
|
|
3527
3972
|
/** @internal */
|
|
3528
|
-
failPending(
|
|
3529
|
-
const
|
|
3530
|
-
return
|
|
3531
|
-
clearTimeout(s.timer), s.reject(
|
|
3532
|
-
}),
|
|
3973
|
+
failPending(t) {
|
|
3974
|
+
const e = l(this, O);
|
|
3975
|
+
return b(this, O, []), e.forEach((s) => {
|
|
3976
|
+
clearTimeout(s.timer), s.reject(t);
|
|
3977
|
+
}), e.length > 0;
|
|
3533
3978
|
}
|
|
3534
|
-
post(
|
|
3535
|
-
this.transport.post(
|
|
3979
|
+
post(t) {
|
|
3980
|
+
this.transport.post(t);
|
|
3536
3981
|
}
|
|
3537
3982
|
}
|
|
3538
|
-
|
|
3983
|
+
q = new WeakMap(), k = new WeakMap(), O = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), S = new WeakSet(), re = function(t, e) {
|
|
3539
3984
|
return new Promise((s, r) => {
|
|
3540
3985
|
const i = {
|
|
3541
|
-
want:
|
|
3986
|
+
want: t,
|
|
3542
3987
|
resolve: s,
|
|
3543
3988
|
reject: r,
|
|
3544
3989
|
timer: setTimeout(() => {
|
|
3545
|
-
|
|
3990
|
+
b(this, O, l(this, O).filter((o) => o !== i)), r(
|
|
3546
3991
|
new Error(
|
|
3547
|
-
`The platform did not confirm ${
|
|
3992
|
+
`The platform did not confirm ${t === "joined" ? "joining" : "leaving"} in time.`
|
|
3548
3993
|
)
|
|
3549
3994
|
);
|
|
3550
|
-
},
|
|
3995
|
+
}, un)
|
|
3551
3996
|
};
|
|
3552
|
-
|
|
3997
|
+
l(this, O).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
|
|
3553
3998
|
});
|
|
3554
|
-
},
|
|
3555
|
-
const
|
|
3556
|
-
|
|
3999
|
+
}, ie = function(t) {
|
|
4000
|
+
const e = l(this, O).filter((s) => s.want === t);
|
|
4001
|
+
b(this, O, l(this, O).filter((s) => s.want !== t)), e.forEach((s) => {
|
|
3557
4002
|
clearTimeout(s.timer), s.resolve();
|
|
3558
4003
|
});
|
|
3559
|
-
},
|
|
3560
|
-
|
|
4004
|
+
}, z = function() {
|
|
4005
|
+
l(this, Q).forEach((t) => $t(t));
|
|
3561
4006
|
};
|
|
3562
|
-
var
|
|
3563
|
-
class
|
|
4007
|
+
var et;
|
|
4008
|
+
class dn extends Ye {
|
|
3564
4009
|
/** @internal Use `client.channel.collab()`. */
|
|
3565
|
-
constructor(
|
|
3566
|
-
super(
|
|
4010
|
+
constructor(e) {
|
|
4011
|
+
super(e, {
|
|
3567
4012
|
join: { action: "joinCollab" },
|
|
3568
4013
|
leave: { action: "leaveCollab" }
|
|
3569
4014
|
});
|
|
3570
|
-
_(this,
|
|
4015
|
+
_(this, et, /* @__PURE__ */ new Map());
|
|
3571
4016
|
}
|
|
3572
4017
|
/**
|
|
3573
4018
|
* Listens for an event other tabs send. Any number of listeners per event.
|
|
3574
4019
|
* @returns a function that removes the listener.
|
|
3575
4020
|
*/
|
|
3576
|
-
on(
|
|
3577
|
-
const r =
|
|
3578
|
-
return r.add(s),
|
|
4021
|
+
on(e, s) {
|
|
4022
|
+
const r = l(this, et).get(e) ?? /* @__PURE__ */ new Set();
|
|
4023
|
+
return r.add(s), l(this, et).set(e, r), () => void r.delete(s);
|
|
3579
4024
|
}
|
|
3580
4025
|
/**
|
|
3581
4026
|
* Sends an event to the other tabs in the room. Does nothing while this tab
|
|
3582
4027
|
* is not in it, matching what the platform does with a message from outside.
|
|
3583
4028
|
*/
|
|
3584
|
-
send(
|
|
3585
|
-
if (
|
|
3586
|
-
throw new Error(`Message types starting with '${
|
|
3587
|
-
this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type:
|
|
4029
|
+
send(e, s) {
|
|
4030
|
+
if (e.startsWith(ne))
|
|
4031
|
+
throw new Error(`Message types starting with '${ne}' are reserved.`);
|
|
4032
|
+
this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: e, payload: s } });
|
|
3588
4033
|
}
|
|
3589
|
-
accepts(
|
|
3590
|
-
return
|
|
4034
|
+
accepts(e) {
|
|
4035
|
+
return e === void 0 || e === "collab";
|
|
3591
4036
|
}
|
|
3592
|
-
async handle(
|
|
3593
|
-
const s =
|
|
4037
|
+
async handle(e) {
|
|
4038
|
+
const s = l(this, et).get(e.type);
|
|
3594
4039
|
if (!(s != null && s.size)) return { handled: !1 };
|
|
3595
|
-
const r =
|
|
3596
|
-
return s.forEach((i) =>
|
|
4040
|
+
const r = We(e);
|
|
4041
|
+
return s.forEach((i) => $t(() => i(e.payload, r))), { handled: !0 };
|
|
3597
4042
|
}
|
|
3598
4043
|
}
|
|
3599
|
-
|
|
3600
|
-
var
|
|
3601
|
-
class
|
|
4044
|
+
et = new WeakMap();
|
|
4045
|
+
var M;
|
|
4046
|
+
class fn extends Ye {
|
|
3602
4047
|
/** @internal Use `client.channel.external(kind)`. */
|
|
3603
|
-
constructor(
|
|
3604
|
-
super(
|
|
4048
|
+
constructor(e, s) {
|
|
4049
|
+
super(e, {
|
|
3605
4050
|
join: { action: "joinExternal", kind: s },
|
|
3606
4051
|
leave: { action: "leaveExternal", kind: s }
|
|
3607
4052
|
});
|
|
3608
|
-
_(this,
|
|
4053
|
+
_(this, M, /* @__PURE__ */ new Map());
|
|
3609
4054
|
this.kind = s;
|
|
3610
4055
|
}
|
|
3611
4056
|
/**
|
|
@@ -3618,25 +4063,25 @@ class Cs extends mt {
|
|
|
3618
4063
|
* would both try to answer.
|
|
3619
4064
|
* @returns a function that removes the handler.
|
|
3620
4065
|
*/
|
|
3621
|
-
on(
|
|
3622
|
-
if (
|
|
4066
|
+
on(e, s) {
|
|
4067
|
+
if (l(this, M).has(e))
|
|
3623
4068
|
throw new Error(
|
|
3624
|
-
`"${
|
|
4069
|
+
`"${e}" already has a handler in this room. Remove it first.`
|
|
3625
4070
|
);
|
|
3626
|
-
return
|
|
4071
|
+
return l(this, M).set(e, s), () => void l(this, M).delete(e);
|
|
3627
4072
|
}
|
|
3628
|
-
accepts(
|
|
3629
|
-
return
|
|
4073
|
+
accepts(e, s) {
|
|
4074
|
+
return e !== void 0 && e !== "external" ? !1 : this.kind === void 0 || e === void 0 || this.kind === s;
|
|
3630
4075
|
}
|
|
3631
4076
|
/** @internal Whether this room has any handler at all. */
|
|
3632
4077
|
get hasHandlers() {
|
|
3633
|
-
return
|
|
4078
|
+
return l(this, M).size > 0;
|
|
3634
4079
|
}
|
|
3635
|
-
async handle(
|
|
3636
|
-
const s =
|
|
4080
|
+
async handle(e) {
|
|
4081
|
+
const s = l(this, M).get(e.type);
|
|
3637
4082
|
if (!s) return { handled: !1 };
|
|
3638
4083
|
try {
|
|
3639
|
-
return { handled: !0, value: await s(
|
|
4084
|
+
return { handled: !0, value: await s(e.payload, We(e)) };
|
|
3640
4085
|
} catch (r) {
|
|
3641
4086
|
return {
|
|
3642
4087
|
handled: !0,
|
|
@@ -3645,8 +4090,8 @@ class Cs extends mt {
|
|
|
3645
4090
|
}
|
|
3646
4091
|
}
|
|
3647
4092
|
}
|
|
3648
|
-
|
|
3649
|
-
function
|
|
4093
|
+
M = new WeakMap();
|
|
4094
|
+
function We(n) {
|
|
3650
4095
|
return {
|
|
3651
4096
|
from: n.from,
|
|
3652
4097
|
at: n.at,
|
|
@@ -3654,118 +4099,118 @@ function gt(n) {
|
|
|
3654
4099
|
kind: n.kind
|
|
3655
4100
|
};
|
|
3656
4101
|
}
|
|
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
|
|
4102
|
+
function pn(n) {
|
|
4103
|
+
const t = n;
|
|
4104
|
+
if ((t == null ? void 0 : t.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
|
|
4105
|
+
const e = t.message;
|
|
4106
|
+
return !e || typeof e.type != "string" ? null : {
|
|
4107
|
+
type: e.type,
|
|
4108
|
+
requestId: typeof e.requestId == "string" ? e.requestId : void 0,
|
|
4109
|
+
payload: e.payload,
|
|
4110
|
+
at: typeof e.at == "number" ? e.at : Date.now(),
|
|
4111
|
+
from: typeof e.from == "string" ? e.from : "",
|
|
4112
|
+
scope: e.scope === "collab" || e.scope === "external" ? e.scope : void 0,
|
|
4113
|
+
kind: typeof e.kind == "string" ? e.kind : void 0
|
|
3669
4114
|
};
|
|
3670
4115
|
}
|
|
3671
|
-
var
|
|
3672
|
-
class
|
|
3673
|
-
constructor(
|
|
3674
|
-
_(this,
|
|
3675
|
-
_(this,
|
|
3676
|
-
_(this,
|
|
3677
|
-
_(this,
|
|
3678
|
-
_(this,
|
|
3679
|
-
_(this,
|
|
3680
|
-
|
|
4116
|
+
var W, yt, F, H, G, v, oe, Rt, Ke, Xe, ze, ae;
|
|
4117
|
+
class yn {
|
|
4118
|
+
constructor(t) {
|
|
4119
|
+
_(this, v);
|
|
4120
|
+
_(this, W);
|
|
4121
|
+
_(this, yt);
|
|
4122
|
+
_(this, F);
|
|
4123
|
+
_(this, H, /* @__PURE__ */ new Map());
|
|
4124
|
+
_(this, G, /* @__PURE__ */ new Set());
|
|
4125
|
+
b(this, W, t), b(this, yt, t.listen((e) => void a(this, v, Ke).call(this, e)));
|
|
3681
4126
|
}
|
|
3682
4127
|
/** The collaboration room for this app. Always the same instance. */
|
|
3683
4128
|
collab() {
|
|
3684
|
-
return
|
|
4129
|
+
return l(this, F) ?? b(this, F, new dn(l(this, W))), l(this, F);
|
|
3685
4130
|
}
|
|
3686
4131
|
/**
|
|
3687
4132
|
* The room for commands from this account's external tools of one `kind`
|
|
3688
4133
|
* (`'mcp'`, `'cli'`, `'revit'`…), or from any of them when `kind` is omitted.
|
|
3689
4134
|
* Always the same instance for the same kind.
|
|
3690
4135
|
*/
|
|
3691
|
-
external(
|
|
3692
|
-
const
|
|
3693
|
-
let s =
|
|
3694
|
-
return s || (s = new
|
|
4136
|
+
external(t) {
|
|
4137
|
+
const e = t ?? "";
|
|
4138
|
+
let s = l(this, H).get(e);
|
|
4139
|
+
return s || (s = new fn(l(this, W), t), l(this, H).set(e, s)), s;
|
|
3695
4140
|
}
|
|
3696
4141
|
/** Stops listening. For tests and teardown; an app normally never calls it. */
|
|
3697
4142
|
dispose() {
|
|
3698
|
-
|
|
4143
|
+
l(this, yt).call(this);
|
|
3699
4144
|
}
|
|
3700
4145
|
}
|
|
3701
|
-
|
|
3702
|
-
return [...
|
|
3703
|
-
},
|
|
3704
|
-
if (
|
|
3705
|
-
if (
|
|
3706
|
-
return
|
|
3707
|
-
},
|
|
3708
|
-
const
|
|
3709
|
-
if (
|
|
3710
|
-
if (
|
|
3711
|
-
a(this,
|
|
4146
|
+
W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), H = new WeakMap(), G = new WeakMap(), v = new WeakSet(), oe = function() {
|
|
4147
|
+
return [...l(this, F) ? [l(this, F)] : [], ...l(this, H).values()];
|
|
4148
|
+
}, Rt = function(t, e) {
|
|
4149
|
+
if (t === "collab") return l(this, F);
|
|
4150
|
+
if (t === "external")
|
|
4151
|
+
return l(this, H).get(typeof e == "string" ? e : "");
|
|
4152
|
+
}, Ke = async function(t) {
|
|
4153
|
+
const e = pn(t);
|
|
4154
|
+
if (e) {
|
|
4155
|
+
if (e.type.startsWith(ne)) {
|
|
4156
|
+
a(this, v, Xe).call(this, e);
|
|
3712
4157
|
return;
|
|
3713
4158
|
}
|
|
3714
|
-
await a(this,
|
|
4159
|
+
await a(this, v, ze).call(this, e);
|
|
3715
4160
|
}
|
|
3716
|
-
},
|
|
4161
|
+
}, Xe = function(t) {
|
|
3717
4162
|
var s, r, i;
|
|
3718
|
-
const
|
|
3719
|
-
switch (
|
|
4163
|
+
const e = t.payload ?? {};
|
|
4164
|
+
switch (t.type) {
|
|
3720
4165
|
case "channel:joined":
|
|
3721
|
-
(s = a(this,
|
|
4166
|
+
(s = a(this, v, Rt).call(this, e.scope, e.kind)) == null || s.applyJoined();
|
|
3722
4167
|
break;
|
|
3723
4168
|
case "channel:left":
|
|
3724
|
-
(r = a(this,
|
|
4169
|
+
(r = a(this, v, Rt).call(this, e.scope, e.kind)) == null || r.applyLeft();
|
|
3725
4170
|
break;
|
|
3726
4171
|
case "channel:peers":
|
|
3727
|
-
(i = a(this,
|
|
4172
|
+
(i = a(this, v, Rt).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
|
|
3728
4173
|
break;
|
|
3729
4174
|
case "channel:peer-joined":
|
|
3730
4175
|
case "channel:peer-left": {
|
|
3731
|
-
if (!
|
|
3732
|
-
const o =
|
|
3733
|
-
(h) => h.accepts("external",
|
|
4176
|
+
if (!e.from) break;
|
|
4177
|
+
const o = e.scope === "collab" ? [l(this, F)] : [...l(this, H).values()].filter(
|
|
4178
|
+
(h) => h.accepts("external", e.kind)
|
|
3734
4179
|
);
|
|
3735
4180
|
for (const h of o)
|
|
3736
|
-
|
|
4181
|
+
t.type === "channel:peer-joined" ? h == null || h.applyPeerJoined({ from: e.from, kind: e.kind }) : h == null || h.applyPeerLeft(e.from);
|
|
3737
4182
|
break;
|
|
3738
4183
|
}
|
|
3739
4184
|
case "channel:error": {
|
|
3740
|
-
const o = new Error(String(
|
|
3741
|
-
a(this,
|
|
4185
|
+
const o = new Error(String(t.payload));
|
|
4186
|
+
a(this, v, oe).call(this).map((u) => u.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
|
|
3742
4187
|
break;
|
|
3743
4188
|
}
|
|
3744
4189
|
}
|
|
3745
|
-
},
|
|
3746
|
-
const
|
|
4190
|
+
}, ze = async function(t) {
|
|
4191
|
+
const e = a(this, v, oe).call(this).filter((i) => i.accepts(t.scope, t.kind));
|
|
3747
4192
|
let s = !1;
|
|
3748
|
-
for (const i of
|
|
3749
|
-
const o = await i.handle(
|
|
3750
|
-
o.handled && (s = !0,
|
|
4193
|
+
for (const i of e) {
|
|
4194
|
+
const o = await i.handle(t);
|
|
4195
|
+
o.handled && (s = !0, t.requestId && a(this, v, ae).call(this, t.requestId, o));
|
|
3751
4196
|
}
|
|
3752
|
-
|
|
4197
|
+
t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v, ae).call(this, t.requestId, {
|
|
3753
4198
|
handled: !0,
|
|
3754
|
-
error: `No handler for "${
|
|
4199
|
+
error: `No handler for "${t.type}".`
|
|
3755
4200
|
});
|
|
3756
|
-
},
|
|
3757
|
-
|
|
4201
|
+
}, ae = function(t, e) {
|
|
4202
|
+
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
4203
|
type: "APP_CHANNEL_PUBLISH",
|
|
3759
4204
|
message: {
|
|
3760
|
-
type:
|
|
3761
|
-
requestId:
|
|
3762
|
-
payload:
|
|
4205
|
+
type: e.error === void 0 ? "reply" : "reply-error",
|
|
4206
|
+
requestId: t,
|
|
4207
|
+
payload: e.error === void 0 ? e.value : { error: e.error }
|
|
3763
4208
|
}
|
|
3764
4209
|
}));
|
|
3765
4210
|
};
|
|
3766
|
-
const
|
|
3767
|
-
var
|
|
3768
|
-
const
|
|
4211
|
+
const J = "project", X = "notifications";
|
|
4212
|
+
var st, mt;
|
|
4213
|
+
const ye = class ye extends Zt {
|
|
3769
4214
|
/**
|
|
3770
4215
|
* @param token - A bearer JWT, OR a function returning the current JWT
|
|
3771
4216
|
* (sync or async). When a function is passed, it's invoked before every
|
|
@@ -3774,14 +4219,14 @@ const Ge = class Ge extends $e {
|
|
|
3774
4219
|
* @param props - Optional client configuration. `useBearer` is forced to
|
|
3775
4220
|
* `true` and cannot be overridden.
|
|
3776
4221
|
*/
|
|
3777
|
-
constructor(
|
|
3778
|
-
super(typeof
|
|
3779
|
-
_(this,
|
|
3780
|
-
_(this,
|
|
3781
|
-
typeof
|
|
4222
|
+
constructor(e, s, r) {
|
|
4223
|
+
super(typeof e == "string" ? e : "", s, { ...r, useBearer: !0 });
|
|
4224
|
+
_(this, st);
|
|
4225
|
+
_(this, mt);
|
|
4226
|
+
typeof e == "function" && b(this, st, e);
|
|
3782
4227
|
}
|
|
3783
4228
|
async resolveAccessToken() {
|
|
3784
|
-
return
|
|
4229
|
+
return l(this, st) ? await l(this, st).call(this) : super.resolveAccessToken();
|
|
3785
4230
|
}
|
|
3786
4231
|
/**
|
|
3787
4232
|
* Creates a client from the platform context injected into
|
|
@@ -3789,8 +4234,8 @@ const Ge = class Ge extends $e {
|
|
|
3789
4234
|
* entry point for apps running inside the platform's iframe — the context
|
|
3790
4235
|
* carries a fresh JWT on every navigation.
|
|
3791
4236
|
*/
|
|
3792
|
-
static fromPlatformContext(
|
|
3793
|
-
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new
|
|
4237
|
+
static fromPlatformContext(e) {
|
|
4238
|
+
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new ye(s.accessToken, s.apiUrl, e);
|
|
3794
4239
|
return r.context = s, r;
|
|
3795
4240
|
}
|
|
3796
4241
|
/**
|
|
@@ -3818,7 +4263,7 @@ const Ge = class Ge extends $e {
|
|
|
3818
4263
|
* ```
|
|
3819
4264
|
*/
|
|
3820
4265
|
get channel() {
|
|
3821
|
-
return
|
|
4266
|
+
return l(this, mt) ?? b(this, mt, new yn(ln())), l(this, mt);
|
|
3822
4267
|
}
|
|
3823
4268
|
// ─── Projects (JWT-only backend routes) ──────────────────────────
|
|
3824
4269
|
/**
|
|
@@ -3837,23 +4282,23 @@ const Ge = class Ge extends $e {
|
|
|
3837
4282
|
* ```
|
|
3838
4283
|
*/
|
|
3839
4284
|
async listProjects() {
|
|
3840
|
-
return await this.request("GET",
|
|
4285
|
+
return await this.request("GET", J);
|
|
3841
4286
|
}
|
|
3842
4287
|
/**
|
|
3843
4288
|
* Gets a project by ID. JWT-only — lives here because
|
|
3844
4289
|
* `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
|
|
3845
4290
|
*/
|
|
3846
|
-
async getProject(
|
|
3847
|
-
return await this.request("GET", `${
|
|
4291
|
+
async getProject(e) {
|
|
4292
|
+
return await this.request("GET", `${J}/${e}`);
|
|
3848
4293
|
}
|
|
3849
4294
|
/**
|
|
3850
4295
|
* Gets the full project data (users, roles, files, folders) for a project.
|
|
3851
4296
|
* User data is stripped of sensitive fields server-side.
|
|
3852
4297
|
*/
|
|
3853
|
-
async getProjectData(
|
|
4298
|
+
async getProjectData(e) {
|
|
3854
4299
|
return await this.request(
|
|
3855
4300
|
"GET",
|
|
3856
|
-
`${
|
|
4301
|
+
`${J}/${e}/data`
|
|
3857
4302
|
);
|
|
3858
4303
|
}
|
|
3859
4304
|
// ─── Account ──────────────────────────────────────────────────────
|
|
@@ -3863,8 +4308,8 @@ const Ge = class Ge extends $e {
|
|
|
3863
4308
|
* an `<img src>` — turn the blob into an object URL with
|
|
3864
4309
|
* `URL.createObjectURL(blob)`. Rejects when the account has no avatar.
|
|
3865
4310
|
*/
|
|
3866
|
-
async getAvatar(
|
|
3867
|
-
return await this.request("GET", `account/${
|
|
4311
|
+
async getAvatar(e) {
|
|
4312
|
+
return await this.request("GET", `account/${e}/avatar`, {
|
|
3868
4313
|
responseType: "blob"
|
|
3869
4314
|
});
|
|
3870
4315
|
}
|
|
@@ -3875,20 +4320,20 @@ const Ge = class Ge extends $e {
|
|
|
3875
4320
|
* admin/owner, `'project'` for a role broad grant, `'entity'` for a
|
|
3876
4321
|
* per-entity override, `'none'` for denied.
|
|
3877
4322
|
*/
|
|
3878
|
-
async checkPermission(
|
|
4323
|
+
async checkPermission(e) {
|
|
3879
4324
|
return await this.request(
|
|
3880
4325
|
"GET",
|
|
3881
|
-
`${
|
|
3882
|
-
{ query:
|
|
4326
|
+
`${J}/permissions/check`,
|
|
4327
|
+
{ query: e }
|
|
3883
4328
|
);
|
|
3884
4329
|
}
|
|
3885
4330
|
/**
|
|
3886
4331
|
* Batch variant of {@link checkPermission}. Evaluates multiple checks in a
|
|
3887
4332
|
* single round-trip; results come back in the same order as `checks`.
|
|
3888
4333
|
*/
|
|
3889
|
-
async checkPermissionBatch(
|
|
3890
|
-
return (await this.request("POST", `${
|
|
3891
|
-
body: JSON.stringify({ checks:
|
|
4334
|
+
async checkPermissionBatch(e) {
|
|
4335
|
+
return (await this.request("POST", `${J}/permissions/check/batch`, {
|
|
4336
|
+
body: JSON.stringify({ checks: e }),
|
|
3892
4337
|
contentType: "application/json"
|
|
3893
4338
|
})).results;
|
|
3894
4339
|
}
|
|
@@ -3914,11 +4359,11 @@ const Ge = class Ge extends $e {
|
|
|
3914
4359
|
* } while (cursor);
|
|
3915
4360
|
* ```
|
|
3916
4361
|
*/
|
|
3917
|
-
async getNotifications(
|
|
3918
|
-
return await this.request("GET",
|
|
4362
|
+
async getNotifications(e) {
|
|
4363
|
+
return await this.request("GET", X, {
|
|
3919
4364
|
query: {
|
|
3920
|
-
...(
|
|
3921
|
-
...(
|
|
4365
|
+
...(e == null ? void 0 : e.cursor) !== void 0 && { cursor: e.cursor },
|
|
4366
|
+
...(e == null ? void 0 : e.limit) !== void 0 && { limit: String(e.limit) }
|
|
3922
4367
|
}
|
|
3923
4368
|
});
|
|
3924
4369
|
}
|
|
@@ -3929,7 +4374,7 @@ const Ge = class Ge extends $e {
|
|
|
3929
4374
|
async getUnreadNotificationCount() {
|
|
3930
4375
|
return (await this.request(
|
|
3931
4376
|
"GET",
|
|
3932
|
-
`${
|
|
4377
|
+
`${X}/unread-count`
|
|
3933
4378
|
)).count;
|
|
3934
4379
|
}
|
|
3935
4380
|
/**
|
|
@@ -3937,12 +4382,12 @@ const Ge = class Ge extends $e {
|
|
|
3937
4382
|
* ignored rather than rejected, so `updated` can be lower than the number
|
|
3938
4383
|
* passed in.
|
|
3939
4384
|
*/
|
|
3940
|
-
async markNotificationsRead(
|
|
4385
|
+
async markNotificationsRead(e) {
|
|
3941
4386
|
return await this.request(
|
|
3942
4387
|
"POST",
|
|
3943
|
-
`${
|
|
4388
|
+
`${X}/mark-read`,
|
|
3944
4389
|
{
|
|
3945
|
-
body: JSON.stringify({ ids:
|
|
4390
|
+
body: JSON.stringify({ ids: e }),
|
|
3946
4391
|
contentType: "application/json"
|
|
3947
4392
|
}
|
|
3948
4393
|
);
|
|
@@ -3951,7 +4396,7 @@ const Ge = class Ge extends $e {
|
|
|
3951
4396
|
async markAllNotificationsRead() {
|
|
3952
4397
|
return await this.request(
|
|
3953
4398
|
"POST",
|
|
3954
|
-
`${
|
|
4399
|
+
`${X}/mark-all-read`
|
|
3955
4400
|
);
|
|
3956
4401
|
}
|
|
3957
4402
|
/**
|
|
@@ -3961,7 +4406,7 @@ const Ge = class Ge extends $e {
|
|
|
3961
4406
|
async getNotificationSubscriptions() {
|
|
3962
4407
|
return await this.request(
|
|
3963
4408
|
"GET",
|
|
3964
|
-
`${
|
|
4409
|
+
`${X}/subscriptions`
|
|
3965
4410
|
);
|
|
3966
4411
|
}
|
|
3967
4412
|
/**
|
|
@@ -3972,10 +4417,10 @@ const Ge = class Ge extends $e {
|
|
|
3972
4417
|
* automation itself is gone — opting out must never be the thing that
|
|
3973
4418
|
* fails.
|
|
3974
4419
|
*/
|
|
3975
|
-
async unsubscribeFromAutomation(
|
|
4420
|
+
async unsubscribeFromAutomation(e) {
|
|
3976
4421
|
return await this.request(
|
|
3977
4422
|
"DELETE",
|
|
3978
|
-
`${
|
|
4423
|
+
`${X}/subscriptions/${e}`
|
|
3979
4424
|
);
|
|
3980
4425
|
}
|
|
3981
4426
|
/**
|
|
@@ -3996,10 +4441,10 @@ const Ge = class Ge extends $e {
|
|
|
3996
4441
|
* });
|
|
3997
4442
|
* ```
|
|
3998
4443
|
*/
|
|
3999
|
-
async subscribeToAutomation(
|
|
4444
|
+
async subscribeToAutomation(e, s, r) {
|
|
4000
4445
|
return await this.request(
|
|
4001
4446
|
"POST",
|
|
4002
|
-
`${
|
|
4447
|
+
`${J}/${e}/events/hooks/${s}/subscription`,
|
|
4003
4448
|
{
|
|
4004
4449
|
body: JSON.stringify(r ?? {}),
|
|
4005
4450
|
contentType: "application/json"
|
|
@@ -4013,10 +4458,10 @@ const Ge = class Ge extends $e {
|
|
|
4013
4458
|
* Throws if the user is not subscribed; use {@link subscribeToAutomation}
|
|
4014
4459
|
* to create one.
|
|
4015
4460
|
*/
|
|
4016
|
-
async updateAutomationSubscription(
|
|
4461
|
+
async updateAutomationSubscription(e, s, r) {
|
|
4017
4462
|
return await this.request(
|
|
4018
4463
|
"PATCH",
|
|
4019
|
-
`${
|
|
4464
|
+
`${J}/${e}/events/hooks/${s}/subscription`,
|
|
4020
4465
|
{
|
|
4021
4466
|
body: JSON.stringify(r),
|
|
4022
4467
|
contentType: "application/json"
|
|
@@ -4049,49 +4494,55 @@ const Ge = class Ge extends $e {
|
|
|
4049
4494
|
* stop();
|
|
4050
4495
|
* ```
|
|
4051
4496
|
*/
|
|
4052
|
-
async onNotification(
|
|
4053
|
-
const s = await this.resolveAccessToken(), r =
|
|
4497
|
+
async onNotification(e) {
|
|
4498
|
+
const s = await this.resolveAccessToken(), r = ut(`${this.socketOrigin}/notifications`, {
|
|
4054
4499
|
auth: { accessToken: s },
|
|
4055
4500
|
transports: ["websocket"]
|
|
4056
4501
|
});
|
|
4057
4502
|
return r.on(
|
|
4058
4503
|
"notification.created",
|
|
4059
|
-
(i) =>
|
|
4504
|
+
(i) => e({ type: "created", id: i == null ? void 0 : i.id })
|
|
4060
4505
|
), r.on(
|
|
4061
4506
|
"notification.read",
|
|
4062
|
-
(i) =>
|
|
4507
|
+
(i) => e({ type: "read", id: i == null ? void 0 : i.id })
|
|
4063
4508
|
), r.on(
|
|
4064
4509
|
"notifications.allRead",
|
|
4065
|
-
(i) =>
|
|
4510
|
+
(i) => e({ type: "allRead", batch: i == null ? void 0 : i.batch })
|
|
4066
4511
|
), () => r.disconnect();
|
|
4067
4512
|
}
|
|
4068
4513
|
};
|
|
4069
|
-
|
|
4070
|
-
let
|
|
4071
|
-
const
|
|
4514
|
+
st = new WeakMap(), mt = new WeakMap();
|
|
4515
|
+
let xe = ye;
|
|
4516
|
+
const wn = {
|
|
4072
4517
|
MAX_FIELDS: 200,
|
|
4073
4518
|
MAX_KEY_LENGTH: 50,
|
|
4074
4519
|
MAX_VALUE_LENGTH: 50
|
|
4075
|
-
},
|
|
4520
|
+
}, _n = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, bn = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, En = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, vn = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, Tn = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, Sn = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, kn = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, On = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, An = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
|
|
4076
4521
|
export {
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4522
|
+
_n as CDEManager,
|
|
4523
|
+
yn as ChannelClient,
|
|
4524
|
+
Ye as ChannelRoom,
|
|
4525
|
+
bn as ClashesManager,
|
|
4526
|
+
dn as CollabRoom,
|
|
4527
|
+
Zt as EngineServicesClient,
|
|
4528
|
+
fn as ExternalRoom,
|
|
4529
|
+
En as FileList,
|
|
4530
|
+
zs as FlowDoc,
|
|
4531
|
+
vn as GISManager,
|
|
4532
|
+
Tn as GitHistoryManager,
|
|
4533
|
+
Sn as HelloWorld,
|
|
4534
|
+
wn as METADATA_LIMITS,
|
|
4535
|
+
xe as PlatformClient,
|
|
4536
|
+
Xs as ProjectHistory,
|
|
4537
|
+
kn as ProjectManager,
|
|
4538
|
+
Zs as Recipes,
|
|
4539
|
+
fe as RequestError,
|
|
4540
|
+
Ae as STORAGE_BATCH_MAX,
|
|
4541
|
+
ve as StaleHistoryError,
|
|
4542
|
+
On as TopicsManager,
|
|
4543
|
+
An as UIManager,
|
|
4544
|
+
zt as mintGuid,
|
|
4545
|
+
Ve as orderByGraph,
|
|
4546
|
+
ln as windowTransport
|
|
4096
4547
|
};
|
|
4097
4548
|
//# sourceMappingURL=index.es.js.map
|