@metamask-previews/base-controller 3.2.0-preview.d32a7cc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/BaseController.d.ts +114 -0
- package/dist/BaseController.d.ts.map +1 -0
- package/dist/BaseController.js +146 -0
- package/dist/BaseController.js.map +1 -0
- package/dist/BaseControllerV2.d.ts +147 -0
- package/dist/BaseControllerV2.d.ts.map +1 -0
- package/dist/BaseControllerV2.js +144 -0
- package/dist/BaseControllerV2.js.map +1 -0
- package/dist/ControllerMessenger.d.ts +357 -0
- package/dist/ControllerMessenger.d.ts.map +1 -0
- package/dist/ControllerMessenger.js +375 -0
- package/dist/ControllerMessenger.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPersistentState = exports.getAnonymizedState = exports.BaseController = void 0;
|
|
4
|
+
const immer_1 = require("immer");
|
|
5
|
+
(0, immer_1.enablePatches)();
|
|
6
|
+
/**
|
|
7
|
+
* Controller class that provides state management, subscriptions, and state metadata
|
|
8
|
+
*/
|
|
9
|
+
class BaseController {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a BaseController instance.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Controller options.
|
|
14
|
+
* @param options.messenger - Controller messaging system.
|
|
15
|
+
* @param options.metadata - State metadata, describing how to "anonymize" the state, and which
|
|
16
|
+
* parts should be persisted.
|
|
17
|
+
* @param options.name - The name of the controller, used as a namespace for events and actions.
|
|
18
|
+
* @param options.state - Initial controller state.
|
|
19
|
+
*/
|
|
20
|
+
constructor({ messenger, metadata, name, state, }) {
|
|
21
|
+
this.messagingSystem = messenger;
|
|
22
|
+
this.name = name;
|
|
23
|
+
this.internalState = state;
|
|
24
|
+
this.metadata = metadata;
|
|
25
|
+
this.messagingSystem.registerActionHandler(`${name}:getState`, () => this.state);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves current controller state.
|
|
29
|
+
*
|
|
30
|
+
* @returns The current state.
|
|
31
|
+
*/
|
|
32
|
+
get state() {
|
|
33
|
+
return this.internalState;
|
|
34
|
+
}
|
|
35
|
+
set state(_) {
|
|
36
|
+
throw new Error(`Controller state cannot be directly mutated; use 'update' method instead.`);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Updates controller state. Accepts a callback that is passed a draft copy
|
|
40
|
+
* of the controller state. If a value is returned, it is set as the new
|
|
41
|
+
* state. Otherwise, any changes made within that callback to the draft are
|
|
42
|
+
* applied to the controller state.
|
|
43
|
+
*
|
|
44
|
+
* @param callback - Callback for updating state, passed a draft state
|
|
45
|
+
* object. Return a new state object or mutate the draft to update state.
|
|
46
|
+
* @returns An object that has the next state, patches applied in the update and inverse patches to
|
|
47
|
+
* rollback the update.
|
|
48
|
+
*/
|
|
49
|
+
update(callback) {
|
|
50
|
+
// We run into ts2589, "infinite type depth", if we don't cast
|
|
51
|
+
// produceWithPatches here.
|
|
52
|
+
const [nextState, patches, inversePatches] = immer_1.produceWithPatches(this.internalState, callback);
|
|
53
|
+
this.internalState = nextState;
|
|
54
|
+
this.messagingSystem.publish(`${this.name}:stateChange`, nextState, patches);
|
|
55
|
+
return { nextState, patches, inversePatches };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Applies immer patches to the current state. The patches come from the
|
|
59
|
+
* update function itself and can either be normal or inverse patches.
|
|
60
|
+
*
|
|
61
|
+
* @param patches - An array of immer patches that are to be applied to make
|
|
62
|
+
* or undo changes.
|
|
63
|
+
*/
|
|
64
|
+
applyPatches(patches) {
|
|
65
|
+
const nextState = (0, immer_1.applyPatches)(this.internalState, patches);
|
|
66
|
+
this.internalState = nextState;
|
|
67
|
+
this.messagingSystem.publish(`${this.name}:stateChange`, nextState, patches);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Prepares the controller for garbage collection. This should be extended
|
|
71
|
+
* by any subclasses to clean up any additional connections or events.
|
|
72
|
+
*
|
|
73
|
+
* The only cleanup performed here is to remove listeners. While technically
|
|
74
|
+
* this is not required to ensure this instance is garbage collected, it at
|
|
75
|
+
* least ensures this instance won't be responsible for preventing the
|
|
76
|
+
* listeners from being garbage collected.
|
|
77
|
+
*/
|
|
78
|
+
destroy() {
|
|
79
|
+
this.messagingSystem.clearEventSubscriptions(`${this.name}:stateChange`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.BaseController = BaseController;
|
|
83
|
+
/**
|
|
84
|
+
* Returns an anonymized representation of the controller state.
|
|
85
|
+
*
|
|
86
|
+
* By "anonymized" we mean that it should not contain any information that could be personally
|
|
87
|
+
* identifiable.
|
|
88
|
+
*
|
|
89
|
+
* @param state - The controller state.
|
|
90
|
+
* @param metadata - The controller state metadata, which describes how to derive the
|
|
91
|
+
* anonymized state.
|
|
92
|
+
* @returns The anonymized controller state.
|
|
93
|
+
*/
|
|
94
|
+
function getAnonymizedState(state, metadata) {
|
|
95
|
+
return deriveStateFromMetadata(state, metadata, 'anonymous');
|
|
96
|
+
}
|
|
97
|
+
exports.getAnonymizedState = getAnonymizedState;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the subset of state that should be persisted.
|
|
100
|
+
*
|
|
101
|
+
* @param state - The controller state.
|
|
102
|
+
* @param metadata - The controller state metadata, which describes which pieces of state should be persisted.
|
|
103
|
+
* @returns The subset of controller state that should be persisted.
|
|
104
|
+
*/
|
|
105
|
+
function getPersistentState(state, metadata) {
|
|
106
|
+
return deriveStateFromMetadata(state, metadata, 'persist');
|
|
107
|
+
}
|
|
108
|
+
exports.getPersistentState = getPersistentState;
|
|
109
|
+
/**
|
|
110
|
+
* Use the metadata to derive state according to the given metadata property.
|
|
111
|
+
*
|
|
112
|
+
* @param state - The full controller state.
|
|
113
|
+
* @param metadata - The controller metadata.
|
|
114
|
+
* @param metadataProperty - The metadata property to use to derive state.
|
|
115
|
+
* @returns The metadata-derived controller state.
|
|
116
|
+
*/
|
|
117
|
+
function deriveStateFromMetadata(state, metadata, metadataProperty) {
|
|
118
|
+
return Object.keys(state).reduce((persistedState, key) => {
|
|
119
|
+
try {
|
|
120
|
+
const stateMetadata = metadata[key];
|
|
121
|
+
if (!stateMetadata) {
|
|
122
|
+
throw new Error(`No metadata found for '${key}'`);
|
|
123
|
+
}
|
|
124
|
+
const propertyMetadata = stateMetadata[metadataProperty];
|
|
125
|
+
const stateProperty = state[key];
|
|
126
|
+
if (typeof propertyMetadata === 'function') {
|
|
127
|
+
persistedState[key] = propertyMetadata(stateProperty);
|
|
128
|
+
}
|
|
129
|
+
else if (propertyMetadata) {
|
|
130
|
+
persistedState[key] = stateProperty;
|
|
131
|
+
}
|
|
132
|
+
return persistedState;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
// Throw error after timeout so that it is captured as a console error
|
|
136
|
+
// (and by Sentry) without interrupting state-related operations
|
|
137
|
+
setTimeout(() => {
|
|
138
|
+
throw error;
|
|
139
|
+
});
|
|
140
|
+
return persistedState;
|
|
141
|
+
}
|
|
142
|
+
}, {});
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=BaseControllerV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseControllerV2.js","sourceRoot":"","sources":["../src/BaseControllerV2.ts"],"names":[],"mappings":";;;AACA,iCAAwE;AAQxE,IAAA,qBAAa,GAAE,CAAC;AAoDhB;;GAEG;AACH,MAAa,cAAc;IAyBzB;;;;;;;;;OASG;IACH,YAAY,EACV,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,KAAK,GAMN;QACC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,I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AE,EAA0B,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import type { Json } from '@metamask/utils';\nimport { enablePatches, produceWithPatches, applyPatches } from 'immer';\nimport type { Draft, Patch } from 'immer';\n\nimport type {\n RestrictedControllerMessenger,\n Namespaced,\n} from './ControllerMessenger';\n\nenablePatches();\n\n/**\n * A state change listener.\n *\n * This function will get called for each state change, and is given a copy of\n * the new state along with a set of patches describing the changes since the\n * last update.\n *\n * @param state - The new controller state.\n * @param patches - A list of patches describing any changes (see here for more\n * information: https://immerjs.github.io/immer/docs/patches)\n */\nexport type Listener<T> = (state: T, patches: Patch[]) => void;\n\n/**\n * An function to derive state.\n *\n * This function will accept one piece of the controller state (one property),\n * and will return some derivation of that state.\n *\n * @param value - A piece of controller state.\n * @returns Something derived from controller state.\n */\nexport type StateDeriver<T extends Json> = (value: T) => Json;\n\n/**\n * State metadata.\n *\n * This metadata describes which parts of state should be persisted, and how to\n * get an anonymized representation of the state.\n */\nexport type StateMetadata<T extends Record<string, Json>> = {\n [P in keyof T]: StatePropertyMetadata<T[P]>;\n};\n\n/**\n * Metadata for a single state property\n *\n * @property persist - Indicates whether this property should be persisted\n * (`true` for persistent, `false` for transient), or is set to a function\n * that derives the persistent state from the state.\n * @property anonymous - Indicates whether this property is already anonymous,\n * (`true` for anonymous, `false` if it has potential to be personally\n * identifiable), or is set to a function that returns an anonymized\n * representation of this state.\n */\nexport interface StatePropertyMetadata<T extends Json> {\n persist: boolean | StateDeriver<T>;\n anonymous: boolean | StateDeriver<T>;\n}\n\n/**\n * Controller class that provides state management, subscriptions, and state metadata\n */\nexport class BaseController<\n N extends string,\n S extends Record<string, Json>,\n messenger extends RestrictedControllerMessenger<N, any, any, string, string>,\n> {\n private internalState: S;\n\n protected messagingSystem: messenger;\n\n /**\n * The name of the controller.\n *\n * This is used by the ComposableController to construct a composed application state.\n */\n public readonly name: N;\n\n public readonly metadata: StateMetadata<S>;\n\n /**\n * The existence of the `subscribe` property is how the ComposableController detects whether a\n * controller extends the old BaseController or the new one. We set it to `undefined` here to\n * ensure the ComposableController never mistakes them for an older style controller.\n */\n public readonly subscribe: undefined;\n\n /**\n * Creates a BaseController instance.\n *\n * @param options - Controller options.\n * @param options.messenger - Controller messaging system.\n * @param options.metadata - State metadata, describing how to \"anonymize\" the state, and which\n * parts should be persisted.\n * @param options.name - The name of the controller, used as a namespace for events and actions.\n * @param options.state - Initial controller state.\n */\n constructor({\n messenger,\n metadata,\n name,\n state,\n }: {\n messenger: messenger;\n metadata: StateMetadata<S>;\n name: N;\n state: S;\n }) {\n this.messagingSystem = messenger;\n this.name = name;\n this.internalState = state;\n this.metadata = metadata;\n\n this.messagingSystem.registerActionHandler(\n `${name}:getState`,\n () => this.state,\n );\n }\n\n /**\n * Retrieves current controller state.\n *\n * @returns The current state.\n */\n get state() {\n return this.internalState;\n }\n\n set state(_) {\n throw new Error(\n `Controller state cannot be directly mutated; use 'update' method instead.`,\n );\n }\n\n /**\n * Updates controller state. Accepts a callback that is passed a draft copy\n * of the controller state. If a value is returned, it is set as the new\n * state. Otherwise, any changes made within that callback to the draft are\n * applied to the controller state.\n *\n * @param callback - Callback for updating state, passed a draft state\n * object. Return a new state object or mutate the draft to update state.\n * @returns An object that has the next state, patches applied in the update and inverse patches to\n * rollback the update.\n */\n protected update(callback: (state: Draft<S>) => void | S): {\n nextState: S;\n patches: Patch[];\n inversePatches: Patch[];\n } {\n // We run into ts2589, \"infinite type depth\", if we don't cast\n // produceWithPatches here.\n const [nextState, patches, inversePatches] = (\n produceWithPatches as unknown as (\n state: S,\n cb: typeof callback,\n ) => [S, Patch[], Patch[]]\n )(this.internalState, callback);\n\n this.internalState = nextState;\n this.messagingSystem.publish(\n `${this.name}:stateChange` as Namespaced<N, any>,\n nextState,\n patches,\n );\n\n return { nextState, patches, inversePatches };\n }\n\n /**\n * Applies immer patches to the current state. The patches come from the\n * update function itself and can either be normal or inverse patches.\n *\n * @param patches - An array of immer patches that are to be applied to make\n * or undo changes.\n */\n protected applyPatches(patches: Patch[]) {\n const nextState = applyPatches(this.internalState, patches);\n this.internalState = nextState;\n this.messagingSystem.publish(\n `${this.name}:stateChange` as Namespaced<N, any>,\n nextState,\n patches,\n );\n }\n\n /**\n * Prepares the controller for garbage collection. This should be extended\n * by any subclasses to clean up any additional connections or events.\n *\n * The only cleanup performed here is to remove listeners. While technically\n * this is not required to ensure this instance is garbage collected, it at\n * least ensures this instance won't be responsible for preventing the\n * listeners from being garbage collected.\n */\n protected destroy() {\n this.messagingSystem.clearEventSubscriptions(\n `${this.name}:stateChange` as Namespaced<N, any>,\n );\n }\n}\n\n/**\n * Returns an anonymized representation of the controller state.\n *\n * By \"anonymized\" we mean that it should not contain any information that could be personally\n * identifiable.\n *\n * @param state - The controller state.\n * @param metadata - The controller state metadata, which describes how to derive the\n * anonymized state.\n * @returns The anonymized controller state.\n */\nexport function getAnonymizedState<S extends Record<string, Json>>(\n state: S,\n metadata: StateMetadata<S>,\n): Record<string, Json> {\n return deriveStateFromMetadata(state, metadata, 'anonymous');\n}\n\n/**\n * Returns the subset of state that should be persisted.\n *\n * @param state - The controller state.\n * @param metadata - The controller state metadata, which describes which pieces of state should be persisted.\n * @returns The subset of controller state that should be persisted.\n */\nexport function getPersistentState<S extends Record<string, Json>>(\n state: S,\n metadata: StateMetadata<S>,\n): Record<string, Json> {\n return deriveStateFromMetadata(state, metadata, 'persist');\n}\n\n/**\n * Use the metadata to derive state according to the given metadata property.\n *\n * @param state - The full controller state.\n * @param metadata - The controller metadata.\n * @param metadataProperty - The metadata property to use to derive state.\n * @returns The metadata-derived controller state.\n */\nfunction deriveStateFromMetadata<S extends Record<string, Json>>(\n state: S,\n metadata: StateMetadata<S>,\n metadataProperty: 'anonymous' | 'persist',\n): Record<string, Json> {\n return Object.keys(state).reduce((persistedState, key) => {\n try {\n const stateMetadata = metadata[key as keyof S];\n if (!stateMetadata) {\n throw new Error(`No metadata found for '${key}'`);\n }\n const propertyMetadata = stateMetadata[metadataProperty];\n const stateProperty = state[key];\n if (typeof propertyMetadata === 'function') {\n persistedState[key as string] = propertyMetadata(\n stateProperty as S[keyof S],\n );\n } else if (propertyMetadata) {\n persistedState[key as string] = stateProperty;\n }\n return persistedState;\n } catch (error) {\n // Throw error after timeout so that it is captured as a console error\n // (and by Sentry) without interrupting state-related operations\n setTimeout(() => {\n throw error;\n });\n return persistedState;\n }\n }, {} as Record<string, Json>);\n}\n"]}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
export declare type ActionHandler<Action, ActionType> = (...args: ExtractActionParameters<Action, ActionType>) => ExtractActionResponse<Action, ActionType>;
|
|
2
|
+
export declare type ExtractActionParameters<Action, T> = Action extends {
|
|
3
|
+
type: T;
|
|
4
|
+
handler: (...args: infer H) => any;
|
|
5
|
+
} ? H : never;
|
|
6
|
+
export declare type ExtractActionResponse<Action, T> = Action extends {
|
|
7
|
+
type: T;
|
|
8
|
+
handler: (...args: any) => infer H;
|
|
9
|
+
} ? H : never;
|
|
10
|
+
export declare type ExtractEventHandler<Event, T> = Event extends {
|
|
11
|
+
type: T;
|
|
12
|
+
payload: infer P;
|
|
13
|
+
} ? P extends unknown[] ? (...payload: P) => void : never : never;
|
|
14
|
+
export declare type ExtractEventPayload<Event, T> = Event extends {
|
|
15
|
+
type: T;
|
|
16
|
+
payload: infer P;
|
|
17
|
+
} ? P : never;
|
|
18
|
+
export declare type GenericEventHandler = (...args: unknown[]) => void;
|
|
19
|
+
export declare type SelectorFunction<Args extends unknown[], ReturnValue> = (...args: Args) => ReturnValue;
|
|
20
|
+
export declare type SelectorEventHandler<SelectorReturnValue> = (newValue: SelectorReturnValue, previousValue: SelectorReturnValue | undefined) => void;
|
|
21
|
+
export declare type ActionConstraint = {
|
|
22
|
+
type: string;
|
|
23
|
+
handler: (...args: any) => unknown;
|
|
24
|
+
};
|
|
25
|
+
export declare type EventConstraint = {
|
|
26
|
+
type: string;
|
|
27
|
+
payload: unknown[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* A namespaced string
|
|
31
|
+
*
|
|
32
|
+
* This type verifies that the string T is prefixed by the string Name followed by a colon.
|
|
33
|
+
*
|
|
34
|
+
* @template Name - The namespace we're checking for.
|
|
35
|
+
* @template T - The full string, including the namespace.
|
|
36
|
+
*/
|
|
37
|
+
export declare type Namespaced<Name extends string, T> = T extends `${Name}:${string}` ? T : never;
|
|
38
|
+
declare type NarrowToNamespace<T, Namespace extends string> = T extends {
|
|
39
|
+
type: `${Namespace}:${string}`;
|
|
40
|
+
} ? T : never;
|
|
41
|
+
declare type NarrowToAllowed<T, Allowed extends string> = T extends {
|
|
42
|
+
type: Allowed;
|
|
43
|
+
} ? T : never;
|
|
44
|
+
/**
|
|
45
|
+
* A restricted controller messenger.
|
|
46
|
+
*
|
|
47
|
+
* This acts as a wrapper around the controller messenger instance that restricts access to actions
|
|
48
|
+
* and events.
|
|
49
|
+
*
|
|
50
|
+
* @template N - The namespace for this messenger. Typically this is the name of the controller or
|
|
51
|
+
* module that this messenger has been created for. The authority to publish events and register
|
|
52
|
+
* actions under this namespace is granted to this restricted messenger instance.
|
|
53
|
+
* @template Action - A type union of all Action types.
|
|
54
|
+
* @template Event - A type union of all Event types.
|
|
55
|
+
* @template AllowedAction - A type union of the 'type' string for any allowed actions.
|
|
56
|
+
* @template AllowedEvent - A type union of the 'type' string for any allowed events.
|
|
57
|
+
*/
|
|
58
|
+
export declare class RestrictedControllerMessenger<N extends string, Action extends ActionConstraint, Event extends EventConstraint, AllowedAction extends string, AllowedEvent extends string> {
|
|
59
|
+
private readonly controllerMessenger;
|
|
60
|
+
private readonly controllerName;
|
|
61
|
+
private readonly allowedActions;
|
|
62
|
+
private readonly allowedEvents;
|
|
63
|
+
/**
|
|
64
|
+
* Constructs a restricted controller messenger
|
|
65
|
+
*
|
|
66
|
+
* The provided allowlists grant the ability to call the listed actions and subscribe to the
|
|
67
|
+
* listed events. The "name" provided grants ownership of any actions and events under that
|
|
68
|
+
* namespace. Ownership allows registering actions and publishing events, as well as
|
|
69
|
+
* unregistering actions and clearing event subscriptions.
|
|
70
|
+
*
|
|
71
|
+
* @param options - The controller options.
|
|
72
|
+
* @param options.controllerMessenger - The controller messenger instance that is being wrapped.
|
|
73
|
+
* @param options.name - The name of the thing this messenger will be handed to (e.g. the
|
|
74
|
+
* controller name). This grants "ownership" of actions and events under this namespace to the
|
|
75
|
+
* restricted controller messenger returned.
|
|
76
|
+
* @param options.allowedActions - The list of actions that this restricted controller messenger
|
|
77
|
+
* should be alowed to call.
|
|
78
|
+
* @param options.allowedEvents - The list of events that this restricted controller messenger
|
|
79
|
+
* should be allowed to subscribe to.
|
|
80
|
+
*/
|
|
81
|
+
constructor({ controllerMessenger, name, allowedActions, allowedEvents, }: {
|
|
82
|
+
controllerMessenger: ControllerMessenger<ActionConstraint, EventConstraint>;
|
|
83
|
+
name: N;
|
|
84
|
+
allowedActions?: AllowedAction[];
|
|
85
|
+
allowedEvents?: AllowedEvent[];
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Register an action handler.
|
|
89
|
+
*
|
|
90
|
+
* This will make the registered function available to call via the `call` method.
|
|
91
|
+
*
|
|
92
|
+
* The action type this handler is registered under *must* be in the current namespace.
|
|
93
|
+
*
|
|
94
|
+
* @param action - The action type. This is a unqiue identifier for this action.
|
|
95
|
+
* @param handler - The action handler. This function gets called when the `call` method is
|
|
96
|
+
* invoked with the given action type.
|
|
97
|
+
* @throws Will throw when a handler has been registered for this action type already.
|
|
98
|
+
* @template T - A type union of Action type strings that are namespaced by N.
|
|
99
|
+
*/
|
|
100
|
+
registerActionHandler<T extends Namespaced<N, Action['type']>>(action: T, handler: ActionHandler<Action, T>): void;
|
|
101
|
+
/**
|
|
102
|
+
* Unregister an action handler.
|
|
103
|
+
*
|
|
104
|
+
* This will prevent this action from being called.
|
|
105
|
+
*
|
|
106
|
+
* The action type being unregistered *must* be in the current namespace.
|
|
107
|
+
*
|
|
108
|
+
* @param action - The action type. This is a unqiue identifier for this action.
|
|
109
|
+
* @template T - A type union of Action type strings that are namespaced by N.
|
|
110
|
+
*/
|
|
111
|
+
unregisterActionHandler<T extends Namespaced<N, Action['type']>>(action: T): void;
|
|
112
|
+
/**
|
|
113
|
+
* Call an action.
|
|
114
|
+
*
|
|
115
|
+
* This function will call the action handler corresponding to the given action type, passing
|
|
116
|
+
* along any parameters given.
|
|
117
|
+
*
|
|
118
|
+
* The action type being called must be on the action allowlist.
|
|
119
|
+
*
|
|
120
|
+
* @param action - The action type. This is a unqiue identifier for this action.
|
|
121
|
+
* @param params - The action parameters. These must match the type of the parameters of the
|
|
122
|
+
* registered action handler.
|
|
123
|
+
* @throws Will throw when no handler has been registered for the given type.
|
|
124
|
+
* @template T - A type union of allowed Action type strings.
|
|
125
|
+
* @returns The action return value.
|
|
126
|
+
*/
|
|
127
|
+
call<T extends AllowedAction & string>(action: T, ...params: ExtractActionParameters<Action, T>): ExtractActionResponse<Action, T>;
|
|
128
|
+
/**
|
|
129
|
+
* Publish an event.
|
|
130
|
+
*
|
|
131
|
+
* Publishes the given payload to all subscribers of the given event type.
|
|
132
|
+
*
|
|
133
|
+
* The event type being published *must* be in the current namespace.
|
|
134
|
+
*
|
|
135
|
+
* @param event - The event type. This is a unique identifier for this event.
|
|
136
|
+
* @param payload - The event payload. The type of the parameters for each event handler must
|
|
137
|
+
* match the type of this payload.
|
|
138
|
+
* @template E - A type union of Event type strings that are namespaced by N.
|
|
139
|
+
*/
|
|
140
|
+
publish<E extends Namespaced<N, Event['type']>>(event: E, ...payload: ExtractEventPayload<Event, E>): void;
|
|
141
|
+
/**
|
|
142
|
+
* Subscribe to an event.
|
|
143
|
+
*
|
|
144
|
+
* Registers the given function as an event handler for the given event type.
|
|
145
|
+
*
|
|
146
|
+
* The event type being subscribed to must be on the event allowlist.
|
|
147
|
+
*
|
|
148
|
+
* @param eventType - The event type. This is a unique identifier for this event.
|
|
149
|
+
* @param handler - The event handler. The type of the parameters for this event handler must
|
|
150
|
+
* match the type of the payload for this event type.
|
|
151
|
+
* @template E - A type union of Event type strings.
|
|
152
|
+
*/
|
|
153
|
+
subscribe<E extends AllowedEvent & string>(eventType: E, handler: ExtractEventHandler<Event, E>): void;
|
|
154
|
+
/**
|
|
155
|
+
* Subscribe to an event, with a selector.
|
|
156
|
+
*
|
|
157
|
+
* Registers the given handler function as an event handler for the given
|
|
158
|
+
* event type. When an event is published, its payload is first passed to the
|
|
159
|
+
* selector. The event handler is only called if the selector's return value
|
|
160
|
+
* differs from its last known return value.
|
|
161
|
+
*
|
|
162
|
+
* The event type being subscribed to must be on the event allowlist.
|
|
163
|
+
*
|
|
164
|
+
* @param eventType - The event type. This is a unique identifier for this event.
|
|
165
|
+
* @param handler - The event handler. The type of the parameters for this event
|
|
166
|
+
* handler must match the return type of the selector.
|
|
167
|
+
* @param selector - The selector function used to select relevant data from
|
|
168
|
+
* the event payload. The type of the parameters for this selector must match
|
|
169
|
+
* the type of the payload for this event type.
|
|
170
|
+
* @template E - A type union of Event type strings.
|
|
171
|
+
* @template V - The selector return value.
|
|
172
|
+
*/
|
|
173
|
+
subscribe<E extends AllowedEvent & string, V>(eventType: E, handler: SelectorEventHandler<V>, selector: SelectorFunction<ExtractEventPayload<Event, E>, V>): void;
|
|
174
|
+
/**
|
|
175
|
+
* Unsubscribe from an event.
|
|
176
|
+
*
|
|
177
|
+
* Unregisters the given function as an event handler for the given event.
|
|
178
|
+
*
|
|
179
|
+
* The event type being unsubscribed to must be on the event allowlist.
|
|
180
|
+
*
|
|
181
|
+
* @param event - The event type. This is a unique identifier for this event.
|
|
182
|
+
* @param handler - The event handler to unregister.
|
|
183
|
+
* @throws Will throw when the given event handler is not registered for this event.
|
|
184
|
+
* @template T - A type union of allowed Event type strings.
|
|
185
|
+
*/
|
|
186
|
+
unsubscribe<E extends AllowedEvent & string>(event: E, handler: ExtractEventHandler<Event, E>): void;
|
|
187
|
+
/**
|
|
188
|
+
* Clear subscriptions for a specific event.
|
|
189
|
+
*
|
|
190
|
+
* This will remove all subscribed handlers for this event.
|
|
191
|
+
*
|
|
192
|
+
* The event type being cleared *must* be in the current namespace.
|
|
193
|
+
*
|
|
194
|
+
* @param event - The event type. This is a unique identifier for this event.
|
|
195
|
+
* @template E - A type union of Event type strings that are namespaced by N.
|
|
196
|
+
*/
|
|
197
|
+
clearEventSubscriptions<E extends Namespaced<N, Event['type']>>(event: E): void;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* A messaging system for controllers.
|
|
201
|
+
*
|
|
202
|
+
* The controller messenger allows registering functions as 'actions' that can be called elsewhere,
|
|
203
|
+
* and it allows publishing and subscribing to events. Both actions and events are identified by
|
|
204
|
+
* unique strings.
|
|
205
|
+
*
|
|
206
|
+
* @template Action - A type union of all Action types.
|
|
207
|
+
* @template Event - A type union of all Event types.
|
|
208
|
+
*/
|
|
209
|
+
export declare class ControllerMessenger<Action extends ActionConstraint, Event extends EventConstraint> {
|
|
210
|
+
private readonly actions;
|
|
211
|
+
private readonly events;
|
|
212
|
+
/**
|
|
213
|
+
* A cache of selector return values for their respective handlers.
|
|
214
|
+
*/
|
|
215
|
+
private readonly eventPayloadCache;
|
|
216
|
+
/**
|
|
217
|
+
* Register an action handler.
|
|
218
|
+
*
|
|
219
|
+
* This will make the registered function available to call via the `call` method.
|
|
220
|
+
*
|
|
221
|
+
* @param actionType - The action type. This is a unqiue identifier for this action.
|
|
222
|
+
* @param handler - The action handler. This function gets called when the `call` method is
|
|
223
|
+
* invoked with the given action type.
|
|
224
|
+
* @throws Will throw when a handler has been registered for this action type already.
|
|
225
|
+
* @template T - A type union of Action type strings.
|
|
226
|
+
*/
|
|
227
|
+
registerActionHandler<T extends Action['type']>(actionType: T, handler: ActionHandler<Action, T>): void;
|
|
228
|
+
/**
|
|
229
|
+
* Unregister an action handler.
|
|
230
|
+
*
|
|
231
|
+
* This will prevent this action from being called.
|
|
232
|
+
*
|
|
233
|
+
* @param actionType - The action type. This is a unqiue identifier for this action.
|
|
234
|
+
* @template T - A type union of Action type strings.
|
|
235
|
+
*/
|
|
236
|
+
unregisterActionHandler<T extends Action['type']>(actionType: T): void;
|
|
237
|
+
/**
|
|
238
|
+
* Unregister all action handlers.
|
|
239
|
+
*
|
|
240
|
+
* This prevents all actions from being called.
|
|
241
|
+
*/
|
|
242
|
+
clearActions(): void;
|
|
243
|
+
/**
|
|
244
|
+
* Call an action.
|
|
245
|
+
*
|
|
246
|
+
* This function will call the action handler corresponding to the given action type, passing
|
|
247
|
+
* along any parameters given.
|
|
248
|
+
*
|
|
249
|
+
* @param actionType - The action type. This is a unqiue identifier for this action.
|
|
250
|
+
* @param params - The action parameters. These must match the type of the parameters of the
|
|
251
|
+
* registered action handler.
|
|
252
|
+
* @throws Will throw when no handler has been registered for the given type.
|
|
253
|
+
* @template T - A type union of Action type strings.
|
|
254
|
+
* @returns The action return value.
|
|
255
|
+
*/
|
|
256
|
+
call<T extends Action['type']>(actionType: T, ...params: ExtractActionParameters<Action, T>): ExtractActionResponse<Action, T>;
|
|
257
|
+
/**
|
|
258
|
+
* Publish an event.
|
|
259
|
+
*
|
|
260
|
+
* Publishes the given payload to all subscribers of the given event type.
|
|
261
|
+
*
|
|
262
|
+
* Note that this method should never throw directly. Any errors from
|
|
263
|
+
* subscribers are captured and re-thrown in a timeout handler.
|
|
264
|
+
*
|
|
265
|
+
* @param eventType - The event type. This is a unique identifier for this event.
|
|
266
|
+
* @param payload - The event payload. The type of the parameters for each event handler must
|
|
267
|
+
* match the type of this payload.
|
|
268
|
+
* @template E - A type union of Event type strings.
|
|
269
|
+
*/
|
|
270
|
+
publish<E extends Event['type']>(eventType: E, ...payload: ExtractEventPayload<Event, E>): void;
|
|
271
|
+
/**
|
|
272
|
+
* Subscribe to an event.
|
|
273
|
+
*
|
|
274
|
+
* Registers the given function as an event handler for the given event type.
|
|
275
|
+
*
|
|
276
|
+
* @param eventType - The event type. This is a unique identifier for this event.
|
|
277
|
+
* @param handler - The event handler. The type of the parameters for this event handler must
|
|
278
|
+
* match the type of the payload for this event type.
|
|
279
|
+
* @template E - A type union of Event type strings.
|
|
280
|
+
*/
|
|
281
|
+
subscribe<E extends Event['type']>(eventType: E, handler: ExtractEventHandler<Event, E>): void;
|
|
282
|
+
/**
|
|
283
|
+
* Subscribe to an event, with a selector.
|
|
284
|
+
*
|
|
285
|
+
* Registers the given handler function as an event handler for the given
|
|
286
|
+
* event type. When an event is published, its payload is first passed to the
|
|
287
|
+
* selector. The event handler is only called if the selector's return value
|
|
288
|
+
* differs from its last known return value.
|
|
289
|
+
*
|
|
290
|
+
* @param eventType - The event type. This is a unique identifier for this event.
|
|
291
|
+
* @param handler - The event handler. The type of the parameters for this event
|
|
292
|
+
* handler must match the return type of the selector.
|
|
293
|
+
* @param selector - The selector function used to select relevant data from
|
|
294
|
+
* the event payload. The type of the parameters for this selector must match
|
|
295
|
+
* the type of the payload for this event type.
|
|
296
|
+
* @template E - A type union of Event type strings.
|
|
297
|
+
* @template V - The selector return value.
|
|
298
|
+
*/
|
|
299
|
+
subscribe<E extends Event['type'], V>(eventType: E, handler: SelectorEventHandler<V>, selector: SelectorFunction<ExtractEventPayload<Event, E>, V>): void;
|
|
300
|
+
/**
|
|
301
|
+
* Unsubscribe from an event.
|
|
302
|
+
*
|
|
303
|
+
* Unregisters the given function as an event handler for the given event.
|
|
304
|
+
*
|
|
305
|
+
* @param eventType - The event type. This is a unique identifier for this event.
|
|
306
|
+
* @param handler - The event handler to unregister.
|
|
307
|
+
* @throws Will throw when the given event handler is not registered for this event.
|
|
308
|
+
* @template E - A type union of Event type strings.
|
|
309
|
+
*/
|
|
310
|
+
unsubscribe<E extends Event['type']>(eventType: E, handler: ExtractEventHandler<Event, E>): void;
|
|
311
|
+
/**
|
|
312
|
+
* Clear subscriptions for a specific event.
|
|
313
|
+
*
|
|
314
|
+
* This will remove all subscribed handlers for this event.
|
|
315
|
+
*
|
|
316
|
+
* @param eventType - The event type. This is a unique identifier for this event.
|
|
317
|
+
* @template E - A type union of Event type strings.
|
|
318
|
+
*/
|
|
319
|
+
clearEventSubscriptions<E extends Event['type']>(eventType: E): void;
|
|
320
|
+
/**
|
|
321
|
+
* Clear all subscriptions.
|
|
322
|
+
*
|
|
323
|
+
* This will remove all subscribed handlers for all events.
|
|
324
|
+
*/
|
|
325
|
+
clearSubscriptions(): void;
|
|
326
|
+
/**
|
|
327
|
+
* Get a restricted controller messenger
|
|
328
|
+
*
|
|
329
|
+
* Returns a wrapper around the controller messenger instance that restricts access to actions
|
|
330
|
+
* and events. The provided allowlists grant the ability to call the listed actions and subscribe
|
|
331
|
+
* to the listed events. The "name" provided grants ownership of any actions and events under
|
|
332
|
+
* that namespace. Ownership allows registering actions and publishing events, as well as
|
|
333
|
+
* unregistering actions and clearing event subscriptions.
|
|
334
|
+
*
|
|
335
|
+
* @param options - Controller messenger options.
|
|
336
|
+
* @param options.name - The name of the thing this messenger will be handed to (e.g. the
|
|
337
|
+
* controller name). This grants "ownership" of actions and events under this namespace to the
|
|
338
|
+
* restricted controller messenger returned.
|
|
339
|
+
* @param options.allowedActions - The list of actions that this restricted controller messenger
|
|
340
|
+
* should be alowed to call.
|
|
341
|
+
* @param options.allowedEvents - The list of events that this restricted controller messenger
|
|
342
|
+
* should be allowed to subscribe to.
|
|
343
|
+
* @template N - The namespace for this messenger. Typically this is the name of the controller or
|
|
344
|
+
* module that this messenger has been created for. The authority to publish events and register
|
|
345
|
+
* actions under this namespace is granted to this restricted messenger instance.
|
|
346
|
+
* @template AllowedAction - A type union of the 'type' string for any allowed actions.
|
|
347
|
+
* @template AllowedEvent - A type union of the 'type' string for any allowed events.
|
|
348
|
+
* @returns The restricted controller messenger.
|
|
349
|
+
*/
|
|
350
|
+
getRestricted<N extends string, AllowedAction extends string, AllowedEvent extends string>({ name, allowedActions, allowedEvents, }: {
|
|
351
|
+
name: N;
|
|
352
|
+
allowedActions?: Extract<Action['type'], AllowedAction>[];
|
|
353
|
+
allowedEvents?: Extract<Event['type'], AllowedEvent>[];
|
|
354
|
+
}): RestrictedControllerMessenger<N, NarrowToNamespace<Action, N> | NarrowToAllowed<Action, AllowedAction>, NarrowToNamespace<Event, N> | NarrowToAllowed<Event, AllowedEvent>, AllowedAction, AllowedEvent>;
|
|
355
|
+
}
|
|
356
|
+
export {};
|
|
357
|
+
//# sourceMappingURL=ControllerMessenger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControllerMessenger.d.ts","sourceRoot":"","sources":["../src/ControllerMessenger.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,CAAC,MAAM,EAAE,UAAU,IAAI,CAC9C,GAAG,IAAI,EAAE,uBAAuB,CAAC,MAAM,EAAE,UAAU,CAAC,KACjD,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC/C,oBAAY,uBAAuB,CAAC,MAAM,EAAE,CAAC,IAAI,MAAM,SAAS;IAC9D,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,GAAG,CAAC;CACpC,GACG,CAAC,GACD,KAAK,CAAC;AACV,oBAAY,qBAAqB,CAAC,MAAM,EAAE,CAAC,IAAI,MAAM,SAAS;IAC5D,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;CACpC,GACG,CAAC,GACD,KAAK,CAAC;AAEV,oBAAY,mBAAmB,CAAC,KAAK,EAAE,CAAC,IAAI,KAAK,SAAS;IACxD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,MAAM,CAAC,CAAC;CAClB,GACG,CAAC,SAAS,OAAO,EAAE,GACjB,CAAC,GAAG,OAAO,EAAE,CAAC,KAAK,IAAI,GACvB,KAAK,GACP,KAAK,CAAC;AACV,oBAAY,mBAAmB,CAAC,KAAK,EAAE,CAAC,IAAI,KAAK,SAAS;IACxD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,MAAM,CAAC,CAAC;CAClB,GACG,CAA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