@djvlc/runtime-core 1.1.1 → 1.2.0
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/index.cjs +1 -1
- package/dist/index.d.cts +388 -64
- package/dist/index.d.ts +388 -64
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,81 +1,176 @@
|
|
|
1
1
|
import * as _djvlc_contracts_types from '@djvlc/contracts-types';
|
|
2
|
-
import { PageResolveResponse, ActionResult, ExpressionContext, Expression, ExpressionValidationResult, ActionRef, EventHandler, HostApi, NavigateOptions, TrackEvent, DialogOptions, DialogResult, ToastOptions, ClipboardApi, StorageApi, ShareOptions, ShareResult, ConfirmOptions, ActionSheetOptions, ActionSheetResult, PreviewImageOptions, ScanCodeResult, ComponentContext, ErrorCode, ManifestItem, PageManifest,
|
|
2
|
+
import { PageResolveResponse, ActionResult, ExpressionContext, Expression, ExpressionValidationResult, ActionRef, EventHandler, HostApi, NavigateOptions, TrackEvent as TrackEvent$1, DialogOptions, DialogResult, ToastOptions, ClipboardApi, StorageApi, ShareOptions, ShareResult, ConfirmOptions, ActionSheetOptions, ActionSheetResult, PreviewImageOptions, ScanCodeResult, ComponentContext, ErrorCode, ManifestItem, PageManifest, PageSchema, CapabilityName, PageLifecycle } from '@djvlc/contracts-types';
|
|
3
3
|
export { ActionExecuteRequest, ActionExecuteResponse, ActionPolicy, ActionRef, ActionResult, AnyValueOrExpression, BlockedComponentInfo, BuiltinActionType, CapabilityDeclaration, CompatInfo, ComponentContext, ComponentMeta, ComponentNode, DataBinding, DataLoadStrategy, DataQueryRequest, DataQueryResponse, DialogOptions, DialogResult, ErrorCode, ErrorMessages, EventDeclaration, EventHandler, Expression, ExpressionContext, ExpressionLocal, ExpressionMeta, ExpressionType, ExpressionValidationResult, HostApi as HostAPI, HostApi, JsonValue, LayoutConfig, LayoutValues, LoopConfig, ManifestItem, NavigateOptions, NodeStyleConfig, PageConfig, PageLifecycle, PageManifest, PageMeta, PageSEO, PageSchema, PageState, PropDefinition, PropsSchema, RuntimeSpec, SchemaVersion, SemVer, StateFieldDefinition, ToastOptions, TrackEvent, UniqueId } from '@djvlc/contracts-types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* User API
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* User API Adapter(端口接口)
|
|
7
|
+
*
|
|
8
|
+
* runtime-core 只定义 Port 接口,不绑定任何 HTTP 客户端或鉴权实现。
|
|
9
|
+
* 由宿主注入实现(如 @djvlc/runtime-client-sdk 的 OpenApiUserAdapter)。
|
|
10
|
+
*
|
|
11
|
+
* 注意:此接口以 runtime domain 为中心,不暴露 OpenAPI Request/Response 类型。
|
|
9
12
|
*/
|
|
10
13
|
|
|
11
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* 页面解析参数
|
|
16
|
+
*/
|
|
12
17
|
interface ResolvePageParams {
|
|
18
|
+
/** 页面 ID */
|
|
13
19
|
pageId: string;
|
|
20
|
+
/** 用户 ID */
|
|
14
21
|
uid?: string;
|
|
22
|
+
/** 设备 ID */
|
|
15
23
|
deviceId?: string;
|
|
24
|
+
/** 环境 */
|
|
16
25
|
env?: 'preview' | 'staging' | 'prod';
|
|
26
|
+
/** 渠道 */
|
|
17
27
|
channel?: string;
|
|
28
|
+
/** 预览 Token */
|
|
18
29
|
previewToken?: string;
|
|
19
30
|
}
|
|
20
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* 动作执行参数
|
|
33
|
+
*/
|
|
21
34
|
interface ExecuteActionParams {
|
|
35
|
+
/** 动作类型 */
|
|
22
36
|
actionType: string;
|
|
37
|
+
/** 动作参数 */
|
|
23
38
|
params: Record<string, unknown>;
|
|
39
|
+
/** 上下文 */
|
|
24
40
|
context: {
|
|
25
41
|
pageVersionId: string;
|
|
26
42
|
uid?: string;
|
|
27
43
|
deviceId?: string;
|
|
28
44
|
channel?: string;
|
|
29
|
-
appId
|
|
45
|
+
appId?: string;
|
|
30
46
|
};
|
|
31
|
-
|
|
47
|
+
/** 幂等键 */
|
|
48
|
+
idempotencyKey?: string;
|
|
32
49
|
}
|
|
33
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* 查询执行参数
|
|
52
|
+
*/
|
|
34
53
|
interface ExecuteQueryParams {
|
|
54
|
+
/** 查询版本 ID */
|
|
35
55
|
queryVersionId: string;
|
|
36
|
-
|
|
56
|
+
/** 查询参数 */
|
|
57
|
+
params: Record<string, unknown>;
|
|
58
|
+
/** 上下文 */
|
|
37
59
|
context: {
|
|
38
60
|
pageVersionId: string;
|
|
39
61
|
uid?: string;
|
|
40
62
|
deviceId?: string;
|
|
41
63
|
};
|
|
42
64
|
}
|
|
43
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* 查询执行结果
|
|
67
|
+
*/
|
|
44
68
|
interface ExecuteQueryResult {
|
|
69
|
+
/** 是否成功 */
|
|
45
70
|
success: boolean;
|
|
71
|
+
/** 数据 */
|
|
46
72
|
data?: unknown;
|
|
73
|
+
/** 成功消息 */
|
|
47
74
|
message?: string;
|
|
75
|
+
/** 错误消息 */
|
|
48
76
|
errorMessage?: string;
|
|
49
77
|
}
|
|
50
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* 埋点上报参数
|
|
80
|
+
*/
|
|
51
81
|
interface TrackPayload {
|
|
82
|
+
/** 事件名称 */
|
|
52
83
|
eventName: string;
|
|
84
|
+
/** 事件参数 */
|
|
53
85
|
params?: Record<string, unknown>;
|
|
54
|
-
|
|
86
|
+
/** 事件类型 */
|
|
87
|
+
type?: 'page_view' | 'click' | 'exposure' | 'custom';
|
|
88
|
+
/** 时间戳 */
|
|
55
89
|
timestamp?: number;
|
|
90
|
+
/** 上下文 */
|
|
56
91
|
context: {
|
|
57
92
|
pageVersionId: string;
|
|
58
|
-
runtimeVersion
|
|
93
|
+
runtimeVersion?: string;
|
|
59
94
|
userId?: string;
|
|
60
95
|
deviceId?: string;
|
|
61
96
|
channel?: string;
|
|
62
|
-
appId
|
|
63
|
-
env
|
|
97
|
+
appId?: string;
|
|
98
|
+
env?: string;
|
|
64
99
|
};
|
|
65
100
|
}
|
|
66
101
|
/**
|
|
67
|
-
* User API
|
|
68
|
-
*
|
|
102
|
+
* User API 适配器接口
|
|
103
|
+
*
|
|
104
|
+
* 统一 runtime 对 User API 的调用,所有请求头、鉴权、重试等逻辑由实现方处理。
|
|
105
|
+
* runtime-core 不绑定任何具体 HTTP 客户端。
|
|
69
106
|
*/
|
|
70
107
|
interface UserApiAdapter {
|
|
71
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* 解析页面
|
|
110
|
+
* @param params 解析参数
|
|
111
|
+
* @returns 页面解析响应
|
|
112
|
+
*/
|
|
113
|
+
resolvePage(params: ResolvePageParams): Promise<PageResolveResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* 执行动作
|
|
116
|
+
* @param params 动作参数
|
|
117
|
+
* @returns 动作结果
|
|
118
|
+
*/
|
|
119
|
+
executeAction<T = unknown>(params: ExecuteActionParams): Promise<ActionResult<T>>;
|
|
120
|
+
/**
|
|
121
|
+
* 执行查询
|
|
122
|
+
* @param params 查询参数
|
|
123
|
+
* @returns 查询结果
|
|
124
|
+
*/
|
|
125
|
+
executeQuery(params: ExecuteQueryParams): Promise<ExecuteQueryResult>;
|
|
126
|
+
/**
|
|
127
|
+
* 埋点上报
|
|
128
|
+
* @param payload 埋点数据
|
|
129
|
+
*/
|
|
130
|
+
track(payload: TrackPayload): void;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Mock 适配器配置
|
|
134
|
+
*/
|
|
135
|
+
interface MockUserApiAdapterOptions {
|
|
136
|
+
/** 模拟延迟(毫秒) */
|
|
137
|
+
delay?: number;
|
|
138
|
+
/** 模拟页面数据(兼容旧字段名) */
|
|
139
|
+
mockPage?: PageResolveResponse;
|
|
140
|
+
/** 页面解析响应(推荐使用) */
|
|
141
|
+
resolvePageResponse?: PageResolveResponse;
|
|
142
|
+
/** 解析页面时抛出的错误 */
|
|
143
|
+
resolvePageThrow?: Error;
|
|
144
|
+
/** 模拟动作结果 */
|
|
145
|
+
mockActionResult?: <T>() => ActionResult<T>;
|
|
146
|
+
/** 模拟查询结果 */
|
|
147
|
+
mockQueryResult?: () => ExecuteQueryResult;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 调用记录
|
|
151
|
+
*/
|
|
152
|
+
interface MockUserApiAdapterCalls {
|
|
153
|
+
resolvePage: ResolvePageParams[];
|
|
154
|
+
executeAction: ExecuteActionParams[];
|
|
155
|
+
executeQuery: ExecuteQueryParams[];
|
|
156
|
+
track: TrackPayload[];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Mock User API 适配器
|
|
160
|
+
* 用于单元测试和开发环境
|
|
161
|
+
*/
|
|
162
|
+
declare class MockUserApiAdapter implements UserApiAdapter {
|
|
163
|
+
private options;
|
|
164
|
+
/** 调用记录 */
|
|
165
|
+
calls: MockUserApiAdapterCalls;
|
|
166
|
+
constructor(options?: MockUserApiAdapterOptions);
|
|
72
167
|
resolvePage(params: ResolvePageParams): Promise<PageResolveResponse>;
|
|
73
|
-
/** 动作执行 POST /actions/execute */
|
|
74
168
|
executeAction<T = unknown>(params: ExecuteActionParams): Promise<ActionResult<T>>;
|
|
75
|
-
/** 数据查询 POST /data/query */
|
|
76
169
|
executeQuery(params: ExecuteQueryParams): Promise<ExecuteQueryResult>;
|
|
77
|
-
/** 埋点 POST /track(可异步、不阻塞) */
|
|
78
170
|
track(payload: TrackPayload): void;
|
|
171
|
+
private delay;
|
|
172
|
+
/** 重置调用记录 */
|
|
173
|
+
resetCalls(): void;
|
|
79
174
|
}
|
|
80
175
|
|
|
81
176
|
/**
|
|
@@ -919,44 +1014,6 @@ declare class ActionBridge {
|
|
|
919
1014
|
private log;
|
|
920
1015
|
}
|
|
921
1016
|
|
|
922
|
-
/**
|
|
923
|
-
* 测试用 User API 适配器 Mock
|
|
924
|
-
* 单测中注入,不再 mock global.fetch
|
|
925
|
-
*/
|
|
926
|
-
|
|
927
|
-
interface MockUserApiAdapterOptions {
|
|
928
|
-
/** resolvePage 返回值(可覆盖) */
|
|
929
|
-
resolvePageResponse?: PageResolveResponse;
|
|
930
|
-
/** executeAction 返回值(可覆盖) */
|
|
931
|
-
executeActionResponse?: ActionResult<unknown>;
|
|
932
|
-
/** executeQuery 返回值(可覆盖) */
|
|
933
|
-
executeQueryResponse?: ExecuteQueryResult;
|
|
934
|
-
/** 是否在 resolve 时抛错 */
|
|
935
|
-
resolvePageThrow?: Error;
|
|
936
|
-
/** 是否在 executeAction 时抛错 */
|
|
937
|
-
executeActionThrow?: Error;
|
|
938
|
-
/** 是否在 executeQuery 时抛错 */
|
|
939
|
-
executeQueryThrow?: Error;
|
|
940
|
-
}
|
|
941
|
-
/**
|
|
942
|
-
* 测试用 Mock 实现
|
|
943
|
-
* 记录调用次数与参数,返回可配置的默认值或自定义值
|
|
944
|
-
*/
|
|
945
|
-
declare class MockUserApiAdapter implements UserApiAdapter {
|
|
946
|
-
private readonly options;
|
|
947
|
-
readonly calls: {
|
|
948
|
-
resolvePage: ResolvePageParams[];
|
|
949
|
-
executeAction: ExecuteActionParams[];
|
|
950
|
-
executeQuery: ExecuteQueryParams[];
|
|
951
|
-
track: TrackPayload[];
|
|
952
|
-
};
|
|
953
|
-
constructor(options?: MockUserApiAdapterOptions);
|
|
954
|
-
resolvePage(params: ResolvePageParams): Promise<PageResolveResponse>;
|
|
955
|
-
executeAction<T = unknown>(params: ExecuteActionParams): Promise<ActionResult<T>>;
|
|
956
|
-
executeQuery(params: ExecuteQueryParams): Promise<ExecuteQueryResult>;
|
|
957
|
-
track(payload: TrackPayload): void;
|
|
958
|
-
}
|
|
959
|
-
|
|
960
1017
|
/**
|
|
961
1018
|
* Host API 实现
|
|
962
1019
|
* 提供给组件的安全 API,完全对齐 @djvlc/contracts-types 中的 HostApi 定义
|
|
@@ -1013,7 +1070,7 @@ declare class HostAPIImpl implements HostApi {
|
|
|
1013
1070
|
private loadingElement;
|
|
1014
1071
|
constructor(options: HostAPIOptions);
|
|
1015
1072
|
navigate(options: NavigateOptions): Promise<void>;
|
|
1016
|
-
track(event: TrackEvent): void;
|
|
1073
|
+
track(event: TrackEvent$1): void;
|
|
1017
1074
|
requestData<T = unknown>(queryId: string, params?: Record<string, unknown>): Promise<T>;
|
|
1018
1075
|
executeAction<T = unknown>(actionType: string, params?: Record<string, unknown>): Promise<ActionResult<T>>;
|
|
1019
1076
|
openDialog(options: DialogOptions): Promise<DialogResult>;
|
|
@@ -1084,6 +1141,14 @@ declare class DjvlcRuntime {
|
|
|
1084
1141
|
* 初始化运行时
|
|
1085
1142
|
*/
|
|
1086
1143
|
init(): Promise<void>;
|
|
1144
|
+
/**
|
|
1145
|
+
* 从已解析的页面结果加载(供 SDK resolve 后注入,跳过 API + CDN 请求)
|
|
1146
|
+
*/
|
|
1147
|
+
loadFromResolved(page: PageResolveResult): Promise<PageResolveResult>;
|
|
1148
|
+
/**
|
|
1149
|
+
* 注入预取数据到 dataStore(query 缓存),供 SDK applyPrefetch 使用
|
|
1150
|
+
*/
|
|
1151
|
+
setPrefetchedData(data: Record<string, unknown>): void;
|
|
1087
1152
|
/**
|
|
1088
1153
|
* 加载页面
|
|
1089
1154
|
*/
|
|
@@ -1136,6 +1201,12 @@ declare class DjvlcRuntime {
|
|
|
1136
1201
|
* 验证 Schema 版本
|
|
1137
1202
|
*/
|
|
1138
1203
|
private validateSchemaVersion;
|
|
1204
|
+
/**
|
|
1205
|
+
* 安全解析 URL 的 host 部分
|
|
1206
|
+
* 支持绝对 URL(http://localhost:3000)和相对路径(/api)
|
|
1207
|
+
* 相对路径时使用 window.location.origin 作为 base
|
|
1208
|
+
*/
|
|
1209
|
+
private safeParseHost;
|
|
1139
1210
|
private resolveContainer;
|
|
1140
1211
|
private initHostApi;
|
|
1141
1212
|
private initActionBridge;
|
|
@@ -1297,7 +1368,8 @@ declare class PageLoader {
|
|
|
1297
1368
|
*/
|
|
1298
1369
|
private callResolveViaAdapter;
|
|
1299
1370
|
/**
|
|
1300
|
-
* 从 CDN 加载 snapshot
|
|
1371
|
+
* 从 CDN 加载 snapshot
|
|
1372
|
+
* 仅支持标准 PageSnapshotJson 格式:{ page, manifest, definitionsDigest, ops, meta }
|
|
1301
1373
|
*/
|
|
1302
1374
|
private loadFromCdn;
|
|
1303
1375
|
/**
|
|
@@ -1311,7 +1383,11 @@ declare class PageLoader {
|
|
|
1311
1383
|
private convertSnapshotPageToPageSchema;
|
|
1312
1384
|
/**
|
|
1313
1385
|
* 转换 PageSnapshotManifest 为 PageManifest
|
|
1314
|
-
*
|
|
1386
|
+
*
|
|
1387
|
+
* 注意:PageSnapshotManifest 是简化版本,缺少一些字段,需要从其他地方获取或使用默认值。
|
|
1388
|
+
* 根据 `comp.source` 区分 bundled/remote:
|
|
1389
|
+
* - bundled:entry/styleEntry 留空(内置组件无需 CDN 入口)
|
|
1390
|
+
* - remote:从 assetsUrl + entrypoints 拼接 entry/styleEntry
|
|
1315
1391
|
*/
|
|
1316
1392
|
private convertSnapshotManifestToPageManifest;
|
|
1317
1393
|
/**
|
|
@@ -1371,6 +1447,10 @@ declare class ComponentLoader {
|
|
|
1371
1447
|
constructor(options: ComponentLoaderOptions);
|
|
1372
1448
|
/**
|
|
1373
1449
|
* 加载单个组件(按 name@version 去重,同一组件并发请求复用同一 Promise)
|
|
1450
|
+
*
|
|
1451
|
+
* 对于 `source: 'bundled'` 的内置组件,直接返回已注册的 Custom Element,跳过 CDN 加载。
|
|
1452
|
+
* 对于 `source: 'remote'` 的远程组件,通过 CDN 拉取脚本并执行。
|
|
1453
|
+
*
|
|
1374
1454
|
* @param item - 清单项(name、version、entry、integrity 等)
|
|
1375
1455
|
* @returns 已加载的组件信息(含 Component 构造函数)
|
|
1376
1456
|
* @throws ComponentBlockedError 当组件在阻断列表中
|
|
@@ -1386,6 +1466,7 @@ declare class ComponentLoader {
|
|
|
1386
1466
|
loadAll(manifest: PageManifest): Promise<Map<string, ComponentLoadResult>>;
|
|
1387
1467
|
/**
|
|
1388
1468
|
* 预加载组件:向 document.head 插入 <link rel="preload" as="script">,仅作提示,不阻塞 load。
|
|
1469
|
+
* 内置组件(source: 'bundled')和无 entry 的组件会被跳过。
|
|
1389
1470
|
* @param items - 需要预加载的清单项
|
|
1390
1471
|
*/
|
|
1391
1472
|
preload(items: ManifestItem[]): void;
|
|
@@ -1476,6 +1557,229 @@ declare class AssetLoader {
|
|
|
1476
1557
|
loadScript(url: string, integrity?: string): Promise<void>;
|
|
1477
1558
|
}
|
|
1478
1559
|
|
|
1560
|
+
/** Tenant 解析入参 */
|
|
1561
|
+
interface ResolveTenantInput {
|
|
1562
|
+
/** 请求 Host */
|
|
1563
|
+
host?: string;
|
|
1564
|
+
/** 请求路径 */
|
|
1565
|
+
path?: string;
|
|
1566
|
+
/** 额外请求头 */
|
|
1567
|
+
headers?: Record<string, string>;
|
|
1568
|
+
}
|
|
1569
|
+
/** Tenant 解析结果 */
|
|
1570
|
+
interface ResolveTenantResult {
|
|
1571
|
+
/** 租户 ID */
|
|
1572
|
+
tenantId: string;
|
|
1573
|
+
/** 租户配置 */
|
|
1574
|
+
config: unknown;
|
|
1575
|
+
}
|
|
1576
|
+
/** Tenant 端口 */
|
|
1577
|
+
interface TenantPort {
|
|
1578
|
+
resolveTenant(input: ResolveTenantInput): Promise<ResolveTenantResult>;
|
|
1579
|
+
}
|
|
1580
|
+
/** 客户端信息 */
|
|
1581
|
+
interface ClientInfo {
|
|
1582
|
+
/** User Agent */
|
|
1583
|
+
ua?: string;
|
|
1584
|
+
/** IP 地址 */
|
|
1585
|
+
ip?: string;
|
|
1586
|
+
/** 设备 ID */
|
|
1587
|
+
deviceId?: string;
|
|
1588
|
+
}
|
|
1589
|
+
/** 认证信息 */
|
|
1590
|
+
interface AuthInfo {
|
|
1591
|
+
/** Token(runtime 只关心有没有 token,怎么塞 header 由 adapter 决定) */
|
|
1592
|
+
token?: string;
|
|
1593
|
+
}
|
|
1594
|
+
/** 追踪信息 */
|
|
1595
|
+
interface TraceInfo {
|
|
1596
|
+
/** Trace ID */
|
|
1597
|
+
traceId?: string;
|
|
1598
|
+
/** Span ID */
|
|
1599
|
+
spanId?: string;
|
|
1600
|
+
}
|
|
1601
|
+
/** Page 解析入参(以 runtime 需要为准) */
|
|
1602
|
+
interface ResolvePageInput {
|
|
1603
|
+
/** 租户 ID */
|
|
1604
|
+
tenantId?: string;
|
|
1605
|
+
/** 页面 ID */
|
|
1606
|
+
pageId: string;
|
|
1607
|
+
/** 页面版本 ID(支持灰度/回滚/复现) */
|
|
1608
|
+
pageVersionId?: string;
|
|
1609
|
+
/** 语言 */
|
|
1610
|
+
locale?: string;
|
|
1611
|
+
/** 用户 ID */
|
|
1612
|
+
uid?: string;
|
|
1613
|
+
/** 客户端信息 */
|
|
1614
|
+
client?: ClientInfo;
|
|
1615
|
+
/** 认证信息 */
|
|
1616
|
+
auth?: AuthInfo;
|
|
1617
|
+
/** 追踪信息 */
|
|
1618
|
+
trace?: TraceInfo;
|
|
1619
|
+
/** 超时(毫秒) */
|
|
1620
|
+
timeoutMs?: number;
|
|
1621
|
+
/** AbortSignal */
|
|
1622
|
+
signal?: AbortSignal;
|
|
1623
|
+
}
|
|
1624
|
+
/** 缓存状态 */
|
|
1625
|
+
type CacheStatus = 'HIT' | 'MISS' | 'BYPASS';
|
|
1626
|
+
/** Page 解析结果元数据 */
|
|
1627
|
+
interface ResolvePageMeta {
|
|
1628
|
+
/** 缓存状态 */
|
|
1629
|
+
cache: CacheStatus;
|
|
1630
|
+
/** 解析时间戳 */
|
|
1631
|
+
resolvedAt: number;
|
|
1632
|
+
/** ETag */
|
|
1633
|
+
etag?: string;
|
|
1634
|
+
/** 缓存 TTL(秒) */
|
|
1635
|
+
cacheTtlSeconds?: number;
|
|
1636
|
+
}
|
|
1637
|
+
/** Page 解析结果(含 schema 与可选预取数据) */
|
|
1638
|
+
interface ResolvePageResult {
|
|
1639
|
+
/** 页面版本 ID */
|
|
1640
|
+
pageVersionId: string;
|
|
1641
|
+
/** 页面 Schema(严格类型) */
|
|
1642
|
+
page: PageSchema;
|
|
1643
|
+
/** 预取数据,可注入 runtime 的 dataStore(query 缓存) */
|
|
1644
|
+
prefetchedData?: Record<string, unknown>;
|
|
1645
|
+
/** 元数据 */
|
|
1646
|
+
meta: ResolvePageMeta;
|
|
1647
|
+
/** 完整页面解析结果,供 runtime.loadFromResolved() 使用 */
|
|
1648
|
+
pageResolveResult?: PageResolveResult;
|
|
1649
|
+
}
|
|
1650
|
+
/** Page Runtime 端口(核心) */
|
|
1651
|
+
interface PageRuntimePort {
|
|
1652
|
+
resolvePage(input: ResolvePageInput): Promise<ResolvePageResult>;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
/** Data 查询入参 */
|
|
1656
|
+
interface DataQueryInput {
|
|
1657
|
+
/** 租户 ID */
|
|
1658
|
+
tenantId?: string;
|
|
1659
|
+
/** 查询版本 ID */
|
|
1660
|
+
queryVersionId: string;
|
|
1661
|
+
/** 查询参数 */
|
|
1662
|
+
params: unknown;
|
|
1663
|
+
/** 上下文 */
|
|
1664
|
+
context: {
|
|
1665
|
+
pageId: string;
|
|
1666
|
+
pageVersionId: string;
|
|
1667
|
+
componentId?: string;
|
|
1668
|
+
uid?: string;
|
|
1669
|
+
deviceId?: string;
|
|
1670
|
+
};
|
|
1671
|
+
/** 追踪信息 */
|
|
1672
|
+
trace?: TraceInfo;
|
|
1673
|
+
/** 超时(毫秒) */
|
|
1674
|
+
timeoutMs?: number;
|
|
1675
|
+
/** AbortSignal */
|
|
1676
|
+
signal?: AbortSignal;
|
|
1677
|
+
}
|
|
1678
|
+
/** Data 查询结果 */
|
|
1679
|
+
interface DataQueryResult<T = unknown> {
|
|
1680
|
+
/** 是否成功 */
|
|
1681
|
+
ok: boolean;
|
|
1682
|
+
/** 数据 */
|
|
1683
|
+
data?: T;
|
|
1684
|
+
/** 错误信息 */
|
|
1685
|
+
error?: {
|
|
1686
|
+
code: string;
|
|
1687
|
+
message?: string;
|
|
1688
|
+
details?: unknown;
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
/** Data 端口 */
|
|
1692
|
+
interface DataPort {
|
|
1693
|
+
query<T = unknown>(input: DataQueryInput): Promise<DataQueryResult<T>>;
|
|
1694
|
+
}
|
|
1695
|
+
/** Action 执行入参 */
|
|
1696
|
+
interface ActionExecuteInput {
|
|
1697
|
+
/** 租户 ID */
|
|
1698
|
+
tenantId?: string;
|
|
1699
|
+
/** 动作类型 */
|
|
1700
|
+
actionType: 'claim' | 'signin' | 'lottery' | 'form_submit' | 'custom' | string;
|
|
1701
|
+
/** 动作参数(用 contracts schema 校验) */
|
|
1702
|
+
payload: unknown;
|
|
1703
|
+
/** 上下文 */
|
|
1704
|
+
context: {
|
|
1705
|
+
pageId: string;
|
|
1706
|
+
pageVersionId: string;
|
|
1707
|
+
componentId?: string;
|
|
1708
|
+
uid?: string;
|
|
1709
|
+
deviceId?: string;
|
|
1710
|
+
};
|
|
1711
|
+
/** 幂等键 */
|
|
1712
|
+
idempotencyKey?: string;
|
|
1713
|
+
/** 追踪信息 */
|
|
1714
|
+
trace?: TraceInfo;
|
|
1715
|
+
/** 超时(毫秒) */
|
|
1716
|
+
timeoutMs?: number;
|
|
1717
|
+
/** AbortSignal */
|
|
1718
|
+
signal?: AbortSignal;
|
|
1719
|
+
}
|
|
1720
|
+
/** Action 执行结果 */
|
|
1721
|
+
interface ActionExecuteResult<T = unknown> {
|
|
1722
|
+
/** 是否成功 */
|
|
1723
|
+
ok: boolean;
|
|
1724
|
+
/** 结果数据(同样用 contracts schema 校验) */
|
|
1725
|
+
data?: T;
|
|
1726
|
+
/** 错误信息 */
|
|
1727
|
+
error?: {
|
|
1728
|
+
code: string;
|
|
1729
|
+
message?: string;
|
|
1730
|
+
details?: unknown;
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
/** Action 端口 */
|
|
1734
|
+
interface ActionPort {
|
|
1735
|
+
executeAction<T = unknown>(input: ActionExecuteInput): Promise<ActionExecuteResult<T>>;
|
|
1736
|
+
}
|
|
1737
|
+
/** 埋点事件 */
|
|
1738
|
+
interface TrackEvent {
|
|
1739
|
+
/** 事件名称 */
|
|
1740
|
+
eventName: string;
|
|
1741
|
+
/** 事件类型 */
|
|
1742
|
+
eventType: 'page_view' | 'click' | 'exposure' | 'action' | 'custom';
|
|
1743
|
+
/** 事件属性 */
|
|
1744
|
+
properties?: Record<string, unknown>;
|
|
1745
|
+
/** 时间戳 */
|
|
1746
|
+
timestamp?: number;
|
|
1747
|
+
}
|
|
1748
|
+
/** Track 入参 */
|
|
1749
|
+
interface TrackInput {
|
|
1750
|
+
/** 租户 ID */
|
|
1751
|
+
tenantId?: string;
|
|
1752
|
+
/** 事件列表(批量上报) */
|
|
1753
|
+
events: TrackEvent[];
|
|
1754
|
+
/** 上下文 */
|
|
1755
|
+
context: {
|
|
1756
|
+
pageId: string;
|
|
1757
|
+
pageVersionId: string;
|
|
1758
|
+
uid?: string;
|
|
1759
|
+
deviceId?: string;
|
|
1760
|
+
sessionId?: string;
|
|
1761
|
+
};
|
|
1762
|
+
/** 追踪信息 */
|
|
1763
|
+
trace?: TraceInfo;
|
|
1764
|
+
}
|
|
1765
|
+
/** Track 端口 */
|
|
1766
|
+
interface TrackPort {
|
|
1767
|
+
track(input: TrackInput): Promise<void>;
|
|
1768
|
+
}
|
|
1769
|
+
/** 聚合 Ports,供 SDK 实现并注入 */
|
|
1770
|
+
interface RuntimePorts {
|
|
1771
|
+
/** 租户端口 */
|
|
1772
|
+
tenant?: TenantPort;
|
|
1773
|
+
/** 页面端口 */
|
|
1774
|
+
page: PageRuntimePort;
|
|
1775
|
+
/** 数据端口 */
|
|
1776
|
+
data: DataPort;
|
|
1777
|
+
/** 动作端口 */
|
|
1778
|
+
action: ActionPort;
|
|
1779
|
+
/** 埋点端口 */
|
|
1780
|
+
track: TrackPort;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1479
1783
|
/**
|
|
1480
1784
|
* 安全管理器
|
|
1481
1785
|
* SRI 校验、域名白名单、组件阻止、能力校验等
|
|
@@ -1876,6 +2180,26 @@ declare function registerFallbackComponents(): void;
|
|
|
1876
2180
|
*/
|
|
1877
2181
|
declare function createFallbackElement(type: 'fallback' | 'blocked' | 'error', message?: string, componentName?: string): HTMLElement;
|
|
1878
2182
|
|
|
2183
|
+
/**
|
|
2184
|
+
* 内置组件注册器
|
|
2185
|
+
*
|
|
2186
|
+
* 在 Runtime.init() 阶段调用 registerBuiltinComponents(),
|
|
2187
|
+
* 将所有内置组件注册为 Custom Elements,供 BaseRenderer.createElement() 使用。
|
|
2188
|
+
*
|
|
2189
|
+
* 幂等:重复调用不会报错(通过 customElements.get 检查是否已注册)。
|
|
2190
|
+
*/
|
|
2191
|
+
/**
|
|
2192
|
+
* 注册所有内置组件为 Custom Elements
|
|
2193
|
+
*
|
|
2194
|
+
* @description
|
|
2195
|
+
* - 幂等:已注册的组件跳过
|
|
2196
|
+
* - 顺序无关:每个组件独立注册
|
|
2197
|
+
* - 日志:在 debug 模式下输出注册信息
|
|
2198
|
+
*
|
|
2199
|
+
* @param debug - 是否打印调试日志,默认 false
|
|
2200
|
+
*/
|
|
2201
|
+
declare function registerBuiltinComponents(debug?: boolean): void;
|
|
2202
|
+
|
|
1879
2203
|
/**
|
|
1880
2204
|
* 遥测管理器
|
|
1881
2205
|
* 链路追踪、性能监控、错误上报
|
|
@@ -2167,4 +2491,4 @@ declare class LifecycleManager {
|
|
|
2167
2491
|
*/
|
|
2168
2492
|
declare const RUNTIME_VERSION = "1.0.0";
|
|
2169
2493
|
|
|
2170
|
-
export { type ASTNode, ActionBridge, type ActionBridgeOptions, ActionError, type ActionExecutor, AssetLoader, type AssetLoaderOptions, BaseRenderer, type BaseRendererOptions, ComponentBlockedError, ComponentLoadError, type ComponentLoadResult, type ComponentLoadStatus, ComponentLoader, type ComponentLoaderOptions, DjvlcRuntime, DjvlcRuntimeError, type EvaluationResult, Evaluator, type EvaluatorOptions, EventBus, type EventBusOptions, type EventHandlerFn, type ExecuteActionParams, type ExecuteQueryParams, type ExecuteQueryResult, ExpressionEngine, type ExpressionEngineOptions, ExpressionError, HostAPIImpl, type HostAPIOptions, IntegrityError, Lexer, type LifecycleEventType, LifecycleManager, type LifecycleManagerOptions, type LoadedComponent, type LogLevel, type Logger, type MetricType, MockUserApiAdapter, type MockUserApiAdapterOptions, PageLoadError, PageLoader, type PageLoaderOptions, type PageResolveResult, Parser, type PerformanceMetric, QueryError, RUNTIME_VERSION, RenderError, type Renderer, type ResolvePageParams, type RuntimeContext, type RuntimeError, type RuntimeErrorType, type RuntimeEvent, type RuntimeEventType, type RuntimeOptions, type RuntimePhase, type RuntimeState, SUPPORTED_SCHEMA_VERSION as SCHEMA_VERSION, SUPPORTED_SCHEMA_VERSION, SecurityManager, type SecurityManagerOptions, type Span, type StateListener, StateManager, TelemetryManager, type TelemetryManagerOptions, type Token, type TokenType, type TrackPayload, type Unsubscribe, type UserApiAdapter, builtinFunctions, createFallbackElement, createRuntime, registerFallbackComponents };
|
|
2494
|
+
export { type ASTNode, ActionBridge, type ActionBridgeOptions, ActionError, type ActionExecuteInput, type ActionExecuteResult, type ActionExecutor, type ActionPort, AssetLoader, type AssetLoaderOptions, type AuthInfo, BaseRenderer, type BaseRendererOptions, type CacheStatus, type ClientInfo, ComponentBlockedError, ComponentLoadError, type ComponentLoadResult, type ComponentLoadStatus, ComponentLoader, type ComponentLoaderOptions, type DataPort, type DataQueryInput, type DataQueryResult, DjvlcRuntime, DjvlcRuntimeError, type EvaluationResult, Evaluator, type EvaluatorOptions, EventBus, type EventBusOptions, type EventHandlerFn, type ExecuteActionParams, type ExecuteQueryParams, type ExecuteQueryResult, ExpressionEngine, type ExpressionEngineOptions, ExpressionError, HostAPIImpl, type HostAPIOptions, IntegrityError, Lexer, type LifecycleEventType, LifecycleManager, type LifecycleManagerOptions, type LoadedComponent, type LogLevel, type Logger, type MetricType, MockUserApiAdapter, type MockUserApiAdapterOptions, PageLoadError, PageLoader, type PageLoaderOptions, type PageRuntimePort as PagePort, type PageResolveResult, type PageRuntimePort, Parser, type PerformanceMetric, type TrackEvent as PortTrackEvent, QueryError, RUNTIME_VERSION, RenderError, type Renderer, type ResolvePageInput, type ResolvePageMeta, type ResolvePageParams, type ResolvePageResult, type ResolveTenantInput, type ResolveTenantResult, type RuntimeContext, type RuntimeError, type RuntimeErrorType, type RuntimeEvent, type RuntimeEventType, type RuntimeOptions, type RuntimePhase, type RuntimePorts, type RuntimeState, SUPPORTED_SCHEMA_VERSION as SCHEMA_VERSION, SUPPORTED_SCHEMA_VERSION, SecurityManager, type SecurityManagerOptions, type Span, type StateListener, StateManager, TelemetryManager, type TelemetryManagerOptions, type TenantPort, type Token, type TokenType, type TraceInfo, type TrackInput, type TrackPayload, type TrackPort, type Unsubscribe, type UserApiAdapter, builtinFunctions, createFallbackElement, createRuntime, registerBuiltinComponents, registerFallbackComponents };
|