@flightdev/ui 2.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 (118) hide show
  1. package/.turbo/turbo-build.log +81 -0
  2. package/.turbo/turbo-lint.log +40 -0
  3. package/.turbo/turbo-typecheck.log +4 -0
  4. package/LICENSE +21 -0
  5. package/README.md +92 -0
  6. package/TESTING.md +124 -0
  7. package/dist/adapter-MMD-iHNx.d.ts +424 -0
  8. package/dist/adapters/tier-1/angular.d.ts +60 -0
  9. package/dist/adapters/tier-1/angular.js +2 -0
  10. package/dist/adapters/tier-1/index.d.ts +7 -0
  11. package/dist/adapters/tier-1/index.js +7 -0
  12. package/dist/adapters/tier-1/qwik.d.ts +55 -0
  13. package/dist/adapters/tier-1/qwik.js +2 -0
  14. package/dist/adapters/tier-1/react.d.ts +67 -0
  15. package/dist/adapters/tier-1/react.js +2 -0
  16. package/dist/adapters/tier-1/solid.d.ts +45 -0
  17. package/dist/adapters/tier-1/solid.js +2 -0
  18. package/dist/adapters/tier-1/svelte.d.ts +48 -0
  19. package/dist/adapters/tier-1/svelte.js +2 -0
  20. package/dist/adapters/tier-1/vue.d.ts +47 -0
  21. package/dist/adapters/tier-1/vue.js +2 -0
  22. package/dist/adapters/tier-2/index.d.ts +7 -0
  23. package/dist/adapters/tier-2/index.js +7 -0
  24. package/dist/adapters/tier-2/inferno.d.ts +31 -0
  25. package/dist/adapters/tier-2/inferno.js +2 -0
  26. package/dist/adapters/tier-2/lit.d.ts +34 -0
  27. package/dist/adapters/tier-2/lit.js +2 -0
  28. package/dist/adapters/tier-2/marko.d.ts +59 -0
  29. package/dist/adapters/tier-2/marko.js +2 -0
  30. package/dist/adapters/tier-2/mithril.d.ts +31 -0
  31. package/dist/adapters/tier-2/mithril.js +2 -0
  32. package/dist/adapters/tier-2/preact.d.ts +33 -0
  33. package/dist/adapters/tier-2/preact.js +2 -0
  34. package/dist/adapters/tier-2/stencil.d.ts +52 -0
  35. package/dist/adapters/tier-2/stencil.js +2 -0
  36. package/dist/adapters/tier-3/alpine.d.ts +73 -0
  37. package/dist/adapters/tier-3/alpine.js +2 -0
  38. package/dist/adapters/tier-3/hotwire.d.ts +71 -0
  39. package/dist/adapters/tier-3/hotwire.js +2 -0
  40. package/dist/adapters/tier-3/htmx.d.ts +88 -0
  41. package/dist/adapters/tier-3/htmx.js +2 -0
  42. package/dist/adapters/tier-3/index.d.ts +7 -0
  43. package/dist/adapters/tier-3/index.js +7 -0
  44. package/dist/adapters/tier-3/petite-vue.d.ts +56 -0
  45. package/dist/adapters/tier-3/petite-vue.js +2 -0
  46. package/dist/adapters/tier-3/stimulus.d.ts +63 -0
  47. package/dist/adapters/tier-3/stimulus.js +2 -0
  48. package/dist/adapters/tier-3/vanilla.d.ts +63 -0
  49. package/dist/adapters/tier-3/vanilla.js +2 -0
  50. package/dist/chunk-2SNQ6PTM.js +217 -0
  51. package/dist/chunk-3D4XMIZI.js +136 -0
  52. package/dist/chunk-3HU6GSQ4.js +125 -0
  53. package/dist/chunk-4PZDNFL7.js +148 -0
  54. package/dist/chunk-5IBLFTYL.js +114 -0
  55. package/dist/chunk-64JZJ7OK.js +142 -0
  56. package/dist/chunk-7ZJI3QU2.js +132 -0
  57. package/dist/chunk-CE4FJHQJ.js +133 -0
  58. package/dist/chunk-DTCAUBH5.js +87 -0
  59. package/dist/chunk-NTASPOHG.js +106 -0
  60. package/dist/chunk-OI2AMQLG.js +152 -0
  61. package/dist/chunk-Q7HUE44H.js +106 -0
  62. package/dist/chunk-QH3LOWXU.js +155 -0
  63. package/dist/chunk-QIVAK6BH.js +103 -0
  64. package/dist/chunk-V34XPVGK.js +103 -0
  65. package/dist/chunk-VK7ZPMO7.js +221 -0
  66. package/dist/chunk-X6CNUW6T.js +136 -0
  67. package/dist/chunk-XTDK7ME5.js +382 -0
  68. package/dist/chunk-YFGSHW5S.js +121 -0
  69. package/dist/chunk-ZAJVSE7J.js +90 -0
  70. package/dist/core/index.d.ts +161 -0
  71. package/dist/core/index.js +2 -0
  72. package/dist/index.d.ts +103 -0
  73. package/dist/index.js +71 -0
  74. package/docs/ADAPTERS.md +946 -0
  75. package/docs/PATTERNS.md +836 -0
  76. package/package.json +229 -0
  77. package/src/adapters/tier-1/angular.ts +223 -0
  78. package/src/adapters/tier-1/index.ts +12 -0
  79. package/src/adapters/tier-1/qwik.ts +177 -0
  80. package/src/adapters/tier-1/react.ts +330 -0
  81. package/src/adapters/tier-1/solid.ts +222 -0
  82. package/src/adapters/tier-1/svelte.ts +211 -0
  83. package/src/adapters/tier-1/vue.ts +234 -0
  84. package/src/adapters/tier-2/index.ts +12 -0
  85. package/src/adapters/tier-2/inferno.ts +149 -0
  86. package/src/adapters/tier-2/lit.ts +191 -0
  87. package/src/adapters/tier-2/marko.ts +199 -0
  88. package/src/adapters/tier-2/mithril.ts +152 -0
  89. package/src/adapters/tier-2/preact.ts +133 -0
  90. package/src/adapters/tier-2/stencil.ts +214 -0
  91. package/src/adapters/tier-3/alpine.ts +218 -0
  92. package/src/adapters/tier-3/hotwire.ts +254 -0
  93. package/src/adapters/tier-3/htmx.ts +263 -0
  94. package/src/adapters/tier-3/index.ts +12 -0
  95. package/src/adapters/tier-3/petite-vue.ts +163 -0
  96. package/src/adapters/tier-3/stimulus.ts +233 -0
  97. package/src/adapters/tier-3/vanilla.ts +252 -0
  98. package/src/ambient.d.ts +310 -0
  99. package/src/core/adapter.ts +366 -0
  100. package/src/core/index.ts +56 -0
  101. package/src/core/registry.ts +518 -0
  102. package/src/core/types.ts +461 -0
  103. package/src/htmx.ts +134 -0
  104. package/src/index.ts +263 -0
  105. package/test/__mocks__/stencil-core.ts +19 -0
  106. package/test/__mocks__/stencil-hydrate.ts +15 -0
  107. package/test/adapters/tier-1.test.ts +206 -0
  108. package/test/adapters/tier-2.test.ts +175 -0
  109. package/test/adapters/tier-3.test.ts +284 -0
  110. package/test/contracts/adapter.contract.ts +293 -0
  111. package/test/core/core.test.ts +310 -0
  112. package/test/errors/error-handling.test.ts +454 -0
  113. package/test/integration/htmx.integration.test.ts +246 -0
  114. package/test/integration/react.integration.test.ts +271 -0
  115. package/test/integration/registry.integration.test.ts +308 -0
  116. package/tsconfig.json +22 -0
  117. package/tsup.config.ts +93 -0
  118. package/vitest.config.ts +101 -0
@@ -0,0 +1,161 @@
1
+ import { U as UIAdapterV2, d as AdapterTier, A as AdapterCapabilities } from '../adapter-MMD-iHNx.js';
2
+ export { B as BaseUIAdapter, C as Component, e as ComponentProps, D as DEFAULT_CAPABILITIES, H as HasCapability, i as Island, I as IslandHydrationStrategy, h as IslandOptions, R as RenderContext, c as RenderResult, f as RenderTiming, S as StreamingOptions, g as StreamingRenderResult, k as TIER_INFO, T as TierInfo, j as UIAdapter, a as UIAdapterV1, b as UIConfig, n as getCapabilities, m as hasCapability, l as isV2Adapter, w as wrapV1Adapter } from '../adapter-MMD-iHNx.js';
3
+
4
+ /**
5
+ * @flightdev/ui - Adapter Registry
6
+ *
7
+ * Global registry for dynamic adapter loading and discovery.
8
+ * Enables lazy loading of adapters to minimize bundle size.
9
+ *
10
+ * @module @flightdev/ui/core/registry
11
+ * @version 2.0.0
12
+ */
13
+
14
+ /**
15
+ * Lazy loader function for an adapter
16
+ */
17
+ type AdapterLoader = () => Promise<UIAdapterV2>;
18
+ /**
19
+ * Adapter metadata for registry
20
+ */
21
+ interface AdapterMetadata {
22
+ /** Unique adapter ID */
23
+ id: string;
24
+ /** Human-readable name */
25
+ name: string;
26
+ /** Framework name */
27
+ framework: string;
28
+ /** Tier classification */
29
+ tier: AdapterTier;
30
+ /** Capability hints (may be incomplete until loaded) */
31
+ capabilities?: Partial<AdapterCapabilities>;
32
+ /** Peer dependencies required */
33
+ peerDependencies?: string[];
34
+ /** Lazy loader function */
35
+ loader: AdapterLoader;
36
+ }
37
+ /**
38
+ * Registry query options
39
+ */
40
+ interface RegistryQueryOptions {
41
+ /** Filter by tier */
42
+ tier?: AdapterTier;
43
+ /** Filter by capability */
44
+ capability?: keyof AdapterCapabilities;
45
+ /** Filter by framework name pattern */
46
+ framework?: string | RegExp;
47
+ }
48
+ /**
49
+ * Global adapter registry for dynamic loading and discovery.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * import { adapterRegistry } from '@flightdev/ui';
54
+ *
55
+ * // Register an adapter
56
+ * adapterRegistry.register({
57
+ * id: 'react',
58
+ * name: 'React',
59
+ * framework: 'react',
60
+ * tier: 'tier-1',
61
+ * loader: () => import('./adapters/tier-1/react.js').then(m => m.react()),
62
+ * });
63
+ *
64
+ * // Get an adapter
65
+ * const reactAdapter = await adapterRegistry.get('react');
66
+ *
67
+ * // List all adapters
68
+ * const allAdapters = adapterRegistry.list();
69
+ * ```
70
+ */
71
+ declare class AdapterRegistry {
72
+ private metadata;
73
+ private instances;
74
+ private loading;
75
+ /**
76
+ * Register an adapter with the registry.
77
+ */
78
+ register(metadata: AdapterMetadata): void;
79
+ /**
80
+ * Register multiple adapters at once.
81
+ */
82
+ registerAll(adapters: AdapterMetadata[]): void;
83
+ /**
84
+ * Unregister an adapter.
85
+ */
86
+ unregister(id: string): boolean;
87
+ /**
88
+ * Check if an adapter is registered.
89
+ */
90
+ has(id: string): boolean;
91
+ /**
92
+ * Get an adapter by ID (lazy loads if not already loaded).
93
+ */
94
+ get(id: string): Promise<UIAdapterV2 | undefined>;
95
+ /**
96
+ * Get an adapter synchronously (only if already loaded).
97
+ */
98
+ getSync(id: string): UIAdapterV2 | undefined;
99
+ /**
100
+ * Get adapter metadata without loading.
101
+ */
102
+ getMetadata(id: string): AdapterMetadata | undefined;
103
+ /**
104
+ * List all registered adapter IDs.
105
+ */
106
+ list(): string[];
107
+ /**
108
+ * List adapters matching query options.
109
+ */
110
+ query(options: RegistryQueryOptions): AdapterMetadata[];
111
+ /**
112
+ * List adapters by tier.
113
+ */
114
+ listByTier(tier: AdapterTier): string[];
115
+ /**
116
+ * List adapters by capability.
117
+ */
118
+ listByCapability(capability: keyof AdapterCapabilities): string[];
119
+ /**
120
+ * Preload adapters for faster access later.
121
+ */
122
+ preload(ids: string[]): Promise<void>;
123
+ /**
124
+ * Get all loaded adapters.
125
+ */
126
+ getLoaded(): Map<string, UIAdapterV2>;
127
+ /**
128
+ * Clear all cached adapter instances (but keep registrations).
129
+ */
130
+ clearCache(): void;
131
+ /**
132
+ * Clear everything (registrations and cache).
133
+ */
134
+ clear(): void;
135
+ /**
136
+ * Get registry statistics.
137
+ */
138
+ stats(): {
139
+ registered: number;
140
+ loaded: number;
141
+ loading: number;
142
+ byTier: Record<AdapterTier, number>;
143
+ };
144
+ /**
145
+ * Load an adapter from metadata.
146
+ */
147
+ private loadAdapter;
148
+ }
149
+ /**
150
+ * Global adapter registry instance.
151
+ *
152
+ * Use this to register and retrieve UI adapters.
153
+ */
154
+ declare const adapterRegistry: AdapterRegistry;
155
+ /**
156
+ * Register all built-in adapters.
157
+ * Called automatically when the package is imported.
158
+ */
159
+ declare function registerBuiltinAdapters(): void;
160
+
161
+ export { AdapterCapabilities, type AdapterLoader, type AdapterMetadata, AdapterTier, type RegistryQueryOptions, UIAdapterV2, adapterRegistry, registerBuiltinAdapters };
@@ -0,0 +1,2 @@
1
+ export { DEFAULT_CAPABILITIES, TIER_INFO, adapterRegistry, registerBuiltinAdapters } from '../chunk-XTDK7ME5.js';
2
+ export { BaseUIAdapter, getCapabilities, hasCapability, isV2Adapter, wrapV1Adapter } from '../chunk-2SNQ6PTM.js';
@@ -0,0 +1,103 @@
1
+ import { U as UIAdapterV2, a as UIAdapterV1, I as IslandHydrationStrategy, b as UIConfig, C as Component, R as RenderContext, c as RenderResult } from './adapter-MMD-iHNx.js';
2
+ export { A as AdapterCapabilities, d as AdapterTier, B as BaseUIAdapter, e as ComponentProps, D as DEFAULT_CAPABILITIES, H as HasCapability, i as Island, h as IslandOptions, f as RenderTiming, S as StreamingOptions, g as StreamingRenderResult, k as TIER_INFO, T as TierInfo, j as UIAdapter, n as getCapabilities, m as hasCapability, l as isV2Adapter, w as wrapV1Adapter } from './adapter-MMD-iHNx.js';
3
+ export { AdapterLoader, AdapterMetadata, RegistryQueryOptions, adapterRegistry, registerBuiltinAdapters } from './core/index.js';
4
+
5
+ /**
6
+ * @flightdev/ui - Universal UI Framework Layer
7
+ *
8
+ * Universal SSR and hydration for 18+ UI frameworks.
9
+ * From React to Angular, Vue to HTMX, Svelte to Web Components.
10
+ *
11
+ * @module @flightdev/ui
12
+ * @version 2.0.0
13
+ *
14
+ * @example Basic Usage
15
+ * ```typescript
16
+ * import { defineUI } from '@flightdev/ui';
17
+ * import { react } from '@flightdev/ui/react';
18
+ *
19
+ * export default defineUI(react());
20
+ * ```
21
+ *
22
+ * @example With Streaming SSR
23
+ * ```typescript
24
+ * import { defineUI } from '@flightdev/ui';
25
+ * import { react } from '@flightdev/ui/react';
26
+ *
27
+ * export default defineUI(react(), {
28
+ * streaming: true,
29
+ * hydration: 'progressive',
30
+ * });
31
+ * ```
32
+ *
33
+ * @example Using Adapter Registry
34
+ * ```typescript
35
+ * import { adapterRegistry } from '@flightdev/ui';
36
+ *
37
+ * // Get adapter dynamically
38
+ * const adapter = await adapterRegistry.get('vue');
39
+ *
40
+ * // List all by tier
41
+ * const tier1 = adapterRegistry.listByTier('tier-1');
42
+ * ```
43
+ */
44
+
45
+ /**
46
+ * Define UI configuration for Flight.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { defineUI } from '@flightdev/ui';
51
+ * import { react } from '@flightdev/ui/react';
52
+ *
53
+ * export const ui = defineUI(react(), {
54
+ * streaming: true,
55
+ * hydration: 'progressive',
56
+ * });
57
+ * ```
58
+ */
59
+ declare function defineUI(adapter: UIAdapterV2 | UIAdapterV1, options?: {
60
+ streaming?: boolean;
61
+ hydration?: 'full' | 'partial' | 'progressive' | 'none';
62
+ islands?: boolean;
63
+ defaultIslandStrategy?: IslandHydrationStrategy;
64
+ }): UIConfig;
65
+
66
+ /**
67
+ * Render a page with the configured UI adapter.
68
+ */
69
+ declare function renderPage(config: UIConfig, component: Component, context?: RenderContext): Promise<RenderResult>;
70
+ /**
71
+ * Render a page as a stream (if adapter supports streaming).
72
+ */
73
+ declare function renderPageStream(config: UIConfig, component: Component, context?: RenderContext): ReadableStream<Uint8Array> | null;
74
+ /**
75
+ * Generate full HTML document from render result.
76
+ */
77
+ declare function toHTML(result: RenderResult, options?: {
78
+ lang?: string;
79
+ title?: string;
80
+ meta?: Record<string, string>;
81
+ charset?: string;
82
+ viewport?: string;
83
+ }): string;
84
+ /**
85
+ * Package version
86
+ */
87
+ declare const VERSION = "2.0.0";
88
+ /**
89
+ * Get information about the UI package
90
+ */
91
+ declare function getPackageInfo(): {
92
+ name: string;
93
+ version: string;
94
+ description: string;
95
+ tiers: {
96
+ 'tier-1': string[];
97
+ 'tier-2': string[];
98
+ 'tier-3': string[];
99
+ };
100
+ totalAdapters: number;
101
+ };
102
+
103
+ export { Component, IslandHydrationStrategy, RenderContext, RenderResult, UIAdapterV1, UIAdapterV2, UIConfig, VERSION, defineUI, getPackageInfo, renderPage, renderPageStream, toHTML };
package/dist/index.js ADDED
@@ -0,0 +1,71 @@
1
+ export { DEFAULT_CAPABILITIES, TIER_INFO, adapterRegistry, registerBuiltinAdapters } from './chunk-XTDK7ME5.js';
2
+ import { isV2Adapter } from './chunk-2SNQ6PTM.js';
3
+ export { BaseUIAdapter, getCapabilities, hasCapability, isV2Adapter, wrapV1Adapter } from './chunk-2SNQ6PTM.js';
4
+
5
+ // src/index.ts
6
+ function defineUI(adapter, options = {}) {
7
+ return {
8
+ adapter,
9
+ streaming: options.streaming ?? false,
10
+ hydration: options.hydration ?? "full",
11
+ islands: options.islands ?? false,
12
+ defaultIslandStrategy: options.defaultIslandStrategy ?? "idle"
13
+ };
14
+ }
15
+ async function renderPage(config, component, context) {
16
+ const result = await config.adapter.renderToString(component, context);
17
+ if (config.hydration !== "none") {
18
+ const hydrationScript = config.adapter.getHydrationScript(result);
19
+ result.scripts = [...result.scripts ?? [], hydrationScript];
20
+ }
21
+ return result;
22
+ }
23
+ function renderPageStream(config, component, context) {
24
+ if (!isV2Adapter(config.adapter) || !config.adapter.capabilities.streaming) {
25
+ return null;
26
+ }
27
+ const streamResult = config.adapter.renderToStream?.(component, context);
28
+ return streamResult?.stream ?? null;
29
+ }
30
+ function toHTML(result, options = {}) {
31
+ const {
32
+ lang = "en",
33
+ title = "Flight App",
34
+ meta = {},
35
+ charset = "UTF-8",
36
+ viewport = "width=device-width, initial-scale=1.0"
37
+ } = options;
38
+ const metaTags = Object.entries(meta).map(([name, content]) => `<meta name="${name}" content="${content}">`).join("\n ");
39
+ const scripts = result.scripts?.map((s) => s.startsWith("<script") ? s : `<script>${s}</script>`).join("\n ") ?? "";
40
+ return `<!DOCTYPE html>
41
+ <html lang="${lang}">
42
+ <head>
43
+ <meta charset="${charset}">
44
+ <meta name="viewport" content="${viewport}">
45
+ <title>${title}</title>
46
+ ${metaTags}
47
+ ${result.head ?? ""}
48
+ ${result.css ? `<style>${result.css}</style>` : ""}
49
+ </head>
50
+ <body>
51
+ <div id="app">${result.html}</div>
52
+ ${scripts}
53
+ </body>
54
+ </html>`;
55
+ }
56
+ var VERSION = "2.0.0";
57
+ function getPackageInfo() {
58
+ return {
59
+ name: "@flightdev/ui",
60
+ version: VERSION,
61
+ description: "Universal UI Framework Layer - SSR/hydration for 18+ frameworks",
62
+ tiers: {
63
+ "tier-1": ["react", "vue", "angular", "svelte", "solid", "qwik"],
64
+ "tier-2": ["preact", "lit", "marko", "stencil", "mithril", "inferno"],
65
+ "tier-3": ["htmx", "alpine", "hotwire", "stimulus", "petite-vue", "vanilla"]
66
+ },
67
+ totalAdapters: 18
68
+ };
69
+ }
70
+
71
+ export { VERSION, defineUI, getPackageInfo, renderPage, renderPageStream, toHTML };