@rimori/client 1.4.10 → 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/{core → rimori-client/src}/controller/VoiceController.d.ts +1 -1
  19. package/dist/rimori-client/src/index.d.ts +11 -0
  20. package/dist/rimori-client/src/index.js +10 -0
  21. package/dist/{plugin/PluginController.d.ts → rimori-client/src/plugin/CommunicationHandler.d.ts} +3 -7
  22. package/dist/{plugin/PluginController.js → rimori-client/src/plugin/CommunicationHandler.js} +3 -28
  23. package/dist/{plugin → rimori-client/src/plugin}/RimoriClient.d.ts +67 -68
  24. package/dist/{plugin → rimori-client/src/plugin}/RimoriClient.js +101 -43
  25. package/dist/{worker → rimori-client/src/worker}/WorkerSetup.js +2 -2
  26. package/example/docs/devdocs.md +1 -1
  27. package/package.json +4 -26
  28. package/src/{core/controller → controller}/AIController.ts +3 -3
  29. package/src/{plugin/AccomplishmentHandler.ts → controller/AccomplishmentController.ts} +1 -1
  30. package/src/{core/controller → controller}/ExerciseController.ts +14 -11
  31. package/src/{core/controller → controller}/ObjectController.ts +2 -2
  32. package/src/{core/controller → controller}/SettingsController.ts +2 -2
  33. package/src/{core/controller → controller}/SharedContentController.ts +1 -1
  34. package/src/{core/controller → controller}/VoiceController.ts +2 -2
  35. package/src/fromRimori/readme.md +1 -1
  36. package/src/index.ts +8 -8
  37. package/src/plugin/{PluginController.ts → CommunicationHandler.ts} +8 -36
  38. package/src/plugin/RimoriClient.ts +125 -118
  39. package/src/worker/WorkerSetup.ts +5 -3
  40. package/tsconfig.json +4 -2
  41. package/dist/cli/scripts/release/release-translation-upload.d.ts +0 -6
  42. package/dist/cli/scripts/release/release-translation-upload.js +0 -87
  43. package/dist/components/CRUDModal.d.ts +0 -17
  44. package/dist/components/CRUDModal.js +0 -24
  45. package/dist/components/MarkdownEditor.d.ts +0 -8
  46. package/dist/components/MarkdownEditor.js +0 -48
  47. package/dist/components/Spinner.d.ts +0 -8
  48. package/dist/components/Spinner.js +0 -4
  49. package/dist/components/ai/Assistant.d.ts +0 -9
  50. package/dist/components/ai/Assistant.js +0 -58
  51. package/dist/components/ai/Avatar.d.ts +0 -14
  52. package/dist/components/ai/Avatar.js +0 -59
  53. package/dist/components/ai/EmbeddedAssistent/AudioInputField.d.ts +0 -7
  54. package/dist/components/ai/EmbeddedAssistent/AudioInputField.js +0 -37
  55. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +0 -8
  56. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +0 -79
  57. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +0 -19
  58. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.js +0 -91
  59. package/dist/components/ai/EmbeddedAssistent/TTS/Player.d.ts +0 -27
  60. package/dist/components/ai/EmbeddedAssistent/TTS/Player.js +0 -185
  61. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +0 -11
  62. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +0 -95
  63. package/dist/components/ai/utils.d.ts +0 -6
  64. package/dist/components/ai/utils.js +0 -13
  65. package/dist/components/audio/Playbutton.d.ts +0 -15
  66. package/dist/components/audio/Playbutton.js +0 -80
  67. package/dist/components/components/ContextMenu.d.ts +0 -10
  68. package/dist/components/components/ContextMenu.js +0 -135
  69. package/dist/components.d.ts +0 -10
  70. package/dist/components.js +0 -11
  71. package/dist/core/controller/EnhancedUserInfo.d.ts +0 -0
  72. package/dist/core/controller/EnhancedUserInfo.js +0 -1
  73. package/dist/core/core.d.ts +0 -14
  74. package/dist/core/core.js +0 -7
  75. package/dist/hooks/I18nHooks.d.ts +0 -11
  76. package/dist/hooks/I18nHooks.js +0 -25
  77. package/dist/hooks/UseChatHook.d.ts +0 -10
  78. package/dist/hooks/UseChatHook.js +0 -29
  79. package/dist/i18n/I18nHooks.d.ts +0 -11
  80. package/dist/i18n/I18nHooks.js +0 -25
  81. package/dist/i18n/Translator.d.ts +0 -43
  82. package/dist/i18n/Translator.js +0 -118
  83. package/dist/i18n/config.d.ts +0 -7
  84. package/dist/i18n/config.js +0 -20
  85. package/dist/i18n/createI18nInstance.d.ts +0 -7
  86. package/dist/i18n/createI18nInstance.js +0 -31
  87. package/dist/i18n/hooks.d.ts +0 -11
  88. package/dist/i18n/hooks.js +0 -25
  89. package/dist/i18n/index.d.ts +0 -4
  90. package/dist/i18n/index.js +0 -4
  91. package/dist/i18n/types.d.ts +0 -7
  92. package/dist/i18n/types.js +0 -1
  93. package/dist/i18n/useRimoriI18n.d.ts +0 -11
  94. package/dist/i18n/useRimoriI18n.js +0 -41
  95. package/dist/index.d.ts +0 -11
  96. package/dist/index.js +0 -11
  97. package/dist/plugin/Translator.d.ts +0 -38
  98. package/dist/plugin/Translator.js +0 -101
  99. package/dist/providers/PluginProvider.d.ts +0 -12
  100. package/dist/providers/PluginProvider.js +0 -152
  101. package/dist/style.css +0 -110
  102. package/dist/style.css.map +0 -1
  103. package/dist/utils/Language.d.ts +0 -67
  104. package/dist/utils/Language.js +0 -69
  105. package/dist/utils/LanguageClass.d.ts +0 -36
  106. package/dist/utils/LanguageClass.example.d.ts +0 -0
  107. package/dist/utils/LanguageClass.example.js +0 -1
  108. package/dist/utils/LanguageClass.js +0 -50
  109. package/dist/utils/LanguageClass.test.d.ts +0 -0
  110. package/dist/utils/LanguageClass.test.js +0 -1
  111. package/src/components/CRUDModal.tsx +0 -75
  112. package/src/components/MarkdownEditor.tsx +0 -144
  113. package/src/components/Spinner.tsx +0 -29
  114. package/src/components/ai/Assistant.tsx +0 -96
  115. package/src/components/ai/Avatar.tsx +0 -99
  116. package/src/components/ai/EmbeddedAssistent/AudioInputField.tsx +0 -73
  117. package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +0 -107
  118. package/src/components/ai/EmbeddedAssistent/TTS/MessageSender.ts +0 -96
  119. package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +0 -197
  120. package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +0 -129
  121. package/src/components/ai/utils.ts +0 -21
  122. package/src/components/audio/Playbutton.tsx +0 -126
  123. package/src/components/components/ContextMenu.tsx +0 -179
  124. package/src/components.ts +0 -11
  125. package/src/core/core.ts +0 -15
  126. package/src/hooks/I18nHooks.ts +0 -33
  127. package/src/hooks/UseChatHook.ts +0 -38
  128. package/src/plugin/ThemeSetter.ts +0 -23
  129. package/src/providers/PluginProvider.tsx +0 -209
  130. package/src/style.scss +0 -136
  131. package/src/utils/PluginUtils.ts +0 -22
  132. /package/dist/{plugin → react-client/plugin}/ThemeSetter.d.ts +0 -0
  133. /package/dist/{plugin → react-client/plugin}/ThemeSetter.js +0 -0
  134. /package/dist/{utils/PluginUtils.d.ts → react-client/src/utils/FullscreenUtils.d.ts} +0 -0
  135. /package/dist/{utils/PluginUtils.js → react-client/src/utils/FullscreenUtils.js} +0 -0
  136. /package/dist/{cli → rimori-client/src/cli}/scripts/init/dev-registration.d.ts +0 -0
  137. /package/dist/{cli → rimori-client/src/cli}/scripts/init/dev-registration.js +0 -0
  138. /package/dist/{cli → rimori-client/src/cli}/scripts/init/env-setup.d.ts +0 -0
  139. /package/dist/{cli → rimori-client/src/cli}/scripts/init/env-setup.js +0 -0
  140. /package/dist/{cli → rimori-client/src/cli}/scripts/init/file-operations.d.ts +0 -0
  141. /package/dist/{cli → rimori-client/src/cli}/scripts/init/file-operations.js +0 -0
  142. /package/dist/{cli → rimori-client/src/cli}/scripts/init/html-cleaner.d.ts +0 -0
  143. /package/dist/{cli → rimori-client/src/cli}/scripts/init/html-cleaner.js +0 -0
  144. /package/dist/{cli → rimori-client/src/cli}/scripts/init/main.d.ts +0 -0
  145. /package/dist/{cli → rimori-client/src/cli}/scripts/init/package-setup.d.ts +0 -0
  146. /package/dist/{cli → rimori-client/src/cli}/scripts/init/package-setup.js +0 -0
  147. /package/dist/{cli → rimori-client/src/cli}/scripts/init/router-transformer.d.ts +0 -0
  148. /package/dist/{cli → rimori-client/src/cli}/scripts/init/router-transformer.js +0 -0
  149. /package/dist/{cli → rimori-client/src/cli}/scripts/init/tailwind-config.d.ts +0 -0
  150. /package/dist/{cli → rimori-client/src/cli}/scripts/init/tailwind-config.js +0 -0
  151. /package/dist/{cli → rimori-client/src/cli}/scripts/init/vite-config.d.ts +0 -0
  152. /package/dist/{cli → rimori-client/src/cli}/scripts/init/vite-config.js +0 -0
  153. /package/dist/{cli → rimori-client/src/cli}/scripts/release/detect-translation-languages.d.ts +0 -0
  154. /package/dist/{cli → rimori-client/src/cli}/scripts/release/detect-translation-languages.js +0 -0
  155. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-config-upload.d.ts +0 -0
  156. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-config-upload.js +0 -0
  157. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-db-update.d.ts +0 -0
  158. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-db-update.js +0 -0
  159. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-file-upload.d.ts +0 -0
  160. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release-file-upload.js +0 -0
  161. /package/dist/{cli → rimori-client/src/cli}/scripts/release/release.d.ts +0 -0
  162. /package/dist/{cli → rimori-client/src/cli}/types/DatabaseTypes.d.ts +0 -0
  163. /package/dist/{cli → rimori-client/src/cli}/types/DatabaseTypes.js +0 -0
  164. /package/dist/{plugin → rimori-client/src/controller}/AudioController.d.ts +0 -0
  165. /package/dist/{plugin → rimori-client/src/controller}/AudioController.js +0 -0
  166. /package/dist/{core → rimori-client/src}/controller/SettingsController.js +0 -0
  167. /package/dist/{core → rimori-client/src}/controller/SharedContentController.js +0 -0
  168. /package/dist/{plugin → rimori-client/src/controller}/TranslationController.d.ts +0 -0
  169. /package/dist/{plugin → rimori-client/src/controller}/TranslationController.js +0 -0
  170. /package/dist/{core → rimori-client/src}/controller/VoiceController.js +0 -0
  171. /package/dist/{fromRimori → rimori-client/src/fromRimori}/EventBus.d.ts +0 -0
  172. /package/dist/{fromRimori → rimori-client/src/fromRimori}/EventBus.js +0 -0
  173. /package/dist/{fromRimori → rimori-client/src/fromRimori}/PluginTypes.d.ts +0 -0
  174. /package/dist/{fromRimori → rimori-client/src/fromRimori}/PluginTypes.js +0 -0
  175. /package/dist/{plugin → rimori-client/src/plugin}/Logger.d.ts +0 -0
  176. /package/dist/{plugin → rimori-client/src/plugin}/Logger.js +0 -0
  177. /package/dist/{plugin → rimori-client/src/plugin}/StandaloneClient.d.ts +0 -0
  178. /package/dist/{plugin → rimori-client/src/plugin}/StandaloneClient.js +0 -0
  179. /package/dist/{utils → rimori-client/src/utils}/difficultyConverter.d.ts +0 -0
  180. /package/dist/{utils → rimori-client/src/utils}/difficultyConverter.js +0 -0
  181. /package/dist/{utils → rimori-client/src/utils}/endpoint.d.ts +0 -0
  182. /package/dist/{utils → rimori-client/src/utils}/endpoint.js +0 -0
  183. /package/dist/{worker → rimori-client/src/worker}/WorkerSetup.d.ts +0 -0
  184. /package/src/{plugin → controller}/AudioController.ts +0 -0
  185. /package/src/{plugin → controller}/TranslationController.ts +0 -0
package/README.md CHANGED
@@ -823,55 +823,6 @@ const EditorExample = () => {
823
823
  };
824
824
  ```
825
825
 
826
- ### CRUDModal
827
-
828
- Modal component for create/update operations:
829
-
830
- ```typescript
831
- import { CRUDModal } from "@rimori/client";
832
-
833
- const DataManager = () => {
834
- const [isOpen, setIsOpen] = useState(false);
835
- const [editItem, setEditItem] = useState(null);
836
-
837
- return (
838
- <CRUDModal
839
- isOpen={isOpen}
840
- onClose={() => setIsOpen(false)}
841
- title={editItem ? "Edit Item" : "Create Item"}
842
- onSave={(data) => {
843
- // Handle save logic
844
- console.log('Saving:', data);
845
- setIsOpen(false);
846
- }}
847
- initialData={editItem}
848
- >
849
- {/* Your form content */}
850
- <input placeholder="Item name" />
851
- <textarea placeholder="Description" />
852
- </CRUDModal>
853
- );
854
- };
855
- ```
856
-
857
- ### Spinner
858
-
859
- Loading indicator component:
860
-
861
- ```typescript
862
- import { Spinner } from "@rimori/client";
863
-
864
- const LoadingExample = () => {
865
- const [isLoading, setIsLoading] = useState(true);
866
-
867
- if (isLoading) {
868
- return <Spinner size="large" />;
869
- }
870
-
871
- return <div>Content loaded!</div>;
872
- };
873
- ```
874
-
875
826
  ### PlayButton
876
827
 
877
828
  Audio playback component:
@@ -0,0 +1,2 @@
1
+ export declare function setTheme(theme?: string | null): void;
2
+ export declare function isDarkTheme(theme?: string | null): boolean;
@@ -0,0 +1,19 @@
1
+ export function setTheme(theme) {
2
+ document.documentElement.classList.add('dark:text-gray-200');
3
+ if (isDarkTheme(theme)) {
4
+ document.documentElement.setAttribute('data-theme', 'dark');
5
+ document.documentElement.classList.add('dark', 'dark:bg-gray-950');
6
+ document.documentElement.style.background = 'hsl(var(--background))';
7
+ }
8
+ }
9
+ export function isDarkTheme(theme) {
10
+ // If no theme provided, try to get from URL as fallback (for standalone mode)
11
+ if (!theme) {
12
+ const urlParams = new URLSearchParams(window.location.search);
13
+ theme = urlParams.get('theme');
14
+ }
15
+ if (!theme || theme === 'system') {
16
+ return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
17
+ }
18
+ return theme === 'dark';
19
+ }
@@ -0,0 +1,2 @@
1
+ export declare function isFullscreen(): boolean;
2
+ export declare function triggerFullscreen(onStateChange: (isFullscreen: boolean) => void, selector?: string): void;
@@ -0,0 +1,23 @@
1
+ export function isFullscreen() {
2
+ return !!document.fullscreenElement;
3
+ }
4
+ export function triggerFullscreen(onStateChange, selector) {
5
+ document.addEventListener('fullscreenchange', () => {
6
+ onStateChange(isFullscreen());
7
+ });
8
+ try {
9
+ const ref = document.querySelector(selector || '#root');
10
+ if (!isFullscreen()) {
11
+ // @ts-ignore
12
+ ref.requestFullscreen() || ref.webkitRequestFullscreen();
13
+ }
14
+ else {
15
+ // @ts-ignore
16
+ document.exitFullscreen() || document.webkitExitFullscreen();
17
+ }
18
+ }
19
+ catch (error) {
20
+ console.error('Failed to enter fullscreen', error.message);
21
+ }
22
+ onStateChange(isFullscreen());
23
+ }
@@ -1,4 +1,4 @@
1
- import { Tool } from '../../fromRimori/PluginTypes';
1
+ import { Tool } from '../fromRimori/PluginTypes';
2
2
  export interface ToolInvocation {
3
3
  toolCallId: string;
4
4
  toolName: string;
@@ -31,7 +31,7 @@ export function generateText(backendUrl, messages, tools, token) {
31
31
  export function streamChatGPT(backendUrl, messages, tools, onResponse, token) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
33
  const messageId = Math.random().toString(36).substring(3);
34
- let currentMessages = [...messages];
34
+ const currentMessages = [...messages];
35
35
  console.log('Starting streamChatGPT with:', {
36
36
  messageId,
37
37
  messageCount: messages.length,
@@ -60,7 +60,7 @@ export function streamChatGPT(backendUrl, messages, tools, onResponse, token) {
60
60
  const decoder = new TextDecoder('utf-8');
61
61
  let content = '';
62
62
  let done = false;
63
- let toolInvocations = [];
63
+ const toolInvocations = [];
64
64
  let currentTextId = '';
65
65
  let isToolCallMode = false;
66
66
  let buffer = ''; // Buffer for incomplete chunks
@@ -21,7 +21,7 @@ export interface MacroAccomplishmentPayload extends BaseAccomplishmentPayload {
21
21
  durationMinutes: number;
22
22
  }
23
23
  export type AccomplishmentPayload = MicroAccomplishmentPayload | MacroAccomplishmentPayload;
24
- export declare class AccomplishmentHandler {
24
+ export declare class AccomplishmentController {
25
25
  private pluginId;
26
26
  constructor(pluginId: string);
27
27
  emitAccomplishment(payload: Omit<AccomplishmentPayload, 'type'>): void;
@@ -1,6 +1,6 @@
1
1
  import { EventBus } from '../fromRimori/EventBus';
2
2
  export const skillCategories = ['reading', 'listening', 'speaking', 'writing', 'learning', 'community'];
3
- export class AccomplishmentHandler {
3
+ export class AccomplishmentController {
4
4
  constructor(pluginId) {
5
5
  this.pluginId = pluginId;
6
6
  }
@@ -1,5 +1,4 @@
1
1
  import { SupabaseClient } from '@supabase/supabase-js';
2
- import { PluginController } from '../../plugin/PluginController';
3
2
  export type TriggerAction = {
4
3
  action_key: string;
5
4
  } & Record<string, string | number | boolean>;
@@ -26,8 +25,7 @@ export interface Exercise {
26
25
  }
27
26
  export declare class ExerciseController {
28
27
  private supabase;
29
- private pluginController;
30
- constructor(supabase: SupabaseClient, pluginController: PluginController);
28
+ constructor(supabase: SupabaseClient);
31
29
  /**
32
30
  * Fetches weekly exercises from the weekly_exercises view.
33
31
  * Shows exercises for the current week that haven't expired.
@@ -36,16 +34,20 @@ export declare class ExerciseController {
36
34
  viewWeeklyExercises(): Promise<Exercise[]>;
37
35
  /**
38
36
  * Creates a new exercise via the backend API.
37
+ * @param token The token to use for authentication.
38
+ * @param backendUrl The URL of the backend API.
39
39
  * @param params Exercise creation parameters.
40
40
  * @returns Created exercise object.
41
41
  */
42
- addExercise(params: CreateExerciseParams): Promise<Exercise>;
42
+ addExercise(token: string, backendUrl: string, params: CreateExerciseParams): Promise<Exercise>;
43
43
  /**
44
44
  * Deletes an exercise via the backend API.
45
- * @param id The exercise ID to delete.
45
+ * @param token The token to use for authentication.
46
+ * @param backendUrl The URL of the backend API.
47
+ * @param exerciseId The exercise ID to delete.
46
48
  * @returns Success status.
47
49
  */
48
- deleteExercise(id: string): Promise<{
50
+ deleteExercise(token: string, backendUrl: string, id: string): Promise<{
49
51
  success: boolean;
50
52
  message: string;
51
53
  }>;
@@ -8,9 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  export class ExerciseController {
11
- constructor(supabase, pluginController) {
11
+ constructor(supabase) {
12
12
  this.supabase = supabase;
13
- this.pluginController = pluginController;
14
13
  }
15
14
  /**
16
15
  * Fetches weekly exercises from the weekly_exercises view.
@@ -28,13 +27,14 @@ export class ExerciseController {
28
27
  }
29
28
  /**
30
29
  * Creates a new exercise via the backend API.
30
+ * @param token The token to use for authentication.
31
+ * @param backendUrl The URL of the backend API.
31
32
  * @param params Exercise creation parameters.
32
33
  * @returns Created exercise object.
33
34
  */
34
- addExercise(params) {
35
+ addExercise(token, backendUrl, params) {
35
36
  return __awaiter(this, void 0, void 0, function* () {
36
- const token = yield this.pluginController.getToken();
37
- const response = yield fetch(`${this.pluginController.getBackendUrl()}/exercises`, {
37
+ const response = yield fetch(`${backendUrl}/exercises`, {
38
38
  method: 'POST',
39
39
  headers: {
40
40
  'Content-Type': 'application/json',
@@ -51,13 +51,14 @@ export class ExerciseController {
51
51
  }
52
52
  /**
53
53
  * Deletes an exercise via the backend API.
54
- * @param id The exercise ID to delete.
54
+ * @param token The token to use for authentication.
55
+ * @param backendUrl The URL of the backend API.
56
+ * @param exerciseId The exercise ID to delete.
55
57
  * @returns Success status.
56
58
  */
57
- deleteExercise(id) {
59
+ deleteExercise(token, backendUrl, id) {
58
60
  return __awaiter(this, void 0, void 0, function* () {
59
- const token = yield this.pluginController.getToken();
60
- const response = yield fetch(`${this.pluginController.getBackendUrl()}/exercises/${id}`, {
61
+ const response = yield fetch(`${backendUrl}/exercises/${id}`, {
61
62
  method: 'DELETE',
62
63
  headers: {
63
64
  Authorization: `Bearer ${token}`,
@@ -36,7 +36,7 @@ export interface ObjectRequest {
36
36
  */
37
37
  instructions: string;
38
38
  }
39
- export declare function generateObject(backendUrl: string, request: ObjectRequest, token: string): Promise<any>;
39
+ export declare function generateObject<T = any>(backendUrl: string, request: ObjectRequest, token: string): Promise<T>;
40
40
  export type OnLLMResponse = (id: string, response: string, finished: boolean, toolInvocations?: any[]) => void;
41
41
  export declare function streamObject(backendUrl: string, request: ObjectRequest, onResponse: OnLLMResponse, token: string): Promise<void>;
42
42
  export {};
@@ -42,7 +42,7 @@ export function streamObject(backendUrl, request, onResponse, token) {
42
42
  const decoder = new TextDecoder('utf-8');
43
43
  let content = '';
44
44
  let done = false;
45
- let toolInvocations = [];
45
+ const toolInvocations = [];
46
46
  while (!done) {
47
47
  const { value } = yield reader.read();
48
48
  if (value) {
@@ -1,6 +1,6 @@
1
1
  import { SupabaseClient } from '@supabase/supabase-js';
2
- import { LanguageLevel } from '../../utils/difficultyConverter';
3
- import { Guild } from '../core';
2
+ import { LanguageLevel } from '../utils/difficultyConverter';
3
+ import { Guild } from '../plugin/CommunicationHandler';
4
4
  export interface Buddy {
5
5
  id: string;
6
6
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { SupabaseClient } from '@supabase/supabase-js';
2
- import { RimoriClient } from '../../plugin/RimoriClient';
2
+ import { RimoriClient } from '../plugin/RimoriClient';
3
3
  import { ObjectRequest } from './ObjectController';
4
4
  export interface SharedContentObjectRequest extends ObjectRequest {
5
5
  fixedProperties?: Record<string, string | number | boolean>;
@@ -1,4 +1,4 @@
1
- export declare function getSTTResponse(backendUrl: string, audio: Blob, token: string): Promise<any>;
1
+ export declare function getSTTResponse(backendUrl: string, audio: Blob, token: string): Promise<string>;
2
2
  export declare function getTTSResponse(backendUrl: string, request: TTSRequest, token: string): Promise<Blob>;
3
3
  interface TTSRequest {
4
4
  input: string;
@@ -0,0 +1,11 @@
1
+ export * from './plugin/CommunicationHandler';
2
+ export * from './cli/types/DatabaseTypes';
3
+ export * from './utils/difficultyConverter';
4
+ export * from './fromRimori/PluginTypes';
5
+ export * from './fromRimori/EventBus';
6
+ export * from './plugin/RimoriClient';
7
+ export * from './plugin/StandaloneClient';
8
+ export { AudioController } from './controller/AudioController';
9
+ export { Translator } from './controller/TranslationController';
10
+ export type { Message, ToolInvocation } from './controller/AIController';
11
+ export type { TOptions } from 'i18next';
@@ -0,0 +1,10 @@
1
+ // Re-export everything
2
+ export * from './plugin/CommunicationHandler';
3
+ export * from './cli/types/DatabaseTypes';
4
+ export * from './utils/difficultyConverter';
5
+ export * from './fromRimori/PluginTypes';
6
+ export * from './fromRimori/EventBus';
7
+ export * from './plugin/RimoriClient';
8
+ export * from './plugin/StandaloneClient';
9
+ export { AudioController } from './controller/AudioController';
10
+ export { Translator } from './controller/TranslationController';
@@ -1,7 +1,6 @@
1
1
  import { SupabaseClient } from '@supabase/supabase-js';
2
- import { UserInfo } from '../core/controller/SettingsController';
2
+ import { UserInfo } from '../controller/SettingsController';
3
3
  import { ActivePlugin, Plugin } from '../fromRimori/PluginTypes';
4
- import { RimoriClient } from './RimoriClient';
5
4
  export interface Guild {
6
5
  id: string;
7
6
  longTermGoalOverride: string;
@@ -21,9 +20,7 @@ export interface RimoriInfo {
21
20
  mainPanelPlugin?: ActivePlugin;
22
21
  sidePanelPlugin?: ActivePlugin;
23
22
  }
24
- export declare class PluginController {
25
- private static client;
26
- private static instance;
23
+ export declare class RimoriCommunicationHandler {
27
24
  private port;
28
25
  private queryParams;
29
26
  private supabase;
@@ -31,10 +28,9 @@ export declare class PluginController {
31
28
  private pluginId;
32
29
  private isMessageChannelReady;
33
30
  private pendingRequests;
34
- private constructor();
31
+ constructor(pluginId: string, standalone: boolean);
35
32
  private initMessageChannel;
36
33
  private sendHello;
37
- static getInstance(pluginId: string, standalone?: boolean): Promise<RimoriClient>;
38
34
  getQueryParam(key: string): string | null;
39
35
  getClient(): Promise<{
40
36
  supabase: SupabaseClient;
@@ -9,11 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { createClient } from '@supabase/supabase-js';
11
11
  import { EventBus } from '../fromRimori/EventBus';
12
- import { RimoriClient } from './RimoriClient';
13
- import { StandaloneClient } from './StandaloneClient';
14
- import { setTheme } from './ThemeSetter';
15
- import { Logger } from './Logger';
16
- export class PluginController {
12
+ export class RimoriCommunicationHandler {
17
13
  constructor(pluginId, standalone) {
18
14
  this.port = null;
19
15
  this.queryParams = {};
@@ -23,12 +19,6 @@ export class PluginController {
23
19
  this.pendingRequests = [];
24
20
  this.pluginId = pluginId;
25
21
  this.getClient = this.getClient.bind(this);
26
- if (typeof WorkerGlobalScope === 'undefined') {
27
- // In standalone mode, use URL fallback. In iframe mode, theme will be set after MessageChannel init
28
- if (standalone) {
29
- setTheme();
30
- }
31
- }
32
22
  //no need to forward messages to parent in standalone mode or worker context
33
23
  if (standalone)
34
24
  return;
@@ -76,7 +66,8 @@ export class PluginController {
76
66
  // Set theme from MessageChannel query params
77
67
  if (!worker) {
78
68
  const theme = this.queryParams['rm_theme'];
79
- setTheme(theme);
69
+ // setTheme(theme);
70
+ console.log('TODO: set theme from MessageChannel query params');
80
71
  }
81
72
  // Forward plugin events to parent (only after MessageChannel is ready)
82
73
  EventBus.on('*', (ev) => {
@@ -113,22 +104,6 @@ export class PluginController {
113
104
  console.error('[PluginController] Error sending hello:', e);
114
105
  }
115
106
  }
116
- static getInstance(pluginId_1) {
117
- return __awaiter(this, arguments, void 0, function* (pluginId, standalone = false) {
118
- if (!PluginController.instance) {
119
- if (standalone) {
120
- yield StandaloneClient.initListeners(pluginId);
121
- }
122
- PluginController.instance = new PluginController(pluginId, standalone);
123
- PluginController.client = yield RimoriClient.getInstance(PluginController.instance);
124
- //only init logger in workers and on main plugin pages
125
- if (PluginController.instance.getQueryParam('applicationMode') !== 'sidebar') {
126
- Logger.getInstance(PluginController.client);
127
- }
128
- }
129
- return PluginController.client;
130
- });
131
- }
132
107
  getQueryParam(key) {
133
108
  return this.queryParams[key] || null;
134
109
  }
@@ -1,65 +1,14 @@
1
1
  import { PostgrestQueryBuilder } from '@supabase/postgrest-js';
2
2
  import { GenericSchema } from '@supabase/supabase-js/dist/module/lib/types';
3
- import { Message, OnLLMResponse } from '../core/controller/AIController';
4
- import { ObjectRequest } from '../core/controller/ObjectController';
5
- import { UserInfo } from '../core/controller/SettingsController';
6
- import { SharedContent, SharedContentFilter, SharedContentObjectRequest } from '../core/controller/SharedContentController';
7
- import { CreateExerciseParams } from '../core/controller/ExerciseController';
3
+ import { Message, OnLLMResponse } from '../controller/AIController';
4
+ import { ObjectRequest } from '../controller/ObjectController';
5
+ import { UserInfo } from '../controller/SettingsController';
6
+ import { SharedContent, SharedContentFilter, SharedContentObjectRequest } from '../controller/SharedContentController';
7
+ import { CreateExerciseParams } from '../controller/ExerciseController';
8
8
  import { EventBusMessage, EventHandler, EventPayload } from '../fromRimori/EventBus';
9
9
  import { ActivePlugin, MainPanelAction, Plugin, Tool } from '../fromRimori/PluginTypes';
10
- import { AccomplishmentPayload } from './AccomplishmentHandler';
11
- import { PluginController } from './PluginController';
12
- import { Translator } from './TranslationController';
13
- interface Db {
14
- from: {
15
- <TableName extends string & keyof GenericSchema['Tables'], Table extends GenericSchema['Tables'][TableName]>(relation: TableName): PostgrestQueryBuilder<GenericSchema, Table, TableName>;
16
- <ViewName extends string & keyof GenericSchema['Views'], View extends GenericSchema['Views'][ViewName]>(relation: ViewName): PostgrestQueryBuilder<GenericSchema, View, ViewName>;
17
- };
18
- /**
19
- * The table prefix for of database tables of the plugin.
20
- */
21
- tablePrefix: string;
22
- /**
23
- * Get the table name for a given plugin table.
24
- * Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
25
- * @param table The plugin table name to get the full table name for.
26
- * @returns The full table name.
27
- */
28
- getTableName: (table: string) => string;
29
- }
30
- interface PluginInterface {
31
- pluginId: string;
32
- setSettings: (settings: any) => Promise<void>;
33
- /**
34
- * Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
35
- * @param defaultSettings The default settings to use if no settings are found.
36
- * @param genericSettings The type of settings to get.
37
- * @returns The settings for the plugin.
38
- */
39
- getSettings: <T extends object>(defaultSettings: T) => Promise<T>;
40
- /**
41
- * Retrieves information about plugins, including:
42
- * - All installed plugins
43
- * - The currently active plugin in the main panel
44
- * - The currently active plugin in the side panel
45
- */
46
- getPluginInfo: () => {
47
- /**
48
- * All installed plugins.
49
- */
50
- installedPlugins: Plugin[];
51
- /**
52
- * The plugin that is loaded in the main panel.
53
- */
54
- mainPanelPlugin?: ActivePlugin;
55
- /**
56
- * The plugin that is loaded in the side panel.
57
- */
58
- sidePanelPlugin?: ActivePlugin;
59
- };
60
- getUserInfo: () => UserInfo;
61
- getTranslator: () => Promise<Translator>;
62
- }
10
+ import { AccomplishmentPayload } from '../controller/AccomplishmentController';
11
+ import { Translator } from '../controller/TranslationController';
63
12
  export declare class RimoriClient {
64
13
  private static instance;
65
14
  private superbase;
@@ -70,9 +19,62 @@ export declare class RimoriClient {
70
19
  private accomplishmentHandler;
71
20
  private rimoriInfo;
72
21
  private translator;
73
- plugin: PluginInterface;
74
- db: Db;
75
22
  private constructor();
23
+ get plugin(): {
24
+ pluginId: string;
25
+ /**
26
+ * Set the settings for the plugin.
27
+ * @param settings The settings to set.
28
+ */
29
+ setSettings: (settings: any) => Promise<void>;
30
+ /**
31
+ * Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
32
+ * @param defaultSettings The default settings to use if no settings are found.
33
+ * @param genericSettings The type of settings to get.
34
+ * @returns The settings for the plugin.
35
+ */
36
+ getSettings: <T extends object>(defaultSettings: T) => Promise<T>;
37
+ getUserInfo: () => UserInfo;
38
+ /**
39
+ * Retrieves information about plugins, including:
40
+ * - All installed plugins
41
+ * - The currently active plugin in the main panel
42
+ * - The currently active plugin in the side panel
43
+ */
44
+ getPluginInfo: () => {
45
+ /**
46
+ * All installed plugins.
47
+ */
48
+ installedPlugins: Plugin[];
49
+ /**
50
+ * The plugin that is loaded in the main panel.
51
+ */
52
+ mainPanelPlugin?: ActivePlugin;
53
+ /**
54
+ * The plugin that is loaded in the side panel.
55
+ */
56
+ sidePanelPlugin?: ActivePlugin;
57
+ };
58
+ /**
59
+ * Get the translator for the plugin.
60
+ * @returns The translator for the plugin.
61
+ */
62
+ getTranslator: () => Promise<Translator>;
63
+ };
64
+ get db(): {
65
+ from: (relation: string) => PostgrestQueryBuilder<GenericSchema, any, any>;
66
+ /**
67
+ * The table prefix for of database tables of the plugin.
68
+ */
69
+ tablePrefix: string;
70
+ /**
71
+ * Get the table name for a given plugin table.
72
+ * Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
73
+ * @param table The plugin table name to get the full table name for.
74
+ * @returns The full table name.
75
+ */
76
+ getTableName: (table: string) => string;
77
+ };
76
78
  event: {
77
79
  /**
78
80
  * Emit an event to Rimori or a plugin.
@@ -129,7 +131,7 @@ export declare class RimoriClient {
129
131
  * @param text Optional text to be used for the action like for example text that the translator would look up.
130
132
  */
131
133
  emitSidebarAction: (pluginId: string, actionKey: string, text?: string) => void;
132
- onMainPanelAction: (callback: (data: MainPanelAction) => void) => void;
134
+ onMainPanelAction: (callback: (data: MainPanelAction) => void, actionsToListen?: string[]) => void;
133
135
  };
134
136
  navigation: {
135
137
  toDashboard: () => void;
@@ -140,15 +142,13 @@ export declare class RimoriClient {
140
142
  * @returns The query parameter value or null if not found
141
143
  */
142
144
  getQueryParam(key: string): string | null;
143
- static getInstance(pluginController: PluginController): Promise<RimoriClient>;
144
- private from;
145
- private getTableName;
145
+ static getInstance(pluginId?: string): Promise<RimoriClient>;
146
146
  ai: {
147
147
  getText: (messages: Message[], tools?: Tool[]) => Promise<string>;
148
148
  getSteamedText: (messages: Message[], onMessage: OnLLMResponse, tools?: Tool[]) => Promise<void>;
149
149
  getVoice: (text: string, voice?: string, speed?: number, language?: string) => Promise<Blob>;
150
150
  getTextFromVoice: (file: Blob) => Promise<string>;
151
- getObject: (request: ObjectRequest) => Promise<any>;
151
+ getObject: <T = any>(request: ObjectRequest) => Promise<T>;
152
152
  };
153
153
  runtime: {
154
154
  fetchBackend: (url: string, options: RequestInit) => Promise<Response>;
@@ -238,13 +238,13 @@ export declare class RimoriClient {
238
238
  * Shows exercises for the current week that haven't expired.
239
239
  * @returns Array of exercise objects.
240
240
  */
241
- view: () => Promise<import("../core/controller/ExerciseController").Exercise[]>;
241
+ view: () => Promise<import("../controller/ExerciseController").Exercise[]>;
242
242
  /**
243
243
  * Creates a new exercise via the backend API.
244
244
  * @param params Exercise creation parameters.
245
245
  * @returns Created exercise object.
246
246
  */
247
- add: (params: CreateExerciseParams) => Promise<import("../core/controller/ExerciseController").Exercise>;
247
+ add: (params: CreateExerciseParams) => Promise<import("../controller/ExerciseController").Exercise>;
248
248
  /**
249
249
  * Deletes an exercise via the backend API.
250
250
  * @param id The exercise ID to delete.
@@ -256,4 +256,3 @@ export declare class RimoriClient {
256
256
  }>;
257
257
  };
258
258
  }
259
- export {};