@quicktvui/naddons 1.0.0-alpha.3 → 1.0.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("vue"),T=require("@extscreen/es3-core"),P=require("@extscreen/es3-vue"),E=s.defineComponent({__name:"GridTabs",props:{tabsData:{},actionPayload:{}},emits:["onTabSelected","onTabNeedsData","onLoadMore","onItemPresence","onTabFocused","onItemClick","onItemFocused"],setup(r,{expose:e,emit:d}){const f=s.ref(),w=p("QtGridTabs","com.quicktvui.plugin.glintui"),v=d;function l(c,t){console.log(`[GridTabs.vue] received event from AsyncWrapper: ${c}`,t);const n=t&&t.nativeEvent!==void 0?t.nativeEvent:t;console.log(`[GridTabs.vue] emitting to parent: ${c}`,n),v(c,n)}return e({scrollToTop:(...c)=>{var t;return(t=f.value)==null?void 0:t.scrollToTop(...c)}}),(c,t)=>(s.openBlock(),s.createBlock(s.unref(w),s.mergeProps({ref_key:"nativeRef",ref:f,tabsData:r.tabsData,actionPayload:r.actionPayload,onOnTabSelected:t[0]||(t[0]=n=>l("onTabSelected",n)),onOnTabNeedsData:t[1]||(t[1]=n=>l("onTabNeedsData",n)),onOnLoadMore:t[2]||(t[2]=n=>l("onLoadMore",n)),onOnItemPresence:t[3]||(t[3]=n=>l("onItemPresence",n)),onOnTabFocused:t[4]||(t[4]=n=>l("onTabFocused",n)),onOnItemClick:t[5]||(t[5]=n=>l("onItemClick",n)),onOnItemFocused:t[6]||(t[6]=n=>l("onItemFocused",n))},c.$attrs),{default:s.withCtx(()=>[s.renderSlot(c.$slots,"default")]),_:3},16,["tabsData","actionPayload"]))}});function R(r,e){const d=s.ref(!1),f=s.ref(!1);return{isIntersecting:d,isVisible:f,handlePresenceState:v=>{var l,c,t;switch(v){case"enter":d.value=!0,(l=e==null?void 0:e.onEnter)==null||l.call(e);break;case"visible":f.value=!0,(c=e==null?void 0:e.onVisible)==null||c.call(e);break;case"leave":d.value=!1,f.value=!1,(t=e==null?void 0:e.onLeave)==null||t.call(e);break}}}}let b;var S;try{const r=require("@extscreen/es3-vue");b=r.registerElement||((S=r.default)==null?void 0:S.registerElement)}catch{}const I={install:r=>{globalThis.__QtGridTabs_registered||(b?(b("qt-grid-tabs",{component:{name:"QtGridTabs",processEventData(e,d,f){return{handler:d,nativeEvent:f}}}}),b("QtGridTabs",{component:{name:"QtGridTabs",processEventData(e,d,f){return{handler:d,nativeEvent:f}}}}),globalThis.__QtGridTabs_registered=!0,console.log("[@quicktvui/naddons] Successfully registered Native tag:","QtGridTabs")):console.warn("[@quicktvui/naddons] Failed to find registerElement from @extscreen/es3-vue")),r.component("GridTabs",E),r.component("qt-grid-tabs",E)}},A=new Set;function p(r,e,d){return s.defineComponent({name:`${r}AsyncWrapper`,inheritAttrs:!1,setup(f,{slots:w,attrs:v}){const l=s.ref("loading"),c=s.ref("");let t=null,n=null;try{t=T.useES(),n=T.useESPlugin()}catch(o){console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。",o)}const G=async()=>{if(!t||typeof t.isComponentRegistered!="function")return console.log("[withAsyncPlugin] es.isComponentRegistered 不可用"),!1;try{const o=await t.isComponentRegistered(r);if(console.log(`[withAsyncPlugin] isComponentRegistered('${r}') 返回:`,o),o===!0||o&&typeof o=="object"&&(o.registered===!0||o.isRegistered===!0))return!0;try{const i=await P.Native.callNativeWithPromise("ExtendModule","getCoreSDKInfo");if(i&&i.core_version){const u=i.core_version;console.log(`[withAsyncPlugin] 当前引擎核心版本: ${u}`);const a=u.split(".").map(g=>parseInt(g,10));if(a.length>=3&&!isNaN(a[0])&&!isNaN(a[1])&&!isNaN(a[2]))if(a[0]*1e6+a[1]*1e3+a[2]>=1011205){console.log(`[withAsyncPlugin] 引擎 >= 1.11.205,使用 ExtendModule 检查 Controller: ${r}`);const y=r.split("-").map($=>$.charAt(0).toUpperCase()+$.slice(1)).join("");console.log(`[withAsyncPlugin] 同时检查原名和驼峰名: ${r}, ${y}`);const[m,h]=await Promise.all([P.Native.callNativeWithPromise("ExtendModule","isComponentRegistered",r).catch(()=>!1),P.Native.callNativeWithPromise("ExtendModule","isComponentRegistered",y).catch(()=>!1)]);if(console.log(`[withAsyncPlugin] ExtendModule.isComponentRegistered 返回: [${m}, ${h}]`),m===!0||h===!0)return!0}else console.log(`[withAsyncPlugin] 引擎版本 ${u} < 1.11.205,跳过 ExtendModule 检查`);else console.log(`[withAsyncPlugin] 无法解析引擎版本号: ${u}`)}}catch(i){console.log("[withAsyncPlugin] 获取引擎版本或检查 Controller 失败:",i)}return!1}catch(o){return console.warn("[withAsyncPlugin] 检查组件注册状态异常:",o),!1}},M=async()=>{if(!e){l.value="ready";return}const o=await G();if(console.log(`[withAsyncPlugin] 拦截检查 - ${r} 是否已注册:`,o),o||A.has(e)){l.value="ready",A.add(e),console.log("[withAsyncPlugin] 组件已注册,跳过安装流程");return}if(!n){console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${r}`),l.value="ready";return}console.log(`[withAsyncPlugin] 开始动态安装插件: ${e}`);try{await new Promise((i,u)=>{let a;const g={onPluginInstallSuccess(y,m,h){y===e&&(clearTimeout(a),n.removeListener(g),console.log(`[withAsyncPlugin] 安装成功 pkg=${y} 状态码=${m}`),m==1003||m==1001?(d?(console.log(`[withAsyncPlugin] 触发反射初始化: ${d}`),P.Native.callNative("EsNativeModule","callReflect",{entry:{from:d,method:"setup"}})):console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"),i()):u(new Error(`安装失败 pkg=${y} status=${m} msg=${h}`)))},onPluginInstallError(y,m,h){y===e&&(clearTimeout(a),n.removeListener(g),u(new Error(`安装失败 pkg=${y} status=${m} msg=${h}`)))}};n.addListener({pkg:e},g),a=setTimeout(()=>{n.removeListener(g),u(new Error(`插件安装超时: ${e}`))},8e3),typeof n.installPlugin=="function"?n.installPlugin({pkg:e}):typeof n.install=="function"?n.install(e):u(new Error("当前运行时不支持 install / installPlugin"))}),await s.nextTick(),A.add(e),l.value="ready"}catch(i){console.error("[withAsyncPlugin] 插件加载失败:",i),c.value=(i==null?void 0:i.message)||String(i),l.value="error"}};return s.onMounted(()=>{M()}),()=>{const o={width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",...v.style||{}};if(l.value==="loading")return s.h("div",{class:"qt-plugin-container",style:o},[s.h("div",{style:{color:"white",fontSize:"30px"}},"插件加载中...")]);if(l.value==="error")return s.h("div",{class:"qt-plugin-container",style:o},[s.h("div",{style:{color:"white",fontSize:"30px",backgroundColor:"rgba(255,0,0,0.5)"}},`插件加载失败: ${c.value}`)]);const i={};for(const[u,a]of Object.entries(v))u.startsWith("on")&&typeof a=="function"?i[u]=(...g)=>(console.log(`[withAsyncPlugin] NativeTag=${r} 收到事件 ${u}:`,g),a(...g)):i[u]=a;return s.h("div",{class:"qt-plugin-container",style:o},[s.h(r,{...i,style:{width:"100%",height:"100%",backgroundColor:"transparent"}},w.default?w.default():[])])}}})}const C={install:r=>{r.use(I)}};exports.GridTabs=E;exports.GridTabsPlugin=I;exports.QuickTVUINAddons=C;exports.default=C;exports.useGridItemPresence=R;exports.withAsyncPlugin=p;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),I=require("@extscreen/es3-core"),v=require("@extscreen/es3-vue"),$=l.defineComponent({__name:"GridTabs",props:{tabsData:{},actionPayload:{}},emits:["onTabSelected","onTabNeedsData","onLoadMore","onItemPresence","onTabFocused","onItemClick","onItemFocused"],setup(o,{expose:t}){const u=l.ref(),d=p("QtGridTabs","com.quicktvui.plugin.glintui");return t({scrollToTop:(...a)=>{var n;return(n=u.value)==null?void 0:n.scrollToTop(...a)}}),(a,n)=>(l.openBlock(),l.createBlock(l.unref(d),l.mergeProps({ref_key:"nativeRef",ref:u,tabsData:o.tabsData,actionPayload:o.actionPayload,onOnTabSelected:n[0]||(n[0]=i=>a.$emit("onTabSelected",i.nativeEvent)),onOnTabNeedsData:n[1]||(n[1]=i=>a.$emit("onTabNeedsData",i.nativeEvent)),onOnLoadMore:n[2]||(n[2]=i=>a.$emit("onLoadMore",i.nativeEvent)),onOnItemPresence:n[3]||(n[3]=i=>a.$emit("onItemPresence",i.nativeEvent)),onOnTabFocused:n[4]||(n[4]=i=>a.$emit("onTabFocused",i.nativeEvent)),onOnItemClick:n[5]||(n[5]=i=>a.$emit("onItemClick",i.nativeEvent)),onOnItemFocused:n[6]||(n[6]=i=>a.$emit("onItemFocused",i.nativeEvent))},a.$attrs),{default:l.withCtx(()=>[l.renderSlot(a.$slots,"default")]),_:3},16,["tabsData","actionPayload"]))}});function F(o,t){const u=l.ref(!1),d=l.ref(!1);return{isIntersecting:u,isVisible:d,handlePresenceState:n=>{var i,P,b;switch(n){case"enter":u.value=!0,(i=t==null?void 0:t.onEnter)==null||i.call(t);break;case"visible":d.value=!0,(P=t==null?void 0:t.onVisible)==null||P.call(t);break;case"leave":u.value=!1,d.value=!1,(b=t==null?void 0:t.onLeave)==null||b.call(t);break}}}}let w;var E;try{const o=require("@extscreen/es3-vue");w=o.registerElement||((E=o.default)==null?void 0:E.registerElement)}catch{}const S={install:o=>{globalThis.__QtGridTabs_registered||(w?(w("qt-grid-tabs",{component:{name:"QtGridTabs",processEventData(t,u,d){return console.log(`[GridTabs/index.ts] qt-grid-tabs 收到原生事件: ${u}, 数据:`,d),t.nativeEvent=d,t}}}),w("QtGridTabs",{component:{name:"QtGridTabs",processEventData(t,u,d){return console.log(`[GridTabs/index.ts] QtGridTabs 收到原生事件: ${u}, 数据:`,d),t.nativeEvent=d,t}}}),globalThis.__QtGridTabs_registered=!0,console.log("[@quicktvui/naddons] Successfully registered Native tag:","QtGridTabs")):console.warn("[@quicktvui/naddons] Failed to find registerElement from @extscreen/es3-vue")),o.component("GridTabs",$),o.component("qt-grid-tabs",$)}},T=new Set;function p(o,t,u){return l.defineComponent({name:`${o}AsyncWrapper`,inheritAttrs:!1,setup(d,{slots:a,attrs:n}){const i=l.ref("loading"),P=l.ref("");let b=null,m=null;try{b=I.useES(),m=I.useESPlugin()}catch(r){console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。",r)}const M=async()=>{if(!b||typeof b.isComponentRegistered!="function")return console.log("[withAsyncPlugin] es.isComponentRegistered 不可用"),!1;try{const r=await b.isComponentRegistered(o);if(console.log(`[withAsyncPlugin] isComponentRegistered('${o}') 返回:`,r),r===!0||r&&typeof r=="object"&&(r.registered===!0||r.isRegistered===!0))return!0;try{const c=await v.Native.callNativeWithPromise("ExtendModule","getCoreSDKInfo");if(c&&c.core_version){const f=c.core_version;console.log(`[withAsyncPlugin] 当前引擎核心版本: ${f}`);const e=f.split(".").map(s=>parseInt(s,10));if(e.length>=3&&!isNaN(e[0])&&!isNaN(e[1])&&!isNaN(e[2]))if(e[0]*1e6+e[1]*1e3+e[2]>=1011205){console.log(`[withAsyncPlugin] 引擎 >= 1.11.205,使用 ExtendModule 检查 Controller: ${o}`);const g=o.split("-").map(A=>A.charAt(0).toUpperCase()+A.slice(1)).join("");console.log(`[withAsyncPlugin] 同时检查原名和驼峰名: ${o}, ${g}`);const[y,h]=await Promise.all([v.Native.callNativeWithPromise("ExtendModule","isComponentRegistered",o).catch(()=>!1),v.Native.callNativeWithPromise("ExtendModule","isComponentRegistered",g).catch(()=>!1)]);if(console.log(`[withAsyncPlugin] ExtendModule.isComponentRegistered 返回: [${y}, ${h}]`),y===!0||h===!0)return!0}else console.log(`[withAsyncPlugin] 引擎版本 ${f} < 1.11.205,跳过 ExtendModule 检查`);else console.log(`[withAsyncPlugin] 无法解析引擎版本号: ${f}`)}}catch(c){console.log("[withAsyncPlugin] 获取引擎版本或检查 Controller 失败:",c)}return!1}catch(r){return console.warn("[withAsyncPlugin] 检查组件注册状态异常:",r),!1}},O=async()=>{if(!t){i.value="ready";return}const r=await M();if(console.log(`[withAsyncPlugin] 拦截检查 - ${o} 是否已注册:`,r),r||T.has(t)){i.value="ready",T.add(t),console.log("[withAsyncPlugin] 组件已注册,跳过安装流程");return}if(!m){console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${o}`),i.value="ready";return}console.log(`[withAsyncPlugin] 开始动态安装插件: ${t}`);try{await new Promise((c,f)=>{let e;const s={onPluginInstallSuccess(g,y,h){g===t&&(clearTimeout(e),m.removeListener(s),console.log(`[withAsyncPlugin] 安装成功 pkg=${g} 状态码=${y}`),y==1003||y==1001?(u?(console.log(`[withAsyncPlugin] 触发反射初始化: ${u}`),v.Native.callNative("EsNativeModule","callReflect",{entry:{from:u,method:"setup"}})):console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"),c()):f(new Error(`安装失败 pkg=${g} status=${y} msg=${h}`)))},onPluginInstallError(g,y,h){g===t&&(clearTimeout(e),m.removeListener(s),f(new Error(`安装失败 pkg=${g} status=${y} msg=${h}`)))}};m.addListener({pkg:t},s),e=setTimeout(()=>{m.removeListener(s),f(new Error(`插件安装超时: ${t}`))},8e3),typeof m.installPlugin=="function"?m.installPlugin({pkg:t}):typeof m.install=="function"?m.install(t):f(new Error("当前运行时不支持 install / installPlugin"))}),await l.nextTick(),T.add(t),i.value="ready"}catch(c){console.error("[withAsyncPlugin] 插件加载失败:",c),P.value=(c==null?void 0:c.message)||String(c),i.value="error"}};return l.onMounted(()=>{O()}),()=>{const r={width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",...n.style||{}};if(i.value==="loading")return l.h("div",{class:"qt-plugin-container",style:r},[l.h("div",{style:{color:"white",fontSize:"30px"}},"插件加载中...")]);if(i.value==="error")return l.h("div",{class:"qt-plugin-container",style:r},[l.h("div",{style:{color:"white",fontSize:"30px",backgroundColor:"rgba(255,0,0,0.5)"}},`插件加载失败: ${P.value}`)]);const c={};for(const[e,s]of Object.entries(n)){const g=e.startsWith("on")&&e!=="onItemPresence"&&e!=="onTabSelected"&&e!=="onTabNeedsData"&&e!=="onLoadMore"&&e!=="onTabFocused"&&e!=="onItemClick"&&e!=="onItemFocused";!e.startsWith("onOn")&&!g&&(c[e]=s)}const f={...c,style:{width:"1920px",height:"1080px",backgroundColor:"transparent"},onItemPresence:e=>{console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onItemPresence:`,e);const s=n.onOnItemPresence||n.onItemPresence||n.onitempresence;typeof s=="function"&&s(e)},onTabSelected:e=>{console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onTabSelected:`,e);const s=n.onOnTabSelected||n.onTabSelected;typeof s=="function"&&s(e)},onTabNeedsData:e=>{console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onTabNeedsData:`,e);const s=n.onOnTabNeedsData||n.onTabNeedsData;typeof s=="function"&&s(e)},onLoadMore:e=>{console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onLoadMore:`,e);const s=n.onOnLoadMore||n.onLoadMore;typeof s=="function"&&s(e)},onTabFocused:e=>{console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onTabFocused:`,e);const s=n.onOnTabFocused||n.onTabFocused;typeof s=="function"&&s(e)},onItemClick:e=>{console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onItemClick:`,e);const s=n.onOnItemClick||n.onItemClick;typeof s=="function"&&s(e)},onItemFocused:e=>{console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onItemFocused:`,e);const s=n.onOnItemFocused||n.onItemFocused;typeof s=="function"&&s(e)}};return console.log("[withAsyncPlugin] 最终准备传递给 h() 的属性键集合:",Object.keys(f)),l.h("div",{class:"qt-plugin-container",style:r},[l.h(o,f,a.default?a.default():[])])}}})}const C={install:o=>{o.use(S)}};exports.GridTabs=$;exports.GridTabsPlugin=S;exports.QuickTVUINAddons=C;exports.default=C;exports.useGridItemPresence=F;exports.withAsyncPlugin=p;
@@ -1,232 +1,259 @@
1
- import { defineComponent as S, ref as b, openBlock as x, createBlock as R, unref as G, mergeProps as M, withCtx as D, renderSlot as k, onMounted as q, h, nextTick as L } from "vue";
2
- import { useES as Q, useESPlugin as F } from "@extscreen/es3-core";
3
- import { Native as P } from "@extscreen/es3-vue";
4
- const T = /* @__PURE__ */ S({
1
+ import { defineComponent as p, ref as P, openBlock as M, createBlock as F, unref as O, mergeProps as D, withCtx as k, renderSlot as G, onMounted as R, h, nextTick as L } from "vue";
2
+ import { useES as x, useESPlugin as q } from "@extscreen/es3-core";
3
+ import { Native as v } from "@extscreen/es3-vue";
4
+ const E = /* @__PURE__ */ p({
5
5
  __name: "GridTabs",
6
6
  props: {
7
7
  tabsData: {},
8
8
  actionPayload: {}
9
9
  },
10
10
  emits: ["onTabSelected", "onTabNeedsData", "onLoadMore", "onItemPresence", "onTabFocused", "onItemClick", "onItemFocused"],
11
- setup(r, { expose: e, emit: u }) {
12
- const d = b(), w = O(
11
+ setup(o, { expose: t }) {
12
+ const a = P(), u = W(
13
13
  "QtGridTabs",
14
14
  "com.quicktvui.plugin.glintui"
15
- ), y = u;
16
- function s(a, t) {
17
- console.log(`[GridTabs.vue] received event from AsyncWrapper: ${a}`, t);
18
- const n = t && t.nativeEvent !== void 0 ? t.nativeEvent : t;
19
- console.log(`[GridTabs.vue] emitting to parent: ${a}`, n), y(a, n);
20
- }
21
- return e({
22
- scrollToTop: (...a) => {
23
- var t;
24
- return (t = d.value) == null ? void 0 : t.scrollToTop(...a);
15
+ );
16
+ return t({
17
+ scrollToTop: (...c) => {
18
+ var n;
19
+ return (n = a.value) == null ? void 0 : n.scrollToTop(...c);
25
20
  }
26
- }), (a, t) => (x(), R(G(w), M({
21
+ }), (c, n) => (M(), F(O(u), D({
27
22
  ref_key: "nativeRef",
28
- ref: d,
29
- tabsData: r.tabsData,
30
- actionPayload: r.actionPayload,
31
- onOnTabSelected: t[0] || (t[0] = (n) => s("onTabSelected", n)),
32
- onOnTabNeedsData: t[1] || (t[1] = (n) => s("onTabNeedsData", n)),
33
- onOnLoadMore: t[2] || (t[2] = (n) => s("onLoadMore", n)),
34
- onOnItemPresence: t[3] || (t[3] = (n) => s("onItemPresence", n)),
35
- onOnTabFocused: t[4] || (t[4] = (n) => s("onTabFocused", n)),
36
- onOnItemClick: t[5] || (t[5] = (n) => s("onItemClick", n)),
37
- onOnItemFocused: t[6] || (t[6] = (n) => s("onItemFocused", n))
38
- }, a.$attrs), {
39
- default: D(() => [
40
- k(a.$slots, "default")
23
+ ref: a,
24
+ tabsData: o.tabsData,
25
+ actionPayload: o.actionPayload,
26
+ onOnTabSelected: n[0] || (n[0] = (l) => c.$emit("onTabSelected", l.nativeEvent)),
27
+ onOnTabNeedsData: n[1] || (n[1] = (l) => c.$emit("onTabNeedsData", l.nativeEvent)),
28
+ onOnLoadMore: n[2] || (n[2] = (l) => c.$emit("onLoadMore", l.nativeEvent)),
29
+ onOnItemPresence: n[3] || (n[3] = (l) => c.$emit("onItemPresence", l.nativeEvent)),
30
+ onOnTabFocused: n[4] || (n[4] = (l) => c.$emit("onTabFocused", l.nativeEvent)),
31
+ onOnItemClick: n[5] || (n[5] = (l) => c.$emit("onItemClick", l.nativeEvent)),
32
+ onOnItemFocused: n[6] || (n[6] = (l) => c.$emit("onItemFocused", l.nativeEvent))
33
+ }, c.$attrs), {
34
+ default: k(() => [
35
+ G(c.$slots, "default")
41
36
  ]),
42
37
  _: 3
43
38
  }, 16, ["tabsData", "actionPayload"]));
44
39
  }
45
40
  });
46
- function U(r, e) {
47
- const u = b(!1), d = b(!1);
41
+ function z(o, t) {
42
+ const a = P(!1), u = P(!1);
48
43
  return {
49
- isIntersecting: u,
50
- isVisible: d,
51
- handlePresenceState: (y) => {
52
- var s, a, t;
53
- switch (y) {
44
+ isIntersecting: a,
45
+ isVisible: u,
46
+ handlePresenceState: (n) => {
47
+ var l, w, y;
48
+ switch (n) {
54
49
  case "enter":
55
- u.value = !0, (s = e == null ? void 0 : e.onEnter) == null || s.call(e);
50
+ a.value = !0, (l = t == null ? void 0 : t.onEnter) == null || l.call(t);
56
51
  break;
57
52
  case "visible":
58
- d.value = !0, (a = e == null ? void 0 : e.onVisible) == null || a.call(e);
53
+ u.value = !0, (w = t == null ? void 0 : t.onVisible) == null || w.call(t);
59
54
  break;
60
55
  case "leave":
61
- u.value = !1, d.value = !1, (t = e == null ? void 0 : e.onLeave) == null || t.call(e);
56
+ a.value = !1, u.value = !1, (y = t == null ? void 0 : t.onLeave) == null || y.call(t);
62
57
  break;
63
58
  }
64
59
  }
65
60
  };
66
61
  }
67
- let E;
68
- var p;
62
+ let $;
63
+ var I;
69
64
  try {
70
- const r = require("@extscreen/es3-vue");
71
- E = r.registerElement || ((p = r.default) == null ? void 0 : p.registerElement);
65
+ const o = require("@extscreen/es3-vue");
66
+ $ = o.registerElement || ((I = o.default) == null ? void 0 : I.registerElement);
72
67
  } catch {
73
68
  }
74
- const W = {
75
- install: (r) => {
76
- globalThis.__QtGridTabs_registered || (E ? (E("qt-grid-tabs", {
69
+ const Q = {
70
+ install: (o) => {
71
+ globalThis.__QtGridTabs_registered || ($ ? ($("qt-grid-tabs", {
77
72
  component: {
78
73
  name: "QtGridTabs",
79
74
  // 关键:将前端标签映射到真正的 Native 组件名
80
- processEventData(e, u, d) {
81
- return {
82
- handler: u,
83
- nativeEvent: d
84
- };
75
+ processEventData(t, a, u) {
76
+ return console.log(`[GridTabs/index.ts] qt-grid-tabs 收到原生事件: ${a}, 数据:`, u), t.nativeEvent = u, t;
85
77
  }
86
78
  }
87
- }), E("QtGridTabs", {
79
+ }), $("QtGridTabs", {
88
80
  component: {
89
81
  name: "QtGridTabs",
90
- processEventData(e, u, d) {
91
- return {
92
- handler: u,
93
- nativeEvent: d
94
- };
82
+ processEventData(t, a, u) {
83
+ return console.log(`[GridTabs/index.ts] QtGridTabs 收到原生事件: ${a}, 数据:`, u), t.nativeEvent = u, t;
95
84
  }
96
85
  }
97
- }), globalThis.__QtGridTabs_registered = !0, console.log("[@quicktvui/naddons] Successfully registered Native tag:", "QtGridTabs")) : console.warn("[@quicktvui/naddons] Failed to find registerElement from @extscreen/es3-vue")), r.component("GridTabs", T), r.component("qt-grid-tabs", T);
86
+ }), globalThis.__QtGridTabs_registered = !0, console.log("[@quicktvui/naddons] Successfully registered Native tag:", "QtGridTabs")) : console.warn("[@quicktvui/naddons] Failed to find registerElement from @extscreen/es3-vue")), o.component("GridTabs", E), o.component("qt-grid-tabs", E);
98
87
  }
99
- }, A = /* @__PURE__ */ new Set();
100
- function O(r, e, u) {
101
- return S({
102
- name: `${r}AsyncWrapper`,
88
+ }, T = /* @__PURE__ */ new Set();
89
+ function W(o, t, a) {
90
+ return p({
91
+ name: `${o}AsyncWrapper`,
103
92
  inheritAttrs: !1,
104
- setup(d, { slots: w, attrs: y }) {
105
- const s = b("loading"), a = b("");
106
- let t = null, n = null;
93
+ setup(u, { slots: c, attrs: n }) {
94
+ const l = P("loading"), w = P("");
95
+ let y = null, g = null;
107
96
  try {
108
- t = Q(), n = F();
109
- } catch (l) {
110
- console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。", l);
97
+ y = x(), g = q();
98
+ } catch (i) {
99
+ console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。", i);
111
100
  }
112
- const I = async () => {
113
- if (!t || typeof t.isComponentRegistered != "function")
101
+ const S = async () => {
102
+ if (!y || typeof y.isComponentRegistered != "function")
114
103
  return console.log("[withAsyncPlugin] es.isComponentRegistered 不可用"), !1;
115
104
  try {
116
- const l = await t.isComponentRegistered(r);
117
- if (console.log(`[withAsyncPlugin] isComponentRegistered('${r}') 返回:`, l), l === !0 || l && typeof l == "object" && (l.registered === !0 || l.isRegistered === !0))
105
+ const i = await y.isComponentRegistered(o);
106
+ if (console.log(`[withAsyncPlugin] isComponentRegistered('${o}') 返回:`, i), i === !0 || i && typeof i == "object" && (i.registered === !0 || i.isRegistered === !0))
118
107
  return !0;
119
108
  try {
120
- const o = await P.callNativeWithPromise("ExtendModule", "getCoreSDKInfo");
121
- if (o && o.core_version) {
122
- const c = o.core_version;
123
- console.log(`[withAsyncPlugin] 当前引擎核心版本: ${c}`);
124
- const i = c.split(".").map((f) => parseInt(f, 10));
125
- if (i.length >= 3 && !isNaN(i[0]) && !isNaN(i[1]) && !isNaN(i[2]))
126
- if (i[0] * 1e6 + i[1] * 1e3 + i[2] >= 1011205) {
127
- console.log(`[withAsyncPlugin] 引擎 >= 1.11.205,使用 ExtendModule 检查 Controller: ${r}`);
128
- const g = r.split("-").map(($) => $.charAt(0).toUpperCase() + $.slice(1)).join("");
129
- console.log(`[withAsyncPlugin] 同时检查原名和驼峰名: ${r}, ${g}`);
130
- const [m, v] = await Promise.all([
131
- P.callNativeWithPromise("ExtendModule", "isComponentRegistered", r).catch(() => !1),
132
- P.callNativeWithPromise("ExtendModule", "isComponentRegistered", g).catch(() => !1)
109
+ const r = await v.callNativeWithPromise("ExtendModule", "getCoreSDKInfo");
110
+ if (r && r.core_version) {
111
+ const d = r.core_version;
112
+ console.log(`[withAsyncPlugin] 当前引擎核心版本: ${d}`);
113
+ const e = d.split(".").map((s) => parseInt(s, 10));
114
+ if (e.length >= 3 && !isNaN(e[0]) && !isNaN(e[1]) && !isNaN(e[2]))
115
+ if (e[0] * 1e6 + e[1] * 1e3 + e[2] >= 1011205) {
116
+ console.log(`[withAsyncPlugin] 引擎 >= 1.11.205,使用 ExtendModule 检查 Controller: ${o}`);
117
+ const f = o.split("-").map((A) => A.charAt(0).toUpperCase() + A.slice(1)).join("");
118
+ console.log(`[withAsyncPlugin] 同时检查原名和驼峰名: ${o}, ${f}`);
119
+ const [m, b] = await Promise.all([
120
+ v.callNativeWithPromise("ExtendModule", "isComponentRegistered", o).catch(() => !1),
121
+ v.callNativeWithPromise("ExtendModule", "isComponentRegistered", f).catch(() => !1)
133
122
  ]);
134
- if (console.log(`[withAsyncPlugin] ExtendModule.isComponentRegistered 返回: [${m}, ${v}]`), m === !0 || v === !0)
123
+ if (console.log(`[withAsyncPlugin] ExtendModule.isComponentRegistered 返回: [${m}, ${b}]`), m === !0 || b === !0)
135
124
  return !0;
136
125
  } else
137
- console.log(`[withAsyncPlugin] 引擎版本 ${c} < 1.11.205,跳过 ExtendModule 检查`);
126
+ console.log(`[withAsyncPlugin] 引擎版本 ${d} < 1.11.205,跳过 ExtendModule 检查`);
138
127
  else
139
- console.log(`[withAsyncPlugin] 无法解析引擎版本号: ${c}`);
128
+ console.log(`[withAsyncPlugin] 无法解析引擎版本号: ${d}`);
140
129
  }
141
- } catch (o) {
142
- console.log("[withAsyncPlugin] 获取引擎版本或检查 Controller 失败:", o);
130
+ } catch (r) {
131
+ console.log("[withAsyncPlugin] 获取引擎版本或检查 Controller 失败:", r);
143
132
  }
144
133
  return !1;
145
- } catch (l) {
146
- return console.warn("[withAsyncPlugin] 检查组件注册状态异常:", l), !1;
134
+ } catch (i) {
135
+ return console.warn("[withAsyncPlugin] 检查组件注册状态异常:", i), !1;
147
136
  }
148
137
  }, C = async () => {
149
- if (!e) {
150
- s.value = "ready";
138
+ if (!t) {
139
+ l.value = "ready";
151
140
  return;
152
141
  }
153
- const l = await I();
154
- if (console.log(`[withAsyncPlugin] 拦截检查 - ${r} 是否已注册:`, l), l || A.has(e)) {
155
- s.value = "ready", A.add(e), console.log("[withAsyncPlugin] 组件已注册,跳过安装流程");
142
+ const i = await S();
143
+ if (console.log(`[withAsyncPlugin] 拦截检查 - ${o} 是否已注册:`, i), i || T.has(t)) {
144
+ l.value = "ready", T.add(t), console.log("[withAsyncPlugin] 组件已注册,跳过安装流程");
156
145
  return;
157
146
  }
158
- if (!n) {
159
- console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${r}`), s.value = "ready";
147
+ if (!g) {
148
+ console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${o}`), l.value = "ready";
160
149
  return;
161
150
  }
162
- console.log(`[withAsyncPlugin] 开始动态安装插件: ${e}`);
151
+ console.log(`[withAsyncPlugin] 开始动态安装插件: ${t}`);
163
152
  try {
164
- await new Promise((o, c) => {
165
- let i;
166
- const f = {
167
- onPluginInstallSuccess(g, m, v) {
168
- g === e && (clearTimeout(i), n.removeListener(f), console.log(`[withAsyncPlugin] 安装成功 pkg=${g} 状态码=${m}`), m == 1003 || m == 1001 ? (u ? (console.log(`[withAsyncPlugin] 触发反射初始化: ${u}`), P.callNative("EsNativeModule", "callReflect", {
153
+ await new Promise((r, d) => {
154
+ let e;
155
+ const s = {
156
+ onPluginInstallSuccess(f, m, b) {
157
+ f === t && (clearTimeout(e), g.removeListener(s), console.log(`[withAsyncPlugin] 安装成功 pkg=${f} 状态码=${m}`), m == 1003 || m == 1001 ? (a ? (console.log(`[withAsyncPlugin] 触发反射初始化: ${a}`), v.callNative("EsNativeModule", "callReflect", {
169
158
  entry: {
170
- from: u,
159
+ from: a,
171
160
  method: "setup"
172
161
  }
173
- })) : console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"), o()) : c(new Error(`安装失败 pkg=${g} status=${m} msg=${v}`)));
162
+ })) : console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"), r()) : d(new Error(`安装失败 pkg=${f} status=${m} msg=${b}`)));
174
163
  },
175
- onPluginInstallError(g, m, v) {
176
- g === e && (clearTimeout(i), n.removeListener(f), c(new Error(`安装失败 pkg=${g} status=${m} msg=${v}`)));
164
+ onPluginInstallError(f, m, b) {
165
+ f === t && (clearTimeout(e), g.removeListener(s), d(new Error(`安装失败 pkg=${f} status=${m} msg=${b}`)));
177
166
  }
178
167
  };
179
- n.addListener({ pkg: e }, f), i = setTimeout(() => {
180
- n.removeListener(f), c(new Error(`插件安装超时: ${e}`));
181
- }, 8e3), typeof n.installPlugin == "function" ? n.installPlugin({ pkg: e }) : typeof n.install == "function" ? n.install(e) : c(new Error("当前运行时不支持 install / installPlugin"));
182
- }), await L(), A.add(e), s.value = "ready";
183
- } catch (o) {
184
- console.error("[withAsyncPlugin] 插件加载失败:", o), a.value = (o == null ? void 0 : o.message) || String(o), s.value = "error";
168
+ g.addListener({ pkg: t }, s), e = setTimeout(() => {
169
+ g.removeListener(s), d(new Error(`插件安装超时: ${t}`));
170
+ }, 8e3), typeof g.installPlugin == "function" ? g.installPlugin({ pkg: t }) : typeof g.install == "function" ? g.install(t) : d(new Error("当前运行时不支持 install / installPlugin"));
171
+ }), await L(), T.add(t), l.value = "ready";
172
+ } catch (r) {
173
+ console.error("[withAsyncPlugin] 插件加载失败:", r), w.value = (r == null ? void 0 : r.message) || String(r), l.value = "error";
185
174
  }
186
175
  };
187
- return q(() => {
176
+ return R(() => {
188
177
  C();
189
178
  }), () => {
190
- const l = {
179
+ const i = {
191
180
  width: "100%",
192
181
  height: "100%",
193
182
  display: "flex",
194
183
  flexDirection: "column",
195
184
  justifyContent: "center",
196
185
  alignItems: "center",
197
- ...y.style || {}
186
+ ...n.style || {}
198
187
  };
199
- if (s.value === "loading")
200
- return h("div", { class: "qt-plugin-container", style: l }, [
188
+ if (l.value === "loading")
189
+ return h("div", { class: "qt-plugin-container", style: i }, [
201
190
  h("div", { style: { color: "white", fontSize: "30px" } }, "插件加载中...")
202
191
  ]);
203
- if (s.value === "error")
204
- return h("div", { class: "qt-plugin-container", style: l }, [
205
- h("div", { style: { color: "white", fontSize: "30px", backgroundColor: "rgba(255,0,0,0.5)" } }, `插件加载失败: ${a.value}`)
192
+ if (l.value === "error")
193
+ return h("div", { class: "qt-plugin-container", style: i }, [
194
+ h("div", { style: { color: "white", fontSize: "30px", backgroundColor: "rgba(255,0,0,0.5)" } }, `插件加载失败: ${w.value}`)
206
195
  ]);
207
- const o = {};
208
- for (const [c, i] of Object.entries(y))
209
- c.startsWith("on") && typeof i == "function" ? o[c] = (...f) => (console.log(`[withAsyncPlugin] NativeTag=${r} 收到事件 ${c}:`, f), i(...f)) : o[c] = i;
210
- return h("div", { class: "qt-plugin-container", style: l }, [
211
- h(r, {
212
- ...o,
213
- style: { width: "100%", height: "100%", backgroundColor: "transparent" }
214
- }, w.default ? w.default() : [])
196
+ const r = {};
197
+ for (const [e, s] of Object.entries(n)) {
198
+ const f = e.startsWith("on") && e !== "onItemPresence" && e !== "onTabSelected" && e !== "onTabNeedsData" && e !== "onLoadMore" && e !== "onTabFocused" && e !== "onItemClick" && e !== "onItemFocused";
199
+ !e.startsWith("onOn") && !f && (r[e] = s);
200
+ }
201
+ const d = {
202
+ ...r,
203
+ style: { width: "1920px", height: "1080px", backgroundColor: "transparent" },
204
+ onItemPresence: (e) => {
205
+ console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onItemPresence:`, e);
206
+ const s = n.onOnItemPresence || n.onItemPresence || n.onitempresence;
207
+ typeof s == "function" && s(e);
208
+ },
209
+ onTabSelected: (e) => {
210
+ console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onTabSelected:`, e);
211
+ const s = n.onOnTabSelected || n.onTabSelected;
212
+ typeof s == "function" && s(e);
213
+ },
214
+ onTabNeedsData: (e) => {
215
+ console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onTabNeedsData:`, e);
216
+ const s = n.onOnTabNeedsData || n.onTabNeedsData;
217
+ typeof s == "function" && s(e);
218
+ },
219
+ onLoadMore: (e) => {
220
+ console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onLoadMore:`, e);
221
+ const s = n.onOnLoadMore || n.onLoadMore;
222
+ typeof s == "function" && s(e);
223
+ },
224
+ onTabFocused: (e) => {
225
+ console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onTabFocused:`, e);
226
+ const s = n.onOnTabFocused || n.onTabFocused;
227
+ typeof s == "function" && s(e);
228
+ },
229
+ onItemClick: (e) => {
230
+ console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onItemClick:`, e);
231
+ const s = n.onOnItemClick || n.onItemClick;
232
+ typeof s == "function" && s(e);
233
+ },
234
+ onItemFocused: (e) => {
235
+ console.log(`[withAsyncPlugin] NativeTag=${o} 收到事件 onItemFocused:`, e);
236
+ const s = n.onOnItemFocused || n.onItemFocused;
237
+ typeof s == "function" && s(e);
238
+ }
239
+ };
240
+ return console.log("[withAsyncPlugin] 最终准备传递给 h() 的属性键集合:", Object.keys(d)), h("div", { class: "qt-plugin-container", style: i }, [
241
+ h(o, d, c.default ? c.default() : [])
215
242
  ]);
216
243
  };
217
244
  }
218
245
  });
219
246
  }
220
- const K = {
221
- install: (r) => {
222
- r.use(W);
247
+ const B = {
248
+ install: (o) => {
249
+ o.use(Q);
223
250
  }
224
251
  };
225
252
  export {
226
- T as GridTabs,
227
- W as GridTabsPlugin,
228
- K as QuickTVUINAddons,
229
- K as default,
230
- U as useGridItemPresence,
231
- O as withAsyncPlugin
253
+ E as GridTabs,
254
+ Q as GridTabsPlugin,
255
+ B as QuickTVUINAddons,
256
+ B as default,
257
+ z as useGridItemPresence,
258
+ W as withAsyncPlugin
232
259
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicktvui/naddons",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "Vue 3 wrappers for QuickTVUI Native Addons",
5
5
  "main": "dist/naddons.cjs.js",
6
6
  "module": "dist/naddons.es.js",