@bi-nova/ui-taro 1.2.0 → 1.2.1-beta.202606171550

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