UNPKG

wgappsdk

Version:

WarGaming App SDK for WebView communication

2 lines (1 loc) 4.94 kB
var e,n,t,r,i,o,a=function(){return a=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},a.apply(this,arguments)};function u(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function u(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,u)}l((r=r.apply(e,n||[])).next())}))}function l(e,n){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(l){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(a=0)),a;)try{if(t=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){a.label=u[1];break}if(6===u[0]&&a.label<i[1]){a.label=i[1],i=u;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(u);break}i[2]&&a.ops.pop(),a.trys.pop();continue}u=n.call(e,a)}catch(e){u=[6,e],r=0}finally{t=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}function c(e){return new Promise((function(n,t){!function(e){var n=window;if(n.WKWebViewJavascriptBridge)return e(n.WKWebViewJavascriptBridge);if(n.WKWVJBCallbacks)return n.WKWVJBCallbacks.push(e);n.WKWVJBCallbacks=[e],n.webkit&&n.webkit.messageHandlers&&n.webkit.messageHandlers.iOS_Native_InjectJavascript&&n.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage(null)}((function(t){t.callHandler("callClientFunction",e,(function(e){n(e)}))}))}))}function s(e,t){return u(this,void 0,void 0,(function(){var i,o,u,s,E,f,O,p;return l(this,(function(l){var T,I,S,N;return I=navigator.userAgent,S=I.indexOf("Android")>-1||I.indexOf("Adr")>-1,N=!!I.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),i=S?"Android":N?"IOS":(T=I).includes("OpenHarmony")||T.includes("HarmonyOS")?"HarmonyOS":"PC",o={biz:e,data:a({method:r.GET},t)},e===n.ENCODECALLURLSYNC&&(u=t.url,s=t.appMethod,E=function(e){var n=new URL(e);return{baseUrl:n.origin+n.pathname,urlParam:n.search.substr(1)}}(u),f=E.baseUrl,O=E.urlParam,p=null,s==r.POST&&(p=function(e){var n={};if(e)for(var t=e.split("&"),r=0;r<t.length;r++){var i=t[r].split("=");n[i[0]]=decodeURIComponent(i[1])}return n}(O)),o.data={baseUrl:f,urlParam:O,postParam:p}),"Android"===i||"HarmonyOS"===i?[2,new Promise((function(e,n){e(window.wargame.callClientFunction(JSON.stringify(o)))}))]:"IOS"===i?[2,c(o)]:[2,Promise.resolve("callNative function Error!")]}))}))}function E(e){return u(this,void 0,void 0,(function(){return l(this,(function(n){return window.callWebViewFunction=function(n){n.biz,e(n)},[2]}))}))}!function(e){e.NONE="NONE",e.WIFI="WIFI",e["2G"]="2G",e["3G"]="3G",e["4G"]="4G",e["5G"]="5G"}(e||(e={})),function(e){e.SHOWTITLE="showTitle",e.ENCODECALLURLSYNC="encodeCallUrlSync",e.OPENH5URL="openH5Url",e.OPENNEWH5URL="openNewH5Url",e.SHOWH5LOG="showH5Log",e.GETNETSTATUS="getNetStatus",e.SHOWNETERRORUI="showNetErrorUi",e.SHOWSUBTITLE="showSubTitle",e.JUMPTOUI="jumpToUi",e.JUMPTOSHARE="jumpToShare",e.JUMPTORANKFILTER="jumpToRankFilter",e.SHAREBTNISSHOW="shareBtnIsShow",e.GETCURUSERPLAT="getCurUserPlat",e.JUMPTOLOGIN="jumpToLogin",e.GETCURVERSION="getCurVersion",e.TITLEBARSTYLEMOTIFY="titleBarStyleMotify",e.JUMPIMAGEBROWSEPAGE="JumpImageBrowsePage",e.SAVEIMAGETOGALLERY="SaveImageToGallery",e.FINISHWEB="finishWeb",e.OPENINPUTVIEW="openInputView",e.OPENINPUTVIEWFORUM="openInputViewForum",e.OPENEDITORFORUM="openEditorForum",e.PUSHFORUMVOTE="pushForumVote",e.PUSHFORUMRECORD="pushForumRecord",e.GETCOMMUNITYTOKEN="getCommmunityToken",e.EDITAVATARFORUM="editAvatarForum",e.VIBRATE="vibrate",e.GETDEVICECONFIGURE="getDeviceConfigure",e.OPENSELECT="openSelect",e.OPENMODAL="openModal",e.VIDEOPLAYER="jumpToVideoPlayer",e.PUSHMESSAGE="pushMessage",e.GETAPPUSERINFO="getAppUserInfo",e.FULLDIALOG="fullDialog",e.SETREQUESTEDORIENTATION="setRequestedOrientation"}(n||(n={})),function(e){e.LIGHT="light",e.MEDIUM="medium",e.HEAVY="heavy"}(t||(t={})),function(e){e.GET="get",e.POST="post"}(r||(r={})),function(e){e.WEBLINK="weblink",e.CMSDETAIL="cmsdetail",e.INSIDELINK="insidelink",e.WEEKLYLINK="weeklylink",e.RANKFILTERLINK="rankfilterlink",e.OPENCLIENT="openclient"}(i||(i={})),function(e){e.URL="url",e.SCREENSHOT="base64bitmap",e.NETIMG="netimg"}(o||(o={}));export{r as AppNetMethod,n as JumpMethod,i as JumpType,e as NetStatus,o as ShareType,t as VibrateLevel,s as callNative,E as onAppMessage};