@metamask/snaps-cli 5.1.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/builders.js +10 -0
  3. package/dist/builders.js.map +1 -0
  4. package/dist/builders.mjs +10 -0
  5. package/dist/builders.mjs.map +1 -0
  6. package/dist/chunk-25SLEORF.mjs +28 -0
  7. package/dist/chunk-25SLEORF.mjs.map +1 -0
  8. package/dist/chunk-2QVYYMUD.js +365 -0
  9. package/dist/chunk-2QVYYMUD.js.map +1 -0
  10. package/dist/{esm/webpack/config.js → chunk-3LNPS7AX.js} +182 -156
  11. package/dist/chunk-3LNPS7AX.js.map +1 -0
  12. package/dist/chunk-46JUPGRY.js +22 -0
  13. package/dist/chunk-46JUPGRY.js.map +1 -0
  14. package/dist/chunk-4NHBPMKT.js +54 -0
  15. package/dist/chunk-4NHBPMKT.js.map +1 -0
  16. package/dist/chunk-4OKAI7AP.js +52 -0
  17. package/dist/chunk-4OKAI7AP.js.map +1 -0
  18. package/dist/chunk-5DDAAM2X.js +41 -0
  19. package/dist/chunk-5DDAAM2X.js.map +1 -0
  20. package/dist/chunk-5DSV76XV.mjs +10 -0
  21. package/dist/chunk-5DSV76XV.mjs.map +1 -0
  22. package/dist/chunk-5JPLNWCO.js +24 -0
  23. package/dist/chunk-5JPLNWCO.js.map +1 -0
  24. package/dist/chunk-5VAZH7L7.js +64 -0
  25. package/dist/chunk-5VAZH7L7.js.map +1 -0
  26. package/dist/chunk-5YUHRLH6.js +22 -0
  27. package/dist/chunk-5YUHRLH6.js.map +1 -0
  28. package/dist/chunk-6IF2UBYA.mjs +13 -0
  29. package/dist/chunk-6IF2UBYA.mjs.map +1 -0
  30. package/dist/chunk-6NJAXMSB.js +135 -0
  31. package/dist/chunk-6NJAXMSB.js.map +1 -0
  32. package/dist/chunk-6VFUO2H5.mjs +124 -0
  33. package/dist/chunk-6VFUO2H5.mjs.map +1 -0
  34. package/dist/chunk-7SN4Y44H.js +287 -0
  35. package/dist/chunk-7SN4Y44H.js.map +1 -0
  36. package/dist/chunk-ASOCIPDR.js +10 -0
  37. package/dist/chunk-ASOCIPDR.js.map +1 -0
  38. package/dist/chunk-B455GFXP.mjs +54 -0
  39. package/dist/chunk-B455GFXP.mjs.map +1 -0
  40. package/dist/chunk-DWS4BJTE.mjs +64 -0
  41. package/dist/chunk-DWS4BJTE.mjs.map +1 -0
  42. package/dist/chunk-EQRMXKXY.js +346 -0
  43. package/dist/chunk-EQRMXKXY.js.map +1 -0
  44. package/dist/chunk-EXGQAOQS.js +64 -0
  45. package/dist/chunk-EXGQAOQS.js.map +1 -0
  46. package/dist/chunk-EXJCMAUI.mjs +23 -0
  47. package/dist/chunk-EXJCMAUI.mjs.map +1 -0
  48. package/dist/chunk-FPG4GBXZ.js +30 -0
  49. package/dist/chunk-FPG4GBXZ.js.map +1 -0
  50. package/dist/chunk-FYTQTDZU.mjs +52 -0
  51. package/dist/chunk-FYTQTDZU.mjs.map +1 -0
  52. package/dist/chunk-G3IYVYVR.js +31 -0
  53. package/dist/chunk-G3IYVYVR.js.map +1 -0
  54. package/dist/chunk-GC7BNDLY.js +23 -0
  55. package/dist/chunk-GC7BNDLY.js.map +1 -0
  56. package/dist/chunk-GKG7TO7T.js +28 -0
  57. package/dist/chunk-GKG7TO7T.js.map +1 -0
  58. package/dist/chunk-GU2KH52B.mjs +53 -0
  59. package/dist/chunk-GU2KH52B.mjs.map +1 -0
  60. package/dist/chunk-GUXDSKV4.mjs +51 -0
  61. package/dist/chunk-GUXDSKV4.mjs.map +1 -0
  62. package/dist/chunk-HGYXRW5B.js +50 -0
  63. package/dist/chunk-HGYXRW5B.js.map +1 -0
  64. package/dist/chunk-HJ4276TR.mjs +41 -0
  65. package/dist/chunk-HJ4276TR.mjs.map +1 -0
  66. package/dist/chunk-HNLMKJBX.js +30 -0
  67. package/dist/chunk-HNLMKJBX.js.map +1 -0
  68. package/dist/chunk-IJYBCHVM.js +32 -0
  69. package/dist/chunk-IJYBCHVM.js.map +1 -0
  70. package/dist/chunk-IQTGFRWK.js +18 -0
  71. package/dist/chunk-IQTGFRWK.js.map +1 -0
  72. package/dist/chunk-IYAFFTJU.js +23 -0
  73. package/dist/chunk-IYAFFTJU.js.map +1 -0
  74. package/dist/chunk-JMISQ4HT.mjs +31 -0
  75. package/dist/chunk-JMISQ4HT.mjs.map +1 -0
  76. package/dist/chunk-K3TSXPME.js +16 -0
  77. package/dist/chunk-K3TSXPME.js.map +1 -0
  78. package/dist/{cjs/webpack/config.js → chunk-KKTPKAZN.mjs} +181 -153
  79. package/dist/chunk-KKTPKAZN.mjs.map +1 -0
  80. package/dist/chunk-KZFWI73A.js +28 -0
  81. package/dist/chunk-KZFWI73A.js.map +1 -0
  82. package/dist/chunk-L5TMG6BQ.js +37 -0
  83. package/dist/chunk-L5TMG6BQ.js.map +1 -0
  84. package/dist/chunk-MCN7UXG3.mjs +287 -0
  85. package/dist/chunk-MCN7UXG3.mjs.map +1 -0
  86. package/dist/chunk-MIV2UFTA.js +13 -0
  87. package/dist/chunk-MIV2UFTA.js.map +1 -0
  88. package/dist/chunk-MMBQXT2G.mjs +30 -0
  89. package/dist/chunk-MMBQXT2G.mjs.map +1 -0
  90. package/dist/chunk-NO53G7NT.js +61 -0
  91. package/dist/chunk-NO53G7NT.js.map +1 -0
  92. package/dist/chunk-O2QUFUOY.js +53 -0
  93. package/dist/chunk-O2QUFUOY.js.map +1 -0
  94. package/dist/chunk-OF4BF57X.mjs +22 -0
  95. package/dist/chunk-OF4BF57X.mjs.map +1 -0
  96. package/dist/chunk-OVCYXVWI.mjs +1 -0
  97. package/dist/chunk-OVCYXVWI.mjs.map +1 -0
  98. package/dist/chunk-PDNDGMB2.mjs +365 -0
  99. package/dist/chunk-PDNDGMB2.mjs.map +1 -0
  100. package/dist/chunk-QCP4QKMQ.mjs +24 -0
  101. package/dist/chunk-QCP4QKMQ.mjs.map +1 -0
  102. package/dist/chunk-QH4AQR33.mjs +61 -0
  103. package/dist/chunk-QH4AQR33.mjs.map +1 -0
  104. package/dist/chunk-S5ERYB6I.mjs +64 -0
  105. package/dist/chunk-S5ERYB6I.mjs.map +1 -0
  106. package/dist/chunk-SAEZHRJJ.mjs +23 -0
  107. package/dist/chunk-SAEZHRJJ.mjs.map +1 -0
  108. package/dist/chunk-T3KPXUAU.js +24 -0
  109. package/dist/chunk-T3KPXUAU.js.map +1 -0
  110. package/dist/chunk-T74IXMA3.mjs +50 -0
  111. package/dist/chunk-T74IXMA3.mjs.map +1 -0
  112. package/dist/chunk-TLTTWAEI.mjs +37 -0
  113. package/dist/chunk-TLTTWAEI.mjs.map +1 -0
  114. package/dist/chunk-TX4BG5GS.mjs +50 -0
  115. package/dist/chunk-TX4BG5GS.mjs.map +1 -0
  116. package/dist/chunk-UA5FEKKH.mjs +30 -0
  117. package/dist/chunk-UA5FEKKH.mjs.map +1 -0
  118. package/dist/chunk-UBWM7UOC.mjs +32 -0
  119. package/dist/chunk-UBWM7UOC.mjs.map +1 -0
  120. package/dist/chunk-USFFVX52.mjs +35 -0
  121. package/dist/chunk-USFFVX52.mjs.map +1 -0
  122. package/dist/chunk-V5Q5HRXB.mjs +30 -0
  123. package/dist/chunk-V5Q5HRXB.mjs.map +1 -0
  124. package/dist/chunk-VI3ZJJYO.mjs +346 -0
  125. package/dist/chunk-VI3ZJJYO.mjs.map +1 -0
  126. package/dist/chunk-VTJFPUIA.mjs +22 -0
  127. package/dist/chunk-VTJFPUIA.mjs.map +1 -0
  128. package/dist/chunk-WH7GOZP7.js +51 -0
  129. package/dist/chunk-WH7GOZP7.js.map +1 -0
  130. package/dist/chunk-WJNHZ4YF.js +35 -0
  131. package/dist/chunk-WJNHZ4YF.js.map +1 -0
  132. package/dist/chunk-WKL7DYYW.mjs +16 -0
  133. package/dist/chunk-WKL7DYYW.mjs.map +1 -0
  134. package/dist/chunk-X2RPNWBJ.mjs +24 -0
  135. package/dist/chunk-X2RPNWBJ.mjs.map +1 -0
  136. package/dist/chunk-X3D3MHWF.js +44 -0
  137. package/dist/chunk-X3D3MHWF.js.map +1 -0
  138. package/dist/chunk-X4FWMO4H.mjs +18 -0
  139. package/dist/chunk-X4FWMO4H.mjs.map +1 -0
  140. package/dist/chunk-Y5PQG4KA.js +1 -0
  141. package/dist/chunk-Y5PQG4KA.js.map +1 -0
  142. package/dist/chunk-YDLKS46R.js +30 -0
  143. package/dist/chunk-YDLKS46R.js.map +1 -0
  144. package/dist/chunk-YURDB35F.js +124 -0
  145. package/dist/chunk-YURDB35F.js.map +1 -0
  146. package/dist/chunk-YYYOE2GO.mjs +32 -0
  147. package/dist/chunk-YYYOE2GO.mjs.map +1 -0
  148. package/dist/chunk-ZOQ32RQI.mjs +135 -0
  149. package/dist/chunk-ZOQ32RQI.mjs.map +1 -0
  150. package/dist/cli.js +21 -0
  151. package/dist/cli.js.map +1 -0
  152. package/dist/cli.mjs +21 -0
  153. package/dist/cli.mjs.map +1 -0
  154. package/dist/commands/build/build.js +29 -0
  155. package/dist/commands/build/build.js.map +1 -0
  156. package/dist/commands/build/build.mjs +29 -0
  157. package/dist/commands/build/build.mjs.map +1 -0
  158. package/dist/commands/build/implementation.js +28 -0
  159. package/dist/commands/build/implementation.js.map +1 -0
  160. package/dist/commands/build/implementation.mjs +28 -0
  161. package/dist/commands/build/implementation.mjs.map +1 -0
  162. package/dist/commands/build/index.js +33 -0
  163. package/dist/commands/build/index.js.map +1 -0
  164. package/dist/commands/build/index.mjs +33 -0
  165. package/dist/commands/build/index.mjs.map +1 -0
  166. package/dist/commands/eval/eval.js +18 -0
  167. package/dist/commands/eval/eval.js.map +1 -0
  168. package/dist/commands/eval/eval.mjs +18 -0
  169. package/dist/commands/eval/eval.mjs.map +1 -0
  170. package/dist/commands/eval/implementation.js +9 -0
  171. package/dist/commands/eval/implementation.js.map +1 -0
  172. package/dist/commands/eval/implementation.mjs +9 -0
  173. package/dist/commands/eval/implementation.mjs.map +1 -0
  174. package/dist/commands/eval/index.js +22 -0
  175. package/dist/commands/eval/index.js.map +1 -0
  176. package/dist/commands/eval/index.mjs +22 -0
  177. package/dist/commands/eval/index.mjs.map +1 -0
  178. package/dist/commands/index.js +39 -0
  179. package/dist/commands/index.js.map +1 -0
  180. package/dist/commands/index.mjs +39 -0
  181. package/dist/commands/index.mjs.map +1 -0
  182. package/dist/commands/manifest/implementation.js +17 -0
  183. package/dist/commands/manifest/implementation.js.map +1 -0
  184. package/dist/commands/manifest/implementation.mjs +17 -0
  185. package/dist/commands/manifest/implementation.mjs.map +1 -0
  186. package/dist/commands/manifest/index.js +22 -0
  187. package/dist/commands/manifest/index.js.map +1 -0
  188. package/dist/commands/manifest/index.mjs +22 -0
  189. package/dist/commands/manifest/index.mjs.map +1 -0
  190. package/dist/commands/manifest/manifest.js +18 -0
  191. package/dist/commands/manifest/manifest.js.map +1 -0
  192. package/dist/commands/manifest/manifest.mjs +18 -0
  193. package/dist/commands/manifest/manifest.mjs.map +1 -0
  194. package/dist/commands/serve/index.js +29 -0
  195. package/dist/commands/serve/index.js.map +1 -0
  196. package/dist/commands/serve/index.mjs +29 -0
  197. package/dist/commands/serve/index.mjs.map +1 -0
  198. package/dist/commands/serve/serve.js +28 -0
  199. package/dist/commands/serve/serve.js.map +1 -0
  200. package/dist/commands/serve/serve.mjs +28 -0
  201. package/dist/commands/serve/serve.mjs.map +1 -0
  202. package/dist/commands/watch/implementation.js +28 -0
  203. package/dist/commands/watch/implementation.js.map +1 -0
  204. package/dist/commands/watch/implementation.mjs +28 -0
  205. package/dist/commands/watch/implementation.mjs.map +1 -0
  206. package/dist/commands/watch/index.js +33 -0
  207. package/dist/commands/watch/index.js.map +1 -0
  208. package/dist/commands/watch/index.mjs +33 -0
  209. package/dist/commands/watch/index.mjs.map +1 -0
  210. package/dist/commands/watch/watch.js +29 -0
  211. package/dist/commands/watch/watch.js.map +1 -0
  212. package/dist/commands/watch/watch.mjs +29 -0
  213. package/dist/commands/watch/watch.mjs.map +1 -0
  214. package/dist/config.js +36 -0
  215. package/dist/config.js.map +1 -0
  216. package/dist/config.mjs +36 -0
  217. package/dist/config.mjs.map +1 -0
  218. package/dist/errors.js +12 -0
  219. package/dist/errors.js.map +1 -0
  220. package/dist/errors.mjs +12 -0
  221. package/dist/errors.mjs.map +1 -0
  222. package/dist/index.js +43 -0
  223. package/dist/index.js.map +1 -0
  224. package/dist/index.mjs +43 -0
  225. package/dist/index.mjs.map +1 -0
  226. package/dist/main.js +49 -0
  227. package/dist/main.js.map +1 -0
  228. package/dist/main.mjs +49 -0
  229. package/dist/main.mjs.map +1 -0
  230. package/dist/structs.js +8 -0
  231. package/dist/structs.js.map +1 -0
  232. package/dist/structs.mjs +8 -0
  233. package/dist/structs.mjs.map +1 -0
  234. package/dist/tsconfig.build.tsbuildinfo +1 -0
  235. package/dist/types/commands/eval/implementation.d.ts +1 -1
  236. package/dist/types/config.d.ts +2 -2
  237. package/dist/types/structs.d.ts +20 -0
  238. package/dist/types/webpack/loaders/function.d.ts +34 -0
  239. package/dist/types/webpack/loaders/index.d.ts +3 -0
  240. package/dist/types/webpack/utils.d.ts +13 -11
  241. package/dist/types/yargs.d.js +1 -0
  242. package/dist/types/yargs.d.js.map +1 -0
  243. package/dist/types/yargs.d.mjs +2 -0
  244. package/dist/types/yargs.d.mjs.map +1 -0
  245. package/dist/utils/cli.js +14 -0
  246. package/dist/utils/cli.js.map +1 -0
  247. package/dist/utils/cli.mjs +14 -0
  248. package/dist/utils/cli.mjs.map +1 -0
  249. package/dist/utils/errors.js +11 -0
  250. package/dist/utils/errors.js.map +1 -0
  251. package/dist/utils/errors.mjs +11 -0
  252. package/dist/utils/errors.mjs.map +1 -0
  253. package/dist/utils/index.js +47 -0
  254. package/dist/utils/index.js.map +1 -0
  255. package/dist/utils/index.mjs +47 -0
  256. package/dist/utils/index.mjs.map +1 -0
  257. package/dist/utils/legacy.js +13 -0
  258. package/dist/utils/legacy.js.map +1 -0
  259. package/dist/utils/legacy.mjs +13 -0
  260. package/dist/utils/legacy.mjs.map +1 -0
  261. package/dist/utils/logging.js +12 -0
  262. package/dist/utils/logging.js.map +1 -0
  263. package/dist/utils/logging.mjs +12 -0
  264. package/dist/utils/logging.mjs.map +1 -0
  265. package/dist/utils/path.js +8 -0
  266. package/dist/utils/path.js.map +1 -0
  267. package/dist/utils/path.mjs +8 -0
  268. package/dist/utils/path.mjs.map +1 -0
  269. package/dist/utils/steps.js +11 -0
  270. package/dist/utils/steps.js.map +1 -0
  271. package/dist/utils/steps.mjs +11 -0
  272. package/dist/utils/steps.mjs.map +1 -0
  273. package/dist/webpack/compiler.js +25 -0
  274. package/dist/webpack/compiler.js.map +1 -0
  275. package/dist/webpack/compiler.mjs +25 -0
  276. package/dist/webpack/compiler.mjs.map +1 -0
  277. package/dist/webpack/config.js +24 -0
  278. package/dist/webpack/config.js.map +1 -0
  279. package/dist/webpack/config.mjs +24 -0
  280. package/dist/webpack/config.mjs.map +1 -0
  281. package/dist/webpack/index.js +44 -0
  282. package/dist/webpack/index.js.map +1 -0
  283. package/dist/webpack/index.mjs +44 -0
  284. package/dist/webpack/index.mjs.map +1 -0
  285. package/dist/webpack/loaders/browserify.js +19 -0
  286. package/dist/webpack/loaders/browserify.js.map +1 -0
  287. package/dist/webpack/loaders/browserify.mjs +19 -0
  288. package/dist/webpack/loaders/browserify.mjs.map +1 -0
  289. package/dist/webpack/loaders/function.js +10 -0
  290. package/dist/webpack/loaders/function.js.map +1 -0
  291. package/dist/webpack/loaders/function.mjs +10 -0
  292. package/dist/webpack/loaders/function.mjs.map +1 -0
  293. package/dist/webpack/loaders/index.js +25 -0
  294. package/dist/webpack/loaders/index.js.map +1 -0
  295. package/dist/webpack/loaders/index.mjs +25 -0
  296. package/dist/webpack/loaders/index.mjs.map +1 -0
  297. package/dist/webpack/loaders/wasm.js +16 -0
  298. package/dist/webpack/loaders/wasm.js.map +1 -0
  299. package/dist/webpack/loaders/wasm.mjs +16 -0
  300. package/dist/webpack/loaders/wasm.mjs.map +1 -0
  301. package/dist/webpack/plugins.js +29 -0
  302. package/dist/webpack/plugins.js.map +1 -0
  303. package/dist/webpack/plugins.mjs +29 -0
  304. package/dist/webpack/plugins.mjs.map +1 -0
  305. package/dist/webpack/server.js +10 -0
  306. package/dist/webpack/server.js.map +1 -0
  307. package/dist/webpack/server.mjs +10 -0
  308. package/dist/webpack/server.mjs.map +1 -0
  309. package/dist/webpack/utils.js +37 -0
  310. package/dist/webpack/utils.js.map +1 -0
  311. package/dist/webpack/utils.mjs +37 -0
  312. package/dist/webpack/utils.mjs.map +1 -0
  313. package/package.json +21 -21
  314. package/.browserslistrc +0 -3
  315. package/dist/cjs/builders.js +0 -148
  316. package/dist/cjs/builders.js.map +0 -1
  317. package/dist/cjs/cli.js +0 -68
  318. package/dist/cjs/cli.js.map +0 -1
  319. package/dist/cjs/commands/build/build.js +0 -54
  320. package/dist/cjs/commands/build/build.js.map +0 -1
  321. package/dist/cjs/commands/build/implementation.js +0 -31
  322. package/dist/cjs/commands/build/implementation.js.map +0 -1
  323. package/dist/cjs/commands/build/index.js +0 -45
  324. package/dist/cjs/commands/build/index.js.map +0 -1
  325. package/dist/cjs/commands/eval/eval.js +0 -57
  326. package/dist/cjs/commands/eval/eval.js.map +0 -1
  327. package/dist/cjs/commands/eval/implementation.js +0 -27
  328. package/dist/cjs/commands/eval/implementation.js.map +0 -1
  329. package/dist/cjs/commands/eval/index.js +0 -50
  330. package/dist/cjs/commands/eval/index.js.map +0 -1
  331. package/dist/cjs/commands/index.js +0 -30
  332. package/dist/cjs/commands/index.js.map +0 -1
  333. package/dist/cjs/commands/manifest/implementation.js +0 -34
  334. package/dist/cjs/commands/manifest/implementation.js.map +0 -1
  335. package/dist/cjs/commands/manifest/index.js +0 -50
  336. package/dist/cjs/commands/manifest/index.js.map +0 -1
  337. package/dist/cjs/commands/manifest/manifest.js +0 -55
  338. package/dist/cjs/commands/manifest/manifest.js.map +0 -1
  339. package/dist/cjs/commands/serve/index.js +0 -33
  340. package/dist/cjs/commands/serve/index.js.map +0 -1
  341. package/dist/cjs/commands/serve/serve.js +0 -21
  342. package/dist/cjs/commands/serve/serve.js.map +0 -1
  343. package/dist/cjs/commands/watch/implementation.js +0 -35
  344. package/dist/cjs/commands/watch/implementation.js.map +0 -1
  345. package/dist/cjs/commands/watch/index.js +0 -47
  346. package/dist/cjs/commands/watch/index.js.map +0 -1
  347. package/dist/cjs/commands/watch/watch.js +0 -51
  348. package/dist/cjs/commands/watch/watch.js.map +0 -1
  349. package/dist/cjs/config.js +0 -320
  350. package/dist/cjs/config.js.map +0 -1
  351. package/dist/cjs/errors.js +0 -37
  352. package/dist/cjs/errors.js.map +0 -1
  353. package/dist/cjs/index.js +0 -77
  354. package/dist/cjs/index.js.map +0 -1
  355. package/dist/cjs/main.js +0 -19
  356. package/dist/cjs/main.js.map +0 -1
  357. package/dist/cjs/utils/cli.js +0 -61
  358. package/dist/cjs/utils/cli.js.map +0 -1
  359. package/dist/cjs/utils/errors.js +0 -42
  360. package/dist/cjs/utils/errors.js.map +0 -1
  361. package/dist/cjs/utils/index.js +0 -25
  362. package/dist/cjs/utils/index.js.map +0 -1
  363. package/dist/cjs/utils/legacy.js +0 -48
  364. package/dist/cjs/utils/legacy.js.map +0 -1
  365. package/dist/cjs/utils/logging.js +0 -46
  366. package/dist/cjs/utils/logging.js.map +0 -1
  367. package/dist/cjs/utils/path.js +0 -16
  368. package/dist/cjs/utils/path.js.map +0 -1
  369. package/dist/cjs/utils/steps.js +0 -52
  370. package/dist/cjs/utils/steps.js.map +0 -1
  371. package/dist/cjs/webpack/compiler.js +0 -19
  372. package/dist/cjs/webpack/compiler.js.map +0 -1
  373. package/dist/cjs/webpack/config.js.map +0 -1
  374. package/dist/cjs/webpack/index.js +0 -23
  375. package/dist/cjs/webpack/index.js.map +0 -1
  376. package/dist/cjs/webpack/loaders/browserify.js +0 -97
  377. package/dist/cjs/webpack/loaders/browserify.js.map +0 -1
  378. package/dist/cjs/webpack/loaders/wasm.js +0 -92
  379. package/dist/cjs/webpack/loaders/wasm.js.map +0 -1
  380. package/dist/cjs/webpack/plugins.js +0 -341
  381. package/dist/cjs/webpack/plugins.js.map +0 -1
  382. package/dist/cjs/webpack/server.js +0 -139
  383. package/dist/cjs/webpack/server.js.map +0 -1
  384. package/dist/cjs/webpack/utils.js +0 -240
  385. package/dist/cjs/webpack/utils.js.map +0 -1
  386. package/dist/esm/builders.js +0 -130
  387. package/dist/esm/builders.js.map +0 -1
  388. package/dist/esm/cli.js +0 -56
  389. package/dist/esm/cli.js.map +0 -1
  390. package/dist/esm/commands/build/build.js +0 -51
  391. package/dist/esm/commands/build/build.js.map +0 -1
  392. package/dist/esm/commands/build/implementation.js +0 -27
  393. package/dist/esm/commands/build/implementation.js.map +0 -1
  394. package/dist/esm/commands/build/index.js +0 -17
  395. package/dist/esm/commands/build/index.js.map +0 -1
  396. package/dist/esm/commands/eval/eval.js +0 -54
  397. package/dist/esm/commands/eval/eval.js.map +0 -1
  398. package/dist/esm/commands/eval/implementation.js +0 -24
  399. package/dist/esm/commands/eval/implementation.js.map +0 -1
  400. package/dist/esm/commands/eval/index.js +0 -22
  401. package/dist/esm/commands/eval/index.js.map +0 -1
  402. package/dist/esm/commands/index.js +0 -15
  403. package/dist/esm/commands/index.js.map +0 -1
  404. package/dist/esm/commands/manifest/implementation.js +0 -33
  405. package/dist/esm/commands/manifest/implementation.js.map +0 -1
  406. package/dist/esm/commands/manifest/index.js +0 -22
  407. package/dist/esm/commands/manifest/index.js.map +0 -1
  408. package/dist/esm/commands/manifest/manifest.js +0 -52
  409. package/dist/esm/commands/manifest/manifest.js.map +0 -1
  410. package/dist/esm/commands/serve/index.js +0 -18
  411. package/dist/esm/commands/serve/index.js.map +0 -1
  412. package/dist/esm/commands/serve/serve.js +0 -17
  413. package/dist/esm/commands/serve/serve.js.map +0 -1
  414. package/dist/esm/commands/watch/implementation.js +0 -34
  415. package/dist/esm/commands/watch/implementation.js.map +0 -1
  416. package/dist/esm/commands/watch/index.js +0 -19
  417. package/dist/esm/commands/watch/index.js.map +0 -1
  418. package/dist/esm/commands/watch/watch.js +0 -50
  419. package/dist/esm/commands/watch/watch.js.map +0 -1
  420. package/dist/esm/config.js +0 -324
  421. package/dist/esm/config.js.map +0 -1
  422. package/dist/esm/errors.js +0 -30
  423. package/dist/esm/errors.js.map +0 -1
  424. package/dist/esm/index.js +0 -6
  425. package/dist/esm/index.js.map +0 -1
  426. package/dist/esm/main.js +0 -10
  427. package/dist/esm/main.js.map +0 -1
  428. package/dist/esm/utils/cli.js +0 -43
  429. package/dist/esm/utils/cli.js.map +0 -1
  430. package/dist/esm/utils/errors.js +0 -43
  431. package/dist/esm/utils/errors.js.map +0 -1
  432. package/dist/esm/utils/index.js +0 -8
  433. package/dist/esm/utils/index.js.map +0 -1
  434. package/dist/esm/utils/legacy.js +0 -47
  435. package/dist/esm/utils/legacy.js.map +0 -1
  436. package/dist/esm/utils/logging.js +0 -40
  437. package/dist/esm/utils/logging.js.map +0 -1
  438. package/dist/esm/utils/path.js +0 -13
  439. package/dist/esm/utils/path.js.map +0 -1
  440. package/dist/esm/utils/steps.js +0 -43
  441. package/dist/esm/utils/steps.js.map +0 -1
  442. package/dist/esm/webpack/compiler.js +0 -15
  443. package/dist/esm/webpack/compiler.js.map +0 -1
  444. package/dist/esm/webpack/config.js.map +0 -1
  445. package/dist/esm/webpack/index.js +0 -6
  446. package/dist/esm/webpack/index.js.map +0 -1
  447. package/dist/esm/webpack/loaders/browserify.js +0 -82
  448. package/dist/esm/webpack/loaders/browserify.js.map +0 -1
  449. package/dist/esm/webpack/loaders/wasm.js +0 -87
  450. package/dist/esm/webpack/loaders/wasm.js.map +0 -1
  451. package/dist/esm/webpack/plugins.js +0 -344
  452. package/dist/esm/webpack/plugins.js.map +0 -1
  453. package/dist/esm/webpack/server.js +0 -133
  454. package/dist/esm/webpack/server.js.map +0 -1
  455. package/dist/esm/webpack/utils.js +0 -271
  456. package/dist/esm/webpack/utils.js.map +0 -1
@@ -0,0 +1,287 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkGKG7TO7Tjs = require('./chunk-GKG7TO7T.js');
4
+
5
+
6
+ var _chunkHNLMKJBXjs = require('./chunk-HNLMKJBX.js');
7
+
8
+
9
+ var _chunkX3D3MHWFjs = require('./chunk-X3D3MHWF.js');
10
+
11
+ // src/webpack/utils.ts
12
+ var _chalk = require('chalk');
13
+ var _fs = require('fs');
14
+ var _module = require('module');
15
+ var _path = require('path');
16
+ var _stripansi = require('strip-ansi'); var _stripansi2 = _interopRequireDefault(_stripansi);
17
+
18
+ // src/webpack/loaders/browserify.ts
19
+ var _browserify = require('browserify'); var _browserify2 = _interopRequireDefault(_browserify);
20
+ var _readablestream = require('readable-stream');
21
+ var loader = async function(content, sourceMap) {
22
+ const config = this.getOptions();
23
+ const { transpilationMode } = config;
24
+ const bundler = _browserify2.default.call(void 0, {
25
+ extensions: [".js", ".ts"],
26
+ debug: Boolean(sourceMap),
27
+ standalone: "<snap>"
28
+ });
29
+ if (transpilationMode !== "none" /* None */) {
30
+ const babelifyOptions = _chunkHNLMKJBXjs.processDependencies.call(void 0, config);
31
+ bundler.transform(_chunkX3D3MHWFjs.__require.call(void 0, "babelify"), {
32
+ global: transpilationMode === "localAndDeps" /* LocalAndDeps */,
33
+ extensions: [".js", ".ts"],
34
+ presets: [
35
+ _chunkX3D3MHWFjs.__require.call(void 0, "@babel/preset-typescript"),
36
+ [
37
+ _chunkX3D3MHWFjs.__require.call(void 0, "@babel/preset-env"),
38
+ {
39
+ targets: {
40
+ browsers: await getBrowserslistTargets()
41
+ }
42
+ }
43
+ ]
44
+ ],
45
+ plugins: [
46
+ _chunkX3D3MHWFjs.__require.call(void 0, "@babel/plugin-transform-runtime"),
47
+ _chunkX3D3MHWFjs.__require.call(void 0, "@babel/plugin-transform-class-properties"),
48
+ _chunkX3D3MHWFjs.__require.call(void 0, "@babel/plugin-transform-private-methods"),
49
+ _chunkX3D3MHWFjs.__require.call(void 0, "@babel/plugin-transform-class-static-block"),
50
+ _chunkX3D3MHWFjs.__require.call(void 0, "@babel/plugin-transform-private-property-in-object")
51
+ ],
52
+ ...babelifyOptions
53
+ });
54
+ }
55
+ _optionalChain([config, 'access', _ => _.bundlerCustomizer, 'optionalCall', _2 => _2(bundler)]);
56
+ const stream = new (0, _readablestream.Readable)();
57
+ stream.push(content);
58
+ stream.push(null);
59
+ bundler.add(stream, {
60
+ file: this.resourcePath
61
+ });
62
+ return new Promise((resolve2, reject) => {
63
+ bundler.bundle((bundleError, buffer) => {
64
+ if (bundleError) {
65
+ reject(bundleError);
66
+ return;
67
+ }
68
+ resolve2(buffer);
69
+ });
70
+ });
71
+ };
72
+ var browserify_default = loader;
73
+
74
+ // src/webpack/utils.ts
75
+ var BROWSERSLIST_FILE = _path.resolve.call(void 0,
76
+ _path.dirname.call(void 0,
77
+ // eslint-disable-next-line n/no-extraneous-require
78
+ _chunkX3D3MHWFjs.__require.resolve("@metamask/snaps-cli/package.json")
79
+ ),
80
+ ".browserslistrc"
81
+ );
82
+ var WEBPACK_FALLBACKS = {
83
+ assert: _chunkX3D3MHWFjs.__require.resolve("assert/"),
84
+ buffer: _chunkX3D3MHWFjs.__require.resolve("buffer/"),
85
+ console: _chunkX3D3MHWFjs.__require.resolve("console-browserify"),
86
+ constants: _chunkX3D3MHWFjs.__require.resolve("constants-browserify"),
87
+ crypto: _chunkX3D3MHWFjs.__require.resolve("crypto-browserify"),
88
+ domain: _chunkX3D3MHWFjs.__require.resolve("domain-browser"),
89
+ events: _chunkX3D3MHWFjs.__require.resolve("events/"),
90
+ http: _chunkX3D3MHWFjs.__require.resolve("stream-http"),
91
+ https: _chunkX3D3MHWFjs.__require.resolve("https-browserify"),
92
+ os: _chunkX3D3MHWFjs.__require.resolve("os-browserify/browser"),
93
+ path: _chunkX3D3MHWFjs.__require.resolve("path-browserify"),
94
+ punycode: _chunkX3D3MHWFjs.__require.resolve("punycode/"),
95
+ process: _chunkX3D3MHWFjs.__require.resolve("process/browser"),
96
+ querystring: _chunkX3D3MHWFjs.__require.resolve("querystring-es3"),
97
+ stream: _chunkX3D3MHWFjs.__require.resolve("stream-browserify"),
98
+ /* eslint-disable @typescript-eslint/naming-convention */
99
+ _stream_duplex: _chunkX3D3MHWFjs.__require.resolve("readable-stream/lib/_stream_duplex"),
100
+ _stream_passthrough: _chunkX3D3MHWFjs.__require.resolve(
101
+ "readable-stream/lib/_stream_passthrough"
102
+ ),
103
+ _stream_readable: _chunkX3D3MHWFjs.__require.resolve("readable-stream/lib/_stream_readable"),
104
+ _stream_transform: _chunkX3D3MHWFjs.__require.resolve("readable-stream/lib/_stream_transform"),
105
+ _stream_writable: _chunkX3D3MHWFjs.__require.resolve("readable-stream/lib/_stream_writable"),
106
+ string_decoder: _chunkX3D3MHWFjs.__require.resolve("string_decoder/"),
107
+ /* eslint-enable @typescript-eslint/naming-convention */
108
+ sys: _chunkX3D3MHWFjs.__require.resolve("util/"),
109
+ timers: _chunkX3D3MHWFjs.__require.resolve("timers-browserify"),
110
+ tty: _chunkX3D3MHWFjs.__require.resolve("tty-browserify"),
111
+ url: _chunkX3D3MHWFjs.__require.resolve("url/"),
112
+ util: _chunkX3D3MHWFjs.__require.resolve("util/"),
113
+ vm: _chunkX3D3MHWFjs.__require.resolve("vm-browserify"),
114
+ zlib: _chunkX3D3MHWFjs.__require.resolve("browserify-zlib")
115
+ };
116
+ async function getDefaultLoader({
117
+ legacy,
118
+ sourceMap
119
+ }) {
120
+ if (legacy) {
121
+ return _chunkGKG7TO7Tjs.getFunctionLoader.call(void 0, browserify_default, legacy);
122
+ }
123
+ const targets = await getBrowserslistTargets();
124
+ return {
125
+ /**
126
+ * We use the `swc-loader` to transpile TypeScript and JavaScript files.
127
+ * This is a Webpack loader that uses the `SWC` compiler, which is a much
128
+ * faster alternative to Babel and TypeScript's own compiler.
129
+ */
130
+ loader: _chunkX3D3MHWFjs.__require.resolve("swc-loader"),
131
+ /**
132
+ * The options for the `swc-loader`. These can be overridden in the
133
+ * `.swcrc` file.
134
+ *
135
+ * @see https://swc.rs/docs/configuration/swcrc
136
+ */
137
+ options: {
138
+ sync: false,
139
+ /**
140
+ * This tells SWC to generate source maps. We set it to the
141
+ * `sourceMap` value from the config object.
142
+ *
143
+ * This must be enabled if source maps are enabled in the config.
144
+ */
145
+ sourceMaps: Boolean(getDevTool(sourceMap)),
146
+ jsc: {
147
+ parser: {
148
+ /**
149
+ * This tells the parser to parse TypeScript files. If you
150
+ * don't need to support TypeScript, you can set this to
151
+ * `ecmascript` instead, but there's no harm in leaving it
152
+ * as `typescript`.
153
+ *
154
+ * @see https://swc.rs/docs/configuration/compilation#jscparser
155
+ */
156
+ syntax: "typescript"
157
+ }
158
+ },
159
+ /**
160
+ * The module configuration. This tells SWC how to output the
161
+ * transpiled code.
162
+ *
163
+ * @see https://swc.rs/docs/configuration/modules
164
+ */
165
+ module: {
166
+ /**
167
+ * This tells SWC to output ES6 modules. This will allow Webpack to
168
+ * optimize the output code better. Snaps don't support ES6 however, so
169
+ * the output code will be transpiled to CommonJS by Webpack later in
170
+ * the build process.
171
+ *
172
+ * @see https://swc.rs/docs/configuration/modules#es6
173
+ */
174
+ type: "es6"
175
+ },
176
+ env: {
177
+ targets: targets.join(", ")
178
+ }
179
+ }
180
+ };
181
+ }
182
+ function getDevTool(sourceMap) {
183
+ if (sourceMap === "inline") {
184
+ return "inline-source-map";
185
+ }
186
+ if (sourceMap === true) {
187
+ return "source-map";
188
+ }
189
+ return false;
190
+ }
191
+ function getProgressHandler(spinner, spinnerText) {
192
+ return (percentage) => {
193
+ if (spinner && spinnerText) {
194
+ spinner.text = `${spinnerText} ${_chalk.dim.call(void 0,
195
+ `(${Math.round(percentage * 100)}%)`
196
+ )}`;
197
+ }
198
+ };
199
+ }
200
+ async function getBrowserslistTargets() {
201
+ const contents = await _fs.promises.readFile(BROWSERSLIST_FILE, "utf8");
202
+ return contents.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
203
+ }
204
+ function pluralize(count, singular, plural = `${singular}s`) {
205
+ return count === 1 ? singular : plural;
206
+ }
207
+ function getFallbacks(polyfills) {
208
+ if (polyfills === true) {
209
+ return Object.fromEntries(
210
+ _module.builtinModules.map((name) => [
211
+ name,
212
+ _nullishCoalesce(WEBPACK_FALLBACKS[name], () => ( false))
213
+ ])
214
+ );
215
+ }
216
+ if (polyfills === false) {
217
+ return Object.fromEntries(_module.builtinModules.map((name) => [name, false]));
218
+ }
219
+ return Object.fromEntries(
220
+ _module.builtinModules.map((name) => [
221
+ name,
222
+ polyfills[name] ? WEBPACK_FALLBACKS[name] : false
223
+ ])
224
+ );
225
+ }
226
+ function getEnvironmentVariables(environment, defaults = {
227
+ NODE_DEBUG: "false",
228
+ NODE_ENV: "production",
229
+ DEBUG: "false"
230
+ }) {
231
+ return Object.fromEntries(
232
+ Object.entries({
233
+ ...defaults,
234
+ ...environment
235
+ }).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)])
236
+ );
237
+ }
238
+ function formatLine(line, indent, initialIndent) {
239
+ const terminalWidth = process.stdout.columns;
240
+ if (!terminalWidth) {
241
+ return `${" ".repeat(initialIndent)}${line}`;
242
+ }
243
+ return line.split(" ").reduce(
244
+ ({ formattedText, currentLineLength }, word, index) => {
245
+ const visibleWord = _stripansi2.default.call(void 0, word);
246
+ const spaceBeforeWord = index > 0 ? " " : "";
247
+ const wordLengthWithSpace = visibleWord.length + spaceBeforeWord.length;
248
+ if (currentLineLength + wordLengthWithSpace > terminalWidth) {
249
+ return {
250
+ formattedText: `${formattedText}
251
+ ${" ".repeat(indent)}${word}`,
252
+ currentLineLength: indent + visibleWord.length
253
+ };
254
+ }
255
+ return {
256
+ formattedText: formattedText + spaceBeforeWord + word,
257
+ currentLineLength: currentLineLength + wordLengthWithSpace
258
+ };
259
+ },
260
+ {
261
+ formattedText: " ".repeat(initialIndent),
262
+ currentLineLength: initialIndent
263
+ }
264
+ ).formattedText;
265
+ }
266
+ function formatText(text, indent, initialIndent = indent) {
267
+ const lines = text.split("\n");
268
+ return lines.map((line, index) => {
269
+ const lineIndent = index === 0 ? initialIndent : indent;
270
+ return formatLine(line, indent, lineIndent);
271
+ }).join("\n");
272
+ }
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+ exports.BROWSERSLIST_FILE = BROWSERSLIST_FILE; exports.WEBPACK_FALLBACKS = WEBPACK_FALLBACKS; exports.getDefaultLoader = getDefaultLoader; exports.getDevTool = getDevTool; exports.getProgressHandler = getProgressHandler; exports.getBrowserslistTargets = getBrowserslistTargets; exports.pluralize = pluralize; exports.getFallbacks = getFallbacks; exports.getEnvironmentVariables = getEnvironmentVariables; exports.formatText = formatText; exports.browserify_default = browserify_default;
287
+ //# sourceMappingURL=chunk-7SN4Y44H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/webpack/utils.ts","../src/webpack/loaders/browserify.ts"],"names":["resolve"],"mappings":";;;;;;;;;;;AAAA,SAAS,WAAW;AACpB,SAAS,YAAY,UAAU;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,SAAS,eAAe;AACjC,OAAO,eAAe;;;ACLtB,OAAO,gBAAgB;AACvB,SAAS,gBAAgB;AAoBzB,IAAM,SAAkD,eACtD,SACA,WACA;AACA,QAAM,SAAS,KAAK,WAAW;AAE/B,QAAM,EAA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AAI,oBAAoB,sBAAsB,eAAe;AAC3D,eAAO;AAAA,UACL,eAAe,GAAG,aAAa;AAAA,EAAK,IAAI,OAAO,MAAM,CAAC,GAAG,IAAI;AAAA,UAC7D,mBAAmB,SAAS,YAAY;AAAA,QAC1C;AAAA,MACF;AAGA,aAAO;AAAA,QACL,eAAe,gBAAgB,kBAAkB;AAAA,QACjD,mBAAmB,oBAAoB;AAAA,MACzC;AAAA,IACF;AAAA,IACA;AAAA,MACE,eAAe,IAAI,OAAO,aAAa;AAAA,MACvC,mBAAmB;AAAA,IACrB;AAAA,EACF,EAAE;AACJ;AAWO,SAAS,WACd,MACA,QACA,gBAAgB,QAChB;AACA,QAAM,QAAQ,KAAK,MAAM,IAAI;AAG7B,SAAO,MACJ,IAAI,CAAC,MAAM,UAAU;AACpB,UAAM,aAAa,UAAU,IAAI,gBAAgB;AACjD,WAAO,WAAW,MAAM,QAAQ,UAAU;AAAA,EAC5C,CAAC,EACA,KAAK,IAAI;AACd","sourcesContent":["import { dim } from 'chalk';\nimport { promises as fs } from 'fs';\nimport { builtinModules } from 'module';\nimport type { Ora } from 'ora';\nimport { dirname, resolve } from 'path';\nimport stripAnsi from 'strip-ansi';\nimport type { Configuration } from 'webpack';\n\nimport type { ProcessedWebpackConfig } from '../config';\nimport { browserify, getFunctionLoader } from './loaders';\n\nexport const BROWSERSLIST_FILE = resolve(\n dirname(\n // eslint-disable-next-line n/no-extraneous-require\n require.resolve('@metamask/snaps-cli/package.json'),\n ),\n '.browserslistrc',\n);\n\nexport const WEBPACK_FALLBACKS = {\n assert: require.resolve('assert/'),\n buffer: require.resolve('buffer/'),\n console: require.resolve('console-browserify'),\n constants: require.resolve('constants-browserify'),\n crypto: require.resolve('crypto-browserify'),\n domain: require.resolve('domain-browser'),\n events: require.resolve('events/'),\n http: require.resolve('stream-http'),\n https: require.resolve('https-browserify'),\n os: require.resolve('os-browserify/browser'),\n path: require.resolve('path-browserify'),\n punycode: require.resolve('punycode/'),\n process: require.resolve('process/browser'),\n querystring: require.resolve('querystring-es3'),\n stream: require.resolve('stream-browserify'),\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex: require.resolve('readable-stream/lib/_stream_duplex'),\n _stream_passthrough: require.resolve(\n 'readable-stream/lib/_stream_passthrough',\n ),\n _stream_readable: require.resolve('readable-stream/lib/_stream_readable'),\n _stream_transform: require.resolve('readable-stream/lib/_stream_transform'),\n _stream_writable: require.resolve('readable-stream/lib/_stream_writable'),\n string_decoder: require.resolve('string_decoder/'),\n /* eslint-enable @typescript-eslint/naming-convention */\n sys: require.resolve('util/'),\n timers: require.resolve('timers-browserify'),\n tty: require.resolve('tty-browserify'),\n url: require.resolve('url/'),\n util: require.resolve('util/'),\n vm: require.resolve('vm-browserify'),\n zlib: require.resolve('browserify-zlib'),\n};\n\n/**\n * Get the default loader for JavaScript and TypeScript files, based on the\n * config object.\n *\n * - If the `legacy` option is set, we use the custom `browserify` loader. This\n * uses the legacy Browserify config to transpile the code.\n * - Otherwise, we use the `swc-loader`. This is a Webpack loader that uses the\n * `SWC` compiler, which is a much faster alternative to Babel and TypeScript's\n * own compiler.\n *\n * @param config - The processed snap Webpack config.\n * @param config.legacy - The legacy config object, if any.\n * @param config.sourceMap - Whether to generate source maps.\n * @see https://swc.rs/docs/usage/swc-loader\n * @returns The default loader.\n */\nexport async function getDefaultLoader({\n legacy,\n sourceMap,\n}: ProcessedWebpackConfig) {\n if (legacy) {\n /**\n * If the snap uses the legacy config, we use the custom `browserify`\n * loader. This uses the legacy Browserify config to transpile the code.\n * This is necessary for backwards compatibility with the\n * `bundlerCustomizer` function.\n */\n return getFunctionLoader(browserify, legacy);\n }\n\n const targets = await getBrowserslistTargets();\n return {\n /**\n * We use the `swc-loader` to transpile TypeScript and JavaScript files.\n * This is a Webpack loader that uses the `SWC` compiler, which is a much\n * faster alternative to Babel and TypeScript's own compiler.\n */\n loader: require.resolve('swc-loader'),\n\n /**\n * The options for the `swc-loader`. These can be overridden in the\n * `.swcrc` file.\n *\n * @see https://swc.rs/docs/configuration/swcrc\n */\n options: {\n sync: false,\n\n /**\n * This tells SWC to generate source maps. We set it to the\n * `sourceMap` value from the config object.\n *\n * This must be enabled if source maps are enabled in the config.\n */\n sourceMaps: Boolean(getDevTool(sourceMap)),\n\n jsc: {\n parser: {\n /**\n * This tells the parser to parse TypeScript files. If you\n * don't need to support TypeScript, you can set this to\n * `ecmascript` instead, but there's no harm in leaving it\n * as `typescript`.\n *\n * @see https://swc.rs/docs/configuration/compilation#jscparser\n */\n syntax: 'typescript',\n },\n },\n\n /**\n * The module configuration. This tells SWC how to output the\n * transpiled code.\n *\n * @see https://swc.rs/docs/configuration/modules\n */\n module: {\n /**\n * This tells SWC to output ES6 modules. This will allow Webpack to\n * optimize the output code better. Snaps don't support ES6 however, so\n * the output code will be transpiled to CommonJS by Webpack later in\n * the build process.\n *\n * @see https://swc.rs/docs/configuration/modules#es6\n */\n type: 'es6',\n },\n\n env: {\n targets: targets.join(', '),\n },\n },\n };\n}\n\n/**\n * Get the Webpack devtool configuration based on the given snap config.\n *\n * - If `sourceMap` is `inline`, return `inline-source-map`.\n * - If `sourceMap` is `true`, return `source-map`.\n * - Otherwise, return `false`.\n *\n * @param sourceMap - The `sourceMap` value from the snap config.\n * @returns The Webpack devtool configuration.\n */\nexport function getDevTool(\n sourceMap: ProcessedWebpackConfig['sourceMap'],\n): Configuration['devtool'] {\n if (sourceMap === 'inline') {\n return 'inline-source-map';\n }\n\n if (sourceMap === true) {\n return 'source-map';\n }\n\n return false;\n}\n\n/**\n * Get a function that can be used as handler function for Webpack's\n * `ProgressPlugin`.\n *\n * @param spinner - The spinner to update.\n * @param spinnerText - The initial spinner text. This will be prepended to the\n * percentage.\n * @returns A function that can be used as handler function for Webpack's\n * `ProgressPlugin`.\n */\n// Note: This is extracted for testing purposes.\nexport function getProgressHandler(spinner?: Ora, spinnerText?: string) {\n return (percentage: number) => {\n if (spinner && spinnerText) {\n spinner.text = `${spinnerText} ${dim(\n `(${Math.round(percentage * 100)}%)`,\n )}`;\n }\n };\n}\n\n/**\n * Get the targets from the `.browserslistrc` file.\n *\n * @returns The browser targets as an array of strings.\n */\nexport async function getBrowserslistTargets() {\n const contents = await fs.readFile(BROWSERSLIST_FILE, 'utf8');\n return contents\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line && !line.startsWith('#'));\n}\n\n/**\n * Get a singular or plural string based on the given count. This is useful for\n * generating messages like \"1 error\" or \"2 errors\". By default, the plural\n * string is the singular string with an \"s\" appended to it.\n *\n * This assumes that the text is in English, and likely won't work for some\n * other languages.\n *\n * @param count - The count.\n * @param singular - The singular string.\n * @param plural - The plural string.\n * @returns The singular or plural string.\n * @example\n * ```typescript\n * pluralize(1, 'error'); // => 'error'\n * pluralize(2, 'error'); // => 'errors'\n * pluralize(1, 'error', 'problem'); // => 'error'\n * pluralize(2, 'error', 'problems'); // => 'problems'\n * ```\n */\nexport function pluralize(\n count: number,\n singular: string,\n plural = `${singular}s`,\n) {\n return count === 1 ? singular : plural;\n}\n\n/**\n * Get an object that can be used as fallback config for Webpack's\n * `fallback` config.\n *\n * @param polyfills - The polyfill object from the snap config.\n * @returns The webpack fallback config.\n */\nexport function getFallbacks(polyfills: ProcessedWebpackConfig['polyfills']): {\n [index: string]: string | false;\n} {\n if (polyfills === true) {\n return Object.fromEntries(\n builtinModules.map((name) => [\n name,\n WEBPACK_FALLBACKS[name as keyof typeof WEBPACK_FALLBACKS] ?? false,\n ]),\n );\n }\n\n if (polyfills === false) {\n return Object.fromEntries(builtinModules.map((name) => [name, false]));\n }\n\n return Object.fromEntries(\n builtinModules.map((name) => [\n name,\n polyfills[name as keyof ProcessedWebpackConfig['polyfills']]\n ? WEBPACK_FALLBACKS[name as keyof typeof WEBPACK_FALLBACKS]\n : false,\n ]),\n );\n}\n\n/**\n * Get an object that can be used as environment variables for Webpack's\n * `DefinePlugin`.\n *\n * @param environment - The environment object from the Snap config.\n * @param defaults - The default environment variables.\n * @returns The Webpack environment variables.\n */\nexport function getEnvironmentVariables(\n environment: Record<string, unknown>,\n defaults = {\n NODE_DEBUG: 'false',\n NODE_ENV: 'production',\n DEBUG: 'false',\n },\n) {\n return Object.fromEntries(\n Object.entries({\n ...defaults,\n ...environment,\n }).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]),\n );\n}\n\n/**\n * Format the given line to fit within the terminal width.\n *\n * @param line - The line to format.\n * @param indent - The indentation to use.\n * @param initialIndent - The initial indentation to use, i.e., the indentation\n * for the first line.\n * @returns The formatted line.\n */\nfunction formatLine(line: string, indent: number, initialIndent: number) {\n const terminalWidth = process.stdout.columns;\n if (!terminalWidth) {\n return `${' '.repeat(initialIndent)}${line}`;\n }\n\n return line.split(' ').reduce(\n ({ formattedText, currentLineLength }, word, index) => {\n // `chalk` adds ANSI escape codes to the text, which are not visible\n // characters. We need to strip them to get the visible length of the\n // text.\n const visibleWord = stripAnsi(word);\n\n // Determine if a space should be added before the word.\n const spaceBeforeWord = index > 0 ? ' ' : '';\n const wordLengthWithSpace = visibleWord.length + spaceBeforeWord.length;\n\n // If the word would exceed the terminal width, start a new line.\n if (currentLineLength + wordLengthWithSpace > terminalWidth) {\n return {\n formattedText: `${formattedText}\\n${' '.repeat(indent)}${word}`,\n currentLineLength: indent + visibleWord.length,\n };\n }\n\n // Otherwise, add the word to the current line.\n return {\n formattedText: formattedText + spaceBeforeWord + word,\n currentLineLength: currentLineLength + wordLengthWithSpace,\n };\n },\n {\n formattedText: ' '.repeat(initialIndent),\n currentLineLength: initialIndent,\n },\n ).formattedText;\n}\n\n/**\n * Format the given text to fit within the terminal width.\n *\n * @param text - The text to format.\n * @param indent - The indentation to use.\n * @param initialIndent - The initial indentation to use, i.e., the indentation\n * for the first line.\n * @returns The formatted text.\n */\nexport function formatText(\n text: string,\n indent: number,\n initialIndent = indent,\n) {\n const lines = text.split('\\n');\n\n // Apply formatting to each line separately and then join them.\n return lines\n .map((line, index) => {\n const lineIndent = index === 0 ? initialIndent : indent;\n return formatLine(line, indent, lineIndent);\n })\n .join('\\n');\n}\n","import browserify from 'browserify';\nimport { Readable } from 'readable-stream';\nimport type { LoaderDefinitionFunction } from 'webpack';\n\nimport { TranspilationModes } from '../../builders';\nimport type { LegacyOptions } from '../../config';\nimport { processDependencies } from '../../utils';\nimport { getBrowserslistTargets } from '../utils';\n\n/**\n * A Browserify loader for Webpack. This exists for backwards compatibility with\n * the legacy configuration format, in order to support the `bundlerCustomizer`\n * function.\n *\n * When this loader is used, the input file will be processed by Browserify, and\n * written to disk by Webpack. Most processing will be handled by Browserify, so\n * there are no benefits like tree-shaking.\n *\n * @param content - The input file contents as a string.\n * @param sourceMap - The source map of the input file.\n */\nconst loader: LoaderDefinitionFunction<LegacyOptions> = async function (\n content,\n sourceMap,\n) {\n const config = this.getOptions();\n\n const { transpilationMode } = config;\n\n const bundler = browserify({\n extensions: ['.js', '.ts'],\n debug: Boolean(sourceMap),\n standalone: '<snap>',\n });\n\n if (transpilationMode !== TranspilationModes.None) {\n const babelifyOptions = processDependencies(config);\n\n // We need to statically import all Browserify transforms, and all Babel\n // presets and plugins, and calling `require` is the sanest way to do that.\n /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */\n bundler.transform(require('babelify'), {\n global: transpilationMode === TranspilationModes.LocalAndDeps,\n extensions: ['.js', '.ts'],\n presets: [\n require('@babel/preset-typescript'),\n [\n require('@babel/preset-env'),\n {\n targets: {\n browsers: await getBrowserslistTargets(),\n },\n },\n ],\n ],\n plugins: [\n require('@babel/plugin-transform-runtime'),\n require('@babel/plugin-transform-class-properties'),\n require('@babel/plugin-transform-private-methods'),\n require('@babel/plugin-transform-class-static-block'),\n require('@babel/plugin-transform-private-property-in-object'),\n ],\n ...(babelifyOptions as any),\n });\n /* eslint-enable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */\n }\n\n config.bundlerCustomizer?.(bundler);\n\n // Browserify doesn't accept a string as an entry point, so we need to convert\n // it to a stream.\n const stream = new Readable();\n stream.push(content);\n stream.push(null);\n\n bundler.add(stream, {\n file: this.resourcePath,\n });\n\n return new Promise<Buffer>((resolve, reject) => {\n bundler.bundle((bundleError, buffer: Buffer) => {\n if (bundleError) {\n reject(bundleError);\n return;\n }\n\n // Browserify inlines the source map, so we just pass the output buffer back\n // to Webpack.\n resolve(buffer);\n });\n });\n};\n\nexport default loader;\n"]}
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/path.ts
2
+ var _path = require('path');
3
+ function getRelativePath(absolutePath, cwd = process.cwd()) {
4
+ return _path.relative.call(void 0, cwd, absolutePath);
5
+ }
6
+
7
+
8
+
9
+ exports.getRelativePath = getRelativePath;
10
+ //# sourceMappingURL=chunk-ASOCIPDR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/path.ts"],"names":[],"mappings":";AAAA,SAAS,gBAAgB;AAUlB,SAAS,gBAAgB,cAAsB,MAAM,QAAQ,IAAI,GAAG;AACzE,SAAO,SAAS,KAAK,YAAY;AACnC","sourcesContent":["import { relative } from 'path';\n\n/**\n * Get the relative path from the current working directory to the given\n * absolute path.\n *\n * @param absolutePath - The absolute path.\n * @param cwd - The current working directory. Defaults to `process.cwd()`.\n * @returns The relative path.\n */\nexport function getRelativePath(absolutePath: string, cwd = process.cwd()) {\n return relative(cwd, absolutePath);\n}\n"]}
@@ -0,0 +1,54 @@
1
+ import {
2
+ watch
3
+ } from "./chunk-USFFVX52.mjs";
4
+ import {
5
+ getServer
6
+ } from "./chunk-6VFUO2H5.mjs";
7
+ import {
8
+ executeSteps
9
+ } from "./chunk-HJ4276TR.mjs";
10
+ import {
11
+ info
12
+ } from "./chunk-JMISQ4HT.mjs";
13
+ import {
14
+ CommandError
15
+ } from "./chunk-OF4BF57X.mjs";
16
+
17
+ // src/commands/watch/watch.ts
18
+ import { isFile } from "@metamask/snaps-utils/node";
19
+ var steps = [
20
+ {
21
+ name: "Checking the input file.",
22
+ task: async ({ config }) => {
23
+ const { input } = config;
24
+ if (!await isFile(input)) {
25
+ throw new CommandError(
26
+ `Input file not found: "${input}". Make sure that the "input" field in your snap config is correct.`
27
+ );
28
+ }
29
+ }
30
+ },
31
+ {
32
+ name: "Starting the development server.",
33
+ condition: ({ config }) => config.server.enabled,
34
+ task: async ({ config, options, spinner }) => {
35
+ const server = getServer(config);
36
+ const { port } = await server.listen(options.port ?? config.server.port);
37
+ info(`The server is listening on http://localhost:${port}.`, spinner);
38
+ }
39
+ },
40
+ {
41
+ name: "Building the snap bundle.",
42
+ task: async ({ config, spinner }) => {
43
+ await watch(config, { spinner });
44
+ }
45
+ }
46
+ ];
47
+ async function watchHandler(config, options) {
48
+ await executeSteps(steps, { config, options });
49
+ }
50
+
51
+ export {
52
+ watchHandler
53
+ };
54
+ //# sourceMappingURL=chunk-B455GFXP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/watch/watch.ts"],"sourcesContent":["import { isFile } from '@metamask/snaps-utils/node';\n\nimport type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';\nimport { CommandError } from '../../errors';\nimport type { Steps } from '../../utils';\nimport { executeSteps, info } from '../../utils';\nimport { getServer } from '../../webpack';\nimport { watch } from './implementation';\n\ntype WatchOptions = {\n /**\n * The port to listen on.\n */\n port?: number;\n};\n\ntype WatchContext = {\n config: ProcessedWebpackConfig;\n options: WatchOptions;\n};\n\nconst steps: Steps<WatchContext> = [\n {\n name: 'Checking the input file.',\n task: async ({ config }) => {\n const { input } = config;\n\n if (!(await isFile(input))) {\n throw new CommandError(\n `Input file not found: \"${input}\". Make sure that the \"input\" field in your snap config is correct.`,\n );\n }\n },\n },\n {\n name: 'Starting the development server.',\n condition: ({ config }) => config.server.enabled,\n task: async ({ config, options, spinner }) => {\n const server = getServer(config);\n const { port } = await server.listen(options.port ?? config.server.port);\n\n info(`The server is listening on http://localhost:${port}.`, spinner);\n },\n },\n {\n name: 'Building the snap bundle.',\n task: async ({ config, spinner }) => {\n await watch(config, { spinner });\n },\n },\n];\n\n/**\n * Watch a directory and its subdirectories for changes, and build when files\n * are added or changed.\n *\n * Ignores 'node_modules' and dotfiles.\n * Creates destination directory if it doesn't exist.\n *\n * @param config - The config object.\n * @param options - The options object.\n */\nexport async function watchHandler(\n config: ProcessedConfig,\n options: WatchOptions,\n): Promise<void> {\n await executeSteps(steps, { config, options });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,cAAc;AAqBvB,IAAM,QAA6B;AAAA,EACjC;AAAA,IACE,MAAM;AAAA,IACN,MAAM,OAAO,EAAE,OAAO,MAAM;AAC1B,YAAM,EAAE,MAAM,IAAI;AAElB,UAAI,CAAE,MAAM,OAAO,KAAK,GAAI;AAC1B,cAAM,IAAI;AAAA,UACR,0BAA0B,KAAK;AAAA,QACjC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,WAAW,CAAC,EAAE,OAAO,MAAM,OAAO,OAAO;AAAA,IACzC,MAAM,OAAO,EAAE,QAAQ,SAAS,QAAQ,MAAM;AAC5C,YAAM,SAAS,UAAU,MAAM;AAC/B,YAAM,EAAE,KAAK,IAAI,MAAM,OAAO,OAAO,QAAQ,QAAQ,OAAO,OAAO,IAAI;AAEvE,WAAK,+CAA+C,IAAI,KAAK,OAAO;AAAA,IACtE;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM,OAAO,EAAE,QAAQ,QAAQ,MAAM;AACnC,YAAM,MAAM,QAAQ,EAAE,QAAQ,CAAC;AAAA,IACjC;AAAA,EACF;AACF;AAYA,eAAsB,aACpB,QACA,SACe;AACf,QAAM,aAAa,OAAO,EAAE,QAAQ,QAAQ,CAAC;AAC/C;","names":[]}
@@ -0,0 +1,64 @@
1
+ // src/webpack/loaders/wasm.ts
2
+ import { assert } from "@metamask/utils";
3
+ import { dirname, resolve } from "path";
4
+ function getImports(importMap) {
5
+ return Object.entries(importMap).map(
6
+ ([moduleName, exportNames]) => `import { ${exportNames.join(", ")} } from ${JSON.stringify(
7
+ moduleName
8
+ )};`
9
+ ).join("\n");
10
+ }
11
+ function getModuleImports(importMap) {
12
+ return Object.entries(importMap).map(
13
+ ([moduleName, exportNames]) => `${JSON.stringify(moduleName)}: { ${exportNames.join(", ")} },`
14
+ ).join("\n");
15
+ }
16
+ function getExports(descriptors) {
17
+ return descriptors.map((descriptor) => {
18
+ if (descriptor.name === "default") {
19
+ return `export default exports[${JSON.stringify(descriptor.name)}];`;
20
+ }
21
+ return `export const ${descriptor.name} = exports[${JSON.stringify(
22
+ descriptor.name
23
+ )}];`;
24
+ }).join("\n");
25
+ }
26
+ var loader = async function loader2(source) {
27
+ assert(source instanceof Uint8Array, "Expected source to be a Uint8Array.");
28
+ const bytes = new Uint8Array(source);
29
+ const wasmModule = await WebAssembly.compile(bytes);
30
+ const exports = WebAssembly.Module.exports(wasmModule);
31
+ const imports = WebAssembly.Module.imports(wasmModule).reduce((target, descriptor) => {
32
+ var _a;
33
+ target[_a = descriptor.module] ?? (target[_a] = []);
34
+ target[descriptor.module].push(descriptor.name);
35
+ return target;
36
+ }, {});
37
+ const path = dirname(this.resourcePath);
38
+ for (const name of Object.keys(imports)) {
39
+ this.addDependency(resolve(path, name));
40
+ }
41
+ return `
42
+ ${getImports(imports)}
43
+
44
+ const bytes = new Uint8Array(${JSON.stringify(Array.from(source))});
45
+ const module = new WebAssembly.Module(bytes);
46
+ const instance = new WebAssembly.Instance(module, {
47
+ ${getModuleImports(imports)}
48
+ });
49
+
50
+ const exports = instance.exports;
51
+ ${getExports(exports)}
52
+ `;
53
+ };
54
+ var wasm_default = loader;
55
+ var raw = true;
56
+
57
+ export {
58
+ getImports,
59
+ getModuleImports,
60
+ getExports,
61
+ wasm_default,
62
+ raw
63
+ };
64
+ //# sourceMappingURL=chunk-DWS4BJTE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/webpack/loaders/wasm.ts"],"sourcesContent":["/* eslint-disable no-restricted-globals */\n\nimport { assert } from '@metamask/utils';\nimport { dirname, resolve } from 'path';\nimport type { LoaderDefinitionFunction } from 'webpack';\n\n/**\n * Get the imports code for the WASM module. This code imports each of the\n * imports from the WASM module.\n *\n * @param importMap - The import map for the WASM module.\n * @returns The imports code for the WASM module.\n */\nexport function getImports(importMap: Record<string, string[]>) {\n return Object.entries(importMap)\n .map(\n ([moduleName, exportNames]) =>\n `import { ${exportNames.join(', ')} } from ${JSON.stringify(\n moduleName,\n )};`,\n )\n .join('\\n');\n}\n\n/**\n * Get the imports code to use in `WebAssembly.Instance`. This code adds each of\n * the imports to the `imports` object.\n *\n * @param importMap - The import map for the WASM module.\n * @returns The imports code for the WASM module.\n */\nexport function getModuleImports(importMap: Record<string, string[]>) {\n return Object.entries(importMap)\n .map(\n ([moduleName, exportNames]) =>\n `${JSON.stringify(moduleName)}: { ${exportNames.join(', ')} },`,\n )\n .join('\\n');\n}\n\n/**\n * Get the exports code for the WASM module. This code exports each of the\n * exports from the WASM module as a variable. This function assumes that the\n * exports are available in a variable named `exports`.\n *\n * @param descriptors - The export descriptors from the WASM module.\n * @returns The exports code for the WASM module.\n */\nexport function getExports(descriptors: WebAssembly.ModuleExportDescriptor[]) {\n return descriptors\n .map((descriptor) => {\n if (descriptor.name === 'default') {\n return `export default exports[${JSON.stringify(descriptor.name)}];`;\n }\n\n return `export const ${descriptor.name} = exports[${JSON.stringify(\n descriptor.name,\n )}];`;\n })\n .join('\\n');\n}\n\n/**\n * A Webpack loader that synchronously loads the WASM module. This makes it\n * possible to import the WASM module directly.\n *\n * @param source - The WASM module as `Uint8Array`.\n * @returns The WASM module as a JavaScript string.\n * @example\n * ```ts\n * import * as wasm from './program.wasm';\n *\n * // Do something with the WASM module...\n * ```\n */\n// Note: This function needs to be defined like this, so that Webpack can bind\n// `this` to the loader context, and TypeScript can infer the type of `this`.\nconst loader: LoaderDefinitionFunction = async function loader(\n source: unknown,\n) {\n assert(source instanceof Uint8Array, 'Expected source to be a Uint8Array.');\n\n const bytes = new Uint8Array(source);\n const wasmModule = await WebAssembly.compile(bytes);\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const exports = WebAssembly.Module.exports(wasmModule);\n const imports = WebAssembly.Module.imports(wasmModule).reduce<\n Record<string, string[]>\n >((target, descriptor) => {\n target[descriptor.module] ??= [];\n target[descriptor.module].push(descriptor.name);\n\n return target;\n }, {});\n\n // Add the WASM import as a dependency so that Webpack will watch it for\n // changes.\n const path = dirname(this.resourcePath);\n for (const name of Object.keys(imports)) {\n this.addDependency(resolve(path, name));\n }\n\n return `\n ${getImports(imports)}\n\n const bytes = new Uint8Array(${JSON.stringify(Array.from(source))});\n const module = new WebAssembly.Module(bytes);\n const instance = new WebAssembly.Instance(module, {\n ${getModuleImports(imports)}\n });\n\n const exports = instance.exports;\n ${getExports(exports)}\n `;\n};\n\nexport default loader;\n\n// By setting `raw` to `true`, we are telling Webpack to provide the source as a\n// `Uint8Array` instead of converting it to a string. This allows us to avoid\n// having to convert the source back to a `Uint8Array` in the loader.\nexport const raw = true;\n"],"mappings":";AAEA,SAAS,cAAc;AACvB,SAAS,SAAS,eAAe;AAU1B,SAAS,WAAW,WAAqC;AAC9D,SAAO,OAAO,QAAQ,SAAS,EAC5B;AAAA,IACC,CAAC,CAAC,YAAY,WAAW,MACvB,YAAY,YAAY,KAAK,IAAI,CAAC,WAAW,KAAK;AAAA,MAChD;AAAA,IACF,CAAC;AAAA,EACL,EACC,KAAK,IAAI;AACd;AASO,SAAS,iBAAiB,WAAqC;AACpE,SAAO,OAAO,QAAQ,SAAS,EAC5B;AAAA,IACC,CAAC,CAAC,YAAY,WAAW,MACvB,GAAG,KAAK,UAAU,UAAU,CAAC,OAAO,YAAY,KAAK,IAAI,CAAC;AAAA,EAC9D,EACC,KAAK,IAAI;AACd;AAUO,SAAS,WAAW,aAAmD;AAC5E,SAAO,YACJ,IAAI,CAAC,eAAe;AACnB,QAAI,WAAW,SAAS,WAAW;AACjC,aAA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