create-fluxstack 1.5.4 → 1.7.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 (61) hide show
  1. package/README.md +172 -215
  2. package/app/client/src/App.tsx +45 -19
  3. package/app/client/src/components/FluxStackConfig.tsx +1 -1
  4. package/app/client/src/components/HybridLiveCounter.tsx +1 -1
  5. package/app/client/src/components/LiveClock.tsx +1 -1
  6. package/app/client/src/components/MainLayout.tsx +0 -2
  7. package/app/client/src/components/SidebarNavigation.tsx +1 -1
  8. package/app/client/src/components/SystemMonitor.tsx +16 -10
  9. package/app/client/src/components/UserProfile.tsx +1 -1
  10. package/app/server/live/FluxStackConfig.ts +2 -1
  11. package/app/server/live/LiveClockComponent.ts +8 -7
  12. package/app/server/live/SidebarNavigation.ts +2 -1
  13. package/app/server/live/SystemMonitor.ts +1 -0
  14. package/app/server/live/UserProfileComponent.ts +36 -30
  15. package/config/server.config.ts +1 -0
  16. package/core/cli/command-registry.ts +10 -10
  17. package/core/cli/commands/plugin-deps.ts +13 -5
  18. package/core/cli/plugin-discovery.ts +1 -1
  19. package/core/client/LiveComponentsProvider.tsx +414 -0
  20. package/core/client/hooks/useHybridLiveComponent.ts +194 -530
  21. package/core/client/index.ts +16 -0
  22. package/core/framework/server.ts +144 -63
  23. package/core/index.ts +4 -1
  24. package/core/plugins/built-in/monitoring/index.ts +1 -1
  25. package/core/plugins/built-in/static/index.ts +1 -1
  26. package/core/plugins/built-in/swagger/index.ts +1 -1
  27. package/core/plugins/built-in/vite/index.ts +1 -1
  28. package/core/plugins/config.ts +1 -1
  29. package/core/plugins/discovery.ts +1 -1
  30. package/core/plugins/executor.ts +1 -1
  31. package/core/plugins/index.ts +1 -0
  32. package/core/server/live/ComponentRegistry.ts +3 -1
  33. package/core/server/live/WebSocketConnectionManager.ts +14 -4
  34. package/core/server/live/websocket-plugin.ts +453 -434
  35. package/core/server/middleware/elysia-helpers.ts +3 -5
  36. package/core/server/plugins/database.ts +1 -1
  37. package/core/server/plugins/static-files-plugin.ts +1 -1
  38. package/core/types/index.ts +1 -1
  39. package/core/types/plugin.ts +1 -1
  40. package/core/types/types.ts +6 -2
  41. package/core/utils/logger/colors.ts +4 -4
  42. package/core/utils/logger/index.ts +37 -4
  43. package/core/utils/logger/winston-logger.ts +1 -1
  44. package/core/utils/sync-version.ts +61 -0
  45. package/core/utils/version.ts +6 -5
  46. package/create-fluxstack.ts +1 -1
  47. package/package.json +5 -3
  48. package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +1 -1
  49. package/plugins/crypto-auth/server/middlewares/cryptoAuthOptional.ts +1 -1
  50. package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +1 -1
  51. package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +1 -1
  52. package/vite.config.ts +8 -0
  53. package/.dockerignore +0 -50
  54. package/CRYPTO-AUTH-MIDDLEWARE-GUIDE.md +0 -475
  55. package/CRYPTO-AUTH-MIDDLEWARES.md +0 -473
  56. package/CRYPTO-AUTH-USAGE.md +0 -491
  57. package/EXEMPLO-ROTA-PROTEGIDA.md +0 -347
  58. package/QUICK-START-CRYPTO-AUTH.md +0 -221
  59. package/app/client/src/components/Teste.tsx +0 -104
  60. package/app/server/live/TesteComponent.ts +0 -87
  61. package/test-crypto-auth.ts +0 -101
@@ -54,7 +54,7 @@ export function createMiddleware<TContext = any>(
54
54
  return new Elysia({ name }).derive(handler as any)
55
55
  } else {
56
56
  // Blocking: use onBeforeHandle() - can stop execution by returning a response
57
- return new Elysia({ name }).onBeforeHandle(handler as any).as('plugin')
57
+ return new Elysia({ name }).onBeforeHandle(handler as any)
58
58
  }
59
59
  }
60
60
 
@@ -109,7 +109,6 @@ export function createGuard<TContext = any>(options: {
109
109
  return options.onFail((ctx as any).set, ctx as TContext)
110
110
  }
111
111
  })
112
- .as('plugin')
113
112
  }
114
113
 
115
114
  /**
@@ -182,7 +181,6 @@ export function createRateLimit(options: {
182
181
  requests.set(key, { count: 1, resetTime: now + windowMs })
183
182
  }
184
183
  })
185
- .as('plugin')
186
184
  }
187
185
 
188
186
  /**
@@ -208,7 +206,7 @@ export function composeMiddleware(options: {
208
206
  composed = composed.use(middleware)
209
207
  }
210
208
 
211
- return composed.as('plugin')
209
+ return composed
212
210
  }
213
211
 
214
212
  /**
@@ -224,4 +222,4 @@ export function isProduction() {
224
222
 
225
223
  export function isTest() {
226
224
  return process.env.NODE_ENV === 'test'
227
- }
225
+ }
@@ -1,4 +1,4 @@
1
- import type { Plugin, PluginContext, CliCommand } from "../../plugins/types"
1
+ import type { FluxStack, PluginContext, CliCommand } from "../../plugins/types"
2
2
 
3
3
  // Database plugin with CLI commands
4
4
  export const databasePlugin: Plugin = {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { existsSync, statSync } from 'fs'
4
4
  import { join, extname, resolve } from 'path'
5
- import type { Plugin, PluginContext } from '../plugins/types'
5
+ import type { FluxStack, PluginContext } from '../plugins/types'
6
6
 
7
7
  export interface StaticFilesConfig {
8
8
  publicDir?: string // Default: 'public'
@@ -32,7 +32,7 @@ export type {
32
32
 
33
33
  // Re-export additional plugin types from core plugins
34
34
  export type {
35
- Plugin as CorePlugin,
35
+ FluxStack as CorePlugin,
36
36
  PluginContext as CorePluginContext,
37
37
  PluginUtils as CorePluginUtils,
38
38
  RequestContext as CoreRequestContext,
@@ -5,7 +5,7 @@
5
5
 
6
6
  // Re-export plugin types
7
7
  export type {
8
- Plugin,
8
+ FluxStack,
9
9
  PluginContext,
10
10
  PluginUtils,
11
11
  RequestContext,
@@ -1,7 +1,11 @@
1
1
  // 🔥 FluxStack Live Components - Shared Types
2
2
 
3
3
  export interface LiveMessage {
4
- type: 'COMPONENT_MOUNT' | 'COMPONENT_UNMOUNT' | 'COMPONENT_REHYDRATE' | 'COMPONENT_ACTION' | 'CALL_ACTION' | 'ACTION_RESPONSE' | 'PROPERTY_UPDATE' | 'STATE_UPDATE' | 'STATE_REHYDRATED' | 'ERROR' | 'BROADCAST'
4
+ type: 'COMPONENT_MOUNT' | 'COMPONENT_UNMOUNT' |
5
+ 'COMPONENT_REHYDRATE' | 'COMPONENT_ACTION' | 'CALL_ACTION' |
6
+ 'ACTION_RESPONSE' | 'PROPERTY_UPDATE' | 'STATE_UPDATE' | 'STATE_REHYDRATED' |
7
+ 'ERROR' | 'BROADCAST' | 'FILE_UPLOAD_START' | 'FILE_UPLOAD_CHUNK' | 'FILE_UPLOAD_COMPLETE' |
8
+ 'COMPONENT_PING' | 'COMPONENT_PONG'
5
9
  componentId: string
6
10
  action?: string
7
11
  property?: string
@@ -65,7 +69,7 @@ export interface WebSocketMessage {
65
69
  }
66
70
 
67
71
  export interface WebSocketResponse {
68
- type: 'MESSAGE_RESPONSE' | 'CONNECTION_ESTABLISHED' | 'ERROR' | 'BROADCAST' | 'ACTION_RESPONSE' | 'COMPONENT_MOUNTED' | 'COMPONENT_REHYDRATED' | 'STATE_UPDATE' | 'STATE_REHYDRATED' | 'FILE_UPLOAD_PROGRESS' | 'FILE_UPLOAD_COMPLETE' | 'FILE_UPLOAD_ERROR' | 'FILE_UPLOAD_START_RESPONSE'
72
+ type: 'MESSAGE_RESPONSE' | 'CONNECTION_ESTABLISHED' | 'ERROR' | 'BROADCAST' | 'ACTION_RESPONSE' | 'COMPONENT_MOUNTED' | 'COMPONENT_REHYDRATED' | 'STATE_UPDATE' | 'STATE_REHYDRATED' | 'FILE_UPLOAD_PROGRESS' | 'FILE_UPLOAD_COMPLETE' | 'FILE_UPLOAD_ERROR' | 'FILE_UPLOAD_START_RESPONSE' | 'COMPONENT_PONG'
69
73
  originalType?: string
70
74
  componentId?: string
71
75
  success?: boolean
@@ -3,10 +3,10 @@
3
3
  * Generates unique colors for each module
4
4
  */
5
5
 
6
- import chalk from 'chalk'
6
+ import chalk, { type ChalkInstance } from 'chalk'
7
7
 
8
- // Cache for module colors
9
- const moduleColors = new Map<string, chalk.Chalk>()
8
+ // Cache for module colors
9
+ const moduleColors = new Map<string, ChalkInstance>()
10
10
 
11
11
  /**
12
12
  * Pre-defined colors for common modules
@@ -55,7 +55,7 @@ export const LEVEL_COLORS = {
55
55
  /**
56
56
  * Generate a unique color for a module based on its name
57
57
  */
58
- export function getColorForModule(moduleName: string): chalk.Chalk {
58
+ export function getColorForModule(moduleName: string): ChalkInstance {
59
59
  // Check cache first
60
60
  if (moduleColors.has(moduleName)) {
61
61
  return moduleColors.get(moduleName)!
@@ -125,12 +125,45 @@ export function SECTION(sectionName: string, callback: () => void): void {
125
125
  }
126
126
 
127
127
  /**
128
- * HTTP request logging (compatibility with Elysia)
128
+ * HTTP request logging with colors and formatting
129
129
  */
130
130
  export function request(method: string, path: string, status?: number, duration?: number): void {
131
- const statusStr = status ? ` ${status}` : ''
132
- const durationStr = duration ? ` (${duration}ms)` : ''
133
- LOG(`${method} ${path}${statusStr}${durationStr}`)
131
+ const { file: callerFile } = getCallerInfo()
132
+ const logger = getLoggerForModule(callerFile)
133
+
134
+ // Color based on HTTP status
135
+ let statusColor = chalk.gray
136
+ if (status) {
137
+ if (status >= 500) statusColor = chalk.red.bold // Server errors
138
+ else if (status >= 400) statusColor = chalk.yellow // Client errors
139
+ else if (status >= 300) statusColor = chalk.cyan // Redirects
140
+ else if (status >= 200) statusColor = chalk.green // Success
141
+ }
142
+
143
+ // Color for HTTP method
144
+ let methodColor = chalk.blue
145
+ if (method === 'POST') methodColor = chalk.green
146
+ else if (method === 'PUT') methodColor = chalk.yellow
147
+ else if (method === 'PATCH') methodColor = chalk.magenta
148
+ else if (method === 'DELETE') methodColor = chalk.red
149
+
150
+ // Format duration with color (warn if slow)
151
+ let durationStr = ''
152
+ if (duration !== undefined) {
153
+ const durationColor = duration > 1000 ? chalk.red : duration > 500 ? chalk.yellow : chalk.gray
154
+ durationStr = ` ${durationColor(`(${duration}ms)`)}`
155
+ }
156
+
157
+ // Build log message
158
+ const methodStr = methodColor(method.padEnd(7))
159
+ const pathStr = chalk.white(path.padEnd(30))
160
+ const statusStr = status ? `→ ${statusColor(status.toString())}` : ''
161
+
162
+ const message = `${methodStr} ${pathStr} ${statusStr}${durationStr}`
163
+
164
+ // Use appropriate log level based on status
165
+ const level = status && status >= 500 ? 'error' : status && status >= 400 ? 'warn' : 'info'
166
+ logger.log({ level, message })
134
167
  }
135
168
 
136
169
  /**
@@ -33,7 +33,7 @@ function createConsoleFormat() {
33
33
  function createFileFormat() {
34
34
  return winston.format.printf(({ timestamp, level, message }) => {
35
35
  // Remove ANSI color codes
36
- const cleanMessage = message.replace(/\u001b\[.*?m/g, '')
36
+ const cleanMessage = String(message).replace(/\u001b\[.*?m/g, '')
37
37
  return `[${timestamp}] [${level.toUpperCase()}]: ${cleanMessage}`
38
38
  })
39
39
  }
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env bun
2
+
3
+ /**
4
+ * Version Synchronization Utility
5
+ * Ensures version consistency between package.json and version.ts
6
+ */
7
+
8
+ import { readFileSync, writeFileSync } from 'fs'
9
+ import { join } from 'path'
10
+
11
+ interface PackageJson {
12
+ version: string
13
+ [key: string]: any
14
+ }
15
+
16
+ /**
17
+ * Read version from package.json
18
+ */
19
+ function getPackageVersion(): string {
20
+ const packagePath = join(process.cwd(), 'package.json')
21
+ const packageContent = readFileSync(packagePath, 'utf-8')
22
+ const packageJson: PackageJson = JSON.parse(packageContent)
23
+ return packageJson.version
24
+ }
25
+
26
+ /**
27
+ * Update version.ts with the version from package.json
28
+ */
29
+ function updateVersionFile(version: string): void {
30
+ const versionPath = join(process.cwd(), 'core/utils/version.ts')
31
+ const versionContent = `/**
32
+ * FluxStack Framework Version
33
+ * Single source of truth for version number
34
+ * Auto-synced with package.json
35
+ */
36
+ export const FLUXSTACK_VERSION = '${version}'
37
+ `
38
+ writeFileSync(versionPath, versionContent)
39
+ console.log(`✅ Updated version.ts to v${version}`)
40
+ }
41
+
42
+ /**
43
+ * Main sync function
44
+ */
45
+ function syncVersion(): void {
46
+ try {
47
+ const packageVersion = getPackageVersion()
48
+ updateVersionFile(packageVersion)
49
+ console.log(`🔄 Version synchronized: v${packageVersion}`)
50
+ } catch (error) {
51
+ console.error('❌ Failed to sync version:', error)
52
+ process.exit(1)
53
+ }
54
+ }
55
+
56
+ // Run if called directly
57
+ if (import.meta.main) {
58
+ syncVersion()
59
+ }
60
+
61
+ export { syncVersion, getPackageVersion }
@@ -1,5 +1,6 @@
1
- /**
2
- * FluxStack Framework Version
3
- * Single source of truth for version number
4
- */
5
- export const FLUXSTACK_VERSION = '1.5.4'
1
+ /**
2
+ * FluxStack Framework Version
3
+ * Single source of truth for version number
4
+ * Auto-synced with package.json
5
+ */
6
+ export const FLUXSTACK_VERSION = '1.7.0'
@@ -59,7 +59,7 @@ program
59
59
  'core',
60
60
  'app',
61
61
  'config', // ✅ CRITICAL: Copy config folder with declarative configs
62
- // 'plugins', // TODO: Copy when crypto-auth plugin is complete
62
+ 'plugins', // TODO: Copy when crypto-auth plugin is complete
63
63
  'ai-context', // ✅ CRITICAL: Copy AI documentation for users
64
64
  'bun.lock', // ✅ CRITICAL: Copy lockfile to maintain working versions
65
65
  'package.json', // ✅ Copy real package.json from framework
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fluxstack",
3
- "version": "1.5.4",
3
+ "version": "1.7.0",
4
4
  "description": "⚡ Revolutionary full-stack TypeScript framework with Declarative Config System, Elysia + React + Bun",
5
5
  "keywords": [
6
6
  "framework",
@@ -28,8 +28,10 @@
28
28
  "dev:frontend": "bun run core/cli/index.ts frontend",
29
29
  "dev:backend": "bun run core/cli/index.ts backend",
30
30
  "dev:coordinated": "concurrently --prefix {name} --names BACKEND,VITE --prefix-colors blue,green --kill-others-on-fail \"bun --watch app/server/index.ts\" \"vite --config vite.config.ts\"",
31
- "dev:clean": "bun run run-clean.ts",
32
- "build": "cross-env NODE_ENV=production bun run core/cli/index.ts build",
31
+
32
+ "sync-version": "bun run core/utils/sync-version.ts",
33
+ "prebuild": "bun run scripts/prebuild.ts",
34
+ "build": "bun run prebuild && cross-env NODE_ENV=production bun run core/cli/index.ts build",
33
35
  "build:frontend": "vite build --config vite.config.ts --emptyOutDir",
34
36
  "build:backend": "bun run core/cli/index.ts build:backend",
35
37
  "start": "bun run core/cli/index.ts start",
@@ -61,5 +61,5 @@ export const cryptoAuthAdmin = (options: CryptoAuthMiddlewareOptions = {}) => {
61
61
  }
62
62
  })
63
63
  )
64
- .as('plugin')
64
+
65
65
  }
@@ -22,5 +22,5 @@ export const cryptoAuthOptional = (options: CryptoAuthMiddlewareOptions = {}) =>
22
22
 
23
23
  return {}
24
24
  })
25
- .as('plugin')
25
+
26
26
  }
@@ -72,5 +72,5 @@ export const cryptoAuthPermissions = (
72
72
  }
73
73
  })
74
74
  )
75
- .as('plugin')
75
+
76
76
  }
@@ -41,5 +41,5 @@ export const cryptoAuthRequired = (options: CryptoAuthMiddlewareOptions = {}) =>
41
41
  }
42
42
  })
43
43
  )
44
- .as('plugin')
44
+
45
45
  }
package/vite.config.ts CHANGED
@@ -43,11 +43,19 @@ export default defineConfig({
43
43
  server: {
44
44
  port: 5173,
45
45
  host: true,
46
+ // Configuração explícita do HMR para evitar conflito com WebSocket do backend
47
+ hmr: {
48
+ protocol: 'ws',
49
+ host: 'localhost',
50
+ port: 5173,
51
+ clientPort: 5173,
52
+ },
46
53
  proxy: {
47
54
  '/api': {
48
55
  target: 'http://localhost:3000',
49
56
  changeOrigin: true,
50
57
  secure: false,
58
+ ws: true, // Habilita proxy WebSocket para live components
51
59
  }
52
60
  }
53
61
  },
package/.dockerignore DELETED
@@ -1,50 +0,0 @@
1
- # Dependencies
2
- node_modules/
3
- */node_modules/
4
-
5
- # Build outputs (will be generated in container)
6
- dist/
7
- build/
8
- .next/
9
-
10
- # Development files
11
- .env.local
12
- .env.development
13
-
14
- # IDE files
15
- .vscode/
16
- .idea/
17
- *.swp
18
- *.swo
19
-
20
- # OS files
21
- .DS_Store
22
- Thumbs.db
23
-
24
- # Logs
25
- *.log
26
- logs/
27
-
28
- # Runtime
29
- .tmp/
30
- .cache/
31
-
32
- # Git
33
- .git/
34
- .gitignore
35
-
36
- # Testing
37
- coverage/
38
- .nyc_output
39
-
40
- # Context AI (not needed in production)
41
- context_ai/
42
-
43
- # Tests (not needed in production)
44
- tests/
45
- *.test.*
46
- *.spec.*
47
-
48
- # Documentation
49
- *.md
50
- !README.md