@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,245 @@
1
+ /*
2
+ * Copyright (c) 2025 Erik Fortune
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in all
12
+ * copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+ /**
24
+ * Configuration options that can be passed via URL parameters
25
+ * @public
26
+ */
27
+ export interface IUrlConfigOptions {
28
+ /**
29
+ * Input file path
30
+ */
31
+ input?: string;
32
+
33
+ /**
34
+ * Configuration name or path
35
+ */
36
+ config?: string;
37
+
38
+ /**
39
+ * Context filter token (pipe-separated)
40
+ */
41
+ contextFilter?: string;
42
+
43
+ /**
44
+ * Qualifier defaults token (pipe-separated)
45
+ */
46
+ qualifierDefaults?: string;
47
+
48
+ /**
49
+ * Resource types filter (comma-separated)
50
+ */
51
+ resourceTypes?: string;
52
+
53
+ /**
54
+ * Maximum distance for language matching
55
+ */
56
+ maxDistance?: number;
57
+
58
+ /**
59
+ * Whether to reduce qualifiers
60
+ */
61
+ reduceQualifiers?: boolean;
62
+
63
+ /**
64
+ * Whether to launch in interactive mode
65
+ */
66
+ interactive?: boolean;
67
+
68
+ /**
69
+ * Starting directory for input file picker (derived from input path)
70
+ */
71
+ inputStartDir?: string;
72
+
73
+ /**
74
+ * Starting directory for config file picker (derived from config path)
75
+ */
76
+ configStartDir?: string;
77
+
78
+ /**
79
+ * Whether to use ZIP loading mode
80
+ */
81
+ loadZip?: boolean;
82
+
83
+ /**
84
+ * Path to ZIP file to load (for CLI-generated ZIPs)
85
+ */
86
+ zipPath?: string;
87
+
88
+ /**
89
+ * Name of ZIP file to load from Downloads (filename only)
90
+ */
91
+ zipFile?: string;
92
+ }
93
+
94
+ /**
95
+ * Parses URL parameters and extracts configuration options
96
+ * @public
97
+ */
98
+ export function parseUrlParameters(): IUrlConfigOptions {
99
+ const params = new URLSearchParams(window.location.search);
100
+
101
+ const options: IUrlConfigOptions = {};
102
+
103
+ // Parse string parameters
104
+ const input = params.get('input');
105
+ if (input) {
106
+ options.input = input;
107
+ // Set starting directory for input file picker
108
+ if (isFilePath(input)) {
109
+ options.inputStartDir = extractDirectoryPath(input);
110
+ }
111
+ }
112
+
113
+ const config = params.get('config');
114
+ if (config) {
115
+ options.config = config;
116
+ // Set starting directory for config file picker
117
+ if (isFilePath(config)) {
118
+ options.configStartDir = extractDirectoryPath(config);
119
+ }
120
+ }
121
+
122
+ const contextFilter = params.get('contextFilter');
123
+ if (contextFilter) options.contextFilter = contextFilter;
124
+
125
+ const qualifierDefaults = params.get('qualifierDefaults');
126
+ if (qualifierDefaults) options.qualifierDefaults = qualifierDefaults;
127
+
128
+ const resourceTypes = params.get('resourceTypes');
129
+ if (resourceTypes) options.resourceTypes = resourceTypes;
130
+
131
+ // Parse numeric parameters
132
+ const maxDistance = params.get('maxDistance');
133
+ if (maxDistance) {
134
+ const parsed = parseInt(maxDistance, 10);
135
+ if (!isNaN(parsed)) options.maxDistance = parsed;
136
+ }
137
+
138
+ // Parse boolean parameters
139
+ const reduceQualifiers = params.get('reduceQualifiers');
140
+ if (reduceQualifiers === 'true') options.reduceQualifiers = true;
141
+
142
+ const interactive = params.get('interactive');
143
+ if (interactive === 'true') options.interactive = true;
144
+
145
+ // Parse ZIP loading parameters
146
+ const loadZip = params.get('loadZip');
147
+ if (loadZip === 'true') options.loadZip = true;
148
+
149
+ const zipPath = params.get('zipPath');
150
+ if (zipPath) options.zipPath = zipPath;
151
+
152
+ const zipFile = params.get('zipFile');
153
+ if (zipFile) options.zipFile = zipFile;
154
+
155
+ return options;
156
+ }
157
+
158
+ /**
159
+ * Converts context filter token to context object
160
+ * Example: "language=en-US|territory=US" -\> \{ language: "en-US", territory: "US" \}
161
+ * @public
162
+ */
163
+ export function parseContextFilter(contextFilter: string): Record<string, string> {
164
+ const context: Record<string, string> = {};
165
+
166
+ const tokens = contextFilter.split('|');
167
+ for (const token of tokens) {
168
+ const [key, value] = token.split('=');
169
+ if (key && value) {
170
+ context[key.trim()] = value.trim();
171
+ }
172
+ }
173
+
174
+ return context;
175
+ }
176
+
177
+ /**
178
+ * Converts qualifier defaults token to structured format
179
+ * Example: "language=en-US,en-CA|territory=US" -\> \{ language: ["en-US", "en-CA"], territory: ["US"] \}
180
+ * @public
181
+ */
182
+ export function parseQualifierDefaults(qualifierDefaults: string): Record<string, string[]> {
183
+ const defaults: Record<string, string[]> = {};
184
+
185
+ const tokens = qualifierDefaults.split('|');
186
+ for (const token of tokens) {
187
+ const [key, values] = token.split('=');
188
+ if (key && values) {
189
+ defaults[key.trim()] = values.split(',').map((v) => v.trim());
190
+ }
191
+ }
192
+
193
+ return defaults;
194
+ }
195
+
196
+ /**
197
+ * Converts resource types string to array
198
+ * Example: "json,string" -\> ["json", "string"]
199
+ * @public
200
+ */
201
+ export function parseResourceTypes(resourceTypes: string): string[] {
202
+ return resourceTypes
203
+ .split(',')
204
+ .map((t) => t.trim())
205
+ .filter((t) => t.length > 0);
206
+ }
207
+
208
+ /**
209
+ * Extracts the directory path from a file or directory path
210
+ * If the path appears to be a directory (no extension), returns it as-is
211
+ * If the path appears to be a file, returns the parent directory
212
+ * @public
213
+ */
214
+ export function extractDirectoryPath(path: string): string {
215
+ if (!path) return '';
216
+
217
+ // Normalize path separators
218
+ const normalizedPath = path.replace(/\\/g, '/');
219
+
220
+ // Check if it looks like a file (has an extension)
221
+ const parts = normalizedPath.split('/');
222
+ const lastPart = parts[parts.length - 1];
223
+
224
+ // If the last part has an extension, treat as file and return directory
225
+ if (lastPart.includes('.') && !lastPart.startsWith('.')) {
226
+ return parts.slice(0, -1).join('/') || '/';
227
+ }
228
+
229
+ // Otherwise, treat as directory
230
+ return normalizedPath;
231
+ }
232
+
233
+ /**
234
+ * Determines if a path appears to be a file (has extension) or directory
235
+ * @public
236
+ */
237
+ export function isFilePath(path: string): boolean {
238
+ if (!path) return false;
239
+
240
+ const parts = path.split('/');
241
+ const lastPart = parts[parts.length - 1];
242
+
243
+ // Has extension and doesn't start with dot (hidden files)
244
+ return lastPart.includes('.') && !lastPart.startsWith('.');
245
+ }
@@ -0,0 +1,87 @@
1
+ /*
2
+ * Copyright (c) 2025 Erik Fortune
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in all
12
+ * copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+ import { webcrypto } from 'crypto';
24
+ import { TextEncoder, TextDecoder } from 'util';
25
+
26
+ // Setup Web Crypto API using Node.js webcrypto
27
+ Object.defineProperty(global, 'crypto', {
28
+ value: webcrypto,
29
+ writable: true,
30
+ configurable: true
31
+ });
32
+
33
+ // Setup TextEncoder/TextDecoder for Node environment
34
+ Object.defineProperty(global, 'TextEncoder', {
35
+ value: TextEncoder,
36
+ writable: true,
37
+ configurable: true
38
+ });
39
+
40
+ Object.defineProperty(global, 'TextDecoder', {
41
+ value: TextDecoder,
42
+ writable: true,
43
+ configurable: true
44
+ });
45
+
46
+ // Mock DataTransfer for File API testing
47
+ class MockDataTransfer {
48
+ items: { add: (file: File) => void };
49
+ files: FileList;
50
+
51
+ constructor() {
52
+ const fileArray: File[] = [];
53
+
54
+ this.items = {
55
+ add: (file: File) => {
56
+ fileArray.push(file);
57
+ this.files = createFileList(fileArray);
58
+ }
59
+ };
60
+
61
+ this.files = createFileList([]);
62
+ }
63
+ }
64
+
65
+ function createFileList(files: File[]): FileList {
66
+ const fileList = {
67
+ length: files.length,
68
+ item: (index: number) => files[index] || null,
69
+ [Symbol.iterator]: function* () {
70
+ for (const file of files) {
71
+ yield file;
72
+ }
73
+ }
74
+ };
75
+
76
+ for (let i = 0; i < files.length; i++) {
77
+ (fileList as unknown as Record<number, File>)[i] = files[i];
78
+ }
79
+
80
+ return fileList as unknown as FileList;
81
+ }
82
+
83
+ Object.defineProperty(global, 'DataTransfer', {
84
+ value: MockDataTransfer,
85
+ writable: true,
86
+ configurable: true
87
+ });
@@ -0,0 +1,155 @@
1
+ /*
2
+ * Copyright (c) 2025 Erik Fortune
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in all
12
+ * copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+ import '@fgv/ts-utils-jest';
24
+ import { BrowserHashProvider } from '../../packlets/crypto';
25
+
26
+ describe('BrowserHashProvider', () => {
27
+ describe('hashString', () => {
28
+ test('successfully hashes a string with SHA-256', async () => {
29
+ const result = await BrowserHashProvider.hashString('test data', 'SHA-256');
30
+ expect(result).toSucceedAndSatisfy((hash) => {
31
+ expect(typeof hash).toBe('string');
32
+ expect(hash).toMatch(/^[a-f0-9]{64}$/); // SHA-256 produces 64 hex characters
33
+ });
34
+ });
35
+
36
+ test('successfully hashes a string with SHA-1', async () => {
37
+ const result = await BrowserHashProvider.hashString('test data', 'SHA-1');
38
+ expect(result).toSucceedAndSatisfy((hash) => {
39
+ expect(typeof hash).toBe('string');
40
+ expect(hash).toMatch(/^[a-f0-9]{40}$/); // SHA-1 produces 40 hex characters
41
+ });
42
+ });
43
+
44
+ test('successfully hashes a string with SHA-512', async () => {
45
+ const result = await BrowserHashProvider.hashString('test data', 'SHA-512');
46
+ expect(result).toSucceedAndSatisfy((hash) => {
47
+ expect(typeof hash).toBe('string');
48
+ expect(hash).toMatch(/^[a-f0-9]{128}$/); // SHA-512 produces 128 hex characters
49
+ });
50
+ });
51
+
52
+ test('uses SHA-256 as default algorithm', async () => {
53
+ const result = await BrowserHashProvider.hashString('test data');
54
+ expect(result).toSucceedAndSatisfy((hash) => {
55
+ expect(hash).toMatch(/^[a-f0-9]{64}$/); // SHA-256 produces 64 hex characters
56
+ });
57
+ });
58
+
59
+ test('produces consistent hash for same input', async () => {
60
+ const input = 'consistent input';
61
+ const result1 = await BrowserHashProvider.hashString(input);
62
+ const result2 = await BrowserHashProvider.hashString(input);
63
+ expect(result1).toSucceed();
64
+ expect(result2).toSucceed();
65
+ if (result1.isSuccess() && result2.isSuccess()) {
66
+ expect(result1.value).toBe(result2.value);
67
+ }
68
+ });
69
+
70
+ test('produces different hashes for different inputs', async () => {
71
+ const result1 = await BrowserHashProvider.hashString('input1');
72
+ const result2 = await BrowserHashProvider.hashString('input2');
73
+ expect(result1).toSucceed();
74
+ expect(result2).toSucceed();
75
+ if (result1.isSuccess() && result2.isSuccess()) {
76
+ expect(result1.value).not.toBe(result2.value);
77
+ }
78
+ });
79
+
80
+ test('handles empty string input', async () => {
81
+ const result = await BrowserHashProvider.hashString('');
82
+ expect(result).toSucceed();
83
+ });
84
+
85
+ test('handles unicode input', async () => {
86
+ const result = await BrowserHashProvider.hashString('🚀 Unicode test 测试');
87
+ expect(result).toSucceedAndSatisfy((hash) => {
88
+ expect(hash).toMatch(/^[a-f0-9]{64}$/);
89
+ });
90
+ });
91
+
92
+ test('fails when crypto.subtle is unavailable', async () => {
93
+ const originalCrypto = global.crypto;
94
+ // @ts-ignore - Intentionally removing crypto for test
95
+ delete global.crypto;
96
+ const result = await BrowserHashProvider.hashString('test');
97
+ expect(result).toFailWith(/Hash computation failed/);
98
+ global.crypto = originalCrypto;
99
+ });
100
+
101
+ test('handles invalid algorithm gracefully', async () => {
102
+ const result = await BrowserHashProvider.hashString('test', 'INVALID-ALG');
103
+ expect(result).toFailWith(/Hash computation failed/);
104
+ });
105
+ });
106
+
107
+ describe('hashParts', () => {
108
+ test('hashes multiple parts with default separator', async () => {
109
+ const parts = ['part1', 'part2', 'part3'];
110
+ const result = await BrowserHashProvider.hashParts(parts);
111
+ expect(result).toSucceedAndSatisfy((hash) => {
112
+ expect(hash).toMatch(/^[a-f0-9]{64}$/);
113
+ });
114
+ });
115
+
116
+ test('hashes multiple parts with custom separator', async () => {
117
+ const parts = ['part1', 'part2', 'part3'];
118
+ const result1 = await BrowserHashProvider.hashParts(parts, 'SHA-256', '|');
119
+ const result2 = await BrowserHashProvider.hashParts(parts, 'SHA-256', ',');
120
+ expect(result1).toSucceed();
121
+ expect(result2).toSucceed();
122
+ if (result1.isSuccess() && result2.isSuccess()) {
123
+ expect(result1.value).not.toBe(result2.value);
124
+ }
125
+ });
126
+
127
+ test('produces same hash as hashString for joined parts', async () => {
128
+ const parts = ['a', 'b', 'c'];
129
+ const separator = '-';
130
+ const joined = parts.join(separator);
131
+ const partsResult = await BrowserHashProvider.hashParts(parts, 'SHA-256', separator);
132
+ const stringResult = await BrowserHashProvider.hashString(joined);
133
+ expect(partsResult).toSucceed();
134
+ expect(stringResult).toSucceed();
135
+ if (partsResult.isSuccess() && stringResult.isSuccess()) {
136
+ expect(partsResult.value).toBe(stringResult.value);
137
+ }
138
+ });
139
+
140
+ test('handles empty array', async () => {
141
+ const result = await BrowserHashProvider.hashParts([]);
142
+ expect(result).toSucceed();
143
+ });
144
+
145
+ test('handles single part', async () => {
146
+ const result = await BrowserHashProvider.hashParts(['single']);
147
+ const stringResult = await BrowserHashProvider.hashString('single');
148
+ expect(result).toSucceed();
149
+ expect(stringResult).toSucceed();
150
+ if (result.isSuccess() && stringResult.isSuccess()) {
151
+ expect(result.value).toBe(stringResult.value);
152
+ }
153
+ });
154
+ });
155
+ });