@metamask/snaps-sdk 4.0.1 → 4.2.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 (72) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/dist/index.js +147 -6
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +162 -5
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/jsx/index.js +327 -0
  7. package/dist/jsx/index.js.map +1 -0
  8. package/dist/jsx/index.mjs +325 -0
  9. package/dist/jsx/index.mjs.map +1 -0
  10. package/dist/jsx/jsx-dev-runtime.js +217 -0
  11. package/dist/jsx/jsx-dev-runtime.js.map +1 -0
  12. package/dist/jsx/jsx-dev-runtime.mjs +215 -0
  13. package/dist/jsx/jsx-dev-runtime.mjs.map +1 -0
  14. package/dist/jsx/jsx-runtime.js +45 -0
  15. package/dist/jsx/jsx-runtime.js.map +1 -0
  16. package/dist/jsx/jsx-runtime.mjs +24 -0
  17. package/dist/jsx/jsx-runtime.mjs.map +1 -0
  18. package/dist/tsconfig.build.tsbuildinfo +1 -1
  19. package/dist/types/internals/index.d.ts +1 -0
  20. package/dist/types/internals/jsx.d.ts +31 -0
  21. package/dist/types/jsx/component.d.ts +66 -0
  22. package/dist/types/jsx/components/Address.d.ts +28 -0
  23. package/dist/types/jsx/components/Box.d.ts +27 -0
  24. package/dist/types/jsx/components/Copyable.d.ts +32 -0
  25. package/dist/types/jsx/components/Divider.d.ts +17 -0
  26. package/dist/types/jsx/components/Heading.d.ts +26 -0
  27. package/dist/types/jsx/components/Image.d.ts +36 -0
  28. package/dist/types/jsx/components/Link.d.ts +35 -0
  29. package/dist/types/jsx/components/Row.d.ts +41 -0
  30. package/dist/types/jsx/components/Spinner.d.ts +17 -0
  31. package/dist/types/jsx/components/Text.d.ts +33 -0
  32. package/dist/types/jsx/components/form/Button.d.ts +37 -0
  33. package/dist/types/jsx/components/form/Field.d.ts +34 -0
  34. package/dist/types/jsx/components/form/Form.d.ts +39 -0
  35. package/dist/types/jsx/components/form/Input.d.ts +37 -0
  36. package/dist/types/jsx/components/form/index.d.ts +9 -0
  37. package/dist/types/jsx/components/formatting/Bold.d.ts +32 -0
  38. package/dist/types/jsx/components/formatting/Italic.d.ts +34 -0
  39. package/dist/types/jsx/components/formatting/index.d.ts +5 -0
  40. package/dist/types/jsx/components/index.d.ts +28 -0
  41. package/dist/types/jsx/index.d.ts +5 -0
  42. package/dist/types/jsx/jsx-dev-runtime.d.ts +17 -0
  43. package/dist/types/jsx/jsx-runtime.d.ts +35 -0
  44. package/dist/types/jsx/validation.d.ts +110 -0
  45. package/dist/types/types/handlers/home-page.d.ts +2 -2
  46. package/dist/types/types/handlers/transaction.d.ts +2 -2
  47. package/dist/types/types/interface.d.ts +72 -0
  48. package/dist/types/types/methods/create-interface.d.ts +2 -2
  49. package/dist/types/types/methods/dialog.d.ts +4 -4
  50. package/dist/types/types/methods/update-interface.d.ts +2 -2
  51. package/dist/types/types/permissions.d.ts +2 -1
  52. package/dist/types/ui/components/address.d.ts +2 -0
  53. package/dist/types/ui/components/button.d.ts +2 -0
  54. package/dist/types/ui/components/copyable.d.ts +2 -0
  55. package/dist/types/ui/components/divider.d.ts +2 -0
  56. package/dist/types/ui/components/form.d.ts +9 -7
  57. package/dist/types/ui/components/heading.d.ts +2 -0
  58. package/dist/types/ui/components/image.d.ts +2 -0
  59. package/dist/types/ui/components/input.d.ts +5 -3
  60. package/dist/types/ui/components/panel.d.ts +88 -86
  61. package/dist/types/ui/components/row.d.ts +2 -0
  62. package/dist/types/ui/components/spinner.d.ts +2 -0
  63. package/dist/types/ui/components/text.d.ts +2 -0
  64. package/dist/types/ui/index.d.ts +0 -1
  65. package/dist/types/ui/nodes.d.ts +0 -5
  66. package/jsx-dev-runtime.d.ts +1 -0
  67. package/jsx-dev-runtime.js +5 -0
  68. package/jsx-runtime.d.ts +1 -0
  69. package/jsx-runtime.js +5 -0
  70. package/jsx.d.ts +1 -0
  71. package/jsx.js +5 -0
  72. package/package.json +27 -6
package/CHANGELOG.md CHANGED
@@ -6,6 +6,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [4.2.0]
10
+ ### Added
11
+ - Add support for BIP-32-Ed25519 / CIP-3 key derivation ([#2408](https://github.com/MetaMask/snaps/pull/2408))
12
+
13
+ ### Fixed
14
+ - Add missing TypeScript declarations for JSX entry points ([#2404](https://github.com/MetaMask/snaps/pull/2404))
15
+
16
+ ## [4.1.0]
17
+ ### Added
18
+ - Add JSX support for custom UI ([#2258](https://github.com/MetaMask/snaps/pull/2258), [#2379](https://github.com/MetaMask/snaps/pull/2379))
19
+ - It's now possible to use JSX components from this package to build user
20
+ interfaces for Snaps.
21
+ - This package now exports a custom JSX runtime that can be used to render
22
+ JSX components in Snaps. It can be used with the `react-jsx` and
23
+ `react-jsxdev` JSX pragmas, using `@metamask/snaps-sdk` as import source.
24
+ - When using `@metamask/snaps-cli` to build Snaps, the Snaps JSX runtime
25
+ will be used automatically.
26
+
27
+ ### Changed
28
+ - Deprecate legacy UI components ([#2388](https://github.com/MetaMask/snaps/pull/2388))
29
+ - Bump `@metamask/providers` from `16.0.0` to `16.1.0` ([#2386](https://github.com/MetaMask/snaps/pull/2386))
30
+
9
31
  ## [4.0.1]
10
32
  ### Fixed
11
33
  - Allow `null` in `FormSubmitEventStruct` form state ([#2333](https://github.com/MetaMask/snaps/pull/2333))
@@ -103,7 +125,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
103
125
  ### Added
104
126
  - Initial release of this package.
105
127
 
106
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.0.1...HEAD
128
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.2.0...HEAD
129
+ [4.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.1.0...@metamask/snaps-sdk@4.2.0
130
+ [4.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.0.1...@metamask/snaps-sdk@4.1.0
107
131
  [4.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.0.0...@metamask/snaps-sdk@4.0.1
108
132
  [4.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@3.2.0...@metamask/snaps-sdk@4.0.0
109
133
  [3.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@3.1.1...@metamask/snaps-sdk@3.2.0
package/dist/index.js CHANGED
@@ -45,6 +45,7 @@ __export(src_exports, {
45
45
  ButtonType: () => ButtonType,
46
46
  ButtonVariant: () => ButtonVariant,
47
47
  ChainDisconnectedError: () => ChainDisconnectedError,
48
+ ComponentOrElementStruct: () => ComponentOrElementStruct,
48
49
  ComponentStruct: () => ComponentStruct,
49
50
  CopyableStruct: () => CopyableStruct,
50
51
  DialogType: () => DialogType,
@@ -90,7 +91,7 @@ __export(src_exports, {
90
91
  UserInputEventType: () => UserInputEventType,
91
92
  UserRejectedRequestError: () => UserRejectedRequestError,
92
93
  address: () => address,
93
- assert: () => import_utils7.assert,
94
+ assert: () => import_utils8.assert,
94
95
  assertIsComponent: () => assertIsComponent,
95
96
  button: () => button,
96
97
  copyable: () => copyable,
@@ -305,6 +306,11 @@ function enumValue(constant) {
305
306
  return literal(constant);
306
307
  }
307
308
 
309
+ // src/internals/jsx.ts
310
+ function nullUnion(structs) {
311
+ return union(structs);
312
+ }
313
+
308
314
  // src/internals/svg.ts
309
315
  var import_utils2 = require("@metamask/utils");
310
316
  var import_fast_xml_parser = require("fast-xml-parser");
@@ -336,7 +342,7 @@ function isSvg(svg2) {
336
342
  }
337
343
 
338
344
  // src/index.ts
339
- var import_utils7 = require("@metamask/utils");
345
+ var import_utils8 = require("@metamask/utils");
340
346
 
341
347
  // src/error-wrappers.ts
342
348
  var import_rpc_errors = require("@metamask/rpc-errors");
@@ -810,10 +816,145 @@ var NotificationType = /* @__PURE__ */ ((NotificationType2) => {
810
816
  })(NotificationType || {});
811
817
 
812
818
  // src/types/interface.ts
819
+ var import_superstruct18 = require("superstruct");
820
+
821
+ // src/jsx/validation.ts
822
+ var import_utils7 = require("@metamask/utils");
813
823
  var import_superstruct17 = require("superstruct");
814
- var FormStateStruct = (0, import_superstruct17.record)((0, import_superstruct17.string)(), (0, import_superstruct17.nullable)((0, import_superstruct17.string)()));
815
- var InterfaceStateStruct = (0, import_superstruct17.record)(
816
- (0, import_superstruct17.string)(),
817
- (0, import_superstruct17.union)([FormStateStruct, (0, import_superstruct17.nullable)((0, import_superstruct17.string)())])
824
+ var KeyStruct = nullUnion([(0, import_superstruct17.string)(), (0, import_superstruct17.number)()]);
825
+ var StringElementStruct = maybeArray(
826
+ (0, import_superstruct17.string)()
827
+ );
828
+ var ElementStruct = (0, import_superstruct17.object)({
829
+ type: (0, import_superstruct17.string)(),
830
+ props: (0, import_superstruct17.record)((0, import_superstruct17.string)(), import_utils7.JsonStruct),
831
+ key: (0, import_superstruct17.nullable)(KeyStruct)
832
+ });
833
+ function maybeArray(struct) {
834
+ return nullUnion([struct, (0, import_superstruct17.array)(struct)]);
835
+ }
836
+ function element(name, props = {}) {
837
+ return (0, import_superstruct17.object)({
838
+ type: literal(name),
839
+ props: (0, import_superstruct17.object)(props),
840
+ key: (0, import_superstruct17.nullable)(KeyStruct)
841
+ });
842
+ }
843
+ var ButtonStruct2 = element("Button", {
844
+ children: StringElementStruct,
845
+ name: (0, import_superstruct17.optional)((0, import_superstruct17.string)()),
846
+ type: (0, import_superstruct17.optional)(nullUnion([literal("button"), literal("submit")])),
847
+ variant: (0, import_superstruct17.optional)(nullUnion([literal("primary"), literal("destructive")])),
848
+ disabled: (0, import_superstruct17.optional)((0, import_superstruct17.boolean)())
849
+ });
850
+ var InputStruct2 = element("Input", {
851
+ name: (0, import_superstruct17.string)(),
852
+ type: (0, import_superstruct17.optional)(
853
+ nullUnion([literal("text"), literal("password"), literal("number")])
854
+ ),
855
+ value: (0, import_superstruct17.optional)((0, import_superstruct17.string)()),
856
+ placeholder: (0, import_superstruct17.optional)((0, import_superstruct17.string)())
857
+ });
858
+ var FieldStruct = element("Field", {
859
+ label: (0, import_superstruct17.optional)((0, import_superstruct17.string)()),
860
+ error: (0, import_superstruct17.optional)((0, import_superstruct17.string)()),
861
+ children: InputStruct2
862
+ });
863
+ var FormStruct2 = element("Form", {
864
+ children: maybeArray(nullUnion([FieldStruct, ButtonStruct2])),
865
+ name: (0, import_superstruct17.string)()
866
+ });
867
+ var BoldStruct = element("Bold", {
868
+ children: maybeArray(
869
+ (0, import_superstruct17.nullable)(
870
+ nullUnion([
871
+ (0, import_superstruct17.string)(),
872
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
873
+ (0, import_superstruct17.lazy)(() => ItalicStruct)
874
+ ])
875
+ )
876
+ )
877
+ });
878
+ var ItalicStruct = element("Italic", {
879
+ children: maybeArray(
880
+ (0, import_superstruct17.nullable)(
881
+ nullUnion([
882
+ (0, import_superstruct17.string)(),
883
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
884
+ (0, import_superstruct17.lazy)(() => BoldStruct)
885
+ ])
886
+ )
887
+ )
888
+ });
889
+ var FormattingStruct = nullUnion([
890
+ BoldStruct,
891
+ ItalicStruct
892
+ ]);
893
+ var AddressStruct2 = element("Address", {
894
+ address: import_utils7.HexChecksumAddressStruct
895
+ });
896
+ var BoxStruct = element("Box", {
897
+ children: maybeArray(
898
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
899
+ (0, import_superstruct17.nullable)((0, import_superstruct17.lazy)(() => JSXElementStruct))
900
+ )
901
+ });
902
+ var CopyableStruct2 = element("Copyable", {
903
+ value: (0, import_superstruct17.string)(),
904
+ sensitive: (0, import_superstruct17.optional)((0, import_superstruct17.boolean)())
905
+ });
906
+ var DividerStruct2 = element("Divider");
907
+ var HeadingStruct2 = element("Heading", {
908
+ children: StringElementStruct
909
+ });
910
+ var ImageStruct2 = element("Image", {
911
+ src: (0, import_superstruct17.string)(),
912
+ alt: (0, import_superstruct17.optional)((0, import_superstruct17.string)())
913
+ });
914
+ var LinkStruct = element("Link", {
915
+ href: (0, import_superstruct17.string)(),
916
+ children: maybeArray((0, import_superstruct17.nullable)(nullUnion([FormattingStruct, (0, import_superstruct17.string)()])))
917
+ });
918
+ var TextStruct2 = element("Text", {
919
+ children: maybeArray(
920
+ (0, import_superstruct17.nullable)(nullUnion([(0, import_superstruct17.string)(), BoldStruct, ItalicStruct, LinkStruct]))
921
+ )
922
+ });
923
+ var RowStruct2 = element("Row", {
924
+ label: (0, import_superstruct17.string)(),
925
+ children: nullUnion([AddressStruct2, ImageStruct2, TextStruct2]),
926
+ variant: (0, import_superstruct17.optional)(
927
+ nullUnion([literal("default"), literal("warning"), literal("error")])
928
+ )
929
+ });
930
+ var SpinnerStruct2 = element("Spinner");
931
+ var JSXElementStruct = nullUnion([
932
+ ButtonStruct2,
933
+ InputStruct2,
934
+ FieldStruct,
935
+ FormStruct2,
936
+ BoldStruct,
937
+ ItalicStruct,
938
+ AddressStruct2,
939
+ BoxStruct,
940
+ CopyableStruct2,
941
+ DividerStruct2,
942
+ HeadingStruct2,
943
+ ImageStruct2,
944
+ LinkStruct,
945
+ RowStruct2,
946
+ SpinnerStruct2,
947
+ TextStruct2
948
+ ]);
949
+
950
+ // src/types/interface.ts
951
+ var FormStateStruct = (0, import_superstruct18.record)((0, import_superstruct18.string)(), (0, import_superstruct18.nullable)((0, import_superstruct18.string)()));
952
+ var InterfaceStateStruct = (0, import_superstruct18.record)(
953
+ (0, import_superstruct18.string)(),
954
+ (0, import_superstruct18.union)([FormStateStruct, (0, import_superstruct18.nullable)((0, import_superstruct18.string)())])
818
955
  );
956
+ var ComponentOrElementStruct = (0, import_superstruct18.union)([
957
+ ComponentStruct,
958
+ JSXElementStruct
959
+ ]);
819
960
  //# sourceMappingURL=index.js.map