@flight-framework/core 0.0.3 → 0.2.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/LICENSE +21 -0
- package/dist/{chunk-5KF3QQWZ.js → chunk-3AY23FZP.js} +5 -19
- package/dist/chunk-3AY23FZP.js.map +1 -0
- package/dist/chunk-4F77J5TY.js +324 -0
- package/dist/chunk-4F77J5TY.js.map +1 -0
- package/dist/{chunk-CLMFEKYM.js → chunk-54HPVE7N.js} +67 -2
- package/dist/chunk-54HPVE7N.js.map +1 -0
- package/dist/chunk-5GUCB2CG.js +300 -0
- package/dist/chunk-5GUCB2CG.js.map +1 -0
- package/dist/chunk-62C7LX2E.js +205 -0
- package/dist/chunk-62C7LX2E.js.map +1 -0
- package/dist/chunk-63SCEXD7.js +3 -0
- package/dist/chunk-63SCEXD7.js.map +1 -0
- package/dist/chunk-6BDCTUQY.js +282 -0
- package/dist/chunk-6BDCTUQY.js.map +1 -0
- package/dist/chunk-6CD5FIYI.js +252 -0
- package/dist/chunk-6CD5FIYI.js.map +1 -0
- package/dist/chunk-6XZQPPYC.js +285 -0
- package/dist/chunk-6XZQPPYC.js.map +1 -0
- package/dist/chunk-BJIMTO2I.js +213 -0
- package/dist/chunk-BJIMTO2I.js.map +1 -0
- package/dist/chunk-CLZSB5QD.js +258 -0
- package/dist/chunk-CLZSB5QD.js.map +1 -0
- package/dist/chunk-K2CQZPCG.js +257 -0
- package/dist/chunk-K2CQZPCG.js.map +1 -0
- package/dist/chunk-MQQLYWZZ.js +288 -0
- package/dist/chunk-MQQLYWZZ.js.map +1 -0
- package/dist/chunk-MRLCNFSD.js +341 -0
- package/dist/chunk-MRLCNFSD.js.map +1 -0
- package/dist/chunk-PSJPMEQK.js +212 -0
- package/dist/chunk-PSJPMEQK.js.map +1 -0
- package/dist/chunk-Q62ZQ6FM.js +218 -0
- package/dist/chunk-Q62ZQ6FM.js.map +1 -0
- package/dist/{chunk-ABNCAPQB.js → chunk-RSVA2EYO.js} +2 -2
- package/dist/chunk-RSVA2EYO.js.map +1 -0
- package/dist/chunk-T3S5YC7L.js +256 -0
- package/dist/chunk-T3S5YC7L.js.map +1 -0
- package/dist/chunk-WFAWAHJH.js +267 -0
- package/dist/chunk-WFAWAHJH.js.map +1 -0
- package/dist/chunk-WOEIJWGJ.js +351 -0
- package/dist/chunk-WOEIJWGJ.js.map +1 -0
- package/dist/chunk-XOIYNY4I.js +164 -0
- package/dist/chunk-XOIYNY4I.js.map +1 -0
- package/dist/chunk-XSY5AAXT.js +125 -0
- package/dist/chunk-XSY5AAXT.js.map +1 -0
- package/dist/chunk-Y22AMGTM.js +3 -0
- package/dist/chunk-Y22AMGTM.js.map +1 -0
- package/dist/file-router/index.d.ts +9 -0
- package/dist/file-router/index.js +1 -1
- package/dist/file-router/streaming-hints.d.ts +129 -0
- package/dist/file-router/streaming-hints.js +3 -0
- package/dist/file-router/streaming-hints.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/islands/index.d.ts +234 -0
- package/dist/islands/index.js +3 -0
- package/dist/islands/index.js.map +1 -0
- package/dist/rsc/adapters/index.d.ts +8 -0
- package/dist/rsc/adapters/index.js +7 -0
- package/dist/rsc/adapters/index.js.map +1 -0
- package/dist/rsc/adapters/preact.d.ts +97 -0
- package/dist/rsc/adapters/preact.js +3 -0
- package/dist/rsc/adapters/preact.js.map +1 -0
- package/dist/rsc/adapters/react.d.ts +82 -0
- package/dist/rsc/adapters/react.js +3 -0
- package/dist/rsc/adapters/react.js.map +1 -0
- package/dist/rsc/adapters/solid.d.ts +84 -0
- package/dist/rsc/adapters/solid.js +3 -0
- package/dist/rsc/adapters/solid.js.map +1 -0
- package/dist/rsc/adapters/vue.d.ts +80 -0
- package/dist/rsc/adapters/vue.js +3 -0
- package/dist/rsc/adapters/vue.js.map +1 -0
- package/dist/rsc/boundaries.d.ts +182 -0
- package/dist/rsc/boundaries.js +3 -0
- package/dist/rsc/boundaries.js.map +1 -0
- package/dist/rsc/context.d.ts +201 -0
- package/dist/rsc/context.js +3 -0
- package/dist/rsc/context.js.map +1 -0
- package/dist/rsc/index.d.ts +20 -124
- package/dist/rsc/index.js +13 -1
- package/dist/rsc/legacy.d.ts +131 -0
- package/dist/rsc/legacy.js +3 -0
- package/dist/rsc/legacy.js.map +1 -0
- package/dist/rsc/payload.d.ts +262 -0
- package/dist/rsc/payload.js +3 -0
- package/dist/rsc/payload.js.map +1 -0
- package/dist/rsc/plugins/esbuild.d.ts +124 -0
- package/dist/rsc/plugins/esbuild.js +4 -0
- package/dist/rsc/plugins/esbuild.js.map +1 -0
- package/dist/rsc/plugins/index.d.ts +4 -0
- package/dist/rsc/plugins/index.js +6 -0
- package/dist/rsc/plugins/index.js.map +1 -0
- package/dist/rsc/plugins/rollup.d.ts +103 -0
- package/dist/rsc/plugins/rollup.js +4 -0
- package/dist/rsc/plugins/rollup.js.map +1 -0
- package/dist/rsc/renderer.d.ts +160 -0
- package/dist/rsc/renderer.js +5 -0
- package/dist/rsc/renderer.js.map +1 -0
- package/dist/rsc/stream.d.ts +129 -0
- package/dist/rsc/stream.js +3 -0
- package/dist/rsc/stream.js.map +1 -0
- package/dist/rsc/vite-plugin.d.ts +78 -0
- package/dist/rsc/vite-plugin.js +4 -0
- package/dist/rsc/vite-plugin.js.map +1 -0
- package/dist/streaming/adapters/index.d.ts +223 -0
- package/dist/streaming/adapters/index.js +3 -0
- package/dist/streaming/adapters/index.js.map +1 -0
- package/dist/streaming/conditional.d.ts +130 -0
- package/dist/streaming/conditional.js +3 -0
- package/dist/streaming/conditional.js.map +1 -0
- package/dist/streaming/index.d.ts +8 -0
- package/dist/streaming/index.js +1 -1
- package/dist/streaming/observability.d.ts +201 -0
- package/dist/streaming/observability.js +4 -0
- package/dist/streaming/observability.js.map +1 -0
- package/dist/streaming/priority.d.ts +103 -0
- package/dist/streaming/priority.js +3 -0
- package/dist/streaming/priority.js.map +1 -0
- package/package.json +180 -100
- package/dist/chunk-5KF3QQWZ.js.map +0 -1
- package/dist/chunk-ABNCAPQB.js.map +0 -1
- package/dist/chunk-CLMFEKYM.js.map +0 -1
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flight-framework/core - Islands Architecture
|
|
3
|
+
*
|
|
4
|
+
* Selective hydration with fine-grained control over when and how
|
|
5
|
+
* components become interactive. Framework-agnostic islands primitives.
|
|
6
|
+
*
|
|
7
|
+
* Best Practices 2026:
|
|
8
|
+
* - Minimal JavaScript: Only hydrate what needs interactivity
|
|
9
|
+
* - Lazy hydration: Load JS when actually needed
|
|
10
|
+
* - Progressive enhancement: Works without JS
|
|
11
|
+
* - Performance: Reduce main thread work
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { defineIsland, renderIsland, hydrateIslands } from '@flight-framework/core/islands';
|
|
16
|
+
*
|
|
17
|
+
* // Server: Define an interactive island
|
|
18
|
+
* const Counter = defineIsland({
|
|
19
|
+
* id: 'counter',
|
|
20
|
+
* component: CounterComponent,
|
|
21
|
+
* hydrate: 'visible', // Only hydrate when scrolled into view
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Server: Render to HTML with island markers
|
|
25
|
+
* const html = await renderIsland(Counter, { initial: 0 });
|
|
26
|
+
*
|
|
27
|
+
* // Client: Hydrate all islands on the page
|
|
28
|
+
* hydrateIslands();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* When to hydrate the island
|
|
33
|
+
*/
|
|
34
|
+
type HydrationTrigger = 'load' | 'idle' | 'visible' | 'interaction' | 'media' | 'never' | CustomHydrationTrigger;
|
|
35
|
+
/**
|
|
36
|
+
* Custom hydration trigger function
|
|
37
|
+
*/
|
|
38
|
+
interface CustomHydrationTrigger {
|
|
39
|
+
type: 'custom';
|
|
40
|
+
/** Name for debugging */
|
|
41
|
+
name: string;
|
|
42
|
+
/** Function that returns a promise resolving when hydration should occur */
|
|
43
|
+
when: (element: HTMLElement) => Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Island configuration
|
|
47
|
+
*/
|
|
48
|
+
interface IslandConfig<P = Record<string, unknown>> {
|
|
49
|
+
/** Unique identifier for this island type */
|
|
50
|
+
id: string;
|
|
51
|
+
/** The component to render (framework-specific) */
|
|
52
|
+
component: unknown;
|
|
53
|
+
/** When to hydrate on client */
|
|
54
|
+
hydrate: HydrationTrigger;
|
|
55
|
+
/** Default props */
|
|
56
|
+
defaultProps?: P;
|
|
57
|
+
/** Media query for 'media' trigger */
|
|
58
|
+
mediaQuery?: string;
|
|
59
|
+
/** Path to client-side component bundle */
|
|
60
|
+
clientEntry?: string;
|
|
61
|
+
/** Fallback HTML while not hydrated (optional override) */
|
|
62
|
+
fallback?: string;
|
|
63
|
+
/** Loading priority hint */
|
|
64
|
+
priority?: 'high' | 'low';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Island instance with props
|
|
68
|
+
*/
|
|
69
|
+
interface Island<P = Record<string, unknown>> {
|
|
70
|
+
/** Island configuration */
|
|
71
|
+
config: IslandConfig<P>;
|
|
72
|
+
/** Instance props */
|
|
73
|
+
props: P;
|
|
74
|
+
/** Unique instance ID (for multiple instances of same island type) */
|
|
75
|
+
instanceId: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Rendered island HTML with metadata
|
|
79
|
+
*/
|
|
80
|
+
interface RenderedIsland {
|
|
81
|
+
/** The HTML string */
|
|
82
|
+
html: string;
|
|
83
|
+
/** Island ID */
|
|
84
|
+
id: string;
|
|
85
|
+
/** Instance ID */
|
|
86
|
+
instanceId: string;
|
|
87
|
+
/** Serialized props for hydration */
|
|
88
|
+
propsScript: string;
|
|
89
|
+
/** CSS if any */
|
|
90
|
+
css?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Island registry for client-side hydration
|
|
94
|
+
*/
|
|
95
|
+
interface IslandRegistry {
|
|
96
|
+
/** Register a component for an island ID */
|
|
97
|
+
register(id: string, loader: () => Promise<unknown>): void;
|
|
98
|
+
/** Get registered loader */
|
|
99
|
+
get(id: string): (() => Promise<unknown>) | undefined;
|
|
100
|
+
/** Check if island is registered */
|
|
101
|
+
has(id: string): boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Client-side hydration options
|
|
105
|
+
*/
|
|
106
|
+
interface HydrateOptions {
|
|
107
|
+
/** Root element to scan for islands */
|
|
108
|
+
root?: HTMLElement;
|
|
109
|
+
/** Custom island registry */
|
|
110
|
+
registry?: IslandRegistry;
|
|
111
|
+
/** Callback when an island is hydrated */
|
|
112
|
+
onHydrate?: (id: string, instanceId: string, duration: number) => void;
|
|
113
|
+
/** Callback on hydration error */
|
|
114
|
+
onError?: (id: string, error: Error) => void;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Define an island component
|
|
118
|
+
*/
|
|
119
|
+
declare function defineIsland<P = Record<string, unknown>>(config: IslandConfig<P>): (props?: P) => Island<P>;
|
|
120
|
+
/**
|
|
121
|
+
* UI framework adapter for island rendering
|
|
122
|
+
*/
|
|
123
|
+
interface IslandRenderAdapter {
|
|
124
|
+
/** Framework name */
|
|
125
|
+
name: string;
|
|
126
|
+
/** Render component to HTML */
|
|
127
|
+
renderToString(component: unknown, props: Record<string, unknown>): Promise<string>;
|
|
128
|
+
/** Get CSS if any */
|
|
129
|
+
getCSS?(component: unknown): string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Set the global island render adapter
|
|
133
|
+
*/
|
|
134
|
+
declare function setIslandAdapter(adapter: IslandRenderAdapter): void;
|
|
135
|
+
/**
|
|
136
|
+
* Render an island to HTML with hydration markers
|
|
137
|
+
*/
|
|
138
|
+
declare function renderIsland<P extends Record<string, unknown>>(island: Island<P>, adapter?: IslandRenderAdapter): Promise<RenderedIsland>;
|
|
139
|
+
/**
|
|
140
|
+
* Render multiple islands and collect their outputs
|
|
141
|
+
*/
|
|
142
|
+
declare function renderIslands<P extends Record<string, unknown>>(islands: Island<P>[], adapter?: IslandRenderAdapter): Promise<{
|
|
143
|
+
html: string;
|
|
144
|
+
propsScripts: string;
|
|
145
|
+
css: string;
|
|
146
|
+
}>;
|
|
147
|
+
/**
|
|
148
|
+
* Create an island registry for client-side hydration
|
|
149
|
+
*/
|
|
150
|
+
declare function createIslandRegistry(): IslandRegistry;
|
|
151
|
+
/**
|
|
152
|
+
* Register an island component for client-side hydration
|
|
153
|
+
*/
|
|
154
|
+
declare function registerIsland(id: string, loader: () => Promise<unknown>): void;
|
|
155
|
+
/**
|
|
156
|
+
* Client-side hydration bootstrapper
|
|
157
|
+
* Call this in your client entry point
|
|
158
|
+
*/
|
|
159
|
+
declare function hydrateIslands(options?: HydrateOptions): void;
|
|
160
|
+
/**
|
|
161
|
+
* Create a React island render adapter
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* import { renderToString } from 'react-dom/server';
|
|
166
|
+
* import { createElement } from 'react';
|
|
167
|
+
*
|
|
168
|
+
* const reactAdapter = createReactIslandAdapter({
|
|
169
|
+
* renderToString,
|
|
170
|
+
* createElement,
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
declare function createReactIslandAdapter(deps: {
|
|
175
|
+
renderToString: (element: unknown) => string;
|
|
176
|
+
createElement: (type: unknown, props?: unknown) => unknown;
|
|
177
|
+
}): IslandRenderAdapter;
|
|
178
|
+
/**
|
|
179
|
+
* Create a Preact island render adapter
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* import { renderToString } from 'preact-render-to-string';
|
|
184
|
+
* import { h } from 'preact';
|
|
185
|
+
*
|
|
186
|
+
* const preactAdapter = createPreactIslandAdapter({
|
|
187
|
+
* renderToString,
|
|
188
|
+
* h,
|
|
189
|
+
* });
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
declare function createPreactIslandAdapter(deps: {
|
|
193
|
+
renderToString: (element: unknown) => string;
|
|
194
|
+
h: (type: unknown, props?: unknown) => unknown;
|
|
195
|
+
}): IslandRenderAdapter;
|
|
196
|
+
/**
|
|
197
|
+
* Create a Vue island render adapter
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* import { renderToString, createSSRApp } from 'vue/server-renderer';
|
|
202
|
+
*
|
|
203
|
+
* const vueAdapter = createVueIslandAdapter({
|
|
204
|
+
* renderToString,
|
|
205
|
+
* createSSRApp,
|
|
206
|
+
* });
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
declare function createVueIslandAdapter(deps: {
|
|
210
|
+
renderToString: (app: unknown) => Promise<string>;
|
|
211
|
+
createSSRApp: (component: unknown, props?: unknown) => unknown;
|
|
212
|
+
}): IslandRenderAdapter;
|
|
213
|
+
/**
|
|
214
|
+
* Create a Solid island render adapter
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* import { renderToString } from 'solid-js/web';
|
|
219
|
+
*
|
|
220
|
+
* const solidAdapter = createSolidIslandAdapter({
|
|
221
|
+
* renderToString,
|
|
222
|
+
* });
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
declare function createSolidIslandAdapter(deps: {
|
|
226
|
+
renderToString: (fn: () => unknown) => string;
|
|
227
|
+
}): IslandRenderAdapter;
|
|
228
|
+
/**
|
|
229
|
+
* Register the flight-island custom element
|
|
230
|
+
* This provides additional functionality like slot support
|
|
231
|
+
*/
|
|
232
|
+
declare function registerFlightIslandElement(): void;
|
|
233
|
+
|
|
234
|
+
export { type CustomHydrationTrigger, type HydrateOptions, type HydrationTrigger, type Island, type IslandConfig, type IslandRegistry, type IslandRenderAdapter, type RenderedIsland, createIslandRegistry, createPreactIslandAdapter, createReactIslandAdapter, createSolidIslandAdapter, createVueIslandAdapter, defineIsland, hydrateIslands, registerFlightIslandElement, registerIsland, renderIsland, renderIslands, setIslandAdapter };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createIslandRegistry, createPreactIslandAdapter, createReactIslandAdapter, createSolidIslandAdapter, createVueIslandAdapter, defineIsland, hydrateIslands, registerFlightIslandElement, registerIsland, renderIsland, renderIslands, setIslandAdapter } from '../chunk-WFAWAHJH.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ReactConsumerOptions, ReactServerComponent, createReactAdapter, createReactConsumer, markAsClientComponent } from './react.js';
|
|
2
|
+
export { VueConsumerOptions, VueDependencies, VueServerComponent, createVueAdapter, createVueConsumer, markAsVueClientComponent } from './vue.js';
|
|
3
|
+
export { SolidConsumerOptions, SolidDependencies, SolidServerComponent, createSolidAdapter, createSolidConsumer, isServer as isSolidServer, markAsSolidClientComponent } from './solid.js';
|
|
4
|
+
export { PreactConsumerOptions, PreactDependencies, PreactServerComponent, createPreactAdapter, createPreactConsumer, markAsPreactClientComponent, lazy as preactLazy } from './preact.js';
|
|
5
|
+
export { ElementTypeInfo, UIAdapter } from '../renderer.js';
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../context.js';
|
|
8
|
+
import '../payload.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import '../../chunk-Y22AMGTM.js';
|
|
2
|
+
export { createPreactAdapter, createPreactConsumer, markAsPreactClientComponent, lazy as preactLazy } from '../../chunk-Q62ZQ6FM.js';
|
|
3
|
+
export { createReactAdapter, createReactConsumer, markAsClientComponent } from '../../chunk-PSJPMEQK.js';
|
|
4
|
+
export { createVueAdapter, createVueConsumer, markAsVueClientComponent } from '../../chunk-BJIMTO2I.js';
|
|
5
|
+
export { createSolidAdapter, createSolidConsumer, isServer as isSolidServer, markAsSolidClientComponent } from '../../chunk-6CD5FIYI.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ServerContext } from '../context.js';
|
|
2
|
+
import { FlightElement, FlightChunk } from '../payload.js';
|
|
3
|
+
import { UIAdapter } from '../renderer.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Minimal Preact VNode interface
|
|
7
|
+
*/
|
|
8
|
+
interface PreactVNode {
|
|
9
|
+
type: unknown;
|
|
10
|
+
props: Record<string, unknown>;
|
|
11
|
+
key: string | number | null;
|
|
12
|
+
ref: unknown;
|
|
13
|
+
__?: unknown;
|
|
14
|
+
__k?: unknown[];
|
|
15
|
+
__b?: number;
|
|
16
|
+
__e?: unknown;
|
|
17
|
+
__c?: unknown;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Preact dependencies (user provides these)
|
|
21
|
+
*/
|
|
22
|
+
interface PreactDependencies {
|
|
23
|
+
/** preact module */
|
|
24
|
+
preact: {
|
|
25
|
+
h: (type: unknown, props?: unknown, ...children: unknown[]) => PreactVNode;
|
|
26
|
+
Fragment?: unknown;
|
|
27
|
+
Component?: unknown;
|
|
28
|
+
isValidElement?: (value: unknown) => boolean;
|
|
29
|
+
cloneElement?: (vnode: PreactVNode, props?: unknown) => PreactVNode;
|
|
30
|
+
};
|
|
31
|
+
/** preact-render-to-string module (optional - for SSR) */
|
|
32
|
+
renderToString?: (vnode: PreactVNode) => string;
|
|
33
|
+
/** preact/hooks module (optional) */
|
|
34
|
+
hooks?: {
|
|
35
|
+
useState: <T>(initial: T) => [T, (v: T) => void];
|
|
36
|
+
useEffect: (fn: () => void | (() => void), deps?: unknown[]) => void;
|
|
37
|
+
useMemo: <T>(fn: () => T, deps: unknown[]) => T;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create Preact UI Adapter
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { createPreactAdapter } from '@flight-framework/core/rsc/adapters/preact';
|
|
46
|
+
* import * as preact from 'preact';
|
|
47
|
+
* import renderToString from 'preact-render-to-string';
|
|
48
|
+
*
|
|
49
|
+
* const adapter = createPreactAdapter({
|
|
50
|
+
* preact,
|
|
51
|
+
* renderToString,
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* const renderer = createRenderer(adapter);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function createPreactAdapter(deps?: PreactDependencies): UIAdapter;
|
|
58
|
+
/**
|
|
59
|
+
* Options for Preact consumer
|
|
60
|
+
*/
|
|
61
|
+
interface PreactConsumerOptions {
|
|
62
|
+
/** Registry of client components */
|
|
63
|
+
registry?: Map<string, () => Promise<unknown>>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a Preact client-side consumer for Flight payloads
|
|
67
|
+
*/
|
|
68
|
+
declare function createPreactConsumer(deps: PreactDependencies, options?: PreactConsumerOptions): {
|
|
69
|
+
/**
|
|
70
|
+
* Register a client component
|
|
71
|
+
*/
|
|
72
|
+
register(id: string, loader: () => Promise<unknown>): void;
|
|
73
|
+
/**
|
|
74
|
+
* Convert Flight elements to Preact VNodes
|
|
75
|
+
*/
|
|
76
|
+
toPreactElement(element: FlightElement): unknown;
|
|
77
|
+
/**
|
|
78
|
+
* Hydrate Flight payload into DOM
|
|
79
|
+
*/
|
|
80
|
+
hydrate(chunks: FlightChunk[], container: Element, hydrateFn?: (vnode: unknown, container: Element) => void): void;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Type helper for Preact Server Component
|
|
84
|
+
*/
|
|
85
|
+
type PreactServerComponent<P = Record<string, unknown>> = (props: P, ctx: ServerContext) => Promise<PreactVNode> | PreactVNode;
|
|
86
|
+
/**
|
|
87
|
+
* Mark a Preact component as a client component
|
|
88
|
+
*/
|
|
89
|
+
declare function markAsPreactClientComponent<T extends (...args: unknown[]) => unknown>(component: T, moduleId: string, exportName?: string): T;
|
|
90
|
+
/**
|
|
91
|
+
* Create a lazy-loading component for Preact
|
|
92
|
+
*/
|
|
93
|
+
declare function lazy<T extends (...args: unknown[]) => unknown>(loader: () => Promise<{
|
|
94
|
+
default: T;
|
|
95
|
+
}>): T;
|
|
96
|
+
|
|
97
|
+
export { type PreactConsumerOptions, type PreactDependencies, type PreactServerComponent, createPreactAdapter, createPreactConsumer, lazy, markAsPreactClientComponent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"preact.js"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ServerContext } from '../context.js';
|
|
3
|
+
import { FlightElement, FlightChunk } from '../payload.js';
|
|
4
|
+
import { UIAdapter } from '../renderer.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create React UI Adapter
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { createReactAdapter } from '@flight-framework/core/rsc/adapters/react';
|
|
12
|
+
* import { renderToString } from 'react-dom/server';
|
|
13
|
+
* import * as React from 'react';
|
|
14
|
+
*
|
|
15
|
+
* const adapter = createReactAdapter({
|
|
16
|
+
* React,
|
|
17
|
+
* renderToString,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const renderer = createRenderer(adapter);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare function createReactAdapter(deps?: {
|
|
24
|
+
/** React module (optional - for SSR) */
|
|
25
|
+
React?: {
|
|
26
|
+
isValidElement: (value: unknown) => boolean;
|
|
27
|
+
Children: {
|
|
28
|
+
toArray: (children: unknown) => unknown[];
|
|
29
|
+
};
|
|
30
|
+
Fragment: symbol;
|
|
31
|
+
Suspense: unknown;
|
|
32
|
+
};
|
|
33
|
+
/** renderToString function (optional - for SSR fallbacks) */
|
|
34
|
+
renderToString?: (element: unknown) => string;
|
|
35
|
+
}): UIAdapter;
|
|
36
|
+
/**
|
|
37
|
+
* Opciones para el consumer de React
|
|
38
|
+
*/
|
|
39
|
+
interface ReactConsumerOptions {
|
|
40
|
+
/** Registry de client components */
|
|
41
|
+
registry?: Map<string, () => Promise<unknown>>;
|
|
42
|
+
/** Callback when hydration completes */
|
|
43
|
+
onHydrate?: (id: string) => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a React client-side consumer for Flight payloads
|
|
47
|
+
*
|
|
48
|
+
* This reconstructs React elements from Flight chunks on the client.
|
|
49
|
+
*/
|
|
50
|
+
declare function createReactConsumer(deps: {
|
|
51
|
+
React: {
|
|
52
|
+
createElement: (type: unknown, props?: unknown, ...children: unknown[]) => unknown;
|
|
53
|
+
Suspense: unknown;
|
|
54
|
+
Fragment: unknown;
|
|
55
|
+
lazy: (factory: () => Promise<{
|
|
56
|
+
default: unknown;
|
|
57
|
+
}>) => unknown;
|
|
58
|
+
};
|
|
59
|
+
}, options?: ReactConsumerOptions): {
|
|
60
|
+
/**
|
|
61
|
+
* Register a client component
|
|
62
|
+
*/
|
|
63
|
+
register(id: string, loader: () => Promise<unknown>): void;
|
|
64
|
+
/**
|
|
65
|
+
* Convert Flight elements to React elements
|
|
66
|
+
*/
|
|
67
|
+
toReactElement(element: FlightElement): unknown;
|
|
68
|
+
/**
|
|
69
|
+
* Process Flight chunks and build React tree
|
|
70
|
+
*/
|
|
71
|
+
processChunks(chunks: FlightChunk[]): unknown;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Type helper for React Server Component
|
|
75
|
+
*/
|
|
76
|
+
type ReactServerComponent<P = Record<string, unknown>> = (props: P, ctx: ServerContext) => Promise<ReturnType<typeof react.createElement>> | ReturnType<typeof react.createElement>;
|
|
77
|
+
/**
|
|
78
|
+
* Mark a component as a client component (for use without bundler transform)
|
|
79
|
+
*/
|
|
80
|
+
declare function markAsClientComponent<T extends (...args: unknown[]) => unknown>(component: T, moduleId: string, exportName?: string): T;
|
|
81
|
+
|
|
82
|
+
export { type ReactConsumerOptions, type ReactServerComponent, createReactAdapter, createReactConsumer, markAsClientComponent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"react.js"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ServerContext } from '../context.js';
|
|
2
|
+
import { FlightElement, FlightChunk } from '../payload.js';
|
|
3
|
+
import { UIAdapter } from '../renderer.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Solid dependencies (user provides these)
|
|
7
|
+
*/
|
|
8
|
+
interface SolidDependencies {
|
|
9
|
+
/** solid-js module */
|
|
10
|
+
solid: {
|
|
11
|
+
createSignal: <T>(value: T) => [() => T, (v: T) => void];
|
|
12
|
+
createMemo: <T>(fn: () => T) => () => T;
|
|
13
|
+
createEffect: (fn: () => void) => void;
|
|
14
|
+
children: (fn: () => unknown) => () => unknown[];
|
|
15
|
+
splitProps: <T extends object, K extends keyof T>(props: T, ...keys: K[][]) => [Pick<T, K>, Omit<T, K>][];
|
|
16
|
+
For?: unknown;
|
|
17
|
+
Show?: unknown;
|
|
18
|
+
Switch?: unknown;
|
|
19
|
+
Match?: unknown;
|
|
20
|
+
Suspense?: unknown;
|
|
21
|
+
ErrorBoundary?: unknown;
|
|
22
|
+
};
|
|
23
|
+
/** solid-js/web module */
|
|
24
|
+
web: {
|
|
25
|
+
render?: (code: () => unknown, element: Element) => () => void;
|
|
26
|
+
hydrate?: (code: () => unknown, element: Element) => () => void;
|
|
27
|
+
renderToString?: (code: () => unknown) => string;
|
|
28
|
+
renderToStringAsync?: (code: () => unknown) => Promise<string>;
|
|
29
|
+
isServer?: boolean;
|
|
30
|
+
Dynamic?: unknown;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create Solid.js UI Adapter
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { createSolidAdapter } from '@flight-framework/core/rsc/adapters/solid';
|
|
39
|
+
* import * as solid from 'solid-js';
|
|
40
|
+
* import * as web from 'solid-js/web';
|
|
41
|
+
*
|
|
42
|
+
* const adapter = createSolidAdapter({ solid, web });
|
|
43
|
+
* const renderer = createRenderer(adapter);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function createSolidAdapter(deps?: SolidDependencies): UIAdapter;
|
|
47
|
+
/**
|
|
48
|
+
* Options for Solid consumer
|
|
49
|
+
*/
|
|
50
|
+
interface SolidConsumerOptions {
|
|
51
|
+
/** Registry of client components */
|
|
52
|
+
registry?: Map<string, () => Promise<unknown>>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a Solid client-side consumer for Flight payloads
|
|
56
|
+
*/
|
|
57
|
+
declare function createSolidConsumer(deps: SolidDependencies, options?: SolidConsumerOptions): {
|
|
58
|
+
/**
|
|
59
|
+
* Register a client component
|
|
60
|
+
*/
|
|
61
|
+
register(id: string, loader: () => Promise<unknown>): void;
|
|
62
|
+
/**
|
|
63
|
+
* Convert Flight elements to Solid JSX
|
|
64
|
+
*/
|
|
65
|
+
toSolidElement(element: FlightElement): unknown;
|
|
66
|
+
/**
|
|
67
|
+
* Hydrate Flight payload into DOM
|
|
68
|
+
*/
|
|
69
|
+
hydrate(chunks: FlightChunk[], container: Element): (() => void) | undefined;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Type helper for Solid Server Component
|
|
73
|
+
*/
|
|
74
|
+
type SolidServerComponent<P = Record<string, unknown>> = (props: P, ctx: ServerContext) => Promise<unknown> | unknown;
|
|
75
|
+
/**
|
|
76
|
+
* Mark a Solid component as a client component
|
|
77
|
+
*/
|
|
78
|
+
declare function markAsSolidClientComponent<T extends object>(component: T, moduleId: string, exportName?: string): T;
|
|
79
|
+
/**
|
|
80
|
+
* Check if running on server (Solid isServer helper)
|
|
81
|
+
*/
|
|
82
|
+
declare function isServer(deps?: SolidDependencies): boolean;
|
|
83
|
+
|
|
84
|
+
export { type SolidConsumerOptions, type SolidDependencies, type SolidServerComponent, createSolidAdapter, createSolidConsumer, isServer, markAsSolidClientComponent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"solid.js"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ServerContext } from '../context.js';
|
|
2
|
+
import { FlightElement } from '../payload.js';
|
|
3
|
+
import { UIAdapter } from '../renderer.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Minimal Vue VNode interface
|
|
7
|
+
*/
|
|
8
|
+
interface VueVNode {
|
|
9
|
+
__v_isVNode?: boolean;
|
|
10
|
+
type: unknown;
|
|
11
|
+
props: Record<string, unknown> | null;
|
|
12
|
+
children: unknown;
|
|
13
|
+
key: string | number | null;
|
|
14
|
+
component?: unknown;
|
|
15
|
+
shapeFlag?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Vue dependencies (user provides these)
|
|
19
|
+
*/
|
|
20
|
+
interface VueDependencies {
|
|
21
|
+
/** Vue module */
|
|
22
|
+
Vue: {
|
|
23
|
+
h: (type: unknown, props?: unknown, children?: unknown) => VueVNode;
|
|
24
|
+
isVNode: (value: unknown) => boolean;
|
|
25
|
+
createSSRApp?: (rootComponent: unknown) => unknown;
|
|
26
|
+
Fragment?: symbol;
|
|
27
|
+
Suspense?: unknown;
|
|
28
|
+
Text?: symbol;
|
|
29
|
+
};
|
|
30
|
+
/** renderToString from vue/server-renderer (optional - for SSR) */
|
|
31
|
+
renderToString?: (app: unknown) => Promise<string>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create Vue UI Adapter
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { createVueAdapter } from '@flight-framework/core/rsc/adapters/vue';
|
|
39
|
+
* import * as Vue from 'vue';
|
|
40
|
+
* import { renderToString } from 'vue/server-renderer';
|
|
41
|
+
*
|
|
42
|
+
* const adapter = createVueAdapter({
|
|
43
|
+
* Vue,
|
|
44
|
+
* renderToString,
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* const renderer = createRenderer(adapter);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function createVueAdapter(deps?: VueDependencies): UIAdapter;
|
|
51
|
+
/**
|
|
52
|
+
* Options for Vue consumer
|
|
53
|
+
*/
|
|
54
|
+
interface VueConsumerOptions {
|
|
55
|
+
/** Registry of client components */
|
|
56
|
+
registry?: Map<string, () => Promise<unknown>>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a Vue client-side consumer for Flight payloads
|
|
60
|
+
*/
|
|
61
|
+
declare function createVueConsumer(deps: VueDependencies, options?: VueConsumerOptions): {
|
|
62
|
+
/**
|
|
63
|
+
* Register a client component
|
|
64
|
+
*/
|
|
65
|
+
register(id: string, loader: () => Promise<unknown>): void;
|
|
66
|
+
/**
|
|
67
|
+
* Convert Flight elements to Vue VNodes
|
|
68
|
+
*/
|
|
69
|
+
toVueElement(element: FlightElement): unknown;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Type helper for Vue Server Component
|
|
73
|
+
*/
|
|
74
|
+
type VueServerComponent<P = Record<string, unknown>> = (props: P, ctx: ServerContext) => Promise<VueVNode> | VueVNode;
|
|
75
|
+
/**
|
|
76
|
+
* Mark a Vue component as a client component
|
|
77
|
+
*/
|
|
78
|
+
declare function markAsVueClientComponent<T extends object>(component: T, moduleId: string, exportName?: string): T;
|
|
79
|
+
|
|
80
|
+
export { type VueConsumerOptions, type VueDependencies, type VueServerComponent, createVueAdapter, createVueConsumer, markAsVueClientComponent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"vue.js"}
|