@metamask/snaps-sdk 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- package/dist/index.js +148 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -6
- package/dist/index.mjs.map +1 -1
- package/dist/jsx/index.js +327 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +325 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/jsx-dev-runtime.js +217 -0
- package/dist/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx/jsx-dev-runtime.mjs +215 -0
- package/dist/jsx/jsx-dev-runtime.mjs.map +1 -0
- package/dist/jsx/jsx-runtime.js +45 -0
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx/jsx-runtime.mjs +24 -0
- package/dist/jsx/jsx-runtime.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/internals/index.d.ts +1 -0
- package/dist/types/internals/jsx.d.ts +31 -0
- package/dist/types/jsx/component.d.ts +66 -0
- package/dist/types/jsx/components/Address.d.ts +28 -0
- package/dist/types/jsx/components/Box.d.ts +27 -0
- package/dist/types/jsx/components/Copyable.d.ts +32 -0
- package/dist/types/jsx/components/Divider.d.ts +17 -0
- package/dist/types/jsx/components/Heading.d.ts +26 -0
- package/dist/types/jsx/components/Image.d.ts +36 -0
- package/dist/types/jsx/components/Link.d.ts +35 -0
- package/dist/types/jsx/components/Row.d.ts +41 -0
- package/dist/types/jsx/components/Spinner.d.ts +17 -0
- package/dist/types/jsx/components/Text.d.ts +33 -0
- package/dist/types/jsx/components/form/Button.d.ts +37 -0
- package/dist/types/jsx/components/form/Field.d.ts +34 -0
- package/dist/types/jsx/components/form/Form.d.ts +39 -0
- package/dist/types/jsx/components/form/Input.d.ts +37 -0
- package/dist/types/jsx/components/form/index.d.ts +9 -0
- package/dist/types/jsx/components/formatting/Bold.d.ts +32 -0
- package/dist/types/jsx/components/formatting/Italic.d.ts +34 -0
- package/dist/types/jsx/components/formatting/index.d.ts +5 -0
- package/dist/types/jsx/components/index.d.ts +28 -0
- package/dist/types/jsx/index.d.ts +5 -0
- package/dist/types/jsx/jsx-dev-runtime.d.ts +17 -0
- package/dist/types/jsx/jsx-runtime.d.ts +35 -0
- package/dist/types/jsx/validation.d.ts +110 -0
- package/dist/types/types/handlers/home-page.d.ts +2 -2
- package/dist/types/types/handlers/transaction.d.ts +2 -2
- package/dist/types/types/handlers/user-input.d.ts +4 -5
- package/dist/types/types/interface.d.ts +72 -0
- package/dist/types/types/methods/create-interface.d.ts +2 -2
- package/dist/types/types/methods/dialog.d.ts +4 -4
- package/dist/types/types/methods/update-interface.d.ts +2 -2
- package/dist/types/ui/components/address.d.ts +2 -0
- package/dist/types/ui/components/button.d.ts +2 -0
- package/dist/types/ui/components/copyable.d.ts +2 -0
- package/dist/types/ui/components/divider.d.ts +2 -0
- package/dist/types/ui/components/form.d.ts +9 -7
- package/dist/types/ui/components/heading.d.ts +2 -0
- package/dist/types/ui/components/image.d.ts +2 -0
- package/dist/types/ui/components/input.d.ts +5 -3
- package/dist/types/ui/components/panel.d.ts +88 -86
- package/dist/types/ui/components/row.d.ts +2 -0
- package/dist/types/ui/components/spinner.d.ts +2 -0
- package/dist/types/ui/components/text.d.ts +2 -0
- package/dist/types/ui/index.d.ts +0 -1
- package/dist/types/ui/nodes.d.ts +0 -5
- package/jsx-dev-runtime.js +5 -0
- package/jsx-runtime.js +5 -0
- package/jsx.js +5 -0
- package/package.json +23 -5
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [4.1.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Add JSX support for custom UI ([#2258](https://github.com/MetaMask/snaps/pull/2258), [#2379](https://github.com/MetaMask/snaps/pull/2379))
|
|
12
|
+
- It's now possible to use JSX components from this package to build user
|
|
13
|
+
interfaces for Snaps.
|
|
14
|
+
- This package now exports a custom JSX runtime that can be used to render
|
|
15
|
+
JSX components in Snaps. It can be used with the `react-jsx` and
|
|
16
|
+
`react-jsxdev` JSX pragmas, using `@metamask/snaps-sdk` as import source.
|
|
17
|
+
- When using `@metamask/snaps-cli` to build Snaps, the Snaps JSX runtime
|
|
18
|
+
will be used automatically.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Deprecate legacy UI components ([#2388](https://github.com/MetaMask/snaps/pull/2388))
|
|
22
|
+
- Bump `@metamask/providers` from `16.0.0` to `16.1.0` ([#2386](https://github.com/MetaMask/snaps/pull/2386))
|
|
23
|
+
|
|
24
|
+
## [4.0.1]
|
|
25
|
+
### Fixed
|
|
26
|
+
- Allow `null` in `FormSubmitEventStruct` form state ([#2333](https://github.com/MetaMask/snaps/pull/2333))
|
|
27
|
+
|
|
9
28
|
## [4.0.0]
|
|
10
29
|
### Removed
|
|
11
30
|
- **BREAKING:** Remove broken `ethereum` properties ([#2296](https://github.com/MetaMask/snaps/pull/2296))
|
|
@@ -99,7 +118,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
99
118
|
### Added
|
|
100
119
|
- Initial release of this package.
|
|
101
120
|
|
|
102
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.
|
|
121
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.1.0...HEAD
|
|
122
|
+
[4.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.0.1...@metamask/snaps-sdk@4.1.0
|
|
123
|
+
[4.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.0.0...@metamask/snaps-sdk@4.0.1
|
|
103
124
|
[4.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@3.2.0...@metamask/snaps-sdk@4.0.0
|
|
104
125
|
[3.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@3.1.1...@metamask/snaps-sdk@3.2.0
|
|
105
126
|
[3.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@3.1.0...@metamask/snaps-sdk@3.1.1
|
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: () =>
|
|
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
|
|
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");
|
|
@@ -760,7 +766,7 @@ var FormSubmitEventStruct = (0, import_superstruct16.assign)(
|
|
|
760
766
|
GenericEventStruct,
|
|
761
767
|
(0, import_superstruct16.object)({
|
|
762
768
|
type: (0, import_superstruct16.literal)("FormSubmitEvent" /* FormSubmitEvent */),
|
|
763
|
-
value: (0, import_superstruct16.record)((0, import_superstruct16.string)(), (0, import_superstruct16.string)()),
|
|
769
|
+
value: (0, import_superstruct16.record)((0, import_superstruct16.string)(), (0, import_superstruct16.nullable)((0, import_superstruct16.string)())),
|
|
764
770
|
name: (0, import_superstruct16.string)()
|
|
765
771
|
})
|
|
766
772
|
);
|
|
@@ -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
|
|
815
|
-
var
|
|
816
|
-
(0, import_superstruct17.string)()
|
|
817
|
-
|
|
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
|