@ramme-io/kernel 5.0.0 → 6.0.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/README.md CHANGED
@@ -4,61 +4,68 @@
4
4
 
5
5
  **The core routing, rendering, and state engine for Ramme applications.**
6
6
 
7
- The Kernel is the brain of every Ramme app. It reads your declarative configuration files (`app.manifest.ts` and `sitemap.ts`), constructs the routing tree, and dynamically renders the correct components via the component registry — all without you writing a single line of routing code.
7
+ The Kernel is the brain of every Ramme app. It owns two rendering paths: a
8
+ **sitemap** you turn into routes with one call, and a **manifest** it renders
9
+ into pages without you writing components at all.
8
10
 
9
11
  ---
10
12
 
11
13
  ## Architecture
12
14
 
13
- The Kernel operates on three core inputs:
14
-
15
15
  ### 1. The Manifest (`app.manifest.ts`)
16
16
 
17
- The global configuration for your application. Defines the app title, description, default theme, and high-level settings.
17
+ The application specification. Its shape is `AppSpecification`, validated by
18
+ `AppSpecificationSchema` in `@ramme-io/shared` — `meta` and `config` are
19
+ required, and `pages` carries the manifest-rendered surface.
18
20
 
19
21
  ```typescript
20
22
  // src/config/app.manifest.ts
21
- export const appManifest = {
22
- name: 'My Ramme App',
23
- description: 'A hardware-accelerated dashboard.',
24
- theme: 'midnight',
25
- version: '1.0.0',
23
+ import type { AppSpecification } from '@ramme-io/kernel';
24
+
25
+ export const appManifest: AppSpecification = {
26
+ meta: { name: 'My Ramme App', version: '1.0.0' },
27
+ config: { theme: 'midnight', mockMode: false },
28
+ domain: { signals: [], entities: [] },
29
+ pages: [],
26
30
  };
27
31
  ```
28
32
 
29
- ### 2. The Sitemap (`sitemap.ts`)
33
+ ### 2. The Sitemap (`*.sitemap.ts`)
30
34
 
31
- The declarative routing and navigation structure. Each entry defines a page, its path, the component to render, and its position in the navigation hierarchy.
35
+ The declarative routing and navigation structure: an array of `SitemapEntry`.
36
+ `component` holds the **component itself**, not its name — the sitemap is
37
+ TypeScript, so a typo is a compile error rather than a blank page at runtime.
32
38
 
33
- ```typescript
34
- // src/config/sitemap.ts
35
- export const sitemap = [
36
- {
37
- path: '/',
38
- label: 'Dashboard',
39
- icon: 'layout-dashboard',
40
- component: 'DashboardPage',
41
- },
42
- {
43
- path: '/settings',
44
- label: 'Settings',
45
- icon: 'settings',
46
- component: 'SettingsPage',
47
- },
39
+ ```tsx
40
+ // src/templates/dashboard/dashboard.sitemap.ts
41
+ import type { SitemapEntry } from '@ramme-io/kernel';
42
+ import DashboardPage from '../../features/dashboard/pages/DashboardPage';
43
+ import SettingsPage from '../../features/settings/pages/SettingsPage';
44
+
45
+ export const dashboardSitemap: SitemapEntry[] = [
46
+ { id: 'home', path: '', title: 'Dashboard', icon: 'layout-dashboard', component: DashboardPage },
47
+ { id: 'settings', path: 'settings', title: 'Settings', icon: 'settings', component: SettingsPage },
48
48
  ];
49
49
  ```
50
50
 
51
+ A sitemap lives next to the layout that serves it, not in one global file. Each
52
+ layout provides its own through `SitemapProvider`, which is what makes the
53
+ layouts swappable — see `products/ramme-marketing/src/templates/`.
54
+
51
55
  ### 3. The Component Registry (`component-registry.tsx`)
52
56
 
53
- Maps the string-based component names from the sitemap to actual React components. This is what allows the Kernel to dynamically render your pages without hardcoded imports in the router.
57
+ Maps **string** component names to React components. This is what renders the
58
+ *manifest*, not the sitemap: `DynamicBlock` resolves `block.type` through it, so
59
+ an AI-authored or user-authored manifest can name `'StatCard'` and get one.
54
60
 
55
61
  ```tsx
56
- // src/core/component-registry.tsx
57
- import { lazy } from 'react';
62
+ // src/config/component-registry.tsx
63
+ import { AUTO_REGISTRY } from '@ramme-io/ui';
64
+ import { SmartTable } from '@ramme-io/kernel';
58
65
 
59
- export const componentRegistry: Record<string, React.LazyExoticComponent<any>> = {
60
- DashboardPage: lazy(() => import('../pages/DashboardPage')),
61
- SettingsPage: lazy(() => import('../pages/SettingsPage')),
66
+ export const COMPONENT_REGISTRY: Record<string, React.FC<any>> = {
67
+ ...AUTO_REGISTRY, // every catalogued @ramme-io/ui component
68
+ SmartTable, // local data-connected blocks
62
69
  };
63
70
  ```
64
71
 
@@ -66,46 +73,73 @@ export const componentRegistry: Record<string, React.LazyExoticComponent<any>> =
66
73
 
67
74
  ## How It Works
68
75
 
69
- 1. **Boot** — The Kernel reads `app.manifest.ts` and applies global settings (theme, metadata).
70
- 2. **Parse** — It ingests `sitemap.ts` and constructs a routing tree from the declarative page definitions.
71
- 3. **Resolve** — For each route, the Kernel looks up the `component` key in the component registry.
72
- 4. **Render** — The resolved React component is lazy-loaded and rendered inside the application shell.
76
+ **Routing path** — `generateRoutes(sitemap)` walks the array recursively and
77
+ returns react-router `<Route>` elements, adding an index redirect from every
78
+ parent to its first child so a folder route is never blank. Your app renders the
79
+ result; the Kernel builds it.
80
+
81
+ **Manifest path** — `ManifestProvider` holds the `AppSpecification`.
82
+ `DynamicPage` looks a page up by id, and `DynamicBlock` hydrates each block:
83
+ resolving `block.type` through the registry, injecting live values from the
84
+ Signal engine for a `signalId`, and loading data for a `dataId`.
73
85
 
74
- The developer never writes `<Route>` elements manually. The Kernel handles all routing, code-splitting, and navigation generation from the sitemap alone.
86
+ The two are independent. An app can use the sitemap alone and never touch
87
+ `pages`, which is what the products in this repo do.
75
88
 
76
89
  ---
77
90
 
78
91
  ## Integration
79
92
 
80
- In a standard Ramme app (generated by `@ramme-io/create-app`), the Kernel is pre-wired. If integrating manually:
93
+ In a standard Ramme app (generated by `@ramme-io/create-app`), the Kernel is
94
+ pre-wired. Mounting it manually — this is `products/ramme-marketing/src/main.tsx`,
95
+ trimmed:
81
96
 
82
97
  ```tsx
83
- import { ManifestProvider } from '@ramme-io/kernel';
98
+ import { BrowserRouter } from 'react-router-dom';
99
+ import { ThemeProvider, ToastProvider } from '@ramme-io/ui';
100
+ import { ManifestProvider, MqttProvider, AuthProvider } from '@ramme-io/kernel';
84
101
  import { appManifest } from './config/app.manifest';
85
- import { sitemap } from './config/sitemap';
86
- import { componentRegistry } from './core/component-registry';
102
+ import App from './App';
87
103
 
88
- export default function App() {
104
+ export default function Root() {
89
105
  return (
90
- <ManifestProvider
91
- manifest={appManifest}
92
- sitemap={sitemap}
93
- registry={componentRegistry}
94
- >
95
- {/* The Kernel renders your app here */}
96
- </ManifestProvider>
106
+ // BrowserRouter must be outermost: providers below it use router hooks.
107
+ <BrowserRouter>
108
+ <ManifestProvider manifest={appManifest}>
109
+ <ThemeProvider appId="marketing" defaultTheme="light">
110
+ <ToastProvider>
111
+ <AuthProvider>
112
+ <MqttProvider>
113
+ <App />
114
+ </MqttProvider>
115
+ </AuthProvider>
116
+ </ToastProvider>
117
+ </ThemeProvider>
118
+ </ManifestProvider>
119
+ </BrowserRouter>
97
120
  );
98
121
  }
99
122
  ```
100
123
 
124
+ `ManifestProvider` takes only `manifest`. The sitemap and the registry are not
125
+ props — a layout provides its sitemap via `SitemapProvider`, and the registry is
126
+ passed to `DynamicBlock` at the point of rendering.
127
+
101
128
  ---
102
129
 
103
130
  ## Key Exports
104
131
 
105
- - **`ManifestProvider`** — The root context provider that hydrates the app with manifest and sitemap data.
106
- - **`useManifest()`** — Hook to access the current app manifest from any component.
107
- - **`useDevice()`** — Hook for consuming normalized telemetry data from connected hardware.
108
- - **`MqttProvider`** — Context provider for real-time MQTT/Ably device communication.
132
+ - **`ManifestProvider`** / **`useManifest()`** — holds and reads the `AppSpecification`.
133
+ - **`SitemapProvider`** / **`useSitemap()`** — the active layout's sitemap, for sidebars, breadcrumbs and titles.
134
+ - **`generateRoutes(sitemap)`** — sitemap array to react-router `<Route>` tree.
135
+ - **`useDynamicSitemap(staticSitemap)`** — merges manifest-authored pages into a static sitemap.
136
+ - **`DynamicPage`** / **`DynamicBlock`** — the manifest renderers.
137
+ - **`useDevice()`** — normalized telemetry from connected hardware.
138
+ - **`MqttProvider`** — MQTT device communication. Ably transport is not in the Kernel; `products/bodewell-web/src/lib/ablyClient.ts` owns it.
139
+ - **`AuthProvider`** / **`useAuth()`** / **`ProtectedRoute`** — authentication.
140
+
141
+ > `useTheme` is **not** exported here — it belongs to `@ramme-io/ui`. There is no
142
+ > `useNavigation`; navigation state comes from `useSitemap` and react-router.
109
143
 
110
144
  ---
111
145