@speckle/objectsender 2.23.8 → 2.23.9
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/index.d.ts +7 -1
- package/dist/objectsender.cjs +2 -2
- package/dist/objectsender.cjs.map +1 -1
- package/dist/objectsender.js +69 -64
- package/dist/objectsender.js.map +1 -1
- package/dist/transports/ServerTransport.d.ts +6 -5
- package/package.json +2 -2
- package/src/index.ts +14 -3
- package/src/transports/ServerTransport.ts +7 -5
- package/src/utils/Serializer.ts +1 -0
package/dist/objectsender.js
CHANGED
|
@@ -4,36 +4,36 @@ var it = (t) => {
|
|
|
4
4
|
};
|
|
5
5
|
var Ct = (t, e, r) => e in t ? mt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
6
6
|
var S = (t, e, r) => Ct(t, typeof e != "symbol" ? e + "" : e, r), X = (t, e, r) => e.has(t) || it("Cannot " + r);
|
|
7
|
-
var T = (t, e, r) => (X(t, e, "read from private field"), r ? r.call(t) : e.get(t)), j = (t, e, r) => e.has(t) ? it("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r),
|
|
7
|
+
var T = (t, e, r) => (X(t, e, "read from private field"), r ? r.call(t) : e.get(t)), j = (t, e, r) => e.has(t) ? it("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), _ = (t, e, r, a) => (X(t, e, "write to private field"), a ? a.call(t, r) : e.set(t, r), r), y = (t, e, r) => (X(t, e, "access private method"), r);
|
|
8
8
|
import "reflect-metadata";
|
|
9
9
|
import { retry as wt, timeoutAt as St } from "@speckle/shared";
|
|
10
10
|
function Y(t) {
|
|
11
|
-
function e(
|
|
12
|
-
return
|
|
11
|
+
function e(z, g) {
|
|
12
|
+
return z << g | z >>> 32 - g;
|
|
13
13
|
}
|
|
14
|
-
function r(
|
|
15
|
-
let
|
|
16
|
-
for (
|
|
17
|
-
w =
|
|
18
|
-
return
|
|
14
|
+
function r(z) {
|
|
15
|
+
let g = "", A, w;
|
|
16
|
+
for (A = 7; A >= 0; A--)
|
|
17
|
+
w = z >>> A * 4 & 15, g += w.toString(16);
|
|
18
|
+
return g;
|
|
19
19
|
}
|
|
20
|
-
function a(
|
|
21
|
-
|
|
20
|
+
function a(z) {
|
|
21
|
+
z = z.replace(/\r\n/g, `
|
|
22
22
|
`);
|
|
23
|
-
let
|
|
24
|
-
for (let
|
|
25
|
-
const w =
|
|
26
|
-
w < 128 ?
|
|
23
|
+
let g = "";
|
|
24
|
+
for (let A = 0; A < z.length; A++) {
|
|
25
|
+
const w = z.charCodeAt(A);
|
|
26
|
+
w < 128 ? g += String.fromCharCode(w) : w > 127 && w < 2048 ? (g += String.fromCharCode(w >> 6 | 192), g += String.fromCharCode(w & 63 | 128)) : (g += String.fromCharCode(w >> 12 | 224), g += String.fromCharCode(w >> 6 & 63 | 128), g += String.fromCharCode(w & 63 | 128));
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return g;
|
|
29
29
|
}
|
|
30
|
-
let i, n,
|
|
30
|
+
let i, n, b;
|
|
31
31
|
const d = new Array(80);
|
|
32
|
-
let O = 1732584193,
|
|
32
|
+
let O = 1732584193, k = 4023233417, s = 2562383102, l = 271733878, v = 3285377520, f, o, c, u, p, m;
|
|
33
33
|
t = a(t);
|
|
34
34
|
const C = t.length, P = [];
|
|
35
35
|
for (n = 0; n < C - 3; n += 4)
|
|
36
|
-
|
|
36
|
+
b = t.charCodeAt(n) << 24 | t.charCodeAt(n + 1) << 16 | t.charCodeAt(n + 2) << 8 | t.charCodeAt(n + 3), P.push(b);
|
|
37
37
|
switch (C % 4) {
|
|
38
38
|
case 0:
|
|
39
39
|
n = 2147483648;
|
|
@@ -53,17 +53,17 @@ function Y(t) {
|
|
|
53
53
|
for (n = 0; n < 16; n++) d[n] = P[i + n];
|
|
54
54
|
for (n = 16; n <= 79; n++)
|
|
55
55
|
d[n] = e(d[n - 3] ^ d[n - 8] ^ d[n - 14] ^ d[n - 16], 1);
|
|
56
|
-
for (f = O,
|
|
57
|
-
m = e(f, 5) + (
|
|
56
|
+
for (f = O, o = k, c = s, u = l, p = v, n = 0; n <= 19; n++)
|
|
57
|
+
m = e(f, 5) + (o & c | ~o & u) + p + d[n] + 1518500249 & 4294967295, p = u, u = c, c = e(o, 30), o = f, f = m;
|
|
58
58
|
for (n = 20; n <= 39; n++)
|
|
59
|
-
m = e(f, 5) + (
|
|
59
|
+
m = e(f, 5) + (o ^ c ^ u) + p + d[n] + 1859775393 & 4294967295, p = u, u = c, c = e(o, 30), o = f, f = m;
|
|
60
60
|
for (n = 40; n <= 59; n++)
|
|
61
|
-
m = e(f, 5) + (
|
|
61
|
+
m = e(f, 5) + (o & c | o & u | c & u) + p + d[n] + 2400959708 & 4294967295, p = u, u = c, c = e(o, 30), o = f, f = m;
|
|
62
62
|
for (n = 60; n <= 79; n++)
|
|
63
|
-
m = e(f, 5) + (
|
|
64
|
-
O = O + f & 4294967295,
|
|
63
|
+
m = e(f, 5) + (o ^ c ^ u) + p + d[n] + 3395469782 & 4294967295, p = u, u = c, c = e(o, 30), o = f, f = m;
|
|
64
|
+
O = O + f & 4294967295, k = k + o & 4294967295, s = s + c & 4294967295, l = l + u & 4294967295, v = v + p & 4294967295;
|
|
65
65
|
}
|
|
66
|
-
return (r(O) + r(
|
|
66
|
+
return (r(O) + r(k) + r(s) + r(l) + r(v)).toLowerCase().substring(0, 40);
|
|
67
67
|
}
|
|
68
68
|
var Tt = typeof global == "object" && global && global.Object === Object && global, vt = typeof self == "object" && self && self.Object === Object && self, tt = Tt || vt || Function("return this")(), D = tt.Symbol, lt = Object.prototype, jt = lt.hasOwnProperty, Ot = lt.toString, R = D ? D.toStringTag : void 0;
|
|
69
69
|
function kt(t) {
|
|
@@ -294,8 +294,8 @@ function nt(t, e) {
|
|
|
294
294
|
var a = arguments, i = e ? e.apply(this, a) : a[0], n = r.cache;
|
|
295
295
|
if (n.has(i))
|
|
296
296
|
return n.get(i);
|
|
297
|
-
var
|
|
298
|
-
return r.cache = n.set(i,
|
|
297
|
+
var b = t.apply(this, a);
|
|
298
|
+
return r.cache = n.set(i, b) || n, b;
|
|
299
299
|
};
|
|
300
300
|
return r.cache = new (nt.Cache || E)(), r;
|
|
301
301
|
}
|
|
@@ -378,22 +378,22 @@ h = new WeakSet(), L = async function(e, r) {
|
|
|
378
378
|
const a = `${this.uniqueId++}-obj`;
|
|
379
379
|
this.lineage.push(a);
|
|
380
380
|
const i = { speckle_type: e.speckle_type || "Base" };
|
|
381
|
-
for (const
|
|
382
|
-
const l = e[
|
|
383
|
-
if (l === void 0 ||
|
|
381
|
+
for (const s in e) {
|
|
382
|
+
const l = e[s];
|
|
383
|
+
if (l === void 0 || s === "id" || s.startsWith("_")) continue;
|
|
384
384
|
if (typeof l != "object") {
|
|
385
|
-
i[
|
|
385
|
+
i[s] = l;
|
|
386
386
|
continue;
|
|
387
387
|
}
|
|
388
|
-
const v =
|
|
389
|
-
if (f &&
|
|
388
|
+
const v = s.startsWith("@") || He(e, s), f = Array.isArray(l), o = f ? Ue(e, s) || s.match(/^@\((\d*)\)/) : !1;
|
|
389
|
+
if (f && o && l.length !== 0 && typeof l[0] != "object") {
|
|
390
390
|
let c = this.chunkSize;
|
|
391
|
-
typeof
|
|
391
|
+
typeof o == "boolean" ? c = Ge(e, s) : c = o[1] !== "" ? parseInt(o[1]) : this.chunkSize;
|
|
392
392
|
const u = [];
|
|
393
393
|
let p = new ut(), m = 0;
|
|
394
394
|
for (const C of l)
|
|
395
395
|
m === c && (u.push(await y(this, h, Q).call(this, p)), p = new ut(), m = 0), p.data.push(C), m++;
|
|
396
|
-
p.data.length !== 0 && u.push(await y(this, h, Q).call(this, p)), typeof
|
|
396
|
+
p.data.length !== 0 && u.push(await y(this, h, Q).call(this, p)), typeof o == "boolean" ? i[s] = u : i[s.replace(o[0], "")] = u;
|
|
397
397
|
continue;
|
|
398
398
|
}
|
|
399
399
|
if (l.speckle_type) {
|
|
@@ -401,23 +401,23 @@ h = new WeakSet(), L = async function(e, r) {
|
|
|
401
401
|
value: l,
|
|
402
402
|
isDetached: v
|
|
403
403
|
});
|
|
404
|
-
i[
|
|
404
|
+
i[s] = v ? y(this, h, W).call(this, c.id) : c;
|
|
405
405
|
continue;
|
|
406
406
|
}
|
|
407
|
-
i[
|
|
407
|
+
i[s] = await y(this, h, M).call(this, {
|
|
408
408
|
value: l,
|
|
409
409
|
isDetached: v
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
|
-
const n = this.detachLineage.pop(),
|
|
413
|
-
if (this.familyTree[
|
|
414
|
-
const
|
|
415
|
-
Object.entries(this.familyTree[
|
|
416
|
-
|
|
417
|
-
}), i.totalChildrenCount = Object.keys(
|
|
412
|
+
const n = this.detachLineage.pop(), b = this.lineage.pop();
|
|
413
|
+
if (this.familyTree[b]) {
|
|
414
|
+
const s = {};
|
|
415
|
+
Object.entries(this.familyTree[b]).forEach(([l, v]) => {
|
|
416
|
+
s[l] = v - this.detachLineage.length;
|
|
417
|
+
}), i.totalChildrenCount = Object.keys(s).length, i.totalChildrenCount && (i.__closure = s);
|
|
418
418
|
}
|
|
419
|
-
const { hash: d, serializedObject: O, size:
|
|
420
|
-
return i.id = d, (n || r) && this.transport && await this.transport.write(O,
|
|
419
|
+
const { hash: d, serializedObject: O, size: k } = y(this, h, bt).call(this, i);
|
|
420
|
+
return i.id = d, (n || r) && this.transport && await this.transport.write(O, k), r && this.transport && await this.transport.flush(), { hash: d, traversed: i };
|
|
421
421
|
}, M = async function({
|
|
422
422
|
value: e,
|
|
423
423
|
isDetached: r = !1
|
|
@@ -435,8 +435,8 @@ h = new WeakSet(), L = async function(e, r) {
|
|
|
435
435
|
for (const n of e)
|
|
436
436
|
if (Ke(n)) {
|
|
437
437
|
this.detachLineage.push(r);
|
|
438
|
-
const { hash:
|
|
439
|
-
i.push(y(this, h, W).call(this,
|
|
438
|
+
const { hash: b } = await y(this, h, L).call(this, n, !1);
|
|
439
|
+
i.push(y(this, h, W).call(this, b));
|
|
440
440
|
} else
|
|
441
441
|
i.push(await y(this, h, M).call(this, { value: n, isDetached: r }));
|
|
442
442
|
return i;
|
|
@@ -472,10 +472,10 @@ class ut {
|
|
|
472
472
|
this.data = [], this.speckle_type = "Speckle.Core.Models.DataChunk";
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
|
-
var
|
|
475
|
+
var $, H, I, U, G, K, B, q;
|
|
476
476
|
class qe {
|
|
477
477
|
constructor(e, r, a, i) {
|
|
478
|
-
j(this,
|
|
478
|
+
j(this, $);
|
|
479
479
|
j(this, H);
|
|
480
480
|
j(this, I);
|
|
481
481
|
j(this, U);
|
|
@@ -483,14 +483,14 @@ class qe {
|
|
|
483
483
|
j(this, K);
|
|
484
484
|
j(this, B);
|
|
485
485
|
j(this, q);
|
|
486
|
-
|
|
486
|
+
_(this, H, (i == null ? void 0 : i.maxSize) || 2e5), _(this, B, (i == null ? void 0 : i.flushRetryCount) || 3), _(this, q, (i == null ? void 0 : i.flushTimeout) || 2 * 60 * 1e3), _(this, I, 0), _(this, U, e), _(this, G, r), _(this, K, a), _(this, $, []);
|
|
487
487
|
}
|
|
488
488
|
async write(e, r) {
|
|
489
|
-
T(this,
|
|
489
|
+
T(this, $).push(e), _(this, I, T(this, I) + r), !(T(this, I) < T(this, H)) && await this.flush();
|
|
490
490
|
}
|
|
491
491
|
async flush() {
|
|
492
|
-
if (T(this,
|
|
493
|
-
const e = new FormData(), r = "[" + T(this,
|
|
492
|
+
if (T(this, $).length === 0) return;
|
|
493
|
+
const e = new FormData(), r = "[" + T(this, $).join(",") + "]";
|
|
494
494
|
e.append("object-batch", new Blob([r], { type: "application/json" }));
|
|
495
495
|
const a = new URL(`/objects/${T(this, G)}`, T(this, U)), i = await wt(
|
|
496
496
|
async () => await Promise.race([
|
|
@@ -508,13 +508,13 @@ class qe {
|
|
|
508
508
|
throw new Error(
|
|
509
509
|
`Unexpected error when sending data. Expected status 200, got ${i.status}`
|
|
510
510
|
);
|
|
511
|
-
|
|
511
|
+
_(this, $, []), _(this, I, 0);
|
|
512
512
|
}
|
|
513
513
|
dispose() {
|
|
514
|
-
|
|
514
|
+
_(this, $, []);
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
-
|
|
517
|
+
$ = new WeakMap(), H = new WeakMap(), I = new WeakMap(), U = new WeakMap(), G = new WeakMap(), K = new WeakMap(), B = new WeakMap(), q = new WeakMap();
|
|
518
518
|
class Qe {
|
|
519
519
|
constructor(e) {
|
|
520
520
|
S(this, "speckle_type");
|
|
@@ -526,19 +526,24 @@ const tr = async (t, {
|
|
|
526
526
|
serverUrl: e = "https://app.speckle.systems",
|
|
527
527
|
projectId: r,
|
|
528
528
|
token: a,
|
|
529
|
-
logger: i = console
|
|
529
|
+
logger: i = console,
|
|
530
|
+
options: n = void 0
|
|
530
531
|
}) => {
|
|
531
|
-
const
|
|
532
|
+
const b = performance.now();
|
|
532
533
|
i == null || i.log("Starting to send");
|
|
533
|
-
const
|
|
534
|
-
|
|
534
|
+
const d = new qe(e, r, a, n == null ? void 0 : n.transport), O = new Be(
|
|
535
|
+
d,
|
|
536
|
+
n == null ? void 0 : n.chunkSize,
|
|
537
|
+
n == null ? void 0 : n.hashingFunction
|
|
538
|
+
);
|
|
539
|
+
let k;
|
|
535
540
|
try {
|
|
536
|
-
|
|
541
|
+
k = await O.write(t);
|
|
537
542
|
} finally {
|
|
538
|
-
|
|
543
|
+
d.dispose(), O.dispose();
|
|
539
544
|
}
|
|
540
|
-
const
|
|
541
|
-
return i.log(`Finished sending in ${(
|
|
545
|
+
const s = performance.now();
|
|
546
|
+
return i.log(`Finished sending in ${(s - b) / 1e3}s.`), k;
|
|
542
547
|
};
|
|
543
548
|
export {
|
|
544
549
|
Qe as Base,
|