@quicktvui/qtx 0.9.0-alpha.2 → 0.9.0-alpha.4

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/qtx.es.js CHANGED
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
8
- import { defineComponent, ref, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot, shallowRef, watch, computed, useSlots, useAttrs, onMounted, nextTick, resolveComponent, createElementBlock, Fragment, createVNode, createElementVNode, normalizeStyle, renderList, h } from "vue";
8
+ import { defineComponent, ref, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot, shallowRef, watch, computed, useSlots, useAttrs, onMounted, nextTick, resolveComponent, createElementBlock, Fragment, createVNode, createElementVNode, normalizeStyle, renderList, onUnmounted, h } from "vue";
9
9
  import { Native, EventBus } from "@extscreen/es3-vue";
10
10
  import { useESEventBus } from "@extscreen/es3-core";
11
11
  const __default__$t = {
@@ -1276,12 +1276,12 @@ function styleRegistry() {
1276
1276
  return [];
1277
1277
  }
1278
1278
  function resolveClassStyles(classes) {
1279
- const registry = styleRegistry();
1279
+ const registry2 = styleRegistry();
1280
1280
  const classList = String(classes || "").split(/\s+/).filter(Boolean);
1281
- if (!classList.length || !registry.length)
1281
+ if (!classList.length || !registry2.length)
1282
1282
  return [];
1283
1283
  const out = [];
1284
- for (const rule of registry) {
1284
+ for (const rule of registry2) {
1285
1285
  const selectors = rule.selectors || [];
1286
1286
  for (const rawSel of selectors) {
1287
1287
  const m = /^\.([A-Za-z0-9_-]+)/.exec(String(rawSel).trim());
@@ -5906,6 +5906,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
5906
5906
  paddingBottom: {},
5907
5907
  reverseLayout: { type: Boolean },
5908
5908
  iconPosition: {},
5909
+ itemPadding: {},
5910
+ iconMargin: {},
5911
+ focusedKey: {},
5909
5912
  gravity: {},
5910
5913
  align: {},
5911
5914
  crossAlign: {},
@@ -6052,6 +6055,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6052
6055
  paddingBottom: __props.paddingBottom,
6053
6056
  reverseLayout: __props.reverseLayout,
6054
6057
  iconPosition: __props.iconPosition || "",
6058
+ itemPadding: __props.itemPadding,
6059
+ iconMargin: __props.iconMargin,
6060
+ focusedKey: __props.focusedKey || "",
6055
6061
  gravity: __props.gravity || "",
6056
6062
  align: __props.align || "",
6057
6063
  crossAlign: __props.crossAlign || "",
@@ -6090,7 +6096,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6090
6096
  renderSlot(_ctx.$slots, "default")
6091
6097
  ]),
6092
6098
  _: 3
6093
- }, 16, ["items", "active", "orientation", "itemWidth", "itemHeight", "gap", "paddingLeft", "paddingTop", "paddingRight", "paddingBottom", "reverseLayout", "iconPosition", "gravity", "align", "crossAlign", "fontSize", "borderRadius", "iconSize", "focusBorderWidth", "normalBg", "normalText", "focusBg", "focusText", "focusBorderColor", "selectedBg", "selectedText", "disabledBg", "disabledText", "indicator", "indicatorColor", "indicatorSize", "badgeBg", "badgeText", "scrollMode", "smoothScroll", "focusable", "selectOnFocus", "focusMemory", "defaultFocusKey", "maxPoolSize"]);
6099
+ }, 16, ["items", "active", "orientation", "itemWidth", "itemHeight", "gap", "paddingLeft", "paddingTop", "paddingRight", "paddingBottom", "reverseLayout", "iconPosition", "itemPadding", "iconMargin", "focusedKey", "gravity", "align", "crossAlign", "fontSize", "borderRadius", "iconSize", "focusBorderWidth", "normalBg", "normalText", "focusBg", "focusText", "focusBorderColor", "selectedBg", "selectedText", "disabledBg", "disabledText", "indicator", "indicatorColor", "indicatorSize", "badgeBg", "badgeText", "scrollMode", "smoothScroll", "focusable", "selectOnFocus", "focusMemory", "defaultFocusKey", "maxPoolSize"]);
6094
6100
  };
6095
6101
  }
6096
6102
  });
@@ -6107,6 +6113,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6107
6113
  itemWidth: {},
6108
6114
  itemHeight: {},
6109
6115
  gap: {},
6116
+ itemPadding: {},
6117
+ iconMargin: {},
6118
+ focusedKey: {},
6110
6119
  paddingLeft: {},
6111
6120
  paddingTop: {},
6112
6121
  paddingRight: {},
@@ -6246,6 +6255,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6246
6255
  poolSize: 16,
6247
6256
  itemWidth: 160,
6248
6257
  itemHeight: 72,
6258
+ itemPadding: 16,
6259
+ iconMargin: 12,
6249
6260
  align: "start",
6250
6261
  crossAlign: "start",
6251
6262
  alignLeading: 0,
@@ -6333,41 +6344,42 @@ const QtxChannelNavPlugin = {
6333
6344
  app.component("qtx-channel-nav", _sfc_main);
6334
6345
  }
6335
6346
  };
6336
- const QTX_PLUGIN_PKG = "com.quicktvui.plugin.qtx";
6337
- const QTX_PLUGIN_INIT_CLASS = "com.quicktvui.plugin.qtx.QtxPluginApp";
6338
6347
  const QTX_MIN_PROTOCOL_VERSION = "1.28.0";
6339
6348
  class QtxInstallError extends Error {
6340
- constructor(code, message, detail) {
6349
+ constructor(code, message, detail, capability = "core") {
6341
6350
  super(`[qtx] ${message}`);
6342
6351
  __publicField(this, "code");
6352
+ __publicField(this, "capability");
6343
6353
  __publicField(this, "detail");
6344
6354
  this.name = "QtxInstallError";
6345
6355
  this.code = code;
6356
+ this.capability = capability;
6346
6357
  this.detail = detail;
6347
6358
  }
6348
6359
  }
6360
+ const RESERVED_NAMESPACE_ROOTS = ["version", "env", "config", "list", "core"];
6349
6361
  function versionToNumber(v) {
6350
6362
  const parts = (v || "").split(/[.\-+]/).slice(0, 3).map((p) => parseInt(p, 10) || 0);
6351
6363
  while (parts.length < 3)
6352
6364
  parts.push(0);
6353
6365
  return parts[0] * 1e6 + parts[1] * 1e3 + parts[2];
6354
6366
  }
6355
- function isVersionAtLeast(actual, required) {
6367
+ function isVersionAtLeast$1(actual, required) {
6356
6368
  return versionToNumber(actual) >= versionToNumber(required);
6357
6369
  }
6358
- async function probeVersionInfo(timeoutMs = 3e3) {
6370
+ async function probeVersionInfo(versionModule, timeoutMs = 3e3) {
6359
6371
  try {
6360
6372
  const result = await Promise.race([
6361
- Native.callNativeWithPromise("QtxVersionModule", "getVersionInfo"),
6373
+ Native.callNativeWithPromise(versionModule, "getVersionInfo"),
6362
6374
  new Promise(
6363
6375
  (_, reject) => setTimeout(() => reject(new Error("probe timeout")), timeoutMs)
6364
6376
  )
6365
6377
  ]);
6366
- if (result && typeof result === "object" && result.protocolVersion) {
6378
+ if (result && typeof result === "object" && (result.pluginVersion || result.protocolVersion)) {
6367
6379
  return {
6368
- pluginVersion: String(result.pluginVersion || ""),
6369
- protocolVersion: String(result.protocolVersion || ""),
6370
- components: result.components || {},
6380
+ pluginVersion: String(result.pluginVersion || result.protocolVersion || ""),
6381
+ protocolVersion: result.protocolVersion ? String(result.protocolVersion) : void 0,
6382
+ components: result.components || void 0,
6371
6383
  mode: result.mode === "plugin" ? "plugin" : "embedded"
6372
6384
  };
6373
6385
  }
@@ -6377,7 +6389,7 @@ async function probeVersionInfo(timeoutMs = 3e3) {
6377
6389
  }
6378
6390
  }
6379
6391
  const QTX_PLUGIN_STATE_EVENT = "onESPluginStateChanged";
6380
- function installPluginViaManager(timeoutMs) {
6392
+ function installPluginViaManager(spec, timeoutMs) {
6381
6393
  return new Promise((resolve, reject) => {
6382
6394
  const bus = EventBus;
6383
6395
  const native = Native;
@@ -6399,12 +6411,14 @@ function installPluginViaManager(timeoutMs) {
6399
6411
  fn();
6400
6412
  }
6401
6413
  function onStateChanged(state) {
6402
- if (!state || state.pkg !== QTX_PLUGIN_PKG)
6414
+ if (!state || state.pkg !== spec.pkg)
6403
6415
  return;
6404
6416
  if (state.success === false) {
6405
6417
  settle(() => reject(new QtxInstallError(
6406
6418
  "INSTALL_FAILED",
6407
- `插件安装失败 status=${state.status} msg=${state.msg ?? ""}`
6419
+ spec.ns === "core" ? `插件安装失败 status=${state.status} msg=${state.msg ?? ""}` : `能力 ${spec.ns} 插件安装失败(pkg=${spec.pkg})status=${state.status} msg=${state.msg ?? ""}`,
6420
+ void 0,
6421
+ spec.ns
6408
6422
  )));
6409
6423
  return;
6410
6424
  }
@@ -6415,32 +6429,44 @@ function installPluginViaManager(timeoutMs) {
6415
6429
  try {
6416
6430
  bus.$on(QTX_PLUGIN_STATE_EVENT, onStateChanged);
6417
6431
  } catch (e) {
6418
- reject(new QtxInstallError("INSTALL_FAILED", "无法订阅宿主插件状态事件(EventBus 不可用)"));
6432
+ reject(new QtxInstallError(
6433
+ "INSTALL_FAILED",
6434
+ spec.ns === "core" ? "无法订阅宿主插件状态事件(EventBus 不可用)" : `能力 ${spec.ns} 无法订阅宿主插件状态事件(EventBus 不可用)`,
6435
+ void 0,
6436
+ spec.ns
6437
+ ));
6419
6438
  return;
6420
6439
  }
6421
6440
  timer = setTimeout(() => {
6422
- probeVersionInfo().then((late) => {
6441
+ probeVersionInfo(spec.versionModule).then((late) => {
6423
6442
  if (late && late.mode === "plugin")
6424
6443
  settle(() => resolve());
6425
6444
  else
6426
- settle(() => reject(new QtxInstallError("TIMEOUT", `插件安装超时(${timeoutMs}ms)`)));
6445
+ settle(() => reject(new QtxInstallError(
6446
+ "TIMEOUT",
6447
+ spec.ns === "core" ? `插件安装超时(${timeoutMs}ms)` : `能力 ${spec.ns} 插件安装超时(${timeoutMs}ms,pkg=${spec.pkg})`,
6448
+ void 0,
6449
+ spec.ns
6450
+ )));
6427
6451
  });
6428
6452
  }, timeoutMs);
6429
6453
  try {
6430
- native.callNative("ESPluginModule", "install", [{ pkg: QTX_PLUGIN_PKG }]);
6454
+ native.callNative("ESPluginModule", "install", [{ pkg: spec.pkg }]);
6431
6455
  } catch (e) {
6432
6456
  settle(() => reject(new QtxInstallError(
6433
6457
  "INSTALL_FAILED",
6434
- `插件安装指令下发失败:${e instanceof Error ? e.message : String(e)}`
6458
+ `插件安装指令下发失败:${e instanceof Error ? e.message : String(e)}`,
6459
+ void 0,
6460
+ spec.ns
6435
6461
  )));
6436
6462
  }
6437
6463
  });
6438
6464
  }
6439
- async function triggerPluginInit() {
6465
+ async function triggerPluginInit(spec) {
6440
6466
  try {
6441
6467
  await Promise.race([
6442
6468
  Native.callNativeWithPromise("EsNativeModule", "callReflect", {
6443
- entry: { from: QTX_PLUGIN_INIT_CLASS, method: "setup" }
6469
+ entry: { from: `${spec.pkg}.QtxPluginApp`, method: "setup" }
6444
6470
  }),
6445
6471
  new Promise((resolve) => setTimeout(resolve, 3e3))
6446
6472
  ]);
@@ -6448,85 +6474,279 @@ async function triggerPluginInit() {
6448
6474
  console.warn("[qtx] callReflect init skipped:", e);
6449
6475
  }
6450
6476
  }
6451
- let readyPromise = null;
6452
- let resolvedInfo = null;
6453
- async function runBootstrap(options) {
6454
- const minPluginVersion = options.minPluginVersion || "0.9.0-alpha.2";
6455
- const minProtocolVersion = options.minProtocolVersion || QTX_MIN_PROTOCOL_VERSION;
6477
+ const BUILTIN_CAPABILITY_SPECS = [
6478
+ // core:qtx 主插件(UI 组件 + 模板引擎 + 预置卡片)。installQtx() 即本域的包装。
6479
+ { ns: "core", pkg: "com.quicktvui.plugin.qtx", module: "QtxPluginApp", versionModule: "QtxVersionModule", minVersion: "" },
6480
+ // dogfood:qtx.version(主插件版本模块,只读诊断面)
6481
+ { ns: "version", pkg: "com.quicktvui.plugin.qtx", module: "QtxVersionModule", versionModule: "QtxVersionModule", minVersion: "" },
6482
+ // dogfood:qtx.env(宿主内建模块清单)
6483
+ { ns: "env", pkg: "com.quicktvui.plugin.qtx", module: "AddonEnvModule", versionModule: "QtxVersionModule", minVersion: "" },
6484
+ // dogfood:qtx.config.gridTabs(GridTabs 全局兜底配置)
6485
+ { ns: "config.gridTabs", pkg: "com.quicktvui.plugin.qtx", module: "GridTabsConfigModule", versionModule: "QtxVersionModule", minVersion: "" },
6486
+ // dogfood:qtx.config.extraUI(ExtraUI 全局主题)
6487
+ { ns: "config.extraUI", pkg: "com.quicktvui.plugin.qtx", module: "ExtraUIConfigModule", versionModule: "QtxVersionModule", minVersion: "" }
6488
+ ];
6489
+ const registry = /* @__PURE__ */ new Map();
6490
+ function addBuiltinCapability(spec) {
6491
+ registry.set(spec.ns, spec);
6492
+ }
6493
+ for (const spec of BUILTIN_CAPABILITY_SPECS)
6494
+ addBuiltinCapability(spec);
6495
+ const CAPABILITIES = registry;
6496
+ const NS_PATTERN = /^[a-z][a-z0-9]*(?:\.[a-z][a-z0-9]*)*$/;
6497
+ function registerCapability(spec) {
6498
+ if (!spec || typeof spec.ns !== "string" || !NS_PATTERN.test(spec.ns)) {
6499
+ throw new Error(`[qtx] 非法能力命名空间 ns=${spec && spec.ns}(应为小写点分单词,如 'file')`);
6500
+ }
6501
+ const root = spec.ns.split(".")[0];
6502
+ if (RESERVED_NAMESPACE_ROOTS.indexOf(root) >= 0) {
6503
+ throw new Error(`[qtx] 命名空间 qtx.${spec.ns} 的根段 "${root}" 已保留(${RESERVED_NAMESPACE_ROOTS.join("/")}),能力域不得占用`);
6504
+ }
6505
+ if (registry.has(spec.ns)) {
6506
+ throw new Error(`[qtx] 能力命名空间 qtx.${spec.ns} 已注册(pkg=${registry.get(spec.ns).pkg})`);
6507
+ }
6508
+ if (!spec.pkg || !spec.module || !spec.versionModule) {
6509
+ throw new Error(`[qtx] 能力 qtx.${spec.ns} 注册缺少 pkg/module/versionModule 字段`);
6510
+ }
6511
+ if (!spec.minVersion) {
6512
+ throw new Error(`[qtx] 能力 qtx.${spec.ns} 的 minVersion 必须由 qtx-cli generate 写入字面量(与类型同源,禁止手改)`);
6513
+ }
6514
+ registry.set(spec.ns, spec);
6515
+ return spec;
6516
+ }
6517
+ function getCapabilitySpec(ns) {
6518
+ return registry.get(ns) || null;
6519
+ }
6520
+ function defaultMainTrackMinVersion() {
6521
+ return "0.9.0-alpha.4";
6522
+ }
6523
+ async function runCapabilityBootstrap(spec, options) {
6524
+ const isCore = spec.ns === "core";
6525
+ const minPluginVersion = options.minVersion || spec.minVersion || defaultMainTrackMinVersion();
6526
+ const minProtocolVersion = isCore ? options.minProtocolVersion || QTX_MIN_PROTOCOL_VERSION : void 0;
6456
6527
  const upgrade = options.upgrade || "auto";
6457
6528
  const timeout = options.timeout || 8e3;
6458
- let info = await probeVersionInfo();
6529
+ let info = await probeVersionInfo(spec.versionModule);
6530
+ if (!info) {
6531
+ await new Promise((r) => setTimeout(r, 800));
6532
+ info = await probeVersionInfo(spec.versionModule);
6533
+ }
6459
6534
  if (!info) {
6460
6535
  if (upgrade === "auto") {
6461
- console.log(`[qtx] QtxVersionModule 未探测到,驱动宿主安装插件 ${QTX_PLUGIN_PKG} ...`);
6462
- await installPluginViaManager(timeout);
6463
- await triggerPluginInit();
6464
- info = await probeVersionInfo();
6536
+ console.log(isCore ? `[qtx] QtxVersionModule 未探测到,驱动宿主安装插件 ${spec.pkg} ...` : `[qtx] 能力 ${spec.ns} 未探测到(${spec.versionModule}),驱动宿主安装插件 ${spec.pkg} ...`);
6537
+ await installPluginViaManager(spec, timeout);
6538
+ await triggerPluginInit(spec);
6539
+ info = await probeVersionInfo(spec.versionModule);
6465
6540
  }
6466
6541
  if (!info) {
6467
6542
  throw new QtxInstallError(
6468
- upgrade === "auto" ? "PROBE_FAILED" : "PROBE_FAILED",
6469
- `插件未安装且未自动安装(upgrade=${upgrade})。请安装 plugin-qtx(${QTX_PLUGIN_PKG})或改用内嵌 AAR(com.quicktvui:qtx)`,
6470
- { minPluginVersion, minProtocolVersion }
6543
+ "PROBE_FAILED",
6544
+ isCore ? `插件未安装且未自动安装(upgrade=${upgrade})。请安装 plugin-qtx(${spec.pkg})或改用内嵌 AAR(com.quicktvui:qtx)` : `能力 ${spec.ns} 的插件未安装且未自动安装(upgrade=${upgrade},pkg=${spec.pkg},版本模块=${spec.versionModule},要求 >= ${minPluginVersion})`,
6545
+ { minPluginVersion, minProtocolVersion },
6546
+ spec.ns
6471
6547
  );
6472
6548
  }
6473
6549
  }
6474
6550
  if (info.mode === "embedded") {
6475
- console.log(`[qtx] embedded 模式就绪(宿主内嵌 com.quicktvui:qtx)`);
6551
+ console.log(isCore ? `[qtx] embedded 模式就绪(宿主内嵌 com.quicktvui:qtx)` : `[qtx] 能力 ${spec.ns} embedded 模式就绪(宿主内嵌,version=${info.pluginVersion})`);
6476
6552
  return info;
6477
6553
  }
6478
- if (!isVersionAtLeast(info.pluginVersion, minPluginVersion) || !isVersionAtLeast(info.protocolVersion, minProtocolVersion)) {
6554
+ const versionOk = isVersionAtLeast$1(info.pluginVersion, minPluginVersion);
6555
+ const protocolOk = !isCore || isVersionAtLeast$1(info.protocolVersion || "", minProtocolVersion || "0.0.0");
6556
+ if (!versionOk || !protocolOk) {
6479
6557
  if (upgrade === "auto") {
6480
6558
  console.log(
6481
- `[qtx] 版本过低(plugin ${info.pluginVersion}/${minPluginVersion}, protocol ${info.protocolVersion}/${minProtocolVersion}),驱动升级...`
6559
+ `[qtx] 版本过低(${isCore ? "plugin" : `能力 ${spec.ns}`} ${info.pluginVersion}/${minPluginVersion}` + (isCore ? `, protocol ${info.protocolVersion}/${minProtocolVersion}` : "") + "),驱动升级..."
6482
6560
  );
6483
- await installPluginViaManager(timeout);
6484
- await triggerPluginInit();
6485
- const reInfo = await probeVersionInfo();
6561
+ await installPluginViaManager(spec, timeout);
6562
+ await triggerPluginInit(spec);
6563
+ const reInfo = await probeVersionInfo(spec.versionModule);
6486
6564
  if (reInfo)
6487
6565
  info = reInfo;
6488
6566
  }
6489
- if (!isVersionAtLeast(info.pluginVersion, minPluginVersion)) {
6567
+ if (!isVersionAtLeast$1(info.pluginVersion, minPluginVersion)) {
6490
6568
  throw new QtxInstallError(
6491
6569
  "VERSION_TOO_LOW",
6492
- `插件版本过低:plugin=${info.pluginVersion},本库要求 >= ${minPluginVersion}。请升级 plugin-qtx`,
6493
- { ...info, minPluginVersion, minProtocolVersion }
6570
+ isCore ? `插件版本过低:plugin=${info.pluginVersion},本库要求 >= ${minPluginVersion}。请升级 plugin-qtx` : `能力 ${spec.ns} 插件版本过低:plugin=${info.pluginVersion},本库要求 >= ${minPluginVersion}(pkg=${spec.pkg})。请升级对应能力插件`,
6571
+ { ...info, minPluginVersion, minProtocolVersion },
6572
+ spec.ns
6494
6573
  );
6495
6574
  }
6496
- if (!isVersionAtLeast(info.protocolVersion, minProtocolVersion)) {
6575
+ if (isCore && !isVersionAtLeast$1(info.protocolVersion || "", minProtocolVersion || "0.0.0")) {
6497
6576
  throw new QtxInstallError(
6498
6577
  "PROTOCOL_MISMATCH",
6499
6578
  `指令协议不兼容:插件 protocol=${info.protocolVersion},本库要求 >= ${minProtocolVersion}(plugin=${info.pluginVersion})。请升级 plugin-qtx 或降级 @quicktvui/qtx`,
6500
- { ...info, minPluginVersion, minProtocolVersion }
6579
+ { ...info, minPluginVersion, minProtocolVersion },
6580
+ spec.ns
6501
6581
  );
6502
6582
  }
6503
6583
  }
6504
- console.log(`[qtx] 就绪:mode=plugin version=${info.pluginVersion} protocol=${info.protocolVersion}`);
6584
+ console.log(isCore ? `[qtx] 就绪:mode=plugin version=${info.pluginVersion} protocol=${info.protocolVersion}` : `[qtx] 能力 ${spec.ns} 就绪:mode=plugin version=${info.pluginVersion}`);
6505
6585
  return info;
6506
6586
  }
6507
- function installQtx(options) {
6508
- if (resolvedInfo)
6509
- return Promise.resolve(resolvedInfo);
6510
- if (!readyPromise) {
6511
- readyPromise = runBootstrap(options || {}).then(
6587
+ const readyPromises = /* @__PURE__ */ new Map();
6588
+ const resolvedInfos = /* @__PURE__ */ new Map();
6589
+ function ensureCapability(ns, options) {
6590
+ const resolved = resolvedInfos.get(ns);
6591
+ if (resolved)
6592
+ return Promise.resolve(resolved);
6593
+ let pending = readyPromises.get(ns);
6594
+ if (!pending) {
6595
+ const spec = registry.get(ns);
6596
+ if (!spec) {
6597
+ return Promise.reject(new QtxInstallError(
6598
+ "UNKNOWN_CAPABILITY",
6599
+ `未注册的能力命名空间 qtx.${ns}(已注册:${Array.from(registry.keys()).map((k) => `qtx.${k}`).join(", ")})`,
6600
+ void 0,
6601
+ ns
6602
+ ));
6603
+ }
6604
+ pending = runCapabilityBootstrap(spec, options || {}).then(
6512
6605
  (info) => {
6513
- resolvedInfo = info;
6606
+ resolvedInfos.set(ns, info);
6514
6607
  return info;
6515
6608
  },
6516
6609
  (err) => {
6517
- readyPromise = null;
6610
+ readyPromises.delete(ns);
6518
6611
  throw err;
6519
6612
  }
6520
6613
  );
6614
+ readyPromises.set(ns, pending);
6521
6615
  }
6522
- return readyPromise;
6616
+ return pending;
6617
+ }
6618
+ function getCapabilityInfo(ns) {
6619
+ return resolvedInfos.get(ns) || null;
6620
+ }
6621
+ const NON_PASSABLE_KEYS = /* @__PURE__ */ new Set([
6622
+ "then",
6623
+ "catch",
6624
+ "finally",
6625
+ // 防 thenable 误判(await / Promise.resolve 探测)
6626
+ "toJSON",
6627
+ // JSON.stringify 安全
6628
+ "constructor",
6629
+ "prototype",
6630
+ "__proto__",
6631
+ "valueOf",
6632
+ "toString",
6633
+ "toLocaleString",
6634
+ "hasOwnProperty",
6635
+ "isPrototypeOf",
6636
+ "propertyIsEnumerable",
6637
+ "inspect",
6638
+ "nodeType",
6639
+ "tagName",
6640
+ // 宿主内省 / 调试器防御
6641
+ "name",
6642
+ "length",
6643
+ "caller",
6644
+ "arguments"
6645
+ ]);
6646
+ const RESERVED_METHOD_KEYS = /* @__PURE__ */ new Set(["ready", "preheat", "getInfo"]);
6647
+ function serializeArg(arg) {
6648
+ return arg !== null && typeof arg === "object" ? JSON.stringify(arg) : arg;
6649
+ }
6650
+ function defineCapability(ns) {
6651
+ const methodCache = /* @__PURE__ */ new Map();
6652
+ const reserved = {
6653
+ ready: () => ensureCapability(ns),
6654
+ preheat: () => ensureCapability(ns).then(() => void 0),
6655
+ getInfo: () => getCapabilityInfo(ns)
6656
+ };
6657
+ const dispatch = (method) => {
6658
+ let fn = methodCache.get(method);
6659
+ if (!fn) {
6660
+ fn = (...args) => {
6661
+ const spec = registry.get(ns);
6662
+ if (!spec) {
6663
+ return Promise.reject(new QtxInstallError(
6664
+ "UNKNOWN_CAPABILITY",
6665
+ `未注册的能力命名空间 qtx.${ns}`,
6666
+ void 0,
6667
+ ns
6668
+ ));
6669
+ }
6670
+ return ensureCapability(ns).then(() => {
6671
+ const native = Native;
6672
+ return native.callNativeWithPromise(spec.module, method, ...args.map(serializeArg));
6673
+ });
6674
+ };
6675
+ methodCache.set(method, fn);
6676
+ }
6677
+ return fn;
6678
+ };
6679
+ return new Proxy({}, {
6680
+ get(_target, prop, _receiver) {
6681
+ if (typeof prop === "symbol")
6682
+ return void 0;
6683
+ if (RESERVED_METHOD_KEYS.has(prop))
6684
+ return reserved[prop];
6685
+ if (NON_PASSABLE_KEYS.has(prop))
6686
+ return void 0;
6687
+ return dispatch(prop);
6688
+ },
6689
+ has(_target, prop) {
6690
+ return typeof prop === "string" && !NON_PASSABLE_KEYS.has(prop);
6691
+ }
6692
+ });
6693
+ }
6694
+ function isPlainObject(v) {
6695
+ return !!v && typeof v === "object";
6696
+ }
6697
+ function attachCapabilityNamespaces(target) {
6698
+ for (const ns of Array.from(registry.keys())) {
6699
+ if (ns === "core")
6700
+ continue;
6701
+ const segments = ns.split(".");
6702
+ let node = target;
6703
+ for (let i = 0; i < segments.length - 1; i++) {
6704
+ const seg = segments[i];
6705
+ if (!Object.prototype.hasOwnProperty.call(node, seg) || !isPlainObject(node[seg])) {
6706
+ node[seg] = {};
6707
+ }
6708
+ node = node[seg];
6709
+ }
6710
+ const leaf = segments[segments.length - 1];
6711
+ if (Object.prototype.hasOwnProperty.call(node, leaf))
6712
+ continue;
6713
+ Object.defineProperty(node, leaf, {
6714
+ configurable: true,
6715
+ enumerable: true,
6716
+ get: () => defineCapability(ns)
6717
+ });
6718
+ }
6719
+ }
6720
+ function isVersionAtLeast(actual, required) {
6721
+ return isVersionAtLeast$1(actual, required);
6722
+ }
6723
+ function toCoreInfo(info) {
6724
+ return {
6725
+ pluginVersion: info.pluginVersion,
6726
+ protocolVersion: info.protocolVersion || "",
6727
+ components: info.components || {},
6728
+ mode: info.mode
6729
+ };
6730
+ }
6731
+ function toCoreOptions(options) {
6732
+ return {
6733
+ minVersion: options == null ? void 0 : options.minPluginVersion,
6734
+ minProtocolVersion: options == null ? void 0 : options.minProtocolVersion,
6735
+ upgrade: options == null ? void 0 : options.upgrade,
6736
+ timeout: options == null ? void 0 : options.timeout
6737
+ };
6738
+ }
6739
+ function installQtx(options) {
6740
+ return ensureCapability("core", toCoreOptions(options)).then(toCoreInfo);
6523
6741
  }
6524
6742
  function ensureQtxReady(options) {
6525
6743
  return installQtx(options);
6526
6744
  }
6527
6745
  function getQtxReadyInfo() {
6528
- return resolvedInfo;
6746
+ const info = getCapabilityInfo("core");
6747
+ return info ? toCoreInfo(info) : null;
6529
6748
  }
6749
+ const GATE_RETRY_DELAYS = [300, 800, 1600, 3e3];
6530
6750
  function createQtxGate(tagName) {
6531
6751
  return defineComponent({
6532
6752
  name: `${tagName}Gate`,
@@ -6535,17 +6755,37 @@ function createQtxGate(tagName) {
6535
6755
  const status = ref("loading");
6536
6756
  const errorMessage = ref("");
6537
6757
  const elRef = ref(null);
6538
- const bootstrap = () => {
6758
+ let attempt = 0;
6759
+ let retryTimer;
6760
+ const clearRetry = () => {
6761
+ if (retryTimer !== void 0) {
6762
+ clearTimeout(retryTimer);
6763
+ retryTimer = void 0;
6764
+ }
6765
+ };
6766
+ const bootstrap = (reset = false) => {
6767
+ if (reset) {
6768
+ clearRetry();
6769
+ attempt = 0;
6770
+ }
6539
6771
  status.value = "loading";
6540
6772
  errorMessage.value = "";
6541
6773
  ensureQtxReady().then(() => {
6542
6774
  status.value = "ready";
6543
6775
  }).catch((e) => {
6776
+ if (attempt < GATE_RETRY_DELAYS.length) {
6777
+ const delay = GATE_RETRY_DELAYS[attempt];
6778
+ attempt += 1;
6779
+ console.warn(`[QTX-GATE] ${tagName} bootstrap failed, retry ${attempt}/${GATE_RETRY_DELAYS.length} in ${delay}ms`);
6780
+ retryTimer = setTimeout(() => bootstrap(), delay);
6781
+ return;
6782
+ }
6544
6783
  status.value = "error";
6545
6784
  errorMessage.value = e instanceof Error ? e.message : String(e);
6546
6785
  });
6547
6786
  };
6548
- onMounted(bootstrap);
6787
+ onMounted(() => bootstrap(true));
6788
+ onUnmounted(clearRetry);
6549
6789
  expose({
6550
6790
  getNativeNode: () => elRef.value
6551
6791
  });
@@ -6562,17 +6802,23 @@ function createQtxGate(tagName) {
6562
6802
  alignItems: "center",
6563
6803
  justifyContent: "center",
6564
6804
  padding: "8px",
6565
- fontSize: "14px",
6566
- color: "#FF6B6B",
6567
6805
  backgroundColor: "#2B2B2B",
6568
6806
  borderRadius: "4px",
6569
6807
  width: "100%",
6570
- height: "100%",
6571
- textAlign: "center"
6808
+ height: "100%"
6572
6809
  },
6573
- onClick: bootstrap
6810
+ onClick: () => bootstrap(true)
6574
6811
  },
6575
- `${errorMessage.value}(点击重试)`
6812
+ [
6813
+ h("qt-text", {
6814
+ text: `${errorMessage.value}(点击重试)`,
6815
+ style: {
6816
+ fontSize: "14px",
6817
+ color: "#FF6B6B",
6818
+ textAlign: "center"
6819
+ }
6820
+ })
6821
+ ]
6576
6822
  );
6577
6823
  }
6578
6824
  return h(
@@ -6592,9 +6838,11 @@ function createQtxGate(tagName) {
6592
6838
  }
6593
6839
  });
6594
6840
  }
6841
+ const gridTabsConfig = defineCapability("config.gridTabs");
6842
+ const extraUIConfig = defineCapability("config.extraUI");
6595
6843
  async function initGridTabsGlobalConfig(config) {
6596
6844
  try {
6597
- const res = await Native.callNativeWithPromise("GridTabsConfigModule", "setDefaultConfig", JSON.stringify(config));
6845
+ const res = await gridTabsConfig.setDefaultConfig(config);
6598
6846
  return !!(res && res.success);
6599
6847
  } catch (error) {
6600
6848
  console.error("[qtx] Failed to initialize GridTabs global config:", error);
@@ -6603,7 +6851,7 @@ async function initGridTabsGlobalConfig(config) {
6603
6851
  }
6604
6852
  async function initExtraUIGlobalTheme(config) {
6605
6853
  try {
6606
- const res = await Native.callNativeWithPromise("ExtraUIConfigModule", "setThemeConfig", JSON.stringify(config));
6854
+ const res = await extraUIConfig.setThemeConfig(config);
6607
6855
  return !!(res && res.success);
6608
6856
  } catch (error) {
6609
6857
  console.error("[qtx] Failed to initialize ExtraUI global theme:", error);
@@ -6699,8 +6947,16 @@ const vPortalTo = {
6699
6947
  delete el.__qtxPortalKey;
6700
6948
  }
6701
6949
  };
6950
+ registerCapability({
6951
+ ns: "file",
6952
+ pkg: "com.quicktvui.plugin.qtx.file",
6953
+ module: "QtxFileModule",
6954
+ versionModule: "QtxFileVersionModule",
6955
+ minVersion: "0.1.0"
6956
+ });
6957
+ defineCapability("file");
6702
6958
  try {
6703
- console.log(`[qtx] Library loaded. Version: ${"0.9.0-alpha.2"}, Build Time: ${"2026/11/12 17:53:08"}`);
6959
+ console.log(`[qtx] Library loaded. Version: ${"0.9.0-alpha.4"}, Build Time: ${"2026/11/17 11:56:12"}`);
6704
6960
  } catch (e) {
6705
6961
  }
6706
6962
  let registerElement;
@@ -6727,7 +6983,20 @@ function registerPortalZoneTag() {
6727
6983
  globalThis.__QtxRelocatePool_registered = true;
6728
6984
  }
6729
6985
  }
6986
+ const qtxVersionNamespace = defineCapability("version");
6987
+ const qtxEnvNamespace = defineCapability("env");
6988
+ const qtxConfigGridTabsNamespace = defineCapability("config.gridTabs");
6989
+ const qtxConfigExtraUINamespace = defineCapability("config.extraUI");
6730
6990
  const qtx = {
6991
+ /** 版本与就绪信息(qtx.version.*,保留字 ready/preheat/getInfo) */
6992
+ version: qtxVersionNamespace,
6993
+ /** 宿主内建模块清单(qtx.env.*) */
6994
+ env: qtxEnvNamespace,
6995
+ /** 全局配置命名空间(qtx.config.gridTabs / qtx.config.extraUI) */
6996
+ config: {
6997
+ gridTabs: qtxConfigGridTabsNamespace,
6998
+ extraUI: qtxConfigExtraUINamespace
6999
+ },
6731
7000
  install: (app) => {
6732
7001
  app.directive("portal-to", vPortalTo);
6733
7002
  registerPortalZoneTag();
@@ -6766,7 +7035,9 @@ const qtx = {
6766
7035
  });
6767
7036
  }
6768
7037
  };
7038
+ attachCapabilityNamespaces(qtx);
6769
7039
  export {
7040
+ CAPABILITIES,
6770
7041
  QTX_CHANNEL_NAV_EVENTS,
6771
7042
  QTX_LIST_EVENTS,
6772
7043
  _sfc_main$2 as QtxAppIcon,
@@ -6818,11 +7089,17 @@ export {
6818
7089
  _sfc_main$6 as QtxTabContent,
6819
7090
  _sfc_main$7 as QtxTabs,
6820
7091
  QtxTabsPlugin,
7092
+ RESERVED_NAMESPACE_ROOTS,
7093
+ attachCapabilityNamespaces,
6821
7094
  captureItemTemplate,
6822
7095
  compactStylePack,
6823
7096
  createQtxGate,
6824
7097
  qtx as default,
7098
+ defineCapability,
7099
+ ensureCapability,
6825
7100
  ensureQtxReady,
7101
+ getCapabilityInfo,
7102
+ getCapabilitySpec,
6826
7103
  getPortalListViewId,
6827
7104
  getQtxReadyInfo,
6828
7105
  getStylePack,
@@ -6837,6 +7114,7 @@ export {
6837
7114
  listStylePacks,
6838
7115
  presetItem,
6839
7116
  qtx,
7117
+ registerCapability,
6840
7118
  registerPortalLive,
6841
7119
  registerStylePack,
6842
7120
  resolvePresetViewType,