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