@fgv/ts-web-extras 5.0.0

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 (262) hide show
  1. package/.rush/temp/86c9c1ad46e237e0b957c2442bf0355cf39babba.tar.log +121 -0
  2. package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +40 -0
  3. package/.rush/temp/operation/build/all.log +40 -0
  4. package/.rush/temp/operation/build/log-chunks.jsonl +40 -0
  5. package/.rush/temp/operation/build/state.json +3 -0
  6. package/.rush/temp/shrinkwrap-deps.json +624 -0
  7. package/config/api-extractor.json +343 -0
  8. package/config/jest.config.json +16 -0
  9. package/config/rig.json +16 -0
  10. package/dist/ts-web-extras.d.ts +574 -0
  11. package/dist/tsdoc-metadata.json +11 -0
  12. package/docs/index.md +34 -0
  13. package/docs/ts-web-extras.browserhashprovider.hashparts.md +88 -0
  14. package/docs/ts-web-extras.browserhashprovider.hashstring.md +72 -0
  15. package/docs/ts-web-extras.browserhashprovider.md +66 -0
  16. package/docs/ts-web-extras.exportasjson.md +70 -0
  17. package/docs/ts-web-extras.exportusingfilesystemapi.md +104 -0
  18. package/docs/ts-web-extras.extractdirectorypath.md +52 -0
  19. package/docs/ts-web-extras.fileapitreeaccessors.create.md +72 -0
  20. package/docs/ts-web-extras.fileapitreeaccessors.extractfilemetadata.md +54 -0
  21. package/docs/ts-web-extras.fileapitreeaccessors.fromdirectoryupload.md +72 -0
  22. package/docs/ts-web-extras.fileapitreeaccessors.fromfilelist.md +72 -0
  23. package/docs/ts-web-extras.fileapitreeaccessors.getoriginalfile.md +72 -0
  24. package/docs/ts-web-extras.fileapitreeaccessors.md +114 -0
  25. package/docs/ts-web-extras.filepickeraccepttype.accept.md +11 -0
  26. package/docs/ts-web-extras.filepickeraccepttype.description.md +11 -0
  27. package/docs/ts-web-extras.filepickeraccepttype.md +75 -0
  28. package/docs/ts-web-extras.filesystemcreatewritableoptions_2.keepexistingdata.md +11 -0
  29. package/docs/ts-web-extras.filesystemcreatewritableoptions_2.md +58 -0
  30. package/docs/ts-web-extras.filesystemdirectoryhandle_2._symbol.asynciterator_.md +15 -0
  31. package/docs/ts-web-extras.filesystemdirectoryhandle_2.entries.md +15 -0
  32. package/docs/ts-web-extras.filesystemdirectoryhandle_2.getdirectoryhandle.md +66 -0
  33. package/docs/ts-web-extras.filesystemdirectoryhandle_2.getfilehandle.md +66 -0
  34. package/docs/ts-web-extras.filesystemdirectoryhandle_2.keys.md +15 -0
  35. package/docs/ts-web-extras.filesystemdirectoryhandle_2.kind.md +11 -0
  36. package/docs/ts-web-extras.filesystemdirectoryhandle_2.md +146 -0
  37. package/docs/ts-web-extras.filesystemdirectoryhandle_2.removeentry.md +66 -0
  38. package/docs/ts-web-extras.filesystemdirectoryhandle_2.resolve.md +50 -0
  39. package/docs/ts-web-extras.filesystemdirectoryhandle_2.values.md +15 -0
  40. package/docs/ts-web-extras.filesystemfilehandle_2.createwritable.md +52 -0
  41. package/docs/ts-web-extras.filesystemfilehandle_2.getfile.md +15 -0
  42. package/docs/ts-web-extras.filesystemfilehandle_2.kind.md +11 -0
  43. package/docs/ts-web-extras.filesystemfilehandle_2.md +92 -0
  44. package/docs/ts-web-extras.filesystemgetdirectoryoptions_2.create.md +11 -0
  45. package/docs/ts-web-extras.filesystemgetdirectoryoptions_2.md +58 -0
  46. package/docs/ts-web-extras.filesystemgetfileoptions_2.create.md +11 -0
  47. package/docs/ts-web-extras.filesystemgetfileoptions_2.md +58 -0
  48. package/docs/ts-web-extras.filesystemhandle_2.issameentry.md +50 -0
  49. package/docs/ts-web-extras.filesystemhandle_2.kind.md +11 -0
  50. package/docs/ts-web-extras.filesystemhandle_2.md +119 -0
  51. package/docs/ts-web-extras.filesystemhandle_2.name.md +11 -0
  52. package/docs/ts-web-extras.filesystemhandle_2.querypermission.md +52 -0
  53. package/docs/ts-web-extras.filesystemhandle_2.requestpermission.md +52 -0
  54. package/docs/ts-web-extras.filesystemhandlepermissiondescriptor.md +58 -0
  55. package/docs/ts-web-extras.filesystemhandlepermissiondescriptor.mode.md +11 -0
  56. package/docs/ts-web-extras.filesystemremoveoptions_2.md +58 -0
  57. package/docs/ts-web-extras.filesystemremoveoptions_2.recursive.md +11 -0
  58. package/docs/ts-web-extras.filesystemwritablefilestream_2.md +57 -0
  59. package/docs/ts-web-extras.filesystemwritablefilestream_2.seek.md +50 -0
  60. package/docs/ts-web-extras.filesystemwritablefilestream_2.truncate.md +50 -0
  61. package/docs/ts-web-extras.filesystemwritablefilestream_2.write.md +50 -0
  62. package/docs/ts-web-extras.filetreehelpers.defaultfileapitreeinitparams.md +13 -0
  63. package/docs/ts-web-extras.filetreehelpers.extractfilelistmetadata.md +56 -0
  64. package/docs/ts-web-extras.filetreehelpers.extractfilemetadata.md +56 -0
  65. package/docs/ts-web-extras.filetreehelpers.fromdirectoryupload.md +76 -0
  66. package/docs/ts-web-extras.filetreehelpers.fromfilelist.md +76 -0
  67. package/docs/ts-web-extras.filetreehelpers.getoriginalfile.md +72 -0
  68. package/docs/ts-web-extras.filetreehelpers.md +102 -0
  69. package/docs/ts-web-extras.idirectoryhandletreeinitializer.dirhandles.md +11 -0
  70. package/docs/ts-web-extras.idirectoryhandletreeinitializer.md +100 -0
  71. package/docs/ts-web-extras.idirectoryhandletreeinitializer.nonrecursive.md +11 -0
  72. package/docs/ts-web-extras.idirectoryhandletreeinitializer.prefix.md +11 -0
  73. package/docs/ts-web-extras.ifilehandletreeinitializer.filehandles.md +11 -0
  74. package/docs/ts-web-extras.ifilehandletreeinitializer.md +79 -0
  75. package/docs/ts-web-extras.ifilehandletreeinitializer.prefix.md +11 -0
  76. package/docs/ts-web-extras.ifilelisttreeinitializer.filelist.md +11 -0
  77. package/docs/ts-web-extras.ifilelisttreeinitializer.md +58 -0
  78. package/docs/ts-web-extras.ifilemetadata.lastmodified.md +11 -0
  79. package/docs/ts-web-extras.ifilemetadata.md +124 -0
  80. package/docs/ts-web-extras.ifilemetadata.name.md +11 -0
  81. package/docs/ts-web-extras.ifilemetadata.path.md +11 -0
  82. package/docs/ts-web-extras.ifilemetadata.size.md +11 -0
  83. package/docs/ts-web-extras.ifilemetadata.type.md +11 -0
  84. package/docs/ts-web-extras.ifsaccessapis.md +56 -0
  85. package/docs/ts-web-extras.ifsaccessapis.showdirectorypicker.md +52 -0
  86. package/docs/ts-web-extras.ifsaccessapis.showopenfilepicker.md +52 -0
  87. package/docs/ts-web-extras.ifsaccessapis.showsavefilepicker.md +52 -0
  88. package/docs/ts-web-extras.isdirectoryhandle.md +56 -0
  89. package/docs/ts-web-extras.isfilehandle.md +56 -0
  90. package/docs/ts-web-extras.isfilepath.md +52 -0
  91. package/docs/ts-web-extras.iurlconfigoptions.config.md +13 -0
  92. package/docs/ts-web-extras.iurlconfigoptions.configstartdir.md +13 -0
  93. package/docs/ts-web-extras.iurlconfigoptions.contextfilter.md +13 -0
  94. package/docs/ts-web-extras.iurlconfigoptions.input.md +13 -0
  95. package/docs/ts-web-extras.iurlconfigoptions.inputstartdir.md +13 -0
  96. package/docs/ts-web-extras.iurlconfigoptions.interactive.md +13 -0
  97. package/docs/ts-web-extras.iurlconfigoptions.loadzip.md +13 -0
  98. package/docs/ts-web-extras.iurlconfigoptions.maxdistance.md +13 -0
  99. package/docs/ts-web-extras.iurlconfigoptions.md +286 -0
  100. package/docs/ts-web-extras.iurlconfigoptions.qualifierdefaults.md +13 -0
  101. package/docs/ts-web-extras.iurlconfigoptions.reducequalifiers.md +13 -0
  102. package/docs/ts-web-extras.iurlconfigoptions.resourcetypes.md +13 -0
  103. package/docs/ts-web-extras.iurlconfigoptions.zipfile.md +13 -0
  104. package/docs/ts-web-extras.iurlconfigoptions.zippath.md +13 -0
  105. package/docs/ts-web-extras.md +512 -0
  106. package/docs/ts-web-extras.parsecontextfilter.md +52 -0
  107. package/docs/ts-web-extras.parsequalifierdefaults.md +52 -0
  108. package/docs/ts-web-extras.parseresourcetypes.md +52 -0
  109. package/docs/ts-web-extras.parseurlparameters.md +17 -0
  110. package/docs/ts-web-extras.safeshowdirectorypicker.md +72 -0
  111. package/docs/ts-web-extras.safeshowopenfilepicker.md +72 -0
  112. package/docs/ts-web-extras.safeshowsavefilepicker.md +72 -0
  113. package/docs/ts-web-extras.showdirectorypickeroptions.id.md +11 -0
  114. package/docs/ts-web-extras.showdirectorypickeroptions.md +96 -0
  115. package/docs/ts-web-extras.showdirectorypickeroptions.mode.md +11 -0
  116. package/docs/ts-web-extras.showdirectorypickeroptions.startin.md +11 -0
  117. package/docs/ts-web-extras.showopenfilepickeroptions.excludeacceptalloption.md +11 -0
  118. package/docs/ts-web-extras.showopenfilepickeroptions.id.md +11 -0
  119. package/docs/ts-web-extras.showopenfilepickeroptions.md +134 -0
  120. package/docs/ts-web-extras.showopenfilepickeroptions.multiple.md +11 -0
  121. package/docs/ts-web-extras.showopenfilepickeroptions.startin.md +11 -0
  122. package/docs/ts-web-extras.showopenfilepickeroptions.types.md +11 -0
  123. package/docs/ts-web-extras.showsavefilepickeroptions.excludeacceptalloption.md +11 -0
  124. package/docs/ts-web-extras.showsavefilepickeroptions.id.md +11 -0
  125. package/docs/ts-web-extras.showsavefilepickeroptions.md +134 -0
  126. package/docs/ts-web-extras.showsavefilepickeroptions.startin.md +11 -0
  127. package/docs/ts-web-extras.showsavefilepickeroptions.suggestedname.md +11 -0
  128. package/docs/ts-web-extras.showsavefilepickeroptions.types.md +11 -0
  129. package/docs/ts-web-extras.supportsfilesystemaccess.md +56 -0
  130. package/docs/ts-web-extras.treeinitializer.md +15 -0
  131. package/docs/ts-web-extras.wellknowndirectory.md +13 -0
  132. package/docs/ts-web-extras.windowwithfsaccess.md +15 -0
  133. package/etc/ts-web-extras.api.md +310 -0
  134. package/lib/index.d.ts +16 -0
  135. package/lib/index.d.ts.map +1 -0
  136. package/lib/index.js +58 -0
  137. package/lib/index.js.map +1 -0
  138. package/lib/packlets/crypto/browserHashProvider.d.ts +24 -0
  139. package/lib/packlets/crypto/browserHashProvider.d.ts.map +1 -0
  140. package/lib/packlets/crypto/browserHashProvider.js +70 -0
  141. package/lib/packlets/crypto/browserHashProvider.js.map +1 -0
  142. package/lib/packlets/crypto/index.d.ts +6 -0
  143. package/lib/packlets/crypto/index.d.ts.map +1 -0
  144. package/lib/packlets/crypto/index.js +43 -0
  145. package/lib/packlets/crypto/index.js.map +1 -0
  146. package/lib/packlets/file-api-types/index.d.ts +205 -0
  147. package/lib/packlets/file-api-types/index.d.ts.map +1 -0
  148. package/lib/packlets/file-api-types/index.js +166 -0
  149. package/lib/packlets/file-api-types/index.js.map +1 -0
  150. package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts +129 -0
  151. package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts.map +1 -0
  152. package/lib/packlets/file-tree/fileApiTreeAccessors.js +334 -0
  153. package/lib/packlets/file-tree/fileApiTreeAccessors.js.map +1 -0
  154. package/lib/packlets/file-tree/index.d.ts +6 -0
  155. package/lib/packlets/file-tree/index.d.ts.map +1 -0
  156. package/lib/packlets/file-tree/index.js +43 -0
  157. package/lib/packlets/file-tree/index.js.map +1 -0
  158. package/lib/packlets/helpers/fileTreeHelpers.d.ts +60 -0
  159. package/lib/packlets/helpers/fileTreeHelpers.d.ts.map +1 -0
  160. package/lib/packlets/helpers/fileTreeHelpers.js +102 -0
  161. package/lib/packlets/helpers/fileTreeHelpers.js.map +1 -0
  162. package/lib/packlets/helpers/index.d.ts +6 -0
  163. package/lib/packlets/helpers/index.d.ts.map +1 -0
  164. package/lib/packlets/helpers/index.js +63 -0
  165. package/lib/packlets/helpers/index.js.map +1 -0
  166. package/lib/packlets/url-utils/index.d.ts +6 -0
  167. package/lib/packlets/url-utils/index.d.ts.map +1 -0
  168. package/lib/packlets/url-utils/index.js +43 -0
  169. package/lib/packlets/url-utils/index.js.map +1 -0
  170. package/lib/packlets/url-utils/urlParams.d.ts +94 -0
  171. package/lib/packlets/url-utils/urlParams.d.ts.map +1 -0
  172. package/lib/packlets/url-utils/urlParams.js +165 -0
  173. package/lib/packlets/url-utils/urlParams.js.map +1 -0
  174. package/lib/test/setupTests.d.ts +2 -0
  175. package/lib/test/setupTests.d.ts.map +1 -0
  176. package/lib/test/setupTests.js +76 -0
  177. package/lib/test/setupTests.js.map +1 -0
  178. package/lib/test/unit/browserHashProvider.test.d.ts +2 -0
  179. package/lib/test/unit/browserHashProvider.test.d.ts.map +1 -0
  180. package/lib/test/unit/browserHashProvider.test.js +142 -0
  181. package/lib/test/unit/browserHashProvider.test.js.map +1 -0
  182. package/lib/test/unit/fileApiTreeAccessors.test.d.ts +2 -0
  183. package/lib/test/unit/fileApiTreeAccessors.test.d.ts.map +1 -0
  184. package/lib/test/unit/fileApiTreeAccessors.test.js +1139 -0
  185. package/lib/test/unit/fileApiTreeAccessors.test.js.map +1 -0
  186. package/lib/test/unit/fileApiTypes.test.d.ts +2 -0
  187. package/lib/test/unit/fileApiTypes.test.d.ts.map +1 -0
  188. package/lib/test/unit/fileApiTypes.test.js +444 -0
  189. package/lib/test/unit/fileApiTypes.test.js.map +1 -0
  190. package/lib/test/unit/fileTreeHelpers.test.d.ts +2 -0
  191. package/lib/test/unit/fileTreeHelpers.test.d.ts.map +1 -0
  192. package/lib/test/unit/fileTreeHelpers.test.js +592 -0
  193. package/lib/test/unit/fileTreeHelpers.test.js.map +1 -0
  194. package/lib/test/unit/urlParams.test.d.ts +2 -0
  195. package/lib/test/unit/urlParams.test.d.ts.map +1 -0
  196. package/lib/test/unit/urlParams.test.js +395 -0
  197. package/lib/test/unit/urlParams.test.js.map +1 -0
  198. package/lib/test/utils/testHelpers.d.ts +51 -0
  199. package/lib/test/utils/testHelpers.d.ts.map +1 -0
  200. package/lib/test/utils/testHelpers.js +133 -0
  201. package/lib/test/utils/testHelpers.js.map +1 -0
  202. package/package.json +68 -0
  203. package/rush-logs/ts-web-extras.build.cache.log +3 -0
  204. package/rush-logs/ts-web-extras.build.log +40 -0
  205. package/src/index.ts +47 -0
  206. package/src/packlets/crypto/browserHashProvider.ts +73 -0
  207. package/src/packlets/crypto/index.ts +28 -0
  208. package/src/packlets/file-api-types/index.ts +345 -0
  209. package/src/packlets/file-tree/fileApiTreeAccessors.ts +420 -0
  210. package/src/packlets/file-tree/index.ts +28 -0
  211. package/src/packlets/helpers/fileTreeHelpers.ts +107 -0
  212. package/src/packlets/helpers/index.ts +28 -0
  213. package/src/packlets/url-utils/index.ts +28 -0
  214. package/src/packlets/url-utils/urlParams.ts +245 -0
  215. package/src/test/setupTests.ts +87 -0
  216. package/src/test/unit/browserHashProvider.test.ts +155 -0
  217. package/src/test/unit/browserHashProvider.test.ts.bak +376 -0
  218. package/src/test/unit/fileApiTreeAccessors.test.ts +1318 -0
  219. package/src/test/unit/fileApiTypes.test.ts +551 -0
  220. package/src/test/unit/fileTreeHelpers.test.ts +694 -0
  221. package/src/test/unit/urlParams.test.ts +464 -0
  222. package/src/test/utils/testHelpers.ts +155 -0
  223. package/temp/build/typescript/ts_l9Fw4VUO.json +1 -0
  224. package/temp/coverage/base.css +224 -0
  225. package/temp/coverage/block-navigation.js +87 -0
  226. package/temp/coverage/crypto/browserHashProvider.ts.html +304 -0
  227. package/temp/coverage/crypto/index.html +116 -0
  228. package/temp/coverage/favicon.png +0 -0
  229. package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +1345 -0
  230. package/temp/coverage/file-tree/index.html +116 -0
  231. package/temp/coverage/helpers/fileTreeHelpers.ts.html +406 -0
  232. package/temp/coverage/helpers/index.html +116 -0
  233. package/temp/coverage/index.html +161 -0
  234. package/temp/coverage/lcov-report/base.css +224 -0
  235. package/temp/coverage/lcov-report/block-navigation.js +87 -0
  236. package/temp/coverage/lcov-report/crypto/browserHashProvider.ts.html +304 -0
  237. package/temp/coverage/lcov-report/crypto/index.html +116 -0
  238. package/temp/coverage/lcov-report/favicon.png +0 -0
  239. package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +1345 -0
  240. package/temp/coverage/lcov-report/file-tree/index.html +116 -0
  241. package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +406 -0
  242. package/temp/coverage/lcov-report/helpers/index.html +116 -0
  243. package/temp/coverage/lcov-report/index.html +161 -0
  244. package/temp/coverage/lcov-report/prettify.css +1 -0
  245. package/temp/coverage/lcov-report/prettify.js +2 -0
  246. package/temp/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  247. package/temp/coverage/lcov-report/sorter.js +210 -0
  248. package/temp/coverage/lcov-report/url-utils/index.html +116 -0
  249. package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +820 -0
  250. package/temp/coverage/lcov.info +1096 -0
  251. package/temp/coverage/prettify.css +1 -0
  252. package/temp/coverage/prettify.js +2 -0
  253. package/temp/coverage/sort-arrow-sprite.png +0 -0
  254. package/temp/coverage/sorter.js +210 -0
  255. package/temp/coverage/url-utils/index.html +116 -0
  256. package/temp/coverage/url-utils/urlParams.ts.html +820 -0
  257. package/temp/test/jest/haste-map-7492f1b44480e0cdd1f220078fb3afd8-c8dd6c3430605adeb2f1cadf4f75e791-8c9336785555d572065b28c111982ba4 +0 -0
  258. package/temp/test/jest/jest-transform-cache-7492f1b44480e0cdd1f220078fb3afd8-79ef2876fae7ca75eedb2aa53dc48338/63/package_63a8257b0e4d0e7ff33f927d75f27a75 +53 -0
  259. package/temp/test/jest/perf-cache-7492f1b44480e0cdd1f220078fb3afd8-da39a3ee5e6b4b0d3255bfef95601890 +1 -0
  260. package/temp/ts-web-extras.api.json +5040 -0
  261. package/temp/ts-web-extras.api.md +310 -0
  262. package/tsconfig.json +7 -0
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@fgv/ts-web-extras](./ts-web-extras.md) &gt; [ShowSaveFilePickerOptions](./ts-web-extras.showsavefilepickeroptions.md) &gt; [startIn](./ts-web-extras.showsavefilepickeroptions.startin.md)
4
+
5
+ ## ShowSaveFilePickerOptions.startIn property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ startIn?: FileSystemHandle | WellKnownDirectory;
11
+ ```
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@fgv/ts-web-extras](./ts-web-extras.md) &gt; [ShowSaveFilePickerOptions](./ts-web-extras.showsavefilepickeroptions.md) &gt; [suggestedName](./ts-web-extras.showsavefilepickeroptions.suggestedname.md)
4
+
5
+ ## ShowSaveFilePickerOptions.suggestedName property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ suggestedName?: string;
11
+ ```
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@fgv/ts-web-extras](./ts-web-extras.md) &gt; [ShowSaveFilePickerOptions](./ts-web-extras.showsavefilepickeroptions.md) &gt; [types](./ts-web-extras.showsavefilepickeroptions.types.md)
4
+
5
+ ## ShowSaveFilePickerOptions.types property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ types?: FilePickerAcceptType[];
11
+ ```
@@ -0,0 +1,56 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@fgv/ts-web-extras](./ts-web-extras.md) &gt; [supportsFileSystemAccess](./ts-web-extras.supportsfilesystemaccess.md)
4
+
5
+ ## supportsFileSystemAccess() function
6
+
7
+ Type guard to check if the browser supports the File System Access API
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare function supportsFileSystemAccess(window: Window): window is WindowWithFsAccess;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ window
36
+
37
+
38
+ </td><td>
39
+
40
+ Window
41
+
42
+
43
+ </td><td>
44
+
45
+ The window object to check
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+
51
+ **Returns:**
52
+
53
+ window is [WindowWithFsAccess](./ts-web-extras.windowwithfsaccess.md)
54
+
55
+ True if the window supports File System Access API
56
+
@@ -0,0 +1,15 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@fgv/ts-web-extras](./ts-web-extras.md) &gt; [TreeInitializer](./ts-web-extras.treeinitializer.md)
4
+
5
+ ## TreeInitializer type
6
+
7
+ Union type for all supported tree initializers.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type TreeInitializer = IFileListTreeInitializer | IFileHandleTreeInitializer | IDirectoryHandleTreeInitializer;
13
+ ```
14
+ **References:** [IFileListTreeInitializer](./ts-web-extras.ifilelisttreeinitializer.md)<!-- -->, [IFileHandleTreeInitializer](./ts-web-extras.ifilehandletreeinitializer.md)<!-- -->, [IDirectoryHandleTreeInitializer](./ts-web-extras.idirectoryhandletreeinitializer.md)
15
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@fgv/ts-web-extras](./ts-web-extras.md) &gt; [WellKnownDirectory](./ts-web-extras.wellknowndirectory.md)
4
+
5
+ ## WellKnownDirectory type
6
+
7
+ Well-known directory type
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type WellKnownDirectory = 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos';
13
+ ```
@@ -0,0 +1,15 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@fgv/ts-web-extras](./ts-web-extras.md) &gt; [WindowWithFsAccess](./ts-web-extras.windowwithfsaccess.md)
4
+
5
+ ## WindowWithFsAccess type
6
+
7
+ Window interface extended with File System Access API
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type WindowWithFsAccess = Window & IFsAccessApis;
13
+ ```
14
+ **References:** [IFsAccessApis](./ts-web-extras.ifsaccessapis.md)
15
+
@@ -0,0 +1,310 @@
1
+ ## API Report File for "@fgv/ts-web-extras"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { FileTree } from '@fgv/ts-json-base';
8
+ import { Result } from '@fgv/ts-utils';
9
+
10
+ // @public
11
+ export class BrowserHashProvider {
12
+ static hashParts(parts: string[], algorithm?: string, separator?: string): Promise<Result<string>>;
13
+ static hashString(data: string, algorithm?: string): Promise<Result<string>>;
14
+ }
15
+
16
+ // @public
17
+ const defaultFileApiTreeInitParams: FileTree.IFileTreeInitParams<string>;
18
+
19
+ // @public
20
+ export function exportAsJson(data: unknown, filename: string): void;
21
+
22
+ // @public
23
+ export function exportUsingFileSystemAPI(data: unknown, suggestedName: string, description?: string, window?: Window): Promise<boolean>;
24
+
25
+ // @public
26
+ export function extractDirectoryPath(path: string): string;
27
+
28
+ // @public
29
+ function extractFileListMetadata(fileList: FileList): Array<IFileMetadata>;
30
+
31
+ // @public
32
+ function extractFileMetadata(file: File): IFileMetadata;
33
+
34
+ // @public
35
+ export class FileApiTreeAccessors<TCT extends string = string> {
36
+ static create<TCT extends string = string>(initializers: TreeInitializer[], params?: FileTree.IFileTreeInitParams<TCT>): Promise<Result<FileTree.FileTree<TCT>>>;
37
+ static extractFileMetadata(file: File): IFileMetadata;
38
+ static fromDirectoryUpload<TCT extends string = string>(fileList: FileList, params?: FileTree.IFileTreeInitParams<TCT>): Promise<Result<FileTree.FileTree<TCT>>>;
39
+ static fromFileList<TCT extends string = string>(fileList: FileList, params?: FileTree.IFileTreeInitParams<TCT>): Promise<Result<FileTree.FileTree<TCT>>>;
40
+ static getOriginalFile(fileList: FileList, targetPath: string): Result<File>;
41
+ }
42
+
43
+ // @public
44
+ export interface FilePickerAcceptType {
45
+ // (undocumented)
46
+ accept: Record<string, string | string[]>;
47
+ // (undocumented)
48
+ description?: string;
49
+ }
50
+
51
+ // @public
52
+ interface FileSystemCreateWritableOptions_2 {
53
+ // (undocumented)
54
+ keepExistingData?: boolean;
55
+ }
56
+ export { FileSystemCreateWritableOptions_2 as FileSystemCreateWritableOptions }
57
+
58
+ // @public
59
+ interface FileSystemDirectoryHandle_2 extends FileSystemHandle_2 {
60
+ // (undocumented)
61
+ [Symbol.asyncIterator](): AsyncIterableIterator<[string, FileSystemHandle_2]>;
62
+ // (undocumented)
63
+ entries(): AsyncIterableIterator<[string, FileSystemHandle_2]>;
64
+ // (undocumented)
65
+ getDirectoryHandle(name: string, options?: FileSystemGetDirectoryOptions_2): Promise<FileSystemDirectoryHandle_2>;
66
+ // (undocumented)
67
+ getFileHandle(name: string, options?: FileSystemGetFileOptions_2): Promise<FileSystemFileHandle_2>;
68
+ // (undocumented)
69
+ keys(): AsyncIterableIterator<string>;
70
+ // (undocumented)
71
+ readonly kind: 'directory';
72
+ // (undocumented)
73
+ removeEntry(name: string, options?: FileSystemRemoveOptions_2): Promise<void>;
74
+ // (undocumented)
75
+ resolve(possibleDescendant: FileSystemHandle_2): Promise<string[] | null>;
76
+ // (undocumented)
77
+ values(): AsyncIterableIterator<FileSystemHandle_2>;
78
+ }
79
+ export { FileSystemDirectoryHandle_2 as FileSystemDirectoryHandle }
80
+
81
+ // @public
82
+ interface FileSystemFileHandle_2 extends FileSystemHandle_2 {
83
+ // (undocumented)
84
+ createWritable(options?: FileSystemCreateWritableOptions_2): Promise<FileSystemWritableFileStream_2>;
85
+ // (undocumented)
86
+ getFile(): Promise<File>;
87
+ // (undocumented)
88
+ readonly kind: 'file';
89
+ }
90
+ export { FileSystemFileHandle_2 as FileSystemFileHandle }
91
+
92
+ // @public
93
+ interface FileSystemGetDirectoryOptions_2 {
94
+ // (undocumented)
95
+ create?: boolean;
96
+ }
97
+ export { FileSystemGetDirectoryOptions_2 as FileSystemGetDirectoryOptions }
98
+
99
+ // @public
100
+ interface FileSystemGetFileOptions_2 {
101
+ // (undocumented)
102
+ create?: boolean;
103
+ }
104
+ export { FileSystemGetFileOptions_2 as FileSystemGetFileOptions }
105
+
106
+ // @public
107
+ interface FileSystemHandle_2 {
108
+ // (undocumented)
109
+ isSameEntry(other: FileSystemHandle_2): Promise<boolean>;
110
+ // (undocumented)
111
+ readonly kind: 'file' | 'directory';
112
+ // (undocumented)
113
+ readonly name: string;
114
+ // (undocumented)
115
+ queryPermission(descriptor?: FileSystemHandlePermissionDescriptor): Promise<PermissionState>;
116
+ // (undocumented)
117
+ requestPermission(descriptor?: FileSystemHandlePermissionDescriptor): Promise<PermissionState>;
118
+ }
119
+ export { FileSystemHandle_2 as FileSystemHandle }
120
+
121
+ // @public
122
+ export interface FileSystemHandlePermissionDescriptor {
123
+ // (undocumented)
124
+ mode?: 'read' | 'readwrite';
125
+ }
126
+
127
+ // @public
128
+ interface FileSystemRemoveOptions_2 {
129
+ // (undocumented)
130
+ recursive?: boolean;
131
+ }
132
+ export { FileSystemRemoveOptions_2 as FileSystemRemoveOptions }
133
+
134
+ // @public
135
+ interface FileSystemWritableFileStream_2 extends WritableStream {
136
+ // (undocumented)
137
+ seek(position: number): Promise<void>;
138
+ // (undocumented)
139
+ truncate(size: number): Promise<void>;
140
+ // (undocumented)
141
+ write(data: BufferSource | Blob | string): Promise<void>;
142
+ }
143
+ export { FileSystemWritableFileStream_2 as FileSystemWritableFileStream }
144
+
145
+ declare namespace FileTreeHelpers {
146
+ export {
147
+ fromFileList,
148
+ fromDirectoryUpload,
149
+ getOriginalFile,
150
+ extractFileListMetadata,
151
+ extractFileMetadata,
152
+ defaultFileApiTreeInitParams
153
+ }
154
+ }
155
+
156
+ // @public
157
+ function fromDirectoryUpload(fileList: FileList, params?: FileTree.IFileTreeInitParams<string>): Promise<Result<FileTree.FileTree<string>>>;
158
+
159
+ // @public
160
+ function fromFileList(fileList: FileList, params?: FileTree.IFileTreeInitParams<string>): Promise<Result<FileTree.FileTree<string>>>;
161
+
162
+ // @public
163
+ function getOriginalFile(fileList: FileList, path: string): Result<File>;
164
+
165
+ // @public
166
+ export interface IDirectoryHandleTreeInitializer {
167
+ // (undocumented)
168
+ readonly dirHandles: FileSystemDirectoryHandle_2[];
169
+ // (undocumented)
170
+ readonly nonRecursive?: boolean;
171
+ // (undocumented)
172
+ readonly prefix?: string;
173
+ }
174
+
175
+ // @public
176
+ export interface IFileHandleTreeInitializer {
177
+ // (undocumented)
178
+ readonly fileHandles: FileSystemFileHandle_2[];
179
+ // (undocumented)
180
+ readonly prefix?: string;
181
+ }
182
+
183
+ // @public
184
+ export interface IFileListTreeInitializer {
185
+ // (undocumented)
186
+ readonly fileList: FileList;
187
+ }
188
+
189
+ // @public
190
+ export interface IFileMetadata {
191
+ // (undocumented)
192
+ lastModified: number;
193
+ // (undocumented)
194
+ name: string;
195
+ // (undocumented)
196
+ path: string;
197
+ // (undocumented)
198
+ size: number;
199
+ // (undocumented)
200
+ type: string;
201
+ }
202
+
203
+ // @public
204
+ export interface IFsAccessApis {
205
+ // (undocumented)
206
+ showDirectoryPicker(options?: ShowDirectoryPickerOptions): Promise<FileSystemDirectoryHandle_2>;
207
+ // (undocumented)
208
+ showOpenFilePicker(options?: ShowOpenFilePickerOptions): Promise<FileSystemFileHandle_2[]>;
209
+ // (undocumented)
210
+ showSaveFilePicker(options?: ShowSaveFilePickerOptions): Promise<FileSystemFileHandle_2>;
211
+ }
212
+
213
+ // @public
214
+ export function isDirectoryHandle(handle: FileSystemHandle_2): handle is FileSystemDirectoryHandle_2;
215
+
216
+ // @public
217
+ export function isFileHandle(handle: FileSystemHandle_2): handle is FileSystemFileHandle_2;
218
+
219
+ // @public
220
+ export function isFilePath(path: string): boolean;
221
+
222
+ // @public
223
+ export interface IUrlConfigOptions {
224
+ config?: string;
225
+ configStartDir?: string;
226
+ contextFilter?: string;
227
+ input?: string;
228
+ inputStartDir?: string;
229
+ interactive?: boolean;
230
+ loadZip?: boolean;
231
+ maxDistance?: number;
232
+ qualifierDefaults?: string;
233
+ reduceQualifiers?: boolean;
234
+ resourceTypes?: string;
235
+ zipFile?: string;
236
+ zipPath?: string;
237
+ }
238
+
239
+ // @public
240
+ export function parseContextFilter(contextFilter: string): Record<string, string>;
241
+
242
+ // @public
243
+ export function parseQualifierDefaults(qualifierDefaults: string): Record<string, string[]>;
244
+
245
+ // @public
246
+ export function parseResourceTypes(resourceTypes: string): string[];
247
+
248
+ // @public
249
+ export function parseUrlParameters(): IUrlConfigOptions;
250
+
251
+ // @public
252
+ export function safeShowDirectoryPicker(window: Window, options?: ShowDirectoryPickerOptions): Promise<FileSystemDirectoryHandle_2 | null>;
253
+
254
+ // @public
255
+ export function safeShowOpenFilePicker(window: Window, options?: ShowOpenFilePickerOptions): Promise<FileSystemFileHandle_2[] | null>;
256
+
257
+ // @public
258
+ export function safeShowSaveFilePicker(window: Window, options?: ShowSaveFilePickerOptions): Promise<FileSystemFileHandle_2 | null>;
259
+
260
+ // @public
261
+ export interface ShowDirectoryPickerOptions {
262
+ // (undocumented)
263
+ id?: string;
264
+ // (undocumented)
265
+ mode?: 'read' | 'readwrite';
266
+ // (undocumented)
267
+ startIn?: FileSystemHandle_2 | WellKnownDirectory;
268
+ }
269
+
270
+ // @public
271
+ export interface ShowOpenFilePickerOptions {
272
+ // (undocumented)
273
+ excludeAcceptAllOption?: boolean;
274
+ // (undocumented)
275
+ id?: string;
276
+ // (undocumented)
277
+ multiple?: boolean;
278
+ // (undocumented)
279
+ startIn?: FileSystemHandle_2 | WellKnownDirectory;
280
+ // (undocumented)
281
+ types?: FilePickerAcceptType[];
282
+ }
283
+
284
+ // @public
285
+ export interface ShowSaveFilePickerOptions {
286
+ // (undocumented)
287
+ excludeAcceptAllOption?: boolean;
288
+ // (undocumented)
289
+ id?: string;
290
+ // (undocumented)
291
+ startIn?: FileSystemHandle_2 | WellKnownDirectory;
292
+ // (undocumented)
293
+ suggestedName?: string;
294
+ // (undocumented)
295
+ types?: FilePickerAcceptType[];
296
+ }
297
+
298
+ // @public
299
+ export function supportsFileSystemAccess(window: Window): window is WindowWithFsAccess;
300
+
301
+ // @public
302
+ export type TreeInitializer = IFileListTreeInitializer | IFileHandleTreeInitializer | IDirectoryHandleTreeInitializer;
303
+
304
+ // @public
305
+ export type WellKnownDirectory = 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos';
306
+
307
+ // @public
308
+ export type WindowWithFsAccess = Window & IFsAccessApis;
309
+
310
+ ```
package/lib/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Browser-compatible utilities and FileTree implementations.
3
+ *
4
+ * This library provides browser-compatible alternatives to Node.js-specific functionality,
5
+ * including Web Crypto API-based hashing, File API-based file tree implementations,
6
+ * and URL parameter parsing utilities.
7
+ * All exports are designed to be tree-shakeable for optimal bundle size.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export * from './packlets/crypto';
12
+ export * from './packlets/file-tree';
13
+ export * from './packlets/helpers';
14
+ export * from './packlets/file-api-types';
15
+ export * from './packlets/url-utils';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;GASG;AAGH,cAAc,mBAAmB,CAAC;AAGlC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,sBAAsB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
35
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ /**
39
+ * Browser-compatible utilities and FileTree implementations.
40
+ *
41
+ * This library provides browser-compatible alternatives to Node.js-specific functionality,
42
+ * including Web Crypto API-based hashing, File API-based file tree implementations,
43
+ * and URL parameter parsing utilities.
44
+ * All exports are designed to be tree-shakeable for optimal bundle size.
45
+ *
46
+ * @packageDocumentation
47
+ */
48
+ // Export crypto functionality
49
+ __exportStar(require("./packlets/crypto"), exports);
50
+ // Export file tree functionality
51
+ __exportStar(require("./packlets/file-tree"), exports);
52
+ // Export helper functions
53
+ __exportStar(require("./packlets/helpers"), exports);
54
+ // Export File System Access API types
55
+ __exportStar(require("./packlets/file-api-types"), exports);
56
+ // Export URL utilities
57
+ __exportStar(require("./packlets/url-utils"), exports);
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH;;;;;;;;;GASG;AAEH,8BAA8B;AAC9B,oDAAkC;AAElC,iCAAiC;AACjC,uDAAqC;AAErC,0BAA0B;AAC1B,qDAAmC;AAEnC,sCAAsC;AACtC,4DAA0C;AAE1C,uBAAuB;AACvB,uDAAqC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Browser-compatible utilities and FileTree implementations.\n *\n * This library provides browser-compatible alternatives to Node.js-specific functionality,\n * including Web Crypto API-based hashing, File API-based file tree implementations,\n * and URL parameter parsing utilities.\n * All exports are designed to be tree-shakeable for optimal bundle size.\n *\n * @packageDocumentation\n */\n\n// Export crypto functionality\nexport * from './packlets/crypto';\n\n// Export file tree functionality\nexport * from './packlets/file-tree';\n\n// Export helper functions\nexport * from './packlets/helpers';\n\n// Export File System Access API types\nexport * from './packlets/file-api-types';\n\n// Export URL utilities\nexport * from './packlets/url-utils';\n"]}
@@ -0,0 +1,24 @@
1
+ import { Result } from '@fgv/ts-utils';
2
+ /**
3
+ * Browser-compatible hash provider using the Web Crypto API.
4
+ * Supports common hash algorithms available in browsers.
5
+ * @public
6
+ */
7
+ export declare class BrowserHashProvider {
8
+ /**
9
+ * Hash a string using the specified algorithm.
10
+ * @param data - The string to hash
11
+ * @param algorithm - The hash algorithm to use
12
+ * @returns Promise resolving to the hex-encoded hash
13
+ */
14
+ static hashString(data: string, algorithm?: string): Promise<Result<string>>;
15
+ /**
16
+ * Hash multiple strings concatenated with a separator.
17
+ * @param parts - Array of strings to concatenate and hash
18
+ * @param algorithm - The hash algorithm to use
19
+ * @param separator - Separator to use between parts (default: '|')
20
+ * @returns Promise resolving to the hex-encoded hash
21
+ */
22
+ static hashParts(parts: string[], algorithm?: string, separator?: string): Promise<Result<string>>;
23
+ }
24
+ //# sourceMappingURL=browserHashProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserHashProvider.d.ts","sourceRoot":"","sources":["../../../src/packlets/crypto/browserHashProvider.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD;;;;GAIG;AACH,qBAAa,mBAAmB;IAC9B;;;;;OAKG;WACiB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAqBpG;;;;;;OAMG;WACiB,SAAS,CAC3B,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,GAAE,MAAkB,EAC7B,SAAS,GAAE,MAAY,GACtB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;CAI3B"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 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
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.BrowserHashProvider = void 0;
25
+ const ts_utils_1 = require("@fgv/ts-utils");
26
+ /**
27
+ * Browser-compatible hash provider using the Web Crypto API.
28
+ * Supports common hash algorithms available in browsers.
29
+ * @public
30
+ */
31
+ class BrowserHashProvider {
32
+ /**
33
+ * Hash a string using the specified algorithm.
34
+ * @param data - The string to hash
35
+ * @param algorithm - The hash algorithm to use
36
+ * @returns Promise resolving to the hex-encoded hash
37
+ */
38
+ static async hashString(data, algorithm = 'SHA-256') {
39
+ try {
40
+ /* c8 ignore next 3 - defense in depth */
41
+ if (!crypto.subtle) {
42
+ return (0, ts_utils_1.fail)('Web Crypto API not available in this environment');
43
+ }
44
+ const encoder = new TextEncoder();
45
+ const dataBuffer = encoder.encode(data);
46
+ const hashBuffer = await crypto.subtle.digest(algorithm, dataBuffer);
47
+ const hashArray = new Uint8Array(hashBuffer);
48
+ const hashHex = Array.from(hashArray)
49
+ .map((b) => b.toString(16).padStart(2, '0'))
50
+ .join('');
51
+ return (0, ts_utils_1.succeed)(hashHex);
52
+ }
53
+ catch (error) {
54
+ return (0, ts_utils_1.fail)(`Hash computation failed: ${error instanceof Error ? error.message : String(error)}`);
55
+ }
56
+ }
57
+ /**
58
+ * Hash multiple strings concatenated with a separator.
59
+ * @param parts - Array of strings to concatenate and hash
60
+ * @param algorithm - The hash algorithm to use
61
+ * @param separator - Separator to use between parts (default: '|')
62
+ * @returns Promise resolving to the hex-encoded hash
63
+ */
64
+ static async hashParts(parts, algorithm = 'SHA-256', separator = '|') {
65
+ const combined = parts.join(separator);
66
+ return this.hashString(combined, algorithm);
67
+ }
68
+ }
69
+ exports.BrowserHashProvider = BrowserHashProvider;
70
+ //# sourceMappingURL=browserHashProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserHashProvider.js","sourceRoot":"","sources":["../../../src/packlets/crypto/browserHashProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AAEtD;;;;GAIG;AACH,MAAa,mBAAmB;IAC9B;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAY,EAAE,YAAoB,SAAS;QACxE,IAAI,CAAC;YACH,yCAAyC;YACzC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO,IAAA,eAAI,EAAC,kDAAkD,CAAC,CAAC;YAClE,CAAC;YAED,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;YAClC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACxC,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YACrE,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;YAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;iBAClC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;iBAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;YAEZ,OAAO,IAAA,kBAAO,EAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAA,eAAI,EAAC,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACpG,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,SAAS,CAC3B,KAAe,EACf,YAAoB,SAAS,EAC7B,YAAoB,GAAG;QAEvB,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC9C,CAAC;CACF;AA3CD,kDA2CC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, succeed, fail } from '@fgv/ts-utils';\n\n/**\n * Browser-compatible hash provider using the Web Crypto API.\n * Supports common hash algorithms available in browsers.\n * @public\n */\nexport class BrowserHashProvider {\n /**\n * Hash a string using the specified algorithm.\n * @param data - The string to hash\n * @param algorithm - The hash algorithm to use\n * @returns Promise resolving to the hex-encoded hash\n */\n public static async hashString(data: string, algorithm: string = 'SHA-256'): Promise<Result<string>> {\n try {\n /* c8 ignore next 3 - defense in depth */\n if (!crypto.subtle) {\n return fail('Web Crypto API not available in this environment');\n }\n\n const encoder = new TextEncoder();\n const dataBuffer = encoder.encode(data);\n const hashBuffer = await crypto.subtle.digest(algorithm, dataBuffer);\n const hashArray = new Uint8Array(hashBuffer);\n const hashHex = Array.from(hashArray)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n\n return succeed(hashHex);\n } catch (error) {\n return fail(`Hash computation failed: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Hash multiple strings concatenated with a separator.\n * @param parts - Array of strings to concatenate and hash\n * @param algorithm - The hash algorithm to use\n * @param separator - Separator to use between parts (default: '|')\n * @returns Promise resolving to the hex-encoded hash\n */\n public static async hashParts(\n parts: string[],\n algorithm: string = 'SHA-256',\n separator: string = '|'\n ): Promise<Result<string>> {\n const combined = parts.join(separator);\n return this.hashString(combined, algorithm);\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Browser-compatible cryptographic utilities using the Web Crypto API.
3
+ * @packageDocumentation
4
+ */
5
+ export * from './browserHashProvider';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/crypto/index.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AAEH,cAAc,uBAAuB,CAAC"}