@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,418 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
24
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
25
+ var m = o[Symbol.asyncIterator], i;
26
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
27
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
28
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.FileSystemAccessTreeAccessors = void 0;
32
+ const ts_utils_1 = require("@fgv/ts-utils");
33
+ const ts_json_base_1 = require("@fgv/ts-json-base");
34
+ /**
35
+ * Implementation of `FileTree.IPersistentFileTreeAccessors` that uses the File System Access API
36
+ * to provide persistent file editing in browsers.
37
+ * @public
38
+ */
39
+ class FileSystemAccessTreeAccessors extends ts_json_base_1.FileTree.InMemoryTreeAccessors {
40
+ /**
41
+ * Protected constructor for FileSystemAccessTreeAccessors.
42
+ * @param files - An array of in-memory files to include in the tree.
43
+ * @param rootDir - The root directory handle.
44
+ * @param handles - Map of file paths to their handles.
45
+ * @param params - Optional params for the tree.
46
+ * @param hasWritePermission - Whether write permission was granted.
47
+ */
48
+ constructor(files, rootDir, handles, params, hasWritePermission) {
49
+ var _a, _b;
50
+ super(files, params);
51
+ this._rootDir = rootDir;
52
+ this._handles = handles;
53
+ this._dirtyFiles = new Set();
54
+ this._pendingDeletions = new Set();
55
+ /* c8 ignore next 3 - intermittent branch coverage: ?? fallback branches in constructor */
56
+ this._autoSync = (_a = params === null || params === void 0 ? void 0 : params.autoSync) !== null && _a !== void 0 ? _a : false;
57
+ this._hasWritePermission = hasWritePermission;
58
+ this._logger = (_b = params === null || params === void 0 ? void 0 : params.logger) !== null && _b !== void 0 ? _b : new ts_utils_1.Logging.LogReporter();
59
+ }
60
+ async _runAutoSyncTask(path, operation, action) {
61
+ try {
62
+ const result = await action();
63
+ if (result.isFailure()) {
64
+ this._logger.error(`Auto-${operation} failed for ${path}: ${result.message}`);
65
+ }
66
+ }
67
+ catch (err) {
68
+ this._logger.error(`Auto-${operation} threw for ${path}: ${String(err)}`);
69
+ }
70
+ }
71
+ /**
72
+ * Creates a new FileSystemAccessTreeAccessors instance from a directory handle.
73
+ * @param dirHandle - The FileSystemDirectoryHandle to load files from.
74
+ * @param params - Optional parameters including autoSync and permission settings.
75
+ * @returns Promise resolving to a FileSystemAccessTreeAccessors instance.
76
+ * @public
77
+ */
78
+ static async fromDirectoryHandle(dirHandle, params) {
79
+ var _a, _b;
80
+ try {
81
+ // Check write permission
82
+ const hasWritePermission = await this._checkWritePermission(dirHandle);
83
+ /* c8 ignore next 3 - coverage intermittently missed in full suite */
84
+ if (!hasWritePermission && ((_a = params === null || params === void 0 ? void 0 : params.requireWritePermission) !== null && _a !== void 0 ? _a : true)) {
85
+ return (0, ts_utils_1.fail)('Write permission required but not granted');
86
+ }
87
+ // Load all files from the directory (always use '/' as base, prefix is handled by parent)
88
+ const { files, handles } = await this._loadDirectory(dirHandle, '/', params);
89
+ // Enable tree mutability when write permission is granted and caller didn't explicitly set mutable
90
+ const effectiveParams = Object.assign(Object.assign({}, params), { mutable: (_b = params === null || params === void 0 ? void 0 : params.mutable) !== null && _b !== void 0 ? _b : (hasWritePermission ? true : false) });
91
+ return (0, ts_utils_1.succeed)(new FileSystemAccessTreeAccessors(files, dirHandle, handles, effectiveParams, hasWritePermission));
92
+ /* c8 ignore next 4 - defensive: outer catch for unexpected errors */
93
+ }
94
+ catch (error) {
95
+ const message = error instanceof Error ? error.message : String(error);
96
+ return (0, ts_utils_1.fail)(`Failed to create FileSystemAccessTreeAccessors: ${message}`);
97
+ }
98
+ }
99
+ /**
100
+ * Creates a new FileSystemAccessTreeAccessors instance from a single file handle.
101
+ *
102
+ * The resulting tree contains exactly one file at `/<filename>`.
103
+ * `syncToDisk()` writes changes back to the original file via the File System Access API.
104
+ * New file creation is not supported on this tree (no parent directory handle).
105
+ *
106
+ * @param fileHandle - The FileSystemFileHandle to load.
107
+ * @param params - Optional parameters including autoSync and permission settings.
108
+ * @returns Promise resolving to a FileSystemAccessTreeAccessors instance.
109
+ * @public
110
+ */
111
+ static async fromFileHandle(fileHandle, params) {
112
+ var _a, _b, _c;
113
+ try {
114
+ const hasWritePermission = await this._checkFileWritePermission(fileHandle);
115
+ /* c8 ignore next 1 - intermittent branch coverage: ?? true fallback */
116
+ if (!hasWritePermission && ((_a = params === null || params === void 0 ? void 0 : params.requireWritePermission) !== null && _a !== void 0 ? _a : true)) {
117
+ return (0, ts_utils_1.fail)('Write permission required but not granted');
118
+ }
119
+ const file = await fileHandle.getFile();
120
+ const contents = await file.text();
121
+ const path = (_b = params === null || params === void 0 ? void 0 : params.filePath) !== null && _b !== void 0 ? _b : `/${fileHandle.name}`;
122
+ /* c8 ignore next 3 - intermittent branch coverage: ternary for inferContentType */
123
+ const contentType = (params === null || params === void 0 ? void 0 : params.inferContentType)
124
+ ? params.inferContentType(path, file.type).orDefault()
125
+ : undefined;
126
+ const files = [{ path, contents, contentType }];
127
+ const handles = new Map([[path, fileHandle]]);
128
+ const dummyRoot = {};
129
+ const effectiveParams = Object.assign(Object.assign({}, params), {
130
+ /* c8 ignore next 1 - intermittent branch coverage: ?? false fallback */
131
+ mutable: hasWritePermission ? true : (_c = params === null || params === void 0 ? void 0 : params.mutable) !== null && _c !== void 0 ? _c : false });
132
+ return (0, ts_utils_1.succeed)(new FileSystemAccessTreeAccessors(files, dummyRoot, handles, effectiveParams, hasWritePermission));
133
+ }
134
+ catch (error) {
135
+ /* c8 ignore next 1 - intermittent branch coverage: error instanceof Error false branch */
136
+ const message = error instanceof Error ? error.message : String(error);
137
+ return (0, ts_utils_1.fail)(`Failed to create FileSystemAccessTreeAccessors from file: ${message}`);
138
+ }
139
+ }
140
+ /**
141
+ * Check if the directory handle has write permission.
142
+ * @param handle - The directory handle to check.
143
+ * @returns Promise resolving to true if write permission is granted.
144
+ * @internal
145
+ */
146
+ static async _checkWritePermission(handle) {
147
+ try {
148
+ const permission = await handle.queryPermission({ mode: 'readwrite' });
149
+ if (permission === 'granted') {
150
+ return true;
151
+ }
152
+ if (permission === 'prompt') {
153
+ const requested = await handle.requestPermission({ mode: 'readwrite' });
154
+ return requested === 'granted';
155
+ }
156
+ return false;
157
+ }
158
+ catch (error) {
159
+ // Permission API might not be available or might throw
160
+ return false;
161
+ }
162
+ }
163
+ /**
164
+ * Check if the file handle has write permission.
165
+ * @param handle - The file handle to check.
166
+ * @returns Promise resolving to true if write permission is granted.
167
+ * @internal
168
+ */
169
+ static async _checkFileWritePermission(handle) {
170
+ try {
171
+ const permission = await handle.queryPermission({ mode: 'readwrite' });
172
+ if (permission === 'granted') {
173
+ return true;
174
+ }
175
+ if (permission === 'prompt') {
176
+ const requested = await handle.requestPermission({ mode: 'readwrite' });
177
+ return requested === 'granted';
178
+ }
179
+ return false;
180
+ }
181
+ catch (error) {
182
+ return false;
183
+ }
184
+ }
185
+ /**
186
+ * Load all files from a directory handle recursively.
187
+ * @param dirHandle - The directory handle to load from.
188
+ * @param basePath - The base path for files.
189
+ * @param params - Optional parameters.
190
+ * @returns Promise resolving to files and handles.
191
+ * @internal
192
+ */
193
+ static async _loadDirectory(dirHandle, basePath, params) {
194
+ var _a, e_1, _b, _c;
195
+ const files = [];
196
+ const handles = new Map();
197
+ try {
198
+ for (var _d = true, _e = __asyncValues(dirHandle.entries()), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
199
+ _c = _f.value;
200
+ _d = false;
201
+ const [name, handle] = _c;
202
+ if (handle.kind === 'file') {
203
+ const fileHandle = handle;
204
+ const file = await fileHandle.getFile();
205
+ const contents = await file.text();
206
+ const path = this._joinPath(basePath, name);
207
+ /* c8 ignore next 2 - coverage intermittently missed in full suite */
208
+ const contentType = (params === null || params === void 0 ? void 0 : params.inferContentType)
209
+ ? params.inferContentType(path, file.type).orDefault()
210
+ : undefined;
211
+ files.push({ path, contents, contentType });
212
+ handles.set(path, fileHandle);
213
+ }
214
+ else if (handle.kind === 'directory') {
215
+ const subDirHandle = handle;
216
+ const subPath = this._joinPath(basePath, name);
217
+ const subResult = await this._loadDirectory(subDirHandle, subPath, params);
218
+ files.push(...subResult.files);
219
+ for (const [path, fileHandle] of subResult.handles) {
220
+ handles.set(path, fileHandle);
221
+ }
222
+ }
223
+ }
224
+ }
225
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
226
+ finally {
227
+ try {
228
+ if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
229
+ }
230
+ finally { if (e_1) throw e_1.error; }
231
+ }
232
+ return { files, handles };
233
+ }
234
+ /**
235
+ * Join path segments.
236
+ * @param base - The base path.
237
+ * @param name - The name to append.
238
+ * @returns The joined path.
239
+ * @internal
240
+ */
241
+ static _joinPath(base, name) {
242
+ const normalized = base.endsWith('/') ? base.slice(0, -1) : base;
243
+ return `${normalized}/${name}`;
244
+ }
245
+ /**
246
+ * Implements `FileTree.IPersistentFileTreeAccessors.syncToDisk`
247
+ */
248
+ async syncToDisk() {
249
+ if (!this._hasWritePermission) {
250
+ return (0, ts_utils_1.fail)('Write permission not granted - cannot sync to disk');
251
+ }
252
+ const errors = [];
253
+ // Process pending deletions from disk
254
+ for (const path of this._pendingDeletions) {
255
+ const deleteResult = await this._deleteFileFromDisk(path);
256
+ if (deleteResult.isFailure()) {
257
+ errors.push(`delete ${path}: ${deleteResult.message}`);
258
+ }
259
+ }
260
+ for (const path of this._dirtyFiles) {
261
+ const syncResult = await this._syncFile(path);
262
+ if (syncResult.isFailure()) {
263
+ errors.push(`${path}: ${syncResult.message}`);
264
+ }
265
+ }
266
+ if (errors.length > 0) {
267
+ return (0, ts_utils_1.fail)(`Failed to sync ${errors.length} file(s):\n${errors.join('\n')}`);
268
+ }
269
+ this._pendingDeletions.clear();
270
+ this._dirtyFiles.clear();
271
+ return (0, ts_utils_1.succeed)(undefined);
272
+ }
273
+ /**
274
+ * Implements `FileTree.IPersistentFileTreeAccessors.isDirty`
275
+ */
276
+ isDirty() {
277
+ return this._dirtyFiles.size > 0 || this._pendingDeletions.size > 0;
278
+ }
279
+ /**
280
+ * Implements `FileTree.IPersistentFileTreeAccessors.getDirtyPaths`
281
+ */
282
+ getDirtyPaths() {
283
+ return [...Array.from(this._dirtyFiles), ...Array.from(this._pendingDeletions)];
284
+ }
285
+ /**
286
+ * Override deleteFile to track pending deletions for syncToDisk.
287
+ */
288
+ deleteFile(path) {
289
+ const result = super.deleteFile(path);
290
+ if (result.isSuccess()) {
291
+ this._dirtyFiles.delete(path);
292
+ this._handles.delete(path);
293
+ if (this._hasWritePermission) {
294
+ this._pendingDeletions.add(path);
295
+ if (this._autoSync) {
296
+ void this._runAutoSyncTask(path, 'delete', () => this._deleteFileFromDisk(path));
297
+ }
298
+ }
299
+ }
300
+ return result;
301
+ }
302
+ /**
303
+ * Implements `FileTree.IMutableFileTreeAccessors.saveFileContents`
304
+ */
305
+ saveFileContents(path, contents) {
306
+ // Call parent to update in-memory state
307
+ const result = super.saveFileContents(path, contents);
308
+ if (result.isSuccess() && this._hasWritePermission) {
309
+ this._dirtyFiles.add(path);
310
+ // Auto-sync if enabled
311
+ if (this._autoSync) {
312
+ // Fire and log-on-failure; don't block the save path.
313
+ void this._runAutoSyncTask(path, 'save', () => this._syncFile(path));
314
+ }
315
+ }
316
+ return result;
317
+ }
318
+ /**
319
+ * Implements `FileTree.IMutableFileTreeAccessors.fileIsMutable`
320
+ */
321
+ fileIsMutable(path) {
322
+ const baseResult = super.fileIsMutable(path);
323
+ if (baseResult.isSuccess() && baseResult.detail === 'transient' && this._hasWritePermission) {
324
+ // Upgrade to 'persistent' if we have write permission
325
+ return (0, ts_utils_1.succeedWithDetail)(true, 'persistent');
326
+ }
327
+ return baseResult;
328
+ }
329
+ /**
330
+ * Sync a single file to disk.
331
+ * @param path - The path of the file to sync.
332
+ * @returns Promise resolving to success or failure.
333
+ * @internal
334
+ */
335
+ async _syncFile(path) {
336
+ const handle = this._handles.get(path);
337
+ if (!handle) {
338
+ return this._createAndWriteFile(path);
339
+ }
340
+ const contents = this.getFileContents(path);
341
+ if (contents.isFailure()) {
342
+ return (0, ts_utils_1.fail)(contents.message);
343
+ }
344
+ try {
345
+ const writable = await handle.createWritable();
346
+ await writable.write(contents.value);
347
+ await writable.close();
348
+ return (0, ts_utils_1.succeed)(undefined);
349
+ /* c8 ignore next 4 - coverage intermittently missed in full suite */
350
+ }
351
+ catch (error) {
352
+ const message = error instanceof Error ? error.message : String(error);
353
+ return (0, ts_utils_1.fail)(`Failed to write file: ${message}`);
354
+ }
355
+ }
356
+ /**
357
+ * Delete a file from disk using the File System Access API.
358
+ * @param path - The path of the file to delete.
359
+ * @returns Promise resolving to success or failure.
360
+ * @internal
361
+ */
362
+ async _deleteFileFromDisk(path) {
363
+ try {
364
+ const absolutePath = this.resolveAbsolutePath(path);
365
+ const parts = absolutePath.split('/').filter((p) => p.length > 0);
366
+ const filename = parts.pop();
367
+ /* c8 ignore next 3 - defensive: invalid path */
368
+ if (!filename) {
369
+ return (0, ts_utils_1.fail)(`Invalid file path: ${path}`);
370
+ }
371
+ // Navigate to the parent directory
372
+ let currentDir = this._rootDir;
373
+ for (const part of parts) {
374
+ currentDir = await currentDir.getDirectoryHandle(part);
375
+ }
376
+ await currentDir.removeEntry(filename);
377
+ return (0, ts_utils_1.succeed)(undefined);
378
+ }
379
+ catch (error) {
380
+ const message = error instanceof Error ? error.message : String(error);
381
+ return (0, ts_utils_1.fail)(`Failed to delete file ${path}: ${message}`);
382
+ }
383
+ }
384
+ /**
385
+ * Create a new file and write its contents.
386
+ * @param path - The path of the file to create.
387
+ * @returns Promise resolving to success or failure.
388
+ * @internal
389
+ */
390
+ async _createAndWriteFile(path) {
391
+ try {
392
+ // Parse path to get directory and filename
393
+ const absolutePath = this.resolveAbsolutePath(path);
394
+ const parts = absolutePath.split('/').filter((p) => p.length > 0);
395
+ const filename = parts.pop();
396
+ /* c8 ignore next 3 - coverage intermittently missed in full suite */
397
+ if (!filename) {
398
+ return (0, ts_utils_1.fail)(`Invalid file path: ${path}`);
399
+ }
400
+ // Navigate/create directory structure
401
+ let currentDir = this._rootDir;
402
+ for (const part of parts) {
403
+ currentDir = await currentDir.getDirectoryHandle(part, { create: true });
404
+ }
405
+ // Create file and write contents
406
+ const fileHandle = await currentDir.getFileHandle(filename, { create: true });
407
+ this._handles.set(path, fileHandle);
408
+ return this._syncFile(path);
409
+ /* c8 ignore next 4 - coverage intermittently missed in full suite */
410
+ }
411
+ catch (error) {
412
+ const message = error instanceof Error ? error.message : String(error);
413
+ return (0, ts_utils_1.fail)(`Failed to create file ${path}: ${message}`);
414
+ }
415
+ }
416
+ }
417
+ exports.FileSystemAccessTreeAccessors = FileSystemAccessTreeAccessors;
418
+ //# sourceMappingURL=fileSystemAccessTreeAccessors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSystemAccessTreeAccessors.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileSystemAccessTreeAccessors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;AAEH,4CAQuB;AACvB,oDAA6C;AAmC7C;;;;GAIG;AACH,MAAa,6BACX,SAAQ,uBAAQ,CAAC,qBAA0B;IAW3C;;;;;;;OAOG;IACH,YACE,KAAoC,EACpC,OAAkC,EAClC,OAA0C,EAC1C,MAAoD,EACpD,kBAA2B;;QAE3B,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAA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AAE,CAAC,CAAC;YAC3E,CAAC;YAED,iCAAiC;YACjC,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAEpC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAC5B,qEAAqE;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,IAAA,eAAI,EAAC,yBAAyB,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF;AA/bD,sEA+bC","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 {\n Result,\n succeed,\n fail,\n captureResult,\n DetailedResult,\n succeedWithDetail,\n Logging\n} from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport { FileSystemDirectoryHandle, FileSystemFileHandle } from '../file-api-types';\n\n/**\n * Options for creating persistent file trees.\n * @public\n */\nexport interface IFileSystemAccessTreeParams<TCT extends string = string>\n extends FileTree.IFileTreeInitParams<TCT> {\n /**\n * Automatically sync changes to disk immediately after each save.\n * If false, changes are batched and written on explicit syncToDisk() call.\n * @defaultValue false\n */\n autoSync?: boolean;\n\n /**\n * Require write permission on the directory handle.\n * If true, fails if write permission cannot be obtained.\n * If false, falls back to read-only mode.\n * @defaultValue true\n */\n requireWritePermission?: boolean;\n\n /**\n * Override the path at which the file is stored in the tree (for fromFileHandle).\n * Must be an absolute path (e.g., '/data/confections/common.yaml').\n * If omitted, defaults to `/<filename>`.\n */\n filePath?: string;\n\n /** Optional logger for auto-sync and persistence failures. */\n logger?: Logging.LogReporter<unknown>;\n}\n\n/**\n * Implementation of `FileTree.IPersistentFileTreeAccessors` that uses the File System Access API\n * to provide persistent file editing in browsers.\n * @public\n */\nexport class FileSystemAccessTreeAccessors<TCT extends string = string>\n extends FileTree.InMemoryTreeAccessors<TCT>\n implements FileTree.IPersistentFileTreeAccessors<TCT>\n{\n private readonly _handles: Map<string, FileSystemFileHandle>;\n private readonly _rootDir: FileSystemDirectoryHandle;\n private readonly _dirtyFiles: Set<string>;\n private readonly _pendingDeletions: Set<string>;\n private readonly _autoSync: boolean;\n private readonly _hasWritePermission: boolean;\n private readonly _logger: Logging.LogReporter<unknown>;\n\n /**\n * Protected constructor for FileSystemAccessTreeAccessors.\n * @param files - An array of in-memory files to include in the tree.\n * @param rootDir - The root directory handle.\n * @param handles - Map of file paths to their handles.\n * @param params - Optional params for the tree.\n * @param hasWritePermission - Whether write permission was granted.\n */\n protected constructor(\n files: FileTree.IInMemoryFile<TCT>[],\n rootDir: FileSystemDirectoryHandle,\n handles: Map<string, FileSystemFileHandle>,\n params: IFileSystemAccessTreeParams<TCT> | undefined,\n hasWritePermission: boolean\n ) {\n super(files, params);\n this._rootDir = rootDir;\n this._handles = handles;\n this._dirtyFiles = new Set();\n this._pendingDeletions = new Set();\n /* c8 ignore next 3 - intermittent branch coverage: ?? fallback branches in constructor */\n this._autoSync = params?.autoSync ?? false;\n this._hasWritePermission = hasWritePermission;\n this._logger = params?.logger ?? new Logging.LogReporter<unknown>();\n }\n\n private async _runAutoSyncTask(\n path: string,\n operation: 'save' | 'delete',\n action: () => Promise<Result<void>>\n ): Promise<void> {\n try {\n const result = await action();\n if (result.isFailure()) {\n this._logger.error(`Auto-${operation} failed for ${path}: ${result.message}`);\n }\n } catch (err) {\n this._logger.error(`Auto-${operation} threw for ${path}: ${String(err)}`);\n }\n }\n\n /**\n * Creates a new FileSystemAccessTreeAccessors instance from a directory handle.\n * @param dirHandle - The FileSystemDirectoryHandle to load files from.\n * @param params - Optional parameters including autoSync and permission settings.\n * @returns Promise resolving to a FileSystemAccessTreeAccessors instance.\n * @public\n */\n public static async fromDirectoryHandle<TCT extends string = string>(\n dirHandle: FileSystemDirectoryHandle,\n params?: IFileSystemAccessTreeParams<TCT>\n ): Promise<Result<FileSystemAccessTreeAccessors<TCT>>> {\n try {\n // Check write permission\n const hasWritePermission = await this._checkWritePermission(dirHandle);\n\n /* c8 ignore next 3 - coverage intermittently missed in full suite */\n if (!hasWritePermission && (params?.requireWritePermission ?? true)) {\n return fail('Write permission required but not granted');\n }\n\n // Load all files from the directory (always use '/' as base, prefix is handled by parent)\n const { files, handles } = await this._loadDirectory<TCT>(dirHandle, '/', params);\n\n // Enable tree mutability when write permission is granted and caller didn't explicitly set mutable\n const effectiveParams: IFileSystemAccessTreeParams<TCT> = {\n ...params,\n mutable: params?.mutable ?? (hasWritePermission ? true : false)\n };\n\n return succeed(\n new FileSystemAccessTreeAccessors<TCT>(files, dirHandle, handles, effectiveParams, hasWritePermission)\n );\n /* c8 ignore next 4 - defensive: outer catch for unexpected errors */\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return fail(`Failed to create FileSystemAccessTreeAccessors: ${message}`);\n }\n }\n\n /**\n * Creates a new FileSystemAccessTreeAccessors instance from a single file handle.\n *\n * The resulting tree contains exactly one file at `/<filename>`.\n * `syncToDisk()` writes changes back to the original file via the File System Access API.\n * New file creation is not supported on this tree (no parent directory handle).\n *\n * @param fileHandle - The FileSystemFileHandle to load.\n * @param params - Optional parameters including autoSync and permission settings.\n * @returns Promise resolving to a FileSystemAccessTreeAccessors instance.\n * @public\n */\n public static async fromFileHandle<TCT extends string = string>(\n fileHandle: FileSystemFileHandle,\n params?: IFileSystemAccessTreeParams<TCT>\n ): Promise<Result<FileSystemAccessTreeAccessors<TCT>>> {\n try {\n const hasWritePermission = await this._checkFileWritePermission(fileHandle);\n\n /* c8 ignore next 1 - intermittent branch coverage: ?? true fallback */\n if (!hasWritePermission && (params?.requireWritePermission ?? true)) {\n return fail('Write permission required but not granted');\n }\n\n const file = await fileHandle.getFile();\n const contents = await file.text();\n const path = params?.filePath ?? `/${fileHandle.name}`;\n /* c8 ignore next 3 - intermittent branch coverage: ternary for inferContentType */\n const contentType = params?.inferContentType\n ? params.inferContentType(path, file.type).orDefault()\n : undefined;\n\n const files: FileTree.IInMemoryFile<TCT>[] = [{ path, contents, contentType }];\n const handles = new Map<string, FileSystemFileHandle>([[path, fileHandle]]);\n\n const dummyRoot = {} as FileSystemDirectoryHandle;\n const effectiveParams: IFileSystemAccessTreeParams<TCT> = {\n ...params,\n /* c8 ignore next 1 - intermittent branch coverage: ?? false fallback */\n mutable: hasWritePermission ? true : params?.mutable ?? false\n };\n\n return succeed(\n new FileSystemAccessTreeAccessors<TCT>(files, dummyRoot, handles, effectiveParams, hasWritePermission)\n );\n } catch (error) {\n /* c8 ignore next 1 - intermittent branch coverage: error instanceof Error false branch */\n const message = error instanceof Error ? error.message : String(error);\n return fail(`Failed to create FileSystemAccessTreeAccessors from file: ${message}`);\n }\n }\n\n /**\n * Check if the directory handle has write permission.\n * @param handle - The directory handle to check.\n * @returns Promise resolving to true if write permission is granted.\n * @internal\n */\n private static async _checkWritePermission(handle: FileSystemDirectoryHandle): Promise<boolean> {\n try {\n const permission = await handle.queryPermission({ mode: 'readwrite' });\n\n if (permission === 'granted') {\n return true;\n }\n\n if (permission === 'prompt') {\n const requested = await handle.requestPermission({ mode: 'readwrite' });\n return requested === 'granted';\n }\n\n return false;\n } catch (error) {\n // Permission API might not be available or might throw\n return false;\n }\n }\n\n /**\n * Check if the file handle has write permission.\n * @param handle - The file handle to check.\n * @returns Promise resolving to true if write permission is granted.\n * @internal\n */\n private static async _checkFileWritePermission(handle: FileSystemFileHandle): Promise<boolean> {\n try {\n const permission = await handle.queryPermission({ mode: 'readwrite' });\n\n if (permission === 'granted') {\n return true;\n }\n\n if (permission === 'prompt') {\n const requested = await handle.requestPermission({ mode: 'readwrite' });\n return requested === 'granted';\n }\n\n return false;\n } catch (error) {\n return false;\n }\n }\n\n /**\n * Load all files from a directory handle recursively.\n * @param dirHandle - The directory handle to load from.\n * @param basePath - The base path for files.\n * @param params - Optional parameters.\n * @returns Promise resolving to files and handles.\n * @internal\n */\n private static async _loadDirectory<TCT extends string = string>(\n dirHandle: FileSystemDirectoryHandle,\n basePath: string,\n params?: IFileSystemAccessTreeParams<TCT>\n ): Promise<{ files: FileTree.IInMemoryFile<TCT>[]; handles: Map<string, FileSystemFileHandle> }> {\n const files: FileTree.IInMemoryFile<TCT>[] = [];\n const handles = new Map<string, FileSystemFileHandle>();\n\n for await (const [name, handle] of dirHandle.entries()) {\n if (handle.kind === 'file') {\n const fileHandle = handle as FileSystemFileHandle;\n const file = await fileHandle.getFile();\n const contents = await file.text();\n const path = this._joinPath(basePath, name);\n /* c8 ignore next 2 - coverage intermittently missed in full suite */\n const contentType = params?.inferContentType\n ? params.inferContentType(path, file.type).orDefault()\n : undefined;\n\n files.push({ path, contents, contentType });\n handles.set(path, fileHandle);\n } else if (handle.kind === 'directory') {\n const subDirHandle = handle as FileSystemDirectoryHandle;\n const subPath = this._joinPath(basePath, name);\n const subResult = await this._loadDirectory<TCT>(subDirHandle, subPath, params);\n files.push(...subResult.files);\n for (const [path, fileHandle] of subResult.handles) {\n handles.set(path, fileHandle);\n }\n }\n }\n\n return { files, handles };\n }\n\n /**\n * Join path segments.\n * @param base - The base path.\n * @param name - The name to append.\n * @returns The joined path.\n * @internal\n */\n private static _joinPath(base: string, name: string): string {\n const normalized = base.endsWith('/') ? base.slice(0, -1) : base;\n return `${normalized}/${name}`;\n }\n\n /**\n * Implements `FileTree.IPersistentFileTreeAccessors.syncToDisk`\n */\n public async syncToDisk(): Promise<Result<void>> {\n if (!this._hasWritePermission) {\n return fail('Write permission not granted - cannot sync to disk');\n }\n\n const errors: string[] = [];\n\n // Process pending deletions from disk\n for (const path of this._pendingDeletions) {\n const deleteResult = await this._deleteFileFromDisk(path);\n if (deleteResult.isFailure()) {\n errors.push(`delete ${path}: ${deleteResult.message}`);\n }\n }\n\n for (const path of this._dirtyFiles) {\n const syncResult = await this._syncFile(path);\n if (syncResult.isFailure()) {\n errors.push(`${path}: ${syncResult.message}`);\n }\n }\n\n if (errors.length > 0) {\n return fail(`Failed to sync ${errors.length} file(s):\\n${errors.join('\\n')}`);\n }\n\n this._pendingDeletions.clear();\n this._dirtyFiles.clear();\n return succeed(undefined);\n }\n\n /**\n * Implements `FileTree.IPersistentFileTreeAccessors.isDirty`\n */\n public isDirty(): boolean {\n return this._dirtyFiles.size > 0 || this._pendingDeletions.size > 0;\n }\n\n /**\n * Implements `FileTree.IPersistentFileTreeAccessors.getDirtyPaths`\n */\n public getDirtyPaths(): string[] {\n return [...Array.from(this._dirtyFiles), ...Array.from(this._pendingDeletions)];\n }\n\n /**\n * Override deleteFile to track pending deletions for syncToDisk.\n */\n public deleteFile(path: string): Result<boolean> {\n const result = super.deleteFile(path);\n if (result.isSuccess()) {\n this._dirtyFiles.delete(path);\n this._handles.delete(path);\n\n if (this._hasWritePermission) {\n this._pendingDeletions.add(path);\n\n if (this._autoSync) {\n void this._runAutoSyncTask(path, 'delete', () => this._deleteFileFromDisk(path));\n }\n }\n }\n return result;\n }\n\n /**\n * Implements `FileTree.IMutableFileTreeAccessors.saveFileContents`\n */\n public saveFileContents(path: string, contents: string): Result<string> {\n // Call parent to update in-memory state\n const result = super.saveFileContents(path, contents);\n\n if (result.isSuccess() && this._hasWritePermission) {\n this._dirtyFiles.add(path);\n\n // Auto-sync if enabled\n if (this._autoSync) {\n // Fire and log-on-failure; don't block the save path.\n void this._runAutoSyncTask(path, 'save', () => this._syncFile(path));\n }\n }\n\n return result;\n }\n\n /**\n * Implements `FileTree.IMutableFileTreeAccessors.fileIsMutable`\n */\n public fileIsMutable(path: string): DetailedResult<boolean, FileTree.SaveDetail> {\n const baseResult = super.fileIsMutable(path);\n\n if (baseResult.isSuccess() && baseResult.detail === 'transient' && this._hasWritePermission) {\n // Upgrade to 'persistent' if we have write permission\n return succeedWithDetail(true, 'persistent');\n }\n\n return baseResult;\n }\n\n /**\n * Sync a single file to disk.\n * @param path - The path of the file to sync.\n * @returns Promise resolving to success or failure.\n * @internal\n */\n private async _syncFile(path: string): Promise<Result<void>> {\n const handle = this._handles.get(path);\n if (!handle) {\n return this._createAndWriteFile(path);\n }\n\n const contents = this.getFileContents(path);\n if (contents.isFailure()) {\n return fail(contents.message);\n }\n\n try {\n const writable = await handle.createWritable();\n await writable.write(contents.value);\n await writable.close();\n return succeed(undefined);\n /* c8 ignore next 4 - coverage intermittently missed in full suite */\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return fail(`Failed to write file: ${message}`);\n }\n }\n\n /**\n * Delete a file from disk using the File System Access API.\n * @param path - The path of the file to delete.\n * @returns Promise resolving to success or failure.\n * @internal\n */\n private async _deleteFileFromDisk(path: string): Promise<Result<void>> {\n try {\n const absolutePath = this.resolveAbsolutePath(path);\n const parts = absolutePath.split('/').filter((p) => p.length > 0);\n const filename = parts.pop();\n\n /* c8 ignore next 3 - defensive: invalid path */\n if (!filename) {\n return fail(`Invalid file path: ${path}`);\n }\n\n // Navigate to the parent directory\n let currentDir = this._rootDir;\n for (const part of parts) {\n currentDir = await currentDir.getDirectoryHandle(part);\n }\n\n await currentDir.removeEntry(filename);\n return succeed(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return fail(`Failed to delete file ${path}: ${message}`);\n }\n }\n\n /**\n * Create a new file and write its contents.\n * @param path - The path of the file to create.\n * @returns Promise resolving to success or failure.\n * @internal\n */\n private async _createAndWriteFile(path: string): Promise<Result<void>> {\n try {\n // Parse path to get directory and filename\n const absolutePath = this.resolveAbsolutePath(path);\n const parts = absolutePath.split('/').filter((p) => p.length > 0);\n const filename = parts.pop();\n\n /* c8 ignore next 3 - coverage intermittently missed in full suite */\n if (!filename) {\n return fail(`Invalid file path: ${path}`);\n }\n\n // Navigate/create directory structure\n let currentDir = this._rootDir;\n for (const part of parts) {\n currentDir = await currentDir.getDirectoryHandle(part, { create: true });\n }\n\n // Create file and write contents\n const fileHandle = await currentDir.getFileHandle(filename, { create: true });\n this._handles.set(path, fileHandle);\n\n return this._syncFile(path);\n /* c8 ignore next 4 - coverage intermittently missed in full suite */\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return fail(`Failed to create file ${path}: ${message}`);\n }\n }\n}\n"]}
@@ -0,0 +1,88 @@
1
+ import { DetailedResult, type Result, Logging } from '@fgv/ts-utils';
2
+ import { FileTree } from '@fgv/ts-json-base';
3
+ /**
4
+ * Configuration for creating HTTP-backed tree accessors.
5
+ * @public
6
+ */
7
+ export interface IHttpTreeParams<TCT extends string = string> extends FileTree.IFileTreeInitParams<TCT> {
8
+ readonly baseUrl: string;
9
+ readonly namespace?: string;
10
+ readonly autoSync?: boolean;
11
+ readonly fetchImpl?: typeof fetch;
12
+ readonly userId?: string;
13
+ readonly logger?: Logging.LogReporter<unknown>;
14
+ }
15
+ /**
16
+ * HTTP-backed file tree accessors that cache data in memory and persist via REST API.
17
+ * @public
18
+ */
19
+ export declare class HttpTreeAccessors<TCT extends string = string> extends FileTree.InMemoryTreeAccessors<TCT> implements FileTree.IPersistentFileTreeAccessors<TCT> {
20
+ private readonly _baseUrl;
21
+ private readonly _namespace;
22
+ private readonly _fetchImpl;
23
+ private readonly _dirtyFiles;
24
+ private readonly _pendingDeletions;
25
+ private readonly _autoSync;
26
+ private readonly _userId;
27
+ private readonly _logger;
28
+ private constructor();
29
+ private _runAutoSyncTask;
30
+ /**
31
+ * Creates a new HttpTreeAccessors instance from an HTTP backend.
32
+ * @param params - Configuration parameters for the HTTP tree accessors.
33
+ * @returns A promise that resolves to a result containing the new HttpTreeAccessors instance or an error message.
34
+ */
35
+ static fromHttp<TCT extends string = string>(params: IHttpTreeParams<TCT>): Promise<Result<HttpTreeAccessors<TCT>>>;
36
+ /**
37
+ * Synchronizes all dirty files to the HTTP backend.
38
+ * @returns A promise that resolves to a result indicating success or failure.
39
+ */
40
+ syncToDisk(): Promise<Result<void>>;
41
+ /**
42
+ * Checks if there are any dirty files that need synchronization.
43
+ * @returns True if there are dirty files, false otherwise.
44
+ */
45
+ isDirty(): boolean;
46
+ /**
47
+ * Gets the list of paths for all dirty files.
48
+ * @returns An array of file paths that have been modified but not yet synchronized.
49
+ */
50
+ getDirtyPaths(): string[];
51
+ deleteFile(path: string): Result<boolean>;
52
+ /**
53
+ * Saves file contents and marks the file as dirty for synchronization.
54
+ * @param path - The path to the file.
55
+ * @param contents - The new contents of the file.
56
+ * @returns A result indicating success or failure.
57
+ */
58
+ saveFileContents(path: string, contents: string): Result<string>;
59
+ /**
60
+ * Checks if a file is mutable (can be modified).
61
+ * @param path - The path to the file.
62
+ * @returns A detailed result indicating if the file is mutable and the reason.
63
+ */
64
+ fileIsMutable(path: string): DetailedResult<boolean, FileTree.SaveDetail>;
65
+ /**
66
+ * Makes an HTTP request to the specified resource path.
67
+ * @param resourcePath - The path to the resource.
68
+ * @param init - Optional request initialization options.
69
+ * @returns A promise that resolves to a result containing the response data or an error message.
70
+ */
71
+ private _request;
72
+ /**
73
+ * Loads files from the HTTP backend for the specified directory path.
74
+ * @param params - Configuration parameters for the HTTP tree accessors.
75
+ * @param directoryPath - The path to the directory to load files from.
76
+ * @returns A promise that resolves to a result containing the loaded files or an error message.
77
+ */
78
+ private static _loadFiles;
79
+ /**
80
+ * Makes an HTTP request with query parameters to the specified resource path.
81
+ * @param params - Configuration parameters for the HTTP tree accessors.
82
+ * @param resourcePath - The path to the resource.
83
+ * @param query - Query parameters to include in the request.
84
+ * @returns A promise that resolves to a result containing the response data or an error message.
85
+ */
86
+ private static _requestWithParams;
87
+ }
88
+ //# sourceMappingURL=httpTreeAccessors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpTreeAccessors.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/httpTreeAccessors.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAQ,KAAK,MAAM,EAA8B,OAAO,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AA4B7C;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,QAAQ,CAAC,mBAAmB,CAAC,GAAG,CAAC;IACrG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;CAChD;AAED;;;GAGG;AACH,qBAAa,iBAAiB,CAAC,GAAG,SAAS,MAA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