@rimori/client 1.1.10 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +189 -63
- package/dist/cli/scripts/init/dev-registration.d.ts +35 -0
- package/dist/cli/scripts/init/dev-registration.js +174 -0
- package/dist/cli/scripts/init/env-setup.d.ts +9 -0
- package/dist/cli/scripts/init/env-setup.js +43 -0
- package/dist/cli/scripts/init/file-operations.d.ts +4 -0
- package/dist/cli/scripts/init/file-operations.js +51 -0
- package/dist/cli/scripts/init/html-cleaner.d.ts +4 -0
- package/dist/cli/scripts/init/html-cleaner.js +38 -0
- package/dist/cli/scripts/init/main.d.ts +2 -0
- package/dist/cli/scripts/init/main.js +160 -0
- package/dist/cli/scripts/init/package-setup.d.ts +32 -0
- package/dist/cli/scripts/init/package-setup.js +75 -0
- package/dist/cli/scripts/init/router-transformer.d.ts +6 -0
- package/dist/cli/scripts/init/router-transformer.js +254 -0
- package/dist/cli/scripts/init/tailwind-config.d.ts +4 -0
- package/dist/cli/scripts/init/tailwind-config.js +56 -0
- package/dist/cli/scripts/init/vite-config.d.ts +20 -0
- package/dist/cli/scripts/init/vite-config.js +54 -0
- package/dist/cli/scripts/release/release-config-upload.d.ts +7 -0
- package/dist/cli/scripts/release/release-config-upload.js +116 -0
- package/dist/cli/scripts/release/release-db-update.d.ts +6 -0
- package/dist/cli/scripts/release/release-db-update.js +100 -0
- package/dist/cli/scripts/release/release-file-upload.d.ts +6 -0
- package/dist/cli/scripts/release/release-file-upload.js +136 -0
- package/dist/cli/scripts/release/release.d.ts +23 -0
- package/dist/cli/scripts/release/release.js +70 -0
- package/dist/cli/types/DatabaseTypes.d.ts +103 -0
- package/dist/cli/types/DatabaseTypes.js +2 -0
- package/dist/components/LoggerExample.d.ts +6 -0
- package/dist/components/LoggerExample.js +79 -0
- package/dist/components/ai/Assistant.js +5 -5
- package/dist/components/ai/Avatar.d.ts +3 -2
- package/dist/components/ai/Avatar.js +11 -6
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +1 -1
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +1 -0
- package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +48 -33
- package/dist/components/ai/utils.js +0 -1
- package/dist/components/audio/Playbutton.js +4 -4
- package/dist/{core → components}/components/ContextMenu.js +50 -11
- package/dist/components.d.ts +5 -5
- package/dist/components.js +5 -5
- package/dist/core/controller/AIController.d.ts +15 -0
- package/dist/core/controller/AIController.js +253 -0
- package/dist/core/controller/AudioController.d.ts +0 -0
- package/dist/core/controller/AudioController.js +1 -0
- package/dist/{controller → core/controller}/ObjectController.d.ts +10 -2
- package/dist/{controller → core/controller}/ObjectController.js +8 -8
- package/dist/{controller → core/controller}/SettingsController.d.ts +28 -4
- package/dist/{controller → core/controller}/SettingsController.js +0 -25
- package/dist/{controller → core/controller}/SharedContentController.d.ts +31 -3
- package/dist/{controller → core/controller}/SharedContentController.js +77 -26
- package/dist/core/controller/VoiceController.d.ts +9 -0
- package/dist/{controller → core/controller}/VoiceController.js +11 -4
- package/dist/core/core.d.ts +14 -0
- package/dist/core/core.js +8 -0
- package/dist/{plugin/fromRimori → fromRimori}/EventBus.d.ts +3 -3
- package/dist/{plugin/fromRimori → fromRimori}/EventBus.js +26 -9
- package/dist/fromRimori/PluginTypes.d.ts +174 -0
- package/dist/hooks/UseChatHook.d.ts +2 -1
- package/dist/hooks/UseChatHook.js +6 -4
- package/dist/hooks/UseLogger.d.ts +30 -0
- package/dist/hooks/UseLogger.js +122 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +5 -3
- package/dist/plugin/AccomplishmentHandler.d.ts +1 -1
- package/dist/plugin/AccomplishmentHandler.js +1 -1
- package/dist/plugin/AudioController.d.ts +37 -0
- package/dist/plugin/AudioController.js +68 -0
- package/dist/plugin/Logger.d.ts +68 -0
- package/dist/plugin/Logger.js +256 -0
- package/dist/plugin/LoggerExample.d.ts +16 -0
- package/dist/plugin/LoggerExample.js +140 -0
- package/dist/plugin/PluginController.d.ts +30 -5
- package/dist/plugin/PluginController.js +182 -53
- package/dist/plugin/RimoriClient.d.ts +68 -21
- package/dist/plugin/RimoriClient.js +88 -41
- package/dist/plugin/StandaloneClient.d.ts +1 -0
- package/dist/plugin/StandaloneClient.js +24 -10
- package/dist/plugin/ThemeSetter.d.ts +2 -1
- package/dist/plugin/ThemeSetter.js +13 -7
- package/dist/providers/PluginProvider.d.ts +4 -1
- package/dist/providers/PluginProvider.js +39 -13
- package/dist/utils/Language.d.ts +2 -1
- package/dist/utils/Language.js +4 -2
- package/dist/utils/audioFormats.d.ts +26 -0
- package/dist/utils/audioFormats.js +67 -0
- package/dist/utils/difficultyConverter.js +1 -1
- package/dist/utils/endpoint.d.ts +2 -0
- package/dist/utils/endpoint.js +2 -0
- package/dist/worker/WorkerSetup.d.ts +3 -2
- package/dist/worker/WorkerSetup.js +22 -65
- package/example/docs/devdocs.md +231 -0
- package/example/docs/overview.md +29 -0
- package/example/docs/userdocs.md +123 -0
- package/example/rimori.config.ts +89 -0
- package/example/worker/vite.config.ts +23 -0
- package/example/worker/worker.ts +11 -0
- package/package.json +16 -9
- package/src/cli/scripts/init/dev-registration.ts +192 -0
- package/src/cli/scripts/init/env-setup.ts +44 -0
- package/src/cli/scripts/init/file-operations.ts +58 -0
- package/src/cli/scripts/init/html-cleaner.ts +48 -0
- package/src/cli/scripts/init/main.ts +172 -0
- package/src/cli/scripts/init/package-setup.ts +117 -0
- package/src/cli/scripts/init/router-transformer.ts +329 -0
- package/src/cli/scripts/init/tailwind-config.ts +75 -0
- package/src/cli/scripts/init/vite-config.ts +73 -0
- package/src/cli/scripts/release/release-config-upload.ts +114 -0
- package/src/cli/scripts/release/release-db-update.ts +97 -0
- package/src/cli/scripts/release/release-file-upload.ts +138 -0
- package/src/cli/scripts/release/release.ts +69 -0
- package/src/cli/types/DatabaseTypes.ts +117 -0
- package/src/components/ai/Assistant.tsx +5 -5
- package/src/components/ai/Avatar.tsx +25 -8
- package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +1 -1
- package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +50 -35
- package/src/components/ai/utils.ts +0 -2
- package/src/components/audio/Playbutton.tsx +4 -4
- package/src/{core → components}/components/ContextMenu.tsx +56 -12
- package/src/components.ts +6 -6
- package/src/core/controller/AIController.ts +283 -0
- package/src/core/controller/ObjectController.ts +115 -0
- package/src/{controller → core/controller}/SettingsController.ts +29 -29
- package/src/{controller → core/controller}/SharedContentController.ts +91 -29
- package/src/core/controller/VoiceController.ts +31 -0
- package/src/core/core.ts +16 -0
- package/src/{plugin/fromRimori → fromRimori}/EventBus.ts +29 -11
- package/src/fromRimori/PluginTypes.ts +205 -0
- package/src/hooks/UseChatHook.ts +8 -5
- package/src/index.ts +6 -3
- package/src/plugin/AccomplishmentHandler.ts +1 -1
- package/src/plugin/AudioController.ts +58 -0
- package/src/plugin/Logger.ts +324 -0
- package/src/plugin/PluginController.ts +203 -63
- package/src/plugin/RimoriClient.ts +127 -55
- package/src/plugin/StandaloneClient.ts +30 -11
- package/src/plugin/ThemeSetter.ts +16 -9
- package/src/providers/PluginProvider.tsx +46 -13
- package/src/utils/Language.ts +4 -2
- package/src/utils/difficultyConverter.ts +3 -3
- package/src/utils/endpoint.ts +2 -0
- package/src/worker/WorkerSetup.ts +13 -60
- package/dist/components/PluginController.d.ts +0 -21
- package/dist/components/PluginController.js +0 -116
- package/dist/controller/AIController.d.ts +0 -23
- package/dist/controller/AIController.js +0 -93
- package/dist/controller/SidePluginController.d.ts +0 -3
- package/dist/controller/SidePluginController.js +0 -31
- package/dist/controller/VoiceController.d.ts +0 -10
- package/dist/core.d.ts +0 -7
- package/dist/core.js +0 -7
- package/dist/plugin/ContextMenu.d.ts +0 -17
- package/dist/plugin/ContextMenu.js +0 -45
- package/dist/plugin/fromRimori/PluginTypes.d.ts +0 -48
- package/dist/plugin/fromRimori/SupabaseHandler.d.ts +0 -13
- package/dist/plugin/fromRimori/SupabaseHandler.js +0 -55
- package/dist/providers/PluginController.d.ts +0 -21
- package/dist/providers/PluginController.js +0 -116
- package/dist/types/Actions.d.ts +0 -4
- package/dist/types/Actions.js +0 -1
- package/src/controller/AIController.ts +0 -112
- package/src/controller/ObjectController.ts +0 -107
- package/src/controller/SidePluginController.ts +0 -25
- package/src/controller/VoiceController.ts +0 -26
- package/src/core.ts +0 -8
- package/src/plugin/fromRimori/PluginTypes.ts +0 -64
- package/src/types/Actions.ts +0 -6
- /package/dist/{core → components}/components/ContextMenu.d.ts +0 -0
- /package/dist/{plugin/fromRimori → fromRimori}/PluginTypes.js +0 -0
- /package/src/{plugin/fromRimori → fromRimori}/readme.md +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { RimoriClient } from './RimoriClient';
|
|
2
|
+
/**
|
|
3
|
+
* Singleton Logger class for Rimori client plugins.
|
|
4
|
+
* Handles all logging levels, production filtering, and log transmission to Rimori.
|
|
5
|
+
* Overrides console methods globally for seamless integration.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Logger {
|
|
8
|
+
private static instance;
|
|
9
|
+
private isProduction;
|
|
10
|
+
private logs;
|
|
11
|
+
private logIdCounter;
|
|
12
|
+
private originalConsole;
|
|
13
|
+
private mousePosition;
|
|
14
|
+
private constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the Logger singleton and override console methods globally.
|
|
17
|
+
* @param rimori - Rimori client instance
|
|
18
|
+
* @param isProduction - Whether the environment is production
|
|
19
|
+
* @returns Logger instance
|
|
20
|
+
*/
|
|
21
|
+
static getInstance(rimori: RimoriClient, isProduction?: boolean): Logger;
|
|
22
|
+
private validateIsProduction;
|
|
23
|
+
/**
|
|
24
|
+
* Expose log access to global scope for DevTools console access.
|
|
25
|
+
*/
|
|
26
|
+
private exposeToDevTools;
|
|
27
|
+
/**
|
|
28
|
+
* Set up navigation event listeners to clear logs on page changes.
|
|
29
|
+
*/
|
|
30
|
+
private setupNavigationClearing;
|
|
31
|
+
/**
|
|
32
|
+
* Override console methods globally to capture all console calls.
|
|
33
|
+
*/
|
|
34
|
+
private overrideConsoleMethods;
|
|
35
|
+
/**
|
|
36
|
+
* Track mouse position for screenshot context.
|
|
37
|
+
*/
|
|
38
|
+
private trackMousePosition;
|
|
39
|
+
/**
|
|
40
|
+
* Handle console method calls and create log entries.
|
|
41
|
+
* @param level - Log level
|
|
42
|
+
* @param args - Console arguments
|
|
43
|
+
*/
|
|
44
|
+
private handleConsoleCall;
|
|
45
|
+
/**
|
|
46
|
+
* Get browser and system information for debugging.
|
|
47
|
+
* @returns Object with browser and system information
|
|
48
|
+
*/
|
|
49
|
+
private getBrowserInfo;
|
|
50
|
+
/**
|
|
51
|
+
* Capture a screenshot of the current page.
|
|
52
|
+
* @returns Promise resolving to base64 screenshot or null if failed
|
|
53
|
+
*/
|
|
54
|
+
private captureScreenshot;
|
|
55
|
+
/**
|
|
56
|
+
* Create a log entry with context information.
|
|
57
|
+
* @param level - Log level
|
|
58
|
+
* @param message - Log message
|
|
59
|
+
* @param data - Additional data
|
|
60
|
+
* @returns Log entry
|
|
61
|
+
*/
|
|
62
|
+
private createLogEntry;
|
|
63
|
+
/**
|
|
64
|
+
* Add a log entry to the internal log array.
|
|
65
|
+
* @param entry - Log entry to add
|
|
66
|
+
*/
|
|
67
|
+
private addLogEntry;
|
|
68
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
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 html2canvas from 'html2canvas';
|
|
11
|
+
/**
|
|
12
|
+
* Singleton Logger class for Rimori client plugins.
|
|
13
|
+
* Handles all logging levels, production filtering, and log transmission to Rimori.
|
|
14
|
+
* Overrides console methods globally for seamless integration.
|
|
15
|
+
*/
|
|
16
|
+
export class Logger {
|
|
17
|
+
constructor(rimori, isProduction) {
|
|
18
|
+
this.logs = [];
|
|
19
|
+
this.logIdCounter = 0;
|
|
20
|
+
this.mousePosition = null;
|
|
21
|
+
this.isProduction = this.validateIsProduction(isProduction);
|
|
22
|
+
// Store original console methods
|
|
23
|
+
this.originalConsole = {
|
|
24
|
+
log: console.log,
|
|
25
|
+
info: console.info,
|
|
26
|
+
warn: console.warn,
|
|
27
|
+
error: console.error,
|
|
28
|
+
debug: console.debug
|
|
29
|
+
};
|
|
30
|
+
// Override console methods globally
|
|
31
|
+
this.overrideConsoleMethods();
|
|
32
|
+
// Track mouse position
|
|
33
|
+
this.trackMousePosition();
|
|
34
|
+
// Expose logs to global scope for DevTools access
|
|
35
|
+
this.exposeToDevTools();
|
|
36
|
+
// Set up navigation clearing
|
|
37
|
+
this.setupNavigationClearing();
|
|
38
|
+
rimori.event.respond('logging.requestPluginLogs', () => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
this.addLogEntry(yield this.createLogEntry('info', 'Screenshot capture', undefined, true));
|
|
40
|
+
const logs = {
|
|
41
|
+
logs: this.logs,
|
|
42
|
+
pluginId: rimori.plugin.pluginId,
|
|
43
|
+
timestamp: new Date().toISOString()
|
|
44
|
+
};
|
|
45
|
+
this.logs = [];
|
|
46
|
+
this.logIdCounter = 0;
|
|
47
|
+
return logs;
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Initialize the Logger singleton and override console methods globally.
|
|
52
|
+
* @param rimori - Rimori client instance
|
|
53
|
+
* @param isProduction - Whether the environment is production
|
|
54
|
+
* @returns Logger instance
|
|
55
|
+
*/
|
|
56
|
+
static getInstance(rimori, isProduction) {
|
|
57
|
+
if (!Logger.instance) {
|
|
58
|
+
Logger.instance = new Logger(rimori, isProduction);
|
|
59
|
+
}
|
|
60
|
+
return Logger.instance;
|
|
61
|
+
}
|
|
62
|
+
validateIsProduction(isProduction) {
|
|
63
|
+
if (isProduction !== undefined) {
|
|
64
|
+
return isProduction;
|
|
65
|
+
}
|
|
66
|
+
if (typeof window !== 'undefined' && window.location.href) {
|
|
67
|
+
return !window.location.href.includes('localhost');
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Expose log access to global scope for DevTools console access.
|
|
73
|
+
*/
|
|
74
|
+
exposeToDevTools() {
|
|
75
|
+
if (typeof window !== 'undefined') {
|
|
76
|
+
// Expose a global function to access logs from DevTools console
|
|
77
|
+
window.getRimoriLogs = () => this.logs;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Set up navigation event listeners to clear logs on page changes.
|
|
82
|
+
*/
|
|
83
|
+
setupNavigationClearing() {
|
|
84
|
+
if (typeof window === 'undefined' || typeof history === 'undefined')
|
|
85
|
+
return;
|
|
86
|
+
// Clear logs on browser back/forward
|
|
87
|
+
window.addEventListener('popstate', () => this.logs = []);
|
|
88
|
+
// Override history methods to clear logs on programmatic navigation
|
|
89
|
+
const originalPushState = history.pushState;
|
|
90
|
+
const originalReplaceState = history.replaceState;
|
|
91
|
+
history.pushState = (...args) => {
|
|
92
|
+
originalPushState.apply(history, args);
|
|
93
|
+
this.logs = [];
|
|
94
|
+
};
|
|
95
|
+
history.replaceState = (...args) => {
|
|
96
|
+
originalReplaceState.apply(history, args);
|
|
97
|
+
this.logs = [];
|
|
98
|
+
};
|
|
99
|
+
// Listen for URL changes (works with React Router and other SPAs)
|
|
100
|
+
let currentUrl = window.location.href;
|
|
101
|
+
const checkUrlChange = () => {
|
|
102
|
+
if (window.location.href !== currentUrl) {
|
|
103
|
+
currentUrl = window.location.href;
|
|
104
|
+
this.logs = [];
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
// Check for URL changes periodically
|
|
108
|
+
setInterval(checkUrlChange, 100);
|
|
109
|
+
// Also listen for hash changes (for hash-based routing)
|
|
110
|
+
window.addEventListener('hashchange', () => this.logs = []);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Override console methods globally to capture all console calls.
|
|
114
|
+
*/
|
|
115
|
+
overrideConsoleMethods() {
|
|
116
|
+
// Override console.log
|
|
117
|
+
console.log = (...args) => {
|
|
118
|
+
this.originalConsole.log(...args);
|
|
119
|
+
this.handleConsoleCall('info', args);
|
|
120
|
+
};
|
|
121
|
+
// Override console.info
|
|
122
|
+
console.info = (...args) => {
|
|
123
|
+
this.originalConsole.info(...args);
|
|
124
|
+
this.handleConsoleCall('info', args);
|
|
125
|
+
};
|
|
126
|
+
// Override console.warn
|
|
127
|
+
console.warn = (...args) => {
|
|
128
|
+
this.originalConsole.warn(...args);
|
|
129
|
+
this.handleConsoleCall('warn', args);
|
|
130
|
+
};
|
|
131
|
+
// Override console.error
|
|
132
|
+
console.error = (...args) => {
|
|
133
|
+
this.originalConsole.error(...args);
|
|
134
|
+
this.handleConsoleCall('error', args);
|
|
135
|
+
};
|
|
136
|
+
// Override console.debug
|
|
137
|
+
console.debug = (...args) => {
|
|
138
|
+
this.originalConsole.debug(...args);
|
|
139
|
+
this.handleConsoleCall('debug', args);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Track mouse position for screenshot context.
|
|
144
|
+
*/
|
|
145
|
+
trackMousePosition() {
|
|
146
|
+
if (typeof window !== 'undefined') {
|
|
147
|
+
const updateMousePosition = (event) => {
|
|
148
|
+
this.mousePosition = {
|
|
149
|
+
x: event.clientX,
|
|
150
|
+
y: event.clientY,
|
|
151
|
+
timestamp: new Date().toISOString()
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
window.addEventListener('mousemove', updateMousePosition);
|
|
155
|
+
window.addEventListener('click', updateMousePosition);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Handle console method calls and create log entries.
|
|
160
|
+
* @param level - Log level
|
|
161
|
+
* @param args - Console arguments
|
|
162
|
+
*/
|
|
163
|
+
handleConsoleCall(level, args) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
// Skip if this is a production log that shouldn't be stored
|
|
166
|
+
if (this.isProduction && (level === 'debug' || level === 'info')) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
// Convert console arguments to message and data
|
|
170
|
+
const message = args.map(arg => typeof arg === 'object' ? JSON.stringify(arg) : String(arg)).join(' ');
|
|
171
|
+
const data = args.length > 1 ? args.slice(1) : undefined;
|
|
172
|
+
const entry = yield this.createLogEntry(level, message, data);
|
|
173
|
+
this.addLogEntry(entry);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get browser and system information for debugging.
|
|
178
|
+
* @returns Object with browser and system information
|
|
179
|
+
*/
|
|
180
|
+
getBrowserInfo() {
|
|
181
|
+
return {
|
|
182
|
+
userAgent: navigator.userAgent,
|
|
183
|
+
language: navigator.language,
|
|
184
|
+
cookieEnabled: navigator.cookieEnabled,
|
|
185
|
+
onLine: navigator.onLine,
|
|
186
|
+
screenResolution: `${screen.width}x${screen.height}`,
|
|
187
|
+
windowSize: `${window.innerWidth}x${window.innerHeight}`,
|
|
188
|
+
timestamp: new Date().toISOString()
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Capture a screenshot of the current page.
|
|
193
|
+
* @returns Promise resolving to base64 screenshot or null if failed
|
|
194
|
+
*/
|
|
195
|
+
captureScreenshot() {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
198
|
+
const canvas = yield html2canvas(document.body);
|
|
199
|
+
const screenshot = canvas.toDataURL('image/png');
|
|
200
|
+
// this.originalConsole.log("screenshot captured", screenshot)
|
|
201
|
+
return screenshot;
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Create a log entry with context information.
|
|
208
|
+
* @param level - Log level
|
|
209
|
+
* @param message - Log message
|
|
210
|
+
* @param data - Additional data
|
|
211
|
+
* @returns Log entry
|
|
212
|
+
*/
|
|
213
|
+
createLogEntry(level, message, data, forceScreenshot) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
const context = {};
|
|
216
|
+
// Add URL if available
|
|
217
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
218
|
+
return {
|
|
219
|
+
id: `log_${++this.logIdCounter}_${Date.now()}`,
|
|
220
|
+
timestamp: new Date().toISOString(),
|
|
221
|
+
level,
|
|
222
|
+
message,
|
|
223
|
+
data,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
context.url = window.location.href;
|
|
227
|
+
// Add browser info (this method now handles worker context internally)
|
|
228
|
+
context.browserInfo = this.getBrowserInfo();
|
|
229
|
+
context.userAgent = context.browserInfo.userAgent;
|
|
230
|
+
// Add screenshot and mouse position if level is error or warn
|
|
231
|
+
if (level === 'error' || level === 'warn' || forceScreenshot) {
|
|
232
|
+
context.screenshot = (yield this.captureScreenshot()) || undefined;
|
|
233
|
+
context.mousePosition = this.mousePosition || undefined;
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
id: `log_${++this.logIdCounter}_${Date.now()}`,
|
|
237
|
+
timestamp: new Date().toISOString(),
|
|
238
|
+
level,
|
|
239
|
+
message,
|
|
240
|
+
data,
|
|
241
|
+
context: context
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Add a log entry to the internal log array.
|
|
247
|
+
* @param entry - Log entry to add
|
|
248
|
+
*/
|
|
249
|
+
addLogEntry(entry) {
|
|
250
|
+
this.logs.push(entry);
|
|
251
|
+
// Maintain log size limit (1000 entries)
|
|
252
|
+
if (this.logs.length > 1000) {
|
|
253
|
+
this.logs = this.logs.slice(-1000);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export declare function initializePluginWithLogger(): Promise<void>;
|
|
6
|
+
export declare function exampleComponentUsage(): {
|
|
7
|
+
handleUserAction: () => void;
|
|
8
|
+
handleApiError: (error: Error) => void;
|
|
9
|
+
handleDeprecatedFeature: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function exampleLogManagement(): {
|
|
12
|
+
sendLogsToRimori: () => Promise<void>;
|
|
13
|
+
getLogStatistics: () => any;
|
|
14
|
+
exportLogsForDebugging: () => void;
|
|
15
|
+
clearOldLogs: () => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
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,21 +1,46 @@
|
|
|
1
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { UserInfo } from '../core/controller/SettingsController';
|
|
3
|
+
import { ActivePlugin, Plugin } from '../fromRimori/PluginTypes';
|
|
2
4
|
import { RimoriClient } from "./RimoriClient";
|
|
5
|
+
export interface RimoriInfo {
|
|
6
|
+
url: string;
|
|
7
|
+
key: string;
|
|
8
|
+
backendUrl: string;
|
|
9
|
+
token: string;
|
|
10
|
+
expiration: Date;
|
|
11
|
+
tablePrefix: string;
|
|
12
|
+
pluginId: string;
|
|
13
|
+
installedPlugins: Plugin[];
|
|
14
|
+
profile: UserInfo;
|
|
15
|
+
mainPanelPlugin?: ActivePlugin;
|
|
16
|
+
sidePanelPlugin?: ActivePlugin;
|
|
17
|
+
}
|
|
3
18
|
export declare class PluginController {
|
|
4
19
|
private static client;
|
|
5
20
|
private static instance;
|
|
6
|
-
private
|
|
21
|
+
private port;
|
|
22
|
+
private queryParams;
|
|
7
23
|
private supabase;
|
|
8
|
-
private
|
|
24
|
+
private rimoriInfo;
|
|
9
25
|
private pluginId;
|
|
26
|
+
private isMessageChannelReady;
|
|
27
|
+
private pendingRequests;
|
|
10
28
|
private constructor();
|
|
29
|
+
private initMessageChannel;
|
|
30
|
+
private sendHello;
|
|
11
31
|
static getInstance(pluginId: string, standalone?: boolean): Promise<RimoriClient>;
|
|
12
|
-
|
|
32
|
+
getQueryParam(key: string): string | null;
|
|
13
33
|
getClient(): Promise<{
|
|
14
34
|
supabase: SupabaseClient;
|
|
15
|
-
|
|
16
|
-
pluginId: string;
|
|
35
|
+
info: RimoriInfo;
|
|
17
36
|
}>;
|
|
18
37
|
getToken(): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the Supabase URL.
|
|
40
|
+
* @returns The Supabase URL.
|
|
41
|
+
* @deprecated All endpoints should use the backend URL instead.
|
|
42
|
+
*/
|
|
19
43
|
getSupabaseUrl(): string;
|
|
44
|
+
getBackendUrl(): string;
|
|
20
45
|
getGlobalEventTopic(preliminaryTopic: string): string;
|
|
21
46
|
}
|