Restructure tree by role; rename mizan-runtime → mizan-base
packages/ flattens into: backends/ server protocol adapters (mizan-django, mizan-ts) frontends/ client kernel + framework adapters (mizan-base, mizan-react, mizan-vue, mizan-svelte) workers/ runtime workers (mizan-ssr) cores/ shared language-level primitives (empty for now; mizan-python forthcoming) The frontend kernel (was packages/mizan-runtime, now frontends/mizan-base) is renamed to reflect its role — it's the shared base that frontend adapters depend on directly. Reflects the substrate position that per-framework adapters wrap a single shared kernel; codegen targets the adapter, not the raw kernel. Path updates landed in: Makefile, two Gitea workflows, Dockerfile.test, four example/harness config files, .claude/settings.local.json, four docs (CLAUDE/ISSUES/ROADMAP/AFI_ARCHITECTURE), four codegen templates (stage1 + react/vue/svelte adapters), and three package.jsons (the mizan-base rename plus mizan-vue/svelte peerDeps). Generated files under examples/django-react-site/harness/src/api/ still reference @mizan/runtime — left as-is; they're regenerated artifacts and the harness is non-functional pending the React wrapper-layer codegen. Also folded in a pre-existing fix: the Gitea workflows had working-directory: react / django pointing at a layout that predates packages/, never updated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
76
frontends/mizan-react/src/channels/index.ts
Normal file
76
frontends/mizan-react/src/channels/index.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* mizan/channels
|
||||
*
|
||||
* Real-time WebSocket communication with Django Channels.
|
||||
* Type-safe bidirectional messaging.
|
||||
*
|
||||
* ## Setup
|
||||
*
|
||||
* ```tsx
|
||||
* // layout.tsx
|
||||
* import { ChannelProvider } from 'mizan/channels'
|
||||
*
|
||||
* export default function Layout({ children }) {
|
||||
* return (
|
||||
* <ChannelProvider>
|
||||
* {children}
|
||||
* </ChannelProvider>
|
||||
* )
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* ## Usage
|
||||
*
|
||||
* ```tsx
|
||||
* // Using generated hooks (recommended)
|
||||
* import { useChatChannel } from '@/api/generated.channels'
|
||||
*
|
||||
* function Chat({ room }) {
|
||||
* const chat = useChatChannel({ room })
|
||||
*
|
||||
* chat.status // 'connecting' | 'connected' | 'disconnected'
|
||||
* chat.messages // DjangoMessage[]
|
||||
* chat.send({ text: 'Hello' }) // Send ReactMessage
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* ```tsx
|
||||
* // Using raw hook (for custom channels)
|
||||
* import { useChannel } from 'mizan/channels'
|
||||
*
|
||||
* function CustomChannel() {
|
||||
* const channel = useChannel<
|
||||
* { room: string }, // Params
|
||||
* { user: string; text: string }, // DjangoMessage
|
||||
* { text: string } // ReactMessage
|
||||
* >('chat', { room: 'general' })
|
||||
*
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
|
||||
// Context
|
||||
export { ChannelProvider, useChannelContext, useChannelStatus } from './context'
|
||||
export type { ChannelProviderProps } from './context'
|
||||
|
||||
// Hooks
|
||||
export { useChannel, useChannelLatest, useRPC, RPCError } from './hooks'
|
||||
export type { UseChannelOptions, RPCClient } from './hooks'
|
||||
|
||||
// Connection (for advanced use)
|
||||
export { ChannelConnection, getDefaultConnection } from './connection'
|
||||
export type {
|
||||
ChannelConnectionOptions,
|
||||
RPCRequest,
|
||||
RPCResponse,
|
||||
RPCSuccessResponse,
|
||||
RPCErrorResponse,
|
||||
} from './connection'
|
||||
|
||||
// Types
|
||||
export type {
|
||||
ConnectionStatus,
|
||||
ChannelSubscription,
|
||||
SubscribeOptions,
|
||||
} from './types'
|
||||
Reference in New Issue
Block a user