@metamask/snaps-sdk 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/index.js +883 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.mjs +810 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/tsconfig.build.tsbuildinfo +1 -0
  7. package/dist/types/error-wrappers.d.ts +464 -48
  8. package/dist/types/errors.d.ts +2 -4
  9. package/dist/types/index.d.ts +1 -1
  10. package/dist/types/internals/error-wrappers.d.ts +29 -3
  11. package/dist/types/internals/index.d.ts +1 -0
  12. package/dist/types/internals/svg.d.ts +14 -0
  13. package/package.json +19 -16
  14. package/dist/cjs/error-wrappers.js +0 -80
  15. package/dist/cjs/error-wrappers.js.map +0 -1
  16. package/dist/cjs/errors.js +0 -157
  17. package/dist/cjs/errors.js.map +0 -1
  18. package/dist/cjs/images.js +0 -54
  19. package/dist/cjs/images.js.map +0 -1
  20. package/dist/cjs/index.js +0 -62
  21. package/dist/cjs/index.js.map +0 -1
  22. package/dist/cjs/internals/error-wrappers.js +0 -25
  23. package/dist/cjs/internals/error-wrappers.js.map +0 -1
  24. package/dist/cjs/internals/errors.js +0 -59
  25. package/dist/cjs/internals/errors.js.map +0 -1
  26. package/dist/cjs/internals/helpers.js +0 -6
  27. package/dist/cjs/internals/helpers.js.map +0 -1
  28. package/dist/cjs/internals/index.js +0 -23
  29. package/dist/cjs/internals/index.js.map +0 -1
  30. package/dist/cjs/internals/structs.js +0 -43
  31. package/dist/cjs/internals/structs.js.map +0 -1
  32. package/dist/cjs/types/caip.js +0 -10
  33. package/dist/cjs/types/caip.js.map +0 -1
  34. package/dist/cjs/types/global.js +0 -6
  35. package/dist/cjs/types/global.js.map +0 -1
  36. package/dist/cjs/types/handlers/cronjob.js +0 -6
  37. package/dist/cjs/types/handlers/cronjob.js.map +0 -1
  38. package/dist/cjs/types/handlers/home-page.js +0 -6
  39. package/dist/cjs/types/handlers/home-page.js.map +0 -1
  40. package/dist/cjs/types/handlers/index.js +0 -28
  41. package/dist/cjs/types/handlers/index.js.map +0 -1
  42. package/dist/cjs/types/handlers/keyring.js +0 -6
  43. package/dist/cjs/types/handlers/keyring.js.map +0 -1
  44. package/dist/cjs/types/handlers/lifecycle.js +0 -6
  45. package/dist/cjs/types/handlers/lifecycle.js.map +0 -1
  46. package/dist/cjs/types/handlers/name-lookup.js +0 -6
  47. package/dist/cjs/types/handlers/name-lookup.js.map +0 -1
  48. package/dist/cjs/types/handlers/rpc-request.js +0 -6
  49. package/dist/cjs/types/handlers/rpc-request.js.map +0 -1
  50. package/dist/cjs/types/handlers/signature.js +0 -6
  51. package/dist/cjs/types/handlers/signature.js.map +0 -1
  52. package/dist/cjs/types/handlers/transaction.js +0 -16
  53. package/dist/cjs/types/handlers/transaction.js.map +0 -1
  54. package/dist/cjs/types/handlers/user-input.js +0 -51
  55. package/dist/cjs/types/handlers/user-input.js.map +0 -1
  56. package/dist/cjs/types/index.js +0 -29
  57. package/dist/cjs/types/index.js.map +0 -1
  58. package/dist/cjs/types/interface.js +0 -26
  59. package/dist/cjs/types/interface.js.map +0 -1
  60. package/dist/cjs/types/methods/create-interface.js +0 -6
  61. package/dist/cjs/types/methods/create-interface.js.map +0 -1
  62. package/dist/cjs/types/methods/dialog.js +0 -18
  63. package/dist/cjs/types/methods/dialog.js.map +0 -1
  64. package/dist/cjs/types/methods/get-bip32-entropy.js +0 -6
  65. package/dist/cjs/types/methods/get-bip32-entropy.js.map +0 -1
  66. package/dist/cjs/types/methods/get-bip32-public-key.js +0 -6
  67. package/dist/cjs/types/methods/get-bip32-public-key.js.map +0 -1
  68. package/dist/cjs/types/methods/get-bip44-entropy.js +0 -6
  69. package/dist/cjs/types/methods/get-bip44-entropy.js.map +0 -1
  70. package/dist/cjs/types/methods/get-client-status.js +0 -10
  71. package/dist/cjs/types/methods/get-client-status.js.map +0 -1
  72. package/dist/cjs/types/methods/get-entropy.js +0 -6
  73. package/dist/cjs/types/methods/get-entropy.js.map +0 -1
  74. package/dist/cjs/types/methods/get-file.js +0 -18
  75. package/dist/cjs/types/methods/get-file.js.map +0 -1
  76. package/dist/cjs/types/methods/get-interface-state.js +0 -6
  77. package/dist/cjs/types/methods/get-interface-state.js.map +0 -1
  78. package/dist/cjs/types/methods/get-locale.js +0 -10
  79. package/dist/cjs/types/methods/get-locale.js.map +0 -1
  80. package/dist/cjs/types/methods/get-snaps.js +0 -6
  81. package/dist/cjs/types/methods/get-snaps.js.map +0 -1
  82. package/dist/cjs/types/methods/index.js +0 -38
  83. package/dist/cjs/types/methods/index.js.map +0 -1
  84. package/dist/cjs/types/methods/invoke-keyring.js +0 -6
  85. package/dist/cjs/types/methods/invoke-keyring.js.map +0 -1
  86. package/dist/cjs/types/methods/invoke-snap.js +0 -6
  87. package/dist/cjs/types/methods/invoke-snap.js.map +0 -1
  88. package/dist/cjs/types/methods/manage-accounts.js +0 -6
  89. package/dist/cjs/types/methods/manage-accounts.js.map +0 -1
  90. package/dist/cjs/types/methods/manage-state.js +0 -18
  91. package/dist/cjs/types/methods/manage-state.js.map +0 -1
  92. package/dist/cjs/types/methods/methods.js +0 -6
  93. package/dist/cjs/types/methods/methods.js.map +0 -1
  94. package/dist/cjs/types/methods/notify.js +0 -17
  95. package/dist/cjs/types/methods/notify.js.map +0 -1
  96. package/dist/cjs/types/methods/request-snaps.js +0 -6
  97. package/dist/cjs/types/methods/request-snaps.js.map +0 -1
  98. package/dist/cjs/types/methods/update-interface.js +0 -6
  99. package/dist/cjs/types/methods/update-interface.js.map +0 -1
  100. package/dist/cjs/types/permissions.js +0 -6
  101. package/dist/cjs/types/permissions.js.map +0 -1
  102. package/dist/cjs/types/provider.js +0 -6
  103. package/dist/cjs/types/provider.js.map +0 -1
  104. package/dist/cjs/types/snap.js +0 -6
  105. package/dist/cjs/types/snap.js.map +0 -1
  106. package/dist/cjs/ui/builder.js +0 -44
  107. package/dist/cjs/ui/builder.js.map +0 -1
  108. package/dist/cjs/ui/component.js +0 -29
  109. package/dist/cjs/ui/component.js.map +0 -1
  110. package/dist/cjs/ui/components/address.js +0 -30
  111. package/dist/cjs/ui/components/address.js.map +0 -1
  112. package/dist/cjs/ui/components/button.js +0 -59
  113. package/dist/cjs/ui/components/button.js.map +0 -1
  114. package/dist/cjs/ui/components/copyable.js +0 -32
  115. package/dist/cjs/ui/components/copyable.js.map +0 -1
  116. package/dist/cjs/ui/components/divider.js +0 -27
  117. package/dist/cjs/ui/components/divider.js.map +0 -1
  118. package/dist/cjs/ui/components/form.js +0 -41
  119. package/dist/cjs/ui/components/form.js.map +0 -1
  120. package/dist/cjs/ui/components/heading.js +0 -30
  121. package/dist/cjs/ui/components/heading.js.map +0 -1
  122. package/dist/cjs/ui/components/image.js +0 -47
  123. package/dist/cjs/ui/components/image.js.map +0 -1
  124. package/dist/cjs/ui/components/index.js +0 -54
  125. package/dist/cjs/ui/components/index.js.map +0 -1
  126. package/dist/cjs/ui/components/input.js +0 -52
  127. package/dist/cjs/ui/components/input.js.map +0 -1
  128. package/dist/cjs/ui/components/panel.js +0 -65
  129. package/dist/cjs/ui/components/panel.js.map +0 -1
  130. package/dist/cjs/ui/components/row.js +0 -57
  131. package/dist/cjs/ui/components/row.js.map +0 -1
  132. package/dist/cjs/ui/components/spinner.js +0 -27
  133. package/dist/cjs/ui/components/spinner.js.map +0 -1
  134. package/dist/cjs/ui/components/text.js +0 -32
  135. package/dist/cjs/ui/components/text.js.map +0 -1
  136. package/dist/cjs/ui/index.js +0 -28
  137. package/dist/cjs/ui/index.js.map +0 -1
  138. package/dist/cjs/ui/nodes.js +0 -46
  139. package/dist/cjs/ui/nodes.js.map +0 -1
  140. package/dist/esm/error-wrappers.js +0 -128
  141. package/dist/esm/error-wrappers.js.map +0 -1
  142. package/dist/esm/errors.js +0 -150
  143. package/dist/esm/errors.js.map +0 -1
  144. package/dist/esm/images.js +0 -84
  145. package/dist/esm/images.js.map +0 -1
  146. package/dist/esm/index.js +0 -10
  147. package/dist/esm/index.js.map +0 -1
  148. package/dist/esm/internals/error-wrappers.js +0 -25
  149. package/dist/esm/internals/error-wrappers.js.map +0 -1
  150. package/dist/esm/internals/errors.js +0 -58
  151. package/dist/esm/internals/errors.js.map +0 -1
  152. package/dist/esm/internals/helpers.js +0 -3
  153. package/dist/esm/internals/helpers.js.map +0 -1
  154. package/dist/esm/internals/index.js +0 -6
  155. package/dist/esm/internals/index.js.map +0 -1
  156. package/dist/esm/internals/structs.js +0 -59
  157. package/dist/esm/internals/structs.js.map +0 -1
  158. package/dist/esm/types/caip.js +0 -7
  159. package/dist/esm/types/caip.js.map +0 -1
  160. package/dist/esm/types/global.js +0 -3
  161. package/dist/esm/types/global.js.map +0 -1
  162. package/dist/esm/types/handlers/cronjob.js +0 -3
  163. package/dist/esm/types/handlers/cronjob.js.map +0 -1
  164. package/dist/esm/types/handlers/home-page.js +0 -3
  165. package/dist/esm/types/handlers/home-page.js.map +0 -1
  166. package/dist/esm/types/handlers/index.js +0 -11
  167. package/dist/esm/types/handlers/index.js.map +0 -1
  168. package/dist/esm/types/handlers/keyring.js +0 -3
  169. package/dist/esm/types/handlers/keyring.js.map +0 -1
  170. package/dist/esm/types/handlers/lifecycle.js +0 -3
  171. package/dist/esm/types/handlers/lifecycle.js.map +0 -1
  172. package/dist/esm/types/handlers/name-lookup.js +0 -3
  173. package/dist/esm/types/handlers/name-lookup.js.map +0 -1
  174. package/dist/esm/types/handlers/rpc-request.js +0 -3
  175. package/dist/esm/types/handlers/rpc-request.js.map +0 -1
  176. package/dist/esm/types/handlers/signature.js +0 -3
  177. package/dist/esm/types/handlers/signature.js.map +0 -1
  178. package/dist/esm/types/handlers/transaction.js +0 -6
  179. package/dist/esm/types/handlers/transaction.js.map +0 -1
  180. package/dist/esm/types/handlers/user-input.js +0 -24
  181. package/dist/esm/types/handlers/user-input.js.map +0 -1
  182. package/dist/esm/types/index.js +0 -12
  183. package/dist/esm/types/index.js.map +0 -1
  184. package/dist/esm/types/interface.js +0 -12
  185. package/dist/esm/types/interface.js.map +0 -1
  186. package/dist/esm/types/methods/create-interface.js +0 -3
  187. package/dist/esm/types/methods/create-interface.js.map +0 -1
  188. package/dist/esm/types/methods/dialog.js +0 -8
  189. package/dist/esm/types/methods/dialog.js.map +0 -1
  190. package/dist/esm/types/methods/get-bip32-entropy.js +0 -3
  191. package/dist/esm/types/methods/get-bip32-entropy.js.map +0 -1
  192. package/dist/esm/types/methods/get-bip32-public-key.js +0 -3
  193. package/dist/esm/types/methods/get-bip32-public-key.js.map +0 -1
  194. package/dist/esm/types/methods/get-bip44-entropy.js +0 -3
  195. package/dist/esm/types/methods/get-bip44-entropy.js.map +0 -1
  196. package/dist/esm/types/methods/get-client-status.js +0 -7
  197. package/dist/esm/types/methods/get-client-status.js.map +0 -1
  198. package/dist/esm/types/methods/get-entropy.js +0 -3
  199. package/dist/esm/types/methods/get-entropy.js.map +0 -1
  200. package/dist/esm/types/methods/get-file.js +0 -8
  201. package/dist/esm/types/methods/get-file.js.map +0 -1
  202. package/dist/esm/types/methods/get-interface-state.js +0 -3
  203. package/dist/esm/types/methods/get-interface-state.js.map +0 -1
  204. package/dist/esm/types/methods/get-locale.js +0 -7
  205. package/dist/esm/types/methods/get-locale.js.map +0 -1
  206. package/dist/esm/types/methods/get-snaps.js +0 -3
  207. package/dist/esm/types/methods/get-snaps.js.map +0 -1
  208. package/dist/esm/types/methods/index.js +0 -21
  209. package/dist/esm/types/methods/index.js.map +0 -1
  210. package/dist/esm/types/methods/invoke-keyring.js +0 -3
  211. package/dist/esm/types/methods/invoke-keyring.js.map +0 -1
  212. package/dist/esm/types/methods/invoke-snap.js +0 -3
  213. package/dist/esm/types/methods/invoke-snap.js.map +0 -1
  214. package/dist/esm/types/methods/manage-accounts.js +0 -3
  215. package/dist/esm/types/methods/manage-accounts.js.map +0 -1
  216. package/dist/esm/types/methods/manage-state.js +0 -8
  217. package/dist/esm/types/methods/manage-state.js.map +0 -1
  218. package/dist/esm/types/methods/methods.js +0 -3
  219. package/dist/esm/types/methods/methods.js.map +0 -1
  220. package/dist/esm/types/methods/notify.js +0 -7
  221. package/dist/esm/types/methods/notify.js.map +0 -1
  222. package/dist/esm/types/methods/request-snaps.js +0 -3
  223. package/dist/esm/types/methods/request-snaps.js.map +0 -1
  224. package/dist/esm/types/methods/update-interface.js +0 -3
  225. package/dist/esm/types/methods/update-interface.js.map +0 -1
  226. package/dist/esm/types/permissions.js +0 -3
  227. package/dist/esm/types/permissions.js.map +0 -1
  228. package/dist/esm/types/provider.js +0 -3
  229. package/dist/esm/types/provider.js.map +0 -1
  230. package/dist/esm/types/snap.js +0 -3
  231. package/dist/esm/types/snap.js.map +0 -1
  232. package/dist/esm/ui/builder.js +0 -50
  233. package/dist/esm/ui/builder.js.map +0 -1
  234. package/dist/esm/ui/component.js +0 -23
  235. package/dist/esm/ui/component.js.map +0 -1
  236. package/dist/esm/ui/components/address.js +0 -22
  237. package/dist/esm/ui/components/address.js.map +0 -1
  238. package/dist/esm/ui/components/button.js +0 -50
  239. package/dist/esm/ui/components/button.js.map +0 -1
  240. package/dist/esm/ui/components/copyable.js +0 -27
  241. package/dist/esm/ui/components/copyable.js.map +0 -1
  242. package/dist/esm/ui/components/divider.js +0 -15
  243. package/dist/esm/ui/components/divider.js.map +0 -1
  244. package/dist/esm/ui/components/form.js +0 -39
  245. package/dist/esm/ui/components/form.js.map +0 -1
  246. package/dist/esm/ui/components/heading.js +0 -22
  247. package/dist/esm/ui/components/heading.js.map +0 -1
  248. package/dist/esm/ui/components/image.js +0 -37
  249. package/dist/esm/ui/components/image.js.map +0 -1
  250. package/dist/esm/ui/components/index.js +0 -14
  251. package/dist/esm/ui/components/index.js.map +0 -1
  252. package/dist/esm/ui/components/input.js +0 -47
  253. package/dist/esm/ui/components/input.js.map +0 -1
  254. package/dist/esm/ui/components/panel.js +0 -66
  255. package/dist/esm/ui/components/panel.js.map +0 -1
  256. package/dist/esm/ui/components/row.js +0 -50
  257. package/dist/esm/ui/components/row.js.map +0 -1
  258. package/dist/esm/ui/components/spinner.js +0 -15
  259. package/dist/esm/ui/components/spinner.js.map +0 -1
  260. package/dist/esm/ui/components/text.js +0 -29
  261. package/dist/esm/ui/components/text.js.map +0 -1
  262. package/dist/esm/ui/index.js +0 -5
  263. package/dist/esm/ui/index.js.map +0 -1
  264. package/dist/esm/ui/nodes.js +0 -29
  265. package/dist/esm/ui/nodes.js.map +0 -1
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./create-interface"), exports);
6
- _export_star(require("./dialog"), exports);
7
- _export_star(require("./get-bip32-entropy"), exports);
8
- _export_star(require("./get-bip32-public-key"), exports);
9
- _export_star(require("./get-bip44-entropy"), exports);
10
- _export_star(require("./get-client-status"), exports);
11
- _export_star(require("./get-entropy"), exports);
12
- _export_star(require("./get-file"), exports);
13
- _export_star(require("./get-interface-state"), exports);
14
- _export_star(require("./get-locale"), exports);
15
- _export_star(require("./get-snaps"), exports);
16
- _export_star(require("./invoke-keyring"), exports);
17
- _export_star(require("./invoke-snap"), exports);
18
- _export_star(require("./manage-accounts"), exports);
19
- _export_star(require("./manage-state"), exports);
20
- _export_star(require("./methods"), exports);
21
- _export_star(require("./notify"), exports);
22
- _export_star(require("./request-snaps"), exports);
23
- _export_star(require("./update-interface"), exports);
24
- function _export_star(from, to) {
25
- Object.keys(from).forEach(function(k) {
26
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
27
- Object.defineProperty(to, k, {
28
- enumerable: true,
29
- get: function() {
30
- return from[k];
31
- }
32
- });
33
- }
34
- });
35
- return from;
36
- }
37
-
38
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/methods/index.ts"],"sourcesContent":["export * from './create-interface';\nexport * from './dialog';\nexport * from './get-bip32-entropy';\nexport * from './get-bip32-public-key';\nexport * from './get-bip44-entropy';\nexport * from './get-client-status';\nexport * from './get-entropy';\nexport * from './get-file';\nexport * from './get-interface-state';\nexport * from './get-locale';\nexport * from './get-snaps';\nexport * from './invoke-keyring';\nexport * from './invoke-snap';\nexport * from './manage-accounts';\nexport * from './manage-state';\nexport * from './methods';\nexport * from './notify';\nexport * from './request-snaps';\nexport * from './update-interface';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
6
- //# sourceMappingURL=invoke-keyring.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/methods/invoke-keyring.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
6
- //# sourceMappingURL=invoke-snap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/methods/invoke-snap.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
6
- //# sourceMappingURL=manage-accounts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/methods/manage-accounts.ts"],"names":[],"mappings":""}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "ManageStateOperation", {
6
- enumerable: true,
7
- get: function() {
8
- return ManageStateOperation;
9
- }
10
- });
11
- var ManageStateOperation;
12
- (function(ManageStateOperation) {
13
- ManageStateOperation["ClearState"] = 'clear';
14
- ManageStateOperation["GetState"] = 'get';
15
- ManageStateOperation["UpdateState"] = 'update';
16
- })(ManageStateOperation || (ManageStateOperation = {}));
17
-
18
- //# sourceMappingURL=manage-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/methods/manage-state.ts"],"sourcesContent":["import type { Json } from '@metamask/utils';\n\nimport type { EnumToUnion } from '../../internals';\n\n/**\n * The operations that can be performed on the state.\n */\nexport enum ManageStateOperation {\n ClearState = 'clear',\n GetState = 'get',\n UpdateState = 'update',\n}\n\n/**\n * The clear state operation, which clears the state.\n *\n * @property operation - The operation to perform on the state. Must be `clear`.\n * @property encrypted - Whether to use the separate encrypted state, or the\n * unencrypted state. Defaults to the encrypted state. Encrypted state can only\n * be used if the extension is unlocked, while unencrypted state can be used\n * whether the extension is locked or unlocked.\n */\nexport type ClearStateOperation = {\n operation: EnumToUnion<ManageStateOperation.ClearState>;\n encrypted?: boolean;\n};\n\n/**\n * The get state operation, which retrieves the state.\n *\n * @property operation - The operation to perform on the state. Must be `get`.\n * @property encrypted - Whether to use the separate encrypted state, or the\n * unencrypted state. Defaults to the encrypted state. Encrypted state can only\n * be used if the extension is unlocked, while unencrypted state can be used\n * whether the extension is locked or unlocked.\n */\nexport type GetStateOperation = {\n operation: EnumToUnion<ManageStateOperation.GetState>;\n encrypted?: boolean;\n};\n\n/**\n * The update state operation, which updates the state.\n *\n * @property operation - The operation to perform on the state. Must be\n * `update`.\n * @property encrypted - Whether to use the separate encrypted state, or the\n * unencrypted state. Defaults to the encrypted state. Encrypted state can only\n * be used if the extension is unlocked, while unencrypted state can be used\n * whether the extension is locked or unlocked.\n * @property newState - The new state to set.\n */\nexport type UpdateStateOperation = {\n operation: EnumToUnion<ManageStateOperation.UpdateState>;\n encrypted?: boolean;\n newState: Record<string, Json>;\n};\n\n/**\n * The request parameters for the `snap_manageState` method.\n *\n * @property operation - The operation to perform on the state.\n * @property encrypted - Whether to use the separate encrypted state, or the\n * unencrypted state. Defaults to the encrypted state.\n * @property newState - The new state to set. Only applicable for the `set`\n * operation.\n */\nexport type ManageStateParams =\n | ClearStateOperation\n | GetStateOperation\n | UpdateStateOperation;\n\n/**\n * The result returned by the `snap_manageState` method.\n *\n * If the operation is `get`, the result is the state. Otherwise, the result is\n * `null`.\n */\nexport type ManageStateResult = Record<string, Json> | null;\n"],"names":["ManageStateOperation","ClearState","GetState","UpdateState"],"mappings":";;;;;;;;;;IAOO;UAAKA,oBAAoB;IAApBA,qBACVC,gBAAa;IADHD,qBAEVE,cAAW;IAFDF,qBAGVG,iBAAc;GAHJH,yBAAAA"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
6
- //# sourceMappingURL=methods.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/methods/methods.ts"],"names":[],"mappings":""}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "NotificationType", {
6
- enumerable: true,
7
- get: function() {
8
- return NotificationType;
9
- }
10
- });
11
- var NotificationType;
12
- (function(NotificationType) {
13
- NotificationType["InApp"] = 'inApp';
14
- NotificationType["Native"] = 'native';
15
- })(NotificationType || (NotificationType = {}));
16
-
17
- //# sourceMappingURL=notify.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/methods/notify.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\n\n/**\n * The types of notifications that can be displayed.\n *\n * - `InApp` - A notification that is displayed in by the MetaMask extension.\n * - `Native` - A notification that is displayed by the operating system.\n */\nexport enum NotificationType {\n InApp = 'inApp',\n Native = 'native',\n}\n\n/**\n * The request parameters for the `snap_notify` method.\n *\n * @property type - The type of notification to display.\n * @property message - The message to display in the notification.\n */\nexport type NotifyParams = {\n type: EnumToUnion<NotificationType>;\n message: string;\n};\n\n/**\n * The result returned by the `snap_notify` method.\n *\n * This method does not return anything.\n */\nexport type NotifyResult = null;\n"],"names":["NotificationType","InApp","Native"],"mappings":";;;;;;;;;;IAQO;UAAKA,gBAAgB;IAAhBA,iBACVC,WAAQ;IADED,iBAEVE,YAAS;GAFCF,qBAAAA"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
6
- //# sourceMappingURL=request-snaps.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/methods/request-snaps.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
6
- //# sourceMappingURL=update-interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/methods/update-interface.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
6
- //# sourceMappingURL=permissions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/types/permissions.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
6
- //# sourceMappingURL=provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/types/provider.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
6
- //# sourceMappingURL=snap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/types/snap.ts"],"names":[],"mappings":""}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "createBuilder", {
6
- enumerable: true,
7
- get: function() {
8
- return createBuilder;
9
- }
10
- });
11
- const _utils = require("@metamask/utils");
12
- function createBuilder(type, struct, keys = []) {
13
- return (...args)=>{
14
- // Node passed as a single object.
15
- if (args.length === 1 && (0, _utils.isPlainObject)(args[0])) {
16
- const node = {
17
- ...args[0],
18
- type
19
- };
20
- // The user could be passing invalid values to the builder, so we need to
21
- // validate them as per the component's struct.
22
- (0, _utils.assertStruct)(node, struct, `Invalid ${type} component`);
23
- return node;
24
- }
25
- // Node passed as an array of arguments.
26
- const node = keys.reduce((partialNode, key, index)=>{
27
- if (args[index] !== undefined) {
28
- return {
29
- ...partialNode,
30
- [key]: args[index]
31
- };
32
- }
33
- return partialNode;
34
- }, {
35
- type
36
- });
37
- // The user could be passing invalid values to the builder, so we need to
38
- // validate them as per the component's struct.
39
- (0, _utils.assertStruct)(node, struct, `Invalid ${type} component`);
40
- return node;
41
- };
42
- }
43
-
44
- //# sourceMappingURL=builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/ui/builder.ts"],"sourcesContent":["import { assertStruct, isPlainObject } from '@metamask/utils';\nimport type { Struct } from 'superstruct';\n\nimport type { Component } from './components';\nimport type { NodeType } from './nodes';\n\n/**\n * A function that builds a {@link Component}. This infers the proper args type\n * from the given node.\n *\n * @internal\n */\ntype NodeBuilder<Node extends Component, Keys extends (keyof Node)[]> = Omit<\n Node,\n 'type'\n> extends Record<string, never>\n ? (...args: []) => Node\n : (...args: [Omit<Node, 'type'>] | NodeArrayType<Node, Keys>) => Node;\n\n/**\n * Map from an array of node keys to the corresponding array type.\n *\n * @example\n * type Node = { type: 'node'; a: string; b: number; c: boolean };\n * type Keys = ['a', 'b', 'c'];\n *\n * type NodeArray = NodeArrayType<Node, Keys>; // [string, number, boolean]\n * @internal\n */\ntype NodeArrayType<Node extends Component, Keys extends (keyof Node)[]> = {\n [Key in keyof Keys]: Node[Keys[Key]];\n};\n\n/**\n * A function that returns a function to \"build\" a {@link Component}. It infers\n * the type of the component from the given struct, and performs validation on\n * the created component.\n *\n * The returned function can handle the node arguments in two ways:\n * 1. As a single object, with the keys corresponding to the node's properties,\n * excluding the `type` property.\n * 2. As an array of arguments, with the order corresponding to the given keys.\n *\n * @param type - The type of the component to build.\n * @param struct - The struct to use to validate the component.\n * @param keys - The keys of the component to use as arguments to the builder.\n * The order of the keys determines the order of the arguments.\n * @returns A function that builds a component of the given type.\n * @internal\n */\nexport function createBuilder<\n Node extends Component,\n Keys extends (keyof Node)[] = [],\n>(\n type: NodeType,\n struct: Struct<Node>,\n keys: Keys = [] as unknown as Keys,\n): NodeBuilder<Node, Keys> {\n return (...args: [Omit<Node, 'type'>] | NodeArrayType<Node, Keys> | []) => {\n // Node passed as a single object.\n if (args.length === 1 && isPlainObject(args[0])) {\n const node = { ...args[0], type };\n\n // The user could be passing invalid values to the builder, so we need to\n // validate them as per the component's struct.\n assertStruct(node, struct, `Invalid ${type} component`);\n return node;\n }\n\n // Node passed as an array of arguments.\n const node = keys.reduce<Partial<Component>>(\n (partialNode, key, index) => {\n if (args[index] !== undefined) {\n return {\n ...partialNode,\n [key]: args[index],\n };\n }\n\n return partialNode;\n },\n { type },\n );\n\n // The user could be passing invalid values to the builder, so we need to\n // validate them as per the component's struct.\n assertStruct(node, struct, `Invalid ${type} component`);\n return node;\n };\n}\n"],"names":["createBuilder","type","struct","keys","args","length","isPlainObject","node","assertStruct","reduce","partialNode","key","index","undefined"],"mappings":";;;;+BAkDgBA;;;eAAAA;;;uBAlD4B;AAkDrC,SAASA,cAIdC,IAAc,EACdC,MAAoB,EACpBC,OAAa,EAAE,AAAmB;IAElC,OAAO,CAAC,GAAGC;QACT,kCAAkC;QAClC,IAAIA,KAAKC,MAAM,KAAK,KAAKC,IAAAA,oBAAa,EAACF,IAAI,CAAC,EAAE,GAAG;YAC/C,MAAMG,OAAO;gBAAE,GAAGH,IAAI,CAAC,EAAE;gBAAEH;YAAK;YAEhC,yEAAyE;YACzE,+CAA+C;YAC/CO,IAAAA,mBAAY,EAACD,MAAML,QAAQ,CAAC,QAAQ,EAAED,KAAK,UAAU,CAAC;YACtD,OAAOM;QACT;QAEA,wCAAwC;QACxC,MAAMA,OAAOJ,KAAKM,MAAM,CACtB,CAACC,aAAaC,KAAKC;YACjB,IAAIR,IAAI,CAACQ,MAAM,KAAKC,WAAW;gBAC7B,OAAO;oBACL,GAAGH,WAAW;oBACd,CAACC,IAAI,EAAEP,IAAI,CAACQ,MAAM;gBACpB;YACF;YAEA,OAAOF;QACT,GACA;YAAET;QAAK;QAGT,yEAAyE;QACzE,+CAA+C;QAC/CO,IAAAA,mBAAY,EAACD,MAAML,QAAQ,CAAC,QAAQ,EAAED,KAAK,UAAU,CAAC;QACtD,OAAOM;IACT;AACF"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- isComponent: function() {
13
- return isComponent;
14
- },
15
- assertIsComponent: function() {
16
- return assertIsComponent;
17
- }
18
- });
19
- const _utils = require("@metamask/utils");
20
- const _superstruct = require("superstruct");
21
- const _components = require("./components");
22
- function isComponent(value) {
23
- return (0, _superstruct.is)(value, _components.ComponentStruct);
24
- }
25
- function assertIsComponent(value) {
26
- (0, _utils.assertStruct)(value, _components.ComponentStruct, 'Invalid component');
27
- }
28
-
29
- //# sourceMappingURL=component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/ui/component.ts"],"sourcesContent":["import { assertStruct } from '@metamask/utils';\nimport { is } from 'superstruct';\n\nimport { ComponentStruct } from './components';\nimport type { Component } from './components';\n\n/**\n * Check if the given value is a {@link Component}. This performs recursive\n * validation of the component's children (if any).\n *\n * @param value - The value to check.\n * @returns `true` if the value is a {@link Component}, `false` otherwise.\n */\nexport function isComponent(value: unknown): value is Component {\n return is(value, ComponentStruct);\n}\n\n/**\n * Assert that the given value is a {@link Component}. This performs recursive\n * validation of the component's children (if any).\n *\n * @param value - The value to check.\n * @throws If the value is not a {@link Component}.\n */\nexport function assertIsComponent(value: unknown): asserts value is Component {\n assertStruct(value, ComponentStruct, 'Invalid component');\n}\n"],"names":["isComponent","assertIsComponent","value","is","ComponentStruct","assertStruct"],"mappings":";;;;;;;;;;;IAagBA,WAAW;eAAXA;;IAWAC,iBAAiB;eAAjBA;;;uBAxBa;6BACV;4BAEa;AAUzB,SAASD,YAAYE,KAAc;IACxC,OAAOC,IAAAA,eAAE,EAACD,OAAOE,2BAAe;AAClC;AASO,SAASH,kBAAkBC,KAAc;IAC9CG,IAAAA,mBAAY,EAACH,OAAOE,2BAAe,EAAE;AACvC"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- AddressStruct: function() {
13
- return AddressStruct;
14
- },
15
- address: function() {
16
- return address;
17
- }
18
- });
19
- const _superstruct = require("superstruct");
20
- const _builder = require("../builder");
21
- const _nodes = require("../nodes");
22
- const AddressStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
23
- type: (0, _superstruct.literal)(_nodes.NodeType.Address),
24
- value: (0, _superstruct.pattern)((0, _superstruct.string)(), /0x[a-fA-F0-9]{40}/u)
25
- }));
26
- const address = (0, _builder.createBuilder)(_nodes.NodeType.Address, AddressStruct, [
27
- 'value'
28
- ]);
29
-
30
- //# sourceMappingURL=address.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/ui/components/address.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, pattern, string } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const AddressStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Address),\n value: pattern(string(), /0x[a-fA-F0-9]{40}/u),\n }),\n);\n\n/**\n * A address node, that renders an EVM-like address and its icon.\n *\n * @property type - The type of the node. Must be the string `address`.\n * @property value - The address in hexadecimal, including 0x.\n */\nexport type Address = Infer<typeof AddressStruct>;\n\n/**\n * Create an {@link Address} node.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `value` property.\n * @param args.value - The address to be rendered.\n * @returns The address node as an object.\n * @example\n * const node = address({ value: '0x4bbeeb066ed09b7aed07bf39eee0460dfa261520' });\n * const node = address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520');\n */\nexport const address = createBuilder(NodeType.Address, AddressStruct, [\n 'value',\n]);\n"],"names":["AddressStruct","address","assign","LiteralStruct","object","type","literal","NodeType","Address","value","pattern","string","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IA2BAC,OAAO;eAAPA;;;6BAhC4C;yBAE3B;uBACU;AAEjC,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;IAC9BC,OAAOC,IAAAA,oBAAO,EAACC,IAAAA,mBAAM,KAAI;AAC3B;AAsBK,MAAMV,UAAUW,IAAAA,sBAAa,EAACL,eAAQ,CAACC,OAAO,EAAER,eAAe;IACpE;CACD"}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- ButtonVariant: function() {
13
- return ButtonVariant;
14
- },
15
- ButtonType: function() {
16
- return ButtonType;
17
- },
18
- ButtonStruct: function() {
19
- return ButtonStruct;
20
- },
21
- button: function() {
22
- return button;
23
- }
24
- });
25
- const _superstruct = require("superstruct");
26
- const _internals = require("../../internals");
27
- const _builder = require("../builder");
28
- const _nodes = require("../nodes");
29
- var ButtonVariant;
30
- (function(ButtonVariant) {
31
- ButtonVariant["Primary"] = 'primary';
32
- ButtonVariant["Secondary"] = 'secondary';
33
- })(ButtonVariant || (ButtonVariant = {}));
34
- var ButtonType;
35
- (function(ButtonType) {
36
- ButtonType["Button"] = 'button';
37
- ButtonType["Submit"] = 'submit';
38
- })(ButtonType || (ButtonType = {}));
39
- const ButtonStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
40
- type: (0, _superstruct.literal)(_nodes.NodeType.Button),
41
- value: (0, _superstruct.string)(),
42
- variant: (0, _superstruct.optional)((0, _superstruct.union)([
43
- (0, _internals.enumValue)(ButtonVariant.Primary),
44
- (0, _internals.enumValue)(ButtonVariant.Secondary)
45
- ])),
46
- buttonType: (0, _superstruct.optional)((0, _superstruct.union)([
47
- (0, _internals.enumValue)(ButtonType.Button),
48
- (0, _internals.enumValue)(ButtonType.Submit)
49
- ])),
50
- name: (0, _superstruct.optional)((0, _superstruct.string)())
51
- }));
52
- const button = (0, _builder.createBuilder)(_nodes.NodeType.Button, ButtonStruct, [
53
- 'value',
54
- 'buttonType',
55
- 'name',
56
- 'variant'
57
- ]);
58
-
59
- //# sourceMappingURL=button.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/ui/components/button.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, optional, string, union } from 'superstruct';\n\nimport { enumValue } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport enum ButtonVariant {\n Primary = 'primary',\n Secondary = 'secondary',\n}\n\nexport enum ButtonType {\n Button = 'button',\n Submit = 'submit',\n}\n\nexport const ButtonStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Button),\n value: string(),\n variant: optional(\n union([\n enumValue(ButtonVariant.Primary),\n enumValue(ButtonVariant.Secondary),\n ]),\n ),\n buttonType: optional(\n union([enumValue(ButtonType.Button), enumValue(ButtonType.Submit)]),\n ),\n name: optional(string()),\n }),\n);\n\n/**\n * A button node, that renders either a primary or a secondary button.\n *\n * @property type - The type of the node, must be the string 'button'.\n * @property variant - The style variant of the node, must be either 'primary' or 'secondary'.\n * @property value - The text content of the node as plain text.\n * @property buttonType - The type of the button, must be either 'button' or 'submit'.\n * @property name - An optional name to identify the button.\n */\nexport type Button = Infer<typeof ButtonStruct>;\n\n/**\n * Create a {@link Button} node.\n *\n * @param args - The node arguments. This can be either a string, or an object\n * with a `value` property. A set of optional properties can be passed.\n * @param args.variant - The optional variant of the button.\n * @param args.value - The text content of the node.\n * @param args.name - The optional name of the button.\n * @returns The text node as object.\n * @example\n * ```typescript\n * const node = button({ variant: 'primary', text: 'Hello, world!', name: 'myButton' });\n * const node = button('Hello, world!', 'button', 'myButton', 'primary');\n * const node = button('Hello, world!');\n * ```\n */\nexport const button = createBuilder(NodeType.Button, ButtonStruct, [\n 'value',\n 'buttonType',\n 'name',\n 'variant',\n]);\n"],"names":["ButtonStruct","button","ButtonVariant","Primary","Secondary","ButtonType","Button","Submit","assign","LiteralStruct","object","type","literal","NodeType","value","string","variant","optional","union","enumValue","buttonType","name","createBuilder"],"mappings":";;;;;;;;;;;;;;;;;IAiBaA,YAAY;eAAZA;;IA6CAC,MAAM;eAANA;;;6BA7DoD;2BAEvC;yBACI;uBACU;IAEjC;UAAKC,aAAa;IAAbA,cACVC,aAAU;IADAD,cAEVE,eAAY;GAFFF,kBAAAA;IAKL;UAAKG,UAAU;IAAVA,WACVC,YAAS;IADCD,WAEVE,YAAS;GAFCF,eAAAA;AAKL,MAAML,eAAeQ,IAAAA,mBAAM,EAChCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACP,MAAM;IAC7BQ,OAAOC,IAAAA,mBAAM;IACbC,SAASC,IAAAA,qBAAQ,EACfC,IAAAA,kBAAK,EAAC;QACJC,IAAAA,oBAAS,EAACjB,cAAcC,OAAO;QAC/BgB,IAAAA,oBAAS,EAACjB,cAAcE,SAAS;KAClC;IAEHgB,YAAYH,IAAAA,qBAAQ,EAClBC,IAAAA,kBAAK,EAAC;QAACC,IAAAA,oBAAS,EAACd,WAAWC,MAAM;QAAGa,IAAAA,oBAAS,EAACd,WAAWE,MAAM;KAAE;IAEpEc,MAAMJ,IAAAA,qBAAQ,EAACF,IAAAA,mBAAM;AACvB;AA8BK,MAAMd,SAASqB,IAAAA,sBAAa,EAACT,eAAQ,CAACP,MAAM,EAAEN,cAAc;IACjE;IACA;IACA;IACA;CACD"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- CopyableStruct: function() {
13
- return CopyableStruct;
14
- },
15
- copyable: function() {
16
- return copyable;
17
- }
18
- });
19
- const _superstruct = require("superstruct");
20
- const _builder = require("../builder");
21
- const _nodes = require("../nodes");
22
- const CopyableStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
23
- type: (0, _superstruct.literal)(_nodes.NodeType.Copyable),
24
- value: (0, _superstruct.string)(),
25
- sensitive: (0, _superstruct.optional)((0, _superstruct.boolean)())
26
- }));
27
- const copyable = (0, _builder.createBuilder)(_nodes.NodeType.Copyable, CopyableStruct, [
28
- 'value',
29
- 'sensitive'
30
- ]);
31
-
32
- //# sourceMappingURL=copyable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/ui/components/copyable.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n assign,\n boolean,\n literal,\n object,\n optional,\n string,\n} from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const CopyableStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Copyable),\n value: string(),\n sensitive: optional(boolean()),\n }),\n);\n\n/**\n * Text that can be copied to the clipboard. It can optionally be marked as\n * sensitive, in which case it will only be displayed to the user after clicking\n * on the component.\n *\n * @property type - The type of the node. Must be the string `copyable`.\n * @property value - The text to be copied.\n * @property sensitive - Whether the value is sensitive or not. Sensitive values\n * are only displayed to the user after clicking on the component. Defaults to\n * false.\n */\nexport type Copyable = Infer<typeof CopyableStruct>;\n\n/**\n * Create a {@link Copyable} component.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `text` property.\n * @param args.value - The text to be copied.\n * @param args.sensitive - Whether the value is sensitive or not. Sensitive\n * values are only displayed to the user after clicking on the component.\n * Defaults to false.\n * @returns A {@link Copyable} component.\n * @example\n * const node = copyable('Hello, world!');\n * const node = copyable({ value: 'Hello, world!' });\n */\nexport const copyable = createBuilder(NodeType.Copyable, CopyableStruct, [\n 'value',\n 'sensitive',\n]);\n"],"names":["CopyableStruct","copyable","assign","LiteralStruct","object","type","literal","NodeType","Copyable","value","string","sensitive","optional","boolean","createBuilder"],"mappings":";;;;;;;;;;;IAaaA,cAAc;eAAdA;;IAoCAC,QAAQ;eAARA;;;6BAzCN;yBAEuB;uBACU;AAEjC,MAAMD,iBAAiBE,IAAAA,mBAAM,EAClCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,QAAQ;IAC/BC,OAAOC,IAAAA,mBAAM;IACbC,WAAWC,IAAAA,qBAAQ,EAACC,IAAAA,oBAAO;AAC7B;AA8BK,MAAMZ,WAAWa,IAAAA,sBAAa,EAACP,eAAQ,CAACC,QAAQ,EAAER,gBAAgB;IACvE;IACA;CACD"}
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- DividerStruct: function() {
13
- return DividerStruct;
14
- },
15
- divider: function() {
16
- return divider;
17
- }
18
- });
19
- const _superstruct = require("superstruct");
20
- const _builder = require("../builder");
21
- const _nodes = require("../nodes");
22
- const DividerStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
23
- type: (0, _superstruct.literal)(_nodes.NodeType.Divider)
24
- }));
25
- const divider = (0, _builder.createBuilder)(_nodes.NodeType.Divider, DividerStruct);
26
-
27
- //# sourceMappingURL=divider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/ui/components/divider.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\n\nexport const DividerStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Divider),\n }),\n);\n\n/**\n * A divider node, that renders a line between other nodes.\n */\nexport type Divider = Infer<typeof DividerStruct>;\n\n/**\n * Create a {@link Divider} node.\n *\n * @returns The divider node as object.\n * @example\n * const node = divider();\n */\nexport const divider = createBuilder(NodeType.Divider, DividerStruct);\n"],"names":["DividerStruct","divider","assign","NodeStruct","object","type","literal","NodeType","Divider","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IAmBAC,OAAO;eAAPA;;;6BAxB2B;yBAEV;uBACO;AAE9B,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;AAChC;AAeK,MAAMP,UAAUQ,IAAAA,sBAAa,EAACF,eAAQ,CAACC,OAAO,EAAER"}
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- FormComponentStruct: function() {
13
- return FormComponentStruct;
14
- },
15
- FormStruct: function() {
16
- return FormStruct;
17
- },
18
- form: function() {
19
- return form;
20
- }
21
- });
22
- const _superstruct = require("superstruct");
23
- const _builder = require("../builder");
24
- const _nodes = require("../nodes");
25
- const _button = require("./button");
26
- const _input = require("./input");
27
- const FormComponentStruct = (0, _superstruct.union)([
28
- _input.InputStruct,
29
- _button.ButtonStruct
30
- ]);
31
- const FormStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
32
- type: (0, _superstruct.literal)(_nodes.NodeType.Form),
33
- children: (0, _superstruct.array)(FormComponentStruct),
34
- name: (0, _superstruct.string)()
35
- }));
36
- const form = (0, _builder.createBuilder)(_nodes.NodeType.Form, FormStruct, [
37
- 'name',
38
- 'children'
39
- ]);
40
-
41
- //# sourceMappingURL=form.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/ui/components/form.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { array, assign, literal, object, string, union } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\nimport { ButtonStruct } from './button';\nimport { InputStruct } from './input';\n\nexport const FormComponentStruct = union([InputStruct, ButtonStruct]);\n\n/**\n * The subset of nodes allowed as children in the {@link Form} node.\n */\nexport type FormComponent = Infer<typeof FormComponentStruct>;\n\nexport const FormStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Form),\n children: array(FormComponentStruct),\n name: string(),\n }),\n);\n\n/**\n * A form node that takes children {@link FormComponent} nodes and renders a form.\n *\n * @property type - The type of the node. Must be the string `form`.\n * @property children - The children of the node. Only {@link FormComponent} nodes are allowed.\n * @property name - The form name used to identify it.\n */\nexport type Form = Infer<typeof FormStruct>;\n\n/**\n * Create a {@link Form} node.\n *\n * @param args - The node arguments. This can be either an array of children and a string, or\n * an object with a `name` and `children` property.\n * @param args.name - The form name used to identify it.\n * @param args.children - The child nodes of the form. This can be any valid\n * {@link FormComponent}.\n * @returns The form node as object.\n * @example\n * const node = form({\n * name: 'myForm',\n * children: [\n * input({ name: 'myInput' }),\n * button({ value: 'Hello, world!' }),\n * ],\n * });\n *\n * const node = form('myForm', [input('myInput'), button('Hello, world!')]);\n */\nexport const form = createBuilder(NodeType.Form, FormStruct, [\n 'name',\n 'children',\n]);\n"],"names":["FormComponentStruct","FormStruct","form","union","InputStruct","ButtonStruct","assign","NodeStruct","object","type","literal","NodeType","Form","children","array","name","string","createBuilder"],"mappings":";;;;;;;;;;;IAQaA,mBAAmB;eAAnBA;;IAOAC,UAAU;eAAVA;;IAsCAC,IAAI;eAAJA;;;6BApDiD;yBAEhC;uBACO;wBACR;uBACD;AAErB,MAAMF,sBAAsBG,IAAAA,kBAAK,EAAC;IAACC,kBAAW;IAAEC,oBAAY;CAAC;AAO7D,MAAMJ,aAAaK,IAAAA,mBAAM,EAC9BC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,IAAI;IAC3BC,UAAUC,IAAAA,kBAAK,EAACd;IAChBe,MAAMC,IAAAA,mBAAM;AACd;AAgCK,MAAMd,OAAOe,IAAAA,sBAAa,EAACN,eAAQ,CAACC,IAAI,EAAEX,YAAY;IAC3D;IACA;CACD"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- HeadingStruct: function() {
13
- return HeadingStruct;
14
- },
15
- heading: function() {
16
- return heading;
17
- }
18
- });
19
- const _superstruct = require("superstruct");
20
- const _builder = require("../builder");
21
- const _nodes = require("../nodes");
22
- const HeadingStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
23
- type: (0, _superstruct.literal)(_nodes.NodeType.Heading),
24
- value: (0, _superstruct.string)()
25
- }));
26
- const heading = (0, _builder.createBuilder)(_nodes.NodeType.Heading, HeadingStruct, [
27
- 'value'
28
- ]);
29
-
30
- //# sourceMappingURL=heading.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/ui/components/heading.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, string } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const HeadingStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Heading),\n value: string(),\n }),\n);\n\n/**\n * A heading node, that renders the text as a heading. The level of the heading\n * is determined by the depth of the heading in the document.\n *\n * @property type - The type of the node, must be the string 'text'.\n * @property value - The text content of the node, either as plain text, or as a\n * markdown string.\n */\nexport type Heading = Infer<typeof HeadingStruct>;\n\n/**\n * Create a {@link Heading} node.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `value` property.\n * @param args.value - The heading text.\n * @returns The heading node as object.\n * @example\n * const node = heading({ value: 'Hello, world!' });\n * const node = heading('Hello, world!');\n */\nexport const heading = createBuilder(NodeType.Heading, HeadingStruct, [\n 'value',\n]);\n"],"names":["HeadingStruct","heading","assign","LiteralStruct","object","type","literal","NodeType","Heading","value","string","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IA6BAC,OAAO;eAAPA;;;6BAlCmC;yBAElB;uBACU;AAEjC,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;IAC9BC,OAAOC,IAAAA,mBAAM;AACf;AAwBK,MAAMT,UAAUU,IAAAA,sBAAa,EAACJ,eAAQ,CAACC,OAAO,EAAER,eAAe;IACpE;CACD"}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- svg: function() {
13
- return svg;
14
- },
15
- ImageStruct: function() {
16
- return ImageStruct;
17
- },
18
- image: function() {
19
- return image;
20
- }
21
- });
22
- const _issvg = /*#__PURE__*/ _interop_require_default(require("is-svg"));
23
- const _superstruct = require("superstruct");
24
- const _builder = require("../builder");
25
- const _nodes = require("../nodes");
26
- function _interop_require_default(obj) {
27
- return obj && obj.__esModule ? obj : {
28
- default: obj
29
- };
30
- }
31
- function svg() {
32
- return (0, _superstruct.refine)((0, _superstruct.string)(), 'SVG', (value)=>{
33
- if (!(0, _issvg.default)(value)) {
34
- return 'Value is not a valid SVG.';
35
- }
36
- return true;
37
- });
38
- }
39
- const ImageStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
40
- type: (0, _superstruct.literal)(_nodes.NodeType.Image),
41
- value: svg()
42
- }));
43
- const image = (0, _builder.createBuilder)(_nodes.NodeType.Image, ImageStruct, [
44
- 'value'
45
- ]);
46
-
47
- //# sourceMappingURL=image.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/ui/components/image.ts"],"sourcesContent":["import isSvg from 'is-svg';\nimport type { Infer } from 'superstruct';\nimport { assign, literal, object, refine, string } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\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 if (!isSvg(value)) {\n return 'Value is not a valid SVG.';\n }\n\n return true;\n });\n}\n\nexport const ImageStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Image),\n value: svg(),\n }),\n);\n\n/**\n * An image node, that renders an SVG image.\n *\n * @property type - The type of the node. Must be the string `image`.\n * @property value - The SVG image to be rendered.\n */\nexport type Image = Infer<typeof ImageStruct>;\n\n/**\n * Create an {@link Image} node.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `value` property.\n * @param args.value - The SVG image to be rendered. Must be a valid SVG string.\n * @returns The image node as object. Other image formats are supported by\n * embedding them as data URLs in the SVG.\n * @example\n * const node = image({ value: '<svg />' });\n * const node = image('<svg />');\n */\nexport const image = createBuilder(NodeType.Image, ImageStruct, ['value']);\n"],"names":["svg","ImageStruct","image","refine","string","value","isSvg","assign","NodeStruct","object","type","literal","NodeType","Image","createBuilder"],"mappings":";;;;;;;;;;;IAagBA,GAAG;eAAHA;;IAUHC,WAAW;eAAXA;;IA4BAC,KAAK;eAALA;;;8DAnDK;6BAEsC;yBAE1B;uBACO;;;;;;AAQ9B,SAASF;IACd,OAAOG,IAAAA,mBAAM,EAACC,IAAAA,mBAAM,KAAI,OAAO,CAACC;QAC9B,IAAI,CAACC,IAAAA,cAAK,EAACD,QAAQ;YACjB,OAAO;QACT;QAEA,OAAO;IACT;AACF;AAEO,MAAMJ,cAAcM,IAAAA,mBAAM,EAC/BC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,KAAK;IAC5BR,OAAOL;AACT;AAuBK,MAAME,QAAQY,IAAAA,sBAAa,EAACF,eAAQ,CAACC,KAAK,EAAEZ,aAAa;IAAC;CAAQ"}