@fgv/ts-web-extras 5.1.0-4 → 5.1.0-41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packlets/crypto-utils/browserCryptoProvider.js +413 -18
- package/dist/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
- package/dist/packlets/crypto-utils/idbPrivateKeyStorage.js +238 -0
- package/dist/packlets/crypto-utils/idbPrivateKeyStorage.js.map +1 -0
- package/dist/packlets/crypto-utils/index.js +13 -0
- package/dist/packlets/crypto-utils/index.js.map +1 -1
- package/dist/packlets/file-tree/directoryHandleStore.js.map +1 -1
- package/dist/packlets/file-tree/fileApiTreeAccessors.js +1 -1
- package/dist/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
- package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js +2 -2
- package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -1
- package/dist/packlets/file-tree/httpTreeAccessors.js +74 -44
- package/dist/packlets/file-tree/httpTreeAccessors.js.map +1 -1
- package/dist/packlets/file-tree/localStorageTreeAccessors.js.map +1 -1
- package/dist/packlets/helpers/fileTreeHelpers.js +1 -1
- package/dist/packlets/helpers/fileTreeHelpers.js.map +1 -1
- package/dist/ts-web-extras.d.ts +259 -10
- package/dist/tsdoc-metadata.json +1 -1
- package/eslint.config.js +32 -0
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts +145 -6
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts.map +1 -1
- package/lib/packlets/crypto-utils/browserCryptoProvider.js +412 -17
- package/lib/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
- package/lib/packlets/crypto-utils/idbPrivateKeyStorage.d.ts +87 -0
- package/lib/packlets/crypto-utils/idbPrivateKeyStorage.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/idbPrivateKeyStorage.js +242 -0
- package/lib/packlets/crypto-utils/idbPrivateKeyStorage.js.map +1 -0
- package/lib/packlets/crypto-utils/index.d.ts +14 -0
- package/lib/packlets/crypto-utils/index.d.ts.map +1 -1
- package/lib/packlets/crypto-utils/index.js +14 -0
- package/lib/packlets/crypto-utils/index.js.map +1 -1
- package/lib/packlets/file-tree/directoryHandleStore.d.ts +2 -2
- package/lib/packlets/file-tree/directoryHandleStore.d.ts.map +1 -1
- package/lib/packlets/file-tree/directoryHandleStore.js.map +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts +2 -2
- package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts.map +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.js +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.d.ts.map +1 -1
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js +2 -2
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -1
- package/lib/packlets/file-tree/httpTreeAccessors.d.ts +6 -0
- package/lib/packlets/file-tree/httpTreeAccessors.d.ts.map +1 -1
- package/lib/packlets/file-tree/httpTreeAccessors.js +74 -44
- package/lib/packlets/file-tree/httpTreeAccessors.js.map +1 -1
- package/lib/packlets/file-tree/localStorageTreeAccessors.js.map +1 -1
- package/lib/packlets/helpers/fileTreeHelpers.d.ts +1 -1
- package/lib/packlets/helpers/fileTreeHelpers.d.ts.map +1 -1
- package/lib/packlets/helpers/fileTreeHelpers.js +6 -6
- package/lib/packlets/helpers/fileTreeHelpers.js.map +1 -1
- package/package.json +15 -14
- package/.rush/temp/44b0369e8112f3c6f4248af466a3f35ad626d9d7.tar.log +0 -237
- package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +0 -55
- package/.rush/temp/operation/build/all.log +0 -55
- package/.rush/temp/operation/build/log-chunks.jsonl +0 -55
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/shrinkwrap-deps.json +0 -692
- package/CHANGELOG.md +0 -23
- package/config/api-extractor.json +0 -343
- package/config/jest.config.json +0 -19
- package/config/rig.json +0 -16
- package/config/typedoc.json +0 -7
- package/dist/test/mocks/idb-keyval.js +0 -6
- package/dist/test/mocks/idb-keyval.js.map +0 -1
- package/dist/test/setupTests.js +0 -74
- package/dist/test/setupTests.js.map +0 -1
- package/dist/test/unit/browserHashProvider.test.js +0 -140
- package/dist/test/unit/browserHashProvider.test.js.map +0 -1
- package/dist/test/unit/directoryHandleStore.test.js +0 -190
- package/dist/test/unit/directoryHandleStore.test.js.map +0 -1
- package/dist/test/unit/fileApiTreeAccessors.test.js +0 -1188
- package/dist/test/unit/fileApiTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/fileApiTypes.test.js +0 -472
- package/dist/test/unit/fileApiTypes.test.js.map +0 -1
- package/dist/test/unit/fileSystemAccessTreeAccessors.test.js +0 -622
- package/dist/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/fileTreeHelpers.test.js +0 -590
- package/dist/test/unit/fileTreeHelpers.test.js.map +0 -1
- package/dist/test/unit/httpTreeAccessors.test.js +0 -1229
- package/dist/test/unit/httpTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/localStorageTreeAccessors.test.js +0 -812
- package/dist/test/unit/localStorageTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/urlParams.test.js +0 -393
- package/dist/test/unit/urlParams.test.js.map +0 -1
- package/dist/test/utils/fileSystemAccessMocks.js +0 -271
- package/dist/test/utils/fileSystemAccessMocks.js.map +0 -1
- package/dist/test/utils/testHelpers.js +0 -124
- package/dist/test/utils/testHelpers.js.map +0 -1
- package/docs/CryptoUtils/README.md +0 -60
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.decrypt.md +0 -27
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.deriveKey.md +0 -26
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.encrypt.md +0 -25
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.fromBase64.md +0 -24
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateKey.md +0 -17
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateRandomBytes.md +0 -24
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.md +0 -151
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.toBase64.md +0 -24
- package/docs/CryptoUtils/classes/BrowserHashProvider.hashParts.md +0 -26
- package/docs/CryptoUtils/classes/BrowserHashProvider.hashString.md +0 -25
- package/docs/CryptoUtils/classes/BrowserHashProvider.md +0 -81
- package/docs/CryptoUtils/functions/createBrowserCryptoProvider.md +0 -12
- package/docs/FileTreeHelpers/README.md +0 -85
- package/docs/FileTreeHelpers/functions/extractFileListMetadata.md +0 -11
- package/docs/FileTreeHelpers/functions/extractFileMetadata.md +0 -11
- package/docs/FileTreeHelpers/functions/fromDirectoryUpload.md +0 -12
- package/docs/FileTreeHelpers/functions/fromFileList.md +0 -12
- package/docs/FileTreeHelpers/functions/getOriginalFile.md +0 -11
- package/docs/FileTreeHelpers/variables/defaultFileApiTreeInitParams.md +0 -9
- package/docs/README.md +0 -524
- package/docs/classes/BrowserCryptoProvider.decrypt.md +0 -27
- package/docs/classes/BrowserCryptoProvider.deriveKey.md +0 -26
- package/docs/classes/BrowserCryptoProvider.encrypt.md +0 -25
- package/docs/classes/BrowserCryptoProvider.fromBase64.md +0 -24
- package/docs/classes/BrowserCryptoProvider.generateKey.md +0 -17
- package/docs/classes/BrowserCryptoProvider.generateRandomBytes.md +0 -24
- package/docs/classes/BrowserCryptoProvider.md +0 -151
- package/docs/classes/BrowserCryptoProvider.toBase64.md +0 -24
- package/docs/classes/BrowserHashProvider.hashParts.md +0 -26
- package/docs/classes/BrowserHashProvider.hashString.md +0 -25
- package/docs/classes/BrowserHashProvider.md +0 -81
- package/docs/classes/DirectoryHandleStore.getAll.md +0 -17
- package/docs/classes/DirectoryHandleStore.getAllLabels.md +0 -17
- package/docs/classes/DirectoryHandleStore.load.md +0 -24
- package/docs/classes/DirectoryHandleStore.md +0 -120
- package/docs/classes/DirectoryHandleStore.remove.md +0 -24
- package/docs/classes/DirectoryHandleStore.save.md +0 -25
- package/docs/classes/FileApiTreeAccessors.create.md +0 -25
- package/docs/classes/FileApiTreeAccessors.createFromHttp.md +0 -24
- package/docs/classes/FileApiTreeAccessors.createFromLocalStorage.md +0 -25
- package/docs/classes/FileApiTreeAccessors.createPersistent.md +0 -26
- package/docs/classes/FileApiTreeAccessors.createPersistentFromFile.md +0 -27
- package/docs/classes/FileApiTreeAccessors.extractFileMetadata.md +0 -24
- package/docs/classes/FileApiTreeAccessors.fromDirectoryUpload.md +0 -25
- package/docs/classes/FileApiTreeAccessors.fromFileList.md +0 -25
- package/docs/classes/FileApiTreeAccessors.getOriginalFile.md +0 -27
- package/docs/classes/FileApiTreeAccessors.md +0 -172
- package/docs/classes/FileSystemAccessTreeAccessors.deleteFile.md +0 -22
- package/docs/classes/FileSystemAccessTreeAccessors.fileIsMutable.md +0 -22
- package/docs/classes/FileSystemAccessTreeAccessors.fromDirectoryHandle.md +0 -25
- package/docs/classes/FileSystemAccessTreeAccessors.fromFileHandle.md +0 -29
- package/docs/classes/FileSystemAccessTreeAccessors.getDirtyPaths.md +0 -15
- package/docs/classes/FileSystemAccessTreeAccessors.isDirty.md +0 -15
- package/docs/classes/FileSystemAccessTreeAccessors.md +0 -275
- package/docs/classes/FileSystemAccessTreeAccessors.saveFileContents.md +0 -23
- package/docs/classes/FileSystemAccessTreeAccessors.syncToDisk.md +0 -15
- package/docs/classes/HttpTreeAccessors.deleteFile.md +0 -22
- package/docs/classes/HttpTreeAccessors.fileIsMutable.md +0 -24
- package/docs/classes/HttpTreeAccessors.fromHttp.md +0 -24
- package/docs/classes/HttpTreeAccessors.getDirtyPaths.md +0 -17
- package/docs/classes/HttpTreeAccessors.isDirty.md +0 -17
- package/docs/classes/HttpTreeAccessors.md +0 -261
- package/docs/classes/HttpTreeAccessors.saveFileContents.md +0 -25
- package/docs/classes/HttpTreeAccessors.syncToDisk.md +0 -22
- package/docs/classes/LocalStorageTreeAccessors.deleteFile.md +0 -24
- package/docs/classes/LocalStorageTreeAccessors.fileIsMutable.md +0 -24
- package/docs/classes/LocalStorageTreeAccessors.fromStorage.md +0 -25
- package/docs/classes/LocalStorageTreeAccessors.getDirtyPaths.md +0 -17
- package/docs/classes/LocalStorageTreeAccessors.isDirty.md +0 -17
- package/docs/classes/LocalStorageTreeAccessors.md +0 -270
- package/docs/classes/LocalStorageTreeAccessors.saveFileContents.md +0 -25
- package/docs/classes/LocalStorageTreeAccessors.syncToDisk.md +0 -17
- package/docs/functions/createBrowserCryptoProvider.md +0 -12
- package/docs/functions/exportAsJson.md +0 -12
- package/docs/functions/exportUsingFileSystemAPI.md +0 -11
- package/docs/functions/extractDirectoryPath.md +0 -13
- package/docs/functions/extractFileListMetadata.md +0 -11
- package/docs/functions/extractFileMetadata.md +0 -11
- package/docs/functions/fromDirectoryUpload.md +0 -12
- package/docs/functions/fromFileList.md +0 -12
- package/docs/functions/getOriginalFile.md +0 -11
- package/docs/functions/isDirectoryHandle.md +0 -11
- package/docs/functions/isFileHandle.md +0 -11
- package/docs/functions/isFilePath.md +0 -11
- package/docs/functions/parseContextFilter.md +0 -12
- package/docs/functions/parseQualifierDefaults.md +0 -12
- package/docs/functions/parseResourceTypes.md +0 -12
- package/docs/functions/parseUrlParameters.md +0 -11
- package/docs/functions/safeShowDirectoryPicker.md +0 -11
- package/docs/functions/safeShowOpenFilePicker.md +0 -11
- package/docs/functions/safeShowSaveFilePicker.md +0 -11
- package/docs/functions/supportsFileSystemAccess.md +0 -11
- package/docs/interfaces/FilePickerAcceptType.accept.md +0 -9
- package/docs/interfaces/FilePickerAcceptType.description.md +0 -9
- package/docs/interfaces/FilePickerAcceptType.md +0 -61
- package/docs/interfaces/FileSystemCreateWritableOptions.keepExistingData.md +0 -9
- package/docs/interfaces/FileSystemCreateWritableOptions.md +0 -44
- package/docs/interfaces/FileSystemDirectoryHandle._asyncIterator_.md +0 -13
- package/docs/interfaces/FileSystemDirectoryHandle.entries.md +0 -13
- package/docs/interfaces/FileSystemDirectoryHandle.getDirectoryHandle.md +0 -21
- package/docs/interfaces/FileSystemDirectoryHandle.getFileHandle.md +0 -21
- package/docs/interfaces/FileSystemDirectoryHandle.keys.md +0 -13
- package/docs/interfaces/FileSystemDirectoryHandle.kind.md +0 -9
- package/docs/interfaces/FileSystemDirectoryHandle.md +0 -224
- package/docs/interfaces/FileSystemDirectoryHandle.removeEntry.md +0 -21
- package/docs/interfaces/FileSystemDirectoryHandle.resolve.md +0 -20
- package/docs/interfaces/FileSystemDirectoryHandle.values.md +0 -13
- package/docs/interfaces/FileSystemFileHandle.createWritable.md +0 -20
- package/docs/interfaces/FileSystemFileHandle.getFile.md +0 -13
- package/docs/interfaces/FileSystemFileHandle.kind.md +0 -9
- package/docs/interfaces/FileSystemFileHandle.md +0 -146
- package/docs/interfaces/FileSystemGetDirectoryOptions.create.md +0 -9
- package/docs/interfaces/FileSystemGetDirectoryOptions.md +0 -44
- package/docs/interfaces/FileSystemGetFileOptions.create.md +0 -9
- package/docs/interfaces/FileSystemGetFileOptions.md +0 -44
- package/docs/interfaces/FileSystemHandle.isSameEntry.md +0 -20
- package/docs/interfaces/FileSystemHandle.kind.md +0 -9
- package/docs/interfaces/FileSystemHandle.md +0 -118
- package/docs/interfaces/FileSystemHandle.name.md +0 -9
- package/docs/interfaces/FileSystemHandle.queryPermission.md +0 -20
- package/docs/interfaces/FileSystemHandle.requestPermission.md +0 -20
- package/docs/interfaces/FileSystemHandlePermissionDescriptor.md +0 -44
- package/docs/interfaces/FileSystemHandlePermissionDescriptor.mode.md +0 -9
- package/docs/interfaces/FileSystemRemoveOptions.md +0 -44
- package/docs/interfaces/FileSystemRemoveOptions.recursive.md +0 -9
- package/docs/interfaces/FileSystemWritableFileStream.md +0 -142
- package/docs/interfaces/FileSystemWritableFileStream.seek.md +0 -20
- package/docs/interfaces/FileSystemWritableFileStream.truncate.md +0 -20
- package/docs/interfaces/FileSystemWritableFileStream.write.md +0 -20
- package/docs/interfaces/IDirectoryHandleTreeInitializer.dirHandles.md +0 -9
- package/docs/interfaces/IDirectoryHandleTreeInitializer.md +0 -78
- package/docs/interfaces/IDirectoryHandleTreeInitializer.nonRecursive.md +0 -9
- package/docs/interfaces/IDirectoryHandleTreeInitializer.prefix.md +0 -9
- package/docs/interfaces/IFileHandleTreeInitializer.fileHandles.md +0 -9
- package/docs/interfaces/IFileHandleTreeInitializer.md +0 -61
- package/docs/interfaces/IFileHandleTreeInitializer.prefix.md +0 -9
- package/docs/interfaces/IFileListTreeInitializer.fileList.md +0 -9
- package/docs/interfaces/IFileListTreeInitializer.md +0 -44
- package/docs/interfaces/IFileMetadata.lastModified.md +0 -9
- package/docs/interfaces/IFileMetadata.md +0 -112
- package/docs/interfaces/IFileMetadata.name.md +0 -9
- package/docs/interfaces/IFileMetadata.path.md +0 -9
- package/docs/interfaces/IFileMetadata.size.md +0 -9
- package/docs/interfaces/IFileMetadata.type.md +0 -9
- package/docs/interfaces/IFileSystemAccessTreeParams.autoSync.md +0 -12
- package/docs/interfaces/IFileSystemAccessTreeParams.filePath.md +0 -13
- package/docs/interfaces/IFileSystemAccessTreeParams.logger.md +0 -11
- package/docs/interfaces/IFileSystemAccessTreeParams.md +0 -148
- package/docs/interfaces/IFileSystemAccessTreeParams.requireWritePermission.md +0 -13
- package/docs/interfaces/IFsAccessApis.md +0 -62
- package/docs/interfaces/IFsAccessApis.showDirectoryPicker.md +0 -20
- package/docs/interfaces/IFsAccessApis.showOpenFilePicker.md +0 -20
- package/docs/interfaces/IFsAccessApis.showSaveFilePicker.md +0 -20
- package/docs/interfaces/IHttpTreeParams.autoSync.md +0 -9
- package/docs/interfaces/IHttpTreeParams.baseUrl.md +0 -9
- package/docs/interfaces/IHttpTreeParams.fetchImpl.md +0 -9
- package/docs/interfaces/IHttpTreeParams.logger.md +0 -9
- package/docs/interfaces/IHttpTreeParams.md +0 -182
- package/docs/interfaces/IHttpTreeParams.namespace.md +0 -9
- package/docs/interfaces/IHttpTreeParams.userId.md +0 -9
- package/docs/interfaces/ILocalStorageTreeParams.autoSync.md +0 -12
- package/docs/interfaces/ILocalStorageTreeParams.md +0 -131
- package/docs/interfaces/ILocalStorageTreeParams.pathToKeyMap.md +0 -13
- package/docs/interfaces/ILocalStorageTreeParams.storage.md +0 -12
- package/docs/interfaces/IUrlConfigOptions.config.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.configStartDir.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.contextFilter.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.input.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.inputStartDir.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.interactive.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.loadZip.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.maxDistance.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.md +0 -248
- package/docs/interfaces/IUrlConfigOptions.qualifierDefaults.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.reduceQualifiers.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.resourceTypes.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.zipFile.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.zipPath.md +0 -11
- package/docs/interfaces/ShowDirectoryPickerOptions.id.md +0 -9
- package/docs/interfaces/ShowDirectoryPickerOptions.md +0 -78
- package/docs/interfaces/ShowDirectoryPickerOptions.mode.md +0 -9
- package/docs/interfaces/ShowDirectoryPickerOptions.startIn.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.excludeAcceptAllOption.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.id.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.md +0 -112
- package/docs/interfaces/ShowOpenFilePickerOptions.multiple.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.startIn.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.types.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.excludeAcceptAllOption.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.id.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.md +0 -112
- package/docs/interfaces/ShowSaveFilePickerOptions.startIn.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.suggestedName.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.types.md +0 -9
- package/docs/type-aliases/TreeInitializer.md +0 -11
- package/docs/type-aliases/WellKnownDirectory.md +0 -11
- package/docs/type-aliases/WindowWithFsAccess.md +0 -11
- package/docs/variables/DEFAULT_DIRECTORY_HANDLE_DB.md +0 -9
- package/docs/variables/DEFAULT_DIRECTORY_HANDLE_STORE.md +0 -9
- package/docs/variables/defaultFileApiTreeInitParams.md +0 -9
- package/etc/ts-web-extras.api.md +0 -433
- package/lib/test/mocks/idb-keyval.d.ts +0 -6
- package/lib/test/mocks/idb-keyval.d.ts.map +0 -1
- package/lib/test/mocks/idb-keyval.js +0 -9
- package/lib/test/mocks/idb-keyval.js.map +0 -1
- package/lib/test/setupTests.d.ts +0 -2
- package/lib/test/setupTests.d.ts.map +0 -1
- package/lib/test/setupTests.js +0 -76
- package/lib/test/setupTests.js.map +0 -1
- package/lib/test/unit/browserHashProvider.test.d.ts +0 -2
- package/lib/test/unit/browserHashProvider.test.d.ts.map +0 -1
- package/lib/test/unit/browserHashProvider.test.js +0 -142
- package/lib/test/unit/browserHashProvider.test.js.map +0 -1
- package/lib/test/unit/directoryHandleStore.test.d.ts +0 -2
- package/lib/test/unit/directoryHandleStore.test.d.ts.map +0 -1
- package/lib/test/unit/directoryHandleStore.test.js +0 -192
- package/lib/test/unit/directoryHandleStore.test.js.map +0 -1
- package/lib/test/unit/fileApiTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/fileApiTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/fileApiTreeAccessors.test.js +0 -1190
- package/lib/test/unit/fileApiTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/fileApiTypes.test.d.ts +0 -2
- package/lib/test/unit/fileApiTypes.test.d.ts.map +0 -1
- package/lib/test/unit/fileApiTypes.test.js +0 -474
- package/lib/test/unit/fileApiTypes.test.js.map +0 -1
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.js +0 -624
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/fileTreeHelpers.test.d.ts +0 -2
- package/lib/test/unit/fileTreeHelpers.test.d.ts.map +0 -1
- package/lib/test/unit/fileTreeHelpers.test.js +0 -592
- package/lib/test/unit/fileTreeHelpers.test.js.map +0 -1
- package/lib/test/unit/httpTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/httpTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/httpTreeAccessors.test.js +0 -1231
- package/lib/test/unit/httpTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/localStorageTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/localStorageTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/localStorageTreeAccessors.test.js +0 -814
- package/lib/test/unit/localStorageTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/urlParams.test.d.ts +0 -2
- package/lib/test/unit/urlParams.test.d.ts.map +0 -1
- package/lib/test/unit/urlParams.test.js +0 -395
- package/lib/test/unit/urlParams.test.js.map +0 -1
- package/lib/test/utils/fileSystemAccessMocks.d.ts +0 -53
- package/lib/test/utils/fileSystemAccessMocks.d.ts.map +0 -1
- package/lib/test/utils/fileSystemAccessMocks.js +0 -277
- package/lib/test/utils/fileSystemAccessMocks.js.map +0 -1
- package/lib/test/utils/testHelpers.d.ts +0 -51
- package/lib/test/utils/testHelpers.d.ts.map +0 -1
- package/lib/test/utils/testHelpers.js +0 -133
- package/lib/test/utils/testHelpers.js.map +0 -1
- package/rush-logs/ts-web-extras.build.cache.log +0 -3
- package/rush-logs/ts-web-extras.build.log +0 -55
- package/src/index.browser.ts +0 -24
- package/src/index.ts +0 -47
- package/src/packlets/crypto-utils/browserCryptoProvider.ts +0 -311
- package/src/packlets/crypto-utils/browserHashProvider.ts +0 -73
- package/src/packlets/crypto-utils/index.ts +0 -29
- package/src/packlets/file-api-types/index.ts +0 -366
- package/src/packlets/file-tree/directoryHandleStore.ts +0 -136
- package/src/packlets/file-tree/fileApiTreeAccessors.ts +0 -528
- package/src/packlets/file-tree/fileSystemAccessTreeAccessors.ts +0 -519
- package/src/packlets/file-tree/httpTreeAccessors.ts +0 -448
- package/src/packlets/file-tree/index.ts +0 -32
- package/src/packlets/file-tree/localStorageTreeAccessors.ts +0 -430
- package/src/packlets/helpers/fileTreeHelpers.ts +0 -107
- package/src/packlets/helpers/index.ts +0 -28
- package/src/packlets/url-utils/index.ts +0 -28
- package/src/packlets/url-utils/urlParams.ts +0 -245
- package/src/test/mocks/idb-keyval.ts +0 -5
- package/src/test/setupTests.ts +0 -87
- package/src/test/unit/browserHashProvider.test.ts +0 -155
- package/src/test/unit/browserHashProvider.test.ts.bak +0 -376
- package/src/test/unit/directoryHandleStore.test.ts +0 -251
- package/src/test/unit/fileApiTreeAccessors.test.ts +0 -1387
- package/src/test/unit/fileApiTypes.test.ts +0 -587
- package/src/test/unit/fileSystemAccessTreeAccessors.test.ts +0 -885
- package/src/test/unit/fileTreeHelpers.test.ts +0 -694
- package/src/test/unit/httpTreeAccessors.test.ts +0 -1571
- package/src/test/unit/localStorageTreeAccessors.test.ts +0 -1014
- package/src/test/unit/urlParams.test.ts +0 -464
- package/src/test/utils/fileSystemAccessMocks.ts +0 -353
- package/src/test/utils/testHelpers.ts +0 -155
- package/temp/build/typescript/ts_8nwakTlr.json +0 -1
- package/temp/coverage/base.css +0 -224
- package/temp/coverage/block-navigation.js +0 -87
- package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +0 -1018
- package/temp/coverage/crypto-utils/browserHashProvider.ts.html +0 -304
- package/temp/coverage/crypto-utils/index.html +0 -131
- package/temp/coverage/favicon.png +0 -0
- package/temp/coverage/file-tree/directoryHandleStore.ts.html +0 -493
- package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +0 -1669
- package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
- package/temp/coverage/file-tree/httpTreeAccessors.ts.html +0 -1429
- package/temp/coverage/file-tree/index.html +0 -176
- package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +0 -1375
- package/temp/coverage/helpers/fileTreeHelpers.ts.html +0 -406
- package/temp/coverage/helpers/index.html +0 -116
- package/temp/coverage/index.html +0 -161
- package/temp/coverage/lcov-report/base.css +0 -224
- package/temp/coverage/lcov-report/block-navigation.js +0 -87
- package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +0 -1018
- package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +0 -304
- package/temp/coverage/lcov-report/crypto-utils/index.html +0 -131
- package/temp/coverage/lcov-report/favicon.png +0 -0
- package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +0 -493
- package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +0 -1669
- package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
- package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +0 -1429
- package/temp/coverage/lcov-report/file-tree/index.html +0 -176
- package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +0 -1375
- package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +0 -406
- package/temp/coverage/lcov-report/helpers/index.html +0 -116
- package/temp/coverage/lcov-report/index.html +0 -161
- package/temp/coverage/lcov-report/prettify.css +0 -1
- package/temp/coverage/lcov-report/prettify.js +0 -2
- package/temp/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/temp/coverage/lcov-report/sorter.js +0 -210
- package/temp/coverage/lcov-report/url-utils/index.html +0 -116
- package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +0 -820
- package/temp/coverage/lcov.info +0 -3597
- package/temp/coverage/prettify.css +0 -1
- package/temp/coverage/prettify.js +0 -2
- package/temp/coverage/sort-arrow-sprite.png +0 -0
- package/temp/coverage/sorter.js +0 -210
- package/temp/coverage/url-utils/index.html +0 -116
- package/temp/coverage/url-utils/urlParams.ts.html +0 -820
- package/temp/test/jest/haste-map-7492f1b44480e0cdd1f220078fb3afd8-c8dd6c3430605adeb2f1cadf4f75e791-8c9336785555d572065b28c111982ba4 +0 -0
- package/temp/test/jest/jest-transform-cache-7492f1b44480e0cdd1f220078fb3afd8-79ef2876fae7ca75eedb2aa53dc48338/7c/package_7c16afc8299e635d80273763175c7a50 +0 -53
- package/temp/test/jest/perf-cache-7492f1b44480e0cdd1f220078fb3afd8-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
- package/temp/ts-web-extras.api.json +0 -8850
- package/temp/ts-web-extras.api.md +0 -433
- package/tsconfig.json +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localStorageTreeAccessors.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/localStorageTreeAccessors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAkB,IAAI,EAAU,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AA4BlE;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,yBACX,SAAQ,QAAQ,CAAC,qBAA0B;IAS3C;;;OAGG;IACH,YACE,KAAoC,EACpC,OAAgB,EAChB,YAAiC,EACjC,MAAqC;;QAErC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,OAAO,C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,EAAE,EAAE,CAAC;YACvB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC9B,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACI,gBAAgB,CAAC,IAAY,EAAE,QAAgB;QACpD,MAAM,MAAM,GAAG,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACtD,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;YACvB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC3B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACxC,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC;oBAC3B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAChC,CAAC;qBAAM,CAAC;oBACN,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAClC,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAC,IAAY;QAC/B,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,UAAU,CAAC,SAAS,EAAE,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACxD,OAAO,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DetailedResult, fail, Result, succeed, succeedWithDetail } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport { isJsonObject, type JsonObject } from '@fgv/ts-json-base';\n\n/**\n * Configuration for LocalStorageTreeAccessors.\n * @public\n */\nexport interface ILocalStorageTreeParams<TCT extends string = string>\n extends FileTree.IFileTreeInitParams<TCT> {\n /**\n * Map of directory path prefixes to localStorage keys.\n * Files under each prefix are stored in the corresponding localStorage key.\n * Example: \\{ '/data/ingredients': 'myapp:ingredients:v1' \\}\n */\n pathToKeyMap: Record<string, string>;\n\n /**\n * Storage instance to use. Defaults to window.localStorage.\n * Can be overridden for testing with mock storage.\n */\n storage?: Storage;\n\n /**\n * If true, automatically sync changes to localStorage on every modification.\n * If false (default), changes are only synced when syncToDisk() is called.\n */\n autoSync?: boolean;\n}\n\n/**\n * Browser localStorage-backed file tree accessors with persistence support.\n *\n * Maps filesystem-like directory paths to localStorage keys, where each key stores\n * multiple collections as a JSON object. This provides a general-purpose implementation\n * for browser-based file tree persistence without requiring File System Access API.\n *\n * Storage format per key: `{ \"collection-id\": \"<raw file content>\" }`\n * File paths map as: `/data/ingredients/collection-id.yaml` → stored in key for `/data/ingredients`\n *\n * Legacy format (v1): `{ \"collection-id\": { ...parsedJsonObject } }` is auto-migrated on load.\n *\n * @public\n */\nexport class LocalStorageTreeAccessors<TCT extends string = string>\n extends FileTree.InMemoryTreeAccessors<TCT>\n implements FileTree.IPersistentFileTreeAccessors<TCT>\n{\n private readonly _storage: Storage;\n private readonly _pathToKeyMap: Map<string, string>;\n private readonly _keyToPathMap: Map<string, string>;\n private readonly _dirtyFiles: Set<string>;\n private readonly _autoSync: boolean;\n\n /**\n * Private constructor. Use fromStorage() factory method instead.\n * @internal\n */\n private constructor(\n files: FileTree.IInMemoryFile<TCT>[],\n storage: Storage,\n pathToKeyMap: Map<string, string>,\n params?: ILocalStorageTreeParams<TCT>\n ) {\n super(files, params);\n this._storage = storage;\n this._pathToKeyMap = pathToKeyMap;\n this._keyToPathMap = new Map(Array.from(pathToKeyMap.entries()).map(([k, v]) => [v, k]));\n this._dirtyFiles = new Set();\n /* c8 ignore next 1 - intermittent branch coverage: ?? false branch when params is undefined */\n this._autoSync = params?.autoSync ?? false;\n }\n\n /**\n * Create LocalStorageTreeAccessors from browser localStorage.\n * Loads all collections from the configured storage keys.\n *\n * @param params - Configuration including path-to-key mappings\n * @returns Result containing the accessors or an error\n * @public\n */\n public static fromStorage<TCT extends string = string>(\n params: ILocalStorageTreeParams<TCT>\n ): Result<LocalStorageTreeAccessors<TCT>> {\n try {\n /* c8 ignore next 1 - intermittent branch coverage: window.localStorage branch when params.storage is undefined */\n const storage = params.storage ?? (typeof window !== 'undefined' ? window.localStorage : undefined);\n if (!storage) {\n return fail('localStorage is not available');\n }\n\n const pathToKeyMap = new Map(Object.entries(params.pathToKeyMap));\n const files = this._loadFromStorage<TCT>(storage, pathToKeyMap, params);\n\n return succeed(new LocalStorageTreeAccessors<TCT>(files, storage, pathToKeyMap, params));\n /* c8 ignore next 4 - defensive: outer catch for unexpected errors */\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return fail(`Failed to create LocalStorageTreeAccessors: ${message}`);\n }\n }\n\n /**\n * Load all files from localStorage based on path-to-key mappings.\n * @internal\n */\n private static _loadFromStorage<TCT extends string = string>(\n storage: Storage,\n pathToKeyMap: Map<string, string>,\n params?: ILocalStorageTreeParams<TCT>\n ): FileTree.IInMemoryFile<TCT>[] {\n const files: FileTree.IInMemoryFile<TCT>[] = [];\n\n for (const [dataPath, storageKey] of pathToKeyMap.entries()) {\n const rawJson = storage.getItem(storageKey);\n if (!rawJson) {\n continue;\n }\n\n try {\n const parsed: unknown = JSON.parse(rawJson);\n if (!isJsonObject(parsed)) {\n continue;\n }\n\n for (const [collectionId, contents] of Object.entries(parsed)) {\n // Support both new format (string values) and legacy format (JsonObject values)\n let rawContent: string;\n let extension: string;\n if (typeof contents === 'string') {\n rawContent = contents;\n // Infer extension: if content looks like JSON, use .json; otherwise .yaml\n extension = this._looksLikeJson(contents) ? '.json' : '.yaml';\n } else if (isJsonObject(contents)) {\n // Legacy format: migrate by stringifying\n rawContent = JSON.stringify(contents);\n extension = '.json';\n } else {\n continue;\n }\n\n const filePath = this._joinPath(dataPath, `${collectionId}${extension}`);\n /* c8 ignore next 3 - intermittent branch coverage: ternary branches in tight loop */\n const contentType = params?.inferContentType\n ? params.inferContentType(filePath, undefined).orDefault()\n : undefined;\n\n files.push({\n path: filePath,\n contents: rawContent,\n contentType\n });\n }\n } catch {\n // Skip corrupted data\n continue;\n }\n }\n\n return files;\n }\n\n /**\n * Heuristic check: does the content look like JSON?\n * @internal\n */\n private static _looksLikeJson(content: string): boolean {\n const trimmed = content.trimStart();\n return trimmed.startsWith('{') || trimmed.startsWith('[');\n }\n\n /**\n * Join path components, handling leading/trailing slashes.\n * @internal\n */\n private static _joinPath(base: string, name: string): string {\n /* c8 ignore next 2 - intermittent branch coverage: slash-trimming edge cases */\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanName = name.startsWith('/') ? name.slice(1) : name;\n return `${cleanBase}/${cleanName}`;\n }\n\n /**\n * Get the storage key for a given file path.\n * @internal\n */\n private _getStorageKeyForPath(path: string): string | undefined {\n // Find the longest matching prefix\n let bestMatch: { prefix: string; key: string } | undefined;\n for (const [prefix, key] of this._pathToKeyMap.entries()) {\n if (path.startsWith(prefix)) {\n /* c8 ignore next 1 - intermittent: overlapping-prefix branch requires two matching prefixes in iteration order */\n if (!bestMatch || prefix.length > bestMatch.prefix.length) {\n bestMatch = { prefix, key };\n }\n }\n }\n return bestMatch?.key;\n }\n\n /**\n * Get the data path prefix for a given file path.\n * @internal\n */\n private _getDataPathForPath(path: string): string | undefined {\n for (const prefix of this._pathToKeyMap.keys()) {\n if (path.startsWith(prefix)) {\n return prefix;\n }\n }\n /* c8 ignore next 2 - coverage intermittently missed in full suite */\n return undefined;\n }\n\n /**\n * Extract collection ID from a file path.\n * Example: '/data/ingredients/my-collection.yaml' → 'my-collection'\n * @internal\n */\n private _getCollectionIdFromPath(path: string): string {\n const dataPath = this._getDataPathForPath(path);\n /* c8 ignore next 3 - coverage intermittently missed in full suite */\n if (!dataPath) {\n return path;\n }\n\n const relativePath = path.slice(dataPath.length);\n /* c8 ignore next 1 - defensive: relativePath always starts with / when paths are absolute */\n const cleanPath = relativePath.startsWith('/') ? relativePath.slice(1) : relativePath;\n\n // Remove any file extension\n const dotIndex = cleanPath.lastIndexOf('.');\n return dotIndex > 0 ? cleanPath.slice(0, dotIndex) : cleanPath;\n }\n\n /**\n * Remove a file's entry from its localStorage key.\n * @internal\n */\n private _deleteFileFromStorage(path: string): void {\n const storageKey = this._getStorageKeyForPath(path);\n if (!storageKey) {\n return;\n }\n\n const collectionId = this._getCollectionIdFromPath(path);\n const existingJson = this._storage.getItem(storageKey);\n if (!existingJson) {\n return;\n }\n\n try {\n const parsed = JSON.parse(existingJson);\n if (isJsonObject(parsed)) {\n const existing = parsed as Record<string, unknown>;\n delete existing[collectionId];\n if (Object.keys(existing).length > 0) {\n this._storage.setItem(storageKey, JSON.stringify(existing));\n } else {\n this._storage.removeItem(storageKey);\n }\n }\n } catch {\n // Storage is corrupted — nothing to clean up\n }\n }\n\n /**\n * Sync a single dirty file to localStorage.\n * @internal\n */\n private _syncFile(path: string): Result<void> {\n const storageKey = this._getStorageKeyForPath(path);\n if (!storageKey) {\n return fail(`No storage key configured for path: ${path}`);\n }\n\n const collectionId = this._getCollectionIdFromPath(path);\n const contentsResult = this.getFileContents(path);\n if (contentsResult.isFailure()) {\n return fail(`Failed to get file contents for ${path}: ${contentsResult.message}`);\n }\n\n try {\n const contents = contentsResult.value;\n\n // Load existing data from storage\n const existingJson = this._storage.getItem(storageKey);\n let existing: Record<string, unknown> = {};\n if (existingJson) {\n try {\n const parsed = JSON.parse(existingJson);\n if (isJsonObject(parsed)) {\n existing = parsed as Record<string, unknown>;\n }\n } catch {\n // Start fresh if corrupted\n }\n }\n\n // Store raw content string (content-agnostic: JSON, YAML, etc.)\n existing[collectionId] = contents;\n this._storage.setItem(storageKey, JSON.stringify(existing));\n\n return succeed(undefined);\n /* c8 ignore next 4 - defensive: only triggers on storage quota or similar runtime errors */\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return fail(`Failed to sync file ${path}: ${message}`);\n }\n }\n\n /**\n * Sync all dirty files to localStorage.\n * @returns Result indicating success or failure\n * @public\n */\n public async syncToDisk(): Promise<Result<void>> {\n if (this._dirtyFiles.size === 0) {\n return succeed(undefined);\n }\n\n const errors: string[] = [];\n for (const path of this._dirtyFiles) {\n const result = this._syncFile(path);\n if (result.isFailure()) {\n errors.push(result.message);\n }\n }\n\n if (errors.length > 0) {\n return fail(`Failed to sync ${errors.length} file(s): ${errors.join('; ')}`);\n }\n\n this._dirtyFiles.clear();\n return succeed(undefined);\n }\n\n /**\n * Check if there are unsaved changes.\n * @returns True if there are dirty files\n * @public\n */\n public isDirty(): boolean {\n return this._dirtyFiles.size > 0;\n }\n\n /**\n * Get list of file paths with unsaved changes.\n * @returns Array of dirty file paths\n * @public\n */\n public getDirtyPaths(): string[] {\n return Array.from(this._dirtyFiles);\n }\n\n /**\n * Delete a file and remove it from localStorage.\n * @param path - File path to delete\n * @returns Result with true if deleted, or error\n * @public\n */\n public deleteFile(path: string): Result<boolean> {\n const result = super.deleteFile(path);\n if (result.isSuccess()) {\n this._dirtyFiles.delete(path);\n this._deleteFileFromStorage(path);\n }\n return result;\n }\n\n /**\n * Save file contents. Marks file as dirty and optionally auto-syncs.\n * @param path - File path\n * @param contents - New file contents\n * @returns Result with the saved contents or error\n * @public\n */\n public saveFileContents(path: string, contents: string): Result<string> {\n const result = super.saveFileContents(path, contents);\n if (result.isSuccess()) {\n this._dirtyFiles.add(path);\n if (this._autoSync) {\n const syncResult = this._syncFile(path);\n if (syncResult.isSuccess()) {\n this._dirtyFiles.delete(path);\n } else {\n return fail(syncResult.message);\n }\n }\n }\n return result;\n }\n\n /**\n * Check if a file is mutable and return persistence detail.\n * @param path - File path to check\n * @returns DetailedResult with mutability status and 'persistent' detail if mutable\n * @public\n */\n public fileIsMutable(path: string): DetailedResult<boolean, FileTree.SaveDetail> {\n const baseResult = super.fileIsMutable(path);\n if (baseResult.isSuccess() && baseResult.value === true) {\n return succeedWithDetail(true, 'persistent');\n }\n return baseResult;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localStorageTreeAccessors.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/localStorageTreeAccessors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAkB,IAAI,EAAU,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA4BjD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,yBACX,SAAQ,QAAQ,CAAC,qBAA0B;IAS3C;;;OAGG;IACH,YACE,KAAoC,EACpC,OAAgB,EAChB,YAA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erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DetailedResult, fail, Result, succeed, succeedWithDetail } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport { isJsonObject } from '@fgv/ts-json-base';\n\n/**\n * Configuration for LocalStorageTreeAccessors.\n * @public\n */\nexport interface ILocalStorageTreeParams<TCT extends string = string>\n extends FileTree.IFileTreeInitParams<TCT> {\n /**\n * Map of directory path prefixes to localStorage keys.\n * Files under each prefix are stored in the corresponding localStorage key.\n * Example: \\{ '/data/ingredients': 'myapp:ingredients:v1' \\}\n */\n pathToKeyMap: Record<string, string>;\n\n /**\n * Storage instance to use. Defaults to window.localStorage.\n * Can be overridden for testing with mock storage.\n */\n storage?: Storage;\n\n /**\n * If true, automatically sync changes to localStorage on every modification.\n * If false (default), changes are only synced when syncToDisk() is called.\n */\n autoSync?: boolean;\n}\n\n/**\n * Browser localStorage-backed file tree accessors with persistence support.\n *\n * Maps filesystem-like directory paths to localStorage keys, where each key stores\n * multiple collections as a JSON object. This provides a general-purpose implementation\n * for browser-based file tree persistence without requiring File System Access API.\n *\n * Storage format per key: `{ \"collection-id\": \"<raw file content>\" }`\n * File paths map as: `/data/ingredients/collection-id.yaml` → stored in key for `/data/ingredients`\n *\n * Legacy format (v1): `{ \"collection-id\": { ...parsedJsonObject } }` is auto-migrated on load.\n *\n * @public\n */\nexport class LocalStorageTreeAccessors<TCT extends string = string>\n extends FileTree.InMemoryTreeAccessors<TCT>\n implements FileTree.IPersistentFileTreeAccessors<TCT>\n{\n private readonly _storage: Storage;\n private readonly _pathToKeyMap: Map<string, string>;\n private readonly _keyToPathMap: Map<string, string>;\n private readonly _dirtyFiles: Set<string>;\n private readonly _autoSync: boolean;\n\n /**\n * Private constructor. Use fromStorage() factory method instead.\n * @internal\n */\n private constructor(\n files: FileTree.IInMemoryFile<TCT>[],\n storage: Storage,\n pathToKeyMap: Map<string, string>,\n params?: ILocalStorageTreeParams<TCT>\n ) {\n super(files, params);\n this._storage = storage;\n this._pathToKeyMap = pathToKeyMap;\n this._keyToPathMap = new Map(Array.from(pathToKeyMap.entries()).map(([k, v]) => [v, k]));\n this._dirtyFiles = new Set();\n /* c8 ignore next 1 - intermittent branch coverage: ?? false branch when params is undefined */\n this._autoSync = params?.autoSync ?? false;\n }\n\n /**\n * Create LocalStorageTreeAccessors from browser localStorage.\n * Loads all collections from the configured storage keys.\n *\n * @param params - Configuration including path-to-key mappings\n * @returns Result containing the accessors or an error\n * @public\n */\n public static fromStorage<TCT extends string = string>(\n params: ILocalStorageTreeParams<TCT>\n ): Result<LocalStorageTreeAccessors<TCT>> {\n try {\n /* c8 ignore next 1 - intermittent branch coverage: window.localStorage branch when params.storage is undefined */\n const storage = params.storage ?? (typeof window !== 'undefined' ? window.localStorage : undefined);\n if (!storage) {\n return fail('localStorage is not available');\n }\n\n const pathToKeyMap = new Map(Object.entries(params.pathToKeyMap));\n const files = this._loadFromStorage<TCT>(storage, pathToKeyMap, params);\n\n return succeed(new LocalStorageTreeAccessors<TCT>(files, storage, pathToKeyMap, params));\n /* c8 ignore next 4 - defensive: outer catch for unexpected errors */\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return fail(`Failed to create LocalStorageTreeAccessors: ${message}`);\n }\n }\n\n /**\n * Load all files from localStorage based on path-to-key mappings.\n * @internal\n */\n private static _loadFromStorage<TCT extends string = string>(\n storage: Storage,\n pathToKeyMap: Map<string, string>,\n params?: ILocalStorageTreeParams<TCT>\n ): FileTree.IInMemoryFile<TCT>[] {\n const files: FileTree.IInMemoryFile<TCT>[] = [];\n\n for (const [dataPath, storageKey] of pathToKeyMap.entries()) {\n const rawJson = storage.getItem(storageKey);\n if (!rawJson) {\n continue;\n }\n\n try {\n const parsed: unknown = JSON.parse(rawJson);\n if (!isJsonObject(parsed)) {\n continue;\n }\n\n for (const [collectionId, contents] of Object.entries(parsed)) {\n // Support both new format (string values) and legacy format (JsonObject values)\n let rawContent: string;\n let extension: string;\n if (typeof contents === 'string') {\n rawContent = contents;\n // Infer extension: if content looks like JSON, use .json; otherwise .yaml\n extension = this._looksLikeJson(contents) ? '.json' : '.yaml';\n } else if (isJsonObject(contents)) {\n // Legacy format: migrate by stringifying\n rawContent = JSON.stringify(contents);\n extension = '.json';\n } else {\n continue;\n }\n\n const filePath = this._joinPath(dataPath, `${collectionId}${extension}`);\n /* c8 ignore next 3 - intermittent branch coverage: ternary branches in tight loop */\n const contentType = params?.inferContentType\n ? params.inferContentType(filePath, undefined).orDefault()\n : undefined;\n\n files.push({\n path: filePath,\n contents: rawContent,\n contentType\n });\n }\n } catch {\n // Skip corrupted data\n continue;\n }\n }\n\n return files;\n }\n\n /**\n * Heuristic check: does the content look like JSON?\n * @internal\n */\n private static _looksLikeJson(content: string): boolean {\n const trimmed = content.trimStart();\n return trimmed.startsWith('{') || trimmed.startsWith('[');\n }\n\n /**\n * Join path components, handling leading/trailing slashes.\n * @internal\n */\n private static _joinPath(base: string, name: string): string {\n /* c8 ignore next 2 - intermittent branch coverage: slash-trimming edge cases */\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanName = name.startsWith('/') ? name.slice(1) : name;\n return `${cleanBase}/${cleanName}`;\n }\n\n /**\n * Get the storage key for a given file path.\n * @internal\n */\n private _getStorageKeyForPath(path: string): string | undefined {\n // Find the longest matching prefix\n let bestMatch: { prefix: string; key: string } | undefined;\n for (const [prefix, key] of this._pathToKeyMap.entries()) {\n if (path.startsWith(prefix)) {\n /* c8 ignore next 1 - intermittent: overlapping-prefix branch requires two matching prefixes in iteration order */\n if (!bestMatch || prefix.length > bestMatch.prefix.length) {\n bestMatch = { prefix, key };\n }\n }\n }\n return bestMatch?.key;\n }\n\n /**\n * Get the data path prefix for a given file path.\n * @internal\n */\n private _getDataPathForPath(path: string): string | undefined {\n for (const prefix of this._pathToKeyMap.keys()) {\n if (path.startsWith(prefix)) {\n return prefix;\n }\n }\n /* c8 ignore next 2 - coverage intermittently missed in full suite */\n return undefined;\n }\n\n /**\n * Extract collection ID from a file path.\n * Example: '/data/ingredients/my-collection.yaml' → 'my-collection'\n * @internal\n */\n private _getCollectionIdFromPath(path: string): string {\n const dataPath = this._getDataPathForPath(path);\n /* c8 ignore next 3 - coverage intermittently missed in full suite */\n if (!dataPath) {\n return path;\n }\n\n const relativePath = path.slice(dataPath.length);\n /* c8 ignore next 1 - defensive: relativePath always starts with / when paths are absolute */\n const cleanPath = relativePath.startsWith('/') ? relativePath.slice(1) : relativePath;\n\n // Remove any file extension\n const dotIndex = cleanPath.lastIndexOf('.');\n return dotIndex > 0 ? cleanPath.slice(0, dotIndex) : cleanPath;\n }\n\n /**\n * Remove a file's entry from its localStorage key.\n * @internal\n */\n private _deleteFileFromStorage(path: string): void {\n const storageKey = this._getStorageKeyForPath(path);\n if (!storageKey) {\n return;\n }\n\n const collectionId = this._getCollectionIdFromPath(path);\n const existingJson = this._storage.getItem(storageKey);\n if (!existingJson) {\n return;\n }\n\n try {\n const parsed = JSON.parse(existingJson);\n if (isJsonObject(parsed)) {\n const existing = parsed as Record<string, unknown>;\n delete existing[collectionId];\n if (Object.keys(existing).length > 0) {\n this._storage.setItem(storageKey, JSON.stringify(existing));\n } else {\n this._storage.removeItem(storageKey);\n }\n }\n } catch {\n // Storage is corrupted — nothing to clean up\n }\n }\n\n /**\n * Sync a single dirty file to localStorage.\n * @internal\n */\n private _syncFile(path: string): Result<void> {\n const storageKey = this._getStorageKeyForPath(path);\n if (!storageKey) {\n return fail(`No storage key configured for path: ${path}`);\n }\n\n const collectionId = this._getCollectionIdFromPath(path);\n const contentsResult = this.getFileContents(path);\n if (contentsResult.isFailure()) {\n return fail(`Failed to get file contents for ${path}: ${contentsResult.message}`);\n }\n\n try {\n const contents = contentsResult.value;\n\n // Load existing data from storage\n const existingJson = this._storage.getItem(storageKey);\n let existing: Record<string, unknown> = {};\n if (existingJson) {\n try {\n const parsed = JSON.parse(existingJson);\n if (isJsonObject(parsed)) {\n existing = parsed as Record<string, unknown>;\n }\n } catch {\n // Start fresh if corrupted\n }\n }\n\n // Store raw content string (content-agnostic: JSON, YAML, etc.)\n existing[collectionId] = contents;\n this._storage.setItem(storageKey, JSON.stringify(existing));\n\n return succeed(undefined);\n /* c8 ignore next 4 - defensive: only triggers on storage quota or similar runtime errors */\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return fail(`Failed to sync file ${path}: ${message}`);\n }\n }\n\n /**\n * Sync all dirty files to localStorage.\n * @returns Result indicating success or failure\n * @public\n */\n public async syncToDisk(): Promise<Result<void>> {\n if (this._dirtyFiles.size === 0) {\n return succeed(undefined);\n }\n\n const errors: string[] = [];\n for (const path of this._dirtyFiles) {\n const result = this._syncFile(path);\n if (result.isFailure()) {\n errors.push(result.message);\n }\n }\n\n if (errors.length > 0) {\n return fail(`Failed to sync ${errors.length} file(s): ${errors.join('; ')}`);\n }\n\n this._dirtyFiles.clear();\n return succeed(undefined);\n }\n\n /**\n * Check if there are unsaved changes.\n * @returns True if there are dirty files\n * @public\n */\n public isDirty(): boolean {\n return this._dirtyFiles.size > 0;\n }\n\n /**\n * Get list of file paths with unsaved changes.\n * @returns Array of dirty file paths\n * @public\n */\n public getDirtyPaths(): string[] {\n return Array.from(this._dirtyFiles);\n }\n\n /**\n * Delete a file and remove it from localStorage.\n * @param path - File path to delete\n * @returns Result with true if deleted, or error\n * @public\n */\n public deleteFile(path: string): Result<boolean> {\n const result = super.deleteFile(path);\n if (result.isSuccess()) {\n this._dirtyFiles.delete(path);\n this._deleteFileFromStorage(path);\n }\n return result;\n }\n\n /**\n * Save file contents. Marks file as dirty and optionally auto-syncs.\n * @param path - File path\n * @param contents - New file contents\n * @returns Result with the saved contents or error\n * @public\n */\n public saveFileContents(path: string, contents: string): Result<string> {\n const result = super.saveFileContents(path, contents);\n if (result.isSuccess()) {\n this._dirtyFiles.add(path);\n if (this._autoSync) {\n const syncResult = this._syncFile(path);\n if (syncResult.isSuccess()) {\n this._dirtyFiles.delete(path);\n } else {\n return fail(syncResult.message);\n }\n }\n }\n return result;\n }\n\n /**\n * Check if a file is mutable and return persistence detail.\n * @param path - File path to check\n * @returns DetailedResult with mutability status and 'persistent' detail if mutable\n * @public\n */\n public fileIsMutable(path: string): DetailedResult<boolean, FileTree.SaveDetail> {\n const baseResult = super.fileIsMutable(path);\n if (baseResult.isSuccess() && baseResult.value === true) {\n return succeedWithDetail(true, 'persistent');\n }\n return baseResult;\n }\n}\n"]}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* SOFTWARE.
|
|
21
21
|
*/
|
|
22
22
|
import { FileTree } from '@fgv/ts-json-base';
|
|
23
|
-
import { FileApiTreeAccessors } from '../file-tree
|
|
23
|
+
import { FileApiTreeAccessors } from '../file-tree';
|
|
24
24
|
/**
|
|
25
25
|
* Default initialization parameters for a `FileTree` using {@link FileApiTreeAccessors}.
|
|
26
26
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileTreeHelpers.js","sourceRoot":"","sources":["../../../src/packlets/helpers/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AAuB,CAAC,QAAkB;IACxD,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAU;IAC5C,OAAO,oBAAoB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport { FileApiTreeAccessors, IFileMetadata } from '../file-tree';\n\n/**\n * Default initialization parameters for a `FileTree` using {@link FileApiTreeAccessors}.\n * @public\n */\nexport const defaultFileApiTreeInitParams: FileTree.IFileTreeInitParams<string> = {\n inferContentType: FileTree.FileItem.defaultAcceptContentType\n};\n\n/**\n * Helper function to create a new FileTree instance\n * from a browser FileList (e.g., from input[type=\"file\"]).\n * @param fileList - FileList from a file input element\n * @param params - Optional `IFileTreeInitParams` for the file tree.\n * @returns Promise resolving to a successful Result with the new FileTree instance\n * if successful, or a failed Result with an error message otherwise\n * @remarks The content type of the files is always `string` and the default\n * accept contentType function (`FileTree.FileItem.defaultAcceptContentType`) is\n * used, so content type is derived from the mime type of the file, when\n * available.\n * @public\n */\nexport function fromFileList(\n fileList: FileList,\n params?: FileTree.IFileTreeInitParams<string>\n): Promise<Result<FileTree.FileTree<string>>> {\n params = { ...defaultFileApiTreeInitParams, ...(params ?? {}) };\n return FileApiTreeAccessors.fromFileList(fileList, params);\n}\n\n/**\n * Helper function to create a new FileTree instance\n * from a directory upload with webkitRelativePath support.\n * @param fileList - FileList from a directory upload (input with webkitdirectory)\n * @param params - Optional `IFileTreeInitParams` for the file tree.\n * @returns Promise resolving to a successful Result with the new FileTree instance\n * if successful, or a failed Result with an error message otherwise\n * @remarks The content type of the files is always `string` and the default\n * accept contentType function (`FileTree.FileItem.defaultAcceptContentType`) is\n * is used, so content type is derived from the mime type of the file, when\n * available.\n * @public\n */\nexport function fromDirectoryUpload(\n fileList: FileList,\n params?: FileTree.IFileTreeInitParams<string>\n): Promise<Result<FileTree.FileTree<string>>> {\n params = { ...defaultFileApiTreeInitParams, ...(params ?? {}) };\n return FileApiTreeAccessors.fromDirectoryUpload(fileList, params);\n}\n\n/**\n * Helper function to get the original File object from a FileList by path.\n * @param fileList - The original FileList\n * @param path - The path to the file\n * @returns A successful Result with the File object if found,\n * or a failed Result with an error message otherwise\n * @public\n */\nexport function getOriginalFile(fileList: FileList, path: string): Result<File> {\n return FileApiTreeAccessors.getOriginalFile(fileList, path);\n}\n\n/**\n * Helper function to extract metadata from a `FileList`.\n * @param fileList - The `FileList` to extract metadata from\n * @returns Array of {@link IFileMetadata | file metadata} objects\n * @public\n */\nexport function extractFileListMetadata(fileList: FileList): Array<IFileMetadata> {\n return Array.from(fileList).map((f) => FileApiTreeAccessors.extractFileMetadata(f));\n}\n\n/**\n * Helper function to extract metadata from a `File`.\n * @param file - The File to extract metadata from\n * @returns {@link IFileMetadata | file metadata} object\n * @public\n */\nexport function extractFileMetadata(file: File): IFileMetadata {\n return FileApiTreeAccessors.extractFileMetadata(file);\n}\n"]}
|
package/dist/ts-web-extras.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { DetailedResult } from '@fgv/ts-utils';
|
|
|
14
14
|
import { FileTree } from '@fgv/ts-json-base';
|
|
15
15
|
import { Logging } from '@fgv/ts-utils';
|
|
16
16
|
import { Result } from '@fgv/ts-utils';
|
|
17
|
+
import { Uuid } from '@fgv/ts-utils';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Browser implementation of `ICryptoProvider` using the Web Crypto API.
|
|
@@ -24,7 +25,7 @@ import { Result } from '@fgv/ts-utils';
|
|
|
24
25
|
*
|
|
25
26
|
* @public
|
|
26
27
|
*/
|
|
27
|
-
declare class BrowserCryptoProvider implements ICryptoProvider {
|
|
28
|
+
declare class BrowserCryptoProvider implements CryptoUtils_2.ICryptoProvider {
|
|
28
29
|
private readonly _crypto;
|
|
29
30
|
/**
|
|
30
31
|
* Creates a new {@link CryptoUtils.BrowserCryptoProvider | BrowserCryptoProvider}.
|
|
@@ -37,7 +38,7 @@ declare class BrowserCryptoProvider implements ICryptoProvider {
|
|
|
37
38
|
* @param key - 32-byte encryption key
|
|
38
39
|
* @returns `Success` with encryption result, or `Failure` with an error.
|
|
39
40
|
*/
|
|
40
|
-
encrypt(plaintext: string, key: Uint8Array): Promise<Result<IEncryptionResult>>;
|
|
41
|
+
encrypt(plaintext: string, key: Uint8Array): Promise<Result<CryptoUtils_2.IEncryptionResult>>;
|
|
41
42
|
/**
|
|
42
43
|
* Decrypts ciphertext using AES-256-GCM.
|
|
43
44
|
* @param encryptedData - Encrypted bytes
|
|
@@ -60,12 +61,25 @@ declare class BrowserCryptoProvider implements ICryptoProvider {
|
|
|
60
61
|
* @returns Success with derived 32-byte key, or Failure with error
|
|
61
62
|
*/
|
|
62
63
|
deriveKey(password: string, salt: Uint8Array, iterations: number): Promise<Result<Uint8Array>>;
|
|
64
|
+
/**
|
|
65
|
+
* Computes a SHA-256 hash of the given data.
|
|
66
|
+
* @param data - UTF-8 string to hash
|
|
67
|
+
* @returns `Success` with hex-encoded hash string, or `Failure` with an error.
|
|
68
|
+
*/
|
|
69
|
+
sha256(data: string): Promise<Result<string>>;
|
|
63
70
|
/**
|
|
64
71
|
* Generates cryptographically secure random bytes.
|
|
65
72
|
* @param length - Number of bytes to generate
|
|
66
73
|
* @returns Success with random bytes, or Failure with error
|
|
67
74
|
*/
|
|
68
75
|
generateRandomBytes(length: number): Result<Uint8Array>;
|
|
76
|
+
/**
|
|
77
|
+
* Generates a cryptographically random UUIDv4 using the injected
|
|
78
|
+
* `Crypto` instance.
|
|
79
|
+
* @returns `Success` with the generated UUID, or `Failure` if the underlying
|
|
80
|
+
* `Crypto` instance does not expose `randomUUID`.
|
|
81
|
+
*/
|
|
82
|
+
generateUuid(): Result<Uuid>;
|
|
69
83
|
/**
|
|
70
84
|
* Encodes binary data to base64 string.
|
|
71
85
|
* @param data - Binary data to encode
|
|
@@ -78,6 +92,135 @@ declare class BrowserCryptoProvider implements ICryptoProvider {
|
|
|
78
92
|
* @returns Success with decoded bytes, or Failure if invalid base64
|
|
79
93
|
*/
|
|
80
94
|
fromBase64(base64: string): Result<Uint8Array>;
|
|
95
|
+
/**
|
|
96
|
+
* Generates a new asymmetric keypair via Web Crypto.
|
|
97
|
+
* @param algorithm - The algorithm to use.
|
|
98
|
+
* @param extractable - Whether the resulting keys may be exported.
|
|
99
|
+
* @returns `Success` with the generated `CryptoKeyPair`, or `Failure` with an error.
|
|
100
|
+
*/
|
|
101
|
+
generateKeyPair(algorithm: CryptoUtils_2.KeyPairAlgorithm, extractable: boolean): Promise<Result<CryptoKeyPair>>;
|
|
102
|
+
/**
|
|
103
|
+
* Exports a public `CryptoKey` as a JSON Web Key.
|
|
104
|
+
* @remarks
|
|
105
|
+
* Rejects non-public keys at runtime. WebCrypto's `exportKey('jwk', ...)`
|
|
106
|
+
* does not enforce public-vs-private; without this guard a caller that
|
|
107
|
+
* passed an extractable private key would receive its private fields
|
|
108
|
+
* (`d`, `p`, `q`, ...) as JWK, defeating the method's name.
|
|
109
|
+
* @param publicKey - Extractable public key to export.
|
|
110
|
+
* @returns `Success` with the JWK, or `Failure` if not a public key or if export fails.
|
|
111
|
+
*/
|
|
112
|
+
exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>>;
|
|
113
|
+
/**
|
|
114
|
+
* Imports a public-key JWK as a `CryptoKey` for the requested algorithm.
|
|
115
|
+
* @param jwk - The JSON Web Key produced by a prior export.
|
|
116
|
+
* @param algorithm - The algorithm the key was generated for.
|
|
117
|
+
* @returns `Success` with the imported public `CryptoKey`, or `Failure` with an error.
|
|
118
|
+
*/
|
|
119
|
+
importPublicKeyJwk(jwk: JsonWebKey, algorithm: CryptoUtils_2.KeyPairAlgorithm): Promise<Result<CryptoKey>>;
|
|
120
|
+
/**
|
|
121
|
+
* Exports a public `CryptoKey` as a DER-encoded SPKI blob.
|
|
122
|
+
* @param publicKey - The public `CryptoKey` to export.
|
|
123
|
+
* @returns `Success` with the raw SPKI bytes, or `Failure` with error context.
|
|
124
|
+
*/
|
|
125
|
+
exportPublicKeySpki(publicKey: CryptoKey): Promise<Result<Uint8Array>>;
|
|
126
|
+
/**
|
|
127
|
+
* Imports a public key from a DER-encoded SPKI blob.
|
|
128
|
+
* @param spkiBytes - The raw SPKI bytes.
|
|
129
|
+
* @param algorithm - The algorithm the key was generated for.
|
|
130
|
+
* @returns `Success` with the imported public `CryptoKey`, or `Failure` with error context.
|
|
131
|
+
*/
|
|
132
|
+
importPublicKeySpki(spkiBytes: Uint8Array, algorithm: CryptoUtils_2.KeyPairAlgorithm): Promise<Result<CryptoKey>>;
|
|
133
|
+
/**
|
|
134
|
+
* Signs `data` with `privateKey` using the algorithm inferred from the key.
|
|
135
|
+
* @param privateKey - A signing `CryptoKey` (`'ecdsa-p256'` or `'ed25519'`).
|
|
136
|
+
* @param data - The bytes to sign.
|
|
137
|
+
* @returns `Success` with the raw signature bytes, or `Failure` with error context.
|
|
138
|
+
*/
|
|
139
|
+
sign(privateKey: CryptoKey, data: Uint8Array): Promise<Result<Uint8Array>>;
|
|
140
|
+
/**
|
|
141
|
+
* Verifies a signature produced by {@link BrowserCryptoProvider.sign}.
|
|
142
|
+
* @param publicKey - A verify `CryptoKey` (`'ecdsa-p256'` or `'ed25519'`).
|
|
143
|
+
* @param signature - The raw signature bytes.
|
|
144
|
+
* @param data - The original data that was signed.
|
|
145
|
+
* @returns `Success` with `true` if valid, `false` if not, or `Failure` with error context.
|
|
146
|
+
*/
|
|
147
|
+
verify(publicKey: CryptoKey, signature: Uint8Array, data: Uint8Array): Promise<Result<boolean>>;
|
|
148
|
+
/**
|
|
149
|
+
* Compares two byte arrays in constant time.
|
|
150
|
+
*
|
|
151
|
+
* Accumulates XOR differences with bitwise-OR; no early-return is possible
|
|
152
|
+
* once the length check passes, making timing independent of the byte
|
|
153
|
+
* values. Returns `false` immediately on length mismatch (length is not
|
|
154
|
+
* secret in normal use).
|
|
155
|
+
* @param a - First byte array.
|
|
156
|
+
* @param b - Second byte array.
|
|
157
|
+
* @returns `true` if lengths match and all bytes are equal, `false` otherwise.
|
|
158
|
+
*/
|
|
159
|
+
timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Computes an HMAC-SHA256 MAC for `data` using `key`.
|
|
162
|
+
* @param key - An HMAC `CryptoKey` with `'sign'` usage.
|
|
163
|
+
* @param data - The bytes to authenticate.
|
|
164
|
+
* @returns `Success` with the 32-byte MAC, or `Failure` with error context.
|
|
165
|
+
*/
|
|
166
|
+
hmacSha256(key: CryptoKey, data: Uint8Array): Promise<Result<Uint8Array>>;
|
|
167
|
+
/**
|
|
168
|
+
* Verifies an HMAC-SHA256 MAC in constant time.
|
|
169
|
+
* @param key - An HMAC `CryptoKey` with `'sign'` usage.
|
|
170
|
+
* @param signature - The MAC bytes to verify.
|
|
171
|
+
* @param data - The original data that was authenticated.
|
|
172
|
+
* @returns `Success` with `true` if valid, `false` if not, or `Failure` with error context.
|
|
173
|
+
*/
|
|
174
|
+
verifyHmacSha256(key: CryptoKey, signature: Uint8Array, data: Uint8Array): Promise<Result<boolean>>;
|
|
175
|
+
/**
|
|
176
|
+
* Encrypts raw bytes using AES-256-GCM with a caller-supplied nonce and
|
|
177
|
+
* optional AAD. See {@link CryptoUtils.ICryptoProvider.encryptBytes | ICryptoProvider.encryptBytes}
|
|
178
|
+
* — in particular the caller's responsibility to use a unique `nonce` per
|
|
179
|
+
* message under a given `key`.
|
|
180
|
+
*
|
|
181
|
+
* Byte-identical to {@link CryptoUtils.NodeCryptoProvider.encryptBytes} for
|
|
182
|
+
* identical `(key, nonce, plaintext, aad)`: Web Crypto appends the 16-byte tag
|
|
183
|
+
* to the ciphertext, and this method splits it off so the returned
|
|
184
|
+
* `ciphertext`/`authTag` match Node's separated-tag layout exactly.
|
|
185
|
+
* @param key - 32-byte AES-256 key.
|
|
186
|
+
* @param nonce - 12-byte GCM nonce (must be unique per message under `key`).
|
|
187
|
+
* @param plaintext - The bytes to encrypt (empty permitted).
|
|
188
|
+
* @param aad - Optional additional authenticated data bound into the tag.
|
|
189
|
+
* @returns `Success` with the ciphertext and 16-byte auth tag, or `Failure` with an error.
|
|
190
|
+
*/
|
|
191
|
+
encryptBytes(key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, aad?: Uint8Array): Promise<Result<CryptoUtils_2.IEncryptBytesResult>>;
|
|
192
|
+
/**
|
|
193
|
+
* Decrypts raw bytes produced by {@link BrowserCryptoProvider.encryptBytes}
|
|
194
|
+
* using AES-256-GCM. See
|
|
195
|
+
* {@link CryptoUtils.ICryptoProvider.decryptBytes | ICryptoProvider.decryptBytes}.
|
|
196
|
+
* Fails (never throws) on any authentication failure, including a mismatched `aad`.
|
|
197
|
+
* @param key - 32-byte AES-256 key.
|
|
198
|
+
* @param nonce - 12-byte GCM nonce (the same one used to encrypt).
|
|
199
|
+
* @param ciphertext - The ciphertext from the `encryptBytes` result.
|
|
200
|
+
* @param authTag - The 16-byte GCM auth tag from the `encryptBytes` result.
|
|
201
|
+
* @param aad - The identical AAD supplied at encrypt time (or absent).
|
|
202
|
+
* @returns `Success` with the decrypted plaintext bytes, or `Failure` with an error.
|
|
203
|
+
*/
|
|
204
|
+
decryptBytes(key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, authTag: Uint8Array, aad?: Uint8Array): Promise<Result<Uint8Array>>;
|
|
205
|
+
/**
|
|
206
|
+
* Wraps `plaintext` for the holder of `recipientPublicKey` using
|
|
207
|
+
* ECIES (ECDH P-256 + HKDF-SHA256 + AES-GCM-256). See
|
|
208
|
+
* {@link CryptoUtils.ICryptoProvider.wrapBytes | ICryptoProvider.wrapBytes}.
|
|
209
|
+
* @param plaintext - The bytes to wrap.
|
|
210
|
+
* @param recipientPublicKey - The recipient's ECDH P-256 public `CryptoKey`.
|
|
211
|
+
* @param options - HKDF salt and info; see {@link CryptoUtils.IWrapBytesOptions | IWrapBytesOptions}.
|
|
212
|
+
* @returns `Success` with the wrapped payload, or `Failure` with an error.
|
|
213
|
+
*/
|
|
214
|
+
wrapBytes(plaintext: Uint8Array, recipientPublicKey: CryptoKey, options: CryptoUtils_2.IWrapBytesOptions): Promise<Result<CryptoUtils_2.IWrappedBytes>>;
|
|
215
|
+
/**
|
|
216
|
+
* Unwraps a payload produced by `wrapBytes` using the recipient's private
|
|
217
|
+
* key. See {@link CryptoUtils.ICryptoProvider.unwrapBytes | ICryptoProvider.unwrapBytes}.
|
|
218
|
+
* @param wrapped - The wrapped payload.
|
|
219
|
+
* @param recipientPrivateKey - The recipient's ECDH P-256 private `CryptoKey`.
|
|
220
|
+
* @param options - HKDF salt and info matching the wrap call.
|
|
221
|
+
* @returns `Success` with the original `plaintext`, or `Failure` with an error.
|
|
222
|
+
*/
|
|
223
|
+
unwrapBytes(wrapped: CryptoUtils_2.IWrappedBytes, recipientPrivateKey: CryptoKey, options: CryptoUtils_2.IWrapBytesOptions): Promise<Result<Uint8Array>>;
|
|
81
224
|
}
|
|
82
225
|
|
|
83
226
|
/**
|
|
@@ -113,9 +256,13 @@ declare function createBrowserCryptoProvider(): Result<BrowserCryptoProvider>;
|
|
|
113
256
|
|
|
114
257
|
declare namespace CryptoUtils {
|
|
115
258
|
export {
|
|
259
|
+
HpkeProvider,
|
|
260
|
+
IHpkeSealResult,
|
|
116
261
|
BrowserHashProvider,
|
|
117
262
|
createBrowserCryptoProvider,
|
|
118
|
-
BrowserCryptoProvider
|
|
263
|
+
BrowserCryptoProvider,
|
|
264
|
+
IIdbPrivateKeyStorageCreateParams,
|
|
265
|
+
IdbPrivateKeyStorage
|
|
119
266
|
}
|
|
120
267
|
}
|
|
121
268
|
export { CryptoUtils }
|
|
@@ -124,13 +271,13 @@ export { CryptoUtils }
|
|
|
124
271
|
* Default IndexedDB database name for directory handles.
|
|
125
272
|
* @public
|
|
126
273
|
*/
|
|
127
|
-
export declare const DEFAULT_DIRECTORY_HANDLE_DB
|
|
274
|
+
export declare const DEFAULT_DIRECTORY_HANDLE_DB: string;
|
|
128
275
|
|
|
129
276
|
/**
|
|
130
277
|
* Default IndexedDB store name for directory handles.
|
|
131
278
|
* @public
|
|
132
279
|
*/
|
|
133
|
-
export declare const DEFAULT_DIRECTORY_HANDLE_STORE
|
|
280
|
+
export declare const DEFAULT_DIRECTORY_HANDLE_STORE: string;
|
|
134
281
|
|
|
135
282
|
/**
|
|
136
283
|
* Default initialization parameters for a `FileTree` using {@link FileApiTreeAccessors}.
|
|
@@ -229,7 +376,7 @@ declare function extractFileListMetadata(fileList: FileList): Array<IFileMetadat
|
|
|
229
376
|
* Supports File API (FileList) and File System Access API handles.
|
|
230
377
|
* @public
|
|
231
378
|
*/
|
|
232
|
-
export declare class FileApiTreeAccessors
|
|
379
|
+
export declare class FileApiTreeAccessors {
|
|
233
380
|
/**
|
|
234
381
|
* Create a persistent FileTree from a File System Access API directory handle.
|
|
235
382
|
* Changes to files can be synced back to disk.
|
|
@@ -325,7 +472,7 @@ declare function extractFileListMetadata(fileList: FileList): Array<IFileMetadat
|
|
|
325
472
|
static getOriginalFile(fileList: FileList, targetPath: string): Result<File>;
|
|
326
473
|
/**
|
|
327
474
|
* Extract file metadata from a File.
|
|
328
|
-
* @param
|
|
475
|
+
* @param file - The File to extract metadata from
|
|
329
476
|
* @returns The {@link IFileMetadata | file metadata}
|
|
330
477
|
*/
|
|
331
478
|
static extractFileMetadata(file: File): IFileMetadata;
|
|
@@ -651,6 +798,14 @@ declare function extractFileListMetadata(fileList: FileList): Array<IFileMetadat
|
|
|
651
798
|
*/
|
|
652
799
|
declare function getOriginalFile(fileList: FileList, path: string): Result<File>;
|
|
653
800
|
|
|
801
|
+
/**
|
|
802
|
+
* HPKE base mode (RFC 9180) — `DHKEM(X25519, HKDF-SHA256) + HKDF-SHA256 + AES-256-GCM`.
|
|
803
|
+
* Re-exported from `@fgv/ts-extras` for browser consumers.
|
|
804
|
+
* @see {@link CryptoUtils.HpkeProvider}
|
|
805
|
+
* @public
|
|
806
|
+
*/
|
|
807
|
+
declare const HpkeProvider: typeof CryptoUtils_2.HpkeProvider;
|
|
808
|
+
|
|
654
809
|
/**
|
|
655
810
|
* HTTP-backed file tree accessors that cache data in memory and persist via REST API.
|
|
656
811
|
* @public
|
|
@@ -686,6 +841,12 @@ declare function extractFileListMetadata(fileList: FileList): Array<IFileMetadat
|
|
|
686
841
|
*/
|
|
687
842
|
syncToDisk(): Promise<Result<void>>;
|
|
688
843
|
private _doSync;
|
|
844
|
+
/**
|
|
845
|
+
* Restores snapshotted items back into the live dirty sets so they
|
|
846
|
+
* are retried on the next sync attempt. Items that were added to
|
|
847
|
+
* the live sets while the sync was in flight are preserved.
|
|
848
|
+
*/
|
|
849
|
+
private _restoreUnsynced;
|
|
689
850
|
/**
|
|
690
851
|
* Checks if there are any dirty files that need synchronization.
|
|
691
852
|
* @returns True if there are dirty files, false otherwise.
|
|
@@ -739,7 +900,70 @@ declare function extractFileListMetadata(fileList: FileList): Array<IFileMetadat
|
|
|
739
900
|
private static _requestWithParams;
|
|
740
901
|
}
|
|
741
902
|
|
|
742
|
-
|
|
903
|
+
/**
|
|
904
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage | IPrivateKeyStorage}
|
|
905
|
+
* implementation backed by IndexedDB. Stores `CryptoKey` objects directly via
|
|
906
|
+
* IndexedDB's structured-clone serialization — no JWK round-trip — so it works
|
|
907
|
+
* with non-extractable keys.
|
|
908
|
+
*
|
|
909
|
+
* `supportsNonExtractable` is `true`: because the `CryptoKey` is stored by
|
|
910
|
+
* reference (structured clone) rather than exported, the keystore may generate
|
|
911
|
+
* `extractable: false` keys for maximum security on browsers that support it.
|
|
912
|
+
*
|
|
913
|
+
* The database is opened lazily on first use and cached. Each operation runs in
|
|
914
|
+
* its own transaction, relying on IndexedDB's default serialization. Multi-tab
|
|
915
|
+
* concurrency is a known limitation: two tabs writing the same id can race; this
|
|
916
|
+
* implementation targets single-tab use.
|
|
917
|
+
*
|
|
918
|
+
* @public
|
|
919
|
+
*/
|
|
920
|
+
declare class IdbPrivateKeyStorage implements CryptoUtils_2.KeyStore.IPrivateKeyStorage {
|
|
921
|
+
/**
|
|
922
|
+
* `true` — IndexedDB stores `CryptoKey` objects directly, so non-extractable
|
|
923
|
+
* keys are supported.
|
|
924
|
+
*/
|
|
925
|
+
readonly supportsNonExtractable: true;
|
|
926
|
+
private readonly _factory;
|
|
927
|
+
private readonly _databaseName;
|
|
928
|
+
private readonly _storeName;
|
|
929
|
+
private _db;
|
|
930
|
+
private constructor();
|
|
931
|
+
/**
|
|
932
|
+
* Creates a new {@link CryptoUtils.IdbPrivateKeyStorage}.
|
|
933
|
+
* @param params - Optional {@link CryptoUtils.IIdbPrivateKeyStorageCreateParams}.
|
|
934
|
+
* @returns `Success` with the new instance, or `Failure` if no IndexedDB
|
|
935
|
+
* factory is available.
|
|
936
|
+
*/
|
|
937
|
+
static create(params?: IIdbPrivateKeyStorageCreateParams): Result<IdbPrivateKeyStorage>;
|
|
938
|
+
/**
|
|
939
|
+
* Stores `key` under `id`.
|
|
940
|
+
* @param id - Storage handle to write under.
|
|
941
|
+
* @param key - The private `CryptoKey` to persist.
|
|
942
|
+
*/
|
|
943
|
+
store(id: string, key: CryptoKey): Promise<Result<string>>;
|
|
944
|
+
/**
|
|
945
|
+
* Loads the private key stored under `id`.
|
|
946
|
+
* @param id - Storage handle to look up.
|
|
947
|
+
*/
|
|
948
|
+
load(id: string): Promise<Result<CryptoKey>>;
|
|
949
|
+
/**
|
|
950
|
+
* Deletes the entry stored under `id`. Missing ids fail, mirroring the
|
|
951
|
+
* encrypted-file backend. The existence check and the delete run in separate
|
|
952
|
+
* transactions (single-tab assumption).
|
|
953
|
+
* @param id - Storage handle to remove.
|
|
954
|
+
*/
|
|
955
|
+
delete(id: string): Promise<Result<string>>;
|
|
956
|
+
/**
|
|
957
|
+
* Lists every stored id.
|
|
958
|
+
*/
|
|
959
|
+
list(): Promise<Result<readonly string[]>>;
|
|
960
|
+
private _getRaw;
|
|
961
|
+
private _openDb;
|
|
962
|
+
private _open;
|
|
963
|
+
private _withStore;
|
|
964
|
+
private _request;
|
|
965
|
+
private _awaitCompletion;
|
|
966
|
+
}
|
|
743
967
|
|
|
744
968
|
/**
|
|
745
969
|
* Tree initializer for File System Access API directory handles.
|
|
@@ -751,8 +975,6 @@ declare function extractFileListMetadata(fileList: FileList): Array<IFileMetadat
|
|
|
751
975
|
readonly nonRecursive?: boolean;
|
|
752
976
|
}
|
|
753
977
|
|
|
754
|
-
declare type IEncryptionResult = CryptoUtils_2.IEncryptionResult;
|
|
755
|
-
|
|
756
978
|
/**
|
|
757
979
|
* Tree initializer for File System Access API file handles.
|
|
758
980
|
* @public
|
|
@@ -820,6 +1042,12 @@ declare function extractFileListMetadata(fileList: FileList): Array<IFileMetadat
|
|
|
820
1042
|
showSaveFilePicker(options?: ShowSaveFilePickerOptions): Promise<FileSystemFileHandle_2>;
|
|
821
1043
|
}
|
|
822
1044
|
|
|
1045
|
+
/**
|
|
1046
|
+
* Output of `HpkeProvider.sealBase`. Re-exported from `@fgv/ts-extras`.
|
|
1047
|
+
* @public
|
|
1048
|
+
*/
|
|
1049
|
+
declare type IHpkeSealResult = CryptoUtils_2.IHpkeSealResult;
|
|
1050
|
+
|
|
823
1051
|
/**
|
|
824
1052
|
* Configuration for creating HTTP-backed tree accessors.
|
|
825
1053
|
* @public
|
|
@@ -833,6 +1061,27 @@ declare function extractFileListMetadata(fileList: FileList): Array<IFileMetadat
|
|
|
833
1061
|
readonly logger?: Logging.LogReporter<unknown>;
|
|
834
1062
|
}
|
|
835
1063
|
|
|
1064
|
+
/**
|
|
1065
|
+
* Parameters for {@link CryptoUtils.IdbPrivateKeyStorage.create}.
|
|
1066
|
+
* @public
|
|
1067
|
+
*/
|
|
1068
|
+
declare interface IIdbPrivateKeyStorageCreateParams {
|
|
1069
|
+
/**
|
|
1070
|
+
* IndexedDB database name. Default: `'fgv-keystore-private-keys'`.
|
|
1071
|
+
*/
|
|
1072
|
+
readonly databaseName?: string;
|
|
1073
|
+
/**
|
|
1074
|
+
* IndexedDB object-store name. Default: `'privateKeys'`.
|
|
1075
|
+
*/
|
|
1076
|
+
readonly storeName?: string;
|
|
1077
|
+
/**
|
|
1078
|
+
* IndexedDB factory to use. Defaults to `globalThis.indexedDB`. Supplied
|
|
1079
|
+
* explicitly in tests (e.g. a `fake-indexeddb` factory) or to target a
|
|
1080
|
+
* non-default factory.
|
|
1081
|
+
*/
|
|
1082
|
+
readonly indexedDB?: IDBFactory;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
836
1085
|
/**
|
|
837
1086
|
* Configuration for LocalStorageTreeAccessors.
|
|
838
1087
|
* @public
|
package/dist/tsdoc-metadata.json
CHANGED
package/eslint.config.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// ESLint 9 flat config
|
|
2
|
+
const nodeProfile = require('@rushstack/eslint-config/flat/profile/node');
|
|
3
|
+
const packletsPlugin = require('@rushstack/eslint-config/flat/mixins/packlets');
|
|
4
|
+
const tsdocPlugin = require('@rushstack/eslint-config/flat/mixins/tsdoc');
|
|
5
|
+
|
|
6
|
+
module.exports = [
|
|
7
|
+
...nodeProfile,
|
|
8
|
+
packletsPlugin,
|
|
9
|
+
...tsdocPlugin,
|
|
10
|
+
{
|
|
11
|
+
rules: {
|
|
12
|
+
'@rushstack/packlets/mechanics': 'warn'
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
// file-api-types/ deliberately mirrors the browser File System Access API.
|
|
17
|
+
// Interface names match the DOM verbatim (no `I` prefix) and some APIs return `null`.
|
|
18
|
+
files: ['src/packlets/file-api-types/**/*.ts'],
|
|
19
|
+
rules: {
|
|
20
|
+
'@typescript-eslint/naming-convention': 'off',
|
|
21
|
+
'@rushstack/no-new-null': 'off'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
// MockStorage implements the browser Storage interface (localStorage), which
|
|
26
|
+
// declares `getItem(key)` and `key(index)` as returning `string | null`.
|
|
27
|
+
files: ['src/test/unit/localStorageTreeAccessors.test.ts'],
|
|
28
|
+
rules: {
|
|
29
|
+
'@rushstack/no-new-null': 'off'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
];
|