diff --git a/packages/filepicker/package.json b/packages/filepicker/package.json index 6b994ed0b..917a8519c 100644 --- a/packages/filepicker/package.json +++ b/packages/filepicker/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@standardnotes/common": "^1.23.1", - "@standardnotes/services": "workspace:*", + "@standardnotes/files": "workspace:*", "@standardnotes/utils": "workspace:*", "@types/wicg-file-system-access": "^2020.9.5", "reflect-metadata": "^0.1.13" diff --git a/packages/filepicker/src/Cache/FileMemoryCache.spec.ts b/packages/filepicker/src/Cache/FileMemoryCache.spec.ts index 5c26b5961..e10d4b2e9 100644 --- a/packages/filepicker/src/Cache/FileMemoryCache.spec.ts +++ b/packages/filepicker/src/Cache/FileMemoryCache.spec.ts @@ -1,4 +1,5 @@ -import { EncryptedBytes } from './../TypedBytes' +import { EncryptedBytes } from '@standardnotes/files' + import { FileMemoryCache } from './FileMemoryCache' describe('file memory cache', () => { diff --git a/packages/filepicker/src/Cache/FileMemoryCache.ts b/packages/filepicker/src/Cache/FileMemoryCache.ts index 16d9488bd..83b8d13bb 100644 --- a/packages/filepicker/src/Cache/FileMemoryCache.ts +++ b/packages/filepicker/src/Cache/FileMemoryCache.ts @@ -1,6 +1,6 @@ import { removeFromArray } from '@standardnotes/utils' import { Uuid } from '@standardnotes/common' -import { EncryptedBytes } from '../TypedBytes' +import { EncryptedBytes } from '@standardnotes/files' export class FileMemoryCache { private cache: Record = {} diff --git a/packages/filepicker/src/Classic/ClassicReader.ts b/packages/filepicker/src/Classic/ClassicReader.ts index 660132ab1..635d02def 100644 --- a/packages/filepicker/src/Classic/ClassicReader.ts +++ b/packages/filepicker/src/Classic/ClassicReader.ts @@ -1,5 +1,5 @@ -import { ByteChunker } from './../Chunker/ByteChunker' -import { OnChunkCallback, FileSelectionResponse } from '../types' +import { ByteChunker, OnChunkCallback } from '@standardnotes/files' +import { FileSelectionResponse } from '../types' import { readFile as utilsReadFile } from '../utils' import { FileReaderInterface } from '../Interface/FileReader' diff --git a/packages/filepicker/src/Interface/FileReader.ts b/packages/filepicker/src/Interface/FileReader.ts index 5d3e4d81f..8ba8f6023 100644 --- a/packages/filepicker/src/Interface/FileReader.ts +++ b/packages/filepicker/src/Interface/FileReader.ts @@ -1,4 +1,6 @@ -import { OnChunkCallback, FileSelectionResponse } from '../types' +import { OnChunkCallback } from '@standardnotes/files' + +import { FileSelectionResponse } from '../types' export interface FileReaderInterface { selectFiles(): Promise diff --git a/packages/filepicker/src/Streaming/StreamingApi.ts b/packages/filepicker/src/Streaming/StreamingApi.ts index 75642d6c0..50b9fa041 100644 --- a/packages/filepicker/src/Streaming/StreamingApi.ts +++ b/packages/filepicker/src/Streaming/StreamingApi.ts @@ -5,7 +5,7 @@ import { FileHandleRead, FileSystemNoSelection, FileSystemResult, -} from '@standardnotes/services' +} from '@standardnotes/files' interface WebDirectoryHandle extends DirectoryHandle { nativeHandle: FileSystemDirectoryHandle diff --git a/packages/filepicker/src/Streaming/StreamingReader.ts b/packages/filepicker/src/Streaming/StreamingReader.ts index 9448c180e..4df1d1a14 100644 --- a/packages/filepicker/src/Streaming/StreamingReader.ts +++ b/packages/filepicker/src/Streaming/StreamingReader.ts @@ -1,6 +1,7 @@ +import { ByteChunker, OnChunkCallback } from '@standardnotes/files' + import { FileReaderInterface } from './../Interface/FileReader' -import { ByteChunker } from '../Chunker/ByteChunker' -import { OnChunkCallback, FileSelectionResponse } from '../types' +import { FileSelectionResponse } from '../types' interface StreamingFileReaderInterface { getFilesFromHandles(handles: FileSystemFileHandle[]): Promise diff --git a/packages/filepicker/src/TypedBytes.ts b/packages/filepicker/src/TypedBytes.ts deleted file mode 100644 index 1e319ccff..000000000 --- a/packages/filepicker/src/TypedBytes.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type EncryptedBytes = { - encryptedBytes: Uint8Array -} - -export type DecryptedBytes = { - decryptedBytes: Uint8Array -} diff --git a/packages/filepicker/src/index.ts b/packages/filepicker/src/index.ts index 306f38890..eaf955f7f 100644 --- a/packages/filepicker/src/index.ts +++ b/packages/filepicker/src/index.ts @@ -5,7 +5,4 @@ export * from './Streaming/StreamingReader' export * from './Streaming/StreamingSaver' export * from './Streaming/StreamingApi' export * from './utils' -export * from './Chunker/ByteChunker' -export * from './Chunker/OrderedByteChunker' export * from './Cache/FileMemoryCache' -export * from './TypedBytes' diff --git a/packages/filepicker/src/types.ts b/packages/filepicker/src/types.ts index a4e174a2c..2aa209978 100644 --- a/packages/filepicker/src/types.ts +++ b/packages/filepicker/src/types.ts @@ -1,5 +1,3 @@ -export type OnChunkCallback = (chunk: Uint8Array, index: number, isLast: boolean) => Promise - export type FileSelectionResponse = { name: string mimeType: string diff --git a/packages/files/package.json b/packages/files/package.json index 305839e9e..548ef70ad 100644 --- a/packages/files/package.json +++ b/packages/files/package.json @@ -32,7 +32,6 @@ "dependencies": { "@standardnotes/common": "^1.23.1", "@standardnotes/encryption": "workspace:*", - "@standardnotes/filepicker": "workspace:*", "@standardnotes/models": "workspace:*", "@standardnotes/responses": "workspace:*", "@standardnotes/sncrypto-common": "workspace:*", diff --git a/packages/filepicker/src/Chunker/ByteChunker.spec.ts b/packages/files/src/Domain/Chunker/ByteChunker.spec.ts similarity index 100% rename from packages/filepicker/src/Chunker/ByteChunker.spec.ts rename to packages/files/src/Domain/Chunker/ByteChunker.spec.ts diff --git a/packages/filepicker/src/Chunker/ByteChunker.ts b/packages/files/src/Domain/Chunker/ByteChunker.ts similarity index 95% rename from packages/filepicker/src/Chunker/ByteChunker.ts rename to packages/files/src/Domain/Chunker/ByteChunker.ts index ab2c1388d..55deb700e 100644 --- a/packages/filepicker/src/Chunker/ByteChunker.ts +++ b/packages/files/src/Domain/Chunker/ByteChunker.ts @@ -1,4 +1,4 @@ -import { OnChunkCallback } from '../types' +import { OnChunkCallback } from './OnChunkCallback' export class ByteChunker { public loggingEnabled = false diff --git a/packages/files/src/Domain/Chunker/OnChunkCallback.ts b/packages/files/src/Domain/Chunker/OnChunkCallback.ts new file mode 100644 index 000000000..9cac24d39 --- /dev/null +++ b/packages/files/src/Domain/Chunker/OnChunkCallback.ts @@ -0,0 +1 @@ +export type OnChunkCallback = (chunk: Uint8Array, index: number, isLast: boolean) => Promise diff --git a/packages/filepicker/src/Chunker/OrderedByteChunker.spec.ts b/packages/files/src/Domain/Chunker/OrderedByteChunker.spec.ts similarity index 100% rename from packages/filepicker/src/Chunker/OrderedByteChunker.spec.ts rename to packages/files/src/Domain/Chunker/OrderedByteChunker.spec.ts diff --git a/packages/filepicker/src/Chunker/OrderedByteChunker.ts b/packages/files/src/Domain/Chunker/OrderedByteChunker.ts similarity index 100% rename from packages/filepicker/src/Chunker/OrderedByteChunker.ts rename to packages/files/src/Domain/Chunker/OrderedByteChunker.ts diff --git a/packages/files/src/Domain/Operations/DownloadAndDecrypt.ts b/packages/files/src/Domain/Operations/DownloadAndDecrypt.ts index 083d78593..a2f644332 100644 --- a/packages/files/src/Domain/Operations/DownloadAndDecrypt.ts +++ b/packages/files/src/Domain/Operations/DownloadAndDecrypt.ts @@ -4,8 +4,9 @@ import { FileDecryptor } from '../UseCase/FileDecryptor' import { FileDownloadProgress } from '../Types/FileDownloadProgress' import { PureCryptoInterface } from '@standardnotes/sncrypto-common' import { FileContent } from '@standardnotes/models' -import { DecryptedBytes, EncryptedBytes } from '@standardnotes/filepicker' import { FilesApiInterface } from '../Api/FilesApiInterface' +import { DecryptedBytes } from '../Types/DecryptedBytes' +import { EncryptedBytes } from '../Types/EncryptedBytes' export type DownloadAndDecryptResult = { success: boolean; error?: ClientDisplayableError; aborted?: boolean } diff --git a/packages/files/src/Domain/Service/ReadAndDecryptBackupFile.ts b/packages/files/src/Domain/Service/ReadAndDecryptBackupFile.ts index 721078461..3a1e1f39b 100644 --- a/packages/files/src/Domain/Service/ReadAndDecryptBackupFile.ts +++ b/packages/files/src/Domain/Service/ReadAndDecryptBackupFile.ts @@ -1,9 +1,9 @@ import { FileContent } from '@standardnotes/models' import { PureCryptoInterface } from '@standardnotes/sncrypto-common' -import { OrderedByteChunker } from '@standardnotes/filepicker' import { FileDecryptor } from '../UseCase/FileDecryptor' import { FileSystemApi } from '../Api/FileSystemApi' import { FileHandleRead } from '../Api/FileHandleRead' +import { OrderedByteChunker } from '../Chunker/OrderedByteChunker' export async function readAndDecryptBackupFile( fileHandle: FileHandleRead, diff --git a/packages/files/src/Domain/Types/DecryptedBytes.ts b/packages/files/src/Domain/Types/DecryptedBytes.ts new file mode 100644 index 000000000..10b2bd59b --- /dev/null +++ b/packages/files/src/Domain/Types/DecryptedBytes.ts @@ -0,0 +1,3 @@ +export type DecryptedBytes = { + decryptedBytes: Uint8Array +} diff --git a/packages/files/src/Domain/Types/EncryptedBytes.ts b/packages/files/src/Domain/Types/EncryptedBytes.ts new file mode 100644 index 000000000..e57abf5ec --- /dev/null +++ b/packages/files/src/Domain/Types/EncryptedBytes.ts @@ -0,0 +1,3 @@ +export type EncryptedBytes = { + encryptedBytes: Uint8Array +} diff --git a/packages/files/src/Domain/index.ts b/packages/files/src/Domain/index.ts index be6d9354a..908e6c34c 100644 --- a/packages/files/src/Domain/index.ts +++ b/packages/files/src/Domain/index.ts @@ -5,6 +5,9 @@ export * from './Api/FileSystemApi' export * from './Api/FileSystemNoSelection' export * from './Api/FileSystemResult' export * from './Api/FilesApiInterface' +export * from './Chunker/ByteChunker' +export * from './Chunker/OnChunkCallback' +export * from './Chunker/OrderedByteChunker' export * from './Device/FileBackupMetadataFile' export * from './Device/FileBackupsConstantsV1' export * from './Device/FileBackupsDevice' @@ -17,6 +20,8 @@ export * from './UseCase/FileDecryptor' export * from './UseCase/FileUploader' export * from './UseCase/FileEncryptor' export * from './UseCase/FileDownloader' +export * from './Types/DecryptedBytes' +export * from './Types/EncryptedBytes' export * from './Types/FileDownloadProgress' export * from './Types/FileUploadProgress' export * from './Types/FileUploadResult' diff --git a/packages/mobile/package.json b/packages/mobile/package.json index 44f2c0825..3aa5c50f1 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -37,7 +37,6 @@ "@react-navigation/stack": "^6.2.1", "@standardnotes/components-meta": "workspace:*", "@standardnotes/filepicker": "workspace:*", - "@standardnotes/files": "workspace:*", "@standardnotes/icons": "workspace:*", "@standardnotes/react-native-aes": "^1.4.3", "@standardnotes/react-native-textview": "1.1.0", diff --git a/packages/mobile/src/Hooks/useFiles.ts b/packages/mobile/src/Hooks/useFiles.ts index af9587d8f..208ce74c2 100644 --- a/packages/mobile/src/Hooks/useFiles.ts +++ b/packages/mobile/src/Hooks/useFiles.ts @@ -9,8 +9,15 @@ import { UploadedFileItemActionType, } from '@Root/Screens/UploadedFilesList/UploadedFileItemAction' import { Tabs } from '@Screens/UploadedFilesList/UploadedFilesList' -import { FileDownloadProgress } from '@standardnotes/files' -import { ButtonType, ChallengeReason, ClientDisplayableError, ContentType, FileItem, SNNote } from '@standardnotes/snjs' +import { + ButtonType, + ChallengeReason, + ClientDisplayableError, + ContentType, + FileDownloadProgress, + FileItem, + SNNote, +} from '@standardnotes/snjs' import { CustomActionSheetOption, useCustomActionSheet } from '@Style/CustomActionSheet' import { useCallback, useEffect, useState } from 'react' import { Platform } from 'react-native' diff --git a/packages/mobile/src/Lib/FilesService.ts b/packages/mobile/src/Lib/FilesService.ts index 094aaec7f..1e478f0b4 100644 --- a/packages/mobile/src/Lib/FilesService.ts +++ b/packages/mobile/src/Lib/FilesService.ts @@ -1,7 +1,6 @@ import { ByteChunker, FileSelectionResponse, OnChunkCallback } from '@standardnotes/filepicker' -import { FileDownloadProgress } from '@standardnotes/files' import { ClientDisplayableError } from '@standardnotes/responses' -import { ApplicationService, FileItem } from '@standardnotes/snjs' +import { ApplicationService, FileDownloadProgress, FileItem } from '@standardnotes/snjs' import { Buffer } from 'buffer' import { Base64 } from 'js-base64' import { PermissionsAndroid, Platform } from 'react-native' diff --git a/packages/snjs/lib/index.ts b/packages/snjs/lib/index.ts index f8eadd30a..75264e0d8 100644 --- a/packages/snjs/lib/index.ts +++ b/packages/snjs/lib/index.ts @@ -9,6 +9,7 @@ export * from './Version' export * from '@standardnotes/common' export * from '@standardnotes/encryption' export * from '@standardnotes/features' +export * from '@standardnotes/files' export * from '@standardnotes/models' export * from '@standardnotes/responses' export * from '@standardnotes/services' diff --git a/packages/ui-services/package.json b/packages/ui-services/package.json index 4fae95890..305f63cdc 100644 --- a/packages/ui-services/package.json +++ b/packages/ui-services/package.json @@ -23,9 +23,9 @@ "test:unit": "jest spec --coverage" }, "dependencies": { + "@standardnotes/common": "^1.30.0", "@standardnotes/filepicker": "workspace:^", "@standardnotes/services": "workspace:^", - "@standardnotes/snjs": "workspace:^", "@standardnotes/styles": "workspace:^", "@standardnotes/toast": "workspace:^", "@standardnotes/utils": "workspace:^" diff --git a/packages/ui-services/src/Archive/ArchiveManager.ts b/packages/ui-services/src/Archive/ArchiveManager.ts index 305dfadd1..938df80af 100644 --- a/packages/ui-services/src/Archive/ArchiveManager.ts +++ b/packages/ui-services/src/Archive/ArchiveManager.ts @@ -1,12 +1,12 @@ import { parseFileName } from '@standardnotes/filepicker' import { BackupFile, - ContentType, BackupFileDecryptedContextualPayload, - NoteContent, EncryptedItemInterface, - SNApplication, -} from '@standardnotes/snjs' + NoteContent, +} from '@standardnotes/models' +import { ContentType } from '@standardnotes/common' +import { ApplicationInterface } from '@standardnotes/services' function sanitizeFileName(name: string): string { return name.trim().replace(/[.\\/:"?*|<>]/g, '_') @@ -27,10 +27,10 @@ type ZippableData = { type ObjectURL = string export class ArchiveManager { - private readonly application: SNApplication + private readonly application: ApplicationInterface private textFile?: string - constructor(application: SNApplication) { + constructor(application: ApplicationInterface) { this.application = application } diff --git a/packages/ui-services/src/IO/IOService.ts b/packages/ui-services/src/IO/IOService.ts index cf37f4857..3065c3e6f 100644 --- a/packages/ui-services/src/IO/IOService.ts +++ b/packages/ui-services/src/IO/IOService.ts @@ -1,4 +1,4 @@ -import { removeFromArray } from '@standardnotes/snjs' +import { removeFromArray } from '@standardnotes/utils' export enum KeyboardKey { Tab = 'Tab', diff --git a/packages/ui-services/src/index.ts b/packages/ui-services/src/index.ts index 10a482bde..4c41fd80f 100644 --- a/packages/ui-services/src/index.ts +++ b/packages/ui-services/src/index.ts @@ -4,4 +4,3 @@ export * from './Archive/ArchiveManager' export * from './IO/IOService' export * from './Security/AutolockService' export * from './Storage/LocalStorage' -export * from './Theme/ThemeManager' diff --git a/packages/web/package.json b/packages/web/package.json index cd2e212cf..e38d1bf9c 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -76,7 +76,6 @@ "@reach/visually-hidden": "^0.16.0", "@standardnotes/components-meta": "workspace:*", "@standardnotes/filepicker": "workspace:*", - "@standardnotes/files": "workspace:*", "@standardnotes/icons": "workspace:*", "@standardnotes/sncrypto-web": "workspace:*", "@standardnotes/snjs": "workspace:*", diff --git a/packages/web/src/javascripts/Application/Application.ts b/packages/web/src/javascripts/Application/Application.ts index 699df2c37..30b47c538 100644 --- a/packages/web/src/javascripts/Application/Application.ts +++ b/packages/web/src/javascripts/Application/Application.ts @@ -22,7 +22,8 @@ import { makeObservable, observable } from 'mobx' import { PanelResizedData } from '@/Types/PanelResizedData' import { isDesktopApplication } from '@/Utils' import { DesktopManager } from './Device/DesktopManager' -import { ArchiveManager, AutolockService, IOService, ThemeManager, WebAlertService } from '@standardnotes/ui-services' +import { ArchiveManager, AutolockService, IOService, WebAlertService } from '@standardnotes/ui-services' +import { ThemeManager } from '@/Theme/ThemeManager' type WebServices = { viewControllerManager: ViewControllerManager diff --git a/packages/ui-services/src/Theme/ThemeManager.ts b/packages/web/src/javascripts/Theme/ThemeManager.ts similarity index 96% rename from packages/ui-services/src/Theme/ThemeManager.ts rename to packages/web/src/javascripts/Theme/ThemeManager.ts index bdc2049ff..52aaf9ac5 100644 --- a/packages/ui-services/src/Theme/ThemeManager.ts +++ b/packages/web/src/javascripts/Theme/ThemeManager.ts @@ -1,27 +1,21 @@ -import { - StorageValueModes, - ApplicationService, - SNTheme, - removeFromArray, - ApplicationEvent, - ContentType, - UuidString, - FeatureStatus, - PrefKey, - CreateDecryptedLocalStorageContextPayload, - InternalEventBus, - PayloadEmitSource, - LocalStorageDecryptedContextualPayload, - WebApplicationInterface, -} from '@standardnotes/snjs' import { dismissToast, ToastType, addTimedToast } from '@standardnotes/toast' +import { ContentType, Uuid } from '@standardnotes/common' +import { + CreateDecryptedLocalStorageContextPayload, + LocalStorageDecryptedContextualPayload, + PayloadEmitSource, + PrefKey, + SNTheme, +} from '@standardnotes/models' +import { removeFromArray } from '@standardnotes/utils' +import { ApplicationEvent, ApplicationService, FeatureStatus, InternalEventBus, StorageValueModes, WebApplicationInterface } from '@standardnotes/snjs' const CachedThemesKey = 'cachedThemes' const TimeBeforeApplyingColorScheme = 5 const DefaultThemeIdentifier = 'Default' export class ThemeManager extends ApplicationService { - private activeThemes: UuidString[] = [] + private activeThemes: Uuid[] = [] private unregisterDesktop?: () => void private unregisterStream!: () => void private lastUseDeviceThemeSettings = false diff --git a/yarn.lock b/yarn.lock index 7c49f7f7b..f5f7d31f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6640,7 +6640,7 @@ __metadata: resolution: "@standardnotes/filepicker@workspace:packages/filepicker" dependencies: "@standardnotes/common": ^1.23.1 - "@standardnotes/services": "workspace:*" + "@standardnotes/files": "workspace:*" "@standardnotes/utils": "workspace:*" "@types/jest": ^28.1.5 "@types/wicg-file-system-access": ^2020.9.5 @@ -6659,7 +6659,6 @@ __metadata: dependencies: "@standardnotes/common": ^1.23.1 "@standardnotes/encryption": "workspace:*" - "@standardnotes/filepicker": "workspace:*" "@standardnotes/models": "workspace:*" "@standardnotes/responses": "workspace:*" "@standardnotes/sncrypto-common": "workspace:*" @@ -6959,7 +6958,6 @@ __metadata: "@standardnotes/components-meta": "workspace:*" "@standardnotes/config": ^2.4.3 "@standardnotes/filepicker": "workspace:*" - "@standardnotes/files": "workspace:*" "@standardnotes/icons": "workspace:*" "@standardnotes/react-native-aes": ^1.4.3 "@standardnotes/react-native-textview": 1.1.0 @@ -7282,7 +7280,7 @@ __metadata: languageName: unknown linkType: soft -"@standardnotes/snjs@^2.41.1, @standardnotes/snjs@workspace:*, @standardnotes/snjs@workspace:^, @standardnotes/snjs@workspace:packages/snjs": +"@standardnotes/snjs@^2.41.1, @standardnotes/snjs@workspace:*, @standardnotes/snjs@workspace:packages/snjs": version: 0.0.0-use.local resolution: "@standardnotes/snjs@workspace:packages/snjs" dependencies: @@ -7459,9 +7457,9 @@ __metadata: version: 0.0.0-use.local resolution: "@standardnotes/ui-services@workspace:packages/ui-services" dependencies: + "@standardnotes/common": ^1.30.0 "@standardnotes/filepicker": "workspace:^" "@standardnotes/services": "workspace:^" - "@standardnotes/snjs": "workspace:^" "@standardnotes/styles": "workspace:^" "@standardnotes/toast": "workspace:^" "@standardnotes/utils": "workspace:^" @@ -7514,7 +7512,6 @@ __metadata: "@reach/visually-hidden": ^0.16.0 "@standardnotes/components-meta": "workspace:*" "@standardnotes/filepicker": "workspace:*" - "@standardnotes/files": "workspace:*" "@standardnotes/icons": "workspace:*" "@standardnotes/sncrypto-web": "workspace:*" "@standardnotes/snjs": "workspace:*"