@bi-nova/ui-taro 1.2.2 → 1.2.4-beta.202608051525
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/ad/index.d.mts +13 -4
- package/dist/ad/index.d.ts +13 -4
- package/dist/ad/index.js +1 -1
- package/dist/ad/index.mjs +1 -1
- package/dist/ad/splash/index.scss +2 -2
- package/package.json +3 -3
package/dist/ad/index.d.mts
CHANGED
|
@@ -67,7 +67,7 @@ interface BiDisplayCustomAd$1 extends BiBaseCustomAd {
|
|
|
67
67
|
* @Author wutao
|
|
68
68
|
* @Date 2026-04-14
|
|
69
69
|
* @LastEditors wutao
|
|
70
|
-
* @LastEditTime 2026-06-
|
|
70
|
+
* @LastEditTime 2026-06-29
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
73
|
/**
|
|
@@ -163,7 +163,7 @@ declare const BiSplashAd: React.FC<BiSplashAdProps>;
|
|
|
163
163
|
* @Author wutao
|
|
164
164
|
* @Date 2026-04-14
|
|
165
165
|
* @LastEditors wutao
|
|
166
|
-
* @LastEditTime 2026-
|
|
166
|
+
* @LastEditTime 2026-08-05 14:48:54
|
|
167
167
|
*/
|
|
168
168
|
|
|
169
169
|
/**
|
|
@@ -183,10 +183,19 @@ interface BiDisplayAdConfigEventDetail {
|
|
|
183
183
|
rawResult?: unknown;
|
|
184
184
|
error?: unknown;
|
|
185
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* 无可展示广告关闭事件数据
|
|
188
|
+
*/
|
|
189
|
+
interface BiDisplayNoAdEventDetail {
|
|
190
|
+
provider: 'none';
|
|
191
|
+
type: BiDisplayAdType;
|
|
192
|
+
adId?: string;
|
|
193
|
+
reason: 'noAd';
|
|
194
|
+
}
|
|
186
195
|
/**
|
|
187
196
|
* 展示广告统一事件数据
|
|
188
197
|
*/
|
|
189
|
-
type BiDisplayAdEventDetail = BiBannerAdEventDetail | BiSplashAdEventDetail | Record<string, unknown>;
|
|
198
|
+
type BiDisplayAdEventDetail = BiBannerAdEventDetail | BiSplashAdEventDetail | BiDisplayNoAdEventDetail | Record<string, unknown>;
|
|
190
199
|
/**
|
|
191
200
|
* 展示广告统一自定义广告数据
|
|
192
201
|
*/
|
|
@@ -225,4 +234,4 @@ interface BiDisplayAdProps {
|
|
|
225
234
|
*/
|
|
226
235
|
declare const BiDisplayAd: React.FC<BiDisplayAdProps>;
|
|
227
236
|
|
|
228
|
-
export { type BiAdProvider, type BiAdType, BiBannerAd, type BiBannerAdEventDetail, type BiBannerAdProps, type BiBannerCustomAd, type BiBaseAdEventDetail, type BiBaseCustomAd, BiDisplayAd, type BiDisplayAdConfigEventDetail, type BiDisplayAdEventDetail, type BiDisplayAdProps, type BiDisplayAdType, type BiDisplayCustomAd, BiSplashAd, type BiSplashAdEventDetail, type BiSplashAdProps, type BiSplashCustomAd };
|
|
237
|
+
export { type BiAdProvider, type BiAdType, BiBannerAd, type BiBannerAdEventDetail, type BiBannerAdProps, type BiBannerCustomAd, type BiBaseAdEventDetail, type BiBaseCustomAd, BiDisplayAd, type BiDisplayAdConfigEventDetail, type BiDisplayAdEventDetail, type BiDisplayAdProps, type BiDisplayAdType, type BiDisplayCustomAd, type BiDisplayNoAdEventDetail, BiSplashAd, type BiSplashAdEventDetail, type BiSplashAdProps, type BiSplashCustomAd };
|
package/dist/ad/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ interface BiDisplayCustomAd$1 extends BiBaseCustomAd {
|
|
|
67
67
|
* @Author wutao
|
|
68
68
|
* @Date 2026-04-14
|
|
69
69
|
* @LastEditors wutao
|
|
70
|
-
* @LastEditTime 2026-06-
|
|
70
|
+
* @LastEditTime 2026-06-29
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
73
|
/**
|
|
@@ -163,7 +163,7 @@ declare const BiSplashAd: React.FC<BiSplashAdProps>;
|
|
|
163
163
|
* @Author wutao
|
|
164
164
|
* @Date 2026-04-14
|
|
165
165
|
* @LastEditors wutao
|
|
166
|
-
* @LastEditTime 2026-
|
|
166
|
+
* @LastEditTime 2026-08-05 14:48:54
|
|
167
167
|
*/
|
|
168
168
|
|
|
169
169
|
/**
|
|
@@ -183,10 +183,19 @@ interface BiDisplayAdConfigEventDetail {
|
|
|
183
183
|
rawResult?: unknown;
|
|
184
184
|
error?: unknown;
|
|
185
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* 无可展示广告关闭事件数据
|
|
188
|
+
*/
|
|
189
|
+
interface BiDisplayNoAdEventDetail {
|
|
190
|
+
provider: 'none';
|
|
191
|
+
type: BiDisplayAdType;
|
|
192
|
+
adId?: string;
|
|
193
|
+
reason: 'noAd';
|
|
194
|
+
}
|
|
186
195
|
/**
|
|
187
196
|
* 展示广告统一事件数据
|
|
188
197
|
*/
|
|
189
|
-
type BiDisplayAdEventDetail = BiBannerAdEventDetail | BiSplashAdEventDetail | Record<string, unknown>;
|
|
198
|
+
type BiDisplayAdEventDetail = BiBannerAdEventDetail | BiSplashAdEventDetail | BiDisplayNoAdEventDetail | Record<string, unknown>;
|
|
190
199
|
/**
|
|
191
200
|
* 展示广告统一自定义广告数据
|
|
192
201
|
*/
|
|
@@ -225,4 +234,4 @@ interface BiDisplayAdProps {
|
|
|
225
234
|
*/
|
|
226
235
|
declare const BiDisplayAd: React.FC<BiDisplayAdProps>;
|
|
227
236
|
|
|
228
|
-
export { type BiAdProvider, type BiAdType, BiBannerAd, type BiBannerAdEventDetail, type BiBannerAdProps, type BiBannerCustomAd, type BiBaseAdEventDetail, type BiBaseCustomAd, BiDisplayAd, type BiDisplayAdConfigEventDetail, type BiDisplayAdEventDetail, type BiDisplayAdProps, type BiDisplayAdType, type BiDisplayCustomAd, BiSplashAd, type BiSplashAdEventDetail, type BiSplashAdProps, type BiSplashCustomAd };
|
|
237
|
+
export { type BiAdProvider, type BiAdType, BiBannerAd, type BiBannerAdEventDetail, type BiBannerAdProps, type BiBannerCustomAd, type BiBaseAdEventDetail, type BiBaseCustomAd, BiDisplayAd, type BiDisplayAdConfigEventDetail, type BiDisplayAdEventDetail, type BiDisplayAdProps, type BiDisplayAdType, type BiDisplayCustomAd, type BiDisplayNoAdEventDetail, BiSplashAd, type BiSplashAdEventDetail, type BiSplashAdProps, type BiSplashCustomAd };
|
package/dist/ad/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var lt=Object.create;var ye=Object.defineProperty,ut=Object.defineProperties,ct=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertyNames,Fe=Object.getOwnPropertySymbols,mt=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var $e=(e,t,n)=>t in e?ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))je.call(t,n)&&$e(e,n,t[n]);if(Fe)for(var n of Fe(t))ft.call(t,n)&&$e(e,n,t[n]);return e},Y=(e,t)=>ut(e,dt(t));var gt=(e,t)=>{for(var n in t)ye(e,n,{get:t[n],enumerable:!0})},He=(e,t,n,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of pt(t))!je.call(e,l)&&l!==n&&ye(e,l,{get:()=>t[l],enumerable:!(f=ct(t,l))||f.enumerable});return e};var Ge=(e,t,n)=>(n=e!=null?lt(mt(e)):{},He(t||!e||!e.__esModule?ye(n,"default",{value:e,enumerable:!0}):n,e)),ht=e=>He(ye({},"__esModule",{value:!0}),e);var St={};gt(St,{BiBannerAd:()=>Ee,BiDisplayAd:()=>et,BiSplashAd:()=>Pe});module.exports=ht(St);var jt=require("./banner/index.scss"),Ht=require("./splash/index.scss");var j=require("react"),L=require("@tarojs/components");var At=Ge(require("@tarojs/components")),De;function we(){if(De!==void 0)return De;try{let e=At;De=(e==null?void 0:e.AdCustom)||null}catch(e){De=null}return De}var de=Ge(require("@tarojs/taro"));function Ie(){return typeof wx!="undefined"?wx:null}function re(e,t){let n=e==null?void 0:e.detail;return n&&typeof n=="object"?g(g({},t),n):e&&typeof e=="object"?g(g({},t),e):g({},t)}function Ye(e){return e&&(e.image||e.video)||""}function qe(e,t=""){return e&&(e.poster||e.image||t)||""}function Je(e,t=""){return e?e.video?!1:e.image?!0:/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(String(t).trim()):!0}function Ke(e){if(!e)return 2;let t=Number(e.adSpec||e.spec||0);if(t===1||t===2)return t;let n=Number(e.videoWidth||e.width||0),f=Number(e.videoHeight||e.height||0);return n>0&&f>0?n>f?1:2:e.video?1:2}function Ne(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function ze(e,t=5){let n=e==null?void 0:e.jumpSeconds,f=n!=null?n:t;return Math.min(99,Math.max(0,Number(f)||0))}function Ce(e){var n;let t=(n=e==null?void 0:e.loadTimeout)!=null?n:e==null?void 0:e.timeout;return Math.max(1e3,Number(t)||5e3)}function Bt(e){return e?e.appId||e.miniProgramAppId||e.jumpAppId?"miniProgram":e.path||e.pagePath||e.jumpPath||e.targetUrl?"internal":e.url||e.webUrl||e.h5Url?"web":"none":"none"}function yt(e){return e&&(e.appId||e.miniProgramAppId||e.jumpAppId)||""}function Dt(e){return e&&(e.path||e.pagePath||e.jumpPath||e.targetUrl)||""}function Ct(e){return e&&(e.url||e.webUrl||e.h5Url)||""}function xe(e){let{customAd:t,actionDetail:n,onOpenWebview:f,onError:l,miniProgramErrorCode:p,navigateErrorCode:R,miniProgramUnsupportedErrorCode:q}=e;if(!t)return;let O=Bt(t),N=yt(t),J=Dt(t),K=Ct(t);if(O==="miniProgram"&&N){let P=Ie();if(!P||typeof P.navigateToMiniProgram!="function"){l==null||l(Y(g({},n),{errCode:q||p,errMsg:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}P.navigateToMiniProgram({appId:N,path:J||"",fail:V=>{l==null||l(Y(g({},n),{errCode:p,errMsg:(V==null?void 0:V.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(O==="internal"&&J){de.navigateTo({url:J,fail:P=>{l==null||l(Y(g({},n),{errCode:R,errMsg:(P==null?void 0:P.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}O==="web"&&K&&(f==null||f(Y(g({},n),{url:K})))}function Xe(){let e=Ie(),t=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},n=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof de.getSystemInfoSync=="function"?de.getSystemInfoSync():{},f=n.windowHeight===n.screenHeight,l=16,p=16,R=16,q=32,O=f&&t.top?t.top:l,N=f&&t.height?t.height:q;return{top:`${O}px`,width:"156rpx",height:`${N}px`,lineHeight:`${N}px`,borderRadius:`${Math.round(N/2)}px`,left:f?`${R}px`:void 0,right:f?void 0:`${p}px`}}function Qe(){var l;let e=typeof de.getSystemInfoSync=="function"?de.getSystemInfoSync():{},t=Math.max(0,Number(e.screenHeight||0)-Number(((l=e.safeArea)==null?void 0:l.bottom)||e.windowHeight||0)),n=t>0?t+42:84,f=t>0?t+88:130;return{contentStyle:{bottom:`${n}rpx`},badgeStyle:{bottom:`${f}rpx`}}}var $=require("react/jsx-runtime"),Ee=({unitId:e="",customAd:t,adIntervals:n=30,className:f,onLoad:l,onError:p,onClose:R,onAction:q,onOpenWebview:O})=>{let N=(0,j.useMemo)(()=>we(),[]),J=!!(e&&N),K=(0,j.useRef)(null),P=(0,j.useRef)(!1),V=(0,j.useRef)(!1),[ee,_]=(0,j.useState)(!1),D=t||null,T=(0,j.useMemo)(()=>`bi-banner-ad${f?` ${f}`:""}`,[f]),w=u=>({provider:u,type:"banner"}),k=(0,j.useCallback)(()=>{K.current&&(clearTimeout(K.current),K.current=null)},[]),v=(0,j.useCallback)((u,C)=>{V.current||(V.current=!0,k(),_(!0),p==null||p(g(g({},re(u,w("custom"))),C)))},[k,p]);(0,j.useEffect)(()=>{if(k(),P.current=!1,V.current=!1,_(!1),!(J||!(D!=null&&D.image)))return K.current=setTimeout(()=>{v(void 0,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})},Ce(D)),()=>{k()}},[k,D,J,v]),(0,j.useEffect)(()=>{!e||N||p==null||p(Y(g({},w("wechat")),{errCode:"BI_BANNER_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"}))},[N,p,e]);let M=u=>{l==null||l(re(u,w("wechat")))},ie=u=>{p==null||p(re(u,w("wechat")))},x=u=>{R==null||R(re(u,w("wechat")))},te=()=>{P.current||V.current||(k(),P.current=!0,l==null||l(w("custom")))},m=u=>{v(u,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},z=u=>{var X;(X=u==null?void 0:u.stopPropagation)==null||X.call(u);let C=w("custom");q==null||q(C),xe({customAd:D,actionDetail:C,onOpenWebview:H=>{O==null||O(H)},onError:H=>{p==null||p(H)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL"})},y=u=>{var C;(C=u==null?void 0:u.stopPropagation)==null||C.call(u),R==null||R(w("custom"))};return J&&N?(0,$.jsx)(N,{className:T,unitId:e,adIntervals:n,onLoad:M,onError:ie,onClose:x}):!D||!D.image||ee?null:(0,$.jsxs)(L.View,{className:T,children:[(0,$.jsxs)(L.View,{className:"bi-banner-ad__surface",onClick:z,children:[(0,$.jsxs)(L.View,{className:"bi-banner-ad__media",children:[(0,$.jsx)(L.Text,{className:"bi-banner-ad__badge bi-banner-ad__badge--overlay",children:Ne(D)}),(0,$.jsx)(L.Image,{className:"bi-banner-ad__image",src:D.image||"",mode:"aspectFill",onLoad:te,onError:m})]}),(0,$.jsxs)(L.View,{className:"bi-banner-ad__content",children:[(0,$.jsx)(L.View,{className:"bi-banner-ad__body",children:D.title?(0,$.jsx)(L.Text,{className:"bi-banner-ad__title",children:D.title}):null}),(0,$.jsxs)(L.View,{className:"bi-banner-ad__footer",children:[D.description?(0,$.jsx)(L.Text,{className:"bi-banner-ad__description",children:D.description}):null,(0,$.jsx)(L.Button,{className:"bi-banner-ad__button",onClick:z,children:D.buttonText||"\u7ACB\u5373\u67E5\u770B"})]})]})]}),(0,$.jsx)(L.Button,{className:"bi-banner-ad__close",onClick:y,children:"\xD7"})]})};var a=require("react"),B=require("@tarojs/components");var h=require("react/jsx-runtime"),Pe=({unitId:e="",customAd:t,show:n=!0,zIndex:f=999,pictureInPicture:l=!1,checkNativeSplash:p=!0,jumpSeconds:R=5,className:q,onLoad:O,onError:N,onClose:J,onAction:K,onHide:P,onOpenWebview:V})=>{let ee=(0,a.useMemo)(()=>we(),[]),_=!!(e&&ee),[D,T]=(0,a.useState)(!1),[w,k]=(0,a.useState)(_),[v,M]=(0,a.useState)(!1),[ie,x]=(0,a.useState)(0),[te,m]=(0,a.useState)(!1),[z,y]=(0,a.useState)(!1),u=(0,a.useRef)(null),C=(0,a.useRef)(null),X=(0,a.useRef)(null),H=(0,a.useRef)(null),le=(0,a.useRef)(null),se=(0,a.useRef)(0),ne=(0,a.useRef)(!1),b=(0,a.useRef)(!1),W=(0,a.useRef)(O),A=(0,a.useRef)(N),F=(0,a.useRef)(J),ue=(0,a.useRef)(K),pe=(0,a.useRef)(P),me=(0,a.useRef)(V),c=t||null,ae=(0,a.useMemo)(()=>Ye(c),[c]),Se=(0,a.useMemo)(()=>qe(c,ae),[c,ae]),oe=!!ae,he=(0,a.useMemo)(()=>Je(c,ae),[c,ae]),Me=(0,a.useMemo)(()=>Ke(c),[c]),ve=(0,a.useMemo)(()=>Ne(c),[c]),U=(0,a.useMemo)(()=>ze(c,R),[c,R]),be=(0,a.useMemo)(()=>Xe(),[]),{contentStyle:_e,badgeStyle:Te}=(0,a.useMemo)(()=>Qe(),[]),Re=(0,a.useMemo)(()=>{let o=["bi-splash-ad"];return v&&o.push("bi-splash-ad--pip"),z&&o.push("bi-splash-ad--pip-animating"),q&&o.push(q),o.join(" ")},[q,z,v]);(0,a.useEffect)(()=>{W.current=O,A.current=N,F.current=J,ue.current=K,pe.current=P,me.current=V},[K,J,N,P,O,V]);let Z=o=>({provider:o,type:"splash"});(0,a.useEffect)(()=>{var o;!n||!e||ee||(o=A.current)==null||o.call(A,Y(g({},Z("wechat")),{errCode:"BI_SPLASH_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"}))},[ee,n,e]);let I=(0,a.useCallback)(()=>{u.current&&(clearInterval(u.current),u.current=null),C.current&&(clearTimeout(C.current),C.current=null)},[]),fe=(0,a.useCallback)(()=>{X.current&&(clearTimeout(X.current),X.current=null)},[]),r=(0,a.useCallback)(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]),i=(0,a.useCallback)(()=>{le.current&&(clearTimeout(le.current),le.current=null)},[]),s=(0,a.useCallback)(()=>{I(),fe(),r(),i()},[I,fe,i,r]),Q=(0,a.useCallback)(o=>{var d;s(),T(!1),M(!1),x(0),m(!1),b.current=!1,y(!1),(d=F.current)==null||d.call(F,o)},[s]),ce=(0,a.useCallback)(()=>{let o=w?"wechat":"custom";if(l){I(),fe(),i(),y(!0),le.current=setTimeout(()=>{var d;le.current=null,M(!0),y(!1),(d=pe.current)==null||d.call(pe,Z(o))},280);return}Q({type:"splash",provider:o})},[I,fe,i,Q,w,l]),E=(0,a.useCallback)(()=>{if(I(),U<=0){ce();return}x(U),u.current=setInterval(()=>{x(o=>o<=1?(I(),C.current=setTimeout(()=>{C.current=null,ce()},0),0):o-1)},1e3)},[I,U,ce]),Oe=(0,a.useCallback)(o=>{!n||!_||!o||v||E()},[_,n,v,E]),Ae=(0,a.useCallback)(()=>{let o=!!(!ne.current&&(_||oe));s(),k(_),T(o),M(!1),x(U),m(!1),b.current=!1,y(!1),Oe(o),o&&!_&&oe&&(X.current=setTimeout(()=>{var d;b.current||(s(),T(!1),M(!1),x(0),m(!1),b.current=!1,y(!1),(d=A.current)==null||d.call(A,Y(g({},Z("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},Ce(c)))},[_,s,U,oe,c,Oe]),ke=(0,a.useCallback)(()=>{if(!n)return;if(!p){ne.current=!1,Ae();return}if(ne.current){T(!1);return}let o=Ie();if(!o||typeof o.getShowSplashAdStatus!="function"||se.current>=3){Ae();return}o.getShowSplashAdStatus({success:d=>{var G;if((d==null?void 0:d.code)===-1){se.current+=1,r(),H.current=setTimeout(()=>{H.current=null,ke()},300);return}if((d==null?void 0:d.code)===1){s(),T(!1),ne.current=!0,(G=W.current)==null||G.call(W,{provider:"wechat",type:"splash",nativeSplash:!0});return}Ae()},fail:()=>{Ae()}})},[_,p,s,r,oe,Ae,n]);(0,a.useEffect)(()=>{if(!n){s(),T(!1),k(_),M(!1),x(0),m(!1),b.current=!1,y(!1),ne.current=!1;return}if(se.current=0,!p)ne.current=!1;else if(ne.current)return s(),k(_),T(!1),M(!1),x(0),m(!1),b.current=!1,y(!1),()=>{s()};return s(),k(_),T(!1),M(!1),x(U),m(!1),b.current=!1,y(!1),ke(),()=>{s()}},[_,p,ke,s,U,n]);let tt=o=>{var d;E(),(d=W.current)==null||d.call(W,re(o,Z("wechat")))},nt=o=>{var d;if(w){if(s(),oe){k(!1),T(!0),M(!1),x(U),m(!1),b.current=!1,y(!1),X.current=setTimeout(()=>{var G;b.current||(s(),T(!1),M(!1),x(0),m(!1),b.current=!1,y(!1),(G=A.current)==null||G.call(A,Y(g({},Z("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},Ce(c));return}T(!1),M(!1),x(0),m(!1),b.current=!1,y(!1),(d=F.current)==null||d.call(F,{provider:"wechat",type:"splash",reason:"wechatAdLoadFail",error:o})}},rt=o=>{var ge;let d=o&&typeof o.detail=="object"?o.detail:{},G=Y(g({},re(o,Z("wechat"))),{errCode:"BI_SPLASH_WECHAT_AD_LOAD_FAIL",errMsg:String(d.errMsg||"\u5FAE\u4FE1\u5F00\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:d.errCode,rawErrMsg:d.errMsg});(ge=A.current)==null||ge.call(A,G),nt(G)},it=o=>{Q(re(o,Z("wechat")))},Ve=()=>{var o;b.current||(fe(),b.current=!0,m(!0),E(),(o=W.current)==null||o.call(W,Z("custom")))},st=(o,d)=>{var G;s(),T(!1),M(!1),x(0),m(!1),b.current=!1,y(!1),(G=A.current)==null||G.call(A,g(g({},re(o,Z("custom"))),d))},We=o=>{st(o,{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},at=()=>{var G;let o=w?"wechat":"custom",d=Z(o);(G=ue.current)==null||G.call(ue,d),o==="custom"&&xe({customAd:c,actionDetail:d,onOpenWebview:ge=>{var Be;(Be=me.current)==null||Be.call(me,ge)},onError:ge=>{var Be;(Be=A.current)==null||Be.call(A,ge)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL"})},ot=()=>{Q({type:"splash",provider:w?"wechat":"custom"})},Ue=w?ee:null;return!D||!!!Ue&&!oe?null:(0,h.jsxs)(B.View,{className:Re,style:{zIndex:f},children:[Ue?(0,h.jsx)(B.View,{className:"bi-splash-ad__popup",children:(0,h.jsx)(B.View,{className:`bi-splash-ad__media-wrapper${v?" bi-splash-ad__media-wrapper--pip":""}`,children:(0,h.jsx)(Ue,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:tt,onError:rt,onClose:it})})}):(0,h.jsx)(B.View,{className:"bi-splash-ad__popup",children:(0,h.jsxs)(B.View,{className:"bi-splash-ad__media-shell",onClick:at,children:[he?(0,h.jsx)(B.Image,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:ae,mode:"aspectFill",onLoad:Ve,onError:We}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(B.Image,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:Se,mode:"aspectFill"}),(0,h.jsx)(B.Video,{className:`bi-splash-ad__video${Me===1?" bi-splash-ad__video--landscape":""}`,src:ae,poster:Se,autoplay:!0,muted:(c==null?void 0:c.muted)!==!1,loop:!0,objectFit:"cover",showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:Ve,onError:We})]}),v?(0,h.jsx)(B.View,{className:"bi-splash-ad__pip-mask"}):null,v?null:(0,h.jsx)(B.View,{className:"bi-splash-ad__badge",style:Te,children:ve}),c&&(c.title||!v&&(c.description||c.buttonText))?(0,h.jsxs)(B.View,{className:"bi-splash-ad__content",style:_e,children:[c.title?(0,h.jsx)(B.Text,{className:"bi-splash-ad__title",children:c.title}):null,!v&&c.description?(0,h.jsx)(B.Text,{className:"bi-splash-ad__description",children:c.description}):null,!v&&c.buttonText?(0,h.jsx)(B.Button,{className:"bi-splash-ad__action",children:c.buttonText}):null]}):null]})}),v?(0,h.jsx)(B.View,{className:"bi-splash-ad__pip-close",onClick:ot,children:(0,h.jsx)(B.View,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,v?null:(0,h.jsxs)(B.View,{className:"bi-splash-ad__skip",style:be,onClick:ce,children:[(0,h.jsxs)(B.Text,{children:[ie,"s"]}),(0,h.jsx)(B.View,{className:"bi-splash-ad__skip-divider"}),(0,h.jsx)(B.Text,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};var S=require("react");var Le=require("react/jsx-runtime"),Ze=["banner","splash"],et=({adId:e="",unitId:t,type:n="banner",customAd:f,adOptions:l=null,sdkKey:p="biNova",autoLoad:R=!0,adIntervals:q=30,show:O=!0,zIndex:N=999,pictureInPicture:J=!1,checkNativeSplash:K=!0,jumpSeconds:P=5,className:V,onLoad:ee,onError:_,onClose:D,onAction:T,onHide:w,onOpenWebview:k,onConfigLoad:v,onConfigError:M})=>{let ie=(0,S.useRef)(0),x=(0,S.useRef)(""),te=(0,S.useRef)(ee),m=(0,S.useRef)(_),z=(0,S.useRef)(D),y=(0,S.useRef)(T),u=(0,S.useRef)(w),C=(0,S.useRef)(k),X=(0,S.useRef)(v),H=(0,S.useRef)(M),[le,se]=(0,S.useState)(!1),[ne,b]=(0,S.useState)(!1),[W,A]=(0,S.useState)(null);(0,S.useEffect)(()=>{te.current=ee,m.current=_,z.current=D,y.current=T,u.current=w,C.current=k,X.current=v,H.current=M},[T,D,M,v,_,w,ee,k]);let F=(0,S.useMemo)(()=>Ze.includes(n)?n:"banner",[n]),ue=()=>!!(R&&e),pe=()=>{var Q;let r=globalThis.getApp,i=typeof r=="function"?r():null;if(!i)return null;let s=i;return s[p]||((Q=s.globalData)==null?void 0:Q[p])||null},me=()=>{var r;try{if(typeof wx!="undefined"&&typeof wx.getAccountInfoSync=="function"){let i=wx.getAccountInfoSync();return((r=i==null?void 0:i.miniProgram)==null?void 0:r.appId)||""}}catch(i){return""}return""},c=()=>{ie.current+=1,x.current="",se(!1),b(!1),A(null)},ae=()=>{let r=l&&typeof l=="object"?l:{},i=me();return Y(g({},r),{adId:e,placementId:r.placementId||e,appId:r.appId||i,type:F})},Se=r=>{try{return JSON.stringify(r||{})}catch(i){return`${String(r.appId||"")}_${String(r.placementId||"")}`}},oe=r=>{let i=(r==null?void 0:r.unitId)||"",s=(r==null?void 0:r.customAd)||(r==null?void 0:r.custom)||null,Q=typeof(r==null?void 0:r.show)=="boolean"?r.show:!!(i||s);return{unitId:i,customAd:s,show:Q}},he=r=>{var i,s;(i=H.current)==null||i.call(H,r),(s=m.current)==null||s.call(m,r)},Me=async()=>{var ce;if(!ue())return;let r=ae(),i=Se(r);if(x.current===i&&(le||ne))return;let s=pe();if(!(s!=null&&s.ads)||typeof s.ads.getDisplayAdConfig!="function"){c(),he({type:F,adId:e,errCode:"DISPLAY_AD_SDK_NOT_READY",errMsg:"\u672A\u83B7\u53D6\u5230\u53EF\u7528\u7684\u5E7F\u544A\u670D\u52A1 SDK\uFF0C\u8BF7\u5148\u6CE8\u5165\u5168\u5C40 biNova \u5B9E\u4F8B"});return}let Q=ie.current+1;ie.current=Q,x.current=i,se(!0),b(!1),A(null);try{let E=await s.ads.getDisplayAdConfig(r);if(Q!==ie.current)return;if(!E||E.code!==0||!E.data){se(!1),b(!0),A(null),he({type:F,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(E==null?void 0:E.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:E||null});return}se(!1),b(!0),A(E.data),(ce=X.current)==null||ce.call(X,{type:F,adId:e,requestOptions:r,data:E.data})}catch(E){if(Q!==ie.current)return;se(!1),b(!0),A(null),he({type:F,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:E instanceof Error?E.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:E})}};(0,S.useEffect)(()=>{var r;Ze.includes(n)||(r=m.current)==null||r.call(m,{type:"banner",errCode:"UNSUPPORTED_DISPLAY_AD_TYPE",errMsg:`\u4E0D\u652F\u6301\u7684\u5C55\u793A\u5E7F\u544A\u7C7B\u578B\uFF1A${n}\uFF0C\u8BF7\u4F7F\u7528 "banner" \u6216 "splash"`})},[n]),(0,S.useEffect)(()=>{if(!e){c();return}Me()},[e,l,R,F,p]);let ve=ue(),U=ve?oe(W):null,be=U?U.unitId:t||"",_e=U?U.customAd:f||null,Te=!!(O&&(!ve||!e||ne&&(U!=null&&U.show))),Re=!!K,Z=e||(W==null?void 0:W.adId)||"",I=r=>g({adId:Z},r);return F==="splash"?(0,Le.jsx)(Pe,g({},{unitId:be,customAd:_e,show:Te,zIndex:N,pictureInPicture:J,checkNativeSplash:Re,jumpSeconds:P,className:V,onLoad:i=>{var s;(s=te.current)==null||s.call(te,I(i))},onError:i=>{var s;(s=m.current)==null||s.call(m,I(i))},onClose:i=>{var s;(s=z.current)==null||s.call(z,I(i))},onAction:i=>{var s;(s=y.current)==null||s.call(y,I(i))},onHide:i=>{var s;(s=u.current)==null||s.call(u,I(i))},onOpenWebview:i=>{var s;(s=C.current)==null||s.call(C,I(i))}})):Te?(0,Le.jsx)(Ee,g({},{unitId:be,customAd:_e,adIntervals:q,className:V,onLoad:r=>{var i;(i=te.current)==null||i.call(te,I(r))},onError:r=>{var i;(i=m.current)==null||i.call(m,I(r))},onClose:r=>{var i;(i=z.current)==null||i.call(z,I(r))},onAction:r=>{var i;(i=y.current)==null||i.call(y,I(r))},onOpenWebview:r=>{var i;(i=C.current)==null||i.call(C,I(r))}})):null};0&&(module.exports={BiBannerAd,BiDisplayAd,BiSplashAd});
|
|
1
|
+
"use strict";var lt=Object.create;var Se=Object.defineProperty,ut=Object.defineProperties,ct=Object.getOwnPropertyDescriptor,dt=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertyNames,$e=Object.getOwnPropertySymbols,mt=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var je=(e,n,r)=>n in e?Se(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,y=(e,n)=>{for(var r in n||(n={}))He.call(n,r)&&je(e,r,n[r]);if($e)for(var r of $e(n))gt.call(n,r)&&je(e,r,n[r]);return e},G=(e,n)=>ut(e,dt(n));var ft=(e,n)=>{for(var r in n)Se(e,r,{get:n[r],enumerable:!0})},Ge=(e,n,r,h)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of pt(n))!He.call(e,u)&&u!==r&&Se(e,u,{get:()=>n[u],enumerable:!(h=ct(n,u))||h.enumerable});return e};var Ye=(e,n,r)=>(r=e!=null?lt(mt(e)):{},Ge(n||!e||!e.__esModule?Se(r,"default",{value:e,enumerable:!0}):r,e)),At=e=>Ge(Se({},"__esModule",{value:!0}),e);var St={};ft(St,{BiBannerAd:()=>Re,BiDisplayAd:()=>tt,BiSplashAd:()=>ke});module.exports=At(St);var jt=require("./banner/index.scss"),Ht=require("./splash/index.scss");var w=require("react"),U=require("@tarojs/components");var ht=Ye(require("@tarojs/components")),ve;function Ne(){if(ve!==void 0)return ve;try{let e=ht;ve=(e==null?void 0:e.AdCustom)||null}catch(e){ve=null}return ve}var ge=Ye(require("@tarojs/taro"));function xe(){return typeof wx!="undefined"?wx:null}function le(e,n){let r=e==null?void 0:e.detail;return r&&typeof r=="object"?y(y({},n),r):e&&typeof e=="object"?y(y({},n),e):y({},n)}function qe(e){return e&&(e.image||e.video)||""}function Je(e,n=""){return e&&(e.poster||e.image||n)||""}function Ke(e,n=""){return e?e.video?!1:e.image?!0:/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(String(n).trim()):!0}function ze(e){if(!e)return 2;let n=Number(e.adSpec||e.spec||0);if(n===1||n===2)return n;let r=Number(e.videoWidth||e.width||0),h=Number(e.videoHeight||e.height||0);return r>0&&h>0?r>h?1:2:e.video?1:2}function Pe(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function Xe(e,n=5){let r=e==null?void 0:e.jumpSeconds,h=r!=null?r:n;return Math.min(99,Math.max(0,Number(h)||0))}function be(e){var r;let n=(r=e==null?void 0:e.loadTimeout)!=null?r:e==null?void 0:e.timeout;return Math.max(1e3,Number(n)||5e3)}function Bt(e){return e?e.appId||e.miniProgramAppId||e.jumpAppId?"miniProgram":e.path||e.pagePath||e.jumpPath||e.targetUrl?"internal":e.url||e.webUrl||e.h5Url?"web":"none":"none"}function yt(e){return e&&(e.appId||e.miniProgramAppId||e.jumpAppId)||""}function Dt(e){return e&&(e.path||e.pagePath||e.jumpPath||e.targetUrl)||""}function Ct(e){return e&&(e.url||e.webUrl||e.h5Url)||""}function Me(e){let{customAd:n,actionDetail:r,onOpenWebview:h,onError:u,miniProgramErrorCode:M,navigateErrorCode:Y,miniProgramUnsupportedErrorCode:q}=e;if(!n)return;let x=Bt(n),P=yt(n),J=Dt(n),K=Ct(n);if(x==="miniProgram"&&P){let R=xe();if(!R||typeof R.navigateToMiniProgram!="function"){u==null||u(G(y({},r),{errCode:q||M,errMsg:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}R.navigateToMiniProgram({appId:P,path:J||"",fail:O=>{u==null||u(G(y({},r),{errCode:M,errMsg:(O==null?void 0:O.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(x==="internal"&&J){ge.navigateTo({url:J,fail:R=>{u==null||u(G(y({},r),{errCode:Y,errMsg:(R==null?void 0:R.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}x==="web"&&K&&(h==null||h(G(y({},r),{url:K})))}function Qe(){let e=xe(),n=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},r=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof ge.getSystemInfoSync=="function"?ge.getSystemInfoSync():{},h=r.windowHeight===r.screenHeight,u=16,M=16,Y=16,q=32,x=h&&n.top?n.top:u,P=h&&n.height?n.height:q;return{top:`${x}px`,width:"156rpx",height:`${P}px`,lineHeight:`${P}px`,borderRadius:`${Math.round(P/2)}px`,left:h?`${Y}px`:void 0,right:h?void 0:`${M}px`}}function Ze(){var u;let e=typeof ge.getSystemInfoSync=="function"?ge.getSystemInfoSync():{},n=Math.max(0,Number(e.screenHeight||0)-Number(((u=e.safeArea)==null?void 0:u.bottom)||e.windowHeight||0)),r=n>0?n+42:84,h=n>0?n+88:130;return{contentStyle:{bottom:`${r}rpx`},badgeStyle:{bottom:`${h}rpx`}}}var j=require("react/jsx-runtime"),Re=({unitId:e="",customAd:n,adIntervals:r=30,className:h,onLoad:u,onError:M,onClose:Y,onAction:q,onOpenWebview:x})=>{let P=(0,w.useMemo)(()=>Ne(),[]),J=!!(e&&P),K=(0,w.useRef)(null),R=(0,w.useRef)(!1),O=(0,w.useRef)(!1),k=(0,w.useRef)(u),p=(0,w.useRef)(M),z=(0,w.useRef)(Y),_=(0,w.useRef)(q),W=(0,w.useRef)(x),[ne,E]=(0,w.useState)(!1),c=n||null,ie=(0,w.useMemo)(()=>`bi-banner-ad${h?` ${h}`:""}`,[h]);(0,w.useEffect)(()=>{k.current=u,p.current=M,z.current=Y,_.current=q,W.current=x},[q,Y,M,u,x]);let C=l=>({provider:l,type:"banner"}),V=(0,w.useCallback)(()=>{K.current&&(clearTimeout(K.current),K.current=null)},[]),f=(0,w.useCallback)((l,m)=>{var B;O.current||(O.current=!0,V(),E(!0),(B=p.current)==null||B.call(p,y(y({},le(l,C("custom"))),m)))},[V]);(0,w.useEffect)(()=>{if(V(),R.current=!1,O.current=!1,E(!1),!(J||!(c!=null&&c.image)))return K.current=setTimeout(()=>{f(void 0,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})},be(c)),()=>{V()}},[V,c,J,f]),(0,w.useEffect)(()=>{var l;!e||P||(l=p.current)==null||l.call(p,G(y({},C("wechat")),{errCode:"BI_BANNER_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"}))},[P,e]);let F=l=>{var m;(m=k.current)==null||m.call(k,le(l,C("wechat")))},v=l=>{var m;(m=p.current)==null||m.call(p,le(l,C("wechat")))},re=l=>{var m;(m=z.current)==null||m.call(z,le(l,C("wechat")))},$=()=>{var l;R.current||O.current||(V(),R.current=!0,(l=k.current)==null||l.call(k,C("custom")))},te=l=>{f(l,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},X=l=>{var B,I;(B=l==null?void 0:l.stopPropagation)==null||B.call(l);let m=C("custom");(I=_.current)==null||I.call(_,m),Me({customAd:c,actionDetail:m,onOpenWebview:A=>{var N;(N=W.current)==null||N.call(W,A)},onError:A=>{var N;(N=p.current)==null||N.call(p,A)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL"})},ae=l=>{var m,B;(m=l==null?void 0:l.stopPropagation)==null||m.call(l),(B=z.current)==null||B.call(z,C("custom"))};return J&&P?(0,j.jsx)(P,{className:ie,unitId:e,adIntervals:r,onLoad:F,onError:v,onClose:re}):!c||!c.image||ne?null:(0,j.jsxs)(U.View,{className:ie,children:[(0,j.jsxs)(U.View,{className:"bi-banner-ad__surface",onClick:X,children:[(0,j.jsxs)(U.View,{className:"bi-banner-ad__media",children:[(0,j.jsx)(U.Text,{className:"bi-banner-ad__badge bi-banner-ad__badge--overlay",children:Pe(c)}),(0,j.jsx)(U.Image,{className:"bi-banner-ad__image",src:c.image||"",mode:"aspectFill",onLoad:$,onError:te})]}),(0,j.jsxs)(U.View,{className:"bi-banner-ad__content",children:[(0,j.jsx)(U.View,{className:"bi-banner-ad__body",children:c.title?(0,j.jsx)(U.Text,{className:"bi-banner-ad__title",children:c.title}):null}),(0,j.jsxs)(U.View,{className:"bi-banner-ad__footer",children:[c.description?(0,j.jsx)(U.Text,{className:"bi-banner-ad__description",children:c.description}):null,(0,j.jsx)(U.Button,{className:"bi-banner-ad__button",onClick:X,children:c.buttonText||"\u7ACB\u5373\u67E5\u770B"})]})]})]}),(0,j.jsx)(U.Button,{className:"bi-banner-ad__close",onClick:ae,children:"\xD7"})]})};var a=require("react"),S=require("@tarojs/components");var D=require("react/jsx-runtime"),ke=({unitId:e="",customAd:n,show:r=!0,zIndex:h=999,pictureInPicture:u=!1,checkNativeSplash:M=!0,jumpSeconds:Y=5,className:q,onLoad:x,onError:P,onClose:J,onAction:K,onHide:R,onOpenWebview:O})=>{let k=(0,a.useMemo)(()=>Ne(),[]),p=!!(e&&k),[z,_]=(0,a.useState)(!1),[W,ne]=(0,a.useState)(p),[E,c]=(0,a.useState)(!1),[ie,C]=(0,a.useState)(0),[V,f]=(0,a.useState)(!1),[F,v]=(0,a.useState)(!1),re=(0,a.useRef)(null),$=(0,a.useRef)(null),te=(0,a.useRef)(null),X=(0,a.useRef)(null),ae=(0,a.useRef)(null),l=(0,a.useRef)(0),m=(0,a.useRef)(!1),B=(0,a.useRef)(!1),I=(0,a.useRef)(x),A=(0,a.useRef)(P),N=(0,a.useRef)(J),Q=(0,a.useRef)(K),pe=(0,a.useRef)(R),fe=(0,a.useRef)(O),d=n||null,se=(0,a.useMemo)(()=>qe(d),[d]),_e=(0,a.useMemo)(()=>Je(d,se),[d,se]),de=!!se,Te=(0,a.useMemo)(()=>Ke(d,se),[d,se]),he=(0,a.useMemo)(()=>ze(d),[d]),Le=(0,a.useMemo)(()=>Pe(d),[d]),oe=(0,a.useMemo)(()=>Xe(d,Y),[d,Y]),we=(0,a.useMemo)(()=>Qe(),[]),{contentStyle:ue,badgeStyle:Ee}=(0,a.useMemo)(()=>Ze(),[]),Ie=(0,a.useMemo)(()=>{let s=["bi-splash-ad"];return E&&s.push("bi-splash-ad--pip"),F&&s.push("bi-splash-ad--pip-animating"),q&&s.push(q),s.join(" ")},[q,F,E]);(0,a.useEffect)(()=>{I.current=x,A.current=P,N.current=J,Q.current=K,pe.current=R,fe.current=O},[K,J,P,R,x,O]);let Z=s=>({provider:s,type:"splash"});(0,a.useEffect)(()=>{var s;!r||!e||k||(s=A.current)==null||s.call(A,G(y({},Z("wechat")),{errCode:"BI_SPLASH_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"}))},[k,r,e]);let ce=(0,a.useCallback)(()=>{re.current&&(clearInterval(re.current),re.current=null),$.current&&(clearTimeout($.current),$.current=null)},[]),me=(0,a.useCallback)(()=>{te.current&&(clearTimeout(te.current),te.current=null)},[]),L=(0,a.useCallback)(()=>{X.current&&(clearTimeout(X.current),X.current=null)},[]),Be=(0,a.useCallback)(()=>{ae.current&&(clearTimeout(ae.current),ae.current=null)},[]),t=(0,a.useCallback)(()=>{ce(),me(),L(),Be()},[ce,me,Be,L]),i=(0,a.useCallback)(s=>{var g;t(),_(!1),c(!1),C(0),f(!1),B.current=!1,v(!1),(g=N.current)==null||g.call(N,s)},[t]),o=(0,a.useCallback)(()=>{let s=W?"wechat":"custom";if(u){ce(),me(),Be(),v(!0),ae.current=setTimeout(()=>{var g;ae.current=null,c(!0),v(!1),(g=pe.current)==null||g.call(pe,Z(s))},280);return}i({type:"splash",provider:s})},[ce,me,Be,i,W,u]),ee=(0,a.useCallback)(()=>{if(ce(),oe<=0){o();return}C(oe),re.current=setInterval(()=>{C(s=>s<=1?(ce(),$.current=setTimeout(()=>{$.current=null,o()},0),0):s-1)},1e3)},[ce,oe,o]),ye=(0,a.useCallback)(s=>{!r||!p||!s||E||ee()},[p,r,E,ee]),T=(0,a.useCallback)(()=>{let s=!!(!m.current&&(p||de));t(),ne(p),_(s),c(!1),C(oe),f(!1),B.current=!1,v(!1),ye(s),s&&!p&&de&&(te.current=setTimeout(()=>{var g;B.current||(t(),_(!1),c(!1),C(0),f(!1),B.current=!1,v(!1),(g=A.current)==null||g.call(A,G(y({},Z("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},be(d)))},[p,t,oe,de,d,ye]),De=(0,a.useCallback)(()=>{if(!r)return;if(!M){m.current=!1,T();return}if(m.current){_(!1);return}let s=xe();if(!s||typeof s.getShowSplashAdStatus!="function"||l.current>=3){T();return}s.getShowSplashAdStatus({success:g=>{var H;if((g==null?void 0:g.code)===-1){l.current+=1,L(),X.current=setTimeout(()=>{X.current=null,De()},300);return}if((g==null?void 0:g.code)===1){t(),_(!1),m.current=!0,(H=I.current)==null||H.call(I,{provider:"wechat",type:"splash",nativeSplash:!0});return}T()},fail:()=>{T()}})},[p,M,t,L,de,T,r]);(0,a.useEffect)(()=>{if(!r){t(),_(!1),ne(p),c(!1),C(0),f(!1),B.current=!1,v(!1),m.current=!1;return}if(l.current=0,!M)m.current=!1;else if(m.current)return t(),ne(p),_(!1),c(!1),C(0),f(!1),B.current=!1,v(!1),()=>{t()};return t(),ne(p),_(!1),c(!1),C(oe),f(!1),B.current=!1,v(!1),De(),()=>{t()}},[p,M,De,t,oe,r]);let Ue=s=>{var g;ee(),(g=I.current)==null||g.call(I,le(s,Z("wechat")))},nt=s=>{var g;if(W){if(t(),de){ne(!1),_(!0),c(!1),C(oe),f(!1),B.current=!1,v(!1),te.current=setTimeout(()=>{var H;B.current||(t(),_(!1),c(!1),C(0),f(!1),B.current=!1,v(!1),(H=A.current)==null||H.call(A,G(y({},Z("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},be(d));return}_(!1),c(!1),C(0),f(!1),B.current=!1,v(!1),(g=N.current)==null||g.call(N,{provider:"wechat",type:"splash",reason:"wechatAdLoadFail",error:s})}},rt=s=>{var Ae;let g=s&&typeof s.detail=="object"?s.detail:{},H=G(y({},le(s,Z("wechat"))),{errCode:"BI_SPLASH_WECHAT_AD_LOAD_FAIL",errMsg:String(g.errMsg||"\u5FAE\u4FE1\u5F00\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:g.errCode,rawErrMsg:g.errMsg});(Ae=A.current)==null||Ae.call(A,H),nt(H)},it=s=>{i(le(s,Z("wechat")))},Ve=()=>{var s;B.current||(me(),B.current=!0,f(!0),ee(),(s=I.current)==null||s.call(I,Z("custom")))},at=(s,g)=>{var H;t(),_(!1),c(!1),C(0),f(!1),B.current=!1,v(!1),(H=A.current)==null||H.call(A,y(y({},le(s,Z("custom"))),g))},Fe=s=>{at(s,{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},st=()=>{var H;let s=W?"wechat":"custom",g=Z(s);(H=Q.current)==null||H.call(Q,g),s==="custom"&&Me({customAd:d,actionDetail:g,onOpenWebview:Ae=>{var Ce;(Ce=fe.current)==null||Ce.call(fe,Ae)},onError:Ae=>{var Ce;(Ce=A.current)==null||Ce.call(A,Ae)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL"})},ot=()=>{i({type:"splash",provider:W?"wechat":"custom"})},Oe=W?k:null;return!z||!!!Oe&&!de?null:(0,D.jsxs)(S.View,{className:Ie,style:{zIndex:h},children:[Oe?(0,D.jsx)(S.View,{className:"bi-splash-ad__popup",children:(0,D.jsx)(S.View,{className:`bi-splash-ad__media-wrapper${E?" bi-splash-ad__media-wrapper--pip":""}`,children:(0,D.jsx)(Oe,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:Ue,onError:rt,onClose:it})})}):(0,D.jsx)(S.View,{className:"bi-splash-ad__popup",children:(0,D.jsxs)(S.View,{className:"bi-splash-ad__media-shell",onClick:st,children:[Te?(0,D.jsx)(S.Image,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:se,mode:"aspectFill",onLoad:Ve,onError:Fe}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(S.Image,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:_e,mode:"aspectFill"}),(0,D.jsx)(S.Video,{className:`bi-splash-ad__video${he===1?" bi-splash-ad__video--landscape":""}`,src:se,poster:_e,autoplay:!0,muted:(d==null?void 0:d.muted)!==!1,loop:!0,objectFit:"cover",showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:Ve,onError:Fe})]}),E?(0,D.jsx)(S.View,{className:"bi-splash-ad__pip-mask"}):null,E?null:(0,D.jsx)(S.View,{className:"bi-splash-ad__badge",style:Ee,children:Le}),d&&(d.title||!E&&(d.description||d.buttonText))?(0,D.jsxs)(S.View,{className:"bi-splash-ad__content",style:ue,children:[d.title?(0,D.jsx)(S.Text,{className:"bi-splash-ad__title",children:d.title}):null,!E&&d.description?(0,D.jsx)(S.Text,{className:"bi-splash-ad__description",children:d.description}):null,!E&&d.buttonText?(0,D.jsx)(S.Button,{className:"bi-splash-ad__action",children:d.buttonText}):null]}):null]})}),E?(0,D.jsx)(S.View,{className:"bi-splash-ad__pip-close",onClick:ot,children:(0,D.jsx)(S.View,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,E?null:(0,D.jsxs)(S.View,{className:"bi-splash-ad__skip",style:we,onClick:o,children:[(0,D.jsxs)(S.Text,{children:[ie,"s"]}),(0,D.jsx)(S.View,{className:"bi-splash-ad__skip-divider"}),(0,D.jsx)(S.Text,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};var b=require("react");var We=require("react/jsx-runtime"),et=["banner","splash"],tt=({adId:e="",unitId:n,type:r="banner",customAd:h,adOptions:u=null,sdkKey:M="biNova",autoLoad:Y=!0,adIntervals:q=30,show:x=!0,zIndex:P=999,pictureInPicture:J=!1,checkNativeSplash:K=!0,jumpSeconds:R=5,className:O,onLoad:k,onError:p,onClose:z,onAction:_,onHide:W,onOpenWebview:ne,onConfigLoad:E,onConfigError:c})=>{let ie=(0,b.useRef)(0),C=(0,b.useRef)(""),V=(0,b.useRef)(k),f=(0,b.useRef)(p),F=(0,b.useRef)(z),v=(0,b.useRef)(_),re=(0,b.useRef)(W),$=(0,b.useRef)(ne),te=(0,b.useRef)(E),X=(0,b.useRef)(c),ae=(0,b.useRef)(x),[l,m]=(0,b.useState)(!1),[B,I]=(0,b.useState)(!1),[A,N]=(0,b.useState)(null);(0,b.useEffect)(()=>{V.current=k,f.current=p,F.current=z,v.current=_,re.current=W,$.current=ne,te.current=E,X.current=c,ae.current=x},[_,z,c,E,p,W,k,ne,x]);let Q=(0,b.useMemo)(()=>et.includes(r)?r:"banner",[r]),pe=()=>!!(Y&&e),fe=()=>{var ee;let t=globalThis.getApp,i=typeof t=="function"?t():null;if(!i)return null;let o=i;return o[M]||((ee=o.globalData)==null?void 0:ee[M])||null},d=()=>{var t;try{if(typeof wx!="undefined"&&typeof wx.getAccountInfoSync=="function"){let i=wx.getAccountInfoSync();return((t=i==null?void 0:i.miniProgram)==null?void 0:t.appId)||""}}catch(i){return""}return""},se=()=>{ie.current+=1,C.current="",m(!1),I(!1),N(null)},_e=()=>{let t=u&&typeof u=="object"?u:{},i=d();return G(y({},t),{adId:e,placementId:t.placementId||e,appId:t.appId||i,type:Q})},de=t=>{try{return JSON.stringify(t||{})}catch(i){return`${String(t.appId||"")}_${String(t.placementId||"")}`}},Te=t=>{let i=(t==null?void 0:t.unitId)||"",o=(t==null?void 0:t.customAd)||(t==null?void 0:t.custom)||null,ee=typeof(t==null?void 0:t.show)=="boolean"?t.show:!!(i||o);return{unitId:i,customAd:o,show:ee}},he=t=>{var i,o;(i=X.current)==null||i.call(X,t),(o=f.current)==null||o.call(f,t)},Le=t=>{var i;(i=F.current)==null||i.call(F,{type:Q,adId:e||t.adId||"",provider:"none",reason:"noAd"})},oe=async()=>{var ye;if(!pe())return;let t=_e(),i=de(t);if(C.current===i&&(l||B))return;let o=fe();if(!(o!=null&&o.ads)||typeof o.ads.getDisplayAdConfig!="function"){se(),he({type:Q,adId:e,errCode:"DISPLAY_AD_SDK_NOT_READY",errMsg:"\u672A\u83B7\u53D6\u5230\u53EF\u7528\u7684\u5E7F\u544A\u670D\u52A1 SDK\uFF0C\u8BF7\u5148\u6CE8\u5165\u5168\u5C40 biNova \u5B9E\u4F8B"});return}let ee=ie.current+1;ie.current=ee,C.current=i,m(!0),I(!1),N(null);try{let T=await o.ads.getDisplayAdConfig(t);if(ee!==ie.current)return;if(!T||T.code!==0||!T.data){m(!1),I(!0),N(null),he({type:Q,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(T==null?void 0:T.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:T||null});return}let De=Te(T.data),Ue=!!(ae.current&&!De.show);m(!1),I(!0),N(T.data),(ye=te.current)==null||ye.call(te,{type:Q,adId:e,requestOptions:t,data:T.data}),Ue&&Le(T.data)}catch(T){if(ee!==ie.current)return;m(!1),I(!0),N(null),he({type:Q,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:T instanceof Error?T.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:T})}};(0,b.useEffect)(()=>{var t;et.includes(r)||(t=f.current)==null||t.call(f,{type:"banner",errCode:"UNSUPPORTED_DISPLAY_AD_TYPE",errMsg:`\u4E0D\u652F\u6301\u7684\u5C55\u793A\u5E7F\u544A\u7C7B\u578B\uFF1A${r}\uFF0C\u8BF7\u4F7F\u7528 "banner" \u6216 "splash"`})},[r]),(0,b.useEffect)(()=>{if(!e){se();return}oe()},[e,u,Y,Q,M]);let we=pe(),ue=we?Te(A):null,Ee=ue?ue.unitId:n||"",Ie=ue?ue.customAd:h||null,Z=!!(x&&(!we||!e||B&&(ue!=null&&ue.show))),ce=!!K,me=e||(A==null?void 0:A.adId)||"",L=t=>y({adId:me},t);return Q==="splash"?(0,We.jsx)(ke,y({},{unitId:Ee,customAd:Ie,show:Z,zIndex:P,pictureInPicture:J,checkNativeSplash:ce,jumpSeconds:R,className:O,onLoad:i=>{var o;(o=V.current)==null||o.call(V,L(i))},onError:i=>{var o;(o=f.current)==null||o.call(f,L(i))},onClose:i=>{var o;(o=F.current)==null||o.call(F,L(i))},onAction:i=>{var o;(o=v.current)==null||o.call(v,L(i))},onHide:i=>{var o;(o=re.current)==null||o.call(re,L(i))},onOpenWebview:i=>{var o;(o=$.current)==null||o.call($,L(i))}})):Z?(0,We.jsx)(Re,y({},{unitId:Ee,customAd:Ie,adIntervals:q,className:O,onLoad:t=>{var i;(i=V.current)==null||i.call(V,L(t))},onError:t=>{var i;(i=f.current)==null||i.call(f,L(t))},onClose:t=>{var i;(i=F.current)==null||i.call(F,L(t))},onAction:t=>{var i;(i=v.current)==null||i.call(v,L(t))},onOpenWebview:t=>{var i;(i=$.current)==null||i.call($,L(t))}})):null};0&&(module.exports={BiBannerAd,BiDisplayAd,BiSplashAd});
|
package/dist/ad/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Bt=Object.defineProperty,yt=Object.defineProperties;var Dt=Object.getOwnPropertyDescriptors;var Ke=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var ze=(e,i,n)=>i in e?Bt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,m=(e,i)=>{for(var n in i||(i={}))Ct.call(i,n)&&ze(e,n,i[n]);if(Ke)for(var n of Ke(i))St.call(i,n)&&ze(e,n,i[n]);return e},W=(e,i)=>yt(e,Dt(i));import"./banner/index.scss";import"./splash/index.scss";import{useCallback as it,useEffect as st,useMemo as at,useRef as Ve,useState as It}from"react";import{View as he,Image as Nt,Button as ot,Text as We}from"@tarojs/components";import*as vt from"@tarojs/components";var Se;function xe(){if(Se!==void 0)return Se;try{let e=vt;Se=(e==null?void 0:e.AdCustom)||null}catch(e){Se=null}return Se}import*as de from"@tarojs/taro";function Ee(){return typeof wx!="undefined"?wx:null}function ee(e,i){let n=e==null?void 0:e.detail;return n&&typeof n=="object"?m(m({},i),n):e&&typeof e=="object"?m(m({},i),e):m({},i)}function Xe(e){return e&&(e.image||e.video)||""}function Qe(e,i=""){return e&&(e.poster||e.image||i)||""}function Ze(e,i=""){return e?e.video?!1:e.image?!0:/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(String(i).trim()):!0}function et(e){if(!e)return 2;let i=Number(e.adSpec||e.spec||0);if(i===1||i===2)return i;let n=Number(e.videoWidth||e.width||0),g=Number(e.videoHeight||e.height||0);return n>0&&g>0?n>g?1:2:e.video?1:2}function Pe(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function tt(e,i=5){let n=e==null?void 0:e.jumpSeconds,g=n!=null?n:i;return Math.min(99,Math.max(0,Number(g)||0))}function ve(e){var n;let i=(n=e==null?void 0:e.loadTimeout)!=null?n:e==null?void 0:e.timeout;return Math.max(1e3,Number(i)||5e3)}function bt(e){return e?e.appId||e.miniProgramAppId||e.jumpAppId?"miniProgram":e.path||e.pagePath||e.jumpPath||e.targetUrl?"internal":e.url||e.webUrl||e.h5Url?"web":"none":"none"}function _t(e){return e&&(e.appId||e.miniProgramAppId||e.jumpAppId)||""}function Tt(e){return e&&(e.path||e.pagePath||e.jumpPath||e.targetUrl)||""}function wt(e){return e&&(e.url||e.webUrl||e.h5Url)||""}function Me(e){let{customAd:i,actionDetail:n,onOpenWebview:g,onError:c,miniProgramErrorCode:d,navigateErrorCode:x,miniProgramUnsupportedErrorCode:$}=e;if(!i)return;let R=bt(i),_=_t(i),j=Tt(i),H=wt(i);if(R==="miniProgram"&&_){let I=Ee();if(!I||typeof I.navigateToMiniProgram!="function"){c==null||c(W(m({},n),{errCode:$||d,errMsg:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}I.navigateToMiniProgram({appId:_,path:j||"",fail:k=>{c==null||c(W(m({},n),{errCode:d,errMsg:(k==null?void 0:k.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(R==="internal"&&j){de.navigateTo({url:j,fail:I=>{c==null||c(W(m({},n),{errCode:x,errMsg:(I==null?void 0:I.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}R==="web"&&H&&(g==null||g(W(m({},n),{url:H})))}function nt(){let e=Ee(),i=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},n=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof de.getSystemInfoSync=="function"?de.getSystemInfoSync():{},g=n.windowHeight===n.screenHeight,c=16,d=16,x=16,$=32,R=g&&i.top?i.top:c,_=g&&i.height?i.height:$;return{top:`${R}px`,width:"156rpx",height:`${_}px`,lineHeight:`${_}px`,borderRadius:`${Math.round(_/2)}px`,left:g?`${x}px`:void 0,right:g?void 0:`${d}px`}}function rt(){var c;let e=typeof de.getSystemInfoSync=="function"?de.getSystemInfoSync():{},i=Math.max(0,Number(e.screenHeight||0)-Number(((c=e.safeArea)==null?void 0:c.bottom)||e.windowHeight||0)),n=i>0?i+42:84,g=i>0?i+88:130;return{contentStyle:{bottom:`${n}rpx`},badgeStyle:{bottom:`${g}rpx`}}}import{jsx as oe,jsxs as be}from"react/jsx-runtime";var Fe=({unitId:e="",customAd:i,adIntervals:n=30,className:g,onLoad:c,onError:d,onClose:x,onAction:$,onOpenWebview:R})=>{let _=at(()=>xe(),[]),j=!!(e&&_),H=Ve(null),I=Ve(!1),k=Ve(!1),[X,C]=It(!1),A=i||null,S=at(()=>`bi-banner-ad${g?` ${g}`:""}`,[g]),v=o=>({provider:o,type:"banner"}),E=it(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]),y=it((o,B)=>{k.current||(k.current=!0,E(),C(!0),d==null||d(m(m({},ee(o,v("custom"))),B)))},[E,d]);st(()=>{if(E(),I.current=!1,k.current=!1,C(!1),!(j||!(A!=null&&A.image)))return H.current=setTimeout(()=>{y(void 0,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})},ve(A)),()=>{E()}},[E,A,j,y]),st(()=>{!e||_||d==null||d(W(m({},v("wechat")),{errCode:"BI_BANNER_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"}))},[_,d,e]);let N=o=>{c==null||c(ee(o,v("wechat")))},re=o=>{d==null||d(ee(o,v("wechat")))},T=o=>{x==null||x(ee(o,v("wechat")))},Q=()=>{I.current||k.current||(E(),I.current=!0,c==null||c(v("custom")))},p=o=>{y(o,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},G=o=>{var Y;(Y=o==null?void 0:o.stopPropagation)==null||Y.call(o);let B=v("custom");$==null||$(B),Me({customAd:A,actionDetail:B,onOpenWebview:O=>{R==null||R(O)},onError:O=>{d==null||d(O)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL"})},h=o=>{var B;(B=o==null?void 0:o.stopPropagation)==null||B.call(o),x==null||x(v("custom"))};return j&&_?oe(_,{className:S,unitId:e,adIntervals:n,onLoad:N,onError:re,onClose:T}):!A||!A.image||X?null:be(he,{className:S,children:[be(he,{className:"bi-banner-ad__surface",onClick:G,children:[be(he,{className:"bi-banner-ad__media",children:[oe(We,{className:"bi-banner-ad__badge bi-banner-ad__badge--overlay",children:Pe(A)}),oe(Nt,{className:"bi-banner-ad__image",src:A.image||"",mode:"aspectFill",onLoad:Q,onError:p})]}),be(he,{className:"bi-banner-ad__content",children:[oe(he,{className:"bi-banner-ad__body",children:A.title?oe(We,{className:"bi-banner-ad__title",children:A.title}):null}),be(he,{className:"bi-banner-ad__footer",children:[A.description?oe(We,{className:"bi-banner-ad__description",children:A.description}):null,oe(ot,{className:"bi-banner-ad__button",onClick:G,children:A.buttonText||"\u7ACB\u5373\u67E5\u770B"})]})]})]}),oe(ot,{className:"bi-banner-ad__close",onClick:h,children:"\xD7"})]})};import{useCallback as z,useEffect as $e,useMemo as te,useRef as F,useState as Ae}from"react";import{View as K,Image as lt,Video as xt,Button as Et,Text as Re}from"@tarojs/components";import{Fragment as Pt,jsx as M,jsxs as Be}from"react/jsx-runtime";var je=({unitId:e="",customAd:i,show:n=!0,zIndex:g=999,pictureInPicture:c=!1,checkNativeSplash:d=!0,jumpSeconds:x=5,className:$,onLoad:R,onError:_,onClose:j,onAction:H,onHide:I,onOpenWebview:k})=>{let X=te(()=>xe(),[]),C=!!(e&&X),[A,S]=Ae(!1),[v,E]=Ae(C),[y,N]=Ae(!1),[re,T]=Ae(0),[Q,p]=Ae(!1),[G,h]=Ae(!1),o=F(null),B=F(null),Y=F(null),O=F(null),le=F(null),ie=F(0),Z=F(!1),D=F(!1),U=F(R),f=F(_),L=F(j),ue=F(H),pe=F(I),me=F(k),l=i||null,se=te(()=>Xe(l),[l]),_e=te(()=>Qe(l,se),[l,se]),ae=!!se,ye=te(()=>Ze(l,se),[l,se]),ke=te(()=>et(l),[l]),Te=te(()=>Pe(l),[l]),P=te(()=>tt(l,x),[l,x]),we=te(()=>nt(),[]),{contentStyle:Ie,badgeStyle:Ne}=te(()=>rt(),[]),Ue=te(()=>{let a=["bi-splash-ad"];return y&&a.push("bi-splash-ad--pip"),G&&a.push("bi-splash-ad--pip-animating"),$&&a.push($),a.join(" ")},[$,G,y]);$e(()=>{U.current=R,f.current=_,L.current=j,ue.current=H,pe.current=I,me.current=k},[H,j,_,I,R,k]);let J=a=>({provider:a,type:"splash"});$e(()=>{var a;!n||!e||X||(a=f.current)==null||a.call(f,W(m({},J("wechat")),{errCode:"BI_SPLASH_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"}))},[X,n,e]);let b=z(()=>{o.current&&(clearInterval(o.current),o.current=null),B.current&&(clearTimeout(B.current),B.current=null)},[]),fe=z(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)},[]),t=z(()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]),r=z(()=>{le.current&&(clearTimeout(le.current),le.current=null)},[]),s=z(()=>{b(),fe(),t(),r()},[b,fe,r,t]),q=z(a=>{var u;s(),S(!1),N(!1),T(0),p(!1),D.current=!1,h(!1),(u=L.current)==null||u.call(L,a)},[s]),ce=z(()=>{let a=v?"wechat":"custom";if(c){b(),fe(),r(),h(!0),le.current=setTimeout(()=>{var u;le.current=null,N(!0),h(!1),(u=pe.current)==null||u.call(pe,J(a))},280);return}q({type:"splash",provider:a})},[b,fe,r,q,v,c]),w=z(()=>{if(b(),P<=0){ce();return}T(P),o.current=setInterval(()=>{T(a=>a<=1?(b(),B.current=setTimeout(()=>{B.current=null,ce()},0),0):a-1)},1e3)},[b,P,ce]),Ye=z(a=>{!n||!C||!a||y||w()},[C,n,y,w]),De=z(()=>{let a=!!(!Z.current&&(C||ae));s(),E(C),S(a),N(!1),T(P),p(!1),D.current=!1,h(!1),Ye(a),a&&!C&&ae&&(Y.current=setTimeout(()=>{var u;D.current||(s(),S(!1),N(!1),T(0),p(!1),D.current=!1,h(!1),(u=f.current)==null||u.call(f,W(m({},J("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},ve(l)))},[C,s,P,ae,l,Ye]),Le=z(()=>{if(!n)return;if(!d){Z.current=!1,De();return}if(Z.current){S(!1);return}let a=Ee();if(!a||typeof a.getShowSplashAdStatus!="function"||ie.current>=3){De();return}a.getShowSplashAdStatus({success:u=>{var V;if((u==null?void 0:u.code)===-1){ie.current+=1,t(),O.current=setTimeout(()=>{O.current=null,Le()},300);return}if((u==null?void 0:u.code)===1){s(),S(!1),Z.current=!0,(V=U.current)==null||V.call(U,{provider:"wechat",type:"splash",nativeSplash:!0});return}De()},fail:()=>{De()}})},[C,d,s,t,ae,De,n]);$e(()=>{if(!n){s(),S(!1),E(C),N(!1),T(0),p(!1),D.current=!1,h(!1),Z.current=!1;return}if(ie.current=0,!d)Z.current=!1;else if(Z.current)return s(),E(C),S(!1),N(!1),T(0),p(!1),D.current=!1,h(!1),()=>{s()};return s(),E(C),S(!1),N(!1),T(P),p(!1),D.current=!1,h(!1),Le(),()=>{s()}},[C,d,Le,s,P,n]);let dt=a=>{var u;w(),(u=U.current)==null||u.call(U,ee(a,J("wechat")))},pt=a=>{var u;if(v){if(s(),ae){E(!1),S(!0),N(!1),T(P),p(!1),D.current=!1,h(!1),Y.current=setTimeout(()=>{var V;D.current||(s(),S(!1),N(!1),T(0),p(!1),D.current=!1,h(!1),(V=f.current)==null||V.call(f,W(m({},J("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},ve(l));return}S(!1),N(!1),T(0),p(!1),D.current=!1,h(!1),(u=L.current)==null||u.call(L,{provider:"wechat",type:"splash",reason:"wechatAdLoadFail",error:a})}},mt=a=>{var ge;let u=a&&typeof a.detail=="object"?a.detail:{},V=W(m({},ee(a,J("wechat"))),{errCode:"BI_SPLASH_WECHAT_AD_LOAD_FAIL",errMsg:String(u.errMsg||"\u5FAE\u4FE1\u5F00\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:u.errCode,rawErrMsg:u.errMsg});(ge=f.current)==null||ge.call(f,V),pt(V)},ft=a=>{q(ee(a,J("wechat")))},qe=()=>{var a;D.current||(fe(),D.current=!0,p(!0),w(),(a=U.current)==null||a.call(U,J("custom")))},gt=(a,u)=>{var V;s(),S(!1),N(!1),T(0),p(!1),D.current=!1,h(!1),(V=f.current)==null||V.call(f,m(m({},ee(a,J("custom"))),u))},Je=a=>{gt(a,{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},ht=()=>{var V;let a=v?"wechat":"custom",u=J(a);(V=ue.current)==null||V.call(ue,u),a==="custom"&&Me({customAd:l,actionDetail:u,onOpenWebview:ge=>{var Ce;(Ce=me.current)==null||Ce.call(me,ge)},onError:ge=>{var Ce;(Ce=f.current)==null||Ce.call(f,ge)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL"})},At=()=>{q({type:"splash",provider:v?"wechat":"custom"})},Oe=v?X:null;return!A||!!!Oe&&!ae?null:Be(K,{className:Ue,style:{zIndex:g},children:[Oe?M(K,{className:"bi-splash-ad__popup",children:M(K,{className:`bi-splash-ad__media-wrapper${y?" bi-splash-ad__media-wrapper--pip":""}`,children:M(Oe,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:dt,onError:mt,onClose:ft})})}):M(K,{className:"bi-splash-ad__popup",children:Be(K,{className:"bi-splash-ad__media-shell",onClick:ht,children:[ye?M(lt,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:se,mode:"aspectFill",onLoad:qe,onError:Je}):Be(Pt,{children:[M(lt,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:_e,mode:"aspectFill"}),M(xt,{className:`bi-splash-ad__video${ke===1?" bi-splash-ad__video--landscape":""}`,src:se,poster:_e,autoplay:!0,muted:(l==null?void 0:l.muted)!==!1,loop:!0,objectFit:"cover",showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:qe,onError:Je})]}),y?M(K,{className:"bi-splash-ad__pip-mask"}):null,y?null:M(K,{className:"bi-splash-ad__badge",style:Ne,children:Te}),l&&(l.title||!y&&(l.description||l.buttonText))?Be(K,{className:"bi-splash-ad__content",style:Ie,children:[l.title?M(Re,{className:"bi-splash-ad__title",children:l.title}):null,!y&&l.description?M(Re,{className:"bi-splash-ad__description",children:l.description}):null,!y&&l.buttonText?M(Et,{className:"bi-splash-ad__action",children:l.buttonText}):null]}):null]})}),y?M(K,{className:"bi-splash-ad__pip-close",onClick:At,children:M(K,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,y?null:Be(K,{className:"bi-splash-ad__skip",style:we,onClick:ce,children:[Be(Re,{children:[re,"s"]}),M(K,{className:"bi-splash-ad__skip-divider"}),M(Re,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};import{useEffect as He,useMemo as Mt,useRef as ne,useState as Ge}from"react";import{jsx as ct}from"react/jsx-runtime";var ut=["banner","splash"],Rt=({adId:e="",unitId:i,type:n="banner",customAd:g,adOptions:c=null,sdkKey:d="biNova",autoLoad:x=!0,adIntervals:$=30,show:R=!0,zIndex:_=999,pictureInPicture:j=!1,checkNativeSplash:H=!0,jumpSeconds:I=5,className:k,onLoad:X,onError:C,onClose:A,onAction:S,onHide:v,onOpenWebview:E,onConfigLoad:y,onConfigError:N})=>{let re=ne(0),T=ne(""),Q=ne(X),p=ne(C),G=ne(A),h=ne(S),o=ne(v),B=ne(E),Y=ne(y),O=ne(N),[le,ie]=Ge(!1),[Z,D]=Ge(!1),[U,f]=Ge(null);He(()=>{Q.current=X,p.current=C,G.current=A,h.current=S,o.current=v,B.current=E,Y.current=y,O.current=N},[S,A,N,y,C,v,X,E]);let L=Mt(()=>ut.includes(n)?n:"banner",[n]),ue=()=>!!(x&&e),pe=()=>{var q;let t=globalThis.getApp,r=typeof t=="function"?t():null;if(!r)return null;let s=r;return s[d]||((q=s.globalData)==null?void 0:q[d])||null},me=()=>{var t;try{if(typeof wx!="undefined"&&typeof wx.getAccountInfoSync=="function"){let r=wx.getAccountInfoSync();return((t=r==null?void 0:r.miniProgram)==null?void 0:t.appId)||""}}catch(r){return""}return""},l=()=>{re.current+=1,T.current="",ie(!1),D(!1),f(null)},se=()=>{let t=c&&typeof c=="object"?c:{},r=me();return W(m({},t),{adId:e,placementId:t.placementId||e,appId:t.appId||r,type:L})},_e=t=>{try{return JSON.stringify(t||{})}catch(r){return`${String(t.appId||"")}_${String(t.placementId||"")}`}},ae=t=>{let r=(t==null?void 0:t.unitId)||"",s=(t==null?void 0:t.customAd)||(t==null?void 0:t.custom)||null,q=typeof(t==null?void 0:t.show)=="boolean"?t.show:!!(r||s);return{unitId:r,customAd:s,show:q}},ye=t=>{var r,s;(r=O.current)==null||r.call(O,t),(s=p.current)==null||s.call(p,t)},ke=async()=>{var ce;if(!ue())return;let t=se(),r=_e(t);if(T.current===r&&(le||Z))return;let s=pe();if(!(s!=null&&s.ads)||typeof s.ads.getDisplayAdConfig!="function"){l(),ye({type:L,adId:e,errCode:"DISPLAY_AD_SDK_NOT_READY",errMsg:"\u672A\u83B7\u53D6\u5230\u53EF\u7528\u7684\u5E7F\u544A\u670D\u52A1 SDK\uFF0C\u8BF7\u5148\u6CE8\u5165\u5168\u5C40 biNova \u5B9E\u4F8B"});return}let q=re.current+1;re.current=q,T.current=r,ie(!0),D(!1),f(null);try{let w=await s.ads.getDisplayAdConfig(t);if(q!==re.current)return;if(!w||w.code!==0||!w.data){ie(!1),D(!0),f(null),ye({type:L,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(w==null?void 0:w.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:w||null});return}ie(!1),D(!0),f(w.data),(ce=Y.current)==null||ce.call(Y,{type:L,adId:e,requestOptions:t,data:w.data})}catch(w){if(q!==re.current)return;ie(!1),D(!0),f(null),ye({type:L,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:w instanceof Error?w.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:w})}};He(()=>{var t;ut.includes(n)||(t=p.current)==null||t.call(p,{type:"banner",errCode:"UNSUPPORTED_DISPLAY_AD_TYPE",errMsg:`\u4E0D\u652F\u6301\u7684\u5C55\u793A\u5E7F\u544A\u7C7B\u578B\uFF1A${n}\uFF0C\u8BF7\u4F7F\u7528 "banner" \u6216 "splash"`})},[n]),He(()=>{if(!e){l();return}ke()},[e,c,x,L,d]);let Te=ue(),P=Te?ae(U):null,we=P?P.unitId:i||"",Ie=P?P.customAd:g||null,Ne=!!(R&&(!Te||!e||Z&&(P!=null&&P.show))),Ue=!!H,J=e||(U==null?void 0:U.adId)||"",b=t=>m({adId:J},t);return L==="splash"?ct(je,m({},{unitId:we,customAd:Ie,show:Ne,zIndex:_,pictureInPicture:j,checkNativeSplash:Ue,jumpSeconds:I,className:k,onLoad:r=>{var s;(s=Q.current)==null||s.call(Q,b(r))},onError:r=>{var s;(s=p.current)==null||s.call(p,b(r))},onClose:r=>{var s;(s=G.current)==null||s.call(G,b(r))},onAction:r=>{var s;(s=h.current)==null||s.call(h,b(r))},onHide:r=>{var s;(s=o.current)==null||s.call(o,b(r))},onOpenWebview:r=>{var s;(s=B.current)==null||s.call(B,b(r))}})):Ne?ct(Fe,m({},{unitId:we,customAd:Ie,adIntervals:$,className:k,onLoad:t=>{var r;(r=Q.current)==null||r.call(Q,b(t))},onError:t=>{var r;(r=p.current)==null||r.call(p,b(t))},onClose:t=>{var r;(r=G.current)==null||r.call(G,b(t))},onAction:t=>{var r;(r=h.current)==null||r.call(h,b(t))},onOpenWebview:t=>{var r;(r=B.current)==null||r.call(B,b(t))}})):null};export{Fe as BiBannerAd,Rt as BiDisplayAd,je as BiSplashAd};
|
|
1
|
+
var Bt=Object.defineProperty,yt=Object.defineProperties;var Dt=Object.getOwnPropertyDescriptors;var Xe=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Qe=(e,i,r)=>i in e?Bt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,h=(e,i)=>{for(var r in i||(i={}))Ct.call(i,r)&&Qe(e,r,i[r]);if(Xe)for(var r of Xe(i))St.call(i,r)&&Qe(e,r,i[r]);return e},W=(e,i)=>yt(e,Dt(i));import"./banner/index.scss";import"./splash/index.scss";import{useCallback as st,useEffect as $e,useMemo as ot,useRef as de,useState as Et}from"react";import{View as Be,Image as It,Button as lt,Text as je}from"@tarojs/components";import*as vt from"@tarojs/components";var Te;function Re(){if(Te!==void 0)return Te;try{let e=vt;Te=(e==null?void 0:e.AdCustom)||null}catch(e){Te=null}return Te}import*as fe from"@tarojs/taro";function ke(){return typeof wx!="undefined"?wx:null}function se(e,i){let r=e==null?void 0:e.detail;return r&&typeof r=="object"?h(h({},i),r):e&&typeof e=="object"?h(h({},i),e):h({},i)}function Ze(e){return e&&(e.image||e.video)||""}function et(e,i=""){return e&&(e.poster||e.image||i)||""}function tt(e,i=""){return e?e.video?!1:e.image?!0:/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(String(i).trim()):!0}function nt(e){if(!e)return 2;let i=Number(e.adSpec||e.spec||0);if(i===1||i===2)return i;let r=Number(e.videoWidth||e.width||0),y=Number(e.videoHeight||e.height||0);return r>0&&y>0?r>y?1:2:e.video?1:2}function Le(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function rt(e,i=5){let r=e==null?void 0:e.jumpSeconds,y=r!=null?r:i;return Math.min(99,Math.max(0,Number(y)||0))}function we(e){var r;let i=(r=e==null?void 0:e.loadTimeout)!=null?r:e==null?void 0:e.timeout;return Math.max(1e3,Number(i)||5e3)}function bt(e){return e?e.appId||e.miniProgramAppId||e.jumpAppId?"miniProgram":e.path||e.pagePath||e.jumpPath||e.targetUrl?"internal":e.url||e.webUrl||e.h5Url?"web":"none":"none"}function _t(e){return e&&(e.appId||e.miniProgramAppId||e.jumpAppId)||""}function Tt(e){return e&&(e.path||e.pagePath||e.jumpPath||e.targetUrl)||""}function wt(e){return e&&(e.url||e.webUrl||e.h5Url)||""}function Ue(e){let{customAd:i,actionDetail:r,onOpenWebview:y,onError:f,miniProgramErrorCode:E,navigateErrorCode:F,miniProgramUnsupportedErrorCode:$}=e;if(!i)return;let T=bt(i),w=_t(i),j=Tt(i),H=wt(i);if(T==="miniProgram"&&w){let I=ke();if(!I||typeof I.navigateToMiniProgram!="function"){f==null||f(W(h({},r),{errCode:$||E,errMsg:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}I.navigateToMiniProgram({appId:w,path:j||"",fail:M=>{f==null||f(W(h({},r),{errCode:E,errMsg:(M==null?void 0:M.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(T==="internal"&&j){fe.navigateTo({url:j,fail:I=>{f==null||f(W(h({},r),{errCode:F,errMsg:(I==null?void 0:I.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}T==="web"&&H&&(y==null||y(W(h({},r),{url:H})))}function it(){let e=ke(),i=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},r=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof fe.getSystemInfoSync=="function"?fe.getSystemInfoSync():{},y=r.windowHeight===r.screenHeight,f=16,E=16,F=16,$=32,T=y&&i.top?i.top:f,w=y&&i.height?i.height:$;return{top:`${T}px`,width:"156rpx",height:`${w}px`,lineHeight:`${w}px`,borderRadius:`${Math.round(w/2)}px`,left:y?`${F}px`:void 0,right:y?void 0:`${E}px`}}function at(){var f;let e=typeof fe.getSystemInfoSync=="function"?fe.getSystemInfoSync():{},i=Math.max(0,Number(e.screenHeight||0)-Number(((f=e.safeArea)==null?void 0:f.bottom)||e.windowHeight||0)),r=i>0?i+42:84,y=i>0?i+88:130;return{contentStyle:{bottom:`${r}rpx`},badgeStyle:{bottom:`${y}rpx`}}}import{jsx as pe,jsxs as Ee}from"react/jsx-runtime";var He=({unitId:e="",customAd:i,adIntervals:r=30,className:y,onLoad:f,onError:E,onClose:F,onAction:$,onOpenWebview:T})=>{let w=ot(()=>Re(),[]),j=!!(e&&w),H=de(null),I=de(!1),M=de(!1),N=de(f),c=de(E),G=de(F),C=de($),R=de(T),[Q,v]=Et(!1),l=i||null,ne=ot(()=>`bi-banner-ad${y?` ${y}`:""}`,[y]);$e(()=>{N.current=f,c.current=E,G.current=F,C.current=$,R.current=T},[$,F,E,f,T]);let B=o=>({provider:o,type:"banner"}),k=st(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]),m=st((o,d)=>{var A;M.current||(M.current=!0,k(),v(!0),(A=c.current)==null||A.call(c,h(h({},se(o,B("custom"))),d)))},[k]);$e(()=>{if(k(),I.current=!1,M.current=!1,v(!1),!(j||!(l!=null&&l.image)))return H.current=setTimeout(()=>{m(void 0,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})},we(l)),()=>{k()}},[k,l,j,m]),$e(()=>{var o;!e||w||(o=c.current)==null||o.call(c,W(h({},B("wechat")),{errCode:"BI_BANNER_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"}))},[w,e]);let L=o=>{var d;(d=N.current)==null||d.call(N,se(o,B("wechat")))},D=o=>{var d;(d=c.current)==null||d.call(c,se(o,B("wechat")))},Z=o=>{var d;(d=G.current)==null||d.call(G,se(o,B("wechat")))},U=()=>{var o;I.current||M.current||(k(),I.current=!0,(o=N.current)==null||o.call(N,B("custom")))},z=o=>{m(o,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},Y=o=>{var A,b;(A=o==null?void 0:o.stopPropagation)==null||A.call(o);let d=B("custom");(b=C.current)==null||b.call(C,d),Ue({customAd:l,actionDetail:d,onOpenWebview:g=>{var _;(_=R.current)==null||_.call(R,g)},onError:g=>{var _;(_=c.current)==null||_.call(c,g)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL"})},re=o=>{var d,A;(d=o==null?void 0:o.stopPropagation)==null||d.call(o),(A=G.current)==null||A.call(G,B("custom"))};return j&&w?pe(w,{className:ne,unitId:e,adIntervals:r,onLoad:L,onError:D,onClose:Z}):!l||!l.image||Q?null:Ee(Be,{className:ne,children:[Ee(Be,{className:"bi-banner-ad__surface",onClick:Y,children:[Ee(Be,{className:"bi-banner-ad__media",children:[pe(je,{className:"bi-banner-ad__badge bi-banner-ad__badge--overlay",children:Le(l)}),pe(It,{className:"bi-banner-ad__image",src:l.image||"",mode:"aspectFill",onLoad:U,onError:z})]}),Ee(Be,{className:"bi-banner-ad__content",children:[pe(Be,{className:"bi-banner-ad__body",children:l.title?pe(je,{className:"bi-banner-ad__title",children:l.title}):null}),Ee(Be,{className:"bi-banner-ad__footer",children:[l.description?pe(je,{className:"bi-banner-ad__description",children:l.description}):null,pe(lt,{className:"bi-banner-ad__button",onClick:Y,children:l.buttonText||"\u7ACB\u5373\u67E5\u770B"})]})]})]}),pe(lt,{className:"bi-banner-ad__close",onClick:re,children:"\xD7"})]})};import{useCallback as ee,useEffect as Ge,useMemo as oe,useRef as V,useState as ye}from"react";import{View as X,Image as ut,Video as Nt,Button as xt,Text as Oe}from"@tarojs/components";import{Fragment as Pt,jsx as P,jsxs as De}from"react/jsx-runtime";var Ye=({unitId:e="",customAd:i,show:r=!0,zIndex:y=999,pictureInPicture:f=!1,checkNativeSplash:E=!0,jumpSeconds:F=5,className:$,onLoad:T,onError:w,onClose:j,onAction:H,onHide:I,onOpenWebview:M})=>{let N=oe(()=>Re(),[]),c=!!(e&&N),[G,C]=ye(!1),[R,Q]=ye(c),[v,l]=ye(!1),[ne,B]=ye(0),[k,m]=ye(!1),[L,D]=ye(!1),Z=V(null),U=V(null),z=V(null),Y=V(null),re=V(null),o=V(0),d=V(!1),A=V(!1),b=V(T),g=V(w),_=V(j),q=V(H),me=V(I),Ae=V(M),u=i||null,ie=oe(()=>Ze(u),[u]),Ie=oe(()=>et(u,ie),[u,ie]),ce=!!ie,Ne=oe(()=>tt(u,ie),[u,ie]),Ce=oe(()=>nt(u),[u]),We=oe(()=>Le(u),[u]),ae=oe(()=>rt(u,F),[u,F]),xe=oe(()=>it(),[]),{contentStyle:le,badgeStyle:Pe}=oe(()=>at(),[]),Me=oe(()=>{let a=["bi-splash-ad"];return v&&a.push("bi-splash-ad--pip"),L&&a.push("bi-splash-ad--pip-animating"),$&&a.push($),a.join(" ")},[$,L,v]);Ge(()=>{b.current=T,g.current=w,_.current=j,q.current=H,me.current=I,Ae.current=M},[H,j,w,I,T,M]);let J=a=>({provider:a,type:"splash"});Ge(()=>{var a;!r||!e||N||(a=g.current)==null||a.call(g,W(h({},J("wechat")),{errCode:"BI_SPLASH_NATIVE_AD_UNSUPPORTED",errMsg:"\u5F53\u524D\u7AEF\u4E0D\u652F\u6301\u5FAE\u4FE1\u539F\u751F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7EC4\u4EF6"}))},[N,r,e]);let ue=ee(()=>{Z.current&&(clearInterval(Z.current),Z.current=null),U.current&&(clearTimeout(U.current),U.current=null)},[]),ge=ee(()=>{z.current&&(clearTimeout(z.current),z.current=null)},[]),x=ee(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)},[]),Se=ee(()=>{re.current&&(clearTimeout(re.current),re.current=null)},[]),t=ee(()=>{ue(),ge(),x(),Se()},[ue,ge,Se,x]),n=ee(a=>{var p;t(),C(!1),l(!1),B(0),m(!1),A.current=!1,D(!1),(p=_.current)==null||p.call(_,a)},[t]),s=ee(()=>{let a=R?"wechat":"custom";if(f){ue(),ge(),Se(),D(!0),re.current=setTimeout(()=>{var p;re.current=null,l(!0),D(!1),(p=me.current)==null||p.call(me,J(a))},280);return}n({type:"splash",provider:a})},[ue,ge,Se,n,R,f]),K=ee(()=>{if(ue(),ae<=0){s();return}B(ae),Z.current=setInterval(()=>{B(a=>a<=1?(ue(),U.current=setTimeout(()=>{U.current=null,s()},0),0):a-1)},1e3)},[ue,ae,s]),ve=ee(a=>{!r||!c||!a||v||K()},[c,r,v,K]),S=ee(()=>{let a=!!(!d.current&&(c||ce));t(),Q(c),C(a),l(!1),B(ae),m(!1),A.current=!1,D(!1),ve(a),a&&!c&&ce&&(z.current=setTimeout(()=>{var p;A.current||(t(),C(!1),l(!1),B(0),m(!1),A.current=!1,D(!1),(p=g.current)==null||p.call(g,W(h({},J("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},we(u)))},[c,t,ae,ce,u,ve]),be=ee(()=>{if(!r)return;if(!E){d.current=!1,S();return}if(d.current){C(!1);return}let a=ke();if(!a||typeof a.getShowSplashAdStatus!="function"||o.current>=3){S();return}a.getShowSplashAdStatus({success:p=>{var O;if((p==null?void 0:p.code)===-1){o.current+=1,x(),Y.current=setTimeout(()=>{Y.current=null,be()},300);return}if((p==null?void 0:p.code)===1){t(),C(!1),d.current=!0,(O=b.current)==null||O.call(b,{provider:"wechat",type:"splash",nativeSplash:!0});return}S()},fail:()=>{S()}})},[c,E,t,x,ce,S,r]);Ge(()=>{if(!r){t(),C(!1),Q(c),l(!1),B(0),m(!1),A.current=!1,D(!1),d.current=!1;return}if(o.current=0,!E)d.current=!1;else if(d.current)return t(),Q(c),C(!1),l(!1),B(0),m(!1),A.current=!1,D(!1),()=>{t()};return t(),Q(c),C(!1),l(!1),B(ae),m(!1),A.current=!1,D(!1),be(),()=>{t()}},[c,E,be,t,ae,r]);let Ve=a=>{var p;K(),(p=b.current)==null||p.call(b,se(a,J("wechat")))},pt=a=>{var p;if(R){if(t(),ce){Q(!1),C(!0),l(!1),B(ae),m(!1),A.current=!1,D(!1),z.current=setTimeout(()=>{var O;A.current||(t(),C(!1),l(!1),B(0),m(!1),A.current=!1,D(!1),(O=g.current)==null||O.call(g,W(h({},J("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},we(u));return}C(!1),l(!1),B(0),m(!1),A.current=!1,D(!1),(p=_.current)==null||p.call(_,{provider:"wechat",type:"splash",reason:"wechatAdLoadFail",error:a})}},mt=a=>{var he;let p=a&&typeof a.detail=="object"?a.detail:{},O=W(h({},se(a,J("wechat"))),{errCode:"BI_SPLASH_WECHAT_AD_LOAD_FAIL",errMsg:String(p.errMsg||"\u5FAE\u4FE1\u5F00\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:p.errCode,rawErrMsg:p.errMsg});(he=g.current)==null||he.call(g,O),pt(O)},gt=a=>{n(se(a,J("wechat")))},Ke=()=>{var a;A.current||(ge(),A.current=!0,m(!0),K(),(a=b.current)==null||a.call(b,J("custom")))},ft=(a,p)=>{var O;t(),C(!1),l(!1),B(0),m(!1),A.current=!1,D(!1),(O=g.current)==null||O.call(g,h(h({},se(a,J("custom"))),p))},ze=a=>{ft(a,{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},At=()=>{var O;let a=R?"wechat":"custom",p=J(a);(O=q.current)==null||O.call(q,p),a==="custom"&&Ue({customAd:u,actionDetail:p,onOpenWebview:he=>{var _e;(_e=Ae.current)==null||_e.call(Ae,he)},onError:he=>{var _e;(_e=g.current)==null||_e.call(g,he)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL"})},ht=()=>{n({type:"splash",provider:R?"wechat":"custom"})},Fe=R?N:null;return!G||!!!Fe&&!ce?null:De(X,{className:Me,style:{zIndex:y},children:[Fe?P(X,{className:"bi-splash-ad__popup",children:P(X,{className:`bi-splash-ad__media-wrapper${v?" bi-splash-ad__media-wrapper--pip":""}`,children:P(Fe,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:Ve,onError:mt,onClose:gt})})}):P(X,{className:"bi-splash-ad__popup",children:De(X,{className:"bi-splash-ad__media-shell",onClick:At,children:[Ne?P(ut,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:ie,mode:"aspectFill",onLoad:Ke,onError:ze}):De(Pt,{children:[P(ut,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:Ie,mode:"aspectFill"}),P(Nt,{className:`bi-splash-ad__video${Ce===1?" bi-splash-ad__video--landscape":""}`,src:ie,poster:Ie,autoplay:!0,muted:(u==null?void 0:u.muted)!==!1,loop:!0,objectFit:"cover",showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:Ke,onError:ze})]}),v?P(X,{className:"bi-splash-ad__pip-mask"}):null,v?null:P(X,{className:"bi-splash-ad__badge",style:Pe,children:We}),u&&(u.title||!v&&(u.description||u.buttonText))?De(X,{className:"bi-splash-ad__content",style:le,children:[u.title?P(Oe,{className:"bi-splash-ad__title",children:u.title}):null,!v&&u.description?P(Oe,{className:"bi-splash-ad__description",children:u.description}):null,!v&&u.buttonText?P(xt,{className:"bi-splash-ad__action",children:u.buttonText}):null]}):null]})}),v?P(X,{className:"bi-splash-ad__pip-close",onClick:ht,children:P(X,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,v?null:De(X,{className:"bi-splash-ad__skip",style:xe,onClick:s,children:[De(Oe,{children:[ne,"s"]}),P(X,{className:"bi-splash-ad__skip-divider"}),P(Oe,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};import{useEffect as qe,useMemo as Mt,useRef as te,useState as Je}from"react";import{jsx as dt}from"react/jsx-runtime";var ct=["banner","splash"],Rt=({adId:e="",unitId:i,type:r="banner",customAd:y,adOptions:f=null,sdkKey:E="biNova",autoLoad:F=!0,adIntervals:$=30,show:T=!0,zIndex:w=999,pictureInPicture:j=!1,checkNativeSplash:H=!0,jumpSeconds:I=5,className:M,onLoad:N,onError:c,onClose:G,onAction:C,onHide:R,onOpenWebview:Q,onConfigLoad:v,onConfigError:l})=>{let ne=te(0),B=te(""),k=te(N),m=te(c),L=te(G),D=te(C),Z=te(R),U=te(Q),z=te(v),Y=te(l),re=te(T),[o,d]=Je(!1),[A,b]=Je(!1),[g,_]=Je(null);qe(()=>{k.current=N,m.current=c,L.current=G,D.current=C,Z.current=R,U.current=Q,z.current=v,Y.current=l,re.current=T},[C,G,l,v,c,R,N,Q,T]);let q=Mt(()=>ct.includes(r)?r:"banner",[r]),me=()=>!!(F&&e),Ae=()=>{var K;let t=globalThis.getApp,n=typeof t=="function"?t():null;if(!n)return null;let s=n;return s[E]||((K=s.globalData)==null?void 0:K[E])||null},u=()=>{var t;try{if(typeof wx!="undefined"&&typeof wx.getAccountInfoSync=="function"){let n=wx.getAccountInfoSync();return((t=n==null?void 0:n.miniProgram)==null?void 0:t.appId)||""}}catch(n){return""}return""},ie=()=>{ne.current+=1,B.current="",d(!1),b(!1),_(null)},Ie=()=>{let t=f&&typeof f=="object"?f:{},n=u();return W(h({},t),{adId:e,placementId:t.placementId||e,appId:t.appId||n,type:q})},ce=t=>{try{return JSON.stringify(t||{})}catch(n){return`${String(t.appId||"")}_${String(t.placementId||"")}`}},Ne=t=>{let n=(t==null?void 0:t.unitId)||"",s=(t==null?void 0:t.customAd)||(t==null?void 0:t.custom)||null,K=typeof(t==null?void 0:t.show)=="boolean"?t.show:!!(n||s);return{unitId:n,customAd:s,show:K}},Ce=t=>{var n,s;(n=Y.current)==null||n.call(Y,t),(s=m.current)==null||s.call(m,t)},We=t=>{var n;(n=L.current)==null||n.call(L,{type:q,adId:e||t.adId||"",provider:"none",reason:"noAd"})},ae=async()=>{var ve;if(!me())return;let t=Ie(),n=ce(t);if(B.current===n&&(o||A))return;let s=Ae();if(!(s!=null&&s.ads)||typeof s.ads.getDisplayAdConfig!="function"){ie(),Ce({type:q,adId:e,errCode:"DISPLAY_AD_SDK_NOT_READY",errMsg:"\u672A\u83B7\u53D6\u5230\u53EF\u7528\u7684\u5E7F\u544A\u670D\u52A1 SDK\uFF0C\u8BF7\u5148\u6CE8\u5165\u5168\u5C40 biNova \u5B9E\u4F8B"});return}let K=ne.current+1;ne.current=K,B.current=n,d(!0),b(!1),_(null);try{let S=await s.ads.getDisplayAdConfig(t);if(K!==ne.current)return;if(!S||S.code!==0||!S.data){d(!1),b(!0),_(null),Ce({type:q,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(S==null?void 0:S.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:S||null});return}let be=Ne(S.data),Ve=!!(re.current&&!be.show);d(!1),b(!0),_(S.data),(ve=z.current)==null||ve.call(z,{type:q,adId:e,requestOptions:t,data:S.data}),Ve&&We(S.data)}catch(S){if(K!==ne.current)return;d(!1),b(!0),_(null),Ce({type:q,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:S instanceof Error?S.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:S})}};qe(()=>{var t;ct.includes(r)||(t=m.current)==null||t.call(m,{type:"banner",errCode:"UNSUPPORTED_DISPLAY_AD_TYPE",errMsg:`\u4E0D\u652F\u6301\u7684\u5C55\u793A\u5E7F\u544A\u7C7B\u578B\uFF1A${r}\uFF0C\u8BF7\u4F7F\u7528 "banner" \u6216 "splash"`})},[r]),qe(()=>{if(!e){ie();return}ae()},[e,f,F,q,E]);let xe=me(),le=xe?Ne(g):null,Pe=le?le.unitId:i||"",Me=le?le.customAd:y||null,J=!!(T&&(!xe||!e||A&&(le!=null&&le.show))),ue=!!H,ge=e||(g==null?void 0:g.adId)||"",x=t=>h({adId:ge},t);return q==="splash"?dt(Ye,h({},{unitId:Pe,customAd:Me,show:J,zIndex:w,pictureInPicture:j,checkNativeSplash:ue,jumpSeconds:I,className:M,onLoad:n=>{var s;(s=k.current)==null||s.call(k,x(n))},onError:n=>{var s;(s=m.current)==null||s.call(m,x(n))},onClose:n=>{var s;(s=L.current)==null||s.call(L,x(n))},onAction:n=>{var s;(s=D.current)==null||s.call(D,x(n))},onHide:n=>{var s;(s=Z.current)==null||s.call(Z,x(n))},onOpenWebview:n=>{var s;(s=U.current)==null||s.call(U,x(n))}})):J?dt(He,h({},{unitId:Pe,customAd:Me,adIntervals:$,className:M,onLoad:t=>{var n;(n=k.current)==null||n.call(k,x(t))},onError:t=>{var n;(n=m.current)==null||n.call(m,x(t))},onClose:t=>{var n;(n=L.current)==null||n.call(L,x(t))},onAction:t=>{var n;(n=D.current)==null||n.call(D,x(t))},onOpenWebview:t=>{var n;(n=U.current)==null||n.call(U,x(t))}})):null};export{He as BiBannerAd,Rt as BiDisplayAd,Ye as BiSplashAd};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bi-nova/ui-taro",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4-beta.202608051525",
|
|
4
4
|
"description": "BI Nova SDK Taro React UI",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@types/react": "^18.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@bi-nova/core": "1.0.1",
|
|
33
|
-
"@bi-nova/ui": "1.0.0"
|
|
32
|
+
"@bi-nova/core": "^1.0.1",
|
|
33
|
+
"@bi-nova/ui": "^1.0.0"
|
|
34
34
|
},
|
|
35
35
|
"license": "ISC",
|
|
36
36
|
"publishConfig": {
|