@djvlc/runtime-core 1.0.1 → 1.0.3
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 -7336
- package/dist/index.d.cts +45 -13
- package/dist/index.d.ts +45 -13
- package/dist/index.js +1 -7291
- package/package.json +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -8,8 +8,8 @@ export { ActionExecuteRequest, ActionExecuteResponse, ActionPolicy, ActionRef, A
|
|
|
8
8
|
interface RuntimeOptions {
|
|
9
9
|
/** 容器元素或选择器 */
|
|
10
10
|
container: string | HTMLElement;
|
|
11
|
-
/** 页面
|
|
12
|
-
|
|
11
|
+
/** 页面 ID(对应 contracts 中的 pageId) */
|
|
12
|
+
pageId: string;
|
|
13
13
|
/** API 基础 URL */
|
|
14
14
|
apiBaseUrl: string;
|
|
15
15
|
/** CDN 基础 URL */
|
|
@@ -68,17 +68,21 @@ interface RuntimeState {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* 页面解析结果(Runtime 使用)
|
|
71
|
+
*
|
|
72
|
+
* @description
|
|
73
|
+
* 这是 Runtime 内部使用的类型,从 PageResolveResponse 和 PageSnapshotJson 转换而来。
|
|
74
|
+
* 使用 pageId 符合 contracts 定义。
|
|
71
75
|
*/
|
|
72
76
|
interface PageResolveResult {
|
|
73
|
-
/** 页面
|
|
74
|
-
|
|
77
|
+
/** 页面 ID(对应 contracts 中的 pageId) */
|
|
78
|
+
pageId: string;
|
|
75
79
|
/** 页面版本 ID */
|
|
76
80
|
pageVersionId: string;
|
|
77
81
|
/** 页面 JSON(PageSchema) */
|
|
78
82
|
pageJson: _djvlc_contracts_types.PageSchema;
|
|
79
83
|
/** 组件清单 */
|
|
80
84
|
manifest: _djvlc_contracts_types.PageManifest;
|
|
81
|
-
/**
|
|
85
|
+
/** 运行时配置(从 OpsConfig 转换而来) */
|
|
82
86
|
runtimeConfig?: {
|
|
83
87
|
/** 被阻断的组件列表 */
|
|
84
88
|
blockedComponents?: Array<{
|
|
@@ -852,7 +856,7 @@ declare class ActionBridge {
|
|
|
852
856
|
* 运行时上下文
|
|
853
857
|
*/
|
|
854
858
|
interface RuntimeContext {
|
|
855
|
-
|
|
859
|
+
pageId: string;
|
|
856
860
|
pageVersionId: string;
|
|
857
861
|
runtimeVersion: string;
|
|
858
862
|
userId?: string;
|
|
@@ -1130,7 +1134,7 @@ declare class RenderError extends DjvlcRuntimeError {
|
|
|
1130
1134
|
|
|
1131
1135
|
/**
|
|
1132
1136
|
* 页面加载器
|
|
1133
|
-
* 负责从 API
|
|
1137
|
+
* 负责从 API 解析页面配置,严格按照 @djvlc/contracts-types 定义
|
|
1134
1138
|
*/
|
|
1135
1139
|
|
|
1136
1140
|
/**
|
|
@@ -1139,8 +1143,10 @@ declare class RenderError extends DjvlcRuntimeError {
|
|
|
1139
1143
|
interface PageLoaderOptions {
|
|
1140
1144
|
/** API 基础 URL */
|
|
1141
1145
|
apiBaseUrl: string;
|
|
1146
|
+
/** 环境 */
|
|
1147
|
+
env?: 'preview' | 'staging' | 'prod';
|
|
1142
1148
|
/** 渠道 */
|
|
1143
|
-
channel?:
|
|
1149
|
+
channel?: string;
|
|
1144
1150
|
/** 认证 Token */
|
|
1145
1151
|
authToken?: string;
|
|
1146
1152
|
/** 预览 Token */
|
|
@@ -1158,6 +1164,7 @@ interface PageLoaderOptions {
|
|
|
1158
1164
|
/**
|
|
1159
1165
|
* 页面加载器
|
|
1160
1166
|
* 负责调用 /page/resolve 接口获取页面数据
|
|
1167
|
+
* 严格按照 contracts 中的 PageResolveResponse 定义
|
|
1161
1168
|
*/
|
|
1162
1169
|
declare class PageLoader {
|
|
1163
1170
|
private options;
|
|
@@ -1165,13 +1172,40 @@ declare class PageLoader {
|
|
|
1165
1172
|
constructor(options: PageLoaderOptions);
|
|
1166
1173
|
/**
|
|
1167
1174
|
* 解析页面
|
|
1168
|
-
* @param
|
|
1175
|
+
* @param pageId 页面 ID(对应 contracts 中的 pageId)
|
|
1169
1176
|
* @param params 额外参数
|
|
1170
1177
|
*/
|
|
1171
|
-
resolve(
|
|
1178
|
+
resolve(pageId: string, params?: {
|
|
1172
1179
|
uid?: string;
|
|
1173
1180
|
deviceId?: string;
|
|
1174
1181
|
}): Promise<PageResolveResult>;
|
|
1182
|
+
/**
|
|
1183
|
+
* 调用 Resolve API
|
|
1184
|
+
* 严格按照 contracts 中的 PageResolveRequest 和 PageResolveResponse
|
|
1185
|
+
*/
|
|
1186
|
+
private callResolveApi;
|
|
1187
|
+
/**
|
|
1188
|
+
* 从 CDN 加载 snapshot 和 manifest
|
|
1189
|
+
*/
|
|
1190
|
+
private loadFromCdn;
|
|
1191
|
+
/**
|
|
1192
|
+
* 转换 PageSnapshotJson 为 PageResolveResult
|
|
1193
|
+
*/
|
|
1194
|
+
private convertSnapshotToResult;
|
|
1195
|
+
/**
|
|
1196
|
+
* 转换 PageSnapshotPage 为 PageSchema
|
|
1197
|
+
* 严格按照 contracts 定义进行转换
|
|
1198
|
+
*/
|
|
1199
|
+
private convertSnapshotPageToPageSchema;
|
|
1200
|
+
/**
|
|
1201
|
+
* 转换 PageSnapshotManifest 为 PageManifest
|
|
1202
|
+
* 注意:PageSnapshotManifest 是简化版本,缺少一些字段,需要从其他地方获取或使用默认值
|
|
1203
|
+
*/
|
|
1204
|
+
private convertSnapshotManifestToPageManifest;
|
|
1205
|
+
/**
|
|
1206
|
+
* 验证 PageResolveResponse(严格按照 contracts 定义)
|
|
1207
|
+
*/
|
|
1208
|
+
private isValidPageResolveResponse;
|
|
1175
1209
|
/**
|
|
1176
1210
|
* 预连接 API 服务器
|
|
1177
1211
|
*/
|
|
@@ -1179,12 +1213,10 @@ declare class PageLoader {
|
|
|
1179
1213
|
/**
|
|
1180
1214
|
* 清除缓存
|
|
1181
1215
|
*/
|
|
1182
|
-
clearCache(
|
|
1183
|
-
private buildResolveUrl;
|
|
1216
|
+
clearCache(pageId?: string): void;
|
|
1184
1217
|
private buildHeaders;
|
|
1185
1218
|
private getCacheKey;
|
|
1186
1219
|
private isCacheValid;
|
|
1187
|
-
private isValidPageResolveResult;
|
|
1188
1220
|
private log;
|
|
1189
1221
|
}
|
|
1190
1222
|
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export { ActionExecuteRequest, ActionExecuteResponse, ActionPolicy, ActionRef, A
|
|
|
8
8
|
interface RuntimeOptions {
|
|
9
9
|
/** 容器元素或选择器 */
|
|
10
10
|
container: string | HTMLElement;
|
|
11
|
-
/** 页面
|
|
12
|
-
|
|
11
|
+
/** 页面 ID(对应 contracts 中的 pageId) */
|
|
12
|
+
pageId: string;
|
|
13
13
|
/** API 基础 URL */
|
|
14
14
|
apiBaseUrl: string;
|
|
15
15
|
/** CDN 基础 URL */
|
|
@@ -68,17 +68,21 @@ interface RuntimeState {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* 页面解析结果(Runtime 使用)
|
|
71
|
+
*
|
|
72
|
+
* @description
|
|
73
|
+
* 这是 Runtime 内部使用的类型,从 PageResolveResponse 和 PageSnapshotJson 转换而来。
|
|
74
|
+
* 使用 pageId 符合 contracts 定义。
|
|
71
75
|
*/
|
|
72
76
|
interface PageResolveResult {
|
|
73
|
-
/** 页面
|
|
74
|
-
|
|
77
|
+
/** 页面 ID(对应 contracts 中的 pageId) */
|
|
78
|
+
pageId: string;
|
|
75
79
|
/** 页面版本 ID */
|
|
76
80
|
pageVersionId: string;
|
|
77
81
|
/** 页面 JSON(PageSchema) */
|
|
78
82
|
pageJson: _djvlc_contracts_types.PageSchema;
|
|
79
83
|
/** 组件清单 */
|
|
80
84
|
manifest: _djvlc_contracts_types.PageManifest;
|
|
81
|
-
/**
|
|
85
|
+
/** 运行时配置(从 OpsConfig 转换而来) */
|
|
82
86
|
runtimeConfig?: {
|
|
83
87
|
/** 被阻断的组件列表 */
|
|
84
88
|
blockedComponents?: Array<{
|
|
@@ -852,7 +856,7 @@ declare class ActionBridge {
|
|
|
852
856
|
* 运行时上下文
|
|
853
857
|
*/
|
|
854
858
|
interface RuntimeContext {
|
|
855
|
-
|
|
859
|
+
pageId: string;
|
|
856
860
|
pageVersionId: string;
|
|
857
861
|
runtimeVersion: string;
|
|
858
862
|
userId?: string;
|
|
@@ -1130,7 +1134,7 @@ declare class RenderError extends DjvlcRuntimeError {
|
|
|
1130
1134
|
|
|
1131
1135
|
/**
|
|
1132
1136
|
* 页面加载器
|
|
1133
|
-
* 负责从 API
|
|
1137
|
+
* 负责从 API 解析页面配置,严格按照 @djvlc/contracts-types 定义
|
|
1134
1138
|
*/
|
|
1135
1139
|
|
|
1136
1140
|
/**
|
|
@@ -1139,8 +1143,10 @@ declare class RenderError extends DjvlcRuntimeError {
|
|
|
1139
1143
|
interface PageLoaderOptions {
|
|
1140
1144
|
/** API 基础 URL */
|
|
1141
1145
|
apiBaseUrl: string;
|
|
1146
|
+
/** 环境 */
|
|
1147
|
+
env?: 'preview' | 'staging' | 'prod';
|
|
1142
1148
|
/** 渠道 */
|
|
1143
|
-
channel?:
|
|
1149
|
+
channel?: string;
|
|
1144
1150
|
/** 认证 Token */
|
|
1145
1151
|
authToken?: string;
|
|
1146
1152
|
/** 预览 Token */
|
|
@@ -1158,6 +1164,7 @@ interface PageLoaderOptions {
|
|
|
1158
1164
|
/**
|
|
1159
1165
|
* 页面加载器
|
|
1160
1166
|
* 负责调用 /page/resolve 接口获取页面数据
|
|
1167
|
+
* 严格按照 contracts 中的 PageResolveResponse 定义
|
|
1161
1168
|
*/
|
|
1162
1169
|
declare class PageLoader {
|
|
1163
1170
|
private options;
|
|
@@ -1165,13 +1172,40 @@ declare class PageLoader {
|
|
|
1165
1172
|
constructor(options: PageLoaderOptions);
|
|
1166
1173
|
/**
|
|
1167
1174
|
* 解析页面
|
|
1168
|
-
* @param
|
|
1175
|
+
* @param pageId 页面 ID(对应 contracts 中的 pageId)
|
|
1169
1176
|
* @param params 额外参数
|
|
1170
1177
|
*/
|
|
1171
|
-
resolve(
|
|
1178
|
+
resolve(pageId: string, params?: {
|
|
1172
1179
|
uid?: string;
|
|
1173
1180
|
deviceId?: string;
|
|
1174
1181
|
}): Promise<PageResolveResult>;
|
|
1182
|
+
/**
|
|
1183
|
+
* 调用 Resolve API
|
|
1184
|
+
* 严格按照 contracts 中的 PageResolveRequest 和 PageResolveResponse
|
|
1185
|
+
*/
|
|
1186
|
+
private callResolveApi;
|
|
1187
|
+
/**
|
|
1188
|
+
* 从 CDN 加载 snapshot 和 manifest
|
|
1189
|
+
*/
|
|
1190
|
+
private loadFromCdn;
|
|
1191
|
+
/**
|
|
1192
|
+
* 转换 PageSnapshotJson 为 PageResolveResult
|
|
1193
|
+
*/
|
|
1194
|
+
private convertSnapshotToResult;
|
|
1195
|
+
/**
|
|
1196
|
+
* 转换 PageSnapshotPage 为 PageSchema
|
|
1197
|
+
* 严格按照 contracts 定义进行转换
|
|
1198
|
+
*/
|
|
1199
|
+
private convertSnapshotPageToPageSchema;
|
|
1200
|
+
/**
|
|
1201
|
+
* 转换 PageSnapshotManifest 为 PageManifest
|
|
1202
|
+
* 注意:PageSnapshotManifest 是简化版本,缺少一些字段,需要从其他地方获取或使用默认值
|
|
1203
|
+
*/
|
|
1204
|
+
private convertSnapshotManifestToPageManifest;
|
|
1205
|
+
/**
|
|
1206
|
+
* 验证 PageResolveResponse(严格按照 contracts 定义)
|
|
1207
|
+
*/
|
|
1208
|
+
private isValidPageResolveResponse;
|
|
1175
1209
|
/**
|
|
1176
1210
|
* 预连接 API 服务器
|
|
1177
1211
|
*/
|
|
@@ -1179,12 +1213,10 @@ declare class PageLoader {
|
|
|
1179
1213
|
/**
|
|
1180
1214
|
* 清除缓存
|
|
1181
1215
|
*/
|
|
1182
|
-
clearCache(
|
|
1183
|
-
private buildResolveUrl;
|
|
1216
|
+
clearCache(pageId?: string): void;
|
|
1184
1217
|
private buildHeaders;
|
|
1185
1218
|
private getCacheKey;
|
|
1186
1219
|
private isCacheValid;
|
|
1187
|
-
private isValidPageResolveResult;
|
|
1188
1220
|
private log;
|
|
1189
1221
|
}
|
|
1190
1222
|
|