@rimori/client 1.3.0 → 1.4.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 (35) hide show
  1. package/.prettierignore +35 -0
  2. package/dist/cli/scripts/release/release-file-upload.js +1 -1
  3. package/dist/cli/types/DatabaseTypes.d.ts +2 -2
  4. package/dist/components/ai/Avatar.js +4 -2
  5. package/dist/components/ai/EmbeddedAssistent/TTS/Player.js +1 -1
  6. package/dist/core/controller/AIController.js +9 -7
  7. package/dist/core/controller/ExerciseController.d.ts +52 -0
  8. package/dist/core/controller/ExerciseController.js +73 -0
  9. package/dist/core/core.d.ts +1 -0
  10. package/dist/plugin/Logger.d.ts +5 -0
  11. package/dist/plugin/Logger.js +56 -6
  12. package/dist/plugin/RimoriClient.d.ts +28 -2
  13. package/dist/plugin/RimoriClient.js +30 -1
  14. package/eslint.config.js +53 -0
  15. package/package.json +9 -2
  16. package/prettier.config.js +8 -0
  17. package/src/cli/scripts/release/release-file-upload.ts +1 -1
  18. package/src/cli/types/DatabaseTypes.ts +17 -10
  19. package/src/components/ai/Avatar.tsx +3 -2
  20. package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +176 -176
  21. package/src/core/controller/AIController.ts +36 -34
  22. package/src/core/controller/ExerciseController.ts +105 -0
  23. package/src/core/core.ts +1 -0
  24. package/src/plugin/Logger.ts +59 -8
  25. package/src/plugin/RimoriClient.ts +40 -6
  26. package/dist/components/LoggerExample.d.ts +0 -6
  27. package/dist/components/LoggerExample.js +0 -79
  28. package/dist/core/controller/AudioController.d.ts +0 -0
  29. package/dist/core/controller/AudioController.js +0 -1
  30. package/dist/hooks/UseLogger.d.ts +0 -30
  31. package/dist/hooks/UseLogger.js +0 -122
  32. package/dist/plugin/LoggerExample.d.ts +0 -16
  33. package/dist/plugin/LoggerExample.js +0 -140
  34. package/dist/utils/audioFormats.d.ts +0 -26
  35. package/dist/utils/audioFormats.js +0 -67
@@ -1,140 +0,0 @@
1
- /**
2
- * Example of how to integrate the Logger into a plugin's main entry point.
3
- * This shows the complete setup process.
4
- */
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
- import { Logger } from './Logger';
15
- // Example plugin initialization with Logger integration
16
- export function initializePluginWithLogger() {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- // 1. Initialize the Logger singleton (call this as early as possible)
19
- const logger = Logger.getInstance(process.env.NODE_ENV === 'production');
20
- console.log('Logger initialized, console methods are now overridden globally');
21
- try {
22
- // 2. Initialize your plugin's core functionality
23
- console.info('Starting plugin initialization...');
24
- // 3. Get the Rimori client (this would be your actual client initialization)
25
- const rimoriClient = yield getRimoriClient(); // Your actual client setup
26
- // 4. Set the Rimori client in the Logger
27
- logger.setRimoriClient(rimoriClient);
28
- console.info('Plugin initialized successfully', {
29
- version: '1.0.0',
30
- environment: process.env.NODE_ENV,
31
- timestamp: new Date().toISOString()
32
- });
33
- // 5. Set up periodic log transmission (optional)
34
- setInterval(() => __awaiter(this, void 0, void 0, function* () {
35
- yield logger.sendRecentLogs(10); // Send last 10 logs every 5 minutes
36
- }), 5 * 60 * 1000);
37
- // 6. Set up error boundary for unhandled errors
38
- window.addEventListener('error', (event) => {
39
- console.error('Unhandled error caught by Logger', {
40
- message: event.message,
41
- filename: event.filename,
42
- lineno: event.lineno,
43
- colno: event.colno
44
- });
45
- });
46
- window.addEventListener('unhandledrejection', (event) => {
47
- console.error('Unhandled promise rejection caught by Logger', {
48
- reason: event.reason
49
- });
50
- });
51
- }
52
- catch (error) {
53
- // This console.error will be automatically captured with screenshot + mouse position
54
- console.error('Failed to initialize plugin', {
55
- error: error.message,
56
- stack: error.stack
57
- });
58
- // Send error logs immediately
59
- yield logger.sendLogsByLevel('error');
60
- }
61
- });
62
- }
63
- // Example of how to use console methods in your components
64
- export function exampleComponentUsage() {
65
- const handleUserAction = () => {
66
- // These console calls are automatically captured by the Logger
67
- console.log('User performed action', {
68
- action: 'button_click',
69
- timestamp: Date.now(),
70
- userId: 'user123'
71
- });
72
- };
73
- const handleApiError = (error) => {
74
- // This console.error will include screenshot + mouse position
75
- console.error('API request failed', {
76
- endpoint: '/api/users',
77
- error: error.message,
78
- statusCode: 500
79
- });
80
- };
81
- const handleDeprecatedFeature = () => {
82
- // This console.warn will include screenshot + mouse position
83
- console.warn('Deprecated feature used', {
84
- feature: 'old-api-endpoint',
85
- suggestedAlternative: 'new-api-endpoint'
86
- });
87
- };
88
- return {
89
- handleUserAction,
90
- handleApiError,
91
- handleDeprecatedFeature
92
- };
93
- }
94
- // Example of log management utilities
95
- export function exampleLogManagement() {
96
- const logger = Logger.getInstance(process.env.NODE_ENV === 'production');
97
- const sendLogsToRimori = () => __awaiter(this, void 0, void 0, function* () {
98
- yield logger.sendAllLogs();
99
- console.log('All logs sent to Rimori');
100
- });
101
- const getLogStatistics = () => {
102
- const stats = logger.getStats();
103
- console.log('Log statistics:', stats);
104
- return stats;
105
- };
106
- const exportLogsForDebugging = () => {
107
- const exportedLogs = logger.exportLogs();
108
- const blob = new Blob([exportedLogs], { type: 'application/json' });
109
- const url = URL.createObjectURL(blob);
110
- const a = document.createElement('a');
111
- a.href = url;
112
- a.download = `rimori-logs-${new Date().toISOString()}.json`;
113
- a.click();
114
- URL.revokeObjectURL(url);
115
- };
116
- const clearOldLogs = () => {
117
- logger.clearLogs();
118
- console.log('All logs cleared');
119
- };
120
- return {
121
- sendLogsToRimori,
122
- getLogStatistics,
123
- exportLogsForDebugging,
124
- clearOldLogs
125
- };
126
- }
127
- // Mock function for demonstration
128
- function getRimoriClient() {
129
- return __awaiter(this, void 0, void 0, function* () {
130
- // This would be your actual Rimori client initialization
131
- return {
132
- plugin: { pluginId: 'example-plugin' },
133
- event: {
134
- emit: (topic, data) => __awaiter(this, void 0, void 0, function* () {
135
- console.log('Sending to Rimori:', topic, data);
136
- })
137
- }
138
- };
139
- });
140
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * Maps audio MIME types to their corresponding file extensions
3
- * OpenAI supports: mp3, mp4, mpeg, mpga, m4a, wav, webm
4
- */
5
- export declare const AUDIO_MIME_TO_EXTENSION: Record<string, string>;
6
- /**
7
- * OpenAI supported audio formats for STT API
8
- */
9
- export declare const OPENAI_SUPPORTED_FORMATS: string[];
10
- /**
11
- * Determines the appropriate file extension for an audio MIME type
12
- * @param mimeType - The MIME type of the audio
13
- * @returns The file extension (without dot) or null if unsupported
14
- */
15
- export declare function getAudioFormatFromMimeType(mimeType: string): string | null;
16
- /**
17
- * Checks if an audio MIME type is supported by OpenAI
18
- * @param mimeType - The MIME type to check
19
- * @returns True if supported, false otherwise
20
- */
21
- export declare function isAudioFormatSupported(mimeType: string): boolean;
22
- /**
23
- * Gets a human-readable list of supported audio formats
24
- * @returns Formatted string of supported formats
25
- */
26
- export declare function getSupportedFormatsList(): string;
@@ -1,67 +0,0 @@
1
- /**
2
- * Maps audio MIME types to their corresponding file extensions
3
- * OpenAI supports: mp3, mp4, mpeg, mpga, m4a, wav, webm
4
- */
5
- export const AUDIO_MIME_TO_EXTENSION = {
6
- 'audio/mpeg': 'mp3',
7
- 'audio/mp3': 'mp3',
8
- 'audio/mp4': 'mp4',
9
- 'audio/m4a': 'm4a',
10
- 'audio/wav': 'wav',
11
- 'audio/wave': 'wav',
12
- 'audio/x-wav': 'wav',
13
- 'audio/webm': 'webm',
14
- 'audio/ogg': 'webm', // Convert ogg to webm for OpenAI compatibility
15
- 'audio/aac': 'm4a', // Convert aac to m4a for OpenAI compatibility
16
- 'audio/x-aac': 'm4a',
17
- 'audio/3gpp': 'mp4', // Convert 3gpp to mp4
18
- 'audio/3gpp2': 'mp4',
19
- 'audio/amr': 'mp4', // Convert amr to mp4
20
- 'audio/amr-wb': 'mp4',
21
- 'audio/flac': 'wav', // Convert flac to wav
22
- 'audio/x-flac': 'wav',
23
- 'audio/opus': 'webm', // Convert opus to webm
24
- 'audio/x-opus': 'webm',
25
- };
26
- /**
27
- * OpenAI supported audio formats for STT API
28
- */
29
- export const OPENAI_SUPPORTED_FORMATS = ['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm'];
30
- /**
31
- * Determines the appropriate file extension for an audio MIME type
32
- * @param mimeType - The MIME type of the audio
33
- * @returns The file extension (without dot) or null if unsupported
34
- */
35
- export function getAudioFormatFromMimeType(mimeType) {
36
- const normalizedMimeType = mimeType.toLowerCase();
37
- // Try to get format from MIME type mapping first
38
- let format = AUDIO_MIME_TO_EXTENSION[normalizedMimeType];
39
- // If no mapping found, try to extract from MIME type
40
- if (!format && normalizedMimeType.includes('audio/')) {
41
- format = normalizedMimeType.replace('audio/', '');
42
- }
43
- // Handle special cases
44
- if (format === 'mpeg') {
45
- format = 'mp3'; // OpenAI expects mp3, not mpeg
46
- }
47
- // Validate the format
48
- if (!format || !OPENAI_SUPPORTED_FORMATS.includes(format)) {
49
- return null;
50
- }
51
- return format;
52
- }
53
- /**
54
- * Checks if an audio MIME type is supported by OpenAI
55
- * @param mimeType - The MIME type to check
56
- * @returns True if supported, false otherwise
57
- */
58
- export function isAudioFormatSupported(mimeType) {
59
- return getAudioFormatFromMimeType(mimeType) !== null;
60
- }
61
- /**
62
- * Gets a human-readable list of supported audio formats
63
- * @returns Formatted string of supported formats
64
- */
65
- export function getSupportedFormatsList() {
66
- return OPENAI_SUPPORTED_FORMATS.join(', ');
67
- }