@metamask-previews/app-metadata-controller 0.0.0-preview-8365901

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 ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ [Unreleased]: https://github.com/MetaMask/core/
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 MetaMask
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # `@metamask/app-metadata-controller`
2
+
3
+ Manages the Metadata for the App
4
+
5
+ ## Installation
6
+
7
+ `yarn add @metamask/app-metadata-controller`
8
+
9
+ or
10
+
11
+ `npm install @metamask/app-metadata-controller`
12
+
13
+ ## Contributing
14
+
15
+ This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ 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");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _AppMetadataController_instances, _AppMetadataController_updateAppVersion, _AppMetadataController_updateMigrationVersion;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AppMetadataController = exports.getDefaultAppMetadataControllerState = void 0;
10
+ const base_controller_1 = require("@metamask/base-controller");
11
+ // Unique name for the controller
12
+ const controllerName = 'AppMetadataController';
13
+ /**
14
+ * Constructs the default {@link AppMetadataController} state. This allows
15
+ * consumers to provide a partial state object when initializing the controller
16
+ * and also helps in constructing complete state objects for this controller in
17
+ * tests.
18
+ *
19
+ * @returns The default {@link AppMetadataController} state.
20
+ */
21
+ const getDefaultAppMetadataControllerState = () => ({
22
+ currentAppVersion: '',
23
+ previousAppVersion: '',
24
+ previousMigrationVersion: 0,
25
+ currentMigrationVersion: 0,
26
+ });
27
+ exports.getDefaultAppMetadataControllerState = getDefaultAppMetadataControllerState;
28
+ /**
29
+ * Metadata configuration for the {@link AppMetadataController}.
30
+ *
31
+ * Defines persistence and anonymity settings for each state property.
32
+ */
33
+ const controllerMetadata = {
34
+ currentAppVersion: {
35
+ persist: true,
36
+ anonymous: true,
37
+ },
38
+ previousAppVersion: {
39
+ persist: true,
40
+ anonymous: true,
41
+ },
42
+ previousMigrationVersion: {
43
+ persist: true,
44
+ anonymous: true,
45
+ },
46
+ currentMigrationVersion: {
47
+ persist: true,
48
+ anonymous: true,
49
+ },
50
+ };
51
+ /**
52
+ * The AppMetadata controller stores metadata about the current extension instance,
53
+ * including the currently and previously installed versions, and the most recently
54
+ * run migration.
55
+ *
56
+ */
57
+ class AppMetadataController extends base_controller_1.BaseController {
58
+ /**
59
+ * Constructs a AppMetadata controller.
60
+ *
61
+ * @param options - the controller options
62
+ * @param options.state - Initial controller state.
63
+ * @param options.messenger - Messenger used to communicate with BaseV2 controller.
64
+ * @param options.currentMigrationVersion - The migration version to store in state.
65
+ * @param options.currentAppVersion - The app version to store in state.
66
+ */
67
+ constructor({ state = {}, messenger, currentAppVersion = '', currentMigrationVersion = 0, }) {
68
+ super({
69
+ name: controllerName,
70
+ metadata: controllerMetadata,
71
+ state: {
72
+ ...(0, exports.getDefaultAppMetadataControllerState)(),
73
+ ...state,
74
+ },
75
+ messenger,
76
+ });
77
+ _AppMetadataController_instances.add(this);
78
+ __classPrivateFieldGet(this, _AppMetadataController_instances, "m", _AppMetadataController_updateAppVersion).call(this, currentAppVersion);
79
+ __classPrivateFieldGet(this, _AppMetadataController_instances, "m", _AppMetadataController_updateMigrationVersion).call(this, currentMigrationVersion);
80
+ }
81
+ }
82
+ exports.AppMetadataController = AppMetadataController;
83
+ _AppMetadataController_instances = new WeakSet(), _AppMetadataController_updateAppVersion = function _AppMetadataController_updateAppVersion(newAppVersion) {
84
+ const oldCurrentAppVersion = this.state.currentAppVersion;
85
+ if (newAppVersion !== oldCurrentAppVersion) {
86
+ this.update((state) => {
87
+ state.currentAppVersion = newAppVersion;
88
+ state.previousAppVersion = oldCurrentAppVersion;
89
+ });
90
+ }
91
+ }, _AppMetadataController_updateMigrationVersion = function _AppMetadataController_updateMigrationVersion(newMigrationVersion) {
92
+ const oldCurrentMigrationVersion = this.state.currentMigrationVersion;
93
+ if (newMigrationVersion !== oldCurrentMigrationVersion) {
94
+ this.update((state) => {
95
+ state.previousMigrationVersion = oldCurrentMigrationVersion;
96
+ state.currentMigrationVersion = newMigrationVersion;
97
+ });
98
+ }
99
+ };
100
+ //# sourceMappingURL=AppMetadataController.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppMetadataController.cjs","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+DAA2D;AAQ3D,iCAAiC;AACjC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAsB/C;;;;;;;GAOG;AACI,MAAM,oCAAoC,GAC/C,GAA+B,EAAE,CAAC,CAAC;IACjC,iBAAiB,EAAE,EAAE;IACrB,kBAAkB,EAAE,EAAE;IACtB,wBAAwB,EAAE,CAAC;IAC3B,uBAAuB,EAAE,CAAC;CAC3B,CAAC,CAAC;AANQ,QAAA,oCAAoC,wCAM5C;AAqDL;;;;GAIG;AACH,MAAM,kBAAkB,GAAG;IACzB,iBAAiB,EAAE;QACjB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,kBAAkB,EAAE;QAClB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,wBAAwB,EAAE;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,uBAAuB,EAAE;QACvB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;CACkD,CAAC;AAEtD;;;;;GAKG;AACH,MAAa,qBAAsB,SAAQ,gCAI1C;IACC;;;;;;;;OAQG;IACH,YAAY,EACV,KAAK,GAAG,EAAE,EACV,SAAS,EACT,iBAAiB,GAAG,EAAE,EACtB,uBAAuB,GAAG,CAAC,GACE;QAC7B,KAAK,CAAC;YACJ,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,kBAAkB;YAC5B,KAAK,EAAE;gBACL,GAAG,IAAA,4CAAoC,GAAE;gBACzC,GAAG,KAAK;aACT;YACD,SAAS;SACV,CAAC,CAAC;;QAEH,uBAAA,IAAI,iFAAkB,MAAtB,IAAI,EAAmB,iBAAiB,CAAC,CAAC;QAE1C,uBAAA,IAAI,uFAAwB,MAA5B,IAAI,EAAyB,uBAAuB,CAAC,CAAC;IACxD,CAAC;CAiCF;AAlED,sDAkEC;6IA1BmB,aAAqB;IACrC,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAE1D,IAAI,aAAa,KAAK,oBAAoB,EAAE;QAC1C,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,iBAAiB,GAAG,aAAa,CAAC;YACxC,KAAK,CAAC,kBAAkB,GAAG,oBAAoB,CAAC;QAClD,CAAC,CAAC,CAAC;KACJ;AACH,CAAC,yGAOuB,mBAA2B;IACjD,MAAM,0BAA0B,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAEtE,IAAI,mBAAmB,KAAK,0BAA0B,EAAE;QACtD,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,wBAAwB,GAAG,0BAA0B,CAAC;YAC5D,KAAK,CAAC,uBAAuB,GAAG,mBAAmB,CAAC;QACtD,CAAC,CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n StateMetadata,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n} from '@metamask/base-controller';\n\n// Unique name for the controller\nconst controllerName = 'AppMetadataController';\n\n/**\n * The options that AppMetadataController takes.\n */\nexport type AppMetadataControllerOptions = {\n state?: Partial<AppMetadataControllerState>;\n messenger: AppMetadataControllerMessenger;\n currentMigrationVersion?: number;\n currentAppVersion?: string;\n};\n\n/**\n * The state of the AppMetadataController\n */\nexport type AppMetadataControllerState = {\n currentAppVersion: string;\n previousAppVersion: string;\n previousMigrationVersion: number;\n currentMigrationVersion: number;\n};\n\n/**\n * Constructs the default {@link AppMetadataController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link AppMetadataController} state.\n */\nexport const getDefaultAppMetadataControllerState =\n (): AppMetadataControllerState => ({\n currentAppVersion: '',\n previousAppVersion: '',\n previousMigrationVersion: 0,\n currentMigrationVersion: 0,\n });\n\n/**\n * Returns the state of the {@link AppMetadataController}.\n */\nexport type AppMetadataControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AppMetadataControllerState\n>;\n\n/**\n * Actions exposed by the {@link AppMetadataController}.\n */\nexport type AppMetadataControllerActions = AppMetadataControllerGetStateAction;\n\n/**\n * Event emitted when the state of the {@link AppMetadataController} changes.\n */\nexport type AppMetadataControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AppMetadataControllerState\n>;\n\n/**\n * Events that can be emitted by the {@link AppMetadataController}\n */\nexport type AppMetadataControllerEvents = AppMetadataControllerStateChangeEvent;\n\n/**\n * Actions that this controller is allowed to call.\n * Currently set to never as this controller doesn't call any other controllers.\n */\ntype AllowedActions = never;\n\n/**\n * Events that this controller is allowed to subscribe.\n */\ntype AllowedEvents = never;\n\n/**\n * Messenger type for the {@link AppMetadataController}.\n *\n * @returns A restricted messenger type that defines the allowed actions and events\n * for the AppMetadataController\n */\nexport type AppMetadataControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n AppMetadataControllerActions | AllowedActions,\n AppMetadataControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Metadata configuration for the {@link AppMetadataController}.\n *\n * Defines persistence and anonymity settings for each state property.\n */\nconst controllerMetadata = {\n currentAppVersion: {\n persist: true,\n anonymous: true,\n },\n previousAppVersion: {\n persist: true,\n anonymous: true,\n },\n previousMigrationVersion: {\n persist: true,\n anonymous: true,\n },\n currentMigrationVersion: {\n persist: true,\n anonymous: true,\n },\n} satisfies StateMetadata<AppMetadataControllerState>;\n\n/**\n * The AppMetadata controller stores metadata about the current extension instance,\n * including the currently and previously installed versions, and the most recently\n * run migration.\n *\n */\nexport class AppMetadataController extends BaseController<\n typeof controllerName,\n AppMetadataControllerState,\n AppMetadataControllerMessenger\n> {\n /**\n * Constructs a AppMetadata controller.\n *\n * @param options - the controller options\n * @param options.state - Initial controller state.\n * @param options.messenger - Messenger used to communicate with BaseV2 controller.\n * @param options.currentMigrationVersion - The migration version to store in state.\n * @param options.currentAppVersion - The app version to store in state.\n */\n constructor({\n state = {},\n messenger,\n currentAppVersion = '',\n currentMigrationVersion = 0,\n }: AppMetadataControllerOptions) {\n super({\n name: controllerName,\n metadata: controllerMetadata,\n state: {\n ...getDefaultAppMetadataControllerState(),\n ...state,\n },\n messenger,\n });\n\n this.#updateAppVersion(currentAppVersion);\n\n this.#updateMigrationVersion(currentMigrationVersion);\n }\n\n /**\n * Updates the currentAppVersion in state, and sets the previousAppVersion to the old currentAppVersion.\n *\n * @param newAppVersion - The new app version to store in state.\n */\n #updateAppVersion(newAppVersion: string): void {\n const oldCurrentAppVersion = this.state.currentAppVersion;\n\n if (newAppVersion !== oldCurrentAppVersion) {\n this.update((state) => {\n state.currentAppVersion = newAppVersion;\n state.previousAppVersion = oldCurrentAppVersion;\n });\n }\n }\n\n /**\n * Updates the migrationVersion in state.\n *\n * @param newMigrationVersion - The new migration version to store in state.\n */\n #updateMigrationVersion(newMigrationVersion: number): void {\n const oldCurrentMigrationVersion = this.state.currentMigrationVersion;\n\n if (newMigrationVersion !== oldCurrentMigrationVersion) {\n this.update((state) => {\n state.previousMigrationVersion = oldCurrentMigrationVersion;\n state.currentMigrationVersion = newMigrationVersion;\n });\n }\n }\n}\n"]}
@@ -0,0 +1,83 @@
1
+ import { BaseController } from "@metamask/base-controller";
2
+ import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
3
+ declare const controllerName = "AppMetadataController";
4
+ /**
5
+ * The options that AppMetadataController takes.
6
+ */
7
+ export type AppMetadataControllerOptions = {
8
+ state?: Partial<AppMetadataControllerState>;
9
+ messenger: AppMetadataControllerMessenger;
10
+ currentMigrationVersion?: number;
11
+ currentAppVersion?: string;
12
+ };
13
+ /**
14
+ * The state of the AppMetadataController
15
+ */
16
+ export type AppMetadataControllerState = {
17
+ currentAppVersion: string;
18
+ previousAppVersion: string;
19
+ previousMigrationVersion: number;
20
+ currentMigrationVersion: number;
21
+ };
22
+ /**
23
+ * Constructs the default {@link AppMetadataController} state. This allows
24
+ * consumers to provide a partial state object when initializing the controller
25
+ * and also helps in constructing complete state objects for this controller in
26
+ * tests.
27
+ *
28
+ * @returns The default {@link AppMetadataController} state.
29
+ */
30
+ export declare const getDefaultAppMetadataControllerState: () => AppMetadataControllerState;
31
+ /**
32
+ * Returns the state of the {@link AppMetadataController}.
33
+ */
34
+ export type AppMetadataControllerGetStateAction = ControllerGetStateAction<typeof controllerName, AppMetadataControllerState>;
35
+ /**
36
+ * Actions exposed by the {@link AppMetadataController}.
37
+ */
38
+ export type AppMetadataControllerActions = AppMetadataControllerGetStateAction;
39
+ /**
40
+ * Event emitted when the state of the {@link AppMetadataController} changes.
41
+ */
42
+ export type AppMetadataControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, AppMetadataControllerState>;
43
+ /**
44
+ * Events that can be emitted by the {@link AppMetadataController}
45
+ */
46
+ export type AppMetadataControllerEvents = AppMetadataControllerStateChangeEvent;
47
+ /**
48
+ * Actions that this controller is allowed to call.
49
+ * Currently set to never as this controller doesn't call any other controllers.
50
+ */
51
+ type AllowedActions = never;
52
+ /**
53
+ * Events that this controller is allowed to subscribe.
54
+ */
55
+ type AllowedEvents = never;
56
+ /**
57
+ * Messenger type for the {@link AppMetadataController}.
58
+ *
59
+ * @returns A restricted messenger type that defines the allowed actions and events
60
+ * for the AppMetadataController
61
+ */
62
+ export type AppMetadataControllerMessenger = RestrictedMessenger<typeof controllerName, AppMetadataControllerActions | AllowedActions, AppMetadataControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
63
+ /**
64
+ * The AppMetadata controller stores metadata about the current extension instance,
65
+ * including the currently and previously installed versions, and the most recently
66
+ * run migration.
67
+ *
68
+ */
69
+ export declare class AppMetadataController extends BaseController<typeof controllerName, AppMetadataControllerState, AppMetadataControllerMessenger> {
70
+ #private;
71
+ /**
72
+ * Constructs a AppMetadata controller.
73
+ *
74
+ * @param options - the controller options
75
+ * @param options.state - Initial controller state.
76
+ * @param options.messenger - Messenger used to communicate with BaseV2 controller.
77
+ * @param options.currentMigrationVersion - The migration version to store in state.
78
+ * @param options.currentAppVersion - The app version to store in state.
79
+ */
80
+ constructor({ state, messenger, currentAppVersion, currentMigrationVersion, }: AppMetadataControllerOptions);
81
+ }
82
+ export {};
83
+ //# sourceMappingURL=AppMetadataController.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppMetadataController.d.cts","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAEV,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACpB,kCAAkC;AAGnC,QAAA,MAAM,cAAc,0BAA0B,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC5C,SAAS,EAAE,8BAA8B,CAAC;IAC1C,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oCAAoC,QAC3C,0BAKF,CAAC;AAEL;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,wBAAwB,CACxE,OAAO,cAAc,EACrB,0BAA0B,CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,mCAAmC,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG,0BAA0B,CAC5E,OAAO,cAAc,EACrB,0BAA0B,CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,qCAAqC,CAAC;AAEhF;;;GAGG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,MAAM,8BAA8B,GAAG,mBAAmB,CAC9D,OAAO,cAAc,EACrB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,EAC3C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AA0BF;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,cAAc,CACvD,OAAO,cAAc,EACrB,0BAA0B,EAC1B,8BAA8B,CAC/B;;IACC;;;;;;;;OAQG;gBACS,EACV,KAAU,EACV,SAAS,EACT,iBAAsB,EACtB,uBAA2B,GAC5B,EAAE,4BAA4B;CA+ChC"}
@@ -0,0 +1,83 @@
1
+ import { BaseController } from "@metamask/base-controller";
2
+ import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
3
+ declare const controllerName = "AppMetadataController";
4
+ /**
5
+ * The options that AppMetadataController takes.
6
+ */
7
+ export type AppMetadataControllerOptions = {
8
+ state?: Partial<AppMetadataControllerState>;
9
+ messenger: AppMetadataControllerMessenger;
10
+ currentMigrationVersion?: number;
11
+ currentAppVersion?: string;
12
+ };
13
+ /**
14
+ * The state of the AppMetadataController
15
+ */
16
+ export type AppMetadataControllerState = {
17
+ currentAppVersion: string;
18
+ previousAppVersion: string;
19
+ previousMigrationVersion: number;
20
+ currentMigrationVersion: number;
21
+ };
22
+ /**
23
+ * Constructs the default {@link AppMetadataController} state. This allows
24
+ * consumers to provide a partial state object when initializing the controller
25
+ * and also helps in constructing complete state objects for this controller in
26
+ * tests.
27
+ *
28
+ * @returns The default {@link AppMetadataController} state.
29
+ */
30
+ export declare const getDefaultAppMetadataControllerState: () => AppMetadataControllerState;
31
+ /**
32
+ * Returns the state of the {@link AppMetadataController}.
33
+ */
34
+ export type AppMetadataControllerGetStateAction = ControllerGetStateAction<typeof controllerName, AppMetadataControllerState>;
35
+ /**
36
+ * Actions exposed by the {@link AppMetadataController}.
37
+ */
38
+ export type AppMetadataControllerActions = AppMetadataControllerGetStateAction;
39
+ /**
40
+ * Event emitted when the state of the {@link AppMetadataController} changes.
41
+ */
42
+ export type AppMetadataControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, AppMetadataControllerState>;
43
+ /**
44
+ * Events that can be emitted by the {@link AppMetadataController}
45
+ */
46
+ export type AppMetadataControllerEvents = AppMetadataControllerStateChangeEvent;
47
+ /**
48
+ * Actions that this controller is allowed to call.
49
+ * Currently set to never as this controller doesn't call any other controllers.
50
+ */
51
+ type AllowedActions = never;
52
+ /**
53
+ * Events that this controller is allowed to subscribe.
54
+ */
55
+ type AllowedEvents = never;
56
+ /**
57
+ * Messenger type for the {@link AppMetadataController}.
58
+ *
59
+ * @returns A restricted messenger type that defines the allowed actions and events
60
+ * for the AppMetadataController
61
+ */
62
+ export type AppMetadataControllerMessenger = RestrictedMessenger<typeof controllerName, AppMetadataControllerActions | AllowedActions, AppMetadataControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
63
+ /**
64
+ * The AppMetadata controller stores metadata about the current extension instance,
65
+ * including the currently and previously installed versions, and the most recently
66
+ * run migration.
67
+ *
68
+ */
69
+ export declare class AppMetadataController extends BaseController<typeof controllerName, AppMetadataControllerState, AppMetadataControllerMessenger> {
70
+ #private;
71
+ /**
72
+ * Constructs a AppMetadata controller.
73
+ *
74
+ * @param options - the controller options
75
+ * @param options.state - Initial controller state.
76
+ * @param options.messenger - Messenger used to communicate with BaseV2 controller.
77
+ * @param options.currentMigrationVersion - The migration version to store in state.
78
+ * @param options.currentAppVersion - The app version to store in state.
79
+ */
80
+ constructor({ state, messenger, currentAppVersion, currentMigrationVersion, }: AppMetadataControllerOptions);
81
+ }
82
+ export {};
83
+ //# sourceMappingURL=AppMetadataController.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppMetadataController.d.mts","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAEV,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACpB,kCAAkC;AAGnC,QAAA,MAAM,cAAc,0BAA0B,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC5C,SAAS,EAAE,8BAA8B,CAAC;IAC1C,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oCAAoC,QAC3C,0BAKF,CAAC;AAEL;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,wBAAwB,CACxE,OAAO,cAAc,EACrB,0BAA0B,CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,mCAAmC,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG,0BAA0B,CAC5E,OAAO,cAAc,EACrB,0BAA0B,CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,qCAAqC,CAAC;AAEhF;;;GAGG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,MAAM,8BAA8B,GAAG,mBAAmB,CAC9D,OAAO,cAAc,EACrB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,EAC3C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AA0BF;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,cAAc,CACvD,OAAO,cAAc,EACrB,0BAA0B,EAC1B,8BAA8B,CAC/B;;IACC;;;;;;;;OAQG;gBACS,EACV,KAAU,EACV,SAAS,EACT,iBAAsB,EACtB,uBAA2B,GAC5B,EAAE,4BAA4B;CA+ChC"}
@@ -0,0 +1,95 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _AppMetadataController_instances, _AppMetadataController_updateAppVersion, _AppMetadataController_updateMigrationVersion;
7
+ import { BaseController } from "@metamask/base-controller";
8
+ // Unique name for the controller
9
+ const controllerName = 'AppMetadataController';
10
+ /**
11
+ * Constructs the default {@link AppMetadataController} state. This allows
12
+ * consumers to provide a partial state object when initializing the controller
13
+ * and also helps in constructing complete state objects for this controller in
14
+ * tests.
15
+ *
16
+ * @returns The default {@link AppMetadataController} state.
17
+ */
18
+ export const getDefaultAppMetadataControllerState = () => ({
19
+ currentAppVersion: '',
20
+ previousAppVersion: '',
21
+ previousMigrationVersion: 0,
22
+ currentMigrationVersion: 0,
23
+ });
24
+ /**
25
+ * Metadata configuration for the {@link AppMetadataController}.
26
+ *
27
+ * Defines persistence and anonymity settings for each state property.
28
+ */
29
+ const controllerMetadata = {
30
+ currentAppVersion: {
31
+ persist: true,
32
+ anonymous: true,
33
+ },
34
+ previousAppVersion: {
35
+ persist: true,
36
+ anonymous: true,
37
+ },
38
+ previousMigrationVersion: {
39
+ persist: true,
40
+ anonymous: true,
41
+ },
42
+ currentMigrationVersion: {
43
+ persist: true,
44
+ anonymous: true,
45
+ },
46
+ };
47
+ /**
48
+ * The AppMetadata controller stores metadata about the current extension instance,
49
+ * including the currently and previously installed versions, and the most recently
50
+ * run migration.
51
+ *
52
+ */
53
+ export class AppMetadataController extends BaseController {
54
+ /**
55
+ * Constructs a AppMetadata controller.
56
+ *
57
+ * @param options - the controller options
58
+ * @param options.state - Initial controller state.
59
+ * @param options.messenger - Messenger used to communicate with BaseV2 controller.
60
+ * @param options.currentMigrationVersion - The migration version to store in state.
61
+ * @param options.currentAppVersion - The app version to store in state.
62
+ */
63
+ constructor({ state = {}, messenger, currentAppVersion = '', currentMigrationVersion = 0, }) {
64
+ super({
65
+ name: controllerName,
66
+ metadata: controllerMetadata,
67
+ state: {
68
+ ...getDefaultAppMetadataControllerState(),
69
+ ...state,
70
+ },
71
+ messenger,
72
+ });
73
+ _AppMetadataController_instances.add(this);
74
+ __classPrivateFieldGet(this, _AppMetadataController_instances, "m", _AppMetadataController_updateAppVersion).call(this, currentAppVersion);
75
+ __classPrivateFieldGet(this, _AppMetadataController_instances, "m", _AppMetadataController_updateMigrationVersion).call(this, currentMigrationVersion);
76
+ }
77
+ }
78
+ _AppMetadataController_instances = new WeakSet(), _AppMetadataController_updateAppVersion = function _AppMetadataController_updateAppVersion(newAppVersion) {
79
+ const oldCurrentAppVersion = this.state.currentAppVersion;
80
+ if (newAppVersion !== oldCurrentAppVersion) {
81
+ this.update((state) => {
82
+ state.currentAppVersion = newAppVersion;
83
+ state.previousAppVersion = oldCurrentAppVersion;
84
+ });
85
+ }
86
+ }, _AppMetadataController_updateMigrationVersion = function _AppMetadataController_updateMigrationVersion(newMigrationVersion) {
87
+ const oldCurrentMigrationVersion = this.state.currentMigrationVersion;
88
+ if (newMigrationVersion !== oldCurrentMigrationVersion) {
89
+ this.update((state) => {
90
+ state.previousMigrationVersion = oldCurrentMigrationVersion;
91
+ state.currentMigrationVersion = newMigrationVersion;
92
+ });
93
+ }
94
+ };
95
+ //# sourceMappingURL=AppMetadataController.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppMetadataController.mjs","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAQ3D,iCAAiC;AACjC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAsB/C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAC/C,GAA+B,EAAE,CAAC,CAAC;IACjC,iBAAiB,EAAE,EAAE;IACrB,kBAAkB,EAAE,EAAE;IACtB,wBAAwB,EAAE,CAAC;IAC3B,uBAAuB,EAAE,CAAC;CAC3B,CAAC,CAAC;AAqDL;;;;GAIG;AACH,MAAM,kBAAkB,GAAG;IACzB,iBAAiB,EAAE;QACjB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,kBAAkB,EAAE;QAClB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,wBAAwB,EAAE;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,uBAAuB,EAAE;QACvB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;CACkD,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,cAI1C;IACC;;;;;;;;OAQG;IACH,YAAY,EACV,KAAK,GAAG,EAAE,EACV,SAAS,EACT,iBAAiB,GAAG,EAAE,EACtB,uBAAuB,GAAG,CAAC,GACE;QAC7B,KAAK,CAAC;YACJ,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,kBAAkB;YAC5B,KAAK,EAAE;gBACL,GAAG,oCAAoC,EAAE;gBACzC,GAAG,KAAK;aACT;YACD,SAAS;SACV,CAAC,CAAC;;QAEH,uBAAA,IAAI,iFAAkB,MAAtB,IAAI,EAAmB,iBAAiB,CAAC,CAAC;QAE1C,uBAAA,IAAI,uFAAwB,MAA5B,IAAI,EAAyB,uBAAuB,CAAC,CAAC;IACxD,CAAC;CAiCF;6IA1BmB,aAAqB;IACrC,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAE1D,IAAI,aAAa,KAAK,oBAAoB,EAAE;QAC1C,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,iBAAiB,GAAG,aAAa,CAAC;YACxC,KAAK,CAAC,kBAAkB,GAAG,oBAAoB,CAAC;QAClD,CAAC,CAAC,CAAC;KACJ;AACH,CAAC,yGAOuB,mBAA2B;IACjD,MAAM,0BAA0B,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAEtE,IAAI,mBAAmB,KAAK,0BAA0B,EAAE;QACtD,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,wBAAwB,GAAG,0BAA0B,CAAC;YAC5D,KAAK,CAAC,uBAAuB,GAAG,mBAAmB,CAAC;QACtD,CAAC,CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n StateMetadata,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n} from '@metamask/base-controller';\n\n// Unique name for the controller\nconst controllerName = 'AppMetadataController';\n\n/**\n * The options that AppMetadataController takes.\n */\nexport type AppMetadataControllerOptions = {\n state?: Partial<AppMetadataControllerState>;\n messenger: AppMetadataControllerMessenger;\n currentMigrationVersion?: number;\n currentAppVersion?: string;\n};\n\n/**\n * The state of the AppMetadataController\n */\nexport type AppMetadataControllerState = {\n currentAppVersion: string;\n previousAppVersion: string;\n previousMigrationVersion: number;\n currentMigrationVersion: number;\n};\n\n/**\n * Constructs the default {@link AppMetadataController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link AppMetadataController} state.\n */\nexport const getDefaultAppMetadataControllerState =\n (): AppMetadataControllerState => ({\n currentAppVersion: '',\n previousAppVersion: '',\n previousMigrationVersion: 0,\n currentMigrationVersion: 0,\n });\n\n/**\n * Returns the state of the {@link AppMetadataController}.\n */\nexport type AppMetadataControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AppMetadataControllerState\n>;\n\n/**\n * Actions exposed by the {@link AppMetadataController}.\n */\nexport type AppMetadataControllerActions = AppMetadataControllerGetStateAction;\n\n/**\n * Event emitted when the state of the {@link AppMetadataController} changes.\n */\nexport type AppMetadataControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AppMetadataControllerState\n>;\n\n/**\n * Events that can be emitted by the {@link AppMetadataController}\n */\nexport type AppMetadataControllerEvents = AppMetadataControllerStateChangeEvent;\n\n/**\n * Actions that this controller is allowed to call.\n * Currently set to never as this controller doesn't call any other controllers.\n */\ntype AllowedActions = never;\n\n/**\n * Events that this controller is allowed to subscribe.\n */\ntype AllowedEvents = never;\n\n/**\n * Messenger type for the {@link AppMetadataController}.\n *\n * @returns A restricted messenger type that defines the allowed actions and events\n * for the AppMetadataController\n */\nexport type AppMetadataControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n AppMetadataControllerActions | AllowedActions,\n AppMetadataControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Metadata configuration for the {@link AppMetadataController}.\n *\n * Defines persistence and anonymity settings for each state property.\n */\nconst controllerMetadata = {\n currentAppVersion: {\n persist: true,\n anonymous: true,\n },\n previousAppVersion: {\n persist: true,\n anonymous: true,\n },\n previousMigrationVersion: {\n persist: true,\n anonymous: true,\n },\n currentMigrationVersion: {\n persist: true,\n anonymous: true,\n },\n} satisfies StateMetadata<AppMetadataControllerState>;\n\n/**\n * The AppMetadata controller stores metadata about the current extension instance,\n * including the currently and previously installed versions, and the most recently\n * run migration.\n *\n */\nexport class AppMetadataController extends BaseController<\n typeof controllerName,\n AppMetadataControllerState,\n AppMetadataControllerMessenger\n> {\n /**\n * Constructs a AppMetadata controller.\n *\n * @param options - the controller options\n * @param options.state - Initial controller state.\n * @param options.messenger - Messenger used to communicate with BaseV2 controller.\n * @param options.currentMigrationVersion - The migration version to store in state.\n * @param options.currentAppVersion - The app version to store in state.\n */\n constructor({\n state = {},\n messenger,\n currentAppVersion = '',\n currentMigrationVersion = 0,\n }: AppMetadataControllerOptions) {\n super({\n name: controllerName,\n metadata: controllerMetadata,\n state: {\n ...getDefaultAppMetadataControllerState(),\n ...state,\n },\n messenger,\n });\n\n this.#updateAppVersion(currentAppVersion);\n\n this.#updateMigrationVersion(currentMigrationVersion);\n }\n\n /**\n * Updates the currentAppVersion in state, and sets the previousAppVersion to the old currentAppVersion.\n *\n * @param newAppVersion - The new app version to store in state.\n */\n #updateAppVersion(newAppVersion: string): void {\n const oldCurrentAppVersion = this.state.currentAppVersion;\n\n if (newAppVersion !== oldCurrentAppVersion) {\n this.update((state) => {\n state.currentAppVersion = newAppVersion;\n state.previousAppVersion = oldCurrentAppVersion;\n });\n }\n }\n\n /**\n * Updates the migrationVersion in state.\n *\n * @param newMigrationVersion - The new migration version to store in state.\n */\n #updateMigrationVersion(newMigrationVersion: number): void {\n const oldCurrentMigrationVersion = this.state.currentMigrationVersion;\n\n if (newMigrationVersion !== oldCurrentMigrationVersion) {\n this.update((state) => {\n state.previousMigrationVersion = oldCurrentMigrationVersion;\n state.currentMigrationVersion = newMigrationVersion;\n });\n }\n }\n}\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppMetadataController = exports.getDefaultAppMetadataControllerState = void 0;
4
+ var AppMetadataController_1 = require("./AppMetadataController.cjs");
5
+ Object.defineProperty(exports, "getDefaultAppMetadataControllerState", { enumerable: true, get: function () { return AppMetadataController_1.getDefaultAppMetadataControllerState; } });
6
+ Object.defineProperty(exports, "AppMetadataController", { enumerable: true, get: function () { return AppMetadataController_1.AppMetadataController; } });
7
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,qEAGiC;AAF/B,6IAAA,oCAAoC,OAAA;AACpC,8HAAA,qBAAqB,OAAA","sourcesContent":["export type {\n AppMetadataControllerActions,\n AppMetadataControllerEvents,\n AppMetadataControllerGetStateAction,\n AppMetadataControllerMessenger,\n AppMetadataControllerState,\n AppMetadataControllerStateChangeEvent,\n} from './AppMetadataController';\nexport {\n getDefaultAppMetadataControllerState,\n AppMetadataController,\n} from './AppMetadataController';\n"]}
@@ -0,0 +1,3 @@
1
+ export type { AppMetadataControllerActions, AppMetadataControllerEvents, AppMetadataControllerGetStateAction, AppMetadataControllerMessenger, AppMetadataControllerState, AppMetadataControllerStateChangeEvent, } from "./AppMetadataController.cjs";
2
+ export { getDefaultAppMetadataControllerState, AppMetadataController, } from "./AppMetadataController.cjs";
3
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,4BAA4B,EAC5B,2BAA2B,EAC3B,mCAAmC,EACnC,8BAA8B,EAC9B,0BAA0B,EAC1B,qCAAqC,GACtC,oCAAgC;AACjC,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GACtB,oCAAgC"}
@@ -0,0 +1,3 @@
1
+ export type { AppMetadataControllerActions, AppMetadataControllerEvents, AppMetadataControllerGetStateAction, AppMetadataControllerMessenger, AppMetadataControllerState, AppMetadataControllerStateChangeEvent, } from "./AppMetadataController.mjs";
2
+ export { getDefaultAppMetadataControllerState, AppMetadataController, } from "./AppMetadataController.mjs";
3
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,4BAA4B,EAC5B,2BAA2B,EAC3B,mCAAmC,EACnC,8BAA8B,EAC9B,0BAA0B,EAC1B,qCAAqC,GACtC,oCAAgC;AACjC,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GACtB,oCAAgC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export { getDefaultAppMetadataControllerState, AppMetadataController } from "./AppMetadataController.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,oCAAoC,EACpC,qBAAqB,EACtB,oCAAgC","sourcesContent":["export type {\n AppMetadataControllerActions,\n AppMetadataControllerEvents,\n AppMetadataControllerGetStateAction,\n AppMetadataControllerMessenger,\n AppMetadataControllerState,\n AppMetadataControllerStateChangeEvent,\n} from './AppMetadataController';\nexport {\n getDefaultAppMetadataControllerState,\n AppMetadataController,\n} from './AppMetadataController';\n"]}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@metamask-previews/app-metadata-controller",
3
+ "version": "0.0.0-preview-8365901",
4
+ "description": "Manages requests that for app metadata",
5
+ "keywords": [
6
+ "MetaMask",
7
+ "Ethereum"
8
+ ],
9
+ "homepage": "https://github.com/MetaMask/core/tree/main/packages/app-metadata-controller#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/MetaMask/core/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/MetaMask/core.git"
16
+ },
17
+ "license": "MIT",
18
+ "sideEffects": false,
19
+ "exports": {
20
+ ".": {
21
+ "import": {
22
+ "types": "./dist/index.d.mts",
23
+ "default": "./dist/index.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.cts",
27
+ "default": "./dist/index.cjs"
28
+ }
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "main": "./dist/index.cjs",
33
+ "types": "./dist/index.d.cts",
34
+ "files": [
35
+ "dist/"
36
+ ],
37
+ "scripts": {
38
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
39
+ "build:docs": "typedoc",
40
+ "changelog:update": "../../scripts/update-changelog.sh @metamask/app-metadata-controller",
41
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/app-metadata-controller",
42
+ "publish:preview": "yarn npm publish --tag preview",
43
+ "since-latest-release": "../../scripts/since-latest-release.sh",
44
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
45
+ "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
46
+ "test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
47
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
48
+ },
49
+ "dependencies": {
50
+ "@metamask/base-controller": "^8.0.0"
51
+ },
52
+ "devDependencies": {
53
+ "@metamask/auto-changelog": "^3.4.4",
54
+ "@types/jest": "^27.4.1",
55
+ "deepmerge": "^4.2.2",
56
+ "jest": "^27.5.1",
57
+ "sinon": "^9.2.4",
58
+ "ts-jest": "^27.1.4",
59
+ "typedoc": "^0.24.8",
60
+ "typedoc-plugin-missing-exports": "^2.0.0",
61
+ "typescript": "~5.2.2"
62
+ },
63
+ "engines": {
64
+ "node": "^18.18 || >=20"
65
+ },
66
+ "publishConfig": {
67
+ "access": "public",
68
+ "registry": "https://registry.npmjs.org/"
69
+ }
70
+ }