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