@metamask/snaps-sdk 5.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -1
- package/dist/index.js +226 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +261 -89
- package/dist/index.mjs.map +1 -1
- package/dist/jsx/index.js +237 -89
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +243 -94
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js +167 -51
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.mjs +173 -56
- package/dist/jsx/jsx-dev-runtime.mjs.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/internals/jsx.d.ts +2 -3
- package/dist/types/internals/structs.d.ts +12 -3
- package/dist/types/internals/svg.d.ts +1 -1
- package/dist/types/jsx/component.d.ts +6 -9
- package/dist/types/jsx/components/Box.d.ts +4 -4
- package/dist/types/jsx/components/Card.d.ts +36 -0
- package/dist/types/jsx/components/Container.d.ts +34 -0
- package/dist/types/jsx/components/Footer.d.ts +28 -0
- package/dist/types/jsx/components/Link.d.ts +2 -2
- package/dist/types/jsx/components/Row.d.ts +1 -1
- package/dist/types/jsx/components/Text.d.ts +7 -2
- package/dist/types/jsx/components/Tooltip.d.ts +38 -0
- package/dist/types/jsx/components/form/Checkbox.d.ts +35 -0
- package/dist/types/jsx/components/form/Dropdown.d.ts +4 -5
- package/dist/types/jsx/components/form/Field.d.ts +7 -1
- package/dist/types/jsx/components/form/FileInput.d.ts +47 -0
- package/dist/types/jsx/components/form/Form.d.ts +4 -7
- package/dist/types/jsx/components/form/Input.d.ts +1 -2
- package/dist/types/jsx/components/form/index.d.ts +5 -1
- package/dist/types/jsx/components/formatting/Bold.d.ts +2 -2
- package/dist/types/jsx/components/formatting/Italic.d.ts +2 -2
- package/dist/types/jsx/components/index.d.ts +9 -1
- package/dist/types/jsx/index.d.ts +1 -1
- package/dist/types/jsx/validation.d.ts +67 -40
- package/dist/types/types/handlers/user-input.d.ts +140 -25
- package/dist/types/types/interface.d.ts +32 -24
- package/dist/types/types/methods/dialog.d.ts +8 -2
- package/dist/types/types/methods/index.d.ts +1 -0
- package/dist/types/types/methods/methods.d.ts +2 -0
- package/dist/types/types/methods/resolve-interface.d.ts +15 -0
- package/dist/types/ui/builder.d.ts +1 -1
- package/dist/types/ui/components/address.d.ts +4 -4
- package/dist/types/ui/components/button.d.ts +7 -7
- package/dist/types/ui/components/copyable.d.ts +5 -5
- package/dist/types/ui/components/divider.d.ts +3 -3
- package/dist/types/ui/components/form.d.ts +7 -7
- package/dist/types/ui/components/heading.d.ts +4 -4
- package/dist/types/ui/components/image.d.ts +4 -4
- package/dist/types/ui/components/input.d.ts +9 -9
- package/dist/types/ui/components/panel.d.ts +1 -1
- package/dist/types/ui/components/row.d.ts +6 -6
- package/dist/types/ui/components/spinner.d.ts +3 -3
- package/dist/types/ui/components/text.d.ts +5 -5
- package/dist/types/ui/nodes.d.ts +6 -6
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [6.1.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Add non-restricted RPC method `snap_resolveInterface` ([#2509](https://github.com/metamask/snaps/pull/2509))
|
|
12
|
+
- This method allows a Snap to resolve a given user interface bound to a `snap_dialog` with a custom value.
|
|
13
|
+
- Add new types `ResolveInterfaceParams`, `ResolveInterfaceResult`.
|
|
14
|
+
- Add `Card` component ([#2480](https://github.com/metamask/snaps/pull/2480))
|
|
15
|
+
- Add `BoxChildStruct`, `FormChildStruct`, `FieldChildUnionStruct` ([#2409](https://github.com/metamask/snaps/pull/2409))
|
|
16
|
+
- Add `Container` and `Footer` components ([#2517](https://github.com/metamask/snaps/pull/2517))
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Update `RootJSXElement` to allow `Container` or `Box` at the root ([#2526](https://github.com/metamask/snaps/pull/2526))
|
|
20
|
+
- Bump `@metamask/key-tree` from `^9.1.1` to `^9.1.2` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
21
|
+
- Bump `@metamask/rpc-errors` from `^6.2.1` to `^6.3.1` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
22
|
+
- Bump `@metamask/utils` from `^8.3.0` to `^9.1.0` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- Replace `superstruct` with ESM-compatible `@metamask/superstruct` `^3.1.0` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
26
|
+
- This fixes the issue of this package being unusable by any TypeScript project that uses `Node16` or `NodeNext` as its `moduleResolution` option.
|
|
27
|
+
- Set `@metamask/providers` from `^17.0.0` to `17.0.0` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
|
|
28
|
+
- `17.1.0` and `17.1.1` introduce regressions.
|
|
29
|
+
|
|
30
|
+
## [6.0.0]
|
|
31
|
+
### Added
|
|
32
|
+
- **BREAKING:** Add `FileInput` component ([#2469](https://github.com/MetaMask/snaps/pull/2469), [#2504](https://github.com/MetaMask/snaps/pull/2504))
|
|
33
|
+
- `FormSubmitEvent` may now contain values of type `File`.
|
|
34
|
+
- **BREAKING:** Add `Checkbox` component ([#2501](https://github.com/MetaMask/snaps/pull/2501))
|
|
35
|
+
- `FormSubmitEvent` and `InputChangeEvent` may now contain values of type `boolean`.
|
|
36
|
+
- Add `alignment` prop to `Text` ([#2489](https://github.com/MetaMask/snaps/pull/2489))
|
|
37
|
+
- Add `Tooltip` component ([#2490](https://github.com/MetaMask/snaps/pull/2490))
|
|
38
|
+
- Support additional components inside forms ([#2497](https://github.com/MetaMask/snaps/pull/2497))
|
|
39
|
+
- Support conditional children in most JSX components ([#2506](https://github.com/MetaMask/snaps/pull/2506))
|
|
40
|
+
|
|
9
41
|
## [5.0.0]
|
|
10
42
|
### Added
|
|
11
43
|
- Allow row tooltips ([#2483](https://github.com/MetaMask/snaps/pull/2483))
|
|
@@ -170,7 +202,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
170
202
|
### Added
|
|
171
203
|
- Initial release of this package.
|
|
172
204
|
|
|
173
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@
|
|
205
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@6.1.0...HEAD
|
|
206
|
+
[6.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@6.0.0...@metamask/snaps-sdk@6.1.0
|
|
207
|
+
[6.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@5.0.0...@metamask/snaps-sdk@6.0.0
|
|
174
208
|
[5.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.4.2...@metamask/snaps-sdk@5.0.0
|
|
175
209
|
[4.4.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.4.1...@metamask/snaps-sdk@4.4.2
|
|
176
210
|
[4.4.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.4.0...@metamask/snaps-sdk@4.4.1
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,8 @@ __export(src_exports, {
|
|
|
51
51
|
DialogType: () => DialogType,
|
|
52
52
|
DisconnectedError: () => DisconnectedError,
|
|
53
53
|
DividerStruct: () => DividerStruct,
|
|
54
|
+
FileStruct: () => FileStruct,
|
|
55
|
+
FileUploadEventStruct: () => FileUploadEventStruct,
|
|
54
56
|
FormComponentStruct: () => FormComponentStruct,
|
|
55
57
|
FormStateStruct: () => FormStateStruct,
|
|
56
58
|
FormStruct: () => FormStruct,
|
|
@@ -84,6 +86,7 @@ __export(src_exports, {
|
|
|
84
86
|
SeverityLevel: () => SeverityLevel,
|
|
85
87
|
SnapError: () => SnapError,
|
|
86
88
|
SpinnerStruct: () => SpinnerStruct,
|
|
89
|
+
StateStruct: () => StateStruct,
|
|
87
90
|
TextStruct: () => TextStruct,
|
|
88
91
|
TransactionRejected: () => TransactionRejected,
|
|
89
92
|
UnauthorizedError: () => UnauthorizedError,
|
|
@@ -92,7 +95,7 @@ __export(src_exports, {
|
|
|
92
95
|
UserInputEventType: () => UserInputEventType,
|
|
93
96
|
UserRejectedRequestError: () => UserRejectedRequestError,
|
|
94
97
|
address: () => address,
|
|
95
|
-
assert: () =>
|
|
98
|
+
assert: () => import_utils9.assert,
|
|
96
99
|
assertIsComponent: () => assertIsComponent,
|
|
97
100
|
button: () => button,
|
|
98
101
|
copyable: () => copyable,
|
|
@@ -284,7 +287,8 @@ function getErrorData(error) {
|
|
|
284
287
|
}
|
|
285
288
|
|
|
286
289
|
// src/internals/structs.ts
|
|
287
|
-
var import_superstruct = require("superstruct");
|
|
290
|
+
var import_superstruct = require("@metamask/superstruct");
|
|
291
|
+
var import_utils2 = require("@metamask/utils");
|
|
288
292
|
function literal(value) {
|
|
289
293
|
return (0, import_superstruct.define)(
|
|
290
294
|
JSON.stringify(value),
|
|
@@ -304,6 +308,41 @@ function union([
|
|
|
304
308
|
function enumValue(constant) {
|
|
305
309
|
return literal(constant);
|
|
306
310
|
}
|
|
311
|
+
function typedUnion(structs) {
|
|
312
|
+
return new import_superstruct.Struct({
|
|
313
|
+
type: "union",
|
|
314
|
+
schema: null,
|
|
315
|
+
*entries(value, context) {
|
|
316
|
+
if (!(0, import_utils2.isPlainObject)(value) || !(0, import_utils2.hasProperty)(value, "type")) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const { type } = value;
|
|
320
|
+
const struct = structs.find(({ schema }) => (0, import_superstruct.is)(type, schema.type));
|
|
321
|
+
if (!struct) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
for (const entry of struct.entries(value, context)) {
|
|
325
|
+
yield entry;
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
validator(value, context) {
|
|
329
|
+
const types = structs.map(({ schema }) => schema.type.type);
|
|
330
|
+
if (!(0, import_utils2.isPlainObject)(value) || !(0, import_utils2.hasProperty)(value, "type") || typeof value.type !== "string") {
|
|
331
|
+
return `Expected type to be one of: ${types.join(
|
|
332
|
+
", "
|
|
333
|
+
)}, but received: undefined`;
|
|
334
|
+
}
|
|
335
|
+
const { type } = value;
|
|
336
|
+
const struct = structs.find(({ schema }) => (0, import_superstruct.is)(type, schema.type));
|
|
337
|
+
if (struct) {
|
|
338
|
+
return struct.validator(value, context);
|
|
339
|
+
}
|
|
340
|
+
return `Expected type to be one of: ${types.join(
|
|
341
|
+
", "
|
|
342
|
+
)}, but received: "${type}"`;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
307
346
|
|
|
308
347
|
// src/internals/jsx.ts
|
|
309
348
|
function nullUnion(structs) {
|
|
@@ -311,7 +350,7 @@ function nullUnion(structs) {
|
|
|
311
350
|
}
|
|
312
351
|
|
|
313
352
|
// src/internals/svg.ts
|
|
314
|
-
var import_superstruct2 = require("superstruct");
|
|
353
|
+
var import_superstruct2 = require("@metamask/superstruct");
|
|
315
354
|
function svg() {
|
|
316
355
|
return (0, import_superstruct2.refine)((0, import_superstruct2.string)(), "SVG", (value) => {
|
|
317
356
|
if (!value.includes("<svg")) {
|
|
@@ -322,7 +361,7 @@ function svg() {
|
|
|
322
361
|
}
|
|
323
362
|
|
|
324
363
|
// src/index.ts
|
|
325
|
-
var
|
|
364
|
+
var import_utils9 = require("@metamask/utils");
|
|
326
365
|
|
|
327
366
|
// src/error-wrappers.ts
|
|
328
367
|
var import_rpc_errors = require("@metamask/rpc-errors");
|
|
@@ -358,19 +397,19 @@ var UserRejectedRequestError = createSnapError(
|
|
|
358
397
|
);
|
|
359
398
|
|
|
360
399
|
// src/images.ts
|
|
361
|
-
var
|
|
400
|
+
var import_utils6 = require("@metamask/utils");
|
|
362
401
|
|
|
363
402
|
// src/ui/components/address.ts
|
|
364
|
-
var
|
|
365
|
-
var
|
|
403
|
+
var import_superstruct4 = require("@metamask/superstruct");
|
|
404
|
+
var import_utils4 = require("@metamask/utils");
|
|
366
405
|
|
|
367
406
|
// src/ui/builder.ts
|
|
368
|
-
var
|
|
407
|
+
var import_utils3 = require("@metamask/utils");
|
|
369
408
|
function createBuilder(type, struct, keys = []) {
|
|
370
409
|
return (...args) => {
|
|
371
|
-
if (args.length === 1 && (0,
|
|
410
|
+
if (args.length === 1 && (0, import_utils3.isPlainObject)(args[0])) {
|
|
372
411
|
const node2 = { ...args[0], type };
|
|
373
|
-
(0,
|
|
412
|
+
(0, import_utils3.assertStruct)(node2, struct, `Invalid ${type} component`);
|
|
374
413
|
return node2;
|
|
375
414
|
}
|
|
376
415
|
const node = keys.reduce(
|
|
@@ -385,13 +424,13 @@ function createBuilder(type, struct, keys = []) {
|
|
|
385
424
|
},
|
|
386
425
|
{ type }
|
|
387
426
|
);
|
|
388
|
-
(0,
|
|
427
|
+
(0, import_utils3.assertStruct)(node, struct, `Invalid ${type} component`);
|
|
389
428
|
return node;
|
|
390
429
|
};
|
|
391
430
|
}
|
|
392
431
|
|
|
393
432
|
// src/ui/nodes.ts
|
|
394
|
-
var import_superstruct3 = require("superstruct");
|
|
433
|
+
var import_superstruct3 = require("@metamask/superstruct");
|
|
395
434
|
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
396
435
|
NodeType2["Copyable"] = "copyable";
|
|
397
436
|
NodeType2["Divider"] = "divider";
|
|
@@ -422,7 +461,7 @@ var AddressStruct = (0, import_superstruct4.assign)(
|
|
|
422
461
|
LiteralStruct,
|
|
423
462
|
(0, import_superstruct4.object)({
|
|
424
463
|
type: (0, import_superstruct4.literal)("address" /* Address */),
|
|
425
|
-
value:
|
|
464
|
+
value: import_utils4.HexChecksumAddressStruct
|
|
426
465
|
})
|
|
427
466
|
);
|
|
428
467
|
var address = createBuilder("address" /* Address */, AddressStruct, [
|
|
@@ -430,7 +469,7 @@ var address = createBuilder("address" /* Address */, AddressStruct, [
|
|
|
430
469
|
]);
|
|
431
470
|
|
|
432
471
|
// src/ui/components/copyable.ts
|
|
433
|
-
var import_superstruct5 = require("superstruct");
|
|
472
|
+
var import_superstruct5 = require("@metamask/superstruct");
|
|
434
473
|
var CopyableStruct = (0, import_superstruct5.assign)(
|
|
435
474
|
LiteralStruct,
|
|
436
475
|
(0, import_superstruct5.object)({
|
|
@@ -445,7 +484,7 @@ var copyable = createBuilder("copyable" /* Copyable */, CopyableStruct, [
|
|
|
445
484
|
]);
|
|
446
485
|
|
|
447
486
|
// src/ui/components/divider.ts
|
|
448
|
-
var import_superstruct6 = require("superstruct");
|
|
487
|
+
var import_superstruct6 = require("@metamask/superstruct");
|
|
449
488
|
var DividerStruct = (0, import_superstruct6.assign)(
|
|
450
489
|
NodeStruct,
|
|
451
490
|
(0, import_superstruct6.object)({
|
|
@@ -455,7 +494,7 @@ var DividerStruct = (0, import_superstruct6.assign)(
|
|
|
455
494
|
var divider = createBuilder("divider" /* Divider */, DividerStruct);
|
|
456
495
|
|
|
457
496
|
// src/ui/components/heading.ts
|
|
458
|
-
var import_superstruct7 = require("superstruct");
|
|
497
|
+
var import_superstruct7 = require("@metamask/superstruct");
|
|
459
498
|
var HeadingStruct = (0, import_superstruct7.assign)(
|
|
460
499
|
LiteralStruct,
|
|
461
500
|
(0, import_superstruct7.object)({
|
|
@@ -468,7 +507,7 @@ var heading = createBuilder("heading" /* Heading */, HeadingStruct, [
|
|
|
468
507
|
]);
|
|
469
508
|
|
|
470
509
|
// src/ui/components/image.ts
|
|
471
|
-
var import_superstruct8 = require("superstruct");
|
|
510
|
+
var import_superstruct8 = require("@metamask/superstruct");
|
|
472
511
|
var ImageStruct = (0, import_superstruct8.assign)(
|
|
473
512
|
NodeStruct,
|
|
474
513
|
(0, import_superstruct8.object)({
|
|
@@ -479,10 +518,10 @@ var ImageStruct = (0, import_superstruct8.assign)(
|
|
|
479
518
|
var image = createBuilder("image" /* Image */, ImageStruct, ["value"]);
|
|
480
519
|
|
|
481
520
|
// src/ui/components/panel.ts
|
|
482
|
-
var import_superstruct15 = require("superstruct");
|
|
521
|
+
var import_superstruct15 = require("@metamask/superstruct");
|
|
483
522
|
|
|
484
523
|
// src/ui/components/button.ts
|
|
485
|
-
var import_superstruct9 = require("superstruct");
|
|
524
|
+
var import_superstruct9 = require("@metamask/superstruct");
|
|
486
525
|
var ButtonVariant = /* @__PURE__ */ ((ButtonVariant2) => {
|
|
487
526
|
ButtonVariant2["Primary"] = "primary";
|
|
488
527
|
ButtonVariant2["Secondary"] = "secondary";
|
|
@@ -518,10 +557,10 @@ var button = createBuilder("button" /* Button */, ButtonStruct, [
|
|
|
518
557
|
]);
|
|
519
558
|
|
|
520
559
|
// src/ui/components/form.ts
|
|
521
|
-
var import_superstruct11 = require("superstruct");
|
|
560
|
+
var import_superstruct11 = require("@metamask/superstruct");
|
|
522
561
|
|
|
523
562
|
// src/ui/components/input.ts
|
|
524
|
-
var import_superstruct10 = require("superstruct");
|
|
563
|
+
var import_superstruct10 = require("@metamask/superstruct");
|
|
525
564
|
var InputType = /* @__PURE__ */ ((InputType2) => {
|
|
526
565
|
InputType2["Text"] = "text";
|
|
527
566
|
InputType2["Number"] = "number";
|
|
@@ -570,10 +609,10 @@ var form = createBuilder("form" /* Form */, FormStruct, [
|
|
|
570
609
|
]);
|
|
571
610
|
|
|
572
611
|
// src/ui/components/row.ts
|
|
573
|
-
var import_superstruct13 = require("superstruct");
|
|
612
|
+
var import_superstruct13 = require("@metamask/superstruct");
|
|
574
613
|
|
|
575
614
|
// src/ui/components/text.ts
|
|
576
|
-
var import_superstruct12 = require("superstruct");
|
|
615
|
+
var import_superstruct12 = require("@metamask/superstruct");
|
|
577
616
|
var TextStruct = (0, import_superstruct12.assign)(
|
|
578
617
|
LiteralStruct,
|
|
579
618
|
(0, import_superstruct12.object)({
|
|
@@ -617,7 +656,7 @@ var row = createBuilder("row" /* Row */, RowStruct, [
|
|
|
617
656
|
]);
|
|
618
657
|
|
|
619
658
|
// src/ui/components/spinner.ts
|
|
620
|
-
var import_superstruct14 = require("superstruct");
|
|
659
|
+
var import_superstruct14 = require("@metamask/superstruct");
|
|
621
660
|
var SpinnerStruct = (0, import_superstruct14.assign)(
|
|
622
661
|
NodeStruct,
|
|
623
662
|
(0, import_superstruct14.object)({
|
|
@@ -642,7 +681,7 @@ var PanelStruct = (0, import_superstruct15.assign)(
|
|
|
642
681
|
})
|
|
643
682
|
);
|
|
644
683
|
var panel = createBuilder("panel" /* Panel */, PanelStruct, ["children"]);
|
|
645
|
-
var ComponentStruct = (
|
|
684
|
+
var ComponentStruct = typedUnion([
|
|
646
685
|
CopyableStruct,
|
|
647
686
|
DividerStruct,
|
|
648
687
|
HeadingStruct,
|
|
@@ -658,13 +697,13 @@ var ComponentStruct = (0, import_superstruct15.union)([
|
|
|
658
697
|
]);
|
|
659
698
|
|
|
660
699
|
// src/ui/component.ts
|
|
661
|
-
var
|
|
662
|
-
var
|
|
700
|
+
var import_superstruct16 = require("@metamask/superstruct");
|
|
701
|
+
var import_utils5 = require("@metamask/utils");
|
|
663
702
|
function isComponent(value) {
|
|
664
703
|
return (0, import_superstruct16.is)(value, ComponentStruct);
|
|
665
704
|
}
|
|
666
705
|
function assertIsComponent(value) {
|
|
667
|
-
(0,
|
|
706
|
+
(0, import_utils5.assertStruct)(value, ComponentStruct, "Invalid component");
|
|
668
707
|
}
|
|
669
708
|
|
|
670
709
|
// src/images.ts
|
|
@@ -681,7 +720,7 @@ async function getRawImageData(url, options) {
|
|
|
681
720
|
);
|
|
682
721
|
}
|
|
683
722
|
const blob = await response.blob();
|
|
684
|
-
(0,
|
|
723
|
+
(0, import_utils6.assert)(
|
|
685
724
|
blob.type === "image/jpeg" || blob.type === "image/png",
|
|
686
725
|
"Expected image data to be a JPEG or PNG image."
|
|
687
726
|
);
|
|
@@ -691,14 +730,14 @@ async function getRawImageData(url, options) {
|
|
|
691
730
|
async function getImageData(url, options) {
|
|
692
731
|
const blob = await getRawImageData(url, options);
|
|
693
732
|
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
694
|
-
return `data:${blob.type};base64,${(0,
|
|
733
|
+
return `data:${blob.type};base64,${(0, import_utils6.bytesToBase64)(bytes)}`;
|
|
695
734
|
}
|
|
696
735
|
async function getImageComponent(url, { width, height = width, request }) {
|
|
697
|
-
(0,
|
|
736
|
+
(0, import_utils6.assert)(
|
|
698
737
|
typeof width === "number" && width > 0,
|
|
699
738
|
"Expected width to be a number greater than 0."
|
|
700
739
|
);
|
|
701
|
-
(0,
|
|
740
|
+
(0, import_utils6.assert)(
|
|
702
741
|
typeof height === "number" && height > 0,
|
|
703
742
|
"Expected height to be a number greater than 0."
|
|
704
743
|
);
|
|
@@ -716,11 +755,12 @@ var SeverityLevel = /* @__PURE__ */ ((SeverityLevel2) => {
|
|
|
716
755
|
})(SeverityLevel || {});
|
|
717
756
|
|
|
718
757
|
// src/types/handlers/user-input.ts
|
|
719
|
-
var import_superstruct17 = require("superstruct");
|
|
758
|
+
var import_superstruct17 = require("@metamask/superstruct");
|
|
720
759
|
var UserInputEventType = /* @__PURE__ */ ((UserInputEventType2) => {
|
|
721
760
|
UserInputEventType2["ButtonClickEvent"] = "ButtonClickEvent";
|
|
722
761
|
UserInputEventType2["FormSubmitEvent"] = "FormSubmitEvent";
|
|
723
762
|
UserInputEventType2["InputChangeEvent"] = "InputChangeEvent";
|
|
763
|
+
UserInputEventType2["FileUploadEvent"] = "FileUploadEvent";
|
|
724
764
|
return UserInputEventType2;
|
|
725
765
|
})(UserInputEventType || {});
|
|
726
766
|
var GenericEventStruct = (0, import_superstruct17.object)({
|
|
@@ -734,11 +774,17 @@ var ButtonClickEventStruct = (0, import_superstruct17.assign)(
|
|
|
734
774
|
name: (0, import_superstruct17.optional)((0, import_superstruct17.string)())
|
|
735
775
|
})
|
|
736
776
|
);
|
|
777
|
+
var FileStruct = (0, import_superstruct17.object)({
|
|
778
|
+
name: (0, import_superstruct17.string)(),
|
|
779
|
+
size: (0, import_superstruct17.number)(),
|
|
780
|
+
contentType: (0, import_superstruct17.string)(),
|
|
781
|
+
contents: (0, import_superstruct17.string)()
|
|
782
|
+
});
|
|
737
783
|
var FormSubmitEventStruct = (0, import_superstruct17.assign)(
|
|
738
784
|
GenericEventStruct,
|
|
739
785
|
(0, import_superstruct17.object)({
|
|
740
786
|
type: (0, import_superstruct17.literal)("FormSubmitEvent" /* FormSubmitEvent */),
|
|
741
|
-
value: (0, import_superstruct17.record)((0, import_superstruct17.string)(), (0, import_superstruct17.nullable)((0, import_superstruct17.string)())),
|
|
787
|
+
value: (0, import_superstruct17.record)((0, import_superstruct17.string)(), (0, import_superstruct17.nullable)((0, import_superstruct17.union)([(0, import_superstruct17.string)(), FileStruct, (0, import_superstruct17.boolean)()]))),
|
|
742
788
|
name: (0, import_superstruct17.string)()
|
|
743
789
|
})
|
|
744
790
|
);
|
|
@@ -747,13 +793,22 @@ var InputChangeEventStruct = (0, import_superstruct17.assign)(
|
|
|
747
793
|
(0, import_superstruct17.object)({
|
|
748
794
|
type: (0, import_superstruct17.literal)("InputChangeEvent" /* InputChangeEvent */),
|
|
749
795
|
name: (0, import_superstruct17.string)(),
|
|
750
|
-
value: (0, import_superstruct17.string)()
|
|
796
|
+
value: (0, import_superstruct17.union)([(0, import_superstruct17.string)(), (0, import_superstruct17.boolean)()])
|
|
797
|
+
})
|
|
798
|
+
);
|
|
799
|
+
var FileUploadEventStruct = (0, import_superstruct17.assign)(
|
|
800
|
+
GenericEventStruct,
|
|
801
|
+
(0, import_superstruct17.object)({
|
|
802
|
+
type: (0, import_superstruct17.literal)("FileUploadEvent" /* FileUploadEvent */),
|
|
803
|
+
name: (0, import_superstruct17.string)(),
|
|
804
|
+
file: (0, import_superstruct17.nullable)(FileStruct)
|
|
751
805
|
})
|
|
752
806
|
);
|
|
753
807
|
var UserInputEventStruct = (0, import_superstruct17.union)([
|
|
754
808
|
ButtonClickEventStruct,
|
|
755
809
|
FormSubmitEventStruct,
|
|
756
|
-
InputChangeEventStruct
|
|
810
|
+
InputChangeEventStruct,
|
|
811
|
+
FileUploadEventStruct
|
|
757
812
|
]);
|
|
758
813
|
|
|
759
814
|
// src/types/methods/dialog.ts
|
|
@@ -788,19 +843,19 @@ var NotificationType = /* @__PURE__ */ ((NotificationType2) => {
|
|
|
788
843
|
})(NotificationType || {});
|
|
789
844
|
|
|
790
845
|
// src/types/interface.ts
|
|
791
|
-
var
|
|
792
|
-
var
|
|
846
|
+
var import_superstruct19 = require("@metamask/superstruct");
|
|
847
|
+
var import_utils8 = require("@metamask/utils");
|
|
793
848
|
|
|
794
849
|
// src/jsx/validation.ts
|
|
795
|
-
var
|
|
796
|
-
var
|
|
850
|
+
var import_superstruct18 = require("@metamask/superstruct");
|
|
851
|
+
var import_utils7 = require("@metamask/utils");
|
|
797
852
|
var KeyStruct = nullUnion([(0, import_superstruct18.string)(), (0, import_superstruct18.number)()]);
|
|
798
|
-
var StringElementStruct =
|
|
853
|
+
var StringElementStruct = children([
|
|
799
854
|
(0, import_superstruct18.string)()
|
|
800
|
-
);
|
|
855
|
+
]);
|
|
801
856
|
var ElementStruct = (0, import_superstruct18.object)({
|
|
802
857
|
type: (0, import_superstruct18.string)(),
|
|
803
|
-
props: (0, import_superstruct18.record)((0, import_superstruct18.string)(),
|
|
858
|
+
props: (0, import_superstruct18.record)((0, import_superstruct18.string)(), import_utils7.JsonStruct),
|
|
804
859
|
key: (0, import_superstruct18.nullable)(KeyStruct)
|
|
805
860
|
});
|
|
806
861
|
function nestable(struct) {
|
|
@@ -810,8 +865,8 @@ function nestable(struct) {
|
|
|
810
865
|
]);
|
|
811
866
|
return nestableStruct;
|
|
812
867
|
}
|
|
813
|
-
function
|
|
814
|
-
return nestable(
|
|
868
|
+
function children(structs) {
|
|
869
|
+
return nestable((0, import_superstruct18.nullable)(nullUnion([...structs, (0, import_superstruct18.boolean)()])));
|
|
815
870
|
}
|
|
816
871
|
function element(name, props = {}) {
|
|
817
872
|
return (0, import_superstruct18.object)({
|
|
@@ -827,6 +882,12 @@ var ButtonStruct2 = element("Button", {
|
|
|
827
882
|
variant: (0, import_superstruct18.optional)(nullUnion([literal("primary"), literal("destructive")])),
|
|
828
883
|
disabled: (0, import_superstruct18.optional)((0, import_superstruct18.boolean)())
|
|
829
884
|
});
|
|
885
|
+
var CheckboxStruct = element("Checkbox", {
|
|
886
|
+
name: (0, import_superstruct18.string)(),
|
|
887
|
+
checked: (0, import_superstruct18.optional)((0, import_superstruct18.boolean)()),
|
|
888
|
+
label: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
889
|
+
variant: (0, import_superstruct18.optional)(nullUnion([literal("default"), literal("toggle")]))
|
|
890
|
+
});
|
|
830
891
|
var InputStruct2 = element("Input", {
|
|
831
892
|
name: (0, import_superstruct18.string)(),
|
|
832
893
|
type: (0, import_superstruct18.optional)(
|
|
@@ -842,55 +903,71 @@ var OptionStruct = element("Option", {
|
|
|
842
903
|
var DropdownStruct = element("Dropdown", {
|
|
843
904
|
name: (0, import_superstruct18.string)(),
|
|
844
905
|
value: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
845
|
-
children:
|
|
906
|
+
children: children([OptionStruct])
|
|
846
907
|
});
|
|
908
|
+
var FileInputStruct = element(
|
|
909
|
+
"FileInput",
|
|
910
|
+
{
|
|
911
|
+
name: (0, import_superstruct18.string)(),
|
|
912
|
+
accept: nullUnion([(0, import_superstruct18.optional)((0, import_superstruct18.array)((0, import_superstruct18.string)()))]),
|
|
913
|
+
compact: (0, import_superstruct18.optional)((0, import_superstruct18.boolean)())
|
|
914
|
+
}
|
|
915
|
+
);
|
|
916
|
+
var BUTTON_INPUT = [InputStruct2, ButtonStruct2];
|
|
917
|
+
var FIELD_CHILDREN_ARRAY = [
|
|
918
|
+
InputStruct2,
|
|
919
|
+
DropdownStruct,
|
|
920
|
+
FileInputStruct,
|
|
921
|
+
CheckboxStruct
|
|
922
|
+
];
|
|
923
|
+
var FieldChildUnionStruct = nullUnion([
|
|
924
|
+
...FIELD_CHILDREN_ARRAY,
|
|
925
|
+
...BUTTON_INPUT
|
|
926
|
+
]);
|
|
927
|
+
var FieldChildStruct = nullUnion([
|
|
928
|
+
(0, import_superstruct18.tuple)(BUTTON_INPUT),
|
|
929
|
+
...FIELD_CHILDREN_ARRAY
|
|
930
|
+
]);
|
|
847
931
|
var FieldStruct = element("Field", {
|
|
848
932
|
label: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
849
933
|
error: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
850
|
-
children:
|
|
851
|
-
(0, import_superstruct18.tuple)([InputStruct2, ButtonStruct2]),
|
|
852
|
-
InputStruct2,
|
|
853
|
-
DropdownStruct
|
|
854
|
-
])
|
|
934
|
+
children: FieldChildStruct
|
|
855
935
|
});
|
|
936
|
+
var FormChildStruct = children(
|
|
937
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
938
|
+
[FieldStruct, (0, import_superstruct18.lazy)(() => BoxChildStruct)]
|
|
939
|
+
);
|
|
856
940
|
var FormStruct2 = element("Form", {
|
|
857
|
-
children:
|
|
941
|
+
children: FormChildStruct,
|
|
858
942
|
name: (0, import_superstruct18.string)()
|
|
859
943
|
});
|
|
860
944
|
var BoldStruct = element("Bold", {
|
|
861
|
-
children:
|
|
862
|
-
(0, import_superstruct18.
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
(0, import_superstruct18.lazy)(() => ItalicStruct)
|
|
867
|
-
])
|
|
868
|
-
)
|
|
869
|
-
)
|
|
945
|
+
children: children([
|
|
946
|
+
(0, import_superstruct18.string)(),
|
|
947
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
948
|
+
(0, import_superstruct18.lazy)(() => ItalicStruct)
|
|
949
|
+
])
|
|
870
950
|
});
|
|
871
951
|
var ItalicStruct = element("Italic", {
|
|
872
|
-
children:
|
|
873
|
-
(0, import_superstruct18.
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
(0, import_superstruct18.lazy)(() => BoldStruct)
|
|
878
|
-
])
|
|
879
|
-
)
|
|
880
|
-
)
|
|
952
|
+
children: children([
|
|
953
|
+
(0, import_superstruct18.string)(),
|
|
954
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
955
|
+
(0, import_superstruct18.lazy)(() => BoldStruct)
|
|
956
|
+
])
|
|
881
957
|
});
|
|
882
958
|
var FormattingStruct = nullUnion([
|
|
883
959
|
BoldStruct,
|
|
884
960
|
ItalicStruct
|
|
885
961
|
]);
|
|
886
962
|
var AddressStruct2 = element("Address", {
|
|
887
|
-
address:
|
|
963
|
+
address: import_utils7.HexChecksumAddressStruct
|
|
888
964
|
});
|
|
965
|
+
var BoxChildrenStruct = children(
|
|
966
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
967
|
+
[(0, import_superstruct18.lazy)(() => BoxChildStruct)]
|
|
968
|
+
);
|
|
889
969
|
var BoxStruct = element("Box", {
|
|
890
|
-
children:
|
|
891
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
892
|
-
(0, import_superstruct18.nullable)((0, import_superstruct18.lazy)(() => BoxChildStruct))
|
|
893
|
-
),
|
|
970
|
+
children: BoxChildrenStruct,
|
|
894
971
|
direction: (0, import_superstruct18.optional)(nullUnion([literal("horizontal"), literal("vertical")])),
|
|
895
972
|
alignment: (0, import_superstruct18.optional)(
|
|
896
973
|
nullUnion([
|
|
@@ -902,6 +979,23 @@ var BoxStruct = element("Box", {
|
|
|
902
979
|
])
|
|
903
980
|
)
|
|
904
981
|
});
|
|
982
|
+
var FooterChildStruct = nullUnion([
|
|
983
|
+
(0, import_superstruct18.tuple)([ButtonStruct2, ButtonStruct2]),
|
|
984
|
+
ButtonStruct2
|
|
985
|
+
]);
|
|
986
|
+
var FooterStruct = element("Footer", {
|
|
987
|
+
children: FooterChildStruct
|
|
988
|
+
});
|
|
989
|
+
var ContainerChildStruct = nullUnion([
|
|
990
|
+
(0, import_superstruct18.tuple)([BoxStruct, FooterStruct]),
|
|
991
|
+
BoxStruct
|
|
992
|
+
]);
|
|
993
|
+
var ContainerStruct = element(
|
|
994
|
+
"Container",
|
|
995
|
+
{
|
|
996
|
+
children: ContainerChildStruct
|
|
997
|
+
}
|
|
998
|
+
);
|
|
905
999
|
var CopyableStruct2 = element("Copyable", {
|
|
906
1000
|
value: (0, import_superstruct18.string)(),
|
|
907
1001
|
sensitive: (0, import_superstruct18.optional)((0, import_superstruct18.boolean)())
|
|
@@ -911,6 +1005,13 @@ var ValueStruct = element("Value", {
|
|
|
911
1005
|
value: (0, import_superstruct18.string)(),
|
|
912
1006
|
extra: (0, import_superstruct18.string)()
|
|
913
1007
|
});
|
|
1008
|
+
var CardStruct = element("Card", {
|
|
1009
|
+
image: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
1010
|
+
title: (0, import_superstruct18.string)(),
|
|
1011
|
+
description: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
1012
|
+
value: (0, import_superstruct18.string)(),
|
|
1013
|
+
extra: (0, import_superstruct18.optional)((0, import_superstruct18.string)())
|
|
1014
|
+
});
|
|
914
1015
|
var HeadingStruct2 = element("Heading", {
|
|
915
1016
|
children: StringElementStruct
|
|
916
1017
|
});
|
|
@@ -920,13 +1021,33 @@ var ImageStruct2 = element("Image", {
|
|
|
920
1021
|
});
|
|
921
1022
|
var LinkStruct = element("Link", {
|
|
922
1023
|
href: (0, import_superstruct18.string)(),
|
|
923
|
-
children:
|
|
1024
|
+
children: children([FormattingStruct, (0, import_superstruct18.string)()])
|
|
924
1025
|
});
|
|
925
1026
|
var TextStruct2 = element("Text", {
|
|
926
|
-
children:
|
|
927
|
-
|
|
1027
|
+
children: children([(0, import_superstruct18.string)(), BoldStruct, ItalicStruct, LinkStruct]),
|
|
1028
|
+
alignment: (0, import_superstruct18.optional)(
|
|
1029
|
+
nullUnion([literal("start"), literal("center"), literal("end")])
|
|
928
1030
|
)
|
|
929
1031
|
});
|
|
1032
|
+
var TooltipChildStruct = nullUnion([
|
|
1033
|
+
TextStruct2,
|
|
1034
|
+
BoldStruct,
|
|
1035
|
+
ItalicStruct,
|
|
1036
|
+
LinkStruct,
|
|
1037
|
+
ImageStruct2,
|
|
1038
|
+
(0, import_superstruct18.boolean)()
|
|
1039
|
+
]);
|
|
1040
|
+
var TooltipContentStruct = nullUnion([
|
|
1041
|
+
TextStruct2,
|
|
1042
|
+
BoldStruct,
|
|
1043
|
+
ItalicStruct,
|
|
1044
|
+
LinkStruct,
|
|
1045
|
+
(0, import_superstruct18.string)()
|
|
1046
|
+
]);
|
|
1047
|
+
var TooltipStruct = element("Tooltip", {
|
|
1048
|
+
children: (0, import_superstruct18.nullable)(TooltipChildStruct),
|
|
1049
|
+
content: TooltipContentStruct
|
|
1050
|
+
});
|
|
930
1051
|
var RowStruct2 = element("Row", {
|
|
931
1052
|
label: (0, import_superstruct18.string)(),
|
|
932
1053
|
children: nullUnion([AddressStruct2, ImageStruct2, TextStruct2, ValueStruct]),
|
|
@@ -936,28 +1057,36 @@ var RowStruct2 = element("Row", {
|
|
|
936
1057
|
tooltip: (0, import_superstruct18.optional)((0, import_superstruct18.string)())
|
|
937
1058
|
});
|
|
938
1059
|
var SpinnerStruct2 = element("Spinner");
|
|
939
|
-
var BoxChildStruct =
|
|
940
|
-
ButtonStruct2,
|
|
941
|
-
InputStruct2,
|
|
942
|
-
FormStruct2,
|
|
943
|
-
BoldStruct,
|
|
944
|
-
ItalicStruct,
|
|
1060
|
+
var BoxChildStruct = typedUnion([
|
|
945
1061
|
AddressStruct2,
|
|
1062
|
+
BoldStruct,
|
|
946
1063
|
BoxStruct,
|
|
1064
|
+
ButtonStruct2,
|
|
947
1065
|
CopyableStruct2,
|
|
948
1066
|
DividerStruct2,
|
|
1067
|
+
DropdownStruct,
|
|
1068
|
+
FileInputStruct,
|
|
1069
|
+
FormStruct2,
|
|
949
1070
|
HeadingStruct2,
|
|
1071
|
+
InputStruct2,
|
|
950
1072
|
ImageStruct2,
|
|
1073
|
+
ItalicStruct,
|
|
951
1074
|
LinkStruct,
|
|
952
1075
|
RowStruct2,
|
|
953
1076
|
SpinnerStruct2,
|
|
954
1077
|
TextStruct2,
|
|
955
|
-
|
|
1078
|
+
TooltipStruct,
|
|
1079
|
+
CheckboxStruct,
|
|
1080
|
+
CardStruct
|
|
1081
|
+
]);
|
|
1082
|
+
var RootJSXElementStruct = nullUnion([
|
|
1083
|
+
BoxChildStruct,
|
|
1084
|
+
ContainerStruct
|
|
956
1085
|
]);
|
|
957
|
-
var
|
|
958
|
-
var JSXElementStruct = nullUnion([
|
|
1086
|
+
var JSXElementStruct = typedUnion([
|
|
959
1087
|
ButtonStruct2,
|
|
960
1088
|
InputStruct2,
|
|
1089
|
+
FileInputStruct,
|
|
961
1090
|
FieldStruct,
|
|
962
1091
|
FormStruct2,
|
|
963
1092
|
BoldStruct,
|
|
@@ -974,18 +1103,24 @@ var JSXElementStruct = nullUnion([
|
|
|
974
1103
|
TextStruct2,
|
|
975
1104
|
DropdownStruct,
|
|
976
1105
|
OptionStruct,
|
|
977
|
-
ValueStruct
|
|
1106
|
+
ValueStruct,
|
|
1107
|
+
TooltipStruct,
|
|
1108
|
+
CheckboxStruct,
|
|
1109
|
+
FooterStruct,
|
|
1110
|
+
ContainerStruct,
|
|
1111
|
+
CardStruct
|
|
978
1112
|
]);
|
|
979
1113
|
|
|
980
1114
|
// src/types/interface.ts
|
|
981
|
-
var
|
|
1115
|
+
var StateStruct = (0, import_superstruct19.union)([FileStruct, (0, import_superstruct19.string)(), (0, import_superstruct19.boolean)()]);
|
|
1116
|
+
var FormStateStruct = (0, import_superstruct19.record)((0, import_superstruct19.string)(), (0, import_superstruct19.nullable)(StateStruct));
|
|
982
1117
|
var InterfaceStateStruct = (0, import_superstruct19.record)(
|
|
983
1118
|
(0, import_superstruct19.string)(),
|
|
984
|
-
(0, import_superstruct19.union)([FormStateStruct, (0, import_superstruct19.nullable)(
|
|
1119
|
+
(0, import_superstruct19.union)([FormStateStruct, (0, import_superstruct19.nullable)(StateStruct)])
|
|
985
1120
|
);
|
|
986
1121
|
var ComponentOrElementStruct = (0, import_superstruct19.union)([
|
|
987
1122
|
ComponentStruct,
|
|
988
1123
|
RootJSXElementStruct
|
|
989
1124
|
]);
|
|
990
|
-
var InterfaceContextStruct = (0, import_superstruct19.record)((0, import_superstruct19.string)(),
|
|
1125
|
+
var InterfaceContextStruct = (0, import_superstruct19.record)((0, import_superstruct19.string)(), import_utils8.JsonStruct);
|
|
991
1126
|
//# sourceMappingURL=index.js.map
|