@quicktvui/naddons 1.0.0-alpha.0

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,9 @@
1
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
2
+ default?(_: {}): any;
3
+ }>;
4
+ export default _default;
5
+ type __VLS_WithTemplateSlots<T, S> = T & {
6
+ new (): {
7
+ $slots: S;
8
+ };
9
+ };
@@ -0,0 +1,7 @@
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 default GridTabsPlugin;
@@ -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,7 @@
1
+ export * from './components/grid-tabs';
2
+ export { withAsyncPlugin } from './core/withAsyncPlugin';
3
+ import { App } from 'vue';
4
+ export declare const QuickTVUINAddons: {
5
+ install: (app: App) => void;
6
+ };
7
+ export default QuickTVUINAddons;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),_=require("@extscreen/es3-core"),A=require("@extscreen/es3-vue"),y=new Set;function P(r,n,i){return e.defineComponent({name:`${r}AsyncWrapper`,inheritAttrs:!1,setup(a,{slots:p,attrs:w}){const o=e.ref("loading"),m=e.ref("");let d=null,s=null;try{d=_.useES(),s=_.useESPlugin()}catch(t){console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。",t)}const $=async()=>{if(!d||typeof d.isComponentRegistered!="function")return!1;try{return(await Promise.allSettled([d.isComponentRegistered(r)])).some(l=>l.status==="fulfilled"&&l.value===!0)}catch{return!1}},q=async()=>{if(!n){o.value="ready";return}if(await $()||y.has(n)){o.value="ready",y.add(n);return}console.log(`[withAsyncPlugin] 开始动态安装插件: ${n}`);try{if(!s)throw new Error("无法获取 useESPlugin 实例");await new Promise((t,l)=>{let g;const f={onPluginInstallSuccess(u,c,h){u===n&&(clearTimeout(g),s.removeListener(f),console.log(`[withAsyncPlugin] 安装成功 pkg=${u} 状态码=${c}`),c==1003?(i?(console.log(`[withAsyncPlugin] 触发反射初始化: ${i}`),A.Native.callNative("EsNativeModule","callReflect",{entry:{from:i,method:"setup"}})):console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"),t()):l(new Error(`安装失败 pkg=${u} status=${c} msg=${h}`)))},onPluginInstallError(u,c,h){u===n&&(clearTimeout(g),s.removeListener(f),l(new Error(`安装失败 pkg=${u} status=${c} msg=${h}`)))}};s.addListener({pkg:n},f),g=setTimeout(()=>{s.removeListener(f),l(new Error(`插件安装超时: ${n}`))},8e3),typeof s.installPlugin=="function"?s.installPlugin({pkg:n}):typeof s.install=="function"?s.install(n):l(new Error("当前运行时不支持 install / installPlugin"))}),await e.nextTick(),y.add(n),o.value="ready"}catch(t){console.error("[withAsyncPlugin] 插件加载失败:",t),m.value=(t==null?void 0:t.message)||String(t),o.value="error"}};return e.onMounted(()=>{q()}),()=>{const t={width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",...w.style||{}};return o.value==="loading"?e.h("div",{class:"qt-plugin-container",style:t},[e.h("div",{style:{color:"white",fontSize:"30px"}},"插件加载中...")]):o.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)"}},`插件加载失败: ${m.value}`)]):e.h("div",{class:"qt-plugin-container",style:t},[e.h(r,{...w,style:{width:"100%",height:"100%",backgroundColor:"transparent"}},p)])}}})}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(a,p)=>(e.openBlock(),e.createBlock(e.unref(i),e.mergeProps({ref_key:"nativeRef",ref:n},a.$attrs),{default:e.withCtx(()=>[e.renderSlot(a.$slots,"default")]),_:3},16))}});let v;try{v=require("@extscreen/es3-vue").registerElement}catch{}const E={install:r=>{globalThis.__qt_grid_tabs_registered||v&&(v("qt-grid-tabs",{component:{name:"qt-grid-tabs",processEventData(n,i,a){return{handler:i,nativeEvent:a}}}}),globalThis.__qt_grid_tabs_registered=!0),r.component("GridTabs",b)}},S={install:r=>{r.use(E)}};exports.GridTabs=b;exports.GridTabsPlugin=E;exports.QuickTVUINAddons=S;exports.default=S;
@@ -0,0 +1,137 @@
1
+ import { defineComponent as E, ref as p, onMounted as S, h as a, nextTick as A, openBlock as q, createBlock as P, unref as T, mergeProps as x, withCtx as R, renderSlot as G } from "vue";
2
+ import { useES as C, useESPlugin as I } from "@extscreen/es3-core";
3
+ import { Native as L } from "@extscreen/es3-vue";
4
+ const h = /* @__PURE__ */ new Set();
5
+ function M(n, t, s) {
6
+ return E({
7
+ name: `${n}AsyncWrapper`,
8
+ inheritAttrs: !1,
9
+ setup(u, { slots: v, attrs: w }) {
10
+ const l = p("loading"), _ = p("");
11
+ let d = null, r = null;
12
+ try {
13
+ d = C(), r = I();
14
+ } catch (e) {
15
+ console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。", e);
16
+ }
17
+ const $ = async () => {
18
+ if (!d || typeof d.isComponentRegistered != "function")
19
+ return !1;
20
+ try {
21
+ return (await Promise.allSettled([
22
+ d.isComponentRegistered(n)
23
+ ])).some((i) => i.status === "fulfilled" && i.value === !0);
24
+ } catch {
25
+ return !1;
26
+ }
27
+ }, b = async () => {
28
+ if (!t) {
29
+ l.value = "ready";
30
+ return;
31
+ }
32
+ if (await $() || h.has(t)) {
33
+ l.value = "ready", h.add(t);
34
+ return;
35
+ }
36
+ console.log(`[withAsyncPlugin] 开始动态安装插件: ${t}`);
37
+ try {
38
+ if (!r)
39
+ throw new Error("无法获取 useESPlugin 实例");
40
+ await new Promise((e, i) => {
41
+ let g;
42
+ const f = {
43
+ onPluginInstallSuccess(o, c, y) {
44
+ o === t && (clearTimeout(g), r.removeListener(f), console.log(`[withAsyncPlugin] 安装成功 pkg=${o} 状态码=${c}`), c == 1003 ? (s ? (console.log(`[withAsyncPlugin] 触发反射初始化: ${s}`), L.callNative("EsNativeModule", "callReflect", {
45
+ entry: {
46
+ from: s,
47
+ method: "setup"
48
+ }
49
+ })) : console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"), e()) : i(new Error(`安装失败 pkg=${o} status=${c} msg=${y}`)));
50
+ },
51
+ onPluginInstallError(o, c, y) {
52
+ o === t && (clearTimeout(g), r.removeListener(f), i(new Error(`安装失败 pkg=${o} status=${c} msg=${y}`)));
53
+ }
54
+ };
55
+ r.addListener({ pkg: t }, f), g = setTimeout(() => {
56
+ r.removeListener(f), i(new Error(`插件安装超时: ${t}`));
57
+ }, 8e3), typeof r.installPlugin == "function" ? r.installPlugin({ pkg: t }) : typeof r.install == "function" ? r.install(t) : i(new Error("当前运行时不支持 install / installPlugin"));
58
+ }), await A(), h.add(t), l.value = "ready";
59
+ } catch (e) {
60
+ console.error("[withAsyncPlugin] 插件加载失败:", e), _.value = (e == null ? void 0 : e.message) || String(e), l.value = "error";
61
+ }
62
+ };
63
+ return S(() => {
64
+ b();
65
+ }), () => {
66
+ const e = {
67
+ width: "100%",
68
+ height: "100%",
69
+ display: "flex",
70
+ flexDirection: "column",
71
+ justifyContent: "center",
72
+ alignItems: "center",
73
+ ...w.style || {}
74
+ };
75
+ return l.value === "loading" ? a("div", { class: "qt-plugin-container", style: e }, [
76
+ a("div", { style: { color: "white", fontSize: "30px" } }, "插件加载中...")
77
+ ]) : l.value === "error" ? a("div", { class: "qt-plugin-container", style: e }, [
78
+ a("div", { style: { color: "white", fontSize: "30px", backgroundColor: "rgba(255,0,0,0.5)" } }, `插件加载失败: ${_.value}`)
79
+ ]) : a("div", { class: "qt-plugin-container", style: e }, [
80
+ a(n, {
81
+ ...w,
82
+ style: { width: "100%", height: "100%", backgroundColor: "transparent" }
83
+ }, v)
84
+ ]);
85
+ };
86
+ }
87
+ });
88
+ }
89
+ const k = /* @__PURE__ */ E({
90
+ __name: "GridTabs",
91
+ setup(n) {
92
+ const t = p(), s = M(
93
+ "qt-grid-tabs",
94
+ "com.quicktvui.plugin.glintui",
95
+ "com.quicktvui.plugin.glintui.GlintPluginApp"
96
+ );
97
+ return (u, v) => (q(), P(T(s), x({
98
+ ref_key: "nativeRef",
99
+ ref: t
100
+ }, u.$attrs), {
101
+ default: R(() => [
102
+ G(u.$slots, "default")
103
+ ]),
104
+ _: 3
105
+ }, 16));
106
+ }
107
+ });
108
+ let m;
109
+ try {
110
+ m = require("@extscreen/es3-vue").registerElement;
111
+ } catch {
112
+ }
113
+ const V = {
114
+ install: (n) => {
115
+ globalThis.__qt_grid_tabs_registered || m && (m("qt-grid-tabs", {
116
+ component: {
117
+ name: "qt-grid-tabs",
118
+ processEventData(t, s, u) {
119
+ return {
120
+ handler: s,
121
+ nativeEvent: u
122
+ };
123
+ }
124
+ }
125
+ }), globalThis.__qt_grid_tabs_registered = !0), n.component("GridTabs", k);
126
+ }
127
+ }, W = {
128
+ install: (n) => {
129
+ n.use(V);
130
+ }
131
+ };
132
+ export {
133
+ k as GridTabs,
134
+ V as GridTabsPlugin,
135
+ W as QuickTVUINAddons,
136
+ W as default
137
+ };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@quicktvui/naddons",
3
+ "version": "1.0.0-alpha.0",
4
+ "description": "Vue 3 wrappers for QuickTVUI Native Addons",
5
+ "main": "dist/naddons.cjs.js",
6
+ "module": "dist/naddons.es.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "dev": "vite build --watch",
13
+ "build": "vue-tsc --emitDeclarationOnly && vite build",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "peerDependencies": {
17
+ "@extscreen/es3-core": "^3.0.0",
18
+ "@extscreen/es3-vue": "^3.0.0",
19
+ "vue": "^3.2.0"
20
+ },
21
+ "devDependencies": {
22
+ "@vitejs/plugin-vue": "^4.0.0",
23
+ "typescript": "^4.9.3",
24
+ "vite": "^4.0.0",
25
+ "vue": "^3.2.0",
26
+ "vue-tsc": "^1.0.0"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }