@rimori/client 2.3.0-next.6 → 2.3.0-next.7

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.
@@ -5,7 +5,7 @@ import { ObjectRequest } from '../controller/ObjectController';
5
5
  import { UserInfo } from '../controller/SettingsController';
6
6
  import { SharedContent, SharedContentFilter, SharedContentObjectRequest } from '../controller/SharedContentController';
7
7
  import { CreateExerciseParams } from '../controller/ExerciseController';
8
- import { EventBusMessage, EventHandler, EventPayload } from '../fromRimori/EventBus';
8
+ import { EventBusMessage, EventHandler, EventPayload, EventListener } from '../fromRimori/EventBus';
9
9
  import { ActivePlugin, MainPanelAction, Plugin, Tool } from '../fromRimori/PluginTypes';
10
10
  import { AccomplishmentPayload } from '../controller/AccomplishmentController';
11
11
  import { Translator } from '../controller/TranslationController';
@@ -112,7 +112,7 @@ export declare class RimoriClient {
112
112
  * @param callback The callback to call when the event is emitted.
113
113
  * @returns An EventListener object containing an off() method to unsubscribe the listeners.
114
114
  */
115
- on: <T = EventPayload>(topic: string | string[], callback: EventHandler<T>) => import("../fromRimori/EventBus").EventListener;
115
+ on: <T = EventPayload>(topic: string | string[], callback: EventHandler<T>) => EventListener;
116
116
  /**
117
117
  * Subscribe to an event once.
118
118
  * @param topic The topic to subscribe to.
@@ -143,8 +143,8 @@ export declare class RimoriClient {
143
143
  * @param text Optional text to be used for the action like for example text that the translator would look up.
144
144
  */
145
145
  emitSidebarAction: (pluginId: string, actionKey: string, text?: string) => void;
146
- onMainPanelAction: (callback: (data: MainPanelAction) => void, actionsToListen?: string | string[]) => void;
147
- onSidePanelAction: (callback: (data: MainPanelAction) => void, actionsToListen?: string | string[]) => void;
146
+ onMainPanelAction: (callback: (data: MainPanelAction) => void, actionsToListen?: string | string[]) => EventListener;
147
+ onSidePanelAction: (callback: (data: MainPanelAction) => void, actionsToListen?: string | string[]) => EventListener;
148
148
  };
149
149
  navigation: {
150
150
  toDashboard: () => void;
@@ -100,7 +100,7 @@ export class RimoriClient {
100
100
  const listeningActions = Array.isArray(actionsToListen) ? actionsToListen : [actionsToListen];
101
101
  // this needs to be a emit and on because the main panel action is triggered by the user and not by the plugin
102
102
  this.event.emit('action.requestMain');
103
- this.event.on('action.requestMain', ({ data }) => {
103
+ return this.event.on('action.requestMain', ({ data }) => {
104
104
  // console.log('Received action for main panel ' + data.action_key);
105
105
  // console.log('Listening to actions', listeningActions);
106
106
  if (listeningActions.length === 0 || listeningActions.includes(data.action_key)) {
@@ -112,7 +112,7 @@ export class RimoriClient {
112
112
  const listeningActions = Array.isArray(actionsToListen) ? actionsToListen : [actionsToListen];
113
113
  // this needs to be a emit and on because the main panel action is triggered by the user and not by the plugin
114
114
  this.event.emit('action.requestSidebar');
115
- this.event.on('action.requestSidebar', ({ data }) => {
115
+ return this.event.on('action.requestSidebar', ({ data }) => {
116
116
  // console.log("eventHandler .onSidePanelAction", data);
117
117
  // console.log('Received action for sidebar ' + data.action);
118
118
  // console.log('Listening to actions', listeningActions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/client",
3
- "version": "2.3.0-next.6",
3
+ "version": "2.3.0-next.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -12,7 +12,7 @@ import {
12
12
  } from '../controller/SharedContentController';
13
13
  import { getSTTResponse, getTTSResponse } from '../controller/VoiceController';
14
14
  import { ExerciseController, CreateExerciseParams } from '../controller/ExerciseController';
15
- import { EventBus, EventBusMessage, EventHandler, EventPayload } from '../fromRimori/EventBus';
15
+ import { EventBus, EventBusMessage, EventHandler, EventPayload, EventListener } from '../fromRimori/EventBus';
16
16
  import { ActivePlugin, MainPanelAction, Plugin, Tool } from '../fromRimori/PluginTypes';
17
17
  import { AccomplishmentController, AccomplishmentPayload } from '../controller/AccomplishmentController';
18
18
  import { RimoriCommunicationHandler, RimoriInfo } from './CommunicationHandler';
@@ -201,7 +201,7 @@ export class RimoriClient {
201
201
  * @param callback The callback to call when the event is emitted.
202
202
  * @returns An EventListener object containing an off() method to unsubscribe the listeners.
203
203
  */
204
- on: <T = EventPayload>(topic: string | string[], callback: EventHandler<T>) => {
204
+ on: <T = EventPayload>(topic: string | string[], callback: EventHandler<T>): EventListener => {
205
205
  const topics = Array.isArray(topic) ? topic : [topic];
206
206
  return EventBus.on<T>(
207
207
  topics.map((t) => this.pluginController.getGlobalEventTopic(t)),
@@ -260,11 +260,14 @@ export class RimoriClient {
260
260
  this.event.emit('global.sidebar.triggerAction', { plugin_id: pluginId, action_key: actionKey, text });
261
261
  },
262
262
 
263
- onMainPanelAction: (callback: (data: MainPanelAction) => void, actionsToListen: string | string[] = []) => {
263
+ onMainPanelAction: (
264
+ callback: (data: MainPanelAction) => void,
265
+ actionsToListen: string | string[] = [],
266
+ ): EventListener => {
264
267
  const listeningActions = Array.isArray(actionsToListen) ? actionsToListen : [actionsToListen];
265
268
  // this needs to be a emit and on because the main panel action is triggered by the user and not by the plugin
266
269
  this.event.emit('action.requestMain');
267
- this.event.on<MainPanelAction>('action.requestMain', ({ data }) => {
270
+ return this.event.on<MainPanelAction>('action.requestMain', ({ data }) => {
268
271
  // console.log('Received action for main panel ' + data.action_key);
269
272
  // console.log('Listening to actions', listeningActions);
270
273
  if (listeningActions.length === 0 || listeningActions.includes(data.action_key)) {
@@ -273,11 +276,14 @@ export class RimoriClient {
273
276
  });
274
277
  },
275
278
 
276
- onSidePanelAction: (callback: (data: MainPanelAction) => void, actionsToListen: string | string[] = []) => {
279
+ onSidePanelAction: (
280
+ callback: (data: MainPanelAction) => void,
281
+ actionsToListen: string | string[] = [],
282
+ ): EventListener => {
277
283
  const listeningActions = Array.isArray(actionsToListen) ? actionsToListen : [actionsToListen];
278
284
  // this needs to be a emit and on because the main panel action is triggered by the user and not by the plugin
279
285
  this.event.emit('action.requestSidebar');
280
- this.event.on<MainPanelAction>('action.requestSidebar', ({ data }) => {
286
+ return this.event.on<MainPanelAction>('action.requestSidebar', ({ data }) => {
281
287
  // console.log("eventHandler .onSidePanelAction", data);
282
288
  // console.log('Received action for sidebar ' + data.action);
283
289
  // console.log('Listening to actions', listeningActions);