2022-09-15 19:59:19 +08:00

1 line
8.5 KiB
JavaScript

"use strict";(wx["webpackJsonp"]=wx["webpackJsonp"]||[]).push([[573],{573:function(e,t,n){n.r(t),n.d(t,{connectReactPage:function(){return Y},createNativeComponentConfig:function(){return z},createReactApp:function(){return U},setReconciler:function(){return L},useAddToFavorites:function(){return E},useDidHide:function(){return f},useDidShow:function(){return m},useError:function(){return v},useLaunch:function(){return g},useLoad:function(){return R},useOptionMenuClick:function(){return w},usePageNotFound:function(){return P},usePageScroll:function(){return S},usePullDownRefresh:function(){return b},usePullIntercept:function(){return x},useReachBottom:function(){return y},useReady:function(){return j},useResize:function(){return C},useRouter:function(){return G},useSaveExitState:function(){return I},useScope:function(){return _},useShareAppMessage:function(){return k},useShareTimeline:function(){return D},useTabItemTap:function(){return M},useTitleClick:function(){return O},useUnload:function(){return T}});var o=n(903),r=n(31);n(868);(0,r.dZ)(),(0,o.Pr)();var s={PageContext:r.kT,R:r.kT},u="taro-app";function c(e,t){var n;const o=t.prototype;return!(null===(n=t.displayName)||void 0===n?void 0:n.includes("Connect"))&&((0,r.mf)(t.render)||!!(null===o||void 0===o?void 0:o.isReactComponent)||o instanceof e.Component)}function i(e){return(0,r.kJ)(e)?e:e?[e]:[]}function a(e){return e.writable=!0,e.enumerable=!0,e}function p(e){o.GY.router=Object.assign({params:null===e||void 0===e?void 0:e.query},e)}var l,d,h=e=>t=>{const{R:n,PageContext:c}=s,i=n.useContext(c)||u,a=n.useRef(),p=n.useRef(t);p.current!==t&&(p.current=t),n.useLayoutEffect((()=>{let t=a.current=(0,o.R0)(i),n=!1;t||(n=!0,a.current=Object.create(null),t=a.current);const s=(...e)=>p.current(...e);return(0,r.mf)(t[e])?t[e]=[t[e],s]:t[e]=[...t[e]||[],s],n&&(0,o.px)(t,i),()=>{const t=a.current;if(!t)return;const n=t[e];n===s?t[e]=void 0:(0,r.kJ)(n)&&(t[e]=n.filter((e=>e!==s))),a.current=void 0}}),[])},f=h("componentDidHide"),m=h("componentDidShow"),v=h("onError"),g=h("onLaunch"),P=h("onPageNotFound"),R=h("onLoad"),S=h("onPageScroll"),b=h("onPullDownRefresh"),x=h("onPullIntercept"),y=h("onReachBottom"),C=h("onResize"),T=h("onUnload"),E=h("onAddToFavorites"),w=h("onOptionMenuClick"),I=h("onSaveExitState"),k=h("onShareAppMessage"),D=h("onShareTimeline"),O=h("onTitleClick"),j=h("onReady"),G=(e=!1)=>{const t=s.R;return e?o.GY.router:t.useMemo((()=>o.GY.router),[])},M=h("onTabItemTap"),_=()=>{},A=Object.freeze({__proto__:null,useDidHide:f,useDidShow:m,useError:v,useLaunch:g,usePageNotFound:P,useLoad:R,usePageScroll:S,usePullDownRefresh:b,usePullIntercept:x,useReachBottom:y,useResize:C,useUnload:T,useAddToFavorites:E,useOptionMenuClick:w,useSaveExitState:I,useShareAppMessage:k,useShareTimeline:D,useTitleClick:O,useReady:j,useRouter:G,useTabItemTap:M,useScope:_}),F=(0,o.BG)();function L(e){r.PT.tap("getLifecycle",(function(e,t){return t=t.replace(/^on(Show|Hide)$/,"componentDid$1"),e[t]})),r.PT.tap("modifyMpEvent",(function(e){e.type=e.type.replace(/-/g,"")})),r.PT.tap("batchedEventUpdates",(function(t){e.unstable_batchedUpdates(t)})),r.PT.tap("mergePageInstance",(function(e,t){e&&t&&("constructor"in e||Object.keys(e).forEach((n=>{const o=e[n],r=i(t[n]);t[n]=r.concat(o)})))}))}function Y(e,t){return n=>{const u=c(e,n),i=e=>e&&(0,o.px)(e,t),a=u?{ref:i}:{forwardedRef:i,reactReduxForwardedRef:i};return s.PageContext===r.kT&&(s.PageContext=e.createContext("")),class extends e.Component{static getDerivedStateFromError(e){var t,n;return null===(n=null===(t=o.GY.app)||void 0===t?void 0:t.onError)||void 0===n||n.call(t,e.message+e.stack),{hasError:!0}}componentDidCatch(e,t){0}render(){const e=this.state.hasError?[]:l(s.PageContext.Provider,{value:t},l(n,Object.assign(Object.assign({},this.props),a)));return l("root",{id:t},e)}constructor(){super(...arguments),this.state={hasError:!1}}}}}function U(e,t,n,i){s.R=t,l=t.createElement,d=n,t.Fragment;const h=t.createRef(),f=c(t,e);let m,v;const g=new Promise((e=>v=e));function P(){return h.current}function R(){var e,n;let r="app";const s=o.c8.getElementById(r);if((t.version||"").startsWith("18")){const t=d.createRoot(s);null===(e=t.render)||void 0===e||e.call(t,l(S))}else null===(n=d.render)||void 0===n||n.call(d,l(S),s)}L(d);class S extends t.Component{mount(e,n,o){const r=Y(t,n)(e),s=n+F(),u=()=>l(r,{key:s,tid:n});this.pages.push(u),this.forceUpdate(o)}unmount(e,t){const n=this.elements,o=n.findIndex((t=>t.props.tid===e));n.splice(o,1),this.forceUpdate(t)}render(){const{pages:t,elements:n}=this;while(t.length>0){const e=t.pop();n.push(e())}let o=null;return f&&(o={ref:h}),l(e,o,n.slice())}constructor(e){super(e),this.pages=[],this.elements=[],m=this,v(this)}}R();const[b,x,y]=r.PT.call("getMiniLifecycleImpl").app,C=Object.create({render(e){m.forceUpdate(e)},mount(e,t,n){m?m.mount(e,t,n):g.then((o=>o.mount(e,t,n)))},unmount(e,t){m.unmount(e,t)}},{config:a({configurable:!0,value:i}),[b]:a({value(e){p(e);const t=()=>{var t;const n=P();if(this.$app=n,n){if(n.taroGlobalData){const e=n.taroGlobalData,t=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);t.forEach((t=>{Object.defineProperty(this,t,{configurable:!0,enumerable:!0,get(){return e[t]},set(n){e[t]=n}})})),Object.defineProperties(this,o)}null===(t=n.onLaunch)||void 0===t||t.call(n,e)}T("onLaunch",e)};m?t():g.then((()=>t()))}}),[x]:a({value(e){var t;p(e);const n=P();null===(t=null===n||void 0===n?void 0:n.componentDidShow)||void 0===t||t.call(n,e),T("onShow",e)}}),[y]:a({value(){var e;const t=P();null===(e=null===t||void 0===t?void 0:t.componentDidHide)||void 0===e||e.call(t),T("onHide")}}),onError:a({value(e){var t;const n=P();null===(t=null===n||void 0===n?void 0:n.onError)||void 0===t||t.call(n,e),T("onError",e)}}),onPageNotFound:a({value(e){var t;const n=P();null===(t=null===n||void 0===n?void 0:n.onPageNotFound)||void 0===t||t.call(n,e),T("onPageNotFound",e)}})});function T(e,...t){const n=(0,o.R0)(u);if(n){const o=P(),s=r.PT.call("getLifecycle",n,e);Array.isArray(s)&&s.forEach((e=>e.apply(o,t)))}}return o.GY.app=C,C}var N,B,H=(0,o.BG)();function $(e,t){class n extends e.Component{componentDidMount(){this.ctx.component=this;const e=this.root.current;e.ctx=this.ctx,e.performUpdate(!0)}render(){return N("root",{ref:this.root},this.props.renderComponent(this.ctx))}constructor(){super(...arguments),this.root=e.createRef(),this.ctx=this.props.getCtx()}}class u extends e.Component{componentDidMount(){o.GY.app=this}mount(t,u,i){const a=c(e,t),p=e=>e&&(0,o.px)(e,u),l=a?{ref:p}:{forwardedRef:p,reactReduxForwardedRef:p};s.PageContext===r.kT&&(s.PageContext=e.createContext(""));const d={compId:u,element:N(n,{key:u,getCtx:i,renderComponent(e){return N(s.PageContext.Provider,{value:u},N(t,Object.assign(Object.assign(Object.assign({},(e.data||(e.data={})).props),l),{$scope:e})))}})};this.setState({components:[...this.state.components,d]})}unmount(e){const t=this.state.components,n=t.findIndex((t=>t.compId===e)),o=[...t.slice(0,n),...t.slice(n+1)];this.setState({components:o})}render(){const e=this.state.components;return e.map((({element:e})=>e))}constructor(){super(...arguments),this.state={components:[]}}}L(t);const i=o.c8.getElementById("app");t.render(N(u,{}),i)}function z(e,t,n,r){var u,c;s.R=t,N=t.createElement,B=n,L(B);const i={options:r,properties:{props:{type:null,value:null,observer(e,t){t&&this.component.forceUpdate()}}},created(){o.GY.app||$(t,B)},attached(){const t=this.compId=H();a(t),this.config=r,o.GY.app.mount(e,t,(()=>this))},ready(){(0,o.p_)(this.compId,"onReady")},detached(){o.GY.app.unmount(this.compId)},pageLifetimes:{show(e){(0,o.p_)(this.compId,"onShow",e)},hide(){(0,o.p_)(this.compId,"onHide")}},methods:{eh:o.$j}};function a(e){const t=getCurrentPages(),n=t[t.length-1];if(o.GY.page===n)return;o.GY.page=n;const r=n.route||n.__route__,s={params:n.options||{},path:(0,o.nY)(r),$taroPath:e,onReady:"",onHide:"",onShow:""};o.GY.router=s,n.options||Object.defineProperty(n,"options",{enumerable:!0,configurable:!0,get(){return this._optionsValue},set(e){s.params=e,this._optionsValue=e}})}return(e.onShareAppMessage||(null===(u=e.prototype)||void 0===u?void 0:u.onShareAppMessage)||e.enableShareAppMessage)&&(i.methods.onShareAppMessage=function(e){const t=null===e||void 0===e?void 0:e.target;if(t){const e=t.id,n=o.c8.getElementById(e);n&&(t.dataset=n.dataset)}return(0,o.p_)(this.compId,"onShareAppMessage",e)}),(e.onShareTimeline||(null===(c=e.prototype)||void 0===c?void 0:c.onShareTimeline)||e.enableShareTimeline)&&(i.methods.onShareTimeline=function(){return(0,o.p_)(this.compId,"onShareTimeline")}),i}r.PT.tap("initNativeApi",(function(e){for(const t in A)e[t]=A[t]}))}}]);