entry.ts & registration
The host loads /modules/memo/entry.js and calls your register() synchronously, before the first render. Everything is declared there: routes, launcher, sidebar, toolbar, search.
// frontend/src/entry.ts
import { lazy } from 'react'
import {
RouteRegistry, WaffleAppRegistry, FaviconRegistry, SlotRegistry,
useSidebarStore, useToolbarStore, useSearchStore, SDK_VERSION,
} from '@kubuno/sdk'
import { useMemoStore } from './store'
import './i18n'
import './index.css'
export const sdkVersion = SDK_VERSION // garde-fou de compatibilité
export function register() {
FaviconRegistry.register('memo', '/memo-logo.svg')
WaffleAppRegistry.register('memo', 'Memo', [
{ id: 'memo', label: 'Memo', Icon: MemoLogo, path: '/memo' },
])
// Routes (composants lazy)
RouteRegistry.register('memo', lazy(() => import('./MemoApp')))
RouteRegistry.register('memo/:id', lazy(() => import('./MemoApp')))
// Barre latérale, barre d'outils, recherche
useSidebarStore.getState().register({
moduleId: 'memo', routePrefix: '/memo',
newButtonLabelKey: 'memo:create',
NewActions: MemoCreateMenu, SidebarBody: MemoSidebar,
})
useToolbarStore.getState().register({
moduleId: 'memo', routePrefix: '/memo', ToolbarComponent: MemoToolbar,
})
useSearchStore.getState().register({
moduleId: 'memo', routePrefix: '/memo',
placeholderKey: 'memo:search_ph',
onSearch: (q) => useMemoStore.getState().setQuery(q),
})
}Compatibility
export const sdkVersion = SDK_VERSION is mandatory: the host refuses to load a module whose SDK is incompatible.
The objects passed to the stores ({ moduleId, routePrefix, … }) are the SDK's exact contracts. Next up: wiring up the data.