@quicktvui/naddons 1.0.0-alpha.1 → 1.0.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.
@@ -0,0 +1,42 @@
1
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
2
+ tabsData?: string | undefined;
3
+ actionPayload?: string | undefined;
4
+ }>>, {
5
+ scrollToTop: (...args: any[]) => any;
6
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ onTabSelected: (payload?: any) => void;
8
+ onTabNeedsData: (payload?: any) => void;
9
+ onLoadMore: (payload?: any) => void;
10
+ onItemPresence: (payload?: any) => void;
11
+ onTabFocused: (payload?: any) => void;
12
+ onItemClick: (payload?: any) => void;
13
+ onItemFocused: (payload?: any) => void;
14
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
15
+ tabsData?: string | undefined;
16
+ actionPayload?: string | undefined;
17
+ }>>> & Readonly<{
18
+ onOnTabSelected?: ((payload?: any) => any) | undefined;
19
+ onOnTabNeedsData?: ((payload?: any) => any) | undefined;
20
+ onOnLoadMore?: ((payload?: any) => any) | undefined;
21
+ onOnItemPresence?: ((payload?: any) => any) | undefined;
22
+ onOnTabFocused?: ((payload?: any) => any) | undefined;
23
+ onOnItemClick?: ((payload?: any) => any) | undefined;
24
+ onOnItemFocused?: ((payload?: any) => any) | undefined;
25
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
26
+ default?(_: {}): any;
27
+ }>;
28
+ export default _default;
29
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
30
+ type __VLS_TypePropsToRuntimeProps<T> = {
31
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
32
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
33
+ } : {
34
+ type: import('vue').PropType<T[K]>;
35
+ required: true;
36
+ };
37
+ };
38
+ type __VLS_WithTemplateSlots<T, S> = T & {
39
+ new (): {
40
+ $slots: S;
41
+ };
42
+ };
@@ -0,0 +1,14 @@
1
+ import type { App } from 'vue';
2
+ import GridTabs from './GridTabs.vue';
3
+ export declare const GridTabsPlugin: {
4
+ install: (app: App) => void;
5
+ };
6
+ export { GridTabs };
7
+ export * from './useGridItemPresence';
8
+ export default GridTabsPlugin;
9
+ declare module 'vue' {
10
+ interface GlobalComponents {
11
+ GridTabs: typeof GridTabs;
12
+ 'qt-grid-tabs': typeof GridTabs;
13
+ }
14
+ }
@@ -0,0 +1,26 @@
1
+ export type PresenceState = 'attached' | 'enter' | 'visible' | 'leave';
2
+ export interface PresencePayload {
3
+ itemId: string;
4
+ state: PresenceState;
5
+ index: number;
6
+ }
7
+ export interface UseGridItemPresenceOptions {
8
+ /** 当组件刚刚进入视口时触发 (用于发起网络请求) */
9
+ onEnter?: () => Promise<any> | void;
10
+ /** 当组件完全无遮挡显示时触发 (用于发送曝光埋点) */
11
+ onVisible?: () => void;
12
+ /** 当组件离开视口时触发 (用于取消网络请求或暂停视频) */
13
+ onLeave?: () => void;
14
+ }
15
+ /**
16
+ * 6.15 视图状态反馈与延迟加载协议 - 前端声明式 Hook
17
+ *
18
+ * 用于在 Vue 组件内部响应底层 Native 传来的可见性状态。
19
+ * 使用此 Hook 之前,父组件必须监听 `<GridTabs @onItemPresence="handlePresence">`
20
+ * 并通过 EventBus 或 Provide/Inject 将事件分发到此 Hook。
21
+ */
22
+ export declare function useGridItemPresence(itemId: string, options?: UseGridItemPresenceOptions): {
23
+ isIntersecting: import("vue").Ref<boolean, boolean>;
24
+ isVisible: import("vue").Ref<boolean, boolean>;
25
+ handlePresenceState: (state: PresenceState) => void;
26
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 提供统一的异步插件安装和降级包装器。
3
+ * 这个组件不会被暴露给最终用户,只被 auto-generated 的组件代码调用。
4
+ */
5
+ export declare function withAsyncPlugin(NativeTag: string, pluginPkgName?: string, pluginInitClass?: string): import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
6
+ [key: string]: any;
7
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,14 @@
1
+ export * from './components/GridTabs';
2
+ import { GridTabs } from './components/GridTabs';
3
+ export { withAsyncPlugin } from './core/withAsyncPlugin';
4
+ import { App } from 'vue';
5
+ export declare const QuickTVUINAddons: {
6
+ install: (app: App) => void;
7
+ };
8
+ export default QuickTVUINAddons;
9
+ declare module 'vue' {
10
+ interface GlobalComponents {
11
+ GridTabs: typeof GridTabs;
12
+ 'qt-grid-tabs': typeof GridTabs;
13
+ }
14
+ }
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),_=require("@extscreen/es3-core"),R=require("@extscreen/es3-vue"),w=new Set;function P(r,n,i){return e.defineComponent({name:`${r}AsyncWrapper`,inheritAttrs:!1,setup(c,{slots:v,attrs:m}){const l=e.ref("loading"),A=e.ref("");let d=null,s=null;try{d=_.useES(),s=_.useESPlugin()}catch(t){console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。",t)}const S=async()=>{if(!d||typeof d.isComponentRegistered!="function")return console.log("[withAsyncPlugin] es.isComponentRegistered 不可用"),!1;try{const t=await d.isComponentRegistered(r);return console.log(`[withAsyncPlugin] isComponentRegistered('${r}') 返回:`,t),!!(t===!0||t&&typeof t=="object"&&t.registered===!0)}catch(t){return console.warn("[withAsyncPlugin] 检查组件注册状态异常:",t),!1}},q=async()=>{if(!n){l.value="ready";return}const t=await S();if(console.log(`[withAsyncPlugin] 拦截检查 - ${r} 是否已注册:`,t),t||w.has(n)){l.value="ready",w.add(n),console.log("[withAsyncPlugin] 组件已注册,跳过安装流程");return}if(!s){console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${r}`),l.value="ready";return}console.log(`[withAsyncPlugin] 开始动态安装插件: ${n}`);try{await new Promise((o,g)=>{let y;const f={onPluginInstallSuccess(u,a,h){u===n&&(clearTimeout(y),s.removeListener(f),console.log(`[withAsyncPlugin] 安装成功 pkg=${u} 状态码=${a}`),a==1003?(i?(console.log(`[withAsyncPlugin] 触发反射初始化: ${i}`),R.Native.callNative("EsNativeModule","callReflect",{entry:{from:i,method:"setup"}})):console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"),o()):g(new Error(`安装失败 pkg=${u} status=${a} msg=${h}`)))},onPluginInstallError(u,a,h){u===n&&(clearTimeout(y),s.removeListener(f),g(new Error(`安装失败 pkg=${u} status=${a} msg=${h}`)))}};s.addListener({pkg:n},f),y=setTimeout(()=>{s.removeListener(f),g(new Error(`插件安装超时: ${n}`))},8e3),typeof s.installPlugin=="function"?s.installPlugin({pkg:n}):typeof s.install=="function"?s.install(n):g(new Error("当前运行时不支持 install / installPlugin"))}),await e.nextTick(),w.add(n),l.value="ready"}catch(o){console.error("[withAsyncPlugin] 插件加载失败:",o),A.value=(o==null?void 0:o.message)||String(o),l.value="error"}};return e.onMounted(()=>{q()}),()=>{const t={width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",...m.style||{}};return l.value==="loading"?e.h("div",{class:"qt-plugin-container",style:t},[e.h("div",{style:{color:"white",fontSize:"30px"}},"插件加载中...")]):l.value==="error"?e.h("div",{class:"qt-plugin-container",style:t},[e.h("div",{style:{color:"white",fontSize:"30px",backgroundColor:"rgba(255,0,0,0.5)"}},`插件加载失败: ${A.value}`)]):e.h("div",{class:"qt-plugin-container",style:t},[e.h(r,{...m,style:{width:"100%",height:"100%",backgroundColor:"transparent"}},v)])}}})}const b=e.defineComponent({__name:"GridTabs",setup(r){const n=e.ref(),i=P("qt-grid-tabs","com.quicktvui.plugin.glintui","com.quicktvui.plugin.glintui.GlintPluginApp");return(c,v)=>(e.openBlock(),e.createBlock(e.unref(i),e.mergeProps({ref_key:"nativeRef",ref:n},c.$attrs),{default:e.withCtx(()=>[e.renderSlot(c.$slots,"default")]),_:3},16))}});let p;try{p=require("@extscreen/es3-vue").registerElement}catch{}const $={install:r=>{globalThis.__qt_grid_tabs_registered||p&&(p("qt-grid-tabs",{component:{name:"qt-grid-tabs",processEventData(n,i,c){return{handler:i,nativeEvent:c}}}}),globalThis.__qt_grid_tabs_registered=!0),r.component("GridTabs",b)}},E={install:r=>{r.use($)}};exports.GridTabs=b;exports.GridTabsPlugin=$;exports.QuickTVUINAddons=E;exports.default=E;exports.withAsyncPlugin=P;
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,140 +1,232 @@
1
- import { defineComponent as $, ref as w, onMounted as b, h as u, nextTick as S, openBlock as q, createBlock as R, unref as x, mergeProps as C, withCtx as T, renderSlot as G } from "vue";
2
- import { useES as I, useESPlugin as L } from "@extscreen/es3-core";
3
- import { Native as M } from "@extscreen/es3-vue";
4
- const p = /* @__PURE__ */ new Set();
5
- function V(n, t, s) {
6
- return $({
7
- name: `${n}AsyncWrapper`,
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({
5
+ __name: "GridTabs",
6
+ props: {
7
+ tabsData: {},
8
+ actionPayload: {}
9
+ },
10
+ emits: ["onTabSelected", "onTabNeedsData", "onLoadMore", "onItemPresence", "onTabFocused", "onItemClick", "onItemFocused"],
11
+ setup(r, { expose: e, emit: u }) {
12
+ const d = b(), w = O(
13
+ "QtGridTabs",
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);
25
+ }
26
+ }), (a, t) => (x(), R(G(w), M({
27
+ 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")
41
+ ]),
42
+ _: 3
43
+ }, 16, ["tabsData", "actionPayload"]));
44
+ }
45
+ });
46
+ function U(r, e) {
47
+ const u = b(!1), d = b(!1);
48
+ return {
49
+ isIntersecting: u,
50
+ isVisible: d,
51
+ handlePresenceState: (y) => {
52
+ var s, a, t;
53
+ switch (y) {
54
+ case "enter":
55
+ u.value = !0, (s = e == null ? void 0 : e.onEnter) == null || s.call(e);
56
+ break;
57
+ case "visible":
58
+ d.value = !0, (a = e == null ? void 0 : e.onVisible) == null || a.call(e);
59
+ break;
60
+ case "leave":
61
+ u.value = !1, d.value = !1, (t = e == null ? void 0 : e.onLeave) == null || t.call(e);
62
+ break;
63
+ }
64
+ }
65
+ };
66
+ }
67
+ let E;
68
+ var p;
69
+ try {
70
+ const r = require("@extscreen/es3-vue");
71
+ E = r.registerElement || ((p = r.default) == null ? void 0 : p.registerElement);
72
+ } catch {
73
+ }
74
+ const W = {
75
+ install: (r) => {
76
+ globalThis.__QtGridTabs_registered || (E ? (E("qt-grid-tabs", {
77
+ component: {
78
+ name: "QtGridTabs",
79
+ // 关键:将前端标签映射到真正的 Native 组件名
80
+ processEventData(e, u, d) {
81
+ return {
82
+ handler: u,
83
+ nativeEvent: d
84
+ };
85
+ }
86
+ }
87
+ }), E("QtGridTabs", {
88
+ component: {
89
+ name: "QtGridTabs",
90
+ processEventData(e, u, d) {
91
+ return {
92
+ handler: u,
93
+ nativeEvent: d
94
+ };
95
+ }
96
+ }
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);
98
+ }
99
+ }, A = /* @__PURE__ */ new Set();
100
+ function O(r, e, u) {
101
+ return S({
102
+ name: `${r}AsyncWrapper`,
8
103
  inheritAttrs: !1,
9
- setup(c, { slots: v, attrs: A }) {
10
- const i = w("loading"), _ = w("");
11
- let d = null, r = null;
104
+ setup(d, { slots: w, attrs: y }) {
105
+ const s = b("loading"), a = b("");
106
+ let t = null, n = null;
12
107
  try {
13
- d = I(), r = L();
14
- } catch (e) {
15
- console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。", e);
108
+ t = Q(), n = F();
109
+ } catch (l) {
110
+ console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。", l);
16
111
  }
17
- const E = async () => {
18
- if (!d || typeof d.isComponentRegistered != "function")
112
+ const I = async () => {
113
+ if (!t || typeof t.isComponentRegistered != "function")
19
114
  return console.log("[withAsyncPlugin] es.isComponentRegistered 不可用"), !1;
20
115
  try {
21
- const e = await d.isComponentRegistered(n);
22
- return console.log(`[withAsyncPlugin] isComponentRegistered('${n}') 返回:`, e), !!(e === !0 || e && typeof e == "object" && e.registered === !0);
23
- } catch (e) {
24
- return console.warn("[withAsyncPlugin] 检查组件注册状态异常:", e), !1;
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))
118
+ return !0;
119
+ 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)
133
+ ]);
134
+ if (console.log(`[withAsyncPlugin] ExtendModule.isComponentRegistered 返回: [${m}, ${v}]`), m === !0 || v === !0)
135
+ return !0;
136
+ } else
137
+ console.log(`[withAsyncPlugin] 引擎版本 ${c} < 1.11.205,跳过 ExtendModule 检查`);
138
+ else
139
+ console.log(`[withAsyncPlugin] 无法解析引擎版本号: ${c}`);
140
+ }
141
+ } catch (o) {
142
+ console.log("[withAsyncPlugin] 获取引擎版本或检查 Controller 失败:", o);
143
+ }
144
+ return !1;
145
+ } catch (l) {
146
+ return console.warn("[withAsyncPlugin] 检查组件注册状态异常:", l), !1;
25
147
  }
26
- }, P = async () => {
27
- if (!t) {
28
- i.value = "ready";
148
+ }, C = async () => {
149
+ if (!e) {
150
+ s.value = "ready";
29
151
  return;
30
152
  }
31
- const e = await E();
32
- if (console.log(`[withAsyncPlugin] 拦截检查 - ${n} 是否已注册:`, e), e || p.has(t)) {
33
- i.value = "ready", p.add(t), console.log("[withAsyncPlugin] 组件已注册,跳过安装流程");
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] 组件已注册,跳过安装流程");
34
156
  return;
35
157
  }
36
- if (!r) {
37
- console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${n}`), i.value = "ready";
158
+ if (!n) {
159
+ console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${r}`), s.value = "ready";
38
160
  return;
39
161
  }
40
- console.log(`[withAsyncPlugin] 开始动态安装插件: ${t}`);
162
+ console.log(`[withAsyncPlugin] 开始动态安装插件: ${e}`);
41
163
  try {
42
- await new Promise((l, f) => {
43
- let y;
44
- const g = {
45
- onPluginInstallSuccess(o, a, h) {
46
- o === t && (clearTimeout(y), r.removeListener(g), console.log(`[withAsyncPlugin] 安装成功 pkg=${o} 状态码=${a}`), a == 1003 ? (s ? (console.log(`[withAsyncPlugin] 触发反射初始化: ${s}`), M.callNative("EsNativeModule", "callReflect", {
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", {
47
169
  entry: {
48
- from: s,
170
+ from: u,
49
171
  method: "setup"
50
172
  }
51
- })) : console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"), l()) : f(new Error(`安装失败 pkg=${o} status=${a} msg=${h}`)));
173
+ })) : console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"), o()) : c(new Error(`安装失败 pkg=${g} status=${m} msg=${v}`)));
52
174
  },
53
- onPluginInstallError(o, a, h) {
54
- o === t && (clearTimeout(y), r.removeListener(g), f(new Error(`安装失败 pkg=${o} status=${a} msg=${h}`)));
175
+ onPluginInstallError(g, m, v) {
176
+ g === e && (clearTimeout(i), n.removeListener(f), c(new Error(`安装失败 pkg=${g} status=${m} msg=${v}`)));
55
177
  }
56
178
  };
57
- r.addListener({ pkg: t }, g), y = setTimeout(() => {
58
- r.removeListener(g), f(new Error(`插件安装超时: ${t}`));
59
- }, 8e3), typeof r.installPlugin == "function" ? r.installPlugin({ pkg: t }) : typeof r.install == "function" ? r.install(t) : f(new Error("当前运行时不支持 install / installPlugin"));
60
- }), await S(), p.add(t), i.value = "ready";
61
- } catch (l) {
62
- console.error("[withAsyncPlugin] 插件加载失败:", l), _.value = (l == null ? void 0 : l.message) || String(l), i.value = "error";
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";
63
185
  }
64
186
  };
65
- return b(() => {
66
- P();
187
+ return q(() => {
188
+ C();
67
189
  }), () => {
68
- const e = {
190
+ const l = {
69
191
  width: "100%",
70
192
  height: "100%",
71
193
  display: "flex",
72
194
  flexDirection: "column",
73
195
  justifyContent: "center",
74
196
  alignItems: "center",
75
- ...A.style || {}
197
+ ...y.style || {}
76
198
  };
77
- return i.value === "loading" ? u("div", { class: "qt-plugin-container", style: e }, [
78
- u("div", { style: { color: "white", fontSize: "30px" } }, "插件加载中...")
79
- ]) : i.value === "error" ? u("div", { class: "qt-plugin-container", style: e }, [
80
- u("div", { style: { color: "white", fontSize: "30px", backgroundColor: "rgba(255,0,0,0.5)" } }, `插件加载失败: ${_.value}`)
81
- ]) : u("div", { class: "qt-plugin-container", style: e }, [
82
- u(n, {
83
- ...A,
199
+ if (s.value === "loading")
200
+ return h("div", { class: "qt-plugin-container", style: l }, [
201
+ h("div", { style: { color: "white", fontSize: "30px" } }, "插件加载中...")
202
+ ]);
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}`)
206
+ ]);
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,
84
213
  style: { width: "100%", height: "100%", backgroundColor: "transparent" }
85
- }, v)
214
+ }, w.default ? w.default() : [])
86
215
  ]);
87
216
  };
88
217
  }
89
218
  });
90
219
  }
91
- const z = /* @__PURE__ */ $({
92
- __name: "GridTabs",
93
- setup(n) {
94
- const t = w(), s = V(
95
- "qt-grid-tabs",
96
- "com.quicktvui.plugin.glintui",
97
- "com.quicktvui.plugin.glintui.GlintPluginApp"
98
- );
99
- return (c, v) => (q(), R(x(s), C({
100
- ref_key: "nativeRef",
101
- ref: t
102
- }, c.$attrs), {
103
- default: T(() => [
104
- G(c.$slots, "default")
105
- ]),
106
- _: 3
107
- }, 16));
108
- }
109
- });
110
- let m;
111
- try {
112
- m = require("@extscreen/es3-vue").registerElement;
113
- } catch {
114
- }
115
- const B = {
116
- install: (n) => {
117
- globalThis.__qt_grid_tabs_registered || m && (m("qt-grid-tabs", {
118
- component: {
119
- name: "qt-grid-tabs",
120
- processEventData(t, s, c) {
121
- return {
122
- handler: s,
123
- nativeEvent: c
124
- };
125
- }
126
- }
127
- }), globalThis.__qt_grid_tabs_registered = !0), n.component("GridTabs", z);
128
- }
129
- }, Q = {
130
- install: (n) => {
131
- n.use(B);
220
+ const K = {
221
+ install: (r) => {
222
+ r.use(W);
132
223
  }
133
224
  };
134
225
  export {
135
- z as GridTabs,
136
- B as GridTabsPlugin,
137
- Q as QuickTVUINAddons,
138
- Q as default,
139
- V as withAsyncPlugin
226
+ T as GridTabs,
227
+ W as GridTabsPlugin,
228
+ K as QuickTVUINAddons,
229
+ K as default,
230
+ U as useGridItemPresence,
231
+ O as withAsyncPlugin
140
232
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicktvui/naddons",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Vue 3 wrappers for QuickTVUI Native Addons",
5
5
  "main": "dist/naddons.cjs.js",
6
6
  "module": "dist/naddons.es.js",
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "scripts": {
12
12
  "dev": "vite build --watch",
13
- "build": "vue-tsc --emitDeclarationOnly && vite build",
13
+ "build": "rm -rf dist && vue-tsc --emitDeclarationOnly && vite build",
14
14
  "prepublishOnly": "npm run build"
15
15
  },
16
16
  "peerDependencies": {