@thatopen/services 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +43 -7
- package/dist/cli.js.map +1 -1
- package/dist/core/history.d.ts +7 -0
- package/dist/core/recipes.d.ts +39 -5
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +428 -396
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var es = Object.defineProperty;
|
|
2
|
+
var ge = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var T = (n, t, e) =>
|
|
7
|
-
var l = (n, t, e) => (Pt(n, t, "read from private field"), e ? e.call(n) : t.get(n)),
|
|
5
|
+
var ss = (n, t, e) => t in n ? es(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
6
|
+
var T = (n, t, e) => ss(n, typeof t != "symbol" ? t + "" : t, e), Pt = (n, t, e) => t.has(n) || ge("Cannot " + e);
|
|
7
|
+
var l = (n, t, e) => (Pt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), b = (n, t, e) => t.has(n) ? ge("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), _ = (n, t, e, s) => (Pt(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), a = (n, t, e) => (Pt(n, t, "access private method"), e);
|
|
8
8
|
const P = /* @__PURE__ */ Object.create(null);
|
|
9
9
|
P.open = "0";
|
|
10
10
|
P.close = "1";
|
|
@@ -17,37 +17,37 @@ const Et = /* @__PURE__ */ Object.create(null);
|
|
|
17
17
|
Object.keys(P).forEach((n) => {
|
|
18
18
|
Et[P[n]] = n;
|
|
19
19
|
});
|
|
20
|
-
const jt = { type: "error", data: "parser error" }, $e = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]",
|
|
20
|
+
const jt = { type: "error", data: "parser error" }, $e = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ce = typeof ArrayBuffer == "function", Re = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, he = ({ type: n, data: t }, e, s) => $e && t instanceof Blob ? e ? s(t) : we(t, s) : Ce && (t instanceof ArrayBuffer || Re(t)) ? e ? s(t) : we(new Blob([t]), s) : s(P[n] + (t || "")), we = (n, t) => {
|
|
21
21
|
const e = new FileReader();
|
|
22
22
|
return e.onload = function() {
|
|
23
23
|
const s = e.result.split(",")[1];
|
|
24
24
|
t("b" + (s || ""));
|
|
25
25
|
}, e.readAsDataURL(n);
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function be(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
30
|
let Bt;
|
|
31
|
-
function
|
|
31
|
+
function ns(n, t) {
|
|
32
32
|
if ($e && n.data instanceof Blob)
|
|
33
|
-
return n.data.arrayBuffer().then(
|
|
34
|
-
if (
|
|
35
|
-
return t(
|
|
36
|
-
|
|
33
|
+
return n.data.arrayBuffer().then(be).then(t);
|
|
34
|
+
if (Ce && (n.data instanceof ArrayBuffer || Re(n.data)))
|
|
35
|
+
return t(be(n.data));
|
|
36
|
+
he(n, !1, (e) => {
|
|
37
37
|
Bt || (Bt = new TextEncoder()), t(Bt.encode(e));
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
const _e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ot = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
41
41
|
for (let n = 0; n < _e.length; n++)
|
|
42
42
|
ot[_e.charCodeAt(n)] = n;
|
|
43
|
-
const
|
|
43
|
+
const rs = (n) => {
|
|
44
44
|
let t = n.length * 0.75, e = n.length, s, r = 0, i, o, h, u;
|
|
45
45
|
n[n.length - 1] === "=" && (t--, n[n.length - 2] === "=" && t--);
|
|
46
|
-
const f = new ArrayBuffer(t),
|
|
46
|
+
const f = new ArrayBuffer(t), p = new Uint8Array(f);
|
|
47
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)],
|
|
48
|
+
i = ot[n.charCodeAt(s)], o = ot[n.charCodeAt(s + 1)], h = ot[n.charCodeAt(s + 2)], u = ot[n.charCodeAt(s + 3)], p[r++] = i << 2 | o >> 4, p[r++] = (o & 15) << 4 | h >> 2, p[r++] = (h & 3) << 6 | u & 63;
|
|
49
49
|
return f;
|
|
50
|
-
},
|
|
50
|
+
}, is = typeof ArrayBuffer == "function", le = (n, t) => {
|
|
51
51
|
if (typeof n != "string")
|
|
52
52
|
return {
|
|
53
53
|
type: "message",
|
|
@@ -56,16 +56,16 @@ const ss = (n) => {
|
|
|
56
56
|
const e = n.charAt(0);
|
|
57
57
|
return e === "b" ? {
|
|
58
58
|
type: "message",
|
|
59
|
-
data:
|
|
59
|
+
data: os(n.substring(1), t)
|
|
60
60
|
} : Et[e] ? n.length > 1 ? {
|
|
61
61
|
type: Et[e],
|
|
62
62
|
data: n.substring(1)
|
|
63
63
|
} : {
|
|
64
64
|
type: Et[e]
|
|
65
65
|
} : jt;
|
|
66
|
-
},
|
|
67
|
-
if (
|
|
68
|
-
const e =
|
|
66
|
+
}, os = (n, t) => {
|
|
67
|
+
if (is) {
|
|
68
|
+
const e = rs(n);
|
|
69
69
|
return Ne(e, t);
|
|
70
70
|
} else
|
|
71
71
|
return { base64: !0, data: n };
|
|
@@ -77,27 +77,27 @@ const ss = (n) => {
|
|
|
77
77
|
default:
|
|
78
78
|
return n instanceof ArrayBuffer ? n : n.buffer;
|
|
79
79
|
}
|
|
80
|
-
}, Pe = "",
|
|
80
|
+
}, Pe = "", as = (n, t) => {
|
|
81
81
|
const e = n.length, s = new Array(e);
|
|
82
82
|
let r = 0;
|
|
83
83
|
n.forEach((i, o) => {
|
|
84
|
-
|
|
84
|
+
he(i, !1, (h) => {
|
|
85
85
|
s[o] = h, ++r === e && t(s.join(Pe));
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
-
},
|
|
88
|
+
}, cs = (n, t) => {
|
|
89
89
|
const e = n.split(Pe), s = [];
|
|
90
90
|
for (let r = 0; r < e.length; r++) {
|
|
91
|
-
const i =
|
|
91
|
+
const i = le(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 hs() {
|
|
98
98
|
return new TransformStream({
|
|
99
99
|
transform(n, t) {
|
|
100
|
-
|
|
100
|
+
ns(n, (e) => {
|
|
101
101
|
const s = e.length;
|
|
102
102
|
let r;
|
|
103
103
|
if (s < 126)
|
|
@@ -120,7 +120,7 @@ let Lt;
|
|
|
120
120
|
function wt(n) {
|
|
121
121
|
return n.reduce((t, e) => t + e.length, 0);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function bt(n, t) {
|
|
124
124
|
if (n[0].length === t)
|
|
125
125
|
return n.shift();
|
|
126
126
|
const e = new Uint8Array(t);
|
|
@@ -129,7 +129,7 @@ function _t(n, t) {
|
|
|
129
129
|
e[r] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
|
|
130
130
|
return n.length && s < n[0].length && (n[0] = n[0].slice(s)), e;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function ls(n, t) {
|
|
133
133
|
Lt || (Lt = new TextDecoder());
|
|
134
134
|
const e = [];
|
|
135
135
|
let s = 0, r = -1, i = !1;
|
|
@@ -139,27 +139,27 @@ function cs(n, t) {
|
|
|
139
139
|
if (s === 0) {
|
|
140
140
|
if (wt(e) < 1)
|
|
141
141
|
break;
|
|
142
|
-
const u =
|
|
142
|
+
const u = bt(e, 1);
|
|
143
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
145
|
if (wt(e) < 2)
|
|
146
146
|
break;
|
|
147
|
-
const u =
|
|
147
|
+
const u = bt(e, 2);
|
|
148
148
|
r = new DataView(u.buffer, u.byteOffset, u.length).getUint16(0), s = 3;
|
|
149
149
|
} else if (s === 2) {
|
|
150
150
|
if (wt(e) < 8)
|
|
151
151
|
break;
|
|
152
|
-
const u =
|
|
153
|
-
if (
|
|
152
|
+
const u = bt(e, 8), f = new DataView(u.buffer, u.byteOffset, u.length), p = f.getUint32(0);
|
|
153
|
+
if (p > Math.pow(2, 21) - 1) {
|
|
154
154
|
h.enqueue(jt);
|
|
155
155
|
break;
|
|
156
156
|
}
|
|
157
|
-
r =
|
|
157
|
+
r = p * Math.pow(2, 32) + f.getUint32(4), s = 3;
|
|
158
158
|
} else {
|
|
159
159
|
if (wt(e) < r)
|
|
160
160
|
break;
|
|
161
|
-
const u =
|
|
162
|
-
h.enqueue(
|
|
161
|
+
const u = bt(e, r);
|
|
162
|
+
h.enqueue(le(i ? u : Lt.decode(u), t)), s = 0;
|
|
163
163
|
}
|
|
164
164
|
if (r === 0 || r > n) {
|
|
165
165
|
h.enqueue(jt);
|
|
@@ -171,9 +171,9 @@ function cs(n, t) {
|
|
|
171
171
|
}
|
|
172
172
|
const Be = 4;
|
|
173
173
|
function E(n) {
|
|
174
|
-
if (n) return
|
|
174
|
+
if (n) return us(n);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function us(n) {
|
|
177
177
|
for (var t in E.prototype)
|
|
178
178
|
n[t] = E.prototype[t];
|
|
179
179
|
return n;
|
|
@@ -219,19 +219,19 @@ E.prototype.listeners = function(n) {
|
|
|
219
219
|
E.prototype.hasListeners = function(n) {
|
|
220
220
|
return !!this.listeners(n).length;
|
|
221
221
|
};
|
|
222
|
-
const
|
|
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")(), ds = "arraybuffer";
|
|
223
223
|
function Le(n, ...t) {
|
|
224
224
|
return t.reduce((e, s) => (n.hasOwnProperty(s) && (e[s] = n[s]), e), {});
|
|
225
225
|
}
|
|
226
|
-
const
|
|
226
|
+
const fs = A.setTimeout, ps = A.clearTimeout;
|
|
227
227
|
function Nt(n, t) {
|
|
228
|
-
t.useNativeTimers ? (n.setTimeoutFn =
|
|
228
|
+
t.useNativeTimers ? (n.setTimeoutFn = fs.bind(A), n.clearTimeoutFn = ps.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 ys = 1.33;
|
|
231
|
+
function ms(n) {
|
|
232
|
+
return typeof n == "string" ? gs(n) : Math.ceil((n.byteLength || n.size) * ys);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function gs(n) {
|
|
235
235
|
let t = 0, e = 0;
|
|
236
236
|
for (let s = 0, r = n.length; s < r; s++)
|
|
237
237
|
t = n.charCodeAt(s), t < 128 ? e += 1 : t < 2048 ? e += 2 : t < 55296 || t >= 57344 ? e += 3 : (s++, e += 4);
|
|
@@ -240,13 +240,13 @@ function ys(n) {
|
|
|
240
240
|
function qe() {
|
|
241
241
|
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function ws(n) {
|
|
244
244
|
let t = "";
|
|
245
245
|
for (let e in n)
|
|
246
246
|
n.hasOwnProperty(e) && (t.length && (t += "&"), t += encodeURIComponent(e) + "=" + encodeURIComponent(n[e]));
|
|
247
247
|
return t;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function bs(n) {
|
|
250
250
|
let t = {}, e = n.split("&");
|
|
251
251
|
for (let s = 0, r = e.length; s < r; s++) {
|
|
252
252
|
let i = e[s].split("=");
|
|
@@ -254,12 +254,12 @@ function gs(n) {
|
|
|
254
254
|
}
|
|
255
255
|
return t;
|
|
256
256
|
}
|
|
257
|
-
class
|
|
257
|
+
class _s extends Error {
|
|
258
258
|
constructor(t, e, s) {
|
|
259
259
|
super(t), this.description = e, this.context = s, this.type = "TransportError";
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
class
|
|
262
|
+
class ue extends E {
|
|
263
263
|
/**
|
|
264
264
|
* Transport abstract constructor.
|
|
265
265
|
*
|
|
@@ -279,7 +279,7 @@ class le extends E {
|
|
|
279
279
|
* @protected
|
|
280
280
|
*/
|
|
281
281
|
onError(t, e, s) {
|
|
282
|
-
return super.emitReserved("error", new
|
|
282
|
+
return super.emitReserved("error", new _s(t, e, s)), this;
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* Opens the transport.
|
|
@@ -316,7 +316,7 @@ class le extends E {
|
|
|
316
316
|
* @protected
|
|
317
317
|
*/
|
|
318
318
|
onData(t) {
|
|
319
|
-
const e =
|
|
319
|
+
const e = le(t, this.socket.binaryType);
|
|
320
320
|
this.onPacket(e);
|
|
321
321
|
}
|
|
322
322
|
/**
|
|
@@ -353,11 +353,11 @@ class le extends E {
|
|
|
353
353
|
return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
|
|
354
354
|
}
|
|
355
355
|
_query(t) {
|
|
356
|
-
const e =
|
|
356
|
+
const e = ws(t);
|
|
357
357
|
return e.length ? "?" + e : "";
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
class
|
|
360
|
+
class Es extends ue {
|
|
361
361
|
constructor() {
|
|
362
362
|
super(...arguments), this._polling = !1;
|
|
363
363
|
}
|
|
@@ -413,7 +413,7 @@ class _s extends le {
|
|
|
413
413
|
return this.onClose({ description: "transport closed by the server" }), !1;
|
|
414
414
|
this.onPacket(s);
|
|
415
415
|
};
|
|
416
|
-
|
|
416
|
+
cs(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.
|
|
@@ -433,7 +433,7 @@ class _s extends le {
|
|
|
433
433
|
* @protected
|
|
434
434
|
*/
|
|
435
435
|
write(t) {
|
|
436
|
-
this.writable = !1,
|
|
436
|
+
this.writable = !1, as(t, (e) => {
|
|
437
437
|
this.doWrite(e, () => {
|
|
438
438
|
this.writable = !0, this.emitReserved("drain");
|
|
439
439
|
});
|
|
@@ -454,10 +454,10 @@ try {
|
|
|
454
454
|
Fe = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
455
455
|
} catch {
|
|
456
456
|
}
|
|
457
|
-
const
|
|
458
|
-
function
|
|
457
|
+
const vs = Fe;
|
|
458
|
+
function Ts() {
|
|
459
459
|
}
|
|
460
|
-
class
|
|
460
|
+
class Ss extends Es {
|
|
461
461
|
/**
|
|
462
462
|
* XHR Polling constructor.
|
|
463
463
|
*
|
|
@@ -570,7 +570,7 @@ class N extends E {
|
|
|
570
570
|
*/
|
|
571
571
|
_cleanup(t) {
|
|
572
572
|
if (!(typeof this._xhr > "u" || this._xhr === null)) {
|
|
573
|
-
if (this._xhr.onreadystatechange =
|
|
573
|
+
if (this._xhr.onreadystatechange = Ts, t)
|
|
574
574
|
try {
|
|
575
575
|
this._xhr.abort();
|
|
576
576
|
} catch {
|
|
@@ -600,27 +600,27 @@ 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", Ee);
|
|
604
604
|
else if (typeof addEventListener == "function") {
|
|
605
605
|
const n = "onpagehide" in A ? "pagehide" : "unload";
|
|
606
|
-
addEventListener(n,
|
|
606
|
+
addEventListener(n, Ee, !1);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
function
|
|
609
|
+
function Ee() {
|
|
610
610
|
for (let n in N.requests)
|
|
611
611
|
N.requests.hasOwnProperty(n) && N.requests[n].abort();
|
|
612
612
|
}
|
|
613
|
-
const
|
|
613
|
+
const ks = function() {
|
|
614
614
|
const n = Ue({
|
|
615
615
|
xdomain: !1
|
|
616
616
|
});
|
|
617
617
|
return n && n.responseType !== null;
|
|
618
618
|
}();
|
|
619
|
-
class
|
|
619
|
+
class Os extends Ss {
|
|
620
620
|
constructor(t) {
|
|
621
621
|
super(t);
|
|
622
622
|
const e = t && t.forceBase64;
|
|
623
|
-
this.supportsBinary =
|
|
623
|
+
this.supportsBinary = ks && !e;
|
|
624
624
|
}
|
|
625
625
|
request(t = {}) {
|
|
626
626
|
return Object.assign(t, { xd: this.xd }, this.opts), new N(Ue, this.uri(), t);
|
|
@@ -629,7 +629,7 @@ class Ss extends vs {
|
|
|
629
629
|
function Ue(n) {
|
|
630
630
|
const t = n.xdomain;
|
|
631
631
|
try {
|
|
632
|
-
if (typeof XMLHttpRequest < "u" && (!t ||
|
|
632
|
+
if (typeof XMLHttpRequest < "u" && (!t || vs))
|
|
633
633
|
return new XMLHttpRequest();
|
|
634
634
|
} catch {
|
|
635
635
|
}
|
|
@@ -640,7 +640,7 @@ function Ue(n) {
|
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
642
|
const De = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
643
|
-
class
|
|
643
|
+
class As extends ue {
|
|
644
644
|
get name() {
|
|
645
645
|
return "websocket";
|
|
646
646
|
}
|
|
@@ -671,12 +671,12 @@ class ks extends le {
|
|
|
671
671
|
this.writable = !1;
|
|
672
672
|
for (let e = 0; e < t.length; e++) {
|
|
673
673
|
const s = t[e], r = e === t.length - 1;
|
|
674
|
-
|
|
674
|
+
he(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
|
});
|
|
@@ -697,7 +697,7 @@ class ks extends le {
|
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
699
|
const qt = A.WebSocket || A.MozWebSocket;
|
|
700
|
-
class
|
|
700
|
+
class Is extends As {
|
|
701
701
|
createSocket(t, e, s) {
|
|
702
702
|
return De ? new qt(t, e, s) : e ? new qt(t, e) : new qt(t);
|
|
703
703
|
}
|
|
@@ -705,7 +705,7 @@ class Os extends ks {
|
|
|
705
705
|
this.ws.send(e);
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
|
-
class
|
|
708
|
+
class xs extends ue {
|
|
709
709
|
get name() {
|
|
710
710
|
return "webtransport";
|
|
711
711
|
}
|
|
@@ -721,7 +721,7 @@ class As extends le {
|
|
|
721
721
|
this.onError("webtransport error", t);
|
|
722
722
|
}), this._transport.ready.then(() => {
|
|
723
723
|
this._transport.createBidirectionalStream().then((t) => {
|
|
724
|
-
const e =
|
|
724
|
+
const e = ls(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), r = hs();
|
|
725
725
|
r.readable.pipeTo(t.writable), this._writer = r.writable.getWriter();
|
|
726
726
|
const i = () => {
|
|
727
727
|
s.read().then(({ done: h, value: u }) => {
|
|
@@ -740,7 +740,7 @@ class As extends le {
|
|
|
740
740
|
for (let e = 0; e < t.length; e++) {
|
|
741
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
|
});
|
|
@@ -751,11 +751,11 @@ class As extends le {
|
|
|
751
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 $s = {
|
|
755
|
+
websocket: Is,
|
|
756
|
+
webtransport: xs,
|
|
757
|
+
polling: Os
|
|
758
|
+
}, Cs = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Rs = [
|
|
759
759
|
"source",
|
|
760
760
|
"protocol",
|
|
761
761
|
"authority",
|
|
@@ -776,16 +776,16 @@ function Mt(n) {
|
|
|
776
776
|
throw "URI too long";
|
|
777
777
|
const t = n, e = n.indexOf("["), s = n.indexOf("]");
|
|
778
778
|
e != -1 && s != -1 && (n = n.substring(0, e) + n.substring(e, s).replace(/:/g, ";") + n.substring(s, n.length));
|
|
779
|
-
let r =
|
|
779
|
+
let r = Cs.exec(n || ""), i = {}, o = 14;
|
|
780
780
|
for (; o--; )
|
|
781
|
-
i[
|
|
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 =
|
|
781
|
+
i[Rs[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 = Ns(i, i.path), i.queryKey = Ps(i, i.query), i;
|
|
783
783
|
}
|
|
784
|
-
function
|
|
784
|
+
function Ns(n, t) {
|
|
785
785
|
const e = /\/{2,9}/g, s = t.replace(e, "/").split("/");
|
|
786
786
|
return (t.slice(0, 1) == "/" || t.length === 0) && s.splice(0, 1), t.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
|
|
787
787
|
}
|
|
788
|
-
function
|
|
788
|
+
function Ps(n, t) {
|
|
789
789
|
const e = {};
|
|
790
790
|
return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, r, i) {
|
|
791
791
|
r && (e[r] = i);
|
|
@@ -795,7 +795,7 @@ const Ht = typeof addEventListener == "function" && typeof removeEventListener =
|
|
|
795
795
|
Ht && addEventListener("offline", () => {
|
|
796
796
|
vt.forEach((n) => n());
|
|
797
797
|
}, !1);
|
|
798
|
-
class
|
|
798
|
+
class J extends E {
|
|
799
799
|
/**
|
|
800
800
|
* Socket constructor.
|
|
801
801
|
*
|
|
@@ -803,7 +803,7 @@ class V extends E {
|
|
|
803
803
|
* @param {Object} opts - options
|
|
804
804
|
*/
|
|
805
805
|
constructor(t, e) {
|
|
806
|
-
if (super(), this.binaryType =
|
|
806
|
+
if (super(), this.binaryType = ds, 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
807
|
const s = Mt(t);
|
|
808
808
|
e.hostname = s.host, e.secure = s.protocol === "https" || s.protocol === "wss", e.port = s.port, s.query && (e.query = s.query);
|
|
809
809
|
} else e.host && (e.hostname = Mt(e.host).host);
|
|
@@ -824,7 +824,7 @@ class V extends E {
|
|
|
824
824
|
},
|
|
825
825
|
transportOptions: {},
|
|
826
826
|
closeOnBeforeunload: !1
|
|
827
|
-
}, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query =
|
|
827
|
+
}, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = bs(this.opts.query)), Ht && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
828
828
|
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
829
829
|
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
830
830
|
this._onClose("transport close", {
|
|
@@ -863,7 +863,7 @@ class V extends E {
|
|
|
863
863
|
}, 0);
|
|
864
864
|
return;
|
|
865
865
|
}
|
|
866
|
-
const t = this.opts.rememberUpgrade &&
|
|
866
|
+
const t = this.opts.rememberUpgrade && J.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
|
|
867
867
|
this.readyState = "opening";
|
|
868
868
|
const e = this.createTransport(t);
|
|
869
869
|
e.open(), this.setTransport(e);
|
|
@@ -882,7 +882,7 @@ class V extends E {
|
|
|
882
882
|
* @private
|
|
883
883
|
*/
|
|
884
884
|
onOpen() {
|
|
885
|
-
this.readyState = "open",
|
|
885
|
+
this.readyState = "open", J.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
|
|
886
886
|
}
|
|
887
887
|
/**
|
|
888
888
|
* Handles a packet.
|
|
@@ -959,7 +959,7 @@ class V extends E {
|
|
|
959
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 && (e +=
|
|
962
|
+
if (r && (e += ms(r)), s > 0 && e > this._maxPayload)
|
|
963
963
|
return this.writeBuffer.slice(0, s);
|
|
964
964
|
e += 2;
|
|
965
965
|
}
|
|
@@ -979,7 +979,7 @@ class V extends E {
|
|
|
979
979
|
if (!this._pingTimeoutTime)
|
|
980
980
|
return !0;
|
|
981
981
|
const t = Date.now() > this._pingTimeoutTime;
|
|
982
|
-
return t && (this._pingTimeoutTime = 0,
|
|
982
|
+
return t && (this._pingTimeoutTime = 0, Rt(() => {
|
|
983
983
|
this._onClose("ping timeout");
|
|
984
984
|
}, this.setTimeoutFn)), t;
|
|
985
985
|
}
|
|
@@ -1046,7 +1046,7 @@ class V extends E {
|
|
|
1046
1046
|
* @private
|
|
1047
1047
|
*/
|
|
1048
1048
|
_onError(t) {
|
|
1049
|
-
if (
|
|
1049
|
+
if (J.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
|
|
1050
1050
|
return this.transports.shift(), this._open();
|
|
1051
1051
|
this.emitReserved("error", t), this._onClose("transport error", t);
|
|
1052
1052
|
}
|
|
@@ -1065,8 +1065,8 @@ class V extends E {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
1067
|
}
|
|
1068
|
-
|
|
1069
|
-
class
|
|
1068
|
+
J.protocol = Be;
|
|
1069
|
+
class Bs extends J {
|
|
1070
1070
|
constructor() {
|
|
1071
1071
|
super(...arguments), this._upgrades = [];
|
|
1072
1072
|
}
|
|
@@ -1083,28 +1083,28 @@ class Ns extends V {
|
|
|
1083
1083
|
*/
|
|
1084
1084
|
_probe(t) {
|
|
1085
1085
|
let e = this.createTransport(t), s = !1;
|
|
1086
|
-
|
|
1086
|
+
J.priorWebsocketSuccess = !1;
|
|
1087
1087
|
const r = () => {
|
|
1088
1088
|
s || (e.send([{ type: "ping", data: "probe" }]), e.once("packet", (w) => {
|
|
1089
1089
|
if (!s)
|
|
1090
1090
|
if (w.type === "pong" && w.data === "probe") {
|
|
1091
1091
|
if (this.upgrading = !0, this.emitReserved("upgrading", e), !e)
|
|
1092
1092
|
return;
|
|
1093
|
-
|
|
1094
|
-
s || this.readyState !== "closed" && (
|
|
1093
|
+
J.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
|
|
1094
|
+
s || this.readyState !== "closed" && (p(), this.setTransport(e), e.send([{ type: "upgrade" }]), this.emitReserved("upgrade", e), e = null, this.upgrading = !1, this.flush());
|
|
1095
1095
|
});
|
|
1096
1096
|
} else {
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1097
|
+
const C = new Error("probe error");
|
|
1098
|
+
C.transport = e.name, this.emitReserved("upgradeError", C);
|
|
1099
1099
|
}
|
|
1100
1100
|
}));
|
|
1101
1101
|
};
|
|
1102
1102
|
function i() {
|
|
1103
|
-
s || (s = !0,
|
|
1103
|
+
s || (s = !0, p(), e.close(), e = null);
|
|
1104
1104
|
}
|
|
1105
1105
|
const o = (w) => {
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1106
|
+
const C = new Error("probe error: " + w);
|
|
1107
|
+
C.transport = e.name, i(), this.emitReserved("upgradeError", C);
|
|
1108
1108
|
};
|
|
1109
1109
|
function h() {
|
|
1110
1110
|
o("transport closed");
|
|
@@ -1115,7 +1115,7 @@ class Ns extends V {
|
|
|
1115
1115
|
function f(w) {
|
|
1116
1116
|
e && w.name !== e.name && i();
|
|
1117
1117
|
}
|
|
1118
|
-
const
|
|
1118
|
+
const p = () => {
|
|
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
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(() => {
|
|
@@ -1138,21 +1138,21 @@ class Ns extends V {
|
|
|
1138
1138
|
return e;
|
|
1139
1139
|
}
|
|
1140
1140
|
}
|
|
1141
|
-
let
|
|
1141
|
+
let Ls = class extends Bs {
|
|
1142
1142
|
constructor(t, e = {}) {
|
|
1143
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) =>
|
|
1144
|
+
(!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => $s[i]).filter((i) => !!i)), super(s ? r : t, r);
|
|
1145
1145
|
}
|
|
1146
1146
|
};
|
|
1147
|
-
function
|
|
1147
|
+
function qs(n, t = "", e) {
|
|
1148
1148
|
let s = n;
|
|
1149
1149
|
e = e || typeof location < "u" && location, n == null && (n = e.protocol + "//" + e.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = e.protocol + n : n = e.host + n), /^(https?|wss?):\/\//.test(n) || (typeof e < "u" ? n = e.protocol + "//" + n : n = "https://" + n), s = Mt(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
|
|
1150
1150
|
const i = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
|
|
1151
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 Fs = typeof ArrayBuffer == "function", Us = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, je = Object.prototype.toString, Ds = typeof Blob == "function" || typeof Blob < "u" && je.call(Blob) === "[object BlobConstructor]", js = typeof File == "function" || typeof File < "u" && je.call(File) === "[object FileConstructor]";
|
|
1154
|
+
function de(n) {
|
|
1155
|
+
return Fs && (n instanceof ArrayBuffer || Us(n)) || Ds && n instanceof Blob || js && n instanceof File;
|
|
1156
1156
|
}
|
|
1157
1157
|
function Tt(n, t) {
|
|
1158
1158
|
if (!n || typeof n != "object")
|
|
@@ -1163,7 +1163,7 @@ function Tt(n, t) {
|
|
|
1163
1163
|
return !0;
|
|
1164
1164
|
return !1;
|
|
1165
1165
|
}
|
|
1166
|
-
if (
|
|
1166
|
+
if (de(n))
|
|
1167
1167
|
return !0;
|
|
1168
1168
|
if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
|
|
1169
1169
|
return Tt(n.toJSON(), !0);
|
|
@@ -1172,14 +1172,14 @@ function Tt(n, t) {
|
|
|
1172
1172
|
return !0;
|
|
1173
1173
|
return !1;
|
|
1174
1174
|
}
|
|
1175
|
-
function
|
|
1175
|
+
function Ms(n) {
|
|
1176
1176
|
const t = [], e = n.data, s = n;
|
|
1177
1177
|
return s.data = Gt(e, t), s.attachments = t.length, { packet: s, buffers: t };
|
|
1178
1178
|
}
|
|
1179
1179
|
function Gt(n, t) {
|
|
1180
1180
|
if (!n)
|
|
1181
1181
|
return n;
|
|
1182
|
-
if (
|
|
1182
|
+
if (de(n)) {
|
|
1183
1183
|
const e = { _placeholder: !0, num: t.length };
|
|
1184
1184
|
return t.push(n), e;
|
|
1185
1185
|
} else if (Array.isArray(n)) {
|
|
@@ -1195,7 +1195,7 @@ function Gt(n, t) {
|
|
|
1195
1195
|
}
|
|
1196
1196
|
return n;
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1198
|
+
function Hs(n, t) {
|
|
1199
1199
|
return n.data = Vt(n.data, t), delete n.attachments, n;
|
|
1200
1200
|
}
|
|
1201
1201
|
function Vt(n, t) {
|
|
@@ -1213,7 +1213,7 @@ function Vt(n, t) {
|
|
|
1213
1213
|
Object.prototype.hasOwnProperty.call(n, e) && (n[e] = Vt(n[e], t));
|
|
1214
1214
|
return n;
|
|
1215
1215
|
}
|
|
1216
|
-
const
|
|
1216
|
+
const Gs = [
|
|
1217
1217
|
"connect",
|
|
1218
1218
|
// used on the client side
|
|
1219
1219
|
"connect_error",
|
|
@@ -1231,7 +1231,7 @@ 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
1233
|
})(g || (g = {}));
|
|
1234
|
-
class
|
|
1234
|
+
class Vs {
|
|
1235
1235
|
/**
|
|
1236
1236
|
* Encoder constructor
|
|
1237
1237
|
*
|
|
@@ -1267,11 +1267,11 @@ class Hs {
|
|
|
1267
1267
|
* a list of buffers.
|
|
1268
1268
|
*/
|
|
1269
1269
|
encodeAsBinary(t) {
|
|
1270
|
-
const e =
|
|
1270
|
+
const e = Ms(t), s = this.encodeAsString(e.packet), r = e.buffers;
|
|
1271
1271
|
return r.unshift(s), r;
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
|
-
class
|
|
1274
|
+
class fe extends E {
|
|
1275
1275
|
/**
|
|
1276
1276
|
* Decoder constructor
|
|
1277
1277
|
*/
|
|
@@ -1293,8 +1293,8 @@ class de extends E {
|
|
|
1293
1293
|
throw new Error("got plaintext data when reconstructing a packet");
|
|
1294
1294
|
e = this.decodeString(t);
|
|
1295
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
|
|
1297
|
-
} else if (
|
|
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 (de(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
|
|
@@ -1323,7 +1323,7 @@ class de extends E {
|
|
|
1323
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 (!Ys(h) || h < 0)
|
|
1327
1327
|
throw new Error("Illegal attachments");
|
|
1328
1328
|
if (h > this.opts.maxAttachments)
|
|
1329
1329
|
throw new Error("too many attachments");
|
|
@@ -1352,7 +1352,7 @@ class de extends E {
|
|
|
1352
1352
|
}
|
|
1353
1353
|
if (t.charAt(++e)) {
|
|
1354
1354
|
const i = this.tryParse(t.substr(e));
|
|
1355
|
-
if (
|
|
1355
|
+
if (fe.isPayloadValid(s.type, i))
|
|
1356
1356
|
s.data = i;
|
|
1357
1357
|
else
|
|
1358
1358
|
throw new Error("invalid payload");
|
|
@@ -1369,14 +1369,14 @@ class de extends E {
|
|
|
1369
1369
|
static isPayloadValid(t, e) {
|
|
1370
1370
|
switch (t) {
|
|
1371
1371
|
case g.CONNECT:
|
|
1372
|
-
return
|
|
1372
|
+
return ve(e);
|
|
1373
1373
|
case g.DISCONNECT:
|
|
1374
1374
|
return e === void 0;
|
|
1375
1375
|
case g.CONNECT_ERROR:
|
|
1376
|
-
return typeof e == "string" ||
|
|
1376
|
+
return typeof e == "string" || ve(e);
|
|
1377
1377
|
case g.EVENT:
|
|
1378
1378
|
case g.BINARY_EVENT:
|
|
1379
|
-
return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" &&
|
|
1379
|
+
return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Gs.indexOf(e[0]) === -1);
|
|
1380
1380
|
case g.ACK:
|
|
1381
1381
|
case g.BINARY_ACK:
|
|
1382
1382
|
return Array.isArray(e);
|
|
@@ -1389,7 +1389,7 @@ class de extends E {
|
|
|
1389
1389
|
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
1392
|
-
class
|
|
1392
|
+
class Js {
|
|
1393
1393
|
constructor(t) {
|
|
1394
1394
|
this.packet = t, this.buffers = [], this.reconPack = t;
|
|
1395
1395
|
}
|
|
@@ -1403,7 +1403,7 @@ class Gs {
|
|
|
1403
1403
|
*/
|
|
1404
1404
|
takeBinaryData(t) {
|
|
1405
1405
|
if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
|
|
1406
|
-
const e =
|
|
1406
|
+
const e = Hs(this.reconPack, this.buffers);
|
|
1407
1407
|
return this.finishedReconstruction(), e;
|
|
1408
1408
|
}
|
|
1409
1409
|
return null;
|
|
@@ -1415,16 +1415,16 @@ class Gs {
|
|
|
1415
1415
|
this.reconPack = null, this.buffers = [];
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
|
-
const
|
|
1418
|
+
const Ys = Number.isInteger || function(n) {
|
|
1419
1419
|
return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
|
|
1420
1420
|
};
|
|
1421
|
-
function
|
|
1421
|
+
function ve(n) {
|
|
1422
1422
|
return Object.prototype.toString.call(n) === "[object Object]";
|
|
1423
1423
|
}
|
|
1424
|
-
const
|
|
1424
|
+
const Ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1425
1425
|
__proto__: null,
|
|
1426
|
-
Decoder:
|
|
1427
|
-
Encoder:
|
|
1426
|
+
Decoder: fe,
|
|
1427
|
+
Encoder: Vs,
|
|
1428
1428
|
get PacketType() {
|
|
1429
1429
|
return g;
|
|
1430
1430
|
}
|
|
@@ -1434,7 +1434,7 @@ function $(n, t, e) {
|
|
|
1434
1434
|
n.off(t, e);
|
|
1435
1435
|
};
|
|
1436
1436
|
}
|
|
1437
|
-
const
|
|
1437
|
+
const Ks = Object.freeze({
|
|
1438
1438
|
connect: 1,
|
|
1439
1439
|
connect_error: 1,
|
|
1440
1440
|
disconnect: 1,
|
|
@@ -1559,7 +1559,7 @@ class Me extends E {
|
|
|
1559
1559
|
*/
|
|
1560
1560
|
emit(t, ...e) {
|
|
1561
1561
|
var s, r, i;
|
|
1562
|
-
if (
|
|
1562
|
+
if (Ks.hasOwnProperty(t))
|
|
1563
1563
|
throw new Error('"' + t.toString() + '" is a reserved event name');
|
|
1564
1564
|
if (e.unshift(t), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
|
|
1565
1565
|
return this._addToQueue(e), this;
|
|
@@ -1568,8 +1568,8 @@ class Me extends E {
|
|
|
1568
1568
|
data: e
|
|
1569
1569
|
};
|
|
1570
1570
|
if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof e[e.length - 1] == "function") {
|
|
1571
|
-
const
|
|
1572
|
-
this._registerAckCallback(
|
|
1571
|
+
const p = this.ids++, w = e.pop();
|
|
1572
|
+
this._registerAckCallback(p, w), o.id = p;
|
|
1573
1573
|
}
|
|
1574
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
1575
|
return this.flags.volatile && !h || (u ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
|
|
@@ -2035,10 +2035,10 @@ class Me extends E {
|
|
|
2035
2035
|
}
|
|
2036
2036
|
}
|
|
2037
2037
|
}
|
|
2038
|
-
function
|
|
2038
|
+
function rt(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
|
+
rt.prototype.duration = function() {
|
|
2042
2042
|
var n = this.ms * Math.pow(this.factor, this.attempts++);
|
|
2043
2043
|
if (this.jitter) {
|
|
2044
2044
|
var t = Math.random(), e = Math.floor(t * this.jitter * n);
|
|
@@ -2046,27 +2046,27 @@ nt.prototype.duration = function() {
|
|
|
2046
2046
|
}
|
|
2047
2047
|
return Math.min(n, this.max) | 0;
|
|
2048
2048
|
};
|
|
2049
|
-
|
|
2049
|
+
rt.prototype.reset = function() {
|
|
2050
2050
|
this.attempts = 0;
|
|
2051
2051
|
};
|
|
2052
|
-
|
|
2052
|
+
rt.prototype.setMin = function(n) {
|
|
2053
2053
|
this.ms = n;
|
|
2054
2054
|
};
|
|
2055
|
-
|
|
2055
|
+
rt.prototype.setMax = function(n) {
|
|
2056
2056
|
this.max = n;
|
|
2057
2057
|
};
|
|
2058
|
-
|
|
2058
|
+
rt.prototype.setJitter = function(n) {
|
|
2059
2059
|
this.jitter = n;
|
|
2060
2060
|
};
|
|
2061
2061
|
class Jt extends E {
|
|
2062
2062
|
constructor(t, e) {
|
|
2063
2063
|
var s;
|
|
2064
|
-
super(), this.nsps = {}, this.subs = [], t && typeof t == "object" && (e = t, t = void 0), e = e || {}, e.path = e.path || "/socket.io", this.opts = e, Nt(this, e), this.reconnection(e.reconnection !== !1), this.reconnectionAttempts(e.reconnectionAttempts || 1 / 0), this.reconnectionDelay(e.reconnectionDelay || 1e3), this.reconnectionDelayMax(e.reconnectionDelayMax || 5e3), this.randomizationFactor((s = e.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new
|
|
2064
|
+
super(), this.nsps = {}, this.subs = [], t && typeof t == "object" && (e = t, t = void 0), e = e || {}, e.path = e.path || "/socket.io", this.opts = e, Nt(this, e), this.reconnection(e.reconnection !== !1), this.reconnectionAttempts(e.reconnectionAttempts || 1 / 0), this.reconnectionDelay(e.reconnectionDelay || 1e3), this.reconnectionDelayMax(e.reconnectionDelayMax || 5e3), this.randomizationFactor((s = e.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new rt({
|
|
2065
2065
|
min: this.reconnectionDelay(),
|
|
2066
2066
|
max: this.reconnectionDelayMax(),
|
|
2067
2067
|
jitter: this.randomizationFactor()
|
|
2068
2068
|
}), this.timeout(e.timeout == null ? 2e4 : e.timeout), this._readyState = "closed", this.uri = t;
|
|
2069
|
-
const r = e.parser ||
|
|
2069
|
+
const r = e.parser || Ws;
|
|
2070
2070
|
this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = e.autoConnect !== !1, this._autoConnect && this.open();
|
|
2071
2071
|
}
|
|
2072
2072
|
reconnection(t) {
|
|
@@ -2109,7 +2109,7 @@ class Jt extends E {
|
|
|
2109
2109
|
open(t) {
|
|
2110
2110
|
if (~this._readyState.indexOf("open"))
|
|
2111
2111
|
return this;
|
|
2112
|
-
this.engine = new
|
|
2112
|
+
this.engine = new Ls(this.uri, this.opts);
|
|
2113
2113
|
const e = this.engine, s = this;
|
|
2114
2114
|
this._readyState = "opening", this.skipReconnect = !1;
|
|
2115
2115
|
const r = $(e, "open", function() {
|
|
@@ -2179,7 +2179,7 @@ class Jt extends E {
|
|
|
2179
2179
|
* @private
|
|
2180
2180
|
*/
|
|
2181
2181
|
ondecoded(t) {
|
|
2182
|
-
|
|
2182
|
+
Rt(() => {
|
|
2183
2183
|
this.emitReserved("packet", t);
|
|
2184
2184
|
}, this.setTimeoutFn);
|
|
2185
2185
|
}
|
|
@@ -2296,12 +2296,12 @@ class Jt extends E {
|
|
|
2296
2296
|
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
|
|
2297
2297
|
}
|
|
2298
2298
|
}
|
|
2299
|
-
const
|
|
2299
|
+
const it = {};
|
|
2300
2300
|
function ut(n, t) {
|
|
2301
2301
|
typeof n == "object" && (t = n, n = void 0), t = t || {};
|
|
2302
|
-
const e =
|
|
2302
|
+
const e = qs(n, t.path || "/socket.io"), s = e.source, r = e.id, i = e.path, o = it[r] && i in it[r].nsps, h = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
|
|
2303
2303
|
let u;
|
|
2304
|
-
return h ? u = new Jt(s, t) : (
|
|
2304
|
+
return h ? u = new Jt(s, t) : (it[r] || (it[r] = new Jt(s, t)), u = it[r]), e.query && !t.query && (t.query = e.queryKey), u.socket(e.path, t);
|
|
2305
2305
|
}
|
|
2306
2306
|
Object.assign(ut, {
|
|
2307
2307
|
Manager: Jt,
|
|
@@ -2309,41 +2309,50 @@ Object.assign(ut, {
|
|
|
2309
2309
|
io: ut,
|
|
2310
2310
|
connect: ut
|
|
2311
2311
|
});
|
|
2312
|
-
class
|
|
2312
|
+
class Te extends Error {
|
|
2313
2313
|
constructor(t, e) {
|
|
2314
2314
|
super(
|
|
2315
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
2316
|
), this.expectedGuid = t, this.actualGuid = e, this.name = "StaleHistoryError";
|
|
2317
2317
|
}
|
|
2318
2318
|
}
|
|
2319
|
-
const
|
|
2320
|
-
function
|
|
2319
|
+
const Se = "bimterop", Yt = "revitflow_history.json", z = "revitflow_ops.json", ke = "revitflow/ops@1", He = "revitflow_model.frag", Ge = "revitflow_", _t = () => `v-${Date.now()}`;
|
|
2320
|
+
function Ve(n, t) {
|
|
2321
2321
|
return n.filter((e) => String(e.parentId ?? "") === t);
|
|
2322
2322
|
}
|
|
2323
|
-
function
|
|
2323
|
+
function j(n) {
|
|
2324
2324
|
return String(n._id ?? n.id ?? "");
|
|
2325
2325
|
}
|
|
2326
|
-
var x, dt,
|
|
2326
|
+
var x, dt, Wt;
|
|
2327
2327
|
class Xs {
|
|
2328
2328
|
constructor(t, e) {
|
|
2329
|
-
|
|
2330
|
-
|
|
2329
|
+
b(this, dt);
|
|
2330
|
+
b(this, x);
|
|
2331
2331
|
this.client = t, this.projectId = e;
|
|
2332
2332
|
}
|
|
2333
2333
|
/** The project's connected documents. */
|
|
2334
2334
|
async docs() {
|
|
2335
|
-
const t = await a(this, dt,
|
|
2335
|
+
const t = await a(this, dt, Wt).call(this);
|
|
2336
2336
|
if (!t) return [];
|
|
2337
2337
|
const e = await this.client.listFolders({
|
|
2338
2338
|
parentFolderId: t,
|
|
2339
2339
|
projectId: this.projectId
|
|
2340
2340
|
}), s = [];
|
|
2341
|
-
for (const r of
|
|
2341
|
+
for (const r of Ve(e, t)) {
|
|
2342
2342
|
const i = String(r.name ?? ""), o = i.indexOf("-");
|
|
2343
|
-
o <= 0
|
|
2343
|
+
if (o <= 0) continue;
|
|
2344
|
+
const u = (await this.client.listFiles({
|
|
2345
|
+
folderId: j(r)
|
|
2346
|
+
})).map(
|
|
2347
|
+
(w) => String(w.name ?? "")
|
|
2348
|
+
), f = u.find((w) => w === He) ?? u.find(
|
|
2349
|
+
(w) => w.endsWith(".frag") && !w.startsWith(Ge)
|
|
2350
|
+
), p = u.includes(Yt) || u.includes(z) || !!f;
|
|
2351
|
+
s.push({
|
|
2344
2352
|
source: i.slice(0, o),
|
|
2345
2353
|
docId: i.slice(o + 1),
|
|
2346
|
-
modelName:
|
|
2354
|
+
modelName: f,
|
|
2355
|
+
...p ? {} : { empty: !0 }
|
|
2347
2356
|
});
|
|
2348
2357
|
}
|
|
2349
2358
|
return s;
|
|
@@ -2355,31 +2364,31 @@ class Xs {
|
|
|
2355
2364
|
/** @internal The `bimterop` folder id, resolved once. */
|
|
2356
2365
|
async rootFolderId(t = !1) {
|
|
2357
2366
|
if (l(this, x)) return l(this, x);
|
|
2358
|
-
const e = await a(this, dt,
|
|
2367
|
+
const e = await a(this, dt, Wt).call(this);
|
|
2359
2368
|
if (e) return e;
|
|
2360
2369
|
if (!t) return;
|
|
2361
2370
|
const s = await this.client.createFolder(
|
|
2362
|
-
|
|
2371
|
+
Se,
|
|
2363
2372
|
void 0,
|
|
2364
2373
|
this.projectId
|
|
2365
2374
|
);
|
|
2366
|
-
return
|
|
2375
|
+
return _(this, x, j(s)), l(this, x);
|
|
2367
2376
|
}
|
|
2368
2377
|
}
|
|
2369
|
-
x = new WeakMap(), dt = new WeakSet(),
|
|
2378
|
+
x = new WeakMap(), dt = new WeakSet(), Wt = async function() {
|
|
2370
2379
|
if (l(this, x)) return l(this, x);
|
|
2371
2380
|
const e = (await this.client.listFolders({
|
|
2372
2381
|
projectId: this.projectId
|
|
2373
2382
|
})).find(
|
|
2374
|
-
(s) => String(s.name ?? "") ===
|
|
2383
|
+
(s) => String(s.name ?? "") === Se && !s.parentId
|
|
2375
2384
|
);
|
|
2376
|
-
return e &&
|
|
2385
|
+
return e && _(this, x, j(e)), l(this, x);
|
|
2377
2386
|
};
|
|
2378
|
-
var L,
|
|
2387
|
+
var L, y, at, ct, Kt, St, kt, Xt, Ot, ht, At, zt, Je;
|
|
2379
2388
|
class zs {
|
|
2380
2389
|
constructor(t, e, s, r) {
|
|
2381
|
-
|
|
2382
|
-
|
|
2390
|
+
b(this, y);
|
|
2391
|
+
b(this, L);
|
|
2383
2392
|
this.client = t, this.project = e, this.source = s, this.docId = r;
|
|
2384
2393
|
}
|
|
2385
2394
|
// ─── Reading ───────────────────────────────────────────────────────────────
|
|
@@ -2389,8 +2398,8 @@ class zs {
|
|
|
2389
2398
|
* Each version gets its `ordinal` filled in.
|
|
2390
2399
|
*/
|
|
2391
2400
|
async timeline() {
|
|
2392
|
-
const t = await a(this,
|
|
2393
|
-
return
|
|
2401
|
+
const t = await a(this, y, Ot).call(this);
|
|
2402
|
+
return Ye((t == null ? void 0 : t.commits) ?? []);
|
|
2394
2403
|
}
|
|
2395
2404
|
/** The head of the timeline, or null before the first sync. */
|
|
2396
2405
|
async latest() {
|
|
@@ -2410,7 +2419,7 @@ class zs {
|
|
|
2410
2419
|
}
|
|
2411
2420
|
/** The visible model .frag as last fully exported. */
|
|
2412
2421
|
async model() {
|
|
2413
|
-
const t = await a(this,
|
|
2422
|
+
const t = await a(this, y, kt).call(this);
|
|
2414
2423
|
if (!t)
|
|
2415
2424
|
throw new Error(
|
|
2416
2425
|
`Document ${this.source}-${this.docId} has no model file yet.`
|
|
@@ -2426,16 +2435,16 @@ class zs {
|
|
|
2426
2435
|
*/
|
|
2427
2436
|
async sync(t) {
|
|
2428
2437
|
var h;
|
|
2429
|
-
const e = await a(this,
|
|
2430
|
-
let s = await a(this,
|
|
2438
|
+
const e = await a(this, y, ct).call(this, !0);
|
|
2439
|
+
let s = await a(this, y, Ot).call(this) ?? {
|
|
2431
2440
|
model: this.docId,
|
|
2432
2441
|
commits: []
|
|
2433
2442
|
};
|
|
2434
2443
|
const r = Oe(s.commits);
|
|
2435
2444
|
if (t.expectedLatestGuid !== void 0 && (r == null ? void 0 : r.guid) !== t.expectedLatestGuid)
|
|
2436
|
-
throw new
|
|
2445
|
+
throw new Te(t.expectedLatestGuid, r == null ? void 0 : r.guid);
|
|
2437
2446
|
const i = {
|
|
2438
|
-
guid:
|
|
2447
|
+
guid: Qt(),
|
|
2439
2448
|
...r ? { parents: [r.guid] } : {},
|
|
2440
2449
|
author: t.author,
|
|
2441
2450
|
source: t.source,
|
|
@@ -2446,8 +2455,8 @@ class zs {
|
|
|
2446
2455
|
changes: t.changes,
|
|
2447
2456
|
counts: Qs(t.changes)
|
|
2448
2457
|
};
|
|
2449
|
-
if (t.model && (await a(this,
|
|
2450
|
-
const u = await a(this,
|
|
2458
|
+
if (t.model && (await a(this, y, Je).call(this, e, t.model), i.full = !0), t.delta) {
|
|
2459
|
+
const u = await a(this, y, kt).call(this);
|
|
2451
2460
|
if (!u)
|
|
2452
2461
|
throw new Error(
|
|
2453
2462
|
"A delta needs the model file to hang from: sync a full model first."
|
|
@@ -2460,20 +2469,20 @@ class zs {
|
|
|
2460
2469
|
f._id ?? f.id
|
|
2461
2470
|
);
|
|
2462
2471
|
}
|
|
2463
|
-
const o = await a(this,
|
|
2472
|
+
const o = await a(this, y, Ot).call(this);
|
|
2464
2473
|
if (o) {
|
|
2465
2474
|
s = o;
|
|
2466
2475
|
const u = Oe(s.commits);
|
|
2467
2476
|
if (t.expectedLatestGuid !== void 0 && (u == null ? void 0 : u.guid) !== t.expectedLatestGuid)
|
|
2468
|
-
throw new
|
|
2477
|
+
throw new Te(t.expectedLatestGuid, u == null ? void 0 : u.guid);
|
|
2469
2478
|
u && !i.parents && (i.parents = [u.guid]);
|
|
2470
2479
|
}
|
|
2471
|
-
return s.commits.push(i), await a(this,
|
|
2480
|
+
return s.commits.push(i), await a(this, y, At).call(this, e, Yt, s), i;
|
|
2472
2481
|
}
|
|
2473
2482
|
// ─── Suggestions (change requests) ────────────────────────────────────────
|
|
2474
2483
|
/** Every suggestion in the document's queue, pending or resolved. */
|
|
2475
2484
|
async suggestions() {
|
|
2476
|
-
const t = await a(this,
|
|
2485
|
+
const t = await a(this, y, ht).call(this);
|
|
2477
2486
|
return (t == null ? void 0 : t.ops) ?? [];
|
|
2478
2487
|
}
|
|
2479
2488
|
/** The suggestions still waiting for the owner, oldest first. */
|
|
@@ -2485,8 +2494,8 @@ class zs {
|
|
|
2485
2494
|
* uploaded as a hidden file under the suggestions index.
|
|
2486
2495
|
*/
|
|
2487
2496
|
async suggest(t) {
|
|
2488
|
-
const e = await a(this,
|
|
2489
|
-
opId: t.opId ??
|
|
2497
|
+
const e = await a(this, y, ct).call(this, !0), s = await a(this, y, ht).call(this) ?? { schema: ke, ops: [] }, r = await a(this, y, St).call(this, z), i = {
|
|
2498
|
+
opId: t.opId ?? Qt(),
|
|
2490
2499
|
title: t.title,
|
|
2491
2500
|
verb: t.verb,
|
|
2492
2501
|
author: t.author,
|
|
@@ -2498,7 +2507,7 @@ class zs {
|
|
|
2498
2507
|
...t.baseCommitGuid ? { baseCommitGuid: t.baseCommitGuid } : {}
|
|
2499
2508
|
};
|
|
2500
2509
|
if (t.payload) {
|
|
2501
|
-
const h = r ?? await a(this,
|
|
2510
|
+
const h = r ?? await a(this, y, zt).call(this, e, z, s), u = await this.client.createHiddenFile(
|
|
2502
2511
|
t.payload,
|
|
2503
2512
|
h.id
|
|
2504
2513
|
);
|
|
@@ -2506,8 +2515,8 @@ class zs {
|
|
|
2506
2515
|
u._id ?? u.id
|
|
2507
2516
|
);
|
|
2508
2517
|
}
|
|
2509
|
-
const o = await a(this,
|
|
2510
|
-
return o.schema ?? (o.schema = ke), o.ops.push(i), await a(this,
|
|
2518
|
+
const o = await a(this, y, ht).call(this) ?? s;
|
|
2519
|
+
return o.schema ?? (o.schema = ke), o.ops.push(i), await a(this, y, At).call(this, e, z, o), i;
|
|
2511
2520
|
}
|
|
2512
2521
|
/** A suggestion's .frag payload. */
|
|
2513
2522
|
async suggestionPayload(t) {
|
|
@@ -2521,15 +2530,15 @@ class zs {
|
|
|
2521
2530
|
* use it for `discarded`.
|
|
2522
2531
|
*/
|
|
2523
2532
|
async resolveSuggestion(t, e) {
|
|
2524
|
-
const s = await a(this,
|
|
2533
|
+
const s = await a(this, y, ct).call(this, !1);
|
|
2525
2534
|
if (!s) throw new Error("This document has no suggestion queue.");
|
|
2526
|
-
const r = await a(this,
|
|
2535
|
+
const r = await a(this, y, ht).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === t);
|
|
2527
2536
|
if (!r || !i)
|
|
2528
2537
|
throw new Error(`No suggestion ${t} in this document's queue.`);
|
|
2529
|
-
return Object.assign(i, e), await a(this,
|
|
2538
|
+
return Object.assign(i, e), await a(this, y, At).call(this, s, z, r), i;
|
|
2530
2539
|
}
|
|
2531
2540
|
}
|
|
2532
|
-
L = new WeakMap(),
|
|
2541
|
+
L = new WeakMap(), y = new WeakSet(), at = function() {
|
|
2533
2542
|
return `${this.source}-${this.docId}`;
|
|
2534
2543
|
}, ct = async function(t) {
|
|
2535
2544
|
if (l(this, L)) return l(this, L);
|
|
@@ -2541,86 +2550,86 @@ L = new WeakMap(), p = new WeakSet(), at = function() {
|
|
|
2541
2550
|
const s = await this.client.listFolders({
|
|
2542
2551
|
parentFolderId: e,
|
|
2543
2552
|
projectId: this.project.projectId
|
|
2544
|
-
}), r =
|
|
2545
|
-
(o) => String(o.name ?? "") === l(this,
|
|
2553
|
+
}), r = Ve(s, e).find(
|
|
2554
|
+
(o) => String(o.name ?? "") === l(this, y, at)
|
|
2546
2555
|
);
|
|
2547
2556
|
if (r)
|
|
2548
|
-
return
|
|
2557
|
+
return _(this, L, j(r)), l(this, L);
|
|
2549
2558
|
if (!t)
|
|
2550
2559
|
throw new Error(
|
|
2551
|
-
`Document ${l(this,
|
|
2560
|
+
`Document ${l(this, y, at)} does not exist in this project.`
|
|
2552
2561
|
);
|
|
2553
2562
|
const i = await this.client.createFolder(
|
|
2554
|
-
l(this,
|
|
2563
|
+
l(this, y, at),
|
|
2555
2564
|
e,
|
|
2556
2565
|
this.project.projectId
|
|
2557
2566
|
);
|
|
2558
|
-
return
|
|
2559
|
-
},
|
|
2560
|
-
const t = await a(this,
|
|
2567
|
+
return _(this, L, j(i)), l(this, L);
|
|
2568
|
+
}, Kt = async function() {
|
|
2569
|
+
const t = await a(this, y, ct).call(this, !1);
|
|
2561
2570
|
return (await this.client.listFiles({ folderId: t })).map((s) => ({
|
|
2562
|
-
id:
|
|
2571
|
+
id: j(s),
|
|
2563
2572
|
name: String(s.name ?? "")
|
|
2564
2573
|
}));
|
|
2565
2574
|
}, St = async function(t) {
|
|
2566
2575
|
try {
|
|
2567
|
-
return (await a(this,
|
|
2576
|
+
return (await a(this, y, Kt).call(this)).find((e) => e.name === t);
|
|
2568
2577
|
} catch {
|
|
2569
2578
|
return;
|
|
2570
2579
|
}
|
|
2571
2580
|
}, kt = async function() {
|
|
2572
2581
|
try {
|
|
2573
|
-
const t = await a(this,
|
|
2574
|
-
return t.find((e) => e.name ===
|
|
2575
|
-
(e) => e.name.endsWith(".frag") && !e.name.startsWith(
|
|
2582
|
+
const t = await a(this, y, Kt).call(this);
|
|
2583
|
+
return t.find((e) => e.name === He) ?? t.find(
|
|
2584
|
+
(e) => e.name.endsWith(".frag") && !e.name.startsWith(Ge)
|
|
2576
2585
|
);
|
|
2577
2586
|
} catch {
|
|
2578
2587
|
return;
|
|
2579
2588
|
}
|
|
2580
|
-
},
|
|
2581
|
-
const e = await a(this,
|
|
2589
|
+
}, Xt = async function(t) {
|
|
2590
|
+
const e = await a(this, y, St).call(this, t);
|
|
2582
2591
|
if (!e) return;
|
|
2583
2592
|
const r = await (await this.client.downloadFile(e.id)).text();
|
|
2584
2593
|
if (r.trim())
|
|
2585
2594
|
return JSON.parse(r);
|
|
2586
2595
|
}, Ot = function() {
|
|
2587
|
-
return a(this,
|
|
2596
|
+
return a(this, y, Xt).call(this, Yt);
|
|
2588
2597
|
}, ht = function() {
|
|
2589
|
-
return a(this,
|
|
2598
|
+
return a(this, y, Xt).call(this, z);
|
|
2590
2599
|
}, At = async function(t, e, s) {
|
|
2591
2600
|
const r = new Blob([JSON.stringify(s)], {
|
|
2592
2601
|
type: "application/json"
|
|
2593
|
-
}), i = await a(this,
|
|
2602
|
+
}), i = await a(this, y, St).call(this, e);
|
|
2594
2603
|
return i ? (await this.client.updateFile(i.id, {
|
|
2595
2604
|
file: r,
|
|
2596
|
-
versionTag:
|
|
2597
|
-
}), i) : await a(this,
|
|
2598
|
-
},
|
|
2605
|
+
versionTag: _t()
|
|
2606
|
+
}), i) : await a(this, y, zt).call(this, t, e, s);
|
|
2607
|
+
}, zt = async function(t, e, s) {
|
|
2599
2608
|
const r = new Blob([JSON.stringify(s)], {
|
|
2600
2609
|
type: "application/json"
|
|
2601
2610
|
}), i = await this.client.createFile({
|
|
2602
2611
|
file: r,
|
|
2603
2612
|
name: e,
|
|
2604
|
-
versionTag:
|
|
2613
|
+
versionTag: _t(),
|
|
2605
2614
|
parentFolderId: t,
|
|
2606
2615
|
projectId: this.project.projectId
|
|
2607
2616
|
}), o = i.item;
|
|
2608
|
-
return { id:
|
|
2609
|
-
},
|
|
2610
|
-
const s = await a(this,
|
|
2617
|
+
return { id: j(o ?? i), name: e };
|
|
2618
|
+
}, Je = async function(t, e) {
|
|
2619
|
+
const s = await a(this, y, kt).call(this);
|
|
2611
2620
|
if (s)
|
|
2612
2621
|
return await this.client.updateFile(s.id, {
|
|
2613
2622
|
file: e,
|
|
2614
|
-
versionTag:
|
|
2623
|
+
versionTag: _t()
|
|
2615
2624
|
}), s;
|
|
2616
|
-
const r = `${l(this,
|
|
2625
|
+
const r = `${l(this, y, at)}.frag`, i = await this.client.createFile({
|
|
2617
2626
|
file: e,
|
|
2618
2627
|
name: r,
|
|
2619
|
-
versionTag:
|
|
2628
|
+
versionTag: _t(),
|
|
2620
2629
|
parentFolderId: t,
|
|
2621
2630
|
projectId: this.project.projectId
|
|
2622
2631
|
}), o = i.item;
|
|
2623
|
-
return { id:
|
|
2632
|
+
return { id: j(o ?? i), name: r };
|
|
2624
2633
|
};
|
|
2625
2634
|
function Qs(n) {
|
|
2626
2635
|
const t = { added: 0, modified: 0, removed: 0 };
|
|
@@ -2628,76 +2637,99 @@ function Qs(n) {
|
|
|
2628
2637
|
e.type === "create" ? t.added++ : e.type === "delete" ? t.removed++ : t.modified++;
|
|
2629
2638
|
return t;
|
|
2630
2639
|
}
|
|
2631
|
-
function
|
|
2640
|
+
function Ye(n) {
|
|
2632
2641
|
var u;
|
|
2633
2642
|
if (n.length <= 1)
|
|
2634
|
-
return n.forEach((f,
|
|
2643
|
+
return n.forEach((f, p) => f.ordinal = p), [...n];
|
|
2635
2644
|
const t = new Map(n.map((f) => [f.guid, f])), e = /* @__PURE__ */ new Map(), s = [];
|
|
2636
2645
|
for (const f of n) {
|
|
2637
|
-
const
|
|
2638
|
-
if (
|
|
2639
|
-
const w = e.get(
|
|
2640
|
-
w.push(f), e.set(
|
|
2646
|
+
const p = (u = f.parents) == null ? void 0 : u[0];
|
|
2647
|
+
if (p && t.has(p)) {
|
|
2648
|
+
const w = e.get(p) ?? [];
|
|
2649
|
+
w.push(f), e.set(p, w);
|
|
2641
2650
|
} else
|
|
2642
2651
|
s.push(f);
|
|
2643
2652
|
}
|
|
2644
|
-
const r = (f,
|
|
2653
|
+
const r = (f, p) => String(f.timestamp).localeCompare(String(p.timestamp));
|
|
2645
2654
|
s.sort(r);
|
|
2646
2655
|
const i = [], o = [...s].reverse(), h = /* @__PURE__ */ new Set();
|
|
2647
2656
|
for (; o.length; ) {
|
|
2648
2657
|
const f = o.pop();
|
|
2649
2658
|
if (h.has(f.guid)) continue;
|
|
2650
2659
|
h.add(f.guid), i.push(f);
|
|
2651
|
-
const
|
|
2652
|
-
for (let w =
|
|
2660
|
+
const p = (e.get(f.guid) ?? []).sort(r);
|
|
2661
|
+
for (let w = p.length - 1; w >= 0; w--) o.push(p[w]);
|
|
2653
2662
|
}
|
|
2654
2663
|
for (const f of n)
|
|
2655
2664
|
h.has(f.guid) || i.push(f);
|
|
2656
|
-
return i.forEach((f,
|
|
2665
|
+
return i.forEach((f, p) => f.ordinal = p), i;
|
|
2657
2666
|
}
|
|
2658
2667
|
function Oe(n) {
|
|
2659
|
-
const t =
|
|
2668
|
+
const t = Ye(n);
|
|
2660
2669
|
return t[t.length - 1];
|
|
2661
2670
|
}
|
|
2662
|
-
function
|
|
2671
|
+
function Qt() {
|
|
2663
2672
|
const n = globalThis.crypto;
|
|
2664
2673
|
return n != null && n.randomUUID ? n.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
|
|
2665
2674
|
const e = Math.random() * 16 | 0;
|
|
2666
2675
|
return (t === "x" ? e : e & 3 | 8).toString(16);
|
|
2667
2676
|
});
|
|
2668
2677
|
}
|
|
2669
|
-
var
|
|
2678
|
+
var M, ft, Zt;
|
|
2670
2679
|
class Zs {
|
|
2671
2680
|
constructor(t) {
|
|
2672
|
-
|
|
2673
|
-
|
|
2681
|
+
b(this, ft);
|
|
2682
|
+
b(this, M, /* @__PURE__ */ new Map());
|
|
2674
2683
|
this.client = t;
|
|
2675
2684
|
}
|
|
2676
2685
|
/** Registers a recipe. One per name; a second with the same name throws. */
|
|
2677
2686
|
register(t) {
|
|
2678
|
-
if (l(this,
|
|
2687
|
+
if (l(this, M).has(t.name))
|
|
2679
2688
|
throw new Error(`A recipe named "${t.name}" is already registered.`);
|
|
2680
|
-
l(this,
|
|
2689
|
+
l(this, M).set(t.name, t);
|
|
2681
2690
|
}
|
|
2682
2691
|
/** The registered recipes, optionally filtered by target application. */
|
|
2683
2692
|
list(t) {
|
|
2684
|
-
return [...l(this,
|
|
2693
|
+
return [...l(this, M).values()].filter(
|
|
2685
2694
|
(s) => (!(t != null && t.to) || s.to === t.to) && (!(t != null && t.input) || s.inputs.includes(t.input))
|
|
2686
2695
|
);
|
|
2687
2696
|
}
|
|
2688
2697
|
/** A registered recipe by name, or undefined. */
|
|
2689
2698
|
get(t) {
|
|
2690
|
-
return l(this,
|
|
2699
|
+
return l(this, M).get(t);
|
|
2691
2700
|
}
|
|
2692
2701
|
/**
|
|
2693
|
-
* Runs a recipe WITHOUT queueing anything: the dry pass. Returns
|
|
2694
|
-
*
|
|
2695
|
-
*
|
|
2696
|
-
*
|
|
2702
|
+
* Runs a recipe WITHOUT queueing anything: the dry pass. Returns a
|
|
2703
|
+
* {@link RecipePlan} — the result to show (title, tallies, targets) plus
|
|
2704
|
+
* everything {@link queue} needs to queue EXACTLY this, payload and opId
|
|
2705
|
+
* included, with no second run. Discard it and the plan never happened.
|
|
2697
2706
|
*/
|
|
2698
2707
|
async plan(t, e) {
|
|
2699
|
-
const {
|
|
2700
|
-
return
|
|
2708
|
+
const { base: s, opId: r, result: i } = await a(this, ft, Zt).call(this, t, e);
|
|
2709
|
+
return {
|
|
2710
|
+
opId: r,
|
|
2711
|
+
projectId: e.projectId,
|
|
2712
|
+
target: e.target,
|
|
2713
|
+
...s != null && s.guid ? { baseCommitGuid: s.guid } : {},
|
|
2714
|
+
result: i
|
|
2715
|
+
};
|
|
2716
|
+
}
|
|
2717
|
+
/**
|
|
2718
|
+
* Queues exactly what {@link plan} planned: same opId, same payload, no
|
|
2719
|
+
* second execution. The pair plan → confirm → queue is the UI flow; `run`
|
|
2720
|
+
* is the one-shot shortcut.
|
|
2721
|
+
*/
|
|
2722
|
+
async queue(t, e) {
|
|
2723
|
+
return { suggestion: await this.client.history(t.projectId).doc(t.target.source, t.target.docId).suggest({
|
|
2724
|
+
opId: t.opId,
|
|
2725
|
+
title: t.result.title,
|
|
2726
|
+
verb: t.result.verb,
|
|
2727
|
+
author: e.author,
|
|
2728
|
+
payload: t.result.payload,
|
|
2729
|
+
targets: t.result.targets,
|
|
2730
|
+
userId: e.userId,
|
|
2731
|
+
baseCommitGuid: t.baseCommitGuid
|
|
2732
|
+
}), result: t.result };
|
|
2701
2733
|
}
|
|
2702
2734
|
/**
|
|
2703
2735
|
* Runs a recipe and queues its suggestion on the target document. Safe to
|
|
@@ -2706,7 +2738,7 @@ class Zs {
|
|
|
2706
2738
|
* to show the tallies before queueing.
|
|
2707
2739
|
*/
|
|
2708
2740
|
async run(t, e) {
|
|
2709
|
-
const { targetDoc: s, base: r, opId: i, result: o } = await a(this, ft,
|
|
2741
|
+
const { targetDoc: s, base: r, opId: i, result: o } = await a(this, ft, Zt).call(this, t, e);
|
|
2710
2742
|
return { suggestion: await s.suggest({
|
|
2711
2743
|
opId: i,
|
|
2712
2744
|
title: o.title,
|
|
@@ -2719,14 +2751,14 @@ class Zs {
|
|
|
2719
2751
|
}), result: o };
|
|
2720
2752
|
}
|
|
2721
2753
|
}
|
|
2722
|
-
|
|
2723
|
-
const s = l(this,
|
|
2754
|
+
M = new WeakMap(), ft = new WeakSet(), Zt = async function(t, e) {
|
|
2755
|
+
const s = l(this, M).get(t);
|
|
2724
2756
|
if (!s) throw new Error(`No recipe named "${t}" is registered.`);
|
|
2725
2757
|
if (s.to !== e.target.source)
|
|
2726
2758
|
throw new Error(
|
|
2727
2759
|
`Recipe "${t}" writes ${s.to}, but the target document belongs to ${e.target.source}.`
|
|
2728
2760
|
);
|
|
2729
|
-
const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o =
|
|
2761
|
+
const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o = Qt(), h = await s.run({
|
|
2730
2762
|
client: this.client,
|
|
2731
2763
|
projectId: e.projectId,
|
|
2732
2764
|
targetDoc: r,
|
|
@@ -2757,7 +2789,7 @@ function en(n) {
|
|
|
2757
2789
|
const t = n.retryAfter;
|
|
2758
2790
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
|
|
2759
2791
|
}
|
|
2760
|
-
class
|
|
2792
|
+
class pe extends Error {
|
|
2761
2793
|
constructor(e, s, r, i) {
|
|
2762
2794
|
const o = tn(r);
|
|
2763
2795
|
super(o.message ?? `${s || "Request failed"} (${e})`);
|
|
@@ -2773,7 +2805,7 @@ class fe extends Error {
|
|
|
2773
2805
|
this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? en(o.details);
|
|
2774
2806
|
}
|
|
2775
2807
|
}
|
|
2776
|
-
const
|
|
2808
|
+
const R = "item/folder", m = "item", U = "processor", sn = "npm-registry", B = "hidden", Ft = "FILE", Ut = "TOOL", Dt = "APP", nn = 500, Ie = 3e4, rn = 0.25, on = (n) => new Promise((t) => setTimeout(t, n));
|
|
2777
2809
|
function an(n) {
|
|
2778
2810
|
var r, i;
|
|
2779
2811
|
const t = (i = (r = n.headers) == null ? void 0 : r.get) == null ? void 0 : i.call(r, "Retry-After");
|
|
@@ -2785,17 +2817,17 @@ function an(n) {
|
|
|
2785
2817
|
return Math.max(0, (s - Date.now()) / 1e3);
|
|
2786
2818
|
}
|
|
2787
2819
|
function cn(n) {
|
|
2788
|
-
return n instanceof
|
|
2820
|
+
return n instanceof pe ? n.status === 429 || n.status >= 500 : !0;
|
|
2789
2821
|
}
|
|
2790
2822
|
function hn(n, t) {
|
|
2791
2823
|
const e = Math.min(
|
|
2792
2824
|
nn * 2 ** t,
|
|
2793
2825
|
Ie
|
|
2794
|
-
), s = e * rn * Math.random(), r = n instanceof
|
|
2826
|
+
), s = e * rn * Math.random(), r = n instanceof pe && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
|
|
2795
2827
|
return r != null ? Math.min(r, Ie) + s : e + s;
|
|
2796
2828
|
}
|
|
2797
|
-
var c,
|
|
2798
|
-
const
|
|
2829
|
+
var c, ee, d, D, pt, lt, It, xt, se, ne, We;
|
|
2830
|
+
const ye = class ye {
|
|
2799
2831
|
/**
|
|
2800
2832
|
* Creates a new EngineServicesClient instance.
|
|
2801
2833
|
* @param accessToken - API access token (obtained from the platform dashboard)
|
|
@@ -2804,7 +2836,7 @@ const pe = class pe {
|
|
|
2804
2836
|
* @param props - Optional configuration (retry count, auth mode, etc.).
|
|
2805
2837
|
*/
|
|
2806
2838
|
constructor(t, e, s) {
|
|
2807
|
-
|
|
2839
|
+
b(this, c);
|
|
2808
2840
|
T(this, "apiUrl");
|
|
2809
2841
|
T(this, "accessToken");
|
|
2810
2842
|
T(this, "wsUrl");
|
|
@@ -2823,7 +2855,7 @@ const pe = class pe {
|
|
|
2823
2855
|
* Populated automatically when using {@link fromPlatformContext}.
|
|
2824
2856
|
*/
|
|
2825
2857
|
T(this, "context");
|
|
2826
|
-
|
|
2858
|
+
b(this, pt);
|
|
2827
2859
|
const { retries: r = 0, useBearer: i = !1, localServerUrl: o } = s || {};
|
|
2828
2860
|
let h = e;
|
|
2829
2861
|
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) {
|
|
@@ -2848,7 +2880,7 @@ const pe = class pe {
|
|
|
2848
2880
|
* ```
|
|
2849
2881
|
*/
|
|
2850
2882
|
static fromPlatformContext(t) {
|
|
2851
|
-
const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new
|
|
2883
|
+
const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new ye(e.accessToken, e.apiUrl, {
|
|
2852
2884
|
...t,
|
|
2853
2885
|
useBearer: !0
|
|
2854
2886
|
});
|
|
@@ -2934,7 +2966,7 @@ const pe = class pe {
|
|
|
2934
2966
|
*/
|
|
2935
2967
|
async listFiles(t) {
|
|
2936
2968
|
const { folderId: e, archived: s, projectId: r } = t || {};
|
|
2937
|
-
return e ? await a(this, c, d).call(this, "GET", `${
|
|
2969
|
+
return e ? await a(this, c, d).call(this, "GET", `${R}/${e}/items`, { query: { itemType: Ft, archived: s } }) : await a(this, c, d).call(this, "GET", `${m}`, {
|
|
2938
2970
|
query: {
|
|
2939
2971
|
itemType: Ft,
|
|
2940
2972
|
archived: s,
|
|
@@ -2949,7 +2981,7 @@ const pe = class pe {
|
|
|
2949
2981
|
* @returns The file item, optionally with version history.
|
|
2950
2982
|
*/
|
|
2951
2983
|
async getFile(t, e) {
|
|
2952
|
-
return await a(this, c,
|
|
2984
|
+
return await a(this, c, ne).call(this, t, e);
|
|
2953
2985
|
}
|
|
2954
2986
|
/**
|
|
2955
2987
|
* Uploads a new file.
|
|
@@ -2967,7 +2999,7 @@ const pe = class pe {
|
|
|
2967
2999
|
* @returns The updated item and/or the new version.
|
|
2968
3000
|
*/
|
|
2969
3001
|
async updateFile(t, e) {
|
|
2970
|
-
return await a(this, c,
|
|
3002
|
+
return await a(this, c, se).call(this, t, e);
|
|
2971
3003
|
}
|
|
2972
3004
|
/**
|
|
2973
3005
|
* Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
|
|
@@ -3058,7 +3090,7 @@ const pe = class pe {
|
|
|
3058
3090
|
*/
|
|
3059
3091
|
async listFolders(t) {
|
|
3060
3092
|
const { archived: e, parentFolderId: s, projectId: r } = t || {};
|
|
3061
|
-
return await a(this, c, d).call(this, "GET",
|
|
3093
|
+
return await a(this, c, d).call(this, "GET", R, {
|
|
3062
3094
|
query: {
|
|
3063
3095
|
parentFolderId: s,
|
|
3064
3096
|
archived: e,
|
|
@@ -3071,7 +3103,7 @@ const pe = class pe {
|
|
|
3071
3103
|
* @param folderId - The folder's unique identifier.
|
|
3072
3104
|
*/
|
|
3073
3105
|
async getFolder(t) {
|
|
3074
|
-
return await a(this, c, d).call(this, "GET", `${
|
|
3106
|
+
return await a(this, c, d).call(this, "GET", `${R}/${t}`);
|
|
3075
3107
|
}
|
|
3076
3108
|
/**
|
|
3077
3109
|
* Batch variant of {@link getFolder}. Resolves a known set of folder ids in
|
|
@@ -3099,7 +3131,7 @@ const pe = class pe {
|
|
|
3099
3131
|
* @returns The created folder.
|
|
3100
3132
|
*/
|
|
3101
3133
|
async createFolder(t, e, s) {
|
|
3102
|
-
return await a(this, c, d).call(this, "POST",
|
|
3134
|
+
return await a(this, c, d).call(this, "POST", R, {
|
|
3103
3135
|
body: JSON.stringify({
|
|
3104
3136
|
name: t,
|
|
3105
3137
|
...e && { parentId: e },
|
|
@@ -3116,7 +3148,7 @@ const pe = class pe {
|
|
|
3116
3148
|
*/
|
|
3117
3149
|
async updateFolder(t, e) {
|
|
3118
3150
|
const { name: s } = e;
|
|
3119
|
-
return await a(this, c, d).call(this, "PUT", `${
|
|
3151
|
+
return await a(this, c, d).call(this, "PUT", `${R}/${t}`, {
|
|
3120
3152
|
body: JSON.stringify({ name: s }),
|
|
3121
3153
|
contentType: "application/json"
|
|
3122
3154
|
});
|
|
@@ -3126,14 +3158,14 @@ const pe = class pe {
|
|
|
3126
3158
|
* @param folderId - The folder's unique identifier.
|
|
3127
3159
|
*/
|
|
3128
3160
|
async archiveFolder(t) {
|
|
3129
|
-
return await a(this, c, d).call(this, "DELETE", `${
|
|
3161
|
+
return await a(this, c, d).call(this, "DELETE", `${R}/${t}`);
|
|
3130
3162
|
}
|
|
3131
3163
|
/**
|
|
3132
3164
|
* Recovers a previously archived folder.
|
|
3133
3165
|
* @param folderId - The folder's unique identifier.
|
|
3134
3166
|
*/
|
|
3135
3167
|
async recoverFolder(t) {
|
|
3136
|
-
return await a(this, c, d).call(this, "PUT", `${
|
|
3168
|
+
return await a(this, c, d).call(this, "PUT", `${R}/${t}/recover`);
|
|
3137
3169
|
}
|
|
3138
3170
|
/**
|
|
3139
3171
|
* Downloads an entire folder as a ZIP archive.
|
|
@@ -3141,7 +3173,7 @@ const pe = class pe {
|
|
|
3141
3173
|
* @returns A fetch Response containing the ZIP data.
|
|
3142
3174
|
*/
|
|
3143
3175
|
async downloadFolder(t) {
|
|
3144
|
-
return await a(this, c, D).call(this, `${
|
|
3176
|
+
return await a(this, c, D).call(this, `${R}/${t}/download`);
|
|
3145
3177
|
}
|
|
3146
3178
|
// ─── Components ──────────────────────────────────────────────────
|
|
3147
3179
|
/**
|
|
@@ -3151,7 +3183,7 @@ const pe = class pe {
|
|
|
3151
3183
|
*/
|
|
3152
3184
|
async listComponents(t) {
|
|
3153
3185
|
const { folderId: e, ShowVersions: s, projectId: r } = t || {};
|
|
3154
|
-
return e ? await a(this, c, d).call(this, "GET", `${
|
|
3186
|
+
return e ? await a(this, c, d).call(this, "GET", `${R}/${e}/items`, {
|
|
3155
3187
|
query: {
|
|
3156
3188
|
itemType: Ut,
|
|
3157
3189
|
...s && { ShowVersions: s }
|
|
@@ -3170,7 +3202,7 @@ const pe = class pe {
|
|
|
3170
3202
|
* @param props - Options such as whether to include versions.
|
|
3171
3203
|
*/
|
|
3172
3204
|
async getComponent(t, e) {
|
|
3173
|
-
return await a(this, c,
|
|
3205
|
+
return await a(this, c, ne).call(this, t, e);
|
|
3174
3206
|
}
|
|
3175
3207
|
/**
|
|
3176
3208
|
* Creates a new component with the given file and version properties.
|
|
@@ -3189,7 +3221,7 @@ const pe = class pe {
|
|
|
3189
3221
|
*/
|
|
3190
3222
|
async updateComponent(t, e) {
|
|
3191
3223
|
const { componentProps: s } = e;
|
|
3192
|
-
return await a(this, c,
|
|
3224
|
+
return await a(this, c, se).call(this, t, e, s);
|
|
3193
3225
|
}
|
|
3194
3226
|
/**
|
|
3195
3227
|
* Downloads a component's full ZIP file. Returns the raw fetch Response.
|
|
@@ -3267,8 +3299,8 @@ const pe = class pe {
|
|
|
3267
3299
|
*/
|
|
3268
3300
|
async initBuiltInComponent(t, e, s) {
|
|
3269
3301
|
const r = await this.getBuiltInComponent(t.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), h = o.map((w) => i[w]), f = new Function(...o, `${r}
|
|
3270
|
-
return main;`)(...h),
|
|
3271
|
-
e.get(
|
|
3302
|
+
return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
3303
|
+
e.get(p);
|
|
3272
3304
|
}
|
|
3273
3305
|
/**
|
|
3274
3306
|
* Loads multiple built-in components in parallel.
|
|
@@ -3335,7 +3367,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3335
3367
|
*/
|
|
3336
3368
|
async listApps(t) {
|
|
3337
3369
|
const { folderId: e, ShowVersions: s, projectId: r } = t || {};
|
|
3338
|
-
return e ? await a(this, c, d).call(this, "GET", `${
|
|
3370
|
+
return e ? await a(this, c, d).call(this, "GET", `${R}/${e}/items`, {
|
|
3339
3371
|
query: {
|
|
3340
3372
|
itemType: Dt,
|
|
3341
3373
|
...s && { ShowVersions: s }
|
|
@@ -3532,7 +3564,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3532
3564
|
* native application's language. See `src/core/recipes.ts`.
|
|
3533
3565
|
*/
|
|
3534
3566
|
get recipes() {
|
|
3535
|
-
return l(this, pt) ??
|
|
3567
|
+
return l(this, pt) ?? _(this, pt, new Zs(this)), l(this, pt);
|
|
3536
3568
|
}
|
|
3537
3569
|
// ─── Hidden Files ────────────────────────────────────────────────
|
|
3538
3570
|
/**
|
|
@@ -3776,29 +3808,29 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3776
3808
|
return await a(this, c, d).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
|
|
3777
3809
|
}
|
|
3778
3810
|
};
|
|
3779
|
-
c = new WeakSet(),
|
|
3811
|
+
c = new WeakSet(), ee = function(t) {
|
|
3780
3812
|
return `${this.apiUrl}/${t}`;
|
|
3781
3813
|
}, d = async function(t, e, s) {
|
|
3782
|
-
const { body: r, query: i, contentType: o, retries: h, responseType: u, retryAttempt: f } = s || {},
|
|
3814
|
+
const { body: r, query: i, contentType: o, retries: h, responseType: u, retryAttempt: f } = s || {}, p = a(this, c, ee).call(this, e), w = a(this, c, We).call(this, i), C = await this.resolveAccessToken(), ts = {
|
|
3783
3815
|
...w,
|
|
3784
|
-
...this.useBearer ? {} : { accessToken:
|
|
3816
|
+
...this.useBearer ? {} : { accessToken: C }
|
|
3785
3817
|
};
|
|
3786
3818
|
try {
|
|
3787
3819
|
const I = await fetch(
|
|
3788
|
-
|
|
3820
|
+
p + "?" + new URLSearchParams(ts).toString(),
|
|
3789
3821
|
{
|
|
3790
3822
|
method: t,
|
|
3791
3823
|
headers: {
|
|
3792
3824
|
Accept: "application/json",
|
|
3793
3825
|
...o && { "Content-Type": o },
|
|
3794
|
-
...this.useBearer && { Authorization: `Bearer ${
|
|
3826
|
+
...this.useBearer && { Authorization: `Bearer ${C}` }
|
|
3795
3827
|
},
|
|
3796
3828
|
...r && { body: r }
|
|
3797
3829
|
}
|
|
3798
3830
|
);
|
|
3799
3831
|
if (!I.ok) {
|
|
3800
3832
|
const K = await I.text().then((gt) => gt).catch(() => "");
|
|
3801
|
-
throw new
|
|
3833
|
+
throw new pe(
|
|
3802
3834
|
I.status,
|
|
3803
3835
|
I.statusText,
|
|
3804
3836
|
K,
|
|
@@ -3820,7 +3852,7 @@ c = new WeakSet(), te = function(t) {
|
|
|
3820
3852
|
throw I;
|
|
3821
3853
|
}
|
|
3822
3854
|
}, D = async function(t, e) {
|
|
3823
|
-
const { query: s } = e || {}, r = a(this, c,
|
|
3855
|
+
const { query: s } = e || {}, r = a(this, c, ee).call(this, t), i = await this.resolveAccessToken(), o = {
|
|
3824
3856
|
...s,
|
|
3825
3857
|
...this.useBearer ? {} : { accessToken: i }
|
|
3826
3858
|
};
|
|
@@ -3848,16 +3880,16 @@ c = new WeakSet(), te = function(t) {
|
|
|
3848
3880
|
}
|
|
3849
3881
|
});
|
|
3850
3882
|
}, xt = async function(t, e, s) {
|
|
3851
|
-
const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: u, metadata: f } = t,
|
|
3852
|
-
return
|
|
3853
|
-
body:
|
|
3883
|
+
const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: u, metadata: f } = t, p = new FormData();
|
|
3884
|
+
return p.append("file", u), p.append("name", r), p.append("versionTag", i), p.append("itemType", e), o && p.append("folderId", o), h && p.append("projectId", h), s && p.append("extraProps", JSON.stringify(s)), f && p.append("metadata", JSON.stringify(f)), await a(this, c, d).call(this, "POST", m, {
|
|
3885
|
+
body: p
|
|
3854
3886
|
});
|
|
3855
|
-
},
|
|
3887
|
+
}, se = async function(t, e, s) {
|
|
3856
3888
|
const { name: r, versionTag: i, parentFolderId: o, file: h, metadata: u } = e;
|
|
3857
|
-
let f,
|
|
3889
|
+
let f, p;
|
|
3858
3890
|
if (h) {
|
|
3859
3891
|
const w = new FormData();
|
|
3860
|
-
w.append("file", h), i && w.append("versionTag", i), s && w.append("extraProps", JSON.stringify(s)), u && w.append("metadata", JSON.stringify(u)),
|
|
3892
|
+
w.append("file", h), i && w.append("versionTag", i), s && w.append("extraProps", JSON.stringify(s)), u && w.append("metadata", JSON.stringify(u)), p = await a(this, c, d).call(this, "POST", `${m}/${t}/version`, {
|
|
3861
3893
|
body: w
|
|
3862
3894
|
});
|
|
3863
3895
|
}
|
|
@@ -3865,25 +3897,25 @@ c = new WeakSet(), te = function(t) {
|
|
|
3865
3897
|
const w = {
|
|
3866
3898
|
...r && { name: r },
|
|
3867
3899
|
...o && { folderId: o }
|
|
3868
|
-
},
|
|
3900
|
+
}, C = JSON.stringify(w);
|
|
3869
3901
|
f = await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
|
|
3870
|
-
body:
|
|
3902
|
+
body: C,
|
|
3871
3903
|
contentType: "application/json"
|
|
3872
3904
|
});
|
|
3873
3905
|
}
|
|
3874
|
-
return { item: f, version:
|
|
3875
|
-
},
|
|
3906
|
+
return { item: f, version: p };
|
|
3907
|
+
}, ne = async function(t, e) {
|
|
3876
3908
|
const { showVersions: s = !1 } = e || {};
|
|
3877
3909
|
return await a(this, c, d).call(this, "GET", `${m}/${t}`, {
|
|
3878
3910
|
query: { showVersions: s }
|
|
3879
3911
|
});
|
|
3880
|
-
},
|
|
3912
|
+
}, We = function(t) {
|
|
3881
3913
|
return t && Object.entries(t).filter(([, e]) => e !== void 0).reduce(
|
|
3882
3914
|
(e, [s, r]) => (e[s] = r, e),
|
|
3883
3915
|
{}
|
|
3884
3916
|
);
|
|
3885
3917
|
};
|
|
3886
|
-
let
|
|
3918
|
+
let te = ye;
|
|
3887
3919
|
function ln() {
|
|
3888
3920
|
if (typeof window > "u" || window.parent === window)
|
|
3889
3921
|
throw new Error(
|
|
@@ -3899,7 +3931,7 @@ function ln() {
|
|
|
3899
3931
|
}
|
|
3900
3932
|
};
|
|
3901
3933
|
}
|
|
3902
|
-
const
|
|
3934
|
+
const re = "channel:", un = 1e4;
|
|
3903
3935
|
function $t(n) {
|
|
3904
3936
|
try {
|
|
3905
3937
|
n();
|
|
@@ -3907,16 +3939,16 @@ function $t(n) {
|
|
|
3907
3939
|
console.error("[channel] a listener threw:", t);
|
|
3908
3940
|
}
|
|
3909
3941
|
}
|
|
3910
|
-
var q, k, O,
|
|
3911
|
-
class
|
|
3942
|
+
var q, k, O, Z, tt, et, S, ie, oe, Q;
|
|
3943
|
+
class Ke {
|
|
3912
3944
|
constructor(t, e) {
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3945
|
+
b(this, S);
|
|
3946
|
+
b(this, q, !1);
|
|
3947
|
+
b(this, k, []);
|
|
3948
|
+
b(this, O, []);
|
|
3949
|
+
b(this, Z, /* @__PURE__ */ new Set());
|
|
3950
|
+
b(this, tt, /* @__PURE__ */ new Set());
|
|
3951
|
+
b(this, et, /* @__PURE__ */ new Set());
|
|
3920
3952
|
this.transport = t, this.controls = e;
|
|
3921
3953
|
}
|
|
3922
3954
|
/** Whether the platform has confirmed this tab is in the room. */
|
|
@@ -3932,47 +3964,47 @@ class Ye {
|
|
|
3932
3964
|
* refuses or does not answer in time. Joining twice is harmless.
|
|
3933
3965
|
*/
|
|
3934
3966
|
join() {
|
|
3935
|
-
return l(this, q) ? Promise.resolve() : a(this, S,
|
|
3967
|
+
return l(this, q) ? Promise.resolve() : a(this, S, ie).call(this, "joined", this.controls.join);
|
|
3936
3968
|
}
|
|
3937
3969
|
/** Leaves the room. Handlers stay registered, so `join()` resumes them. */
|
|
3938
3970
|
leave() {
|
|
3939
|
-
return !l(this, q) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S,
|
|
3971
|
+
return !l(this, q) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S, ie).call(this, "left", this.controls.leave);
|
|
3940
3972
|
}
|
|
3941
3973
|
/** Fires when `joined` or `peers` changes. Returns a function that stops it. */
|
|
3942
3974
|
onChange(t) {
|
|
3943
|
-
return l(this,
|
|
3975
|
+
return l(this, Z).add(t), () => void l(this, Z).delete(t);
|
|
3944
3976
|
}
|
|
3945
3977
|
onPeerJoined(t) {
|
|
3946
|
-
return l(this,
|
|
3978
|
+
return l(this, tt).add(t), () => void l(this, tt).delete(t);
|
|
3947
3979
|
}
|
|
3948
3980
|
onPeerLeft(t) {
|
|
3949
|
-
return l(this,
|
|
3981
|
+
return l(this, et).add(t), () => void l(this, et).delete(t);
|
|
3950
3982
|
}
|
|
3951
3983
|
/** @internal */
|
|
3952
3984
|
applyJoined() {
|
|
3953
|
-
|
|
3985
|
+
_(this, q, !0), a(this, S, oe).call(this, "joined"), a(this, S, Q).call(this);
|
|
3954
3986
|
}
|
|
3955
3987
|
/** @internal */
|
|
3956
3988
|
applyLeft() {
|
|
3957
|
-
|
|
3989
|
+
_(this, q, !1), _(this, k, []), a(this, S, oe).call(this, "left"), a(this, S, Q).call(this);
|
|
3958
3990
|
}
|
|
3959
3991
|
/** @internal */
|
|
3960
3992
|
applyPeers(t) {
|
|
3961
|
-
|
|
3993
|
+
_(this, k, t), a(this, S, Q).call(this);
|
|
3962
3994
|
}
|
|
3963
3995
|
/** @internal */
|
|
3964
3996
|
applyPeerJoined(t) {
|
|
3965
|
-
!l(this, q) || l(this, k).some((e) => e.from === t.from) || (
|
|
3997
|
+
!l(this, q) || l(this, k).some((e) => e.from === t.from) || (_(this, k, [...l(this, k), t]), l(this, tt).forEach((e) => $t(() => e(t))), a(this, S, Q).call(this));
|
|
3966
3998
|
}
|
|
3967
3999
|
/** @internal */
|
|
3968
4000
|
applyPeerLeft(t) {
|
|
3969
4001
|
const e = l(this, k).find((s) => s.from === t);
|
|
3970
|
-
e && (
|
|
4002
|
+
e && (_(this, k, l(this, k).filter((s) => s.from !== t)), l(this, et).forEach((s) => $t(() => s(e))), a(this, S, Q).call(this));
|
|
3971
4003
|
}
|
|
3972
4004
|
/** @internal */
|
|
3973
4005
|
failPending(t) {
|
|
3974
4006
|
const e = l(this, O);
|
|
3975
|
-
return
|
|
4007
|
+
return _(this, O, []), e.forEach((s) => {
|
|
3976
4008
|
clearTimeout(s.timer), s.reject(t);
|
|
3977
4009
|
}), e.length > 0;
|
|
3978
4010
|
}
|
|
@@ -3980,14 +4012,14 @@ class Ye {
|
|
|
3980
4012
|
this.transport.post(t);
|
|
3981
4013
|
}
|
|
3982
4014
|
}
|
|
3983
|
-
q = new WeakMap(), k = new WeakMap(), O = new WeakMap(),
|
|
4015
|
+
q = new WeakMap(), k = new WeakMap(), O = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), et = new WeakMap(), S = new WeakSet(), ie = function(t, e) {
|
|
3984
4016
|
return new Promise((s, r) => {
|
|
3985
4017
|
const i = {
|
|
3986
4018
|
want: t,
|
|
3987
4019
|
resolve: s,
|
|
3988
4020
|
reject: r,
|
|
3989
4021
|
timer: setTimeout(() => {
|
|
3990
|
-
|
|
4022
|
+
_(this, O, l(this, O).filter((o) => o !== i)), r(
|
|
3991
4023
|
new Error(
|
|
3992
4024
|
`The platform did not confirm ${t === "joined" ? "joining" : "leaving"} in time.`
|
|
3993
4025
|
)
|
|
@@ -3996,61 +4028,61 @@ q = new WeakMap(), k = new WeakMap(), O = new WeakMap(), Q = new WeakMap(), Z =
|
|
|
3996
4028
|
};
|
|
3997
4029
|
l(this, O).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
|
|
3998
4030
|
});
|
|
3999
|
-
},
|
|
4031
|
+
}, oe = function(t) {
|
|
4000
4032
|
const e = l(this, O).filter((s) => s.want === t);
|
|
4001
|
-
|
|
4033
|
+
_(this, O, l(this, O).filter((s) => s.want !== t)), e.forEach((s) => {
|
|
4002
4034
|
clearTimeout(s.timer), s.resolve();
|
|
4003
4035
|
});
|
|
4004
|
-
},
|
|
4005
|
-
l(this,
|
|
4036
|
+
}, Q = function() {
|
|
4037
|
+
l(this, Z).forEach((t) => $t(t));
|
|
4006
4038
|
};
|
|
4007
|
-
var
|
|
4008
|
-
class dn extends
|
|
4039
|
+
var st;
|
|
4040
|
+
class dn extends Ke {
|
|
4009
4041
|
/** @internal Use `client.channel.collab()`. */
|
|
4010
4042
|
constructor(e) {
|
|
4011
4043
|
super(e, {
|
|
4012
4044
|
join: { action: "joinCollab" },
|
|
4013
4045
|
leave: { action: "leaveCollab" }
|
|
4014
4046
|
});
|
|
4015
|
-
|
|
4047
|
+
b(this, st, /* @__PURE__ */ new Map());
|
|
4016
4048
|
}
|
|
4017
4049
|
/**
|
|
4018
4050
|
* Listens for an event other tabs send. Any number of listeners per event.
|
|
4019
4051
|
* @returns a function that removes the listener.
|
|
4020
4052
|
*/
|
|
4021
4053
|
on(e, s) {
|
|
4022
|
-
const r = l(this,
|
|
4023
|
-
return r.add(s), l(this,
|
|
4054
|
+
const r = l(this, st).get(e) ?? /* @__PURE__ */ new Set();
|
|
4055
|
+
return r.add(s), l(this, st).set(e, r), () => void r.delete(s);
|
|
4024
4056
|
}
|
|
4025
4057
|
/**
|
|
4026
4058
|
* Sends an event to the other tabs in the room. Does nothing while this tab
|
|
4027
4059
|
* is not in it, matching what the platform does with a message from outside.
|
|
4028
4060
|
*/
|
|
4029
4061
|
send(e, s) {
|
|
4030
|
-
if (e.startsWith(
|
|
4031
|
-
throw new Error(`Message types starting with '${
|
|
4062
|
+
if (e.startsWith(re))
|
|
4063
|
+
throw new Error(`Message types starting with '${re}' are reserved.`);
|
|
4032
4064
|
this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: e, payload: s } });
|
|
4033
4065
|
}
|
|
4034
4066
|
accepts(e) {
|
|
4035
4067
|
return e === void 0 || e === "collab";
|
|
4036
4068
|
}
|
|
4037
4069
|
async handle(e) {
|
|
4038
|
-
const s = l(this,
|
|
4070
|
+
const s = l(this, st).get(e.type);
|
|
4039
4071
|
if (!(s != null && s.size)) return { handled: !1 };
|
|
4040
|
-
const r =
|
|
4072
|
+
const r = Xe(e);
|
|
4041
4073
|
return s.forEach((i) => $t(() => i(e.payload, r))), { handled: !0 };
|
|
4042
4074
|
}
|
|
4043
4075
|
}
|
|
4044
|
-
|
|
4045
|
-
var
|
|
4046
|
-
class fn extends
|
|
4076
|
+
st = new WeakMap();
|
|
4077
|
+
var H;
|
|
4078
|
+
class fn extends Ke {
|
|
4047
4079
|
/** @internal Use `client.channel.external(kind)`. */
|
|
4048
4080
|
constructor(e, s) {
|
|
4049
4081
|
super(e, {
|
|
4050
4082
|
join: { action: "joinExternal", kind: s },
|
|
4051
4083
|
leave: { action: "leaveExternal", kind: s }
|
|
4052
4084
|
});
|
|
4053
|
-
|
|
4085
|
+
b(this, H, /* @__PURE__ */ new Map());
|
|
4054
4086
|
this.kind = s;
|
|
4055
4087
|
}
|
|
4056
4088
|
/**
|
|
@@ -4064,24 +4096,24 @@ class fn extends Ye {
|
|
|
4064
4096
|
* @returns a function that removes the handler.
|
|
4065
4097
|
*/
|
|
4066
4098
|
on(e, s) {
|
|
4067
|
-
if (l(this,
|
|
4099
|
+
if (l(this, H).has(e))
|
|
4068
4100
|
throw new Error(
|
|
4069
4101
|
`"${e}" already has a handler in this room. Remove it first.`
|
|
4070
4102
|
);
|
|
4071
|
-
return l(this,
|
|
4103
|
+
return l(this, H).set(e, s), () => void l(this, H).delete(e);
|
|
4072
4104
|
}
|
|
4073
4105
|
accepts(e, s) {
|
|
4074
4106
|
return e !== void 0 && e !== "external" ? !1 : this.kind === void 0 || e === void 0 || this.kind === s;
|
|
4075
4107
|
}
|
|
4076
4108
|
/** @internal Whether this room has any handler at all. */
|
|
4077
4109
|
get hasHandlers() {
|
|
4078
|
-
return l(this,
|
|
4110
|
+
return l(this, H).size > 0;
|
|
4079
4111
|
}
|
|
4080
4112
|
async handle(e) {
|
|
4081
|
-
const s = l(this,
|
|
4113
|
+
const s = l(this, H).get(e.type);
|
|
4082
4114
|
if (!s) return { handled: !1 };
|
|
4083
4115
|
try {
|
|
4084
|
-
return { handled: !0, value: await s(e.payload,
|
|
4116
|
+
return { handled: !0, value: await s(e.payload, Xe(e)) };
|
|
4085
4117
|
} catch (r) {
|
|
4086
4118
|
return {
|
|
4087
4119
|
handled: !0,
|
|
@@ -4090,8 +4122,8 @@ class fn extends Ye {
|
|
|
4090
4122
|
}
|
|
4091
4123
|
}
|
|
4092
4124
|
}
|
|
4093
|
-
|
|
4094
|
-
function
|
|
4125
|
+
H = new WeakMap();
|
|
4126
|
+
function Xe(n) {
|
|
4095
4127
|
return {
|
|
4096
4128
|
from: n.from,
|
|
4097
4129
|
at: n.at,
|
|
@@ -4113,20 +4145,20 @@ function pn(n) {
|
|
|
4113
4145
|
kind: typeof e.kind == "string" ? e.kind : void 0
|
|
4114
4146
|
};
|
|
4115
4147
|
}
|
|
4116
|
-
var W, yt, F,
|
|
4148
|
+
var W, yt, F, G, V, v, ae, Ct, ze, Qe, Ze, ce;
|
|
4117
4149
|
class yn {
|
|
4118
4150
|
constructor(t) {
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4151
|
+
b(this, v);
|
|
4152
|
+
b(this, W);
|
|
4153
|
+
b(this, yt);
|
|
4154
|
+
b(this, F);
|
|
4155
|
+
b(this, G, /* @__PURE__ */ new Map());
|
|
4156
|
+
b(this, V, /* @__PURE__ */ new Set());
|
|
4157
|
+
_(this, W, t), _(this, yt, t.listen((e) => void a(this, v, ze).call(this, e)));
|
|
4126
4158
|
}
|
|
4127
4159
|
/** The collaboration room for this app. Always the same instance. */
|
|
4128
4160
|
collab() {
|
|
4129
|
-
return l(this, F) ??
|
|
4161
|
+
return l(this, F) ?? _(this, F, new dn(l(this, W))), l(this, F);
|
|
4130
4162
|
}
|
|
4131
4163
|
/**
|
|
4132
4164
|
* The room for commands from this account's external tools of one `kind`
|
|
@@ -4135,46 +4167,46 @@ class yn {
|
|
|
4135
4167
|
*/
|
|
4136
4168
|
external(t) {
|
|
4137
4169
|
const e = t ?? "";
|
|
4138
|
-
let s = l(this,
|
|
4139
|
-
return s || (s = new fn(l(this, W), t), l(this,
|
|
4170
|
+
let s = l(this, G).get(e);
|
|
4171
|
+
return s || (s = new fn(l(this, W), t), l(this, G).set(e, s)), s;
|
|
4140
4172
|
}
|
|
4141
4173
|
/** Stops listening. For tests and teardown; an app normally never calls it. */
|
|
4142
4174
|
dispose() {
|
|
4143
4175
|
l(this, yt).call(this);
|
|
4144
4176
|
}
|
|
4145
4177
|
}
|
|
4146
|
-
W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(),
|
|
4147
|
-
return [...l(this, F) ? [l(this, F)] : [], ...l(this,
|
|
4148
|
-
},
|
|
4178
|
+
W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), G = new WeakMap(), V = new WeakMap(), v = new WeakSet(), ae = function() {
|
|
4179
|
+
return [...l(this, F) ? [l(this, F)] : [], ...l(this, G).values()];
|
|
4180
|
+
}, Ct = function(t, e) {
|
|
4149
4181
|
if (t === "collab") return l(this, F);
|
|
4150
4182
|
if (t === "external")
|
|
4151
|
-
return l(this,
|
|
4152
|
-
},
|
|
4183
|
+
return l(this, G).get(typeof e == "string" ? e : "");
|
|
4184
|
+
}, ze = async function(t) {
|
|
4153
4185
|
const e = pn(t);
|
|
4154
4186
|
if (e) {
|
|
4155
|
-
if (e.type.startsWith(
|
|
4156
|
-
a(this, v,
|
|
4187
|
+
if (e.type.startsWith(re)) {
|
|
4188
|
+
a(this, v, Qe).call(this, e);
|
|
4157
4189
|
return;
|
|
4158
4190
|
}
|
|
4159
|
-
await a(this, v,
|
|
4191
|
+
await a(this, v, Ze).call(this, e);
|
|
4160
4192
|
}
|
|
4161
|
-
},
|
|
4193
|
+
}, Qe = function(t) {
|
|
4162
4194
|
var s, r, i;
|
|
4163
4195
|
const e = t.payload ?? {};
|
|
4164
4196
|
switch (t.type) {
|
|
4165
4197
|
case "channel:joined":
|
|
4166
|
-
(s = a(this, v,
|
|
4198
|
+
(s = a(this, v, Ct).call(this, e.scope, e.kind)) == null || s.applyJoined();
|
|
4167
4199
|
break;
|
|
4168
4200
|
case "channel:left":
|
|
4169
|
-
(r = a(this, v,
|
|
4201
|
+
(r = a(this, v, Ct).call(this, e.scope, e.kind)) == null || r.applyLeft();
|
|
4170
4202
|
break;
|
|
4171
4203
|
case "channel:peers":
|
|
4172
|
-
(i = a(this, v,
|
|
4204
|
+
(i = a(this, v, Ct).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
|
|
4173
4205
|
break;
|
|
4174
4206
|
case "channel:peer-joined":
|
|
4175
4207
|
case "channel:peer-left": {
|
|
4176
4208
|
if (!e.from) break;
|
|
4177
|
-
const o = e.scope === "collab" ? [l(this, F)] : [...l(this,
|
|
4209
|
+
const o = e.scope === "collab" ? [l(this, F)] : [...l(this, G).values()].filter(
|
|
4178
4210
|
(h) => h.accepts("external", e.kind)
|
|
4179
4211
|
);
|
|
4180
4212
|
for (const h of o)
|
|
@@ -4183,23 +4215,23 @@ W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), H = new WeakMap(), G =
|
|
|
4183
4215
|
}
|
|
4184
4216
|
case "channel:error": {
|
|
4185
4217
|
const o = new Error(String(t.payload));
|
|
4186
|
-
a(this, v,
|
|
4218
|
+
a(this, v, ae).call(this).map((u) => u.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
|
|
4187
4219
|
break;
|
|
4188
4220
|
}
|
|
4189
4221
|
}
|
|
4190
|
-
},
|
|
4191
|
-
const e = a(this, v,
|
|
4222
|
+
}, Ze = async function(t) {
|
|
4223
|
+
const e = a(this, v, ae).call(this).filter((i) => i.accepts(t.scope, t.kind));
|
|
4192
4224
|
let s = !1;
|
|
4193
4225
|
for (const i of e) {
|
|
4194
4226
|
const o = await i.handle(t);
|
|
4195
|
-
o.handled && (s = !0, t.requestId && a(this, v,
|
|
4227
|
+
o.handled && (s = !0, t.requestId && a(this, v, ce).call(this, t.requestId, o));
|
|
4196
4228
|
}
|
|
4197
|
-
t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v,
|
|
4229
|
+
t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v, ce).call(this, t.requestId, {
|
|
4198
4230
|
handled: !0,
|
|
4199
4231
|
error: `No handler for "${t.type}".`
|
|
4200
4232
|
});
|
|
4201
|
-
},
|
|
4202
|
-
l(this,
|
|
4233
|
+
}, ce = function(t, e) {
|
|
4234
|
+
l(this, V).has(t) || (l(this, V).add(t), l(this, V).size > 500 && l(this, V).delete(l(this, V).values().next().value), l(this, W).post({
|
|
4203
4235
|
type: "APP_CHANNEL_PUBLISH",
|
|
4204
4236
|
message: {
|
|
4205
4237
|
type: e.error === void 0 ? "reply" : "reply-error",
|
|
@@ -4208,9 +4240,9 @@ W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), H = new WeakMap(), G =
|
|
|
4208
4240
|
}
|
|
4209
4241
|
}));
|
|
4210
4242
|
};
|
|
4211
|
-
const
|
|
4212
|
-
var
|
|
4213
|
-
const
|
|
4243
|
+
const Y = "project", X = "notifications";
|
|
4244
|
+
var nt, mt;
|
|
4245
|
+
const me = class me extends te {
|
|
4214
4246
|
/**
|
|
4215
4247
|
* @param token - A bearer JWT, OR a function returning the current JWT
|
|
4216
4248
|
* (sync or async). When a function is passed, it's invoked before every
|
|
@@ -4221,12 +4253,12 @@ const ye = class ye extends Zt {
|
|
|
4221
4253
|
*/
|
|
4222
4254
|
constructor(e, s, r) {
|
|
4223
4255
|
super(typeof e == "string" ? e : "", s, { ...r, useBearer: !0 });
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
typeof e == "function" &&
|
|
4256
|
+
b(this, nt);
|
|
4257
|
+
b(this, mt);
|
|
4258
|
+
typeof e == "function" && _(this, nt, e);
|
|
4227
4259
|
}
|
|
4228
4260
|
async resolveAccessToken() {
|
|
4229
|
-
return l(this,
|
|
4261
|
+
return l(this, nt) ? await l(this, nt).call(this) : super.resolveAccessToken();
|
|
4230
4262
|
}
|
|
4231
4263
|
/**
|
|
4232
4264
|
* Creates a client from the platform context injected into
|
|
@@ -4235,7 +4267,7 @@ const ye = class ye extends Zt {
|
|
|
4235
4267
|
* carries a fresh JWT on every navigation.
|
|
4236
4268
|
*/
|
|
4237
4269
|
static fromPlatformContext(e) {
|
|
4238
|
-
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new
|
|
4270
|
+
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new me(s.accessToken, s.apiUrl, e);
|
|
4239
4271
|
return r.context = s, r;
|
|
4240
4272
|
}
|
|
4241
4273
|
/**
|
|
@@ -4263,7 +4295,7 @@ const ye = class ye extends Zt {
|
|
|
4263
4295
|
* ```
|
|
4264
4296
|
*/
|
|
4265
4297
|
get channel() {
|
|
4266
|
-
return l(this, mt) ??
|
|
4298
|
+
return l(this, mt) ?? _(this, mt, new yn(ln())), l(this, mt);
|
|
4267
4299
|
}
|
|
4268
4300
|
// ─── Projects (JWT-only backend routes) ──────────────────────────
|
|
4269
4301
|
/**
|
|
@@ -4282,14 +4314,14 @@ const ye = class ye extends Zt {
|
|
|
4282
4314
|
* ```
|
|
4283
4315
|
*/
|
|
4284
4316
|
async listProjects() {
|
|
4285
|
-
return await this.request("GET",
|
|
4317
|
+
return await this.request("GET", Y);
|
|
4286
4318
|
}
|
|
4287
4319
|
/**
|
|
4288
4320
|
* Gets a project by ID. JWT-only — lives here because
|
|
4289
4321
|
* `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
|
|
4290
4322
|
*/
|
|
4291
4323
|
async getProject(e) {
|
|
4292
|
-
return await this.request("GET", `${
|
|
4324
|
+
return await this.request("GET", `${Y}/${e}`);
|
|
4293
4325
|
}
|
|
4294
4326
|
/**
|
|
4295
4327
|
* Gets the full project data (users, roles, files, folders) for a project.
|
|
@@ -4298,7 +4330,7 @@ const ye = class ye extends Zt {
|
|
|
4298
4330
|
async getProjectData(e) {
|
|
4299
4331
|
return await this.request(
|
|
4300
4332
|
"GET",
|
|
4301
|
-
`${
|
|
4333
|
+
`${Y}/${e}/data`
|
|
4302
4334
|
);
|
|
4303
4335
|
}
|
|
4304
4336
|
// ─── Account ──────────────────────────────────────────────────────
|
|
@@ -4323,7 +4355,7 @@ const ye = class ye extends Zt {
|
|
|
4323
4355
|
async checkPermission(e) {
|
|
4324
4356
|
return await this.request(
|
|
4325
4357
|
"GET",
|
|
4326
|
-
`${
|
|
4358
|
+
`${Y}/permissions/check`,
|
|
4327
4359
|
{ query: e }
|
|
4328
4360
|
);
|
|
4329
4361
|
}
|
|
@@ -4332,7 +4364,7 @@ const ye = class ye extends Zt {
|
|
|
4332
4364
|
* single round-trip; results come back in the same order as `checks`.
|
|
4333
4365
|
*/
|
|
4334
4366
|
async checkPermissionBatch(e) {
|
|
4335
|
-
return (await this.request("POST", `${
|
|
4367
|
+
return (await this.request("POST", `${Y}/permissions/check/batch`, {
|
|
4336
4368
|
body: JSON.stringify({ checks: e }),
|
|
4337
4369
|
contentType: "application/json"
|
|
4338
4370
|
})).results;
|
|
@@ -4444,7 +4476,7 @@ const ye = class ye extends Zt {
|
|
|
4444
4476
|
async subscribeToAutomation(e, s, r) {
|
|
4445
4477
|
return await this.request(
|
|
4446
4478
|
"POST",
|
|
4447
|
-
`${
|
|
4479
|
+
`${Y}/${e}/events/hooks/${s}/subscription`,
|
|
4448
4480
|
{
|
|
4449
4481
|
body: JSON.stringify(r ?? {}),
|
|
4450
4482
|
contentType: "application/json"
|
|
@@ -4461,7 +4493,7 @@ const ye = class ye extends Zt {
|
|
|
4461
4493
|
async updateAutomationSubscription(e, s, r) {
|
|
4462
4494
|
return await this.request(
|
|
4463
4495
|
"PATCH",
|
|
4464
|
-
`${
|
|
4496
|
+
`${Y}/${e}/events/hooks/${s}/subscription`,
|
|
4465
4497
|
{
|
|
4466
4498
|
body: JSON.stringify(r),
|
|
4467
4499
|
contentType: "application/json"
|
|
@@ -4511,20 +4543,20 @@ const ye = class ye extends Zt {
|
|
|
4511
4543
|
), () => r.disconnect();
|
|
4512
4544
|
}
|
|
4513
4545
|
};
|
|
4514
|
-
|
|
4515
|
-
let xe =
|
|
4546
|
+
nt = new WeakMap(), mt = new WeakMap();
|
|
4547
|
+
let xe = me;
|
|
4516
4548
|
const wn = {
|
|
4517
4549
|
MAX_FIELDS: 200,
|
|
4518
4550
|
MAX_KEY_LENGTH: 50,
|
|
4519
4551
|
MAX_VALUE_LENGTH: 50
|
|
4520
|
-
},
|
|
4552
|
+
}, bn = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, _n = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, En = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, vn = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, Tn = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, Sn = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, kn = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, On = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, An = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
|
|
4521
4553
|
export {
|
|
4522
|
-
|
|
4554
|
+
bn as CDEManager,
|
|
4523
4555
|
yn as ChannelClient,
|
|
4524
|
-
|
|
4525
|
-
|
|
4556
|
+
Ke as ChannelRoom,
|
|
4557
|
+
_n as ClashesManager,
|
|
4526
4558
|
dn as CollabRoom,
|
|
4527
|
-
|
|
4559
|
+
te as EngineServicesClient,
|
|
4528
4560
|
fn as ExternalRoom,
|
|
4529
4561
|
En as FileList,
|
|
4530
4562
|
zs as FlowDoc,
|
|
@@ -4536,13 +4568,13 @@ export {
|
|
|
4536
4568
|
Xs as ProjectHistory,
|
|
4537
4569
|
kn as ProjectManager,
|
|
4538
4570
|
Zs as Recipes,
|
|
4539
|
-
|
|
4571
|
+
pe as RequestError,
|
|
4540
4572
|
Ae as STORAGE_BATCH_MAX,
|
|
4541
|
-
|
|
4573
|
+
Te as StaleHistoryError,
|
|
4542
4574
|
On as TopicsManager,
|
|
4543
4575
|
An as UIManager,
|
|
4544
|
-
|
|
4545
|
-
|
|
4576
|
+
Qt as mintGuid,
|
|
4577
|
+
Ye as orderByGraph,
|
|
4546
4578
|
ln as windowTransport
|
|
4547
4579
|
};
|
|
4548
4580
|
//# sourceMappingURL=index.es.js.map
|