@lytjs/renderer 6.9.2 → 6.9.3
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/dist/dom.d.cts +1 -0
- package/dist/dom.d.ts +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +965 -0
- package/dist/index.d.ts +965 -0
- package/dist/index.mjs.map +1 -1
- package/dist/ssr.d.cts +21 -0
- package/dist/ssr.d.ts +21 -0
- package/dist/vapor/vapor-app.cjs.map +1 -1
- package/dist/vapor/vapor-app.d.cts +88 -0
- package/dist/vapor/vapor-app.d.ts +88 -0
- package/dist/vapor/vapor-app.mjs.map +1 -1
- package/package.json +12 -12
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,965 @@
|
|
|
1
|
+
import { Ref } from '@lytjs/reactivity';
|
|
2
|
+
export { getSkippedTrackingCount, resetSkippedTrackingCount, shouldSkipTracking, withFirstRenderOptimization } from '@lytjs/reactivity';
|
|
3
|
+
import { VaporComponentDefinition, VaporApp } from './vapor/vapor-app.js';
|
|
4
|
+
export { VaporAppOptions, VaporComponentOptions, VaporContext, PropOptions as VaporPropOptions } from './vapor/vapor-app.js';
|
|
5
|
+
import { VNode } from '@lytjs/vdom';
|
|
6
|
+
export { RendererOptions, VNode, createRenderer } from '@lytjs/vdom';
|
|
7
|
+
export { DOMRenderer, EventInvoker, HydrationRenderer, ParsedEvent, WebRendererHost, createDOMRenderer, createHydrationFunctions, createInvoker, createWebHost, getEventKey, normalizeEventName, parseEventModifier, patchAttr, patchClass, patchEvent, patchProp, patchStyle, removeAllEventListeners, wrapDOMEvent } from '@lytjs/adapter-web';
|
|
8
|
+
export { isOn } from '@lytjs/common-events';
|
|
9
|
+
export { HostEvent, HostEventHandler, HostEventOptions, HostRect, HostStyleDeclaration, RendererHost, TransitionDurationInfo } from '@lytjs/host-contract';
|
|
10
|
+
export { SSRInput } from './ssr.js';
|
|
11
|
+
export { escapeHtml, isBooleanAttr } from '@lytjs/common-string';
|
|
12
|
+
|
|
13
|
+
/** 数据获取状态 */
|
|
14
|
+
interface DataFetchState<T = unknown> {
|
|
15
|
+
/** 数据 */
|
|
16
|
+
data: T | undefined;
|
|
17
|
+
/** 是否正在加载 */
|
|
18
|
+
loading: boolean;
|
|
19
|
+
/** 错误信息 */
|
|
20
|
+
error: Error | null;
|
|
21
|
+
/** 是否来自缓存 */
|
|
22
|
+
fromCache: boolean;
|
|
23
|
+
/** 获取时间戳 */
|
|
24
|
+
timestamp: number | null;
|
|
25
|
+
}
|
|
26
|
+
/** 数据获取选项 */
|
|
27
|
+
interface DataFetchOptions<T = unknown> {
|
|
28
|
+
/** 是否立即执行 */
|
|
29
|
+
immediate?: boolean;
|
|
30
|
+
/** 初始数据 */
|
|
31
|
+
initialData?: T;
|
|
32
|
+
/** 缓存键 */
|
|
33
|
+
cacheKey?: string | (() => string);
|
|
34
|
+
/** 缓存时间(毫秒) */
|
|
35
|
+
cacheTime?: number;
|
|
36
|
+
/** 是否服务端预取 */
|
|
37
|
+
serverPrefetch?: boolean;
|
|
38
|
+
/** 依赖项变化时重新获取 */
|
|
39
|
+
watch?: Ref<unknown>[];
|
|
40
|
+
/** 转换函数 */
|
|
41
|
+
transform?: (data: unknown) => T;
|
|
42
|
+
/** 错误处理 */
|
|
43
|
+
onError?: (error: Error) => void;
|
|
44
|
+
/** 成功处理 */
|
|
45
|
+
onSuccess?: (data: T) => void;
|
|
46
|
+
/** 重试次数 */
|
|
47
|
+
retry?: number;
|
|
48
|
+
/** 重试延迟(毫秒) */
|
|
49
|
+
retryDelay?: number;
|
|
50
|
+
}
|
|
51
|
+
/** 预取数据条目 */
|
|
52
|
+
interface PrefetchDataEntry {
|
|
53
|
+
/** 缓存键 */
|
|
54
|
+
key: string;
|
|
55
|
+
/** 数据 */
|
|
56
|
+
data: unknown;
|
|
57
|
+
/** 时间戳 */
|
|
58
|
+
timestamp: number;
|
|
59
|
+
/** 过期时间 */
|
|
60
|
+
expiresAt: number;
|
|
61
|
+
}
|
|
62
|
+
/** 预取管理器 */
|
|
63
|
+
interface PrefetchManager {
|
|
64
|
+
/** 预取数据 */
|
|
65
|
+
prefetch<T>(key: string, fetcher: () => Promise<T>): Promise<T>;
|
|
66
|
+
/** 获取预取数据 */
|
|
67
|
+
getPrefetchedData<T>(key: string): T | undefined;
|
|
68
|
+
/** 序列化所有预取数据 */
|
|
69
|
+
serialize(): string;
|
|
70
|
+
/** 反序列化预取数据 */
|
|
71
|
+
deserialize(data: string): void;
|
|
72
|
+
/** 清除预取数据 */
|
|
73
|
+
clear(): void;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 序列化数据(支持特殊类型)
|
|
77
|
+
*/
|
|
78
|
+
declare function serializeData(data: unknown): string;
|
|
79
|
+
/**
|
|
80
|
+
* 反序列化数据
|
|
81
|
+
*/
|
|
82
|
+
declare function deserializeData(json: string): unknown;
|
|
83
|
+
/**
|
|
84
|
+
* 创建预取管理器
|
|
85
|
+
*/
|
|
86
|
+
declare function createPrefetchManager(): PrefetchManager;
|
|
87
|
+
/**
|
|
88
|
+
* 组合式数据获取函数
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const { data, loading, error, refetch } = useFetch('/api/users', {
|
|
93
|
+
* immediate: true,
|
|
94
|
+
* cacheKey: 'users',
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
declare function useFetch<T extends string | number | boolean | object | null = object>(url: string | (() => string), options?: DataFetchOptions<T>): {
|
|
99
|
+
data: Ref<T | undefined>;
|
|
100
|
+
loading: Ref<boolean>;
|
|
101
|
+
error: Ref<Error | null>;
|
|
102
|
+
refetch: () => Promise<void>;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* 异步数据获取(类似 Nuxt useAsyncData)
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const { data, pending, error } = useAsyncData('users', () =>
|
|
110
|
+
* $fetch('/api/users')
|
|
111
|
+
* );
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
declare function useAsyncData<T extends string | number | boolean | object | null = object>(key: string, fetcher: () => Promise<T>, options?: DataFetchOptions<T>): {
|
|
115
|
+
data: Ref<T | undefined>;
|
|
116
|
+
pending: Ref<boolean>;
|
|
117
|
+
error: Ref<Error | null>;
|
|
118
|
+
refresh: () => Promise<void>;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* 注入服务端预取数据到 HTML
|
|
122
|
+
*/
|
|
123
|
+
declare function injectPrefetchData(): string;
|
|
124
|
+
/**
|
|
125
|
+
* 从客户端读取预取数据
|
|
126
|
+
*/
|
|
127
|
+
declare function getPrefetchData<T = unknown>(key: string): T | undefined;
|
|
128
|
+
|
|
129
|
+
/** Server Action 配置 */
|
|
130
|
+
interface ServerActionConfig {
|
|
131
|
+
/** 服务端 action 端点 */
|
|
132
|
+
endpoint?: string;
|
|
133
|
+
/** 请求头 */
|
|
134
|
+
headers?: Record<string, string>;
|
|
135
|
+
/** 错误处理 */
|
|
136
|
+
onError?: (error: Error) => void;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 配置 Server Action
|
|
140
|
+
*/
|
|
141
|
+
declare function configureServerAction(config: Partial<ServerActionConfig>): void;
|
|
142
|
+
/**
|
|
143
|
+
* 调用服务端函数
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* // 在客户端调用服务端函数
|
|
148
|
+
* const result = await callServer('ProductList', 'fetchProducts', { category: 'electronics' });
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
declare function callServer<T = unknown>(componentName: string, functionName: string, ...args: unknown[]): Promise<T>;
|
|
152
|
+
/**
|
|
153
|
+
* 创建服务端函数代理
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* // 创建类型安全的服务端函数调用
|
|
158
|
+
* const fetchProducts = createServerFunction<Product[]>('ProductList', 'fetchProducts');
|
|
159
|
+
* const products = await fetchProducts({ category: 'electronics' });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare function createServerFunction<T>(componentName: string, functionName: string): (...args: unknown[]) => Promise<T>;
|
|
163
|
+
/**
|
|
164
|
+
* 获取服务端预取的数据
|
|
165
|
+
*/
|
|
166
|
+
declare function getServerData<T = unknown>(key?: string): T | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* 检查是否有服务端数据
|
|
169
|
+
*/
|
|
170
|
+
declare function hasServerData(): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* 检查组件是否已 hydration
|
|
173
|
+
*/
|
|
174
|
+
declare function isHydrated(componentId: string): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* 标记组件为已 hydration
|
|
177
|
+
*/
|
|
178
|
+
declare function markHydrated(componentId: string): void;
|
|
179
|
+
/**
|
|
180
|
+
* 获取 hydration 状态
|
|
181
|
+
*/
|
|
182
|
+
declare function getHydrationState(componentId: string): {
|
|
183
|
+
hydrated: boolean;
|
|
184
|
+
pending: boolean;
|
|
185
|
+
error: Error | null;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* 自动 hydrate 所有 Server Components
|
|
189
|
+
*/
|
|
190
|
+
declare function autoHydrate(): Promise<void>;
|
|
191
|
+
|
|
192
|
+
/** Server Component 定义 */
|
|
193
|
+
interface ServerComponentDefinition {
|
|
194
|
+
/** 组件 ID */
|
|
195
|
+
id: string;
|
|
196
|
+
/** 组件名称 */
|
|
197
|
+
name: string;
|
|
198
|
+
/** 渲染函数 */
|
|
199
|
+
render: () => Promise<string>;
|
|
200
|
+
/** 数据获取函数 */
|
|
201
|
+
fetchData?: () => Promise<Record<string, unknown>>;
|
|
202
|
+
/** 序列化数据 */
|
|
203
|
+
serializeData?: () => string;
|
|
204
|
+
}
|
|
205
|
+
/** Server Action 请求 */
|
|
206
|
+
interface ServerActionRequest {
|
|
207
|
+
/** 组件名称 */
|
|
208
|
+
componentName: string;
|
|
209
|
+
/** 函数名称 */
|
|
210
|
+
functionName: string;
|
|
211
|
+
/** 参数 */
|
|
212
|
+
args: unknown[];
|
|
213
|
+
}
|
|
214
|
+
/** Server Action 响应 */
|
|
215
|
+
interface ServerActionResponse {
|
|
216
|
+
/** 是否成功 */
|
|
217
|
+
success: boolean;
|
|
218
|
+
/** 返回数据 */
|
|
219
|
+
data?: unknown;
|
|
220
|
+
/** 错误信息 */
|
|
221
|
+
error?: string;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* 注册 Server Component
|
|
225
|
+
*/
|
|
226
|
+
declare function registerServerComponent(component: ServerComponentDefinition): void;
|
|
227
|
+
/**
|
|
228
|
+
* 注册服务端函数
|
|
229
|
+
*/
|
|
230
|
+
declare function registerServerFunction(componentId: string, functionName: string, fn: (...args: unknown[]) => Promise<unknown>): void;
|
|
231
|
+
/**
|
|
232
|
+
* 获取 Server Component
|
|
233
|
+
*/
|
|
234
|
+
declare function getServerComponent(id: string): ServerComponentDefinition | undefined;
|
|
235
|
+
/**
|
|
236
|
+
* 获取服务端函数
|
|
237
|
+
*/
|
|
238
|
+
declare function getServerFunction(componentId: string, functionName: string): ((...args: unknown[]) => Promise<unknown>) | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* 处理 Server Action 请求
|
|
241
|
+
* 用于处理客户端对服务端函数的调用
|
|
242
|
+
*/
|
|
243
|
+
declare function handleServerAction(request: ServerActionRequest): Promise<ServerActionResponse>;
|
|
244
|
+
/**
|
|
245
|
+
* 创建 Server Action 处理器
|
|
246
|
+
* 用于 Express/Fastify 等服务端框架
|
|
247
|
+
*/
|
|
248
|
+
declare function createServerActionHandler(): (req: any, res: any) => Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* 序列化 Server Component 数据
|
|
251
|
+
*/
|
|
252
|
+
declare function serializeServerData(data: unknown): string;
|
|
253
|
+
/**
|
|
254
|
+
* 反序列化 Server Component 数据
|
|
255
|
+
*/
|
|
256
|
+
declare function deserializeServerData(json: string): unknown;
|
|
257
|
+
/**
|
|
258
|
+
* 渲染 Server Component
|
|
259
|
+
*/
|
|
260
|
+
declare function renderServerComponent(componentId: string, _context?: Record<string, unknown>): Promise<string>;
|
|
261
|
+
/**
|
|
262
|
+
* 定义 Server Component
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* export default defineServerComponent({
|
|
267
|
+
* id: 'product-list',
|
|
268
|
+
* name: 'ProductList',
|
|
269
|
+
* async fetchData() {
|
|
270
|
+
* const products = await db.products.findMany();
|
|
271
|
+
* return { products };
|
|
272
|
+
* },
|
|
273
|
+
* async render() {
|
|
274
|
+
* return '<div class="product-list">...</div>';
|
|
275
|
+
* }
|
|
276
|
+
* });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare function defineServerComponent(options: Omit<ServerComponentDefinition, 'serializeData'> & {
|
|
280
|
+
serializeData?: () => string;
|
|
281
|
+
}): ServerComponentDefinition;
|
|
282
|
+
|
|
283
|
+
/** HMR 更新类型 */
|
|
284
|
+
type HMRUpdateType = 'template' | 'script' | 'style' | 'full';
|
|
285
|
+
/** HMR 更新信息 */
|
|
286
|
+
interface HMRUpdate {
|
|
287
|
+
type: HMRUpdateType;
|
|
288
|
+
componentId: string;
|
|
289
|
+
oldComponent: VaporComponentDefinition | null;
|
|
290
|
+
newComponent: VaporComponentDefinition;
|
|
291
|
+
timestamp: number;
|
|
292
|
+
}
|
|
293
|
+
/** HMR 状态保留策略 */
|
|
294
|
+
interface HMRStatePreservation {
|
|
295
|
+
/** 是否保留 ref 状态 */
|
|
296
|
+
refs: boolean;
|
|
297
|
+
/** 是否保留 reactive 状态 */
|
|
298
|
+
reactive: boolean;
|
|
299
|
+
/** 是否保留 computed 缓存 */
|
|
300
|
+
computed: boolean;
|
|
301
|
+
/** 是否保留 watch 副作用 */
|
|
302
|
+
watches: boolean;
|
|
303
|
+
}
|
|
304
|
+
/** 默认状态保留策略 */
|
|
305
|
+
declare const DEFAULT_STATE_PRESERVATION: HMRStatePreservation;
|
|
306
|
+
/**
|
|
307
|
+
* 生成唯一的组件 ID
|
|
308
|
+
*/
|
|
309
|
+
declare function generateComponentId(): string;
|
|
310
|
+
/**
|
|
311
|
+
* 注册组件实例
|
|
312
|
+
*/
|
|
313
|
+
declare function registerComponent(id: string, component: VaporComponentDefinition, container: Element): void;
|
|
314
|
+
/**
|
|
315
|
+
* 注销组件实例
|
|
316
|
+
*/
|
|
317
|
+
declare function unregisterComponent(id: string): void;
|
|
318
|
+
/** HMR 更新监听器 */
|
|
319
|
+
type HMRUpdateListener = (update: HMRUpdate) => void;
|
|
320
|
+
/**
|
|
321
|
+
* 添加 HMR 更新监听器
|
|
322
|
+
*/
|
|
323
|
+
declare function onHMRUpdate(listener: HMRUpdateListener): () => void;
|
|
324
|
+
/**
|
|
325
|
+
* 处理组件更新
|
|
326
|
+
*
|
|
327
|
+
* @param componentId 组件 ID
|
|
328
|
+
* @param newComponent 新组件定义
|
|
329
|
+
* @param updateType 更新类型
|
|
330
|
+
* @param preservation 状态保留策略
|
|
331
|
+
* @returns 是否成功更新
|
|
332
|
+
*/
|
|
333
|
+
declare function handleComponentUpdate(componentId: string, newComponent: VaporComponentDefinition, updateType: HMRUpdateType, _preservation?: HMRStatePreservation): boolean;
|
|
334
|
+
/**
|
|
335
|
+
* 创建 Vite HMR accept 处理器
|
|
336
|
+
*
|
|
337
|
+
* 用于在组件中调用:
|
|
338
|
+
* ```ts
|
|
339
|
+
* if (import.meta.hot) {
|
|
340
|
+
* import.meta.hot.accept((newModule) => {
|
|
341
|
+
* createVaporHMRHandler('my-component-id')(newModule);
|
|
342
|
+
* });
|
|
343
|
+
* }
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
declare function createVaporHMRHandler(componentId: string): (newModule: {
|
|
347
|
+
default: VaporComponentDefinition;
|
|
348
|
+
} | null) => void;
|
|
349
|
+
/**
|
|
350
|
+
* 检测是否支持 HMR
|
|
351
|
+
*/
|
|
352
|
+
declare function isHMRAvailable(): boolean;
|
|
353
|
+
/**
|
|
354
|
+
* 手动触发组件重新渲染
|
|
355
|
+
*/
|
|
356
|
+
declare function forceRerender(componentId: string): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* 清理所有 HMR 状态
|
|
359
|
+
*/
|
|
360
|
+
declare function clearHMRState(): void;
|
|
361
|
+
|
|
362
|
+
type App = unknown;
|
|
363
|
+
type Component = unknown;
|
|
364
|
+
/** Hydration 模式 */
|
|
365
|
+
type HydrationMode = 'full' | 'selective' | 'lazy';
|
|
366
|
+
/** Hydration 选项 */
|
|
367
|
+
interface HydrationOptions {
|
|
368
|
+
/** Hydration 模式 */
|
|
369
|
+
mode?: HydrationMode;
|
|
370
|
+
/** 选择性 Hydration 选择器 */
|
|
371
|
+
selectors?: string[];
|
|
372
|
+
/** 懒加载阈值(毫秒) */
|
|
373
|
+
lazyThreshold?: number;
|
|
374
|
+
/** 是否在空闲时 Hydration */
|
|
375
|
+
idleCallback?: boolean;
|
|
376
|
+
/** 错误处理 */
|
|
377
|
+
onError?: (error: HydrationError) => void;
|
|
378
|
+
/** 不匹配处理 */
|
|
379
|
+
onMismatch?: (mismatch: HydrationMismatch) => void;
|
|
380
|
+
/** Hydration 完成回调 */
|
|
381
|
+
onComplete?: () => void;
|
|
382
|
+
}
|
|
383
|
+
/** Hydration 错误 */
|
|
384
|
+
interface HydrationError {
|
|
385
|
+
/** 错误类型 */
|
|
386
|
+
type: 'mismatch' | 'missing' | 'invalid' | 'script';
|
|
387
|
+
/** 错误消息 */
|
|
388
|
+
message: string;
|
|
389
|
+
/** 相关节点 */
|
|
390
|
+
node?: Element;
|
|
391
|
+
/** 原始错误 */
|
|
392
|
+
error?: Error;
|
|
393
|
+
}
|
|
394
|
+
/** Hydration 不匹配 */
|
|
395
|
+
interface HydrationMismatch {
|
|
396
|
+
/** 期望的 HTML */
|
|
397
|
+
expected: string;
|
|
398
|
+
/** 实际的 HTML */
|
|
399
|
+
actual: string;
|
|
400
|
+
/** 节点路径 */
|
|
401
|
+
path: string;
|
|
402
|
+
/** 恢复策略 */
|
|
403
|
+
recoveryStrategy: 'rerender' | 'keep-server' | 'keep-client';
|
|
404
|
+
}
|
|
405
|
+
/** Hydration 统计 */
|
|
406
|
+
interface HydrationStats {
|
|
407
|
+
/** 总节点数 */
|
|
408
|
+
totalNodes: number;
|
|
409
|
+
/** 已 Hydration 节点数 */
|
|
410
|
+
hydratedNodes: number;
|
|
411
|
+
/** 跳过的节点数 */
|
|
412
|
+
skippedNodes: number;
|
|
413
|
+
/** 不匹配数 */
|
|
414
|
+
mismatches: number;
|
|
415
|
+
/** 错误数 */
|
|
416
|
+
errors: number;
|
|
417
|
+
/** Hydration 耗时(毫秒) */
|
|
418
|
+
duration: number;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* 全应用 Hydration
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```ts
|
|
425
|
+
* // 服务端渲染的 HTML
|
|
426
|
+
* const html = '<div id="app">...</div>';
|
|
427
|
+
*
|
|
428
|
+
* // 客户端 Hydration
|
|
429
|
+
* hydrateApp(App, '#app');
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
declare function hydrateApp(component: Component, container: string | Element, options?: HydrationOptions): Promise<{
|
|
433
|
+
app: App;
|
|
434
|
+
stats: HydrationStats;
|
|
435
|
+
}>;
|
|
436
|
+
/**
|
|
437
|
+
* 选择性 Hydration
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```ts
|
|
441
|
+
* // 只 Hydration 可见区域
|
|
442
|
+
* hydrateVisible(App, '#app');
|
|
443
|
+
*
|
|
444
|
+
* // 基于 IntersectionObserver
|
|
445
|
+
* hydrateOnVisible(App, '#app', {
|
|
446
|
+
* rootMargin: '100px',
|
|
447
|
+
* });
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
declare function hydrateVisible(component: Component, container: string | Element, options?: HydrationOptions): Promise<{
|
|
451
|
+
app: App;
|
|
452
|
+
stats: HydrationStats;
|
|
453
|
+
}>;
|
|
454
|
+
/**
|
|
455
|
+
* 延迟 Hydration
|
|
456
|
+
* 将 Hydration 任务加入队列,按优先级执行
|
|
457
|
+
*/
|
|
458
|
+
declare function queueHydration(element: Element, priority: 'high' | 'medium' | 'low', callback: () => Promise<void>): void;
|
|
459
|
+
/**
|
|
460
|
+
* 水合错误恢复策略
|
|
461
|
+
*/
|
|
462
|
+
type RecoveryStrategy = 'rerender' | 'keep-server' | 'keep-client' | 'fallback';
|
|
463
|
+
/**
|
|
464
|
+
* 水合错误处理器
|
|
465
|
+
*/
|
|
466
|
+
declare class HydrationErrorHandler {
|
|
467
|
+
private errors;
|
|
468
|
+
private mismatches;
|
|
469
|
+
private options;
|
|
470
|
+
constructor(options?: HydrationOptions);
|
|
471
|
+
/**
|
|
472
|
+
* 处理 Hydration 错误
|
|
473
|
+
*/
|
|
474
|
+
handleError(error: HydrationError): RecoveryStrategy;
|
|
475
|
+
/**
|
|
476
|
+
* 处理不匹配错误
|
|
477
|
+
*/
|
|
478
|
+
private handleMismatch;
|
|
479
|
+
/**
|
|
480
|
+
* 判断是否是轻微不匹配
|
|
481
|
+
*/
|
|
482
|
+
private isMinorMismatch;
|
|
483
|
+
/**
|
|
484
|
+
* 判断是否是严重不匹配
|
|
485
|
+
*/
|
|
486
|
+
private isCriticalMismatch;
|
|
487
|
+
/**
|
|
488
|
+
* 获取节点路径
|
|
489
|
+
*/
|
|
490
|
+
private getNodePath;
|
|
491
|
+
/**
|
|
492
|
+
* 获取所有错误
|
|
493
|
+
*/
|
|
494
|
+
getErrors(): HydrationError[];
|
|
495
|
+
/**
|
|
496
|
+
* 获取所有不匹配
|
|
497
|
+
*/
|
|
498
|
+
getMismatches(): HydrationMismatch[];
|
|
499
|
+
/**
|
|
500
|
+
* 清除错误记录
|
|
501
|
+
*/
|
|
502
|
+
clear(): void;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* 创建错误处理器
|
|
506
|
+
*/
|
|
507
|
+
declare function createHydrationErrorHandler(options?: HydrationOptions): HydrationErrorHandler;
|
|
508
|
+
/**
|
|
509
|
+
* 安全 Hydration
|
|
510
|
+
* 带错误恢复的 Hydration
|
|
511
|
+
*/
|
|
512
|
+
declare function safeHydrate(component: Component, container: string | Element, options?: HydrationOptions): Promise<{
|
|
513
|
+
app: App;
|
|
514
|
+
stats: HydrationStats;
|
|
515
|
+
errorHandler: HydrationErrorHandler;
|
|
516
|
+
}>;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* @lytjs/renderer - SSR 流式渲染
|
|
520
|
+
* 使用 Web Streams API 进行服务端流式渲染
|
|
521
|
+
* FIX: P2-36 使用共享工具函数
|
|
522
|
+
*/
|
|
523
|
+
|
|
524
|
+
interface SSRStreamOptions {
|
|
525
|
+
/** 是否在块之间插入注释标记(用于调试) */
|
|
526
|
+
commentMarkers?: boolean;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/** 优化的流式渲染选项 */
|
|
530
|
+
interface OptimizedStreamOptions {
|
|
531
|
+
/** 是否启用预加载提示 */
|
|
532
|
+
preloadHints?: boolean;
|
|
533
|
+
/** 是否启用 HTTP/2 Push */
|
|
534
|
+
http2Push?: boolean;
|
|
535
|
+
/** 关键 CSS 内联 */
|
|
536
|
+
criticalCSS?: string;
|
|
537
|
+
/** 延迟加载阈值(毫秒) */
|
|
538
|
+
deferThreshold?: number;
|
|
539
|
+
/** 是否启用压缩 */
|
|
540
|
+
compression?: boolean;
|
|
541
|
+
/** 缓冲区大小(字节) */
|
|
542
|
+
bufferSize?: number;
|
|
543
|
+
/** 是否启用 Early Flush */
|
|
544
|
+
earlyFlush?: boolean;
|
|
545
|
+
}
|
|
546
|
+
/** 预加载提示 */
|
|
547
|
+
interface PreloadHint {
|
|
548
|
+
/** 资源类型 */
|
|
549
|
+
type: 'script' | 'style' | 'font' | 'image';
|
|
550
|
+
/** 资源 URL */
|
|
551
|
+
href: string;
|
|
552
|
+
/** 是否跨域 */
|
|
553
|
+
crossorigin?: boolean;
|
|
554
|
+
/** 优先级 */
|
|
555
|
+
importance?: 'high' | 'low' | 'auto';
|
|
556
|
+
}
|
|
557
|
+
/** 流式渲染统计 */
|
|
558
|
+
interface StreamStats {
|
|
559
|
+
/** TTFB(首字节时间) */
|
|
560
|
+
ttfb: number;
|
|
561
|
+
/** 总渲染时间 */
|
|
562
|
+
totalTime: number;
|
|
563
|
+
/** 块数量 */
|
|
564
|
+
chunkCount: number;
|
|
565
|
+
/** 总字节数 */
|
|
566
|
+
totalBytes: number;
|
|
567
|
+
/** Suspense 边界数量 */
|
|
568
|
+
suspenseBoundaries: number;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* 优化的 SSR 流式渲染器
|
|
572
|
+
*
|
|
573
|
+
* 特性:
|
|
574
|
+
* - Early Flush:尽早发送初始 HTML
|
|
575
|
+
* - 智能缓冲:自动管理缓冲区大小
|
|
576
|
+
* - 预加载提示:自动生成 Link 头
|
|
577
|
+
* - 优先级调度:关键内容优先发送
|
|
578
|
+
*/
|
|
579
|
+
declare class OptimizedSSRStream {
|
|
580
|
+
private controller;
|
|
581
|
+
private encoder;
|
|
582
|
+
private options;
|
|
583
|
+
private buffer;
|
|
584
|
+
private bufferSize;
|
|
585
|
+
private stats;
|
|
586
|
+
private startTime;
|
|
587
|
+
private flushedFirstChunk;
|
|
588
|
+
private preloadHints;
|
|
589
|
+
constructor(controller: ReadableStreamDefaultController<Uint8Array>, options?: OptimizedStreamOptions);
|
|
590
|
+
/**
|
|
591
|
+
* 推送 HTML 内容到流
|
|
592
|
+
*/
|
|
593
|
+
push(html: string): void;
|
|
594
|
+
/**
|
|
595
|
+
* 刷新缓冲区到流
|
|
596
|
+
*/
|
|
597
|
+
flush(): void;
|
|
598
|
+
/**
|
|
599
|
+
* 添加预加载提示
|
|
600
|
+
*/
|
|
601
|
+
addPreloadHint(hint: PreloadHint): void;
|
|
602
|
+
/**
|
|
603
|
+
* 生成文档头部
|
|
604
|
+
*/
|
|
605
|
+
generateDocumentHead(options: {
|
|
606
|
+
title?: string;
|
|
607
|
+
meta?: Record<string, string>[];
|
|
608
|
+
links?: Record<string, string>[];
|
|
609
|
+
styles?: string[];
|
|
610
|
+
}): string;
|
|
611
|
+
/**
|
|
612
|
+
* 生成文档尾部
|
|
613
|
+
*/
|
|
614
|
+
generateDocumentFooter(options: {
|
|
615
|
+
scripts?: string[];
|
|
616
|
+
inlineScripts?: string[];
|
|
617
|
+
}): string;
|
|
618
|
+
/**
|
|
619
|
+
* 流式渲染 VNode
|
|
620
|
+
*/
|
|
621
|
+
renderVNode(vnode: VNode): Promise<void>;
|
|
622
|
+
/**
|
|
623
|
+
* 获取渲染统计
|
|
624
|
+
*/
|
|
625
|
+
getStats(): StreamStats;
|
|
626
|
+
/**
|
|
627
|
+
* 完成渲染
|
|
628
|
+
*/
|
|
629
|
+
finish(): void;
|
|
630
|
+
private generateLinkHeader;
|
|
631
|
+
private streamVNode;
|
|
632
|
+
private streamFragment;
|
|
633
|
+
private streamElement;
|
|
634
|
+
private streamComponent;
|
|
635
|
+
private isComponentVNode;
|
|
636
|
+
private yieldToMicrotask;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* @lytjs/renderer - SSR Island 架构
|
|
641
|
+
* 为 SSR 应用提供基于 Island 的选择性 hydration
|
|
642
|
+
*/
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Island 组件的精简接口。
|
|
646
|
+
* 使用简化的结构以避免与完整的 ComponentOptions 紧耦合。
|
|
647
|
+
*/
|
|
648
|
+
interface ComponentOptions {
|
|
649
|
+
name?: string;
|
|
650
|
+
props?: Record<string, unknown>;
|
|
651
|
+
setup?: (props: Record<string, unknown>) => Record<string, unknown> | VNode | void;
|
|
652
|
+
render?: (ctx: Record<string, unknown>) => VNode;
|
|
653
|
+
data?: () => Record<string, unknown>;
|
|
654
|
+
[key: string]: unknown;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
interface SignalRenderer {
|
|
658
|
+
/** 将模板渲染到指定的容器元素或 CSS 选择器 */
|
|
659
|
+
render(container: Element | string): void;
|
|
660
|
+
/** 卸载渲染器,清理所有 effect 和 DOM */
|
|
661
|
+
unmount(): void;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/** Vapor SSR 渲染选项 */
|
|
665
|
+
interface VaporSSROptions {
|
|
666
|
+
/** 是否包含数据预取脚本 */
|
|
667
|
+
includePrefetchScript?: boolean;
|
|
668
|
+
/** 是否启用流式渲染 */
|
|
669
|
+
streaming?: boolean;
|
|
670
|
+
/** 自定义序列化函数 */
|
|
671
|
+
serialize?: (data: unknown) => string;
|
|
672
|
+
}
|
|
673
|
+
/** Vapor SSR 渲染结果 */
|
|
674
|
+
interface VaporSSRResult {
|
|
675
|
+
/** 渲染的 HTML 字符串 */
|
|
676
|
+
html: string;
|
|
677
|
+
/** 预取的数据(用于客户端 hydration) */
|
|
678
|
+
prefetchData?: Record<string, unknown>;
|
|
679
|
+
/** 需要注入的脚本 */
|
|
680
|
+
scripts?: string[];
|
|
681
|
+
/** 需要注入的样式 */
|
|
682
|
+
styles?: string[];
|
|
683
|
+
}
|
|
684
|
+
/** Vapor SSR 流式渲染结果 */
|
|
685
|
+
interface VaporSSRStreamResult {
|
|
686
|
+
/** HTML 流 */
|
|
687
|
+
stream: ReadableStream<Uint8Array>;
|
|
688
|
+
/** 预取数据 Promise */
|
|
689
|
+
prefetchData: Promise<Record<string, unknown>>;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* 定义数据预取函数
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* ```ts
|
|
696
|
+
* const App = defineVaporComponent({
|
|
697
|
+
* template: '<div>{{ data.message }}</div>',
|
|
698
|
+
* setup() {
|
|
699
|
+
* // 使用 definePrefetch 定义预取函数
|
|
700
|
+
* const data = definePrefetch(async () => {
|
|
701
|
+
* const res = await fetch('/api/data');
|
|
702
|
+
* return res.json();
|
|
703
|
+
* });
|
|
704
|
+
* return { data };
|
|
705
|
+
* }
|
|
706
|
+
* });
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
declare function definePrefetch<T>(fetcher: () => Promise<T>): {
|
|
710
|
+
data: T | undefined;
|
|
711
|
+
__prefetchFn__: () => Promise<T>;
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
714
|
+
* 在 setup 中使用预取数据
|
|
715
|
+
*/
|
|
716
|
+
declare function usePrefetchData<T>(key: string, _fetcher?: () => Promise<T>): {
|
|
717
|
+
data: T | undefined;
|
|
718
|
+
pending: boolean;
|
|
719
|
+
error: Error | null;
|
|
720
|
+
};
|
|
721
|
+
/**
|
|
722
|
+
* Vapor SSR Hydration 选项
|
|
723
|
+
*/
|
|
724
|
+
interface VaporHydrationOptions {
|
|
725
|
+
/** 是否启用选择性 hydration */
|
|
726
|
+
selective?: boolean;
|
|
727
|
+
/** Hydration 错误处理 */
|
|
728
|
+
onError?: (error: Error) => void;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* @lytjs/renderer - Component Resource Cleanup
|
|
733
|
+
*
|
|
734
|
+
* 基于 WeakMap 的组件资源清理注册表。
|
|
735
|
+
* 组件卸载时自动清理所有注册的事件监听器、effect 订阅和 cleanup 钩子。
|
|
736
|
+
*/
|
|
737
|
+
/** 渲染器接口(仅需 removeEventListener 方法) */
|
|
738
|
+
interface ResourceCleanupRenderer {
|
|
739
|
+
removeEventListener(el: unknown, event: string, handler: (...args: unknown[]) => void, options?: unknown): void;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* 注册组件事件监听器。
|
|
743
|
+
* 组件卸载时将自动调用 renderer.removeEventListener 移除该监听器。
|
|
744
|
+
*
|
|
745
|
+
* @param component - 组件实例(作为 WeakMap key)
|
|
746
|
+
* @param el - 事件目标元素
|
|
747
|
+
* @param event - 事件名称
|
|
748
|
+
* @param handler - 事件处理函数
|
|
749
|
+
* @param options - 可选的 addEventListener 选项
|
|
750
|
+
*/
|
|
751
|
+
declare function registerComponentEventListener(component: object, el: unknown, event: string, handler: (...args: unknown[]) => void, options?: unknown): void;
|
|
752
|
+
/**
|
|
753
|
+
* 注册 effect 订阅。
|
|
754
|
+
* 组件卸载时将自动调用 dispose 函数停止 effect。
|
|
755
|
+
*
|
|
756
|
+
* @param component - 组件实例(作为 WeakMap key)
|
|
757
|
+
* @param dispose - effect 的 dispose 回调函数
|
|
758
|
+
*/
|
|
759
|
+
declare function registerComponentEffectSubscription(component: object, dispose: () => void): void;
|
|
760
|
+
/**
|
|
761
|
+
* 注册通用 cleanup 钩子。
|
|
762
|
+
* 组件卸载时将按注册顺序执行该回调。
|
|
763
|
+
*
|
|
764
|
+
* @param component - 组件实例(作为 WeakMap key)
|
|
765
|
+
* @param cleanup - 清理回调函数
|
|
766
|
+
*/
|
|
767
|
+
declare function registerComponentCleanup(component: object, cleanup: () => void): void;
|
|
768
|
+
/**
|
|
769
|
+
* 统一清理组件所有注册资源。
|
|
770
|
+
*
|
|
771
|
+
* 清理顺序:
|
|
772
|
+
* 1. cleanup 钩子(可能依赖 effect 仍活跃)
|
|
773
|
+
* 2. effect 订阅(停止响应式追踪)
|
|
774
|
+
* 3. 事件监听器(DOM 操作,最后执行)
|
|
775
|
+
*
|
|
776
|
+
* 每个清理操作均通过 try-catch 保护,单个失败不影响其余流程。
|
|
777
|
+
*
|
|
778
|
+
* @param renderer - 渲染器实例,需提供 removeEventListener 方法
|
|
779
|
+
* @param component - 要清理资源的组件实例
|
|
780
|
+
*/
|
|
781
|
+
declare function cleanupComponentResources(renderer: ResourceCleanupRenderer, component: object): void;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* @lytjs/renderer - Shared utilities
|
|
785
|
+
*
|
|
786
|
+
* This module provides shared utility functions used across the renderer package,
|
|
787
|
+
* including HTML escaping, boolean attribute detection, and void element checks.
|
|
788
|
+
* It re-exports selected utilities from @lytjs/common-string for convenience.
|
|
789
|
+
*/
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Check if a tag is a void (self-closing) element
|
|
793
|
+
*/
|
|
794
|
+
declare function isVoidElement(tag: string): boolean;
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* 渲染器插件接口
|
|
798
|
+
* 插件可以挂载到渲染生命周期的各个阶段
|
|
799
|
+
*/
|
|
800
|
+
interface RendererPlugin {
|
|
801
|
+
/** 插件名称 */
|
|
802
|
+
name: string;
|
|
803
|
+
/** 插件安装时调用 */
|
|
804
|
+
install: (context: PluginContext) => void;
|
|
805
|
+
/** 可选:在 mount vnode 之前调用 */
|
|
806
|
+
beforeMount?: (vnode: VNode) => void;
|
|
807
|
+
/** 可选:在 mount vnode 之后调用 */
|
|
808
|
+
afterMount?: (vnode: VNode, container: unknown) => void;
|
|
809
|
+
/** 可选:在 patch vnode 之前调用 */
|
|
810
|
+
beforePatch?: (oldVNode: VNode, newVNode: VNode) => void;
|
|
811
|
+
/** 可选:在 patch vnode 之后调用 */
|
|
812
|
+
afterPatch?: (vnode: VNode) => void;
|
|
813
|
+
/** 可选:在 unmount vnode 之前调用 */
|
|
814
|
+
beforeUnmount?: (vnode: VNode) => void;
|
|
815
|
+
/** 可选:在 unmount vnode 之后调用 */
|
|
816
|
+
afterUnmount?: (vnode: VNode) => void;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* 插件安装时传递的上下文
|
|
820
|
+
*/
|
|
821
|
+
interface PluginContext {
|
|
822
|
+
/** 为特定的生命周期事件注册钩子 */
|
|
823
|
+
on: (event: LifecycleEvent, handler: HookHandler) => void;
|
|
824
|
+
/** 移除已注册的钩子 */
|
|
825
|
+
off: (event: LifecycleEvent, handler: HookHandler) => void;
|
|
826
|
+
}
|
|
827
|
+
/** 插件可以挂载的生命周期事件 */
|
|
828
|
+
type LifecycleEvent = 'beforeMount' | 'afterMount' | 'beforePatch' | 'afterPatch' | 'beforeUnmount' | 'afterUnmount';
|
|
829
|
+
/** 钩子处理函数类型 */
|
|
830
|
+
type HookHandler = (...args: unknown[]) => void;
|
|
831
|
+
/**
|
|
832
|
+
* 安装渲染器插件。
|
|
833
|
+
* 插件可以通过挂载生命周期事件来扩展渲染器的功能。
|
|
834
|
+
*
|
|
835
|
+
* @example
|
|
836
|
+
* ```ts
|
|
837
|
+
* // 创建插件
|
|
838
|
+
* const myPlugin: RendererPlugin = {
|
|
839
|
+
* name: 'MyPlugin',
|
|
840
|
+
* install(context) {
|
|
841
|
+
* context.on('beforeMount', (vnode) => {
|
|
842
|
+
* console.log('Before mount:', vnode);
|
|
843
|
+
* });
|
|
844
|
+
* },
|
|
845
|
+
* };
|
|
846
|
+
*
|
|
847
|
+
* // 使用插件
|
|
848
|
+
* use(myPlugin);
|
|
849
|
+
* ```
|
|
850
|
+
*/
|
|
851
|
+
declare function use(plugin: RendererPlugin): void;
|
|
852
|
+
/**
|
|
853
|
+
* 获取所有已安装的插件
|
|
854
|
+
*/
|
|
855
|
+
declare function getInstalledPlugins(): readonly RendererPlugin[];
|
|
856
|
+
/**
|
|
857
|
+
* 检查插件是否已安装
|
|
858
|
+
*/
|
|
859
|
+
declare function isPluginInstalled(pluginName: string): boolean;
|
|
860
|
+
/**
|
|
861
|
+
* 按名称移除插件
|
|
862
|
+
*/
|
|
863
|
+
declare function removePlugin(pluginName: string): boolean;
|
|
864
|
+
/**
|
|
865
|
+
* 内部:执行生命周期事件的钩子
|
|
866
|
+
* 由渲染器在适当的生命周期节点调用
|
|
867
|
+
* FIX: P2-29 数组遍历优化 - 使用 for 循环替代 forEach
|
|
868
|
+
*/
|
|
869
|
+
declare function executeHooks(event: LifecycleEvent, ...args: unknown[]): void;
|
|
870
|
+
|
|
871
|
+
/** Hydration 完善:全应用、选择性、错误恢复 */
|
|
872
|
+
declare function getEnhancedHydrationFunctions(): Promise<{
|
|
873
|
+
hydrateApp: typeof hydrateApp;
|
|
874
|
+
hydrateVisible: typeof hydrateVisible;
|
|
875
|
+
queueHydration: typeof queueHydration;
|
|
876
|
+
safeHydrate: typeof safeHydrate;
|
|
877
|
+
createHydrationErrorHandler: typeof createHydrationErrorHandler;
|
|
878
|
+
}>;
|
|
879
|
+
|
|
880
|
+
/** 将组件渲染为字符串(SSR) */
|
|
881
|
+
declare function renderToString(input: {
|
|
882
|
+
vnode: VNode;
|
|
883
|
+
}): Promise<string>;
|
|
884
|
+
|
|
885
|
+
/** 将 VNode 树流式渲染为 ReadableStream(SSR Streaming) */
|
|
886
|
+
declare function renderToStream(input: {
|
|
887
|
+
vnode: unknown;
|
|
888
|
+
}, options?: {
|
|
889
|
+
commentMarkers?: boolean;
|
|
890
|
+
}): Promise<ReadableStream>;
|
|
891
|
+
|
|
892
|
+
/** 优化的流式渲染 - TTFB 降低 50%+ */
|
|
893
|
+
declare function createOptimizedStream(vnode: unknown, options?: unknown): Promise<ReadableStream>;
|
|
894
|
+
declare function renderDocumentToStream(vnode: unknown, options?: unknown): Promise<ReadableStream>;
|
|
895
|
+
|
|
896
|
+
declare function hydrateIsland(el: Element, component: ComponentOptions, props?: Record<string, unknown>): Promise<void>;
|
|
897
|
+
declare function registerIslandComponent(name: string, component: ComponentOptions): Promise<void>;
|
|
898
|
+
declare function createIslandSSRContent(name: string, props?: Record<string, unknown>): Promise<string>;
|
|
899
|
+
|
|
900
|
+
/** 创建 Signal 模式渲染器(细粒度 DOM 更新) */
|
|
901
|
+
declare function createSignalRenderer(template?: string, context?: Record<string, unknown>): Promise<SignalRenderer>;
|
|
902
|
+
|
|
903
|
+
/** 创建 Vapor 模式渲染器(Signal 渲染器的别名) */
|
|
904
|
+
declare function createVaporRenderer(template?: string, context?: Record<string, unknown>): Promise<SignalRenderer>;
|
|
905
|
+
|
|
906
|
+
/** 定义 Vapor 模式组件 */
|
|
907
|
+
declare function defineVaporComponent(options: unknown): Promise<VaporComponentDefinition>;
|
|
908
|
+
declare function createVaporApp(rootComponent: unknown, props?: Record<string, unknown>): Promise<VaporApp>;
|
|
909
|
+
|
|
910
|
+
/** Vapor 模式 HMR 支持 */
|
|
911
|
+
declare function getVaporHMRFunctions(): Promise<{
|
|
912
|
+
generateComponentId: typeof generateComponentId;
|
|
913
|
+
registerComponent: typeof registerComponent;
|
|
914
|
+
unregisterComponent: typeof unregisterComponent;
|
|
915
|
+
handleComponentUpdate: typeof handleComponentUpdate;
|
|
916
|
+
createVaporHMRHandler: typeof createVaporHMRHandler;
|
|
917
|
+
isHMRAvailable: typeof isHMRAvailable;
|
|
918
|
+
forceRerender: typeof forceRerender;
|
|
919
|
+
clearHMRState: typeof clearHMRState;
|
|
920
|
+
onHMRUpdate: typeof onHMRUpdate;
|
|
921
|
+
}>;
|
|
922
|
+
|
|
923
|
+
/** Vapor 模式 SSR 支持 */
|
|
924
|
+
declare function renderVaporToString(component: unknown, props?: Record<string, unknown>, options?: unknown): Promise<VaporSSRResult>;
|
|
925
|
+
declare function renderVaporToStream(component: unknown, props?: Record<string, unknown>, options?: unknown): Promise<VaporSSRStreamResult>;
|
|
926
|
+
declare function hydrateVaporComponent(container: Element | string, component: unknown, options?: unknown): Promise<void>;
|
|
927
|
+
|
|
928
|
+
/** Server Components 服务端运行时 */
|
|
929
|
+
declare function getServerComponentFunctions(): Promise<{
|
|
930
|
+
registerServerComponent: typeof registerServerComponent;
|
|
931
|
+
registerServerFunction: typeof registerServerFunction;
|
|
932
|
+
getServerComponent: typeof getServerComponent;
|
|
933
|
+
getServerFunction: typeof getServerFunction;
|
|
934
|
+
handleServerAction: typeof handleServerAction;
|
|
935
|
+
createServerActionHandler: typeof createServerActionHandler;
|
|
936
|
+
serializeServerData: typeof serializeServerData;
|
|
937
|
+
deserializeServerData: typeof deserializeServerData;
|
|
938
|
+
renderServerComponent: typeof renderServerComponent;
|
|
939
|
+
defineServerComponent: typeof defineServerComponent;
|
|
940
|
+
}>;
|
|
941
|
+
|
|
942
|
+
/** Server Components 客户端运行时 */
|
|
943
|
+
declare function getServerComponentClientFunctions(): Promise<{
|
|
944
|
+
callServer: typeof callServer;
|
|
945
|
+
createServerFunction: typeof createServerFunction;
|
|
946
|
+
getServerData: typeof getServerData;
|
|
947
|
+
hasServerData: typeof hasServerData;
|
|
948
|
+
isHydrated: typeof isHydrated;
|
|
949
|
+
markHydrated: typeof markHydrated;
|
|
950
|
+
getHydrationState: typeof getHydrationState;
|
|
951
|
+
autoHydrate: typeof autoHydrate;
|
|
952
|
+
configureServerAction: typeof configureServerAction;
|
|
953
|
+
}>;
|
|
954
|
+
/** 数据获取集成 */
|
|
955
|
+
declare function getDataFetchingFunctions(): Promise<{
|
|
956
|
+
serializeData: typeof serializeData;
|
|
957
|
+
deserializeData: typeof deserializeData;
|
|
958
|
+
createPrefetchManager: typeof createPrefetchManager;
|
|
959
|
+
useFetch: typeof useFetch;
|
|
960
|
+
useAsyncData: typeof useAsyncData;
|
|
961
|
+
injectPrefetchData: typeof injectPrefetchData;
|
|
962
|
+
getPrefetchData: typeof getPrefetchData;
|
|
963
|
+
}>;
|
|
964
|
+
|
|
965
|
+
export { DEFAULT_STATE_PRESERVATION, type DataFetchOptions, type DataFetchState, type HMRStatePreservation, type HMRUpdate, type HMRUpdateType, type HookHandler, type HydrationError, HydrationErrorHandler, type HydrationMismatch, type HydrationMode, type HydrationOptions, type HydrationStats, type ComponentOptions as IslandComponentOptions, type LifecycleEvent, OptimizedSSRStream, type OptimizedStreamOptions, type RendererPlugin as Plugin, type PluginContext, type PrefetchDataEntry, type PrefetchManager, type PreloadHint, type RecoveryStrategy, type RendererPlugin, type ResourceCleanupRenderer, type SSRStreamOptions, type ServerActionRequest, type ServerActionResponse, type ServerComponentDefinition, type SignalRenderer, type StreamStats, VaporApp, VaporComponentDefinition, type VaporHydrationOptions, type SignalRenderer as VaporRenderer, type VaporSSROptions, type VaporSSRResult, type VaporSSRStreamResult, cleanupComponentResources, createIslandSSRContent, createOptimizedStream, createSignalRenderer, createVaporApp, createVaporRenderer, definePrefetch, defineVaporComponent, executeHooks, getDataFetchingFunctions, getEnhancedHydrationFunctions, getInstalledPlugins, getServerComponentClientFunctions, getServerComponentFunctions, getVaporHMRFunctions, hydrateIsland, hydrateVaporComponent, isPluginInstalled, isVoidElement, registerComponentCleanup, registerComponentEffectSubscription, registerComponentEventListener, registerIslandComponent, removePlugin, renderDocumentToStream, renderToStream, renderToString, renderVaporToStream, renderVaporToString, use, usePrefetchData };
|