@fgv/ts-web-extras 5.1.0-4 → 5.1.0-40

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.
Files changed (424) hide show
  1. package/dist/packlets/crypto-utils/browserCryptoProvider.js +330 -18
  2. package/dist/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
  3. package/dist/packlets/crypto-utils/idbPrivateKeyStorage.js +238 -0
  4. package/dist/packlets/crypto-utils/idbPrivateKeyStorage.js.map +1 -0
  5. package/dist/packlets/crypto-utils/index.js +13 -0
  6. package/dist/packlets/crypto-utils/index.js.map +1 -1
  7. package/dist/packlets/file-tree/directoryHandleStore.js.map +1 -1
  8. package/dist/packlets/file-tree/fileApiTreeAccessors.js +1 -1
  9. package/dist/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
  10. package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js +2 -2
  11. package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -1
  12. package/dist/packlets/file-tree/httpTreeAccessors.js +74 -44
  13. package/dist/packlets/file-tree/httpTreeAccessors.js.map +1 -1
  14. package/dist/packlets/file-tree/localStorageTreeAccessors.js.map +1 -1
  15. package/dist/packlets/helpers/fileTreeHelpers.js +1 -1
  16. package/dist/packlets/helpers/fileTreeHelpers.js.map +1 -1
  17. package/dist/ts-web-extras.d.ts +229 -10
  18. package/dist/tsdoc-metadata.json +1 -1
  19. package/eslint.config.js +32 -0
  20. package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts +115 -6
  21. package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts.map +1 -1
  22. package/lib/packlets/crypto-utils/browserCryptoProvider.js +329 -17
  23. package/lib/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
  24. package/lib/packlets/crypto-utils/idbPrivateKeyStorage.d.ts +87 -0
  25. package/lib/packlets/crypto-utils/idbPrivateKeyStorage.d.ts.map +1 -0
  26. package/lib/packlets/crypto-utils/idbPrivateKeyStorage.js +242 -0
  27. package/lib/packlets/crypto-utils/idbPrivateKeyStorage.js.map +1 -0
  28. package/lib/packlets/crypto-utils/index.d.ts +14 -0
  29. package/lib/packlets/crypto-utils/index.d.ts.map +1 -1
  30. package/lib/packlets/crypto-utils/index.js +14 -0
  31. package/lib/packlets/crypto-utils/index.js.map +1 -1
  32. package/lib/packlets/file-tree/directoryHandleStore.d.ts +2 -2
  33. package/lib/packlets/file-tree/directoryHandleStore.d.ts.map +1 -1
  34. package/lib/packlets/file-tree/directoryHandleStore.js.map +1 -1
  35. package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts +2 -2
  36. package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts.map +1 -1
  37. package/lib/packlets/file-tree/fileApiTreeAccessors.js +1 -1
  38. package/lib/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
  39. package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.d.ts.map +1 -1
  40. package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js +2 -2
  41. package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -1
  42. package/lib/packlets/file-tree/httpTreeAccessors.d.ts +6 -0
  43. package/lib/packlets/file-tree/httpTreeAccessors.d.ts.map +1 -1
  44. package/lib/packlets/file-tree/httpTreeAccessors.js +74 -44
  45. package/lib/packlets/file-tree/httpTreeAccessors.js.map +1 -1
  46. package/lib/packlets/file-tree/localStorageTreeAccessors.js.map +1 -1
  47. package/lib/packlets/helpers/fileTreeHelpers.d.ts +1 -1
  48. package/lib/packlets/helpers/fileTreeHelpers.d.ts.map +1 -1
  49. package/lib/packlets/helpers/fileTreeHelpers.js +6 -6
  50. package/lib/packlets/helpers/fileTreeHelpers.js.map +1 -1
  51. package/package.json +15 -14
  52. package/.rush/temp/44b0369e8112f3c6f4248af466a3f35ad626d9d7.tar.log +0 -237
  53. package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +0 -55
  54. package/.rush/temp/operation/build/all.log +0 -55
  55. package/.rush/temp/operation/build/log-chunks.jsonl +0 -55
  56. package/.rush/temp/operation/build/state.json +0 -3
  57. package/.rush/temp/shrinkwrap-deps.json +0 -692
  58. package/CHANGELOG.md +0 -23
  59. package/config/api-extractor.json +0 -343
  60. package/config/jest.config.json +0 -19
  61. package/config/rig.json +0 -16
  62. package/config/typedoc.json +0 -7
  63. package/dist/test/mocks/idb-keyval.js +0 -6
  64. package/dist/test/mocks/idb-keyval.js.map +0 -1
  65. package/dist/test/setupTests.js +0 -74
  66. package/dist/test/setupTests.js.map +0 -1
  67. package/dist/test/unit/browserHashProvider.test.js +0 -140
  68. package/dist/test/unit/browserHashProvider.test.js.map +0 -1
  69. package/dist/test/unit/directoryHandleStore.test.js +0 -190
  70. package/dist/test/unit/directoryHandleStore.test.js.map +0 -1
  71. package/dist/test/unit/fileApiTreeAccessors.test.js +0 -1188
  72. package/dist/test/unit/fileApiTreeAccessors.test.js.map +0 -1
  73. package/dist/test/unit/fileApiTypes.test.js +0 -472
  74. package/dist/test/unit/fileApiTypes.test.js.map +0 -1
  75. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js +0 -622
  76. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
  77. package/dist/test/unit/fileTreeHelpers.test.js +0 -590
  78. package/dist/test/unit/fileTreeHelpers.test.js.map +0 -1
  79. package/dist/test/unit/httpTreeAccessors.test.js +0 -1229
  80. package/dist/test/unit/httpTreeAccessors.test.js.map +0 -1
  81. package/dist/test/unit/localStorageTreeAccessors.test.js +0 -812
  82. package/dist/test/unit/localStorageTreeAccessors.test.js.map +0 -1
  83. package/dist/test/unit/urlParams.test.js +0 -393
  84. package/dist/test/unit/urlParams.test.js.map +0 -1
  85. package/dist/test/utils/fileSystemAccessMocks.js +0 -271
  86. package/dist/test/utils/fileSystemAccessMocks.js.map +0 -1
  87. package/dist/test/utils/testHelpers.js +0 -124
  88. package/dist/test/utils/testHelpers.js.map +0 -1
  89. package/docs/CryptoUtils/README.md +0 -60
  90. package/docs/CryptoUtils/classes/BrowserCryptoProvider.decrypt.md +0 -27
  91. package/docs/CryptoUtils/classes/BrowserCryptoProvider.deriveKey.md +0 -26
  92. package/docs/CryptoUtils/classes/BrowserCryptoProvider.encrypt.md +0 -25
  93. package/docs/CryptoUtils/classes/BrowserCryptoProvider.fromBase64.md +0 -24
  94. package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateKey.md +0 -17
  95. package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateRandomBytes.md +0 -24
  96. package/docs/CryptoUtils/classes/BrowserCryptoProvider.md +0 -151
  97. package/docs/CryptoUtils/classes/BrowserCryptoProvider.toBase64.md +0 -24
  98. package/docs/CryptoUtils/classes/BrowserHashProvider.hashParts.md +0 -26
  99. package/docs/CryptoUtils/classes/BrowserHashProvider.hashString.md +0 -25
  100. package/docs/CryptoUtils/classes/BrowserHashProvider.md +0 -81
  101. package/docs/CryptoUtils/functions/createBrowserCryptoProvider.md +0 -12
  102. package/docs/FileTreeHelpers/README.md +0 -85
  103. package/docs/FileTreeHelpers/functions/extractFileListMetadata.md +0 -11
  104. package/docs/FileTreeHelpers/functions/extractFileMetadata.md +0 -11
  105. package/docs/FileTreeHelpers/functions/fromDirectoryUpload.md +0 -12
  106. package/docs/FileTreeHelpers/functions/fromFileList.md +0 -12
  107. package/docs/FileTreeHelpers/functions/getOriginalFile.md +0 -11
  108. package/docs/FileTreeHelpers/variables/defaultFileApiTreeInitParams.md +0 -9
  109. package/docs/README.md +0 -524
  110. package/docs/classes/BrowserCryptoProvider.decrypt.md +0 -27
  111. package/docs/classes/BrowserCryptoProvider.deriveKey.md +0 -26
  112. package/docs/classes/BrowserCryptoProvider.encrypt.md +0 -25
  113. package/docs/classes/BrowserCryptoProvider.fromBase64.md +0 -24
  114. package/docs/classes/BrowserCryptoProvider.generateKey.md +0 -17
  115. package/docs/classes/BrowserCryptoProvider.generateRandomBytes.md +0 -24
  116. package/docs/classes/BrowserCryptoProvider.md +0 -151
  117. package/docs/classes/BrowserCryptoProvider.toBase64.md +0 -24
  118. package/docs/classes/BrowserHashProvider.hashParts.md +0 -26
  119. package/docs/classes/BrowserHashProvider.hashString.md +0 -25
  120. package/docs/classes/BrowserHashProvider.md +0 -81
  121. package/docs/classes/DirectoryHandleStore.getAll.md +0 -17
  122. package/docs/classes/DirectoryHandleStore.getAllLabels.md +0 -17
  123. package/docs/classes/DirectoryHandleStore.load.md +0 -24
  124. package/docs/classes/DirectoryHandleStore.md +0 -120
  125. package/docs/classes/DirectoryHandleStore.remove.md +0 -24
  126. package/docs/classes/DirectoryHandleStore.save.md +0 -25
  127. package/docs/classes/FileApiTreeAccessors.create.md +0 -25
  128. package/docs/classes/FileApiTreeAccessors.createFromHttp.md +0 -24
  129. package/docs/classes/FileApiTreeAccessors.createFromLocalStorage.md +0 -25
  130. package/docs/classes/FileApiTreeAccessors.createPersistent.md +0 -26
  131. package/docs/classes/FileApiTreeAccessors.createPersistentFromFile.md +0 -27
  132. package/docs/classes/FileApiTreeAccessors.extractFileMetadata.md +0 -24
  133. package/docs/classes/FileApiTreeAccessors.fromDirectoryUpload.md +0 -25
  134. package/docs/classes/FileApiTreeAccessors.fromFileList.md +0 -25
  135. package/docs/classes/FileApiTreeAccessors.getOriginalFile.md +0 -27
  136. package/docs/classes/FileApiTreeAccessors.md +0 -172
  137. package/docs/classes/FileSystemAccessTreeAccessors.deleteFile.md +0 -22
  138. package/docs/classes/FileSystemAccessTreeAccessors.fileIsMutable.md +0 -22
  139. package/docs/classes/FileSystemAccessTreeAccessors.fromDirectoryHandle.md +0 -25
  140. package/docs/classes/FileSystemAccessTreeAccessors.fromFileHandle.md +0 -29
  141. package/docs/classes/FileSystemAccessTreeAccessors.getDirtyPaths.md +0 -15
  142. package/docs/classes/FileSystemAccessTreeAccessors.isDirty.md +0 -15
  143. package/docs/classes/FileSystemAccessTreeAccessors.md +0 -275
  144. package/docs/classes/FileSystemAccessTreeAccessors.saveFileContents.md +0 -23
  145. package/docs/classes/FileSystemAccessTreeAccessors.syncToDisk.md +0 -15
  146. package/docs/classes/HttpTreeAccessors.deleteFile.md +0 -22
  147. package/docs/classes/HttpTreeAccessors.fileIsMutable.md +0 -24
  148. package/docs/classes/HttpTreeAccessors.fromHttp.md +0 -24
  149. package/docs/classes/HttpTreeAccessors.getDirtyPaths.md +0 -17
  150. package/docs/classes/HttpTreeAccessors.isDirty.md +0 -17
  151. package/docs/classes/HttpTreeAccessors.md +0 -261
  152. package/docs/classes/HttpTreeAccessors.saveFileContents.md +0 -25
  153. package/docs/classes/HttpTreeAccessors.syncToDisk.md +0 -22
  154. package/docs/classes/LocalStorageTreeAccessors.deleteFile.md +0 -24
  155. package/docs/classes/LocalStorageTreeAccessors.fileIsMutable.md +0 -24
  156. package/docs/classes/LocalStorageTreeAccessors.fromStorage.md +0 -25
  157. package/docs/classes/LocalStorageTreeAccessors.getDirtyPaths.md +0 -17
  158. package/docs/classes/LocalStorageTreeAccessors.isDirty.md +0 -17
  159. package/docs/classes/LocalStorageTreeAccessors.md +0 -270
  160. package/docs/classes/LocalStorageTreeAccessors.saveFileContents.md +0 -25
  161. package/docs/classes/LocalStorageTreeAccessors.syncToDisk.md +0 -17
  162. package/docs/functions/createBrowserCryptoProvider.md +0 -12
  163. package/docs/functions/exportAsJson.md +0 -12
  164. package/docs/functions/exportUsingFileSystemAPI.md +0 -11
  165. package/docs/functions/extractDirectoryPath.md +0 -13
  166. package/docs/functions/extractFileListMetadata.md +0 -11
  167. package/docs/functions/extractFileMetadata.md +0 -11
  168. package/docs/functions/fromDirectoryUpload.md +0 -12
  169. package/docs/functions/fromFileList.md +0 -12
  170. package/docs/functions/getOriginalFile.md +0 -11
  171. package/docs/functions/isDirectoryHandle.md +0 -11
  172. package/docs/functions/isFileHandle.md +0 -11
  173. package/docs/functions/isFilePath.md +0 -11
  174. package/docs/functions/parseContextFilter.md +0 -12
  175. package/docs/functions/parseQualifierDefaults.md +0 -12
  176. package/docs/functions/parseResourceTypes.md +0 -12
  177. package/docs/functions/parseUrlParameters.md +0 -11
  178. package/docs/functions/safeShowDirectoryPicker.md +0 -11
  179. package/docs/functions/safeShowOpenFilePicker.md +0 -11
  180. package/docs/functions/safeShowSaveFilePicker.md +0 -11
  181. package/docs/functions/supportsFileSystemAccess.md +0 -11
  182. package/docs/interfaces/FilePickerAcceptType.accept.md +0 -9
  183. package/docs/interfaces/FilePickerAcceptType.description.md +0 -9
  184. package/docs/interfaces/FilePickerAcceptType.md +0 -61
  185. package/docs/interfaces/FileSystemCreateWritableOptions.keepExistingData.md +0 -9
  186. package/docs/interfaces/FileSystemCreateWritableOptions.md +0 -44
  187. package/docs/interfaces/FileSystemDirectoryHandle._asyncIterator_.md +0 -13
  188. package/docs/interfaces/FileSystemDirectoryHandle.entries.md +0 -13
  189. package/docs/interfaces/FileSystemDirectoryHandle.getDirectoryHandle.md +0 -21
  190. package/docs/interfaces/FileSystemDirectoryHandle.getFileHandle.md +0 -21
  191. package/docs/interfaces/FileSystemDirectoryHandle.keys.md +0 -13
  192. package/docs/interfaces/FileSystemDirectoryHandle.kind.md +0 -9
  193. package/docs/interfaces/FileSystemDirectoryHandle.md +0 -224
  194. package/docs/interfaces/FileSystemDirectoryHandle.removeEntry.md +0 -21
  195. package/docs/interfaces/FileSystemDirectoryHandle.resolve.md +0 -20
  196. package/docs/interfaces/FileSystemDirectoryHandle.values.md +0 -13
  197. package/docs/interfaces/FileSystemFileHandle.createWritable.md +0 -20
  198. package/docs/interfaces/FileSystemFileHandle.getFile.md +0 -13
  199. package/docs/interfaces/FileSystemFileHandle.kind.md +0 -9
  200. package/docs/interfaces/FileSystemFileHandle.md +0 -146
  201. package/docs/interfaces/FileSystemGetDirectoryOptions.create.md +0 -9
  202. package/docs/interfaces/FileSystemGetDirectoryOptions.md +0 -44
  203. package/docs/interfaces/FileSystemGetFileOptions.create.md +0 -9
  204. package/docs/interfaces/FileSystemGetFileOptions.md +0 -44
  205. package/docs/interfaces/FileSystemHandle.isSameEntry.md +0 -20
  206. package/docs/interfaces/FileSystemHandle.kind.md +0 -9
  207. package/docs/interfaces/FileSystemHandle.md +0 -118
  208. package/docs/interfaces/FileSystemHandle.name.md +0 -9
  209. package/docs/interfaces/FileSystemHandle.queryPermission.md +0 -20
  210. package/docs/interfaces/FileSystemHandle.requestPermission.md +0 -20
  211. package/docs/interfaces/FileSystemHandlePermissionDescriptor.md +0 -44
  212. package/docs/interfaces/FileSystemHandlePermissionDescriptor.mode.md +0 -9
  213. package/docs/interfaces/FileSystemRemoveOptions.md +0 -44
  214. package/docs/interfaces/FileSystemRemoveOptions.recursive.md +0 -9
  215. package/docs/interfaces/FileSystemWritableFileStream.md +0 -142
  216. package/docs/interfaces/FileSystemWritableFileStream.seek.md +0 -20
  217. package/docs/interfaces/FileSystemWritableFileStream.truncate.md +0 -20
  218. package/docs/interfaces/FileSystemWritableFileStream.write.md +0 -20
  219. package/docs/interfaces/IDirectoryHandleTreeInitializer.dirHandles.md +0 -9
  220. package/docs/interfaces/IDirectoryHandleTreeInitializer.md +0 -78
  221. package/docs/interfaces/IDirectoryHandleTreeInitializer.nonRecursive.md +0 -9
  222. package/docs/interfaces/IDirectoryHandleTreeInitializer.prefix.md +0 -9
  223. package/docs/interfaces/IFileHandleTreeInitializer.fileHandles.md +0 -9
  224. package/docs/interfaces/IFileHandleTreeInitializer.md +0 -61
  225. package/docs/interfaces/IFileHandleTreeInitializer.prefix.md +0 -9
  226. package/docs/interfaces/IFileListTreeInitializer.fileList.md +0 -9
  227. package/docs/interfaces/IFileListTreeInitializer.md +0 -44
  228. package/docs/interfaces/IFileMetadata.lastModified.md +0 -9
  229. package/docs/interfaces/IFileMetadata.md +0 -112
  230. package/docs/interfaces/IFileMetadata.name.md +0 -9
  231. package/docs/interfaces/IFileMetadata.path.md +0 -9
  232. package/docs/interfaces/IFileMetadata.size.md +0 -9
  233. package/docs/interfaces/IFileMetadata.type.md +0 -9
  234. package/docs/interfaces/IFileSystemAccessTreeParams.autoSync.md +0 -12
  235. package/docs/interfaces/IFileSystemAccessTreeParams.filePath.md +0 -13
  236. package/docs/interfaces/IFileSystemAccessTreeParams.logger.md +0 -11
  237. package/docs/interfaces/IFileSystemAccessTreeParams.md +0 -148
  238. package/docs/interfaces/IFileSystemAccessTreeParams.requireWritePermission.md +0 -13
  239. package/docs/interfaces/IFsAccessApis.md +0 -62
  240. package/docs/interfaces/IFsAccessApis.showDirectoryPicker.md +0 -20
  241. package/docs/interfaces/IFsAccessApis.showOpenFilePicker.md +0 -20
  242. package/docs/interfaces/IFsAccessApis.showSaveFilePicker.md +0 -20
  243. package/docs/interfaces/IHttpTreeParams.autoSync.md +0 -9
  244. package/docs/interfaces/IHttpTreeParams.baseUrl.md +0 -9
  245. package/docs/interfaces/IHttpTreeParams.fetchImpl.md +0 -9
  246. package/docs/interfaces/IHttpTreeParams.logger.md +0 -9
  247. package/docs/interfaces/IHttpTreeParams.md +0 -182
  248. package/docs/interfaces/IHttpTreeParams.namespace.md +0 -9
  249. package/docs/interfaces/IHttpTreeParams.userId.md +0 -9
  250. package/docs/interfaces/ILocalStorageTreeParams.autoSync.md +0 -12
  251. package/docs/interfaces/ILocalStorageTreeParams.md +0 -131
  252. package/docs/interfaces/ILocalStorageTreeParams.pathToKeyMap.md +0 -13
  253. package/docs/interfaces/ILocalStorageTreeParams.storage.md +0 -12
  254. package/docs/interfaces/IUrlConfigOptions.config.md +0 -11
  255. package/docs/interfaces/IUrlConfigOptions.configStartDir.md +0 -11
  256. package/docs/interfaces/IUrlConfigOptions.contextFilter.md +0 -11
  257. package/docs/interfaces/IUrlConfigOptions.input.md +0 -11
  258. package/docs/interfaces/IUrlConfigOptions.inputStartDir.md +0 -11
  259. package/docs/interfaces/IUrlConfigOptions.interactive.md +0 -11
  260. package/docs/interfaces/IUrlConfigOptions.loadZip.md +0 -11
  261. package/docs/interfaces/IUrlConfigOptions.maxDistance.md +0 -11
  262. package/docs/interfaces/IUrlConfigOptions.md +0 -248
  263. package/docs/interfaces/IUrlConfigOptions.qualifierDefaults.md +0 -11
  264. package/docs/interfaces/IUrlConfigOptions.reduceQualifiers.md +0 -11
  265. package/docs/interfaces/IUrlConfigOptions.resourceTypes.md +0 -11
  266. package/docs/interfaces/IUrlConfigOptions.zipFile.md +0 -11
  267. package/docs/interfaces/IUrlConfigOptions.zipPath.md +0 -11
  268. package/docs/interfaces/ShowDirectoryPickerOptions.id.md +0 -9
  269. package/docs/interfaces/ShowDirectoryPickerOptions.md +0 -78
  270. package/docs/interfaces/ShowDirectoryPickerOptions.mode.md +0 -9
  271. package/docs/interfaces/ShowDirectoryPickerOptions.startIn.md +0 -9
  272. package/docs/interfaces/ShowOpenFilePickerOptions.excludeAcceptAllOption.md +0 -9
  273. package/docs/interfaces/ShowOpenFilePickerOptions.id.md +0 -9
  274. package/docs/interfaces/ShowOpenFilePickerOptions.md +0 -112
  275. package/docs/interfaces/ShowOpenFilePickerOptions.multiple.md +0 -9
  276. package/docs/interfaces/ShowOpenFilePickerOptions.startIn.md +0 -9
  277. package/docs/interfaces/ShowOpenFilePickerOptions.types.md +0 -9
  278. package/docs/interfaces/ShowSaveFilePickerOptions.excludeAcceptAllOption.md +0 -9
  279. package/docs/interfaces/ShowSaveFilePickerOptions.id.md +0 -9
  280. package/docs/interfaces/ShowSaveFilePickerOptions.md +0 -112
  281. package/docs/interfaces/ShowSaveFilePickerOptions.startIn.md +0 -9
  282. package/docs/interfaces/ShowSaveFilePickerOptions.suggestedName.md +0 -9
  283. package/docs/interfaces/ShowSaveFilePickerOptions.types.md +0 -9
  284. package/docs/type-aliases/TreeInitializer.md +0 -11
  285. package/docs/type-aliases/WellKnownDirectory.md +0 -11
  286. package/docs/type-aliases/WindowWithFsAccess.md +0 -11
  287. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_DB.md +0 -9
  288. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_STORE.md +0 -9
  289. package/docs/variables/defaultFileApiTreeInitParams.md +0 -9
  290. package/etc/ts-web-extras.api.md +0 -433
  291. package/lib/test/mocks/idb-keyval.d.ts +0 -6
  292. package/lib/test/mocks/idb-keyval.d.ts.map +0 -1
  293. package/lib/test/mocks/idb-keyval.js +0 -9
  294. package/lib/test/mocks/idb-keyval.js.map +0 -1
  295. package/lib/test/setupTests.d.ts +0 -2
  296. package/lib/test/setupTests.d.ts.map +0 -1
  297. package/lib/test/setupTests.js +0 -76
  298. package/lib/test/setupTests.js.map +0 -1
  299. package/lib/test/unit/browserHashProvider.test.d.ts +0 -2
  300. package/lib/test/unit/browserHashProvider.test.d.ts.map +0 -1
  301. package/lib/test/unit/browserHashProvider.test.js +0 -142
  302. package/lib/test/unit/browserHashProvider.test.js.map +0 -1
  303. package/lib/test/unit/directoryHandleStore.test.d.ts +0 -2
  304. package/lib/test/unit/directoryHandleStore.test.d.ts.map +0 -1
  305. package/lib/test/unit/directoryHandleStore.test.js +0 -192
  306. package/lib/test/unit/directoryHandleStore.test.js.map +0 -1
  307. package/lib/test/unit/fileApiTreeAccessors.test.d.ts +0 -2
  308. package/lib/test/unit/fileApiTreeAccessors.test.d.ts.map +0 -1
  309. package/lib/test/unit/fileApiTreeAccessors.test.js +0 -1190
  310. package/lib/test/unit/fileApiTreeAccessors.test.js.map +0 -1
  311. package/lib/test/unit/fileApiTypes.test.d.ts +0 -2
  312. package/lib/test/unit/fileApiTypes.test.d.ts.map +0 -1
  313. package/lib/test/unit/fileApiTypes.test.js +0 -474
  314. package/lib/test/unit/fileApiTypes.test.js.map +0 -1
  315. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts +0 -2
  316. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts.map +0 -1
  317. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js +0 -624
  318. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
  319. package/lib/test/unit/fileTreeHelpers.test.d.ts +0 -2
  320. package/lib/test/unit/fileTreeHelpers.test.d.ts.map +0 -1
  321. package/lib/test/unit/fileTreeHelpers.test.js +0 -592
  322. package/lib/test/unit/fileTreeHelpers.test.js.map +0 -1
  323. package/lib/test/unit/httpTreeAccessors.test.d.ts +0 -2
  324. package/lib/test/unit/httpTreeAccessors.test.d.ts.map +0 -1
  325. package/lib/test/unit/httpTreeAccessors.test.js +0 -1231
  326. package/lib/test/unit/httpTreeAccessors.test.js.map +0 -1
  327. package/lib/test/unit/localStorageTreeAccessors.test.d.ts +0 -2
  328. package/lib/test/unit/localStorageTreeAccessors.test.d.ts.map +0 -1
  329. package/lib/test/unit/localStorageTreeAccessors.test.js +0 -814
  330. package/lib/test/unit/localStorageTreeAccessors.test.js.map +0 -1
  331. package/lib/test/unit/urlParams.test.d.ts +0 -2
  332. package/lib/test/unit/urlParams.test.d.ts.map +0 -1
  333. package/lib/test/unit/urlParams.test.js +0 -395
  334. package/lib/test/unit/urlParams.test.js.map +0 -1
  335. package/lib/test/utils/fileSystemAccessMocks.d.ts +0 -53
  336. package/lib/test/utils/fileSystemAccessMocks.d.ts.map +0 -1
  337. package/lib/test/utils/fileSystemAccessMocks.js +0 -277
  338. package/lib/test/utils/fileSystemAccessMocks.js.map +0 -1
  339. package/lib/test/utils/testHelpers.d.ts +0 -51
  340. package/lib/test/utils/testHelpers.d.ts.map +0 -1
  341. package/lib/test/utils/testHelpers.js +0 -133
  342. package/lib/test/utils/testHelpers.js.map +0 -1
  343. package/rush-logs/ts-web-extras.build.cache.log +0 -3
  344. package/rush-logs/ts-web-extras.build.log +0 -55
  345. package/src/index.browser.ts +0 -24
  346. package/src/index.ts +0 -47
  347. package/src/packlets/crypto-utils/browserCryptoProvider.ts +0 -311
  348. package/src/packlets/crypto-utils/browserHashProvider.ts +0 -73
  349. package/src/packlets/crypto-utils/index.ts +0 -29
  350. package/src/packlets/file-api-types/index.ts +0 -366
  351. package/src/packlets/file-tree/directoryHandleStore.ts +0 -136
  352. package/src/packlets/file-tree/fileApiTreeAccessors.ts +0 -528
  353. package/src/packlets/file-tree/fileSystemAccessTreeAccessors.ts +0 -519
  354. package/src/packlets/file-tree/httpTreeAccessors.ts +0 -448
  355. package/src/packlets/file-tree/index.ts +0 -32
  356. package/src/packlets/file-tree/localStorageTreeAccessors.ts +0 -430
  357. package/src/packlets/helpers/fileTreeHelpers.ts +0 -107
  358. package/src/packlets/helpers/index.ts +0 -28
  359. package/src/packlets/url-utils/index.ts +0 -28
  360. package/src/packlets/url-utils/urlParams.ts +0 -245
  361. package/src/test/mocks/idb-keyval.ts +0 -5
  362. package/src/test/setupTests.ts +0 -87
  363. package/src/test/unit/browserHashProvider.test.ts +0 -155
  364. package/src/test/unit/browserHashProvider.test.ts.bak +0 -376
  365. package/src/test/unit/directoryHandleStore.test.ts +0 -251
  366. package/src/test/unit/fileApiTreeAccessors.test.ts +0 -1387
  367. package/src/test/unit/fileApiTypes.test.ts +0 -587
  368. package/src/test/unit/fileSystemAccessTreeAccessors.test.ts +0 -885
  369. package/src/test/unit/fileTreeHelpers.test.ts +0 -694
  370. package/src/test/unit/httpTreeAccessors.test.ts +0 -1571
  371. package/src/test/unit/localStorageTreeAccessors.test.ts +0 -1014
  372. package/src/test/unit/urlParams.test.ts +0 -464
  373. package/src/test/utils/fileSystemAccessMocks.ts +0 -353
  374. package/src/test/utils/testHelpers.ts +0 -155
  375. package/temp/build/typescript/ts_8nwakTlr.json +0 -1
  376. package/temp/coverage/base.css +0 -224
  377. package/temp/coverage/block-navigation.js +0 -87
  378. package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +0 -1018
  379. package/temp/coverage/crypto-utils/browserHashProvider.ts.html +0 -304
  380. package/temp/coverage/crypto-utils/index.html +0 -131
  381. package/temp/coverage/favicon.png +0 -0
  382. package/temp/coverage/file-tree/directoryHandleStore.ts.html +0 -493
  383. package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +0 -1669
  384. package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
  385. package/temp/coverage/file-tree/httpTreeAccessors.ts.html +0 -1429
  386. package/temp/coverage/file-tree/index.html +0 -176
  387. package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +0 -1375
  388. package/temp/coverage/helpers/fileTreeHelpers.ts.html +0 -406
  389. package/temp/coverage/helpers/index.html +0 -116
  390. package/temp/coverage/index.html +0 -161
  391. package/temp/coverage/lcov-report/base.css +0 -224
  392. package/temp/coverage/lcov-report/block-navigation.js +0 -87
  393. package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +0 -1018
  394. package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +0 -304
  395. package/temp/coverage/lcov-report/crypto-utils/index.html +0 -131
  396. package/temp/coverage/lcov-report/favicon.png +0 -0
  397. package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +0 -493
  398. package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +0 -1669
  399. package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
  400. package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +0 -1429
  401. package/temp/coverage/lcov-report/file-tree/index.html +0 -176
  402. package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +0 -1375
  403. package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +0 -406
  404. package/temp/coverage/lcov-report/helpers/index.html +0 -116
  405. package/temp/coverage/lcov-report/index.html +0 -161
  406. package/temp/coverage/lcov-report/prettify.css +0 -1
  407. package/temp/coverage/lcov-report/prettify.js +0 -2
  408. package/temp/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  409. package/temp/coverage/lcov-report/sorter.js +0 -210
  410. package/temp/coverage/lcov-report/url-utils/index.html +0 -116
  411. package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +0 -820
  412. package/temp/coverage/lcov.info +0 -3597
  413. package/temp/coverage/prettify.css +0 -1
  414. package/temp/coverage/prettify.js +0 -2
  415. package/temp/coverage/sort-arrow-sprite.png +0 -0
  416. package/temp/coverage/sorter.js +0 -210
  417. package/temp/coverage/url-utils/index.html +0 -116
  418. package/temp/coverage/url-utils/urlParams.ts.html +0 -820
  419. package/temp/test/jest/haste-map-7492f1b44480e0cdd1f220078fb3afd8-c8dd6c3430605adeb2f1cadf4f75e791-8c9336785555d572065b28c111982ba4 +0 -0
  420. package/temp/test/jest/jest-transform-cache-7492f1b44480e0cdd1f220078fb3afd8-79ef2876fae7ca75eedb2aa53dc48338/7c/package_7c16afc8299e635d80273763175c7a50 +0 -53
  421. package/temp/test/jest/perf-cache-7492f1b44480e0cdd1f220078fb3afd8-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
  422. package/temp/ts-web-extras.api.json +0 -8850
  423. package/temp/ts-web-extras.api.md +0 -433
  424. package/tsconfig.json +0 -7
@@ -1,430 +0,0 @@
1
- /*
2
- * Copyright (c) 2026 Erik Fortune
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in all
12
- * copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
- import { DetailedResult, fail, Result, succeed, succeedWithDetail } from '@fgv/ts-utils';
24
- import { FileTree } from '@fgv/ts-json-base';
25
- import { isJsonObject, type JsonObject } from '@fgv/ts-json-base';
26
-
27
- /**
28
- * Configuration for LocalStorageTreeAccessors.
29
- * @public
30
- */
31
- export interface ILocalStorageTreeParams<TCT extends string = string>
32
- extends FileTree.IFileTreeInitParams<TCT> {
33
- /**
34
- * Map of directory path prefixes to localStorage keys.
35
- * Files under each prefix are stored in the corresponding localStorage key.
36
- * Example: \{ '/data/ingredients': 'myapp:ingredients:v1' \}
37
- */
38
- pathToKeyMap: Record<string, string>;
39
-
40
- /**
41
- * Storage instance to use. Defaults to window.localStorage.
42
- * Can be overridden for testing with mock storage.
43
- */
44
- storage?: Storage;
45
-
46
- /**
47
- * If true, automatically sync changes to localStorage on every modification.
48
- * If false (default), changes are only synced when syncToDisk() is called.
49
- */
50
- autoSync?: boolean;
51
- }
52
-
53
- /**
54
- * Browser localStorage-backed file tree accessors with persistence support.
55
- *
56
- * Maps filesystem-like directory paths to localStorage keys, where each key stores
57
- * multiple collections as a JSON object. This provides a general-purpose implementation
58
- * for browser-based file tree persistence without requiring File System Access API.
59
- *
60
- * Storage format per key: `{ "collection-id": "<raw file content>" }`
61
- * File paths map as: `/data/ingredients/collection-id.yaml` → stored in key for `/data/ingredients`
62
- *
63
- * Legacy format (v1): `{ "collection-id": { ...parsedJsonObject } }` is auto-migrated on load.
64
- *
65
- * @public
66
- */
67
- export class LocalStorageTreeAccessors<TCT extends string = string>
68
- extends FileTree.InMemoryTreeAccessors<TCT>
69
- implements FileTree.IPersistentFileTreeAccessors<TCT>
70
- {
71
- private readonly _storage: Storage;
72
- private readonly _pathToKeyMap: Map<string, string>;
73
- private readonly _keyToPathMap: Map<string, string>;
74
- private readonly _dirtyFiles: Set<string>;
75
- private readonly _autoSync: boolean;
76
-
77
- /**
78
- * Private constructor. Use fromStorage() factory method instead.
79
- * @internal
80
- */
81
- private constructor(
82
- files: FileTree.IInMemoryFile<TCT>[],
83
- storage: Storage,
84
- pathToKeyMap: Map<string, string>,
85
- params?: ILocalStorageTreeParams<TCT>
86
- ) {
87
- super(files, params);
88
- this._storage = storage;
89
- this._pathToKeyMap = pathToKeyMap;
90
- this._keyToPathMap = new Map(Array.from(pathToKeyMap.entries()).map(([k, v]) => [v, k]));
91
- this._dirtyFiles = new Set();
92
- /* c8 ignore next 1 - intermittent branch coverage: ?? false branch when params is undefined */
93
- this._autoSync = params?.autoSync ?? false;
94
- }
95
-
96
- /**
97
- * Create LocalStorageTreeAccessors from browser localStorage.
98
- * Loads all collections from the configured storage keys.
99
- *
100
- * @param params - Configuration including path-to-key mappings
101
- * @returns Result containing the accessors or an error
102
- * @public
103
- */
104
- public static fromStorage<TCT extends string = string>(
105
- params: ILocalStorageTreeParams<TCT>
106
- ): Result<LocalStorageTreeAccessors<TCT>> {
107
- try {
108
- /* c8 ignore next 1 - intermittent branch coverage: window.localStorage branch when params.storage is undefined */
109
- const storage = params.storage ?? (typeof window !== 'undefined' ? window.localStorage : undefined);
110
- if (!storage) {
111
- return fail('localStorage is not available');
112
- }
113
-
114
- const pathToKeyMap = new Map(Object.entries(params.pathToKeyMap));
115
- const files = this._loadFromStorage<TCT>(storage, pathToKeyMap, params);
116
-
117
- return succeed(new LocalStorageTreeAccessors<TCT>(files, storage, pathToKeyMap, params));
118
- /* c8 ignore next 4 - defensive: outer catch for unexpected errors */
119
- } catch (error) {
120
- const message = error instanceof Error ? error.message : String(error);
121
- return fail(`Failed to create LocalStorageTreeAccessors: ${message}`);
122
- }
123
- }
124
-
125
- /**
126
- * Load all files from localStorage based on path-to-key mappings.
127
- * @internal
128
- */
129
- private static _loadFromStorage<TCT extends string = string>(
130
- storage: Storage,
131
- pathToKeyMap: Map<string, string>,
132
- params?: ILocalStorageTreeParams<TCT>
133
- ): FileTree.IInMemoryFile<TCT>[] {
134
- const files: FileTree.IInMemoryFile<TCT>[] = [];
135
-
136
- for (const [dataPath, storageKey] of pathToKeyMap.entries()) {
137
- const rawJson = storage.getItem(storageKey);
138
- if (!rawJson) {
139
- continue;
140
- }
141
-
142
- try {
143
- const parsed: unknown = JSON.parse(rawJson);
144
- if (!isJsonObject(parsed)) {
145
- continue;
146
- }
147
-
148
- for (const [collectionId, contents] of Object.entries(parsed)) {
149
- // Support both new format (string values) and legacy format (JsonObject values)
150
- let rawContent: string;
151
- let extension: string;
152
- if (typeof contents === 'string') {
153
- rawContent = contents;
154
- // Infer extension: if content looks like JSON, use .json; otherwise .yaml
155
- extension = this._looksLikeJson(contents) ? '.json' : '.yaml';
156
- } else if (isJsonObject(contents)) {
157
- // Legacy format: migrate by stringifying
158
- rawContent = JSON.stringify(contents);
159
- extension = '.json';
160
- } else {
161
- continue;
162
- }
163
-
164
- const filePath = this._joinPath(dataPath, `${collectionId}${extension}`);
165
- /* c8 ignore next 3 - intermittent branch coverage: ternary branches in tight loop */
166
- const contentType = params?.inferContentType
167
- ? params.inferContentType(filePath, undefined).orDefault()
168
- : undefined;
169
-
170
- files.push({
171
- path: filePath,
172
- contents: rawContent,
173
- contentType
174
- });
175
- }
176
- } catch {
177
- // Skip corrupted data
178
- continue;
179
- }
180
- }
181
-
182
- return files;
183
- }
184
-
185
- /**
186
- * Heuristic check: does the content look like JSON?
187
- * @internal
188
- */
189
- private static _looksLikeJson(content: string): boolean {
190
- const trimmed = content.trimStart();
191
- return trimmed.startsWith('{') || trimmed.startsWith('[');
192
- }
193
-
194
- /**
195
- * Join path components, handling leading/trailing slashes.
196
- * @internal
197
- */
198
- private static _joinPath(base: string, name: string): string {
199
- /* c8 ignore next 2 - intermittent branch coverage: slash-trimming edge cases */
200
- const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;
201
- const cleanName = name.startsWith('/') ? name.slice(1) : name;
202
- return `${cleanBase}/${cleanName}`;
203
- }
204
-
205
- /**
206
- * Get the storage key for a given file path.
207
- * @internal
208
- */
209
- private _getStorageKeyForPath(path: string): string | undefined {
210
- // Find the longest matching prefix
211
- let bestMatch: { prefix: string; key: string } | undefined;
212
- for (const [prefix, key] of this._pathToKeyMap.entries()) {
213
- if (path.startsWith(prefix)) {
214
- /* c8 ignore next 1 - intermittent: overlapping-prefix branch requires two matching prefixes in iteration order */
215
- if (!bestMatch || prefix.length > bestMatch.prefix.length) {
216
- bestMatch = { prefix, key };
217
- }
218
- }
219
- }
220
- return bestMatch?.key;
221
- }
222
-
223
- /**
224
- * Get the data path prefix for a given file path.
225
- * @internal
226
- */
227
- private _getDataPathForPath(path: string): string | undefined {
228
- for (const prefix of this._pathToKeyMap.keys()) {
229
- if (path.startsWith(prefix)) {
230
- return prefix;
231
- }
232
- }
233
- /* c8 ignore next 2 - coverage intermittently missed in full suite */
234
- return undefined;
235
- }
236
-
237
- /**
238
- * Extract collection ID from a file path.
239
- * Example: '/data/ingredients/my-collection.yaml' → 'my-collection'
240
- * @internal
241
- */
242
- private _getCollectionIdFromPath(path: string): string {
243
- const dataPath = this._getDataPathForPath(path);
244
- /* c8 ignore next 3 - coverage intermittently missed in full suite */
245
- if (!dataPath) {
246
- return path;
247
- }
248
-
249
- const relativePath = path.slice(dataPath.length);
250
- /* c8 ignore next 1 - defensive: relativePath always starts with / when paths are absolute */
251
- const cleanPath = relativePath.startsWith('/') ? relativePath.slice(1) : relativePath;
252
-
253
- // Remove any file extension
254
- const dotIndex = cleanPath.lastIndexOf('.');
255
- return dotIndex > 0 ? cleanPath.slice(0, dotIndex) : cleanPath;
256
- }
257
-
258
- /**
259
- * Remove a file's entry from its localStorage key.
260
- * @internal
261
- */
262
- private _deleteFileFromStorage(path: string): void {
263
- const storageKey = this._getStorageKeyForPath(path);
264
- if (!storageKey) {
265
- return;
266
- }
267
-
268
- const collectionId = this._getCollectionIdFromPath(path);
269
- const existingJson = this._storage.getItem(storageKey);
270
- if (!existingJson) {
271
- return;
272
- }
273
-
274
- try {
275
- const parsed = JSON.parse(existingJson);
276
- if (isJsonObject(parsed)) {
277
- const existing = parsed as Record<string, unknown>;
278
- delete existing[collectionId];
279
- if (Object.keys(existing).length > 0) {
280
- this._storage.setItem(storageKey, JSON.stringify(existing));
281
- } else {
282
- this._storage.removeItem(storageKey);
283
- }
284
- }
285
- } catch {
286
- // Storage is corrupted — nothing to clean up
287
- }
288
- }
289
-
290
- /**
291
- * Sync a single dirty file to localStorage.
292
- * @internal
293
- */
294
- private _syncFile(path: string): Result<void> {
295
- const storageKey = this._getStorageKeyForPath(path);
296
- if (!storageKey) {
297
- return fail(`No storage key configured for path: ${path}`);
298
- }
299
-
300
- const collectionId = this._getCollectionIdFromPath(path);
301
- const contentsResult = this.getFileContents(path);
302
- if (contentsResult.isFailure()) {
303
- return fail(`Failed to get file contents for ${path}: ${contentsResult.message}`);
304
- }
305
-
306
- try {
307
- const contents = contentsResult.value;
308
-
309
- // Load existing data from storage
310
- const existingJson = this._storage.getItem(storageKey);
311
- let existing: Record<string, unknown> = {};
312
- if (existingJson) {
313
- try {
314
- const parsed = JSON.parse(existingJson);
315
- if (isJsonObject(parsed)) {
316
- existing = parsed as Record<string, unknown>;
317
- }
318
- } catch {
319
- // Start fresh if corrupted
320
- }
321
- }
322
-
323
- // Store raw content string (content-agnostic: JSON, YAML, etc.)
324
- existing[collectionId] = contents;
325
- this._storage.setItem(storageKey, JSON.stringify(existing));
326
-
327
- return succeed(undefined);
328
- /* c8 ignore next 4 - defensive: only triggers on storage quota or similar runtime errors */
329
- } catch (error) {
330
- const message = error instanceof Error ? error.message : String(error);
331
- return fail(`Failed to sync file ${path}: ${message}`);
332
- }
333
- }
334
-
335
- /**
336
- * Sync all dirty files to localStorage.
337
- * @returns Result indicating success or failure
338
- * @public
339
- */
340
- public async syncToDisk(): Promise<Result<void>> {
341
- if (this._dirtyFiles.size === 0) {
342
- return succeed(undefined);
343
- }
344
-
345
- const errors: string[] = [];
346
- for (const path of this._dirtyFiles) {
347
- const result = this._syncFile(path);
348
- if (result.isFailure()) {
349
- errors.push(result.message);
350
- }
351
- }
352
-
353
- if (errors.length > 0) {
354
- return fail(`Failed to sync ${errors.length} file(s): ${errors.join('; ')}`);
355
- }
356
-
357
- this._dirtyFiles.clear();
358
- return succeed(undefined);
359
- }
360
-
361
- /**
362
- * Check if there are unsaved changes.
363
- * @returns True if there are dirty files
364
- * @public
365
- */
366
- public isDirty(): boolean {
367
- return this._dirtyFiles.size > 0;
368
- }
369
-
370
- /**
371
- * Get list of file paths with unsaved changes.
372
- * @returns Array of dirty file paths
373
- * @public
374
- */
375
- public getDirtyPaths(): string[] {
376
- return Array.from(this._dirtyFiles);
377
- }
378
-
379
- /**
380
- * Delete a file and remove it from localStorage.
381
- * @param path - File path to delete
382
- * @returns Result with true if deleted, or error
383
- * @public
384
- */
385
- public deleteFile(path: string): Result<boolean> {
386
- const result = super.deleteFile(path);
387
- if (result.isSuccess()) {
388
- this._dirtyFiles.delete(path);
389
- this._deleteFileFromStorage(path);
390
- }
391
- return result;
392
- }
393
-
394
- /**
395
- * Save file contents. Marks file as dirty and optionally auto-syncs.
396
- * @param path - File path
397
- * @param contents - New file contents
398
- * @returns Result with the saved contents or error
399
- * @public
400
- */
401
- public saveFileContents(path: string, contents: string): Result<string> {
402
- const result = super.saveFileContents(path, contents);
403
- if (result.isSuccess()) {
404
- this._dirtyFiles.add(path);
405
- if (this._autoSync) {
406
- const syncResult = this._syncFile(path);
407
- if (syncResult.isSuccess()) {
408
- this._dirtyFiles.delete(path);
409
- } else {
410
- return fail(syncResult.message);
411
- }
412
- }
413
- }
414
- return result;
415
- }
416
-
417
- /**
418
- * Check if a file is mutable and return persistence detail.
419
- * @param path - File path to check
420
- * @returns DetailedResult with mutability status and 'persistent' detail if mutable
421
- * @public
422
- */
423
- public fileIsMutable(path: string): DetailedResult<boolean, FileTree.SaveDetail> {
424
- const baseResult = super.fileIsMutable(path);
425
- if (baseResult.isSuccess() && baseResult.value === true) {
426
- return succeedWithDetail(true, 'persistent');
427
- }
428
- return baseResult;
429
- }
430
- }
@@ -1,107 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Erik Fortune
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in all
12
- * copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
- import { Result } from '@fgv/ts-utils';
24
- import { FileTree } from '@fgv/ts-json-base';
25
- import { FileApiTreeAccessors, IFileMetadata } from '../file-tree/fileApiTreeAccessors';
26
-
27
- /**
28
- * Default initialization parameters for a `FileTree` using {@link FileApiTreeAccessors}.
29
- * @public
30
- */
31
- export const defaultFileApiTreeInitParams: FileTree.IFileTreeInitParams<string> = {
32
- inferContentType: FileTree.FileItem.defaultAcceptContentType
33
- };
34
-
35
- /**
36
- * Helper function to create a new FileTree instance
37
- * from a browser FileList (e.g., from input[type="file"]).
38
- * @param fileList - FileList from a file input element
39
- * @param params - Optional `IFileTreeInitParams` for the file tree.
40
- * @returns Promise resolving to a successful Result with the new FileTree instance
41
- * if successful, or a failed Result with an error message otherwise
42
- * @remarks The content type of the files is always `string` and the default
43
- * accept contentType function (`FileTree.FileItem.defaultAcceptContentType`) is
44
- * used, so content type is derived from the mime type of the file, when
45
- * available.
46
- * @public
47
- */
48
- export function fromFileList(
49
- fileList: FileList,
50
- params?: FileTree.IFileTreeInitParams<string>
51
- ): Promise<Result<FileTree.FileTree<string>>> {
52
- params = { ...defaultFileApiTreeInitParams, ...(params ?? {}) };
53
- return FileApiTreeAccessors.fromFileList(fileList, params);
54
- }
55
-
56
- /**
57
- * Helper function to create a new FileTree instance
58
- * from a directory upload with webkitRelativePath support.
59
- * @param fileList - FileList from a directory upload (input with webkitdirectory)
60
- * @param params - Optional `IFileTreeInitParams` for the file tree.
61
- * @returns Promise resolving to a successful Result with the new FileTree instance
62
- * if successful, or a failed Result with an error message otherwise
63
- * @remarks The content type of the files is always `string` and the default
64
- * accept contentType function (`FileTree.FileItem.defaultAcceptContentType`) is
65
- * is used, so content type is derived from the mime type of the file, when
66
- * available.
67
- * @public
68
- */
69
- export function fromDirectoryUpload(
70
- fileList: FileList,
71
- params?: FileTree.IFileTreeInitParams<string>
72
- ): Promise<Result<FileTree.FileTree<string>>> {
73
- params = { ...defaultFileApiTreeInitParams, ...(params ?? {}) };
74
- return FileApiTreeAccessors.fromDirectoryUpload(fileList, params);
75
- }
76
-
77
- /**
78
- * Helper function to get the original File object from a FileList by path.
79
- * @param fileList - The original FileList
80
- * @param path - The path to the file
81
- * @returns A successful Result with the File object if found,
82
- * or a failed Result with an error message otherwise
83
- * @public
84
- */
85
- export function getOriginalFile(fileList: FileList, path: string): Result<File> {
86
- return FileApiTreeAccessors.getOriginalFile(fileList, path);
87
- }
88
-
89
- /**
90
- * Helper function to extract metadata from a `FileList`.
91
- * @param fileList - The `FileList` to extract metadata from
92
- * @returns Array of {@link IFileMetadata | file metadata} objects
93
- * @public
94
- */
95
- export function extractFileListMetadata(fileList: FileList): Array<IFileMetadata> {
96
- return Array.from(fileList).map((f) => FileApiTreeAccessors.extractFileMetadata(f));
97
- }
98
-
99
- /**
100
- * Helper function to extract metadata from a `File`.
101
- * @param file - The File to extract metadata from
102
- * @returns {@link IFileMetadata | file metadata} object
103
- * @public
104
- */
105
- export function extractFileMetadata(file: File): IFileMetadata {
106
- return FileApiTreeAccessors.extractFileMetadata(file);
107
- }
@@ -1,28 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Erik Fortune
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in all
12
- * copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
- /**
24
- * Tree-shakeable helper functions for browser-compatible file operations.
25
- * @packageDocumentation
26
- */
27
-
28
- export * as FileTreeHelpers from './fileTreeHelpers';
@@ -1,28 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Erik Fortune
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in all
12
- * copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
- /**
24
- * URL parameter parsing utilities for web applications.
25
- * @packageDocumentation
26
- */
27
-
28
- export * from './urlParams';