@fileverse-dev/dsheet 4.0.3 → 4.0.5

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.
Files changed (41) hide show
  1. package/dist/{constants-Cdz6oSCq.js → constants-CRFfbkoQ.js} +1 -1
  2. package/dist/constants.js +1 -1
  3. package/dist/{crypto-constants-CqpCRs86.js → crypto-constants-ZTlAYRUf.js} +33 -22
  4. package/dist/editor/components/sidebar/use-right-panels.d.ts +1 -1
  5. package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
  6. package/dist/editor/hooks/use-celldata-compaction.d.ts +2 -3
  7. package/dist/editor/utils/compact-committed-celldata.d.ts +11 -10
  8. package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
  9. package/dist/editor/utils/import-compaction.d.ts +25 -0
  10. package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
  11. package/dist/editor/utils/xlsx-import-pipeline.d.ts +28 -0
  12. package/dist/{executeStringFunction-BQvE7aeV.js → executeStringFunction-B6fhDKyN.js} +7014 -6490
  13. package/dist/formula.js +1 -1
  14. package/dist/{index-CeTa91qc.js → index-BqGOKo9u.js} +15445 -14688
  15. package/dist/index.es.js +22 -22
  16. package/dist/sheet-engine/core/api/common.d.ts +1 -0
  17. package/dist/sheet-engine/core/context.d.ts +3 -1
  18. package/dist/sheet-engine/core/index.d.ts +2 -2
  19. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +11 -0
  20. package/dist/sheet-engine/core/modules/formula.d.ts +27 -0
  21. package/dist/sheet-engine/core/modules/index.d.ts +3 -2
  22. package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
  23. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +2 -0
  24. package/dist/sheet-engine/core/settings.d.ts +2 -0
  25. package/dist/sheet-engine/core/types.d.ts +21 -0
  26. package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
  27. package/dist/sheet-engine/react/components/Workbook/api.d.ts +1 -0
  28. package/dist/sheet-engine/react/components/Workbook/index.d.ts +1 -0
  29. package/dist/style.css +1 -1
  30. package/dist/{template-data-list-oP1s0Uxn.js → template-data-list-RKnVLsuf.js} +51 -50
  31. package/dist/use-xlsx-import-impl-Bddlxx23.js +1898 -0
  32. package/dist/worker/dsheet-worker-client.d.ts +14 -0
  33. package/dist/worker/dsheet-worker.d.ts +14 -0
  34. package/dist/xlsx-defined-names-DsWdNZw-.js +117 -0
  35. package/dist/xlsx-export-impl-DJiXCevi.js +831 -0
  36. package/dist/xlsx-hyperlink-inline-CTg4_gg1.js +2512 -0
  37. package/package.json +5 -4
  38. package/dist/use-xlsx-import-impl-BVsfV8ZV.js +0 -1572
  39. package/dist/xlsx-export-impl-Ber9FhFY.js +0 -3138
  40. package/dist/xlsx-hyperlink-inline-DzewAypN.js +0 -71
  41. package/dist/xlsx-image-utils-Cvg0qxRA.js +0 -126
@@ -0,0 +1,14 @@
1
+ import { DsheetWorkerApi } from './dsheet-worker';
2
+ import * as Comlink from 'comlink';
3
+ export type { DsheetWorkerApi };
4
+ export declare const isDsheetWorkerSupported: () => boolean;
5
+ export declare const terminateDsheetWorker: () => void;
6
+ /**
7
+ * Run a task on the shared dsheet worker. The worker is spawned lazily,
8
+ * reused across tasks, and terminated after 30s idle (a parse can hold
9
+ * hundreds of MB of transient allocations — terminating returns them to
10
+ * the OS immediately). Callers must handle rejection and fall back to the
11
+ * main-thread equivalent; a worker that failed is torn down so the next
12
+ * task starts from a fresh one.
13
+ */
14
+ export declare function runDsheetWorkerTask<T>(task: (api: Comlink.Remote<DsheetWorkerApi>) => Promise<T>): Promise<T>;
@@ -0,0 +1,14 @@
1
+ import { XlsxParseSettings, XlsxParsedWorkbook } from '../editor/utils/xlsx-import-pipeline';
2
+
3
+ /**
4
+ * The dsheet offload worker. One worker, many tasks: add new offloadable
5
+ * operations as methods on this object — the client (dsheet-worker-client)
6
+ * exposes them through the same Comlink proxy. Everything reachable from
7
+ * here must stay DOM/React/Yjs-free; the worker bundle is built standalone
8
+ * and inlined into the package, so main-bundle externals do not exist here.
9
+ */
10
+ declare const dsheetWorkerApi: {
11
+ parseXlsxWorkbook: (file: File, settings?: XlsxParseSettings) => Promise<XlsxParsedWorkbook>;
12
+ };
13
+ export type DsheetWorkerApi = typeof dsheetWorkerApi;
14
+ export {};
@@ -0,0 +1,117 @@
1
+ import { i as w } from "./executeStringFunction-B6fhDKyN.js";
2
+ import { J as x } from "./xlsx-hyperlink-inline-CTg4_gg1.js";
3
+ function g(o) {
4
+ return o.startsWith("_xlnm.");
5
+ }
6
+ function S(o) {
7
+ return /[^A-Za-z0-9_]/.test(o) ? `'${o.replace(/'/g, "''")}'` : o;
8
+ }
9
+ function p(o, e) {
10
+ return `$${w(e)}$${o + 1}`;
11
+ }
12
+ function I(o, e) {
13
+ const l = S(o), a = p(e.row[0], e.column[0]), n = p(e.row[1], e.column[1]), r = a === n ? a : `${a}:${n}`;
14
+ return `${l}!${r}`;
15
+ }
16
+ function $(o) {
17
+ const e = String(o || "").trim();
18
+ if (!e) return null;
19
+ let l = "", a = e;
20
+ const n = e.lastIndexOf("!");
21
+ if (n >= 0) {
22
+ let i = e.slice(0, n);
23
+ a = e.slice(n + 1), i.startsWith("'") && i.endsWith("'") && (i = i.slice(1, -1).replace(/''/g, "'")), l = i;
24
+ }
25
+ const r = a.split(":"), d = (i) => {
26
+ const t = i.trim().replace(/\$/g, "").match(/^([A-Za-z]+)(\d+)$/);
27
+ if (!t) return null;
28
+ const u = t[1].toUpperCase();
29
+ let m = 0;
30
+ for (let f = 0; f < u.length; f += 1)
31
+ m = m * 26 + (u.charCodeAt(f) - 64);
32
+ return { row: parseInt(t[2], 10) - 1, col: m - 1 };
33
+ }, c = d(r[0]);
34
+ if (!c) return null;
35
+ const s = r.length > 1 ? d(r[1]) : c;
36
+ return s ? {
37
+ sheetName: l,
38
+ range: {
39
+ row: [Math.min(c.row, s.row), Math.max(c.row, s.row)],
40
+ column: [Math.min(c.col, s.col), Math.max(c.col, s.col)]
41
+ }
42
+ } : null;
43
+ }
44
+ function b() {
45
+ return `dn_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
46
+ }
47
+ function k(o, e) {
48
+ var r, d, c, s, i;
49
+ const l = new Map(
50
+ e.filter((t) => t.id && t.name).map((t) => [String(t.name), t.id])
51
+ ), a = [], n = /* @__PURE__ */ new Set();
52
+ for (const t of o) {
53
+ if (!(t != null && t.name) || g(t.name) || n.has(t.name.toLowerCase())) continue;
54
+ const u = (r = t.ranges) == null ? void 0 : r[0];
55
+ if (!u) continue;
56
+ const m = $(u);
57
+ if (!m) continue;
58
+ let f = m.sheetName && l.get(m.sheetName) || void 0;
59
+ if (!f && t.localSheetId != null && ((d = e[t.localSheetId]) != null && d.id) && (f = e[t.localSheetId].id), !f && ((c = e[0]) != null && c.id) && (f = e[0].id), !f) continue;
60
+ const h = t.localSheetId != null && ((s = e[t.localSheetId]) != null && s.id) ? "sheet" : "workbook";
61
+ a.push({
62
+ id: b(),
63
+ name: t.name,
64
+ sheetId: f,
65
+ range: m.range,
66
+ scope: h,
67
+ localSheetId: h === "sheet" ? (i = e[t.localSheetId]) == null ? void 0 : i.id : void 0
68
+ }), n.add(t.name.toLowerCase());
69
+ }
70
+ return a;
71
+ }
72
+ function D(o, e, l) {
73
+ if (!(e != null && e.length)) return;
74
+ const a = new Map(
75
+ l.filter((n) => n.id && n.name).map((n) => [n.id, n.name])
76
+ );
77
+ for (const n of e) {
78
+ if (!(n != null && n.name) || g(n.name)) continue;
79
+ const r = a.get(n.sheetId);
80
+ if (r)
81
+ try {
82
+ o.definedNames.add(
83
+ I(r, n.range),
84
+ n.name
85
+ );
86
+ } catch {
87
+ }
88
+ }
89
+ }
90
+ async function A(o) {
91
+ var e;
92
+ try {
93
+ const l = await x.loadAsync(o), a = l.file("xl/workbook.xml") || ((e = l.file(/xl\/workbook\.xml$/i)) == null ? void 0 : e[0]) || null;
94
+ if (!a) return [];
95
+ const n = await a.async("text"), r = [], d = /<definedName\b([^>]*)>([\s\S]*?)<\/definedName>/gi;
96
+ let c = d.exec(n);
97
+ for (; c; ) {
98
+ const s = c[1] || "", i = (c[2] || "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').trim(), t = s.match(/\bname="([^"]+)"/i), u = s.match(/\blocalSheetId="(\d+)"/i), m = t == null ? void 0 : t[1];
99
+ m && i && r.push({
100
+ name: m,
101
+ ranges: [i],
102
+ localSheetId: u ? parseInt(u[1], 10) : void 0
103
+ }), c = d.exec(n);
104
+ }
105
+ return r;
106
+ } catch {
107
+ return [];
108
+ }
109
+ }
110
+ export {
111
+ D as applyDefinedNamesToExcelWorkbook,
112
+ I as encodeDefinedNameExcelRef,
113
+ k as excelEntriesToDefinedNames,
114
+ g as isExcelSystemDefinedName,
115
+ A as parseDefinedNamesFromXlsxBuffer,
116
+ $ as parseExcelDefinedNameRef
117
+ };