@metamask/snaps-sdk 6.5.1 → 6.6.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 +92 -1
- package/dist/error-wrappers.d.cts +240 -192
- package/dist/error-wrappers.d.cts.map +1 -1
- package/dist/error-wrappers.d.mts +240 -192
- package/dist/error-wrappers.d.mts.map +1 -1
- package/dist/errors.cjs +12 -25
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.mjs +12 -25
- package/dist/errors.mjs.map +1 -1
- package/dist/internals/error-wrappers.d.cts +15 -12
- package/dist/internals/error-wrappers.d.cts.map +1 -1
- package/dist/internals/error-wrappers.d.mts +15 -12
- package/dist/internals/error-wrappers.d.mts.map +1 -1
- package/dist/jsx/components/Link.cjs.map +1 -1
- package/dist/jsx/components/Link.d.cts +3 -1
- package/dist/jsx/components/Link.d.cts.map +1 -1
- package/dist/jsx/components/Link.d.mts +3 -1
- package/dist/jsx/components/Link.d.mts.map +1 -1
- package/dist/jsx/components/Link.mjs.map +1 -1
- package/dist/jsx/index.cjs +2 -1
- package/dist/jsx/index.cjs.map +1 -1
- package/dist/jsx/index.d.cts +1 -1
- package/dist/jsx/index.d.cts.map +1 -1
- package/dist/jsx/index.d.mts +1 -1
- package/dist/jsx/index.d.mts.map +1 -1
- package/dist/jsx/index.mjs +1 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/validation.cjs +33 -2
- package/dist/jsx/validation.cjs.map +1 -1
- package/dist/jsx/validation.d.cts +9 -0
- package/dist/jsx/validation.d.cts.map +1 -1
- package/dist/jsx/validation.d.mts +9 -0
- package/dist/jsx/validation.d.mts.map +1 -1
- package/dist/jsx/validation.mjs +32 -1
- package/dist/jsx/validation.mjs.map +1 -1
- package/dist/types/methods/notify.cjs.map +1 -1
- package/dist/types/methods/notify.d.cts +21 -2
- package/dist/types/methods/notify.d.cts.map +1 -1
- package/dist/types/methods/notify.d.mts +21 -2
- package/dist/types/methods/notify.d.mts.map +1 -1
- package/dist/types/methods/notify.mjs.map +1 -1
- package/package.json +28 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-wrappers.d.mts","sourceRoot":"","sources":["../src/error-wrappers.ts"],"names":[],"mappings":";AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa
|
|
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"}
|
package/dist/errors.cjs
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.SnapError = void 0;
|
|
16
4
|
const internals_1 = require("./internals/index.cjs");
|
|
@@ -19,6 +7,10 @@ const internals_1 = require("./internals/index.cjs");
|
|
|
19
7
|
* crash.
|
|
20
8
|
*/
|
|
21
9
|
class SnapError extends Error {
|
|
10
|
+
#code;
|
|
11
|
+
#message;
|
|
12
|
+
#data;
|
|
13
|
+
#stack;
|
|
22
14
|
/**
|
|
23
15
|
* Create a new `SnapError`.
|
|
24
16
|
*
|
|
@@ -34,17 +26,13 @@ class SnapError extends Error {
|
|
|
34
26
|
constructor(error, data = {}) {
|
|
35
27
|
const message = (0, internals_1.getErrorMessage)(error);
|
|
36
28
|
super(message);
|
|
37
|
-
|
|
38
|
-
|
|
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");
|
|
29
|
+
this.#message = message;
|
|
30
|
+
this.#code = (0, internals_1.getErrorCode)(error);
|
|
43
31
|
const mergedData = { ...(0, internals_1.getErrorData)(error), ...data };
|
|
44
32
|
if (Object.keys(mergedData).length > 0) {
|
|
45
|
-
|
|
33
|
+
this.#data = mergedData;
|
|
46
34
|
}
|
|
47
|
-
|
|
35
|
+
this.#stack = super.stack;
|
|
48
36
|
}
|
|
49
37
|
/**
|
|
50
38
|
* The error name.
|
|
@@ -60,7 +48,7 @@ class SnapError extends Error {
|
|
|
60
48
|
* @returns The error code.
|
|
61
49
|
*/
|
|
62
50
|
get code() {
|
|
63
|
-
return
|
|
51
|
+
return this.#code;
|
|
64
52
|
}
|
|
65
53
|
/**
|
|
66
54
|
* The error message.
|
|
@@ -70,7 +58,7 @@ class SnapError extends Error {
|
|
|
70
58
|
// This line is covered, but Jest doesn't pick it up for some reason.
|
|
71
59
|
/* istanbul ignore next */
|
|
72
60
|
get message() {
|
|
73
|
-
return
|
|
61
|
+
return this.#message;
|
|
74
62
|
}
|
|
75
63
|
/**
|
|
76
64
|
* Additional data for the error.
|
|
@@ -78,7 +66,7 @@ class SnapError extends Error {
|
|
|
78
66
|
* @returns Additional data for the error.
|
|
79
67
|
*/
|
|
80
68
|
get data() {
|
|
81
|
-
return
|
|
69
|
+
return this.#data;
|
|
82
70
|
}
|
|
83
71
|
/**
|
|
84
72
|
* The error stack.
|
|
@@ -88,7 +76,7 @@ class SnapError extends Error {
|
|
|
88
76
|
// This line is covered, but Jest doesn't pick it up for some reason.
|
|
89
77
|
/* istanbul ignore next */
|
|
90
78
|
get stack() {
|
|
91
|
-
return
|
|
79
|
+
return this.#stack;
|
|
92
80
|
}
|
|
93
81
|
/**
|
|
94
82
|
* Convert the error to a JSON object.
|
|
@@ -120,5 +108,4 @@ class SnapError extends Error {
|
|
|
120
108
|
}
|
|
121
109
|
}
|
|
122
110
|
exports.SnapError = SnapError;
|
|
123
|
-
_SnapError_code = new WeakMap(), _SnapError_message = new WeakMap(), _SnapError_data = new WeakMap(), _SnapError_stack = new WeakMap();
|
|
124
111
|
//# sourceMappingURL=errors.cjs.map
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAEA,qDAMqB;AAErB;;;GAGG;AACH,MAAa,SAAU,SAAQ,KAAK;IACzB,KAAK,CAAS;IAEd,QAAQ,CAAS;IAEjB,KAAK,CAAwB;IAE7B,MAAM,CAAU;IAEzB;;;;;;;;;;;OAWG;IACH,YACE,KAAoC,EACpC,OAA6B,EAAE;QAE/B,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,KAAK,CAAC,CAAC;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAA,wBAAY,EAAC,KAAK,CAAC,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,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC;QAC1B,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,qEAAqE;IACrE,0BAA0B;IAC1B,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,qEAAqE;IACrE,0BAA0B;IAC1B,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,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"]}
|
package/dist/errors.mjs
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
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
1
|
import { getErrorCode, getErrorData, getErrorMessage, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE } from "./internals/index.mjs";
|
|
14
2
|
/**
|
|
15
3
|
* A generic error which can be thrown by a Snap, without it causing the Snap to
|
|
16
4
|
* crash.
|
|
17
5
|
*/
|
|
18
6
|
export class SnapError extends Error {
|
|
7
|
+
#code;
|
|
8
|
+
#message;
|
|
9
|
+
#data;
|
|
10
|
+
#stack;
|
|
19
11
|
/**
|
|
20
12
|
* Create a new `SnapError`.
|
|
21
13
|
*
|
|
@@ -31,17 +23,13 @@ export class SnapError extends Error {
|
|
|
31
23
|
constructor(error, data = {}) {
|
|
32
24
|
const message = getErrorMessage(error);
|
|
33
25
|
super(message);
|
|
34
|
-
|
|
35
|
-
|
|
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");
|
|
26
|
+
this.#message = message;
|
|
27
|
+
this.#code = getErrorCode(error);
|
|
40
28
|
const mergedData = { ...getErrorData(error), ...data };
|
|
41
29
|
if (Object.keys(mergedData).length > 0) {
|
|
42
|
-
|
|
30
|
+
this.#data = mergedData;
|
|
43
31
|
}
|
|
44
|
-
|
|
32
|
+
this.#stack = super.stack;
|
|
45
33
|
}
|
|
46
34
|
/**
|
|
47
35
|
* The error name.
|
|
@@ -57,7 +45,7 @@ export class SnapError extends Error {
|
|
|
57
45
|
* @returns The error code.
|
|
58
46
|
*/
|
|
59
47
|
get code() {
|
|
60
|
-
return
|
|
48
|
+
return this.#code;
|
|
61
49
|
}
|
|
62
50
|
/**
|
|
63
51
|
* The error message.
|
|
@@ -67,7 +55,7 @@ export class SnapError extends Error {
|
|
|
67
55
|
// This line is covered, but Jest doesn't pick it up for some reason.
|
|
68
56
|
/* istanbul ignore next */
|
|
69
57
|
get message() {
|
|
70
|
-
return
|
|
58
|
+
return this.#message;
|
|
71
59
|
}
|
|
72
60
|
/**
|
|
73
61
|
* Additional data for the error.
|
|
@@ -75,7 +63,7 @@ export class SnapError extends Error {
|
|
|
75
63
|
* @returns Additional data for the error.
|
|
76
64
|
*/
|
|
77
65
|
get data() {
|
|
78
|
-
return
|
|
66
|
+
return this.#data;
|
|
79
67
|
}
|
|
80
68
|
/**
|
|
81
69
|
* The error stack.
|
|
@@ -85,7 +73,7 @@ export class SnapError extends Error {
|
|
|
85
73
|
// This line is covered, but Jest doesn't pick it up for some reason.
|
|
86
74
|
/* istanbul ignore next */
|
|
87
75
|
get stack() {
|
|
88
|
-
return
|
|
76
|
+
return this.#stack;
|
|
89
77
|
}
|
|
90
78
|
/**
|
|
91
79
|
* Convert the error to a JSON object.
|
|
@@ -116,5 +104,4 @@ export class SnapError extends Error {
|
|
|
116
104
|
return this.toJSON();
|
|
117
105
|
}
|
|
118
106
|
}
|
|
119
|
-
_SnapError_code = new WeakMap(), _SnapError_message = new WeakMap(), _SnapError_data = new WeakMap(), _SnapError_stack = new WeakMap();
|
|
120
107
|
//# sourceMappingURL=errors.mjs.map
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
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;IACzB,KAAK,CAAS;IAEd,QAAQ,CAAS;IAEjB,KAAK,CAAwB;IAE7B,MAAM,CAAU;IAEzB;;;;;;;;;;;OAWG;IACH,YACE,KAAoC,EACpC,OAA6B,EAAE;QAE/B,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,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,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC;QAC1B,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,qEAAqE;IACrE,0BAA0B;IAC1B,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,qEAAqE;IACrE,0BAA0B;IAC1B,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,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"]}
|
|
@@ -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 "__#182025@#code": number;
|
|
19
|
+
readonly "__#182025@#message": string;
|
|
20
|
+
readonly "__#182025@#data"?: Record<string, Json> | undefined;
|
|
21
|
+
readonly "__#182025@#stack"?: string | undefined;
|
|
22
22
|
readonly name: string;
|
|
23
23
|
readonly code: number;
|
|
24
24
|
readonly message: string;
|
|
@@ -26,12 +26,13 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
26
26
|
readonly stack: string | undefined;
|
|
27
27
|
toJSON(): import("../errors.cjs").SerializedSnapError;
|
|
28
28
|
serialize(): import("../errors.cjs").SerializedSnapError;
|
|
29
|
+
cause?: unknown;
|
|
29
30
|
};
|
|
30
31
|
new (data?: Record<string, Json>): {
|
|
31
|
-
readonly "__#
|
|
32
|
-
readonly "__#
|
|
33
|
-
readonly "__#
|
|
34
|
-
readonly "__#
|
|
32
|
+
readonly "__#182025@#code": number;
|
|
33
|
+
readonly "__#182025@#message": string;
|
|
34
|
+
readonly "__#182025@#data"?: Record<string, Json> | undefined;
|
|
35
|
+
readonly "__#182025@#stack"?: string | undefined;
|
|
35
36
|
readonly name: string;
|
|
36
37
|
readonly code: number;
|
|
37
38
|
readonly message: string;
|
|
@@ -39,12 +40,13 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
39
40
|
readonly stack: string | undefined;
|
|
40
41
|
toJSON(): import("../errors.cjs").SerializedSnapError;
|
|
41
42
|
serialize(): import("../errors.cjs").SerializedSnapError;
|
|
43
|
+
cause?: unknown;
|
|
42
44
|
};
|
|
43
45
|
new (message?: string | Record<string, Json>, data?: Record<string, Json>): {
|
|
44
|
-
readonly "__#
|
|
45
|
-
readonly "__#
|
|
46
|
-
readonly "__#
|
|
47
|
-
readonly "__#
|
|
46
|
+
readonly "__#182025@#code": number;
|
|
47
|
+
readonly "__#182025@#message": string;
|
|
48
|
+
readonly "__#182025@#data"?: Record<string, Json> | undefined;
|
|
49
|
+
readonly "__#182025@#stack"?: string | undefined;
|
|
48
50
|
readonly name: string;
|
|
49
51
|
readonly code: number;
|
|
50
52
|
readonly message: string;
|
|
@@ -52,6 +54,7 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
52
54
|
readonly stack: string | undefined;
|
|
53
55
|
toJSON(): import("../errors.cjs").SerializedSnapError;
|
|
54
56
|
serialize(): import("../errors.cjs").SerializedSnapError;
|
|
57
|
+
cause?: unknown;
|
|
55
58
|
};
|
|
56
59
|
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
57
60
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-wrappers.d.cts","sourceRoot":"","sources":["../../src/internals/error-wrappers.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,6BAA6B;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,oBAAoB;mBAO9B,MAAM
|
|
1
|
+
{"version":3,"file":"error-wrappers.d.cts","sourceRoot":"","sources":["../../src/internals/error-wrappers.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,6BAA6B;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,oBAAoB;mBAO9B,MAAM;;;;;;;;;;;;;;gBAOT,OAAO,MAAM,EAAE,IAAI,CAAC;;;;;;;;;;;;;;mBAS3B,MAAM,GAAG,OAAO,MAAM,EAAE,IAAI,CAAC,SAChC,OAAO,MAAM,EAAE,IAAI,CAAC;;;;;;;;;;;;;;;;;EAgChC"}
|
|
@@ -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 "__#91014@#code": number;
|
|
19
|
+
readonly "__#91014@#message": string;
|
|
20
|
+
readonly "__#91014@#data"?: Record<string, Json> | undefined;
|
|
21
|
+
readonly "__#91014@#stack"?: string | undefined;
|
|
22
22
|
readonly name: string;
|
|
23
23
|
readonly code: number;
|
|
24
24
|
readonly message: string;
|
|
@@ -26,12 +26,13 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
26
26
|
readonly stack: string | undefined;
|
|
27
27
|
toJSON(): import("../errors.mjs").SerializedSnapError;
|
|
28
28
|
serialize(): import("../errors.mjs").SerializedSnapError;
|
|
29
|
+
cause?: unknown;
|
|
29
30
|
};
|
|
30
31
|
new (data?: Record<string, Json>): {
|
|
31
|
-
readonly "__#
|
|
32
|
-
readonly "__#
|
|
33
|
-
readonly "__#
|
|
34
|
-
readonly "__#
|
|
32
|
+
readonly "__#91014@#code": number;
|
|
33
|
+
readonly "__#91014@#message": string;
|
|
34
|
+
readonly "__#91014@#data"?: Record<string, Json> | undefined;
|
|
35
|
+
readonly "__#91014@#stack"?: string | undefined;
|
|
35
36
|
readonly name: string;
|
|
36
37
|
readonly code: number;
|
|
37
38
|
readonly message: string;
|
|
@@ -39,12 +40,13 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
39
40
|
readonly stack: string | undefined;
|
|
40
41
|
toJSON(): import("../errors.mjs").SerializedSnapError;
|
|
41
42
|
serialize(): import("../errors.mjs").SerializedSnapError;
|
|
43
|
+
cause?: unknown;
|
|
42
44
|
};
|
|
43
45
|
new (message?: string | Record<string, Json>, data?: Record<string, Json>): {
|
|
44
|
-
readonly "__#
|
|
45
|
-
readonly "__#
|
|
46
|
-
readonly "__#
|
|
47
|
-
readonly "__#
|
|
46
|
+
readonly "__#91014@#code": number;
|
|
47
|
+
readonly "__#91014@#message": string;
|
|
48
|
+
readonly "__#91014@#data"?: Record<string, Json> | undefined;
|
|
49
|
+
readonly "__#91014@#stack"?: string | undefined;
|
|
48
50
|
readonly name: string;
|
|
49
51
|
readonly code: number;
|
|
50
52
|
readonly message: string;
|
|
@@ -52,6 +54,7 @@ export declare function createSnapError(fn: JsonRpcErrorFunction): {
|
|
|
52
54
|
readonly stack: string | undefined;
|
|
53
55
|
toJSON(): import("../errors.mjs").SerializedSnapError;
|
|
54
56
|
serialize(): import("../errors.mjs").SerializedSnapError;
|
|
57
|
+
cause?: unknown;
|
|
55
58
|
};
|
|
56
59
|
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
57
60
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-wrappers.d.mts","sourceRoot":"","sources":["../../src/internals/error-wrappers.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,6BAA6B;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,oBAAoB;mBAO9B,MAAM
|
|
1
|
+
{"version":3,"file":"error-wrappers.d.mts","sourceRoot":"","sources":["../../src/internals/error-wrappers.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,6BAA6B;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,oBAAoB;mBAO9B,MAAM;;;;;;;;;;;;;;gBAOT,OAAO,MAAM,EAAE,IAAI,CAAC;;;;;;;;;;;;;;mBAS3B,MAAM,GAAG,OAAO,MAAM,EAAE,IAAI,CAAC,SAChC,OAAO,MAAM,EAAE,IAAI,CAAC;;;;;;;;;;;;;;;;;EAgChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.cjs","sourceRoot":"","sources":["../../../src/jsx/components/Link.ts"],"names":[],"mappings":";;;AACA,gDAAmD;
|
|
1
|
+
{"version":3,"file":"Link.cjs","sourceRoot":"","sources":["../../../src/jsx/components/Link.ts"],"names":[],"mappings":";;;AACA,gDAAmD;AAwBnD,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB;;;;;;;;;;GAUG;AACU,QAAA,IAAI,GAAG,IAAA,+BAAmB,EAAyB,IAAI,CAAC,CAAC","sourcesContent":["import type { SnapsChildren } from '../component';\nimport { createSnapComponent } from '../component';\nimport type { StandardFormattingElement } from './formatting';\nimport { type IconElement } from './Icon';\nimport { type ImageElement } from './Image';\n\n/**\n * The children of the {@link Link} component.\n */\nexport type LinkChildren = SnapsChildren<\n string | StandardFormattingElement | IconElement | ImageElement\n>;\n\n/**\n * The props of the {@link Link} component.\n *\n * @property children - The text to display in the link.\n * @property href - The URL to link to. This must be an `https` or `mailto` URL.\n * `http` is not allowed.\n */\nexport type LinkProps = {\n children: LinkChildren;\n href: string;\n};\n\nconst TYPE = 'Link';\n\n/**\n * A link component, which is used to display a hyperlink.\n *\n * @param props - The props of the component.\n * @param props.children - The text to display in the link.\n * @param props.href - The URL to link to. This must be an `https` or `mailto`\n * URL. `http` is not allowed.\n * @returns A link element.\n * @example\n * <Link href=\"https://example.com\">Click here</Link>\n */\nexport const Link = createSnapComponent<LinkProps, typeof TYPE>(TYPE);\n\n/**\n * A link element.\n *\n * @see Link\n */\nexport type LinkElement = ReturnType<typeof Link>;\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { SnapsChildren } from "../component.cjs";
|
|
2
2
|
import type { StandardFormattingElement } from "./formatting/index.cjs";
|
|
3
|
+
import { type IconElement } from "./Icon.cjs";
|
|
4
|
+
import { type ImageElement } from "./Image.cjs";
|
|
3
5
|
/**
|
|
4
6
|
* The children of the {@link Link} component.
|
|
5
7
|
*/
|
|
6
|
-
export type LinkChildren = SnapsChildren<string | StandardFormattingElement>;
|
|
8
|
+
export type LinkChildren = SnapsChildren<string | StandardFormattingElement | IconElement | ImageElement>;
|
|
7
9
|
/**
|
|
8
10
|
* The props of the {@link Link} component.
|
|
9
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.cts","sourceRoot":"","sources":["../../../src/jsx/components/Link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAqB;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,+BAAqB;
|
|
1
|
+
{"version":3,"file":"Link.d.cts","sourceRoot":"","sources":["../../../src/jsx/components/Link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAqB;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,+BAAqB;AAC9D,OAAO,EAAE,KAAK,WAAW,EAAE,mBAAe;AAC1C,OAAO,EAAE,KAAK,YAAY,EAAE,oBAAgB;AAE5C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,CACtC,MAAM,GAAG,yBAAyB,GAAG,WAAW,GAAG,YAAY,CAChE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAIF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,yDAAoD,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { SnapsChildren } from "../component.mjs";
|
|
2
2
|
import type { StandardFormattingElement } from "./formatting/index.mjs";
|
|
3
|
+
import { type IconElement } from "./Icon.mjs";
|
|
4
|
+
import { type ImageElement } from "./Image.mjs";
|
|
3
5
|
/**
|
|
4
6
|
* The children of the {@link Link} component.
|
|
5
7
|
*/
|
|
6
|
-
export type LinkChildren = SnapsChildren<string | StandardFormattingElement>;
|
|
8
|
+
export type LinkChildren = SnapsChildren<string | StandardFormattingElement | IconElement | ImageElement>;
|
|
7
9
|
/**
|
|
8
10
|
* The props of the {@link Link} component.
|
|
9
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.mts","sourceRoot":"","sources":["../../../src/jsx/components/Link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAqB;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,+BAAqB;
|
|
1
|
+
{"version":3,"file":"Link.d.mts","sourceRoot":"","sources":["../../../src/jsx/components/Link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAqB;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,+BAAqB;AAC9D,OAAO,EAAE,KAAK,WAAW,EAAE,mBAAe;AAC1C,OAAO,EAAE,KAAK,YAAY,EAAE,oBAAgB;AAE5C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,CACtC,MAAM,GAAG,yBAAyB,GAAG,WAAW,GAAG,YAAY,CAChE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAIF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,yDAAoD,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.mjs","sourceRoot":"","sources":["../../../src/jsx/components/Link.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;
|
|
1
|
+
{"version":3,"file":"Link.mjs","sourceRoot":"","sources":["../../../src/jsx/components/Link.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AAwBnD,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,mBAAmB,CAAyB,IAAI,CAAC,CAAC","sourcesContent":["import type { SnapsChildren } from '../component';\nimport { createSnapComponent } from '../component';\nimport type { StandardFormattingElement } from './formatting';\nimport { type IconElement } from './Icon';\nimport { type ImageElement } from './Image';\n\n/**\n * The children of the {@link Link} component.\n */\nexport type LinkChildren = SnapsChildren<\n string | StandardFormattingElement | IconElement | ImageElement\n>;\n\n/**\n * The props of the {@link Link} component.\n *\n * @property children - The text to display in the link.\n * @property href - The URL to link to. This must be an `https` or `mailto` URL.\n * `http` is not allowed.\n */\nexport type LinkProps = {\n children: LinkChildren;\n href: string;\n};\n\nconst TYPE = 'Link';\n\n/**\n * A link component, which is used to display a hyperlink.\n *\n * @param props - The props of the component.\n * @param props.children - The text to display in the link.\n * @param props.href - The URL to link to. This must be an `https` or `mailto`\n * URL. `http` is not allowed.\n * @returns A link element.\n * @example\n * <Link href=\"https://example.com\">Click here</Link>\n */\nexport const Link = createSnapComponent<LinkProps, typeof TYPE>(TYPE);\n\n/**\n * A link element.\n *\n * @see Link\n */\nexport type LinkElement = ReturnType<typeof Link>;\n"]}
|
package/dist/jsx/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.FieldChildUnionStruct = exports.FormChildStruct = exports.BoxChildStruct = exports.assertJSXElement = exports.isJSXElementUnsafe = exports.isJSXElement = exports.RootJSXElementStruct = exports.JSXElementStruct = void 0;
|
|
17
|
+
exports.NotificationComponentsStruct = exports.FieldChildUnionStruct = exports.FormChildStruct = exports.BoxChildStruct = exports.assertJSXElement = exports.isJSXElementUnsafe = exports.isJSXElement = exports.RootJSXElementStruct = exports.JSXElementStruct = void 0;
|
|
18
18
|
__exportStar(require("./component.cjs"), exports);
|
|
19
19
|
__exportStar(require("./components/index.cjs"), exports);
|
|
20
20
|
__exportStar(require("./jsx-runtime.cjs"), exports);
|
|
@@ -28,4 +28,5 @@ Object.defineProperty(exports, "assertJSXElement", { enumerable: true, get: func
|
|
|
28
28
|
Object.defineProperty(exports, "BoxChildStruct", { enumerable: true, get: function () { return validation_1.BoxChildStruct; } });
|
|
29
29
|
Object.defineProperty(exports, "FormChildStruct", { enumerable: true, get: function () { return validation_1.FormChildStruct; } });
|
|
30
30
|
Object.defineProperty(exports, "FieldChildUnionStruct", { enumerable: true, get: function () { return validation_1.FieldChildUnionStruct; } });
|
|
31
|
+
Object.defineProperty(exports, "NotificationComponentsStruct", { enumerable: true, get: function () { return validation_1.NotificationComponentsStruct; } });
|
|
31
32
|
//# sourceMappingURL=index.cjs.map
|
package/dist/jsx/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA4B;AAC5B,yDAA6B;AAC7B,oDAA8B;AAC9B,wDAAkC;AAClC,+
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA4B;AAC5B,yDAA6B;AAC7B,oDAA8B;AAC9B,wDAAkC;AAClC,+CAUsB;AATpB,8GAAA,gBAAgB,OAAA;AAChB,kHAAA,oBAAoB,OAAA;AACpB,0GAAA,YAAY,OAAA;AACZ,gHAAA,kBAAkB,OAAA;AAClB,8GAAA,gBAAgB,OAAA;AAChB,4GAAA,cAAc,OAAA;AACd,6GAAA,eAAe,OAAA;AACf,mHAAA,qBAAqB,OAAA;AACrB,0HAAA,4BAA4B,OAAA","sourcesContent":["export * from './component';\nexport * from './components';\nexport * from './jsx-runtime';\nexport * from './jsx-dev-runtime';\nexport {\n JSXElementStruct,\n RootJSXElementStruct,\n isJSXElement,\n isJSXElementUnsafe,\n assertJSXElement,\n BoxChildStruct,\n FormChildStruct,\n FieldChildUnionStruct,\n NotificationComponentsStruct,\n} from './validation';\n"]}
|
package/dist/jsx/index.d.cts
CHANGED
|
@@ -2,5 +2,5 @@ export * from "./component.cjs";
|
|
|
2
2
|
export * from "./components/index.cjs";
|
|
3
3
|
export * from "./jsx-runtime.cjs";
|
|
4
4
|
export * from "./jsx-dev-runtime.cjs";
|
|
5
|
-
export { JSXElementStruct, RootJSXElementStruct, isJSXElement, isJSXElementUnsafe, assertJSXElement, BoxChildStruct, FormChildStruct, FieldChildUnionStruct, } from "./validation.cjs";
|
|
5
|
+
export { JSXElementStruct, RootJSXElementStruct, isJSXElement, isJSXElementUnsafe, assertJSXElement, BoxChildStruct, FormChildStruct, FieldChildUnionStruct, NotificationComponentsStruct, } from "./validation.cjs";
|
|
6
6
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/jsx/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,uCAA6B;AAC7B,kCAA8B;AAC9B,sCAAkC;AAClC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,uCAA6B;AAC7B,kCAA8B;AAC9B,sCAAkC;AAClC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,4BAA4B,GAC7B,yBAAqB"}
|
package/dist/jsx/index.d.mts
CHANGED
|
@@ -2,5 +2,5 @@ export * from "./component.mjs";
|
|
|
2
2
|
export * from "./components/index.mjs";
|
|
3
3
|
export * from "./jsx-runtime.mjs";
|
|
4
4
|
export * from "./jsx-dev-runtime.mjs";
|
|
5
|
-
export { JSXElementStruct, RootJSXElementStruct, isJSXElement, isJSXElementUnsafe, assertJSXElement, BoxChildStruct, FormChildStruct, FieldChildUnionStruct, } from "./validation.mjs";
|
|
5
|
+
export { JSXElementStruct, RootJSXElementStruct, isJSXElement, isJSXElementUnsafe, assertJSXElement, BoxChildStruct, FormChildStruct, FieldChildUnionStruct, NotificationComponentsStruct, } from "./validation.mjs";
|
|
6
6
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/jsx/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,uCAA6B;AAC7B,kCAA8B;AAC9B,sCAAkC;AAClC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,uCAA6B;AAC7B,kCAA8B;AAC9B,sCAAkC;AAClC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,4BAA4B,GAC7B,yBAAqB"}
|
package/dist/jsx/index.mjs
CHANGED
|
@@ -2,5 +2,5 @@ export * from "./component.mjs";
|
|
|
2
2
|
export * from "./components/index.mjs";
|
|
3
3
|
export * from "./jsx-runtime.mjs";
|
|
4
4
|
export * from "./jsx-dev-runtime.mjs";
|
|
5
|
-
export { JSXElementStruct, RootJSXElementStruct, isJSXElement, isJSXElementUnsafe, assertJSXElement, BoxChildStruct, FormChildStruct, FieldChildUnionStruct } from "./validation.mjs";
|
|
5
|
+
export { JSXElementStruct, RootJSXElementStruct, isJSXElement, isJSXElementUnsafe, assertJSXElement, BoxChildStruct, FormChildStruct, FieldChildUnionStruct, NotificationComponentsStruct } from "./validation.mjs";
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
package/dist/jsx/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,uCAA6B;AAC7B,kCAA8B;AAC9B,sCAAkC;AAClC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,uCAA6B;AAC7B,kCAA8B;AAC9B,sCAAkC;AAClC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,4BAA4B,EAC7B,yBAAqB","sourcesContent":["export * from './component';\nexport * from './components';\nexport * from './jsx-runtime';\nexport * from './jsx-dev-runtime';\nexport {\n JSXElementStruct,\n RootJSXElementStruct,\n isJSXElement,\n isJSXElementUnsafe,\n assertJSXElement,\n BoxChildStruct,\n FormChildStruct,\n FieldChildUnionStruct,\n NotificationComponentsStruct,\n} from './validation';\n"]}
|
package/dist/jsx/validation.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertJSXElement = exports.isJSXElementUnsafe = exports.isJSXElement = exports.JSXElementStruct = exports.RootJSXElementStruct = exports.ContainerStruct = exports.BoxChildStruct = exports.SpinnerStruct = exports.RowStruct = exports.TooltipStruct = exports.TooltipContentStruct = exports.TooltipChildStruct = exports.TextStruct = exports.LinkStruct = exports.HeadingStruct = exports.ValueStruct = exports.DividerStruct = exports.CopyableStruct = exports.FooterStruct = exports.FooterChildStruct = exports.SectionStruct = exports.BoxStruct = exports.BoxChildrenStruct = exports.AddressStruct = exports.FormattingStruct = exports.ItalicStruct = exports.BoldStruct = exports.FormStruct = exports.FormChildStruct = exports.FieldStruct = exports.FieldChildUnionStruct = exports.FileInputStruct = exports.RadioGroupStruct = exports.RadioStruct = exports.SelectorStruct = exports.SelectorOptionStruct = exports.CardStruct = exports.DropdownStruct = exports.OptionStruct = exports.InputStruct = exports.CheckboxStruct = exports.ButtonStruct = exports.IconStruct = exports.ImageStruct = exports.ElementStruct = exports.StringElementStruct = exports.KeyStruct = void 0;
|
|
3
|
+
exports.assertJSXElement = exports.isJSXElementUnsafe = exports.isJSXElement = exports.JSXElementStruct = exports.RootJSXElementStruct = exports.ContainerStruct = exports.NotificationComponentsStruct = exports.BoxChildStruct = exports.SpinnerStruct = exports.RowStruct = exports.TooltipStruct = exports.TooltipContentStruct = exports.TooltipChildStruct = exports.TextStruct = exports.LinkStruct = exports.HeadingStruct = exports.ValueStruct = exports.DividerStruct = exports.CopyableStruct = exports.FooterStruct = exports.FooterChildStruct = exports.NotificationStruct = exports.NotificationChildrenStruct = exports.SectionStruct = exports.BoxStruct = exports.BoxChildrenStruct = exports.AddressStruct = exports.FormattingStruct = exports.ItalicStruct = exports.BoldStruct = exports.FormStruct = exports.FormChildStruct = exports.FieldStruct = exports.FieldChildUnionStruct = exports.FileInputStruct = exports.RadioGroupStruct = exports.RadioStruct = exports.SelectorStruct = exports.SelectorOptionStruct = exports.CardStruct = exports.DropdownStruct = exports.OptionStruct = exports.InputStruct = exports.CheckboxStruct = exports.ButtonStruct = exports.IconStruct = exports.ImageStruct = exports.ElementStruct = exports.StringElementStruct = exports.KeyStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
6
|
const internals_1 = require("../internals/index.cjs");
|
|
@@ -346,6 +346,23 @@ exports.SectionStruct = element('Section', {
|
|
|
346
346
|
(0, internals_1.literal)('space-around'),
|
|
347
347
|
])),
|
|
348
348
|
});
|
|
349
|
+
exports.NotificationChildrenStruct = children(
|
|
350
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
351
|
+
[(0, superstruct_1.lazy)(() => exports.NotificationComponentsStruct)]);
|
|
352
|
+
/**
|
|
353
|
+
* A struct for the {@link BoxElement} type but with a limited subset of children.
|
|
354
|
+
*/
|
|
355
|
+
exports.NotificationStruct = element('Box', {
|
|
356
|
+
children: exports.NotificationChildrenStruct,
|
|
357
|
+
direction: (0, superstruct_1.optional)((0, internals_1.nullUnion)([(0, internals_1.literal)('horizontal'), (0, internals_1.literal)('vertical')])),
|
|
358
|
+
alignment: (0, superstruct_1.optional)((0, internals_1.nullUnion)([
|
|
359
|
+
(0, internals_1.literal)('start'),
|
|
360
|
+
(0, internals_1.literal)('center'),
|
|
361
|
+
(0, internals_1.literal)('end'),
|
|
362
|
+
(0, internals_1.literal)('space-between'),
|
|
363
|
+
(0, internals_1.literal)('space-around'),
|
|
364
|
+
])),
|
|
365
|
+
});
|
|
349
366
|
/**
|
|
350
367
|
* A subset of JSX elements that are allowed as children of the Footer component.
|
|
351
368
|
* This set should include a single button or a tuple of two buttons.
|
|
@@ -391,7 +408,7 @@ exports.HeadingStruct = element('Heading', {
|
|
|
391
408
|
*/
|
|
392
409
|
exports.LinkStruct = element('Link', {
|
|
393
410
|
href: (0, superstruct_1.string)(),
|
|
394
|
-
children: children([exports.FormattingStruct, (0, superstruct_1.string)()]),
|
|
411
|
+
children: children([exports.FormattingStruct, (0, superstruct_1.string)(), exports.IconStruct, exports.ImageStruct]),
|
|
395
412
|
});
|
|
396
413
|
/**
|
|
397
414
|
* A struct for the {@link TextElement} type.
|
|
@@ -499,6 +516,20 @@ exports.BoxChildStruct = (0, internals_1.typedUnion)([
|
|
|
499
516
|
exports.SelectorStruct,
|
|
500
517
|
exports.SectionStruct,
|
|
501
518
|
]);
|
|
519
|
+
exports.NotificationComponentsStruct = (0, internals_1.typedUnion)([
|
|
520
|
+
exports.CopyableStruct,
|
|
521
|
+
exports.NotificationStruct,
|
|
522
|
+
exports.BoldStruct,
|
|
523
|
+
exports.ItalicStruct,
|
|
524
|
+
exports.AddressStruct,
|
|
525
|
+
exports.DividerStruct,
|
|
526
|
+
exports.RowStruct,
|
|
527
|
+
exports.TextStruct,
|
|
528
|
+
exports.TooltipStruct,
|
|
529
|
+
exports.IconStruct,
|
|
530
|
+
exports.ImageStruct,
|
|
531
|
+
exports.LinkStruct,
|
|
532
|
+
]);
|
|
502
533
|
/**
|
|
503
534
|
* A struct for the {@link ContainerElement} type.
|
|
504
535
|
*/
|