@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.
Files changed (120) hide show
  1. package/README.md +285 -70
  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 +11 -181
  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,103 +0,0 @@
1
- import { BaseUIAdapter } from './chunk-2SNQ6PTM.js';
2
-
3
- // src/adapters/tier-2/mithril.ts
4
- var MithrilAdapter = class extends BaseUIAdapter {
5
- constructor(options = {}) {
6
- super();
7
- this.options = options;
8
- }
9
- id = "mithril";
10
- name = "Mithril";
11
- framework = "mithril";
12
- frameworkVersion = "2+";
13
- tier = "tier-2";
14
- capabilities = {
15
- streaming: false,
16
- partialHydration: false,
17
- islands: false,
18
- resumable: false,
19
- ssg: true,
20
- csr: true,
21
- serverComponents: false
22
- };
23
- async renderToString(component, _context) {
24
- const startTime = performance.now();
25
- try {
26
- const render = await import('mithril-node-render').then((m2) => m2.default || m2);
27
- const m = await import('mithril').then((mod) => mod.default || mod);
28
- const MithrilComponent = component.component;
29
- const vnode = m(MithrilComponent, component.props ?? {});
30
- const html = await render(vnode);
31
- return {
32
- html,
33
- hydrationData: {
34
- props: component.props,
35
- componentId: component.id ?? this.generateId()
36
- },
37
- timing: this.createTiming(startTime)
38
- };
39
- } catch (error) {
40
- const message = error instanceof Error ? error.message : String(error);
41
- if (message.includes("Cannot find module 'mithril-node-render'")) {
42
- throw new Error(
43
- "[Flight/Mithril] Mithril SSR package not found.\nInstall required packages:\n npm install mithril mithril-node-render\n npm install -D @types/mithril"
44
- );
45
- }
46
- throw error;
47
- }
48
- }
49
- getHydrationScript(result) {
50
- const data = this.serializeProps(result.hydrationData);
51
- return `
52
- <script type="module">
53
- window.__FLIGHT_DATA__ = ${data};
54
- window.__FLIGHT_ADAPTER__ = 'mithril';
55
-
56
- import m from 'mithril';
57
-
58
- const App = window.__FLIGHT_APP__;
59
- const container = document.getElementById('app');
60
-
61
- if (App && container) {
62
- // Mithril mounts and diffs against existing DOM
63
- m.mount(container, {
64
- view: () => m(App, window.__FLIGHT_DATA__.props)
65
- });
66
- }
67
- </script>
68
- `.trim();
69
- }
70
- getClientEntry() {
71
- return `
72
- import m from 'mithril';
73
-
74
- export function hydrate() {
75
- const container = document.getElementById('app');
76
- const App = window.__FLIGHT_APP__;
77
- const data = window.__FLIGHT_DATA__ ?? {};
78
-
79
- if (!container || !App) {
80
- console.warn('[Flight/Mithril] Missing container or App');
81
- return;
82
- }
83
-
84
- // Mithril automatically diffs against existing DOM
85
- m.mount(container, {
86
- view: () => m(App, data.props)
87
- });
88
- }
89
-
90
- export function render(App, container, props = {}) {
91
- m.mount(container, {
92
- view: () => m(App, props)
93
- });
94
- }
95
- `.trim();
96
- }
97
- };
98
- function mithril(options) {
99
- return new MithrilAdapter(options);
100
- }
101
- var mithril_default = mithril;
102
-
103
- export { MithrilAdapter, mithril, mithril_default };
@@ -1,221 +0,0 @@
1
- import { BaseUIAdapter } from './chunk-2SNQ6PTM.js';
2
-
3
- // src/adapters/tier-1/react.ts
4
- var ReactAdapter = class extends BaseUIAdapter {
5
- constructor(options = {}) {
6
- super();
7
- this.options = options;
8
- }
9
- id = "react";
10
- name = "React";
11
- framework = "react";
12
- frameworkVersion = "18+";
13
- tier = "tier-1";
14
- capabilities = {
15
- streaming: true,
16
- partialHydration: true,
17
- islands: true,
18
- resumable: false,
19
- // React 19 has some resumability features
20
- ssg: true,
21
- csr: true,
22
- serverComponents: true
23
- };
24
- async renderToString(component, _context) {
25
- const startTime = performance.now();
26
- const { renderToString } = await import('react-dom/server');
27
- const { createElement } = await import('react');
28
- const element = createElement(
29
- component.component,
30
- component.props ?? {},
31
- component.children
32
- );
33
- const html = renderToString(element);
34
- return {
35
- html,
36
- hydrationData: {
37
- props: component.props,
38
- componentId: component.id ?? this.generateId()
39
- },
40
- timing: this.createTiming(startTime)
41
- };
42
- }
43
- /**
44
- * Render to stream using React 18+ streaming SSR.
45
- *
46
- * Uses `renderToReadableStream` (Web Streams API) which works in:
47
- * - Node.js 18+ (with Web Streams support)
48
- * - Deno
49
- * - Cloudflare Workers
50
- * - Vercel Edge Runtime
51
- * - Other edge runtimes
52
- *
53
- * Falls back to `renderToPipeableStream` for Node.js environments
54
- * that require traditional streams.
55
- */
56
- renderToStream(component, _context, options) {
57
- let aborted = false;
58
- let abortController = null;
59
- let resolvePromise;
60
- let rejectPromise;
61
- const done = new Promise((resolve, reject) => {
62
- resolvePromise = resolve;
63
- rejectPromise = reject;
64
- });
65
- const stream = new ReadableStream({
66
- start: async (controller) => {
67
- try {
68
- const { renderToReadableStream } = await import('react-dom/server');
69
- const { createElement } = await import('react');
70
- const element = createElement(
71
- component.component,
72
- component.props ?? {},
73
- component.children
74
- );
75
- abortController = new AbortController();
76
- const reactStream = await renderToReadableStream(element, {
77
- signal: abortController.signal,
78
- onError(error) {
79
- const err = error instanceof Error ? error : new Error(String(error));
80
- options?.onError?.(err);
81
- }
82
- });
83
- options?.onShellReady?.();
84
- const reader = reactStream.getReader();
85
- const pump = async () => {
86
- try {
87
- while (true) {
88
- if (aborted) {
89
- await reader.cancel();
90
- controller.close();
91
- resolvePromise();
92
- return;
93
- }
94
- const { done: readerDone, value } = await reader.read();
95
- if (readerDone) {
96
- controller.close();
97
- options?.onAllReady?.();
98
- resolvePromise();
99
- return;
100
- }
101
- if (value) {
102
- controller.enqueue(value);
103
- }
104
- }
105
- } catch (error) {
106
- const err = error instanceof Error ? error : new Error(String(error));
107
- options?.onError?.(err);
108
- controller.error(err);
109
- rejectPromise(err);
110
- }
111
- };
112
- await pump();
113
- } catch (error) {
114
- const err = error instanceof Error ? error : new Error(String(error));
115
- if (err.message.includes("renderToReadableStream")) {
116
- await this.fallbackStreamRender(component, controller, options, resolvePromise, rejectPromise);
117
- return;
118
- }
119
- options?.onShellError?.(err);
120
- options?.onError?.(err);
121
- controller.error(err);
122
- rejectPromise(err);
123
- }
124
- }
125
- });
126
- return {
127
- stream,
128
- done,
129
- abort: () => {
130
- aborted = true;
131
- abortController?.abort();
132
- resolvePromise();
133
- }
134
- };
135
- }
136
- /**
137
- * Fallback render for environments without Web Streams support.
138
- * Uses renderToString and emits as a single chunk.
139
- */
140
- async fallbackStreamRender(component, controller, options, resolvePromise, rejectPromise) {
141
- try {
142
- const { renderToString } = await import('react-dom/server');
143
- const { createElement } = await import('react');
144
- const element = createElement(
145
- component.component,
146
- component.props ?? {},
147
- component.children
148
- );
149
- options?.onShellReady?.();
150
- const html = renderToString(element);
151
- const encoded = new TextEncoder().encode(html);
152
- controller.enqueue(encoded);
153
- controller.close();
154
- options?.onAllReady?.();
155
- resolvePromise();
156
- } catch (error) {
157
- const err = error instanceof Error ? error : new Error(String(error));
158
- options?.onError?.(err);
159
- controller.error(err);
160
- rejectPromise(err);
161
- }
162
- }
163
- getHydrationScript(result) {
164
- const data = this.serializeProps(result.hydrationData);
165
- return `
166
- <script type="module">
167
- window.__FLIGHT_DATA__ = ${data};
168
- window.__FLIGHT_ADAPTER__ = 'react';
169
-
170
- import { hydrateRoot } from 'react-dom/client';
171
-
172
- const container = document.getElementById('app');
173
- const App = window.__FLIGHT_APP__;
174
-
175
- if (container && App) {
176
- const { props } = window.__FLIGHT_DATA__;
177
- import('react').then(({ createElement }) => {
178
- hydrateRoot(container, createElement(App, props));
179
- });
180
- }
181
- </script>
182
- `.trim();
183
- }
184
- getClientEntry() {
185
- return `
186
- import { hydrateRoot, createRoot } from 'react-dom/client';
187
- import { createElement } from 'react';
188
-
189
- export function hydrate() {
190
- const container = document.getElementById('app');
191
- const App = window.__FLIGHT_APP__;
192
- const data = window.__FLIGHT_DATA__ ?? {};
193
-
194
- if (!container || !App) {
195
- console.warn('[Flight/React] Missing container or App');
196
- return;
197
- }
198
-
199
- // Check if we have SSR content to hydrate
200
- if (container.innerHTML.trim()) {
201
- hydrateRoot(container, createElement(App, data.props));
202
- } else {
203
- // Fallback to client-side render
204
- createRoot(container).render(createElement(App, data.props));
205
- }
206
- }
207
-
208
- export function render(App, container, props = {}) {
209
- const root = createRoot(container);
210
- root.render(createElement(App, props));
211
- return root;
212
- }
213
- `.trim();
214
- }
215
- };
216
- function react(options) {
217
- return new ReactAdapter(options);
218
- }
219
- var react_default = react;
220
-
221
- export { ReactAdapter, react, react_default };
@@ -1,136 +0,0 @@
1
- import { BaseUIAdapter } from './chunk-2SNQ6PTM.js';
2
-
3
- // src/adapters/tier-1/svelte.ts
4
- var SvelteAdapter = class extends BaseUIAdapter {
5
- constructor(options = {}) {
6
- super();
7
- this.options = options;
8
- }
9
- id = "svelte";
10
- name = "Svelte";
11
- framework = "svelte";
12
- frameworkVersion = "5+";
13
- tier = "tier-1";
14
- capabilities = {
15
- streaming: false,
16
- // Svelte 5 doesn't have streaming SSR yet
17
- partialHydration: true,
18
- islands: true,
19
- resumable: false,
20
- ssg: true,
21
- csr: true,
22
- serverComponents: false
23
- };
24
- async renderToString(component, _context) {
25
- const startTime = performance.now();
26
- try {
27
- const { render } = await import('svelte/server');
28
- const SvelteComponent = component.component;
29
- const { body, head } = render(SvelteComponent, {
30
- props: component.props ?? {}
31
- });
32
- return {
33
- html: body,
34
- head,
35
- hydrationData: {
36
- props: component.props,
37
- componentId: component.id ?? this.generateId()
38
- },
39
- css: this.options.extractCss ? void 0 : void 0,
40
- // CSS handled by bundler
41
- timing: this.createTiming(startTime)
42
- };
43
- } catch (error) {
44
- const message = error instanceof Error ? error.message : String(error);
45
- if (message.includes("Cannot find module 'svelte/server'")) {
46
- return this.renderSvelte4(component, startTime);
47
- }
48
- throw error;
49
- }
50
- }
51
- /**
52
- * Fallback render for Svelte 4
53
- */
54
- async renderSvelte4(component, startTime) {
55
- const SvelteComponent = component.component;
56
- const result = SvelteComponent.render(component.props ?? {});
57
- return {
58
- html: result.html,
59
- head: result.head,
60
- css: result.css?.code,
61
- hydrationData: {
62
- props: component.props,
63
- componentId: component.id ?? this.generateId()
64
- },
65
- timing: this.createTiming(startTime)
66
- };
67
- }
68
- getHydrationScript(result) {
69
- const data = this.serializeProps(result.hydrationData);
70
- return `
71
- <script type="module">
72
- window.__FLIGHT_DATA__ = ${data};
73
- window.__FLIGHT_ADAPTER__ = 'svelte';
74
-
75
- const App = window.__FLIGHT_APP__;
76
- const container = document.getElementById('app');
77
-
78
- if (App && container) {
79
- const { props } = window.__FLIGHT_DATA__;
80
- // Svelte 5 mount
81
- import('svelte').then(({ mount, hydrate }) => {
82
- if (container.innerHTML.trim()) {
83
- hydrate(App, { target: container, props });
84
- } else {
85
- mount(App, { target: container, props });
86
- }
87
- });
88
- }
89
- </script>
90
- `.trim();
91
- }
92
- getClientEntry() {
93
- return `
94
- // Svelte 5 client entry
95
- import { mount, hydrate } from 'svelte';
96
-
97
- export function hydrateApp() {
98
- const container = document.getElementById('app');
99
- const App = window.__FLIGHT_APP__;
100
- const data = window.__FLIGHT_DATA__ ?? {};
101
-
102
- if (!container || !App) {
103
- console.warn('[Flight/Svelte] Missing container or App');
104
- return;
105
- }
106
-
107
- // Check if we have SSR content to hydrate
108
- if (container.innerHTML.trim()) {
109
- return hydrate(App, {
110
- target: container,
111
- props: data.props ?? {},
112
- });
113
- } else {
114
- // Fallback to client-side render
115
- return mount(App, {
116
- target: container,
117
- props: data.props ?? {},
118
- });
119
- }
120
- }
121
-
122
- export function render(App, container, props = {}) {
123
- return mount(App, { target: container, props });
124
- }
125
-
126
- // Export for Flight
127
- export { hydrateApp as hydrate };
128
- `.trim();
129
- }
130
- };
131
- function svelte(options) {
132
- return new SvelteAdapter(options);
133
- }
134
- var svelte_default = svelte;
135
-
136
- export { SvelteAdapter, svelte, svelte_default };
@@ -1,121 +0,0 @@
1
- import { BaseUIAdapter } from './chunk-2SNQ6PTM.js';
2
-
3
- // src/adapters/tier-2/lit.ts
4
- var LitAdapter = class extends BaseUIAdapter {
5
- constructor(options = {}) {
6
- super();
7
- this.options = options;
8
- }
9
- id = "lit";
10
- name = "Lit";
11
- framework = "lit";
12
- frameworkVersion = "3+";
13
- tier = "tier-2";
14
- capabilities = {
15
- streaming: false,
16
- partialHydration: true,
17
- islands: true,
18
- resumable: false,
19
- ssg: true,
20
- csr: true,
21
- serverComponents: false
22
- };
23
- async renderToString(component, _context) {
24
- const startTime = performance.now();
25
- try {
26
- const { render } = await import('@lit-labs/ssr');
27
- const { html } = await import('lit');
28
- const { collectResult } = await import('@lit-labs/ssr/lib/render-result.js');
29
- let template;
30
- if (typeof component.component === "string") {
31
- const tagName = component.component;
32
- const props = component.props ?? {};
33
- const attrs = Object.entries(props).map(([key, value]) => {
34
- const attrName = key.replace(/([A-Z])/g, "-$1").toLowerCase();
35
- return `${attrName}="${this.escapeHtml(String(value))}"`;
36
- }).join(" ");
37
- template = html`<${tagName} ${attrs}></${tagName}>`;
38
- } else if (typeof component.component === "function") {
39
- template = component.component(component.props ?? {});
40
- } else {
41
- template = component.component;
42
- }
43
- const ssrResult = render(template);
44
- const htmlString = await collectResult(ssrResult);
45
- return {
46
- html: htmlString,
47
- hydrationData: {
48
- props: component.props,
49
- componentId: component.id ?? this.generateId()
50
- },
51
- timing: this.createTiming(startTime)
52
- };
53
- } catch (error) {
54
- const message = error instanceof Error ? error.message : String(error);
55
- if (message.includes("Cannot find module '@lit-labs/ssr'")) {
56
- throw new Error(
57
- "[Flight/Lit] Lit SSR package not found.\nInstall required packages:\n npm install lit @lit-labs/ssr"
58
- );
59
- }
60
- throw error;
61
- }
62
- }
63
- createIsland(component, props, options) {
64
- const tagName = component;
65
- const id = this.generateId();
66
- const deferHydration = this.options.deferHydration ?? false;
67
- const attrs = Object.entries(props ?? {}).map(([key, value]) => {
68
- const attrName = key.replace(/([A-Z])/g, "-$1").toLowerCase();
69
- return `${attrName}="${this.escapeHtml(String(value))}"`;
70
- }).join(" ");
71
- const placeholder = `
72
- <${tagName}
73
- ${attrs}
74
- data-flight-island="${id}"
75
- ${deferHydration ? "defer-hydration" : ""}
76
- ></${tagName}>
77
- `.trim();
78
- return {
79
- id,
80
- component,
81
- props,
82
- options: options ?? { hydrate: "load" },
83
- placeholder
84
- };
85
- }
86
- getHydrationScript(result) {
87
- const data = this.serializeProps(result.hydrationData);
88
- return `
89
- <script type="module">
90
- window.__FLIGHT_DATA__ = ${data};
91
- window.__FLIGHT_ADAPTER__ = 'lit';
92
-
93
- // Lit components hydrate when their definition is loaded
94
- // If using defer-hydration, call removeAttribute('defer-hydration')
95
- document.querySelectorAll('[defer-hydration]').forEach(el => {
96
- el.removeAttribute('defer-hydration');
97
- });
98
- </script>
99
- `.trim();
100
- }
101
- getClientEntry() {
102
- return `
103
- // Lit Client Entry
104
- // Lit components self-hydrate when their definitions are loaded
105
-
106
- export function hydrate() {
107
- // Remove defer-hydration attributes to trigger hydration
108
- document.querySelectorAll('[defer-hydration]').forEach(el => {
109
- el.removeAttribute('defer-hydration');
110
- });
111
- console.log('[Flight/Lit] Components hydrated');
112
- }
113
- `.trim();
114
- }
115
- };
116
- function lit(options) {
117
- return new LitAdapter(options);
118
- }
119
- var lit_default = lit;
120
-
121
- export { LitAdapter, lit, lit_default };
@@ -1,90 +0,0 @@
1
- import { BaseUIAdapter } from './chunk-2SNQ6PTM.js';
2
-
3
- // src/adapters/tier-3/petite-vue.ts
4
- var PetiteVueAdapter = class extends BaseUIAdapter {
5
- constructor(options = {}) {
6
- super();
7
- this.options = options;
8
- }
9
- id = "petite-vue";
10
- name = "Petite-vue";
11
- framework = "petite-vue";
12
- frameworkVersion = "0.4+";
13
- tier = "tier-3";
14
- capabilities = {
15
- streaming: false,
16
- partialHydration: false,
17
- islands: false,
18
- resumable: false,
19
- ssg: true,
20
- csr: true,
21
- serverComponents: false
22
- };
23
- async renderToString(component, _context) {
24
- const startTime = performance.now();
25
- let html;
26
- if (typeof component.component === "function") {
27
- html = component.component(component.props ?? {});
28
- } else if (typeof component.component === "string") {
29
- html = component.component;
30
- } else {
31
- throw new Error(
32
- "[Flight/Petite-vue] Components must be HTML strings or template functions.\nUse v-scope for state and @click, v-model, etc. for interactivity."
33
- );
34
- }
35
- return {
36
- html,
37
- hydrationData: component.props,
38
- timing: this.createTiming(startTime)
39
- };
40
- }
41
- getHydrationScript(_result) {
42
- const {
43
- version = "0.4.1",
44
- autoInit = true
45
- } = this.options;
46
- return `
47
- <!-- Flight/Petite-vue -->
48
- <script type="module">
49
- import { createApp } from 'https://esm.sh/petite-vue@${version}';
50
-
51
- window.__FLIGHT_ADAPTER__ = 'petite-vue';
52
- ${autoInit ? `createApp().mount();` : "// Manual init: createApp().mount()"}
53
-
54
- console.log('[Flight/Petite-vue] Initialized');
55
- </script>
56
- `.trim();
57
- }
58
- getClientEntry() {
59
- return `
60
- import { createApp, reactive } from 'petite-vue';
61
-
62
- export { createApp, reactive };
63
-
64
- export function hydrate() {
65
- createApp().mount();
66
- console.log('[Flight/Petite-vue] Application mounted');
67
- }
68
-
69
- export function createScope(initialState) {
70
- return reactive(initialState);
71
- }
72
- `.trim();
73
- }
74
- };
75
- function vScope(state, content) {
76
- const stateStr = JSON.stringify(state).replace(/"/g, "'");
77
- return `<div v-scope="${stateStr}">${content}</div>`;
78
- }
79
- function vFor(items, itemName, content) {
80
- return `<template v-for="${itemName} in ${items}">${content}</template>`;
81
- }
82
- function vIf(condition, content) {
83
- return `<template v-if="${condition}">${content}</template>`;
84
- }
85
- function petiteVue(options) {
86
- return new PetiteVueAdapter(options);
87
- }
88
- var petite_vue_default = petiteVue;
89
-
90
- export { PetiteVueAdapter, petiteVue, petite_vue_default, vFor, vIf, vScope };