@finesoft/front 0.1.74 → 0.1.76

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.
@@ -0,0 +1,1249 @@
1
+ //#region ../core/src/actions/types.d.ts
2
+ /**
3
+ * Action 类型定义
4
+ *
5
+ * FlowAction — SPA 内部导航
6
+ * ExternalUrlAction — 打开外部链接
7
+ * CompoundAction — 组合多个 Action
8
+ */
9
+ /** Action Kind 常量 */
10
+ declare const ACTION_KINDS: {
11
+ FLOW: "flow";
12
+ EXTERNAL_URL: "externalUrl";
13
+ COMPOUND: "compound";
14
+ };
15
+ /** FlowAction — SPA 导航 */
16
+ interface FlowAction {
17
+ kind: typeof ACTION_KINDS.FLOW;
18
+ url: string;
19
+ /** 展示方式: 默认 push,modal 弹窗 */
20
+ presentationContext?: "default" | "modal";
21
+ }
22
+ /** ExternalUrlAction — 外部链接 */
23
+ interface ExternalUrlAction {
24
+ kind: typeof ACTION_KINDS.EXTERNAL_URL;
25
+ url: string;
26
+ }
27
+ /** CompoundAction — 组合 Action */
28
+ interface CompoundAction {
29
+ kind: typeof ACTION_KINDS.COMPOUND;
30
+ actions: Action[];
31
+ }
32
+ /** 所有 Action 的联合类型 */
33
+ type Action = FlowAction | ExternalUrlAction | CompoundAction;
34
+ declare function isFlowAction(action: Action): action is FlowAction;
35
+ declare function isExternalUrlAction(action: Action): action is ExternalUrlAction;
36
+ declare function isCompoundAction(action: Action): action is CompoundAction;
37
+ declare function makeFlowAction(url: string, presentationContext?: FlowAction["presentationContext"]): FlowAction;
38
+ declare function makeExternalUrlAction(url: string): ExternalUrlAction;
39
+ //#endregion
40
+ //#region ../core/src/actions/dispatcher.d.ts
41
+ /** Action 处理器函数类型 */
42
+ type ActionHandler<A extends Action = Action> = (action: A) => Promise<void> | void;
43
+ declare class ActionDispatcher {
44
+ private handlers;
45
+ /**
46
+ * 注册指定 kind 的 handler。
47
+ *
48
+ * 重复 kind 时保留第一个注册者并发出警告——这是有意设计:
49
+ * framework 内部 handler 先注册,应用层意外覆盖会被记录而非静默生效。
50
+ * 如需显式替换,先调用 removeAction(kind)。
51
+ */
52
+ onAction<A extends Action>(kind: string, handler: ActionHandler<A>): void;
53
+ /** 移除指定 kind 的 handler(用于显式覆盖场景) */
54
+ removeAction(kind: string): boolean;
55
+ /** 执行一个 Action(CompoundAction 递归展开,有深度限制) */
56
+ perform(action: Action, _depth?: number): Promise<void>;
57
+ }
58
+ //#endregion
59
+ //#region ../core/src/dependencies/container.d.ts
60
+ /**
61
+ * Container — 通用的依赖注入容器
62
+ */
63
+ type Factory<T> = () => T;
64
+ declare class Container {
65
+ private registrations;
66
+ private resolutionStack;
67
+ private parent?;
68
+ private children;
69
+ /** 注册依赖(默认单例) */
70
+ register<T>(key: string, factory: Factory<T>, singleton?: boolean): this;
71
+ /** 解析依赖 — 当前容器未注册时回退到 parent */
72
+ resolve<T>(key: string): T;
73
+ /** 检查是否已注册(含 parent) */
74
+ has(key: string): boolean;
75
+ /**
76
+ * 创建子容器(请求级 scope)
77
+ *
78
+ * 子容器可覆写父容器的依赖(如每请求的 locale、user),
79
+ * 未覆写的 key 自动回退到父容器解析。子容器会被父容器跟踪,
80
+ * 父容器 dispose 时一并销毁所有未独立 dispose 的子容器。
81
+ */
82
+ createScope(): Container;
83
+ /**
84
+ * 销毁容器,清除所有缓存。
85
+ *
86
+ * - 递归 dispose 所有 createScope() 创建的未 dispose 子容器
87
+ * - 自身被 dispose 后从父容器移除引用,允许 GC
88
+ * - 重复 dispose 安全(幂等)
89
+ */
90
+ dispose(): void;
91
+ }
92
+ //#endregion
93
+ //#region ../core/src/intents/types.d.ts
94
+ /** Intent — 描述一个用户意图 */
95
+ interface Intent<T = unknown> {
96
+ /** Intent 标识符(用于匹配 Controller) */
97
+ id: string;
98
+ /** 意图参数 */
99
+ params?: Record<string, string>;
100
+ /** 预期返回的数据(仅用于类型推断) */
101
+ _returnType?: T;
102
+ }
103
+ /** Intent Controller — 处理特定 intentId 的业务逻辑 */
104
+ interface IntentController<T = unknown> {
105
+ /** Controller 对应的 Intent ID */
106
+ intentId: string;
107
+ /** 执行意图,返回页面数据 */
108
+ perform(intent: Intent<T>, container: Container): Promise<T> | T;
109
+ }
110
+ //#endregion
111
+ //#region ../core/src/intents/dispatcher.d.ts
112
+ declare class IntentDispatcher {
113
+ private controllers;
114
+ /** 注册一个 IntentController */
115
+ register(controller: IntentController): void;
116
+ /** 分发 Intent 到对应 Controller */
117
+ dispatch<T>(intent: Intent<T>, container: Container): Promise<T>;
118
+ /** 检查是否已注册某个 Intent */
119
+ has(intentId: string): boolean;
120
+ }
121
+ //#endregion
122
+ //#region ../core/src/logger/types.d.ts
123
+ /** 日志级别 */
124
+ type Level = "debug" | "info" | "warn" | "error";
125
+ /**
126
+ * Logger 接口
127
+ *
128
+ * 所有方法返回空字符串,允许在模板中内联使用而不渲染文本。
129
+ */
130
+ interface Logger {
131
+ debug(...args: unknown[]): string;
132
+ info(...args: unknown[]): string;
133
+ warn(...args: unknown[]): string;
134
+ error(...args: unknown[]): string;
135
+ }
136
+ interface LoggerFactory {
137
+ loggerFor(category: string): Logger;
138
+ }
139
+ //#endregion
140
+ //#region ../core/src/logger/base.d.ts
141
+ declare abstract class BaseLogger implements Logger {
142
+ protected category: string;
143
+ constructor(category: string);
144
+ abstract debug(...args: unknown[]): string;
145
+ abstract info(...args: unknown[]): string;
146
+ abstract warn(...args: unknown[]): string;
147
+ abstract error(...args: unknown[]): string;
148
+ }
149
+ //#endregion
150
+ //#region ../core/src/logger/reporting.d.ts
151
+ /** 日志上报回调 */
152
+ interface ReportCallback {
153
+ (level: Level, category: string, args: unknown[]): void;
154
+ }
155
+ /** 配置 */
156
+ interface ReportingLoggerOptions {
157
+ /** 最低上报级别(默认 "warn") */
158
+ minLevel?: Level;
159
+ /** 上报回调 */
160
+ report: ReportCallback;
161
+ }
162
+ declare class ReportingLogger extends BaseLogger {
163
+ private readonly minPriority;
164
+ private readonly report;
165
+ constructor(category: string, options: ReportingLoggerOptions);
166
+ debug(...args: unknown[]): string;
167
+ info(...args: unknown[]): string;
168
+ warn(...args: unknown[]): string;
169
+ error(...args: unknown[]): string;
170
+ private maybeReport;
171
+ }
172
+ declare class ReportingLoggerFactory implements LoggerFactory {
173
+ private readonly options;
174
+ constructor(options: ReportingLoggerOptions);
175
+ loggerFor(category: string): Logger;
176
+ }
177
+ //#endregion
178
+ //#region ../core/src/metrics/types.d.ts
179
+ /**
180
+ * Metrics — 类型定义
181
+ *
182
+ * 框架级埋点基础设施的核心接口。
183
+ */
184
+ /** 事件记录器 — 所有 metrics 后端实现此接口 */
185
+ interface EventRecorder {
186
+ /** 记录一条事件 */
187
+ record(type: string, fields?: Record<string, unknown>): void;
188
+ /** 刷新待发送的事件队列 */
189
+ flush?(): Promise<void>;
190
+ /** 销毁记录器,释放资源 */
191
+ destroy?(): void;
192
+ }
193
+ /** 字段提供者 — 每次记录前自动注入公共字段 */
194
+ interface MetricsFieldsProvider {
195
+ /** 返回需要附加到每条事件的字段 */
196
+ getFields(): Record<string, unknown>;
197
+ }
198
+ /** Impression 条目 */
199
+ interface ImpressionEntry {
200
+ /** 被追踪元素的唯一标识 */
201
+ id: string;
202
+ /** 元素进入视口的时间戳 */
203
+ timestamp: number;
204
+ /** 附加数据 */
205
+ metadata?: Record<string, unknown>;
206
+ }
207
+ /** Impression 观察器 — 追踪元素可见性 */
208
+ interface ImpressionObserver {
209
+ /** 开始追踪一个元素 */
210
+ observe(element: Element, id: string, metadata?: Record<string, unknown>): void;
211
+ /** 停止追踪一个元素 */
212
+ unobserve(element: Element): void;
213
+ /** 获取已捕获的曝光并清空 */
214
+ consume(): ImpressionEntry[];
215
+ /** 销毁观察器 */
216
+ destroy(): void;
217
+ }
218
+ //#endregion
219
+ //#region ../core/src/utils/platform.d.ts
220
+ /**
221
+ * Platform — UA 解析与平台检测
222
+ *
223
+ * 提供统一的平台/浏览器/OS 检测,避免在各处手写 UA 判断。
224
+ */
225
+ interface PlatformInfo {
226
+ /** 操作系统 */
227
+ os: "ios" | "android" | "macos" | "windows" | "linux" | "unknown";
228
+ /** 浏览器 */
229
+ browser: "safari" | "chrome" | "firefox" | "edge" | "opera" | "samsung" | "unknown";
230
+ /** 渲染引擎 */
231
+ engine: "webkit" | "blink" | "gecko" | "unknown";
232
+ /** 是否为移动设备 */
233
+ isMobile: boolean;
234
+ /** 是否为触摸设备 */
235
+ isTouch: boolean;
236
+ }
237
+ /**
238
+ * 从 User-Agent 字符串解析平台信息
239
+ *
240
+ * @param ua - User-Agent 字符串(默认取 navigator.userAgent)
241
+ */
242
+ declare function detectPlatform(ua?: string): PlatformInfo;
243
+ //#endregion
244
+ //#region ../core/src/i18n/messages.d.ts
245
+ /**
246
+ * i18n message helpers shared by SSR and browser startup.
247
+ */
248
+ /** Flat translation table: key -> localized text */
249
+ type FlatMessages = Record<string, string>;
250
+ /** Nested translation value: plain text or pluralized text map */
251
+ type NestedMessageValue = string | Record<string, string>;
252
+ /** Locale-grouped translation table */
253
+ type LocaleMessages = Record<string, Record<string, NestedMessageValue>>;
254
+ /**
255
+ * Translation message formats supported by the framework:
256
+ * - flat messages for a single locale
257
+ * - locale-grouped messages with optional plural subkeys
258
+ */
259
+ type TranslationMessages = FlatMessages | LocaleMessages;
260
+ interface MessagesLoaderContext {
261
+ readonly runtime: "server" | "browser";
262
+ readonly fetch: typeof globalThis.fetch;
263
+ readonly url: string;
264
+ readonly request?: Request;
265
+ }
266
+ type MessagesLoader = (locale: string, context: MessagesLoaderContext) => TranslationMessages | Promise<TranslationMessages | undefined> | undefined;
267
+ interface ResolveConfiguredMessagesOptions {
268
+ locale?: string;
269
+ loadMessages?: MessagesLoader;
270
+ context?: MessagesLoaderContext;
271
+ }
272
+ /**
273
+ * Resolve the effective translation source for a locale.
274
+ */
275
+ declare function resolveConfiguredMessages(options: ResolveConfiguredMessagesOptions): Promise<TranslationMessages | undefined>;
276
+ /**
277
+ * Resolve `TranslationMessages` into the flat map consumed by
278
+ * `SimpleTranslator`.
279
+ */
280
+ declare function resolveMessages(messages: TranslationMessages, locale: string): Record<string, string> | undefined;
281
+ //#endregion
282
+ //#region ../core/src/dependencies/make-dependencies.d.ts
283
+ /** 网络请求层 */
284
+ interface Net {
285
+ fetch(url: string, options?: RequestInit): Promise<Response>;
286
+ }
287
+ /** 存储接口 */
288
+ interface Storage {
289
+ get(key: string): string | undefined;
290
+ set(key: string, value: string): void;
291
+ delete(key: string): void;
292
+ }
293
+ /** Feature Flags */
294
+ interface FeatureFlags {
295
+ isEnabled(key: string): boolean;
296
+ getString(key: string): string | undefined;
297
+ getNumber(key: string): number | undefined;
298
+ }
299
+ /** Feature Flags Provider — 用于从远程/外部源加载 flags */
300
+ interface FeatureFlagsProvider {
301
+ isEnabled(key: string): boolean;
302
+ getString?(key: string): string | undefined;
303
+ getNumber?(key: string): number | undefined;
304
+ }
305
+ /** Metrics 记录器 */
306
+ interface MetricsRecorder {
307
+ /** 记录一条事件(通用方法) */
308
+ record(type: string, fields?: Record<string, unknown>): void;
309
+ /** 记录页面访问(便捷方法) */
310
+ recordPageView(page: string, fields?: Record<string, unknown>): void;
311
+ /** 记录自定义事件(便捷方法) */
312
+ recordEvent(name: string, fields?: Record<string, unknown>): void;
313
+ /** 刷新待发送队列 */
314
+ flush?(): Promise<void>;
315
+ /** 销毁记录器 */
316
+ destroy?(): void;
317
+ }
318
+ declare const DEP_KEYS: {
319
+ readonly LOGGER: "logger";
320
+ readonly LOGGER_FACTORY: "loggerFactory";
321
+ readonly NET: "net";
322
+ readonly STORAGE: "storage";
323
+ readonly FEATURE_FLAGS: "featureFlags";
324
+ readonly METRICS: "metrics";
325
+ readonly FETCH: "fetch";
326
+ readonly EVENT_RECORDER: "eventRecorder";
327
+ readonly LOCALE: "locale";
328
+ readonly PLATFORM: "platform";
329
+ readonly TRANSLATOR: "translator";
330
+ };
331
+ interface MakeDependenciesOptions {
332
+ fetch?: typeof globalThis.fetch;
333
+ featureFlags?: Record<string, boolean | string | number>;
334
+ /** 外部 feature flags providers(远程配置、A/B 测试等) */
335
+ featureFlagsProviders?: FeatureFlagsProvider[];
336
+ /** 日志上报回调 — 提供后自动组合 ReportingLoggerFactory */
337
+ reportCallback?: ReportCallback;
338
+ /** 自定义 EventRecorder(默认 ConsoleEventRecorder) */
339
+ eventRecorder?: EventRecorder;
340
+ /** 语言代码(如 "zh-Hans"、"en-US"),用于注入 locale 信息 */
341
+ locale?: string;
342
+ /** 自定义 PlatformInfo(默认通过 UA 自动检测) */
343
+ platform?: PlatformInfo;
344
+ }
345
+ declare function makeDependencies(container: Container, options?: MakeDependenciesOptions): void;
346
+ //#endregion
347
+ //#region ../core/src/models/page.d.ts
348
+ /**
349
+ * BasePage — 所有页面共享的基础属性
350
+ *
351
+ * 具体页面类型由应用层定义并扩展此接口。
352
+ */
353
+ interface BasePage {
354
+ id: string;
355
+ pageType: string;
356
+ title: string;
357
+ description?: string;
358
+ url?: string;
359
+ }
360
+ //#endregion
361
+ //#region ../core/src/middleware/types.d.ts
362
+ /** 导航上下文(beforeLoad 阶段可用) */
363
+ interface NavigationContext {
364
+ /** 完整 URL(path + query) */
365
+ readonly url: string;
366
+ /** 仅路径部分 */
367
+ readonly path: string;
368
+ /** 路由参数 + 查询参数 */
369
+ readonly params: Record<string, string>;
370
+ /** 匹配的 Intent */
371
+ readonly intent: Intent;
372
+ /** 是否在服务端运行 */
373
+ readonly isServer: boolean;
374
+ /** DI 容器(可获取自定义服务) */
375
+ readonly container: Container;
376
+ /** 获取 Cookie 值(两端均可用) */
377
+ getCookie(name: string): string | undefined;
378
+ /** 获取请求头值(仅服务端有值,客户端始终返回 undefined) */
379
+ getHeader(name: string): string | undefined;
380
+ }
381
+ /** 后置上下文(afterLoad 阶段,包含页面数据) */
382
+ interface PostLoadContext extends NavigationContext {
383
+ /** 控制器返回的页面数据 */
384
+ readonly page: BasePage;
385
+ }
386
+ /** 继续执行下一个中间件 */
387
+ interface NextResult {
388
+ readonly kind: "next";
389
+ }
390
+ /** 重定向(服务端: HTTP 301/302,客户端: 触发新导航) */
391
+ interface RedirectResult {
392
+ readonly kind: "redirect";
393
+ readonly url: string;
394
+ readonly status: number;
395
+ }
396
+ /** URL 重写(服务端: HTTP 301,客户端: replaceState 仅更新地址栏) */
397
+ interface RewriteResult {
398
+ readonly kind: "rewrite";
399
+ readonly url: string;
400
+ }
401
+ /** 拒绝访问 */
402
+ interface DenyResult {
403
+ readonly kind: "deny";
404
+ readonly status: number;
405
+ readonly message: string;
406
+ }
407
+ type MiddlewareResult = NextResult | RedirectResult | RewriteResult | DenyResult;
408
+ /** 继续执行 */
409
+ declare function next(): NextResult;
410
+ /** 重定向到新 URL */
411
+ declare function redirect(url: string, status?: 301 | 302): RedirectResult;
412
+ /** URL 重写(不重新加载数据) */
413
+ declare function rewrite(url: string): RewriteResult;
414
+ /** 拒绝访问 */
415
+ declare function deny(status?: number, message?: string): DenyResult;
416
+ /** beforeLoad 守卫:路由匹配后、数据加载前 */
417
+ type BeforeLoadGuard = (ctx: NavigationContext) => MiddlewareResult | Promise<MiddlewareResult>;
418
+ /** afterLoad 守卫:数据加载后、渲染前 */
419
+ type AfterLoadGuard = (ctx: PostLoadContext) => MiddlewareResult | Promise<MiddlewareResult>;
420
+ //#endregion
421
+ //#region ../core/src/router/router.d.ts
422
+ /** 路由匹配结果 */
423
+ interface RouteMatch {
424
+ intent: Intent;
425
+ action: FlowAction;
426
+ renderMode?: string;
427
+ /** 该路由绑定的 beforeLoad 守卫 */
428
+ beforeGuards?: BeforeLoadGuard[];
429
+ /** 该路由绑定的 afterLoad 守卫 */
430
+ afterGuards?: AfterLoadGuard[];
431
+ }
432
+ /** 路由添加选项 */
433
+ interface RouteAddOptions {
434
+ renderMode?: string;
435
+ beforeGuards?: BeforeLoadGuard[];
436
+ afterGuards?: AfterLoadGuard[];
437
+ }
438
+ declare class Router {
439
+ private routes;
440
+ /** 添加路由规则 */
441
+ add(pattern: string, intentId: string, renderModeOrOptions?: string | RouteAddOptions): this;
442
+ /** 解析 URL → RouteMatch */
443
+ resolve(urlOrPath: string): RouteMatch | null;
444
+ /** 获取所有已注册的路由 */
445
+ getRoutes(): string[];
446
+ private parseUrl;
447
+ }
448
+ //#endregion
449
+ //#region ../core/src/logger/composite.d.ts
450
+ declare class CompositeLoggerFactory implements LoggerFactory {
451
+ private readonly factories;
452
+ constructor(factories: LoggerFactory[]);
453
+ loggerFor(name: string): Logger;
454
+ }
455
+ declare class CompositeLogger implements Logger {
456
+ private readonly loggers;
457
+ constructor(loggers: Logger[]);
458
+ debug(...args: unknown[]): string;
459
+ info(...args: unknown[]): string;
460
+ warn(...args: unknown[]): string;
461
+ error(...args: unknown[]): string;
462
+ private callAll;
463
+ }
464
+ //#endregion
465
+ //#region ../core/src/logger/console.d.ts
466
+ declare class ConsoleLogger extends BaseLogger {
467
+ debug(...args: unknown[]): string;
468
+ info(...args: unknown[]): string;
469
+ warn(...args: unknown[]): string;
470
+ error(...args: unknown[]): string;
471
+ }
472
+ declare class ConsoleLoggerFactory implements LoggerFactory {
473
+ loggerFor(category: string): Logger;
474
+ }
475
+ //#endregion
476
+ //#region ../core/src/logger/local-storage-filter.d.ts
477
+ declare function shouldLog(name: string, level: Level): boolean;
478
+ declare function resetFilterCache(): void;
479
+ //#endregion
480
+ //#region ../core/src/i18n/types.d.ts
481
+ /**
482
+ * i18n — 类型定义
483
+ *
484
+ * 框架级国际化基础设施。
485
+ */
486
+ /** 翻译函数 */
487
+ interface Translator {
488
+ /**
489
+ * 翻译 key → 本地化字符串
490
+ * @param key - 翻译 key
491
+ * @param values - 插值参数
492
+ */
493
+ t(key: string, values?: Record<string, string | number>): string;
494
+ /**
495
+ * 复数形式翻译
496
+ * @param key - 翻译 key 前缀
497
+ * @param count - 数量
498
+ * @param values - 附加插值
499
+ */
500
+ plural(key: string, count: number, values?: Record<string, string | number>): string;
501
+ /** 当前 locale(如 "zh-Hans" / "en-US") */
502
+ readonly locale: string;
503
+ }
504
+ /** 文本方向 */
505
+ type TextDirection = "ltr" | "rtl";
506
+ /** HTML 语言属性 */
507
+ interface LocaleAttributes {
508
+ /** BCP 47 语言标签 */
509
+ lang: string;
510
+ /** 文本方向 */
511
+ dir: TextDirection;
512
+ }
513
+ /** Locale 信息 */
514
+ interface LocaleInfo {
515
+ /** 语言代码(如 "zh-Hans", "en") */
516
+ language: string;
517
+ /** 地区/Storefront 代码(如 "CN", "US") */
518
+ region?: string;
519
+ /** BCP 47 完整标签 */
520
+ bcp47: string;
521
+ /** 文本方向 */
522
+ dir: TextDirection;
523
+ }
524
+ //#endregion
525
+ //#region ../core/src/prefetched-intents/prefetched-intents.d.ts
526
+ /** 预获取的 Intent-Data 对 */
527
+ interface PrefetchedIntent {
528
+ intent: Intent;
529
+ data: unknown;
530
+ }
531
+ declare class PrefetchedIntents {
532
+ private intents;
533
+ private constructor();
534
+ /** 从 PrefetchedIntent 数组创建缓存实例 */
535
+ static fromArray(items: PrefetchedIntent[]): PrefetchedIntents;
536
+ /** 创建空缓存实例 */
537
+ static empty(): PrefetchedIntents;
538
+ /**
539
+ * 获取缓存的 Intent 结果(一次性使用)。
540
+ * 命中后从缓存中删除。
541
+ */
542
+ get<T>(intent: Intent<T>): T | undefined;
543
+ /** 检查缓存中是否有某个 Intent 的数据 */
544
+ has(intent: Intent): boolean;
545
+ /** 缓存中的条目数 */
546
+ get size(): number;
547
+ }
548
+ //#endregion
549
+ //#region ../core/src/framework.d.ts
550
+ /** Framework 初始化配置 */
551
+ interface FrameworkConfig extends MakeDependenciesOptions {
552
+ setupRoutes?: (router: Router) => void;
553
+ prefetchedIntents?: PrefetchedIntents;
554
+ }
555
+ declare class Framework {
556
+ readonly container: Container;
557
+ readonly intentDispatcher: IntentDispatcher;
558
+ readonly actionDispatcher: ActionDispatcher;
559
+ readonly router: Router;
560
+ readonly prefetchedIntents: PrefetchedIntents;
561
+ private readonly beforeGuards;
562
+ private readonly afterGuards;
563
+ private _logger?;
564
+ private constructor();
565
+ /** 创建并初始化 Framework 实例 */
566
+ static create(config?: FrameworkConfig): Framework;
567
+ private getLogger;
568
+ /** 分发 Intent — 获取页面数据 */
569
+ dispatch<T>(intent: Intent<T>): Promise<T>;
570
+ /** 执行 Action — 处理用户交互 */
571
+ perform(action: Action): Promise<void>;
572
+ /** 路由 URL — 将 URL 解析为 Intent + Action */
573
+ routeUrl(url: string): RouteMatch | null;
574
+ /** 记录页面访问事件 */
575
+ didEnterPage(page: BasePage): void;
576
+ /** 获取 locale 信息(如果已配置) */
577
+ getLocale(): LocaleAttributes | undefined;
578
+ /** 获取翻译器(如果当前 locale 已经初始化了翻译字典) */
579
+ getTranslator(): Translator | undefined;
580
+ /** 获取平台信息 */
581
+ getPlatform(): PlatformInfo;
582
+ /** 注册 Action 处理器 */
583
+ onAction<A extends Action>(kind: string, handler: ActionHandler<A>): void;
584
+ /** 注册 Intent Controller */
585
+ registerIntent(controller: IntentController): void;
586
+ /** 注册 beforeLoad 守卫(路由匹配后、数据加载前) */
587
+ beforeLoad(guard: BeforeLoadGuard): void;
588
+ /** 注册 afterLoad 守卫(数据加载后、渲染前) */
589
+ afterLoad(guard: AfterLoadGuard): void;
590
+ /** 执行所有 beforeLoad 守卫(全局 → 路由级) */
591
+ runBeforeLoad(ctx: NavigationContext, routeGuards?: BeforeLoadGuard[]): Promise<MiddlewareResult>;
592
+ /** 执行所有 afterLoad 守卫(全局 → 路由级) */
593
+ runAfterLoad(ctx: PostLoadContext, routeGuards?: AfterLoadGuard[]): Promise<MiddlewareResult>;
594
+ /** 销毁 Framework 实例 */
595
+ dispose(): void;
596
+ }
597
+ //#endregion
598
+ //#region ../core/src/models/shelf.d.ts
599
+ interface BaseShelf {
600
+ id: string;
601
+ shelfType: string;
602
+ title?: string;
603
+ subtitle?: string;
604
+ seeAllAction?: Action;
605
+ isHorizontal?: boolean;
606
+ }
607
+ interface BaseItem {
608
+ id: string;
609
+ itemType: string;
610
+ clickAction?: Action;
611
+ }
612
+ //#endregion
613
+ //#region ../core/src/prefetched-intents/stable-stringify.d.ts
614
+ /**
615
+ * stableStringify — 确定性 JSON 序列化(keys 按字母排序)
616
+ *
617
+ * 用作缓存 key:相同内容的对象始终产生相同字符串。
618
+ */
619
+ declare function stableStringify(obj: unknown): string;
620
+ //#endregion
621
+ //#region ../core/src/http/client.d.ts
622
+ /**
623
+ * HttpClient — 通用 HTTP 客户端基类
624
+ *
625
+ * 为 API Client 提供标准化的 HTTP 请求能力。
626
+ * 子类继承后只需关注业务端点定义,不需要重复实现 fetch / JSON 解析 / 错误处理。
627
+ */
628
+ /** HTTP 请求错误 */
629
+ declare class HttpError extends Error {
630
+ readonly status: number;
631
+ readonly statusText: string;
632
+ readonly body?: string | undefined;
633
+ constructor(status: number, statusText: string, body?: string | undefined);
634
+ }
635
+ /** 请求拦截器 — 在发送前修改请求 */
636
+ interface RequestInterceptor {
637
+ (url: string, init: RequestInit): RequestInit | Promise<RequestInit>;
638
+ }
639
+ /** 响应拦截器 — 在解析前修改响应 */
640
+ interface ResponseInterceptor {
641
+ (response: Response, url: string): Response | Promise<Response>;
642
+ }
643
+ /** HttpClient 构造配置 */
644
+ interface HttpClientConfig {
645
+ /** API base URL(如 "/api" 或 "https://example.com/api") */
646
+ baseUrl: string;
647
+ /** 默认请求头 */
648
+ defaultHeaders?: Record<string, string>;
649
+ /** 自定义 fetch 实现(便于测试或 SSR) */
650
+ fetch?: typeof globalThis.fetch;
651
+ /** 请求拦截器(按注册顺序执行) */
652
+ requestInterceptors?: RequestInterceptor[];
653
+ /** 响应拦截器(按注册顺序执行) */
654
+ responseInterceptors?: ResponseInterceptor[];
655
+ }
656
+ /**
657
+ * 通用 HTTP 客户端基类
658
+ *
659
+ * 使用方式: 创建子类继承 HttpClient,定义业务方法调用 this.get() / this.post() 等。
660
+ *
661
+ * @example
662
+ * ```ts
663
+ * class MyApiClient extends HttpClient {
664
+ * async getUser(id: string) {
665
+ * return this.get<User>(`/users/${id}`);
666
+ * }
667
+ * }
668
+ * ```
669
+ */
670
+ declare abstract class HttpClient {
671
+ protected readonly baseUrl: string;
672
+ protected readonly defaultHeaders: Record<string, string>;
673
+ protected readonly fetchFn: typeof globalThis.fetch;
674
+ private readonly requestInterceptors;
675
+ private readonly responseInterceptors;
676
+ constructor(config: HttpClientConfig);
677
+ /** 动态添加请求拦截器 */
678
+ useRequestInterceptor(interceptor: RequestInterceptor): this;
679
+ /** 动态添加响应拦截器 */
680
+ useResponseInterceptor(interceptor: ResponseInterceptor): this;
681
+ /** GET 请求,返回解析后的 JSON */
682
+ protected get<T>(path: string, params?: Record<string, string>): Promise<T>;
683
+ /** POST 请求,自动序列化 body 为 JSON */
684
+ protected post<T>(path: string, body?: unknown, params?: Record<string, string>): Promise<T>;
685
+ /** PUT 请求 */
686
+ protected put<T>(path: string, body?: unknown, params?: Record<string, string>): Promise<T>;
687
+ /** DELETE 请求 */
688
+ protected del<T>(path: string, params?: Record<string, string>): Promise<T>;
689
+ /**
690
+ * 底层请求方法 — 子类可覆写以自定义行为
691
+ *
692
+ * 自动处理:
693
+ * - URL 拼接 (baseUrl + path + params)
694
+ * - 默认 headers 合并
695
+ * - JSON body 序列化
696
+ * - 响应 JSON 解析
697
+ * - 非 2xx 状态码抛出 HttpError
698
+ */
699
+ protected request<T>(method: string, path: string, options?: {
700
+ params?: Record<string, string>;
701
+ body?: unknown;
702
+ headers?: Record<string, string>;
703
+ }): Promise<T>;
704
+ /** 构建完整 URL — 子类可覆写以自定义 URL 拼接逻辑 */
705
+ protected buildUrl(path: string, params?: Record<string, string>): string;
706
+ }
707
+ //#endregion
708
+ //#region ../core/src/intents/base-controller.d.ts
709
+ /**
710
+ * 抽象 Controller 基类
711
+ *
712
+ * 统一处理:
713
+ * - 类型安全的参数提取 (TParams)
714
+ * - 返回类型约束 (TResult)
715
+ * - try/catch 错误处理 + 可选 fallback
716
+ *
717
+ * @example
718
+ * ```ts
719
+ * class ProductController extends BaseController<{ productId: string }, ProductPage> {
720
+ * readonly intentId = "product-page";
721
+ *
722
+ * async execute(params: { productId: string }, container: Container) {
723
+ * const api = container.resolve<ApiClient>("api");
724
+ * return api.getProduct(params.productId);
725
+ * }
726
+ *
727
+ * fallback(params: { productId: string }, error: Error) {
728
+ * return getMockProduct(params.productId);
729
+ * }
730
+ * }
731
+ * ```
732
+ */
733
+ declare abstract class BaseController<TParams extends Record<string, string | undefined> = Record<string, string>, TResult = unknown> implements IntentController<TResult> {
734
+ /** Controller 对应的 Intent ID */
735
+ abstract readonly intentId: string;
736
+ /**
737
+ * 执行业务逻辑 — 子类必须实现
738
+ *
739
+ * @param params - Intent 参数(已类型化)
740
+ * @param container - DI 容器
741
+ * @returns 页面数据
742
+ */
743
+ abstract execute(params: TParams, container: Container): Promise<TResult> | TResult;
744
+ /**
745
+ * 错误回退 — 子类可选覆写
746
+ *
747
+ * 当 execute() 抛出异常时调用。
748
+ * 默认行为: 重新抛出原始错误。
749
+ *
750
+ * @param params - Intent 参数
751
+ * @param error - execute() 抛出的错误
752
+ * @returns 回退数据
753
+ */
754
+ fallback(params: TParams, error: Error): Promise<TResult> | TResult;
755
+ /**
756
+ * IntentController.perform() 实现
757
+ *
758
+ * 自动 try/catch → fallback 模式。
759
+ */
760
+ perform(intent: Intent<TResult>, container: Container): Promise<TResult>;
761
+ }
762
+ //#endregion
763
+ //#region ../core/src/data/mapper.d.ts
764
+ /**
765
+ * Mapper 类型工具 — 标准化数据转换管线
766
+ *
767
+ * 提供类型约定和组合函数,让 API 响应 → 页面模型 的转换有统一的签名模式。
768
+ */
769
+ /** 同步映射函数 */
770
+ type Mapper<TInput, TOutput> = (input: TInput) => TOutput;
771
+ /** 异步映射函数 */
772
+ type AsyncMapper<TInput, TOutput> = (input: TInput) => TOutput | Promise<TOutput>;
773
+ /**
774
+ * 组合两个同步 Mapper: A → B → C
775
+ */
776
+ declare function pipe<A, B, C>(m1: Mapper<A, B>, m2: Mapper<B, C>): Mapper<A, C>;
777
+ /**
778
+ * 组合三个同步 Mapper: A → B → C → D
779
+ */
780
+ declare function pipe<A, B, C, D>(m1: Mapper<A, B>, m2: Mapper<B, C>, m3: Mapper<C, D>): Mapper<A, D>;
781
+ /**
782
+ * 组合四个同步 Mapper: A → B → C → D → E
783
+ */
784
+ declare function pipe<A, B, C, D, E>(m1: Mapper<A, B>, m2: Mapper<B, C>, m3: Mapper<C, D>, m4: Mapper<D, E>): Mapper<A, E>;
785
+ /**
786
+ * 组合任意数量的同步 Mapper
787
+ */
788
+ declare function pipe(...mappers: Mapper<unknown, unknown>[]): Mapper<unknown, unknown>;
789
+ /**
790
+ * 组合两个可能异步的 Mapper: A → B → C
791
+ */
792
+ declare function pipeAsync<A, B, C>(m1: AsyncMapper<A, B>, m2: AsyncMapper<B, C>): AsyncMapper<A, C>;
793
+ /**
794
+ * 组合三个可能异步的 Mapper
795
+ */
796
+ declare function pipeAsync<A, B, C, D>(m1: AsyncMapper<A, B>, m2: AsyncMapper<B, C>, m3: AsyncMapper<C, D>): AsyncMapper<A, D>;
797
+ /**
798
+ * 将一个 Mapper 应用到数组的每个元素
799
+ */
800
+ declare function mapEach<TInput, TOutput>(mapper: Mapper<TInput, TOutput>): Mapper<TInput[], TOutput[]>;
801
+ //#endregion
802
+ //#region ../core/src/bootstrap/define-routes.d.ts
803
+ /** 渲染模式 */
804
+ type RenderMode = "ssr" | "csr" | "prerender";
805
+ /** 单条路由定义 */
806
+ interface RouteDefinition {
807
+ /** URL pattern (如 "/product/:productId") */
808
+ path: string;
809
+ /** Intent ID (如 "product-page") */
810
+ intentId: string;
811
+ /**
812
+ * Controller 实例(可选)。
813
+ * 同一个 intentId 的多条路由只需在第一条提供 controller。
814
+ */
815
+ controller?: IntentController;
816
+ /**
817
+ * 渲染模式(可选,默认 "ssr")。
818
+ * - "ssr": 服务端渲染(默认)
819
+ * - "csr": 客户端渲染(返回空壳 HTML,由客户端 JS 渲染)
820
+ * - "prerender": 预渲染(构建时生成静态 HTML + ISR 缓存)
821
+ */
822
+ renderMode?: RenderMode;
823
+ /**
824
+ * 路由级 beforeLoad 守卫(可选)。
825
+ * 在全局守卫之后执行,仅对匹配此路由的请求生效。
826
+ */
827
+ beforeLoad?: BeforeLoadGuard[];
828
+ /**
829
+ * 路由级 afterLoad 守卫(可选)。
830
+ * 在全局守卫之后执行,仅对匹配此路由的请求生效。
831
+ */
832
+ afterLoad?: AfterLoadGuard[];
833
+ }
834
+ /** defineRoutes 选项 */
835
+ interface DefineRoutesOptions {
836
+ /**
837
+ * 支持的 locale 列表。
838
+ * 提供后,每条路由会额外注册 `/:locale/path` 版本,
839
+ * `:locale` 参数自动出现在 `intent.params.locale` 中。
840
+ * 原始无前缀路径保留作为备选路由。
841
+ *
842
+ * @example
843
+ * ```ts
844
+ * defineRoutes(framework, routes, { locales: ["zh", "en", "ja"] });
845
+ * // "/about" → 注册 /about + /zh/about + /en/about + /ja/about
846
+ * ```
847
+ */
848
+ locales?: string[];
849
+ }
850
+ /**
851
+ * 声明式注册路由和 Controller
852
+ *
853
+ * - 自动去重: 同一 intentId 的 controller 只注册一次
854
+ * - 路由和 controller 在同一个配置数组中,方便检查一致性
855
+ *
856
+ * @example
857
+ * ```ts
858
+ * defineRoutes(framework, [
859
+ * { path: "/", intentId: "home", controller: new HomeController() },
860
+ * { path: "/product/:id", intentId: "product", controller: new ProductController() },
861
+ * { path: "/search", intentId: "search", controller: new SearchController() },
862
+ * { path: "/charts/:type", intentId: "charts", controller: new ChartsController() },
863
+ * { path: "/charts", intentId: "charts" }, // 同 intentId,不需要重复 controller
864
+ * ]);
865
+ * ```
866
+ */
867
+ declare function defineRoutes(framework: Framework, definitions: RouteDefinition[], options?: DefineRoutesOptions): void;
868
+ //#endregion
869
+ //#region ../core/src/utils/lru-map.d.ts
870
+ /**
871
+ * LruMap — 固定容量的 LRU 缓存
872
+ */
873
+ declare class LruMap<K, V> {
874
+ private map;
875
+ private readonly capacity;
876
+ constructor(capacity: number);
877
+ get(key: K): V | undefined;
878
+ set(key: K, value: V): void;
879
+ has(key: K): boolean;
880
+ delete(key: K): boolean;
881
+ get size(): number;
882
+ clear(): void;
883
+ }
884
+ //#endregion
885
+ //#region ../core/src/utils/optional.d.ts
886
+ /**
887
+ * Optional 类型工具
888
+ */
889
+ type None = null | undefined;
890
+ type Optional<T> = T | None;
891
+ declare function isSome<T>(value: Optional<T>): value is T;
892
+ declare function isNone<T>(value: Optional<T>): value is None;
893
+ //#endregion
894
+ //#region ../core/src/utils/pwa.d.ts
895
+ /**
896
+ * PWA Display Mode 检测
897
+ *
898
+ * 检测当前应用是否以 PWA 模式运行。
899
+ */
900
+ type PWADisplayMode = "standalone" | "twa" | "browser";
901
+ /**
902
+ * 检测 PWA display mode
903
+ *
904
+ * - `standalone`: 已安装的 PWA(通过 Add to Home Screen)
905
+ * - `twa`: Trusted Web Activity(Android 原生壳)
906
+ * - `browser`: 普通浏览器标签页
907
+ */
908
+ declare function getPWADisplayMode(): PWADisplayMode;
909
+ //#endregion
910
+ //#region ../core/src/utils/url.d.ts
911
+ /**
912
+ * URL 工具函数
913
+ */
914
+ /** 移除 URL scheme (https://, http://) */
915
+ declare function removeScheme(url: string): string;
916
+ /** 移除 URL host 部分,保留路径 */
917
+ declare function removeHost(url: string): string;
918
+ /** 移除 query 参数 */
919
+ declare function removeQueryParams(url: string): string;
920
+ /** 获取 URL 的基础路径(无 query、hash) */
921
+ declare function getBaseUrl(url: string): string;
922
+ /** 构建 URL(路径 + query 参数) */
923
+ declare function buildUrl(path: string, params?: Record<string, string | undefined>): string;
924
+ //#endregion
925
+ //#region ../core/src/utils/uuid.d.ts
926
+ /**
927
+ * UUID v4 生成器
928
+ */
929
+ declare function generateUuid(): string;
930
+ //#endregion
931
+ //#region ../core/src/middleware/context.d.ts
932
+ interface ServerContextOptions {
933
+ url: string;
934
+ intent: Intent;
935
+ container: Container;
936
+ /** 原始 Request 对象(提取 cookie 和 header) */
937
+ request?: Request;
938
+ }
939
+ /** 从 Request 对象构建服务端上下文 */
940
+ declare function createServerContext(options: ServerContextOptions): NavigationContext;
941
+ interface BrowserContextOptions {
942
+ url: string;
943
+ intent: Intent;
944
+ container: Container;
945
+ }
946
+ /** 从 document.cookie 构建浏览器端上下文 */
947
+ declare function createBrowserContext(options: BrowserContextOptions): NavigationContext;
948
+ //#endregion
949
+ //#region ../core/src/middleware/pipeline.d.ts
950
+ /** 执行 beforeLoad 守卫链 */
951
+ declare function runBeforeLoadGuards(guards: BeforeLoadGuard[], ctx: NavigationContext): Promise<MiddlewareResult>;
952
+ /** 执行 afterLoad 守卫链 */
953
+ declare function runAfterLoadGuards(guards: AfterLoadGuard[], ctx: PostLoadContext): Promise<MiddlewareResult>;
954
+ //#endregion
955
+ //#region ../core/src/metrics/composite-recorder.d.ts
956
+ declare class CompositeEventRecorder implements EventRecorder {
957
+ private readonly recorders;
958
+ constructor(recorders: EventRecorder[]);
959
+ record(type: string, fields?: Record<string, unknown>): void;
960
+ flush(): Promise<void>;
961
+ destroy(): void;
962
+ }
963
+ //#endregion
964
+ //#region ../core/src/metrics/console-recorder.d.ts
965
+ declare class ConsoleEventRecorder implements EventRecorder {
966
+ private readonly prefix;
967
+ constructor(prefix?: string);
968
+ record(type: string, fields?: Record<string, unknown>): void;
969
+ flush(): Promise<void>;
970
+ destroy(): void;
971
+ }
972
+ //#endregion
973
+ //#region ../core/src/metrics/impression-observer.d.ts
974
+ interface ImpressionObserverOptions {
975
+ /** 可见比例阈值(0~1),默认 0.5 */
976
+ threshold?: number;
977
+ /** 最小可见时长(毫秒),默认 1000 */
978
+ minVisibleDuration?: number;
979
+ }
980
+ declare class IntersectionImpressionObserver implements ImpressionObserver {
981
+ private readonly observer;
982
+ private readonly tracked;
983
+ private readonly captured;
984
+ private readonly minDuration;
985
+ constructor(options?: ImpressionObserverOptions);
986
+ observe(element: Element, id: string, metadata?: Record<string, unknown>): void;
987
+ unobserve(element: Element): void;
988
+ consume(): ImpressionEntry[];
989
+ destroy(): void;
990
+ }
991
+ //#endregion
992
+ //#region ../core/src/metrics/void-recorder.d.ts
993
+ declare class VoidEventRecorder implements EventRecorder {
994
+ record(): void;
995
+ flush(): Promise<void>;
996
+ destroy(): void;
997
+ }
998
+ //#endregion
999
+ //#region ../core/src/metrics/with-fields-recorder.d.ts
1000
+ declare class WithFieldsRecorder implements EventRecorder {
1001
+ private readonly inner;
1002
+ private readonly providers;
1003
+ constructor(inner: EventRecorder, providers: MetricsFieldsProvider[]);
1004
+ record(type: string, fields?: Record<string, unknown>): void;
1005
+ flush(): Promise<void>;
1006
+ destroy(): void;
1007
+ }
1008
+ //#endregion
1009
+ //#region ../core/src/i18n/interpolate.d.ts
1010
+ /**
1011
+ * ICU 消息格式插值
1012
+ *
1013
+ * 支持 `{name}` 占位符替换和基础复数规则。
1014
+ */
1015
+ /** 将 `{key}` 占位符替换为 values 中的对应值 */
1016
+ declare function interpolate(template: string, values?: Record<string, string | number>): string;
1017
+ /**
1018
+ * CLDR 复数类别
1019
+ *
1020
+ * 简化版:覆盖 zero / one / two / few / many / other。
1021
+ * 完整 CLDR 规则可通过 PluralRuleProvider 注入。
1022
+ */
1023
+ type PluralCategory = "zero" | "one" | "two" | "few" | "many" | "other";
1024
+ /** 复数规则函数 — 给定数量返回复数类别 */
1025
+ type PluralRuleProvider = (count: number) => PluralCategory;
1026
+ /**
1027
+ * 英语复数规则(默认)
1028
+ * 0 → other, 1 → one, 2+ → other
1029
+ */
1030
+ declare function englishPlural(count: number): PluralCategory;
1031
+ /**
1032
+ * 解析带复数后缀的翻译 key
1033
+ *
1034
+ * 约定: `key.one`, `key.other`, `key.zero`, etc.
1035
+ */
1036
+ declare function resolvePluralKey(key: string, category: PluralCategory): string;
1037
+ //#endregion
1038
+ //#region ../core/src/i18n/locale.d.ts
1039
+ /** 检测语言是否为 RTL */
1040
+ declare function isRtl(language: string): boolean;
1041
+ /** 获取文本方向 */
1042
+ declare function getTextDirection(language: string): TextDirection;
1043
+ /**
1044
+ * 从语言代码生成 HTML lang/dir 属性
1045
+ *
1046
+ * @example
1047
+ * ```ts
1048
+ * getLocaleAttributes("ar-SA") // { lang: "ar-SA", dir: "rtl" }
1049
+ * getLocaleAttributes("en-US") // { lang: "en-US", dir: "ltr" }
1050
+ * ```
1051
+ */
1052
+ declare function getLocaleAttributes(language: string): LocaleAttributes;
1053
+ /**
1054
+ * 构建 LocaleInfo
1055
+ *
1056
+ * @param language - 语言代码(如 "zh-Hans")
1057
+ * @param region - 地区代码(如 "CN"),可选
1058
+ */
1059
+ declare function makeLocaleInfo(language: string, region?: string): LocaleInfo;
1060
+ /**
1061
+ * 将 locale 属性应用到 `<html>` 元素
1062
+ *
1063
+ * 服务端渲染时可用于字符串拼接,浏览器端直接操作 DOM。
1064
+ */
1065
+ declare function setHtmlLocaleAttributes(attrs: LocaleAttributes): void;
1066
+ /**
1067
+ * 从 URL 前缀中提取 locale
1068
+ *
1069
+ * @param url - 请求 URL(如 "/zh/about")
1070
+ * @param supportedLocales - 支持的 locale 列表(如 ["zh", "en", "ja"])
1071
+ * @returns 匹配时返回 `{ locale, strippedUrl }`,不匹配返回 null
1072
+ *
1073
+ * @example
1074
+ * ```ts
1075
+ * resolveLocaleFromUrl("/zh/about", ["zh", "en"])
1076
+ * // → { locale: "zh", strippedUrl: "/about" }
1077
+ *
1078
+ * resolveLocaleFromUrl("/about", ["zh", "en"])
1079
+ * // → null
1080
+ * ```
1081
+ */
1082
+ declare function resolveLocaleFromUrl(url: string, supportedLocales: string[]): {
1083
+ locale: string;
1084
+ strippedUrl: string;
1085
+ } | null;
1086
+ //#endregion
1087
+ //#region ../core/src/i18n/translator.d.ts
1088
+ interface SimpleTranslatorOptions {
1089
+ /** 翻译映射 */
1090
+ messages: Record<string, string>;
1091
+ /** 当前 locale */
1092
+ locale: string;
1093
+ /** 复数规则函数(默认英语规则) */
1094
+ pluralRule?: PluralRuleProvider;
1095
+ /** 找不到翻译时的回退行为(默认返回 key) */
1096
+ fallback?: (key: string) => string;
1097
+ }
1098
+ declare class SimpleTranslator implements Translator {
1099
+ readonly locale: string;
1100
+ private readonly messages;
1101
+ private readonly pluralRule;
1102
+ private readonly fallback;
1103
+ constructor(options: SimpleTranslatorOptions);
1104
+ t(key: string, values?: Record<string, string | number>): string;
1105
+ plural(key: string, count: number, values?: Record<string, string | number>): string;
1106
+ }
1107
+ //#endregion
1108
+ //#region ../browser/src/action-handlers/external-url-action.d.ts
1109
+ interface ExternalUrlDependencies {
1110
+ framework: Framework;
1111
+ log: Logger;
1112
+ }
1113
+ declare function registerExternalUrlHandler(deps: ExternalUrlDependencies): void;
1114
+ //#endregion
1115
+ //#region ../browser/src/action-handlers/flow-action.d.ts
1116
+ /** UI 框架回调 — 解耦 Svelte store 等依赖 */
1117
+ interface FlowActionCallbacks {
1118
+ /** 导航后更新当前路径(替代 currentPath.set()) */
1119
+ onNavigate(pathname: string): void;
1120
+ /** 模态页面展示(替代 openModal()) */
1121
+ onModal(page: BasePage): void;
1122
+ }
1123
+ /** 注册 FlowAction handler 所需的依赖 */
1124
+ interface FlowActionDependencies {
1125
+ framework: Framework;
1126
+ log: Logger;
1127
+ callbacks: FlowActionCallbacks;
1128
+ /** 更新应用 UI 的回调,page 可以是 Promise */
1129
+ updateApp: (props: {
1130
+ page: Promise<BasePage> | BasePage;
1131
+ isFirstPage?: boolean;
1132
+ }) => void;
1133
+ /** 获取可滚动页面元素,用于滚动位置保存/恢复 */
1134
+ getScrollablePageElement?: () => HTMLElement | null;
1135
+ }
1136
+ declare function registerFlowActionHandler(deps: FlowActionDependencies): void;
1137
+ //#endregion
1138
+ //#region ../browser/src/action-handlers/register.d.ts
1139
+ interface ActionHandlerDependencies {
1140
+ framework: Framework;
1141
+ log: Logger;
1142
+ callbacks: FlowActionCallbacks;
1143
+ updateApp: (props: {
1144
+ page: Promise<BasePage> | BasePage;
1145
+ isFirstPage?: boolean;
1146
+ }) => void;
1147
+ /** 获取可滚动页面元素,用于滚动位置保存/恢复 */
1148
+ getScrollablePageElement?: () => HTMLElement | null;
1149
+ }
1150
+ declare function registerActionHandlers(deps: ActionHandlerDependencies): void;
1151
+ //#endregion
1152
+ //#region ../browser/src/start-app.d.ts
1153
+ interface BrowserAppConfig {
1154
+ /** 注册 controllers 和路由的引导函数 */
1155
+ bootstrap: (framework: Framework) => void;
1156
+ /** DOM 挂载点 ID(默认 "app") */
1157
+ mountId?: string;
1158
+ /** 获取可滚动页面元素,用于滚动位置保存/恢复 */
1159
+ getScrollablePageElement?: () => HTMLElement | null;
1160
+ /**
1161
+ * 启动前钩子 — 在 Framework 创建后、挂载前执行
1162
+ *
1163
+ * 用于初始化错误监控、埋点 SDK、i18n 等。
1164
+ */
1165
+ onBeforeStart?: (framework: Framework) => void | Promise<void>;
1166
+ /**
1167
+ * 启动后钩子 — 在初始页面触发后执行
1168
+ *
1169
+ * 用于启动后操作(如 service worker 注册、性能打点)。
1170
+ */
1171
+ onAfterStart?: (framework: Framework) => void | Promise<void>;
1172
+ /**
1173
+ * 挂载应用到 DOM
1174
+ *
1175
+ * 框架无关 — Svelte / React / Vue 均可通过此回调实现。
1176
+ *
1177
+ * @param target - DOM 挂载点
1178
+ * @param context - Framework 实例 + 语言
1179
+ * @returns 更新函数,用于后续页面切换
1180
+ */
1181
+ mount: (target: HTMLElement, context: {
1182
+ framework: Framework;
1183
+ }) => (props: {
1184
+ page: Promise<BasePage> | BasePage;
1185
+ isFirstPage?: boolean;
1186
+ }) => void;
1187
+ /** FlowAction / ExternalUrl 回调 */
1188
+ callbacks: FlowActionCallbacks;
1189
+ /**
1190
+ * Framework 配置 — locale、reportCallback、eventRecorder 等
1191
+ *
1192
+ * 传入后会在 Framework.create() 时合并。
1193
+ * prefetchedIntents 由框架自动从 DOM 提取,无需传入。
1194
+ */
1195
+ frameworkConfig?: Omit<FrameworkConfig, "prefetchedIntents">;
1196
+ /**
1197
+ * 异步加载当前 locale 的翻译字典。
1198
+ *
1199
+ * 显式传入时会覆盖 bootstrap / Vite 自动生成的 loader。
1200
+ */
1201
+ loadMessages?: MessagesLoader;
1202
+ }
1203
+ /**
1204
+ * 启动客户端应用
1205
+ *
1206
+ * 自动执行 hydration 全流程。
1207
+ */
1208
+ declare function startBrowserApp(config: BrowserAppConfig): Promise<void>;
1209
+ //#endregion
1210
+ //#region ../browser/src/utils/history.d.ts
1211
+ interface HistoryOptions {
1212
+ getScrollablePageElement: () => HTMLElement | null;
1213
+ }
1214
+ declare class History<State> {
1215
+ private readonly entries;
1216
+ private readonly log;
1217
+ private readonly getScrollablePageElement;
1218
+ private currentStateId;
1219
+ constructor(log: Logger, options: HistoryOptions, sizeLimit?: number);
1220
+ replaceState(state: State, url: string): void;
1221
+ pushState(state: State, url: string): void;
1222
+ beforeTransition(): void;
1223
+ onPopState(listener: (url: string, state?: State) => void | Promise<void>): void;
1224
+ /** 仅推入 URL,不缓存页面状态(用于页面加载失败场景) */
1225
+ pushUrl(url: string): void;
1226
+ /** 仅替换 URL,不缓存页面状态(用于页面加载失败场景) */
1227
+ replaceUrl(url: string): void;
1228
+ updateState(update: (current?: State) => State): void;
1229
+ private get scrollTop();
1230
+ private set scrollTop(value);
1231
+ }
1232
+ //#endregion
1233
+ //#region ../browser/src/utils/try-scroll.d.ts
1234
+ declare function tryScroll(log: Logger, getScrollableElement: () => HTMLElement | null, scrollY: number): void;
1235
+ //#endregion
1236
+ //#region ../browser/src/server-data.d.ts
1237
+ /**
1238
+ * 从 DOM 反序列化服务端嵌入的数据。
1239
+ * 读取 `<script id="serialized-server-data">` 的内容并移除标签。
1240
+ */
1241
+ declare function deserializeServerData(): PrefetchedIntent[] | undefined;
1242
+ /**
1243
+ * 从 DOM 提取 SSR 数据并构建 PrefetchedIntents 实例。
1244
+ * 替代原来的 PrefetchedIntents.fromDom()。
1245
+ */
1246
+ declare function createPrefetchedIntentsFromDom(): PrefetchedIntents;
1247
+ //#endregion
1248
+ export { RenderMode as $, Storage as $t, IntersectionImpressionObserver as A, isCompoundAction as An, RouteAddOptions as At, buildUrl as B, RedirectResult as Bt, PluralRuleProvider as C, ActionDispatcher as Cn, Translator as Ct, WithFieldsRecorder as D, CompoundAction as Dn, ConsoleLoggerFactory as Dt, resolvePluralKey as E, Action as En, ConsoleLogger as Et, BrowserContextOptions as F, DenyResult as Ft, PWADisplayMode as G, rewrite as Gt, removeHost as H, deny as Ht, ServerContextOptions as I, MiddlewareResult as It, Optional as J, FeatureFlags as Jt, getPWADisplayMode as K, BasePage as Kt, createBrowserContext as L, NavigationContext as Lt, CompositeEventRecorder as M, isFlowAction as Mn, Router as Mt, runAfterLoadGuards as N, makeExternalUrlAction as Nn, AfterLoadGuard as Nt, VoidEventRecorder as O, ExternalUrlAction as On, CompositeLogger as Ot, runBeforeLoadGuards as P, makeFlowAction as Pn, BeforeLoadGuard as Pt, DefineRoutesOptions as Q, Net as Qt, createServerContext as R, NextResult as Rt, PluralCategory as S, Container as Sn, TextDirection as St, interpolate as T, ACTION_KINDS as Tn, shouldLog as Tt, removeQueryParams as U, next as Ut, getBaseUrl as V, RewriteResult as Vt, removeScheme as W, redirect as Wt, isSome as X, MakeDependenciesOptions as Xt, isNone as Y, FeatureFlagsProvider as Yt, LruMap as Z, MetricsRecorder as Zt, getTextDirection as _, Logger as _n, FrameworkConfig as _t, BrowserAppConfig as a, resolveMessages as an, pipe as at, resolveLocaleFromUrl as b, Intent as bn, LocaleAttributes as bt, registerActionHandlers as c, EventRecorder as cn, HttpClient as ct, registerFlowActionHandler as d, MetricsFieldsProvider as dn, RequestInterceptor as dt, makeDependencies as en, RouteDefinition as et, ExternalUrlDependencies as f, ReportCallback as fn, ResponseInterceptor as ft, getLocaleAttributes as g, BaseLogger as gn, Framework as gt, SimpleTranslatorOptions as h, ReportingLoggerOptions as hn, BaseShelf as ht, History as i, resolveConfiguredMessages as in, mapEach as it, ConsoleEventRecorder as j, isExternalUrlAction as jn, RouteMatch as jt, ImpressionObserverOptions as k, FlowAction as kn, CompositeLoggerFactory as kt, FlowActionCallbacks as l, ImpressionEntry as ln, HttpClientConfig as lt, SimpleTranslator as m, ReportingLoggerFactory as mn, BaseItem as mt, deserializeServerData as n, MessagesLoaderContext as nn, AsyncMapper as nt, startBrowserApp as o, PlatformInfo as on, pipeAsync as ot, registerExternalUrlHandler as p, ReportingLogger as pn, stableStringify as pt, None as q, DEP_KEYS as qt, tryScroll as r, TranslationMessages as rn, Mapper as rt, ActionHandlerDependencies as s, detectPlatform as sn, BaseController as st, createPrefetchedIntentsFromDom as t, MessagesLoader as tn, defineRoutes as tt, FlowActionDependencies as u, ImpressionObserver as un, HttpError as ut, isRtl as v, LoggerFactory as vn, PrefetchedIntent as vt, englishPlural as w, ActionHandler as wn, resetFilterCache as wt, setHtmlLocaleAttributes as x, IntentController as xn, LocaleInfo as xt, makeLocaleInfo as y, IntentDispatcher as yn, PrefetchedIntents as yt, generateUuid as z, PostLoadContext as zt };
1249
+ //# sourceMappingURL=server-data-DGbiKzMS.d.mts.map