@metamask-previews/connectivity-controller 0.1.0-preview-903db2da → 0.1.0-preview-3ec2a74

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/ConnectivityController-method-action-types.cjs +7 -0
  3. package/dist/ConnectivityController-method-action-types.cjs.map +1 -0
  4. package/dist/ConnectivityController-method-action-types.d.cts +19 -0
  5. package/dist/ConnectivityController-method-action-types.d.cts.map +1 -0
  6. package/dist/ConnectivityController-method-action-types.d.mts +19 -0
  7. package/dist/ConnectivityController-method-action-types.d.mts.map +1 -0
  8. package/dist/ConnectivityController-method-action-types.mjs +6 -0
  9. package/dist/ConnectivityController-method-action-types.mjs.map +1 -0
  10. package/dist/ConnectivityController.cjs +35 -9
  11. package/dist/ConnectivityController.cjs.map +1 -1
  12. package/dist/ConnectivityController.d.cts +13 -1
  13. package/dist/ConnectivityController.d.cts.map +1 -1
  14. package/dist/ConnectivityController.d.mts +13 -1
  15. package/dist/ConnectivityController.d.mts.map +1 -1
  16. package/dist/ConnectivityController.mjs +35 -9
  17. package/dist/ConnectivityController.mjs.map +1 -1
  18. package/dist/index.cjs +3 -1
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +2 -0
  21. package/dist/index.d.cts.map +1 -1
  22. package/dist/index.d.mts +2 -0
  23. package/dist/index.d.mts.map +1 -1
  24. package/dist/index.mjs +1 -0
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/selectors.cjs +28 -0
  27. package/dist/selectors.cjs.map +1 -0
  28. package/dist/selectors.d.cts +31 -0
  29. package/dist/selectors.d.cts.map +1 -0
  30. package/dist/selectors.d.mts +31 -0
  31. package/dist/selectors.d.mts.map +1 -0
  32. package/dist/selectors.mjs +25 -0
  33. package/dist/selectors.mjs.map +1 -0
  34. package/dist/types.cjs.map +1 -1
  35. package/dist/types.d.cts +3 -3
  36. package/dist/types.d.cts.map +1 -1
  37. package/dist/types.d.mts +3 -3
  38. package/dist/types.d.mts.map +1 -1
  39. package/dist/types.mjs.map +1 -1
  40. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Add `init` method to asynchronously fetch and set the initial connectivity status from the adapter ([#7679](https://github.com/MetaMask/core/pull/7679))
13
+ - The controller now initializes with a default state (online) and requires calling `init()` to fetch the actual status
14
+ - Add `setConnectivityStatus` method to manually set connectivity status ([#7676](https://github.com/MetaMask/core/pull/7676))
15
+ - The method is exposed as a messenger action `ConnectivityController:setConnectivityStatus`
16
+ - Add `connectivityControllerSelectors` with `selectConnectivityStatus` and `selectIsOffline` selectors ([#7701](https://github.com/MetaMask/core/pull/7701))
17
+ - `selectConnectivityStatus` returns the current connectivity status from the controller state
18
+ - `selectIsOffline` is a memoized selector that returns `true` when the device is offline
19
+
20
+ ### Changed
21
+
22
+ - **BREAKING:** `ConnectivityAdapter.getStatus()` must now return a `Promise<ConnectivityStatus>` (async) ([#7679](https://github.com/MetaMask/core/pull/7679))
23
+ - Adapter implementations must update their `getStatus()` method to return a Promise
24
+ - This change enables asynchronous initialization of the controller via the `init()` method
25
+
10
26
  ## [0.1.0]
11
27
 
12
28
  ### Added
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
4
+ * Do not edit manually.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=ConnectivityController-method-action-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectivityController-method-action-types.cjs","sourceRoot":"","sources":["../src/ConnectivityController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { ConnectivityController } from './ConnectivityController';\n\n/**\n * Sets the connectivity status.\n *\n * @param status - The connectivity status to set.\n */\nexport type ConnectivityControllerSetConnectivityStatusAction = {\n type: `ConnectivityController:setConnectivityStatus`;\n handler: ConnectivityController['setConnectivityStatus'];\n};\n\n/**\n * Union of all ConnectivityController action types.\n */\nexport type ConnectivityControllerMethodActions =\n ConnectivityControllerSetConnectivityStatusAction;\n"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ConnectivityController } from "./ConnectivityController.cjs";
6
+ /**
7
+ * Sets the connectivity status.
8
+ *
9
+ * @param status - The connectivity status to set.
10
+ */
11
+ export type ConnectivityControllerSetConnectivityStatusAction = {
12
+ type: `ConnectivityController:setConnectivityStatus`;
13
+ handler: ConnectivityController['setConnectivityStatus'];
14
+ };
15
+ /**
16
+ * Union of all ConnectivityController action types.
17
+ */
18
+ export type ConnectivityControllerMethodActions = ConnectivityControllerSetConnectivityStatusAction;
19
+ //# sourceMappingURL=ConnectivityController-method-action-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectivityController-method-action-types.d.cts","sourceRoot":"","sources":["../src/ConnectivityController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,qCAAiC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;CAC1D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC7C,iDAAiD,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ConnectivityController } from "./ConnectivityController.mjs";
6
+ /**
7
+ * Sets the connectivity status.
8
+ *
9
+ * @param status - The connectivity status to set.
10
+ */
11
+ export type ConnectivityControllerSetConnectivityStatusAction = {
12
+ type: `ConnectivityController:setConnectivityStatus`;
13
+ handler: ConnectivityController['setConnectivityStatus'];
14
+ };
15
+ /**
16
+ * Union of all ConnectivityController action types.
17
+ */
18
+ export type ConnectivityControllerMethodActions = ConnectivityControllerSetConnectivityStatusAction;
19
+ //# sourceMappingURL=ConnectivityController-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectivityController-method-action-types.d.mts","sourceRoot":"","sources":["../src/ConnectivityController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,qCAAiC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;CAC1D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC7C,iDAAiD,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=ConnectivityController-method-action-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectivityController-method-action-types.mjs","sourceRoot":"","sources":["../src/ConnectivityController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { ConnectivityController } from './ConnectivityController';\n\n/**\n * Sets the connectivity status.\n *\n * @param status - The connectivity status to set.\n */\nexport type ConnectivityControllerSetConnectivityStatusAction = {\n type: `ConnectivityController:setConnectivityStatus`;\n handler: ConnectivityController['setConnectivityStatus'];\n};\n\n/**\n * Union of all ConnectivityController action types.\n */\nexport type ConnectivityControllerMethodActions =\n ConnectivityControllerSetConnectivityStatusAction;\n"]}
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _ConnectivityController_connectivityAdapter;
2
14
  Object.defineProperty(exports, "__esModule", { value: true });
3
15
  exports.ConnectivityController = exports.getDefaultConnectivityControllerState = exports.controllerName = void 0;
4
16
  const base_controller_1 = require("@metamask/base-controller");
@@ -34,6 +46,7 @@ function getDefaultConnectivityControllerState() {
34
46
  };
35
47
  }
36
48
  exports.getDefaultConnectivityControllerState = getDefaultConnectivityControllerState;
49
+ const MESSENGER_EXPOSED_METHODS = ['setConnectivityStatus'];
37
50
  /**
38
51
  * ConnectivityController stores the device's internet connectivity status.
39
52
  *
@@ -57,22 +70,35 @@ class ConnectivityController extends base_controller_1.BaseController {
57
70
  * @param args.connectivityAdapter - The connectivity adapter to use.
58
71
  */
59
72
  constructor({ messenger, connectivityAdapter, }) {
60
- const initialStatus = connectivityAdapter.getStatus();
61
73
  super({
62
74
  messenger,
63
75
  metadata: connectivityControllerMetadata,
64
76
  name: exports.controllerName,
65
- state: {
66
- ...getDefaultConnectivityControllerState(),
67
- connectivityStatus: initialStatus,
68
- },
77
+ state: getDefaultConnectivityControllerState(),
69
78
  });
70
- connectivityAdapter.onConnectivityChange((status) => {
71
- this.update((draftState) => {
72
- draftState.connectivityStatus = status;
73
- });
79
+ _ConnectivityController_connectivityAdapter.set(this, void 0);
80
+ __classPrivateFieldSet(this, _ConnectivityController_connectivityAdapter, connectivityAdapter, "f");
81
+ __classPrivateFieldGet(this, _ConnectivityController_connectivityAdapter, "f").onConnectivityChange(this.setConnectivityStatus.bind(this));
82
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
83
+ }
84
+ /**
85
+ * Initializes the controller by fetching the initial connectivity status.
86
+ */
87
+ async init() {
88
+ const initialStatus = await __classPrivateFieldGet(this, _ConnectivityController_connectivityAdapter, "f").getStatus();
89
+ this.setConnectivityStatus(initialStatus);
90
+ }
91
+ /**
92
+ * Sets the connectivity status.
93
+ *
94
+ * @param status - The connectivity status to set.
95
+ */
96
+ setConnectivityStatus(status) {
97
+ this.update((draftState) => {
98
+ draftState.connectivityStatus = status;
74
99
  });
75
100
  }
76
101
  }
77
102
  exports.ConnectivityController = ConnectivityController;
103
+ _ConnectivityController_connectivityAdapter = new WeakMap();
78
104
  //# sourceMappingURL=ConnectivityController.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectivityController.cjs","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAG3D,uCAAgD;AAGhD;;;;GAIG;AACU,QAAA,cAAc,GAAG,wBAAwB,CAAC;AAavD;;GAEG;AACH,MAAM,8BAA8B,GAAG;IACrC,kBAAkB,EAAE;QAClB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,IAAI;QAC5B,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,IAAI;KACf;CACmD,CAAC;AAEvD;;;;;;;GAOG;AACH,SAAgB,qCAAqC;IACnD,OAAO;QACL,kBAAkB,EAAE,6BAAqB,CAAC,MAAM;KACjD,CAAC;AACJ,CAAC;AAJD,sFAIC;AAkED;;;;;;;;;;;;;GAaG;AACH,MAAa,sBAAuB,SAAQ,gCAI3C;IACC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,mBAAmB,GACW;QAC9B,MAAM,aAAa,GAAG,mBAAmB,CAAC,SAAS,EAAE,CAAC;QAEtD,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,8BAA8B;YACxC,IAAI,EAAE,sBAAc;YACpB,KAAK,EAAE;gBACL,GAAG,qCAAqC,EAAE;gBAC1C,kBAAkB,EAAE,aAAa;aAClC;SACF,CAAC,CAAC;QAEH,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE;YAClD,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;gBACzB,UAAU,CAAC,kBAAkB,GAAG,MAAM,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlCD,wDAkCC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { CONNECTIVITY_STATUSES } from './types';\nimport type { ConnectivityAdapter, ConnectivityStatus } from './types';\n\n/**\n * The name of the {@link ConnectivityController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nexport const controllerName = 'ConnectivityController';\n\n/**\n * State for the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerState = {\n /**\n * The current device connectivity status.\n * Named with 'connectivity' prefix to avoid conflicts when state is flattened in Redux.\n */\n connectivityStatus: ConnectivityStatus;\n};\n\n/**\n * The metadata for each property in {@link ConnectivityControllerState}.\n */\nconst connectivityControllerMetadata = {\n connectivityStatus: {\n persist: false,\n includeInDebugSnapshot: true,\n includeInStateLogs: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<ConnectivityControllerState>;\n\n/**\n * Constructs the default {@link ConnectivityController} 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 ConnectivityController} state.\n */\nexport function getDefaultConnectivityControllerState(): ConnectivityControllerState {\n return {\n connectivityStatus: CONNECTIVITY_STATUSES.Online,\n };\n}\n\n/**\n * Retrieves the state of the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ConnectivityControllerState\n>;\n\n/**\n * Actions that {@link ConnectivityControllerMessenger} exposes to other consumers.\n */\nexport type ConnectivityControllerActions =\n ConnectivityControllerGetStateAction;\n\n/**\n * Actions from other messengers that {@link ConnectivityControllerMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when the state of {@link ConnectivityController} changes.\n */\nexport type ConnectivityControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n ConnectivityControllerState\n>;\n\n/**\n * Events that {@link ConnectivityControllerMessenger} exposes to other consumers.\n */\nexport type ConnectivityControllerEvents =\n ConnectivityControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ConnectivityControllerMessenger} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ConnectivityController}.\n */\nexport type ConnectivityControllerMessenger = Messenger<\n typeof controllerName,\n ConnectivityControllerActions | AllowedActions,\n ConnectivityControllerEvents | AllowedEvents\n>;\n\n/**\n * Options for constructing the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerOptions = {\n /**\n * The messenger for inter-controller communication.\n */\n messenger: ConnectivityControllerMessenger;\n\n /**\n * Connectivity adapter for platform-specific detection.\n */\n connectivityAdapter: ConnectivityAdapter;\n};\n\n/**\n * ConnectivityController stores the device's internet connectivity status.\n *\n * This controller is platform-agnostic and designed to be used across different\n * MetaMask clients (extension, mobile). It requires a `ConnectivityAdapter` to\n * be injected, which provides platform-specific connectivity detection.\n *\n * The controller subscribes to the adapter's `onConnectivityChange` callback\n * and updates its state accordingly. All connectivity updates flow through\n * the adapter, ensuring a single source of truth.\n *\n * This controller provides a centralized state for connectivity status,\n * enabling the UI and other controllers to adapt when the user goes offline.\n */\nexport class ConnectivityController extends BaseController<\n typeof controllerName,\n ConnectivityControllerState,\n ConnectivityControllerMessenger\n> {\n /**\n * Constructs a new {@link ConnectivityController}.\n *\n * @param args - The arguments to this controller.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.connectivityAdapter - The connectivity adapter to use.\n */\n constructor({\n messenger,\n connectivityAdapter,\n }: ConnectivityControllerOptions) {\n const initialStatus = connectivityAdapter.getStatus();\n\n super({\n messenger,\n metadata: connectivityControllerMetadata,\n name: controllerName,\n state: {\n ...getDefaultConnectivityControllerState(),\n connectivityStatus: initialStatus,\n },\n });\n\n connectivityAdapter.onConnectivityChange((status) => {\n this.update((draftState) => {\n draftState.connectivityStatus = status;\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ConnectivityController.cjs","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAI3D,uCAAgD;AAGhD;;;;GAIG;AACU,QAAA,cAAc,GAAG,wBAAwB,CAAC;AAavD;;GAEG;AACH,MAAM,8BAA8B,GAAG;IACrC,kBAAkB,EAAE;QAClB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,IAAI;QAC5B,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,IAAI;KACf;CACmD,CAAC;AAEvD;;;;;;;GAOG;AACH,SAAgB,qCAAqC;IACnD,OAAO;QACL,kBAAkB,EAAE,6BAAqB,CAAC,MAAM;KACjD,CAAC;AACJ,CAAC;AAJD,sFAIC;AAED,MAAM,yBAAyB,GAAG,CAAC,uBAAuB,CAAU,CAAC;AAmErE;;;;;;;;;;;;;GAaG;AACH,MAAa,sBAAuB,SAAQ,gCAI3C;IAGC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,mBAAmB,GACW;QAC9B,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,8BAA8B;YACxC,IAAI,EAAE,sBAAc;YACpB,KAAK,EAAE,qCAAqC,EAAE;SAC/C,CAAC,CAAC;QAlBI,8DAA0C;QAoBjD,uBAAA,IAAI,+CAAwB,mBAAmB,MAAA,CAAC;QAEhD,uBAAA,IAAI,mDAAqB,CAAC,oBAAoB,CAC5C,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CACtC,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,aAAa,GAAG,MAAM,uBAAA,IAAI,mDAAqB,CAAC,SAAS,EAAE,CAAC;QAClE,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,qBAAqB,CAAC,MAA0B;QAC9C,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;YACzB,UAAU,CAAC,kBAAkB,GAAG,MAAM,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAvDD,wDAuDC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { ConnectivityControllerMethodActions } from './ConnectivityController-method-action-types';\nimport { CONNECTIVITY_STATUSES } from './types';\nimport type { ConnectivityAdapter, ConnectivityStatus } from './types';\n\n/**\n * The name of the {@link ConnectivityController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nexport const controllerName = 'ConnectivityController';\n\n/**\n * State for the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerState = {\n /**\n * The current device connectivity status.\n * Named with 'connectivity' prefix to avoid conflicts when state is flattened in Redux.\n */\n connectivityStatus: ConnectivityStatus;\n};\n\n/**\n * The metadata for each property in {@link ConnectivityControllerState}.\n */\nconst connectivityControllerMetadata = {\n connectivityStatus: {\n persist: false,\n includeInDebugSnapshot: true,\n includeInStateLogs: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<ConnectivityControllerState>;\n\n/**\n * Constructs the default {@link ConnectivityController} 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 ConnectivityController} state.\n */\nexport function getDefaultConnectivityControllerState(): ConnectivityControllerState {\n return {\n connectivityStatus: CONNECTIVITY_STATUSES.Online,\n };\n}\n\nconst MESSENGER_EXPOSED_METHODS = ['setConnectivityStatus'] as const;\n\n/**\n * Retrieves the state of the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ConnectivityControllerState\n>;\n\n/**\n * Actions that {@link ConnectivityControllerMessenger} exposes to other consumers.\n */\nexport type ConnectivityControllerActions =\n | ConnectivityControllerGetStateAction\n | ConnectivityControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link ConnectivityControllerMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when the state of {@link ConnectivityController} changes.\n */\nexport type ConnectivityControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n ConnectivityControllerState\n>;\n\n/**\n * Events that {@link ConnectivityControllerMessenger} exposes to other consumers.\n */\nexport type ConnectivityControllerEvents =\n ConnectivityControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ConnectivityControllerMessenger} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ConnectivityController}.\n */\nexport type ConnectivityControllerMessenger = Messenger<\n typeof controllerName,\n ConnectivityControllerActions | AllowedActions,\n ConnectivityControllerEvents | AllowedEvents\n>;\n\n/**\n * Options for constructing the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerOptions = {\n /**\n * The messenger for inter-controller communication.\n */\n messenger: ConnectivityControllerMessenger;\n\n /**\n * Connectivity adapter for platform-specific detection.\n */\n connectivityAdapter: ConnectivityAdapter;\n};\n\n/**\n * ConnectivityController stores the device's internet connectivity status.\n *\n * This controller is platform-agnostic and designed to be used across different\n * MetaMask clients (extension, mobile). It requires a `ConnectivityAdapter` to\n * be injected, which provides platform-specific connectivity detection.\n *\n * The controller subscribes to the adapter's `onConnectivityChange` callback\n * and updates its state accordingly. All connectivity updates flow through\n * the adapter, ensuring a single source of truth.\n *\n * This controller provides a centralized state for connectivity status,\n * enabling the UI and other controllers to adapt when the user goes offline.\n */\nexport class ConnectivityController extends BaseController<\n typeof controllerName,\n ConnectivityControllerState,\n ConnectivityControllerMessenger\n> {\n readonly #connectivityAdapter: ConnectivityAdapter;\n\n /**\n * Constructs a new {@link ConnectivityController}.\n *\n * @param args - The arguments to this controller.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.connectivityAdapter - The connectivity adapter to use.\n */\n constructor({\n messenger,\n connectivityAdapter,\n }: ConnectivityControllerOptions) {\n super({\n messenger,\n metadata: connectivityControllerMetadata,\n name: controllerName,\n state: getDefaultConnectivityControllerState(),\n });\n\n this.#connectivityAdapter = connectivityAdapter;\n\n this.#connectivityAdapter.onConnectivityChange(\n this.setConnectivityStatus.bind(this),\n );\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Initializes the controller by fetching the initial connectivity status.\n */\n async init(): Promise<void> {\n const initialStatus = await this.#connectivityAdapter.getStatus();\n this.setConnectivityStatus(initialStatus);\n }\n\n /**\n * Sets the connectivity status.\n *\n * @param status - The connectivity status to set.\n */\n setConnectivityStatus(status: ConnectivityStatus): void {\n this.update((draftState) => {\n draftState.connectivityStatus = status;\n });\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
2
  import { BaseController } from "@metamask/base-controller";
3
3
  import type { Messenger } from "@metamask/messenger";
4
+ import { ConnectivityControllerMethodActions } from "./ConnectivityController-method-action-types.cjs";
4
5
  import type { ConnectivityAdapter, ConnectivityStatus } from "./types.cjs";
5
6
  /**
6
7
  * The name of the {@link ConnectivityController}, used to namespace the
@@ -34,7 +35,7 @@ export type ConnectivityControllerGetStateAction = ControllerGetStateAction<type
34
35
  /**
35
36
  * Actions that {@link ConnectivityControllerMessenger} exposes to other consumers.
36
37
  */
37
- export type ConnectivityControllerActions = ConnectivityControllerGetStateAction;
38
+ export type ConnectivityControllerActions = ConnectivityControllerGetStateAction | ConnectivityControllerMethodActions;
38
39
  /**
39
40
  * Actions from other messengers that {@link ConnectivityControllerMessenger} calls.
40
41
  */
@@ -85,6 +86,7 @@ export type ConnectivityControllerOptions = {
85
86
  * enabling the UI and other controllers to adapt when the user goes offline.
86
87
  */
87
88
  export declare class ConnectivityController extends BaseController<typeof controllerName, ConnectivityControllerState, ConnectivityControllerMessenger> {
89
+ #private;
88
90
  /**
89
91
  * Constructs a new {@link ConnectivityController}.
90
92
  *
@@ -93,6 +95,16 @@ export declare class ConnectivityController extends BaseController<typeof contro
93
95
  * @param args.connectivityAdapter - The connectivity adapter to use.
94
96
  */
95
97
  constructor({ messenger, connectivityAdapter, }: ConnectivityControllerOptions);
98
+ /**
99
+ * Initializes the controller by fetching the initial connectivity status.
100
+ */
101
+ init(): Promise<void>;
102
+ /**
103
+ * Sets the connectivity status.
104
+ *
105
+ * @param status - The connectivity status to set.
106
+ */
107
+ setConnectivityStatus(status: ConnectivityStatus): void;
96
108
  }
97
109
  export {};
98
110
  //# sourceMappingURL=ConnectivityController.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectivityController.d.cts","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAgB;AAEvE;;;;GAIG;AACH,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC;;;OAGG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,qCAAqC,IAAI,2BAA2B,CAInF;AAED;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,wBAAwB,CACzE,OAAO,cAAc,EACrB,2BAA2B,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACvC,oCAAoC,CAAC;AAEvC;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,0BAA0B,CAC7E,OAAO,cAAc,EACrB,2BAA2B,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACtC,sCAAsC,CAAC;AAEzC;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,cAAc,EACrB,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;OAEG;IACH,SAAS,EAAE,+BAA+B,CAAC;IAE3C;;OAEG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,qBAAa,sBAAuB,SAAQ,cAAc,CACxD,OAAO,cAAc,EACrB,2BAA2B,EAC3B,+BAA+B,CAChC;IACC;;;;;;OAMG;gBACS,EACV,SAAS,EACT,mBAAmB,GACpB,EAAE,6BAA6B;CAmBjC"}
1
+ {"version":3,"file":"ConnectivityController.d.cts","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,mCAAmC,EAAE,yDAAqD;AAEnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAgB;AAEvE;;;;GAIG;AACH,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC;;;OAGG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,qCAAqC,IAAI,2BAA2B,CAInF;AAID;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,wBAAwB,CACzE,OAAO,cAAc,EACrB,2BAA2B,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,oCAAoC,GACpC,mCAAmC,CAAC;AAExC;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,0BAA0B,CAC7E,OAAO,cAAc,EACrB,2BAA2B,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACtC,sCAAsC,CAAC;AAEzC;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,cAAc,EACrB,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;OAEG;IACH,SAAS,EAAE,+BAA+B,CAAC;IAE3C;;OAEG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,qBAAa,sBAAuB,SAAQ,cAAc,CACxD,OAAO,cAAc,EACrB,2BAA2B,EAC3B,+BAA+B,CAChC;;IAGC;;;;;;OAMG;gBACS,EACV,SAAS,EACT,mBAAmB,GACpB,EAAE,6BAA6B;IAoBhC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B;;;;OAIG;IACH,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;CAKxD"}
@@ -1,6 +1,7 @@
1
1
  import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
2
  import { BaseController } from "@metamask/base-controller";
3
3
  import type { Messenger } from "@metamask/messenger";
4
+ import { ConnectivityControllerMethodActions } from "./ConnectivityController-method-action-types.mjs";
4
5
  import type { ConnectivityAdapter, ConnectivityStatus } from "./types.mjs";
5
6
  /**
6
7
  * The name of the {@link ConnectivityController}, used to namespace the
@@ -34,7 +35,7 @@ export type ConnectivityControllerGetStateAction = ControllerGetStateAction<type
34
35
  /**
35
36
  * Actions that {@link ConnectivityControllerMessenger} exposes to other consumers.
36
37
  */
37
- export type ConnectivityControllerActions = ConnectivityControllerGetStateAction;
38
+ export type ConnectivityControllerActions = ConnectivityControllerGetStateAction | ConnectivityControllerMethodActions;
38
39
  /**
39
40
  * Actions from other messengers that {@link ConnectivityControllerMessenger} calls.
40
41
  */
@@ -85,6 +86,7 @@ export type ConnectivityControllerOptions = {
85
86
  * enabling the UI and other controllers to adapt when the user goes offline.
86
87
  */
87
88
  export declare class ConnectivityController extends BaseController<typeof controllerName, ConnectivityControllerState, ConnectivityControllerMessenger> {
89
+ #private;
88
90
  /**
89
91
  * Constructs a new {@link ConnectivityController}.
90
92
  *
@@ -93,6 +95,16 @@ export declare class ConnectivityController extends BaseController<typeof contro
93
95
  * @param args.connectivityAdapter - The connectivity adapter to use.
94
96
  */
95
97
  constructor({ messenger, connectivityAdapter, }: ConnectivityControllerOptions);
98
+ /**
99
+ * Initializes the controller by fetching the initial connectivity status.
100
+ */
101
+ init(): Promise<void>;
102
+ /**
103
+ * Sets the connectivity status.
104
+ *
105
+ * @param status - The connectivity status to set.
106
+ */
107
+ setConnectivityStatus(status: ConnectivityStatus): void;
96
108
  }
97
109
  export {};
98
110
  //# sourceMappingURL=ConnectivityController.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectivityController.d.mts","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAgB;AAEvE;;;;GAIG;AACH,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC;;;OAGG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,qCAAqC,IAAI,2BAA2B,CAInF;AAED;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,wBAAwB,CACzE,OAAO,cAAc,EACrB,2BAA2B,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACvC,oCAAoC,CAAC;AAEvC;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,0BAA0B,CAC7E,OAAO,cAAc,EACrB,2BAA2B,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACtC,sCAAsC,CAAC;AAEzC;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,cAAc,EACrB,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;OAEG;IACH,SAAS,EAAE,+BAA+B,CAAC;IAE3C;;OAEG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,qBAAa,sBAAuB,SAAQ,cAAc,CACxD,OAAO,cAAc,EACrB,2BAA2B,EAC3B,+BAA+B,CAChC;IACC;;;;;;OAMG;gBACS,EACV,SAAS,EACT,mBAAmB,GACpB,EAAE,6BAA6B;CAmBjC"}
1
+ {"version":3,"file":"ConnectivityController.d.mts","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,mCAAmC,EAAE,yDAAqD;AAEnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAgB;AAEvE;;;;GAIG;AACH,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC;;;OAGG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,qCAAqC,IAAI,2BAA2B,CAInF;AAID;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,wBAAwB,CACzE,OAAO,cAAc,EACrB,2BAA2B,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,oCAAoC,GACpC,mCAAmC,CAAC;AAExC;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,0BAA0B,CAC7E,OAAO,cAAc,EACrB,2BAA2B,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACtC,sCAAsC,CAAC;AAEzC;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,cAAc,EACrB,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;OAEG;IACH,SAAS,EAAE,+BAA+B,CAAC;IAE3C;;OAEG;IACH,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,qBAAa,sBAAuB,SAAQ,cAAc,CACxD,OAAO,cAAc,EACrB,2BAA2B,EAC3B,+BAA+B,CAChC;;IAGC;;;;;;OAMG;gBACS,EACV,SAAS,EACT,mBAAmB,GACpB,EAAE,6BAA6B;IAoBhC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B;;;;OAIG;IACH,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;CAKxD"}
@@ -1,3 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ConnectivityController_connectivityAdapter;
1
13
  import { BaseController } from "@metamask/base-controller";
2
14
  import { CONNECTIVITY_STATUSES } from "./types.mjs";
3
15
  /**
@@ -30,6 +42,7 @@ export function getDefaultConnectivityControllerState() {
30
42
  connectivityStatus: CONNECTIVITY_STATUSES.Online,
31
43
  };
32
44
  }
45
+ const MESSENGER_EXPOSED_METHODS = ['setConnectivityStatus'];
33
46
  /**
34
47
  * ConnectivityController stores the device's internet connectivity status.
35
48
  *
@@ -53,21 +66,34 @@ export class ConnectivityController extends BaseController {
53
66
  * @param args.connectivityAdapter - The connectivity adapter to use.
54
67
  */
55
68
  constructor({ messenger, connectivityAdapter, }) {
56
- const initialStatus = connectivityAdapter.getStatus();
57
69
  super({
58
70
  messenger,
59
71
  metadata: connectivityControllerMetadata,
60
72
  name: controllerName,
61
- state: {
62
- ...getDefaultConnectivityControllerState(),
63
- connectivityStatus: initialStatus,
64
- },
73
+ state: getDefaultConnectivityControllerState(),
65
74
  });
66
- connectivityAdapter.onConnectivityChange((status) => {
67
- this.update((draftState) => {
68
- draftState.connectivityStatus = status;
69
- });
75
+ _ConnectivityController_connectivityAdapter.set(this, void 0);
76
+ __classPrivateFieldSet(this, _ConnectivityController_connectivityAdapter, connectivityAdapter, "f");
77
+ __classPrivateFieldGet(this, _ConnectivityController_connectivityAdapter, "f").onConnectivityChange(this.setConnectivityStatus.bind(this));
78
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
79
+ }
80
+ /**
81
+ * Initializes the controller by fetching the initial connectivity status.
82
+ */
83
+ async init() {
84
+ const initialStatus = await __classPrivateFieldGet(this, _ConnectivityController_connectivityAdapter, "f").getStatus();
85
+ this.setConnectivityStatus(initialStatus);
86
+ }
87
+ /**
88
+ * Sets the connectivity status.
89
+ *
90
+ * @param status - The connectivity status to set.
91
+ */
92
+ setConnectivityStatus(status) {
93
+ this.update((draftState) => {
94
+ draftState.connectivityStatus = status;
70
95
  });
71
96
  }
72
97
  }
98
+ _ConnectivityController_connectivityAdapter = new WeakMap();
73
99
  //# sourceMappingURL=ConnectivityController.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectivityController.mjs","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAG3D,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAGhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAavD;;GAEG;AACH,MAAM,8BAA8B,GAAG;IACrC,kBAAkB,EAAE;QAClB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,IAAI;QAC5B,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,IAAI;KACf;CACmD,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,UAAU,qCAAqC;IACnD,OAAO;QACL,kBAAkB,EAAE,qBAAqB,CAAC,MAAM;KACjD,CAAC;AACJ,CAAC;AAkED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,sBAAuB,SAAQ,cAI3C;IACC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,mBAAmB,GACW;QAC9B,MAAM,aAAa,GAAG,mBAAmB,CAAC,SAAS,EAAE,CAAC;QAEtD,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,8BAA8B;YACxC,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE;gBACL,GAAG,qCAAqC,EAAE;gBAC1C,kBAAkB,EAAE,aAAa;aAClC;SACF,CAAC,CAAC;QAEH,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE;YAClD,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;gBACzB,UAAU,CAAC,kBAAkB,GAAG,MAAM,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { CONNECTIVITY_STATUSES } from './types';\nimport type { ConnectivityAdapter, ConnectivityStatus } from './types';\n\n/**\n * The name of the {@link ConnectivityController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nexport const controllerName = 'ConnectivityController';\n\n/**\n * State for the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerState = {\n /**\n * The current device connectivity status.\n * Named with 'connectivity' prefix to avoid conflicts when state is flattened in Redux.\n */\n connectivityStatus: ConnectivityStatus;\n};\n\n/**\n * The metadata for each property in {@link ConnectivityControllerState}.\n */\nconst connectivityControllerMetadata = {\n connectivityStatus: {\n persist: false,\n includeInDebugSnapshot: true,\n includeInStateLogs: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<ConnectivityControllerState>;\n\n/**\n * Constructs the default {@link ConnectivityController} 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 ConnectivityController} state.\n */\nexport function getDefaultConnectivityControllerState(): ConnectivityControllerState {\n return {\n connectivityStatus: CONNECTIVITY_STATUSES.Online,\n };\n}\n\n/**\n * Retrieves the state of the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ConnectivityControllerState\n>;\n\n/**\n * Actions that {@link ConnectivityControllerMessenger} exposes to other consumers.\n */\nexport type ConnectivityControllerActions =\n ConnectivityControllerGetStateAction;\n\n/**\n * Actions from other messengers that {@link ConnectivityControllerMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when the state of {@link ConnectivityController} changes.\n */\nexport type ConnectivityControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n ConnectivityControllerState\n>;\n\n/**\n * Events that {@link ConnectivityControllerMessenger} exposes to other consumers.\n */\nexport type ConnectivityControllerEvents =\n ConnectivityControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ConnectivityControllerMessenger} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ConnectivityController}.\n */\nexport type ConnectivityControllerMessenger = Messenger<\n typeof controllerName,\n ConnectivityControllerActions | AllowedActions,\n ConnectivityControllerEvents | AllowedEvents\n>;\n\n/**\n * Options for constructing the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerOptions = {\n /**\n * The messenger for inter-controller communication.\n */\n messenger: ConnectivityControllerMessenger;\n\n /**\n * Connectivity adapter for platform-specific detection.\n */\n connectivityAdapter: ConnectivityAdapter;\n};\n\n/**\n * ConnectivityController stores the device's internet connectivity status.\n *\n * This controller is platform-agnostic and designed to be used across different\n * MetaMask clients (extension, mobile). It requires a `ConnectivityAdapter` to\n * be injected, which provides platform-specific connectivity detection.\n *\n * The controller subscribes to the adapter's `onConnectivityChange` callback\n * and updates its state accordingly. All connectivity updates flow through\n * the adapter, ensuring a single source of truth.\n *\n * This controller provides a centralized state for connectivity status,\n * enabling the UI and other controllers to adapt when the user goes offline.\n */\nexport class ConnectivityController extends BaseController<\n typeof controllerName,\n ConnectivityControllerState,\n ConnectivityControllerMessenger\n> {\n /**\n * Constructs a new {@link ConnectivityController}.\n *\n * @param args - The arguments to this controller.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.connectivityAdapter - The connectivity adapter to use.\n */\n constructor({\n messenger,\n connectivityAdapter,\n }: ConnectivityControllerOptions) {\n const initialStatus = connectivityAdapter.getStatus();\n\n super({\n messenger,\n metadata: connectivityControllerMetadata,\n name: controllerName,\n state: {\n ...getDefaultConnectivityControllerState(),\n connectivityStatus: initialStatus,\n },\n });\n\n connectivityAdapter.onConnectivityChange((status) => {\n this.update((draftState) => {\n draftState.connectivityStatus = status;\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ConnectivityController.mjs","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAI3D,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAGhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAavD;;GAEG;AACH,MAAM,8BAA8B,GAAG;IACrC,kBAAkB,EAAE;QAClB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,IAAI;QAC5B,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,IAAI;KACf;CACmD,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,UAAU,qCAAqC;IACnD,OAAO;QACL,kBAAkB,EAAE,qBAAqB,CAAC,MAAM;KACjD,CAAC;AACJ,CAAC;AAED,MAAM,yBAAyB,GAAG,CAAC,uBAAuB,CAAU,CAAC;AAmErE;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,sBAAuB,SAAQ,cAI3C;IAGC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,mBAAmB,GACW;QAC9B,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,8BAA8B;YACxC,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,qCAAqC,EAAE;SAC/C,CAAC,CAAC;QAlBI,8DAA0C;QAoBjD,uBAAA,IAAI,+CAAwB,mBAAmB,MAAA,CAAC;QAEhD,uBAAA,IAAI,mDAAqB,CAAC,oBAAoB,CAC5C,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CACtC,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,aAAa,GAAG,MAAM,uBAAA,IAAI,mDAAqB,CAAC,SAAS,EAAE,CAAC;QAClE,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,qBAAqB,CAAC,MAA0B;QAC9C,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;YACzB,UAAU,CAAC,kBAAkB,GAAG,MAAM,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { ConnectivityControllerMethodActions } from './ConnectivityController-method-action-types';\nimport { CONNECTIVITY_STATUSES } from './types';\nimport type { ConnectivityAdapter, ConnectivityStatus } from './types';\n\n/**\n * The name of the {@link ConnectivityController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nexport const controllerName = 'ConnectivityController';\n\n/**\n * State for the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerState = {\n /**\n * The current device connectivity status.\n * Named with 'connectivity' prefix to avoid conflicts when state is flattened in Redux.\n */\n connectivityStatus: ConnectivityStatus;\n};\n\n/**\n * The metadata for each property in {@link ConnectivityControllerState}.\n */\nconst connectivityControllerMetadata = {\n connectivityStatus: {\n persist: false,\n includeInDebugSnapshot: true,\n includeInStateLogs: true,\n usedInUi: true,\n },\n} satisfies StateMetadata<ConnectivityControllerState>;\n\n/**\n * Constructs the default {@link ConnectivityController} 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 ConnectivityController} state.\n */\nexport function getDefaultConnectivityControllerState(): ConnectivityControllerState {\n return {\n connectivityStatus: CONNECTIVITY_STATUSES.Online,\n };\n}\n\nconst MESSENGER_EXPOSED_METHODS = ['setConnectivityStatus'] as const;\n\n/**\n * Retrieves the state of the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ConnectivityControllerState\n>;\n\n/**\n * Actions that {@link ConnectivityControllerMessenger} exposes to other consumers.\n */\nexport type ConnectivityControllerActions =\n | ConnectivityControllerGetStateAction\n | ConnectivityControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link ConnectivityControllerMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Published when the state of {@link ConnectivityController} changes.\n */\nexport type ConnectivityControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n ConnectivityControllerState\n>;\n\n/**\n * Events that {@link ConnectivityControllerMessenger} exposes to other consumers.\n */\nexport type ConnectivityControllerEvents =\n ConnectivityControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ConnectivityControllerMessenger} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ConnectivityController}.\n */\nexport type ConnectivityControllerMessenger = Messenger<\n typeof controllerName,\n ConnectivityControllerActions | AllowedActions,\n ConnectivityControllerEvents | AllowedEvents\n>;\n\n/**\n * Options for constructing the {@link ConnectivityController}.\n */\nexport type ConnectivityControllerOptions = {\n /**\n * The messenger for inter-controller communication.\n */\n messenger: ConnectivityControllerMessenger;\n\n /**\n * Connectivity adapter for platform-specific detection.\n */\n connectivityAdapter: ConnectivityAdapter;\n};\n\n/**\n * ConnectivityController stores the device's internet connectivity status.\n *\n * This controller is platform-agnostic and designed to be used across different\n * MetaMask clients (extension, mobile). It requires a `ConnectivityAdapter` to\n * be injected, which provides platform-specific connectivity detection.\n *\n * The controller subscribes to the adapter's `onConnectivityChange` callback\n * and updates its state accordingly. All connectivity updates flow through\n * the adapter, ensuring a single source of truth.\n *\n * This controller provides a centralized state for connectivity status,\n * enabling the UI and other controllers to adapt when the user goes offline.\n */\nexport class ConnectivityController extends BaseController<\n typeof controllerName,\n ConnectivityControllerState,\n ConnectivityControllerMessenger\n> {\n readonly #connectivityAdapter: ConnectivityAdapter;\n\n /**\n * Constructs a new {@link ConnectivityController}.\n *\n * @param args - The arguments to this controller.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.connectivityAdapter - The connectivity adapter to use.\n */\n constructor({\n messenger,\n connectivityAdapter,\n }: ConnectivityControllerOptions) {\n super({\n messenger,\n metadata: connectivityControllerMetadata,\n name: controllerName,\n state: getDefaultConnectivityControllerState(),\n });\n\n this.#connectivityAdapter = connectivityAdapter;\n\n this.#connectivityAdapter.onConnectivityChange(\n this.setConnectivityStatus.bind(this),\n );\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Initializes the controller by fetching the initial connectivity status.\n */\n async init(): Promise<void> {\n const initialStatus = await this.#connectivityAdapter.getStatus();\n this.setConnectivityStatus(initialStatus);\n }\n\n /**\n * Sets the connectivity status.\n *\n * @param status - The connectivity status to set.\n */\n setConnectivityStatus(status: ConnectivityStatus): void {\n this.update((draftState) => {\n draftState.connectivityStatus = status;\n });\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultConnectivityControllerState = exports.ConnectivityController = exports.CONNECTIVITY_STATUSES = void 0;
3
+ exports.connectivityControllerSelectors = exports.getDefaultConnectivityControllerState = exports.ConnectivityController = exports.CONNECTIVITY_STATUSES = void 0;
4
4
  var types_1 = require("./types.cjs");
5
5
  Object.defineProperty(exports, "CONNECTIVITY_STATUSES", { enumerable: true, get: function () { return types_1.CONNECTIVITY_STATUSES; } });
6
6
  var ConnectivityController_1 = require("./ConnectivityController.cjs");
7
7
  Object.defineProperty(exports, "ConnectivityController", { enumerable: true, get: function () { return ConnectivityController_1.ConnectivityController; } });
8
8
  Object.defineProperty(exports, "getDefaultConnectivityControllerState", { enumerable: true, get: function () { return ConnectivityController_1.getDefaultConnectivityControllerState; } });
9
+ var selectors_1 = require("./selectors.cjs");
10
+ Object.defineProperty(exports, "connectivityControllerSelectors", { enumerable: true, get: function () { return selectors_1.connectivityControllerSelectors; } });
9
11
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AASA,qCAAgD;AAAvC,8GAAA,qBAAqB,OAAA;AAC9B,uEAGkC;AAFhC,gIAAA,sBAAsB,OAAA;AACtB,+IAAA,qCAAqC,OAAA","sourcesContent":["export type {\n ConnectivityControllerState,\n ConnectivityControllerGetStateAction,\n ConnectivityControllerActions,\n ConnectivityControllerStateChangeEvent,\n ConnectivityControllerEvents,\n ConnectivityControllerMessenger,\n} from './ConnectivityController';\nexport type { ConnectivityAdapter, ConnectivityStatus } from './types';\nexport { CONNECTIVITY_STATUSES } from './types';\nexport {\n ConnectivityController,\n getDefaultConnectivityControllerState,\n} from './ConnectivityController';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAUA,qCAAgD;AAAvC,8GAAA,qBAAqB,OAAA;AAC9B,uEAGkC;AAFhC,gIAAA,sBAAsB,OAAA;AACtB,+IAAA,qCAAqC,OAAA;AAEvC,6CAA8D;AAArD,4HAAA,+BAA+B,OAAA","sourcesContent":["export type {\n ConnectivityControllerState,\n ConnectivityControllerGetStateAction,\n ConnectivityControllerActions,\n ConnectivityControllerStateChangeEvent,\n ConnectivityControllerEvents,\n ConnectivityControllerMessenger,\n} from './ConnectivityController';\nexport type { ConnectivityControllerSetConnectivityStatusAction } from './ConnectivityController-method-action-types';\nexport type { ConnectivityAdapter, ConnectivityStatus } from './types';\nexport { CONNECTIVITY_STATUSES } from './types';\nexport {\n ConnectivityController,\n getDefaultConnectivityControllerState,\n} from './ConnectivityController';\nexport { connectivityControllerSelectors } from './selectors';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  export type { ConnectivityControllerState, ConnectivityControllerGetStateAction, ConnectivityControllerActions, ConnectivityControllerStateChangeEvent, ConnectivityControllerEvents, ConnectivityControllerMessenger, } from "./ConnectivityController.cjs";
2
+ export type { ConnectivityControllerSetConnectivityStatusAction } from "./ConnectivityController-method-action-types.cjs";
2
3
  export type { ConnectivityAdapter, ConnectivityStatus } from "./types.cjs";
3
4
  export { CONNECTIVITY_STATUSES } from "./types.cjs";
4
5
  export { ConnectivityController, getDefaultConnectivityControllerState, } from "./ConnectivityController.cjs";
6
+ export { connectivityControllerSelectors } from "./selectors.cjs";
5
7
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,2BAA2B,EAC3B,oCAAoC,EACpC,6BAA6B,EAC7B,sCAAsC,EACtC,4BAA4B,EAC5B,+BAA+B,GAChC,qCAAiC;AAClC,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAgB;AACvE,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAChD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAiC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,2BAA2B,EAC3B,oCAAoC,EACpC,6BAA6B,EAC7B,sCAAsC,EACtC,4BAA4B,EAC5B,+BAA+B,GAChC,qCAAiC;AAClC,YAAY,EAAE,iDAAiD,EAAE,yDAAqD;AACtH,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAgB;AACvE,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAChD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAiC;AAClC,OAAO,EAAE,+BAA+B,EAAE,wBAAoB"}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,7 @@
1
1
  export type { ConnectivityControllerState, ConnectivityControllerGetStateAction, ConnectivityControllerActions, ConnectivityControllerStateChangeEvent, ConnectivityControllerEvents, ConnectivityControllerMessenger, } from "./ConnectivityController.mjs";
2
+ export type { ConnectivityControllerSetConnectivityStatusAction } from "./ConnectivityController-method-action-types.mjs";
2
3
  export type { ConnectivityAdapter, ConnectivityStatus } from "./types.mjs";
3
4
  export { CONNECTIVITY_STATUSES } from "./types.mjs";
4
5
  export { ConnectivityController, getDefaultConnectivityControllerState, } from "./ConnectivityController.mjs";
6
+ export { connectivityControllerSelectors } from "./selectors.mjs";
5
7
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,2BAA2B,EAC3B,oCAAoC,EACpC,6BAA6B,EAC7B,sCAAsC,EACtC,4BAA4B,EAC5B,+BAA+B,GAChC,qCAAiC;AAClC,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAgB;AACvE,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAChD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAiC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,2BAA2B,EAC3B,oCAAoC,EACpC,6BAA6B,EAC7B,sCAAsC,EACtC,4BAA4B,EAC5B,+BAA+B,GAChC,qCAAiC;AAClC,YAAY,EAAE,iDAAiD,EAAE,yDAAqD;AACtH,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAgB;AACvE,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAChD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAiC;AAClC,OAAO,EAAE,+BAA+B,EAAE,wBAAoB"}
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
1
  export { CONNECTIVITY_STATUSES } from "./types.mjs";
2
2
  export { ConnectivityController, getDefaultConnectivityControllerState } from "./ConnectivityController.mjs";
3
+ export { connectivityControllerSelectors } from "./selectors.mjs";
3
4
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAChD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACtC,qCAAiC","sourcesContent":["export type {\n ConnectivityControllerState,\n ConnectivityControllerGetStateAction,\n ConnectivityControllerActions,\n ConnectivityControllerStateChangeEvent,\n ConnectivityControllerEvents,\n ConnectivityControllerMessenger,\n} from './ConnectivityController';\nexport type { ConnectivityAdapter, ConnectivityStatus } from './types';\nexport { CONNECTIVITY_STATUSES } from './types';\nexport {\n ConnectivityController,\n getDefaultConnectivityControllerState,\n} from './ConnectivityController';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAChD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACtC,qCAAiC;AAClC,OAAO,EAAE,+BAA+B,EAAE,wBAAoB","sourcesContent":["export type {\n ConnectivityControllerState,\n ConnectivityControllerGetStateAction,\n ConnectivityControllerActions,\n ConnectivityControllerStateChangeEvent,\n ConnectivityControllerEvents,\n ConnectivityControllerMessenger,\n} from './ConnectivityController';\nexport type { ConnectivityControllerSetConnectivityStatusAction } from './ConnectivityController-method-action-types';\nexport type { ConnectivityAdapter, ConnectivityStatus } from './types';\nexport { CONNECTIVITY_STATUSES } from './types';\nexport {\n ConnectivityController,\n getDefaultConnectivityControllerState,\n} from './ConnectivityController';\nexport { connectivityControllerSelectors } from './selectors';\n"]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.connectivityControllerSelectors = void 0;
4
+ const reselect_1 = require("reselect");
5
+ const types_1 = require("./types.cjs");
6
+ /**
7
+ * Selects the connectivity status from the controller state.
8
+ *
9
+ * @param state - The controller state
10
+ * @returns The connectivity status
11
+ */
12
+ const selectConnectivityStatus = (state) => state.connectivityStatus;
13
+ /**
14
+ * Selects whether the device is offline.
15
+ *
16
+ * @param state - The controller state
17
+ * @returns Whether the device is offline
18
+ */
19
+ const selectIsOffline = (0, reselect_1.createSelector)([selectConnectivityStatus], (connectivityStatus) => connectivityStatus === types_1.CONNECTIVITY_STATUSES.Offline);
20
+ /**
21
+ * Selectors for the ConnectivityController state.
22
+ * These can be used with Redux or directly with controller state.
23
+ */
24
+ exports.connectivityControllerSelectors = {
25
+ selectConnectivityStatus,
26
+ selectIsOffline,
27
+ };
28
+ //# sourceMappingURL=selectors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAG1C,uCAAgD;AAGhD;;;;;GAKG;AACH,MAAM,wBAAwB,GAAG,CAC/B,KAAkC,EACd,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,eAAe,GAAG,IAAA,yBAAc,EACpC,CAAC,wBAAwB,CAAC,EAC1B,CAAC,kBAAkB,EAAE,EAAE,CAAC,kBAAkB,KAAK,6BAAqB,CAAC,OAAO,CAC7E,CAAC;AAEF;;;GAGG;AACU,QAAA,+BAA+B,GAAG;IAC7C,wBAAwB;IACxB,eAAe;CAChB,CAAC","sourcesContent":["import { createSelector } from 'reselect';\n\nimport type { ConnectivityControllerState } from './ConnectivityController';\nimport { CONNECTIVITY_STATUSES } from './types';\nimport type { ConnectivityStatus } from './types';\n\n/**\n * Selects the connectivity status from the controller state.\n *\n * @param state - The controller state\n * @returns The connectivity status\n */\nconst selectConnectivityStatus = (\n state: ConnectivityControllerState,\n): ConnectivityStatus => state.connectivityStatus;\n\n/**\n * Selects whether the device is offline.\n *\n * @param state - The controller state\n * @returns Whether the device is offline\n */\nconst selectIsOffline = createSelector(\n [selectConnectivityStatus],\n (connectivityStatus) => connectivityStatus === CONNECTIVITY_STATUSES.Offline,\n);\n\n/**\n * Selectors for the ConnectivityController state.\n * These can be used with Redux or directly with controller state.\n */\nexport const connectivityControllerSelectors = {\n selectConnectivityStatus,\n selectIsOffline,\n};\n"]}
@@ -0,0 +1,31 @@
1
+ import type { ConnectivityControllerState } from "./ConnectivityController.cjs";
2
+ import type { ConnectivityStatus } from "./types.cjs";
3
+ /**
4
+ * Selectors for the ConnectivityController state.
5
+ * These can be used with Redux or directly with controller state.
6
+ */
7
+ export declare const connectivityControllerSelectors: {
8
+ selectConnectivityStatus: (state: ConnectivityControllerState) => ConnectivityStatus;
9
+ selectIsOffline: ((state: ConnectivityControllerState) => boolean) & {
10
+ clearCache: () => void;
11
+ resultsCount: () => number;
12
+ resetResultsCount: () => void;
13
+ } & {
14
+ resultFunc: (resultFuncArgs_0: ConnectivityStatus) => boolean;
15
+ memoizedResultFunc: ((resultFuncArgs_0: ConnectivityStatus) => boolean) & {
16
+ clearCache: () => void;
17
+ resultsCount: () => number;
18
+ resetResultsCount: () => void;
19
+ };
20
+ lastResult: () => boolean;
21
+ dependencies: [(state: ConnectivityControllerState) => ConnectivityStatus];
22
+ recomputations: () => number;
23
+ resetRecomputations: () => void;
24
+ dependencyRecomputations: () => number;
25
+ resetDependencyRecomputations: () => void;
26
+ } & {
27
+ memoize: typeof import("reselect").weakMapMemoize;
28
+ argsMemoize: typeof import("reselect").weakMapMemoize;
29
+ };
30
+ };
31
+ //# sourceMappingURL=selectors.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,qCAAiC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAuBlD;;;GAGG;AACH,eAAO,MAAM,+BAA+B;sCAlBnC,2BAA2B,KACjC,kBAAkB;;;;;;;;;;;;;+BADZ,2BAA2B,KACjC,kBAAkB;;;;;;;;;CAoBpB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { ConnectivityControllerState } from "./ConnectivityController.mjs";
2
+ import type { ConnectivityStatus } from "./types.mjs";
3
+ /**
4
+ * Selectors for the ConnectivityController state.
5
+ * These can be used with Redux or directly with controller state.
6
+ */
7
+ export declare const connectivityControllerSelectors: {
8
+ selectConnectivityStatus: (state: ConnectivityControllerState) => ConnectivityStatus;
9
+ selectIsOffline: ((state: ConnectivityControllerState) => boolean) & {
10
+ clearCache: () => void;
11
+ resultsCount: () => number;
12
+ resetResultsCount: () => void;
13
+ } & {
14
+ resultFunc: (resultFuncArgs_0: ConnectivityStatus) => boolean;
15
+ memoizedResultFunc: ((resultFuncArgs_0: ConnectivityStatus) => boolean) & {
16
+ clearCache: () => void;
17
+ resultsCount: () => number;
18
+ resetResultsCount: () => void;
19
+ };
20
+ lastResult: () => boolean;
21
+ dependencies: [(state: ConnectivityControllerState) => ConnectivityStatus];
22
+ recomputations: () => number;
23
+ resetRecomputations: () => void;
24
+ dependencyRecomputations: () => number;
25
+ resetDependencyRecomputations: () => void;
26
+ } & {
27
+ memoize: typeof import("reselect").weakMapMemoize;
28
+ argsMemoize: typeof import("reselect").weakMapMemoize;
29
+ };
30
+ };
31
+ //# sourceMappingURL=selectors.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,qCAAiC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAuBlD;;;GAGG;AACH,eAAO,MAAM,+BAA+B;sCAlBnC,2BAA2B,KACjC,kBAAkB;;;;;;;;;;;;;+BADZ,2BAA2B,KACjC,kBAAkB;;;;;;;;;CAoBpB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { createSelector } from "reselect";
2
+ import { CONNECTIVITY_STATUSES } from "./types.mjs";
3
+ /**
4
+ * Selects the connectivity status from the controller state.
5
+ *
6
+ * @param state - The controller state
7
+ * @returns The connectivity status
8
+ */
9
+ const selectConnectivityStatus = (state) => state.connectivityStatus;
10
+ /**
11
+ * Selects whether the device is offline.
12
+ *
13
+ * @param state - The controller state
14
+ * @returns Whether the device is offline
15
+ */
16
+ const selectIsOffline = createSelector([selectConnectivityStatus], (connectivityStatus) => connectivityStatus === CONNECTIVITY_STATUSES.Offline);
17
+ /**
18
+ * Selectors for the ConnectivityController state.
19
+ * These can be used with Redux or directly with controller state.
20
+ */
21
+ export const connectivityControllerSelectors = {
22
+ selectConnectivityStatus,
23
+ selectIsOffline,
24
+ };
25
+ //# sourceMappingURL=selectors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB;AAG1C,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAGhD;;;;;GAKG;AACH,MAAM,wBAAwB,GAAG,CAC/B,KAAkC,EACd,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,eAAe,GAAG,cAAc,CACpC,CAAC,wBAAwB,CAAC,EAC1B,CAAC,kBAAkB,EAAE,EAAE,CAAC,kBAAkB,KAAK,qBAAqB,CAAC,OAAO,CAC7E,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,wBAAwB;IACxB,eAAe;CAChB,CAAC","sourcesContent":["import { createSelector } from 'reselect';\n\nimport type { ConnectivityControllerState } from './ConnectivityController';\nimport { CONNECTIVITY_STATUSES } from './types';\nimport type { ConnectivityStatus } from './types';\n\n/**\n * Selects the connectivity status from the controller state.\n *\n * @param state - The controller state\n * @returns The connectivity status\n */\nconst selectConnectivityStatus = (\n state: ConnectivityControllerState,\n): ConnectivityStatus => state.connectivityStatus;\n\n/**\n * Selects whether the device is offline.\n *\n * @param state - The controller state\n * @returns Whether the device is offline\n */\nconst selectIsOffline = createSelector(\n [selectConnectivityStatus],\n (connectivityStatus) => connectivityStatus === CONNECTIVITY_STATUSES.Offline,\n);\n\n/**\n * Selectors for the ConnectivityController state.\n * These can be used with Redux or directly with controller state.\n */\nexport const connectivityControllerSelectors = {\n selectConnectivityStatus,\n selectIsOffline,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,qBAAqB,GAAG;IACnC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC","sourcesContent":["/**\n * Connectivity status constants.\n * Used to represent whether the device has internet connectivity.\n */\nexport const CONNECTIVITY_STATUSES = {\n Online: 'online',\n Offline: 'offline',\n} as const;\n\nexport type ConnectivityStatus =\n (typeof CONNECTIVITY_STATUSES)[keyof typeof CONNECTIVITY_STATUSES];\n\n/**\n * Adapter interface for platform-specific connectivity detection.\n * Each platform (extension, mobile) implements this interface using\n * platform-specific APIs to detect internet connectivity.\n */\nexport type ConnectivityAdapter = {\n /**\n * Returns the current connectivity status.\n *\n * @returns 'online' if the device is online, 'offline' otherwise.\n */\n getStatus(): ConnectivityStatus;\n\n /**\n * Registers a callback to be called when connectivity status changes.\n *\n * @param callback - Function called with 'online' when online, 'offline' when offline.\n */\n onConnectivityChange(callback: (status: ConnectivityStatus) => void): void;\n\n /**\n * Cleans up any resources (event listeners, subscriptions).\n */\n destroy(): void;\n};\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,qBAAqB,GAAG;IACnC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC","sourcesContent":["/**\n * Connectivity status constants.\n * Used to represent whether the device has internet connectivity.\n */\nexport const CONNECTIVITY_STATUSES = {\n Online: 'online',\n Offline: 'offline',\n} as const;\n\nexport type ConnectivityStatus =\n (typeof CONNECTIVITY_STATUSES)[keyof typeof CONNECTIVITY_STATUSES];\n\n/**\n * Adapter interface for platform-specific connectivity detection.\n * Each platform (extension, mobile) implements this interface using\n * platform-specific APIs to detect internet connectivity.\n */\nexport type ConnectivityAdapter = {\n /**\n * Returns a promise that resolves to the current connectivity status.\n *\n * @returns A promise that resolves to 'online' if the device is online, 'offline' otherwise.\n */\n getStatus(): Promise<ConnectivityStatus>;\n\n /**\n * Registers a callback to be called when connectivity status changes.\n *\n * @param callback - Function called with 'online' when online, 'offline' when offline.\n */\n onConnectivityChange(callback: (status: ConnectivityStatus) => void): void;\n\n /**\n * Cleans up any resources (event listeners, subscriptions).\n */\n destroy(): void;\n};\n"]}
package/dist/types.d.cts CHANGED
@@ -14,11 +14,11 @@ export type ConnectivityStatus = (typeof CONNECTIVITY_STATUSES)[keyof typeof CON
14
14
  */
15
15
  export type ConnectivityAdapter = {
16
16
  /**
17
- * Returns the current connectivity status.
17
+ * Returns a promise that resolves to the current connectivity status.
18
18
  *
19
- * @returns 'online' if the device is online, 'offline' otherwise.
19
+ * @returns A promise that resolves to 'online' if the device is online, 'offline' otherwise.
20
20
  */
21
- getStatus(): ConnectivityStatus;
21
+ getStatus(): Promise<ConnectivityStatus>;
22
22
  /**
23
23
  * Registers a callback to be called when connectivity status changes.
24
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;CAGxB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,CAAC;IAEhC;;;;OAIG;IACH,oBAAoB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,GAAG,IAAI,CAAC;IAE3E;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC"}
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;CAGxB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,SAAS,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEzC;;;;OAIG;IACH,oBAAoB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,GAAG,IAAI,CAAC;IAE3E;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC"}
package/dist/types.d.mts CHANGED
@@ -14,11 +14,11 @@ export type ConnectivityStatus = (typeof CONNECTIVITY_STATUSES)[keyof typeof CON
14
14
  */
15
15
  export type ConnectivityAdapter = {
16
16
  /**
17
- * Returns the current connectivity status.
17
+ * Returns a promise that resolves to the current connectivity status.
18
18
  *
19
- * @returns 'online' if the device is online, 'offline' otherwise.
19
+ * @returns A promise that resolves to 'online' if the device is online, 'offline' otherwise.
20
20
  */
21
- getStatus(): ConnectivityStatus;
21
+ getStatus(): Promise<ConnectivityStatus>;
22
22
  /**
23
23
  * Registers a callback to be called when connectivity status changes.
24
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;CAGxB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,CAAC;IAEhC;;;;OAIG;IACH,oBAAoB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,GAAG,IAAI,CAAC;IAE3E;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC"}
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;CAGxB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,SAAS,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEzC;;;;OAIG;IACH,oBAAoB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,GAAG,IAAI,CAAC;IAE3E;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC","sourcesContent":["/**\n * Connectivity status constants.\n * Used to represent whether the device has internet connectivity.\n */\nexport const CONNECTIVITY_STATUSES = {\n Online: 'online',\n Offline: 'offline',\n} as const;\n\nexport type ConnectivityStatus =\n (typeof CONNECTIVITY_STATUSES)[keyof typeof CONNECTIVITY_STATUSES];\n\n/**\n * Adapter interface for platform-specific connectivity detection.\n * Each platform (extension, mobile) implements this interface using\n * platform-specific APIs to detect internet connectivity.\n */\nexport type ConnectivityAdapter = {\n /**\n * Returns the current connectivity status.\n *\n * @returns 'online' if the device is online, 'offline' otherwise.\n */\n getStatus(): ConnectivityStatus;\n\n /**\n * Registers a callback to be called when connectivity status changes.\n *\n * @param callback - Function called with 'online' when online, 'offline' when offline.\n */\n onConnectivityChange(callback: (status: ConnectivityStatus) => void): void;\n\n /**\n * Cleans up any resources (event listeners, subscriptions).\n */\n destroy(): void;\n};\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACV,CAAC","sourcesContent":["/**\n * Connectivity status constants.\n * Used to represent whether the device has internet connectivity.\n */\nexport const CONNECTIVITY_STATUSES = {\n Online: 'online',\n Offline: 'offline',\n} as const;\n\nexport type ConnectivityStatus =\n (typeof CONNECTIVITY_STATUSES)[keyof typeof CONNECTIVITY_STATUSES];\n\n/**\n * Adapter interface for platform-specific connectivity detection.\n * Each platform (extension, mobile) implements this interface using\n * platform-specific APIs to detect internet connectivity.\n */\nexport type ConnectivityAdapter = {\n /**\n * Returns a promise that resolves to the current connectivity status.\n *\n * @returns A promise that resolves to 'online' if the device is online, 'offline' otherwise.\n */\n getStatus(): Promise<ConnectivityStatus>;\n\n /**\n * Registers a callback to be called when connectivity status changes.\n *\n * @param callback - Function called with 'online' when online, 'offline' when offline.\n */\n onConnectivityChange(callback: (status: ConnectivityStatus) => void): void;\n\n /**\n * Cleans up any resources (event listeners, subscriptions).\n */\n destroy(): void;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/connectivity-controller",
3
- "version": "0.1.0-preview-903db2da",
3
+ "version": "0.1.0-preview-3ec2a74",
4
4
  "description": "ConnectivityController stores the device's internet connectivity status",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -49,7 +49,8 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@metamask/base-controller": "^9.0.0",
52
- "@metamask/messenger": "^0.3.0"
52
+ "@metamask/messenger": "^0.3.0",
53
+ "reselect": "^5.1.1"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@metamask/auto-changelog": "^3.4.4",