@fgv/ts-web-extras 5.1.0-2 → 5.1.0-21

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 (263) hide show
  1. package/dist/packlets/crypto-utils/browserCryptoProvider.js +208 -18
  2. package/dist/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
  3. package/dist/packlets/file-tree/fileApiTreeAccessors.js +1 -1
  4. package/dist/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
  5. package/dist/packlets/file-tree/httpTreeAccessors.js +72 -42
  6. package/dist/packlets/file-tree/httpTreeAccessors.js.map +1 -1
  7. package/dist/ts-web-extras.d.ts +59 -7
  8. package/dist/tsdoc-metadata.json +1 -1
  9. package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts +52 -5
  10. package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts.map +1 -1
  11. package/lib/packlets/crypto-utils/browserCryptoProvider.js +207 -17
  12. package/lib/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
  13. package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts +1 -1
  14. package/lib/packlets/file-tree/fileApiTreeAccessors.js +1 -1
  15. package/lib/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
  16. package/lib/packlets/file-tree/httpTreeAccessors.d.ts +6 -0
  17. package/lib/packlets/file-tree/httpTreeAccessors.d.ts.map +1 -1
  18. package/lib/packlets/file-tree/httpTreeAccessors.js +72 -42
  19. package/lib/packlets/file-tree/httpTreeAccessors.js.map +1 -1
  20. package/package.json +27 -26
  21. package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +0 -75
  22. package/.rush/temp/chunked-rush-logs/ts-web-extras.test.chunks.jsonl +0 -75
  23. package/.rush/temp/operation/build/all.log +0 -75
  24. package/.rush/temp/operation/build/error.log +0 -18
  25. package/.rush/temp/operation/build/log-chunks.jsonl +0 -75
  26. package/.rush/temp/operation/build/state.json +0 -3
  27. package/.rush/temp/operation/test/all.log +0 -75
  28. package/.rush/temp/operation/test/error.log +0 -18
  29. package/.rush/temp/operation/test/log-chunks.jsonl +0 -75
  30. package/.rush/temp/operation/test/state.json +0 -3
  31. package/.rush/temp/shrinkwrap-deps.json +0 -635
  32. package/CHANGELOG.md +0 -23
  33. package/config/api-extractor.json +0 -343
  34. package/config/jest.config.json +0 -19
  35. package/config/rig.json +0 -16
  36. package/config/typedoc.json +0 -6
  37. package/dist/test/mocks/idb-keyval.js +0 -6
  38. package/dist/test/mocks/idb-keyval.js.map +0 -1
  39. package/dist/test/setupTests.js +0 -74
  40. package/dist/test/setupTests.js.map +0 -1
  41. package/dist/test/unit/browserHashProvider.test.js +0 -140
  42. package/dist/test/unit/browserHashProvider.test.js.map +0 -1
  43. package/dist/test/unit/directoryHandleStore.test.js +0 -190
  44. package/dist/test/unit/directoryHandleStore.test.js.map +0 -1
  45. package/dist/test/unit/fileApiTreeAccessors.test.js +0 -1188
  46. package/dist/test/unit/fileApiTreeAccessors.test.js.map +0 -1
  47. package/dist/test/unit/fileApiTypes.test.js +0 -472
  48. package/dist/test/unit/fileApiTypes.test.js.map +0 -1
  49. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js +0 -622
  50. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
  51. package/dist/test/unit/fileTreeHelpers.test.js +0 -590
  52. package/dist/test/unit/fileTreeHelpers.test.js.map +0 -1
  53. package/dist/test/unit/httpTreeAccessors.test.js +0 -1229
  54. package/dist/test/unit/httpTreeAccessors.test.js.map +0 -1
  55. package/dist/test/unit/localStorageTreeAccessors.test.js +0 -812
  56. package/dist/test/unit/localStorageTreeAccessors.test.js.map +0 -1
  57. package/dist/test/unit/urlParams.test.js +0 -393
  58. package/dist/test/unit/urlParams.test.js.map +0 -1
  59. package/dist/test/utils/fileSystemAccessMocks.js +0 -271
  60. package/dist/test/utils/fileSystemAccessMocks.js.map +0 -1
  61. package/dist/test/utils/testHelpers.js +0 -124
  62. package/dist/test/utils/testHelpers.js.map +0 -1
  63. package/docs/@fgv/namespaces/CryptoUtils/README.md +0 -18
  64. package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserCryptoProvider.md +0 -203
  65. package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserHashProvider.md +0 -63
  66. package/docs/@fgv/namespaces/CryptoUtils/functions/createBrowserCryptoProvider.md +0 -18
  67. package/docs/@fgv/namespaces/FileTreeHelpers/README.md +0 -19
  68. package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileListMetadata.md +0 -23
  69. package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileMetadata.md +0 -23
  70. package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromDirectoryUpload.md +0 -33
  71. package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromFileList.md +0 -33
  72. package/docs/@fgv/namespaces/FileTreeHelpers/functions/getOriginalFile.md +0 -25
  73. package/docs/@fgv/namespaces/FileTreeHelpers/variables/defaultFileApiTreeInitParams.md +0 -11
  74. package/docs/README.md +0 -78
  75. package/docs/classes/DirectoryHandleStore.md +0 -116
  76. package/docs/classes/FileApiTreeAccessors.md +0 -286
  77. package/docs/classes/FileSystemAccessTreeAccessors.md +0 -557
  78. package/docs/classes/HttpTreeAccessors.md +0 -508
  79. package/docs/classes/LocalStorageTreeAccessors.md +0 -520
  80. package/docs/functions/exportAsJson.md +0 -23
  81. package/docs/functions/exportUsingFileSystemAPI.md +0 -26
  82. package/docs/functions/extractDirectoryPath.md +0 -23
  83. package/docs/functions/isDirectoryHandle.md +0 -23
  84. package/docs/functions/isFileHandle.md +0 -23
  85. package/docs/functions/isFilePath.md +0 -21
  86. package/docs/functions/parseContextFilter.md +0 -22
  87. package/docs/functions/parseQualifierDefaults.md +0 -22
  88. package/docs/functions/parseResourceTypes.md +0 -22
  89. package/docs/functions/parseUrlParameters.md +0 -15
  90. package/docs/functions/safeShowDirectoryPicker.md +0 -24
  91. package/docs/functions/safeShowOpenFilePicker.md +0 -24
  92. package/docs/functions/safeShowSaveFilePicker.md +0 -24
  93. package/docs/functions/supportsFileSystemAccess.md +0 -23
  94. package/docs/interfaces/FilePickerAcceptType.md +0 -16
  95. package/docs/interfaces/FileSystemCreateWritableOptions.md +0 -15
  96. package/docs/interfaces/FileSystemDirectoryHandle.md +0 -187
  97. package/docs/interfaces/FileSystemFileHandle.md +0 -106
  98. package/docs/interfaces/FileSystemGetDirectoryOptions.md +0 -15
  99. package/docs/interfaces/FileSystemGetFileOptions.md +0 -15
  100. package/docs/interfaces/FileSystemHandle.md +0 -69
  101. package/docs/interfaces/FileSystemHandlePermissionDescriptor.md +0 -15
  102. package/docs/interfaces/FileSystemRemoveOptions.md +0 -15
  103. package/docs/interfaces/FileSystemWritableFileStream.md +0 -127
  104. package/docs/interfaces/IDirectoryHandleTreeInitializer.md +0 -17
  105. package/docs/interfaces/IFileHandleTreeInitializer.md +0 -16
  106. package/docs/interfaces/IFileListTreeInitializer.md +0 -15
  107. package/docs/interfaces/IFileMetadata.md +0 -19
  108. package/docs/interfaces/IFileSystemAccessTreeParams.md +0 -30
  109. package/docs/interfaces/IFsAccessApis.md +0 -57
  110. package/docs/interfaces/IHttpTreeParams.md +0 -32
  111. package/docs/interfaces/ILocalStorageTreeParams.md +0 -30
  112. package/docs/interfaces/IUrlConfigOptions.md +0 -27
  113. package/docs/interfaces/ShowDirectoryPickerOptions.md +0 -17
  114. package/docs/interfaces/ShowOpenFilePickerOptions.md +0 -19
  115. package/docs/interfaces/ShowSaveFilePickerOptions.md +0 -19
  116. package/docs/type-aliases/TreeInitializer.md +0 -11
  117. package/docs/type-aliases/WellKnownDirectory.md +0 -11
  118. package/docs/type-aliases/WindowWithFsAccess.md +0 -11
  119. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_DB.md +0 -11
  120. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_STORE.md +0 -11
  121. package/etc/ts-web-extras.api.md +0 -433
  122. package/lib/test/mocks/idb-keyval.d.ts +0 -6
  123. package/lib/test/mocks/idb-keyval.d.ts.map +0 -1
  124. package/lib/test/mocks/idb-keyval.js +0 -9
  125. package/lib/test/mocks/idb-keyval.js.map +0 -1
  126. package/lib/test/setupTests.d.ts +0 -2
  127. package/lib/test/setupTests.d.ts.map +0 -1
  128. package/lib/test/setupTests.js +0 -76
  129. package/lib/test/setupTests.js.map +0 -1
  130. package/lib/test/unit/browserHashProvider.test.d.ts +0 -2
  131. package/lib/test/unit/browserHashProvider.test.d.ts.map +0 -1
  132. package/lib/test/unit/browserHashProvider.test.js +0 -142
  133. package/lib/test/unit/browserHashProvider.test.js.map +0 -1
  134. package/lib/test/unit/directoryHandleStore.test.d.ts +0 -2
  135. package/lib/test/unit/directoryHandleStore.test.d.ts.map +0 -1
  136. package/lib/test/unit/directoryHandleStore.test.js +0 -192
  137. package/lib/test/unit/directoryHandleStore.test.js.map +0 -1
  138. package/lib/test/unit/fileApiTreeAccessors.test.d.ts +0 -2
  139. package/lib/test/unit/fileApiTreeAccessors.test.d.ts.map +0 -1
  140. package/lib/test/unit/fileApiTreeAccessors.test.js +0 -1190
  141. package/lib/test/unit/fileApiTreeAccessors.test.js.map +0 -1
  142. package/lib/test/unit/fileApiTypes.test.d.ts +0 -2
  143. package/lib/test/unit/fileApiTypes.test.d.ts.map +0 -1
  144. package/lib/test/unit/fileApiTypes.test.js +0 -474
  145. package/lib/test/unit/fileApiTypes.test.js.map +0 -1
  146. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts +0 -2
  147. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts.map +0 -1
  148. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js +0 -624
  149. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
  150. package/lib/test/unit/fileTreeHelpers.test.d.ts +0 -2
  151. package/lib/test/unit/fileTreeHelpers.test.d.ts.map +0 -1
  152. package/lib/test/unit/fileTreeHelpers.test.js +0 -592
  153. package/lib/test/unit/fileTreeHelpers.test.js.map +0 -1
  154. package/lib/test/unit/httpTreeAccessors.test.d.ts +0 -2
  155. package/lib/test/unit/httpTreeAccessors.test.d.ts.map +0 -1
  156. package/lib/test/unit/httpTreeAccessors.test.js +0 -1231
  157. package/lib/test/unit/httpTreeAccessors.test.js.map +0 -1
  158. package/lib/test/unit/localStorageTreeAccessors.test.d.ts +0 -2
  159. package/lib/test/unit/localStorageTreeAccessors.test.d.ts.map +0 -1
  160. package/lib/test/unit/localStorageTreeAccessors.test.js +0 -814
  161. package/lib/test/unit/localStorageTreeAccessors.test.js.map +0 -1
  162. package/lib/test/unit/urlParams.test.d.ts +0 -2
  163. package/lib/test/unit/urlParams.test.d.ts.map +0 -1
  164. package/lib/test/unit/urlParams.test.js +0 -395
  165. package/lib/test/unit/urlParams.test.js.map +0 -1
  166. package/lib/test/utils/fileSystemAccessMocks.d.ts +0 -53
  167. package/lib/test/utils/fileSystemAccessMocks.d.ts.map +0 -1
  168. package/lib/test/utils/fileSystemAccessMocks.js +0 -277
  169. package/lib/test/utils/fileSystemAccessMocks.js.map +0 -1
  170. package/lib/test/utils/testHelpers.d.ts +0 -51
  171. package/lib/test/utils/testHelpers.d.ts.map +0 -1
  172. package/lib/test/utils/testHelpers.js +0 -133
  173. package/lib/test/utils/testHelpers.js.map +0 -1
  174. package/rush-logs/ts-web-extras.build.cache.log +0 -0
  175. package/rush-logs/ts-web-extras.build.error.log +0 -18
  176. package/rush-logs/ts-web-extras.build.log +0 -75
  177. package/rush-logs/ts-web-extras.test.cache.log +0 -1
  178. package/rush-logs/ts-web-extras.test.error.log +0 -18
  179. package/rush-logs/ts-web-extras.test.log +0 -75
  180. package/src/index.browser.ts +0 -24
  181. package/src/index.ts +0 -47
  182. package/src/packlets/crypto-utils/browserCryptoProvider.ts +0 -311
  183. package/src/packlets/crypto-utils/browserHashProvider.ts +0 -73
  184. package/src/packlets/crypto-utils/index.ts +0 -29
  185. package/src/packlets/file-api-types/index.ts +0 -366
  186. package/src/packlets/file-tree/directoryHandleStore.ts +0 -136
  187. package/src/packlets/file-tree/fileApiTreeAccessors.ts +0 -528
  188. package/src/packlets/file-tree/fileSystemAccessTreeAccessors.ts +0 -519
  189. package/src/packlets/file-tree/httpTreeAccessors.ts +0 -448
  190. package/src/packlets/file-tree/index.ts +0 -32
  191. package/src/packlets/file-tree/localStorageTreeAccessors.ts +0 -430
  192. package/src/packlets/helpers/fileTreeHelpers.ts +0 -107
  193. package/src/packlets/helpers/index.ts +0 -28
  194. package/src/packlets/url-utils/index.ts +0 -28
  195. package/src/packlets/url-utils/urlParams.ts +0 -245
  196. package/src/test/mocks/idb-keyval.ts +0 -5
  197. package/src/test/setupTests.ts +0 -87
  198. package/src/test/unit/browserHashProvider.test.ts +0 -155
  199. package/src/test/unit/browserHashProvider.test.ts.bak +0 -376
  200. package/src/test/unit/directoryHandleStore.test.ts +0 -251
  201. package/src/test/unit/fileApiTreeAccessors.test.ts +0 -1387
  202. package/src/test/unit/fileApiTypes.test.ts +0 -587
  203. package/src/test/unit/fileSystemAccessTreeAccessors.test.ts +0 -885
  204. package/src/test/unit/fileTreeHelpers.test.ts +0 -694
  205. package/src/test/unit/httpTreeAccessors.test.ts +0 -1571
  206. package/src/test/unit/localStorageTreeAccessors.test.ts +0 -1014
  207. package/src/test/unit/urlParams.test.ts +0 -464
  208. package/src/test/utils/fileSystemAccessMocks.ts +0 -353
  209. package/src/test/utils/testHelpers.ts +0 -155
  210. package/temp/build/typescript/ts_8nwakTlr.json +0 -1
  211. package/temp/coverage/base.css +0 -224
  212. package/temp/coverage/block-navigation.js +0 -87
  213. package/temp/coverage/crypto/browserHashProvider.ts.html +0 -304
  214. package/temp/coverage/crypto/index.html +0 -116
  215. package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +0 -1018
  216. package/temp/coverage/crypto-utils/browserHashProvider.ts.html +0 -304
  217. package/temp/coverage/crypto-utils/index.html +0 -131
  218. package/temp/coverage/favicon.png +0 -0
  219. package/temp/coverage/file-tree/directoryHandleStore.ts.html +0 -493
  220. package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +0 -1669
  221. package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
  222. package/temp/coverage/file-tree/httpTreeAccessors.ts.html +0 -1429
  223. package/temp/coverage/file-tree/index.html +0 -176
  224. package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +0 -1375
  225. package/temp/coverage/helpers/fileTreeHelpers.ts.html +0 -406
  226. package/temp/coverage/helpers/index.html +0 -116
  227. package/temp/coverage/index.html +0 -161
  228. package/temp/coverage/lcov-report/base.css +0 -224
  229. package/temp/coverage/lcov-report/block-navigation.js +0 -87
  230. package/temp/coverage/lcov-report/crypto/browserHashProvider.ts.html +0 -304
  231. package/temp/coverage/lcov-report/crypto/index.html +0 -116
  232. package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +0 -1018
  233. package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +0 -304
  234. package/temp/coverage/lcov-report/crypto-utils/index.html +0 -131
  235. package/temp/coverage/lcov-report/favicon.png +0 -0
  236. package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +0 -493
  237. package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +0 -1669
  238. package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
  239. package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +0 -1429
  240. package/temp/coverage/lcov-report/file-tree/index.html +0 -176
  241. package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +0 -1375
  242. package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +0 -406
  243. package/temp/coverage/lcov-report/helpers/index.html +0 -116
  244. package/temp/coverage/lcov-report/index.html +0 -161
  245. package/temp/coverage/lcov-report/prettify.css +0 -1
  246. package/temp/coverage/lcov-report/prettify.js +0 -2
  247. package/temp/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  248. package/temp/coverage/lcov-report/sorter.js +0 -210
  249. package/temp/coverage/lcov-report/url-utils/index.html +0 -116
  250. package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +0 -820
  251. package/temp/coverage/lcov.info +0 -3597
  252. package/temp/coverage/prettify.css +0 -1
  253. package/temp/coverage/prettify.js +0 -2
  254. package/temp/coverage/sort-arrow-sprite.png +0 -0
  255. package/temp/coverage/sorter.js +0 -210
  256. package/temp/coverage/url-utils/index.html +0 -116
  257. package/temp/coverage/url-utils/urlParams.ts.html +0 -820
  258. package/temp/test/jest/haste-map-b931e4e63102f86c5bd4949f7dced44f-9d713eb41149188b4e5c0ae3d86d0a57-2ad8e16b24e391b8cdbe50b55c137169 +0 -0
  259. package/temp/test/jest/jest-transform-cache-b931e4e63102f86c5bd4949f7dced44f-79ef2876fae7ca75eedb2aa53dc48338/b5/package_b5f57afc9ec2c011239b1608ee5bdfa5 +0 -53
  260. package/temp/test/jest/perf-cache-b931e4e63102f86c5bd4949f7dced44f-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
  261. package/temp/ts-web-extras.api.json +0 -8850
  262. package/temp/ts-web-extras.api.md +0 -433
  263. package/tsconfig.json +0 -7
@@ -1,245 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- export const createStore = jest.fn(() => ({}));
2
- export const get = jest.fn();
3
- export const set = jest.fn();
4
- export const del = jest.fn();
5
- export const keys = jest.fn();
@@ -1,87 +0,0 @@
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
- });
@@ -1,155 +0,0 @@
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-utils';
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
- });