@maravilla-labs/vite-plugin 0.3.3 → 0.3.4
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 +11 -4
- package/dist/index.d.ts +15 -2
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -66,10 +66,7 @@ const users = await platform.env.DB.find('users', {});
|
|
|
66
66
|
|
|
67
67
|
## How It Works
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
1. **Environment Configuration**: Sets environment variables that `@solutas/platform` uses to connect to the dev server
|
|
72
|
-
2. **SSR Context Management**: Ensures platform instances are properly managed during server-side rendering
|
|
69
|
+
Configures your Vite dev server so platform routes (auth pages, assets, realtime, API) work alongside your framework's dev server. With the plugin in place, your app uses plain relative URLs (`/_auth/login`, `/api/kv`) and they reach the platform server transparently.
|
|
73
70
|
|
|
74
71
|
```mermaid
|
|
75
72
|
graph LR
|
|
@@ -93,6 +90,16 @@ graph LR
|
|
|
93
90
|
- **Default**: `'dev-tenant'`
|
|
94
91
|
- **Description**: Tenant ID for development (useful for multi-tenant testing)
|
|
95
92
|
|
|
93
|
+
### `additionalProxies`
|
|
94
|
+
- **Type**: `string[]`
|
|
95
|
+
- **Default**: `[]`
|
|
96
|
+
- **Description**: Extra URL prefixes to forward to the platform dev server, in addition to the built-in defaults. Use this if your app exposes custom routes the platform owns.
|
|
97
|
+
|
|
98
|
+
### `disableProxy`
|
|
99
|
+
- **Type**: `boolean`
|
|
100
|
+
- **Default**: `false`
|
|
101
|
+
- **Description**: Opt out of the dev-server proxy. Useful if you route platform requests through some other mechanism.
|
|
102
|
+
|
|
96
103
|
## Framework Examples
|
|
97
104
|
|
|
98
105
|
### SvelteKit
|
package/dist/index.d.ts
CHANGED
|
@@ -61,15 +61,28 @@ declare function createPlatformClient(baseUrl: string, tenant?: string): Platfor
|
|
|
61
61
|
|
|
62
62
|
interface MaravillaPluginOptions {
|
|
63
63
|
/**
|
|
64
|
-
* URL of the Maravilla dev server
|
|
64
|
+
* URL of the Maravilla dev server. Used both for env-var injection and
|
|
65
|
+
* as the proxy target for `/_auth`, `/_assets`, `/_rt`, and `/api`.
|
|
65
66
|
* @default 'http://localhost:3001'
|
|
66
67
|
*/
|
|
67
68
|
devServerUrl?: string;
|
|
68
69
|
/**
|
|
69
|
-
* Tenant ID for development
|
|
70
|
+
* Tenant ID for development.
|
|
70
71
|
* @default 'dev-tenant'
|
|
71
72
|
*/
|
|
72
73
|
tenant?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Extra URL prefixes to forward to the platform dev server, in addition
|
|
76
|
+
* to the defaults (`/_auth`, `/_assets`, `/_rt`, `/api`). Each prefix is
|
|
77
|
+
* proxied with `changeOrigin: true`. Use this for custom platform routes.
|
|
78
|
+
*/
|
|
79
|
+
additionalProxies?: string[];
|
|
80
|
+
/**
|
|
81
|
+
* Disable the dev-server proxy entirely. Useful if your project routes
|
|
82
|
+
* platform requests through some other mechanism.
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
disableProxy?: boolean;
|
|
73
86
|
}
|
|
74
87
|
declare function maravilla(options?: MaravillaPluginOptions): Plugin;
|
|
75
88
|
|
package/dist/index.js
CHANGED
|
@@ -257,17 +257,35 @@ function createPlatformClient(baseUrl, tenant) {
|
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
// src/index.ts
|
|
260
|
+
var DEFAULT_PROXY_PREFIXES = ["/_auth", "/_assets", "/_rt", "/api"];
|
|
260
261
|
function maravilla(options = {}) {
|
|
261
262
|
const devServerUrl = options.devServerUrl || "http://localhost:3001";
|
|
262
263
|
const tenant = options.tenant || "dev-tenant";
|
|
264
|
+
const disableProxy = options.disableProxy ?? false;
|
|
265
|
+
const additionalProxies = options.additionalProxies ?? [];
|
|
263
266
|
return {
|
|
264
267
|
name: "vite-plugin-maravilla",
|
|
268
|
+
config() {
|
|
269
|
+
if (disableProxy) return void 0;
|
|
270
|
+
const proxy = {};
|
|
271
|
+
for (const prefix of [...DEFAULT_PROXY_PREFIXES, ...additionalProxies]) {
|
|
272
|
+
proxy[prefix] = {
|
|
273
|
+
target: devServerUrl,
|
|
274
|
+
changeOrigin: true,
|
|
275
|
+
ws: prefix === "/_rt"
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
return { server: { proxy } };
|
|
279
|
+
},
|
|
265
280
|
configureServer(server) {
|
|
266
281
|
process.env.MARAVILLA_DEV_SERVER = devServerUrl;
|
|
267
282
|
process.env.MARAVILLA_TENANT = tenant;
|
|
268
283
|
console.log(`[maravilla] Platform APIs configured for ${devServerUrl}`);
|
|
269
284
|
console.log("[maravilla] Using tenant:", tenant);
|
|
270
|
-
|
|
285
|
+
if (!disableProxy) {
|
|
286
|
+
const proxied = [...DEFAULT_PROXY_PREFIXES, ...additionalProxies].join(", ");
|
|
287
|
+
console.log(`[maravilla] Proxying ${proxied} \u2192 ${devServerUrl}`);
|
|
288
|
+
}
|
|
271
289
|
server.ssrLoadModule = new Proxy(server.ssrLoadModule, {
|
|
272
290
|
async apply(target, thisArg, args) {
|
|
273
291
|
const result = await Reflect.apply(target, thisArg, args);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/functions.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["import type { Plugin, ViteDevServer } from 'vite';\nimport { buildFunctions, developmentServer } from '@maravilla-labs/functions';\nimport { join } from 'node:path';\n\nexport interface FunctionsPluginOptions {\n functionsDir?: string;\n functionsPort?: number;\n watch?: boolean;\n}\n\n/**\n * Vite plugin for Maravilla functions development\n * Handles building and serving functions with hot reload\n */\nexport function maravillaFunctions(options: FunctionsPluginOptions = {}): Plugin {\n const {\n functionsDir = 'functions',\n functionsPort = 3003,\n watch = true,\n } = options;\n\n let functionsBundle: any = null;\n let cleanupWatcher: (() => void) | null = null;\n\n return {\n name: 'vite-plugin-maravilla-functions',\n \n async configureServer(server: ViteDevServer) {\n const resolvedFunctionsDir = join(server.config.root, functionsDir);\n \n // Check if functions directory exists\n try {\n await import('node:fs/promises').then(fs => fs.access(resolvedFunctionsDir));\n } catch {\n console.log(`[maravilla-functions] No functions directory found at ${resolvedFunctionsDir}`);\n return;\n }\n\n console.log(`[maravilla-functions] Found functions at ${resolvedFunctionsDir}`);\n\n // Build functions initially\n try {\n functionsBundle = await buildFunctions({\n functionsDir: resolvedFunctionsDir,\n outputDir: join(server.config.root, '.maravilla/functions-dev'),\n production: false,\n minify: false,\n });\n\n console.log(`[maravilla-functions] Built ${functionsBundle.functions} functions:`);\n functionsBundle.routes.forEach((route: any) => {\n console.log(` ${route.path} → ${route.name} (${route.methods.join(', ')})`);\n });\n } catch (error) {\n console.error('[maravilla-functions] Build failed:', error);\n return;\n }\n\n // Set up dev server with watcher\n if (watch) {\n const cleanup = await developmentServer({\n functionsDir: resolvedFunctionsDir,\n outputDir: join(server.config.root, '.maravilla/functions-dev'),\n watch: true,\n onRebuild: async () => {\n // Reload functions bundle\n functionsBundle = await buildFunctions({\n functionsDir: resolvedFunctionsDir,\n outputDir: join(server.config.root, '.maravilla/functions-dev'),\n production: false,\n minify: false,\n });\n \n // Notify Vite of the change\n server.ws.send({\n type: 'custom',\n event: 'maravilla:functions-reload',\n data: { routes: functionsBundle.routes }\n });\n }\n });\n cleanupWatcher = cleanup || null;\n }\n\n // Add middleware to handle function requests\n server.middlewares.use(async (req, res, next) => {\n // Only handle /api routes\n if (!req.url?.startsWith('/api')) {\n return next();\n }\n\n // Check if this matches a function route\n const matchedRoute = functionsBundle?.routes.find((route: any) => {\n const routePath = route.path;\n const requestPath = req.url?.split('?')[0];\n return routePath === requestPath || \n (routePath === '/api' && requestPath === '/api') ||\n (routePath === '/api' && requestPath === '/api/');\n });\n\n if (!matchedRoute) {\n return next();\n }\n\n // Check if method is allowed\n const method = req.method?.toUpperCase() || 'GET';\n if (!matchedRoute.methods.includes(method)) {\n res.statusCode = 405;\n res.setHeader('Allow', matchedRoute.methods.join(', '));\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({\n error: 'Method not allowed',\n allowed: matchedRoute.methods\n }));\n return;\n }\n\n console.log(`[maravilla-functions] ${method} ${req.url} → ${matchedRoute.name}`);\n\n // For now, execute the function in a simple way\n // In production, this would use the V8 isolate runtime\n try {\n const functionModule = await import(\n join(server.config.root, '.maravilla/functions-dev/functions.js')\n );\n\n // Create a mock Request object\n const url = new URL(req.url!, `http://localhost:${server.config.server?.port || 5173}`);\n const headers = new Headers();\n Object.entries(req.headers).forEach(([key, value]) => {\n if (typeof value === 'string') {\n headers.append(key, value);\n } else if (Array.isArray(value)) {\n value.forEach(v => headers.append(key, v));\n }\n });\n\n // Get body if present\n let body = null;\n if (req.method && ['POST', 'PUT', 'PATCH'].includes(req.method)) {\n const MAX_BODY_SIZE = 10 * 1024 * 1024; // 10MB\n body = await new Promise<string>((resolve, reject) => {\n let data = '';\n let size = 0;\n req.on('data', (chunk: Buffer | string) => {\n size += typeof chunk === 'string' ? Buffer.byteLength(chunk) : chunk.length;\n if (size > MAX_BODY_SIZE) {\n req.destroy(new Error('Request body too large'));\n reject(new Error('Request body too large'));\n return;\n }\n data += chunk;\n });\n req.on('end', () => resolve(data));\n req.on('error', reject);\n }).catch((err) => {\n res.statusCode = 413;\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({ error: 'Payload too large', message: err.message }));\n return null;\n });\n if (body === null) return;\n }\n\n const request = {\n url: url.toString(),\n method: req.method || 'GET',\n headers,\n json: body ? () => Promise.resolve(JSON.parse(body)) : undefined,\n text: () => Promise.resolve(body || ''),\n };\n\n // Call the function handler\n const response = await functionModule.handleFunctionRequest(request);\n\n // Send response\n res.statusCode = response.status || 200;\n Object.entries(response.headers || {}).forEach(([key, value]) => {\n res.setHeader(key, value as string);\n });\n \n if (response instanceof Response) {\n const responseBody = await response.text();\n res.end(responseBody);\n } else {\n res.end(JSON.stringify(response));\n }\n } catch (error: any) {\n console.error('[maravilla-functions] Execution error:', error);\n res.statusCode = 500;\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({\n error: 'Function execution failed',\n message: error.message,\n stack: process.env.NODE_ENV === 'development' ? error.stack : undefined\n }));\n }\n });\n },\n\n async closeBundle() {\n if (cleanupWatcher) {\n cleanupWatcher();\n }\n }\n };\n}","/**\n * Platform client for communicating with the dev server\n */\n\nexport interface PlatformClient {\n kv: KvClient;\n db: DbClient;\n}\n\nexport interface KvClient {\n get(namespace: string, key: string): Promise<any>;\n put(namespace: string, key: string, value: any, ttl?: number): Promise<void>;\n delete(namespace: string, key: string): Promise<void>;\n list(namespace: string, options?: KvListOptions): Promise<KvListResponse>;\n}\n\nexport interface DbClient {\n find(collection: string, filter?: any, options?: DbFindOptions): Promise<any[]>;\n findOne(collection: string, filter: any): Promise<any | null>;\n insertOne(collection: string, document: any): Promise<string>;\n updateOne(collection: string, filter: any, update: any): Promise<{ modified: number }>;\n deleteOne(collection: string, filter: any): Promise<{ deleted: number }>;\n}\n\nexport interface KvListOptions {\n prefix?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface KvListResponse {\n success: boolean;\n result: Array<{ name: string; expiration?: number; metadata?: any }>;\n result_info: {\n count: number;\n cursor?: string;\n };\n}\n\nexport interface DbFindOptions {\n limit?: number;\n skip?: number;\n sort?: any;\n}\n\nexport function createPlatformClient(baseUrl: string, tenant?: string): PlatformClient {\n const tenantId = tenant || 'dev-tenant';\n const headers = {\n 'Content-Type': 'application/json',\n 'X-Tenant-Id': tenantId,\n };\n\n const fetchWithError = async (url: string, options: RequestInit = {}) => {\n try {\n const response = await fetch(url, {\n ...options,\n headers: {\n ...headers,\n ...options.headers,\n },\n });\n\n if (!response.ok && response.status !== 404) {\n const error = await response.text();\n throw new Error(`Platform API error: ${response.status} - ${error}`);\n }\n\n return response;\n } catch (error) {\n if (error instanceof TypeError && error.message.includes('fetch')) {\n throw new Error(\n `Failed to connect to Maravilla dev server at ${baseUrl}. ` +\n 'Please ensure the dev server is running (cargo run -p dev-server)'\n );\n }\n throw error;\n }\n };\n\n const kv: KvClient = {\n async get(namespace: string, key: string) {\n const response = await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`);\n if (response.status === 404) return null;\n return response.json();\n },\n\n async put(namespace: string, key: string, value: any, ttl?: number) {\n const requestHeaders: Record<string, string> = { ...headers };\n if (ttl) {\n requestHeaders['X-TTL'] = ttl.toString();\n }\n\n await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`, {\n method: 'PUT',\n headers: requestHeaders,\n body: JSON.stringify(value),\n });\n },\n\n async delete(namespace: string, key: string) {\n await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`, {\n method: 'DELETE',\n });\n },\n\n async list(namespace: string, options: KvListOptions = {}) {\n const response = await fetchWithError(`${baseUrl}/api/kv/${namespace}`, {\n method: 'POST',\n body: JSON.stringify(options),\n });\n return response.json() as Promise<KvListResponse>;\n },\n };\n\n const db: DbClient = {\n async find(collection: string, filter: any = {}, options: DbFindOptions = {}) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}`, {\n method: 'POST',\n body: JSON.stringify({ filter, options }),\n });\n return response.json() as Promise<any[]>;\n },\n\n async findOne(collection: string, filter: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}/findOne`, {\n method: 'POST',\n body: JSON.stringify(filter),\n });\n if (response.status === 404) return null;\n return response.json();\n },\n\n async insertOne(collection: string, document: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}`, {\n method: 'PUT',\n body: JSON.stringify(document),\n });\n const result = await response.json() as { id: string };\n return result.id;\n },\n\n async updateOne(collection: string, filter: any, update: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}/update`, {\n method: 'POST',\n body: JSON.stringify({ filter, update }),\n });\n return response.json() as Promise<{ modified: number }>;\n },\n\n async deleteOne(collection: string, filter: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}/delete`, {\n method: 'DELETE',\n body: JSON.stringify(filter),\n });\n return response.json() as Promise<{ deleted: number }>;\n },\n };\n\n return { kv, db };\n}","import type { Plugin } from 'vite';\n\nexport interface MaravillaPluginOptions {\n /**\n * URL of the Maravilla dev server\n * @default 'http://localhost:3001'\n */\n devServerUrl?: string;\n \n /**\n * Tenant ID for development\n * @default 'dev-tenant'\n */\n tenant?: string;\n}\n\nexport function maravilla(options: MaravillaPluginOptions = {}): Plugin {\n const devServerUrl = options.devServerUrl || 'http://localhost:3001';\n const tenant = options.tenant || 'dev-tenant';\n\n return {\n name: 'vite-plugin-maravilla',\n \n configureServer(server) {\n // Set environment variables that @maravilla/platform will use\n process.env.MARAVILLA_DEV_SERVER = devServerUrl;\n process.env.MARAVILLA_TENANT = tenant;\n \n console.log(`[maravilla] Platform APIs configured for ${devServerUrl}`);\n console.log('[maravilla] Using tenant:', tenant);\n console.log('[maravilla] Apps should use @maravilla/platform to access services');\n \n // Hook into SSR module resolution to ensure platform is available\n server.ssrLoadModule = new Proxy(server.ssrLoadModule, {\n async apply(target, thisArg, args) {\n const result = await Reflect.apply(target, thisArg, args);\n \n // Clear platform cache before each SSR module load to ensure fresh instance\n if ((globalThis as any).__maravilla_platform) {\n delete (globalThis as any).__maravilla_platform;\n }\n \n return result;\n }\n });\n }\n };\n}\n\n// Functions plugin\nexport { maravillaFunctions } from './functions.js';\nexport type { FunctionsPluginOptions } from './functions.js';\n\n// Legacy exports for backwards compatibility\nexport { createPlatformClient } from './client.js';\nexport type { PlatformClient, KvClient, DbClient } from './client.js';"],"mappings":";AACA,SAAS,gBAAgB,yBAAyB;AAClD,SAAS,YAAY;AAYd,SAAS,mBAAmB,UAAkC,CAAC,GAAW;AAC/E,QAAM;AAAA,IACJ,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,QAAQ;AAAA,EACV,IAAI;AAEJ,MAAI,kBAAuB;AAC3B,MAAI,iBAAsC;AAE1C,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,MAAM,gBAAgB,QAAu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AA6B,MAAM;AAC/C,cAAQ,IAAI,oEAAoE;AAGhF,aAAO,gBAAgB,IAAI,MAAM,OAAO,eAAe;AAAA,QACrD,MAAM,MAAM,QAAQ,SAAS,MAAM;AACjC,gBAAM,SAAS,MAAM,QAAQ,MAAM,QAAQ,SAAS,IAAI;AAGxD,cAAK,WAAmB,sBAAsB;AAC5C,mBAAQ,WAAmB;AAAA,UAC7B;AAEA,iBAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/functions.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["import type { Plugin, ViteDevServer } from 'vite';\nimport { buildFunctions, developmentServer } from '@maravilla-labs/functions';\nimport { join } from 'node:path';\n\nexport interface FunctionsPluginOptions {\n functionsDir?: string;\n functionsPort?: number;\n watch?: boolean;\n}\n\n/**\n * Vite plugin for Maravilla functions development\n * Handles building and serving functions with hot reload\n */\nexport function maravillaFunctions(options: FunctionsPluginOptions = {}): Plugin {\n const {\n functionsDir = 'functions',\n functionsPort = 3003,\n watch = true,\n } = options;\n\n let functionsBundle: any = null;\n let cleanupWatcher: (() => void) | null = null;\n\n return {\n name: 'vite-plugin-maravilla-functions',\n \n async configureServer(server: ViteDevServer) {\n const resolvedFunctionsDir = join(server.config.root, functionsDir);\n \n // Check if functions directory exists\n try {\n await import('node:fs/promises').then(fs => fs.access(resolvedFunctionsDir));\n } catch {\n console.log(`[maravilla-functions] No functions directory found at ${resolvedFunctionsDir}`);\n return;\n }\n\n console.log(`[maravilla-functions] Found functions at ${resolvedFunctionsDir}`);\n\n // Build functions initially\n try {\n functionsBundle = await buildFunctions({\n functionsDir: resolvedFunctionsDir,\n outputDir: join(server.config.root, '.maravilla/functions-dev'),\n production: false,\n minify: false,\n });\n\n console.log(`[maravilla-functions] Built ${functionsBundle.functions} functions:`);\n functionsBundle.routes.forEach((route: any) => {\n console.log(` ${route.path} → ${route.name} (${route.methods.join(', ')})`);\n });\n } catch (error) {\n console.error('[maravilla-functions] Build failed:', error);\n return;\n }\n\n // Set up dev server with watcher\n if (watch) {\n const cleanup = await developmentServer({\n functionsDir: resolvedFunctionsDir,\n outputDir: join(server.config.root, '.maravilla/functions-dev'),\n watch: true,\n onRebuild: async () => {\n // Reload functions bundle\n functionsBundle = await buildFunctions({\n functionsDir: resolvedFunctionsDir,\n outputDir: join(server.config.root, '.maravilla/functions-dev'),\n production: false,\n minify: false,\n });\n \n // Notify Vite of the change\n server.ws.send({\n type: 'custom',\n event: 'maravilla:functions-reload',\n data: { routes: functionsBundle.routes }\n });\n }\n });\n cleanupWatcher = cleanup || null;\n }\n\n // Add middleware to handle function requests\n server.middlewares.use(async (req, res, next) => {\n // Only handle /api routes\n if (!req.url?.startsWith('/api')) {\n return next();\n }\n\n // Check if this matches a function route\n const matchedRoute = functionsBundle?.routes.find((route: any) => {\n const routePath = route.path;\n const requestPath = req.url?.split('?')[0];\n return routePath === requestPath || \n (routePath === '/api' && requestPath === '/api') ||\n (routePath === '/api' && requestPath === '/api/');\n });\n\n if (!matchedRoute) {\n return next();\n }\n\n // Check if method is allowed\n const method = req.method?.toUpperCase() || 'GET';\n if (!matchedRoute.methods.includes(method)) {\n res.statusCode = 405;\n res.setHeader('Allow', matchedRoute.methods.join(', '));\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({\n error: 'Method not allowed',\n allowed: matchedRoute.methods\n }));\n return;\n }\n\n console.log(`[maravilla-functions] ${method} ${req.url} → ${matchedRoute.name}`);\n\n // For now, execute the function in a simple way\n // In production, this would use the V8 isolate runtime\n try {\n const functionModule = await import(\n join(server.config.root, '.maravilla/functions-dev/functions.js')\n );\n\n // Create a mock Request object\n const url = new URL(req.url!, `http://localhost:${server.config.server?.port || 5173}`);\n const headers = new Headers();\n Object.entries(req.headers).forEach(([key, value]) => {\n if (typeof value === 'string') {\n headers.append(key, value);\n } else if (Array.isArray(value)) {\n value.forEach(v => headers.append(key, v));\n }\n });\n\n // Get body if present\n let body = null;\n if (req.method && ['POST', 'PUT', 'PATCH'].includes(req.method)) {\n const MAX_BODY_SIZE = 10 * 1024 * 1024; // 10MB\n body = await new Promise<string>((resolve, reject) => {\n let data = '';\n let size = 0;\n req.on('data', (chunk: Buffer | string) => {\n size += typeof chunk === 'string' ? Buffer.byteLength(chunk) : chunk.length;\n if (size > MAX_BODY_SIZE) {\n req.destroy(new Error('Request body too large'));\n reject(new Error('Request body too large'));\n return;\n }\n data += chunk;\n });\n req.on('end', () => resolve(data));\n req.on('error', reject);\n }).catch((err) => {\n res.statusCode = 413;\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({ error: 'Payload too large', message: err.message }));\n return null;\n });\n if (body === null) return;\n }\n\n const request = {\n url: url.toString(),\n method: req.method || 'GET',\n headers,\n json: body ? () => Promise.resolve(JSON.parse(body)) : undefined,\n text: () => Promise.resolve(body || ''),\n };\n\n // Call the function handler\n const response = await functionModule.handleFunctionRequest(request);\n\n // Send response\n res.statusCode = response.status || 200;\n Object.entries(response.headers || {}).forEach(([key, value]) => {\n res.setHeader(key, value as string);\n });\n \n if (response instanceof Response) {\n const responseBody = await response.text();\n res.end(responseBody);\n } else {\n res.end(JSON.stringify(response));\n }\n } catch (error: any) {\n console.error('[maravilla-functions] Execution error:', error);\n res.statusCode = 500;\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({\n error: 'Function execution failed',\n message: error.message,\n stack: process.env.NODE_ENV === 'development' ? error.stack : undefined\n }));\n }\n });\n },\n\n async closeBundle() {\n if (cleanupWatcher) {\n cleanupWatcher();\n }\n }\n };\n}","/**\n * Platform client for communicating with the dev server\n */\n\nexport interface PlatformClient {\n kv: KvClient;\n db: DbClient;\n}\n\nexport interface KvClient {\n get(namespace: string, key: string): Promise<any>;\n put(namespace: string, key: string, value: any, ttl?: number): Promise<void>;\n delete(namespace: string, key: string): Promise<void>;\n list(namespace: string, options?: KvListOptions): Promise<KvListResponse>;\n}\n\nexport interface DbClient {\n find(collection: string, filter?: any, options?: DbFindOptions): Promise<any[]>;\n findOne(collection: string, filter: any): Promise<any | null>;\n insertOne(collection: string, document: any): Promise<string>;\n updateOne(collection: string, filter: any, update: any): Promise<{ modified: number }>;\n deleteOne(collection: string, filter: any): Promise<{ deleted: number }>;\n}\n\nexport interface KvListOptions {\n prefix?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface KvListResponse {\n success: boolean;\n result: Array<{ name: string; expiration?: number; metadata?: any }>;\n result_info: {\n count: number;\n cursor?: string;\n };\n}\n\nexport interface DbFindOptions {\n limit?: number;\n skip?: number;\n sort?: any;\n}\n\nexport function createPlatformClient(baseUrl: string, tenant?: string): PlatformClient {\n const tenantId = tenant || 'dev-tenant';\n const headers = {\n 'Content-Type': 'application/json',\n 'X-Tenant-Id': tenantId,\n };\n\n const fetchWithError = async (url: string, options: RequestInit = {}) => {\n try {\n const response = await fetch(url, {\n ...options,\n headers: {\n ...headers,\n ...options.headers,\n },\n });\n\n if (!response.ok && response.status !== 404) {\n const error = await response.text();\n throw new Error(`Platform API error: ${response.status} - ${error}`);\n }\n\n return response;\n } catch (error) {\n if (error instanceof TypeError && error.message.includes('fetch')) {\n throw new Error(\n `Failed to connect to Maravilla dev server at ${baseUrl}. ` +\n 'Please ensure the dev server is running (cargo run -p dev-server)'\n );\n }\n throw error;\n }\n };\n\n const kv: KvClient = {\n async get(namespace: string, key: string) {\n const response = await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`);\n if (response.status === 404) return null;\n return response.json();\n },\n\n async put(namespace: string, key: string, value: any, ttl?: number) {\n const requestHeaders: Record<string, string> = { ...headers };\n if (ttl) {\n requestHeaders['X-TTL'] = ttl.toString();\n }\n\n await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`, {\n method: 'PUT',\n headers: requestHeaders,\n body: JSON.stringify(value),\n });\n },\n\n async delete(namespace: string, key: string) {\n await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`, {\n method: 'DELETE',\n });\n },\n\n async list(namespace: string, options: KvListOptions = {}) {\n const response = await fetchWithError(`${baseUrl}/api/kv/${namespace}`, {\n method: 'POST',\n body: JSON.stringify(options),\n });\n return response.json() as Promise<KvListResponse>;\n },\n };\n\n const db: DbClient = {\n async find(collection: string, filter: any = {}, options: DbFindOptions = {}) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}`, {\n method: 'POST',\n body: JSON.stringify({ filter, options }),\n });\n return response.json() as Promise<any[]>;\n },\n\n async findOne(collection: string, filter: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}/findOne`, {\n method: 'POST',\n body: JSON.stringify(filter),\n });\n if (response.status === 404) return null;\n return response.json();\n },\n\n async insertOne(collection: string, document: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}`, {\n method: 'PUT',\n body: JSON.stringify(document),\n });\n const result = await response.json() as { id: string };\n return result.id;\n },\n\n async updateOne(collection: string, filter: any, update: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}/update`, {\n method: 'POST',\n body: JSON.stringify({ filter, update }),\n });\n return response.json() as Promise<{ modified: number }>;\n },\n\n async deleteOne(collection: string, filter: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}/delete`, {\n method: 'DELETE',\n body: JSON.stringify(filter),\n });\n return response.json() as Promise<{ deleted: number }>;\n },\n };\n\n return { kv, db };\n}","import type { Plugin, ProxyOptions } from 'vite';\n\nexport interface MaravillaPluginOptions {\n /**\n * URL of the Maravilla dev server. Used both for env-var injection and\n * as the proxy target for `/_auth`, `/_assets`, `/_rt`, and `/api`.\n * @default 'http://localhost:3001'\n */\n devServerUrl?: string;\n\n /**\n * Tenant ID for development.\n * @default 'dev-tenant'\n */\n tenant?: string;\n\n /**\n * Extra URL prefixes to forward to the platform dev server, in addition\n * to the defaults (`/_auth`, `/_assets`, `/_rt`, `/api`). Each prefix is\n * proxied with `changeOrigin: true`. Use this for custom platform routes.\n */\n additionalProxies?: string[];\n\n /**\n * Disable the dev-server proxy entirely. Useful if your project routes\n * platform requests through some other mechanism.\n * @default false\n */\n disableProxy?: boolean;\n}\n\n/**\n * URL prefixes the dev-server owns. Anything the browser navigates to\n * directly (auth pages, assets) or upgrades (realtime ws) must be proxied\n * here so it lands on the platform server instead of the framework dev\n * server. Mirrors the prefixes registered in\n * `crates/dev-server/src/router.rs`.\n */\nconst DEFAULT_PROXY_PREFIXES = ['/_auth', '/_assets', '/_rt', '/api'] as const;\n\nexport function maravilla(options: MaravillaPluginOptions = {}): Plugin {\n const devServerUrl = options.devServerUrl || 'http://localhost:3001';\n const tenant = options.tenant || 'dev-tenant';\n const disableProxy = options.disableProxy ?? false;\n const additionalProxies = options.additionalProxies ?? [];\n\n return {\n name: 'vite-plugin-maravilla',\n\n config() {\n if (disableProxy) return undefined;\n const proxy: Record<string, ProxyOptions> = {};\n for (const prefix of [...DEFAULT_PROXY_PREFIXES, ...additionalProxies]) {\n // `/_rt/*` includes the WebSocket upgrade path `/_rt/ws`; enabling\n // `ws: true` is harmless for the plain HTTP routes under `/_rt`.\n proxy[prefix] = {\n target: devServerUrl,\n changeOrigin: true,\n ws: prefix === '/_rt',\n };\n }\n return { server: { proxy } };\n },\n\n configureServer(server) {\n // Set environment variables that @maravilla/platform will use\n process.env.MARAVILLA_DEV_SERVER = devServerUrl;\n process.env.MARAVILLA_TENANT = tenant;\n\n console.log(`[maravilla] Platform APIs configured for ${devServerUrl}`);\n console.log('[maravilla] Using tenant:', tenant);\n if (!disableProxy) {\n const proxied = [...DEFAULT_PROXY_PREFIXES, ...additionalProxies].join(', ');\n console.log(`[maravilla] Proxying ${proxied} → ${devServerUrl}`);\n }\n\n // Hook into SSR module resolution to ensure platform is available\n server.ssrLoadModule = new Proxy(server.ssrLoadModule, {\n async apply(target, thisArg, args) {\n const result = await Reflect.apply(target, thisArg, args);\n\n // Clear platform cache before each SSR module load to ensure fresh instance\n if ((globalThis as any).__maravilla_platform) {\n delete (globalThis as any).__maravilla_platform;\n }\n\n return result;\n }\n });\n }\n };\n}\n\n// Functions plugin\nexport { maravillaFunctions } from './functions.js';\nexport type { FunctionsPluginOptions } from './functions.js';\n\n// Legacy exports for backwards compatibility\nexport { createPlatformClient } from './client.js';\nexport type { PlatformClient, KvClient, DbClient } from './client.js';\n"],"mappings":";AACA,SAAS,gBAAgB,yBAAyB;AAClD,SAAS,YAAY;AAYd,SAAS,mBAAmB,UAAkC,CAAC,GAAW;AAC/E,QAAM;AAAA,IACJ,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,QAAQ;AAAA,EACV,IAAI;AAEJ,MAAI,kBAAuB;AAC3B,MAAI,iBAAsC;AAE1C,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,MAAM,gBAAgB,QAAuB;AAC3C,YAAM,uBAAuB,KAAK,OAAO,OAAO,MAAM,YAAY;AAGlE,UAAI;AACF,cAAM,OAAO,aAAkB,EAAE,KAAK,QAAM,GAAG,OAAO,oBAAoB,CAAC;AAAA,MAC7E,QAAQ;AACN,gBAAQ,IAAI,yDAAyD,oBAAoB,EAAE;AAC3F;AAAA,MACF;AAEA,cAAQ,IAAI,4CAA4C,oBAAoB,EAAE;AAG9E,UAAI;AACF,0BAAkB,MAAM,eAAe;AAAA,UACrC,cAAc;AAAA,UACd,WAAW,KAAK,OAAO,OAAO,MAAM,0BAA0B;AAAA,UAC9D,YAAY;AAAA,UACZ,QAAQ;AAAA,QACV,CAAC;AAED,gBAAQ,IAAI,+BAA+B,gBAAgB,SAAS,aAAa;AACjF,wBAAgB,OAAO,QAAQ,CAAC,UAAe;AAC7C,kBAAQ,IAAI,KAAK,MAAM,IAAI,WAAM,MAAM,IAAI,KAAK,MAAM,QAAQ,KAAK,IAAI,CAAC,GAAG;AAAA,QAC7E,CAAC;AAAA,MACH,SAAS,OAAO;AACd,gBAAQ,MAAM,uCAAuC,KAAK;AAC1D;AAAA,MACF;AAGA,UAAI,OAAO;AACT,cAAM,UAAU,MAAM,kBAAkB;AAAA,UACtC,cAAc;AAAA,UACd,WA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AAmB;AAAA,UAC7B;AAEA,iBAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maravilla-labs/vite-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Vite plugin for Maravilla Runtime development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@types/node": "^20.10.5",
|
|
28
28
|
"tsup": "^8.0.1",
|
|
29
29
|
"typescript": "^5.3.3",
|
|
30
|
-
"vite": "^
|
|
30
|
+
"vite": "^8.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"vite": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
33
|
+
"vite": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"vite",
|