@metamask/snaps-sdk 0.0.0 → 1.0.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 +6 -1
- package/dist/cjs/errors.js +157 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +44 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internals/errors.js +59 -0
- package/dist/cjs/internals/errors.js.map +1 -0
- package/dist/cjs/internals/helpers.js +6 -0
- package/dist/cjs/internals/helpers.js.map +1 -0
- package/dist/cjs/internals/index.js +21 -0
- package/dist/cjs/internals/index.js.map +1 -0
- package/dist/cjs/types/caip.js +10 -0
- package/dist/cjs/types/caip.js.map +1 -0
- package/dist/cjs/types/global.js +6 -0
- package/dist/cjs/types/global.js.map +1 -0
- package/dist/cjs/types/handlers/cronjob.js +6 -0
- package/dist/cjs/types/handlers/cronjob.js.map +1 -0
- package/dist/cjs/types/handlers/home-page.js +6 -0
- package/dist/cjs/types/handlers/home-page.js.map +1 -0
- package/dist/cjs/types/handlers/index.js +26 -0
- package/dist/cjs/types/handlers/index.js.map +1 -0
- package/dist/cjs/types/handlers/keyring.js +6 -0
- package/dist/cjs/types/handlers/keyring.js.map +1 -0
- package/dist/cjs/types/handlers/lifecycle.js +6 -0
- package/dist/cjs/types/handlers/lifecycle.js.map +1 -0
- package/dist/cjs/types/handlers/name-lookup.js +6 -0
- package/dist/cjs/types/handlers/name-lookup.js.map +1 -0
- package/dist/cjs/types/handlers/rpc-request.js +6 -0
- package/dist/cjs/types/handlers/rpc-request.js.map +1 -0
- package/dist/cjs/types/handlers/transaction.js +16 -0
- package/dist/cjs/types/handlers/transaction.js.map +1 -0
- package/dist/cjs/types/index.js +28 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/methods/dialog.js +18 -0
- package/dist/cjs/types/methods/dialog.js.map +1 -0
- package/dist/cjs/types/methods/get-bip32-entropy.js +6 -0
- package/dist/cjs/types/methods/get-bip32-entropy.js.map +1 -0
- package/dist/cjs/types/methods/get-bip32-public-key.js +6 -0
- package/dist/cjs/types/methods/get-bip32-public-key.js.map +1 -0
- package/dist/cjs/types/methods/get-bip44-entropy.js +6 -0
- package/dist/cjs/types/methods/get-bip44-entropy.js.map +1 -0
- package/dist/cjs/types/methods/get-entropy.js +6 -0
- package/dist/cjs/types/methods/get-entropy.js.map +1 -0
- package/dist/cjs/types/methods/get-file.js +18 -0
- package/dist/cjs/types/methods/get-file.js.map +1 -0
- package/dist/cjs/types/methods/get-locale.js +10 -0
- package/dist/cjs/types/methods/get-locale.js.map +1 -0
- package/dist/cjs/types/methods/get-snaps.js +6 -0
- package/dist/cjs/types/methods/get-snaps.js.map +1 -0
- package/dist/cjs/types/methods/index.js +34 -0
- package/dist/cjs/types/methods/index.js.map +1 -0
- package/dist/cjs/types/methods/invoke-keyring.js +6 -0
- package/dist/cjs/types/methods/invoke-keyring.js.map +1 -0
- package/dist/cjs/types/methods/invoke-snap.js +6 -0
- package/dist/cjs/types/methods/invoke-snap.js.map +1 -0
- package/dist/cjs/types/methods/manage-accounts.js +6 -0
- package/dist/cjs/types/methods/manage-accounts.js.map +1 -0
- package/dist/cjs/types/methods/manage-state.js +18 -0
- package/dist/cjs/types/methods/manage-state.js.map +1 -0
- package/dist/cjs/types/methods/methods.js +6 -0
- package/dist/cjs/types/methods/methods.js.map +1 -0
- package/dist/cjs/types/methods/notify.js +17 -0
- package/dist/cjs/types/methods/notify.js.map +1 -0
- package/dist/cjs/types/methods/request-snaps.js +6 -0
- package/dist/cjs/types/methods/request-snaps.js.map +1 -0
- package/dist/cjs/types/permissions.js +6 -0
- package/dist/cjs/types/permissions.js.map +1 -0
- package/dist/cjs/types/provider.js +6 -0
- package/dist/cjs/types/provider.js.map +1 -0
- package/dist/cjs/types/snap.js +6 -0
- package/dist/cjs/types/snap.js.map +1 -0
- package/dist/cjs/ui/builder.js +44 -0
- package/dist/cjs/ui/builder.js.map +1 -0
- package/dist/cjs/ui/component.js +29 -0
- package/dist/cjs/ui/component.js.map +1 -0
- package/dist/cjs/ui/components/copyable.js +32 -0
- package/dist/cjs/ui/components/copyable.js.map +1 -0
- package/dist/cjs/ui/components/divider.js +27 -0
- package/dist/cjs/ui/components/divider.js.map +1 -0
- package/dist/cjs/ui/components/heading.js +30 -0
- package/dist/cjs/ui/components/heading.js.map +1 -0
- package/dist/cjs/ui/components/image.js +47 -0
- package/dist/cjs/ui/components/image.js.map +1 -0
- package/dist/cjs/ui/components/index.js +49 -0
- package/dist/cjs/ui/components/index.js.map +1 -0
- package/dist/cjs/ui/components/panel.js +55 -0
- package/dist/cjs/ui/components/panel.js.map +1 -0
- package/dist/cjs/ui/components/spinner.js +27 -0
- package/dist/cjs/ui/components/spinner.js.map +1 -0
- package/dist/cjs/ui/components/text.js +32 -0
- package/dist/cjs/ui/components/text.js.map +1 -0
- package/dist/cjs/ui/index.js +28 -0
- package/dist/cjs/ui/index.js.map +1 -0
- package/dist/cjs/ui/nodes.js +41 -0
- package/dist/cjs/ui/nodes.js.map +1 -0
- package/dist/esm/errors.js +150 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +5 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internals/errors.js +58 -0
- package/dist/esm/internals/errors.js.map +1 -0
- package/dist/esm/internals/helpers.js +3 -0
- package/dist/esm/internals/helpers.js.map +1 -0
- package/dist/esm/internals/index.js +4 -0
- package/dist/esm/internals/index.js.map +1 -0
- package/dist/esm/types/caip.js +7 -0
- package/dist/esm/types/caip.js.map +1 -0
- package/dist/esm/types/global.js +3 -0
- package/dist/esm/types/global.js.map +1 -0
- package/dist/esm/types/handlers/cronjob.js +3 -0
- package/dist/esm/types/handlers/cronjob.js.map +1 -0
- package/dist/esm/types/handlers/home-page.js +3 -0
- package/dist/esm/types/handlers/home-page.js.map +1 -0
- package/dist/esm/types/handlers/index.js +9 -0
- package/dist/esm/types/handlers/index.js.map +1 -0
- package/dist/esm/types/handlers/keyring.js +3 -0
- package/dist/esm/types/handlers/keyring.js.map +1 -0
- package/dist/esm/types/handlers/lifecycle.js +3 -0
- package/dist/esm/types/handlers/lifecycle.js.map +1 -0
- package/dist/esm/types/handlers/name-lookup.js +3 -0
- package/dist/esm/types/handlers/name-lookup.js.map +1 -0
- package/dist/esm/types/handlers/rpc-request.js +3 -0
- package/dist/esm/types/handlers/rpc-request.js.map +1 -0
- package/dist/esm/types/handlers/transaction.js +6 -0
- package/dist/esm/types/handlers/transaction.js.map +1 -0
- package/dist/esm/types/index.js +11 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/methods/dialog.js +8 -0
- package/dist/esm/types/methods/dialog.js.map +1 -0
- package/dist/esm/types/methods/get-bip32-entropy.js +3 -0
- package/dist/esm/types/methods/get-bip32-entropy.js.map +1 -0
- package/dist/esm/types/methods/get-bip32-public-key.js +3 -0
- package/dist/esm/types/methods/get-bip32-public-key.js.map +1 -0
- package/dist/esm/types/methods/get-bip44-entropy.js +3 -0
- package/dist/esm/types/methods/get-bip44-entropy.js.map +1 -0
- package/dist/esm/types/methods/get-entropy.js +3 -0
- package/dist/esm/types/methods/get-entropy.js.map +1 -0
- package/dist/esm/types/methods/get-file.js +8 -0
- package/dist/esm/types/methods/get-file.js.map +1 -0
- package/dist/esm/types/methods/get-locale.js +7 -0
- package/dist/esm/types/methods/get-locale.js.map +1 -0
- package/dist/esm/types/methods/get-snaps.js +3 -0
- package/dist/esm/types/methods/get-snaps.js.map +1 -0
- package/dist/esm/types/methods/index.js +17 -0
- package/dist/esm/types/methods/index.js.map +1 -0
- package/dist/esm/types/methods/invoke-keyring.js +3 -0
- package/dist/esm/types/methods/invoke-keyring.js.map +1 -0
- package/dist/esm/types/methods/invoke-snap.js +3 -0
- package/dist/esm/types/methods/invoke-snap.js.map +1 -0
- package/dist/esm/types/methods/manage-accounts.js +3 -0
- package/dist/esm/types/methods/manage-accounts.js.map +1 -0
- package/dist/esm/types/methods/manage-state.js +8 -0
- package/dist/esm/types/methods/manage-state.js.map +1 -0
- package/dist/esm/types/methods/methods.js +3 -0
- package/dist/esm/types/methods/methods.js.map +1 -0
- package/dist/esm/types/methods/notify.js +7 -0
- package/dist/esm/types/methods/notify.js.map +1 -0
- package/dist/esm/types/methods/request-snaps.js +3 -0
- package/dist/esm/types/methods/request-snaps.js.map +1 -0
- package/dist/esm/types/permissions.js +3 -0
- package/dist/esm/types/permissions.js.map +1 -0
- package/dist/esm/types/provider.js +3 -0
- package/dist/esm/types/provider.js.map +1 -0
- package/dist/esm/types/snap.js +3 -0
- package/dist/esm/types/snap.js.map +1 -0
- package/dist/esm/ui/builder.js +50 -0
- package/dist/esm/ui/builder.js.map +1 -0
- package/dist/esm/ui/component.js +23 -0
- package/dist/esm/ui/component.js.map +1 -0
- package/dist/esm/ui/components/copyable.js +27 -0
- package/dist/esm/ui/components/copyable.js.map +1 -0
- package/dist/esm/ui/components/divider.js +15 -0
- package/dist/esm/ui/components/divider.js.map +1 -0
- package/dist/esm/ui/components/heading.js +22 -0
- package/dist/esm/ui/components/heading.js.map +1 -0
- package/dist/esm/ui/components/image.js +37 -0
- package/dist/esm/ui/components/image.js.map +1 -0
- package/dist/esm/ui/components/index.js +9 -0
- package/dist/esm/ui/components/index.js.map +1 -0
- package/dist/esm/ui/components/panel.js +56 -0
- package/dist/esm/ui/components/panel.js.map +1 -0
- package/dist/esm/ui/components/spinner.js +15 -0
- package/dist/esm/ui/components/spinner.js.map +1 -0
- package/dist/esm/ui/components/text.js +29 -0
- package/dist/esm/ui/components/text.js.map +1 -0
- package/dist/esm/ui/index.js +5 -0
- package/dist/esm/ui/index.js.map +1 -0
- package/dist/esm/ui/nodes.js +24 -0
- package/dist/esm/ui/nodes.js.map +1 -0
- package/dist/types/errors.d.ts +88 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/internals/errors.d.ts +41 -0
- package/dist/types/internals/helpers.d.ts +36 -0
- package/dist/types/internals/index.d.ts +2 -0
- package/dist/types/types/caip.d.ts +12 -0
- package/dist/types/types/global.d.ts +8 -0
- package/dist/types/types/handlers/cronjob.d.ts +14 -0
- package/dist/types/types/handlers/home-page.d.ts +19 -0
- package/dist/types/types/handlers/index.d.ts +7 -0
- package/dist/types/types/handlers/keyring.d.ts +20 -0
- package/dist/types/types/handlers/lifecycle.d.ts +41 -0
- package/dist/types/types/handlers/name-lookup.d.ts +59 -0
- package/dist/types/types/handlers/rpc-request.d.ts +21 -0
- package/dist/types/types/handlers/transaction.d.ts +110 -0
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types/types/methods/dialog.d.ts +67 -0
- package/dist/types/types/methods/get-bip32-entropy.d.ts +15 -0
- package/dist/types/types/methods/get-bip32-public-key.d.ts +19 -0
- package/dist/types/types/methods/get-bip44-entropy.d.ts +14 -0
- package/dist/types/types/methods/get-entropy.d.ts +16 -0
- package/dist/types/types/methods/get-file.d.ts +23 -0
- package/dist/types/types/methods/get-locale.d.ts +12 -0
- package/dist/types/types/methods/get-snaps.d.ts +16 -0
- package/dist/types/types/methods/index.d.ts +15 -0
- package/dist/types/types/methods/invoke-keyring.d.ts +14 -0
- package/dist/types/types/methods/invoke-snap.d.ts +16 -0
- package/dist/types/types/methods/manage-accounts.d.ts +18 -0
- package/dist/types/types/methods/manage-state.d.ts +69 -0
- package/dist/types/types/methods/methods.d.ts +62 -0
- package/dist/types/types/methods/notify.d.ts +27 -0
- package/dist/types/types/methods/request-snaps.d.ts +18 -0
- package/dist/types/types/permissions.d.ts +46 -0
- package/dist/types/types/provider.d.ts +14 -0
- package/dist/types/types/snap.d.ts +12 -0
- package/dist/types/ui/builder.d.ts +42 -0
- package/dist/types/ui/component.d.ts +17 -0
- package/dist/types/ui/components/copyable.d.ts +49 -0
- package/dist/types/ui/components/divider.d.ts +21 -0
- package/dist/types/ui/components/heading.d.ts +36 -0
- package/dist/types/ui/components/image.d.ts +42 -0
- package/dist/types/ui/components/index.d.ts +9 -0
- package/dist/types/ui/components/panel.d.ts +153 -0
- package/dist/types/ui/components/spinner.d.ts +22 -0
- package/dist/types/ui/components/text.d.ts +46 -0
- package/dist/types/ui/index.d.ts +3 -0
- package/dist/types/ui/nodes.d.ts +51 -0
- package/package.json +10 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-locale.ts"],"sourcesContent":["/**\n * The request parameters for the `snap_getLocale` method.\n *\n * This method does not accept any parameters.\n */\nexport type GetLocaleParams = never;\n\n/**\n * The result returned by the `snap_getLocale` method.\n *\n * It is the locale of the user's MetaMask extension.\n */\nexport type GetLocaleResult = string;\n"],"names":[],"mappings":"AAAA;;;;CAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-snaps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./dialog"), exports);
|
|
6
|
+
_export_star(require("./get-bip32-entropy"), exports);
|
|
7
|
+
_export_star(require("./get-bip32-public-key"), exports);
|
|
8
|
+
_export_star(require("./get-bip44-entropy"), exports);
|
|
9
|
+
_export_star(require("./get-entropy"), exports);
|
|
10
|
+
_export_star(require("./get-file"), exports);
|
|
11
|
+
_export_star(require("./get-locale"), exports);
|
|
12
|
+
_export_star(require("./get-snaps"), exports);
|
|
13
|
+
_export_star(require("./invoke-keyring"), exports);
|
|
14
|
+
_export_star(require("./invoke-snap"), exports);
|
|
15
|
+
_export_star(require("./manage-accounts"), exports);
|
|
16
|
+
_export_star(require("./manage-state"), exports);
|
|
17
|
+
_export_star(require("./methods"), exports);
|
|
18
|
+
_export_star(require("./notify"), exports);
|
|
19
|
+
_export_star(require("./request-snaps"), exports);
|
|
20
|
+
function _export_star(from, to) {
|
|
21
|
+
Object.keys(from).forEach(function(k) {
|
|
22
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
23
|
+
Object.defineProperty(to, k, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return from[k];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return from;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/index.ts"],"sourcesContent":["export * from './dialog';\nexport * from './get-bip32-entropy';\nexport * from './get-bip32-public-key';\nexport * from './get-bip44-entropy';\nexport * from './get-entropy';\nexport * from './get-file';\nexport * from './get-locale';\nexport * from './get-snaps';\nexport * from './invoke-keyring';\nexport * from './invoke-snap';\nexport * from './manage-accounts';\nexport * from './manage-state';\nexport * from './methods';\nexport * from './notify';\nexport * from './request-snaps';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/invoke-keyring.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/invoke-snap.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/manage-accounts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ManageStateOperation", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ManageStateOperation;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var ManageStateOperation;
|
|
12
|
+
(function(ManageStateOperation) {
|
|
13
|
+
ManageStateOperation["ClearState"] = 'clear';
|
|
14
|
+
ManageStateOperation["GetState"] = 'get';
|
|
15
|
+
ManageStateOperation["UpdateState"] = 'update';
|
|
16
|
+
})(ManageStateOperation || (ManageStateOperation = {}));
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=manage-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/manage-state.ts"],"sourcesContent":["import type { Json } from '@metamask/utils';\n\nimport type { EnumToUnion } from '../../internals';\n\n/**\n * The operations that can be performed on the state.\n */\nexport enum ManageStateOperation {\n ClearState = 'clear',\n GetState = 'get',\n UpdateState = 'update',\n}\n\n/**\n * The clear state operation, which clears the state.\n *\n * @property operation - The operation to perform on the state. Must be `clear`.\n * @property encrypted - Whether to use the separate encrypted state, or the\n * unencrypted state. Defaults to the encrypted state. Encrypted state can only\n * be used if the extension is unlocked, while unencrypted state can be used\n * whether the extension is locked or unlocked.\n */\nexport type ClearStateOperation = {\n operation: EnumToUnion<ManageStateOperation.ClearState>;\n encrypted?: boolean;\n};\n\n/**\n * The get state operation, which retrieves the state.\n *\n * @property operation - The operation to perform on the state. Must be `get`.\n * @property encrypted - Whether to use the separate encrypted state, or the\n * unencrypted state. Defaults to the encrypted state. Encrypted state can only\n * be used if the extension is unlocked, while unencrypted state can be used\n * whether the extension is locked or unlocked.\n */\nexport type GetStateOperation = {\n operation: EnumToUnion<ManageStateOperation.GetState>;\n encrypted?: boolean;\n};\n\n/**\n * The update state operation, which updates the state.\n *\n * @property operation - The operation to perform on the state. Must be\n * `update`.\n * @property encrypted - Whether to use the separate encrypted state, or the\n * unencrypted state. Defaults to the encrypted state. Encrypted state can only\n * be used if the extension is unlocked, while unencrypted state can be used\n * whether the extension is locked or unlocked.\n * @property newState - The new state to set.\n */\nexport type UpdateStateOperation = {\n operation: EnumToUnion<ManageStateOperation.UpdateState>;\n encrypted?: boolean;\n newState: Record<string, Json>;\n};\n\n/**\n * The request parameters for the `snap_manageState` method.\n *\n * @property operation - The operation to perform on the state.\n * @property encrypted - Whether to use the separate encrypted state, or the\n * unencrypted state. Defaults to the encrypted state.\n * @property newState - The new state to set. Only applicable for the `set`\n * operation.\n */\nexport type ManageStateParams =\n | ClearStateOperation\n | GetStateOperation\n | UpdateStateOperation;\n\n/**\n * The result returned by the `snap_manageState` method.\n *\n * If the operation is `get`, the result is the state. Otherwise, the result is\n * `null`.\n */\nexport type ManageStateResult = Record<string, Json> | null;\n"],"names":["ManageStateOperation","ClearState","GetState","UpdateState"],"mappings":";;;;;;;;;;IAOO;UAAKA,oBAAoB;IAApBA,qBACVC,gBAAa;IADHD,qBAEVE,cAAW;IAFDF,qBAGVG,iBAAc;GAHJH,yBAAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/methods.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "NotificationType", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return NotificationType;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var NotificationType;
|
|
12
|
+
(function(NotificationType) {
|
|
13
|
+
NotificationType["InApp"] = 'inApp';
|
|
14
|
+
NotificationType["Native"] = 'native';
|
|
15
|
+
})(NotificationType || (NotificationType = {}));
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=notify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/notify.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\n\n/**\n * The types of notifications that can be displayed.\n *\n * - `InApp` - A notification that is displayed in by the MetaMask extension.\n * - `Native` - A notification that is displayed by the operating system.\n */\nexport enum NotificationType {\n InApp = 'inApp',\n Native = 'native',\n}\n\n/**\n * The request parameters for the `snap_notify` method.\n *\n * @property type - The type of notification to display.\n * @property message - The message to display in the notification.\n */\nexport type NotifyParams = {\n type: EnumToUnion<NotificationType>;\n message: string;\n};\n\n/**\n * The result returned by the `snap_notify` method.\n *\n * This method does not return anything.\n */\nexport type NotifyResult = null;\n"],"names":["NotificationType","InApp","Native"],"mappings":";;;;;;;;;;IAQO;UAAKA,gBAAgB;IAAhBA,iBACVC,WAAQ;IADED,iBAEVE,YAAS;GAFCF,qBAAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/request-snaps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/types/permissions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/types/provider.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/types/snap.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createBuilder", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createBuilder;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _utils = require("@metamask/utils");
|
|
12
|
+
function createBuilder(type, struct, keys = []) {
|
|
13
|
+
return (...args)=>{
|
|
14
|
+
// Node passed as a single object.
|
|
15
|
+
if (args.length === 1 && (0, _utils.isPlainObject)(args[0])) {
|
|
16
|
+
const node = {
|
|
17
|
+
...args[0],
|
|
18
|
+
type
|
|
19
|
+
};
|
|
20
|
+
// The user could be passing invalid values to the builder, so we need to
|
|
21
|
+
// validate them as per the component's struct.
|
|
22
|
+
(0, _utils.assertStruct)(node, struct, `Invalid ${type} component`);
|
|
23
|
+
return node;
|
|
24
|
+
}
|
|
25
|
+
// Node passed as an array of arguments.
|
|
26
|
+
const node = keys.reduce((partialNode, key, index)=>{
|
|
27
|
+
if (args[index] !== undefined) {
|
|
28
|
+
return {
|
|
29
|
+
...partialNode,
|
|
30
|
+
[key]: args[index]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return partialNode;
|
|
34
|
+
}, {
|
|
35
|
+
type
|
|
36
|
+
});
|
|
37
|
+
// The user could be passing invalid values to the builder, so we need to
|
|
38
|
+
// validate them as per the component's struct.
|
|
39
|
+
(0, _utils.assertStruct)(node, struct, `Invalid ${type} component`);
|
|
40
|
+
return node;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/builder.ts"],"sourcesContent":["import { assertStruct, isPlainObject } from '@metamask/utils';\nimport type { Struct } from 'superstruct';\n\nimport type { Component } from './components';\nimport type { NodeType } from './nodes';\n\n/**\n * A function that builds a {@link Component}. This infers the proper args type\n * from the given node.\n *\n * @internal\n */\ntype NodeBuilder<Node extends Component, Keys extends (keyof Node)[]> = Omit<\n Node,\n 'type'\n> extends Record<string, never>\n ? (...args: []) => Node\n : (...args: [Omit<Node, 'type'>] | NodeArrayType<Node, Keys>) => Node;\n\n/**\n * Map from an array of node keys to the corresponding array type.\n *\n * @example\n * type Node = { type: 'node'; a: string; b: number; c: boolean };\n * type Keys = ['a', 'b', 'c'];\n *\n * type NodeArray = NodeArrayType<Node, Keys>; // [string, number, boolean]\n * @internal\n */\ntype NodeArrayType<Node extends Component, Keys extends (keyof Node)[]> = {\n [Key in keyof Keys]: Node[Keys[Key]];\n};\n\n/**\n * A function that returns a function to \"build\" a {@link Component}. It infers\n * the type of the component from the given struct, and performs validation on\n * the created component.\n *\n * The returned function can handle the node arguments in two ways:\n * 1. As a single object, with the keys corresponding to the node's properties,\n * excluding the `type` property.\n * 2. As an array of arguments, with the order corresponding to the given keys.\n *\n * @param type - The type of the component to build.\n * @param struct - The struct to use to validate the component.\n * @param keys - The keys of the component to use as arguments to the builder.\n * The order of the keys determines the order of the arguments.\n * @returns A function that builds a component of the given type.\n * @internal\n */\nexport function createBuilder<\n Node extends Component,\n Keys extends (keyof Node)[] = [],\n>(\n type: NodeType,\n struct: Struct<Node>,\n keys: Keys = [] as unknown as Keys,\n): NodeBuilder<Node, Keys> {\n return (...args: [Omit<Node, 'type'>] | NodeArrayType<Node, Keys> | []) => {\n // Node passed as a single object.\n if (args.length === 1 && isPlainObject(args[0])) {\n const node = { ...args[0], type };\n\n // The user could be passing invalid values to the builder, so we need to\n // validate them as per the component's struct.\n assertStruct(node, struct, `Invalid ${type} component`);\n return node;\n }\n\n // Node passed as an array of arguments.\n const node = keys.reduce<Partial<Component>>(\n (partialNode, key, index) => {\n if (args[index] !== undefined) {\n return {\n ...partialNode,\n [key]: args[index],\n };\n }\n\n return partialNode;\n },\n { type },\n );\n\n // The user could be passing invalid values to the builder, so we need to\n // validate them as per the component's struct.\n assertStruct(node, struct, `Invalid ${type} component`);\n return node;\n };\n}\n"],"names":["createBuilder","type","struct","keys","args","length","isPlainObject","node","assertStruct","reduce","partialNode","key","index","undefined"],"mappings":";;;;+BAkDgBA;;;eAAAA;;;uBAlD4B;AAkDrC,SAASA,cAIdC,IAAc,EACdC,MAAoB,EACpBC,OAAa,EAAE,AAAmB;IAElC,OAAO,CAAC,GAAGC;QACT,kCAAkC;QAClC,IAAIA,KAAKC,MAAM,KAAK,KAAKC,IAAAA,oBAAa,EAACF,IAAI,CAAC,EAAE,GAAG;YAC/C,MAAMG,OAAO;gBAAE,GAAGH,IAAI,CAAC,EAAE;gBAAEH;YAAK;YAEhC,yEAAyE;YACzE,+CAA+C;YAC/CO,IAAAA,mBAAY,EAACD,MAAML,QAAQ,CAAC,QAAQ,EAAED,KAAK,UAAU,CAAC;YACtD,OAAOM;QACT;QAEA,wCAAwC;QACxC,MAAMA,OAAOJ,KAAKM,MAAM,CACtB,CAACC,aAAaC,KAAKC;YACjB,IAAIR,IAAI,CAACQ,MAAM,KAAKC,WAAW;gBAC7B,OAAO;oBACL,GAAGH,WAAW;oBACd,CAACC,IAAI,EAAEP,IAAI,CAACQ,MAAM;gBACpB;YACF;YAEA,OAAOF;QACT,GACA;YAAET;QAAK;QAGT,yEAAyE;QACzE,+CAA+C;QAC/CO,IAAAA,mBAAY,EAACD,MAAML,QAAQ,CAAC,QAAQ,EAAED,KAAK,UAAU,CAAC;QACtD,OAAOM;IACT;AACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
isComponent: function() {
|
|
13
|
+
return isComponent;
|
|
14
|
+
},
|
|
15
|
+
assertIsComponent: function() {
|
|
16
|
+
return assertIsComponent;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _utils = require("@metamask/utils");
|
|
20
|
+
const _superstruct = require("superstruct");
|
|
21
|
+
const _components = require("./components");
|
|
22
|
+
function isComponent(value) {
|
|
23
|
+
return (0, _superstruct.is)(value, _components.ComponentStruct);
|
|
24
|
+
}
|
|
25
|
+
function assertIsComponent(value) {
|
|
26
|
+
(0, _utils.assertStruct)(value, _components.ComponentStruct, 'Invalid component');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/component.ts"],"sourcesContent":["import { assertStruct } from '@metamask/utils';\nimport { is } from 'superstruct';\n\nimport { ComponentStruct } from './components';\nimport type { Component } from './components';\n\n/**\n * Check if the given value is a {@link Component}. This performs recursive\n * validation of the component's children (if any).\n *\n * @param value - The value to check.\n * @returns `true` if the value is a {@link Component}, `false` otherwise.\n */\nexport function isComponent(value: unknown): value is Component {\n return is(value, ComponentStruct);\n}\n\n/**\n * Assert that the given value is a {@link Component}. This performs recursive\n * validation of the component's children (if any).\n *\n * @param value - The value to check.\n * @throws If the value is not a {@link Component}.\n */\nexport function assertIsComponent(value: unknown): asserts value is Component {\n assertStruct(value, ComponentStruct, 'Invalid component');\n}\n"],"names":["isComponent","assertIsComponent","value","is","ComponentStruct","assertStruct"],"mappings":";;;;;;;;;;;IAagBA,WAAW;eAAXA;;IAWAC,iBAAiB;eAAjBA;;;uBAxBa;6BACV;4BAEa;AAUzB,SAASD,YAAYE,KAAc;IACxC,OAAOC,IAAAA,eAAE,EAACD,OAAOE,2BAAe;AAClC;AASO,SAASH,kBAAkBC,KAAc;IAC9CG,IAAAA,mBAAY,EAACH,OAAOE,2BAAe,EAAE;AACvC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
CopyableStruct: function() {
|
|
13
|
+
return CopyableStruct;
|
|
14
|
+
},
|
|
15
|
+
copyable: function() {
|
|
16
|
+
return copyable;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _superstruct = require("superstruct");
|
|
20
|
+
const _builder = require("../builder");
|
|
21
|
+
const _nodes = require("../nodes");
|
|
22
|
+
const CopyableStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
23
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Copyable),
|
|
24
|
+
value: (0, _superstruct.string)(),
|
|
25
|
+
sensitive: (0, _superstruct.optional)((0, _superstruct.boolean)())
|
|
26
|
+
}));
|
|
27
|
+
const copyable = (0, _builder.createBuilder)(_nodes.NodeType.Copyable, CopyableStruct, [
|
|
28
|
+
'value',
|
|
29
|
+
'sensitive'
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=copyable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/copyable.ts"],"sourcesContent":["import {\n assign,\n boolean,\n literal,\n object,\n optional,\n string,\n} from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\nimport type { Literal } from '../nodes';\n\n/**\n * Text that can be copied to the clipboard. It can optionally be marked as\n * sensitive, in which case it will only be displayed to the user after clicking\n * on the component.\n *\n * @property type - The type of the node. Must be the string `copyable`.\n * @property value - The text to be copied.\n * @property sensitive - Whether the value is sensitive or not. Sensitive values\n * are only displayed to the user after clicking on the component. Defaults to\n * false.\n */\nexport type Copyable = Literal & {\n type: NodeType.Copyable;\n value: string;\n};\n\nexport const CopyableStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Copyable),\n value: string(),\n sensitive: optional(boolean()),\n }),\n);\n\n/**\n * Create a {@link Copyable} component.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `text` property.\n * @param args.value - The text to be copied.\n * @param args.sensitive - Whether the value is sensitive or not. Sensitive\n * values are only displayed to the user after clicking on the component.\n * Defaults to false.\n * @returns A {@link Copyable} component.\n * @example\n * const node = copyable('Hello, world!');\n * const node = copyable({ value: 'Hello, world!' });\n */\nexport const copyable = createBuilder(NodeType.Copyable, CopyableStruct, [\n 'value',\n 'sensitive',\n]);\n"],"names":["CopyableStruct","copyable","assign","LiteralStruct","object","type","literal","NodeType","Copyable","value","string","sensitive","optional","boolean","createBuilder"],"mappings":";;;;;;;;;;;IA6BaA,cAAc;eAAdA;;IAuBAC,QAAQ;eAARA;;;6BA7CN;yBAEuB;uBACU;AAmBjC,MAAMD,iBAAiBE,IAAAA,mBAAM,EAClCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,QAAQ;IAC/BC,OAAOC,IAAAA,mBAAM;IACbC,WAAWC,IAAAA,qBAAQ,EAACC,IAAAA,oBAAO;AAC7B;AAiBK,MAAMZ,WAAWa,IAAAA,sBAAa,EAACP,eAAQ,CAACC,QAAQ,EAAER,gBAAgB;IACvE;IACA;CACD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
DividerStruct: function() {
|
|
13
|
+
return DividerStruct;
|
|
14
|
+
},
|
|
15
|
+
divider: function() {
|
|
16
|
+
return divider;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _superstruct = require("superstruct");
|
|
20
|
+
const _builder = require("../builder");
|
|
21
|
+
const _nodes = require("../nodes");
|
|
22
|
+
const DividerStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
23
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Divider)
|
|
24
|
+
}));
|
|
25
|
+
const divider = (0, _builder.createBuilder)(_nodes.NodeType.Divider, DividerStruct);
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/divider.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\n\nexport const DividerStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Divider),\n }),\n);\n\n/**\n * A divider node, that renders a line between other nodes.\n */\nexport type Divider = Infer<typeof DividerStruct>;\n\n/**\n * Create a {@link Divider} node.\n *\n * @returns The divider node as object.\n * @example\n * const node = divider();\n */\nexport const divider = createBuilder(NodeType.Divider, DividerStruct);\n"],"names":["DividerStruct","divider","assign","NodeStruct","object","type","literal","NodeType","Divider","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IAmBAC,OAAO;eAAPA;;;6BAxB2B;yBAEV;uBACO;AAE9B,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;AAChC;AAeK,MAAMP,UAAUQ,IAAAA,sBAAa,EAACF,eAAQ,CAACC,OAAO,EAAER"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
HeadingStruct: function() {
|
|
13
|
+
return HeadingStruct;
|
|
14
|
+
},
|
|
15
|
+
heading: function() {
|
|
16
|
+
return heading;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _superstruct = require("superstruct");
|
|
20
|
+
const _builder = require("../builder");
|
|
21
|
+
const _nodes = require("../nodes");
|
|
22
|
+
const HeadingStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
23
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Heading),
|
|
24
|
+
value: (0, _superstruct.string)()
|
|
25
|
+
}));
|
|
26
|
+
const heading = (0, _builder.createBuilder)(_nodes.NodeType.Heading, HeadingStruct, [
|
|
27
|
+
'value'
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=heading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/heading.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, string } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const HeadingStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Heading),\n value: string(),\n }),\n);\n\n/**\n * A heading node, that renders the text as a heading. The level of the heading\n * is determined by the depth of the heading in the document.\n *\n * @property type - The type of the node, must be the string 'text'.\n * @property value - The text content of the node, either as plain text, or as a\n * markdown string.\n */\nexport type Heading = Infer<typeof HeadingStruct>;\n\n/**\n * Create a {@link Heading} node.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `value` property.\n * @param args.value - The heading text.\n * @returns The heading node as object.\n * @example\n * const node = heading({ value: 'Hello, world!' });\n * const node = heading('Hello, world!');\n */\nexport const heading = createBuilder(NodeType.Heading, HeadingStruct, [\n 'value',\n]);\n"],"names":["HeadingStruct","heading","assign","LiteralStruct","object","type","literal","NodeType","Heading","value","string","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IA6BAC,OAAO;eAAPA;;;6BAlCmC;yBAElB;uBACU;AAEjC,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;IAC9BC,OAAOC,IAAAA,mBAAM;AACf;AAwBK,MAAMT,UAAUU,IAAAA,sBAAa,EAACJ,eAAQ,CAACC,OAAO,EAAER,eAAe;IACpE;CACD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
svg: function() {
|
|
13
|
+
return svg;
|
|
14
|
+
},
|
|
15
|
+
ImageStruct: function() {
|
|
16
|
+
return ImageStruct;
|
|
17
|
+
},
|
|
18
|
+
image: function() {
|
|
19
|
+
return image;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _issvg = /*#__PURE__*/ _interop_require_default(require("is-svg"));
|
|
23
|
+
const _superstruct = require("superstruct");
|
|
24
|
+
const _builder = require("../builder");
|
|
25
|
+
const _nodes = require("../nodes");
|
|
26
|
+
function _interop_require_default(obj) {
|
|
27
|
+
return obj && obj.__esModule ? obj : {
|
|
28
|
+
default: obj
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function svg() {
|
|
32
|
+
return (0, _superstruct.refine)((0, _superstruct.string)(), 'SVG', (value)=>{
|
|
33
|
+
if (!(0, _issvg.default)(value)) {
|
|
34
|
+
return 'Value is not a valid SVG.';
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const ImageStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
40
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Image),
|
|
41
|
+
value: svg()
|
|
42
|
+
}));
|
|
43
|
+
const image = (0, _builder.createBuilder)(_nodes.NodeType.Image, ImageStruct, [
|
|
44
|
+
'value'
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/image.ts"],"sourcesContent":["import isSvg from 'is-svg';\nimport type { Infer } from 'superstruct';\nimport { assign, literal, object, refine, string } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\n\n/**\n * Get a Struct that validates a string as a valid SVG.\n *\n * @returns A Struct that validates a string as a valid SVG.\n * @internal\n */\nexport function svg() {\n return refine(string(), 'SVG', (value) => {\n if (!isSvg(value)) {\n return 'Value is not a valid SVG.';\n }\n\n return true;\n });\n}\n\nexport const ImageStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Image),\n value: svg(),\n }),\n);\n\n/**\n * An image node, that renders an SVG image.\n *\n * @property type - The type of the node. Must be the string `image`.\n * @property value - The SVG image to be rendered.\n */\nexport type Image = Infer<typeof ImageStruct>;\n\n/**\n * Create an {@link Image} node.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `value` property.\n * @param args.value - The SVG image to be rendered. Must be a valid SVG string.\n * @returns The image node as object. Other image formats are supported by\n * embedding them as data URLs in the SVG.\n * @example\n * const node = image({ value: '<svg />' });\n * const node = image('<svg />');\n */\nexport const image = createBuilder(NodeType.Image, ImageStruct, ['value']);\n"],"names":["svg","ImageStruct","image","refine","string","value","isSvg","assign","NodeStruct","object","type","literal","NodeType","Image","createBuilder"],"mappings":";;;;;;;;;;;IAagBA,GAAG;eAAHA;;IAUHC,WAAW;eAAXA;;IA4BAC,KAAK;eAALA;;;8DAnDK;6BAEsC;yBAE1B;uBACO;;;;;;AAQ9B,SAASF;IACd,OAAOG,IAAAA,mBAAM,EAACC,IAAAA,mBAAM,KAAI,OAAO,CAACC;QAC9B,IAAI,CAACC,IAAAA,cAAK,EAACD,QAAQ;YACjB,OAAO;QACT;QAEA,OAAO;IACT;AACF;AAEO,MAAMJ,cAAcM,IAAAA,mBAAM,EAC/BC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,KAAK;IAC5BR,OAAOL;AACT;AAuBK,MAAME,QAAQY,IAAAA,sBAAa,EAACF,eAAQ,CAACC,KAAK,EAAEZ,aAAa;IAAC;CAAQ"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
image: function() {
|
|
13
|
+
return _image.image;
|
|
14
|
+
},
|
|
15
|
+
ImageStruct: function() {
|
|
16
|
+
return _image.ImageStruct;
|
|
17
|
+
},
|
|
18
|
+
ComponentStruct: function() {
|
|
19
|
+
return _panel.ComponentStruct;
|
|
20
|
+
},
|
|
21
|
+
panel: function() {
|
|
22
|
+
return _panel.panel;
|
|
23
|
+
},
|
|
24
|
+
PanelStruct: function() {
|
|
25
|
+
return _panel.PanelStruct;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
_export_star(require("./copyable"), exports);
|
|
29
|
+
_export_star(require("./divider"), exports);
|
|
30
|
+
_export_star(require("./heading"), exports);
|
|
31
|
+
const _image = require("./image");
|
|
32
|
+
const _panel = require("./panel");
|
|
33
|
+
_export_star(require("./spinner"), exports);
|
|
34
|
+
_export_star(require("./text"), exports);
|
|
35
|
+
function _export_star(from, to) {
|
|
36
|
+
Object.keys(from).forEach(function(k) {
|
|
37
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
38
|
+
Object.defineProperty(to, k, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function() {
|
|
41
|
+
return from[k];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return from;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/index.ts"],"sourcesContent":["export * from './copyable';\nexport * from './divider';\nexport * from './heading';\nexport type { Image } from './image';\nexport { image, ImageStruct } from './image';\nexport type { Component, Panel } from './panel';\nexport { ComponentStruct, panel, PanelStruct } from './panel';\nexport * from './spinner';\nexport * from './text';\n"],"names":["image","ImageStruct","ComponentStruct","panel","PanelStruct"],"mappings":";;;;;;;;;;;IAISA,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;IAElBC,eAAe;eAAfA,sBAAe;;IAAEC,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;;qBAN9B;qBACA;qBACA;uBAEqB;uBAEiB;qBACtC;qBACA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
ParentStruct: function() {
|
|
13
|
+
return ParentStruct;
|
|
14
|
+
},
|
|
15
|
+
PanelStruct: function() {
|
|
16
|
+
return PanelStruct;
|
|
17
|
+
},
|
|
18
|
+
panel: function() {
|
|
19
|
+
return panel;
|
|
20
|
+
},
|
|
21
|
+
ComponentStruct: function() {
|
|
22
|
+
return ComponentStruct;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const _superstruct = require("superstruct");
|
|
26
|
+
const _builder = require("../builder");
|
|
27
|
+
const _nodes = require("../nodes");
|
|
28
|
+
const _copyable = require("./copyable");
|
|
29
|
+
const _divider = require("./divider");
|
|
30
|
+
const _heading = require("./heading");
|
|
31
|
+
const _image = require("./image");
|
|
32
|
+
const _spinner = require("./spinner");
|
|
33
|
+
const _text = require("./text");
|
|
34
|
+
const ParentStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
35
|
+
// This node references itself indirectly, so we need to use `lazy()`.
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
37
|
+
children: (0, _superstruct.array)((0, _superstruct.lazy)(()=>ComponentStruct))
|
|
38
|
+
}));
|
|
39
|
+
const PanelStruct = (0, _superstruct.assign)(ParentStruct, (0, _superstruct.object)({
|
|
40
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Panel)
|
|
41
|
+
}));
|
|
42
|
+
const panel = (0, _builder.createBuilder)(_nodes.NodeType.Panel, PanelStruct, [
|
|
43
|
+
'children'
|
|
44
|
+
]);
|
|
45
|
+
const ComponentStruct = (0, _superstruct.union)([
|
|
46
|
+
_copyable.CopyableStruct,
|
|
47
|
+
_divider.DividerStruct,
|
|
48
|
+
_heading.HeadingStruct,
|
|
49
|
+
_image.ImageStruct,
|
|
50
|
+
PanelStruct,
|
|
51
|
+
_spinner.SpinnerStruct,
|
|
52
|
+
_text.TextStruct
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/panel.ts"],"sourcesContent":["import type { Infer, Struct } from 'superstruct';\nimport { array, assign, lazy, literal, object, union } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\nimport { CopyableStruct } from './copyable';\nimport { DividerStruct } from './divider';\nimport { HeadingStruct } from './heading';\nimport { ImageStruct } from './image';\nimport { SpinnerStruct } from './spinner';\nimport { TextStruct } from './text';\n\n/**\n * @internal\n */\nexport const ParentStruct = assign(\n NodeStruct,\n object({\n // This node references itself indirectly, so we need to use `lazy()`.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n children: array(lazy(() => ComponentStruct)),\n }),\n);\n\n/**\n * A node which supports child nodes. This is used for nodes that render their\n * children, such as {@link Panel}.\n *\n * @property type - The type of the node.\n * @property children - The children of the node\n * @internal\n */\nexport type Parent = Infer<typeof ParentStruct>;\n\n/**\n * @internal\n */\nexport const PanelStruct: Struct<Panel> = assign(\n ParentStruct,\n object({\n type: literal(NodeType.Panel),\n }),\n);\n\n/**\n * A panel node, which renders its children.\n *\n * @property type - The type of the node, must be the string 'text'.\n * @property value - The text content of the node, either as plain text, or as a\n * markdown string.\n */\n// This node references itself indirectly, so it cannot be inferred.\nexport type Panel = {\n type: NodeType.Panel;\n children: Component[];\n};\n\n/**\n * Create a {@link Panel} node.\n *\n * @param args - The node arguments. This can be either an array of children, or\n * an object with a `children` property.\n * @param args.children - The child nodes of the panel. This can be any valid\n * {@link Component}.\n * @returns The panel node as object.\n * @example\n * const node = panel({\n * children: [\n * heading({ text: 'Hello, world!' }),\n * text({ text: 'This is a panel.' }),\n * ],\n * });\n *\n * const node = panel([\n * heading('Hello, world!'),\n * text('This is a panel.'),\n * ]);\n */\nexport const panel = createBuilder(NodeType.Panel, PanelStruct, ['children']);\n\n// This is defined separately from `Component` to avoid circular dependencies.\nexport const ComponentStruct = union([\n CopyableStruct,\n DividerStruct,\n HeadingStruct,\n ImageStruct,\n PanelStruct,\n SpinnerStruct,\n TextStruct,\n]);\n\n/**\n * All supported component types.\n */\nexport type Component = Infer<typeof ComponentStruct>;\n"],"names":["ParentStruct","PanelStruct","panel","ComponentStruct","assign","NodeStruct","object","children","array","lazy","type","literal","NodeType","Panel","createBuilder","union","CopyableStruct","DividerStruct","HeadingStruct","ImageStruct","SpinnerStruct","TextStruct"],"mappings":";;;;;;;;;;;IAeaA,YAAY;eAAZA;;IAsBAC,WAAW;eAAXA;;IAyCAC,KAAK;eAALA;;IAGAC,eAAe;eAAfA;;;6BAhF+C;yBAE9B;uBACO;0BACN;yBACD;yBACA;uBACF;yBACE;sBACH;AAKpB,MAAMH,eAAeI,IAAAA,mBAAM,EAChCC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACL,sEAAsE;IACtE,mEAAmE;IACnEC,UAAUC,IAAAA,kBAAK,EAACC,IAAAA,iBAAI,EAAC,IAAMN;AAC7B;AAgBK,MAAMF,cAA6BG,IAAAA,mBAAM,EAC9CJ,cACAM,IAAAA,mBAAM,EAAC;IACLI,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,KAAK;AAC9B;AAqCK,MAAMX,QAAQY,IAAAA,sBAAa,EAACF,eAAQ,CAACC,KAAK,EAAEZ,aAAa;IAAC;CAAW;AAGrE,MAAME,kBAAkBY,IAAAA,kBAAK,EAAC;IACnCC,wBAAc;IACdC,sBAAa;IACbC,sBAAa;IACbC,kBAAW;IACXlB;IACAmB,sBAAa;IACbC,gBAAU;CACX"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
SpinnerStruct: function() {
|
|
13
|
+
return SpinnerStruct;
|
|
14
|
+
},
|
|
15
|
+
spinner: function() {
|
|
16
|
+
return spinner;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _superstruct = require("superstruct");
|
|
20
|
+
const _builder = require("../builder");
|
|
21
|
+
const _nodes = require("../nodes");
|
|
22
|
+
const SpinnerStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
23
|
+
type: (0, _superstruct.literal)(_nodes.NodeType.Spinner)
|
|
24
|
+
}));
|
|
25
|
+
const spinner = (0, _builder.createBuilder)(_nodes.NodeType.Spinner, SpinnerStruct);
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/ui/components/spinner.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\n\nexport const SpinnerStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Spinner),\n }),\n);\n\n/**\n * A spinner node, that renders a spinner, either as a full-screen overlay, or\n * inline when nested inside a {@link Panel}.\n */\nexport type Spinner = Infer<typeof SpinnerStruct>;\n\n/**\n * Create a {@link Spinner} node.\n *\n * @returns The spinner node as object.\n * @example\n * const node = spinner();\n */\nexport const spinner = createBuilder(NodeType.Spinner, SpinnerStruct);\n"],"names":["SpinnerStruct","spinner","assign","NodeStruct","object","type","literal","NodeType","Spinner","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IAoBAC,OAAO;eAAPA;;;6BAzB2B;yBAEV;uBACO;AAE9B,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;AAChC;AAgBK,MAAMP,UAAUQ,IAAAA,sBAAa,EAACF,eAAQ,CAACC,OAAO,EAAER"}
|