@djvlc/runtime-core 1.1.0 → 1.1.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/dist/index.cjs +1 -1
- package/dist/index.d.cts +407 -137
- package/dist/index.d.ts +407 -137
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,177 @@
|
|
|
1
1
|
import * as _djvlc_contracts_types from '@djvlc/contracts-types';
|
|
2
|
-
import { ExpressionContext, Expression, ExpressionValidationResult, ActionRef, EventHandler,
|
|
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
|
+
/**
|
|
6
|
+
* User API Adapter(端口接口)
|
|
7
|
+
*
|
|
8
|
+
* runtime-core 只定义 Port 接口,不绑定任何 HTTP 客户端或鉴权实现。
|
|
9
|
+
* 由宿主注入实现(如 @djvlc/runtime-client-sdk 的 OpenApiUserAdapter)。
|
|
10
|
+
*
|
|
11
|
+
* 注意:此接口以 runtime domain 为中心,不暴露 OpenAPI Request/Response 类型。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 页面解析参数
|
|
16
|
+
*/
|
|
17
|
+
interface ResolvePageParams {
|
|
18
|
+
/** 页面 ID */
|
|
19
|
+
pageId: string;
|
|
20
|
+
/** 用户 ID */
|
|
21
|
+
uid?: string;
|
|
22
|
+
/** 设备 ID */
|
|
23
|
+
deviceId?: string;
|
|
24
|
+
/** 环境 */
|
|
25
|
+
env?: 'preview' | 'staging' | 'prod';
|
|
26
|
+
/** 渠道 */
|
|
27
|
+
channel?: string;
|
|
28
|
+
/** 预览 Token */
|
|
29
|
+
previewToken?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 动作执行参数
|
|
33
|
+
*/
|
|
34
|
+
interface ExecuteActionParams {
|
|
35
|
+
/** 动作类型 */
|
|
36
|
+
actionType: string;
|
|
37
|
+
/** 动作参数 */
|
|
38
|
+
params: Record<string, unknown>;
|
|
39
|
+
/** 上下文 */
|
|
40
|
+
context: {
|
|
41
|
+
pageVersionId: string;
|
|
42
|
+
uid?: string;
|
|
43
|
+
deviceId?: string;
|
|
44
|
+
channel?: string;
|
|
45
|
+
appId?: string;
|
|
46
|
+
};
|
|
47
|
+
/** 幂等键 */
|
|
48
|
+
idempotencyKey?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 查询执行参数
|
|
52
|
+
*/
|
|
53
|
+
interface ExecuteQueryParams {
|
|
54
|
+
/** 查询版本 ID */
|
|
55
|
+
queryVersionId: string;
|
|
56
|
+
/** 查询参数 */
|
|
57
|
+
params: Record<string, unknown>;
|
|
58
|
+
/** 上下文 */
|
|
59
|
+
context: {
|
|
60
|
+
pageVersionId: string;
|
|
61
|
+
uid?: string;
|
|
62
|
+
deviceId?: string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 查询执行结果
|
|
67
|
+
*/
|
|
68
|
+
interface ExecuteQueryResult {
|
|
69
|
+
/** 是否成功 */
|
|
70
|
+
success: boolean;
|
|
71
|
+
/** 数据 */
|
|
72
|
+
data?: unknown;
|
|
73
|
+
/** 成功消息 */
|
|
74
|
+
message?: string;
|
|
75
|
+
/** 错误消息 */
|
|
76
|
+
errorMessage?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 埋点上报参数
|
|
80
|
+
*/
|
|
81
|
+
interface TrackPayload {
|
|
82
|
+
/** 事件名称 */
|
|
83
|
+
eventName: string;
|
|
84
|
+
/** 事件参数 */
|
|
85
|
+
params?: Record<string, unknown>;
|
|
86
|
+
/** 事件类型 */
|
|
87
|
+
type?: 'page_view' | 'click' | 'exposure' | 'custom';
|
|
88
|
+
/** 时间戳 */
|
|
89
|
+
timestamp?: number;
|
|
90
|
+
/** 上下文 */
|
|
91
|
+
context: {
|
|
92
|
+
pageVersionId: string;
|
|
93
|
+
runtimeVersion?: string;
|
|
94
|
+
userId?: string;
|
|
95
|
+
deviceId?: string;
|
|
96
|
+
channel?: string;
|
|
97
|
+
appId?: string;
|
|
98
|
+
env?: string;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* User API 适配器接口
|
|
103
|
+
*
|
|
104
|
+
* 统一 runtime 对 User API 的调用,所有请求头、鉴权、重试等逻辑由实现方处理。
|
|
105
|
+
* runtime-core 不绑定任何具体 HTTP 客户端。
|
|
106
|
+
*/
|
|
107
|
+
interface UserApiAdapter {
|
|
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);
|
|
167
|
+
resolvePage(params: ResolvePageParams): Promise<PageResolveResponse>;
|
|
168
|
+
executeAction<T = unknown>(params: ExecuteActionParams): Promise<ActionResult<T>>;
|
|
169
|
+
executeQuery(params: ExecuteQueryParams): Promise<ExecuteQueryResult>;
|
|
170
|
+
track(payload: TrackPayload): void;
|
|
171
|
+
private delay;
|
|
172
|
+
/** 重置调用记录 */
|
|
173
|
+
resetCalls(): void;
|
|
174
|
+
}
|
|
5
175
|
|
|
6
176
|
/**
|
|
7
177
|
* 运行时初始化选项
|
|
@@ -43,6 +213,8 @@ interface RuntimeOptions {
|
|
|
43
213
|
onMetric?: (metric: PerformanceMetric) => void;
|
|
44
214
|
/** 加载完成回调 */
|
|
45
215
|
onLoad?: (data: PageResolveResult) => void;
|
|
216
|
+
/** User API 适配器(必填,由宿主注入,core 不绑定具体 HTTP/鉴权实现) */
|
|
217
|
+
userApiAdapter: UserApiAdapter;
|
|
46
218
|
}
|
|
47
219
|
/**
|
|
48
220
|
* 运行时阶段
|
|
@@ -842,139 +1014,6 @@ declare class ActionBridge {
|
|
|
842
1014
|
private log;
|
|
843
1015
|
}
|
|
844
1016
|
|
|
845
|
-
/**
|
|
846
|
-
* User API 适配器接口
|
|
847
|
-
* 统一 Runtime 与 User API 的交互:页面解析、动作执行、数据查询、埋点
|
|
848
|
-
* 认证、请求头、重试等逻辑由实现类统一处理,便于测试与切换实现(如 openapi-user-client)
|
|
849
|
-
*/
|
|
850
|
-
|
|
851
|
-
/** 页面解析入参 */
|
|
852
|
-
interface ResolvePageParams {
|
|
853
|
-
pageId: string;
|
|
854
|
-
uid?: string;
|
|
855
|
-
deviceId?: string;
|
|
856
|
-
env?: 'preview' | 'staging' | 'prod';
|
|
857
|
-
channel?: string;
|
|
858
|
-
previewToken?: string;
|
|
859
|
-
}
|
|
860
|
-
/** 动作执行入参 */
|
|
861
|
-
interface ExecuteActionParams {
|
|
862
|
-
actionType: string;
|
|
863
|
-
params: Record<string, unknown>;
|
|
864
|
-
context: {
|
|
865
|
-
pageVersionId: string;
|
|
866
|
-
uid?: string;
|
|
867
|
-
deviceId?: string;
|
|
868
|
-
channel?: string;
|
|
869
|
-
appId: string;
|
|
870
|
-
};
|
|
871
|
-
idempotencyKey: string;
|
|
872
|
-
}
|
|
873
|
-
/** 数据查询入参 */
|
|
874
|
-
interface ExecuteQueryParams {
|
|
875
|
-
queryVersionId: string;
|
|
876
|
-
params?: Record<string, unknown>;
|
|
877
|
-
context: {
|
|
878
|
-
pageVersionId: string;
|
|
879
|
-
uid?: string;
|
|
880
|
-
deviceId?: string;
|
|
881
|
-
};
|
|
882
|
-
}
|
|
883
|
-
/** 数据查询出参(与 User API /data/query 一致) */
|
|
884
|
-
interface ExecuteQueryResult {
|
|
885
|
-
success: boolean;
|
|
886
|
-
data?: unknown;
|
|
887
|
-
message?: string;
|
|
888
|
-
errorMessage?: string;
|
|
889
|
-
}
|
|
890
|
-
/** 埋点 payload(与 User API /track 一致) */
|
|
891
|
-
interface TrackPayload {
|
|
892
|
-
eventName: string;
|
|
893
|
-
params?: Record<string, unknown>;
|
|
894
|
-
type?: string;
|
|
895
|
-
timestamp?: number;
|
|
896
|
-
context: {
|
|
897
|
-
pageVersionId: string;
|
|
898
|
-
runtimeVersion: string;
|
|
899
|
-
userId?: string;
|
|
900
|
-
deviceId?: string;
|
|
901
|
-
channel?: string;
|
|
902
|
-
appId: string;
|
|
903
|
-
env: string;
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
/**
|
|
907
|
-
* User API 适配器
|
|
908
|
-
* 只约定入参/出参,不绑定具体 HTTP 库;由 Runtime 注入实现,单测可注入 Mock
|
|
909
|
-
*/
|
|
910
|
-
interface UserApiAdapter {
|
|
911
|
-
/** 页面解析 GET /page/resolve */
|
|
912
|
-
resolvePage(params: ResolvePageParams): Promise<PageResolveResponse>;
|
|
913
|
-
/** 动作执行 POST /actions/execute */
|
|
914
|
-
executeAction<T = unknown>(params: ExecuteActionParams): Promise<ActionResult<T>>;
|
|
915
|
-
/** 数据查询 POST /data/query */
|
|
916
|
-
executeQuery(params: ExecuteQueryParams): Promise<ExecuteQueryResult>;
|
|
917
|
-
/** 埋点 POST /track(可异步、不阻塞) */
|
|
918
|
-
track(payload: TrackPayload): void;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
/**
|
|
922
|
-
* 基于 @djvlc/openapi-user-client 的 User API 适配器
|
|
923
|
-
* 统一认证、请求头、重试等逻辑,不直接使用 fetch
|
|
924
|
-
*/
|
|
925
|
-
|
|
926
|
-
type OpenApiUserAdapterOptions = UserClientConfig;
|
|
927
|
-
/**
|
|
928
|
-
* 基于 openapi-user-client 的 User API 适配器实现
|
|
929
|
-
* Runtime 与 User API 的交互仅通过此适配器
|
|
930
|
-
*/
|
|
931
|
-
declare class OpenApiUserAdapter implements UserApiAdapter {
|
|
932
|
-
private readonly client;
|
|
933
|
-
constructor(options?: OpenApiUserAdapterOptions);
|
|
934
|
-
resolvePage(params: ResolvePageParams): Promise<PageResolveResponse>;
|
|
935
|
-
executeAction<T = unknown>(params: ExecuteActionParams): Promise<ActionResult<T>>;
|
|
936
|
-
executeQuery(params: ExecuteQueryParams): Promise<ExecuteQueryResult>;
|
|
937
|
-
track(payload: TrackPayload): void;
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
/**
|
|
941
|
-
* 测试用 User API 适配器 Mock
|
|
942
|
-
* 单测中注入,不再 mock global.fetch
|
|
943
|
-
*/
|
|
944
|
-
|
|
945
|
-
interface MockUserApiAdapterOptions {
|
|
946
|
-
/** resolvePage 返回值(可覆盖) */
|
|
947
|
-
resolvePageResponse?: PageResolveResponse;
|
|
948
|
-
/** executeAction 返回值(可覆盖) */
|
|
949
|
-
executeActionResponse?: ActionResult<unknown>;
|
|
950
|
-
/** executeQuery 返回值(可覆盖) */
|
|
951
|
-
executeQueryResponse?: ExecuteQueryResult;
|
|
952
|
-
/** 是否在 resolve 时抛错 */
|
|
953
|
-
resolvePageThrow?: Error;
|
|
954
|
-
/** 是否在 executeAction 时抛错 */
|
|
955
|
-
executeActionThrow?: Error;
|
|
956
|
-
/** 是否在 executeQuery 时抛错 */
|
|
957
|
-
executeQueryThrow?: Error;
|
|
958
|
-
}
|
|
959
|
-
/**
|
|
960
|
-
* 测试用 Mock 实现
|
|
961
|
-
* 记录调用次数与参数,返回可配置的默认值或自定义值
|
|
962
|
-
*/
|
|
963
|
-
declare class MockUserApiAdapter implements UserApiAdapter {
|
|
964
|
-
private readonly options;
|
|
965
|
-
readonly calls: {
|
|
966
|
-
resolvePage: ResolvePageParams[];
|
|
967
|
-
executeAction: ExecuteActionParams[];
|
|
968
|
-
executeQuery: ExecuteQueryParams[];
|
|
969
|
-
track: TrackPayload[];
|
|
970
|
-
};
|
|
971
|
-
constructor(options?: MockUserApiAdapterOptions);
|
|
972
|
-
resolvePage(params: ResolvePageParams): Promise<PageResolveResponse>;
|
|
973
|
-
executeAction<T = unknown>(params: ExecuteActionParams): Promise<ActionResult<T>>;
|
|
974
|
-
executeQuery(params: ExecuteQueryParams): Promise<ExecuteQueryResult>;
|
|
975
|
-
track(payload: TrackPayload): void;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
1017
|
/**
|
|
979
1018
|
* Host API 实现
|
|
980
1019
|
* 提供给组件的安全 API,完全对齐 @djvlc/contracts-types 中的 HostApi 定义
|
|
@@ -1031,7 +1070,7 @@ declare class HostAPIImpl implements HostApi {
|
|
|
1031
1070
|
private loadingElement;
|
|
1032
1071
|
constructor(options: HostAPIOptions);
|
|
1033
1072
|
navigate(options: NavigateOptions): Promise<void>;
|
|
1034
|
-
track(event: TrackEvent): void;
|
|
1073
|
+
track(event: TrackEvent$1): void;
|
|
1035
1074
|
requestData<T = unknown>(queryId: string, params?: Record<string, unknown>): Promise<T>;
|
|
1036
1075
|
executeAction<T = unknown>(actionType: string, params?: Record<string, unknown>): Promise<ActionResult<T>>;
|
|
1037
1076
|
openDialog(options: DialogOptions): Promise<DialogResult>;
|
|
@@ -1102,6 +1141,14 @@ declare class DjvlcRuntime {
|
|
|
1102
1141
|
* 初始化运行时
|
|
1103
1142
|
*/
|
|
1104
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;
|
|
1105
1152
|
/**
|
|
1106
1153
|
* 加载页面
|
|
1107
1154
|
*/
|
|
@@ -1494,6 +1541,229 @@ declare class AssetLoader {
|
|
|
1494
1541
|
loadScript(url: string, integrity?: string): Promise<void>;
|
|
1495
1542
|
}
|
|
1496
1543
|
|
|
1544
|
+
/** Tenant 解析入参 */
|
|
1545
|
+
interface ResolveTenantInput {
|
|
1546
|
+
/** 请求 Host */
|
|
1547
|
+
host?: string;
|
|
1548
|
+
/** 请求路径 */
|
|
1549
|
+
path?: string;
|
|
1550
|
+
/** 额外请求头 */
|
|
1551
|
+
headers?: Record<string, string>;
|
|
1552
|
+
}
|
|
1553
|
+
/** Tenant 解析结果 */
|
|
1554
|
+
interface ResolveTenantResult {
|
|
1555
|
+
/** 租户 ID */
|
|
1556
|
+
tenantId: string;
|
|
1557
|
+
/** 租户配置 */
|
|
1558
|
+
config: unknown;
|
|
1559
|
+
}
|
|
1560
|
+
/** Tenant 端口 */
|
|
1561
|
+
interface TenantPort {
|
|
1562
|
+
resolveTenant(input: ResolveTenantInput): Promise<ResolveTenantResult>;
|
|
1563
|
+
}
|
|
1564
|
+
/** 客户端信息 */
|
|
1565
|
+
interface ClientInfo {
|
|
1566
|
+
/** User Agent */
|
|
1567
|
+
ua?: string;
|
|
1568
|
+
/** IP 地址 */
|
|
1569
|
+
ip?: string;
|
|
1570
|
+
/** 设备 ID */
|
|
1571
|
+
deviceId?: string;
|
|
1572
|
+
}
|
|
1573
|
+
/** 认证信息 */
|
|
1574
|
+
interface AuthInfo {
|
|
1575
|
+
/** Token(runtime 只关心有没有 token,怎么塞 header 由 adapter 决定) */
|
|
1576
|
+
token?: string;
|
|
1577
|
+
}
|
|
1578
|
+
/** 追踪信息 */
|
|
1579
|
+
interface TraceInfo {
|
|
1580
|
+
/** Trace ID */
|
|
1581
|
+
traceId?: string;
|
|
1582
|
+
/** Span ID */
|
|
1583
|
+
spanId?: string;
|
|
1584
|
+
}
|
|
1585
|
+
/** Page 解析入参(以 runtime 需要为准) */
|
|
1586
|
+
interface ResolvePageInput {
|
|
1587
|
+
/** 租户 ID */
|
|
1588
|
+
tenantId?: string;
|
|
1589
|
+
/** 页面 ID */
|
|
1590
|
+
pageId: string;
|
|
1591
|
+
/** 页面版本 ID(支持灰度/回滚/复现) */
|
|
1592
|
+
pageVersionId?: string;
|
|
1593
|
+
/** 语言 */
|
|
1594
|
+
locale?: string;
|
|
1595
|
+
/** 用户 ID */
|
|
1596
|
+
uid?: string;
|
|
1597
|
+
/** 客户端信息 */
|
|
1598
|
+
client?: ClientInfo;
|
|
1599
|
+
/** 认证信息 */
|
|
1600
|
+
auth?: AuthInfo;
|
|
1601
|
+
/** 追踪信息 */
|
|
1602
|
+
trace?: TraceInfo;
|
|
1603
|
+
/** 超时(毫秒) */
|
|
1604
|
+
timeoutMs?: number;
|
|
1605
|
+
/** AbortSignal */
|
|
1606
|
+
signal?: AbortSignal;
|
|
1607
|
+
}
|
|
1608
|
+
/** 缓存状态 */
|
|
1609
|
+
type CacheStatus = 'HIT' | 'MISS' | 'BYPASS';
|
|
1610
|
+
/** Page 解析结果元数据 */
|
|
1611
|
+
interface ResolvePageMeta {
|
|
1612
|
+
/** 缓存状态 */
|
|
1613
|
+
cache: CacheStatus;
|
|
1614
|
+
/** 解析时间戳 */
|
|
1615
|
+
resolvedAt: number;
|
|
1616
|
+
/** ETag */
|
|
1617
|
+
etag?: string;
|
|
1618
|
+
/** 缓存 TTL(秒) */
|
|
1619
|
+
cacheTtlSeconds?: number;
|
|
1620
|
+
}
|
|
1621
|
+
/** Page 解析结果(含 schema 与可选预取数据) */
|
|
1622
|
+
interface ResolvePageResult {
|
|
1623
|
+
/** 页面版本 ID */
|
|
1624
|
+
pageVersionId: string;
|
|
1625
|
+
/** 页面 Schema(严格类型) */
|
|
1626
|
+
page: PageSchema;
|
|
1627
|
+
/** 预取数据,可注入 runtime 的 dataStore(query 缓存) */
|
|
1628
|
+
prefetchedData?: Record<string, unknown>;
|
|
1629
|
+
/** 元数据 */
|
|
1630
|
+
meta: ResolvePageMeta;
|
|
1631
|
+
/** 完整页面解析结果,供 runtime.loadFromResolved() 使用 */
|
|
1632
|
+
pageResolveResult?: PageResolveResult;
|
|
1633
|
+
}
|
|
1634
|
+
/** Page Runtime 端口(核心) */
|
|
1635
|
+
interface PageRuntimePort {
|
|
1636
|
+
resolvePage(input: ResolvePageInput): Promise<ResolvePageResult>;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
/** Data 查询入参 */
|
|
1640
|
+
interface DataQueryInput {
|
|
1641
|
+
/** 租户 ID */
|
|
1642
|
+
tenantId?: string;
|
|
1643
|
+
/** 查询版本 ID */
|
|
1644
|
+
queryVersionId: string;
|
|
1645
|
+
/** 查询参数 */
|
|
1646
|
+
params: unknown;
|
|
1647
|
+
/** 上下文 */
|
|
1648
|
+
context: {
|
|
1649
|
+
pageId: string;
|
|
1650
|
+
pageVersionId: string;
|
|
1651
|
+
componentId?: string;
|
|
1652
|
+
uid?: string;
|
|
1653
|
+
deviceId?: string;
|
|
1654
|
+
};
|
|
1655
|
+
/** 追踪信息 */
|
|
1656
|
+
trace?: TraceInfo;
|
|
1657
|
+
/** 超时(毫秒) */
|
|
1658
|
+
timeoutMs?: number;
|
|
1659
|
+
/** AbortSignal */
|
|
1660
|
+
signal?: AbortSignal;
|
|
1661
|
+
}
|
|
1662
|
+
/** Data 查询结果 */
|
|
1663
|
+
interface DataQueryResult<T = unknown> {
|
|
1664
|
+
/** 是否成功 */
|
|
1665
|
+
ok: boolean;
|
|
1666
|
+
/** 数据 */
|
|
1667
|
+
data?: T;
|
|
1668
|
+
/** 错误信息 */
|
|
1669
|
+
error?: {
|
|
1670
|
+
code: string;
|
|
1671
|
+
message?: string;
|
|
1672
|
+
details?: unknown;
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
/** Data 端口 */
|
|
1676
|
+
interface DataPort {
|
|
1677
|
+
query<T = unknown>(input: DataQueryInput): Promise<DataQueryResult<T>>;
|
|
1678
|
+
}
|
|
1679
|
+
/** Action 执行入参 */
|
|
1680
|
+
interface ActionExecuteInput {
|
|
1681
|
+
/** 租户 ID */
|
|
1682
|
+
tenantId?: string;
|
|
1683
|
+
/** 动作类型 */
|
|
1684
|
+
actionType: 'claim' | 'signin' | 'lottery' | 'form_submit' | 'custom' | string;
|
|
1685
|
+
/** 动作参数(用 contracts schema 校验) */
|
|
1686
|
+
payload: unknown;
|
|
1687
|
+
/** 上下文 */
|
|
1688
|
+
context: {
|
|
1689
|
+
pageId: string;
|
|
1690
|
+
pageVersionId: string;
|
|
1691
|
+
componentId?: string;
|
|
1692
|
+
uid?: string;
|
|
1693
|
+
deviceId?: string;
|
|
1694
|
+
};
|
|
1695
|
+
/** 幂等键 */
|
|
1696
|
+
idempotencyKey?: string;
|
|
1697
|
+
/** 追踪信息 */
|
|
1698
|
+
trace?: TraceInfo;
|
|
1699
|
+
/** 超时(毫秒) */
|
|
1700
|
+
timeoutMs?: number;
|
|
1701
|
+
/** AbortSignal */
|
|
1702
|
+
signal?: AbortSignal;
|
|
1703
|
+
}
|
|
1704
|
+
/** Action 执行结果 */
|
|
1705
|
+
interface ActionExecuteResult<T = unknown> {
|
|
1706
|
+
/** 是否成功 */
|
|
1707
|
+
ok: boolean;
|
|
1708
|
+
/** 结果数据(同样用 contracts schema 校验) */
|
|
1709
|
+
data?: T;
|
|
1710
|
+
/** 错误信息 */
|
|
1711
|
+
error?: {
|
|
1712
|
+
code: string;
|
|
1713
|
+
message?: string;
|
|
1714
|
+
details?: unknown;
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
/** Action 端口 */
|
|
1718
|
+
interface ActionPort {
|
|
1719
|
+
executeAction<T = unknown>(input: ActionExecuteInput): Promise<ActionExecuteResult<T>>;
|
|
1720
|
+
}
|
|
1721
|
+
/** 埋点事件 */
|
|
1722
|
+
interface TrackEvent {
|
|
1723
|
+
/** 事件名称 */
|
|
1724
|
+
eventName: string;
|
|
1725
|
+
/** 事件类型 */
|
|
1726
|
+
eventType: 'page_view' | 'click' | 'exposure' | 'action' | 'custom';
|
|
1727
|
+
/** 事件属性 */
|
|
1728
|
+
properties?: Record<string, unknown>;
|
|
1729
|
+
/** 时间戳 */
|
|
1730
|
+
timestamp?: number;
|
|
1731
|
+
}
|
|
1732
|
+
/** Track 入参 */
|
|
1733
|
+
interface TrackInput {
|
|
1734
|
+
/** 租户 ID */
|
|
1735
|
+
tenantId?: string;
|
|
1736
|
+
/** 事件列表(批量上报) */
|
|
1737
|
+
events: TrackEvent[];
|
|
1738
|
+
/** 上下文 */
|
|
1739
|
+
context: {
|
|
1740
|
+
pageId: string;
|
|
1741
|
+
pageVersionId: string;
|
|
1742
|
+
uid?: string;
|
|
1743
|
+
deviceId?: string;
|
|
1744
|
+
sessionId?: string;
|
|
1745
|
+
};
|
|
1746
|
+
/** 追踪信息 */
|
|
1747
|
+
trace?: TraceInfo;
|
|
1748
|
+
}
|
|
1749
|
+
/** Track 端口 */
|
|
1750
|
+
interface TrackPort {
|
|
1751
|
+
track(input: TrackInput): Promise<void>;
|
|
1752
|
+
}
|
|
1753
|
+
/** 聚合 Ports,供 SDK 实现并注入 */
|
|
1754
|
+
interface RuntimePorts {
|
|
1755
|
+
/** 租户端口 */
|
|
1756
|
+
tenant?: TenantPort;
|
|
1757
|
+
/** 页面端口 */
|
|
1758
|
+
page: PageRuntimePort;
|
|
1759
|
+
/** 数据端口 */
|
|
1760
|
+
data: DataPort;
|
|
1761
|
+
/** 动作端口 */
|
|
1762
|
+
action: ActionPort;
|
|
1763
|
+
/** 埋点端口 */
|
|
1764
|
+
track: TrackPort;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1497
1767
|
/**
|
|
1498
1768
|
* 安全管理器
|
|
1499
1769
|
* SRI 校验、域名白名单、组件阻止、能力校验等
|
|
@@ -2185,4 +2455,4 @@ declare class LifecycleManager {
|
|
|
2185
2455
|
*/
|
|
2186
2456
|
declare const RUNTIME_VERSION = "1.0.0";
|
|
2187
2457
|
|
|
2188
|
-
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,
|
|
2458
|
+
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, registerFallbackComponents };
|