@djvlc/runtime-core 1.1.2 → 1.2.1

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.d.cts CHANGED
@@ -1201,6 +1201,12 @@ declare class DjvlcRuntime {
1201
1201
  * 验证 Schema 版本
1202
1202
  */
1203
1203
  private validateSchemaVersion;
1204
+ /**
1205
+ * 安全解析 URL 的 host 部分
1206
+ * 支持绝对 URL(http://localhost:3000)和相对路径(/api)
1207
+ * 相对路径时使用 window.location.origin 作为 base
1208
+ */
1209
+ private safeParseHost;
1204
1210
  private resolveContainer;
1205
1211
  private initHostApi;
1206
1212
  private initActionBridge;
@@ -1362,7 +1368,8 @@ declare class PageLoader {
1362
1368
  */
1363
1369
  private callResolveViaAdapter;
1364
1370
  /**
1365
- * 从 CDN 加载 snapshot 和 manifest
1371
+ * 从 CDN 加载 snapshot
1372
+ * 仅支持标准 PageSnapshotJson 格式:{ page, manifest, definitionsDigest, ops, meta }
1366
1373
  */
1367
1374
  private loadFromCdn;
1368
1375
  /**
@@ -1376,7 +1383,11 @@ declare class PageLoader {
1376
1383
  private convertSnapshotPageToPageSchema;
1377
1384
  /**
1378
1385
  * 转换 PageSnapshotManifest 为 PageManifest
1379
- * 注意:PageSnapshotManifest 是简化版本,缺少一些字段,需要从其他地方获取或使用默认值
1386
+ *
1387
+ * 注意:PageSnapshotManifest 是简化版本,缺少一些字段,需要从其他地方获取或使用默认值。
1388
+ * 根据 `comp.source` 区分 bundled/remote:
1389
+ * - bundled:entry/styleEntry 留空(内置组件无需 CDN 入口)
1390
+ * - remote:从 assetsUrl + entrypoints 拼接 entry/styleEntry
1380
1391
  */
1381
1392
  private convertSnapshotManifestToPageManifest;
1382
1393
  /**
@@ -1436,6 +1447,10 @@ declare class ComponentLoader {
1436
1447
  constructor(options: ComponentLoaderOptions);
1437
1448
  /**
1438
1449
  * 加载单个组件(按 name@version 去重,同一组件并发请求复用同一 Promise)
1450
+ *
1451
+ * 对于 `source: 'bundled'` 的内置组件,直接返回已注册的 Custom Element,跳过 CDN 加载。
1452
+ * 对于 `source: 'remote'` 的远程组件,通过 CDN 拉取脚本并执行。
1453
+ *
1439
1454
  * @param item - 清单项(name、version、entry、integrity 等)
1440
1455
  * @returns 已加载的组件信息(含 Component 构造函数)
1441
1456
  * @throws ComponentBlockedError 当组件在阻断列表中
@@ -1451,6 +1466,7 @@ declare class ComponentLoader {
1451
1466
  loadAll(manifest: PageManifest): Promise<Map<string, ComponentLoadResult>>;
1452
1467
  /**
1453
1468
  * 预加载组件:向 document.head 插入 &lt;link rel="preload" as="script"&gt;,仅作提示,不阻塞 load。
1469
+ * 内置组件(source: 'bundled')和无 entry 的组件会被跳过。
1454
1470
  * @param items - 需要预加载的清单项
1455
1471
  */
1456
1472
  preload(items: ManifestItem[]): void;
@@ -2064,6 +2080,30 @@ declare class BaseRenderer implements Renderer {
2064
2080
  * 将布局值转换为 CSS
2065
2081
  */
2066
2082
  private layoutToCSS;
2083
+ /**
2084
+ * 应用 SEO 配置
2085
+ *
2086
+ * 按照 PageSEO 定义设置 document.title / <meta> / Open Graph / JSON-LD:
2087
+ * - title → document.title + <meta property="og:title">
2088
+ * - description → <meta name="description"> + <meta property="og:description">
2089
+ * - keywords → <meta name="keywords">
2090
+ * - canonicalUrl → <link rel="canonical">
2091
+ * - ogImage → <meta property="og:image">
2092
+ * - ogType → <meta property="og:type">
2093
+ * - indexable → <meta name="robots">
2094
+ * - structuredData → <script type="application/ld+json">
2095
+ *
2096
+ * 优先级:seo.title > meta.title(seo 是面向搜索引擎的,meta 是面向编辑器的)
2097
+ */
2098
+ private applySEO;
2099
+ /** 设置或更新 <meta name="..."> 标签 */
2100
+ private _setMeta;
2101
+ /** 设置或更新 <meta property="..."> 标签(Open Graph) */
2102
+ private _setMetaProperty;
2103
+ /** 设置或更新 <link rel="..."> 标签 */
2104
+ private _setLink;
2105
+ /** 注入 JSON-LD 结构化数据 */
2106
+ private _injectJsonLd;
2067
2107
  /**
2068
2108
  * 应用页面配置(PageConfig 结构)
2069
2109
  *
@@ -2164,6 +2204,26 @@ declare function registerFallbackComponents(): void;
2164
2204
  */
2165
2205
  declare function createFallbackElement(type: 'fallback' | 'blocked' | 'error', message?: string, componentName?: string): HTMLElement;
2166
2206
 
2207
+ /**
2208
+ * 内置组件注册器
2209
+ *
2210
+ * 在 Runtime.init() 阶段调用 registerBuiltinComponents(),
2211
+ * 将所有内置组件注册为 Custom Elements,供 BaseRenderer.createElement() 使用。
2212
+ *
2213
+ * 幂等:重复调用不会报错(通过 customElements.get 检查是否已注册)。
2214
+ */
2215
+ /**
2216
+ * 注册所有内置组件为 Custom Elements
2217
+ *
2218
+ * @description
2219
+ * - 幂等:已注册的组件跳过
2220
+ * - 顺序无关:每个组件独立注册
2221
+ * - 日志:在 debug 模式下输出注册信息
2222
+ *
2223
+ * @param debug - 是否打印调试日志,默认 false
2224
+ */
2225
+ declare function registerBuiltinComponents(debug?: boolean): void;
2226
+
2167
2227
  /**
2168
2228
  * 遥测管理器
2169
2229
  * 链路追踪、性能监控、错误上报
@@ -2455,4 +2515,4 @@ declare class LifecycleManager {
2455
2515
  */
2456
2516
  declare const RUNTIME_VERSION = "1.0.0";
2457
2517
 
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 };
2518
+ 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 };
package/dist/index.d.ts CHANGED
@@ -1201,6 +1201,12 @@ declare class DjvlcRuntime {
1201
1201
  * 验证 Schema 版本
1202
1202
  */
1203
1203
  private validateSchemaVersion;
1204
+ /**
1205
+ * 安全解析 URL 的 host 部分
1206
+ * 支持绝对 URL(http://localhost:3000)和相对路径(/api)
1207
+ * 相对路径时使用 window.location.origin 作为 base
1208
+ */
1209
+ private safeParseHost;
1204
1210
  private resolveContainer;
1205
1211
  private initHostApi;
1206
1212
  private initActionBridge;
@@ -1362,7 +1368,8 @@ declare class PageLoader {
1362
1368
  */
1363
1369
  private callResolveViaAdapter;
1364
1370
  /**
1365
- * 从 CDN 加载 snapshot 和 manifest
1371
+ * 从 CDN 加载 snapshot
1372
+ * 仅支持标准 PageSnapshotJson 格式:{ page, manifest, definitionsDigest, ops, meta }
1366
1373
  */
1367
1374
  private loadFromCdn;
1368
1375
  /**
@@ -1376,7 +1383,11 @@ declare class PageLoader {
1376
1383
  private convertSnapshotPageToPageSchema;
1377
1384
  /**
1378
1385
  * 转换 PageSnapshotManifest 为 PageManifest
1379
- * 注意:PageSnapshotManifest 是简化版本,缺少一些字段,需要从其他地方获取或使用默认值
1386
+ *
1387
+ * 注意:PageSnapshotManifest 是简化版本,缺少一些字段,需要从其他地方获取或使用默认值。
1388
+ * 根据 `comp.source` 区分 bundled/remote:
1389
+ * - bundled:entry/styleEntry 留空(内置组件无需 CDN 入口)
1390
+ * - remote:从 assetsUrl + entrypoints 拼接 entry/styleEntry
1380
1391
  */
1381
1392
  private convertSnapshotManifestToPageManifest;
1382
1393
  /**
@@ -1436,6 +1447,10 @@ declare class ComponentLoader {
1436
1447
  constructor(options: ComponentLoaderOptions);
1437
1448
  /**
1438
1449
  * 加载单个组件(按 name@version 去重,同一组件并发请求复用同一 Promise)
1450
+ *
1451
+ * 对于 `source: 'bundled'` 的内置组件,直接返回已注册的 Custom Element,跳过 CDN 加载。
1452
+ * 对于 `source: 'remote'` 的远程组件,通过 CDN 拉取脚本并执行。
1453
+ *
1439
1454
  * @param item - 清单项(name、version、entry、integrity 等)
1440
1455
  * @returns 已加载的组件信息(含 Component 构造函数)
1441
1456
  * @throws ComponentBlockedError 当组件在阻断列表中
@@ -1451,6 +1466,7 @@ declare class ComponentLoader {
1451
1466
  loadAll(manifest: PageManifest): Promise<Map<string, ComponentLoadResult>>;
1452
1467
  /**
1453
1468
  * 预加载组件:向 document.head 插入 &lt;link rel="preload" as="script"&gt;,仅作提示,不阻塞 load。
1469
+ * 内置组件(source: 'bundled')和无 entry 的组件会被跳过。
1454
1470
  * @param items - 需要预加载的清单项
1455
1471
  */
1456
1472
  preload(items: ManifestItem[]): void;
@@ -2064,6 +2080,30 @@ declare class BaseRenderer implements Renderer {
2064
2080
  * 将布局值转换为 CSS
2065
2081
  */
2066
2082
  private layoutToCSS;
2083
+ /**
2084
+ * 应用 SEO 配置
2085
+ *
2086
+ * 按照 PageSEO 定义设置 document.title / <meta> / Open Graph / JSON-LD:
2087
+ * - title → document.title + <meta property="og:title">
2088
+ * - description → <meta name="description"> + <meta property="og:description">
2089
+ * - keywords → <meta name="keywords">
2090
+ * - canonicalUrl → <link rel="canonical">
2091
+ * - ogImage → <meta property="og:image">
2092
+ * - ogType → <meta property="og:type">
2093
+ * - indexable → <meta name="robots">
2094
+ * - structuredData → <script type="application/ld+json">
2095
+ *
2096
+ * 优先级:seo.title > meta.title(seo 是面向搜索引擎的,meta 是面向编辑器的)
2097
+ */
2098
+ private applySEO;
2099
+ /** 设置或更新 <meta name="..."> 标签 */
2100
+ private _setMeta;
2101
+ /** 设置或更新 <meta property="..."> 标签(Open Graph) */
2102
+ private _setMetaProperty;
2103
+ /** 设置或更新 <link rel="..."> 标签 */
2104
+ private _setLink;
2105
+ /** 注入 JSON-LD 结构化数据 */
2106
+ private _injectJsonLd;
2067
2107
  /**
2068
2108
  * 应用页面配置(PageConfig 结构)
2069
2109
  *
@@ -2164,6 +2204,26 @@ declare function registerFallbackComponents(): void;
2164
2204
  */
2165
2205
  declare function createFallbackElement(type: 'fallback' | 'blocked' | 'error', message?: string, componentName?: string): HTMLElement;
2166
2206
 
2207
+ /**
2208
+ * 内置组件注册器
2209
+ *
2210
+ * 在 Runtime.init() 阶段调用 registerBuiltinComponents(),
2211
+ * 将所有内置组件注册为 Custom Elements,供 BaseRenderer.createElement() 使用。
2212
+ *
2213
+ * 幂等:重复调用不会报错(通过 customElements.get 检查是否已注册)。
2214
+ */
2215
+ /**
2216
+ * 注册所有内置组件为 Custom Elements
2217
+ *
2218
+ * @description
2219
+ * - 幂等:已注册的组件跳过
2220
+ * - 顺序无关:每个组件独立注册
2221
+ * - 日志:在 debug 模式下输出注册信息
2222
+ *
2223
+ * @param debug - 是否打印调试日志,默认 false
2224
+ */
2225
+ declare function registerBuiltinComponents(debug?: boolean): void;
2226
+
2167
2227
  /**
2168
2228
  * 遥测管理器
2169
2229
  * 链路追踪、性能监控、错误上报
@@ -2455,4 +2515,4 @@ declare class LifecycleManager {
2455
2515
  */
2456
2516
  declare const RUNTIME_VERSION = "1.0.0";
2457
2517
 
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 };
2518
+ 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 };