@metamask/snaps-sdk 6.3.0 → 6.4.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 (885) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/dist/error-wrappers.cjs +146 -0
  3. package/dist/error-wrappers.cjs.map +1 -0
  4. package/dist/error-wrappers.d.cts +830 -0
  5. package/dist/error-wrappers.d.cts.map +1 -0
  6. package/dist/{types/error-wrappers.d.ts → error-wrappers.d.mts} +193 -192
  7. package/dist/error-wrappers.d.mts.map +1 -0
  8. package/dist/error-wrappers.mjs +143 -0
  9. package/dist/error-wrappers.mjs.map +1 -0
  10. package/dist/errors.cjs +124 -0
  11. package/dist/errors.cjs.map +1 -0
  12. package/dist/{types/errors.d.ts → errors.d.cts} +3 -2
  13. package/dist/errors.d.cts.map +1 -0
  14. package/dist/errors.d.mts +87 -0
  15. package/dist/errors.d.mts.map +1 -0
  16. package/dist/errors.mjs +120 -0
  17. package/dist/errors.mjs.map +1 -0
  18. package/dist/images.cjs +91 -0
  19. package/dist/images.cjs.map +1 -0
  20. package/dist/{types/images.d.ts → images.d.cts} +2 -1
  21. package/dist/images.d.cts.map +1 -0
  22. package/dist/images.d.mts +70 -0
  23. package/dist/images.d.mts.map +1 -0
  24. package/dist/images.mjs +86 -0
  25. package/dist/images.mjs.map +1 -0
  26. package/dist/index.cjs +36 -0
  27. package/dist/index.cjs.map +1 -0
  28. package/dist/index.d.cts +10 -0
  29. package/dist/index.d.cts.map +1 -0
  30. package/dist/index.d.mts +10 -0
  31. package/dist/index.d.mts.map +1 -0
  32. package/dist/index.mjs +7 -1429
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/internals/error-wrappers.cjs +44 -0
  35. package/dist/internals/error-wrappers.cjs.map +1 -0
  36. package/dist/internals/error-wrappers.d.cts +60 -0
  37. package/dist/internals/error-wrappers.d.cts.map +1 -0
  38. package/dist/{types/internals/error-wrappers.d.ts → internals/error-wrappers.d.mts} +15 -14
  39. package/dist/internals/error-wrappers.d.mts.map +1 -0
  40. package/dist/internals/error-wrappers.mjs +40 -0
  41. package/dist/internals/error-wrappers.mjs.map +1 -0
  42. package/dist/internals/errors.cjs +80 -0
  43. package/dist/internals/errors.cjs.map +1 -0
  44. package/dist/{types/internals/errors.d.ts → internals/errors.d.cts} +1 -0
  45. package/dist/internals/errors.d.cts.map +1 -0
  46. package/dist/internals/errors.d.mts +42 -0
  47. package/dist/internals/errors.d.mts.map +1 -0
  48. package/dist/internals/errors.mjs +73 -0
  49. package/dist/internals/errors.mjs.map +1 -0
  50. package/dist/internals/helpers.cjs +3 -0
  51. package/dist/internals/helpers.cjs.map +1 -0
  52. package/dist/{types/internals/helpers.d.ts → internals/helpers.d.cts} +2 -1
  53. package/dist/internals/helpers.d.cts.map +1 -0
  54. package/dist/internals/helpers.d.mts +37 -0
  55. package/dist/internals/helpers.d.mts.map +1 -0
  56. package/dist/internals/helpers.mjs +2 -0
  57. package/dist/internals/helpers.mjs.map +1 -0
  58. package/dist/internals/index.cjs +23 -0
  59. package/dist/internals/index.cjs.map +1 -0
  60. package/dist/internals/index.d.cts +7 -0
  61. package/dist/internals/index.d.cts.map +1 -0
  62. package/dist/internals/index.d.mts +7 -0
  63. package/dist/internals/index.d.mts.map +1 -0
  64. package/dist/internals/index.mjs +7 -0
  65. package/dist/internals/index.mjs.map +1 -0
  66. package/dist/internals/jsx.cjs +17 -0
  67. package/dist/internals/jsx.cjs.map +1 -0
  68. package/dist/{types/internals/jsx.d.ts → internals/jsx.d.cts} +3 -2
  69. package/dist/internals/jsx.d.cts.map +1 -0
  70. package/dist/internals/jsx.d.mts +31 -0
  71. package/dist/internals/jsx.d.mts.map +1 -0
  72. package/dist/internals/jsx.mjs +13 -0
  73. package/dist/internals/jsx.mjs.map +1 -0
  74. package/dist/internals/structs.cjs +161 -0
  75. package/dist/internals/structs.cjs.map +1 -0
  76. package/dist/{types/internals/structs.d.ts → internals/structs.d.cts} +13 -3
  77. package/dist/internals/structs.d.cts.map +1 -0
  78. package/dist/internals/structs.d.mts +69 -0
  79. package/dist/internals/structs.d.mts.map +1 -0
  80. package/dist/internals/structs.mjs +153 -0
  81. package/dist/internals/structs.mjs.map +1 -0
  82. package/dist/internals/svg.cjs +23 -0
  83. package/dist/internals/svg.cjs.map +1 -0
  84. package/dist/{types/internals/svg.d.ts → internals/svg.d.cts} +1 -0
  85. package/dist/internals/svg.d.cts.map +1 -0
  86. package/dist/internals/svg.d.mts +8 -0
  87. package/dist/internals/svg.d.mts.map +1 -0
  88. package/dist/internals/svg.mjs +19 -0
  89. package/dist/internals/svg.mjs.map +1 -0
  90. package/dist/jsx/component.cjs +32 -0
  91. package/dist/jsx/component.cjs.map +1 -0
  92. package/dist/{types/jsx/component.d.ts → jsx/component.d.cts} +2 -1
  93. package/dist/jsx/component.d.cts.map +1 -0
  94. package/dist/jsx/component.d.mts +74 -0
  95. package/dist/jsx/component.d.mts.map +1 -0
  96. package/dist/jsx/component.mjs +28 -0
  97. package/dist/jsx/component.mjs.map +1 -0
  98. package/dist/jsx/components/Address.cjs +23 -0
  99. package/dist/jsx/components/Address.cjs.map +1 -0
  100. package/dist/jsx/components/Address.d.cts +34 -0
  101. package/dist/jsx/components/Address.d.cts.map +1 -0
  102. package/dist/jsx/components/Address.d.mts +34 -0
  103. package/dist/jsx/components/Address.d.mts.map +1 -0
  104. package/dist/jsx/components/Address.mjs +20 -0
  105. package/dist/jsx/components/Address.mjs.map +1 -0
  106. package/dist/jsx/components/Box.cjs +18 -0
  107. package/dist/jsx/components/Box.cjs.map +1 -0
  108. package/dist/{types/jsx/components/Box.d.ts → jsx/components/Box.d.cts} +2 -1
  109. package/dist/jsx/components/Box.d.cts.map +1 -0
  110. package/dist/jsx/components/Box.d.mts +32 -0
  111. package/dist/jsx/components/Box.d.mts.map +1 -0
  112. package/dist/jsx/components/Box.mjs +15 -0
  113. package/dist/jsx/components/Box.mjs.map +1 -0
  114. package/dist/jsx/components/Card.cjs +20 -0
  115. package/dist/jsx/components/Card.cjs.map +1 -0
  116. package/dist/{types/jsx/components/Card.d.ts → jsx/components/Card.d.cts} +1 -0
  117. package/dist/jsx/components/Card.d.cts.map +1 -0
  118. package/dist/jsx/components/Card.d.mts +37 -0
  119. package/dist/jsx/components/Card.d.mts.map +1 -0
  120. package/dist/jsx/components/Card.mjs +17 -0
  121. package/dist/jsx/components/Card.mjs.map +1 -0
  122. package/dist/jsx/components/Container.cjs +24 -0
  123. package/dist/jsx/components/Container.cjs.map +1 -0
  124. package/dist/{types/jsx/components/Container.d.ts → jsx/components/Container.d.cts} +4 -3
  125. package/dist/jsx/components/Container.d.cts.map +1 -0
  126. package/dist/jsx/components/Container.d.mts +35 -0
  127. package/dist/jsx/components/Container.d.mts.map +1 -0
  128. package/dist/jsx/components/Container.mjs +21 -0
  129. package/dist/jsx/components/Container.mjs.map +1 -0
  130. package/dist/jsx/components/Copyable.cjs +20 -0
  131. package/dist/jsx/components/Copyable.cjs.map +1 -0
  132. package/dist/{types/jsx/components/Copyable.d.ts → jsx/components/Copyable.d.cts} +1 -0
  133. package/dist/jsx/components/Copyable.d.cts.map +1 -0
  134. package/dist/jsx/components/Copyable.d.mts +33 -0
  135. package/dist/jsx/components/Copyable.d.mts.map +1 -0
  136. package/dist/jsx/components/Copyable.mjs +17 -0
  137. package/dist/jsx/components/Copyable.mjs.map +1 -0
  138. package/dist/jsx/components/Divider.cjs +17 -0
  139. package/dist/jsx/components/Divider.cjs.map +1 -0
  140. package/dist/{types/jsx/components/Divider.d.ts → jsx/components/Divider.d.cts} +1 -0
  141. package/dist/jsx/components/Divider.d.cts.map +1 -0
  142. package/dist/jsx/components/Divider.d.mts +18 -0
  143. package/dist/jsx/components/Divider.d.mts.map +1 -0
  144. package/dist/jsx/components/Divider.mjs +14 -0
  145. package/dist/jsx/components/Divider.mjs.map +1 -0
  146. package/dist/jsx/components/Footer.cjs +19 -0
  147. package/dist/jsx/components/Footer.cjs.map +1 -0
  148. package/dist/{types/jsx/components/Footer.d.ts → jsx/components/Footer.d.cts} +2 -1
  149. package/dist/jsx/components/Footer.d.cts.map +1 -0
  150. package/dist/jsx/components/Footer.d.mts +29 -0
  151. package/dist/jsx/components/Footer.d.mts.map +1 -0
  152. package/dist/jsx/components/Footer.mjs +16 -0
  153. package/dist/jsx/components/Footer.mjs.map +1 -0
  154. package/dist/jsx/components/Heading.cjs +16 -0
  155. package/dist/jsx/components/Heading.cjs.map +1 -0
  156. package/dist/{types/jsx/components/Heading.d.ts → jsx/components/Heading.d.cts} +2 -1
  157. package/dist/jsx/components/Heading.d.cts.map +1 -0
  158. package/dist/jsx/components/Heading.d.mts +27 -0
  159. package/dist/jsx/components/Heading.d.mts.map +1 -0
  160. package/dist/jsx/components/Heading.mjs +13 -0
  161. package/dist/jsx/components/Heading.mjs.map +1 -0
  162. package/dist/jsx/components/Icon.cjs +180 -0
  163. package/dist/jsx/components/Icon.cjs.map +1 -0
  164. package/dist/{types/jsx/components/Icon.d.ts → jsx/components/Icon.d.cts} +1 -0
  165. package/dist/jsx/components/Icon.d.cts.map +1 -0
  166. package/dist/jsx/components/Icon.d.mts +190 -0
  167. package/dist/jsx/components/Icon.d.mts.map +1 -0
  168. package/dist/jsx/components/Icon.mjs +177 -0
  169. package/dist/jsx/components/Icon.mjs.map +1 -0
  170. package/dist/jsx/components/Image.cjs +22 -0
  171. package/dist/jsx/components/Image.cjs.map +1 -0
  172. package/dist/{types/jsx/components/Image.d.ts → jsx/components/Image.d.cts} +1 -0
  173. package/dist/jsx/components/Image.d.cts.map +1 -0
  174. package/dist/jsx/components/Image.d.mts +37 -0
  175. package/dist/jsx/components/Image.d.mts.map +1 -0
  176. package/dist/jsx/components/Image.mjs +19 -0
  177. package/dist/jsx/components/Image.mjs.map +1 -0
  178. package/dist/jsx/components/Link.cjs +18 -0
  179. package/dist/jsx/components/Link.cjs.map +1 -0
  180. package/dist/{types/jsx/components/Link.d.ts → jsx/components/Link.d.cts} +3 -2
  181. package/dist/jsx/components/Link.d.cts.map +1 -0
  182. package/dist/jsx/components/Link.d.mts +36 -0
  183. package/dist/jsx/components/Link.d.mts.map +1 -0
  184. package/dist/jsx/components/Link.mjs +15 -0
  185. package/dist/jsx/components/Link.mjs.map +1 -0
  186. package/dist/jsx/components/Row.cjs +22 -0
  187. package/dist/jsx/components/Row.cjs.map +1 -0
  188. package/dist/{types/jsx/components/Row.d.ts → jsx/components/Row.d.cts} +5 -4
  189. package/dist/jsx/components/Row.d.cts.map +1 -0
  190. package/dist/jsx/components/Row.d.mts +46 -0
  191. package/dist/jsx/components/Row.d.mts.map +1 -0
  192. package/dist/jsx/components/Row.mjs +19 -0
  193. package/dist/jsx/components/Row.mjs.map +1 -0
  194. package/dist/jsx/components/Section.cjs +26 -0
  195. package/dist/jsx/components/Section.cjs.map +1 -0
  196. package/dist/jsx/components/Section.d.cts +38 -0
  197. package/dist/jsx/components/Section.d.cts.map +1 -0
  198. package/dist/jsx/components/Section.d.mts +38 -0
  199. package/dist/jsx/components/Section.d.mts.map +1 -0
  200. package/dist/jsx/components/Section.mjs +23 -0
  201. package/dist/jsx/components/Section.mjs.map +1 -0
  202. package/dist/jsx/components/Spinner.cjs +17 -0
  203. package/dist/jsx/components/Spinner.cjs.map +1 -0
  204. package/dist/{types/jsx/components/Spinner.d.ts → jsx/components/Spinner.d.cts} +1 -0
  205. package/dist/jsx/components/Spinner.d.cts.map +1 -0
  206. package/dist/jsx/components/Spinner.d.mts +18 -0
  207. package/dist/jsx/components/Spinner.d.mts.map +1 -0
  208. package/dist/jsx/components/Spinner.mjs +14 -0
  209. package/dist/jsx/components/Spinner.mjs.map +1 -0
  210. package/dist/jsx/components/Text.cjs +22 -0
  211. package/dist/jsx/components/Text.cjs.map +1 -0
  212. package/dist/{types/jsx/components/Text.d.ts → jsx/components/Text.d.cts} +5 -4
  213. package/dist/jsx/components/Text.d.cts.map +1 -0
  214. package/dist/jsx/components/Text.d.mts +45 -0
  215. package/dist/jsx/components/Text.d.mts.map +1 -0
  216. package/dist/jsx/components/Text.mjs +19 -0
  217. package/dist/jsx/components/Text.mjs.map +1 -0
  218. package/dist/jsx/components/Tooltip.cjs +23 -0
  219. package/dist/jsx/components/Tooltip.cjs.map +1 -0
  220. package/dist/{types/jsx/components/Tooltip.d.ts → jsx/components/Tooltip.d.cts} +6 -5
  221. package/dist/jsx/components/Tooltip.d.cts.map +1 -0
  222. package/dist/jsx/components/Tooltip.d.mts +40 -0
  223. package/dist/jsx/components/Tooltip.d.mts.map +1 -0
  224. package/dist/jsx/components/Tooltip.mjs +20 -0
  225. package/dist/jsx/components/Tooltip.mjs.map +1 -0
  226. package/dist/jsx/components/Value.cjs +21 -0
  227. package/dist/jsx/components/Value.cjs.map +1 -0
  228. package/dist/{types/jsx/components/Value.d.ts → jsx/components/Value.d.cts} +1 -0
  229. package/dist/jsx/components/Value.d.cts.map +1 -0
  230. package/dist/jsx/components/Value.d.mts +32 -0
  231. package/dist/jsx/components/Value.d.mts.map +1 -0
  232. package/dist/jsx/components/Value.mjs +18 -0
  233. package/dist/jsx/components/Value.mjs.map +1 -0
  234. package/dist/jsx/components/form/Button.cjs +17 -0
  235. package/dist/jsx/components/form/Button.cjs.map +1 -0
  236. package/dist/{types/jsx/components/form/Button.d.ts → jsx/components/form/Button.d.cts} +4 -3
  237. package/dist/jsx/components/form/Button.d.cts.map +1 -0
  238. package/dist/jsx/components/form/Button.d.mts +40 -0
  239. package/dist/jsx/components/form/Button.d.mts.map +1 -0
  240. package/dist/jsx/components/form/Button.mjs +14 -0
  241. package/dist/jsx/components/form/Button.mjs.map +1 -0
  242. package/dist/jsx/components/form/Checkbox.cjs +20 -0
  243. package/dist/jsx/components/form/Checkbox.cjs.map +1 -0
  244. package/dist/{types/jsx/components/form/Checkbox.d.ts → jsx/components/form/Checkbox.d.cts} +1 -0
  245. package/dist/jsx/components/form/Checkbox.d.cts.map +1 -0
  246. package/dist/jsx/components/form/Checkbox.d.mts +36 -0
  247. package/dist/jsx/components/form/Checkbox.d.mts.map +1 -0
  248. package/dist/jsx/components/form/Checkbox.mjs +17 -0
  249. package/dist/jsx/components/form/Checkbox.mjs.map +1 -0
  250. package/dist/jsx/components/form/Dropdown.cjs +23 -0
  251. package/dist/jsx/components/form/Dropdown.cjs.map +1 -0
  252. package/dist/{types/jsx/components/form/Dropdown.d.ts → jsx/components/form/Dropdown.d.cts} +3 -2
  253. package/dist/jsx/components/form/Dropdown.d.cts.map +1 -0
  254. package/dist/jsx/components/form/Dropdown.d.mts +39 -0
  255. package/dist/jsx/components/form/Dropdown.d.mts.map +1 -0
  256. package/dist/jsx/components/form/Dropdown.mjs +20 -0
  257. package/dist/jsx/components/form/Dropdown.mjs.map +1 -0
  258. package/dist/jsx/components/form/Field.cjs +26 -0
  259. package/dist/jsx/components/form/Field.cjs.map +1 -0
  260. package/dist/{types/jsx/components/form/Field.d.ts → jsx/components/form/Field.d.cts} +9 -8
  261. package/dist/jsx/components/form/Field.d.cts.map +1 -0
  262. package/dist/jsx/components/form/Field.d.mts +46 -0
  263. package/dist/jsx/components/form/Field.d.mts.map +1 -0
  264. package/dist/jsx/components/form/Field.mjs +23 -0
  265. package/dist/jsx/components/form/Field.mjs.map +1 -0
  266. package/dist/jsx/components/form/FileInput.cjs +31 -0
  267. package/dist/jsx/components/form/FileInput.cjs.map +1 -0
  268. package/dist/{types/jsx/components/form/FileInput.d.ts → jsx/components/form/FileInput.d.cts} +1 -0
  269. package/dist/jsx/components/form/FileInput.d.cts.map +1 -0
  270. package/dist/jsx/components/form/FileInput.d.mts +48 -0
  271. package/dist/jsx/components/form/FileInput.d.mts.map +1 -0
  272. package/dist/jsx/components/form/FileInput.mjs +28 -0
  273. package/dist/jsx/components/form/FileInput.mjs.map +1 -0
  274. package/dist/jsx/components/form/Form.cjs +24 -0
  275. package/dist/jsx/components/form/Form.cjs.map +1 -0
  276. package/dist/{types/jsx/components/form/Form.d.ts → jsx/components/form/Form.d.cts} +2 -1
  277. package/dist/jsx/components/form/Form.d.cts.map +1 -0
  278. package/dist/jsx/components/form/Form.d.mts +37 -0
  279. package/dist/jsx/components/form/Form.d.mts.map +1 -0
  280. package/dist/jsx/components/form/Form.mjs +21 -0
  281. package/dist/jsx/components/form/Form.mjs.map +1 -0
  282. package/dist/jsx/components/form/Input.cjs +20 -0
  283. package/dist/jsx/components/form/Input.cjs.map +1 -0
  284. package/dist/{types/jsx/components/form/Input.d.ts → jsx/components/form/Input.d.cts} +1 -0
  285. package/dist/jsx/components/form/Input.d.cts.map +1 -0
  286. package/dist/jsx/components/form/Input.d.mts +36 -0
  287. package/dist/jsx/components/form/Input.d.mts.map +1 -0
  288. package/dist/jsx/components/form/Input.mjs +17 -0
  289. package/dist/jsx/components/form/Input.mjs.map +1 -0
  290. package/dist/jsx/components/form/Option.cjs +25 -0
  291. package/dist/jsx/components/form/Option.cjs.map +1 -0
  292. package/dist/{types/jsx/components/form/Option.d.ts → jsx/components/form/Option.d.cts} +1 -0
  293. package/dist/jsx/components/form/Option.d.cts.map +1 -0
  294. package/dist/jsx/components/form/Option.d.mts +36 -0
  295. package/dist/jsx/components/form/Option.d.mts.map +1 -0
  296. package/dist/jsx/components/form/Option.mjs +22 -0
  297. package/dist/jsx/components/form/Option.mjs.map +1 -0
  298. package/dist/jsx/components/form/Radio.cjs +23 -0
  299. package/dist/jsx/components/form/Radio.cjs.map +1 -0
  300. package/dist/{types/jsx/components/form/Radio.d.ts → jsx/components/form/Radio.d.cts} +1 -0
  301. package/dist/jsx/components/form/Radio.d.cts.map +1 -0
  302. package/dist/jsx/components/form/Radio.d.mts +36 -0
  303. package/dist/jsx/components/form/Radio.d.mts.map +1 -0
  304. package/dist/jsx/components/form/Radio.mjs +20 -0
  305. package/dist/jsx/components/form/Radio.mjs.map +1 -0
  306. package/dist/jsx/components/form/RadioGroup.cjs +14 -0
  307. package/dist/jsx/components/form/RadioGroup.cjs.map +1 -0
  308. package/dist/{types/jsx/components/form/RadioGroup.d.ts → jsx/components/form/RadioGroup.d.cts} +3 -2
  309. package/dist/jsx/components/form/RadioGroup.d.cts.map +1 -0
  310. package/dist/jsx/components/form/RadioGroup.d.mts +30 -0
  311. package/dist/jsx/components/form/RadioGroup.d.mts.map +1 -0
  312. package/dist/jsx/components/form/RadioGroup.mjs +11 -0
  313. package/dist/jsx/components/form/RadioGroup.mjs.map +1 -0
  314. package/dist/jsx/components/form/Selector.cjs +24 -0
  315. package/dist/jsx/components/form/Selector.cjs.map +1 -0
  316. package/dist/{types/jsx/components/form/Selector.d.ts → jsx/components/form/Selector.d.cts} +3 -2
  317. package/dist/jsx/components/form/Selector.d.cts.map +1 -0
  318. package/dist/jsx/components/form/Selector.d.mts +42 -0
  319. package/dist/jsx/components/form/Selector.d.mts.map +1 -0
  320. package/dist/jsx/components/form/Selector.mjs +21 -0
  321. package/dist/jsx/components/form/Selector.mjs.map +1 -0
  322. package/dist/jsx/components/form/SelectorOption.cjs +23 -0
  323. package/dist/jsx/components/form/SelectorOption.cjs.map +1 -0
  324. package/dist/{types/jsx/components/form/SelectorOption.d.ts → jsx/components/form/SelectorOption.d.cts} +2 -1
  325. package/dist/jsx/components/form/SelectorOption.d.cts.map +1 -0
  326. package/dist/jsx/components/form/SelectorOption.d.mts +36 -0
  327. package/dist/jsx/components/form/SelectorOption.d.mts.map +1 -0
  328. package/dist/jsx/components/form/SelectorOption.mjs +20 -0
  329. package/dist/jsx/components/form/SelectorOption.mjs.map +1 -0
  330. package/dist/jsx/components/form/index.cjs +29 -0
  331. package/dist/jsx/components/form/index.cjs.map +1 -0
  332. package/dist/jsx/components/form/index.d.cts +26 -0
  333. package/dist/jsx/components/form/index.d.cts.map +1 -0
  334. package/dist/jsx/components/form/index.d.mts +26 -0
  335. package/dist/jsx/components/form/index.d.mts.map +1 -0
  336. package/dist/jsx/components/form/index.mjs +13 -0
  337. package/dist/jsx/components/form/index.mjs.map +1 -0
  338. package/dist/jsx/components/formatting/Bold.cjs +21 -0
  339. package/dist/jsx/components/formatting/Bold.cjs.map +1 -0
  340. package/dist/{types/jsx/components/formatting/Bold.d.ts → jsx/components/formatting/Bold.d.cts} +2 -1
  341. package/dist/jsx/components/formatting/Bold.d.cts.map +1 -0
  342. package/dist/jsx/components/formatting/Bold.d.mts +33 -0
  343. package/dist/jsx/components/formatting/Bold.d.mts.map +1 -0
  344. package/dist/jsx/components/formatting/Bold.mjs +18 -0
  345. package/dist/jsx/components/formatting/Bold.mjs.map +1 -0
  346. package/dist/jsx/components/formatting/Italic.cjs +20 -0
  347. package/dist/jsx/components/formatting/Italic.cjs.map +1 -0
  348. package/dist/{types/jsx/components/formatting/Italic.d.ts → jsx/components/formatting/Italic.d.cts} +2 -1
  349. package/dist/jsx/components/formatting/Italic.d.cts.map +1 -0
  350. package/dist/jsx/components/formatting/Italic.d.mts +35 -0
  351. package/dist/jsx/components/formatting/Italic.d.mts.map +1 -0
  352. package/dist/jsx/components/formatting/Italic.mjs +17 -0
  353. package/dist/jsx/components/formatting/Italic.mjs.map +1 -0
  354. package/dist/jsx/components/formatting/index.cjs +19 -0
  355. package/dist/jsx/components/formatting/index.cjs.map +1 -0
  356. package/dist/jsx/components/formatting/index.d.cts +6 -0
  357. package/dist/jsx/components/formatting/index.d.cts.map +1 -0
  358. package/dist/jsx/components/formatting/index.d.mts +6 -0
  359. package/dist/jsx/components/formatting/index.d.mts.map +1 -0
  360. package/dist/jsx/components/formatting/index.mjs +3 -0
  361. package/dist/jsx/components/formatting/index.mjs.map +1 -0
  362. package/dist/jsx/components/index.cjs +36 -0
  363. package/dist/jsx/components/index.cjs.map +1 -0
  364. package/dist/jsx/components/index.d.cts +43 -0
  365. package/dist/jsx/components/index.d.cts.map +1 -0
  366. package/dist/jsx/components/index.d.mts +43 -0
  367. package/dist/jsx/components/index.d.mts.map +1 -0
  368. package/dist/jsx/components/index.mjs +20 -0
  369. package/dist/jsx/components/index.mjs.map +1 -0
  370. package/dist/jsx/index.cjs +31 -0
  371. package/dist/jsx/index.cjs.map +1 -0
  372. package/dist/jsx/index.d.cts +6 -0
  373. package/dist/jsx/index.d.cts.map +1 -0
  374. package/dist/jsx/index.d.mts +6 -0
  375. package/dist/jsx/index.d.mts.map +1 -0
  376. package/dist/jsx/index.mjs +5 -809
  377. package/dist/jsx/index.mjs.map +1 -1
  378. package/dist/jsx/jsx-dev-runtime.cjs +27 -0
  379. package/dist/jsx/jsx-dev-runtime.cjs.map +1 -0
  380. package/dist/{types/jsx/jsx-dev-runtime.d.ts → jsx/jsx-dev-runtime.d.cts} +2 -1
  381. package/dist/jsx/jsx-dev-runtime.d.cts.map +1 -0
  382. package/dist/jsx/jsx-dev-runtime.d.mts +18 -0
  383. package/dist/jsx/jsx-dev-runtime.d.mts.map +1 -0
  384. package/dist/jsx/jsx-dev-runtime.mjs +21 -642
  385. package/dist/jsx/jsx-dev-runtime.mjs.map +1 -1
  386. package/dist/jsx/jsx-runtime.cjs +54 -0
  387. package/dist/jsx/jsx-runtime.cjs.map +1 -0
  388. package/dist/{types/jsx/jsx-runtime.d.ts → jsx/jsx-runtime.d.cts} +2 -1
  389. package/dist/jsx/jsx-runtime.d.cts.map +1 -0
  390. package/dist/jsx/jsx-runtime.d.mts +36 -0
  391. package/dist/jsx/jsx-runtime.d.mts.map +1 -0
  392. package/dist/jsx/jsx-runtime.mjs +46 -21
  393. package/dist/jsx/jsx-runtime.mjs.map +1 -1
  394. package/dist/jsx/validation.cjs +577 -0
  395. package/dist/jsx/validation.cjs.map +1 -0
  396. package/dist/{types/jsx/validation.d.ts → jsx/validation.d.cts} +22 -17
  397. package/dist/jsx/validation.d.cts.map +1 -0
  398. package/dist/jsx/validation.d.mts +247 -0
  399. package/dist/jsx/validation.d.mts.map +1 -0
  400. package/dist/jsx/validation.mjs +571 -0
  401. package/dist/jsx/validation.mjs.map +1 -0
  402. package/dist/types/caip.cjs +3 -0
  403. package/dist/types/caip.cjs.map +1 -0
  404. package/dist/types/{types/caip.d.ts → caip.d.cts} +1 -0
  405. package/dist/types/caip.d.cts.map +1 -0
  406. package/dist/types/caip.d.mts +13 -0
  407. package/dist/types/caip.d.mts.map +1 -0
  408. package/dist/types/caip.mjs +2 -0
  409. package/dist/types/caip.mjs.map +1 -0
  410. package/dist/types/global.cjs +3 -0
  411. package/dist/types/global.cjs.map +1 -0
  412. package/dist/types/{types/global.d.ts → global.d.cts} +2 -1
  413. package/dist/types/global.d.cts.map +1 -0
  414. package/dist/types/global.d.mts +9 -0
  415. package/dist/types/global.d.mts.map +1 -0
  416. package/dist/types/global.mjs +2 -0
  417. package/dist/types/global.mjs.map +1 -0
  418. package/dist/types/handlers/cronjob.cjs +3 -0
  419. package/dist/types/handlers/cronjob.cjs.map +1 -0
  420. package/dist/types/{types/handlers/cronjob.d.ts → handlers/cronjob.d.cts} +2 -1
  421. package/dist/types/handlers/cronjob.d.cts.map +1 -0
  422. package/dist/types/handlers/cronjob.d.mts +15 -0
  423. package/dist/types/handlers/cronjob.d.mts.map +1 -0
  424. package/dist/types/handlers/cronjob.mjs +2 -0
  425. package/dist/types/handlers/cronjob.mjs.map +1 -0
  426. package/dist/types/handlers/home-page.cjs +3 -0
  427. package/dist/types/handlers/home-page.cjs.map +1 -0
  428. package/dist/types/{types/handlers/home-page.d.ts → handlers/home-page.d.cts} +2 -1
  429. package/dist/types/handlers/home-page.d.cts.map +1 -0
  430. package/dist/types/handlers/home-page.d.mts +23 -0
  431. package/dist/types/handlers/home-page.d.mts.map +1 -0
  432. package/dist/types/handlers/home-page.mjs +2 -0
  433. package/dist/types/handlers/home-page.mjs.map +1 -0
  434. package/dist/types/handlers/index.cjs +26 -0
  435. package/dist/types/handlers/index.cjs.map +1 -0
  436. package/dist/types/handlers/index.d.cts +10 -0
  437. package/dist/types/handlers/index.d.cts.map +1 -0
  438. package/dist/types/handlers/index.d.mts +10 -0
  439. package/dist/types/handlers/index.d.mts.map +1 -0
  440. package/dist/types/handlers/index.mjs +10 -0
  441. package/dist/types/handlers/index.mjs.map +1 -0
  442. package/dist/types/handlers/keyring.cjs +3 -0
  443. package/dist/types/handlers/keyring.cjs.map +1 -0
  444. package/dist/types/{types/handlers/keyring.d.ts → handlers/keyring.d.cts} +2 -1
  445. package/dist/types/handlers/keyring.d.cts.map +1 -0
  446. package/dist/types/handlers/keyring.d.mts +21 -0
  447. package/dist/types/handlers/keyring.d.mts.map +1 -0
  448. package/dist/types/handlers/keyring.mjs +2 -0
  449. package/dist/types/handlers/keyring.mjs.map +1 -0
  450. package/dist/types/handlers/lifecycle.cjs +3 -0
  451. package/dist/types/handlers/lifecycle.cjs.map +1 -0
  452. package/dist/types/{types/handlers/lifecycle.d.ts → handlers/lifecycle.d.cts} +1 -0
  453. package/dist/types/handlers/lifecycle.d.cts.map +1 -0
  454. package/dist/types/handlers/lifecycle.d.mts +38 -0
  455. package/dist/types/handlers/lifecycle.d.mts.map +1 -0
  456. package/dist/types/handlers/lifecycle.mjs +2 -0
  457. package/dist/types/handlers/lifecycle.mjs.map +1 -0
  458. package/dist/types/handlers/name-lookup.cjs +3 -0
  459. package/dist/types/handlers/name-lookup.cjs.map +1 -0
  460. package/dist/types/{types/handlers/name-lookup.d.ts → handlers/name-lookup.d.cts} +3 -2
  461. package/dist/types/handlers/name-lookup.d.cts.map +1 -0
  462. package/dist/types/handlers/name-lookup.d.mts +82 -0
  463. package/dist/types/handlers/name-lookup.d.mts.map +1 -0
  464. package/dist/types/handlers/name-lookup.mjs +2 -0
  465. package/dist/types/handlers/name-lookup.mjs.map +1 -0
  466. package/dist/types/handlers/rpc-request.cjs +3 -0
  467. package/dist/types/handlers/rpc-request.cjs.map +1 -0
  468. package/dist/types/{types/handlers/rpc-request.d.ts → handlers/rpc-request.d.cts} +2 -1
  469. package/dist/types/handlers/rpc-request.d.cts.map +1 -0
  470. package/dist/types/handlers/rpc-request.d.mts +22 -0
  471. package/dist/types/handlers/rpc-request.d.mts.map +1 -0
  472. package/dist/types/handlers/rpc-request.mjs +2 -0
  473. package/dist/types/handlers/rpc-request.mjs.map +1 -0
  474. package/dist/types/handlers/signature.cjs +3 -0
  475. package/dist/types/handlers/signature.cjs.map +1 -0
  476. package/dist/types/{types/handlers/signature.d.ts → handlers/signature.d.cts} +4 -3
  477. package/dist/types/handlers/signature.d.cts.map +1 -0
  478. package/dist/types/handlers/signature.d.mts +112 -0
  479. package/dist/types/handlers/signature.d.mts.map +1 -0
  480. package/dist/types/handlers/signature.mjs +2 -0
  481. package/dist/types/handlers/signature.mjs.map +1 -0
  482. package/dist/types/handlers/transaction.cjs +15 -0
  483. package/dist/types/handlers/transaction.cjs.map +1 -0
  484. package/dist/types/{types/handlers/transaction.d.ts → handlers/transaction.d.cts} +4 -3
  485. package/dist/types/handlers/transaction.d.cts.map +1 -0
  486. package/dist/types/handlers/transaction.d.mts +115 -0
  487. package/dist/types/handlers/transaction.d.mts.map +1 -0
  488. package/dist/types/handlers/transaction.mjs +12 -0
  489. package/dist/types/handlers/transaction.mjs.map +1 -0
  490. package/dist/types/handlers/user-input.cjs +56 -0
  491. package/dist/types/handlers/user-input.cjs.map +1 -0
  492. package/dist/types/{types/handlers/user-input.d.ts → handlers/user-input.d.cts} +11 -10
  493. package/dist/types/handlers/user-input.d.cts.map +1 -0
  494. package/dist/types/handlers/user-input.d.mts +196 -0
  495. package/dist/types/handlers/user-input.d.mts.map +1 -0
  496. package/dist/types/handlers/user-input.mjs +53 -0
  497. package/dist/types/handlers/user-input.mjs.map +1 -0
  498. package/dist/types/images.cjs +2 -0
  499. package/dist/types/images.cjs.map +1 -0
  500. package/dist/types/{types/images.d.ts → images.d.cts} +1 -0
  501. package/dist/types/images.d.cts.map +1 -0
  502. package/dist/types/images.d.mts +13 -0
  503. package/dist/types/images.d.mts.map +1 -0
  504. package/dist/types/images.mjs +2 -0
  505. package/dist/types/images.mjs.map +1 -0
  506. package/dist/types/index.cjs +29 -0
  507. package/dist/types/index.cjs.map +1 -0
  508. package/dist/types/index.d.cts +10 -0
  509. package/dist/types/index.d.cts.map +1 -0
  510. package/dist/types/index.d.mts +10 -0
  511. package/dist/types/index.d.mts.map +1 -0
  512. package/dist/types/index.mjs +13 -0
  513. package/dist/types/index.mjs.map +1 -0
  514. package/dist/types/interface.cjs +26 -0
  515. package/dist/types/interface.cjs.map +1 -0
  516. package/dist/types/{types/interface.d.ts → interface.d.cts} +22 -21
  517. package/dist/types/interface.d.cts.map +1 -0
  518. package/dist/types/interface.d.mts +120 -0
  519. package/dist/types/interface.d.mts.map +1 -0
  520. package/dist/types/interface.mjs +23 -0
  521. package/dist/types/interface.mjs.map +1 -0
  522. package/dist/types/methods/create-interface.cjs +3 -0
  523. package/dist/types/methods/create-interface.cjs.map +1 -0
  524. package/dist/types/{types/methods/create-interface.d.ts → methods/create-interface.d.cts} +2 -1
  525. package/dist/types/methods/create-interface.d.cts.map +1 -0
  526. package/dist/types/methods/create-interface.d.mts +15 -0
  527. package/dist/types/methods/create-interface.d.mts.map +1 -0
  528. package/dist/types/methods/create-interface.mjs +2 -0
  529. package/dist/types/methods/create-interface.mjs.map +1 -0
  530. package/dist/types/methods/dialog.cjs +18 -0
  531. package/dist/types/methods/dialog.cjs.map +1 -0
  532. package/dist/types/{types/methods/dialog.d.ts → methods/dialog.d.cts} +4 -3
  533. package/dist/types/methods/dialog.d.cts.map +1 -0
  534. package/dist/types/methods/dialog.d.mts +88 -0
  535. package/dist/types/methods/dialog.d.mts.map +1 -0
  536. package/dist/types/methods/dialog.mjs +15 -0
  537. package/dist/types/methods/dialog.mjs.map +1 -0
  538. package/dist/types/methods/get-bip32-entropy.cjs +3 -0
  539. package/dist/types/methods/get-bip32-entropy.cjs.map +1 -0
  540. package/dist/types/{types/methods/get-bip32-entropy.d.ts → methods/get-bip32-entropy.d.cts} +3 -2
  541. package/dist/types/methods/get-bip32-entropy.d.cts.map +1 -0
  542. package/dist/types/methods/get-bip32-entropy.d.mts +16 -0
  543. package/dist/types/methods/get-bip32-entropy.d.mts.map +1 -0
  544. package/dist/types/methods/get-bip32-entropy.mjs +2 -0
  545. package/dist/types/methods/get-bip32-entropy.mjs.map +1 -0
  546. package/dist/types/methods/get-bip32-public-key.cjs +3 -0
  547. package/dist/types/methods/get-bip32-public-key.cjs.map +1 -0
  548. package/dist/types/{types/methods/get-bip32-public-key.d.ts → methods/get-bip32-public-key.d.cts} +2 -1
  549. package/dist/types/methods/get-bip32-public-key.d.cts.map +1 -0
  550. package/dist/types/methods/get-bip32-public-key.d.mts +20 -0
  551. package/dist/types/methods/get-bip32-public-key.d.mts.map +1 -0
  552. package/dist/types/methods/get-bip32-public-key.mjs +2 -0
  553. package/dist/types/methods/get-bip32-public-key.mjs.map +1 -0
  554. package/dist/types/methods/get-bip44-entropy.cjs +3 -0
  555. package/dist/types/methods/get-bip44-entropy.cjs.map +1 -0
  556. package/dist/types/{types/methods/get-bip44-entropy.d.ts → methods/get-bip44-entropy.d.cts} +3 -2
  557. package/dist/types/methods/get-bip44-entropy.d.cts.map +1 -0
  558. package/dist/types/methods/get-bip44-entropy.d.mts +15 -0
  559. package/dist/types/methods/get-bip44-entropy.d.mts.map +1 -0
  560. package/dist/types/methods/get-bip44-entropy.mjs +2 -0
  561. package/dist/types/methods/get-bip44-entropy.mjs.map +1 -0
  562. package/dist/types/methods/get-client-status.cjs +3 -0
  563. package/dist/types/methods/get-client-status.cjs.map +1 -0
  564. package/dist/types/{types/methods/get-client-status.d.ts → methods/get-client-status.d.cts} +1 -0
  565. package/dist/types/methods/get-client-status.d.cts.map +1 -0
  566. package/dist/types/methods/get-client-status.d.mts +15 -0
  567. package/dist/types/methods/get-client-status.d.mts.map +1 -0
  568. package/dist/types/methods/get-client-status.mjs +2 -0
  569. package/dist/types/methods/get-client-status.mjs.map +1 -0
  570. package/dist/types/methods/get-entropy.cjs +3 -0
  571. package/dist/types/methods/get-entropy.cjs.map +1 -0
  572. package/dist/types/{types/methods/get-entropy.d.ts → methods/get-entropy.d.cts} +2 -1
  573. package/dist/types/methods/get-entropy.d.cts.map +1 -0
  574. package/dist/types/methods/get-entropy.d.mts +17 -0
  575. package/dist/types/methods/get-entropy.d.mts.map +1 -0
  576. package/dist/types/methods/get-entropy.mjs +2 -0
  577. package/dist/types/methods/get-entropy.mjs.map +1 -0
  578. package/dist/types/methods/get-file.cjs +13 -0
  579. package/dist/types/methods/get-file.cjs.map +1 -0
  580. package/dist/types/{types/methods/get-file.d.ts → methods/get-file.d.cts} +2 -1
  581. package/dist/types/methods/get-file.d.cts.map +1 -0
  582. package/dist/types/methods/get-file.d.mts +24 -0
  583. package/dist/types/methods/get-file.d.mts.map +1 -0
  584. package/dist/types/methods/get-file.mjs +10 -0
  585. package/dist/types/methods/get-file.mjs.map +1 -0
  586. package/dist/types/methods/get-interface-state.cjs +3 -0
  587. package/dist/types/methods/get-interface-state.cjs.map +1 -0
  588. package/dist/types/{types/methods/get-interface-state.d.ts → methods/get-interface-state.d.cts} +2 -1
  589. package/dist/types/methods/get-interface-state.d.cts.map +1 -0
  590. package/dist/types/methods/get-interface-state.d.mts +14 -0
  591. package/dist/types/methods/get-interface-state.d.mts.map +1 -0
  592. package/dist/types/methods/get-interface-state.mjs +2 -0
  593. package/dist/types/methods/get-interface-state.mjs.map +1 -0
  594. package/dist/types/methods/get-locale.cjs +3 -0
  595. package/dist/types/methods/get-locale.cjs.map +1 -0
  596. package/dist/types/{types/methods/get-locale.d.ts → methods/get-locale.d.cts} +1 -0
  597. package/dist/types/methods/get-locale.d.cts.map +1 -0
  598. package/dist/types/methods/get-locale.d.mts +13 -0
  599. package/dist/types/methods/get-locale.d.mts.map +1 -0
  600. package/dist/types/methods/get-locale.mjs +2 -0
  601. package/dist/types/methods/get-locale.mjs.map +1 -0
  602. package/dist/types/methods/get-preferences.cjs +3 -0
  603. package/dist/types/methods/get-preferences.cjs.map +1 -0
  604. package/dist/types/{types/methods/get-preferences.d.ts → methods/get-preferences.d.cts} +1 -0
  605. package/dist/types/methods/get-preferences.d.cts.map +1 -0
  606. package/dist/types/methods/get-preferences.d.mts +16 -0
  607. package/dist/types/methods/get-preferences.d.mts.map +1 -0
  608. package/dist/types/methods/get-preferences.mjs +2 -0
  609. package/dist/types/methods/get-preferences.mjs.map +1 -0
  610. package/dist/types/methods/get-snaps.cjs +3 -0
  611. package/dist/types/methods/get-snaps.cjs.map +1 -0
  612. package/dist/types/{types/methods/get-snaps.d.ts → methods/get-snaps.d.cts} +3 -2
  613. package/dist/types/methods/get-snaps.d.cts.map +1 -0
  614. package/dist/types/methods/get-snaps.d.mts +17 -0
  615. package/dist/types/methods/get-snaps.d.mts.map +1 -0
  616. package/dist/types/methods/get-snaps.mjs +2 -0
  617. package/dist/types/methods/get-snaps.mjs.map +1 -0
  618. package/dist/types/methods/index.cjs +38 -0
  619. package/dist/types/methods/index.cjs.map +1 -0
  620. package/dist/types/methods/index.d.cts +22 -0
  621. package/dist/types/methods/index.d.cts.map +1 -0
  622. package/dist/types/methods/index.d.mts +22 -0
  623. package/dist/types/methods/index.d.mts.map +1 -0
  624. package/dist/types/methods/index.mjs +22 -0
  625. package/dist/types/methods/index.mjs.map +1 -0
  626. package/dist/types/methods/invoke-keyring.cjs +3 -0
  627. package/dist/types/methods/invoke-keyring.cjs.map +1 -0
  628. package/dist/types/{types/methods/invoke-keyring.d.ts → methods/invoke-keyring.d.cts} +3 -2
  629. package/dist/types/methods/invoke-keyring.d.cts.map +1 -0
  630. package/dist/types/methods/invoke-keyring.d.mts +15 -0
  631. package/dist/types/methods/invoke-keyring.d.mts.map +1 -0
  632. package/dist/types/methods/invoke-keyring.mjs +2 -0
  633. package/dist/types/methods/invoke-keyring.mjs.map +1 -0
  634. package/dist/types/methods/invoke-snap.cjs +3 -0
  635. package/dist/types/methods/invoke-snap.cjs.map +1 -0
  636. package/dist/types/{types/methods/invoke-snap.d.ts → methods/invoke-snap.d.cts} +2 -1
  637. package/dist/types/methods/invoke-snap.d.cts.map +1 -0
  638. package/dist/types/methods/invoke-snap.d.mts +17 -0
  639. package/dist/types/methods/invoke-snap.d.mts.map +1 -0
  640. package/dist/types/methods/invoke-snap.mjs +2 -0
  641. package/dist/types/methods/invoke-snap.mjs.map +1 -0
  642. package/dist/types/methods/manage-accounts.cjs +3 -0
  643. package/dist/types/methods/manage-accounts.cjs.map +1 -0
  644. package/dist/types/{types/methods/manage-accounts.d.ts → methods/manage-accounts.d.cts} +2 -1
  645. package/dist/types/methods/manage-accounts.d.cts.map +1 -0
  646. package/dist/types/methods/manage-accounts.d.mts +19 -0
  647. package/dist/types/methods/manage-accounts.d.mts.map +1 -0
  648. package/dist/types/methods/manage-accounts.mjs +2 -0
  649. package/dist/types/methods/manage-accounts.mjs.map +1 -0
  650. package/dist/types/methods/manage-state.cjs +13 -0
  651. package/dist/types/methods/manage-state.cjs.map +1 -0
  652. package/dist/types/{types/methods/manage-state.d.ts → methods/manage-state.d.cts} +3 -2
  653. package/dist/types/methods/manage-state.d.cts.map +1 -0
  654. package/dist/types/methods/manage-state.d.mts +70 -0
  655. package/dist/types/methods/manage-state.d.mts.map +1 -0
  656. package/dist/types/methods/manage-state.mjs +10 -0
  657. package/dist/types/methods/manage-state.mjs.map +1 -0
  658. package/dist/types/methods/methods.cjs +3 -0
  659. package/dist/types/methods/methods.cjs.map +1 -0
  660. package/dist/types/{types/methods/methods.d.ts → methods/methods.d.cts} +22 -21
  661. package/dist/types/methods/methods.d.cts.map +1 -0
  662. package/dist/types/methods/methods.d.mts +75 -0
  663. package/dist/types/methods/methods.d.mts.map +1 -0
  664. package/dist/types/methods/methods.mjs +2 -0
  665. package/dist/types/methods/methods.mjs.map +1 -0
  666. package/dist/types/methods/notify.cjs +15 -0
  667. package/dist/types/methods/notify.cjs.map +1 -0
  668. package/dist/types/{types/methods/notify.d.ts → methods/notify.d.cts} +2 -1
  669. package/dist/types/methods/notify.d.cts.map +1 -0
  670. package/dist/types/methods/notify.d.mts +28 -0
  671. package/dist/types/methods/notify.d.mts.map +1 -0
  672. package/dist/types/methods/notify.mjs +12 -0
  673. package/dist/types/methods/notify.mjs.map +1 -0
  674. package/dist/types/methods/request-snaps.cjs +3 -0
  675. package/dist/types/methods/request-snaps.cjs.map +1 -0
  676. package/dist/types/{types/methods/request-snaps.d.ts → methods/request-snaps.d.cts} +3 -2
  677. package/dist/types/methods/request-snaps.d.cts.map +1 -0
  678. package/dist/types/methods/request-snaps.d.mts +19 -0
  679. package/dist/types/methods/request-snaps.d.mts.map +1 -0
  680. package/dist/types/methods/request-snaps.mjs +2 -0
  681. package/dist/types/methods/request-snaps.mjs.map +1 -0
  682. package/dist/types/methods/resolve-interface.cjs +3 -0
  683. package/dist/types/methods/resolve-interface.cjs.map +1 -0
  684. package/dist/types/{types/methods/resolve-interface.d.ts → methods/resolve-interface.d.cts} +2 -1
  685. package/dist/types/methods/resolve-interface.d.cts.map +1 -0
  686. package/dist/types/methods/resolve-interface.d.mts +16 -0
  687. package/dist/types/methods/resolve-interface.d.mts.map +1 -0
  688. package/dist/types/methods/resolve-interface.mjs +2 -0
  689. package/dist/types/methods/resolve-interface.mjs.map +1 -0
  690. package/dist/types/methods/update-interface.cjs +3 -0
  691. package/dist/types/methods/update-interface.cjs.map +1 -0
  692. package/dist/types/{types/methods/update-interface.d.ts → methods/update-interface.d.cts} +2 -1
  693. package/dist/types/methods/update-interface.d.cts.map +1 -0
  694. package/dist/types/methods/update-interface.d.mts +16 -0
  695. package/dist/types/methods/update-interface.d.mts.map +1 -0
  696. package/dist/types/methods/update-interface.mjs +2 -0
  697. package/dist/types/methods/update-interface.mjs.map +1 -0
  698. package/dist/types/permissions.cjs +3 -0
  699. package/dist/types/permissions.cjs.map +1 -0
  700. package/dist/types/{types/permissions.d.ts → permissions.d.cts} +4 -3
  701. package/dist/types/permissions.d.cts.map +1 -0
  702. package/dist/types/permissions.d.mts +75 -0
  703. package/dist/types/permissions.d.mts.map +1 -0
  704. package/dist/types/permissions.mjs +2 -0
  705. package/dist/types/permissions.mjs.map +1 -0
  706. package/dist/types/provider.cjs +3 -0
  707. package/dist/types/provider.cjs.map +1 -0
  708. package/dist/types/{types/provider.d.ts → provider.d.cts} +3 -2
  709. package/dist/types/provider.d.cts.map +1 -0
  710. package/dist/types/provider.d.mts +15 -0
  711. package/dist/types/provider.d.mts.map +1 -0
  712. package/dist/types/provider.mjs +2 -0
  713. package/dist/types/provider.mjs.map +1 -0
  714. package/dist/types/snap.cjs +3 -0
  715. package/dist/types/snap.cjs.map +1 -0
  716. package/dist/types/{types/snap.d.ts → snap.d.cts} +3 -2
  717. package/dist/types/snap.d.cts.map +1 -0
  718. package/dist/types/snap.d.mts +13 -0
  719. package/dist/types/snap.d.mts.map +1 -0
  720. package/dist/types/snap.mjs +2 -0
  721. package/dist/types/snap.mjs.map +1 -0
  722. package/dist/ui/builder.cjs +49 -0
  723. package/dist/ui/builder.cjs.map +1 -0
  724. package/dist/{types/ui/builder.d.ts → ui/builder.d.cts} +4 -3
  725. package/dist/ui/builder.d.cts.map +1 -0
  726. package/dist/ui/builder.d.mts +43 -0
  727. package/dist/ui/builder.d.mts.map +1 -0
  728. package/dist/ui/builder.mjs +45 -0
  729. package/dist/ui/builder.mjs.map +1 -0
  730. package/dist/ui/component.cjs +29 -0
  731. package/dist/ui/component.cjs.map +1 -0
  732. package/dist/{types/ui/component.d.ts → ui/component.d.cts} +2 -1
  733. package/dist/ui/component.d.cts.map +1 -0
  734. package/dist/ui/component.d.mts +18 -0
  735. package/dist/ui/component.d.mts.map +1 -0
  736. package/dist/ui/component.mjs +24 -0
  737. package/dist/ui/component.mjs.map +1 -0
  738. package/dist/ui/components/address.cjs +28 -0
  739. package/dist/ui/components/address.cjs.map +1 -0
  740. package/dist/{types/ui/components/address.d.ts → ui/components/address.d.cts} +6 -5
  741. package/dist/ui/components/address.d.cts.map +1 -0
  742. package/dist/ui/components/address.d.mts +37 -0
  743. package/dist/ui/components/address.d.mts.map +1 -0
  744. package/dist/ui/components/address.mjs +25 -0
  745. package/dist/ui/components/address.mjs.map +1 -0
  746. package/dist/ui/components/button.cjs +52 -0
  747. package/dist/ui/components/button.cjs.map +1 -0
  748. package/dist/{types/ui/components/button.d.ts → ui/components/button.d.cts} +9 -8
  749. package/dist/ui/components/button.d.cts.map +1 -0
  750. package/dist/ui/components/button.d.mts +65 -0
  751. package/dist/ui/components/button.d.mts.map +1 -0
  752. package/dist/ui/components/button.mjs +49 -0
  753. package/dist/ui/components/button.mjs.map +1 -0
  754. package/dist/ui/components/copyable.cjs +32 -0
  755. package/dist/ui/components/copyable.cjs.map +1 -0
  756. package/dist/{types/ui/components/copyable.d.ts → ui/components/copyable.d.cts} +6 -5
  757. package/dist/ui/components/copyable.d.cts.map +1 -0
  758. package/dist/ui/components/copyable.d.mts +49 -0
  759. package/dist/ui/components/copyable.d.mts.map +1 -0
  760. package/dist/ui/components/copyable.mjs +29 -0
  761. package/dist/ui/components/copyable.mjs.map +1 -0
  762. package/dist/ui/components/divider.cjs +20 -0
  763. package/dist/ui/components/divider.cjs.map +1 -0
  764. package/dist/{types/ui/components/divider.d.ts → ui/components/divider.d.cts} +3 -2
  765. package/dist/ui/components/divider.d.cts.map +1 -0
  766. package/dist/ui/components/divider.d.mts +24 -0
  767. package/dist/ui/components/divider.d.mts.map +1 -0
  768. package/dist/ui/components/divider.mjs +17 -0
  769. package/dist/ui/components/divider.mjs.map +1 -0
  770. package/dist/ui/components/form.cjs +41 -0
  771. package/dist/ui/components/form.cjs.map +1 -0
  772. package/dist/{types/ui/components/form.d.ts → ui/components/form.d.cts} +31 -30
  773. package/dist/ui/components/form.d.cts.map +1 -0
  774. package/dist/ui/components/form.d.mts +154 -0
  775. package/dist/ui/components/form.d.mts.map +1 -0
  776. package/dist/ui/components/form.mjs +38 -0
  777. package/dist/ui/components/form.mjs.map +1 -0
  778. package/dist/ui/components/heading.cjs +27 -0
  779. package/dist/ui/components/heading.cjs.map +1 -0
  780. package/dist/{types/ui/components/heading.d.ts → ui/components/heading.d.cts} +6 -5
  781. package/dist/ui/components/heading.d.cts.map +1 -0
  782. package/dist/ui/components/heading.d.mts +39 -0
  783. package/dist/ui/components/heading.d.mts.map +1 -0
  784. package/dist/ui/components/heading.mjs +24 -0
  785. package/dist/ui/components/heading.mjs.map +1 -0
  786. package/dist/ui/components/image.cjs +27 -0
  787. package/dist/ui/components/image.cjs.map +1 -0
  788. package/dist/{types/ui/components/image.d.ts → ui/components/image.d.cts} +6 -5
  789. package/dist/ui/components/image.d.cts.map +1 -0
  790. package/dist/ui/components/image.d.mts +38 -0
  791. package/dist/ui/components/image.d.mts.map +1 -0
  792. package/dist/ui/components/image.mjs +24 -0
  793. package/dist/ui/components/image.mjs.map +1 -0
  794. package/dist/ui/components/index.cjs +35 -0
  795. package/dist/ui/components/index.cjs.map +1 -0
  796. package/dist/ui/components/index.d.cts +15 -0
  797. package/dist/ui/components/index.d.cts.map +1 -0
  798. package/dist/ui/components/index.d.mts +15 -0
  799. package/dist/ui/components/index.d.mts.map +1 -0
  800. package/dist/ui/components/index.mjs +13 -0
  801. package/dist/ui/components/index.mjs.map +1 -0
  802. package/dist/ui/components/input.cjs +60 -0
  803. package/dist/ui/components/input.cjs.map +1 -0
  804. package/dist/{types/ui/components/input.d.ts → ui/components/input.d.cts} +9 -8
  805. package/dist/ui/components/input.d.cts.map +1 -0
  806. package/dist/ui/components/input.d.mts +78 -0
  807. package/dist/ui/components/input.d.mts.map +1 -0
  808. package/dist/ui/components/input.mjs +57 -0
  809. package/dist/ui/components/input.mjs.map +1 -0
  810. package/dist/ui/components/panel.cjs +72 -0
  811. package/dist/ui/components/panel.cjs.map +1 -0
  812. package/dist/{types/ui/components/panel.d.ts → ui/components/panel.d.cts} +88 -87
  813. package/dist/ui/components/panel.d.cts.map +1 -0
  814. package/dist/ui/components/panel.d.mts +406 -0
  815. package/dist/ui/components/panel.d.mts.map +1 -0
  816. package/dist/ui/components/panel.mjs +69 -0
  817. package/dist/ui/components/panel.mjs.map +1 -0
  818. package/dist/ui/components/row.cjs +51 -0
  819. package/dist/ui/components/row.cjs.map +1 -0
  820. package/dist/{types/ui/components/row.d.ts → ui/components/row.d.cts} +21 -20
  821. package/dist/ui/components/row.d.cts.map +1 -0
  822. package/dist/ui/components/row.d.mts +107 -0
  823. package/dist/ui/components/row.d.mts.map +1 -0
  824. package/dist/ui/components/row.mjs +48 -0
  825. package/dist/ui/components/row.mjs.map +1 -0
  826. package/dist/ui/components/spinner.cjs +20 -0
  827. package/dist/ui/components/spinner.cjs.map +1 -0
  828. package/dist/{types/ui/components/spinner.d.ts → ui/components/spinner.d.cts} +3 -2
  829. package/dist/ui/components/spinner.d.cts.map +1 -0
  830. package/dist/ui/components/spinner.d.mts +25 -0
  831. package/dist/ui/components/spinner.d.mts.map +1 -0
  832. package/dist/ui/components/spinner.mjs +17 -0
  833. package/dist/ui/components/spinner.mjs.map +1 -0
  834. package/dist/ui/components/text.cjs +34 -0
  835. package/dist/ui/components/text.cjs.map +1 -0
  836. package/dist/{types/ui/components/text.d.ts → ui/components/text.d.cts} +6 -5
  837. package/dist/ui/components/text.d.cts.map +1 -0
  838. package/dist/ui/components/text.d.mts +49 -0
  839. package/dist/ui/components/text.d.mts.map +1 -0
  840. package/dist/ui/components/text.mjs +31 -0
  841. package/dist/ui/components/text.mjs.map +1 -0
  842. package/dist/ui/index.cjs +22 -0
  843. package/dist/ui/index.cjs.map +1 -0
  844. package/dist/ui/index.d.cts +4 -0
  845. package/dist/ui/index.d.cts.map +1 -0
  846. package/dist/ui/index.d.mts +4 -0
  847. package/dist/ui/index.d.mts.map +1 -0
  848. package/dist/ui/index.mjs +4 -0
  849. package/dist/ui/index.mjs.map +1 -0
  850. package/dist/ui/nodes.cjs +38 -0
  851. package/dist/ui/nodes.cjs.map +1 -0
  852. package/dist/{types/ui/nodes.d.ts → ui/nodes.d.cts} +3 -2
  853. package/dist/ui/nodes.d.cts.map +1 -0
  854. package/dist/ui/nodes.d.mts +57 -0
  855. package/dist/ui/nodes.d.mts.map +1 -0
  856. package/dist/ui/nodes.mjs +35 -0
  857. package/dist/ui/nodes.mjs.map +1 -0
  858. package/jsx-dev-runtime.d.ts +3 -1
  859. package/jsx-dev-runtime.js +1 -1
  860. package/jsx-runtime.d.ts +3 -1
  861. package/jsx-runtime.js +1 -1
  862. package/jsx.d.ts +3 -1
  863. package/jsx.js +1 -1
  864. package/package.json +42 -27
  865. package/dist/index.js +0 -1370
  866. package/dist/index.js.map +0 -1
  867. package/dist/jsx/index.js +0 -810
  868. package/dist/jsx/index.js.map +0 -1
  869. package/dist/jsx/jsx-dev-runtime.js +0 -644
  870. package/dist/jsx/jsx-dev-runtime.js.map +0 -1
  871. package/dist/jsx/jsx-runtime.js +0 -45
  872. package/dist/jsx/jsx-runtime.js.map +0 -1
  873. package/dist/tsconfig.build.tsbuildinfo +0 -1
  874. package/dist/types/index.d.ts +0 -9
  875. package/dist/types/internals/index.d.ts +0 -6
  876. package/dist/types/jsx/components/Address.d.ts +0 -28
  877. package/dist/types/jsx/components/form/index.d.ts +0 -25
  878. package/dist/types/jsx/components/formatting/index.d.ts +0 -5
  879. package/dist/types/jsx/components/index.d.ts +0 -40
  880. package/dist/types/jsx/index.d.ts +0 -5
  881. package/dist/types/types/handlers/index.d.ts +0 -9
  882. package/dist/types/types/index.d.ts +0 -9
  883. package/dist/types/types/methods/index.d.ts +0 -21
  884. package/dist/types/ui/components/index.d.ts +0 -14
  885. package/dist/types/ui/index.d.ts +0 -3
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selectiveUnion = exports.typedUnion = exports.enumValue = exports.union = exports.literal = void 0;
4
+ const superstruct_1 = require("@metamask/superstruct");
5
+ const utils_1 = require("@metamask/utils");
6
+ /**
7
+ * A wrapper of `superstruct`'s `literal` struct that also defines the name of
8
+ * the struct as the literal value.
9
+ *
10
+ * This is useful for improving the error messages returned by `superstruct`.
11
+ * For example, instead of returning an error like:
12
+ *
13
+ * ```
14
+ * Expected the value to satisfy a union of `literal | literal`, but received: \"baz\"
15
+ * ```
16
+ *
17
+ * This struct will return an error like:
18
+ *
19
+ * ```
20
+ * Expected the value to satisfy a union of `"foo" | "bar"`, but received: \"baz\"
21
+ * ```
22
+ *
23
+ * @param value - The literal value.
24
+ * @returns The `superstruct` struct, which validates that the value is equal
25
+ * to the literal value.
26
+ */
27
+ function literal(value) {
28
+ return (0, superstruct_1.define)(JSON.stringify(value), (0, superstruct_1.literal)(value).validator);
29
+ }
30
+ exports.literal = literal;
31
+ /**
32
+ * A wrapper of `superstruct`'s `union` struct that also defines the schema as
33
+ * the union of the schemas of the structs.
34
+ *
35
+ * This is useful for improving the error messages returned by `superstruct`.
36
+ *
37
+ * @param structs - The structs to union.
38
+ * @param structs."0" - The first struct.
39
+ * @param structs."1" - The remaining structs.
40
+ * @returns The `superstruct` struct, which validates that the value satisfies
41
+ * one of the structs.
42
+ */
43
+ function union([head, ...tail]) {
44
+ const struct = (0, superstruct_1.union)([head, ...tail]);
45
+ return new superstruct_1.Struct({
46
+ ...struct,
47
+ schema: [head, ...tail],
48
+ });
49
+ }
50
+ exports.union = union;
51
+ /**
52
+ * Superstruct struct for validating an enum value. This allows using both the
53
+ * enum string values and the enum itself as values.
54
+ *
55
+ * @param constant - The enum to validate against.
56
+ * @returns The superstruct struct.
57
+ */
58
+ function enumValue(constant) {
59
+ return literal(constant);
60
+ }
61
+ exports.enumValue = enumValue;
62
+ /**
63
+ * Create a custom union struct that validates exclusively based on a `type` field.
64
+ *
65
+ * This should improve error messaging for unions with many structs in them.
66
+ *
67
+ * @param structs - The structs to union.
68
+ * @returns The `superstruct` struct, which validates that the value satisfies
69
+ * one of the structs.
70
+ */
71
+ function typedUnion(structs) {
72
+ const flatStructs = structs
73
+ .map((struct) => struct.type === 'union' && Array.isArray(struct.schema)
74
+ ? struct.schema
75
+ : struct)
76
+ .flat(Infinity);
77
+ const types = flatStructs.map(({ schema }) => schema.type.type);
78
+ return new superstruct_1.Struct({
79
+ type: 'union',
80
+ schema: flatStructs,
81
+ *entries(value, context) {
82
+ if (!(0, utils_1.isPlainObject)(value) || !(0, utils_1.hasProperty)(value, 'type')) {
83
+ return;
84
+ }
85
+ const { type } = value;
86
+ const struct = flatStructs.find(({ schema }) => (0, superstruct_1.is)(type, schema.type));
87
+ if (!struct) {
88
+ return;
89
+ }
90
+ for (const entry of struct.entries(value, context)) {
91
+ yield entry;
92
+ }
93
+ },
94
+ coercer(value, context) {
95
+ if (!(0, utils_1.isPlainObject)(value) || !(0, utils_1.hasProperty)(value, 'type')) {
96
+ return value;
97
+ }
98
+ const { type } = value;
99
+ const struct = flatStructs.find(({ schema }) => (0, superstruct_1.is)(type, schema.type));
100
+ if (struct) {
101
+ return struct.coercer(value, context);
102
+ }
103
+ return value;
104
+ },
105
+ // At this point we know the value to be an object.
106
+ *refiner(value, context) {
107
+ const struct = flatStructs.find(({ schema }) => (0, superstruct_1.is)(value.type, schema.type));
108
+ yield* struct.refiner(value, context);
109
+ },
110
+ validator(value, context) {
111
+ if (!(0, utils_1.isPlainObject)(value) ||
112
+ !(0, utils_1.hasProperty)(value, 'type') ||
113
+ typeof value.type !== 'string') {
114
+ return `Expected type to be one of: ${types.join(', ')}, but received: undefined`;
115
+ }
116
+ const { type } = value;
117
+ const struct = flatStructs.find(({ schema }) => (0, superstruct_1.is)(type, schema.type));
118
+ if (struct) {
119
+ // This only validates the root of the struct, entries does the rest of the work.
120
+ return struct.validator(value, context);
121
+ }
122
+ return `Expected type to be one of: ${types.join(', ')}, but received: "${type}"`;
123
+ },
124
+ });
125
+ }
126
+ exports.typedUnion = typedUnion;
127
+ /**
128
+ * Create a custom union struct that uses a `selector` function for choosing
129
+ * the validation path.
130
+ *
131
+ * @param selector - The selector function choosing the struct to validate with.
132
+ * @returns The `superstruct` struct, which validates that the value satisfies
133
+ * one of the structs.
134
+ */
135
+ function selectiveUnion(selector) {
136
+ return new superstruct_1.Struct({
137
+ type: 'union',
138
+ schema: null,
139
+ *entries(value, context) {
140
+ const struct = selector(value);
141
+ for (const entry of struct.entries(value, context)) {
142
+ yield entry;
143
+ }
144
+ },
145
+ *refiner(value, context) {
146
+ const struct = selector(value);
147
+ yield* struct.refiner(value, context);
148
+ },
149
+ coercer(value, context) {
150
+ const struct = selector(value);
151
+ return struct.coercer(value, context);
152
+ },
153
+ validator(value, context) {
154
+ const struct = selector(value);
155
+ // This only validates the root of the struct, entries does the rest of the work.
156
+ return struct.validator(value, context);
157
+ },
158
+ });
159
+ }
160
+ exports.selectiveUnion = selectiveUnion;
161
+ //# sourceMappingURL=structs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structs.cjs","sourceRoot":"","sources":["../../src/internals/structs.ts"],"names":[],"mappings":";;;AACA,uDAM+B;AAE/B,2CAA6D;AAI7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,OAAO,CAAyC,KAAW;IACzE,OAAO,IAAA,oBAAM,EACX,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EACrB,IAAA,qBAAkB,EAAC,KAAK,CAAC,CAAC,SAAS,CACpC,CAAC;AACJ,CAAC;AALD,0BAKC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,KAAK,CAAmD,CACtE,IAAI,EACJ,GAAG,IAAI,CACqB;IAI5B,MAAM,MAAM,GAAG,IAAA,mBAAgB,EAAC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IAEjD,OAAO,IAAI,oBAAM,CAAC;QAChB,GAAG,MAAM;QACT,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;KACxB,CAAC,CAAC;AACL,CAAC;AAbD,sBAaC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CACvB,QAAc;IAEd,OAAO,OAAO,CAAC,QAA6B,CAAC,CAAC;AAChD,CAAC;AAJD,8BAIC;AAED;;;;;;;;GAQG;AACH,SAAgB,UAAU,CACxB,OAAoC;IAEpC,MAAM,WAAW,GAAG,OAAO;SACxB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACd,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QACrD,CAAC,CAAC,MAAM,CAAC,MAAM;QACf,CAAC,CAAC,MAAM,CAC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H,SAAgB,cAAc,CAC5B,QAAkB;IAElB,OAAO,IAAI,oBAAM,CAAC;QAChB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,IAAI;QACZ,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO;YACrB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;YAE/B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;gBACnD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO;YACrB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;YAE/B,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,OAAO;YACpB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;YAE/B,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,OAAO;YACtB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;YAE/B,iFAAiF;YACjF,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AA9BD,wCA8BC","sourcesContent":["import type { AnyStruct, Infer, InferStructTuple } from '@metamask/superstruct';\nimport {\n Struct,\n define,\n is,\n literal as superstructLiteral,\n union as superstructUnion,\n} from '@metamask/superstruct';\nimport type { PlainObject } from '@metamask/utils';\nimport { hasProperty, isPlainObject } from '@metamask/utils';\n\nimport type { EnumToUnion } from './helpers';\n\n/**\n * A wrapper of `superstruct`'s `literal` struct that also defines the name of\n * the struct as the literal value.\n *\n * This is useful for improving the error messages returned by `superstruct`.\n * For example, instead of returning an error like:\n *\n * ```\n * Expected the value to satisfy a union of `literal | literal`, but received: \\\"baz\\\"\n * ```\n *\n * This struct will return an error like:\n *\n * ```\n * Expected the value to satisfy a union of `\"foo\" | \"bar\"`, but received: \\\"baz\\\"\n * ```\n *\n * @param value - The literal value.\n * @returns The `superstruct` struct, which validates that the value is equal\n * to the literal value.\n */\nexport function literal<Type extends string | number | boolean>(value: Type) {\n return define<Type>(\n JSON.stringify(value),\n superstructLiteral(value).validator,\n );\n}\n\n/**\n * A wrapper of `superstruct`'s `union` struct that also defines the schema as\n * the union of the schemas of the structs.\n *\n * This is useful for improving the error messages returned by `superstruct`.\n *\n * @param structs - The structs to union.\n * @param structs.\"0\" - The first struct.\n * @param structs.\"1\" - The remaining structs.\n * @returns The `superstruct` struct, which validates that the value satisfies\n * one of the structs.\n */\nexport function union<Head extends AnyStruct, Tail extends AnyStruct[]>([\n head,\n ...tail\n]: [head: Head, ...tail: Tail]): Struct<\n Infer<Head> | InferStructTuple<Tail>[number],\n [head: Head, ...tail: Tail]\n> {\n const struct = superstructUnion([head, ...tail]);\n\n return new Struct({\n ...struct,\n schema: [head, ...tail],\n });\n}\n\n/**\n * Superstruct struct for validating an enum value. This allows using both the\n * enum string values and the enum itself as values.\n *\n * @param constant - The enum to validate against.\n * @returns The superstruct struct.\n */\nexport function enumValue<Type extends string>(\n constant: Type,\n): Struct<EnumToUnion<Type>, null> {\n return literal(constant as EnumToUnion<Type>);\n}\n\n/**\n * Create a custom union struct that validates exclusively based on a `type` field.\n *\n * This should improve error messaging for unions with many structs in them.\n *\n * @param structs - The structs to union.\n * @returns The `superstruct` struct, which validates that the value satisfies\n * one of the structs.\n */\nexport function typedUnion<Head extends AnyStruct, Tail extends AnyStruct[]>(\n structs: [head: Head, ...tail: Tail],\n): Struct<Infer<Head> | InferStructTuple<Tail>[number], null> {\n const flatStructs = structs\n .map((struct) =>\n struct.type === 'union' && Array.isArray(struct.schema)\n ? struct.schema\n : struct,\n )\n .flat(Infinity);\n const types = flatStructs.map(({ schema }) => schema.type.type);\n return new Struct({\n type: 'union',\n schema: flatStructs,\n *entries(value, context) {\n if (!isPlainObject(value) || !hasProperty(value, 'type')) {\n return;\n }\n\n const { type } = value;\n const struct = flatStructs.find(({ schema }) => is(type, schema.type));\n\n if (!struct) {\n return;\n }\n\n for (const entry of struct.entries(value, context)) {\n yield entry;\n }\n },\n coercer(value, context) {\n if (!isPlainObject(value) || !hasProperty(value, 'type')) {\n return value;\n }\n\n const { type } = value;\n const struct = flatStructs.find(({ schema }) => is(type, schema.type));\n if (struct) {\n return struct.coercer(value, context);\n }\n\n return value;\n },\n // At this point we know the value to be an object.\n *refiner(value: PlainObject, context) {\n const struct = flatStructs.find(({ schema }) =>\n is(value.type, schema.type),\n );\n\n yield* struct.refiner(value, context);\n },\n validator(value, context) {\n if (\n !isPlainObject(value) ||\n !hasProperty(value, 'type') ||\n typeof value.type !== 'string'\n ) {\n return `Expected type to be one of: ${types.join(\n ', ',\n )}, but received: undefined`;\n }\n\n const { type } = value;\n\n const struct = flatStructs.find(({ schema }) => is(type, schema.type));\n\n if (struct) {\n // This only validates the root of the struct, entries does the rest of the work.\n return struct.validator(value, context);\n }\n\n return `Expected type to be one of: ${types.join(\n ', ',\n )}, but received: \"${type}\"`;\n },\n }) as unknown as Struct<Infer<Head> | InferStructTuple<Tail>[number], null>;\n}\n\n/**\n * Create a custom union struct that uses a `selector` function for choosing\n * the validation path.\n *\n * @param selector - The selector function choosing the struct to validate with.\n * @returns The `superstruct` struct, which validates that the value satisfies\n * one of the structs.\n */\nexport function selectiveUnion<Selector extends (value: any) => AnyStruct>(\n selector: Selector,\n): Struct<Infer<ReturnType<Selector>>, null> {\n return new Struct({\n type: 'union',\n schema: null,\n *entries(value, context) {\n const struct = selector(value);\n\n for (const entry of struct.entries(value, context)) {\n yield entry;\n }\n },\n *refiner(value, context) {\n const struct = selector(value);\n\n yield* struct.refiner(value, context);\n },\n coercer(value, context) {\n const struct = selector(value);\n\n return struct.coercer(value, context);\n },\n validator(value, context) {\n const struct = selector(value);\n\n // This only validates the root of the struct, entries does the rest of the work.\n return struct.validator(value, context);\n },\n });\n}\n"]}
@@ -1,6 +1,6 @@
1
- import type { AnyStruct, Infer, InferStructTuple } from '@metamask/superstruct';
2
- import { Struct } from '@metamask/superstruct';
3
- import type { EnumToUnion } from './helpers';
1
+ import type { AnyStruct, Infer, InferStructTuple } from "@metamask/superstruct";
2
+ import { Struct } from "@metamask/superstruct";
3
+ import type { EnumToUnion } from "./helpers.cjs";
4
4
  /**
5
5
  * A wrapper of `superstruct`'s `literal` struct that also defines the name of
6
6
  * the struct as the literal value.
@@ -57,3 +57,13 @@ export declare function enumValue<Type extends string>(constant: Type): Struct<E
57
57
  * one of the structs.
58
58
  */
59
59
  export declare function typedUnion<Head extends AnyStruct, Tail extends AnyStruct[]>(structs: [head: Head, ...tail: Tail]): Struct<Infer<Head> | InferStructTuple<Tail>[number], null>;
60
+ /**
61
+ * Create a custom union struct that uses a `selector` function for choosing
62
+ * the validation path.
63
+ *
64
+ * @param selector - The selector function choosing the struct to validate with.
65
+ * @returns The `superstruct` struct, which validates that the value satisfies
66
+ * one of the structs.
67
+ */
68
+ export declare function selectiveUnion<Selector extends (value: any) => AnyStruct>(selector: Selector): Struct<Infer<ReturnType<Selector>>, null>;
69
+ //# sourceMappingURL=structs.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structs.d.cts","sourceRoot":"","sources":["../../src/internals/structs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,8BAA8B;AAChF,OAAO,EACL,MAAM,EAKP,8BAA8B;AAI/B,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAkB;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,sBAK1E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,IAAI,SAAS,SAAS,EAAE,IAAI,SAAS,SAAS,EAAE,EAAE,CACtE,IAAI,EACJ,GAAG,IAAI,CACR,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CACrC,KAAK,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAC5C;IAAC,IAAI,EAAE,IAAI;IAAE,GAAG,IAAI,EAAE,IAAI;CAAC,CAC5B,CAOA;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,SAAS,MAAM,EAC3C,QAAQ,EAAE,IAAI,GACb,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAEjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,SAAS,EAAE,IAAI,SAAS,SAAS,EAAE,EACzE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,CAAC,GACnC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CA0E5D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,SAAS,CAAC,KAAK,EAAE,GAAG,KAAK,SAAS,EACvE,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CA4B3C"}
@@ -0,0 +1,69 @@
1
+ import type { AnyStruct, Infer, InferStructTuple } from "@metamask/superstruct";
2
+ import { Struct } from "@metamask/superstruct";
3
+ import type { EnumToUnion } from "./helpers.mjs";
4
+ /**
5
+ * A wrapper of `superstruct`'s `literal` struct that also defines the name of
6
+ * the struct as the literal value.
7
+ *
8
+ * This is useful for improving the error messages returned by `superstruct`.
9
+ * For example, instead of returning an error like:
10
+ *
11
+ * ```
12
+ * Expected the value to satisfy a union of `literal | literal`, but received: \"baz\"
13
+ * ```
14
+ *
15
+ * This struct will return an error like:
16
+ *
17
+ * ```
18
+ * Expected the value to satisfy a union of `"foo" | "bar"`, but received: \"baz\"
19
+ * ```
20
+ *
21
+ * @param value - The literal value.
22
+ * @returns The `superstruct` struct, which validates that the value is equal
23
+ * to the literal value.
24
+ */
25
+ export declare function literal<Type extends string | number | boolean>(value: Type): Struct<Type, null>;
26
+ /**
27
+ * A wrapper of `superstruct`'s `union` struct that also defines the schema as
28
+ * the union of the schemas of the structs.
29
+ *
30
+ * This is useful for improving the error messages returned by `superstruct`.
31
+ *
32
+ * @param structs - The structs to union.
33
+ * @param structs."0" - The first struct.
34
+ * @param structs."1" - The remaining structs.
35
+ * @returns The `superstruct` struct, which validates that the value satisfies
36
+ * one of the structs.
37
+ */
38
+ export declare function union<Head extends AnyStruct, Tail extends AnyStruct[]>([head, ...tail]: [head: Head, ...tail: Tail]): Struct<Infer<Head> | InferStructTuple<Tail>[number], [
39
+ head: Head,
40
+ ...tail: Tail
41
+ ]>;
42
+ /**
43
+ * Superstruct struct for validating an enum value. This allows using both the
44
+ * enum string values and the enum itself as values.
45
+ *
46
+ * @param constant - The enum to validate against.
47
+ * @returns The superstruct struct.
48
+ */
49
+ export declare function enumValue<Type extends string>(constant: Type): Struct<EnumToUnion<Type>, null>;
50
+ /**
51
+ * Create a custom union struct that validates exclusively based on a `type` field.
52
+ *
53
+ * This should improve error messaging for unions with many structs in them.
54
+ *
55
+ * @param structs - The structs to union.
56
+ * @returns The `superstruct` struct, which validates that the value satisfies
57
+ * one of the structs.
58
+ */
59
+ export declare function typedUnion<Head extends AnyStruct, Tail extends AnyStruct[]>(structs: [head: Head, ...tail: Tail]): Struct<Infer<Head> | InferStructTuple<Tail>[number], null>;
60
+ /**
61
+ * Create a custom union struct that uses a `selector` function for choosing
62
+ * the validation path.
63
+ *
64
+ * @param selector - The selector function choosing the struct to validate with.
65
+ * @returns The `superstruct` struct, which validates that the value satisfies
66
+ * one of the structs.
67
+ */
68
+ export declare function selectiveUnion<Selector extends (value: any) => AnyStruct>(selector: Selector): Struct<Infer<ReturnType<Selector>>, null>;
69
+ //# sourceMappingURL=structs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structs.d.mts","sourceRoot":"","sources":["../../src/internals/structs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,8BAA8B;AAChF,OAAO,EACL,MAAM,EAKP,8BAA8B;AAI/B,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAkB;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,sBAK1E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,IAAI,SAAS,SAAS,EAAE,IAAI,SAAS,SAAS,EAAE,EAAE,CACtE,IAAI,EACJ,GAAG,IAAI,CACR,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CACrC,KAAK,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAC5C;IAAC,IAAI,EAAE,IAAI;IAAE,GAAG,IAAI,EAAE,IAAI;CAAC,CAC5B,CAOA;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,SAAS,MAAM,EAC3C,QAAQ,EAAE,IAAI,GACb,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAEjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,SAAS,EAAE,IAAI,SAAS,SAAS,EAAE,EACzE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,CAAC,GACnC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CA0E5D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,SAAS,CAAC,KAAK,EAAE,GAAG,KAAK,SAAS,EACvE,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CA4B3C"}
@@ -0,0 +1,153 @@
1
+ import { Struct, define, is, literal as superstructLiteral, union as superstructUnion } from "@metamask/superstruct";
2
+ import { hasProperty, isPlainObject } from "@metamask/utils";
3
+ /**
4
+ * A wrapper of `superstruct`'s `literal` struct that also defines the name of
5
+ * the struct as the literal value.
6
+ *
7
+ * This is useful for improving the error messages returned by `superstruct`.
8
+ * For example, instead of returning an error like:
9
+ *
10
+ * ```
11
+ * Expected the value to satisfy a union of `literal | literal`, but received: \"baz\"
12
+ * ```
13
+ *
14
+ * This struct will return an error like:
15
+ *
16
+ * ```
17
+ * Expected the value to satisfy a union of `"foo" | "bar"`, but received: \"baz\"
18
+ * ```
19
+ *
20
+ * @param value - The literal value.
21
+ * @returns The `superstruct` struct, which validates that the value is equal
22
+ * to the literal value.
23
+ */
24
+ export function literal(value) {
25
+ return define(JSON.stringify(value), superstructLiteral(value).validator);
26
+ }
27
+ /**
28
+ * A wrapper of `superstruct`'s `union` struct that also defines the schema as
29
+ * the union of the schemas of the structs.
30
+ *
31
+ * This is useful for improving the error messages returned by `superstruct`.
32
+ *
33
+ * @param structs - The structs to union.
34
+ * @param structs."0" - The first struct.
35
+ * @param structs."1" - The remaining structs.
36
+ * @returns The `superstruct` struct, which validates that the value satisfies
37
+ * one of the structs.
38
+ */
39
+ export function union([head, ...tail]) {
40
+ const struct = superstructUnion([head, ...tail]);
41
+ return new Struct({
42
+ ...struct,
43
+ schema: [head, ...tail],
44
+ });
45
+ }
46
+ /**
47
+ * Superstruct struct for validating an enum value. This allows using both the
48
+ * enum string values and the enum itself as values.
49
+ *
50
+ * @param constant - The enum to validate against.
51
+ * @returns The superstruct struct.
52
+ */
53
+ export function enumValue(constant) {
54
+ return literal(constant);
55
+ }
56
+ /**
57
+ * Create a custom union struct that validates exclusively based on a `type` field.
58
+ *
59
+ * This should improve error messaging for unions with many structs in them.
60
+ *
61
+ * @param structs - The structs to union.
62
+ * @returns The `superstruct` struct, which validates that the value satisfies
63
+ * one of the structs.
64
+ */
65
+ export function typedUnion(structs) {
66
+ const flatStructs = structs
67
+ .map((struct) => struct.type === 'union' && Array.isArray(struct.schema)
68
+ ? struct.schema
69
+ : struct)
70
+ .flat(Infinity);
71
+ const types = flatStructs.map(({ schema }) => schema.type.type);
72
+ return new Struct({
73
+ type: 'union',
74
+ schema: flatStructs,
75
+ *entries(value, context) {
76
+ if (!isPlainObject(value) || !hasProperty(value, 'type')) {
77
+ return;
78
+ }
79
+ const { type } = value;
80
+ const struct = flatStructs.find(({ schema }) => is(type, schema.type));
81
+ if (!struct) {
82
+ return;
83
+ }
84
+ for (const entry of struct.entries(value, context)) {
85
+ yield entry;
86
+ }
87
+ },
88
+ coercer(value, context) {
89
+ if (!isPlainObject(value) || !hasProperty(value, 'type')) {
90
+ return value;
91
+ }
92
+ const { type } = value;
93
+ const struct = flatStructs.find(({ schema }) => is(type, schema.type));
94
+ if (struct) {
95
+ return struct.coercer(value, context);
96
+ }
97
+ return value;
98
+ },
99
+ // At this point we know the value to be an object.
100
+ *refiner(value, context) {
101
+ const struct = flatStructs.find(({ schema }) => is(value.type, schema.type));
102
+ yield* struct.refiner(value, context);
103
+ },
104
+ validator(value, context) {
105
+ if (!isPlainObject(value) ||
106
+ !hasProperty(value, 'type') ||
107
+ typeof value.type !== 'string') {
108
+ return `Expected type to be one of: ${types.join(', ')}, but received: undefined`;
109
+ }
110
+ const { type } = value;
111
+ const struct = flatStructs.find(({ schema }) => is(type, schema.type));
112
+ if (struct) {
113
+ // This only validates the root of the struct, entries does the rest of the work.
114
+ return struct.validator(value, context);
115
+ }
116
+ return `Expected type to be one of: ${types.join(', ')}, but received: "${type}"`;
117
+ },
118
+ });
119
+ }
120
+ /**
121
+ * Create a custom union struct that uses a `selector` function for choosing
122
+ * the validation path.
123
+ *
124
+ * @param selector - The selector function choosing the struct to validate with.
125
+ * @returns The `superstruct` struct, which validates that the value satisfies
126
+ * one of the structs.
127
+ */
128
+ export function selectiveUnion(selector) {
129
+ return new Struct({
130
+ type: 'union',
131
+ schema: null,
132
+ *entries(value, context) {
133
+ const struct = selector(value);
134
+ for (const entry of struct.entries(value, context)) {
135
+ yield entry;
136
+ }
137
+ },
138
+ *refiner(value, context) {
139
+ const struct = selector(value);
140
+ yield* struct.refiner(value, context);
141
+ },
142
+ coercer(value, context) {
143
+ const struct = selector(value);
144
+ return struct.coercer(value, context);
145
+ },
146
+ validator(value, context) {
147
+ const struct = selector(value);
148
+ // This only validates the root of the struct, entries does the rest of the work.
149
+ return struct.validator(value, context);
150
+ },
151
+ });
152
+ }
153
+ //# sourceMappingURL=structs.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structs.mjs","sourceRoot":"","sources":["../../src/internals/structs.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,MAAM,EACN,EAAE,EACF,OAAO,IAAI,kBAAkB,EAC7B,KAAK,IAAI,gBAAgB,EAC1B,8BAA8B;AAE/B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,wBAAwB;AAI7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,OAAO,CAAyC,KAAW;IACzE,OAAO,MAAM,CACX,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EACrB,kBAAkB,CAAC,KAAK,CAAC,CAAC,SAAS,CACpC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,K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,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,OAAO;YACtB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;YAE/B,iFAAiF;YACjF,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { AnyStruct, Infer, InferStructTuple } from '@metamask/superstruct';\nimport {\n Struct,\n define,\n is,\n literal as superstructLiteral,\n union as superstructUnion,\n} from '@metamask/superstruct';\nimport type { PlainObject } from '@metamask/utils';\nimport { hasProperty, isPlainObject } from '@metamask/utils';\n\nimport type { EnumToUnion } from './helpers';\n\n/**\n * A wrapper of `superstruct`'s `literal` struct that also defines the name of\n * the struct as the literal value.\n *\n * This is useful for improving the error messages returned by `superstruct`.\n * For example, instead of returning an error like:\n *\n * ```\n * Expected the value to satisfy a union of `literal | literal`, but received: \\\"baz\\\"\n * ```\n *\n * This struct will return an error like:\n *\n * ```\n * Expected the value to satisfy a union of `\"foo\" | \"bar\"`, but received: \\\"baz\\\"\n * ```\n *\n * @param value - The literal value.\n * @returns The `superstruct` struct, which validates that the value is equal\n * to the literal value.\n */\nexport function literal<Type extends string | number | boolean>(value: Type) {\n return define<Type>(\n JSON.stringify(value),\n superstructLiteral(value).validator,\n );\n}\n\n/**\n * A wrapper of `superstruct`'s `union` struct that also defines the schema as\n * the union of the schemas of the structs.\n *\n * This is useful for improving the error messages returned by `superstruct`.\n *\n * @param structs - The structs to union.\n * @param structs.\"0\" - The first struct.\n * @param structs.\"1\" - The remaining structs.\n * @returns The `superstruct` struct, which validates that the value satisfies\n * one of the structs.\n */\nexport function union<Head extends AnyStruct, Tail extends AnyStruct[]>([\n head,\n ...tail\n]: [head: Head, ...tail: Tail]): Struct<\n Infer<Head> | InferStructTuple<Tail>[number],\n [head: Head, ...tail: Tail]\n> {\n const struct = superstructUnion([head, ...tail]);\n\n return new Struct({\n ...struct,\n schema: [head, ...tail],\n });\n}\n\n/**\n * Superstruct struct for validating an enum value. This allows using both the\n * enum string values and the enum itself as values.\n *\n * @param constant - The enum to validate against.\n * @returns The superstruct struct.\n */\nexport function enumValue<Type extends string>(\n constant: Type,\n): Struct<EnumToUnion<Type>, null> {\n return literal(constant as EnumToUnion<Type>);\n}\n\n/**\n * Create a custom union struct that validates exclusively based on a `type` field.\n *\n * This should improve error messaging for unions with many structs in them.\n *\n * @param structs - The structs to union.\n * @returns The `superstruct` struct, which validates that the value satisfies\n * one of the structs.\n */\nexport function typedUnion<Head extends AnyStruct, Tail extends AnyStruct[]>(\n structs: [head: Head, ...tail: Tail],\n): Struct<Infer<Head> | InferStructTuple<Tail>[number], null> {\n const flatStructs = structs\n .map((struct) =>\n struct.type === 'union' && Array.isArray(struct.schema)\n ? struct.schema\n : struct,\n )\n .flat(Infinity);\n const types = flatStructs.map(({ schema }) => schema.type.type);\n return new Struct({\n type: 'union',\n schema: flatStructs,\n *entries(value, context) {\n if (!isPlainObject(value) || !hasProperty(value, 'type')) {\n return;\n }\n\n const { type } = value;\n const struct = flatStructs.find(({ schema }) => is(type, schema.type));\n\n if (!struct) {\n return;\n }\n\n for (const entry of struct.entries(value, context)) {\n yield entry;\n }\n },\n coercer(value, context) {\n if (!isPlainObject(value) || !hasProperty(value, 'type')) {\n return value;\n }\n\n const { type } = value;\n const struct = flatStructs.find(({ schema }) => is(type, schema.type));\n if (struct) {\n return struct.coercer(value, context);\n }\n\n return value;\n },\n // At this point we know the value to be an object.\n *refiner(value: PlainObject, context) {\n const struct = flatStructs.find(({ schema }) =>\n is(value.type, schema.type),\n );\n\n yield* struct.refiner(value, context);\n },\n validator(value, context) {\n if (\n !isPlainObject(value) ||\n !hasProperty(value, 'type') ||\n typeof value.type !== 'string'\n ) {\n return `Expected type to be one of: ${types.join(\n ', ',\n )}, but received: undefined`;\n }\n\n const { type } = value;\n\n const struct = flatStructs.find(({ schema }) => is(type, schema.type));\n\n if (struct) {\n // This only validates the root of the struct, entries does the rest of the work.\n return struct.validator(value, context);\n }\n\n return `Expected type to be one of: ${types.join(\n ', ',\n )}, but received: \"${type}\"`;\n },\n }) as unknown as Struct<Infer<Head> | InferStructTuple<Tail>[number], null>;\n}\n\n/**\n * Create a custom union struct that uses a `selector` function for choosing\n * the validation path.\n *\n * @param selector - The selector function choosing the struct to validate with.\n * @returns The `superstruct` struct, which validates that the value satisfies\n * one of the structs.\n */\nexport function selectiveUnion<Selector extends (value: any) => AnyStruct>(\n selector: Selector,\n): Struct<Infer<ReturnType<Selector>>, null> {\n return new Struct({\n type: 'union',\n schema: null,\n *entries(value, context) {\n const struct = selector(value);\n\n for (const entry of struct.entries(value, context)) {\n yield entry;\n }\n },\n *refiner(value, context) {\n const struct = selector(value);\n\n yield* struct.refiner(value, context);\n },\n coercer(value, context) {\n const struct = selector(value);\n\n return struct.coercer(value, context);\n },\n validator(value, context) {\n const struct = selector(value);\n\n // This only validates the root of the struct, entries does the rest of the work.\n return struct.validator(value, context);\n },\n });\n}\n"]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.svg = void 0;
4
+ const superstruct_1 = require("@metamask/superstruct");
5
+ /**
6
+ * Get a Struct that validates a string as a valid SVG.
7
+ *
8
+ * @returns A Struct that validates a string as a valid SVG.
9
+ * @internal
10
+ */
11
+ function svg() {
12
+ return (0, superstruct_1.refine)((0, superstruct_1.string)(), 'SVG', (value) => {
13
+ // This validation is intentionally very basic, we don't need to be that strict
14
+ // and merely have this extra validation as a helpful error if devs aren't
15
+ // passing in SVGs.
16
+ if (!value.includes('<svg')) {
17
+ return 'Value is not a valid SVG.';
18
+ }
19
+ return true;
20
+ });
21
+ }
22
+ exports.svg = svg;
23
+ //# sourceMappingURL=svg.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.cjs","sourceRoot":"","sources":["../../src/internals/svg.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AAEvD;;;;;GAKG;AACH,SAAgB,GAAG;IACjB,OAAO,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QACvC,+EAA+E;QAC/E,0EAA0E;QAC1E,mBAAmB;QACnB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,2BAA2B,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAXD,kBAWC","sourcesContent":["import { refine, string } from '@metamask/superstruct';\n\n/**\n * Get a Struct that validates a string as a valid SVG.\n *\n * @returns A Struct that validates a string as a valid SVG.\n * @internal\n */\nexport function svg() {\n return refine(string(), 'SVG', (value) => {\n // This validation is intentionally very basic, we don't need to be that strict\n // and merely have this extra validation as a helpful error if devs aren't\n // passing in SVGs.\n if (!value.includes('<svg')) {\n return 'Value is not a valid SVG.';\n }\n\n return true;\n });\n}\n"]}
@@ -5,3 +5,4 @@
5
5
  * @internal
6
6
  */
7
7
  export declare function svg(): import("@metamask/superstruct").Struct<string, null>;
8
+ //# sourceMappingURL=svg.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.d.cts","sourceRoot":"","sources":["../../src/internals/svg.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,GAAG,yDAWlB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get a Struct that validates a string as a valid SVG.
3
+ *
4
+ * @returns A Struct that validates a string as a valid SVG.
5
+ * @internal
6
+ */
7
+ export declare function svg(): import("@metamask/superstruct").Struct<string, null>;
8
+ //# sourceMappingURL=svg.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.d.mts","sourceRoot":"","sources":["../../src/internals/svg.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,GAAG,yDAWlB"}
@@ -0,0 +1,19 @@
1
+ import { refine, string } from "@metamask/superstruct";
2
+ /**
3
+ * Get a Struct that validates a string as a valid SVG.
4
+ *
5
+ * @returns A Struct that validates a string as a valid SVG.
6
+ * @internal
7
+ */
8
+ export function svg() {
9
+ return refine(string(), 'SVG', (value) => {
10
+ // This validation is intentionally very basic, we don't need to be that strict
11
+ // and merely have this extra validation as a helpful error if devs aren't
12
+ // passing in SVGs.
13
+ if (!value.includes('<svg')) {
14
+ return 'Value is not a valid SVG.';
15
+ }
16
+ return true;
17
+ });
18
+ }
19
+ //# sourceMappingURL=svg.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.mjs","sourceRoot":"","sources":["../../src/internals/svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAEvD;;;;;GAKG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QACvC,+EAA+E;QAC/E,0EAA0E;QAC1E,mBAAmB;QACnB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,2BAA2B,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { refine, string } from '@metamask/superstruct';\n\n/**\n * Get a Struct that validates a string as a valid SVG.\n *\n * @returns A Struct that validates a string as a valid SVG.\n * @internal\n */\nexport function svg() {\n return refine(string(), 'SVG', (value) => {\n // This validation is intentionally very basic, we don't need to be that strict\n // and merely have this extra validation as a helpful error if devs aren't\n // passing in SVGs.\n if (!value.includes('<svg')) {\n return 'Value is not a valid SVG.';\n }\n\n return true;\n });\n}\n"]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSnapComponent = void 0;
4
+ /**
5
+ * Remove undefined props from an object.
6
+ *
7
+ * @param props - The object to remove undefined props from.
8
+ * @returns The object without undefined props.
9
+ */
10
+ function removeUndefinedProps(props) {
11
+ return Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined));
12
+ }
13
+ /**
14
+ * Create a Snap component from a type. This is a helper function that creates a
15
+ * Snap component function.
16
+ *
17
+ * @param type - The type of the component.
18
+ * @returns A function that creates a Snap element.
19
+ * @see SnapComponent
20
+ */
21
+ function createSnapComponent(type) {
22
+ return (props) => {
23
+ const { key = null, ...rest } = props;
24
+ return {
25
+ type,
26
+ props: removeUndefinedProps(rest),
27
+ key,
28
+ };
29
+ };
30
+ }
31
+ exports.createSnapComponent = createSnapComponent;
32
+ //# sourceMappingURL=component.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.cjs","sourceRoot":"","sources":["../../src/jsx/component.ts"],"names":[],"mappings":";;;AA8EA;;;;;GAKG;AACH,SAAS,oBAAoB,CAA2B,KAAY;IAClE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CACxD,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAGjC,IAAU;IACV,OAAO,CAAC,KAAmC,EAAE,EAAE;QAC7C,MAAM,EAAE,GAAG,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QACtC,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,oBAAoB,CAAC,IAAa,CAAC;YAC1C,GAAG;SACJ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAZD,kDAYC","sourcesContent":["import type { Json } from '@metamask/utils';\n\n/**\n * A key, which can be a string or a number.\n */\nexport type Key = string | number;\n\n/**\n * A JSON object.\n */\nexport type JsonObject = Record<string, Json>;\n\n/**\n * A generic JSX element.\n *\n * @property type - The type of the element.\n * @property props - The props of the element.\n * @property key - The key of the element.\n */\nexport type GenericSnapElement = {\n type: string;\n props: JsonObject;\n key: Key | null;\n};\n\n/**\n * A JSX element.\n *\n * @property type - The type of the element.\n * @property props - The props of the element.\n * @property key - The key of the element.\n */\nexport type SnapElement<\n Props extends JsonObject = Record<string, never>,\n Type extends string = string,\n> = {\n type: Type;\n props: Props;\n key: Key | null;\n};\n\n/**\n * A type that can be a single value or an infinitely nestable array of values.\n *\n * @template Type - The type that can be an array.\n * @example\n * type NestableString = Nestable<string>;\n * const nestableString: NestableString = 'hello';\n * const nestableStringArray: NestableString = ['hello', 'world', ['foo', ['bar']]];\n */\nexport type Nestable<Type> = Type | Nestable<Type>[];\n\n/**\n * A type that can be a single value or an array of values, a boolean, or null.\n *\n * @template Type - The type that can be an array.\n */\nexport type SnapsChildren<Type> = Nestable<Type | boolean | null>;\n\n/**\n * A JSX node, which can be an element, a string, null, or an array of nodes.\n */\nexport type SnapNode = SnapsChildren<GenericSnapElement | string>;\n\n/**\n * A JSX string element, which can be a string or an array of strings, or\n * booleans (for conditional rendering).\n */\nexport type StringElement = SnapsChildren<string>;\n\n/**\n * A JSX component.\n */\nexport type SnapComponent<\n Props extends JsonObject = Record<string, never>,\n Type extends string = string,\n> = (props: Props & { key?: Key | null }) => SnapElement<Props, Type>;\n\n/**\n * Remove undefined props from an object.\n *\n * @param props - The object to remove undefined props from.\n * @returns The object without undefined props.\n */\nfunction removeUndefinedProps<Props extends JsonObject>(props: Props): Props {\n return Object.fromEntries(\n Object.entries(props).filter(([, value]) => value !== undefined),\n ) as Props;\n}\n\n/**\n * Create a Snap component from a type. This is a helper function that creates a\n * Snap component function.\n *\n * @param type - The type of the component.\n * @returns A function that creates a Snap element.\n * @see SnapComponent\n */\nexport function createSnapComponent<\n Props extends JsonObject = Record<string, never>,\n Type extends string = string,\n>(type: Type): SnapComponent<Props, Type> {\n return (props: Props & { key?: Key | null }) => {\n const { key = null, ...rest } = props;\n return {\n type,\n props: removeUndefinedProps(rest as Props),\n key,\n };\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Json } from '@metamask/utils';
1
+ import type { Json } from "@metamask/utils";
2
2
  /**
3
3
  * A key, which can be a string or a number.
4
4
  */
@@ -71,3 +71,4 @@ export type SnapComponent<Props extends JsonObject = Record<string, never>, Type
71
71
  * @see SnapComponent
72
72
  */
73
73
  export declare function createSnapComponent<Props extends JsonObject = Record<string, never>, Type extends string = string>(type: Type): SnapComponent<Props, Type>;
74
+ //# sourceMappingURL=component.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.cts","sourceRoot":"","sources":["../../src/jsx/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG,MAAM,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,CACrB,KAAK,SAAS,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAChD,IAAI,SAAS,MAAM,GAAG,MAAM,IAC1B;IACF,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,CAAC,IAAI,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,GAAG,OAAO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