create-fluxstack 1.18.0 → 1.19.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/CHANGELOG.md +132 -0
- package/app/client/src/App.tsx +7 -7
- package/app/client/src/components/AppLayout.tsx +60 -23
- package/app/client/src/components/ColorWheel.tsx +195 -0
- package/app/client/src/components/DemoPage.tsx +5 -3
- package/app/client/src/components/LiveUploadWidget.tsx +1 -1
- package/app/client/src/components/ThemePicker.tsx +307 -0
- package/app/client/src/config/theme.config.ts +127 -0
- package/app/client/src/hooks/useThemeClock.ts +66 -0
- package/app/client/src/index.css +193 -0
- package/app/client/src/lib/theme-clock.ts +201 -0
- package/app/client/src/live/AuthDemo.tsx +9 -9
- package/app/client/src/live/CounterDemo.tsx +10 -10
- package/app/client/src/live/FormDemo.tsx +8 -8
- package/app/client/src/live/PingPongDemo.tsx +10 -10
- package/app/client/src/live/RoomChatDemo.tsx +10 -10
- package/app/client/src/live/SharedCounterDemo.tsx +5 -5
- package/app/client/src/pages/ApiTestPage.tsx +5 -5
- package/app/client/src/pages/HomePage.tsx +12 -12
- package/app/server/index.ts +8 -0
- package/app/server/live/auto-generated-components.ts +1 -1
- package/app/server/live/rooms/ChatRoom.ts +13 -8
- package/app/server/routes/index.ts +20 -10
- package/core/build/index.ts +1 -1
- package/core/cli/command-registry.ts +1 -1
- package/core/cli/commands/build.ts +25 -6
- package/core/cli/commands/plugin-deps.ts +1 -2
- package/core/cli/generators/plugin.ts +433 -581
- package/core/framework/server.ts +34 -8
- package/core/index.ts +6 -5
- package/core/plugins/index.ts +71 -199
- package/core/plugins/types.ts +76 -461
- package/core/server/index.ts +1 -1
- package/core/utils/logger/startup-banner.ts +26 -4
- package/core/utils/version.ts +6 -6
- package/create-fluxstack.ts +216 -107
- package/package.json +108 -107
- package/tsconfig.json +2 -1
- package/app/client/.live-stubs/LiveAdminPanel.js +0 -15
- package/app/client/.live-stubs/LiveCounter.js +0 -9
- package/app/client/.live-stubs/LiveForm.js +0 -11
- package/app/client/.live-stubs/LiveLocalCounter.js +0 -8
- package/app/client/.live-stubs/LivePingPong.js +0 -10
- package/app/client/.live-stubs/LiveRoomChat.js +0 -11
- package/app/client/.live-stubs/LiveSharedCounter.js +0 -10
- package/app/client/.live-stubs/LiveUpload.js +0 -15
- package/core/plugins/config.ts +0 -356
- package/core/plugins/dependency-manager.ts +0 -481
- package/core/plugins/discovery.ts +0 -379
- package/core/plugins/executor.ts +0 -353
- package/core/plugins/manager.ts +0 -645
- package/core/plugins/module-resolver.ts +0 -227
- package/core/plugins/registry.ts +0 -913
- package/vitest.config.live.ts +0 -69
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Module Resolver para Plugins
|
|
3
|
-
* Implementa resolução em cascata: plugin local → projeto principal
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { existsSync, readFileSync } from 'fs'
|
|
7
|
-
import { join, resolve } from 'path'
|
|
8
|
-
import type { Logger } from '@core/utils/logger'
|
|
9
|
-
|
|
10
|
-
export interface ModuleResolverConfig {
|
|
11
|
-
projectRoot: string
|
|
12
|
-
logger?: Logger
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class PluginModuleResolver {
|
|
16
|
-
private config: ModuleResolverConfig
|
|
17
|
-
private logger?: Logger
|
|
18
|
-
private static readonly MAX_CACHE_SIZE = 1000
|
|
19
|
-
private resolveCache: Map<string, string> = new Map()
|
|
20
|
-
|
|
21
|
-
constructor(config: ModuleResolverConfig) {
|
|
22
|
-
this.config = config
|
|
23
|
-
this.logger = config.logger
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private cacheSet(key: string, value: string): void {
|
|
27
|
-
if (this.resolveCache.size >= PluginModuleResolver.MAX_CACHE_SIZE) {
|
|
28
|
-
const firstKey = this.resolveCache.keys().next().value
|
|
29
|
-
if (firstKey !== undefined) {
|
|
30
|
-
this.resolveCache.delete(firstKey)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
this.resolveCache.set(key, value)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Resolve um módulo com estratégia em cascata:
|
|
38
|
-
* 1. node_modules local do plugin
|
|
39
|
-
* 2. node_modules do projeto principal
|
|
40
|
-
*/
|
|
41
|
-
resolveModule(moduleName: string, pluginPath: string): string | null {
|
|
42
|
-
const cacheKey = `${pluginPath}::${moduleName}`
|
|
43
|
-
|
|
44
|
-
// Verificar cache
|
|
45
|
-
if (this.resolveCache.has(cacheKey)) {
|
|
46
|
-
return this.resolveCache.get(cacheKey)!
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this.logger?.debug(`Resolvendo módulo '${moduleName}' para plugin em '${pluginPath}'`)
|
|
50
|
-
|
|
51
|
-
// 1. Tentar no node_modules local do plugin
|
|
52
|
-
const localPath = this.tryResolveLocal(moduleName, pluginPath)
|
|
53
|
-
if (localPath) {
|
|
54
|
-
this.logger?.debug(`✅ Módulo '${moduleName}' encontrado localmente: ${localPath}`)
|
|
55
|
-
this.cacheSet(cacheKey, localPath)
|
|
56
|
-
return localPath
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 2. Tentar no node_modules do projeto principal
|
|
60
|
-
const projectPath = this.tryResolveProject(moduleName)
|
|
61
|
-
if (projectPath) {
|
|
62
|
-
this.logger?.debug(`✅ Módulo '${moduleName}' encontrado no projeto: ${projectPath}`)
|
|
63
|
-
this.cacheSet(cacheKey, projectPath)
|
|
64
|
-
return projectPath
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
this.logger?.warn(`❌ Módulo '${moduleName}' não encontrado em nenhum contexto`)
|
|
68
|
-
return null
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Tenta resolver no node_modules local do plugin
|
|
73
|
-
*/
|
|
74
|
-
private tryResolveLocal(moduleName: string, pluginPath: string): string | null {
|
|
75
|
-
const pluginDir = resolve(pluginPath)
|
|
76
|
-
const localNodeModules = join(pluginDir, 'node_modules', moduleName)
|
|
77
|
-
|
|
78
|
-
if (existsSync(localNodeModules)) {
|
|
79
|
-
// Verificar se tem package.json para pegar o entry point
|
|
80
|
-
const packageJsonPath = join(localNodeModules, 'package.json')
|
|
81
|
-
if (existsSync(packageJsonPath)) {
|
|
82
|
-
try {
|
|
83
|
-
const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
|
|
84
|
-
const entry = pkg.module || pkg.main || 'index.js'
|
|
85
|
-
const entryPath = join(localNodeModules, entry)
|
|
86
|
-
|
|
87
|
-
if (existsSync(entryPath)) {
|
|
88
|
-
return entryPath
|
|
89
|
-
}
|
|
90
|
-
} catch (error) {
|
|
91
|
-
this.logger?.debug(`Erro ao ler package.json de '${moduleName}'`, { error })
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Fallback: tentar index.js/index.ts
|
|
96
|
-
const indexJs = join(localNodeModules, 'index.js')
|
|
97
|
-
const indexTs = join(localNodeModules, 'index.ts')
|
|
98
|
-
|
|
99
|
-
if (existsSync(indexJs)) return indexJs
|
|
100
|
-
if (existsSync(indexTs)) return indexTs
|
|
101
|
-
|
|
102
|
-
return localNodeModules
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return null
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Tenta resolver no node_modules do projeto principal
|
|
110
|
-
*/
|
|
111
|
-
private tryResolveProject(moduleName: string): string | null {
|
|
112
|
-
const projectNodeModules = join(this.config.projectRoot, 'node_modules', moduleName)
|
|
113
|
-
|
|
114
|
-
if (existsSync(projectNodeModules)) {
|
|
115
|
-
// Verificar se tem package.json para pegar o entry point
|
|
116
|
-
const packageJsonPath = join(projectNodeModules, 'package.json')
|
|
117
|
-
if (existsSync(packageJsonPath)) {
|
|
118
|
-
try {
|
|
119
|
-
const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
|
|
120
|
-
const entry = pkg.module || pkg.main || 'index.js'
|
|
121
|
-
const entryPath = join(projectNodeModules, entry)
|
|
122
|
-
|
|
123
|
-
if (existsSync(entryPath)) {
|
|
124
|
-
return entryPath
|
|
125
|
-
}
|
|
126
|
-
} catch (error) {
|
|
127
|
-
this.logger?.debug(`Erro ao ler package.json de '${moduleName}'`, { error })
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Fallback: tentar index.js/index.ts
|
|
132
|
-
const indexJs = join(projectNodeModules, 'index.js')
|
|
133
|
-
const indexTs = join(projectNodeModules, 'index.ts')
|
|
134
|
-
|
|
135
|
-
if (existsSync(indexJs)) return indexJs
|
|
136
|
-
if (existsSync(indexTs)) return indexTs
|
|
137
|
-
|
|
138
|
-
return projectNodeModules
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return null
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Resolve sub-paths (ex: @noble/curves/ed25519)
|
|
146
|
-
*/
|
|
147
|
-
resolveSubpath(moduleName: string, subpath: string, pluginPath: string): string | null {
|
|
148
|
-
const fullModule = `${moduleName}/${subpath}`
|
|
149
|
-
const cacheKey = `${pluginPath}::${fullModule}`
|
|
150
|
-
|
|
151
|
-
// Verificar cache
|
|
152
|
-
if (this.resolveCache.has(cacheKey)) {
|
|
153
|
-
return this.resolveCache.get(cacheKey)!
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
this.logger?.debug(`Resolvendo subpath '${fullModule}' para plugin em '${pluginPath}'`)
|
|
157
|
-
|
|
158
|
-
// 1. Tentar no node_modules local do plugin
|
|
159
|
-
const pluginDir = resolve(pluginPath)
|
|
160
|
-
const localPath = join(pluginDir, 'node_modules', fullModule)
|
|
161
|
-
|
|
162
|
-
if (this.existsWithExtension(localPath)) {
|
|
163
|
-
const resolvedLocal = this.findFileWithExtension(localPath)
|
|
164
|
-
if (resolvedLocal) {
|
|
165
|
-
this.logger?.debug(`✅ Subpath '${fullModule}' encontrado localmente: ${resolvedLocal}`)
|
|
166
|
-
this.cacheSet(cacheKey, resolvedLocal)
|
|
167
|
-
return resolvedLocal
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// 2. Tentar no node_modules do projeto principal
|
|
172
|
-
const projectPath = join(this.config.projectRoot, 'node_modules', fullModule)
|
|
173
|
-
|
|
174
|
-
if (this.existsWithExtension(projectPath)) {
|
|
175
|
-
const resolvedProject = this.findFileWithExtension(projectPath)
|
|
176
|
-
if (resolvedProject) {
|
|
177
|
-
this.logger?.debug(`✅ Subpath '${fullModule}' encontrado no projeto: ${resolvedProject}`)
|
|
178
|
-
this.cacheSet(cacheKey, resolvedProject)
|
|
179
|
-
return resolvedProject
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
this.logger?.warn(`❌ Subpath '${fullModule}' não encontrado em nenhum contexto`)
|
|
184
|
-
return null
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Verifica se arquivo existe com alguma extensão comum
|
|
189
|
-
*/
|
|
190
|
-
private existsWithExtension(basePath: string): boolean {
|
|
191
|
-
const extensions = ['', '.js', '.ts', '.mjs', '.cjs', '.jsx', '.tsx', '/index.js', '/index.ts']
|
|
192
|
-
return extensions.some(ext => existsSync(basePath + ext))
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Encontra arquivo com extensão
|
|
197
|
-
*/
|
|
198
|
-
private findFileWithExtension(basePath: string): string | null {
|
|
199
|
-
const extensions = ['', '.js', '.ts', '.mjs', '.cjs', '.jsx', '.tsx', '/index.js', '/index.ts']
|
|
200
|
-
|
|
201
|
-
for (const ext of extensions) {
|
|
202
|
-
const fullPath = basePath + ext
|
|
203
|
-
if (existsSync(fullPath)) {
|
|
204
|
-
return fullPath
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return null
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Limpar cache
|
|
213
|
-
*/
|
|
214
|
-
clearCache(): void {
|
|
215
|
-
this.resolveCache.clear()
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Obter estatísticas
|
|
220
|
-
*/
|
|
221
|
-
getStats() {
|
|
222
|
-
return {
|
|
223
|
-
cachedModules: this.resolveCache.size,
|
|
224
|
-
projectRoot: this.config.projectRoot
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|