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