@rimori/client 1.4.10 → 2.1.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.
- package/README.md +140 -1171
- package/dist/{core/controller → controller}/AIController.d.ts +1 -1
- package/dist/{core/controller → controller}/AIController.js +2 -2
- package/dist/{plugin/AccomplishmentHandler.d.ts → controller/AccomplishmentController.d.ts} +1 -1
- package/dist/{plugin/AccomplishmentHandler.js → controller/AccomplishmentController.js} +1 -1
- package/dist/{core/controller → controller}/ExerciseController.d.ts +8 -6
- package/dist/{core/controller → controller}/ExerciseController.js +10 -9
- package/dist/{core/controller → controller}/ObjectController.d.ts +1 -1
- package/dist/{core/controller → controller}/ObjectController.js +1 -1
- package/dist/{core/controller → controller}/SettingsController.d.ts +2 -2
- package/dist/{core/controller → controller}/SharedContentController.d.ts +1 -1
- package/dist/{core/controller → controller}/VoiceController.d.ts +1 -1
- package/dist/index.d.ts +14 -8
- package/dist/index.js +7 -7
- package/dist/plugin/{PluginController.d.ts → CommunicationHandler.d.ts} +4 -7
- package/dist/plugin/{PluginController.js → CommunicationHandler.js} +19 -27
- package/dist/plugin/RimoriClient.d.ts +67 -68
- package/dist/plugin/RimoriClient.js +101 -43
- package/dist/worker/WorkerSetup.js +3 -3
- package/example/docs/devdocs.md +1 -1
- package/package.json +5 -26
- package/src/{core/controller → controller}/AIController.ts +3 -3
- package/src/{plugin/AccomplishmentHandler.ts → controller/AccomplishmentController.ts} +1 -1
- package/src/{core/controller → controller}/ExerciseController.ts +14 -11
- package/src/{core/controller → controller}/ObjectController.ts +2 -2
- package/src/{core/controller → controller}/SettingsController.ts +2 -2
- package/src/{core/controller → controller}/SharedContentController.ts +1 -1
- package/src/{core/controller → controller}/VoiceController.ts +2 -2
- package/src/fromRimori/readme.md +1 -1
- package/src/index.ts +14 -8
- package/src/plugin/{PluginController.ts → CommunicationHandler.ts} +24 -36
- package/src/plugin/RimoriClient.ts +127 -118
- package/src/worker/WorkerSetup.ts +6 -4
- package/tsconfig.json +5 -2
- package/dist/cli/scripts/release/release-translation-upload.d.ts +0 -6
- package/dist/cli/scripts/release/release-translation-upload.js +0 -87
- package/dist/components/CRUDModal.d.ts +0 -17
- package/dist/components/CRUDModal.js +0 -24
- package/dist/components/MarkdownEditor.d.ts +0 -8
- package/dist/components/MarkdownEditor.js +0 -48
- package/dist/components/Spinner.d.ts +0 -8
- package/dist/components/Spinner.js +0 -4
- package/dist/components/ai/Assistant.d.ts +0 -9
- package/dist/components/ai/Assistant.js +0 -58
- package/dist/components/ai/Avatar.d.ts +0 -14
- package/dist/components/ai/Avatar.js +0 -59
- package/dist/components/ai/EmbeddedAssistent/AudioInputField.d.ts +0 -7
- package/dist/components/ai/EmbeddedAssistent/AudioInputField.js +0 -37
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +0 -8
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +0 -79
- package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +0 -19
- package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.js +0 -91
- package/dist/components/ai/EmbeddedAssistent/TTS/Player.d.ts +0 -27
- package/dist/components/ai/EmbeddedAssistent/TTS/Player.js +0 -185
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +0 -11
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +0 -95
- package/dist/components/ai/utils.d.ts +0 -6
- package/dist/components/ai/utils.js +0 -13
- package/dist/components/audio/Playbutton.d.ts +0 -15
- package/dist/components/audio/Playbutton.js +0 -80
- package/dist/components/components/ContextMenu.d.ts +0 -10
- package/dist/components/components/ContextMenu.js +0 -135
- package/dist/components.d.ts +0 -10
- package/dist/components.js +0 -11
- package/dist/core/controller/EnhancedUserInfo.d.ts +0 -0
- package/dist/core/controller/EnhancedUserInfo.js +0 -1
- package/dist/core/core.d.ts +0 -14
- package/dist/core/core.js +0 -7
- package/dist/hooks/I18nHooks.d.ts +0 -11
- package/dist/hooks/I18nHooks.js +0 -25
- package/dist/hooks/UseChatHook.d.ts +0 -10
- package/dist/hooks/UseChatHook.js +0 -29
- package/dist/i18n/I18nHooks.d.ts +0 -11
- package/dist/i18n/I18nHooks.js +0 -25
- package/dist/i18n/Translator.d.ts +0 -43
- package/dist/i18n/Translator.js +0 -118
- package/dist/i18n/config.d.ts +0 -7
- package/dist/i18n/config.js +0 -20
- package/dist/i18n/createI18nInstance.d.ts +0 -7
- package/dist/i18n/createI18nInstance.js +0 -31
- package/dist/i18n/hooks.d.ts +0 -11
- package/dist/i18n/hooks.js +0 -25
- package/dist/i18n/index.d.ts +0 -4
- package/dist/i18n/index.js +0 -4
- package/dist/i18n/types.d.ts +0 -7
- package/dist/i18n/types.js +0 -1
- package/dist/i18n/useRimoriI18n.d.ts +0 -11
- package/dist/i18n/useRimoriI18n.js +0 -41
- package/dist/plugin/ThemeSetter.d.ts +0 -2
- package/dist/plugin/ThemeSetter.js +0 -19
- package/dist/plugin/Translator.d.ts +0 -38
- package/dist/plugin/Translator.js +0 -101
- package/dist/providers/PluginProvider.d.ts +0 -12
- package/dist/providers/PluginProvider.js +0 -152
- package/dist/style.css +0 -110
- package/dist/style.css.map +0 -1
- package/dist/utils/Language.d.ts +0 -67
- package/dist/utils/Language.js +0 -69
- package/dist/utils/LanguageClass.d.ts +0 -36
- package/dist/utils/LanguageClass.example.d.ts +0 -0
- package/dist/utils/LanguageClass.example.js +0 -1
- package/dist/utils/LanguageClass.js +0 -50
- package/dist/utils/LanguageClass.test.d.ts +0 -0
- package/dist/utils/LanguageClass.test.js +0 -1
- package/dist/utils/PluginUtils.d.ts +0 -2
- package/dist/utils/PluginUtils.js +0 -23
- package/src/components/CRUDModal.tsx +0 -75
- package/src/components/MarkdownEditor.tsx +0 -144
- package/src/components/Spinner.tsx +0 -29
- package/src/components/ai/Assistant.tsx +0 -96
- package/src/components/ai/Avatar.tsx +0 -99
- package/src/components/ai/EmbeddedAssistent/AudioInputField.tsx +0 -73
- package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +0 -107
- package/src/components/ai/EmbeddedAssistent/TTS/MessageSender.ts +0 -96
- package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +0 -197
- package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +0 -129
- package/src/components/ai/utils.ts +0 -21
- package/src/components/audio/Playbutton.tsx +0 -126
- package/src/components/components/ContextMenu.tsx +0 -179
- package/src/components.ts +0 -11
- package/src/core/core.ts +0 -15
- package/src/hooks/I18nHooks.ts +0 -33
- package/src/hooks/UseChatHook.ts +0 -38
- package/src/plugin/ThemeSetter.ts +0 -23
- package/src/providers/PluginProvider.tsx +0 -209
- package/src/style.scss +0 -136
- package/src/utils/PluginUtils.ts +0 -22
- /package/dist/{plugin → controller}/AudioController.d.ts +0 -0
- /package/dist/{plugin → controller}/AudioController.js +0 -0
- /package/dist/{core/controller → controller}/SettingsController.js +0 -0
- /package/dist/{core/controller → controller}/SharedContentController.js +0 -0
- /package/dist/{plugin → controller}/TranslationController.d.ts +0 -0
- /package/dist/{plugin → controller}/TranslationController.js +0 -0
- /package/dist/{core/controller → controller}/VoiceController.js +0 -0
- /package/src/{plugin → controller}/AudioController.ts +0 -0
- /package/src/{plugin → controller}/TranslationController.ts +0 -0
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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<
|
|
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
|
-
|
|
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 '
|
|
3
|
-
import { Guild } from '../
|
|
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 '
|
|
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<
|
|
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;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './hooks/UseChatHook';
|
|
3
|
-
export * from './plugin/PluginController';
|
|
4
|
-
export * from './providers/PluginProvider';
|
|
1
|
+
export * from './plugin/CommunicationHandler';
|
|
5
2
|
export * from './cli/types/DatabaseTypes';
|
|
6
3
|
export * from './utils/difficultyConverter';
|
|
7
|
-
export * from './utils/PluginUtils';
|
|
8
4
|
export * from './fromRimori/PluginTypes';
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
5
|
+
export * from './fromRimori/EventBus';
|
|
6
|
+
export * from './plugin/RimoriClient';
|
|
7
|
+
export * from './plugin/StandaloneClient';
|
|
8
|
+
export { setupWorker } from './worker/WorkerSetup';
|
|
9
|
+
export { AudioController } from './controller/AudioController';
|
|
10
|
+
export { Translator } from './controller/TranslationController';
|
|
11
|
+
export type { TOptions } from 'i18next';
|
|
12
|
+
export type { SharedContent, SharedContentObjectRequest } from './controller/SharedContentController';
|
|
13
|
+
export type { Exercise } from './controller/ExerciseController';
|
|
14
|
+
export type { UserInfo, Language } from './controller/SettingsController';
|
|
15
|
+
export type { Message, ToolInvocation } from './controller/AIController';
|
|
16
|
+
export type { TriggerAction } from './controller/ExerciseController';
|
|
17
|
+
export type { MacroAccomplishmentPayload, MicroAccomplishmentPayload } from './controller/AccomplishmentController';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Re-export everything
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './hooks/UseChatHook';
|
|
4
|
-
export * from './plugin/PluginController';
|
|
5
|
-
export * from './providers/PluginProvider';
|
|
2
|
+
export * from './plugin/CommunicationHandler';
|
|
6
3
|
export * from './cli/types/DatabaseTypes';
|
|
7
4
|
export * from './utils/difficultyConverter';
|
|
8
|
-
export * from './utils/PluginUtils';
|
|
9
5
|
export * from './fromRimori/PluginTypes';
|
|
10
|
-
export
|
|
11
|
-
export
|
|
6
|
+
export * from './fromRimori/EventBus';
|
|
7
|
+
export * from './plugin/RimoriClient';
|
|
8
|
+
export * from './plugin/StandaloneClient';
|
|
9
|
+
export { setupWorker } from './worker/WorkerSetup';
|
|
10
|
+
export { AudioController } from './controller/AudioController';
|
|
11
|
+
export { Translator } from './controller/TranslationController';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
-
import { UserInfo } from '../
|
|
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
|
|
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,10 @@ export declare class PluginController {
|
|
|
31
28
|
private pluginId;
|
|
32
29
|
private isMessageChannelReady;
|
|
33
30
|
private pendingRequests;
|
|
34
|
-
|
|
31
|
+
constructor(pluginId: string, standalone: boolean);
|
|
35
32
|
private initMessageChannel;
|
|
36
33
|
private sendHello;
|
|
37
|
-
|
|
34
|
+
private sendFinishedInit;
|
|
38
35
|
getQueryParam(key: string): string | null;
|
|
39
36
|
getClient(): Promise<{
|
|
40
37
|
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
|
-
|
|
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;
|
|
@@ -75,8 +65,9 @@ export class PluginController {
|
|
|
75
65
|
};
|
|
76
66
|
// Set theme from MessageChannel query params
|
|
77
67
|
if (!worker) {
|
|
78
|
-
const theme = this.queryParams['rm_theme'];
|
|
79
|
-
setTheme(theme);
|
|
68
|
+
// const theme = this.queryParams['rm_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) => {
|
|
@@ -98,6 +89,9 @@ export class PluginController {
|
|
|
98
89
|
window.addEventListener('message', listener);
|
|
99
90
|
}
|
|
100
91
|
this.sendHello(worker);
|
|
92
|
+
EventBus.on('self.rimori.triggerInitFinished', () => {
|
|
93
|
+
this.sendFinishedInit(worker);
|
|
94
|
+
});
|
|
101
95
|
}
|
|
102
96
|
sendHello(isWorker = false) {
|
|
103
97
|
try {
|
|
@@ -113,21 +107,19 @@ export class PluginController {
|
|
|
113
107
|
console.error('[PluginController] Error sending hello:', e);
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
}
|
|
110
|
+
sendFinishedInit(isWorker = false) {
|
|
111
|
+
try {
|
|
112
|
+
const payload = { type: 'rimori:acknowledged', pluginId: this.pluginId };
|
|
113
|
+
if (isWorker) {
|
|
114
|
+
self.postMessage(payload);
|
|
128
115
|
}
|
|
129
|
-
|
|
130
|
-
|
|
116
|
+
else {
|
|
117
|
+
window.parent.postMessage(payload, '*');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
console.error('[PluginController] Error sending finished init:', e);
|
|
122
|
+
}
|
|
131
123
|
}
|
|
132
124
|
getQueryParam(key) {
|
|
133
125
|
return this.queryParams[key] || null;
|
|
@@ -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 '../
|
|
4
|
-
import { ObjectRequest } from '../
|
|
5
|
-
import { UserInfo } from '../
|
|
6
|
-
import { SharedContent, SharedContentFilter, SharedContentObjectRequest } from '../
|
|
7
|
-
import { CreateExerciseParams } from '../
|
|
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 '
|
|
11
|
-
import {
|
|
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: <ViewName extends string & keyof GenericSchema["Views"], View extends GenericSchema["Views"][ViewName]>(relation: string) => PostgrestQueryBuilder<GenericSchema, View, ViewName>;
|
|
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(
|
|
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<
|
|
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("../
|
|
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("../
|
|
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 {};
|