@fileverse-dev/dsheet 4.1.13-a → 4.1.13-b
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-C2bF_Npd.js → index-7Fa_Mod8.js} +1913 -1910
- package/dist/index.es.js +1 -1
- package/dist/persistence-compaction-CIxc1USC.js +123 -0
- package/dist/persistence-compaction.d.ts +15 -0
- package/dist/persistence.js +57 -51
- package/dist/{use-xlsx-import-impl-DSYOyk4c.js → use-xlsx-import-impl-Br6nyaAS.js} +3 -3
- package/dist/{xlsx-defined-names-AmoE3FGc.js → xlsx-defined-names-CUwiqOuM.js} +1 -1
- package/dist/{xlsx-export-impl-Buo3mgXM.js → xlsx-export-impl-CYyAFJGw.js} +3 -3
- package/dist/{xlsx-hyperlink-inline-BqwlPUEK.js → xlsx-hyperlink-inline-CKQmxa8u.js} +1 -1
- package/package.json +1 -1
- package/dist/persistence-utils-BXFajzvq.js +0 -98
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as s, d as o, f as t, S as r, g as l, h as n, j as d, T as S, k as c, l as i, n as m, o as h, p, q as C, t as u, u as E, v as F, w as g, x, z as R, A, B as f, D as I, E as L, F as T, G as w, H as y, I as v, J as D, K as M, L as b, M as k, N as z, O, P } from "./index-
|
|
1
|
+
import { C as s, d as o, f as t, S as r, g as l, h as n, j as d, T as S, k as c, l as i, n as m, o as h, p, q as C, t as u, u as E, v as F, w as g, x, z as R, A, B as f, D as I, E as L, F as T, G as w, H as y, I as v, J as D, K as M, L as b, M as k, N as z, O, P } from "./index-7Fa_Mod8.js";
|
|
2
2
|
import { cy as G, cz as K, cA as U, cG as X, bs as _, e as j, f as B, l as H, a as J, dj as N, dk as q, bb as Y, dl as Z, dm as Q, dr as W, ds as $, du as ee, I as ae, dJ as se, eg as oe, b4 as te } from "./executeStringFunction-D1IXrBP2.js";
|
|
3
3
|
import { FLVURL as le } from "@fileverse-dev/formulajs";
|
|
4
4
|
import { E as de, S as Se } from "./constants-8Ij49Lxv.js";
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as i from "yjs";
|
|
2
|
+
const p = typeof Buffer == "function";
|
|
3
|
+
typeof TextDecoder == "function" && new TextDecoder();
|
|
4
|
+
typeof TextEncoder == "function" && new TextEncoder();
|
|
5
|
+
const C = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", l = Array.prototype.slice.call(C), u = ((t) => {
|
|
6
|
+
let e = {};
|
|
7
|
+
return t.forEach((r, o) => e[r] = o), e;
|
|
8
|
+
})(l), x = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/, d = String.fromCharCode.bind(String), b = typeof Uint8Array.from == "function" ? Uint8Array.from.bind(Uint8Array) : (t) => new Uint8Array(Array.prototype.slice.call(t, 0)), B = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (e) => e == "+" ? "-" : "_"), E = (t) => t.replace(/[^A-Za-z0-9\+\/]/g, ""), P = (t) => {
|
|
9
|
+
let e, r, o, n, a = "";
|
|
10
|
+
const s = t.length % 3;
|
|
11
|
+
for (let c = 0; c < t.length; ) {
|
|
12
|
+
if ((r = t.charCodeAt(c++)) > 255 || (o = t.charCodeAt(c++)) > 255 || (n = t.charCodeAt(c++)) > 255)
|
|
13
|
+
throw new TypeError("invalid character found");
|
|
14
|
+
e = r << 16 | o << 8 | n, a += l[e >> 18 & 63] + l[e >> 12 & 63] + l[e >> 6 & 63] + l[e & 63];
|
|
15
|
+
}
|
|
16
|
+
return s ? a.slice(0, s - 3) + "===".substring(s) : a;
|
|
17
|
+
}, v = typeof btoa == "function" ? (t) => btoa(t) : p ? (t) => Buffer.from(t, "binary").toString("base64") : P, A = p ? (t) => Buffer.from(t).toString("base64") : (t) => {
|
|
18
|
+
let r = [];
|
|
19
|
+
for (let o = 0, n = t.length; o < n; o += 4096)
|
|
20
|
+
r.push(d.apply(null, t.subarray(o, o + 4096)));
|
|
21
|
+
return v(r.join(""));
|
|
22
|
+
}, S = (t, e = !1) => e ? B(A(t)) : A(t), R = (t) => {
|
|
23
|
+
if (t = t.replace(/\s+/g, ""), !x.test(t))
|
|
24
|
+
throw new TypeError("malformed base64.");
|
|
25
|
+
t += "==".slice(2 - (t.length & 3));
|
|
26
|
+
let e, r, o, n = [];
|
|
27
|
+
for (let a = 0; a < t.length; )
|
|
28
|
+
e = u[t.charAt(a++)] << 18 | u[t.charAt(a++)] << 12 | (r = u[t.charAt(a++)]) << 6 | (o = u[t.charAt(a++)]), r === 64 ? n.push(d(e >> 16 & 255)) : o === 64 ? n.push(d(e >> 16 & 255, e >> 8 & 255)) : n.push(d(e >> 16 & 255, e >> 8 & 255, e & 255));
|
|
29
|
+
return n.join("");
|
|
30
|
+
}, k = typeof atob == "function" ? (t) => atob(E(t)) : p ? (t) => Buffer.from(t, "base64").toString("binary") : R, z = p ? (t) => b(Buffer.from(t, "base64")) : (t) => b(k(t).split("").map((e) => e.charCodeAt(0))), I = (t) => z(Z(t)), Z = (t) => E(t.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), q = 8e3, j = (t) => t instanceof Error ? t : new Error(String(t)), K = (t, e, r = "dsheet-package-ingress") => {
|
|
31
|
+
const o = I(e), n = new i.Doc();
|
|
32
|
+
try {
|
|
33
|
+
i.applyUpdate(n, o);
|
|
34
|
+
} finally {
|
|
35
|
+
n.destroy();
|
|
36
|
+
}
|
|
37
|
+
let a = !1;
|
|
38
|
+
const s = () => {
|
|
39
|
+
a = !0;
|
|
40
|
+
};
|
|
41
|
+
t.on("update", s);
|
|
42
|
+
try {
|
|
43
|
+
return i.applyUpdate(t, o, r), a;
|
|
44
|
+
} finally {
|
|
45
|
+
t.off("update", s);
|
|
46
|
+
}
|
|
47
|
+
}, M = async (t, e) => {
|
|
48
|
+
let r;
|
|
49
|
+
try {
|
|
50
|
+
return await Promise.race([
|
|
51
|
+
t,
|
|
52
|
+
new Promise((o, n) => {
|
|
53
|
+
r = setTimeout(
|
|
54
|
+
() => n(new Error("dSheet IndexedDB operation timed out")),
|
|
55
|
+
e
|
|
56
|
+
);
|
|
57
|
+
})
|
|
58
|
+
]);
|
|
59
|
+
} finally {
|
|
60
|
+
r && clearTimeout(r);
|
|
61
|
+
}
|
|
62
|
+
}, w = (t, e, r) => ({
|
|
63
|
+
dsheetId: t,
|
|
64
|
+
status: e,
|
|
65
|
+
encodedState: null,
|
|
66
|
+
stateVector: null,
|
|
67
|
+
...r ? { error: j(r) } : {}
|
|
68
|
+
}), V = (t, e) => {
|
|
69
|
+
const r = i.encodeStateAsUpdate(e);
|
|
70
|
+
return {
|
|
71
|
+
dsheetId: t,
|
|
72
|
+
status: r.length <= 2 ? "empty" : "available",
|
|
73
|
+
encodedState: S(r),
|
|
74
|
+
stateVector: S(i.encodeStateVector(e))
|
|
75
|
+
};
|
|
76
|
+
}, N = (t, e, r) => {
|
|
77
|
+
if (!r)
|
|
78
|
+
return w(
|
|
79
|
+
t,
|
|
80
|
+
"unavailable",
|
|
81
|
+
new Error("dSheet document is not ready")
|
|
82
|
+
);
|
|
83
|
+
try {
|
|
84
|
+
return K(r, e, "dsheet-package-ingress"), V(t, r);
|
|
85
|
+
} catch (o) {
|
|
86
|
+
return w(t, "corrupt", o);
|
|
87
|
+
}
|
|
88
|
+
}, y = "updates", O = async (t, e = 2) => {
|
|
89
|
+
if (t._destroyed) return 0;
|
|
90
|
+
const r = await t._db;
|
|
91
|
+
if (!r.objectStoreNames.contains(y)) return 0;
|
|
92
|
+
const o = await new Promise((n, a) => {
|
|
93
|
+
const s = r.transaction(y, "readwrite"), c = s.objectStore(y);
|
|
94
|
+
let h = 0;
|
|
95
|
+
const m = c.getAllKeys();
|
|
96
|
+
m.onsuccess = () => {
|
|
97
|
+
const f = m.result;
|
|
98
|
+
if (f.length < e) return;
|
|
99
|
+
const g = c.getAll();
|
|
100
|
+
g.onsuccess = () => {
|
|
101
|
+
const U = g.result.filter(
|
|
102
|
+
(T) => T instanceof Uint8Array
|
|
103
|
+
), _ = i.mergeUpdates([
|
|
104
|
+
...U,
|
|
105
|
+
i.encodeStateAsUpdate(t.doc)
|
|
106
|
+
]), D = f[f.length - 1];
|
|
107
|
+
c.delete(IDBKeyRange.upperBound(D)), c.add(_), h = f.length;
|
|
108
|
+
};
|
|
109
|
+
}, s.oncomplete = () => n(h), s.onerror = () => a(s.error), s.onabort = () => a(s.error ?? new Error("compaction aborted"));
|
|
110
|
+
});
|
|
111
|
+
return o > 0 && (t._dbsize = 1), o;
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
q as D,
|
|
115
|
+
N as a,
|
|
116
|
+
O as c,
|
|
117
|
+
S as f,
|
|
118
|
+
K as m,
|
|
119
|
+
V as s,
|
|
120
|
+
I as t,
|
|
121
|
+
w as u,
|
|
122
|
+
M as w
|
|
123
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* y-indexeddb appends a FULL copy of the doc every time a provider is attached
|
|
5
|
+
* to a Y.Doc that already holds content, and only trims after 500 rows. dSheet
|
|
6
|
+
* attaches to pre-filled docs on every open (published content, remote merges),
|
|
7
|
+
* so the store grows by one full copy per open and every load replays them all.
|
|
8
|
+
*
|
|
9
|
+
* This collapses the store into a single row. It runs in ONE readwrite
|
|
10
|
+
* transaction and merges every stored row (not just this provider's doc), so
|
|
11
|
+
* rows written by another tab/provider in the meantime are never lost.
|
|
12
|
+
*
|
|
13
|
+
* Returns the number of rows removed (0 when nothing needed compacting).
|
|
14
|
+
*/
|
|
15
|
+
export declare const compactDsheetPersistence: (persistence: IndexeddbPersistence, minRows?: number) => Promise<number>;
|
package/dist/persistence.js
CHANGED
|
@@ -1,118 +1,124 @@
|
|
|
1
|
-
import { t as D, f as
|
|
1
|
+
import { t as D, f as g, D as b, u as p, w as S, c as v, s as w } from "./persistence-compaction-CIxc1USC.js";
|
|
2
2
|
import * as u from "yjs";
|
|
3
|
-
import { clearDocument as
|
|
4
|
-
const f = /* @__PURE__ */ new Map(),
|
|
5
|
-
const
|
|
3
|
+
import { clearDocument as x, IndexeddbPersistence as E } from "y-indexeddb";
|
|
4
|
+
const f = /* @__PURE__ */ new Map(), A = (e) => {
|
|
5
|
+
const a = new u.Doc();
|
|
6
6
|
try {
|
|
7
7
|
return u.applyUpdate(
|
|
8
|
-
|
|
8
|
+
a,
|
|
9
9
|
typeof e == "string" ? D(e) : e
|
|
10
|
-
),
|
|
10
|
+
), g(u.encodeStateVector(a));
|
|
11
11
|
} finally {
|
|
12
|
-
|
|
12
|
+
a.destroy();
|
|
13
13
|
}
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
let r = null, t = null,
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
},
|
|
14
|
+
}, B = (e, a) => new Promise((c) => {
|
|
15
|
+
const s = new u.Doc();
|
|
16
|
+
let r = null, t = null, o = !1, y = !1;
|
|
17
|
+
const m = (n) => {
|
|
18
|
+
o || (o = !0, clearTimeout(h), r == null || r.close(), s.destroy(), c(n));
|
|
19
|
+
}, i = (n, d) => m(p(e, n, d)), h = setTimeout(() => {
|
|
20
20
|
try {
|
|
21
21
|
t == null || t.abort();
|
|
22
22
|
} catch {
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
},
|
|
24
|
+
i("timed-out", new Error("dSheet IndexedDB read timed out"));
|
|
25
|
+
}, a);
|
|
26
26
|
let l;
|
|
27
27
|
try {
|
|
28
28
|
l = indexedDB.open(e);
|
|
29
29
|
} catch (n) {
|
|
30
|
-
|
|
30
|
+
i("unavailable", n);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
l.onupgradeneeded = () => {
|
|
34
34
|
var n;
|
|
35
|
-
|
|
35
|
+
y = !0, (n = l.transaction) == null || n.abort();
|
|
36
36
|
}, l.onerror = () => {
|
|
37
|
-
|
|
37
|
+
y ? m(p(e, "missing")) : i("unavailable", l.error);
|
|
38
38
|
}, l.onsuccess = () => {
|
|
39
39
|
if (r = l.result, !r.objectStoreNames.contains("updates") || !r.objectStoreNames.contains("custom")) {
|
|
40
|
-
|
|
40
|
+
i("corrupt", new Error("dSheet IndexedDB schema is invalid"));
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
try {
|
|
44
44
|
t = r.transaction("updates", "readonly");
|
|
45
45
|
const n = t.objectStore("updates").getAll();
|
|
46
|
-
n.onerror = () =>
|
|
46
|
+
n.onerror = () => i("unavailable", n.error), n.onsuccess = () => {
|
|
47
47
|
try {
|
|
48
48
|
for (const d of n.result ?? []) {
|
|
49
49
|
if (!(d instanceof Uint8Array))
|
|
50
50
|
throw new Error("dSheet IndexedDB contains a non-Yjs update");
|
|
51
|
-
u.applyUpdate(
|
|
51
|
+
u.applyUpdate(s, d);
|
|
52
52
|
}
|
|
53
53
|
} catch (d) {
|
|
54
|
-
|
|
54
|
+
i("corrupt", d);
|
|
55
55
|
}
|
|
56
|
-
}, t.oncomplete = () =>
|
|
57
|
-
|
|
56
|
+
}, t.oncomplete = () => m(w(e, s)), t.onabort = () => {
|
|
57
|
+
o || i("unavailable", t == null ? void 0 : t.error);
|
|
58
58
|
}, t.onerror = () => {
|
|
59
|
-
|
|
59
|
+
o || i("unavailable", t == null ? void 0 : t.error);
|
|
60
60
|
};
|
|
61
61
|
} catch (n) {
|
|
62
|
-
|
|
62
|
+
i("unavailable", n);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
}),
|
|
65
|
+
}), T = async (e, a) => {
|
|
66
66
|
if (typeof indexedDB > "u")
|
|
67
67
|
return p(
|
|
68
68
|
e,
|
|
69
69
|
"unavailable",
|
|
70
70
|
new Error("IndexedDB is unavailable")
|
|
71
71
|
);
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
72
|
+
const c = indexedDB;
|
|
73
|
+
if (c.databases)
|
|
74
74
|
try {
|
|
75
|
-
if (!(await
|
|
75
|
+
if (!(await c.databases()).some((r) => r.name === e))
|
|
76
76
|
return p(e, "missing");
|
|
77
77
|
} catch {
|
|
78
78
|
}
|
|
79
|
-
return
|
|
80
|
-
},
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
const
|
|
79
|
+
return B(e, a);
|
|
80
|
+
}, C = (e, a = {}) => {
|
|
81
|
+
const c = f.get(e);
|
|
82
|
+
if (c) return c;
|
|
83
|
+
const s = T(
|
|
84
84
|
e,
|
|
85
|
-
|
|
85
|
+
a.timeoutMs ?? b
|
|
86
86
|
).finally(() => {
|
|
87
|
-
f.get(e) ===
|
|
87
|
+
f.get(e) === s && f.delete(e);
|
|
88
88
|
});
|
|
89
|
-
return f.set(e,
|
|
90
|
-
},
|
|
91
|
-
const
|
|
89
|
+
return f.set(e, s), s;
|
|
90
|
+
}, P = async (e, a, c = {}) => {
|
|
91
|
+
const s = c.timeoutMs ?? b, r = new u.Doc();
|
|
92
92
|
try {
|
|
93
|
-
u.applyUpdate(r, D(
|
|
94
|
-
} catch (
|
|
95
|
-
return r.destroy(), p(e, "corrupt",
|
|
93
|
+
u.applyUpdate(r, D(a), "dsheet-package-ingress");
|
|
94
|
+
} catch (o) {
|
|
95
|
+
return r.destroy(), p(e, "corrupt", o);
|
|
96
96
|
}
|
|
97
97
|
let t = null;
|
|
98
98
|
try {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
t = new E(e, r), await S(t.whenSynced, s);
|
|
100
|
+
try {
|
|
101
|
+
await v(t);
|
|
102
|
+
} catch (o) {
|
|
103
|
+
console.warn("[DSheet] IndexedDB compaction failed:", o);
|
|
104
|
+
}
|
|
105
|
+
return w(e, r);
|
|
106
|
+
} catch (o) {
|
|
101
107
|
return p(
|
|
102
108
|
e,
|
|
103
|
-
/timed out/i.test(String(
|
|
104
|
-
|
|
109
|
+
/timed out/i.test(String(o)) ? "timed-out" : "unavailable",
|
|
110
|
+
o
|
|
105
111
|
);
|
|
106
112
|
} finally {
|
|
107
113
|
await (t == null ? void 0 : t.destroy().catch(() => {
|
|
108
114
|
})), r.destroy();
|
|
109
115
|
}
|
|
110
116
|
}, j = async (e) => {
|
|
111
|
-
f.delete(e), typeof indexedDB < "u" && await
|
|
117
|
+
f.delete(e), typeof indexedDB < "u" && await x(e);
|
|
112
118
|
};
|
|
113
119
|
export {
|
|
114
120
|
j as deleteDsheetContent,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
A as getDsheetStateVector,
|
|
122
|
+
P as mergeDsheetContent,
|
|
123
|
+
C as readDsheetContent
|
|
118
124
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as BZ from "yjs";
|
|
2
|
-
import { i as Yl, a as hl, s as eZ, r as ul, y as Il, b as pl, m as Rl } from "./index-
|
|
2
|
+
import { i as Yl, a as hl, s as eZ, r as ul, y as Il, b as pl, m as Rl } from "./index-7Fa_Mod8.js";
|
|
3
3
|
import { g as sl } from "./executeStringFunction-D1IXrBP2.js";
|
|
4
4
|
import { Workbook as al } from "exceljs";
|
|
5
5
|
import Kl from "luckyexcel";
|
|
6
|
-
import { e as Jl, b as xl, n as Ml } from "./xlsx-hyperlink-inline-
|
|
7
|
-
import { parseDefinedNamesFromXlsxBuffer as Sl, excelEntriesToDefinedNames as OZ } from "./xlsx-defined-names-
|
|
6
|
+
import { e as Jl, b as xl, n as Ml } from "./xlsx-hyperlink-inline-CKQmxa8u.js";
|
|
7
|
+
import { parseDefinedNamesFromXlsxBuffer as Sl, excelEntriesToDefinedNames as OZ } from "./xlsx-defined-names-CUwiqOuM.js";
|
|
8
8
|
import { toast as fZ } from "@fileverse/ui";
|
|
9
9
|
var Zl = { exports: {} };
|
|
10
10
|
(function(m) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { utils as S, write as nt } from "xlsx-js-style";
|
|
2
2
|
import { Workbook as pt } from "exceljs";
|
|
3
3
|
import { toast as rt } from "@fileverse/ui";
|
|
4
|
-
import { J as dt, c as X, g as ht, a as mt } from "./xlsx-hyperlink-inline-
|
|
4
|
+
import { J as dt, c as X, g as ht, a as mt } from "./xlsx-hyperlink-inline-CKQmxa8u.js";
|
|
5
5
|
import { b as gt } from "./executeStringFunction-D1IXrBP2.js";
|
|
6
|
-
import { e as bt } from "./index-
|
|
6
|
+
import { e as bt } from "./index-7Fa_Mod8.js";
|
|
7
7
|
const xt = {
|
|
8
8
|
1: "thin",
|
|
9
9
|
2: "hair",
|
|
@@ -854,7 +854,7 @@ const Z = (t) => {
|
|
|
854
854
|
O
|
|
855
855
|
);
|
|
856
856
|
});
|
|
857
|
-
const { applyDefinedNamesToExcelWorkbook: ct } = await import("./xlsx-defined-names-
|
|
857
|
+
const { applyDefinedNamesToExcelWorkbook: ct } = await import("./xlsx-defined-names-CUwiqOuM.js");
|
|
858
858
|
ct(
|
|
859
859
|
B,
|
|
860
860
|
(k = (C = (s = t.current).getWorkbookContext) == null ? void 0 : C.call(s)) == null ? void 0 : k.definedNames,
|
package/package.json
CHANGED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import * as i from "yjs";
|
|
2
|
-
const p = typeof Buffer == "function";
|
|
3
|
-
typeof TextDecoder == "function" && new TextDecoder();
|
|
4
|
-
typeof TextEncoder == "function" && new TextEncoder();
|
|
5
|
-
const A = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", c = Array.prototype.slice.call(A), f = ((t) => {
|
|
6
|
-
let e = {};
|
|
7
|
-
return t.forEach((r, n) => e[r] = n), e;
|
|
8
|
-
})(c), b = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/, u = String.fromCharCode.bind(String), d = typeof Uint8Array.from == "function" ? Uint8Array.from.bind(Uint8Array) : (t) => new Uint8Array(Array.prototype.slice.call(t, 0)), E = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (e) => e == "+" ? "-" : "_"), g = (t) => t.replace(/[^A-Za-z0-9\+\/]/g, ""), S = (t) => {
|
|
9
|
-
let e, r, n, o, a = "";
|
|
10
|
-
const s = t.length % 3;
|
|
11
|
-
for (let l = 0; l < t.length; ) {
|
|
12
|
-
if ((r = t.charCodeAt(l++)) > 255 || (n = t.charCodeAt(l++)) > 255 || (o = t.charCodeAt(l++)) > 255)
|
|
13
|
-
throw new TypeError("invalid character found");
|
|
14
|
-
e = r << 16 | n << 8 | o, a += c[e >> 18 & 63] + c[e >> 12 & 63] + c[e >> 6 & 63] + c[e & 63];
|
|
15
|
-
}
|
|
16
|
-
return s ? a.slice(0, s - 3) + "===".substring(s) : a;
|
|
17
|
-
}, U = typeof btoa == "function" ? (t) => btoa(t) : p ? (t) => Buffer.from(t, "binary").toString("base64") : S, y = p ? (t) => Buffer.from(t).toString("base64") : (t) => {
|
|
18
|
-
let r = [];
|
|
19
|
-
for (let n = 0, o = t.length; n < o; n += 4096)
|
|
20
|
-
r.push(u.apply(null, t.subarray(n, n + 4096)));
|
|
21
|
-
return U(r.join(""));
|
|
22
|
-
}, h = (t, e = !1) => e ? E(y(t)) : y(t), _ = (t) => {
|
|
23
|
-
if (t = t.replace(/\s+/g, ""), !b.test(t))
|
|
24
|
-
throw new TypeError("malformed base64.");
|
|
25
|
-
t += "==".slice(2 - (t.length & 3));
|
|
26
|
-
let e, r, n, o = [];
|
|
27
|
-
for (let a = 0; a < t.length; )
|
|
28
|
-
e = f[t.charAt(a++)] << 18 | f[t.charAt(a++)] << 12 | (r = f[t.charAt(a++)]) << 6 | (n = f[t.charAt(a++)]), r === 64 ? o.push(u(e >> 16 & 255)) : n === 64 ? o.push(u(e >> 16 & 255, e >> 8 & 255)) : o.push(u(e >> 16 & 255, e >> 8 & 255, e & 255));
|
|
29
|
-
return o.join("");
|
|
30
|
-
}, w = typeof atob == "function" ? (t) => atob(g(t)) : p ? (t) => Buffer.from(t, "base64").toString("binary") : _, D = p ? (t) => d(Buffer.from(t, "base64")) : (t) => d(w(t).split("").map((e) => e.charCodeAt(0))), T = (t) => D(C(t)), C = (t) => g(t.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), v = 8e3, x = (t) => t instanceof Error ? t : new Error(String(t)), B = (t, e, r = "dsheet-package-ingress") => {
|
|
31
|
-
const n = T(e), o = new i.Doc();
|
|
32
|
-
try {
|
|
33
|
-
i.applyUpdate(o, n);
|
|
34
|
-
} finally {
|
|
35
|
-
o.destroy();
|
|
36
|
-
}
|
|
37
|
-
let a = !1;
|
|
38
|
-
const s = () => {
|
|
39
|
-
a = !0;
|
|
40
|
-
};
|
|
41
|
-
t.on("update", s);
|
|
42
|
-
try {
|
|
43
|
-
return i.applyUpdate(t, n, r), a;
|
|
44
|
-
} finally {
|
|
45
|
-
t.off("update", s);
|
|
46
|
-
}
|
|
47
|
-
}, z = async (t, e) => {
|
|
48
|
-
let r;
|
|
49
|
-
try {
|
|
50
|
-
return await Promise.race([
|
|
51
|
-
t,
|
|
52
|
-
new Promise((n, o) => {
|
|
53
|
-
r = setTimeout(
|
|
54
|
-
() => o(new Error("dSheet IndexedDB operation timed out")),
|
|
55
|
-
e
|
|
56
|
-
);
|
|
57
|
-
})
|
|
58
|
-
]);
|
|
59
|
-
} finally {
|
|
60
|
-
r && clearTimeout(r);
|
|
61
|
-
}
|
|
62
|
-
}, m = (t, e, r) => ({
|
|
63
|
-
dsheetId: t,
|
|
64
|
-
status: e,
|
|
65
|
-
encodedState: null,
|
|
66
|
-
stateVector: null,
|
|
67
|
-
...r ? { error: x(r) } : {}
|
|
68
|
-
}), P = (t, e) => {
|
|
69
|
-
const r = i.encodeStateAsUpdate(e);
|
|
70
|
-
return {
|
|
71
|
-
dsheetId: t,
|
|
72
|
-
status: r.length <= 2 ? "empty" : "available",
|
|
73
|
-
encodedState: h(r),
|
|
74
|
-
stateVector: h(i.encodeStateVector(e))
|
|
75
|
-
};
|
|
76
|
-
}, Z = (t, e, r) => {
|
|
77
|
-
if (!r)
|
|
78
|
-
return m(
|
|
79
|
-
t,
|
|
80
|
-
"unavailable",
|
|
81
|
-
new Error("dSheet document is not ready")
|
|
82
|
-
);
|
|
83
|
-
try {
|
|
84
|
-
return B(r, e, "dsheet-package-ingress"), P(t, r);
|
|
85
|
-
} catch (n) {
|
|
86
|
-
return m(t, "corrupt", n);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
export {
|
|
90
|
-
v as D,
|
|
91
|
-
Z as a,
|
|
92
|
-
h as f,
|
|
93
|
-
B as m,
|
|
94
|
-
P as s,
|
|
95
|
-
T as t,
|
|
96
|
-
m as u,
|
|
97
|
-
z as w
|
|
98
|
-
};
|