@ai-matrx/office 0.8.63 → 0.8.65

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/univer/collab/realtime.ts","../src/univer/collab/useWorkbookRealtime.ts","../src/univer/ports.ts"],"sourcesContent":["/**\n * @ai-matrx/office/univer/realtime — the workbook snapshot-insert subscription (a React hook). Kept apart\n * from `univer/collab` so importing it never loads Yjs.\n */\nexport * from \"./useWorkbookRealtime\";\n","/**\n * useWorkbookRealtime — subscribe to udt_workbook_snapshots inserts for one\n * workbook. Fires whenever a NEW snapshot is committed (any client, including\n * us). The caller passes a callback that receives the new snapshot id and\n * created_by, so it can decide whether to reload (e.g. ignore our own writes\n * via the created_by comparison).\n *\n * NOT a CRDT layer. This is \"last write wins on the snapshot row,\" matching\n * the v1 storage model in `udt_v2_workbook_snapshots.sql`. Real concurrent\n * collab (per-keystroke CRDT updates) is a follow-up phase. *\n * REALTIME: `@ai-matrx/data/realtime` owns the channel (`useChannel`) — dedup, the\n * decoupled ordered handler queue, jittered reconnect, tab sleep, diagnostics.\n * What was here was a raw `.channel(...).subscribe()` with manual teardown and\n * NO catch-up read, which on this surface is the worst version of the bug: a\n * snapshot committed by a collaborator while the tab slept was never seen, so\n * the next local save checkpointed on top of a base that had already moved.\n * `onBackfill` re-reads the newest snapshot and hands it to the same callback,\n * so a recovery is indistinguishable from having received the event.\n *\n * The catch-up read is the host port `readNewestWorkbookSnapshot` (the package owns no database client).\n *\n * Echo suppression is deliberately NOT relied on here: these are INSERTs of\n * new rows this client never registers on the write ledger, and the caller's\n * `created_by` comparison is the contract — every insert is delivered.\n */\n\"use client\";\n\nimport { useCallback } from \"react\";\n\nimport { defineChannelNamespace } from \"@ai-matrx/data/realtime\";\nimport { useChannel } from \"@ai-matrx/data/realtime/react\";\nimport { getUniverHost } from \"../ports\";\n\nexport type WorkbookRealtimeEvent = {\n snapshotId: string;\n createdBy: string | null;\n createdAt: string;\n};\n\n/** One place names this channel. A second, different declaration throws. */\nconst workbookSnapshotsChannel = defineChannelNamespace({\n namespace: \"udt-workbook-snapshots\",\n parts: [\"workbookId\"],\n description: \"workbench.udt_workbook_snapshots inserts for one workbook\",\n});\n\nexport type SnapshotRow = {\n id?: string;\n created_by?: string | null;\n created_at?: string;\n};\n\nexport function useWorkbookRealtime(\n workbookId: string | null | undefined,\n onSnapshot: (event: WorkbookRealtimeEvent) => void,\n options?: { enabled?: boolean },\n) {\n const enabled = options?.enabled ?? true;\n\n const emit = useCallback(\n (row: SnapshotRow | null) => {\n if (!row?.id) return;\n onSnapshot({\n snapshotId: row.id,\n // component-created-by-ok: append-only snapshot with NO updated_by column and NO parent-rewrite trigger — created_by is the author the client wrote at insert (the only person field this table has)\n createdBy: row.created_by ?? null,\n createdAt: row.created_at ?? new Date().toISOString(),\n });\n },\n [onSnapshot],\n );\n\n useChannel(\n enabled && workbookId\n ? {\n topic: workbookSnapshotsChannel.topic({ workbookId }),\n postgresChanges: [\n {\n event: \"INSERT\",\n schema: \"workbench\",\n table: \"udt_workbook_snapshots\",\n filter: `workbook_id=eq.${workbookId}`,\n rowId: (row) => (typeof row.id === \"string\" ? row.id : undefined),\n onChange: ({ row }) => emit(row as SnapshotRow | null),\n },\n ],\n // Realtime has no replay. Re-read the newest snapshot so a reconnect,\n // tab wake or network restore cannot leave this client checkpointing\n // on top of a base that moved while it was away.\n onBackfill: async () => {\n let data: SnapshotRow | null;\n let error: { message: string } | null;\n try {\n ({ data, error } = await getUniverHost().readNewestWorkbookSnapshot(workbookId));\n } catch (e) {\n data = null;\n error = { message: e instanceof Error ? e.message : String(e) };\n }\n if (error) {\n // Not silent: without this read the caller is working from a\n // base it cannot know is stale.\n console.warn(\n \"[udt-workbook RT] catch-up read failed — this workbook may be \" +\n \"working from a stale snapshot base; reload before saving.\",\n error.message,\n );\n return;\n }\n emit(data);\n },\n }\n : null,\n );\n}\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, the snapshot catch-up read 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 /** The newest snapshot row of a workbook (the realtime catch-up read), or `data: null` when it has none. */\n readNewestWorkbookSnapshot(\n workbookId: string,\n ): Promise<{ data: { id?: string; created_by?: string | null; created_at?: string } | null; error: { message: string } | null }>;\n /** Tell the person a picture did not upload. */\n notifyUploadError(error: unknown): void;\n /** The painted color 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2BA,m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G;AACV,iBAAO;AACP,kBAAQ,EAAE,SAAS,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,EAAE;AAAA,QAChE;AACA,YAAI,OAAO;AAGT,kBAAQ;AAAA,YACN;AAAA,YAEA,MAAM;AAAA,UACR;AACA;AAAA,QACF;AACA,aAAK,IAAI;AAAA,MACX;AAAA,IACF,IACA;AAAA,EACN;AACF;","names":["import_react"]}
1
+ {"version":3,"sources":["../src/univer/collab/realtime.ts","../src/univer/collab/useWorkbookRealtime.ts","../src/univer/ports.ts"],"sourcesContent":["\"use client\";\n\n/**\n * @ai-matrx/office/univer/realtime — the workbook snapshot-insert subscription (a React hook). Kept apart\n * from `univer/collab` so importing it never loads Yjs.\n */\nexport * from \"./useWorkbookRealtime\";\n","/**\n * useWorkbookRealtime — subscribe to udt_workbook_snapshots inserts for one\n * workbook. Fires whenever a NEW snapshot is committed (any client, including\n * us). The caller passes a callback that receives the new snapshot id and\n * created_by, so it can decide whether to reload (e.g. ignore our own writes\n * via the created_by comparison).\n *\n * NOT a CRDT layer. This is \"last write wins on the snapshot row,\" matching\n * the v1 storage model in `udt_v2_workbook_snapshots.sql`. Real concurrent\n * collab (per-keystroke CRDT updates) is a follow-up phase. *\n * REALTIME: `@ai-matrx/data/realtime` owns the channel (`useChannel`) — dedup, the\n * decoupled ordered handler queue, jittered reconnect, tab sleep, diagnostics.\n * What was here was a raw `.channel(...).subscribe()` with manual teardown and\n * NO catch-up read, which on this surface is the worst version of the bug: a\n * snapshot committed by a collaborator while the tab slept was never seen, so\n * the next local save checkpointed on top of a base that had already moved.\n * `onBackfill` re-reads the newest snapshot and hands it to the same callback,\n * so a recovery is indistinguishable from having received the event.\n *\n * The catch-up read is the host port `readNewestWorkbookSnapshot` (the package owns no database client).\n *\n * Echo suppression is deliberately NOT relied on here: these are INSERTs of\n * new rows this client never registers on the write ledger, and the caller's\n * `created_by` comparison is the contract — every insert is delivered.\n */\n\"use client\";\n\nimport { useCallback } from \"react\";\n\nimport { defineChannelNamespace } from \"@ai-matrx/data/realtime\";\nimport { useChannel } from \"@ai-matrx/data/realtime/react\";\nimport { getUniverHost } from \"../ports\";\n\nexport type WorkbookRealtimeEvent = {\n snapshotId: string;\n createdBy: string | null;\n createdAt: string;\n};\n\n/** One place names this channel. A second, different declaration throws. */\nconst workbookSnapshotsChannel = defineChannelNamespace({\n namespace: \"udt-workbook-snapshots\",\n parts: [\"workbookId\"],\n description: \"workbench.udt_workbook_snapshots inserts for one workbook\",\n});\n\nexport type SnapshotRow = {\n id?: string;\n created_by?: string | null;\n created_at?: string;\n};\n\nexport function useWorkbookRealtime(\n workbookId: string | null | undefined,\n onSnapshot: (event: WorkbookRealtimeEvent) => void,\n options?: { enabled?: boolean },\n) {\n const enabled = options?.enabled ?? true;\n\n const emit = useCallback(\n (row: SnapshotRow | null) => {\n if (!row?.id) return;\n onSnapshot({\n snapshotId: row.id,\n // component-created-by-ok: append-only snapshot with NO updated_by column and NO parent-rewrite trigger — created_by is the author the client wrote at insert (the only person field this table has)\n createdBy: row.created_by ?? null,\n createdAt: row.created_at ?? new Date().toISOString(),\n });\n },\n [onSnapshot],\n );\n\n useChannel(\n enabled && workbookId\n ? {\n topic: workbookSnapshotsChannel.topic({ workbookId }),\n postgresChanges: [\n {\n event: \"INSERT\",\n schema: \"workbench\",\n table: \"udt_workbook_snapshots\",\n filter: `workbook_id=eq.${workbookId}`,\n rowId: (row) => (typeof row.id === \"string\" ? row.id : undefined),\n onChange: ({ row }) => emit(row as SnapshotRow | null),\n },\n ],\n // Realtime has no replay. Re-read the newest snapshot so a reconnect,\n // tab wake or network restore cannot leave this client checkpointing\n // on top of a base that moved while it was away.\n onBackfill: async () => {\n let data: SnapshotRow | null;\n let error: { message: string } | null;\n try {\n ({ data, error } = await getUniverHost().readNewestWorkbookSnapshot(workbookId));\n } catch (e) {\n data = null;\n error = { message: e instanceof Error ? e.message : String(e) };\n }\n if (error) {\n // Not silent: without this read the caller is working from a\n // base it cannot know is stale.\n console.warn(\n \"[udt-workbook RT] catch-up read failed — this workbook may be \" +\n \"working from a stale snapshot base; reload before saving.\",\n error.message,\n );\n return;\n }\n emit(data);\n },\n }\n : null,\n );\n}\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, the snapshot catch-up read 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 /** The newest snapshot row of a workbook (the realtime catch-up read), or `data: null` when it has none. */\n readNewestWorkbookSnapshot(\n workbookId: string,\n ): Promise<{ data: { id?: string; created_by?: string | null; created_at?: string } | null; error: { message: string } | null }>;\n /** Tell the person a picture did not upload. */\n notifyUploadError(error: unknown): void;\n /** The painted color 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2BA,mBAA4B;AAE5B,sBAAuC;AACvC,IAAAA,gBAA2B;;;ACU3B,IAAM,OAAO,uBAAO,IAAI,6BAA6B;AAErD,IAAM,OAAO,MAAY;AACvB,QAAM,IAAI;AACV,SAAQ,EAAE,IAAI,MAAM,CAAC;AACvB;AAMO,SAAS,gBAAiC;AAC/C,QAAM,QAAQ,KAAK,EAAE;AACrB,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,8FAA8F;AAC1H,SAAO;AACT;;;ADfA,IAAM,+BAA2B,wCAAuB;AAAA,EACtD,WAAW;AAAA,EACX,OAAO,CAAC,YAAY;AAAA,EACpB,aAAa;AACf,CAAC;AAQM,SAAS,oBACd,YACA,YACA,SACA;AACA,QAAM,UAAU,SAAS,WAAW;AAEpC,QAAM,WAAO;AAAA,IACX,CAAC,QAA4B;AAC3B,UAAI,CAAC,KAAK,GAAI;AACd,iBAAW;AAAA,QACT,YAAY,IAAI;AAAA;AAAA,QAEhB,WAAW,IAAI,cAAc;AAAA,QAC7B,WAAW,IAAI,eAAc,oBAAI,KAAK,GAAE,YAAY;AAAA,MACtD,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA;AAAA,IACE,WAAW,aACP;AAAA,MACE,OAAO,yBAAyB,MAAM,EAAE,WAAW,CAAC;AAAA,MACpD,iBAAiB;AAAA,QACf;AAAA,UACE,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,OAAO;AAAA,UACP,QAAQ,kBAAkB,UAAU;AAAA,UACpC,OAAO,CAAC,QAAS,OAAO,IAAI,OAAO,WAAW,IAAI,KAAK;AAAA,UACvD,UAAU,CAAC,EAAE,IAAI,MAAM,KAAK,GAAyB;AAAA,QACvD;AAAA,MACF;AAAA;AAAA;AAAA;AAAA,MAIA,YAAY,YAAY;AACtB,YAAI;AACJ,YAAI;AACJ,YAAI;AACF,WAAC,EAAE,MAAM,MAAM,IAAI,MAAM,cAAc,EAAE,2BAA2B,UAAU;AAAA,QAChF,SAAS,GAAG;AACV,iBAAO;AACP,kBAAQ,EAAE,SAAS,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,EAAE;AAAA,QAChE;AACA,YAAI,OAAO;AAGT,kBAAQ;AAAA,YACN;AAAA,YAEA,MAAM;AAAA,UACR;AACA;AAAA,QACF;AACA,aAAK,IAAI;AAAA,MACX;AAAA,IACF,IACA;AAAA,EACN;AACF;","names":["import_react"]}
@@ -1 +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","../src/univer/collab/covered.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\";\nexport * from \"./collab/covered\";\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, the snapshot catch-up read 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 /** The newest snapshot row of a workbook (the realtime catch-up read), or `data: null` when it has none. */\n readNewestWorkbookSnapshot(\n workbookId: string,\n ): Promise<{ data: { id?: string; created_by?: string | null; created_at?: string } | null; error: { message: string } | null }>;\n /** Tell the person a picture did not upload. */\n notifyUploadError(error: unknown): void;\n /** The painted color 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/** Whether an editor of this record is open in this tab. */\nexport function hasOpenEditorContent(kind: EditorRecordKind, recordId: string): boolean {\n return replacers.has(keyOf(kind, recordId));\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 color Univer hands its canvas — WITHOUT the dark-mode inversion.\n *\n * Univer 1.0 writes many of its own fills as THEME TOKENS, not colors: 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 * color 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 color.\n * @param lookup The live theme (`ThemeService.getColorFromTheme`).\n * @returns the token's color 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","/**\n * A saved snapshot names the collab-room entries it already holds, so a seat that boots from it never\n * replays them (2026-10-16: a reload showed the text twice). Pure — no Yjs — so the editors' model can\n * stamp and read it without loading the room.\n */\n\n/** The key a saved snapshot carries its covered room entries under (`stampCovered` / `takeCovered`). */\nexport const COLLAB_COVERED_KEY = \"__matrxCollabCovered\";\n\n/** The snapshot to SAVE: `snapshot` plus the room entries it holds (`WorkbookCollabSession.coveredNow`). */\nexport function stampCovered<T extends object>(snapshot: T, covered: readonly string[]): T {\n return { ...snapshot, [COLLAB_COVERED_KEY]: [...covered] };\n}\n\n/** A LOADED snapshot split into the content to mount and the room entries it already holds. */\nexport function takeCovered<T>(snapshot: T): { snapshot: T; covered: Set<string> } {\n if (!snapshot || typeof snapshot !== \"object\" || !(COLLAB_COVERED_KEY in (snapshot as object))) {\n return { snapshot, covered: new Set() };\n }\n const { [COLLAB_COVERED_KEY]: list, ...rest } = snapshot as Record<string, unknown>;\n return {\n snapshot: rest as T,\n covered: new Set(Array.isArray(list) ? list.filter((e): e is string => typeof e === \"string\") : []),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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CAAC,SAAS,CAAC,OAAO,QAAS;AAC/B,WAAO,QAAQ,eAAe,SAAS,MAAM;AAAA,EAC/C,GAAG,CAAC,QAAQ,OAAO,IAAI,CAAC;AAC1B;;;AC3BO,IAAM,qBAAqB;AAG3B,SAAS,aAA+B,UAAa,SAA+B;AACzF,SAAO,EAAE,GAAG,UAAU,CAAC,kBAAkB,GAAG,CAAC,GAAG,OAAO,EAAE;AAC3D;AAGO,SAAS,YAAe,UAAoD;AACjF,MAAI,CAAC,YAAY,OAAO,aAAa,YAAY,EAAE,sBAAuB,WAAsB;AAC9F,WAAO,EAAE,UAAU,SAAS,oBAAI,IAAI,EAAE;AAAA,EACxC;AACA,QAAM,EAAE,CAAC,kBAAkB,GAAG,MAAM,GAAG,KAAK,IAAI;AAChD,SAAO;AAAA,IACL,UAAU;AAAA,IACV,SAAS,IAAI,IAAI,MAAM,QAAQ,IAAI,IAAI,KAAK,OAAO,CAAC,MAAmB,OAAO,MAAM,QAAQ,IAAI,CAAC,CAAC;AAAA,EACpG;AACF;","names":["import_core","import_core","import_ui"]}
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","../src/univer/collab/covered.ts"],"sourcesContent":["\"use client\";\n\n/**\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\";\nexport * from \"./collab/covered\";\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, the snapshot catch-up read 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 /** The newest snapshot row of a workbook (the realtime catch-up read), or `data: null` when it has none. */\n readNewestWorkbookSnapshot(\n workbookId: string,\n ): Promise<{ data: { id?: string; created_by?: string | null; created_at?: string } | null; error: { message: string } | null }>;\n /** Tell the person a picture did not upload. */\n notifyUploadError(error: unknown): void;\n /** The painted color 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/** Whether an editor of this record is open in this tab. */\nexport function hasOpenEditorContent(kind: EditorRecordKind, recordId: string): boolean {\n return replacers.has(keyOf(kind, recordId));\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 color Univer hands its canvas — WITHOUT the dark-mode inversion.\n *\n * Univer 1.0 writes many of its own fills as THEME TOKENS, not colors: 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 * color 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 color.\n * @param lookup The live theme (`ThemeService.getColorFromTheme`).\n * @returns the token's color 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","/**\n * A saved snapshot names the collab-room entries it already holds, so a seat that boots from it never\n * replays them (2026-10-16: a reload showed the text twice). Pure — no Yjs — so the editors' model can\n * stamp and read it without loading the room.\n */\n\n/** The key a saved snapshot carries its covered room entries under (`stampCovered` / `takeCovered`). */\nexport const COLLAB_COVERED_KEY = \"__matrxCollabCovered\";\n\n/** The snapshot to SAVE: `snapshot` plus the room entries it holds (`WorkbookCollabSession.coveredNow`). */\nexport function stampCovered<T extends object>(snapshot: T, covered: readonly string[]): T {\n return { ...snapshot, [COLLAB_COVERED_KEY]: [...covered] };\n}\n\n/** A LOADED snapshot split into the content to mount and the room entries it already holds. */\nexport function takeCovered<T>(snapshot: T): { snapshot: T; covered: Set<string> } {\n if (!snapshot || typeof snapshot !== \"object\" || !(COLLAB_COVERED_KEY in (snapshot as object))) {\n return { snapshot, covered: new Set() };\n }\n const { [COLLAB_COVERED_KEY]: list, ...rest } = snapshot as Record<string, unknown>;\n return {\n snapshot: rest as T,\n covered: new Set(Array.isArray(list) ? list.filter((e): e is string => typeof e === \"string\") : []),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwCA,IAAM,OAAO,uBAAO,IAAI,6BAA6B;AAErD,IAAM,OAAO,MAAY;AACvB,QAAM,IAAI;AACV,SAAQ,EAAE,IAAI,MAAM,CAAC;AACvB;AAEO,SAAS,oBAAoB,OAA8B;AAChE,OAAK,EAAE,QAAQ;AACjB;AAEO,SAAS,gBAAiC;AAC/C,QAAM,QAAQ,KAAK,EAAE;AACrB,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,8FAA8F;AAC1H,SAAO;AACT;;;AC7CO,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;A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S,yBACd,OACA,QACQ;AACR,MAAI,CAAC,YAAY,KAAK,KAAK,EAAG,QAAO;AACrC,QAAM,WAAW,OAAO,KAAK;AAC7B,SAAO,OAAO,aAAa,YAAY,SAAS,SAAS,IAAI,WAAW;AAC1E;;;AClBA,mBAA0B;AASnB,SAAS,sBACd,QACA,OACM;AACN,QAAM,OAAO,cAAc,EAAE,aAAa;AAE1C,8BAAU,MAAM;AACd,QAAI,CAAC,SAAS,CAAC,OAAO,QAAS;AAC/B,WAAO,QAAQ,eAAe,SAAS,MAAM;AAAA,EAC/C,GAAG,CAAC,QAAQ,OAAO,IAAI,CAAC;AAC1B;;;AC3BO,IAAM,qBAAqB;AAG3B,SAAS,aAA+B,UAAa,SAA+B;AACzF,SAAO,EAAE,GAAG,UAAU,CAAC,kBAAkB,GAAG,CAAC,GAAG,OAAO,EAAE;AAC3D;AAGO,SAAS,YAAe,UAAoD;AACjF,MAAI,CAAC,YAAY,OAAO,aAAa,YAAY,EAAE,sBAAuB,WAAsB;AAC9F,WAAO,EAAE,UAAU,SAAS,oBAAI,IAAI,EAAE;AAAA,EACxC;AACA,QAAM,EAAE,CAAC,kBAAkB,GAAG,MAAM,GAAG,KAAK,IAAI;AAChD,SAAO;AAAA,IACL,UAAU;AAAA,IACV,SAAS,IAAI,IAAI,MAAM,QAAQ,IAAI,IAAI,KAAK,OAAO,CAAC,MAAmB,OAAO,MAAM,QAAQ,IAAI,CAAC,CAAC;AAAA,EACpG;AACF;","names":["import_core","import_core","import_ui"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/office",
3
- "version": "0.8.63",
3
+ "version": "0.8.65",
4
4
  "description": "The AI Matrx Office layer: the editors' shared command and menu model, the Google and Microsoft ribbon model, page setup, the Office record types and the configured product hosts. The Univer glue shared by Sheets and Docs. Sheets, Docs and the other products arrive as sections of this one package.",
5
5
  "type": "module",
6
6
  "main": "./dist/core.cjs",
@@ -205,14 +205,14 @@
205
205
  "y-protocols": "^1.0.7",
206
206
  "yjs": "^13.6.33",
207
207
  "@ai-matrx/alchemy": "latest",
208
- "@ai-matrx/auth": "latest",
209
208
  "@ai-matrx/api": "latest",
209
+ "@ai-matrx/auth": "latest",
210
+ "@ai-matrx/content-ir": "latest",
210
211
  "@ai-matrx/data": "latest",
211
212
  "@ai-matrx/design-system": "latest",
212
- "@ai-matrx/content-ir": "latest",
213
+ "@ai-matrx/print": "latest",
213
214
  "@ai-matrx/kit": "latest",
214
215
  "@ai-matrx/records": "latest",
215
- "@ai-matrx/print": "latest",
216
216
  "@ai-matrx/rich-content": "latest"
217
217
  },
218
218
  "peerDependencies": {
@@ -243,9 +243,8 @@
243
243
  "tsup": "^8.5.1",
244
244
  "typescript": "^6.0.3",
245
245
  "vitest": "^5.0.1",
246
- "@ai-matrx/playground": "0.1.0",
247
- "@ai-matrx/records-ui": "0.116.0",
248
- "@ai-matrx/media": "0.15.1"
246
+ "@ai-matrx/media": "0.15.1",
247
+ "@ai-matrx/records-ui": "0.116.0"
249
248
  },
250
249
  "publishConfig": {
251
250
  "access": "public",
@@ -285,5 +284,5 @@
285
284
  "fuzz:sheets": "SHEET_FUZZ_SEEDS=${SHEET_FUZZ_SEEDS:-4000} CHAIN_FUZZ_SEEDS=${CHAIN_FUZZ_SEEDS:-4000} SHEET_FUZZ_HEAP_MB=${SHEET_FUZZ_HEAP_MB:-12288} NODE_OPTIONS=--max-old-space-size=16384 vitest run src/collab/sheets/transform/sheet-transform-fuzz.test.ts src/collab/sheets/transform/sheet-transform-chain-fuzz.test.ts",
286
285
  "verify:tarball": "node ./scripts/verify-tarball.mjs"
287
286
  },
288
- "gitHead": "7f9ea195ab4c116e3fa2468671a9b4879530b792"
287
+ "gitHead": "ba2eaed14f8188f606751129c882c0fb12fa96bf"
289
288
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/aidream/aidream/apps/shared/office/dist/chunk-6TUFBQLH.cjs","../src/docs/doc-tools-core.ts"],"names":[],"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AC3D,EAAA;AAC6D,EAAA;AAC/D;AAGqC;AACqC;AACtB,EAAA;AACC,EAAA;AACpB,EAAA;AACD,EAAA;AACA,EAAA;AACC,EAAA;AACe,EAAA;AACjB,EAAA;AACG,EAAA;AACF,EAAA;AACiB,EAAA;AACjB,EAAA;AACD,EAAA;AACE,EAAA;AACjC;AAEqE;AACqB,EAAA;AACvB,EAAA;AACnE;ADvFmE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/aidream/aidream/apps/shared/office/dist/chunk-6TUFBQLH.cjs","sourcesContent":[null,"/**\n * The pure half of the Docs tools: building blocks, bookmarks, paragraph borders, the ruler's\n * geometry and the document language. No Univer import, so each is proven on plain snapshots.\n */\n\nimport { PX_PER_INCH } from \"../core\";\nimport { tableStartsAt } from \"@ai-matrx/content-ir/source\";\nimport { markdownToUniverDoc } from \"./markdown-to-univer-doc\";\n\nexport interface BuildingBlock {\n id: string;\n label: string;\n description: string;\n markdown: string;\n}\n\nexport const BUILDING_BLOCKS: BuildingBlock[] = [\n { id: \"meeting-notes\", label: \"Meeting notes\", description: \"Date, attendees, agenda, decisions and action items.\", markdown: \"## Meeting notes\\n\\nDate: \\nAttendees: \\n\\n### Agenda\\n\\n1. \\n\\n### Discussion\\n\\n### Decisions\\n\\n### Action items\\n\\n☐ Owner: Task, due date\\n\" },\n { id: \"project-tracker\", label: \"Project tracker\", description: \"Goal, milestones, owners, risks and status.\", markdown: \"## Project tracker\\n\\nGoal: \\nOwner: \\nStatus: On track\\n\\n### Milestones\\n\\n☐ Milestone, owner, due date\\n\\n### Risks\\n\\n### Next steps\\n\" },\n { id: \"email-draft\", label: \"Email draft\", description: \"To, subject and a three-part message ready to fill in.\", markdown: \"## Email draft\\n\\nTo: \\nSubject: \\n\\nHi ,\\n\\nI am writing about .\\n\\nThe next step is .\\n\\nThanks,\\n\" },\n { id: \"weekly-status\", label: \"Weekly status\", description: \"Done, next, and blocked, for one week.\", markdown: \"## Weekly status\\n\\nWeek of: \\n\\n### Done this week\\n\\n### Next week\\n\\n### Blocked\\n\" },\n { id: \"decision-log\", label: \"Decision record\", description: \"Context, options, decision and consequences.\", markdown: \"## Decision record\\n\\nDate: \\nDecider: \\n\\n### Context\\n\\n### Options considered\\n\\n### Decision\\n\\n### Consequences\\n\" },\n { id: \"pros-cons\", label: \"Pros and cons\", description: \"A side-by-side weighing of one choice.\", markdown: \"## Pros and cons\\n\\nChoice: \\n\\n### Pros\\n\\n### Cons\\n\\n### Verdict\\n\" },\n];\n\n/** What Univer's paste command takes as `doc`: a body (no document-closing `\\n`) plus the table sources its `tables` name. */\nexport interface MarkdownFragment {\n body: Record<string, unknown> & { dataStream: string };\n tableSource?: Record<string, unknown>;\n drawings?: Record<string, unknown>;\n}\n\n/**\n * Markdown to a fragment Univer can insert at the caret (`doc.command.inner-paste`): headings, lists,\n * bold, links and REAL tables, from THE one writer (`markdownToUniverDoc`). The document-closing `\\n`\n * and its section break are dropped; every other body part (tables, links, runs) is kept.\n */\nexport function markdownFragment(markdown: string): MarkdownFragment {\n const doc = markdownToUniverDoc(markdown) as unknown as {\n body?: Record<string, unknown> & { dataStream: string };\n tableSource?: Record<string, unknown>;\n drawings?: Record<string, unknown>;\n };\n const whole = doc.body ?? { dataStream: \"\" };\n let stream = whole.dataStream;\n if (stream.endsWith(\"\\n\")) stream = stream.slice(0, -1);\n const { sectionBreaks: _sectionBreaks, ...rest } = whole;\n void _sectionBreaks;\n const paragraphs = ((whole.paragraphs as Array<{ startIndex: number }> | undefined) ?? []).filter((p) => p.startIndex < stream.length);\n const textRuns = ((whole.textRuns as Array<{ st: number; ed: number }> | undefined) ?? [])\n .filter((r) => r.st < stream.length)\n .map((r) => ({ ...r, ed: Math.min(r.ed, stream.length) }));\n return {\n body: { ...rest, dataStream: stream, paragraphs, textRuns },\n ...(doc.tableSource ? { tableSource: doc.tableSource } : {}),\n ...(doc.drawings ? { drawings: doc.drawings } : {}),\n };\n}\n\n/**\n * True when text carries markdown STRUCTURE a document should draw: a table, a heading, a list, a\n * fence, a quote, a link, or bold. Plain prose (and a stray `*` or `_`) is false, so ordinary\n * typing and paste stay plain text. Every door that takes agent- or clipboard-supplied text asks\n * this one question, then converts through `markdownFragment`.\n */\nexport function looksLikeMarkdown(text: string): boolean {\n if (!text) return false;\n const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n if (/^\\s{0,3}#{1,6}\\s+\\S/.test(line)) return true;\n if (/^\\s*([-*+]|\\d+[.)])\\s+\\S/.test(line)) return true;\n if (/^\\s{0,3}(```|~~~)/.test(line)) return true;\n if (/^\\s*>\\s?\\S/.test(line)) return true;\n if (tableStartsAt(lines, i)) return true;\n }\n return /\\*\\*[^*\\s][^*]*\\*\\*|\\[[^\\]\\n]+\\]\\([^)\\s]+\\)/.test(text);\n}\n\n/**\n * Where a BLOCK (table of contents, building block) goes for a caret: never inside a paragraph's\n * text, so a heading is never split. Caret at the start of a paragraph (or in an empty one) →\n * insert right there; anywhere else → end the caret's paragraph with a new line and insert at the\n * start of that new paragraph. `dataStream` is Univer's body stream (paragraphs end in `\\r`).\n */\nexport function blockInsertPlan(dataStream: string, caret: number): { at: number; breakAt: number | null } {\n const c = Math.max(0, Math.min(caret, dataStream.length));\n const start = Math.max(dataStream.lastIndexOf(\"\\r\", c - 1), dataStream.lastIndexOf(\"\\n\", c - 1)) + 1;\n let end = dataStream.indexOf(\"\\r\", c);\n if (end < 0) end = dataStream.length;\n // Field marks and anchors are zero-width: a paragraph holding only them is empty.\n const text = dataStream.slice(start, end).replace(/[\\u0000-\\u001f\\u200b]/g, \"\").trim();\n if (c === start || text === \"\") return { at: start, breakAt: null };\n return { at: end + 1, breakAt: end };\n}\n\n/** Univer's CustomRangeType.BOOKMARK. */\nexport const BOOKMARK_RANGE_TYPE = 3;\n/** A bookmark is an invisible anchor: one zero-width character the custom range wraps. */\nexport const BOOKMARK_ANCHOR = \"​\";\n\nexport interface Bookmark {\n id: string;\n name: string;\n offset: number;\n}\n\ninterface BodyWithRanges {\n customRanges?: Array<{ rangeId: string; rangeType: number; startIndex: number; properties?: { name?: unknown } }>;\n}\n\nexport function collectBookmarks(snapshot: unknown): Bookmark[] {\n const body = (snapshot as { body?: BodyWithRanges } | null)?.body;\n const out: Bookmark[] = [];\n for (const r of body?.customRanges ?? []) {\n if (r.rangeType !== BOOKMARK_RANGE_TYPE) continue;\n out.push({ id: r.rangeId, name: typeof r.properties?.name === \"string\" ? r.properties.name : \"\", offset: r.startIndex });\n }\n return out.sort((a, b) => a.offset - b.offset);\n}\n\nexport function bookmarkBody(id: string, name: string) {\n return {\n dataStream: BOOKMARK_ANCHOR,\n customRanges: [{ startIndex: 0, endIndex: 0, rangeId: id, rangeType: BOOKMARK_RANGE_TYPE, properties: { name }, wholeEntity: true }],\n };\n}\n\nexport function cleanBookmarkName(raw: string, existing: readonly Bookmark[]): { ok: true; name: string } | { ok: false; why: string } {\n const name = raw.replace(/\\s+/g, \" \").trim().slice(0, 80);\n if (!name) return { ok: false, why: \"Give the bookmark a name.\" };\n if (existing.some((b) => b.name.toLowerCase() === name.toLowerCase())) return { ok: false, why: `A bookmark named \"${name}\" already exists.` };\n return { ok: true, name };\n}\n\n/** `#bookmark=<name>` in the page address names a bookmark to jump to on open. */\nexport function bookmarkFromHash(hash: string): string | null {\n const m = /^#bookmark=(.+)$/.exec(hash);\n if (!m) return null;\n try {\n return decodeURIComponent(m[1]!);\n } catch {\n return null;\n }\n}\nexport const bookmarkHash = (name: string) => `#bookmark=${encodeURIComponent(name)}`;\n\nexport type BorderSide = \"top\" | \"bottom\" | \"both\" | \"none\";\nexport type BorderDash = \"solid\" | \"dashed\" | \"dotted\";\n/** Univer's DashStyleType values. */\nconst DASH: Record<BorderDash, number> = { solid: 1, dotted: 2, dashed: 3 };\n\nexport interface BorderChoice {\n side: BorderSide;\n color: string;\n width: number;\n dash: BorderDash;\n padding: number;\n}\n\n/** The `paragraph` argument of `doc-paragraph-setting.command` for a choice (Univer draws top and bottom paragraph borders). */\nexport function paragraphBorderParams(c: BorderChoice): Record<string, unknown> {\n const line = { color: { rgb: c.color }, width: c.width, dashStyle: DASH[c.dash], padding: c.padding };\n return {\n borderTop: c.side === \"top\" || c.side === \"both\" ? line : null,\n borderBottom: c.side === \"bottom\" || c.side === \"both\" ? line : null,\n };\n}\n\nexport interface RulerGeometry {\n pageLeft: number;\n pageWidth: number;\n marginLeft: number;\n marginRight: number;\n ticks: Array<{ x: number; kind: \"inch\" | \"half\" | \"eighth\"; label?: string }>;\n}\n\n/** The ruler above the page: inch ticks from the page's left edge (margins shaded), at the current zoom. */\nexport function rulerGeometry(a: { containerWidth: number; zoom: number; pageWidthPx: number; marginLeftPx: number; marginRightPx: number }): RulerGeometry {\n const pageWidth = a.pageWidthPx * a.zoom;\n const pageLeft = Math.max(0, (a.containerWidth - pageWidth) / 2);\n const ticks: RulerGeometry[\"ticks\"] = [];\n const inches = a.pageWidthPx / PX_PER_INCH;\n for (let eighth = 0; eighth <= Math.floor(inches * 8); eighth++) {\n const x = pageLeft + (eighth * PX_PER_INCH * a.zoom) / 8;\n if (eighth % 8 === 0) {\n const marginInches = a.marginLeftPx / PX_PER_INCH;\n ticks.push({ x, kind: \"inch\", ...(eighth / 8 !== marginInches ? { label: String(Math.round(Math.abs(eighth / 8 - marginInches))) } : {}) });\n } else ticks.push({ x, kind: eighth % 4 === 0 ? \"half\" : \"eighth\" });\n }\n return { pageLeft, pageWidth, marginLeft: a.marginLeftPx * a.zoom, marginRight: a.marginRightPx * a.zoom, ticks };\n}\n\n/** The key on the document style that carries the language (the slot the paper color also uses). */\nexport const DOCUMENT_LANGUAGE_KEY = \"matrxLanguage\";\nexport const DOCUMENT_LANGUAGES: Array<{ code: string; label: string }> = [\n { code: \"en-US\", label: \"English (United States)\" },\n { code: \"en-GB\", label: \"English (United Kingdom)\" },\n { code: \"es\", label: \"Spanish\" },\n { code: \"fr\", label: \"French\" },\n { code: \"de\", label: \"German\" },\n { code: \"it\", label: \"Italian\" },\n { code: \"pt-BR\", label: \"Portuguese (Brazil)\" },\n { code: \"nl\", label: \"Dutch\" },\n { code: \"ja\", label: \"Japanese\" },\n { code: \"ko\", label: \"Korean\" },\n { code: \"zh-CN\", label: \"Chinese (Simplified)\" },\n { code: \"ar\", label: \"Arabic\" },\n { code: \"hi\", label: \"Hindi\" },\n { code: \"ru\", label: \"Russian\" },\n];\n\nexport function readDocumentLanguage(documentStyle: unknown): string {\n const v = (documentStyle as Record<string, unknown> | undefined)?.[DOCUMENT_LANGUAGE_KEY];\n return typeof v === \"string\" && DOCUMENT_LANGUAGES.some((l) => l.code === v) ? v : \"en-US\";\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/docs/doc-tools-core.ts"],"sourcesContent":["/**\n * The pure half of the Docs tools: building blocks, bookmarks, paragraph borders, the ruler's\n * geometry and the document language. No Univer import, so each is proven on plain snapshots.\n */\n\nimport { PX_PER_INCH } from \"../core\";\nimport { tableStartsAt } from \"@ai-matrx/content-ir/source\";\nimport { markdownToUniverDoc } from \"./markdown-to-univer-doc\";\n\nexport interface BuildingBlock {\n id: string;\n label: string;\n description: string;\n markdown: string;\n}\n\nexport const BUILDING_BLOCKS: BuildingBlock[] = [\n { id: \"meeting-notes\", label: \"Meeting notes\", description: \"Date, attendees, agenda, decisions and action items.\", markdown: \"## Meeting notes\\n\\nDate: \\nAttendees: \\n\\n### Agenda\\n\\n1. \\n\\n### Discussion\\n\\n### Decisions\\n\\n### Action items\\n\\n☐ Owner: Task, due date\\n\" },\n { id: \"project-tracker\", label: \"Project tracker\", description: \"Goal, milestones, owners, risks and status.\", markdown: \"## Project tracker\\n\\nGoal: \\nOwner: \\nStatus: On track\\n\\n### Milestones\\n\\n☐ Milestone, owner, due date\\n\\n### Risks\\n\\n### Next steps\\n\" },\n { id: \"email-draft\", label: \"Email draft\", description: \"To, subject and a three-part message ready to fill in.\", markdown: \"## Email draft\\n\\nTo: \\nSubject: \\n\\nHi ,\\n\\nI am writing about .\\n\\nThe next step is .\\n\\nThanks,\\n\" },\n { id: \"weekly-status\", label: \"Weekly status\", description: \"Done, next, and blocked, for one week.\", markdown: \"## Weekly status\\n\\nWeek of: \\n\\n### Done this week\\n\\n### Next week\\n\\n### Blocked\\n\" },\n { id: \"decision-log\", label: \"Decision record\", description: \"Context, options, decision and consequences.\", markdown: \"## Decision record\\n\\nDate: \\nDecider: \\n\\n### Context\\n\\n### Options considered\\n\\n### Decision\\n\\n### Consequences\\n\" },\n { id: \"pros-cons\", label: \"Pros and cons\", description: \"A side-by-side weighing of one choice.\", markdown: \"## Pros and cons\\n\\nChoice: \\n\\n### Pros\\n\\n### Cons\\n\\n### Verdict\\n\" },\n];\n\n/** What Univer's paste command takes as `doc`: a body (no document-closing `\\n`) plus the table sources its `tables` name. */\nexport interface MarkdownFragment {\n body: Record<string, unknown> & { dataStream: string };\n tableSource?: Record<string, unknown>;\n drawings?: Record<string, unknown>;\n}\n\n/**\n * Markdown to a fragment Univer can insert at the caret (`doc.command.inner-paste`): headings, lists,\n * bold, links and REAL tables, from THE one writer (`markdownToUniverDoc`). The document-closing `\\n`\n * and its section break are dropped; every other body part (tables, links, runs) is kept.\n */\nexport function markdownFragment(markdown: string): MarkdownFragment {\n const doc = markdownToUniverDoc(markdown) as unknown as {\n body?: Record<string, unknown> & { dataStream: string };\n tableSource?: Record<string, unknown>;\n drawings?: Record<string, unknown>;\n };\n const whole = doc.body ?? { dataStream: \"\" };\n let stream = whole.dataStream;\n if (stream.endsWith(\"\\n\")) stream = stream.slice(0, -1);\n const { sectionBreaks: _sectionBreaks, ...rest } = whole;\n void _sectionBreaks;\n const paragraphs = ((whole.paragraphs as Array<{ startIndex: number }> | undefined) ?? []).filter((p) => p.startIndex < stream.length);\n const textRuns = ((whole.textRuns as Array<{ st: number; ed: number }> | undefined) ?? [])\n .filter((r) => r.st < stream.length)\n .map((r) => ({ ...r, ed: Math.min(r.ed, stream.length) }));\n return {\n body: { ...rest, dataStream: stream, paragraphs, textRuns },\n ...(doc.tableSource ? { tableSource: doc.tableSource } : {}),\n ...(doc.drawings ? { drawings: doc.drawings } : {}),\n };\n}\n\n/**\n * True when text carries markdown STRUCTURE a document should draw: a table, a heading, a list, a\n * fence, a quote, a link, or bold. Plain prose (and a stray `*` or `_`) is false, so ordinary\n * typing and paste stay plain text. Every door that takes agent- or clipboard-supplied text asks\n * this one question, then converts through `markdownFragment`.\n */\nexport function looksLikeMarkdown(text: string): boolean {\n if (!text) return false;\n const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n if (/^\\s{0,3}#{1,6}\\s+\\S/.test(line)) return true;\n if (/^\\s*([-*+]|\\d+[.)])\\s+\\S/.test(line)) return true;\n if (/^\\s{0,3}(```|~~~)/.test(line)) return true;\n if (/^\\s*>\\s?\\S/.test(line)) return true;\n if (tableStartsAt(lines, i)) return true;\n }\n return /\\*\\*[^*\\s][^*]*\\*\\*|\\[[^\\]\\n]+\\]\\([^)\\s]+\\)/.test(text);\n}\n\n/**\n * Where a BLOCK (table of contents, building block) goes for a caret: never inside a paragraph's\n * text, so a heading is never split. Caret at the start of a paragraph (or in an empty one) →\n * insert right there; anywhere else → end the caret's paragraph with a new line and insert at the\n * start of that new paragraph. `dataStream` is Univer's body stream (paragraphs end in `\\r`).\n */\nexport function blockInsertPlan(dataStream: string, caret: number): { at: number; breakAt: number | null } {\n const c = Math.max(0, Math.min(caret, dataStream.length));\n const start = Math.max(dataStream.lastIndexOf(\"\\r\", c - 1), dataStream.lastIndexOf(\"\\n\", c - 1)) + 1;\n let end = dataStream.indexOf(\"\\r\", c);\n if (end < 0) end = dataStream.length;\n // Field marks and anchors are zero-width: a paragraph holding only them is empty.\n const text = dataStream.slice(start, end).replace(/[\\u0000-\\u001f\\u200b]/g, \"\").trim();\n if (c === start || text === \"\") return { at: start, breakAt: null };\n return { at: end + 1, breakAt: end };\n}\n\n/** Univer's CustomRangeType.BOOKMARK. */\nexport const BOOKMARK_RANGE_TYPE = 3;\n/** A bookmark is an invisible anchor: one zero-width character the custom range wraps. */\nexport const BOOKMARK_ANCHOR = \"​\";\n\nexport interface Bookmark {\n id: string;\n name: string;\n offset: number;\n}\n\ninterface BodyWithRanges {\n customRanges?: Array<{ rangeId: string; rangeType: number; startIndex: number; properties?: { name?: unknown } }>;\n}\n\nexport function collectBookmarks(snapshot: unknown): Bookmark[] {\n const body = (snapshot as { body?: BodyWithRanges } | null)?.body;\n const out: Bookmark[] = [];\n for (const r of body?.customRanges ?? []) {\n if (r.rangeType !== BOOKMARK_RANGE_TYPE) continue;\n out.push({ id: r.rangeId, name: typeof r.properties?.name === \"string\" ? r.properties.name : \"\", offset: r.startIndex });\n }\n return out.sort((a, b) => a.offset - b.offset);\n}\n\nexport function bookmarkBody(id: string, name: string) {\n return {\n dataStream: BOOKMARK_ANCHOR,\n customRanges: [{ startIndex: 0, endIndex: 0, rangeId: id, rangeType: BOOKMARK_RANGE_TYPE, properties: { name }, wholeEntity: true }],\n };\n}\n\nexport function cleanBookmarkName(raw: string, existing: readonly Bookmark[]): { ok: true; name: string } | { ok: false; why: string } {\n const name = raw.replace(/\\s+/g, \" \").trim().slice(0, 80);\n if (!name) return { ok: false, why: \"Give the bookmark a name.\" };\n if (existing.some((b) => b.name.toLowerCase() === name.toLowerCase())) return { ok: false, why: `A bookmark named \"${name}\" already exists.` };\n return { ok: true, name };\n}\n\n/** `#bookmark=<name>` in the page address names a bookmark to jump to on open. */\nexport function bookmarkFromHash(hash: string): string | null {\n const m = /^#bookmark=(.+)$/.exec(hash);\n if (!m) return null;\n try {\n return decodeURIComponent(m[1]!);\n } catch {\n return null;\n }\n}\nexport const bookmarkHash = (name: string) => `#bookmark=${encodeURIComponent(name)}`;\n\nexport type BorderSide = \"top\" | \"bottom\" | \"both\" | \"none\";\nexport type BorderDash = \"solid\" | \"dashed\" | \"dotted\";\n/** Univer's DashStyleType values. */\nconst DASH: Record<BorderDash, number> = { solid: 1, dotted: 2, dashed: 3 };\n\nexport interface BorderChoice {\n side: BorderSide;\n color: string;\n width: number;\n dash: BorderDash;\n padding: number;\n}\n\n/** The `paragraph` argument of `doc-paragraph-setting.command` for a choice (Univer draws top and bottom paragraph borders). */\nexport function paragraphBorderParams(c: BorderChoice): Record<string, unknown> {\n const line = { color: { rgb: c.color }, width: c.width, dashStyle: DASH[c.dash], padding: c.padding };\n return {\n borderTop: c.side === \"top\" || c.side === \"both\" ? line : null,\n borderBottom: c.side === \"bottom\" || c.side === \"both\" ? line : null,\n };\n}\n\nexport interface RulerGeometry {\n pageLeft: number;\n pageWidth: number;\n marginLeft: number;\n marginRight: number;\n ticks: Array<{ x: number; kind: \"inch\" | \"half\" | \"eighth\"; label?: string }>;\n}\n\n/** The ruler above the page: inch ticks from the page's left edge (margins shaded), at the current zoom. */\nexport function rulerGeometry(a: { containerWidth: number; zoom: number; pageWidthPx: number; marginLeftPx: number; marginRightPx: number }): RulerGeometry {\n const pageWidth = a.pageWidthPx * a.zoom;\n const pageLeft = Math.max(0, (a.containerWidth - pageWidth) / 2);\n const ticks: RulerGeometry[\"ticks\"] = [];\n const inches = a.pageWidthPx / PX_PER_INCH;\n for (let eighth = 0; eighth <= Math.floor(inches * 8); eighth++) {\n const x = pageLeft + (eighth * PX_PER_INCH * a.zoom) / 8;\n if (eighth % 8 === 0) {\n const marginInches = a.marginLeftPx / PX_PER_INCH;\n ticks.push({ x, kind: \"inch\", ...(eighth / 8 !== marginInches ? { label: String(Math.round(Math.abs(eighth / 8 - marginInches))) } : {}) });\n } else ticks.push({ x, kind: eighth % 4 === 0 ? \"half\" : \"eighth\" });\n }\n return { pageLeft, pageWidth, marginLeft: a.marginLeftPx * a.zoom, marginRight: a.marginRightPx * a.zoom, ticks };\n}\n\n/** The key on the document style that carries the language (the slot the paper color also uses). */\nexport const DOCUMENT_LANGUAGE_KEY = \"matrxLanguage\";\nexport const DOCUMENT_LANGUAGES: Array<{ code: string; label: string }> = [\n { code: \"en-US\", label: \"English (United States)\" },\n { code: \"en-GB\", label: \"English (United Kingdom)\" },\n { code: \"es\", label: \"Spanish\" },\n { code: \"fr\", label: \"French\" },\n { code: \"de\", label: \"German\" },\n { code: \"it\", label: \"Italian\" },\n { code: \"pt-BR\", label: \"Portuguese (Brazil)\" },\n { code: \"nl\", label: \"Dutch\" },\n { code: \"ja\", label: \"Japanese\" },\n { code: \"ko\", label: \"Korean\" },\n { code: \"zh-CN\", label: \"Chinese (Simplified)\" },\n { code: \"ar\", label: \"Arabic\" },\n { code: \"hi\", label: \"Hindi\" },\n { code: \"ru\", label: \"Russian\" },\n];\n\nexport function readDocumentLanguage(documentStyle: unknown): string {\n const v = (documentStyle as Record<string, unknown> | undefined)?.[DOCUMENT_LANGUAGE_KEY];\n return typeof v === \"string\" && DOCUMENT_LANGUAGES.some((l) => l.code === v) ? v : \"en-US\";\n}\n"],"mappings":";;;;;;AAMA,SAAS,qBAAqB;AAUvB,IAAM,kBAAmC;AAAA,EAC9C,EAAE,IAAI,iBAAiB,OAAO,iBAAiB,aAAa,wDAAwD,UAAU,wJAAmJ;AAAA,EACjR,EAAE,IAAI,mBAAmB,OAAO,mBAAmB,aAAa,+CAA+C,UAAU,kJAA6I;AAAA,EACtQ,EAAE,IAAI,eAAe,OAAO,eAAe,aAAa,0DAA0D,UAAU,uGAAuG;AAAA,EACnO,EAAE,IAAI,iBAAiB,OAAO,iBAAiB,aAAa,0CAA0C,UAAU,wFAAwF;AAAA,EACxM,EAAE,IAAI,gBAAgB,OAAO,mBAAmB,aAAa,gDAAgD,UAAU,yHAAyH;AAAA,EAChP,EAAE,IAAI,aAAa,OAAO,iBAAiB,aAAa,0CAA0C,UAAU,wEAAwE;AACtL;AAcO,SAAS,iBAAiB,UAAoC;AACnE,QAAM,MAAM,oBAAoB,QAAQ;AAKxC,QAAM,QAAQ,IAAI,QAAQ,EAAE,YAAY,GAAG;AAC3C,MAAI,SAAS,MAAM;AACnB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