@ai-matrx/office 0.1.0 → 0.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ W1-G2a1. The Univer glue shared by Sheets and Docs moves in from matrx-frontend `lib/univer`.
6
+
7
+ - New `./univer` entry (client; loads `@univerjs/*`): `disposeUniverInstance`, `identifyUniverUser`, `isSnapshotMutation` / `isWorkbookSnapshotMutation`, `matrxImagePorts` + `resolveExportImage` + `uploadImportedImage`, `openEditorContent` (`registerOpenEditorContent`, `showSavedSnapshot`, `swapContentGuarded`), `registerMissingUniverIcons`, `registerUniverFacadeDependencies`, `routeUniverNotificationsToApp`, `resolveUniverCanvasColor`, `univerImageStore`, `useUniverDarkModeSync`. A transitional entry: it goes internal again when the two editors move into their sections.
8
+ - New `./univer/history` entry (pure): the `document-history` / `workbook-history` tab keys, `readHistoryTab`, `documentHistoryToggleInput`, `workbookHistoryToggleInput`. The two canvas-kind registrations stay in the host app (they lazy-load the views, so no import cycle).
9
+ - New host ports: `configureUniverHost({ toast, getSignedInUser, files, notifyUploadError, useThemeMode })`. Univer glue throws naming the port if an editor mounts before the host configured them.
10
+
11
+ ### Consumer action
12
+
13
+ Call `configureUniverHost(...)` once at start-up, before a workbook or document editor mounts. Replace `@/lib/univer/*` imports with `@ai-matrx/office/univer`, and `@/lib/univer/historyKinds` with `@ai-matrx/office/univer/history`.
14
+
3
15
  ## 0.1.0
4
16
 
5
17
  First release (W1-G1a). `/core`: editor menu model, ribbon model, Google parity rows, document page style, `PageSetup`, product hosts, Office row types. `/core/page-setup-apply`: Univer page-setup commands.
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/univer/history.ts
21
+ var history_exports = {};
22
+ __export(history_exports, {
23
+ DOCUMENT_HISTORY_KIND: () => DOCUMENT_HISTORY_KIND,
24
+ WORKBOOK_HISTORY_KIND: () => WORKBOOK_HISTORY_KIND,
25
+ documentHistoryToggleInput: () => documentHistoryToggleInput,
26
+ readHistoryTab: () => readHistoryTab,
27
+ workbookHistoryToggleInput: () => workbookHistoryToggleInput
28
+ });
29
+ module.exports = __toCommonJS(history_exports);
30
+ var DOCUMENT_HISTORY_KIND = "document-history";
31
+ var WORKBOOK_HISTORY_KIND = "workbook-history";
32
+ function readHistoryTab(data) {
33
+ if (typeof data !== "object" || data === null || Array.isArray(data)) return null;
34
+ const record = data;
35
+ const id = typeof record.id === "string" && record.id ? record.id : null;
36
+ if (!id) return null;
37
+ return { id, editable: record.editable !== false };
38
+ }
39
+ function subjectTitle(what, subject) {
40
+ const name = subject?.trim();
41
+ return name ? `${what} \xB7 ${name}` : what;
42
+ }
43
+ function documentHistoryToggleInput(documentId, editable, documentName) {
44
+ return {
45
+ kind: DOCUMENT_HISTORY_KIND,
46
+ key: documentId,
47
+ title: subjectTitle("Document history", documentName),
48
+ data: { id: documentId, editable },
49
+ followTitle: true
50
+ };
51
+ }
52
+ function workbookHistoryToggleInput(workbookId, editable, workbookName) {
53
+ return {
54
+ kind: WORKBOOK_HISTORY_KIND,
55
+ key: workbookId,
56
+ title: subjectTitle("Workbook history", workbookName),
57
+ data: { id: workbookId, editable },
58
+ followTitle: true
59
+ };
60
+ }
61
+ //# sourceMappingURL=univer-history.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/univer/history.ts"],"sourcesContent":["/**\n * A document's or a workbook's snapshot history as a canvas tab — the keys and toggle inputs the\n * editors use, and the reader the two history views use. One tab per document (`document-history`,\n * keyed by the document id) and per workbook (`workbook-history`, keyed by the workbook id).\n *\n * Pure: no React, no canvas package, no Univer. The two `defineCanvasKind` registrations stay with\n * the host app (matrx-frontend `features/canvas/host`) and lazy-load the views, so this module never\n * imports a view (the cycle the old `lib/univer/historyKinds.ts` closed).\n */\n\nexport const DOCUMENT_HISTORY_KIND = \"document-history\";\nexport const WORKBOOK_HISTORY_KIND = \"workbook-history\";\n\nexport interface HistoryTabData {\n id: string;\n editable: boolean;\n}\n\n/** Structurally the host's `ToolToggleInput` (the canvas toggle the editor's History button presses). */\nexport interface HistoryToggleInput {\n kind: string;\n key: string;\n title: string;\n data: { id: string; editable: boolean };\n followTitle: true;\n}\n\n/** A tab's data as a history subject, or null when it names no subject. */\nexport function readHistoryTab(data: unknown): HistoryTabData | null {\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) return null;\n const record = data as Record<string, unknown>;\n const id = typeof record.id === \"string\" && record.id ? record.id : null;\n if (!id) return null;\n return { id, editable: record.editable !== false };\n}\n\n/** \"<what> · <subject>\", or just \"<what>\" while the subject has no name. */\nfunction subjectTitle(what: string, subject: string | null | undefined): string {\n const name = subject?.trim();\n return name ? `${what} · ${name}` : what;\n}\n\n// The tab names its subject — two open history tabs never share a title, and\n// the editor that owns the toggle keeps it in step with a rename.\nexport function documentHistoryToggleInput(documentId: string, editable: boolean, documentName?: string | null): HistoryToggleInput {\n return {\n kind: DOCUMENT_HISTORY_KIND,\n key: documentId,\n title: subjectTitle(\"Document history\", documentName),\n data: { id: documentId, editable },\n followTitle: true,\n };\n}\n\nexport function workbookHistoryToggleInput(workbookId: string, editable: boolean, workbookName?: string | null): HistoryToggleInput {\n return {\n kind: WORKBOOK_HISTORY_KIND,\n key: workbookId,\n title: subjectTitle(\"Workbook history\", workbookName),\n data: { id: workbookId, editable },\n followTitle: true,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAiB9B,SAAS,eAAe,MAAsC;AACnE,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,IAAI,EAAG,QAAO;AAC7E,QAAM,SAAS;AACf,QAAM,KAAK,OAAO,OAAO,OAAO,YAAY,OAAO,KAAK,OAAO,KAAK;AACpE,MAAI,CAAC,GAAI,QAAO;AAChB,SAAO,EAAE,IAAI,UAAU,OAAO,aAAa,MAAM;AACnD;AAGA,SAAS,aAAa,MAAc,SAA4C;AAC9E,QAAM,OAAO,SAAS,KAAK;AAC3B,SAAO,OAAO,GAAG,IAAI,SAAM,IAAI,KAAK;AACtC;AAIO,SAAS,2BAA2B,YAAoB,UAAmB,cAAkD;AAClI,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO,aAAa,oBAAoB,YAAY;AAAA,IACpD,MAAM,EAAE,IAAI,YAAY,SAAS;AAAA,IACjC,aAAa;AAAA,EACf;AACF;AAEO,SAAS,2BAA2B,YAAoB,UAAmB,cAAkD;AAClI,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO,aAAa,oBAAoB,YAAY;AAAA,IACpD,MAAM,EAAE,IAAI,YAAY,SAAS;AAAA,IACjC,aAAa;AAAA,EACf;AACF;","names":[]}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * A document's or a workbook's snapshot history as a canvas tab — the keys and toggle inputs the
3
+ * editors use, and the reader the two history views use. One tab per document (`document-history`,
4
+ * keyed by the document id) and per workbook (`workbook-history`, keyed by the workbook id).
5
+ *
6
+ * Pure: no React, no canvas package, no Univer. The two `defineCanvasKind` registrations stay with
7
+ * the host app (matrx-frontend `features/canvas/host`) and lazy-load the views, so this module never
8
+ * imports a view (the cycle the old `lib/univer/historyKinds.ts` closed).
9
+ */
10
+ declare const DOCUMENT_HISTORY_KIND = "document-history";
11
+ declare const WORKBOOK_HISTORY_KIND = "workbook-history";
12
+ interface HistoryTabData {
13
+ id: string;
14
+ editable: boolean;
15
+ }
16
+ /** Structurally the host's `ToolToggleInput` (the canvas toggle the editor's History button presses). */
17
+ interface HistoryToggleInput {
18
+ kind: string;
19
+ key: string;
20
+ title: string;
21
+ data: {
22
+ id: string;
23
+ editable: boolean;
24
+ };
25
+ followTitle: true;
26
+ }
27
+ /** A tab's data as a history subject, or null when it names no subject. */
28
+ declare function readHistoryTab(data: unknown): HistoryTabData | null;
29
+ declare function documentHistoryToggleInput(documentId: string, editable: boolean, documentName?: string | null): HistoryToggleInput;
30
+ declare function workbookHistoryToggleInput(workbookId: string, editable: boolean, workbookName?: string | null): HistoryToggleInput;
31
+
32
+ export { DOCUMENT_HISTORY_KIND, type HistoryTabData, type HistoryToggleInput, WORKBOOK_HISTORY_KIND, documentHistoryToggleInput, readHistoryTab, workbookHistoryToggleInput };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * A document's or a workbook's snapshot history as a canvas tab — the keys and toggle inputs the
3
+ * editors use, and the reader the two history views use. One tab per document (`document-history`,
4
+ * keyed by the document id) and per workbook (`workbook-history`, keyed by the workbook id).
5
+ *
6
+ * Pure: no React, no canvas package, no Univer. The two `defineCanvasKind` registrations stay with
7
+ * the host app (matrx-frontend `features/canvas/host`) and lazy-load the views, so this module never
8
+ * imports a view (the cycle the old `lib/univer/historyKinds.ts` closed).
9
+ */
10
+ declare const DOCUMENT_HISTORY_KIND = "document-history";
11
+ declare const WORKBOOK_HISTORY_KIND = "workbook-history";
12
+ interface HistoryTabData {
13
+ id: string;
14
+ editable: boolean;
15
+ }
16
+ /** Structurally the host's `ToolToggleInput` (the canvas toggle the editor's History button presses). */
17
+ interface HistoryToggleInput {
18
+ kind: string;
19
+ key: string;
20
+ title: string;
21
+ data: {
22
+ id: string;
23
+ editable: boolean;
24
+ };
25
+ followTitle: true;
26
+ }
27
+ /** A tab's data as a history subject, or null when it names no subject. */
28
+ declare function readHistoryTab(data: unknown): HistoryTabData | null;
29
+ declare function documentHistoryToggleInput(documentId: string, editable: boolean, documentName?: string | null): HistoryToggleInput;
30
+ declare function workbookHistoryToggleInput(workbookId: string, editable: boolean, workbookName?: string | null): HistoryToggleInput;
31
+
32
+ export { DOCUMENT_HISTORY_KIND, type HistoryTabData, type HistoryToggleInput, WORKBOOK_HISTORY_KIND, documentHistoryToggleInput, readHistoryTab, workbookHistoryToggleInput };
@@ -0,0 +1,40 @@
1
+ // src/univer/history.ts
2
+ var DOCUMENT_HISTORY_KIND = "document-history";
3
+ var WORKBOOK_HISTORY_KIND = "workbook-history";
4
+ function readHistoryTab(data) {
5
+ if (typeof data !== "object" || data === null || Array.isArray(data)) return null;
6
+ const record = data;
7
+ const id = typeof record.id === "string" && record.id ? record.id : null;
8
+ if (!id) return null;
9
+ return { id, editable: record.editable !== false };
10
+ }
11
+ function subjectTitle(what, subject) {
12
+ const name = subject?.trim();
13
+ return name ? `${what} \xB7 ${name}` : what;
14
+ }
15
+ function documentHistoryToggleInput(documentId, editable, documentName) {
16
+ return {
17
+ kind: DOCUMENT_HISTORY_KIND,
18
+ key: documentId,
19
+ title: subjectTitle("Document history", documentName),
20
+ data: { id: documentId, editable },
21
+ followTitle: true
22
+ };
23
+ }
24
+ function workbookHistoryToggleInput(workbookId, editable, workbookName) {
25
+ return {
26
+ kind: WORKBOOK_HISTORY_KIND,
27
+ key: workbookId,
28
+ title: subjectTitle("Workbook history", workbookName),
29
+ data: { id: workbookId, editable },
30
+ followTitle: true
31
+ };
32
+ }
33
+ export {
34
+ DOCUMENT_HISTORY_KIND,
35
+ WORKBOOK_HISTORY_KIND,
36
+ documentHistoryToggleInput,
37
+ readHistoryTab,
38
+ workbookHistoryToggleInput
39
+ };
40
+ //# sourceMappingURL=univer-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/univer/history.ts"],"sourcesContent":["/**\n * A document's or a workbook's snapshot history as a canvas tab — the keys and toggle inputs the\n * editors use, and the reader the two history views use. One tab per document (`document-history`,\n * keyed by the document id) and per workbook (`workbook-history`, keyed by the workbook id).\n *\n * Pure: no React, no canvas package, no Univer. The two `defineCanvasKind` registrations stay with\n * the host app (matrx-frontend `features/canvas/host`) and lazy-load the views, so this module never\n * imports a view (the cycle the old `lib/univer/historyKinds.ts` closed).\n */\n\nexport const DOCUMENT_HISTORY_KIND = \"document-history\";\nexport const WORKBOOK_HISTORY_KIND = \"workbook-history\";\n\nexport interface HistoryTabData {\n id: string;\n editable: boolean;\n}\n\n/** Structurally the host's `ToolToggleInput` (the canvas toggle the editor's History button presses). */\nexport interface HistoryToggleInput {\n kind: string;\n key: string;\n title: string;\n data: { id: string; editable: boolean };\n followTitle: true;\n}\n\n/** A tab's data as a history subject, or null when it names no subject. */\nexport function readHistoryTab(data: unknown): HistoryTabData | null {\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) return null;\n const record = data as Record<string, unknown>;\n const id = typeof record.id === \"string\" && record.id ? record.id : null;\n if (!id) return null;\n return { id, editable: record.editable !== false };\n}\n\n/** \"<what> · <subject>\", or just \"<what>\" while the subject has no name. */\nfunction subjectTitle(what: string, subject: string | null | undefined): string {\n const name = subject?.trim();\n return name ? `${what} · ${name}` : what;\n}\n\n// The tab names its subject — two open history tabs never share a title, and\n// the editor that owns the toggle keeps it in step with a rename.\nexport function documentHistoryToggleInput(documentId: string, editable: boolean, documentName?: string | null): HistoryToggleInput {\n return {\n kind: DOCUMENT_HISTORY_KIND,\n key: documentId,\n title: subjectTitle(\"Document history\", documentName),\n data: { id: documentId, editable },\n followTitle: true,\n };\n}\n\nexport function workbookHistoryToggleInput(workbookId: string, editable: boolean, workbookName?: string | null): HistoryToggleInput {\n return {\n kind: WORKBOOK_HISTORY_KIND,\n key: workbookId,\n title: subjectTitle(\"Workbook history\", workbookName),\n data: { id: workbookId, editable },\n followTitle: true,\n };\n}\n"],"mappings":";AAUO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAiB9B,SAAS,eAAe,MAAsC;AACnE,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,IAAI,EAAG,QAAO;AAC7E,QAAM,SAAS;AACf,QAAM,KAAK,OAAO,OAAO,OAAO,YAAY,OAAO,KAAK,OAAO,KAAK;AACpE,MAAI,CAAC,GAAI,QAAO;AAChB,SAAO,EAAE,IAAI,UAAU,OAAO,aAAa,MAAM;AACnD;AAGA,SAAS,aAAa,MAAc,SAA4C;AAC9E,QAAM,OAAO,SAAS,KAAK;AAC3B,SAAO,OAAO,GAAG,IAAI,SAAM,IAAI,KAAK;AACtC;AAIO,SAAS,2BAA2B,YAAoB,UAAmB,cAAkD;AAClI,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO,aAAa,oBAAoB,YAAY;AAAA,IACpD,MAAM,EAAE,IAAI,YAAY,SAAS;AAAA,IACjC,aAAa;AAAA,EACf;AACF;AAEO,SAAS,2BAA2B,YAAoB,UAAmB,cAAkD;AAClI,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO,aAAa,oBAAoB,YAAY;AAAA,IACpD,MAAM,EAAE,IAAI,YAAY,SAAS;AAAA,IACjC,aAAa;AAAA,EACf;AACF;","names":[]}
@@ -0,0 +1,333 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/univer/index.ts
22
+ var univer_exports = {};
23
+ __export(univer_exports, {
24
+ DOCUMENT_HISTORY_KIND: () => DOCUMENT_HISTORY_KIND,
25
+ MATRX_IMAGE_PREFIX: () => MATRX_IMAGE_PREFIX,
26
+ MISSING_UNIVER_ICONS: () => MISSING_UNIVER_ICONS,
27
+ WORKBOOK_HISTORY_KIND: () => WORKBOOK_HISTORY_KIND,
28
+ configureUniverHost: () => configureUniverHost,
29
+ createMatrxImageStore: () => createMatrxImageStore,
30
+ disposeUniverInstance: () => disposeUniverInstance,
31
+ documentHistoryToggleInput: () => documentHistoryToggleInput,
32
+ getUniverHost: () => getUniverHost,
33
+ identifyUniverUser: () => identifyUniverUser,
34
+ isMatrxImageSource: () => isMatrxImageSource,
35
+ isSnapshotMutation: () => isSnapshotMutation,
36
+ isWorkbookSnapshotMutation: () => isWorkbookSnapshotMutation,
37
+ matrxImageFileId: () => matrxImageFileId,
38
+ matrxImagePorts: () => matrxImagePorts,
39
+ readHistoryTab: () => readHistoryTab,
40
+ registerMatrxImageStore: () => registerMatrxImageStore,
41
+ registerMissingUniverIcons: () => registerMissingUniverIcons,
42
+ registerOpenEditorContent: () => registerOpenEditorContent,
43
+ registerUniverFacadeDependencies: () => registerUniverFacadeDependencies,
44
+ releaseMatrxImageStore: () => releaseMatrxImageStore,
45
+ resolveExportImage: () => resolveExportImage,
46
+ resolveUniverCanvasColor: () => resolveUniverCanvasColor,
47
+ routeUniverNotificationsToApp: () => routeUniverNotificationsToApp,
48
+ showSavedSnapshot: () => showSavedSnapshot,
49
+ showUniverNotification: () => showUniverNotification,
50
+ swapContentGuarded: () => swapContentGuarded,
51
+ univerOwnerId: () => univerOwnerId,
52
+ uploadImportedImage: () => uploadImportedImage,
53
+ useUniverDarkModeSync: () => useUniverDarkModeSync,
54
+ workbookHistoryToggleInput: () => workbookHistoryToggleInput
55
+ });
56
+ module.exports = __toCommonJS(univer_exports);
57
+
58
+ // src/univer/ports.ts
59
+ var SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.office.univer-host");
60
+ var slot = () => {
61
+ const g = globalThis;
62
+ return g[SLOT] ??= {};
63
+ };
64
+ function configureUniverHost(ports) {
65
+ slot().ports = ports;
66
+ }
67
+ function getUniverHost() {
68
+ const ports = slot().ports;
69
+ if (!ports) throw new Error("@ai-matrx/office/univer: configureUniverHost(ports) was not called before an editor mounted.");
70
+ return ports;
71
+ }
72
+
73
+ // src/univer/history.ts
74
+ var DOCUMENT_HISTORY_KIND = "document-history";
75
+ var WORKBOOK_HISTORY_KIND = "workbook-history";
76
+ function readHistoryTab(data) {
77
+ if (typeof data !== "object" || data === null || Array.isArray(data)) return null;
78
+ const record = data;
79
+ const id = typeof record.id === "string" && record.id ? record.id : null;
80
+ if (!id) return null;
81
+ return { id, editable: record.editable !== false };
82
+ }
83
+ function subjectTitle(what, subject) {
84
+ const name = subject?.trim();
85
+ return name ? `${what} \xB7 ${name}` : what;
86
+ }
87
+ function documentHistoryToggleInput(documentId, editable, documentName) {
88
+ return {
89
+ kind: DOCUMENT_HISTORY_KIND,
90
+ key: documentId,
91
+ title: subjectTitle("Document history", documentName),
92
+ data: { id: documentId, editable },
93
+ followTitle: true
94
+ };
95
+ }
96
+ function workbookHistoryToggleInput(workbookId, editable, workbookName) {
97
+ return {
98
+ kind: WORKBOOK_HISTORY_KIND,
99
+ key: workbookId,
100
+ title: subjectTitle("Workbook history", workbookName),
101
+ data: { id: workbookId, editable },
102
+ followTitle: true
103
+ };
104
+ }
105
+
106
+ // src/univer/univerImageStore.ts
107
+ var import_core = require("@univerjs/core");
108
+ var MATRX_IMAGE_PREFIX = "matrx-file:";
109
+ var isMatrxImageSource = (source) => source.startsWith(MATRX_IMAGE_PREFIX);
110
+ var matrxImageFileId = (source) => source.slice(MATRX_IMAGE_PREFIX.length);
111
+ var ALLOWED = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp", "image/webp"];
112
+ function createMatrxImageStore(ports) {
113
+ const blobUrls = /* @__PURE__ */ new Map();
114
+ return {
115
+ /** Revoke every object URL this store made (the editor is going away). */
116
+ dispose() {
117
+ for (const pending of blobUrls.values()) void pending.then((url) => URL.revokeObjectURL(url), () => void 0);
118
+ blobUrls.clear();
119
+ },
120
+ async saveImage(file) {
121
+ if (!ALLOWED.includes(file.type)) throw new Error("ERROR_IMAGE_TYPE");
122
+ let fileId;
123
+ try {
124
+ ({ fileId } = await ports.upload(file));
125
+ } catch (error) {
126
+ ports.onUploadError(error);
127
+ throw error;
128
+ }
129
+ const source = MATRX_IMAGE_PREFIX + fileId;
130
+ const localUrl = URL.createObjectURL(file);
131
+ blobUrls.set(fileId, Promise.resolve(localUrl));
132
+ return {
133
+ imageId: (0, import_core.generateRandomId)(6),
134
+ imageSourceType: import_core.ImageSourceType.URL,
135
+ source,
136
+ base64Cache: localUrl,
137
+ status: import_core.ImageUploadStatusType.SUCCUSS
138
+ };
139
+ },
140
+ async download(url) {
141
+ if (!isMatrxImageSource(url)) return url;
142
+ const fileId = matrxImageFileId(url);
143
+ let pending = blobUrls.get(fileId);
144
+ if (!pending) {
145
+ pending = ports.getBlob(fileId).then((blob) => URL.createObjectURL(blob));
146
+ blobUrls.set(fileId, pending);
147
+ pending.catch(() => blobUrls.delete(fileId));
148
+ }
149
+ return pending;
150
+ }
151
+ };
152
+ }
153
+ var stores = /* @__PURE__ */ new WeakMap();
154
+ function releaseMatrxImageStore(injector) {
155
+ if (!injector) return;
156
+ stores.get(injector)?.dispose();
157
+ stores.delete(injector);
158
+ }
159
+ function registerMatrxImageStore(injector, ports) {
160
+ const store = createMatrxImageStore(ports);
161
+ stores.set(injector, store);
162
+ const io = injector.get(import_core.IImageIoService);
163
+ io.saveImage = store.saveImage;
164
+ const urls = injector.get(import_core.IURLImageService);
165
+ urls.registerURLImageDownloader(store.download);
166
+ }
167
+
168
+ // src/univer/disposeUniverInstance.ts
169
+ function disposeUniverInstance(instance) {
170
+ const target = instance;
171
+ if (!target) return;
172
+ const injector = target.__getInjector?.();
173
+ queueMicrotask(() => {
174
+ releaseMatrxImageStore(injector);
175
+ try {
176
+ target.dispose();
177
+ } catch {
178
+ }
179
+ });
180
+ }
181
+
182
+ // src/univer/identifyUniverUser.ts
183
+ var import_core2 = require("@univerjs/core");
184
+ async function identifyUniverUser(injector) {
185
+ const user = await getUniverHost().getSignedInUser();
186
+ if (!user?.id) return;
187
+ const meta = user.metadata ?? {};
188
+ const name = String(meta.full_name ?? meta.name ?? user.email ?? "You");
189
+ const users = injector.get(import_core2.UserManagerService);
190
+ users.setCurrentUser({ userID: univerOwnerId(user.id), name, avatar: String(meta.avatar_url ?? "") });
191
+ }
192
+ function univerOwnerId(userId) {
193
+ return `Owner_${userId}`;
194
+ }
195
+
196
+ // src/univer/isSnapshotMutation.ts
197
+ var MUTATION = 2;
198
+ var NON_CONTENT_ID_PATTERN = /(scroll|selection|set-selections|viewport|zoom|hover|cursor|focus|activate)/i;
199
+ function isSnapshotMutation(command) {
200
+ if (command.type !== MUTATION) return false;
201
+ if (NON_CONTENT_ID_PATTERN.test(command.id)) return false;
202
+ return true;
203
+ }
204
+ var WORKBOOK_SELF_MUTATION_PATTERN = /^(formula\.mutation\.[a-z-]*(calculation|trigger)[a-z-]*|doc\.mutation\.)/;
205
+ function isWorkbookSnapshotMutation(command) {
206
+ if (!isSnapshotMutation(command)) return false;
207
+ return !WORKBOOK_SELF_MUTATION_PATTERN.test(command.id);
208
+ }
209
+
210
+ // src/univer/matrxImagePorts.ts
211
+ var matrxImagePorts = {
212
+ async upload(file) {
213
+ return getUniverHost().files.upload(file);
214
+ },
215
+ getBlob(fileId) {
216
+ return getUniverHost().files.getBlob(fileId);
217
+ },
218
+ onUploadError(error) {
219
+ getUniverHost().notifyUploadError(error);
220
+ }
221
+ };
222
+ async function resolveExportImage(source) {
223
+ let blob;
224
+ if (isMatrxImageSource(source)) {
225
+ blob = await getUniverHost().files.getBlob(matrxImageFileId(source));
226
+ } else {
227
+ const res = await fetch(source);
228
+ if (!res.ok) return null;
229
+ blob = await res.blob();
230
+ }
231
+ const extension = blob.type.includes("gif") ? "gif" : blob.type.includes("png") ? "png" : "jpeg";
232
+ return { bytes: new Uint8Array(await blob.arrayBuffer()), extension };
233
+ }
234
+ async function uploadImportedImage(bytes, extension) {
235
+ const mime = extension === "jpg" ? "image/jpeg" : `image/${extension}`;
236
+ const { fileId } = await getUniverHost().files.upload(new File([bytes], `image.${extension}`, { type: mime }));
237
+ return fileId;
238
+ }
239
+
240
+ // src/univer/openEditorContent.ts
241
+ var replacers = /* @__PURE__ */ new Map();
242
+ var keyOf = (kind, recordId) => `${kind}:${recordId}`;
243
+ function registerOpenEditorContent(kind, recordId, replace) {
244
+ const key = keyOf(kind, recordId);
245
+ replacers.set(key, replace);
246
+ return () => {
247
+ if (replacers.get(key) === replace) replacers.delete(key);
248
+ };
249
+ }
250
+ async function showSavedSnapshot(kind, recordId, row) {
251
+ const replace = replacers.get(keyOf(kind, recordId));
252
+ if (!replace) return false;
253
+ await replace(row);
254
+ return true;
255
+ }
256
+ function swapContentGuarded(args) {
257
+ try {
258
+ args.swap(args.next);
259
+ return { ok: true };
260
+ } catch (error) {
261
+ let previousRestored = false;
262
+ if (args.previous) {
263
+ try {
264
+ args.swap(args.previous);
265
+ previousRestored = true;
266
+ } catch {
267
+ }
268
+ }
269
+ return { ok: false, error, previousRestored };
270
+ }
271
+ }
272
+
273
+ // src/univer/registerMissingUniverIcons.ts
274
+ var import_ui = require("@univerjs/ui");
275
+ var import_icons = require("@univerjs/icons");
276
+ var MISSING_UNIVER_ICONS = { AddImageIcon: import_icons.AddImageIcon };
277
+ function registerMissingUniverIcons(injector) {
278
+ const icons = injector.get(import_ui.IconManager);
279
+ icons.register({ ...MISSING_UNIVER_ICONS });
280
+ }
281
+
282
+ // src/univer/registerUniverFacadeDependencies.ts
283
+ function registerUniverFacadeDependencies(injector, dependencies) {
284
+ for (const dependency of dependencies) {
285
+ if (!injector.has(dependency)) injector.add([dependency]);
286
+ }
287
+ }
288
+
289
+ // src/univer/routeUniverNotificationsToApp.ts
290
+ var import_core3 = require("@univerjs/core");
291
+ var import_ui2 = require("@univerjs/ui");
292
+ function showUniverNotification(params) {
293
+ const title = typeof params.title === "string" ? params.title : String(params.title ?? "");
294
+ const options = {
295
+ ...params.content ? { description: params.content } : {},
296
+ ...params.duration !== void 0 ? { duration: params.duration } : {}
297
+ };
298
+ const kind = params.type ?? "message";
299
+ const { toast } = getUniverHost();
300
+ const show = kind === "loading" ? toast.message : toast[kind];
301
+ const id = show(title, options);
302
+ return (0, import_core3.toDisposable)(() => toast.dismiss(id));
303
+ }
304
+ function routeUniverNotificationsToApp(injector) {
305
+ if (!injector || typeof injector.replace !== "function") {
306
+ return { applied: false, reason: "injector has no replace()" };
307
+ }
308
+ try {
309
+ injector.replace([import_ui2.INotificationService, { useValue: { show: showUniverNotification } }]);
310
+ return { applied: true };
311
+ } catch (err) {
312
+ return { applied: false, reason: err instanceof Error ? err.message : String(err) };
313
+ }
314
+ }
315
+
316
+ // src/univer/univer-theme-token-color.ts
317
+ var THEME_TOKEN = /^[a-zA-Z]+\.[a-zA-Z0-9]+$/;
318
+ function resolveUniverCanvasColor(color, lookup) {
319
+ if (!THEME_TOKEN.test(color)) return color;
320
+ const resolved = lookup(color);
321
+ return typeof resolved === "string" && resolved.length > 0 ? resolved : color;
322
+ }
323
+
324
+ // src/univer/useUniverDarkModeSync.ts
325
+ var import_react = require("react");
326
+ function useUniverDarkModeSync(apiRef, ready) {
327
+ const mode = getUniverHost().useThemeMode();
328
+ (0, import_react.useEffect)(() => {
329
+ if (!ready || !apiRef.current) return;
330
+ apiRef.current.toggleDarkMode(mode === "dark");
331
+ }, [apiRef, ready, mode]);
332
+ }
333
+ //# sourceMappingURL=univer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/univer/index.ts","../src/univer/ports.ts","../src/univer/history.ts","../src/univer/univerImageStore.ts","../src/univer/disposeUniverInstance.ts","../src/univer/identifyUniverUser.ts","../src/univer/isSnapshotMutation.ts","../src/univer/matrxImagePorts.ts","../src/univer/openEditorContent.ts","../src/univer/registerMissingUniverIcons.ts","../src/univer/registerUniverFacadeDependencies.ts","../src/univer/routeUniverNotificationsToApp.ts","../src/univer/univer-theme-token-color.ts","../src/univer/useUniverDarkModeSync.ts"],"sourcesContent":["/**\n * The Univer glue shared by `/sheets` and `/docs` (was matrx-frontend `lib/univer`). A transitional\n * subpath: matrx-frontend's two editors import it until they move into their sections, then this\n * entry goes internal again (BUILD-BOOK §1.3, Amendments W1-G2a1). Importing it loads `@univerjs/*`;\n * the pure history keys are their own entry (`./univer/history`) for code that must not.\n */\nexport * from \"./ports\";\nexport * from \"./history\";\nexport * from \"./disposeUniverInstance\";\nexport * from \"./identifyUniverUser\";\nexport * from \"./isSnapshotMutation\";\nexport * from \"./matrxImagePorts\";\nexport * from \"./openEditorContent\";\nexport * from \"./registerMissingUniverIcons\";\nexport * from \"./registerUniverFacadeDependencies\";\nexport * from \"./routeUniverNotificationsToApp\";\nexport * from \"./univer-theme-token-color\";\nexport * from \"./univerImageStore\";\nexport * from \"./useUniverDarkModeSync\";\n","/**\n * The host ports of the Univer glue.\n *\n * The glue belongs to the package, but four things belong to the app that mounts an editor: the\n * toast path, the signed-in person, the file store and the painted theme. The host states them\n * once at start-up with `configureUniverHost`; the glue reads them here. State sits on a\n * `globalThis` slot so a dual-bundled copy of the package still sees one host (dual-bundle rule).\n * An unconfigured port THROWS naming the port (nothing fails silently).\n */\n\nexport type UniverToastId = string | number;\ntype ToastShow = (title: string, options?: { description?: string; duration?: number }) => UniverToastId;\n\nexport interface UniverHostPorts {\n /** The app's toast path (one toaster per page). */\n toast: {\n success: ToastShow;\n info: ToastShow;\n warning: ToastShow;\n error: ToastShow;\n message: ToastShow;\n dismiss(id: UniverToastId): void;\n };\n /** Who is typing, or null when signed out. `metadata` is the auth user's metadata bag. */\n getSignedInUser(): Promise<{ id: string; email?: string | null; metadata?: Record<string, unknown> | null } | null>;\n /** The file store behind pictures on a sheet or in a document. */\n files: {\n upload(file: File): Promise<{ fileId: string }>;\n getBlob(fileId: string): Promise<Blob>;\n };\n /** Tell the person a picture did not upload. */\n notifyUploadError(error: unknown): void;\n /** The painted colour mode, as a React hook (re-renders on a switch). */\n useThemeMode(): \"light\" | \"dark\";\n}\n\nconst SLOT = Symbol.for(\"ai-matrx.office.univer-host\");\ntype Slot = { ports?: UniverHostPorts };\nconst slot = (): Slot => {\n const g = globalThis as Record<symbol, Slot | undefined>;\n return (g[SLOT] ??= {});\n};\n\nexport function configureUniverHost(ports: UniverHostPorts): void {\n slot().ports = ports;\n}\n\nexport function getUniverHost(): UniverHostPorts {\n const ports = slot().ports;\n if (!ports) throw new Error(\"@ai-matrx/office/univer: configureUniverHost(ports) was not called before an editor mounted.\");\n return ports;\n}\n","/**\n * A document's or a workbook's snapshot history as a canvas tab — the keys and toggle inputs the\n * editors use, and the reader the two history views use. One tab per document (`document-history`,\n * keyed by the document id) and per workbook (`workbook-history`, keyed by the workbook id).\n *\n * Pure: no React, no canvas package, no Univer. The two `defineCanvasKind` registrations stay with\n * the host app (matrx-frontend `features/canvas/host`) and lazy-load the views, so this module never\n * imports a view (the cycle the old `lib/univer/historyKinds.ts` closed).\n */\n\nexport const DOCUMENT_HISTORY_KIND = \"document-history\";\nexport const WORKBOOK_HISTORY_KIND = \"workbook-history\";\n\nexport interface HistoryTabData {\n id: string;\n editable: boolean;\n}\n\n/** Structurally the host's `ToolToggleInput` (the canvas toggle the editor's History button presses). */\nexport interface HistoryToggleInput {\n kind: string;\n key: string;\n title: string;\n data: { id: string; editable: boolean };\n followTitle: true;\n}\n\n/** A tab's data as a history subject, or null when it names no subject. */\nexport function readHistoryTab(data: unknown): HistoryTabData | null {\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) return null;\n const record = data as Record<string, unknown>;\n const id = typeof record.id === \"string\" && record.id ? record.id : null;\n if (!id) return null;\n return { id, editable: record.editable !== false };\n}\n\n/** \"<what> · <subject>\", or just \"<what>\" while the subject has no name. */\nfunction subjectTitle(what: string, subject: string | null | undefined): string {\n const name = subject?.trim();\n return name ? `${what} · ${name}` : what;\n}\n\n// The tab names its subject — two open history tabs never share a title, and\n// the editor that owns the toggle keeps it in step with a rename.\nexport function documentHistoryToggleInput(documentId: string, editable: boolean, documentName?: string | null): HistoryToggleInput {\n return {\n kind: DOCUMENT_HISTORY_KIND,\n key: documentId,\n title: subjectTitle(\"Document history\", documentName),\n data: { id: documentId, editable },\n followTitle: true,\n };\n}\n\nexport function workbookHistoryToggleInput(workbookId: string, editable: boolean, workbookName?: string | null): HistoryToggleInput {\n return {\n kind: WORKBOOK_HISTORY_KIND,\n key: workbookId,\n title: subjectTitle(\"Workbook history\", workbookName),\n data: { id: workbookId, editable },\n followTitle: true,\n };\n}\n","/**\n * univerImageStore — images on a sheet or in a document live in OUR file\n * store; the Univer snapshot holds only a reference (`matrx-file:<fileId>`).\n *\n * Why: Univer's stock image service inlines every picture as base64 into the\n * snapshot, so one 2 MB photo made every autosave, history row and collab\n * mutation ~2 MB. Here `saveImage` uploads the file and hands Univer a URL-type\n * source; Univer's URL-image downloader turns the reference back into bytes\n * (`getBlob` → object URL) when it paints. Images already inline (BASE64\n * sources) are untouched and keep rendering.\n */\n\nimport {\n IImageIoService,\n IURLImageService,\n ImageSourceType,\n ImageUploadStatusType,\n generateRandomId,\n} from \"@univerjs/core\";\n\nexport const MATRX_IMAGE_PREFIX = \"matrx-file:\";\n\nexport const isMatrxImageSource = (source: string): boolean =>\n source.startsWith(MATRX_IMAGE_PREFIX);\n\nexport const matrxImageFileId = (source: string): string =>\n source.slice(MATRX_IMAGE_PREFIX.length);\n\nexport type ImageStorePorts = {\n upload(file: File): Promise<{ fileId: string }>;\n getBlob(fileId: string): Promise<Blob>;\n /** Called when an upload fails, so the person is told (never silent). */\n onUploadError(error: unknown): void;\n};\n\nconst ALLOWED = [\"image/png\", \"image/jpeg\", \"image/jpg\", \"image/gif\", \"image/bmp\", \"image/webp\"];\n\ntype ImageIo = {\n saveImage(file: File): Promise<unknown>;\n};\ntype UrlImages = {\n registerURLImageDownloader(d: (url: string) => Promise<string>): { dispose(): void };\n};\ntype InjectorLike = { get(id: unknown): unknown };\n\n/** Pure core: the two replacements, given ports. */\nexport function createMatrxImageStore(ports: ImageStorePorts) {\n const blobUrls = new Map<string, Promise<string>>();\n return {\n /** Revoke every object URL this store made (the editor is going away). */\n dispose() {\n for (const pending of blobUrls.values()) void pending.then((url) => URL.revokeObjectURL(url), () => undefined);\n blobUrls.clear();\n },\n async saveImage(file: File) {\n if (!ALLOWED.includes(file.type)) throw new Error(\"ERROR_IMAGE_TYPE\");\n let fileId: string;\n try {\n ({ fileId } = await ports.upload(file));\n } catch (error) {\n ports.onUploadError(error);\n throw error;\n }\n const source = MATRX_IMAGE_PREFIX + fileId;\n // Univer measures the picture from base64Cache before it inserts (an empty one throws, nothing is\n // inserted). A blob URL of the file just chosen serves that and paints it; it is never saved.\n const localUrl = URL.createObjectURL(file);\n blobUrls.set(fileId, Promise.resolve(localUrl));\n return {\n imageId: generateRandomId(6),\n imageSourceType: ImageSourceType.URL,\n source,\n base64Cache: localUrl,\n status: ImageUploadStatusType.SUCCUSS,\n };\n },\n async download(url: string): Promise<string> {\n if (!isMatrxImageSource(url)) return url;\n const fileId = matrxImageFileId(url);\n let pending = blobUrls.get(fileId);\n if (!pending) {\n pending = ports.getBlob(fileId).then((blob) => URL.createObjectURL(blob));\n blobUrls.set(fileId, pending);\n pending.catch(() => blobUrls.delete(fileId));\n }\n return pending;\n },\n };\n}\n\nconst stores = new WeakMap<object, { dispose(): void }>();\n\n/** Release the object URLs of the store wired into this Univer instance (call as the instance is disposed). */\nexport function releaseMatrxImageStore(injector: object | null | undefined): void {\n if (!injector) return;\n stores.get(injector)?.dispose();\n stores.delete(injector);\n}\n\n/** Wire the store into one Univer instance's image services. */\nexport function registerMatrxImageStore(injector: InjectorLike, ports: ImageStorePorts): void {\n const store = createMatrxImageStore(ports);\n stores.set(injector, store);\n const io = injector.get(IImageIoService) as ImageIo;\n io.saveImage = store.saveImage as ImageIo[\"saveImage\"];\n const urls = injector.get(IURLImageService) as UrlImages;\n urls.registerURLImageDownloader(store.download);\n}\n","import { releaseMatrxImageStore } from \"./univerImageStore\";\n\n/** Univer owns React roots; synchronous dispose during React commit causes races. */\nexport function disposeUniverInstance(\n instance: { dispose(): void } | null | undefined,\n): void {\n const target = instance;\n if (!target) return;\n const injector = (target as { __getInjector?: () => object }).__getInjector?.();\n queueMicrotask(() => {\n releaseMatrxImageStore(injector);\n try {\n target.dispose();\n } catch {\n // Instance may already be torn down by a concurrent unmount.\n }\n });\n}\n","import { UserManagerService } from \"@univerjs/core\";\nimport { getUniverHost } from \"./ports\";\n\ntype InjectorLike = { get(id: unknown): unknown };\n\n/**\n * Tell Univer who is typing, so a comment thread is attributed to the\n * signed-in person instead of Univer's placeholder owner.\n *\n * The userID MUST keep the `Owner_` prefix: Univer's built-in local\n * permission service grants unit roles by user-id prefix (`isDevRole`), so a\n * bare uuid gets no role and every edit is refused as \"range is protected\".\n * Our own access (canActOn) decides editability; Univer must always see an\n * owner. Guarded by identify-univer-user-keeps-owner-role.test.ts.\n */\nexport async function identifyUniverUser(injector: InjectorLike): Promise<void> {\n const user = await getUniverHost().getSignedInUser();\n if (!user?.id) return;\n const meta = (user.metadata ?? {}) as Record<string, unknown>;\n const name = String(meta.full_name ?? meta.name ?? user.email ?? \"You\");\n const users = injector.get(UserManagerService) as {\n setCurrentUser(u: { userID: string; name: string; avatar: string }): void;\n };\n users.setCurrentUser({ userID: univerOwnerId(user.id), name, avatar: String(meta.avatar_url ?? \"\") });\n}\n\n/** Univer's local permission service reads the role from this prefix. */\nexport function univerOwnerId(userId: string): string {\n return `Owner_${userId}`;\n}\n","/**\n * isSnapshotMutation — the autosave dirty-filter for the Univer editors.\n *\n * D97: `onCommandExecuted` fires for EVERY command — including viewport\n * scrolls and selection moves — so an unfiltered listener marked the doc\n * dirty on mere scrolling and wrote a new snapshot row (version history +\n * collab broadcast) 2.5s later. Only CommandType.MUTATION changes the data\n * that a snapshot persists (Univer's own docs: OPERATION = \"not saved to\n * snapshot, such as modifying scroll position\"). We therefore accept ONLY\n * mutations, and additionally deny-list any mutation whose id marks it as\n * scroll / selection / viewport bookkeeping, belt-and-braces.\n */\nimport type { ICommandInfo } from \"@univerjs/core\";\n\n/**\n * Univer's `CommandType.MUTATION`. A literal, so this filter (and the document\n * model that uses it outside the editor chunk) never pulls Univer's runtime —\n * which touches `window` at import — into a server-rendered chunk.\n */\nconst MUTATION = 2;\n\n/** Non-content command ids that must never mark the document dirty. */\nconst NON_CONTENT_ID_PATTERN =\n /(scroll|selection|set-selections|viewport|zoom|hover|cursor|focus|activate)/i;\n\nexport function isSnapshotMutation(command: ICommandInfo): boolean {\n if (command.type !== MUTATION) return false;\n if (NON_CONTENT_ID_PATTERN.test(command.id)) return false;\n return true;\n}\n\n/**\n * Mutations a SPREADSHEET fires on its own while it opens and recalculates —\n * they change nothing the person typed, so they must never mark the workbook\n * dirty. Observed on a plain open of a workbook with formulas (2026-10-10):\n * `formula.mutation.set-trigger-formula-calculation-start`,\n * `...set-formula-calculation-start`, `...set-formula-calculation-notification`\n * and a `doc.mutation.rich-text-editing` from the internal cell-editor document.\n * Each open then wrote a new snapshot (history bloat, and a false \"both changed\"\n * against Google). A real edit always arrives as a `sheet.mutation.*`.\n */\nconst WORKBOOK_SELF_MUTATION_PATTERN =\n /^(formula\\.mutation\\.[a-z-]*(calculation|trigger)[a-z-]*|doc\\.mutation\\.)/;\n\nexport function isWorkbookSnapshotMutation(command: ICommandInfo): boolean {\n if (!isSnapshotMutation(command)) return false;\n return !WORKBOOK_SELF_MUTATION_PATTERN.test(command.id);\n}\n","import { getUniverHost } from \"./ports\";\nimport { isMatrxImageSource, matrxImageFileId, type ImageStorePorts } from \"./univerImageStore\";\n\n/** The real file-store ports (the host's): upload, read back as a blob, tell the person on failure. */\nexport const matrxImagePorts: ImageStorePorts = {\n async upload(file) {\n return getUniverHost().files.upload(file);\n },\n getBlob(fileId) {\n return getUniverHost().files.getBlob(fileId);\n },\n onUploadError(error) {\n getUniverHost().notifyUploadError(error);\n },\n};\n\n/** Export: a snapshot picture source (`matrx-file:<id>` or a URL) as bytes + type, or null if unreadable. */\nexport async function resolveExportImage(\n source: string,\n): Promise<{ bytes: Uint8Array; extension: \"png\" | \"jpeg\" | \"gif\" } | null> {\n let blob: Blob;\n if (isMatrxImageSource(source)) {\n blob = await getUniverHost().files.getBlob(matrxImageFileId(source));\n } else {\n const res = await fetch(source);\n if (!res.ok) return null;\n blob = await res.blob();\n }\n const extension = blob.type.includes(\"gif\") ? \"gif\" : blob.type.includes(\"png\") ? \"png\" : \"jpeg\";\n return { bytes: new Uint8Array(await blob.arrayBuffer()), extension };\n}\n\n/** Import: store a picture from a file, return its file id. */\nexport async function uploadImportedImage(bytes: Uint8Array, extension: string): Promise<string> {\n const mime = extension === \"jpg\" ? \"image/jpeg\" : `image/${extension}`;\n const { fileId } = await getUniverHost().files.upload(new File([bytes as BlobPart], `image.${extension}`, { type: mime }));\n return fileId;\n}\n","/**\n * THE ONE way to replace the whole content of an open Univer editor\n * (workbook or document) with a snapshot that is already SAVED: a history\n * restore, \"Update from Google\" / \"Use Google's\", and a collaborator's\n * replacement all arrive here.\n *\n * Callers save first, then call `showSavedSnapshot`. The open editor for that\n * record (registered below) swaps its content in place, drops its pending\n * autosave (it would write the old content back over the new one), and — in\n * a collab room — tells every peer to reload the same snapshot. A caller\n * never touches Univer units itself: disposing the current unit by hand left\n * Univer's selection observers pointing at nothing (`getUnitId` of null).\n *\n * Pure registry (no Univer import), so it is testable without booting Univer.\n */\n\nexport type EditorRecordKind = \"workbook\" | \"document\";\n\n/** A snapshot row as stored: its id and the Univer body. */\nexport type SavedEditorSnapshot = { id: string; snapshot: unknown };\n\nexport type EditorContentReplacer = (row: SavedEditorSnapshot) => void | Promise<void>;\n\nconst replacers = new Map<string, EditorContentReplacer>();\n\nconst keyOf = (kind: EditorRecordKind, recordId: string) => `${kind}:${recordId}`;\n\n/**\n * The open editor of a record lends its replacer while it is mounted. The\n * newest registration wins; the returned release only removes its own.\n */\nexport function registerOpenEditorContent(\n kind: EditorRecordKind,\n recordId: string,\n replace: EditorContentReplacer,\n): () => void {\n const key = keyOf(kind, recordId);\n replacers.set(key, replace);\n return () => {\n if (replacers.get(key) === replace) replacers.delete(key);\n };\n}\n\n/**\n * Show a saved snapshot in the record's open editor (and its collab peers).\n * Returns false when no editor of the record is open in this tab — the saved\n * row then simply is the content the next open loads.\n */\nexport async function showSavedSnapshot(\n kind: EditorRecordKind,\n recordId: string,\n row: SavedEditorSnapshot,\n): Promise<boolean> {\n const replace = replacers.get(keyOf(kind, recordId));\n if (!replace) return false;\n await replace(row);\n return true;\n}\n\n/**\n * THE CONTENT-SWAP GUARD. A swap is dispose-then-create; if the create throws, the unit is gone and\n * the grid would stay blank. `swap(snapshot)` is the editor's own dispose+create (it disposes\n * whatever unit is open, if any). On a throw this puts the content that was open before straight\n * back (synchronously — never a blank grid) and says so; the editor then reloads the latest SAVED\n * version and still raises the original error, so the person is told.\n */\nexport function swapContentGuarded(args: {\n swap: (snapshot: unknown) => void;\n next: unknown;\n /** What was open before (`workbook.save()` taken before the swap), or null when nothing was. */\n previous: unknown | null;\n}): { ok: true } | { ok: false; error: unknown; previousRestored: boolean } {\n try {\n args.swap(args.next);\n return { ok: true };\n } catch (error) {\n let previousRestored = false;\n if (args.previous) {\n try {\n args.swap(args.previous);\n previousRestored = true;\n } catch {\n /* the latest saved version is tried next, by the caller */\n }\n }\n return { ok: false, error, previousRestored };\n }\n}\n","\"use client\";\n\n/**\n * Univer's drawing UI names `AddImageIcon` on its Insert-image menu items but\n * never registers it (upstream gap), so the icon manager logs \"Icon AddImageIcon\n * does not exist\" on every editor load. Register it ourselves, right after\n * `createUniver`, so the toolbar draws a real icon and the console stays clean.\n */\n\nimport { IconManager } from \"@univerjs/ui\";\nimport { AddImageIcon } from \"@univerjs/icons\";\n\ntype InjectorLike = { get(id: unknown): unknown };\n\n/** Icons Univer's own plugins reference but do not register. */\nexport const MISSING_UNIVER_ICONS = { AddImageIcon } as const;\n\nexport function registerMissingUniverIcons(injector: InjectorLike): void {\n const icons = injector.get(IconManager) as {\n register(icons: Record<string, unknown>): unknown;\n };\n icons.register({ ...MISSING_UNIVER_ICONS });\n}\n","type UniverDependency = new (...args: never[]) => unknown;\n\ntype UniverInjector = {\n has(dependency: UniverDependency): boolean;\n add(dependency: [UniverDependency]): void;\n};\n\n/**\n * Register services required by process-global Univer Facade observers.\n *\n * Facade modules can outlive the editor type that first imported them, so a\n * later Univer instance may receive their lifecycle callbacks without loading\n * that type's plugins. Registration is intentionally narrow: callers name only\n * the observer dependencies that are safe for their instance.\n */\nexport function registerUniverFacadeDependencies(\n injector: UniverInjector,\n dependencies: readonly UniverDependency[],\n): void {\n for (const dependency of dependencies) {\n if (!injector.has(dependency)) injector.add([dependency]);\n }\n}\n","\"use client\";\n\n/**\n * Univer's notifications go through the APP's toast path — one toaster per page.\n *\n * Univer's own `DesktopNotificationService` mounts a second sonner `<Toaster>`\n * into its workbench the moment it is created. sonner's toast store is global,\n * so with the app's Toaster also mounted every toast (ours and Univer's) showed\n * twice on a workbook or document page. Replacing the service before anything\n * resolves it means Univer never mounts that Toaster, and what Univer has to\n * say (clipboard permission, paste limits) reaches the person through\n * the host's toast port like every other message (tracked, Error Inspector, Alchemy).\n *\n * Call right after `createUniver`, before the first unit is created.\n */\n\nimport { toDisposable, type IDisposable } from \"@univerjs/core\";\nimport { INotificationService } from \"@univerjs/ui\";\n\nimport { getUniverHost } from \"./ports\";\n\ntype UniverNotification = {\n title: unknown;\n content?: string;\n type?: \"success\" | \"info\" | \"warning\" | \"error\" | \"message\" | \"loading\";\n duration?: number;\n};\n\nexport interface NotificationReplaceableInjector {\n replace?: (dependency: [unknown, unknown]) => void;\n}\n\n/** Show one Univer notification as an app toast; dismissing the disposable removes it. */\nexport function showUniverNotification(params: UniverNotification): IDisposable {\n const title = typeof params.title === \"string\" ? params.title : String(params.title ?? \"\");\n const options = {\n ...(params.content ? { description: params.content } : {}),\n ...(params.duration !== undefined ? { duration: params.duration } : {}),\n };\n const kind = params.type ?? \"message\";\n const { toast } = getUniverHost();\n const show = kind === \"loading\" ? toast.message : toast[kind];\n const id = show(title, options) as string | number;\n return toDisposable(() => toast.dismiss(id));\n}\n\nexport function routeUniverNotificationsToApp(\n injector: NotificationReplaceableInjector | null | undefined,\n): { applied: boolean; reason?: string } {\n if (!injector || typeof injector.replace !== \"function\") {\n return { applied: false, reason: \"injector has no replace()\" };\n }\n try {\n injector.replace([INotificationService, { useValue: { show: showUniverNotification } }]);\n return { applied: true };\n } catch (err) {\n return { applied: false, reason: err instanceof Error ? err.message : String(err) };\n }\n}\n","/**\n * Resolve a colour Univer hands its canvas — WITHOUT the dark-mode inversion.\n *\n * Univer 1.0 writes many of its own fills as THEME TOKENS, not colours: the\n * page is `\"gray.0\"`, the desk `\"gray.100\"`, the page outline `\"gray.200\"`,\n * default ink `\"gray.900\"` (engine-render 1.0.2 `DocBackground`, docs-ui\n * `resolveDocRenderBackground`). Its `CanvasColorService` turns a token into a\n * colour before anything reaches `ctx.fillStyle`; its `DumbCanvasColorService`\n * does NOT — it returns `\"gray.0\"` as-is. A canvas IGNORES a `fillStyle` it\n * cannot parse and keeps the previous one, which starts as `#000000`, so with\n * the dumb service every page came out solid black and the canvas element's\n * CSS background (`style.backgroundColor = \"gray.100\"`, also ignored) stayed\n * transparent — in every browser, headed or headless, light or dark.\n *\n * Pure (no Univer import) so the jest test and `check:univer-doc-theme` drive\n * the same function the editor installs.\n */\n\n/** `palette.shade` — the shape Univer's theme tokens take (`gray.0`, `primary.600`). */\nconst THEME_TOKEN = /^[a-zA-Z]+\\.[a-zA-Z0-9]+$/;\n\n/**\n * @param color What Univer is about to paint: a theme token or a real colour.\n * @param lookup The live theme (`ThemeService.getColorFromTheme`).\n * @returns the token's colour from the current theme; anything else unchanged.\n */\nexport function resolveUniverCanvasColor(\n color: string,\n lookup: (token: string) => unknown,\n): string {\n if (!THEME_TOKEN.test(color)) return color;\n const resolved = lookup(color);\n return typeof resolved === \"string\" && resolved.length > 0 ? resolved : color;\n}\n","/**\n * useUniverDarkModeSync — keep a Univer instance's dark mode in lockstep with\n * the app's painted theme (`<html class=\"dark\">` via `useThemeMode`).\n *\n * Univer owns its own theming (see https://docs.univer.ai/guides/docs/ui/themes):\n * you boot it with `theme` + `darkMode`, then flip dark mode at runtime via the\n * Facade API `univerAPI.toggleDarkMode(isDark)`. This is the ONLY supported way\n * to theme Univer — do NOT try to force it with a `colorScheme` CSS override on\n * a wrapper (that just fights Univer's own popups/portals and breaks dark mode).\n *\n * Shared by every Univer surface (DocumentEditor, WorkbookEditor) so the\n * theme→Univer bridge lives in exactly one place.\n */\n\"use client\";\n\nimport { useEffect } from \"react\";\nimport type { FUniver } from \"@univerjs/presets\";\n\nimport { getUniverHost } from \"./ports\";\n\n/**\n * @param apiRef Ref holding the Univer Facade API (set once the instance boots).\n * @param ready True once the instance is booted and the API is usable.\n */\nexport function useUniverDarkModeSync(\n apiRef: React.RefObject<FUniver | null>,\n ready: boolean,\n): void {\n const mode = getUniverHost().useThemeMode();\n\n useEffect(() => {\n if (!ready || !apiRef.current) return;\n apiRef.current.toggleDarkMode(mode === \"dark\");\n }, [apiRef, ready, mode]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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