@bi-nova/ui-taro 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,7 +67,7 @@ interface BiDisplayCustomAd$1 extends BiBaseCustomAd {
67
67
  * @Author wutao
68
68
  * @Date 2026-04-14
69
69
  * @LastEditors wutao
70
- * @LastEditTime 2026-04-14
70
+ * @LastEditTime 2026-06-16
71
71
  */
72
72
 
73
73
  /**
@@ -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-04-14
114
+ * @LastEditTime 2026-06-16
115
115
  */
116
116
 
117
117
  /**
@@ -67,7 +67,7 @@ interface BiDisplayCustomAd$1 extends BiBaseCustomAd {
67
67
  * @Author wutao
68
68
  * @Date 2026-04-14
69
69
  * @LastEditors wutao
70
- * @LastEditTime 2026-04-14
70
+ * @LastEditTime 2026-06-16
71
71
  */
72
72
 
73
73
  /**
@@ -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-04-14
114
+ * @LastEditTime 2026-06-16
115
115
  */
116
116
 
117
117
  /**
package/dist/ad/index.js CHANGED
@@ -1 +1 @@
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});
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});
package/dist/ad/index.mjs CHANGED
@@ -1 +1 @@
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};
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};
@@ -3,7 +3,7 @@
3
3
  * @Author wutao
4
4
  * @Date 2026-04-14
5
5
  * @LastEditors wutao
6
- * @LastEditTime 2026-04-14
6
+ * @LastEditTime 2026-06-16
7
7
  */
8
8
  .bi-splash-ad {
9
9
  position: fixed;
@@ -171,9 +171,11 @@
171
171
  top: 16px;
172
172
  right: 16px;
173
173
  z-index: 20;
174
- display: inline-flex;
174
+ display: flex;
175
175
  align-items: center;
176
+ width: auto;
176
177
  min-width: 132rpx;
178
+ max-width: 220rpx;
177
179
  padding: 0 18rpx;
178
180
  background: rgba(0, 0, 0, 0.45);
179
181
  color: #ffffff;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bi-nova/ui-taro",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "BI Nova SDK Taro React UI",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",