@metamask/snaps-sdk 10.2.0 → 10.4.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 +19 -1
- package/dist/error-wrappers.d.cts +192 -192
- package/dist/error-wrappers.d.mts +192 -192
- package/dist/images.cjs +1 -0
- package/dist/images.cjs.map +1 -1
- package/dist/images.d.cts +1 -0
- package/dist/images.d.cts.map +1 -1
- package/dist/images.d.mts +1 -0
- package/dist/images.d.mts.map +1 -1
- package/dist/images.mjs +1 -0
- package/dist/images.mjs.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internals/error-wrappers.d.cts +12 -12
- package/dist/internals/error-wrappers.d.mts +12 -12
- package/dist/internals/index.cjs +1 -0
- package/dist/internals/index.cjs.map +1 -1
- package/dist/internals/index.d.cts +1 -0
- package/dist/internals/index.d.cts.map +1 -1
- package/dist/internals/index.d.mts +1 -0
- package/dist/internals/index.d.mts.map +1 -1
- package/dist/internals/index.mjs +1 -0
- package/dist/internals/index.mjs.map +1 -1
- package/dist/internals/uri.cjs +21 -0
- package/dist/internals/uri.cjs.map +1 -0
- package/dist/internals/uri.d.cts +11 -0
- package/dist/internals/uri.d.cts.map +1 -0
- package/dist/internals/uri.d.mts +11 -0
- package/dist/internals/uri.d.mts.map +1 -0
- package/dist/internals/uri.mjs +17 -0
- package/dist/internals/uri.mjs.map +1 -0
- package/dist/jsx/components/Image.cjs +2 -0
- package/dist/jsx/components/Image.cjs.map +1 -1
- package/dist/jsx/components/Image.d.cts +4 -0
- package/dist/jsx/components/Image.d.cts.map +1 -1
- package/dist/jsx/components/Image.d.mts +4 -0
- package/dist/jsx/components/Image.d.mts.map +1 -1
- package/dist/jsx/components/Image.mjs +2 -0
- package/dist/jsx/components/Image.mjs.map +1 -1
- package/dist/jsx/validation.cjs +3 -1
- package/dist/jsx/validation.cjs.map +1 -1
- package/dist/jsx/validation.d.cts +8 -0
- package/dist/jsx/validation.d.cts.map +1 -1
- package/dist/jsx/validation.d.mts +8 -0
- package/dist/jsx/validation.d.mts.map +1 -1
- package/dist/jsx/validation.mjs +4 -2
- package/dist/jsx/validation.mjs.map +1 -1
- package/dist/types/handlers/assets-market-data.cjs.map +1 -1
- package/dist/types/handlers/assets-market-data.d.cts +1 -1
- package/dist/types/handlers/assets-market-data.d.mts +1 -1
- package/dist/types/handlers/assets-market-data.mjs.map +1 -1
- package/dist/types/interface.d.cts +2 -0
- package/dist/types/interface.d.cts.map +1 -1
- package/dist/types/interface.d.mts +2 -0
- package/dist/types/interface.d.mts.map +1 -1
- package/dist/types/methods/index.cjs.map +1 -1
- package/dist/types/methods/index.d.cts +1 -0
- package/dist/types/methods/index.d.cts.map +1 -1
- package/dist/types/methods/index.d.mts +1 -0
- package/dist/types/methods/index.d.mts.map +1 -1
- package/dist/types/methods/index.mjs.map +1 -1
- package/dist/types/methods/methods.cjs.map +1 -1
- package/dist/types/methods/methods.d.cts +5 -0
- package/dist/types/methods/methods.d.cts.map +1 -1
- package/dist/types/methods/methods.d.mts +5 -0
- package/dist/types/methods/methods.d.mts.map +1 -1
- package/dist/types/methods/methods.mjs.map +1 -1
- package/dist/types/methods/multichain/create-session.cjs +3 -0
- package/dist/types/methods/multichain/create-session.cjs.map +1 -0
- package/dist/types/methods/multichain/create-session.d.cts +34 -0
- package/dist/types/methods/multichain/create-session.d.cts.map +1 -0
- package/dist/types/methods/multichain/create-session.d.mts +34 -0
- package/dist/types/methods/multichain/create-session.d.mts.map +1 -0
- package/dist/types/methods/multichain/create-session.mjs +2 -0
- package/dist/types/methods/multichain/create-session.mjs.map +1 -0
- package/dist/types/methods/multichain/get-session.cjs +3 -0
- package/dist/types/methods/multichain/get-session.cjs.map +1 -0
- package/dist/types/methods/multichain/get-session.d.cts +14 -0
- package/dist/types/methods/multichain/get-session.d.cts.map +1 -0
- package/dist/types/methods/multichain/get-session.d.mts +14 -0
- package/dist/types/methods/multichain/get-session.d.mts.map +1 -0
- package/dist/types/methods/multichain/get-session.mjs +2 -0
- package/dist/types/methods/multichain/get-session.mjs.map +1 -0
- package/dist/types/methods/multichain/index.cjs +3 -0
- package/dist/types/methods/multichain/index.cjs.map +1 -0
- package/dist/types/methods/multichain/index.d.cts +5 -0
- package/dist/types/methods/multichain/index.d.cts.map +1 -0
- package/dist/types/methods/multichain/index.d.mts +5 -0
- package/dist/types/methods/multichain/index.d.mts.map +1 -0
- package/dist/types/methods/multichain/index.mjs +2 -0
- package/dist/types/methods/multichain/index.mjs.map +1 -0
- package/dist/types/methods/multichain/invoke-method.cjs +3 -0
- package/dist/types/methods/multichain/invoke-method.cjs.map +1 -0
- package/dist/types/methods/multichain/invoke-method.d.cts +18 -0
- package/dist/types/methods/multichain/invoke-method.d.cts.map +1 -0
- package/dist/types/methods/multichain/invoke-method.d.mts +18 -0
- package/dist/types/methods/multichain/invoke-method.d.mts.map +1 -0
- package/dist/types/methods/multichain/invoke-method.mjs +2 -0
- package/dist/types/methods/multichain/invoke-method.mjs.map +1 -0
- package/dist/types/methods/multichain/revoke-session.cjs +3 -0
- package/dist/types/methods/multichain/revoke-session.cjs.map +1 -0
- package/dist/types/methods/multichain/revoke-session.d.cts +13 -0
- package/dist/types/methods/multichain/revoke-session.d.cts.map +1 -0
- package/dist/types/methods/multichain/revoke-session.d.mts +13 -0
- package/dist/types/methods/multichain/revoke-session.d.mts.map +1 -0
- package/dist/types/methods/multichain/revoke-session.mjs +2 -0
- package/dist/types/methods/multichain/revoke-session.mjs.map +1 -0
- package/package.json +3 -3
package/dist/images.cjs
CHANGED
|
@@ -79,6 +79,7 @@ exports.getImageData = getImageData;
|
|
|
79
79
|
* @param options.request - The options to use when fetching the image data.
|
|
80
80
|
* This is passed directly to `fetch`.
|
|
81
81
|
* @returns A promise that resolves to the image data as an image component.
|
|
82
|
+
* @deprecated Use `<Image src="external_url" />` instead. This function will be removed in a future release.
|
|
82
83
|
*/
|
|
83
84
|
async function getImageComponent(url, { width, height = width, request }) {
|
|
84
85
|
(0, utils_1.assert)(typeof width === 'number' && width > 0, 'Expected width to be a number greater than 0.');
|
package/dist/images.cjs.map
CHANGED
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;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 * @deprecated Use `<Image src=\"external_url\" />` instead. This function will be removed in a future release.\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"]}
|
package/dist/images.d.cts
CHANGED
|
@@ -62,6 +62,7 @@ export type ImageOptions = {
|
|
|
62
62
|
* @param options.request - The options to use when fetching the image data.
|
|
63
63
|
* This is passed directly to `fetch`.
|
|
64
64
|
* @returns A promise that resolves to the image data as an image component.
|
|
65
|
+
* @deprecated Use `<Image src="external_url" />` instead. This function will be removed in a future release.
|
|
65
66
|
*/
|
|
66
67
|
export declare function getImageComponent(url: string, { width, height, request }: ImageOptions): Promise<{
|
|
67
68
|
value: string;
|
package/dist/images.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"images.d.cts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAoCA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,mBAKpE;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"images.d.cts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAoCA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,mBAKpE;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,EAAE,KAAK,EAAE,MAAc,EAAE,OAAO,EAAE,EAAE,YAAY;;;GAkBjD"}
|
package/dist/images.d.mts
CHANGED
|
@@ -62,6 +62,7 @@ export type ImageOptions = {
|
|
|
62
62
|
* @param options.request - The options to use when fetching the image data.
|
|
63
63
|
* This is passed directly to `fetch`.
|
|
64
64
|
* @returns A promise that resolves to the image data as an image component.
|
|
65
|
+
* @deprecated Use `<Image src="external_url" />` instead. This function will be removed in a future release.
|
|
65
66
|
*/
|
|
66
67
|
export declare function getImageComponent(url: string, { width, height, request }: ImageOptions): Promise<{
|
|
67
68
|
value: string;
|
package/dist/images.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"images.d.mts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAoCA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,mBAKpE;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"images.d.mts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAoCA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,mBAKpE;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,EAAE,KAAK,EAAE,MAAc,EAAE,OAAO,EAAE,EAAE,YAAY;;;GAkBjD"}
|
package/dist/images.mjs
CHANGED
|
@@ -75,6 +75,7 @@ export async function getImageData(url, options) {
|
|
|
75
75
|
* @param options.request - The options to use when fetching the image data.
|
|
76
76
|
* This is passed directly to `fetch`.
|
|
77
77
|
* @returns A promise that resolves to the image data as an image component.
|
|
78
|
+
* @deprecated Use `<Image src="external_url" />` instead. This function will be removed in a future release.
|
|
78
79
|
*/
|
|
79
80
|
export async function getImageComponent(url, { width, height = width, request }) {
|
|
80
81
|
assert(typeof width === 'number' && width > 0, 'Expected width to be a number greater than 0.');
|
package/dist/images.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"images.mjs","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,wBAAwB;AAExD,OAAO,EAAE,KAAK,EAAE,uBAAa;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,MAAM,CACJ,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;AACH,MAAM,CAAC,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,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;AAC5D,CAAC;AAiBD
|
|
1
|
+
{"version":3,"file":"images.mjs","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,wBAAwB;AAExD,OAAO,EAAE,KAAK,EAAE,uBAAa;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,MAAM,CACJ,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;AACH,MAAM,CAAC,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,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;AAC5D,CAAC;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,EAAgB;IAEhD,MAAM,CACJ,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,EACtC,+CAA+C,CAChD,CAAC;IAEF,MAAM,CACJ,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,KAAK,CACV,QAAQ,IAAI,CAAC,IAAI,EAAE,8CAA8C,IAAI,CAAC,IAAI,EAAE,UAAU,SAAS,YAAY,CAC5G,CAAC;AACJ,CAAC","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 * @deprecated Use `<Image src=\"external_url\" />` instead. This function will be removed in a future release.\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"]}
|
package/dist/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.assert = exports.ISO8601DateStruct = exports.nonEmptyRecord = exports.selectiveUnion = exports.typedUnion = exports.enumValue = exports.union = exports.literal = exports.SNAP_ERROR_MESSAGE = exports.SNAP_ERROR_CODE = exports.getErrorStack = exports.getErrorMessage = exports.getErrorData = void 0;
|
|
17
|
+
exports.assert = exports.uri = exports.ISO8601DateStruct = exports.nonEmptyRecord = exports.selectiveUnion = exports.typedUnion = exports.enumValue = exports.union = exports.literal = exports.SNAP_ERROR_MESSAGE = exports.SNAP_ERROR_CODE = exports.getErrorStack = exports.getErrorMessage = exports.getErrorData = void 0;
|
|
18
18
|
var internals_1 = require("./internals/index.cjs");
|
|
19
19
|
Object.defineProperty(exports, "getErrorData", { enumerable: true, get: function () { return internals_1.getErrorData; } });
|
|
20
20
|
Object.defineProperty(exports, "getErrorMessage", { enumerable: true, get: function () { return internals_1.getErrorMessage; } });
|
|
@@ -28,6 +28,7 @@ Object.defineProperty(exports, "typedUnion", { enumerable: true, get: function (
|
|
|
28
28
|
Object.defineProperty(exports, "selectiveUnion", { enumerable: true, get: function () { return internals_1.selectiveUnion; } });
|
|
29
29
|
Object.defineProperty(exports, "nonEmptyRecord", { enumerable: true, get: function () { return internals_1.nonEmptyRecord; } });
|
|
30
30
|
Object.defineProperty(exports, "ISO8601DateStruct", { enumerable: true, get: function () { return internals_1.ISO8601DateStruct; } });
|
|
31
|
+
Object.defineProperty(exports, "uri", { enumerable: true, get: function () { return internals_1.uri; } });
|
|
31
32
|
var utils_1 = require("@metamask/utils");
|
|
32
33
|
Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return utils_1.assert; } });
|
|
33
34
|
__exportStar(require("./errors.cjs"), exports);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,mDAcqB;AAbnB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AACf,0GAAA,aAAa,OAAA;AACb,4GAAA,eAAe,OAAA;AACf,+GAAA,kBAAkB,OAAA;AAClB,oGAAA,OAAO,OAAA;AACP,kGAAA,KAAK,OAAA;AACL,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,gGAAA,GAAG,OAAA;AAUL,yCAAyC;AAAhC,+FAAA,MAAM,OAAA;AAEf,+CAAyB;AACzB,uDAAiC;AACjC,+CAAyB;AACzB,oDAAwB;AACxB,iDAAqB","sourcesContent":["// Only internals that are used by other Snaps packages should be exported here.\nexport type { EnumToUnion } from './internals';\nexport type { UriOptions } from './internals';\nexport {\n getErrorData,\n getErrorMessage,\n getErrorStack,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n literal,\n union,\n enumValue,\n typedUnion,\n selectiveUnion,\n nonEmptyRecord,\n ISO8601DateStruct,\n uri,\n} from './internals';\n\n// Re-exported from `@metamask/utils` for convenience.\nexport type {\n Json,\n JsonRpcError,\n JsonRpcRequest,\n JsonRpcParams,\n} from '@metamask/utils';\nexport { assert } from '@metamask/utils';\n\nexport * from './errors';\nexport * from './error-wrappers';\nexport * from './images';\nexport * from './types';\nexport * from './ui';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { EnumToUnion } from "./internals/index.cjs";
|
|
2
|
-
export {
|
|
2
|
+
export type { UriOptions } from "./internals/index.cjs";
|
|
3
|
+
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue, typedUnion, selectiveUnion, nonEmptyRecord, ISO8601DateStruct, uri, } from "./internals/index.cjs";
|
|
3
4
|
export type { Json, JsonRpcError, JsonRpcRequest, JsonRpcParams, } from "@metamask/utils";
|
|
4
5
|
export { assert } from "@metamask/utils";
|
|
5
6
|
export * from "./errors.cjs";
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,8BAAoB;AAC/C,OAAO,EACL,YAAY,EACZ,eAAe,EACf,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,8BAAoB;AAC/C,YAAY,EAAE,UAAU,EAAE,8BAAoB;AAC9C,OAAO,EACL,YAAY,EACZ,eAAe,EACf,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,GAAG,GACJ,8BAAoB;AAGrB,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,cAAc,EACd,aAAa,GACd,wBAAwB;AACzB,OAAO,EAAE,MAAM,EAAE,wBAAwB;AAEzC,6BAAyB;AACzB,qCAAiC;AACjC,6BAAyB;AACzB,kCAAwB;AACxB,+BAAqB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { EnumToUnion } from "./internals/index.mjs";
|
|
2
|
-
export {
|
|
2
|
+
export type { UriOptions } from "./internals/index.mjs";
|
|
3
|
+
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue, typedUnion, selectiveUnion, nonEmptyRecord, ISO8601DateStruct, uri, } from "./internals/index.mjs";
|
|
3
4
|
export type { Json, JsonRpcError, JsonRpcRequest, JsonRpcParams, } from "@metamask/utils";
|
|
4
5
|
export { assert } from "@metamask/utils";
|
|
5
6
|
export * from "./errors.mjs";
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,8BAAoB;AAC/C,OAAO,EACL,YAAY,EACZ,eAAe,EACf,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,8BAAoB;AAC/C,YAAY,EAAE,UAAU,EAAE,8BAAoB;AAC9C,OAAO,EACL,YAAY,EACZ,eAAe,EACf,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,GAAG,GACJ,8BAAoB;AAGrB,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,cAAc,EACd,aAAa,GACd,wBAAwB;AACzB,OAAO,EAAE,MAAM,EAAE,wBAAwB;AAEzC,6BAAyB;AACzB,qCAAiC;AACjC,6BAAyB;AACzB,kCAAwB;AACxB,+BAAqB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue, typedUnion, selectiveUnion, nonEmptyRecord, ISO8601DateStruct } from "./internals/index.mjs";
|
|
1
|
+
export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue, typedUnion, selectiveUnion, nonEmptyRecord, ISO8601DateStruct, uri } from "./internals/index.mjs";
|
|
2
2
|
export { assert } from "@metamask/utils";
|
|
3
3
|
export * from "./errors.mjs";
|
|
4
4
|
export * from "./error-wrappers.mjs";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,GAAG,EACJ,8BAAoB;AASrB,OAAO,EAAE,MAAM,EAAE,wBAAwB;AAEzC,6BAAyB;AACzB,qCAAiC;AACjC,6BAAyB;AACzB,kCAAwB;AACxB,+BAAqB","sourcesContent":["// Only internals that are used by other Snaps packages should be exported here.\nexport type { EnumToUnion } from './internals';\nexport type { UriOptions } from './internals';\nexport {\n getErrorData,\n getErrorMessage,\n getErrorStack,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n literal,\n union,\n enumValue,\n typedUnion,\n selectiveUnion,\n nonEmptyRecord,\n ISO8601DateStruct,\n uri,\n} from './internals';\n\n// Re-exported from `@metamask/utils` for convenience.\nexport type {\n Json,\n JsonRpcError,\n JsonRpcRequest,\n JsonRpcParams,\n} from '@metamask/utils';\nexport { assert } from '@metamask/utils';\n\nexport * from './errors';\nexport * from './error-wrappers';\nexport * from './images';\nexport * from './types';\nexport * from './ui';\n"]}
|
|
@@ -15,10 +15,10 @@ export type JsonRpcErrorFunction = typeof rpcErrors.parse;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
17
17
|
new (message?: string): {
|
|
18
|
-
readonly "__#
|
|
19
|
-
readonly "__#
|
|
20
|
-
readonly "__#
|
|
21
|
-
readonly "__#
|
|
18
|
+
readonly "__#17027@#code": number;
|
|
19
|
+
readonly "__#17027@#message": string;
|
|
20
|
+
readonly "__#17027@#data"?: Record<string, Json> | undefined;
|
|
21
|
+
readonly "__#17027@#stack"?: string | undefined;
|
|
22
22
|
readonly name: string;
|
|
23
23
|
readonly code: number;
|
|
24
24
|
readonly message: string;
|
|
@@ -29,10 +29,10 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
29
29
|
cause?: unknown;
|
|
30
30
|
};
|
|
31
31
|
new (data?: Record<string, Json>): {
|
|
32
|
-
readonly "__#
|
|
33
|
-
readonly "__#
|
|
34
|
-
readonly "__#
|
|
35
|
-
readonly "__#
|
|
32
|
+
readonly "__#17027@#code": number;
|
|
33
|
+
readonly "__#17027@#message": string;
|
|
34
|
+
readonly "__#17027@#data"?: Record<string, Json> | undefined;
|
|
35
|
+
readonly "__#17027@#stack"?: string | undefined;
|
|
36
36
|
readonly name: string;
|
|
37
37
|
readonly code: number;
|
|
38
38
|
readonly message: string;
|
|
@@ -43,10 +43,10 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
43
43
|
cause?: unknown;
|
|
44
44
|
};
|
|
45
45
|
new (message?: string | Record<string, Json>, data?: Record<string, Json>): {
|
|
46
|
-
readonly "__#
|
|
47
|
-
readonly "__#
|
|
48
|
-
readonly "__#
|
|
49
|
-
readonly "__#
|
|
46
|
+
readonly "__#17027@#code": number;
|
|
47
|
+
readonly "__#17027@#message": string;
|
|
48
|
+
readonly "__#17027@#data"?: Record<string, Json> | undefined;
|
|
49
|
+
readonly "__#17027@#stack"?: string | undefined;
|
|
50
50
|
readonly name: string;
|
|
51
51
|
readonly code: number;
|
|
52
52
|
readonly message: string;
|
|
@@ -15,10 +15,10 @@ export type JsonRpcErrorFunction = typeof rpcErrors.parse;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
17
17
|
new (message?: string): {
|
|
18
|
-
readonly "__#
|
|
19
|
-
readonly "__#
|
|
20
|
-
readonly "__#
|
|
21
|
-
readonly "__#
|
|
18
|
+
readonly "__#8519@#code": number;
|
|
19
|
+
readonly "__#8519@#message": string;
|
|
20
|
+
readonly "__#8519@#data"?: Record<string, Json> | undefined;
|
|
21
|
+
readonly "__#8519@#stack"?: string | undefined;
|
|
22
22
|
readonly name: string;
|
|
23
23
|
readonly code: number;
|
|
24
24
|
readonly message: string;
|
|
@@ -29,10 +29,10 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
29
29
|
cause?: unknown;
|
|
30
30
|
};
|
|
31
31
|
new (data?: Record<string, Json>): {
|
|
32
|
-
readonly "__#
|
|
33
|
-
readonly "__#
|
|
34
|
-
readonly "__#
|
|
35
|
-
readonly "__#
|
|
32
|
+
readonly "__#8519@#code": number;
|
|
33
|
+
readonly "__#8519@#message": string;
|
|
34
|
+
readonly "__#8519@#data"?: Record<string, Json> | undefined;
|
|
35
|
+
readonly "__#8519@#stack"?: string | undefined;
|
|
36
36
|
readonly name: string;
|
|
37
37
|
readonly code: number;
|
|
38
38
|
readonly message: string;
|
|
@@ -43,10 +43,10 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
43
43
|
cause?: unknown;
|
|
44
44
|
};
|
|
45
45
|
new (message?: string | Record<string, Json>, data?: Record<string, Json>): {
|
|
46
|
-
readonly "__#
|
|
47
|
-
readonly "__#
|
|
48
|
-
readonly "__#
|
|
49
|
-
readonly "__#
|
|
46
|
+
readonly "__#8519@#code": number;
|
|
47
|
+
readonly "__#8519@#message": string;
|
|
48
|
+
readonly "__#8519@#data"?: Record<string, Json> | undefined;
|
|
49
|
+
readonly "__#8519@#stack"?: string | undefined;
|
|
50
50
|
readonly name: string;
|
|
51
51
|
readonly code: number;
|
|
52
52
|
readonly message: string;
|
package/dist/internals/index.cjs
CHANGED
|
@@ -20,4 +20,5 @@ __exportStar(require("./structs.cjs"), exports);
|
|
|
20
20
|
__exportStar(require("./jsx.cjs"), exports);
|
|
21
21
|
__exportStar(require("./svg.cjs"), exports);
|
|
22
22
|
__exportStar(require("./time.cjs"), exports);
|
|
23
|
+
__exportStar(require("./uri.cjs"), exports);
|
|
23
24
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAiC;AACjC,+CAAyB;AAEzB,gDAA0B;AAC1B,4CAAsB;AACtB,4CAAsB;AACtB,6CAAuB","sourcesContent":["export * from './error-wrappers';\nexport * from './errors';\nexport type * from './helpers';\nexport * from './structs';\nexport * from './jsx';\nexport * from './svg';\nexport * from './time';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAiC;AACjC,+CAAyB;AAEzB,gDAA0B;AAC1B,4CAAsB;AACtB,4CAAsB;AACtB,6CAAuB;AACvB,4CAAsB","sourcesContent":["export * from './error-wrappers';\nexport * from './errors';\nexport type * from './helpers';\nexport * from './structs';\nexport * from './jsx';\nexport * from './svg';\nexport * from './time';\nexport * from './uri';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,qCAAiC;AACjC,6BAAyB;AACzB,mCAA+B;AAC/B,8BAA0B;AAC1B,0BAAsB;AACtB,0BAAsB;AACtB,2BAAuB"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,qCAAiC;AACjC,6BAAyB;AACzB,mCAA+B;AAC/B,8BAA0B;AAC1B,0BAAsB;AACtB,0BAAsB;AACtB,2BAAuB;AACvB,0BAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,qCAAiC;AACjC,6BAAyB;AACzB,mCAA+B;AAC/B,8BAA0B;AAC1B,0BAAsB;AACtB,0BAAsB;AACtB,2BAAuB"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,qCAAiC;AACjC,6BAAyB;AACzB,mCAA+B;AAC/B,8BAA0B;AAC1B,0BAAsB;AACtB,0BAAsB;AACtB,2BAAuB;AACvB,0BAAsB"}
|
package/dist/internals/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,qCAAiC;AACjC,6BAAyB;AAEzB,8BAA0B;AAC1B,0BAAsB;AACtB,0BAAsB;AACtB,2BAAuB","sourcesContent":["export * from './error-wrappers';\nexport * from './errors';\nexport type * from './helpers';\nexport * from './structs';\nexport * from './jsx';\nexport * from './svg';\nexport * from './time';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,qCAAiC;AACjC,6BAAyB;AAEzB,8BAA0B;AAC1B,0BAAsB;AACtB,0BAAsB;AACtB,2BAAuB;AACvB,0BAAsB","sourcesContent":["export * from './error-wrappers';\nexport * from './errors';\nexport type * from './helpers';\nexport * from './structs';\nexport * from './jsx';\nexport * from './svg';\nexport * from './time';\nexport * from './uri';\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uri = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const errors_1 = require("./errors.cjs");
|
|
6
|
+
const uri = (opts = {}) => (0, superstruct_1.refine)((0, superstruct_1.string)(), 'uri', (value) => {
|
|
7
|
+
try {
|
|
8
|
+
const url = new URL(value);
|
|
9
|
+
const UrlStruct = (0, superstruct_1.type)(opts);
|
|
10
|
+
(0, superstruct_1.assert)(url, UrlStruct);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error instanceof superstruct_1.StructError) {
|
|
15
|
+
return (0, errors_1.getErrorMessage)(error);
|
|
16
|
+
}
|
|
17
|
+
return `Expected URL, got "${value.toString()}"`;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.uri = uri;
|
|
21
|
+
//# sourceMappingURL=uri.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri.cjs","sourceRoot":"","sources":["../../src/internals/uri.ts"],"names":[],"mappings":";;;AAAA,uDAM+B;AAG/B,yCAA2C;AAWpC,MAAM,GAAG,GAAG,CAAC,OAAwB,EAAE,EAAE,EAAE,CAChD,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;IAChC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAE3B,MAAM,SAAS,GAAG,IAAA,kBAAI,EAAC,IAAI,CAAC,CAAC;QAC7B,IAAA,oBAAiB,EAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,OAAO,IAAA,wBAAe,EAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,sBAAsB,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC;IACnD,CAAC;AACH,CAAC,CAAC,CAAC;AAdQ,QAAA,GAAG,OAcX","sourcesContent":["import {\n refine,\n string,\n type,\n assert as assertSuperstruct,\n StructError,\n} from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\n\nimport { getErrorMessage } from './errors';\n\nexport type UriOptions<Type extends string> = {\n protocol?: Struct<Type>;\n hash?: Struct<Type>;\n port?: Struct<Type>;\n hostname?: Struct<Type>;\n pathname?: Struct<Type>;\n search?: Struct<Type>;\n};\n\nexport const uri = (opts: UriOptions<any> = {}) =>\n refine(string(), 'uri', (value) => {\n try {\n const url = new URL(value);\n\n const UrlStruct = type(opts);\n assertSuperstruct(url, UrlStruct);\n return true;\n } catch (error) {\n if (error instanceof StructError) {\n return getErrorMessage(error);\n }\n return `Expected URL, got \"${value.toString()}\"`;\n }\n });\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Struct } from "@metamask/superstruct";
|
|
2
|
+
export type UriOptions<Type extends string> = {
|
|
3
|
+
protocol?: Struct<Type>;
|
|
4
|
+
hash?: Struct<Type>;
|
|
5
|
+
port?: Struct<Type>;
|
|
6
|
+
hostname?: Struct<Type>;
|
|
7
|
+
pathname?: Struct<Type>;
|
|
8
|
+
search?: Struct<Type>;
|
|
9
|
+
};
|
|
10
|
+
export declare const uri: (opts?: UriOptions<any>) => Struct<string, null>;
|
|
11
|
+
//# sourceMappingURL=uri.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri.d.cts","sourceRoot":"","sources":["../../src/internals/uri.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAIpD,MAAM,MAAM,UAAU,CAAC,IAAI,SAAS,MAAM,IAAI;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,GAAG,UAAU,WAAW,GAAG,CAAC,yBAcrC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Struct } from "@metamask/superstruct";
|
|
2
|
+
export type UriOptions<Type extends string> = {
|
|
3
|
+
protocol?: Struct<Type>;
|
|
4
|
+
hash?: Struct<Type>;
|
|
5
|
+
port?: Struct<Type>;
|
|
6
|
+
hostname?: Struct<Type>;
|
|
7
|
+
pathname?: Struct<Type>;
|
|
8
|
+
search?: Struct<Type>;
|
|
9
|
+
};
|
|
10
|
+
export declare const uri: (opts?: UriOptions<any>) => Struct<string, null>;
|
|
11
|
+
//# sourceMappingURL=uri.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri.d.mts","sourceRoot":"","sources":["../../src/internals/uri.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAIpD,MAAM,MAAM,UAAU,CAAC,IAAI,SAAS,MAAM,IAAI;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,GAAG,UAAU,WAAW,GAAG,CAAC,yBAcrC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { refine, string, type, assert as assertSuperstruct, StructError } from "@metamask/superstruct";
|
|
2
|
+
import { getErrorMessage } from "./errors.mjs";
|
|
3
|
+
export const uri = (opts = {}) => refine(string(), 'uri', (value) => {
|
|
4
|
+
try {
|
|
5
|
+
const url = new URL(value);
|
|
6
|
+
const UrlStruct = type(opts);
|
|
7
|
+
assertSuperstruct(url, UrlStruct);
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (error instanceof StructError) {
|
|
12
|
+
return getErrorMessage(error);
|
|
13
|
+
}
|
|
14
|
+
return `Expected URL, got "${value.toString()}"`;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=uri.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri.mjs","sourceRoot":"","sources":["../../src/internals/uri.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,IAAI,EACJ,MAAM,IAAI,iBAAiB,EAC3B,WAAW,EACZ,8BAA8B;AAG/B,OAAO,EAAE,eAAe,EAAE,qBAAiB;AAW3C,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,OAAwB,EAAE,EAAE,EAAE,CAChD,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;IAChC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAE3B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,iBAAiB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,sBAAsB,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC;IACnD,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import {\n refine,\n string,\n type,\n assert as assertSuperstruct,\n StructError,\n} from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\n\nimport { getErrorMessage } from './errors';\n\nexport type UriOptions<Type extends string> = {\n protocol?: Struct<Type>;\n hash?: Struct<Type>;\n port?: Struct<Type>;\n hostname?: Struct<Type>;\n pathname?: Struct<Type>;\n search?: Struct<Type>;\n};\n\nexport const uri = (opts: UriOptions<any> = {}) =>\n refine(string(), 'uri', (value) => {\n try {\n const url = new URL(value);\n\n const UrlStruct = type(opts);\n assertSuperstruct(url, UrlStruct);\n return true;\n } catch (error) {\n if (error instanceof StructError) {\n return getErrorMessage(error);\n }\n return `Expected URL, got \"${value.toString()}\"`;\n }\n });\n"]}
|
|
@@ -15,6 +15,8 @@ const TYPE = 'Image';
|
|
|
15
15
|
* @param props.alt - The alternative text of the image, which describes the
|
|
16
16
|
* image for users who cannot see it.
|
|
17
17
|
* @param props.borderRadius - The border radius applied to the image.
|
|
18
|
+
* @param props.width - The width of the image.
|
|
19
|
+
* @param props.height - The height of the image.
|
|
18
20
|
* @returns An image element.
|
|
19
21
|
* @example
|
|
20
22
|
* <Image src="<svg>...</svg>" alt="An example image" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.cjs","sourceRoot":"","sources":["../../../src/jsx/components/Image.ts"],"names":[],"mappings":";;;AACA,gDAAmD;
|
|
1
|
+
{"version":3,"file":"Image.cjs","sourceRoot":"","sources":["../../../src/jsx/components/Image.ts"],"names":[],"mappings":";;;AACA,gDAAmD;AAmBnD,MAAM,IAAI,GAAG,OAAO,CAAC;AAErB;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,KAAK,GAAG,IAAA,+BAAmB,EAA0B,IAAI,CAAC,CAAC","sourcesContent":["import type { BorderRadius } from './utils';\nimport { createSnapComponent } from '../component';\n\n/**\n * The props of the {@link Image} component.\n *\n * @property src - The SVG image to display. This should be an SVG string, and\n * other formats such as PNG and JPEG are not supported directly. You can use\n * the `data:` URL scheme to embed images inside the SVG.\n * @property alt - The alternative text of the image, which describes the image\n * for users who cannot see it.\n */\ntype ImageProps = {\n src: string;\n alt?: string | undefined;\n borderRadius?: BorderRadius | undefined;\n height?: number | undefined;\n width?: number | undefined;\n};\n\nconst TYPE = 'Image';\n\n/**\n * An image component, which is used to display an image.\n *\n * This component does not accept any children.\n *\n * @param props - The props of the component.\n * @param props.src - The URL of the image to display. This should be an SVG\n * string, and other formats such as PNG and JPEG are not supported directly.\n * You can use the `data:` URL scheme to embed images inside the SVG.\n * @param props.alt - The alternative text of the image, which describes the\n * image for users who cannot see it.\n * @param props.borderRadius - The border radius applied to the image.\n * @param props.width - The width of the image.\n * @param props.height - The height of the image.\n * @returns An image element.\n * @example\n * <Image src=\"<svg>...</svg>\" alt=\"An example image\" />\n */\nexport const Image = createSnapComponent<ImageProps, typeof TYPE>(TYPE);\n\n/**\n * An image element.\n *\n * @see Image\n */\nexport type ImageElement = ReturnType<typeof Image>;\n"]}
|
|
@@ -12,6 +12,8 @@ type ImageProps = {
|
|
|
12
12
|
src: string;
|
|
13
13
|
alt?: string | undefined;
|
|
14
14
|
borderRadius?: BorderRadius | undefined;
|
|
15
|
+
height?: number | undefined;
|
|
16
|
+
width?: number | undefined;
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* An image component, which is used to display an image.
|
|
@@ -25,6 +27,8 @@ type ImageProps = {
|
|
|
25
27
|
* @param props.alt - The alternative text of the image, which describes the
|
|
26
28
|
* image for users who cannot see it.
|
|
27
29
|
* @param props.borderRadius - The border radius applied to the image.
|
|
30
|
+
* @param props.width - The width of the image.
|
|
31
|
+
* @param props.height - The height of the image.
|
|
28
32
|
* @returns An image element.
|
|
29
33
|
* @example
|
|
30
34
|
* <Image src="<svg>...</svg>" alt="An example image" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.cts","sourceRoot":"","sources":["../../../src/jsx/components/Image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAG5C;;;;;;;;GAQG;AACH,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Image.d.cts","sourceRoot":"","sources":["../../../src/jsx/components/Image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAG5C;;;;;;;;GAQG;AACH,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAIF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,KAAK,2DAAqD,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC"}
|
|
@@ -12,6 +12,8 @@ type ImageProps = {
|
|
|
12
12
|
src: string;
|
|
13
13
|
alt?: string | undefined;
|
|
14
14
|
borderRadius?: BorderRadius | undefined;
|
|
15
|
+
height?: number | undefined;
|
|
16
|
+
width?: number | undefined;
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* An image component, which is used to display an image.
|
|
@@ -25,6 +27,8 @@ type ImageProps = {
|
|
|
25
27
|
* @param props.alt - The alternative text of the image, which describes the
|
|
26
28
|
* image for users who cannot see it.
|
|
27
29
|
* @param props.borderRadius - The border radius applied to the image.
|
|
30
|
+
* @param props.width - The width of the image.
|
|
31
|
+
* @param props.height - The height of the image.
|
|
28
32
|
* @returns An image element.
|
|
29
33
|
* @example
|
|
30
34
|
* <Image src="<svg>...</svg>" alt="An example image" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.mts","sourceRoot":"","sources":["../../../src/jsx/components/Image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAG5C;;;;;;;;GAQG;AACH,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Image.d.mts","sourceRoot":"","sources":["../../../src/jsx/components/Image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAG5C;;;;;;;;GAQG;AACH,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAIF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,KAAK,2DAAqD,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC"}
|
|
@@ -12,6 +12,8 @@ const TYPE = 'Image';
|
|
|
12
12
|
* @param props.alt - The alternative text of the image, which describes the
|
|
13
13
|
* image for users who cannot see it.
|
|
14
14
|
* @param props.borderRadius - The border radius applied to the image.
|
|
15
|
+
* @param props.width - The width of the image.
|
|
16
|
+
* @param props.height - The height of the image.
|
|
15
17
|
* @returns An image element.
|
|
16
18
|
* @example
|
|
17
19
|
* <Image src="<svg>...</svg>" alt="An example image" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.mjs","sourceRoot":"","sources":["../../../src/jsx/components/Image.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;
|
|
1
|
+
{"version":3,"file":"Image.mjs","sourceRoot":"","sources":["../../../src/jsx/components/Image.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AAmBnD,MAAM,IAAI,GAAG,OAAO,CAAC;AAErB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,mBAAmB,CAA0B,IAAI,CAAC,CAAC","sourcesContent":["import type { BorderRadius } from './utils';\nimport { createSnapComponent } from '../component';\n\n/**\n * The props of the {@link Image} component.\n *\n * @property src - The SVG image to display. This should be an SVG string, and\n * other formats such as PNG and JPEG are not supported directly. You can use\n * the `data:` URL scheme to embed images inside the SVG.\n * @property alt - The alternative text of the image, which describes the image\n * for users who cannot see it.\n */\ntype ImageProps = {\n src: string;\n alt?: string | undefined;\n borderRadius?: BorderRadius | undefined;\n height?: number | undefined;\n width?: number | undefined;\n};\n\nconst TYPE = 'Image';\n\n/**\n * An image component, which is used to display an image.\n *\n * This component does not accept any children.\n *\n * @param props - The props of the component.\n * @param props.src - The URL of the image to display. This should be an SVG\n * string, and other formats such as PNG and JPEG are not supported directly.\n * You can use the `data:` URL scheme to embed images inside the SVG.\n * @param props.alt - The alternative text of the image, which describes the\n * image for users who cannot see it.\n * @param props.borderRadius - The border radius applied to the image.\n * @param props.width - The width of the image.\n * @param props.height - The height of the image.\n * @returns An image element.\n * @example\n * <Image src=\"<svg>...</svg>\" alt=\"An example image\" />\n */\nexport const Image = createSnapComponent<ImageProps, typeof TYPE>(TYPE);\n\n/**\n * An image element.\n *\n * @see Image\n */\nexport type ImageElement = ReturnType<typeof Image>;\n"]}
|
package/dist/jsx/validation.cjs
CHANGED
|
@@ -111,9 +111,11 @@ exports.BorderRadiusStruct = (0, internals_1.nullUnion)([
|
|
|
111
111
|
* A struct for the {@link ImageElement} type.
|
|
112
112
|
*/
|
|
113
113
|
exports.ImageStruct = element('Image', {
|
|
114
|
-
src: (0, internals_1.svg)(),
|
|
114
|
+
src: (0, internals_1.nullUnion)([(0, internals_1.svg)(), (0, internals_1.uri)({ protocol: (0, internals_1.literal)('https:') })]),
|
|
115
115
|
alt: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
116
116
|
borderRadius: (0, superstruct_1.optional)(exports.BorderRadiusStruct),
|
|
117
|
+
width: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
118
|
+
height: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
117
119
|
});
|
|
118
120
|
const IconNameStruct = (0, internals_1.nullUnion)(Object.values(components_1.IconName).map((name) => (0, internals_1.literal)(name)));
|
|
119
121
|
/**
|