@rimori/client 1.1.0 → 1.1.2
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 +949 -35
- package/dist/components/ai/Avatar.d.ts +1 -1
- package/dist/components/ai/EmbeddedAssistent/AudioInputField.js +1 -1
- package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +1 -1
- package/dist/controller/SidePluginController.js +2 -1
- package/dist/core.d.ts +0 -5
- package/dist/core.js +0 -5
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/plugin/PluginController.d.ts +1 -1
- package/dist/plugin/PluginController.js +16 -7
- package/dist/plugin/StandaloneClient.d.ts +16 -0
- package/dist/plugin/StandaloneClient.js +76 -0
- package/dist/plugin/fromRimori/PluginTypes.d.ts +0 -3
- package/dist/plugin/fromRimori/SupabaseHandler.d.ts +13 -0
- package/dist/plugin/fromRimori/SupabaseHandler.js +55 -0
- package/dist/providers/PluginProvider.js +42 -3
- package/package.json +1 -1
- package/src/components/ai/Avatar.tsx +1 -1
- package/src/components/ai/EmbeddedAssistent/AudioInputField.tsx +1 -1
- package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +1 -1
- package/src/controller/SidePluginController.ts +2 -1
- package/src/core.ts +0 -5
- package/src/index.ts +0 -8
- package/src/plugin/PluginController.ts +18 -8
- package/src/plugin/StandaloneClient.ts +73 -0
- package/src/plugin/fromRimori/PluginTypes.ts +0 -3
- package/src/providers/PluginProvider.tsx +48 -3
|
@@ -5,11 +5,8 @@ export interface Plugin {
|
|
|
5
5
|
id: string;
|
|
6
6
|
title: string;
|
|
7
7
|
description: string;
|
|
8
|
-
git_repository: string;
|
|
9
|
-
website: string;
|
|
10
8
|
icon_url: string;
|
|
11
9
|
version: string;
|
|
12
|
-
author: string;
|
|
13
10
|
endpoint: string;
|
|
14
11
|
context_menu_actions: MenuEntry[];
|
|
15
12
|
plugin_pages: PluginPage[];
|
|
@@ -3,6 +3,7 @@ import { PluginController } from '../plugin/PluginController';
|
|
|
3
3
|
import { RimoriClient } from '../plugin/RimoriClient';
|
|
4
4
|
import { EventBusHandler } from '../plugin/fromRimori/EventBus';
|
|
5
5
|
import ContextMenu from '../core/components/ContextMenu';
|
|
6
|
+
import { StandaloneClient } from '../plugin/StandaloneClient';
|
|
6
7
|
|
|
7
8
|
interface PluginProviderProps {
|
|
8
9
|
children: ReactNode;
|
|
@@ -13,11 +14,21 @@ const PluginContext = createContext<RimoriClient | null>(null);
|
|
|
13
14
|
|
|
14
15
|
export const PluginProvider: React.FC<PluginProviderProps> = ({ children, pluginId }) => {
|
|
15
16
|
const [plugin, setPlugin] = useState<RimoriClient | null>(null);
|
|
16
|
-
|
|
17
|
+
const [standaloneClient, setStandaloneClient] = useState<StandaloneClient | boolean>(false);
|
|
17
18
|
|
|
18
19
|
useEffect(() => {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
initEventBus(pluginId);
|
|
21
|
+
const standaloneDetected = new URLSearchParams(window.location.search).get("secret") === null;
|
|
22
|
+
if (standaloneDetected && !standaloneClient) {
|
|
23
|
+
StandaloneClient.getInstance().then(client => {
|
|
24
|
+
client.needsLogin().then((needLogin) => setStandaloneClient(needLogin ? client : true));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ((!standaloneDetected && !plugin) || (standaloneDetected && standaloneClient === true)) {
|
|
29
|
+
PluginController.getInstance(pluginId, standaloneDetected).then(setPlugin);
|
|
30
|
+
}
|
|
31
|
+
}, [pluginId, standaloneClient]);
|
|
21
32
|
|
|
22
33
|
//route change
|
|
23
34
|
useEffect(() => {
|
|
@@ -50,6 +61,12 @@ export const PluginProvider: React.FC<PluginProviderProps> = ({ children, plugin
|
|
|
50
61
|
return () => body.removeEventListener('resize', handleResize);
|
|
51
62
|
}, [plugin]);
|
|
52
63
|
|
|
64
|
+
if (standaloneClient instanceof StandaloneClient) {
|
|
65
|
+
return <StandaloneAuth onLogin={async (email, password) => {
|
|
66
|
+
if (await standaloneClient.login(email, password)) setStandaloneClient(true);
|
|
67
|
+
}} />
|
|
68
|
+
}
|
|
69
|
+
|
|
53
70
|
if (!plugin) {
|
|
54
71
|
return ""
|
|
55
72
|
}
|
|
@@ -74,4 +91,32 @@ function initEventBus(pluginId: string) {
|
|
|
74
91
|
const url = new URL(window.location.href);
|
|
75
92
|
const isSidebar = url.searchParams.get("applicationMode") === "sidebar";
|
|
76
93
|
EventBusHandler.getInstance("Plugin EventBus " + pluginId + " " + (isSidebar ? "sidebar" : "main"));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function StandaloneAuth({ onLogin }: { onLogin: (user: string, password: string) => void }) {
|
|
97
|
+
const [user, setUser] = useState("");
|
|
98
|
+
const [password, setPassword] = useState("");
|
|
99
|
+
return (
|
|
100
|
+
<div style={{
|
|
101
|
+
position: 'fixed',
|
|
102
|
+
inset: 0,
|
|
103
|
+
display: 'flex',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
justifyContent: 'center',
|
|
106
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
107
|
+
}}>
|
|
108
|
+
<div style={{ backgroundColor: '#343534', padding: '1rem', borderRadius: '0.5rem', width: '500px', flexDirection: 'column', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
109
|
+
<p style={{ fontSize: '2rem', fontWeight: 'bold', marginBottom: '1rem', textAlign: 'center' }}>Rimori Login</p>
|
|
110
|
+
<p style={{ marginBottom: '1rem', textAlign: 'center' }}>
|
|
111
|
+
Please login with your Rimori developer account for this plugin to be able to access the Rimori platform the same it will operate in the Rimori platform.
|
|
112
|
+
</p>
|
|
113
|
+
{/* email and password input */}
|
|
114
|
+
<input style={{ marginBottom: '1rem', width: '100%', padding: '0.5rem', borderRadius: '0.5rem', border: 'none', backgroundColor: '#444444' }} type="email" placeholder="Email" onChange={(e) => setUser(e.target.value)} />
|
|
115
|
+
<input style={{ marginBottom: '1rem', width: '100%', padding: '0.5rem', borderRadius: '0.5rem', border: 'none', backgroundColor: '#444444' }} type="password" placeholder="Password" onChange={(e) => setPassword(e.target.value)} />
|
|
116
|
+
<button style={{ marginBottom: '1rem', width: '100%', padding: '0.5rem', borderRadius: '0.5rem', border: 'none', backgroundColor: '#928358' }} onClick={() => {
|
|
117
|
+
onLogin(user, password);
|
|
118
|
+
}}>Login</button>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
)
|
|
77
122
|
}
|