@metamask/snaps-utils 8.0.1 → 8.1.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 (975) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/array.cjs +17 -0
  3. package/dist/array.cjs.map +1 -0
  4. package/dist/array.d.cts +11 -0
  5. package/dist/array.d.cts.map +1 -0
  6. package/dist/array.d.mts +11 -0
  7. package/dist/array.d.mts.map +1 -0
  8. package/dist/array.mjs +12 -7
  9. package/dist/array.mjs.map +1 -1
  10. package/dist/auxiliary-files.cjs +39 -0
  11. package/dist/auxiliary-files.cjs.map +1 -0
  12. package/dist/auxiliary-files.d.cts +17 -0
  13. package/dist/auxiliary-files.d.cts.map +1 -0
  14. package/dist/auxiliary-files.d.mts +17 -0
  15. package/dist/auxiliary-files.d.mts.map +1 -0
  16. package/dist/auxiliary-files.mjs +33 -14
  17. package/dist/auxiliary-files.mjs.map +1 -1
  18. package/dist/base64.cjs +38 -0
  19. package/dist/base64.cjs.map +1 -0
  20. package/dist/base64.d.cts +16 -0
  21. package/dist/base64.d.cts.map +1 -0
  22. package/dist/base64.d.mts +16 -0
  23. package/dist/base64.d.mts.map +1 -0
  24. package/dist/base64.mjs +32 -12
  25. package/dist/base64.mjs.map +1 -1
  26. package/dist/bytes.cjs +22 -0
  27. package/dist/bytes.cjs.map +1 -0
  28. package/dist/bytes.d.cts +9 -0
  29. package/dist/bytes.d.cts.map +1 -0
  30. package/dist/bytes.d.mts +9 -0
  31. package/dist/bytes.d.mts.map +1 -0
  32. package/dist/bytes.mjs +17 -9
  33. package/dist/bytes.mjs.map +1 -1
  34. package/dist/caveats.cjs +51 -0
  35. package/dist/caveats.cjs.map +1 -0
  36. package/dist/caveats.d.cts +47 -0
  37. package/dist/caveats.d.cts.map +1 -0
  38. package/dist/caveats.d.mts +47 -0
  39. package/dist/caveats.d.mts.map +1 -0
  40. package/dist/caveats.mjs +47 -7
  41. package/dist/caveats.mjs.map +1 -1
  42. package/dist/checksum.cjs +49 -0
  43. package/dist/checksum.cjs.map +1 -0
  44. package/dist/checksum.d.cts +22 -0
  45. package/dist/checksum.d.cts.map +1 -0
  46. package/dist/checksum.d.mts +22 -0
  47. package/dist/checksum.d.mts.map +1 -0
  48. package/dist/checksum.mjs +43 -12
  49. package/dist/checksum.mjs.map +1 -1
  50. package/dist/constants.cjs +8 -0
  51. package/dist/constants.cjs.map +1 -0
  52. package/dist/constants.d.cts +2 -0
  53. package/dist/constants.d.cts.map +1 -0
  54. package/dist/constants.d.mts +2 -0
  55. package/dist/constants.d.mts.map +1 -0
  56. package/dist/constants.mjs +4 -7
  57. package/dist/constants.mjs.map +1 -1
  58. package/dist/cronjob.cjs +70 -0
  59. package/dist/cronjob.cjs.map +1 -0
  60. package/dist/cronjob.d.cts +90 -0
  61. package/dist/cronjob.d.cts.map +1 -0
  62. package/dist/cronjob.d.mts +90 -0
  63. package/dist/cronjob.d.mts.map +1 -0
  64. package/dist/cronjob.mjs +64 -19
  65. package/dist/cronjob.mjs.map +1 -1
  66. package/dist/deep-clone.cjs +9 -0
  67. package/dist/deep-clone.cjs.map +1 -0
  68. package/dist/deep-clone.d.cts +2 -0
  69. package/dist/deep-clone.d.cts.map +1 -0
  70. package/dist/deep-clone.d.mts +2 -0
  71. package/dist/deep-clone.d.mts.map +1 -0
  72. package/dist/deep-clone.mjs +9 -7
  73. package/dist/deep-clone.mjs.map +1 -1
  74. package/dist/default-endowments.cjs +42 -0
  75. package/dist/default-endowments.cjs.map +1 -0
  76. package/dist/default-endowments.d.cts +5 -0
  77. package/dist/default-endowments.d.cts.map +1 -0
  78. package/dist/default-endowments.d.mts +5 -0
  79. package/dist/default-endowments.d.mts.map +1 -0
  80. package/dist/default-endowments.mjs +38 -7
  81. package/dist/default-endowments.mjs.map +1 -1
  82. package/dist/derivation-paths.cjs +215 -0
  83. package/dist/derivation-paths.cjs.map +1 -0
  84. package/dist/derivation-paths.d.cts +25 -0
  85. package/dist/derivation-paths.d.cts.map +1 -0
  86. package/dist/derivation-paths.d.mts +25 -0
  87. package/dist/derivation-paths.d.mts.map +1 -0
  88. package/dist/derivation-paths.mjs +206 -12
  89. package/dist/derivation-paths.mjs.map +1 -1
  90. package/dist/entropy.cjs +8 -0
  91. package/dist/entropy.cjs.map +1 -0
  92. package/dist/entropy.d.cts +4 -0
  93. package/dist/entropy.d.cts.map +1 -0
  94. package/dist/entropy.d.mts +4 -0
  95. package/dist/entropy.d.mts.map +1 -0
  96. package/dist/entropy.mjs +4 -9
  97. package/dist/entropy.mjs.map +1 -1
  98. package/dist/errors.cjs +189 -0
  99. package/dist/errors.cjs.map +1 -0
  100. package/dist/errors.d.cts +85 -0
  101. package/dist/errors.d.cts.map +1 -0
  102. package/dist/errors.d.mts +85 -0
  103. package/dist/errors.d.mts.map +1 -0
  104. package/dist/errors.mjs +179 -18
  105. package/dist/errors.mjs.map +1 -1
  106. package/dist/eval-worker.cjs +42 -0
  107. package/dist/eval-worker.cjs.map +1 -0
  108. package/dist/eval-worker.d.cts +2 -0
  109. package/dist/eval-worker.d.cts.map +1 -0
  110. package/dist/eval-worker.d.mts +2 -0
  111. package/dist/eval-worker.d.mts.map +1 -0
  112. package/dist/eval-worker.mjs +28 -31
  113. package/dist/eval-worker.mjs.map +1 -1
  114. package/dist/eval.cjs +54 -0
  115. package/dist/eval.cjs.map +1 -0
  116. package/dist/eval.d.cts +17 -0
  117. package/dist/eval.d.cts.map +1 -0
  118. package/dist/eval.d.mts +17 -0
  119. package/dist/eval.d.mts.map +1 -0
  120. package/dist/eval.mjs +48 -16
  121. package/dist/eval.mjs.map +1 -1
  122. package/dist/fs.cjs +159 -0
  123. package/dist/fs.cjs.map +1 -0
  124. package/dist/fs.d.cts +70 -0
  125. package/dist/fs.d.cts.map +1 -0
  126. package/dist/fs.d.mts +70 -0
  127. package/dist/fs.d.mts.map +1 -0
  128. package/dist/fs.mjs +144 -27
  129. package/dist/fs.mjs.map +1 -1
  130. package/dist/handler-types.cjs +18 -0
  131. package/dist/handler-types.cjs.map +1 -0
  132. package/dist/handler-types.d.cts +35 -0
  133. package/dist/handler-types.d.cts.map +1 -0
  134. package/dist/handler-types.d.mts +35 -0
  135. package/dist/handler-types.d.mts.map +1 -0
  136. package/dist/handler-types.mjs +14 -9
  137. package/dist/handler-types.mjs.map +1 -1
  138. package/dist/handlers.cjs +119 -0
  139. package/dist/handlers.cjs.map +1 -0
  140. package/dist/handlers.d.cts +750 -0
  141. package/dist/handlers.d.cts.map +1 -0
  142. package/dist/handlers.d.mts +750 -0
  143. package/dist/handlers.d.mts.map +1 -0
  144. package/dist/handlers.mjs +114 -33
  145. package/dist/handlers.mjs.map +1 -1
  146. package/dist/icon.cjs +58 -0
  147. package/dist/icon.cjs.map +1 -0
  148. package/dist/icon.d.cts +20 -0
  149. package/dist/icon.d.cts.map +1 -0
  150. package/dist/icon.d.mts +20 -0
  151. package/dist/icon.d.mts.map +1 -0
  152. package/dist/icon.mjs +52 -14
  153. package/dist/icon.mjs.map +1 -1
  154. package/dist/iframe.cjs +54 -0
  155. package/dist/iframe.cjs.map +1 -0
  156. package/dist/iframe.d.cts +12 -0
  157. package/dist/iframe.d.cts.map +1 -0
  158. package/dist/iframe.d.mts +12 -0
  159. package/dist/iframe.d.mts.map +1 -0
  160. package/dist/iframe.mjs +49 -7
  161. package/dist/iframe.mjs.map +1 -1
  162. package/dist/iframe.test.browser.cjs +15 -0
  163. package/dist/iframe.test.browser.cjs.map +1 -0
  164. package/dist/iframe.test.browser.d.cts +2 -0
  165. package/dist/iframe.test.browser.d.cts.map +1 -0
  166. package/dist/iframe.test.browser.d.mts +2 -0
  167. package/dist/iframe.test.browser.d.mts.map +1 -0
  168. package/dist/iframe.test.browser.mjs +13 -0
  169. package/dist/iframe.test.browser.mjs.map +1 -0
  170. package/dist/index.cjs +49 -0
  171. package/dist/index.cjs.map +1 -0
  172. package/dist/index.d.cts +33 -0
  173. package/dist/index.d.cts.map +1 -0
  174. package/dist/index.d.mts +33 -0
  175. package/dist/index.d.mts.map +1 -0
  176. package/dist/index.executionenv.cjs +25 -0
  177. package/dist/index.executionenv.cjs.map +1 -0
  178. package/dist/index.executionenv.d.cts +8 -0
  179. package/dist/index.executionenv.d.cts.map +1 -0
  180. package/dist/index.executionenv.d.mts +8 -0
  181. package/dist/index.executionenv.d.mts.map +1 -0
  182. package/dist/index.executionenv.mjs +8 -127
  183. package/dist/index.executionenv.mjs.map +1 -1
  184. package/dist/index.mjs +32 -397
  185. package/dist/index.mjs.map +1 -1
  186. package/dist/json-rpc.cjs +135 -0
  187. package/dist/json-rpc.cjs.map +1 -0
  188. package/dist/json-rpc.d.cts +56 -0
  189. package/dist/json-rpc.d.cts.map +1 -0
  190. package/dist/json-rpc.d.mts +56 -0
  191. package/dist/json-rpc.d.mts.map +1 -0
  192. package/dist/json-rpc.mjs +127 -17
  193. package/dist/json-rpc.mjs.map +1 -1
  194. package/dist/json.cjs +34 -0
  195. package/dist/json.cjs.map +1 -0
  196. package/dist/json.d.cts +23 -0
  197. package/dist/json.d.cts.map +1 -0
  198. package/dist/json.d.mts +23 -0
  199. package/dist/json.d.mts.map +1 -0
  200. package/dist/json.mjs +28 -9
  201. package/dist/json.mjs.map +1 -1
  202. package/dist/localization.cjs +128 -0
  203. package/dist/localization.cjs.map +1 -0
  204. package/dist/localization.d.cts +146 -0
  205. package/dist/localization.d.cts.map +1 -0
  206. package/dist/localization.d.mts +146 -0
  207. package/dist/localization.d.mts.map +1 -0
  208. package/dist/localization.mjs +119 -22
  209. package/dist/localization.mjs.map +1 -1
  210. package/dist/logging.cjs +67 -0
  211. package/dist/logging.cjs.map +1 -0
  212. package/dist/logging.d.cts +50 -0
  213. package/dist/logging.d.cts.map +1 -0
  214. package/dist/logging.d.mts +50 -0
  215. package/dist/logging.d.mts.map +1 -0
  216. package/dist/logging.mjs +60 -13
  217. package/dist/logging.mjs.map +1 -1
  218. package/dist/manifest/index.cjs +18 -0
  219. package/dist/manifest/index.cjs.map +1 -0
  220. package/dist/manifest/index.d.cts +2 -0
  221. package/dist/manifest/index.d.cts.map +1 -0
  222. package/dist/manifest/index.d.mts +2 -0
  223. package/dist/manifest/index.d.mts.map +1 -0
  224. package/dist/manifest/index.mjs +1 -64
  225. package/dist/manifest/index.mjs.map +1 -1
  226. package/dist/manifest/manifest.cjs +267 -0
  227. package/dist/manifest/manifest.cjs.map +1 -0
  228. package/dist/manifest/manifest.d.cts +100 -0
  229. package/dist/manifest/manifest.d.cts.map +1 -0
  230. package/dist/manifest/manifest.d.mts +100 -0
  231. package/dist/manifest/manifest.d.mts.map +1 -0
  232. package/dist/manifest/manifest.mjs +252 -57
  233. package/dist/manifest/manifest.mjs.map +1 -1
  234. package/dist/manifest/node.cjs +19 -0
  235. package/dist/manifest/node.cjs.map +1 -0
  236. package/dist/manifest/node.d.cts +3 -0
  237. package/dist/manifest/node.d.cts.map +1 -0
  238. package/dist/manifest/node.d.mts +3 -0
  239. package/dist/manifest/node.d.mts.map +1 -0
  240. package/dist/manifest/node.mjs +2 -105
  241. package/dist/manifest/node.mjs.map +1 -1
  242. package/dist/manifest/validation.cjs +194 -0
  243. package/dist/manifest/validation.cjs.map +1 -0
  244. package/dist/manifest/validation.d.cts +254 -0
  245. package/dist/manifest/validation.d.cts.map +1 -0
  246. package/dist/manifest/validation.d.mts +254 -0
  247. package/dist/manifest/validation.d.mts.map +1 -0
  248. package/dist/manifest/validation.mjs +186 -63
  249. package/dist/manifest/validation.mjs.map +1 -1
  250. package/dist/manifest/validator-types.cjs +3 -0
  251. package/dist/manifest/validator-types.cjs.map +1 -0
  252. package/dist/manifest/validator-types.d.cts +35 -0
  253. package/dist/manifest/validator-types.d.cts.map +1 -0
  254. package/dist/manifest/validator-types.d.mts +35 -0
  255. package/dist/manifest/validator-types.d.mts.map +1 -0
  256. package/dist/manifest/validator-types.mjs +1 -0
  257. package/dist/manifest/validator-types.mjs.map +1 -1
  258. package/dist/manifest/validator.cjs +109 -0
  259. package/dist/manifest/validator.cjs.map +1 -0
  260. package/dist/manifest/validator.d.cts +24 -0
  261. package/dist/manifest/validator.d.cts.map +1 -0
  262. package/dist/manifest/validator.d.mts +24 -0
  263. package/dist/manifest/validator.d.mts.map +1 -0
  264. package/dist/manifest/validator.mjs +79 -42
  265. package/dist/manifest/validator.mjs.map +1 -1
  266. package/dist/manifest/validators/checksum.cjs +23 -0
  267. package/dist/manifest/validators/checksum.cjs.map +1 -0
  268. package/dist/manifest/validators/checksum.d.cts +6 -0
  269. package/dist/manifest/validators/checksum.d.cts.map +1 -0
  270. package/dist/manifest/validators/checksum.d.mts +6 -0
  271. package/dist/manifest/validators/checksum.d.mts.map +1 -0
  272. package/dist/manifest/validators/checksum.mjs +18 -13
  273. package/dist/manifest/validators/checksum.mjs.map +1 -1
  274. package/dist/manifest/validators/expected-files.cjs +24 -0
  275. package/dist/manifest/validators/expected-files.cjs.map +1 -0
  276. package/dist/manifest/validators/expected-files.d.cts +6 -0
  277. package/dist/manifest/validators/expected-files.d.cts.map +1 -0
  278. package/dist/manifest/validators/expected-files.d.mts +6 -0
  279. package/dist/manifest/validators/expected-files.d.mts.map +1 -0
  280. package/dist/manifest/validators/expected-files.mjs +19 -7
  281. package/dist/manifest/validators/expected-files.mjs.map +1 -1
  282. package/dist/manifest/validators/icon-declared.cjs +15 -0
  283. package/dist/manifest/validators/icon-declared.cjs.map +1 -0
  284. package/dist/manifest/validators/icon-declared.d.cts +6 -0
  285. package/dist/manifest/validators/icon-declared.d.cts.map +1 -0
  286. package/dist/manifest/validators/icon-declared.d.mts +6 -0
  287. package/dist/manifest/validators/icon-declared.d.mts.map +1 -0
  288. package/dist/manifest/validators/icon-declared.mjs +10 -6
  289. package/dist/manifest/validators/icon-declared.mjs.map +1 -1
  290. package/dist/manifest/validators/icon-dimensions.cjs +20 -0
  291. package/dist/manifest/validators/icon-dimensions.cjs.map +1 -0
  292. package/dist/manifest/validators/icon-dimensions.d.cts +6 -0
  293. package/dist/manifest/validators/icon-dimensions.d.cts.map +1 -0
  294. package/dist/manifest/validators/icon-dimensions.d.mts +6 -0
  295. package/dist/manifest/validators/icon-dimensions.d.mts.map +1 -0
  296. package/dist/manifest/validators/icon-dimensions.mjs +15 -8
  297. package/dist/manifest/validators/icon-dimensions.mjs.map +1 -1
  298. package/dist/manifest/validators/icon-missing.cjs +16 -0
  299. package/dist/manifest/validators/icon-missing.cjs.map +1 -0
  300. package/dist/manifest/validators/icon-missing.d.cts +6 -0
  301. package/dist/manifest/validators/icon-missing.d.cts.map +1 -0
  302. package/dist/manifest/validators/icon-missing.d.mts +6 -0
  303. package/dist/manifest/validators/icon-missing.d.mts.map +1 -0
  304. package/dist/manifest/validators/icon-missing.mjs +11 -6
  305. package/dist/manifest/validators/icon-missing.mjs.map +1 -1
  306. package/dist/manifest/validators/index.cjs +31 -0
  307. package/dist/manifest/validators/index.cjs.map +1 -0
  308. package/dist/manifest/validators/index.d.cts +15 -0
  309. package/dist/manifest/validators/index.d.cts.map +1 -0
  310. package/dist/manifest/validators/index.d.mts +15 -0
  311. package/dist/manifest/validators/index.d.mts.map +1 -0
  312. package/dist/manifest/validators/index.mjs +14 -79
  313. package/dist/manifest/validators/index.mjs.map +1 -1
  314. package/dist/manifest/validators/is-localization-file.cjs +23 -0
  315. package/dist/manifest/validators/is-localization-file.cjs.map +1 -0
  316. package/dist/manifest/validators/is-localization-file.d.cts +6 -0
  317. package/dist/manifest/validators/is-localization-file.d.cts.map +1 -0
  318. package/dist/manifest/validators/is-localization-file.d.mts +6 -0
  319. package/dist/manifest/validators/is-localization-file.d.mts.map +1 -0
  320. package/dist/manifest/validators/is-localization-file.mjs +18 -10
  321. package/dist/manifest/validators/is-localization-file.mjs.map +1 -1
  322. package/dist/manifest/validators/is-package-json.cjs +24 -0
  323. package/dist/manifest/validators/is-package-json.cjs.map +1 -0
  324. package/dist/manifest/validators/is-package-json.d.cts +6 -0
  325. package/dist/manifest/validators/is-package-json.d.cts.map +1 -0
  326. package/dist/manifest/validators/is-package-json.d.mts +6 -0
  327. package/dist/manifest/validators/is-package-json.d.mts.map +1 -0
  328. package/dist/manifest/validators/is-package-json.mjs +19 -9
  329. package/dist/manifest/validators/is-package-json.mjs.map +1 -1
  330. package/dist/manifest/validators/is-snap-icon.cjs +24 -0
  331. package/dist/manifest/validators/is-snap-icon.cjs.map +1 -0
  332. package/dist/manifest/validators/is-snap-icon.d.cts +6 -0
  333. package/dist/manifest/validators/is-snap-icon.d.cts.map +1 -0
  334. package/dist/manifest/validators/is-snap-icon.d.mts +6 -0
  335. package/dist/manifest/validators/is-snap-icon.d.mts.map +1 -0
  336. package/dist/manifest/validators/is-snap-icon.mjs +19 -8
  337. package/dist/manifest/validators/is-snap-icon.mjs.map +1 -1
  338. package/dist/manifest/validators/is-snap-manifest.cjs +25 -0
  339. package/dist/manifest/validators/is-snap-manifest.cjs.map +1 -0
  340. package/dist/manifest/validators/is-snap-manifest.d.cts +6 -0
  341. package/dist/manifest/validators/is-snap-manifest.d.cts.map +1 -0
  342. package/dist/manifest/validators/is-snap-manifest.d.mts +6 -0
  343. package/dist/manifest/validators/is-snap-manifest.d.mts.map +1 -0
  344. package/dist/manifest/validators/is-snap-manifest.mjs +20 -21
  345. package/dist/manifest/validators/is-snap-manifest.mjs.map +1 -1
  346. package/dist/manifest/validators/manifest-localization.cjs +30 -0
  347. package/dist/manifest/validators/manifest-localization.cjs.map +1 -0
  348. package/dist/manifest/validators/manifest-localization.d.cts +6 -0
  349. package/dist/manifest/validators/manifest-localization.d.cts.map +1 -0
  350. package/dist/manifest/validators/manifest-localization.d.mts +6 -0
  351. package/dist/manifest/validators/manifest-localization.d.mts.map +1 -0
  352. package/dist/manifest/validators/manifest-localization.mjs +25 -8
  353. package/dist/manifest/validators/manifest-localization.mjs.map +1 -1
  354. package/dist/manifest/validators/package-json-recommended-fields.cjs +18 -0
  355. package/dist/manifest/validators/package-json-recommended-fields.cjs.map +1 -0
  356. package/dist/manifest/validators/package-json-recommended-fields.d.cts +6 -0
  357. package/dist/manifest/validators/package-json-recommended-fields.d.cts.map +1 -0
  358. package/dist/manifest/validators/package-json-recommended-fields.d.mts +6 -0
  359. package/dist/manifest/validators/package-json-recommended-fields.d.mts.map +1 -0
  360. package/dist/manifest/validators/package-json-recommended-fields.mjs +13 -6
  361. package/dist/manifest/validators/package-json-recommended-fields.mjs.map +1 -1
  362. package/dist/manifest/validators/package-name-match.cjs +21 -0
  363. package/dist/manifest/validators/package-name-match.cjs.map +1 -0
  364. package/dist/manifest/validators/package-name-match.d.cts +6 -0
  365. package/dist/manifest/validators/package-name-match.d.cts.map +1 -0
  366. package/dist/manifest/validators/package-name-match.d.mts +6 -0
  367. package/dist/manifest/validators/package-name-match.d.mts.map +1 -0
  368. package/dist/manifest/validators/package-name-match.mjs +16 -7
  369. package/dist/manifest/validators/package-name-match.mjs.map +1 -1
  370. package/dist/manifest/validators/repository-match.cjs +29 -0
  371. package/dist/manifest/validators/repository-match.cjs.map +1 -0
  372. package/dist/manifest/validators/repository-match.d.cts +6 -0
  373. package/dist/manifest/validators/repository-match.d.cts.map +1 -0
  374. package/dist/manifest/validators/repository-match.d.mts +6 -0
  375. package/dist/manifest/validators/repository-match.d.mts.map +1 -0
  376. package/dist/manifest/validators/repository-match.mjs +28 -8
  377. package/dist/manifest/validators/repository-match.mjs.map +1 -1
  378. package/dist/manifest/validators/version-match.cjs +21 -0
  379. package/dist/manifest/validators/version-match.cjs.map +1 -0
  380. package/dist/manifest/validators/version-match.d.cts +6 -0
  381. package/dist/manifest/validators/version-match.d.cts.map +1 -0
  382. package/dist/manifest/validators/version-match.d.mts +6 -0
  383. package/dist/manifest/validators/version-match.d.mts.map +1 -0
  384. package/dist/manifest/validators/version-match.mjs +16 -7
  385. package/dist/manifest/validators/version-match.mjs.map +1 -1
  386. package/dist/mock.cjs +113 -0
  387. package/dist/mock.cjs.map +1 -0
  388. package/dist/mock.d.cts +15 -0
  389. package/dist/mock.d.cts.map +1 -0
  390. package/dist/mock.d.mts +15 -0
  391. package/dist/mock.d.mts.map +1 -0
  392. package/dist/mock.mjs +103 -11
  393. package/dist/mock.mjs.map +1 -1
  394. package/dist/namespace.cjs +136 -0
  395. package/dist/namespace.cjs.map +1 -0
  396. package/dist/namespace.d.cts +130 -0
  397. package/dist/namespace.d.cts.map +1 -0
  398. package/dist/namespace.d.mts +130 -0
  399. package/dist/namespace.d.mts.map +1 -0
  400. package/dist/namespace.mjs +125 -43
  401. package/dist/namespace.mjs.map +1 -1
  402. package/dist/node.cjs +25 -0
  403. package/dist/node.cjs.map +1 -0
  404. package/dist/node.d.cts +8 -0
  405. package/dist/node.d.cts.map +1 -0
  406. package/dist/node.d.mts +8 -0
  407. package/dist/node.d.mts.map +1 -0
  408. package/dist/node.mjs +8 -475
  409. package/dist/node.mjs.map +1 -1
  410. package/dist/path.cjs +21 -0
  411. package/dist/path.cjs.map +1 -0
  412. package/dist/path.d.cts +8 -0
  413. package/dist/path.d.cts.map +1 -0
  414. package/dist/path.d.mts +8 -0
  415. package/dist/path.d.mts.map +1 -0
  416. package/dist/path.mjs +16 -7
  417. package/dist/path.mjs.map +1 -1
  418. package/dist/post-process.cjs +339 -0
  419. package/dist/post-process.cjs.map +1 -0
  420. package/dist/post-process.d.cts +72 -0
  421. package/dist/post-process.d.cts.map +1 -0
  422. package/dist/post-process.d.mts +72 -0
  423. package/dist/post-process.d.mts.map +1 -0
  424. package/dist/post-process.mjs +335 -9
  425. package/dist/post-process.mjs.map +1 -1
  426. package/dist/promise.cjs +3 -0
  427. package/dist/promise.cjs.map +1 -0
  428. package/dist/promise.d.cts +2 -0
  429. package/dist/promise.d.cts.map +1 -0
  430. package/dist/promise.d.mts +2 -0
  431. package/dist/promise.d.mts.map +1 -0
  432. package/dist/promise.mjs +1 -1
  433. package/dist/promise.mjs.map +1 -1
  434. package/dist/snaps.cjs +207 -0
  435. package/dist/snaps.cjs.map +1 -0
  436. package/dist/snaps.d.cts +170 -0
  437. package/dist/snaps.d.cts.map +1 -0
  438. package/dist/snaps.d.mts +170 -0
  439. package/dist/snaps.d.mts.map +1 -0
  440. package/dist/snaps.mjs +200 -45
  441. package/dist/snaps.mjs.map +1 -1
  442. package/dist/strings.cjs +15 -0
  443. package/dist/strings.cjs.map +1 -0
  444. package/dist/strings.d.cts +9 -0
  445. package/dist/strings.d.cts.map +1 -0
  446. package/dist/strings.d.mts +9 -0
  447. package/dist/strings.d.mts.map +1 -0
  448. package/dist/strings.mjs +10 -7
  449. package/dist/strings.mjs.map +1 -1
  450. package/dist/structs.cjs +316 -0
  451. package/dist/structs.cjs.map +1 -0
  452. package/dist/structs.d.cts +181 -0
  453. package/dist/structs.d.cts.map +1 -0
  454. package/dist/structs.d.mts +181 -0
  455. package/dist/structs.d.mts.map +1 -0
  456. package/dist/structs.mjs +300 -32
  457. package/dist/structs.mjs.map +1 -1
  458. package/dist/svg.cjs +49 -0
  459. package/dist/svg.cjs.map +1 -0
  460. package/dist/svg.d.cts +15 -0
  461. package/dist/svg.d.cts.map +1 -0
  462. package/dist/svg.d.mts +15 -0
  463. package/dist/svg.d.mts.map +1 -0
  464. package/dist/svg.mjs +43 -9
  465. package/dist/svg.mjs.map +1 -1
  466. package/dist/types.cjs +64 -0
  467. package/dist/types.cjs.map +1 -0
  468. package/dist/types.d.cts +104 -0
  469. package/dist/types.d.cts.map +1 -0
  470. package/dist/types.d.mts +104 -0
  471. package/dist/types.d.mts.map +1 -0
  472. package/dist/types.mjs +58 -21
  473. package/dist/types.mjs.map +1 -1
  474. package/dist/ui.cjs +405 -0
  475. package/dist/ui.cjs.map +1 -0
  476. package/dist/ui.d.cts +93 -0
  477. package/dist/ui.d.cts.map +1 -0
  478. package/dist/ui.d.mts +93 -0
  479. package/dist/ui.d.mts.map +1 -0
  480. package/dist/ui.mjs +391 -23
  481. package/dist/ui.mjs.map +1 -1
  482. package/dist/validation.cjs +23 -0
  483. package/dist/validation.cjs.map +1 -0
  484. package/dist/validation.d.cts +9 -0
  485. package/dist/validation.d.cts.map +1 -0
  486. package/dist/validation.d.mts +9 -0
  487. package/dist/validation.d.mts.map +1 -0
  488. package/dist/validation.mjs +18 -26
  489. package/dist/validation.mjs.map +1 -1
  490. package/dist/versions.cjs +44 -0
  491. package/dist/versions.cjs.map +1 -0
  492. package/dist/versions.d.cts +22 -0
  493. package/dist/versions.d.cts.map +1 -0
  494. package/dist/versions.d.mts +22 -0
  495. package/dist/versions.d.mts.map +1 -0
  496. package/dist/versions.mjs +38 -11
  497. package/dist/versions.mjs.map +1 -1
  498. package/dist/virtual-file/VirtualFile.cjs +75 -0
  499. package/dist/virtual-file/VirtualFile.cjs.map +1 -0
  500. package/dist/virtual-file/VirtualFile.d.cts +35 -0
  501. package/dist/virtual-file/VirtualFile.d.cts.map +1 -0
  502. package/dist/virtual-file/VirtualFile.d.mts +35 -0
  503. package/dist/virtual-file/VirtualFile.d.mts.map +1 -0
  504. package/dist/virtual-file/VirtualFile.mjs +70 -8
  505. package/dist/virtual-file/VirtualFile.mjs.map +1 -1
  506. package/dist/virtual-file/index.cjs +18 -0
  507. package/dist/virtual-file/index.cjs.map +1 -0
  508. package/dist/virtual-file/index.d.cts +2 -0
  509. package/dist/virtual-file/index.d.cts.map +1 -0
  510. package/dist/virtual-file/index.d.mts +2 -0
  511. package/dist/virtual-file/index.d.mts.map +1 -0
  512. package/dist/virtual-file/index.mjs +1 -9
  513. package/dist/virtual-file/index.mjs.map +1 -1
  514. package/dist/virtual-file/node.cjs +19 -0
  515. package/dist/virtual-file/node.cjs.map +1 -0
  516. package/dist/virtual-file/node.d.cts +3 -0
  517. package/dist/virtual-file/node.d.cts.map +1 -0
  518. package/dist/virtual-file/node.d.mts +3 -0
  519. package/dist/virtual-file/node.d.mts.map +1 -0
  520. package/dist/virtual-file/node.mjs +2 -16
  521. package/dist/virtual-file/node.mjs.map +1 -1
  522. package/dist/virtual-file/toVirtualFile.cjs +31 -0
  523. package/dist/virtual-file/toVirtualFile.cjs.map +1 -0
  524. package/dist/virtual-file/toVirtualFile.d.cts +24 -0
  525. package/dist/virtual-file/toVirtualFile.d.cts.map +1 -0
  526. package/dist/virtual-file/toVirtualFile.d.mts +24 -0
  527. package/dist/virtual-file/toVirtualFile.d.mts.map +1 -0
  528. package/dist/virtual-file/toVirtualFile.mjs +25 -11
  529. package/dist/virtual-file/toVirtualFile.mjs.map +1 -1
  530. package/package.json +36 -24
  531. package/dist/array.js +0 -8
  532. package/dist/array.js.map +0 -1
  533. package/dist/auxiliary-files.js +0 -15
  534. package/dist/auxiliary-files.js.map +0 -1
  535. package/dist/base64.js +0 -13
  536. package/dist/base64.js.map +0 -1
  537. package/dist/bytes.js +0 -10
  538. package/dist/bytes.js.map +0 -1
  539. package/dist/caveats.js +0 -8
  540. package/dist/caveats.js.map +0 -1
  541. package/dist/checksum.js +0 -13
  542. package/dist/checksum.js.map +0 -1
  543. package/dist/chunk-37EUH3KZ.js +0 -293
  544. package/dist/chunk-37EUH3KZ.js.map +0 -1
  545. package/dist/chunk-3N27GIUS.mjs +0 -229
  546. package/dist/chunk-3N27GIUS.mjs.map +0 -1
  547. package/dist/chunk-3OXW5H4F.js +0 -30
  548. package/dist/chunk-3OXW5H4F.js.map +0 -1
  549. package/dist/chunk-3RFGTBEP.js +0 -151
  550. package/dist/chunk-3RFGTBEP.js.map +0 -1
  551. package/dist/chunk-3RUWAMJT.mjs +0 -31
  552. package/dist/chunk-3RUWAMJT.mjs.map +0 -1
  553. package/dist/chunk-3S4INAGA.mjs +0 -18
  554. package/dist/chunk-3S4INAGA.mjs.map +0 -1
  555. package/dist/chunk-44VFHYJO.js +0 -249
  556. package/dist/chunk-44VFHYJO.js.map +0 -1
  557. package/dist/chunk-4AA3TKRJ.mjs +0 -153
  558. package/dist/chunk-4AA3TKRJ.mjs.map +0 -1
  559. package/dist/chunk-4BGZ2CHC.mjs +0 -22
  560. package/dist/chunk-4BGZ2CHC.mjs.map +0 -1
  561. package/dist/chunk-4CMD46B2.js +0 -1
  562. package/dist/chunk-4CMD46B2.js.map +0 -1
  563. package/dist/chunk-4RYTYEUQ.mjs +0 -33
  564. package/dist/chunk-4RYTYEUQ.mjs.map +0 -1
  565. package/dist/chunk-4ZJOU3LR.js +0 -71
  566. package/dist/chunk-4ZJOU3LR.js.map +0 -1
  567. package/dist/chunk-53QXTM77.js +0 -229
  568. package/dist/chunk-53QXTM77.js.map +0 -1
  569. package/dist/chunk-5FTBWYCW.mjs +0 -27
  570. package/dist/chunk-5FTBWYCW.mjs.map +0 -1
  571. package/dist/chunk-5MABKEV7.mjs +0 -66
  572. package/dist/chunk-5MABKEV7.mjs.map +0 -1
  573. package/dist/chunk-5R7UF7KM.mjs +0 -21
  574. package/dist/chunk-5R7UF7KM.mjs.map +0 -1
  575. package/dist/chunk-5UAPBOKO.js +0 -37
  576. package/dist/chunk-5UAPBOKO.js.map +0 -1
  577. package/dist/chunk-5WKQI22S.js +0 -7
  578. package/dist/chunk-5WKQI22S.js.map +0 -1
  579. package/dist/chunk-63OXILAY.mjs +0 -69
  580. package/dist/chunk-63OXILAY.mjs.map +0 -1
  581. package/dist/chunk-6ATNGN44.js +0 -300
  582. package/dist/chunk-6ATNGN44.js.map +0 -1
  583. package/dist/chunk-6HXIPMBN.js +0 -103
  584. package/dist/chunk-6HXIPMBN.js.map +0 -1
  585. package/dist/chunk-6YJWU77L.js +0 -19
  586. package/dist/chunk-6YJWU77L.js.map +0 -1
  587. package/dist/chunk-7HLSXEHK.mjs +0 -300
  588. package/dist/chunk-7HLSXEHK.mjs.map +0 -1
  589. package/dist/chunk-7LG4D4XA.mjs +0 -20
  590. package/dist/chunk-7LG4D4XA.mjs.map +0 -1
  591. package/dist/chunk-7P62OIGX.js +0 -69
  592. package/dist/chunk-7P62OIGX.js.map +0 -1
  593. package/dist/chunk-7T7FYH77.mjs +0 -37
  594. package/dist/chunk-7T7FYH77.mjs.map +0 -1
  595. package/dist/chunk-7VJ2BOVU.js +0 -15
  596. package/dist/chunk-7VJ2BOVU.js.map +0 -1
  597. package/dist/chunk-A3RRMELT.mjs +0 -1
  598. package/dist/chunk-A3RRMELT.mjs.map +0 -1
  599. package/dist/chunk-AMW2VJ3N.js +0 -32
  600. package/dist/chunk-AMW2VJ3N.js.map +0 -1
  601. package/dist/chunk-ANYNWSCA.mjs +0 -104
  602. package/dist/chunk-ANYNWSCA.mjs.map +0 -1
  603. package/dist/chunk-AOGVLPQZ.js +0 -18
  604. package/dist/chunk-AOGVLPQZ.js.map +0 -1
  605. package/dist/chunk-AS5P6JRP.mjs +0 -9
  606. package/dist/chunk-AS5P6JRP.mjs.map +0 -1
  607. package/dist/chunk-ASZWZ7JT.js +0 -20
  608. package/dist/chunk-ASZWZ7JT.js.map +0 -1
  609. package/dist/chunk-B5GNTDE2.js +0 -109
  610. package/dist/chunk-B5GNTDE2.js.map +0 -1
  611. package/dist/chunk-BGSO2GQC.mjs +0 -41
  612. package/dist/chunk-BGSO2GQC.mjs.map +0 -1
  613. package/dist/chunk-BPK5BH7K.js +0 -27
  614. package/dist/chunk-BPK5BH7K.js.map +0 -1
  615. package/dist/chunk-CJK7DDV2.mjs +0 -109
  616. package/dist/chunk-CJK7DDV2.mjs.map +0 -1
  617. package/dist/chunk-CPG2UGAA.js +0 -25
  618. package/dist/chunk-CPG2UGAA.js.map +0 -1
  619. package/dist/chunk-DE22V5AO.mjs +0 -53
  620. package/dist/chunk-DE22V5AO.mjs.map +0 -1
  621. package/dist/chunk-DEQUNIME.js +0 -53
  622. package/dist/chunk-DEQUNIME.js.map +0 -1
  623. package/dist/chunk-DKO64Y4H.mjs +0 -27
  624. package/dist/chunk-DKO64Y4H.mjs.map +0 -1
  625. package/dist/chunk-E3BDBG6T.js +0 -20
  626. package/dist/chunk-E3BDBG6T.js.map +0 -1
  627. package/dist/chunk-EFRPCO3C.js +0 -1
  628. package/dist/chunk-EFRPCO3C.js.map +0 -1
  629. package/dist/chunk-EVHDXNOC.mjs +0 -35
  630. package/dist/chunk-EVHDXNOC.mjs.map +0 -1
  631. package/dist/chunk-EYWMVDCD.mjs +0 -25
  632. package/dist/chunk-EYWMVDCD.mjs.map +0 -1
  633. package/dist/chunk-FA4QIZH6.js +0 -1
  634. package/dist/chunk-FA4QIZH6.js.map +0 -1
  635. package/dist/chunk-FBZ5SU7X.js +0 -189
  636. package/dist/chunk-FBZ5SU7X.js.map +0 -1
  637. package/dist/chunk-GIVJAZ2Q.mjs +0 -248
  638. package/dist/chunk-GIVJAZ2Q.mjs.map +0 -1
  639. package/dist/chunk-GJAVOB7B.js +0 -24
  640. package/dist/chunk-GJAVOB7B.js.map +0 -1
  641. package/dist/chunk-GXSTPU7D.mjs +0 -293
  642. package/dist/chunk-GXSTPU7D.mjs.map +0 -1
  643. package/dist/chunk-HY4W6BUH.mjs +0 -24
  644. package/dist/chunk-HY4W6BUH.mjs.map +0 -1
  645. package/dist/chunk-HYF7Q6VY.mjs +0 -1
  646. package/dist/chunk-HYF7Q6VY.mjs.map +0 -1
  647. package/dist/chunk-I2SWLZ34.js +0 -30
  648. package/dist/chunk-I2SWLZ34.js.map +0 -1
  649. package/dist/chunk-IELPPZJP.mjs +0 -189
  650. package/dist/chunk-IELPPZJP.mjs.map +0 -1
  651. package/dist/chunk-IJX3CXOY.js +0 -9
  652. package/dist/chunk-IJX3CXOY.js.map +0 -1
  653. package/dist/chunk-IPUL74MZ.mjs +0 -30
  654. package/dist/chunk-IPUL74MZ.mjs.map +0 -1
  655. package/dist/chunk-IV3FSWZ7.mjs +0 -9
  656. package/dist/chunk-IV3FSWZ7.mjs.map +0 -1
  657. package/dist/chunk-IVDERT5W.js +0 -22
  658. package/dist/chunk-IVDERT5W.js.map +0 -1
  659. package/dist/chunk-JETPRED3.js +0 -248
  660. package/dist/chunk-JETPRED3.js.map +0 -1
  661. package/dist/chunk-JI5NQ2C3.mjs +0 -1
  662. package/dist/chunk-JI5NQ2C3.mjs.map +0 -1
  663. package/dist/chunk-JJTIVHFX.mjs +0 -38
  664. package/dist/chunk-JJTIVHFX.mjs.map +0 -1
  665. package/dist/chunk-L2DHOOBX.js +0 -33
  666. package/dist/chunk-L2DHOOBX.js.map +0 -1
  667. package/dist/chunk-LEKZPKS2.js +0 -21
  668. package/dist/chunk-LEKZPKS2.js.map +0 -1
  669. package/dist/chunk-LHQP7CUJ.mjs +0 -107
  670. package/dist/chunk-LHQP7CUJ.mjs.map +0 -1
  671. package/dist/chunk-LOJA2ZS4.js +0 -107
  672. package/dist/chunk-LOJA2ZS4.js.map +0 -1
  673. package/dist/chunk-LQSEBGOX.js +0 -34
  674. package/dist/chunk-LQSEBGOX.js.map +0 -1
  675. package/dist/chunk-MDOG3S4V.mjs +0 -34
  676. package/dist/chunk-MDOG3S4V.mjs.map +0 -1
  677. package/dist/chunk-MFGLB75H.mjs +0 -22
  678. package/dist/chunk-MFGLB75H.mjs.map +0 -1
  679. package/dist/chunk-MKFQAXRF.js +0 -21
  680. package/dist/chunk-MKFQAXRF.js.map +0 -1
  681. package/dist/chunk-MQURBEO4.mjs +0 -16
  682. package/dist/chunk-MQURBEO4.mjs.map +0 -1
  683. package/dist/chunk-MWAZGSRO.js +0 -75
  684. package/dist/chunk-MWAZGSRO.js.map +0 -1
  685. package/dist/chunk-N2JAYIUP.mjs +0 -75
  686. package/dist/chunk-N2JAYIUP.mjs.map +0 -1
  687. package/dist/chunk-N4MA537G.js +0 -22
  688. package/dist/chunk-N4MA537G.js.map +0 -1
  689. package/dist/chunk-N5HVDE3P.mjs +0 -30
  690. package/dist/chunk-N5HVDE3P.mjs.map +0 -1
  691. package/dist/chunk-N722KRZW.js +0 -41
  692. package/dist/chunk-N722KRZW.js.map +0 -1
  693. package/dist/chunk-NNYGTNHP.mjs +0 -1
  694. package/dist/chunk-NNYGTNHP.mjs.map +0 -1
  695. package/dist/chunk-NSVVZNSD.mjs +0 -183
  696. package/dist/chunk-NSVVZNSD.mjs.map +0 -1
  697. package/dist/chunk-NUCLSR2G.js +0 -8
  698. package/dist/chunk-NUCLSR2G.js.map +0 -1
  699. package/dist/chunk-OBN2WDFU.js +0 -38
  700. package/dist/chunk-OBN2WDFU.js.map +0 -1
  701. package/dist/chunk-P252LKUT.mjs +0 -9
  702. package/dist/chunk-P252LKUT.mjs.map +0 -1
  703. package/dist/chunk-PAOTMYIM.mjs +0 -69
  704. package/dist/chunk-PAOTMYIM.mjs.map +0 -1
  705. package/dist/chunk-PJMEJVOB.mjs +0 -29
  706. package/dist/chunk-PJMEJVOB.mjs.map +0 -1
  707. package/dist/chunk-PLBSSUVY.js +0 -29
  708. package/dist/chunk-PLBSSUVY.js.map +0 -1
  709. package/dist/chunk-PLNIERDY.js +0 -34
  710. package/dist/chunk-PLNIERDY.js.map +0 -1
  711. package/dist/chunk-PO5BBHHX.mjs +0 -22
  712. package/dist/chunk-PO5BBHHX.mjs.map +0 -1
  713. package/dist/chunk-PTOH2SVI.mjs +0 -55
  714. package/dist/chunk-PTOH2SVI.mjs.map +0 -1
  715. package/dist/chunk-PZF4KWU2.mjs +0 -151
  716. package/dist/chunk-PZF4KWU2.mjs.map +0 -1
  717. package/dist/chunk-QD3LTING.js +0 -34
  718. package/dist/chunk-QD3LTING.js.map +0 -1
  719. package/dist/chunk-QGCNQRIQ.js +0 -35
  720. package/dist/chunk-QGCNQRIQ.js.map +0 -1
  721. package/dist/chunk-QYPLUMB7.mjs +0 -249
  722. package/dist/chunk-QYPLUMB7.mjs.map +0 -1
  723. package/dist/chunk-RAZ7XG4Z.mjs +0 -1
  724. package/dist/chunk-RAZ7XG4Z.mjs.map +0 -1
  725. package/dist/chunk-RNMJQSVQ.js +0 -69
  726. package/dist/chunk-RNMJQSVQ.js.map +0 -1
  727. package/dist/chunk-RRFKK45V.mjs +0 -15
  728. package/dist/chunk-RRFKK45V.mjs.map +0 -1
  729. package/dist/chunk-S3BWTUTZ.js +0 -31
  730. package/dist/chunk-S3BWTUTZ.js.map +0 -1
  731. package/dist/chunk-SKKANJ45.mjs +0 -19
  732. package/dist/chunk-SKKANJ45.mjs.map +0 -1
  733. package/dist/chunk-SPCIIRSB.mjs +0 -7
  734. package/dist/chunk-SPCIIRSB.mjs.map +0 -1
  735. package/dist/chunk-SRMDDOVO.mjs +0 -20
  736. package/dist/chunk-SRMDDOVO.mjs.map +0 -1
  737. package/dist/chunk-SYYDKPK3.js +0 -15
  738. package/dist/chunk-SYYDKPK3.js.map +0 -1
  739. package/dist/chunk-T2VA4YJE.js +0 -104
  740. package/dist/chunk-T2VA4YJE.js.map +0 -1
  741. package/dist/chunk-T3VM5YXY.js +0 -1
  742. package/dist/chunk-T3VM5YXY.js.map +0 -1
  743. package/dist/chunk-T3YY4JIJ.js +0 -9
  744. package/dist/chunk-T3YY4JIJ.js.map +0 -1
  745. package/dist/chunk-T5ZOOZ46.js +0 -22
  746. package/dist/chunk-T5ZOOZ46.js.map +0 -1
  747. package/dist/chunk-TAMKWZ4E.js +0 -183
  748. package/dist/chunk-TAMKWZ4E.js.map +0 -1
  749. package/dist/chunk-TFP64TMV.js +0 -1
  750. package/dist/chunk-TFP64TMV.js.map +0 -1
  751. package/dist/chunk-TYWGZIOF.mjs +0 -34
  752. package/dist/chunk-TYWGZIOF.mjs.map +0 -1
  753. package/dist/chunk-UAINMOUU.js +0 -18
  754. package/dist/chunk-UAINMOUU.js.map +0 -1
  755. package/dist/chunk-UNNEBOL4.mjs +0 -15
  756. package/dist/chunk-UNNEBOL4.mjs.map +0 -1
  757. package/dist/chunk-UW74NLTC.mjs +0 -18
  758. package/dist/chunk-UW74NLTC.mjs.map +0 -1
  759. package/dist/chunk-VBYSWMSU.js +0 -66
  760. package/dist/chunk-VBYSWMSU.js.map +0 -1
  761. package/dist/chunk-VEPYH26P.js +0 -27
  762. package/dist/chunk-VEPYH26P.js.map +0 -1
  763. package/dist/chunk-VIAHMNTA.mjs +0 -34
  764. package/dist/chunk-VIAHMNTA.mjs.map +0 -1
  765. package/dist/chunk-VWLBM7XM.js +0 -1
  766. package/dist/chunk-VWLBM7XM.js.map +0 -1
  767. package/dist/chunk-W7A3BYUP.mjs +0 -1
  768. package/dist/chunk-W7A3BYUP.mjs.map +0 -1
  769. package/dist/chunk-W7KRIAIX.js +0 -55
  770. package/dist/chunk-W7KRIAIX.js.map +0 -1
  771. package/dist/chunk-X2GGUOMY.js +0 -153
  772. package/dist/chunk-X2GGUOMY.js.map +0 -1
  773. package/dist/chunk-X3UZCGO5.mjs +0 -103
  774. package/dist/chunk-X3UZCGO5.mjs.map +0 -1
  775. package/dist/chunk-XF2AZMWG.mjs +0 -32
  776. package/dist/chunk-XF2AZMWG.mjs.map +0 -1
  777. package/dist/chunk-XWYJQWHG.js +0 -56
  778. package/dist/chunk-XWYJQWHG.js.map +0 -1
  779. package/dist/chunk-XZ7362GQ.mjs +0 -63
  780. package/dist/chunk-XZ7362GQ.mjs.map +0 -1
  781. package/dist/chunk-XZNJFDBF.mjs +0 -21
  782. package/dist/chunk-XZNJFDBF.mjs.map +0 -1
  783. package/dist/chunk-YJHQZFR4.mjs +0 -71
  784. package/dist/chunk-YJHQZFR4.mjs.map +0 -1
  785. package/dist/chunk-YL2EHYAA.js +0 -16
  786. package/dist/chunk-YL2EHYAA.js.map +0 -1
  787. package/dist/chunk-Z2JQNSVL.mjs +0 -8
  788. package/dist/chunk-Z2JQNSVL.mjs.map +0 -1
  789. package/dist/chunk-ZT3KKTS2.js +0 -9
  790. package/dist/chunk-ZT3KKTS2.js.map +0 -1
  791. package/dist/constants.js +0 -8
  792. package/dist/constants.js.map +0 -1
  793. package/dist/cronjob.js +0 -20
  794. package/dist/cronjob.js.map +0 -1
  795. package/dist/deep-clone.js +0 -8
  796. package/dist/deep-clone.js.map +0 -1
  797. package/dist/default-endowments.js +0 -8
  798. package/dist/default-endowments.js.map +0 -1
  799. package/dist/derivation-paths.js +0 -13
  800. package/dist/derivation-paths.js.map +0 -1
  801. package/dist/entropy.js +0 -10
  802. package/dist/entropy.js.map +0 -1
  803. package/dist/errors.js +0 -20
  804. package/dist/errors.js.map +0 -1
  805. package/dist/eval-worker.js +0 -43
  806. package/dist/eval-worker.js.map +0 -1
  807. package/dist/eval.js +0 -17
  808. package/dist/eval.js.map +0 -1
  809. package/dist/fs.js +0 -28
  810. package/dist/fs.js.map +0 -1
  811. package/dist/handler-types.js +0 -10
  812. package/dist/handler-types.js.map +0 -1
  813. package/dist/handlers.js +0 -35
  814. package/dist/handlers.js.map +0 -1
  815. package/dist/icon.js +0 -15
  816. package/dist/icon.js.map +0 -1
  817. package/dist/iframe.js +0 -8
  818. package/dist/iframe.js.map +0 -1
  819. package/dist/index.executionenv.js +0 -128
  820. package/dist/index.executionenv.js.map +0 -1
  821. package/dist/index.js +0 -398
  822. package/dist/index.js.map +0 -1
  823. package/dist/json-rpc.js +0 -18
  824. package/dist/json-rpc.js.map +0 -1
  825. package/dist/json.js +0 -10
  826. package/dist/json.js.map +0 -1
  827. package/dist/localization.js +0 -23
  828. package/dist/localization.js.map +0 -1
  829. package/dist/logging.js +0 -14
  830. package/dist/logging.js.map +0 -1
  831. package/dist/manifest/index.js +0 -65
  832. package/dist/manifest/index.js.map +0 -1
  833. package/dist/manifest/manifest.js +0 -59
  834. package/dist/manifest/manifest.js.map +0 -1
  835. package/dist/manifest/node.js +0 -106
  836. package/dist/manifest/node.js.map +0 -1
  837. package/dist/manifest/validation.js +0 -64
  838. package/dist/manifest/validation.js.map +0 -1
  839. package/dist/manifest/validator-types.js +0 -1
  840. package/dist/manifest/validator-types.js.map +0 -1
  841. package/dist/manifest/validator.js +0 -44
  842. package/dist/manifest/validator.js.map +0 -1
  843. package/dist/manifest/validators/checksum.js +0 -15
  844. package/dist/manifest/validators/checksum.js.map +0 -1
  845. package/dist/manifest/validators/expected-files.js +0 -9
  846. package/dist/manifest/validators/expected-files.js.map +0 -1
  847. package/dist/manifest/validators/icon-declared.js +0 -8
  848. package/dist/manifest/validators/icon-declared.js.map +0 -1
  849. package/dist/manifest/validators/icon-dimensions.js +0 -10
  850. package/dist/manifest/validators/icon-dimensions.js.map +0 -1
  851. package/dist/manifest/validators/icon-missing.js +0 -8
  852. package/dist/manifest/validators/icon-missing.js.map +0 -1
  853. package/dist/manifest/validators/index.js +0 -80
  854. package/dist/manifest/validators/index.js.map +0 -1
  855. package/dist/manifest/validators/is-localization-file.js +0 -12
  856. package/dist/manifest/validators/is-localization-file.js.map +0 -1
  857. package/dist/manifest/validators/is-package-json.js +0 -11
  858. package/dist/manifest/validators/is-package-json.js.map +0 -1
  859. package/dist/manifest/validators/is-snap-icon.js +0 -10
  860. package/dist/manifest/validators/is-snap-icon.js.map +0 -1
  861. package/dist/manifest/validators/is-snap-manifest.js +0 -23
  862. package/dist/manifest/validators/is-snap-manifest.js.map +0 -1
  863. package/dist/manifest/validators/manifest-localization.js +0 -10
  864. package/dist/manifest/validators/manifest-localization.js.map +0 -1
  865. package/dist/manifest/validators/package-json-recommended-fields.js +0 -8
  866. package/dist/manifest/validators/package-json-recommended-fields.js.map +0 -1
  867. package/dist/manifest/validators/package-name-match.js +0 -9
  868. package/dist/manifest/validators/package-name-match.js.map +0 -1
  869. package/dist/manifest/validators/repository-match.js +0 -10
  870. package/dist/manifest/validators/repository-match.js.map +0 -1
  871. package/dist/manifest/validators/version-match.js +0 -9
  872. package/dist/manifest/validators/version-match.js.map +0 -1
  873. package/dist/mock.js +0 -13
  874. package/dist/mock.js.map +0 -1
  875. package/dist/namespace.js +0 -44
  876. package/dist/namespace.js.map +0 -1
  877. package/dist/node.js +0 -476
  878. package/dist/node.js.map +0 -1
  879. package/dist/path.js +0 -8
  880. package/dist/path.js.map +0 -1
  881. package/dist/post-process.js +0 -10
  882. package/dist/post-process.js.map +0 -1
  883. package/dist/promise.js +0 -2
  884. package/dist/promise.js.map +0 -1
  885. package/dist/snaps.js +0 -46
  886. package/dist/snaps.js.map +0 -1
  887. package/dist/strings.js +0 -8
  888. package/dist/strings.js.map +0 -1
  889. package/dist/structs.js +0 -33
  890. package/dist/structs.js.map +0 -1
  891. package/dist/svg.js +0 -10
  892. package/dist/svg.js.map +0 -1
  893. package/dist/tsconfig.build.tsbuildinfo +0 -1
  894. package/dist/types/array.d.ts +0 -10
  895. package/dist/types/auxiliary-files.d.ts +0 -16
  896. package/dist/types/base64.d.ts +0 -15
  897. package/dist/types/bytes.d.ts +0 -8
  898. package/dist/types/caveats.d.ts +0 -46
  899. package/dist/types/checksum.d.ts +0 -21
  900. package/dist/types/constants.d.ts +0 -1
  901. package/dist/types/cronjob.d.ts +0 -89
  902. package/dist/types/deep-clone.d.ts +0 -1
  903. package/dist/types/default-endowments.d.ts +0 -4
  904. package/dist/types/derivation-paths.d.ts +0 -24
  905. package/dist/types/entropy.d.ts +0 -3
  906. package/dist/types/errors.d.ts +0 -84
  907. package/dist/types/eval-worker.d.ts +0 -1
  908. package/dist/types/eval.d.ts +0 -16
  909. package/dist/types/fs.d.ts +0 -69
  910. package/dist/types/handler-types.d.ts +0 -34
  911. package/dist/types/handlers.d.ts +0 -749
  912. package/dist/types/icon.d.ts +0 -19
  913. package/dist/types/iframe.d.ts +0 -11
  914. package/dist/types/iframe.test.browser.d.ts +0 -1
  915. package/dist/types/index.d.ts +0 -32
  916. package/dist/types/index.executionenv.d.ts +0 -7
  917. package/dist/types/json-rpc.d.ts +0 -55
  918. package/dist/types/json.d.ts +0 -22
  919. package/dist/types/localization.d.ts +0 -145
  920. package/dist/types/logging.d.ts +0 -49
  921. package/dist/types/manifest/index.d.ts +0 -1
  922. package/dist/types/manifest/manifest.d.ts +0 -98
  923. package/dist/types/manifest/node.d.ts +0 -2
  924. package/dist/types/manifest/validation.d.ts +0 -253
  925. package/dist/types/manifest/validator-types.d.ts +0 -34
  926. package/dist/types/manifest/validator.d.ts +0 -22
  927. package/dist/types/manifest/validators/checksum.d.ts +0 -5
  928. package/dist/types/manifest/validators/expected-files.d.ts +0 -5
  929. package/dist/types/manifest/validators/icon-declared.d.ts +0 -5
  930. package/dist/types/manifest/validators/icon-dimensions.d.ts +0 -5
  931. package/dist/types/manifest/validators/icon-missing.d.ts +0 -5
  932. package/dist/types/manifest/validators/index.d.ts +0 -14
  933. package/dist/types/manifest/validators/is-localization-file.d.ts +0 -5
  934. package/dist/types/manifest/validators/is-package-json.d.ts +0 -5
  935. package/dist/types/manifest/validators/is-snap-icon.d.ts +0 -5
  936. package/dist/types/manifest/validators/is-snap-manifest.d.ts +0 -5
  937. package/dist/types/manifest/validators/manifest-localization.d.ts +0 -5
  938. package/dist/types/manifest/validators/package-json-recommended-fields.d.ts +0 -5
  939. package/dist/types/manifest/validators/package-name-match.d.ts +0 -5
  940. package/dist/types/manifest/validators/repository-match.d.ts +0 -5
  941. package/dist/types/manifest/validators/version-match.d.ts +0 -5
  942. package/dist/types/mock.d.ts +0 -14
  943. package/dist/types/namespace.d.ts +0 -129
  944. package/dist/types/node.d.ts +0 -7
  945. package/dist/types/path.d.ts +0 -7
  946. package/dist/types/post-process.d.ts +0 -71
  947. package/dist/types/promise.d.ts +0 -1
  948. package/dist/types/snaps.d.ts +0 -169
  949. package/dist/types/strings.d.ts +0 -8
  950. package/dist/types/structs.d.ts +0 -180
  951. package/dist/types/svg.d.ts +0 -14
  952. package/dist/types/types.d.ts +0 -103
  953. package/dist/types/ui.d.ts +0 -84
  954. package/dist/types/validation.d.ts +0 -8
  955. package/dist/types/versions.d.ts +0 -21
  956. package/dist/types/virtual-file/VirtualFile.d.ts +0 -34
  957. package/dist/types/virtual-file/index.d.ts +0 -1
  958. package/dist/types/virtual-file/node.d.ts +0 -2
  959. package/dist/types/virtual-file/toVirtualFile.d.ts +0 -21
  960. package/dist/types.js +0 -22
  961. package/dist/types.js.map +0 -1
  962. package/dist/ui.js +0 -24
  963. package/dist/ui.js.map +0 -1
  964. package/dist/validation.js +0 -27
  965. package/dist/validation.js.map +0 -1
  966. package/dist/versions.js +0 -12
  967. package/dist/versions.js.map +0 -1
  968. package/dist/virtual-file/VirtualFile.js +0 -9
  969. package/dist/virtual-file/VirtualFile.js.map +0 -1
  970. package/dist/virtual-file/index.js +0 -10
  971. package/dist/virtual-file/index.js.map +0 -1
  972. package/dist/virtual-file/node.js +0 -17
  973. package/dist/virtual-file/node.js.map +0 -1
  974. package/dist/virtual-file/toVirtualFile.js +0 -12
  975. package/dist/virtual-file/toVirtualFile.js.map +0 -1
package/dist/eval.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"eval.mjs","sourceRoot":"","sources":["../src/eval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,wBAAwB;AACzC,OAAO,EAAE,IAAI,EAAE,sBAAsB;AACrC,OAAO,EAAE,IAAI,EAAE,aAAa;AAE5B,OAAO,EAAE,gBAAgB,EAAE,iBAAa;AAOxC,MAAM,OAAO,aAAc,SAAQ,KAAK;IAGtC,YAAY,OAAe,EAAE,MAAkB;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB;IACjD,MAAM,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAEnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE;YACpE,oEAAoE;YACpE,qDAAqD;YACrD,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QAEH,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;QACrD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;QAErD,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;YACxC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;YACxC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,QAAgB,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG;gBACb,MAAM;gBACN,MAAM;aACP,CAAC;YAEF,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;gBACnB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;YACzB,CAAC;YAED,OAAO,MAAM,CACX,IAAI,aAAa,CACf,2CAA2C,QAAQ,GAAG,EACtD,MAAM,CACP,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { assert } from '@metamask/utils';\nimport { fork } from 'child_process';\nimport { join } from 'path';\n\nimport { validateFilePath } from './fs';\n\nexport type EvalOutput = {\n stdout: string;\n stderr: string;\n};\n\nexport class SnapEvalError extends Error {\n readonly output: EvalOutput;\n\n constructor(message: string, output: EvalOutput) {\n super(message);\n\n this.name = 'SnapEvalError';\n this.output = output;\n }\n}\n\n/**\n * Spawn a new process to run the provided bundle in.\n *\n * @param bundlePath - The path to the bundle to run.\n * @returns `null` if the worker ran successfully.\n * @throws If the worker failed to run successfully.\n */\nexport async function evalBundle(bundlePath: string): Promise<EvalOutput> {\n await validateFilePath(bundlePath);\n\n return new Promise((resolve, reject) => {\n const worker = fork(join(__dirname, 'eval-worker.cjs'), [bundlePath], {\n // To avoid printing the output of the worker to the console, we set\n // `stdio` to `pipe` and handle the output ourselves.\n stdio: 'pipe',\n });\n\n let stdout = '';\n let stderr = '';\n\n assert(worker.stdout, '`stdout` should be defined.');\n assert(worker.stderr, '`stderr` should be defined.');\n\n worker.stdout.on('data', (data: Buffer) => {\n stdout += data.toString();\n });\n\n worker.stderr.on('data', (data: Buffer) => {\n stderr += data.toString();\n });\n\n worker.on('exit', (exitCode: number) => {\n const output = {\n stdout,\n stderr,\n };\n\n if (exitCode === 0) {\n return resolve(output);\n }\n\n return reject(\n new SnapEvalError(\n `Process exited with non-zero exit code: ${exitCode}.`,\n output,\n ),\n );\n });\n });\n}\n"]}
package/dist/fs.cjs ADDED
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useTemporaryFile = exports.validateDirPath = exports.validateFilePath = exports.validateOutfileName = exports.getOutfilePath = exports.readJsonFile = exports.isFile = exports.isDirectory = void 0;
7
+ const fs_1 = require("fs");
8
+ const os_1 = __importDefault(require("os"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const json_1 = require("./json.cjs");
11
+ const node_1 = require("./virtual-file/node.cjs");
12
+ /**
13
+ * Checks whether the given path string resolves to an existing directory, and
14
+ * optionally creates the directory if it doesn't exist.
15
+ *
16
+ * @param pathString - The path string to check.
17
+ * @param createDir - Whether to create the directory if it doesn't exist.
18
+ * @returns Whether the given path is an existing directory.
19
+ */
20
+ async function isDirectory(pathString, createDir) {
21
+ try {
22
+ const stats = await fs_1.promises.stat(pathString);
23
+ return stats.isDirectory();
24
+ }
25
+ catch (error) {
26
+ if (error.code === 'ENOENT') {
27
+ if (!createDir) {
28
+ return false;
29
+ }
30
+ await fs_1.promises.mkdir(pathString, { recursive: true });
31
+ return true;
32
+ }
33
+ return false;
34
+ }
35
+ }
36
+ exports.isDirectory = isDirectory;
37
+ /**
38
+ * Checks whether the given path string resolves to an existing file.
39
+ *
40
+ * @param pathString - The path string to check.
41
+ * @returns Whether the given path is an existing file.
42
+ */
43
+ async function isFile(pathString) {
44
+ try {
45
+ const stats = await fs_1.promises.stat(pathString);
46
+ return stats.isFile();
47
+ }
48
+ catch (error) {
49
+ return false;
50
+ }
51
+ }
52
+ exports.isFile = isFile;
53
+ /**
54
+ * Reads a `.json` file, parses its contents, and returns them.
55
+ *
56
+ * @param pathString - The path to the JSON file.
57
+ * @returns The parsed contents of the JSON file.
58
+ */
59
+ async function readJsonFile(pathString) {
60
+ if (!pathString.endsWith('.json')) {
61
+ throw new Error('The specified file must be a ".json" file.');
62
+ }
63
+ let file;
64
+ try {
65
+ file = await (0, node_1.readVirtualFile)(pathString, 'utf8');
66
+ }
67
+ catch (error) {
68
+ if (error.code === 'ENOENT') {
69
+ throw new Error(`Could not find '${pathString}'. Please ensure that the file exists.`);
70
+ }
71
+ throw error;
72
+ }
73
+ file.result = (0, json_1.parseJson)(file.toString());
74
+ return file;
75
+ }
76
+ exports.readJsonFile = readJsonFile;
77
+ /**
78
+ * Gets the complete out file path from an output file name and parent
79
+ * directory path.
80
+ *
81
+ * @param outDir - The path to the out file's parent directory.
82
+ * @param outFileName - The out file's name.
83
+ * @returns The complete path to the out file.
84
+ */
85
+ function getOutfilePath(outDir, outFileName) {
86
+ return path_1.default.join(outDir, outFileName || 'bundle.js');
87
+ }
88
+ exports.getOutfilePath = getOutfilePath;
89
+ /**
90
+ * Ensures that the outfile name is just a `.js` file name.
91
+ * Throws on validation failure.
92
+ *
93
+ * @param filename - The file name to validate.
94
+ * @returns `true` if validation succeeded.
95
+ * @throws If the file name is invalid.
96
+ */
97
+ function validateOutfileName(filename) {
98
+ if (!filename.endsWith('.js') ||
99
+ filename === '.js' ||
100
+ path_1.default.basename(filename) !== filename) {
101
+ throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);
102
+ }
103
+ return true;
104
+ }
105
+ exports.validateOutfileName = validateOutfileName;
106
+ /**
107
+ * Validates a file path. Throws on validation failure.
108
+ *
109
+ * @param filePath - The file path to validate.
110
+ * @returns `true` if validation succeeded.
111
+ * @throws If the path does not resolve to a file.
112
+ */
113
+ async function validateFilePath(filePath) {
114
+ const exists = await isFile(filePath);
115
+ if (!exists) {
116
+ throw new Error(`Invalid params: '${filePath}' is not a file or does not exist.`);
117
+ }
118
+ return true;
119
+ }
120
+ exports.validateFilePath = validateFilePath;
121
+ /**
122
+ * Validates a directory path. Throws on validation failure.
123
+ *
124
+ * @param dirPath - The directory path to validate.
125
+ * @param createDir - Whether to create the directory if it doesn't exist.
126
+ * @returns `true` if validation succeeded or the directory was created.
127
+ * @throws If the directory does not exist or could not be created.
128
+ */
129
+ async function validateDirPath(dirPath, createDir) {
130
+ const exists = await isDirectory(dirPath, createDir);
131
+ if (!exists) {
132
+ throw new Error(`Invalid params: '${dirPath}' is not a directory or could not be created.`);
133
+ }
134
+ return true;
135
+ }
136
+ exports.validateDirPath = validateDirPath;
137
+ /**
138
+ * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.
139
+ * This function handles deletion of the temporary file after usage.
140
+ *
141
+ * @param fileName - The name of the temporary file.
142
+ * @param fileContents - The content of the temporary file.
143
+ * @param fn - The callback function to call when the temporary file has been created.
144
+ */
145
+ async function useTemporaryFile(fileName, fileContents, fn) {
146
+ const filePath = path_1.default.join(os_1.default.tmpdir(), fileName);
147
+ await fs_1.promises.mkdir(path_1.default.dirname(filePath), { recursive: true });
148
+ await fs_1.promises.writeFile(filePath, fileContents);
149
+ try {
150
+ await fn(filePath);
151
+ }
152
+ finally {
153
+ if (await isFile(filePath)) {
154
+ await fs_1.promises.unlink(filePath);
155
+ }
156
+ }
157
+ }
158
+ exports.useTemporaryFile = useTemporaryFile;
159
+ //# sourceMappingURL=fs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.cjs","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Json } from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport os from 'os';\nimport pathUtils from 'path';\n\nimport { parseJson } from './json';\nimport type { VirtualFile } from './virtual-file';\nimport { readVirtualFile } from './virtual-file/node';\n\n/**\n * Checks whether the given path string resolves to an existing directory, and\n * optionally creates the directory if it doesn't exist.\n *\n * @param pathString - The path string to check.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns Whether the given path is an existing directory.\n */\nexport async function isDirectory(\n pathString: string,\n createDir: boolean,\n): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isDirectory();\n } catch (error) {\n if (error.code === 'ENOENT') {\n if (!createDir) {\n return false;\n }\n\n await fs.mkdir(pathString, { recursive: true });\n return true;\n }\n\n return false;\n }\n}\n\n/**\n * Checks whether the given path string resolves to an existing file.\n *\n * @param pathString - The path string to check.\n * @returns Whether the given path is an existing file.\n */\nexport async function isFile(pathString: string): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isFile();\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Reads a `.json` file, parses its contents, and returns them.\n *\n * @param pathString - The path to the JSON file.\n * @returns The parsed contents of the JSON file.\n */\nexport async function readJsonFile<Type extends Json = Json>(\n pathString: string,\n): Promise<VirtualFile<Type>> {\n if (!pathString.endsWith('.json')) {\n throw new Error('The specified file must be a \".json\" file.');\n }\n\n let file;\n try {\n file = await readVirtualFile(pathString, 'utf8');\n } catch (error) {\n if (error.code === 'ENOENT') {\n throw new Error(\n `Could not find '${pathString}'. Please ensure that the file exists.`,\n );\n }\n\n throw error;\n }\n file.result = parseJson(file.toString());\n return file as VirtualFile<Type>;\n}\n\n/**\n * Gets the complete out file path from an output file name and parent\n * directory path.\n *\n * @param outDir - The path to the out file's parent directory.\n * @param outFileName - The out file's name.\n * @returns The complete path to the out file.\n */\nexport function getOutfilePath(outDir: string, outFileName: string): string {\n return pathUtils.join(outDir, outFileName || 'bundle.js');\n}\n\n/**\n * Ensures that the outfile name is just a `.js` file name.\n * Throws on validation failure.\n *\n * @param filename - The file name to validate.\n * @returns `true` if validation succeeded.\n * @throws If the file name is invalid.\n */\nexport function validateOutfileName(filename: string): boolean {\n if (\n !filename.endsWith('.js') ||\n filename === '.js' ||\n pathUtils.basename(filename) !== filename\n ) {\n throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);\n }\n return true;\n}\n\n/**\n * Validates a file path. Throws on validation failure.\n *\n * @param filePath - The file path to validate.\n * @returns `true` if validation succeeded.\n * @throws If the path does not resolve to a file.\n */\nexport async function validateFilePath(filePath: string): Promise<boolean> {\n const exists = await isFile(filePath);\n if (!exists) {\n throw new Error(\n `Invalid params: '${filePath}' is not a file or does not exist.`,\n );\n }\n return true;\n}\n\n/**\n * Validates a directory path. Throws on validation failure.\n *\n * @param dirPath - The directory path to validate.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns `true` if validation succeeded or the directory was created.\n * @throws If the directory does not exist or could not be created.\n */\nexport async function validateDirPath(\n dirPath: string,\n createDir: boolean,\n): Promise<boolean> {\n const exists = await isDirectory(dirPath, createDir);\n if (!exists) {\n throw new Error(\n `Invalid params: '${dirPath}' is not a directory or could not be created.`,\n );\n }\n return true;\n}\n\n/**\n * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.\n * This function handles deletion of the temporary file after usage.\n *\n * @param fileName - The name of the temporary file.\n * @param fileContents - The content of the temporary file.\n * @param fn - The callback function to call when the temporary file has been created.\n */\nexport async function useTemporaryFile(\n fileName: string,\n fileContents: string,\n fn: (path: string) => Promise<unknown>,\n): Promise<void> {\n const filePath = pathUtils.join(os.tmpdir(), fileName);\n await fs.mkdir(pathUtils.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, fileContents);\n try {\n await fn(filePath);\n } finally {\n if (await isFile(filePath)) {\n await fs.unlink(filePath);\n }\n }\n}\n"]}
package/dist/fs.d.cts ADDED
@@ -0,0 +1,70 @@
1
+ import type { Json } from "@metamask/utils";
2
+ import type { VirtualFile } from "./virtual-file/index.cjs";
3
+ /**
4
+ * Checks whether the given path string resolves to an existing directory, and
5
+ * optionally creates the directory if it doesn't exist.
6
+ *
7
+ * @param pathString - The path string to check.
8
+ * @param createDir - Whether to create the directory if it doesn't exist.
9
+ * @returns Whether the given path is an existing directory.
10
+ */
11
+ export declare function isDirectory(pathString: string, createDir: boolean): Promise<boolean>;
12
+ /**
13
+ * Checks whether the given path string resolves to an existing file.
14
+ *
15
+ * @param pathString - The path string to check.
16
+ * @returns Whether the given path is an existing file.
17
+ */
18
+ export declare function isFile(pathString: string): Promise<boolean>;
19
+ /**
20
+ * Reads a `.json` file, parses its contents, and returns them.
21
+ *
22
+ * @param pathString - The path to the JSON file.
23
+ * @returns The parsed contents of the JSON file.
24
+ */
25
+ export declare function readJsonFile<Type extends Json = Json>(pathString: string): Promise<VirtualFile<Type>>;
26
+ /**
27
+ * Gets the complete out file path from an output file name and parent
28
+ * directory path.
29
+ *
30
+ * @param outDir - The path to the out file's parent directory.
31
+ * @param outFileName - The out file's name.
32
+ * @returns The complete path to the out file.
33
+ */
34
+ export declare function getOutfilePath(outDir: string, outFileName: string): string;
35
+ /**
36
+ * Ensures that the outfile name is just a `.js` file name.
37
+ * Throws on validation failure.
38
+ *
39
+ * @param filename - The file name to validate.
40
+ * @returns `true` if validation succeeded.
41
+ * @throws If the file name is invalid.
42
+ */
43
+ export declare function validateOutfileName(filename: string): boolean;
44
+ /**
45
+ * Validates a file path. Throws on validation failure.
46
+ *
47
+ * @param filePath - The file path to validate.
48
+ * @returns `true` if validation succeeded.
49
+ * @throws If the path does not resolve to a file.
50
+ */
51
+ export declare function validateFilePath(filePath: string): Promise<boolean>;
52
+ /**
53
+ * Validates a directory path. Throws on validation failure.
54
+ *
55
+ * @param dirPath - The directory path to validate.
56
+ * @param createDir - Whether to create the directory if it doesn't exist.
57
+ * @returns `true` if validation succeeded or the directory was created.
58
+ * @throws If the directory does not exist or could not be created.
59
+ */
60
+ export declare function validateDirPath(dirPath: string, createDir: boolean): Promise<boolean>;
61
+ /**
62
+ * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.
63
+ * This function handles deletion of the temporary file after usage.
64
+ *
65
+ * @param fileName - The name of the temporary file.
66
+ * @param fileContents - The content of the temporary file.
67
+ * @param fn - The callback function to call when the temporary file has been created.
68
+ */
69
+ export declare function useTemporaryFile(fileName: string, fileContents: string, fn: (path: string) => Promise<unknown>): Promise<void>;
70
+ //# sourceMappingURL=fs.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.cts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAM5C,OAAO,KAAK,EAAE,WAAW,EAAE,iCAAuB;AAGlD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOjE;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,SAAS,IAAI,GAAG,IAAI,EACzD,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAmB5B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAS7D;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQzE;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GACrC,OAAO,CAAC,IAAI,CAAC,CAWf"}
package/dist/fs.d.mts ADDED
@@ -0,0 +1,70 @@
1
+ import type { Json } from "@metamask/utils";
2
+ import type { VirtualFile } from "./virtual-file/index.mjs";
3
+ /**
4
+ * Checks whether the given path string resolves to an existing directory, and
5
+ * optionally creates the directory if it doesn't exist.
6
+ *
7
+ * @param pathString - The path string to check.
8
+ * @param createDir - Whether to create the directory if it doesn't exist.
9
+ * @returns Whether the given path is an existing directory.
10
+ */
11
+ export declare function isDirectory(pathString: string, createDir: boolean): Promise<boolean>;
12
+ /**
13
+ * Checks whether the given path string resolves to an existing file.
14
+ *
15
+ * @param pathString - The path string to check.
16
+ * @returns Whether the given path is an existing file.
17
+ */
18
+ export declare function isFile(pathString: string): Promise<boolean>;
19
+ /**
20
+ * Reads a `.json` file, parses its contents, and returns them.
21
+ *
22
+ * @param pathString - The path to the JSON file.
23
+ * @returns The parsed contents of the JSON file.
24
+ */
25
+ export declare function readJsonFile<Type extends Json = Json>(pathString: string): Promise<VirtualFile<Type>>;
26
+ /**
27
+ * Gets the complete out file path from an output file name and parent
28
+ * directory path.
29
+ *
30
+ * @param outDir - The path to the out file's parent directory.
31
+ * @param outFileName - The out file's name.
32
+ * @returns The complete path to the out file.
33
+ */
34
+ export declare function getOutfilePath(outDir: string, outFileName: string): string;
35
+ /**
36
+ * Ensures that the outfile name is just a `.js` file name.
37
+ * Throws on validation failure.
38
+ *
39
+ * @param filename - The file name to validate.
40
+ * @returns `true` if validation succeeded.
41
+ * @throws If the file name is invalid.
42
+ */
43
+ export declare function validateOutfileName(filename: string): boolean;
44
+ /**
45
+ * Validates a file path. Throws on validation failure.
46
+ *
47
+ * @param filePath - The file path to validate.
48
+ * @returns `true` if validation succeeded.
49
+ * @throws If the path does not resolve to a file.
50
+ */
51
+ export declare function validateFilePath(filePath: string): Promise<boolean>;
52
+ /**
53
+ * Validates a directory path. Throws on validation failure.
54
+ *
55
+ * @param dirPath - The directory path to validate.
56
+ * @param createDir - Whether to create the directory if it doesn't exist.
57
+ * @returns `true` if validation succeeded or the directory was created.
58
+ * @throws If the directory does not exist or could not be created.
59
+ */
60
+ export declare function validateDirPath(dirPath: string, createDir: boolean): Promise<boolean>;
61
+ /**
62
+ * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.
63
+ * This function handles deletion of the temporary file after usage.
64
+ *
65
+ * @param fileName - The name of the temporary file.
66
+ * @param fileContents - The content of the temporary file.
67
+ * @param fn - The callback function to call when the temporary file has been created.
68
+ */
69
+ export declare function useTemporaryFile(fileName: string, fileContents: string, fn: (path: string) => Promise<unknown>): Promise<void>;
70
+ //# sourceMappingURL=fs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.mts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAM5C,OAAO,KAAK,EAAE,WAAW,EAAE,iCAAuB;AAGlD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOjE;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,SAAS,IAAI,GAAG,IAAI,EACzD,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAmB5B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAS7D;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQzE;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GACrC,OAAO,CAAC,IAAI,CAAC,CAWf"}
package/dist/fs.mjs CHANGED
@@ -1,28 +1,145 @@
1
- import {
2
- getOutfilePath,
3
- isDirectory,
4
- isFile,
5
- readJsonFile,
6
- useTemporaryFile,
7
- validateDirPath,
8
- validateFilePath,
9
- validateOutfileName
10
- } from "./chunk-X3UZCGO5.mjs";
11
- import "./chunk-RAZ7XG4Z.mjs";
12
- import "./chunk-XZNJFDBF.mjs";
13
- import "./chunk-HYF7Q6VY.mjs";
14
- import "./chunk-UNNEBOL4.mjs";
15
- import "./chunk-DE22V5AO.mjs";
16
- import "./chunk-Z2JQNSVL.mjs";
17
- import "./chunk-3RUWAMJT.mjs";
18
- export {
19
- getOutfilePath,
20
- isDirectory,
21
- isFile,
22
- readJsonFile,
23
- useTemporaryFile,
24
- validateDirPath,
25
- validateFilePath,
26
- validateOutfileName
27
- };
1
+ import { promises as fs } from "fs";
2
+ import os from "os";
3
+ import pathUtils from "path";
4
+ import { parseJson } from "./json.mjs";
5
+ import { readVirtualFile } from "./virtual-file/node.mjs";
6
+ /**
7
+ * Checks whether the given path string resolves to an existing directory, and
8
+ * optionally creates the directory if it doesn't exist.
9
+ *
10
+ * @param pathString - The path string to check.
11
+ * @param createDir - Whether to create the directory if it doesn't exist.
12
+ * @returns Whether the given path is an existing directory.
13
+ */
14
+ export async function isDirectory(pathString, createDir) {
15
+ try {
16
+ const stats = await fs.stat(pathString);
17
+ return stats.isDirectory();
18
+ }
19
+ catch (error) {
20
+ if (error.code === 'ENOENT') {
21
+ if (!createDir) {
22
+ return false;
23
+ }
24
+ await fs.mkdir(pathString, { recursive: true });
25
+ return true;
26
+ }
27
+ return false;
28
+ }
29
+ }
30
+ /**
31
+ * Checks whether the given path string resolves to an existing file.
32
+ *
33
+ * @param pathString - The path string to check.
34
+ * @returns Whether the given path is an existing file.
35
+ */
36
+ export async function isFile(pathString) {
37
+ try {
38
+ const stats = await fs.stat(pathString);
39
+ return stats.isFile();
40
+ }
41
+ catch (error) {
42
+ return false;
43
+ }
44
+ }
45
+ /**
46
+ * Reads a `.json` file, parses its contents, and returns them.
47
+ *
48
+ * @param pathString - The path to the JSON file.
49
+ * @returns The parsed contents of the JSON file.
50
+ */
51
+ export async function readJsonFile(pathString) {
52
+ if (!pathString.endsWith('.json')) {
53
+ throw new Error('The specified file must be a ".json" file.');
54
+ }
55
+ let file;
56
+ try {
57
+ file = await readVirtualFile(pathString, 'utf8');
58
+ }
59
+ catch (error) {
60
+ if (error.code === 'ENOENT') {
61
+ throw new Error(`Could not find '${pathString}'. Please ensure that the file exists.`);
62
+ }
63
+ throw error;
64
+ }
65
+ file.result = parseJson(file.toString());
66
+ return file;
67
+ }
68
+ /**
69
+ * Gets the complete out file path from an output file name and parent
70
+ * directory path.
71
+ *
72
+ * @param outDir - The path to the out file's parent directory.
73
+ * @param outFileName - The out file's name.
74
+ * @returns The complete path to the out file.
75
+ */
76
+ export function getOutfilePath(outDir, outFileName) {
77
+ return pathUtils.join(outDir, outFileName || 'bundle.js');
78
+ }
79
+ /**
80
+ * Ensures that the outfile name is just a `.js` file name.
81
+ * Throws on validation failure.
82
+ *
83
+ * @param filename - The file name to validate.
84
+ * @returns `true` if validation succeeded.
85
+ * @throws If the file name is invalid.
86
+ */
87
+ export function validateOutfileName(filename) {
88
+ if (!filename.endsWith('.js') ||
89
+ filename === '.js' ||
90
+ pathUtils.basename(filename) !== filename) {
91
+ throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);
92
+ }
93
+ return true;
94
+ }
95
+ /**
96
+ * Validates a file path. Throws on validation failure.
97
+ *
98
+ * @param filePath - The file path to validate.
99
+ * @returns `true` if validation succeeded.
100
+ * @throws If the path does not resolve to a file.
101
+ */
102
+ export async function validateFilePath(filePath) {
103
+ const exists = await isFile(filePath);
104
+ if (!exists) {
105
+ throw new Error(`Invalid params: '${filePath}' is not a file or does not exist.`);
106
+ }
107
+ return true;
108
+ }
109
+ /**
110
+ * Validates a directory path. Throws on validation failure.
111
+ *
112
+ * @param dirPath - The directory path to validate.
113
+ * @param createDir - Whether to create the directory if it doesn't exist.
114
+ * @returns `true` if validation succeeded or the directory was created.
115
+ * @throws If the directory does not exist or could not be created.
116
+ */
117
+ export async function validateDirPath(dirPath, createDir) {
118
+ const exists = await isDirectory(dirPath, createDir);
119
+ if (!exists) {
120
+ throw new Error(`Invalid params: '${dirPath}' is not a directory or could not be created.`);
121
+ }
122
+ return true;
123
+ }
124
+ /**
125
+ * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.
126
+ * This function handles deletion of the temporary file after usage.
127
+ *
128
+ * @param fileName - The name of the temporary file.
129
+ * @param fileContents - The content of the temporary file.
130
+ * @param fn - The callback function to call when the temporary file has been created.
131
+ */
132
+ export async function useTemporaryFile(fileName, fileContents, fn) {
133
+ const filePath = pathUtils.join(os.tmpdir(), fileName);
134
+ await fs.mkdir(pathUtils.dirname(filePath), { recursive: true });
135
+ await fs.writeFile(filePath, fileContents);
136
+ try {
137
+ await fn(filePath);
138
+ }
139
+ finally {
140
+ if (await isFile(filePath)) {
141
+ await fs.unlink(filePath);
142
+ }
143
+ }
144
+ }
28
145
  //# sourceMappingURL=fs.mjs.map
package/dist/fs.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"fs.mjs","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Json } from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport os from 'os';\nimport pathUtils from 'path';\n\nimport { parseJson } from './json';\nimport type { VirtualFile } from './virtual-file';\nimport { readVirtualFile } from './virtual-file/node';\n\n/**\n * Checks whether the given path string resolves to an existing directory, and\n * optionally creates the directory if it doesn't exist.\n *\n * @param pathString - The path string to check.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns Whether the given path is an existing directory.\n */\nexport async function isDirectory(\n pathString: string,\n createDir: boolean,\n): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isDirectory();\n } catch (error) {\n if (error.code === 'ENOENT') {\n if (!createDir) {\n return false;\n }\n\n await fs.mkdir(pathString, { recursive: true });\n return true;\n }\n\n return false;\n }\n}\n\n/**\n * Checks whether the given path string resolves to an existing file.\n *\n * @param pathString - The path string to check.\n * @returns Whether the given path is an existing file.\n */\nexport async function isFile(pathString: string): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isFile();\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Reads a `.json` file, parses its contents, and returns them.\n *\n * @param pathString - The path to the JSON file.\n * @returns The parsed contents of the JSON file.\n */\nexport async function readJsonFile<Type extends Json = Json>(\n pathString: string,\n): Promise<VirtualFile<Type>> {\n if (!pathString.endsWith('.json')) {\n throw new Error('The specified file must be a \".json\" file.');\n }\n\n let file;\n try {\n file = await readVirtualFile(pathString, 'utf8');\n } catch (error) {\n if (error.code === 'ENOENT') {\n throw new Error(\n `Could not find '${pathString}'. Please ensure that the file exists.`,\n );\n }\n\n throw error;\n }\n file.result = parseJson(file.toString());\n return file as VirtualFile<Type>;\n}\n\n/**\n * Gets the complete out file path from an output file name and parent\n * directory path.\n *\n * @param outDir - The path to the out file's parent directory.\n * @param outFileName - The out file's name.\n * @returns The complete path to the out file.\n */\nexport function getOutfilePath(outDir: string, outFileName: string): string {\n return pathUtils.join(outDir, outFileName || 'bundle.js');\n}\n\n/**\n * Ensures that the outfile name is just a `.js` file name.\n * Throws on validation failure.\n *\n * @param filename - The file name to validate.\n * @returns `true` if validation succeeded.\n * @throws If the file name is invalid.\n */\nexport function validateOutfileName(filename: string): boolean {\n if (\n !filename.endsWith('.js') ||\n filename === '.js' ||\n pathUtils.basename(filename) !== filename\n ) {\n throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);\n }\n return true;\n}\n\n/**\n * Validates a file path. Throws on validation failure.\n *\n * @param filePath - The file path to validate.\n * @returns `true` if validation succeeded.\n * @throws If the path does not resolve to a file.\n */\nexport async function validateFilePath(filePath: string): Promise<boolean> {\n const exists = await isFile(filePath);\n if (!exists) {\n throw new Error(\n `Invalid params: '${filePath}' is not a file or does not exist.`,\n );\n }\n return true;\n}\n\n/**\n * Validates a directory path. Throws on validation failure.\n *\n * @param dirPath - The directory path to validate.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns `true` if validation succeeded or the directory was created.\n * @throws If the directory does not exist or could not be created.\n */\nexport async function validateDirPath(\n dirPath: string,\n createDir: boolean,\n): Promise<boolean> {\n const exists = await isDirectory(dirPath, createDir);\n if (!exists) {\n throw new Error(\n `Invalid params: '${dirPath}' is not a directory or could not be created.`,\n );\n }\n return true;\n}\n\n/**\n * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.\n * This function handles deletion of the temporary file after usage.\n *\n * @param fileName - The name of the temporary file.\n * @param fileContents - The content of the temporary file.\n * @param fn - The callback function to call when the temporary file has been created.\n */\nexport async function useTemporaryFile(\n fileName: string,\n fileContents: string,\n fn: (path: string) => Promise<unknown>,\n): Promise<void> {\n const filePath = pathUtils.join(os.tmpdir(), fileName);\n await fs.mkdir(pathUtils.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, fileContents);\n try {\n await fn(filePath);\n } finally {\n if (await isFile(filePath)) {\n await fs.unlink(filePath);\n }\n }\n}\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SNAP_EXPORT_NAMES = exports.HandlerType = void 0;
4
+ var HandlerType;
5
+ (function (HandlerType) {
6
+ HandlerType["OnRpcRequest"] = "onRpcRequest";
7
+ HandlerType["OnSignature"] = "onSignature";
8
+ HandlerType["OnTransaction"] = "onTransaction";
9
+ HandlerType["OnCronjob"] = "onCronjob";
10
+ HandlerType["OnInstall"] = "onInstall";
11
+ HandlerType["OnUpdate"] = "onUpdate";
12
+ HandlerType["OnNameLookup"] = "onNameLookup";
13
+ HandlerType["OnKeyringRequest"] = "onKeyringRequest";
14
+ HandlerType["OnHomePage"] = "onHomePage";
15
+ HandlerType["OnUserInput"] = "onUserInput";
16
+ })(HandlerType || (exports.HandlerType = HandlerType = {}));
17
+ exports.SNAP_EXPORT_NAMES = Object.values(HandlerType);
18
+ //# sourceMappingURL=handler-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-types.cjs","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAWX;AAXD,WAAY,WAAW;IACrB,4CAA6B,CAAA;IAC7B,0CAA2B,CAAA;IAC3B,8CAA+B,CAAA;IAC/B,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,4CAA6B,CAAA;IAC7B,oDAAqC,CAAA;IACrC,wCAAyB,CAAA;IACzB,0CAA2B,CAAA;AAC7B,CAAC,EAXW,WAAW,2BAAX,WAAW,QAWtB;AA0BY,QAAA,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["export enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnSignature = 'onSignature',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnNameLookup = 'onNameLookup',\n OnKeyringRequest = 'onKeyringRequest',\n OnHomePage = 'onHomePage',\n OnUserInput = 'onUserInput',\n}\n\nexport type SnapHandler = {\n /**\n * The type of handler.\n */\n type: HandlerType;\n\n /**\n * Whether the handler is required, i.e., whether the request will fail if the\n * handler is called, but the snap does not export it.\n *\n * This is primarily used for the lifecycle handlers, which are optional.\n */\n required: boolean;\n\n /**\n * Validate the given snap export. This should return a type guard for the\n * handler type.\n *\n * @param snapExport - The export to validate.\n * @returns Whether the export is valid.\n */\n validator: (snapExport: unknown) => boolean;\n};\n\nexport const SNAP_EXPORT_NAMES = Object.values(HandlerType);\n"]}
@@ -0,0 +1,35 @@
1
+ export declare enum HandlerType {
2
+ OnRpcRequest = "onRpcRequest",
3
+ OnSignature = "onSignature",
4
+ OnTransaction = "onTransaction",
5
+ OnCronjob = "onCronjob",
6
+ OnInstall = "onInstall",
7
+ OnUpdate = "onUpdate",
8
+ OnNameLookup = "onNameLookup",
9
+ OnKeyringRequest = "onKeyringRequest",
10
+ OnHomePage = "onHomePage",
11
+ OnUserInput = "onUserInput"
12
+ }
13
+ export type SnapHandler = {
14
+ /**
15
+ * The type of handler.
16
+ */
17
+ type: HandlerType;
18
+ /**
19
+ * Whether the handler is required, i.e., whether the request will fail if the
20
+ * handler is called, but the snap does not export it.
21
+ *
22
+ * This is primarily used for the lifecycle handlers, which are optional.
23
+ */
24
+ required: boolean;
25
+ /**
26
+ * Validate the given snap export. This should return a type guard for the
27
+ * handler type.
28
+ *
29
+ * @param snapExport - The export to validate.
30
+ * @returns Whether the export is valid.
31
+ */
32
+ validator: (snapExport: unknown) => boolean;
33
+ };
34
+ export declare const SNAP_EXPORT_NAMES: HandlerType[];
35
+ //# sourceMappingURL=handler-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-types.d.cts","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,WAAW,gBAAgB;CAC5B;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAA6B,CAAC"}
@@ -0,0 +1,35 @@
1
+ export declare enum HandlerType {
2
+ OnRpcRequest = "onRpcRequest",
3
+ OnSignature = "onSignature",
4
+ OnTransaction = "onTransaction",
5
+ OnCronjob = "onCronjob",
6
+ OnInstall = "onInstall",
7
+ OnUpdate = "onUpdate",
8
+ OnNameLookup = "onNameLookup",
9
+ OnKeyringRequest = "onKeyringRequest",
10
+ OnHomePage = "onHomePage",
11
+ OnUserInput = "onUserInput"
12
+ }
13
+ export type SnapHandler = {
14
+ /**
15
+ * The type of handler.
16
+ */
17
+ type: HandlerType;
18
+ /**
19
+ * Whether the handler is required, i.e., whether the request will fail if the
20
+ * handler is called, but the snap does not export it.
21
+ *
22
+ * This is primarily used for the lifecycle handlers, which are optional.
23
+ */
24
+ required: boolean;
25
+ /**
26
+ * Validate the given snap export. This should return a type guard for the
27
+ * handler type.
28
+ *
29
+ * @param snapExport - The export to validate.
30
+ * @returns Whether the export is valid.
31
+ */
32
+ validator: (snapExport: unknown) => boolean;
33
+ };
34
+ export declare const SNAP_EXPORT_NAMES: HandlerType[];
35
+ //# sourceMappingURL=handler-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-types.d.mts","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,WAAW,gBAAgB;CAC5B;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAA6B,CAAC"}