create-fluxstack 1.14.0 → 1.16.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/LLMD/INDEX.md +4 -3
- package/LLMD/resources/live-binary-delta.md +507 -0
- package/LLMD/resources/live-components.md +208 -12
- package/LLMD/resources/live-rooms.md +731 -333
- package/app/client/.live-stubs/LiveAdminPanel.js +5 -0
- package/app/client/.live-stubs/LiveCounter.js +9 -0
- package/app/client/.live-stubs/LiveForm.js +11 -0
- package/app/client/.live-stubs/LiveLocalCounter.js +8 -0
- package/app/client/.live-stubs/LivePingPong.js +10 -0
- package/app/client/.live-stubs/LiveRoomChat.js +11 -0
- package/app/client/.live-stubs/LiveSharedCounter.js +10 -0
- package/app/client/.live-stubs/LiveUpload.js +15 -0
- package/app/client/src/App.tsx +19 -7
- package/app/client/src/components/AppLayout.tsx +18 -10
- package/app/client/src/live/PingPongDemo.tsx +199 -0
- package/app/client/src/live/RoomChatDemo.tsx +187 -22
- package/app/client/src/live/SharedCounterDemo.tsx +142 -0
- package/app/server/auth/DevAuthProvider.ts +2 -2
- package/app/server/auth/JWTAuthProvider.example.ts +2 -2
- package/app/server/index.ts +2 -2
- package/app/server/live/LiveAdminPanel.ts +1 -1
- package/app/server/live/LivePingPong.ts +61 -0
- package/app/server/live/LiveProtectedChat.ts +1 -1
- package/app/server/live/LiveRoomChat.ts +106 -38
- package/app/server/live/LiveSharedCounter.ts +73 -0
- package/app/server/live/rooms/ChatRoom.ts +68 -0
- package/app/server/live/rooms/CounterRoom.ts +51 -0
- package/app/server/live/rooms/DirectoryRoom.ts +42 -0
- package/app/server/live/rooms/PingRoom.ts +40 -0
- package/app/server/routes/room.routes.ts +1 -2
- package/core/build/live-components-generator.ts +11 -2
- package/core/build/vite-plugins.ts +28 -0
- package/core/client/hooks/useLiveUpload.ts +3 -4
- package/core/client/index.ts +25 -35
- package/core/framework/server.ts +1 -1
- package/core/server/index.ts +1 -2
- package/core/server/live/auto-generated-components.ts +5 -8
- package/core/server/live/index.ts +90 -21
- package/core/server/live/websocket-plugin.ts +54 -1079
- package/core/types/types.ts +76 -1025
- package/core/utils/version.ts +1 -1
- package/create-fluxstack.ts +1 -1
- package/package.json +100 -95
- package/plugins/crypto-auth/index.ts +1 -1
- package/plugins/crypto-auth/server/CryptoAuthLiveProvider.ts +2 -2
- package/tsconfig.json +4 -1
- package/vite.config.ts +40 -12
- package/app/client/src/live/ChatDemo.tsx +0 -107
- package/app/client/src/live/LiveDebuggerPanel.tsx +0 -779
- package/app/server/live/LiveChat.ts +0 -78
- package/core/client/LiveComponentsProvider.tsx +0 -531
- package/core/client/components/Live.tsx +0 -111
- package/core/client/components/LiveDebugger.tsx +0 -1324
- package/core/client/hooks/AdaptiveChunkSizer.ts +0 -215
- package/core/client/hooks/state-validator.ts +0 -130
- package/core/client/hooks/useChunkedUpload.ts +0 -359
- package/core/client/hooks/useLiveChunkedUpload.ts +0 -87
- package/core/client/hooks/useLiveComponent.ts +0 -853
- package/core/client/hooks/useLiveDebugger.ts +0 -392
- package/core/client/hooks/useRoom.ts +0 -409
- package/core/client/hooks/useRoomProxy.ts +0 -382
- package/core/server/live/ComponentRegistry.ts +0 -1128
- package/core/server/live/FileUploadManager.ts +0 -446
- package/core/server/live/LiveComponentPerformanceMonitor.ts +0 -931
- package/core/server/live/LiveDebugger.ts +0 -462
- package/core/server/live/LiveLogger.ts +0 -144
- package/core/server/live/LiveRoomManager.ts +0 -278
- package/core/server/live/RoomEventBus.ts +0 -234
- package/core/server/live/RoomStateManager.ts +0 -172
- package/core/server/live/SingleConnectionManager.ts +0 -0
- package/core/server/live/StateSignature.ts +0 -705
- package/core/server/live/WebSocketConnectionManager.ts +0 -710
- package/core/server/live/auth/LiveAuthContext.ts +0 -71
- package/core/server/live/auth/LiveAuthManager.ts +0 -304
- package/core/server/live/auth/index.ts +0 -19
- package/core/server/live/auth/types.ts +0 -179
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
// 🔥 FluxStack Live - Hook para componentes real-time
|
|
2
|
-
//
|
|
3
|
-
// Uso:
|
|
4
|
-
// import { Live } from '@/core/client'
|
|
5
|
-
// import { LiveForm } from '@server/live/LiveForm'
|
|
6
|
-
//
|
|
7
|
-
// // Sem estado inicial - usa defaultState do componente
|
|
8
|
-
// const form = Live.use(LiveForm)
|
|
9
|
-
//
|
|
10
|
-
// // Com estado inicial parcial (override)
|
|
11
|
-
// const form = Live.use(LiveForm, { name: 'João' })
|
|
12
|
-
//
|
|
13
|
-
// return (
|
|
14
|
-
// <input {...form.$field('name', { syncOn: 'blur' })} />
|
|
15
|
-
// <button onClick={() => form.submit()}>Enviar</button>
|
|
16
|
-
// )
|
|
17
|
-
//
|
|
18
|
-
// 🔥 Broadcasts Tipados (Discriminated Union):
|
|
19
|
-
// // No servidor, defina a interface de broadcasts:
|
|
20
|
-
// export interface LiveFormBroadcasts {
|
|
21
|
-
// FORM_SUBMITTED: { formId: string; data: any }
|
|
22
|
-
// FIELD_CHANGED: { field: string; value: any }
|
|
23
|
-
// }
|
|
24
|
-
//
|
|
25
|
-
// // No cliente, use com tipagem automática (discriminated union):
|
|
26
|
-
// import { LiveForm, type LiveFormBroadcasts } from '@server/live/LiveForm'
|
|
27
|
-
//
|
|
28
|
-
// const form = Live.use(LiveForm)
|
|
29
|
-
// form.$onBroadcast<LiveFormBroadcasts>((event) => {
|
|
30
|
-
// switch (event.type) {
|
|
31
|
-
// case 'FORM_SUBMITTED':
|
|
32
|
-
// console.log(event.data.formId) // ✅ Tipado como string!
|
|
33
|
-
// break
|
|
34
|
-
// case 'FIELD_CHANGED':
|
|
35
|
-
// console.log(event.data.field) // ✅ Tipado como string!
|
|
36
|
-
// break
|
|
37
|
-
// }
|
|
38
|
-
// })
|
|
39
|
-
|
|
40
|
-
import { useLiveComponent } from '../hooks/useLiveComponent'
|
|
41
|
-
import type { UseLiveComponentOptions, LiveProxy, LiveProxyWithBroadcasts } from '../hooks/useLiveComponent'
|
|
42
|
-
|
|
43
|
-
// ===== Tipos para Inferência do Servidor =====
|
|
44
|
-
|
|
45
|
-
// Extrai o defaultState estático da classe
|
|
46
|
-
type ExtractDefaultState<T> = T extends { defaultState: infer S }
|
|
47
|
-
? S extends Record<string, any> ? S : Record<string, any>
|
|
48
|
-
: Record<string, any>
|
|
49
|
-
|
|
50
|
-
// Extrai o State da classe do servidor (via instance.state)
|
|
51
|
-
type ExtractState<T> = T extends { new(...args: any[]): { state: infer S } }
|
|
52
|
-
? S extends Record<string, any> ? S : Record<string, any>
|
|
53
|
-
: ExtractDefaultState<T>
|
|
54
|
-
|
|
55
|
-
// Extrai os nomes de publicActions como union type
|
|
56
|
-
type ExtractPublicActionNames<T> = T extends { publicActions: readonly (infer A)[] }
|
|
57
|
-
? A extends string ? A : never
|
|
58
|
-
: never
|
|
59
|
-
|
|
60
|
-
// Extrai as Actions respeitando publicActions (MANDATORY)
|
|
61
|
-
// - Se publicActions está definido: somente métodos listados são expostos
|
|
62
|
-
// - Se publicActions NÃO está definido: nenhuma action disponível (secure by default)
|
|
63
|
-
type ExtractActions<T> = T extends { new(...args: any[]): infer Instance }
|
|
64
|
-
? T extends { publicActions: readonly string[] }
|
|
65
|
-
? {
|
|
66
|
-
[K in keyof Instance as K extends ExtractPublicActionNames<T>
|
|
67
|
-
? Instance[K] extends (...args: any[]) => Promise<any> ? K : never
|
|
68
|
-
: never
|
|
69
|
-
]: Instance[K]
|
|
70
|
-
}
|
|
71
|
-
: Record<string, never>
|
|
72
|
-
: Record<string, never>
|
|
73
|
-
|
|
74
|
-
// ===== Opções do Live.use() =====
|
|
75
|
-
|
|
76
|
-
interface LiveUseOptions<TState> extends UseLiveComponentOptions {
|
|
77
|
-
/** Estado inicial para o componente */
|
|
78
|
-
initialState?: Partial<TState>
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// ===== Hook Principal =====
|
|
82
|
-
|
|
83
|
-
function useLive<
|
|
84
|
-
T extends { new(...args: any[]): any; defaultState?: Record<string, any>; componentName: string; publicActions?: readonly string[] },
|
|
85
|
-
TBroadcasts extends Record<string, any> = Record<string, any>
|
|
86
|
-
>(
|
|
87
|
-
ComponentClass: T,
|
|
88
|
-
options?: LiveUseOptions<ExtractState<T>>
|
|
89
|
-
): LiveProxyWithBroadcasts<ExtractState<T>, ExtractActions<T>, TBroadcasts> {
|
|
90
|
-
// Use static componentName (required for production builds with minification)
|
|
91
|
-
const componentName = ComponentClass.componentName
|
|
92
|
-
|
|
93
|
-
// Usa defaultState da classe se não passar initialState
|
|
94
|
-
const defaultState = (ComponentClass as any).defaultState || {}
|
|
95
|
-
const { initialState, ...restOptions } = options || {}
|
|
96
|
-
const mergedState = { ...defaultState, ...initialState } as ExtractState<T>
|
|
97
|
-
|
|
98
|
-
return useLiveComponent<ExtractState<T>, ExtractActions<T>, TBroadcasts>(
|
|
99
|
-
componentName,
|
|
100
|
-
mergedState,
|
|
101
|
-
restOptions
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ===== Export =====
|
|
106
|
-
|
|
107
|
-
export const Live = {
|
|
108
|
-
use: useLive
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export default Live
|