@metamask-previews/base-controller 8.4.2-preview-9fa15fd0 → 9.0.0-preview-46d2c977

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +18 -4
  2. package/dist/BaseController.cjs +23 -57
  3. package/dist/BaseController.cjs.map +1 -1
  4. package/dist/BaseController.d.cts +16 -45
  5. package/dist/BaseController.d.cts.map +1 -1
  6. package/dist/BaseController.d.mts +16 -45
  7. package/dist/BaseController.d.mts.map +1 -1
  8. package/dist/BaseController.mjs +22 -53
  9. package/dist/BaseController.mjs.map +1 -1
  10. package/dist/index.cjs +1 -8
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +2 -6
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +2 -6
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +1 -3
  17. package/dist/index.mjs.map +1 -1
  18. package/package.json +2 -14
  19. package/dist/Messenger.cjs +0 -279
  20. package/dist/Messenger.cjs.map +0 -1
  21. package/dist/Messenger.d.cts +0 -231
  22. package/dist/Messenger.d.cts.map +0 -1
  23. package/dist/Messenger.d.mts +0 -231
  24. package/dist/Messenger.d.mts.map +0 -1
  25. package/dist/Messenger.mjs +0 -275
  26. package/dist/Messenger.mjs.map +0 -1
  27. package/dist/RestrictedMessenger.cjs +0 -242
  28. package/dist/RestrictedMessenger.cjs.map +0 -1
  29. package/dist/RestrictedMessenger.d.cts +0 -200
  30. package/dist/RestrictedMessenger.d.cts.map +0 -1
  31. package/dist/RestrictedMessenger.d.mts +0 -200
  32. package/dist/RestrictedMessenger.d.mts.map +0 -1
  33. package/dist/RestrictedMessenger.mjs +0 -238
  34. package/dist/RestrictedMessenger.mjs.map +0 -1
  35. package/dist/next/BaseController.cjs +0 -168
  36. package/dist/next/BaseController.cjs.map +0 -1
  37. package/dist/next/BaseController.d.cts +0 -206
  38. package/dist/next/BaseController.d.cts.map +0 -1
  39. package/dist/next/BaseController.d.mts +0 -206
  40. package/dist/next/BaseController.d.mts.map +0 -1
  41. package/dist/next/BaseController.mjs +0 -163
  42. package/dist/next/BaseController.mjs.map +0 -1
  43. package/dist/next/index.cjs +0 -7
  44. package/dist/next/index.cjs.map +0 -1
  45. package/dist/next/index.d.cts +0 -3
  46. package/dist/next/index.d.cts.map +0 -1
  47. package/dist/next/index.d.mts +0 -3
  48. package/dist/next/index.d.mts.map +0 -1
  49. package/dist/next/index.mjs +0 -2
  50. package/dist/next/index.mjs.map +0 -1
  51. package/next.d.ts +0 -7
  52. package/next.js +0 -3
@@ -1,200 +0,0 @@
1
- import type { ActionConstraint, ActionHandler, Messenger, EventConstraint, ExtractActionParameters, ExtractActionResponse, ExtractEventHandler, ExtractEventPayload, NamespacedName, NotNamespacedBy, SelectorEventHandler, SelectorFunction } from "./Messenger.cjs";
2
- /**
3
- * A universal supertype of all `RestrictedMessenger` instances. This type can be assigned to any
4
- * `RestrictedMessenger` type.
5
- *
6
- * @template Namespace - Name of the module this messenger is for. Optionally can be used to
7
- * narrow this type to a constraint for the messenger of a specific module.
8
- */
9
- export type RestrictedMessengerConstraint<Namespace extends string = string> = RestrictedMessenger<Namespace, ActionConstraint, EventConstraint, string, string>;
10
- /**
11
- * A restricted messenger.
12
- *
13
- * This acts as a wrapper around the messenger instance that restricts access to actions
14
- * and events.
15
- *
16
- * @template Namespace - The namespace for this messenger. Typically this is the name of the controller or
17
- * module that this messenger has been created for. The authority to publish events and register
18
- * actions under this namespace is granted to this restricted messenger instance.
19
- * @template Action - A type union of all Action types.
20
- * @template Event - A type union of all Event types.
21
- * @template AllowedAction - A type union of the 'type' string for any allowed actions.
22
- * This must not include internal actions that are in the messenger's namespace.
23
- * @template AllowedEvent - A type union of the 'type' string for any allowed events.
24
- * This must not include internal events that are in the messenger's namespace.
25
- */
26
- export declare class RestrictedMessenger<Namespace extends string, Action extends ActionConstraint, Event extends EventConstraint, AllowedAction extends string, AllowedEvent extends string> {
27
- #private;
28
- /**
29
- * Constructs a restricted messenger
30
- *
31
- * The provided allowlists grant the ability to call the listed actions and subscribe to the
32
- * listed events. The "name" provided grants ownership of any actions and events under that
33
- * namespace. Ownership allows registering actions and publishing events, as well as
34
- * unregistering actions and clearing event subscriptions.
35
- *
36
- * @param options - Options.
37
- * @param options.messenger - The messenger instance that is being wrapped.
38
- * @param options.name - The name of the thing this messenger will be handed to (e.g. the
39
- * controller name). This grants "ownership" of actions and events under this namespace to the
40
- * restricted messenger returned.
41
- * @param options.allowedActions - The list of actions that this restricted messenger should be
42
- * allowed to call.
43
- * @param options.allowedEvents - The list of events that this restricted messenger should be
44
- * allowed to subscribe to.
45
- */
46
- constructor({ messenger, name, allowedActions, allowedEvents, }: {
47
- messenger?: Messenger<ActionConstraint, EventConstraint>;
48
- name: Namespace;
49
- allowedActions: NotNamespacedBy<Namespace, AllowedAction>[];
50
- allowedEvents: NotNamespacedBy<Namespace, AllowedEvent>[];
51
- });
52
- /**
53
- * Register an action handler.
54
- *
55
- * This will make the registered function available to call via the `call` method.
56
- *
57
- * The action type this handler is registered under *must* be in the current namespace.
58
- *
59
- * @param action - The action type. This is a unique identifier for this action.
60
- * @param handler - The action handler. This function gets called when the `call` method is
61
- * invoked with the given action type.
62
- * @throws Will throw if an action handler that is not in the current namespace is being registered.
63
- * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
64
- */
65
- registerActionHandler<ActionType extends Action['type'] & NamespacedName<Namespace>>(action: ActionType, handler: ActionHandler<Action, ActionType>): void;
66
- /**
67
- * Registers action handlers for a list of methods on a messenger client
68
- *
69
- * @param messengerClient - The object that is expected to make use of the messenger.
70
- * @param methodNames - The names of the methods on the messenger client to register as action
71
- * handlers.
72
- * @template MessengerClient - The type expected to make use of the messenger.
73
- * @template MethodNames - The type union of method names to register as action handlers.
74
- */
75
- registerMethodActionHandlers<MessengerClient extends {
76
- name: string;
77
- }, MethodNames extends keyof MessengerClient & string>(messengerClient: MessengerClient, methodNames: readonly MethodNames[]): void;
78
- /**
79
- * Unregister an action handler.
80
- *
81
- * This will prevent this action from being called.
82
- *
83
- * The action type being unregistered *must* be in the current namespace.
84
- *
85
- * @param action - The action type. This is a unique identifier for this action.
86
- * @throws Will throw if an action handler that is not in the current namespace is being unregistered.
87
- * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
88
- */
89
- unregisterActionHandler<ActionType extends Action['type'] & NamespacedName<Namespace>>(action: ActionType): void;
90
- /**
91
- * Call an action.
92
- *
93
- * This function will call the action handler corresponding to the given action type, passing
94
- * along any parameters given.
95
- *
96
- * The action type being called must be on the action allowlist.
97
- *
98
- * @param actionType - The action type. This is a unique identifier for this action.
99
- * @param params - The action parameters. These must match the type of the parameters of the
100
- * registered action handler.
101
- * @throws Will throw when no handler has been registered for the given type.
102
- * @template ActionType - A type union of allowed Action type strings.
103
- * @returns The action return value.
104
- */
105
- call<ActionType extends AllowedAction | (Action['type'] & NamespacedName<Namespace>)>(actionType: ActionType, ...params: ExtractActionParameters<Action, ActionType>): ExtractActionResponse<Action, ActionType>;
106
- /**
107
- * Register a function for getting the initial payload for an event.
108
- *
109
- * This is used for events that represent a state change, where the payload is the state.
110
- * Registering a function for getting the payload allows event selectors to have a point of
111
- * comparison the first time state changes.
112
- *
113
- * The event type *must* be in the current namespace
114
- *
115
- * @param args - The arguments to this function
116
- * @param args.eventType - The event type to register a payload for.
117
- * @param args.getPayload - A function for retrieving the event payload.
118
- * @template EventType - A type union of Event type strings.
119
- */
120
- registerInitialEventPayload<EventType extends Event['type'] & NamespacedName<Namespace>>({ eventType, getPayload, }: {
121
- eventType: EventType;
122
- getPayload: () => ExtractEventPayload<Event, EventType>;
123
- }): void;
124
- /**
125
- * Publish an event.
126
- *
127
- * Publishes the given payload to all subscribers of the given event type.
128
- *
129
- * The event type being published *must* be in the current namespace.
130
- *
131
- * @param event - The event type. This is a unique identifier for this event.
132
- * @param payload - The event payload. The type of the parameters for each event handler must
133
- * match the type of this payload.
134
- * @throws Will throw if an event that is not in the current namespace is being published.
135
- * @template EventType - A type union of Event type strings that are namespaced by Namespace.
136
- */
137
- publish<EventType extends Event['type'] & NamespacedName<Namespace>>(event: EventType, ...payload: ExtractEventPayload<Event, EventType>): void;
138
- /**
139
- * Subscribe to an event.
140
- *
141
- * Registers the given function as an event handler for the given event type.
142
- *
143
- * The event type being subscribed to must be on the event allowlist.
144
- *
145
- * @param eventType - The event type. This is a unique identifier for this event.
146
- * @param handler - The event handler. The type of the parameters for this event handler must
147
- * match the type of the payload for this event type.
148
- * @throws Will throw if the given event is not an allowed event for this messenger.
149
- * @template EventType - A type union of Event type strings.
150
- */
151
- subscribe<EventType extends AllowedEvent | (Event['type'] & NamespacedName<Namespace>)>(eventType: EventType, handler: ExtractEventHandler<Event, EventType>): void;
152
- /**
153
- * Subscribe to an event, with a selector.
154
- *
155
- * Registers the given handler function as an event handler for the given
156
- * event type. When an event is published, its payload is first passed to the
157
- * selector. The event handler is only called if the selector's return value
158
- * differs from its last known return value.
159
- *
160
- * The event type being subscribed to must be on the event allowlist.
161
- *
162
- * @param eventType - The event type. This is a unique identifier for this event.
163
- * @param handler - The event handler. The type of the parameters for this event
164
- * handler must match the return type of the selector.
165
- * @param selector - The selector function used to select relevant data from
166
- * the event payload. The type of the parameters for this selector must match
167
- * the type of the payload for this event type.
168
- * @throws Will throw if the given event is not an allowed event for this messenger.
169
- * @template EventType - A type union of Event type strings.
170
- * @template SelectorReturnValue - The selector return value.
171
- */
172
- subscribe<EventType extends AllowedEvent | (Event['type'] & NamespacedName<Namespace>), SelectorReturnValue>(eventType: EventType, handler: SelectorEventHandler<SelectorReturnValue>, selector: SelectorFunction<Event, EventType, SelectorReturnValue>): void;
173
- /**
174
- * Unsubscribe from an event.
175
- *
176
- * Unregisters the given function as an event handler for the given event.
177
- *
178
- * The event type being unsubscribed to must be on the event allowlist.
179
- *
180
- * @param event - The event type. This is a unique identifier for this event.
181
- * @param handler - The event handler to unregister.
182
- * @throws Will throw if the given event is not an allowed event for this messenger.
183
- * @template EventType - A type union of allowed Event type strings.
184
- * @template SelectorReturnValue - The selector return value.
185
- */
186
- unsubscribe<EventType extends AllowedEvent | (Event['type'] & NamespacedName<Namespace>), SelectorReturnValue = unknown>(event: EventType, handler: ExtractEventHandler<Event, EventType> | SelectorEventHandler<SelectorReturnValue>): 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
- * @throws Will throw if a subscription for an event that is not in the current namespace is being cleared.
196
- * @template EventType - A type union of Event type strings that are namespaced by Namespace.
197
- */
198
- clearEventSubscriptions<EventType extends Event['type'] & NamespacedName<Namespace>>(event: EventType): void;
199
- }
200
- //# sourceMappingURL=RestrictedMessenger.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RestrictedMessenger.d.cts","sourceRoot":"","sources":["../src/RestrictedMessenger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EACjB,wBAAoB;AAErB;;;;;;GAMG;AACH,MAAM,MAAM,6BAA6B,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,IACzE,mBAAmB,CACjB,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,MAAM,CACP,CAAC;AAEJ;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAmB,CAC9B,SAAS,SAAS,MAAM,EACxB,MAAM,SAAS,gBAAgB,EAC/B,KAAK,SAAS,eAAe,EAC7B,aAAa,SAAS,MAAM,EAC5B,YAAY,SAAS,MAAM;;IAU3B;;;;;;;;;;;;;;;;;OAiBG;gBACS,EACV,SAAS,EACT,IAAI,EACJ,cAAc,EACd,aA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1
- import type { ActionConstraint, ActionHandler, Messenger, EventConstraint, ExtractActionParameters, ExtractActionResponse, ExtractEventHandler, ExtractEventPayload, NamespacedName, NotNamespacedBy, SelectorEventHandler, SelectorFunction } from "./Messenger.mjs";
2
- /**
3
- * A universal supertype of all `RestrictedMessenger` instances. This type can be assigned to any
4
- * `RestrictedMessenger` type.
5
- *
6
- * @template Namespace - Name of the module this messenger is for. Optionally can be used to
7
- * narrow this type to a constraint for the messenger of a specific module.
8
- */
9
- export type RestrictedMessengerConstraint<Namespace extends string = string> = RestrictedMessenger<Namespace, ActionConstraint, EventConstraint, string, string>;
10
- /**
11
- * A restricted messenger.
12
- *
13
- * This acts as a wrapper around the messenger instance that restricts access to actions
14
- * and events.
15
- *
16
- * @template Namespace - The namespace for this messenger. Typically this is the name of the controller or
17
- * module that this messenger has been created for. The authority to publish events and register
18
- * actions under this namespace is granted to this restricted messenger instance.
19
- * @template Action - A type union of all Action types.
20
- * @template Event - A type union of all Event types.
21
- * @template AllowedAction - A type union of the 'type' string for any allowed actions.
22
- * This must not include internal actions that are in the messenger's namespace.
23
- * @template AllowedEvent - A type union of the 'type' string for any allowed events.
24
- * This must not include internal events that are in the messenger's namespace.
25
- */
26
- export declare class RestrictedMessenger<Namespace extends string, Action extends ActionConstraint, Event extends EventConstraint, AllowedAction extends string, AllowedEvent extends string> {
27
- #private;
28
- /**
29
- * Constructs a restricted messenger
30
- *
31
- * The provided allowlists grant the ability to call the listed actions and subscribe to the
32
- * listed events. The "name" provided grants ownership of any actions and events under that
33
- * namespace. Ownership allows registering actions and publishing events, as well as
34
- * unregistering actions and clearing event subscriptions.
35
- *
36
- * @param options - Options.
37
- * @param options.messenger - The messenger instance that is being wrapped.
38
- * @param options.name - The name of the thing this messenger will be handed to (e.g. the
39
- * controller name). This grants "ownership" of actions and events under this namespace to the
40
- * restricted messenger returned.
41
- * @param options.allowedActions - The list of actions that this restricted messenger should be
42
- * allowed to call.
43
- * @param options.allowedEvents - The list of events that this restricted messenger should be
44
- * allowed to subscribe to.
45
- */
46
- constructor({ messenger, name, allowedActions, allowedEvents, }: {
47
- messenger?: Messenger<ActionConstraint, EventConstraint>;
48
- name: Namespace;
49
- allowedActions: NotNamespacedBy<Namespace, AllowedAction>[];
50
- allowedEvents: NotNamespacedBy<Namespace, AllowedEvent>[];
51
- });
52
- /**
53
- * Register an action handler.
54
- *
55
- * This will make the registered function available to call via the `call` method.
56
- *
57
- * The action type this handler is registered under *must* be in the current namespace.
58
- *
59
- * @param action - The action type. This is a unique identifier for this action.
60
- * @param handler - The action handler. This function gets called when the `call` method is
61
- * invoked with the given action type.
62
- * @throws Will throw if an action handler that is not in the current namespace is being registered.
63
- * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
64
- */
65
- registerActionHandler<ActionType extends Action['type'] & NamespacedName<Namespace>>(action: ActionType, handler: ActionHandler<Action, ActionType>): void;
66
- /**
67
- * Registers action handlers for a list of methods on a messenger client
68
- *
69
- * @param messengerClient - The object that is expected to make use of the messenger.
70
- * @param methodNames - The names of the methods on the messenger client to register as action
71
- * handlers.
72
- * @template MessengerClient - The type expected to make use of the messenger.
73
- * @template MethodNames - The type union of method names to register as action handlers.
74
- */
75
- registerMethodActionHandlers<MessengerClient extends {
76
- name: string;
77
- }, MethodNames extends keyof MessengerClient & string>(messengerClient: MessengerClient, methodNames: readonly MethodNames[]): void;
78
- /**
79
- * Unregister an action handler.
80
- *
81
- * This will prevent this action from being called.
82
- *
83
- * The action type being unregistered *must* be in the current namespace.
84
- *
85
- * @param action - The action type. This is a unique identifier for this action.
86
- * @throws Will throw if an action handler that is not in the current namespace is being unregistered.
87
- * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
88
- */
89
- unregisterActionHandler<ActionType extends Action['type'] & NamespacedName<Namespace>>(action: ActionType): void;
90
- /**
91
- * Call an action.
92
- *
93
- * This function will call the action handler corresponding to the given action type, passing
94
- * along any parameters given.
95
- *
96
- * The action type being called must be on the action allowlist.
97
- *
98
- * @param actionType - The action type. This is a unique identifier for this action.
99
- * @param params - The action parameters. These must match the type of the parameters of the
100
- * registered action handler.
101
- * @throws Will throw when no handler has been registered for the given type.
102
- * @template ActionType - A type union of allowed Action type strings.
103
- * @returns The action return value.
104
- */
105
- call<ActionType extends AllowedAction | (Action['type'] & NamespacedName<Namespace>)>(actionType: ActionType, ...params: ExtractActionParameters<Action, ActionType>): ExtractActionResponse<Action, ActionType>;
106
- /**
107
- * Register a function for getting the initial payload for an event.
108
- *
109
- * This is used for events that represent a state change, where the payload is the state.
110
- * Registering a function for getting the payload allows event selectors to have a point of
111
- * comparison the first time state changes.
112
- *
113
- * The event type *must* be in the current namespace
114
- *
115
- * @param args - The arguments to this function
116
- * @param args.eventType - The event type to register a payload for.
117
- * @param args.getPayload - A function for retrieving the event payload.
118
- * @template EventType - A type union of Event type strings.
119
- */
120
- registerInitialEventPayload<EventType extends Event['type'] & NamespacedName<Namespace>>({ eventType, getPayload, }: {
121
- eventType: EventType;
122
- getPayload: () => ExtractEventPayload<Event, EventType>;
123
- }): void;
124
- /**
125
- * Publish an event.
126
- *
127
- * Publishes the given payload to all subscribers of the given event type.
128
- *
129
- * The event type being published *must* be in the current namespace.
130
- *
131
- * @param event - The event type. This is a unique identifier for this event.
132
- * @param payload - The event payload. The type of the parameters for each event handler must
133
- * match the type of this payload.
134
- * @throws Will throw if an event that is not in the current namespace is being published.
135
- * @template EventType - A type union of Event type strings that are namespaced by Namespace.
136
- */
137
- publish<EventType extends Event['type'] & NamespacedName<Namespace>>(event: EventType, ...payload: ExtractEventPayload<Event, EventType>): void;
138
- /**
139
- * Subscribe to an event.
140
- *
141
- * Registers the given function as an event handler for the given event type.
142
- *
143
- * The event type being subscribed to must be on the event allowlist.
144
- *
145
- * @param eventType - The event type. This is a unique identifier for this event.
146
- * @param handler - The event handler. The type of the parameters for this event handler must
147
- * match the type of the payload for this event type.
148
- * @throws Will throw if the given event is not an allowed event for this messenger.
149
- * @template EventType - A type union of Event type strings.
150
- */
151
- subscribe<EventType extends AllowedEvent | (Event['type'] & NamespacedName<Namespace>)>(eventType: EventType, handler: ExtractEventHandler<Event, EventType>): void;
152
- /**
153
- * Subscribe to an event, with a selector.
154
- *
155
- * Registers the given handler function as an event handler for the given
156
- * event type. When an event is published, its payload is first passed to the
157
- * selector. The event handler is only called if the selector's return value
158
- * differs from its last known return value.
159
- *
160
- * The event type being subscribed to must be on the event allowlist.
161
- *
162
- * @param eventType - The event type. This is a unique identifier for this event.
163
- * @param handler - The event handler. The type of the parameters for this event
164
- * handler must match the return type of the selector.
165
- * @param selector - The selector function used to select relevant data from
166
- * the event payload. The type of the parameters for this selector must match
167
- * the type of the payload for this event type.
168
- * @throws Will throw if the given event is not an allowed event for this messenger.
169
- * @template EventType - A type union of Event type strings.
170
- * @template SelectorReturnValue - The selector return value.
171
- */
172
- subscribe<EventType extends AllowedEvent | (Event['type'] & NamespacedName<Namespace>), SelectorReturnValue>(eventType: EventType, handler: SelectorEventHandler<SelectorReturnValue>, selector: SelectorFunction<Event, EventType, SelectorReturnValue>): void;
173
- /**
174
- * Unsubscribe from an event.
175
- *
176
- * Unregisters the given function as an event handler for the given event.
177
- *
178
- * The event type being unsubscribed to must be on the event allowlist.
179
- *
180
- * @param event - The event type. This is a unique identifier for this event.
181
- * @param handler - The event handler to unregister.
182
- * @throws Will throw if the given event is not an allowed event for this messenger.
183
- * @template EventType - A type union of allowed Event type strings.
184
- * @template SelectorReturnValue - The selector return value.
185
- */
186
- unsubscribe<EventType extends AllowedEvent | (Event['type'] & NamespacedName<Namespace>), SelectorReturnValue = unknown>(event: EventType, handler: ExtractEventHandler<Event, EventType> | SelectorEventHandler<SelectorReturnValue>): 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
- * @throws Will throw if a subscription for an event that is not in the current namespace is being cleared.
196
- * @template EventType - A type union of Event type strings that are namespaced by Namespace.
197
- */
198
- clearEventSubscriptions<EventType extends Event['type'] & NamespacedName<Namespace>>(event: EventType): void;
199
- }
200
- //# sourceMappingURL=RestrictedMessenger.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RestrictedMessenger.d.mts","sourceRoot":"","sources":["../src/RestrictedMessenger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EACjB,wBAAoB;AAErB;;;;;;GAMG;AACH,MAAM,MAAM,6BAA6B,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,IACzE,mBAAmB,CACjB,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,MAAM,CACP,CAAC;AAEJ;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAmB,CAC9B,SAAS,SAAS,MAAM,EACxB,MAAM,SAAS,gBAAgB,EAC/B,KAAK,SAAS,eAAe,EAC7B,aAAa,SAAS,MAAM,EAC5B,YAAY,SAAS,MAAM;;IAU3B;;;;;;;;;;;;;;;;;OAiBG;gBACS,EACV,SAAS,EACT,IAAI,EACJ,cAAc,EACd,aAAa,GACd,EAAE;QACD,SAAS,CAAC,EAAE,SAAS,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;QACzD,IAAI,EAAE,SAAS,CAAC;QAChB,cAAc,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,CAAC;QAC5D,aAAa,EAAE,eAAe,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC;KAC3D;IAWD;;;;;;;;;;;;OAYG;IACH,qBAAqB,CACnB,UAAU,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,EAC7D,MAAM,EAAE,UAAU,EAAE,OAAO,EAA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SAAS,EAAE,OAAO,EAAE,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,IAAI;IAE7E;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAS,CACP,SAAS,SACL,YAAY,GACZ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,EAC/C,mBAAmB,EAEnB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,EAClD,QAAQ,EAAE,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,mBAAmB,CAAC,GAChE,IAAI;IA2BP;;;;;;;;;;;;OAYG;IACH,WAAW,CACT,SAAS,SACL,YAAY,GACZ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,EAC/C,mBAAmB,GAAG,OAAO,EAE7B,KAAK,EAAE,SAAS,EAChB,OAAO,EACH,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,GACrC,oBAAoB,CAAC,mBAAmB,CAAC;IAQ/C;;;;;;;;;;OAUG;IACH,uBAAuB,CACrB,SAAS,SAAS,KAAK,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,EAC3D,KAAK,EAAE,SAAS;CA4DnB"}
@@ -1,238 +0,0 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _RestrictedMessenger_instances, _RestrictedMessenger_messenger, _RestrictedMessenger_namespace, _RestrictedMessenger_allowedActions, _RestrictedMessenger_allowedEvents, _RestrictedMessenger_isAllowedEvent, _RestrictedMessenger_isAllowedAction, _RestrictedMessenger_isInCurrentNamespace;
13
- /**
14
- * A restricted messenger.
15
- *
16
- * This acts as a wrapper around the messenger instance that restricts access to actions
17
- * and events.
18
- *
19
- * @template Namespace - The namespace for this messenger. Typically this is the name of the controller or
20
- * module that this messenger has been created for. The authority to publish events and register
21
- * actions under this namespace is granted to this restricted messenger instance.
22
- * @template Action - A type union of all Action types.
23
- * @template Event - A type union of all Event types.
24
- * @template AllowedAction - A type union of the 'type' string for any allowed actions.
25
- * This must not include internal actions that are in the messenger's namespace.
26
- * @template AllowedEvent - A type union of the 'type' string for any allowed events.
27
- * This must not include internal events that are in the messenger's namespace.
28
- */
29
- export class RestrictedMessenger {
30
- /**
31
- * Constructs a restricted messenger
32
- *
33
- * The provided allowlists grant the ability to call the listed actions and subscribe to the
34
- * listed events. The "name" provided grants ownership of any actions and events under that
35
- * namespace. Ownership allows registering actions and publishing events, as well as
36
- * unregistering actions and clearing event subscriptions.
37
- *
38
- * @param options - Options.
39
- * @param options.messenger - The messenger instance that is being wrapped.
40
- * @param options.name - The name of the thing this messenger will be handed to (e.g. the
41
- * controller name). This grants "ownership" of actions and events under this namespace to the
42
- * restricted messenger returned.
43
- * @param options.allowedActions - The list of actions that this restricted messenger should be
44
- * allowed to call.
45
- * @param options.allowedEvents - The list of events that this restricted messenger should be
46
- * allowed to subscribe to.
47
- */
48
- constructor({ messenger, name, allowedActions, allowedEvents, }) {
49
- _RestrictedMessenger_instances.add(this);
50
- _RestrictedMessenger_messenger.set(this, void 0);
51
- _RestrictedMessenger_namespace.set(this, void 0);
52
- _RestrictedMessenger_allowedActions.set(this, void 0);
53
- _RestrictedMessenger_allowedEvents.set(this, void 0);
54
- if (!messenger) {
55
- throw new Error('Messenger not provided');
56
- }
57
- // The above condition guarantees that one of these options is defined.
58
- __classPrivateFieldSet(this, _RestrictedMessenger_messenger, messenger, "f");
59
- __classPrivateFieldSet(this, _RestrictedMessenger_namespace, name, "f");
60
- __classPrivateFieldSet(this, _RestrictedMessenger_allowedActions, allowedActions, "f");
61
- __classPrivateFieldSet(this, _RestrictedMessenger_allowedEvents, allowedEvents, "f");
62
- }
63
- /**
64
- * Register an action handler.
65
- *
66
- * This will make the registered function available to call via the `call` method.
67
- *
68
- * The action type this handler is registered under *must* be in the current namespace.
69
- *
70
- * @param action - The action type. This is a unique identifier for this action.
71
- * @param handler - The action handler. This function gets called when the `call` method is
72
- * invoked with the given action type.
73
- * @throws Will throw if an action handler that is not in the current namespace is being registered.
74
- * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
75
- */
76
- registerActionHandler(action, handler) {
77
- /* istanbul ignore if */ // Branch unreachable with valid types
78
- if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, action)) {
79
- throw new Error(`Only allowed registering action handlers prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
80
- }
81
- __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").registerActionHandler(action, handler);
82
- }
83
- /**
84
- * Registers action handlers for a list of methods on a messenger client
85
- *
86
- * @param messengerClient - The object that is expected to make use of the messenger.
87
- * @param methodNames - The names of the methods on the messenger client to register as action
88
- * handlers.
89
- * @template MessengerClient - The type expected to make use of the messenger.
90
- * @template MethodNames - The type union of method names to register as action handlers.
91
- */
92
- registerMethodActionHandlers(messengerClient, methodNames) {
93
- __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").registerMethodActionHandlers(messengerClient, methodNames);
94
- }
95
- /**
96
- * Unregister an action handler.
97
- *
98
- * This will prevent this action from being called.
99
- *
100
- * The action type being unregistered *must* be in the current namespace.
101
- *
102
- * @param action - The action type. This is a unique identifier for this action.
103
- * @throws Will throw if an action handler that is not in the current namespace is being unregistered.
104
- * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
105
- */
106
- unregisterActionHandler(action) {
107
- /* istanbul ignore if */ // Branch unreachable with valid types
108
- if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, action)) {
109
- throw new Error(`Only allowed unregistering action handlers prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
110
- }
111
- __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").unregisterActionHandler(action);
112
- }
113
- /**
114
- * Call an action.
115
- *
116
- * This function will call the action handler corresponding to the given action type, passing
117
- * along any parameters given.
118
- *
119
- * The action type being called must be on the action allowlist.
120
- *
121
- * @param actionType - The action type. This is a unique identifier for this action.
122
- * @param params - The action parameters. These must match the type of the parameters of the
123
- * registered action handler.
124
- * @throws Will throw when no handler has been registered for the given type.
125
- * @template ActionType - A type union of allowed Action type strings.
126
- * @returns The action return value.
127
- */
128
- call(actionType, ...params) {
129
- if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isAllowedAction).call(this, actionType)) {
130
- throw new Error(`Action missing from allow list: ${actionType}`);
131
- }
132
- const response = __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").call(actionType, ...params);
133
- return response;
134
- }
135
- /**
136
- * Register a function for getting the initial payload for an event.
137
- *
138
- * This is used for events that represent a state change, where the payload is the state.
139
- * Registering a function for getting the payload allows event selectors to have a point of
140
- * comparison the first time state changes.
141
- *
142
- * The event type *must* be in the current namespace
143
- *
144
- * @param args - The arguments to this function
145
- * @param args.eventType - The event type to register a payload for.
146
- * @param args.getPayload - A function for retrieving the event payload.
147
- * @template EventType - A type union of Event type strings.
148
- */
149
- registerInitialEventPayload({ eventType, getPayload, }) {
150
- /* istanbul ignore if */ // Branch unreachable with valid types
151
- if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, eventType)) {
152
- throw new Error(`Only allowed publishing events prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
153
- }
154
- __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").registerInitialEventPayload({
155
- eventType,
156
- getPayload,
157
- });
158
- }
159
- /**
160
- * Publish an event.
161
- *
162
- * Publishes the given payload to all subscribers of the given event type.
163
- *
164
- * The event type being published *must* be in the current namespace.
165
- *
166
- * @param event - The event type. This is a unique identifier for this event.
167
- * @param payload - The event payload. The type of the parameters for each event handler must
168
- * match the type of this payload.
169
- * @throws Will throw if an event that is not in the current namespace is being published.
170
- * @template EventType - A type union of Event type strings that are namespaced by Namespace.
171
- */
172
- publish(event, ...payload) {
173
- /* istanbul ignore if */ // Branch unreachable with valid types
174
- if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, event)) {
175
- throw new Error(`Only allowed publishing events prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
176
- }
177
- __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").publish(event, ...payload);
178
- }
179
- subscribe(event, handler, selector) {
180
- if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isAllowedEvent).call(this, event)) {
181
- throw new Error(`Event missing from allow list: ${event}`);
182
- }
183
- if (selector) {
184
- return __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").subscribe(event, handler, selector);
185
- }
186
- return __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").subscribe(event, handler);
187
- }
188
- /**
189
- * Unsubscribe from an event.
190
- *
191
- * Unregisters the given function as an event handler for the given event.
192
- *
193
- * The event type being unsubscribed to must be on the event allowlist.
194
- *
195
- * @param event - The event type. This is a unique identifier for this event.
196
- * @param handler - The event handler to unregister.
197
- * @throws Will throw if the given event is not an allowed event for this messenger.
198
- * @template EventType - A type union of allowed Event type strings.
199
- * @template SelectorReturnValue - The selector return value.
200
- */
201
- unsubscribe(event, handler) {
202
- if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isAllowedEvent).call(this, event)) {
203
- throw new Error(`Event missing from allow list: ${event}`);
204
- }
205
- __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").unsubscribe(event, handler);
206
- }
207
- /**
208
- * Clear subscriptions for a specific event.
209
- *
210
- * This will remove all subscribed handlers for this event.
211
- *
212
- * The event type being cleared *must* be in the current namespace.
213
- *
214
- * @param event - The event type. This is a unique identifier for this event.
215
- * @throws Will throw if a subscription for an event that is not in the current namespace is being cleared.
216
- * @template EventType - A type union of Event type strings that are namespaced by Namespace.
217
- */
218
- clearEventSubscriptions(event) {
219
- if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, event)) {
220
- throw new Error(`Only allowed clearing events prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
221
- }
222
- __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").clearEventSubscriptions(event);
223
- }
224
- }
225
- _RestrictedMessenger_messenger = new WeakMap(), _RestrictedMessenger_namespace = new WeakMap(), _RestrictedMessenger_allowedActions = new WeakMap(), _RestrictedMessenger_allowedEvents = new WeakMap(), _RestrictedMessenger_instances = new WeakSet(), _RestrictedMessenger_isAllowedEvent = function _RestrictedMessenger_isAllowedEvent(eventType) {
226
- // Safely upcast to allow runtime check
227
- const allowedEvents = __classPrivateFieldGet(this, _RestrictedMessenger_allowedEvents, "f");
228
- return (__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, eventType) ||
229
- (allowedEvents !== null && allowedEvents.includes(eventType)));
230
- }, _RestrictedMessenger_isAllowedAction = function _RestrictedMessenger_isAllowedAction(actionType) {
231
- // Safely upcast to allow runtime check
232
- const allowedActions = __classPrivateFieldGet(this, _RestrictedMessenger_allowedActions, "f");
233
- return (__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, actionType) ||
234
- (allowedActions !== null && allowedActions.includes(actionType)));
235
- }, _RestrictedMessenger_isInCurrentNamespace = function _RestrictedMessenger_isInCurrentNamespace(name) {
236
- return name.startsWith(`${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:`);
237
- };
238
- //# sourceMappingURL=RestrictedMessenger.mjs.map