@finesoft/front 0.1.39 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-re7jUCuM.mjs +178 -0
- package/dist/app-re7jUCuM.mjs.map +1 -0
- package/dist/index.d.mts +1276 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2749 -0
- package/dist/index.mjs.map +1 -0
- package/dist/locale-D2Bu7w47.mjs +27 -0
- package/dist/locale-D2Bu7w47.mjs.map +1 -0
- package/dist/rolldown-runtime-wcPFST8Q.mjs +13 -0
- package/dist/server-peer-modules-BSSsxBaF.d.mts +41 -0
- package/dist/server-peer-modules-BSSsxBaF.d.mts.map +1 -0
- package/package.json +21 -32
- package/README.md +0 -1136
- package/dist/app-XEMPAI6H.js +0 -10
- package/dist/app-XEMPAI6H.js.map +0 -1
- package/dist/browser.cjs +0 -1465
- package/dist/browser.cjs.map +0 -1
- package/dist/browser.d.cts +0 -904
- package/dist/browser.d.ts +0 -904
- package/dist/browser.js +0 -115
- package/dist/browser.js.map +0 -1
- package/dist/chunk-4PPCVAKZ.js +0 -463
- package/dist/chunk-4PPCVAKZ.js.map +0 -1
- package/dist/chunk-OYTIGVEG.js +0 -193
- package/dist/chunk-OYTIGVEG.js.map +0 -1
- package/dist/chunk-PSPVIVC2.js +0 -25
- package/dist/chunk-PSPVIVC2.js.map +0 -1
- package/dist/chunk-SDPWQT2T.js +0 -936
- package/dist/chunk-SDPWQT2T.js.map +0 -1
- package/dist/chunk-XQ3UWZOS.js +0 -187
- package/dist/chunk-XQ3UWZOS.js.map +0 -1
- package/dist/index.cjs +0 -3661
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -582
- package/dist/index.d.ts +0 -582
- package/dist/index.js +0 -1648
- package/dist/index.js.map +0 -1
- package/dist/locale-CAZ4INCX.js +0 -7
- package/dist/locale-CAZ4INCX.js.map +0 -1
- package/dist/src-XNC7QNVI.js +0 -21
- package/dist/src-XNC7QNVI.js.map +0 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1276 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import * as node_fs0 from "node:fs";
|
|
3
|
+
import { ViteDevServer } from "vite";
|
|
4
|
+
|
|
5
|
+
//#region ../core/src/actions/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Action 类型定义
|
|
8
|
+
*
|
|
9
|
+
* FlowAction — SPA 内部导航
|
|
10
|
+
* ExternalUrlAction — 打开外部链接
|
|
11
|
+
* CompoundAction — 组合多个 Action
|
|
12
|
+
*/
|
|
13
|
+
/** Action Kind 常量 */
|
|
14
|
+
declare const ACTION_KINDS: {
|
|
15
|
+
FLOW: "flow";
|
|
16
|
+
EXTERNAL_URL: "externalUrl";
|
|
17
|
+
COMPOUND: "compound";
|
|
18
|
+
};
|
|
19
|
+
/** FlowAction — SPA 导航 */
|
|
20
|
+
interface FlowAction {
|
|
21
|
+
kind: typeof ACTION_KINDS.FLOW;
|
|
22
|
+
url: string;
|
|
23
|
+
/** 展示方式: 默认 push,modal 弹窗 */
|
|
24
|
+
presentationContext?: "default" | "modal";
|
|
25
|
+
}
|
|
26
|
+
/** ExternalUrlAction — 外部链接 */
|
|
27
|
+
interface ExternalUrlAction {
|
|
28
|
+
kind: typeof ACTION_KINDS.EXTERNAL_URL;
|
|
29
|
+
url: string;
|
|
30
|
+
}
|
|
31
|
+
/** CompoundAction — 组合 Action */
|
|
32
|
+
interface CompoundAction {
|
|
33
|
+
kind: typeof ACTION_KINDS.COMPOUND;
|
|
34
|
+
actions: Action[];
|
|
35
|
+
}
|
|
36
|
+
/** 所有 Action 的联合类型 */
|
|
37
|
+
type Action = FlowAction | ExternalUrlAction | CompoundAction;
|
|
38
|
+
declare function isFlowAction(action: Action): action is FlowAction;
|
|
39
|
+
declare function isExternalUrlAction(action: Action): action is ExternalUrlAction;
|
|
40
|
+
declare function isCompoundAction(action: Action): action is CompoundAction;
|
|
41
|
+
declare function makeFlowAction(url: string, presentationContext?: FlowAction["presentationContext"]): FlowAction;
|
|
42
|
+
declare function makeExternalUrlAction(url: string): ExternalUrlAction;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region ../core/src/actions/dispatcher.d.ts
|
|
45
|
+
/** Action 处理器函数类型 */
|
|
46
|
+
type ActionHandler<A extends Action = Action> = (action: A) => Promise<void> | void;
|
|
47
|
+
declare class ActionDispatcher {
|
|
48
|
+
private handlers;
|
|
49
|
+
private wiredActions;
|
|
50
|
+
/** 注册指定 kind 的 handler(防止重复注册) */
|
|
51
|
+
onAction<A extends Action>(kind: string, handler: ActionHandler<A>): void;
|
|
52
|
+
/** 执行一个 Action(CompoundAction 递归展开) */
|
|
53
|
+
perform(action: Action): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region ../core/src/dependencies/container.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* Container — 通用的依赖注入容器
|
|
59
|
+
*/
|
|
60
|
+
type Factory<T> = () => T;
|
|
61
|
+
declare class Container {
|
|
62
|
+
private registrations;
|
|
63
|
+
/** 注册依赖(默认单例) */
|
|
64
|
+
register<T>(key: string, factory: Factory<T>, singleton?: boolean): this;
|
|
65
|
+
/** 解析依赖 */
|
|
66
|
+
resolve<T>(key: string): T;
|
|
67
|
+
/** 检查是否已注册 */
|
|
68
|
+
has(key: string): boolean;
|
|
69
|
+
/** 销毁容器,清除所有缓存 */
|
|
70
|
+
dispose(): void;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region ../core/src/intents/types.d.ts
|
|
74
|
+
/** Intent — 描述一个用户意图 */
|
|
75
|
+
interface Intent<T = unknown> {
|
|
76
|
+
/** Intent 标识符(用于匹配 Controller) */
|
|
77
|
+
id: string;
|
|
78
|
+
/** 意图参数 */
|
|
79
|
+
params?: Record<string, string>;
|
|
80
|
+
/** 预期返回的数据(仅用于类型推断) */
|
|
81
|
+
_returnType?: T;
|
|
82
|
+
}
|
|
83
|
+
/** Intent Controller — 处理特定 intentId 的业务逻辑 */
|
|
84
|
+
interface IntentController<T = unknown> {
|
|
85
|
+
/** Controller 对应的 Intent ID */
|
|
86
|
+
intentId: string;
|
|
87
|
+
/** 执行意图,返回页面数据 */
|
|
88
|
+
perform(intent: Intent<T>, container: Container): Promise<T> | T;
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region ../core/src/intents/dispatcher.d.ts
|
|
92
|
+
declare class IntentDispatcher {
|
|
93
|
+
private controllers;
|
|
94
|
+
/** 注册一个 IntentController */
|
|
95
|
+
register(controller: IntentController): void;
|
|
96
|
+
/** 分发 Intent 到对应 Controller */
|
|
97
|
+
dispatch<T>(intent: Intent<T>, container: Container): Promise<T>;
|
|
98
|
+
/** 检查是否已注册某个 Intent */
|
|
99
|
+
has(intentId: string): boolean;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region ../core/src/logger/types.d.ts
|
|
103
|
+
/** 日志级别 */
|
|
104
|
+
type Level = "debug" | "info" | "warn" | "error";
|
|
105
|
+
/**
|
|
106
|
+
* Logger 接口
|
|
107
|
+
*
|
|
108
|
+
* 所有方法返回空字符串,允许在模板中内联使用而不渲染文本。
|
|
109
|
+
*/
|
|
110
|
+
interface Logger {
|
|
111
|
+
debug(...args: unknown[]): string;
|
|
112
|
+
info(...args: unknown[]): string;
|
|
113
|
+
warn(...args: unknown[]): string;
|
|
114
|
+
error(...args: unknown[]): string;
|
|
115
|
+
}
|
|
116
|
+
interface LoggerFactory {
|
|
117
|
+
loggerFor(category: string): Logger;
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region ../core/src/dependencies/make-dependencies.d.ts
|
|
121
|
+
/** 网络请求层 */
|
|
122
|
+
interface Net {
|
|
123
|
+
fetch(url: string, options?: RequestInit): Promise<Response>;
|
|
124
|
+
}
|
|
125
|
+
/** 多语言状态 */
|
|
126
|
+
interface Locale {
|
|
127
|
+
language: string;
|
|
128
|
+
storefront: string;
|
|
129
|
+
setActiveLocale(language: string, storefront: string): void;
|
|
130
|
+
}
|
|
131
|
+
/** 存储接口 */
|
|
132
|
+
interface Storage {
|
|
133
|
+
get(key: string): string | undefined;
|
|
134
|
+
set(key: string, value: string): void;
|
|
135
|
+
delete(key: string): void;
|
|
136
|
+
}
|
|
137
|
+
/** Feature Flags */
|
|
138
|
+
interface FeatureFlags {
|
|
139
|
+
isEnabled(key: string): boolean;
|
|
140
|
+
getString(key: string): string | undefined;
|
|
141
|
+
getNumber(key: string): number | undefined;
|
|
142
|
+
}
|
|
143
|
+
/** Metrics 记录器 */
|
|
144
|
+
interface MetricsRecorder {
|
|
145
|
+
recordPageView(page: string, fields?: Record<string, unknown>): void;
|
|
146
|
+
recordEvent(name: string, fields?: Record<string, unknown>): void;
|
|
147
|
+
}
|
|
148
|
+
declare const DEP_KEYS: {
|
|
149
|
+
readonly LOGGER: "logger";
|
|
150
|
+
readonly LOGGER_FACTORY: "loggerFactory";
|
|
151
|
+
readonly NET: "net";
|
|
152
|
+
readonly LOCALE: "locale";
|
|
153
|
+
readonly STORAGE: "storage";
|
|
154
|
+
readonly FEATURE_FLAGS: "featureFlags";
|
|
155
|
+
readonly METRICS: "metrics";
|
|
156
|
+
readonly FETCH: "fetch";
|
|
157
|
+
};
|
|
158
|
+
interface MakeDependenciesOptions {
|
|
159
|
+
fetch?: typeof globalThis.fetch;
|
|
160
|
+
language?: string;
|
|
161
|
+
storefront?: string;
|
|
162
|
+
featureFlags?: Record<string, boolean | string | number>;
|
|
163
|
+
}
|
|
164
|
+
declare function makeDependencies(container: Container, options?: MakeDependenciesOptions): void;
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region ../core/src/models/page.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* BasePage — 所有页面共享的基础属性
|
|
169
|
+
*
|
|
170
|
+
* 具体页面类型由应用层定义并扩展此接口。
|
|
171
|
+
*/
|
|
172
|
+
interface BasePage {
|
|
173
|
+
id: string;
|
|
174
|
+
pageType: string;
|
|
175
|
+
title: string;
|
|
176
|
+
description?: string;
|
|
177
|
+
url?: string;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region ../core/src/middleware/types.d.ts
|
|
181
|
+
/** 导航上下文(beforeLoad 阶段可用) */
|
|
182
|
+
interface NavigationContext {
|
|
183
|
+
/** 完整 URL(path + query) */
|
|
184
|
+
readonly url: string;
|
|
185
|
+
/** 仅路径部分 */
|
|
186
|
+
readonly path: string;
|
|
187
|
+
/** 路由参数 + 查询参数 */
|
|
188
|
+
readonly params: Record<string, string>;
|
|
189
|
+
/** 匹配的 Intent */
|
|
190
|
+
readonly intent: Intent;
|
|
191
|
+
/** 是否在服务端运行 */
|
|
192
|
+
readonly isServer: boolean;
|
|
193
|
+
/** DI 容器(可获取自定义服务) */
|
|
194
|
+
readonly container: Container;
|
|
195
|
+
/** 获取 Cookie 值(两端均可用) */
|
|
196
|
+
getCookie(name: string): string | undefined;
|
|
197
|
+
/** 获取请求头值(仅服务端有值,客户端始终返回 undefined) */
|
|
198
|
+
getHeader(name: string): string | undefined;
|
|
199
|
+
}
|
|
200
|
+
/** 后置上下文(afterLoad 阶段,包含页面数据) */
|
|
201
|
+
interface PostLoadContext extends NavigationContext {
|
|
202
|
+
/** 控制器返回的页面数据 */
|
|
203
|
+
readonly page: BasePage;
|
|
204
|
+
}
|
|
205
|
+
/** 继续执行下一个中间件 */
|
|
206
|
+
interface NextResult {
|
|
207
|
+
readonly kind: "next";
|
|
208
|
+
}
|
|
209
|
+
/** 重定向(服务端: HTTP 301/302,客户端: 触发新导航) */
|
|
210
|
+
interface RedirectResult {
|
|
211
|
+
readonly kind: "redirect";
|
|
212
|
+
readonly url: string;
|
|
213
|
+
readonly status: number;
|
|
214
|
+
}
|
|
215
|
+
/** URL 重写(服务端: HTTP 301,客户端: replaceState 仅更新地址栏) */
|
|
216
|
+
interface RewriteResult {
|
|
217
|
+
readonly kind: "rewrite";
|
|
218
|
+
readonly url: string;
|
|
219
|
+
}
|
|
220
|
+
/** 拒绝访问 */
|
|
221
|
+
interface DenyResult {
|
|
222
|
+
readonly kind: "deny";
|
|
223
|
+
readonly status: number;
|
|
224
|
+
readonly message: string;
|
|
225
|
+
}
|
|
226
|
+
type MiddlewareResult = NextResult | RedirectResult | RewriteResult | DenyResult;
|
|
227
|
+
/** 继续执行 */
|
|
228
|
+
declare function next(): NextResult;
|
|
229
|
+
/** 重定向到新 URL */
|
|
230
|
+
declare function redirect(url: string, status?: 301 | 302): RedirectResult;
|
|
231
|
+
/** URL 重写(不重新加载数据) */
|
|
232
|
+
declare function rewrite(url: string): RewriteResult;
|
|
233
|
+
/** 拒绝访问 */
|
|
234
|
+
declare function deny(status?: number, message?: string): DenyResult;
|
|
235
|
+
/** beforeLoad 守卫:路由匹配后、数据加载前 */
|
|
236
|
+
type BeforeLoadGuard = (ctx: NavigationContext) => MiddlewareResult | Promise<MiddlewareResult>;
|
|
237
|
+
/** afterLoad 守卫:数据加载后、渲染前 */
|
|
238
|
+
type AfterLoadGuard = (ctx: PostLoadContext) => MiddlewareResult | Promise<MiddlewareResult>;
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region ../core/src/router/router.d.ts
|
|
241
|
+
/** 路由匹配结果 */
|
|
242
|
+
interface RouteMatch {
|
|
243
|
+
intent: Intent;
|
|
244
|
+
action: FlowAction;
|
|
245
|
+
renderMode?: string;
|
|
246
|
+
/** 该路由绑定的 beforeLoad 守卫 */
|
|
247
|
+
beforeGuards?: BeforeLoadGuard[];
|
|
248
|
+
/** 该路由绑定的 afterLoad 守卫 */
|
|
249
|
+
afterGuards?: AfterLoadGuard[];
|
|
250
|
+
}
|
|
251
|
+
/** 路由添加选项 */
|
|
252
|
+
interface RouteAddOptions {
|
|
253
|
+
renderMode?: string;
|
|
254
|
+
beforeGuards?: BeforeLoadGuard[];
|
|
255
|
+
afterGuards?: AfterLoadGuard[];
|
|
256
|
+
}
|
|
257
|
+
declare class Router {
|
|
258
|
+
private routes;
|
|
259
|
+
/** 添加路由规则 */
|
|
260
|
+
add(pattern: string, intentId: string, renderModeOrOptions?: string | RouteAddOptions): this;
|
|
261
|
+
/** 解析 URL → RouteMatch */
|
|
262
|
+
resolve(urlOrPath: string): RouteMatch | null;
|
|
263
|
+
/** 获取所有已注册的路由 */
|
|
264
|
+
getRoutes(): string[];
|
|
265
|
+
private extractPath;
|
|
266
|
+
private extractQueryParams;
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region ../core/src/logger/base.d.ts
|
|
270
|
+
declare abstract class BaseLogger implements Logger {
|
|
271
|
+
protected category: string;
|
|
272
|
+
constructor(category: string);
|
|
273
|
+
abstract debug(...args: unknown[]): string;
|
|
274
|
+
abstract info(...args: unknown[]): string;
|
|
275
|
+
abstract warn(...args: unknown[]): string;
|
|
276
|
+
abstract error(...args: unknown[]): string;
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region ../core/src/logger/composite.d.ts
|
|
280
|
+
declare class CompositeLoggerFactory implements LoggerFactory {
|
|
281
|
+
private readonly factories;
|
|
282
|
+
constructor(factories: LoggerFactory[]);
|
|
283
|
+
loggerFor(name: string): Logger;
|
|
284
|
+
}
|
|
285
|
+
declare class CompositeLogger implements Logger {
|
|
286
|
+
private readonly loggers;
|
|
287
|
+
constructor(loggers: Logger[]);
|
|
288
|
+
debug(...args: unknown[]): string;
|
|
289
|
+
info(...args: unknown[]): string;
|
|
290
|
+
warn(...args: unknown[]): string;
|
|
291
|
+
error(...args: unknown[]): string;
|
|
292
|
+
private callAll;
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region ../core/src/logger/console.d.ts
|
|
296
|
+
declare class ConsoleLogger extends BaseLogger {
|
|
297
|
+
debug(...args: unknown[]): string;
|
|
298
|
+
info(...args: unknown[]): string;
|
|
299
|
+
warn(...args: unknown[]): string;
|
|
300
|
+
error(...args: unknown[]): string;
|
|
301
|
+
}
|
|
302
|
+
declare class ConsoleLoggerFactory implements LoggerFactory {
|
|
303
|
+
loggerFor(category: string): Logger;
|
|
304
|
+
}
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region ../core/src/logger/local-storage-filter.d.ts
|
|
307
|
+
declare function shouldLog(name: string, level: Level): boolean;
|
|
308
|
+
declare function resetFilterCache(): void;
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region ../core/src/prefetched-intents/prefetched-intents.d.ts
|
|
311
|
+
/** 预获取的 Intent-Data 对 */
|
|
312
|
+
interface PrefetchedIntent {
|
|
313
|
+
intent: Intent;
|
|
314
|
+
data: unknown;
|
|
315
|
+
}
|
|
316
|
+
declare class PrefetchedIntents {
|
|
317
|
+
private intents;
|
|
318
|
+
private constructor();
|
|
319
|
+
/** 从 PrefetchedIntent 数组创建缓存实例 */
|
|
320
|
+
static fromArray(items: PrefetchedIntent[]): PrefetchedIntents;
|
|
321
|
+
/** 创建空缓存实例 */
|
|
322
|
+
static empty(): PrefetchedIntents;
|
|
323
|
+
/**
|
|
324
|
+
* 获取缓存的 Intent 结果(一次性使用)。
|
|
325
|
+
* 命中后从缓存中删除。
|
|
326
|
+
*/
|
|
327
|
+
get<T>(intent: Intent<T>): T | undefined;
|
|
328
|
+
/** 检查缓存中是否有某个 Intent 的数据 */
|
|
329
|
+
has(intent: Intent): boolean;
|
|
330
|
+
/** 缓存中的条目数 */
|
|
331
|
+
get size(): number;
|
|
332
|
+
}
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region ../core/src/framework.d.ts
|
|
335
|
+
/** Framework 初始化配置 */
|
|
336
|
+
interface FrameworkConfig extends MakeDependenciesOptions {
|
|
337
|
+
setupRoutes?: (router: Router) => void;
|
|
338
|
+
prefetchedIntents?: PrefetchedIntents;
|
|
339
|
+
}
|
|
340
|
+
declare class Framework {
|
|
341
|
+
readonly container: Container;
|
|
342
|
+
readonly intentDispatcher: IntentDispatcher;
|
|
343
|
+
readonly actionDispatcher: ActionDispatcher;
|
|
344
|
+
readonly router: Router;
|
|
345
|
+
readonly prefetchedIntents: PrefetchedIntents;
|
|
346
|
+
private readonly beforeGuards;
|
|
347
|
+
private readonly afterGuards;
|
|
348
|
+
private constructor();
|
|
349
|
+
/** 创建并初始化 Framework 实例 */
|
|
350
|
+
static create(config?: FrameworkConfig): Framework;
|
|
351
|
+
/** 分发 Intent — 获取页面数据 */
|
|
352
|
+
dispatch<T>(intent: Intent<T>): Promise<T>;
|
|
353
|
+
/** 执行 Action — 处理用户交互 */
|
|
354
|
+
perform(action: Action): Promise<void>;
|
|
355
|
+
/** 路由 URL — 将 URL 解析为 Intent + Action */
|
|
356
|
+
routeUrl(url: string): RouteMatch | null;
|
|
357
|
+
/** 记录页面访问事件 */
|
|
358
|
+
didEnterPage(page: BasePage): void;
|
|
359
|
+
/** 注册 Action 处理器 */
|
|
360
|
+
onAction<A extends Action>(kind: string, handler: ActionHandler<A>): void;
|
|
361
|
+
/** 注册 Intent Controller */
|
|
362
|
+
registerIntent(controller: IntentController): void;
|
|
363
|
+
/** 注册 beforeLoad 守卫(路由匹配后、数据加载前) */
|
|
364
|
+
beforeLoad(guard: BeforeLoadGuard): void;
|
|
365
|
+
/** 注册 afterLoad 守卫(数据加载后、渲染前) */
|
|
366
|
+
afterLoad(guard: AfterLoadGuard): void;
|
|
367
|
+
/** 执行所有 beforeLoad 守卫(全局 → 路由级) */
|
|
368
|
+
runBeforeLoad(ctx: NavigationContext, routeGuards?: BeforeLoadGuard[]): Promise<MiddlewareResult>;
|
|
369
|
+
/** 执行所有 afterLoad 守卫(全局 → 路由级) */
|
|
370
|
+
runAfterLoad(ctx: PostLoadContext, routeGuards?: AfterLoadGuard[]): Promise<MiddlewareResult>;
|
|
371
|
+
/** 销毁 Framework 实例 */
|
|
372
|
+
dispose(): void;
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region ../core/src/models/shelf.d.ts
|
|
376
|
+
interface BaseShelf {
|
|
377
|
+
id: string;
|
|
378
|
+
shelfType: string;
|
|
379
|
+
title?: string;
|
|
380
|
+
subtitle?: string;
|
|
381
|
+
seeAllAction?: Action;
|
|
382
|
+
isHorizontal?: boolean;
|
|
383
|
+
}
|
|
384
|
+
interface BaseItem {
|
|
385
|
+
id: string;
|
|
386
|
+
itemType: string;
|
|
387
|
+
clickAction?: Action;
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region ../core/src/prefetched-intents/stable-stringify.d.ts
|
|
391
|
+
/**
|
|
392
|
+
* stableStringify — 确定性 JSON 序列化(keys 按字母排序)
|
|
393
|
+
*
|
|
394
|
+
* 用作缓存 key:相同内容的对象始终产生相同字符串。
|
|
395
|
+
*/
|
|
396
|
+
declare function stableStringify(obj: unknown, _seen?: Set<object>): string;
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region ../core/src/http/client.d.ts
|
|
399
|
+
/**
|
|
400
|
+
* HttpClient — 通用 HTTP 客户端基类
|
|
401
|
+
*
|
|
402
|
+
* 为 API Client 提供标准化的 HTTP 请求能力。
|
|
403
|
+
* 子类继承后只需关注业务端点定义,不需要重复实现 fetch / JSON 解析 / 错误处理。
|
|
404
|
+
*/
|
|
405
|
+
/** HTTP 请求错误 */
|
|
406
|
+
declare class HttpError extends Error {
|
|
407
|
+
readonly status: number;
|
|
408
|
+
readonly statusText: string;
|
|
409
|
+
readonly body?: string | undefined;
|
|
410
|
+
constructor(status: number, statusText: string, body?: string | undefined);
|
|
411
|
+
}
|
|
412
|
+
/** HttpClient 构造配置 */
|
|
413
|
+
interface HttpClientConfig {
|
|
414
|
+
/** API base URL(如 "/api" 或 "https://example.com/api") */
|
|
415
|
+
baseUrl: string;
|
|
416
|
+
/** 默认请求头 */
|
|
417
|
+
defaultHeaders?: Record<string, string>;
|
|
418
|
+
/** 自定义 fetch 实现(便于测试或 SSR) */
|
|
419
|
+
fetch?: typeof globalThis.fetch;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* 通用 HTTP 客户端基类
|
|
423
|
+
*
|
|
424
|
+
* 使用方式: 创建子类继承 HttpClient,定义业务方法调用 this.get() / this.post() 等。
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```ts
|
|
428
|
+
* class MyApiClient extends HttpClient {
|
|
429
|
+
* async getUser(id: string) {
|
|
430
|
+
* return this.get<User>(`/users/${id}`);
|
|
431
|
+
* }
|
|
432
|
+
* }
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
declare abstract class HttpClient {
|
|
436
|
+
protected readonly baseUrl: string;
|
|
437
|
+
protected readonly defaultHeaders: Record<string, string>;
|
|
438
|
+
protected readonly fetchFn: typeof globalThis.fetch;
|
|
439
|
+
constructor(config: HttpClientConfig);
|
|
440
|
+
/** GET 请求,返回解析后的 JSON */
|
|
441
|
+
protected get<T>(path: string, params?: Record<string, string>): Promise<T>;
|
|
442
|
+
/** POST 请求,自动序列化 body 为 JSON */
|
|
443
|
+
protected post<T>(path: string, body?: unknown, params?: Record<string, string>): Promise<T>;
|
|
444
|
+
/** PUT 请求 */
|
|
445
|
+
protected put<T>(path: string, body?: unknown, params?: Record<string, string>): Promise<T>;
|
|
446
|
+
/** DELETE 请求 */
|
|
447
|
+
protected del<T>(path: string, params?: Record<string, string>): Promise<T>;
|
|
448
|
+
/**
|
|
449
|
+
* 底层请求方法 — 子类可覆写以自定义行为
|
|
450
|
+
*
|
|
451
|
+
* 自动处理:
|
|
452
|
+
* - URL 拼接 (baseUrl + path + params)
|
|
453
|
+
* - 默认 headers 合并
|
|
454
|
+
* - JSON body 序列化
|
|
455
|
+
* - 响应 JSON 解析
|
|
456
|
+
* - 非 2xx 状态码抛出 HttpError
|
|
457
|
+
*/
|
|
458
|
+
protected request<T>(method: string, path: string, options?: {
|
|
459
|
+
params?: Record<string, string>;
|
|
460
|
+
body?: unknown;
|
|
461
|
+
headers?: Record<string, string>;
|
|
462
|
+
}): Promise<T>;
|
|
463
|
+
/** 构建完整 URL — 子类可覆写以自定义 URL 拼接逻辑 */
|
|
464
|
+
protected buildUrl(path: string, params?: Record<string, string>): string;
|
|
465
|
+
}
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region ../core/src/intents/base-controller.d.ts
|
|
468
|
+
/**
|
|
469
|
+
* 抽象 Controller 基类
|
|
470
|
+
*
|
|
471
|
+
* 统一处理:
|
|
472
|
+
* - 类型安全的参数提取 (TParams)
|
|
473
|
+
* - 返回类型约束 (TResult)
|
|
474
|
+
* - try/catch 错误处理 + 可选 fallback
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* ```ts
|
|
478
|
+
* class ProductController extends BaseController<{ productId: string }, ProductPage> {
|
|
479
|
+
* readonly intentId = "product-page";
|
|
480
|
+
*
|
|
481
|
+
* async execute(params: { productId: string }, container: Container) {
|
|
482
|
+
* const api = container.resolve<ApiClient>("api");
|
|
483
|
+
* return api.getProduct(params.productId);
|
|
484
|
+
* }
|
|
485
|
+
*
|
|
486
|
+
* fallback(params: { productId: string }, error: Error) {
|
|
487
|
+
* return getMockProduct(params.productId);
|
|
488
|
+
* }
|
|
489
|
+
* }
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
declare abstract class BaseController<TParams extends Record<string, string | undefined> = Record<string, string>, TResult = unknown> implements IntentController<TResult> {
|
|
493
|
+
/** Controller 对应的 Intent ID */
|
|
494
|
+
abstract readonly intentId: string;
|
|
495
|
+
/**
|
|
496
|
+
* 执行业务逻辑 — 子类必须实现
|
|
497
|
+
*
|
|
498
|
+
* @param params - Intent 参数(已类型化)
|
|
499
|
+
* @param container - DI 容器
|
|
500
|
+
* @returns 页面数据
|
|
501
|
+
*/
|
|
502
|
+
abstract execute(params: TParams, container: Container): Promise<TResult> | TResult;
|
|
503
|
+
/**
|
|
504
|
+
* 错误回退 — 子类可选覆写
|
|
505
|
+
*
|
|
506
|
+
* 当 execute() 抛出异常时调用。
|
|
507
|
+
* 默认行为: 重新抛出原始错误。
|
|
508
|
+
*
|
|
509
|
+
* @param params - Intent 参数
|
|
510
|
+
* @param error - execute() 抛出的错误
|
|
511
|
+
* @returns 回退数据
|
|
512
|
+
*/
|
|
513
|
+
fallback(params: TParams, error: Error): Promise<TResult> | TResult;
|
|
514
|
+
/**
|
|
515
|
+
* IntentController.perform() 实现
|
|
516
|
+
*
|
|
517
|
+
* 自动 try/catch → fallback 模式。
|
|
518
|
+
*/
|
|
519
|
+
perform(intent: Intent<TResult>, container: Container): Promise<TResult>;
|
|
520
|
+
}
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region ../core/src/data/mapper.d.ts
|
|
523
|
+
/**
|
|
524
|
+
* Mapper 类型工具 — 标准化数据转换管线
|
|
525
|
+
*
|
|
526
|
+
* 提供类型约定和组合函数,让 API 响应 → 页面模型 的转换有统一的签名模式。
|
|
527
|
+
*/
|
|
528
|
+
/** 同步映射函数 */
|
|
529
|
+
type Mapper<TInput, TOutput> = (input: TInput) => TOutput;
|
|
530
|
+
/** 异步映射函数 */
|
|
531
|
+
type AsyncMapper<TInput, TOutput> = (input: TInput) => TOutput | Promise<TOutput>;
|
|
532
|
+
/**
|
|
533
|
+
* 组合两个同步 Mapper: A → B → C
|
|
534
|
+
*/
|
|
535
|
+
declare function pipe<A, B, C>(m1: Mapper<A, B>, m2: Mapper<B, C>): Mapper<A, C>;
|
|
536
|
+
/**
|
|
537
|
+
* 组合三个同步 Mapper: A → B → C → D
|
|
538
|
+
*/
|
|
539
|
+
declare function pipe<A, B, C, D>(m1: Mapper<A, B>, m2: Mapper<B, C>, m3: Mapper<C, D>): Mapper<A, D>;
|
|
540
|
+
/**
|
|
541
|
+
* 组合四个同步 Mapper: A → B → C → D → E
|
|
542
|
+
*/
|
|
543
|
+
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>;
|
|
544
|
+
/**
|
|
545
|
+
* 组合任意数量的同步 Mapper
|
|
546
|
+
*/
|
|
547
|
+
declare function pipe(...mappers: Mapper<unknown, unknown>[]): Mapper<unknown, unknown>;
|
|
548
|
+
/**
|
|
549
|
+
* 组合两个可能异步的 Mapper: A → B → C
|
|
550
|
+
*/
|
|
551
|
+
declare function pipeAsync<A, B, C>(m1: AsyncMapper<A, B>, m2: AsyncMapper<B, C>): AsyncMapper<A, C>;
|
|
552
|
+
/**
|
|
553
|
+
* 组合三个可能异步的 Mapper
|
|
554
|
+
*/
|
|
555
|
+
declare function pipeAsync<A, B, C, D>(m1: AsyncMapper<A, B>, m2: AsyncMapper<B, C>, m3: AsyncMapper<C, D>): AsyncMapper<A, D>;
|
|
556
|
+
/**
|
|
557
|
+
* 将一个 Mapper 应用到数组的每个元素
|
|
558
|
+
*/
|
|
559
|
+
declare function mapEach<TInput, TOutput>(mapper: Mapper<TInput, TOutput>): Mapper<TInput[], TOutput[]>;
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region ../core/src/bootstrap/define-routes.d.ts
|
|
562
|
+
/** 渲染模式 */
|
|
563
|
+
type RenderMode = "ssr" | "csr" | "prerender";
|
|
564
|
+
/** 单条路由定义 */
|
|
565
|
+
interface RouteDefinition {
|
|
566
|
+
/** URL pattern (如 "/product/:productId") */
|
|
567
|
+
path: string;
|
|
568
|
+
/** Intent ID (如 "product-page") */
|
|
569
|
+
intentId: string;
|
|
570
|
+
/**
|
|
571
|
+
* Controller 实例(可选)。
|
|
572
|
+
* 同一个 intentId 的多条路由只需在第一条提供 controller。
|
|
573
|
+
*/
|
|
574
|
+
controller?: IntentController;
|
|
575
|
+
/**
|
|
576
|
+
* 渲染模式(可选,默认 "ssr")。
|
|
577
|
+
* - "ssr": 服务端渲染(默认)
|
|
578
|
+
* - "csr": 客户端渲染(返回空壳 HTML,由客户端 JS 渲染)
|
|
579
|
+
* - "prerender": 预渲染(构建时生成静态 HTML + ISR 缓存)
|
|
580
|
+
*/
|
|
581
|
+
renderMode?: RenderMode;
|
|
582
|
+
/**
|
|
583
|
+
* 路由级 beforeLoad 守卫(可选)。
|
|
584
|
+
* 在全局守卫之后执行,仅对匹配此路由的请求生效。
|
|
585
|
+
*/
|
|
586
|
+
beforeLoad?: BeforeLoadGuard[];
|
|
587
|
+
/**
|
|
588
|
+
* 路由级 afterLoad 守卫(可选)。
|
|
589
|
+
* 在全局守卫之后执行,仅对匹配此路由的请求生效。
|
|
590
|
+
*/
|
|
591
|
+
afterLoad?: AfterLoadGuard[];
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* 声明式注册路由和 Controller
|
|
595
|
+
*
|
|
596
|
+
* - 自动去重: 同一 intentId 的 controller 只注册一次
|
|
597
|
+
* - 路由和 controller 在同一个配置数组中,方便检查一致性
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```ts
|
|
601
|
+
* defineRoutes(framework, [
|
|
602
|
+
* { path: "/", intentId: "home", controller: new HomeController() },
|
|
603
|
+
* { path: "/product/:id", intentId: "product", controller: new ProductController() },
|
|
604
|
+
* { path: "/search", intentId: "search", controller: new SearchController() },
|
|
605
|
+
* { path: "/charts/:type", intentId: "charts", controller: new ChartsController() },
|
|
606
|
+
* { path: "/charts", intentId: "charts" }, // 同 intentId,不需要重复 controller
|
|
607
|
+
* ]);
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
declare function defineRoutes(framework: Framework, definitions: RouteDefinition[]): void;
|
|
611
|
+
//#endregion
|
|
612
|
+
//#region ../core/src/utils/lru-map.d.ts
|
|
613
|
+
/**
|
|
614
|
+
* LruMap — 固定容量的 LRU 缓存
|
|
615
|
+
*/
|
|
616
|
+
declare class LruMap<K, V> {
|
|
617
|
+
private map;
|
|
618
|
+
private readonly capacity;
|
|
619
|
+
constructor(capacity: number);
|
|
620
|
+
get(key: K): V | undefined;
|
|
621
|
+
set(key: K, value: V): void;
|
|
622
|
+
has(key: K): boolean;
|
|
623
|
+
delete(key: K): boolean;
|
|
624
|
+
get size(): number;
|
|
625
|
+
clear(): void;
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region ../core/src/utils/optional.d.ts
|
|
629
|
+
/**
|
|
630
|
+
* Optional 类型工具
|
|
631
|
+
*/
|
|
632
|
+
type None = null | undefined;
|
|
633
|
+
type Optional<T> = T | None;
|
|
634
|
+
declare function isSome<T>(value: Optional<T>): value is T;
|
|
635
|
+
declare function isNone<T>(value: Optional<T>): value is None;
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region ../core/src/utils/url.d.ts
|
|
638
|
+
/**
|
|
639
|
+
* URL 工具函数
|
|
640
|
+
*/
|
|
641
|
+
/** 移除 URL scheme (https://, http://) */
|
|
642
|
+
declare function removeScheme(url: string): string;
|
|
643
|
+
/** 移除 URL host 部分,保留路径 */
|
|
644
|
+
declare function removeHost(url: string): string;
|
|
645
|
+
/** 移除 query 参数 */
|
|
646
|
+
declare function removeQueryParams(url: string): string;
|
|
647
|
+
/** 获取 URL 的基础路径(无 query、hash) */
|
|
648
|
+
declare function getBaseUrl(url: string): string;
|
|
649
|
+
/** 构建 URL(路径 + query 参数) */
|
|
650
|
+
declare function buildUrl(path: string, params?: Record<string, string | undefined>): string;
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region ../core/src/utils/uuid.d.ts
|
|
653
|
+
/**
|
|
654
|
+
* UUID v4 生成器
|
|
655
|
+
*/
|
|
656
|
+
declare function generateUuid(): string;
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region ../core/src/middleware/context.d.ts
|
|
659
|
+
interface ServerContextOptions {
|
|
660
|
+
url: string;
|
|
661
|
+
intent: Intent;
|
|
662
|
+
container: Container;
|
|
663
|
+
/** 原始 Request 对象(提取 cookie 和 header) */
|
|
664
|
+
request?: Request;
|
|
665
|
+
}
|
|
666
|
+
/** 从 Request 对象构建服务端上下文 */
|
|
667
|
+
declare function createServerContext(options: ServerContextOptions): NavigationContext;
|
|
668
|
+
interface BrowserContextOptions {
|
|
669
|
+
url: string;
|
|
670
|
+
intent: Intent;
|
|
671
|
+
container: Container;
|
|
672
|
+
}
|
|
673
|
+
/** 从 document.cookie 构建浏览器端上下文 */
|
|
674
|
+
declare function createBrowserContext(options: BrowserContextOptions): NavigationContext;
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region ../core/src/middleware/pipeline.d.ts
|
|
677
|
+
/** 执行 beforeLoad 守卫链 */
|
|
678
|
+
declare function runBeforeLoadGuards(guards: BeforeLoadGuard[], ctx: NavigationContext): Promise<MiddlewareResult>;
|
|
679
|
+
/** 执行 afterLoad 守卫链 */
|
|
680
|
+
declare function runAfterLoadGuards(guards: AfterLoadGuard[], ctx: PostLoadContext): Promise<MiddlewareResult>;
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region ../browser/src/action-handlers/external-url-action.d.ts
|
|
683
|
+
interface ExternalUrlDependencies {
|
|
684
|
+
framework: Framework;
|
|
685
|
+
log: Logger;
|
|
686
|
+
}
|
|
687
|
+
declare function registerExternalUrlHandler(deps: ExternalUrlDependencies): void;
|
|
688
|
+
//#endregion
|
|
689
|
+
//#region ../browser/src/action-handlers/flow-action.d.ts
|
|
690
|
+
/** UI 框架回调 — 解耦 Svelte store 等依赖 */
|
|
691
|
+
interface FlowActionCallbacks {
|
|
692
|
+
/** 导航后更新当前路径(替代 currentPath.set()) */
|
|
693
|
+
onNavigate(pathname: string): void;
|
|
694
|
+
/** 模态页面展示(替代 openModal()) */
|
|
695
|
+
onModal(page: BasePage): void;
|
|
696
|
+
}
|
|
697
|
+
/** 注册 FlowAction handler 所需的依赖 */
|
|
698
|
+
interface FlowActionDependencies {
|
|
699
|
+
framework: Framework;
|
|
700
|
+
log: Logger;
|
|
701
|
+
callbacks: FlowActionCallbacks;
|
|
702
|
+
/** 更新应用 UI 的回调,page 可以是 Promise */
|
|
703
|
+
updateApp: (props: {
|
|
704
|
+
page: Promise<BasePage> | BasePage;
|
|
705
|
+
isFirstPage?: boolean;
|
|
706
|
+
}) => void;
|
|
707
|
+
/** 获取可滚动页面元素,用于滚动位置保存/恢复 */
|
|
708
|
+
getScrollablePageElement?: () => HTMLElement | null;
|
|
709
|
+
}
|
|
710
|
+
declare function registerFlowActionHandler(deps: FlowActionDependencies): void;
|
|
711
|
+
//#endregion
|
|
712
|
+
//#region ../browser/src/action-handlers/register.d.ts
|
|
713
|
+
interface ActionHandlerDependencies {
|
|
714
|
+
framework: Framework;
|
|
715
|
+
log: Logger;
|
|
716
|
+
callbacks: FlowActionCallbacks;
|
|
717
|
+
updateApp: (props: {
|
|
718
|
+
page: Promise<BasePage> | BasePage;
|
|
719
|
+
isFirstPage?: boolean;
|
|
720
|
+
}) => void;
|
|
721
|
+
/** 获取可滚动页面元素,用于滚动位置保存/恢复 */
|
|
722
|
+
getScrollablePageElement?: () => HTMLElement | null;
|
|
723
|
+
}
|
|
724
|
+
declare function registerActionHandlers(deps: ActionHandlerDependencies): void;
|
|
725
|
+
//#endregion
|
|
726
|
+
//#region ../browser/src/start-app.d.ts
|
|
727
|
+
interface BrowserAppConfig {
|
|
728
|
+
/** 注册 controllers 和路由的引导函数 */
|
|
729
|
+
bootstrap: (framework: Framework) => void;
|
|
730
|
+
/** 默认语言(回退值) */
|
|
731
|
+
defaultLocale?: string;
|
|
732
|
+
/** DOM 挂载点 ID(默认 "app") */
|
|
733
|
+
mountId?: string;
|
|
734
|
+
/** 获取可滚动页面元素,用于滚动位置保存/恢复 */
|
|
735
|
+
getScrollablePageElement?: () => HTMLElement | null;
|
|
736
|
+
/**
|
|
737
|
+
* 挂载应用到 DOM
|
|
738
|
+
*
|
|
739
|
+
* 框架无关 — Svelte / React / Vue 均可通过此回调实现。
|
|
740
|
+
*
|
|
741
|
+
* @param target - DOM 挂载点
|
|
742
|
+
* @param context - Framework 实例 + 语言
|
|
743
|
+
* @returns 更新函数,用于后续页面切换
|
|
744
|
+
*/
|
|
745
|
+
mount: (target: HTMLElement, context: {
|
|
746
|
+
framework: Framework;
|
|
747
|
+
locale: string;
|
|
748
|
+
}) => (props: {
|
|
749
|
+
page: Promise<BasePage> | BasePage;
|
|
750
|
+
isFirstPage?: boolean;
|
|
751
|
+
}) => void;
|
|
752
|
+
/** FlowAction / ExternalUrl 回调 */
|
|
753
|
+
callbacks: FlowActionCallbacks;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* 启动客户端应用
|
|
757
|
+
*
|
|
758
|
+
* 自动执行 hydration 全流程。
|
|
759
|
+
*/
|
|
760
|
+
declare function startBrowserApp(config: BrowserAppConfig): Promise<void>;
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region ../browser/src/utils/history.d.ts
|
|
763
|
+
interface HistoryOptions {
|
|
764
|
+
getScrollablePageElement: () => HTMLElement | null;
|
|
765
|
+
}
|
|
766
|
+
declare class History<State> {
|
|
767
|
+
private readonly entries;
|
|
768
|
+
private readonly log;
|
|
769
|
+
private readonly getScrollablePageElement;
|
|
770
|
+
private currentStateId;
|
|
771
|
+
constructor(log: Logger, options: HistoryOptions, sizeLimit?: number);
|
|
772
|
+
replaceState(state: State, url: string): void;
|
|
773
|
+
pushState(state: State, url: string): void;
|
|
774
|
+
beforeTransition(): void;
|
|
775
|
+
onPopState(listener: (url: string, state?: State) => void | Promise<void>): void;
|
|
776
|
+
/** 仅推入 URL,不缓存页面状态(用于页面加载失败场景) */
|
|
777
|
+
pushUrl(url: string): void;
|
|
778
|
+
/** 仅替换 URL,不缓存页面状态(用于页面加载失败场景) */
|
|
779
|
+
replaceUrl(url: string): void;
|
|
780
|
+
updateState(update: (current?: State) => State): void;
|
|
781
|
+
private get scrollTop();
|
|
782
|
+
private set scrollTop(value);
|
|
783
|
+
}
|
|
784
|
+
//#endregion
|
|
785
|
+
//#region ../browser/src/utils/try-scroll.d.ts
|
|
786
|
+
declare function tryScroll(log: Logger, getScrollableElement: () => HTMLElement | null, scrollY: number): void;
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region ../browser/src/server-data.d.ts
|
|
789
|
+
/**
|
|
790
|
+
* 从 DOM 反序列化服务端嵌入的数据。
|
|
791
|
+
* 读取 `<script id="serialized-server-data">` 的内容并移除标签。
|
|
792
|
+
*/
|
|
793
|
+
declare function deserializeServerData(): PrefetchedIntent[] | undefined;
|
|
794
|
+
/**
|
|
795
|
+
* 从 DOM 提取 SSR 数据并构建 PrefetchedIntents 实例。
|
|
796
|
+
* 替代原来的 PrefetchedIntents.fromDom()。
|
|
797
|
+
*/
|
|
798
|
+
declare function createPrefetchedIntentsFromDom(): PrefetchedIntents;
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region ../ssr/src/render.d.ts
|
|
801
|
+
interface SSRRenderOptions {
|
|
802
|
+
/** 请求 URL */
|
|
803
|
+
url: string;
|
|
804
|
+
/** Framework 配置(含路由注册等) */
|
|
805
|
+
frameworkConfig: FrameworkConfig;
|
|
806
|
+
/** 注册 controllers 和路由的引导函数 */
|
|
807
|
+
bootstrap: (framework: Framework) => void;
|
|
808
|
+
/** 获取错误页面 */
|
|
809
|
+
getErrorPage: (status: number, message: string) => BasePage;
|
|
810
|
+
/** 应用层渲染函数(如 Svelte SSR render) */
|
|
811
|
+
renderApp: (page: BasePage, framework: Framework) => SSRAppResult;
|
|
812
|
+
/** 可选的 SSR 请求上下文(如自定义 fetch) */
|
|
813
|
+
ssrContext?: SSRContext;
|
|
814
|
+
}
|
|
815
|
+
/** SSR 请求级上下文 */
|
|
816
|
+
interface SSRContext {
|
|
817
|
+
/** 自定义 fetch(如 Hono 内部路由回环) */
|
|
818
|
+
fetch?: typeof globalThis.fetch;
|
|
819
|
+
/** 原始 Request 对象(用于中间件读取 cookie/header) */
|
|
820
|
+
request?: Request;
|
|
821
|
+
}
|
|
822
|
+
interface SSRAppResult {
|
|
823
|
+
html: string;
|
|
824
|
+
head: string;
|
|
825
|
+
css: string;
|
|
826
|
+
}
|
|
827
|
+
interface SSRRenderResult {
|
|
828
|
+
html: string;
|
|
829
|
+
head: string;
|
|
830
|
+
css: string;
|
|
831
|
+
serverData: PrefetchedIntent[];
|
|
832
|
+
/** 该路由的渲染模式(由 Router 返回) */
|
|
833
|
+
renderMode?: string;
|
|
834
|
+
/** 中间件要求的重定向(服务端应返回 HTTP 301/302) */
|
|
835
|
+
redirect?: {
|
|
836
|
+
url: string;
|
|
837
|
+
status: number;
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
declare function ssrRender(options: SSRRenderOptions): Promise<SSRRenderResult>;
|
|
841
|
+
//#endregion
|
|
842
|
+
//#region ../ssr/src/create-render.d.ts
|
|
843
|
+
interface SSRRenderConfig {
|
|
844
|
+
/** 注册 controllers 和路由的引导函数 */
|
|
845
|
+
bootstrap: (framework: Framework) => void;
|
|
846
|
+
/** 获取错误页面 */
|
|
847
|
+
getErrorPage: (status: number, message: string) => BasePage;
|
|
848
|
+
/**
|
|
849
|
+
* 应用层渲染函数
|
|
850
|
+
*
|
|
851
|
+
* @param page - 当前页面数据
|
|
852
|
+
* @param locale - 当前语言
|
|
853
|
+
* @returns SSR 渲染结果 { html, head, css }
|
|
854
|
+
*/
|
|
855
|
+
renderApp: (page: BasePage, locale: string) => SSRAppResult;
|
|
856
|
+
/** Framework 构造配置(可选) */
|
|
857
|
+
frameworkConfig?: FrameworkConfig;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* 创建 render 函数
|
|
861
|
+
*
|
|
862
|
+
* @returns `render(url, locale, ssrContext?)` — 供 @finesoft/server SSRModule 使用
|
|
863
|
+
*/
|
|
864
|
+
declare function createSSRRender(config: SSRRenderConfig): (url: string, locale: string, ssrContext?: SSRContext) => Promise<SSRRenderResult>;
|
|
865
|
+
//#endregion
|
|
866
|
+
//#region ../ssr/src/inject.d.ts
|
|
867
|
+
/**
|
|
868
|
+
* injectSSRContent — 将 SSR 渲染结果注入 HTML 模板
|
|
869
|
+
*/
|
|
870
|
+
/** SSR HTML 模板占位符常量 */
|
|
871
|
+
declare const SSR_PLACEHOLDERS: {
|
|
872
|
+
readonly LANG: "<!--ssr-lang-->";
|
|
873
|
+
readonly HEAD: "<!--ssr-head-->";
|
|
874
|
+
readonly BODY: "<!--ssr-body-->";
|
|
875
|
+
readonly DATA: "<!--ssr-data-->";
|
|
876
|
+
};
|
|
877
|
+
interface InjectSSROptions {
|
|
878
|
+
template: string;
|
|
879
|
+
locale: string;
|
|
880
|
+
head: string;
|
|
881
|
+
css: string;
|
|
882
|
+
html: string;
|
|
883
|
+
serializedData: string;
|
|
884
|
+
}
|
|
885
|
+
declare function injectSSRContent(options: InjectSSROptions): string;
|
|
886
|
+
/**
|
|
887
|
+
* CSR 空壳注入 — 只替换 lang,清空 body/head/data 占位符
|
|
888
|
+
* 用于 renderMode === "csr" 的路由
|
|
889
|
+
*/
|
|
890
|
+
declare function injectCSRShell(template: string, locale: string): string;
|
|
891
|
+
//#endregion
|
|
892
|
+
//#region ../ssr/src/server-data.d.ts
|
|
893
|
+
declare function serializeServerData(data: PrefetchedIntent[]): string;
|
|
894
|
+
//#endregion
|
|
895
|
+
//#region ../server/src/proxy.d.ts
|
|
896
|
+
/** 代理路由认证配置 */
|
|
897
|
+
interface ProxyAuthConfig {
|
|
898
|
+
/** 认证类型 */
|
|
899
|
+
type: "bearer" | "basic";
|
|
900
|
+
/** 环境变量名称(运行时从 process.env 读取) */
|
|
901
|
+
envKey: string;
|
|
902
|
+
}
|
|
903
|
+
/** 声明式代理路由配置 */
|
|
904
|
+
interface ProxyRouteConfig {
|
|
905
|
+
/** URL 前缀,如 "/api/apple"(必须以 "/" 开头) */
|
|
906
|
+
prefix: string;
|
|
907
|
+
/** 代理目标地址(必须以 "https://" 开头) */
|
|
908
|
+
target: string;
|
|
909
|
+
/** HTTP 方法(默认 ["all"]) */
|
|
910
|
+
methods?: ("all" | "get" | "post" | "put" | "delete" | "patch")[];
|
|
911
|
+
/** 附加到代理请求的头部 */
|
|
912
|
+
headers?: Record<string, string>;
|
|
913
|
+
/** 认证配置 */
|
|
914
|
+
auth?: ProxyAuthConfig;
|
|
915
|
+
/** Cache-Control 响应头 */
|
|
916
|
+
cache?: string;
|
|
917
|
+
/** 是否跟随重定向(默认 false) */
|
|
918
|
+
followRedirects?: boolean;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* 注册声明式代理路由到 Hono app(运行时使用:dev / preview / createServer)
|
|
922
|
+
*/
|
|
923
|
+
declare function registerProxyRoutes(app: Hono, configs: ProxyRouteConfig[]): void;
|
|
924
|
+
/**
|
|
925
|
+
* 生成代理路由的内联代码(用于 serverless/edge 入口,避免运行时依赖)
|
|
926
|
+
*/
|
|
927
|
+
declare function generateProxyCode(configs: ProxyRouteConfig[]): string;
|
|
928
|
+
//#endregion
|
|
929
|
+
//#region ../server/src/adapters/types.d.ts
|
|
930
|
+
/** 适配器上下文 — 由 vite-plugin 的 closeBundle 构造后传入 adapter.build() */
|
|
931
|
+
interface AdapterContext {
|
|
932
|
+
/** 项目根路径 */
|
|
933
|
+
root: string;
|
|
934
|
+
/** SSR 入口文件相对路径(如 "src/ssr.ts") */
|
|
935
|
+
ssrEntry: string;
|
|
936
|
+
/** setup 文件相对路径(如 "src/proxies.ts"),仅当 options.setup 为 string 时有值 */
|
|
937
|
+
setupPath?: string;
|
|
938
|
+
/** 路由定义入口文件(用于预渲染时加载路由),如 "src/lib/bootstrap.ts" */
|
|
939
|
+
bootstrapEntry?: string;
|
|
940
|
+
/** 支持的语言列表 */
|
|
941
|
+
locales: string[];
|
|
942
|
+
/** 默认语言 */
|
|
943
|
+
defaultLocale: string;
|
|
944
|
+
/** dist/client/index.html 的内容 */
|
|
945
|
+
templateHtml: string;
|
|
946
|
+
/** Vite 的 resolve 配置 */
|
|
947
|
+
resolvedResolve: unknown;
|
|
948
|
+
/** Vite 的 css 配置 */
|
|
949
|
+
resolvedCss: unknown;
|
|
950
|
+
/**
|
|
951
|
+
* 按路由覆盖的渲染模式。
|
|
952
|
+
* key: 精确路径或 glob 模式,value: "ssr" | "csr" | "prerender"
|
|
953
|
+
*/
|
|
954
|
+
renderModes?: Record<string, string>;
|
|
955
|
+
/** 声明式代理路由配置 */
|
|
956
|
+
proxies?: ProxyRouteConfig[];
|
|
957
|
+
vite: any;
|
|
958
|
+
fs: typeof node_fs0;
|
|
959
|
+
path: {
|
|
960
|
+
resolve: (...args: string[]) => string;
|
|
961
|
+
join: (...args: string[]) => string;
|
|
962
|
+
};
|
|
963
|
+
/** 生成 serverless/edge function 入口源码 */
|
|
964
|
+
generateSSREntry(opts: GenerateSSREntryOptions): string;
|
|
965
|
+
/** 用 Vite SSR 模式构建 bundle */
|
|
966
|
+
buildBundle(opts: BuildBundleOptions): Promise<void>;
|
|
967
|
+
/** 复制 dist/client 静态资源到目标目录 */
|
|
968
|
+
copyStaticAssets(destDir: string, opts?: CopyStaticAssetsOptions): void;
|
|
969
|
+
}
|
|
970
|
+
interface GenerateSSREntryOptions {
|
|
971
|
+
/** 平台特定的导入语句(如 `import { handle } from "hono/vercel";`) */
|
|
972
|
+
platformImport: string;
|
|
973
|
+
/** 平台特定的导出语句(如 `export default handle(app);`) */
|
|
974
|
+
platformExport: string;
|
|
975
|
+
/**
|
|
976
|
+
* 平台特定的 ISR 缓存实现代码(可选)。
|
|
977
|
+
* 需提供 `async function platformCacheGet(url)` 返回 string|null,
|
|
978
|
+
* 和 `async function platformCacheSet(url, html)` 的函数定义。
|
|
979
|
+
* 不提供时使用内置的内存 Map 缓存。
|
|
980
|
+
*/
|
|
981
|
+
platformCache?: string;
|
|
982
|
+
/**
|
|
983
|
+
* 平台特定的响应后处理代码(可选)。
|
|
984
|
+
* 在 prerender 路由返回前执行,可用于设置 CDN 缓存头等。
|
|
985
|
+
* 代码中可使用变量 `c`(Hono Context)。
|
|
986
|
+
*/
|
|
987
|
+
platformPrerenderResponseHook?: string;
|
|
988
|
+
/**
|
|
989
|
+
* 平台特定的中间件代码(可选)。
|
|
990
|
+
* 插入在 catch-all GET 路由之前,可用于添加静态文件服务等。
|
|
991
|
+
* 代码中可使用变量 `app`(Hono 实例)。
|
|
992
|
+
*/
|
|
993
|
+
platformMiddleware?: string;
|
|
994
|
+
}
|
|
995
|
+
interface BuildBundleOptions {
|
|
996
|
+
/** 临时入口文件路径 */
|
|
997
|
+
entry: string;
|
|
998
|
+
/** 输出目录 */
|
|
999
|
+
outDir: string;
|
|
1000
|
+
/** 构建 target(默认 "node18") */
|
|
1001
|
+
target?: string;
|
|
1002
|
+
/** 输出文件名(默认 "index.mjs") */
|
|
1003
|
+
fileName?: string;
|
|
1004
|
+
/** 排除的模块(默认 ["vite", "esbuild", "rollup", "fsevents", "lightningcss"]) */
|
|
1005
|
+
external?: string[];
|
|
1006
|
+
/** 是否打包所有依赖(默认 true) */
|
|
1007
|
+
noExternal?: boolean;
|
|
1008
|
+
}
|
|
1009
|
+
interface CopyStaticAssetsOptions {
|
|
1010
|
+
/** 是否排除 index.html(默认 true) */
|
|
1011
|
+
excludeHtml?: boolean;
|
|
1012
|
+
}
|
|
1013
|
+
/** 适配器接口 */
|
|
1014
|
+
interface Adapter {
|
|
1015
|
+
/** 适配器名称(用于日志) */
|
|
1016
|
+
name: string;
|
|
1017
|
+
/** 生成目标平台部署产物 */
|
|
1018
|
+
build(ctx: AdapterContext): Promise<void>;
|
|
1019
|
+
}
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region ../server/src/adapters/auto.d.ts
|
|
1022
|
+
declare function autoAdapter(): Adapter;
|
|
1023
|
+
//#endregion
|
|
1024
|
+
//#region ../server/src/adapters/cloudflare.d.ts
|
|
1025
|
+
declare function cloudflareAdapter(): Adapter;
|
|
1026
|
+
//#endregion
|
|
1027
|
+
//#region ../server/src/adapters/netlify.d.ts
|
|
1028
|
+
declare function netlifyAdapter(): Adapter;
|
|
1029
|
+
//#endregion
|
|
1030
|
+
//#region ../server/src/adapters/node.d.ts
|
|
1031
|
+
declare function nodeAdapter(): Adapter;
|
|
1032
|
+
//#endregion
|
|
1033
|
+
//#region ../server/src/adapters/resolve.d.ts
|
|
1034
|
+
declare function resolveAdapter(value: string | Adapter): Adapter;
|
|
1035
|
+
//#endregion
|
|
1036
|
+
//#region ../server/src/adapters/static.d.ts
|
|
1037
|
+
interface StaticAdapterOptions {
|
|
1038
|
+
/**
|
|
1039
|
+
* 导出 routes 数组的文件路径(相对于项目根目录)。
|
|
1040
|
+
* 默认 "src/lib/bootstrap.ts"。
|
|
1041
|
+
* 文件需 export 一个 RouteDefinition[] 类型的 routes 变量。
|
|
1042
|
+
*/
|
|
1043
|
+
routesExport?: string;
|
|
1044
|
+
/**
|
|
1045
|
+
* 额外的动态路由 URL(带具体参数值),如:
|
|
1046
|
+
* ["/product/123", "/list/games"]
|
|
1047
|
+
*/
|
|
1048
|
+
dynamicRoutes?: string[];
|
|
1049
|
+
}
|
|
1050
|
+
declare function staticAdapter(opts?: StaticAdapterOptions): Adapter;
|
|
1051
|
+
//#endregion
|
|
1052
|
+
//#region ../server/src/adapters/vercel.d.ts
|
|
1053
|
+
declare function vercelAdapter(): Adapter;
|
|
1054
|
+
//#endregion
|
|
1055
|
+
//#region ../server/src/app.d.ts
|
|
1056
|
+
interface SSRModule {
|
|
1057
|
+
render: (url: string, locale: string, ssrContext?: {
|
|
1058
|
+
fetch?: typeof globalThis.fetch;
|
|
1059
|
+
request?: Request;
|
|
1060
|
+
}) => Promise<{
|
|
1061
|
+
html: string;
|
|
1062
|
+
head: string;
|
|
1063
|
+
css: string;
|
|
1064
|
+
serverData: unknown;
|
|
1065
|
+
renderMode?: string;
|
|
1066
|
+
redirect?: {
|
|
1067
|
+
url: string;
|
|
1068
|
+
status: number;
|
|
1069
|
+
};
|
|
1070
|
+
}>;
|
|
1071
|
+
serializeServerData: (data: unknown) => string;
|
|
1072
|
+
}
|
|
1073
|
+
interface SSRAppOptions {
|
|
1074
|
+
/** 项目根路径 */
|
|
1075
|
+
root: string;
|
|
1076
|
+
/** Vite dev server(仅开发模式) */
|
|
1077
|
+
vite?: ViteDevServer;
|
|
1078
|
+
/** 是否生产环境 */
|
|
1079
|
+
isProduction: boolean;
|
|
1080
|
+
/** SSR 入口文件路径(开发用,如 "/src/ssr.ts") */
|
|
1081
|
+
ssrEntryPath?: string;
|
|
1082
|
+
/** 生产环境 SSR 模块路径(如 "../dist/server/ssr.js") */
|
|
1083
|
+
ssrProductionModule?: string;
|
|
1084
|
+
/** 支持的语言列表 */
|
|
1085
|
+
supportedLocales?: string[];
|
|
1086
|
+
/** 默认语言 */
|
|
1087
|
+
defaultLocale?: string;
|
|
1088
|
+
/**
|
|
1089
|
+
* 父级 Hono app 的 fetch 函数,用于 SSR 内部路由回环。
|
|
1090
|
+
* SSR 渲染时,控制器的 fetch 请求(如 /api/apple/*)会通过此函数
|
|
1091
|
+
* 直接在进程内路由到代理 handler,避免网络自请求死锁。
|
|
1092
|
+
*/
|
|
1093
|
+
parentFetch?: (request: Request) => Response | Promise<Response>;
|
|
1094
|
+
/**
|
|
1095
|
+
* 按路由覆盖渲染模式(精确路径或 glob 模式)。
|
|
1096
|
+
* 优先级高于路由级 renderMode。
|
|
1097
|
+
*/
|
|
1098
|
+
renderModes?: Record<string, string>;
|
|
1099
|
+
}
|
|
1100
|
+
declare function createSSRApp(options: SSRAppOptions): Hono;
|
|
1101
|
+
//#endregion
|
|
1102
|
+
//#region ../server/src/runtime.d.ts
|
|
1103
|
+
/**
|
|
1104
|
+
* runtime — 运行时检测 + 项目根路径推导
|
|
1105
|
+
*/
|
|
1106
|
+
interface RuntimeInfo {
|
|
1107
|
+
isDeno: boolean;
|
|
1108
|
+
isBun: boolean;
|
|
1109
|
+
isVercel: boolean;
|
|
1110
|
+
isProduction: boolean;
|
|
1111
|
+
}
|
|
1112
|
+
/** 检测当前运行时环境 */
|
|
1113
|
+
declare function detectRuntime(): RuntimeInfo;
|
|
1114
|
+
/**
|
|
1115
|
+
* 从 `import.meta.url` 推导项目根路径
|
|
1116
|
+
*
|
|
1117
|
+
* @param importMetaUrl - 调用方的 `import.meta.url`
|
|
1118
|
+
* @param levelsUp - 向上移动多少级(默认 0,即调用方所在目录就是项目根)
|
|
1119
|
+
*/
|
|
1120
|
+
declare function resolveRoot(importMetaUrl: string, levelsUp?: number): Promise<string>;
|
|
1121
|
+
//#endregion
|
|
1122
|
+
//#region ../server/src/create-server.d.ts
|
|
1123
|
+
interface ServerConfig {
|
|
1124
|
+
/** 项目根路径(默认 process.cwd()) */
|
|
1125
|
+
root?: string;
|
|
1126
|
+
/** 支持的语言列表 */
|
|
1127
|
+
locales?: string[];
|
|
1128
|
+
/** 默认语言 */
|
|
1129
|
+
defaultLocale?: string;
|
|
1130
|
+
/** 端口号(默认 3000) */
|
|
1131
|
+
port?: number;
|
|
1132
|
+
/** 注册自定义路由(在 SSR catch-all 之前调用,但在声明式代理之后) */
|
|
1133
|
+
setup?: (app: Hono) => void | Promise<void>;
|
|
1134
|
+
/** 声明式代理路由配置 */
|
|
1135
|
+
proxies?: ProxyRouteConfig[];
|
|
1136
|
+
/** SSR 相关选项(透传给 createSSRApp) */
|
|
1137
|
+
ssr?: Pick<SSRAppOptions, "ssrEntryPath" | "ssrProductionModule">;
|
|
1138
|
+
}
|
|
1139
|
+
interface ServerInstance {
|
|
1140
|
+
app: Hono;
|
|
1141
|
+
vite?: ViteDevServer;
|
|
1142
|
+
runtime: RuntimeInfo;
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* 创建并启动 SSR 服务器
|
|
1146
|
+
*
|
|
1147
|
+
* @example
|
|
1148
|
+
* ```ts
|
|
1149
|
+
* const { app } = await createServer({
|
|
1150
|
+
* locales: ["zh", "en"],
|
|
1151
|
+
* setup: (app) => registerProxies(app),
|
|
1152
|
+
* });
|
|
1153
|
+
* export { app };
|
|
1154
|
+
* ```
|
|
1155
|
+
*/
|
|
1156
|
+
declare function createServer(config?: ServerConfig): Promise<ServerInstance>;
|
|
1157
|
+
//#endregion
|
|
1158
|
+
//#region ../server/src/locale.d.ts
|
|
1159
|
+
/**
|
|
1160
|
+
* Accept-Language 解析
|
|
1161
|
+
*/
|
|
1162
|
+
declare function parseAcceptLanguage(header: string | undefined, supported?: string[], fallback?: string): string;
|
|
1163
|
+
//#endregion
|
|
1164
|
+
//#region ../server/src/start.d.ts
|
|
1165
|
+
interface StartServerOptions {
|
|
1166
|
+
/** 最终的 Hono app(已包含 SSR + 自定义路由) */
|
|
1167
|
+
app: Hono;
|
|
1168
|
+
/** 项目根路径 */
|
|
1169
|
+
root: string;
|
|
1170
|
+
/** 端口号 */
|
|
1171
|
+
port?: number;
|
|
1172
|
+
/** 是否生产环境 */
|
|
1173
|
+
isProduction: boolean;
|
|
1174
|
+
/** Vite dev server(仅开发模式传入) */
|
|
1175
|
+
vite?: ViteDevServer;
|
|
1176
|
+
/** 运行时信息(可选,不传时自动检测) */
|
|
1177
|
+
runtime?: RuntimeInfo;
|
|
1178
|
+
/** 已注册的路由列表(用于启动日志) */
|
|
1179
|
+
routes?: string[];
|
|
1180
|
+
/** 支持的语言列表(用于启动日志) */
|
|
1181
|
+
locales?: string[];
|
|
1182
|
+
/** SSR 入口路径(用于启动日志) */
|
|
1183
|
+
ssrEntryPath?: string;
|
|
1184
|
+
}
|
|
1185
|
+
declare function startServer(options: StartServerOptions): Promise<{
|
|
1186
|
+
vite?: ViteDevServer;
|
|
1187
|
+
}>;
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region ../server/src/vite-plugin.d.ts
|
|
1190
|
+
interface FinesoftFrontViteOptions {
|
|
1191
|
+
/** 支持的语言列表 */
|
|
1192
|
+
locales?: string[];
|
|
1193
|
+
/** 默认语言 */
|
|
1194
|
+
defaultLocale?: string;
|
|
1195
|
+
/** SSR 配置 */
|
|
1196
|
+
ssr?: {
|
|
1197
|
+
/** SSR 入口文件路径(默认 "src/ssr.ts") */entry?: string;
|
|
1198
|
+
};
|
|
1199
|
+
/**
|
|
1200
|
+
* 声明式代理路由配置。
|
|
1201
|
+
* 框架统一执行路径校验(SSRF 防护)、Host 限制、错误处理、响应头控制。
|
|
1202
|
+
* 代理路由在 setup 之前注册,优先级高于自定义路由。
|
|
1203
|
+
*/
|
|
1204
|
+
proxies?: ProxyRouteConfig[];
|
|
1205
|
+
/**
|
|
1206
|
+
* 注册自定义路由(非代理类)。
|
|
1207
|
+
* - 传入 Function:仅 dev/preview 时可用。
|
|
1208
|
+
* - 传入 string(文件路径):dev/preview/adapter 均可用,
|
|
1209
|
+
* 文件需 export default 一个 (app: Hono) => void 函数。
|
|
1210
|
+
* 注意:代理路由请使用 proxies 选项,不要在 setup 中手写代理。
|
|
1211
|
+
*/
|
|
1212
|
+
setup?: ((app: Hono) => void | Promise<void>) | string;
|
|
1213
|
+
/**
|
|
1214
|
+
* 部署适配器。
|
|
1215
|
+
* - 字符串快捷方式:"vercel" | "cloudflare" | "netlify" | "node" | "static" | "auto"
|
|
1216
|
+
* - 自定义 Adapter 对象:{ name, build(ctx) }
|
|
1217
|
+
* - 不设置则不生成部署产物
|
|
1218
|
+
*/
|
|
1219
|
+
adapter?: string | Adapter;
|
|
1220
|
+
/**
|
|
1221
|
+
* 按路由覆盖渲染模式(优先级高于 RouteDefinition.renderMode)。
|
|
1222
|
+
* key: 精确路径或 glob 模式,如 "/search" 或 "/blog/*"
|
|
1223
|
+
* value: "ssr" | "csr" | "prerender"
|
|
1224
|
+
*
|
|
1225
|
+
* @example
|
|
1226
|
+
* ```ts
|
|
1227
|
+
* renderModes: {
|
|
1228
|
+
* "/search": "csr",
|
|
1229
|
+
* "/blog/*": "prerender",
|
|
1230
|
+
* }
|
|
1231
|
+
* ```
|
|
1232
|
+
*/
|
|
1233
|
+
renderModes?: Record<string, "ssr" | "csr" | "prerender">;
|
|
1234
|
+
/**
|
|
1235
|
+
* 路由定义入口文件(用于预渲染时加载路由),默认 "src/lib/bootstrap.ts"。
|
|
1236
|
+
* 如果项目不使用声明式路由定义,可以不设置。
|
|
1237
|
+
*/
|
|
1238
|
+
bootstrapEntry?: string;
|
|
1239
|
+
}
|
|
1240
|
+
declare function finesoftFrontViteConfig(options?: FinesoftFrontViteOptions): {
|
|
1241
|
+
name: string;
|
|
1242
|
+
config(userConfig: Record<string, any>, env: {
|
|
1243
|
+
command: string;
|
|
1244
|
+
}): Record<string, any>;
|
|
1245
|
+
configResolved(config: Record<string, any>): void;
|
|
1246
|
+
/**
|
|
1247
|
+
* Dev 模式 CSS 内联 — 消除 SSR 首屏布局抖动
|
|
1248
|
+
*
|
|
1249
|
+
* Vite dev 模式下,global.scss 等非组件 CSS 通过 JS 模块系统异步加载,
|
|
1250
|
+
* 导致 SSR HTML 初次渲染缺少布局关键样式(box-sizing、flex 布局、padding-top 等)。
|
|
1251
|
+
*
|
|
1252
|
+
* 此 hook 在 HTML 模板变换阶段(SSR 渲染之前):
|
|
1253
|
+
* 1. 找到浏览器入口脚本(排除 /@vite/client 等内部脚本)
|
|
1254
|
+
* 2. 编译入口脚本,填充 Vite 模块图
|
|
1255
|
+
* 3. 遍历模块图收集所有 CSS 依赖(排除 .svelte 组件 CSS,由 SSR 渲染自行处理)
|
|
1256
|
+
* 4. 通过 ssrLoadModule 获取编译后 CSS(SCSS→CSS)
|
|
1257
|
+
* 5. 注入 <style data-vite-dev-id> 标签到 <head>
|
|
1258
|
+
*
|
|
1259
|
+
* data-vite-dev-id 确保 Vite HMR 客户端复用已有标签,避免重复注入。
|
|
1260
|
+
*/
|
|
1261
|
+
transformIndexHtml: {
|
|
1262
|
+
order: "pre";
|
|
1263
|
+
handler(html: string, ctx: any): Promise<{
|
|
1264
|
+
tag: string;
|
|
1265
|
+
attrs: Record<string, string>;
|
|
1266
|
+
children: string;
|
|
1267
|
+
injectTo: "head";
|
|
1268
|
+
}[] | undefined>;
|
|
1269
|
+
};
|
|
1270
|
+
configureServer(server: any): () => Promise<void>;
|
|
1271
|
+
configurePreviewServer(server: any): () => Promise<void>;
|
|
1272
|
+
closeBundle(): Promise<void>;
|
|
1273
|
+
};
|
|
1274
|
+
//#endregion
|
|
1275
|
+
export { ACTION_KINDS, Action, ActionDispatcher, ActionHandler, type ActionHandlerDependencies, type Adapter, type AdapterContext, AfterLoadGuard, AsyncMapper, BaseController, BaseItem, BaseLogger, BasePage, BaseShelf, BeforeLoadGuard, type BrowserAppConfig, BrowserContextOptions, CompositeLogger, CompositeLoggerFactory, CompoundAction, ConsoleLogger, ConsoleLoggerFactory, Container, DEP_KEYS, DenyResult, ExternalUrlAction, type ExternalUrlDependencies, FeatureFlags, type FinesoftFrontViteOptions, FlowAction, type FlowActionCallbacks, type FlowActionDependencies, Framework, FrameworkConfig, History, HttpClient, HttpClientConfig, HttpError, type InjectSSROptions, Intent, IntentController, IntentDispatcher, Locale, type Logger, Logger as LoggerInterface, type LoggerFactory, LruMap, Mapper, MetricsRecorder, MiddlewareResult, NavigationContext, Net, NextResult, None, Optional, PostLoadContext, PrefetchedIntent, PrefetchedIntents, type ProxyAuthConfig, type ProxyRouteConfig, RedirectResult, RenderMode, RewriteResult, RouteAddOptions, RouteDefinition, RouteMatch, Router, type RuntimeInfo, type SSRAppOptions, type SSRContext, type SSRModule, type SSRRenderConfig, type SSRRenderOptions, type SSRRenderResult, SSR_PLACEHOLDERS, type ServerConfig, ServerContextOptions, type ServerInstance, type StartServerOptions, Storage, autoAdapter, buildUrl, cloudflareAdapter, createBrowserContext, createPrefetchedIntentsFromDom, createSSRApp, createSSRRender, createServer, createServerContext, defineRoutes, deny, deserializeServerData, detectRuntime, finesoftFrontViteConfig, generateProxyCode, generateUuid, getBaseUrl, injectCSRShell, injectSSRContent, isCompoundAction, isExternalUrlAction, isFlowAction, isNone, isSome, makeDependencies, makeExternalUrlAction, makeFlowAction, mapEach, netlifyAdapter, next, nodeAdapter, parseAcceptLanguage, pipe, pipeAsync, redirect, registerActionHandlers, registerExternalUrlHandler, registerFlowActionHandler, registerProxyRoutes, removeHost, removeQueryParams, removeScheme, resetFilterCache, resolveAdapter, resolveRoot, rewrite, runAfterLoadGuards, runBeforeLoadGuards, serializeServerData, shouldLog, ssrRender, stableStringify, startBrowserApp, startServer, staticAdapter, tryScroll, vercelAdapter };
|
|
1276
|
+
//# sourceMappingURL=index.d.mts.map
|