@djvlc/runtime-core 1.1.1 → 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 +350 -62
- package/dist/index.d.ts +350 -62
- 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
|
*/
|
|
@@ -1476,6 +1541,229 @@ declare class AssetLoader {
|
|
|
1476
1541
|
loadScript(url: string, integrity?: string): Promise<void>;
|
|
1477
1542
|
}
|
|
1478
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
|
+
|
|
1479
1767
|
/**
|
|
1480
1768
|
* 安全管理器
|
|
1481
1769
|
* SRI 校验、域名白名单、组件阻止、能力校验等
|
|
@@ -2167,4 +2455,4 @@ declare class LifecycleManager {
|
|
|
2167
2455
|
*/
|
|
2168
2456
|
declare const RUNTIME_VERSION = "1.0.0";
|
|
2169
2457
|
|
|
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 };
|
|
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 };
|