'use strict';!function(require,directRequire){const a=require('react'),b=require('./3b5f8e2469c474c8d433c1c6926d8999.js'),c=require('./a78e6d6a87de1708226375ca4c320d76.js');class d extends a.Component{constructor(a){super(a)}componentDidMount(){this.initWebview()}componentWillUnmount(){this.webview&&this.webview.detach()}initWebview(){if(!this.webview){const a=this.webview=c.get('simulator');a.className='simulator-bd-webview_body webviewbody',a.setAttribute('partition','persist:simulator'),a.setAttribute('style',`position:absolute;height:${this.props.height}px;width:${this.props.width}px`),this.initEvent(this.webview),a.src=this.props.src,a.attach(this.refs.container)}}initEvent(a){a.on('dialog',(a)=>{const b=a.messageType||'',c=a.messageText,d=a.dialog;if('alert'===b&&0===c.indexOf('map handle:')){const a=c.replace('map handle:','');this.props.chooseLocation(JSON.parse(a))}}),a.on('permissionrequest',function(a){'geolocation'===a.permission&&a.request.allow()})}render(){return a.createElement('div',{ref:'container'})}}module.exports=d}(require('lazyload'),require);
'use strict';!function(require,directRequire){const a=require('react'),b=require('./d3976cc01aeebc5b09e11c4135b6bd8d.js'),c=require('./c4190a2430506f3602ca550e1e75d620.js'),d=require('./a8c87029da0fa06e986298d447ab0fe2.js'),e=require('./4762f28cad4425c4fc55dec009c87a7e.js'),f=require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),g=require('./ff946754202ecf377034d29daac7c8d9.js'),{connect:h}=require('react-redux');class i extends a.Component{componentDidMount(){this.initWebview(),this._onDevtoolsMessage=this.onDevtoolsMessage.bind(this),e.register(this._onDevtoolsMessage)}componentWillReceiveProps(a){a.webview!=this.props.webview&&a.webview&&setTimeout(()=>{this.showDevTools()}),a.device!=this.props.device&&setTimeout(()=>{this.setDevice()})}componentWillUnmount(){e.unRegister(this._onDevtoolsMessage)}onDevtoolsMessage(a){'Button.popup'===a.command&&this.props.windowActions.setDebuggerWindow({popup:!this.props.popup})}initWebview(){const a=this.devtoolsview=document.createElement('webview');a.setAttribute('partition','persist:devtools'),a.setAttribute('style','height:100%;width:100%;position:relative;');const b=`${a.getUserAgent()} devtoolsview port/${global.messageCenterPort}`;a.setUserAgentOverride(b),this.container.appendChild(a),this.props.webview&&this.showDevTools(),this.initEvent()}initEvent(){const a=this.devtoolsview;a&&(a.addEventListener('newwindow',this._newwindow),a.addEventListener('dialog',(a)=>{const b=a.messageType||'',c=a.messageText,d=c,e=a.dialog;if('prompt'===b)if(d===f.GET_MESSAGE_TOKEN)e.ok(g.getToken());else if(null!==d){const a=prompt(c);e.ok(a)}else e.cancel()}))}setDevice(){const a=this.props;e.send({command:'SET_DEVICE',data:{width:0,height:0,deviceScaleFactor:parseFloat(a.dpr),mobile:!0,fitWindow:!1,scale:1,screenHeight:parseInt(a.height),screenWidth:parseInt(a.width),positionX:0,positionY:0,screenOrientation:{angle:0,type:'portraitPrimary'}}})}_newwindow(a){a.preventDefault();let b=a.targetUrl;b&&('https://developers.google.com/web/tools/chrome-devtools/'===b&&(b='https://mp.weixin.qq.com/debug/wxadoc/dev/index.html'),'https://developers.google.com/web/updates/2017/05/devtools-release-notes'===b&&(b='https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/new.html'),nw.Window.open(b,{width:799,height:799}))}showDevTools(){const a=this.props.webview,b=this.devtoolsview,c=()=>{b.removeEventListener('loadcommit',c);const d=()=>{a.removeEventListener('loadcommit',d),a.showDevTools(!0,b)};a.addEventListener('loadcommit',d),a.src='html/about.html'};b.addEventListener('loadcommit',c),b.addEventListener('contentload',()=>{this.setDevice()}),b.src='about:blank'}render(){return a.createElement('div',{ref:(a)=>this.container=a,style:{flex:1,height:this.props.isPopup?'100%':'inherit'},className:'devtools'})}}module.exports=h((a)=>{const b=a.webdebugger||{},c=a.toolbar.deviceInfo;return{device:c,dpr:c.dpr,height:c.screenHeight-c.navigationbarHeight-c.statusbarHeight,width:c.screenWidth,webview:b.webview,popup:a.window.debug.popup}},(a)=>({debuggerActions:b.bindActionCreators(c,a),windowActions:b.bindActionCreators(d,a)}))(i)}(require('lazyload'),require);
'use strict';!function(require,directRequire){const a=require('path'),b=require('react'),c=require('./a1dd553cc059d528bb0ef56afed53968.js'),d=require('./d62fc37d7aa6416d5dcc240ba94175cd.js'),e=require('./1dea83a77e99a7c94f6b6f01f5c175b0.js'),f=require('./dd93307b3045531926d5a6645f6f3455.js'),g=require('./51a8f674caffc4c2fa2358314af90837.js'),h=require('./72653d4b93cdd7443296229431a7aa9a.js'),i=require('./99fff845d6c7bff564f99e38e435f827.js'),j=require('./6620a0cf7dad1b400d60f0fdae40f524.js');class k extends b.Component{constructor(a){super(a),this.syncDialogMap={},this.readyForLaunch=!1}componentDidMount(){this._onAppServiceMessage=this.onAppServiceMessage.bind(this),c.register(this._onAppServiceMessage),this._onAppDataMessage=this.onAppDataMessage.bind(this),f.register(this._onAppDataMessage),this._onStorageMessage=this.onStorageMessage.bind(this),g.register(this._onStorageMessage),this.initProjectFileWatcher(),this.initWebview()}componentDidUpdate(){this.props.show&&!this.appended&&this.devtoolsview&&this.showDevTools()}componentWillUnmount(){this.devtoolsview&&this.devtoolsview.remove(),this.webview&&this.webview.remove(),c.unRegister(this._onAppServiceMessage),f.unRegister(this._onAppDataMessage),g.unRegister(this._onStorageMessage)}componentWillReceiveProps(a){if(a.assdkCallbackInfo!=this.props.assdkCallbackInfo){let{callbackID:b,res:d}=a.assdkCallbackInfo;this.syncDialogMap[b]?(this.syncDialogMap[b].ok(JSON.stringify(d)),delete this.syncDialogMap[b]):c.invokeCallback(b,d)}a.appLaunched!=this.props.appLaunched&&!1===a.appLaunched&&this.restart(),a.project!=this.props.project&&this.initProjectFileWatcher(),this.readyForLaunch&&!this.appLaunched&&a.currentWebview&&a.currentWebview.ready&&setTimeout(()=>{this.appLaunch()}),a.show!=this.props.show&&a.show&&(this.appended=!1)}initWebview(){this.devtoolsview&&this.devtoolsview.remove(),this.webview&&this.webview.remove();let a=this.devtoolsview=document.createElement('webview'),b=this.webview=document.createElement('webview');b.setUserAgentOverride(`appservice port/${global.messageCenterPort}`),b.setAttribute('partition','persist:appservice'),b.setAttribute('tabIndex','-1'),this.onSyncMessage(b);let c=`${a.getUserAgent()} appservicedevtools port/${global.messageCenterPort} proxy/${global.proxyPort}`;a.setUserAgentOverride(c),a.setAttribute('partition','persist:devtools'),a.setAttribute('style','height:100%;width:100%;position:absolute;'),this.refs.container.appendChild(b),this.restart(),this.props.show&&this.showDevTools()}showDevTools(){let a=this.devtoolsview;this.refs.popupcontainer.appendChild(a);const b=()=>{a.removeEventListener('loadcommit',b),this.webview.showDevTools(!0,this.devtoolsview)};a.addEventListener('loadcommit',b),a.src='about:blank',this.appended=!0}appLaunch(){let a=this.props;this.readyForLaunch&&!this.appLaunched&&a.currentWebview&&a.currentWebview.ready&&(c.triggerOnEvent({eventName:'onAppRoute',data:{path:a.currentWebview.pathName+'.html',query:a.currentWebview.query,openType:'appLaunch'}}),this.props.simulatorActions.setAppLaunched(!0),this.appLaunched=!0)}restart(){if(this.loading)return;this.props.simulatorActions.setAppLaunched(!1);let a=()=>{this.webview.removeEventListener('loadstop',a),this.readyForLaunch=!0,this.loading=!1,this.appLaunch()},b=`http://${this.props.project.hash}.appservice.open.weixin.qq.com/appservice`;this.readyForLaunch=!1,this.loading=!0,this.appLaunched=!1,this.webview.src=b,this.webview.addEventListener('loadstop',a)}onAppServiceMessage(a){let{command:b,data:d}=a;'APPSERVICE_PUBLISH'==b?c.publish(a):'APPSERVICE_INVOKE'==b?this.props.assdkActions.exec(d):'SEND_APP_DATA'==b&&f.send({command:'SEND_APP_DATA',data:d})}onAppDataMessage(a){let{command:b,data:d}=a;'GET_APP_DATA'==b?f.send({command:'GET_APP_DATA'}):'WRITE_APP_DATA'==b&&c.send({command:'WRITE_APP_DATA',data:d})}onStorageMessage(a){let{command:b,data:c}=a;'EXEC_STORAGE_SDK'==b&&(console.error(c),this.props.assdkActions.exec(c))}onSyncMessage(a){a.addEventListener('dialog',(a)=>{let b=a.messageType||'',c=a.messageText;if('prompt'===b&&(a.preventDefault(),/^____sdk____/.test(c))){let b=JSON.parse(c.replace(/^____sdk____/,'')),d=b.command;'APPSERVICE_INVOKE'===d&&(this.syncDialogMap[b.data.callbackID]=a.dialog,this.props.assdkActions.exec(b.data))}})}setAppConfig(){e(this.props.project).then((a)=>{this.props.simulatorActions.setAppConfig(a)})}initProjectFileWatcher(){this.props.project&&!this.projectFiles&&d(this.props.project.projectpath).then((b)=>{this.projectFiles=b,this.projectFiles.on('all',(b,c)=>{let d=a.extname(c);'.json'===d&&process.nextTick(()=>{this.setAppConfig()})}),this.setAppConfig()})}onAppserviceWindowClose(){this.props.setDebuggerWindow({show:!1})}render(){let a=this.props;return b.createElement('div',{ref:'container',style:{height:0}},b.createElement(i,null),a.show?b.createElement(j,{title:'\u8C03\u8BD5\u5668',width:500,height:500,always_on_top:!0,onWindowClose:this.onAppserviceWindowClose.bind(this),ref:'popupcontainer'},b.createElement('div',null)):null)}}module.exports=k}(require('lazyload'),require);
 `});else{let b=0;const c=setInterval(()=>{const d=this.webview.src||'';/\?load$/.test(d)?(this.showConsole(a),clearInterval(c)):(b++,10==b&&clearInterval(c))},500)}}onMessage(a){const{command:b,data:c}=a;'APPSERVICE_INVOKE'==b&&this.props.wssdkActions.exec(c)}initWebviewEvent(a){a.addEventListener('dialog',(a)=>{const b=a.messageType||'',c=a.messageText;if('prompt'!==b);else if(a.preventDefault(),/^____sdk____/.test(c)){const b=JSON.parse(c.replace(/^____sdk____/,'')),d=b.command;'APPSERVICE_INVOKE'===d&&(this.syncDialogMap[b.data.callbackID]=a.dialog,this.props.wssdkActions.exec(b.data))}else c===q.GET_MESSAGE_TOKEN&&a.dialog.ok(r.getToken())})}initWebview(){this.devtoolsview&&this.devtoolsview.remove(),this.webview&&this.webview.remove();const a=this.devtoolsview=document.createElement('webview'),b=this.webview=document.createElement('webview'),c=t.getSessionToken(s.UA_TOKEN);b.setUserAgentOverride(`wechatdevtools widgetservice port/${global.messageCenterPort} token/${c}`),b.setAttribute('partition','persist:appservice'),b.setAttribute('tabIndex','-1'),this.initWebviewEvent(b);const d=`${a.getUserAgent()} widgetservicedevtools port/${global.messageCenterPort}`;a.setUserAgentOverride(d),a.setAttribute('partition','persist:devtools'),a.setAttribute('style','height:100%;width:100%;position:relative;'),a.addEventListener('dialog',function(a){const b=a.messageType||'',c=a.messageText;'prompt'===b&&c===q.GET_MESSAGE_TOKEN&&a.dialog.ok(r.getToken())}),this.serviceContainer.appendChild(b),this.showDevTools()}showDevTools(){const a=this.devtoolsview,b=this.webview;this.container.appendChild(a),this.hackNewWindow(a);const c=()=>{a.removeEventListener('loadcommit',c);const d=()=>{b.removeEventListener('loadcommit',d),b.showDevTools(!0,a),o.initWebview(b),this.loaded=!0,this.props.simulatorActions.setAppLaunched(!0)};b.addEventListener('loadcommit',d),this.resetStatus(),b.src=k};a.addEventListener('loadcommit',c),a.src=k}resetStatus(){this.loaded=!1,this.couldGetData=!1}hackNewWindow(a){a.addEventListener('newwindow',function(a){a.preventDefault();let b=a.targetUrl;b&&('https://developers.google.com/web/tools/chrome-devtools/'===b&&(b='https://mp.weixin.qq.com/debug/wxadoc/dev/index.html'),0==b.indexOf('wxfile://')&&(b=b.replace('wxfile://','http://wxfile.open.weixin.qq.com/')),nw.Window.open(b,{width:799,height:799}))})}restart(){if(!this.loaded||!this.webview)return;const a=()=>{this.webview.removeEventListener('loadcommit',a),this.loaded=!0,this.couldGetData=!0,this.props.simulatorActions.setAppLaunched(!0)};this.resetStatus(),this.webview.addEventListener('loadcommit',a);const b=this.props.project,c=`http://127.0.0.1:${global.proxyPort}/widgetservice/${b.compileType}`;this.webview.src=c,this.props.simulatorActions.setWidget({ready:!1})}onResizeStop(a,b,c){this.props.windowActions.setDebuggerWindow({height:c})}getWidgetData(){const a=this.props;if((a.compileType==f.conversation||a.compileType==f.search)&&this.props.ready&&this.couldGetData){this.getWidgetDataTimer&&(clearTimeout(this.getWidgetDataTimer),this.getWidgetDataTimer=null);const b={appid:n.getProjectAppID()};a.compileType==f.conversation?b.cachekey=a.condiction.cachekey:a.compileType==f.search&&(b.scene=1,b.query=a.wxaData,b.cachekey='',b.url=a.condiction.debugUrl,!b.query&&this.showConsole({group:p.config.WIDGET_NETWORK_ERROR,type:'error',msg:p.config.SEARCH_DATA_EMPTY})),m.getWidgetData(b).then((a)=>{const b=1e3*a.interval||5e3;d.send({command:'APPSERVICE_ON_EVENT',data:{eventName:'onDataPush',data:{data:a}}}),this.getWidgetDataTimer=setTimeout(()=>{this.getWidgetData()},b)}).catch((a)=>{this.showConsole({group:p.config.WIDGET_NETWORK_ERROR,type:'error',msg:p.config.FAIL_DYNAMIC_PAGE_DATA+a})})}}render(){const a=this.props,d={height:a.height};return a.show&&!a.editorShow&&(d.flex='1'),b.createElement(g,{innerRef:(a)=>this.container=a,width:'100%',height:a.height,className:c('devtools',{"ui-invisible":!a.show}),style:d,topResizable:!0,onResizeStop:this.onResizeStop.bind(this)},b.createElement('div',{className:'ui-divider ui-divider-horizontal',style:{pointerEvents:'none'}}),b.createElement('div',{ref:(a)=>this.serviceContainer=a,style:{width:0,height:0}}))}}module.exports=u((a)=>{const b=a.toolbar.deviceInfo,c=a.project.current,d=c.compileType,e=c.condiction[d]||{},f=e.list[e.current]||{},g=a.simulator.widget||{};return{project:c,compileType:d,libVersion:c.libVersion,assdkCallbackInfo:a.simulator.assdkCallbackInfo,jssdkCallbackInfo:a.simulator.jssdkCallbackInfo,editorShow:a.window.editor&&a.window.editor.show,show:a.window.debug.show,compileCommand:a.simulator.compileCommand,wxaData:g.wxaData||'',errmsg:g.errmsg||'',ready:g.ready,condiction:f,device:b}},(a)=>({simulatorActions:e.bindActionCreators(j,a),windowActions:e.bindActionCreators(h,a),wssdkActions:e.bindActionCreators(i,a),setDebuggerWindow:e.bindActionCreators(h.setDebuggerWindow,a)}))(v)}(require('lazyload'),require);
'use strict';!function(require,directRequire){const a=require('path'),b=require('react'),c=require('./a1dd553cc059d528bb0ef56afed53968.js'),d=require('./a15851ca252a104aad8b3fd3fc114574.js'),e=require('./dd93307b3045531926d5a6645f6f3455.js'),f=require('./51a8f674caffc4c2fa2358314af90837.js'),g=require('./9a24eb4fb7a49d4dd24531943fc3c899.js'),h=require('./2dfc6a3df6d6fc51266b293c8420e88b.js'),i=require('./72653d4b93cdd7443296229431a7aa9a.js'),j=require('./99fff845d6c7bff564f99e38e435f827.js'),k=require('./6fc66cd42da3e8c155b22db441702cda.js'),l=require('./6620a0cf7dad1b400d60f0fdae40f524.js'),m=require('./3b5f8e2469c474c8d433c1c6926d8999.js'),n=require('./92320c1386e6db6a6f2556736a9bc280.js'),o=require('./ea653f45dc25181ca4f1b108175009b7.js'),p=require('./2a36cc34e5f44e62f9188b9fc0871d70.js'),q=require('classnames'),r=require('./0794878a22a26634e42df858bbaca543.js'),s=require('./ff946754202ecf377034d29daac7c8d9.js'),t=require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),u=require('./common/locales/index.js'),v=require('./3bfffbe88b3d923921f851c0697974fe.js'),w=require('./71734cad2a6081d396ea668ffa405627.js'),x=require('./d3976cc01aeebc5b09e11c4135b6bd8d.js'),y=require('moment'),{resetBackgroundStatus:z}=require('./a3959bb900db9f65ed2e9c5dfa6977b7.js'),A=require('./949d8235c744ced2a80121e4dba34c28.js'),B='about:blank';let C;chrome.webRequest.onBeforeSendHeaders.addListener((a)=>{let{type:b,url:c}=a;if('websocket'===b&&0!==c.indexOf(`ws://127.0.0.1:${global.messageCenterPort}`)){let b=a.requestHeaders||[],c=v.getProjectAppID();if(b.push({name:'Referer',value:`https://servicewechat.com/${c}/devtools/page-frame.html`}),C){for(let a in C)b.push({name:a,value:C[a]});C=void 0}return{requestHeaders:b}}},{urls:['<all_urls>']},['blocking','requestHeaders']);class D extends b.Component{constructor(a){super(a),this.onResizeStop=(a,b,c)=>{this.props.windowActions.setDebuggerWindow({height:c})},this.syncDialogMap={},this.restartTimer=null,this.subPackageLoading={},this.taskMap={}}componentDidMount(){this._onAppServiceMessage=this.onAppServiceMessage.bind(this),c.register(this._onAppServiceMessage),this._onAppDataMessage=this.onAppDataMessage.bind(this),e.register(this._onAppDataMessage),this._onStorageMessage=this.onStorageMessage.bind(this),f.register(this._onStorageMessage),this._onDevtoolsMessage=this.onDevtoolsMessage.bind(this),g.register(this._onDevtoolsMessage),h.initHelper({setDebuggerWindow:this.props.setDebuggerWindow.bind(this)}),this.initWebview()}componentWillUnmount(){this.devtoolsview&&this.devtoolsview.remove(),this.webview&&(this.webview.removeEventListener('newwindow',this._newwindow),this.webview.remove()),c.unRegister(this._onAppServiceMessage),e.unRegister(this._onAppDataMessage),f.unRegister(this._onStorageMessage),g.unRegister(this._onDevtoolsMessage)}componentWillReceiveProps(a){if(a.assdkCallbackInfo!=this.props.assdkCallbackInfo){let{callbackID:b,res:d}=a.assdkCallbackInfo;this.syncDialogMap[b]?(this.syncDialogMap[b].ok(JSON.stringify(d)),delete this.syncDialogMap[b]):c.invokeCallback(b,d)}(a.compileCommand!=this.props.compileCommand||a.device!=this.props.device)&&(c.ready=!1,this.restart()),a.appLaunched!=this.props.appLaunched&&a.appLaunched&&this.taskMap.appLaunched&&(this.taskMap.appLaunched.forEach((a)=>{a()}),delete this.taskMap.appLaunched),a.appRoute!=this.props.appRoute&&('ready'==a.appRoute.status?'appLaunch'==a.appRoute.openType?setTimeout(()=>{this.triggerLaunch()}):this.triggerAppRoute(a):'done'==a.appRoute.status&&this.triggerAppRouteDone(a)),a.networkType!=this.props.networkType&&c.triggerOnEvent({eventName:'onNetworkStatusChange',data:{isConnected:'none'!==a.networkType,networkType:a.networkType}}),a.storage!=this.props.storage&&f.send({command:'UPDATE_STORAGE',data:a.storage}),a.subPackageLoaded!=this.props.subPackageLoaded&&setTimeout(()=>{this.checkSubPackages()})}triggerAppRouteDone(a){let b=a.currentWebview,d=b.pathName;const e=()=>{let e={};for(let a in b.query)e[a]=encodeURIComponent(b.query[a]);c.triggerOnEvent({eventName:'onAppRouteDone',data:{webviewId:b.id,path:d+'.html',query:e,openType:a.appRoute.openType}})};let f=x.checkIsInSubPackage(a.appConfig,d);!f||a.subPackageLoaded[f.root]?e():(!this.taskMap[f.root]&&(this.taskMap[f.root]=[]),this.taskMap[f.root].push(e))}triggerAppRoute(a){let b=a.currentWebview,d=b.pathName;const e=()=>{let e={};for(let a in b.query)e[a]=encodeURIComponent(b.query[a]);c.triggerOnEvent({eventName:'onAppRoute',data:{webviewId:b.id,path:d+'.html',query:e,openType:a.appRoute.openType}})};let f=x.checkIsInSubPackage(a.appConfig,d);!f||a.subPackageLoaded[f.root]?e():(!this.taskMap[f.root]&&(this.taskMap[f.root]=[]),this.taskMap[f.root].push(e))}triggerLaunch(){let a=this.props.currentWebview,b=a.pathName;const d=()=>{c.triggerOnEvent({eventName:'onAppRoute',data:{webviewId:a.id,path:b+'.html',query:a.query,scene:this.props.scene,openType:'appLaunch'}})};let e=x.checkIsInSubPackage(this.props.appConfig,b);e?this.props.subPackageLoaded[e.root]?d():(!this.taskMap[e.root]&&(this.taskMap[e.root]=[]),this.taskMap[e.root].push(d)):this.props.appLaunched?d():(!this.taskMap.appLaunched&&(this.taskMap.appLaunched=[]),this.taskMap.appLaunched.push(d))}initWebview(){this.devtoolsview&&(this.container.removeChild(this.devtoolsview),this.devtoolsview.remove()),this.webview&&(this.appservicecontainer.removeChild(this.webview),this.webview.remove());let a=this.devtoolsview=document.createElement('webview'),b=this.webview=document.createElement('webview');b.setUserAgentOverride(`wechatdevtools appservice port/${global.messageCenterPort}`),b.setAttribute('partition','persist:appservice'),b.setAttribute('tabIndex','-1'),b.addEventListener('exit',(a)=>{('abnormal'===a.reason||'crash'===a.reason||'killed'===a.reason)&&this.initWebview()}),this.initWebviewEvent(b);let c=`${a.getUserAgent()} appservicedevtools port/${global.messageCenterPort} proxy/${global.proxyPort}`;a.setUserAgentOverride(c),a.setAttribute('partition','persist:devtools'),a.setAttribute('style','height:100%;width:100%;position:relative;display:block;'),a.addEventListener('exit',(a)=>{('abnormal'===a.reason||'crash'===a.reason||'killed'===a.reason)&&this.initWebview()}),this.appservicecontainer.appendChild(b),this.showDevTools()}initWebviewEvent(a){a.addEventListener('dialog',(a)=>{let b=a.messageType||'',d=a.messageText;if('prompt'===b){if(a.preventDefault(),/^____sdk____/.test(d)){let b=JSON.parse(d.replace(/^____sdk____/,'')),c=b.command;'APPSERVICE_INVOKE'===c&&(this.syncDialogMap[b.data.callbackID]=a.dialog,this.props.assdkActions.exec(b.data))}}else if('alert'==b)if('DOCUMENT_READY'==d)c.ready=!0,this.props.simulatorActions.setAppLaunched(!0);else if(0==d.indexOf('SUBPACKAGE_READY_')){let a=d.replace(/^SUBPACKAGE_READY_/,'');this.props.simulatorActions.setSubPackage(a,!0)}else if(0===d.indexOf('SET_SOCKET_HEADER:'))try{let a=JSON.parse(d.replace('SET_SOCKET_HEADER:',''));C=a}catch(a){}});let b=a.request;b.onErrorOccurred.addListener((a)=>{let{type:b}=a;if('main_frame'===b&&0===a.error.indexOf('net::')&&'net::ERR_BLOCKED_BY_CLIENT'!==a.error)return void h.display({command:t.DISPLAY_ERROR,data:{code:A.APPSERVICE_NETWORK_ERROR,error:{details:a}}})},{urls:['<all_urls>']}),b.onBeforeSendHeaders.addListener((a)=>{let b=this.props.project;if(b){let b=a.url;if('main_frame'===a.type&&b.match(/\?load$/))return this.restart(),{cancel:!0};if(0!=b.indexOf(`http://127.0.0.1:${global.proxyPort}/appservice`)&&!/favicon\.ico$/.test(b)&&'none'==this.props.networkType)return h.display({command:t.DISPLAY_ERROR,data:{title:u.config.NO_NETWORK_TIPS_TITLE,error:{message:u.config.NO_NETWORK_TIPS_CONTENT.format(b)}}}),{cancel:!0};let d=a.requestHeaders||[],e=d.findIndex((a)=>{return'cookie'===a.name.toLowerCase()});d.splice(e,1);for(var c=0;c<d.length;++c)if('_Cookie'===d[c].name&&(d[c].name='Cookie'),'Referer'===d[c].name){let a=v.getProjectAppID();d[c].value=`https://servicewechat.com/${a}/devtools/page-frame.html`}return{requestHeaders:a.requestHeaders}}},{urls:['<all_urls>']},['blocking','requestHeaders']),b.onHeadersReceived.addListener((a)=>{let{type:b}=a;if('xmlhttprequest'===b){let b=a.responseHeaders||[],c={};return b.forEach((a)=>{let{name:b,value:d}=a;c[b]||(c[b]=[]),c[b].push(d)}),b.push({name:'for-weapp-devtools',value:JSON.stringify(c)}),{responseHeaders:b}}return{}},{urls:['<all_urls>']},['blocking','responseHeaders'])}_newwindow(a){a.preventDefault();let b=a.targetUrl;0===b.indexOf(`http://127.0.0.1:${global.proxyPort}/appservice/appservice`)||`http://127.0.0.1:${global.proxyPort}/favicon.ico`===b||0===b.indexOf('ws://')||0===b.indexOf('wss://')||b&&('https://developers.google.com/web/tools/chrome-devtools/'===b&&(b='https://mp.weixin.qq.com/debug/wxadoc/dev/index.html'),'https://developers.google.com/web/updates/2017/05/devtools-release-notes'===b&&(b='https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/new.html'),0==b.indexOf('wxfile://')&&(b=b.replace('wxfile://','http://wxfile.open.weixin.qq.com/')),nw.Window.open(b,{width:799,height:799}))}hackNewWindow(a){a.addEventListener('newwindow',this._newwindow.bind(this))}showDevTools(){let a=this.devtoolsview,b=this.webview;this.container.appendChild(a),this.hackNewWindow(a);const c=()=>{a.removeEventListener('loadstop',c);const d=()=>{b.removeEventListener('loadstop',d),b.showDevTools(!0,a),this.loaded=!0,this.onWebviewLoadCommit(),this.restart()};b.addEventListener('loadstop',d),this.resetStatus(),b.src=B};a.addEventListener('loadstop',c),a.src=B}resetStatus(){this.loaded=!1,this.taskMap={},this.subPackageLoading={},z()}restart(){clearTimeout(this.restartTimer),this.restartTimer=setTimeout(()=>{if(!this.loaded||!this.webview||!this.props.appConfig)return;h.cleanQueue(),this.props.simulatorActions.launch();let a=()=>{this.webview.removeEventListener('loadcommit',a),this.loaded=!0,c.ready=!0},b=`http://127.0.0.1:${global.proxyPort}/appservice/appservice`;this.resetStatus(),this.webview.src=b,this.webview.addEventListener('loadcommit',a)})}onWebviewLoadCommit(){h.initWebview(this.webview)}onDevtoolsMessage(a){if('CLICK'===a.command&&this.devtoolsview){const a=new UIEvent('click',{bubbles:!0});this.devtoolsview.dispatchEvent(a)}}onAppServiceMessage(a){let{command:b,data:d}=a;'APPSERVICE_PUBLISH'==b?c.publish(a):'APPSERVICE_INVOKE'==b?setTimeout(()=>{this.props.assdkActions.exec(d)}):'SEND_APP_DATA'==b?e.ready&&e.send({command:'SEND_APP_DATA',data:d}):'SYSTEM'==b&&this.onSystemCommand(d.api,d.data)}checkSubPackages(){for(let a in this.props.subPackageLoaded)if(!this.props.subPackageLoaded[a]&&!this.subPackageLoading[a]){this.subPackageLoading[a]=!0;let b=async()=>{let b=await w(this.props.project,a);this.webview.executeScript({code:b},()=>{})};this.props.appLaunched?b():(!this.taskMap.appLaunched&&(this.taskMap.appLaunched=[]),this.taskMap.appLaunched.push(b))}else this.taskMap[a]&&0<this.taskMap[a].length&&(this.taskMap[a].forEach((a)=>{a()}),delete this.taskMap[a])}onSystemCommand(a,b){switch(a){case'checkProxy':{try{let a=nw.App.getProxyForURL(b);c.send({command:'SYSTEM_CALLBACK',data:{api:'checkProxy',data:[{url:b,proxy:a}]}})}catch(a){}break}case'showDecryptedInfo':{c.send({command:'SYSTEM_CALLBACK',data:{api:'showDecryptedInfo',data:this.props.decryptedInfo}});break}case'showSystemInfo':{chrome.processes.getProcessInfo([],!0,(a)=>{let b=0,d=[];for(let c in a){let e=a[c];e.privateMemory&&(b+=e.privateMemory);let{tasks:f,type:g}=e;'extension'===g&&(g='',f.forEach((a)=>{a.tabId||(title=a.title.replace(/.*open\.weixin\.qq\.com\//g,'').replace(/\?.*/,''),g+=`${title};`)}),g=g.replace(/网页视图:/g,'')),g=g.replace('\u7F51\u9875',''),d.push({type:g,osProcessId:e.osProcessId,privateMemory:(e.privateMemory/1024/1024).toFixed(2)})}b=b/1024/1024,c.send({command:'SYSTEM_CALLBACK',data:{api:'showSystemInfo',data:{restartInfo:{restartTimes:this.props.restartTimes,beginTime:y(global.beginTime).calendar()},memory:b,info:d}}})});break}case'openToolsLog':{nw.Shell.openItem(n.WeappLog);break}case'openVendor':{nw.Shell.openItem(n.WeappVendor);break}case'syncMessage':{p.sync();break}case'qcloudup':{(async(a={})=>{let b=await r.operate(this.props.project,a);c.send({command:'SYSTEM_CALLBACK',data:{api:'qcloudup',data:b}})})(b);break}case'build':{this.props.simulatorActions.compile({origin:t.COMPILE_ORIGIN.CONSOLE});break}case'preview':{this.props.toolbarActions.togglePreviewCode();break}case'upload':{this.props.infoActions.setUploadInfo({show:!0});break}default:}}onAppDataMessage(a){let{command:b,data:d}=a;'GET_APP_DATA'==b?(e.ready=!0,c.send({command:'GET_APP_DATA'})):'WRITE_APP_DATA'==b?c.send({command:'WRITE_APP_DATA',data:d}):'ON_PANEL_HIDE'==b&&(e.ready=!1)}onStorageMessage(a){let{command:b,data:c}=a;'EXEC_STORAGE_SDK'==b?this.props.assdkActions.exec(c):'STORAGE_PANNEL_SHOW'==b?(f.ready=!0,this.props.assdkActions.exec({api:'getStorage',args:{},callbackID:-1})):'STORAGE_PANNEL_HIDE'==b&&(f.ready=!1)}render(){let a=this.props,c={height:a.height};a.show&&!a.editorShow&&(c.flex='1');let d=q('devtools',{"ui-invisible":!a.show});return b.createElement(o,{innerRef:(a)=>this.container=a,width:'100%',height:a.height,className:d,style:c,topResizable:!0,onResizeStop:this.onResizeStop},b.createElement(j,null),b.createElement(k,null),b.createElement('div',{className:'ui-divider ui-divider-horizontal',style:{pointerEvents:'none'}}),b.createElement('div',{ref:(a)=>this.appservicecontainer=a,style:{width:0,height:0},tabIndex:-1}))}}module.exports=D}(require('lazyload'),require);
'use strict';!function(require,directRequire){const a=require('react'),b=require('prop-types'),c=require('url'),d=require('./41c99b908d0cb118c2a6fcf3c306663c.js'),e=require('./3b5f8e2469c474c8d433c1c6926d8999.js'),f=require('./a15851ca252a104aad8b3fd3fc114574.js'),g=require('./0db6515f85d6f6210c2d50722041eb1f.js'),h=require('./d00040b9bed6196b3701ea7c8a4b4db3.js'),i=require('./e9e3fd38aeedddd6db73d1d015ff6952.js'),j=require('./72653d4b93cdd7443296229431a7aa9a.js'),k=require('./709f7f8328edb932b1169de8b7e694dd.js'),l=require('./3e4c71c2a2cc438e1b3afc3fb10bd4b6.js'),m=require('./a1dd553cc059d528bb0ef56afed53968.js'),n=require('./919ad605b043ca39c480b04f2062eb9a.js'),o=require('./3bfffbe88b3d923921f851c0697974fe.js'),p=require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),q=require('./2dfc6a3df6d6fc51266b293c8420e88b.js'),r=require('./common/locales/index.js'),s=require('./a78e6d6a87de1708226375ca4c320d76.js'),t=require('./d3976cc01aeebc5b09e11c4135b6bd8d.js'),u=require('./d2baddafb02abd034d543c2a31ef97a0.js'),v=require('./f6cbcecf6ed9f533f6a506310d8f07b6.js'),w=require('./949d8235c744ced2a80121e4dba34c28.js'),x=require('./41168dca39589e852da6631126d0f94d.js'),y=require('./a7261ee5e1a26dddf8d07b048ad1c94d.js'),z=require('./87822abadd12d18b00ea00716f2410f6.js'),A=require('./ff946754202ecf377034d29daac7c8d9.js'),{weappStoreFileReqular:B,weappTmpFileReqular:C,weappUsrFileReqular:D,weappStoreFilePathPrefix:E,weappTmpFilePathPrefix:F,weappUsrFilePathPrefix:G}=require('./6242f55dbdfe53c2f07b7a51568311f2.js'),{validType:H,tokenManager:I}=require('./dc244a5ba483ad6e0acd267d3b91b282.js'),J='darwin'===process.platform;let K={};class L extends a.Component{constructor(a){super(a),this._consolemessage=this.consolemessage.bind(this),this._onWebviewMessage=this.onWebviewMessage.bind(this),this.state={zIndex:'standby'==a.type?-1:0},this.consoleMsgQueue={}}componentDidMount(){const a=this.props,b=this.container,c=this.webviewID=a.info.id;this.context.isPopup&&this.adjustWindowSize();const d=this.webview=s.get('simulator',{id:c,width:a.width,height:a.height,dpr:a.dpr});d.needDebugger=1,this.props.muted&&d.setAudioMuted(!0),this.setWebviewHeight(),this.setUserAgentOverride(),'tip'==a.type?d.src=`html/weappabout.html?${c}`:(this.initEvent(),this.initDebuggeeEvent(),d.src=`http://127.0.0.1:${global.proxyPort}/aboutblank?${c}`),d.attach(b),f.register(c,this._onWebviewMessage),this.wxmlMessager=i.get('wxml_miniprogram'),global.online&&z.manager.addWebview(c,d._webview)}componentWillReceiveProps(a){if(a.jssdkCallbackInfo!=this.props.jssdkCallbackInfo){const{callbackID:b,res:c,webviewID:d}=a.jssdkCallbackInfo;d==a.info.id&&f.invokeCallback(d,b,c)}if(a.interfaceCallbackInfo!=this.props.interfaceCallbackInfo){const{data:b}=a.interfaceCallbackInfo;b&&b.webviewID==a.info.id&&this.handleInterfaceInvocation(a.interfaceCallbackInfo)}if(a.captureScreen!=this.props.captureScreen&&a.captureScreen.webviewID==this.webviewID&&setTimeout(()=>{this.captureScreen()}),(a.info.pathName!=this.props.info.pathName||a.info.forceLoad!=this.props.info.forceLoad&&a.info.pathName)&&setTimeout(()=>{this.loadPage()}),a.type!=this.props.type&&'standby'!=a.type&&this.setState({zIndex:0}),a.wxmlInspected!=this.props.wxmlInspected&&this.webview&&this.webview.setEmulationTouch(!a.wxmlInspected),(a.muted&&!this.props.muted||!a.muted&&this.props.muted)&&this.webview&&this.webview.setAudioMuted(a.muted),this.props.info.ready&&a.show!=this.props.show)if(clearTimeout(this.hideTimer),!a.show){try{this.props.appConfig.entryPagePath.match(/^(.+)\.html$/)[1]===this.props.info.pathName&&this.webview.captureVisibleRegion({format:'png'},(a)=>{this.props.projectActions.updateProjectCover({image:a})})}catch(a){j.error('fail: capture screen while leaving first page'+a.toString())}this.hideTimer=setTimeout(()=>{this.setState({zIndex:1})},200)}else this.setState({zIndex:2});a.height!=this.props.height&&(clearTimeout(this._setWebviewHeightTimer),this._setWebviewHeightTimer=setTimeout(()=>{this.context.isPopup&&this.adjustWindowSize(),this.setWebviewHeight()})),a.shareInfoShow!=this.props.shareInfoShow&&a.shareInfoShow&&a.show&&!a.info.htmlwebviewInfo&&this.webview.executeScript({code:'alert(\'GET_WEBVIEW_SCROLL_Y\' + window.scrollY);window.scrollTo(0,0);'},()=>{this.webview.captureVisibleRegion({format:'png'},(a)=>{this.props.simulatorActions.setShareDataURI(this.webviewID,a),this.webview.executeScript({code:`window.scrollTo(0,${this.webviewScrollY})`},()=>{this.webviewScrollY=void 0})})})}componentWillUnmount(){this.webview&&this.webview.detach(),global.online&&z.manager.removeWebview(this.props.info.id),this.props.simulatorActions.setDebuggee(void 0,this.webviewID,!1),f.unRegister(this.webviewID,this._onWebviewMessage)}adjustWindowSize(){}handleInterfaceInvocation(a){function b(a){y.invokeCallback({callbackID:c,data:a})}const{callbackID:c,method:d,data:e}=a;switch(d){case'getWebviewHTML':{this.documentReady?this.webview.executeScript({code:'document.body.innerHTML'},(a)=>{a&&a[0]?b(a[0]):b('')}):b('');break}case'getScreenShot':{this.webview.captureVisibleRegion({format:'png'},(a)=>{b(a)});break}}}captureScreen(){this.webview.captureVisibleRegion({format:'png'},(a)=>{const b=Buffer.from(a.replace('data:image/png;base64,',''),'base64'),c=v.copyFileDataToTemp(this.props.project,b,'.png'),{webviewID:d,callbackID:e}=this.props.captureScreen;this.props.simulatorActions.assdkCallback({callbackID:e,res:{errMsg:'captureScreen:ok',tempFilePath:c}})})}setWebviewHeight(){let a=this.props.width/this.props.deviceScale,b=this.props.height/this.props.deviceScale;'popup'==this.props.position&&(b=this.props.height,a=this.props.width),this.webview.setAttribute('style',`position:absolute;height:${b}px;width:${a}px;`);try{this.webview.setOffset({height:this.props.height,width:this.props.width,dpr:this.props.dpr})}catch(a){}}reload(){this.documentReady=!1;const a=this.webview;this.setUserAgentOverride(),a.src=`http://127.0.0.1:${global.proxyPort}/__pageframe__/pageframe.html`}setUserAgentOverride(){const a=I.getSessionToken(H.UA_TOKEN);let b=this.props.ua.replace('{{webviewID}}',this.webviewID);b+=` port/${global.messageCenterPort} token/${a}`,this.webview.setUserAgentOverride(b)}async animateWebviewTransition(a){return new Promise((b)=>{if(!this.container)return;let{top:c,left:d,height:e,width:f}=this.container.getBoundingClientRect();if(e/=this.props.deviceScale,f/=this.props.deviceScale,c=this.props.top,d=0,'enter'===a){const a=this.container.style.cssText,g=`position:fixed; width:${f}px; height:${e}px; top:${c}px; left:${d}px;`;this.container.style.cssText='z-index: 2;'+g,this.container.style.transform=`translate(${f}px, 0)`;const h=()=>{this.container.removeEventListener('transitionend',h),this.container.style.cssText=a,this.setState({zIndex:this.props.show?1:0},b)};this.container.addEventListener('transitionend',h);const i=this.context.window||global.Win;i.window.requestAnimationFrame(()=>{this.container&&(this.container.style.transition='all linear 0.2s',this.container.style.transform='translate(0,0)')}),this.container.offsetHeight}else if('exit'===a){const a=this.container.style.cssText,g=`position:fixed; width:${f}px; height:${e}px; top:${c}px; left:${d}px;`;this.container.style.cssText='z-index: 2;'+g,this.container.style.transform='translate(0, 0)';const h=()=>{this.container.removeEventListener('transitionend',h),this.container.style.cssText=a,this.setState({zIndex:this.props.show?1:0},b)};this.container.addEventListener('transitionend',h);const i=this.context.window||global.Win;i.window.requestAnimationFrame(()=>{this.container&&(this.container.style.transition='all linear 0.2s',this.container.style.transform=`translate(${f}px,0)`)}),this.container.offsetHeight}})}async loadPage(){const a=this.webview;if(!this.webview||!this.props.info||!this.props.info.pathName||!this.documentReady)return;const b=this.props.info;if(b.pageNotFound&&!b.forceLoad)return void m.triggerOnEvent({eventName:'onPageNotFound',data:{path:b.pathName,query:b.query,isEntryPage:b.isEntryPage},webviewID:this.webviewID});this.setWebviewHeight();const d=b.pathName;a.setAttribute('route',d);const e=c.parse(a.src);e.pathname=`__pageframe__/${d}`;const f=c.format(e);let g='';try{g=await u(this.props.project,d)}catch(a){return void q.display({command:p.DISPLAY_ERROR,data:{error:a}})}g=`var script = document.createElement('script')
      script.text = \`
        history.pushState('','', '${f}')
        ${g};
      \`
      document.head.appendChild(script)`,a.executeScript({code:g},()=>{Date.now();this.props.simulatorActions.setWebviewReady(this.webviewID,!0),this.onWebviewReady()})}consolemessage(a){const b=a.message;this.consoleMsgQueue[b]||(this.consoleMsgQueue[b]=!0,n(a))}onWebviewReady(){this.props.muted&&setTimeout(()=>{this.webview.setAudioMuted(this.props.muted)},100)}onWebviewMessage(a){let b={};try{b=JSON.parse(a)}catch(b){return void j.error(`onWebviewMessage parse ${a} error ${b}`)}if('WEBVIEW_PUBLISH'==b.command)f.publish(a);else if('WEBVIEW_INVOKE'==b.command){const a=b.data.api;'initReady'==a&&this.initReady();const c=b.data.callbackID;this.props.jssdkActions.exec(b.data,this.webviewID).then((a)=>{a&&f.invokeCallback(this.webviewID,c,a)})}else'PULLDOWN_REFRESH'==b.command&&m.triggerOnEvent({eventName:'onPullDownRefresh',data:{},webviewID:this.webviewID})}initReady(){setTimeout(()=>{b()},20);const a=-1==this.props.info.tabbarIndex;var b=()=>{a?(this.animateWebviewTransition('enter'),this.props.simulatorActions.setAppRoute({status:'done'})):(this.setState({zIndex:this.props.show?2:1}),this.props.simulatorActions.setAppRoute({status:'done'})),setTimeout(()=>{this.tryCaptureScreenForBackground()},2e3)}}tryCaptureScreenForBackground(){if(!global.online){this._captureTryCount||(this._captureTryCount=0),this._captureTryCount++;try{this.props.appConfig.entryPagePath.match(/^(.+)\.html$/)[1]===this.props.info.pathName&&this.webview.captureVisibleRegion({format:'png'},async(a)=>{try{const b=await x({taskName:'isSameColorImage',config:{type:'dataURI',format:'png'},dataStr:a,maxTimeout:60000,useBackup:!1,downgrade:!0});if(b.error)throw new Error(b.error);if(b.same){if(5<this._captureTryCount)return;setTimeout(this.tryCaptureScreenForBackground.bind(this),2e3)}else this.props.projectActions.updateProjectCover({image:a})}catch(a){j.info('process capture screen failure with err: '+a.toString())}})}catch(a){j.info('chrome capture screen failure with err: '+a.toString())}}}initDebuggeeEvent(){global.useChromeRemoteDebugProtocal&&(this.webview.onDebuggeeEvent=(a,b,c={})=>{if('DOM.inlineStyleInvalidated'!==b&&'DOM.characterDataModified'!==b&&('Overlay.nodeHighlightRequested'!==b||'Overlay.nodeHighlightRequested'!==K.method||c.nodeId!==K.nodeId)){K='Overlay.nodeHighlightRequested'===b?{method:b,nodeId:c.nodeId}:{};({"DOM.documentUpdated":!0,"DOM.childNodeCountUpdated":!0,"DOM.setChildNodes":!0,"DOM.childNodeRemoved":!0,"DOM.childNodeInserted":!0,"DOM.attributeRemoved":!0,"DOM.attributeModified":!0,"Overlay.inspectNodeRequested":!0,"DOM.nodeHighlightRequested":!0,"Overlay.nodeHighlightRequested":!0})[b]&&this.wxmlMessager.triggerOnEvent('ON_EVENT',{debuggee:a,method:b,params:c})}}),this.webview.onDebuggeeDetach=(a)=>{this.props.simulatorActions.setDebuggee(a,this.webviewID,!1)},this.webview.onDebuggeeAttach=(a)=>{this.props.simulatorActions.setDebuggee(a,this.webviewID,!0),this.reload()}}initEvent(){const a=this.webview;a.on('consolemessage',this._consolemessage),a.on('dialog',(a)=>{const b=a.messageType||'',c=a.messageText,d=a.dialog;'alert'===b?'DOCUMENT_READY'==c?(this.documentReady=!0,this.loadPage()):0==c.indexOf('GET_WEBVIEW_SCROLL_Y')?this.webviewScrollY=c.replace('GET_WEBVIEW_SCROLL_Y',''):0==c.indexOf('\u8FDB\u5165\u5BA2\u670D\u4F1A\u8BDD')&&this.props.simulatorActions.setConfirm({show:!0,content:c,showCancel:!1,confirmText:r.config.RETURN}):'confirm'===b?a.preventDefault():'prompt'===b&&(c===p.GET_MESSAGE_TOKEN?a.dialog.ok(A.getToken()):a.dialog.ok(''))}),a.on('mouseleave',()=>{a.setEmulationTouch(!1)}),a.on('mouseenter',()=>{this.props.wxmlInspected||a.setEmulationTouch(!0)}),this.initRequestListener(a)}initRequestListener(a){a.request;this.webview.onRequestErrorOccurred=(a)=>{const{type:b}=a;'script'===b||'main_frame'===b||'net::ERR_ABORTED'===a.error||'image'==a.type&&`http://127.0.0.1:${global.proxyPort}/__pageframe__/${this.props.info.pathName}`==a.url||q.display({command:p.DISPLAY_ERROR,data:{error:{code:w.WEBVIEW_NETWORK_ERROR,details:a}}})},this.webview.onBeforeRequest=(a)=>{const b=a.url;if(0==b.indexOf(`http://127.0.0.1:${global.proxyPort}/`)){const a=c.parse(b),d=a.pathname.replace(/^\//,'');if('aboutblank'!=d&&'favicon.ico'!=d&&!/^__pageframe__\//.test(d)&&0!==d.indexOf(E)&&0!==d.indexOf(F)&&0!==d.indexOf(G)&&0!==d.indexOf('experience'))return{redirectUrl:`http://127.0.0.1:${global.proxyPort}/__pageframe__/${d}`}}else{if(B.test(b)||C.test(b)||D.test(b))return{redirectUrl:b.replace(/^https?:\/\//,`$&127.0.0.1:${global.proxyPort}/`)};if(/^file:\/\//i.test(b))return{cancel:!0}}},this.webview.onRequestBeforeSendHeaders=(a)=>{const b=a.url;if(0!=b.indexOf(`http://127.0.0.1:${global.proxyPort}/`)&&!/favicon\.ico$/.test(b)&&'none'==this.props.networkType)return q.display({command:p.DISPLAY_ERROR,data:{title:r.config.NO_NETWORK_TIPS_TITLE,error:{message:r.config.NO_NETWORK_TIPS_CONTENT.format(b)}}}),{cancel:!0};if(0==b.indexOf(`http://127.0.0.1:${global.proxyPort}/__pageframe__`)){const a=c.parse(b),d=a.pathname.replace(/^\/__pageframe__\//,''),e=t.checkIsInSubPackage(this.props.appConfig,d),f=t.checkIsInSubPackage(this.props.appConfig,this.props.info.pathName);if(e&&e!=f)return q.display({command:p.DISPLAY_ERROR,data:{title:r.config.RESOURCE_RELATIVE_TIPS_TITLE,error:{message:r.config.RESOURCE_RELATIVE_TIPS_CONTENT.format(d)}}}),{cancel:!0}}const d=a.requestHeaders||[],e=d.findIndex((a)=>'cookie'===a.name.toLowerCase());d.splice(e,1);for(let b=0;b<d.length;++b)if('Referer'===d[b].name){const a=o.getProjectAppID();d[b].value=`https://servicewechat.com/${a}/devtools/page-frame.html`}return{requestHeaders:a.requestHeaders}},this.webview.onRequestCompleted=(a)=>{const{type:b,statusCode:c}=a;if('script'!==b&&'main_frame'!==b&&400<=c){if('image'==a.type&&`http://127.0.0.1:${global.proxyPort}/__pageframe__/${this.props.info.pathName}`==a.url)return;q.display({command:p.DISPLAY_ERROR,data:{error:{code:w.WEBVIEW_NETWORK_ERROR,details:a}}})}}}render(){const b=this.props,c={position:'absolute',width:b.width,height:b.height,top:b.top,zIndex:this.state.zIndex},e=b.info.htmlwebviewInfo;return a.createElement('div',{className:'webview',ref:(a)=>this.container=a,style:c},e?a.createElement(d,{webviewID:b.info.id,htmlId:e.htmlId,url:e.src||'',originUrl:e.originUrl||'',cangoback:e.cangoback,width:e.position&&e.position.width||b.width,height:e.position&&e.position.height||b.height,left:e.position&&e.position.left||0,top:e.position&&e.position.top||0}):null)}}L.contextTypes={isPopup:b.bool,window:b.object},module.exports=L}(require('lazyload'),require);
'use strict';!function(require,directRequire){const a=require('react'),b=require('./d3976cc01aeebc5b09e11c4135b6bd8d.js'),c=require('./c4190a2430506f3602ca550e1e75d620.js'),d=require('./9a24eb4fb7a49d4dd24531943fc3c899.js'),{connect:e}=require('react-redux');class f extends a.Component{componentDidMount(){this.initWebview()}componentWillReceiveProps(a){a.webview!=this.props.webview&&a.webview&&setTimeout(()=>{this.showDevTools()}),a.device!=this.props.device&&setTimeout(()=>{this.setDevice()})}initWebview(){let a=this.devtoolsview=document.createElement('webview');a.setAttribute('partition','persist:devtools'),a.setAttribute('style','height:100%;width:100%;position:relative;');let b=`${a.getUserAgent()} devtoolsview port/${global.messageCenterPort}`;a.setUserAgentOverride(b),this.container.appendChild(a)}setDevice(){const a=this.props;d.send({command:'SET_DEVICE',data:{width:0,height:0,deviceScaleFactor:parseFloat(a.dpr),mobile:!0,fitWindow:!1,scale:1,screenHeight:parseInt(a.height),screenWidth:parseInt(a.width),positionX:0,positionY:0,screenOrientation:{angle:0,type:'portraitPrimary'}}})}_newwindow(a){a.preventDefault();let b=a.targetUrl;b&&('https://developers.google.com/web/tools/chrome-devtools/'===b&&(b='https://mp.weixin.qq.com/debug/wxadoc/dev/index.html'),'https://developers.google.com/web/updates/2017/05/devtools-release-notes'===b&&(b='https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/new.html'),nw.Window.open(b,{width:799,height:799}))}showDevTools(){let a=this.props.webview,b=this.devtoolsview;const c=()=>{b.removeEventListener('loadcommit',c);const d=()=>{a.removeEventListener('loadcommit',d),a.showDevTools(!0,b)};a.addEventListener('loadcommit',d),a.src='html/about.html'};b.addEventListener('loadcommit',c),b.addEventListener('contentload',()=>{this.setDevice()}),b.src='about:blank',b.addEventListener('newwindow',this._newwindow)}render(){return a.createElement('div',{ref:(a)=>this.container=a,style:{flex:1},className:'devtools'})}}module.exports=e((a)=>{let b=a.webdebugger||{},c=a.toolbar.deviceInfo;return{device:c,dpr:c.dpr,height:c.screenHeight-c.navigationbarHeight-c.statusbarHeight,width:c.screenWidth,webview:b.webview}},(a)=>{return{debuggerActions:b.bindActionCreators(c,a)}})(f)}(require('lazyload'),require);