@fileverse-dev/dsheet 3.0.2-patch.1 → 3.0.2-patch.2
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 -0
- package/dist/editor/hooks/use-editor-sync.d.ts +1 -0
- package/dist/editor/types.d.ts +2 -0
- package/dist/{index-Dql-IRPC.js → index-Biq3hJno.js} +7736 -7753
- package/dist/index.es.js +1 -1
- package/dist/persistence-utils-ySfLnGiT.js +89 -0
- package/dist/persistence-utils.d.ts +18 -0
- package/dist/persistence.d.ts +15 -0
- package/dist/persistence.js +128 -0
- package/dist/{use-xlsx-import-impl-BsL90Hs0.js → use-xlsx-import-impl-BQYFALtb.js} +1 -1
- package/dist/{xlsx-export-impl-DfQuhamE.js → xlsx-export-impl-CqCiaiT9.js} +1 -1
- package/package.json +12 -4
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-Biq3hJno.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 h from "yjs";
|
|
2
|
+
import { storeState as g } from "y-indexeddb";
|
|
3
|
+
const f = 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)), _ = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (e) => e == "+" ? "-" : "_"), b = (t) => t.replace(/[^A-Za-z0-9\+\/]/g, ""), w = (t) => {
|
|
10
|
+
let e, r, o, n, a = "";
|
|
11
|
+
const u = 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 u ? a.slice(0, u - 3) + "===".substring(u) : a;
|
|
18
|
+
}, T = typeof btoa == "function" ? (t) => btoa(t) : f ? (t) => Buffer.from(t, "binary").toString("base64") : w, p = f ? (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 T(r.join(""));
|
|
23
|
+
}, y = (t, e = !1) => e ? _(p(t)) : p(t), U = (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
|
+
}, D = typeof atob == "function" ? (t) => atob(b(t)) : f ? (t) => Buffer.from(t, "base64").toString("binary") : U, x = f ? (t) => m(Buffer.from(t, "base64")) : (t) => m(D(t).split("").map((e) => e.charCodeAt(0))), Z = (t) => x(C(t)), C = (t) => b(t.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), B = 8e3, A = (t) => t instanceof Error ? t : new Error(String(t)), P = 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
|
+
}, d = (t, e, r) => ({
|
|
47
|
+
dsheetId: t,
|
|
48
|
+
status: e,
|
|
49
|
+
encodedState: null,
|
|
50
|
+
stateVector: null,
|
|
51
|
+
...r ? { error: A(r) } : {}
|
|
52
|
+
}), v = (t, e) => {
|
|
53
|
+
const r = h.encodeStateAsUpdate(e);
|
|
54
|
+
return {
|
|
55
|
+
dsheetId: t,
|
|
56
|
+
status: r.length <= 2 ? "empty" : "available",
|
|
57
|
+
encodedState: y(r),
|
|
58
|
+
stateVector: y(h.encodeStateVector(e))
|
|
59
|
+
};
|
|
60
|
+
}, I = async (t, e, r, o = {}) => {
|
|
61
|
+
if (!e || !r)
|
|
62
|
+
return d(
|
|
63
|
+
t,
|
|
64
|
+
"unavailable",
|
|
65
|
+
new Error("dSheet IndexedDB persistence is not ready")
|
|
66
|
+
);
|
|
67
|
+
const n = v(t, e);
|
|
68
|
+
try {
|
|
69
|
+
return await P(
|
|
70
|
+
g(r, !1),
|
|
71
|
+
o.timeoutMs ?? B
|
|
72
|
+
), n;
|
|
73
|
+
} catch (a) {
|
|
74
|
+
return d(
|
|
75
|
+
t,
|
|
76
|
+
/timed out/i.test(A(a).message) ? "timed-out" : "unavailable",
|
|
77
|
+
a
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
B as D,
|
|
83
|
+
I as a,
|
|
84
|
+
y as f,
|
|
85
|
+
v as s,
|
|
86
|
+
Z as t,
|
|
87
|
+
d as u,
|
|
88
|
+
P as w
|
|
89
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
export declare const DEFAULT_DSHEET_PERSISTENCE_TIMEOUT_MS = 8000;
|
|
4
|
+
export type DSheetContentStatus = 'available' | 'empty' | 'missing' | 'corrupt' | 'timed-out' | 'unavailable';
|
|
5
|
+
export type DSheetContentSnapshot = {
|
|
6
|
+
dsheetId: string;
|
|
7
|
+
status: DSheetContentStatus;
|
|
8
|
+
encodedState: string | null;
|
|
9
|
+
stateVector: string | null;
|
|
10
|
+
error?: Error;
|
|
11
|
+
};
|
|
12
|
+
export type DSheetContentReadOptions = {
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const withDsheetPersistenceTimeout: <T>(promise: Promise<T>, timeoutMs: number) => Promise<T>;
|
|
16
|
+
export declare const unavailableDsheetContentSnapshot: (dsheetId: string, status: Exclude<DSheetContentStatus, "available" | "empty">, error?: unknown) => DSheetContentSnapshot;
|
|
17
|
+
export declare const snapshotDsheetDocument: (dsheetId: string, doc: Y.Doc) => DSheetContentSnapshot;
|
|
18
|
+
export declare const flushDsheetContentPersistence: (dsheetId: string, doc: Y.Doc | null, persistence: IndexeddbPersistence | null, options?: DSheetContentReadOptions) => Promise<DSheetContentSnapshot>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DSheetContentReadOptions, DSheetContentSnapshot } from './persistence-utils';
|
|
2
|
+
|
|
3
|
+
export type { DSheetContentReadOptions, DSheetContentSnapshot, DSheetContentStatus, } from './persistence-utils';
|
|
4
|
+
export declare const getDsheetStateVector: (encodedState: string | Uint8Array) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Read the package-owned Y-IndexedDB database without attaching another
|
|
7
|
+
* persistence writer. Completed reads are never cached.
|
|
8
|
+
*/
|
|
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
|
+
*/
|
|
14
|
+
export declare const mergeDsheetContent: (dsheetId: string, encodedState: string, options?: DSheetContentReadOptions) => Promise<DSheetContentSnapshot>;
|
|
15
|
+
export declare const deleteDsheetContent: (dsheetId: string) => Promise<void>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { t as D, f as h, D as b, u as y, w as g, a as S, s as v } from "./persistence-utils-ySfLnGiT.js";
|
|
2
|
+
import * as u from "yjs";
|
|
3
|
+
import { clearDocument as E, IndexeddbPersistence as x } from "y-indexeddb";
|
|
4
|
+
const m = /* @__PURE__ */ new Map(), M = (e) => {
|
|
5
|
+
const a = new u.Doc();
|
|
6
|
+
try {
|
|
7
|
+
return u.applyUpdate(
|
|
8
|
+
a,
|
|
9
|
+
typeof e == "string" ? D(e) : e
|
|
10
|
+
), h(u.encodeStateVector(a));
|
|
11
|
+
} finally {
|
|
12
|
+
a.destroy();
|
|
13
|
+
}
|
|
14
|
+
}, B = (e, a) => new Promise((o) => {
|
|
15
|
+
const s = new u.Doc();
|
|
16
|
+
let n = null, t = null, i = !1, c = !1;
|
|
17
|
+
const d = (r) => {
|
|
18
|
+
i || (i = !0, clearTimeout(w), n == null || n.close(), s.destroy(), o(r));
|
|
19
|
+
}, l = (r, f) => d(y(e, r, f)), w = setTimeout(() => {
|
|
20
|
+
try {
|
|
21
|
+
t == null || t.abort();
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
l("timed-out", new Error("dSheet IndexedDB read timed out"));
|
|
25
|
+
}, a);
|
|
26
|
+
let p;
|
|
27
|
+
try {
|
|
28
|
+
p = indexedDB.open(e);
|
|
29
|
+
} catch (r) {
|
|
30
|
+
l("unavailable", r);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
p.onupgradeneeded = () => {
|
|
34
|
+
var r;
|
|
35
|
+
c = !0, (r = p.transaction) == null || r.abort();
|
|
36
|
+
}, p.onerror = () => {
|
|
37
|
+
c ? d(y(e, "missing")) : l("unavailable", p.error);
|
|
38
|
+
}, p.onsuccess = () => {
|
|
39
|
+
if (n = p.result, !n.objectStoreNames.contains("updates") || !n.objectStoreNames.contains("custom")) {
|
|
40
|
+
l("corrupt", new Error("dSheet IndexedDB schema is invalid"));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
t = n.transaction("updates", "readonly");
|
|
45
|
+
const r = t.objectStore("updates").getAll();
|
|
46
|
+
r.onerror = () => l("unavailable", r.error), r.onsuccess = () => {
|
|
47
|
+
try {
|
|
48
|
+
for (const f of r.result ?? []) {
|
|
49
|
+
if (!(f instanceof Uint8Array))
|
|
50
|
+
throw new Error("dSheet IndexedDB contains a non-Yjs update");
|
|
51
|
+
u.applyUpdate(s, f);
|
|
52
|
+
}
|
|
53
|
+
} catch (f) {
|
|
54
|
+
l("corrupt", f);
|
|
55
|
+
}
|
|
56
|
+
}, t.oncomplete = () => d(v(e, s)), t.onabort = () => {
|
|
57
|
+
i || l("unavailable", t == null ? void 0 : t.error);
|
|
58
|
+
}, t.onerror = () => {
|
|
59
|
+
i || l("unavailable", t == null ? void 0 : t.error);
|
|
60
|
+
};
|
|
61
|
+
} catch (r) {
|
|
62
|
+
l("unavailable", r);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}), U = async (e, a) => {
|
|
66
|
+
if (typeof indexedDB > "u")
|
|
67
|
+
return y(
|
|
68
|
+
e,
|
|
69
|
+
"unavailable",
|
|
70
|
+
new Error("IndexedDB is unavailable")
|
|
71
|
+
);
|
|
72
|
+
const o = indexedDB;
|
|
73
|
+
if (o.databases)
|
|
74
|
+
try {
|
|
75
|
+
if (!(await o.databases()).some((n) => n.name === e))
|
|
76
|
+
return y(e, "missing");
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
return B(e, a);
|
|
80
|
+
}, A = (e, a = {}) => {
|
|
81
|
+
const o = m.get(e);
|
|
82
|
+
if (o) return o;
|
|
83
|
+
const s = U(
|
|
84
|
+
e,
|
|
85
|
+
a.timeoutMs ?? b
|
|
86
|
+
).finally(() => {
|
|
87
|
+
m.get(e) === s && m.delete(e);
|
|
88
|
+
});
|
|
89
|
+
return m.set(e, s), s;
|
|
90
|
+
}, P = async (e, a, o = {}) => {
|
|
91
|
+
const s = o.timeoutMs ?? b;
|
|
92
|
+
let n;
|
|
93
|
+
const t = new u.Doc();
|
|
94
|
+
try {
|
|
95
|
+
n = D(a), u.applyUpdate(t, n);
|
|
96
|
+
} catch (d) {
|
|
97
|
+
return y(e, "corrupt", d);
|
|
98
|
+
} finally {
|
|
99
|
+
t.destroy();
|
|
100
|
+
}
|
|
101
|
+
const i = new u.Doc();
|
|
102
|
+
let c = null;
|
|
103
|
+
try {
|
|
104
|
+
return c = new x(e, i), await g(c.whenSynced, s), u.applyUpdate(i, n, "dsheet-package-ingress"), await S(
|
|
105
|
+
e,
|
|
106
|
+
i,
|
|
107
|
+
c,
|
|
108
|
+
o
|
|
109
|
+
);
|
|
110
|
+
} catch (d) {
|
|
111
|
+
return y(
|
|
112
|
+
e,
|
|
113
|
+
/timed out/i.test(String(d)) ? "timed-out" : "unavailable",
|
|
114
|
+
d
|
|
115
|
+
);
|
|
116
|
+
} finally {
|
|
117
|
+
await (c == null ? void 0 : c.destroy().catch(() => {
|
|
118
|
+
})), i.destroy();
|
|
119
|
+
}
|
|
120
|
+
}, j = async (e) => {
|
|
121
|
+
m.delete(e), typeof indexedDB < "u" && await E(e);
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
j as deleteDsheetContent,
|
|
125
|
+
M as getDsheetStateVector,
|
|
126
|
+
P as mergeDsheetContent,
|
|
127
|
+
A as readDsheetContent
|
|
128
|
+
};
|
|
@@ -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-Biq3hJno.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-Biq3hJno.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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@fileverse-dev/dsheet",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "DSheet",
|
|
5
|
-
"version": "3.0.2-patch.
|
|
5
|
+
"version": "3.0.2-patch.2",
|
|
6
6
|
"main": "dist/index.es.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
8
8
|
"exports": {
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"types": "./dist/formula.d.ts",
|
|
22
22
|
"default": "./dist/formula.js"
|
|
23
23
|
},
|
|
24
|
+
"./persistence": {
|
|
25
|
+
"import": "./dist/persistence.js",
|
|
26
|
+
"types": "./dist/persistence.d.ts",
|
|
27
|
+
"default": "./dist/persistence.js"
|
|
28
|
+
},
|
|
24
29
|
"./styles": "./dist/style.css",
|
|
25
30
|
"./types": "./dist/editor/types.d.ts"
|
|
26
31
|
},
|
|
@@ -37,7 +42,8 @@
|
|
|
37
42
|
"build:dist": "vite build",
|
|
38
43
|
"dev:link": "npm run build:dist && cp -r dist/* ../dsheets.new/node_modules/@fileverse-dev/dsheet/dist/ && echo '✓ Copied to dsheets.new'",
|
|
39
44
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
|
|
40
|
-
"preview": "vite preview"
|
|
45
|
+
"preview": "vite preview",
|
|
46
|
+
"test:unit": "vitest run"
|
|
41
47
|
},
|
|
42
48
|
"lint-staged": {
|
|
43
49
|
"**/*.{js,jsx,ts,tsx}": [
|
|
@@ -76,12 +82,12 @@
|
|
|
76
82
|
"tailwindcss-animate": "^1.0.7",
|
|
77
83
|
"tiny-emitter": "^2.1.0",
|
|
78
84
|
"uuid": "^8.3.2",
|
|
85
|
+
"viem": "^2.35.0",
|
|
79
86
|
"vite-plugin-dts": "^3.6.3",
|
|
80
87
|
"xlsx": "^0.18.5",
|
|
81
88
|
"xlsx-js-style": "^1.2.0",
|
|
82
89
|
"y-indexeddb": "^9.0.12",
|
|
83
|
-
"y-protocols": "^1.0.6"
|
|
84
|
-
"viem": "^2.35.0"
|
|
90
|
+
"y-protocols": "^1.0.6"
|
|
85
91
|
},
|
|
86
92
|
"peerDependencies": {
|
|
87
93
|
"yjs": ">=13.6.30 <14"
|
|
@@ -104,6 +110,7 @@
|
|
|
104
110
|
"eslint-plugin-prettier": "^5.2.1",
|
|
105
111
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
106
112
|
"eslint-plugin-react-refresh": "^0.4.4",
|
|
113
|
+
"fake-indexeddb": "^6.2.4",
|
|
107
114
|
"husky": "^9.1.7",
|
|
108
115
|
"lint-staged": "^15.2.10",
|
|
109
116
|
"postcss": "^8.4.38",
|
|
@@ -113,6 +120,7 @@
|
|
|
113
120
|
"tailwindcss": "^3.4.3",
|
|
114
121
|
"typescript": "^5.2.2",
|
|
115
122
|
"vite": "^5.0.0",
|
|
123
|
+
"vitest": "^3.2.4",
|
|
116
124
|
"yjs": "13.6.30"
|
|
117
125
|
}
|
|
118
126
|
}
|