@quicktvui/naddons 1.0.0-alpha.1 → 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.
- package/dist/components/GridTabs/GridTabs.vue.d.ts +42 -0
- package/dist/components/GridTabs/index.d.ts +14 -0
- package/dist/components/GridTabs/useGridItemPresence.d.ts +26 -0
- package/dist/core/withAsyncPlugin.d.ts +7 -0
- package/dist/index.d.ts +14 -0
- package/dist/naddons.cjs.js +1 -1
- package/dist/naddons.es.js +218 -99
- package/package.json +2 -2
|
@@ -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>;
|
package/dist/index.d.ts
ADDED
|
@@ -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
|
+
}
|
package/dist/naddons.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
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;
|
package/dist/naddons.es.js
CHANGED
|
@@ -1,140 +1,259 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useES as
|
|
3
|
-
import { Native as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
__name: "GridTabs",
|
|
6
|
+
props: {
|
|
7
|
+
tabsData: {},
|
|
8
|
+
actionPayload: {}
|
|
9
|
+
},
|
|
10
|
+
emits: ["onTabSelected", "onTabNeedsData", "onLoadMore", "onItemPresence", "onTabFocused", "onItemClick", "onItemFocused"],
|
|
11
|
+
setup(o, { expose: t }) {
|
|
12
|
+
const a = P(), u = W(
|
|
13
|
+
"QtGridTabs",
|
|
14
|
+
"com.quicktvui.plugin.glintui"
|
|
15
|
+
);
|
|
16
|
+
return t({
|
|
17
|
+
scrollToTop: (...c) => {
|
|
18
|
+
var n;
|
|
19
|
+
return (n = a.value) == null ? void 0 : n.scrollToTop(...c);
|
|
20
|
+
}
|
|
21
|
+
}), (c, n) => (M(), F(O(u), D({
|
|
22
|
+
ref_key: "nativeRef",
|
|
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")
|
|
36
|
+
]),
|
|
37
|
+
_: 3
|
|
38
|
+
}, 16, ["tabsData", "actionPayload"]));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
function z(o, t) {
|
|
42
|
+
const a = P(!1), u = P(!1);
|
|
43
|
+
return {
|
|
44
|
+
isIntersecting: a,
|
|
45
|
+
isVisible: u,
|
|
46
|
+
handlePresenceState: (n) => {
|
|
47
|
+
var l, w, y;
|
|
48
|
+
switch (n) {
|
|
49
|
+
case "enter":
|
|
50
|
+
a.value = !0, (l = t == null ? void 0 : t.onEnter) == null || l.call(t);
|
|
51
|
+
break;
|
|
52
|
+
case "visible":
|
|
53
|
+
u.value = !0, (w = t == null ? void 0 : t.onVisible) == null || w.call(t);
|
|
54
|
+
break;
|
|
55
|
+
case "leave":
|
|
56
|
+
a.value = !1, u.value = !1, (y = t == null ? void 0 : t.onLeave) == null || y.call(t);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
let $;
|
|
63
|
+
var I;
|
|
64
|
+
try {
|
|
65
|
+
const o = require("@extscreen/es3-vue");
|
|
66
|
+
$ = o.registerElement || ((I = o.default) == null ? void 0 : I.registerElement);
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
const Q = {
|
|
70
|
+
install: (o) => {
|
|
71
|
+
globalThis.__QtGridTabs_registered || ($ ? ($("qt-grid-tabs", {
|
|
72
|
+
component: {
|
|
73
|
+
name: "QtGridTabs",
|
|
74
|
+
// 关键:将前端标签映射到真正的 Native 组件名
|
|
75
|
+
processEventData(t, a, u) {
|
|
76
|
+
return console.log(`[GridTabs/index.ts] qt-grid-tabs 收到原生事件: ${a}, 数据:`, u), t.nativeEvent = u, t;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}), $("QtGridTabs", {
|
|
80
|
+
component: {
|
|
81
|
+
name: "QtGridTabs",
|
|
82
|
+
processEventData(t, a, u) {
|
|
83
|
+
return console.log(`[GridTabs/index.ts] QtGridTabs 收到原生事件: ${a}, 数据:`, u), t.nativeEvent = u, t;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
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);
|
|
87
|
+
}
|
|
88
|
+
}, T = /* @__PURE__ */ new Set();
|
|
89
|
+
function W(o, t, a) {
|
|
90
|
+
return p({
|
|
91
|
+
name: `${o}AsyncWrapper`,
|
|
8
92
|
inheritAttrs: !1,
|
|
9
|
-
setup(
|
|
10
|
-
const
|
|
11
|
-
let
|
|
93
|
+
setup(u, { slots: c, attrs: n }) {
|
|
94
|
+
const l = P("loading"), w = P("");
|
|
95
|
+
let y = null, g = null;
|
|
12
96
|
try {
|
|
13
|
-
|
|
14
|
-
} catch (
|
|
15
|
-
console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。",
|
|
97
|
+
y = x(), g = q();
|
|
98
|
+
} catch (i) {
|
|
99
|
+
console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。", i);
|
|
16
100
|
}
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
101
|
+
const S = async () => {
|
|
102
|
+
if (!y || typeof y.isComponentRegistered != "function")
|
|
19
103
|
return console.log("[withAsyncPlugin] es.isComponentRegistered 不可用"), !1;
|
|
20
104
|
try {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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))
|
|
107
|
+
return !0;
|
|
108
|
+
try {
|
|
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)
|
|
122
|
+
]);
|
|
123
|
+
if (console.log(`[withAsyncPlugin] ExtendModule.isComponentRegistered 返回: [${m}, ${b}]`), m === !0 || b === !0)
|
|
124
|
+
return !0;
|
|
125
|
+
} else
|
|
126
|
+
console.log(`[withAsyncPlugin] 引擎版本 ${d} < 1.11.205,跳过 ExtendModule 检查`);
|
|
127
|
+
else
|
|
128
|
+
console.log(`[withAsyncPlugin] 无法解析引擎版本号: ${d}`);
|
|
129
|
+
}
|
|
130
|
+
} catch (r) {
|
|
131
|
+
console.log("[withAsyncPlugin] 获取引擎版本或检查 Controller 失败:", r);
|
|
132
|
+
}
|
|
133
|
+
return !1;
|
|
134
|
+
} catch (i) {
|
|
135
|
+
return console.warn("[withAsyncPlugin] 检查组件注册状态异常:", i), !1;
|
|
25
136
|
}
|
|
26
|
-
},
|
|
137
|
+
}, C = async () => {
|
|
27
138
|
if (!t) {
|
|
28
|
-
|
|
139
|
+
l.value = "ready";
|
|
29
140
|
return;
|
|
30
141
|
}
|
|
31
|
-
const
|
|
32
|
-
if (console.log(`[withAsyncPlugin] 拦截检查 - ${
|
|
33
|
-
|
|
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] 组件已注册,跳过安装流程");
|
|
34
145
|
return;
|
|
35
146
|
}
|
|
36
|
-
if (!
|
|
37
|
-
console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${
|
|
147
|
+
if (!g) {
|
|
148
|
+
console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${o}`), l.value = "ready";
|
|
38
149
|
return;
|
|
39
150
|
}
|
|
40
151
|
console.log(`[withAsyncPlugin] 开始动态安装插件: ${t}`);
|
|
41
152
|
try {
|
|
42
|
-
await new Promise((
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
onPluginInstallSuccess(
|
|
46
|
-
|
|
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", {
|
|
47
158
|
entry: {
|
|
48
|
-
from:
|
|
159
|
+
from: a,
|
|
49
160
|
method: "setup"
|
|
50
161
|
}
|
|
51
|
-
})) : console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"),
|
|
162
|
+
})) : console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"), r()) : d(new Error(`安装失败 pkg=${f} status=${m} msg=${b}`)));
|
|
52
163
|
},
|
|
53
|
-
onPluginInstallError(
|
|
54
|
-
|
|
164
|
+
onPluginInstallError(f, m, b) {
|
|
165
|
+
f === t && (clearTimeout(e), g.removeListener(s), d(new Error(`安装失败 pkg=${f} status=${m} msg=${b}`)));
|
|
55
166
|
}
|
|
56
167
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, 8e3), typeof
|
|
60
|
-
}), await
|
|
61
|
-
} catch (
|
|
62
|
-
console.error("[withAsyncPlugin] 插件加载失败:",
|
|
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";
|
|
63
174
|
}
|
|
64
175
|
};
|
|
65
|
-
return
|
|
66
|
-
|
|
176
|
+
return R(() => {
|
|
177
|
+
C();
|
|
67
178
|
}), () => {
|
|
68
|
-
const
|
|
179
|
+
const i = {
|
|
69
180
|
width: "100%",
|
|
70
181
|
height: "100%",
|
|
71
182
|
display: "flex",
|
|
72
183
|
flexDirection: "column",
|
|
73
184
|
justifyContent: "center",
|
|
74
185
|
alignItems: "center",
|
|
75
|
-
...
|
|
186
|
+
...n.style || {}
|
|
76
187
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
188
|
+
if (l.value === "loading")
|
|
189
|
+
return h("div", { class: "qt-plugin-container", style: i }, [
|
|
190
|
+
h("div", { style: { color: "white", fontSize: "30px" } }, "插件加载中...")
|
|
191
|
+
]);
|
|
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}`)
|
|
195
|
+
]);
|
|
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() : [])
|
|
86
242
|
]);
|
|
87
243
|
};
|
|
88
244
|
}
|
|
89
245
|
});
|
|
90
246
|
}
|
|
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
247
|
const B = {
|
|
116
|
-
install: (
|
|
117
|
-
|
|
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);
|
|
248
|
+
install: (o) => {
|
|
249
|
+
o.use(Q);
|
|
132
250
|
}
|
|
133
251
|
};
|
|
134
252
|
export {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
253
|
+
E as GridTabs,
|
|
254
|
+
Q as GridTabsPlugin,
|
|
255
|
+
B as QuickTVUINAddons,
|
|
256
|
+
B as default,
|
|
257
|
+
z as useGridItemPresence,
|
|
258
|
+
W as withAsyncPlugin
|
|
140
259
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quicktvui/naddons",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
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",
|
|
@@ -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": {
|