@rimori/react-client 0.1.0 → 0.1.1

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 (102) hide show
  1. package/dist/{react-client/src/components → components}/ContextMenu.js +1 -2
  2. package/dist/components/ai/Assistant.js +1 -1
  3. package/dist/components/ai/Avatar.d.ts +1 -1
  4. package/dist/components/ai/Avatar.js +1 -1
  5. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +1 -1
  6. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +2 -2
  7. package/dist/components/audio/Playbutton.js +10 -8
  8. package/dist/hooks/I18nHooks.d.ts +1 -1
  9. package/dist/hooks/UseChatHook.d.ts +2 -2
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.js +10 -0
  12. package/dist/providers/PluginProvider.d.ts +2 -1
  13. package/dist/providers/PluginProvider.js +9 -8
  14. package/dist/{react-client/src/utils → utils}/FullscreenUtils.js +2 -2
  15. package/package.json +1 -1
  16. package/src/components/ContextMenu.tsx +2 -2
  17. package/src/index.ts +11 -0
  18. package/src/plugin/ThemeSetter.ts +1 -1
  19. package/src/providers/PluginProvider.tsx +10 -9
  20. package/src/utils/FullscreenUtils.ts +5 -5
  21. package/tsconfig.json +6 -12
  22. package/dist/components/components/ContextMenu.d.ts +0 -10
  23. package/dist/components/components/ContextMenu.js +0 -135
  24. package/dist/react-client/src/components/MarkdownEditor.d.ts +0 -8
  25. package/dist/react-client/src/components/MarkdownEditor.js +0 -48
  26. package/dist/react-client/src/components/Spinner.d.ts +0 -8
  27. package/dist/react-client/src/components/Spinner.js +0 -4
  28. package/dist/react-client/src/components/ai/Assistant.d.ts +0 -9
  29. package/dist/react-client/src/components/ai/Assistant.js +0 -58
  30. package/dist/react-client/src/components/ai/Avatar.d.ts +0 -14
  31. package/dist/react-client/src/components/ai/Avatar.js +0 -59
  32. package/dist/react-client/src/components/ai/EmbeddedAssistent/AudioInputField.d.ts +0 -7
  33. package/dist/react-client/src/components/ai/EmbeddedAssistent/AudioInputField.js +0 -37
  34. package/dist/react-client/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +0 -8
  35. package/dist/react-client/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +0 -79
  36. package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +0 -19
  37. package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/MessageSender.js +0 -91
  38. package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/Player.d.ts +0 -27
  39. package/dist/react-client/src/components/ai/EmbeddedAssistent/TTS/Player.js +0 -185
  40. package/dist/react-client/src/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +0 -11
  41. package/dist/react-client/src/components/ai/EmbeddedAssistent/VoiceRecoder.js +0 -95
  42. package/dist/react-client/src/components/ai/utils.d.ts +0 -6
  43. package/dist/react-client/src/components/ai/utils.js +0 -13
  44. package/dist/react-client/src/components/audio/Playbutton.d.ts +0 -15
  45. package/dist/react-client/src/components/audio/Playbutton.js +0 -82
  46. package/dist/react-client/src/components/components/ContextMenu.d.ts +0 -10
  47. package/dist/react-client/src/components/components/ContextMenu.js +0 -135
  48. package/dist/react-client/src/hooks/I18nHooks.d.ts +0 -11
  49. package/dist/react-client/src/hooks/I18nHooks.js +0 -25
  50. package/dist/react-client/src/hooks/UseChatHook.d.ts +0 -10
  51. package/dist/react-client/src/hooks/UseChatHook.js +0 -29
  52. package/dist/react-client/src/plugin/ThemeSetter.d.ts +0 -2
  53. package/dist/react-client/src/plugin/ThemeSetter.js +0 -19
  54. package/dist/react-client/src/providers/PluginProvider.d.ts +0 -12
  55. package/dist/react-client/src/providers/PluginProvider.js +0 -142
  56. package/dist/react-client/src/utils/PluginUtils.d.ts +0 -2
  57. package/dist/react-client/src/utils/PluginUtils.js +0 -23
  58. package/dist/rimori-client/src/cli/types/DatabaseTypes.d.ts +0 -103
  59. package/dist/rimori-client/src/cli/types/DatabaseTypes.js +0 -2
  60. package/dist/rimori-client/src/controller/AIController.d.ts +0 -15
  61. package/dist/rimori-client/src/controller/AIController.js +0 -255
  62. package/dist/rimori-client/src/controller/AccomplishmentController.d.ts +0 -38
  63. package/dist/rimori-client/src/controller/AccomplishmentController.js +0 -112
  64. package/dist/rimori-client/src/controller/AudioController.d.ts +0 -37
  65. package/dist/rimori-client/src/controller/AudioController.js +0 -68
  66. package/dist/rimori-client/src/controller/ExerciseController.d.ts +0 -54
  67. package/dist/rimori-client/src/controller/ExerciseController.js +0 -74
  68. package/dist/rimori-client/src/controller/ObjectController.d.ts +0 -42
  69. package/dist/rimori-client/src/controller/ObjectController.js +0 -76
  70. package/dist/rimori-client/src/controller/SettingsController.d.ts +0 -79
  71. package/dist/rimori-client/src/controller/SettingsController.js +0 -118
  72. package/dist/rimori-client/src/controller/SharedContentController.d.ts +0 -106
  73. package/dist/rimori-client/src/controller/SharedContentController.js +0 -285
  74. package/dist/rimori-client/src/controller/TranslationController.d.ts +0 -38
  75. package/dist/rimori-client/src/controller/TranslationController.js +0 -106
  76. package/dist/rimori-client/src/controller/VoiceController.d.ts +0 -9
  77. package/dist/rimori-client/src/controller/VoiceController.js +0 -37
  78. package/dist/rimori-client/src/fromRimori/EventBus.d.ts +0 -101
  79. package/dist/rimori-client/src/fromRimori/EventBus.js +0 -263
  80. package/dist/rimori-client/src/fromRimori/PluginTypes.d.ts +0 -174
  81. package/dist/rimori-client/src/fromRimori/PluginTypes.js +0 -1
  82. package/dist/rimori-client/src/index.d.ts +0 -11
  83. package/dist/rimori-client/src/index.js +0 -10
  84. package/dist/rimori-client/src/plugin/CommunicationHandler.d.ts +0 -48
  85. package/dist/rimori-client/src/plugin/CommunicationHandler.js +0 -234
  86. package/dist/rimori-client/src/plugin/Logger.d.ts +0 -73
  87. package/dist/rimori-client/src/plugin/Logger.js +0 -308
  88. package/dist/rimori-client/src/plugin/RimoriClient.d.ts +0 -258
  89. package/dist/rimori-client/src/plugin/RimoriClient.js +0 -375
  90. package/dist/rimori-client/src/plugin/StandaloneClient.d.ts +0 -17
  91. package/dist/rimori-client/src/plugin/StandaloneClient.js +0 -115
  92. package/dist/rimori-client/src/utils/difficultyConverter.d.ts +0 -4
  93. package/dist/rimori-client/src/utils/difficultyConverter.js +0 -10
  94. package/dist/rimori-client/src/utils/endpoint.d.ts +0 -2
  95. package/dist/rimori-client/src/utils/endpoint.js +0 -2
  96. package/dist/utils/PluginUtils.d.ts +0 -2
  97. package/dist/utils/PluginUtils.js +0 -23
  98. package/index.ts +0 -6
  99. /package/dist/{react-client/src/components → components}/ContextMenu.d.ts +0 -0
  100. /package/dist/{react-client/plugin → plugin}/ThemeSetter.d.ts +0 -0
  101. /package/dist/{react-client/plugin → plugin}/ThemeSetter.js +0 -0
  102. /package/dist/{react-client/src/utils → utils}/FullscreenUtils.d.ts +0 -0
@@ -1,115 +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 { createClient } from '@supabase/supabase-js';
11
- import { EventBus } from '../fromRimori/EventBus';
12
- import { DEFAULT_ANON_KEY, DEFAULT_ENDPOINT } from '../utils/endpoint';
13
- export class StandaloneClient {
14
- constructor(config) {
15
- this.supabase = createClient(config.url, config.key);
16
- this.config = config;
17
- }
18
- static getInstance() {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- if (!StandaloneClient.instance) {
21
- const config = yield fetch('https://app.rimori.se/config.json')
22
- .then((res) => res.json())
23
- .catch((err) => {
24
- console.warn('Error fetching config.json, using default values', err);
25
- });
26
- StandaloneClient.instance = new StandaloneClient({
27
- url: (config === null || config === void 0 ? void 0 : config.SUPABASE_URL) || DEFAULT_ENDPOINT,
28
- key: (config === null || config === void 0 ? void 0 : config.SUPABASE_ANON_KEY) || DEFAULT_ANON_KEY,
29
- backendUrl: (config === null || config === void 0 ? void 0 : config.BACKEND_URL) || 'https://api.rimori.se',
30
- });
31
- }
32
- return StandaloneClient.instance;
33
- });
34
- }
35
- getClient() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- return this.supabase;
38
- });
39
- }
40
- needsLogin() {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- const { error } = yield this.supabase.auth.getUser();
43
- return error !== null;
44
- });
45
- }
46
- login(email, password) {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- const { error } = yield this.supabase.auth.signInWithPassword({ email, password });
49
- if (error) {
50
- console.error('Login failed:', error);
51
- return false;
52
- }
53
- console.log('Successfully logged in');
54
- return true;
55
- });
56
- }
57
- static initListeners(pluginId) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- console.warn('The plugin seams to not be running inside the Rimori platform. Switching to development standalone mode.');
60
- // console.log("event that needs to be handled", event);
61
- const { supabase, config } = yield StandaloneClient.getInstance();
62
- // EventBus.on("*", async (event) => {
63
- EventBus.respond('standalone', 'global.supabase.requestAccess', () => __awaiter(this, void 0, void 0, function* () {
64
- var _a;
65
- const session = yield supabase.auth.getSession();
66
- console.log('session', session);
67
- // Call the NestJS backend endpoint instead of the Supabase edge function
68
- // get current guild id if any
69
- let guildId = null;
70
- try {
71
- const { data: { user }, } = yield supabase.auth.getUser();
72
- if (user) {
73
- const { data: profile } = yield supabase
74
- .from('profiles')
75
- .select('current_guild_id')
76
- .eq('user_id', user.id)
77
- .maybeSingle();
78
- guildId = (profile === null || profile === void 0 ? void 0 : profile.current_guild_id) || null;
79
- }
80
- }
81
- catch (_) {
82
- guildId = null;
83
- }
84
- const response = yield fetch(`${config.backendUrl}/plugin/token`, {
85
- method: 'POST',
86
- headers: {
87
- 'Content-Type': 'application/json',
88
- Authorization: `Bearer ${(_a = session.data.session) === null || _a === void 0 ? void 0 : _a.access_token}`,
89
- },
90
- body: JSON.stringify({
91
- pluginId: pluginId,
92
- guildId: guildId,
93
- }),
94
- });
95
- if (!response.ok) {
96
- const errorText = yield response.text();
97
- throw new Error(`Failed to get plugin token. ${response.status}: ${errorText}`);
98
- }
99
- const data = yield response.json();
100
- return {
101
- token: data.token,
102
- pluginId: pluginId,
103
- url: config.url,
104
- key: config.key,
105
- backendUrl: config.backendUrl,
106
- tablePrefix: pluginId,
107
- expiration: new Date(Date.now() + 1000 * 60 * 60 * 1.5), // 1.5 hours
108
- };
109
- }));
110
- EventBus.on('*', (event) => __awaiter(this, void 0, void 0, function* () {
111
- console.log('[standalone] would send event to parent', event);
112
- }), ['standalone']);
113
- });
114
- }
115
- }
@@ -1,4 +0,0 @@
1
- export type LanguageLevel = 'Pre-A1' | 'A1' | 'A2' | 'B1' | 'B2' | 'C1' | 'C2' | 'Post-C2';
2
- export declare function getDifficultyLevel(difficulty: LanguageLevel): number;
3
- export declare function getDifficultyLabel(difficulty: number): LanguageLevel;
4
- export declare function getNeighborDifficultyLevel(difficulty: LanguageLevel, difficultyAdjustment: number): LanguageLevel;
@@ -1,10 +0,0 @@
1
- const codes = ['Pre-A1', 'A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'Post-C2'];
2
- export function getDifficultyLevel(difficulty) {
3
- return codes.indexOf(difficulty) + 1;
4
- }
5
- export function getDifficultyLabel(difficulty) {
6
- return codes[difficulty];
7
- }
8
- export function getNeighborDifficultyLevel(difficulty, difficultyAdjustment) {
9
- return getDifficultyLabel(getDifficultyLevel(difficulty) + difficultyAdjustment - 1);
10
- }
@@ -1,2 +0,0 @@
1
- export declare const DEFAULT_ENDPOINT = "https://pheptqdoqsdnadgoihvr.supabase.co";
2
- export declare const DEFAULT_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBoZXB0cWRvcXNkbmFkZ29paHZyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzE2OTY2ODcsImV4cCI6MjA0NzI3MjY4N30.4GPFAXTF8685FaXISdAPNCIM-H3RGLo8GbyhQpu1mP0";
@@ -1,2 +0,0 @@
1
- export const DEFAULT_ENDPOINT = 'https://pheptqdoqsdnadgoihvr.supabase.co';
2
- export const DEFAULT_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBoZXB0cWRvcXNkbmFkZ29paHZyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzE2OTY2ODcsImV4cCI6MjA0NzI3MjY4N30.4GPFAXTF8685FaXISdAPNCIM-H3RGLo8GbyhQpu1mP0';
@@ -1,2 +0,0 @@
1
- export declare function isFullscreen(): boolean;
2
- export declare function triggerFullscreen(onStateChange: (isFullscreen: boolean) => void, selector?: string): void;
@@ -1,23 +0,0 @@
1
- export function isFullscreen() {
2
- return !!document.fullscreenElement;
3
- }
4
- export function triggerFullscreen(onStateChange, selector) {
5
- document.addEventListener('fullscreenchange', () => {
6
- onStateChange(isFullscreen());
7
- });
8
- try {
9
- const ref = document.querySelector(selector || '#root');
10
- if (!isFullscreen()) {
11
- // @ts-ignore
12
- ref.requestFullscreen() || ref.webkitRequestFullscreen();
13
- }
14
- else {
15
- // @ts-ignore
16
- document.exitFullscreen() || document.webkitExitFullscreen();
17
- }
18
- }
19
- catch (error) {
20
- console.error('Failed to enter fullscreen', error.message);
21
- }
22
- onStateChange(isFullscreen());
23
- }
package/index.ts DELETED
@@ -1,6 +0,0 @@
1
- // Re-export everything
2
- export * from './src/hooks/UseChatHook';
3
- export * from './src/providers/PluginProvider';
4
- export * from './src/utils/FullscreenUtils';
5
- export { FirstMessages } from './src/components/ai/utils';
6
- export { useTranslation } from './src/hooks/I18nHooks';