@fileverse-dev/dsheet 3.0.2-patch.3 → 3.0.2-patch.4
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/editor/contexts/editor-context.d.ts +2 -2
- package/dist/editor/hooks/use-editor-sync.d.ts +3 -3
- package/dist/editor/types.d.ts +2 -2
- package/dist/{index-QXaCiKEu.js → index-DvLR_0vI.js} +1751 -1756
- package/dist/index.es.js +1 -1
- package/dist/persistence-utils-DsM_MOB1.js +89 -0
- package/dist/persistence-utils.d.ts +1 -3
- package/dist/persistence.d.ts +1 -4
- package/dist/persistence.js +69 -79
- package/dist/{use-xlsx-import-impl-CAu1_1ci.js → use-xlsx-import-impl-CcCQW14T.js} +1 -1
- package/dist/{xlsx-export-impl-jffVaI-3.js → xlsx-export-impl-D2wiFktd.js} +1 -1
- package/package.json +1 -1
- package/dist/persistence-utils-EM6EHJYw.js +0 -103
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as s, a as t, b as o, S as r, d as l, i as n, e as i, T as d, f as S, g as c, h, j as m, k as p, l as C, n as u, o as E, p as F, q as g, s as x, t as R, u as L, v as f, w as A, x as I, z as w, A as T, B as b, D as v, E as M, F as D, G as k, H as V, I as X, J as z, K as P, L as U, M as _, N as y } from "./index-
|
|
1
|
+
import { C as s, a as t, b as o, S as r, d as l, i as n, e as i, T as d, f as S, g as c, h, j as m, k as p, l as C, n as u, o as E, p as F, q as g, s as x, t as R, u as L, v as f, w as A, x as I, z as w, A as T, B as b, D as v, E as M, F as D, G as k, H as V, I as X, J as z, K as P, L as U, M as _, N as y } from "./index-DvLR_0vI.js";
|
|
2
2
|
import { bW as G, bX as H, bY as O, c0 as j, bi as J, e as K, f as N, h as Y, a as q, cm as W, as as Z, cu as Q } from "./executeStringFunction-C5hEkx9z.js";
|
|
3
3
|
import { FLVURL as ee } from "@fileverse-dev/formulajs";
|
|
4
4
|
import { E as se, S as te } from "./constants-Q8nzbvQO.js";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as c from "yjs";
|
|
2
|
+
const u = typeof Buffer == "function";
|
|
3
|
+
typeof TextDecoder == "function" && new TextDecoder();
|
|
4
|
+
typeof TextEncoder == "function" && new TextEncoder();
|
|
5
|
+
const b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", s = Array.prototype.slice.call(b), l = ((t) => {
|
|
6
|
+
let e = {};
|
|
7
|
+
return t.forEach((r, o) => e[r] = o), e;
|
|
8
|
+
})(s), g = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/, f = String.fromCharCode.bind(String), h = typeof Uint8Array.from == "function" ? Uint8Array.from.bind(Uint8Array) : (t) => new Uint8Array(Array.prototype.slice.call(t, 0)), S = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (e) => e == "+" ? "-" : "_"), A = (t) => t.replace(/[^A-Za-z0-9\+\/]/g, ""), E = (t) => {
|
|
9
|
+
let e, r, o, n, a = "";
|
|
10
|
+
const p = t.length % 3;
|
|
11
|
+
for (let i = 0; i < t.length; ) {
|
|
12
|
+
if ((r = t.charCodeAt(i++)) > 255 || (o = t.charCodeAt(i++)) > 255 || (n = t.charCodeAt(i++)) > 255)
|
|
13
|
+
throw new TypeError("invalid character found");
|
|
14
|
+
e = r << 16 | o << 8 | n, a += s[e >> 18 & 63] + s[e >> 12 & 63] + s[e >> 6 & 63] + s[e & 63];
|
|
15
|
+
}
|
|
16
|
+
return p ? a.slice(0, p - 3) + "===".substring(p) : a;
|
|
17
|
+
}, U = typeof btoa == "function" ? (t) => btoa(t) : u ? (t) => Buffer.from(t, "binary").toString("base64") : E, d = u ? (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(f.apply(null, t.subarray(o, o + 4096)));
|
|
21
|
+
return U(r.join(""));
|
|
22
|
+
}, m = (t, e = !1) => e ? S(d(t)) : d(t), _ = (t) => {
|
|
23
|
+
if (t = t.replace(/\s+/g, ""), !g.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 = l[t.charAt(a++)] << 18 | l[t.charAt(a++)] << 12 | (r = l[t.charAt(a++)]) << 6 | (o = l[t.charAt(a++)]), r === 64 ? n.push(f(e >> 16 & 255)) : o === 64 ? n.push(f(e >> 16 & 255, e >> 8 & 255)) : n.push(f(e >> 16 & 255, e >> 8 & 255, e & 255));
|
|
29
|
+
return n.join("");
|
|
30
|
+
}, w = typeof atob == "function" ? (t) => atob(A(t)) : u ? (t) => Buffer.from(t, "base64").toString("binary") : _, D = u ? (t) => h(Buffer.from(t, "base64")) : (t) => h(w(t).split("").map((e) => e.charCodeAt(0))), T = (t) => D(C(t)), C = (t) => A(t.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), P = 8e3, x = (t) => t instanceof Error ? t : new Error(String(t)), v = async (t, e) => {
|
|
31
|
+
let r;
|
|
32
|
+
try {
|
|
33
|
+
return await Promise.race([
|
|
34
|
+
t,
|
|
35
|
+
new Promise((o, n) => {
|
|
36
|
+
r = setTimeout(
|
|
37
|
+
() => n(new Error("dSheet IndexedDB operation timed out")),
|
|
38
|
+
e
|
|
39
|
+
);
|
|
40
|
+
})
|
|
41
|
+
]);
|
|
42
|
+
} finally {
|
|
43
|
+
r && clearTimeout(r);
|
|
44
|
+
}
|
|
45
|
+
}, y = (t, e, r) => ({
|
|
46
|
+
dsheetId: t,
|
|
47
|
+
status: e,
|
|
48
|
+
encodedState: null,
|
|
49
|
+
stateVector: null,
|
|
50
|
+
...r ? { error: x(r) } : {}
|
|
51
|
+
}), B = (t, e) => {
|
|
52
|
+
const r = c.encodeStateAsUpdate(e);
|
|
53
|
+
return {
|
|
54
|
+
dsheetId: t,
|
|
55
|
+
status: r.length <= 2 ? "empty" : "available",
|
|
56
|
+
encodedState: m(r),
|
|
57
|
+
stateVector: m(c.encodeStateVector(e))
|
|
58
|
+
};
|
|
59
|
+
}, z = (t, e, r) => {
|
|
60
|
+
if (!r)
|
|
61
|
+
return y(
|
|
62
|
+
t,
|
|
63
|
+
"unavailable",
|
|
64
|
+
new Error("dSheet document is not ready")
|
|
65
|
+
);
|
|
66
|
+
let o;
|
|
67
|
+
const n = new c.Doc();
|
|
68
|
+
try {
|
|
69
|
+
o = T(e), c.applyUpdate(n, o);
|
|
70
|
+
} catch (a) {
|
|
71
|
+
return y(t, "corrupt", a);
|
|
72
|
+
} finally {
|
|
73
|
+
n.destroy();
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
return c.applyUpdate(r, o, "dsheet-package-ingress"), B(t, r);
|
|
77
|
+
} catch (a) {
|
|
78
|
+
return y(t, "corrupt", a);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
P as D,
|
|
83
|
+
m as f,
|
|
84
|
+
z as m,
|
|
85
|
+
B as s,
|
|
86
|
+
T as t,
|
|
87
|
+
y as u,
|
|
88
|
+
v as w
|
|
89
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
2
1
|
import * as Y from 'yjs';
|
|
3
2
|
export declare const DEFAULT_DSHEET_PERSISTENCE_TIMEOUT_MS = 8000;
|
|
4
3
|
export type DSheetContentStatus = 'available' | 'empty' | 'missing' | 'corrupt' | 'timed-out' | 'unavailable';
|
|
@@ -15,5 +14,4 @@ export type DSheetContentReadOptions = {
|
|
|
15
14
|
export declare const withDsheetPersistenceTimeout: <T>(promise: Promise<T>, timeoutMs: number) => Promise<T>;
|
|
16
15
|
export declare const unavailableDsheetContentSnapshot: (dsheetId: string, status: Exclude<DSheetContentStatus, "available" | "empty">, error?: unknown) => DSheetContentSnapshot;
|
|
17
16
|
export declare const snapshotDsheetDocument: (dsheetId: string, doc: Y.Doc) => DSheetContentSnapshot;
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const mergeDsheetContentPersistence: (dsheetId: string, encodedState: string, doc: Y.Doc | null, persistence: IndexeddbPersistence | null, options?: DSheetContentReadOptions) => Promise<DSheetContentSnapshot>;
|
|
17
|
+
export declare const mergeDsheetContentIntoDocument: (dsheetId: string, encodedState: string, doc: Y.Doc | null) => DSheetContentSnapshot;
|
package/dist/persistence.d.ts
CHANGED
|
@@ -7,9 +7,6 @@ export declare const getDsheetStateVector: (encodedState: string | Uint8Array) =
|
|
|
7
7
|
* persistence writer. Completed reads are never cached.
|
|
8
8
|
*/
|
|
9
9
|
export declare const readDsheetContent: (dsheetId: string, options?: DSheetContentReadOptions) => Promise<DSheetContentSnapshot>;
|
|
10
|
-
/**
|
|
11
|
-
* Merge content through the same persistence provider used by a mounted
|
|
12
|
-
* editor, and resolve only after the applied update is durable.
|
|
13
|
-
*/
|
|
10
|
+
/** Merge content into the package-owned Y-IndexedDB document. */
|
|
14
11
|
export declare const mergeDsheetContent: (dsheetId: string, encodedState: string, options?: DSheetContentReadOptions) => Promise<DSheetContentSnapshot>;
|
|
15
12
|
export declare const deleteDsheetContent: (dsheetId: string) => Promise<void>;
|
package/dist/persistence.js
CHANGED
|
@@ -1,128 +1,118 @@
|
|
|
1
|
-
import { t as D, f as h, D as b, u as
|
|
1
|
+
import { t as D, f as h, D as b, u as p, w as S, s as w } from "./persistence-utils-DsM_MOB1.js";
|
|
2
2
|
import * as u from "yjs";
|
|
3
|
-
import { clearDocument as
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
import { clearDocument as v, IndexeddbPersistence as E } from "y-indexeddb";
|
|
4
|
+
const f = /* @__PURE__ */ new Map(), M = (e) => {
|
|
5
|
+
const o = new u.Doc();
|
|
6
6
|
try {
|
|
7
7
|
return u.applyUpdate(
|
|
8
|
-
|
|
8
|
+
o,
|
|
9
9
|
typeof e == "string" ? D(e) : e
|
|
10
|
-
), h(u.encodeStateVector(
|
|
10
|
+
), h(u.encodeStateVector(o));
|
|
11
11
|
} finally {
|
|
12
|
-
|
|
12
|
+
o.destroy();
|
|
13
13
|
}
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
let
|
|
17
|
-
const
|
|
18
|
-
i || (i = !0, clearTimeout(
|
|
19
|
-
},
|
|
14
|
+
}, x = (e, o) => new Promise((s) => {
|
|
15
|
+
const a = new u.Doc();
|
|
16
|
+
let r = null, t = null, i = !1, m = !1;
|
|
17
|
+
const y = (n) => {
|
|
18
|
+
i || (i = !0, clearTimeout(g), r == null || r.close(), a.destroy(), s(n));
|
|
19
|
+
}, c = (n, d) => y(p(e, n, d)), g = setTimeout(() => {
|
|
20
20
|
try {
|
|
21
21
|
t == null || t.abort();
|
|
22
22
|
} catch {
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
let
|
|
24
|
+
c("timed-out", new Error("dSheet IndexedDB read timed out"));
|
|
25
|
+
}, o);
|
|
26
|
+
let l;
|
|
27
27
|
try {
|
|
28
|
-
|
|
29
|
-
} catch (
|
|
30
|
-
|
|
28
|
+
l = indexedDB.open(e);
|
|
29
|
+
} catch (n) {
|
|
30
|
+
c("unavailable", n);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
if (
|
|
40
|
-
|
|
33
|
+
l.onupgradeneeded = () => {
|
|
34
|
+
var n;
|
|
35
|
+
m = !0, (n = l.transaction) == null || n.abort();
|
|
36
|
+
}, l.onerror = () => {
|
|
37
|
+
m ? y(p(e, "missing")) : c("unavailable", l.error);
|
|
38
|
+
}, l.onsuccess = () => {
|
|
39
|
+
if (r = l.result, !r.objectStoreNames.contains("updates") || !r.objectStoreNames.contains("custom")) {
|
|
40
|
+
c("corrupt", new Error("dSheet IndexedDB schema is invalid"));
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
try {
|
|
44
|
-
t =
|
|
45
|
-
const
|
|
46
|
-
|
|
44
|
+
t = r.transaction("updates", "readonly");
|
|
45
|
+
const n = t.objectStore("updates").getAll();
|
|
46
|
+
n.onerror = () => c("unavailable", n.error), n.onsuccess = () => {
|
|
47
47
|
try {
|
|
48
|
-
for (const
|
|
49
|
-
if (!(
|
|
48
|
+
for (const d of n.result ?? []) {
|
|
49
|
+
if (!(d instanceof Uint8Array))
|
|
50
50
|
throw new Error("dSheet IndexedDB contains a non-Yjs update");
|
|
51
|
-
u.applyUpdate(
|
|
51
|
+
u.applyUpdate(a, d);
|
|
52
52
|
}
|
|
53
|
-
} catch (
|
|
54
|
-
|
|
53
|
+
} catch (d) {
|
|
54
|
+
c("corrupt", d);
|
|
55
55
|
}
|
|
56
|
-
}, t.oncomplete = () =>
|
|
57
|
-
i ||
|
|
56
|
+
}, t.oncomplete = () => y(w(e, a)), t.onabort = () => {
|
|
57
|
+
i || c("unavailable", t == null ? void 0 : t.error);
|
|
58
58
|
}, t.onerror = () => {
|
|
59
|
-
i ||
|
|
59
|
+
i || c("unavailable", t == null ? void 0 : t.error);
|
|
60
60
|
};
|
|
61
|
-
} catch (
|
|
62
|
-
|
|
61
|
+
} catch (n) {
|
|
62
|
+
c("unavailable", n);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
}),
|
|
65
|
+
}), B = async (e, o) => {
|
|
66
66
|
if (typeof indexedDB > "u")
|
|
67
|
-
return
|
|
67
|
+
return p(
|
|
68
68
|
e,
|
|
69
69
|
"unavailable",
|
|
70
70
|
new Error("IndexedDB is unavailable")
|
|
71
71
|
);
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
72
|
+
const s = indexedDB;
|
|
73
|
+
if (s.databases)
|
|
74
74
|
try {
|
|
75
|
-
if (!(await
|
|
76
|
-
return
|
|
75
|
+
if (!(await s.databases()).some((r) => r.name === e))
|
|
76
|
+
return p(e, "missing");
|
|
77
77
|
} catch {
|
|
78
78
|
}
|
|
79
|
-
return
|
|
80
|
-
}, A = (e,
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
const
|
|
79
|
+
return x(e, o);
|
|
80
|
+
}, A = (e, o = {}) => {
|
|
81
|
+
const s = f.get(e);
|
|
82
|
+
if (s) return s;
|
|
83
|
+
const a = B(
|
|
84
84
|
e,
|
|
85
|
-
|
|
85
|
+
o.timeoutMs ?? b
|
|
86
86
|
).finally(() => {
|
|
87
|
-
|
|
87
|
+
f.get(e) === a && f.delete(e);
|
|
88
88
|
});
|
|
89
|
-
return
|
|
90
|
-
},
|
|
91
|
-
const
|
|
92
|
-
let n;
|
|
93
|
-
const t = new u.Doc();
|
|
89
|
+
return f.set(e, a), a;
|
|
90
|
+
}, C = async (e, o, s = {}) => {
|
|
91
|
+
const a = s.timeoutMs ?? b, r = new u.Doc();
|
|
94
92
|
try {
|
|
95
|
-
|
|
96
|
-
} catch (
|
|
97
|
-
return
|
|
98
|
-
} finally {
|
|
99
|
-
t.destroy();
|
|
93
|
+
u.applyUpdate(r, D(o), "dsheet-package-ingress");
|
|
94
|
+
} catch (i) {
|
|
95
|
+
return r.destroy(), p(e, "corrupt", i);
|
|
100
96
|
}
|
|
101
|
-
|
|
102
|
-
let c = null;
|
|
97
|
+
let t = null;
|
|
103
98
|
try {
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
c,
|
|
108
|
-
o
|
|
109
|
-
);
|
|
110
|
-
} catch (d) {
|
|
111
|
-
return y(
|
|
99
|
+
return t = new E(e, r), await S(t.whenSynced, a), w(e, r);
|
|
100
|
+
} catch (i) {
|
|
101
|
+
return p(
|
|
112
102
|
e,
|
|
113
|
-
/timed out/i.test(String(
|
|
114
|
-
|
|
103
|
+
/timed out/i.test(String(i)) ? "timed-out" : "unavailable",
|
|
104
|
+
i
|
|
115
105
|
);
|
|
116
106
|
} finally {
|
|
117
|
-
await (
|
|
118
|
-
})),
|
|
107
|
+
await (t == null ? void 0 : t.destroy().catch(() => {
|
|
108
|
+
})), r.destroy();
|
|
119
109
|
}
|
|
120
110
|
}, j = async (e) => {
|
|
121
|
-
|
|
111
|
+
f.delete(e), typeof indexedDB < "u" && await v(e);
|
|
122
112
|
};
|
|
123
113
|
export {
|
|
124
114
|
j as deleteDsheetContent,
|
|
125
115
|
M as getDsheetStateVector,
|
|
126
|
-
|
|
116
|
+
C as mergeDsheetContent,
|
|
127
117
|
A as readDsheetContent
|
|
128
118
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as Ze } from "./executeStringFunction-C5hEkx9z.js";
|
|
2
2
|
import * as Je from "yjs";
|
|
3
|
-
import { m as Qe, y as Ke, r as et } from "./index-
|
|
3
|
+
import { m as Qe, y as Ke, r as et } from "./index-DvLR_0vI.js";
|
|
4
4
|
import { n as tt } from "./xlsx-hyperlink-inline-DzewAypN.js";
|
|
5
5
|
import { toast as Ie } from "@fileverse/ui";
|
|
6
6
|
var ze = { exports: {} };
|
|
@@ -3,7 +3,7 @@ import { Workbook as Pt } from "exceljs";
|
|
|
3
3
|
import { toast as Ut } from "@fileverse/ui";
|
|
4
4
|
import { addFortuneImagesToWorksheet as Lt } from "./xlsx-image-utils-Cvg0qxRA.js";
|
|
5
5
|
import { g as jt, c as xt } from "./executeStringFunction-C5hEkx9z.js";
|
|
6
|
-
import { c as Ct } from "./index-
|
|
6
|
+
import { c as Ct } from "./index-DvLR_0vI.js";
|
|
7
7
|
import { c as zt, g as Wt } from "./xlsx-hyperlink-inline-DzewAypN.js";
|
|
8
8
|
const Mt = {
|
|
9
9
|
1: "thin",
|
package/package.json
CHANGED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import * as h from "yjs";
|
|
2
|
-
import { storeState as g } from "y-indexeddb";
|
|
3
|
-
const u = typeof Buffer == "function";
|
|
4
|
-
typeof TextDecoder == "function" && new TextDecoder();
|
|
5
|
-
typeof TextEncoder == "function" && new TextEncoder();
|
|
6
|
-
const S = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", s = Array.prototype.slice.call(S), i = ((t) => {
|
|
7
|
-
let e = {};
|
|
8
|
-
return t.forEach((r, o) => e[r] = o), e;
|
|
9
|
-
})(s), E = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/, l = String.fromCharCode.bind(String), m = typeof Uint8Array.from == "function" ? Uint8Array.from.bind(Uint8Array) : (t) => new Uint8Array(Array.prototype.slice.call(t, 0)), w = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (e) => e == "+" ? "-" : "_"), b = (t) => t.replace(/[^A-Za-z0-9\+\/]/g, ""), _ = (t) => {
|
|
10
|
-
let e, r, o, n, a = "";
|
|
11
|
-
const y = t.length % 3;
|
|
12
|
-
for (let c = 0; c < t.length; ) {
|
|
13
|
-
if ((r = t.charCodeAt(c++)) > 255 || (o = t.charCodeAt(c++)) > 255 || (n = t.charCodeAt(c++)) > 255)
|
|
14
|
-
throw new TypeError("invalid character found");
|
|
15
|
-
e = r << 16 | o << 8 | n, a += s[e >> 18 & 63] + s[e >> 12 & 63] + s[e >> 6 & 63] + s[e & 63];
|
|
16
|
-
}
|
|
17
|
-
return y ? a.slice(0, y - 3) + "===".substring(y) : a;
|
|
18
|
-
}, U = typeof btoa == "function" ? (t) => btoa(t) : u ? (t) => Buffer.from(t, "binary").toString("base64") : _, p = u ? (t) => Buffer.from(t).toString("base64") : (t) => {
|
|
19
|
-
let r = [];
|
|
20
|
-
for (let o = 0, n = t.length; o < n; o += 4096)
|
|
21
|
-
r.push(l.apply(null, t.subarray(o, o + 4096)));
|
|
22
|
-
return U(r.join(""));
|
|
23
|
-
}, d = (t, e = !1) => e ? w(p(t)) : p(t), D = (t) => {
|
|
24
|
-
if (t = t.replace(/\s+/g, ""), !E.test(t))
|
|
25
|
-
throw new TypeError("malformed base64.");
|
|
26
|
-
t += "==".slice(2 - (t.length & 3));
|
|
27
|
-
let e, r, o, n = [];
|
|
28
|
-
for (let a = 0; a < t.length; )
|
|
29
|
-
e = i[t.charAt(a++)] << 18 | i[t.charAt(a++)] << 12 | (r = i[t.charAt(a++)]) << 6 | (o = i[t.charAt(a++)]), r === 64 ? n.push(l(e >> 16 & 255)) : o === 64 ? n.push(l(e >> 16 & 255, e >> 8 & 255)) : n.push(l(e >> 16 & 255, e >> 8 & 255, e & 255));
|
|
30
|
-
return n.join("");
|
|
31
|
-
}, T = typeof atob == "function" ? (t) => atob(b(t)) : u ? (t) => Buffer.from(t, "base64").toString("binary") : D, x = u ? (t) => m(Buffer.from(t, "base64")) : (t) => m(T(t).split("").map((e) => e.charCodeAt(0))), C = (t) => x(B(t)), B = (t) => b(t.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), P = 8e3, A = (t) => t instanceof Error ? t : new Error(String(t)), v = async (t, e) => {
|
|
32
|
-
let r;
|
|
33
|
-
try {
|
|
34
|
-
return await Promise.race([
|
|
35
|
-
t,
|
|
36
|
-
new Promise((o, n) => {
|
|
37
|
-
r = setTimeout(
|
|
38
|
-
() => n(new Error("dSheet IndexedDB operation timed out")),
|
|
39
|
-
e
|
|
40
|
-
);
|
|
41
|
-
})
|
|
42
|
-
]);
|
|
43
|
-
} finally {
|
|
44
|
-
r && clearTimeout(r);
|
|
45
|
-
}
|
|
46
|
-
}, f = (t, e, r) => ({
|
|
47
|
-
dsheetId: t,
|
|
48
|
-
status: e,
|
|
49
|
-
encodedState: null,
|
|
50
|
-
stateVector: null,
|
|
51
|
-
...r ? { error: A(r) } : {}
|
|
52
|
-
}), z = (t, e) => {
|
|
53
|
-
const r = h.encodeStateAsUpdate(e);
|
|
54
|
-
return {
|
|
55
|
-
dsheetId: t,
|
|
56
|
-
status: r.length <= 2 ? "empty" : "available",
|
|
57
|
-
encodedState: d(r),
|
|
58
|
-
stateVector: d(h.encodeStateVector(e))
|
|
59
|
-
};
|
|
60
|
-
}, Z = async (t, e, r, o = {}) => {
|
|
61
|
-
if (!e || !r)
|
|
62
|
-
return f(
|
|
63
|
-
t,
|
|
64
|
-
"unavailable",
|
|
65
|
-
new Error("dSheet IndexedDB persistence is not ready")
|
|
66
|
-
);
|
|
67
|
-
const n = z(t, e);
|
|
68
|
-
try {
|
|
69
|
-
return await v(
|
|
70
|
-
g(r, !1),
|
|
71
|
-
o.timeoutMs ?? P
|
|
72
|
-
), n;
|
|
73
|
-
} catch (a) {
|
|
74
|
-
return f(
|
|
75
|
-
t,
|
|
76
|
-
/timed out/i.test(A(a).message) ? "timed-out" : "unavailable",
|
|
77
|
-
a
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}, V = async (t, e, r, o, n = {}) => {
|
|
81
|
-
if (!r || !(o != null && o.synced))
|
|
82
|
-
return f(
|
|
83
|
-
t,
|
|
84
|
-
"unavailable",
|
|
85
|
-
new Error("dSheet IndexedDB persistence is not ready")
|
|
86
|
-
);
|
|
87
|
-
try {
|
|
88
|
-
h.applyUpdate(r, C(e), "dsheet-package-ingress");
|
|
89
|
-
} catch (a) {
|
|
90
|
-
return f(t, "corrupt", a);
|
|
91
|
-
}
|
|
92
|
-
return Z(t, r, o, n);
|
|
93
|
-
};
|
|
94
|
-
export {
|
|
95
|
-
P as D,
|
|
96
|
-
Z as a,
|
|
97
|
-
d as f,
|
|
98
|
-
V as m,
|
|
99
|
-
z as s,
|
|
100
|
-
C as t,
|
|
101
|
-
f as u,
|
|
102
|
-
v as w
|
|
103
|
-
};
|