@rimori/react-client 0.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/.prettierignore +35 -0
- package/LICENSE +201 -0
- package/README copy.md +1216 -0
- package/README.md +1 -0
- package/dist/components/MarkdownEditor.d.ts +8 -0
- package/dist/components/MarkdownEditor.js +48 -0
- package/dist/components/Spinner.d.ts +8 -0
- package/dist/components/Spinner.js +4 -0
- package/dist/components/ai/Assistant.d.ts +9 -0
- package/dist/components/ai/Assistant.js +58 -0
- package/dist/components/ai/Avatar.d.ts +14 -0
- package/dist/components/ai/Avatar.js +59 -0
- package/dist/components/ai/EmbeddedAssistent/AudioInputField.d.ts +7 -0
- package/dist/components/ai/EmbeddedAssistent/AudioInputField.js +37 -0
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +8 -0
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +79 -0
- package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +19 -0
- package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.js +91 -0
- package/dist/components/ai/EmbeddedAssistent/TTS/Player.d.ts +27 -0
- package/dist/components/ai/EmbeddedAssistent/TTS/Player.js +185 -0
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +11 -0
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +95 -0
- package/dist/components/ai/utils.d.ts +6 -0
- package/dist/components/ai/utils.js +13 -0
- package/dist/components/audio/Playbutton.d.ts +15 -0
- package/dist/components/audio/Playbutton.js +80 -0
- package/dist/components/components/ContextMenu.d.ts +10 -0
- package/dist/components/components/ContextMenu.js +135 -0
- package/dist/hooks/I18nHooks.d.ts +11 -0
- package/dist/hooks/I18nHooks.js +25 -0
- package/dist/hooks/UseChatHook.d.ts +10 -0
- package/dist/hooks/UseChatHook.js +29 -0
- package/dist/providers/PluginProvider.d.ts +11 -0
- package/dist/providers/PluginProvider.js +142 -0
- package/dist/react-client/plugin/ThemeSetter.d.ts +2 -0
- package/dist/react-client/plugin/ThemeSetter.js +19 -0
- package/dist/react-client/src/components/ContextMenu.d.ts +10 -0
- package/dist/react-client/src/components/ContextMenu.js +135 -0
- package/dist/react-client/src/components/MarkdownEditor.d.ts +8 -0
- package/dist/react-client/src/components/MarkdownEditor.js +48 -0
- package/dist/react-client/src/components/Spinner.d.ts +8 -0
- package/dist/react-client/src/components/Spinner.js +4 -0
- package/dist/react-client/src/components/ai/Assistant.d.ts +9 -0
- package/dist/react-client/src/components/ai/Assistant.js +58 -0
- package/dist/react-client/src/components/ai/Avatar.d.ts +14 -0
- package/dist/react-client/src/components/ai/Avatar.js +59 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/AudioInputField.d.ts +7 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/AudioInputField.js +37 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +8 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +79 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +19 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/MessageSender.js +91 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/Player.d.ts +27 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/Player.js +185 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +11 -0
- package/dist/react-client/src/components/ai/EmbeddedAssistent/VoiceRecoder.js +95 -0
- package/dist/react-client/src/components/ai/utils.d.ts +6 -0
- package/dist/react-client/src/components/ai/utils.js +13 -0
- package/dist/react-client/src/components/audio/Playbutton.d.ts +15 -0
- package/dist/react-client/src/components/audio/Playbutton.js +82 -0
- package/dist/react-client/src/components/components/ContextMenu.d.ts +10 -0
- package/dist/react-client/src/components/components/ContextMenu.js +135 -0
- package/dist/react-client/src/hooks/I18nHooks.d.ts +11 -0
- package/dist/react-client/src/hooks/I18nHooks.js +25 -0
- package/dist/react-client/src/hooks/UseChatHook.d.ts +10 -0
- package/dist/react-client/src/hooks/UseChatHook.js +29 -0
- package/dist/react-client/src/plugin/ThemeSetter.d.ts +2 -0
- package/dist/react-client/src/plugin/ThemeSetter.js +19 -0
- package/dist/react-client/src/providers/PluginProvider.d.ts +12 -0
- package/dist/react-client/src/providers/PluginProvider.js +142 -0
- package/dist/react-client/src/utils/FullscreenUtils.d.ts +2 -0
- package/dist/react-client/src/utils/FullscreenUtils.js +23 -0
- package/dist/react-client/src/utils/PluginUtils.d.ts +2 -0
- package/dist/react-client/src/utils/PluginUtils.js +23 -0
- package/dist/rimori-client/src/cli/types/DatabaseTypes.d.ts +103 -0
- package/dist/rimori-client/src/cli/types/DatabaseTypes.js +2 -0
- package/dist/rimori-client/src/controller/AIController.d.ts +15 -0
- package/dist/rimori-client/src/controller/AIController.js +255 -0
- package/dist/rimori-client/src/controller/AccomplishmentController.d.ts +38 -0
- package/dist/rimori-client/src/controller/AccomplishmentController.js +112 -0
- package/dist/rimori-client/src/controller/AudioController.d.ts +37 -0
- package/dist/rimori-client/src/controller/AudioController.js +68 -0
- package/dist/rimori-client/src/controller/ExerciseController.d.ts +54 -0
- package/dist/rimori-client/src/controller/ExerciseController.js +74 -0
- package/dist/rimori-client/src/controller/ObjectController.d.ts +42 -0
- package/dist/rimori-client/src/controller/ObjectController.js +76 -0
- package/dist/rimori-client/src/controller/SettingsController.d.ts +79 -0
- package/dist/rimori-client/src/controller/SettingsController.js +118 -0
- package/dist/rimori-client/src/controller/SharedContentController.d.ts +106 -0
- package/dist/rimori-client/src/controller/SharedContentController.js +285 -0
- package/dist/rimori-client/src/controller/TranslationController.d.ts +38 -0
- package/dist/rimori-client/src/controller/TranslationController.js +106 -0
- package/dist/rimori-client/src/controller/VoiceController.d.ts +9 -0
- package/dist/rimori-client/src/controller/VoiceController.js +37 -0
- package/dist/rimori-client/src/fromRimori/EventBus.d.ts +101 -0
- package/dist/rimori-client/src/fromRimori/EventBus.js +263 -0
- package/dist/rimori-client/src/fromRimori/PluginTypes.d.ts +174 -0
- package/dist/rimori-client/src/fromRimori/PluginTypes.js +1 -0
- package/dist/rimori-client/src/index.d.ts +11 -0
- package/dist/rimori-client/src/index.js +10 -0
- package/dist/rimori-client/src/plugin/CommunicationHandler.d.ts +48 -0
- package/dist/rimori-client/src/plugin/CommunicationHandler.js +234 -0
- package/dist/rimori-client/src/plugin/Logger.d.ts +73 -0
- package/dist/rimori-client/src/plugin/Logger.js +308 -0
- package/dist/rimori-client/src/plugin/RimoriClient.d.ts +258 -0
- package/dist/rimori-client/src/plugin/RimoriClient.js +375 -0
- package/dist/rimori-client/src/plugin/StandaloneClient.d.ts +17 -0
- package/dist/rimori-client/src/plugin/StandaloneClient.js +115 -0
- package/dist/rimori-client/src/utils/difficultyConverter.d.ts +4 -0
- package/dist/rimori-client/src/utils/difficultyConverter.js +10 -0
- package/dist/rimori-client/src/utils/endpoint.d.ts +2 -0
- package/dist/rimori-client/src/utils/endpoint.js +2 -0
- package/dist/style.css +110 -0
- package/dist/style.css.map +1 -0
- package/dist/utils/PluginUtils.d.ts +2 -0
- package/dist/utils/PluginUtils.js +23 -0
- package/eslint.config.js +53 -0
- package/index.ts +6 -0
- package/package.json +47 -0
- package/prettier.config.js +8 -0
- package/src/components/ContextMenu.tsx +177 -0
- package/src/components/MarkdownEditor.tsx +144 -0
- package/src/components/Spinner.tsx +29 -0
- package/src/components/ai/Assistant.tsx +96 -0
- package/src/components/ai/Avatar.tsx +99 -0
- package/src/components/ai/EmbeddedAssistent/AudioInputField.tsx +73 -0
- package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +107 -0
- package/src/components/ai/EmbeddedAssistent/TTS/MessageSender.ts +96 -0
- package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +197 -0
- package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +129 -0
- package/src/components/ai/utils.ts +21 -0
- package/src/components/audio/Playbutton.tsx +126 -0
- package/src/hooks/I18nHooks.ts +33 -0
- package/src/hooks/UseChatHook.ts +38 -0
- package/src/plugin/ThemeSetter.ts +23 -0
- package/src/providers/PluginProvider.tsx +197 -0
- package/src/style.scss +136 -0
- package/src/utils/FullscreenUtils.ts +22 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
export class ChunkedAudioPlayer {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.chunkQueue = [];
|
|
13
|
+
this.isPlaying = false;
|
|
14
|
+
this.shouldMonitorLoudness = true;
|
|
15
|
+
this.isMonitoring = false;
|
|
16
|
+
this.handle = 0;
|
|
17
|
+
this.volume = 1.0;
|
|
18
|
+
this.loudnessCallback = () => { };
|
|
19
|
+
this.currentIndex = 0;
|
|
20
|
+
this.startedPlaying = false;
|
|
21
|
+
this.onEndOfSpeech = () => { };
|
|
22
|
+
this.init();
|
|
23
|
+
}
|
|
24
|
+
init() {
|
|
25
|
+
this.audioContext = new AudioContext();
|
|
26
|
+
this.analyser = this.audioContext.createAnalyser();
|
|
27
|
+
this.analyser.fftSize = 256; // Set the FFT size (smaller values provide faster updates, larger ones give better resolution)
|
|
28
|
+
const bufferLength = this.analyser.frequencyBinCount;
|
|
29
|
+
this.dataArray = new Uint8Array(bufferLength); // Array to hold frequency data
|
|
30
|
+
}
|
|
31
|
+
setOnLoudnessChange(callback) {
|
|
32
|
+
this.loudnessCallback = callback;
|
|
33
|
+
}
|
|
34
|
+
setVolume(volume) {
|
|
35
|
+
this.volume = volume;
|
|
36
|
+
}
|
|
37
|
+
addChunk(chunk, position) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
console.log('Adding chunk', position, chunk);
|
|
40
|
+
this.chunkQueue[position] = chunk;
|
|
41
|
+
// console.log("received chunk", {
|
|
42
|
+
// chunkQueue: this.chunkQueue.length,
|
|
43
|
+
// isPlaying: this.isPlaying,
|
|
44
|
+
// })
|
|
45
|
+
if (position === 0 && !this.startedPlaying) {
|
|
46
|
+
this.startedPlaying = true;
|
|
47
|
+
this.playChunks();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
playChunks() {
|
|
52
|
+
// console.log({ isPlaying: this.isPlaying });
|
|
53
|
+
if (this.isPlaying)
|
|
54
|
+
return;
|
|
55
|
+
if (!this.chunkQueue[this.currentIndex]) {
|
|
56
|
+
// wait until the correct chunk arrives
|
|
57
|
+
setTimeout(() => this.playChunks(), 10);
|
|
58
|
+
}
|
|
59
|
+
this.isPlaying = true;
|
|
60
|
+
this.playChunk(this.chunkQueue[this.currentIndex]).then(() => {
|
|
61
|
+
this.isPlaying = false;
|
|
62
|
+
this.currentIndex++;
|
|
63
|
+
if (this.chunkQueue[this.currentIndex]) {
|
|
64
|
+
this.shouldMonitorLoudness = true;
|
|
65
|
+
this.playChunks();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// console.log('Playback finished', { currentIndex: this.currentIndex, chunkQueue: this.chunkQueue });
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
// console.log('Check again if really playback finished', { currentIndex: this.currentIndex, chunkQueue: this.chunkQueue });
|
|
71
|
+
if (this.chunkQueue.length > this.currentIndex) {
|
|
72
|
+
this.playChunks();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
this.startedPlaying = false;
|
|
76
|
+
this.shouldMonitorLoudness = false;
|
|
77
|
+
}
|
|
78
|
+
}, 1000);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
stopPlayback() {
|
|
83
|
+
// console.log('Stopping playback');
|
|
84
|
+
// Implement logic to stop the current playback
|
|
85
|
+
this.isPlaying = false;
|
|
86
|
+
this.chunkQueue = [];
|
|
87
|
+
this.startedPlaying = false;
|
|
88
|
+
this.shouldMonitorLoudness = false;
|
|
89
|
+
cancelAnimationFrame(this.handle);
|
|
90
|
+
}
|
|
91
|
+
playChunk(chunk) {
|
|
92
|
+
// console.log({queue: this.chunkQueue})
|
|
93
|
+
if (!chunk) {
|
|
94
|
+
return Promise.resolve();
|
|
95
|
+
}
|
|
96
|
+
// console.log('Playing chunk', chunk);
|
|
97
|
+
return new Promise((resolve) => {
|
|
98
|
+
const source = this.audioContext.createBufferSource();
|
|
99
|
+
this.audioContext.decodeAudioData(chunk.slice(0)).then((audioBuffer) => {
|
|
100
|
+
source.buffer = audioBuffer;
|
|
101
|
+
// Create a GainNode for volume control
|
|
102
|
+
const gainNode = this.audioContext.createGain();
|
|
103
|
+
gainNode.gain.value = this.volume;
|
|
104
|
+
// Connect the source to the GainNode, then to the analyser node, then to the destination (speakers)
|
|
105
|
+
source.connect(gainNode);
|
|
106
|
+
gainNode.connect(this.analyser);
|
|
107
|
+
this.analyser.connect(this.audioContext.destination);
|
|
108
|
+
source.start(0);
|
|
109
|
+
// console.log('Playing chunk', this.currentIndex);
|
|
110
|
+
gainNode.gain.value = this.volume;
|
|
111
|
+
source.onended = () => {
|
|
112
|
+
// console.log('Chunk ended');
|
|
113
|
+
resolve();
|
|
114
|
+
};
|
|
115
|
+
// Start monitoring loudness only once
|
|
116
|
+
if (!this.isMonitoring) {
|
|
117
|
+
this.isMonitoring = true;
|
|
118
|
+
this.shouldMonitorLoudness = true;
|
|
119
|
+
this.monitorLoudness();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
playAgain() {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
console.log('Playing again');
|
|
127
|
+
if (this.chunkQueue.length > 0 && !this.isPlaying) {
|
|
128
|
+
this.playChunks();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
monitorLoudness() {
|
|
133
|
+
// Stop monitoring when the flag is false
|
|
134
|
+
if (!this.shouldMonitorLoudness) {
|
|
135
|
+
// console.log('Loudness monitoring stopped.');
|
|
136
|
+
cancelAnimationFrame(this.handle);
|
|
137
|
+
this.loudnessCallback(0);
|
|
138
|
+
this.onEndOfSpeech();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// Get the time domain data from the analyser (this is a snapshot of the waveform)
|
|
142
|
+
this.analyser.getByteTimeDomainData(this.dataArray);
|
|
143
|
+
// Calculate the RMS (root mean square) of the waveform values to get the perceived loudness
|
|
144
|
+
let sum = 0;
|
|
145
|
+
for (let i = 0; i < this.dataArray.length; i++) {
|
|
146
|
+
const value = this.dataArray[i] / 128.0 - 1.0; // Normalize between -1 and 1
|
|
147
|
+
sum += value * value;
|
|
148
|
+
}
|
|
149
|
+
const rms = Math.sqrt(sum / this.dataArray.length);
|
|
150
|
+
// Handle the case where RMS is 0 to avoid log10(0)
|
|
151
|
+
if (rms === 0) {
|
|
152
|
+
// console.log('Current loudness: Silent');
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
let loudnessInDb = 20 * Math.log10(rms); // Convert to dB
|
|
156
|
+
// console.log('Current loudness:' + loudnessInDb);
|
|
157
|
+
const minDb = -57;
|
|
158
|
+
const maxDb = -15;
|
|
159
|
+
if (loudnessInDb < minDb) {
|
|
160
|
+
loudnessInDb = minDb;
|
|
161
|
+
}
|
|
162
|
+
if (loudnessInDb > maxDb) {
|
|
163
|
+
loudnessInDb = maxDb;
|
|
164
|
+
}
|
|
165
|
+
const loudnessScale = ((loudnessInDb - minDb) / (maxDb - minDb)) * 100;
|
|
166
|
+
// console.log("root:corrent loudness", loudnessScale);
|
|
167
|
+
this.loudnessCallback(loudnessScale);
|
|
168
|
+
}
|
|
169
|
+
// Call this method again at regular intervals if you want continuous loudness monitoring
|
|
170
|
+
this.handle = requestAnimationFrame(() => this.monitorLoudness());
|
|
171
|
+
}
|
|
172
|
+
reset() {
|
|
173
|
+
// console.log('Resetting player');
|
|
174
|
+
this.stopPlayback();
|
|
175
|
+
this.currentIndex = 0;
|
|
176
|
+
this.shouldMonitorLoudness = true;
|
|
177
|
+
//reset to the beginning when the class gets initialized
|
|
178
|
+
this.isMonitoring = false;
|
|
179
|
+
this.isPlaying = false;
|
|
180
|
+
this.init();
|
|
181
|
+
}
|
|
182
|
+
setOnEndOfSpeech(callback) {
|
|
183
|
+
this.onEndOfSpeech = callback;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
iconSize?: string;
|
|
3
|
+
className?: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
enablePushToTalk?: boolean;
|
|
7
|
+
onRecordingStatusChange: (running: boolean) => void;
|
|
8
|
+
onVoiceRecorded: (message: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const VoiceRecorder: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<unknown>>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,135 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
interface PluginProviderProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
pluginId: string;
|
|
5
|
+
settings?: {
|
|
6
|
+
disableContextMenu?: boolean;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare const PluginProvider: React.FC<PluginProviderProps>;
|
|
10
|
+
export declare const useRimori: () => any;
|
|
11
|
+
export {};
|