@finesoft/front 0.5.1 → 0.5.2
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/README.md +4 -4
- package/dist/Outlet.svelte +39 -0
- package/dist/Outlet.svelte.d.ts +7 -0
- package/dist/browser-DIU6Sxl3.mjs +1237 -0
- package/dist/browser-kFMjlLGT.d.mts +262 -0
- package/dist/browser.d.mts +7 -2
- package/dist/browser.mjs +9 -1
- package/dist/controller-types-CgmJ6-le.d.mts +16 -0
- package/dist/cookies-Bpf9VayB.d.mts +779 -0
- package/dist/fetch-policy-BHT8RtrL.mjs +82 -0
- package/dist/host-guard-DDWxLpFL.mjs +222 -0
- package/dist/http-B6CJqDyf.d.mts +46 -0
- package/dist/http-CaxrMD1A.d.mts +1 -0
- package/dist/http-D70PL72H.mjs +257 -0
- package/dist/http.d.mts +3 -0
- package/dist/http.mjs +2 -0
- package/dist/index-node.d.mts +15 -0
- package/dist/index-node.mjs +15 -0
- package/dist/index.d.mts +48 -697
- package/dist/index.mjs +44 -261
- package/dist/load-node.d.mts +5 -0
- package/dist/load-node.mjs +10 -0
- package/dist/load-portable.d.mts +5 -0
- package/dist/load-portable.mjs +8 -0
- package/dist/lru-map-BKoUAySU.mjs +50 -0
- package/dist/messages-CAt2QdGr.mjs +140 -0
- package/dist/native-contract-DuR25hYB.d.mts +14 -0
- package/dist/native-contract.d.mts +2 -0
- package/dist/native-contract.mjs +1 -0
- package/dist/node-D9hB4dsz.d.mts +35 -0
- package/dist/node.d.mts +2 -0
- package/dist/node.mjs +59 -0
- package/dist/path-CGFl2w7D.mjs +113 -0
- package/dist/path-CXT6xGPO.d.mts +261 -0
- package/dist/portable-CaxrMD1A.d.mts +1 -0
- package/dist/portable.d.mts +11 -0
- package/dist/portable.mjs +12 -0
- package/dist/proxy-1SphZ7x7.mjs +436 -0
- package/dist/proxy-2dSWO-Xw.d.mts +53 -0
- package/dist/public-types-BcJM-AYc.mjs +835 -0
- package/dist/react-DhwBRw01.d.mts +16 -0
- package/dist/react.d.mts +3 -0
- package/dist/react.mjs +29 -0
- package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
- package/dist/secure-fetch-Xlht2jd7.d.mts +30 -0
- package/dist/server-controller-proxy-BkVuVWVD.d.mts +38 -0
- package/dist/session-DnB4ZC3x.d.mts +1279 -0
- package/dist/src-Ftl_0rhu.mjs +28 -0
- package/dist/src-qwx7Vw8g.mjs +3807 -0
- package/dist/ssr-BEUNDvbj.d.mts +210 -0
- package/dist/ssr-C8xnYXoY.mjs +357 -0
- package/dist/ssr.d.mts +3 -0
- package/dist/ssr.mjs +3 -0
- package/dist/svelte-Dr5to3SE.d.mts +16 -0
- package/dist/svelte.d.mts +3 -0
- package/dist/svelte.mjs +13 -0
- package/dist/typegen-C-WeJCtf.d.mts +12 -0
- package/dist/typegen-cli.d.mts +1 -0
- package/dist/typegen-cli.mjs +11 -0
- package/dist/typegen.d.mts +3 -0
- package/dist/typegen.mjs +2 -0
- package/dist/types-BuaZHRG7.mjs +402 -0
- package/dist/undici-CPfL25Hr.mjs +22262 -0
- package/dist/vite-Cj4SPA8D.d.mts +277 -0
- package/dist/vite.d.mts +4 -0
- package/dist/vite.mjs +2354 -0
- package/dist/vue-DGmzuKho.d.mts +32 -0
- package/dist/vue.d.mts +3 -0
- package/dist/vue.mjs +56 -0
- package/dist/web.d.mts +6 -0
- package/dist/web.mjs +8 -0
- package/dist/worker.d.mts +2 -0
- package/dist/worker.mjs +2 -0
- package/docs/01-getting-started.md +67 -199
- package/docs/02-routing-and-controllers.md +163 -241
- package/docs/03-middleware.md +10 -212
- package/docs/04-rendering-and-hydration.md +6 -333
- package/docs/05-i18n.md +7 -237
- package/docs/06-http-client.md +20 -263
- package/docs/07-di-container.md +23 -257
- package/docs/08-observability.md +6 -286
- package/docs/09-server-and-deployment.md +59 -219
- package/docs/10-features-platform-pwa.md +7 -231
- package/docs/11-navigation.md +143 -288
- package/docs/12-session-restoration.md +6 -214
- package/docs/README.md +7 -7
- package/docs/advanced/custom-action-handler.md +29 -229
- package/docs/advanced/custom-adapter.md +7 -259
- package/docs/advanced/custom-event-recorder.md +7 -312
- package/docs/advanced/inline-proxy-codegen.md +6 -185
- package/docs/advanced/multi-tenant-scopes.md +10 -323
- package/docs/engineering/ci-release-flow.md +35 -222
- package/docs/engineering/project-structure.md +34 -277
- package/docs/engineering/testing.md +8 -310
- package/docs/pitfalls/container-scope-leak.md +2 -214
- package/docs/pitfalls/i18n-bundle-size.md +6 -176
- package/docs/pitfalls/proxy-binary-payloads.md +8 -12
- package/docs/pitfalls/ssr-hydration-mismatch.md +4 -160
- package/docs/pitfalls/ssr-vs-csr-globals.md +9 -170
- package/docs/zh/01-getting-started.md +67 -199
- package/docs/zh/02-routing-and-controllers.md +166 -244
- package/docs/zh/03-middleware.md +10 -212
- package/docs/zh/04-rendering-and-hydration.md +6 -333
- package/docs/zh/05-i18n.md +7 -237
- package/docs/zh/06-http-client.md +20 -263
- package/docs/zh/07-di-container.md +23 -257
- package/docs/zh/08-observability.md +6 -283
- package/docs/zh/09-server-and-deployment.md +59 -219
- package/docs/zh/10-features-platform-pwa.md +7 -231
- package/docs/zh/11-navigation.md +130 -290
- package/docs/zh/12-session-restoration.md +6 -214
- package/docs/zh/README.md +4 -4
- package/docs/zh/advanced/custom-action-handler.md +29 -229
- package/docs/zh/advanced/custom-adapter.md +7 -259
- package/docs/zh/advanced/custom-event-recorder.md +7 -312
- package/docs/zh/advanced/inline-proxy-codegen.md +6 -185
- package/docs/zh/advanced/multi-tenant-scopes.md +10 -323
- package/docs/zh/engineering/ci-release-flow.md +35 -222
- package/docs/zh/engineering/project-structure.md +34 -277
- package/docs/zh/engineering/testing.md +8 -310
- package/docs/zh/pitfalls/container-scope-leak.md +2 -214
- package/docs/zh/pitfalls/i18n-bundle-size.md +6 -176
- package/docs/zh/pitfalls/proxy-binary-payloads.md +8 -12
- package/docs/zh/pitfalls/ssr-hydration-mismatch.md +4 -160
- package/docs/zh/pitfalls/ssr-vs-csr-globals.md +9 -170
- package/package.json +118 -20
- package/dist/browser-BHhVWXik.mjs +0 -2
- package/dist/browser-BV2BBXm7.d.mts +0 -2811
|
@@ -0,0 +1,779 @@
|
|
|
1
|
+
import { E as ParamSchema, S as EventRecorder, _ as OperationPolicy, b as RuntimeOptions, c as ExecutionContext, d as ExecutionHandle, f as Implementation, g as OperationHandler, h as Operation, m as ModuleDefinition, s as AppDefinition, w as MetricsFieldsProvider, y as RuntimeHandle } from "./path-CXT6xGPO.mjs";
|
|
2
|
+
import { $t as MiddlewareResult, A as SessionStore, B as ControllerContext, Bt as NavigationPath, Dn as LocaleInfo, En as LocaleAttributes, F as WebRuntime, Ft as LeafNode, Gn as InferParams, Gt as SplitColumn, Hn as Logger, Jn as QuerySchemaMap, Jt as StackNode, Kn as InferQuery, Kt as SplitNode, Mn as BaseController, O as SessionSnapshot, On as TextDirection, Pn as ControllerInput, R as PageControllerDefinition, Rt as NavigationNode, Un as LoggerFactory, Wn as ExtractParamNames, Xt as AfterLoadGuard, Yt as TabsNode, Z as NavigationCodec, Zn as MultiValueSchema, Zt as BeforeLoadGuard, _n as RouteInput$1, bt as Router, en as NavigationContext, ft as PageRoute, j as SessionStoreOptions, kn as Translator, mt as RouteDefinition, nn as PostLoadContext, qt as SplitVisibility, un as BasePage, v as NavigationScopedState, vn as RouteIntent, yn as RouteParams, yt as RouteMatch, z as WebAppDefinition } from "./session-DnB4ZC3x.mjs";
|
|
3
|
+
import { t as SecureFetchOptions } from "./secure-fetch-Xlht2jd7.mjs";
|
|
4
|
+
//#region ../core/src/schema/primitives.d.ts
|
|
5
|
+
interface StrOptions {
|
|
6
|
+
minLength?: number;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
pattern?: RegExp;
|
|
9
|
+
}
|
|
10
|
+
declare function str(opts?: StrOptions): ParamSchema<string>;
|
|
11
|
+
interface NumOptions {
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
}
|
|
15
|
+
declare function int(opts?: NumOptions): ParamSchema<number>;
|
|
16
|
+
declare function num(opts?: NumOptions): ParamSchema<number>;
|
|
17
|
+
declare function bool(): ParamSchema<boolean>;
|
|
18
|
+
declare function oneOf<const T extends readonly string[]>(values: T): ParamSchema<T[number]>;
|
|
19
|
+
declare function uuid(): ParamSchema<string>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region ../core/src/schema/modifiers.d.ts
|
|
22
|
+
/** 输入缺失(undefined)时跳过校验、产出 undefined;否则委托内部 codec(同步或异步均可)。 */
|
|
23
|
+
declare function optional<T>(codec: MultiValueSchema<T>): MultiValueSchema<T | undefined>;
|
|
24
|
+
declare function optional<T>(codec: ParamSchema<T>): ParamSchema<T | undefined>;
|
|
25
|
+
/** 输入缺失时用 fallback;否则委托内部 codec。 */
|
|
26
|
+
declare function withDefault<T>(codec: MultiValueSchema<T>, fallback: T): MultiValueSchema<T>;
|
|
27
|
+
declare function withDefault<T>(codec: ParamSchema<T>, fallback: T): ParamSchema<T>;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region ../core/src/logger/composite.d.ts
|
|
30
|
+
declare class CompositeLoggerFactory implements LoggerFactory {
|
|
31
|
+
private readonly factories;
|
|
32
|
+
constructor(factories: LoggerFactory[]);
|
|
33
|
+
loggerFor(name: string): Logger;
|
|
34
|
+
}
|
|
35
|
+
declare class CompositeLogger implements Logger {
|
|
36
|
+
private readonly loggers;
|
|
37
|
+
constructor(loggers: Logger[]);
|
|
38
|
+
debug(...args: unknown[]): void;
|
|
39
|
+
info(...args: unknown[]): void;
|
|
40
|
+
warn(...args: unknown[]): void;
|
|
41
|
+
error(...args: unknown[]): void;
|
|
42
|
+
private callAll;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region ../core/src/utils/stable-stringify.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* stableStringify — 确定性 JSON 序列化(keys 按字母排序)
|
|
48
|
+
*
|
|
49
|
+
* 用作缓存 key:相同内容的对象始终产生相同字符串。
|
|
50
|
+
*/
|
|
51
|
+
declare function stableStringify(obj: unknown): string;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region ../core/src/http/errors.d.ts
|
|
54
|
+
/** HTTP 请求错误 */
|
|
55
|
+
declare class HttpError extends Error {
|
|
56
|
+
readonly status: number;
|
|
57
|
+
readonly statusText: string;
|
|
58
|
+
readonly body?: string | undefined;
|
|
59
|
+
constructor(status: number, statusText: string, body?: string | undefined);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* SSRF 防护拦截到不安全的目标地址时抛出。应用层可以 catch 它来给出业务友好的错误,
|
|
63
|
+
* 不需要靠 message 字符串匹配。
|
|
64
|
+
*/
|
|
65
|
+
declare class HostGuardError extends Error {
|
|
66
|
+
readonly url: string;
|
|
67
|
+
readonly reason: string;
|
|
68
|
+
constructor(url: string, reason: string);
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region ../core/src/http/client.d.ts
|
|
72
|
+
/** 请求拦截器 — 在发送前修改请求 */
|
|
73
|
+
interface RequestInterceptor {
|
|
74
|
+
(url: string, init: RequestInit): RequestInit | Promise<RequestInit>;
|
|
75
|
+
}
|
|
76
|
+
/** 响应拦截器 — 在解析前修改响应 */
|
|
77
|
+
interface ResponseInterceptor {
|
|
78
|
+
(response: Response, url: string): Response | Promise<Response>;
|
|
79
|
+
}
|
|
80
|
+
interface HttpRequestOptions {
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
headers?: Record<string, string>;
|
|
83
|
+
}
|
|
84
|
+
/** HttpClient 构造配置 */
|
|
85
|
+
interface HttpClientConfig extends SecureFetchOptions {
|
|
86
|
+
/** API base URL(如 "/api" 或 "https://example.com/api") */
|
|
87
|
+
baseUrl: string;
|
|
88
|
+
/** 默认请求头 */
|
|
89
|
+
defaultHeaders?: Record<string, string>;
|
|
90
|
+
/** 自定义 fetch 实现(便于测试或 SSR)。可由 execution context 提供。 */
|
|
91
|
+
fetch?: typeof globalThis.fetch;
|
|
92
|
+
/** Binds this client to an execution's portable fetch and cancellation signal. */
|
|
93
|
+
context?: Pick<ExecutionContext, "fetch" | "signal">;
|
|
94
|
+
/** 请求拦截器(按注册顺序执行) */
|
|
95
|
+
requestInterceptors?: RequestInterceptor[];
|
|
96
|
+
/** 响应拦截器(按注册顺序执行) */
|
|
97
|
+
responseInterceptors?: ResponseInterceptor[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 通用 HTTP 客户端基类
|
|
101
|
+
*
|
|
102
|
+
* 使用方式: 创建子类继承 HttpClient,定义业务方法调用 this.get() / this.post() 等。
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* class MyApiClient extends HttpClient {
|
|
107
|
+
* async getUser(id: string) {
|
|
108
|
+
* return this.get<User>(`/users/${id}`);
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare abstract class HttpClient {
|
|
114
|
+
protected readonly baseUrl: string;
|
|
115
|
+
protected readonly defaultHeaders: Record<string, string>;
|
|
116
|
+
protected readonly fetchFn: typeof globalThis.fetch;
|
|
117
|
+
private readonly requestInterceptors;
|
|
118
|
+
private readonly responseInterceptors;
|
|
119
|
+
private readonly contextSignal?;
|
|
120
|
+
constructor(config: HttpClientConfig);
|
|
121
|
+
/** 动态添加请求拦截器 */
|
|
122
|
+
useRequestInterceptor(interceptor: RequestInterceptor): this;
|
|
123
|
+
/** 动态添加响应拦截器 */
|
|
124
|
+
useResponseInterceptor(interceptor: ResponseInterceptor): this;
|
|
125
|
+
/** GET 请求,返回解析后的 JSON */
|
|
126
|
+
protected get<T>(path: string, params?: Record<string, string>, options?: HttpRequestOptions): Promise<T>;
|
|
127
|
+
/** POST 请求,自动序列化 body 为 JSON */
|
|
128
|
+
protected post<T>(path: string, body?: unknown, params?: Record<string, string>, options?: HttpRequestOptions): Promise<T>;
|
|
129
|
+
/** PUT 请求 */
|
|
130
|
+
protected put<T>(path: string, body?: unknown, params?: Record<string, string>, options?: HttpRequestOptions): Promise<T>;
|
|
131
|
+
/** DELETE 请求 */
|
|
132
|
+
protected del<T>(path: string, params?: Record<string, string>, options?: HttpRequestOptions): Promise<T>;
|
|
133
|
+
/**
|
|
134
|
+
* 底层请求方法 — 子类可覆写以自定义行为
|
|
135
|
+
*
|
|
136
|
+
* 自动处理:
|
|
137
|
+
* - URL 拼接 (baseUrl + path + params)
|
|
138
|
+
* - SSRF 防护(IP 字面量同步校验 + 可选 DNS 解析校验)
|
|
139
|
+
* - 默认 headers 合并
|
|
140
|
+
* - JSON body 序列化
|
|
141
|
+
* - 响应 JSON 解析
|
|
142
|
+
* - 非 2xx 状态码抛出 HttpError
|
|
143
|
+
*/
|
|
144
|
+
protected request<T>(method: string, path: string, options?: {
|
|
145
|
+
params?: Record<string, string>;
|
|
146
|
+
body?: unknown;
|
|
147
|
+
headers?: Record<string, string>;
|
|
148
|
+
signal?: AbortSignal;
|
|
149
|
+
}): Promise<T>;
|
|
150
|
+
/** 构建完整 URL — 子类可覆写以自定义 URL 拼接逻辑 */
|
|
151
|
+
protected buildUrl(path: string, params?: Record<string, string>): string;
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region ../core/src/http/host-guard.d.ts
|
|
155
|
+
/**
|
|
156
|
+
* host-guard — refuse outbound requests to private / loopback / reserved hosts.
|
|
157
|
+
*
|
|
158
|
+
* Why this exists: `HttpClient` and the raw `fetch` injected via DI both used
|
|
159
|
+
* to accept any URL the application built. SSR controllers that take a
|
|
160
|
+
* user-controlled URL (image proxy, link preview, OAuth callback) could be
|
|
161
|
+
* tricked into fetching `http://127.0.0.1/admin` and embedding the response in
|
|
162
|
+
* the SSR HTML. Round 1 of the adversarial drill walked straight through this;
|
|
163
|
+
* round 2's hand-rolled IPv4 regex was bypassed in five minutes with
|
|
164
|
+
* `[::ffff:7f00:1]`. This module centralises the check so applications can stop
|
|
165
|
+
* re-implementing it (badly).
|
|
166
|
+
*
|
|
167
|
+
* Coverage (synchronous, IP-literal forms):
|
|
168
|
+
* - IPv4 dotted-decimal: `127.0.0.1`, `10.0.0.5`, `192.168.1.1`, `172.16.0.1`
|
|
169
|
+
* - IPv4 zero / link-local / multicast / reserved: `0.0.0.0`, `169.254.0.1`,
|
|
170
|
+
* `224.0.0.1`, `240.0.0.0/4`
|
|
171
|
+
* - IPv4 non-dotted forms accepted by some parsers: decimal `2130706433`,
|
|
172
|
+
* hex `0x7f000001`, octal `0177.0.0.1`
|
|
173
|
+
* - IPv6 loopback `::1`, link-local `fe80::/10`, ULA `fc00::/7`, unspecified `::`
|
|
174
|
+
* - IPv4-mapped IPv6: `::ffff:7f00:1`, `::ffff:127.0.0.1`
|
|
175
|
+
* - Names: `localhost`, `*.localhost`
|
|
176
|
+
*
|
|
177
|
+
* NOT covered here (callers can layer on top):
|
|
178
|
+
* - DNS resolution of arbitrary hostnames — `enforceHostGuard` can preflight
|
|
179
|
+
* answers, but connection-time enforcement requires a host transport such
|
|
180
|
+
* as Node's `nodeSafeFetchOptions`, preserving hostname and TLS SNI.
|
|
181
|
+
* - IDN / homograph attacks — Node's URL parser punycode-encodes hostnames
|
|
182
|
+
* already, so the hostname this code sees is the ASCII form.
|
|
183
|
+
*/
|
|
184
|
+
type HostCheckResult = {
|
|
185
|
+
ok: true;
|
|
186
|
+
} | {
|
|
187
|
+
ok: false;
|
|
188
|
+
reason: string;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Inspect a hostname string (the `URL.hostname` value, without brackets, port,
|
|
192
|
+
* or userinfo). Returns `{ok: false}` for anything in a private/loopback/
|
|
193
|
+
* reserved range; `{ok: true}` if the literal looks like a public address or a
|
|
194
|
+
* non-IP name (the caller may then DNS-resolve and re-check).
|
|
195
|
+
*/
|
|
196
|
+
declare function classifyHost(rawHost: string): HostCheckResult;
|
|
197
|
+
/**
|
|
198
|
+
* Convenience wrapper for callers holding a full URL string. Also rejects
|
|
199
|
+
* non-http(s) schemes (gopher, file, data, …).
|
|
200
|
+
*/
|
|
201
|
+
declare function classifyUrl(rawUrl: string): HostCheckResult;
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region ../core/src/http/redirect-fetch.d.ts
|
|
204
|
+
/** One redirect owner for protected clients and fixed-origin proxies. */
|
|
205
|
+
declare function fetchWithRedirects(fetch: typeof globalThis.fetch, input: string | URL | Request, init: RequestInit | undefined, validate: (url: string) => void | Promise<void>): Promise<Response>;
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region ../core/src/data/mapper.d.ts
|
|
208
|
+
/**
|
|
209
|
+
* Mapper 类型工具 — 标准化数据转换管线
|
|
210
|
+
*
|
|
211
|
+
* 提供类型约定和组合函数,让 API 响应 → 页面模型 的转换有统一的签名模式。
|
|
212
|
+
*/
|
|
213
|
+
/** 同步映射函数 */
|
|
214
|
+
type Mapper<TInput, TOutput> = (input: TInput) => TOutput;
|
|
215
|
+
/** 异步映射函数 */
|
|
216
|
+
type AsyncMapper<TInput, TOutput> = (input: TInput) => TOutput | Promise<TOutput>;
|
|
217
|
+
/**
|
|
218
|
+
* 组合两个同步 Mapper: A → B → C
|
|
219
|
+
*/
|
|
220
|
+
declare function pipe<A, B, C>(m1: Mapper<A, B>, m2: Mapper<B, C>): Mapper<A, C>;
|
|
221
|
+
/**
|
|
222
|
+
* 组合三个同步 Mapper: A → B → C → D
|
|
223
|
+
*/
|
|
224
|
+
declare function pipe<A, B, C, D>(m1: Mapper<A, B>, m2: Mapper<B, C>, m3: Mapper<C, D>): Mapper<A, D>;
|
|
225
|
+
/**
|
|
226
|
+
* 组合四个同步 Mapper: A → B → C → D → E
|
|
227
|
+
*/
|
|
228
|
+
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>;
|
|
229
|
+
/**
|
|
230
|
+
* 组合任意数量的同步 Mapper
|
|
231
|
+
*/
|
|
232
|
+
declare function pipe(...mappers: Mapper<unknown, unknown>[]): Mapper<unknown, unknown>;
|
|
233
|
+
/**
|
|
234
|
+
* 组合两个可能异步的 Mapper: A → B → C
|
|
235
|
+
*/
|
|
236
|
+
declare function pipeAsync<A, B, C>(m1: AsyncMapper<A, B>, m2: AsyncMapper<B, C>): AsyncMapper<A, C>;
|
|
237
|
+
/**
|
|
238
|
+
* 组合三个可能异步的 Mapper
|
|
239
|
+
*/
|
|
240
|
+
declare function pipeAsync<A, B, C, D>(m1: AsyncMapper<A, B>, m2: AsyncMapper<B, C>, m3: AsyncMapper<C, D>): AsyncMapper<A, D>;
|
|
241
|
+
/**
|
|
242
|
+
* 将一个 Mapper 应用到数组的每个元素
|
|
243
|
+
*/
|
|
244
|
+
declare function mapEach<TInput, TOutput>(mapper: Mapper<TInput, TOutput>): Mapper<TInput[], TOutput[]>;
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region ../core/src/utils/lru-map.d.ts
|
|
247
|
+
/**
|
|
248
|
+
* LruMap — 固定容量的 LRU 缓存
|
|
249
|
+
*/
|
|
250
|
+
declare class LruMap<K, V> {
|
|
251
|
+
private map;
|
|
252
|
+
private readonly capacity;
|
|
253
|
+
constructor(capacity: number);
|
|
254
|
+
get(key: K): V | undefined;
|
|
255
|
+
set(key: K, value: V): void;
|
|
256
|
+
has(key: K): boolean;
|
|
257
|
+
delete(key: K): boolean;
|
|
258
|
+
get size(): number;
|
|
259
|
+
clear(): void;
|
|
260
|
+
/** Iterate in eviction order: least recently used first. */
|
|
261
|
+
entries(): IterableIterator<[K, V]>;
|
|
262
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region ../core/src/utils/optional.d.ts
|
|
266
|
+
/**
|
|
267
|
+
* Optional 类型工具
|
|
268
|
+
*/
|
|
269
|
+
type None = null | undefined;
|
|
270
|
+
type Optional<T> = T | None;
|
|
271
|
+
declare function isSome<T>(value: Optional<T>): value is T;
|
|
272
|
+
declare function isNone<T>(value: Optional<T>): value is None;
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region ../core/src/utils/url.d.ts
|
|
275
|
+
/**
|
|
276
|
+
* URL 工具函数
|
|
277
|
+
*/
|
|
278
|
+
/** 移除 URL scheme (https://, http://) */
|
|
279
|
+
declare function removeScheme(url: string): string;
|
|
280
|
+
/** 移除 URL host 部分,保留路径 */
|
|
281
|
+
declare function removeHost(url: string): string;
|
|
282
|
+
/** 移除 query 参数 */
|
|
283
|
+
declare function removeQueryParams(url: string): string;
|
|
284
|
+
/** 获取 URL 的基础路径(无 query、hash) */
|
|
285
|
+
declare function getBaseUrl(url: string): string;
|
|
286
|
+
/** 构建 URL(路径 + query 参数) */
|
|
287
|
+
declare function buildUrl(path: string, params?: Record<string, string | undefined>): string;
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region ../core/src/utils/uuid.d.ts
|
|
290
|
+
/**
|
|
291
|
+
* UUID v4 生成器
|
|
292
|
+
*/
|
|
293
|
+
declare function generateUuid(): string;
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region ../core/src/metrics/composite-recorder.d.ts
|
|
296
|
+
declare class CompositeEventRecorder implements EventRecorder {
|
|
297
|
+
private readonly recorders;
|
|
298
|
+
constructor(recorders: EventRecorder[]);
|
|
299
|
+
record(type: string, fields?: Record<string, unknown>): void;
|
|
300
|
+
flush(): Promise<void>;
|
|
301
|
+
destroy(): void;
|
|
302
|
+
}
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region ../core/src/metrics/console-recorder.d.ts
|
|
305
|
+
declare class ConsoleEventRecorder implements EventRecorder {
|
|
306
|
+
private readonly prefix;
|
|
307
|
+
constructor(prefix?: string);
|
|
308
|
+
record(type: string, fields?: Record<string, unknown>): void;
|
|
309
|
+
flush(): Promise<void>;
|
|
310
|
+
destroy(): void;
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region ../core/src/metrics/void-recorder.d.ts
|
|
314
|
+
declare class VoidEventRecorder implements EventRecorder {
|
|
315
|
+
record(): void;
|
|
316
|
+
flush(): Promise<void>;
|
|
317
|
+
destroy(): void;
|
|
318
|
+
}
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region ../core/src/metrics/with-fields-recorder.d.ts
|
|
321
|
+
declare class WithFieldsRecorder implements EventRecorder {
|
|
322
|
+
private readonly inner;
|
|
323
|
+
private readonly providers;
|
|
324
|
+
constructor(inner: EventRecorder, providers: MetricsFieldsProvider[]);
|
|
325
|
+
record(type: string, fields?: Record<string, unknown>): void;
|
|
326
|
+
flush(): Promise<void>;
|
|
327
|
+
destroy(): void;
|
|
328
|
+
}
|
|
329
|
+
//#endregion
|
|
330
|
+
//#region ../core/src/i18n/interpolate.d.ts
|
|
331
|
+
/**
|
|
332
|
+
* ICU 消息格式插值
|
|
333
|
+
*
|
|
334
|
+
* 支持 `{name}` 占位符替换和基础复数规则。
|
|
335
|
+
*/
|
|
336
|
+
/** 将 `{key}` 占位符替换为 values 中的对应值 */
|
|
337
|
+
declare function interpolate(template: string, values?: Record<string, string | number>): string;
|
|
338
|
+
/**
|
|
339
|
+
* CLDR 复数类别
|
|
340
|
+
*
|
|
341
|
+
* 简化版:覆盖 zero / one / two / few / many / other。
|
|
342
|
+
* 完整 CLDR 规则可通过 PluralRuleProvider 注入。
|
|
343
|
+
*/
|
|
344
|
+
type PluralCategory = "zero" | "one" | "two" | "few" | "many" | "other";
|
|
345
|
+
/** 复数规则函数 — 给定数量返回复数类别 */
|
|
346
|
+
type PluralRuleProvider = (count: number) => PluralCategory;
|
|
347
|
+
/**
|
|
348
|
+
* 英语复数规则(默认)
|
|
349
|
+
* 0 → other, 1 → one, 2+ → other
|
|
350
|
+
*/
|
|
351
|
+
declare function englishPlural(count: number): PluralCategory;
|
|
352
|
+
/**
|
|
353
|
+
* 解析带复数后缀的翻译 key
|
|
354
|
+
*
|
|
355
|
+
* 约定: `key.one`, `key.other`, `key.zero`, etc.
|
|
356
|
+
*/
|
|
357
|
+
declare function resolvePluralKey(key: string, category: PluralCategory): string;
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region ../core/src/i18n/locale.d.ts
|
|
360
|
+
/** 检测语言是否为 RTL */
|
|
361
|
+
declare function isRtl(language: string): boolean;
|
|
362
|
+
/** 获取文本方向 */
|
|
363
|
+
declare function getTextDirection(language: string): TextDirection;
|
|
364
|
+
/**
|
|
365
|
+
* 从语言代码生成 HTML lang/dir 属性
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```ts
|
|
369
|
+
* getLocaleAttributes("ar-SA") // { lang: "ar-SA", dir: "rtl" }
|
|
370
|
+
* getLocaleAttributes("en-US") // { lang: "en-US", dir: "ltr" }
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
declare function getLocaleAttributes(language: string): LocaleAttributes;
|
|
374
|
+
/**
|
|
375
|
+
* 构建 LocaleInfo
|
|
376
|
+
*
|
|
377
|
+
* @param language - 语言代码(如 "zh-Hans")
|
|
378
|
+
* @param region - 地区代码(如 "CN"),可选
|
|
379
|
+
*/
|
|
380
|
+
declare function makeLocaleInfo(language: string, region?: string): LocaleInfo;
|
|
381
|
+
/**
|
|
382
|
+
* 从 URL 前缀中提取 locale
|
|
383
|
+
*
|
|
384
|
+
* @param url - 请求 URL(如 "/zh/about")
|
|
385
|
+
* @param supportedLocales - 支持的 locale 列表(如 ["zh", "en", "ja"])
|
|
386
|
+
* @returns 匹配时返回 `{ locale, strippedUrl }`,不匹配返回 null
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* ```ts
|
|
390
|
+
* resolveLocaleFromUrl("/zh/about", ["zh", "en"])
|
|
391
|
+
* // → { locale: "zh", strippedUrl: "/about" }
|
|
392
|
+
*
|
|
393
|
+
* resolveLocaleFromUrl("/about", ["zh", "en"])
|
|
394
|
+
* // → null
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
declare function resolveLocaleFromUrl(url: string, supportedLocales: string[]): {
|
|
398
|
+
locale: string;
|
|
399
|
+
strippedUrl: string;
|
|
400
|
+
} | null;
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region ../core/src/i18n/translator.d.ts
|
|
403
|
+
interface SimpleTranslatorOptions {
|
|
404
|
+
/** 翻译映射 */
|
|
405
|
+
messages: Record<string, string>;
|
|
406
|
+
/** 当前 locale */
|
|
407
|
+
locale: string;
|
|
408
|
+
/** 复数规则函数(默认英语规则) */
|
|
409
|
+
pluralRule?: PluralRuleProvider;
|
|
410
|
+
/** 找不到翻译时的回退行为(默认返回 key) */
|
|
411
|
+
fallback?: (key: string) => string;
|
|
412
|
+
}
|
|
413
|
+
declare class SimpleTranslator implements Translator {
|
|
414
|
+
readonly locale: string;
|
|
415
|
+
private readonly messages;
|
|
416
|
+
private readonly pluralRule;
|
|
417
|
+
private readonly fallback;
|
|
418
|
+
constructor(options: SimpleTranslatorOptions);
|
|
419
|
+
t(key: string, values?: Record<string, string | number>): string;
|
|
420
|
+
plural(key: string, count: number, values?: Record<string, string | number>): string;
|
|
421
|
+
}
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region ../core/src/application/operation.d.ts
|
|
424
|
+
declare function defineOperation<I = undefined, O = unknown>(operation: Operation<I, O>): Operation<I, O>;
|
|
425
|
+
declare function implementOperation<I, O>(operation: Operation<I, O>, handler: OperationHandler<I, O>): Implementation<I, O>;
|
|
426
|
+
/** A fresh controller owns each call; reusable definitions never retain request state. */
|
|
427
|
+
declare function implementController<I extends Record<string, unknown>, O>(operation: Operation<I, O>, create: () => BaseController<ControllerInput<I>, O>): Implementation<I, O>;
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region ../core/src/application/definition.d.ts
|
|
430
|
+
declare function defineModule(module: ModuleDefinition): ModuleDefinition;
|
|
431
|
+
declare function defineApp(app: AppDefinition): AppDefinition;
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region ../core/src/application/runtime.d.ts
|
|
434
|
+
declare function createRuntime(options: RuntimeOptions): RuntimeHandle;
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region ../web/src/models/safe-error-page.d.ts
|
|
437
|
+
interface SafeErrorPageOptions {
|
|
438
|
+
/** HTTP-style status code used in the page title (e.g. 404, 500). */
|
|
439
|
+
status: number;
|
|
440
|
+
/**
|
|
441
|
+
* The message users / client code may safely see in production. Should
|
|
442
|
+
* contain no stack, file paths, hostnames, or secrets.
|
|
443
|
+
*/
|
|
444
|
+
publicMessage: string;
|
|
445
|
+
/**
|
|
446
|
+
* Optional error / debug payload to surface only in non-production. In
|
|
447
|
+
* production this is dropped entirely; only `publicMessage` is exposed.
|
|
448
|
+
*/
|
|
449
|
+
devError?: unknown;
|
|
450
|
+
/**
|
|
451
|
+
* Override the production detection. Pass `true` to force the prod-safe
|
|
452
|
+
* variant (drops devError). Defaults to true.
|
|
453
|
+
*/
|
|
454
|
+
isProduction?: boolean;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Build a BasePage for an error condition. In production, only `publicMessage`
|
|
458
|
+
* makes it into the page. In dev, `devError` (if provided) is appended.
|
|
459
|
+
*/
|
|
460
|
+
declare function safeErrorPage(options: SafeErrorPageOptions): BasePage;
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region ../web/src/application/route-input.d.ts
|
|
463
|
+
type Simplify<T> = { [K in keyof T]: T[K]; };
|
|
464
|
+
type OptionalKeys<Path extends string> = { [K in ExtractParamNames<Path>]: Path extends `${string}:${K}?` | `${string}:${K}?/${string}` ? K : never; }[ExtractParamNames<Path>];
|
|
465
|
+
type PathInput<Path extends string> = string extends Path ? RouteParams : { [K in Exclude<ExtractParamNames<Path>, OptionalKeys<Path>>]: string; } & { [K in OptionalKeys<Path>]?: string; };
|
|
466
|
+
type Params<R> = R extends {
|
|
467
|
+
params?: infer P extends Record<string, ParamSchema>;
|
|
468
|
+
} ? R extends {
|
|
469
|
+
params: unknown;
|
|
470
|
+
} ? InferParams<P> : {} | InferParams<P> : {};
|
|
471
|
+
type Query<R> = R extends {
|
|
472
|
+
query?: infer Q extends QuerySchemaMap;
|
|
473
|
+
} ? R extends {
|
|
474
|
+
query: unknown;
|
|
475
|
+
} ? InferQuery<Q> : {} | InferQuery<Q> : {};
|
|
476
|
+
type WithCodecs<Path extends string, P> = P extends unknown ? Simplify<Omit<PathInput<Path>, keyof P> & P> : never;
|
|
477
|
+
type RouteInput<R> = R extends string ? {
|
|
478
|
+
params: Simplify<PathInput<R>>;
|
|
479
|
+
query: {};
|
|
480
|
+
} : R extends {
|
|
481
|
+
path: infer Path extends string;
|
|
482
|
+
} ? {
|
|
483
|
+
params: WithCodecs<Path, Params<R>>;
|
|
484
|
+
query: Query<R>;
|
|
485
|
+
} : never;
|
|
486
|
+
/** All accepted routes remain a union: a controller must handle every alias. */
|
|
487
|
+
type RouteInputFor<Routes extends readonly (string | PageRoute)[]> = Routes extends readonly [] ? {
|
|
488
|
+
params: RouteParams;
|
|
489
|
+
query: RouteParams;
|
|
490
|
+
} : RouteInput<Routes[number]>;
|
|
491
|
+
/** Reject codec keys that cannot be captured by the corresponding path. */
|
|
492
|
+
type ValidRoutes<Routes extends readonly (string | PageRoute)[]> = { [I in keyof Routes]: Routes[I] extends {
|
|
493
|
+
path: infer Path extends string;
|
|
494
|
+
params: infer P;
|
|
495
|
+
} ? string extends Path ? Routes[I] : Exclude<keyof P, ExtractParamNames<Path>> extends never ? Routes[I] : never : Routes[I]; };
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region ../web/src/navigation/nodes.d.ts
|
|
498
|
+
/** 构造叶子节点(一个具体导航目标)。 */
|
|
499
|
+
declare function leaf(intent: string, params?: RouteParams, options?: {
|
|
500
|
+
entryId?: string;
|
|
501
|
+
url?: string;
|
|
502
|
+
query?: RouteParams;
|
|
503
|
+
}): LeafNode;
|
|
504
|
+
/**
|
|
505
|
+
* 构造栈节点。
|
|
506
|
+
* 接受单个根节点(栈仅含根)或一个 entries 数组(entries[0]=根,末尾=栈顶)。
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* stack(leaf("home")) // 单根栈
|
|
510
|
+
* stack([leaf("home"), leaf("detail")]) // 根 + 栈顶
|
|
511
|
+
*/
|
|
512
|
+
declare function stack(rootOrEntries: NavigationNode | readonly NavigationNode[]): StackNode;
|
|
513
|
+
/** tabs 构造选项 */
|
|
514
|
+
interface TabsInit {
|
|
515
|
+
/** 当前激活分支键 */
|
|
516
|
+
readonly active: string;
|
|
517
|
+
/** 分支映射(键 → 子节点) */
|
|
518
|
+
readonly branches: Readonly<Record<string, NavigationNode>>;
|
|
519
|
+
/** 稳定顺序;缺省时按 branches 的插入顺序推导 */
|
|
520
|
+
readonly order?: readonly string[];
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* 构造 Tabs 节点。
|
|
524
|
+
* 缺省 `order` 时按 `branches` 的插入顺序(`Object.keys`)推导稳定顺序。
|
|
525
|
+
*/
|
|
526
|
+
declare function tabs(init: TabsInit): TabsNode;
|
|
527
|
+
/** split 列初始化(content 可缺省 = 尚未选择) */
|
|
528
|
+
interface SplitColumnInit {
|
|
529
|
+
readonly id: string;
|
|
530
|
+
readonly content?: NavigationNode;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* 构造 Split 节点(多列并存)。
|
|
534
|
+
* `visibility` 缺省(不写字段)等价 `automatic` = 全列可见;
|
|
535
|
+
* 显式传入时纳入节点状态,影响 `collectVisibleDestinations` 与 SSR 预取。
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* split([{ id: "sidebar", content: leaf("folders") }, { id: "detail" }])
|
|
539
|
+
* split([...], "detailOnly") // 深链:仅 detail 列可见
|
|
540
|
+
*/
|
|
541
|
+
declare function split(columns: readonly SplitColumnInit[], visibility?: SplitVisibility): SplitNode;
|
|
542
|
+
declare function isLeafNode(node: NavigationNode): node is LeafNode;
|
|
543
|
+
declare function isStackNode(node: NavigationNode): node is StackNode;
|
|
544
|
+
declare function isTabsNode(node: NavigationNode): node is TabsNode;
|
|
545
|
+
declare function isSplitNode(node: NavigationNode): node is SplitNode;
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region ../web/src/navigation/keys.d.ts
|
|
548
|
+
/** Resource identity never identifies a page instance. */
|
|
549
|
+
declare function resourceKey(intent: string, params: RouteParams, partition?: {
|
|
550
|
+
identity?: string;
|
|
551
|
+
locale?: string;
|
|
552
|
+
}, query?: RouteParams): string;
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region ../web/src/navigation/operations.d.ts
|
|
555
|
+
/**
|
|
556
|
+
* 解析「激活路径」:从根沿可见分支一路向下,直到叶子或无法继续。
|
|
557
|
+
* - leaf:路径在此结束
|
|
558
|
+
* - stack:进入栈顶 entry
|
|
559
|
+
* - tabs:进入 active 分支
|
|
560
|
+
* - split:进入最后一个有内容的列(无任何内容则结束)
|
|
561
|
+
*/
|
|
562
|
+
declare function resolveActivePath(tree: NavigationNode): NavigationPath;
|
|
563
|
+
/**
|
|
564
|
+
* 按路径定位节点;任一步无效(索引越界 / 键不存在 / 列为空 / kind 不匹配)返回 undefined。
|
|
565
|
+
*/
|
|
566
|
+
declare function findNode(tree: NavigationNode, path: NavigationPath): NavigationNode | undefined;
|
|
567
|
+
/**
|
|
568
|
+
* 找到 target 处(默认激活路径)「at/under」最近的 StackNode 路径。
|
|
569
|
+
* 从 target 节点沿激活分支向下,返回第一个遇到的 StackNode 的完整路径;
|
|
570
|
+
* 找不到则返回 undefined。
|
|
571
|
+
*/
|
|
572
|
+
declare function findNearestStack(tree: NavigationNode, path: NavigationPath): NavigationPath | undefined;
|
|
573
|
+
/**
|
|
574
|
+
* 收集所有可见的叶子目标(顺序即渲染/解析顺序)。
|
|
575
|
+
* - leaf → [leaf]
|
|
576
|
+
* - stack → 栈顶 entry 的可见目标
|
|
577
|
+
* - tabs → active 分支的可见目标
|
|
578
|
+
* - split → 每个有内容的列的可见目标,按列序拼接
|
|
579
|
+
*/
|
|
580
|
+
declare function collectVisibleDestinations(tree: NavigationNode): readonly LeafNode[];
|
|
581
|
+
/**
|
|
582
|
+
* 收集树中**全部存在**的叶子(含不可见:栈非顶 entry、未激活 tab 分支、所有非空 split 列)。
|
|
583
|
+
* 区别于 `collectVisibleDestinations`(只沿可见分支)—— 保活 / 缓存 prune / 作用域保留需要
|
|
584
|
+
* 全部 present 条目。顺序:栈按序、tabs 按 `Object.values(branches)` 序、split 按列序。
|
|
585
|
+
*/
|
|
586
|
+
declare function collectAllLeaves(tree: NavigationNode): readonly LeafNode[];
|
|
587
|
+
/**
|
|
588
|
+
* 按 `visibility` 求出一个 split 节点当前**可见**的列(不裁剪空内容列——空 content 由调用方处理)。
|
|
589
|
+
*
|
|
590
|
+
* - `automatic`(缺省)/ `all`:全部列。
|
|
591
|
+
* - `doubleColumn`:首列 + 末列(三列时隐藏中间 content 列;列数 ≤ 2 时等价全部)。
|
|
592
|
+
* - `detailOnly`:仅末列(detail)。
|
|
593
|
+
*
|
|
594
|
+
* 应用渲染时也可用它决定该画哪几列,无需自行重实现可见性映射。
|
|
595
|
+
*/
|
|
596
|
+
declare function visibleSplitColumns(node: SplitNode): readonly SplitColumn[];
|
|
597
|
+
/** 在目标栈(默认激活栈,或 target「at/under」最近的 stack)顶部 push 一个节点。 */
|
|
598
|
+
declare function push(tree: NavigationNode, node: NavigationNode, target?: NavigationPath): NavigationNode;
|
|
599
|
+
/** 从 target 处最近的 stack 弹出 count 个 entry(默认 1);绝不弹到根 entry 之下。 */
|
|
600
|
+
declare function pop(tree: NavigationNode, count?: number, target?: NavigationPath): NavigationNode;
|
|
601
|
+
/** 把 target 处最近的 stack 弹回到根 entry。 */
|
|
602
|
+
declare function popToRoot(tree: NavigationNode, target?: NavigationPath): NavigationNode;
|
|
603
|
+
/** 把 target 处最近的 stack 弹回到指定 index(保留 [0..index])。 */
|
|
604
|
+
declare function popTo(tree: NavigationNode, index: number, target?: NavigationPath): NavigationNode;
|
|
605
|
+
/** 替换 target 处最近 stack 的栈顶 entry(栈为空时抛错)。 */
|
|
606
|
+
declare function replaceTop(tree: NavigationNode, node: NavigationNode, target?: NavigationPath): NavigationNode;
|
|
607
|
+
/**
|
|
608
|
+
* 切换 tabs 节点的激活分支。
|
|
609
|
+
* target 默认为「最近的激活 tabs 节点」;target 必须指向 TabsNode,且 key 必须是已知分支。
|
|
610
|
+
*/
|
|
611
|
+
declare function selectTab(tree: NavigationNode, key: string, target?: NavigationPath): NavigationNode;
|
|
612
|
+
/**
|
|
613
|
+
* 设置 split 某列内容,并清空它之后的所有列(content 置 undefined)。
|
|
614
|
+
* target 默认为「最近的激活 split 节点」;columnId 必须是已知列。
|
|
615
|
+
*/
|
|
616
|
+
declare function selectColumn(tree: NavigationNode, columnId: string, content: NavigationNode | undefined, target?: NavigationPath): NavigationNode;
|
|
617
|
+
/**
|
|
618
|
+
* 设置 split 节点的列可见性(对标 SwiftUI `NavigationSplitViewVisibility`)。
|
|
619
|
+
* target 默认为「最近的激活 split 节点」。改变 visibility 会影响 `collectVisibleDestinations`,
|
|
620
|
+
* 进而触发 controller 对「新变可见」的列做 dispatch / SSR 预取(如 detailOnly → all 时补预取 sidebar/content)。
|
|
621
|
+
*/
|
|
622
|
+
declare function setVisibility(tree: NavigationNode, visibility: SplitVisibility, target?: NavigationPath): NavigationNode;
|
|
623
|
+
/** Apply resolved route metadata to leaves without changing their instance identities. */
|
|
624
|
+
declare function mapNavigationLeaves(tree: NavigationNode, transform: (leaf: LeafNode) => LeafNode): NavigationNode;
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region ../web/src/session/snapshot.d.ts
|
|
627
|
+
/** 把快照编码为确定性字符串(keys 排序),用作 `storage.set` 的值。 */
|
|
628
|
+
declare function encodeSnapshot(snapshot: SessionSnapshot): string;
|
|
629
|
+
/**
|
|
630
|
+
* 解码并校验快照。
|
|
631
|
+
*
|
|
632
|
+
* 校验:`version === expectedVersion`、`slices`/`scoped` 为对象、`capturedAt` 为数值;
|
|
633
|
+
* `navigation` 可缺省。任一不符或解析失败 → `undefined`(永不抛)。
|
|
634
|
+
*/
|
|
635
|
+
declare function decodeSnapshot(raw: string | undefined, expectedVersion: number): SessionSnapshot | undefined;
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region ../web/src/session/scoped-state.d.ts
|
|
638
|
+
/**
|
|
639
|
+
* 收集导航树中**全部 leaf** 的身份键(含不可见 / 未激活分支 / 各 split 列)。
|
|
640
|
+
* 委派给 `collectAllLeaves`(同一「全部存在」遍历),映射成 entryKey。
|
|
641
|
+
* 「全部存在」而非「可见」,用于 scoped 状态保留。
|
|
642
|
+
*/
|
|
643
|
+
declare function collectLeafKeys(tree: NavigationNode): string[];
|
|
644
|
+
/**
|
|
645
|
+
* 创建导航作用域状态容器。
|
|
646
|
+
*
|
|
647
|
+
* 内部持一个 `Map`;`prune` 由 `presentKeys` 构造 `Set`,删除不在其中的全部键。
|
|
648
|
+
* `initial` 在构造时浅拷贝进 `Map`,构造后改动源对象不会泄漏进容器。
|
|
649
|
+
*/
|
|
650
|
+
declare function createNavigationScopedState(initial?: Record<string, unknown>): NavigationScopedState;
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region ../web/src/session/session-store.d.ts
|
|
653
|
+
/** One ordered persistence owner; implicit saves capture when their queue slot starts. */
|
|
654
|
+
declare function createSessionStore(options: SessionStoreOptions): SessionStore;
|
|
655
|
+
//#endregion
|
|
656
|
+
//#region ../web/src/middleware/pipeline.d.ts
|
|
657
|
+
/** 执行 beforeLoad 守卫链 */
|
|
658
|
+
declare const runBeforeLoadGuards: (guards: ((ctx: NavigationContext) => MiddlewareResult | Promise<MiddlewareResult>)[], ctx: NavigationContext) => Promise<MiddlewareResult>;
|
|
659
|
+
/** 执行 afterLoad 守卫链 */
|
|
660
|
+
declare const runAfterLoadGuards: (guards: ((ctx: PostLoadContext) => MiddlewareResult | Promise<MiddlewareResult>)[], ctx: PostLoadContext) => Promise<MiddlewareResult>;
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region ../web/src/application/definition.d.ts
|
|
663
|
+
interface WebPlan {
|
|
664
|
+
readonly app: AppDefinition;
|
|
665
|
+
readonly router: Router;
|
|
666
|
+
readonly routes: readonly RouteDefinition[];
|
|
667
|
+
readonly operations: ReadonlyMap<string, Operation<RouteInput$1, BasePage>>;
|
|
668
|
+
}
|
|
669
|
+
declare function getWebPlan(definition: WebAppDefinition): WebPlan;
|
|
670
|
+
declare function defineWebApp<const Pages extends readonly PageControllerDefinition[]>(input: WebAppDefinition<Pages>): WebAppDefinition<Pages>;
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region ../web/src/application/load-page.d.ts
|
|
673
|
+
interface LoadPageOptions {
|
|
674
|
+
readonly web: WebRuntime;
|
|
675
|
+
readonly target: string | LeafNode;
|
|
676
|
+
readonly execution?: ExecutionHandle;
|
|
677
|
+
readonly signal?: AbortSignal;
|
|
678
|
+
readonly retained?: BasePage;
|
|
679
|
+
readonly entryId?: string;
|
|
680
|
+
readonly createContext?: (input: {
|
|
681
|
+
url: string;
|
|
682
|
+
intent: RouteIntent;
|
|
683
|
+
execution: ExecutionHandle;
|
|
684
|
+
}) => NavigationContext;
|
|
685
|
+
readonly beforeLoad?: readonly BeforeLoadGuard[];
|
|
686
|
+
readonly afterLoad?: readonly AfterLoadGuard[];
|
|
687
|
+
}
|
|
688
|
+
type PageLoadResult = {
|
|
689
|
+
readonly kind: "page";
|
|
690
|
+
readonly page: BasePage;
|
|
691
|
+
readonly target: LeafNode;
|
|
692
|
+
readonly match?: RouteMatch;
|
|
693
|
+
readonly rewriteUrl?: string;
|
|
694
|
+
} | {
|
|
695
|
+
readonly kind: "redirect";
|
|
696
|
+
readonly url: string;
|
|
697
|
+
readonly status: number;
|
|
698
|
+
} | {
|
|
699
|
+
readonly kind: "deny";
|
|
700
|
+
readonly status: number;
|
|
701
|
+
readonly message: string;
|
|
702
|
+
};
|
|
703
|
+
/** One page pipeline, shared by URL, SSR and every visible tree destination. */
|
|
704
|
+
declare function loadPage(options: LoadPageOptions): Promise<PageLoadResult>;
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region ../web/src/application/initial-navigation.d.ts
|
|
707
|
+
/** Resolve and validate once, then let an application arrange typed targets. */
|
|
708
|
+
declare function resolveInitialNavigation(web: WebRuntime, url: string, options?: {
|
|
709
|
+
codec?: NavigationCodec;
|
|
710
|
+
initial?: WebAppDefinition["navigation"];
|
|
711
|
+
}): Promise<{
|
|
712
|
+
tree: NavigationNode;
|
|
713
|
+
renderMode: string | undefined;
|
|
714
|
+
} | undefined>;
|
|
715
|
+
//#endregion
|
|
716
|
+
//#region ../web/src/application/page.d.ts
|
|
717
|
+
type ControllerParams<C> = C extends {
|
|
718
|
+
execute(input: {
|
|
719
|
+
params: infer P;
|
|
720
|
+
}): unknown;
|
|
721
|
+
} ? P extends RouteParams ? P : RouteParams : RouteParams;
|
|
722
|
+
/** Reference helpers emit existing declarations. Page type, operation id and entry id stay distinct. */
|
|
723
|
+
interface PageReference<P extends RouteParams, R extends BasePage, Id extends string = string, Q extends RouteParams = RouteParams> extends PageControllerDefinition {
|
|
724
|
+
readonly id: Id;
|
|
725
|
+
route<const Path extends string>(path: Path): Readonly<{
|
|
726
|
+
path: Path;
|
|
727
|
+
intentId: Id;
|
|
728
|
+
}>;
|
|
729
|
+
route<const Path extends string, const Options extends Omit<PageRoute<Path>, "path">>(path: Path, options: Options & NoInfer<Record<Exclude<keyof Options, keyof Omit<PageRoute<Path>, "path">>, never>>): Readonly<{
|
|
730
|
+
path: Path;
|
|
731
|
+
intentId: Id;
|
|
732
|
+
} & Options>;
|
|
733
|
+
leaf(...args: {} extends Q ? {} extends P ? [params?: P, options?: {
|
|
734
|
+
url?: string;
|
|
735
|
+
query?: Q;
|
|
736
|
+
}] : [params: P, options?: {
|
|
737
|
+
url?: string;
|
|
738
|
+
query?: Q;
|
|
739
|
+
}] : [params: P, options: {
|
|
740
|
+
url?: string;
|
|
741
|
+
query: Q;
|
|
742
|
+
}]): LeafNode;
|
|
743
|
+
/** Explicit result pageType association; native component prop validation belongs to the UI adapter. */
|
|
744
|
+
bindView<const Type extends R["pageType"], View>(pageType: Type, view: View): Readonly<Record<Type, View>>;
|
|
745
|
+
}
|
|
746
|
+
declare function definePage<const Id extends string, const Routes extends readonly (string | PageRoute)[], R extends BasePage>(input: {
|
|
747
|
+
readonly id: Id;
|
|
748
|
+
readonly routes: Routes & NoInfer<ValidRoutes<Routes>>;
|
|
749
|
+
readonly handler: (params: NoInfer<RouteInputFor<Routes>["params"]>, context: ControllerContext, query: NoInfer<RouteInputFor<Routes>["query"]>) => R | Promise<R>;
|
|
750
|
+
readonly policies?: readonly OperationPolicy<NoInfer<RouteInputFor<Routes>["params"]>>[];
|
|
751
|
+
}): PageReference<RouteInputFor<Routes>["params"], R, Id, RouteInputFor<Routes>["query"]>;
|
|
752
|
+
declare function definePage<const Id extends string, const Routes extends readonly (string | PageRoute)[], R extends BasePage>(input: {
|
|
753
|
+
readonly id: Id;
|
|
754
|
+
readonly routes: Routes & NoInfer<ValidRoutes<Routes>>;
|
|
755
|
+
readonly create: () => {
|
|
756
|
+
perform: (params: NoInfer<RouteInputFor<Routes>["params"]>, context: ExecutionContext, query: NoInfer<RouteInputFor<Routes>["query"]>) => R | Promise<R>;
|
|
757
|
+
};
|
|
758
|
+
readonly policies?: readonly OperationPolicy<NoInfer<RouteInputFor<Routes>["params"]>>[];
|
|
759
|
+
}): PageReference<RouteInputFor<Routes>["params"], R, Id, RouteInputFor<Routes>["query"]>;
|
|
760
|
+
declare function definePage<const Id extends string, C extends {
|
|
761
|
+
perform(input: any, context: ExecutionContext): Promise<BasePage>;
|
|
762
|
+
}>(input: {
|
|
763
|
+
readonly id: Id;
|
|
764
|
+
readonly routes?: undefined;
|
|
765
|
+
readonly create: () => C;
|
|
766
|
+
readonly policies?: readonly OperationPolicy<RouteParams>[];
|
|
767
|
+
}): PageReference<ControllerParams<C>, Awaited<ReturnType<C["perform"]>>, Id>;
|
|
768
|
+
declare function definePage<const Id extends string, P extends RouteParams, R extends BasePage>(input: {
|
|
769
|
+
readonly id: Id;
|
|
770
|
+
readonly routes?: undefined;
|
|
771
|
+
readonly handler: (params: P, context: ControllerContext) => R | Promise<R>;
|
|
772
|
+
readonly policies?: readonly OperationPolicy<RouteParams>[];
|
|
773
|
+
}): PageReference<P, R, Id>;
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region ../web/src/middleware/cookies.d.ts
|
|
776
|
+
declare function parseCookieString(str: string): Map<string, string>;
|
|
777
|
+
//#endregion
|
|
778
|
+
export { SimpleTranslatorOptions as $, uuid as $t, setVisibility as A, fetchWithRedirects as At, split as B, HttpError as Bt, popTo as C, isSome as Ct, resolveActivePath as D, mapEach as Dt, replaceTop as E, Mapper as Et, isLeafNode as F, HttpClientConfig as Ft, safeErrorPage as G, withDefault as Gt, tabs as H, CompositeLogger as Ht, isSplitNode as I, HttpRequestOptions as It, defineModule as J, bool as Jt, createRuntime as K, NumOptions as Kt, isStackNode as L, RequestInterceptor as Lt, resourceKey as M, classifyHost as Mt, SplitColumnInit as N, classifyUrl as Nt, selectColumn as O, pipe as Ot, TabsInit as P, HttpClient as Pt, SimpleTranslator as Q, str as Qt, isTabsNode as R, ResponseInterceptor as Rt, pop as S, isNone as St, push as T, AsyncMapper as Tt, RouteInputFor as U, CompositeLoggerFactory as Ut, stack as V, stableStringify as Vt, SafeErrorPageOptions as W, optional as Wt, implementController as X, num as Xt, defineOperation as Y, int as Yt, implementOperation as Z, oneOf as Zt, collectAllLeaves as _, removeHost as _t, LoadPageOptions as a, PluralCategory as at, findNode as b, None as bt, defineWebApp as c, interpolate as ct, runBeforeLoadGuards as d, VoidEventRecorder as dt, getLocaleAttributes as et, createSessionStore as f, ConsoleEventRecorder as ft, encodeSnapshot as g, getBaseUrl as gt, decodeSnapshot as h, buildUrl as ht, resolveInitialNavigation as i, resolveLocaleFromUrl as it, visibleSplitColumns as j, HostCheckResult as jt, selectTab as k, pipeAsync as kt, getWebPlan as l, resolvePluralKey as lt, createNavigationScopedState as m, generateUuid as mt, PageReference as n, isRtl as nt, PageLoadResult as o, PluralRuleProvider as ot, collectLeafKeys as p, CompositeEventRecorder as pt, defineApp as q, StrOptions as qt, definePage as r, makeLocaleInfo as rt, loadPage as s, englishPlural as st, parseCookieString as t, getTextDirection as tt, runAfterLoadGuards as u, WithFieldsRecorder as ut, collectVisibleDestinations as v, removeQueryParams as vt, popToRoot as w, LruMap as wt, mapNavigationLeaves as x, Optional as xt, findNearestStack as y, removeScheme as yt, leaf as z, HostGuardError as zt };
|
|
779
|
+
//# sourceMappingURL=cookies-Bpf9VayB.d.mts.map
|