@metamask-previews/app-metadata-controller 2.0.1-preview-b13d916 → 2.0.1-preview-4f4c98e

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
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Changed
11
11
 
12
+ - **BREAKING:** Bump minimum Node.js version to 22 ([#9168](https://github.com/MetaMask/core/pull/9168))
12
13
  - Bump `@metamask/messenger` from `^1.0.0` to `^2.0.0` ([#8364](https://github.com/MetaMask/core/pull/8364), [#8373](https://github.com/MetaMask/core/pull/8373), [#8632](https://github.com/MetaMask/core/pull/8632), [#9392](https://github.com/MetaMask/core/pull/9392))
13
14
  - Bump `@metamask/base-controller` from `^9.0.1` to `^9.1.0` ([#8457](https://github.com/MetaMask/core/pull/8457))
14
15
 
@@ -1,6 +1,6 @@
1
- import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
- import { BaseController } from "@metamask/base-controller";
3
- import type { Messenger } from "@metamask/messenger";
1
+ import type { ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
2
+ import { BaseController } from '@metamask/base-controller';
3
+ import type { Messenger } from '@metamask/messenger';
4
4
  declare const controllerName = "AppMetadataController";
5
5
  /**
6
6
  * The options that AppMetadataController takes.
@@ -81,4 +81,4 @@ export declare class AppMetadataController extends BaseController<typeof control
81
81
  constructor({ state, messenger, currentAppVersion, currentMigrationVersion, }: AppMetadataControllerOptions);
82
82
  }
83
83
  export {};
84
- //# sourceMappingURL=AppMetadataController.d.mts.map
84
+ //# sourceMappingURL=AppMetadataController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppMetadataController.d.ts","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,2BAA2B,CA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AQ,cAAc,CACvD,OAAO,cAAc,EACrB,0BAA0B,EAC1B,8BAA8B,CAC/B;;IACC;;;;;;;;OAQG;IACH,YAAY,EACV,KAAU,EACV,SAAS,EACT,iBAAsB,EACtB,uBAA2B,GAC5B,EAAE,4BAA4B,EAc9B;CAiCF"}
@@ -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";
7
+ import { BaseController } from '@metamask/base-controller';
8
8
  // Unique name for the controller
9
9
  const controllerName = 'AppMetadataController';
10
10
  /**
@@ -100,4 +100,4 @@ _AppMetadataController_instances = new WeakSet(), _AppMetadataController_updateA
100
100
  });
101
101
  }
102
102
  };
103
- //# sourceMappingURL=AppMetadataController.mjs.map
103
+ //# sourceMappingURL=AppMetadataController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppMetadataController.js","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":";;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,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,k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ACjD,MAAM,0BAA0B,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAEtE,IAAI,mBAAmB,KAAK,0BAA0B,EAAE,CAAC;QACvD,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;IACL,CAAC;AACH,CAAC","sourcesContent":["import type {\n StateMetadata,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\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,3 +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
1
+ export type { AppMetadataControllerActions, AppMetadataControllerEvents, AppMetadataControllerGetStateAction, AppMetadataControllerMessenger, AppMetadataControllerState, AppMetadataControllerStateChangeEvent, } from './AppMetadataController.js';
2
+ export { getDefaultAppMetadataControllerState, AppMetadataController, } from './AppMetadataController.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,4BAA4B,EAC5B,2BAA2B,EAC3B,mCAAmC,EACnC,8BAA8B,EAC9B,0BAA0B,EAC1B,qCAAqC,GACtC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GACtB,MAAM,4BAA4B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { getDefaultAppMetadataControllerState, AppMetadataController, } from './AppMetadataController.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GACtB,MAAM,4BAA4B,CAAC","sourcesContent":["export type {\n AppMetadataControllerActions,\n AppMetadataControllerEvents,\n AppMetadataControllerGetStateAction,\n AppMetadataControllerMessenger,\n AppMetadataControllerState,\n AppMetadataControllerStateChangeEvent,\n} from './AppMetadataController.js';\nexport {\n getDefaultAppMetadataControllerState,\n AppMetadataController,\n} from './AppMetadataController.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/app-metadata-controller",
3
- "version": "2.0.1-preview-b13d916",
3
+ "version": "2.0.1-preview-4f4c98e",
4
4
  "description": "Manages requests that for app metadata",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -18,19 +18,12 @@
18
18
  "files": [
19
19
  "dist/"
20
20
  ],
21
+ "type": "module",
21
22
  "sideEffects": false,
22
- "main": "./dist/index.cjs",
23
- "types": "./dist/index.d.cts",
24
23
  "exports": {
25
24
  ".": {
26
- "import": {
27
- "types": "./dist/index.d.mts",
28
- "default": "./dist/index.mjs"
29
- },
30
- "require": {
31
- "types": "./dist/index.d.cts",
32
- "default": "./dist/index.cjs"
33
- }
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
34
27
  },
35
28
  "./package.json": "./package.json"
36
29
  },
@@ -39,9 +32,11 @@
39
32
  "registry": "https://registry.npmjs.org/"
40
33
  },
41
34
  "scripts": {
42
- "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
43
- "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
35
+ "build": "tsc --project tsconfig.build.json",
36
+ "build:all": "tsc --build tsconfig.build.json --verbose",
37
+ "build:clean": "yarn build:only-clean && yarn build",
44
38
  "build:docs": "typedoc",
39
+ "build:only-clean": "rimraf './dist' './tsconfig.build.tsbuildinfo'",
45
40
  "changelog:update": "../../scripts/update-changelog.sh @metamask/app-metadata-controller",
46
41
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/app-metadata-controller",
47
42
  "lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
@@ -58,17 +53,18 @@
58
53
  },
59
54
  "devDependencies": {
60
55
  "@metamask/auto-changelog": "^6.1.0",
61
- "@ts-bridge/cli": "^0.6.4",
62
56
  "@types/jest": "^30.0.0",
57
+ "@typescript/native": "npm:typescript@^7.0.2",
63
58
  "deepmerge": "^4.2.2",
64
59
  "jest": "^30.4.2",
60
+ "rimraf": "^5.0.5",
65
61
  "ts-jest": "^29.4.11",
66
62
  "tsx": "^4.20.5",
67
63
  "typedoc": "^0.25.13",
68
64
  "typedoc-plugin-missing-exports": "^2.0.0",
69
- "typescript": "~5.3.3"
65
+ "typescript": "npm:@typescript/typescript6@^6.0.2"
70
66
  },
71
67
  "engines": {
72
- "node": "^18.18 || >=20"
68
+ "node": "^22.14.0 || ^24"
73
69
  }
74
70
  }
@@ -1,108 +0,0 @@
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
- includeInStateLogs: true,
36
- persist: true,
37
- includeInDebugSnapshot: true,
38
- usedInUi: false,
39
- },
40
- previousAppVersion: {
41
- includeInStateLogs: true,
42
- persist: true,
43
- includeInDebugSnapshot: true,
44
- usedInUi: false,
45
- },
46
- previousMigrationVersion: {
47
- includeInStateLogs: true,
48
- persist: true,
49
- includeInDebugSnapshot: true,
50
- usedInUi: false,
51
- },
52
- currentMigrationVersion: {
53
- includeInStateLogs: true,
54
- persist: true,
55
- includeInDebugSnapshot: true,
56
- usedInUi: false,
57
- },
58
- };
59
- /**
60
- * The AppMetadata controller stores metadata about the current extension instance,
61
- * including the currently and previously installed versions, and the most recently
62
- * run migration.
63
- *
64
- */
65
- class AppMetadataController extends base_controller_1.BaseController {
66
- /**
67
- * Constructs a AppMetadata controller.
68
- *
69
- * @param options - the controller options
70
- * @param options.state - Initial controller state.
71
- * @param options.messenger - Messenger used to communicate with BaseV2 controller.
72
- * @param options.currentMigrationVersion - The migration version to store in state.
73
- * @param options.currentAppVersion - The app version to store in state.
74
- */
75
- constructor({ state = {}, messenger, currentAppVersion = '', currentMigrationVersion = 0, }) {
76
- super({
77
- name: controllerName,
78
- metadata: controllerMetadata,
79
- state: {
80
- ...(0, exports.getDefaultAppMetadataControllerState)(),
81
- ...state,
82
- },
83
- messenger,
84
- });
85
- _AppMetadataController_instances.add(this);
86
- __classPrivateFieldGet(this, _AppMetadataController_instances, "m", _AppMetadataController_updateAppVersion).call(this, currentAppVersion);
87
- __classPrivateFieldGet(this, _AppMetadataController_instances, "m", _AppMetadataController_updateMigrationVersion).call(this, currentMigrationVersion);
88
- }
89
- }
90
- exports.AppMetadataController = AppMetadataController;
91
- _AppMetadataController_instances = new WeakSet(), _AppMetadataController_updateAppVersion = function _AppMetadataController_updateAppVersion(newAppVersion) {
92
- const oldCurrentAppVersion = this.state.currentAppVersion;
93
- if (newAppVersion !== oldCurrentAppVersion) {
94
- this.update((state) => {
95
- state.currentAppVersion = newAppVersion;
96
- state.previousAppVersion = oldCurrentAppVersion;
97
- });
98
- }
99
- }, _AppMetadataController_updateMigrationVersion = function _AppMetadataController_updateMigrationVersion(newMigrationVersion) {
100
- const oldCurrentMigrationVersion = this.state.currentMigrationVersion;
101
- if (newMigrationVersion !== oldCurrentMigrationVersion) {
102
- this.update((state) => {
103
- state.previousMigrationVersion = oldCurrentMigrationVersion;
104
- state.currentMigrationVersion = newMigrationVersion;
105
- });
106
- }
107
- };
108
- //# sourceMappingURL=AppMetadataController.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AppMetadataController.cjs","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":";;;;;;;;;AAKA,+DAA2D;AAG3D,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;CAC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KAAK,oBAAoB,EAAE,CAAC;QAC3C,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;IACL,CAAC;AACH,CAAC,yGAOuB,mBAA2B;IACjD,MAAM,0BAA0B,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAEtE,IAAI,mBAAmB,KAAK,0BAA0B,EAAE,CAAC;QACvD,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;IACL,CAAC;AACH,CAAC","sourcesContent":["import type {\n StateMetadata,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\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,84 +0,0 @@
1
- import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
- import { BaseController } from "@metamask/base-controller";
3
- import type { Messenger } from "@metamask/messenger";
4
- declare const controllerName = "AppMetadataController";
5
- /**
6
- * The options that AppMetadataController takes.
7
- */
8
- export type AppMetadataControllerOptions = {
9
- state?: Partial<AppMetadataControllerState>;
10
- messenger: AppMetadataControllerMessenger;
11
- currentMigrationVersion?: number;
12
- currentAppVersion?: string;
13
- };
14
- /**
15
- * The state of the AppMetadataController
16
- */
17
- export type AppMetadataControllerState = {
18
- currentAppVersion: string;
19
- previousAppVersion: string;
20
- previousMigrationVersion: number;
21
- currentMigrationVersion: number;
22
- };
23
- /**
24
- * Constructs the default {@link AppMetadataController} state. This allows
25
- * consumers to provide a partial state object when initializing the controller
26
- * and also helps in constructing complete state objects for this controller in
27
- * tests.
28
- *
29
- * @returns The default {@link AppMetadataController} state.
30
- */
31
- export declare const getDefaultAppMetadataControllerState: () => AppMetadataControllerState;
32
- /**
33
- * Returns the state of the {@link AppMetadataController}.
34
- */
35
- export type AppMetadataControllerGetStateAction = ControllerGetStateAction<typeof controllerName, AppMetadataControllerState>;
36
- /**
37
- * Actions exposed by the {@link AppMetadataController}.
38
- */
39
- export type AppMetadataControllerActions = AppMetadataControllerGetStateAction;
40
- /**
41
- * Event emitted when the state of the {@link AppMetadataController} changes.
42
- */
43
- export type AppMetadataControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, AppMetadataControllerState>;
44
- /**
45
- * Events that can be emitted by the {@link AppMetadataController}
46
- */
47
- export type AppMetadataControllerEvents = AppMetadataControllerStateChangeEvent;
48
- /**
49
- * Actions that this controller is allowed to call.
50
- * Currently set to never as this controller doesn't call any other controllers.
51
- */
52
- type AllowedActions = never;
53
- /**
54
- * Events that this controller is allowed to subscribe.
55
- */
56
- type AllowedEvents = never;
57
- /**
58
- * Messenger type for the {@link AppMetadataController}.
59
- *
60
- * @returns A restricted messenger type that defines the allowed actions and events
61
- * for the AppMetadataController
62
- */
63
- export type AppMetadataControllerMessenger = Messenger<typeof controllerName, AppMetadataControllerActions | AllowedActions, AppMetadataControllerEvents | AllowedEvents>;
64
- /**
65
- * The AppMetadata controller stores metadata about the current extension instance,
66
- * including the currently and previously installed versions, and the most recently
67
- * run migration.
68
- *
69
- */
70
- export declare class AppMetadataController extends BaseController<typeof controllerName, AppMetadataControllerState, AppMetadataControllerMessenger> {
71
- #private;
72
- /**
73
- * Constructs a AppMetadata controller.
74
- *
75
- * @param options - the controller options
76
- * @param options.state - Initial controller state.
77
- * @param options.messenger - Messenger used to communicate with BaseV2 controller.
78
- * @param options.currentMigrationVersion - The migration version to store in state.
79
- * @param options.currentAppVersion - The app version to store in state.
80
- */
81
- constructor({ state, messenger, currentAppVersion, currentMigrationVersion, }: AppMetadataControllerOptions);
82
- }
83
- export {};
84
- //# sourceMappingURL=AppMetadataController.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AppMetadataController.d.cts","sourceRoot":"","sources":["../src/AppMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,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,cA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I,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;IACL,CAAC;AACH,CAAC,yGAOuB,mBAA2B;IACjD,MAAM,0BAA0B,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAEtE,IAAI,mBAAmB,KAAK,0BAA0B,EAAE,CAAC;QACvD,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;IACL,CAAC;AACH,CAAC","sourcesContent":["import type {\n StateMetadata,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\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"]}
package/dist/index.cjs DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppMetadataController = exports.getDefaultAppMetadataControllerState = void 0;
4
- var AppMetadataController_js_1 = require("./AppMetadataController.cjs");
5
- Object.defineProperty(exports, "getDefaultAppMetadataControllerState", { enumerable: true, get: function () { return AppMetadataController_js_1.getDefaultAppMetadataControllerState; } });
6
- Object.defineProperty(exports, "AppMetadataController", { enumerable: true, get: function () { return AppMetadataController_js_1.AppMetadataController; } });
7
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,wEAGoC;AAFlC,gJAAA,oCAAoC,OAAA;AACpC,iIAAA,qBAAqB,OAAA","sourcesContent":["export type {\n AppMetadataControllerActions,\n AppMetadataControllerEvents,\n AppMetadataControllerGetStateAction,\n AppMetadataControllerMessenger,\n AppMetadataControllerState,\n AppMetadataControllerStateChangeEvent,\n} from './AppMetadataController.js';\nexport {\n getDefaultAppMetadataControllerState,\n AppMetadataController,\n} from './AppMetadataController.js';\n"]}
@@ -1 +0,0 @@
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,oCAAmC;AACpC,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GACtB,oCAAmC"}
package/dist/index.d.mts DELETED
@@ -1,3 +0,0 @@
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
@@ -1 +0,0 @@
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,oCAAmC;AACpC,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GACtB,oCAAmC"}
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- export { getDefaultAppMetadataControllerState, AppMetadataController } from "./AppMetadataController.mjs";
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,oCAAoC,EACpC,qBAAqB,EACtB,oCAAmC","sourcesContent":["export type {\n AppMetadataControllerActions,\n AppMetadataControllerEvents,\n AppMetadataControllerGetStateAction,\n AppMetadataControllerMessenger,\n AppMetadataControllerState,\n AppMetadataControllerStateChangeEvent,\n} from './AppMetadataController.js';\nexport {\n getDefaultAppMetadataControllerState,\n AppMetadataController,\n} from './AppMetadataController.js';\n"]}