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.
Files changed (257) hide show
  1. package/.dockerignore +1 -2
  2. package/Dockerfile +8 -8
  3. package/LLMD/INDEX.md +64 -0
  4. package/LLMD/MAINTENANCE.md +197 -0
  5. package/LLMD/MIGRATION.md +156 -0
  6. package/LLMD/config/.gitkeep +1 -0
  7. package/LLMD/config/declarative-system.md +268 -0
  8. package/LLMD/config/environment-vars.md +327 -0
  9. package/LLMD/config/runtime-reload.md +401 -0
  10. package/LLMD/core/.gitkeep +1 -0
  11. package/LLMD/core/build-system.md +599 -0
  12. package/LLMD/core/framework-lifecycle.md +229 -0
  13. package/LLMD/core/plugin-system.md +451 -0
  14. package/LLMD/patterns/.gitkeep +1 -0
  15. package/LLMD/patterns/anti-patterns.md +297 -0
  16. package/LLMD/patterns/project-structure.md +264 -0
  17. package/LLMD/patterns/type-safety.md +440 -0
  18. package/LLMD/reference/.gitkeep +1 -0
  19. package/LLMD/reference/cli-commands.md +250 -0
  20. package/LLMD/reference/plugin-hooks.md +357 -0
  21. package/LLMD/reference/routing.md +39 -0
  22. package/LLMD/reference/troubleshooting.md +364 -0
  23. package/LLMD/resources/.gitkeep +1 -0
  24. package/LLMD/resources/controllers.md +465 -0
  25. package/LLMD/resources/live-components.md +703 -0
  26. package/LLMD/resources/live-rooms.md +482 -0
  27. package/LLMD/resources/live-upload.md +130 -0
  28. package/LLMD/resources/plugins-external.md +617 -0
  29. package/LLMD/resources/routes-eden.md +254 -0
  30. package/README.md +37 -17
  31. package/app/client/index.html +0 -1
  32. package/app/client/src/App.tsx +107 -150
  33. package/app/client/src/components/AppLayout.tsx +68 -0
  34. package/app/client/src/components/BackButton.tsx +13 -0
  35. package/app/client/src/components/DemoPage.tsx +20 -0
  36. package/app/client/src/components/LiveUploadWidget.tsx +204 -0
  37. package/app/client/src/lib/eden-api.ts +85 -60
  38. package/app/client/src/live/ChatDemo.tsx +107 -0
  39. package/app/client/src/live/CounterDemo.tsx +206 -0
  40. package/app/client/src/live/FormDemo.tsx +119 -0
  41. package/app/client/src/live/RoomChatDemo.tsx +242 -0
  42. package/app/client/src/live/UploadDemo.tsx +21 -0
  43. package/app/client/src/main.tsx +4 -1
  44. package/app/client/src/pages/ApiTestPage.tsx +108 -0
  45. package/app/client/src/pages/HomePage.tsx +76 -0
  46. package/app/server/app.ts +1 -4
  47. package/app/server/controllers/users.controller.ts +36 -44
  48. package/app/server/index.ts +25 -35
  49. package/app/server/live/LiveChat.ts +77 -0
  50. package/app/server/live/LiveCounter.ts +67 -0
  51. package/app/server/live/LiveForm.ts +63 -0
  52. package/app/server/live/LiveLocalCounter.ts +32 -0
  53. package/app/server/live/LiveRoomChat.ts +285 -0
  54. package/app/server/live/LiveUpload.ts +81 -0
  55. package/app/server/routes/index.ts +3 -1
  56. package/app/server/routes/room.routes.ts +117 -0
  57. package/app/server/routes/users.routes.ts +35 -27
  58. package/app/shared/types/index.ts +14 -2
  59. package/config/app.config.ts +2 -62
  60. package/config/client.config.ts +2 -95
  61. package/config/database.config.ts +2 -99
  62. package/config/fluxstack.config.ts +25 -45
  63. package/config/index.ts +57 -38
  64. package/config/monitoring.config.ts +2 -114
  65. package/config/plugins.config.ts +2 -80
  66. package/config/server.config.ts +2 -68
  67. package/config/services.config.ts +2 -130
  68. package/config/system/app.config.ts +29 -0
  69. package/config/system/build.config.ts +49 -0
  70. package/config/system/client.config.ts +68 -0
  71. package/config/system/database.config.ts +17 -0
  72. package/config/system/fluxstack.config.ts +114 -0
  73. package/config/{logger.config.ts → system/logger.config.ts} +3 -1
  74. package/config/system/monitoring.config.ts +114 -0
  75. package/config/system/plugins.config.ts +84 -0
  76. package/config/{runtime.config.ts → system/runtime.config.ts} +1 -1
  77. package/config/system/server.config.ts +68 -0
  78. package/config/system/services.config.ts +46 -0
  79. package/config/{system.config.ts → system/system.config.ts} +1 -1
  80. package/core/build/flux-plugins-generator.ts +325 -325
  81. package/core/build/index.ts +39 -27
  82. package/core/build/live-components-generator.ts +3 -3
  83. package/core/build/optimizer.ts +235 -235
  84. package/core/cli/command-registry.ts +6 -4
  85. package/core/cli/commands/build.ts +79 -0
  86. package/core/cli/commands/create.ts +54 -0
  87. package/core/cli/commands/dev.ts +101 -0
  88. package/core/cli/commands/help.ts +34 -0
  89. package/core/cli/commands/index.ts +34 -0
  90. package/core/cli/commands/make-plugin.ts +90 -0
  91. package/core/cli/commands/plugin-add.ts +197 -0
  92. package/core/cli/commands/plugin-deps.ts +2 -2
  93. package/core/cli/commands/plugin-list.ts +208 -0
  94. package/core/cli/commands/plugin-remove.ts +170 -0
  95. package/core/cli/generators/component.ts +769 -769
  96. package/core/cli/generators/controller.ts +1 -1
  97. package/core/cli/generators/index.ts +146 -146
  98. package/core/cli/generators/interactive.ts +227 -227
  99. package/core/cli/generators/plugin.ts +2 -2
  100. package/core/cli/generators/prompts.ts +82 -82
  101. package/core/cli/generators/route.ts +6 -6
  102. package/core/cli/generators/service.ts +2 -2
  103. package/core/cli/generators/template-engine.ts +4 -3
  104. package/core/cli/generators/types.ts +2 -2
  105. package/core/cli/generators/utils.ts +191 -191
  106. package/core/cli/index.ts +115 -686
  107. package/core/cli/plugin-discovery.ts +2 -2
  108. package/core/client/LiveComponentsProvider.tsx +60 -8
  109. package/core/client/api/eden.ts +183 -0
  110. package/core/client/api/index.ts +11 -0
  111. package/core/client/components/Live.tsx +104 -0
  112. package/core/client/fluxstack.ts +1 -9
  113. package/core/client/hooks/AdaptiveChunkSizer.ts +215 -215
  114. package/core/client/hooks/state-validator.ts +1 -1
  115. package/core/client/hooks/useAuth.ts +48 -48
  116. package/core/client/hooks/useChunkedUpload.ts +85 -35
  117. package/core/client/hooks/useLiveChunkedUpload.ts +87 -0
  118. package/core/client/hooks/useLiveComponent.ts +800 -0
  119. package/core/client/hooks/useLiveUpload.ts +71 -0
  120. package/core/client/hooks/useRoom.ts +409 -0
  121. package/core/client/hooks/useRoomProxy.ts +382 -0
  122. package/core/client/index.ts +17 -68
  123. package/core/client/standalone-entry.ts +8 -0
  124. package/core/client/standalone.ts +74 -53
  125. package/core/client/state/createStore.ts +192 -192
  126. package/core/client/state/index.ts +14 -14
  127. package/core/config/index.ts +70 -291
  128. package/core/config/schema.ts +42 -723
  129. package/core/framework/client.ts +131 -131
  130. package/core/framework/index.ts +7 -7
  131. package/core/framework/server.ts +47 -40
  132. package/core/framework/types.ts +2 -2
  133. package/core/index.ts +23 -4
  134. package/core/live/ComponentRegistry.ts +3 -3
  135. package/core/live/types.ts +77 -0
  136. package/core/plugins/built-in/index.ts +134 -134
  137. package/core/plugins/built-in/live-components/commands/create-live-component.ts +242 -1066
  138. package/core/plugins/built-in/live-components/index.ts +1 -1
  139. package/core/plugins/built-in/monitoring/index.ts +111 -47
  140. package/core/plugins/built-in/static/index.ts +1 -1
  141. package/core/plugins/built-in/swagger/index.ts +68 -265
  142. package/core/plugins/built-in/vite/index.ts +85 -185
  143. package/core/plugins/built-in/vite/vite-dev.ts +10 -16
  144. package/core/plugins/config.ts +9 -7
  145. package/core/plugins/dependency-manager.ts +31 -1
  146. package/core/plugins/discovery.ts +19 -7
  147. package/core/plugins/executor.ts +2 -2
  148. package/core/plugins/index.ts +203 -203
  149. package/core/plugins/manager.ts +27 -39
  150. package/core/plugins/module-resolver.ts +19 -8
  151. package/core/plugins/registry.ts +255 -19
  152. package/core/plugins/types.ts +20 -53
  153. package/core/server/framework.ts +66 -43
  154. package/core/server/index.ts +15 -15
  155. package/core/server/live/ComponentRegistry.ts +78 -71
  156. package/core/server/live/FileUploadManager.ts +23 -10
  157. package/core/server/live/LiveComponentPerformanceMonitor.ts +1 -1
  158. package/core/server/live/LiveRoomManager.ts +261 -0
  159. package/core/server/live/RoomEventBus.ts +234 -0
  160. package/core/server/live/RoomStateManager.ts +172 -0
  161. package/core/server/live/StateSignature.ts +643 -643
  162. package/core/server/live/WebSocketConnectionManager.ts +30 -19
  163. package/core/server/live/auto-generated-components.ts +21 -9
  164. package/core/server/live/index.ts +14 -0
  165. package/core/server/live/websocket-plugin.ts +214 -67
  166. package/core/server/middleware/elysia-helpers.ts +7 -2
  167. package/core/server/middleware/errorHandling.ts +1 -1
  168. package/core/server/middleware/index.ts +31 -31
  169. package/core/server/plugins/database.ts +180 -180
  170. package/core/server/plugins/static-files-plugin.ts +69 -69
  171. package/core/server/plugins/swagger.ts +1 -1
  172. package/core/server/rooms/RoomBroadcaster.ts +357 -0
  173. package/core/server/rooms/RoomSystem.ts +463 -0
  174. package/core/server/rooms/index.ts +13 -0
  175. package/core/server/services/BaseService.ts +1 -1
  176. package/core/server/services/ServiceContainer.ts +1 -1
  177. package/core/server/services/index.ts +8 -8
  178. package/core/templates/create-project.ts +12 -12
  179. package/core/testing/index.ts +9 -9
  180. package/core/testing/setup.ts +73 -73
  181. package/core/types/api.ts +168 -168
  182. package/core/types/build.ts +219 -219
  183. package/core/types/config.ts +56 -26
  184. package/core/types/index.ts +4 -4
  185. package/core/types/plugin.ts +107 -107
  186. package/core/types/types.ts +353 -14
  187. package/core/utils/build-logger.ts +324 -324
  188. package/core/utils/config-schema.ts +480 -480
  189. package/core/utils/env.ts +2 -8
  190. package/core/utils/errors/codes.ts +114 -114
  191. package/core/utils/errors/handlers.ts +36 -1
  192. package/core/utils/errors/index.ts +49 -5
  193. package/core/utils/errors/middleware.ts +113 -113
  194. package/core/utils/helpers.ts +6 -16
  195. package/core/utils/index.ts +17 -17
  196. package/core/utils/logger/colors.ts +114 -114
  197. package/core/utils/logger/config.ts +13 -9
  198. package/core/utils/logger/formatter.ts +82 -82
  199. package/core/utils/logger/group-logger.ts +101 -101
  200. package/core/utils/logger/index.ts +6 -1
  201. package/core/utils/logger/stack-trace.ts +3 -1
  202. package/core/utils/logger/startup-banner.ts +82 -82
  203. package/core/utils/logger/winston-logger.ts +152 -152
  204. package/core/utils/monitoring/index.ts +211 -211
  205. package/core/utils/sync-version.ts +66 -66
  206. package/core/utils/version.ts +1 -1
  207. package/create-fluxstack.ts +8 -7
  208. package/package.json +12 -13
  209. package/plugins/crypto-auth/cli/make-protected-route.command.ts +1 -1
  210. package/plugins/crypto-auth/client/CryptoAuthClient.ts +302 -302
  211. package/plugins/crypto-auth/client/components/index.ts +11 -11
  212. package/plugins/crypto-auth/client/index.ts +11 -11
  213. package/plugins/crypto-auth/config/index.ts +1 -1
  214. package/plugins/crypto-auth/index.ts +4 -4
  215. package/plugins/crypto-auth/package.json +65 -65
  216. package/plugins/crypto-auth/server/AuthMiddleware.ts +1 -1
  217. package/plugins/crypto-auth/server/CryptoAuthService.ts +185 -185
  218. package/plugins/crypto-auth/server/index.ts +21 -21
  219. package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +3 -3
  220. package/plugins/crypto-auth/server/middlewares/cryptoAuthOptional.ts +1 -1
  221. package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +2 -2
  222. package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +2 -2
  223. package/plugins/crypto-auth/server/middlewares/helpers.ts +1 -1
  224. package/plugins/crypto-auth/server/middlewares/index.ts +22 -22
  225. package/tsconfig.api-strict.json +16 -0
  226. package/tsconfig.json +48 -52
  227. package/{app/client/tsconfig.node.json → tsconfig.node.json} +25 -25
  228. package/types/global.d.ts +29 -29
  229. package/types/vitest.d.ts +8 -8
  230. package/vite.config.ts +38 -62
  231. package/vitest.config.live.ts +10 -9
  232. package/vitest.config.ts +29 -17
  233. package/app/client/README.md +0 -69
  234. package/app/client/SIMPLIFICATION.md +0 -140
  235. package/app/client/frontend-only.ts +0 -12
  236. package/app/client/src/live/FileUploadExample.tsx +0 -359
  237. package/app/client/src/live/MinimalLiveClock.tsx +0 -47
  238. package/app/client/src/live/QuickUploadTest.tsx +0 -193
  239. package/app/client/tsconfig.app.json +0 -45
  240. package/app/client/tsconfig.json +0 -7
  241. package/app/client/zustand-setup.md +0 -65
  242. package/app/server/backend-only.ts +0 -18
  243. package/app/server/live/LiveClockComponent.ts +0 -215
  244. package/app/server/live/LiveFileUploadComponent.ts +0 -77
  245. package/app/server/routes/env-test.ts +0 -110
  246. package/core/client/hooks/index.ts +0 -7
  247. package/core/client/hooks/useHybridLiveComponent.ts +0 -685
  248. package/core/client/hooks/useTypedLiveComponent.ts +0 -133
  249. package/core/client/hooks/useWebSocket.ts +0 -361
  250. package/core/config/env.ts +0 -546
  251. package/core/config/loader.ts +0 -522
  252. package/core/config/runtime-config.ts +0 -327
  253. package/core/config/validator.ts +0 -540
  254. package/core/server/backend-entry.ts +0 -51
  255. package/core/server/standalone.ts +0 -106
  256. package/core/utils/regenerate-files.ts +0 -69
  257. package/fluxstack.config.ts +0 -354
@@ -1,231 +1,131 @@
1
- import type { FluxStack, PluginContext, RequestContext } from "@/core/plugins/types"
2
- import { FLUXSTACK_VERSION } from "@/core/utils/version"
3
- import { clientConfig } from '@/config/client.config'
4
- import { isDevelopment } from "@/core/utils/helpers"
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
- // Default configuration values (uses clientConfig from /config)
11
- const DEFAULTS = {
12
- enabled: true,
13
- port: clientConfig.vite.port,
14
- host: clientConfig.vite.host,
15
- checkInterval: 2000,
16
- maxRetries: 10,
17
- timeout: 5000,
18
- proxyPaths: [] as string[],
19
- excludePaths: [] as string[],
20
- // Static file serving (production) - uses clientConfig
21
- publicDir: clientConfig.build.outDir,
22
- indexFile: "index.html"
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
- * Helper to safely parse request.url which might be relative or absolute
27
- */
28
- function parseRequestURL(request: Request): URL {
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
- // Try parsing as absolute URL first
31
- return new URL(request.url)
32
- } catch {
33
- // If relative, use host from headers or default to localhost
34
- const host = request.headers.get('host') || 'localhost'
35
- const protocol = request.headers.get('x-forwarded-proto') || 'http'
36
- return new URL(request.url, `${protocol}://${host}`)
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: "Enhanced Vite integration plugin for FluxStack with improved error handling and monitoring",
84
+ description: "Vite integration plugin for FluxStack",
44
85
  author: "FluxStack Team",
45
- priority: 800, // Should run early to setup proxying
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 (!DEFAULTS.enabled) {
52
- context.logger.debug('Vite plugin disabled or no client configuration found')
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
- publicDir: DEFAULTS.publicDir
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 (!DEFAULTS.enabled) return
108
+ if (!pluginsConfig.viteEnabled) return
125
109
 
126
110
  if (!isDevelopment()) {
127
- context.logger.debug(`Static files ready`, {
128
- publicDir: DEFAULTS.publicDir,
129
- indexFile: DEFAULTS.indexFile
130
- })
111
+ context.logger.debug('Static files ready')
131
112
  return
132
113
  }
133
114
 
134
- const viteConfig = (context as any).viteConfig
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 (requestContext: RequestContext) => {
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
- // Skip API routes and swagger - let them be handled by backend
145
- if (requestContext.path.startsWith("/api") || requestContext.path.startsWith("/swagger")) {
146
- return
147
- }
121
+ const shouldSkip = (pluginsConfig.viteExcludePaths ?? []).some(prefix =>
122
+ ctx.path === prefix || ctx.path.startsWith(prefix + '/')
123
+ )
148
124
 
149
- // For Vite internal routes, proxy directly to Vite server
150
- if (requestContext.path.startsWith("/@") || // All Vite internal routes (/@vite/, /@fs/, /@react-refresh, etc.)
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 "@/core/plugins/types"
2
- import { clientConfig } from '@/config/client.config'
3
-
4
- // Dynamic import type for vite
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 = DEFAULTS.port || clientConfig.vite.port || 5173
22
- const viteHost = DEFAULTS.host || "localhost"
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('@/core/utils/logger/group-logger')
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: 'silent'
33
+ logLevel: logLevel
40
34
  })
41
35
 
42
36
  await viteServer.listen()
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  import type { FluxStack, PluginConfigSchema, PluginValidationResult } from "./types"
7
- import type { FluxStackConfig } from "@/core/config/schema"
8
- import type { Logger } from "@/core/utils/logger/index"
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
- return config.plugins.config[pluginName] || {}
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
- if (!config.plugins.config) {
74
- config.plugins.config = {}
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 '@/core/utils/logger'
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 "@/core/utils/logger/index"
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
- return (
310
- plugin &&
311
- typeof plugin === 'object' &&
312
- typeof plugin.name === 'string' &&
313
- plugin.name.length > 0
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
  /**
@@ -10,8 +10,8 @@ import type {
10
10
  PluginPriority,
11
11
  HookExecutionOptions
12
12
  } from "./types"
13
- import type { Logger } from "@/core/utils/logger/index"
14
- import { FluxStackError } from "@/core/utils/errors"
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