@metamask-previews/app-metadata-controller 1.1.0-preview-e9856975 → 1.1.0-preview-83095132

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 CHANGED
@@ -15,8 +15,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
 
16
16
  ### Changed
17
17
 
18
- - **BREAKING:** Use new `Messenger` from `@metamask/messenger` ([#6385](https://github.com/MetaMask/core/pull/6385))
19
- - Previously, `AppMetadataController` accepted a `RestrictedMessenger` instance from `@metamask/base-controller`.
20
18
  - Bump `@metamask/base-controller` from `^8.0.0` to `^8.4.1` ([#5722](https://github.com/MetaMask/core/pull/5722), [#6284](https://github.com/MetaMask/core/pull/6284), [#6355](https://github.com/MetaMask/core/pull/6355), [#6465](https://github.com/MetaMask/core/pull/6465), [#6632](https://github.com/MetaMask/core/pull/6632), [#6807](https://github.com/MetaMask/core/pull/6807))
21
19
 
22
20
  ## [1.0.0]
@@ -7,7 +7,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
7
7
  var _AppMetadataController_instances, _AppMetadataController_updateAppVersion, _AppMetadataController_updateMigrationVersion;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.AppMetadataController = exports.getDefaultAppMetadataControllerState = void 0;
10
- const next_1 = require("@metamask/base-controller/next");
10
+ const base_controller_1 = require("@metamask/base-controller");
11
11
  // Unique name for the controller
12
12
  const controllerName = 'AppMetadataController';
13
13
  /**
@@ -34,25 +34,25 @@ const controllerMetadata = {
34
34
  currentAppVersion: {
35
35
  includeInStateLogs: true,
36
36
  persist: true,
37
- includeInDebugSnapshot: true,
37
+ anonymous: true,
38
38
  usedInUi: false,
39
39
  },
40
40
  previousAppVersion: {
41
41
  includeInStateLogs: true,
42
42
  persist: true,
43
- includeInDebugSnapshot: true,
43
+ anonymous: true,
44
44
  usedInUi: false,
45
45
  },
46
46
  previousMigrationVersion: {
47
47
  includeInStateLogs: true,
48
48
  persist: true,
49
- includeInDebugSnapshot: true,
49
+ anonymous: true,
50
50
  usedInUi: false,
51
51
  },
52
52
  currentMigrationVersion: {
53
53
  includeInStateLogs: true,
54
54
  persist: true,
55
- includeInDebugSnapshot: true,
55
+ anonymous: true,
56
56
  usedInUi: false,
57
57
  },
58
58
  };
@@ -62,7 +62,7 @@ const controllerMetadata = {
62
62
  * run migration.
63
63
  *
64
64
  */
65
- class AppMetadataController extends next_1.BaseController {
65
+ class AppMetadataController extends base_controller_1.BaseController {
66
66
  /**
67
67
  * Constructs a AppMetadata controller.
68
68
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AppMetadataController.cjs","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":";;;;;;;;;AAKA,yDAAgE;AAGhE,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;AAmDL;;;;GAIG;AACH,MAAM,kBAAkB,GAAG;IACzB,iBAAiB,EAAE;QACjB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,kBAAkB,EAAE;QAClB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,wBAAwB,EAAE;QACxB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,uBAAuB,EAAE;QACv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CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["import type {\n StateMetadata,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller/next';\nimport { BaseController } from '@metamask/base-controller/next';\nimport type { Messenger } from '@metamask/messenger';\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 = Messenger<\n typeof controllerName,\n AppMetadataControllerActions | AllowedActions,\n AppMetadataControllerEvents | AllowedEvents\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 includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n previousAppVersion: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n previousMigrationVersion: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n currentMigrationVersion: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\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"]}
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,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK;KAChB;IACD,kBAAkB,EAAE;QAClB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK;KAChB;IACD,wBAAwB,EAAE;QACxB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK;KAChB;IACD,uBAAuB,EAAE;QACvB,kBAAkB,EAAE,IAAI;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","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 includeInStateLogs: true,\n persist: true,\n anonymous: true,\n usedInUi: false,\n },\n previousAppVersion: {\n includeInStateLogs: true,\n persist: true,\n anonymous: true,\n usedInUi: false,\n },\n previousMigrationVersion: {\n includeInStateLogs: true,\n persist: true,\n anonymous: true,\n usedInUi: false,\n },\n currentMigrationVersion: {\n includeInStateLogs: true,\n persist: true,\n anonymous: true,\n usedInUi: false,\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"]}
@@ -1,6 +1,5 @@
1
- import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller/next";
2
- import { BaseController } from "@metamask/base-controller/next";
3
- import type { Messenger } from "@metamask/messenger";
1
+ import { BaseController } from "@metamask/base-controller";
2
+ import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
4
3
  declare const controllerName = "AppMetadataController";
5
4
  /**
6
5
  * The options that AppMetadataController takes.
@@ -60,7 +59,7 @@ type AllowedEvents = never;
60
59
  * @returns A restricted messenger type that defines the allowed actions and events
61
60
  * for the AppMetadataController
62
61
  */
63
- export type AppMetadataControllerMessenger = Messenger<typeof controllerName, AppMetadataControllerActions | AllowedActions, AppMetadataControllerEvents | AllowedEvents>;
62
+ export type AppMetadataControllerMessenger = RestrictedMessenger<typeof controllerName, AppMetadataControllerActions | AllowedActions, AppMetadataControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
64
63
  /**
65
64
  * The AppMetadata controller stores metadata about the current extension instance,
66
65
  * including the currently and previously installed versions, and the most recently
@@ -1 +1 @@
1
- {"version":3,"file":"AppMetadataController.d.cts","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,wBAAwB,EACxB,0BAA0B,EAC3B,uCAAuC;AACxC,OAAO,EAAE,cAAc,EAAE,uCAAuC;AAChE,OAAO,KAAK,EAAE,S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G;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;AAkCF;;;;;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"}
@@ -1,6 +1,5 @@
1
- import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller/next";
2
- import { BaseController } from "@metamask/base-controller/next";
3
- import type { Messenger } from "@metamask/messenger";
1
+ import { BaseController } from "@metamask/base-controller";
2
+ import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
4
3
  declare const controllerName = "AppMetadataController";
5
4
  /**
6
5
  * The options that AppMetadataController takes.
@@ -60,7 +59,7 @@ type AllowedEvents = never;
60
59
  * @returns A restricted messenger type that defines the allowed actions and events
61
60
  * for the AppMetadataController
62
61
  */
63
- export type AppMetadataControllerMessenger = Messenger<typeof controllerName, AppMetadataControllerActions | AllowedActions, AppMetadataControllerEvents | AllowedEvents>;
62
+ export type AppMetadataControllerMessenger = RestrictedMessenger<typeof controllerName, AppMetadataControllerActions | AllowedActions, AppMetadataControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
64
63
  /**
65
64
  * The AppMetadata controller stores metadata about the current extension instance,
66
65
  * including the currently and previously installed versions, and the most recently
@@ -1 +1 @@
1
- {"version":3,"file":"AppMetadataController.d.mts","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,wBAAwB,EACxB,0BAA0B,EAC3B,uCAAuC;AACxC,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;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;AAkCF;;;;;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"}
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _AppMetadataController_instances, _AppMetadataController_updateAppVersion, _AppMetadataController_updateMigrationVersion;
7
- import { BaseController } from "@metamask/base-controller/next";
7
+ import { BaseController } from "@metamask/base-controller";
8
8
  // Unique name for the controller
9
9
  const controllerName = 'AppMetadataController';
10
10
  /**
@@ -30,25 +30,25 @@ const controllerMetadata = {
30
30
  currentAppVersion: {
31
31
  includeInStateLogs: true,
32
32
  persist: true,
33
- includeInDebugSnapshot: true,
33
+ anonymous: true,
34
34
  usedInUi: false,
35
35
  },
36
36
  previousAppVersion: {
37
37
  includeInStateLogs: true,
38
38
  persist: true,
39
- includeInDebugSnapshot: true,
39
+ anonymous: true,
40
40
  usedInUi: false,
41
41
  },
42
42
  previousMigrationVersion: {
43
43
  includeInStateLogs: true,
44
44
  persist: true,
45
- includeInDebugSnapshot: true,
45
+ anonymous: true,
46
46
  usedInUi: false,
47
47
  },
48
48
  currentMigrationVersion: {
49
49
  includeInStateLogs: true,
50
50
  persist: true,
51
- includeInDebugSnapshot: true,
51
+ anonymous: true,
52
52
  usedInUi: false,
53
53
  },
54
54
  };
@@ -1 +1 @@
1
- {"version":3,"file":"AppMetadataController.mjs","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":";;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,uCAAuC;AAGhE,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;AAmDL;;;;GAIG;AACH,MAAM,kBAAkB,GAAG;IACzB,iBAAiB,EAAE;QACjB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,kBAAkB,EAAE;QAClB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,wBAAwB,EAAE;QACxB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,uBAAuB,EAAE;QACvB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;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 type {\n StateMetadata,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller/next';\nimport { BaseController } from '@metamask/base-controller/next';\nimport type { Messenger } from '@metamask/messenger';\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 = Messenger<\n typeof controllerName,\n AppMetadataControllerActions | AllowedActions,\n AppMetadataControllerEvents | AllowedEvents\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 includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n previousAppVersion: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n previousMigrationVersion: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n currentMigrationVersion: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\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"]}
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,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK;KAChB;IACD,kBAAkB,EAAE;QAClB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK;KAChB;IACD,wBAAwB,EAAE;QACxB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK;KAChB;IACD,uBAAuB,EAAE;QACvB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK;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 includeInStateLogs: true,\n persist: true,\n anonymous: true,\n usedInUi: false,\n },\n previousAppVersion: {\n includeInStateLogs: true,\n persist: true,\n anonymous: true,\n usedInUi: false,\n },\n previousMigrationVersion: {\n includeInStateLogs: true,\n persist: true,\n anonymous: true,\n usedInUi: false,\n },\n currentMigrationVersion: {\n includeInStateLogs: true,\n persist: true,\n anonymous: true,\n usedInUi: false,\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/app-metadata-controller",
3
- "version": "1.1.0-preview-e9856975",
3
+ "version": "1.1.0-preview-83095132",
4
4
  "description": "Manages requests that for app metadata",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -47,8 +47,7 @@
47
47
  "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
48
48
  },
49
49
  "dependencies": {
50
- "@metamask/base-controller": "^8.4.1",
51
- "@metamask/messenger": "^0.3.0"
50
+ "@metamask/base-controller": "^8.4.1"
52
51
  },
53
52
  "devDependencies": {
54
53
  "@metamask/auto-changelog": "^3.4.4",