create-fluxstack 1.10.1 → 1.12.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/.dockerignore +1 -2
- package/Dockerfile +8 -8
- package/LLMD/INDEX.md +64 -0
- package/LLMD/MAINTENANCE.md +197 -0
- package/LLMD/MIGRATION.md +156 -0
- package/LLMD/config/.gitkeep +1 -0
- package/LLMD/config/declarative-system.md +268 -0
- package/LLMD/config/environment-vars.md +327 -0
- package/LLMD/config/runtime-reload.md +401 -0
- package/LLMD/core/.gitkeep +1 -0
- package/LLMD/core/build-system.md +599 -0
- package/LLMD/core/framework-lifecycle.md +229 -0
- package/LLMD/core/plugin-system.md +451 -0
- package/LLMD/patterns/.gitkeep +1 -0
- package/LLMD/patterns/anti-patterns.md +297 -0
- package/LLMD/patterns/project-structure.md +264 -0
- package/LLMD/patterns/type-safety.md +440 -0
- package/LLMD/reference/.gitkeep +1 -0
- package/LLMD/reference/cli-commands.md +250 -0
- package/LLMD/reference/plugin-hooks.md +357 -0
- package/LLMD/reference/routing.md +39 -0
- package/LLMD/reference/troubleshooting.md +364 -0
- package/LLMD/resources/.gitkeep +1 -0
- package/LLMD/resources/controllers.md +465 -0
- package/LLMD/resources/live-components.md +703 -0
- package/LLMD/resources/live-rooms.md +482 -0
- package/LLMD/resources/live-upload.md +130 -0
- package/LLMD/resources/plugins-external.md +617 -0
- package/LLMD/resources/routes-eden.md +254 -0
- package/README.md +37 -17
- package/app/client/index.html +0 -1
- package/app/client/src/App.tsx +107 -150
- package/app/client/src/components/AppLayout.tsx +68 -0
- package/app/client/src/components/BackButton.tsx +13 -0
- package/app/client/src/components/DemoPage.tsx +20 -0
- package/app/client/src/components/LiveUploadWidget.tsx +204 -0
- package/app/client/src/lib/eden-api.ts +85 -60
- package/app/client/src/live/ChatDemo.tsx +107 -0
- package/app/client/src/live/CounterDemo.tsx +206 -0
- package/app/client/src/live/FormDemo.tsx +119 -0
- package/app/client/src/live/RoomChatDemo.tsx +242 -0
- package/app/client/src/live/UploadDemo.tsx +21 -0
- package/app/client/src/main.tsx +4 -1
- package/app/client/src/pages/ApiTestPage.tsx +108 -0
- package/app/client/src/pages/HomePage.tsx +76 -0
- package/app/server/app.ts +1 -4
- package/app/server/controllers/users.controller.ts +36 -44
- package/app/server/index.ts +25 -35
- package/app/server/live/LiveChat.ts +77 -0
- package/app/server/live/LiveCounter.ts +67 -0
- package/app/server/live/LiveForm.ts +63 -0
- package/app/server/live/LiveLocalCounter.ts +32 -0
- package/app/server/live/LiveRoomChat.ts +285 -0
- package/app/server/live/LiveUpload.ts +81 -0
- package/app/server/routes/index.ts +3 -1
- package/app/server/routes/room.routes.ts +117 -0
- package/app/server/routes/users.routes.ts +35 -27
- package/app/shared/types/index.ts +14 -2
- package/config/app.config.ts +2 -62
- package/config/client.config.ts +2 -95
- package/config/database.config.ts +2 -99
- package/config/fluxstack.config.ts +25 -45
- package/config/index.ts +57 -38
- package/config/monitoring.config.ts +2 -114
- package/config/plugins.config.ts +2 -80
- package/config/server.config.ts +2 -68
- package/config/services.config.ts +2 -130
- package/config/system/app.config.ts +29 -0
- package/config/system/build.config.ts +49 -0
- package/config/system/client.config.ts +68 -0
- package/config/system/database.config.ts +17 -0
- package/config/system/fluxstack.config.ts +114 -0
- package/config/{logger.config.ts → system/logger.config.ts} +3 -1
- package/config/system/monitoring.config.ts +114 -0
- package/config/system/plugins.config.ts +84 -0
- package/config/{runtime.config.ts → system/runtime.config.ts} +1 -1
- package/config/system/server.config.ts +68 -0
- package/config/system/services.config.ts +46 -0
- package/config/{system.config.ts → system/system.config.ts} +1 -1
- package/core/build/flux-plugins-generator.ts +325 -325
- package/core/build/index.ts +39 -27
- package/core/build/live-components-generator.ts +3 -3
- package/core/build/optimizer.ts +235 -235
- package/core/cli/command-registry.ts +6 -4
- package/core/cli/commands/build.ts +79 -0
- package/core/cli/commands/create.ts +54 -0
- package/core/cli/commands/dev.ts +101 -0
- package/core/cli/commands/help.ts +34 -0
- package/core/cli/commands/index.ts +34 -0
- package/core/cli/commands/make-plugin.ts +90 -0
- package/core/cli/commands/plugin-add.ts +197 -0
- package/core/cli/commands/plugin-deps.ts +2 -2
- package/core/cli/commands/plugin-list.ts +208 -0
- package/core/cli/commands/plugin-remove.ts +170 -0
- package/core/cli/generators/component.ts +769 -769
- package/core/cli/generators/controller.ts +1 -1
- package/core/cli/generators/index.ts +146 -146
- package/core/cli/generators/interactive.ts +227 -227
- package/core/cli/generators/plugin.ts +2 -2
- package/core/cli/generators/prompts.ts +82 -82
- package/core/cli/generators/route.ts +6 -6
- package/core/cli/generators/service.ts +2 -2
- package/core/cli/generators/template-engine.ts +4 -3
- package/core/cli/generators/types.ts +2 -2
- package/core/cli/generators/utils.ts +191 -191
- package/core/cli/index.ts +115 -686
- package/core/cli/plugin-discovery.ts +2 -2
- package/core/client/LiveComponentsProvider.tsx +60 -8
- package/core/client/api/eden.ts +183 -0
- package/core/client/api/index.ts +11 -0
- package/core/client/components/Live.tsx +104 -0
- package/core/client/fluxstack.ts +1 -9
- package/core/client/hooks/AdaptiveChunkSizer.ts +215 -215
- package/core/client/hooks/state-validator.ts +1 -1
- package/core/client/hooks/useAuth.ts +48 -48
- package/core/client/hooks/useChunkedUpload.ts +85 -35
- package/core/client/hooks/useLiveChunkedUpload.ts +87 -0
- package/core/client/hooks/useLiveComponent.ts +800 -0
- package/core/client/hooks/useLiveUpload.ts +71 -0
- package/core/client/hooks/useRoom.ts +409 -0
- package/core/client/hooks/useRoomProxy.ts +382 -0
- package/core/client/index.ts +17 -68
- package/core/client/standalone-entry.ts +8 -0
- package/core/client/standalone.ts +74 -53
- package/core/client/state/createStore.ts +192 -192
- package/core/client/state/index.ts +14 -14
- package/core/config/index.ts +70 -291
- package/core/config/schema.ts +42 -723
- package/core/framework/client.ts +131 -131
- package/core/framework/index.ts +7 -7
- package/core/framework/server.ts +47 -40
- package/core/framework/types.ts +2 -2
- package/core/index.ts +23 -4
- package/core/live/ComponentRegistry.ts +3 -3
- package/core/live/types.ts +77 -0
- package/core/plugins/built-in/index.ts +134 -134
- package/core/plugins/built-in/live-components/commands/create-live-component.ts +242 -1066
- package/core/plugins/built-in/live-components/index.ts +1 -1
- package/core/plugins/built-in/monitoring/index.ts +111 -47
- package/core/plugins/built-in/static/index.ts +1 -1
- package/core/plugins/built-in/swagger/index.ts +68 -265
- package/core/plugins/built-in/vite/index.ts +85 -185
- package/core/plugins/built-in/vite/vite-dev.ts +10 -16
- package/core/plugins/config.ts +9 -7
- package/core/plugins/dependency-manager.ts +31 -1
- package/core/plugins/discovery.ts +19 -7
- package/core/plugins/executor.ts +2 -2
- package/core/plugins/index.ts +203 -203
- package/core/plugins/manager.ts +27 -39
- package/core/plugins/module-resolver.ts +19 -8
- package/core/plugins/registry.ts +255 -19
- package/core/plugins/types.ts +20 -53
- package/core/server/framework.ts +66 -43
- package/core/server/index.ts +15 -15
- package/core/server/live/ComponentRegistry.ts +78 -71
- package/core/server/live/FileUploadManager.ts +23 -10
- package/core/server/live/LiveComponentPerformanceMonitor.ts +1 -1
- package/core/server/live/LiveRoomManager.ts +261 -0
- package/core/server/live/RoomEventBus.ts +234 -0
- package/core/server/live/RoomStateManager.ts +172 -0
- package/core/server/live/StateSignature.ts +643 -643
- package/core/server/live/WebSocketConnectionManager.ts +30 -19
- package/core/server/live/auto-generated-components.ts +21 -9
- package/core/server/live/index.ts +14 -0
- package/core/server/live/websocket-plugin.ts +214 -67
- package/core/server/middleware/elysia-helpers.ts +7 -2
- package/core/server/middleware/errorHandling.ts +1 -1
- package/core/server/middleware/index.ts +31 -31
- package/core/server/plugins/database.ts +180 -180
- package/core/server/plugins/static-files-plugin.ts +69 -69
- package/core/server/plugins/swagger.ts +1 -1
- package/core/server/rooms/RoomBroadcaster.ts +357 -0
- package/core/server/rooms/RoomSystem.ts +463 -0
- package/core/server/rooms/index.ts +13 -0
- package/core/server/services/BaseService.ts +1 -1
- package/core/server/services/ServiceContainer.ts +1 -1
- package/core/server/services/index.ts +8 -8
- package/core/templates/create-project.ts +12 -12
- package/core/testing/index.ts +9 -9
- package/core/testing/setup.ts +73 -73
- package/core/types/api.ts +168 -168
- package/core/types/build.ts +219 -219
- package/core/types/config.ts +56 -26
- package/core/types/index.ts +4 -4
- package/core/types/plugin.ts +107 -107
- package/core/types/types.ts +353 -14
- package/core/utils/build-logger.ts +324 -324
- package/core/utils/config-schema.ts +480 -480
- package/core/utils/env.ts +2 -8
- package/core/utils/errors/codes.ts +114 -114
- package/core/utils/errors/handlers.ts +36 -1
- package/core/utils/errors/index.ts +49 -5
- package/core/utils/errors/middleware.ts +113 -113
- package/core/utils/helpers.ts +6 -16
- package/core/utils/index.ts +17 -17
- package/core/utils/logger/colors.ts +114 -114
- package/core/utils/logger/config.ts +13 -9
- package/core/utils/logger/formatter.ts +82 -82
- package/core/utils/logger/group-logger.ts +101 -101
- package/core/utils/logger/index.ts +6 -1
- package/core/utils/logger/stack-trace.ts +3 -1
- package/core/utils/logger/startup-banner.ts +82 -82
- package/core/utils/logger/winston-logger.ts +152 -152
- package/core/utils/monitoring/index.ts +211 -211
- package/core/utils/sync-version.ts +66 -66
- package/core/utils/version.ts +1 -1
- package/create-fluxstack.ts +8 -7
- package/package.json +12 -13
- package/plugins/crypto-auth/cli/make-protected-route.command.ts +1 -1
- package/plugins/crypto-auth/client/CryptoAuthClient.ts +302 -302
- package/plugins/crypto-auth/client/components/index.ts +11 -11
- package/plugins/crypto-auth/client/index.ts +11 -11
- package/plugins/crypto-auth/config/index.ts +1 -1
- package/plugins/crypto-auth/index.ts +4 -4
- package/plugins/crypto-auth/package.json +65 -65
- package/plugins/crypto-auth/server/AuthMiddleware.ts +1 -1
- package/plugins/crypto-auth/server/CryptoAuthService.ts +185 -185
- package/plugins/crypto-auth/server/index.ts +21 -21
- package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +3 -3
- package/plugins/crypto-auth/server/middlewares/cryptoAuthOptional.ts +1 -1
- package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +2 -2
- package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +2 -2
- package/plugins/crypto-auth/server/middlewares/helpers.ts +1 -1
- package/plugins/crypto-auth/server/middlewares/index.ts +22 -22
- package/tsconfig.api-strict.json +16 -0
- package/tsconfig.json +48 -52
- package/{app/client/tsconfig.node.json → tsconfig.node.json} +25 -25
- package/types/global.d.ts +29 -29
- package/types/vitest.d.ts +8 -8
- package/vite.config.ts +38 -62
- package/vitest.config.live.ts +10 -9
- package/vitest.config.ts +29 -17
- package/app/client/README.md +0 -69
- package/app/client/SIMPLIFICATION.md +0 -140
- package/app/client/frontend-only.ts +0 -12
- package/app/client/src/live/FileUploadExample.tsx +0 -359
- package/app/client/src/live/MinimalLiveClock.tsx +0 -47
- package/app/client/src/live/QuickUploadTest.tsx +0 -193
- package/app/client/tsconfig.app.json +0 -45
- package/app/client/tsconfig.json +0 -7
- package/app/client/zustand-setup.md +0 -65
- package/app/server/backend-only.ts +0 -18
- package/app/server/live/LiveClockComponent.ts +0 -215
- package/app/server/live/LiveFileUploadComponent.ts +0 -77
- package/app/server/routes/env-test.ts +0 -110
- package/core/client/hooks/index.ts +0 -7
- package/core/client/hooks/useHybridLiveComponent.ts +0 -685
- package/core/client/hooks/useTypedLiveComponent.ts +0 -133
- package/core/client/hooks/useWebSocket.ts +0 -361
- package/core/config/env.ts +0 -546
- package/core/config/loader.ts +0 -522
- package/core/config/runtime-config.ts +0 -327
- package/core/config/validator.ts +0 -540
- package/core/server/backend-entry.ts +0 -51
- package/core/server/standalone.ts +0 -106
- package/core/utils/regenerate-files.ts +0 -69
- package/fluxstack.config.ts +0 -354
|
@@ -1,231 +1,131 @@
|
|
|
1
|
-
import type { FluxStack, PluginContext, RequestContext } from "
|
|
2
|
-
import { FLUXSTACK_VERSION } from "
|
|
3
|
-
import { clientConfig } from '
|
|
4
|
-
import {
|
|
1
|
+
import type { FluxStack, PluginContext, RequestContext } from "@core/plugins/types"
|
|
2
|
+
import { FLUXSTACK_VERSION } from "@core/utils/version"
|
|
3
|
+
import { clientConfig } from '@config'
|
|
4
|
+
import { pluginsConfig } from '@config'
|
|
5
|
+
import { isDevelopment } from "@core/utils/helpers"
|
|
5
6
|
import { join } from "path"
|
|
6
7
|
import { statSync, existsSync } from "fs"
|
|
7
8
|
|
|
8
9
|
type Plugin = FluxStack.Plugin
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
const PLUGIN_PRIORITY = 800
|
|
12
|
+
const INDEX_FILE = "index.html"
|
|
13
|
+
|
|
14
|
+
/** Create static file handler with cached base directory */
|
|
15
|
+
function createStaticFallback() {
|
|
16
|
+
// Discover base directory once
|
|
17
|
+
const baseDir = existsSync('client') ? 'client'
|
|
18
|
+
: existsSync('dist/client') ? 'dist/client'
|
|
19
|
+
: clientConfig.build.outDir ?? 'dist/client'
|
|
20
|
+
|
|
21
|
+
return (c: { request?: Request }) => {
|
|
22
|
+
const req = c.request
|
|
23
|
+
if (!req) return
|
|
24
|
+
|
|
25
|
+
let pathname = decodeURIComponent(new URL(req.url).pathname)
|
|
26
|
+
if (pathname === '/' || pathname === '') {
|
|
27
|
+
pathname = `/${INDEX_FILE}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Try to serve the requested file
|
|
31
|
+
const filePath = join(baseDir, pathname)
|
|
32
|
+
try {
|
|
33
|
+
if (statSync(filePath).isFile()) {
|
|
34
|
+
return Bun.file(filePath)
|
|
35
|
+
}
|
|
36
|
+
} catch {}
|
|
37
|
+
|
|
38
|
+
// SPA fallback: serve index.html
|
|
39
|
+
const indexPath = join(baseDir, INDEX_FILE)
|
|
40
|
+
try {
|
|
41
|
+
statSync(indexPath)
|
|
42
|
+
return Bun.file(indexPath)
|
|
43
|
+
} catch {}
|
|
44
|
+
}
|
|
23
45
|
}
|
|
24
46
|
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
47
|
+
/** Proxy request to Vite dev server */
|
|
48
|
+
async function proxyToVite(ctx: RequestContext): Promise<void> {
|
|
49
|
+
const { host, port } = clientConfig.vite
|
|
50
|
+
|
|
29
51
|
try {
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
// Parse URL (handle relative URLs)
|
|
53
|
+
let url: URL
|
|
54
|
+
try {
|
|
55
|
+
url = new URL(ctx.request.url)
|
|
56
|
+
} catch {
|
|
57
|
+
const reqHost = ctx.request.headers.get('host') || 'localhost'
|
|
58
|
+
const protocol = ctx.request.headers.get('x-forwarded-proto') || 'http'
|
|
59
|
+
url = new URL(ctx.request.url, `${protocol}://${reqHost}`)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const response = await fetch(`http://${host}:${port}${ctx.path}${url.search}`, {
|
|
63
|
+
method: ctx.method,
|
|
64
|
+
headers: ctx.headers,
|
|
65
|
+
body: ctx.method !== 'GET' && ctx.method !== 'HEAD' ? ctx.request.body : undefined
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
ctx.handled = true
|
|
69
|
+
ctx.response = new Response(await response.arrayBuffer(), {
|
|
70
|
+
status: response.status,
|
|
71
|
+
statusText: response.statusText,
|
|
72
|
+
headers: response.headers
|
|
73
|
+
})
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (clientConfig.vite.enableLogging) {
|
|
76
|
+
console.warn(`Vite proxy error: ${error}`)
|
|
77
|
+
}
|
|
37
78
|
}
|
|
38
79
|
}
|
|
39
80
|
|
|
40
81
|
export const vitePlugin: Plugin = {
|
|
41
82
|
name: "vite",
|
|
42
83
|
version: FLUXSTACK_VERSION,
|
|
43
|
-
description: "
|
|
84
|
+
description: "Vite integration plugin for FluxStack",
|
|
44
85
|
author: "FluxStack Team",
|
|
45
|
-
priority:
|
|
86
|
+
priority: PLUGIN_PRIORITY,
|
|
46
87
|
category: "development",
|
|
47
88
|
tags: ["vite", "development", "hot-reload"],
|
|
48
89
|
dependencies: [],
|
|
49
90
|
|
|
50
91
|
setup: async (context: PluginContext) => {
|
|
51
|
-
if (!
|
|
52
|
-
context.logger.debug('Vite plugin disabled
|
|
92
|
+
if (!pluginsConfig.viteEnabled) {
|
|
93
|
+
context.logger.debug('Vite plugin disabled')
|
|
53
94
|
return
|
|
54
95
|
}
|
|
55
96
|
|
|
56
|
-
// Production mode: setup static file serving
|
|
57
97
|
if (!isDevelopment()) {
|
|
58
|
-
context.logger.debug("Production mode: static file serving enabled"
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
// Static fallback handler (runs last)
|
|
63
|
-
const staticFallback = (c: any) => {
|
|
64
|
-
const req = c.request
|
|
65
|
-
if (!req) return
|
|
66
|
-
|
|
67
|
-
const url = new URL(req.url)
|
|
68
|
-
let pathname = decodeURIComponent(url.pathname)
|
|
69
|
-
|
|
70
|
-
// Determine base directory using path discovery
|
|
71
|
-
let baseDir: string
|
|
72
|
-
|
|
73
|
-
// Production: try paths in order of preference
|
|
74
|
-
if (existsSync('client')) {
|
|
75
|
-
// Found client/ in current directory (running from dist/)
|
|
76
|
-
baseDir = 'client'
|
|
77
|
-
} else if (existsSync('dist/client')) {
|
|
78
|
-
// Found dist/client/ (running from project root)
|
|
79
|
-
baseDir = 'dist/client'
|
|
80
|
-
} else {
|
|
81
|
-
// Fallback to configured path
|
|
82
|
-
baseDir = DEFAULTS.publicDir
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Root or empty path → index.html
|
|
86
|
-
if (pathname === '/' || pathname === '') {
|
|
87
|
-
pathname = `/${DEFAULTS.indexFile}`
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const filePath = join(baseDir, pathname)
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
const info = statSync(filePath)
|
|
94
|
-
|
|
95
|
-
// File exists → serve it
|
|
96
|
-
if (info.isFile()) {
|
|
97
|
-
return Bun.file(filePath)
|
|
98
|
-
}
|
|
99
|
-
} catch (_) {
|
|
100
|
-
// File not found → continue
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// SPA fallback: serve index.html for non-file routes
|
|
104
|
-
const indexPath = join(baseDir, DEFAULTS.indexFile)
|
|
105
|
-
try {
|
|
106
|
-
statSync(indexPath) // Ensure index exists
|
|
107
|
-
return Bun.file(indexPath)
|
|
108
|
-
} catch (_) {
|
|
109
|
-
// Index not found → let request continue (404)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Register as catch-all fallback (runs after all other routes)
|
|
114
|
-
context.app.all('*', staticFallback)
|
|
98
|
+
context.logger.debug("Production mode: static file serving enabled")
|
|
99
|
+
context.app.all('*', createStaticFallback())
|
|
115
100
|
return
|
|
116
101
|
}
|
|
117
102
|
|
|
118
|
-
// Development mode: import and setup Vite dev server
|
|
119
103
|
const { setupViteDev } = await import('./vite-dev')
|
|
120
104
|
await setupViteDev(context)
|
|
121
105
|
},
|
|
122
106
|
|
|
123
107
|
onServerStart: async (context: PluginContext) => {
|
|
124
|
-
if (!
|
|
108
|
+
if (!pluginsConfig.viteEnabled) return
|
|
125
109
|
|
|
126
110
|
if (!isDevelopment()) {
|
|
127
|
-
context.logger.debug(
|
|
128
|
-
publicDir: DEFAULTS.publicDir,
|
|
129
|
-
indexFile: DEFAULTS.indexFile
|
|
130
|
-
})
|
|
111
|
+
context.logger.debug('Static files ready')
|
|
131
112
|
return
|
|
132
113
|
}
|
|
133
114
|
|
|
134
|
-
|
|
135
|
-
if (viteConfig) {
|
|
136
|
-
context.logger.debug(`Vite integration active - monitoring ${viteConfig.host}:${viteConfig.port}`)
|
|
137
|
-
}
|
|
115
|
+
context.logger.debug(`Vite active - ${clientConfig.vite.host}:${clientConfig.vite.port}`)
|
|
138
116
|
},
|
|
139
117
|
|
|
140
|
-
onBeforeRoute: async (
|
|
141
|
-
// Production mode: static serving handled by catch-all route in setup
|
|
118
|
+
onBeforeRoute: async (ctx: RequestContext) => {
|
|
142
119
|
if (!isDevelopment()) return
|
|
143
120
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
121
|
+
const shouldSkip = (pluginsConfig.viteExcludePaths ?? []).some(prefix =>
|
|
122
|
+
ctx.path === prefix || ctx.path.startsWith(prefix + '/')
|
|
123
|
+
)
|
|
148
124
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
requestContext.path.startsWith("/__vite") || // Vite HMR and dev routes
|
|
152
|
-
requestContext.path.startsWith("/node_modules") || // Direct node_modules access
|
|
153
|
-
requestContext.path.includes("/.vite/") || // Vite cache and deps
|
|
154
|
-
requestContext.path.endsWith(".js.map") || // Source maps
|
|
155
|
-
requestContext.path.endsWith(".css.map")) { // CSS source maps
|
|
156
|
-
|
|
157
|
-
// Use fixed configuration for Vite proxy
|
|
158
|
-
const viteHost = "localhost"
|
|
159
|
-
const vitePort = 5173
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
const url = parseRequestURL(requestContext.request)
|
|
163
|
-
const viteUrl = `http://${viteHost}:${vitePort}${requestContext.path}${url.search}`
|
|
164
|
-
|
|
165
|
-
// Forward request to Vite
|
|
166
|
-
const response = await fetch(viteUrl, {
|
|
167
|
-
method: requestContext.method,
|
|
168
|
-
headers: requestContext.headers,
|
|
169
|
-
body: requestContext.method !== 'GET' && requestContext.method !== 'HEAD' ? requestContext.request.body : undefined
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
// Return the Vite response
|
|
173
|
-
const body = await response.arrayBuffer()
|
|
174
|
-
|
|
175
|
-
requestContext.handled = true
|
|
176
|
-
requestContext.response = new Response(body, {
|
|
177
|
-
status: response.status,
|
|
178
|
-
statusText: response.statusText,
|
|
179
|
-
headers: response.headers
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
} catch (viteError) {
|
|
183
|
-
// If Vite fails, let the request continue to normal routing (will become 404)
|
|
184
|
-
// Only log if explicitly enabled for debugging
|
|
185
|
-
if (clientConfig.vite.enableLogging) {
|
|
186
|
-
console.warn(`Vite proxy error: ${viteError}`)
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Use fixed configuration for simplicity - Vite should be running on port 5173
|
|
193
|
-
const viteHost = "localhost"
|
|
194
|
-
const vitePort = 5173
|
|
195
|
-
|
|
196
|
-
try {
|
|
197
|
-
const url = parseRequestURL(requestContext.request)
|
|
198
|
-
const viteUrl = `http://${viteHost}:${vitePort}${requestContext.path}${url.search}`
|
|
199
|
-
|
|
200
|
-
// Forward request to Vite
|
|
201
|
-
const response = await fetch(viteUrl, {
|
|
202
|
-
method: requestContext.method,
|
|
203
|
-
headers: requestContext.headers,
|
|
204
|
-
body: requestContext.method !== 'GET' && requestContext.method !== 'HEAD' ? requestContext.request.body : undefined
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
// If Vite responds successfully, handle the request
|
|
208
|
-
if (response.ok || response.status < 500) {
|
|
209
|
-
// Return a proper Response object with all headers and status
|
|
210
|
-
const body = await response.arrayBuffer()
|
|
211
|
-
|
|
212
|
-
requestContext.handled = true
|
|
213
|
-
requestContext.response = new Response(body, {
|
|
214
|
-
status: response.status,
|
|
215
|
-
statusText: response.statusText,
|
|
216
|
-
headers: response.headers
|
|
217
|
-
})
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
} catch (viteError) {
|
|
221
|
-
// If Vite fails, let the request continue to normal routing (will become 404)
|
|
222
|
-
// Only log if explicitly enabled for debugging
|
|
223
|
-
if (clientConfig.vite.enableLogging) {
|
|
224
|
-
console.warn(`Vite proxy error: ${viteError}`)
|
|
225
|
-
}
|
|
125
|
+
if (!shouldSkip) {
|
|
126
|
+
await proxyToVite(ctx)
|
|
226
127
|
}
|
|
227
128
|
}
|
|
228
129
|
}
|
|
229
130
|
|
|
230
|
-
|
|
231
|
-
export default vitePlugin
|
|
131
|
+
export default vitePlugin
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
import type { PluginContext } from "
|
|
2
|
-
import { clientConfig } from '
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { PluginContext } from "@core/plugins/types"
|
|
2
|
+
import { clientConfig } from '@config'
|
|
3
|
+
import type { LogLevel } from "vite"
|
|
4
|
+
import conf from "@/vite.config"
|
|
5
|
+
// Dynamic import t@ype for vite
|
|
5
6
|
type ViteDevServer = Awaited<ReturnType<typeof import('vite')['createServer']>>
|
|
6
7
|
|
|
7
8
|
// Store vite server instance
|
|
8
9
|
let viteServer: ViteDevServer | null = null
|
|
9
10
|
|
|
10
|
-
// Default configuration values
|
|
11
|
-
const DEFAULTS = {
|
|
12
|
-
port: clientConfig.vite.port,
|
|
13
|
-
host: clientConfig.vite.host
|
|
14
|
-
}
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* Setup Vite development server
|
|
18
13
|
* This file is only imported in development mode
|
|
19
14
|
*/
|
|
20
15
|
export async function setupViteDev(context: PluginContext): Promise<void> {
|
|
21
|
-
const vitePort =
|
|
22
|
-
const viteHost =
|
|
23
|
-
|
|
16
|
+
const vitePort = clientConfig.vite.port || 5173
|
|
17
|
+
const viteHost = clientConfig.vite.host || "localhost"
|
|
18
|
+
const logLevel = clientConfig.vite.logLevel as LogLevel
|
|
24
19
|
// Import group logger utilities
|
|
25
|
-
const { endGroup } = await import('
|
|
20
|
+
const { endGroup } = await import('@core/utils/logger/group-logger')
|
|
26
21
|
|
|
27
22
|
try {
|
|
28
23
|
// Dynamic import of vite
|
|
29
24
|
const { createServer } = await import('vite')
|
|
30
|
-
|
|
31
25
|
// Start Vite dev server programmatically (silently)
|
|
32
26
|
viteServer = await createServer({
|
|
33
27
|
configFile: './vite.config.ts',
|
|
@@ -36,7 +30,7 @@ export async function setupViteDev(context: PluginContext): Promise<void> {
|
|
|
36
30
|
host: viteHost,
|
|
37
31
|
strictPort: true
|
|
38
32
|
},
|
|
39
|
-
logLevel:
|
|
33
|
+
logLevel: logLevel
|
|
40
34
|
})
|
|
41
35
|
|
|
42
36
|
await viteServer.listen()
|
package/core/plugins/config.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { FluxStack, PluginConfigSchema, PluginValidationResult } from "./types"
|
|
7
|
-
import type { FluxStackConfig } from "
|
|
8
|
-
import type { Logger } from "
|
|
7
|
+
import type { FluxStackConfig } from "@config"
|
|
8
|
+
import type { Logger } from "@core/utils/logger/index"
|
|
9
9
|
|
|
10
10
|
type Plugin = FluxStack.Plugin
|
|
11
11
|
|
|
@@ -61,19 +61,21 @@ export class DefaultPluginConfigManager implements PluginConfigManager {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Get plugin configuration from main config
|
|
64
|
+
* @deprecated Plugin configs are now directly accessed from config.plugins
|
|
64
65
|
*/
|
|
65
66
|
getPluginConfig(pluginName: string, config: FluxStackConfig): any {
|
|
66
|
-
|
|
67
|
+
// Plugin configs are now accessed directly from config.plugins
|
|
68
|
+
// Example: config.plugins.swaggerEnabled
|
|
69
|
+
return {}
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
/**
|
|
70
73
|
* Set plugin configuration in main config
|
|
74
|
+
* @deprecated Plugin configs are now set via environment variables and config files
|
|
71
75
|
*/
|
|
72
76
|
setPluginConfig(pluginName: string, pluginConfig: any, config: FluxStackConfig): void {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
config.plugins.config[pluginName] = pluginConfig
|
|
77
|
+
// Plugin configs are now set via environment variables and config files
|
|
78
|
+
// This function is deprecated and does nothing
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
/**
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { existsSync, readFileSync, writeFileSync } from 'fs'
|
|
7
7
|
import { join, resolve } from 'path'
|
|
8
8
|
import { execSync } from 'child_process'
|
|
9
|
-
import type { Logger } from '
|
|
9
|
+
import type { Logger } from '@core/utils/logger'
|
|
10
10
|
|
|
11
11
|
export interface PluginDependency {
|
|
12
12
|
name: string
|
|
@@ -230,6 +230,36 @@ export class PluginDependencyManager {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Instalar dependências diretamente em um path específico
|
|
235
|
+
*/
|
|
236
|
+
async installDependenciesInPath(pluginPath: string, dependencies: Record<string, string>): Promise<void> {
|
|
237
|
+
if (!this.config.autoInstall) {
|
|
238
|
+
this.logger?.debug('Auto-instalação desabilitada')
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (Object.keys(dependencies).length === 0) {
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const pluginDeps: PluginDependency[] = Object.entries(dependencies).map(([name, version]) => ({
|
|
247
|
+
name,
|
|
248
|
+
version,
|
|
249
|
+
type: 'dependency'
|
|
250
|
+
}))
|
|
251
|
+
|
|
252
|
+
this.logger?.debug(`📦 Instalando ${pluginDeps.length} dependência(s) em ${pluginPath}`)
|
|
253
|
+
|
|
254
|
+
try {
|
|
255
|
+
await this.installPluginDependenciesLocally(pluginPath, pluginDeps)
|
|
256
|
+
this.logger?.debug(`✅ Dependências instaladas com sucesso em ${pluginPath}`)
|
|
257
|
+
} catch (error) {
|
|
258
|
+
this.logger?.error(`❌ Erro ao instalar dependências em ${pluginPath}`, { error })
|
|
259
|
+
throw error
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
233
263
|
/**
|
|
234
264
|
* Encontrar diretório de um plugin pelo nome
|
|
235
265
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { FluxStack, PluginManifest, PluginLoadResult, PluginDiscoveryOptions } from "./types"
|
|
7
|
-
import type { Logger } from "
|
|
7
|
+
import type { Logger } from "@core/utils/logger/index"
|
|
8
8
|
import { readdir, readFile } from "fs/promises"
|
|
9
9
|
import { join, resolve } from "path"
|
|
10
10
|
import { existsSync } from "fs"
|
|
@@ -306,12 +306,24 @@ export class PluginDiscovery {
|
|
|
306
306
|
* Validate if an object is a valid plugin
|
|
307
307
|
*/
|
|
308
308
|
private isValidPlugin(plugin: any): plugin is Plugin {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
309
|
+
if (!plugin || typeof plugin !== 'object' || typeof plugin.name !== 'string' || plugin.name.length === 0) {
|
|
310
|
+
return false
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const hookNames = [
|
|
314
|
+
'setup', 'onConfigLoad', 'onBeforeServerStart', 'onServerStart',
|
|
315
|
+
'onAfterServerStart', 'onBeforeServerStop', 'onServerStop',
|
|
316
|
+
'onRequest', 'onResponse', 'onError'
|
|
317
|
+
]
|
|
318
|
+
|
|
319
|
+
for (const hook of hookNames) {
|
|
320
|
+
if (hook in plugin && typeof plugin[hook] !== 'function') {
|
|
321
|
+
this.logger?.warn(`Plugin "${plugin.name}" has invalid hook "${hook}" (expected function, got ${typeof plugin[hook]})`)
|
|
322
|
+
return false
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return true
|
|
315
327
|
}
|
|
316
328
|
|
|
317
329
|
/**
|
package/core/plugins/executor.ts
CHANGED
|
@@ -10,8 +10,8 @@ import type {
|
|
|
10
10
|
PluginPriority,
|
|
11
11
|
HookExecutionOptions
|
|
12
12
|
} from "./types"
|
|
13
|
-
import type { Logger } from "
|
|
14
|
-
import { FluxStackError } from "
|
|
13
|
+
import type { Logger } from "@core/utils/logger/index"
|
|
14
|
+
import { FluxStackError } from "@core/utils/errors"
|
|
15
15
|
|
|
16
16
|
export interface PluginExecutionPlan {
|
|
17
17
|
hook: PluginHook
|