@metamask/snaps-sdk 6.3.0 → 6.5.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 +34 -1
- package/dist/error-wrappers.cjs +146 -0
- package/dist/error-wrappers.cjs.map +1 -0
- package/dist/error-wrappers.d.cts +830 -0
- package/dist/error-wrappers.d.cts.map +1 -0
- package/dist/{types/error-wrappers.d.ts → error-wrappers.d.mts} +289 -288
- package/dist/error-wrappers.d.mts.map +1 -0
- package/dist/error-wrappers.mjs +143 -0
- package/dist/error-wrappers.mjs.map +1 -0
- package/dist/errors.cjs +124 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/{types/errors.d.ts → errors.d.cts} +3 -2
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +87 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +120 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/images.cjs +91 -0
- package/dist/images.cjs.map +1 -0
- package/dist/{types/images.d.ts → images.d.cts} +2 -1
- package/dist/images.d.cts.map +1 -0
- package/dist/images.d.mts +70 -0
- package/dist/images.d.mts.map +1 -0
- package/dist/images.mjs +86 -0
- package/dist/images.mjs.map +1 -0
- package/dist/index.cjs +36 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +7 -1429
- package/dist/index.mjs.map +1 -1
- package/dist/internals/error-wrappers.cjs +44 -0
- package/dist/internals/error-wrappers.cjs.map +1 -0
- package/dist/internals/error-wrappers.d.cts +60 -0
- package/dist/internals/error-wrappers.d.cts.map +1 -0
- package/dist/{types/internals/error-wrappers.d.ts → internals/error-wrappers.d.mts} +21 -20
- package/dist/internals/error-wrappers.d.mts.map +1 -0
- package/dist/internals/error-wrappers.mjs +40 -0
- package/dist/internals/error-wrappers.mjs.map +1 -0
- package/dist/internals/errors.cjs +80 -0
- package/dist/internals/errors.cjs.map +1 -0
- package/dist/{types/internals/errors.d.ts → internals/errors.d.cts} +1 -0
- package/dist/internals/errors.d.cts.map +1 -0
- package/dist/internals/errors.d.mts +42 -0
- package/dist/internals/errors.d.mts.map +1 -0
- package/dist/internals/errors.mjs +73 -0
- package/dist/internals/errors.mjs.map +1 -0
- package/dist/internals/helpers.cjs +3 -0
- package/dist/internals/helpers.cjs.map +1 -0
- package/dist/{types/internals/helpers.d.ts → internals/helpers.d.cts} +2 -1
- package/dist/internals/helpers.d.cts.map +1 -0
- package/dist/internals/helpers.d.mts +37 -0
- package/dist/internals/helpers.d.mts.map +1 -0
- package/dist/internals/helpers.mjs +2 -0
- package/dist/internals/helpers.mjs.map +1 -0
- package/dist/internals/index.cjs +23 -0
- package/dist/internals/index.cjs.map +1 -0
- package/dist/internals/index.d.cts +7 -0
- package/dist/internals/index.d.cts.map +1 -0
- package/dist/internals/index.d.mts +7 -0
- package/dist/internals/index.d.mts.map +1 -0
- package/dist/internals/index.mjs +7 -0
- package/dist/internals/index.mjs.map +1 -0
- package/dist/internals/jsx.cjs +17 -0
- package/dist/internals/jsx.cjs.map +1 -0
- package/dist/{types/internals/jsx.d.ts → internals/jsx.d.cts} +3 -2
- package/dist/internals/jsx.d.cts.map +1 -0
- package/dist/internals/jsx.d.mts +31 -0
- package/dist/internals/jsx.d.mts.map +1 -0
- package/dist/internals/jsx.mjs +13 -0
- package/dist/internals/jsx.mjs.map +1 -0
- package/dist/internals/structs.cjs +161 -0
- package/dist/internals/structs.cjs.map +1 -0
- package/dist/{types/internals/structs.d.ts → internals/structs.d.cts} +13 -3
- package/dist/internals/structs.d.cts.map +1 -0
- package/dist/internals/structs.d.mts +69 -0
- package/dist/internals/structs.d.mts.map +1 -0
- package/dist/internals/structs.mjs +153 -0
- package/dist/internals/structs.mjs.map +1 -0
- package/dist/internals/svg.cjs +23 -0
- package/dist/internals/svg.cjs.map +1 -0
- package/dist/{types/internals/svg.d.ts → internals/svg.d.cts} +1 -0
- package/dist/internals/svg.d.cts.map +1 -0
- package/dist/internals/svg.d.mts +8 -0
- package/dist/internals/svg.d.mts.map +1 -0
- package/dist/internals/svg.mjs +19 -0
- package/dist/internals/svg.mjs.map +1 -0
- package/dist/jsx/component.cjs +32 -0
- package/dist/jsx/component.cjs.map +1 -0
- package/dist/{types/jsx/component.d.ts → jsx/component.d.cts} +6 -1
- package/dist/jsx/component.d.cts.map +1 -0
- package/dist/jsx/component.d.mts +78 -0
- package/dist/jsx/component.d.mts.map +1 -0
- package/dist/jsx/component.mjs +28 -0
- package/dist/jsx/component.mjs.map +1 -0
- package/dist/jsx/components/Address.cjs +23 -0
- package/dist/jsx/components/Address.cjs.map +1 -0
- package/dist/jsx/components/Address.d.cts +34 -0
- package/dist/jsx/components/Address.d.cts.map +1 -0
- package/dist/jsx/components/Address.d.mts +34 -0
- package/dist/jsx/components/Address.d.mts.map +1 -0
- package/dist/jsx/components/Address.mjs +20 -0
- package/dist/jsx/components/Address.mjs.map +1 -0
- package/dist/jsx/components/Box.cjs +18 -0
- package/dist/jsx/components/Box.cjs.map +1 -0
- package/dist/{types/jsx/components/Box.d.ts → jsx/components/Box.d.cts} +5 -2
- package/dist/jsx/components/Box.d.cts.map +1 -0
- package/dist/jsx/components/Box.d.mts +34 -0
- package/dist/jsx/components/Box.d.mts.map +1 -0
- package/dist/jsx/components/Box.mjs +15 -0
- package/dist/jsx/components/Box.mjs.map +1 -0
- package/dist/jsx/components/Card.cjs +20 -0
- package/dist/jsx/components/Card.cjs.map +1 -0
- package/dist/{types/jsx/components/Card.d.ts → jsx/components/Card.d.cts} +2 -1
- package/dist/jsx/components/Card.d.cts.map +1 -0
- package/dist/jsx/components/Card.d.mts +37 -0
- package/dist/jsx/components/Card.d.mts.map +1 -0
- package/dist/jsx/components/Card.mjs +17 -0
- package/dist/jsx/components/Card.mjs.map +1 -0
- package/dist/jsx/components/Container.cjs +24 -0
- package/dist/jsx/components/Container.cjs.map +1 -0
- package/dist/{types/jsx/components/Container.d.ts → jsx/components/Container.d.cts} +5 -4
- package/dist/jsx/components/Container.d.cts.map +1 -0
- package/dist/jsx/components/Container.d.mts +35 -0
- package/dist/jsx/components/Container.d.mts.map +1 -0
- package/dist/jsx/components/Container.mjs +21 -0
- package/dist/jsx/components/Container.mjs.map +1 -0
- package/dist/jsx/components/Copyable.cjs +20 -0
- package/dist/jsx/components/Copyable.cjs.map +1 -0
- package/dist/{types/jsx/components/Copyable.d.ts → jsx/components/Copyable.d.cts} +2 -1
- package/dist/jsx/components/Copyable.d.cts.map +1 -0
- package/dist/jsx/components/Copyable.d.mts +33 -0
- package/dist/jsx/components/Copyable.d.mts.map +1 -0
- package/dist/jsx/components/Copyable.mjs +17 -0
- package/dist/jsx/components/Copyable.mjs.map +1 -0
- package/dist/jsx/components/Divider.cjs +17 -0
- package/dist/jsx/components/Divider.cjs.map +1 -0
- package/dist/{types/jsx/components/Divider.d.ts → jsx/components/Divider.d.cts} +2 -1
- package/dist/jsx/components/Divider.d.cts.map +1 -0
- package/dist/jsx/components/Divider.d.mts +18 -0
- package/dist/jsx/components/Divider.d.mts.map +1 -0
- package/dist/jsx/components/Divider.mjs +14 -0
- package/dist/jsx/components/Divider.mjs.map +1 -0
- package/dist/jsx/components/Footer.cjs +19 -0
- package/dist/jsx/components/Footer.cjs.map +1 -0
- package/dist/{types/jsx/components/Footer.d.ts → jsx/components/Footer.d.cts} +3 -2
- package/dist/jsx/components/Footer.d.cts.map +1 -0
- package/dist/jsx/components/Footer.d.mts +29 -0
- package/dist/jsx/components/Footer.d.mts.map +1 -0
- package/dist/jsx/components/Footer.mjs +16 -0
- package/dist/jsx/components/Footer.mjs.map +1 -0
- package/dist/jsx/components/Heading.cjs +16 -0
- package/dist/jsx/components/Heading.cjs.map +1 -0
- package/dist/{types/jsx/components/Heading.d.ts → jsx/components/Heading.d.cts} +3 -2
- package/dist/jsx/components/Heading.d.cts.map +1 -0
- package/dist/jsx/components/Heading.d.mts +27 -0
- package/dist/jsx/components/Heading.d.mts.map +1 -0
- package/dist/jsx/components/Heading.mjs +13 -0
- package/dist/jsx/components/Heading.mjs.map +1 -0
- package/dist/jsx/components/Icon.cjs +180 -0
- package/dist/jsx/components/Icon.cjs.map +1 -0
- package/dist/{types/jsx/components/Icon.d.ts → jsx/components/Icon.d.cts} +2 -1
- package/dist/jsx/components/Icon.d.cts.map +1 -0
- package/dist/jsx/components/Icon.d.mts +190 -0
- package/dist/jsx/components/Icon.d.mts.map +1 -0
- package/dist/jsx/components/Icon.mjs +177 -0
- package/dist/jsx/components/Icon.mjs.map +1 -0
- package/dist/jsx/components/Image.cjs +22 -0
- package/dist/jsx/components/Image.cjs.map +1 -0
- package/dist/{types/jsx/components/Image.d.ts → jsx/components/Image.d.cts} +2 -1
- package/dist/jsx/components/Image.d.cts.map +1 -0
- package/dist/jsx/components/Image.d.mts +37 -0
- package/dist/jsx/components/Image.d.mts.map +1 -0
- package/dist/jsx/components/Image.mjs +19 -0
- package/dist/jsx/components/Image.mjs.map +1 -0
- package/dist/jsx/components/Link.cjs +18 -0
- package/dist/jsx/components/Link.cjs.map +1 -0
- package/dist/{types/jsx/components/Link.d.ts → jsx/components/Link.d.cts} +4 -3
- package/dist/jsx/components/Link.d.cts.map +1 -0
- package/dist/jsx/components/Link.d.mts +36 -0
- package/dist/jsx/components/Link.d.mts.map +1 -0
- package/dist/jsx/components/Link.mjs +15 -0
- package/dist/jsx/components/Link.mjs.map +1 -0
- package/dist/jsx/components/Row.cjs +22 -0
- package/dist/jsx/components/Row.cjs.map +1 -0
- package/dist/{types/jsx/components/Row.d.ts → jsx/components/Row.d.cts} +6 -5
- package/dist/jsx/components/Row.d.cts.map +1 -0
- package/dist/jsx/components/Row.d.mts +46 -0
- package/dist/jsx/components/Row.d.mts.map +1 -0
- package/dist/jsx/components/Row.mjs +19 -0
- package/dist/jsx/components/Row.mjs.map +1 -0
- package/dist/jsx/components/Section.cjs +26 -0
- package/dist/jsx/components/Section.cjs.map +1 -0
- package/dist/jsx/components/Section.d.cts +38 -0
- package/dist/jsx/components/Section.d.cts.map +1 -0
- package/dist/jsx/components/Section.d.mts +38 -0
- package/dist/jsx/components/Section.d.mts.map +1 -0
- package/dist/jsx/components/Section.mjs +23 -0
- package/dist/jsx/components/Section.mjs.map +1 -0
- package/dist/jsx/components/Spinner.cjs +17 -0
- package/dist/jsx/components/Spinner.cjs.map +1 -0
- package/dist/{types/jsx/components/Spinner.d.ts → jsx/components/Spinner.d.cts} +2 -1
- package/dist/jsx/components/Spinner.d.cts.map +1 -0
- package/dist/jsx/components/Spinner.d.mts +18 -0
- package/dist/jsx/components/Spinner.d.mts.map +1 -0
- package/dist/jsx/components/Spinner.mjs +14 -0
- package/dist/jsx/components/Spinner.mjs.map +1 -0
- package/dist/jsx/components/Text.cjs +22 -0
- package/dist/jsx/components/Text.cjs.map +1 -0
- package/dist/{types/jsx/components/Text.d.ts → jsx/components/Text.d.cts} +6 -5
- package/dist/jsx/components/Text.d.cts.map +1 -0
- package/dist/jsx/components/Text.d.mts +45 -0
- package/dist/jsx/components/Text.d.mts.map +1 -0
- package/dist/jsx/components/Text.mjs +19 -0
- package/dist/jsx/components/Text.mjs.map +1 -0
- package/dist/jsx/components/Tooltip.cjs +23 -0
- package/dist/jsx/components/Tooltip.cjs.map +1 -0
- package/dist/{types/jsx/components/Tooltip.d.ts → jsx/components/Tooltip.d.cts} +7 -6
- package/dist/jsx/components/Tooltip.d.cts.map +1 -0
- package/dist/jsx/components/Tooltip.d.mts +40 -0
- package/dist/jsx/components/Tooltip.d.mts.map +1 -0
- package/dist/jsx/components/Tooltip.mjs +20 -0
- package/dist/jsx/components/Tooltip.mjs.map +1 -0
- package/dist/jsx/components/Value.cjs +21 -0
- package/dist/jsx/components/Value.cjs.map +1 -0
- package/dist/{types/jsx/components/Value.d.ts → jsx/components/Value.d.cts} +2 -1
- package/dist/jsx/components/Value.d.cts.map +1 -0
- package/dist/jsx/components/Value.d.mts +32 -0
- package/dist/jsx/components/Value.d.mts.map +1 -0
- package/dist/jsx/components/Value.mjs +18 -0
- package/dist/jsx/components/Value.mjs.map +1 -0
- package/dist/jsx/components/form/Button.cjs +17 -0
- package/dist/jsx/components/form/Button.cjs.map +1 -0
- package/dist/{types/jsx/components/form/Button.d.ts → jsx/components/form/Button.d.cts} +7 -4
- package/dist/jsx/components/form/Button.d.cts.map +1 -0
- package/dist/jsx/components/form/Button.d.mts +42 -0
- package/dist/jsx/components/form/Button.d.mts.map +1 -0
- package/dist/jsx/components/form/Button.mjs +14 -0
- package/dist/jsx/components/form/Button.mjs.map +1 -0
- package/dist/jsx/components/form/Checkbox.cjs +20 -0
- package/dist/jsx/components/form/Checkbox.cjs.map +1 -0
- package/dist/{types/jsx/components/form/Checkbox.d.ts → jsx/components/form/Checkbox.d.cts} +2 -1
- package/dist/jsx/components/form/Checkbox.d.cts.map +1 -0
- package/dist/jsx/components/form/Checkbox.d.mts +36 -0
- package/dist/jsx/components/form/Checkbox.d.mts.map +1 -0
- package/dist/jsx/components/form/Checkbox.mjs +17 -0
- package/dist/jsx/components/form/Checkbox.mjs.map +1 -0
- package/dist/jsx/components/form/Dropdown.cjs +23 -0
- package/dist/jsx/components/form/Dropdown.cjs.map +1 -0
- package/dist/{types/jsx/components/form/Dropdown.d.ts → jsx/components/form/Dropdown.d.cts} +4 -3
- package/dist/jsx/components/form/Dropdown.d.cts.map +1 -0
- package/dist/jsx/components/form/Dropdown.d.mts +39 -0
- package/dist/jsx/components/form/Dropdown.d.mts.map +1 -0
- package/dist/jsx/components/form/Dropdown.mjs +20 -0
- package/dist/jsx/components/form/Dropdown.mjs.map +1 -0
- package/dist/jsx/components/form/Field.cjs +26 -0
- package/dist/jsx/components/form/Field.cjs.map +1 -0
- package/dist/{types/jsx/components/form/Field.d.ts → jsx/components/form/Field.d.cts} +10 -9
- package/dist/jsx/components/form/Field.d.cts.map +1 -0
- package/dist/jsx/components/form/Field.d.mts +46 -0
- package/dist/jsx/components/form/Field.d.mts.map +1 -0
- package/dist/jsx/components/form/Field.mjs +23 -0
- package/dist/jsx/components/form/Field.mjs.map +1 -0
- package/dist/jsx/components/form/FileInput.cjs +31 -0
- package/dist/jsx/components/form/FileInput.cjs.map +1 -0
- package/dist/{types/jsx/components/form/FileInput.d.ts → jsx/components/form/FileInput.d.cts} +2 -1
- package/dist/jsx/components/form/FileInput.d.cts.map +1 -0
- package/dist/jsx/components/form/FileInput.d.mts +48 -0
- package/dist/jsx/components/form/FileInput.d.mts.map +1 -0
- package/dist/jsx/components/form/FileInput.mjs +28 -0
- package/dist/jsx/components/form/FileInput.mjs.map +1 -0
- package/dist/jsx/components/form/Form.cjs +24 -0
- package/dist/jsx/components/form/Form.cjs.map +1 -0
- package/dist/{types/jsx/components/form/Form.d.ts → jsx/components/form/Form.d.cts} +3 -2
- package/dist/jsx/components/form/Form.d.cts.map +1 -0
- package/dist/jsx/components/form/Form.d.mts +37 -0
- package/dist/jsx/components/form/Form.d.mts.map +1 -0
- package/dist/jsx/components/form/Form.mjs +21 -0
- package/dist/jsx/components/form/Form.mjs.map +1 -0
- package/dist/jsx/components/form/Input.cjs +20 -0
- package/dist/jsx/components/form/Input.cjs.map +1 -0
- package/dist/{types/jsx/components/form/Input.d.ts → jsx/components/form/Input.d.cts} +2 -1
- package/dist/jsx/components/form/Input.d.cts.map +1 -0
- package/dist/jsx/components/form/Input.d.mts +36 -0
- package/dist/jsx/components/form/Input.d.mts.map +1 -0
- package/dist/jsx/components/form/Input.mjs +17 -0
- package/dist/jsx/components/form/Input.mjs.map +1 -0
- package/dist/jsx/components/form/Option.cjs +25 -0
- package/dist/jsx/components/form/Option.cjs.map +1 -0
- package/dist/{types/jsx/components/form/Option.d.ts → jsx/components/form/Option.d.cts} +2 -1
- package/dist/jsx/components/form/Option.d.cts.map +1 -0
- package/dist/jsx/components/form/Option.d.mts +36 -0
- package/dist/jsx/components/form/Option.d.mts.map +1 -0
- package/dist/jsx/components/form/Option.mjs +22 -0
- package/dist/jsx/components/form/Option.mjs.map +1 -0
- package/dist/jsx/components/form/Radio.cjs +23 -0
- package/dist/jsx/components/form/Radio.cjs.map +1 -0
- package/dist/{types/jsx/components/form/Radio.d.ts → jsx/components/form/Radio.d.cts} +2 -1
- package/dist/jsx/components/form/Radio.d.cts.map +1 -0
- package/dist/jsx/components/form/Radio.d.mts +36 -0
- package/dist/jsx/components/form/Radio.d.mts.map +1 -0
- package/dist/jsx/components/form/Radio.mjs +20 -0
- package/dist/jsx/components/form/Radio.mjs.map +1 -0
- package/dist/jsx/components/form/RadioGroup.cjs +14 -0
- package/dist/jsx/components/form/RadioGroup.cjs.map +1 -0
- package/dist/{types/jsx/components/form/RadioGroup.d.ts → jsx/components/form/RadioGroup.d.cts} +4 -3
- package/dist/jsx/components/form/RadioGroup.d.cts.map +1 -0
- package/dist/jsx/components/form/RadioGroup.d.mts +30 -0
- package/dist/jsx/components/form/RadioGroup.d.mts.map +1 -0
- package/dist/jsx/components/form/RadioGroup.mjs +11 -0
- package/dist/jsx/components/form/RadioGroup.mjs.map +1 -0
- package/dist/jsx/components/form/Selector.cjs +24 -0
- package/dist/jsx/components/form/Selector.cjs.map +1 -0
- package/dist/{types/jsx/components/form/Selector.d.ts → jsx/components/form/Selector.d.cts} +4 -3
- package/dist/jsx/components/form/Selector.d.cts.map +1 -0
- package/dist/jsx/components/form/Selector.d.mts +42 -0
- package/dist/jsx/components/form/Selector.d.mts.map +1 -0
- package/dist/jsx/components/form/Selector.mjs +21 -0
- package/dist/jsx/components/form/Selector.mjs.map +1 -0
- package/dist/jsx/components/form/SelectorOption.cjs +23 -0
- package/dist/jsx/components/form/SelectorOption.cjs.map +1 -0
- package/dist/{types/jsx/components/form/SelectorOption.d.ts → jsx/components/form/SelectorOption.d.cts} +3 -2
- package/dist/jsx/components/form/SelectorOption.d.cts.map +1 -0
- package/dist/jsx/components/form/SelectorOption.d.mts +36 -0
- package/dist/jsx/components/form/SelectorOption.d.mts.map +1 -0
- package/dist/jsx/components/form/SelectorOption.mjs +20 -0
- package/dist/jsx/components/form/SelectorOption.mjs.map +1 -0
- package/dist/jsx/components/form/index.cjs +29 -0
- package/dist/jsx/components/form/index.cjs.map +1 -0
- package/dist/jsx/components/form/index.d.cts +26 -0
- package/dist/jsx/components/form/index.d.cts.map +1 -0
- package/dist/jsx/components/form/index.d.mts +26 -0
- package/dist/jsx/components/form/index.d.mts.map +1 -0
- package/dist/jsx/components/form/index.mjs +13 -0
- package/dist/jsx/components/form/index.mjs.map +1 -0
- package/dist/jsx/components/formatting/Bold.cjs +21 -0
- package/dist/jsx/components/formatting/Bold.cjs.map +1 -0
- package/dist/{types/jsx/components/formatting/Bold.d.ts → jsx/components/formatting/Bold.d.cts} +3 -2
- package/dist/jsx/components/formatting/Bold.d.cts.map +1 -0
- package/dist/jsx/components/formatting/Bold.d.mts +33 -0
- package/dist/jsx/components/formatting/Bold.d.mts.map +1 -0
- package/dist/jsx/components/formatting/Bold.mjs +18 -0
- package/dist/jsx/components/formatting/Bold.mjs.map +1 -0
- package/dist/jsx/components/formatting/Italic.cjs +20 -0
- package/dist/jsx/components/formatting/Italic.cjs.map +1 -0
- package/dist/{types/jsx/components/formatting/Italic.d.ts → jsx/components/formatting/Italic.d.cts} +3 -2
- package/dist/jsx/components/formatting/Italic.d.cts.map +1 -0
- package/dist/jsx/components/formatting/Italic.d.mts +35 -0
- package/dist/jsx/components/formatting/Italic.d.mts.map +1 -0
- package/dist/jsx/components/formatting/Italic.mjs +17 -0
- package/dist/jsx/components/formatting/Italic.mjs.map +1 -0
- package/dist/jsx/components/formatting/index.cjs +19 -0
- package/dist/jsx/components/formatting/index.cjs.map +1 -0
- package/dist/jsx/components/formatting/index.d.cts +6 -0
- package/dist/jsx/components/formatting/index.d.cts.map +1 -0
- package/dist/jsx/components/formatting/index.d.mts +6 -0
- package/dist/jsx/components/formatting/index.d.mts.map +1 -0
- package/dist/jsx/components/formatting/index.mjs +3 -0
- package/dist/jsx/components/formatting/index.mjs.map +1 -0
- package/dist/jsx/components/index.cjs +36 -0
- package/dist/jsx/components/index.cjs.map +1 -0
- package/dist/jsx/components/index.d.cts +43 -0
- package/dist/jsx/components/index.d.cts.map +1 -0
- package/dist/jsx/components/index.d.mts +43 -0
- package/dist/jsx/components/index.d.mts.map +1 -0
- package/dist/jsx/components/index.mjs +20 -0
- package/dist/jsx/components/index.mjs.map +1 -0
- package/dist/jsx/index.cjs +31 -0
- package/dist/jsx/index.cjs.map +1 -0
- package/dist/jsx/index.d.cts +6 -0
- package/dist/jsx/index.d.cts.map +1 -0
- package/dist/jsx/index.d.mts +6 -0
- package/dist/jsx/index.d.mts.map +1 -0
- package/dist/jsx/index.mjs +5 -809
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/jsx-dev-runtime.cjs +27 -0
- package/dist/jsx/jsx-dev-runtime.cjs.map +1 -0
- package/dist/{types/jsx/jsx-dev-runtime.d.ts → jsx/jsx-dev-runtime.d.cts} +2 -1
- package/dist/jsx/jsx-dev-runtime.d.cts.map +1 -0
- package/dist/jsx/jsx-dev-runtime.d.mts +18 -0
- package/dist/jsx/jsx-dev-runtime.d.mts.map +1 -0
- package/dist/jsx/jsx-dev-runtime.mjs +21 -642
- package/dist/jsx/jsx-dev-runtime.mjs.map +1 -1
- package/dist/jsx/jsx-runtime.cjs +54 -0
- package/dist/jsx/jsx-runtime.cjs.map +1 -0
- package/dist/{types/jsx/jsx-runtime.d.ts → jsx/jsx-runtime.d.cts} +2 -1
- package/dist/jsx/jsx-runtime.d.cts.map +1 -0
- package/dist/jsx/jsx-runtime.d.mts +36 -0
- package/dist/jsx/jsx-runtime.d.mts.map +1 -0
- package/dist/jsx/jsx-runtime.mjs +46 -21
- package/dist/jsx/jsx-runtime.mjs.map +1 -1
- package/dist/jsx/validation.cjs +600 -0
- package/dist/jsx/validation.cjs.map +1 -0
- package/dist/{types/jsx/validation.d.ts → jsx/validation.d.cts} +32 -27
- package/dist/jsx/validation.d.cts.map +1 -0
- package/dist/jsx/validation.d.mts +247 -0
- package/dist/jsx/validation.d.mts.map +1 -0
- package/dist/jsx/validation.mjs +594 -0
- package/dist/jsx/validation.mjs.map +1 -0
- package/dist/types/caip.cjs +3 -0
- package/dist/types/caip.cjs.map +1 -0
- package/dist/types/{types/caip.d.ts → caip.d.cts} +1 -0
- package/dist/types/caip.d.cts.map +1 -0
- package/dist/types/caip.d.mts +13 -0
- package/dist/types/caip.d.mts.map +1 -0
- package/dist/types/caip.mjs +2 -0
- package/dist/types/caip.mjs.map +1 -0
- package/dist/types/global.cjs +3 -0
- package/dist/types/global.cjs.map +1 -0
- package/dist/types/{types/global.d.ts → global.d.cts} +2 -1
- package/dist/types/global.d.cts.map +1 -0
- package/dist/types/global.d.mts +9 -0
- package/dist/types/global.d.mts.map +1 -0
- package/dist/types/global.mjs +2 -0
- package/dist/types/global.mjs.map +1 -0
- package/dist/types/handlers/cronjob.cjs +3 -0
- package/dist/types/handlers/cronjob.cjs.map +1 -0
- package/dist/types/{types/handlers/cronjob.d.ts → handlers/cronjob.d.cts} +2 -1
- package/dist/types/handlers/cronjob.d.cts.map +1 -0
- package/dist/types/handlers/cronjob.d.mts +15 -0
- package/dist/types/handlers/cronjob.d.mts.map +1 -0
- package/dist/types/handlers/cronjob.mjs +2 -0
- package/dist/types/handlers/cronjob.mjs.map +1 -0
- package/dist/types/handlers/home-page.cjs +3 -0
- package/dist/types/handlers/home-page.cjs.map +1 -0
- package/dist/types/{types/handlers/home-page.d.ts → handlers/home-page.d.cts} +2 -1
- package/dist/types/handlers/home-page.d.cts.map +1 -0
- package/dist/types/handlers/home-page.d.mts +23 -0
- package/dist/types/handlers/home-page.d.mts.map +1 -0
- package/dist/types/handlers/home-page.mjs +2 -0
- package/dist/types/handlers/home-page.mjs.map +1 -0
- package/dist/types/handlers/index.cjs +26 -0
- package/dist/types/handlers/index.cjs.map +1 -0
- package/dist/types/handlers/index.d.cts +10 -0
- package/dist/types/handlers/index.d.cts.map +1 -0
- package/dist/types/handlers/index.d.mts +10 -0
- package/dist/types/handlers/index.d.mts.map +1 -0
- package/dist/types/handlers/index.mjs +10 -0
- package/dist/types/handlers/index.mjs.map +1 -0
- package/dist/types/handlers/keyring.cjs +3 -0
- package/dist/types/handlers/keyring.cjs.map +1 -0
- package/dist/types/{types/handlers/keyring.d.ts → handlers/keyring.d.cts} +2 -1
- package/dist/types/handlers/keyring.d.cts.map +1 -0
- package/dist/types/handlers/keyring.d.mts +21 -0
- package/dist/types/handlers/keyring.d.mts.map +1 -0
- package/dist/types/handlers/keyring.mjs +2 -0
- package/dist/types/handlers/keyring.mjs.map +1 -0
- package/dist/types/handlers/lifecycle.cjs +3 -0
- package/dist/types/handlers/lifecycle.cjs.map +1 -0
- package/dist/types/{types/handlers/lifecycle.d.ts → handlers/lifecycle.d.cts} +1 -0
- package/dist/types/handlers/lifecycle.d.cts.map +1 -0
- package/dist/types/handlers/lifecycle.d.mts +38 -0
- package/dist/types/handlers/lifecycle.d.mts.map +1 -0
- package/dist/types/handlers/lifecycle.mjs +2 -0
- package/dist/types/handlers/lifecycle.mjs.map +1 -0
- package/dist/types/handlers/name-lookup.cjs +3 -0
- package/dist/types/handlers/name-lookup.cjs.map +1 -0
- package/dist/types/{types/handlers/name-lookup.d.ts → handlers/name-lookup.d.cts} +3 -2
- package/dist/types/handlers/name-lookup.d.cts.map +1 -0
- package/dist/types/handlers/name-lookup.d.mts +82 -0
- package/dist/types/handlers/name-lookup.d.mts.map +1 -0
- package/dist/types/handlers/name-lookup.mjs +2 -0
- package/dist/types/handlers/name-lookup.mjs.map +1 -0
- package/dist/types/handlers/rpc-request.cjs +3 -0
- package/dist/types/handlers/rpc-request.cjs.map +1 -0
- package/dist/types/{types/handlers/rpc-request.d.ts → handlers/rpc-request.d.cts} +2 -1
- package/dist/types/handlers/rpc-request.d.cts.map +1 -0
- package/dist/types/handlers/rpc-request.d.mts +22 -0
- package/dist/types/handlers/rpc-request.d.mts.map +1 -0
- package/dist/types/handlers/rpc-request.mjs +2 -0
- package/dist/types/handlers/rpc-request.mjs.map +1 -0
- package/dist/types/handlers/signature.cjs +3 -0
- package/dist/types/handlers/signature.cjs.map +1 -0
- package/dist/types/{types/handlers/signature.d.ts → handlers/signature.d.cts} +4 -3
- package/dist/types/handlers/signature.d.cts.map +1 -0
- package/dist/types/handlers/signature.d.mts +112 -0
- package/dist/types/handlers/signature.d.mts.map +1 -0
- package/dist/types/handlers/signature.mjs +2 -0
- package/dist/types/handlers/signature.mjs.map +1 -0
- package/dist/types/handlers/transaction.cjs +15 -0
- package/dist/types/handlers/transaction.cjs.map +1 -0
- package/dist/types/{types/handlers/transaction.d.ts → handlers/transaction.d.cts} +4 -3
- package/dist/types/handlers/transaction.d.cts.map +1 -0
- package/dist/types/handlers/transaction.d.mts +115 -0
- package/dist/types/handlers/transaction.d.mts.map +1 -0
- package/dist/types/handlers/transaction.mjs +12 -0
- package/dist/types/handlers/transaction.mjs.map +1 -0
- package/dist/types/handlers/user-input.cjs +56 -0
- package/dist/types/handlers/user-input.cjs.map +1 -0
- package/dist/types/{types/handlers/user-input.d.ts → handlers/user-input.d.cts} +11 -10
- package/dist/types/handlers/user-input.d.cts.map +1 -0
- package/dist/types/handlers/user-input.d.mts +196 -0
- package/dist/types/handlers/user-input.d.mts.map +1 -0
- package/dist/types/handlers/user-input.mjs +53 -0
- package/dist/types/handlers/user-input.mjs.map +1 -0
- package/dist/types/images.cjs +2 -0
- package/dist/types/images.cjs.map +1 -0
- package/dist/types/{types/images.d.ts → images.d.cts} +1 -0
- package/dist/types/images.d.cts.map +1 -0
- package/dist/types/images.d.mts +13 -0
- package/dist/types/images.d.mts.map +1 -0
- package/dist/types/images.mjs +2 -0
- package/dist/types/images.mjs.map +1 -0
- package/dist/types/index.cjs +29 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +10 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.mts +10 -0
- package/dist/types/index.d.mts.map +1 -0
- package/dist/types/index.mjs +13 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/interface.cjs +26 -0
- package/dist/types/interface.cjs.map +1 -0
- package/dist/types/interface.d.cts +120 -0
- package/dist/types/interface.d.cts.map +1 -0
- package/dist/types/interface.d.mts +120 -0
- package/dist/types/interface.d.mts.map +1 -0
- package/dist/types/interface.mjs +23 -0
- package/dist/types/interface.mjs.map +1 -0
- package/dist/types/methods/create-interface.cjs +3 -0
- package/dist/types/methods/create-interface.cjs.map +1 -0
- package/dist/types/{types/methods/create-interface.d.ts → methods/create-interface.d.cts} +2 -1
- package/dist/types/methods/create-interface.d.cts.map +1 -0
- package/dist/types/methods/create-interface.d.mts +15 -0
- package/dist/types/methods/create-interface.d.mts.map +1 -0
- package/dist/types/methods/create-interface.mjs +2 -0
- package/dist/types/methods/create-interface.mjs.map +1 -0
- package/dist/types/methods/dialog.cjs +18 -0
- package/dist/types/methods/dialog.cjs.map +1 -0
- package/dist/types/{types/methods/dialog.d.ts → methods/dialog.d.cts} +4 -3
- package/dist/types/methods/dialog.d.cts.map +1 -0
- package/dist/types/methods/dialog.d.mts +88 -0
- package/dist/types/methods/dialog.d.mts.map +1 -0
- package/dist/types/methods/dialog.mjs +15 -0
- package/dist/types/methods/dialog.mjs.map +1 -0
- package/dist/types/methods/get-bip32-entropy.cjs +3 -0
- package/dist/types/methods/get-bip32-entropy.cjs.map +1 -0
- package/dist/types/{types/methods/get-bip32-entropy.d.ts → methods/get-bip32-entropy.d.cts} +3 -2
- package/dist/types/methods/get-bip32-entropy.d.cts.map +1 -0
- package/dist/types/methods/get-bip32-entropy.d.mts +16 -0
- package/dist/types/methods/get-bip32-entropy.d.mts.map +1 -0
- package/dist/types/methods/get-bip32-entropy.mjs +2 -0
- package/dist/types/methods/get-bip32-entropy.mjs.map +1 -0
- package/dist/types/methods/get-bip32-public-key.cjs +3 -0
- package/dist/types/methods/get-bip32-public-key.cjs.map +1 -0
- package/dist/types/{types/methods/get-bip32-public-key.d.ts → methods/get-bip32-public-key.d.cts} +2 -1
- package/dist/types/methods/get-bip32-public-key.d.cts.map +1 -0
- package/dist/types/methods/get-bip32-public-key.d.mts +20 -0
- package/dist/types/methods/get-bip32-public-key.d.mts.map +1 -0
- package/dist/types/methods/get-bip32-public-key.mjs +2 -0
- package/dist/types/methods/get-bip32-public-key.mjs.map +1 -0
- package/dist/types/methods/get-bip44-entropy.cjs +3 -0
- package/dist/types/methods/get-bip44-entropy.cjs.map +1 -0
- package/dist/types/{types/methods/get-bip44-entropy.d.ts → methods/get-bip44-entropy.d.cts} +3 -2
- package/dist/types/methods/get-bip44-entropy.d.cts.map +1 -0
- package/dist/types/methods/get-bip44-entropy.d.mts +15 -0
- package/dist/types/methods/get-bip44-entropy.d.mts.map +1 -0
- package/dist/types/methods/get-bip44-entropy.mjs +2 -0
- package/dist/types/methods/get-bip44-entropy.mjs.map +1 -0
- package/dist/types/methods/get-client-status.cjs +3 -0
- package/dist/types/methods/get-client-status.cjs.map +1 -0
- package/dist/types/{types/methods/get-client-status.d.ts → methods/get-client-status.d.cts} +1 -0
- package/dist/types/methods/get-client-status.d.cts.map +1 -0
- package/dist/types/methods/get-client-status.d.mts +15 -0
- package/dist/types/methods/get-client-status.d.mts.map +1 -0
- package/dist/types/methods/get-client-status.mjs +2 -0
- package/dist/types/methods/get-client-status.mjs.map +1 -0
- package/dist/types/methods/get-entropy.cjs +3 -0
- package/dist/types/methods/get-entropy.cjs.map +1 -0
- package/dist/types/{types/methods/get-entropy.d.ts → methods/get-entropy.d.cts} +2 -1
- package/dist/types/methods/get-entropy.d.cts.map +1 -0
- package/dist/types/methods/get-entropy.d.mts +17 -0
- package/dist/types/methods/get-entropy.d.mts.map +1 -0
- package/dist/types/methods/get-entropy.mjs +2 -0
- package/dist/types/methods/get-entropy.mjs.map +1 -0
- package/dist/types/methods/get-file.cjs +13 -0
- package/dist/types/methods/get-file.cjs.map +1 -0
- package/dist/types/{types/methods/get-file.d.ts → methods/get-file.d.cts} +2 -1
- package/dist/types/methods/get-file.d.cts.map +1 -0
- package/dist/types/methods/get-file.d.mts +24 -0
- package/dist/types/methods/get-file.d.mts.map +1 -0
- package/dist/types/methods/get-file.mjs +10 -0
- package/dist/types/methods/get-file.mjs.map +1 -0
- package/dist/types/methods/get-interface-state.cjs +3 -0
- package/dist/types/methods/get-interface-state.cjs.map +1 -0
- package/dist/types/{types/methods/get-interface-state.d.ts → methods/get-interface-state.d.cts} +2 -1
- package/dist/types/methods/get-interface-state.d.cts.map +1 -0
- package/dist/types/methods/get-interface-state.d.mts +14 -0
- package/dist/types/methods/get-interface-state.d.mts.map +1 -0
- package/dist/types/methods/get-interface-state.mjs +2 -0
- package/dist/types/methods/get-interface-state.mjs.map +1 -0
- package/dist/types/methods/get-locale.cjs +3 -0
- package/dist/types/methods/get-locale.cjs.map +1 -0
- package/dist/types/{types/methods/get-locale.d.ts → methods/get-locale.d.cts} +1 -0
- package/dist/types/methods/get-locale.d.cts.map +1 -0
- package/dist/types/methods/get-locale.d.mts +13 -0
- package/dist/types/methods/get-locale.d.mts.map +1 -0
- package/dist/types/methods/get-locale.mjs +2 -0
- package/dist/types/methods/get-locale.mjs.map +1 -0
- package/dist/types/methods/get-preferences.cjs +3 -0
- package/dist/types/methods/get-preferences.cjs.map +1 -0
- package/dist/types/{types/methods/get-preferences.d.ts → methods/get-preferences.d.cts} +1 -0
- package/dist/types/methods/get-preferences.d.cts.map +1 -0
- package/dist/types/methods/get-preferences.d.mts +16 -0
- package/dist/types/methods/get-preferences.d.mts.map +1 -0
- package/dist/types/methods/get-preferences.mjs +2 -0
- package/dist/types/methods/get-preferences.mjs.map +1 -0
- package/dist/types/methods/get-snaps.cjs +3 -0
- package/dist/types/methods/get-snaps.cjs.map +1 -0
- package/dist/types/{types/methods/get-snaps.d.ts → methods/get-snaps.d.cts} +3 -2
- package/dist/types/methods/get-snaps.d.cts.map +1 -0
- package/dist/types/methods/get-snaps.d.mts +17 -0
- package/dist/types/methods/get-snaps.d.mts.map +1 -0
- package/dist/types/methods/get-snaps.mjs +2 -0
- package/dist/types/methods/get-snaps.mjs.map +1 -0
- package/dist/types/methods/index.cjs +38 -0
- package/dist/types/methods/index.cjs.map +1 -0
- package/dist/types/methods/index.d.cts +22 -0
- package/dist/types/methods/index.d.cts.map +1 -0
- package/dist/types/methods/index.d.mts +22 -0
- package/dist/types/methods/index.d.mts.map +1 -0
- package/dist/types/methods/index.mjs +22 -0
- package/dist/types/methods/index.mjs.map +1 -0
- package/dist/types/methods/invoke-keyring.cjs +3 -0
- package/dist/types/methods/invoke-keyring.cjs.map +1 -0
- package/dist/types/{types/methods/invoke-keyring.d.ts → methods/invoke-keyring.d.cts} +3 -2
- package/dist/types/methods/invoke-keyring.d.cts.map +1 -0
- package/dist/types/methods/invoke-keyring.d.mts +15 -0
- package/dist/types/methods/invoke-keyring.d.mts.map +1 -0
- package/dist/types/methods/invoke-keyring.mjs +2 -0
- package/dist/types/methods/invoke-keyring.mjs.map +1 -0
- package/dist/types/methods/invoke-snap.cjs +3 -0
- package/dist/types/methods/invoke-snap.cjs.map +1 -0
- package/dist/types/{types/methods/invoke-snap.d.ts → methods/invoke-snap.d.cts} +2 -1
- package/dist/types/methods/invoke-snap.d.cts.map +1 -0
- package/dist/types/methods/invoke-snap.d.mts +17 -0
- package/dist/types/methods/invoke-snap.d.mts.map +1 -0
- package/dist/types/methods/invoke-snap.mjs +2 -0
- package/dist/types/methods/invoke-snap.mjs.map +1 -0
- package/dist/types/methods/manage-accounts.cjs +3 -0
- package/dist/types/methods/manage-accounts.cjs.map +1 -0
- package/dist/types/{types/methods/manage-accounts.d.ts → methods/manage-accounts.d.cts} +2 -1
- package/dist/types/methods/manage-accounts.d.cts.map +1 -0
- package/dist/types/methods/manage-accounts.d.mts +19 -0
- package/dist/types/methods/manage-accounts.d.mts.map +1 -0
- package/dist/types/methods/manage-accounts.mjs +2 -0
- package/dist/types/methods/manage-accounts.mjs.map +1 -0
- package/dist/types/methods/manage-state.cjs +13 -0
- package/dist/types/methods/manage-state.cjs.map +1 -0
- package/dist/types/{types/methods/manage-state.d.ts → methods/manage-state.d.cts} +3 -2
- package/dist/types/methods/manage-state.d.cts.map +1 -0
- package/dist/types/methods/manage-state.d.mts +70 -0
- package/dist/types/methods/manage-state.d.mts.map +1 -0
- package/dist/types/methods/manage-state.mjs +10 -0
- package/dist/types/methods/manage-state.mjs.map +1 -0
- package/dist/types/methods/methods.cjs +3 -0
- package/dist/types/methods/methods.cjs.map +1 -0
- package/dist/types/{types/methods/methods.d.ts → methods/methods.d.cts} +22 -21
- package/dist/types/methods/methods.d.cts.map +1 -0
- package/dist/types/methods/methods.d.mts +75 -0
- package/dist/types/methods/methods.d.mts.map +1 -0
- package/dist/types/methods/methods.mjs +2 -0
- package/dist/types/methods/methods.mjs.map +1 -0
- package/dist/types/methods/notify.cjs +15 -0
- package/dist/types/methods/notify.cjs.map +1 -0
- package/dist/types/{types/methods/notify.d.ts → methods/notify.d.cts} +2 -1
- package/dist/types/methods/notify.d.cts.map +1 -0
- package/dist/types/methods/notify.d.mts +28 -0
- package/dist/types/methods/notify.d.mts.map +1 -0
- package/dist/types/methods/notify.mjs +12 -0
- package/dist/types/methods/notify.mjs.map +1 -0
- package/dist/types/methods/request-snaps.cjs +3 -0
- package/dist/types/methods/request-snaps.cjs.map +1 -0
- package/dist/types/{types/methods/request-snaps.d.ts → methods/request-snaps.d.cts} +3 -2
- package/dist/types/methods/request-snaps.d.cts.map +1 -0
- package/dist/types/methods/request-snaps.d.mts +19 -0
- package/dist/types/methods/request-snaps.d.mts.map +1 -0
- package/dist/types/methods/request-snaps.mjs +2 -0
- package/dist/types/methods/request-snaps.mjs.map +1 -0
- package/dist/types/methods/resolve-interface.cjs +3 -0
- package/dist/types/methods/resolve-interface.cjs.map +1 -0
- package/dist/types/{types/methods/resolve-interface.d.ts → methods/resolve-interface.d.cts} +2 -1
- package/dist/types/methods/resolve-interface.d.cts.map +1 -0
- package/dist/types/methods/resolve-interface.d.mts +16 -0
- package/dist/types/methods/resolve-interface.d.mts.map +1 -0
- package/dist/types/methods/resolve-interface.mjs +2 -0
- package/dist/types/methods/resolve-interface.mjs.map +1 -0
- package/dist/types/methods/update-interface.cjs +3 -0
- package/dist/types/methods/update-interface.cjs.map +1 -0
- package/dist/types/{types/methods/update-interface.d.ts → methods/update-interface.d.cts} +2 -1
- package/dist/types/methods/update-interface.d.cts.map +1 -0
- package/dist/types/methods/update-interface.d.mts +16 -0
- package/dist/types/methods/update-interface.d.mts.map +1 -0
- package/dist/types/methods/update-interface.mjs +2 -0
- package/dist/types/methods/update-interface.mjs.map +1 -0
- package/dist/types/permissions.cjs +3 -0
- package/dist/types/permissions.cjs.map +1 -0
- package/dist/types/{types/permissions.d.ts → permissions.d.cts} +4 -3
- package/dist/types/permissions.d.cts.map +1 -0
- package/dist/types/permissions.d.mts +75 -0
- package/dist/types/permissions.d.mts.map +1 -0
- package/dist/types/permissions.mjs +2 -0
- package/dist/types/permissions.mjs.map +1 -0
- package/dist/types/provider.cjs +3 -0
- package/dist/types/provider.cjs.map +1 -0
- package/dist/types/{types/provider.d.ts → provider.d.cts} +3 -2
- package/dist/types/provider.d.cts.map +1 -0
- package/dist/types/provider.d.mts +15 -0
- package/dist/types/provider.d.mts.map +1 -0
- package/dist/types/provider.mjs +2 -0
- package/dist/types/provider.mjs.map +1 -0
- package/dist/types/snap.cjs +3 -0
- package/dist/types/snap.cjs.map +1 -0
- package/dist/types/{types/snap.d.ts → snap.d.cts} +3 -2
- package/dist/types/snap.d.cts.map +1 -0
- package/dist/types/snap.d.mts +13 -0
- package/dist/types/snap.d.mts.map +1 -0
- package/dist/types/snap.mjs +2 -0
- package/dist/types/snap.mjs.map +1 -0
- package/dist/ui/builder.cjs +49 -0
- package/dist/ui/builder.cjs.map +1 -0
- package/dist/{types/ui/builder.d.ts → ui/builder.d.cts} +4 -3
- package/dist/ui/builder.d.cts.map +1 -0
- package/dist/ui/builder.d.mts +43 -0
- package/dist/ui/builder.d.mts.map +1 -0
- package/dist/ui/builder.mjs +45 -0
- package/dist/ui/builder.mjs.map +1 -0
- package/dist/ui/component.cjs +29 -0
- package/dist/ui/component.cjs.map +1 -0
- package/dist/{types/ui/component.d.ts → ui/component.d.cts} +2 -1
- package/dist/ui/component.d.cts.map +1 -0
- package/dist/ui/component.d.mts +18 -0
- package/dist/ui/component.d.mts.map +1 -0
- package/dist/ui/component.mjs +24 -0
- package/dist/ui/component.mjs.map +1 -0
- package/dist/ui/components/address.cjs +28 -0
- package/dist/ui/components/address.cjs.map +1 -0
- package/dist/{types/ui/components/address.d.ts → ui/components/address.d.cts} +6 -5
- package/dist/ui/components/address.d.cts.map +1 -0
- package/dist/ui/components/address.d.mts +37 -0
- package/dist/ui/components/address.d.mts.map +1 -0
- package/dist/ui/components/address.mjs +25 -0
- package/dist/ui/components/address.mjs.map +1 -0
- package/dist/ui/components/button.cjs +52 -0
- package/dist/ui/components/button.cjs.map +1 -0
- package/dist/{types/ui/components/button.d.ts → ui/components/button.d.cts} +9 -8
- package/dist/ui/components/button.d.cts.map +1 -0
- package/dist/ui/components/button.d.mts +65 -0
- package/dist/ui/components/button.d.mts.map +1 -0
- package/dist/ui/components/button.mjs +49 -0
- package/dist/ui/components/button.mjs.map +1 -0
- package/dist/ui/components/copyable.cjs +32 -0
- package/dist/ui/components/copyable.cjs.map +1 -0
- package/dist/{types/ui/components/copyable.d.ts → ui/components/copyable.d.cts} +6 -5
- package/dist/ui/components/copyable.d.cts.map +1 -0
- package/dist/ui/components/copyable.d.mts +49 -0
- package/dist/ui/components/copyable.d.mts.map +1 -0
- package/dist/ui/components/copyable.mjs +29 -0
- package/dist/ui/components/copyable.mjs.map +1 -0
- package/dist/ui/components/divider.cjs +20 -0
- package/dist/ui/components/divider.cjs.map +1 -0
- package/dist/{types/ui/components/divider.d.ts → ui/components/divider.d.cts} +3 -2
- package/dist/ui/components/divider.d.cts.map +1 -0
- package/dist/ui/components/divider.d.mts +24 -0
- package/dist/ui/components/divider.d.mts.map +1 -0
- package/dist/ui/components/divider.mjs +17 -0
- package/dist/ui/components/divider.mjs.map +1 -0
- package/dist/ui/components/form.cjs +41 -0
- package/dist/ui/components/form.cjs.map +1 -0
- package/dist/{types/ui/components/form.d.ts → ui/components/form.d.cts} +31 -30
- package/dist/ui/components/form.d.cts.map +1 -0
- package/dist/ui/components/form.d.mts +154 -0
- package/dist/ui/components/form.d.mts.map +1 -0
- package/dist/ui/components/form.mjs +38 -0
- package/dist/ui/components/form.mjs.map +1 -0
- package/dist/ui/components/heading.cjs +27 -0
- package/dist/ui/components/heading.cjs.map +1 -0
- package/dist/{types/ui/components/heading.d.ts → ui/components/heading.d.cts} +6 -5
- package/dist/ui/components/heading.d.cts.map +1 -0
- package/dist/ui/components/heading.d.mts +39 -0
- package/dist/ui/components/heading.d.mts.map +1 -0
- package/dist/ui/components/heading.mjs +24 -0
- package/dist/ui/components/heading.mjs.map +1 -0
- package/dist/ui/components/image.cjs +27 -0
- package/dist/ui/components/image.cjs.map +1 -0
- package/dist/{types/ui/components/image.d.ts → ui/components/image.d.cts} +6 -5
- package/dist/ui/components/image.d.cts.map +1 -0
- package/dist/ui/components/image.d.mts +38 -0
- package/dist/ui/components/image.d.mts.map +1 -0
- package/dist/ui/components/image.mjs +24 -0
- package/dist/ui/components/image.mjs.map +1 -0
- package/dist/ui/components/index.cjs +35 -0
- package/dist/ui/components/index.cjs.map +1 -0
- package/dist/ui/components/index.d.cts +15 -0
- package/dist/ui/components/index.d.cts.map +1 -0
- package/dist/ui/components/index.d.mts +15 -0
- package/dist/ui/components/index.d.mts.map +1 -0
- package/dist/ui/components/index.mjs +13 -0
- package/dist/ui/components/index.mjs.map +1 -0
- package/dist/ui/components/input.cjs +60 -0
- package/dist/ui/components/input.cjs.map +1 -0
- package/dist/{types/ui/components/input.d.ts → ui/components/input.d.cts} +9 -8
- package/dist/ui/components/input.d.cts.map +1 -0
- package/dist/ui/components/input.d.mts +78 -0
- package/dist/ui/components/input.d.mts.map +1 -0
- package/dist/ui/components/input.mjs +57 -0
- package/dist/ui/components/input.mjs.map +1 -0
- package/dist/ui/components/panel.cjs +72 -0
- package/dist/ui/components/panel.cjs.map +1 -0
- package/dist/{types/ui/components/panel.d.ts → ui/components/panel.d.cts} +88 -87
- package/dist/ui/components/panel.d.cts.map +1 -0
- package/dist/ui/components/panel.d.mts +406 -0
- package/dist/ui/components/panel.d.mts.map +1 -0
- package/dist/ui/components/panel.mjs +69 -0
- package/dist/ui/components/panel.mjs.map +1 -0
- package/dist/ui/components/row.cjs +51 -0
- package/dist/ui/components/row.cjs.map +1 -0
- package/dist/{types/ui/components/row.d.ts → ui/components/row.d.cts} +21 -20
- package/dist/ui/components/row.d.cts.map +1 -0
- package/dist/ui/components/row.d.mts +107 -0
- package/dist/ui/components/row.d.mts.map +1 -0
- package/dist/ui/components/row.mjs +48 -0
- package/dist/ui/components/row.mjs.map +1 -0
- package/dist/ui/components/spinner.cjs +20 -0
- package/dist/ui/components/spinner.cjs.map +1 -0
- package/dist/{types/ui/components/spinner.d.ts → ui/components/spinner.d.cts} +3 -2
- package/dist/ui/components/spinner.d.cts.map +1 -0
- package/dist/ui/components/spinner.d.mts +25 -0
- package/dist/ui/components/spinner.d.mts.map +1 -0
- package/dist/ui/components/spinner.mjs +17 -0
- package/dist/ui/components/spinner.mjs.map +1 -0
- package/dist/ui/components/text.cjs +34 -0
- package/dist/ui/components/text.cjs.map +1 -0
- package/dist/{types/ui/components/text.d.ts → ui/components/text.d.cts} +6 -5
- package/dist/ui/components/text.d.cts.map +1 -0
- package/dist/ui/components/text.d.mts +49 -0
- package/dist/ui/components/text.d.mts.map +1 -0
- package/dist/ui/components/text.mjs +31 -0
- package/dist/ui/components/text.mjs.map +1 -0
- package/dist/ui/index.cjs +22 -0
- package/dist/ui/index.cjs.map +1 -0
- package/dist/ui/index.d.cts +4 -0
- package/dist/ui/index.d.cts.map +1 -0
- package/dist/ui/index.d.mts +4 -0
- package/dist/ui/index.d.mts.map +1 -0
- package/dist/ui/index.mjs +4 -0
- package/dist/ui/index.mjs.map +1 -0
- package/dist/ui/nodes.cjs +38 -0
- package/dist/ui/nodes.cjs.map +1 -0
- package/dist/{types/ui/nodes.d.ts → ui/nodes.d.cts} +3 -2
- package/dist/ui/nodes.d.cts.map +1 -0
- package/dist/ui/nodes.d.mts +57 -0
- package/dist/ui/nodes.d.mts.map +1 -0
- package/dist/ui/nodes.mjs +35 -0
- package/dist/ui/nodes.mjs.map +1 -0
- package/jsx-dev-runtime.d.ts +3 -1
- package/jsx-dev-runtime.js +1 -1
- package/jsx-runtime.d.ts +3 -1
- package/jsx-runtime.js +1 -1
- package/jsx.d.ts +3 -1
- package/jsx.js +1 -1
- package/package.json +42 -27
- package/dist/index.js +0 -1370
- package/dist/index.js.map +0 -1
- package/dist/jsx/index.js +0 -810
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/jsx-dev-runtime.js +0 -644
- package/dist/jsx/jsx-dev-runtime.js.map +0 -1
- package/dist/jsx/jsx-runtime.js +0 -45
- package/dist/jsx/jsx-runtime.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/index.d.ts +0 -9
- package/dist/types/internals/index.d.ts +0 -6
- package/dist/types/jsx/components/Address.d.ts +0 -28
- package/dist/types/jsx/components/form/index.d.ts +0 -25
- package/dist/types/jsx/components/formatting/index.d.ts +0 -5
- package/dist/types/jsx/components/index.d.ts +0 -40
- package/dist/types/jsx/index.d.ts +0 -5
- package/dist/types/types/handlers/index.d.ts +0 -9
- package/dist/types/types/index.d.ts +0 -9
- package/dist/types/types/interface.d.ts +0 -119
- package/dist/types/types/methods/index.d.ts +0 -21
- package/dist/types/ui/components/index.d.ts +0 -14
- package/dist/types/ui/index.d.ts +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-wrappers.d.mts","sourceRoot":"","sources":["../src/error-wrappers.ts"],"names":[],"mappings":";AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAsC,CAAC;AAEjE;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA0C,CAAC;AAEzE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA2C,CAAC;AAE3E;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA4C,CAAC;AAE7E;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA2C,CAAC;AAE3E;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA4C,CAAC;AAE7E;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEnC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAmC,CAAC;AAE3D;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEjC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEpC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAE/B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAElC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA+C,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA+C,CAAC;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAElC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEpC,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { providerErrors, rpcErrors } from "@metamask/rpc-errors";
|
|
2
|
+
import { createSnapError } from "./internals/index.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* A JSON-RPC 2.0 Internal (-32603) error.
|
|
5
|
+
*
|
|
6
|
+
* This can be thrown by a Snap to indicate that an internal error occurred,
|
|
7
|
+
* without crashing the Snap.
|
|
8
|
+
*
|
|
9
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
10
|
+
*/
|
|
11
|
+
export const InternalError = createSnapError(rpcErrors.internal);
|
|
12
|
+
/**
|
|
13
|
+
* An Ethereum JSON-RPC Invalid Input (-32000) error.
|
|
14
|
+
*
|
|
15
|
+
* This can be thrown by a Snap to indicate that the input to a method is
|
|
16
|
+
* invalid, without crashing the Snap.
|
|
17
|
+
*
|
|
18
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
19
|
+
*/
|
|
20
|
+
export const InvalidInputError = createSnapError(rpcErrors.invalidInput);
|
|
21
|
+
/**
|
|
22
|
+
* A JSON-RPC 2.0 Invalid Params (-32602) error.
|
|
23
|
+
*
|
|
24
|
+
* This can be thrown by a Snap to indicate that the parameters to a method are
|
|
25
|
+
* invalid, without crashing the Snap.
|
|
26
|
+
*
|
|
27
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
28
|
+
*/
|
|
29
|
+
export const InvalidParamsError = createSnapError(rpcErrors.invalidParams);
|
|
30
|
+
/**
|
|
31
|
+
* A JSON-RPC 2.0 Invalid Request (-32600) error.
|
|
32
|
+
*
|
|
33
|
+
* This can be thrown by a Snap to indicate that the request is invalid, without
|
|
34
|
+
* crashing the Snap.
|
|
35
|
+
*
|
|
36
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
37
|
+
*/
|
|
38
|
+
export const InvalidRequestError = createSnapError(rpcErrors.invalidRequest);
|
|
39
|
+
/**
|
|
40
|
+
* An Ethereum JSON-RPC Limit Exceeded (-32005) error.
|
|
41
|
+
*
|
|
42
|
+
* This can be thrown by a Snap to indicate that a limit has been exceeded,
|
|
43
|
+
* without crashing the Snap.
|
|
44
|
+
*
|
|
45
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
46
|
+
*/
|
|
47
|
+
export const LimitExceededError = createSnapError(rpcErrors.limitExceeded);
|
|
48
|
+
/**
|
|
49
|
+
* An Ethereum JSON-RPC Method Not Found (-32601) error.
|
|
50
|
+
*
|
|
51
|
+
* This can be thrown by a Snap to indicate that a method does not exist,
|
|
52
|
+
* without crashing the Snap.
|
|
53
|
+
*
|
|
54
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
55
|
+
*/
|
|
56
|
+
export const MethodNotFoundError = createSnapError(rpcErrors.methodNotFound);
|
|
57
|
+
/**
|
|
58
|
+
* An Ethereum JSON-RPC Method Not Supported (-32004) error.
|
|
59
|
+
*
|
|
60
|
+
* This can be thrown by a Snap to indicate that a method is not supported,
|
|
61
|
+
* without crashing the Snap.
|
|
62
|
+
*/
|
|
63
|
+
export const MethodNotSupportedError = createSnapError(rpcErrors.methodNotSupported);
|
|
64
|
+
/**
|
|
65
|
+
* A JSON-RPC 2.0 Parse (-32700) error.
|
|
66
|
+
*
|
|
67
|
+
* This can be thrown by a Snap to indicate that a request is not valid JSON,
|
|
68
|
+
* without crashing the Snap.
|
|
69
|
+
*
|
|
70
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
71
|
+
*/
|
|
72
|
+
export const ParseError = createSnapError(rpcErrors.parse);
|
|
73
|
+
/**
|
|
74
|
+
* An Ethereum JSON-RPC Resource Not Found (-32001) error.
|
|
75
|
+
*
|
|
76
|
+
* This can be thrown by a Snap to indicate that a resource does not exist,
|
|
77
|
+
* without crashing the Snap.
|
|
78
|
+
*
|
|
79
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
80
|
+
*/
|
|
81
|
+
export const ResourceNotFoundError = createSnapError(rpcErrors.resourceNotFound);
|
|
82
|
+
/**
|
|
83
|
+
* An Ethereum JSON-RPC Resource Unavailable (-32002) error.
|
|
84
|
+
*
|
|
85
|
+
* This can be thrown by a Snap to indicate that a resource is unavailable,
|
|
86
|
+
* without crashing the Snap.
|
|
87
|
+
*
|
|
88
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
89
|
+
*/
|
|
90
|
+
export const ResourceUnavailableError = createSnapError(rpcErrors.resourceUnavailable);
|
|
91
|
+
/**
|
|
92
|
+
* An Ethereum JSON-RPC Transaction Rejected (-32003) error.
|
|
93
|
+
*
|
|
94
|
+
* This can be thrown by a Snap to indicate that a transaction was rejected,
|
|
95
|
+
* without crashing the Snap.
|
|
96
|
+
*
|
|
97
|
+
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
98
|
+
*/
|
|
99
|
+
export const TransactionRejected = createSnapError(rpcErrors.transactionRejected);
|
|
100
|
+
/**
|
|
101
|
+
* An Ethereum Provider Chain Disconnected (4901) error.
|
|
102
|
+
*
|
|
103
|
+
* This can be thrown by a Snap to indicate that the provider is disconnected
|
|
104
|
+
* from the requested chain, without crashing the Snap.
|
|
105
|
+
*
|
|
106
|
+
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
107
|
+
*/
|
|
108
|
+
export const ChainDisconnectedError = createSnapError(providerErrors.chainDisconnected);
|
|
109
|
+
/**
|
|
110
|
+
* An Ethereum Provider Disconnected (4900) error.
|
|
111
|
+
*
|
|
112
|
+
* This can be thrown by a Snap to indicate that the provider is disconnected,
|
|
113
|
+
* without crashing the Snap.
|
|
114
|
+
*
|
|
115
|
+
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
116
|
+
*/
|
|
117
|
+
export const DisconnectedError = createSnapError(providerErrors.disconnected);
|
|
118
|
+
/**
|
|
119
|
+
* An Ethereum Provider Unauthorized (4100) error.
|
|
120
|
+
*
|
|
121
|
+
* This can be thrown by a Snap to indicate that the requested method / account
|
|
122
|
+
* is not authorized by the user, without crashing the Snap.
|
|
123
|
+
*/
|
|
124
|
+
export const UnauthorizedError = createSnapError(providerErrors.unauthorized);
|
|
125
|
+
/**
|
|
126
|
+
* An Ethereum Provider Unsupported Method (4200) error.
|
|
127
|
+
*
|
|
128
|
+
* This can be thrown by a Snap to indicate that the requested method is not
|
|
129
|
+
* supported by the provider, without crashing the Snap.
|
|
130
|
+
*
|
|
131
|
+
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
132
|
+
*/
|
|
133
|
+
export const UnsupportedMethodError = createSnapError(providerErrors.unsupportedMethod);
|
|
134
|
+
/**
|
|
135
|
+
* An Ethereum Provider User Rejected Request (4001) error.
|
|
136
|
+
*
|
|
137
|
+
* This can be thrown by a Snap to indicate that the user rejected the request,
|
|
138
|
+
* without crashing the Snap.
|
|
139
|
+
*
|
|
140
|
+
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
141
|
+
*/
|
|
142
|
+
export const UserRejectedRequestError = createSnapError(providerErrors.userRejectedRequest);
|
|
143
|
+
//# sourceMappingURL=error-wrappers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-wrappers.mjs","sourceRoot":"","sources":["../src/error-wrappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,6BAA6B;AAEjE,OAAO,EAAE,eAAe,EAAE,8BAAoB;AAE9C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AAE3E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AAE3E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CACpD,SAAS,CAAC,kBAAkB,CAC7B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAClD,SAAS,CAAC,gBAAgB,CAC3B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CACrD,SAAS,CAAC,mBAAmB,CAC9B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAChD,SAAS,CAAC,mBAAmB,CAC9B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CACnD,cAAc,CAAC,iBAAiB,CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CACnD,cAAc,CAAC,iBAAiB,CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CACrD,cAAc,CAAC,mBAAmB,CACnC,CAAC","sourcesContent":["import { providerErrors, rpcErrors } from '@metamask/rpc-errors';\n\nimport { createSnapError } from './internals';\n\n/**\n * A JSON-RPC 2.0 Internal (-32603) error.\n *\n * This can be thrown by a Snap to indicate that an internal error occurred,\n * without crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const InternalError = createSnapError(rpcErrors.internal);\n\n/**\n * An Ethereum JSON-RPC Invalid Input (-32000) error.\n *\n * This can be thrown by a Snap to indicate that the input to a method is\n * invalid, without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const InvalidInputError = createSnapError(rpcErrors.invalidInput);\n\n/**\n * A JSON-RPC 2.0 Invalid Params (-32602) error.\n *\n * This can be thrown by a Snap to indicate that the parameters to a method are\n * invalid, without crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const InvalidParamsError = createSnapError(rpcErrors.invalidParams);\n\n/**\n * A JSON-RPC 2.0 Invalid Request (-32600) error.\n *\n * This can be thrown by a Snap to indicate that the request is invalid, without\n * crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const InvalidRequestError = createSnapError(rpcErrors.invalidRequest);\n\n/**\n * An Ethereum JSON-RPC Limit Exceeded (-32005) error.\n *\n * This can be thrown by a Snap to indicate that a limit has been exceeded,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const LimitExceededError = createSnapError(rpcErrors.limitExceeded);\n\n/**\n * An Ethereum JSON-RPC Method Not Found (-32601) error.\n *\n * This can be thrown by a Snap to indicate that a method does not exist,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const MethodNotFoundError = createSnapError(rpcErrors.methodNotFound);\n\n/**\n * An Ethereum JSON-RPC Method Not Supported (-32004) error.\n *\n * This can be thrown by a Snap to indicate that a method is not supported,\n * without crashing the Snap.\n */\nexport const MethodNotSupportedError = createSnapError(\n rpcErrors.methodNotSupported,\n);\n\n/**\n * A JSON-RPC 2.0 Parse (-32700) error.\n *\n * This can be thrown by a Snap to indicate that a request is not valid JSON,\n * without crashing the Snap.\n *\n * @see https://www.jsonrpc.org/specification#error_object\n */\nexport const ParseError = createSnapError(rpcErrors.parse);\n\n/**\n * An Ethereum JSON-RPC Resource Not Found (-32001) error.\n *\n * This can be thrown by a Snap to indicate that a resource does not exist,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const ResourceNotFoundError = createSnapError(\n rpcErrors.resourceNotFound,\n);\n\n/**\n * An Ethereum JSON-RPC Resource Unavailable (-32002) error.\n *\n * This can be thrown by a Snap to indicate that a resource is unavailable,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const ResourceUnavailableError = createSnapError(\n rpcErrors.resourceUnavailable,\n);\n\n/**\n * An Ethereum JSON-RPC Transaction Rejected (-32003) error.\n *\n * This can be thrown by a Snap to indicate that a transaction was rejected,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1474#error-codes\n */\nexport const TransactionRejected = createSnapError(\n rpcErrors.transactionRejected,\n);\n\n/**\n * An Ethereum Provider Chain Disconnected (4901) error.\n *\n * This can be thrown by a Snap to indicate that the provider is disconnected\n * from the requested chain, without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const ChainDisconnectedError = createSnapError(\n providerErrors.chainDisconnected,\n);\n\n/**\n * An Ethereum Provider Disconnected (4900) error.\n *\n * This can be thrown by a Snap to indicate that the provider is disconnected,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const DisconnectedError = createSnapError(providerErrors.disconnected);\n\n/**\n * An Ethereum Provider Unauthorized (4100) error.\n *\n * This can be thrown by a Snap to indicate that the requested method / account\n * is not authorized by the user, without crashing the Snap.\n */\nexport const UnauthorizedError = createSnapError(providerErrors.unauthorized);\n\n/**\n * An Ethereum Provider Unsupported Method (4200) error.\n *\n * This can be thrown by a Snap to indicate that the requested method is not\n * supported by the provider, without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const UnsupportedMethodError = createSnapError(\n providerErrors.unsupportedMethod,\n);\n\n/**\n * An Ethereum Provider User Rejected Request (4001) error.\n *\n * This can be thrown by a Snap to indicate that the user rejected the request,\n * without crashing the Snap.\n *\n * @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors\n */\nexport const UserRejectedRequestError = createSnapError(\n providerErrors.userRejectedRequest,\n);\n"]}
|
package/dist/errors.cjs
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _SnapError_code, _SnapError_message, _SnapError_data, _SnapError_stack;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SnapError = void 0;
|
|
16
|
+
const internals_1 = require("./internals/index.cjs");
|
|
17
|
+
/**
|
|
18
|
+
* A generic error which can be thrown by a Snap, without it causing the Snap to
|
|
19
|
+
* crash.
|
|
20
|
+
*/
|
|
21
|
+
class SnapError extends Error {
|
|
22
|
+
/**
|
|
23
|
+
* Create a new `SnapError`.
|
|
24
|
+
*
|
|
25
|
+
* @param error - The error to create the `SnapError` from. If this is a
|
|
26
|
+
* `string`, it will be used as the error message. If this is an `Error`, its
|
|
27
|
+
* `message` property will be used as the error message. If this is a
|
|
28
|
+
* `JsonRpcError`, its `message` property will be used as the error message
|
|
29
|
+
* and its `code` property will be used as the error code. Otherwise, the
|
|
30
|
+
* error will be converted to a string and used as the error message.
|
|
31
|
+
* @param data - Additional data to include in the error. This will be merged
|
|
32
|
+
* with the error data, if any.
|
|
33
|
+
*/
|
|
34
|
+
constructor(error, data = {}) {
|
|
35
|
+
const message = (0, internals_1.getErrorMessage)(error);
|
|
36
|
+
super(message);
|
|
37
|
+
_SnapError_code.set(this, void 0);
|
|
38
|
+
_SnapError_message.set(this, void 0);
|
|
39
|
+
_SnapError_data.set(this, void 0);
|
|
40
|
+
_SnapError_stack.set(this, void 0);
|
|
41
|
+
__classPrivateFieldSet(this, _SnapError_message, message, "f");
|
|
42
|
+
__classPrivateFieldSet(this, _SnapError_code, (0, internals_1.getErrorCode)(error), "f");
|
|
43
|
+
const mergedData = { ...(0, internals_1.getErrorData)(error), ...data };
|
|
44
|
+
if (Object.keys(mergedData).length > 0) {
|
|
45
|
+
__classPrivateFieldSet(this, _SnapError_data, mergedData, "f");
|
|
46
|
+
}
|
|
47
|
+
__classPrivateFieldSet(this, _SnapError_stack, super.stack, "f");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The error name.
|
|
51
|
+
*
|
|
52
|
+
* @returns The error name.
|
|
53
|
+
*/
|
|
54
|
+
get name() {
|
|
55
|
+
return 'SnapError';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The error code.
|
|
59
|
+
*
|
|
60
|
+
* @returns The error code.
|
|
61
|
+
*/
|
|
62
|
+
get code() {
|
|
63
|
+
return __classPrivateFieldGet(this, _SnapError_code, "f");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The error message.
|
|
67
|
+
*
|
|
68
|
+
* @returns The error message.
|
|
69
|
+
*/
|
|
70
|
+
// This line is covered, but Jest doesn't pick it up for some reason.
|
|
71
|
+
/* istanbul ignore next */
|
|
72
|
+
get message() {
|
|
73
|
+
return __classPrivateFieldGet(this, _SnapError_message, "f");
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Additional data for the error.
|
|
77
|
+
*
|
|
78
|
+
* @returns Additional data for the error.
|
|
79
|
+
*/
|
|
80
|
+
get data() {
|
|
81
|
+
return __classPrivateFieldGet(this, _SnapError_data, "f");
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The error stack.
|
|
85
|
+
*
|
|
86
|
+
* @returns The error stack.
|
|
87
|
+
*/
|
|
88
|
+
// This line is covered, but Jest doesn't pick it up for some reason.
|
|
89
|
+
/* istanbul ignore next */
|
|
90
|
+
get stack() {
|
|
91
|
+
return __classPrivateFieldGet(this, _SnapError_stack, "f");
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Convert the error to a JSON object.
|
|
95
|
+
*
|
|
96
|
+
* @returns The JSON object.
|
|
97
|
+
*/
|
|
98
|
+
toJSON() {
|
|
99
|
+
return {
|
|
100
|
+
code: internals_1.SNAP_ERROR_CODE,
|
|
101
|
+
message: internals_1.SNAP_ERROR_MESSAGE,
|
|
102
|
+
data: {
|
|
103
|
+
cause: {
|
|
104
|
+
code: this.code,
|
|
105
|
+
message: this.message,
|
|
106
|
+
stack: this.stack,
|
|
107
|
+
...(this.data ? { data: this.data } : {}),
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Serialize the error to a JSON object. This is called by
|
|
114
|
+
* `@metamask/rpc-errors` when serializing the error.
|
|
115
|
+
*
|
|
116
|
+
* @returns The JSON object.
|
|
117
|
+
*/
|
|
118
|
+
serialize() {
|
|
119
|
+
return this.toJSON();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.SnapError = SnapError;
|
|
123
|
+
_SnapError_code = new WeakMap(), _SnapError_message = new WeakMap(), _SnapError_data = new WeakMap(), _SnapError_stack = new WeakMap();
|
|
124
|
+
//# sourceMappingURL=errors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,qDAMqB;AAErB;;;GAGG;AACH,MAAa,SAAU,SAAQ,KAAK;IASlC;;;;;;;;;;;OAWG;IACH,YACE,KAAoC,EACpC,OAA6B,EAAE;QAE/B,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,KAAK,CAAC,CAAC;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAzBR,kCAAc;QAEd,qCAAiB;QAEjB,kCAA6B;QAE7B,mCAAgB;QAqBvB,uBAAA,IAAI,sBAAY,OAAO,MAAA,CAAC;QACxB,uBAAA,IAAI,mBAAS,IAAA,wBAAY,EAAC,KAAK,CAAC,MAAA,CAAC;QAEjC,MAAM,UAAU,GAAG,EAAE,GAAG,IAAA,wBAAY,EAAC,KAAK,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;QACvD,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvC,uBAAA,IAAI,mBAAS,UAAU,MAAA,CAAC;QAC1B,CAAC;QAED,uBAAA,IAAI,oBAAU,KAAK,CAAC,KAAK,MAAA,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,uBAAM,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,qEAAqE;IACrE,0BAA0B;IAC1B,IAAI,OAAO;QACT,OAAO,uBAAA,IAAI,0BAAS,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,uBAAM,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,qEAAqE;IACrE,0BAA0B;IAC1B,IAAI,KAAK;QACP,OAAO,uBAAA,IAAI,wBAAO,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,2BAAe;YACrB,OAAO,EAAE,8BAAkB;YAC3B,IAAI,EAAE;gBACJ,KAAK,EAAE;oBACL,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC1C;aACF;SACF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACF;AArHD,8BAqHC","sourcesContent":["import type { Json, JsonRpcError } from '@metamask/utils';\n\nimport {\n getErrorCode,\n getErrorData,\n getErrorMessage,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n} from './internals';\n\n/**\n * A generic error which can be thrown by a Snap, without it causing the Snap to\n * crash.\n */\nexport class SnapError extends Error {\n readonly #code: number;\n\n readonly #message: string;\n\n readonly #data?: Record<string, Json>;\n\n readonly #stack?: string;\n\n /**\n * Create a new `SnapError`.\n *\n * @param error - The error to create the `SnapError` from. If this is a\n * `string`, it will be used as the error message. If this is an `Error`, its\n * `message` property will be used as the error message. If this is a\n * `JsonRpcError`, its `message` property will be used as the error message\n * and its `code` property will be used as the error code. Otherwise, the\n * error will be converted to a string and used as the error message.\n * @param data - Additional data to include in the error. This will be merged\n * with the error data, if any.\n */\n constructor(\n error: string | Error | JsonRpcError,\n data: Record<string, Json> = {},\n ) {\n const message = getErrorMessage(error);\n super(message);\n\n this.#message = message;\n this.#code = getErrorCode(error);\n\n const mergedData = { ...getErrorData(error), ...data };\n if (Object.keys(mergedData).length > 0) {\n this.#data = mergedData;\n }\n\n this.#stack = super.stack;\n }\n\n /**\n * The error name.\n *\n * @returns The error name.\n */\n get name() {\n return 'SnapError';\n }\n\n /**\n * The error code.\n *\n * @returns The error code.\n */\n get code() {\n return this.#code;\n }\n\n /**\n * The error message.\n *\n * @returns The error message.\n */\n // This line is covered, but Jest doesn't pick it up for some reason.\n /* istanbul ignore next */\n get message() {\n return this.#message;\n }\n\n /**\n * Additional data for the error.\n *\n * @returns Additional data for the error.\n */\n get data() {\n return this.#data;\n }\n\n /**\n * The error stack.\n *\n * @returns The error stack.\n */\n // This line is covered, but Jest doesn't pick it up for some reason.\n /* istanbul ignore next */\n get stack() {\n return this.#stack;\n }\n\n /**\n * Convert the error to a JSON object.\n *\n * @returns The JSON object.\n */\n toJSON(): SerializedSnapError {\n return {\n code: SNAP_ERROR_CODE,\n message: SNAP_ERROR_MESSAGE,\n data: {\n cause: {\n code: this.code,\n message: this.message,\n stack: this.stack,\n ...(this.data ? { data: this.data } : {}),\n },\n },\n };\n }\n\n /**\n * Serialize the error to a JSON object. This is called by\n * `@metamask/rpc-errors` when serializing the error.\n *\n * @returns The JSON object.\n */\n serialize() {\n return this.toJSON();\n }\n}\n\n/**\n * A serialized {@link SnapError}. It's JSON-serializable, so it can be sent\n * over the RPC. The original error is wrapped in the `cause` property.\n *\n * @property code - The error code. This is always `-31002`.\n * @property message - The error message. This is always `'Snap Error'`.\n * @property data - The error data.\n * @property data.cause - The cause of the error.\n * @property data.cause.code - The error code.\n * @property data.cause.message - The error message.\n * @property data.cause.stack - The error stack.\n * @property data.cause.data - Additional data for the error.\n * @see SnapError\n */\nexport type SerializedSnapError = {\n code: typeof SNAP_ERROR_CODE;\n message: typeof SNAP_ERROR_MESSAGE;\n data: {\n cause: JsonRpcError;\n };\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Json, JsonRpcError } from
|
|
2
|
-
import { SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE } from
|
|
1
|
+
import type { Json, JsonRpcError } from "@metamask/utils";
|
|
2
|
+
import { SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE } from "./internals/index.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* A generic error which can be thrown by a Snap, without it causing the Snap to
|
|
5
5
|
* crash.
|
|
@@ -84,3 +84,4 @@ export type SerializedSnapError = {
|
|
|
84
84
|
cause: JsonRpcError;
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
|
+
//# sourceMappingURL=errors.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.cts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,wBAAwB;AAE1D,OAAO,EAIL,eAAe,EACf,kBAAkB,EACnB,8BAAoB;AAErB;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK;;IASlC;;;;;;;;;;;OAWG;gBAED,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,YAAY,EACpC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAM;IAgBjC;;;;OAIG;IACH,IAAI,IAAI,WAEP;IAED;;;;OAIG;IACH,IAAI,IAAI,WAEP;IAED;;;;OAIG;IAGH,IAAI,OAAO,WAEV;IAED;;;;OAIG;IACH,IAAI,IAAI,qCAEP;IAED;;;;OAIG;IAGH,IAAI,KAAK,uBAER;IAED;;;;OAIG;IACH,MAAM,IAAI,mBAAmB;IAe7B;;;;;OAKG;IACH,SAAS;CAGV;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,OAAO,eAAe,CAAC;IAC7B,OAAO,EAAE,OAAO,kBAAkB,CAAC;IACnC,IAAI,EAAE;QACJ,KAAK,EAAE,YAAY,CAAC;KACrB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Json, JsonRpcError } from "@metamask/utils";
|
|
2
|
+
import { SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE } from "./internals/index.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* A generic error which can be thrown by a Snap, without it causing the Snap to
|
|
5
|
+
* crash.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SnapError extends Error {
|
|
8
|
+
#private;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new `SnapError`.
|
|
11
|
+
*
|
|
12
|
+
* @param error - The error to create the `SnapError` from. If this is a
|
|
13
|
+
* `string`, it will be used as the error message. If this is an `Error`, its
|
|
14
|
+
* `message` property will be used as the error message. If this is a
|
|
15
|
+
* `JsonRpcError`, its `message` property will be used as the error message
|
|
16
|
+
* and its `code` property will be used as the error code. Otherwise, the
|
|
17
|
+
* error will be converted to a string and used as the error message.
|
|
18
|
+
* @param data - Additional data to include in the error. This will be merged
|
|
19
|
+
* with the error data, if any.
|
|
20
|
+
*/
|
|
21
|
+
constructor(error: string | Error | JsonRpcError, data?: Record<string, Json>);
|
|
22
|
+
/**
|
|
23
|
+
* The error name.
|
|
24
|
+
*
|
|
25
|
+
* @returns The error name.
|
|
26
|
+
*/
|
|
27
|
+
get name(): string;
|
|
28
|
+
/**
|
|
29
|
+
* The error code.
|
|
30
|
+
*
|
|
31
|
+
* @returns The error code.
|
|
32
|
+
*/
|
|
33
|
+
get code(): number;
|
|
34
|
+
/**
|
|
35
|
+
* The error message.
|
|
36
|
+
*
|
|
37
|
+
* @returns The error message.
|
|
38
|
+
*/
|
|
39
|
+
get message(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Additional data for the error.
|
|
42
|
+
*
|
|
43
|
+
* @returns Additional data for the error.
|
|
44
|
+
*/
|
|
45
|
+
get data(): Record<string, Json> | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The error stack.
|
|
48
|
+
*
|
|
49
|
+
* @returns The error stack.
|
|
50
|
+
*/
|
|
51
|
+
get stack(): string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Convert the error to a JSON object.
|
|
54
|
+
*
|
|
55
|
+
* @returns The JSON object.
|
|
56
|
+
*/
|
|
57
|
+
toJSON(): SerializedSnapError;
|
|
58
|
+
/**
|
|
59
|
+
* Serialize the error to a JSON object. This is called by
|
|
60
|
+
* `@metamask/rpc-errors` when serializing the error.
|
|
61
|
+
*
|
|
62
|
+
* @returns The JSON object.
|
|
63
|
+
*/
|
|
64
|
+
serialize(): SerializedSnapError;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A serialized {@link SnapError}. It's JSON-serializable, so it can be sent
|
|
68
|
+
* over the RPC. The original error is wrapped in the `cause` property.
|
|
69
|
+
*
|
|
70
|
+
* @property code - The error code. This is always `-31002`.
|
|
71
|
+
* @property message - The error message. This is always `'Snap Error'`.
|
|
72
|
+
* @property data - The error data.
|
|
73
|
+
* @property data.cause - The cause of the error.
|
|
74
|
+
* @property data.cause.code - The error code.
|
|
75
|
+
* @property data.cause.message - The error message.
|
|
76
|
+
* @property data.cause.stack - The error stack.
|
|
77
|
+
* @property data.cause.data - Additional data for the error.
|
|
78
|
+
* @see SnapError
|
|
79
|
+
*/
|
|
80
|
+
export type SerializedSnapError = {
|
|
81
|
+
code: typeof SNAP_ERROR_CODE;
|
|
82
|
+
message: typeof SNAP_ERROR_MESSAGE;
|
|
83
|
+
data: {
|
|
84
|
+
cause: JsonRpcError;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=errors.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,wBAAwB;AAE1D,OAAO,EAIL,eAAe,EACf,kBAAkB,EACnB,8BAAoB;AAErB;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK;;IASlC;;;;;;;;;;;OAWG;gBAED,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,YAAY,EACpC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAM;IAgBjC;;;;OAIG;IACH,IAAI,IAAI,WAEP;IAED;;;;OAIG;IACH,IAAI,IAAI,WAEP;IAED;;;;OAIG;IAGH,IAAI,OAAO,WAEV;IAED;;;;OAIG;IACH,IAAI,IAAI,qCAEP;IAED;;;;OAIG;IAGH,IAAI,KAAK,uBAER;IAED;;;;OAIG;IACH,MAAM,IAAI,mBAAmB;IAe7B;;;;;OAKG;IACH,SAAS;CAGV;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,OAAO,eAAe,CAAC;IAC7B,OAAO,EAAE,OAAO,kBAAkB,CAAC;IACnC,IAAI,EAAE;QACJ,KAAK,EAAE,YAAY,CAAC;KACrB,CAAC;CACH,CAAC"}
|
package/dist/errors.mjs
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _SnapError_code, _SnapError_message, _SnapError_data, _SnapError_stack;
|
|
13
|
+
import { getErrorCode, getErrorData, getErrorMessage, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE } from "./internals/index.mjs";
|
|
14
|
+
/**
|
|
15
|
+
* A generic error which can be thrown by a Snap, without it causing the Snap to
|
|
16
|
+
* crash.
|
|
17
|
+
*/
|
|
18
|
+
export class SnapError extends Error {
|
|
19
|
+
/**
|
|
20
|
+
* Create a new `SnapError`.
|
|
21
|
+
*
|
|
22
|
+
* @param error - The error to create the `SnapError` from. If this is a
|
|
23
|
+
* `string`, it will be used as the error message. If this is an `Error`, its
|
|
24
|
+
* `message` property will be used as the error message. If this is a
|
|
25
|
+
* `JsonRpcError`, its `message` property will be used as the error message
|
|
26
|
+
* and its `code` property will be used as the error code. Otherwise, the
|
|
27
|
+
* error will be converted to a string and used as the error message.
|
|
28
|
+
* @param data - Additional data to include in the error. This will be merged
|
|
29
|
+
* with the error data, if any.
|
|
30
|
+
*/
|
|
31
|
+
constructor(error, data = {}) {
|
|
32
|
+
const message = getErrorMessage(error);
|
|
33
|
+
super(message);
|
|
34
|
+
_SnapError_code.set(this, void 0);
|
|
35
|
+
_SnapError_message.set(this, void 0);
|
|
36
|
+
_SnapError_data.set(this, void 0);
|
|
37
|
+
_SnapError_stack.set(this, void 0);
|
|
38
|
+
__classPrivateFieldSet(this, _SnapError_message, message, "f");
|
|
39
|
+
__classPrivateFieldSet(this, _SnapError_code, getErrorCode(error), "f");
|
|
40
|
+
const mergedData = { ...getErrorData(error), ...data };
|
|
41
|
+
if (Object.keys(mergedData).length > 0) {
|
|
42
|
+
__classPrivateFieldSet(this, _SnapError_data, mergedData, "f");
|
|
43
|
+
}
|
|
44
|
+
__classPrivateFieldSet(this, _SnapError_stack, super.stack, "f");
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The error name.
|
|
48
|
+
*
|
|
49
|
+
* @returns The error name.
|
|
50
|
+
*/
|
|
51
|
+
get name() {
|
|
52
|
+
return 'SnapError';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The error code.
|
|
56
|
+
*
|
|
57
|
+
* @returns The error code.
|
|
58
|
+
*/
|
|
59
|
+
get code() {
|
|
60
|
+
return __classPrivateFieldGet(this, _SnapError_code, "f");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The error message.
|
|
64
|
+
*
|
|
65
|
+
* @returns The error message.
|
|
66
|
+
*/
|
|
67
|
+
// This line is covered, but Jest doesn't pick it up for some reason.
|
|
68
|
+
/* istanbul ignore next */
|
|
69
|
+
get message() {
|
|
70
|
+
return __classPrivateFieldGet(this, _SnapError_message, "f");
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Additional data for the error.
|
|
74
|
+
*
|
|
75
|
+
* @returns Additional data for the error.
|
|
76
|
+
*/
|
|
77
|
+
get data() {
|
|
78
|
+
return __classPrivateFieldGet(this, _SnapError_data, "f");
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The error stack.
|
|
82
|
+
*
|
|
83
|
+
* @returns The error stack.
|
|
84
|
+
*/
|
|
85
|
+
// This line is covered, but Jest doesn't pick it up for some reason.
|
|
86
|
+
/* istanbul ignore next */
|
|
87
|
+
get stack() {
|
|
88
|
+
return __classPrivateFieldGet(this, _SnapError_stack, "f");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Convert the error to a JSON object.
|
|
92
|
+
*
|
|
93
|
+
* @returns The JSON object.
|
|
94
|
+
*/
|
|
95
|
+
toJSON() {
|
|
96
|
+
return {
|
|
97
|
+
code: SNAP_ERROR_CODE,
|
|
98
|
+
message: SNAP_ERROR_MESSAGE,
|
|
99
|
+
data: {
|
|
100
|
+
cause: {
|
|
101
|
+
code: this.code,
|
|
102
|
+
message: this.message,
|
|
103
|
+
stack: this.stack,
|
|
104
|
+
...(this.data ? { data: this.data } : {}),
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Serialize the error to a JSON object. This is called by
|
|
111
|
+
* `@metamask/rpc-errors` when serializing the error.
|
|
112
|
+
*
|
|
113
|
+
* @returns The JSON object.
|
|
114
|
+
*/
|
|
115
|
+
serialize() {
|
|
116
|
+
return this.toJSON();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
_SnapError_code = new WeakMap(), _SnapError_message = new WeakMap(), _SnapError_data = new WeakMap(), _SnapError_stack = new WeakMap();
|
|
120
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,kBAAkB,EACnB,8BAAoB;AAErB;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IASlC;;;;;;;;;;;OAWG;IACH,YACE,KAAoC,EACpC,OAA6B,EAAE;QAE/B,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAzBR,kCAAc;QAEd,qCAAiB;QAEjB,kCAA6B;QAE7B,mCAAgB;QAqBvB,uBAAA,IAAI,sBAAY,OAAO,MAAA,CAAC;QACxB,uBAAA,IAAI,mBAAS,YAAY,CAAC,KAAK,CAAC,MAAA,CAAC;QAEjC,MAAM,UAAU,GAAG,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;QACvD,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvC,uBAAA,IAAI,mBAAS,UAAU,MAAA,CAAC;QAC1B,CAAC;QAED,uBAAA,IAAI,oBAAU,KAAK,CAAC,KAAK,MAAA,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,uBAAM,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,qEAAqE;IACrE,0BAA0B;IAC1B,IAAI,OAAO;QACT,OAAO,uBAAA,IAAI,0BAAS,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,uBAAM,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,qEAAqE;IACrE,0BAA0B;IAC1B,IAAI,KAAK;QACP,OAAO,uBAAA,IAAI,wBAAO,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,kBAAkB;YAC3B,IAAI,EAAE;gBACJ,KAAK,EAAE;oBACL,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC1C;aACF;SACF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["import type { Json, JsonRpcError } from '@metamask/utils';\n\nimport {\n getErrorCode,\n getErrorData,\n getErrorMessage,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n} from './internals';\n\n/**\n * A generic error which can be thrown by a Snap, without it causing the Snap to\n * crash.\n */\nexport class SnapError extends Error {\n readonly #code: number;\n\n readonly #message: string;\n\n readonly #data?: Record<string, Json>;\n\n readonly #stack?: string;\n\n /**\n * Create a new `SnapError`.\n *\n * @param error - The error to create the `SnapError` from. If this is a\n * `string`, it will be used as the error message. If this is an `Error`, its\n * `message` property will be used as the error message. If this is a\n * `JsonRpcError`, its `message` property will be used as the error message\n * and its `code` property will be used as the error code. Otherwise, the\n * error will be converted to a string and used as the error message.\n * @param data - Additional data to include in the error. This will be merged\n * with the error data, if any.\n */\n constructor(\n error: string | Error | JsonRpcError,\n data: Record<string, Json> = {},\n ) {\n const message = getErrorMessage(error);\n super(message);\n\n this.#message = message;\n this.#code = getErrorCode(error);\n\n const mergedData = { ...getErrorData(error), ...data };\n if (Object.keys(mergedData).length > 0) {\n this.#data = mergedData;\n }\n\n this.#stack = super.stack;\n }\n\n /**\n * The error name.\n *\n * @returns The error name.\n */\n get name() {\n return 'SnapError';\n }\n\n /**\n * The error code.\n *\n * @returns The error code.\n */\n get code() {\n return this.#code;\n }\n\n /**\n * The error message.\n *\n * @returns The error message.\n */\n // This line is covered, but Jest doesn't pick it up for some reason.\n /* istanbul ignore next */\n get message() {\n return this.#message;\n }\n\n /**\n * Additional data for the error.\n *\n * @returns Additional data for the error.\n */\n get data() {\n return this.#data;\n }\n\n /**\n * The error stack.\n *\n * @returns The error stack.\n */\n // This line is covered, but Jest doesn't pick it up for some reason.\n /* istanbul ignore next */\n get stack() {\n return this.#stack;\n }\n\n /**\n * Convert the error to a JSON object.\n *\n * @returns The JSON object.\n */\n toJSON(): SerializedSnapError {\n return {\n code: SNAP_ERROR_CODE,\n message: SNAP_ERROR_MESSAGE,\n data: {\n cause: {\n code: this.code,\n message: this.message,\n stack: this.stack,\n ...(this.data ? { data: this.data } : {}),\n },\n },\n };\n }\n\n /**\n * Serialize the error to a JSON object. This is called by\n * `@metamask/rpc-errors` when serializing the error.\n *\n * @returns The JSON object.\n */\n serialize() {\n return this.toJSON();\n }\n}\n\n/**\n * A serialized {@link SnapError}. It's JSON-serializable, so it can be sent\n * over the RPC. The original error is wrapped in the `cause` property.\n *\n * @property code - The error code. This is always `-31002`.\n * @property message - The error message. This is always `'Snap Error'`.\n * @property data - The error data.\n * @property data.cause - The cause of the error.\n * @property data.cause.code - The error code.\n * @property data.cause.message - The error message.\n * @property data.cause.stack - The error stack.\n * @property data.cause.data - Additional data for the error.\n * @see SnapError\n */\nexport type SerializedSnapError = {\n code: typeof SNAP_ERROR_CODE;\n message: typeof SNAP_ERROR_MESSAGE;\n data: {\n cause: JsonRpcError;\n };\n};\n"]}
|
package/dist/images.cjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImageComponent = exports.getImageData = void 0;
|
|
4
|
+
const utils_1 = require("@metamask/utils");
|
|
5
|
+
const ui_1 = require("./ui/index.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* Get raw image data from a URL.
|
|
8
|
+
*
|
|
9
|
+
* @param url - The URL to get the image data from.
|
|
10
|
+
* @param options - The options to use when fetching the image data. This is
|
|
11
|
+
* passed directly to `fetch`.
|
|
12
|
+
* @returns A promise that resolves to the image data as a blob.
|
|
13
|
+
*/
|
|
14
|
+
async function getRawImageData(url, options) {
|
|
15
|
+
if (typeof fetch !== 'function') {
|
|
16
|
+
throw new Error(`Failed to fetch image data from "${url}": Using this function requires the "endowment:network-access" permission.`);
|
|
17
|
+
}
|
|
18
|
+
return fetch(url, options).then(async (response) => {
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
throw new Error(`Failed to fetch image data from "${url}": ${response.status} ${response.statusText}`);
|
|
21
|
+
}
|
|
22
|
+
const blob = await response.blob();
|
|
23
|
+
(0, utils_1.assert)(blob.type === 'image/jpeg' || blob.type === 'image/png', 'Expected image data to be a JPEG or PNG image.');
|
|
24
|
+
return blob;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get image data as data-string from a URL. This is useful for embedding images
|
|
29
|
+
* inside of SVGs. Only JPEG and PNG images are supported.
|
|
30
|
+
*
|
|
31
|
+
* Note: This function uses `fetch` to get the image data. This means that using
|
|
32
|
+
* it requires the `endowment:network-access` permission.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const imageData = await getImageData('https://cataas.com/cat');
|
|
36
|
+
* const svg = `
|
|
37
|
+
* <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
|
|
38
|
+
* <image href="${imageData}" />
|
|
39
|
+
* </svg>
|
|
40
|
+
* `;
|
|
41
|
+
*
|
|
42
|
+
* // Render the SVG in a Snap UI.
|
|
43
|
+
* const ui = image(svg);
|
|
44
|
+
* @param url - The URL to get the image data from.
|
|
45
|
+
* @param options - The options to use when fetching the image data. This is
|
|
46
|
+
* passed directly to `fetch`.
|
|
47
|
+
* @returns A promise that resolves to the image data as a data-string.
|
|
48
|
+
*/
|
|
49
|
+
async function getImageData(url, options) {
|
|
50
|
+
const blob = await getRawImageData(url, options);
|
|
51
|
+
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
52
|
+
return `data:${blob.type};base64,${(0, utils_1.bytesToBase64)(bytes)}`;
|
|
53
|
+
}
|
|
54
|
+
exports.getImageData = getImageData;
|
|
55
|
+
/**
|
|
56
|
+
* Get an image component from a URL. This is useful for embedding images inside
|
|
57
|
+
* Snap UIs. Only JPEG and PNG images are supported.
|
|
58
|
+
*
|
|
59
|
+
* Note: This function uses `fetch` to get the image data. This means that using
|
|
60
|
+
* it requires the `endowment:network-access` permission.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* const component = await getImage('https://cataas.com/cat');
|
|
64
|
+
*
|
|
65
|
+
* return await snap.request({
|
|
66
|
+
* method: 'snap_dialog',
|
|
67
|
+
* params: {
|
|
68
|
+
* type: 'alert',
|
|
69
|
+
* content: panel([
|
|
70
|
+
* component,
|
|
71
|
+
* ]),
|
|
72
|
+
* },
|
|
73
|
+
* });
|
|
74
|
+
* @param url - The URL to get the image data from.
|
|
75
|
+
* @param options - The options to use when fetching and rendering the image.
|
|
76
|
+
* @param options.width - The width of the image.
|
|
77
|
+
* @param options.height - The height of the image. If this is not provided, the
|
|
78
|
+
* width will be used as the height.
|
|
79
|
+
* @param options.request - The options to use when fetching the image data.
|
|
80
|
+
* This is passed directly to `fetch`.
|
|
81
|
+
* @returns A promise that resolves to the image data as an image component.
|
|
82
|
+
*/
|
|
83
|
+
async function getImageComponent(url, { width, height = width, request }) {
|
|
84
|
+
(0, utils_1.assert)(typeof width === 'number' && width > 0, 'Expected width to be a number greater than 0.');
|
|
85
|
+
(0, utils_1.assert)(typeof height === 'number' && height > 0, 'Expected height to be a number greater than 0.');
|
|
86
|
+
const imageData = await getImageData(url, request);
|
|
87
|
+
const size = `width="${width}" height="${height}"`;
|
|
88
|
+
return (0, ui_1.image)(`<svg ${size.trim()} xmlns="http://www.w3.org/2000/svg"><image ${size.trim()} href="${imageData}" /></svg>`);
|
|
89
|
+
}
|
|
90
|
+
exports.getImageComponent = getImageComponent;
|
|
91
|
+
//# sourceMappingURL=images.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.cjs","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":";;;AAAA,2CAAwD;AAExD,uCAA6B;AAE7B;;;;;;;GAOG;AACH,KAAK,UAAU,eAAe,CAAC,GAAW,EAAE,OAAqB;IAC/D,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,oCAAoC,GAAG,4EAA4E,CACpH,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QACjD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,oCAAoC,GAAG,MAAM,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CACtF,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,IAAA,cAAM,EACJ,IAAI,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EACvD,gDAAgD,CACjD,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,YAAY,CAAC,GAAW,EAAE,OAAqB;IACnE,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAEvD,OAAO,QAAQ,IAAI,CAAC,IAAI,WAAW,IAAA,qBAAa,EAAC,KAAK,CAAC,EAAE,CAAC;AAC5D,CAAC;AALD,oCAKC;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,EAAgB;IAEhD,IAAA,cAAM,EACJ,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,EACtC,+CAA+C,CAChD,CAAC;IAEF,IAAA,cAAM,EACJ,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,GAAG,CAAC,EACxC,gDAAgD,CACjD,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,UAAU,KAAK,aAAa,MAAM,GAAG,CAAC;IAEnD,OAAO,IAAA,UAAK,EACV,QAAQ,IAAI,CAAC,IAAI,EAAE,8CAA8C,IAAI,CAAC,IAAI,EAAE,UAAU,SAAS,YAAY,CAC5G,CAAC;AACJ,CAAC;AApBD,8CAoBC","sourcesContent":["import { assert, bytesToBase64 } from '@metamask/utils';\n\nimport { image } from './ui';\n\n/**\n * Get raw image data from a URL.\n *\n * @param url - The URL to get the image data from.\n * @param options - The options to use when fetching the image data. This is\n * passed directly to `fetch`.\n * @returns A promise that resolves to the image data as a blob.\n */\nasync function getRawImageData(url: string, options?: RequestInit) {\n if (typeof fetch !== 'function') {\n throw new Error(\n `Failed to fetch image data from \"${url}\": Using this function requires the \"endowment:network-access\" permission.`,\n );\n }\n\n return fetch(url, options).then(async (response) => {\n if (!response.ok) {\n throw new Error(\n `Failed to fetch image data from \"${url}\": ${response.status} ${response.statusText}`,\n );\n }\n\n const blob = await response.blob();\n assert(\n blob.type === 'image/jpeg' || blob.type === 'image/png',\n 'Expected image data to be a JPEG or PNG image.',\n );\n\n return blob;\n });\n}\n\n/**\n * Get image data as data-string from a URL. This is useful for embedding images\n * inside of SVGs. Only JPEG and PNG images are supported.\n *\n * Note: This function uses `fetch` to get the image data. This means that using\n * it requires the `endowment:network-access` permission.\n *\n * @example\n * const imageData = await getImageData('https://cataas.com/cat');\n * const svg = `\n * <svg width=\"100\" height=\"100\" xmlns=\"http://www.w3.org/2000/svg\">\n * <image href=\"${imageData}\" />\n * </svg>\n * `;\n *\n * // Render the SVG in a Snap UI.\n * const ui = image(svg);\n * @param url - The URL to get the image data from.\n * @param options - The options to use when fetching the image data. This is\n * passed directly to `fetch`.\n * @returns A promise that resolves to the image data as a data-string.\n */\nexport async function getImageData(url: string, options?: RequestInit) {\n const blob = await getRawImageData(url, options);\n const bytes = new Uint8Array(await blob.arrayBuffer());\n\n return `data:${blob.type};base64,${bytesToBase64(bytes)}`;\n}\n\n/**\n * Options for getting an SVG image element from a URL.\n *\n * @property width - The width of the image.\n * @property height - The height of the image. If this is not provided, the\n * width will be used as the height.\n * @property request - The options to use when fetching the image data. This is\n * passed directly to `fetch`.\n */\nexport type ImageOptions = {\n width: number;\n height?: number;\n request?: RequestInit;\n};\n\n/**\n * Get an image component from a URL. This is useful for embedding images inside\n * Snap UIs. Only JPEG and PNG images are supported.\n *\n * Note: This function uses `fetch` to get the image data. This means that using\n * it requires the `endowment:network-access` permission.\n *\n * @example\n * const component = await getImage('https://cataas.com/cat');\n *\n * return await snap.request({\n * method: 'snap_dialog',\n * params: {\n * type: 'alert',\n * content: panel([\n * component,\n * ]),\n * },\n * });\n * @param url - The URL to get the image data from.\n * @param options - The options to use when fetching and rendering the image.\n * @param options.width - The width of the image.\n * @param options.height - The height of the image. If this is not provided, the\n * width will be used as the height.\n * @param options.request - The options to use when fetching the image data.\n * This is passed directly to `fetch`.\n * @returns A promise that resolves to the image data as an image component.\n */\nexport async function getImageComponent(\n url: string,\n { width, height = width, request }: ImageOptions,\n) {\n assert(\n typeof width === 'number' && width > 0,\n 'Expected width to be a number greater than 0.',\n );\n\n assert(\n typeof height === 'number' && height > 0,\n 'Expected height to be a number greater than 0.',\n );\n\n const imageData = await getImageData(url, request);\n const size = `width=\"${width}\" height=\"${height}\"`;\n\n return image(\n `<svg ${size.trim()} xmlns=\"http://www.w3.org/2000/svg\"><image ${size.trim()} href=\"${imageData}\" /></svg>`,\n );\n}\n"]}
|