@quicktvui/naddons 1.0.0-alpha.4 → 1.0.0-alpha.6
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/components/DatePicker/DatePicker.vue.d.ts +28 -0
- package/dist/components/DatePicker/index.d.ts +13 -0
- package/dist/components/GridTabs/GridTabs.vue.d.ts +7 -1
- package/dist/components/GridTabs/PortalItem.vue.d.ts +26 -0
- package/dist/components/GridTabs/PortalPool.vue.d.ts +2 -0
- package/dist/components/GridTabs/index.d.ts +1 -1
- package/dist/components/GridTabs/useGridTabs.d.ts +91 -0
- package/dist/components/GridTabs/useGridTabsData.d.ts +20 -0
- package/dist/components/GridTabs/useGridTabsUpdater.d.ts +24 -0
- package/dist/components/Keyboard/Keyboard.vue.d.ts +50 -0
- package/dist/components/Keyboard/index.d.ts +13 -0
- package/dist/components/NumericKeyboard/NumericKeyboard.vue.d.ts +28 -0
- package/dist/components/NumericKeyboard/index.d.ts +13 -0
- package/dist/components/PortalItem/PortalItem.vue.d.ts +24 -0
- package/dist/components/PortalItem/index.d.ts +13 -0
- package/dist/components/PortalPool/PortalPool.vue.d.ts +11 -0
- package/dist/components/PortalPool/index.d.ts +13 -0
- package/dist/components/RatingBar/RatingBar.vue.d.ts +34 -0
- package/dist/components/RatingBar/index.d.ts +13 -0
- package/dist/core/AddonProvider.d.ts +34 -0
- package/dist/core/withAsyncPlugin.d.ts +17 -2
- package/dist/index.d.ts +28 -2
- package/dist/naddons.cjs.js +1 -1
- package/dist/naddons.es.js +706 -182
- package/package.json +3 -1
package/dist/naddons.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),x=require("@extscreen/es3-vue"),Q=require("@extscreen/es3-core"),Z="QtGridTabs",D=l.defineComponent({__name:"GridTabs",props:{protocolVersion:{},tabsData:{},actionPayload:{}},emits:["onTabSelected","onTabNeedsData","onLoadMore","onItemPresence","onTabFocused","onItemClick","onItemFocused","onProtocolMismatch"],setup(o,{expose:r}){const u=l.ref(),g=O(),f=Z+"_Plugin",a=(g.isPluginActive?f:Z).replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase().replace(/^-/,""),b=C(a,g.pluginPackageName||"com.quicktvui.plugin.glintui");return r({getNativeNode:()=>{var s,c;return((c=(s=u.value)==null?void 0:s.getNativeNode)==null?void 0:c.call(s))||u.value},dispatchAction:(...s)=>{var v,$;const c=(($=(v=u.value)==null?void 0:v.getNativeNode)==null?void 0:$.call(v))||u.value;c&&x.Native.callUIFunction(c,"dispatchAction",s)},scrollToTop:(...s)=>{var v,$;const c=(($=(v=u.value)==null?void 0:v.getNativeNode)==null?void 0:$.call(v))||u.value;c&&x.Native.callUIFunction(c,"scrollToTop",s)}}),(s,c)=>(l.openBlock(),l.createBlock(l.unref(b),l.mergeProps({ref_key:"nativeRef",ref:u,protocolVersion:o.protocolVersion,tabsData:o.tabsData,actionPayload:o.actionPayload,onOnTabSelected:c[0]||(c[0]=v=>s.$emit("onTabSelected",v.nativeEvent)),onOnTabNeedsData:c[1]||(c[1]=v=>s.$emit("onTabNeedsData",v.nativeEvent)),onOnLoadMore:c[2]||(c[2]=v=>s.$emit("onLoadMore",v.nativeEvent)),onOnItemPresence:c[3]||(c[3]=v=>s.$emit("onItemPresence",v.nativeEvent)),onOnTabFocused:c[4]||(c[4]=v=>s.$emit("onTabFocused",v.nativeEvent)),onOnItemClick:c[5]||(c[5]=v=>s.$emit("onItemClick",v.nativeEvent)),onOnItemFocused:c[6]||(c[6]=v=>s.$emit("onItemFocused",v.nativeEvent)),onOnProtocolMismatch:c[7]||(c[7]=v=>s.$emit("onProtocolMismatch",v.nativeEvent))},s.$attrs),{default:l.withCtx(()=>[l.renderSlot(s.$slots,"default")]),_:3},16,["protocolVersion","tabsData","actionPayload"]))}});let F;var X;try{const o=require("@extscreen/es3-vue");F=o.registerElement||((X=o.default)==null?void 0:X.registerElement)}catch{}const oe={install:o=>{if(!globalThis.__QtGridTabs_registered)if(F){const r=(u,g)=>{F(u,{component:{name:g?"QtGridTabs_Plugin":"QtGridTabs",processEventData(f,y){const a=f.handler||f,b=y||(a==null?void 0:a.nativeParams)||{};return a&&(a.nativeEvent=b),a}}})};r("qt-grid-tabs",!1),r("qt-grid-tabs-plugin",!0),r("QtGridTabs",!1),r("QtGridTabs_Plugin",!0),r("gt-tabs",!1),r("gt-tabs-plugin",!0),globalThis.__QtGridTabs_registered=!0,console.log("[@quicktvui/naddons] Successfully registered Native tag:","QtGridTabs")}else console.warn("[@quicktvui/naddons] Failed to find registerElement from @extscreen/es3-vue");o.component("GridTabs",D),o.component("qt-grid-tabs",D),o.component("gt-tabs",D)}};function de(o,r){const u=l.ref(""),g=l.shallowRef([]),f=l.shallowRef([]);let y=!1,a=!1;const b="__virtual_single_tab__",s=l.ref({}),c=e=>{const t=Array.isArray(e)?e:[e],n=JSON.stringify(t);if(a&&o.value){if(typeof o.value.dispatchAction=="function"){console.log("[useGridTabs] Calling Wrapper dispatchAction directly"),o.value.dispatchAction(n);return}let i=o.value;typeof o.value.getNativeNode=="function"?i=o.value.getNativeNode()||o.value:o.value.nativeRef&&(i=o.value.nativeRef),i?(console.log("[useGridTabs] Calling Native.callUIFunction(dispatchAction)"),x.Native.callUIFunction(i,"dispatchAction",[n])):console.warn("[useGridTabs] Native target is null or undefined, cannot call dispatchAction")}},v=(e,t)=>{if(!e)return!1;let n=!0;return e.id||(console.error(`[useGridTabs] ❌ 数据格式错误 (${t}): 卡片缺失必填字段 'id'。每个卡片必须有唯一标识才能进行后续更新!`,e),n=!1),e.viewType||(console.error(`[useGridTabs] ❌ 数据格式错误 (${t}): 卡片缺失必填字段 'viewType' (id: ${e.id||"未知"})。必须指定 Native 注册的视图类型或 Portal 标识!`,e),n=!1),n},$=(e,t)=>{if(!e)return!1;let n=!0;return e.tabId||(console.error(`[useGridTabs] ❌ 数据格式错误 (${t}): Tab 缺失必填字段 'tabId'。每个 Tab 必须有唯一标识!`,e),n=!1),(e.title===void 0||e.title===null)&&console.warn(`[useGridTabs] ⚠️ 数据格式警告 (${t}): Tab 缺失 'title' 字段 (tabId: ${e.tabId||"未知"}),导航栏可能显示为空。`,e),n},R=(e,t)=>{if(!e||e.length===0)return;k.clear();const n=e[0].hasOwnProperty("tabId")||e[0].hasOwnProperty("items")&&Array.isArray(e[0].items);y=t==="1d",t==="1d"&&n?console.error("[useGridTabs] ❌ 赋值错误: 你正在向 `items.value` (一维瀑布流) 赋值二维 Tabs 数据结构!请改用 `tabs.value = ...`"):t==="2d"&&!n&&console.error("[useGridTabs] ❌ 赋值错误: 你正在向 `tabs.value` (二维导航) 赋值一维卡片列表数据结构!请改用 `items.value = ...`"),t==="1d"?e.forEach((i,d)=>v(i,`items.value[${d}]`)):e.forEach((i,d)=>{$(i,`tabs.value[${d}]`),i.items&&Array.isArray(i.items)&&i.items.forEach((p,P)=>v(p,`tabs.value[${d}].items[${P}]`))}),a=!0,h()},k=new Set,h=(e="unknown")=>{if(!a){console.warn("[useGridTabs] triggerRootUpdate skipped because isInitialized is false");return}let t={gridBasis:(r==null?void 0:r.gridBasis)??30,unitType:(r==null?void 0:r.unitType)??"px",contentConfig:(r==null?void 0:r.contentConfig)??(r==null?void 0:r.layoutConfig)??{padding:[0,60,60,60],navContentGapNormal:0,itemGap:24},navConfig:(r==null?void 0:r.navConfig)??{dock:"left",mode:"fixed",renderType:"smart-hybrid",box:{size:[200,0]},expandedBox:{size:[300,0]}},cacheConfig:(r==null?void 0:r.cacheConfig)??{offscreenPageLimit:1,prefetchOffset:2,resetOnSwitch:!0},animationConfig:(r==null?void 0:r.animationConfig)??{duration:250,layoutEntrance:"staggered_slide_up",itemUpdate:"fade_cross"},focusConfig:(r==null?void 0:r.focusConfig)??{defaultFocus:"content",restoreLastFocus:!0},referenceResolution:(r==null?void 0:r.referenceResolution)??{w:1920,h:1080}},n=[];y?(t.navConfig={...t.navConfig,renderType:"none"},n=[{tabId:b,title:"Virtual Tab",hidden:!0,items:f.value}]):n=g.value;const i=JSON.stringify({page_spec:t,tabs:n});u.value===""?(console.log(`[useGridTabs] triggerRootUpdate: Initializing tabsDataStr (length=${i.length})`),u.value=i):(console.log(`[useGridTabs] triggerRootUpdate: Sending RELOAD_TABS action directly to Native (length=${i.length})`),u.value=i,c({op:"RELOAD_TABS",payload:{pageSpec:t,page_spec:t,tabs:n}}))},G=e=>!e||typeof e!="object"||e.__isGridTabsProxy?e:(e.content&&typeof e.content=="object"&&!e.content.__isGridTabsProxy&&(e.content=new Proxy(e.content,{set(t,n,i,d){const p=Reflect.set(t,n,i,d);return e.id&&a&&c({op:"UPDATE_ITEM",itemId:e.id,payload:e}),p}}),Object.defineProperty(e.content,"__isGridTabsProxy",{value:!0,enumerable:!1})),new Proxy(e,{set(t,n,i,d){const p=Reflect.set(t,n,i,d);return t.id&&a&&c({op:"UPDATE_ITEM",itemId:t.id,payload:t}),p}})),S=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=G(e[n]);return new Proxy(e,{get(n,i,d){return i==="push"?(...p)=>{p.forEach((M,ue)=>v(M,`push(${ue})`)),a||console.error("[useGridTabs] ❌ 时机错误: 在底层还未完成初始化时调用了 push()。请先对 items.value 或 tabs.value 进行全量赋值!");const P=p.map(M=>G(M)),_=Array.prototype.push.apply(n,P);return c({op:"APPEND_SUB_ITEMS",itemId:t,payload:{subItems:P}}),_}:Reflect.get(n,i,d)},set(n,i,d,p){if(i!=="length"&&!isNaN(Number(i))){a||console.error(`[useGridTabs] ❌ 时机错误: 在底层还未完成初始化时直接修改了索引 [${String(i)}]。请先对 items.value 或 tabs.value 进行全量赋值!`),v(d,`索引赋值 [${String(i)}]`);const P=G(d),_=Reflect.set(n,i,P,p);return P&&P.id&&c({op:"UPDATE_ITEM",itemId:P.id,payload:P}),_}return Reflect.set(n,i,d,p)}})},m=e=>(e.items&&Array.isArray(e.items)&&!e.items.__isGridTabsProxy&&(e.items=S(e.items,e.tabId),Object.defineProperty(e.items,"__isGridTabsProxy",{value:!0,enumerable:!1})),new Proxy(e,{set(t,n,i,d){if(n==="items"){let p=i;Array.isArray(i)&&!i.__isGridTabsProxy&&(p=S(i,t.tabId),Object.defineProperty(p,"__isGridTabsProxy",{value:!0,enumerable:!1}));const P=Reflect.set(t,n,p,d);return h(),P}return Reflect.set(t,n,i,d)}})),T=e=>{const t=e.map(n=>m(n));return new Proxy(t,{set(n,i,d,p){if(i!=="length"&&!isNaN(Number(i))){let P=d;d.__isGridTabsProxy||(P=m(d),Object.defineProperty(P,"__isGridTabsProxy",{value:!0,enumerable:!1}));const _=Reflect.set(n,i,P,p);return h(),_}return Reflect.set(n,i,d,p)}})};l.watch(g,(e,t)=>{if(console.log("[useGridTabs] watch(tabs) triggered:",{newTabs:e,isInitialized:a}),!e||e.length===0){u.value="",a=!1;return}if(e.__isGridTabsProxy)console.log("[useGridTabs] newTabs is ALREADY a proxy, triggering root update"),h();else{console.log("[useGridTabs] newTabs is NOT a proxy, performing full deduceModeAndInitialize & wrapping"),R(e,"2d");const n=T(e);Object.defineProperty(n,"__isGridTabsProxy",{value:!0,enumerable:!1}),g.value=n,h()}},{flush:"sync"}),l.watch(f,(e,t)=>{if(console.log("[useGridTabs] watch(items) triggered:",{newItems:e,isInitialized:a}),!e||e.length===0){u.value="",a=!1;return}if(e.__isGridTabsProxy)console.log("[useGridTabs] newItems is ALREADY a proxy, triggering root update"),h();else{console.log("[useGridTabs] newItems is NOT a proxy, performing full deduceModeAndInitialize & wrapping"),R(e,"1d");const n=S(e,b);Object.defineProperty(n,"__isGridTabsProxy",{value:!0,enumerable:!1}),f.value=n,h()}},{flush:"sync"});const E=()=>{console.log("[useGridTabs] resetInitialization called manually"),a=!1,u.value=""},A=e=>{if(!e||e.length===0){u.value="",a=!1;return}e[0].hasOwnProperty("tabId")||e[0].hasOwnProperty("items")&&Array.isArray(e[0].items)?g.value=e:f.value=e},I=e=>{s.value=e},N=l.computed(()=>({tabsData:u.value,onTabNeedsData:async(...e)=>{let t=e[0];if(t&&t.nativeEvent&&(t=t.nativeEvent),!s.value.onTabNeedsData)return;const{tabId:n,index:i,reason:d}=t;if(k.has(n)){console.log(`[useGridTabs] onTabNeedsData SKIP: tabId=${n} 已经发起过请求,防止死循环`);return}k.add(n);try{const p=await s.value.onTabNeedsData(n,i,d);if(p&&Array.isArray(p)){const P=g.value.find(_=>_.tabId===n);P&&(P.items=p)}}catch(p){console.error("[useGridTabs] onTabNeedsData 执行失败:",p),k.delete(n)}},onLoadMore:async(...e)=>{let t=e[0];if(t&&t.nativeEvent&&(t=t.nativeEvent),!s.value.onLoadMore)return;const{tabId:n,cursor:i,itemId:d}=t,p=await s.value.onLoadMore(n,i,d);if(p&&Array.isArray(p)&&p.length>0)if(y)f.value.push(...p);else{const P=g.value.find(_=>_.tabId===n);P&&P.items&&P.items.push(...p)}},onItemPresence:(...e)=>{let t=e[0];if(console.log("[useGridTabs] ⚡️ bindings caught onItemPresence:",t),s.value.onItemPresence)try{let n=typeof t=="string"?t:(t==null?void 0:t.nativeEvent)||t;n&&typeof n.data=="string"&&(n=n.data);const i=typeof n=="string"?JSON.parse(n):n;i&&i.type==="VIEW_PRESENCE_BATCH"&&Array.isArray(i.payload)?i.payload.forEach(d=>{d.itemId&&typeof d.itemId=="string"&&d.itemId.startsWith("fallback_pos_")&&console.warn(`[useGridTabs] ⚠️ 警告:检测到列表项曝光 (index=${d.index}),但未配置 itemId。请检查传入的 items 数组,务必为每个数据项指定唯一的 itemId,否则底层无法准确进行去重与曝光上报。`),s.value.onItemPresence(d)}):s.value.onItemPresence(i)}catch(n){console.error("[useGridTabs] Failed to parse onItemPresence event payload:",n),s.value.onItemPresence(t)}},onTabSelected:(...e)=>{let t=e[0];t&&t.nativeEvent&&(t=t.nativeEvent),s.value.onTabSelected&&s.value.onTabSelected(t)},onItemClick:(...e)=>{let t=e[0];if(console.log("[useGridTabs] RAW onItemClick intercepted from Native:",t),t&&t.nativeEvent&&(t=t.nativeEvent),s.value.onItemClick)try{let n=typeof t=="string"?t:(t==null?void 0:t.data)||t;console.log("[useGridTabs] Parsed eventStr:",n);const i=typeof n=="string"?JSON.parse(n):n;s.value.onItemClick(i)}catch(n){console.error("[useGridTabs] Failed to parse onItemClick event payload:",n),s.value.onItemClick(t)}else console.warn("[useGridTabs] onItemClick triggered but NO callback registered in callbacksRef!")},onItemFocused:(...e)=>{let t=e[0];if(t&&t.nativeEvent&&(t=t.nativeEvent),s.value.onItemFocused)try{let n=typeof t=="string"?t:(t==null?void 0:t.data)||t;const i=typeof n=="string"?JSON.parse(n):n;s.value.onItemFocused(i)}catch(n){console.error("[useGridTabs] Failed to parse onItemFocused event payload:",n),s.value.onItemFocused(t)}},onTabFocused:(...e)=>{let t=e[0];t&&t.nativeEvent&&(t=t.nativeEvent),s.value.onTabFocused&&s.value.onTabFocused(t)}}));return{tabsDataStr:u,bindings:N,tabs:g,items:f,initData:A,setCallbacks:I,updateItem:(e,t)=>{if(!a){console.error("[useGridTabs] ❌ 时机错误: 尚未初始化数据,无法调用 updateItem");return}c({op:"UPDATE_ITEM",itemId:e,payload:t});const n=i=>{for(const d in t)d==="content"&&i.content?Object.assign(i.content,t.content):i[d]=t[d]};if(y){const i=f.value.find(d=>d.id===e);i&&n(i)}else for(const i of g.value)if(i.items){const d=i.items.find(p=>p.id===e);if(d){n(d);break}}},dispatchAction:c,resetInitialization:E}}const J="QtKeyboard",L=l.defineComponent({__name:"Keyboard",props:{backgroundColor:{},textColor:{},weakTextColor:{},focusBackgroundColor:{},focusTextColor:{},placeholder:{},textFullKeyboard:{},textT9Keyboard:{},textClear:{},textDelete:{},currentInput:{}},emits:["onInputChanged","onKeyPressed"],setup(o,{expose:r}){const u=l.ref(),g=O(),f=J+"_Plugin",a=(g.isPluginActive?f:J).replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase().replace(/^-/,""),b=C(a,g.pluginPackageName||"com.quicktvui.plugin.extraui","com.quicktvui.plugin.extraui.ExtraUIPluginApp");return r({getNativeNode:()=>{var s,c;return((c=(s=u.value)==null?void 0:s.getNativeNode)==null?void 0:c.call(s))||u.value}}),(s,c)=>(l.openBlock(),l.createBlock(l.unref(b),l.mergeProps({ref_key:"nativeRef",ref:u,backgroundColor:o.backgroundColor,textColor:o.textColor,weakTextColor:o.weakTextColor,focusBackgroundColor:o.focusBackgroundColor,focusTextColor:o.focusTextColor,placeholder:o.placeholder,textFullKeyboard:o.textFullKeyboard,textT9Keyboard:o.textT9Keyboard,textClear:o.textClear,textDelete:o.textDelete,currentInput:o.currentInput,onOnInputChanged:c[0]||(c[0]=v=>s.$emit("onInputChanged",v.nativeEvent)),onOnKeyPressed:c[1]||(c[1]=v=>s.$emit("onKeyPressed",v.nativeEvent))},s.$attrs),{default:l.withCtx(()=>[l.renderSlot(s.$slots,"default")]),_:3},16,["backgroundColor","textColor","weakTextColor","focusBackgroundColor","focusTextColor","placeholder","textFullKeyboard","textT9Keyboard","textClear","textDelete","currentInput"]))}});let K;var ee;try{const o=require("@extscreen/es3-vue");K=o.registerElement||((ee=o.default)==null?void 0:ee.registerElement)}catch{}const se={install:o=>{if(!globalThis.__QtKeyboard_registered)if(K){const r=(u,g)=>{K(u,{component:{name:g?"QtKeyboard_Plugin":"QtKeyboard",processEventData(f,y){const a=f.handler||f,b=y||(a==null?void 0:a.nativeParams)||{};return a&&(a.nativeEvent=b),a}}})};r("qt-keyboard",!1),r("qt-keyboard-plugin",!0),r("QtKeyboard",!1),r("QtKeyboard_Plugin",!0),globalThis.__QtKeyboard_registered=!0,console.log("[@quicktvui/naddons] Successfully registered Native tag:","QtKeyboard")}else console.warn("[@quicktvui/naddons] Failed to find registerElement from @extscreen/es3-vue");o.component("Keyboard",L),o.component("qt-keyboard",L)}},Y="QtPortalPool",U=l.defineComponent({__name:"PortalPool",setup(o,{expose:r}){const u=l.ref(),g=O(),f=Y+"_Plugin",a=(g.isPluginActive?f:Y).replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase().replace(/^-/,""),b=C(a,g.pluginPackageName||"com.quicktvui.plugin.glintui");return r({getNativeNode:()=>{var s,c;return((c=(s=u.value)==null?void 0:s.getNativeNode)==null?void 0:c.call(s))||u.value}}),(s,c)=>(l.openBlock(),l.createBlock(l.unref(b),l.mergeProps({ref_key:"nativeRef",ref:u},s.$attrs),{default:l.withCtx(()=>[l.renderSlot(s.$slots,"default")]),_:3},16))}});let B;var te;try{const o=require("@extscreen/es3-vue");B=o.registerElement||((te=o.default)==null?void 0:te.registerElement)}catch{}const re={install:o=>{if(!globalThis.__QtPortalPool_registered)if(B){const r=(u,g)=>{B(u,{component:{name:g?"QtPortalPool_Plugin":"QtPortalPool",processEventData(f,y){const a=f.handler||f,b=y||(a==null?void 0:a.nativeParams)||{};return a&&(a.nativeEvent=b),a}}})};r("qt-portal-pool",!1),r("qt-portal-pool-plugin",!0),r("QtPortalPool",!1),r("QtPortalPool_Plugin",!0),globalThis.__QtPortalPool_registered=!0,console.log("[@quicktvui/naddons] Successfully registered Native tag:","QtPortalPool")}else console.warn("[@quicktvui/naddons] Failed to find registerElement from @extscreen/es3-vue");o.component("PortalPool",U),o.component("qt-portal-pool",U)}},H="QtPortalItem",V=l.defineComponent({__name:"PortalItem",props:{portalId:{}},setup(o,{expose:r}){const u=l.ref(),g=O(),f=H+"_Plugin",a=(g.isPluginActive?f:H).replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase().replace(/^-/,""),b=C(a,g.pluginPackageName||"com.quicktvui.plugin.glintui");return r({getNativeNode:()=>{var s,c;return((c=(s=u.value)==null?void 0:s.getNativeNode)==null?void 0:c.call(s))||u.value}}),(s,c)=>(l.openBlock(),l.createBlock(l.unref(b),l.mergeProps({ref_key:"nativeRef",ref:u,portalId:o.portalId},s.$attrs),{default:l.withCtx(()=>[l.renderSlot(s.$slots,"default")]),_:3},16,["portalId"]))}});let j;var ne;try{const o=require("@extscreen/es3-vue");j=o.registerElement||((ne=o.default)==null?void 0:ne.registerElement)}catch{}const ie={install:o=>{if(!globalThis.__QtPortalItem_registered)if(j){const r=(u,g)=>{j(u,{component:{name:g?"QtPortalItem_Plugin":"QtPortalItem",processEventData(f,y){const a=f.handler||f,b=y||(a==null?void 0:a.nativeParams)||{};return a&&(a.nativeEvent=b),a}}})};r("qt-portal-item",!1),r("qt-portal-item-plugin",!0),r("QtPortalItem",!1),r("QtPortalItem_Plugin",!0),globalThis.__QtPortalItem_registered=!0,console.log("[@quicktvui/naddons] Successfully registered Native tag:","QtPortalItem")}else console.warn("[@quicktvui/naddons] Failed to find registerElement from @extscreen/es3-vue");o.component("PortalItem",V),o.component("qt-portal-item",V)}},ae={skipPluginCheck:!1},q=new Set;function C(o,r,u){return l.defineComponent({name:`${o}AsyncWrapper`,inheritAttrs:!1,props:{skipPluginCheck:{type:Boolean,default:!1}},setup(g,{slots:f,attrs:y,expose:a}){const b=l.ref("loading"),s=l.ref(""),c=l.ref(),v=globalThis.__VUE_INSTANCE__;a({getNativeNode:()=>{let m=c.value;return!m&&v&&v.vnode&&v.vnode.el&&(m=v.vnode.el,m.childNodes&&m.childNodes.length>0&&(m=m.childNodes[0])),m},nativeRef:c});let k=null,h=null;try{k=Q.useES(),h=Q.useESPlugin()}catch(m){console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。",m)}const G=async()=>{if(!k||typeof k.isComponentRegistered!="function")return console.log("[withAsyncPlugin] es.isComponentRegistered 不可用"),!1;try{const m=await k.isComponentRegistered(o);if(console.log(`[withAsyncPlugin] isComponentRegistered('${o}') 返回:`,m),m===!0||m&&typeof m=="object"&&(m.registered===!0||m.isRegistered===!0))return!0;try{const T=await x.Native.callNativeWithPromise("ExtendModule","getCoreSDKInfo");if(T&&T.core_version){const E=T.core_version;console.log(`[withAsyncPlugin] 当前引擎核心版本: ${E}`);const A=E.split(".").map(I=>parseInt(I,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: ${o}`);const N=o.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("");console.log(`[withAsyncPlugin] 同时检查原名和驼峰名: ${o}, ${N}`);const[w,e]=await Promise.all([x.Native.callNativeWithPromise("ExtendModule","isComponentRegistered",o).catch(()=>!1),x.Native.callNativeWithPromise("ExtendModule","isComponentRegistered",N).catch(()=>!1)]);if(console.log(`[withAsyncPlugin] ExtendModule.isComponentRegistered 返回: [${w}, ${e}]`),w===!0||e===!0)return!0}else console.log(`[withAsyncPlugin] 引擎版本 ${E} < 1.11.205,跳过 ExtendModule 检查`);else console.log(`[withAsyncPlugin] 无法解析引擎版本号: ${E}`)}}catch(T){console.log("[withAsyncPlugin] 获取引擎版本或检查 Controller 失败:",T)}return!1}catch(m){return console.warn("[withAsyncPlugin] 检查组件注册状态异常:",m),!1}},S=async()=>{if(ae.skipPluginCheck||g.skipPluginCheck){console.log(`[withAsyncPlugin] 跳过 ${o} 插件检查 (skipPluginCheck = true)`),b.value="ready";return}if(!r){b.value="ready";return}const m=await G();if(console.log(`[withAsyncPlugin] 拦截检查 - ${o} 是否已注册:`,m),m||q.has(r)){b.value="ready",q.add(r),console.log("[withAsyncPlugin] 组件已注册,跳过安装流程");return}if(!h){console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${o}`),b.value="ready";return}console.log(`[withAsyncPlugin] 开始动态安装插件: ${r}`);try{await new Promise((T,E)=>{let A;const I={onPluginInstallSuccess(N,w,e){N===r&&(clearTimeout(A),h.removeListener(I),console.log(`[withAsyncPlugin] 安装成功 pkg=${N} 状态码=${w}`),w==1003||w==1001?(u?(console.log(`[withAsyncPlugin] 触发反射初始化: ${u}`),x.Native.callNative("EsNativeModule","callReflect",{entry:{from:u,method:"setup"}})):console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"),T()):E(new Error(`安装失败 pkg=${N} status=${w} msg=${e}`)))},onPluginInstallError(N,w,e){N===r&&(clearTimeout(A),h.removeListener(I),E(new Error(`安装失败 pkg=${N} status=${w} msg=${e}`)))}};h.addListener({pkg:r},I),A=setTimeout(()=>{h.removeListener(I),E(new Error(`插件安装超时: ${r}`))},8e3),typeof h.installPlugin=="function"?h.installPlugin({pkg:r}):typeof h.install=="function"?h.install(r):E(new Error("当前运行时不支持 install / installPlugin"))}),await l.nextTick(),q.add(r),b.value="ready"}catch(T){console.error("[withAsyncPlugin] 插件加载失败:",T),s.value=(T==null?void 0:T.message)||String(T),b.value="error"}};return l.onMounted(()=>{S()}),()=>{const m={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",...y.style||{}},T=y.class?`qt-plugin-container ${y.class}`:"qt-plugin-container";if(b.value==="loading")return l.h("div",{class:T,style:m},[l.h("div",{style:{color:"white",fontSize:"30px"}},"插件加载中...")]);if(b.value==="error")return l.h("div",{class:T,style:m},[l.h("div",{style:{color:"white",fontSize:"30px",backgroundColor:"rgba(255,0,0,0.5)"}},`插件加载失败: ${s.value}`)]);const E={},A={};for(const[e,t]of Object.entries(y))if(!(e==="class"||e==="style"))if(e.startsWith("on")&&typeof t=="function"){let n=e;e.startsWith("onOn")&&(n="on"+e.slice(4)),A[n]=t}else if(e.startsWith("on")&&Array.isArray(t)){let n=e;e.startsWith("onOn")&&(n="on"+e.slice(4)),A[n]=t}else e.startsWith("onOn")||(E[e]=t);const I={...E,...A,ref:e=>{c.value=e},style:{width:"100%",height:"100%",backgroundColor:"transparent"}},N=I.tabsData||"",w=I.actionPayload||"";return console.log("[withAsyncPlugin] 最终准备传递给 h() 的属性键集合:",Object.keys(I),"tabsData.length=",N.length,"actionPayload.length=",w.length),l.h("div",{class:T,style:m},[l.h(o,I,f.default?f.default():[])])}}})}const W=Symbol("AddonEnvContext"),le={isPluginActive:!1,nameSuffix:"",pluginPackageName:"com.quicktvui.plugin.glintui",builtInVersions:{}};async function ve(o="com.quicktvui.plugin.glintui",r="_Plugin"){const u=Q.useES();let g={};try{const s=await x.Native.callNativeModule("AddonEnvModule","getBuiltInVersions",[]);s&&typeof s=="object"&&(g=s)}catch(s){console.warn("[AddonProvider] Failed to fetch built-in versions from AddonEnvModule",s)}const f=`QtGridTabs${r}`,y=u.isComponentRegistered(f),a=y instanceof Promise?await y:y,b={isPluginActive:a,nameSuffix:a?r:"",pluginPackageName:a?`${o}.ext`:o,builtInVersions:g};return console.info("[AddonProvider] Environment initialized:",b),b}let z=l.ref(le);function ge(o){z.value=o,l.provide(W,z)}function O(){var o;return((o=l.inject(W,z))==null?void 0:o.value)||le}const ce={install:o=>{o.use(oe),o.use(se),o.use(re),o.use(ie)}};exports.ADDON_ENV_CONTEXT_KEY=W;exports.GridTabs=D;exports.GridTabsPlugin=oe;exports.Keyboard=L;exports.KeyboardPlugin=se;exports.PortalItem=V;exports.PortalItemPlugin=ie;exports.PortalPool=U;exports.PortalPoolPlugin=re;exports.QuickTVUINAddons=ce;exports.QuickTVUINAddonsConfig=ae;exports.default=ce;exports.initAddonEnv=ve;exports.provideAddonEnv=ge;exports.useAddonEnv=O;exports.useGridTabs=de;exports.withAsyncPlugin=C;
|