@bi-nova/ui-taro 1.2.4 → 1.2.5
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 +3 -2
- package/dist/ad/index.d.ts +3 -2
- package/dist/ad/index.js +1 -1
- package/dist/ad/index.mjs +1 -1
- package/package.json +1 -1
package/dist/ad/index.d.mts
CHANGED
|
@@ -111,7 +111,7 @@ declare const BiBannerAd: React.FC<BiBannerAdProps>;
|
|
|
111
111
|
* @Author wutao
|
|
112
112
|
* @Date 2026-04-14
|
|
113
113
|
* @LastEditors wutao
|
|
114
|
-
* @LastEditTime 2026-
|
|
114
|
+
* @LastEditTime 2026-08-07 10:51:08
|
|
115
115
|
*/
|
|
116
116
|
|
|
117
117
|
/**
|
|
@@ -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-08-
|
|
166
|
+
* @LastEditTime 2026-08-07 10:51:08
|
|
167
167
|
*/
|
|
168
168
|
|
|
169
169
|
/**
|
|
@@ -217,6 +217,7 @@ interface BiDisplayAdProps {
|
|
|
217
217
|
zIndex?: number;
|
|
218
218
|
pictureInPicture?: boolean;
|
|
219
219
|
checkNativeSplash?: boolean;
|
|
220
|
+
nativeSplashCache?: boolean;
|
|
220
221
|
jumpSeconds?: number;
|
|
221
222
|
className?: string;
|
|
222
223
|
onLoad?: (detail: BiDisplayAdEventDetail) => void;
|
package/dist/ad/index.d.ts
CHANGED
|
@@ -111,7 +111,7 @@ declare const BiBannerAd: React.FC<BiBannerAdProps>;
|
|
|
111
111
|
* @Author wutao
|
|
112
112
|
* @Date 2026-04-14
|
|
113
113
|
* @LastEditors wutao
|
|
114
|
-
* @LastEditTime 2026-
|
|
114
|
+
* @LastEditTime 2026-08-07 10:51:08
|
|
115
115
|
*/
|
|
116
116
|
|
|
117
117
|
/**
|
|
@@ -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-08-
|
|
166
|
+
* @LastEditTime 2026-08-07 10:51:08
|
|
167
167
|
*/
|
|
168
168
|
|
|
169
169
|
/**
|
|
@@ -217,6 +217,7 @@ interface BiDisplayAdProps {
|
|
|
217
217
|
zIndex?: number;
|
|
218
218
|
pictureInPicture?: boolean;
|
|
219
219
|
checkNativeSplash?: boolean;
|
|
220
|
+
nativeSplashCache?: boolean;
|
|
220
221
|
jumpSeconds?: number;
|
|
221
222
|
className?: string;
|
|
222
223
|
onLoad?: (detail: BiDisplayAdEventDetail) => void;
|
package/dist/ad/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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});
|
|
1
|
+
"use strict";var ut=Object.create;var Ne=Object.defineProperty,ct=Object.defineProperties,dt=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertyNames,Je=Object.getOwnPropertySymbols,gt=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var ze=(e,t,r)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t)=>{for(var r in t||(t={}))Xe.call(t,r)&&ze(e,r,t[r]);if(Je)for(var r of Je(t))ft.call(t,r)&&ze(e,r,t[r]);return e},$=(e,t)=>ct(e,pt(t));var ht=(e,t)=>{for(var r in t)Ne(e,r,{get:t[r],enumerable:!0})},Qe=(e,t,r,A)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of mt(t))!Xe.call(e,u)&&u!==r&&Ne(e,u,{get:()=>t[u],enumerable:!(A=dt(t,u))||A.enumerable});return e};var Ze=(e,t,r)=>(r=e!=null?ut(gt(e)):{},Qe(t||!e||!e.__esModule?Ne(r,"default",{value:e,enumerable:!0}):r,e)),At=e=>Qe(Ne({},"__esModule",{value:!0}),e);var _t={};ht(_t,{BiBannerAd:()=>Ve,BiDisplayAd:()=>lt,BiSplashAd:()=>We});module.exports=At(_t);var Gt=require("./banner/index.scss"),Yt=require("./splash/index.scss");var T=require("react"),O=require("@tarojs/components");var yt=Ze(require("@tarojs/components")),Ie;function Re(){if(Ie!==void 0)return Ie;try{let e=yt;Ie=(e==null?void 0:e.AdCustom)||null}catch(e){Ie=null}return Ie}var Ce=Ze(require("@tarojs/taro"));function Le(){return typeof wx!="undefined"?wx:null}function de(e,t){let r=e==null?void 0:e.detail;return r&&typeof r=="object"?h(h({},t),r):e&&typeof e=="object"?h(h({},t),e):h({},t)}function et(e){return e&&(e.image||e.video)||""}function tt(e,t=""){return e&&(e.poster||e.image||t)||""}function nt(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 rt(e){if(!e)return 2;let t=Number(e.adSpec||e.spec||0);if(t===1||t===2)return t;let r=Number(e.videoWidth||e.width||0),A=Number(e.videoHeight||e.height||0);return r>0&&A>0?r>A?1:2:e.video?1:2}function Ue(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function it(e,t=5){let r=e==null?void 0:e.jumpSeconds,A=r!=null?r:t;return Math.min(99,Math.max(0,Number(A)||0))}function xe(e){var r;let t=(r=e==null?void 0:e.loadTimeout)!=null?r: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 St(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 Oe(e){let{customAd:t,actionDetail:r,onOpenWebview:A,onError:u,miniProgramErrorCode:k,navigateErrorCode:J,miniProgramUnsupportedErrorCode:z}=e;if(!t)return;let b=Bt(t),M=St(t),X=Dt(t),j=Ct(t);if(b==="miniProgram"&&M){let E=Le();if(!E||typeof E.navigateToMiniProgram!="function"){u==null||u($(h({},r),{errCode:z||k,errMsg:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}E.navigateToMiniProgram({appId:M,path:X||"",fail:G=>{u==null||u($(h({},r),{errCode:k,errMsg:(G==null?void 0:G.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(b==="internal"&&X){Ce.navigateTo({url:X,fail:E=>{u==null||u($(h({},r),{errCode:J,errMsg:(E==null?void 0:E.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}b==="web"&&j&&(A==null||A($(h({},r),{url:j})))}function st(){let e=Le(),t=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},r=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof Ce.getSystemInfoSync=="function"?Ce.getSystemInfoSync():{},A=r.windowHeight===r.screenHeight,u=16,k=16,J=16,z=32,b=A&&t.top?t.top:u,M=A&&t.height?t.height:z;return{top:`${b}px`,width:"156rpx",height:`${M}px`,lineHeight:`${M}px`,borderRadius:`${Math.round(M/2)}px`,left:A?`${J}px`:void 0,right:A?void 0:`${k}px`}}function at(){var u;let e=typeof Ce.getSystemInfoSync=="function"?Ce.getSystemInfoSync():{},t=Math.max(0,Number(e.screenHeight||0)-Number(((u=e.safeArea)==null?void 0:u.bottom)||e.windowHeight||0)),r=t>0?t+42:84,A=t>0?t+88:130;return{contentStyle:{bottom:`${r}rpx`},badgeStyle:{bottom:`${A}rpx`}}}var H=require("react/jsx-runtime"),Ve=({unitId:e="",customAd:t,adIntervals:r=30,className:A,onLoad:u,onError:k,onClose:J,onAction:z,onOpenWebview:b})=>{let M=(0,T.useMemo)(()=>Re(),[]),X=!!(e&&M),j=(0,T.useRef)(null),E=(0,T.useRef)(!1),G=(0,T.useRef)(!1),V=(0,T.useRef)(u),p=(0,T.useRef)(k),Q=(0,T.useRef)(J),_=(0,T.useRef)(z),W=(0,T.useRef)(b),[se,N]=(0,T.useState)(!1),d=t||null,fe=(0,T.useMemo)(()=>`bi-banner-ad${A?` ${A}`:""}`,[A]);(0,T.useEffect)(()=>{V.current=u,p.current=k,Q.current=J,_.current=z,W.current=b},[z,J,k,u,b]);let f=o=>({provider:o,type:"banner"}),ae=(0,T.useCallback)(()=>{j.current&&(clearTimeout(j.current),j.current=null)},[]),w=(0,T.useCallback)((o,y)=>{var D;G.current||(G.current=!0,ae(),N(!0),(D=p.current)==null||D.call(p,h(h({},de(o,f("custom"))),y)))},[ae]);(0,T.useEffect)(()=>{if(ae(),E.current=!1,G.current=!1,N(!1),!(X||!(d!=null&&d.image)))return j.current=setTimeout(()=>{w(void 0,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})},xe(d)),()=>{ae()}},[ae,d,X,w]),(0,T.useEffect)(()=>{var o;!e||M||(o=p.current)==null||o.call(p,$(h({},f("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"}))},[M,e]);let te=o=>{var y;(y=V.current)==null||y.call(V,de(o,f("wechat")))},g=o=>{var y;(y=p.current)==null||y.call(p,de(o,f("wechat")))},R=o=>{var y;(y=Q.current)==null||y.call(Q,de(o,f("wechat")))},F=()=>{var o;E.current||G.current||(ae(),E.current=!0,(o=V.current)==null||o.call(V,f("custom")))},ne=o=>{w(o,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},U=o=>{var D,I;(D=o==null?void 0:o.stopPropagation)==null||D.call(o);let y=f("custom");(I=_.current)==null||I.call(_,y),Oe({customAd:d,actionDetail:y,onOpenWebview:B=>{var x;(x=W.current)==null||x.call(W,B)},onError:B=>{var x;(x=p.current)==null||x.call(p,B)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL"})},re=o=>{var y,D;(y=o==null?void 0:o.stopPropagation)==null||y.call(o),(D=Q.current)==null||D.call(Q,f("custom"))};return X&&M?(0,H.jsx)(M,{className:fe,unitId:e,adIntervals:r,onLoad:te,onError:g,onClose:R}):!d||!d.image||se?null:(0,H.jsxs)(O.View,{className:fe,children:[(0,H.jsxs)(O.View,{className:"bi-banner-ad__surface",onClick:U,children:[(0,H.jsxs)(O.View,{className:"bi-banner-ad__media",children:[(0,H.jsx)(O.Text,{className:"bi-banner-ad__badge bi-banner-ad__badge--overlay",children:Ue(d)}),(0,H.jsx)(O.Image,{className:"bi-banner-ad__image",src:d.image||"",mode:"aspectFill",onLoad:F,onError:ne})]}),(0,H.jsxs)(O.View,{className:"bi-banner-ad__content",children:[(0,H.jsx)(O.View,{className:"bi-banner-ad__body",children:d.title?(0,H.jsx)(O.Text,{className:"bi-banner-ad__title",children:d.title}):null}),(0,H.jsxs)(O.View,{className:"bi-banner-ad__footer",children:[d.description?(0,H.jsx)(O.Text,{className:"bi-banner-ad__description",children:d.description}):null,(0,H.jsx)(O.Button,{className:"bi-banner-ad__button",onClick:U,children:d.buttonText||"\u7ACB\u5373\u67E5\u770B"})]})]})]}),(0,H.jsx)(O.Button,{className:"bi-banner-ad__close",onClick:re,children:"\xD7"})]})};var s=require("react"),C=require("@tarojs/components");var S=require("react/jsx-runtime"),We=({unitId:e="",customAd:t,show:r=!0,zIndex:A=999,pictureInPicture:u=!1,checkNativeSplash:k=!0,jumpSeconds:J=5,className:z,onLoad:b,onError:M,onClose:X,onAction:j,onHide:E,onOpenWebview:G})=>{let V=(0,s.useMemo)(()=>Re(),[]),p=!!(e&&V),[Q,_]=(0,s.useState)(!1),[W,se]=(0,s.useState)(p),[N,d]=(0,s.useState)(!1),[fe,f]=(0,s.useState)(0),[ae,w]=(0,s.useState)(!1),[te,g]=(0,s.useState)(!1),R=(0,s.useRef)(null),F=(0,s.useRef)(null),ne=(0,s.useRef)(null),U=(0,s.useRef)(null),re=(0,s.useRef)(null),o=(0,s.useRef)(0),y=(0,s.useRef)(!1),D=(0,s.useRef)(!1),I=(0,s.useRef)(b),B=(0,s.useRef)(M),x=(0,s.useRef)(X),pe=(0,s.useRef)(j),le=(0,s.useRef)(E),Y=(0,s.useRef)(G),c=t||null,me=(0,s.useMemo)(()=>et(c),[c]),ve=(0,s.useMemo)(()=>tt(c,me),[c,me]),ge=!!me,Fe=(0,s.useMemo)(()=>nt(c,me),[c,me]),$e=(0,s.useMemo)(()=>rt(c),[c]),Pe=(0,s.useMemo)(()=>Ue(c),[c]),ue=(0,s.useMemo)(()=>it(c,J),[c,J]),He=(0,s.useMemo)(()=>st(),[]),{contentStyle:Me,badgeStyle:_e}=(0,s.useMemo)(()=>at(),[]),je=(0,s.useMemo)(()=>{let a=["bi-splash-ad"];return N&&a.push("bi-splash-ad--pip"),te&&a.push("bi-splash-ad--pip-animating"),z&&a.push(z),a.join(" ")},[z,te,N]);(0,s.useEffect)(()=>{I.current=b,B.current=M,x.current=X,pe.current=j,le.current=E,Y.current=G},[j,X,M,E,b,G]);let ie=a=>({provider:a,type:"splash"});(0,s.useEffect)(()=>{var a;!r||!e||V||(a=B.current)==null||a.call(B,$(h({},ie("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"}))},[V,r,e]);let ce=(0,s.useCallback)(()=>{R.current&&(clearInterval(R.current),R.current=null),F.current&&(clearTimeout(F.current),F.current=null)},[]),Z=(0,s.useCallback)(()=>{ne.current&&(clearTimeout(ne.current),ne.current=null)},[]),he=(0,s.useCallback)(()=>{U.current&&(clearTimeout(U.current),U.current=null)},[]),Ae=(0,s.useCallback)(()=>{re.current&&(clearTimeout(re.current),re.current=null)},[]),P=(0,s.useCallback)(()=>{ce(),Z(),he(),Ae()},[ce,Z,Ae,he]),ye=(0,s.useCallback)(a=>{var m;P(),_(!1),d(!1),f(0),w(!1),D.current=!1,g(!1),(m=x.current)==null||m.call(x,a)},[P]),Be=(0,s.useCallback)(()=>{let a=W?"wechat":"custom";if(u){ce(),Z(),Ae(),g(!0),re.current=setTimeout(()=>{var m;re.current=null,d(!0),g(!1),(m=le.current)==null||m.call(le,ie(a))},280);return}ye({type:"splash",provider:a})},[ce,Z,Ae,ye,W,u]),oe=(0,s.useCallback)(()=>{if(ce(),ue<=0){Be();return}f(ue),R.current=setInterval(()=>{f(a=>a<=1?(ce(),F.current=setTimeout(()=>{F.current=null,Be()},0),0):a-1)},1e3)},[ce,ue,Be]),Ge=(0,s.useCallback)(a=>{!r||!p||!a||N||oe()},[p,r,N,oe]),Se=(0,s.useCallback)(()=>{let a=!!(!y.current&&(p||ge));P(),se(p),_(a),d(!1),f(ue),w(!1),D.current=!1,g(!1),Ge(a),a&&!p&&ge&&(ne.current=setTimeout(()=>{var m;D.current||(P(),_(!1),d(!1),f(0),w(!1),D.current=!1,g(!1),(m=B.current)==null||m.call(B,$(h({},ie("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},xe(c)))},[p,P,ue,ge,c,Ge]),Te=(0,s.useCallback)(()=>{if(!r)return;if(y.current){_(!1);return}if(!k){Se();return}let a=Le();if(!a||typeof a.getShowSplashAdStatus!="function"||o.current>=3){Se();return}a.getShowSplashAdStatus({success:m=>{var q;if((m==null?void 0:m.code)===-1){o.current+=1,he(),U.current=setTimeout(()=>{U.current=null,Te()},300);return}if((m==null?void 0:m.code)===1){P(),_(!1),y.current=!0,(q=I.current)==null||q.call(I,{provider:"wechat",type:"splash",nativeSplash:!0});return}Se()},fail:()=>{Se()}})},[p,k,P,he,ge,Se,r]);(0,s.useEffect)(()=>{if(!r){P(),_(!1),se(p),d(!1),f(0),w(!1),D.current=!1,g(!1),y.current=!1;return}return o.current=0,y.current?(P(),se(p),_(!1),d(!1),f(0),w(!1),D.current=!1,g(!1),()=>{P()}):(k||(y.current=!1),P(),se(p),_(!1),d(!1),f(ue),w(!1),D.current=!1,g(!1),Te(),()=>{P()})},[p,k,Te,P,ue,r]);let ee=a=>{var m;oe(),(m=I.current)==null||m.call(I,de(a,ie("wechat")))},Ke=a=>{var m;if(W){if(P(),ge){se(!1),_(!0),d(!1),f(ue),w(!1),D.current=!1,g(!1),ne.current=setTimeout(()=>{var q;D.current||(P(),_(!1),d(!1),f(0),w(!1),D.current=!1,g(!1),(q=B.current)==null||q.call(B,$(h({},ie("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},xe(c));return}_(!1),d(!1),f(0),w(!1),D.current=!1,g(!1),(m=x.current)==null||m.call(x,{provider:"wechat",type:"splash",reason:"wechatAdLoadFail",error:a})}},ke=a=>{var be;let m=a&&typeof a.detail=="object"?a.detail:{},q=$(h({},de(a,ie("wechat"))),{errCode:"BI_SPLASH_WECHAT_AD_LOAD_FAIL",errMsg:String(m.errMsg||"\u5FAE\u4FE1\u5F00\u5C4F\u5E7F\u544A\u52A0\u8F7D\u5931\u8D25"),rawErrCode:m.errCode,rawErrMsg:m.errMsg});(be=B.current)==null||be.call(B,q),Ke(q)},n=a=>{ye(de(a,ie("wechat")))},i=()=>{var a;D.current||(Z(),D.current=!0,w(!0),oe(),(a=I.current)==null||a.call(I,ie("custom")))},l=(a,m)=>{var q;P(),_(!1),d(!1),f(0),w(!1),D.current=!1,g(!1),(q=B.current)==null||q.call(B,h(h({},de(a,ie("custom"))),m))},K=a=>{l(a,{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},De=()=>{var q;let a=W?"wechat":"custom",m=ie(a);(q=pe.current)==null||q.call(pe,m),a==="custom"&&Oe({customAd:c,actionDetail:m,onOpenWebview:be=>{var Ee;(Ee=Y.current)==null||Ee.call(Y,be)},onError:be=>{var Ee;(Ee=B.current)==null||Ee.call(B,be)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL"})},L=()=>{ye({type:"splash",provider:W?"wechat":"custom"})},we=W?V:null;return!Q||!!!we&&!ge?null:(0,S.jsxs)(C.View,{className:je,style:{zIndex:A},children:[we?(0,S.jsx)(C.View,{className:"bi-splash-ad__popup",children:(0,S.jsx)(C.View,{className:`bi-splash-ad__media-wrapper${N?" bi-splash-ad__media-wrapper--pip":""}`,children:(0,S.jsx)(we,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:ee,onError:ke,onClose:n})})}):(0,S.jsx)(C.View,{className:"bi-splash-ad__popup",children:(0,S.jsxs)(C.View,{className:"bi-splash-ad__media-shell",onClick:De,children:[Fe?(0,S.jsx)(C.Image,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:me,mode:"aspectFill",onLoad:i,onError:K}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C.Image,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:ve,mode:"aspectFill"}),(0,S.jsx)(C.Video,{className:`bi-splash-ad__video${$e===1?" bi-splash-ad__video--landscape":""}`,src:me,poster:ve,autoplay:!0,muted:(c==null?void 0:c.muted)!==!1,loop:!0,objectFit:"cover",showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:i,onError:K})]}),N?(0,S.jsx)(C.View,{className:"bi-splash-ad__pip-mask"}):null,N?null:(0,S.jsx)(C.View,{className:"bi-splash-ad__badge",style:_e,children:Pe}),c&&(c.title||!N&&(c.description||c.buttonText))?(0,S.jsxs)(C.View,{className:"bi-splash-ad__content",style:Me,children:[c.title?(0,S.jsx)(C.Text,{className:"bi-splash-ad__title",children:c.title}):null,!N&&c.description?(0,S.jsx)(C.Text,{className:"bi-splash-ad__description",children:c.description}):null,!N&&c.buttonText?(0,S.jsx)(C.Button,{className:"bi-splash-ad__action",children:c.buttonText}):null]}):null]})}),N?(0,S.jsx)(C.View,{className:"bi-splash-ad__pip-close",onClick:L,children:(0,S.jsx)(C.View,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,N?null:(0,S.jsxs)(C.View,{className:"bi-splash-ad__skip",style:He,onClick:Be,children:[(0,S.jsxs)(C.Text,{children:[fe,"s"]}),(0,S.jsx)(C.View,{className:"bi-splash-ad__skip-divider"}),(0,S.jsx)(C.Text,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};var v=require("react");var Ye=require("react/jsx-runtime"),vt="BI_DISPLAY_NATIVE_SPLASH_CONSUMED",bt=300*1e3,ot=["banner","splash"],lt=({adId:e="",unitId:t,type:r="banner",customAd:A,adOptions:u=null,sdkKey:k="biNova",autoLoad:J=!0,adIntervals:z=30,show:b=!0,zIndex:M=999,pictureInPicture:X=!1,checkNativeSplash:j=!0,nativeSplashCache:E=!0,jumpSeconds:G=5,className:V,onLoad:p,onError:Q,onClose:_,onAction:W,onHide:se,onOpenWebview:N,onConfigLoad:d,onConfigError:fe})=>{var ke;let f=(0,v.useRef)(0),ae=(0,v.useRef)(""),w=(0,v.useRef)(null),te=(0,v.useRef)(p),g=(0,v.useRef)(Q),R=(0,v.useRef)(_),F=(0,v.useRef)(W),ne=(0,v.useRef)(se),U=(0,v.useRef)(N),re=(0,v.useRef)(d),o=(0,v.useRef)(fe),y=(0,v.useRef)(b),[D,I]=(0,v.useState)(!1),[B,x]=(0,v.useState)(!1),[pe,le]=(0,v.useState)(null);(0,v.useEffect)(()=>{te.current=p,g.current=Q,R.current=_,F.current=W,ne.current=se,U.current=N,re.current=d,o.current=fe,y.current=b},[W,_,fe,d,Q,se,p,N,b]);let Y=(0,v.useMemo)(()=>ot.includes(r)?r:"banner",[r]),c=()=>!!(J&&e),me=()=>{var K;let n=globalThis.getApp,i=typeof n=="function"?n():null;if(!i)return null;let l=i;return l[k]||((K=l.globalData)==null?void 0:K[k])||null},ve=()=>{var n;try{if(typeof wx!="undefined"&&typeof wx.getAccountInfoSync=="function"){let i=wx.getAccountInfoSync();return((n=i==null?void 0:i.miniProgram)==null?void 0:n.appId)||""}}catch(i){return""}return""},ge=(n,i)=>`${vt}_${i||"unknown"}_${n||"empty"}`,Fe=(n,i)=>{if(!E||!n||typeof wx=="undefined"||typeof wx.getStorageSync!="function")return!1;try{let l=ge(n,i),K=Number(wx.getStorageSync(l)||0),De=Date.now()-K;return K>0&&De>=0&&De<=bt}catch(l){return!1}},$e=()=>{if(E&&!(!e||typeof wx=="undefined"||typeof wx.setStorageSync!="function"))try{let n=ge(e,ve());wx.setStorageSync(n,Date.now())}catch(n){}},Pe=()=>{f.current+=1,ae.current="",I(!1),x(!1),le(null)},ue=()=>{let n=u&&typeof u=="object"?u:{},i=ve();return $(h({},n),{adId:e,placementId:n.placementId||e,appId:n.appId||i,type:Y})},He=n=>{try{return JSON.stringify(n||{})}catch(i){return`${String(n.appId||"")}_${String(n.placementId||"")}`}},Me=n=>{let i=(n==null?void 0:n.unitId)||"",l=(n==null?void 0:n.customAd)||(n==null?void 0:n.custom)||null,K=typeof(n==null?void 0:n.show)=="boolean"?n.show:!!(i||l);return{unitId:i,customAd:l,show:K}},_e=n=>{var i,l;(i=o.current)==null||i.call(o,n),(l=g.current)==null||l.call(g,n)},je=n=>{var i;(i=R.current)==null||i.call(R,{type:Y,adId:e||n.adId||"",provider:"none",reason:"noAd"})},ie=async()=>{var De;if(!c())return;let n=ue(),i=He(n);if(ae.current===i&&(D||B))return;let l=me();if(!(l!=null&&l.ads)||typeof l.ads.getDisplayAdConfig!="function"){Pe(),_e({type:Y,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=f.current+1;f.current=K,ae.current=i,I(!0),x(!1),le(null);try{let L=await l.ads.getDisplayAdConfig(n);if(K!==f.current)return;if(!L||L.code!==0||!L.data){I(!1),x(!0),le(null),_e({type:Y,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(L==null?void 0:L.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:L||null});return}let we=Me(L.data),qe=!!(y.current&&!we.show);I(!1),x(!0),le(L.data),(De=re.current)==null||De.call(re,{type:Y,adId:e,requestOptions:n,data:L.data}),qe&&je(L.data)}catch(L){if(K!==f.current)return;I(!1),x(!0),le(null),_e({type:Y,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:L instanceof Error?L.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:L})}};(0,v.useEffect)(()=>{var n;ot.includes(r)||(n=g.current)==null||n.call(g,{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,v.useEffect)(()=>{if(!e){Pe();return}ie()},[e,u,J,Y,k]);let ce=c(),Z=ce?Me(pe):null,he=Z?Z.unitId:t||"",Ae=Z?Z.customAd:A||null,P=!!(b&&(!ce||!e||B&&(Z!=null&&Z.show))),ye=ve(),Be=JSON.stringify([Y,ye,e,j,E]),oe=w.current;!!(!oe||oe.identity!==Be||!oe.show&&b)?w.current={identity:Be,show:b,shouldCheck:!!(j&&!Fe(e,ye))}:oe&&oe.show!==b&&(w.current=$(h({},oe),{show:b}));let Se=!!((ke=w.current)!=null&&ke.shouldCheck),Te=e||(pe==null?void 0:pe.adId)||"",ee=n=>h({adId:Te},n);return Y==="splash"?(0,Ye.jsx)(We,h({},{unitId:he,customAd:Ae,show:P,zIndex:M,pictureInPicture:X,checkNativeSplash:Se,jumpSeconds:G,className:V,onLoad:i=>{var l;i&&typeof i=="object"&&i.nativeSplash===!0&&$e(),(l=te.current)==null||l.call(te,ee(i))},onError:i=>{var l;(l=g.current)==null||l.call(g,ee(i))},onClose:i=>{var l;(l=R.current)==null||l.call(R,ee(i))},onAction:i=>{var l;(l=F.current)==null||l.call(F,ee(i))},onHide:i=>{var l;(l=ne.current)==null||l.call(ne,ee(i))},onOpenWebview:i=>{var l;(l=U.current)==null||l.call(U,ee(i))}})):P?(0,Ye.jsx)(Ve,h({},{unitId:he,customAd:Ae,adIntervals:z,className:V,onLoad:n=>{var i;(i=te.current)==null||i.call(te,ee(n))},onError:n=>{var i;(i=g.current)==null||i.call(g,ee(n))},onClose:n=>{var i;(i=R.current)==null||i.call(R,ee(n))},onAction:n=>{var i;(i=F.current)==null||i.call(F,ee(n))},onOpenWebview:n=>{var i;(i=U.current)==null||i.call(U,ee(n))}})):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 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};
|
|
1
|
+
var Bt=Object.defineProperty,St=Object.defineProperties;var Dt=Object.getOwnPropertyDescriptors;var it=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var st=(e,i,r)=>i in e?Bt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,g=(e,i)=>{for(var r in i||(i={}))Ct.call(i,r)&&st(e,r,i[r]);if(it)for(var r of it(i))vt.call(i,r)&&st(e,r,i[r]);return e},U=(e,i)=>St(e,Dt(i));import"./banner/index.scss";import"./splash/index.scss";import{useCallback as mt,useEffect as Je,useMemo as gt,useRef as fe,useState as Nt}from"react";import{View as Te,Image as It,Button as ft,Text as ze}from"@tarojs/components";import*as bt from"@tarojs/components";var Me;function Ve(){if(Me!==void 0)return Me;try{let e=bt;Me=(e==null?void 0:e.AdCustom)||null}catch(e){Me=null}return Me}import*as ve from"@tarojs/taro";function We(){return typeof wx!="undefined"?wx:null}function ue(e,i){let r=e==null?void 0:e.detail;return r&&typeof r=="object"?g(g({},i),r):e&&typeof e=="object"?g(g({},i),e):g({},i)}function at(e){return e&&(e.image||e.video)||""}function ot(e,i=""){return e&&(e.poster||e.image||i)||""}function lt(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 ut(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),B=Number(e.videoHeight||e.height||0);return r>0&&B>0?r>B?1:2:e.video?1:2}function Fe(e){return e&&(e.badgeText||e.adLabel)||"\u5E7F\u544A"}function ct(e,i=5){let r=e==null?void 0:e.jumpSeconds,B=r!=null?r:i;return Math.min(99,Math.max(0,Number(B)||0))}function ke(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 _t(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 Tt(e){return e&&(e.appId||e.miniProgramAppId||e.jumpAppId)||""}function wt(e){return e&&(e.path||e.pagePath||e.jumpPath||e.targetUrl)||""}function Et(e){return e&&(e.url||e.webUrl||e.h5Url)||""}function $e(e){let{customAd:i,actionDetail:r,onOpenWebview:B,onError:f,miniProgramErrorCode:N,navigateErrorCode:j,miniProgramUnsupportedErrorCode:G}=e;if(!i)return;let S=_t(i),E=Tt(i),Y=wt(i),O=Et(i);if(S==="miniProgram"&&E){let v=We();if(!v||typeof v.navigateToMiniProgram!="function"){f==null||f(U(g({},r),{errCode:G||N,errMsg:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F"}));return}v.navigateToMiniProgram({appId:E,path:Y||"",fail:V=>{f==null||f(U(g({},r),{errCode:N,errMsg:(V==null?void 0:V.errMsg)||"\u8DF3\u8F6C\u5230\u5176\u4ED6\u5C0F\u7A0B\u5E8F\u5931\u8D25"}))}});return}if(S==="internal"&&Y){ve.navigateTo({url:Y,fail:v=>{f==null||f(U(g({},r),{errCode:j,errMsg:(v==null?void 0:v.errMsg)||"\u9875\u9762\u8DF3\u8F6C\u5931\u8D25"}))}});return}S==="web"&&O&&(B==null||B(U(g({},r),{url:O})))}function dt(){let e=We(),i=e&&typeof e.getMenuButtonBoundingClientRect=="function"?e.getMenuButtonBoundingClientRect():{},r=e&&typeof e.getWindowInfo=="function"?e.getWindowInfo():typeof ve.getSystemInfoSync=="function"?ve.getSystemInfoSync():{},B=r.windowHeight===r.screenHeight,f=16,N=16,j=16,G=32,S=B&&i.top?i.top:f,E=B&&i.height?i.height:G;return{top:`${S}px`,width:"156rpx",height:`${E}px`,lineHeight:`${E}px`,borderRadius:`${Math.round(E/2)}px`,left:B?`${j}px`:void 0,right:B?void 0:`${N}px`}}function pt(){var f;let e=typeof ve.getSystemInfoSync=="function"?ve.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,B=i>0?i+88:130;return{contentStyle:{bottom:`${r}rpx`},badgeStyle:{bottom:`${B}rpx`}}}import{jsx as he,jsxs as Re}from"react/jsx-runtime";var Xe=({unitId:e="",customAd:i,adIntervals:r=30,className:B,onLoad:f,onError:N,onClose:j,onAction:G,onOpenWebview:S})=>{let E=gt(()=>Ve(),[]),Y=!!(e&&E),O=fe(null),v=fe(!1),V=fe(!1),k=fe(f),c=fe(N),K=fe(j),D=fe(G),R=fe(S),[ne,b]=Nt(!1),u=i||null,ge=gt(()=>`bi-banner-ad${B?` ${B}`:""}`,[B]);Je(()=>{k.current=f,c.current=N,K.current=j,D.current=G,R.current=S},[G,j,N,f,S]);let m=a=>({provider:a,type:"banner"}),re=mt(()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]),C=mt((a,h)=>{var y;V.current||(V.current=!0,re(),b(!0),(y=c.current)==null||y.call(c,g(g({},ue(a,m("custom"))),h)))},[re]);Je(()=>{if(re(),v.current=!1,V.current=!1,b(!1),!(Y||!(u!=null&&u.image)))return O.current=setTimeout(()=>{C(void 0,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})},ke(u)),()=>{re()}},[re,u,Y,C]),Je(()=>{var a;!e||E||(a=c.current)==null||a.call(c,U(g({},m("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"}))},[E,e]);let z=a=>{var h;(h=k.current)==null||h.call(k,ue(a,m("wechat")))},p=a=>{var h;(h=c.current)==null||h.call(c,ue(a,m("wechat")))},I=a=>{var h;(h=K.current)==null||h.call(K,ue(a,m("wechat")))},L=()=>{var a;v.current||V.current||(re(),v.current=!0,(a=k.current)==null||a.call(k,m("custom")))},X=a=>{C(a,{errCode:"BI_BANNER_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"Banner \u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},P=a=>{var y,_;(y=a==null?void 0:a.stopPropagation)==null||y.call(a);let h=m("custom");(_=D.current)==null||_.call(D,h),$e({customAd:u,actionDetail:h,onOpenWebview:A=>{var T;(T=R.current)==null||T.call(R,A)},onError:A=>{var T;(T=c.current)==null||T.call(c,A)},miniProgramErrorCode:"BI_BANNER_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_BANNER_NAVIGATE_FAIL"})},Q=a=>{var h,y;(h=a==null?void 0:a.stopPropagation)==null||h.call(a),(y=K.current)==null||y.call(K,m("custom"))};return Y&&E?he(E,{className:ge,unitId:e,adIntervals:r,onLoad:z,onError:p,onClose:I}):!u||!u.image||ne?null:Re(Te,{className:ge,children:[Re(Te,{className:"bi-banner-ad__surface",onClick:P,children:[Re(Te,{className:"bi-banner-ad__media",children:[he(ze,{className:"bi-banner-ad__badge bi-banner-ad__badge--overlay",children:Fe(u)}),he(It,{className:"bi-banner-ad__image",src:u.image||"",mode:"aspectFill",onLoad:L,onError:X})]}),Re(Te,{className:"bi-banner-ad__content",children:[he(Te,{className:"bi-banner-ad__body",children:u.title?he(ze,{className:"bi-banner-ad__title",children:u.title}):null}),Re(Te,{className:"bi-banner-ad__footer",children:[u.description?he(ze,{className:"bi-banner-ad__description",children:u.description}):null,he(ft,{className:"bi-banner-ad__button",onClick:P,children:u.buttonText||"\u7ACB\u5373\u67E5\u770B"})]})]})]}),he(ft,{className:"bi-banner-ad__close",onClick:Q,children:"\xD7"})]})};import{useCallback as se,useEffect as Qe,useMemo as ce,useRef as H,useState as we}from"react";import{View as ee,Image as ht,Video as xt,Button as Pt,Text as He}from"@tarojs/components";import{Fragment as Mt,jsx as M,jsxs as Ee}from"react/jsx-runtime";var Ze=({unitId:e="",customAd:i,show:r=!0,zIndex:B=999,pictureInPicture:f=!1,checkNativeSplash:N=!0,jumpSeconds:j=5,className:G,onLoad:S,onError:E,onClose:Y,onAction:O,onHide:v,onOpenWebview:V})=>{let k=ce(()=>Ve(),[]),c=!!(e&&k),[K,D]=we(!1),[R,ne]=we(c),[b,u]=we(!1),[ge,m]=we(0),[re,C]=we(!1),[z,p]=we(!1),I=H(null),L=H(null),X=H(null),P=H(null),Q=H(null),a=H(0),h=H(!1),y=H(!1),_=H(S),A=H(E),T=H(Y),de=H(O),ae=H(v),W=H(V),l=i||null,pe=ce(()=>at(l),[l]),be=ce(()=>ot(l,pe),[l,pe]),me=!!pe,je=ce(()=>lt(l,pe),[l,pe]),Ge=ce(()=>ut(l),[l]),Le=ce(()=>Fe(l),[l]),oe=ce(()=>ct(l,j),[l,j]),Ye=ce(()=>dt(),[]),{contentStyle:Ue,badgeStyle:Ne}=ce(()=>pt(),[]),Ke=ce(()=>{let s=["bi-splash-ad"];return b&&s.push("bi-splash-ad--pip"),z&&s.push("bi-splash-ad--pip-animating"),G&&s.push(G),s.join(" ")},[G,z,b]);Qe(()=>{_.current=S,A.current=E,T.current=Y,de.current=O,ae.current=v,W.current=V},[O,Y,E,v,S,V]);let Z=s=>({provider:s,type:"splash"});Qe(()=>{var s;!r||!e||k||(s=A.current)==null||s.call(A,U(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"}))},[k,r,e]);let le=se(()=>{I.current&&(clearInterval(I.current),I.current=null),L.current&&(clearTimeout(L.current),L.current=null)},[]),q=se(()=>{X.current&&(clearTimeout(X.current),X.current=null)},[]),Ae=se(()=>{P.current&&(clearTimeout(P.current),P.current=null)},[]),ye=se(()=>{Q.current&&(clearTimeout(Q.current),Q.current=null)},[]),w=se(()=>{le(),q(),Ae(),ye()},[le,q,ye,Ae]),Be=se(s=>{var d;w(),D(!1),u(!1),m(0),C(!1),y.current=!1,p(!1),(d=T.current)==null||d.call(T,s)},[w]),Se=se(()=>{let s=R?"wechat":"custom";if(f){le(),q(),ye(),p(!0),Q.current=setTimeout(()=>{var d;Q.current=null,u(!0),p(!1),(d=ae.current)==null||d.call(ae,Z(s))},280);return}Be({type:"splash",provider:s})},[le,q,ye,Be,R,f]),ie=se(()=>{if(le(),oe<=0){Se();return}m(oe),I.current=setInterval(()=>{m(s=>s<=1?(le(),L.current=setTimeout(()=>{L.current=null,Se()},0),0):s-1)},1e3)},[le,oe,Se]),qe=se(s=>{!r||!c||!s||b||ie()},[c,r,b,ie]),De=se(()=>{let s=!!(!h.current&&(c||me));w(),ne(c),D(s),u(!1),m(oe),C(!1),y.current=!1,p(!1),qe(s),s&&!c&&me&&(X.current=setTimeout(()=>{var d;y.current||(w(),D(!1),u(!1),m(0),C(!1),y.current=!1,p(!1),(d=A.current)==null||d.call(A,U(g({},Z("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},ke(l)))},[c,w,oe,me,l,qe]),Ie=se(()=>{if(!r)return;if(h.current){D(!1);return}if(!N){De();return}let s=We();if(!s||typeof s.getShowSplashAdStatus!="function"||a.current>=3){De();return}s.getShowSplashAdStatus({success:d=>{var $;if((d==null?void 0:d.code)===-1){a.current+=1,Ae(),P.current=setTimeout(()=>{P.current=null,Ie()},300);return}if((d==null?void 0:d.code)===1){w(),D(!1),h.current=!0,($=_.current)==null||$.call(_,{provider:"wechat",type:"splash",nativeSplash:!0});return}De()},fail:()=>{De()}})},[c,N,w,Ae,me,De,r]);Qe(()=>{if(!r){w(),D(!1),ne(c),u(!1),m(0),C(!1),y.current=!1,p(!1),h.current=!1;return}return a.current=0,h.current?(w(),ne(c),D(!1),u(!1),m(0),C(!1),y.current=!1,p(!1),()=>{w()}):(N||(h.current=!1),w(),ne(c),D(!1),u(!1),m(oe),C(!1),y.current=!1,p(!1),Ie(),()=>{w()})},[c,N,Ie,w,oe,r]);let J=s=>{var d;ie(),(d=_.current)==null||d.call(_,ue(s,Z("wechat")))},nt=s=>{var d;if(R){if(w(),me){ne(!1),D(!0),u(!1),m(oe),C(!1),y.current=!1,p(!1),X.current=setTimeout(()=>{var $;y.current||(w(),D(!1),u(!1),m(0),C(!1),y.current=!1,p(!1),($=A.current)==null||$.call(A,U(g({},Z("custom")),{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_TIMEOUT",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u8D85\u65F6"})))},ke(l));return}D(!1),u(!1),m(0),C(!1),y.current=!1,p(!1),(d=T.current)==null||d.call(T,{provider:"wechat",type:"splash",reason:"wechatAdLoadFail",error:s})}},Oe=s=>{var _e;let d=s&&typeof s.detail=="object"?s.detail:{},$=U(g({},ue(s,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});(_e=A.current)==null||_e.call(A,$),nt($)},t=s=>{Be(ue(s,Z("wechat")))},n=()=>{var s;y.current||(q(),y.current=!0,C(!0),ie(),(s=_.current)==null||s.call(_,Z("custom")))},o=(s,d)=>{var $;w(),D(!1),u(!1),m(0),C(!1),y.current=!1,p(!1),($=A.current)==null||$.call(A,g(g({},ue(s,Z("custom"))),d))},F=s=>{o(s,{errCode:"BI_SPLASH_CUSTOM_MEDIA_LOAD_FAIL",errMsg:"\u5F00\u5C4F\u81EA\u5B9A\u4E49\u5E7F\u544A\u7D20\u6750\u52A0\u8F7D\u5931\u8D25"})},Ce=()=>{var $;let s=R?"wechat":"custom",d=Z(s);($=de.current)==null||$.call(de,d),s==="custom"&&$e({customAd:l,actionDetail:d,onOpenWebview:_e=>{var Pe;(Pe=W.current)==null||Pe.call(W,_e)},onError:_e=>{var Pe;(Pe=A.current)==null||Pe.call(A,_e)},miniProgramErrorCode:"BI_SPLASH_NAVIGATE_MINI_PROGRAM_FAIL",navigateErrorCode:"BI_SPLASH_NAVIGATE_FAIL"})},x=()=>{Be({type:"splash",provider:R?"wechat":"custom"})},xe=R?k:null;return!K||!!!xe&&!me?null:Ee(ee,{className:Ke,style:{zIndex:B},children:[xe?M(ee,{className:"bi-splash-ad__popup",children:M(ee,{className:`bi-splash-ad__media-wrapper${b?" bi-splash-ad__media-wrapper--pip":""}`,children:M(xe,{className:"bi-splash-ad__wechat-unit",unitId:e,onLoad:J,onError:Oe,onClose:t})})}):M(ee,{className:"bi-splash-ad__popup",children:Ee(ee,{className:"bi-splash-ad__media-shell",onClick:Ce,children:[je?M(ht,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:pe,mode:"aspectFill",onLoad:n,onError:F}):Ee(Mt,{children:[M(ht,{className:"bi-splash-ad__media bi-splash-ad__media--background",src:be,mode:"aspectFill"}),M(xt,{className:`bi-splash-ad__video${Ge===1?" bi-splash-ad__video--landscape":""}`,src:pe,poster:be,autoplay:!0,muted:(l==null?void 0:l.muted)!==!1,loop:!0,objectFit:"cover",showCenterPlayBtn:!1,showPlayBtn:!1,controls:!1,onLoadedMetaData:n,onError:F})]}),b?M(ee,{className:"bi-splash-ad__pip-mask"}):null,b?null:M(ee,{className:"bi-splash-ad__badge",style:Ne,children:Le}),l&&(l.title||!b&&(l.description||l.buttonText))?Ee(ee,{className:"bi-splash-ad__content",style:Ue,children:[l.title?M(He,{className:"bi-splash-ad__title",children:l.title}):null,!b&&l.description?M(He,{className:"bi-splash-ad__description",children:l.description}):null,!b&&l.buttonText?M(Pt,{className:"bi-splash-ad__action",children:l.buttonText}):null]}):null]})}),b?M(ee,{className:"bi-splash-ad__pip-close",onClick:x,children:M(ee,{className:"bi-splash-ad__pip-close-text",children:"\u5173\u95ED"})}):null,b?null:Ee(ee,{className:"bi-splash-ad__skip",style:Ye,onClick:Se,children:[Ee(He,{children:[ge,"s"]}),M(ee,{className:"bi-splash-ad__skip-divider"}),M(He,{className:"bi-splash-ad__skip-text",children:"\u8DF3\u8FC7"})]})]})};import{useEffect as et,useMemo as kt,useRef as te,useState as tt}from"react";import{jsx as yt}from"react/jsx-runtime";var Rt="BI_DISPLAY_NATIVE_SPLASH_CONSUMED",Lt=300*1e3,At=["banner","splash"],Ut=({adId:e="",unitId:i,type:r="banner",customAd:B,adOptions:f=null,sdkKey:N="biNova",autoLoad:j=!0,adIntervals:G=30,show:S=!0,zIndex:E=999,pictureInPicture:Y=!1,checkNativeSplash:O=!0,nativeSplashCache:v=!0,jumpSeconds:V=5,className:k,onLoad:c,onError:K,onClose:D,onAction:R,onHide:ne,onOpenWebview:b,onConfigLoad:u,onConfigError:ge})=>{var Oe;let m=te(0),re=te(""),C=te(null),z=te(c),p=te(K),I=te(D),L=te(R),X=te(ne),P=te(b),Q=te(u),a=te(ge),h=te(S),[y,_]=tt(!1),[A,T]=tt(!1),[de,ae]=tt(null);et(()=>{z.current=c,p.current=K,I.current=D,L.current=R,X.current=ne,P.current=b,Q.current=u,a.current=ge,h.current=S},[R,D,ge,u,K,ne,c,b,S]);let W=kt(()=>At.includes(r)?r:"banner",[r]),l=()=>!!(j&&e),pe=()=>{var F;let t=globalThis.getApp,n=typeof t=="function"?t():null;if(!n)return null;let o=n;return o[N]||((F=o.globalData)==null?void 0:F[N])||null},be=()=>{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""},me=(t,n)=>`${Rt}_${n||"unknown"}_${t||"empty"}`,je=(t,n)=>{if(!v||!t||typeof wx=="undefined"||typeof wx.getStorageSync!="function")return!1;try{let o=me(t,n),F=Number(wx.getStorageSync(o)||0),Ce=Date.now()-F;return F>0&&Ce>=0&&Ce<=Lt}catch(o){return!1}},Ge=()=>{if(v&&!(!e||typeof wx=="undefined"||typeof wx.setStorageSync!="function"))try{let t=me(e,be());wx.setStorageSync(t,Date.now())}catch(t){}},Le=()=>{m.current+=1,re.current="",_(!1),T(!1),ae(null)},oe=()=>{let t=f&&typeof f=="object"?f:{},n=be();return U(g({},t),{adId:e,placementId:t.placementId||e,appId:t.appId||n,type:W})},Ye=t=>{try{return JSON.stringify(t||{})}catch(n){return`${String(t.appId||"")}_${String(t.placementId||"")}`}},Ue=t=>{let n=(t==null?void 0:t.unitId)||"",o=(t==null?void 0:t.customAd)||(t==null?void 0:t.custom)||null,F=typeof(t==null?void 0:t.show)=="boolean"?t.show:!!(n||o);return{unitId:n,customAd:o,show:F}},Ne=t=>{var n,o;(n=a.current)==null||n.call(a,t),(o=p.current)==null||o.call(p,t)},Ke=t=>{var n;(n=I.current)==null||n.call(I,{type:W,adId:e||t.adId||"",provider:"none",reason:"noAd"})},Z=async()=>{var Ce;if(!l())return;let t=oe(),n=Ye(t);if(re.current===n&&(y||A))return;let o=pe();if(!(o!=null&&o.ads)||typeof o.ads.getDisplayAdConfig!="function"){Le(),Ne({type:W,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 F=m.current+1;m.current=F,re.current=n,_(!0),T(!1),ae(null);try{let x=await o.ads.getDisplayAdConfig(t);if(F!==m.current)return;if(!x||x.code!==0||!x.data){_(!1),T(!0),ae(null),Ne({type:W,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_FAIL",errMsg:(x==null?void 0:x.message)||"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5931\u8D25",rawResult:x||null});return}let xe=Ue(x.data),rt=!!(h.current&&!xe.show);_(!1),T(!0),ae(x.data),(Ce=Q.current)==null||Ce.call(Q,{type:W,adId:e,requestOptions:t,data:x.data}),rt&&Ke(x.data)}catch(x){if(F!==m.current)return;_(!1),T(!0),ae(null),Ne({type:W,adId:e,errCode:"DISPLAY_AD_REMOTE_CONFIG_EXCEPTION",errMsg:x instanceof Error?x.message:"\u83B7\u53D6\u5C55\u793A\u5E7F\u544A\u914D\u7F6E\u5F02\u5E38",error:x})}};et(()=>{var t;At.includes(r)||(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${r}\uFF0C\u8BF7\u4F7F\u7528 "banner" \u6216 "splash"`})},[r]),et(()=>{if(!e){Le();return}Z()},[e,f,j,W,N]);let le=l(),q=le?Ue(de):null,Ae=q?q.unitId:i||"",ye=q?q.customAd:B||null,w=!!(S&&(!le||!e||A&&(q!=null&&q.show))),Be=be(),Se=JSON.stringify([W,Be,e,O,v]),ie=C.current;!!(!ie||ie.identity!==Se||!ie.show&&S)?C.current={identity:Se,show:S,shouldCheck:!!(O&&!je(e,Be))}:ie&&ie.show!==S&&(C.current=U(g({},ie),{show:S}));let De=!!((Oe=C.current)!=null&&Oe.shouldCheck),Ie=e||(de==null?void 0:de.adId)||"",J=t=>g({adId:Ie},t);return W==="splash"?yt(Ze,g({},{unitId:Ae,customAd:ye,show:w,zIndex:E,pictureInPicture:Y,checkNativeSplash:De,jumpSeconds:V,className:k,onLoad:n=>{var o;n&&typeof n=="object"&&n.nativeSplash===!0&&Ge(),(o=z.current)==null||o.call(z,J(n))},onError:n=>{var o;(o=p.current)==null||o.call(p,J(n))},onClose:n=>{var o;(o=I.current)==null||o.call(I,J(n))},onAction:n=>{var o;(o=L.current)==null||o.call(L,J(n))},onHide:n=>{var o;(o=X.current)==null||o.call(X,J(n))},onOpenWebview:n=>{var o;(o=P.current)==null||o.call(P,J(n))}})):w?yt(Xe,g({},{unitId:Ae,customAd:ye,adIntervals:G,className:k,onLoad:t=>{var n;(n=z.current)==null||n.call(z,J(t))},onError:t=>{var n;(n=p.current)==null||n.call(p,J(t))},onClose:t=>{var n;(n=I.current)==null||n.call(I,J(t))},onAction:t=>{var n;(n=L.current)==null||n.call(L,J(t))},onOpenWebview:t=>{var n;(n=P.current)==null||n.call(P,J(t))}})):null};export{Xe as BiBannerAd,Ut as BiDisplayAd,Ze as BiSplashAd};
|