diff --git a/src/app/document/io/save.ts b/src/app/document/io/save.ts index 87cf0c9c9..f86af654c 100644 --- a/src/app/document/io/save.ts +++ b/src/app/document/io/save.ts @@ -3,27 +3,15 @@ import type { EditorState } from '@open-pencil/core/editor' import { downloadBlob } from '@/app/document/io/browser' import { documentNameFromFigPath } from '@/app/document/io/names' import { chooseBrowserFigSaveHandle, chooseTauriFigSavePath } from '@/app/document/io/save-targets' -import type { DocumentSourceIdentity } from '@/app/document/io/types' +import type { DocumentSourceAccess } from '@/app/document/io/types' import { createDocumentWriter } from '@/app/document/io/write' -import type { StorageDocumentBinding } from '@/app/integrations/storage/types' import { IS_TAURI } from '@/constants' type SaveDocumentState = EditorState & { documentName: string } -type SaveActionsOptions = { +type SaveActionsOptions = Omit & { state: SaveDocumentState buildFigFile: () => Uint8Array | Promise - getFilePath: () => string | null - setFilePath: (path: string | null) => void - getFileHandle: () => FileSystemFileHandle | null - setFileHandle: (handle: FileSystemFileHandle | null) => void - getDownloadName: () => string | null - setDownloadName: (name: string | null) => void - getStorageBinding: () => StorageDocumentBinding | null - setStorageBinding: (binding: StorageDocumentBinding | null) => void - setSourceIdentity: (identity: DocumentSourceIdentity) => void - setSavedVersion: (version: number) => void - setLastWriteTime: (time: number) => void startWatchingFile: () => void } diff --git a/src/app/document/io/source.ts b/src/app/document/io/source.ts index 40b3b1326..e296d8fd3 100644 --- a/src/app/document/io/source.ts +++ b/src/app/document/io/source.ts @@ -9,7 +9,7 @@ import { } from '@/app/document/io/names' import { createSaveActions } from '@/app/document/io/save' import { createDocumentSourceState } from '@/app/document/io/source-state' -import type { DocumentSourceIdentity } from '@/app/document/io/types' +import type { DocumentSourceAccess } from '@/app/document/io/types' import type { StorageDocumentBinding } from '@/app/integrations/storage/types' type DocumentSourceState = EditorState & { @@ -19,23 +19,11 @@ type DocumentSourceState = EditorState & { export { createDocumentSourceState } -type DocumentSourceOptions = { +type DocumentSourceOptions = DocumentSourceAccess & { editor: Editor state: DocumentSourceState stopWatchingFile: () => void startWatchingFile: () => Promise - getFileHandle: () => FileSystemFileHandle | null - setFileHandle: (handle: FileSystemFileHandle | null) => void - getFilePath: () => string | null - setFilePath: (path: string | null) => void - getDownloadName: () => string | null - setDownloadName: (name: string | null) => void - getStorageBinding: () => StorageDocumentBinding | null - setStorageBinding: (binding: StorageDocumentBinding | null) => void - setSourceIdentity: (identity: DocumentSourceIdentity) => void - getSavedVersion: () => number - setSavedVersion: (version: number) => void - setLastWriteTime: (time: number) => void getRenderer: () => Editor['renderer'] } diff --git a/src/app/document/io/types.ts b/src/app/document/io/types.ts index 48a9a92f5..f890dc649 100644 --- a/src/app/document/io/types.ts +++ b/src/app/document/io/types.ts @@ -1,6 +1,23 @@ +import type { StorageDocumentBinding } from '@/app/integrations/storage/types' + export type DocumentSourceIdentity = Readonly<{ handle: FileSystemFileHandle | null path: string | null }> +export type DocumentSourceAccess = { + getFileHandle: () => FileSystemFileHandle | null + setFileHandle: (handle: FileSystemFileHandle | null) => void + getFilePath: () => string | null + setFilePath: (path: string | null) => void + getDownloadName: () => string | null + setDownloadName: (name: string | null) => void + getStorageBinding: () => StorageDocumentBinding | null + setStorageBinding: (binding: StorageDocumentBinding | null) => void + setSourceIdentity: (identity: DocumentSourceIdentity) => void + getSavedVersion: () => number + setSavedVersion: (version: number) => void + setLastWriteTime: (time: number) => void +} + export type ViewportSize = { width: number; height: number }