Socket
Socket
Sign inDemoInstall

@metamask/snaps-sdk

Package Overview
Dependencies
Maintainers
11
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/snaps-sdk - npm Package Compare versions

Comparing version 6.0.0 to 6.1.0

dist/types/jsx/components/Card.d.ts

24

CHANGELOG.md

@@ -9,2 +9,23 @@ # Changelog

## [6.1.0]
### Added
- Add non-restricted RPC method `snap_resolveInterface` ([#2509](https://github.com/metamask/snaps/pull/2509))
- This method allows a Snap to resolve a given user interface bound to a `snap_dialog` with a custom value.
- Add new types `ResolveInterfaceParams`, `ResolveInterfaceResult`.
- Add `Card` component ([#2480](https://github.com/metamask/snaps/pull/2480))
- Add `BoxChildStruct`, `FormChildStruct`, `FieldChildUnionStruct` ([#2409](https://github.com/metamask/snaps/pull/2409))
- Add `Container` and `Footer` components ([#2517](https://github.com/metamask/snaps/pull/2517))
### Changed
- Update `RootJSXElement` to allow `Container` or `Box` at the root ([#2526](https://github.com/metamask/snaps/pull/2526))
- Bump `@metamask/key-tree` from `^9.1.1` to `^9.1.2` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
- Bump `@metamask/rpc-errors` from `^6.2.1` to `^6.3.1` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
- Bump `@metamask/utils` from `^8.3.0` to `^9.1.0` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
### Fixed
- Replace `superstruct` with ESM-compatible `@metamask/superstruct` `^3.1.0` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
- This fixes the issue of this package being unusable by any TypeScript project that uses `Node16` or `NodeNext` as its `moduleResolution` option.
- Set `@metamask/providers` from `^17.0.0` to `17.0.0` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
- `17.1.0` and `17.1.1` introduce regressions.
## [6.0.0]

@@ -185,3 +206,4 @@ ### Added

[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@6.0.0...HEAD
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@6.1.0...HEAD
[6.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@6.0.0...@metamask/snaps-sdk@6.1.0
[6.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@5.0.0...@metamask/snaps-sdk@6.0.0

@@ -188,0 +210,0 @@ [5.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.4.2...@metamask/snaps-sdk@5.0.0

198

dist/index.js

@@ -98,3 +98,3 @@ "use strict";

address: () => address,
assert: () => import_utils8.assert,
assert: () => import_utils9.assert,
assertIsComponent: () => assertIsComponent,

@@ -291,3 +291,4 @@ button: () => button,

// src/internals/structs.ts
var import_superstruct = require("superstruct");
var import_superstruct = require("@metamask/superstruct");
var import_utils2 = require("@metamask/utils");
function literal(value) {

@@ -312,2 +313,37 @@ return (0, import_superstruct.define)(

}
function typedUnion(structs) {
return new import_superstruct.Struct({
type: "union",
schema: null,
*entries(value, context) {
if (!(0, import_utils2.isPlainObject)(value) || !(0, import_utils2.hasProperty)(value, "type")) {
return;
}
const { type } = value;
const struct = structs.find(({ schema }) => (0, import_superstruct.is)(type, schema.type));
if (!struct) {
return;
}
for (const entry of struct.entries(value, context)) {
yield entry;
}
},
validator(value, context) {
const types = structs.map(({ schema }) => schema.type.type);
if (!(0, import_utils2.isPlainObject)(value) || !(0, import_utils2.hasProperty)(value, "type") || typeof value.type !== "string") {
return `Expected type to be one of: ${types.join(
", "
)}, but received: undefined`;
}
const { type } = value;
const struct = structs.find(({ schema }) => (0, import_superstruct.is)(type, schema.type));
if (struct) {
return struct.validator(value, context);
}
return `Expected type to be one of: ${types.join(
", "
)}, but received: "${type}"`;
}
});
}

@@ -320,3 +356,3 @@ // src/internals/jsx.ts

// src/internals/svg.ts
var import_superstruct2 = require("superstruct");
var import_superstruct2 = require("@metamask/superstruct");
function svg() {

@@ -332,3 +368,3 @@ return (0, import_superstruct2.refine)((0, import_superstruct2.string)(), "SVG", (value) => {

// src/index.ts
var import_utils8 = require("@metamask/utils");
var import_utils9 = require("@metamask/utils");

@@ -369,15 +405,15 @@ // src/error-wrappers.ts

// src/images.ts
var import_utils5 = require("@metamask/utils");
var import_utils6 = require("@metamask/utils");
// src/ui/components/address.ts
var import_utils3 = require("@metamask/utils");
var import_superstruct4 = require("superstruct");
var import_superstruct4 = require("@metamask/superstruct");
var import_utils4 = require("@metamask/utils");
// src/ui/builder.ts
var import_utils2 = require("@metamask/utils");
var import_utils3 = require("@metamask/utils");
function createBuilder(type, struct, keys = []) {
return (...args) => {
if (args.length === 1 && (0, import_utils2.isPlainObject)(args[0])) {
if (args.length === 1 && (0, import_utils3.isPlainObject)(args[0])) {
const node2 = { ...args[0], type };
(0, import_utils2.assertStruct)(node2, struct, `Invalid ${type} component`);
(0, import_utils3.assertStruct)(node2, struct, `Invalid ${type} component`);
return node2;

@@ -397,3 +433,3 @@ }

);
(0, import_utils2.assertStruct)(node, struct, `Invalid ${type} component`);
(0, import_utils3.assertStruct)(node, struct, `Invalid ${type} component`);
return node;

@@ -404,3 +440,3 @@ };

// src/ui/nodes.ts
var import_superstruct3 = require("superstruct");
var import_superstruct3 = require("@metamask/superstruct");
var NodeType = /* @__PURE__ */ ((NodeType2) => {

@@ -436,3 +472,3 @@ NodeType2["Copyable"] = "copyable";

type: (0, import_superstruct4.literal)("address" /* Address */),
value: import_utils3.HexChecksumAddressStruct
value: import_utils4.HexChecksumAddressStruct
})

@@ -445,3 +481,3 @@ );

// src/ui/components/copyable.ts
var import_superstruct5 = require("superstruct");
var import_superstruct5 = require("@metamask/superstruct");
var CopyableStruct = (0, import_superstruct5.assign)(

@@ -461,3 +497,3 @@ LiteralStruct,

// src/ui/components/divider.ts
var import_superstruct6 = require("superstruct");
var import_superstruct6 = require("@metamask/superstruct");
var DividerStruct = (0, import_superstruct6.assign)(

@@ -472,3 +508,3 @@ NodeStruct,

// src/ui/components/heading.ts
var import_superstruct7 = require("superstruct");
var import_superstruct7 = require("@metamask/superstruct");
var HeadingStruct = (0, import_superstruct7.assign)(

@@ -486,3 +522,3 @@ LiteralStruct,

// src/ui/components/image.ts
var import_superstruct8 = require("superstruct");
var import_superstruct8 = require("@metamask/superstruct");
var ImageStruct = (0, import_superstruct8.assign)(

@@ -498,6 +534,6 @@ NodeStruct,

// src/ui/components/panel.ts
var import_superstruct15 = require("superstruct");
var import_superstruct15 = require("@metamask/superstruct");
// src/ui/components/button.ts
var import_superstruct9 = require("superstruct");
var import_superstruct9 = require("@metamask/superstruct");
var ButtonVariant = /* @__PURE__ */ ((ButtonVariant2) => {

@@ -538,6 +574,6 @@ ButtonVariant2["Primary"] = "primary";

// src/ui/components/form.ts
var import_superstruct11 = require("superstruct");
var import_superstruct11 = require("@metamask/superstruct");
// src/ui/components/input.ts
var import_superstruct10 = require("superstruct");
var import_superstruct10 = require("@metamask/superstruct");
var InputType = /* @__PURE__ */ ((InputType2) => {

@@ -591,6 +627,6 @@ InputType2["Text"] = "text";

// src/ui/components/row.ts
var import_superstruct13 = require("superstruct");
var import_superstruct13 = require("@metamask/superstruct");
// src/ui/components/text.ts
var import_superstruct12 = require("superstruct");
var import_superstruct12 = require("@metamask/superstruct");
var TextStruct = (0, import_superstruct12.assign)(

@@ -639,3 +675,3 @@ LiteralStruct,

// src/ui/components/spinner.ts
var import_superstruct14 = require("superstruct");
var import_superstruct14 = require("@metamask/superstruct");
var SpinnerStruct = (0, import_superstruct14.assign)(

@@ -665,3 +701,3 @@ NodeStruct,

var panel = createBuilder("panel" /* Panel */, PanelStruct, ["children"]);
var ComponentStruct = (0, import_superstruct15.union)([
var ComponentStruct = typedUnion([
CopyableStruct,

@@ -682,4 +718,4 @@ DividerStruct,

// src/ui/component.ts
var import_utils4 = require("@metamask/utils");
var import_superstruct16 = require("superstruct");
var import_superstruct16 = require("@metamask/superstruct");
var import_utils5 = require("@metamask/utils");
function isComponent(value) {

@@ -689,3 +725,3 @@ return (0, import_superstruct16.is)(value, ComponentStruct);

function assertIsComponent(value) {
(0, import_utils4.assertStruct)(value, ComponentStruct, "Invalid component");
(0, import_utils5.assertStruct)(value, ComponentStruct, "Invalid component");
}

@@ -707,3 +743,3 @@

const blob = await response.blob();
(0, import_utils5.assert)(
(0, import_utils6.assert)(
blob.type === "image/jpeg" || blob.type === "image/png",

@@ -718,10 +754,10 @@ "Expected image data to be a JPEG or PNG image."

const bytes = new Uint8Array(await blob.arrayBuffer());
return `data:${blob.type};base64,${(0, import_utils5.bytesToBase64)(bytes)}`;
return `data:${blob.type};base64,${(0, import_utils6.bytesToBase64)(bytes)}`;
}
async function getImageComponent(url, { width, height = width, request }) {
(0, import_utils5.assert)(
(0, import_utils6.assert)(
typeof width === "number" && width > 0,
"Expected width to be a number greater than 0."
);
(0, import_utils5.assert)(
(0, import_utils6.assert)(
typeof height === "number" && height > 0,

@@ -744,3 +780,3 @@ "Expected height to be a number greater than 0."

// src/types/handlers/user-input.ts
var import_superstruct17 = require("superstruct");
var import_superstruct17 = require("@metamask/superstruct");
var UserInputEventType = /* @__PURE__ */ ((UserInputEventType2) => {

@@ -833,8 +869,8 @@ UserInputEventType2["ButtonClickEvent"] = "ButtonClickEvent";

// src/types/interface.ts
var import_utils7 = require("@metamask/utils");
var import_superstruct19 = require("superstruct");
var import_superstruct19 = require("@metamask/superstruct");
var import_utils8 = require("@metamask/utils");
// src/jsx/validation.ts
var import_utils6 = require("@metamask/utils");
var import_superstruct18 = require("superstruct");
var import_superstruct18 = require("@metamask/superstruct");
var import_utils7 = require("@metamask/utils");
var KeyStruct = nullUnion([(0, import_superstruct18.string)(), (0, import_superstruct18.number)()]);

@@ -846,3 +882,3 @@ var StringElementStruct = children([

type: (0, import_superstruct18.string)(),
props: (0, import_superstruct18.record)((0, import_superstruct18.string)(), import_utils6.JsonStruct),
props: (0, import_superstruct18.record)((0, import_superstruct18.string)(), import_utils7.JsonStruct),
key: (0, import_superstruct18.nullable)(KeyStruct)

@@ -905,18 +941,28 @@ });

);
var BUTTON_INPUT = [InputStruct2, ButtonStruct2];
var FIELD_CHILDREN_ARRAY = [
InputStruct2,
DropdownStruct,
FileInputStruct,
CheckboxStruct
];
var FieldChildUnionStruct = nullUnion([
...FIELD_CHILDREN_ARRAY,
...BUTTON_INPUT
]);
var FieldChildStruct = nullUnion([
(0, import_superstruct18.tuple)(BUTTON_INPUT),
...FIELD_CHILDREN_ARRAY
]);
var FieldStruct = element("Field", {
label: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
error: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
children: nullUnion([
(0, import_superstruct18.tuple)([InputStruct2, ButtonStruct2]),
DropdownStruct,
FileInputStruct,
InputStruct2,
CheckboxStruct
])
children: FieldChildStruct
});
var FormChildStruct = children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[FieldStruct, (0, import_superstruct18.lazy)(() => BoxChildStruct)]
);
var FormStruct2 = element("Form", {
children: children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[FieldStruct, (0, import_superstruct18.lazy)(() => BoxChildStruct)]
),
children: FormChildStruct,
name: (0, import_superstruct18.string)()

@@ -943,9 +989,10 @@ });

var AddressStruct2 = element("Address", {
address: import_utils6.HexChecksumAddressStruct
address: import_utils7.HexChecksumAddressStruct
});
var BoxChildrenStruct = children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[(0, import_superstruct18.lazy)(() => BoxChildStruct)]
);
var BoxStruct = element("Box", {
children: children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[(0, import_superstruct18.lazy)(() => BoxChildStruct)]
),
children: BoxChildrenStruct,
direction: (0, import_superstruct18.optional)(nullUnion([literal("horizontal"), literal("vertical")])),

@@ -962,2 +1009,19 @@ alignment: (0, import_superstruct18.optional)(

});
var FooterChildStruct = nullUnion([
(0, import_superstruct18.tuple)([ButtonStruct2, ButtonStruct2]),
ButtonStruct2
]);
var FooterStruct = element("Footer", {
children: FooterChildStruct
});
var ContainerChildStruct = nullUnion([
(0, import_superstruct18.tuple)([BoxStruct, FooterStruct]),
BoxStruct
]);
var ContainerStruct = element(
"Container",
{
children: ContainerChildStruct
}
);
var CopyableStruct2 = element("Copyable", {

@@ -972,2 +1036,9 @@ value: (0, import_superstruct18.string)(),

});
var CardStruct = element("Card", {
image: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
title: (0, import_superstruct18.string)(),
description: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
value: (0, import_superstruct18.string)(),
extra: (0, import_superstruct18.optional)((0, import_superstruct18.string)())
});
var HeadingStruct2 = element("Heading", {

@@ -1018,3 +1089,3 @@ children: StringElementStruct

var SpinnerStruct2 = element("Spinner");
var BoxChildStruct = nullUnion([
var BoxChildStruct = typedUnion([
AddressStruct2,

@@ -1038,6 +1109,10 @@ BoldStruct,

TooltipStruct,
CheckboxStruct
CheckboxStruct,
CardStruct
]);
var RootJSXElementStruct = BoxChildStruct;
var JSXElementStruct = nullUnion([
var RootJSXElementStruct = nullUnion([
BoxChildStruct,
ContainerStruct
]);
var JSXElementStruct = typedUnion([
ButtonStruct2,

@@ -1064,3 +1139,6 @@ InputStruct2,

TooltipStruct,
CheckboxStruct
CheckboxStruct,
FooterStruct,
ContainerStruct,
CardStruct
]);

@@ -1079,3 +1157,3 @@

]);
var InterfaceContextStruct = (0, import_superstruct19.record)((0, import_superstruct19.string)(), import_utils7.JsonStruct);
var InterfaceContextStruct = (0, import_superstruct19.record)((0, import_superstruct19.string)(), import_utils8.JsonStruct);
//# sourceMappingURL=index.js.map

@@ -26,4 +26,7 @@ "use strict";

Box: () => Box,
BoxChildStruct: () => BoxChildStruct,
Button: () => Button,
Card: () => Card,
Checkbox: () => Checkbox,
Container: () => Container,
Copyable: () => Copyable,

@@ -33,4 +36,7 @@ Divider: () => Divider,

Field: () => Field,
FieldChildUnionStruct: () => FieldChildUnionStruct,
FileInput: () => FileInput,
Footer: () => Footer,
Form: () => Form,
FormChildStruct: () => FormChildStruct,
Heading: () => Heading,

@@ -124,42 +130,54 @@ Image: () => Image,

// src/jsx/components/Card.ts
var TYPE13 = "Card";
var Card = createSnapComponent(TYPE13);
// src/jsx/components/Copyable.ts
var TYPE13 = "Copyable";
var Copyable = createSnapComponent(TYPE13);
var TYPE14 = "Copyable";
var Copyable = createSnapComponent(TYPE14);
// src/jsx/components/Divider.ts
var TYPE14 = "Divider";
var Divider = createSnapComponent(TYPE14);
var TYPE15 = "Divider";
var Divider = createSnapComponent(TYPE15);
// src/jsx/components/Value.ts
var TYPE15 = "Value";
var Value = createSnapComponent(TYPE15);
var TYPE16 = "Value";
var Value = createSnapComponent(TYPE16);
// src/jsx/components/Heading.ts
var TYPE16 = "Heading";
var Heading = createSnapComponent(TYPE16);
var TYPE17 = "Heading";
var Heading = createSnapComponent(TYPE17);
// src/jsx/components/Image.ts
var TYPE17 = "Image";
var Image = createSnapComponent(TYPE17);
var TYPE18 = "Image";
var Image = createSnapComponent(TYPE18);
// src/jsx/components/Link.ts
var TYPE18 = "Link";
var Link = createSnapComponent(TYPE18);
var TYPE19 = "Link";
var Link = createSnapComponent(TYPE19);
// src/jsx/components/Row.ts
var TYPE19 = "Row";
var Row = createSnapComponent(TYPE19);
var TYPE20 = "Row";
var Row = createSnapComponent(TYPE20);
// src/jsx/components/Spinner.ts
var TYPE20 = "Spinner";
var Spinner = createSnapComponent(TYPE20);
var TYPE21 = "Spinner";
var Spinner = createSnapComponent(TYPE21);
// src/jsx/components/Text.ts
var TYPE21 = "Text";
var Text = createSnapComponent(TYPE21);
var TYPE22 = "Text";
var Text = createSnapComponent(TYPE22);
// src/jsx/components/Tooltip.ts
var TYPE22 = "Tooltip";
var Tooltip = createSnapComponent(TYPE22);
var TYPE23 = "Tooltip";
var Tooltip = createSnapComponent(TYPE23);
// src/jsx/components/Footer.ts
var TYPE24 = "Footer";
var Footer = createSnapComponent(TYPE24);
// src/jsx/components/Container.ts
var TYPE25 = "Container";
var Container = createSnapComponent(TYPE25);
// src/jsx/jsx-runtime.ts

@@ -186,7 +204,8 @@ function jsx(component, props, key) {

// src/jsx/validation.ts
var import_utils = require("@metamask/utils");
var import_superstruct3 = require("superstruct");
var import_superstruct3 = require("@metamask/superstruct");
var import_utils2 = require("@metamask/utils");
// src/internals/structs.ts
var import_superstruct = require("superstruct");
var import_superstruct = require("@metamask/superstruct");
var import_utils = require("@metamask/utils");
function literal(value) {

@@ -208,2 +227,37 @@ return (0, import_superstruct.define)(

}
function typedUnion(structs) {
return new import_superstruct.Struct({
type: "union",
schema: null,
*entries(value, context) {
if (!(0, import_utils.isPlainObject)(value) || !(0, import_utils.hasProperty)(value, "type")) {
return;
}
const { type } = value;
const struct = structs.find(({ schema }) => (0, import_superstruct.is)(type, schema.type));
if (!struct) {
return;
}
for (const entry of struct.entries(value, context)) {
yield entry;
}
},
validator(value, context) {
const types = structs.map(({ schema }) => schema.type.type);
if (!(0, import_utils.isPlainObject)(value) || !(0, import_utils.hasProperty)(value, "type") || typeof value.type !== "string") {
return `Expected type to be one of: ${types.join(
", "
)}, but received: undefined`;
}
const { type } = value;
const struct = structs.find(({ schema }) => (0, import_superstruct.is)(type, schema.type));
if (struct) {
return struct.validator(value, context);
}
return `Expected type to be one of: ${types.join(
", "
)}, but received: "${type}"`;
}
});
}

@@ -216,3 +270,3 @@ // src/internals/jsx.ts

// src/internals/svg.ts
var import_superstruct2 = require("superstruct");
var import_superstruct2 = require("@metamask/superstruct");
function svg() {

@@ -234,3 +288,3 @@ return (0, import_superstruct2.refine)((0, import_superstruct2.string)(), "SVG", (value) => {

type: (0, import_superstruct3.string)(),
props: (0, import_superstruct3.record)((0, import_superstruct3.string)(), import_utils.JsonStruct),
props: (0, import_superstruct3.record)((0, import_superstruct3.string)(), import_utils2.JsonStruct),
key: (0, import_superstruct3.nullable)(KeyStruct)

@@ -293,18 +347,28 @@ });

);
var BUTTON_INPUT = [InputStruct, ButtonStruct];
var FIELD_CHILDREN_ARRAY = [
InputStruct,
DropdownStruct,
FileInputStruct,
CheckboxStruct
];
var FieldChildUnionStruct = nullUnion([
...FIELD_CHILDREN_ARRAY,
...BUTTON_INPUT
]);
var FieldChildStruct = nullUnion([
(0, import_superstruct3.tuple)(BUTTON_INPUT),
...FIELD_CHILDREN_ARRAY
]);
var FieldStruct = element("Field", {
label: (0, import_superstruct3.optional)((0, import_superstruct3.string)()),
error: (0, import_superstruct3.optional)((0, import_superstruct3.string)()),
children: nullUnion([
(0, import_superstruct3.tuple)([InputStruct, ButtonStruct]),
DropdownStruct,
FileInputStruct,
InputStruct,
CheckboxStruct
])
children: FieldChildStruct
});
var FormChildStruct = children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[FieldStruct, (0, import_superstruct3.lazy)(() => BoxChildStruct)]
);
var FormStruct = element("Form", {
children: children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[FieldStruct, (0, import_superstruct3.lazy)(() => BoxChildStruct)]
),
children: FormChildStruct,
name: (0, import_superstruct3.string)()

@@ -331,9 +395,10 @@ });

var AddressStruct = element("Address", {
address: import_utils.HexChecksumAddressStruct
address: import_utils2.HexChecksumAddressStruct
});
var BoxChildrenStruct = children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[(0, import_superstruct3.lazy)(() => BoxChildStruct)]
);
var BoxStruct = element("Box", {
children: children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[(0, import_superstruct3.lazy)(() => BoxChildStruct)]
),
children: BoxChildrenStruct,
direction: (0, import_superstruct3.optional)(nullUnion([literal("horizontal"), literal("vertical")])),

@@ -350,2 +415,19 @@ alignment: (0, import_superstruct3.optional)(

});
var FooterChildStruct = nullUnion([
(0, import_superstruct3.tuple)([ButtonStruct, ButtonStruct]),
ButtonStruct
]);
var FooterStruct = element("Footer", {
children: FooterChildStruct
});
var ContainerChildStruct = nullUnion([
(0, import_superstruct3.tuple)([BoxStruct, FooterStruct]),
BoxStruct
]);
var ContainerStruct = element(
"Container",
{
children: ContainerChildStruct
}
);
var CopyableStruct = element("Copyable", {

@@ -360,2 +442,9 @@ value: (0, import_superstruct3.string)(),

});
var CardStruct = element("Card", {
image: (0, import_superstruct3.optional)((0, import_superstruct3.string)()),
title: (0, import_superstruct3.string)(),
description: (0, import_superstruct3.optional)((0, import_superstruct3.string)()),
value: (0, import_superstruct3.string)(),
extra: (0, import_superstruct3.optional)((0, import_superstruct3.string)())
});
var HeadingStruct = element("Heading", {

@@ -406,3 +495,3 @@ children: StringElementStruct

var SpinnerStruct = element("Spinner");
var BoxChildStruct = nullUnion([
var BoxChildStruct = typedUnion([
AddressStruct,

@@ -426,6 +515,10 @@ BoldStruct,

TooltipStruct,
CheckboxStruct
CheckboxStruct,
CardStruct
]);
var RootJSXElementStruct = BoxChildStruct;
var JSXElementStruct = nullUnion([
var RootJSXElementStruct = nullUnion([
BoxChildStruct,
ContainerStruct
]);
var JSXElementStruct = typedUnion([
ButtonStruct,

@@ -452,3 +545,6 @@ InputStruct,

TooltipStruct,
CheckboxStruct
CheckboxStruct,
FooterStruct,
ContainerStruct,
CardStruct
]);

@@ -459,3 +555,3 @@ function isJSXElement(value) {

function isJSXElementUnsafe(value) {
return (0, import_utils.isPlainObject)(value) && (0, import_utils.hasProperty)(value, "type") && (0, import_utils.hasProperty)(value, "props") && (0, import_utils.hasProperty)(value, "key");
return (0, import_utils2.isPlainObject)(value) && (0, import_utils2.hasProperty)(value, "type") && (0, import_utils2.hasProperty)(value, "props") && (0, import_utils2.hasProperty)(value, "key");
}

@@ -462,0 +558,0 @@ function assertJSXElement(value) {

@@ -45,7 +45,8 @@ "use strict";

// src/jsx/validation.ts
var import_utils = require("@metamask/utils");
var import_superstruct3 = require("superstruct");
var import_superstruct3 = require("@metamask/superstruct");
var import_utils2 = require("@metamask/utils");
// src/internals/structs.ts
var import_superstruct = require("superstruct");
var import_superstruct = require("@metamask/superstruct");
var import_utils = require("@metamask/utils");
function literal(value) {

@@ -67,2 +68,37 @@ return (0, import_superstruct.define)(

}
function typedUnion(structs) {
return new import_superstruct.Struct({
type: "union",
schema: null,
*entries(value, context) {
if (!(0, import_utils.isPlainObject)(value) || !(0, import_utils.hasProperty)(value, "type")) {
return;
}
const { type } = value;
const struct = structs.find(({ schema }) => (0, import_superstruct.is)(type, schema.type));
if (!struct) {
return;
}
for (const entry of struct.entries(value, context)) {
yield entry;
}
},
validator(value, context) {
const types = structs.map(({ schema }) => schema.type.type);
if (!(0, import_utils.isPlainObject)(value) || !(0, import_utils.hasProperty)(value, "type") || typeof value.type !== "string") {
return `Expected type to be one of: ${types.join(
", "
)}, but received: undefined`;
}
const { type } = value;
const struct = structs.find(({ schema }) => (0, import_superstruct.is)(type, schema.type));
if (struct) {
return struct.validator(value, context);
}
return `Expected type to be one of: ${types.join(
", "
)}, but received: "${type}"`;
}
});
}

@@ -75,3 +111,3 @@ // src/internals/jsx.ts

// src/internals/svg.ts
var import_superstruct2 = require("superstruct");
var import_superstruct2 = require("@metamask/superstruct");
function svg() {

@@ -93,3 +129,3 @@ return (0, import_superstruct2.refine)((0, import_superstruct2.string)(), "SVG", (value) => {

type: (0, import_superstruct3.string)(),
props: (0, import_superstruct3.record)((0, import_superstruct3.string)(), import_utils.JsonStruct),
props: (0, import_superstruct3.record)((0, import_superstruct3.string)(), import_utils2.JsonStruct),
key: (0, import_superstruct3.nullable)(KeyStruct)

@@ -152,18 +188,28 @@ });

);
var BUTTON_INPUT = [InputStruct, ButtonStruct];
var FIELD_CHILDREN_ARRAY = [
InputStruct,
DropdownStruct,
FileInputStruct,
CheckboxStruct
];
var FieldChildUnionStruct = nullUnion([
...FIELD_CHILDREN_ARRAY,
...BUTTON_INPUT
]);
var FieldChildStruct = nullUnion([
(0, import_superstruct3.tuple)(BUTTON_INPUT),
...FIELD_CHILDREN_ARRAY
]);
var FieldStruct = element("Field", {
label: (0, import_superstruct3.optional)((0, import_superstruct3.string)()),
error: (0, import_superstruct3.optional)((0, import_superstruct3.string)()),
children: nullUnion([
(0, import_superstruct3.tuple)([InputStruct, ButtonStruct]),
DropdownStruct,
FileInputStruct,
InputStruct,
CheckboxStruct
])
children: FieldChildStruct
});
var FormChildStruct = children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[FieldStruct, (0, import_superstruct3.lazy)(() => BoxChildStruct)]
);
var FormStruct = element("Form", {
children: children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[FieldStruct, (0, import_superstruct3.lazy)(() => BoxChildStruct)]
),
children: FormChildStruct,
name: (0, import_superstruct3.string)()

@@ -190,9 +236,10 @@ });

var AddressStruct = element("Address", {
address: import_utils.HexChecksumAddressStruct
address: import_utils2.HexChecksumAddressStruct
});
var BoxChildrenStruct = children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[(0, import_superstruct3.lazy)(() => BoxChildStruct)]
);
var BoxStruct = element("Box", {
children: children(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
[(0, import_superstruct3.lazy)(() => BoxChildStruct)]
),
children: BoxChildrenStruct,
direction: (0, import_superstruct3.optional)(nullUnion([literal("horizontal"), literal("vertical")])),

@@ -209,2 +256,19 @@ alignment: (0, import_superstruct3.optional)(

});
var FooterChildStruct = nullUnion([
(0, import_superstruct3.tuple)([ButtonStruct, ButtonStruct]),
ButtonStruct
]);
var FooterStruct = element("Footer", {
children: FooterChildStruct
});
var ContainerChildStruct = nullUnion([
(0, import_superstruct3.tuple)([BoxStruct, FooterStruct]),
BoxStruct
]);
var ContainerStruct = element(
"Container",
{
children: ContainerChildStruct
}
);
var CopyableStruct = element("Copyable", {

@@ -219,2 +283,9 @@ value: (0, import_superstruct3.string)(),

});
var CardStruct = element("Card", {
image: (0, import_superstruct3.optional)((0, import_superstruct3.string)()),
title: (0, import_superstruct3.string)(),
description: (0, import_superstruct3.optional)((0, import_superstruct3.string)()),
value: (0, import_superstruct3.string)(),
extra: (0, import_superstruct3.optional)((0, import_superstruct3.string)())
});
var HeadingStruct = element("Heading", {

@@ -265,3 +336,3 @@ children: StringElementStruct

var SpinnerStruct = element("Spinner");
var BoxChildStruct = nullUnion([
var BoxChildStruct = typedUnion([
AddressStruct,

@@ -285,5 +356,10 @@ BoldStruct,

TooltipStruct,
CheckboxStruct
CheckboxStruct,
CardStruct
]);
var JSXElementStruct = nullUnion([
var RootJSXElementStruct = nullUnion([
BoxChildStruct,
ContainerStruct
]);
var JSXElementStruct = typedUnion([
ButtonStruct,

@@ -310,3 +386,6 @@ InputStruct,

TooltipStruct,
CheckboxStruct
CheckboxStruct,
FooterStruct,
ContainerStruct,
CardStruct
]);

@@ -313,0 +392,0 @@ function isJSXElement(value) {

@@ -1,3 +0,2 @@

import type { Infer, Struct } from 'superstruct';
import type { AnyStruct, EnumSchema, InferStructTuple, IsExactMatch, IsMatch, IsRecord, IsTuple, UnionToIntersection } from 'superstruct/dist/utils';
import type { AnyStruct, EnumSchema, Infer, InferStructTuple, IsExactMatch, IsMatch, IsRecord, IsTuple, Struct, UnionToIntersection } from '@metamask/superstruct';
import type { EmptyObject } from '../types';

@@ -4,0 +3,0 @@ /**

@@ -1,4 +0,3 @@

import type { Infer } from 'superstruct';
import { Struct } from 'superstruct';
import type { AnyStruct, InferStructTuple } from 'superstruct/dist/utils';
import type { AnyStruct, Infer, InferStructTuple } from '@metamask/superstruct';
import { Struct } from '@metamask/superstruct';
import type { EnumToUnion } from './helpers';

@@ -51,1 +50,11 @@ /**

export declare function enumValue<Type extends string>(constant: Type): Struct<EnumToUnion<Type>, null>;
/**
* Create a custom union struct that validates exclusively based on a `type` field.
*
* This should improve error messaging for unions with many structs in them.
*
* @param structs - The structs to union.
* @returns The `superstruct` struct, which validates that the value satisfies
* one of the structs.
*/
export declare function typedUnion<Head extends AnyStruct, Tail extends AnyStruct[]>(structs: [head: Head, ...tail: Tail]): Struct<Infer<Head> | InferStructTuple<Tail>[number], null>;

@@ -7,2 +7,2 @@ /**

*/
export declare function svg(): import("superstruct").Struct<string, null>;
export declare function svg(): import("@metamask/superstruct").Struct<string, null>;
import type { AddressElement } from './Address';
import type { BoxElement } from './Box';
import type { CardElement } from './Card';
import type { ContainerElement } from './Container';
import type { CopyableElement } from './Copyable';
import type { DividerElement } from './Divider';
import type { FooterElement } from './Footer';
import type { StandardFormElement } from './form';

@@ -19,2 +22,3 @@ import type { StandardFormattingElement } from './formatting';

export * from './Box';
export * from './Card';
export * from './Copyable';

@@ -30,5 +34,7 @@ export * from './Divider';

export * from './Tooltip';
export * from './Footer';
export * from './Container';
/**
* A built-in JSX element, which can be used in a Snap user interface.
*/
export declare type JSXElement = StandardFormElement | StandardFormattingElement | AddressElement | BoxElement | CopyableElement | DividerElement | ValueElement | HeadingElement | ImageElement | LinkElement | RowElement | SpinnerElement | TextElement | TooltipElement;
export declare type JSXElement = StandardFormElement | StandardFormattingElement | AddressElement | BoxElement | CardElement | ContainerElement | CopyableElement | DividerElement | FooterElement | ValueElement | HeadingElement | ImageElement | LinkElement | RowElement | SpinnerElement | TextElement | TooltipElement;

@@ -5,2 +5,2 @@ export * from './component';

export * from './jsx-dev-runtime';
export { JSXElementStruct, RootJSXElementStruct, isJSXElement, isJSXElementUnsafe, assertJSXElement, } from './validation';
export { JSXElementStruct, RootJSXElementStruct, isJSXElement, isJSXElementUnsafe, assertJSXElement, BoxChildStruct, FormChildStruct, FieldChildUnionStruct, } from './validation';

@@ -1,5 +0,5 @@

import type { Struct } from 'superstruct';
import type { Struct } from '@metamask/superstruct';
import type { Describe } from '../internals';
import type { GenericSnapElement, Key, SnapElement, StringElement } from './component';
import type { AddressElement, BoldElement, BoxElement, ButtonElement, CheckboxElement, CopyableElement, DividerElement, DropdownElement, OptionElement, FieldElement, FormElement, HeadingElement, ImageElement, InputElement, ItalicElement, JSXElement, LinkElement, RowElement, SpinnerElement, StandardFormattingElement, TextElement, TooltipElement, ValueElement, FileInputElement } from './components';
import type { GenericSnapElement, Key, SnapElement, SnapsChildren, StringElement } from './component';
import type { AddressElement, BoldElement, BoxElement, ButtonElement, CheckboxElement, CardElement, CopyableElement, DividerElement, DropdownElement, OptionElement, FieldElement, FormElement, HeadingElement, ImageElement, InputElement, ItalicElement, JSXElement, LinkElement, RowElement, SpinnerElement, StandardFormattingElement, TextElement, TooltipElement, ValueElement, FileInputElement, ContainerElement, FooterElement } from './components';
/**

@@ -42,2 +42,7 @@ * A struct for the {@link Key} type.

/**
* A union of the allowed children of the Field component.
* This is mainly used in the simulator for validation purposes.
*/
export declare const FieldChildUnionStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").CheckboxProps, "Checkbox"> | SnapElement<import("./components").InputProps, "Input"> | SnapElement<import("./components").DropdownProps, "Dropdown"> | SnapElement<import("./components").FileInputProps, "FileInput">, null>;
/**
* A struct for the {@link FieldElement} type.

@@ -47,2 +52,6 @@ */

/**
* A subset of JSX elements that are allowed as children of the Form component.
*/
export declare const FormChildStruct: Struct<SnapsChildren<GenericSnapElement>, null>;
/**
* A struct for the {@link FormElement} type.

@@ -64,2 +73,3 @@ */

export declare const AddressStruct: Describe<AddressElement>;
export declare const BoxChildrenStruct: Struct<SnapsChildren<GenericSnapElement>, null>;
/**

@@ -70,2 +80,20 @@ * A struct for the {@link BoxElement} type.

/**
* A subset of JSX elements that are allowed as children of the Footer component.
* This set should include a single button or a tuple of two buttons.
*/
export declare const FooterChildStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | [SnapElement<import("./components").ButtonProps, "Button">, SnapElement<import("./components").ButtonProps, "Button">], null>;
/**
* A struct for the {@link FooterElement} type.
*/
export declare const FooterStruct: Describe<FooterElement>;
/**
* A subset of JSX elements that are allowed as children of the Container component.
* This set should include a single Box or a tuple of a Box and a Footer component.
*/
export declare const ContainerChildStruct: Struct<SnapElement<import("./components").BoxProps, "Box"> | [SnapElement<import("./components").BoxProps, "Box">, SnapElement<import("./components").FooterProps, "Footer">], null>;
/**
* A struct for the {@link ContainerElement} type.
*/
export declare const ContainerStruct: Describe<ContainerElement>;
/**
* A struct for the {@link CopyableElement} type.

@@ -83,2 +111,6 @@ */

/**
* A struct for the {@link CardElement} type.
*/
export declare const CardStruct: Describe<CardElement>;
/**
* A struct for the {@link HeadingElement} type.

@@ -129,3 +161,3 @@ */

*/
export declare const BoxChildStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").CheckboxProps, "Checkbox"> | SnapElement<import("./components").FormProps, "Form"> | SnapElement<import("./components").InputProps, "Input"> | SnapElement<import("./components").DropdownProps, "Dropdown"> | SnapElement<import("./components").FileInputProps, "FileInput"> | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<import("./components").AddressProps, "Address"> | SnapElement<import("./components").BoxProps, "Box"> | SnapElement<import("./components").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<{
export declare const BoxChildStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").CheckboxProps, "Checkbox"> | SnapElement<import("./components").FormProps, "Form"> | SnapElement<import("./components").InputProps, "Input"> | SnapElement<import("./components").DropdownProps, "Dropdown"> | SnapElement<import("./components").FileInputProps, "FileInput"> | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<import("./components").AddressProps, "Address"> | SnapElement<import("./components").BoxProps, "Box"> | SnapElement<import("./components").CardProps, "Card"> | SnapElement<import("./components").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<{
children: StringElement;

@@ -140,3 +172,3 @@ }, "Heading"> | SnapElement<{

*/
export declare const RootJSXElementStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").CheckboxProps, "Checkbox"> | SnapElement<import("./components").FormProps, "Form"> | SnapElement<import("./components").InputProps, "Input"> | SnapElement<import("./components").DropdownProps, "Dropdown"> | SnapElement<import("./components").FileInputProps, "FileInput"> | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<import("./components").AddressProps, "Address"> | SnapElement<import("./components").BoxProps, "Box"> | SnapElement<import("./components").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<{
export declare const RootJSXElementStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").CheckboxProps, "Checkbox"> | SnapElement<import("./components").FormProps, "Form"> | SnapElement<import("./components").InputProps, "Input"> | SnapElement<import("./components").DropdownProps, "Dropdown"> | SnapElement<import("./components").FileInputProps, "FileInput"> | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<import("./components").AddressProps, "Address"> | SnapElement<import("./components").BoxProps, "Box"> | SnapElement<import("./components").CardProps, "Card"> | SnapElement<import("./components").ContainerProps, "Container"> | SnapElement<import("./components").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<{
children: StringElement;

@@ -143,0 +175,0 @@ }, "Heading"> | SnapElement<{

@@ -1,2 +0,2 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import type { InterfaceContext } from '../interface';

@@ -18,15 +18,15 @@ /**

}
export declare const GenericEventStruct: import("superstruct").Struct<{
export declare const GenericEventStruct: import("@metamask/superstruct").Struct<{
type: string;
name?: string | undefined;
}, {
type: import("superstruct").Struct<string, null>;
name: import("superstruct").Struct<string | undefined, null>;
type: import("@metamask/superstruct").Struct<string, null>;
name: import("@metamask/superstruct").Struct<string | undefined, null>;
}>;
export declare const ButtonClickEventStruct: import("superstruct").Struct<{
export declare const ButtonClickEventStruct: import("@metamask/superstruct").Struct<{
type: UserInputEventType.ButtonClickEvent;
name?: string | undefined;
}, {
type: import("superstruct").Struct<UserInputEventType.ButtonClickEvent, UserInputEventType.ButtonClickEvent>;
name: import("superstruct").Struct<string | undefined, null>;
type: import("@metamask/superstruct").Struct<UserInputEventType.ButtonClickEvent, UserInputEventType.ButtonClickEvent>;
name: import("@metamask/superstruct").Struct<string | undefined, null>;
}>;

@@ -42,3 +42,3 @@ /**

export declare type ButtonClickEvent = Infer<typeof ButtonClickEventStruct>;
export declare const FileStruct: import("superstruct").Struct<{
export declare const FileStruct: import("@metamask/superstruct").Struct<{
name: string;

@@ -49,6 +49,6 @@ size: number;

}, {
name: import("superstruct").Struct<string, null>;
size: import("superstruct").Struct<number, null>;
contentType: import("superstruct").Struct<string, null>;
contents: import("superstruct").Struct<string, null>;
name: import("@metamask/superstruct").Struct<string, null>;
size: import("@metamask/superstruct").Struct<number, null>;
contentType: import("@metamask/superstruct").Struct<string, null>;
contents: import("@metamask/superstruct").Struct<string, null>;
}>;

@@ -65,3 +65,3 @@ /**

export declare type File = Infer<typeof FileStruct>;
export declare const FormSubmitEventStruct: import("superstruct").Struct<{
export declare const FormSubmitEventStruct: import("@metamask/superstruct").Struct<{
value: Record<string, string | boolean | {

@@ -76,4 +76,4 @@ name: string;

}, {
type: import("superstruct").Struct<UserInputEventType.FormSubmitEvent, UserInputEventType.FormSubmitEvent>;
value: import("superstruct").Struct<Record<string, string | boolean | {
type: import("@metamask/superstruct").Struct<UserInputEventType.FormSubmitEvent, UserInputEventType.FormSubmitEvent>;
value: import("@metamask/superstruct").Struct<Record<string, string | boolean | {
name: string;

@@ -84,3 +84,3 @@ size: number;

} | null>, null>;
name: import("superstruct").Struct<string, null>;
name: import("@metamask/superstruct").Struct<string, null>;
}>;

@@ -101,3 +101,3 @@ /**

export declare type FormSubmitEvent = Infer<typeof FormSubmitEventStruct>;
export declare const InputChangeEventStruct: import("superstruct").Struct<{
export declare const InputChangeEventStruct: import("@metamask/superstruct").Struct<{
value: string | boolean;

@@ -107,5 +107,5 @@ type: UserInputEventType.InputChangeEvent;

}, {
type: import("superstruct").Struct<UserInputEventType.InputChangeEvent, UserInputEventType.InputChangeEvent>;
name: import("superstruct").Struct<string, null>;
value: import("superstruct").Struct<string | boolean, null>;
type: import("@metamask/superstruct").Struct<UserInputEventType.InputChangeEvent, UserInputEventType.InputChangeEvent>;
name: import("@metamask/superstruct").Struct<string, null>;
value: import("@metamask/superstruct").Struct<string | boolean, null>;
}>;

@@ -121,3 +121,3 @@ /**

export declare type InputChangeEvent = Infer<typeof InputChangeEventStruct>;
export declare const FileUploadEventStruct: import("superstruct").Struct<{
export declare const FileUploadEventStruct: import("@metamask/superstruct").Struct<{
type: UserInputEventType.FileUploadEvent;

@@ -132,5 +132,5 @@ name: string;

}, {
type: import("superstruct").Struct<UserInputEventType.FileUploadEvent, UserInputEventType.FileUploadEvent>;
name: import("superstruct").Struct<string, null>;
file: import("superstruct").Struct<{
type: import("@metamask/superstruct").Struct<UserInputEventType.FileUploadEvent, UserInputEventType.FileUploadEvent>;
name: import("@metamask/superstruct").Struct<string, null>;
file: import("@metamask/superstruct").Struct<{
name: string;

@@ -141,6 +141,6 @@ size: number;

} | null, {
name: import("superstruct").Struct<string, null>;
size: import("superstruct").Struct<number, null>;
contentType: import("superstruct").Struct<string, null>;
contents: import("superstruct").Struct<string, null>;
name: import("@metamask/superstruct").Struct<string, null>;
size: import("@metamask/superstruct").Struct<number, null>;
contentType: import("@metamask/superstruct").Struct<string, null>;
contents: import("@metamask/superstruct").Struct<string, null>;
}>;

@@ -159,3 +159,3 @@ }>;

export declare type FileUploadEvent = Infer<typeof FileUploadEventStruct>;
export declare const UserInputEventStruct: import("superstruct").Struct<{
export declare const UserInputEventStruct: import("@metamask/superstruct").Struct<{
type: UserInputEventType.ButtonClickEvent;

@@ -162,0 +162,0 @@ name?: string | undefined;

@@ -1,2 +0,2 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import type { JSXElement } from '../jsx';

@@ -10,3 +10,3 @@ import type { Component } from '../ui';

*/
export declare const StateStruct: import("superstruct").Struct<string | boolean | {
export declare const StateStruct: import("@metamask/superstruct").Struct<string | boolean | {
name: string;

@@ -17,3 +17,3 @@ size: number;

}, null>;
export declare const FormStateStruct: import("superstruct").Struct<Record<string, string | boolean | {
export declare const FormStateStruct: import("@metamask/superstruct").Struct<Record<string, string | boolean | {
name: string;

@@ -24,3 +24,3 @@ size: number;

} | null>, null>;
export declare const InterfaceStateStruct: import("superstruct").Struct<Record<string, string | boolean | {
export declare const InterfaceStateStruct: import("@metamask/superstruct").Struct<Record<string, string | boolean | {
name: string;

@@ -40,3 +40,3 @@ size: number;

export declare type ComponentOrElement = Component | JSXElement;
export declare const ComponentOrElementStruct: import("superstruct").Struct<{
export declare const ComponentOrElementStruct: import("@metamask/superstruct").Struct<{
value: string;

@@ -109,3 +109,3 @@ type: import("../ui").NodeType.Copyable;

})[];
} | import("../jsx").SnapElement<import("../jsx").ButtonProps, "Button"> | import("../jsx").SnapElement<import("../jsx").CheckboxProps, "Checkbox"> | import("../jsx").SnapElement<import("../jsx").FormProps, "Form"> | import("../jsx").SnapElement<import("../jsx").InputProps, "Input"> | import("../jsx").SnapElement<import("../jsx").DropdownProps, "Dropdown"> | import("../jsx").SnapElement<import("../jsx").FileInputProps, "FileInput"> | import("../jsx").SnapElement<import("../jsx").BoldProps, "Bold"> | import("../jsx").SnapElement<import("../jsx").ItalicProps, "Italic"> | import("../jsx").SnapElement<import("../jsx").AddressProps, "Address"> | import("../jsx").SnapElement<import("../jsx").BoxProps, "Box"> | import("../jsx").SnapElement<import("../jsx").CopyableProps, "Copyable"> | import("../jsx").SnapElement<Record<string, never>, "Divider"> | import("../jsx").SnapElement<{
} | import("../jsx").SnapElement<import("../jsx").ButtonProps, "Button"> | import("../jsx").SnapElement<import("../jsx").CheckboxProps, "Checkbox"> | import("../jsx").SnapElement<import("../jsx").FormProps, "Form"> | import("../jsx").SnapElement<import("../jsx").InputProps, "Input"> | import("../jsx").SnapElement<import("../jsx").DropdownProps, "Dropdown"> | import("../jsx").SnapElement<import("../jsx").FileInputProps, "FileInput"> | import("../jsx").SnapElement<import("../jsx").BoldProps, "Bold"> | import("../jsx").SnapElement<import("../jsx").ItalicProps, "Italic"> | import("../jsx").SnapElement<import("../jsx").AddressProps, "Address"> | import("../jsx").SnapElement<import("../jsx").BoxProps, "Box"> | import("../jsx").SnapElement<import("../jsx").CardProps, "Card"> | import("../jsx").SnapElement<import("../jsx").ContainerProps, "Container"> | import("../jsx").SnapElement<import("../jsx").CopyableProps, "Copyable"> | import("../jsx").SnapElement<Record<string, never>, "Divider"> | import("../jsx").SnapElement<{
children: import("../jsx").StringElement;

@@ -116,3 +116,3 @@ }, "Heading"> | import("../jsx").SnapElement<{

}, "Image"> | import("../jsx").SnapElement<import("../jsx").LinkProps, "Link"> | import("../jsx").SnapElement<import("../jsx").TextProps, "Text"> | import("../jsx").SnapElement<import("../jsx").RowProps, "Row"> | import("../jsx").SnapElement<Record<string, never>, "Spinner"> | import("../jsx").SnapElement<import("../jsx").TooltipProps, "Tooltip">, null>;
export declare const InterfaceContextStruct: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
export declare const InterfaceContextStruct: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
export declare type InterfaceContext = Infer<typeof InterfaceContextStruct>;

@@ -0,1 +1,2 @@

import type { Json } from '@metamask/utils';
import type { ComponentOrElement } from '..';

@@ -16,2 +17,7 @@ import type { EnumToUnion } from '../../internals';

}
export declare type DefaultDialog = {
id: string;
} | {
content: ComponentOrElement;
};
/**

@@ -72,3 +78,3 @@ * An alert dialog.

*/
export declare type DialogParams = AlertDialog | ConfirmationDialog | PromptDialog;
export declare type DialogParams = AlertDialog | ConfirmationDialog | PromptDialog | DefaultDialog;
/**

@@ -83,2 +89,2 @@ * The result returned by the `snap_dialog` method.

*/
export declare type DialogResult = null | boolean | string;
export declare type DialogResult = null | boolean | string | Json;

@@ -20,1 +20,2 @@ export * from './create-interface';

export * from './update-interface';
export * from './resolve-interface';

@@ -19,2 +19,3 @@ import type { Method } from '../../internals';

import type { RequestSnapsParams, RequestSnapsResult } from './request-snaps';
import type { ResolveInterfaceParams, ResolveInterfaceResult } from './resolve-interface';
import type { UpdateInterfaceParams, UpdateInterfaceResult } from './update-interface';

@@ -40,2 +41,3 @@ /**

snap_getInterfaceState: [GetInterfaceStateParams, GetInterfaceStateResult];
snap_resolveInterface: [ResolveInterfaceParams, ResolveInterfaceResult];
wallet_getSnaps: [GetSnapsParams, GetSnapsResult];

@@ -42,0 +44,0 @@ wallet_invokeKeyring: [InvokeKeyringParams, InvokeKeyringResult];

@@ -1,2 +0,2 @@

import type { Struct } from 'superstruct';
import type { Struct } from '@metamask/superstruct';
import type { Component } from './components';

@@ -3,0 +3,0 @@ import type { NodeType } from './nodes';

@@ -1,9 +0,9 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';
export declare const AddressStruct: import("superstruct").Struct<{
export declare const AddressStruct: import("@metamask/superstruct").Struct<{
value: `0x${string}`;
type: NodeType.Address;
}, {
type: import("superstruct").Struct<NodeType.Address, NodeType.Address>;
value: import("superstruct").Struct<`0x${string}`, null>;
type: import("@metamask/superstruct").Struct<NodeType.Address, NodeType.Address>;
value: import("@metamask/superstruct").Struct<`0x${string}`, null>;
}>;

@@ -10,0 +10,0 @@ /**

@@ -1,2 +0,2 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';

@@ -11,3 +11,3 @@ export declare enum ButtonVariant {

}
export declare const ButtonStruct: import("superstruct").Struct<{
export declare const ButtonStruct: import("@metamask/superstruct").Struct<{
value: string;

@@ -19,7 +19,7 @@ type: NodeType.Button;

}, {
type: import("superstruct").Struct<NodeType.Button, NodeType.Button>;
value: import("superstruct").Struct<string, null>;
variant: import("superstruct").Struct<"primary" | "secondary" | undefined, null>;
buttonType: import("superstruct").Struct<"button" | "submit" | undefined, null>;
name: import("superstruct").Struct<string | undefined, null>;
type: import("@metamask/superstruct").Struct<NodeType.Button, NodeType.Button>;
value: import("@metamask/superstruct").Struct<string, null>;
variant: import("@metamask/superstruct").Struct<"primary" | "secondary" | undefined, null>;
buttonType: import("@metamask/superstruct").Struct<"button" | "submit" | undefined, null>;
name: import("@metamask/superstruct").Struct<string | undefined, null>;
}>;

@@ -26,0 +26,0 @@ /**

@@ -1,4 +0,4 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';
export declare const CopyableStruct: import("superstruct").Struct<{
export declare const CopyableStruct: import("@metamask/superstruct").Struct<{
value: string;

@@ -8,5 +8,5 @@ type: NodeType.Copyable;

}, {
type: import("superstruct").Struct<NodeType.Copyable, NodeType.Copyable>;
value: import("superstruct").Struct<string, null>;
sensitive: import("superstruct").Struct<boolean | undefined, null>;
type: import("@metamask/superstruct").Struct<NodeType.Copyable, NodeType.Copyable>;
value: import("@metamask/superstruct").Struct<string, null>;
sensitive: import("@metamask/superstruct").Struct<boolean | undefined, null>;
}>;

@@ -13,0 +13,0 @@ /**

@@ -1,7 +0,7 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';
export declare const DividerStruct: import("superstruct").Struct<{
export declare const DividerStruct: import("@metamask/superstruct").Struct<{
type: NodeType.Divider;
}, {
type: import("superstruct").Struct<NodeType.Divider, NodeType.Divider>;
type: import("@metamask/superstruct").Struct<NodeType.Divider, NodeType.Divider>;
}>;

@@ -8,0 +8,0 @@ /**

@@ -1,4 +0,4 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';
export declare const FormComponentStruct: import("superstruct").Struct<{
export declare const FormComponentStruct: import("@metamask/superstruct").Struct<{
type: NodeType.Input;

@@ -22,3 +22,3 @@ name: string;

export declare type FormComponent = Infer<typeof FormComponentStruct>;
export declare const FormStruct: import("superstruct").Struct<{
export declare const FormStruct: import("@metamask/superstruct").Struct<{
type: NodeType.Form;

@@ -42,4 +42,4 @@ name: string;

}, {
type: import("superstruct").Struct<NodeType.Form, NodeType.Form>;
children: import("superstruct").Struct<({
type: import("@metamask/superstruct").Struct<NodeType.Form, NodeType.Form>;
children: import("@metamask/superstruct").Struct<({
type: NodeType.Input;

@@ -58,3 +58,3 @@ name: string;

buttonType?: "button" | "submit" | undefined;
})[], import("superstruct").Struct<{
})[], import("@metamask/superstruct").Struct<{
type: NodeType.Input;

@@ -74,3 +74,3 @@ name: string;

}, null>>;
name: import("superstruct").Struct<string, null>;
name: import("@metamask/superstruct").Struct<string, null>;
}>;

@@ -77,0 +77,0 @@ /**

@@ -1,9 +0,9 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';
export declare const HeadingStruct: import("superstruct").Struct<{
export declare const HeadingStruct: import("@metamask/superstruct").Struct<{
value: string;
type: NodeType.Heading;
}, {
type: import("superstruct").Struct<NodeType.Heading, NodeType.Heading>;
value: import("superstruct").Struct<string, null>;
type: import("@metamask/superstruct").Struct<NodeType.Heading, NodeType.Heading>;
value: import("@metamask/superstruct").Struct<string, null>;
}>;

@@ -10,0 +10,0 @@ /**

@@ -1,9 +0,9 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';
export declare const ImageStruct: import("superstruct").Struct<{
export declare const ImageStruct: import("@metamask/superstruct").Struct<{
value: string;
type: NodeType.Image;
}, {
type: import("superstruct").Struct<NodeType.Image, NodeType.Image>;
value: import("superstruct").Struct<string, null>;
type: import("@metamask/superstruct").Struct<NodeType.Image, NodeType.Image>;
value: import("@metamask/superstruct").Struct<string, null>;
}>;

@@ -10,0 +10,0 @@ /**

@@ -1,2 +0,2 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';

@@ -12,3 +12,3 @@ /**

}
export declare const InputStruct: import("superstruct").Struct<{
export declare const InputStruct: import("@metamask/superstruct").Struct<{
type: NodeType.Input;

@@ -22,9 +22,9 @@ name: string;

}, {
type: import("superstruct").Struct<NodeType.Input, NodeType.Input>;
value: import("superstruct").Struct<string | undefined, null>;
name: import("superstruct").Struct<string, null>;
inputType: import("superstruct").Struct<"number" | "text" | "password" | undefined, null>;
placeholder: import("superstruct").Struct<string | undefined, null>;
label: import("superstruct").Struct<string | undefined, null>;
error: import("superstruct").Struct<string | undefined, null>;
type: import("@metamask/superstruct").Struct<NodeType.Input, NodeType.Input>;
value: import("@metamask/superstruct").Struct<string | undefined, null>;
name: import("@metamask/superstruct").Struct<string, null>;
inputType: import("@metamask/superstruct").Struct<"number" | "text" | "password" | undefined, null>;
placeholder: import("@metamask/superstruct").Struct<string | undefined, null>;
label: import("@metamask/superstruct").Struct<string | undefined, null>;
error: import("@metamask/superstruct").Struct<string | undefined, null>;
}>;

@@ -31,0 +31,0 @@ /**

@@ -1,2 +0,2 @@

import type { Infer, Struct } from 'superstruct';
import type { Infer, Struct } from '@metamask/superstruct';
import { NodeType } from '../nodes';

@@ -3,0 +3,0 @@ /**

@@ -1,2 +0,2 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';

@@ -8,3 +8,3 @@ export declare enum RowVariant {

}
export declare const RowStruct: import("superstruct").Struct<{
export declare const RowStruct: import("@metamask/superstruct").Struct<{
value: {

@@ -25,6 +25,6 @@ value: string;

}, {
type: import("superstruct").Struct<NodeType.Row, NodeType.Row>;
variant: import("superstruct").Struct<"default" | "warning" | "critical" | undefined, null>;
label: import("superstruct").Struct<string, null>;
value: import("superstruct").Struct<{
type: import("@metamask/superstruct").Struct<NodeType.Row, NodeType.Row>;
variant: import("@metamask/superstruct").Struct<"default" | "warning" | "critical" | undefined, null>;
label: import("@metamask/superstruct").Struct<string, null>;
value: import("@metamask/superstruct").Struct<{
value: string;

@@ -31,0 +31,0 @@ type: NodeType.Image;

@@ -1,7 +0,7 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';
export declare const SpinnerStruct: import("superstruct").Struct<{
export declare const SpinnerStruct: import("@metamask/superstruct").Struct<{
type: NodeType.Spinner;
}, {
type: import("superstruct").Struct<NodeType.Spinner, NodeType.Spinner>;
type: import("@metamask/superstruct").Struct<NodeType.Spinner, NodeType.Spinner>;
}>;

@@ -8,0 +8,0 @@ /**

@@ -1,4 +0,4 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
import { NodeType } from '../nodes';
export declare const TextStruct: import("superstruct").Struct<{
export declare const TextStruct: import("@metamask/superstruct").Struct<{
value: string;

@@ -8,5 +8,5 @@ type: NodeType.Text;

}, {
type: import("superstruct").Struct<NodeType.Text, NodeType.Text>;
value: import("superstruct").Struct<string, null>;
markdown: import("superstruct").Struct<boolean | undefined, null>;
type: import("@metamask/superstruct").Struct<NodeType.Text, NodeType.Text>;
value: import("@metamask/superstruct").Struct<string, null>;
markdown: import("@metamask/superstruct").Struct<boolean | undefined, null>;
}>;

@@ -13,0 +13,0 @@ /**

@@ -1,2 +0,2 @@

import type { Infer } from 'superstruct';
import type { Infer } from '@metamask/superstruct';
/**

@@ -24,6 +24,6 @@ * The supported node types. This is based on SIP-7.

*/
export declare const NodeStruct: import("superstruct").Struct<{
export declare const NodeStruct: import("@metamask/superstruct").Struct<{
type: string;
}, {
type: import("superstruct").Struct<string, null>;
type: import("@metamask/superstruct").Struct<string, null>;
}>;

@@ -41,8 +41,8 @@ /**

*/
export declare const LiteralStruct: import("superstruct").Struct<{
export declare const LiteralStruct: import("@metamask/superstruct").Struct<{
value: unknown;
type: string;
}, {
value: import("superstruct").Struct<unknown, null>;
type: import("superstruct").Struct<string, null>;
value: import("@metamask/superstruct").Struct<unknown, null>;
type: import("@metamask/superstruct").Struct<string, null>;
}>;

@@ -49,0 +49,0 @@ /**

{
"name": "@metamask/snaps-sdk",
"version": "6.0.0",
"version": "6.1.0",
"repository": {

@@ -62,7 +62,7 @@ "type": "git",

"dependencies": {
"@metamask/key-tree": "^9.1.1",
"@metamask/providers": "^17.0.0",
"@metamask/rpc-errors": "^6.2.1",
"@metamask/utils": "^8.3.0",
"superstruct": "^1.0.3"
"@metamask/key-tree": "^9.1.2",
"@metamask/providers": "17.0.0",
"@metamask/rpc-errors": "^6.3.1",
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^9.1.0"
},

@@ -69,0 +69,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc