@lytjs/core 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.
Files changed (3) hide show
  1. package/dist/index.d.cts +1556 -0
  2. package/dist/index.d.ts +1556 -0
  3. package/package.json +12 -12
@@ -0,0 +1,1556 @@
1
+ import { VNode, Fragment, Text, Comment, VNodeChildren } from '@lytjs/vdom';
2
+ export { Comment, Fragment, Text, VNode, VNodeChildren, cloneVNode, createVNode, mergeProps } from '@lytjs/vdom';
3
+ import { BaseAppConfig, Directive, DebuggerEvent, DirectiveArguments } from '@lytjs/shared-types';
4
+ export { DebuggerEvent, Directive, DirectiveArguments, DirectiveBinding, Renderer } from '@lytjs/shared-types';
5
+ import { ComponentPublicInstance, ComponentOptions, InternalSlots } from '@lytjs/component';
6
+ export { ComponentOptions, ComponentPublicInstance, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onUnmounted, onUpdated } from '@lytjs/component';
7
+ export { nextTick } from '@lytjs/common-scheduler';
8
+ import { WritableComputedRef, Ref } from '@lytjs/reactivity';
9
+ export { computed, effect, reactive, ref, watch, watchEffect } from '@lytjs/reactivity';
10
+ export { compile } from '@lytjs/compiler';
11
+
12
+ /**
13
+ * 配置 Schema 类型
14
+ * @description JSON Schema 风格的结构化配置验证
15
+ */
16
+ /** Schema 类型枚举 */
17
+ type SchemaType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'enum' | 'union';
18
+ /** JSON Schema 风格的配置 Schema */
19
+ interface ConfigSchema<T = unknown> {
20
+ /** Schema 类型 */
21
+ type: SchemaType;
22
+ /** 字段描述(用于文档生成) */
23
+ description?: string;
24
+ /** 默认值 */
25
+ default?: T;
26
+ /** 是否必填 */
27
+ required?: boolean;
28
+ /** 是否可为空 */
29
+ nullable?: boolean;
30
+ /** 字符串验证 */
31
+ string?: StringSchema;
32
+ /** 数字验证 */
33
+ number?: NumberSchema;
34
+ /** 布尔验证 */
35
+ boolean?: BooleanSchema;
36
+ /** 对象验证 */
37
+ object?: ObjectSchema<T>;
38
+ /** 数组验证 */
39
+ array?: ArraySchema;
40
+ /** 枚举验证 */
41
+ enum?: EnumSchema<T>;
42
+ /** 联合类型验证 */
43
+ union?: UnionSchema;
44
+ /** 自定义验证函数 */
45
+ validate?: (value: T, context: ValidationContext$1) => ValidationResult;
46
+ /** 转换函数(用于预处理用户输入) */
47
+ transform?: (value: unknown) => T;
48
+ }
49
+ /** 字符串 Schema */
50
+ interface StringSchema {
51
+ /** 最小长度 */
52
+ minLength?: number;
53
+ /** 最大长度 */
54
+ maxLength?: number;
55
+ /** 正则表达式模式 */
56
+ pattern?: string | RegExp;
57
+ /** 格式校验 */
58
+ format?: StringFormat;
59
+ /** 枚举值 */
60
+ enum?: string[];
61
+ }
62
+ /** 字符串格式 */
63
+ type StringFormat = 'date' | 'time' | 'date-time' | 'email' | 'url' | 'uri' | 'uuid' | 'semver';
64
+ /** 数字 Schema */
65
+ interface NumberSchema {
66
+ /** 最小值 */
67
+ minimum?: number;
68
+ /** 最大值 */
69
+ maximum?: number;
70
+ /** 排除最小值 */
71
+ exclusiveMinimum?: number;
72
+ /** 排除最大值 */
73
+ exclusiveMaximum?: number;
74
+ /** 必须为整数 */
75
+ integer?: boolean;
76
+ /** 枚举值 */
77
+ enum?: number[];
78
+ }
79
+ /** 布尔 Schema */
80
+ interface BooleanSchema {
81
+ /** 默认值时的说明 */
82
+ defaultDescription?: string;
83
+ }
84
+ /** 对象 Schema */
85
+ interface ObjectSchema<T = unknown> {
86
+ /** 属性定义 */
87
+ properties: Record<string, ConfigSchema>;
88
+ /** 必需属性 */
89
+ required?: string[];
90
+ /** 额外属性是否允许 */
91
+ additionalProperties?: boolean;
92
+ /** 属性名模式 */
93
+ patternProperties?: Record<string, ConfigSchema>;
94
+ /** 最大属性数 */
95
+ maxProperties?: number;
96
+ /** 最小属性数 */
97
+ minProperties?: number;
98
+ /** 对象级别验证 */
99
+ validate?: (obj: T, context: ValidationContext$1) => ValidationResult;
100
+ }
101
+ /** 数组 Schema */
102
+ interface ArraySchema {
103
+ /** 元素类型 */
104
+ items?: ConfigSchema;
105
+ /** 元组类型(固定长度) */
106
+ tuple?: ConfigSchema[];
107
+ /** 最少元素数 */
108
+ minItems?: number;
109
+ /** 最多元素数 */
110
+ maxItems?: number;
111
+ /** 是否允许重复 */
112
+ uniqueItems?: boolean;
113
+ }
114
+ /** 枚举 Schema */
115
+ interface EnumSchema<T = unknown> {
116
+ /** 允许的值 */
117
+ values: T[];
118
+ /** 默认值 */
119
+ default?: T;
120
+ }
121
+ /** 联合类型 Schema */
122
+ interface UnionSchema {
123
+ /** 可选的类型 */
124
+ anyOf: ConfigSchema[];
125
+ /** 精确匹配类型 */
126
+ oneOf?: ConfigSchema[];
127
+ /** 不允许的类型 */
128
+ not?: ConfigSchema;
129
+ }
130
+ /** 验证上下文 */
131
+ interface ValidationContext$1 {
132
+ /** 当前路径(用于错误报告) */
133
+ path: string;
134
+ /** 根对象 */
135
+ root: unknown;
136
+ /** 自定义数据 */
137
+ data?: Record<string, unknown>;
138
+ }
139
+ /** 验证结果 */
140
+ interface ValidationResult {
141
+ /** 是否有效 */
142
+ valid: boolean;
143
+ /** 错误信息 */
144
+ message?: string;
145
+ /** 错误路径 */
146
+ path?: string;
147
+ }
148
+ /** 验证错误 */
149
+ interface ConfigValidationError {
150
+ /** 错误路径 */
151
+ path: string;
152
+ /** 错误消息 */
153
+ message: string;
154
+ /** 期望的值类型 */
155
+ expected?: string;
156
+ /** 实际的值 */
157
+ actual?: unknown;
158
+ /** 错误代码 */
159
+ code: ValidationErrorCode;
160
+ }
161
+ /** 验证错误代码 */
162
+ type ValidationErrorCode = 'type_error' | 'required' | 'enum_mismatch' | 'pattern_mismatch' | 'format_error' | 'min_length' | 'max_length' | 'minimum' | 'maximum' | 'min_items' | 'max_items' | 'unique_items' | 'additional_properties' | 'custom_error';
163
+ /** 配置验证报告 */
164
+ interface ConfigValidationReport {
165
+ /** 是否有效 */
166
+ valid: boolean;
167
+ /** 错误列表 */
168
+ errors: ConfigValidationError[];
169
+ /** 错误数量 */
170
+ errorCount: number;
171
+ /** 警告数量 */
172
+ warningCount: number;
173
+ }
174
+ /** 配置转换报告 */
175
+ interface ConfigTransformReport<T = unknown> {
176
+ /** 转换后的配置 */
177
+ config: T;
178
+ /** 是否成功 */
179
+ success: boolean;
180
+ /** 错误列表 */
181
+ errors: ConfigValidationError[];
182
+ /** 警告列表 */
183
+ warnings: string[];
184
+ /** 应用的转换 */
185
+ transforms: string[];
186
+ }
187
+
188
+ /**
189
+ * 插件注册表
190
+ * @description 管理插件的注册、注销、查询和依赖关系
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * const registry = new PluginRegistry();
195
+ *
196
+ * // 注册插件
197
+ * registry.register(myPlugin, { theme: 'dark' });
198
+ *
199
+ * // 查询插件
200
+ * const plugin = registry.get('my-plugin');
201
+ *
202
+ * // 检查依赖
203
+ * const result = registry.checkDependencies(anotherPlugin);
204
+ *
205
+ * // 监听事件
206
+ * registry.on('after:install', (event, data) => {
207
+ * console.log(`Plugin ${data.name} installed`);
208
+ * });
209
+ * ```
210
+ */
211
+ declare class PluginRegistry {
212
+ /** 已注册插件映射(name → RegisteredPlugin) */
213
+ private plugins;
214
+ /** 事件监听器映射 */
215
+ private listeners;
216
+ constructor();
217
+ /**
218
+ * 注册插件
219
+ * @param plugin - 插件实例(EnhancedPlugin 或基础 Plugin)
220
+ * @param options - 安装选项
221
+ * @returns 注册结果
222
+ */
223
+ register(plugin: EnhancedPlugin | Plugin, options?: unknown): RegistrationResult;
224
+ /**
225
+ * 注销插件
226
+ * @param name - 插件名称
227
+ * @returns 是否成功注销
228
+ */
229
+ unregister(name: string): boolean;
230
+ /**
231
+ * 获取已注册插件信息
232
+ * @param name - 插件名称
233
+ * @returns 插件注册信息,如果未找到则返回 undefined
234
+ */
235
+ get(name: string): RegisteredPlugin | undefined;
236
+ /**
237
+ * 获取已注册的插件实例
238
+ * @param name - 插件名称
239
+ * @returns 插件实例,如果未找到则返回 undefined
240
+ */
241
+ getPlugin(name: string): EnhancedPlugin | undefined;
242
+ /**
243
+ * 检查插件是否已注册
244
+ * @param name - 插件名称
245
+ */
246
+ has(name: string): boolean;
247
+ /**
248
+ * 获取所有已注册插件名称
249
+ */
250
+ getNames(): string[];
251
+ /**
252
+ * 获取所有已注册插件信息
253
+ */
254
+ getAll(): RegisteredPlugin[];
255
+ /**
256
+ * 获取已安装插件列表
257
+ */
258
+ getInstalled(): RegisteredPlugin[];
259
+ /**
260
+ * 标记插件为已安装
261
+ * @param name - 插件名称
262
+ */
263
+ markInstalled(name: string): void;
264
+ /**
265
+ * 标记插件为未安装
266
+ * @param name - 插件名称
267
+ */
268
+ markUninstalled(name: string): void;
269
+ /**
270
+ * 检查插件依赖是否满足
271
+ * @param plugin - 要检查的插件
272
+ * @returns 依赖检查结果
273
+ */
274
+ checkDependencies(plugin: EnhancedPlugin | Plugin): DependencyResult;
275
+ /**
276
+ * 解析插件加载顺序(拓扑排序)
277
+ * @description 根据依赖关系计算正确的安装顺序
278
+ * @returns 排序后的插件列表
279
+ * @throws 如果存在循环依赖则抛出错误
280
+ */
281
+ resolveLoadOrder(): EnhancedPlugin[];
282
+ /**
283
+ * 获取插件数量
284
+ */
285
+ get size(): number;
286
+ /**
287
+ * 清空所有已注册插件
288
+ */
289
+ clear(): void;
290
+ /**
291
+ * 注册事件监听器
292
+ * @param event - 事件类型
293
+ * @param handler - 事件处理函数
294
+ * @returns 取消监听的函数
295
+ */
296
+ on(event: PluginLifecycleEvent, handler: PluginEventListener): () => void;
297
+ /**
298
+ * 触发事件
299
+ * @param event - 事件类型
300
+ * @param data - 事件数据
301
+ */
302
+ emit(event: PluginLifecycleEvent, data: unknown): void;
303
+ /**
304
+ * 移除事件监听器
305
+ * @param event - 事件类型
306
+ * @param handler - 事件处理函数
307
+ */
308
+ off(event: PluginLifecycleEvent, handler: PluginEventListener): void;
309
+ /**
310
+ * 获取插件名称
311
+ */
312
+ private getPluginName;
313
+ /**
314
+ * 检查是否为 EnhancedPlugin
315
+ */
316
+ private isEnhancedPlugin;
317
+ /**
318
+ * 将基础 Plugin 标准化为 EnhancedPlugin
319
+ */
320
+ private normalizePlugin;
321
+ /**
322
+ * 检查插件冲突
323
+ */
324
+ private checkConflicts;
325
+ /**
326
+ * 简单的 semver 版本比较
327
+ * @description 支持 ^, ~, >=, >, <, <=, = 前缀
328
+ */
329
+ private satisfiesVersion;
330
+ /**
331
+ * 解析版本号字符串
332
+ */
333
+ private parseVersion;
334
+ /**
335
+ * 比较两个版本号
336
+ * @returns 正数表示 a > b,负数表示 a < b,0 表示相等
337
+ */
338
+ private compareVersions;
339
+ }
340
+
341
+ /**
342
+ * 验证报告中的单个问题
343
+ */
344
+ interface ValidationIssue {
345
+ /** 问题级别 */
346
+ level: 'error' | 'warning' | 'info';
347
+ /** 问题规则名称 */
348
+ rule: string;
349
+ /** 问题描述 */
350
+ message: string;
351
+ }
352
+ /**
353
+ * 插件验证报告
354
+ * @description 包含验证结果和所有发现的问题
355
+ */
356
+ interface ValidationReport {
357
+ /** 是否通过验证(无 error 级别问题) */
358
+ valid: boolean;
359
+ /** 插件名称 */
360
+ pluginName: string;
361
+ /** 所有验证问题 */
362
+ issues: ValidationIssue[];
363
+ /** 错误数量 */
364
+ errorCount: number;
365
+ /** 警告数量 */
366
+ warningCount: number;
367
+ /** 信息数量 */
368
+ infoCount: number;
369
+ }
370
+ /**
371
+ * 验证规则函数类型
372
+ */
373
+ type ValidationRule = (plugin: EnhancedPlugin | Plugin, context: ValidationContext) => ValidationIssue[];
374
+ /**
375
+ * 验证上下文
376
+ */
377
+ interface ValidationContext {
378
+ /** 已知插件名称列表(用于循环依赖检测) */
379
+ knownPlugins: Set<string>;
380
+ }
381
+ /**
382
+ * 插件验证器
383
+ * @description 对插件进行结构和配置验证,确保插件符合规范
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * const validator = new PluginValidator();
388
+ *
389
+ * // 验证单个插件
390
+ * const report = validator.validate(myPlugin);
391
+ * if (!report.valid) {
392
+ * console.error('Plugin validation failed:', report.issues);
393
+ * }
394
+ *
395
+ * // 批量验证
396
+ * const reports = validator.validateAll([plugin1, plugin2, plugin3]);
397
+ * ```
398
+ */
399
+ declare class PluginValidator {
400
+ /** 内置验证规则列表 */
401
+ private rules;
402
+ /** 已知插件名称集合(用于跨插件验证) */
403
+ private knownPlugins;
404
+ constructor();
405
+ /**
406
+ * 验证插件
407
+ * @param plugin - 要验证的插件
408
+ * @returns 验证报告
409
+ */
410
+ validate(plugin: EnhancedPlugin | Plugin): ValidationReport;
411
+ /**
412
+ * 批量验证多个插件
413
+ * @param plugins - 要验证的插件列表
414
+ * @returns 验证报告列表
415
+ */
416
+ validateAll(plugins: (EnhancedPlugin | Plugin)[]): ValidationReport[];
417
+ /**
418
+ * 注册已知插件名称(用于跨插件验证)
419
+ * @param names - 插件名称列表
420
+ */
421
+ registerKnownPlugins(names: string[]): void;
422
+ /**
423
+ * 添加自定义验证规则
424
+ * @param rule - 验证规则函数
425
+ */
426
+ addRule(rule: ValidationRule): void;
427
+ /**
428
+ * 移除验证规则
429
+ * @param rule - 要移除的验证规则函数
430
+ */
431
+ removeRule(rule: ValidationRule): void;
432
+ /**
433
+ * 规则:验证插件基本结构
434
+ * @description 确保插件有 install 方法
435
+ */
436
+ private validateStructure;
437
+ /**
438
+ * 规则:验证插件名称
439
+ * @description 确保名称有效且不冲突
440
+ */
441
+ private validateName;
442
+ /**
443
+ * 规则:验证版本号格式
444
+ * @description 确保版本号符合 semver 格式
445
+ */
446
+ private validateVersion;
447
+ /**
448
+ * 规则:验证依赖声明
449
+ * @description 检查依赖格式和已知性
450
+ */
451
+ private validateDependencies;
452
+ /**
453
+ * 验证依赖数组
454
+ */
455
+ private validateDependencyArray;
456
+ /**
457
+ * 规则:验证冲突声明
458
+ * @description 检查冲突列表格式
459
+ */
460
+ private validateConflicts;
461
+ /**
462
+ * 规则:验证 peerRequirements
463
+ * @description 检查宿主框架版本要求格式
464
+ */
465
+ private validatePeerRequirements;
466
+ /**
467
+ * 规则:验证生命周期钩子
468
+ * @description 确保生命周期钩子是函数
469
+ */
470
+ private validateLifecycleHooks;
471
+ /**
472
+ * 获取插件名称
473
+ */
474
+ private getPluginName;
475
+ /**
476
+ * 检查是否为 EnhancedPlugin
477
+ */
478
+ private isEnhancedPlugin;
479
+ }
480
+
481
+ interface App<HostElement = Element> {
482
+ config: AppConfig;
483
+ use(plugin: Plugin | PluginInstallFunction, ...options: unknown[]): App;
484
+ mount(rootContainer: HostElement | string): Promise<ComponentPublicInstance | null>;
485
+ unmount(): void;
486
+ provide<T = unknown>(key: string | symbol, value: T): App;
487
+ inject<T = unknown>(key: string | symbol): T | undefined;
488
+ component(name: string, component: Component): App;
489
+ directive(name: string, directive: Directive): App;
490
+ mixin(mixin: ComponentOptions): App;
491
+ /** 注册全局事件监听器,将在卸载时自动清理。 */
492
+ on(target: EventTarget, event: string, handler: EventListener, options?: AddEventListenerOptions): App;
493
+ /** 移除之前注册的全局事件监听器。 */
494
+ off(target: EventTarget, event: string, handler: EventListener, options?: AddEventListenerOptions): App;
495
+ /** 获取插件注册表实例(内部 API,用于高级插件管理) */
496
+ readonly _pluginRegistry: PluginRegistry;
497
+ /** 获取插件验证器实例(内部 API,用于自定义验证) */
498
+ readonly _pluginValidator: PluginValidator;
499
+ errorHandler?: (err: unknown, instance: ComponentPublicInstance | null, info: string) => void;
500
+ warnHandler?: (msg: string, instance: ComponentPublicInstance | null, trace: string) => void;
501
+ }
502
+ interface AppConfig extends BaseAppConfig {
503
+ performance: boolean;
504
+ globalProperties: Record<string, unknown>;
505
+ isCustomElement?: (tag: string) => boolean;
506
+ compilerOptions?: Record<string, unknown>;
507
+ }
508
+ /** createApp 的配置选项 */
509
+ interface AppOptions {
510
+ /** 渲染模式:'vnode' 使用 VNode diff(默认),'signal' 使用 Signal + 直接 DOM 操作,'vapor' 是 'signal' 的别名 */
511
+ rendererMode?: 'vnode' | 'signal' | 'vapor';
512
+ }
513
+ /** 插件安装函数签名(支持泛型选项) */
514
+ type PluginInstallFunction<T = unknown> = (app: App, ...options: T[]) => void | Promise<void>;
515
+ /**
516
+ * 基础插件接口
517
+ * @description 所有 LytJS 插件必须实现此接口
518
+ */
519
+ interface Plugin<TOptions = unknown> {
520
+ /** 插件安装函数 */
521
+ install: PluginInstallFunction<TOptions>;
522
+ }
523
+ /**
524
+ * 插件元数据信息
525
+ * @description 描述插件的附加信息,用于文档生成和插件市场展示
526
+ */
527
+ interface PluginMeta {
528
+ /** 插件描述 */
529
+ description?: string;
530
+ /** 插件作者 */
531
+ author?: string;
532
+ /** 关键词标签 */
533
+ keywords?: string[];
534
+ /** 插件主页 */
535
+ homepage?: string;
536
+ /** 许可证 */
537
+ license?: string;
538
+ /** 仓库地址 */
539
+ repository?: string;
540
+ }
541
+ /**
542
+ * 插件依赖声明
543
+ * @description 声明插件对其他插件或框架版本的依赖关系
544
+ */
545
+ interface PluginDependency {
546
+ /** 依赖的插件名称 */
547
+ name: string;
548
+ /** 版本范围要求(semver 格式) */
549
+ version?: string;
550
+ /** 是否为可选依赖 */
551
+ optional?: boolean;
552
+ }
553
+ /**
554
+ * 增强版插件接口(v6.0 Plugin System Enhancement)
555
+ * @description 包含名称、版本、元数据、生命周期钩子和依赖管理
556
+ */
557
+ interface EnhancedPlugin<TOptions = unknown> extends Plugin<TOptions> {
558
+ /** 插件唯一标识名称(必填) */
559
+ name: string;
560
+ /** 插件版本号(semver 格式) */
561
+ version?: string;
562
+ /** 插件元数据 */
563
+ meta?: PluginMeta;
564
+ /** 依赖的其他插件 */
565
+ dependencies?: PluginDependency[];
566
+ /** 可选依赖的插件 */
567
+ optionalDependencies?: PluginDependency[];
568
+ /** 冲突的插件名称列表 */
569
+ conflicts?: string[];
570
+ /** 对宿主框架的版本要求 */
571
+ peerRequirements?: {
572
+ lytjs?: string;
573
+ node?: string;
574
+ };
575
+ /** 插件选项的 Schema 定义,用于验证和文档生成 */
576
+ configSchema?: ConfigSchema<TOptions>;
577
+ /** 安装前钩子,返回 false 可取消安装 */
578
+ beforeInstall?: (app: App) => boolean | Promise<boolean>;
579
+ /** 安装后钩子 */
580
+ afterInstall?: (app: App) => void | Promise<void>;
581
+ /** 应用挂载前钩子 */
582
+ beforeMount?: (app: App) => void | Promise<void>;
583
+ /** 应用挂载后钩子 */
584
+ afterMount?: (app: App) => void | Promise<void>;
585
+ /** 清理函数,在 app 卸载时调用 */
586
+ cleanup?: () => void | Promise<void>;
587
+ }
588
+ /**
589
+ * 支持 cleanup 的插件接口(向后兼容)
590
+ * FIX: P2-40 定义 PluginWithCleanup 接口,替代类型断言链
591
+ * @deprecated 推荐使用 EnhancedPlugin 替代
592
+ */
593
+ interface PluginWithCleanup extends Plugin {
594
+ /** 插件清理函数,在 app 卸载时调用 */
595
+ cleanup?: () => void;
596
+ /** 插件名称,用于错误报告 */
597
+ name?: string;
598
+ }
599
+ /** 插件函数类型(支持 cleanup) */
600
+ type PluginFunctionWithCleanup = PluginInstallFunction & {
601
+ cleanup?: () => void;
602
+ name?: string;
603
+ };
604
+ /** 已注册插件的信息 */
605
+ interface RegisteredPlugin {
606
+ /** 插件实例 */
607
+ plugin: EnhancedPlugin;
608
+ /** 安装时传入的选项 */
609
+ options: unknown;
610
+ /** 是否已安装 */
611
+ installed: boolean;
612
+ /** 注册时间戳 */
613
+ registeredAt: number;
614
+ /** 安装时间戳 */
615
+ installedAt?: number;
616
+ }
617
+ /** 插件注册结果 */
618
+ interface RegistrationResult {
619
+ /** 是否成功 */
620
+ success: boolean;
621
+ /** 插件名称 */
622
+ name: string;
623
+ /** 错误信息(如果失败) */
624
+ error?: string;
625
+ }
626
+ /** 依赖检查结果 */
627
+ interface DependencyResult {
628
+ /** 是否满足所有依赖 */
629
+ satisfied: boolean;
630
+ /** 缺少的必需依赖 */
631
+ missing: Array<{
632
+ name: string;
633
+ version?: string;
634
+ }>;
635
+ /** 缺少的可选依赖 */
636
+ missingOptional: Array<{
637
+ name: string;
638
+ version?: string;
639
+ }>;
640
+ /** 版本不兼容的依赖 */
641
+ versionMismatch: Array<{
642
+ name: string;
643
+ expected: string;
644
+ actual?: string;
645
+ }>;
646
+ }
647
+ /** 插件生命周期事件类型 */
648
+ type PluginLifecycleEvent = 'before:register' | 'after:register' | 'before:install' | 'after:install' | 'before:unregister' | 'after:unregister' | 'error';
649
+ /** 插件事件监听器 */
650
+ type PluginEventListener = (event: PluginLifecycleEvent, data: unknown) => void;
651
+ type Component = ComponentOptions | (() => VNode);
652
+
653
+ type AsyncComponentLoader = () => Promise<Component>;
654
+ interface AsyncComponentOptions {
655
+ loader: AsyncComponentLoader;
656
+ loadingComponent?: Component;
657
+ errorComponent?: Component;
658
+ delay?: number;
659
+ timeout?: number;
660
+ suspensible?: boolean;
661
+ onError?: (error: Error, retry: () => void, fail: () => void, attempts: number) => void;
662
+ }
663
+
664
+ type ErrorCapturedHook = (err: Error, instance: ComponentPublicInstance | null, info: string) => boolean | void;
665
+ type DebuggerHook = (event: DebuggerEvent) => void;
666
+
667
+ declare function createApp(rootComponent: Component, rootProps?: Record<string, unknown> | null, options?: AppOptions): App;
668
+
669
+ declare function h(type: string): VNode;
670
+ declare function h(type: Component): VNode;
671
+ declare function h(type: typeof Fragment): VNode;
672
+ declare function h(type: typeof Text): VNode;
673
+ declare function h(type: typeof Comment): VNode;
674
+ declare function h<P = Record<string, unknown>>(type: string, props: P | null): VNode;
675
+ declare function h<P = Record<string, unknown>>(type: Component, props: P | null): VNode;
676
+ declare function h(type: typeof Fragment, props: Record<string, unknown> | null): VNode;
677
+ declare function h(type: typeof Text, props: Record<string, unknown> | null): VNode;
678
+ declare function h(type: typeof Comment, props: Record<string, unknown> | null): VNode;
679
+ declare function h<P = Record<string, unknown>>(type: string, props: P | null, ...children: VNodeChildren[]): VNode;
680
+ declare function h<P = Record<string, unknown>>(type: Component, props: P | null, ...children: VNodeChildren[]): VNode;
681
+ declare function h(type: typeof Fragment, props: Record<string, unknown> | null, ...children: VNodeChildren[]): VNode;
682
+ declare function h(type: typeof Text, props: Record<string, unknown> | null, ...children: VNodeChildren[]): VNode;
683
+ declare function h(type: typeof Comment, props: Record<string, unknown> | null, ...children: VNodeChildren[]): VNode;
684
+
685
+ /**
686
+ * 定义组件(re-export from @lytjs/component)
687
+ *
688
+ * 权威实现在 @lytjs/component 中,此处统一返回类型为 ComponentOptions。
689
+ * 由于 Component = ComponentOptions | (() => any),
690
+ * 返回 ComponentOptions 是 Component 的子集,完全兼容。
691
+ */
692
+ declare const defineComponent: (options: ComponentOptions) => ComponentOptions;
693
+ /**
694
+ * 定义异步组件
695
+ */
696
+ declare function defineAsyncComponent(source: AsyncComponentLoader | AsyncComponentOptions): Component;
697
+
698
+ /**
699
+ * 解析组件:从当前组件实例的 components 选项和全局注册中查找
700
+ */
701
+ declare function resolveComponent(name: string): Component | undefined;
702
+ /**
703
+ * 解析指令:从当前组件实例的 directives 选项和全局注册中查找
704
+ */
705
+ declare function resolveDirective(name: string): Directive | undefined;
706
+ /**
707
+ * 解析动态组件:
708
+ * - 如果 tag 是字符串,尝试从 appContext.components 中解析已注册组件,
709
+ * 如果找不到则返回原始字符串(可能是原生 HTML 元素)
710
+ * - 如果 tag 已经是组件对象,直接返回
711
+ */
712
+ declare function resolveDynamicComponent(tag: string | Component): Component | string;
713
+
714
+ declare function withDirectives(vnode: VNode, directives: DirectiveArguments): VNode;
715
+ /** Memo 缓存条目 */
716
+ interface MemoEntry {
717
+ memo: unknown[];
718
+ result: VNode;
719
+ }
720
+ /**
721
+ * 带缓存的渲染辅助
722
+ */
723
+ declare function withMemo(memo: unknown[], render: () => VNode, cache: MemoEntry[], index: number): VNode;
724
+
725
+ /**
726
+ * 获取当前组件的 slots
727
+ * FIX: P2-37 useSlots 类型安全增强:
728
+ * 返回的 InternalSlots 类型确保 slot 函数的参数和返回值类型正确
729
+ */
730
+ declare function useSlots(): InternalSlots;
731
+ /**
732
+ * 获取当前组件的 attrs
733
+ */
734
+ declare function useAttrs(): Record<string, unknown>;
735
+ /**
736
+ * 双向绑定辅助(v-model 的 composition API 版本)
737
+ */
738
+ declare function useModel<T>(props: Record<string, T | undefined>, key: string): WritableComputedRef<T>;
739
+ /**
740
+ * defineModel 运行时实现。
741
+ * Vue 3.4+ 新增的编译器宏,在 lytjs 中以运行时函数形式提供。
742
+ *
743
+ * 用法:
744
+ * const modelValue = defineModel() // 默认 'modelValue'
745
+ * const title = defineModel('title') // 命名 model
746
+ * const count = defineModel('count', { default: 0 }) // 带默认值
747
+ *
748
+ * 返回一个 WritableComputedRef,读取时返回 prop 值,写入时触发 update 事件。
749
+ */
750
+ declare function defineModel<T = unknown>(name?: string, options?: {
751
+ default?: T;
752
+ required?: boolean;
753
+ type?: unknown;
754
+ transform?: (value: T) => T;
755
+ }): WritableComputedRef<T>;
756
+ /**
757
+ * 获取模板引用的 ref。
758
+ * 通过 key 从组件实例的 refs 中获取对应的 DOM 元素或组件实例。
759
+ * 使用 watch 持续追踪 refs 变化,确保响应式同步。
760
+ * Vue 3.5+ 新增组合式 API。
761
+ */
762
+ declare function useTemplateRef<T = unknown>(key: string): Ref<T | null>;
763
+ /**
764
+ * 生成应用范围内唯一的 ID。
765
+ * Vue 3.5 新增的组合式 API,用于生成可预测的唯一标识符,
766
+ * 特别适用于无障碍属性(aria-*)和表单元素关联。
767
+ *
768
+ * 每个组件实例会获得一个基于组件 uid 的 ID 前缀,
769
+ * 确保同一组件在不同位置渲染时产生不同的 ID。
770
+ *
771
+ * FIX: P2-38 使用高熵随机数替代全局计数器,防止多实例/多窗口场景下的 ID 冲突
772
+ */
773
+ declare function useId(): Readonly<Ref<string>>;
774
+ /**
775
+ * 获取单文件组件中 CSS Modules 的类名映射。
776
+ * 在 SFC 中,`<style module>` 块会被编译为 CSS Modules,
777
+ * useCssModule 返回一个包含局部类名到全局类名映射的对象。
778
+ *
779
+ * @param name - CSS Modules 的名称,默认为 '$style'
780
+ */
781
+ declare function useCssModule(name?: string): Record<string, string>;
782
+ /**
783
+ * 在组件实例上设置 CSS 自定义属性(CSS Variables)。
784
+ * 提供响应式的方式来管理 CSS 变量。
785
+ *
786
+ * @param vars - 一个函数,返回包含 CSS 变量键值对的对象
787
+ *
788
+ * 用法:
789
+ * useCssVars(() => ({
790
+ * color: themeColor.value,
791
+ * fontSize: size.value + 'px',
792
+ * }))
793
+ */
794
+ declare function useCssVars(vars: () => Record<string, string>): void;
795
+
796
+ /**
797
+ * defineCustomElement 的配置选项
798
+ */
799
+ interface DefineCustomElementOptions {
800
+ /** 是否使用 Shadow DOM(默认 true) */
801
+ shadowRoot?: boolean;
802
+ /** Custom Element 标签名(默认使用组件 name) */
803
+ name?: string;
804
+ /** CSS 样式(注入到 Shadow DOM) */
805
+ css?: string;
806
+ }
807
+ /**
808
+ * 将 LytJS 组件包装为 Custom Element
809
+ */
810
+ declare function defineCustomElement(componentOptions: ComponentOptions, options?: DefineCustomElementOptions): CustomElementConstructor;
811
+ /**
812
+ * 在 setup 中获取当前 Custom Element 的 Shadow Root
813
+ */
814
+ declare function useShadowRoot(): ShadowRoot | null;
815
+ /**
816
+ * 在 setup 中获取当前 Custom Element 的宿主元素
817
+ */
818
+ declare function useHost(): HTMLElement | null;
819
+ /**
820
+ * 在 setup 中获取 slot 变化通知(MutationObserver)
821
+ * 返回一个注册回调的函数
822
+ */
823
+ declare function useWebComponentSlots(onChange: () => void): void;
824
+ /**
825
+ * 向 Shadow DOM 注入样式
826
+ */
827
+ declare function injectChildStyles(styles: string): void;
828
+
829
+ /**
830
+ * 配置验证器
831
+ * @description 根据 ConfigSchema 验证配置值
832
+ */
833
+ declare class ConfigValidator {
834
+ /** 自定义验证规则 */
835
+ private rules;
836
+ /**
837
+ * 验证配置值
838
+ * @param value - 要验证的值
839
+ * @param schema - 配置 Schema
840
+ * @param path - 当前路径(用于错误报告)
841
+ * @returns 验证报告
842
+ */
843
+ validate(value: unknown, schema: ConfigSchema, path?: string): ConfigValidationReport;
844
+ /**
845
+ * 验证字符串值
846
+ */
847
+ private validateString;
848
+ /**
849
+ * 验证数字值
850
+ */
851
+ private validateNumber;
852
+ /**
853
+ * 验证布尔值
854
+ */
855
+ private validateBoolean;
856
+ /**
857
+ * 验证对象值
858
+ */
859
+ private validateObject;
860
+ /**
861
+ * 验证数组值
862
+ */
863
+ private validateArray;
864
+ /**
865
+ * 验证枚举值
866
+ */
867
+ private validateEnum;
868
+ /**
869
+ * 验证联合类型
870
+ */
871
+ private validateUnion;
872
+ /**
873
+ * 验证字符串格式
874
+ */
875
+ private validateFormat;
876
+ /**
877
+ * 创建验证错误
878
+ */
879
+ private createError;
880
+ /**
881
+ * 添加自定义验证规则
882
+ */
883
+ addRule(rule: (value: unknown, schema: ConfigSchema, context: ValidationContext$1) => ConfigValidationError | null): void;
884
+ /**
885
+ * 移除自定义验证规则
886
+ */
887
+ removeRule(rule: (value: unknown, schema: ConfigSchema, context: ValidationContext$1) => ConfigValidationError | null): void;
888
+ private isStringType;
889
+ }
890
+ /**
891
+ * 快速验证配置
892
+ */
893
+ declare function validateConfig<T>(value: unknown, schema: ConfigSchema<T>): ConfigValidationReport;
894
+
895
+ /**
896
+ * 配置转换器
897
+ * @description 负责应用默认值、类型转换和预处理
898
+ */
899
+ declare class ConfigTransformer {
900
+ private validator;
901
+ constructor();
902
+ /**
903
+ * 转换并验证配置
904
+ * @param value - 原始配置值
905
+ * @param schema - 配置 Schema
906
+ * @param path - 当前路径
907
+ * @returns 转换报告
908
+ */
909
+ transform<T>(value: unknown, schema: ConfigSchema<T>, path?: string): ConfigTransformReport<T>;
910
+ /**
911
+ * 转换对象配置
912
+ */
913
+ private transformObject;
914
+ /**
915
+ * 转换数组配置
916
+ */
917
+ private transformArray;
918
+ /**
919
+ * 合并多个配置(用户配置覆盖默认配置)
920
+ * @param defaults - 默认配置
921
+ * @param overrides - 用户配置
922
+ * @param schema - 配置 Schema
923
+ * @returns 合并后的配置
924
+ */
925
+ merge<T>(defaults: Partial<T>, overrides: Partial<T>, schema: ConfigSchema<T>): ConfigTransformReport<T>;
926
+ /**
927
+ * 深度合并两个对象
928
+ */
929
+ private deepMerge;
930
+ /**
931
+ * 从配置中提取指定字段
932
+ * @param config - 完整配置
933
+ * @param schema - 配置 Schema
934
+ * @param keys - 要提取的键
935
+ * @returns 提取的配置子集
936
+ */
937
+ extract<T, K extends keyof T>(config: T, schema: ConfigSchema<T>, keys: K[]): Partial<T>;
938
+ }
939
+ /**
940
+ * 快速转换配置
941
+ */
942
+ declare function transformConfig<T>(value: unknown, schema: ConfigSchema<T>): ConfigTransformReport<T>;
943
+ /**
944
+ * 快速合并配置
945
+ */
946
+ declare function mergeConfig<T>(defaults: Partial<T>, overrides: Partial<T>, schema: ConfigSchema<T>): ConfigTransformReport<T>;
947
+
948
+ /**
949
+ * 插件配置选项
950
+ */
951
+ interface PluginConfig<TOptions = unknown> {
952
+ /** 插件名称 */
953
+ name: string;
954
+ /** 插件版本 */
955
+ version?: string;
956
+ /** 插件描述 */
957
+ description?: string;
958
+ /** 插件作者 */
959
+ author?: string;
960
+ /** 关键词 */
961
+ keywords?: string[];
962
+ /** 插件选项 Schema */
963
+ schema?: ConfigSchema<TOptions>;
964
+ /** 安装函数 */
965
+ install: (app: App, options: TOptions) => void | Promise<void>;
966
+ }
967
+ /**
968
+ * 插件定义结果
969
+ */
970
+ interface PluginDefinition<TOptions = unknown> extends EnhancedPlugin<TOptions> {
971
+ /** 配置验证报告 */
972
+ configReport?: ConfigValidationReport;
973
+ }
974
+ /**
975
+ * 创建插件定义
976
+ * @description 提供类型安全的插件定义方式
977
+ *
978
+ * @example
979
+ * ```typescript
980
+ * const myPlugin = definePlugin({
981
+ * name: 'my-plugin',
982
+ * version: '1.0.0',
983
+ * description: 'My awesome plugin',
984
+ * schema: {
985
+ * type: 'object',
986
+ * properties: {
987
+ * theme: { type: 'string', string: { enum: ['light', 'dark'] }, default: 'light' },
988
+ * debug: { type: 'boolean', default: false },
989
+ * },
990
+ * },
991
+ * install: (app, options) => {
992
+ * console.log('Plugin installed with options:', options);
993
+ * },
994
+ * });
995
+ * ```
996
+ */
997
+ declare function definePlugin<TOptions = unknown>(config: PluginConfig<TOptions>): PluginDefinition<TOptions>;
998
+ /**
999
+ * 验证插件配置
1000
+ * @description 验证用户提供的配置是否符合 Schema
1001
+ *
1002
+ * @example
1003
+ * ```typescript
1004
+ * const result = validatePluginConfig(myPlugin, { theme: 'dark', debug: true });
1005
+ * if (!result.valid) {
1006
+ * console.error(result.errors);
1007
+ * }
1008
+ * ```
1009
+ */
1010
+ declare function validatePluginConfig<TOptions>(plugin: EnhancedPlugin<TOptions>, userConfig: unknown): ConfigValidationReport;
1011
+ /**
1012
+ * 转换插件配置
1013
+ * @description 验证并转换用户配置,应用默认值
1014
+ *
1015
+ * @example
1016
+ * ```typescript
1017
+ * const result = transformPluginConfig(myPlugin, { debug: true });
1018
+ * // result.config = { theme: 'light', debug: true } (theme 从 default 填充)
1019
+ * ```
1020
+ */
1021
+ declare function transformPluginConfig<TOptions>(plugin: EnhancedPlugin<TOptions>, userConfig: unknown): ConfigTransformReport<TOptions>;
1022
+ /**
1023
+ * 合并插件默认配置
1024
+ * @description 将用户配置与插件默认配置合并
1025
+ *
1026
+ * @example
1027
+ * ```typescript
1028
+ * const result = mergePluginConfig(myPlugin, { theme: 'dark' }, userConfig);
1029
+ * ```
1030
+ */
1031
+ declare function mergePluginConfig<TOptions>(plugin: EnhancedPlugin<TOptions>, defaults: Partial<TOptions>, overrides: Partial<TOptions>): ConfigTransformReport<TOptions>;
1032
+ /**
1033
+ * 创建插件测试器
1034
+ * @description 用于在隔离环境中测试插件
1035
+ */
1036
+ interface PluginTesterOptions {
1037
+ /** 测试用的 App 配置 */
1038
+ appConfig?: {
1039
+ performance?: boolean;
1040
+ globalProperties?: Record<string, unknown>;
1041
+ };
1042
+ /** 是否启用调试日志 */
1043
+ debug?: boolean;
1044
+ /** 配置验证回调 */
1045
+ onValidationError?: (errors: ConfigValidationReport) => void;
1046
+ /** 安装前回调 */
1047
+ onBeforeInstall?: (app: App) => void;
1048
+ /** 安装后回调 */
1049
+ onAfterInstall?: (app: App) => void;
1050
+ /** 清理回调 */
1051
+ onCleanup?: () => void;
1052
+ }
1053
+ /**
1054
+ * 插件测试器
1055
+ * @description 提供插件测试的辅助功能
1056
+ */
1057
+ declare class PluginTester {
1058
+ private options;
1059
+ private app;
1060
+ private installedPlugins;
1061
+ constructor(options?: PluginTesterOptions);
1062
+ /**
1063
+ * 创建测试 App
1064
+ */
1065
+ createApp(): Promise<App>;
1066
+ /**
1067
+ * 安装插件进行测试
1068
+ */
1069
+ installPlugin(plugin: EnhancedPlugin, options?: unknown): Promise<void>;
1070
+ /**
1071
+ * 卸载插件进行测试
1072
+ */
1073
+ uninstallPlugin(name: string): void;
1074
+ /**
1075
+ * 运行清理
1076
+ */
1077
+ cleanup(): void;
1078
+ /**
1079
+ * 获取已安装插件列表
1080
+ */
1081
+ getInstalledPlugins(): string[];
1082
+ /**
1083
+ * 获取 App 实例
1084
+ */
1085
+ getApp(): App | null;
1086
+ }
1087
+ /**
1088
+ * 快速创建插件测试器
1089
+ */
1090
+ declare function createPluginTester(options?: PluginTesterOptions): PluginTester;
1091
+ /**
1092
+ * 测试插件安装
1093
+ * @description 在隔离环境中测试插件安装
1094
+ */
1095
+ declare function testPluginInstall(plugin: EnhancedPlugin, options?: unknown, testerOptions?: PluginTesterOptions): Promise<{
1096
+ success: boolean;
1097
+ error?: Error;
1098
+ app?: App;
1099
+ }>;
1100
+
1101
+ /**
1102
+ * @lytjs/core - 全局配置系统
1103
+ *
1104
+ * 提供运行时配置管理和合并功能
1105
+ *
1106
+ * @module @lytjs/core/config
1107
+ * @version 6.0.0
1108
+ */
1109
+ /**
1110
+ * 配置变更监听器
1111
+ */
1112
+ type ConfigChangeCallback<T = unknown> = (newValue: T, oldValue: T, path: string) => void;
1113
+ /**
1114
+ * 配置选项
1115
+ */
1116
+ interface ConfigOptions {
1117
+ /** 是否允许在运行时修改配置 */
1118
+ mutable?: boolean;
1119
+ /** 是否深度合并配置 */
1120
+ deepMerge?: boolean;
1121
+ /** 变更时的回调函数 */
1122
+ onChange?: ConfigChangeCallback;
1123
+ }
1124
+ /**
1125
+ * 配置对象类型
1126
+ */
1127
+ type ConfigValue = string | number | boolean | null | undefined | ConfigObject | ConfigArray;
1128
+ /**
1129
+ * 配置对象
1130
+ */
1131
+ interface ConfigObject {
1132
+ [key: string]: ConfigValue;
1133
+ }
1134
+ /**
1135
+ * 配置数组
1136
+ */
1137
+ type ConfigArray = ConfigValue[];
1138
+ /**
1139
+ * 全局配置管理器
1140
+ *
1141
+ * 提供配置存储、合并、变更监听等功能
1142
+ *
1143
+ * @example
1144
+ * ```ts
1145
+ * // 创建配置管理器
1146
+ * const config = new ConfigManager({
1147
+ * api: { baseURL: '/api', timeout: 5000 },
1148
+ * theme: { primary: '#007bff' }
1149
+ * })
1150
+ *
1151
+ * // 获取配置
1152
+ * const baseURL = config.get('api.baseURL')
1153
+ *
1154
+ * // 设置配置
1155
+ * config.set('api.timeout', 10000)
1156
+ *
1157
+ * // 监听变更
1158
+ * config.watch('theme.primary', (newVal, oldVal) => {
1159
+ * console.log(`主题色从 ${oldVal} 变为 ${newVal}`)
1160
+ * })
1161
+ * ```
1162
+ */
1163
+ declare class ConfigManager {
1164
+ private config;
1165
+ private options;
1166
+ private listeners;
1167
+ private globalListeners;
1168
+ constructor(initialConfig?: ConfigObject, options?: ConfigOptions);
1169
+ /**
1170
+ * 获取配置值
1171
+ *
1172
+ * @param path - 配置路径(支持点号分隔,如 'api.baseURL')
1173
+ * @param defaultValue - 默认值
1174
+ * @returns 配置值或默认值
1175
+ *
1176
+ * @example
1177
+ * ```ts
1178
+ * config.get('api.baseURL') // '/api'
1179
+ * config.get('api.timeout', 5000) // 5000 (如果不存在)
1180
+ * config.get('theme.colors.primary') // 嵌套值
1181
+ * ```
1182
+ */
1183
+ get<T = ConfigValue>(path: string, defaultValue?: T): T | undefined;
1184
+ /**
1185
+ * 设置配置值
1186
+ *
1187
+ * @param path - 配置路径
1188
+ * @param value - 新值
1189
+ * @returns 是否设置成功
1190
+ *
1191
+ * @example
1192
+ * ```ts
1193
+ * config.set('api.timeout', 10000)
1194
+ * config.set('theme.colors.primary', '#ff0000')
1195
+ * ```
1196
+ */
1197
+ set<T = ConfigValue>(path: string, value: T): boolean;
1198
+ /**
1199
+ * 批量设置配置
1200
+ *
1201
+ * @param config - 配置对象
1202
+ * @param merge - 是否合并(true)或替换(false)
1203
+ *
1204
+ * @example
1205
+ * ```ts
1206
+ * config.setMultiple({
1207
+ * 'api.timeout': 10000,
1208
+ * 'theme.primary': '#ff0000'
1209
+ * })
1210
+ * ```
1211
+ */
1212
+ setMultiple(config: Record<string, ConfigValue>, merge?: boolean): void;
1213
+ /**
1214
+ * 检查配置是否存在
1215
+ *
1216
+ * @param path - 配置路径
1217
+ * @returns 是否存在
1218
+ */
1219
+ has(path: string): boolean;
1220
+ /**
1221
+ * 删除配置
1222
+ *
1223
+ * @param path - 配置路径
1224
+ * @returns 是否删除成功
1225
+ */
1226
+ delete(path: string): boolean;
1227
+ /**
1228
+ * 合并配置
1229
+ *
1230
+ * @param config - 要合并的配置
1231
+ * @param deep - 是否深度合并
1232
+ *
1233
+ * @example
1234
+ * ```ts
1235
+ * config.merge({
1236
+ * api: { timeout: 10000 },
1237
+ * newKey: 'value'
1238
+ * })
1239
+ * ```
1240
+ */
1241
+ merge(config: ConfigObject, deep?: boolean): void;
1242
+ /**
1243
+ * 深度合并对象,并在值变更时通知监听器
1244
+ * FIX: P2-v11-08 替代原 deepMerge,在合并过程中收集变更的键并通知监听器
1245
+ */
1246
+ private deepMergeNotify;
1247
+ /**
1248
+ * 获取所有配置
1249
+ *
1250
+ * @returns 配置对象的深拷贝
1251
+ */
1252
+ getAll(): ConfigObject;
1253
+ /**
1254
+ * 重置配置
1255
+ *
1256
+ * @param newConfig - 新的配置对象
1257
+ */
1258
+ reset(newConfig?: ConfigObject): void;
1259
+ /**
1260
+ * 清空配置
1261
+ */
1262
+ clear(): void;
1263
+ /**
1264
+ * 监听配置变更
1265
+ *
1266
+ * @param path - 配置路径(空字符串表示监听所有变更)
1267
+ * @param callback - 变更回调
1268
+ * @returns 取消监听函数
1269
+ *
1270
+ * @example
1271
+ * ```ts
1272
+ * // 监听特定路径
1273
+ * const unwatch = config.watch('api.timeout', (newVal, oldVal) => {
1274
+ * console.log(`timeout 从 ${oldVal} 变为 ${newVal}`)
1275
+ * })
1276
+ *
1277
+ * // 监听所有变更
1278
+ * config.watch('', (newConfig) => {
1279
+ * console.log('配置已更新:', newConfig)
1280
+ * })
1281
+ * ```
1282
+ */
1283
+ watch<T = ConfigValue>(path: string, callback: ConfigChangeCallback<T>): () => void;
1284
+ /**
1285
+ * 通知监听器
1286
+ */
1287
+ private notify;
1288
+ /**
1289
+ * 设置可变性
1290
+ *
1291
+ * @param mutable - 是否可变
1292
+ */
1293
+ setMutable(mutable: boolean): void;
1294
+ /**
1295
+ * 检查是否可变
1296
+ * FIX: P2-v11-09 简化 isMutable():mutable 在构造函数中已设置默认值为 true,
1297
+ * 不可能为 undefined,因此 ?? true 是冗余的
1298
+ */
1299
+ isMutable(): boolean;
1300
+ }
1301
+ /**
1302
+ * 获取全局配置管理器
1303
+ *
1304
+ * @returns 全局配置管理器实例
1305
+ */
1306
+ declare function getGlobalConfig(): ConfigManager;
1307
+ /**
1308
+ * 设置全局配置
1309
+ *
1310
+ * @param config - 配置对象
1311
+ * @param merge - 是否合并
1312
+ */
1313
+ declare function setGlobalConfig(config: ConfigObject, merge?: boolean): void;
1314
+ /**
1315
+ * 获取全局配置值
1316
+ *
1317
+ * @param path - 配置路径
1318
+ * @param defaultValue - 默认值
1319
+ */
1320
+ declare function getConfig<T = ConfigValue>(path: string, defaultValue?: T): T | undefined;
1321
+ /**
1322
+ * 设置全局配置值
1323
+ *
1324
+ * @param path - 配置路径
1325
+ * @param value - 配置值
1326
+ */
1327
+ declare function setConfig<T = ConfigValue>(path: string, value: T): boolean;
1328
+ /**
1329
+ * 监听全局配置变更
1330
+ *
1331
+ * @param path - 配置路径
1332
+ * @param callback - 变更回调
1333
+ */
1334
+ declare function watchConfig<T = ConfigValue>(path: string, callback: ConfigChangeCallback<T>): () => void;
1335
+ /**
1336
+ * 配置预设
1337
+ */
1338
+ declare const configPresets: {
1339
+ /**
1340
+ * 开发环境预设
1341
+ */
1342
+ development: () => ConfigObject;
1343
+ /**
1344
+ * 生产环境预设
1345
+ */
1346
+ production: () => ConfigObject;
1347
+ /**
1348
+ * 测试环境预设
1349
+ */
1350
+ test: () => ConfigObject;
1351
+ };
1352
+ /**
1353
+ * 应用配置预设
1354
+ *
1355
+ * @param preset - 预设名称
1356
+ */
1357
+ declare function applyConfigPreset(preset: keyof typeof configPresets): void;
1358
+
1359
+ /**
1360
+ * HTTP 客户端类型(来自 @lytjs/common-http)
1361
+ *
1362
+ * 用途:
1363
+ * - SSR 数据预取
1364
+ * - API 请求封装
1365
+ * - 请求拦截和错误处理
1366
+ */
1367
+ interface HttpClientLike {
1368
+ get<T = unknown>(url: string, options?: unknown): Promise<T>;
1369
+ post<T = unknown>(url: string, data?: unknown, options?: unknown): Promise<T>;
1370
+ put<T = unknown>(url: string, data?: unknown, options?: unknown): Promise<T>;
1371
+ delete<T = unknown>(url: string, options?: unknown): Promise<T>;
1372
+ interceptors: {
1373
+ request: {
1374
+ use: (fn: unknown) => number;
1375
+ };
1376
+ response: {
1377
+ use: (fn: unknown) => number;
1378
+ };
1379
+ };
1380
+ }
1381
+ /**
1382
+ * URL 查询工具类型(来自 @lytjs/common-query)
1383
+ *
1384
+ * 用途:
1385
+ * - 路由参数解析
1386
+ * - URL 构建
1387
+ * - 查询字符串处理
1388
+ */
1389
+ interface QueryUtilsLike {
1390
+ parseQueryString(str: string): Record<string, string>;
1391
+ stringifyQueryString(obj: Record<string, unknown>): string;
1392
+ parseURL(url: string): {
1393
+ protocol: string;
1394
+ host: string;
1395
+ pathname: string;
1396
+ search: string;
1397
+ hash: string;
1398
+ };
1399
+ buildURL(base: string, params?: Record<string, unknown>): string;
1400
+ }
1401
+ /**
1402
+ * 安全工具类型(来自 @lytjs/common-security)
1403
+ *
1404
+ * 用途:
1405
+ * - XSS 防护
1406
+ * - HTML 转义
1407
+ * - 安全的动态内容处理
1408
+ */
1409
+ interface SecurityUtilsLike {
1410
+ escapeHtml(str: string): string;
1411
+ escapeAttr(str: string): string;
1412
+ sanitizeHtml(html: string, options?: unknown): string;
1413
+ }
1414
+ /**
1415
+ * 缓存工具类型(来自 @lytjs/common-cache)
1416
+ *
1417
+ * 用途:
1418
+ * - 组件实例缓存
1419
+ * - 计算结果缓存
1420
+ * - Keep-alive 实现
1421
+ */
1422
+ interface CacheUtilsLike {
1423
+ createLRUCache<K, V>(maxSize: number): {
1424
+ get(key: K): V | undefined;
1425
+ set(key: K, value: V): void;
1426
+ has(key: K): boolean;
1427
+ delete(key: K): boolean;
1428
+ clear(): void;
1429
+ size: number;
1430
+ };
1431
+ }
1432
+ /**
1433
+ * 框架核心集成点
1434
+ *
1435
+ * 允许外部模块(如路由、状态管理)注册其工具实现,
1436
+ * 使框架核心可以使用这些功能而无需直接依赖。
1437
+ */
1438
+ interface CoreIntegrations {
1439
+ http?: HttpClientLike;
1440
+ query?: QueryUtilsLike;
1441
+ security?: SecurityUtilsLike;
1442
+ cache?: CacheUtilsLike;
1443
+ }
1444
+ /**
1445
+ * 注册集成点(全局,向后兼容)
1446
+ */
1447
+ declare function registerIntegrations(integrations: CoreIntegrations): void;
1448
+ /**
1449
+ * 获取 HTTP 客户端
1450
+ */
1451
+ declare function getHttpClient(): HttpClientLike | undefined;
1452
+ /**
1453
+ * 获取查询工具
1454
+ */
1455
+ declare function getQueryUtils(): QueryUtilsLike | undefined;
1456
+ /**
1457
+ * 获取安全工具
1458
+ */
1459
+ declare function getSecurityUtils(): SecurityUtilsLike | undefined;
1460
+ /**
1461
+ * 获取缓存工具
1462
+ */
1463
+ declare function getCacheUtils(): CacheUtilsLike | undefined;
1464
+ /**
1465
+ * 安全转义 HTML(如果有安全工具则使用,否则使用基础实现)
1466
+ */
1467
+ declare function safeEscapeHtml(str: string): string;
1468
+ /**
1469
+ * 解析查询字符串(如果有查询工具则使用,否则使用基础实现)
1470
+ */
1471
+ declare function safeParseQueryString(str: string): Record<string, string>;
1472
+
1473
+ /**
1474
+ * @lytjs/core - 错误边界组件
1475
+ *
1476
+ * 提供强大的错误处理和恢复机制
1477
+ */
1478
+
1479
+ /** 错误信息 */
1480
+ interface ErrorInfo {
1481
+ componentStack?: string;
1482
+ timestamp: Date;
1483
+ }
1484
+ /** 降级组件属性 */
1485
+ interface FallbackProps {
1486
+ error: Error;
1487
+ errorInfo: ErrorInfo;
1488
+ reset: () => void;
1489
+ retry: () => void;
1490
+ retryCount: number;
1491
+ maxRetries: number;
1492
+ hasRetries: boolean;
1493
+ }
1494
+ /** 错误边界属性 */
1495
+ interface ErrorBoundaryProps {
1496
+ fallback?: unknown;
1497
+ fallbackRender?: (error: Error, errorInfo: ErrorInfo, reset: () => void) => VNode;
1498
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
1499
+ maxRetries?: number;
1500
+ retryDelay?: number;
1501
+ onRetry?: (retryCount: number) => void;
1502
+ onMaxRetriesReached?: (error: Error) => void;
1503
+ }
1504
+ /** 错误报告上下文 */
1505
+ interface ErrorContext {
1506
+ componentName?: string;
1507
+ props?: Record<string, unknown>;
1508
+ state?: Record<string, unknown>;
1509
+ url?: string;
1510
+ userAgent?: string;
1511
+ timestamp: Date;
1512
+ }
1513
+ /** 错误报告器接口 */
1514
+ interface ErrorReporter {
1515
+ report(error: Error, context: ErrorContext): void;
1516
+ }
1517
+ /** 错误日志 */
1518
+ interface ErrorLog {
1519
+ id: string;
1520
+ timestamp: Date;
1521
+ error: Error;
1522
+ errorInfo: ErrorInfo;
1523
+ context: ErrorContext;
1524
+ retryCount: number;
1525
+ }
1526
+ /** 设置全局错误报告器 */
1527
+ declare function setGlobalErrorReporter(reporter: ErrorReporter): void;
1528
+ /** 获取全局错误报告器 */
1529
+ declare function getGlobalErrorReporter(): ErrorReporter;
1530
+ /** 错误日志管理器 */
1531
+ declare class ErrorLogManager {
1532
+ private logs;
1533
+ private maxLogs;
1534
+ addLog(log: ErrorLog): void;
1535
+ getLogs(): ErrorLog[];
1536
+ clearLogs(): void;
1537
+ exportLogs(): string;
1538
+ getLogById(id: string): ErrorLog | undefined;
1539
+ getLogsByErrorType(errorType: string): ErrorLog[];
1540
+ getLogsByDateRange(start: Date, end: Date): ErrorLog[];
1541
+ getErrorStats(): {
1542
+ totalErrors: number;
1543
+ errorTypes: Record<string, number>;
1544
+ recentErrors: ErrorLog[];
1545
+ };
1546
+ }
1547
+ /** 全局错误日志管理器实例 */
1548
+ declare const errorLogManager: ErrorLogManager;
1549
+ /** 错误边界组件实现 */
1550
+ declare function ErrorBoundary(props: ErrorBoundaryProps): VNode;
1551
+ /** 错误边界钩子 - 用于手动触发错误 */
1552
+ declare function useErrorHandler(): (error: Error) => void;
1553
+ /** 错误边界重置钩子 */
1554
+ declare function useErrorBoundaryReset(): () => void;
1555
+
1556
+ export { type App, type AppConfig, type AppOptions, type ArraySchema, type AsyncComponentLoader, type AsyncComponentOptions, type BooleanSchema, type CacheUtilsLike, type Component, type ConfigArray, type ConfigChangeCallback, ConfigManager, type ConfigObject, type ConfigOptions, type ConfigSchema, type ConfigTransformReport, ConfigTransformer, type ConfigValidationError, type ConfigValidationReport, ConfigValidator, type ConfigValue, type CoreIntegrations, type DebuggerHook, type DefineCustomElementOptions, type DependencyResult, type EnhancedPlugin, type EnumSchema, ErrorBoundary, type ErrorBoundaryProps, type ErrorCapturedHook, type ErrorContext, type ErrorInfo, type ErrorLog, type ErrorReporter, type FallbackProps, type HttpClientLike, type NumberSchema, type ObjectSchema, type Plugin, type PluginConfig, type PluginDefinition, type PluginDependency, type PluginEventListener, type PluginFunctionWithCleanup, type PluginInstallFunction, type PluginLifecycleEvent, type PluginMeta, PluginRegistry, PluginTester, type PluginTesterOptions, PluginValidator, type PluginWithCleanup, type QueryUtilsLike, type RegisteredPlugin, type RegistrationResult, type SchemaType, type SecurityUtilsLike, type StringFormat, type StringSchema, type UnionSchema, type ValidationContext$1 as ValidationContext, type ValidationErrorCode, type ValidationIssue, type ValidationReport, type ValidationResult, applyConfigPreset, configPresets, createApp, h as createElement, createPluginTester, defineAsyncComponent, defineComponent, defineCustomElement, defineModel, definePlugin, errorLogManager, getCacheUtils, getConfig, getGlobalConfig, getGlobalErrorReporter, getHttpClient, getQueryUtils, getSecurityUtils, h, injectChildStyles, mergeConfig, mergePluginConfig, registerIntegrations, resolveComponent, resolveDirective, resolveDynamicComponent, safeEscapeHtml, safeParseQueryString, setConfig, setGlobalConfig, setGlobalErrorReporter, testPluginInstall, transformConfig, transformPluginConfig, useAttrs, useCssModule, useCssVars, useErrorBoundaryReset, useErrorHandler, useHost, useId, useModel, useShadowRoot, useSlots, useTemplateRef, useWebComponentSlots, validateConfig, validatePluginConfig, watchConfig, withDirectives, withMemo };