@flight-framework/core 0.1.0 → 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-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-YIOQC3DC.js → chunk-6BDCTUQY.js} +3 -3
- package/dist/{chunk-YIOQC3DC.js.map → chunk-6BDCTUQY.js.map} +1 -1
- 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-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-6WSPUG5L.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-OBNYNJB5.js → chunk-WOEIJWGJ.js} +6 -8
- package/dist/chunk-WOEIJWGJ.js.map +1 -0
- package/dist/{chunk-I2B4WSHC.js → chunk-XSY5AAXT.js} +3 -4
- 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/streaming-hints.d.ts +1 -1
- package/dist/file-router/streaming-hints.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- 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/index.js +1 -1
- package/dist/streaming/observability.js +2 -2
- package/dist/streaming/priority.js +1 -1
- package/package.json +180 -124
- package/dist/chunk-5KF3QQWZ.js.map +0 -1
- package/dist/chunk-6WSPUG5L.js.map +0 -1
- package/dist/chunk-I2B4WSHC.js.map +0 -1
- package/dist/chunk-OBNYNJB5.js.map +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flight-framework/core - esbuild Plugin for RSC
|
|
3
|
+
*
|
|
4
|
+
* esbuild plugin for Flight Server Components.
|
|
5
|
+
* Transforms 'use client' and 'use server' directives at build time.
|
|
6
|
+
*
|
|
7
|
+
* Philosophy: Zero lock-in - esbuild is optional, user decides bundler.
|
|
8
|
+
*
|
|
9
|
+
* @module @flight-framework/core/rsc/plugins/esbuild
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* esbuild Plugin interface (minimal)
|
|
13
|
+
* We define our own to avoid requiring esbuild as dependency
|
|
14
|
+
*/
|
|
15
|
+
interface EsbuildPlugin {
|
|
16
|
+
name: string;
|
|
17
|
+
setup: (build: EsbuildBuild) => void | Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
interface EsbuildBuild {
|
|
20
|
+
initialOptions: EsbuildBuildOptions;
|
|
21
|
+
onStart: (callback: () => void | Promise<void>) => void;
|
|
22
|
+
onEnd: (callback: (result: EsbuildResult) => void | Promise<void>) => void;
|
|
23
|
+
onResolve: (options: {
|
|
24
|
+
filter: RegExp;
|
|
25
|
+
namespace?: string;
|
|
26
|
+
}, callback: (args: EsbuildResolveArgs) => EsbuildResolveResult | null | undefined | Promise<EsbuildResolveResult | null | undefined>) => void;
|
|
27
|
+
onLoad: (options: {
|
|
28
|
+
filter: RegExp;
|
|
29
|
+
namespace?: string;
|
|
30
|
+
}, callback: (args: EsbuildLoadArgs) => EsbuildLoadResult | null | undefined | Promise<EsbuildLoadResult | null | undefined>) => void;
|
|
31
|
+
}
|
|
32
|
+
interface EsbuildBuildOptions {
|
|
33
|
+
outdir?: string;
|
|
34
|
+
write?: boolean;
|
|
35
|
+
metafile?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface EsbuildResult {
|
|
38
|
+
errors: unknown[];
|
|
39
|
+
warnings: unknown[];
|
|
40
|
+
metafile?: unknown;
|
|
41
|
+
}
|
|
42
|
+
interface EsbuildResolveArgs {
|
|
43
|
+
path: string;
|
|
44
|
+
importer: string;
|
|
45
|
+
namespace: string;
|
|
46
|
+
resolveDir: string;
|
|
47
|
+
kind: string;
|
|
48
|
+
}
|
|
49
|
+
interface EsbuildResolveResult {
|
|
50
|
+
path?: string;
|
|
51
|
+
external?: boolean;
|
|
52
|
+
namespace?: string;
|
|
53
|
+
suffix?: string;
|
|
54
|
+
pluginData?: unknown;
|
|
55
|
+
errors?: unknown[];
|
|
56
|
+
warnings?: unknown[];
|
|
57
|
+
watchFiles?: string[];
|
|
58
|
+
watchDirs?: string[];
|
|
59
|
+
}
|
|
60
|
+
interface EsbuildLoadArgs {
|
|
61
|
+
path: string;
|
|
62
|
+
namespace: string;
|
|
63
|
+
suffix: string;
|
|
64
|
+
pluginData: unknown;
|
|
65
|
+
}
|
|
66
|
+
interface EsbuildLoadResult {
|
|
67
|
+
contents?: string;
|
|
68
|
+
loader?: 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'css';
|
|
69
|
+
resolveDir?: string;
|
|
70
|
+
errors?: unknown[];
|
|
71
|
+
warnings?: unknown[];
|
|
72
|
+
watchFiles?: string[];
|
|
73
|
+
watchDirs?: string[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Plugin configuration
|
|
77
|
+
*/
|
|
78
|
+
interface FlightEsbuildPluginOptions {
|
|
79
|
+
/** Include patterns (regex) */
|
|
80
|
+
include?: RegExp;
|
|
81
|
+
/** Exclude patterns (regex) */
|
|
82
|
+
exclude?: RegExp;
|
|
83
|
+
/** Server actions endpoint */
|
|
84
|
+
actionsEndpoint?: string;
|
|
85
|
+
/** Output directory for manifests */
|
|
86
|
+
manifestDir?: string;
|
|
87
|
+
/** Is this for SSR build? */
|
|
88
|
+
ssr?: boolean;
|
|
89
|
+
/** Dev mode (include extra debug info) */
|
|
90
|
+
dev?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Manifest entry
|
|
94
|
+
*/
|
|
95
|
+
interface ManifestEntry {
|
|
96
|
+
id: string;
|
|
97
|
+
file: string;
|
|
98
|
+
exports: string[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Flight RSC esbuild Plugin
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* // build.js
|
|
106
|
+
* import * as esbuild from 'esbuild';
|
|
107
|
+
* import { flightRSCEsbuild } from '@flight-framework/core/rsc/plugins/esbuild';
|
|
108
|
+
*
|
|
109
|
+
* await esbuild.build({
|
|
110
|
+
* entryPoints: ['src/index.tsx'],
|
|
111
|
+
* bundle: true,
|
|
112
|
+
* outdir: 'dist',
|
|
113
|
+
* plugins: [
|
|
114
|
+
* flightRSCEsbuild({
|
|
115
|
+
* actionsEndpoint: '/_flight/action',
|
|
116
|
+
* ssr: true,
|
|
117
|
+
* }),
|
|
118
|
+
* ],
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
declare function flightRSCEsbuild(options?: FlightEsbuildPluginOptions): EsbuildPlugin;
|
|
123
|
+
|
|
124
|
+
export { type EsbuildBuild, type EsbuildBuildOptions, type EsbuildLoadArgs, type EsbuildLoadResult, type EsbuildPlugin, type EsbuildResolveArgs, type EsbuildResolveResult, type EsbuildResult, type FlightEsbuildPluginOptions, type ManifestEntry, flightRSCEsbuild as default, flightRSCEsbuild };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"esbuild.js"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ClientManifestEntry, FlightRSCPluginOptions as FlightVitePluginOptions, ServerManifestEntry, default as flightRSCVite } from '../vite-plugin.js';
|
|
2
|
+
export { EsbuildBuild, EsbuildLoadArgs, EsbuildLoadResult, EsbuildPlugin, EsbuildResolveArgs, EsbuildResolveResult, FlightEsbuildPluginOptions, ManifestEntry, default as flightRSCEsbuild } from './esbuild.js';
|
|
3
|
+
export { FlightRollupPluginOptions, RollupPlugin, RollupPluginContext, default as flightRSCRollup } from './rollup.js';
|
|
4
|
+
import 'vite';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { flightRSCEsbuild } from '../../chunk-6XZQPPYC.js';
|
|
2
|
+
export { flightRSCRollup } from '../../chunk-5GUCB2CG.js';
|
|
3
|
+
export { flightRSC as flightRSCVite } from '../../chunk-MRLCNFSD.js';
|
|
4
|
+
import '../../chunk-CLZSB5QD.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flight-framework/core - Rollup Plugin for RSC
|
|
3
|
+
*
|
|
4
|
+
* Rollup plugin for Flight Server Components.
|
|
5
|
+
* Transforms 'use client' and 'use server' directives at build time.
|
|
6
|
+
*
|
|
7
|
+
* Philosophy: Zero lock-in - Rollup is optional, user decides bundler.
|
|
8
|
+
*
|
|
9
|
+
* @module @flight-framework/core/rsc/plugins/rollup
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Rollup Plugin interface (minimal)
|
|
13
|
+
* We define our own to avoid requiring rollup as dependency
|
|
14
|
+
*/
|
|
15
|
+
interface RollupPlugin {
|
|
16
|
+
name: string;
|
|
17
|
+
buildStart?: (options: unknown) => void | Promise<void>;
|
|
18
|
+
resolveId?: (source: string, importer: string | undefined, options: {
|
|
19
|
+
isEntry: boolean;
|
|
20
|
+
}) => string | null | undefined | {
|
|
21
|
+
id: string;
|
|
22
|
+
external?: boolean;
|
|
23
|
+
} | Promise<string | null | undefined | {
|
|
24
|
+
id: string;
|
|
25
|
+
external?: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
load?: (id: string) => string | null | undefined | {
|
|
28
|
+
code: string;
|
|
29
|
+
map?: unknown;
|
|
30
|
+
} | Promise<string | null | undefined | {
|
|
31
|
+
code: string;
|
|
32
|
+
map?: unknown;
|
|
33
|
+
}>;
|
|
34
|
+
transform?: (code: string, id: string) => string | null | undefined | {
|
|
35
|
+
code: string;
|
|
36
|
+
map?: unknown;
|
|
37
|
+
} | Promise<string | null | undefined | {
|
|
38
|
+
code: string;
|
|
39
|
+
map?: unknown;
|
|
40
|
+
}>;
|
|
41
|
+
generateBundle?: (options: unknown, bundle: Record<string, unknown>) => void | Promise<void>;
|
|
42
|
+
buildEnd?: (error?: Error) => void | Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
interface RollupPluginContext {
|
|
45
|
+
emitFile: (file: {
|
|
46
|
+
type: 'asset' | 'chunk';
|
|
47
|
+
fileName?: string;
|
|
48
|
+
source?: string;
|
|
49
|
+
id?: string;
|
|
50
|
+
}) => string;
|
|
51
|
+
warn: (message: string) => void;
|
|
52
|
+
error: (message: string) => never;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Plugin configuration
|
|
56
|
+
*/
|
|
57
|
+
interface FlightRollupPluginOptions {
|
|
58
|
+
/** Include patterns (regex or function) */
|
|
59
|
+
include?: RegExp | ((id: string) => boolean);
|
|
60
|
+
/** Exclude patterns (regex or function) */
|
|
61
|
+
exclude?: RegExp | ((id: string) => boolean);
|
|
62
|
+
/** Server actions endpoint */
|
|
63
|
+
actionsEndpoint?: string;
|
|
64
|
+
/** Client manifest filename */
|
|
65
|
+
clientManifest?: string;
|
|
66
|
+
/** Server manifest filename */
|
|
67
|
+
serverManifest?: string;
|
|
68
|
+
/** Is this for SSR build? */
|
|
69
|
+
ssr?: boolean;
|
|
70
|
+
/** Dev mode */
|
|
71
|
+
dev?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Manifest entry
|
|
75
|
+
*/
|
|
76
|
+
interface ManifestEntry {
|
|
77
|
+
id: string;
|
|
78
|
+
file: string;
|
|
79
|
+
exports: string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Flight RSC Rollup Plugin
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* // rollup.config.js
|
|
87
|
+
* import { flightRSCRollup } from '@flight-framework/core/rsc/plugins/rollup';
|
|
88
|
+
*
|
|
89
|
+
* export default {
|
|
90
|
+
* input: 'src/index.tsx',
|
|
91
|
+
* output: { dir: 'dist', format: 'esm' },
|
|
92
|
+
* plugins: [
|
|
93
|
+
* flightRSCRollup({
|
|
94
|
+
* ssr: true,
|
|
95
|
+
* actionsEndpoint: '/_flight/action',
|
|
96
|
+
* }),
|
|
97
|
+
* ],
|
|
98
|
+
* };
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function flightRSCRollup(options?: FlightRollupPluginOptions): RollupPlugin;
|
|
102
|
+
|
|
103
|
+
export { type FlightRollupPluginOptions, type ManifestEntry, type RollupPlugin, type RollupPluginContext, flightRSCRollup as default, flightRSCRollup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"rollup.js"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { FlightChunk, ServerComponentChunk, ClientReferenceChunk } from './payload.js';
|
|
2
|
+
import { ServerContext } from './context.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @flight-framework/core - Server Component Renderer
|
|
6
|
+
*
|
|
7
|
+
* Renders Server Components to FlightChunks.
|
|
8
|
+
* Framework-agnostic rendering engine that works with adapters.
|
|
9
|
+
*
|
|
10
|
+
* @module @flight-framework/core/rsc/renderer
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* UI Framework adapter for rendering
|
|
15
|
+
*/
|
|
16
|
+
interface UIAdapter {
|
|
17
|
+
/** Adapter name */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Check if value is a framework element */
|
|
20
|
+
isElement(value: unknown): boolean;
|
|
21
|
+
/** Get element type info */
|
|
22
|
+
getElementType(element: unknown): ElementTypeInfo;
|
|
23
|
+
/** Get element props */
|
|
24
|
+
getProps(element: unknown): Record<string, unknown>;
|
|
25
|
+
/** Get element children */
|
|
26
|
+
getChildren(element: unknown): unknown[];
|
|
27
|
+
/** Get element key */
|
|
28
|
+
getKey(element: unknown): string | number | undefined;
|
|
29
|
+
/** Check if component is a client boundary */
|
|
30
|
+
isClientBoundary(component: unknown): boolean;
|
|
31
|
+
/** Render element to HTML string (for SSR fallback) */
|
|
32
|
+
renderToString?(element: unknown): Promise<string>;
|
|
33
|
+
}
|
|
34
|
+
type ElementTypeInfo = {
|
|
35
|
+
kind: 'host';
|
|
36
|
+
tag: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'component';
|
|
39
|
+
fn: ComponentFn;
|
|
40
|
+
name: string;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'fragment';
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'suspense';
|
|
45
|
+
fallback?: unknown;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'provider';
|
|
48
|
+
value?: unknown;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'context';
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'text';
|
|
53
|
+
value: string;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'null';
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Component function type
|
|
59
|
+
*/
|
|
60
|
+
type ComponentFn = (props: Record<string, unknown>, ctx?: ServerContext) => unknown | Promise<unknown>;
|
|
61
|
+
/**
|
|
62
|
+
* Render options
|
|
63
|
+
*/
|
|
64
|
+
interface RenderOptions {
|
|
65
|
+
/** Include SSR fallbacks for client components */
|
|
66
|
+
includeSSRFallbacks?: boolean;
|
|
67
|
+
/** Error handler */
|
|
68
|
+
onError?: (error: Error, componentName?: string) => void;
|
|
69
|
+
/** Dev mode (include extra debug info) */
|
|
70
|
+
dev?: boolean;
|
|
71
|
+
/** Max render depth to prevent infinite loops */
|
|
72
|
+
maxDepth?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Render result with metadata
|
|
76
|
+
*/
|
|
77
|
+
interface RenderResult {
|
|
78
|
+
/** All chunks generated */
|
|
79
|
+
chunks: FlightChunk[];
|
|
80
|
+
/** Root chunk */
|
|
81
|
+
root: ServerComponentChunk;
|
|
82
|
+
/** Client references found */
|
|
83
|
+
clientRefs: ClientReferenceChunk[];
|
|
84
|
+
/** Timing info */
|
|
85
|
+
timing: {
|
|
86
|
+
startTime: number;
|
|
87
|
+
endTime: number;
|
|
88
|
+
duration: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Flight Server Component Renderer
|
|
93
|
+
*/
|
|
94
|
+
declare class FlightRenderer {
|
|
95
|
+
private adapter;
|
|
96
|
+
private options;
|
|
97
|
+
private chunks;
|
|
98
|
+
private clientRefs;
|
|
99
|
+
private pendingPromises;
|
|
100
|
+
private depth;
|
|
101
|
+
constructor(adapter: UIAdapter, options?: RenderOptions);
|
|
102
|
+
/**
|
|
103
|
+
* Render a component tree to Flight chunks
|
|
104
|
+
*/
|
|
105
|
+
render(element: unknown, ctx: ServerContext): Promise<RenderResult>;
|
|
106
|
+
/**
|
|
107
|
+
* Render as async generator (for streaming)
|
|
108
|
+
*/
|
|
109
|
+
renderStreaming(element: unknown, ctx: ServerContext): AsyncGenerator<FlightChunk>;
|
|
110
|
+
/**
|
|
111
|
+
* Render an element to FlightElement
|
|
112
|
+
*/
|
|
113
|
+
private renderElement;
|
|
114
|
+
/**
|
|
115
|
+
* Render a framework-specific element
|
|
116
|
+
*/
|
|
117
|
+
private renderFrameworkElement;
|
|
118
|
+
/**
|
|
119
|
+
* Render a host element (div, span, etc.)
|
|
120
|
+
*/
|
|
121
|
+
private renderHostElement;
|
|
122
|
+
/**
|
|
123
|
+
* Render a component (server or client)
|
|
124
|
+
*/
|
|
125
|
+
private renderComponent;
|
|
126
|
+
/**
|
|
127
|
+
* Render a client boundary
|
|
128
|
+
*/
|
|
129
|
+
private renderClientBoundary;
|
|
130
|
+
/**
|
|
131
|
+
* Render a Suspense boundary
|
|
132
|
+
*/
|
|
133
|
+
private renderSuspense;
|
|
134
|
+
/**
|
|
135
|
+
* Render an async boundary (promise thrown from component)
|
|
136
|
+
*/
|
|
137
|
+
private renderAsyncBoundary;
|
|
138
|
+
/**
|
|
139
|
+
* Render a Client Reference directly
|
|
140
|
+
*/
|
|
141
|
+
private renderClientReference;
|
|
142
|
+
/**
|
|
143
|
+
* Resolve all pending async chunks
|
|
144
|
+
*/
|
|
145
|
+
private resolvePendingChunks;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Create a renderer with adapter
|
|
149
|
+
*/
|
|
150
|
+
declare function createRenderer(adapter: UIAdapter, options?: RenderOptions): FlightRenderer;
|
|
151
|
+
/**
|
|
152
|
+
* Render a server component tree
|
|
153
|
+
*/
|
|
154
|
+
declare function renderServerComponent<P>(component: ComponentFn, props: P, ctx: ServerContext, adapter: UIAdapter, options?: RenderOptions): Promise<RenderResult>;
|
|
155
|
+
/**
|
|
156
|
+
* Render server component as streaming chunks
|
|
157
|
+
*/
|
|
158
|
+
declare function renderServerComponentStreaming<P>(component: ComponentFn, props: P, ctx: ServerContext, adapter: UIAdapter, options?: RenderOptions): AsyncGenerator<FlightChunk>;
|
|
159
|
+
|
|
160
|
+
export { type ComponentFn, type ElementTypeInfo, FlightRenderer, type RenderOptions, type RenderResult, type UIAdapter, createRenderer, renderServerComponent, renderServerComponentStreaming };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"renderer.js"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { FlightChunk, ServerComponentChunk, ErrorBoundaryChunk } from './payload.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @flight-framework/core - Flight Stream
|
|
5
|
+
*
|
|
6
|
+
* Protocolo de streaming para Server Components.
|
|
7
|
+
* Usa NDJSON (Newline Delimited JSON) para máxima debuggabilidad.
|
|
8
|
+
*
|
|
9
|
+
* Filosofía Flight:
|
|
10
|
+
* - Formato abierto y documentado
|
|
11
|
+
* - Works con cualquier runtime (Node, Deno, Bun, Edge)
|
|
12
|
+
* - Fácil de debuggear (text-based)
|
|
13
|
+
* - Sin dependencias
|
|
14
|
+
*
|
|
15
|
+
* @module @flight-framework/core/rsc/stream
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Opciones para crear un FlightStream
|
|
20
|
+
*/
|
|
21
|
+
interface FlightStreamOptions {
|
|
22
|
+
/** Incluir timestamps en chunks */
|
|
23
|
+
timestamps?: boolean;
|
|
24
|
+
/** Prefix para IDs generados */
|
|
25
|
+
idPrefix?: string;
|
|
26
|
+
/** Callback cuando un chunk es enviado */
|
|
27
|
+
onChunk?: (chunk: FlightChunk) => void;
|
|
28
|
+
/** Callback cuando el stream termina */
|
|
29
|
+
onComplete?: () => void;
|
|
30
|
+
/** Callback en caso de error */
|
|
31
|
+
onError?: (error: Error) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resultado del parsing de un FlightStream
|
|
35
|
+
*/
|
|
36
|
+
interface FlightStreamResult {
|
|
37
|
+
/** Chunks recibidos */
|
|
38
|
+
chunks: FlightChunk[];
|
|
39
|
+
/** Componente raíz */
|
|
40
|
+
root?: ServerComponentChunk;
|
|
41
|
+
/** Errores encontrados */
|
|
42
|
+
errors: ErrorBoundaryChunk[];
|
|
43
|
+
/** Tiempo total de streaming en ms */
|
|
44
|
+
duration: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Crea un ReadableStream desde un AsyncIterable de chunks
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* async function* renderApp() {
|
|
52
|
+
* yield createServerChunk('root', tree);
|
|
53
|
+
* yield createClientChunk('counter', './Counter', 'default', { initial: 0 });
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* const stream = createFlightStream(renderApp());
|
|
57
|
+
* return new Response(stream, { headers: { 'Content-Type': 'text/x-flight' } });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function createFlightStream(chunks: AsyncIterable<FlightChunk>, options?: FlightStreamOptions): ReadableStream<Uint8Array>;
|
|
61
|
+
/**
|
|
62
|
+
* Crea un FlightStream desde un array de chunks
|
|
63
|
+
*/
|
|
64
|
+
declare function createFlightStreamFromArray(chunks: FlightChunk[], options?: FlightStreamOptions): ReadableStream<Uint8Array>;
|
|
65
|
+
/**
|
|
66
|
+
* Parsea un FlightStream a chunks individuales
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // En el cliente
|
|
71
|
+
* const response = await fetch('/page');
|
|
72
|
+
* const chunks = parseFlightStream(response.body!);
|
|
73
|
+
*
|
|
74
|
+
* for await (const chunk of chunks) {
|
|
75
|
+
* handleChunk(chunk);
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare function parseFlightStream(stream: ReadableStream<Uint8Array>): AsyncGenerator<FlightChunk>;
|
|
80
|
+
/**
|
|
81
|
+
* Parsea un string completo de FlightStream
|
|
82
|
+
*/
|
|
83
|
+
declare function parseFlightStreamSync(data: string): FlightChunk[];
|
|
84
|
+
/**
|
|
85
|
+
* Consume un FlightStream y retorna todos los chunks
|
|
86
|
+
*/
|
|
87
|
+
declare function consumeFlightStream(stream: ReadableStream<Uint8Array>): Promise<FlightStreamResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Crea una Response con Flight payload
|
|
90
|
+
*/
|
|
91
|
+
declare function createFlightResponse(chunks: AsyncIterable<FlightChunk>, options?: FlightResponseOptions): Response;
|
|
92
|
+
interface FlightResponseOptions {
|
|
93
|
+
status?: number;
|
|
94
|
+
headers?: Record<string, string>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Crea una Response HTML con streaming SSR + Flight payload embebido
|
|
98
|
+
*/
|
|
99
|
+
declare function createHybridResponse(htmlStream: ReadableStream<Uint8Array>, flightChunks: FlightChunk[], options?: FlightResponseOptions): Response;
|
|
100
|
+
/**
|
|
101
|
+
* Crea un stream controller para enviar chunks progresivamente
|
|
102
|
+
*/
|
|
103
|
+
declare function createStreamController(): {
|
|
104
|
+
stream: ReadableStream<Uint8Array>;
|
|
105
|
+
enqueue: (chunk: FlightChunk) => void;
|
|
106
|
+
error: (error: Error) => void;
|
|
107
|
+
close: () => void;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Merge múltiples streams en uno solo (para rendering paralelo)
|
|
111
|
+
*/
|
|
112
|
+
declare function mergeFlightStreams(...streams: ReadableStream<Uint8Array>[]): ReadableStream<Uint8Array>;
|
|
113
|
+
/**
|
|
114
|
+
* Pipe a flight stream through a transform
|
|
115
|
+
*/
|
|
116
|
+
declare function transformFlightStream(stream: ReadableStream<Uint8Array>, transform: (chunk: FlightChunk) => FlightChunk | null | Promise<FlightChunk | null>): ReadableStream<Uint8Array>;
|
|
117
|
+
/**
|
|
118
|
+
* Pretty print Flight chunks para debugging
|
|
119
|
+
*/
|
|
120
|
+
declare function prettyPrintChunks(chunks: FlightChunk[]): string;
|
|
121
|
+
/**
|
|
122
|
+
* Error durante parsing de FlightStream
|
|
123
|
+
*/
|
|
124
|
+
declare class FlightStreamError extends Error {
|
|
125
|
+
readonly rawData?: string | undefined;
|
|
126
|
+
constructor(message: string, rawData?: string | undefined);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { type FlightResponseOptions, FlightStreamError, type FlightStreamOptions, type FlightStreamResult, consumeFlightStream, createFlightResponse, createFlightStream, createFlightStreamFromArray, createHybridResponse, createStreamController, mergeFlightStreams, parseFlightStream, parseFlightStreamSync, prettyPrintChunks, transformFlightStream };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { FlightStreamError, consumeFlightStream, createFlightResponse, createFlightStream, createFlightStreamFromArray, createHybridResponse, createStreamController, mergeFlightStreams, parseFlightStream, parseFlightStreamSync, prettyPrintChunks, transformFlightStream } from '../chunk-T3S5YC7L.js';
|
|
2
|
+
//# sourceMappingURL=stream.js.map
|
|
3
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"stream.js"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @flight-framework/vite-plugin-rsc
|
|
5
|
+
*
|
|
6
|
+
* Vite plugin for Flight Server Components.
|
|
7
|
+
* Transforms 'use client' and 'use server' directives at build time.
|
|
8
|
+
*
|
|
9
|
+
* Philosophy:
|
|
10
|
+
* - Zero config for common cases
|
|
11
|
+
* - Full control when needed
|
|
12
|
+
* - Works with any Vite project
|
|
13
|
+
* - No Next.js dependencies
|
|
14
|
+
*
|
|
15
|
+
* @module @flight-framework/vite-plugin-rsc
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Plugin configuration
|
|
20
|
+
*/
|
|
21
|
+
interface FlightRSCPluginOptions {
|
|
22
|
+
/** Include patterns (glob) */
|
|
23
|
+
include?: string[];
|
|
24
|
+
/** Exclude patterns (glob) */
|
|
25
|
+
exclude?: string[];
|
|
26
|
+
/** Server actions endpoint */
|
|
27
|
+
actionsEndpoint?: string;
|
|
28
|
+
/** Client manifest output path */
|
|
29
|
+
clientManifest?: string;
|
|
30
|
+
/** Server manifest output path */
|
|
31
|
+
serverManifest?: string;
|
|
32
|
+
/** Enable dev mode features */
|
|
33
|
+
dev?: boolean;
|
|
34
|
+
/** Custom transforms */
|
|
35
|
+
transforms?: {
|
|
36
|
+
/** Transform client components */
|
|
37
|
+
client?: (code: string, id: string) => string | null;
|
|
38
|
+
/** Transform server actions */
|
|
39
|
+
server?: (code: string, id: string) => string | null;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Client manifest entry
|
|
44
|
+
*/
|
|
45
|
+
interface ClientManifestEntry {
|
|
46
|
+
id: string;
|
|
47
|
+
file: string;
|
|
48
|
+
exports: string[];
|
|
49
|
+
chunks?: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Server manifest entry
|
|
53
|
+
*/
|
|
54
|
+
interface ServerManifestEntry {
|
|
55
|
+
id: string;
|
|
56
|
+
file: string;
|
|
57
|
+
actions: string[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Flight RSC Vite Plugin
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // vite.config.ts
|
|
65
|
+
* import { flightRSC } from '@flight-framework/core/rsc/vite-plugin';
|
|
66
|
+
*
|
|
67
|
+
* export default defineConfig({
|
|
68
|
+
* plugins: [
|
|
69
|
+
* flightRSC({
|
|
70
|
+
* actionsEndpoint: '/_flight/action',
|
|
71
|
+
* }),
|
|
72
|
+
* ],
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function flightRSC(options?: FlightRSCPluginOptions): Plugin[];
|
|
77
|
+
|
|
78
|
+
export { type ClientManifestEntry, type FlightRSCPluginOptions, type ServerManifestEntry, flightRSC as default, flightRSC };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"vite-plugin.js"}
|
package/dist/streaming/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createLazyContent, createStreamingResponse, createStreamingSSR, renderWithStreaming, streamParallel, streamSequential } from '../chunk-
|
|
1
|
+
export { createLazyContent, createStreamingResponse, createStreamingSSR, renderWithStreaming, streamParallel, streamSequential } from '../chunk-RSVA2EYO.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { MetricsAggregator, createHttpObserver, createInstrumentedStream, createLoggerObserver } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { MetricsAggregator, createHttpObserver, createInstrumentedStream, createLoggerObserver } from '../chunk-6BDCTUQY.js';
|
|
2
|
+
import '../chunk-RSVA2EYO.js';
|
|
3
3
|
//# sourceMappingURL=observability.js.map
|
|
4
4
|
//# sourceMappingURL=observability.js.map
|