@rimori/client 1.4.9 → 2.0.0

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 (185) hide show
  1. package/README.md +0 -49
  2. package/dist/react-client/src/plugin/ThemeSetter.d.ts +2 -0
  3. package/dist/react-client/src/plugin/ThemeSetter.js +19 -0
  4. package/dist/react-client/src/utils/PluginUtils.d.ts +2 -0
  5. package/dist/react-client/src/utils/PluginUtils.js +23 -0
  6. package/dist/{cli → rimori-client/src/cli}/scripts/init/main.js +0 -0
  7. package/dist/{cli → rimori-client/src/cli}/scripts/release/release.js +0 -0
  8. package/dist/{core → rimori-client/src}/controller/AIController.d.ts +1 -1
  9. package/dist/{core → rimori-client/src}/controller/AIController.js +2 -2
  10. package/dist/{plugin/AccomplishmentHandler.d.ts → rimori-client/src/controller/AccomplishmentController.d.ts} +1 -1
  11. package/dist/{plugin/AccomplishmentHandler.js → rimori-client/src/controller/AccomplishmentController.js} +1 -1
  12. package/dist/{core → rimori-client/src}/controller/ExerciseController.d.ts +8 -6
  13. package/dist/{core → rimori-client/src}/controller/ExerciseController.js +10 -9
  14. package/dist/{core → rimori-client/src}/controller/ObjectController.d.ts +1 -1
  15. package/dist/{core → rimori-client/src}/controller/ObjectController.js +1 -1
  16. package/dist/{core → rimori-client/src}/controller/SettingsController.d.ts +2 -2
  17. package/dist/{core → rimori-client/src}/controller/SharedContentController.d.ts +1 -1
  18. package/dist/{plugin → rimori-client/src/controller}/TranslationController.js +5 -4
  19. package/dist/{core → rimori-client/src}/controller/VoiceController.d.ts +1 -1
  20. package/dist/rimori-client/src/index.d.ts +11 -0
  21. package/dist/rimori-client/src/index.js +10 -0
  22. package/dist/{plugin/PluginController.d.ts → rimori-client/src/plugin/CommunicationHandler.d.ts} +3 -7
  23. package/dist/{plugin/PluginController.js → rimori-client/src/plugin/CommunicationHandler.js} +3 -28
  24. package/dist/{plugin → rimori-client/src/plugin}/RimoriClient.d.ts +67 -68
  25. package/dist/{plugin → rimori-client/src/plugin}/RimoriClient.js +101 -43
  26. package/dist/{worker → rimori-client/src/worker}/WorkerSetup.js +2 -2
  27. package/example/docs/devdocs.md +1 -1
  28. package/package.json +4 -26
  29. package/src/{core/controller → controller}/AIController.ts +3 -3
  30. package/src/{plugin/AccomplishmentHandler.ts → controller/AccomplishmentController.ts} +1 -1
  31. package/src/{core/controller → controller}/ExerciseController.ts +14 -11
  32. package/src/{core/controller → controller}/ObjectController.ts +2 -2
  33. package/src/{core/controller → controller}/SettingsController.ts +2 -2
  34. package/src/{core/controller → controller}/SharedContentController.ts +1 -1
  35. package/src/{plugin → controller}/TranslationController.ts +6 -4
  36. package/src/{core/controller → controller}/VoiceController.ts +2 -2
  37. package/src/fromRimori/readme.md +1 -1
  38. package/src/index.ts +8 -8
  39. package/src/plugin/{PluginController.ts → CommunicationHandler.ts} +8 -36
  40. package/src/plugin/RimoriClient.ts +125 -118
  41. package/src/worker/WorkerSetup.ts +5 -3
  42. package/tsconfig.json +4 -2
  43. package/dist/cli/scripts/release/release-translation-upload.d.ts +0 -6
  44. package/dist/cli/scripts/release/release-translation-upload.js +0 -87
  45. package/dist/components/CRUDModal.d.ts +0 -17
  46. package/dist/components/CRUDModal.js +0 -24
  47. package/dist/components/MarkdownEditor.d.ts +0 -8
  48. package/dist/components/MarkdownEditor.js +0 -48
  49. package/dist/components/Spinner.d.ts +0 -8
  50. package/dist/components/Spinner.js +0 -4
  51. package/dist/components/ai/Assistant.d.ts +0 -9
  52. package/dist/components/ai/Assistant.js +0 -58
  53. package/dist/components/ai/Avatar.d.ts +0 -14
  54. package/dist/components/ai/Avatar.js +0 -59
  55. package/dist/components/ai/EmbeddedAssistent/AudioInputField.d.ts +0 -7
  56. package/dist/components/ai/EmbeddedAssistent/AudioInputField.js +0 -37
  57. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +0 -8
  58. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +0 -79
  59. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +0 -19
  60. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.js +0 -91
  61. package/dist/components/ai/EmbeddedAssistent/TTS/Player.d.ts +0 -27
  62. package/dist/components/ai/EmbeddedAssistent/TTS/Player.js +0 -185
  63. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +0 -11
  64. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +0 -95
  65. package/dist/components/ai/utils.d.ts +0 -6
  66. package/dist/components/ai/utils.js +0 -13
  67. package/dist/components/audio/Playbutton.d.ts +0 -15
  68. package/dist/components/audio/Playbutton.js +0 -80
  69. package/dist/components/components/ContextMenu.d.ts +0 -10
  70. package/dist/components/components/ContextMenu.js +0 -135
  71. package/dist/components.d.ts +0 -10
  72. package/dist/components.js +0 -11
  73. package/dist/core/controller/EnhancedUserInfo.d.ts +0 -0
  74. package/dist/core/controller/EnhancedUserInfo.js +0 -1
  75. package/dist/core/core.d.ts +0 -14
  76. package/dist/core/core.js +0 -7
  77. package/dist/hooks/I18nHooks.d.ts +0 -11
  78. package/dist/hooks/I18nHooks.js +0 -25
  79. package/dist/hooks/UseChatHook.d.ts +0 -10
  80. package/dist/hooks/UseChatHook.js +0 -29
  81. package/dist/i18n/I18nHooks.d.ts +0 -11
  82. package/dist/i18n/I18nHooks.js +0 -25
  83. package/dist/i18n/Translator.d.ts +0 -43
  84. package/dist/i18n/Translator.js +0 -118
  85. package/dist/i18n/config.d.ts +0 -7
  86. package/dist/i18n/config.js +0 -20
  87. package/dist/i18n/createI18nInstance.d.ts +0 -7
  88. package/dist/i18n/createI18nInstance.js +0 -31
  89. package/dist/i18n/hooks.d.ts +0 -11
  90. package/dist/i18n/hooks.js +0 -25
  91. package/dist/i18n/index.d.ts +0 -4
  92. package/dist/i18n/index.js +0 -4
  93. package/dist/i18n/types.d.ts +0 -7
  94. package/dist/i18n/types.js +0 -1
  95. package/dist/i18n/useRimoriI18n.d.ts +0 -11
  96. package/dist/i18n/useRimoriI18n.js +0 -41
  97. package/dist/index.d.ts +0 -11
  98. package/dist/index.js +0 -11
  99. package/dist/plugin/Translator.d.ts +0 -38
  100. package/dist/plugin/Translator.js +0 -101
  101. package/dist/providers/PluginProvider.d.ts +0 -12
  102. package/dist/providers/PluginProvider.js +0 -152
  103. package/dist/style.css +0 -110
  104. package/dist/style.css.map +0 -1
  105. package/dist/utils/Language.d.ts +0 -67
  106. package/dist/utils/Language.js +0 -69
  107. package/dist/utils/LanguageClass.d.ts +0 -36
  108. package/dist/utils/LanguageClass.example.d.ts +0 -0
  109. package/dist/utils/LanguageClass.example.js +0 -1
  110. package/dist/utils/LanguageClass.js +0 -50
  111. package/dist/utils/LanguageClass.test.d.ts +0 -0
  112. package/dist/utils/LanguageClass.test.js +0 -1
  113. package/src/components/CRUDModal.tsx +0 -75
  114. package/src/components/MarkdownEditor.tsx +0 -144
  115. package/src/components/Spinner.tsx +0 -29
  116. package/src/components/ai/Assistant.tsx +0 -96
  117. package/src/components/ai/Avatar.tsx +0 -99
  118. package/src/components/ai/EmbeddedAssistent/AudioInputField.tsx +0 -73
  119. package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +0 -107
  120. package/src/components/ai/EmbeddedAssistent/TTS/MessageSender.ts +0 -96
  121. package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +0 -197
  122. package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +0 -129
  123. package/src/components/ai/utils.ts +0 -21
  124. package/src/components/audio/Playbutton.tsx +0 -126
  125. package/src/components/components/ContextMenu.tsx +0 -179
  126. package/src/components.ts +0 -11
  127. package/src/core/core.ts +0 -15
  128. package/src/hooks/I18nHooks.ts +0 -33
  129. package/src/hooks/UseChatHook.ts +0 -38
  130. package/src/plugin/ThemeSetter.ts +0 -23
  131. package/src/providers/PluginProvider.tsx +0 -209
  132. package/src/style.scss +0 -136
  133. package/src/utils/PluginUtils.ts +0 -22
  134. /package/dist/{plugin → react-client/plugin}/ThemeSetter.d.ts +0 -0
  135. /package/dist/{plugin → react-client/plugin}/ThemeSetter.js +0 -0
  136. /package/dist/{utils/PluginUtils.d.ts → react-client/src/utils/FullscreenUtils.d.ts} +0 -0
  137. /package/dist/{utils/PluginUtils.js → react-client/src/utils/FullscreenUtils.js} +0 -0
  138. /package/dist/{cli → rimori-client/src/cli}/scripts/init/dev-registration.d.ts +0 -0
  139. /package/dist/{cli → rimori-client/src/cli}/scripts/init/dev-registration.js +0 -0
  140. /package/dist/{cli → rimori-client/src/cli}/scripts/init/env-setup.d.ts +0 -0
  141. /package/dist/{cli → rimori-client/src/cli}/scripts/init/env-setup.js +0 -0
  142. /package/dist/{cli → rimori-client/src/cli}/scripts/init/file-operations.d.ts +0 -0
  143. /package/dist/{cli → rimori-client/src/cli}/scripts/init/file-operations.js +0 -0
  144. /package/dist/{cli → rimori-client/src/cli}/scripts/init/html-cleaner.d.ts +0 -0
  145. /package/dist/{cli → rimori-client/src/cli}/scripts/init/html-cleaner.js +0 -0
  146. /package/dist/{cli → rimori-client/src/cli}/scripts/init/main.d.ts +0 -0
  147. /package/dist/{cli → rimori-client/src/cli}/scripts/init/package-setup.d.ts +0 -0
  148. /package/dist/{cli → rimori-client/src/cli}/scripts/init/package-setup.js +0 -0
  149. /package/dist/{cli → rimori-client/src/cli}/scripts/init/router-transformer.d.ts +0 -0
  150. /package/dist/{cli → rimori-client/src/cli}/scripts/init/router-transformer.js +0 -0
  151. /package/dist/{cli → rimori-client/src/cli}/scripts/init/tailwind-config.d.ts +0 -0
  152. /package/dist/{cli → rimori-client/src/cli}/scripts/init/tailwind-config.js +0 -0
  153. /package/dist/{cli → rimori-client/src/cli}/scripts/init/vite-config.d.ts +0 -0
  154. /package/dist/{cli → rimori-client/src/cli}/scripts/init/vite-config.js +0 -0
  155. /package/dist/{cli → rimori-client/src/cli}/scripts/release/detect-translation-languages.d.ts +0 -0
  156. /package/dist/{cli → rimori-client/src/cli}/scripts/release/detect-translation-languages.js +0 -0
  157. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-config-upload.d.ts +0 -0
  158. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-config-upload.js +0 -0
  159. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-db-update.d.ts +0 -0
  160. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-db-update.js +0 -0
  161. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-file-upload.d.ts +0 -0
  162. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-file-upload.js +0 -0
  163. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release.d.ts +0 -0
  164. /package/dist/{cli → rimori-client/src/cli}/types/DatabaseTypes.d.ts +0 -0
  165. /package/dist/{cli → rimori-client/src/cli}/types/DatabaseTypes.js +0 -0
  166. /package/dist/{plugin → rimori-client/src/controller}/AudioController.d.ts +0 -0
  167. /package/dist/{plugin → rimori-client/src/controller}/AudioController.js +0 -0
  168. /package/dist/{core → rimori-client/src}/controller/SettingsController.js +0 -0
  169. /package/dist/{core → rimori-client/src}/controller/SharedContentController.js +0 -0
  170. /package/dist/{plugin → rimori-client/src/controller}/TranslationController.d.ts +0 -0
  171. /package/dist/{core → rimori-client/src}/controller/VoiceController.js +0 -0
  172. /package/dist/{fromRimori → rimori-client/src/fromRimori}/EventBus.d.ts +0 -0
  173. /package/dist/{fromRimori → rimori-client/src/fromRimori}/EventBus.js +0 -0
  174. /package/dist/{fromRimori → rimori-client/src/fromRimori}/PluginTypes.d.ts +0 -0
  175. /package/dist/{fromRimori → rimori-client/src/fromRimori}/PluginTypes.js +0 -0
  176. /package/dist/{plugin → rimori-client/src/plugin}/Logger.d.ts +0 -0
  177. /package/dist/{plugin → rimori-client/src/plugin}/Logger.js +0 -0
  178. /package/dist/{plugin → rimori-client/src/plugin}/StandaloneClient.d.ts +0 -0
  179. /package/dist/{plugin → rimori-client/src/plugin}/StandaloneClient.js +0 -0
  180. /package/dist/{utils → rimori-client/src/utils}/difficultyConverter.d.ts +0 -0
  181. /package/dist/{utils → rimori-client/src/utils}/difficultyConverter.js +0 -0
  182. /package/dist/{utils → rimori-client/src/utils}/endpoint.d.ts +0 -0
  183. /package/dist/{utils → rimori-client/src/utils}/endpoint.js +0 -0
  184. /package/dist/{worker → rimori-client/src/worker}/WorkerSetup.d.ts +0 -0
  185. /package/src/{plugin → controller}/AudioController.ts +0 -0
@@ -1,133 +1,108 @@
1
1
  import { PostgrestQueryBuilder } from '@supabase/postgrest-js';
2
2
  import { SupabaseClient } from '@supabase/supabase-js';
3
3
  import { GenericSchema } from '@supabase/supabase-js/dist/module/lib/types';
4
- import { generateText, Message, OnLLMResponse, streamChatGPT } from '../core/controller/AIController';
5
- import { generateObject, ObjectRequest } from '../core/controller/ObjectController';
6
- import { SettingsController, UserInfo } from '../core/controller/SettingsController';
4
+ import { generateText, Message, OnLLMResponse, streamChatGPT } from '../controller/AIController';
5
+ import { generateObject, ObjectRequest } from '../controller/ObjectController';
6
+ import { SettingsController, UserInfo } from '../controller/SettingsController';
7
7
  import {
8
8
  SharedContent,
9
9
  SharedContentController,
10
10
  SharedContentFilter,
11
11
  SharedContentObjectRequest,
12
- } from '../core/controller/SharedContentController';
13
- import { getSTTResponse, getTTSResponse } from '../core/controller/VoiceController';
14
- import { ExerciseController, CreateExerciseParams } from '../core/controller/ExerciseController';
12
+ } from '../controller/SharedContentController';
13
+ import { getSTTResponse, getTTSResponse } from '../controller/VoiceController';
14
+ import { ExerciseController, CreateExerciseParams } from '../controller/ExerciseController';
15
15
  import { EventBus, EventBusMessage, EventHandler, EventPayload } from '../fromRimori/EventBus';
16
16
  import { ActivePlugin, MainPanelAction, Plugin, Tool } from '../fromRimori/PluginTypes';
17
- import { AccomplishmentHandler, AccomplishmentPayload } from './AccomplishmentHandler';
18
- import { PluginController, RimoriInfo } from './PluginController';
19
- import { Translator } from './TranslationController';
17
+ import { AccomplishmentController, AccomplishmentPayload } from '../controller/AccomplishmentController';
18
+ import { RimoriCommunicationHandler, RimoriInfo } from './CommunicationHandler';
19
+ import { Translator } from '../controller/TranslationController';
20
+ import { Logger } from './Logger';
21
+ import { setTheme } from '../../../react-client/src/plugin/ThemeSetter';
22
+ import { StandaloneClient } from './StandaloneClient';
20
23
 
21
- interface Db {
22
- from: {
23
- <TableName extends string & keyof GenericSchema['Tables'], Table extends GenericSchema['Tables'][TableName]>(
24
- relation: TableName,
25
- ): PostgrestQueryBuilder<GenericSchema, Table, TableName>;
26
- <ViewName extends string & keyof GenericSchema['Views'], View extends GenericSchema['Views'][ViewName]>(
27
- relation: ViewName,
28
- ): PostgrestQueryBuilder<GenericSchema, View, ViewName>;
29
- };
30
- // storage: SupabaseClient["storage"];
31
-
32
- // functions: SupabaseClient["functions"];
33
- /**
34
- * The table prefix for of database tables of the plugin.
35
- */
36
- tablePrefix: string;
37
- /**
38
- * Get the table name for a given plugin table.
39
- * Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
40
- * @param table The plugin table name to get the full table name for.
41
- * @returns The full table name.
42
- */
43
- getTableName: (table: string) => string;
44
- }
45
-
46
- interface PluginInterface {
47
- pluginId: string;
48
- setSettings: (settings: any) => Promise<void>;
49
- /**
50
- * Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
51
- * @param defaultSettings The default settings to use if no settings are found.
52
- * @param genericSettings The type of settings to get.
53
- * @returns The settings for the plugin.
54
- */
55
- getSettings: <T extends object>(defaultSettings: T) => Promise<T>;
56
- /**
57
- * Retrieves information about plugins, including:
58
- * - All installed plugins
59
- * - The currently active plugin in the main panel
60
- * - The currently active plugin in the side panel
61
- */
62
- getPluginInfo: () => {
63
- /**
64
- * All installed plugins.
65
- */
66
- installedPlugins: Plugin[];
67
- /**
68
- * The plugin that is loaded in the main panel.
69
- */
70
- mainPanelPlugin?: ActivePlugin;
71
- /**
72
- * The plugin that is loaded in the side panel.
73
- */
74
- sidePanelPlugin?: ActivePlugin;
75
- };
76
- getUserInfo: () => UserInfo;
77
- getTranslator: () => Promise<Translator>;
78
- }
24
+ // Add declaration for WorkerGlobalScope
25
+ declare const WorkerGlobalScope: any;
79
26
 
80
27
  export class RimoriClient {
81
28
  private static instance: RimoriClient;
82
29
  private superbase: SupabaseClient;
83
- private pluginController: PluginController;
30
+ private pluginController: RimoriCommunicationHandler;
84
31
  private settingsController: SettingsController;
85
32
  private sharedContentController: SharedContentController;
86
33
  private exerciseController: ExerciseController;
87
- private accomplishmentHandler: AccomplishmentHandler;
34
+ private accomplishmentHandler: AccomplishmentController;
88
35
  private rimoriInfo: RimoriInfo;
89
36
  private translator: Translator;
90
- public plugin: PluginInterface;
91
- public db: Db;
92
37
 
93
- private constructor(supabase: SupabaseClient, info: RimoriInfo, pluginController: PluginController) {
38
+ private constructor(controller: RimoriCommunicationHandler, supabase: SupabaseClient, info: RimoriInfo) {
94
39
  this.rimoriInfo = info;
95
40
  this.superbase = supabase;
96
- this.pluginController = pluginController;
41
+ this.pluginController = controller;
42
+ this.exerciseController = new ExerciseController(supabase);
43
+ this.accomplishmentHandler = new AccomplishmentController(info.pluginId);
97
44
  this.settingsController = new SettingsController(supabase, info.pluginId, info.guild);
98
- this.sharedContentController = new SharedContentController(this.superbase, this);
99
- this.exerciseController = new ExerciseController(supabase, pluginController);
100
- this.accomplishmentHandler = new AccomplishmentHandler(info.pluginId);
45
+ this.sharedContentController = new SharedContentController(supabase, this);
101
46
  this.translator = new Translator(info.profile.mother_tongue.code);
102
47
 
103
- this.from = this.from.bind(this);
104
- this.getTableName = this.getTableName.bind(this);
48
+ //only init logger in workers and on main plugin pages
49
+ if (this.getQueryParam('applicationMode') !== 'sidebar') {
50
+ Logger.getInstance(this);
51
+ }
52
+ }
105
53
 
106
- this.db = {
107
- from: this.from,
108
- // storage: this.superbase.storage,
109
- // functions: this.superbase.functions,
110
- tablePrefix: info.tablePrefix,
111
- getTableName: this.getTableName,
112
- };
113
- this.plugin = {
114
- pluginId: info.pluginId,
54
+ public get plugin() {
55
+ return {
56
+ pluginId: this.rimoriInfo.pluginId,
57
+ /**
58
+ * Set the settings for the plugin.
59
+ * @param settings The settings to set.
60
+ */
115
61
  setSettings: async (settings: any): Promise<void> => {
116
62
  await this.settingsController.setSettings(settings);
117
63
  },
64
+ /**
65
+ * Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
66
+ * @param defaultSettings The default settings to use if no settings are found.
67
+ * @param genericSettings The type of settings to get.
68
+ * @returns The settings for the plugin.
69
+ */
118
70
  getSettings: async <T extends object>(defaultSettings: T): Promise<T> => {
119
71
  return await this.settingsController.getSettings<T>(defaultSettings);
120
72
  },
121
73
  getUserInfo: (): UserInfo => {
122
74
  return this.rimoriInfo.profile;
123
75
  },
124
- getPluginInfo: () => {
76
+ /**
77
+ * Retrieves information about plugins, including:
78
+ * - All installed plugins
79
+ * - The currently active plugin in the main panel
80
+ * - The currently active plugin in the side panel
81
+ */
82
+ getPluginInfo: (): {
83
+ /**
84
+ * All installed plugins.
85
+ */
86
+ installedPlugins: Plugin[];
87
+ /**
88
+ * The plugin that is loaded in the main panel.
89
+ */
90
+ mainPanelPlugin?: ActivePlugin;
91
+ /**
92
+ * The plugin that is loaded in the side panel.
93
+ */
94
+ sidePanelPlugin?: ActivePlugin;
95
+ } => {
125
96
  return {
126
97
  installedPlugins: this.rimoriInfo.installedPlugins,
127
98
  mainPanelPlugin: this.rimoriInfo.mainPanelPlugin,
128
99
  sidePanelPlugin: this.rimoriInfo.sidePanelPlugin,
129
100
  };
130
101
  },
102
+ /**
103
+ * Get the translator for the plugin.
104
+ * @returns The translator for the plugin.
105
+ */
131
106
  getTranslator: async (): Promise<Translator> => {
132
107
  await this.translator.initialize();
133
108
  return this.translator;
@@ -135,6 +110,42 @@ export class RimoriClient {
135
110
  };
136
111
  }
137
112
 
113
+ public get db() {
114
+ return {
115
+ // private from<
116
+ // TableName extends string & keyof GenericSchema['Tables'],
117
+ // Table extends GenericSchema['Tables'][TableName],
118
+ // >(relation: TableName): PostgrestQueryBuilder<GenericSchema, Table, TableName>;
119
+ // private from<ViewName extends string & keyof GenericSchema['Views'], View extends GenericSchema['Views'][ViewName]>(
120
+ // relation: ViewName,
121
+ // ): PostgrestQueryBuilder<GenericSchema, View, ViewName>;
122
+ from: (relation: string): PostgrestQueryBuilder<GenericSchema, any, any> => {
123
+ return this.superbase.from(this.db.getTableName(relation));
124
+ },
125
+ // storage: this.superbase.storage,
126
+ // functions: this.superbase.functions,
127
+ /**
128
+ * The table prefix for of database tables of the plugin.
129
+ */
130
+ tablePrefix: this.rimoriInfo.tablePrefix,
131
+ /**
132
+ * Get the table name for a given plugin table.
133
+ * Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
134
+ * @param table The plugin table name to get the full table name for.
135
+ * @returns The full table name.
136
+ */
137
+ getTableName: (table: string): string => {
138
+ if (/[A-Z]/.test(table)) {
139
+ throw new Error('Table name cannot include uppercase letters. Please use snake_case for table names.');
140
+ }
141
+ if (table.startsWith('global_')) {
142
+ return table.replace('global_', '');
143
+ }
144
+ return this.db.tablePrefix + '_' + table;
145
+ },
146
+ };
147
+ }
148
+
138
149
  public event = {
139
150
  /**
140
151
  * Emit an event to Rimori or a plugin.
@@ -225,15 +236,19 @@ export class RimoriClient {
225
236
  this.event.emit('global.sidebar.triggerAction', { plugin_id: pluginId, action_key: actionKey, text });
226
237
  },
227
238
 
228
- onMainPanelAction: (callback: (data: MainPanelAction) => void) => {
239
+ onMainPanelAction: (callback: (data: MainPanelAction) => void, actionsToListen: string[] = []) => {
229
240
  // this needs to be a emit and on because the main panel action is triggered by the user and not by the plugin
230
241
  this.event.emit('action.requestMain');
231
- this.event.on<MainPanelAction>('action.requestMain', ({ data }) => callback(data));
242
+ this.event.on<MainPanelAction>('action.requestMain', ({ data }) => {
243
+ if (actionsToListen.includes(data.action)) {
244
+ callback(data);
245
+ }
246
+ });
232
247
  },
233
248
  };
234
249
 
235
250
  public navigation = {
236
- toDashboard: () => {
251
+ toDashboard: (): void => {
237
252
  this.event.emit('global.navigation.triggerToDashboard');
238
253
  },
239
254
  };
@@ -247,33 +262,21 @@ export class RimoriClient {
247
262
  return this.pluginController.getQueryParam(key);
248
263
  }
249
264
 
250
- public static async getInstance(pluginController: PluginController): Promise<RimoriClient> {
265
+ public static async getInstance(pluginId?: string): Promise<RimoriClient> {
251
266
  if (!RimoriClient.instance) {
252
- const client = await pluginController.getClient();
253
- RimoriClient.instance = new RimoriClient(client.supabase, client.info, pluginController);
254
- }
255
- return RimoriClient.instance;
256
- }
267
+ if (!pluginId) throw new Error('Plugin ID is required');
257
268
 
258
- private from<
259
- TableName extends string & keyof GenericSchema['Tables'],
260
- Table extends GenericSchema['Tables'][TableName],
261
- >(relation: TableName): PostgrestQueryBuilder<GenericSchema, Table, TableName>;
262
- private from<ViewName extends string & keyof GenericSchema['Views'], View extends GenericSchema['Views'][ViewName]>(
263
- relation: ViewName,
264
- ): PostgrestQueryBuilder<GenericSchema, View, ViewName>;
265
- private from(relation: string): PostgrestQueryBuilder<GenericSchema, any, any> {
266
- return this.superbase.from(this.getTableName(relation));
267
- }
269
+ const controller = new RimoriCommunicationHandler(pluginId, false);
268
270
 
269
- private getTableName(table: string) {
270
- if (/[A-Z]/.test(table)) {
271
- throw new Error('Table name cannot include uppercase letters. Please use snake_case for table names.');
272
- }
273
- if (table.startsWith('global_')) {
274
- return table.replace('global_', '');
271
+ if (typeof WorkerGlobalScope === 'undefined') {
272
+ // In standalone mode, use URL fallback. In iframe mode, theme will be set after MessageChannel init
273
+ // setTheme();
274
+ // await StandaloneClient.initListeners(pluginId);
275
+ }
276
+ const client = await controller.getClient();
277
+ RimoriClient.instance = new RimoriClient(controller, client.supabase, client.info);
275
278
  }
276
- return this.db.tablePrefix + '_' + table;
279
+ return RimoriClient.instance;
277
280
  }
278
281
 
279
282
  public ai = {
@@ -295,9 +298,9 @@ export class RimoriClient {
295
298
  const token = await this.pluginController.getToken();
296
299
  return getSTTResponse(this.pluginController.getBackendUrl(), file, token);
297
300
  },
298
- getObject: async (request: ObjectRequest): Promise<any> => {
301
+ getObject: async <T = any>(request: ObjectRequest): Promise<T> => {
299
302
  const token = await this.pluginController.getToken();
300
- return generateObject(this.pluginController.getBackendUrl(), request, token);
303
+ return generateObject<T>(this.pluginController.getBackendUrl(), request, token);
301
304
  },
302
305
  // getSteamedObject: this.generateObjectStream,
303
306
  };
@@ -436,7 +439,9 @@ export class RimoriClient {
436
439
  * @returns Created exercise object.
437
440
  */
438
441
  add: async (params: CreateExerciseParams) => {
439
- return this.exerciseController.addExercise(params);
442
+ const token = await this.pluginController.getToken();
443
+ const backendUrl = this.pluginController.getBackendUrl();
444
+ return this.exerciseController.addExercise(token, backendUrl, params);
440
445
  },
441
446
 
442
447
  /**
@@ -445,7 +450,9 @@ export class RimoriClient {
445
450
  * @returns Success status.
446
451
  */
447
452
  delete: async (id: string) => {
448
- return this.exerciseController.deleteExercise(id);
453
+ const token = await this.pluginController.getToken();
454
+ const backendUrl = this.pluginController.getBackendUrl();
455
+ return this.exerciseController.deleteExercise(token, backendUrl, id);
449
456
  },
450
457
  };
451
458
  }
@@ -1,13 +1,15 @@
1
1
  import { RimoriClient } from '../plugin/RimoriClient';
2
2
  import { EventBusHandler } from '../fromRimori/EventBus';
3
- import { PluginController } from '../plugin/PluginController';
4
3
 
5
4
  /**
6
5
  * Sets up the web worker for the plugin to be able receive and send messages to Rimori.
7
6
  * @param pluginId - The id of the plugin to setup the worker for.
8
7
  * @param init - The function containing the initialization logic.
9
8
  */
10
- export async function setupWorker(pluginId: string, init: (client: RimoriClient) => void | Promise<void>) {
9
+ export async function setupWorker(
10
+ pluginId: string,
11
+ init: (client: RimoriClient) => void | Promise<void>,
12
+ ): Promise<void> {
11
13
  // Mock of the window object for the worker context to be able to use the PluginController.
12
14
  const mockWindow = {
13
15
  isWorker: true,
@@ -23,7 +25,7 @@ export async function setupWorker(pluginId: string, init: (client: RimoriClient)
23
25
 
24
26
  EventBusHandler.getInstance('Worker EventBus');
25
27
 
26
- const rimoriClient = await PluginController.getInstance(pluginId);
28
+ const rimoriClient = await RimoriClient.getInstance(pluginId);
27
29
  console.debug('[Worker] RimoriClient initialized.');
28
30
 
29
31
  await init(rimoriClient);
package/tsconfig.json CHANGED
@@ -10,5 +10,7 @@
10
10
  "skipLibCheck": true,
11
11
  "strict": true
12
12
  },
13
- "include": ["src/**/*"]
14
- }
13
+ "include": [
14
+ "src/**/*",
15
+ ]
16
+ }
@@ -1,6 +0,0 @@
1
- import { Config } from './release.js';
2
- /**
3
- * Upload translation files to the release function
4
- * @param config - Configuration object
5
- */
6
- export declare function uploadTranslations(config: Config, release_id: string): Promise<void>;
@@ -1,87 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import fs from 'fs';
11
- import path from 'path';
12
- /**
13
- * Upload translation files to the release function
14
- * @param config - Configuration object
15
- */
16
- export function uploadTranslations(config, release_id) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- const localesPath = './public/locales';
19
- console.log(`📁 Checking for translation files...`);
20
- // Check if locales directory exists
21
- try {
22
- yield fs.promises.access(localesPath);
23
- }
24
- catch (e) {
25
- console.log('⚠️ No locales directory found at public/locales, skipping translation upload');
26
- return;
27
- }
28
- // Read all files in the locales directory
29
- const files = yield fs.promises.readdir(localesPath);
30
- // Filter out local- files and only include .json files
31
- const translationFiles = files.filter(file => file.endsWith('.json') &&
32
- !file.startsWith('local-'));
33
- if (translationFiles.length === 0) {
34
- console.log('⚠️ No translation files found (excluding local- files), skipping translation upload');
35
- return;
36
- }
37
- console.log(`🌐 Found ${translationFiles.length} translation files: ${translationFiles.join(', ')}`);
38
- // Create FormData
39
- const formData = new FormData();
40
- // Add version and release channel data
41
- formData.append('version', config.version);
42
- formData.append('release_channel', config.release_channel);
43
- formData.append('plugin_id', config.plugin_id);
44
- // Create path mapping with ID as key
45
- const pathMapping = {};
46
- try {
47
- // Process each translation file
48
- for (let i = 0; i < translationFiles.length; i++) {
49
- const fileName = translationFiles[i];
50
- const filePath = path.join(localesPath, fileName);
51
- console.log(`📄 Processing ${fileName}...`);
52
- const fileContent = yield fs.promises.readFile(filePath);
53
- const contentType = 'application/json';
54
- // Generate unique ID for this file
55
- const fileId = `file_${i}`;
56
- // Add to path mapping using ID as key
57
- pathMapping[fileId] = fileName;
58
- // Create a Blob with the file content and content type
59
- const blob = new Blob([new Uint8Array(fileContent)], { type: contentType });
60
- // Add file to FormData with ID_filename format
61
- const formFileName = `${fileId}_${fileName}`;
62
- formData.append('files', blob, formFileName);
63
- }
64
- }
65
- catch (error) {
66
- console.error(`❌ Error reading translation files:`, error.message);
67
- throw error;
68
- }
69
- // Add path mapping to FormData
70
- formData.append('path_mapping', JSON.stringify(pathMapping));
71
- // Upload to the release endpoint
72
- const response = yield fetch(`${config.domain}/release/${release_id}/translations`, {
73
- method: 'POST',
74
- headers: { Authorization: `Bearer ${config.token}` },
75
- body: formData,
76
- });
77
- if (response.ok) {
78
- console.log('✅ Translation files uploaded successfully!');
79
- }
80
- else {
81
- const errorText = yield response.text();
82
- console.log('❌ Translation upload failed!');
83
- console.log('Response:', errorText);
84
- throw new Error(`Translation upload failed with status ${response.status}`);
85
- }
86
- });
87
- }
@@ -1,17 +0,0 @@
1
- interface Props {
2
- title: string;
3
- show?: boolean;
4
- className?: string;
5
- closeAble?: boolean;
6
- children: React.ReactNode;
7
- actionbuttons: ActionButton[];
8
- buttonText?: string | React.ReactNode;
9
- onClose?: () => void;
10
- }
11
- interface ActionButton {
12
- text: string;
13
- onClick: () => void;
14
- closeModal?: boolean;
15
- }
16
- export declare function CRUDModal({ actionbuttons, children, title, buttonText, className, closeAble, show, onClose, }: Props): import("react/jsx-runtime").JSX.Element;
17
- export {};
@@ -1,24 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useEffect, useRef } from 'react';
3
- export function CRUDModal({ actionbuttons, children, title, buttonText, className, closeAble = true, show = false, onClose, }) {
4
- const dialogRef = useRef(null);
5
- useEffect(() => {
6
- var _a, _b;
7
- if (show) {
8
- (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.showModal();
9
- }
10
- else {
11
- (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.close();
12
- }
13
- }, [show]);
14
- const handleClose = () => {
15
- var _a;
16
- (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.close();
17
- onClose === null || onClose === void 0 ? void 0 : onClose();
18
- };
19
- return (_jsxs(_Fragment, { children: [!!buttonText && (_jsx("button", { className: className, onClick: () => { var _a; return (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.showModal(); }, children: buttonText })), _jsxs("dialog", { ref: dialogRef, className: "bg-gray-400 rounded-lg font-normal", onClose: handleClose, children: [_jsxs("div", { className: "bg-gray-500 text-xl flex flex-row justify-between p-3 items-start font-bold", children: [_jsx("h2", { children: title }), closeAble && _jsx("button", { onClick: handleClose, children: "\u00D7" })] }), _jsx("div", { className: "modal-body p-2", children: children }), _jsx("div", { className: "modal-footer px-2 py-2 flex flex-row gap-2 border-t-2", children: actionbuttons.map(({ onClick, text, closeModal = true }, index) => (_jsx("button", { className: "bg-blue-500 hover:bg-blue-600 dark:border-gray-900 rounded-md py-2 px-4 dark:text-white font-bold", onClick: () => {
20
- if (closeModal)
21
- handleClose();
22
- onClick();
23
- }, children: text }, index))) })] })] }));
24
- }
@@ -1,8 +0,0 @@
1
- interface Props {
2
- content?: string;
3
- editable: boolean;
4
- className?: string;
5
- onUpdate?: (content: string) => void;
6
- }
7
- export declare const MarkdownEditor: (props: Props) => import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,48 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Markdown } from 'tiptap-markdown';
3
- import StarterKit from '@tiptap/starter-kit';
4
- import { PiCodeBlock } from 'react-icons/pi';
5
- import { TbBlockquote } from 'react-icons/tb';
6
- import { GoListOrdered } from 'react-icons/go';
7
- import { AiOutlineUnorderedList } from 'react-icons/ai';
8
- import { EditorProvider, useCurrentEditor } from '@tiptap/react';
9
- import { LuHeading1, LuHeading2, LuHeading3 } from 'react-icons/lu';
10
- import { FaBold, FaCode, FaItalic, FaParagraph, FaStrikethrough } from 'react-icons/fa';
11
- const EditorButton = ({ action, isActive, label, disabled }) => {
12
- const { editor } = useCurrentEditor();
13
- if (!editor) {
14
- return null;
15
- }
16
- if (action.includes('heading')) {
17
- const level = parseInt(action[action.length - 1]);
18
- return (_jsx("button", { onClick: () => editor.chain().focus().toggleHeading({ level: level }).run(), className: `pl-2 ${isActive ? 'is-active' : ''}`, children: label }));
19
- }
20
- return (_jsx("button", { onClick: () => editor.chain().focus()[action]().run(), disabled: disabled ? !editor.can().chain().focus()[action]().run() : false, className: `pl-2 ${isActive ? 'is-active' : ''}`, children: label }));
21
- };
22
- const MenuBar = () => {
23
- const { editor } = useCurrentEditor();
24
- if (!editor) {
25
- return null;
26
- }
27
- return (_jsxs("div", { className: "bg-gray-400 dark:bg-gray-800 dark:text-white text-lg flex flex-row flex-wrap items-center p-1", children: [_jsx(EditorButton, { action: "toggleBold", isActive: editor.isActive('bold'), label: _jsx(FaBold, {}), disabled: true }), _jsx(EditorButton, { action: "toggleItalic", isActive: editor.isActive('italic'), label: _jsx(FaItalic, {}), disabled: true }), _jsx(EditorButton, { action: "toggleStrike", isActive: editor.isActive('strike'), label: _jsx(FaStrikethrough, {}), disabled: true }), _jsx(EditorButton, { action: "toggleCode", isActive: editor.isActive('code'), label: _jsx(FaCode, {}), disabled: true }), _jsx(EditorButton, { action: "setParagraph", isActive: editor.isActive('paragraph'), label: _jsx(FaParagraph, {}) }), _jsx(EditorButton, { action: "setHeading1", isActive: editor.isActive('heading', { level: 1 }), label: _jsx(LuHeading1, { size: '24px' }) }), _jsx(EditorButton, { action: "setHeading2", isActive: editor.isActive('heading', { level: 2 }), label: _jsx(LuHeading2, { size: '24px' }) }), _jsx(EditorButton, { action: "setHeading3", isActive: editor.isActive('heading', { level: 3 }), label: _jsx(LuHeading3, { size: '24px' }) }), _jsx(EditorButton, { action: "toggleBulletList", isActive: editor.isActive('bulletList'), label: _jsx(AiOutlineUnorderedList, { size: '24px' }) }), _jsx(EditorButton, { action: "toggleOrderedList", isActive: editor.isActive('orderedList'), label: _jsx(GoListOrdered, { size: '24px' }) }), _jsx(EditorButton, { action: "toggleCodeBlock", isActive: editor.isActive('codeBlock'), label: _jsx(PiCodeBlock, { size: '24px' }) }), _jsx(EditorButton, { action: "toggleBlockquote", isActive: editor.isActive('blockquote'), label: _jsx(TbBlockquote, { size: '24px' }) })] }));
28
- };
29
- const extensions = [
30
- StarterKit.configure({
31
- bulletList: {
32
- HTMLAttributes: {
33
- class: 'list-disc list-inside dark:text-white p-1 mt-1 [&_li]:mb-1 [&_p]:inline m-0',
34
- },
35
- },
36
- orderedList: {
37
- HTMLAttributes: {
38
- className: 'list-decimal list-inside dark:text-white p-1 mt-1 [&_li]:mb-1 [&_p]:inline m-0',
39
- },
40
- },
41
- }),
42
- Markdown,
43
- ];
44
- export const MarkdownEditor = (props) => {
45
- return (_jsx("div", { className: 'text-md border border-gray-800 overflow-hidden ' + props.className, style: { borderWidth: props.editable ? 1 : 0 }, children: _jsx(EditorProvider, { slotBefore: props.editable ? _jsx(MenuBar, {}) : null, extensions: extensions, content: props.content, editable: props.editable, onUpdate: (e) => {
46
- props.onUpdate && props.onUpdate(e.editor.storage.markdown.getMarkdown());
47
- } }, (props.editable ? 'editable' : 'readonly') + props.content) }));
48
- };
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- interface SpinnerProps {
3
- text?: string;
4
- size?: string;
5
- className?: string;
6
- }
7
- export declare const Spinner: React.FC<SpinnerProps>;
8
- export {};
@@ -1,4 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export const Spinner = ({ text, className, size = '30px' }) => {
3
- return (_jsxs("div", { className: 'flex items-center space-x-2 ' + className, children: [_jsxs("svg", { style: { width: size, height: size }, className: "animate-spin -ml-1 mr-3 h-5 w-5 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), text && _jsx("span", { className: "", children: text })] }));
4
- };
@@ -1,9 +0,0 @@
1
- import { FirstMessages } from './utils';
2
- interface Props {
3
- voiceId: any;
4
- avatarImageUrl: string;
5
- onComplete: (result: any) => void;
6
- autoStartConversation?: FirstMessages;
7
- }
8
- export declare function AssistantChat({ avatarImageUrl, voiceId, onComplete, autoStartConversation }: Props): import("react/jsx-runtime").JSX.Element;
9
- export {};