fix(files): filepicker circular dependency

This commit is contained in:
Karol Sójko
2022-08-04 17:32:49 +02:00
parent 696b82b9d3
commit 183f68c9c1
33 changed files with 64 additions and 64 deletions

View File

@@ -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"

View File

@@ -1,4 +1,5 @@
import { EncryptedBytes } from './../TypedBytes'
import { EncryptedBytes } from '@standardnotes/files'
import { FileMemoryCache } from './FileMemoryCache'
describe('file memory cache', () => {

View File

@@ -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<Uuid, EncryptedBytes> = {}

View File

@@ -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'

View File

@@ -1,4 +1,6 @@
import { OnChunkCallback, FileSelectionResponse } from '../types'
import { OnChunkCallback } from '@standardnotes/files'
import { FileSelectionResponse } from '../types'
export interface FileReaderInterface {
selectFiles(): Promise<File[]>

View File

@@ -5,7 +5,7 @@ import {
FileHandleRead,
FileSystemNoSelection,
FileSystemResult,
} from '@standardnotes/services'
} from '@standardnotes/files'
interface WebDirectoryHandle extends DirectoryHandle {
nativeHandle: FileSystemDirectoryHandle

View File

@@ -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<File[]>

View File

@@ -1,7 +0,0 @@
export type EncryptedBytes = {
encryptedBytes: Uint8Array
}
export type DecryptedBytes = {
decryptedBytes: Uint8Array
}

View File

@@ -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'

View File

@@ -1,5 +1,3 @@
export type OnChunkCallback = (chunk: Uint8Array, index: number, isLast: boolean) => Promise<void>
export type FileSelectionResponse = {
name: string
mimeType: string

View File

@@ -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:*",

View File

@@ -1,4 +1,4 @@
import { OnChunkCallback } from '../types'
import { OnChunkCallback } from './OnChunkCallback'
export class ByteChunker {
public loggingEnabled = false

View File

@@ -0,0 +1 @@
export type OnChunkCallback = (chunk: Uint8Array, index: number, isLast: boolean) => Promise<void>

View File

@@ -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 }

View File

@@ -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,

View File

@@ -0,0 +1,3 @@
export type DecryptedBytes = {
decryptedBytes: Uint8Array
}

View File

@@ -0,0 +1,3 @@
export type EncryptedBytes = {
encryptedBytes: Uint8Array
}

View File

@@ -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'

View File

@@ -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",

View File

@@ -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'

View File

@@ -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'

View File

@@ -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'

View File

@@ -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:^"

View File

@@ -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
}

View File

@@ -1,4 +1,4 @@
import { removeFromArray } from '@standardnotes/snjs'
import { removeFromArray } from '@standardnotes/utils'
export enum KeyboardKey {
Tab = 'Tab',

View File

@@ -4,4 +4,3 @@ export * from './Archive/ArchiveManager'
export * from './IO/IOService'
export * from './Security/AutolockService'
export * from './Storage/LocalStorage'
export * from './Theme/ThemeManager'

View File

@@ -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:*",

View File

@@ -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

View File

@@ -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

View File

@@ -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:*"