@flightdev/ui 2.0.1 → 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.
Files changed (120) hide show
  1. package/README.md +283 -68
  2. package/dist/{chunk-XTDK7ME5.js → chunk-S4DTUQII.js} +246 -19
  3. package/dist/chunk-S4DTUQII.js.map +1 -0
  4. package/dist/core/index.d.ts +423 -3
  5. package/dist/core/index.js +23 -2
  6. package/dist/core/index.js.map +1 -0
  7. package/dist/index.d.ts +2 -3
  8. package/dist/index.js +29 -5
  9. package/dist/index.js.map +1 -0
  10. package/package.json +7 -183
  11. package/.turbo/turbo-build.log +0 -81
  12. package/.turbo/turbo-lint.log +0 -40
  13. package/.turbo/turbo-typecheck.log +0 -4
  14. package/TESTING.md +0 -124
  15. package/dist/adapter-MMD-iHNx.d.ts +0 -424
  16. package/dist/adapters/tier-1/angular.d.ts +0 -60
  17. package/dist/adapters/tier-1/angular.js +0 -2
  18. package/dist/adapters/tier-1/index.d.ts +0 -7
  19. package/dist/adapters/tier-1/index.js +0 -7
  20. package/dist/adapters/tier-1/qwik.d.ts +0 -55
  21. package/dist/adapters/tier-1/qwik.js +0 -2
  22. package/dist/adapters/tier-1/react.d.ts +0 -67
  23. package/dist/adapters/tier-1/react.js +0 -2
  24. package/dist/adapters/tier-1/solid.d.ts +0 -45
  25. package/dist/adapters/tier-1/solid.js +0 -2
  26. package/dist/adapters/tier-1/svelte.d.ts +0 -48
  27. package/dist/adapters/tier-1/svelte.js +0 -2
  28. package/dist/adapters/tier-1/vue.d.ts +0 -47
  29. package/dist/adapters/tier-1/vue.js +0 -2
  30. package/dist/adapters/tier-2/index.d.ts +0 -7
  31. package/dist/adapters/tier-2/index.js +0 -7
  32. package/dist/adapters/tier-2/inferno.d.ts +0 -31
  33. package/dist/adapters/tier-2/inferno.js +0 -2
  34. package/dist/adapters/tier-2/lit.d.ts +0 -34
  35. package/dist/adapters/tier-2/lit.js +0 -2
  36. package/dist/adapters/tier-2/marko.d.ts +0 -59
  37. package/dist/adapters/tier-2/marko.js +0 -2
  38. package/dist/adapters/tier-2/mithril.d.ts +0 -31
  39. package/dist/adapters/tier-2/mithril.js +0 -2
  40. package/dist/adapters/tier-2/preact.d.ts +0 -33
  41. package/dist/adapters/tier-2/preact.js +0 -2
  42. package/dist/adapters/tier-2/stencil.d.ts +0 -52
  43. package/dist/adapters/tier-2/stencil.js +0 -2
  44. package/dist/adapters/tier-3/alpine.d.ts +0 -73
  45. package/dist/adapters/tier-3/alpine.js +0 -2
  46. package/dist/adapters/tier-3/hotwire.d.ts +0 -71
  47. package/dist/adapters/tier-3/hotwire.js +0 -2
  48. package/dist/adapters/tier-3/htmx.d.ts +0 -88
  49. package/dist/adapters/tier-3/htmx.js +0 -2
  50. package/dist/adapters/tier-3/index.d.ts +0 -7
  51. package/dist/adapters/tier-3/index.js +0 -7
  52. package/dist/adapters/tier-3/petite-vue.d.ts +0 -56
  53. package/dist/adapters/tier-3/petite-vue.js +0 -2
  54. package/dist/adapters/tier-3/stimulus.d.ts +0 -63
  55. package/dist/adapters/tier-3/stimulus.js +0 -2
  56. package/dist/adapters/tier-3/vanilla.d.ts +0 -63
  57. package/dist/adapters/tier-3/vanilla.js +0 -2
  58. package/dist/chunk-2SNQ6PTM.js +0 -217
  59. package/dist/chunk-3D4XMIZI.js +0 -136
  60. package/dist/chunk-3HU6GSQ4.js +0 -125
  61. package/dist/chunk-4PZDNFL7.js +0 -148
  62. package/dist/chunk-5IBLFTYL.js +0 -114
  63. package/dist/chunk-64JZJ7OK.js +0 -142
  64. package/dist/chunk-7ZJI3QU2.js +0 -132
  65. package/dist/chunk-CE4FJHQJ.js +0 -133
  66. package/dist/chunk-DTCAUBH5.js +0 -87
  67. package/dist/chunk-NTASPOHG.js +0 -106
  68. package/dist/chunk-OI2AMQLG.js +0 -152
  69. package/dist/chunk-Q7HUE44H.js +0 -106
  70. package/dist/chunk-QH3LOWXU.js +0 -155
  71. package/dist/chunk-QIVAK6BH.js +0 -103
  72. package/dist/chunk-V34XPVGK.js +0 -103
  73. package/dist/chunk-VK7ZPMO7.js +0 -221
  74. package/dist/chunk-X6CNUW6T.js +0 -136
  75. package/dist/chunk-YFGSHW5S.js +0 -121
  76. package/dist/chunk-ZAJVSE7J.js +0 -90
  77. package/docs/ADAPTERS.md +0 -946
  78. package/docs/PATTERNS.md +0 -836
  79. package/src/adapters/tier-1/angular.ts +0 -223
  80. package/src/adapters/tier-1/index.ts +0 -12
  81. package/src/adapters/tier-1/qwik.ts +0 -177
  82. package/src/adapters/tier-1/react.ts +0 -330
  83. package/src/adapters/tier-1/solid.ts +0 -222
  84. package/src/adapters/tier-1/svelte.ts +0 -211
  85. package/src/adapters/tier-1/vue.ts +0 -234
  86. package/src/adapters/tier-2/index.ts +0 -12
  87. package/src/adapters/tier-2/inferno.ts +0 -149
  88. package/src/adapters/tier-2/lit.ts +0 -191
  89. package/src/adapters/tier-2/marko.ts +0 -199
  90. package/src/adapters/tier-2/mithril.ts +0 -152
  91. package/src/adapters/tier-2/preact.ts +0 -133
  92. package/src/adapters/tier-2/stencil.ts +0 -214
  93. package/src/adapters/tier-3/alpine.ts +0 -218
  94. package/src/adapters/tier-3/hotwire.ts +0 -254
  95. package/src/adapters/tier-3/htmx.ts +0 -263
  96. package/src/adapters/tier-3/index.ts +0 -12
  97. package/src/adapters/tier-3/petite-vue.ts +0 -163
  98. package/src/adapters/tier-3/stimulus.ts +0 -233
  99. package/src/adapters/tier-3/vanilla.ts +0 -252
  100. package/src/ambient.d.ts +0 -310
  101. package/src/core/adapter.ts +0 -366
  102. package/src/core/index.ts +0 -56
  103. package/src/core/registry.ts +0 -518
  104. package/src/core/types.ts +0 -461
  105. package/src/htmx.ts +0 -134
  106. package/src/index.ts +0 -263
  107. package/test/__mocks__/stencil-core.ts +0 -19
  108. package/test/__mocks__/stencil-hydrate.ts +0 -15
  109. package/test/adapters/tier-1.test.ts +0 -206
  110. package/test/adapters/tier-2.test.ts +0 -175
  111. package/test/adapters/tier-3.test.ts +0 -284
  112. package/test/contracts/adapter.contract.ts +0 -293
  113. package/test/core/core.test.ts +0 -310
  114. package/test/errors/error-handling.test.ts +0 -454
  115. package/test/integration/htmx.integration.test.ts +0 -246
  116. package/test/integration/react.integration.test.ts +0 -271
  117. package/test/integration/registry.integration.test.ts +0 -308
  118. package/tsconfig.json +0 -22
  119. package/tsup.config.ts +0 -93
  120. package/vitest.config.ts +0 -101
@@ -1,252 +0,0 @@
1
- /**
2
- * @flightdev/ui - Vanilla Web Components Adapter (Tier 3)
3
- *
4
- * Pure Web Components adapter - no framework, just standards.
5
- *
6
- * @module @flightdev/ui/vanilla
7
- * @version 2.0.0
8
- */
9
-
10
- import { BaseUIAdapter } from '../../core/adapter.js';
11
- import type {
12
- AdapterCapabilities,
13
- Component,
14
- RenderContext,
15
- RenderResult,
16
- Island,
17
- IslandOptions,
18
- } from '../../core/types.js';
19
-
20
- // ============================================================================
21
- // Types
22
- // ============================================================================
23
-
24
- export interface VanillaAdapterOptions {
25
- /** Enable declarative shadow DOM */
26
- declarativeShadowDom?: boolean;
27
-
28
- /** Polyfill for older browsers */
29
- polyfill?: boolean;
30
- }
31
-
32
- // ============================================================================
33
- // Vanilla Adapter
34
- // ============================================================================
35
-
36
- export class VanillaAdapter extends BaseUIAdapter {
37
- readonly id = 'vanilla';
38
- readonly name = 'Vanilla Web Components';
39
- readonly framework = 'vanilla';
40
- readonly frameworkVersion = 'ES2022+';
41
- readonly tier = 'tier-3' as const;
42
-
43
- override readonly capabilities: AdapterCapabilities = {
44
- streaming: false,
45
- partialHydration: false,
46
- islands: true, // Web Components ARE islands
47
- resumable: false,
48
- ssg: true,
49
- csr: true,
50
- serverComponents: false,
51
- };
52
-
53
- constructor(private options: VanillaAdapterOptions = {}) {
54
- super();
55
- }
56
-
57
- async renderToString(
58
- component: Component,
59
- _context?: RenderContext
60
- ): Promise<RenderResult> {
61
- const startTime = performance.now();
62
-
63
- let html: string;
64
-
65
- if (typeof component.component === 'string') {
66
- // Component is a tag name
67
- const tagName = component.component;
68
- const props = component.props ?? {};
69
-
70
- const attrs = Object.entries(props)
71
- .map(([key, value]) => {
72
- const attrName = key.replace(/([A-Z])/g, '-$1').toLowerCase();
73
- return `${attrName}="${this.escapeHtml(String(value))}"`;
74
- })
75
- .join(' ');
76
-
77
- html = `<${tagName} ${attrs}></${tagName}>`;
78
- } else if (typeof component.component === 'function') {
79
- html = (component.component as (props: unknown) => string)(component.props ?? {});
80
- } else {
81
- throw new Error(
82
- '[Flight/Vanilla] Components must be tag names or template functions.'
83
- );
84
- }
85
-
86
- return {
87
- html,
88
- hydrationData: {
89
- props: component.props,
90
- componentId: component.id ?? this.generateId(),
91
- },
92
- timing: this.createTiming(startTime),
93
- };
94
- }
95
-
96
- override createIsland(
97
- component: unknown,
98
- props?: Record<string, unknown>,
99
- options?: IslandOptions
100
- ): Island {
101
- const tagName = component as string;
102
- const id = this.generateId();
103
-
104
- const attrs = Object.entries(props ?? {})
105
- .map(([key, value]) => {
106
- const attrName = key.replace(/([A-Z])/g, '-$1').toLowerCase();
107
- return `${attrName}="${this.escapeHtml(String(value))}"`;
108
- })
109
- .join(' ');
110
-
111
- const placeholder = `
112
- <${tagName}
113
- ${attrs}
114
- data-flight-island="${id}"
115
- data-flight-hydrate="${options?.hydrate ?? 'load'}"
116
- ></${tagName}>
117
- `.trim();
118
-
119
- return {
120
- id,
121
- component,
122
- props,
123
- options: options ?? { hydrate: 'load' },
124
- placeholder,
125
- };
126
- }
127
-
128
- override getHydrationScript(_result: RenderResult): string {
129
- const { polyfill = false } = this.options;
130
-
131
- let scripts = `
132
- <!-- Flight/Vanilla Web Components -->
133
- <script>
134
- window.__FLIGHT_ADAPTER__ = 'vanilla';
135
- </script>
136
- `;
137
-
138
- if (polyfill) {
139
- scripts += `
140
- <script src="https://unpkg.com/@webcomponents/webcomponentsjs@2.8.0/webcomponents-loader.js"></script>
141
- `;
142
- }
143
-
144
- return scripts.trim();
145
- }
146
-
147
- override getClientEntry(): string {
148
- return `
149
- // Vanilla Web Components Client Entry
150
- // Components self-register when their scripts are loaded
151
-
152
- export function hydrate() {
153
- // Web Components auto-upgrade when defined
154
- console.log('[Flight/Vanilla] Web Components ready');
155
- }
156
-
157
- // Helper to define a custom element
158
- export function define(tagName, elementClass) {
159
- if (!customElements.get(tagName)) {
160
- customElements.define(tagName, elementClass);
161
- }
162
- }
163
-
164
- // Wait for a component to be defined
165
- export function whenDefined(tagName) {
166
- return customElements.whenDefined(tagName);
167
- }
168
-
169
- // Upgrade all elements matching a selector
170
- export function upgradeAll(selector = '*') {
171
- document.querySelectorAll(selector).forEach(el => {
172
- customElements.upgrade(el);
173
- });
174
- }
175
- `.trim();
176
- }
177
- }
178
-
179
- // ============================================================================
180
- // Template Helpers
181
- // ============================================================================
182
-
183
- /**
184
- * Create a custom element with declarative shadow DOM
185
- */
186
- export function shadowRoot(content: string, mode: 'open' | 'closed' = 'open'): string {
187
- return `<template shadowrootmode="${mode}">${content}</template>`;
188
- }
189
-
190
- /**
191
- * Create a slot element
192
- */
193
- export function slot(name?: string): string {
194
- return name ? `<slot name="${name}"></slot>` : '<slot></slot>';
195
- }
196
-
197
- /**
198
- * Create a basic custom element class string (for inline scripts)
199
- */
200
- export function createElementClass(tagName: string, options: {
201
- connectedCallback?: string;
202
- observedAttributes?: string[];
203
- template?: string;
204
- } = {}): string {
205
- const className = tagName
206
- .split('-')
207
- .map(s => s.charAt(0).toUpperCase() + s.slice(1))
208
- .join('');
209
-
210
- return `
211
- class ${className} extends HTMLElement {
212
- ${options.observedAttributes ? `static observedAttributes = ${JSON.stringify(options.observedAttributes)};` : ''}
213
-
214
- constructor() {
215
- super();
216
- ${options.template ? `
217
- this.attachShadow({ mode: 'open' });
218
- this.shadowRoot.innerHTML = \`${options.template}\`;
219
- ` : ''}
220
- }
221
-
222
- connectedCallback() {
223
- ${options.connectedCallback ?? ''}
224
- }
225
- }
226
-
227
- customElements.define('${tagName}', ${className});
228
- `.trim();
229
- }
230
-
231
- // ============================================================================
232
- // Factory Function
233
- // ============================================================================
234
-
235
- /**
236
- * Create a Vanilla Web Components UI adapter.
237
- *
238
- * @example
239
- * ```typescript
240
- * import { vanilla } from '@flightdev/ui/vanilla';
241
- * import { defineUI } from '@flightdev/ui';
242
- *
243
- * export default defineUI(vanilla({
244
- * declarativeShadowDom: true,
245
- * }));
246
- * ```
247
- */
248
- export function vanilla(options?: VanillaAdapterOptions): VanillaAdapter {
249
- return new VanillaAdapter(options);
250
- }
251
-
252
- export default vanilla;
package/src/ambient.d.ts DELETED
@@ -1,310 +0,0 @@
1
- /**
2
- * Type declarations for UI framework peer dependencies
3
- * Following 2026 best practices: specific types instead of any
4
- */
5
-
6
- // ============================================================================
7
- // Node.js Types (for SSR)
8
- // ============================================================================
9
-
10
- declare namespace NodeJS {
11
- interface WritableStream {
12
- write(chunk: unknown): boolean;
13
- end(cb?: () => void): void;
14
- on(event: string, listener: (...args: unknown[]) => void): this;
15
- }
16
- }
17
-
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- declare const Buffer: any;
20
-
21
- // ============================================================================
22
- // React
23
- // ============================================================================
24
-
25
- declare namespace React {
26
- type ComponentType<P = object> = (props: P) => ReactNode;
27
- type ReactNode = string | number | boolean | null | undefined | ReactElement;
28
- interface ReactElement {
29
- type: string | ComponentType;
30
- props: Record<string, unknown>;
31
- key: string | number | null;
32
- }
33
- }
34
-
35
- declare module 'react' {
36
- export type ComponentType<P = object> = React.ComponentType<P>;
37
- export type ReactNode = React.ReactNode;
38
- export type ReactElement = React.ReactElement;
39
-
40
- export function createElement<P extends object>(
41
- type: string | ComponentType<P>,
42
- props?: P | null,
43
- ...children: ReactNode[]
44
- ): ReactElement;
45
- }
46
-
47
- declare module 'react-dom/server' {
48
- import type { ReactElement } from 'react';
49
-
50
- export function renderToString(element: ReactElement): string;
51
- export function renderToStaticMarkup(element: ReactElement): string;
52
-
53
- export interface PipeableStream {
54
- pipe<T extends NodeJS.WritableStream>(destination: T): T;
55
- abort(): void;
56
- }
57
-
58
- export interface RenderToPipeableStreamOptions {
59
- onShellReady?: () => void;
60
- onShellError?: (error: Error) => void;
61
- onAllReady?: () => void;
62
- onError?: (error: Error) => void;
63
- }
64
-
65
- export function renderToPipeableStream(
66
- element: ReactElement,
67
- options?: RenderToPipeableStreamOptions
68
- ): PipeableStream;
69
-
70
- // Web Streams API version (for Node.js 18+, Deno, Edge runtimes)
71
- export interface RenderToReadableStreamOptions {
72
- signal?: AbortSignal;
73
- onError?: (error: unknown) => void;
74
- nonce?: string;
75
- bootstrapScriptContent?: string;
76
- bootstrapScripts?: string[];
77
- bootstrapModules?: string[];
78
- }
79
-
80
- export function renderToReadableStream(
81
- element: ReactElement,
82
- options?: RenderToReadableStreamOptions
83
- ): Promise<ReadableStream<Uint8Array>>;
84
- }
85
-
86
- declare module 'react-dom/client' {
87
- import type { ReactElement } from 'react';
88
-
89
- export interface Root {
90
- render(children: ReactElement): void;
91
- unmount(): void;
92
- }
93
-
94
- export function hydrateRoot(container: Element | null, children: ReactElement): Root;
95
- export function createRoot(container: Element | null): Root;
96
- }
97
-
98
- // ============================================================================
99
- // Vue 3
100
- // ============================================================================
101
-
102
- declare module 'vue' {
103
- export interface App<T = unknown> {
104
- mount(selector: string | Element): T;
105
- unmount(): void;
106
- }
107
-
108
- export type Component = object;
109
-
110
- export function createSSRApp(rootComponent: Component, rootProps?: object): App;
111
- export function createApp(rootComponent: Component, rootProps?: object): App;
112
- }
113
-
114
- declare module 'vue/server-renderer' {
115
- import type { App } from 'vue';
116
-
117
- export function renderToString(app: App): Promise<string>;
118
- export function renderToWebStream(app: App): ReadableStream<Uint8Array>;
119
- }
120
-
121
- // ============================================================================
122
- // Angular
123
- // ============================================================================
124
-
125
- declare module '@angular/platform-server' {
126
- export function renderApplication(
127
- bootstrap: (document: string, url: string) => Promise<unknown>,
128
- options: { document: string; url: string }
129
- ): Promise<string>;
130
- }
131
-
132
- declare module '@angular/platform-browser' {
133
- export function provideClientHydration(...features: unknown[]): unknown;
134
- export function withIncrementalHydration(): unknown;
135
- export function withEventReplay(): unknown;
136
- }
137
-
138
- // ============================================================================
139
- // Solid.js
140
- // ============================================================================
141
-
142
- declare module 'solid-js' {
143
- export type JSXElement = object;
144
- }
145
-
146
- declare module 'solid-js/web' {
147
- export function renderToString(fn: () => object): Promise<string>;
148
- export function hydrate(fn: () => object, node: Element | null): void;
149
- export function render(fn: () => object, node: Element | null): void;
150
-
151
- export interface StreamResult {
152
- readable: ReadableStream<Uint8Array>;
153
- done: Promise<void>;
154
- }
155
-
156
- export function renderToStream(fn: () => object): StreamResult;
157
- }
158
-
159
- // ============================================================================
160
- // Svelte
161
- // ============================================================================
162
-
163
- declare module 'svelte' {
164
- export interface SvelteComponent {
165
- render(props?: object): {
166
- html: string;
167
- head?: string;
168
- css?: { code: string };
169
- };
170
- }
171
-
172
- export function mount<T>(
173
- component: T,
174
- options: { target: Element; props?: object }
175
- ): unknown;
176
-
177
- export function hydrate<T>(
178
- component: T,
179
- options: { target: Element; props?: object }
180
- ): unknown;
181
- }
182
-
183
- declare module 'svelte/server' {
184
- export function render<T>(
185
- component: T,
186
- options: { props?: object }
187
- ): { body: string; head: string };
188
- }
189
-
190
- // ============================================================================
191
- // Qwik
192
- // ============================================================================
193
-
194
- declare module '@builder.io/qwik/server' {
195
- export interface RenderToStringResult {
196
- html: string;
197
- }
198
-
199
- export function renderToString(
200
- component: () => unknown,
201
- options?: { containerTagName?: string }
202
- ): Promise<RenderToStringResult>;
203
- }
204
-
205
- // ============================================================================
206
- // Tier 2 Frameworks
207
- // ============================================================================
208
-
209
- declare namespace preact {
210
- type FunctionComponent<P = object> = (props: P) => unknown;
211
- }
212
-
213
- declare module 'preact' {
214
- export function h(
215
- type: string | preact.FunctionComponent,
216
- props?: object,
217
- ...children: unknown[]
218
- ): object;
219
- }
220
-
221
- declare module 'preact-render-to-string' {
222
- export default function renderToString(vnode: object): string;
223
- export function renderToString(vnode: object): string;
224
- }
225
-
226
- declare module 'lit' {
227
- export function html(strings: TemplateStringsArray, ...values: unknown[]): unknown;
228
- }
229
-
230
- declare module '@lit-labs/ssr' {
231
- export function render(template: unknown): Iterable<string>;
232
- }
233
-
234
- declare module '@lit-labs/ssr/lib/render-result.js' {
235
- export function collectResult(result: Iterable<string>): Promise<string>;
236
- }
237
-
238
- declare module 'marko' { }
239
-
240
- declare module '@stencil/core/hydrate' {
241
- export interface RenderToStringResult {
242
- html: string;
243
- diagnostics: unknown[];
244
- }
245
-
246
- export interface RenderToStringOptions {
247
- fullDocument?: boolean;
248
- serializeShadowRoot?: 'declarative-shadow-dom' | undefined;
249
- prettyHtml?: boolean;
250
- }
251
-
252
- export function renderToString(
253
- html: string,
254
- options?: RenderToStringOptions
255
- ): Promise<RenderToStringResult>;
256
- }
257
-
258
- declare namespace mithril {
259
- type Component<P = object> = {
260
- view: (vnode: { attrs: P }) => unknown;
261
- };
262
- }
263
-
264
- declare module 'mithril' {
265
- export default function m(
266
- selector: string | mithril.Component,
267
- attrs?: object,
268
- ...children: unknown[]
269
- ): object;
270
- }
271
-
272
- declare module 'mithril-node-render' {
273
- export default function render(vnode: object): Promise<string>;
274
- }
275
-
276
- declare namespace inferno {
277
- type Component<P = object> = (props: P) => unknown;
278
- }
279
-
280
- declare module 'inferno-server' {
281
- export function renderToString(element: object): string;
282
- }
283
-
284
- declare module 'inferno-create-element' {
285
- export function createElement(
286
- type: string | inferno.Component,
287
- props?: object,
288
- ...children: unknown[]
289
- ): object;
290
- }
291
-
292
- declare module 'inferno-hydrate' {
293
- export function hydrate(element: object, container: Element | null): void;
294
- }
295
-
296
- declare module 'inferno' {
297
- export function render(element: object, container: Element | null): void;
298
- }
299
-
300
- // ============================================================================
301
- // Stream (Node.js)
302
- // ============================================================================
303
-
304
- declare module 'stream' {
305
- export class Readable {
306
- constructor(options?: { read?: () => void });
307
- on(event: string, listener: (...args: unknown[]) => void): this;
308
- pipe<T>(destination: T): T;
309
- }
310
- }