@fgv/ts-web-extras 5.0.2 → 5.1.0-1

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 (383) hide show
  1. package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +58 -25
  2. package/.rush/temp/chunked-rush-logs/ts-web-extras.test.chunks.jsonl +70 -0
  3. package/.rush/temp/operation/build/all.log +58 -25
  4. package/.rush/temp/operation/build/error.log +18 -0
  5. package/.rush/temp/operation/build/log-chunks.jsonl +58 -25
  6. package/.rush/temp/operation/build/state.json +1 -1
  7. package/.rush/temp/operation/test/all.log +70 -0
  8. package/.rush/temp/operation/test/error.log +16 -0
  9. package/.rush/temp/operation/test/log-chunks.jsonl +70 -0
  10. package/.rush/temp/operation/test/state.json +3 -0
  11. package/.rush/temp/shrinkwrap-deps.json +175 -163
  12. package/config/jest.config.json +4 -1
  13. package/config/typedoc.json +6 -0
  14. package/dist/index.js +2 -2
  15. package/dist/index.js.map +1 -1
  16. package/dist/packlets/crypto-utils/browserCryptoProvider.js +254 -0
  17. package/dist/packlets/crypto-utils/browserCryptoProvider.js.map +1 -0
  18. package/dist/packlets/crypto-utils/browserHashProvider.js.map +1 -0
  19. package/dist/packlets/{crypto → crypto-utils}/index.js +1 -0
  20. package/dist/packlets/crypto-utils/index.js.map +1 -0
  21. package/dist/packlets/file-api-types/index.js +27 -3
  22. package/dist/packlets/file-api-types/index.js.map +1 -1
  23. package/dist/packlets/file-tree/directoryHandleStore.js +124 -0
  24. package/dist/packlets/file-tree/directoryHandleStore.js.map +1 -0
  25. package/dist/packlets/file-tree/fileApiTreeAccessors.js +91 -0
  26. package/dist/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
  27. package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js +414 -0
  28. package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -0
  29. package/dist/packlets/file-tree/httpTreeAccessors.js +279 -0
  30. package/dist/packlets/file-tree/httpTreeAccessors.js.map +1 -0
  31. package/dist/packlets/file-tree/index.js +4 -0
  32. package/dist/packlets/file-tree/index.js.map +1 -1
  33. package/dist/packlets/file-tree/localStorageTreeAccessors.js +359 -0
  34. package/dist/packlets/file-tree/localStorageTreeAccessors.js.map +1 -0
  35. package/dist/test/mocks/idb-keyval.js +6 -0
  36. package/dist/test/mocks/idb-keyval.js.map +1 -0
  37. package/dist/test/unit/browserHashProvider.test.js +1 -1
  38. package/dist/test/unit/browserHashProvider.test.js.map +1 -1
  39. package/dist/test/unit/directoryHandleStore.test.js +190 -0
  40. package/dist/test/unit/directoryHandleStore.test.js.map +1 -0
  41. package/dist/test/unit/fileApiTreeAccessors.test.js +51 -0
  42. package/dist/test/unit/fileApiTreeAccessors.test.js.map +1 -1
  43. package/dist/test/unit/fileApiTypes.test.js +30 -0
  44. package/dist/test/unit/fileApiTypes.test.js.map +1 -1
  45. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js +622 -0
  46. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js.map +1 -0
  47. package/dist/test/unit/httpTreeAccessors.test.js +1000 -0
  48. package/dist/test/unit/httpTreeAccessors.test.js.map +1 -0
  49. package/dist/test/unit/localStorageTreeAccessors.test.js +812 -0
  50. package/dist/test/unit/localStorageTreeAccessors.test.js.map +1 -0
  51. package/dist/test/utils/fileSystemAccessMocks.js +271 -0
  52. package/dist/test/utils/fileSystemAccessMocks.js.map +1 -0
  53. package/dist/ts-web-extras.d.ts +584 -1
  54. package/dist/tsdoc-metadata.json +1 -1
  55. package/docs/@fgv/namespaces/CryptoUtils/README.md +18 -0
  56. package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserCryptoProvider.md +203 -0
  57. package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserHashProvider.md +63 -0
  58. package/docs/@fgv/namespaces/CryptoUtils/functions/createBrowserCryptoProvider.md +18 -0
  59. package/docs/@fgv/namespaces/FileTreeHelpers/README.md +19 -0
  60. package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileListMetadata.md +23 -0
  61. package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileMetadata.md +23 -0
  62. package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromDirectoryUpload.md +33 -0
  63. package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromFileList.md +33 -0
  64. package/docs/@fgv/namespaces/FileTreeHelpers/functions/getOriginalFile.md +25 -0
  65. package/docs/@fgv/namespaces/FileTreeHelpers/variables/defaultFileApiTreeInitParams.md +11 -0
  66. package/docs/README.md +78 -0
  67. package/docs/classes/DirectoryHandleStore.md +116 -0
  68. package/docs/classes/FileApiTreeAccessors.md +286 -0
  69. package/docs/classes/FileSystemAccessTreeAccessors.md +557 -0
  70. package/docs/classes/HttpTreeAccessors.md +508 -0
  71. package/docs/classes/LocalStorageTreeAccessors.md +520 -0
  72. package/docs/functions/exportAsJson.md +23 -0
  73. package/docs/functions/exportUsingFileSystemAPI.md +26 -0
  74. package/docs/functions/extractDirectoryPath.md +23 -0
  75. package/docs/functions/isDirectoryHandle.md +23 -0
  76. package/docs/functions/isFileHandle.md +23 -0
  77. package/docs/functions/isFilePath.md +21 -0
  78. package/docs/functions/parseContextFilter.md +22 -0
  79. package/docs/functions/parseQualifierDefaults.md +22 -0
  80. package/docs/functions/parseResourceTypes.md +22 -0
  81. package/docs/functions/parseUrlParameters.md +15 -0
  82. package/docs/functions/safeShowDirectoryPicker.md +24 -0
  83. package/docs/functions/safeShowOpenFilePicker.md +24 -0
  84. package/docs/functions/safeShowSaveFilePicker.md +24 -0
  85. package/docs/functions/supportsFileSystemAccess.md +23 -0
  86. package/docs/interfaces/FilePickerAcceptType.md +16 -0
  87. package/docs/interfaces/FileSystemCreateWritableOptions.md +15 -0
  88. package/docs/interfaces/FileSystemDirectoryHandle.md +187 -0
  89. package/docs/interfaces/FileSystemFileHandle.md +106 -0
  90. package/docs/interfaces/FileSystemGetDirectoryOptions.md +15 -0
  91. package/docs/interfaces/FileSystemGetFileOptions.md +15 -0
  92. package/docs/interfaces/FileSystemHandle.md +69 -0
  93. package/docs/interfaces/FileSystemHandlePermissionDescriptor.md +15 -0
  94. package/docs/interfaces/FileSystemRemoveOptions.md +15 -0
  95. package/docs/interfaces/FileSystemWritableFileStream.md +127 -0
  96. package/docs/interfaces/IDirectoryHandleTreeInitializer.md +17 -0
  97. package/docs/interfaces/IFileHandleTreeInitializer.md +16 -0
  98. package/docs/interfaces/IFileListTreeInitializer.md +15 -0
  99. package/docs/interfaces/IFileMetadata.md +19 -0
  100. package/docs/interfaces/IFileSystemAccessTreeParams.md +30 -0
  101. package/docs/interfaces/IFsAccessApis.md +57 -0
  102. package/docs/interfaces/IHttpTreeParams.md +32 -0
  103. package/docs/interfaces/ILocalStorageTreeParams.md +30 -0
  104. package/docs/interfaces/IUrlConfigOptions.md +27 -0
  105. package/docs/interfaces/ShowDirectoryPickerOptions.md +17 -0
  106. package/docs/interfaces/ShowOpenFilePickerOptions.md +19 -0
  107. package/docs/interfaces/ShowSaveFilePickerOptions.md +19 -0
  108. package/docs/type-aliases/TreeInitializer.md +11 -0
  109. package/docs/type-aliases/WellKnownDirectory.md +11 -0
  110. package/docs/type-aliases/WindowWithFsAccess.md +11 -0
  111. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_DB.md +11 -0
  112. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_STORE.md +11 -0
  113. package/etc/ts-web-extras.api.md +124 -1
  114. package/lib/index.d.ts +2 -1
  115. package/lib/index.d.ts.map +1 -1
  116. package/lib/index.js +25 -2
  117. package/lib/index.js.map +1 -1
  118. package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts +77 -0
  119. package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts.map +1 -0
  120. package/lib/packlets/crypto-utils/browserCryptoProvider.js +259 -0
  121. package/lib/packlets/crypto-utils/browserCryptoProvider.js.map +1 -0
  122. package/lib/packlets/crypto-utils/browserHashProvider.d.ts.map +1 -0
  123. package/lib/packlets/crypto-utils/browserHashProvider.js.map +1 -0
  124. package/lib/packlets/{crypto → crypto-utils}/index.d.ts +1 -0
  125. package/lib/packlets/crypto-utils/index.d.ts.map +1 -0
  126. package/lib/packlets/{crypto → crypto-utils}/index.js +1 -0
  127. package/lib/packlets/crypto-utils/index.js.map +1 -0
  128. package/lib/packlets/file-api-types/index.d.ts.map +1 -1
  129. package/lib/packlets/file-api-types/index.js +27 -3
  130. package/lib/packlets/file-api-types/index.js.map +1 -1
  131. package/lib/packlets/file-tree/directoryHandleStore.d.ts +59 -0
  132. package/lib/packlets/file-tree/directoryHandleStore.d.ts.map +1 -0
  133. package/lib/packlets/file-tree/directoryHandleStore.js +128 -0
  134. package/lib/packlets/file-tree/directoryHandleStore.js.map +1 -0
  135. package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts +66 -0
  136. package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts.map +1 -1
  137. package/lib/packlets/file-tree/fileApiTreeAccessors.js +91 -0
  138. package/lib/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
  139. package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.d.ts +152 -0
  140. package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.d.ts.map +1 -0
  141. package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js +418 -0
  142. package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -0
  143. package/lib/packlets/file-tree/httpTreeAccessors.d.ts +88 -0
  144. package/lib/packlets/file-tree/httpTreeAccessors.d.ts.map +1 -0
  145. package/lib/packlets/file-tree/httpTreeAccessors.js +283 -0
  146. package/lib/packlets/file-tree/httpTreeAccessors.js.map +1 -0
  147. package/lib/packlets/file-tree/index.d.ts +4 -0
  148. package/lib/packlets/file-tree/index.d.ts.map +1 -1
  149. package/lib/packlets/file-tree/index.js +4 -0
  150. package/lib/packlets/file-tree/index.js.map +1 -1
  151. package/lib/packlets/file-tree/localStorageTreeAccessors.d.ts +141 -0
  152. package/lib/packlets/file-tree/localStorageTreeAccessors.d.ts.map +1 -0
  153. package/lib/packlets/file-tree/localStorageTreeAccessors.js +363 -0
  154. package/lib/packlets/file-tree/localStorageTreeAccessors.js.map +1 -0
  155. package/lib/test/mocks/idb-keyval.d.ts +6 -0
  156. package/lib/test/mocks/idb-keyval.d.ts.map +1 -0
  157. package/lib/test/mocks/idb-keyval.js +9 -0
  158. package/lib/test/mocks/idb-keyval.js.map +1 -0
  159. package/lib/test/unit/browserHashProvider.test.js +21 -21
  160. package/lib/test/unit/browserHashProvider.test.js.map +1 -1
  161. package/lib/test/unit/directoryHandleStore.test.d.ts +2 -0
  162. package/lib/test/unit/directoryHandleStore.test.d.ts.map +1 -0
  163. package/lib/test/unit/directoryHandleStore.test.js +192 -0
  164. package/lib/test/unit/directoryHandleStore.test.js.map +1 -0
  165. package/lib/test/unit/fileApiTreeAccessors.test.js +51 -0
  166. package/lib/test/unit/fileApiTreeAccessors.test.js.map +1 -1
  167. package/lib/test/unit/fileApiTypes.test.js +30 -0
  168. package/lib/test/unit/fileApiTypes.test.js.map +1 -1
  169. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts +2 -0
  170. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts.map +1 -0
  171. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js +624 -0
  172. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js.map +1 -0
  173. package/lib/test/unit/httpTreeAccessors.test.d.ts +2 -0
  174. package/lib/test/unit/httpTreeAccessors.test.d.ts.map +1 -0
  175. package/lib/test/unit/httpTreeAccessors.test.js +1002 -0
  176. package/lib/test/unit/httpTreeAccessors.test.js.map +1 -0
  177. package/lib/test/unit/localStorageTreeAccessors.test.d.ts +2 -0
  178. package/lib/test/unit/localStorageTreeAccessors.test.d.ts.map +1 -0
  179. package/lib/test/unit/localStorageTreeAccessors.test.js +814 -0
  180. package/lib/test/unit/localStorageTreeAccessors.test.js.map +1 -0
  181. package/lib/test/utils/fileSystemAccessMocks.d.ts +53 -0
  182. package/lib/test/utils/fileSystemAccessMocks.d.ts.map +1 -0
  183. package/lib/test/utils/fileSystemAccessMocks.js +277 -0
  184. package/lib/test/utils/fileSystemAccessMocks.js.map +1 -0
  185. package/package.json +41 -34
  186. package/rush-logs/ts-web-extras.build.cache.log +0 -1
  187. package/rush-logs/ts-web-extras.build.error.log +18 -0
  188. package/rush-logs/ts-web-extras.build.log +58 -25
  189. package/rush-logs/ts-web-extras.test.cache.log +1 -0
  190. package/rush-logs/ts-web-extras.test.error.log +16 -0
  191. package/rush-logs/ts-web-extras.test.log +70 -0
  192. package/src/index.ts +2 -2
  193. package/src/packlets/crypto-utils/browserCryptoProvider.ts +311 -0
  194. package/src/packlets/{crypto → crypto-utils}/index.ts +1 -0
  195. package/src/packlets/file-api-types/index.ts +24 -3
  196. package/src/packlets/file-tree/directoryHandleStore.ts +136 -0
  197. package/src/packlets/file-tree/fileApiTreeAccessors.ts +108 -0
  198. package/src/packlets/file-tree/fileSystemAccessTreeAccessors.ts +519 -0
  199. package/src/packlets/file-tree/httpTreeAccessors.ts +381 -0
  200. package/src/packlets/file-tree/index.ts +4 -0
  201. package/src/packlets/file-tree/localStorageTreeAccessors.ts +430 -0
  202. package/src/test/mocks/idb-keyval.ts +5 -0
  203. package/src/test/unit/browserHashProvider.test.ts +1 -1
  204. package/src/test/unit/directoryHandleStore.test.ts +251 -0
  205. package/src/test/unit/fileApiTreeAccessors.test.ts +69 -0
  206. package/src/test/unit/fileApiTypes.test.ts +36 -0
  207. package/src/test/unit/fileSystemAccessTreeAccessors.test.ts +885 -0
  208. package/src/test/unit/httpTreeAccessors.test.ts +1278 -0
  209. package/src/test/unit/localStorageTreeAccessors.test.ts +1014 -0
  210. package/src/test/utils/fileSystemAccessMocks.ts +353 -0
  211. package/temp/build/typescript/ts_8nwakTlr.json +1 -0
  212. package/temp/coverage/crypto/browserHashProvider.ts.html +1 -1
  213. package/temp/coverage/crypto/index.html +1 -1
  214. package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +1018 -0
  215. package/temp/coverage/crypto-utils/browserHashProvider.ts.html +304 -0
  216. package/temp/coverage/crypto-utils/index.html +131 -0
  217. package/temp/coverage/file-tree/directoryHandleStore.ts.html +493 -0
  218. package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +330 -6
  219. package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +1642 -0
  220. package/temp/coverage/file-tree/httpTreeAccessors.ts.html +1228 -0
  221. package/temp/coverage/file-tree/index.html +69 -9
  222. package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +1375 -0
  223. package/temp/coverage/helpers/fileTreeHelpers.ts.html +1 -1
  224. package/temp/coverage/helpers/index.html +1 -1
  225. package/temp/coverage/index.html +13 -13
  226. package/temp/coverage/lcov-report/crypto/browserHashProvider.ts.html +1 -1
  227. package/temp/coverage/lcov-report/crypto/index.html +1 -1
  228. package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +1018 -0
  229. package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +304 -0
  230. package/temp/coverage/lcov-report/crypto-utils/index.html +131 -0
  231. package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +493 -0
  232. package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +330 -6
  233. package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +1642 -0
  234. package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +1228 -0
  235. package/temp/coverage/lcov-report/file-tree/index.html +69 -9
  236. package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +1375 -0
  237. package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +1 -1
  238. package/temp/coverage/lcov-report/helpers/index.html +1 -1
  239. package/temp/coverage/lcov-report/index.html +13 -13
  240. package/temp/coverage/lcov-report/url-utils/index.html +1 -1
  241. package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +1 -1
  242. package/temp/coverage/lcov.info +2829 -428
  243. package/temp/coverage/url-utils/index.html +1 -1
  244. package/temp/coverage/url-utils/urlParams.ts.html +1 -1
  245. package/temp/test/jest/haste-map-b931e4e63102f86c5bd4949f7dced44f-9d713eb41149188b4e5c0ae3d86d0a57-2ad8e16b24e391b8cdbe50b55c137169 +0 -0
  246. package/temp/test/jest/perf-cache-b931e4e63102f86c5bd4949f7dced44f-da39a3ee5e6b4b0d3255bfef95601890 +1 -0
  247. package/temp/ts-web-extras.api.json +5282 -1472
  248. package/temp/ts-web-extras.api.md +124 -1
  249. package/dist/packlets/crypto/browserHashProvider.js.map +0 -1
  250. package/dist/packlets/crypto/index.js.map +0 -1
  251. package/docs/index.md +0 -34
  252. package/docs/ts-web-extras.browserhashprovider.hashparts.md +0 -88
  253. package/docs/ts-web-extras.browserhashprovider.hashstring.md +0 -72
  254. package/docs/ts-web-extras.browserhashprovider.md +0 -66
  255. package/docs/ts-web-extras.exportasjson.md +0 -70
  256. package/docs/ts-web-extras.exportusingfilesystemapi.md +0 -104
  257. package/docs/ts-web-extras.extractdirectorypath.md +0 -52
  258. package/docs/ts-web-extras.fileapitreeaccessors.create.md +0 -72
  259. package/docs/ts-web-extras.fileapitreeaccessors.extractfilemetadata.md +0 -54
  260. package/docs/ts-web-extras.fileapitreeaccessors.fromdirectoryupload.md +0 -72
  261. package/docs/ts-web-extras.fileapitreeaccessors.fromfilelist.md +0 -72
  262. package/docs/ts-web-extras.fileapitreeaccessors.getoriginalfile.md +0 -72
  263. package/docs/ts-web-extras.fileapitreeaccessors.md +0 -114
  264. package/docs/ts-web-extras.filepickeraccepttype.accept.md +0 -11
  265. package/docs/ts-web-extras.filepickeraccepttype.description.md +0 -11
  266. package/docs/ts-web-extras.filepickeraccepttype.md +0 -75
  267. package/docs/ts-web-extras.filesystemcreatewritableoptions_2.keepexistingdata.md +0 -11
  268. package/docs/ts-web-extras.filesystemcreatewritableoptions_2.md +0 -58
  269. package/docs/ts-web-extras.filesystemdirectoryhandle_2._symbol.asynciterator_.md +0 -15
  270. package/docs/ts-web-extras.filesystemdirectoryhandle_2.entries.md +0 -15
  271. package/docs/ts-web-extras.filesystemdirectoryhandle_2.getdirectoryhandle.md +0 -66
  272. package/docs/ts-web-extras.filesystemdirectoryhandle_2.getfilehandle.md +0 -66
  273. package/docs/ts-web-extras.filesystemdirectoryhandle_2.keys.md +0 -15
  274. package/docs/ts-web-extras.filesystemdirectoryhandle_2.kind.md +0 -11
  275. package/docs/ts-web-extras.filesystemdirectoryhandle_2.md +0 -146
  276. package/docs/ts-web-extras.filesystemdirectoryhandle_2.removeentry.md +0 -66
  277. package/docs/ts-web-extras.filesystemdirectoryhandle_2.resolve.md +0 -50
  278. package/docs/ts-web-extras.filesystemdirectoryhandle_2.values.md +0 -15
  279. package/docs/ts-web-extras.filesystemfilehandle_2.createwritable.md +0 -52
  280. package/docs/ts-web-extras.filesystemfilehandle_2.getfile.md +0 -15
  281. package/docs/ts-web-extras.filesystemfilehandle_2.kind.md +0 -11
  282. package/docs/ts-web-extras.filesystemfilehandle_2.md +0 -92
  283. package/docs/ts-web-extras.filesystemgetdirectoryoptions_2.create.md +0 -11
  284. package/docs/ts-web-extras.filesystemgetdirectoryoptions_2.md +0 -58
  285. package/docs/ts-web-extras.filesystemgetfileoptions_2.create.md +0 -11
  286. package/docs/ts-web-extras.filesystemgetfileoptions_2.md +0 -58
  287. package/docs/ts-web-extras.filesystemhandle_2.issameentry.md +0 -50
  288. package/docs/ts-web-extras.filesystemhandle_2.kind.md +0 -11
  289. package/docs/ts-web-extras.filesystemhandle_2.md +0 -119
  290. package/docs/ts-web-extras.filesystemhandle_2.name.md +0 -11
  291. package/docs/ts-web-extras.filesystemhandle_2.querypermission.md +0 -52
  292. package/docs/ts-web-extras.filesystemhandle_2.requestpermission.md +0 -52
  293. package/docs/ts-web-extras.filesystemhandlepermissiondescriptor.md +0 -58
  294. package/docs/ts-web-extras.filesystemhandlepermissiondescriptor.mode.md +0 -11
  295. package/docs/ts-web-extras.filesystemremoveoptions_2.md +0 -58
  296. package/docs/ts-web-extras.filesystemremoveoptions_2.recursive.md +0 -11
  297. package/docs/ts-web-extras.filesystemwritablefilestream_2.md +0 -57
  298. package/docs/ts-web-extras.filesystemwritablefilestream_2.seek.md +0 -50
  299. package/docs/ts-web-extras.filesystemwritablefilestream_2.truncate.md +0 -50
  300. package/docs/ts-web-extras.filesystemwritablefilestream_2.write.md +0 -50
  301. package/docs/ts-web-extras.filetreehelpers.defaultfileapitreeinitparams.md +0 -13
  302. package/docs/ts-web-extras.filetreehelpers.extractfilelistmetadata.md +0 -56
  303. package/docs/ts-web-extras.filetreehelpers.extractfilemetadata.md +0 -56
  304. package/docs/ts-web-extras.filetreehelpers.fromdirectoryupload.md +0 -76
  305. package/docs/ts-web-extras.filetreehelpers.fromfilelist.md +0 -76
  306. package/docs/ts-web-extras.filetreehelpers.getoriginalfile.md +0 -72
  307. package/docs/ts-web-extras.filetreehelpers.md +0 -102
  308. package/docs/ts-web-extras.idirectoryhandletreeinitializer.dirhandles.md +0 -11
  309. package/docs/ts-web-extras.idirectoryhandletreeinitializer.md +0 -100
  310. package/docs/ts-web-extras.idirectoryhandletreeinitializer.nonrecursive.md +0 -11
  311. package/docs/ts-web-extras.idirectoryhandletreeinitializer.prefix.md +0 -11
  312. package/docs/ts-web-extras.ifilehandletreeinitializer.filehandles.md +0 -11
  313. package/docs/ts-web-extras.ifilehandletreeinitializer.md +0 -79
  314. package/docs/ts-web-extras.ifilehandletreeinitializer.prefix.md +0 -11
  315. package/docs/ts-web-extras.ifilelisttreeinitializer.filelist.md +0 -11
  316. package/docs/ts-web-extras.ifilelisttreeinitializer.md +0 -58
  317. package/docs/ts-web-extras.ifilemetadata.lastmodified.md +0 -11
  318. package/docs/ts-web-extras.ifilemetadata.md +0 -124
  319. package/docs/ts-web-extras.ifilemetadata.name.md +0 -11
  320. package/docs/ts-web-extras.ifilemetadata.path.md +0 -11
  321. package/docs/ts-web-extras.ifilemetadata.size.md +0 -11
  322. package/docs/ts-web-extras.ifilemetadata.type.md +0 -11
  323. package/docs/ts-web-extras.ifsaccessapis.md +0 -56
  324. package/docs/ts-web-extras.ifsaccessapis.showdirectorypicker.md +0 -52
  325. package/docs/ts-web-extras.ifsaccessapis.showopenfilepicker.md +0 -52
  326. package/docs/ts-web-extras.ifsaccessapis.showsavefilepicker.md +0 -52
  327. package/docs/ts-web-extras.isdirectoryhandle.md +0 -56
  328. package/docs/ts-web-extras.isfilehandle.md +0 -56
  329. package/docs/ts-web-extras.isfilepath.md +0 -52
  330. package/docs/ts-web-extras.iurlconfigoptions.config.md +0 -13
  331. package/docs/ts-web-extras.iurlconfigoptions.configstartdir.md +0 -13
  332. package/docs/ts-web-extras.iurlconfigoptions.contextfilter.md +0 -13
  333. package/docs/ts-web-extras.iurlconfigoptions.input.md +0 -13
  334. package/docs/ts-web-extras.iurlconfigoptions.inputstartdir.md +0 -13
  335. package/docs/ts-web-extras.iurlconfigoptions.interactive.md +0 -13
  336. package/docs/ts-web-extras.iurlconfigoptions.loadzip.md +0 -13
  337. package/docs/ts-web-extras.iurlconfigoptions.maxdistance.md +0 -13
  338. package/docs/ts-web-extras.iurlconfigoptions.md +0 -286
  339. package/docs/ts-web-extras.iurlconfigoptions.qualifierdefaults.md +0 -13
  340. package/docs/ts-web-extras.iurlconfigoptions.reducequalifiers.md +0 -13
  341. package/docs/ts-web-extras.iurlconfigoptions.resourcetypes.md +0 -13
  342. package/docs/ts-web-extras.iurlconfigoptions.zipfile.md +0 -13
  343. package/docs/ts-web-extras.iurlconfigoptions.zippath.md +0 -13
  344. package/docs/ts-web-extras.md +0 -512
  345. package/docs/ts-web-extras.parsecontextfilter.md +0 -52
  346. package/docs/ts-web-extras.parsequalifierdefaults.md +0 -52
  347. package/docs/ts-web-extras.parseresourcetypes.md +0 -52
  348. package/docs/ts-web-extras.parseurlparameters.md +0 -17
  349. package/docs/ts-web-extras.safeshowdirectorypicker.md +0 -72
  350. package/docs/ts-web-extras.safeshowopenfilepicker.md +0 -72
  351. package/docs/ts-web-extras.safeshowsavefilepicker.md +0 -72
  352. package/docs/ts-web-extras.showdirectorypickeroptions.id.md +0 -11
  353. package/docs/ts-web-extras.showdirectorypickeroptions.md +0 -96
  354. package/docs/ts-web-extras.showdirectorypickeroptions.mode.md +0 -11
  355. package/docs/ts-web-extras.showdirectorypickeroptions.startin.md +0 -11
  356. package/docs/ts-web-extras.showopenfilepickeroptions.excludeacceptalloption.md +0 -11
  357. package/docs/ts-web-extras.showopenfilepickeroptions.id.md +0 -11
  358. package/docs/ts-web-extras.showopenfilepickeroptions.md +0 -134
  359. package/docs/ts-web-extras.showopenfilepickeroptions.multiple.md +0 -11
  360. package/docs/ts-web-extras.showopenfilepickeroptions.startin.md +0 -11
  361. package/docs/ts-web-extras.showopenfilepickeroptions.types.md +0 -11
  362. package/docs/ts-web-extras.showsavefilepickeroptions.excludeacceptalloption.md +0 -11
  363. package/docs/ts-web-extras.showsavefilepickeroptions.id.md +0 -11
  364. package/docs/ts-web-extras.showsavefilepickeroptions.md +0 -134
  365. package/docs/ts-web-extras.showsavefilepickeroptions.startin.md +0 -11
  366. package/docs/ts-web-extras.showsavefilepickeroptions.suggestedname.md +0 -11
  367. package/docs/ts-web-extras.showsavefilepickeroptions.types.md +0 -11
  368. package/docs/ts-web-extras.supportsfilesystemaccess.md +0 -56
  369. package/docs/ts-web-extras.treeinitializer.md +0 -15
  370. package/docs/ts-web-extras.wellknowndirectory.md +0 -13
  371. package/docs/ts-web-extras.windowwithfsaccess.md +0 -15
  372. package/lib/packlets/crypto/browserHashProvider.d.ts.map +0 -1
  373. package/lib/packlets/crypto/browserHashProvider.js.map +0 -1
  374. package/lib/packlets/crypto/index.d.ts.map +0 -1
  375. package/lib/packlets/crypto/index.js.map +0 -1
  376. package/temp/build/typescript/ts_vnCx6LlY.json +0 -1
  377. package/temp/test/jest/haste-map-7492f1b44480e0cdd1f220078fb3afd8-c8dd6c3430605adeb2f1cadf4f75e791-8c9336785555d572065b28c111982ba4 +0 -0
  378. package/temp/test/jest/perf-cache-7492f1b44480e0cdd1f220078fb3afd8-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
  379. /package/dist/packlets/{crypto → crypto-utils}/browserHashProvider.js +0 -0
  380. /package/lib/packlets/{crypto → crypto-utils}/browserHashProvider.d.ts +0 -0
  381. /package/lib/packlets/{crypto → crypto-utils}/browserHashProvider.js +0 -0
  382. /package/src/packlets/{crypto → crypto-utils}/browserHashProvider.ts +0 -0
  383. /package/temp/test/jest/{jest-transform-cache-7492f1b44480e0cdd1f220078fb3afd8-79ef2876fae7ca75eedb2aa53dc48338/0e/package_0eb6535f5987849d93ea51ef33a14cf6 → jest-transform-cache-b931e4e63102f86c5bd4949f7dced44f-79ef2876fae7ca75eedb2aa53dc48338/b5/package_b5f57afc9ec2c011239b1608ee5bdfa5} +0 -0
@@ -0,0 +1,190 @@
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
+ import '@fgv/ts-utils-jest';
23
+ import { DirectoryHandleStore, DEFAULT_DIRECTORY_HANDLE_DB, DEFAULT_DIRECTORY_HANDLE_STORE } from '../../packlets/file-tree/directoryHandleStore';
24
+ import { get, set, del, keys, createStore } from 'idb-keyval';
25
+ const mockGet = jest.mocked(get);
26
+ const mockSet = jest.mocked(set);
27
+ const mockDel = jest.mocked(del);
28
+ const mockKeys = jest.mocked(keys);
29
+ const mockCreateStore = jest.mocked(createStore);
30
+ function makeMockHandle(name) {
31
+ return {
32
+ kind: 'directory',
33
+ name,
34
+ isSameEntry: jest.fn(),
35
+ queryPermission: jest.fn(),
36
+ requestPermission: jest.fn(),
37
+ getDirectoryHandle: jest.fn(),
38
+ getFileHandle: jest.fn(),
39
+ removeEntry: jest.fn(),
40
+ resolve: jest.fn(),
41
+ keys: jest.fn(),
42
+ values: jest.fn(),
43
+ entries: jest.fn(),
44
+ [Symbol.asyncIterator]: jest.fn()
45
+ };
46
+ }
47
+ describe('DirectoryHandleStore', () => {
48
+ beforeEach(() => {
49
+ jest.clearAllMocks();
50
+ });
51
+ describe('constants', () => {
52
+ test('DEFAULT_DIRECTORY_HANDLE_DB has expected value', () => {
53
+ expect(DEFAULT_DIRECTORY_HANDLE_DB).toBe('chocolate-lab-storage');
54
+ });
55
+ test('DEFAULT_DIRECTORY_HANDLE_STORE has expected value', () => {
56
+ expect(DEFAULT_DIRECTORY_HANDLE_STORE).toBe('directory-handles');
57
+ });
58
+ });
59
+ describe('constructor', () => {
60
+ test('uses default db and store names', () => {
61
+ new DirectoryHandleStore();
62
+ expect(mockCreateStore).toHaveBeenCalledWith(DEFAULT_DIRECTORY_HANDLE_DB, DEFAULT_DIRECTORY_HANDLE_STORE);
63
+ });
64
+ test('uses custom db and store names', () => {
65
+ new DirectoryHandleStore('custom-db', 'custom-store');
66
+ expect(mockCreateStore).toHaveBeenCalledWith('custom-db', 'custom-store');
67
+ });
68
+ });
69
+ describe('save', () => {
70
+ test('saves a handle successfully', async () => {
71
+ mockSet.mockResolvedValue(undefined);
72
+ const store = new DirectoryHandleStore();
73
+ const handle = makeMockHandle('my-dir');
74
+ const result = await store.save('my-dir', handle);
75
+ expect(result).toSucceed();
76
+ expect(mockSet).toHaveBeenCalledWith('my-dir', handle, expect.anything());
77
+ });
78
+ test('returns failure when set throws', async () => {
79
+ mockSet.mockRejectedValue(new Error('IndexedDB unavailable'));
80
+ const store = new DirectoryHandleStore();
81
+ const handle = makeMockHandle('my-dir');
82
+ const result = await store.save('my-dir', handle);
83
+ expect(result).toFailWith(/IndexedDB unavailable/);
84
+ });
85
+ });
86
+ describe('load', () => {
87
+ test('returns the handle when found', async () => {
88
+ const handle = makeMockHandle('my-dir');
89
+ mockGet.mockResolvedValue(handle);
90
+ const store = new DirectoryHandleStore();
91
+ const result = await store.load('my-dir');
92
+ expect(result).toSucceedWith(handle);
93
+ expect(mockGet).toHaveBeenCalledWith('my-dir', expect.anything());
94
+ });
95
+ test('returns undefined when not found', async () => {
96
+ mockGet.mockResolvedValue(undefined);
97
+ const store = new DirectoryHandleStore();
98
+ const result = await store.load('missing');
99
+ expect(result).toSucceedWith(undefined);
100
+ });
101
+ test('returns failure when get throws', async () => {
102
+ mockGet.mockRejectedValue(new Error('read error'));
103
+ const store = new DirectoryHandleStore();
104
+ const result = await store.load('my-dir');
105
+ expect(result).toFailWith(/read error/);
106
+ });
107
+ });
108
+ describe('remove', () => {
109
+ test('removes a handle successfully', async () => {
110
+ mockDel.mockResolvedValue(undefined);
111
+ const store = new DirectoryHandleStore();
112
+ const result = await store.remove('my-dir');
113
+ expect(result).toSucceed();
114
+ expect(mockDel).toHaveBeenCalledWith('my-dir', expect.anything());
115
+ });
116
+ test('returns failure when del throws', async () => {
117
+ mockDel.mockRejectedValue(new Error('delete error'));
118
+ const store = new DirectoryHandleStore();
119
+ const result = await store.remove('my-dir');
120
+ expect(result).toFailWith(/delete error/);
121
+ });
122
+ });
123
+ describe('getAllLabels', () => {
124
+ test('returns all keys', async () => {
125
+ mockKeys.mockResolvedValue(['dir-a', 'dir-b']);
126
+ const store = new DirectoryHandleStore();
127
+ const result = await store.getAllLabels();
128
+ expect(result).toSucceedWith(['dir-a', 'dir-b']);
129
+ expect(mockKeys).toHaveBeenCalledWith(expect.anything());
130
+ });
131
+ test('returns empty array when no keys', async () => {
132
+ mockKeys.mockResolvedValue([]);
133
+ const store = new DirectoryHandleStore();
134
+ const result = await store.getAllLabels();
135
+ expect(result).toSucceedWith([]);
136
+ });
137
+ test('returns failure when keys throws', async () => {
138
+ mockKeys.mockRejectedValue(new Error('keys error'));
139
+ const store = new DirectoryHandleStore();
140
+ const result = await store.getAllLabels();
141
+ expect(result).toFailWith(/keys error/);
142
+ });
143
+ });
144
+ describe('getAll', () => {
145
+ test('returns all label/handle pairs', async () => {
146
+ const handleA = makeMockHandle('dir-a');
147
+ const handleB = makeMockHandle('dir-b');
148
+ mockKeys.mockResolvedValue(['dir-a', 'dir-b']);
149
+ mockGet.mockResolvedValueOnce(handleA).mockResolvedValueOnce(handleB);
150
+ const store = new DirectoryHandleStore();
151
+ const result = await store.getAll();
152
+ expect(result).toSucceedAndSatisfy((entries) => {
153
+ expect(entries).toHaveLength(2);
154
+ expect(entries[0]).toEqual({ label: 'dir-a', handle: handleA });
155
+ expect(entries[1]).toEqual({ label: 'dir-b', handle: handleB });
156
+ });
157
+ });
158
+ test('returns empty array when no handles stored', async () => {
159
+ mockKeys.mockResolvedValue([]);
160
+ const store = new DirectoryHandleStore();
161
+ const result = await store.getAll();
162
+ expect(result).toSucceedWith([]);
163
+ });
164
+ test('skips entries where handle is undefined', async () => {
165
+ const handleA = makeMockHandle('dir-a');
166
+ mockKeys.mockResolvedValue(['dir-a', 'dir-b']);
167
+ mockGet.mockResolvedValueOnce(handleA).mockResolvedValueOnce(undefined);
168
+ const store = new DirectoryHandleStore();
169
+ const result = await store.getAll();
170
+ expect(result).toSucceedAndSatisfy((entries) => {
171
+ expect(entries).toHaveLength(1);
172
+ expect(entries[0]).toEqual({ label: 'dir-a', handle: handleA });
173
+ });
174
+ });
175
+ test('returns failure when getAllLabels fails', async () => {
176
+ mockKeys.mockRejectedValue(new Error('keys error'));
177
+ const store = new DirectoryHandleStore();
178
+ const result = await store.getAll();
179
+ expect(result).toFailWith(/keys error/);
180
+ });
181
+ test('returns failure when load fails for a key', async () => {
182
+ mockKeys.mockResolvedValue(['dir-a']);
183
+ mockGet.mockRejectedValue(new Error('load error'));
184
+ const store = new DirectoryHandleStore();
185
+ const result = await store.getAll();
186
+ expect(result).toFailWith(/load error/);
187
+ });
188
+ });
189
+ });
190
+ //# sourceMappingURL=directoryHandleStore.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directoryHandleStore.test.js","sourceRoot":"","sources":["../../../src/test/unit/directoryHandleStore.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,8BAA8B,EAC/B,MAAM,+CAA+C,CAAC;AAGvD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACjC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACjC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACnC,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAEjD,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,IAAI;QACJ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C,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;YAClE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;YACzD,QAAQ,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;YACpD,MAAM,KAAK,GAAG,IAAI,oBAAoB,EAAE,CAAC;YAEzC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC;YAEpC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;YAC3D,QAAQ,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACtC,OAAO,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;YACnD,MAAM,KAAK,GAAG,IAAI,oBAAoB,EAAE,CAAC;YAEzC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC;YAEpC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","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 '@fgv/ts-utils-jest';\nimport {\n DirectoryHandleStore,\n DEFAULT_DIRECTORY_HANDLE_DB,\n DEFAULT_DIRECTORY_HANDLE_STORE\n} from '../../packlets/file-tree/directoryHandleStore';\nimport type { FileSystemDirectoryHandle } from '../../packlets/file-api-types';\n\nimport { get, set, del, keys, createStore } from 'idb-keyval';\n\nconst mockGet = jest.mocked(get);\nconst mockSet = jest.mocked(set);\nconst mockDel = jest.mocked(del);\nconst mockKeys = jest.mocked(keys);\nconst mockCreateStore = jest.mocked(createStore);\n\nfunction makeMockHandle(name: string): FileSystemDirectoryHandle {\n return {\n kind: 'directory',\n name,\n isSameEntry: jest.fn(),\n queryPermission: jest.fn(),\n requestPermission: jest.fn(),\n getDirectoryHandle: jest.fn(),\n getFileHandle: jest.fn(),\n removeEntry: jest.fn(),\n resolve: jest.fn(),\n keys: jest.fn(),\n values: jest.fn(),\n entries: jest.fn(),\n [Symbol.asyncIterator]: jest.fn()\n } as FileSystemDirectoryHandle;\n}\n\ndescribe('DirectoryHandleStore', () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n describe('constants', () => {\n test('DEFAULT_DIRECTORY_HANDLE_DB has expected value', () => {\n expect(DEFAULT_DIRECTORY_HANDLE_DB).toBe('chocolate-lab-storage');\n });\n\n test('DEFAULT_DIRECTORY_HANDLE_STORE has expected value', () => {\n expect(DEFAULT_DIRECTORY_HANDLE_STORE).toBe('directory-handles');\n });\n });\n\n describe('constructor', () => {\n test('uses default db and store names', () => {\n new DirectoryHandleStore();\n expect(mockCreateStore).toHaveBeenCalledWith(\n DEFAULT_DIRECTORY_HANDLE_DB,\n DEFAULT_DIRECTORY_HANDLE_STORE\n );\n });\n\n test('uses custom db and store names', () => {\n new DirectoryHandleStore('custom-db', 'custom-store');\n expect(mockCreateStore).toHaveBeenCalledWith('custom-db', 'custom-store');\n });\n });\n\n describe('save', () => {\n test('saves a handle successfully', async () => {\n mockSet.mockResolvedValue(undefined);\n const store = new DirectoryHandleStore();\n const handle = makeMockHandle('my-dir');\n\n const result = await store.save('my-dir', handle);\n\n expect(result).toSucceed();\n expect(mockSet).toHaveBeenCalledWith('my-dir', handle, expect.anything());\n });\n\n test('returns failure when set throws', async () => {\n mockSet.mockRejectedValue(new Error('IndexedDB unavailable'));\n const store = new DirectoryHandleStore();\n const handle = makeMockHandle('my-dir');\n\n const result = await store.save('my-dir', handle);\n\n expect(result).toFailWith(/IndexedDB unavailable/);\n });\n });\n\n describe('load', () => {\n test('returns the handle when found', async () => {\n const handle = makeMockHandle('my-dir');\n mockGet.mockResolvedValue(handle);\n const store = new DirectoryHandleStore();\n\n const result = await store.load('my-dir');\n\n expect(result).toSucceedWith(handle);\n expect(mockGet).toHaveBeenCalledWith('my-dir', expect.anything());\n });\n\n test('returns undefined when not found', async () => {\n mockGet.mockResolvedValue(undefined);\n const store = new DirectoryHandleStore();\n\n const result = await store.load('missing');\n\n expect(result).toSucceedWith(undefined);\n });\n\n test('returns failure when get throws', async () => {\n mockGet.mockRejectedValue(new Error('read error'));\n const store = new DirectoryHandleStore();\n\n const result = await store.load('my-dir');\n\n expect(result).toFailWith(/read error/);\n });\n });\n\n describe('remove', () => {\n test('removes a handle successfully', async () => {\n mockDel.mockResolvedValue(undefined);\n const store = new DirectoryHandleStore();\n\n const result = await store.remove('my-dir');\n\n expect(result).toSucceed();\n expect(mockDel).toHaveBeenCalledWith('my-dir', expect.anything());\n });\n\n test('returns failure when del throws', async () => {\n mockDel.mockRejectedValue(new Error('delete error'));\n const store = new DirectoryHandleStore();\n\n const result = await store.remove('my-dir');\n\n expect(result).toFailWith(/delete error/);\n });\n });\n\n describe('getAllLabels', () => {\n test('returns all keys', async () => {\n mockKeys.mockResolvedValue(['dir-a', 'dir-b']);\n const store = new DirectoryHandleStore();\n\n const result = await store.getAllLabels();\n\n expect(result).toSucceedWith(['dir-a', 'dir-b']);\n expect(mockKeys).toHaveBeenCalledWith(expect.anything());\n });\n\n test('returns empty array when no keys', async () => {\n mockKeys.mockResolvedValue([]);\n const store = new DirectoryHandleStore();\n\n const result = await store.getAllLabels();\n\n expect(result).toSucceedWith([]);\n });\n\n test('returns failure when keys throws', async () => {\n mockKeys.mockRejectedValue(new Error('keys error'));\n const store = new DirectoryHandleStore();\n\n const result = await store.getAllLabels();\n\n expect(result).toFailWith(/keys error/);\n });\n });\n\n describe('getAll', () => {\n test('returns all label/handle pairs', async () => {\n const handleA = makeMockHandle('dir-a');\n const handleB = makeMockHandle('dir-b');\n mockKeys.mockResolvedValue(['dir-a', 'dir-b']);\n mockGet.mockResolvedValueOnce(handleA).mockResolvedValueOnce(handleB);\n const store = new DirectoryHandleStore();\n\n const result = await store.getAll();\n\n expect(result).toSucceedAndSatisfy((entries) => {\n expect(entries).toHaveLength(2);\n expect(entries[0]).toEqual({ label: 'dir-a', handle: handleA });\n expect(entries[1]).toEqual({ label: 'dir-b', handle: handleB });\n });\n });\n\n test('returns empty array when no handles stored', async () => {\n mockKeys.mockResolvedValue([]);\n const store = new DirectoryHandleStore();\n\n const result = await store.getAll();\n\n expect(result).toSucceedWith([]);\n });\n\n test('skips entries where handle is undefined', async () => {\n const handleA = makeMockHandle('dir-a');\n mockKeys.mockResolvedValue(['dir-a', 'dir-b']);\n mockGet.mockResolvedValueOnce(handleA).mockResolvedValueOnce(undefined);\n const store = new DirectoryHandleStore();\n\n const result = await store.getAll();\n\n expect(result).toSucceedAndSatisfy((entries) => {\n expect(entries).toHaveLength(1);\n expect(entries[0]).toEqual({ label: 'dir-a', handle: handleA });\n });\n });\n\n test('returns failure when getAllLabels fails', async () => {\n mockKeys.mockRejectedValue(new Error('keys error'));\n const store = new DirectoryHandleStore();\n\n const result = await store.getAll();\n\n expect(result).toFailWith(/keys error/);\n });\n\n test('returns failure when load fails for a key', async () => {\n mockKeys.mockResolvedValue(['dir-a']);\n mockGet.mockRejectedValue(new Error('load error'));\n const store = new DirectoryHandleStore();\n\n const result = await store.getAll();\n\n expect(result).toFailWith(/load error/);\n });\n });\n});\n"]}
@@ -34,8 +34,30 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
34
34
  };
35
35
  import '@fgv/ts-utils-jest';
36
36
  import { FileApiTreeAccessors } from '../../packlets/file-tree';
37
+ import { FileTree } from '@fgv/ts-json-base';
37
38
  import { FileTreeHelpers } from '../../packlets/helpers';
38
39
  import { createMockFile, createMockFileList, createMockDirectoryFileList, verifyFileAPI } from '../utils/testHelpers';
40
+ function makeMockHttpResponse(options) {
41
+ const { ok, status = ok ? 200 : 400, jsonValue, textValue, throwOnJson } = options;
42
+ return {
43
+ ok,
44
+ status,
45
+ json: throwOnJson
46
+ ? () => Promise.reject(new Error('JSON parse error'))
47
+ : () => Promise.resolve(jsonValue),
48
+ text: () => Promise.resolve(textValue !== null && textValue !== void 0 ? textValue : `HTTP ${status}`)
49
+ };
50
+ }
51
+ function makeMockHttpFetch(responses) {
52
+ let callIndex = 0;
53
+ return (url, _init) => {
54
+ const response = responses[callIndex++];
55
+ if (response === undefined) {
56
+ return Promise.reject(new Error(`Unexpected fetch call to ${url.toString()}`));
57
+ }
58
+ return Promise.resolve(makeMockHttpResponse(response));
59
+ };
60
+ }
39
61
  describe('FileApiTreeAccessors', () => {
40
62
  describe('Static factory methods', () => {
41
63
  describe('create', () => {
@@ -1133,5 +1155,34 @@ describe('FileApiTreeAccessors', () => {
1133
1155
  });
1134
1156
  });
1135
1157
  });
1158
+ describe('createFromHttp', () => {
1159
+ test('succeeds and returns a FileTree when HTTP backend loads successfully', async () => {
1160
+ const fetchImpl = makeMockHttpFetch([
1161
+ {
1162
+ ok: true,
1163
+ jsonValue: { path: '/', children: [{ path: '/data.json', name: 'data.json', type: 'file' }] }
1164
+ },
1165
+ { ok: true, jsonValue: { path: '/data.json', contents: '{"items":{}}' } }
1166
+ ]);
1167
+ const result = await FileApiTreeAccessors.createFromHttp({
1168
+ baseUrl: 'http://localhost:3000',
1169
+ fetchImpl,
1170
+ mutable: true
1171
+ });
1172
+ expect(result).toSucceedAndSatisfy((tree) => {
1173
+ expect(tree).toBeInstanceOf(FileTree.FileTree);
1174
+ expect(tree.getFile('/data.json')).toSucceed();
1175
+ expect(FileTree.isPersistentAccessors(tree.hal)).toBe(true);
1176
+ });
1177
+ });
1178
+ test('fails when the HTTP backend returns an error during initial load', async () => {
1179
+ const fetchImpl = makeMockHttpFetch([{ ok: false, status: 503, textValue: 'Service Unavailable' }]);
1180
+ const result = await FileApiTreeAccessors.createFromHttp({
1181
+ baseUrl: 'http://localhost:3000',
1182
+ fetchImpl
1183
+ });
1184
+ expect(result).toFailWith(/service unavailable/i);
1185
+ });
1186
+ });
1136
1187
  });
1137
1188
  //# sourceMappingURL=fileApiTreeAccessors.test.js.map