@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,574 @@
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
+
12
+ import { FileTree } from '@fgv/ts-json-base';
13
+ import { Result } from '@fgv/ts-utils';
14
+
15
+ /**
16
+ * Browser-compatible hash provider using the Web Crypto API.
17
+ * Supports common hash algorithms available in browsers.
18
+ * @public
19
+ */
20
+ export declare class BrowserHashProvider {
21
+ /**
22
+ * Hash a string using the specified algorithm.
23
+ * @param data - The string to hash
24
+ * @param algorithm - The hash algorithm to use
25
+ * @returns Promise resolving to the hex-encoded hash
26
+ */
27
+ static hashString(data: string, algorithm?: string): Promise<Result<string>>;
28
+ /**
29
+ * Hash multiple strings concatenated with a separator.
30
+ * @param parts - Array of strings to concatenate and hash
31
+ * @param algorithm - The hash algorithm to use
32
+ * @param separator - Separator to use between parts (default: '|')
33
+ * @returns Promise resolving to the hex-encoded hash
34
+ */
35
+ static hashParts(parts: string[], algorithm?: string, separator?: string): Promise<Result<string>>;
36
+ }
37
+
38
+ /**
39
+ * Default initialization parameters for a `FileTree` using {@link FileApiTreeAccessors}.
40
+ * @public
41
+ */
42
+ declare const defaultFileApiTreeInitParams: FileTree.IFileTreeInitParams<string>;
43
+
44
+ /**
45
+ * Export data as JSON file using legacy blob download method.
46
+ * Creates a temporary download link and triggers file download.
47
+ * @param data - Data to export as JSON
48
+ * @param filename - Name for the downloaded file
49
+ * @public
50
+ */
51
+ export declare function exportAsJson(data: unknown, filename: string): void;
52
+
53
+ /**
54
+ * Export data using File System Access API with fallback to blob download.
55
+ * @param data - Data to export as JSON
56
+ * @param suggestedName - Suggested filename for the save dialog
57
+ * @param description - Description for file type filter (default: 'JSON files')
58
+ * @param window - Window object for API access (default: globalThis.window)
59
+ * @returns Promise resolving to true if saved via File System Access API, false if fallback used
60
+ * @public
61
+ */
62
+ export declare function exportUsingFileSystemAPI(data: unknown, suggestedName: string, description?: string, window?: Window): Promise<boolean>;
63
+
64
+ /**
65
+ * Extracts the directory path from a file or directory path
66
+ * If the path appears to be a directory (no extension), returns it as-is
67
+ * If the path appears to be a file, returns the parent directory
68
+ * @public
69
+ */
70
+ export declare function extractDirectoryPath(path: string): string;
71
+
72
+ /**
73
+ * Helper function to extract metadata from a `FileList`.
74
+ * @param fileList - The `FileList` to extract metadata from
75
+ * @returns Array of {@link IFileMetadata | file metadata} objects
76
+ * @public
77
+ */
78
+ declare function extractFileListMetadata(fileList: FileList): Array<IFileMetadata>;
79
+
80
+ /**
81
+ * Helper function to extract metadata from a `File`.
82
+ * @param file - The File to extract metadata from
83
+ * @returns {@link IFileMetadata | file metadata} object
84
+ * @public
85
+ */
86
+ declare function extractFileMetadata(file: File): IFileMetadata;
87
+
88
+ /**
89
+ * Helper class to create FileTree instances from various file sources.
90
+ * Supports File API (FileList) and File System Access API handles.
91
+ * @public
92
+ */
93
+ export declare class FileApiTreeAccessors<TCT extends string = string> {
94
+ /**
95
+ * Create FileTree from various file sources using TreeInitializer array.
96
+ * @param initializers - Array of TreeInitializer objects specifying file sources
97
+ * @param params - Optional `IFileTreeInitParams` for the file tree.
98
+ * @returns Promise resolving to a FileTree with all content pre-loaded
99
+ */
100
+ static create<TCT extends string = string>(initializers: TreeInitializer[], params?: FileTree.IFileTreeInitParams<TCT>): Promise<Result<FileTree.FileTree<TCT>>>;
101
+ /**
102
+ * Create FileTree from FileList (e.g., from input[type="file"]).
103
+ * @param fileList - FileList from a file input element
104
+ * @param params - Optional `IFileTreeInitParams` for the file tree.
105
+ * @returns Promise resolving to a FileTree with all content pre-loaded
106
+ */
107
+ static fromFileList<TCT extends string = string>(fileList: FileList, params?: FileTree.IFileTreeInitParams<TCT>): Promise<Result<FileTree.FileTree<TCT>>>;
108
+ /**
109
+ * Create FileTree from directory upload with webkitRelativePath.
110
+ * @param fileList - FileList from a directory upload (input with webkitdirectory)
111
+ * @param params - Optional `IFileTreeInitParams` for the file tree.
112
+ * @returns Promise resolving to a FileTree with all content pre-loaded
113
+ */
114
+ static fromDirectoryUpload<TCT extends string = string>(fileList: FileList, params?: FileTree.IFileTreeInitParams<TCT>): Promise<Result<FileTree.FileTree<TCT>>>;
115
+ /**
116
+ * Get the File object for a specific path from the original FileList.
117
+ * This is useful for accessing the original File API object for operations
118
+ * like getting file metadata, MIME type, etc.
119
+ * @param fileList - The original FileList
120
+ * @param targetPath - The path to find
121
+ * @returns Result containing the File object if found
122
+ */
123
+ static getOriginalFile(fileList: FileList, targetPath: string): Result<File>;
124
+ /**
125
+ * Extract file metadata from a File.
126
+ * @param fileList - The File to extract metadata from
127
+ * @returns The {@link IFileMetadata | file metadata}
128
+ */
129
+ static extractFileMetadata(file: File): IFileMetadata;
130
+ /**
131
+ * Process a single TreeInitializer and return the resulting files.
132
+ * @param initializer - The TreeInitializer to process
133
+ * @param params - Optional `IFileTreeInitParams` for the file tree.
134
+ * @returns Promise resolving to an array of `IInMemoryFile` objects
135
+ * @internal
136
+ */
137
+ private static _processInitializer;
138
+ /**
139
+ * Process a FileList and return IInMemoryFile array.
140
+ * @param fileList - The FileList to process
141
+ * @param params - Optional `IFileTreeInitParams` for the file tree.
142
+ * @returns Promise resolving to an array of `IInMemoryFile` objects
143
+ * @internal
144
+ */
145
+ private static _processFileList;
146
+ /**
147
+ * Process FileSystemFileHandles and return IInMemoryFile array.
148
+ * @internal
149
+ */
150
+ private static _processFileHandles;
151
+ /**
152
+ * Process FileSystemDirectoryHandles and return IInMemoryFile array.
153
+ * @param handles - The FileSystemDirectoryHandle[] to process
154
+ * @param prefix - The prefix to use for the file paths
155
+ * @param recursive - Whether to process the directory recursively
156
+ * @param params - Optional `IFileTreeInitParams` for the file tree.
157
+ * @returns Promise resolving to an array of `IInMemoryFile` objects
158
+ * @internal
159
+ */
160
+ private static _processDirectoryHandles;
161
+ /**
162
+ * Process a single FileSystemDirectoryHandle recursively.
163
+ * @param handle - The FileSystemDirectoryHandle to process
164
+ * @param basePath - The base path to use for the file paths
165
+ * @param recursive - Whether to process the directory recursively
166
+ * @param params - Optional `IFileTreeInitParams` for the file tree.
167
+ * @returns Promise resolving to an array of `IInMemoryFile` objects
168
+ * @internal
169
+ */
170
+ private static _processDirectoryHandle;
171
+ private static _normalizePath;
172
+ }
173
+
174
+ /**
175
+ * File picker accept type
176
+ * @public
177
+ */
178
+ export declare interface FilePickerAcceptType {
179
+ description?: string;
180
+ accept: Record<string, string | string[]>;
181
+ }
182
+
183
+ /**
184
+ * Options for creating writable file streams
185
+ * @public
186
+ */
187
+ declare interface FileSystemCreateWritableOptions_2 {
188
+ keepExistingData?: boolean;
189
+ }
190
+ export { FileSystemCreateWritableOptions_2 as FileSystemCreateWritableOptions }
191
+
192
+ /**
193
+ * Directory handle interface
194
+ * @public
195
+ */
196
+ declare interface FileSystemDirectoryHandle_2 extends FileSystemHandle_2 {
197
+ readonly kind: 'directory';
198
+ getDirectoryHandle(name: string, options?: FileSystemGetDirectoryOptions_2): Promise<FileSystemDirectoryHandle_2>;
199
+ getFileHandle(name: string, options?: FileSystemGetFileOptions_2): Promise<FileSystemFileHandle_2>;
200
+ removeEntry(name: string, options?: FileSystemRemoveOptions_2): Promise<void>;
201
+ resolve(possibleDescendant: FileSystemHandle_2): Promise<string[] | null>;
202
+ keys(): AsyncIterableIterator<string>;
203
+ values(): AsyncIterableIterator<FileSystemHandle_2>;
204
+ entries(): AsyncIterableIterator<[string, FileSystemHandle_2]>;
205
+ [Symbol.asyncIterator](): AsyncIterableIterator<[string, FileSystemHandle_2]>;
206
+ }
207
+ export { FileSystemDirectoryHandle_2 as FileSystemDirectoryHandle }
208
+
209
+ /**
210
+ * File handle interface
211
+ * @public
212
+ */
213
+ declare interface FileSystemFileHandle_2 extends FileSystemHandle_2 {
214
+ readonly kind: 'file';
215
+ getFile(): Promise<File>;
216
+ createWritable(options?: FileSystemCreateWritableOptions_2): Promise<FileSystemWritableFileStream_2>;
217
+ }
218
+ export { FileSystemFileHandle_2 as FileSystemFileHandle }
219
+
220
+ /**
221
+ * Options for getting directory handles
222
+ * @public
223
+ */
224
+ declare interface FileSystemGetDirectoryOptions_2 {
225
+ create?: boolean;
226
+ }
227
+ export { FileSystemGetDirectoryOptions_2 as FileSystemGetDirectoryOptions }
228
+
229
+ /**
230
+ * Options for getting file handles
231
+ * @public
232
+ */
233
+ declare interface FileSystemGetFileOptions_2 {
234
+ create?: boolean;
235
+ }
236
+ export { FileSystemGetFileOptions_2 as FileSystemGetFileOptions }
237
+
238
+ /**
239
+ * Base interface for file system handles
240
+ * @public
241
+ */
242
+ declare interface FileSystemHandle_2 {
243
+ readonly kind: 'file' | 'directory';
244
+ readonly name: string;
245
+ isSameEntry(other: FileSystemHandle_2): Promise<boolean>;
246
+ queryPermission(descriptor?: FileSystemHandlePermissionDescriptor): Promise<PermissionState>;
247
+ requestPermission(descriptor?: FileSystemHandlePermissionDescriptor): Promise<PermissionState>;
248
+ }
249
+ export { FileSystemHandle_2 as FileSystemHandle }
250
+
251
+ /**
252
+ * Permission descriptor for file system handles
253
+ * @public
254
+ */
255
+ export declare interface FileSystemHandlePermissionDescriptor {
256
+ mode?: 'read' | 'readwrite';
257
+ }
258
+
259
+ /**
260
+ * Options for removing entries
261
+ * @public
262
+ */
263
+ declare interface FileSystemRemoveOptions_2 {
264
+ recursive?: boolean;
265
+ }
266
+ export { FileSystemRemoveOptions_2 as FileSystemRemoveOptions }
267
+
268
+ /**
269
+ * Writable file stream interface
270
+ * @public
271
+ */
272
+ declare interface FileSystemWritableFileStream_2 extends WritableStream {
273
+ write(data: BufferSource | Blob | string): Promise<void>;
274
+ seek(position: number): Promise<void>;
275
+ truncate(size: number): Promise<void>;
276
+ }
277
+ export { FileSystemWritableFileStream_2 as FileSystemWritableFileStream }
278
+
279
+ export declare namespace FileTreeHelpers {
280
+ export {
281
+ fromFileList,
282
+ fromDirectoryUpload,
283
+ getOriginalFile,
284
+ extractFileListMetadata,
285
+ extractFileMetadata,
286
+ defaultFileApiTreeInitParams
287
+ }
288
+ }
289
+
290
+ /**
291
+ * Helper function to create a new FileTree instance
292
+ * from a directory upload with webkitRelativePath support.
293
+ * @param fileList - FileList from a directory upload (input with webkitdirectory)
294
+ * @param params - Optional `IFileTreeInitParams` for the file tree.
295
+ * @returns Promise resolving to a successful Result with the new FileTree instance
296
+ * if successful, or a failed Result with an error message otherwise
297
+ * @remarks The content type of the files is always `string` and the default
298
+ * accept contentType function (`FileTree.FileItem.defaultAcceptContentType`) is
299
+ * is used, so content type is derived from the mime type of the file, when
300
+ * available.
301
+ * @public
302
+ */
303
+ declare function fromDirectoryUpload(fileList: FileList, params?: FileTree.IFileTreeInitParams<string>): Promise<Result<FileTree.FileTree<string>>>;
304
+
305
+ /**
306
+ * Helper function to create a new FileTree instance
307
+ * from a browser FileList (e.g., from input[type="file"]).
308
+ * @param fileList - FileList from a file input element
309
+ * @param params - Optional `IFileTreeInitParams` for the file tree.
310
+ * @returns Promise resolving to a successful Result with the new FileTree instance
311
+ * if successful, or a failed Result with an error message otherwise
312
+ * @remarks The content type of the files is always `string` and the default
313
+ * accept contentType function (`FileTree.FileItem.defaultAcceptContentType`) is
314
+ * used, so content type is derived from the mime type of the file, when
315
+ * available.
316
+ * @public
317
+ */
318
+ declare function fromFileList(fileList: FileList, params?: FileTree.IFileTreeInitParams<string>): Promise<Result<FileTree.FileTree<string>>>;
319
+
320
+ /**
321
+ * Helper function to get the original File object from a FileList by path.
322
+ * @param fileList - The original FileList
323
+ * @param path - The path to the file
324
+ * @returns A successful Result with the File object if found,
325
+ * or a failed Result with an error message otherwise
326
+ * @public
327
+ */
328
+ declare function getOriginalFile(fileList: FileList, path: string): Result<File>;
329
+
330
+ /**
331
+ * Tree initializer for File System Access API directory handles.
332
+ * @public
333
+ */
334
+ export declare interface IDirectoryHandleTreeInitializer {
335
+ readonly prefix?: string;
336
+ readonly dirHandles: FileSystemDirectoryHandle_2[];
337
+ readonly nonRecursive?: boolean;
338
+ }
339
+
340
+ /**
341
+ * Tree initializer for File System Access API file handles.
342
+ * @public
343
+ */
344
+ export declare interface IFileHandleTreeInitializer {
345
+ readonly prefix?: string;
346
+ readonly fileHandles: FileSystemFileHandle_2[];
347
+ }
348
+
349
+ /**
350
+ * Tree initializer for FileList objects (from File API).
351
+ * @public
352
+ */
353
+ export declare interface IFileListTreeInitializer {
354
+ readonly fileList: FileList;
355
+ }
356
+
357
+ /**
358
+ * Interface for file metadata.
359
+ * @public
360
+ */
361
+ export declare interface IFileMetadata {
362
+ path: string;
363
+ name: string;
364
+ size: number;
365
+ type: string;
366
+ lastModified: number;
367
+ }
368
+
369
+ /**
370
+ * File System Access API methods available on Window
371
+ * @public
372
+ */
373
+ export declare interface IFsAccessApis {
374
+ showDirectoryPicker(options?: ShowDirectoryPickerOptions): Promise<FileSystemDirectoryHandle_2>;
375
+ showOpenFilePicker(options?: ShowOpenFilePickerOptions): Promise<FileSystemFileHandle_2[]>;
376
+ showSaveFilePicker(options?: ShowSaveFilePickerOptions): Promise<FileSystemFileHandle_2>;
377
+ }
378
+
379
+ /**
380
+ * Type guard to check if a FileSystemHandle is a directory handle
381
+ * @param handle - The handle to check
382
+ * @returns True if the handle is a FileSystemDirectoryHandle
383
+ * @public
384
+ */
385
+ export declare function isDirectoryHandle(handle: FileSystemHandle_2): handle is FileSystemDirectoryHandle_2;
386
+
387
+ /**
388
+ * Type guard to check if a FileSystemHandle is a file handle
389
+ * @param handle - The handle to check
390
+ * @returns True if the handle is a FileSystemFileHandle
391
+ * @public
392
+ */
393
+ export declare function isFileHandle(handle: FileSystemHandle_2): handle is FileSystemFileHandle_2;
394
+
395
+ /**
396
+ * Determines if a path appears to be a file (has extension) or directory
397
+ * @public
398
+ */
399
+ export declare function isFilePath(path: string): boolean;
400
+
401
+ /**
402
+ * Configuration options that can be passed via URL parameters
403
+ * @public
404
+ */
405
+ export declare interface IUrlConfigOptions {
406
+ /**
407
+ * Input file path
408
+ */
409
+ input?: string;
410
+ /**
411
+ * Configuration name or path
412
+ */
413
+ config?: string;
414
+ /**
415
+ * Context filter token (pipe-separated)
416
+ */
417
+ contextFilter?: string;
418
+ /**
419
+ * Qualifier defaults token (pipe-separated)
420
+ */
421
+ qualifierDefaults?: string;
422
+ /**
423
+ * Resource types filter (comma-separated)
424
+ */
425
+ resourceTypes?: string;
426
+ /**
427
+ * Maximum distance for language matching
428
+ */
429
+ maxDistance?: number;
430
+ /**
431
+ * Whether to reduce qualifiers
432
+ */
433
+ reduceQualifiers?: boolean;
434
+ /**
435
+ * Whether to launch in interactive mode
436
+ */
437
+ interactive?: boolean;
438
+ /**
439
+ * Starting directory for input file picker (derived from input path)
440
+ */
441
+ inputStartDir?: string;
442
+ /**
443
+ * Starting directory for config file picker (derived from config path)
444
+ */
445
+ configStartDir?: string;
446
+ /**
447
+ * Whether to use ZIP loading mode
448
+ */
449
+ loadZip?: boolean;
450
+ /**
451
+ * Path to ZIP file to load (for CLI-generated ZIPs)
452
+ */
453
+ zipPath?: string;
454
+ /**
455
+ * Name of ZIP file to load from Downloads (filename only)
456
+ */
457
+ zipFile?: string;
458
+ }
459
+
460
+ /**
461
+ * Converts context filter token to context object
462
+ * Example: "language=en-US|territory=US" -\> \{ language: "en-US", territory: "US" \}
463
+ * @public
464
+ */
465
+ export declare function parseContextFilter(contextFilter: string): Record<string, string>;
466
+
467
+ /**
468
+ * Converts qualifier defaults token to structured format
469
+ * Example: "language=en-US,en-CA|territory=US" -\> \{ language: ["en-US", "en-CA"], territory: ["US"] \}
470
+ * @public
471
+ */
472
+ export declare function parseQualifierDefaults(qualifierDefaults: string): Record<string, string[]>;
473
+
474
+ /**
475
+ * Converts resource types string to array
476
+ * Example: "json,string" -\> ["json", "string"]
477
+ * @public
478
+ */
479
+ export declare function parseResourceTypes(resourceTypes: string): string[];
480
+
481
+ /**
482
+ * Parses URL parameters and extracts configuration options
483
+ * @public
484
+ */
485
+ export declare function parseUrlParameters(): IUrlConfigOptions;
486
+
487
+ /**
488
+ * Safely access showDirectoryPicker with proper type checking
489
+ * @param window - The window object
490
+ * @param options - Options for the directory picker
491
+ * @returns Promise with directory handle or null if not supported
492
+ * @public
493
+ */
494
+ export declare function safeShowDirectoryPicker(window: Window, options?: ShowDirectoryPickerOptions): Promise<FileSystemDirectoryHandle_2 | null>;
495
+
496
+ /**
497
+ * Safely access showOpenFilePicker with proper type checking
498
+ * @param window - The window object
499
+ * @param options - Options for the file picker
500
+ * @returns Promise with file handles or null if not supported
501
+ * @public
502
+ */
503
+ export declare function safeShowOpenFilePicker(window: Window, options?: ShowOpenFilePickerOptions): Promise<FileSystemFileHandle_2[] | null>;
504
+
505
+ /**
506
+ * Safely access showSaveFilePicker with proper type checking
507
+ * @param window - The window object
508
+ * @param options - Options for the file picker
509
+ * @returns Promise with file handle or null if not supported
510
+ * @public
511
+ */
512
+ export declare function safeShowSaveFilePicker(window: Window, options?: ShowSaveFilePickerOptions): Promise<FileSystemFileHandle_2 | null>;
513
+
514
+ /**
515
+ * Directory picker options
516
+ * @public
517
+ */
518
+ export declare interface ShowDirectoryPickerOptions {
519
+ id?: string;
520
+ mode?: 'read' | 'readwrite';
521
+ startIn?: FileSystemHandle_2 | WellKnownDirectory;
522
+ }
523
+
524
+ /**
525
+ * File picker options
526
+ * @public
527
+ */
528
+ export declare interface ShowOpenFilePickerOptions {
529
+ multiple?: boolean;
530
+ excludeAcceptAllOption?: boolean;
531
+ id?: string;
532
+ startIn?: FileSystemHandle_2 | WellKnownDirectory;
533
+ types?: FilePickerAcceptType[];
534
+ }
535
+
536
+ /**
537
+ * Save file picker options
538
+ * @public
539
+ */
540
+ export declare interface ShowSaveFilePickerOptions {
541
+ excludeAcceptAllOption?: boolean;
542
+ id?: string;
543
+ startIn?: FileSystemHandle_2 | WellKnownDirectory;
544
+ suggestedName?: string;
545
+ types?: FilePickerAcceptType[];
546
+ }
547
+
548
+ /**
549
+ * Type guard to check if the browser supports the File System Access API
550
+ * @param window - The window object to check
551
+ * @returns True if the window supports File System Access API
552
+ * @public
553
+ */
554
+ export declare function supportsFileSystemAccess(window: Window): window is WindowWithFsAccess;
555
+
556
+ /**
557
+ * Union type for all supported tree initializers.
558
+ * @public
559
+ */
560
+ export declare type TreeInitializer = IFileListTreeInitializer | IFileHandleTreeInitializer | IDirectoryHandleTreeInitializer;
561
+
562
+ /**
563
+ * Well-known directory type
564
+ * @public
565
+ */
566
+ export declare type WellKnownDirectory = 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos';
567
+
568
+ /**
569
+ * Window interface extended with File System Access API
570
+ * @public
571
+ */
572
+ export declare type WindowWithFsAccess = Window & IFsAccessApis;
573
+
574
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.52.12"
9
+ }
10
+ ]
11
+ }
package/docs/index.md ADDED
@@ -0,0 +1,34 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md)
4
+
5
+ ## API Reference
6
+
7
+ ## Packages
8
+
9
+ <table><thead><tr><th>
10
+
11
+ Package
12
+
13
+
14
+ </th><th>
15
+
16
+ Description
17
+
18
+
19
+ </th></tr></thead>
20
+ <tbody><tr><td>
21
+
22
+ [@fgv/ts-web-extras](./ts-web-extras.md)
23
+
24
+
25
+ </td><td>
26
+
27
+ Browser-compatible utilities and FileTree implementations.
28
+
29
+ This library provides browser-compatible alternatives to Node.js-specific functionality, including Web Crypto API-based hashing, File API-based file tree implementations, and URL parameter parsing utilities. All exports are designed to be tree-shakeable for optimal bundle size.
30
+
31
+
32
+ </td></tr>
33
+ </tbody></table>
34
+
@@ -0,0 +1,88 @@
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; [BrowserHashProvider](./ts-web-extras.browserhashprovider.md) &gt; [hashParts](./ts-web-extras.browserhashprovider.hashparts.md)
4
+
5
+ ## BrowserHashProvider.hashParts() method
6
+
7
+ Hash multiple strings concatenated with a separator.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ static hashParts(parts: string[], algorithm?: string, separator?: string): Promise<Result<string>>;
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
+ parts
36
+
37
+
38
+ </td><td>
39
+
40
+ string\[\]
41
+
42
+
43
+ </td><td>
44
+
45
+ Array of strings to concatenate and hash
46
+
47
+
48
+ </td></tr>
49
+ <tr><td>
50
+
51
+ algorithm
52
+
53
+
54
+ </td><td>
55
+
56
+ string
57
+
58
+
59
+ </td><td>
60
+
61
+ _(Optional)_ The hash algorithm to use
62
+
63
+
64
+ </td></tr>
65
+ <tr><td>
66
+
67
+ separator
68
+
69
+
70
+ </td><td>
71
+
72
+ string
73
+
74
+
75
+ </td><td>
76
+
77
+ _(Optional)_ Separator to use between parts (default: '\|')
78
+
79
+
80
+ </td></tr>
81
+ </tbody></table>
82
+
83
+ **Returns:**
84
+
85
+ Promise&lt;Result&lt;string&gt;&gt;
86
+
87
+ Promise resolving to the hex-encoded hash
88
+