@rimori/client 1.1.10 → 1.2.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 (151) hide show
  1. package/README.md +128 -45
  2. package/dist/cli/scripts/init/dev-registration.d.ts +35 -0
  3. package/dist/cli/scripts/init/dev-registration.js +175 -0
  4. package/dist/cli/scripts/init/env-setup.d.ts +9 -0
  5. package/dist/cli/scripts/init/env-setup.js +43 -0
  6. package/dist/cli/scripts/init/file-operations.d.ts +4 -0
  7. package/dist/cli/scripts/init/file-operations.js +51 -0
  8. package/dist/cli/scripts/init/html-cleaner.d.ts +4 -0
  9. package/dist/cli/scripts/init/html-cleaner.js +38 -0
  10. package/dist/cli/scripts/init/main.d.ts +2 -0
  11. package/dist/cli/scripts/init/main.js +159 -0
  12. package/dist/cli/scripts/init/package-setup.d.ts +32 -0
  13. package/dist/cli/scripts/init/package-setup.js +75 -0
  14. package/dist/cli/scripts/init/router-transformer.d.ts +6 -0
  15. package/dist/cli/scripts/init/router-transformer.js +254 -0
  16. package/dist/cli/scripts/init/tailwind-config.d.ts +4 -0
  17. package/dist/cli/scripts/init/tailwind-config.js +56 -0
  18. package/dist/cli/scripts/init/vite-config.d.ts +20 -0
  19. package/dist/cli/scripts/init/vite-config.js +54 -0
  20. package/dist/cli/scripts/release/release-config-upload.d.ts +7 -0
  21. package/dist/cli/scripts/release/release-config-upload.js +116 -0
  22. package/dist/cli/scripts/release/release-db-update.d.ts +6 -0
  23. package/dist/cli/scripts/release/release-db-update.js +100 -0
  24. package/dist/cli/scripts/release/release-file-upload.d.ts +6 -0
  25. package/dist/cli/scripts/release/release-file-upload.js +136 -0
  26. package/dist/cli/scripts/release/release.d.ts +23 -0
  27. package/dist/cli/scripts/release/release.js +70 -0
  28. package/dist/cli/types/DatabaseTypes.d.ts +103 -0
  29. package/dist/cli/types/DatabaseTypes.js +2 -0
  30. package/dist/components/ai/Assistant.js +4 -4
  31. package/dist/components/ai/Avatar.d.ts +3 -2
  32. package/dist/components/ai/Avatar.js +10 -5
  33. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +1 -1
  34. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +1 -0
  35. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +12 -6
  36. package/dist/components/ai/utils.js +0 -1
  37. package/dist/components/audio/Playbutton.js +3 -3
  38. package/dist/{core → components}/components/ContextMenu.js +2 -2
  39. package/dist/components.d.ts +5 -5
  40. package/dist/components.js +5 -5
  41. package/dist/core/controller/AIController.d.ts +15 -0
  42. package/dist/core/controller/AIController.js +120 -0
  43. package/dist/{controller → core/controller}/ObjectController.d.ts +8 -0
  44. package/dist/{controller → core/controller}/SettingsController.d.ts +12 -4
  45. package/dist/{controller → core/controller}/SettingsController.js +0 -25
  46. package/dist/{controller → core/controller}/SharedContentController.d.ts +1 -1
  47. package/dist/{controller → core/controller}/SharedContentController.js +4 -4
  48. package/dist/core/core.d.ts +13 -0
  49. package/dist/core/core.js +8 -0
  50. package/dist/{plugin/fromRimori → fromRimori}/EventBus.d.ts +3 -3
  51. package/dist/{plugin/fromRimori → fromRimori}/EventBus.js +25 -8
  52. package/dist/fromRimori/PluginTypes.d.ts +171 -0
  53. package/dist/hooks/UseChatHook.d.ts +2 -1
  54. package/dist/hooks/UseChatHook.js +3 -3
  55. package/dist/index.d.ts +5 -3
  56. package/dist/index.js +4 -3
  57. package/dist/plugin/AccomplishmentHandler.d.ts +1 -1
  58. package/dist/plugin/AccomplishmentHandler.js +1 -1
  59. package/dist/plugin/PluginController.d.ts +16 -3
  60. package/dist/plugin/PluginController.js +24 -18
  61. package/dist/plugin/RimoriClient.d.ts +16 -11
  62. package/dist/plugin/RimoriClient.js +35 -25
  63. package/dist/plugin/StandaloneClient.js +11 -8
  64. package/dist/plugin/ThemeSetter.d.ts +1 -0
  65. package/dist/plugin/ThemeSetter.js +9 -6
  66. package/dist/providers/PluginProvider.d.ts +3 -0
  67. package/dist/providers/PluginProvider.js +4 -4
  68. package/dist/utils/Language.d.ts +2 -1
  69. package/dist/utils/Language.js +4 -2
  70. package/dist/utils/difficultyConverter.js +1 -1
  71. package/dist/utils/endpoint.d.ts +2 -0
  72. package/dist/utils/endpoint.js +2 -0
  73. package/dist/worker/WorkerSetup.js +3 -1
  74. package/example/docs/devdocs.md +231 -0
  75. package/example/docs/overview.md +29 -0
  76. package/example/docs/userdocs.md +123 -0
  77. package/example/rimori.config.ts +89 -0
  78. package/example/worker/vite.config.ts +23 -0
  79. package/example/worker/worker.ts +11 -0
  80. package/package.json +15 -9
  81. package/src/cli/scripts/init/dev-registration.ts +193 -0
  82. package/src/cli/scripts/init/env-setup.ts +44 -0
  83. package/src/cli/scripts/init/file-operations.ts +58 -0
  84. package/src/cli/scripts/init/html-cleaner.ts +48 -0
  85. package/src/cli/scripts/init/main.ts +171 -0
  86. package/src/cli/scripts/init/package-setup.ts +117 -0
  87. package/src/cli/scripts/init/router-transformer.ts +329 -0
  88. package/src/cli/scripts/init/tailwind-config.ts +75 -0
  89. package/src/cli/scripts/init/vite-config.ts +73 -0
  90. package/src/cli/scripts/release/release-config-upload.ts +114 -0
  91. package/src/cli/scripts/release/release-db-update.ts +97 -0
  92. package/src/cli/scripts/release/release-file-upload.ts +138 -0
  93. package/src/cli/scripts/release/release.ts +69 -0
  94. package/src/cli/types/DatabaseTypes.ts +117 -0
  95. package/src/components/ai/Assistant.tsx +4 -4
  96. package/src/components/ai/Avatar.tsx +24 -7
  97. package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +1 -1
  98. package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +16 -8
  99. package/src/components/ai/utils.ts +0 -2
  100. package/src/components/audio/Playbutton.tsx +3 -3
  101. package/src/{core → components}/components/ContextMenu.tsx +3 -3
  102. package/src/components.ts +6 -6
  103. package/src/core/controller/AIController.ts +122 -0
  104. package/src/core/controller/ObjectController.ts +115 -0
  105. package/src/{controller → core/controller}/SettingsController.ts +13 -29
  106. package/src/{controller → core/controller}/SharedContentController.ts +5 -5
  107. package/src/core/core.ts +15 -0
  108. package/src/{plugin/fromRimori → fromRimori}/EventBus.ts +28 -10
  109. package/src/fromRimori/PluginTypes.ts +203 -0
  110. package/src/hooks/UseChatHook.ts +5 -4
  111. package/src/index.ts +5 -3
  112. package/src/plugin/AccomplishmentHandler.ts +1 -1
  113. package/src/plugin/PluginController.ts +35 -23
  114. package/src/plugin/RimoriClient.ts +42 -35
  115. package/src/plugin/StandaloneClient.ts +11 -8
  116. package/src/plugin/ThemeSetter.ts +12 -8
  117. package/src/providers/PluginProvider.tsx +7 -4
  118. package/src/utils/Language.ts +4 -2
  119. package/src/utils/difficultyConverter.ts +3 -3
  120. package/src/utils/endpoint.ts +2 -0
  121. package/src/worker/WorkerSetup.ts +4 -2
  122. package/dist/components/PluginController.d.ts +0 -21
  123. package/dist/components/PluginController.js +0 -116
  124. package/dist/controller/AIController.d.ts +0 -23
  125. package/dist/controller/AIController.js +0 -93
  126. package/dist/controller/SidePluginController.d.ts +0 -3
  127. package/dist/controller/SidePluginController.js +0 -31
  128. package/dist/core.d.ts +0 -7
  129. package/dist/core.js +0 -7
  130. package/dist/plugin/ContextMenu.d.ts +0 -17
  131. package/dist/plugin/ContextMenu.js +0 -45
  132. package/dist/plugin/fromRimori/PluginTypes.d.ts +0 -48
  133. package/dist/plugin/fromRimori/SupabaseHandler.d.ts +0 -13
  134. package/dist/plugin/fromRimori/SupabaseHandler.js +0 -55
  135. package/dist/providers/PluginController.d.ts +0 -21
  136. package/dist/providers/PluginController.js +0 -116
  137. package/dist/types/Actions.d.ts +0 -4
  138. package/dist/types/Actions.js +0 -1
  139. package/src/controller/AIController.ts +0 -112
  140. package/src/controller/ObjectController.ts +0 -107
  141. package/src/controller/SidePluginController.ts +0 -25
  142. package/src/core.ts +0 -8
  143. package/src/plugin/fromRimori/PluginTypes.ts +0 -64
  144. package/src/types/Actions.ts +0 -6
  145. /package/dist/{core → components}/components/ContextMenu.d.ts +0 -0
  146. /package/dist/{controller → core/controller}/ObjectController.js +0 -0
  147. /package/dist/{controller → core/controller}/VoiceController.d.ts +0 -0
  148. /package/dist/{controller → core/controller}/VoiceController.js +0 -0
  149. /package/dist/{plugin/fromRimori → fromRimori}/PluginTypes.js +0 -0
  150. /package/src/{controller → core/controller}/VoiceController.ts +0 -0
  151. /package/src/{plugin/fromRimori → fromRimori}/readme.md +0 -0
package/README.md CHANGED
@@ -5,6 +5,8 @@ The **@rimori/client** package is a comprehensive React library that enables plu
5
5
  ## Table of Contents
6
6
 
7
7
  - [Installation](#installation)
8
+ - [Quick Start Plugin Development](#quick-start-plugin-development)
9
+ - [Releasing Your Plugin to Rimori](#releasing-your-plugin-to-rimori)
8
10
  - [Quick Start](#quick-start)
9
11
  - [Core API - usePlugin Hook](#core-api---useplugin-hook)
10
12
  - [Database Integration](#database-integration)
@@ -25,64 +27,146 @@ npm install @rimori/client
25
27
  yarn add @rimori/client
26
28
  ```
27
29
 
28
- ## Quick Start
30
+ ## Quick Start Plugin Development
29
31
 
30
- ### Basic Setup
32
+ The Rimori Client package includes powerful CLI tools to eliminate the tedious setup process and get you building your plugin fast. The initialization script handles authentication, plugin registration, environment setup, and all necessary boilerplate configuration.
31
33
 
32
- ```typescript
33
- import { lazy } from "react";
34
- import { PluginProvider, usePlugin } from "@rimori/client";
35
- import { HashRouter, Route, Routes } from "react-router-dom";
34
+ ### Prerequisites
36
35
 
37
- // Load pages lazily for optimal performance
38
- const SettingsPage = lazy(() => import("./pages/settings/SettingsPage"));
39
- const MainPage = lazy(() => import("./pages/MainPage"));
36
+ Before initializing your plugin, ensure you have:
40
37
 
41
- const App = () => (
42
- <PluginProvider pluginId="rimori-plugin-id">
43
- <HashRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
44
- <Routes>
45
- <Route path="/" element={<MainPage />} />
46
- <Route path="/settings" element={<SettingsPage />} />
47
- </Routes>
48
- </HashRouter>
49
- </PluginProvider>
50
- );
38
+ 1. **Node.js and yarn/npm installed**
39
+ 2. **A Rimori account** - You'll need to login during initialization to receive your access token
51
40
 
52
- export default App;
41
+ ### Initializing a New Plugin
42
+
43
+ Open Lovable and vibe code the look of your plugin.
44
+
45
+ Then connect it to your Github account.
46
+
47
+ Clone the git repository:
48
+
49
+ ```bash
50
+ git clone ...
51
+ cd my-awesome-plugin
52
+
53
+ # Initialize with Rimori Client (this handles everything!)
54
+ npx @rimori/client rimori-init
53
55
  ```
54
56
 
55
- ### TailwindCSS Configuration
57
+ ### What the Init Script Does
56
58
 
57
- Add the library to your `tailwind.config.js`:
59
+ The `rimori-init` command automates the entire plugin setup process:
58
60
 
59
- ```javascript
60
- export default {
61
- darkMode: ["class"], // Required for theme detection
62
- content: [
63
- "./src/**/*.{js,jsx,ts,tsx}",
64
- "node_modules/@rimori/client/dist/components/**/*.{js,jsx}",
65
- ],
66
- // ... rest of config
67
- }
61
+ 1. **🔐 Authentication**: Prompts for your Rimori credentials and authenticates with the platform
62
+ 2. **🚀 Plugin Registration**: Automatically registers your plugin and generates a unique plugin ID
63
+ 3. **🔑 Access Token**: Provides you with an access token for future plugin releases
64
+ 4. **📦 Package Configuration**: Updates `package.json` with plugin-specific settings
65
+ 5. **⚙️ Environment Setup**: Creates `.env` files with your credentials
66
+ 6. **📁 File Structure**: Copies all necessary boilerplate files and examples
67
+ 7. **🎨 Configuration**: Sets up Vite, Tailwind, and router configurations
68
+ 8. **📖 Documentation**: Provides example documentation and getting started guides
69
+
70
+ ### Upgrade Mode
71
+
72
+ If you need to upgrade an existing plugin's configuration without changing the plugin ID:
73
+
74
+ ```bash
75
+ yarn rimori-init --upgrade
68
76
  ```
69
77
 
70
- ### Vite Configuration
78
+ ### Development Setup
79
+
80
+ After initialization, start developing immediately:
81
+
82
+ ```bash
83
+ # Start development server
84
+ yarn dev
85
+
86
+ # Your plugin will be available at:
87
+ # http://localhost:3000 (or your chosen port)
88
+ ```
89
+
90
+ Rimori client comes pre-configured with:
91
+ - ✅ **Hot reload** for instant development feedback
92
+ - ✅ **TypeScript support** with full type safety
93
+ - ✅ **TailwindCSS** for modern styling
94
+ - ✅ **React Router** for navigation
95
+ - ✅ **Example components** and documentation
96
+
97
+ ## Releasing Your Plugin to Rimori
98
+
99
+ Publishing your plugin to the Rimori platform is streamlined through the built-in `rimori-release` CLI tool. The release process handles database updates, file uploads, and plugin activation automatically.
100
+
101
+ ### Prerequisites
102
+
103
+ 1. **Plugin must be initialized** - Use `rimori-init` first to set up your plugin
104
+ 2. **Build your plugin** - Ensure your plugin is built and the output is in the `dist/` directory
105
+ 3. **Environment configured** - Your `.env` file should contain `RIMORI_TOKEN` (set during initialization)
106
+
107
+ ### Quick Release (Recommended)
108
+
109
+ During plugin initialization, convenient release scripts are automatically added to your `package.json`. These scripts handle building and releasing in one command:
110
+
111
+ ```bash
112
+ # Quick release commands (build + release)
113
+ yarn release:alpha # Build and release to alpha channel
114
+ yarn release:beta # Build and release to beta channel
115
+ yarn release:stable # Build and release to stable channel
116
+ ```
117
+
118
+ ### Manual Release Process
119
+
120
+ If you prefer more control or need to understand the underlying process, you can use the `rimori-release` command directly:
121
+
122
+ ```bash
123
+ # Build your plugin first
124
+ yarn build
125
+
126
+ # Then release to different channels
127
+ yarn rimori-release alpha # For alpha testing
128
+ yarn rimori-release beta # For beta releases
129
+ yarn rimori-release stable # For production releases
130
+ ```
131
+
132
+ The plugin version is automatically read from your `package.json`, and the plugin ID is retrieved from the `r_id` field (set during initialization).
133
+
134
+ ### What the Release Script Does
135
+
136
+ The `rimori-release` command performs a complete release workflow:
137
+
138
+ 1. **📋 Configuration Upload**: Sends plugin metadata and configuration to the platform
139
+ 2. **🗄️ Database Updates**: Updates plugin information and release records
140
+ 3. **📁 File Upload**: Uploads all files from your `dist/` directory to the platform
141
+ 4. **🚀 Plugin Activation**: Activates the new version on the specified release channel
142
+
143
+ ### Release Channels
144
+
145
+ - **`alpha`**: Early development releases for internal testing
146
+ - **`beta`**: Pre-release versions for beta testers
147
+ - **`stable`**: Production-ready releases for all users
148
+
149
+ ### Automatic Configuration
150
+
151
+ During plugin initialization, the following are automatically configured:
152
+ - `RIMORI_TOKEN`: Your authentication token (stored in `.env`)
153
+ - `r_id`: Your unique plugin ID (stored in `package.json`)
154
+ - **Release scripts**: `yarn release:alpha`, `yarn release:beta`, `yarn release:stable`
155
+ - **Build configuration**: TypeScript checking, Vite setup, and worker builds
156
+
157
+ ### Troubleshooting
158
+
159
+ If you encounter release issues:
160
+
161
+ 1. **Missing token**: Ensure `RIMORI_TOKEN` is in your `.env` file
162
+ 2. **No plugin ID**: Verify `r_id` exists in your `package.json`
163
+ 3. **Build errors**: Run `yarn build` successfully before releasing
164
+ 4. **Authentication**: Your token may have expired - re-run `rimori-init` if needed
165
+
166
+
71
167
 
72
- Add the following to your `vite.config.ts`:
73
168
 
74
- ```javascript
75
- import { defineConfig } from 'vite'
76
- import react from '@vitejs/plugin-react'
77
169
 
78
- export default defineConfig({
79
- plugins: [react()],
80
- base: './', // Set base path for proper asset loading
81
- build: {
82
- outDir: 'dist',
83
- assetsDir: 'assets'
84
- }
85
- })
86
170
  ```
87
171
 
88
172
  ## Core API - usePlugin Hook
@@ -1013,5 +1097,4 @@ export default App;
1013
1097
  4. **Event Cleanup**: Always unsubscribe from events in useEffect cleanup
1014
1098
  5. **Responsive Design**: Use TailwindCSS classes for responsive layouts
1015
1099
 
1016
- ## License
1017
1100
 
@@ -0,0 +1,35 @@
1
+ export interface UserCredentials {
2
+ email: string;
3
+ password: string;
4
+ }
5
+ export interface DeveloperRegisterResponse {
6
+ plugin_id: string;
7
+ access_token: string;
8
+ }
9
+ /**
10
+ * Prompts user for email and password credentials.
11
+ * @returns Promise resolving to user credentials.
12
+ */
13
+ export declare function askForCredentials(): Promise<UserCredentials>;
14
+ /**
15
+ * Prompts user for development port with default value.
16
+ * @returns Promise resolving to the selected port.
17
+ */
18
+ export declare function askForPort(): Promise<number>;
19
+ /**
20
+ * Authenticates with Supabase using email and password.
21
+ * @param param
22
+ * @param param.email - User email address.
23
+ * @param param.password - User password.
24
+ * @returns Promise resolving to JWT access token.
25
+ * @throws {Error} if authentication fails.
26
+ */
27
+ export declare function authenticateWithSupabase({ email, password, }: UserCredentials): Promise<string>;
28
+ /**
29
+ * Registers developer and gets plugin credentials from the backend.
30
+ * @param jwtToken - JWT token from Supabase authentication.
31
+ * @param port - Development port for the plugin.
32
+ * @returns Promise resolving to plugin ID and access token.
33
+ * @throws {Error} if registration request fails.
34
+ */
35
+ export declare function registerDeveloper(jwtToken: string, port: number): Promise<DeveloperRegisterResponse>;
@@ -0,0 +1,175 @@
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 path from 'path';
12
+ import * as readline from 'readline';
13
+ import { DEFAULT_ANON_KEY, DEFAULT_ENDPOINT } from '../../../utils/endpoint.js';
14
+ /**
15
+ * Prompts user for email and password credentials.
16
+ * @returns Promise resolving to user credentials.
17
+ */
18
+ export function askForCredentials() {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const rl = readline.createInterface({
21
+ input: process.stdin,
22
+ output: process.stdout,
23
+ });
24
+ return new Promise((resolve) => {
25
+ rl.question('Enter your email: ', (email) => {
26
+ rl.close();
27
+ // Create a new interface for password input with muted output
28
+ const passwordRl = readline.createInterface({
29
+ input: process.stdin,
30
+ output: process.stdout,
31
+ terminal: false
32
+ });
33
+ process.stdout.write('Enter your password: ');
34
+ // Set up stdin for raw input
35
+ process.stdin.setRawMode(true);
36
+ process.stdin.resume();
37
+ let password = '';
38
+ const onData = (buffer) => {
39
+ const char = buffer.toString('utf8');
40
+ if (char === '\r' || char === '\n') {
41
+ // Enter pressed
42
+ process.stdin.setRawMode(false);
43
+ process.stdin.pause();
44
+ process.stdin.removeListener('data', onData);
45
+ process.stdout.write('\n');
46
+ passwordRl.close();
47
+ resolve({ email: email.trim(), password: password.trim() });
48
+ }
49
+ else if (char === '\u0003') {
50
+ // Ctrl+C
51
+ process.stdin.setRawMode(false);
52
+ process.stdin.pause();
53
+ process.stdin.removeListener('data', onData);
54
+ process.stdout.write('\n');
55
+ process.exit(0);
56
+ }
57
+ else if (char === '\u007f' || char === '\b') {
58
+ // Backspace
59
+ if (password.length > 0) {
60
+ password = password.slice(0, -1);
61
+ process.stdout.write('\b \b');
62
+ }
63
+ }
64
+ else if (char.charCodeAt(0) >= 32 && char.charCodeAt(0) <= 126) {
65
+ // Printable characters
66
+ password += char;
67
+ process.stdout.write('*');
68
+ }
69
+ };
70
+ process.stdin.on('data', onData);
71
+ });
72
+ });
73
+ });
74
+ }
75
+ /**
76
+ * Prompts user for development port with default value.
77
+ * @returns Promise resolving to the selected port.
78
+ */
79
+ export function askForPort() {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const rl = readline.createInterface({
82
+ input: process.stdin,
83
+ output: process.stdout,
84
+ });
85
+ return new Promise((resolve) => {
86
+ rl.question('Enter development port (default: 3000): ', (answer) => {
87
+ rl.close();
88
+ const port = answer.trim() || '3000';
89
+ // Validate port is a number
90
+ const portNumber = parseInt(port, 10);
91
+ if (isNaN(portNumber) || portNumber < 1 || portNumber > 65535) {
92
+ console.error('Error: Port must be a valid number between 1 and 65535');
93
+ process.exit(1);
94
+ }
95
+ resolve(portNumber);
96
+ });
97
+ });
98
+ });
99
+ }
100
+ /**
101
+ * Authenticates with Supabase using email and password.
102
+ * @param param
103
+ * @param param.email - User email address.
104
+ * @param param.password - User password.
105
+ * @returns Promise resolving to JWT access token.
106
+ * @throws {Error} if authentication fails.
107
+ */
108
+ export function authenticateWithSupabase(_a) {
109
+ return __awaiter(this, arguments, void 0, function* ({ email, password, }) {
110
+ var _b;
111
+ console.log('🔐 Authenticating with Supabase...');
112
+ // Initialize Supabase client (you may need to adjust the URL and key)
113
+ const supabaseUrl = process.env.SUPABASE_URL || DEFAULT_ENDPOINT;
114
+ const supabaseKey = process.env.SUPABASE_ANON_KEY || DEFAULT_ANON_KEY;
115
+ const supabase = createClient(supabaseUrl, supabaseKey);
116
+ try {
117
+ const { data, error } = yield supabase.auth.signInWithPassword({
118
+ email,
119
+ password,
120
+ });
121
+ if (error) {
122
+ throw new Error(`Authentication failed: ${error.message}`);
123
+ }
124
+ if (!((_b = data.session) === null || _b === void 0 ? void 0 : _b.access_token)) {
125
+ throw new Error('No access token received from authentication');
126
+ }
127
+ console.log('✅ Supabase authentication successful!');
128
+ return data.session.access_token;
129
+ }
130
+ catch (error) {
131
+ throw new Error(`Supabase authentication failed: ${error}`);
132
+ }
133
+ });
134
+ }
135
+ /**
136
+ * Registers developer and gets plugin credentials from the backend.
137
+ * @param jwtToken - JWT token from Supabase authentication.
138
+ * @param port - Development port for the plugin.
139
+ * @returns Promise resolving to plugin ID and access token.
140
+ * @throws {Error} if registration request fails.
141
+ */
142
+ export function registerDeveloper(jwtToken, port) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ console.log('🚀 Registering developer and creating plugin...');
145
+ try {
146
+ console.log('port', port, typeof port);
147
+ const currentFolderName = path.basename(process.cwd());
148
+ const body = { port, pluginName: currentFolderName };
149
+ const backendUrl = process.env.RIMORI_BACKEND_URL || "https://api.rimori.se";
150
+ const response = yield fetch(backendUrl + '/developer/register', {
151
+ method: 'POST',
152
+ headers: {
153
+ 'Content-Type': 'application/json',
154
+ 'Authorization': `Bearer ${jwtToken}`,
155
+ },
156
+ body: JSON.stringify(body),
157
+ });
158
+ if (!response.ok) {
159
+ console.error(yield response.text());
160
+ throw new Error(`HTTP error! status: ${response.status}`);
161
+ }
162
+ const data = yield response.json();
163
+ if (!data.plugin_id || !data.access_token) {
164
+ throw new Error('Invalid response: missing pluginId or access_token');
165
+ }
166
+ console.log('✅ Plugin registration successful!');
167
+ console.log(`Plugin ID: ${data.plugin_id}`);
168
+ return data;
169
+ }
170
+ catch (error) {
171
+ console.error(error);
172
+ throw new Error(`Developer registration failed: ${error}`);
173
+ }
174
+ });
175
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Creates or updates the .env file with the plugin token.
3
+ * @param token - The plugin authentication token.
4
+ */
5
+ export declare function setupEnvFile(token: string): void;
6
+ /**
7
+ * Updates .gitignore to exclude .env files.
8
+ */
9
+ export declare function updateGitignore(): void;
@@ -0,0 +1,43 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ /**
4
+ * Creates or updates the .env file with the plugin token.
5
+ * @param token - The plugin authentication token.
6
+ */
7
+ export function setupEnvFile(token) {
8
+ const envPath = path.resolve('.env');
9
+ if (!fs.existsSync(envPath)) {
10
+ const envContent = `RIMORI_TOKEN=${token}\n`;
11
+ fs.writeFileSync(envPath, envContent, 'utf8');
12
+ console.log('Created .env file with RIMORI_TOKEN');
13
+ }
14
+ else {
15
+ console.log('.env file already exists, skipping creation');
16
+ }
17
+ }
18
+ /**
19
+ * Updates .gitignore to exclude .env files.
20
+ */
21
+ export function updateGitignore() {
22
+ const gitignorePath = path.resolve('.gitignore');
23
+ let gitignoreContent = '';
24
+ let needsUpdate = false;
25
+ if (fs.existsSync(gitignorePath)) {
26
+ gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
27
+ // Check if .env is already in .gitignore
28
+ if (!gitignoreContent.includes('.env')) {
29
+ needsUpdate = true;
30
+ }
31
+ }
32
+ else {
33
+ needsUpdate = true;
34
+ }
35
+ if (needsUpdate) {
36
+ gitignoreContent += '\n.env\npublic/web-worker.js\n';
37
+ fs.writeFileSync(gitignorePath, gitignoreContent, 'utf8');
38
+ console.log('Added .env to .gitignore');
39
+ }
40
+ else {
41
+ console.log('.env already in .gitignore, skipping update');
42
+ }
43
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Copies necessary files and creates directories for the plugin setup.
3
+ */
4
+ export declare function copyPluginFiles(): void;
@@ -0,0 +1,51 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { dirname } from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ // ES module equivalent of __dirname
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ /**
9
+ * Configuration mapping source files to destination files.
10
+ * Key: Source path relative to __dirname
11
+ * Value: Destination path relative to current working directory
12
+ */
13
+ const FILE_COPY_MAP = {
14
+ '../../../../example/rimori.config.ts': './rimori/rimori.config.ts',
15
+ '../../../../README.md': './rimori/readme.md',
16
+ '../../../../example/docs/overview.md': './public/docs/overview.md',
17
+ '../../../../example/docs/devdocs.md': './public/docs/devdocs.md',
18
+ '../../../../example/docs/userdocs.md': './public/docs/userdocs.md',
19
+ '../../../../example/worker/worker.ts': './worker/worker.ts',
20
+ '../../../../example/worker/vite.config.ts': './worker/vite.config.ts',
21
+ };
22
+ /**
23
+ * Copies necessary files and creates directories for the plugin setup.
24
+ */
25
+ export function copyPluginFiles() {
26
+ console.log('Copying plugin files...');
27
+ for (const [srcRelativePath, destRelativePath] of Object.entries(FILE_COPY_MAP)) {
28
+ const srcPath = path.resolve(__dirname, srcRelativePath);
29
+ const destPath = path.resolve(destRelativePath);
30
+ const destDir = path.dirname(destPath);
31
+ // Check if source file exists
32
+ if (!fs.existsSync(srcPath)) {
33
+ console.log(`Warning: Source file not found: ${srcPath}`);
34
+ continue;
35
+ }
36
+ // Create destination directory if it doesn't exist
37
+ if (!fs.existsSync(destDir)) {
38
+ console.log(`Creating directory: ${destDir}`);
39
+ fs.mkdirSync(destDir, { recursive: true });
40
+ }
41
+ // Only copy if destination file doesn't exist
42
+ if (!fs.existsSync(destPath)) {
43
+ fs.copyFileSync(srcPath, destPath);
44
+ console.log(`Copied: ${srcRelativePath} -> ${destRelativePath}`);
45
+ }
46
+ else {
47
+ console.log(`File already exists, skipping: ${destRelativePath}`);
48
+ }
49
+ }
50
+ console.log('Plugin file copying completed.');
51
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Processes HTML files to remove unwanted meta tags.
3
+ */
4
+ export declare function cleanHtmlMetaTags(): void;
@@ -0,0 +1,38 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ /**
4
+ * Removes all meta tags from HTML content except viewport and charset.
5
+ * @param htmlContent - The HTML content to process.
6
+ * @returns The processed HTML content with unwanted meta tags removed.
7
+ */
8
+ function removeUnwantedMetaTags(htmlContent) {
9
+ // Remove all meta tags except those with name="viewport" or charset attribute
10
+ let cleanedContent = htmlContent.replace(/<meta\s+(?![^>]*(?:name\s*=\s*["']viewport["']|charset\s*=))[^>]*>/gi, '');
11
+ // Remove empty lines left behind
12
+ cleanedContent = cleanedContent.replace(/^\s*[\r\n]/gm, '');
13
+ return cleanedContent;
14
+ }
15
+ /**
16
+ * Processes HTML files to remove unwanted meta tags.
17
+ */
18
+ export function cleanHtmlMetaTags() {
19
+ const filePath = path.resolve('./index.html');
20
+ if (!filePath.endsWith('.html')) {
21
+ return;
22
+ }
23
+ if (!fs.existsSync(filePath)) {
24
+ console.log(`Warning: HTML file not found: ${filePath}`);
25
+ return;
26
+ }
27
+ try {
28
+ const content = fs.readFileSync(filePath, 'utf8');
29
+ const cleanedContent = removeUnwantedMetaTags(content);
30
+ if (content !== cleanedContent) {
31
+ fs.writeFileSync(filePath, cleanedContent, 'utf8');
32
+ console.log(`Cleaned meta tags in: ${filePath}`);
33
+ }
34
+ }
35
+ catch (error) {
36
+ console.error(`Error processing HTML file ${filePath}:`, error);
37
+ }
38
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};