@speckle/objectsender 1.0.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/objectsender.cjs +3 -0
- package/dist/objectsender.cjs.map +1 -0
- package/dist/objectsender.js +534 -0
- package/dist/objectsender.js.map +1 -0
- package/dist/vite.svg +1 -0
- package/eslint.config.mjs +41 -0
- package/index.html +104 -0
- package/package.json +58 -0
- package/public/vite.svg +1 -0
- package/readme.md +13 -0
- package/src/examples/browser/main.ts +120 -0
- package/src/index.ts +51 -0
- package/src/transports/ITransport.ts +12 -0
- package/src/transports/ServerTransport.ts +61 -0
- package/src/utils/Base.ts +15 -0
- package/src/utils/IDisposable.ts +3 -0
- package/src/utils/Serializer.ts +248 -0
- package/src/utils/Sha1.ts +138 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +23 -0
- package/vite.config.js +18 -0
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
var ht = Object.defineProperty;
|
|
2
|
+
var ut = (t, e, r) => e in t ? ht(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var u = (t, e, r) => (ut(t, typeof e != "symbol" ? e + "" : e, r), r), ft = (t, e, r) => {
|
|
4
|
+
if (!e.has(t))
|
|
5
|
+
throw TypeError("Cannot " + r);
|
|
6
|
+
};
|
|
7
|
+
var P = (t, e, r) => {
|
|
8
|
+
if (e.has(t))
|
|
9
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
+
e instanceof WeakSet ? e.add(t) : e.set(t, r);
|
|
11
|
+
};
|
|
12
|
+
var y = (t, e, r) => (ft(t, e, "access private method"), r);
|
|
13
|
+
function B(t) {
|
|
14
|
+
function e(T, _) {
|
|
15
|
+
return T << _ | T >>> 32 - _;
|
|
16
|
+
}
|
|
17
|
+
function r(T) {
|
|
18
|
+
let _ = "", v, C;
|
|
19
|
+
for (v = 7; v >= 0; v--)
|
|
20
|
+
C = T >>> v * 4 & 15, _ += C.toString(16);
|
|
21
|
+
return _;
|
|
22
|
+
}
|
|
23
|
+
function i(T) {
|
|
24
|
+
T = T.replace(/\r\n/g, `
|
|
25
|
+
`);
|
|
26
|
+
let _ = "";
|
|
27
|
+
for (let v = 0; v < T.length; v++) {
|
|
28
|
+
const C = T.charCodeAt(v);
|
|
29
|
+
C < 128 ? _ += String.fromCharCode(C) : C > 127 && C < 2048 ? (_ += String.fromCharCode(C >> 6 | 192), _ += String.fromCharCode(C & 63 | 128)) : (_ += String.fromCharCode(C >> 12 | 224), _ += String.fromCharCode(C >> 6 & 63 | 128), _ += String.fromCharCode(C & 63 | 128));
|
|
30
|
+
}
|
|
31
|
+
return _;
|
|
32
|
+
}
|
|
33
|
+
let a, n, g;
|
|
34
|
+
const p = new Array(80);
|
|
35
|
+
let m = 1732584193, j = 4023233417, h = 2562383102, f = 271733878, S = 3285377520, l, s, o, c, d, b;
|
|
36
|
+
t = i(t);
|
|
37
|
+
const w = t.length, O = [];
|
|
38
|
+
for (n = 0; n < w - 3; n += 4)
|
|
39
|
+
g = t.charCodeAt(n) << 24 | t.charCodeAt(n + 1) << 16 | t.charCodeAt(n + 2) << 8 | t.charCodeAt(n + 3), O.push(g);
|
|
40
|
+
switch (w % 4) {
|
|
41
|
+
case 0:
|
|
42
|
+
n = 2147483648;
|
|
43
|
+
break;
|
|
44
|
+
case 1:
|
|
45
|
+
n = t.charCodeAt(w - 1) << 24 | 8388608;
|
|
46
|
+
break;
|
|
47
|
+
case 2:
|
|
48
|
+
n = t.charCodeAt(w - 2) << 24 | t.charCodeAt(w - 1) << 16 | 32768;
|
|
49
|
+
break;
|
|
50
|
+
case 3:
|
|
51
|
+
n = t.charCodeAt(w - 3) << 24 | t.charCodeAt(w - 2) << 16 | t.charCodeAt(w - 1) << 8 | 128;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
for (O.push(n); O.length % 16 !== 14; )
|
|
55
|
+
O.push(0);
|
|
56
|
+
for (O.push(w >>> 29), O.push(w << 3 & 4294967295), a = 0; a < O.length; a += 16) {
|
|
57
|
+
for (n = 0; n < 16; n++)
|
|
58
|
+
p[n] = O[a + n];
|
|
59
|
+
for (n = 16; n <= 79; n++)
|
|
60
|
+
p[n] = e(p[n - 3] ^ p[n - 8] ^ p[n - 14] ^ p[n - 16], 1);
|
|
61
|
+
for (l = m, s = j, o = h, c = f, d = S, n = 0; n <= 19; n++)
|
|
62
|
+
b = e(l, 5) + (s & o | ~s & c) + d + p[n] + 1518500249 & 4294967295, d = c, c = o, o = e(s, 30), s = l, l = b;
|
|
63
|
+
for (n = 20; n <= 39; n++)
|
|
64
|
+
b = e(l, 5) + (s ^ o ^ c) + d + p[n] + 1859775393 & 4294967295, d = c, c = o, o = e(s, 30), s = l, l = b;
|
|
65
|
+
for (n = 40; n <= 59; n++)
|
|
66
|
+
b = e(l, 5) + (s & o | s & c | o & c) + d + p[n] + 2400959708 & 4294967295, d = c, c = o, o = e(s, 30), s = l, l = b;
|
|
67
|
+
for (n = 60; n <= 79; n++)
|
|
68
|
+
b = e(l, 5) + (s ^ o ^ c) + d + p[n] + 3395469782 & 4294967295, d = c, c = o, o = e(s, 30), s = l, l = b;
|
|
69
|
+
m = m + l & 4294967295, j = j + s & 4294967295, h = h + o & 4294967295, f = f + c & 4294967295, S = S + d & 4294967295;
|
|
70
|
+
}
|
|
71
|
+
return (r(m) + r(j) + r(h) + r(f) + r(S)).toLowerCase().substring(0, 32);
|
|
72
|
+
}
|
|
73
|
+
var lt = typeof global == "object" && global && global.Object === Object && global, pt = typeof self == "object" && self && self.Object === Object && self, W = lt || pt || Function("return this")(), x = W.Symbol, rt = Object.prototype, dt = rt.hasOwnProperty, yt = rt.toString, F = x ? x.toStringTag : void 0;
|
|
74
|
+
function gt(t) {
|
|
75
|
+
var e = dt.call(t, F), r = t[F];
|
|
76
|
+
try {
|
|
77
|
+
t[F] = void 0;
|
|
78
|
+
var i = !0;
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
var a = yt.call(t);
|
|
82
|
+
return i && (e ? t[F] = r : delete t[F]), a;
|
|
83
|
+
}
|
|
84
|
+
var _t = Object.prototype, bt = _t.toString;
|
|
85
|
+
function wt(t) {
|
|
86
|
+
return bt.call(t);
|
|
87
|
+
}
|
|
88
|
+
var Ct = "[object Null]", St = "[object Undefined]", Y = x ? x.toStringTag : void 0;
|
|
89
|
+
function nt(t) {
|
|
90
|
+
return t == null ? t === void 0 ? St : Ct : Y && Y in Object(t) ? gt(t) : wt(t);
|
|
91
|
+
}
|
|
92
|
+
function it(t) {
|
|
93
|
+
return t != null && typeof t == "object";
|
|
94
|
+
}
|
|
95
|
+
var mt = "[object Symbol]";
|
|
96
|
+
function J(t) {
|
|
97
|
+
return typeof t == "symbol" || it(t) && nt(t) == mt;
|
|
98
|
+
}
|
|
99
|
+
function Tt(t, e) {
|
|
100
|
+
for (var r = -1, i = t == null ? 0 : t.length, a = Array(i); ++r < i; )
|
|
101
|
+
a[r] = e(t[r], r, t);
|
|
102
|
+
return a;
|
|
103
|
+
}
|
|
104
|
+
var V = Array.isArray, vt = 1 / 0, Z = x ? x.prototype : void 0, Q = Z ? Z.toString : void 0;
|
|
105
|
+
function at(t) {
|
|
106
|
+
if (typeof t == "string")
|
|
107
|
+
return t;
|
|
108
|
+
if (V(t))
|
|
109
|
+
return Tt(t, at) + "";
|
|
110
|
+
if (J(t))
|
|
111
|
+
return Q ? Q.call(t) : "";
|
|
112
|
+
var e = t + "";
|
|
113
|
+
return e == "0" && 1 / t == -vt ? "-0" : e;
|
|
114
|
+
}
|
|
115
|
+
function st(t) {
|
|
116
|
+
var e = typeof t;
|
|
117
|
+
return t != null && (e == "object" || e == "function");
|
|
118
|
+
}
|
|
119
|
+
var jt = "[object AsyncFunction]", Ot = "[object Function]", zt = "[object GeneratorFunction]", $t = "[object Proxy]";
|
|
120
|
+
function At(t) {
|
|
121
|
+
if (!st(t))
|
|
122
|
+
return !1;
|
|
123
|
+
var e = nt(t);
|
|
124
|
+
return e == Ot || e == zt || e == jt || e == $t;
|
|
125
|
+
}
|
|
126
|
+
var K = W["__core-js_shared__"], tt = function() {
|
|
127
|
+
var t = /[^.]+$/.exec(K && K.keys && K.keys.IE_PROTO || "");
|
|
128
|
+
return t ? "Symbol(src)_1." + t : "";
|
|
129
|
+
}();
|
|
130
|
+
function kt(t) {
|
|
131
|
+
return !!tt && tt in t;
|
|
132
|
+
}
|
|
133
|
+
var Pt = Function.prototype, It = Pt.toString;
|
|
134
|
+
function xt(t) {
|
|
135
|
+
if (t != null) {
|
|
136
|
+
try {
|
|
137
|
+
return It.call(t);
|
|
138
|
+
} catch {
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
return t + "";
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return "";
|
|
146
|
+
}
|
|
147
|
+
var Et = /[\\^$.*+?()[\]{}|]/g, Ft = /^\[object .+?Constructor\]$/, Dt = Function.prototype, Lt = Object.prototype, Nt = Dt.toString, Ht = Lt.hasOwnProperty, Ut = RegExp(
|
|
148
|
+
"^" + Nt.call(Ht).replace(Et, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
149
|
+
);
|
|
150
|
+
function Mt(t) {
|
|
151
|
+
if (!st(t) || kt(t))
|
|
152
|
+
return !1;
|
|
153
|
+
var e = At(t) ? Ut : Ft;
|
|
154
|
+
return e.test(xt(t));
|
|
155
|
+
}
|
|
156
|
+
function Rt(t, e) {
|
|
157
|
+
return t == null ? void 0 : t[e];
|
|
158
|
+
}
|
|
159
|
+
function ot(t, e) {
|
|
160
|
+
var r = Rt(t, e);
|
|
161
|
+
return Mt(r) ? r : void 0;
|
|
162
|
+
}
|
|
163
|
+
function Gt(t, e) {
|
|
164
|
+
return t === e || t !== t && e !== e;
|
|
165
|
+
}
|
|
166
|
+
var Bt = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, Kt = /^\w*$/;
|
|
167
|
+
function qt(t, e) {
|
|
168
|
+
if (V(t))
|
|
169
|
+
return !1;
|
|
170
|
+
var r = typeof t;
|
|
171
|
+
return r == "number" || r == "symbol" || r == "boolean" || t == null || J(t) ? !0 : Kt.test(t) || !Bt.test(t) || e != null && t in Object(e);
|
|
172
|
+
}
|
|
173
|
+
var N = ot(Object, "create");
|
|
174
|
+
function Wt() {
|
|
175
|
+
this.__data__ = N ? N(null) : {}, this.size = 0;
|
|
176
|
+
}
|
|
177
|
+
function Jt(t) {
|
|
178
|
+
var e = this.has(t) && delete this.__data__[t];
|
|
179
|
+
return this.size -= e ? 1 : 0, e;
|
|
180
|
+
}
|
|
181
|
+
var Vt = "__lodash_hash_undefined__", Xt = Object.prototype, Yt = Xt.hasOwnProperty;
|
|
182
|
+
function Zt(t) {
|
|
183
|
+
var e = this.__data__;
|
|
184
|
+
if (N) {
|
|
185
|
+
var r = e[t];
|
|
186
|
+
return r === Vt ? void 0 : r;
|
|
187
|
+
}
|
|
188
|
+
return Yt.call(e, t) ? e[t] : void 0;
|
|
189
|
+
}
|
|
190
|
+
var Qt = Object.prototype, te = Qt.hasOwnProperty;
|
|
191
|
+
function ee(t) {
|
|
192
|
+
var e = this.__data__;
|
|
193
|
+
return N ? e[t] !== void 0 : te.call(e, t);
|
|
194
|
+
}
|
|
195
|
+
var re = "__lodash_hash_undefined__";
|
|
196
|
+
function ne(t, e) {
|
|
197
|
+
var r = this.__data__;
|
|
198
|
+
return this.size += this.has(t) ? 0 : 1, r[t] = N && e === void 0 ? re : e, this;
|
|
199
|
+
}
|
|
200
|
+
function A(t) {
|
|
201
|
+
var e = -1, r = t == null ? 0 : t.length;
|
|
202
|
+
for (this.clear(); ++e < r; ) {
|
|
203
|
+
var i = t[e];
|
|
204
|
+
this.set(i[0], i[1]);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
A.prototype.clear = Wt;
|
|
208
|
+
A.prototype.delete = Jt;
|
|
209
|
+
A.prototype.get = Zt;
|
|
210
|
+
A.prototype.has = ee;
|
|
211
|
+
A.prototype.set = ne;
|
|
212
|
+
function ie() {
|
|
213
|
+
this.__data__ = [], this.size = 0;
|
|
214
|
+
}
|
|
215
|
+
function R(t, e) {
|
|
216
|
+
for (var r = t.length; r--; )
|
|
217
|
+
if (Gt(t[r][0], e))
|
|
218
|
+
return r;
|
|
219
|
+
return -1;
|
|
220
|
+
}
|
|
221
|
+
var ae = Array.prototype, se = ae.splice;
|
|
222
|
+
function oe(t) {
|
|
223
|
+
var e = this.__data__, r = R(e, t);
|
|
224
|
+
if (r < 0)
|
|
225
|
+
return !1;
|
|
226
|
+
var i = e.length - 1;
|
|
227
|
+
return r == i ? e.pop() : se.call(e, r, 1), --this.size, !0;
|
|
228
|
+
}
|
|
229
|
+
function ce(t) {
|
|
230
|
+
var e = this.__data__, r = R(e, t);
|
|
231
|
+
return r < 0 ? void 0 : e[r][1];
|
|
232
|
+
}
|
|
233
|
+
function he(t) {
|
|
234
|
+
return R(this.__data__, t) > -1;
|
|
235
|
+
}
|
|
236
|
+
function ue(t, e) {
|
|
237
|
+
var r = this.__data__, i = R(r, t);
|
|
238
|
+
return i < 0 ? (++this.size, r.push([t, e])) : r[i][1] = e, this;
|
|
239
|
+
}
|
|
240
|
+
function E(t) {
|
|
241
|
+
var e = -1, r = t == null ? 0 : t.length;
|
|
242
|
+
for (this.clear(); ++e < r; ) {
|
|
243
|
+
var i = t[e];
|
|
244
|
+
this.set(i[0], i[1]);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
E.prototype.clear = ie;
|
|
248
|
+
E.prototype.delete = oe;
|
|
249
|
+
E.prototype.get = ce;
|
|
250
|
+
E.prototype.has = he;
|
|
251
|
+
E.prototype.set = ue;
|
|
252
|
+
var fe = ot(W, "Map");
|
|
253
|
+
function le() {
|
|
254
|
+
this.size = 0, this.__data__ = {
|
|
255
|
+
hash: new A(),
|
|
256
|
+
map: new (fe || E)(),
|
|
257
|
+
string: new A()
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function pe(t) {
|
|
261
|
+
var e = typeof t;
|
|
262
|
+
return e == "string" || e == "number" || e == "symbol" || e == "boolean" ? t !== "__proto__" : t === null;
|
|
263
|
+
}
|
|
264
|
+
function G(t, e) {
|
|
265
|
+
var r = t.__data__;
|
|
266
|
+
return pe(e) ? r[typeof e == "string" ? "string" : "hash"] : r.map;
|
|
267
|
+
}
|
|
268
|
+
function de(t) {
|
|
269
|
+
var e = G(this, t).delete(t);
|
|
270
|
+
return this.size -= e ? 1 : 0, e;
|
|
271
|
+
}
|
|
272
|
+
function ye(t) {
|
|
273
|
+
return G(this, t).get(t);
|
|
274
|
+
}
|
|
275
|
+
function ge(t) {
|
|
276
|
+
return G(this, t).has(t);
|
|
277
|
+
}
|
|
278
|
+
function _e(t, e) {
|
|
279
|
+
var r = G(this, t), i = r.size;
|
|
280
|
+
return r.set(t, e), this.size += r.size == i ? 0 : 1, this;
|
|
281
|
+
}
|
|
282
|
+
function k(t) {
|
|
283
|
+
var e = -1, r = t == null ? 0 : t.length;
|
|
284
|
+
for (this.clear(); ++e < r; ) {
|
|
285
|
+
var i = t[e];
|
|
286
|
+
this.set(i[0], i[1]);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
k.prototype.clear = le;
|
|
290
|
+
k.prototype.delete = de;
|
|
291
|
+
k.prototype.get = ye;
|
|
292
|
+
k.prototype.has = ge;
|
|
293
|
+
k.prototype.set = _e;
|
|
294
|
+
var be = "Expected a function";
|
|
295
|
+
function X(t, e) {
|
|
296
|
+
if (typeof t != "function" || e != null && typeof e != "function")
|
|
297
|
+
throw new TypeError(be);
|
|
298
|
+
var r = function() {
|
|
299
|
+
var i = arguments, a = e ? e.apply(this, i) : i[0], n = r.cache;
|
|
300
|
+
if (n.has(a))
|
|
301
|
+
return n.get(a);
|
|
302
|
+
var g = t.apply(this, i);
|
|
303
|
+
return r.cache = n.set(a, g) || n, g;
|
|
304
|
+
};
|
|
305
|
+
return r.cache = new (X.Cache || k)(), r;
|
|
306
|
+
}
|
|
307
|
+
X.Cache = k;
|
|
308
|
+
var we = 500;
|
|
309
|
+
function Ce(t) {
|
|
310
|
+
var e = X(t, function(i) {
|
|
311
|
+
return r.size === we && r.clear(), i;
|
|
312
|
+
}), r = e.cache;
|
|
313
|
+
return e;
|
|
314
|
+
}
|
|
315
|
+
var Se = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, me = /\\(\\)?/g, Te = Ce(function(t) {
|
|
316
|
+
var e = [];
|
|
317
|
+
return t.charCodeAt(0) === 46 && e.push(""), t.replace(Se, function(r, i, a, n) {
|
|
318
|
+
e.push(a ? n.replace(me, "$1") : i || r);
|
|
319
|
+
}), e;
|
|
320
|
+
});
|
|
321
|
+
function ve(t) {
|
|
322
|
+
return t == null ? "" : at(t);
|
|
323
|
+
}
|
|
324
|
+
function je(t, e) {
|
|
325
|
+
return V(t) ? t : qt(t, e) ? [t] : Te(ve(t));
|
|
326
|
+
}
|
|
327
|
+
var Oe = 1 / 0;
|
|
328
|
+
function ze(t) {
|
|
329
|
+
if (typeof t == "string" || J(t))
|
|
330
|
+
return t;
|
|
331
|
+
var e = t + "";
|
|
332
|
+
return e == "0" && 1 / t == -Oe ? "-0" : e;
|
|
333
|
+
}
|
|
334
|
+
function $e(t, e) {
|
|
335
|
+
e = je(e, t);
|
|
336
|
+
for (var r = 0, i = e.length; t != null && r < i; )
|
|
337
|
+
t = t[ze(e[r++])];
|
|
338
|
+
return r && r == i ? t : void 0;
|
|
339
|
+
}
|
|
340
|
+
function Ae(t, e, r) {
|
|
341
|
+
var i = t == null ? void 0 : $e(t, e);
|
|
342
|
+
return i === void 0 ? r : i;
|
|
343
|
+
}
|
|
344
|
+
const ke = (t) => it(t) && !!Ae(t, "speckle_type");
|
|
345
|
+
var z, D, $, L, I, U, H, q, M, ct;
|
|
346
|
+
class Pe {
|
|
347
|
+
constructor(e, r = 1e3, i = B) {
|
|
348
|
+
P(this, z);
|
|
349
|
+
P(this, $);
|
|
350
|
+
P(this, I);
|
|
351
|
+
P(this, H);
|
|
352
|
+
P(this, M);
|
|
353
|
+
u(this, "chunkSize");
|
|
354
|
+
u(this, "detachLineage");
|
|
355
|
+
u(this, "lineage");
|
|
356
|
+
u(this, "familyTree");
|
|
357
|
+
u(this, "closureTable");
|
|
358
|
+
u(this, "transport");
|
|
359
|
+
u(this, "uniqueId");
|
|
360
|
+
u(this, "hashingFunction");
|
|
361
|
+
this.chunkSize = r, this.detachLineage = [!0], this.lineage = [], this.familyTree = {}, this.closureTable = {}, this.transport = e, this.uniqueId = 0, this.hashingFunction = i || B;
|
|
362
|
+
}
|
|
363
|
+
async write(e) {
|
|
364
|
+
return await y(this, z, D).call(this, e, !0);
|
|
365
|
+
}
|
|
366
|
+
dispose() {
|
|
367
|
+
this.detachLineage = [], this.lineage = [], this.familyTree = {}, this.closureTable = {}, this.transport = null;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
z = new WeakSet(), D = async function(e, r) {
|
|
371
|
+
const i = `${this.uniqueId++}-obj`;
|
|
372
|
+
this.lineage.push(i);
|
|
373
|
+
const a = { speckle_type: e.speckle_type || "Base" };
|
|
374
|
+
for (const h in e) {
|
|
375
|
+
const f = e[h];
|
|
376
|
+
if (!f || h === "id" || h.startsWith("_"))
|
|
377
|
+
continue;
|
|
378
|
+
if (typeof f != "object") {
|
|
379
|
+
a[h] = f;
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
const S = h.startsWith("@"), l = Array.isArray(f), s = l ? h.match(/^@\((\d*)\)/) : !1;
|
|
383
|
+
if (l && s && f.length !== 0 && typeof f[0] != "object") {
|
|
384
|
+
const o = s[1] !== "" ? parseInt(s[1]) : this.chunkSize, c = [];
|
|
385
|
+
let d = new et(), b = 0;
|
|
386
|
+
for (const w of f)
|
|
387
|
+
b === o && (c.push(await y(this, H, q).call(this, d)), d = new et(), b = 0), d.data.push(w), b++;
|
|
388
|
+
d.data.length !== 0 && c.push(await y(this, H, q).call(this, d)), a[h.replace(s[0], "")] = c;
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (f.speckle_type) {
|
|
392
|
+
const o = await y(this, $, L).call(this, {
|
|
393
|
+
value: f,
|
|
394
|
+
isDetached: S
|
|
395
|
+
});
|
|
396
|
+
a[h] = S ? y(this, I, U).call(this, o.id) : o;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
a[h] = await y(this, $, L).call(this, {
|
|
400
|
+
value: f,
|
|
401
|
+
isDetached: S
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
const n = this.detachLineage.pop(), g = this.lineage.pop();
|
|
405
|
+
if (this.familyTree[g]) {
|
|
406
|
+
const h = {};
|
|
407
|
+
Object.entries(this.familyTree[g]).forEach(([f, S]) => {
|
|
408
|
+
h[f] = S - this.detachLineage.length;
|
|
409
|
+
}), a.totalChildrenCount = Object.keys(h).length, a.totalChildrenCount && (a.__closure = h);
|
|
410
|
+
}
|
|
411
|
+
const { hash: p, serializedObject: m, size: j } = y(this, M, ct).call(this, a);
|
|
412
|
+
return a.id = p, (n || r) && this.transport && await this.transport.write(m, j), r && this.transport && await this.transport.flush(), { hash: p, traversed: a };
|
|
413
|
+
}, $ = new WeakSet(), L = async function({
|
|
414
|
+
value: e,
|
|
415
|
+
isDetached: r = !1
|
|
416
|
+
}) {
|
|
417
|
+
if (typeof e != "object")
|
|
418
|
+
return e;
|
|
419
|
+
if (Array.isArray(e)) {
|
|
420
|
+
const i = e;
|
|
421
|
+
if (i.length === 0)
|
|
422
|
+
return e;
|
|
423
|
+
if (typeof i[0] != "object")
|
|
424
|
+
return i;
|
|
425
|
+
if (!r)
|
|
426
|
+
return Promise.all(
|
|
427
|
+
e.map(async (n) => await y(this, $, L).call(this, { value: n }))
|
|
428
|
+
);
|
|
429
|
+
const a = [];
|
|
430
|
+
for (const n of e)
|
|
431
|
+
if (ke(n)) {
|
|
432
|
+
this.detachLineage.push(r);
|
|
433
|
+
const { hash: g } = await y(this, z, D).call(this, n, !1);
|
|
434
|
+
a.push(y(this, I, U).call(this, g));
|
|
435
|
+
} else
|
|
436
|
+
a.push(await y(this, $, L).call(this, { value: n, isDetached: r }));
|
|
437
|
+
return a;
|
|
438
|
+
}
|
|
439
|
+
if (!e.speckle_type)
|
|
440
|
+
return e;
|
|
441
|
+
if (e.speckle_type)
|
|
442
|
+
return this.detachLineage.push(r), (await y(this, z, D).call(this, e, !1)).traversed;
|
|
443
|
+
throw new Error(`Unsupported type '${typeof e}': ${e}.`);
|
|
444
|
+
}, I = new WeakSet(), U = function(e) {
|
|
445
|
+
return this.lineage.forEach((r) => {
|
|
446
|
+
this.familyTree[r] || (this.familyTree[r] = {}), (!this.familyTree[r][e] || this.familyTree[r][e] > this.detachLineage.length) && (this.familyTree[r][e] = this.detachLineage.length);
|
|
447
|
+
}), {
|
|
448
|
+
referencedId: e,
|
|
449
|
+
speckle_type: "reference"
|
|
450
|
+
};
|
|
451
|
+
}, H = new WeakSet(), q = async function(e) {
|
|
452
|
+
this.detachLineage.push(!0);
|
|
453
|
+
const { hash: r } = await y(this, z, D).call(this, e, !1);
|
|
454
|
+
return y(this, I, U).call(this, r);
|
|
455
|
+
}, M = new WeakSet(), ct = function(e) {
|
|
456
|
+
const r = JSON.stringify(e), i = this.hashingFunction(r), a = r.substring(0, 1) + `"id":"${i}",` + r.substring(1);
|
|
457
|
+
return {
|
|
458
|
+
hash: B(r),
|
|
459
|
+
serializedObject: a,
|
|
460
|
+
size: r.length
|
|
461
|
+
// approx, good enough as we're just limiting artificially batch sizes based on this
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
class et {
|
|
465
|
+
constructor() {
|
|
466
|
+
u(this, "speckle_type");
|
|
467
|
+
u(this, "data");
|
|
468
|
+
this.data = [], this.speckle_type = "Speckle.Core.Models.DataChunk";
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
class Ie {
|
|
472
|
+
constructor(e, r, i, a = 2e5) {
|
|
473
|
+
u(this, "buffer");
|
|
474
|
+
u(this, "maxSize");
|
|
475
|
+
u(this, "currSize");
|
|
476
|
+
u(this, "serverUrl");
|
|
477
|
+
u(this, "projectId");
|
|
478
|
+
u(this, "authToken");
|
|
479
|
+
this.maxSize = a, this.currSize = 0, this.serverUrl = e, this.projectId = r, this.authToken = i, this.buffer = [];
|
|
480
|
+
}
|
|
481
|
+
async write(e, r) {
|
|
482
|
+
this.buffer.push(e), this.currSize += r, !(this.currSize < this.maxSize) && await this.flush();
|
|
483
|
+
}
|
|
484
|
+
async flush() {
|
|
485
|
+
if (this.buffer.length === 0)
|
|
486
|
+
return;
|
|
487
|
+
const e = new FormData(), r = "[" + this.buffer.join(",") + "]";
|
|
488
|
+
e.append("object-batch", new Blob([r], { type: "application/json" }));
|
|
489
|
+
const i = new URL(`/objects/${this.projectId}`, this.serverUrl), a = await fetch(i, {
|
|
490
|
+
method: "POST",
|
|
491
|
+
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
492
|
+
body: e
|
|
493
|
+
});
|
|
494
|
+
if (a.status !== 201)
|
|
495
|
+
throw new Error(
|
|
496
|
+
`Unexpected error when sending data. Expected status 200, got ${a.status}`
|
|
497
|
+
);
|
|
498
|
+
this.buffer = [], this.currSize = 0;
|
|
499
|
+
}
|
|
500
|
+
dispose() {
|
|
501
|
+
this.buffer = [];
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
class Fe {
|
|
505
|
+
constructor(e) {
|
|
506
|
+
u(this, "speckle_type");
|
|
507
|
+
if (this.speckle_type = this.constructor.name, e)
|
|
508
|
+
for (const r in e)
|
|
509
|
+
this[r] = e[r];
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
const De = async (t, {
|
|
513
|
+
serverUrl: e = "https://app.speckle.systems",
|
|
514
|
+
projectId: r,
|
|
515
|
+
token: i,
|
|
516
|
+
logger: a = console
|
|
517
|
+
}) => {
|
|
518
|
+
const n = performance.now();
|
|
519
|
+
a == null || a.log("Starting to send");
|
|
520
|
+
const g = new Ie(e, r, i), p = new Pe(g);
|
|
521
|
+
let m;
|
|
522
|
+
try {
|
|
523
|
+
m = await p.write(t);
|
|
524
|
+
} finally {
|
|
525
|
+
g.dispose(), p.dispose();
|
|
526
|
+
}
|
|
527
|
+
const j = performance.now();
|
|
528
|
+
return a.log(`Finished sending in ${(j - n) / 1e3}s.`), m;
|
|
529
|
+
};
|
|
530
|
+
export {
|
|
531
|
+
Fe as Base,
|
|
532
|
+
De as send
|
|
533
|
+
};
|
|
534
|
+
//# sourceMappingURL=objectsender.js.map
|