@flightdev/ui 2.0.0 → 4.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 +285 -70
- package/dist/{chunk-XTDK7ME5.js → chunk-S4DTUQII.js} +246 -19
- package/dist/chunk-S4DTUQII.js.map +1 -0
- package/dist/core/index.d.ts +423 -3
- package/dist/core/index.js +23 -2
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +29 -5
- package/dist/index.js.map +1 -0
- package/package.json +11 -181
- package/.turbo/turbo-build.log +0 -81
- package/.turbo/turbo-lint.log +0 -40
- package/.turbo/turbo-typecheck.log +0 -4
- package/TESTING.md +0 -124
- package/dist/adapter-MMD-iHNx.d.ts +0 -424
- package/dist/adapters/tier-1/angular.d.ts +0 -60
- package/dist/adapters/tier-1/angular.js +0 -2
- package/dist/adapters/tier-1/index.d.ts +0 -7
- package/dist/adapters/tier-1/index.js +0 -7
- package/dist/adapters/tier-1/qwik.d.ts +0 -55
- package/dist/adapters/tier-1/qwik.js +0 -2
- package/dist/adapters/tier-1/react.d.ts +0 -67
- package/dist/adapters/tier-1/react.js +0 -2
- package/dist/adapters/tier-1/solid.d.ts +0 -45
- package/dist/adapters/tier-1/solid.js +0 -2
- package/dist/adapters/tier-1/svelte.d.ts +0 -48
- package/dist/adapters/tier-1/svelte.js +0 -2
- package/dist/adapters/tier-1/vue.d.ts +0 -47
- package/dist/adapters/tier-1/vue.js +0 -2
- package/dist/adapters/tier-2/index.d.ts +0 -7
- package/dist/adapters/tier-2/index.js +0 -7
- package/dist/adapters/tier-2/inferno.d.ts +0 -31
- package/dist/adapters/tier-2/inferno.js +0 -2
- package/dist/adapters/tier-2/lit.d.ts +0 -34
- package/dist/adapters/tier-2/lit.js +0 -2
- package/dist/adapters/tier-2/marko.d.ts +0 -59
- package/dist/adapters/tier-2/marko.js +0 -2
- package/dist/adapters/tier-2/mithril.d.ts +0 -31
- package/dist/adapters/tier-2/mithril.js +0 -2
- package/dist/adapters/tier-2/preact.d.ts +0 -33
- package/dist/adapters/tier-2/preact.js +0 -2
- package/dist/adapters/tier-2/stencil.d.ts +0 -52
- package/dist/adapters/tier-2/stencil.js +0 -2
- package/dist/adapters/tier-3/alpine.d.ts +0 -73
- package/dist/adapters/tier-3/alpine.js +0 -2
- package/dist/adapters/tier-3/hotwire.d.ts +0 -71
- package/dist/adapters/tier-3/hotwire.js +0 -2
- package/dist/adapters/tier-3/htmx.d.ts +0 -88
- package/dist/adapters/tier-3/htmx.js +0 -2
- package/dist/adapters/tier-3/index.d.ts +0 -7
- package/dist/adapters/tier-3/index.js +0 -7
- package/dist/adapters/tier-3/petite-vue.d.ts +0 -56
- package/dist/adapters/tier-3/petite-vue.js +0 -2
- package/dist/adapters/tier-3/stimulus.d.ts +0 -63
- package/dist/adapters/tier-3/stimulus.js +0 -2
- package/dist/adapters/tier-3/vanilla.d.ts +0 -63
- package/dist/adapters/tier-3/vanilla.js +0 -2
- package/dist/chunk-2SNQ6PTM.js +0 -217
- package/dist/chunk-3D4XMIZI.js +0 -136
- package/dist/chunk-3HU6GSQ4.js +0 -125
- package/dist/chunk-4PZDNFL7.js +0 -148
- package/dist/chunk-5IBLFTYL.js +0 -114
- package/dist/chunk-64JZJ7OK.js +0 -142
- package/dist/chunk-7ZJI3QU2.js +0 -132
- package/dist/chunk-CE4FJHQJ.js +0 -133
- package/dist/chunk-DTCAUBH5.js +0 -87
- package/dist/chunk-NTASPOHG.js +0 -106
- package/dist/chunk-OI2AMQLG.js +0 -152
- package/dist/chunk-Q7HUE44H.js +0 -106
- package/dist/chunk-QH3LOWXU.js +0 -155
- package/dist/chunk-QIVAK6BH.js +0 -103
- package/dist/chunk-V34XPVGK.js +0 -103
- package/dist/chunk-VK7ZPMO7.js +0 -221
- package/dist/chunk-X6CNUW6T.js +0 -136
- package/dist/chunk-YFGSHW5S.js +0 -121
- package/dist/chunk-ZAJVSE7J.js +0 -90
- package/docs/ADAPTERS.md +0 -946
- package/docs/PATTERNS.md +0 -836
- package/src/adapters/tier-1/angular.ts +0 -223
- package/src/adapters/tier-1/index.ts +0 -12
- package/src/adapters/tier-1/qwik.ts +0 -177
- package/src/adapters/tier-1/react.ts +0 -330
- package/src/adapters/tier-1/solid.ts +0 -222
- package/src/adapters/tier-1/svelte.ts +0 -211
- package/src/adapters/tier-1/vue.ts +0 -234
- package/src/adapters/tier-2/index.ts +0 -12
- package/src/adapters/tier-2/inferno.ts +0 -149
- package/src/adapters/tier-2/lit.ts +0 -191
- package/src/adapters/tier-2/marko.ts +0 -199
- package/src/adapters/tier-2/mithril.ts +0 -152
- package/src/adapters/tier-2/preact.ts +0 -133
- package/src/adapters/tier-2/stencil.ts +0 -214
- package/src/adapters/tier-3/alpine.ts +0 -218
- package/src/adapters/tier-3/hotwire.ts +0 -254
- package/src/adapters/tier-3/htmx.ts +0 -263
- package/src/adapters/tier-3/index.ts +0 -12
- package/src/adapters/tier-3/petite-vue.ts +0 -163
- package/src/adapters/tier-3/stimulus.ts +0 -233
- package/src/adapters/tier-3/vanilla.ts +0 -252
- package/src/ambient.d.ts +0 -310
- package/src/core/adapter.ts +0 -366
- package/src/core/index.ts +0 -56
- package/src/core/registry.ts +0 -518
- package/src/core/types.ts +0 -461
- package/src/htmx.ts +0 -134
- package/src/index.ts +0 -263
- package/test/__mocks__/stencil-core.ts +0 -19
- package/test/__mocks__/stencil-hydrate.ts +0 -15
- package/test/adapters/tier-1.test.ts +0 -206
- package/test/adapters/tier-2.test.ts +0 -175
- package/test/adapters/tier-3.test.ts +0 -284
- package/test/contracts/adapter.contract.ts +0 -293
- package/test/core/core.test.ts +0 -310
- package/test/errors/error-handling.test.ts +0 -454
- package/test/integration/htmx.integration.test.ts +0 -246
- package/test/integration/react.integration.test.ts +0 -271
- package/test/integration/registry.integration.test.ts +0 -308
- package/tsconfig.json +0 -22
- package/tsup.config.ts +0 -93
- package/vitest.config.ts +0 -101
package/README.md
CHANGED
|
@@ -1,91 +1,306 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @flightdev/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The universal UI framework layer for Flight. Provides server-side rendering (SSR) and hydration support for 18+ UI frameworks.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Quick Start](#quick-start)
|
|
9
|
+
- [Architecture](#architecture)
|
|
10
|
+
- [Adapter Registry](#adapter-registry)
|
|
11
|
+
- [Rendering](#rendering)
|
|
12
|
+
- [API Reference](#api-reference)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
|
|
15
|
+
---
|
|
4
16
|
|
|
5
17
|
## Installation
|
|
6
18
|
|
|
7
19
|
```bash
|
|
8
|
-
npm install @
|
|
20
|
+
npm install @flightdev/ui
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then install the adapter for your framework:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @flightdev/ui-react # React 18+
|
|
27
|
+
npm install @flightdev/ui-vue # Vue 3
|
|
28
|
+
npm install @flightdev/ui-angular # Angular 17+
|
|
29
|
+
npm install @flightdev/ui-svelte # Svelte 5
|
|
30
|
+
npm install @flightdev/ui-solid # Solid.js
|
|
31
|
+
npm install @flightdev/ui-qwik # Qwik
|
|
9
32
|
```
|
|
10
33
|
|
|
11
|
-
|
|
34
|
+
---
|
|
12
35
|
|
|
13
|
-
|
|
36
|
+
## Quick Start
|
|
14
37
|
|
|
15
|
-
```
|
|
16
|
-
import {
|
|
38
|
+
```typescript
|
|
39
|
+
import { defineUI, renderPage, toHTML } from '@flightdev/ui';
|
|
40
|
+
import { react } from '@flightdev/ui-react';
|
|
17
41
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
// Define UI configuration
|
|
43
|
+
const ui = defineUI(react());
|
|
44
|
+
|
|
45
|
+
// Render a component
|
|
46
|
+
const result = await renderPage(ui, {
|
|
47
|
+
component: App,
|
|
48
|
+
props: { user: { name: 'John' } },
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Generate full HTML document
|
|
52
|
+
const html = toHTML(result, {
|
|
53
|
+
title: 'My App',
|
|
54
|
+
lang: 'en',
|
|
55
|
+
});
|
|
29
56
|
```
|
|
30
57
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Architecture
|
|
61
|
+
|
|
62
|
+
The UI system is organized into three tiers based on feature support:
|
|
63
|
+
|
|
64
|
+
### Tier 1: Full Support
|
|
65
|
+
|
|
66
|
+
Full SSR, streaming, hydration, and islands architecture support.
|
|
67
|
+
|
|
68
|
+
| Adapter | Package | Streaming | Islands | Resumable |
|
|
69
|
+
|---------|---------|-----------|---------|-----------|
|
|
70
|
+
| React 18+ | `@flightdev/ui-react` | Yes | Yes | No |
|
|
71
|
+
| Vue 3 | `@flightdev/ui-vue` | Yes | Yes | No |
|
|
72
|
+
| Angular 17+ | `@flightdev/ui-angular` | Yes | Yes | No |
|
|
73
|
+
| Svelte 5 | `@flightdev/ui-svelte` | No | Yes | No |
|
|
74
|
+
| Solid.js | `@flightdev/ui-solid` | Yes | Yes | No |
|
|
75
|
+
| Qwik | `@flightdev/ui-qwik` | Yes | Yes | Yes |
|
|
76
|
+
|
|
77
|
+
### Tier 2: Standard Support
|
|
78
|
+
|
|
79
|
+
SSR and hydration with framework-specific optimizations.
|
|
80
|
+
|
|
81
|
+
| Adapter | Package |
|
|
82
|
+
|---------|---------|
|
|
83
|
+
| Preact | `@flightdev/ui-preact` |
|
|
84
|
+
| Lit | `@flightdev/ui-lit` |
|
|
85
|
+
| Marko | `@flightdev/ui-marko` |
|
|
86
|
+
| Stencil | `@flightdev/ui-stencil` |
|
|
87
|
+
| Mithril | `@flightdev/ui-mithril` |
|
|
88
|
+
| Inferno | `@flightdev/ui-inferno` |
|
|
89
|
+
|
|
90
|
+
### Tier 3: HTML-First
|
|
91
|
+
|
|
92
|
+
Server-rendered HTML with minimal JavaScript.
|
|
93
|
+
|
|
94
|
+
| Adapter | Package |
|
|
95
|
+
|---------|---------|
|
|
96
|
+
| HTMX | `@flightdev/ui-htmx` |
|
|
97
|
+
| Alpine.js | `@flightdev/ui-alpine` |
|
|
98
|
+
| Hotwire | `@flightdev/ui-hotwire` |
|
|
99
|
+
| Stimulus | `@flightdev/ui-stimulus` |
|
|
100
|
+
| Petite-vue | `@flightdev/ui-petite-vue` |
|
|
101
|
+
| Vanilla | `@flightdev/ui-vanilla` |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Adapter Registry
|
|
106
|
+
|
|
107
|
+
The adapter registry provides dynamic loading and capability queries.
|
|
108
|
+
|
|
109
|
+
### Registering Adapters
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { adapterRegistry, registerBuiltinAdapters } from '@flightdev/ui';
|
|
113
|
+
|
|
114
|
+
// Register all built-in adapters
|
|
115
|
+
registerBuiltinAdapters();
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Getting Adapters
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Get adapter by name
|
|
122
|
+
const adapter = await adapterRegistry.get('react');
|
|
123
|
+
|
|
124
|
+
// Get adapter metadata
|
|
125
|
+
const metadata = adapterRegistry.getMetadata('vue');
|
|
126
|
+
console.log(metadata.tier); // 'tier-1'
|
|
127
|
+
console.log(metadata.framework); // 'vue'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Querying Capabilities
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// List adapters by tier
|
|
134
|
+
const tier1 = adapterRegistry.listByTier('tier-1');
|
|
135
|
+
// ['react', 'vue', 'angular', 'svelte', 'solid', 'qwik']
|
|
136
|
+
|
|
137
|
+
// List adapters by capability
|
|
138
|
+
const streaming = adapterRegistry.listByCapability('streaming');
|
|
139
|
+
// ['react', 'vue', 'angular', 'solid', 'qwik', 'marko']
|
|
140
|
+
|
|
141
|
+
// Check if adapter has capability
|
|
142
|
+
const hasStreaming = adapterRegistry.hasCapability('react', 'streaming');
|
|
143
|
+
// true
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Rendering
|
|
149
|
+
|
|
150
|
+
### String Rendering
|
|
151
|
+
|
|
152
|
+
Render a component to an HTML string:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
const result = await adapter.renderToString({
|
|
156
|
+
component: App,
|
|
157
|
+
props: { data },
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
console.log(result.html); // Rendered HTML
|
|
161
|
+
console.log(result.hydrationData); // State for client hydration
|
|
162
|
+
console.log(result.timing); // Performance metrics
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Streaming Rendering
|
|
166
|
+
|
|
167
|
+
For adapters with streaming support:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const { stream, done, abort } = adapter.renderToStream(
|
|
171
|
+
{ component: App, props: {} },
|
|
172
|
+
{ url: request.url },
|
|
173
|
+
{
|
|
174
|
+
onShellReady: () => {
|
|
175
|
+
response.writeHead(200, {
|
|
176
|
+
'Content-Type': 'text/html',
|
|
177
|
+
'Transfer-Encoding': 'chunked',
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
onError: (error) => {
|
|
181
|
+
console.error('Render error:', error);
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const reader = stream.getReader();
|
|
187
|
+
while (true) {
|
|
188
|
+
const { done: readerDone, value } = await reader.read();
|
|
189
|
+
if (readerDone) break;
|
|
190
|
+
response.write(value);
|
|
46
191
|
}
|
|
192
|
+
response.end();
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Hydration Scripts
|
|
196
|
+
|
|
197
|
+
Generate client-side hydration code:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
const result = await adapter.renderToString({ component: App, props: {} });
|
|
201
|
+
const hydrationScript = adapter.getHydrationScript(result);
|
|
202
|
+
|
|
203
|
+
const html = `
|
|
204
|
+
<!DOCTYPE html>
|
|
205
|
+
<html>
|
|
206
|
+
<body>
|
|
207
|
+
<div id="app">${result.html}</div>
|
|
208
|
+
${hydrationScript}
|
|
209
|
+
</body>
|
|
210
|
+
</html>
|
|
211
|
+
`;
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## API Reference
|
|
217
|
+
|
|
218
|
+
### defineUI
|
|
219
|
+
|
|
220
|
+
Create a UI configuration object.
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
function defineUI(
|
|
224
|
+
adapter: UIAdapterV2 | UIAdapterV1,
|
|
225
|
+
options?: {
|
|
226
|
+
streaming?: boolean;
|
|
227
|
+
hydration?: 'full' | 'partial' | 'progressive' | 'none';
|
|
228
|
+
islands?: boolean;
|
|
229
|
+
defaultIslandStrategy?: IslandHydrationStrategy;
|
|
230
|
+
}
|
|
231
|
+
): UIConfig;
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### renderPage
|
|
235
|
+
|
|
236
|
+
Render a component with the configured adapter.
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
function renderPage(
|
|
240
|
+
config: UIConfig,
|
|
241
|
+
component: Component,
|
|
242
|
+
context?: RenderContext
|
|
243
|
+
): Promise<RenderResult>;
|
|
47
244
|
```
|
|
48
245
|
|
|
49
|
-
###
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
246
|
+
### toHTML
|
|
247
|
+
|
|
248
|
+
Generate a full HTML document from a render result.
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
function toHTML(
|
|
252
|
+
result: RenderResult,
|
|
253
|
+
options?: {
|
|
254
|
+
lang?: string;
|
|
255
|
+
title?: string;
|
|
256
|
+
meta?: Record<string, string>;
|
|
257
|
+
charset?: string;
|
|
258
|
+
viewport?: string;
|
|
259
|
+
}
|
|
260
|
+
): string;
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### BaseUIAdapter
|
|
264
|
+
|
|
265
|
+
Base class for creating custom adapters.
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
import { BaseUIAdapter } from '@flightdev/ui';
|
|
269
|
+
import type { Component, RenderResult, RenderContext } from '@flightdev/ui';
|
|
270
|
+
|
|
271
|
+
class MyAdapter extends BaseUIAdapter {
|
|
272
|
+
readonly id = 'my-adapter';
|
|
273
|
+
readonly name = 'My Adapter';
|
|
274
|
+
readonly framework = 'my-framework';
|
|
275
|
+
readonly tier = 'tier-2' as const;
|
|
276
|
+
|
|
277
|
+
async renderToString(
|
|
278
|
+
component: Component,
|
|
279
|
+
context?: RenderContext
|
|
280
|
+
): Promise<RenderResult> {
|
|
281
|
+
// Implementation
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
getHydrationScript(result: RenderResult): string {
|
|
285
|
+
// Implementation
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
getClientEntry(): string {
|
|
289
|
+
// Implementation
|
|
290
|
+
}
|
|
65
291
|
}
|
|
66
292
|
```
|
|
67
293
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
- Slider
|
|
79
|
-
- Select / Combobox
|
|
80
|
-
- Toast / Notifications
|
|
81
|
-
|
|
82
|
-
## Features
|
|
83
|
-
|
|
84
|
-
- Fully accessible (WAI-ARIA)
|
|
85
|
-
- Keyboard navigation
|
|
86
|
-
- Focus management
|
|
87
|
-
- Unstyled (bring your own CSS)
|
|
88
|
-
- TypeScript support
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Documentation
|
|
297
|
+
|
|
298
|
+
For detailed documentation on each adapter and advanced patterns:
|
|
299
|
+
|
|
300
|
+
- [Adapter System](./docs/ADAPTERS.md)
|
|
301
|
+
- [Usage Patterns](./docs/PATTERNS.md)
|
|
302
|
+
|
|
303
|
+
---
|
|
89
304
|
|
|
90
305
|
## License
|
|
91
306
|
|