@metamask-previews/connectivity-controller 0.3.0-preview-40d5fb1e2 → 0.3.0-preview-0dfe3b334

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.
@@ -1 +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.\n * Do not edit manually.\n */\n\nimport type { ConnectivityController } from './ConnectivityController';\n\n/**\n * Initializes the controller by fetching the initial connectivity status.\n */\nexport type ConnectivityControllerInitAction = {\n type: `ConnectivityController:init`;\n handler: ConnectivityController['init'];\n};\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 | ConnectivityControllerInitAction\n | ConnectivityControllerSetConnectivityStatusAction;\n"]}
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.\n * Do not edit manually.\n */\n\nimport type { ConnectivityController } from './ConnectivityController.js';\n\n/**\n * Initializes the controller by fetching the initial connectivity status.\n */\nexport type ConnectivityControllerInitAction = {\n type: `ConnectivityController:init`;\n handler: ConnectivityController['init'];\n};\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 | ConnectivityControllerInitAction\n | ConnectivityControllerSetConnectivityStatusAction;\n"]}
@@ -1 +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;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;CACzC,CAAC;AAEF;;;;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,GAC3C,gCAAgC,GAChC,iDAAiD,CAAC"}
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,qCAAoC;AAE1E;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;CACzC,CAAC;AAEF;;;;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,GAC3C,gCAAgC,GAChC,iDAAiD,CAAC"}
@@ -1 +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;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;CACzC,CAAC;AAEF;;;;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,GAC3C,gCAAgC,GAChC,iDAAiD,CAAC"}
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,qCAAoC;AAE1E;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;CACzC,CAAC;AAEF;;;;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,GAC3C,gCAAgC,GAChC,iDAAiD,CAAC"}
@@ -1 +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.\n * Do not edit manually.\n */\n\nimport type { ConnectivityController } from './ConnectivityController';\n\n/**\n * Initializes the controller by fetching the initial connectivity status.\n */\nexport type ConnectivityControllerInitAction = {\n type: `ConnectivityController:init`;\n handler: ConnectivityController['init'];\n};\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 | ConnectivityControllerInitAction\n | ConnectivityControllerSetConnectivityStatusAction;\n"]}
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.\n * Do not edit manually.\n */\n\nimport type { ConnectivityController } from './ConnectivityController.js';\n\n/**\n * Initializes the controller by fetching the initial connectivity status.\n */\nexport type ConnectivityControllerInitAction = {\n type: `ConnectivityController:init`;\n handler: ConnectivityController['init'];\n};\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 | ConnectivityControllerInitAction\n | ConnectivityControllerSetConnectivityStatusAction;\n"]}
@@ -14,7 +14,7 @@ var _ConnectivityController_connectivityAdapter;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ConnectivityController = exports.getDefaultConnectivityControllerState = exports.controllerName = void 0;
16
16
  const base_controller_1 = require("@metamask/base-controller");
17
- const types_1 = require("./types.cjs");
17
+ const types_js_1 = require("./types.cjs");
18
18
  /**
19
19
  * The name of the {@link ConnectivityController}, used to namespace the
20
20
  * controller's actions and events and to namespace the controller's state data
@@ -42,7 +42,7 @@ const connectivityControllerMetadata = {
42
42
  */
43
43
  function getDefaultConnectivityControllerState() {
44
44
  return {
45
- connectivityStatus: types_1.CONNECTIVITY_STATUSES.Online,
45
+ connectivityStatus: types_js_1.CONNECTIVITY_STATUSES.Online,
46
46
  };
47
47
  }
48
48
  exports.getDefaultConnectivityControllerState = getDefaultConnectivityControllerState;
@@ -1 +1 @@
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,MAAM,EAAE,uBAAuB,CAAU,CAAC;AAmE7E;;;;;;;;;;;;;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 = ['init', '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
+ {"version":3,"file":"ConnectivityController.cjs","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAI3D,0CAAmD;AAGnD;;;;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,gCAAqB,CAAC,MAAM;KACjD,CAAC;AACJ,CAAC;AAJD,sFAIC;AAED,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAU,CAAC;AAmE7E;;;;;;;;;;;;;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.js';\nimport { CONNECTIVITY_STATUSES } from './types.js';\nimport type { ConnectivityAdapter, ConnectivityStatus } from './types.js';\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 = ['init', '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 +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;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
+ {"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,yDAAwD;AAEtG,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAmB;AAE1E;;;;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 +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;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
+ {"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,yDAAwD;AAEtG,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAmB;AAE1E;;;;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 +1 @@
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,MAAM,EAAE,uBAAuB,CAAU,CAAC;AAmE7E;;;;;;;;;;;;;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 = ['init', '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
+ {"version":3,"file":"ConnectivityController.mjs","sourceRoot":"","sources":["../src/ConnectivityController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAI3D,OAAO,EAAE,qBAAqB,EAAE,oBAAmB;AAGnD;;;;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,MAAM,EAAE,uBAAuB,CAAU,CAAC;AAmE7E;;;;;;;;;;;;;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.js';\nimport { CONNECTIVITY_STATUSES } from './types.js';\nimport type { ConnectivityAdapter, ConnectivityStatus } from './types.js';\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 = ['init', '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,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.connectivityControllerSelectors = exports.getDefaultConnectivityControllerState = exports.ConnectivityController = exports.CONNECTIVITY_STATUSES = void 0;
4
- var types_1 = require("./types.cjs");
5
- Object.defineProperty(exports, "CONNECTIVITY_STATUSES", { enumerable: true, get: function () { return types_1.CONNECTIVITY_STATUSES; } });
6
- var ConnectivityController_1 = require("./ConnectivityController.cjs");
7
- Object.defineProperty(exports, "ConnectivityController", { enumerable: true, get: function () { return ConnectivityController_1.ConnectivityController; } });
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; } });
4
+ var types_js_1 = require("./types.cjs");
5
+ Object.defineProperty(exports, "CONNECTIVITY_STATUSES", { enumerable: true, get: function () { return types_js_1.CONNECTIVITY_STATUSES; } });
6
+ var ConnectivityController_js_1 = require("./ConnectivityController.cjs");
7
+ Object.defineProperty(exports, "ConnectivityController", { enumerable: true, get: function () { return ConnectivityController_js_1.ConnectivityController; } });
8
+ Object.defineProperty(exports, "getDefaultConnectivityControllerState", { enumerable: true, get: function () { return ConnectivityController_js_1.getDefaultConnectivityControllerState; } });
9
+ var selectors_js_1 = require("./selectors.cjs");
10
+ Object.defineProperty(exports, "connectivityControllerSelectors", { enumerable: true, get: function () { return selectors_js_1.connectivityControllerSelectors; } });
11
11
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAUA,wCAAmD;AAA1C,iHAAA,qBAAqB,OAAA;AAC9B,0EAGqC;AAFnC,mIAAA,sBAAsB,OAAA;AACtB,kJAAA,qCAAqC,OAAA;AAEvC,gDAAiE;AAAxD,+HAAA,+BAA+B,OAAA","sourcesContent":["export type {\n ConnectivityControllerState,\n ConnectivityControllerGetStateAction,\n ConnectivityControllerActions,\n ConnectivityControllerStateChangeEvent,\n ConnectivityControllerEvents,\n ConnectivityControllerMessenger,\n} from './ConnectivityController.js';\nexport type { ConnectivityControllerSetConnectivityStatusAction } from './ConnectivityController-method-action-types.js';\nexport type { ConnectivityAdapter, ConnectivityStatus } from './types.js';\nexport { CONNECTIVITY_STATUSES } from './types.js';\nexport {\n ConnectivityController,\n getDefaultConnectivityControllerState,\n} from './ConnectivityController.js';\nexport { connectivityControllerSelectors } from './selectors.js';\n"]}
@@ -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,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"}
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,qCAAoC;AACrC,YAAY,EAAE,iDAAiD,EAAE,yDAAwD;AACzH,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAmB;AAC1E,OAAO,EAAE,qBAAqB,EAAE,oBAAmB;AACnD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAoC;AACrC,OAAO,EAAE,+BAA+B,EAAE,wBAAuB"}
@@ -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,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"}
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,qCAAoC;AACrC,YAAY,EAAE,iDAAiD,EAAE,yDAAwD;AACzH,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAmB;AAC1E,OAAO,EAAE,qBAAqB,EAAE,oBAAmB;AACnD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,GACtC,qCAAoC;AACrC,OAAO,EAAE,+BAA+B,EAAE,wBAAuB"}
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,qBAAqB,EAAE,oBAAmB;AACnD,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACtC,qCAAoC;AACrC,OAAO,EAAE,+BAA+B,EAAE,wBAAuB","sourcesContent":["export type {\n ConnectivityControllerState,\n ConnectivityControllerGetStateAction,\n ConnectivityControllerActions,\n ConnectivityControllerStateChangeEvent,\n ConnectivityControllerEvents,\n ConnectivityControllerMessenger,\n} from './ConnectivityController.js';\nexport type { ConnectivityControllerSetConnectivityStatusAction } from './ConnectivityController-method-action-types.js';\nexport type { ConnectivityAdapter, ConnectivityStatus } from './types.js';\nexport { CONNECTIVITY_STATUSES } from './types.js';\nexport {\n ConnectivityController,\n getDefaultConnectivityControllerState,\n} from './ConnectivityController.js';\nexport { connectivityControllerSelectors } from './selectors.js';\n"]}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.connectivityControllerSelectors = void 0;
4
4
  const reselect_1 = require("reselect");
5
- const types_1 = require("./types.cjs");
5
+ const types_js_1 = require("./types.cjs");
6
6
  /**
7
7
  * Selects the connectivity status from the controller state.
8
8
  *
@@ -16,7 +16,7 @@ const selectConnectivityStatus = (state) => state.connectivityStatus;
16
16
  * @param state - The controller state
17
17
  * @returns Whether the device is offline
18
18
  */
19
- const selectIsOffline = (0, reselect_1.createSelector)([selectConnectivityStatus], (connectivityStatus) => connectivityStatus === types_1.CONNECTIVITY_STATUSES.Offline);
19
+ const selectIsOffline = (0, reselect_1.createSelector)([selectConnectivityStatus], (connectivityStatus) => connectivityStatus === types_js_1.CONNECTIVITY_STATUSES.Offline);
20
20
  /**
21
21
  * Selectors for the ConnectivityController state.
22
22
  * These can be used with Redux or directly with controller state.
@@ -1 +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"]}
1
+ {"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAG1C,0CAAmD;AAGnD;;;;;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,gCAAqB,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.js';\nimport { CONNECTIVITY_STATUSES } from './types.js';\nimport type { ConnectivityStatus } from './types.js';\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":"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"}
1
+ {"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,qCAAoC;AAE/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAmB;AAuBrD;;;GAGG;AACH,eAAO,MAAM,+BAA+B;sCAlBnC,2BAA2B,KACjC,kBAAkB;;;;;;;;;;;;;+BADZ,2BAA2B,KACjC,kBAAkB;;;;;;;;;CAoBpB,CAAC"}
@@ -1 +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"}
1
+ {"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,qCAAoC;AAE/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAmB;AAuBrD;;;GAGG;AACH,eAAO,MAAM,+BAA+B;sCAlBnC,2BAA2B,KACjC,kBAAkB;;;;;;;;;;;;;+BADZ,2BAA2B,KACjC,kBAAkB;;;;;;;;;CAoBpB,CAAC"}
@@ -1 +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
+ {"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB;AAG1C,OAAO,EAAE,qBAAqB,EAAE,oBAAmB;AAGnD;;;;;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.js';\nimport { CONNECTIVITY_STATUSES } from './types.js';\nimport type { ConnectivityStatus } from './types.js';\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/connectivity-controller",
3
- "version": "0.3.0-preview-40d5fb1e2",
3
+ "version": "0.3.0-preview-0dfe3b334",
4
4
  "description": "ConnectivityController stores the device's internet connectivity status",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -46,8 +46,8 @@
46
46
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/connectivity-controller",
47
47
  "lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
48
48
  "lint:tsconfigs:fix": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts --fix",
49
- "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check",
50
- "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate",
49
+ "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --check",
50
+ "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --esm --generate",
51
51
  "since-latest-release": "../../scripts/since-latest-release.sh",
52
52
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
53
53
  "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
@@ -62,10 +62,10 @@
62
62
  "devDependencies": {
63
63
  "@metamask/auto-changelog": "^6.1.0",
64
64
  "@ts-bridge/cli": "^0.6.4",
65
- "@types/jest": "^29.5.14",
65
+ "@types/jest": "^30.0.0",
66
66
  "deepmerge": "^4.2.2",
67
- "jest": "^29.7.0",
68
- "ts-jest": "^29.2.5",
67
+ "jest": "^30.4.2",
68
+ "ts-jest": "^29.4.11",
69
69
  "tsx": "^4.20.5",
70
70
  "typedoc": "^0.25.13",
71
71
  "typedoc-plugin-missing-exports": "^2.0.0",