@thatopen/services 0.22.0 → 0.24.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 +225 -1
- package/dist/cli.js.map +1 -1
- package/dist/core/client.d.ts +7 -0
- package/dist/core/documents.d.ts +59 -0
- package/dist/core/history.d.ts +58 -0
- package/dist/core/op-builder.d.ts +118 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1396 -1004
- package/dist/index.es.js.map +1 -1
- package/docs/ai-quickstart.md +53 -5
- package/package.json +9 -1
package/dist/index.es.js
CHANGED
|
@@ -1,265 +1,265 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var Js = Object.defineProperty;
|
|
2
|
+
var xe = (r) => {
|
|
3
|
+
throw TypeError(r);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
Object.keys(
|
|
18
|
-
|
|
5
|
+
var Ys = (r, t, e) => t in r ? Js(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
6
|
+
var I = (r, t, e) => Ys(r, typeof t != "symbol" ? t + "" : t, e), jt = (r, t, e) => t.has(r) || xe("Cannot " + e);
|
|
7
|
+
var u = (r, t, e) => (jt(r, t, "read from private field"), e ? e.call(r) : t.get(r)), b = (r, t, e) => t.has(r) ? xe("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), _ = (r, t, e, s) => (jt(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), a = (r, t, e) => (jt(r, t, "access private method"), e);
|
|
8
|
+
const F = /* @__PURE__ */ Object.create(null);
|
|
9
|
+
F.open = "0";
|
|
10
|
+
F.close = "1";
|
|
11
|
+
F.ping = "2";
|
|
12
|
+
F.pong = "3";
|
|
13
|
+
F.message = "4";
|
|
14
|
+
F.upgrade = "5";
|
|
15
|
+
F.noop = "6";
|
|
16
|
+
const kt = /* @__PURE__ */ Object.create(null);
|
|
17
|
+
Object.keys(F).forEach((r) => {
|
|
18
|
+
kt[F[r]] = r;
|
|
19
19
|
});
|
|
20
|
-
const
|
|
20
|
+
const Wt = { type: "error", data: "parser error" }, We = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ke = typeof ArrayBuffer == "function", ze = (r) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(r) : r && r.buffer instanceof ArrayBuffer, we = ({ type: r, data: t }, e, s) => We && t instanceof Blob ? e ? s(t) : Re(t, s) : Ke && (t instanceof ArrayBuffer || ze(t)) ? e ? s(t) : Re(new Blob([t]), s) : s(F[r] + (t || "")), Re = (r, 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
|
-
}, e.readAsDataURL(
|
|
25
|
+
}, e.readAsDataURL(r);
|
|
26
26
|
};
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function $e(r) {
|
|
28
|
+
return r instanceof Uint8Array ? r : r instanceof ArrayBuffer ? new Uint8Array(r) : new Uint8Array(r.buffer, r.byteOffset, r.byteLength);
|
|
29
29
|
}
|
|
30
|
-
let
|
|
31
|
-
function
|
|
32
|
-
if (
|
|
33
|
-
return
|
|
34
|
-
if (
|
|
35
|
-
return t(
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
let Mt;
|
|
31
|
+
function Ws(r, t) {
|
|
32
|
+
if (We && r.data instanceof Blob)
|
|
33
|
+
return r.data.arrayBuffer().then($e).then(t);
|
|
34
|
+
if (Ke && (r.data instanceof ArrayBuffer || ze(r.data)))
|
|
35
|
+
return t($e(r.data));
|
|
36
|
+
we(r, !1, (e) => {
|
|
37
|
+
Mt || (Mt = new TextEncoder()), t(Mt.encode(e));
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
for (let
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
let t =
|
|
45
|
-
|
|
46
|
-
const f = new ArrayBuffer(t),
|
|
40
|
+
const Ne = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", pt = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
41
|
+
for (let r = 0; r < Ne.length; r++)
|
|
42
|
+
pt[Ne.charCodeAt(r)] = r;
|
|
43
|
+
const Ks = (r) => {
|
|
44
|
+
let t = r.length * 0.75, e = r.length, s, n = 0, i, o, c, d;
|
|
45
|
+
r[r.length - 1] === "=" && (t--, r[r.length - 2] === "=" && t--);
|
|
46
|
+
const f = new ArrayBuffer(t), h = new Uint8Array(f);
|
|
47
47
|
for (s = 0; s < e; s += 4)
|
|
48
|
-
i =
|
|
48
|
+
i = pt[r.charCodeAt(s)], o = pt[r.charCodeAt(s + 1)], c = pt[r.charCodeAt(s + 2)], d = pt[r.charCodeAt(s + 3)], h[n++] = i << 2 | o >> 4, h[n++] = (o & 15) << 4 | c >> 2, h[n++] = (c & 3) << 6 | d & 63;
|
|
49
49
|
return f;
|
|
50
|
-
},
|
|
51
|
-
if (typeof
|
|
50
|
+
}, zs = typeof ArrayBuffer == "function", be = (r, t) => {
|
|
51
|
+
if (typeof r != "string")
|
|
52
52
|
return {
|
|
53
53
|
type: "message",
|
|
54
|
-
data:
|
|
54
|
+
data: Xe(r, t)
|
|
55
55
|
};
|
|
56
|
-
const e =
|
|
56
|
+
const e = r.charAt(0);
|
|
57
57
|
return e === "b" ? {
|
|
58
58
|
type: "message",
|
|
59
|
-
data:
|
|
60
|
-
} :
|
|
61
|
-
type:
|
|
62
|
-
data:
|
|
59
|
+
data: Xs(r.substring(1), t)
|
|
60
|
+
} : kt[e] ? r.length > 1 ? {
|
|
61
|
+
type: kt[e],
|
|
62
|
+
data: r.substring(1)
|
|
63
63
|
} : {
|
|
64
|
-
type:
|
|
65
|
-
} :
|
|
66
|
-
},
|
|
67
|
-
if (
|
|
68
|
-
const e =
|
|
69
|
-
return
|
|
64
|
+
type: kt[e]
|
|
65
|
+
} : Wt;
|
|
66
|
+
}, Xs = (r, t) => {
|
|
67
|
+
if (zs) {
|
|
68
|
+
const e = Ks(r);
|
|
69
|
+
return Xe(e, t);
|
|
70
70
|
} else
|
|
71
|
-
return { base64: !0, data:
|
|
72
|
-
},
|
|
71
|
+
return { base64: !0, data: r };
|
|
72
|
+
}, Xe = (r, t) => {
|
|
73
73
|
switch (t) {
|
|
74
74
|
case "blob":
|
|
75
|
-
return
|
|
75
|
+
return r instanceof Blob ? r : new Blob([r]);
|
|
76
76
|
case "arraybuffer":
|
|
77
77
|
default:
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
const e =
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
s[o] =
|
|
78
|
+
return r instanceof ArrayBuffer ? r : r.buffer;
|
|
79
|
+
}
|
|
80
|
+
}, Qe = "", Qs = (r, t) => {
|
|
81
|
+
const e = r.length, s = new Array(e);
|
|
82
|
+
let n = 0;
|
|
83
|
+
r.forEach((i, o) => {
|
|
84
|
+
we(i, !1, (c) => {
|
|
85
|
+
s[o] = c, ++n === e && t(s.join(Qe));
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
-
},
|
|
89
|
-
const e =
|
|
90
|
-
for (let
|
|
91
|
-
const i =
|
|
88
|
+
}, Zs = (r, t) => {
|
|
89
|
+
const e = r.split(Qe), s = [];
|
|
90
|
+
for (let n = 0; n < e.length; n++) {
|
|
91
|
+
const i = be(e[n], 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 tr() {
|
|
98
98
|
return new TransformStream({
|
|
99
|
-
transform(
|
|
100
|
-
|
|
99
|
+
transform(r, t) {
|
|
100
|
+
Ws(r, (e) => {
|
|
101
101
|
const s = e.length;
|
|
102
|
-
let
|
|
102
|
+
let n;
|
|
103
103
|
if (s < 126)
|
|
104
|
-
|
|
104
|
+
n = new Uint8Array(1), new DataView(n.buffer).setUint8(0, s);
|
|
105
105
|
else if (s < 65536) {
|
|
106
|
-
|
|
107
|
-
const i = new DataView(
|
|
106
|
+
n = new Uint8Array(3);
|
|
107
|
+
const i = new DataView(n.buffer);
|
|
108
108
|
i.setUint8(0, 126), i.setUint16(1, s);
|
|
109
109
|
} else {
|
|
110
|
-
|
|
111
|
-
const i = new DataView(
|
|
110
|
+
n = new Uint8Array(9);
|
|
111
|
+
const i = new DataView(n.buffer);
|
|
112
112
|
i.setUint8(0, 127), i.setBigUint64(1, BigInt(s));
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
r.data && typeof r.data != "string" && (n[0] |= 128), t.enqueue(n), t.enqueue(e);
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
let
|
|
120
|
-
function
|
|
121
|
-
return
|
|
119
|
+
let Vt;
|
|
120
|
+
function It(r) {
|
|
121
|
+
return r.reduce((t, e) => t + e.length, 0);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
if (
|
|
125
|
-
return
|
|
123
|
+
function Ot(r, t) {
|
|
124
|
+
if (r[0].length === t)
|
|
125
|
+
return r.shift();
|
|
126
126
|
const e = new Uint8Array(t);
|
|
127
127
|
let s = 0;
|
|
128
|
-
for (let
|
|
129
|
-
e[
|
|
130
|
-
return
|
|
128
|
+
for (let n = 0; n < t; n++)
|
|
129
|
+
e[n] = r[0][s++], s === r[0].length && (r.shift(), s = 0);
|
|
130
|
+
return r.length && s < r[0].length && (r[0] = r[0].slice(s)), e;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
132
|
+
function er(r, t) {
|
|
133
|
+
Vt || (Vt = new TextDecoder());
|
|
134
134
|
const e = [];
|
|
135
|
-
let s = 0,
|
|
135
|
+
let s = 0, n = -1, i = !1;
|
|
136
136
|
return new TransformStream({
|
|
137
|
-
transform(o,
|
|
137
|
+
transform(o, c) {
|
|
138
138
|
for (e.push(o); ; ) {
|
|
139
139
|
if (s === 0) {
|
|
140
|
-
if (
|
|
140
|
+
if (It(e) < 1)
|
|
141
141
|
break;
|
|
142
|
-
const
|
|
143
|
-
i = (
|
|
142
|
+
const d = Ot(e, 1);
|
|
143
|
+
i = (d[0] & 128) === 128, n = d[0] & 127, n < 126 ? s = 3 : n === 126 ? s = 1 : s = 2;
|
|
144
144
|
} else if (s === 1) {
|
|
145
|
-
if (
|
|
145
|
+
if (It(e) < 2)
|
|
146
146
|
break;
|
|
147
|
-
const
|
|
148
|
-
|
|
147
|
+
const d = Ot(e, 2);
|
|
148
|
+
n = new DataView(d.buffer, d.byteOffset, d.length).getUint16(0), s = 3;
|
|
149
149
|
} else if (s === 2) {
|
|
150
|
-
if (
|
|
150
|
+
if (It(e) < 8)
|
|
151
151
|
break;
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
|
|
152
|
+
const d = Ot(e, 8), f = new DataView(d.buffer, d.byteOffset, d.length), h = f.getUint32(0);
|
|
153
|
+
if (h > Math.pow(2, 21) - 1) {
|
|
154
|
+
c.enqueue(Wt);
|
|
155
155
|
break;
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
n = h * Math.pow(2, 32) + f.getUint32(4), s = 3;
|
|
158
158
|
} else {
|
|
159
|
-
if (
|
|
159
|
+
if (It(e) < n)
|
|
160
160
|
break;
|
|
161
|
-
const
|
|
162
|
-
|
|
161
|
+
const d = Ot(e, n);
|
|
162
|
+
c.enqueue(be(i ? d : Vt.decode(d), t)), s = 0;
|
|
163
163
|
}
|
|
164
|
-
if (
|
|
165
|
-
|
|
164
|
+
if (n === 0 || n > r) {
|
|
165
|
+
c.enqueue(Wt);
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
const
|
|
173
|
-
function E(
|
|
174
|
-
if (
|
|
172
|
+
const Ze = 4;
|
|
173
|
+
function E(r) {
|
|
174
|
+
if (r) return sr(r);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function sr(r) {
|
|
177
177
|
for (var t in E.prototype)
|
|
178
|
-
|
|
179
|
-
return
|
|
178
|
+
r[t] = E.prototype[t];
|
|
179
|
+
return r;
|
|
180
180
|
}
|
|
181
|
-
E.prototype.on = E.prototype.addEventListener = function(
|
|
182
|
-
return this._callbacks = this._callbacks || {}, (this._callbacks["$" +
|
|
181
|
+
E.prototype.on = E.prototype.addEventListener = function(r, t) {
|
|
182
|
+
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + r] = this._callbacks["$" + r] || []).push(t), this;
|
|
183
183
|
};
|
|
184
|
-
E.prototype.once = function(
|
|
184
|
+
E.prototype.once = function(r, t) {
|
|
185
185
|
function e() {
|
|
186
|
-
this.off(
|
|
186
|
+
this.off(r, e), t.apply(this, arguments);
|
|
187
187
|
}
|
|
188
|
-
return e.fn = t, this.on(
|
|
188
|
+
return e.fn = t, this.on(r, e), this;
|
|
189
189
|
};
|
|
190
|
-
E.prototype.off = E.prototype.removeListener = E.prototype.removeAllListeners = E.prototype.removeEventListener = function(
|
|
190
|
+
E.prototype.off = E.prototype.removeListener = E.prototype.removeAllListeners = E.prototype.removeEventListener = function(r, t) {
|
|
191
191
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
|
|
192
192
|
return this._callbacks = {}, this;
|
|
193
|
-
var e = this._callbacks["$" +
|
|
193
|
+
var e = this._callbacks["$" + r];
|
|
194
194
|
if (!e) return this;
|
|
195
195
|
if (arguments.length == 1)
|
|
196
|
-
return delete this._callbacks["$" +
|
|
197
|
-
for (var s,
|
|
198
|
-
if (s = e[
|
|
199
|
-
e.splice(
|
|
196
|
+
return delete this._callbacks["$" + r], this;
|
|
197
|
+
for (var s, n = 0; n < e.length; n++)
|
|
198
|
+
if (s = e[n], s === t || s.fn === t) {
|
|
199
|
+
e.splice(n, 1);
|
|
200
200
|
break;
|
|
201
201
|
}
|
|
202
|
-
return e.length === 0 && delete this._callbacks["$" +
|
|
202
|
+
return e.length === 0 && delete this._callbacks["$" + r], this;
|
|
203
203
|
};
|
|
204
|
-
E.prototype.emit = function(
|
|
204
|
+
E.prototype.emit = function(r) {
|
|
205
205
|
this._callbacks = this._callbacks || {};
|
|
206
|
-
for (var t = new Array(arguments.length - 1), e = this._callbacks["$" +
|
|
206
|
+
for (var t = new Array(arguments.length - 1), e = this._callbacks["$" + r], s = 1; s < arguments.length; s++)
|
|
207
207
|
t[s - 1] = arguments[s];
|
|
208
208
|
if (e) {
|
|
209
209
|
e = e.slice(0);
|
|
210
|
-
for (var s = 0,
|
|
210
|
+
for (var s = 0, n = e.length; s < n; ++s)
|
|
211
211
|
e[s].apply(this, t);
|
|
212
212
|
}
|
|
213
213
|
return this;
|
|
214
214
|
};
|
|
215
215
|
E.prototype.emitReserved = E.prototype.emit;
|
|
216
|
-
E.prototype.listeners = function(
|
|
217
|
-
return this._callbacks = this._callbacks || {}, this._callbacks["$" +
|
|
216
|
+
E.prototype.listeners = function(r) {
|
|
217
|
+
return this._callbacks = this._callbacks || {}, this._callbacks["$" + r] || [];
|
|
218
218
|
};
|
|
219
|
-
E.prototype.hasListeners = function(
|
|
220
|
-
return !!this.listeners(
|
|
219
|
+
E.prototype.hasListeners = function(r) {
|
|
220
|
+
return !!this.listeners(r).length;
|
|
221
221
|
};
|
|
222
|
-
const
|
|
223
|
-
function
|
|
224
|
-
return t.reduce((e, s) => (
|
|
222
|
+
const Ft = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), R = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), rr = "arraybuffer";
|
|
223
|
+
function ts(r, ...t) {
|
|
224
|
+
return t.reduce((e, s) => (r.hasOwnProperty(s) && (e[s] = r[s]), e), {});
|
|
225
225
|
}
|
|
226
|
-
const
|
|
227
|
-
function
|
|
228
|
-
t.useNativeTimers ? (
|
|
226
|
+
const nr = R.setTimeout, ir = R.clearTimeout;
|
|
227
|
+
function qt(r, t) {
|
|
228
|
+
t.useNativeTimers ? (r.setTimeoutFn = nr.bind(R), r.clearTimeoutFn = ir.bind(R)) : (r.setTimeoutFn = R.setTimeout.bind(R), r.clearTimeoutFn = R.clearTimeout.bind(R));
|
|
229
229
|
}
|
|
230
|
-
const
|
|
231
|
-
function
|
|
232
|
-
return typeof
|
|
230
|
+
const or = 1.33;
|
|
231
|
+
function ar(r) {
|
|
232
|
+
return typeof r == "string" ? cr(r) : Math.ceil((r.byteLength || r.size) * or);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function cr(r) {
|
|
235
235
|
let t = 0, e = 0;
|
|
236
|
-
for (let s = 0,
|
|
237
|
-
t =
|
|
236
|
+
for (let s = 0, n = r.length; s < n; s++)
|
|
237
|
+
t = r.charCodeAt(s), t < 128 ? e += 1 : t < 2048 ? e += 2 : t < 55296 || t >= 57344 ? e += 3 : (s++, e += 4);
|
|
238
238
|
return e;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function es() {
|
|
241
241
|
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function hr(r) {
|
|
244
244
|
let t = "";
|
|
245
|
-
for (let e in
|
|
246
|
-
|
|
245
|
+
for (let e in r)
|
|
246
|
+
r.hasOwnProperty(e) && (t.length && (t += "&"), t += encodeURIComponent(e) + "=" + encodeURIComponent(r[e]));
|
|
247
247
|
return t;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
let t = {}, e =
|
|
251
|
-
for (let s = 0,
|
|
249
|
+
function lr(r) {
|
|
250
|
+
let t = {}, e = r.split("&");
|
|
251
|
+
for (let s = 0, n = e.length; s < n; s++) {
|
|
252
252
|
let i = e[s].split("=");
|
|
253
253
|
t[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
|
|
254
254
|
}
|
|
255
255
|
return t;
|
|
256
256
|
}
|
|
257
|
-
class
|
|
257
|
+
class ur 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 _e extends E {
|
|
263
263
|
/**
|
|
264
264
|
* Transport abstract constructor.
|
|
265
265
|
*
|
|
@@ -267,7 +267,7 @@ class ue extends E {
|
|
|
267
267
|
* @protected
|
|
268
268
|
*/
|
|
269
269
|
constructor(t) {
|
|
270
|
-
super(), this.writable = !1,
|
|
270
|
+
super(), this.writable = !1, qt(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* Emits an error.
|
|
@@ -279,7 +279,7 @@ class ue 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 ur(t, e, s)), this;
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* Opens the transport.
|
|
@@ -316,7 +316,7 @@ class ue extends E {
|
|
|
316
316
|
* @protected
|
|
317
317
|
*/
|
|
318
318
|
onData(t) {
|
|
319
|
-
const e =
|
|
319
|
+
const e = be(t, this.socket.binaryType);
|
|
320
320
|
this.onPacket(e);
|
|
321
321
|
}
|
|
322
322
|
/**
|
|
@@ -353,11 +353,11 @@ class ue 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 = hr(t);
|
|
357
357
|
return e.length ? "?" + e : "";
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
class
|
|
360
|
+
class dr extends _e {
|
|
361
361
|
constructor() {
|
|
362
362
|
super(...arguments), this._polling = !1;
|
|
363
363
|
}
|
|
@@ -413,7 +413,7 @@ class Es extends ue {
|
|
|
413
413
|
return this.onClose({ description: "transport closed by the server" }), !1;
|
|
414
414
|
this.onPacket(s);
|
|
415
415
|
};
|
|
416
|
-
|
|
416
|
+
Zs(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 Es extends ue {
|
|
|
433
433
|
* @protected
|
|
434
434
|
*/
|
|
435
435
|
write(t) {
|
|
436
|
-
this.writable = !1,
|
|
436
|
+
this.writable = !1, Qs(t, (e) => {
|
|
437
437
|
this.doWrite(e, () => {
|
|
438
438
|
this.writable = !0, this.emitReserved("drain");
|
|
439
439
|
});
|
|
@@ -446,18 +446,18 @@ class Es extends ue {
|
|
|
446
446
|
*/
|
|
447
447
|
uri() {
|
|
448
448
|
const t = this.opts.secure ? "https" : "http", e = this.query || {};
|
|
449
|
-
return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] =
|
|
449
|
+
return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = es()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
let
|
|
452
|
+
let ss = !1;
|
|
453
453
|
try {
|
|
454
|
-
|
|
454
|
+
ss = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
455
455
|
} catch {
|
|
456
456
|
}
|
|
457
|
-
const
|
|
458
|
-
function
|
|
457
|
+
const fr = ss;
|
|
458
|
+
function pr() {
|
|
459
459
|
}
|
|
460
|
-
class
|
|
460
|
+
class yr extends dr {
|
|
461
461
|
/**
|
|
462
462
|
* XHR Polling constructor.
|
|
463
463
|
*
|
|
@@ -483,8 +483,8 @@ class Ss extends Es {
|
|
|
483
483
|
method: "POST",
|
|
484
484
|
data: t
|
|
485
485
|
});
|
|
486
|
-
s.on("success", e), s.on("error", (
|
|
487
|
-
this.onError("xhr post error",
|
|
486
|
+
s.on("success", e), s.on("error", (n, i) => {
|
|
487
|
+
this.onError("xhr post error", n, i);
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
490
|
/**
|
|
@@ -499,7 +499,7 @@ class Ss extends Es {
|
|
|
499
499
|
}), this.pollXhr = t;
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
|
-
class
|
|
502
|
+
class L extends E {
|
|
503
503
|
/**
|
|
504
504
|
* Request constructor
|
|
505
505
|
*
|
|
@@ -507,7 +507,7 @@ class N extends E {
|
|
|
507
507
|
* @package
|
|
508
508
|
*/
|
|
509
509
|
constructor(t, e, s) {
|
|
510
|
-
super(), this.createRequest = t,
|
|
510
|
+
super(), this.createRequest = t, qt(this, s), this._opts = s, this._method = s.method || "GET", this._uri = e, this._data = s.data !== void 0 ? s.data : null, this._create();
|
|
511
511
|
}
|
|
512
512
|
/**
|
|
513
513
|
* Creates the XHR object and sends the request.
|
|
@@ -516,7 +516,7 @@ class N extends E {
|
|
|
516
516
|
*/
|
|
517
517
|
_create() {
|
|
518
518
|
var t;
|
|
519
|
-
const e =
|
|
519
|
+
const e = ts(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
520
520
|
e.xdomain = !!this._opts.xd;
|
|
521
521
|
const s = this._xhr = this.createRequest(e);
|
|
522
522
|
try {
|
|
@@ -524,8 +524,8 @@ class N extends E {
|
|
|
524
524
|
try {
|
|
525
525
|
if (this._opts.extraHeaders) {
|
|
526
526
|
s.setDisableHeaderCheck && s.setDisableHeaderCheck(!0);
|
|
527
|
-
for (let
|
|
528
|
-
this._opts.extraHeaders.hasOwnProperty(
|
|
527
|
+
for (let n in this._opts.extraHeaders)
|
|
528
|
+
this._opts.extraHeaders.hasOwnProperty(n) && s.setRequestHeader(n, this._opts.extraHeaders[n]);
|
|
529
529
|
}
|
|
530
530
|
} catch {
|
|
531
531
|
}
|
|
@@ -539,21 +539,21 @@ class N extends E {
|
|
|
539
539
|
} catch {
|
|
540
540
|
}
|
|
541
541
|
(t = this._opts.cookieJar) === null || t === void 0 || t.addCookies(s), "withCredentials" in s && (s.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (s.timeout = this._opts.requestTimeout), s.onreadystatechange = () => {
|
|
542
|
-
var
|
|
543
|
-
s.readyState === 3 && ((
|
|
542
|
+
var n;
|
|
543
|
+
s.readyState === 3 && ((n = this._opts.cookieJar) === null || n === void 0 || n.parseCookies(
|
|
544
544
|
// @ts-ignore
|
|
545
545
|
s.getResponseHeader("set-cookie")
|
|
546
546
|
)), s.readyState === 4 && (s.status === 200 || s.status === 1223 ? this._onLoad() : this.setTimeoutFn(() => {
|
|
547
547
|
this._onError(typeof s.status == "number" ? s.status : 0);
|
|
548
548
|
}, 0));
|
|
549
549
|
}, s.send(this._data);
|
|
550
|
-
} catch (
|
|
550
|
+
} catch (n) {
|
|
551
551
|
this.setTimeoutFn(() => {
|
|
552
|
-
this._onError(
|
|
552
|
+
this._onError(n);
|
|
553
553
|
}, 0);
|
|
554
554
|
return;
|
|
555
555
|
}
|
|
556
|
-
typeof document < "u" && (this._index =
|
|
556
|
+
typeof document < "u" && (this._index = L.requestsCount++, L.requests[this._index] = this);
|
|
557
557
|
}
|
|
558
558
|
/**
|
|
559
559
|
* Called upon error.
|
|
@@ -570,12 +570,12 @@ 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 = pr, t)
|
|
574
574
|
try {
|
|
575
575
|
this._xhr.abort();
|
|
576
576
|
} catch {
|
|
577
577
|
}
|
|
578
|
-
typeof document < "u" && delete
|
|
578
|
+
typeof document < "u" && delete L.requests[this._index], this._xhr = null;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
/**
|
|
@@ -596,61 +596,61 @@ class N extends E {
|
|
|
596
596
|
this._cleanup();
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
|
-
|
|
600
|
-
|
|
599
|
+
L.requestsCount = 0;
|
|
600
|
+
L.requests = {};
|
|
601
601
|
if (typeof document < "u") {
|
|
602
602
|
if (typeof attachEvent == "function")
|
|
603
|
-
attachEvent("onunload",
|
|
603
|
+
attachEvent("onunload", Pe);
|
|
604
604
|
else if (typeof addEventListener == "function") {
|
|
605
|
-
const
|
|
606
|
-
addEventListener(
|
|
605
|
+
const r = "onpagehide" in R ? "pagehide" : "unload";
|
|
606
|
+
addEventListener(r, Pe, !1);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
function
|
|
610
|
-
for (let
|
|
611
|
-
|
|
609
|
+
function Pe() {
|
|
610
|
+
for (let r in L.requests)
|
|
611
|
+
L.requests.hasOwnProperty(r) && L.requests[r].abort();
|
|
612
612
|
}
|
|
613
|
-
const
|
|
614
|
-
const
|
|
613
|
+
const mr = function() {
|
|
614
|
+
const r = rs({
|
|
615
615
|
xdomain: !1
|
|
616
616
|
});
|
|
617
|
-
return
|
|
617
|
+
return r && r.responseType !== null;
|
|
618
618
|
}();
|
|
619
|
-
class
|
|
619
|
+
class gr extends yr {
|
|
620
620
|
constructor(t) {
|
|
621
621
|
super(t);
|
|
622
622
|
const e = t && t.forceBase64;
|
|
623
|
-
this.supportsBinary =
|
|
623
|
+
this.supportsBinary = mr && !e;
|
|
624
624
|
}
|
|
625
625
|
request(t = {}) {
|
|
626
|
-
return Object.assign(t, { xd: this.xd }, this.opts), new
|
|
626
|
+
return Object.assign(t, { xd: this.xd }, this.opts), new L(rs, this.uri(), t);
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
|
-
function
|
|
630
|
-
const t =
|
|
629
|
+
function rs(r) {
|
|
630
|
+
const t = r.xdomain;
|
|
631
631
|
try {
|
|
632
|
-
if (typeof XMLHttpRequest < "u" && (!t ||
|
|
632
|
+
if (typeof XMLHttpRequest < "u" && (!t || fr))
|
|
633
633
|
return new XMLHttpRequest();
|
|
634
634
|
} catch {
|
|
635
635
|
}
|
|
636
636
|
if (!t)
|
|
637
637
|
try {
|
|
638
|
-
return new
|
|
638
|
+
return new R[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
639
639
|
} catch {
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
const
|
|
643
|
-
class
|
|
642
|
+
const ns = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
643
|
+
class wr extends _e {
|
|
644
644
|
get name() {
|
|
645
645
|
return "websocket";
|
|
646
646
|
}
|
|
647
647
|
doOpen() {
|
|
648
|
-
const t = this.uri(), e = this.opts.protocols, s =
|
|
648
|
+
const t = this.uri(), e = this.opts.protocols, s = ns ? {} : ts(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
649
649
|
this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
|
|
650
650
|
try {
|
|
651
651
|
this.ws = this.createSocket(t, e, s);
|
|
652
|
-
} catch (
|
|
653
|
-
return this.emitReserved("error",
|
|
652
|
+
} catch (n) {
|
|
653
|
+
return this.emitReserved("error", n);
|
|
654
654
|
}
|
|
655
655
|
this.ws.binaryType = this.socket.binaryType, this.addEventListeners();
|
|
656
656
|
}
|
|
@@ -670,13 +670,13 @@ class As extends ue {
|
|
|
670
670
|
write(t) {
|
|
671
671
|
this.writable = !1;
|
|
672
672
|
for (let e = 0; e < t.length; e++) {
|
|
673
|
-
const s = t[e],
|
|
674
|
-
|
|
673
|
+
const s = t[e], n = e === t.length - 1;
|
|
674
|
+
we(s, this.supportsBinary, (i) => {
|
|
675
675
|
try {
|
|
676
676
|
this.doWrite(s, i);
|
|
677
677
|
} catch {
|
|
678
678
|
}
|
|
679
|
-
|
|
679
|
+
n && Ft(() => {
|
|
680
680
|
this.writable = !0, this.emitReserved("drain");
|
|
681
681
|
}, this.setTimeoutFn);
|
|
682
682
|
});
|
|
@@ -693,19 +693,19 @@ class As extends ue {
|
|
|
693
693
|
*/
|
|
694
694
|
uri() {
|
|
695
695
|
const t = this.opts.secure ? "wss" : "ws", e = this.query || {};
|
|
696
|
-
return this.opts.timestampRequests && (e[this.opts.timestampParam] =
|
|
696
|
+
return this.opts.timestampRequests && (e[this.opts.timestampParam] = es()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
|
-
const
|
|
700
|
-
class
|
|
699
|
+
const Gt = R.WebSocket || R.MozWebSocket;
|
|
700
|
+
class br extends wr {
|
|
701
701
|
createSocket(t, e, s) {
|
|
702
|
-
return
|
|
702
|
+
return ns ? new Gt(t, e, s) : e ? new Gt(t, e) : new Gt(t);
|
|
703
703
|
}
|
|
704
704
|
doWrite(t, e) {
|
|
705
705
|
this.ws.send(e);
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
|
-
class
|
|
708
|
+
class _r extends _e {
|
|
709
709
|
get name() {
|
|
710
710
|
return "webtransport";
|
|
711
711
|
}
|
|
@@ -721,12 +721,12 @@ class xs extends ue {
|
|
|
721
721
|
this.onError("webtransport error", t);
|
|
722
722
|
}), this._transport.ready.then(() => {
|
|
723
723
|
this._transport.createBidirectionalStream().then((t) => {
|
|
724
|
-
const e =
|
|
725
|
-
|
|
724
|
+
const e = er(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), n = tr();
|
|
725
|
+
n.readable.pipeTo(t.writable), this._writer = n.writable.getWriter();
|
|
726
726
|
const i = () => {
|
|
727
|
-
s.read().then(({ done:
|
|
728
|
-
|
|
729
|
-
}).catch((
|
|
727
|
+
s.read().then(({ done: c, value: d }) => {
|
|
728
|
+
c || (this.onPacket(d), i());
|
|
729
|
+
}).catch((c) => {
|
|
730
730
|
});
|
|
731
731
|
};
|
|
732
732
|
i();
|
|
@@ -738,9 +738,9 @@ class xs extends ue {
|
|
|
738
738
|
write(t) {
|
|
739
739
|
this.writable = !1;
|
|
740
740
|
for (let e = 0; e < t.length; e++) {
|
|
741
|
-
const s = t[e],
|
|
741
|
+
const s = t[e], n = e === t.length - 1;
|
|
742
742
|
this._writer.write(s).then(() => {
|
|
743
|
-
|
|
743
|
+
n && Ft(() => {
|
|
744
744
|
this.writable = !0, this.emitReserved("drain");
|
|
745
745
|
}, this.setTimeoutFn);
|
|
746
746
|
});
|
|
@@ -751,11 +751,11 @@ class xs extends ue {
|
|
|
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 Er = {
|
|
755
|
+
websocket: br,
|
|
756
|
+
webtransport: _r,
|
|
757
|
+
polling: gr
|
|
758
|
+
}, vr = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Tr = [
|
|
759
759
|
"source",
|
|
760
760
|
"protocol",
|
|
761
761
|
"authority",
|
|
@@ -771,31 +771,31 @@ const $s = {
|
|
|
771
771
|
"query",
|
|
772
772
|
"anchor"
|
|
773
773
|
];
|
|
774
|
-
function
|
|
775
|
-
if (
|
|
774
|
+
function Kt(r) {
|
|
775
|
+
if (r.length > 8e3)
|
|
776
776
|
throw "URI too long";
|
|
777
|
-
const t =
|
|
778
|
-
e != -1 && s != -1 && (
|
|
779
|
-
let
|
|
777
|
+
const t = r, e = r.indexOf("["), s = r.indexOf("]");
|
|
778
|
+
e != -1 && s != -1 && (r = r.substring(0, e) + r.substring(e, s).replace(/:/g, ";") + r.substring(s, r.length));
|
|
779
|
+
let n = vr.exec(r || ""), 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[Tr[o]] = n[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 = Sr(i, i.path), i.queryKey = Ir(i, i.query), i;
|
|
783
783
|
}
|
|
784
|
-
function
|
|
784
|
+
function Sr(r, 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 Ir(r, t) {
|
|
789
789
|
const e = {};
|
|
790
|
-
return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s,
|
|
791
|
-
|
|
790
|
+
return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, n, i) {
|
|
791
|
+
n && (e[n] = i);
|
|
792
792
|
}), e;
|
|
793
793
|
}
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
794
|
+
const zt = typeof addEventListener == "function" && typeof removeEventListener == "function", Ct = [];
|
|
795
|
+
zt && addEventListener("offline", () => {
|
|
796
|
+
Ct.forEach((r) => r());
|
|
797
797
|
}, !1);
|
|
798
|
-
class
|
|
798
|
+
class z extends E {
|
|
799
799
|
/**
|
|
800
800
|
* Socket constructor.
|
|
801
801
|
*
|
|
@@ -803,13 +803,13 @@ class J extends E {
|
|
|
803
803
|
* @param {Object} opts - options
|
|
804
804
|
*/
|
|
805
805
|
constructor(t, e) {
|
|
806
|
-
if (super(), this.binaryType =
|
|
807
|
-
const s =
|
|
806
|
+
if (super(), this.binaryType = rr, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, t && typeof t == "object" && (e = t, t = null), t) {
|
|
807
|
+
const s = Kt(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
|
-
} else e.host && (e.hostname =
|
|
810
|
-
|
|
811
|
-
const
|
|
812
|
-
this.transports.push(
|
|
809
|
+
} else e.host && (e.hostname = Kt(e.host).host);
|
|
810
|
+
qt(this, e), this.secure = e.secure != null ? e.secure : typeof location < "u" && location.protocol === "https:", e.hostname && !e.port && (e.port = this.secure ? "443" : "80"), this.hostname = e.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = e.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, e.transports.forEach((s) => {
|
|
811
|
+
const n = s.prototype.name;
|
|
812
|
+
this.transports.push(n), this._transportsByName[n] = s;
|
|
813
813
|
}), this.opts = Object.assign({
|
|
814
814
|
path: "/engine.io",
|
|
815
815
|
agent: !1,
|
|
@@ -824,13 +824,13 @@ class J 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 = lr(this.opts.query)), zt && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
828
828
|
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
829
829
|
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
830
830
|
this._onClose("transport close", {
|
|
831
831
|
description: "network connection lost"
|
|
832
832
|
});
|
|
833
|
-
},
|
|
833
|
+
}, Ct.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
|
|
834
834
|
}
|
|
835
835
|
/**
|
|
836
836
|
* Creates transport of the given type.
|
|
@@ -841,7 +841,7 @@ class J extends E {
|
|
|
841
841
|
*/
|
|
842
842
|
createTransport(t) {
|
|
843
843
|
const e = Object.assign({}, this.opts.query);
|
|
844
|
-
e.EIO =
|
|
844
|
+
e.EIO = Ze, e.transport = t, this.id && (e.sid = this.id);
|
|
845
845
|
const s = Object.assign({}, this.opts, {
|
|
846
846
|
query: e,
|
|
847
847
|
socket: this,
|
|
@@ -863,7 +863,7 @@ class J extends E {
|
|
|
863
863
|
}, 0);
|
|
864
864
|
return;
|
|
865
865
|
}
|
|
866
|
-
const t = this.opts.rememberUpgrade &&
|
|
866
|
+
const t = this.opts.rememberUpgrade && z.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 J extends E {
|
|
|
882
882
|
* @private
|
|
883
883
|
*/
|
|
884
884
|
onOpen() {
|
|
885
|
-
this.readyState = "open",
|
|
885
|
+
this.readyState = "open", z.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
|
|
886
886
|
}
|
|
887
887
|
/**
|
|
888
888
|
* Handles a packet.
|
|
@@ -958,8 +958,8 @@ class J extends E {
|
|
|
958
958
|
return this.writeBuffer;
|
|
959
959
|
let e = 1;
|
|
960
960
|
for (let s = 0; s < this.writeBuffer.length; s++) {
|
|
961
|
-
const
|
|
962
|
-
if (
|
|
961
|
+
const n = this.writeBuffer[s].data;
|
|
962
|
+
if (n && (e += ar(n)), s > 0 && e > this._maxPayload)
|
|
963
963
|
return this.writeBuffer.slice(0, s);
|
|
964
964
|
e += 2;
|
|
965
965
|
}
|
|
@@ -979,7 +979,7 @@ class J 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, Ft(() => {
|
|
983
983
|
this._onClose("ping timeout");
|
|
984
984
|
}, this.setTimeoutFn)), t;
|
|
985
985
|
}
|
|
@@ -1014,8 +1014,8 @@ class J extends E {
|
|
|
1014
1014
|
* @param {Function} fn - callback function.
|
|
1015
1015
|
* @private
|
|
1016
1016
|
*/
|
|
1017
|
-
_sendPacket(t, e, s,
|
|
1018
|
-
if (typeof e == "function" && (
|
|
1017
|
+
_sendPacket(t, e, s, n) {
|
|
1018
|
+
if (typeof e == "function" && (n = e, e = void 0), typeof s == "function" && (n = s, s = null), this.readyState === "closing" || this.readyState === "closed")
|
|
1019
1019
|
return;
|
|
1020
1020
|
s = s || {}, s.compress = s.compress !== !1;
|
|
1021
1021
|
const i = {
|
|
@@ -1023,7 +1023,7 @@ class J extends E {
|
|
|
1023
1023
|
data: e,
|
|
1024
1024
|
options: s
|
|
1025
1025
|
};
|
|
1026
|
-
this.emitReserved("packetCreate", i), this.writeBuffer.push(i),
|
|
1026
|
+
this.emitReserved("packetCreate", i), this.writeBuffer.push(i), n && this.once("flush", n), this.flush();
|
|
1027
1027
|
}
|
|
1028
1028
|
/**
|
|
1029
1029
|
* Closes the connection.
|
|
@@ -1046,7 +1046,7 @@ class J extends E {
|
|
|
1046
1046
|
* @private
|
|
1047
1047
|
*/
|
|
1048
1048
|
_onError(t) {
|
|
1049
|
-
if (
|
|
1049
|
+
if (z.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
|
}
|
|
@@ -1057,16 +1057,16 @@ class J extends E {
|
|
|
1057
1057
|
*/
|
|
1058
1058
|
_onClose(t, e) {
|
|
1059
1059
|
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
|
|
1060
|
-
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(),
|
|
1061
|
-
const s =
|
|
1062
|
-
s !== -1 &&
|
|
1060
|
+
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), zt && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
1061
|
+
const s = Ct.indexOf(this._offlineEventListener);
|
|
1062
|
+
s !== -1 && Ct.splice(s, 1);
|
|
1063
1063
|
}
|
|
1064
1064
|
this.readyState = "closed", this.id = null, this.emitReserved("close", t, e), this.writeBuffer = [], this._prevBufferLen = 0;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
1067
|
}
|
|
1068
|
-
|
|
1069
|
-
class
|
|
1068
|
+
z.protocol = Ze;
|
|
1069
|
+
class Or extends z {
|
|
1070
1070
|
constructor() {
|
|
1071
1071
|
super(...arguments), this._upgrades = [];
|
|
1072
1072
|
}
|
|
@@ -1083,42 +1083,42 @@ class Bs extends J {
|
|
|
1083
1083
|
*/
|
|
1084
1084
|
_probe(t) {
|
|
1085
1085
|
let e = this.createTransport(t), s = !1;
|
|
1086
|
-
|
|
1087
|
-
const
|
|
1088
|
-
s || (e.send([{ type: "ping", data: "probe" }]), e.once("packet", (
|
|
1086
|
+
z.priorWebsocketSuccess = !1;
|
|
1087
|
+
const n = () => {
|
|
1088
|
+
s || (e.send([{ type: "ping", data: "probe" }]), e.once("packet", (g) => {
|
|
1089
1089
|
if (!s)
|
|
1090
|
-
if (
|
|
1090
|
+
if (g.type === "pong" && g.data === "probe") {
|
|
1091
1091
|
if (this.upgrading = !0, this.emitReserved("upgrading", e), !e)
|
|
1092
1092
|
return;
|
|
1093
|
-
|
|
1094
|
-
s || this.readyState !== "closed" && (
|
|
1093
|
+
z.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
|
|
1094
|
+
s || this.readyState !== "closed" && (h(), 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 S = new Error("probe error");
|
|
1098
|
+
S.transport = e.name, this.emitReserved("upgradeError", S);
|
|
1099
1099
|
}
|
|
1100
1100
|
}));
|
|
1101
1101
|
};
|
|
1102
1102
|
function i() {
|
|
1103
|
-
s || (s = !0,
|
|
1103
|
+
s || (s = !0, h(), e.close(), e = null);
|
|
1104
1104
|
}
|
|
1105
|
-
const o = (
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1105
|
+
const o = (g) => {
|
|
1106
|
+
const S = new Error("probe error: " + g);
|
|
1107
|
+
S.transport = e.name, i(), this.emitReserved("upgradeError", S);
|
|
1108
1108
|
};
|
|
1109
|
-
function
|
|
1109
|
+
function c() {
|
|
1110
1110
|
o("transport closed");
|
|
1111
1111
|
}
|
|
1112
|
-
function
|
|
1112
|
+
function d() {
|
|
1113
1113
|
o("socket closed");
|
|
1114
1114
|
}
|
|
1115
|
-
function f(
|
|
1116
|
-
e &&
|
|
1115
|
+
function f(g) {
|
|
1116
|
+
e && g.name !== e.name && i();
|
|
1117
1117
|
}
|
|
1118
|
-
const
|
|
1119
|
-
e.removeListener("open",
|
|
1118
|
+
const h = () => {
|
|
1119
|
+
e.removeListener("open", n), e.removeListener("error", o), e.removeListener("close", c), this.off("close", d), this.off("upgrading", f);
|
|
1120
1120
|
};
|
|
1121
|
-
e.once("open",
|
|
1121
|
+
e.once("open", n), e.once("error", o), e.once("close", c), this.once("close", d), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && t !== "webtransport" ? this.setTimeoutFn(() => {
|
|
1122
1122
|
s || e.open();
|
|
1123
1123
|
}, 200) : e.open();
|
|
1124
1124
|
}
|
|
@@ -1138,82 +1138,82 @@ class Bs extends J {
|
|
|
1138
1138
|
return e;
|
|
1139
1139
|
}
|
|
1140
1140
|
}
|
|
1141
|
-
let
|
|
1141
|
+
let Ar = class extends Or {
|
|
1142
1142
|
constructor(t, e = {}) {
|
|
1143
|
-
const s = typeof t == "object",
|
|
1144
|
-
(!
|
|
1143
|
+
const s = typeof t == "object", n = s ? { ...t } : { ...e };
|
|
1144
|
+
(!n.transports || n.transports && typeof n.transports[0] == "string") && (n.transports = (n.transports || ["polling", "websocket", "webtransport"]).map((i) => Er[i]).filter((i) => !!i)), super(s ? n : t, n);
|
|
1145
1145
|
}
|
|
1146
1146
|
};
|
|
1147
|
-
function
|
|
1148
|
-
let s =
|
|
1149
|
-
e = e || typeof location < "u" && location,
|
|
1147
|
+
function kr(r, t = "", e) {
|
|
1148
|
+
let s = r;
|
|
1149
|
+
e = e || typeof location < "u" && location, r == null && (r = e.protocol + "//" + e.host), typeof r == "string" && (r.charAt(0) === "/" && (r.charAt(1) === "/" ? r = e.protocol + r : r = e.host + r), /^(https?|wss?):\/\//.test(r) || (typeof e < "u" ? r = e.protocol + "//" + r : r = "https://" + r), s = Kt(r)), 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 Cr = typeof ArrayBuffer == "function", xr = (r) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(r) : r.buffer instanceof ArrayBuffer, is = Object.prototype.toString, Rr = typeof Blob == "function" || typeof Blob < "u" && is.call(Blob) === "[object BlobConstructor]", $r = typeof File == "function" || typeof File < "u" && is.call(File) === "[object FileConstructor]";
|
|
1154
|
+
function Ee(r) {
|
|
1155
|
+
return Cr && (r instanceof ArrayBuffer || xr(r)) || Rr && r instanceof Blob || $r && r instanceof File;
|
|
1156
1156
|
}
|
|
1157
|
-
function
|
|
1158
|
-
if (!
|
|
1157
|
+
function xt(r, t) {
|
|
1158
|
+
if (!r || typeof r != "object")
|
|
1159
1159
|
return !1;
|
|
1160
|
-
if (Array.isArray(
|
|
1161
|
-
for (let e = 0, s =
|
|
1162
|
-
if (
|
|
1160
|
+
if (Array.isArray(r)) {
|
|
1161
|
+
for (let e = 0, s = r.length; e < s; e++)
|
|
1162
|
+
if (xt(r[e]))
|
|
1163
1163
|
return !0;
|
|
1164
1164
|
return !1;
|
|
1165
1165
|
}
|
|
1166
|
-
if (
|
|
1166
|
+
if (Ee(r))
|
|
1167
1167
|
return !0;
|
|
1168
|
-
if (
|
|
1169
|
-
return
|
|
1170
|
-
for (const e in
|
|
1171
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
1168
|
+
if (r.toJSON && typeof r.toJSON == "function" && arguments.length === 1)
|
|
1169
|
+
return xt(r.toJSON(), !0);
|
|
1170
|
+
for (const e in r)
|
|
1171
|
+
if (Object.prototype.hasOwnProperty.call(r, e) && xt(r[e]))
|
|
1172
1172
|
return !0;
|
|
1173
1173
|
return !1;
|
|
1174
1174
|
}
|
|
1175
|
-
function
|
|
1176
|
-
const t = [], e =
|
|
1177
|
-
return s.data =
|
|
1175
|
+
function Nr(r) {
|
|
1176
|
+
const t = [], e = r.data, s = r;
|
|
1177
|
+
return s.data = Xt(e, t), s.attachments = t.length, { packet: s, buffers: t };
|
|
1178
1178
|
}
|
|
1179
|
-
function
|
|
1180
|
-
if (!
|
|
1181
|
-
return
|
|
1182
|
-
if (
|
|
1179
|
+
function Xt(r, t) {
|
|
1180
|
+
if (!r)
|
|
1181
|
+
return r;
|
|
1182
|
+
if (Ee(r)) {
|
|
1183
1183
|
const e = { _placeholder: !0, num: t.length };
|
|
1184
|
-
return t.push(
|
|
1185
|
-
} else if (Array.isArray(
|
|
1186
|
-
const e = new Array(
|
|
1187
|
-
for (let s = 0; s <
|
|
1188
|
-
e[s] =
|
|
1184
|
+
return t.push(r), e;
|
|
1185
|
+
} else if (Array.isArray(r)) {
|
|
1186
|
+
const e = new Array(r.length);
|
|
1187
|
+
for (let s = 0; s < r.length; s++)
|
|
1188
|
+
e[s] = Xt(r[s], t);
|
|
1189
1189
|
return e;
|
|
1190
|
-
} else if (typeof
|
|
1190
|
+
} else if (typeof r == "object" && !(r instanceof Date)) {
|
|
1191
1191
|
const e = {};
|
|
1192
|
-
for (const s in
|
|
1193
|
-
Object.prototype.hasOwnProperty.call(
|
|
1192
|
+
for (const s in r)
|
|
1193
|
+
Object.prototype.hasOwnProperty.call(r, s) && (e[s] = Xt(r[s], t));
|
|
1194
1194
|
return e;
|
|
1195
1195
|
}
|
|
1196
|
-
return
|
|
1196
|
+
return r;
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1199
|
-
return
|
|
1198
|
+
function Pr(r, t) {
|
|
1199
|
+
return r.data = Qt(r.data, t), delete r.attachments, r;
|
|
1200
1200
|
}
|
|
1201
|
-
function
|
|
1202
|
-
if (!
|
|
1203
|
-
return
|
|
1204
|
-
if (
|
|
1205
|
-
if (typeof
|
|
1206
|
-
return t[
|
|
1201
|
+
function Qt(r, t) {
|
|
1202
|
+
if (!r)
|
|
1203
|
+
return r;
|
|
1204
|
+
if (r && r._placeholder === !0) {
|
|
1205
|
+
if (typeof r.num == "number" && r.num >= 0 && r.num < t.length)
|
|
1206
|
+
return t[r.num];
|
|
1207
1207
|
throw new Error("illegal attachments");
|
|
1208
|
-
} else if (Array.isArray(
|
|
1209
|
-
for (let e = 0; e <
|
|
1210
|
-
|
|
1211
|
-
else if (typeof
|
|
1212
|
-
for (const e in
|
|
1213
|
-
Object.prototype.hasOwnProperty.call(
|
|
1214
|
-
return
|
|
1208
|
+
} else if (Array.isArray(r))
|
|
1209
|
+
for (let e = 0; e < r.length; e++)
|
|
1210
|
+
r[e] = Qt(r[e], t);
|
|
1211
|
+
else if (typeof r == "object")
|
|
1212
|
+
for (const e in r)
|
|
1213
|
+
Object.prototype.hasOwnProperty.call(r, e) && (r[e] = Qt(r[e], t));
|
|
1214
|
+
return r;
|
|
1215
1215
|
}
|
|
1216
|
-
const
|
|
1216
|
+
const Br = [
|
|
1217
1217
|
"connect",
|
|
1218
1218
|
// used on the client side
|
|
1219
1219
|
"connect_error",
|
|
@@ -1227,11 +1227,11 @@ const Gs = [
|
|
|
1227
1227
|
"removeListener"
|
|
1228
1228
|
// used by the Node.js EventEmitter
|
|
1229
1229
|
];
|
|
1230
|
-
var
|
|
1231
|
-
(function(
|
|
1232
|
-
|
|
1233
|
-
})(
|
|
1234
|
-
class
|
|
1230
|
+
var w;
|
|
1231
|
+
(function(r) {
|
|
1232
|
+
r[r.CONNECT = 0] = "CONNECT", r[r.DISCONNECT = 1] = "DISCONNECT", r[r.EVENT = 2] = "EVENT", r[r.ACK = 3] = "ACK", r[r.CONNECT_ERROR = 4] = "CONNECT_ERROR", r[r.BINARY_EVENT = 5] = "BINARY_EVENT", r[r.BINARY_ACK = 6] = "BINARY_ACK";
|
|
1233
|
+
})(w || (w = {}));
|
|
1234
|
+
class Lr {
|
|
1235
1235
|
/**
|
|
1236
1236
|
* Encoder constructor
|
|
1237
1237
|
*
|
|
@@ -1247,8 +1247,8 @@ class Vs {
|
|
|
1247
1247
|
* @param {Object} obj - packet object
|
|
1248
1248
|
*/
|
|
1249
1249
|
encode(t) {
|
|
1250
|
-
return (t.type ===
|
|
1251
|
-
type: t.type ===
|
|
1250
|
+
return (t.type === w.EVENT || t.type === w.ACK) && xt(t) ? this.encodeAsBinary({
|
|
1251
|
+
type: t.type === w.EVENT ? w.BINARY_EVENT : w.BINARY_ACK,
|
|
1252
1252
|
nsp: t.nsp,
|
|
1253
1253
|
data: t.data,
|
|
1254
1254
|
id: t.id
|
|
@@ -1259,7 +1259,7 @@ class Vs {
|
|
|
1259
1259
|
*/
|
|
1260
1260
|
encodeAsString(t) {
|
|
1261
1261
|
let e = "" + t.type;
|
|
1262
|
-
return (t.type ===
|
|
1262
|
+
return (t.type === w.BINARY_EVENT || t.type === w.BINARY_ACK) && (e += t.attachments + "-"), t.nsp && t.nsp !== "/" && (e += t.nsp + ","), t.id != null && (e += t.id), t.data != null && (e += JSON.stringify(t.data, this.replacer)), e;
|
|
1263
1263
|
}
|
|
1264
1264
|
/**
|
|
1265
1265
|
* Encode packet as 'buffer sequence' by removing blobs, and
|
|
@@ -1267,11 +1267,11 @@ class Vs {
|
|
|
1267
1267
|
* a list of buffers.
|
|
1268
1268
|
*/
|
|
1269
1269
|
encodeAsBinary(t) {
|
|
1270
|
-
const e =
|
|
1271
|
-
return
|
|
1270
|
+
const e = Nr(t), s = this.encodeAsString(e.packet), n = e.buffers;
|
|
1271
|
+
return n.unshift(s), n;
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
|
-
class
|
|
1274
|
+
class ve extends E {
|
|
1275
1275
|
/**
|
|
1276
1276
|
* Decoder constructor
|
|
1277
1277
|
*/
|
|
@@ -1292,9 +1292,9 @@ class fe extends E {
|
|
|
1292
1292
|
if (this.reconstructor)
|
|
1293
1293
|
throw new Error("got plaintext data when reconstructing a packet");
|
|
1294
1294
|
e = this.decodeString(t);
|
|
1295
|
-
const s = e.type ===
|
|
1296
|
-
s || e.type ===
|
|
1297
|
-
} else if (
|
|
1295
|
+
const s = e.type === w.BINARY_EVENT;
|
|
1296
|
+
s || e.type === w.BINARY_ACK ? (e.type = s ? w.EVENT : w.ACK, this.reconstructor = new Fr(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
|
|
1297
|
+
} else if (Ee(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
|
|
@@ -1313,21 +1313,21 @@ class fe extends E {
|
|
|
1313
1313
|
const s = {
|
|
1314
1314
|
type: Number(t.charAt(0))
|
|
1315
1315
|
};
|
|
1316
|
-
if (
|
|
1316
|
+
if (w[s.type] === void 0)
|
|
1317
1317
|
throw new Error("unknown packet type " + s.type);
|
|
1318
|
-
if (s.type ===
|
|
1318
|
+
if (s.type === w.BINARY_EVENT || s.type === w.BINARY_ACK) {
|
|
1319
1319
|
const i = e + 1;
|
|
1320
1320
|
for (; t.charAt(++e) !== "-" && e != t.length; )
|
|
1321
1321
|
;
|
|
1322
1322
|
const o = t.substring(i, e);
|
|
1323
1323
|
if (o != Number(o) || t.charAt(e) !== "-")
|
|
1324
1324
|
throw new Error("Illegal attachments");
|
|
1325
|
-
const
|
|
1326
|
-
if (!
|
|
1325
|
+
const c = Number(o);
|
|
1326
|
+
if (!qr(c) || c < 0)
|
|
1327
1327
|
throw new Error("Illegal attachments");
|
|
1328
|
-
if (
|
|
1328
|
+
if (c > this.opts.maxAttachments)
|
|
1329
1329
|
throw new Error("too many attachments");
|
|
1330
|
-
s.attachments =
|
|
1330
|
+
s.attachments = c;
|
|
1331
1331
|
}
|
|
1332
1332
|
if (t.charAt(e + 1) === "/") {
|
|
1333
1333
|
const i = e + 1;
|
|
@@ -1336,8 +1336,8 @@ class fe extends E {
|
|
|
1336
1336
|
s.nsp = t.substring(i, e);
|
|
1337
1337
|
} else
|
|
1338
1338
|
s.nsp = "/";
|
|
1339
|
-
const
|
|
1340
|
-
if (
|
|
1339
|
+
const n = t.charAt(e + 1);
|
|
1340
|
+
if (n !== "" && Number(n) == n) {
|
|
1341
1341
|
const i = e + 1;
|
|
1342
1342
|
for (; ++e; ) {
|
|
1343
1343
|
const o = t.charAt(e);
|
|
@@ -1352,7 +1352,7 @@ class fe extends E {
|
|
|
1352
1352
|
}
|
|
1353
1353
|
if (t.charAt(++e)) {
|
|
1354
1354
|
const i = this.tryParse(t.substr(e));
|
|
1355
|
-
if (
|
|
1355
|
+
if (ve.isPayloadValid(s.type, i))
|
|
1356
1356
|
s.data = i;
|
|
1357
1357
|
else
|
|
1358
1358
|
throw new Error("invalid payload");
|
|
@@ -1368,17 +1368,17 @@ class fe extends E {
|
|
|
1368
1368
|
}
|
|
1369
1369
|
static isPayloadValid(t, e) {
|
|
1370
1370
|
switch (t) {
|
|
1371
|
-
case
|
|
1372
|
-
return
|
|
1373
|
-
case
|
|
1371
|
+
case w.CONNECT:
|
|
1372
|
+
return Be(e);
|
|
1373
|
+
case w.DISCONNECT:
|
|
1374
1374
|
return e === void 0;
|
|
1375
|
-
case
|
|
1376
|
-
return typeof e == "string" ||
|
|
1377
|
-
case
|
|
1378
|
-
case
|
|
1379
|
-
return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" &&
|
|
1380
|
-
case
|
|
1381
|
-
case
|
|
1375
|
+
case w.CONNECT_ERROR:
|
|
1376
|
+
return typeof e == "string" || Be(e);
|
|
1377
|
+
case w.EVENT:
|
|
1378
|
+
case w.BINARY_EVENT:
|
|
1379
|
+
return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Br.indexOf(e[0]) === -1);
|
|
1380
|
+
case w.ACK:
|
|
1381
|
+
case w.BINARY_ACK:
|
|
1382
1382
|
return Array.isArray(e);
|
|
1383
1383
|
}
|
|
1384
1384
|
}
|
|
@@ -1389,7 +1389,7 @@ class fe extends E {
|
|
|
1389
1389
|
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
1392
|
-
class
|
|
1392
|
+
class Fr {
|
|
1393
1393
|
constructor(t) {
|
|
1394
1394
|
this.packet = t, this.buffers = [], this.reconPack = t;
|
|
1395
1395
|
}
|
|
@@ -1403,7 +1403,7 @@ class Js {
|
|
|
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 = Pr(this.reconPack, this.buffers);
|
|
1407
1407
|
return this.finishedReconstruction(), e;
|
|
1408
1408
|
}
|
|
1409
1409
|
return null;
|
|
@@ -1415,26 +1415,26 @@ class Js {
|
|
|
1415
1415
|
this.reconPack = null, this.buffers = [];
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
|
-
const
|
|
1419
|
-
return typeof
|
|
1418
|
+
const qr = Number.isInteger || function(r) {
|
|
1419
|
+
return typeof r == "number" && isFinite(r) && Math.floor(r) === r;
|
|
1420
1420
|
};
|
|
1421
|
-
function
|
|
1422
|
-
return Object.prototype.toString.call(
|
|
1421
|
+
function Be(r) {
|
|
1422
|
+
return Object.prototype.toString.call(r) === "[object Object]";
|
|
1423
1423
|
}
|
|
1424
|
-
const
|
|
1424
|
+
const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1425
1425
|
__proto__: null,
|
|
1426
|
-
Decoder:
|
|
1427
|
-
Encoder:
|
|
1426
|
+
Decoder: ve,
|
|
1427
|
+
Encoder: Lr,
|
|
1428
1428
|
get PacketType() {
|
|
1429
|
-
return
|
|
1429
|
+
return w;
|
|
1430
1430
|
}
|
|
1431
1431
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1432
|
-
function
|
|
1433
|
-
return
|
|
1434
|
-
|
|
1432
|
+
function N(r, t, e) {
|
|
1433
|
+
return r.on(t, e), function() {
|
|
1434
|
+
r.off(t, e);
|
|
1435
1435
|
};
|
|
1436
1436
|
}
|
|
1437
|
-
const
|
|
1437
|
+
const Ur = Object.freeze({
|
|
1438
1438
|
connect: 1,
|
|
1439
1439
|
connect_error: 1,
|
|
1440
1440
|
disconnect: 1,
|
|
@@ -1443,7 +1443,7 @@ const Ks = Object.freeze({
|
|
|
1443
1443
|
newListener: 1,
|
|
1444
1444
|
removeListener: 1
|
|
1445
1445
|
});
|
|
1446
|
-
class
|
|
1446
|
+
class os extends E {
|
|
1447
1447
|
/**
|
|
1448
1448
|
* `Socket` constructor.
|
|
1449
1449
|
*/
|
|
@@ -1477,10 +1477,10 @@ class Me extends E {
|
|
|
1477
1477
|
return;
|
|
1478
1478
|
const t = this.io;
|
|
1479
1479
|
this.subs = [
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1480
|
+
N(t, "open", this.onopen.bind(this)),
|
|
1481
|
+
N(t, "packet", this.onpacket.bind(this)),
|
|
1482
|
+
N(t, "error", this.onerror.bind(this)),
|
|
1483
|
+
N(t, "close", this.onclose.bind(this))
|
|
1484
1484
|
];
|
|
1485
1485
|
}
|
|
1486
1486
|
/**
|
|
@@ -1558,39 +1558,39 @@ class Me extends E {
|
|
|
1558
1558
|
* @return self
|
|
1559
1559
|
*/
|
|
1560
1560
|
emit(t, ...e) {
|
|
1561
|
-
var s,
|
|
1562
|
-
if (
|
|
1561
|
+
var s, n, i;
|
|
1562
|
+
if (Ur.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;
|
|
1566
1566
|
const o = {
|
|
1567
|
-
type:
|
|
1567
|
+
type: w.EVENT,
|
|
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 h = this.ids++, g = e.pop();
|
|
1572
|
+
this._registerAckCallback(h, g), o.id = h;
|
|
1573
1573
|
}
|
|
1574
|
-
const
|
|
1575
|
-
return this.flags.volatile && !
|
|
1574
|
+
const c = (n = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || n === void 0 ? void 0 : n.writable, d = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
|
|
1575
|
+
return this.flags.volatile && !c || (d ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
|
|
1576
1576
|
}
|
|
1577
1577
|
/**
|
|
1578
1578
|
* @private
|
|
1579
1579
|
*/
|
|
1580
1580
|
_registerAckCallback(t, e) {
|
|
1581
1581
|
var s;
|
|
1582
|
-
const
|
|
1583
|
-
if (
|
|
1582
|
+
const n = (s = this.flags.timeout) !== null && s !== void 0 ? s : this._opts.ackTimeout;
|
|
1583
|
+
if (n === void 0) {
|
|
1584
1584
|
this.acks[t] = e;
|
|
1585
1585
|
return;
|
|
1586
1586
|
}
|
|
1587
1587
|
const i = this.io.setTimeoutFn(() => {
|
|
1588
1588
|
delete this.acks[t];
|
|
1589
|
-
for (let
|
|
1590
|
-
this.sendBuffer[
|
|
1589
|
+
for (let c = 0; c < this.sendBuffer.length; c++)
|
|
1590
|
+
this.sendBuffer[c].id === t && this.sendBuffer.splice(c, 1);
|
|
1591
1591
|
e.call(this, new Error("operation has timed out"));
|
|
1592
|
-
},
|
|
1593
|
-
this.io.clearTimeoutFn(i), e.apply(this,
|
|
1592
|
+
}, n), o = (...c) => {
|
|
1593
|
+
this.io.clearTimeoutFn(i), e.apply(this, c);
|
|
1594
1594
|
};
|
|
1595
1595
|
o.withError = !0, this.acks[t] = o;
|
|
1596
1596
|
}
|
|
@@ -1611,8 +1611,8 @@ class Me extends E {
|
|
|
1611
1611
|
* @return a Promise that will be fulfilled when the server acknowledges the event
|
|
1612
1612
|
*/
|
|
1613
1613
|
emitWithAck(t, ...e) {
|
|
1614
|
-
return new Promise((s,
|
|
1615
|
-
const i = (o,
|
|
1614
|
+
return new Promise((s, n) => {
|
|
1615
|
+
const i = (o, c) => o ? n(o) : s(c);
|
|
1616
1616
|
i.withError = !0, e.push(i), this.emit(t, ...e);
|
|
1617
1617
|
});
|
|
1618
1618
|
}
|
|
@@ -1631,7 +1631,7 @@ class Me extends E {
|
|
|
1631
1631
|
args: t,
|
|
1632
1632
|
flags: Object.assign({ fromQueue: !0 }, this.flags)
|
|
1633
1633
|
};
|
|
1634
|
-
t.push((
|
|
1634
|
+
t.push((n, ...i) => (this._queue[0], n !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), e && e(n)) : (this._queue.shift(), e && e(null, ...i)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
|
|
1635
1635
|
}
|
|
1636
1636
|
/**
|
|
1637
1637
|
* Send the first packet of the queue, and wait for an acknowledgement from the server.
|
|
@@ -1672,7 +1672,7 @@ class Me extends E {
|
|
|
1672
1672
|
*/
|
|
1673
1673
|
_sendConnectPacket(t) {
|
|
1674
1674
|
this.packet({
|
|
1675
|
-
type:
|
|
1675
|
+
type: w.CONNECT,
|
|
1676
1676
|
data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, t) : t
|
|
1677
1677
|
});
|
|
1678
1678
|
}
|
|
@@ -1718,21 +1718,21 @@ class Me extends E {
|
|
|
1718
1718
|
onpacket(t) {
|
|
1719
1719
|
if (t.nsp === this.nsp)
|
|
1720
1720
|
switch (t.type) {
|
|
1721
|
-
case
|
|
1721
|
+
case w.CONNECT:
|
|
1722
1722
|
t.data && t.data.sid ? this.onconnect(t.data.sid, t.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
|
|
1723
1723
|
break;
|
|
1724
|
-
case
|
|
1725
|
-
case
|
|
1724
|
+
case w.EVENT:
|
|
1725
|
+
case w.BINARY_EVENT:
|
|
1726
1726
|
this.onevent(t);
|
|
1727
1727
|
break;
|
|
1728
|
-
case
|
|
1729
|
-
case
|
|
1728
|
+
case w.ACK:
|
|
1729
|
+
case w.BINARY_ACK:
|
|
1730
1730
|
this.onack(t);
|
|
1731
1731
|
break;
|
|
1732
|
-
case
|
|
1732
|
+
case w.DISCONNECT:
|
|
1733
1733
|
this.ondisconnect();
|
|
1734
1734
|
break;
|
|
1735
|
-
case
|
|
1735
|
+
case w.CONNECT_ERROR:
|
|
1736
1736
|
this.destroy();
|
|
1737
1737
|
const s = new Error(t.data.message);
|
|
1738
1738
|
s.data = t.data.data, this.emitReserved("connect_error", s);
|
|
@@ -1765,11 +1765,11 @@ class Me extends E {
|
|
|
1765
1765
|
ack(t) {
|
|
1766
1766
|
const e = this;
|
|
1767
1767
|
let s = !1;
|
|
1768
|
-
return function(...
|
|
1768
|
+
return function(...n) {
|
|
1769
1769
|
s || (s = !0, e.packet({
|
|
1770
|
-
type:
|
|
1770
|
+
type: w.ACK,
|
|
1771
1771
|
id: t,
|
|
1772
|
-
data:
|
|
1772
|
+
data: n
|
|
1773
1773
|
}));
|
|
1774
1774
|
};
|
|
1775
1775
|
}
|
|
@@ -1836,7 +1836,7 @@ class Me extends E {
|
|
|
1836
1836
|
* @return self
|
|
1837
1837
|
*/
|
|
1838
1838
|
disconnect() {
|
|
1839
|
-
return this.connected && this.packet({ type:
|
|
1839
|
+
return this.connected && this.packet({ type: w.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
|
|
1840
1840
|
}
|
|
1841
1841
|
/**
|
|
1842
1842
|
* Alias for {@link disconnect()}.
|
|
@@ -2035,39 +2035,39 @@ class Me extends E {
|
|
|
2035
2035
|
}
|
|
2036
2036
|
}
|
|
2037
2037
|
}
|
|
2038
|
-
function
|
|
2039
|
-
|
|
2038
|
+
function ut(r) {
|
|
2039
|
+
r = r || {}, this.ms = r.min || 100, this.max = r.max || 1e4, this.factor = r.factor || 2, this.jitter = r.jitter > 0 && r.jitter <= 1 ? r.jitter : 0, this.attempts = 0;
|
|
2040
2040
|
}
|
|
2041
|
-
|
|
2042
|
-
var
|
|
2041
|
+
ut.prototype.duration = function() {
|
|
2042
|
+
var r = this.ms * Math.pow(this.factor, this.attempts++);
|
|
2043
2043
|
if (this.jitter) {
|
|
2044
|
-
var t = Math.random(), e = Math.floor(t * this.jitter *
|
|
2045
|
-
|
|
2044
|
+
var t = Math.random(), e = Math.floor(t * this.jitter * r);
|
|
2045
|
+
r = Math.floor(t * 10) & 1 ? r + e : r - e;
|
|
2046
2046
|
}
|
|
2047
|
-
return Math.min(
|
|
2047
|
+
return Math.min(r, this.max) | 0;
|
|
2048
2048
|
};
|
|
2049
|
-
|
|
2049
|
+
ut.prototype.reset = function() {
|
|
2050
2050
|
this.attempts = 0;
|
|
2051
2051
|
};
|
|
2052
|
-
|
|
2053
|
-
this.ms =
|
|
2052
|
+
ut.prototype.setMin = function(r) {
|
|
2053
|
+
this.ms = r;
|
|
2054
2054
|
};
|
|
2055
|
-
|
|
2056
|
-
this.max =
|
|
2055
|
+
ut.prototype.setMax = function(r) {
|
|
2056
|
+
this.max = r;
|
|
2057
2057
|
};
|
|
2058
|
-
|
|
2059
|
-
this.jitter =
|
|
2058
|
+
ut.prototype.setJitter = function(r) {
|
|
2059
|
+
this.jitter = r;
|
|
2060
2060
|
};
|
|
2061
|
-
class
|
|
2061
|
+
class Zt 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,
|
|
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, qt(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 ut({
|
|
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
|
|
2070
|
-
this.encoder = new
|
|
2069
|
+
const n = e.parser || Dr;
|
|
2070
|
+
this.encoder = new n.Encoder(), this.decoder = new n.Decoder(), this._autoConnect = e.autoConnect !== !1, this._autoConnect && this.open();
|
|
2071
2071
|
}
|
|
2072
2072
|
reconnection(t) {
|
|
2073
2073
|
return arguments.length ? (this._reconnection = !!t, t || (this.skipReconnect = !0), this) : this._reconnection;
|
|
@@ -2109,23 +2109,23 @@ 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 Ar(this.uri, this.opts);
|
|
2113
2113
|
const e = this.engine, s = this;
|
|
2114
2114
|
this._readyState = "opening", this.skipReconnect = !1;
|
|
2115
|
-
const
|
|
2115
|
+
const n = N(e, "open", function() {
|
|
2116
2116
|
s.onopen(), t && t();
|
|
2117
|
-
}), i = (
|
|
2118
|
-
this.cleanup(), this._readyState = "closed", this.emitReserved("error",
|
|
2119
|
-
}, o =
|
|
2117
|
+
}), i = (c) => {
|
|
2118
|
+
this.cleanup(), this._readyState = "closed", this.emitReserved("error", c), t ? t(c) : this.maybeReconnectOnOpen();
|
|
2119
|
+
}, o = N(e, "error", i);
|
|
2120
2120
|
if (this._timeout !== !1) {
|
|
2121
|
-
const
|
|
2122
|
-
|
|
2123
|
-
},
|
|
2124
|
-
this.opts.autoUnref &&
|
|
2125
|
-
this.clearTimeoutFn(
|
|
2121
|
+
const c = this._timeout, d = this.setTimeoutFn(() => {
|
|
2122
|
+
n(), i(new Error("timeout")), e.close();
|
|
2123
|
+
}, c);
|
|
2124
|
+
this.opts.autoUnref && d.unref(), this.subs.push(() => {
|
|
2125
|
+
this.clearTimeoutFn(d);
|
|
2126
2126
|
});
|
|
2127
2127
|
}
|
|
2128
|
-
return this.subs.push(
|
|
2128
|
+
return this.subs.push(n), this.subs.push(o), this;
|
|
2129
2129
|
}
|
|
2130
2130
|
/**
|
|
2131
2131
|
* Alias for open()
|
|
@@ -2145,12 +2145,12 @@ class Jt extends E {
|
|
|
2145
2145
|
this.cleanup(), this._readyState = "open", this.emitReserved("open");
|
|
2146
2146
|
const t = this.engine;
|
|
2147
2147
|
this.subs.push(
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2148
|
+
N(t, "ping", this.onping.bind(this)),
|
|
2149
|
+
N(t, "data", this.ondata.bind(this)),
|
|
2150
|
+
N(t, "error", this.onerror.bind(this)),
|
|
2151
|
+
N(t, "close", this.onclose.bind(this)),
|
|
2152
2152
|
// @ts-ignore
|
|
2153
|
-
|
|
2153
|
+
N(this.decoder, "decoded", this.ondecoded.bind(this))
|
|
2154
2154
|
);
|
|
2155
2155
|
}
|
|
2156
2156
|
/**
|
|
@@ -2179,7 +2179,7 @@ class Jt extends E {
|
|
|
2179
2179
|
* @private
|
|
2180
2180
|
*/
|
|
2181
2181
|
ondecoded(t) {
|
|
2182
|
-
|
|
2182
|
+
Ft(() => {
|
|
2183
2183
|
this.emitReserved("packet", t);
|
|
2184
2184
|
}, this.setTimeoutFn);
|
|
2185
2185
|
}
|
|
@@ -2199,7 +2199,7 @@ class Jt extends E {
|
|
|
2199
2199
|
*/
|
|
2200
2200
|
socket(t, e) {
|
|
2201
2201
|
let s = this.nsps[t];
|
|
2202
|
-
return s ? this._autoConnect && !s.active && s.connect() : (s = new
|
|
2202
|
+
return s ? this._autoConnect && !s.active && s.connect() : (s = new os(this, t, e), this.nsps[t] = s), s;
|
|
2203
2203
|
}
|
|
2204
2204
|
/**
|
|
2205
2205
|
* Called upon a socket close.
|
|
@@ -2277,8 +2277,8 @@ class Jt extends E {
|
|
|
2277
2277
|
const e = this.backoff.duration();
|
|
2278
2278
|
this._reconnecting = !0;
|
|
2279
2279
|
const s = this.setTimeoutFn(() => {
|
|
2280
|
-
t.skipReconnect || (this.emitReserved("reconnect_attempt", t.backoff.attempts), !t.skipReconnect && t.open((
|
|
2281
|
-
|
|
2280
|
+
t.skipReconnect || (this.emitReserved("reconnect_attempt", t.backoff.attempts), !t.skipReconnect && t.open((n) => {
|
|
2281
|
+
n ? (t._reconnecting = !1, t.reconnect(), this.emitReserved("reconnect_error", n)) : t.onreconnect();
|
|
2282
2282
|
}));
|
|
2283
2283
|
}, e);
|
|
2284
2284
|
this.opts.autoUnref && s.unref(), this.subs.push(() => {
|
|
@@ -2296,100 +2296,205 @@ class Jt extends E {
|
|
|
2296
2296
|
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
|
|
2297
2297
|
}
|
|
2298
2298
|
}
|
|
2299
|
-
const
|
|
2300
|
-
function
|
|
2301
|
-
typeof
|
|
2302
|
-
const e =
|
|
2303
|
-
let
|
|
2304
|
-
return
|
|
2299
|
+
const ft = {};
|
|
2300
|
+
function wt(r, t) {
|
|
2301
|
+
typeof r == "object" && (t = r, r = void 0), t = t || {};
|
|
2302
|
+
const e = kr(r, t.path || "/socket.io"), s = e.source, n = e.id, i = e.path, o = ft[n] && i in ft[n].nsps, c = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
|
|
2303
|
+
let d;
|
|
2304
|
+
return c ? d = new Zt(s, t) : (ft[n] || (ft[n] = new Zt(s, t)), d = ft[n]), e.query && !t.query && (t.query = e.queryKey), d.socket(e.path, t);
|
|
2305
2305
|
}
|
|
2306
|
-
Object.assign(
|
|
2307
|
-
Manager:
|
|
2308
|
-
Socket:
|
|
2309
|
-
io:
|
|
2310
|
-
connect:
|
|
2306
|
+
Object.assign(wt, {
|
|
2307
|
+
Manager: Zt,
|
|
2308
|
+
Socket: os,
|
|
2309
|
+
io: wt,
|
|
2310
|
+
connect: wt
|
|
2311
2311
|
});
|
|
2312
|
-
|
|
2312
|
+
const te = "thatopen/document@1", Le = "document.json", Fe = () => `v-${Date.now()}`;
|
|
2313
|
+
function jr(r) {
|
|
2314
|
+
return String(r._id ?? r.id ?? "");
|
|
2315
|
+
}
|
|
2316
|
+
var bt, ee;
|
|
2317
|
+
class as {
|
|
2318
|
+
constructor(t, e) {
|
|
2319
|
+
b(this, bt);
|
|
2320
|
+
this.client = t, this.projectId = e;
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* The document's descriptor, read and validated, or null when the folder
|
|
2324
|
+
* has none yet (an old folder, or a plain folder that is not a document).
|
|
2325
|
+
*/
|
|
2326
|
+
async descriptor(t) {
|
|
2327
|
+
const e = await a(this, bt, ee).call(this, t);
|
|
2328
|
+
if (!e) return null;
|
|
2329
|
+
const n = await (await this.client.downloadFile(e.id)).text();
|
|
2330
|
+
if (!n.trim()) return null;
|
|
2331
|
+
let i;
|
|
2332
|
+
try {
|
|
2333
|
+
i = JSON.parse(n);
|
|
2334
|
+
} catch {
|
|
2335
|
+
return null;
|
|
2336
|
+
}
|
|
2337
|
+
return Mr(i);
|
|
2338
|
+
}
|
|
2339
|
+
/**
|
|
2340
|
+
* The first view whose format appears in `formats` — searched in the ORDER
|
|
2341
|
+
* OF THE LIST, so the caller's preference wins (ask `['frag', 'ifc']` and a
|
|
2342
|
+
* document carrying both answers the frag). Null when none matches: that is
|
|
2343
|
+
* where an interface offers "Process".
|
|
2344
|
+
*/
|
|
2345
|
+
async view(t, e) {
|
|
2346
|
+
const s = await this.descriptor(t);
|
|
2347
|
+
if (!s) return null;
|
|
2348
|
+
for (const n of e) {
|
|
2349
|
+
const i = s.views.find((o) => o.format === n);
|
|
2350
|
+
if (i) return i;
|
|
2351
|
+
}
|
|
2352
|
+
return null;
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* Registers a renderable representation — a processor's last act. One view
|
|
2356
|
+
* per format: an existing view of the same format is replaced (a re-run
|
|
2357
|
+
* processor updates, it does not accumulate). The descriptor must exist;
|
|
2358
|
+
* create it first with {@link setDescriptor}.
|
|
2359
|
+
*/
|
|
2360
|
+
async addView(t, e) {
|
|
2361
|
+
const s = await this.descriptor(t);
|
|
2362
|
+
if (!s)
|
|
2363
|
+
throw new Error(
|
|
2364
|
+
"This folder has no document descriptor yet: call setDescriptor first."
|
|
2365
|
+
);
|
|
2366
|
+
s.views = [
|
|
2367
|
+
...s.views.filter((n) => n.format !== e.format),
|
|
2368
|
+
e
|
|
2369
|
+
], await this.setDescriptor(t, s);
|
|
2370
|
+
}
|
|
2371
|
+
/** Writes the descriptor, creating or replacing `document.json`. */
|
|
2372
|
+
async setDescriptor(t, e) {
|
|
2373
|
+
const s = {
|
|
2374
|
+
...e,
|
|
2375
|
+
schema: te,
|
|
2376
|
+
views: e.views ?? []
|
|
2377
|
+
}, n = new Blob([JSON.stringify(s)], {
|
|
2378
|
+
type: "application/json"
|
|
2379
|
+
}), i = await a(this, bt, ee).call(this, t);
|
|
2380
|
+
if (i) {
|
|
2381
|
+
await this.client.updateFile(i.id, {
|
|
2382
|
+
file: n,
|
|
2383
|
+
versionTag: Fe()
|
|
2384
|
+
});
|
|
2385
|
+
return;
|
|
2386
|
+
}
|
|
2387
|
+
await this.client.createFile({
|
|
2388
|
+
file: n,
|
|
2389
|
+
name: Le,
|
|
2390
|
+
versionTag: Fe(),
|
|
2391
|
+
parentFolderId: t,
|
|
2392
|
+
projectId: this.projectId
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
bt = new WeakSet(), ee = async function(t) {
|
|
2397
|
+
const s = (await this.client.listFiles({ folderId: t })).find(
|
|
2398
|
+
(n) => String(n.name ?? "") === Le
|
|
2399
|
+
);
|
|
2400
|
+
return s ? { id: jr(s) } : void 0;
|
|
2401
|
+
};
|
|
2402
|
+
function Mr(r) {
|
|
2403
|
+
if (!r || typeof r != "object") return null;
|
|
2404
|
+
const t = r;
|
|
2405
|
+
if (t.schema !== te || typeof t.name != "string") return null;
|
|
2406
|
+
const e = Array.isArray(t.views) ? t.views.filter(
|
|
2407
|
+
(i) => !!i && typeof i == "object" && typeof i.fileId == "string" && typeof i.format == "string"
|
|
2408
|
+
) : [], s = t.native, n = !!s && typeof s == "object" && typeof s.fileId == "string" && typeof s.format == "string";
|
|
2409
|
+
return {
|
|
2410
|
+
schema: te,
|
|
2411
|
+
name: t.name,
|
|
2412
|
+
...n ? { native: { fileId: s.fileId, format: s.format } } : {},
|
|
2413
|
+
views: e
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
class qe extends Error {
|
|
2313
2417
|
constructor(t, e) {
|
|
2314
2418
|
super(
|
|
2315
2419
|
`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
2420
|
), this.expectedGuid = t, this.actualGuid = e, this.name = "StaleHistoryError";
|
|
2317
2421
|
}
|
|
2318
2422
|
}
|
|
2319
|
-
const
|
|
2320
|
-
function
|
|
2321
|
-
return
|
|
2423
|
+
const De = "bimterop", se = "revitflow_history.json", et = "revitflow_ops.json", Ue = "revitflow/ops@1", cs = "revitflow_model.frag", hs = "revitflow_", Vr = "bimterop-locks-anchor", At = () => `v-${Date.now()}`;
|
|
2424
|
+
function ls(r, t) {
|
|
2425
|
+
return r.filter((e) => String(e.parentId ?? "") === t);
|
|
2322
2426
|
}
|
|
2323
|
-
function
|
|
2324
|
-
return String(
|
|
2427
|
+
function B(r) {
|
|
2428
|
+
return String(r._id ?? r.id ?? "");
|
|
2325
2429
|
}
|
|
2326
|
-
var
|
|
2327
|
-
class
|
|
2430
|
+
var $, _t, re;
|
|
2431
|
+
class Gr {
|
|
2328
2432
|
constructor(t, e) {
|
|
2329
|
-
b(this,
|
|
2330
|
-
b(this,
|
|
2433
|
+
b(this, _t);
|
|
2434
|
+
b(this, $);
|
|
2331
2435
|
this.client = t, this.projectId = e;
|
|
2332
2436
|
}
|
|
2333
2437
|
/** The project's connected documents. */
|
|
2334
2438
|
async docs() {
|
|
2335
|
-
const t = await a(this,
|
|
2439
|
+
const t = await a(this, _t, re).call(this);
|
|
2336
2440
|
if (!t) return [];
|
|
2337
2441
|
const e = await this.client.listFolders({
|
|
2338
2442
|
parentFolderId: t,
|
|
2339
2443
|
projectId: this.projectId
|
|
2340
2444
|
}), s = [];
|
|
2341
|
-
for (const
|
|
2342
|
-
const i = String(
|
|
2445
|
+
for (const n of ls(e, t)) {
|
|
2446
|
+
const i = String(n.name ?? ""), o = i.indexOf("-");
|
|
2343
2447
|
if (o <= 0) continue;
|
|
2344
|
-
const
|
|
2345
|
-
folderId:
|
|
2448
|
+
const d = (await this.client.listFiles({
|
|
2449
|
+
folderId: B(n)
|
|
2346
2450
|
})).map(
|
|
2347
|
-
(
|
|
2348
|
-
), f =
|
|
2349
|
-
(
|
|
2350
|
-
),
|
|
2451
|
+
(g) => String(g.name ?? "")
|
|
2452
|
+
), f = d.find((g) => g === cs) ?? d.find(
|
|
2453
|
+
(g) => g.endsWith(".frag") && !g.startsWith(hs)
|
|
2454
|
+
), h = d.includes(se) || d.includes(et) || !!f;
|
|
2351
2455
|
s.push({
|
|
2352
2456
|
source: i.slice(0, o),
|
|
2353
2457
|
docId: i.slice(o + 1),
|
|
2458
|
+
folderId: B(n),
|
|
2354
2459
|
modelName: f,
|
|
2355
|
-
...
|
|
2460
|
+
...h ? {} : { empty: !0 }
|
|
2356
2461
|
});
|
|
2357
2462
|
}
|
|
2358
2463
|
return s;
|
|
2359
2464
|
}
|
|
2360
2465
|
/** One document's history. `source` and `docId` as {@link docs} lists them. */
|
|
2361
2466
|
doc(t, e) {
|
|
2362
|
-
return new
|
|
2467
|
+
return new Hr(this.client, this, t, e);
|
|
2363
2468
|
}
|
|
2364
2469
|
/** @internal The `bimterop` folder id, resolved once. */
|
|
2365
2470
|
async rootFolderId(t = !1) {
|
|
2366
|
-
if (
|
|
2367
|
-
const e = await a(this,
|
|
2471
|
+
if (u(this, $)) return u(this, $);
|
|
2472
|
+
const e = await a(this, _t, re).call(this);
|
|
2368
2473
|
if (e) return e;
|
|
2369
2474
|
if (!t) return;
|
|
2370
2475
|
const s = await this.client.createFolder(
|
|
2371
|
-
|
|
2476
|
+
De,
|
|
2372
2477
|
void 0,
|
|
2373
2478
|
this.projectId
|
|
2374
2479
|
);
|
|
2375
|
-
return _(this,
|
|
2480
|
+
return _(this, $, B(s)), u(this, $);
|
|
2376
2481
|
}
|
|
2377
2482
|
}
|
|
2378
|
-
|
|
2379
|
-
if (
|
|
2483
|
+
$ = new WeakMap(), _t = new WeakSet(), re = async function() {
|
|
2484
|
+
if (u(this, $)) return u(this, $);
|
|
2380
2485
|
const e = (await this.client.listFolders({
|
|
2381
2486
|
projectId: this.projectId
|
|
2382
2487
|
})).find(
|
|
2383
|
-
(s) => String(s.name ?? "") ===
|
|
2488
|
+
(s) => String(s.name ?? "") === De && !s.parentId
|
|
2384
2489
|
);
|
|
2385
|
-
return e && _(this,
|
|
2490
|
+
return e && _(this, $, B(e)), u(this, $);
|
|
2386
2491
|
};
|
|
2387
|
-
var
|
|
2388
|
-
class
|
|
2389
|
-
constructor(t, e, s,
|
|
2390
|
-
b(this,
|
|
2391
|
-
b(this,
|
|
2392
|
-
this.client = t, this.project = e, this.source = s, this.docId =
|
|
2492
|
+
var U, p, st, rt, D, ne, yt, nt, ie, Rt, mt, $t, oe, us;
|
|
2493
|
+
class Hr {
|
|
2494
|
+
constructor(t, e, s, n) {
|
|
2495
|
+
b(this, p);
|
|
2496
|
+
b(this, U);
|
|
2497
|
+
this.client = t, this.project = e, this.source = s, this.docId = n;
|
|
2393
2498
|
}
|
|
2394
2499
|
// ─── Reading ───────────────────────────────────────────────────────────────
|
|
2395
2500
|
/**
|
|
@@ -2398,8 +2503,8 @@ class zs {
|
|
|
2398
2503
|
* Each version gets its `ordinal` filled in.
|
|
2399
2504
|
*/
|
|
2400
2505
|
async timeline() {
|
|
2401
|
-
const t = await a(this,
|
|
2402
|
-
return
|
|
2506
|
+
const t = await a(this, p, Rt).call(this);
|
|
2507
|
+
return ds((t == null ? void 0 : t.commits) ?? []);
|
|
2403
2508
|
}
|
|
2404
2509
|
/** The head of the timeline, or null before the first sync. */
|
|
2405
2510
|
async latest() {
|
|
@@ -2419,13 +2524,97 @@ class zs {
|
|
|
2419
2524
|
}
|
|
2420
2525
|
/** The visible model .frag as last fully exported. */
|
|
2421
2526
|
async model() {
|
|
2422
|
-
const t = await a(this,
|
|
2527
|
+
const t = await a(this, p, nt).call(this);
|
|
2423
2528
|
if (!t)
|
|
2424
2529
|
throw new Error(
|
|
2425
2530
|
`Document ${this.source}-${this.docId} has no model file yet.`
|
|
2426
2531
|
);
|
|
2427
2532
|
return await (await this.client.downloadFile(t.id)).blob();
|
|
2428
2533
|
}
|
|
2534
|
+
/** The document folder's item id — the id the CDE knows this document by. */
|
|
2535
|
+
async folderId() {
|
|
2536
|
+
return await a(this, p, D).call(this, !1);
|
|
2537
|
+
}
|
|
2538
|
+
// ─── The document descriptor ───────────────────────────────────────────────
|
|
2539
|
+
/**
|
|
2540
|
+
* The document descriptor (`document.json`), or null when the folder does
|
|
2541
|
+
* not carry one yet — an old folder from before descriptors existed.
|
|
2542
|
+
*/
|
|
2543
|
+
async descriptor() {
|
|
2544
|
+
return await u(this, p, st).descriptor(await a(this, p, D).call(this, !1));
|
|
2545
|
+
}
|
|
2546
|
+
/**
|
|
2547
|
+
* The first view whose format appears in `formats`, searched in the order
|
|
2548
|
+
* of the list (the caller's preference wins). Falls back to the visible
|
|
2549
|
+
* model .frag on a descriptor-less folder, so old documents keep viewing.
|
|
2550
|
+
*/
|
|
2551
|
+
async view(t) {
|
|
2552
|
+
const e = await a(this, p, D).call(this, !1), s = await u(this, p, st).descriptor(e);
|
|
2553
|
+
if (s) {
|
|
2554
|
+
for (const i of t) {
|
|
2555
|
+
const o = s.views.find((c) => c.format === i);
|
|
2556
|
+
if (o) return o;
|
|
2557
|
+
}
|
|
2558
|
+
return null;
|
|
2559
|
+
}
|
|
2560
|
+
if (!t.includes("frag")) return null;
|
|
2561
|
+
const n = await a(this, p, nt).call(this);
|
|
2562
|
+
return n ? { fileId: n.id, format: "frag" } : null;
|
|
2563
|
+
}
|
|
2564
|
+
/**
|
|
2565
|
+
* Registers a renderable representation, creating the descriptor when the
|
|
2566
|
+
* folder predates them (named after the model file, or the folder itself).
|
|
2567
|
+
* One view per format: a same-format view is replaced, not accumulated.
|
|
2568
|
+
*/
|
|
2569
|
+
async addView(t) {
|
|
2570
|
+
const e = await a(this, p, D).call(this, !0);
|
|
2571
|
+
if (await u(this, p, st).descriptor(e)) {
|
|
2572
|
+
await u(this, p, st).addView(e, t);
|
|
2573
|
+
return;
|
|
2574
|
+
}
|
|
2575
|
+
const n = await a(this, p, nt).call(this);
|
|
2576
|
+
await u(this, p, st).setDescriptor(e, {
|
|
2577
|
+
name: (n == null ? void 0 : n.name.replace(/\.frag$/, "")) ?? u(this, p, rt),
|
|
2578
|
+
views: [t]
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
// ─── Ownership (element locks) ─────────────────────────────────────────────
|
|
2582
|
+
/**
|
|
2583
|
+
* Who currently holds which elements, read from the lock registry the
|
|
2584
|
+
* native plugins arbitrate through. Read-only: claiming and releasing stay
|
|
2585
|
+
* with the plugins. Empty when nobody holds anything (or the document has
|
|
2586
|
+
* no lock anchor yet). Arbitration is applied: a key contested by two
|
|
2587
|
+
* claims counts only for the earliest one, matching the plugins' rule.
|
|
2588
|
+
*/
|
|
2589
|
+
async ownership() {
|
|
2590
|
+
const t = await a(this, p, yt).call(this, Vr);
|
|
2591
|
+
if (!t) return [];
|
|
2592
|
+
const e = await this.client.getHiddenFilesByParent(t.id), s = await Promise.all(
|
|
2593
|
+
e.map(async (o) => {
|
|
2594
|
+
try {
|
|
2595
|
+
const c = B(o), d = await this.client.downloadHiddenFile(c), f = JSON.parse(await d.text());
|
|
2596
|
+
return !f || typeof f != "object" || !("revitflowlock" in f) || !Array.isArray(f.keys) ? null : {
|
|
2597
|
+
owner: String(f.user ?? ""),
|
|
2598
|
+
keys: f.keys.filter((h) => typeof h == "string")
|
|
2599
|
+
};
|
|
2600
|
+
} catch {
|
|
2601
|
+
return null;
|
|
2602
|
+
}
|
|
2603
|
+
})
|
|
2604
|
+
), n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
|
|
2605
|
+
for (const o of s)
|
|
2606
|
+
if (o)
|
|
2607
|
+
for (const c of o.keys) {
|
|
2608
|
+
if (!c || n.has(c)) continue;
|
|
2609
|
+
n.add(c);
|
|
2610
|
+
const d = i.get(o.owner) ?? [];
|
|
2611
|
+
d.push(c), i.set(o.owner, d);
|
|
2612
|
+
}
|
|
2613
|
+
return [...i.entries()].map(([o, c]) => ({
|
|
2614
|
+
owner: o,
|
|
2615
|
+
elements: c
|
|
2616
|
+
}));
|
|
2617
|
+
}
|
|
2429
2618
|
// ─── Writing versions ─────────────────────────────────────────────────────
|
|
2430
2619
|
/**
|
|
2431
2620
|
* Appends one version: uploads the geometry it carries, then the updated
|
|
@@ -2434,55 +2623,55 @@ class zs {
|
|
|
2434
2623
|
* silent fork.
|
|
2435
2624
|
*/
|
|
2436
2625
|
async sync(t) {
|
|
2437
|
-
var
|
|
2438
|
-
const e = await a(this,
|
|
2439
|
-
let s = await a(this,
|
|
2626
|
+
var c;
|
|
2627
|
+
const e = await a(this, p, D).call(this, !0);
|
|
2628
|
+
let s = await a(this, p, Rt).call(this) ?? {
|
|
2440
2629
|
model: this.docId,
|
|
2441
2630
|
commits: []
|
|
2442
2631
|
};
|
|
2443
|
-
const
|
|
2444
|
-
if (t.expectedLatestGuid !== void 0 && (
|
|
2445
|
-
throw new
|
|
2632
|
+
const n = je(s.commits);
|
|
2633
|
+
if (t.expectedLatestGuid !== void 0 && (n == null ? void 0 : n.guid) !== t.expectedLatestGuid)
|
|
2634
|
+
throw new qe(t.expectedLatestGuid, n == null ? void 0 : n.guid);
|
|
2446
2635
|
const i = {
|
|
2447
|
-
guid:
|
|
2448
|
-
...
|
|
2636
|
+
guid: ae(),
|
|
2637
|
+
...n ? { parents: [n.guid] } : {},
|
|
2449
2638
|
author: t.author,
|
|
2450
2639
|
source: t.source,
|
|
2451
2640
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2452
2641
|
...t.message ? { message: t.message } : {},
|
|
2453
2642
|
...t.userId ? { userId: t.userId } : {},
|
|
2454
|
-
...(
|
|
2643
|
+
...(c = t.appliedOps) != null && c.length ? { appliedOps: t.appliedOps } : {},
|
|
2455
2644
|
changes: t.changes,
|
|
2456
|
-
counts:
|
|
2645
|
+
counts: Jr(t.changes)
|
|
2457
2646
|
};
|
|
2458
|
-
if (t.model && (await a(this,
|
|
2459
|
-
const
|
|
2460
|
-
if (!
|
|
2647
|
+
if (t.model && (await a(this, p, us).call(this, e, t.model), i.full = !0), t.delta) {
|
|
2648
|
+
const d = await a(this, p, nt).call(this);
|
|
2649
|
+
if (!d)
|
|
2461
2650
|
throw new Error(
|
|
2462
2651
|
"A delta needs the model file to hang from: sync a full model first."
|
|
2463
2652
|
);
|
|
2464
2653
|
const f = await this.client.createHiddenFile(
|
|
2465
2654
|
t.delta,
|
|
2466
|
-
|
|
2655
|
+
d.id
|
|
2467
2656
|
);
|
|
2468
2657
|
i.deltaId = String(
|
|
2469
2658
|
f._id ?? f.id
|
|
2470
2659
|
);
|
|
2471
2660
|
}
|
|
2472
|
-
const o = await a(this,
|
|
2661
|
+
const o = await a(this, p, Rt).call(this);
|
|
2473
2662
|
if (o) {
|
|
2474
2663
|
s = o;
|
|
2475
|
-
const
|
|
2476
|
-
if (t.expectedLatestGuid !== void 0 && (
|
|
2477
|
-
throw new
|
|
2478
|
-
|
|
2664
|
+
const d = je(s.commits);
|
|
2665
|
+
if (t.expectedLatestGuid !== void 0 && (d == null ? void 0 : d.guid) !== t.expectedLatestGuid)
|
|
2666
|
+
throw new qe(t.expectedLatestGuid, d == null ? void 0 : d.guid);
|
|
2667
|
+
d && !i.parents && (i.parents = [d.guid]);
|
|
2479
2668
|
}
|
|
2480
|
-
return s.commits.push(i), await a(this,
|
|
2669
|
+
return s.commits.push(i), await a(this, p, $t).call(this, e, se, s), i;
|
|
2481
2670
|
}
|
|
2482
2671
|
// ─── Suggestions (change requests) ────────────────────────────────────────
|
|
2483
2672
|
/** Every suggestion in the document's queue, pending or resolved. */
|
|
2484
2673
|
async suggestions() {
|
|
2485
|
-
const t = await a(this,
|
|
2674
|
+
const t = await a(this, p, mt).call(this);
|
|
2486
2675
|
return (t == null ? void 0 : t.ops) ?? [];
|
|
2487
2676
|
}
|
|
2488
2677
|
/** The suggestions still waiting for the owner, oldest first. */
|
|
@@ -2494,8 +2683,9 @@ class zs {
|
|
|
2494
2683
|
* uploaded as a hidden file under the suggestions index.
|
|
2495
2684
|
*/
|
|
2496
2685
|
async suggest(t) {
|
|
2497
|
-
const e = await a(this,
|
|
2498
|
-
opId: t.opId ??
|
|
2686
|
+
const e = await a(this, p, D).call(this, !0), s = await a(this, p, mt).call(this) ?? { schema: Ue, ops: [] }, n = await a(this, p, yt).call(this, et), i = {
|
|
2687
|
+
opId: t.opId ?? ae(),
|
|
2688
|
+
to: t.to ?? this.source,
|
|
2499
2689
|
title: t.title,
|
|
2500
2690
|
verb: t.verb,
|
|
2501
2691
|
author: t.author,
|
|
@@ -2507,16 +2697,16 @@ class zs {
|
|
|
2507
2697
|
...t.baseCommitGuid ? { baseCommitGuid: t.baseCommitGuid } : {}
|
|
2508
2698
|
};
|
|
2509
2699
|
if (t.payload) {
|
|
2510
|
-
const
|
|
2700
|
+
const c = n ?? await a(this, p, oe).call(this, e, et, s), d = await this.client.createHiddenFile(
|
|
2511
2701
|
t.payload,
|
|
2512
|
-
|
|
2702
|
+
c.id
|
|
2513
2703
|
);
|
|
2514
2704
|
i.fragId = String(
|
|
2515
|
-
|
|
2705
|
+
d._id ?? d.id
|
|
2516
2706
|
);
|
|
2517
2707
|
}
|
|
2518
|
-
const o = await a(this,
|
|
2519
|
-
return o.schema ?? (o.schema =
|
|
2708
|
+
const o = await a(this, p, mt).call(this) ?? s;
|
|
2709
|
+
return o.schema ?? (o.schema = Ue), o.ops.push(i), await a(this, p, $t).call(this, e, et, o), i;
|
|
2520
2710
|
}
|
|
2521
2711
|
/** A suggestion's .frag payload. */
|
|
2522
2712
|
async suggestionPayload(t) {
|
|
@@ -2530,18 +2720,20 @@ class zs {
|
|
|
2530
2720
|
* use it for `discarded`.
|
|
2531
2721
|
*/
|
|
2532
2722
|
async resolveSuggestion(t, e) {
|
|
2533
|
-
const s = await a(this,
|
|
2723
|
+
const s = await a(this, p, D).call(this, !1);
|
|
2534
2724
|
if (!s) throw new Error("This document has no suggestion queue.");
|
|
2535
|
-
const
|
|
2536
|
-
if (!
|
|
2725
|
+
const n = await a(this, p, mt).call(this), i = n == null ? void 0 : n.ops.find((o) => o.opId === t);
|
|
2726
|
+
if (!n || !i)
|
|
2537
2727
|
throw new Error(`No suggestion ${t} in this document's queue.`);
|
|
2538
|
-
return Object.assign(i, e), await a(this,
|
|
2728
|
+
return Object.assign(i, e), await a(this, p, $t).call(this, s, et, n), i;
|
|
2539
2729
|
}
|
|
2540
2730
|
}
|
|
2541
|
-
|
|
2731
|
+
U = new WeakMap(), p = new WeakSet(), st = function() {
|
|
2732
|
+
return new as(this.client, this.project.projectId);
|
|
2733
|
+
}, rt = function() {
|
|
2542
2734
|
return `${this.source}-${this.docId}`;
|
|
2543
|
-
},
|
|
2544
|
-
if (
|
|
2735
|
+
}, D = async function(t) {
|
|
2736
|
+
if (u(this, U)) return u(this, U);
|
|
2545
2737
|
const e = await this.project.rootFolderId(t);
|
|
2546
2738
|
if (!e)
|
|
2547
2739
|
throw new Error(
|
|
@@ -2550,153 +2742,153 @@ L = new WeakMap(), y = new WeakSet(), at = function() {
|
|
|
2550
2742
|
const s = await this.client.listFolders({
|
|
2551
2743
|
parentFolderId: e,
|
|
2552
2744
|
projectId: this.project.projectId
|
|
2553
|
-
}),
|
|
2554
|
-
(o) => String(o.name ?? "") ===
|
|
2745
|
+
}), n = ls(s, e).find(
|
|
2746
|
+
(o) => String(o.name ?? "") === u(this, p, rt)
|
|
2555
2747
|
);
|
|
2556
|
-
if (
|
|
2557
|
-
return _(this,
|
|
2748
|
+
if (n)
|
|
2749
|
+
return _(this, U, B(n)), u(this, U);
|
|
2558
2750
|
if (!t)
|
|
2559
2751
|
throw new Error(
|
|
2560
|
-
`Document ${
|
|
2752
|
+
`Document ${u(this, p, rt)} does not exist in this project.`
|
|
2561
2753
|
);
|
|
2562
2754
|
const i = await this.client.createFolder(
|
|
2563
|
-
|
|
2755
|
+
u(this, p, rt),
|
|
2564
2756
|
e,
|
|
2565
2757
|
this.project.projectId
|
|
2566
2758
|
);
|
|
2567
|
-
return _(this,
|
|
2568
|
-
},
|
|
2569
|
-
const t = await a(this,
|
|
2759
|
+
return _(this, U, B(i)), u(this, U);
|
|
2760
|
+
}, ne = async function() {
|
|
2761
|
+
const t = await a(this, p, D).call(this, !1);
|
|
2570
2762
|
return (await this.client.listFiles({ folderId: t })).map((s) => ({
|
|
2571
|
-
id:
|
|
2763
|
+
id: B(s),
|
|
2572
2764
|
name: String(s.name ?? "")
|
|
2573
2765
|
}));
|
|
2574
|
-
},
|
|
2766
|
+
}, yt = async function(t) {
|
|
2575
2767
|
try {
|
|
2576
|
-
return (await a(this,
|
|
2768
|
+
return (await a(this, p, ne).call(this)).find((e) => e.name === t);
|
|
2577
2769
|
} catch {
|
|
2578
2770
|
return;
|
|
2579
2771
|
}
|
|
2580
|
-
},
|
|
2772
|
+
}, nt = async function() {
|
|
2581
2773
|
try {
|
|
2582
|
-
const t = await a(this,
|
|
2583
|
-
return t.find((e) => e.name ===
|
|
2584
|
-
(e) => e.name.endsWith(".frag") && !e.name.startsWith(
|
|
2774
|
+
const t = await a(this, p, ne).call(this);
|
|
2775
|
+
return t.find((e) => e.name === cs) ?? t.find(
|
|
2776
|
+
(e) => e.name.endsWith(".frag") && !e.name.startsWith(hs)
|
|
2585
2777
|
);
|
|
2586
2778
|
} catch {
|
|
2587
2779
|
return;
|
|
2588
2780
|
}
|
|
2589
|
-
},
|
|
2590
|
-
const e = await a(this,
|
|
2781
|
+
}, ie = async function(t) {
|
|
2782
|
+
const e = await a(this, p, yt).call(this, t);
|
|
2591
2783
|
if (!e) return;
|
|
2592
|
-
const
|
|
2593
|
-
if (
|
|
2594
|
-
return JSON.parse(
|
|
2595
|
-
},
|
|
2596
|
-
return a(this,
|
|
2597
|
-
},
|
|
2598
|
-
return a(this,
|
|
2599
|
-
},
|
|
2600
|
-
const
|
|
2784
|
+
const n = await (await this.client.downloadFile(e.id)).text();
|
|
2785
|
+
if (n.trim())
|
|
2786
|
+
return JSON.parse(n);
|
|
2787
|
+
}, Rt = function() {
|
|
2788
|
+
return a(this, p, ie).call(this, se);
|
|
2789
|
+
}, mt = function() {
|
|
2790
|
+
return a(this, p, ie).call(this, et);
|
|
2791
|
+
}, $t = async function(t, e, s) {
|
|
2792
|
+
const n = new Blob([JSON.stringify(s)], {
|
|
2601
2793
|
type: "application/json"
|
|
2602
|
-
}), i = await a(this,
|
|
2794
|
+
}), i = await a(this, p, yt).call(this, e);
|
|
2603
2795
|
return i ? (await this.client.updateFile(i.id, {
|
|
2604
|
-
file:
|
|
2605
|
-
versionTag:
|
|
2606
|
-
}), i) : await a(this,
|
|
2607
|
-
},
|
|
2608
|
-
const
|
|
2796
|
+
file: n,
|
|
2797
|
+
versionTag: At()
|
|
2798
|
+
}), i) : await a(this, p, oe).call(this, t, e, s);
|
|
2799
|
+
}, oe = async function(t, e, s) {
|
|
2800
|
+
const n = new Blob([JSON.stringify(s)], {
|
|
2609
2801
|
type: "application/json"
|
|
2610
2802
|
}), i = await this.client.createFile({
|
|
2611
|
-
file:
|
|
2803
|
+
file: n,
|
|
2612
2804
|
name: e,
|
|
2613
|
-
versionTag:
|
|
2805
|
+
versionTag: At(),
|
|
2614
2806
|
parentFolderId: t,
|
|
2615
2807
|
projectId: this.project.projectId
|
|
2616
2808
|
}), o = i.item;
|
|
2617
|
-
return { id:
|
|
2618
|
-
},
|
|
2619
|
-
const s = await a(this,
|
|
2809
|
+
return { id: B(o ?? i), name: e };
|
|
2810
|
+
}, us = async function(t, e) {
|
|
2811
|
+
const s = await a(this, p, nt).call(this);
|
|
2620
2812
|
if (s)
|
|
2621
2813
|
return await this.client.updateFile(s.id, {
|
|
2622
2814
|
file: e,
|
|
2623
|
-
versionTag:
|
|
2815
|
+
versionTag: At()
|
|
2624
2816
|
}), s;
|
|
2625
|
-
const
|
|
2817
|
+
const n = `${u(this, p, rt)}.frag`, i = await this.client.createFile({
|
|
2626
2818
|
file: e,
|
|
2627
|
-
name:
|
|
2628
|
-
versionTag:
|
|
2819
|
+
name: n,
|
|
2820
|
+
versionTag: At(),
|
|
2629
2821
|
parentFolderId: t,
|
|
2630
2822
|
projectId: this.project.projectId
|
|
2631
2823
|
}), o = i.item;
|
|
2632
|
-
return { id:
|
|
2824
|
+
return { id: B(o ?? i), name: n };
|
|
2633
2825
|
};
|
|
2634
|
-
function
|
|
2826
|
+
function Jr(r) {
|
|
2635
2827
|
const t = { added: 0, modified: 0, removed: 0 };
|
|
2636
|
-
for (const e of
|
|
2828
|
+
for (const e of r)
|
|
2637
2829
|
e.type === "create" ? t.added++ : e.type === "delete" ? t.removed++ : t.modified++;
|
|
2638
2830
|
return t;
|
|
2639
2831
|
}
|
|
2640
|
-
function
|
|
2641
|
-
var
|
|
2642
|
-
if (
|
|
2643
|
-
return
|
|
2644
|
-
const t = new Map(
|
|
2645
|
-
for (const f of
|
|
2646
|
-
const
|
|
2647
|
-
if (
|
|
2648
|
-
const
|
|
2649
|
-
|
|
2832
|
+
function ds(r) {
|
|
2833
|
+
var d;
|
|
2834
|
+
if (r.length <= 1)
|
|
2835
|
+
return r.forEach((f, h) => f.ordinal = h), [...r];
|
|
2836
|
+
const t = new Map(r.map((f) => [f.guid, f])), e = /* @__PURE__ */ new Map(), s = [];
|
|
2837
|
+
for (const f of r) {
|
|
2838
|
+
const h = (d = f.parents) == null ? void 0 : d[0];
|
|
2839
|
+
if (h && t.has(h)) {
|
|
2840
|
+
const g = e.get(h) ?? [];
|
|
2841
|
+
g.push(f), e.set(h, g);
|
|
2650
2842
|
} else
|
|
2651
2843
|
s.push(f);
|
|
2652
2844
|
}
|
|
2653
|
-
const
|
|
2654
|
-
s.sort(
|
|
2655
|
-
const i = [], o = [...s].reverse(),
|
|
2845
|
+
const n = (f, h) => String(f.timestamp).localeCompare(String(h.timestamp));
|
|
2846
|
+
s.sort(n);
|
|
2847
|
+
const i = [], o = [...s].reverse(), c = /* @__PURE__ */ new Set();
|
|
2656
2848
|
for (; o.length; ) {
|
|
2657
2849
|
const f = o.pop();
|
|
2658
|
-
if (
|
|
2659
|
-
|
|
2660
|
-
const
|
|
2661
|
-
for (let
|
|
2662
|
-
}
|
|
2663
|
-
for (const f of
|
|
2664
|
-
|
|
2665
|
-
return i.forEach((f,
|
|
2850
|
+
if (c.has(f.guid)) continue;
|
|
2851
|
+
c.add(f.guid), i.push(f);
|
|
2852
|
+
const h = (e.get(f.guid) ?? []).sort(n);
|
|
2853
|
+
for (let g = h.length - 1; g >= 0; g--) o.push(h[g]);
|
|
2854
|
+
}
|
|
2855
|
+
for (const f of r)
|
|
2856
|
+
c.has(f.guid) || i.push(f);
|
|
2857
|
+
return i.forEach((f, h) => f.ordinal = h), i;
|
|
2666
2858
|
}
|
|
2667
|
-
function
|
|
2668
|
-
const t =
|
|
2859
|
+
function je(r) {
|
|
2860
|
+
const t = ds(r);
|
|
2669
2861
|
return t[t.length - 1];
|
|
2670
2862
|
}
|
|
2671
|
-
function
|
|
2672
|
-
const
|
|
2673
|
-
return
|
|
2863
|
+
function ae() {
|
|
2864
|
+
const r = globalThis.crypto;
|
|
2865
|
+
return r != null && r.randomUUID ? r.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
|
|
2674
2866
|
const e = Math.random() * 16 | 0;
|
|
2675
2867
|
return (t === "x" ? e : e & 3 | 8).toString(16);
|
|
2676
2868
|
});
|
|
2677
2869
|
}
|
|
2678
|
-
var
|
|
2679
|
-
class
|
|
2870
|
+
var J, Et, ce;
|
|
2871
|
+
class Yr {
|
|
2680
2872
|
constructor(t) {
|
|
2681
|
-
b(this,
|
|
2682
|
-
b(this,
|
|
2873
|
+
b(this, Et);
|
|
2874
|
+
b(this, J, /* @__PURE__ */ new Map());
|
|
2683
2875
|
this.client = t;
|
|
2684
2876
|
}
|
|
2685
2877
|
/** Registers a recipe. One per name; a second with the same name throws. */
|
|
2686
2878
|
register(t) {
|
|
2687
|
-
if (
|
|
2879
|
+
if (u(this, J).has(t.name))
|
|
2688
2880
|
throw new Error(`A recipe named "${t.name}" is already registered.`);
|
|
2689
|
-
|
|
2881
|
+
u(this, J).set(t.name, t);
|
|
2690
2882
|
}
|
|
2691
2883
|
/** The registered recipes, optionally filtered by target application. */
|
|
2692
2884
|
list(t) {
|
|
2693
|
-
return [...
|
|
2885
|
+
return [...u(this, J).values()].filter(
|
|
2694
2886
|
(s) => (!(t != null && t.to) || s.to === t.to) && (!(t != null && t.input) || s.inputs.includes(t.input))
|
|
2695
2887
|
);
|
|
2696
2888
|
}
|
|
2697
2889
|
/** A registered recipe by name, or undefined. */
|
|
2698
2890
|
get(t) {
|
|
2699
|
-
return
|
|
2891
|
+
return u(this, J).get(t);
|
|
2700
2892
|
}
|
|
2701
2893
|
/**
|
|
2702
2894
|
* Runs a recipe WITHOUT queueing anything: the dry pass. Returns a
|
|
@@ -2705,9 +2897,9 @@ class Zs {
|
|
|
2705
2897
|
* included, with no second run. Discard it and the plan never happened.
|
|
2706
2898
|
*/
|
|
2707
2899
|
async plan(t, e) {
|
|
2708
|
-
const { base: s, opId:
|
|
2900
|
+
const { base: s, opId: n, result: i } = await a(this, Et, ce).call(this, t, e);
|
|
2709
2901
|
return {
|
|
2710
|
-
opId:
|
|
2902
|
+
opId: n,
|
|
2711
2903
|
projectId: e.projectId,
|
|
2712
2904
|
target: e.target,
|
|
2713
2905
|
...s != null && s.guid ? { baseCommitGuid: s.guid } : {},
|
|
@@ -2738,7 +2930,7 @@ class Zs {
|
|
|
2738
2930
|
* to show the tallies before queueing.
|
|
2739
2931
|
*/
|
|
2740
2932
|
async run(t, e) {
|
|
2741
|
-
const { targetDoc: s, base:
|
|
2933
|
+
const { targetDoc: s, base: n, opId: i, result: o } = await a(this, Et, ce).call(this, t, e);
|
|
2742
2934
|
return { suggestion: await s.suggest({
|
|
2743
2935
|
opId: i,
|
|
2744
2936
|
title: o.title,
|
|
@@ -2747,31 +2939,31 @@ class Zs {
|
|
|
2747
2939
|
payload: o.payload,
|
|
2748
2940
|
targets: o.targets,
|
|
2749
2941
|
userId: e.userId,
|
|
2750
|
-
baseCommitGuid:
|
|
2942
|
+
baseCommitGuid: n == null ? void 0 : n.guid
|
|
2751
2943
|
}), result: o };
|
|
2752
2944
|
}
|
|
2753
2945
|
}
|
|
2754
|
-
|
|
2755
|
-
const s =
|
|
2946
|
+
J = new WeakMap(), Et = new WeakSet(), ce = async function(t, e) {
|
|
2947
|
+
const s = u(this, J).get(t);
|
|
2756
2948
|
if (!s) throw new Error(`No recipe named "${t}" is registered.`);
|
|
2757
2949
|
if (s.to !== e.target.source)
|
|
2758
2950
|
throw new Error(
|
|
2759
2951
|
`Recipe "${t}" writes ${s.to}, but the target document belongs to ${e.target.source}.`
|
|
2760
2952
|
);
|
|
2761
|
-
const
|
|
2953
|
+
const n = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await n.latest(), o = ae(), c = await s.run({
|
|
2762
2954
|
client: this.client,
|
|
2763
2955
|
projectId: e.projectId,
|
|
2764
|
-
targetDoc:
|
|
2956
|
+
targetDoc: n,
|
|
2765
2957
|
opId: o,
|
|
2766
2958
|
input: e.input,
|
|
2767
2959
|
settings: e.settings ?? {}
|
|
2768
2960
|
});
|
|
2769
|
-
return { recipe: s, targetDoc:
|
|
2961
|
+
return { recipe: s, targetDoc: n, base: i, opId: o, result: c };
|
|
2770
2962
|
};
|
|
2771
|
-
const
|
|
2772
|
-
function
|
|
2963
|
+
const Me = 100;
|
|
2964
|
+
function Wr(r) {
|
|
2773
2965
|
try {
|
|
2774
|
-
const t = JSON.parse(
|
|
2966
|
+
const t = JSON.parse(r);
|
|
2775
2967
|
if (t && typeof t == "object") {
|
|
2776
2968
|
const e = t;
|
|
2777
2969
|
return {
|
|
@@ -2784,31 +2976,31 @@ function tn(n) {
|
|
|
2784
2976
|
}
|
|
2785
2977
|
return {};
|
|
2786
2978
|
}
|
|
2787
|
-
function
|
|
2788
|
-
if (!
|
|
2789
|
-
const t =
|
|
2979
|
+
function Kr(r) {
|
|
2980
|
+
if (!r || typeof r != "object") return;
|
|
2981
|
+
const t = r.retryAfter;
|
|
2790
2982
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
|
|
2791
2983
|
}
|
|
2792
|
-
class
|
|
2793
|
-
constructor(e, s,
|
|
2794
|
-
const o =
|
|
2984
|
+
class Te extends Error {
|
|
2985
|
+
constructor(e, s, n, i) {
|
|
2986
|
+
const o = Wr(n);
|
|
2795
2987
|
super(o.message ?? `${s || "Request failed"} (${e})`);
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2988
|
+
I(this, "status");
|
|
2989
|
+
I(this, "code");
|
|
2990
|
+
I(this, "details");
|
|
2991
|
+
I(this, "body");
|
|
2800
2992
|
/**
|
|
2801
2993
|
* Seconds to wait before retrying, taken from the `Retry-After` header or
|
|
2802
2994
|
* from `details.retryAfter`. Only present on rate-limited (429) responses.
|
|
2803
2995
|
*/
|
|
2804
|
-
|
|
2805
|
-
this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body =
|
|
2996
|
+
I(this, "retryAfter");
|
|
2997
|
+
this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = n, this.retryAfter = i ?? Kr(o.details);
|
|
2806
2998
|
}
|
|
2807
2999
|
}
|
|
2808
|
-
const
|
|
2809
|
-
function
|
|
2810
|
-
var
|
|
2811
|
-
const t = (i = (
|
|
3000
|
+
const P = "item/folder", m = "item", G = "processor", zr = "npm-registry", q = "hidden", Ht = "FILE", Jt = "TOOL", Yt = "APP", Xr = 500, Ve = 3e4, Qr = 0.25, Zr = (r) => new Promise((t) => setTimeout(t, r));
|
|
3001
|
+
function tn(r) {
|
|
3002
|
+
var n, i;
|
|
3003
|
+
const t = (i = (n = r.headers) == null ? void 0 : n.get) == null ? void 0 : i.call(n, "Retry-After");
|
|
2812
3004
|
if (!t) return;
|
|
2813
3005
|
const e = Number(t);
|
|
2814
3006
|
if (Number.isFinite(e)) return Math.max(0, e);
|
|
@@ -2816,18 +3008,18 @@ function an(n) {
|
|
|
2816
3008
|
if (!Number.isNaN(s))
|
|
2817
3009
|
return Math.max(0, (s - Date.now()) / 1e3);
|
|
2818
3010
|
}
|
|
2819
|
-
function
|
|
2820
|
-
return
|
|
3011
|
+
function en(r) {
|
|
3012
|
+
return r instanceof Te ? r.status === 429 || r.status >= 500 : !0;
|
|
2821
3013
|
}
|
|
2822
|
-
function
|
|
3014
|
+
function sn(r, t) {
|
|
2823
3015
|
const e = Math.min(
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
), s = e *
|
|
2827
|
-
return
|
|
3016
|
+
Xr * 2 ** t,
|
|
3017
|
+
Ve
|
|
3018
|
+
), s = e * Qr * Math.random(), n = r instanceof Te && r.retryAfter != null ? r.retryAfter * 1e3 : void 0;
|
|
3019
|
+
return n != null ? Math.min(n, Ve) + s : e + s;
|
|
2828
3020
|
}
|
|
2829
|
-
var
|
|
2830
|
-
const
|
|
3021
|
+
var l, le, y, H, vt, gt, Nt, Pt, ue, de, fs;
|
|
3022
|
+
const Se = class Se {
|
|
2831
3023
|
/**
|
|
2832
3024
|
* Creates a new EngineServicesClient instance.
|
|
2833
3025
|
* @param accessToken - API access token (obtained from the platform dashboard)
|
|
@@ -2836,31 +3028,31 @@ const ye = class ye {
|
|
|
2836
3028
|
* @param props - Optional configuration (retry count, auth mode, etc.).
|
|
2837
3029
|
*/
|
|
2838
3030
|
constructor(t, e, s) {
|
|
2839
|
-
b(this,
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
3031
|
+
b(this, l);
|
|
3032
|
+
I(this, "apiUrl");
|
|
3033
|
+
I(this, "accessToken");
|
|
3034
|
+
I(this, "wsUrl");
|
|
3035
|
+
I(this, "retries");
|
|
3036
|
+
I(this, "useBearer");
|
|
3037
|
+
I(this, "builtInGlobals", null);
|
|
2846
3038
|
/**
|
|
2847
3039
|
* URL of a local execution server (e.g. `http://localhost:4001`).
|
|
2848
3040
|
* When set, execution methods are routed to this server instead of the cloud API.
|
|
2849
3041
|
* Set to `null` to disable local routing and use the cloud API.
|
|
2850
3042
|
*/
|
|
2851
|
-
|
|
3043
|
+
I(this, "localServerUrl", null);
|
|
2852
3044
|
/**
|
|
2853
3045
|
* The platform context this client was created with.
|
|
2854
3046
|
* Contains `appId`, `projectId`, `accessToken`, and `apiUrl`.
|
|
2855
3047
|
* Populated automatically when using {@link fromPlatformContext}.
|
|
2856
3048
|
*/
|
|
2857
|
-
|
|
2858
|
-
b(this,
|
|
2859
|
-
const { retries:
|
|
2860
|
-
let
|
|
2861
|
-
if (
|
|
2862
|
-
let
|
|
2863
|
-
|
|
3049
|
+
I(this, "context");
|
|
3050
|
+
b(this, vt);
|
|
3051
|
+
const { retries: n = 0, useBearer: i = !1, localServerUrl: o } = s || {};
|
|
3052
|
+
let c = e;
|
|
3053
|
+
if (c.charAt(c.length - 1) === "/" && (c = c.slice(0, -1)), this.apiUrl = `${c}/api`, this.accessToken = t, this.wsUrl = c, this.retries = n, this.useBearer = i, this.context = { appId: "", projectId: "", accessToken: t, apiUrl: e }, o) {
|
|
3054
|
+
let d = o;
|
|
3055
|
+
d.charAt(d.length - 1) === "/" && (d = d.slice(0, -1)), this.localServerUrl = d;
|
|
2864
3056
|
}
|
|
2865
3057
|
}
|
|
2866
3058
|
/**
|
|
@@ -2880,7 +3072,7 @@ const ye = class ye {
|
|
|
2880
3072
|
* ```
|
|
2881
3073
|
*/
|
|
2882
3074
|
static fromPlatformContext(t) {
|
|
2883
|
-
const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new
|
|
3075
|
+
const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new Se(e.accessToken, e.apiUrl, {
|
|
2884
3076
|
...t,
|
|
2885
3077
|
useBearer: !0
|
|
2886
3078
|
});
|
|
@@ -2956,7 +3148,7 @@ const ye = class ye {
|
|
|
2956
3148
|
* cleaning logic is applied identically.
|
|
2957
3149
|
*/
|
|
2958
3150
|
async request(t, e, s) {
|
|
2959
|
-
return a(this,
|
|
3151
|
+
return a(this, l, y).call(this, t, e, s);
|
|
2960
3152
|
}
|
|
2961
3153
|
// ─── Files ───────────────────────────────────────────────────────
|
|
2962
3154
|
/**
|
|
@@ -2965,12 +3157,12 @@ const ye = class ye {
|
|
|
2965
3157
|
* @returns Array of file items.
|
|
2966
3158
|
*/
|
|
2967
3159
|
async listFiles(t) {
|
|
2968
|
-
const { folderId: e, archived: s, projectId:
|
|
2969
|
-
return e ? await a(this,
|
|
3160
|
+
const { folderId: e, archived: s, projectId: n } = t || {};
|
|
3161
|
+
return e ? await a(this, l, y).call(this, "GET", `${P}/${e}/items`, { query: { itemType: Ht, archived: s } }) : await a(this, l, y).call(this, "GET", `${m}`, {
|
|
2970
3162
|
query: {
|
|
2971
|
-
itemType:
|
|
3163
|
+
itemType: Ht,
|
|
2972
3164
|
archived: s,
|
|
2973
|
-
...
|
|
3165
|
+
...n && { projectId: n }
|
|
2974
3166
|
}
|
|
2975
3167
|
});
|
|
2976
3168
|
}
|
|
@@ -2981,7 +3173,7 @@ const ye = class ye {
|
|
|
2981
3173
|
* @returns The file item, optionally with version history.
|
|
2982
3174
|
*/
|
|
2983
3175
|
async getFile(t, e) {
|
|
2984
|
-
return await a(this,
|
|
3176
|
+
return await a(this, l, de).call(this, t, e);
|
|
2985
3177
|
}
|
|
2986
3178
|
/**
|
|
2987
3179
|
* Uploads a new file.
|
|
@@ -2989,7 +3181,7 @@ const ye = class ye {
|
|
|
2989
3181
|
* @returns The created item and its first version.
|
|
2990
3182
|
*/
|
|
2991
3183
|
async createFile(t) {
|
|
2992
|
-
return await a(this,
|
|
3184
|
+
return await a(this, l, Pt).call(this, t, Ht);
|
|
2993
3185
|
}
|
|
2994
3186
|
/**
|
|
2995
3187
|
* Updates an existing file. Can rename, move to a different folder,
|
|
@@ -2999,21 +3191,21 @@ const ye = class ye {
|
|
|
2999
3191
|
* @returns The updated item and/or the new version.
|
|
3000
3192
|
*/
|
|
3001
3193
|
async updateFile(t, e) {
|
|
3002
|
-
return await a(this,
|
|
3194
|
+
return await a(this, l, ue).call(this, t, e);
|
|
3003
3195
|
}
|
|
3004
3196
|
/**
|
|
3005
3197
|
* Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
|
|
3006
3198
|
* @param fileId - The file's unique identifier.
|
|
3007
3199
|
*/
|
|
3008
3200
|
async archiveFile(t) {
|
|
3009
|
-
return await a(this,
|
|
3201
|
+
return await a(this, l, y).call(this, "DELETE", `${m}/${t}`);
|
|
3010
3202
|
}
|
|
3011
3203
|
/**
|
|
3012
3204
|
* Recovers a previously archived file.
|
|
3013
3205
|
* @param fileId - The file's unique identifier.
|
|
3014
3206
|
*/
|
|
3015
3207
|
async recoverFile(t) {
|
|
3016
|
-
return await a(this,
|
|
3208
|
+
return await a(this, l, y).call(this, "PUT", `${m}/${t}/recover`);
|
|
3017
3209
|
}
|
|
3018
3210
|
/**
|
|
3019
3211
|
* Downloads a file's content. Returns the raw fetch Response.
|
|
@@ -3022,7 +3214,7 @@ const ye = class ye {
|
|
|
3022
3214
|
* @returns A fetch Response containing the file data.
|
|
3023
3215
|
*/
|
|
3024
3216
|
async downloadFile(t, e) {
|
|
3025
|
-
return await a(this,
|
|
3217
|
+
return await a(this, l, Nt).call(this, t, e);
|
|
3026
3218
|
}
|
|
3027
3219
|
/**
|
|
3028
3220
|
* Retrieves the free-JSON metadata for a specific file version.
|
|
@@ -3032,10 +3224,10 @@ const ye = class ye {
|
|
|
3032
3224
|
* @param params - Optional flags such as `withDraft`.
|
|
3033
3225
|
*/
|
|
3034
3226
|
async getFileVersionMetadata(t, e, s) {
|
|
3035
|
-
const { withDraft:
|
|
3036
|
-
return await a(this,
|
|
3227
|
+
const { withDraft: n } = s || {};
|
|
3228
|
+
return await a(this, l, y).call(this, "GET", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
|
|
3037
3229
|
query: {
|
|
3038
|
-
...
|
|
3230
|
+
...n && { withDraft: "true" }
|
|
3039
3231
|
}
|
|
3040
3232
|
});
|
|
3041
3233
|
}
|
|
@@ -3046,7 +3238,7 @@ const ye = class ye {
|
|
|
3046
3238
|
* @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
|
|
3047
3239
|
*/
|
|
3048
3240
|
async updateFileVersionMetadata(t, e, s) {
|
|
3049
|
-
return await a(this,
|
|
3241
|
+
return await a(this, l, y).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
|
|
3050
3242
|
body: JSON.stringify({ metadata: s }),
|
|
3051
3243
|
contentType: "application/json"
|
|
3052
3244
|
});
|
|
@@ -3057,7 +3249,7 @@ const ye = class ye {
|
|
|
3057
3249
|
* @param versionTag - The version tag.
|
|
3058
3250
|
*/
|
|
3059
3251
|
async deleteFileVersionMetadata(t, e) {
|
|
3060
|
-
return await a(this,
|
|
3252
|
+
return await a(this, l, y).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`);
|
|
3061
3253
|
}
|
|
3062
3254
|
/**
|
|
3063
3255
|
* Batch variant of {@link getFileVersionMetadata}. Reads the metadata of
|
|
@@ -3074,9 +3266,9 @@ const ye = class ye {
|
|
|
3074
3266
|
*/
|
|
3075
3267
|
async getFileVersionMetadataBatch(t, e) {
|
|
3076
3268
|
const { withDraft: s } = e || {};
|
|
3077
|
-
return await a(this,
|
|
3269
|
+
return await a(this, l, gt).call(this, t, async (n) => (await a(this, l, y).call(this, "POST", `${m}/batch/version-metadata`, {
|
|
3078
3270
|
body: JSON.stringify({
|
|
3079
|
-
entries:
|
|
3271
|
+
entries: n,
|
|
3080
3272
|
...s !== void 0 && { withDraft: s }
|
|
3081
3273
|
}),
|
|
3082
3274
|
contentType: "application/json"
|
|
@@ -3089,12 +3281,12 @@ const ye = class ye {
|
|
|
3089
3281
|
* @returns Array of folder items.
|
|
3090
3282
|
*/
|
|
3091
3283
|
async listFolders(t) {
|
|
3092
|
-
const { archived: e, parentFolderId: s, projectId:
|
|
3093
|
-
return await a(this,
|
|
3284
|
+
const { archived: e, parentFolderId: s, projectId: n } = t || {};
|
|
3285
|
+
return await a(this, l, y).call(this, "GET", P, {
|
|
3094
3286
|
query: {
|
|
3095
3287
|
parentFolderId: s,
|
|
3096
3288
|
archived: e,
|
|
3097
|
-
...
|
|
3289
|
+
...n && { projectId: n }
|
|
3098
3290
|
}
|
|
3099
3291
|
});
|
|
3100
3292
|
}
|
|
@@ -3103,7 +3295,7 @@ const ye = class ye {
|
|
|
3103
3295
|
* @param folderId - The folder's unique identifier.
|
|
3104
3296
|
*/
|
|
3105
3297
|
async getFolder(t) {
|
|
3106
|
-
return await a(this,
|
|
3298
|
+
return await a(this, l, y).call(this, "GET", `${P}/${t}`);
|
|
3107
3299
|
}
|
|
3108
3300
|
/**
|
|
3109
3301
|
* Batch variant of {@link getFolder}. Resolves a known set of folder ids in
|
|
@@ -3119,7 +3311,7 @@ const ye = class ye {
|
|
|
3119
3311
|
* @param folderIds - The folder ids to resolve.
|
|
3120
3312
|
*/
|
|
3121
3313
|
async getFoldersBatch(t) {
|
|
3122
|
-
return await a(this,
|
|
3314
|
+
return await a(this, l, gt).call(this, t, async (e) => (await a(this, l, y).call(this, "POST", `${m}/batch/folders`, {
|
|
3123
3315
|
body: JSON.stringify({ folderIds: e }),
|
|
3124
3316
|
contentType: "application/json"
|
|
3125
3317
|
})).results);
|
|
@@ -3131,7 +3323,7 @@ const ye = class ye {
|
|
|
3131
3323
|
* @returns The created folder.
|
|
3132
3324
|
*/
|
|
3133
3325
|
async createFolder(t, e, s) {
|
|
3134
|
-
return await a(this,
|
|
3326
|
+
return await a(this, l, y).call(this, "POST", P, {
|
|
3135
3327
|
body: JSON.stringify({
|
|
3136
3328
|
name: t,
|
|
3137
3329
|
...e && { parentId: e },
|
|
@@ -3148,7 +3340,7 @@ const ye = class ye {
|
|
|
3148
3340
|
*/
|
|
3149
3341
|
async updateFolder(t, e) {
|
|
3150
3342
|
const { name: s } = e;
|
|
3151
|
-
return await a(this,
|
|
3343
|
+
return await a(this, l, y).call(this, "PUT", `${P}/${t}`, {
|
|
3152
3344
|
body: JSON.stringify({ name: s }),
|
|
3153
3345
|
contentType: "application/json"
|
|
3154
3346
|
});
|
|
@@ -3158,14 +3350,14 @@ const ye = class ye {
|
|
|
3158
3350
|
* @param folderId - The folder's unique identifier.
|
|
3159
3351
|
*/
|
|
3160
3352
|
async archiveFolder(t) {
|
|
3161
|
-
return await a(this,
|
|
3353
|
+
return await a(this, l, y).call(this, "DELETE", `${P}/${t}`);
|
|
3162
3354
|
}
|
|
3163
3355
|
/**
|
|
3164
3356
|
* Recovers a previously archived folder.
|
|
3165
3357
|
* @param folderId - The folder's unique identifier.
|
|
3166
3358
|
*/
|
|
3167
3359
|
async recoverFolder(t) {
|
|
3168
|
-
return await a(this,
|
|
3360
|
+
return await a(this, l, y).call(this, "PUT", `${P}/${t}/recover`);
|
|
3169
3361
|
}
|
|
3170
3362
|
/**
|
|
3171
3363
|
* Downloads an entire folder as a ZIP archive.
|
|
@@ -3173,7 +3365,7 @@ const ye = class ye {
|
|
|
3173
3365
|
* @returns A fetch Response containing the ZIP data.
|
|
3174
3366
|
*/
|
|
3175
3367
|
async downloadFolder(t) {
|
|
3176
|
-
return await a(this,
|
|
3368
|
+
return await a(this, l, H).call(this, `${P}/${t}/download`);
|
|
3177
3369
|
}
|
|
3178
3370
|
// ─── Components ──────────────────────────────────────────────────
|
|
3179
3371
|
/**
|
|
@@ -3182,17 +3374,17 @@ const ye = class ye {
|
|
|
3182
3374
|
* @returns Array of component items.
|
|
3183
3375
|
*/
|
|
3184
3376
|
async listComponents(t) {
|
|
3185
|
-
const { folderId: e, ShowVersions: s, projectId:
|
|
3186
|
-
return e ? await a(this,
|
|
3377
|
+
const { folderId: e, ShowVersions: s, projectId: n } = t || {};
|
|
3378
|
+
return e ? await a(this, l, y).call(this, "GET", `${P}/${e}/items`, {
|
|
3187
3379
|
query: {
|
|
3188
|
-
itemType:
|
|
3380
|
+
itemType: Jt,
|
|
3189
3381
|
...s && { ShowVersions: s }
|
|
3190
3382
|
}
|
|
3191
|
-
}) : await a(this,
|
|
3383
|
+
}) : await a(this, l, y).call(this, "GET", `${m}`, {
|
|
3192
3384
|
query: {
|
|
3193
|
-
itemType:
|
|
3385
|
+
itemType: Jt,
|
|
3194
3386
|
...s && { ShowVersions: s },
|
|
3195
|
-
...
|
|
3387
|
+
...n && { projectId: n }
|
|
3196
3388
|
}
|
|
3197
3389
|
});
|
|
3198
3390
|
}
|
|
@@ -3202,7 +3394,7 @@ const ye = class ye {
|
|
|
3202
3394
|
* @param props - Options such as whether to include versions.
|
|
3203
3395
|
*/
|
|
3204
3396
|
async getComponent(t, e) {
|
|
3205
|
-
return await a(this,
|
|
3397
|
+
return await a(this, l, de).call(this, t, e);
|
|
3206
3398
|
}
|
|
3207
3399
|
/**
|
|
3208
3400
|
* Creates a new component with the given file and version properties.
|
|
@@ -3211,7 +3403,7 @@ const ye = class ye {
|
|
|
3211
3403
|
*/
|
|
3212
3404
|
async createComponent(t) {
|
|
3213
3405
|
const { componentProps: e } = t;
|
|
3214
|
-
return await a(this,
|
|
3406
|
+
return await a(this, l, Pt).call(this, t, Jt, e);
|
|
3215
3407
|
}
|
|
3216
3408
|
/**
|
|
3217
3409
|
* Updates an existing component. Can rename, move, and/or upload a new version.
|
|
@@ -3221,7 +3413,7 @@ const ye = class ye {
|
|
|
3221
3413
|
*/
|
|
3222
3414
|
async updateComponent(t, e) {
|
|
3223
3415
|
const { componentProps: s } = e;
|
|
3224
|
-
return await a(this,
|
|
3416
|
+
return await a(this, l, ue).call(this, t, e, s);
|
|
3225
3417
|
}
|
|
3226
3418
|
/**
|
|
3227
3419
|
* Downloads a component's full ZIP file. Returns the raw fetch Response.
|
|
@@ -3230,7 +3422,7 @@ const ye = class ye {
|
|
|
3230
3422
|
* @returns A fetch Response containing the ZIP data.
|
|
3231
3423
|
*/
|
|
3232
3424
|
async downloadComponent(t, e) {
|
|
3233
|
-
return await a(this,
|
|
3425
|
+
return await a(this, l, Nt).call(this, t, e);
|
|
3234
3426
|
}
|
|
3235
3427
|
/**
|
|
3236
3428
|
* Downloads only the JavaScript bundle from a component's ZIP.
|
|
@@ -3240,11 +3432,11 @@ const ye = class ye {
|
|
|
3240
3432
|
* @returns A fetch Response containing the bundle JavaScript text.
|
|
3241
3433
|
*/
|
|
3242
3434
|
async downloadComponentBundle(t, e) {
|
|
3243
|
-
const { versionTag: s, withDraft:
|
|
3244
|
-
return await a(this,
|
|
3435
|
+
const { versionTag: s, withDraft: n } = e || {};
|
|
3436
|
+
return await a(this, l, H).call(this, `${m}/${t}/download/bundle`, {
|
|
3245
3437
|
query: {
|
|
3246
3438
|
...s && { versionTag: s },
|
|
3247
|
-
...
|
|
3439
|
+
...n && { withDraft: n }
|
|
3248
3440
|
}
|
|
3249
3441
|
});
|
|
3250
3442
|
}
|
|
@@ -3253,14 +3445,14 @@ const ye = class ye {
|
|
|
3253
3445
|
* @param componentId - The component's unique identifier.
|
|
3254
3446
|
*/
|
|
3255
3447
|
async archiveComponent(t) {
|
|
3256
|
-
return await a(this,
|
|
3448
|
+
return await a(this, l, y).call(this, "DELETE", `${m}/${t}`);
|
|
3257
3449
|
}
|
|
3258
3450
|
/**
|
|
3259
3451
|
* Recovers a previously archived component.
|
|
3260
3452
|
* @param componentId - The component's unique identifier.
|
|
3261
3453
|
*/
|
|
3262
3454
|
async recoverComponent(t) {
|
|
3263
|
-
return await a(this,
|
|
3455
|
+
return await a(this, l, y).call(this, "PUT", `${m}/${t}/recover`);
|
|
3264
3456
|
}
|
|
3265
3457
|
// ─── Built-in Components ─────────────────────────────────────────
|
|
3266
3458
|
/**
|
|
@@ -3269,7 +3461,7 @@ const ye = class ye {
|
|
|
3269
3461
|
* @returns The component's JavaScript source code as a string.
|
|
3270
3462
|
*/
|
|
3271
3463
|
async getBuiltInComponent(t) {
|
|
3272
|
-
return await (await a(this,
|
|
3464
|
+
return await (await a(this, l, H).call(this, `built-in/${t}/bundle`)).text();
|
|
3273
3465
|
}
|
|
3274
3466
|
/**
|
|
3275
3467
|
* Fetches a built-in component bundle, evaluates it, and registers it
|
|
@@ -3298,9 +3490,9 @@ const ye = class ye {
|
|
|
3298
3490
|
* ```
|
|
3299
3491
|
*/
|
|
3300
3492
|
async initBuiltInComponent(t, e, s) {
|
|
3301
|
-
const
|
|
3302
|
-
return main;`)(...
|
|
3303
|
-
e.get(
|
|
3493
|
+
const n = await this.getBuiltInComponent(t.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), c = o.map((g) => i[g]), f = new Function(...o, `${n}
|
|
3494
|
+
return main;`)(...c), h = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
3495
|
+
e.get(h);
|
|
3304
3496
|
}
|
|
3305
3497
|
/**
|
|
3306
3498
|
* Loads multiple built-in components in parallel.
|
|
@@ -3342,13 +3534,13 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3342
3534
|
* ```
|
|
3343
3535
|
*/
|
|
3344
3536
|
async setup(t, ...e) {
|
|
3345
|
-
var o,
|
|
3346
|
-
const s = t.OBC,
|
|
3537
|
+
var o, c;
|
|
3538
|
+
const s = t.OBC, n = t.BUI;
|
|
3347
3539
|
if (!(s != null && s.Components))
|
|
3348
3540
|
throw new Error("globals.OBC must include Components");
|
|
3349
|
-
if (!(
|
|
3541
|
+
if (!(n != null && n.Manager)) throw new Error("globals.BUI must include Manager");
|
|
3350
3542
|
const i = new s.Components();
|
|
3351
|
-
return
|
|
3543
|
+
return n.Manager.init(), this.setBuiltInGlobals(t), await this.initBuiltInComponents(i, ...e), i.init(), (c = (o = this.context.appEventOrchestrator) == null ? void 0 : o.appLoaded) == null || c.call(o), { components: i };
|
|
3352
3544
|
}
|
|
3353
3545
|
/**
|
|
3354
3546
|
* Reports an error to the platform via the {@link AppEventOrchestrator.appError} callback.
|
|
@@ -3356,8 +3548,8 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3356
3548
|
* @param data - Arbitrary error data to send to the platform.
|
|
3357
3549
|
*/
|
|
3358
3550
|
throwError(t, e) {
|
|
3359
|
-
var s,
|
|
3360
|
-
(
|
|
3551
|
+
var s, n;
|
|
3552
|
+
(n = (s = this.context.appEventOrchestrator) == null ? void 0 : s.appError) == null || n.call(s, t, e);
|
|
3361
3553
|
}
|
|
3362
3554
|
// ─── Apps ────────────────────────────────────────────────────────
|
|
3363
3555
|
/**
|
|
@@ -3366,17 +3558,17 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3366
3558
|
* @returns Array of app items.
|
|
3367
3559
|
*/
|
|
3368
3560
|
async listApps(t) {
|
|
3369
|
-
const { folderId: e, ShowVersions: s, projectId:
|
|
3370
|
-
return e ? await a(this,
|
|
3561
|
+
const { folderId: e, ShowVersions: s, projectId: n } = t || {};
|
|
3562
|
+
return e ? await a(this, l, y).call(this, "GET", `${P}/${e}/items`, {
|
|
3371
3563
|
query: {
|
|
3372
|
-
itemType:
|
|
3564
|
+
itemType: Yt,
|
|
3373
3565
|
...s && { ShowVersions: s }
|
|
3374
3566
|
}
|
|
3375
|
-
}) : await a(this,
|
|
3567
|
+
}) : await a(this, l, y).call(this, "GET", `${m}`, {
|
|
3376
3568
|
query: {
|
|
3377
|
-
itemType:
|
|
3569
|
+
itemType: Yt,
|
|
3378
3570
|
...s && { ShowVersions: s },
|
|
3379
|
-
...
|
|
3571
|
+
...n && { projectId: n }
|
|
3380
3572
|
}
|
|
3381
3573
|
});
|
|
3382
3574
|
}
|
|
@@ -3387,7 +3579,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3387
3579
|
*/
|
|
3388
3580
|
async createApp(t) {
|
|
3389
3581
|
const { appProps: e } = t;
|
|
3390
|
-
return await a(this,
|
|
3582
|
+
return await a(this, l, Pt).call(this, t, Yt, e);
|
|
3391
3583
|
}
|
|
3392
3584
|
/**
|
|
3393
3585
|
* Downloads an app's full ZIP file. Returns the raw fetch Response.
|
|
@@ -3396,7 +3588,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3396
3588
|
* @returns A fetch Response containing the ZIP data.
|
|
3397
3589
|
*/
|
|
3398
3590
|
async downloadApp(t, e) {
|
|
3399
|
-
return await a(this,
|
|
3591
|
+
return await a(this, l, Nt).call(this, t, e);
|
|
3400
3592
|
}
|
|
3401
3593
|
/**
|
|
3402
3594
|
* Downloads only the JavaScript bundle from an app's ZIP.
|
|
@@ -3406,11 +3598,11 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3406
3598
|
* @returns A fetch Response containing the bundle JavaScript text.
|
|
3407
3599
|
*/
|
|
3408
3600
|
async downloadAppBundle(t, e) {
|
|
3409
|
-
const { versionTag: s, withDraft:
|
|
3410
|
-
return await a(this,
|
|
3601
|
+
const { versionTag: s, withDraft: n } = e || {};
|
|
3602
|
+
return await a(this, l, H).call(this, `${m}/${t}/download/bundle`, {
|
|
3411
3603
|
query: {
|
|
3412
3604
|
...s && { versionTag: s },
|
|
3413
|
-
...
|
|
3605
|
+
...n && { withDraft: n }
|
|
3414
3606
|
}
|
|
3415
3607
|
});
|
|
3416
3608
|
}
|
|
@@ -3419,7 +3611,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3419
3611
|
* @param appId - The app's unique identifier.
|
|
3420
3612
|
*/
|
|
3421
3613
|
async archiveApp(t) {
|
|
3422
|
-
return await a(this,
|
|
3614
|
+
return await a(this, l, y).call(this, "DELETE", `${m}/${t}`);
|
|
3423
3615
|
}
|
|
3424
3616
|
// ─── NPM Registry ────────────────────────────────────────────────
|
|
3425
3617
|
/**
|
|
@@ -3431,7 +3623,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3431
3623
|
* @returns The registry, scope, read-only token, and assembled `.npmrc`.
|
|
3432
3624
|
*/
|
|
3433
3625
|
async getNpmCredentials() {
|
|
3434
|
-
return await a(this,
|
|
3626
|
+
return await a(this, l, y).call(this, "GET", `${zr}/credentials`);
|
|
3435
3627
|
}
|
|
3436
3628
|
// ─── Execution ───────────────────────────────────────────────────
|
|
3437
3629
|
/**
|
|
@@ -3450,7 +3642,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3450
3642
|
*/
|
|
3451
3643
|
async executeComponent(t, e, s) {
|
|
3452
3644
|
if (this.localServerUrl) {
|
|
3453
|
-
const
|
|
3645
|
+
const n = `${this.localServerUrl}/api/${G}/${t}/execute`, i = await fetch(n, {
|
|
3454
3646
|
method: "POST",
|
|
3455
3647
|
headers: { "Content-Type": "application/json" },
|
|
3456
3648
|
body: JSON.stringify(e)
|
|
@@ -3463,7 +3655,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3463
3655
|
}
|
|
3464
3656
|
return await i.json();
|
|
3465
3657
|
}
|
|
3466
|
-
return await a(this,
|
|
3658
|
+
return await a(this, l, y).call(this, "POST", `${G}/${t}/execute`, {
|
|
3467
3659
|
body: JSON.stringify(e),
|
|
3468
3660
|
query: { ...s && { versionTag: s } },
|
|
3469
3661
|
contentType: "application/json"
|
|
@@ -3475,16 +3667,16 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3475
3667
|
*/
|
|
3476
3668
|
async abortExecution(t) {
|
|
3477
3669
|
if (this.localServerUrl) {
|
|
3478
|
-
const e = `${this.localServerUrl}/api/${
|
|
3670
|
+
const e = `${this.localServerUrl}/api/${G}/progress/${t}/abort`, s = await fetch(e, { method: "POST" });
|
|
3479
3671
|
if (!s.ok) {
|
|
3480
|
-
const
|
|
3672
|
+
const n = await s.text().catch(() => "");
|
|
3481
3673
|
throw new Error(
|
|
3482
|
-
`Local server request failed: ${s.status} - ${
|
|
3674
|
+
`Local server request failed: ${s.status} - ${n}`
|
|
3483
3675
|
);
|
|
3484
3676
|
}
|
|
3485
3677
|
return await s.json();
|
|
3486
3678
|
}
|
|
3487
|
-
return await a(this,
|
|
3679
|
+
return await a(this, l, y).call(this, "POST", `${G}/progress/${t}/abort`);
|
|
3488
3680
|
}
|
|
3489
3681
|
/**
|
|
3490
3682
|
* Lists all executions for a given component.
|
|
@@ -3501,7 +3693,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3501
3693
|
*/
|
|
3502
3694
|
async listExecutions(t, e) {
|
|
3503
3695
|
if (this.localServerUrl) {
|
|
3504
|
-
const s = e ? `?projectId=${encodeURIComponent(e)}` : "",
|
|
3696
|
+
const s = e ? `?projectId=${encodeURIComponent(e)}` : "", n = `${this.localServerUrl}/api/${G}/${t}/progress${s}`, i = await fetch(n);
|
|
3505
3697
|
if (!i.ok) {
|
|
3506
3698
|
const o = await i.text().catch(() => "");
|
|
3507
3699
|
throw new Error(
|
|
@@ -3510,7 +3702,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3510
3702
|
}
|
|
3511
3703
|
return await i.json();
|
|
3512
3704
|
}
|
|
3513
|
-
return await a(this,
|
|
3705
|
+
return await a(this, l, y).call(this, "GET", `${G}/${t}/progress`, { query: { ...e && { projectId: e } } });
|
|
3514
3706
|
}
|
|
3515
3707
|
/**
|
|
3516
3708
|
* Gets details of a specific execution, including its messages.
|
|
@@ -3519,16 +3711,16 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3519
3711
|
*/
|
|
3520
3712
|
async getExecution(t) {
|
|
3521
3713
|
if (this.localServerUrl) {
|
|
3522
|
-
const e = `${this.localServerUrl}/api/${
|
|
3714
|
+
const e = `${this.localServerUrl}/api/${G}/progress/${t}`, s = await fetch(e);
|
|
3523
3715
|
if (!s.ok) {
|
|
3524
|
-
const
|
|
3716
|
+
const n = await s.text().catch(() => "");
|
|
3525
3717
|
throw new Error(
|
|
3526
|
-
`Local server request failed: ${s.status} - ${
|
|
3718
|
+
`Local server request failed: ${s.status} - ${n}`
|
|
3527
3719
|
);
|
|
3528
3720
|
}
|
|
3529
3721
|
return await s.json();
|
|
3530
3722
|
}
|
|
3531
|
-
return await a(this,
|
|
3723
|
+
return await a(this, l, y).call(this, "GET", `${G}/progress/${t}`);
|
|
3532
3724
|
}
|
|
3533
3725
|
/**
|
|
3534
3726
|
* Subscribes to real-time execution progress via WebSocket.
|
|
@@ -3537,19 +3729,27 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3537
3729
|
* @param onUpdateCallback - Callback invoked on each progress/result event.
|
|
3538
3730
|
*/
|
|
3539
3731
|
async onExecutionProgress(t, e) {
|
|
3540
|
-
const s = this.localServerUrl ?? this.wsUrl,
|
|
3732
|
+
const s = this.localServerUrl ?? this.wsUrl, n = await wt(s, {
|
|
3541
3733
|
auth: { accessToken: this.accessToken },
|
|
3542
3734
|
transports: ["websocket"]
|
|
3543
3735
|
});
|
|
3544
|
-
|
|
3545
|
-
|
|
3736
|
+
n.on("connect", function() {
|
|
3737
|
+
n.emit("executionSubscription", JSON.stringify({ executionId: t })), n.on("execution", (i) => {
|
|
3546
3738
|
e(i);
|
|
3547
3739
|
});
|
|
3548
|
-
}),
|
|
3740
|
+
}), n.on("connect_error", function(i) {
|
|
3549
3741
|
console.log(i);
|
|
3550
3742
|
});
|
|
3551
3743
|
}
|
|
3552
|
-
// ─── History & Recipes
|
|
3744
|
+
// ─── Documents, History & Recipes ────────────────────────────────
|
|
3745
|
+
/**
|
|
3746
|
+
* A project's documents. Every document is a FOLDER holding its files plus
|
|
3747
|
+
* a `document.json` descriptor naming the document, its native form and its
|
|
3748
|
+
* renderable views. See `src/core/documents.ts` for the model and schema.
|
|
3749
|
+
*/
|
|
3750
|
+
documents(t) {
|
|
3751
|
+
return new as(this, t);
|
|
3752
|
+
}
|
|
3553
3753
|
/**
|
|
3554
3754
|
* A project's history of connected documents (Revit models, AutoCAD
|
|
3555
3755
|
* drawings…): their version timelines and their change requests. See
|
|
@@ -3557,14 +3757,14 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3557
3757
|
* or write it; the storage underneath is private and will move.
|
|
3558
3758
|
*/
|
|
3559
3759
|
history(t) {
|
|
3560
|
-
return new
|
|
3760
|
+
return new Gr(this, t);
|
|
3561
3761
|
}
|
|
3562
3762
|
/**
|
|
3563
3763
|
* The recipe registry and runner: scripts that write change requests in a
|
|
3564
3764
|
* native application's language. See `src/core/recipes.ts`.
|
|
3565
3765
|
*/
|
|
3566
3766
|
get recipes() {
|
|
3567
|
-
return
|
|
3767
|
+
return u(this, vt) ?? _(this, vt, new Yr(this)), u(this, vt);
|
|
3568
3768
|
}
|
|
3569
3769
|
// ─── Hidden Files ────────────────────────────────────────────────
|
|
3570
3770
|
/**
|
|
@@ -3577,9 +3777,9 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3577
3777
|
* @returns The hidden file ID.
|
|
3578
3778
|
*/
|
|
3579
3779
|
async createHiddenFile(t, e, s) {
|
|
3580
|
-
const
|
|
3581
|
-
return
|
|
3582
|
-
body:
|
|
3780
|
+
const n = new FormData();
|
|
3781
|
+
return n.append("file", t), n.append("parentItemId", e), s != null && n.append("tag", s), await a(this, l, y).call(this, "POST", `${m}/${q}`, {
|
|
3782
|
+
body: n
|
|
3583
3783
|
});
|
|
3584
3784
|
}
|
|
3585
3785
|
/**
|
|
@@ -3593,11 +3793,11 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3593
3793
|
* @returns One result per uploaded file, in order, each with its hidden file ID.
|
|
3594
3794
|
*/
|
|
3595
3795
|
async createHiddenFilesBatch(t, e, s) {
|
|
3596
|
-
const
|
|
3796
|
+
const n = new FormData();
|
|
3597
3797
|
for (const i of t)
|
|
3598
|
-
|
|
3599
|
-
return
|
|
3600
|
-
body:
|
|
3798
|
+
n.append("files", i);
|
|
3799
|
+
return n.append("parentItemId", e), s != null && n.append("tag", s), await a(this, l, y).call(this, "POST", `${m}/${q}/batch`, {
|
|
3800
|
+
body: n
|
|
3601
3801
|
});
|
|
3602
3802
|
}
|
|
3603
3803
|
/**
|
|
@@ -3605,21 +3805,21 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3605
3805
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3606
3806
|
*/
|
|
3607
3807
|
async deleteHiddenFile(t) {
|
|
3608
|
-
return await a(this,
|
|
3808
|
+
return await a(this, l, y).call(this, "DELETE", `${m}/${q}/${t}`);
|
|
3609
3809
|
}
|
|
3610
3810
|
/**
|
|
3611
3811
|
* Gets metadata for a hidden file.
|
|
3612
3812
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3613
3813
|
*/
|
|
3614
3814
|
async getHiddenFile(t) {
|
|
3615
|
-
return await a(this,
|
|
3815
|
+
return await a(this, l, y).call(this, "GET", `${m}/${q}/${t}`);
|
|
3616
3816
|
}
|
|
3617
3817
|
/**
|
|
3618
3818
|
* Downloads a hidden file's content. Returns the raw fetch Response.
|
|
3619
3819
|
* @param hiddenId - The hidden file's unique identifier.
|
|
3620
3820
|
*/
|
|
3621
3821
|
async downloadHiddenFile(t) {
|
|
3622
|
-
return await a(this,
|
|
3822
|
+
return await a(this, l, H).call(this, `${m}/${q}/${t}/download`);
|
|
3623
3823
|
}
|
|
3624
3824
|
/**
|
|
3625
3825
|
* Mints a short-lived presigned URL for a hidden file so the browser can
|
|
@@ -3639,7 +3839,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3639
3839
|
* an ISO timestamp when it stops working.
|
|
3640
3840
|
*/
|
|
3641
3841
|
async getHiddenFileSignedUrl(t, e) {
|
|
3642
|
-
return await a(this,
|
|
3842
|
+
return await a(this, l, y).call(this, "GET", `${m}/${q}/${t}/signed-url`, { ...e != null && { query: { expiresIn: e } } });
|
|
3643
3843
|
}
|
|
3644
3844
|
/**
|
|
3645
3845
|
* Batch variant of {@link getHiddenFileSignedUrl}. Mints presigned URLs for
|
|
@@ -3660,7 +3860,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3660
3860
|
* 900 (15 min) server-side; values are clamped to that range.
|
|
3661
3861
|
*/
|
|
3662
3862
|
async getHiddenFileSignedUrlsBatch(t, e) {
|
|
3663
|
-
return await a(this,
|
|
3863
|
+
return await a(this, l, gt).call(this, t, async (s) => (await a(this, l, y).call(this, "POST", `${m}/${q}/signed-url/batch`, {
|
|
3664
3864
|
body: JSON.stringify({
|
|
3665
3865
|
hiddenFileIds: s,
|
|
3666
3866
|
...e != null && { expiresIn: e }
|
|
@@ -3676,14 +3876,14 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3676
3876
|
* @returns Array of hidden file entities.
|
|
3677
3877
|
*/
|
|
3678
3878
|
async getHiddenFilesByParent(t, e) {
|
|
3679
|
-
return await a(this,
|
|
3879
|
+
return await a(this, l, y).call(this, "GET", `${m}/${t}/${q}`, { ...e != null && { query: { tag: e } } });
|
|
3680
3880
|
}
|
|
3681
3881
|
/**
|
|
3682
3882
|
* Deletes all hidden files attached to a parent item.
|
|
3683
3883
|
* @param parentFileId - The parent item's unique identifier.
|
|
3684
3884
|
*/
|
|
3685
3885
|
async deleteHiddenFilesByParent(t) {
|
|
3686
|
-
return await a(this,
|
|
3886
|
+
return await a(this, l, y).call(this, "DELETE", `${m}/${t}/${q}`);
|
|
3687
3887
|
}
|
|
3688
3888
|
// ─── Icons ───────────────────────────────────────────────────────
|
|
3689
3889
|
/**
|
|
@@ -3695,7 +3895,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3695
3895
|
*/
|
|
3696
3896
|
async uploadItemIcon(t, e) {
|
|
3697
3897
|
const s = new FormData();
|
|
3698
|
-
return s.append("icon", e), await a(this,
|
|
3898
|
+
return s.append("icon", e), await a(this, l, y).call(this, "PUT", `${m}/${t}/icon`, {
|
|
3699
3899
|
body: s
|
|
3700
3900
|
});
|
|
3701
3901
|
}
|
|
@@ -3705,7 +3905,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3705
3905
|
* @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
|
|
3706
3906
|
*/
|
|
3707
3907
|
async getItemIcon(t) {
|
|
3708
|
-
return await a(this,
|
|
3908
|
+
return await a(this, l, H).call(this, `${m}/${t}/icon`);
|
|
3709
3909
|
}
|
|
3710
3910
|
/**
|
|
3711
3911
|
* Removes the icon from an item.
|
|
@@ -3713,7 +3913,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3713
3913
|
* @returns The updated item with icon fields removed.
|
|
3714
3914
|
*/
|
|
3715
3915
|
async removeItemIcon(t) {
|
|
3716
|
-
return await a(this,
|
|
3916
|
+
return await a(this, l, y).call(this, "DELETE", `${m}/${t}/icon`);
|
|
3717
3917
|
}
|
|
3718
3918
|
// ─── General Item Operations ─────────────────────────────────────
|
|
3719
3919
|
/**
|
|
@@ -3723,7 +3923,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3723
3923
|
* @returns The updated item.
|
|
3724
3924
|
*/
|
|
3725
3925
|
async updateItem(t, e) {
|
|
3726
|
-
return await a(this,
|
|
3926
|
+
return await a(this, l, y).call(this, "PUT", `${m}/${t}`, {
|
|
3727
3927
|
body: JSON.stringify(e),
|
|
3728
3928
|
contentType: "application/json"
|
|
3729
3929
|
});
|
|
@@ -3738,9 +3938,9 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3738
3938
|
* @param metadata - Optional free-JSON metadata to store on the new version.
|
|
3739
3939
|
* @returns The created version.
|
|
3740
3940
|
*/
|
|
3741
|
-
async createVersion(t, e, s,
|
|
3941
|
+
async createVersion(t, e, s, n, i) {
|
|
3742
3942
|
const o = new FormData();
|
|
3743
|
-
return o.append("file", e), o.append("versionTag", s),
|
|
3943
|
+
return o.append("file", e), o.append("versionTag", s), n && o.append("extraProps", JSON.stringify(n)), i && o.append("metadata", JSON.stringify(i)), await a(this, l, y).call(this, "POST", `${m}/${t}/version`, { body: o });
|
|
3744
3944
|
}
|
|
3745
3945
|
/**
|
|
3746
3946
|
* Lists versions of an item. Pass `archived: true` to fetch only archived
|
|
@@ -3750,7 +3950,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3750
3950
|
* @returns Array of versions, sorted by creation date descending.
|
|
3751
3951
|
*/
|
|
3752
3952
|
async listVersions(t, e = {}) {
|
|
3753
|
-
return await a(this,
|
|
3953
|
+
return await a(this, l, y).call(this, "GET", `${m}/${encodeURIComponent(t)}/versions`, { query: e });
|
|
3754
3954
|
}
|
|
3755
3955
|
/**
|
|
3756
3956
|
* Batch variant of {@link listVersions}. Lists the versions of many items in
|
|
@@ -3769,9 +3969,9 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3769
3969
|
*/
|
|
3770
3970
|
async listVersionsBatch(t, e = {}) {
|
|
3771
3971
|
const { archived: s } = e;
|
|
3772
|
-
return await a(this,
|
|
3972
|
+
return await a(this, l, gt).call(this, t, async (n) => (await a(this, l, y).call(this, "POST", `${m}/batch/versions`, {
|
|
3773
3973
|
body: JSON.stringify({
|
|
3774
|
-
itemIds:
|
|
3974
|
+
itemIds: n,
|
|
3775
3975
|
...s !== void 0 && { archived: s }
|
|
3776
3976
|
}),
|
|
3777
3977
|
contentType: "application/json"
|
|
@@ -3787,7 +3987,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3787
3987
|
* @returns The archived version.
|
|
3788
3988
|
*/
|
|
3789
3989
|
async archiveVersion(t, e) {
|
|
3790
|
-
return await a(this,
|
|
3990
|
+
return await a(this, l, y).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/archive`);
|
|
3791
3991
|
}
|
|
3792
3992
|
/**
|
|
3793
3993
|
* Recovers a previously archived version, restoring it to the active list.
|
|
@@ -3796,7 +3996,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3796
3996
|
* @returns The recovered version.
|
|
3797
3997
|
*/
|
|
3798
3998
|
async recoverVersion(t, e) {
|
|
3799
|
-
return await a(this,
|
|
3999
|
+
return await a(this, l, y).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/recover`);
|
|
3800
4000
|
}
|
|
3801
4001
|
/**
|
|
3802
4002
|
* Permanently deletes a version, including its file in object storage.
|
|
@@ -3805,59 +4005,59 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
|
|
|
3805
4005
|
* @param versionTag - The version's tag (e.g. "v2").
|
|
3806
4006
|
*/
|
|
3807
4007
|
async deleteVersion(t, e) {
|
|
3808
|
-
return await a(this,
|
|
4008
|
+
return await a(this, l, y).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
|
|
3809
4009
|
}
|
|
3810
4010
|
};
|
|
3811
|
-
|
|
4011
|
+
l = new WeakSet(), le = function(t) {
|
|
3812
4012
|
return `${this.apiUrl}/${t}`;
|
|
3813
|
-
},
|
|
3814
|
-
const { body:
|
|
3815
|
-
...
|
|
3816
|
-
...this.useBearer ? {} : { accessToken:
|
|
4013
|
+
}, y = async function(t, e, s) {
|
|
4014
|
+
const { body: n, query: i, contentType: o, retries: c, responseType: d, retryAttempt: f } = s || {}, h = a(this, l, le).call(this, e), g = a(this, l, fs).call(this, i), S = await this.resolveAccessToken(), dt = {
|
|
4015
|
+
...g,
|
|
4016
|
+
...this.useBearer ? {} : { accessToken: S }
|
|
3817
4017
|
};
|
|
3818
4018
|
try {
|
|
3819
|
-
const
|
|
3820
|
-
|
|
4019
|
+
const O = await fetch(
|
|
4020
|
+
h + "?" + new URLSearchParams(dt).toString(),
|
|
3821
4021
|
{
|
|
3822
4022
|
method: t,
|
|
3823
4023
|
headers: {
|
|
3824
4024
|
Accept: "application/json",
|
|
3825
4025
|
...o && { "Content-Type": o },
|
|
3826
|
-
...this.useBearer && { Authorization: `Bearer ${
|
|
4026
|
+
...this.useBearer && { Authorization: `Bearer ${S}` }
|
|
3827
4027
|
},
|
|
3828
|
-
...
|
|
4028
|
+
...n && { body: n }
|
|
3829
4029
|
}
|
|
3830
4030
|
);
|
|
3831
|
-
if (!
|
|
3832
|
-
const
|
|
3833
|
-
throw new
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
4031
|
+
if (!O.ok) {
|
|
4032
|
+
const k = await O.text().then((Z) => Z).catch(() => "");
|
|
4033
|
+
throw new Te(
|
|
4034
|
+
O.status,
|
|
4035
|
+
O.statusText,
|
|
4036
|
+
k,
|
|
4037
|
+
tn(O)
|
|
3838
4038
|
);
|
|
3839
4039
|
}
|
|
3840
|
-
return
|
|
4040
|
+
return d === "blob" ? await O.blob() : O.json().then((k) => k).catch(() => {
|
|
3841
4041
|
});
|
|
3842
|
-
} catch (
|
|
3843
|
-
const
|
|
3844
|
-
if (
|
|
3845
|
-
const
|
|
3846
|
-
return await
|
|
4042
|
+
} catch (O) {
|
|
4043
|
+
const k = c ?? this.retries;
|
|
4044
|
+
if (k > 0 && en(O)) {
|
|
4045
|
+
const Z = f ?? 0;
|
|
4046
|
+
return await Zr(sn(O, Z)), await a(this, l, y).call(this, t, e, {
|
|
3847
4047
|
...s,
|
|
3848
|
-
retries:
|
|
3849
|
-
retryAttempt:
|
|
4048
|
+
retries: k - 1,
|
|
4049
|
+
retryAttempt: Z + 1
|
|
3850
4050
|
});
|
|
3851
4051
|
}
|
|
3852
|
-
throw
|
|
4052
|
+
throw O;
|
|
3853
4053
|
}
|
|
3854
|
-
},
|
|
3855
|
-
const { query: s } = e || {},
|
|
4054
|
+
}, H = async function(t, e) {
|
|
4055
|
+
const { query: s } = e || {}, n = a(this, l, le).call(this, t), i = await this.resolveAccessToken(), o = {
|
|
3856
4056
|
...s,
|
|
3857
4057
|
...this.useBearer ? {} : { accessToken: i }
|
|
3858
4058
|
};
|
|
3859
4059
|
return await fetch(
|
|
3860
|
-
|
|
4060
|
+
n + "?" + new URLSearchParams(o).toString(),
|
|
3861
4061
|
{
|
|
3862
4062
|
method: "GET",
|
|
3863
4063
|
...this.useBearer && {
|
|
@@ -3865,146 +4065,146 @@ c = new WeakSet(), ee = function(t) {
|
|
|
3865
4065
|
}
|
|
3866
4066
|
}
|
|
3867
4067
|
);
|
|
3868
|
-
},
|
|
4068
|
+
}, vt = new WeakMap(), gt = async function(t, e) {
|
|
3869
4069
|
if (!t.length) return [];
|
|
3870
4070
|
const s = [];
|
|
3871
|
-
for (let i = 0; i < t.length; i +=
|
|
3872
|
-
s.push(t.slice(i, i +
|
|
4071
|
+
for (let i = 0; i < t.length; i += Me)
|
|
4072
|
+
s.push(t.slice(i, i + Me));
|
|
3873
4073
|
return (await Promise.all(s.map(e))).flat();
|
|
3874
|
-
},
|
|
3875
|
-
const { versionTag: s, withDraft:
|
|
3876
|
-
return await a(this,
|
|
4074
|
+
}, Nt = async function(t, e) {
|
|
4075
|
+
const { versionTag: s, withDraft: n } = e || {};
|
|
4076
|
+
return await a(this, l, H).call(this, `${m}/${t}/download`, {
|
|
3877
4077
|
query: {
|
|
3878
4078
|
...s && { versionTag: s },
|
|
3879
|
-
...
|
|
4079
|
+
...n && { withDraft: n }
|
|
3880
4080
|
}
|
|
3881
4081
|
});
|
|
3882
|
-
},
|
|
3883
|
-
const { name:
|
|
3884
|
-
return
|
|
3885
|
-
body:
|
|
4082
|
+
}, Pt = async function(t, e, s) {
|
|
4083
|
+
const { name: n, versionTag: i, parentFolderId: o, projectId: c, file: d, metadata: f } = t, h = new FormData();
|
|
4084
|
+
return h.append("file", d), h.append("name", n), h.append("versionTag", i), h.append("itemType", e), o && h.append("folderId", o), c && h.append("projectId", c), s && h.append("extraProps", JSON.stringify(s)), f && h.append("metadata", JSON.stringify(f)), await a(this, l, y).call(this, "POST", m, {
|
|
4085
|
+
body: h
|
|
3886
4086
|
});
|
|
3887
|
-
},
|
|
3888
|
-
const { name:
|
|
3889
|
-
let f,
|
|
3890
|
-
if (
|
|
3891
|
-
const
|
|
3892
|
-
|
|
3893
|
-
body:
|
|
4087
|
+
}, ue = async function(t, e, s) {
|
|
4088
|
+
const { name: n, versionTag: i, parentFolderId: o, file: c, metadata: d } = e;
|
|
4089
|
+
let f, h;
|
|
4090
|
+
if (c) {
|
|
4091
|
+
const g = new FormData();
|
|
4092
|
+
g.append("file", c), i && g.append("versionTag", i), s && g.append("extraProps", JSON.stringify(s)), d && g.append("metadata", JSON.stringify(d)), h = await a(this, l, y).call(this, "POST", `${m}/${t}/version`, {
|
|
4093
|
+
body: g
|
|
3894
4094
|
});
|
|
3895
4095
|
}
|
|
3896
|
-
if (
|
|
3897
|
-
const
|
|
3898
|
-
...
|
|
4096
|
+
if (n || o) {
|
|
4097
|
+
const g = {
|
|
4098
|
+
...n && { name: n },
|
|
3899
4099
|
...o && { folderId: o }
|
|
3900
|
-
},
|
|
3901
|
-
f = await a(this,
|
|
3902
|
-
body:
|
|
4100
|
+
}, S = JSON.stringify(g);
|
|
4101
|
+
f = await a(this, l, y).call(this, "PUT", `${m}/${t}`, {
|
|
4102
|
+
body: S,
|
|
3903
4103
|
contentType: "application/json"
|
|
3904
4104
|
});
|
|
3905
4105
|
}
|
|
3906
|
-
return { item: f, version:
|
|
3907
|
-
},
|
|
4106
|
+
return { item: f, version: h };
|
|
4107
|
+
}, de = async function(t, e) {
|
|
3908
4108
|
const { showVersions: s = !1 } = e || {};
|
|
3909
|
-
return await a(this,
|
|
4109
|
+
return await a(this, l, y).call(this, "GET", `${m}/${t}`, {
|
|
3910
4110
|
query: { showVersions: s }
|
|
3911
4111
|
});
|
|
3912
|
-
},
|
|
4112
|
+
}, fs = function(t) {
|
|
3913
4113
|
return t && Object.entries(t).filter(([, e]) => e !== void 0).reduce(
|
|
3914
|
-
(e, [s,
|
|
4114
|
+
(e, [s, n]) => (e[s] = n, e),
|
|
3915
4115
|
{}
|
|
3916
4116
|
);
|
|
3917
4117
|
};
|
|
3918
|
-
let
|
|
3919
|
-
function
|
|
4118
|
+
let he = Se;
|
|
4119
|
+
function rn() {
|
|
3920
4120
|
if (typeof window > "u" || window.parent === window)
|
|
3921
4121
|
throw new Error(
|
|
3922
4122
|
"client.channel only works inside a That Open app, which runs in an iframe of the platform."
|
|
3923
4123
|
);
|
|
3924
4124
|
return {
|
|
3925
|
-
post: (
|
|
3926
|
-
listen: (
|
|
4125
|
+
post: (r) => window.parent.postMessage(r, "*"),
|
|
4126
|
+
listen: (r) => {
|
|
3927
4127
|
const t = (e) => {
|
|
3928
|
-
e.source === window.parent &&
|
|
4128
|
+
e.source === window.parent && r(e.data);
|
|
3929
4129
|
};
|
|
3930
4130
|
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
3931
4131
|
}
|
|
3932
4132
|
};
|
|
3933
4133
|
}
|
|
3934
|
-
const
|
|
3935
|
-
function
|
|
4134
|
+
const fe = "channel:", nn = 1e4;
|
|
4135
|
+
function Bt(r) {
|
|
3936
4136
|
try {
|
|
3937
|
-
|
|
4137
|
+
r();
|
|
3938
4138
|
} catch (t) {
|
|
3939
4139
|
console.error("[channel] a listener threw:", t);
|
|
3940
4140
|
}
|
|
3941
4141
|
}
|
|
3942
|
-
var
|
|
3943
|
-
class
|
|
4142
|
+
var j, C, x, ot, at, ct, A, pe, ye, it;
|
|
4143
|
+
class ps {
|
|
3944
4144
|
constructor(t, e) {
|
|
3945
|
-
b(this,
|
|
3946
|
-
b(this,
|
|
3947
|
-
b(this,
|
|
3948
|
-
b(this,
|
|
3949
|
-
b(this,
|
|
3950
|
-
b(this,
|
|
3951
|
-
b(this,
|
|
4145
|
+
b(this, A);
|
|
4146
|
+
b(this, j, !1);
|
|
4147
|
+
b(this, C, []);
|
|
4148
|
+
b(this, x, []);
|
|
4149
|
+
b(this, ot, /* @__PURE__ */ new Set());
|
|
4150
|
+
b(this, at, /* @__PURE__ */ new Set());
|
|
4151
|
+
b(this, ct, /* @__PURE__ */ new Set());
|
|
3952
4152
|
this.transport = t, this.controls = e;
|
|
3953
4153
|
}
|
|
3954
4154
|
/** Whether the platform has confirmed this tab is in the room. */
|
|
3955
4155
|
get joined() {
|
|
3956
|
-
return
|
|
4156
|
+
return u(this, j);
|
|
3957
4157
|
}
|
|
3958
4158
|
/** Who else is in the room right now, as the platform last reported. */
|
|
3959
4159
|
get peers() {
|
|
3960
|
-
return
|
|
4160
|
+
return u(this, C);
|
|
3961
4161
|
}
|
|
3962
4162
|
/**
|
|
3963
4163
|
* Enters the room. Resolves when the platform confirms; rejects if it
|
|
3964
4164
|
* refuses or does not answer in time. Joining twice is harmless.
|
|
3965
4165
|
*/
|
|
3966
4166
|
join() {
|
|
3967
|
-
return
|
|
4167
|
+
return u(this, j) ? Promise.resolve() : a(this, A, pe).call(this, "joined", this.controls.join);
|
|
3968
4168
|
}
|
|
3969
4169
|
/** Leaves the room. Handlers stay registered, so `join()` resumes them. */
|
|
3970
4170
|
leave() {
|
|
3971
|
-
return !
|
|
4171
|
+
return !u(this, j) && !u(this, x).some((t) => t.want === "joined") ? Promise.resolve() : a(this, A, pe).call(this, "left", this.controls.leave);
|
|
3972
4172
|
}
|
|
3973
4173
|
/** Fires when `joined` or `peers` changes. Returns a function that stops it. */
|
|
3974
4174
|
onChange(t) {
|
|
3975
|
-
return
|
|
4175
|
+
return u(this, ot).add(t), () => void u(this, ot).delete(t);
|
|
3976
4176
|
}
|
|
3977
4177
|
onPeerJoined(t) {
|
|
3978
|
-
return
|
|
4178
|
+
return u(this, at).add(t), () => void u(this, at).delete(t);
|
|
3979
4179
|
}
|
|
3980
4180
|
onPeerLeft(t) {
|
|
3981
|
-
return
|
|
4181
|
+
return u(this, ct).add(t), () => void u(this, ct).delete(t);
|
|
3982
4182
|
}
|
|
3983
4183
|
/** @internal */
|
|
3984
4184
|
applyJoined() {
|
|
3985
|
-
_(this,
|
|
4185
|
+
_(this, j, !0), a(this, A, ye).call(this, "joined"), a(this, A, it).call(this);
|
|
3986
4186
|
}
|
|
3987
4187
|
/** @internal */
|
|
3988
4188
|
applyLeft() {
|
|
3989
|
-
_(this,
|
|
4189
|
+
_(this, j, !1), _(this, C, []), a(this, A, ye).call(this, "left"), a(this, A, it).call(this);
|
|
3990
4190
|
}
|
|
3991
4191
|
/** @internal */
|
|
3992
4192
|
applyPeers(t) {
|
|
3993
|
-
_(this,
|
|
4193
|
+
_(this, C, t), a(this, A, it).call(this);
|
|
3994
4194
|
}
|
|
3995
4195
|
/** @internal */
|
|
3996
4196
|
applyPeerJoined(t) {
|
|
3997
|
-
!
|
|
4197
|
+
!u(this, j) || u(this, C).some((e) => e.from === t.from) || (_(this, C, [...u(this, C), t]), u(this, at).forEach((e) => Bt(() => e(t))), a(this, A, it).call(this));
|
|
3998
4198
|
}
|
|
3999
4199
|
/** @internal */
|
|
4000
4200
|
applyPeerLeft(t) {
|
|
4001
|
-
const e =
|
|
4002
|
-
e && (_(this,
|
|
4201
|
+
const e = u(this, C).find((s) => s.from === t);
|
|
4202
|
+
e && (_(this, C, u(this, C).filter((s) => s.from !== t)), u(this, ct).forEach((s) => Bt(() => s(e))), a(this, A, it).call(this));
|
|
4003
4203
|
}
|
|
4004
4204
|
/** @internal */
|
|
4005
4205
|
failPending(t) {
|
|
4006
|
-
const e =
|
|
4007
|
-
return _(this,
|
|
4206
|
+
const e = u(this, x);
|
|
4207
|
+
return _(this, x, []), e.forEach((s) => {
|
|
4008
4208
|
clearTimeout(s.timer), s.reject(t);
|
|
4009
4209
|
}), e.length > 0;
|
|
4010
4210
|
}
|
|
@@ -4012,77 +4212,77 @@ class Ke {
|
|
|
4012
4212
|
this.transport.post(t);
|
|
4013
4213
|
}
|
|
4014
4214
|
}
|
|
4015
|
-
|
|
4016
|
-
return new Promise((s,
|
|
4215
|
+
j = new WeakMap(), C = new WeakMap(), x = new WeakMap(), ot = new WeakMap(), at = new WeakMap(), ct = new WeakMap(), A = new WeakSet(), pe = function(t, e) {
|
|
4216
|
+
return new Promise((s, n) => {
|
|
4017
4217
|
const i = {
|
|
4018
4218
|
want: t,
|
|
4019
4219
|
resolve: s,
|
|
4020
|
-
reject:
|
|
4220
|
+
reject: n,
|
|
4021
4221
|
timer: setTimeout(() => {
|
|
4022
|
-
_(this,
|
|
4222
|
+
_(this, x, u(this, x).filter((o) => o !== i)), n(
|
|
4023
4223
|
new Error(
|
|
4024
4224
|
`The platform did not confirm ${t === "joined" ? "joining" : "leaving"} in time.`
|
|
4025
4225
|
)
|
|
4026
4226
|
);
|
|
4027
|
-
},
|
|
4227
|
+
}, nn)
|
|
4028
4228
|
};
|
|
4029
|
-
|
|
4229
|
+
u(this, x).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
|
|
4030
4230
|
});
|
|
4031
|
-
},
|
|
4032
|
-
const e =
|
|
4033
|
-
_(this,
|
|
4231
|
+
}, ye = function(t) {
|
|
4232
|
+
const e = u(this, x).filter((s) => s.want === t);
|
|
4233
|
+
_(this, x, u(this, x).filter((s) => s.want !== t)), e.forEach((s) => {
|
|
4034
4234
|
clearTimeout(s.timer), s.resolve();
|
|
4035
4235
|
});
|
|
4036
|
-
},
|
|
4037
|
-
|
|
4236
|
+
}, it = function() {
|
|
4237
|
+
u(this, ot).forEach((t) => Bt(t));
|
|
4038
4238
|
};
|
|
4039
|
-
var
|
|
4040
|
-
class
|
|
4239
|
+
var ht;
|
|
4240
|
+
class on extends ps {
|
|
4041
4241
|
/** @internal Use `client.channel.collab()`. */
|
|
4042
4242
|
constructor(e) {
|
|
4043
4243
|
super(e, {
|
|
4044
4244
|
join: { action: "joinCollab" },
|
|
4045
4245
|
leave: { action: "leaveCollab" }
|
|
4046
4246
|
});
|
|
4047
|
-
b(this,
|
|
4247
|
+
b(this, ht, /* @__PURE__ */ new Map());
|
|
4048
4248
|
}
|
|
4049
4249
|
/**
|
|
4050
4250
|
* Listens for an event other tabs send. Any number of listeners per event.
|
|
4051
4251
|
* @returns a function that removes the listener.
|
|
4052
4252
|
*/
|
|
4053
4253
|
on(e, s) {
|
|
4054
|
-
const
|
|
4055
|
-
return
|
|
4254
|
+
const n = u(this, ht).get(e) ?? /* @__PURE__ */ new Set();
|
|
4255
|
+
return n.add(s), u(this, ht).set(e, n), () => void n.delete(s);
|
|
4056
4256
|
}
|
|
4057
4257
|
/**
|
|
4058
4258
|
* Sends an event to the other tabs in the room. Does nothing while this tab
|
|
4059
4259
|
* is not in it, matching what the platform does with a message from outside.
|
|
4060
4260
|
*/
|
|
4061
4261
|
send(e, s) {
|
|
4062
|
-
if (e.startsWith(
|
|
4063
|
-
throw new Error(`Message types starting with '${
|
|
4262
|
+
if (e.startsWith(fe))
|
|
4263
|
+
throw new Error(`Message types starting with '${fe}' are reserved.`);
|
|
4064
4264
|
this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: e, payload: s } });
|
|
4065
4265
|
}
|
|
4066
4266
|
accepts(e) {
|
|
4067
4267
|
return e === void 0 || e === "collab";
|
|
4068
4268
|
}
|
|
4069
4269
|
async handle(e) {
|
|
4070
|
-
const s =
|
|
4270
|
+
const s = u(this, ht).get(e.type);
|
|
4071
4271
|
if (!(s != null && s.size)) return { handled: !1 };
|
|
4072
|
-
const
|
|
4073
|
-
return s.forEach((i) =>
|
|
4272
|
+
const n = ys(e);
|
|
4273
|
+
return s.forEach((i) => Bt(() => i(e.payload, n))), { handled: !0 };
|
|
4074
4274
|
}
|
|
4075
4275
|
}
|
|
4076
|
-
|
|
4077
|
-
var
|
|
4078
|
-
class
|
|
4276
|
+
ht = new WeakMap();
|
|
4277
|
+
var Y;
|
|
4278
|
+
class an extends ps {
|
|
4079
4279
|
/** @internal Use `client.channel.external(kind)`. */
|
|
4080
4280
|
constructor(e, s) {
|
|
4081
4281
|
super(e, {
|
|
4082
4282
|
join: { action: "joinExternal", kind: s },
|
|
4083
4283
|
leave: { action: "leaveExternal", kind: s }
|
|
4084
4284
|
});
|
|
4085
|
-
b(this,
|
|
4285
|
+
b(this, Y, /* @__PURE__ */ new Map());
|
|
4086
4286
|
this.kind = s;
|
|
4087
4287
|
}
|
|
4088
4288
|
/**
|
|
@@ -4096,43 +4296,43 @@ class fn extends Ke {
|
|
|
4096
4296
|
* @returns a function that removes the handler.
|
|
4097
4297
|
*/
|
|
4098
4298
|
on(e, s) {
|
|
4099
|
-
if (
|
|
4299
|
+
if (u(this, Y).has(e))
|
|
4100
4300
|
throw new Error(
|
|
4101
4301
|
`"${e}" already has a handler in this room. Remove it first.`
|
|
4102
4302
|
);
|
|
4103
|
-
return
|
|
4303
|
+
return u(this, Y).set(e, s), () => void u(this, Y).delete(e);
|
|
4104
4304
|
}
|
|
4105
4305
|
accepts(e, s) {
|
|
4106
4306
|
return e !== void 0 && e !== "external" ? !1 : this.kind === void 0 || e === void 0 || this.kind === s;
|
|
4107
4307
|
}
|
|
4108
4308
|
/** @internal Whether this room has any handler at all. */
|
|
4109
4309
|
get hasHandlers() {
|
|
4110
|
-
return
|
|
4310
|
+
return u(this, Y).size > 0;
|
|
4111
4311
|
}
|
|
4112
4312
|
async handle(e) {
|
|
4113
|
-
const s =
|
|
4313
|
+
const s = u(this, Y).get(e.type);
|
|
4114
4314
|
if (!s) return { handled: !1 };
|
|
4115
4315
|
try {
|
|
4116
|
-
return { handled: !0, value: await s(e.payload,
|
|
4117
|
-
} catch (
|
|
4316
|
+
return { handled: !0, value: await s(e.payload, ys(e)) };
|
|
4317
|
+
} catch (n) {
|
|
4118
4318
|
return {
|
|
4119
4319
|
handled: !0,
|
|
4120
|
-
error:
|
|
4320
|
+
error: n instanceof Error ? n.message : String(n)
|
|
4121
4321
|
};
|
|
4122
4322
|
}
|
|
4123
4323
|
}
|
|
4124
4324
|
}
|
|
4125
|
-
|
|
4126
|
-
function
|
|
4325
|
+
Y = new WeakMap();
|
|
4326
|
+
function ys(r) {
|
|
4127
4327
|
return {
|
|
4128
|
-
from:
|
|
4129
|
-
at:
|
|
4130
|
-
requestId:
|
|
4131
|
-
kind:
|
|
4328
|
+
from: r.from,
|
|
4329
|
+
at: r.at,
|
|
4330
|
+
requestId: r.requestId,
|
|
4331
|
+
kind: r.kind
|
|
4132
4332
|
};
|
|
4133
4333
|
}
|
|
4134
|
-
function
|
|
4135
|
-
const t =
|
|
4334
|
+
function cn(r) {
|
|
4335
|
+
const t = r;
|
|
4136
4336
|
if ((t == null ? void 0 : t.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
|
|
4137
4337
|
const e = t.message;
|
|
4138
4338
|
return !e || typeof e.type != "string" ? null : {
|
|
@@ -4145,20 +4345,20 @@ function pn(n) {
|
|
|
4145
4345
|
kind: typeof e.kind == "string" ? e.kind : void 0
|
|
4146
4346
|
};
|
|
4147
4347
|
}
|
|
4148
|
-
var
|
|
4149
|
-
class
|
|
4348
|
+
var Q, Tt, M, W, K, v, me, Lt, ms, gs, ws, ge;
|
|
4349
|
+
class hn {
|
|
4150
4350
|
constructor(t) {
|
|
4151
4351
|
b(this, v);
|
|
4152
|
-
b(this,
|
|
4153
|
-
b(this,
|
|
4154
|
-
b(this,
|
|
4155
|
-
b(this,
|
|
4156
|
-
b(this,
|
|
4157
|
-
_(this,
|
|
4352
|
+
b(this, Q);
|
|
4353
|
+
b(this, Tt);
|
|
4354
|
+
b(this, M);
|
|
4355
|
+
b(this, W, /* @__PURE__ */ new Map());
|
|
4356
|
+
b(this, K, /* @__PURE__ */ new Set());
|
|
4357
|
+
_(this, Q, t), _(this, Tt, t.listen((e) => void a(this, v, ms).call(this, e)));
|
|
4158
4358
|
}
|
|
4159
4359
|
/** The collaboration room for this app. Always the same instance. */
|
|
4160
4360
|
collab() {
|
|
4161
|
-
return
|
|
4361
|
+
return u(this, M) ?? _(this, M, new on(u(this, Q))), u(this, M);
|
|
4162
4362
|
}
|
|
4163
4363
|
/**
|
|
4164
4364
|
* The room for commands from this account's external tools of one `kind`
|
|
@@ -4167,71 +4367,71 @@ class yn {
|
|
|
4167
4367
|
*/
|
|
4168
4368
|
external(t) {
|
|
4169
4369
|
const e = t ?? "";
|
|
4170
|
-
let s =
|
|
4171
|
-
return s || (s = new
|
|
4370
|
+
let s = u(this, W).get(e);
|
|
4371
|
+
return s || (s = new an(u(this, Q), t), u(this, W).set(e, s)), s;
|
|
4172
4372
|
}
|
|
4173
4373
|
/** Stops listening. For tests and teardown; an app normally never calls it. */
|
|
4174
4374
|
dispose() {
|
|
4175
|
-
|
|
4375
|
+
u(this, Tt).call(this);
|
|
4176
4376
|
}
|
|
4177
4377
|
}
|
|
4178
|
-
|
|
4179
|
-
return [...
|
|
4180
|
-
},
|
|
4181
|
-
if (t === "collab") return
|
|
4378
|
+
Q = new WeakMap(), Tt = new WeakMap(), M = new WeakMap(), W = new WeakMap(), K = new WeakMap(), v = new WeakSet(), me = function() {
|
|
4379
|
+
return [...u(this, M) ? [u(this, M)] : [], ...u(this, W).values()];
|
|
4380
|
+
}, Lt = function(t, e) {
|
|
4381
|
+
if (t === "collab") return u(this, M);
|
|
4182
4382
|
if (t === "external")
|
|
4183
|
-
return
|
|
4184
|
-
},
|
|
4185
|
-
const e =
|
|
4383
|
+
return u(this, W).get(typeof e == "string" ? e : "");
|
|
4384
|
+
}, ms = async function(t) {
|
|
4385
|
+
const e = cn(t);
|
|
4186
4386
|
if (e) {
|
|
4187
|
-
if (e.type.startsWith(
|
|
4188
|
-
a(this, v,
|
|
4387
|
+
if (e.type.startsWith(fe)) {
|
|
4388
|
+
a(this, v, gs).call(this, e);
|
|
4189
4389
|
return;
|
|
4190
4390
|
}
|
|
4191
|
-
await a(this, v,
|
|
4391
|
+
await a(this, v, ws).call(this, e);
|
|
4192
4392
|
}
|
|
4193
|
-
},
|
|
4194
|
-
var s,
|
|
4393
|
+
}, gs = function(t) {
|
|
4394
|
+
var s, n, i;
|
|
4195
4395
|
const e = t.payload ?? {};
|
|
4196
4396
|
switch (t.type) {
|
|
4197
4397
|
case "channel:joined":
|
|
4198
|
-
(s = a(this, v,
|
|
4398
|
+
(s = a(this, v, Lt).call(this, e.scope, e.kind)) == null || s.applyJoined();
|
|
4199
4399
|
break;
|
|
4200
4400
|
case "channel:left":
|
|
4201
|
-
(
|
|
4401
|
+
(n = a(this, v, Lt).call(this, e.scope, e.kind)) == null || n.applyLeft();
|
|
4202
4402
|
break;
|
|
4203
4403
|
case "channel:peers":
|
|
4204
|
-
(i = a(this, v,
|
|
4404
|
+
(i = a(this, v, Lt).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
|
|
4205
4405
|
break;
|
|
4206
4406
|
case "channel:peer-joined":
|
|
4207
4407
|
case "channel:peer-left": {
|
|
4208
4408
|
if (!e.from) break;
|
|
4209
|
-
const o = e.scope === "collab" ? [
|
|
4210
|
-
(
|
|
4409
|
+
const o = e.scope === "collab" ? [u(this, M)] : [...u(this, W).values()].filter(
|
|
4410
|
+
(c) => c.accepts("external", e.kind)
|
|
4211
4411
|
);
|
|
4212
|
-
for (const
|
|
4213
|
-
t.type === "channel:peer-joined" ?
|
|
4412
|
+
for (const c of o)
|
|
4413
|
+
t.type === "channel:peer-joined" ? c == null || c.applyPeerJoined({ from: e.from, kind: e.kind }) : c == null || c.applyPeerLeft(e.from);
|
|
4214
4414
|
break;
|
|
4215
4415
|
}
|
|
4216
4416
|
case "channel:error": {
|
|
4217
4417
|
const o = new Error(String(t.payload));
|
|
4218
|
-
a(this, v,
|
|
4418
|
+
a(this, v, me).call(this).map((d) => d.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
|
|
4219
4419
|
break;
|
|
4220
4420
|
}
|
|
4221
4421
|
}
|
|
4222
|
-
},
|
|
4223
|
-
const e = a(this, v,
|
|
4422
|
+
}, ws = async function(t) {
|
|
4423
|
+
const e = a(this, v, me).call(this).filter((i) => i.accepts(t.scope, t.kind));
|
|
4224
4424
|
let s = !1;
|
|
4225
4425
|
for (const i of e) {
|
|
4226
4426
|
const o = await i.handle(t);
|
|
4227
|
-
o.handled && (s = !0, t.requestId && a(this, v,
|
|
4427
|
+
o.handled && (s = !0, t.requestId && a(this, v, ge).call(this, t.requestId, o));
|
|
4228
4428
|
}
|
|
4229
|
-
t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v,
|
|
4429
|
+
t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v, ge).call(this, t.requestId, {
|
|
4230
4430
|
handled: !0,
|
|
4231
4431
|
error: `No handler for "${t.type}".`
|
|
4232
4432
|
});
|
|
4233
|
-
},
|
|
4234
|
-
|
|
4433
|
+
}, ge = function(t, e) {
|
|
4434
|
+
u(this, K).has(t) || (u(this, K).add(t), u(this, K).size > 500 && u(this, K).delete(u(this, K).values().next().value), u(this, Q).post({
|
|
4235
4435
|
type: "APP_CHANNEL_PUBLISH",
|
|
4236
4436
|
message: {
|
|
4237
4437
|
type: e.error === void 0 ? "reply" : "reply-error",
|
|
@@ -4240,9 +4440,9 @@ W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), G = new WeakMap(), V =
|
|
|
4240
4440
|
}
|
|
4241
4441
|
}));
|
|
4242
4442
|
};
|
|
4243
|
-
const
|
|
4244
|
-
var
|
|
4245
|
-
const
|
|
4443
|
+
const X = "project", tt = "notifications";
|
|
4444
|
+
var lt, St;
|
|
4445
|
+
const Ie = class Ie extends he {
|
|
4246
4446
|
/**
|
|
4247
4447
|
* @param token - A bearer JWT, OR a function returning the current JWT
|
|
4248
4448
|
* (sync or async). When a function is passed, it's invoked before every
|
|
@@ -4251,14 +4451,14 @@ const me = class me extends te {
|
|
|
4251
4451
|
* @param props - Optional client configuration. `useBearer` is forced to
|
|
4252
4452
|
* `true` and cannot be overridden.
|
|
4253
4453
|
*/
|
|
4254
|
-
constructor(e, s,
|
|
4255
|
-
super(typeof e == "string" ? e : "", s, { ...
|
|
4256
|
-
b(this,
|
|
4257
|
-
b(this,
|
|
4258
|
-
typeof e == "function" && _(this,
|
|
4454
|
+
constructor(e, s, n) {
|
|
4455
|
+
super(typeof e == "string" ? e : "", s, { ...n, useBearer: !0 });
|
|
4456
|
+
b(this, lt);
|
|
4457
|
+
b(this, St);
|
|
4458
|
+
typeof e == "function" && _(this, lt, e);
|
|
4259
4459
|
}
|
|
4260
4460
|
async resolveAccessToken() {
|
|
4261
|
-
return
|
|
4461
|
+
return u(this, lt) ? await u(this, lt).call(this) : super.resolveAccessToken();
|
|
4262
4462
|
}
|
|
4263
4463
|
/**
|
|
4264
4464
|
* Creates a client from the platform context injected into
|
|
@@ -4267,8 +4467,8 @@ const me = class me extends te {
|
|
|
4267
4467
|
* carries a fresh JWT on every navigation.
|
|
4268
4468
|
*/
|
|
4269
4469
|
static fromPlatformContext(e) {
|
|
4270
|
-
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" },
|
|
4271
|
-
return
|
|
4470
|
+
const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, n = new Ie(s.accessToken, s.apiUrl, e);
|
|
4471
|
+
return n.context = s, n;
|
|
4272
4472
|
}
|
|
4273
4473
|
/**
|
|
4274
4474
|
* The platform channel, from inside an app: a collaboration room shared with
|
|
@@ -4295,7 +4495,7 @@ const me = class me extends te {
|
|
|
4295
4495
|
* ```
|
|
4296
4496
|
*/
|
|
4297
4497
|
get channel() {
|
|
4298
|
-
return
|
|
4498
|
+
return u(this, St) ?? _(this, St, new hn(rn())), u(this, St);
|
|
4299
4499
|
}
|
|
4300
4500
|
// ─── Projects (JWT-only backend routes) ──────────────────────────
|
|
4301
4501
|
/**
|
|
@@ -4314,14 +4514,14 @@ const me = class me extends te {
|
|
|
4314
4514
|
* ```
|
|
4315
4515
|
*/
|
|
4316
4516
|
async listProjects() {
|
|
4317
|
-
return await this.request("GET",
|
|
4517
|
+
return await this.request("GET", X);
|
|
4318
4518
|
}
|
|
4319
4519
|
/**
|
|
4320
4520
|
* Gets a project by ID. JWT-only — lives here because
|
|
4321
4521
|
* `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
|
|
4322
4522
|
*/
|
|
4323
4523
|
async getProject(e) {
|
|
4324
|
-
return await this.request("GET", `${
|
|
4524
|
+
return await this.request("GET", `${X}/${e}`);
|
|
4325
4525
|
}
|
|
4326
4526
|
/**
|
|
4327
4527
|
* Gets the full project data (users, roles, files, folders) for a project.
|
|
@@ -4330,7 +4530,7 @@ const me = class me extends te {
|
|
|
4330
4530
|
async getProjectData(e) {
|
|
4331
4531
|
return await this.request(
|
|
4332
4532
|
"GET",
|
|
4333
|
-
`${
|
|
4533
|
+
`${X}/${e}/data`
|
|
4334
4534
|
);
|
|
4335
4535
|
}
|
|
4336
4536
|
// ─── Account ──────────────────────────────────────────────────────
|
|
@@ -4355,7 +4555,7 @@ const me = class me extends te {
|
|
|
4355
4555
|
async checkPermission(e) {
|
|
4356
4556
|
return await this.request(
|
|
4357
4557
|
"GET",
|
|
4358
|
-
`${
|
|
4558
|
+
`${X}/permissions/check`,
|
|
4359
4559
|
{ query: e }
|
|
4360
4560
|
);
|
|
4361
4561
|
}
|
|
@@ -4364,7 +4564,7 @@ const me = class me extends te {
|
|
|
4364
4564
|
* single round-trip; results come back in the same order as `checks`.
|
|
4365
4565
|
*/
|
|
4366
4566
|
async checkPermissionBatch(e) {
|
|
4367
|
-
return (await this.request("POST", `${
|
|
4567
|
+
return (await this.request("POST", `${X}/permissions/check/batch`, {
|
|
4368
4568
|
body: JSON.stringify({ checks: e }),
|
|
4369
4569
|
contentType: "application/json"
|
|
4370
4570
|
})).results;
|
|
@@ -4392,7 +4592,7 @@ const me = class me extends te {
|
|
|
4392
4592
|
* ```
|
|
4393
4593
|
*/
|
|
4394
4594
|
async getNotifications(e) {
|
|
4395
|
-
return await this.request("GET",
|
|
4595
|
+
return await this.request("GET", tt, {
|
|
4396
4596
|
query: {
|
|
4397
4597
|
...(e == null ? void 0 : e.cursor) !== void 0 && { cursor: e.cursor },
|
|
4398
4598
|
...(e == null ? void 0 : e.limit) !== void 0 && { limit: String(e.limit) }
|
|
@@ -4406,7 +4606,7 @@ const me = class me extends te {
|
|
|
4406
4606
|
async getUnreadNotificationCount() {
|
|
4407
4607
|
return (await this.request(
|
|
4408
4608
|
"GET",
|
|
4409
|
-
`${
|
|
4609
|
+
`${tt}/unread-count`
|
|
4410
4610
|
)).count;
|
|
4411
4611
|
}
|
|
4412
4612
|
/**
|
|
@@ -4417,7 +4617,7 @@ const me = class me extends te {
|
|
|
4417
4617
|
async markNotificationsRead(e) {
|
|
4418
4618
|
return await this.request(
|
|
4419
4619
|
"POST",
|
|
4420
|
-
`${
|
|
4620
|
+
`${tt}/mark-read`,
|
|
4421
4621
|
{
|
|
4422
4622
|
body: JSON.stringify({ ids: e }),
|
|
4423
4623
|
contentType: "application/json"
|
|
@@ -4428,7 +4628,7 @@ const me = class me extends te {
|
|
|
4428
4628
|
async markAllNotificationsRead() {
|
|
4429
4629
|
return await this.request(
|
|
4430
4630
|
"POST",
|
|
4431
|
-
`${
|
|
4631
|
+
`${tt}/mark-all-read`
|
|
4432
4632
|
);
|
|
4433
4633
|
}
|
|
4434
4634
|
/**
|
|
@@ -4438,7 +4638,7 @@ const me = class me extends te {
|
|
|
4438
4638
|
async getNotificationSubscriptions() {
|
|
4439
4639
|
return await this.request(
|
|
4440
4640
|
"GET",
|
|
4441
|
-
`${
|
|
4641
|
+
`${tt}/subscriptions`
|
|
4442
4642
|
);
|
|
4443
4643
|
}
|
|
4444
4644
|
/**
|
|
@@ -4452,7 +4652,7 @@ const me = class me extends te {
|
|
|
4452
4652
|
async unsubscribeFromAutomation(e) {
|
|
4453
4653
|
return await this.request(
|
|
4454
4654
|
"DELETE",
|
|
4455
|
-
`${
|
|
4655
|
+
`${tt}/subscriptions/${e}`
|
|
4456
4656
|
);
|
|
4457
4657
|
}
|
|
4458
4658
|
/**
|
|
@@ -4473,12 +4673,12 @@ const me = class me extends te {
|
|
|
4473
4673
|
* });
|
|
4474
4674
|
* ```
|
|
4475
4675
|
*/
|
|
4476
|
-
async subscribeToAutomation(e, s,
|
|
4676
|
+
async subscribeToAutomation(e, s, n) {
|
|
4477
4677
|
return await this.request(
|
|
4478
4678
|
"POST",
|
|
4479
|
-
`${
|
|
4679
|
+
`${X}/${e}/events/hooks/${s}/subscription`,
|
|
4480
4680
|
{
|
|
4481
|
-
body: JSON.stringify(
|
|
4681
|
+
body: JSON.stringify(n ?? {}),
|
|
4482
4682
|
contentType: "application/json"
|
|
4483
4683
|
}
|
|
4484
4684
|
);
|
|
@@ -4490,12 +4690,12 @@ const me = class me extends te {
|
|
|
4490
4690
|
* Throws if the user is not subscribed; use {@link subscribeToAutomation}
|
|
4491
4691
|
* to create one.
|
|
4492
4692
|
*/
|
|
4493
|
-
async updateAutomationSubscription(e, s,
|
|
4693
|
+
async updateAutomationSubscription(e, s, n) {
|
|
4494
4694
|
return await this.request(
|
|
4495
4695
|
"PATCH",
|
|
4496
|
-
`${
|
|
4696
|
+
`${X}/${e}/events/hooks/${s}/subscription`,
|
|
4497
4697
|
{
|
|
4498
|
-
body: JSON.stringify(
|
|
4698
|
+
body: JSON.stringify(n),
|
|
4499
4699
|
contentType: "application/json"
|
|
4500
4700
|
}
|
|
4501
4701
|
);
|
|
@@ -4527,54 +4727,246 @@ const me = class me extends te {
|
|
|
4527
4727
|
* ```
|
|
4528
4728
|
*/
|
|
4529
4729
|
async onNotification(e) {
|
|
4530
|
-
const s = await this.resolveAccessToken(),
|
|
4730
|
+
const s = await this.resolveAccessToken(), n = wt(`${this.socketOrigin}/notifications`, {
|
|
4531
4731
|
auth: { accessToken: s },
|
|
4532
4732
|
transports: ["websocket"]
|
|
4533
4733
|
});
|
|
4534
|
-
return
|
|
4734
|
+
return n.on(
|
|
4535
4735
|
"notification.created",
|
|
4536
4736
|
(i) => e({ type: "created", id: i == null ? void 0 : i.id })
|
|
4537
|
-
),
|
|
4737
|
+
), n.on(
|
|
4538
4738
|
"notification.read",
|
|
4539
4739
|
(i) => e({ type: "read", id: i == null ? void 0 : i.id })
|
|
4540
|
-
),
|
|
4740
|
+
), n.on(
|
|
4541
4741
|
"notifications.allRead",
|
|
4542
4742
|
(i) => e({ type: "allRead", batch: i == null ? void 0 : i.batch })
|
|
4543
|
-
), () =>
|
|
4743
|
+
), () => n.disconnect();
|
|
4544
4744
|
}
|
|
4545
4745
|
};
|
|
4546
|
-
|
|
4547
|
-
let
|
|
4548
|
-
const
|
|
4746
|
+
lt = new WeakMap(), St = new WeakMap();
|
|
4747
|
+
let Ge = Ie;
|
|
4748
|
+
const ln = "flow:", un = "flow:op", dn = "flow:source", fn = "revitflow/op@2", He = "REVITFLOWCHANGE", Je = "REVITFLOWOPERATION";
|
|
4749
|
+
class wn {
|
|
4750
|
+
constructor(t) {
|
|
4751
|
+
I(this, "changes", []);
|
|
4752
|
+
this.target = t;
|
|
4753
|
+
}
|
|
4754
|
+
/** How many changes are queued. An operation with none is refused by `build`. */
|
|
4755
|
+
get length() {
|
|
4756
|
+
return this.changes.length;
|
|
4757
|
+
}
|
|
4758
|
+
// The envelope, readable. Whoever writes the queue entry has to put the SAME
|
|
4759
|
+
// values in it as the payload carries — an entry that disagrees with its own
|
|
4760
|
+
// payload is a row describing a different operation — so they are exposed
|
|
4761
|
+
// here rather than passed twice by every caller.
|
|
4762
|
+
get batchId() {
|
|
4763
|
+
return this.target.batchId;
|
|
4764
|
+
}
|
|
4765
|
+
get title() {
|
|
4766
|
+
return this.target.title ?? `${this.changes.length} change(s)`;
|
|
4767
|
+
}
|
|
4768
|
+
get author() {
|
|
4769
|
+
return this.target.author ?? "app";
|
|
4770
|
+
}
|
|
4771
|
+
get userId() {
|
|
4772
|
+
return this.target.userId;
|
|
4773
|
+
}
|
|
4774
|
+
get baseCommit() {
|
|
4775
|
+
return this.target.baseCommit;
|
|
4776
|
+
}
|
|
4777
|
+
/**
|
|
4778
|
+
* Create something. There is no id yet: the attributes describe what it is,
|
|
4779
|
+
* the placement says where it goes, and the operation answers with the id
|
|
4780
|
+
* it got.
|
|
4781
|
+
*/
|
|
4782
|
+
add(t, e = {}) {
|
|
4783
|
+
return this.changes.push({ op: "add", attrs: this.pack(t, e) }), this;
|
|
4784
|
+
}
|
|
4785
|
+
/** Write attributes onto an item that already exists, named by the id the target published. */
|
|
4786
|
+
set(t, e, s = {}) {
|
|
4787
|
+
return this.requireId(t, "set"), this.changes.push({ op: "set", item: t, attrs: this.pack(e, s) }), this;
|
|
4788
|
+
}
|
|
4789
|
+
/** Delete an item. Whatever the target cascades along with it is reported, not guessed at here. */
|
|
4790
|
+
remove(t) {
|
|
4791
|
+
return this.requireId(t, "remove"), this.changes.push({ op: "remove", item: t, attrs: {} }), this;
|
|
4792
|
+
}
|
|
4793
|
+
/**
|
|
4794
|
+
* A label for what this operation mostly does. Derived, never read to
|
|
4795
|
+
* decide anything: one operation may add, set and remove at once and still
|
|
4796
|
+
* be atomic, so what each change does is written on the change.
|
|
4797
|
+
*/
|
|
4798
|
+
get summary() {
|
|
4799
|
+
const t = new Set(this.changes.map((e) => e.op));
|
|
4800
|
+
return t.size === 1 ? [...t][0] : "mixed";
|
|
4801
|
+
}
|
|
4802
|
+
/**
|
|
4803
|
+
* The .frag bytes, zlib-deflated, ready to upload as the operation's
|
|
4804
|
+
* payload.
|
|
4805
|
+
*
|
|
4806
|
+
* `opId` is taken rather than generated so the caller can put the same id
|
|
4807
|
+
* in the queue entry it writes next ({@link Recipes} mints it before the
|
|
4808
|
+
* run); an id this class invented and did not return would have to be dug
|
|
4809
|
+
* back out of the bytes.
|
|
4810
|
+
*/
|
|
4811
|
+
async build(t) {
|
|
4812
|
+
if (this.changes.length === 0)
|
|
4813
|
+
throw new Error(
|
|
4814
|
+
"An operation with no changes is not an operation. Add at least one."
|
|
4815
|
+
);
|
|
4816
|
+
const e = {
|
|
4817
|
+
schema: fn,
|
|
4818
|
+
opId: t,
|
|
4819
|
+
// Through the getters, so the envelope and the queue entry cannot drift
|
|
4820
|
+
// into disagreeing about the same operation.
|
|
4821
|
+
batchId: this.batchId ?? t,
|
|
4822
|
+
targetProject: this.target.project,
|
|
4823
|
+
targetDocument: this.target.document,
|
|
4824
|
+
baseCommit: this.baseCommit,
|
|
4825
|
+
author: this.author,
|
|
4826
|
+
...this.userId ? { userId: this.userId } : {},
|
|
4827
|
+
title: this.title,
|
|
4828
|
+
summary: this.summary
|
|
4829
|
+
}, [s, n] = await pn();
|
|
4830
|
+
return yn(
|
|
4831
|
+
this.flatbuffer(s, n, t, JSON.stringify(e))
|
|
4832
|
+
);
|
|
4833
|
+
}
|
|
4834
|
+
// ---------------------------------------------------------------------------------------------
|
|
4835
|
+
/** Placement rides in the attributes, in the same string form the target published. */
|
|
4836
|
+
pack(t, e) {
|
|
4837
|
+
const s = {};
|
|
4838
|
+
for (const [n, i] of Object.entries(t ?? {}))
|
|
4839
|
+
n.startsWith(ln) || (s[n] = String(i));
|
|
4840
|
+
return e.position && (s.Position = e.position.map(Ye).join(",")), e.rotationDeg !== void 0 && (s.Rotation = Ye(e.rotationDeg)), e.source && (s[dn] = e.source), s;
|
|
4841
|
+
}
|
|
4842
|
+
requireId(t, e) {
|
|
4843
|
+
if (!t || !t.trim())
|
|
4844
|
+
throw new Error(`A '${e}' has to name the item it acts on.`);
|
|
4845
|
+
}
|
|
4846
|
+
/**
|
|
4847
|
+
* The buffer itself.
|
|
4848
|
+
*
|
|
4849
|
+
* Laid out exactly as the C# writer lays it out, because the add-in's
|
|
4850
|
+
* reader is the one that has to accept both: items first and the container
|
|
4851
|
+
* after, ids handed out by one monotonic counter, attributes as
|
|
4852
|
+
* `[name, value, type]` JSON triples, and a Meshes table that exists but is
|
|
4853
|
+
* empty.
|
|
4854
|
+
*
|
|
4855
|
+
* Empty rather than absent: the reader asks for it unconditionally, and a
|
|
4856
|
+
* model that draws nothing is still a model. Nothing here gets a sample —
|
|
4857
|
+
* an item with no triangles must not have one, because a sample's bounding
|
|
4858
|
+
* box would then have no size and the reader turns a box into a "dimension"
|
|
4859
|
+
* and rejects a falsy one.
|
|
4860
|
+
*/
|
|
4861
|
+
flatbuffer(t, e, s, n) {
|
|
4862
|
+
const { Attribute: i, Meshes: o, Model: c, SpatialStructure: d, Transform: f } = e, h = new t.Builder(1024), g = this.changes.length, S = new Uint32Array(g);
|
|
4863
|
+
let dt = 1;
|
|
4864
|
+
for (let T = 0; T < g; T++) S[T] = dt++;
|
|
4865
|
+
const O = dt++, k = (T) => (T(h, 0), h.endVector()), Z = o.createShellsVector(h, []), bs = o.createCircleExtrusionsVector(h, []), _s = k(o.startSamplesVector), Es = k(o.startRepresentationsVector), vs = k(o.startMaterialsVector), Ts = k(o.startLocalTransformsVector), Ss = k(o.startGlobalTransformsVector), Is = o.createMeshesItemsVector(h, []), Os = o.createMaterialIdsVector(h, []), As = o.createRepresentationIdsVector(h, []), ks = o.createSampleIdsVector(h, []), Cs = o.createLocalTransformIdsVector(h, []), xs = o.createGlobalTransformIdsVector(h, []);
|
|
4866
|
+
o.startMeshes(h), o.addCoordinates(h, f.createTransform(h, 0, 0, 0, 1, 0, 0, 0, 1, 0)), o.addGlobalTransforms(h, Ss), o.addShells(h, Z), o.addRepresentations(h, Es), o.addSamples(h, _s), o.addLocalTransforms(h, Ts), o.addMaterials(h, vs), o.addCircleExtrusions(h, bs), o.addMeshesItems(h, Is), o.addRepresentationIds(h, As), o.addSampleIds(h, ks), o.addMaterialIds(h, Os), o.addLocalTransformIds(h, Cs), o.addGlobalTransformIds(h, xs);
|
|
4867
|
+
const Rs = o.endMeshes(h), $s = h.createString(n), Dt = /* @__PURE__ */ new Set(), Ut = [];
|
|
4868
|
+
for (const T of this.changes) {
|
|
4869
|
+
const V = [], Vs = {
|
|
4870
|
+
[un]: T.op,
|
|
4871
|
+
...T.attrs
|
|
4872
|
+
};
|
|
4873
|
+
for (const [Gs, Hs] of Object.entries(Vs)) {
|
|
4874
|
+
const Ce = JSON.stringify([Gs, Hs, "IFCTEXT"]);
|
|
4875
|
+
Dt.add(Ce), V.push(h.createString(Ce));
|
|
4876
|
+
}
|
|
4877
|
+
Ut.push(
|
|
4878
|
+
i.createAttribute(h, i.createDataVector(h, V))
|
|
4879
|
+
);
|
|
4880
|
+
}
|
|
4881
|
+
{
|
|
4882
|
+
const T = JSON.stringify(["Name", s, "IFCLABEL"]);
|
|
4883
|
+
Dt.add(T);
|
|
4884
|
+
const V = i.createDataVector(h, [h.createString(T)]);
|
|
4885
|
+
Ut.push(i.createAttribute(h, V));
|
|
4886
|
+
}
|
|
4887
|
+
const Ns = c.createAttributesVector(h, Ut), Ps = c.createUniqueAttributesVector(
|
|
4888
|
+
h,
|
|
4889
|
+
[...Dt].map((T) => h.createString(T))
|
|
4890
|
+
), Oe = this.changes.map(
|
|
4891
|
+
() => h.createString(He)
|
|
4892
|
+
);
|
|
4893
|
+
Oe.push(h.createString(Je));
|
|
4894
|
+
const Bs = c.createCategoriesVector(h, Oe), Ae = [], ke = [];
|
|
4895
|
+
this.changes.forEach((T, V) => {
|
|
4896
|
+
T.item && (Ae.push(h.createString(T.item)), ke.push(S[V]));
|
|
4897
|
+
});
|
|
4898
|
+
const Ls = c.createGuidsVector(h, Ae), Fs = c.createGuidsItemsVector(h, ke), qs = c.createLocalIdsVector(h, [...S, O]), Ds = this.changes.map(
|
|
4899
|
+
(T, V) => d.createSpatialStructure(
|
|
4900
|
+
h,
|
|
4901
|
+
S[V],
|
|
4902
|
+
h.createString(He),
|
|
4903
|
+
0
|
|
4904
|
+
)
|
|
4905
|
+
), Us = d.createSpatialStructure(
|
|
4906
|
+
h,
|
|
4907
|
+
O,
|
|
4908
|
+
h.createString(Je),
|
|
4909
|
+
d.createChildrenVector(h, Ds)
|
|
4910
|
+
), js = h.createString(s);
|
|
4911
|
+
c.startModel(h), c.addMeshes(h, Rs), c.addMetadata(h, $s), c.addAttributes(h, Ns), c.addUniqueAttributes(h, Ps), c.addLocalIds(h, qs), c.addCategories(h, Bs), c.addGuidsItems(h, Fs), c.addGuids(h, Ls), c.addGuid(h, js), c.addSpatialStructure(h, Us), c.addMaxLocalId(h, dt);
|
|
4912
|
+
const Ms = c.endModel(h);
|
|
4913
|
+
return c.finishModelBuffer(h, Ms), h.asUint8Array();
|
|
4914
|
+
}
|
|
4915
|
+
}
|
|
4916
|
+
async function pn() {
|
|
4917
|
+
try {
|
|
4918
|
+
return await Promise.all([
|
|
4919
|
+
import("flatbuffers"),
|
|
4920
|
+
import("@thatopen/fragments")
|
|
4921
|
+
]);
|
|
4922
|
+
} catch (r) {
|
|
4923
|
+
throw new Error(
|
|
4924
|
+
`OperationBuilder needs the optional peers \`flatbuffers\` and \`@thatopen/fragments\` installed — add them to the app that authors operations. (${r instanceof Error ? r.message : String(r)})`
|
|
4925
|
+
);
|
|
4926
|
+
}
|
|
4927
|
+
}
|
|
4928
|
+
function Ye(r) {
|
|
4929
|
+
return Number.isFinite(r) ? String(r) : "0";
|
|
4930
|
+
}
|
|
4931
|
+
async function yn(r) {
|
|
4932
|
+
const t = new Blob([r]).stream().pipeThrough(new CompressionStream("deflate"));
|
|
4933
|
+
return new Uint8Array(await new Response(t).arrayBuffer());
|
|
4934
|
+
}
|
|
4935
|
+
const bn = {
|
|
4549
4936
|
MAX_FIELDS: 200,
|
|
4550
4937
|
MAX_KEY_LENGTH: 50,
|
|
4551
4938
|
MAX_VALUE_LENGTH: 50
|
|
4552
|
-
},
|
|
4939
|
+
}, _n = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, En = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, vn = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, Tn = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, Sn = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, In = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, On = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, An = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, kn = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
|
|
4553
4940
|
export {
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
vn as
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
On as
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4941
|
+
_n as CDEManager,
|
|
4942
|
+
hn as ChannelClient,
|
|
4943
|
+
ps as ChannelRoom,
|
|
4944
|
+
En as ClashesManager,
|
|
4945
|
+
on as CollabRoom,
|
|
4946
|
+
Le as DOCUMENT_FILE,
|
|
4947
|
+
te as DOCUMENT_SCHEMA,
|
|
4948
|
+
he as EngineServicesClient,
|
|
4949
|
+
an as ExternalRoom,
|
|
4950
|
+
vn as FileList,
|
|
4951
|
+
Hr as FlowDoc,
|
|
4952
|
+
Tn as GISManager,
|
|
4953
|
+
Sn as GitHistoryManager,
|
|
4954
|
+
In as HelloWorld,
|
|
4955
|
+
bn as METADATA_LIMITS,
|
|
4956
|
+
fn as OP_SCHEMA,
|
|
4957
|
+
wn as OperationBuilder,
|
|
4958
|
+
Ge as PlatformClient,
|
|
4959
|
+
as as ProjectDocuments,
|
|
4960
|
+
Gr as ProjectHistory,
|
|
4961
|
+
On as ProjectManager,
|
|
4962
|
+
Yr as Recipes,
|
|
4963
|
+
Te as RequestError,
|
|
4964
|
+
Me as STORAGE_BATCH_MAX,
|
|
4965
|
+
qe as StaleHistoryError,
|
|
4966
|
+
An as TopicsManager,
|
|
4967
|
+
kn as UIManager,
|
|
4968
|
+
ae as mintGuid,
|
|
4969
|
+
ds as orderByGraph,
|
|
4970
|
+
rn as windowTransport
|
|
4579
4971
|
};
|
|
4580
4972
|
//# sourceMappingURL=index.es.js.map
|