@quicktvui/qtx 0.9.0-alpha.2 → 0.9.0-alpha.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/AI_CONTRACT.md +46 -8
- package/README.md +4 -4
- package/dist/capabilities/index.d.ts +10 -0
- package/dist/components/QtxChannelNav/QtxChannelNavBase.vue.d.ts +6 -0
- package/dist/components/QtxChannelNav/types.d.ts +10 -0
- package/dist/core/capabilities.d.ts +119 -0
- package/dist/core/installQtx.d.ts +1 -11
- package/dist/core/theme.d.ts +2 -5
- package/dist/index.d.ts +16 -0
- package/dist/qtx.cjs.js +1 -1
- package/dist/qtx.es.js +323 -66
- package/package.json +3 -2
- package/plugin/qtx-clip-inject.cjs +198 -0
- package/plugin/vite.mjs +31 -0
- package/plugin/webpack.cjs +23 -0
package/dist/qtx.es.js
CHANGED
|
@@ -1276,12 +1276,12 @@ function styleRegistry() {
|
|
|
1276
1276
|
return [];
|
|
1277
1277
|
}
|
|
1278
1278
|
function resolveClassStyles(classes) {
|
|
1279
|
-
const
|
|
1279
|
+
const registry2 = styleRegistry();
|
|
1280
1280
|
const classList = String(classes || "").split(/\s+/).filter(Boolean);
|
|
1281
|
-
if (!classList.length || !
|
|
1281
|
+
if (!classList.length || !registry2.length)
|
|
1282
1282
|
return [];
|
|
1283
1283
|
const out = [];
|
|
1284
|
-
for (const rule of
|
|
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(
|
|
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 !==
|
|
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(
|
|
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(
|
|
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:
|
|
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:
|
|
6469
|
+
entry: { from: `${spec.pkg}.QtxPluginApp`, method: "setup" }
|
|
6444
6470
|
}),
|
|
6445
6471
|
new Promise((resolve) => setTimeout(resolve, 3e3))
|
|
6446
6472
|
]);
|
|
@@ -6448,84 +6474,277 @@ async function triggerPluginInit() {
|
|
|
6448
6474
|
console.warn("[qtx] callReflect init skipped:", e);
|
|
6449
6475
|
}
|
|
6450
6476
|
}
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
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.3";
|
|
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 未探测到,驱动宿主安装插件 ${
|
|
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
|
-
|
|
6469
|
-
`插件未安装且未自动安装(upgrade=${upgrade})。请安装 plugin-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
|
-
|
|
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]
|
|
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
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
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
|
-
|
|
6606
|
+
resolvedInfos.set(ns, info);
|
|
6514
6607
|
return info;
|
|
6515
6608
|
},
|
|
6516
6609
|
(err) => {
|
|
6517
|
-
|
|
6610
|
+
readyPromises.delete(ns);
|
|
6518
6611
|
throw err;
|
|
6519
6612
|
}
|
|
6520
6613
|
);
|
|
6614
|
+
readyPromises.set(ns, pending);
|
|
6615
|
+
}
|
|
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
|
+
});
|
|
6521
6718
|
}
|
|
6522
|
-
|
|
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
|
-
|
|
6746
|
+
const info = getCapabilityInfo("core");
|
|
6747
|
+
return info ? toCoreInfo(info) : null;
|
|
6529
6748
|
}
|
|
6530
6749
|
function createQtxGate(tagName) {
|
|
6531
6750
|
return defineComponent({
|
|
@@ -6562,17 +6781,23 @@ function createQtxGate(tagName) {
|
|
|
6562
6781
|
alignItems: "center",
|
|
6563
6782
|
justifyContent: "center",
|
|
6564
6783
|
padding: "8px",
|
|
6565
|
-
fontSize: "14px",
|
|
6566
|
-
color: "#FF6B6B",
|
|
6567
6784
|
backgroundColor: "#2B2B2B",
|
|
6568
6785
|
borderRadius: "4px",
|
|
6569
6786
|
width: "100%",
|
|
6570
|
-
height: "100%"
|
|
6571
|
-
textAlign: "center"
|
|
6787
|
+
height: "100%"
|
|
6572
6788
|
},
|
|
6573
6789
|
onClick: bootstrap
|
|
6574
6790
|
},
|
|
6575
|
-
|
|
6791
|
+
[
|
|
6792
|
+
h("qt-text", {
|
|
6793
|
+
text: `${errorMessage.value}(点击重试)`,
|
|
6794
|
+
style: {
|
|
6795
|
+
fontSize: "14px",
|
|
6796
|
+
color: "#FF6B6B",
|
|
6797
|
+
textAlign: "center"
|
|
6798
|
+
}
|
|
6799
|
+
})
|
|
6800
|
+
]
|
|
6576
6801
|
);
|
|
6577
6802
|
}
|
|
6578
6803
|
return h(
|
|
@@ -6592,9 +6817,11 @@ function createQtxGate(tagName) {
|
|
|
6592
6817
|
}
|
|
6593
6818
|
});
|
|
6594
6819
|
}
|
|
6820
|
+
const gridTabsConfig = defineCapability("config.gridTabs");
|
|
6821
|
+
const extraUIConfig = defineCapability("config.extraUI");
|
|
6595
6822
|
async function initGridTabsGlobalConfig(config) {
|
|
6596
6823
|
try {
|
|
6597
|
-
const res = await
|
|
6824
|
+
const res = await gridTabsConfig.setDefaultConfig(config);
|
|
6598
6825
|
return !!(res && res.success);
|
|
6599
6826
|
} catch (error) {
|
|
6600
6827
|
console.error("[qtx] Failed to initialize GridTabs global config:", error);
|
|
@@ -6603,7 +6830,7 @@ async function initGridTabsGlobalConfig(config) {
|
|
|
6603
6830
|
}
|
|
6604
6831
|
async function initExtraUIGlobalTheme(config) {
|
|
6605
6832
|
try {
|
|
6606
|
-
const res = await
|
|
6833
|
+
const res = await extraUIConfig.setThemeConfig(config);
|
|
6607
6834
|
return !!(res && res.success);
|
|
6608
6835
|
} catch (error) {
|
|
6609
6836
|
console.error("[qtx] Failed to initialize ExtraUI global theme:", error);
|
|
@@ -6699,8 +6926,16 @@ const vPortalTo = {
|
|
|
6699
6926
|
delete el.__qtxPortalKey;
|
|
6700
6927
|
}
|
|
6701
6928
|
};
|
|
6929
|
+
registerCapability({
|
|
6930
|
+
ns: "file",
|
|
6931
|
+
pkg: "com.quicktvui.plugin.qtx.file",
|
|
6932
|
+
module: "QtxFileModule",
|
|
6933
|
+
versionModule: "QtxFileVersionModule",
|
|
6934
|
+
minVersion: "0.1.0"
|
|
6935
|
+
});
|
|
6936
|
+
defineCapability("file");
|
|
6702
6937
|
try {
|
|
6703
|
-
console.log(`[qtx] Library loaded. Version: ${"0.9.0-alpha.
|
|
6938
|
+
console.log(`[qtx] Library loaded. Version: ${"0.9.0-alpha.3"}, Build Time: ${"2026/11/17 11:16:52"}`);
|
|
6704
6939
|
} catch (e) {
|
|
6705
6940
|
}
|
|
6706
6941
|
let registerElement;
|
|
@@ -6727,7 +6962,20 @@ function registerPortalZoneTag() {
|
|
|
6727
6962
|
globalThis.__QtxRelocatePool_registered = true;
|
|
6728
6963
|
}
|
|
6729
6964
|
}
|
|
6965
|
+
const qtxVersionNamespace = defineCapability("version");
|
|
6966
|
+
const qtxEnvNamespace = defineCapability("env");
|
|
6967
|
+
const qtxConfigGridTabsNamespace = defineCapability("config.gridTabs");
|
|
6968
|
+
const qtxConfigExtraUINamespace = defineCapability("config.extraUI");
|
|
6730
6969
|
const qtx = {
|
|
6970
|
+
/** 版本与就绪信息(qtx.version.*,保留字 ready/preheat/getInfo) */
|
|
6971
|
+
version: qtxVersionNamespace,
|
|
6972
|
+
/** 宿主内建模块清单(qtx.env.*) */
|
|
6973
|
+
env: qtxEnvNamespace,
|
|
6974
|
+
/** 全局配置命名空间(qtx.config.gridTabs / qtx.config.extraUI) */
|
|
6975
|
+
config: {
|
|
6976
|
+
gridTabs: qtxConfigGridTabsNamespace,
|
|
6977
|
+
extraUI: qtxConfigExtraUINamespace
|
|
6978
|
+
},
|
|
6731
6979
|
install: (app) => {
|
|
6732
6980
|
app.directive("portal-to", vPortalTo);
|
|
6733
6981
|
registerPortalZoneTag();
|
|
@@ -6766,7 +7014,9 @@ const qtx = {
|
|
|
6766
7014
|
});
|
|
6767
7015
|
}
|
|
6768
7016
|
};
|
|
7017
|
+
attachCapabilityNamespaces(qtx);
|
|
6769
7018
|
export {
|
|
7019
|
+
CAPABILITIES,
|
|
6770
7020
|
QTX_CHANNEL_NAV_EVENTS,
|
|
6771
7021
|
QTX_LIST_EVENTS,
|
|
6772
7022
|
_sfc_main$2 as QtxAppIcon,
|
|
@@ -6818,11 +7068,17 @@ export {
|
|
|
6818
7068
|
_sfc_main$6 as QtxTabContent,
|
|
6819
7069
|
_sfc_main$7 as QtxTabs,
|
|
6820
7070
|
QtxTabsPlugin,
|
|
7071
|
+
RESERVED_NAMESPACE_ROOTS,
|
|
7072
|
+
attachCapabilityNamespaces,
|
|
6821
7073
|
captureItemTemplate,
|
|
6822
7074
|
compactStylePack,
|
|
6823
7075
|
createQtxGate,
|
|
6824
7076
|
qtx as default,
|
|
7077
|
+
defineCapability,
|
|
7078
|
+
ensureCapability,
|
|
6825
7079
|
ensureQtxReady,
|
|
7080
|
+
getCapabilityInfo,
|
|
7081
|
+
getCapabilitySpec,
|
|
6826
7082
|
getPortalListViewId,
|
|
6827
7083
|
getQtxReadyInfo,
|
|
6828
7084
|
getStylePack,
|
|
@@ -6837,6 +7093,7 @@ export {
|
|
|
6837
7093
|
listStylePacks,
|
|
6838
7094
|
presetItem,
|
|
6839
7095
|
qtx,
|
|
7096
|
+
registerCapability,
|
|
6840
7097
|
registerPortalLive,
|
|
6841
7098
|
registerStylePack,
|
|
6842
7099
|
resolvePresetViewType,
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quicktvui/qtx",
|
|
3
|
-
"version": "0.9.0-alpha.
|
|
3
|
+
"version": "0.9.0-alpha.3",
|
|
4
4
|
"description": "Vue 3 wrappers for QuickTVUI Native Addons",
|
|
5
5
|
"main": "dist/qtx.cjs.js",
|
|
6
6
|
"module": "dist/qtx.es.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
-
"AI_CONTRACT.md"
|
|
10
|
+
"AI_CONTRACT.md",
|
|
11
|
+
"plugin"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
14
|
"dev": "vite build --watch",
|