webview-module-api
Version:
Standard module APIs of the <web-view> component within windmill.
2 lines • 25.8 kB
JavaScript
/* __webviewModuleApi (0.3.8), build at 2019-06-05 18:17. */
var __webviewModuleApi=function(){"use strict";"undefined"==typeof window&&(window={ctrl:{},lib:{}}),!window.ctrl&&(window.ctrl={}),!window.lib&&(window.lib={}),function(l,e){function t(e,t){e=e.toString().split("."),t=t.toString().split(".");for(var n=0;n<e.length||n<t.length;n++){var r=parseInt(e[n],10),i=parseInt(t[n],10);if(window.isNaN(r)&&(r=0),window.isNaN(i)&&(i=0),r<i)return-1;if(i<r)return 1}return 0}var u=l.Promise,i=l.document,n=l.navigator.userAgent,a=/Windows\sPhone\s(?:OS\s)?[\d\.]+/i.test(n)||/Windows\sNT\s[\d\.]+/i.test(n),s=a&&l.WindVane_Win_Private&&l.WindVane_Win_Private.call,c=/iPhone|iPad|iPod/i.test(n),d=/Android/i.test(n),r=n.match(/WindVane[\/\s](\d+[._]\d+[._]\d+)/),o=Object.prototype.hasOwnProperty,f=e.windvane=l.WindVane||(l.WindVane={version:"3.0.4"}),p=Math.floor(65536*Math.random()),g=1,v=[],h="iframe_",m="param_",y={isAvailable:1===t(r=r?(r[1]||"0.0.0").replace(/\_/g,"."):"0.0.0","0"),isNewBridgeAvailable:1===t(r,d?"8.3.0":"8.2.0"),call2:function(e,t,n,r,i){var o=e.indexOf(".");return y.call(e.substr(0,o),e.substr(o+1),t,n,r,i)},call:function(e,t,n,r,i,o){var a,s;if("number"==typeof arguments[arguments.length-1]&&(o=arguments[arguments.length-1]),"function"!=typeof r&&(r=null),"function"!=typeof i&&(i=null),!u||r||i||(s=new u(function(e,t){r=e,i=t})),y.isNewBridgeAvailable&&l.__windvane__&&l.__windvane__.call)return l.__windvane__.call(e+"."+t,n,r,i,o),s;a=b.getSid();var c={success:r,failure:i};return 0<o&&(c.timeout=setTimeout(function(){y.onFailure(a,{ret:"HY_TIMEOUT"})},o)),b.registerCall(a,c),b.registerGC(a,o),y.isAvailable?b.callMethod(e,t,n,a):y.onFailure(a,{ret:"HY_NOT_IN_WINDVANE"}),s},fireEvent:function(e,t,n){var r=i.createEvent("HTMLEvents");r.initEvent(e,!1,!0),r.param=b.parseData(t),i.dispatchEvent(r)},getParam:function(e){return b.getParam(e)},setData:function(e,t){},find:function(e,t){t||b.unregisterCall(e,!1)},onSuccess:function(e,t,n){b.onComplete(e,t,"success",n)},onFailure:function(e,t){b.onComplete(e,t,"failure")}};y.isNewBridgeAvailable&&l.__windvane__&&l.__windvane__.callSync&&(y.callSync=function(e,t){if(c)return l.__windvane__.callSync(e,t);if(d){var n={name:e};t&&(n.params=JSON.stringify(t));var r=l.__windvane__.callSync(n);if(r)try{return JSON.parse(r)}catch(e){}}});var b={params:{},calls:{},getSid:function(){return(p+g++)%65536+""},buildParam:function(e){return e&&"object"==typeof e?JSON.stringify(e):e||""},getParam:function(e){return this.params[m+e]||""},setParam:function(e,t){this.params[m+e]=t},parseData:function(t){var n;if(t&&"string"==typeof t)try{n=JSON.parse(t)}catch(e){n={ret:"HY_RESULT_PARSE_ERROR",originValue:t}}else n=t||{};return n},registerCall:function(e,t){this.calls[e]=t},unregisterCall:function(e,t){var n=this.calls[e]||{},r=n.timeout;return r&&clearTimeout(r),t||delete this.calls[e],n},useIframe:function(e,t){var n=h+e,r=v.pop();r||((r=i.createElement("iframe")).setAttribute("frameborder","0"),r.style.cssText="width:0;height:0;border:0;display:none;"),r.setAttribute("id",n),r.setAttribute("src",t),r.parentNode||setTimeout(function(){i.body.appendChild(r)},5)},retrieveIframe:function(e){var t=h+e,n=i.querySelector("#"+t);if(n)if(3<=v.length)try{i.body.removeChild(n)}catch(e){}else v.indexOf(n)<0&&v.push(n)},callMethod:function(e,t,n,r){var i=b.buildParam(n);if(a)s?l.WindVane_Win_Private.call(e,t,r,i):this.onComplete(r,{ret:"HY_NO_HANDLER_ON_WP"},"failure");else if(c){this.setParam(r,i);var o="hybrid://"+e+":"+r+"/"+t+"?"+encodeURIComponent(i);this.useIframe(r,o)}else if(d){this.setParam(r,n);o="hybrid://"+e+":"+r+"/"+t+"?"+i;window.prompt(o,"wv_hybrid:")}else this.onComplete(r,{ret:"HY_NOT_SUPPORT_DEVICE"},"failure")},registerGC:function(e,t){var n=this,r=Math.max(t||0,6e5),i=Math.max(t||0,6e4);setTimeout(function(){n.unregisterCall(e)},r),c&&setTimeout(function(){n.params[m+e]&&delete n.params[m+e]},i)},onComplete:function(e,t,n,r){var i=this.unregisterCall(e,r),o=i.success,a=i.failure,s=(t=this.parseData(t)).ret;"string"==typeof s&&((t=t.value||t).ret||(t.ret=[s])),"success"===n?o&&o(t):"failure"===n&&a&&a(t),c&&(this.retrieveIframe(e),this.params[m+e]&&delete this.params[m+e])}};for(var w in y)o.call(f,w)||(f[w]=y[w])}(window,window.lib||(window.lib={}));window.lib.windvane;var N="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e,t=(function(e,t){console.log("Start windmill renderer.min (0.4.2) framework. Build at 2018-09-20 19:21"),e.exports=function(){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{writable:!0,enumerable:!1,configurable:!0,value:function(e,t){var n=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(e),i=1;i<arguments.length;i++){var o=n[i];if(null!=o)for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(r[a]=o[a])}return r}});var t,o=(t=1e5,function(){var e=String(t);return t+=1,e});function s(e){return Object.prototype.toString.call(e).slice(8,-1)}function c(e){return"Object"===s(e)}function i(){for(var e=arguments,t=[],n=arguments.length;n--;)t[n]=e[n]}var n=function(){},l={},a=["Android","iOS"];function r(e,t){if("object"==typeof process&&process&&process.env,!0===l.debugMode)return!0}function u(e,t){r()&&n("debug",e)}function d(e,t){r()&&n("warn",e)}function f(e,t){r()&&n("error",e)}function p(e){f(e)}n=function(e,t){var n,r="["+((n=e).charAt(0).toUpperCase()+n.slice(1))+"][wml-r] "+t;return l.isWeex&&-1<a.indexOf(l.platform)?console.log(r):console.error(r)};var g={network:["request","uploadFile"],miniApp:["setAppShareInfo","hideLauncherLoading","setWebViewTop","setWebViewBackgroundImage"],mtop:["request"],storage:["length","setItem","getItem","removeItem"],memoryStorage:["setItem","getItem"],tabBar:["show","hide"],navigator:["push","pop","openMessagePage","reloadPage","getBackStack","popToHome","navigateTo","redirectTo","switchTab"],user:["login","logout","info"],modal:["alert","confirm","toast","showLoading","hideLoading"],navigatorBar:["show","hide","setTitle","setRightItem","setStyle","setDrawer","setActionSheet","hasIndexBadge","scaleIndexBadge","resetIndexBadge","getHeight","openDrawer","isDrawerOpened","closeDrawer","setLeftItem","showMenu","hideMenu","getStatusBarHeight","setNavigationBar"],clipboard:["writeText","readText"],picker:["pick","pickDate","pickTime","chooseCity"],webSocket:["webSocket","send","close","onOpen","onMessage","onClose","onError"],calendar:["addEvent","checkEvent","removeEvent"],connection:["getType","getDownlinkMax","onChange"],screen:["setAlwaysOn","setBrightness","getScreenBrightness"],broadcast:["createChannel","postMessage","onMessage","close"],share:["doShare"],cookie:["read","write","getAllObjects"],audio:["load","play","pause","stop","setVolume","canPlayType"],wopc:["authLogin","checkAuthSession","doAuth","getSessionKey","setSessionKey"],WopcMtopPlugin:["request"],device:["onShake","vibrate"],keyboard:["hideKeyboard"],contact:["choosePhoneContact"],location:["getLocation"],alipay:["tradePay"],userTrack:["commit","commitut","commitEvent","customAdvance","pageAppear","pageDisappear","skipPage","updatePageUtparam","updateNextPageUtparam"],"nuvajs-exec":["exec"],aluWVJSBridge:["userIsLogin","refreshAlipayCookie"],TBDeviceInfo:["getUtdid"],actionSheet:["showActionSheet"],image:["chooseImage","previewImage","compressImage","getImageInfo","saveImage"],media:["startVoice","stopVoice"],audioRecord:["startRecord","stopRecord","cancelRecord"],audioPlayer:["playVoice","pauseVoice","stopVoice"],file:["saveFile","getFileInfo","getFileList","removeFile"],video:["chooseVideo","getVideoInfo"],phone:["makePhoneCall"],compass:["startCompass","stopCompass","onCompassChange"],tbsecurity:["secureToken"]},e=function(){};e.prototype.$on=function(e,t){return void 0===t&&(t=i),u('$on "'+e+'"'),!e&&p("invalid event name "+e+" for windmill.$on."),t===i&&p("bind event "+e+" with no callback through windmill.$on."),this.bridge.onReceiveMessage({data:{type:e},origin:this.label,type:"Event"},t)},e.prototype.$once=function(e,t){return void 0===t&&(t=i),u('$once "'+e+'"'),!e&&p("invalid event name "+e+" for windmill.$once."),t===i&&p("bind event "+e+" with no callback through windmill.$once."),this.bridge.onReceiveMessage({data:{type:e,once:!0},origin:this.label,type:"Event"},t)},e.prototype.$off=function(e,t){return u('$off "'+e+'"'),!e&&p("invalid event name "+e+" for windmill.$off."),this.bridge.unbindEventListener("Event."+e,t)},e.prototype.$cycle=function(e,t){return void 0===t&&(t=i),u('$cycle "'+e+'"'),e&&/^app:|^page(:|@)/.test(e)||p("invalid lifecycle name "+e+" for windmill.$cycle."),t===i&&p("hook lifecycle "+e+" with no callback function through windmill.$cycle."),"AppWorker"!==this.label&&/^app:/.test(e)&&p("Shouldn't bind lifecycle hook for app in a page client."),this.bridge.onReceiveMessage({type:"Lifecycle",origin:this.label,data:{type:e}},t)},e.prototype.$decycle=function(e,t){return u('$decycle "'+e+'"'),e&&/^app:|^page(:|@)/.test(e)||p("invalid lifecycle name "+e+" for windmill.$decycle."),this.bridge.unbindEventListener("Lifecycle."+e,t)},e.prototype.$emit=function(e,t,n){return void 0===t&&(t={}),u('$emit("'+e+'")'),!e&&p("invalid event name "+e+" for windmill.$emit."),n&&n!==this.label?this.bridge.postMessage({data:{type:e,data:t},origin:this.label,target:n,type:"Event"}):this.bridge.emitEvent(""+e,t)},e.prototype.$callAsync=function(n,r){var i=this;return void 0===r&&(r={}),u('$callAsync "'+n+'"'),n||p("invalid method name "+n+" for windmill.$callAsync."),new Promise(function(e,t){i.bridge.dispatchMessage({type:"ModuleCall",origin:i.label,target:"AppWorker",data:{method:n,params:r}},e,t,!1)})},e.prototype.$call=function(e,t,n,r){return void 0===t&&(t={}),void 0===n&&(n=i),void 0===r&&(r=i),u('$call "'+e+'", params: '+JSON.stringify(t)),e||p("invalid method name "+e+" for windmill.$call."),this.bridge.dispatchMessage({type:"ModuleCall",origin:this.label,target:"AppWorker",data:{method:e,params:t}},n,r,!0)},e.prototype.$registerModules=function(e){!function(r,i){if(void 0===i&&(i=!1),c(r)){var e=function(t){var e=r[t];g[t]?i||d('The "'+t+'" module has already been registered.It would be overridden.'):g[t]=[];var n=g[t];Array.isArray(e)?e.forEach(function(e){-1===n.indexOf(e)?n.push(e):i||d('The "'+e+'" of the "'+t+'" module has already been registered.')}):f('Invalid parameter type! The method list of the "'+t+'" module should be an Array.')};for(var t in r)e(t)}else f("Invalid parameter type! The module definition is not a plain object.")}(e,!0)},e.prototype.$getAvailableModules=function(){return function(e){var t={};try{t=JSON.parse(JSON.stringify(e))}catch(e){}return t}(g)};var v="[[EVENT_MAP]]";function h(e,t){var n=e[v];return Array.isArray(n[t])||(n[t]=[]),n[t]}var m,y=function(){u("Create new EventEmitter."),Object.defineProperty(this,v,{configurable:!1,enumerable:!1,writable:!1,value:{}})};function b(t){var n;try{n=JSON.stringify(t)}catch(e){n=t}p("failed to postMessage: "+n)}function w(e,t,n,r,i,o){var a=t+"."+n;return e.WindVane?e.WindVane.call(t,n,r,i,o):p("should have WindVane in global context"+(a?" to call "+a:"")+".")}y.prototype.on=function(e,t){return u('EventEmitter: on("'+e+'")'),h(this,e).push({listener:t,once:!1,callCount:0}),this},y.prototype.once=function(e,t){return u('EventEmitter: once("'+e+'")'),h(this,e).push({listener:t,once:!0,callCount:0}),this},y.prototype.off=function(e,t){u('EventEmitter: off("'+e+'"'+(t?", listener":"")+")");var n=this[v];if(t){var r=n[e];if(Array.isArray(r)){var i=r.findIndex(function(e){return e.listener===t});-1!==i&&r.splice(i,1)}}else delete n[e];return this};var _=!(y.prototype.emit=function(t){for(var e=arguments,n=[],r=arguments.length-1;0<r--;)n[r]=e[r+1];u('EventEmitter: emit("'+t+'", '+JSON.stringify(n)+")");var i=this[v],o=i[t];return Array.isArray(o)&&(i[t]=o.filter(function(e){try{e.listener.apply(null,n),e.callCount+=1}catch(e){return f('Failed to emit "'+t+'" event.'),f(e.toString()),!0}return!e.once})),this}),S=function(){this._messages=[]};S.prototype.postMessage=function(e){u("cache message in lazyMsgModule. "+JSON.stringify(e)),this._messages.push(e)},S.prototype.replaceWith=function(e){M=!1,this._messageModule=e,this._flush()},S.prototype._flush=function(){var t=this;this._messages.forEach(function(e){return t._messageModule.postMessage(e)})};var M,A,k=new S;function E(e,t){var n,r=e?(n=e).requireModule("@weex/windmill")||n.requireModule("windmill"):function(){if(!m){var t="undefined"!=typeof window?window:N;m={postMessage:function(e){return w(t,"Windmill","postMessage",e,function(){},b)},onmessage:function(e){if(!_)return _=!0,w(t,"Windmill","onMessage",{},e,b)}}}return m}();if(!r)return p("can't find message module ("+(e?"windmill module":"message module in webview")+")."),M=!0,k;if("function"==typeof t){u('Set the "onmessage" method to the bridge through callback.');try{r.onmessage(t)}catch(e){f('Failed to set the "onmessage" method to the bridge through callback.'),f(e.toString())}}return M&&k.replaceWith(r),r}function I(e){var t=e.match(/([^@]+)(@\S+)/);return t&&t[1]||e}var O=function(e,t){var a=this;void 0===t&&(t={}),u("Create a new RendererBridge."),A=t.isWeex,this._emitter=new y,u("Register onmessage api for "+(A?"Weex windmill module":"webview")+"."),A&&(this._weex=e),this._onMessage=function(e){if(u("Receive message from the worker. (message: "+JSON.stringify(e)+")"),!c(e)&&(f("The parameter of onmessage should be a plain object! Not "+s(e)),"string"==typeof e))try{e=JSON.parse(e)}catch(e){return void f("Failed to parse the message string. "+e.toString())}var t=e.type,n=e.data;void 0===n&&(n={});var r=e.origin,i=e.callbackId;switch(t){case"Callback":a._emitter.emit("callback@AppWorker:"+i,n);break;case"Event":var o=I(n.type);a._emitter.emit(t+"."+o,Object.assign({origin:r},n,{type:o}));break;case"Lifecycle":a._emitter.emit(t+"."+n.lifecycle,n.options);break;case"SetData":a._emitter.emit("Event.setdata",n);break;default:p('Unknown message type received from worker: "'+t+'"')}},E(e,this._onMessage)};O.prototype.dispatchMessage=function(t,n,r,e){u("Dispatch message to worker. (message: "+JSON.stringify(t)+")"),t.callbackId=this._genCallbackId(function(e){return e.status&&"SUCCESS"===e.status?n(e):(e.status,f("call API "+t.data.method+" from renderer failed: "+e.status+", "+e.error),r(e))},{keepAlive:e});try{t.keepAlive=!0,this.postMessage(t)}catch(e){r(e)}},O.prototype.postMessage=function(e){try{u("Call postMessage to worker. (message: "+JSON.stringify(e)+")"),E(this._weex,this._onMessage).postMessage(e)}catch(e){p(e.message||e.toString()||"postMessage failed.")}},O.prototype._genCallbackId=function(e,t){var n=t.keepAlive,r=t.callbackId,i=r||o();return this._emitter[n?"on":"once"]("callback@AppWorker:"+i,e),i},O.prototype.onReceiveMessage=function(e,t){var n=e.type,r=e.data;void 0===r&&(r={});var i=r.type;"Event"===n&&(i=I(i),r.type=i);var o=r.once?"once":"on";this._emitter[o](n+"."+i,t)},O.prototype.unbindEventListener=function(e,t){this._emitter.off(I(e),t)},O.prototype.emitEvent=function(e,t){void 0===t&&(t={});var n=I(e);this._emitter.emit("Event."+n,{type:n,data:t})};var T=function(n){function e(e,t){void 0===t&&(t={}),n.call(this),this._name=t.pageName||"",this.label=t.clientId||"",e&&c(e.config)&&(this._name=e.config.pageName||"",this.label=e.config.clientId||"",e.config.availableModules?(this.$registerModules(e.config.availableModules),this._gotAvailableModulesFromWeex=!0):d("No available modules in weex options.")),u("Create a new RendererRuntime. ("+this.label+", "+this._name+")"),this.bridge=new O(e,t),this._init()}return n&&(e.__proto__=n),((e.prototype=Object.create(n&&n.prototype)).constructor=e).prototype._init=function(){var t=this;this.bridge.onReceiveMessage({origin:"AppWorker",target:this.label,type:"Event",data:{type:"registerModules"}},function(e){e&&"registerModules"===e.type&&(u("Register available modules in renderer. ("+Object.keys(e.data)+")"),t.$registerModules(e.data))})},e.prototype.ready=function(){this.bridge.dispatchMessage({origin:this.label,target:"AppWorker",type:"Event",data:{type:"[[RendererRuntimeReady]]",data:{label:this.label,handshake:!this._gotAvailableModulesFromWeex}}},i,i)},e.prototype.$getCurrentActivePageId=function(){return this.label},e}(e),C=["$on","$once","$off","$emit","$cycle","$decycle","$call","$callAsync","$navTo","$getAvailableModules","$getCurrentActivePageId"];return function(e,t){var n=!(!e||!e.requireModule);!function(e){if(!e.platform)return console.error("set logger environment failed.");Object.assign(l,e)}({platform:n&&e.config.env.platform,debugMode:n&&e.config.env.debugMode,isWeex:n}),u("Setup Windmill renderer framework."),e&&!e.requireModule&&(t=e,e=void 0),t||(t={}),u("Instantiate renderer in "+(((t=Object.assign({},t)).isWeex=n)?"Weex container":"WindVane container")+".");var i,o,a,s,r=new T(e,t),c=(i=r,o={},C.forEach(function(r){"function"==typeof i[r]&&(o[r]=function(){for(var e=arguments,t=[],n=arguments.length;n--;)t[n]=e[n];return i[r].apply(i,t)})}),o);return u("Prepare runtime APIs: "+JSON.stringify(C)),t.exposeModuleGetter&&function(e,t,n){void 0===n&&(n=!0);var r=void 0!==N?N:"undefined"!=typeof self?self:new Function("return this")();try{Object.defineProperty(r,e,{value:t,configurable:!0,enumerable:!0,writable:!n})}catch(n){r[e]=t}}("__WINDMILL_MODULE_GETTER__",(a=function(){return c},s=function(){for(var e,t=arguments,n=[],r=arguments.length;r--;)n[r]=t[r];return(e=a()).$call.apply(e,n)},function(i){if(!i)return u("Require a universal module proxy."),{call:s};var e=g[i];if(Array.isArray(e)){u('Require the "'+i+'" module.');var t={};return e.forEach(function(r){t[r]=function(){for(var e=arguments,t=[],n=arguments.length;n--;)t[n]=e[n];return s.apply(void 0,[i+"."+r].concat(t))}}),t}d('Require unknown module "'+i+"\".It may not exist or haven't been registered.")})),r.ready(),c}}()}(e={exports:{}},e.exports),e.exports),n="__WINDMILL_WORKER_RUNTIME_APIS__",r="__WEBVIEW_MESSAGE_EVENT_NAME__",i="[[JSON]]",o=/^\[\[JSON\]\].*/;function l(){return"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:new Function("return this")()}var u="__WINDMILL_MODULE_GETTER__";var a="[[EVENT_MAP]]";function s(e,t){var n=e[a];return Array.isArray(n[t])||(n[t]=[]),n[t]}var c,d=function(){Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:{}})};function f(e){return"Object"===(t=e,Object.prototype.toString.call(t).slice(8,-1));var t}function p(){return"object"==typeof __windmill_environment__?__windmill_environment__:"object"==typeof wmlEnv?wmlEnv:"object"==typeof windmillEnv?windmillEnv:{}}function g(){if(!c){var e=l();c=e[n]}return c}function v(){return g().$getCurrentActivePageId()}d.prototype.on=function(e,t){return s(this,e).push({listener:t,once:!1,callCount:0}),this},d.prototype.once=function(e,t){return s(this,e).push({listener:t,once:!0,callCount:0}),this},d.prototype.off=function(e,t){var n=this[a];if(t){var r=n[e];if(Array.isArray(r)){var i=r.findIndex(function(e){return e.listener===t});-1!==i&&r.splice(i,1)}}else delete n[e];return this},d.prototype.emit=function(e){for(var t=[],n=arguments.length-1;0<n--;)t[n]=arguments[n+1];var r=this[a],i=r[e];return Array.isArray(i)&&(r[e]=i.filter(function(e){try{e.listener.apply(null,t),e.callCount+=1}catch(e){return!0}return!e.once})),this};var h={};function m(e,t){var n=h[e];return"function"==typeof n&&f(t)?n(t):t}new d;function y(t,n,e){void 0===e&&(e=!0);var r=l();try{Object.defineProperty(r,t,{value:n,configurable:!0,enumerable:!0,writable:!e})}catch(e){r[t]=n}}var b=["success","fail","complete"];function w(n,e){var r=g();if(r){if(e&&"function"==typeof r.$callSync)return function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return r.$callSync.apply(r,[n].concat(e))};if(!e&&"function"==typeof r.$call)return function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return r.$call.apply(r,[n].concat(e))}}var t,i,o=n.split(/\s*\.\s*/i),a=o[0],s=o[1];if(a&&s){var c=(t=a,(i=l())&&"function"==typeof i[u]?i[u](t):i&&"function"==typeof i.require?i.require("@core/"+t):(console.error('Can\'t find available "require" function.'),i&&i&&"function"==typeof i.requireModule?i.requireModule(t):i&&i.weex&&"function"==typeof i.weex.requireModule?i.weex.requireModule("@windmill/"+t):void 0));if(c&&"function"==typeof c[s])return c[s]}return function(){}}function _(e,t){if("function"==typeof e)try{return e.apply(null,t)}catch(e){console.error("Failed to execute internal method: "+e.toString())}}var S=function(e,t){console.error('Failed to execute callback of "'+e+'": '+t.toString())};function M(t,e,n){if("function"==typeof e)try{return e.apply(null,n)}catch(e){S(t,e)}}var A={};function k(n,r,e,i,o){void 0===r&&(r={}),void 0===e&&(e=r),void 0===i&&(i=function(e){return e}),void 0===o&&(o=function(e){return e});var t=w(n),a=!1;return t(function(e){var t={};for(var n in e)-1===b.indexOf(n)&&(t[n]=e[n]);return t}(e),function(e){var t=_(i,[e]);M(n,r.success,[t]),a||(M(n,r.complete,[t]),a=!0)},function(e){var t=_(o,[e]);M(n,r.fail,[t]),a||(M(n,r.complete,[t]),a=!0)},A)}function E(e){return"/"===e.charAt(0)}function I(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}function O(e){return void 0===e&&(e=""),"/"===e[0]?e.slice(1):e}function T(e){return{data:o.test(e.value)?JSON.parse(e.value.substr(i.length)):e.value}}function C(){var e=p();return{model:e.model,pixelRatio:e.pixelRatio,windowWidth:e.screenWidth,windowHeight:e.screenHeight,language:e.language,version:e.appVersion,storage:null,currentBattery:null,system:e.systemVersion,platform:e.platform,screenWidth:e.screenWidth,screenHeight:e.screenHeight,brand:e.brand,fontSizeSetting:14,app:e.appName,SDKVersion:e.version,frameworkType:e.frameworkType,frameworkVersion:e.frameworkVersion,userAgent:e.userAgent,screenDensity:e.screenDensity}}var W=p().version||"";var P,$=Object.freeze({postMessage:function(e){var t=g();if(t){var n=v();t.$emit(r+"@"+n,e,"AppWorker")}},onMessage:function(t){var e=g();if(e){var n=v();e.$on(r+"@"+n,function(e){t(e)})}},showActionSheet:function(e){k("actionSheet.showActionSheet",e)},tradePay:function(e){void 0===e&&(e={}),k("alipay.tradePay",e=m("tradePay",e))},getNetworkType:function(e){k("connection.getType",e=m("getNetworkType",e),{},function(e){return{networkType:(e.type||"").toUpperCase()}})},chooseImage:function(e){k("image.chooseImage",e)},previewImage:function(e){k("image.previewImage",e)},getLocation:function(e){var r=e.type;k("location.getLocation",e,e,function(e){var t={longitude:e.coords.longitude,latitude:e.coords.latitude,accuracy:e.coords.accuracy};if(0<r&&e.address){t.country=e.address.country,t.province=e.address.province,t.city=e.address.city,t.cityAdcode=e.address.cityCode,t.district=e.address.area,t.districtAdcode=e.address.areaCode;var n=p();n&&"iOS"===n.platform&&"8.8.0"===n.appVersion&&(t.cityAdcode=e.address.areaCode)}return t})},alert:function(e){void 0===e&&(e={}),k("modal.alert",e,{title:e.title,message:e.content,okTitle:e.buttonText})},showLoading:function(e){k("modal.showLoading",e)},hideLoading:function(e){k("modal.hideLoading",e)},navigateTo:function(e,t){void 0===e&&(e={}),void 0===t&&(t=""),k("navigator.push",e=m("navigateTo",e),{url:O(function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=e&&e.split("/")||[],r=t&&t.split("/")||[],i=e&&E(e),o=t&&E(t),a=i||o;if(e&&E(e)?r=n:n.length&&(r.pop(),r=r.concat(n)),!r.length)return"/";var s=void 0;if(r.length){var c=r[r.length-1];s="."===c||".."===c||""===c}else s=!1;for(var l=0,u=r.length;0<=u;u--){var d=r[u];"."===d?I(r,u):".."===d?(I(r,u),l++):l&&(I(r,u),l--)}if(!a)for(;l--;l)r.unshift("..");!a||""===r[0]||r[0]&&E(r[0])||r.unshift("");var f=r.join("/");return s&&"/"!==f.substr(-1)&&(f+="/"),f}(e.url,t)||"")})},navigateBack:function(e){k("navigator.pop",m("navigateBack",e))},switchTab:function(e){void 0===e&&(e={}),k("navigator.switchTab",e=m("switchTab",e),{url:O(e.url)})},redirectTo:function(e){void 0===e&&(e={}),k("navigator.redirectTo",e=m("redirectTo",e),{url:O(e.url)})},httpRequest:function(r){void 0===r&&(r={});var e=(r=m("httpRequest",r)).method||"GET";if("GET"===e&&f(r.data)){var i=[];Object.keys(r.data).forEach(function(e){var t=r.data[e],n="object"==typeof t?JSON.stringify(t):t;i.push(e+"="+encodeURIComponent(n))});var t=i.join("&");0<=r.url.indexOf("?")?r.url+=t:r.url+="?"+t}k("network.request",r,{method:e,url:r.url,headers:r.headers||{"Content-Type":"application/x-www-form-urlencoded"},dataType:r.dataType||"json",body:r.data},function(e){return{data:e.data,status:e.status,headers:e.headers}})},setStorage:function(e){var t;void 0===e&&(e={}),k("storage.setItem",e,{key:e.key,value:(t=e,i+JSON.stringify(t.data))})},getStorage:function(e){void 0===e&&(e={}),k("storage.getItem",e,e,T)},removeStorage:function(e){void 0===e&&(e={}),k("storage.removeItem",e)},clearStorage:function(e){k("storage.clearStorage",e)},getStorageInfo:function(e){k("storage.getStorageInfo",e)},getSystemInfoSync:C,getSystemInfo:function(t){void 0===t&&(t={});try{"function"==typeof t.success&&t.success.call(this,C())}catch(e){"function"==typeof t.fail&&t.fail.call(this,e)}finally{"function"==typeof t.complete&&t.complete.call(this)}},SDKVersion:W,sendMtop:function(e){k("sendMtop.request",m("sendMtop",e))}}),x=t({},{isWeex:!1,exposeModuleGetter:!0});function R(e){var t=Object.assign({},$,{canIUse:function(e){return e in $}});return e&&e.preprocessor&&function(e,t){if(f(e)&&f(t))for(var n in t)r=e,i=n,Object.prototype.hasOwnProperty.call(r,i)&&"function"==typeof t[n]&&(h[n]=t[n]);var r,i}(t,e.preprocessor),x.$on(r,function(e){void 0===e&&(e={}),"function"==typeof t.onMessage&&t.onMessage(e.data)}),{my:t}}(P=x)&&(c=P);var j=R();for(var V in j)y(V,j[V]);return R}();