@quicktvui/naddons 1.0.0-alpha.0 → 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const 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;
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,67 +1,69 @@
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({
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
7
  name: `${n}AsyncWrapper`,
8
8
  inheritAttrs: !1,
9
- setup(u, { slots: v, attrs: w }) {
10
- const l = p("loading"), _ = p("");
9
+ setup(c, { slots: v, attrs: A }) {
10
+ const i = w("loading"), _ = w("");
11
11
  let d = null, r = null;
12
12
  try {
13
- d = C(), r = I();
13
+ d = I(), r = L();
14
14
  } catch (e) {
15
15
  console.warn("[withAsyncPlugin] 获取 useES 或 useESPlugin 失败,可能处于非 ES 环境。", e);
16
16
  }
17
- const $ = async () => {
17
+ const E = async () => {
18
18
  if (!d || typeof d.isComponentRegistered != "function")
19
- return !1;
19
+ return console.log("[withAsyncPlugin] es.isComponentRegistered 不可用"), !1;
20
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;
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;
26
25
  }
27
- }, b = async () => {
26
+ }, P = async () => {
28
27
  if (!t) {
29
- l.value = "ready";
28
+ i.value = "ready";
29
+ return;
30
+ }
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] 组件已注册,跳过安装流程");
30
34
  return;
31
35
  }
32
- if (await $() || h.has(t)) {
33
- l.value = "ready", h.add(t);
36
+ if (!r) {
37
+ console.warn(`[withAsyncPlugin] 无法获取 useESPlugin 实例,可能处于内置 AAR 环境或非插件环境,尝试直接渲染 ${n}`), i.value = "ready";
34
38
  return;
35
39
  }
36
40
  console.log(`[withAsyncPlugin] 开始动态安装插件: ${t}`);
37
41
  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", {
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", {
45
47
  entry: {
46
48
  from: s,
47
49
  method: "setup"
48
50
  }
49
- })) : console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"), e()) : i(new Error(`安装失败 pkg=${o} status=${c} msg=${y}`)));
51
+ })) : console.log("[withAsyncPlugin] 安装成功,跳过反射初始化(无 pluginInitClass)"), l()) : f(new Error(`安装失败 pkg=${o} status=${a} msg=${h}`)));
50
52
  },
51
- onPluginInstallError(o, c, y) {
52
- o === t && (clearTimeout(g), r.removeListener(f), i(new Error(`安装失败 pkg=${o} status=${c} msg=${y}`)));
53
+ onPluginInstallError(o, a, h) {
54
+ o === t && (clearTimeout(y), r.removeListener(g), f(new Error(`安装失败 pkg=${o} status=${a} msg=${h}`)));
53
55
  }
54
56
  };
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";
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";
61
63
  }
62
64
  };
63
- return S(() => {
64
- b();
65
+ return b(() => {
66
+ P();
65
67
  }), () => {
66
68
  const e = {
67
69
  width: "100%",
@@ -70,15 +72,15 @@ function M(n, t, s) {
70
72
  flexDirection: "column",
71
73
  justifyContent: "center",
72
74
  alignItems: "center",
73
- ...w.style || {}
75
+ ...A.style || {}
74
76
  };
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,
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,
82
84
  style: { width: "100%", height: "100%", backgroundColor: "transparent" }
83
85
  }, v)
84
86
  ]);
@@ -86,20 +88,20 @@ function M(n, t, s) {
86
88
  }
87
89
  });
88
90
  }
89
- const k = /* @__PURE__ */ E({
91
+ const z = /* @__PURE__ */ $({
90
92
  __name: "GridTabs",
91
93
  setup(n) {
92
- const t = p(), s = M(
94
+ const t = w(), s = V(
93
95
  "qt-grid-tabs",
94
96
  "com.quicktvui.plugin.glintui",
95
97
  "com.quicktvui.plugin.glintui.GlintPluginApp"
96
98
  );
97
- return (u, v) => (q(), P(T(s), x({
99
+ return (c, v) => (q(), R(x(s), C({
98
100
  ref_key: "nativeRef",
99
101
  ref: t
100
- }, u.$attrs), {
101
- default: R(() => [
102
- G(u.$slots, "default")
102
+ }, c.$attrs), {
103
+ default: T(() => [
104
+ G(c.$slots, "default")
103
105
  ]),
104
106
  _: 3
105
107
  }, 16));
@@ -110,28 +112,29 @@ try {
110
112
  m = require("@extscreen/es3-vue").registerElement;
111
113
  } catch {
112
114
  }
113
- const V = {
115
+ const B = {
114
116
  install: (n) => {
115
117
  globalThis.__qt_grid_tabs_registered || m && (m("qt-grid-tabs", {
116
118
  component: {
117
119
  name: "qt-grid-tabs",
118
- processEventData(t, s, u) {
120
+ processEventData(t, s, c) {
119
121
  return {
120
122
  handler: s,
121
- nativeEvent: u
123
+ nativeEvent: c
122
124
  };
123
125
  }
124
126
  }
125
- }), globalThis.__qt_grid_tabs_registered = !0), n.component("GridTabs", k);
127
+ }), globalThis.__qt_grid_tabs_registered = !0), n.component("GridTabs", z);
126
128
  }
127
- }, W = {
129
+ }, Q = {
128
130
  install: (n) => {
129
- n.use(V);
131
+ n.use(B);
130
132
  }
131
133
  };
132
134
  export {
133
- k as GridTabs,
134
- V as GridTabsPlugin,
135
- W as QuickTVUINAddons,
136
- W as default
135
+ z as GridTabs,
136
+ B as GridTabsPlugin,
137
+ Q as QuickTVUINAddons,
138
+ Q as default,
139
+ V as withAsyncPlugin
137
140
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicktvui/naddons",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "Vue 3 wrappers for QuickTVUI Native Addons",
5
5
  "main": "dist/naddons.cjs.js",
6
6
  "module": "dist/naddons.es.js",
@@ -14,9 +14,9 @@
14
14
  "prepublishOnly": "npm run build"
15
15
  },
16
16
  "peerDependencies": {
17
- "@extscreen/es3-core": "^3.0.0",
18
- "@extscreen/es3-vue": "^3.0.0",
19
- "vue": "^3.2.0"
17
+ "@extscreen/es3-core": ">=3.0.0",
18
+ "@extscreen/es3-vue": ">=3.0.0",
19
+ "vue": ">=3.2.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@vitejs/plugin-vue": "^4.0.0",
@@ -1,9 +0,0 @@
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
- };
@@ -1,7 +0,0 @@
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;
@@ -1,7 +0,0 @@
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 DELETED
@@ -1,7 +0,0 @@
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;