@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.
Files changed (136) hide show
  1. package/README.md +140 -1171
  2. package/dist/{core/controller → controller}/AIController.d.ts +1 -1
  3. package/dist/{core/controller → controller}/AIController.js +2 -2
  4. package/dist/{plugin/AccomplishmentHandler.d.ts → controller/AccomplishmentController.d.ts} +1 -1
  5. package/dist/{plugin/AccomplishmentHandler.js → controller/AccomplishmentController.js} +1 -1
  6. package/dist/{core/controller → controller}/ExerciseController.d.ts +8 -6
  7. package/dist/{core/controller → controller}/ExerciseController.js +10 -9
  8. package/dist/{core/controller → controller}/ObjectController.d.ts +1 -1
  9. package/dist/{core/controller → controller}/ObjectController.js +1 -1
  10. package/dist/{core/controller → controller}/SettingsController.d.ts +2 -2
  11. package/dist/{core/controller → controller}/SharedContentController.d.ts +1 -1
  12. package/dist/{core/controller → controller}/VoiceController.d.ts +1 -1
  13. package/dist/index.d.ts +14 -8
  14. package/dist/index.js +7 -7
  15. package/dist/plugin/{PluginController.d.ts → CommunicationHandler.d.ts} +4 -7
  16. package/dist/plugin/{PluginController.js → CommunicationHandler.js} +19 -27
  17. package/dist/plugin/RimoriClient.d.ts +67 -68
  18. package/dist/plugin/RimoriClient.js +101 -43
  19. package/dist/worker/WorkerSetup.js +3 -3
  20. package/example/docs/devdocs.md +1 -1
  21. package/package.json +5 -26
  22. package/src/{core/controller → controller}/AIController.ts +3 -3
  23. package/src/{plugin/AccomplishmentHandler.ts → controller/AccomplishmentController.ts} +1 -1
  24. package/src/{core/controller → controller}/ExerciseController.ts +14 -11
  25. package/src/{core/controller → controller}/ObjectController.ts +2 -2
  26. package/src/{core/controller → controller}/SettingsController.ts +2 -2
  27. package/src/{core/controller → controller}/SharedContentController.ts +1 -1
  28. package/src/{core/controller → controller}/VoiceController.ts +2 -2
  29. package/src/fromRimori/readme.md +1 -1
  30. package/src/index.ts +14 -8
  31. package/src/plugin/{PluginController.ts → CommunicationHandler.ts} +24 -36
  32. package/src/plugin/RimoriClient.ts +127 -118
  33. package/src/worker/WorkerSetup.ts +6 -4
  34. package/tsconfig.json +5 -2
  35. package/dist/cli/scripts/release/release-translation-upload.d.ts +0 -6
  36. package/dist/cli/scripts/release/release-translation-upload.js +0 -87
  37. package/dist/components/CRUDModal.d.ts +0 -17
  38. package/dist/components/CRUDModal.js +0 -24
  39. package/dist/components/MarkdownEditor.d.ts +0 -8
  40. package/dist/components/MarkdownEditor.js +0 -48
  41. package/dist/components/Spinner.d.ts +0 -8
  42. package/dist/components/Spinner.js +0 -4
  43. package/dist/components/ai/Assistant.d.ts +0 -9
  44. package/dist/components/ai/Assistant.js +0 -58
  45. package/dist/components/ai/Avatar.d.ts +0 -14
  46. package/dist/components/ai/Avatar.js +0 -59
  47. package/dist/components/ai/EmbeddedAssistent/AudioInputField.d.ts +0 -7
  48. package/dist/components/ai/EmbeddedAssistent/AudioInputField.js +0 -37
  49. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +0 -8
  50. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +0 -79
  51. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +0 -19
  52. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.js +0 -91
  53. package/dist/components/ai/EmbeddedAssistent/TTS/Player.d.ts +0 -27
  54. package/dist/components/ai/EmbeddedAssistent/TTS/Player.js +0 -185
  55. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +0 -11
  56. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +0 -95
  57. package/dist/components/ai/utils.d.ts +0 -6
  58. package/dist/components/ai/utils.js +0 -13
  59. package/dist/components/audio/Playbutton.d.ts +0 -15
  60. package/dist/components/audio/Playbutton.js +0 -80
  61. package/dist/components/components/ContextMenu.d.ts +0 -10
  62. package/dist/components/components/ContextMenu.js +0 -135
  63. package/dist/components.d.ts +0 -10
  64. package/dist/components.js +0 -11
  65. package/dist/core/controller/EnhancedUserInfo.d.ts +0 -0
  66. package/dist/core/controller/EnhancedUserInfo.js +0 -1
  67. package/dist/core/core.d.ts +0 -14
  68. package/dist/core/core.js +0 -7
  69. package/dist/hooks/I18nHooks.d.ts +0 -11
  70. package/dist/hooks/I18nHooks.js +0 -25
  71. package/dist/hooks/UseChatHook.d.ts +0 -10
  72. package/dist/hooks/UseChatHook.js +0 -29
  73. package/dist/i18n/I18nHooks.d.ts +0 -11
  74. package/dist/i18n/I18nHooks.js +0 -25
  75. package/dist/i18n/Translator.d.ts +0 -43
  76. package/dist/i18n/Translator.js +0 -118
  77. package/dist/i18n/config.d.ts +0 -7
  78. package/dist/i18n/config.js +0 -20
  79. package/dist/i18n/createI18nInstance.d.ts +0 -7
  80. package/dist/i18n/createI18nInstance.js +0 -31
  81. package/dist/i18n/hooks.d.ts +0 -11
  82. package/dist/i18n/hooks.js +0 -25
  83. package/dist/i18n/index.d.ts +0 -4
  84. package/dist/i18n/index.js +0 -4
  85. package/dist/i18n/types.d.ts +0 -7
  86. package/dist/i18n/types.js +0 -1
  87. package/dist/i18n/useRimoriI18n.d.ts +0 -11
  88. package/dist/i18n/useRimoriI18n.js +0 -41
  89. package/dist/plugin/ThemeSetter.d.ts +0 -2
  90. package/dist/plugin/ThemeSetter.js +0 -19
  91. package/dist/plugin/Translator.d.ts +0 -38
  92. package/dist/plugin/Translator.js +0 -101
  93. package/dist/providers/PluginProvider.d.ts +0 -12
  94. package/dist/providers/PluginProvider.js +0 -152
  95. package/dist/style.css +0 -110
  96. package/dist/style.css.map +0 -1
  97. package/dist/utils/Language.d.ts +0 -67
  98. package/dist/utils/Language.js +0 -69
  99. package/dist/utils/LanguageClass.d.ts +0 -36
  100. package/dist/utils/LanguageClass.example.d.ts +0 -0
  101. package/dist/utils/LanguageClass.example.js +0 -1
  102. package/dist/utils/LanguageClass.js +0 -50
  103. package/dist/utils/LanguageClass.test.d.ts +0 -0
  104. package/dist/utils/LanguageClass.test.js +0 -1
  105. package/dist/utils/PluginUtils.d.ts +0 -2
  106. package/dist/utils/PluginUtils.js +0 -23
  107. package/src/components/CRUDModal.tsx +0 -75
  108. package/src/components/MarkdownEditor.tsx +0 -144
  109. package/src/components/Spinner.tsx +0 -29
  110. package/src/components/ai/Assistant.tsx +0 -96
  111. package/src/components/ai/Avatar.tsx +0 -99
  112. package/src/components/ai/EmbeddedAssistent/AudioInputField.tsx +0 -73
  113. package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +0 -107
  114. package/src/components/ai/EmbeddedAssistent/TTS/MessageSender.ts +0 -96
  115. package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +0 -197
  116. package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +0 -129
  117. package/src/components/ai/utils.ts +0 -21
  118. package/src/components/audio/Playbutton.tsx +0 -126
  119. package/src/components/components/ContextMenu.tsx +0 -179
  120. package/src/components.ts +0 -11
  121. package/src/core/core.ts +0 -15
  122. package/src/hooks/I18nHooks.ts +0 -33
  123. package/src/hooks/UseChatHook.ts +0 -38
  124. package/src/plugin/ThemeSetter.ts +0 -23
  125. package/src/providers/PluginProvider.tsx +0 -209
  126. package/src/style.scss +0 -136
  127. package/src/utils/PluginUtils.ts +0 -22
  128. /package/dist/{plugin → controller}/AudioController.d.ts +0 -0
  129. /package/dist/{plugin → controller}/AudioController.js +0 -0
  130. /package/dist/{core/controller → controller}/SettingsController.js +0 -0
  131. /package/dist/{core/controller → controller}/SharedContentController.js +0 -0
  132. /package/dist/{plugin → controller}/TranslationController.d.ts +0 -0
  133. /package/dist/{plugin → controller}/TranslationController.js +0 -0
  134. /package/dist/{core/controller → controller}/VoiceController.js +0 -0
  135. /package/src/{plugin → controller}/AudioController.ts +0 -0
  136. /package/src/{plugin → controller}/TranslationController.ts +0 -0
@@ -1,95 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import { useRimori } from '../../../components';
12
- import { FaMicrophone, FaSpinner } from 'react-icons/fa6';
13
- import { AudioController } from '../../../plugin/AudioController';
14
- import { useState, useRef, forwardRef, useImperativeHandle, useEffect } from 'react';
15
- export const VoiceRecorder = forwardRef(({ onVoiceRecorded, iconSize, className, disabled, loading, onRecordingStatusChange, enablePushToTalk = false, }, ref) => {
16
- const [isRecording, setIsRecording] = useState(false);
17
- const [internalIsProcessing, setInternalIsProcessing] = useState(false);
18
- const audioControllerRef = useRef(null);
19
- const { ai, plugin } = useRimori();
20
- // Ref for latest onVoiceRecorded callback
21
- const onVoiceRecordedRef = useRef(onVoiceRecorded);
22
- useEffect(() => {
23
- onVoiceRecordedRef.current = onVoiceRecorded;
24
- }, [onVoiceRecorded]);
25
- const startRecording = () => __awaiter(void 0, void 0, void 0, function* () {
26
- try {
27
- if (!audioControllerRef.current) {
28
- audioControllerRef.current = new AudioController(plugin.pluginId);
29
- }
30
- yield audioControllerRef.current.startRecording();
31
- setIsRecording(true);
32
- onRecordingStatusChange(true);
33
- }
34
- catch (error) {
35
- console.error('Failed to start recording:', error);
36
- // Handle permission denied or other errors
37
- }
38
- });
39
- const stopRecording = () => __awaiter(void 0, void 0, void 0, function* () {
40
- try {
41
- if (audioControllerRef.current && isRecording) {
42
- const audioResult = yield audioControllerRef.current.stopRecording();
43
- // console.log("audioResult: ", audioResult);
44
- setInternalIsProcessing(true);
45
- // Play the recorded audio from the Blob
46
- // const blobUrl = URL.createObjectURL(audioResult.recording);
47
- // const audioRef = new Audio(blobUrl);
48
- // audioRef.onended = () => URL.revokeObjectURL(blobUrl);
49
- // audioRef.play().catch((e) => console.error('Playback error:', e));
50
- // console.log("audioBlob: ", audioResult.recording);
51
- const text = yield ai.getTextFromVoice(audioResult.recording);
52
- // console.log("stt result", text);
53
- // throw new Error("test");
54
- setInternalIsProcessing(false);
55
- onVoiceRecordedRef.current(text);
56
- }
57
- }
58
- catch (error) {
59
- console.error('Failed to stop recording:', error);
60
- }
61
- finally {
62
- setIsRecording(false);
63
- onRecordingStatusChange(false);
64
- }
65
- });
66
- useImperativeHandle(ref, () => ({
67
- startRecording,
68
- stopRecording,
69
- }));
70
- // push to talk feature
71
- const spacePressedRef = useRef(false);
72
- useEffect(() => {
73
- if (!enablePushToTalk)
74
- return;
75
- const handleKeyDown = (event) => __awaiter(void 0, void 0, void 0, function* () {
76
- if (event.code === 'Space' && !spacePressedRef.current) {
77
- spacePressedRef.current = true;
78
- yield startRecording();
79
- }
80
- });
81
- const handleKeyUp = (event) => {
82
- if (event.code === 'Space' && spacePressedRef.current) {
83
- spacePressedRef.current = false;
84
- stopRecording();
85
- }
86
- };
87
- window.addEventListener('keydown', handleKeyDown);
88
- window.addEventListener('keyup', handleKeyUp);
89
- return () => {
90
- window.removeEventListener('keydown', handleKeyDown);
91
- window.removeEventListener('keyup', handleKeyUp);
92
- };
93
- }, [enablePushToTalk]);
94
- return (_jsx("button", { className: 'flex flex-row justify-center items-center rounded-full mx-auto disabled:opacity-50 ' + className, onClick: isRecording ? stopRecording : startRecording, disabled: disabled || loading || internalIsProcessing, children: loading || internalIsProcessing ? (_jsx(FaSpinner, { className: "animate-spin" })) : (_jsx(FaMicrophone, { size: iconSize, className: isRecording ? 'text-red-600' : '' })) }));
95
- });
@@ -1,6 +0,0 @@
1
- export interface FirstMessages {
2
- instructions?: string;
3
- userMessage?: string;
4
- assistantMessage?: string;
5
- }
6
- export declare function getFirstMessages(instructions: FirstMessages): any[];
@@ -1,13 +0,0 @@
1
- export function getFirstMessages(instructions) {
2
- const messages = [];
3
- if (instructions.instructions) {
4
- messages.push({ id: '1', role: 'system', content: instructions.instructions });
5
- }
6
- if (instructions.userMessage) {
7
- messages.push({ id: '2', role: 'user', content: instructions.userMessage });
8
- }
9
- if (instructions.assistantMessage) {
10
- messages.push({ id: '3', role: 'assistant', content: instructions.assistantMessage });
11
- }
12
- return messages;
13
- }
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- type AudioPlayerProps = {
3
- text: string;
4
- voice?: string;
5
- language?: string;
6
- hide?: boolean;
7
- playOnMount?: boolean;
8
- initialSpeed?: number;
9
- enableSpeedAdjustment?: boolean;
10
- playListenerEvent?: string;
11
- };
12
- export declare const AudioPlayOptions: number[];
13
- export type AudioPlayOptionType = 0.8 | 0.9 | 1.0 | 1.1 | 1.2 | 1.5;
14
- export declare const AudioPlayer: React.FC<AudioPlayerProps>;
15
- export {};
@@ -1,80 +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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { useState, useEffect } from 'react';
12
- import { FaPlayCircle, FaStopCircle } from 'react-icons/fa';
13
- import { useRimori } from '../../providers/PluginProvider';
14
- import { Spinner } from '../Spinner';
15
- import { EventBus } from '../../fromRimori/EventBus';
16
- export const AudioPlayOptions = [0.8, 0.9, 1.0, 1.1, 1.2, 1.5];
17
- let isFetchingAudio = false;
18
- export const AudioPlayer = ({ text, voice, language, hide, playListenerEvent, initialSpeed = 1.0, playOnMount = false, enableSpeedAdjustment = false, }) => {
19
- const [audioUrl, setAudioUrl] = useState(null);
20
- const [speed, setSpeed] = useState(initialSpeed);
21
- const [isPlaying, setIsPlaying] = useState(false);
22
- const [isLoading, setIsLoading] = useState(false);
23
- const { ai } = useRimori();
24
- useEffect(() => {
25
- if (!playListenerEvent)
26
- return;
27
- EventBus.on(playListenerEvent, () => togglePlayback());
28
- }, [playListenerEvent]);
29
- useEffect(() => {
30
- audioUrl && setAudioUrl(null);
31
- return () => {
32
- audioUrl && URL.revokeObjectURL(audioUrl);
33
- };
34
- }, [text]);
35
- // Function to generate audio from text using API
36
- const generateAudio = () => __awaiter(void 0, void 0, void 0, function* () {
37
- setIsLoading(true);
38
- const blob = yield ai.getVoice(text, voice || (language ? 'aws_default' : 'openai_alloy'), 1, language);
39
- setAudioUrl(URL.createObjectURL(blob));
40
- setIsLoading(false);
41
- });
42
- // Effect to play audio when audioUrl changes and play state is true
43
- useEffect(() => {
44
- if (!audioUrl || !isPlaying)
45
- return;
46
- const audio = new Audio(audioUrl);
47
- audio.playbackRate = speed;
48
- audio
49
- .play()
50
- .then(() => {
51
- audio.onended = () => {
52
- setIsPlaying(false);
53
- isFetchingAudio = false;
54
- };
55
- })
56
- .catch((e) => {
57
- console.warn('Error playing audio:', e);
58
- setIsPlaying(false);
59
- });
60
- return () => {
61
- audio.pause();
62
- };
63
- }, [audioUrl, isPlaying, speed]);
64
- const togglePlayback = () => {
65
- if (!isPlaying && !audioUrl) {
66
- generateAudio().then(() => setIsPlaying(true));
67
- }
68
- else {
69
- setIsPlaying((prev) => !prev);
70
- }
71
- };
72
- useEffect(() => {
73
- if (!playOnMount || isFetchingAudio)
74
- return;
75
- isFetchingAudio = true;
76
- // console.log("playOnMount", playOnMount);
77
- togglePlayback();
78
- }, [playOnMount]);
79
- return (_jsx("div", { className: "group relative", children: _jsxs("div", { className: "flex flex-row items-end", children: [!hide && (_jsx("button", { className: "text-gray-500", onClick: togglePlayback, disabled: isLoading, children: isLoading ? _jsx(Spinner, {}) : isPlaying ? _jsx(FaStopCircle, { size: '25px' }) : _jsx(FaPlayCircle, { size: '25px' }) })), enableSpeedAdjustment && (_jsxs("div", { className: "ml-1 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-row text-sm text-gray-500", children: [_jsx("span", { className: "pr-1", children: "Speed: " }), _jsx("select", { value: speed, className: "appearance-none cursor-pointer pr-0 p-0 rounded shadow leading-tight focus:outline-none focus:bg-gray-800 focus:ring bg-transparent border-0", onChange: (e) => setSpeed(parseFloat(e.target.value)), disabled: isLoading, children: AudioPlayOptions.map((s) => (_jsx("option", { value: s, children: s }, s))) })] }))] }) }));
80
- };
@@ -1,10 +0,0 @@
1
- import { RimoriClient } from '../../plugin/RimoriClient';
2
- export interface Position {
3
- x: number;
4
- y: number;
5
- text?: string;
6
- }
7
- declare const ContextMenu: ({ client }: {
8
- client: RimoriClient;
9
- }) => import("react/jsx-runtime").JSX.Element | null;
10
- export default ContextMenu;
@@ -1,135 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useEffect, useRef } from 'react';
3
- import { EventBus } from '../../fromRimori/EventBus';
4
- const ContextMenu = ({ client }) => {
5
- const [isOpen, setIsOpen] = useState(false);
6
- const [actions, setActions] = useState([]);
7
- const [position, setPosition] = useState({ x: 0, y: 0 });
8
- const [openOnTextSelect, setOpenOnTextSelect] = useState(false);
9
- const [menuWidth, setMenuWidth] = useState(0);
10
- const menuRef = useRef(null);
11
- const isMobile = window.innerWidth < 768;
12
- /**
13
- * Calculates position for mobile context menu based on selected text bounds.
14
- * Centers the menu horizontally over the selected text and positions it 30px below the text's end.
15
- * @param selectedText - The currently selected text
16
- * @param menuWidth - The width of the menu to center properly
17
- * @returns Position object with x and y coordinates
18
- */
19
- const calculateMobilePosition = (selectedText, menuWidth = 0) => {
20
- const selection = window.getSelection();
21
- if (!selection || !selectedText) {
22
- return { x: 0, y: 0, text: selectedText };
23
- }
24
- const range = selection.getRangeAt(0);
25
- const rect = range.getBoundingClientRect();
26
- // Center horizontally over the selected text, accounting for menu width
27
- const centerX = rect.left + rect.width / 2 - menuWidth / 2;
28
- // Position 12px below where the text ends vertically
29
- const textEndY = rect.bottom + 12;
30
- return { x: centerX, y: textEndY, text: selectedText };
31
- };
32
- useEffect(() => {
33
- const actions = client.plugin
34
- .getPluginInfo()
35
- .installedPlugins.flatMap((p) => p.context_menu_actions)
36
- .filter(Boolean);
37
- setActions(actions);
38
- setOpenOnTextSelect(client.plugin.getUserInfo().context_menu_on_select);
39
- EventBus.on('global.contextMenu.createActions', ({ data }) => {
40
- setActions([...data.actions, ...actions]);
41
- });
42
- }, []);
43
- // Update menu width when menu is rendered
44
- useEffect(() => {
45
- if (isOpen && menuRef.current) {
46
- setMenuWidth(menuRef.current.offsetWidth);
47
- }
48
- }, [isOpen, actions]);
49
- useEffect(() => {
50
- // Track mouse position globally
51
- const handleMouseMove = (e) => {
52
- var _a;
53
- const selectedText = (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString().trim();
54
- if (isOpen && selectedText === position.text)
55
- return;
56
- if (isMobile && selectedText) {
57
- setPosition(calculateMobilePosition(selectedText, menuWidth));
58
- }
59
- else {
60
- setPosition({ x: e.clientX, y: e.clientY, text: selectedText });
61
- }
62
- };
63
- const handleMouseUp = (e) => {
64
- var _a, _b;
65
- const selectedText = (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString().trim();
66
- // Check if click is inside the context menu
67
- if (menuRef.current && menuRef.current.contains(e.target)) {
68
- // Don't close the menu if clicking inside
69
- return;
70
- }
71
- // Prevent context menu on textarea or text input selection
72
- const target = e.target;
73
- const isTextInput = target &&
74
- (target.tagName === 'TEXTAREA' || (target.tagName === 'INPUT' && target.type === 'text'));
75
- if (isTextInput) {
76
- setIsOpen(false);
77
- return;
78
- }
79
- if (e.button === 0 && isOpen) {
80
- setIsOpen(false);
81
- (_b = window.getSelection()) === null || _b === void 0 ? void 0 : _b.removeAllRanges();
82
- }
83
- else if (selectedText && (openOnTextSelect || e.button === 2)) {
84
- if (e.button === 2) {
85
- e.preventDefault();
86
- }
87
- if (isMobile) {
88
- setPosition(calculateMobilePosition(selectedText, menuWidth));
89
- }
90
- else {
91
- setPosition({ x: e.clientX, y: e.clientY, text: selectedText });
92
- }
93
- setIsOpen(true);
94
- }
95
- else {
96
- setIsOpen(false);
97
- }
98
- };
99
- // Add selectionchange listener to close menu if selection is cleared and update position for mobile
100
- const handleSelectionChange = () => {
101
- var _a;
102
- const selectedText = (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString().trim();
103
- if (!selectedText && isOpen) {
104
- setIsOpen(false);
105
- }
106
- else if (selectedText && isOpen && isMobile) {
107
- // Update position in real-time as text selection changes on mobile
108
- setPosition(calculateMobilePosition(selectedText, menuWidth));
109
- }
110
- };
111
- document.addEventListener('mouseup', handleMouseUp);
112
- window.addEventListener('mousemove', handleMouseMove);
113
- document.addEventListener('contextmenu', handleMouseUp);
114
- document.addEventListener('selectionchange', handleSelectionChange);
115
- return () => {
116
- document.removeEventListener('mouseup', handleMouseUp);
117
- window.removeEventListener('mousemove', handleMouseMove);
118
- document.removeEventListener('contextmenu', handleMouseUp);
119
- document.removeEventListener('selectionchange', handleSelectionChange);
120
- };
121
- }, [openOnTextSelect, isOpen, position.text]);
122
- if (!isOpen) {
123
- return null;
124
- }
125
- return (_jsx("div", { ref: menuRef, className: "fixed bg-gray-400 dark:bg-gray-700 shadow-lg border border-gray-400 rounded-md overflow-hidden dark:text-white z-50", style: { top: position.y, left: position.x }, children: actions.map((action, index) => (_jsx(MenuEntryItem, { icon: action.icon, text: action.text, onClick: () => {
126
- var _a;
127
- setIsOpen(false);
128
- (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
129
- client.event.emitSidebarAction(action.plugin_id, action.action_key, position.text);
130
- } }, index))) }));
131
- };
132
- function MenuEntryItem(props) {
133
- return (_jsxs("button", { onClick: props.onClick, className: "px-4 py-2 text-left hover:bg-gray-500 dark:hover:bg-gray-600 w-full flex flex-row", children: [_jsx("span", { className: "flex-grow", children: props.icon }), _jsx("span", { className: "flex-grow", children: props.text })] }));
134
- }
135
- export default ContextMenu;
@@ -1,10 +0,0 @@
1
- export * from './components/ai/Assistant';
2
- export * from './components/ai/Avatar';
3
- export * from './components/ai/EmbeddedAssistent/VoiceRecoder';
4
- export * from './components/audio/Playbutton';
5
- export * from './components/CRUDModal';
6
- export * from './components/MarkdownEditor';
7
- export * from './components/Spinner';
8
- export * from './hooks/UseChatHook';
9
- export * from './plugin/ThemeSetter';
10
- export * from './providers/PluginProvider';
@@ -1,11 +0,0 @@
1
- // React components and hooks exports
2
- export * from './components/ai/Assistant';
3
- export * from './components/ai/Avatar';
4
- export * from './components/ai/EmbeddedAssistent/VoiceRecoder';
5
- export * from './components/audio/Playbutton';
6
- export * from './components/CRUDModal';
7
- export * from './components/MarkdownEditor';
8
- export * from './components/Spinner';
9
- export * from './hooks/UseChatHook';
10
- export * from './plugin/ThemeSetter';
11
- export * from './providers/PluginProvider';
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,14 +0,0 @@
1
- export * from '../fromRimori/PluginTypes';
2
- export * from '../plugin/PluginController';
3
- export * from '../plugin/RimoriClient';
4
- export * from '../utils/difficultyConverter';
5
- export * from '../utils/PluginUtils';
6
- export * from '../worker/WorkerSetup';
7
- export { EventBusMessage } from '../fromRimori/EventBus';
8
- export { Buddy, UserInfo, Language } from './controller/SettingsController';
9
- export { SharedContent } from './controller/SharedContentController';
10
- export { Exercise, TriggerAction } from './controller/ExerciseController';
11
- export { Message, OnLLMResponse, ToolInvocation } from './controller/AIController';
12
- export { MacroAccomplishmentPayload, MicroAccomplishmentPayload } from '../plugin/AccomplishmentHandler';
13
- export { Tool } from '../fromRimori/PluginTypes';
14
- export { SharedContentObjectRequest } from './controller/SharedContentController';
package/dist/core/core.js DELETED
@@ -1,7 +0,0 @@
1
- // Core functionality exports
2
- export * from '../fromRimori/PluginTypes';
3
- export * from '../plugin/PluginController';
4
- export * from '../plugin/RimoriClient';
5
- export * from '../utils/difficultyConverter';
6
- export * from '../utils/PluginUtils';
7
- export * from '../worker/WorkerSetup';
@@ -1,11 +0,0 @@
1
- import { TOptions } from 'i18next';
2
- type TranslatorFn = (key: string, options?: TOptions) => string;
3
- /**
4
- * Custom useTranslation hook that provides a translation function and indicates readiness
5
- * @returns An object containing the translation function (`t`) and a boolean (`ready`) indicating if the translator is initialized.
6
- */
7
- export declare function useTranslation(): {
8
- t: TranslatorFn;
9
- ready: boolean;
10
- };
11
- export {};
@@ -1,25 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { useRimori } from '../providers/PluginProvider';
3
- /**
4
- * Custom useTranslation hook that provides a translation function and indicates readiness
5
- * @returns An object containing the translation function (`t`) and a boolean (`ready`) indicating if the translator is initialized.
6
- */
7
- export function useTranslation() {
8
- const { plugin } = useRimori();
9
- const [translatorInstance, setTranslatorInstance] = useState(null);
10
- useEffect(() => {
11
- void plugin.getTranslator().then(setTranslatorInstance);
12
- }, [plugin]);
13
- const safeT = (key, options) => {
14
- // return zero-width space if translator is not initialized to keep text space occupied
15
- if (!translatorInstance)
16
- return '\u200B'; // zero-width space
17
- const result = translatorInstance.t(key, options);
18
- if (!result) {
19
- console.error(`Translation key not found: ${key}`);
20
- return '\u200B'; // zero-width space
21
- }
22
- return result;
23
- };
24
- return { t: safeT, ready: translatorInstance !== null };
25
- }
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { Tool } from '../fromRimori/PluginTypes';
3
- import { Message } from '../core/controller/AIController';
4
- export declare function useChat(tools?: Tool[]): {
5
- messages: Message[];
6
- append: (appendMessages: Message[]) => void;
7
- isLoading: boolean;
8
- setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
9
- lastMessage: Message | undefined;
10
- };
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import { useRimori } from '../providers/PluginProvider';
3
- export function useChat(tools) {
4
- const [messages, setMessages] = React.useState([]);
5
- const [isLoading, setIsLoading] = React.useState(false);
6
- const { ai } = useRimori();
7
- const append = (appendMessages) => {
8
- const allMessages = [...messages, ...appendMessages];
9
- setMessages(allMessages);
10
- ai.getSteamedText(allMessages, (id, message, finished, toolInvocations) => {
11
- const lastMessage = messages[messages.length - 1];
12
- setIsLoading(!finished);
13
- if ((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.id) === id) {
14
- lastMessage.content = message;
15
- setMessages([...messages, lastMessage]);
16
- }
17
- else {
18
- setMessages([...allMessages, { id, role: 'assistant', content: message, toolCalls: toolInvocations }]);
19
- }
20
- }, tools);
21
- };
22
- return {
23
- messages,
24
- append,
25
- isLoading,
26
- setMessages,
27
- lastMessage: messages[messages.length - 1],
28
- };
29
- }
@@ -1,11 +0,0 @@
1
- import { TOptions } from 'i18next';
2
- type TranslatorFn = (key: string, options?: TOptions) => string;
3
- /**
4
- * Custom useTranslation hook that provides a translation function and indicates readiness
5
- * @returns An object containing the translation function (`t`) and a boolean (`ready`) indicating if the translator is initialized.
6
- */
7
- export declare function useTranslation(): {
8
- t: TranslatorFn;
9
- ready: boolean;
10
- };
11
- export {};
@@ -1,25 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { useRimori } from '../providers/PluginProvider';
3
- /**
4
- * Custom useTranslation hook that provides a translation function and indicates readiness
5
- * @returns An object containing the translation function (`t`) and a boolean (`ready`) indicating if the translator is initialized.
6
- */
7
- export function useTranslation() {
8
- const { plugin } = useRimori();
9
- const [translatorInstance, setTranslatorInstance] = useState(null);
10
- useEffect(() => {
11
- void plugin.getTranslator().then(setTranslatorInstance);
12
- }, [plugin]);
13
- const safeT = (key, options) => {
14
- if (!translatorInstance)
15
- return '\u200B'; // zero-width space
16
- try {
17
- return translatorInstance.t(key, options);
18
- }
19
- catch (error) {
20
- console.error('Translation error:', error);
21
- return key;
22
- }
23
- };
24
- return { t: safeT, ready: translatorInstance !== null };
25
- }
@@ -1,43 +0,0 @@
1
- import { ThirdPartyModule, TOptions } from 'i18next';
2
- /**
3
- * Translator class for handling internationalization
4
- */
5
- export declare class Translator {
6
- private currentLanguage;
7
- private isInitialized;
8
- private i18n;
9
- constructor(initialLanguage: string);
10
- /**
11
- * Initialize translator with user's language
12
- * @param userLanguage - Language code from user info
13
- */
14
- initialize(): Promise<void>;
15
- private getTranslationUrl;
16
- /**
17
- * Initialize i18n with or without React support
18
- * @param isReact - Whether to use React-specific features
19
- */
20
- private getI18n;
21
- usePlugin(plugin: ThirdPartyModule): void;
22
- /**
23
- * Fetch translations manually from the current domain
24
- * @param language - Language code to fetch
25
- * @returns Promise with translation data
26
- */
27
- private fetchTranslations;
28
- /**
29
- * Get translation for a key
30
- * @param key - Translation key
31
- * @param options - Translation options
32
- * @returns Translated string
33
- */
34
- t(key: string, options?: TOptions): string;
35
- /**
36
- * Get current language
37
- */
38
- getCurrentLanguage(): string;
39
- /**
40
- * Check if translator is initialized
41
- */
42
- isReady(): boolean;
43
- }