zalo-js-bridge
Advanced tools
Comparing version 1.10.10 to 1.10.11
# Base Library Update Logs | ||
## 1.10.11 (2021-02-01) | ||
### Bug Fixes | ||
* export for npm e3c3669 | ||
## 1.10.10 (2021-02-01) | ||
@@ -4,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionHaveCallBack=t.Action=void 0,t.Action={getdownloadedsticker:"action.get.downloaded.sticker",opensharesticker:"action.open.share.sticker",openprofile:"action.open.profile",openfeeddetail:"action.open.feeddetail",openfriendrada:"action.open.friendrada",openinapp:"action.open.inapp",openoutapp:"action.open.outapp",openpage:"action.open.page",openphotodetail:"action.open.photodetail",opengalary:"action.open.galary",opengamecenter:"action.open.gamecenter",opengamenews:"action.open.gamenews",opentabcontact:"action.open.tab.contact",opentabsocial:"action.open.tab.social",openfriendsuggest:"action.open.friendsuggest",opengrouplist:"action.open.grouplist",opennearby:"action.open.nearby",openroom:"action.open.room",openstickerstore:"action.open.stickerstore",opencreatechat:"action.open.createchat",copylinkcatesticker:"action.copy.link.catesticker",requestbuysticker:"action.request.buy.sticker",openchat:"action.open.chat",opentabchat:"action.open.tab.chat",openChatGroup:"action.open.chatgroup",openaddfriend:"action.open.addfriend",opentabmore:"action.open.tab.more",openpostfeed:"action.open.postfeed",openlogindevices:"action.open.logindevices",opensendsticker:"action.open.sendsticker",reportabuse:"action.report.abuse",followoa:"action.follow.oa",unfollowoa:"action.unfollow.oa",opengamedetail:"action.open.gamedetail",opensharesheet:"action.open.sharesheet",requestcamera:"action.request.permission.camera",changetitleheader:"action.change.title.header",clearcachewebview:"action.webview.clearcache",confirmcache:"action.webview.confirmcache",isvisible:"action.webview.isvisible",networktype:"action.webview.networktype",changebuttonheader:"action.change.button.header",createoptionmenu:"action.create.options.menu",createshortcut:"action.create.shortcut",changeleftbuttonbar:"action.change.actionbar.leftbutton.type",closewindow:"action.window.close",checkResError:"action.webview.checkResError",requestPayment:"action.iap.requestpayment",getzbrowserstats:"action.zbrowser.getstats",jsbridge:"action.zbrowser.jsbridge",bioauthen:"action.prompt.authentication",changeColorHeader:"action.change.actionbar.color",checkStateAuthen:"action.prompt.authentication.check_state",openappstore:"action.open.appstore",getlocation:"action.get.location",querylocationhide:"action.query.location.hide",showtoast:"action.show.toast",openapp:"action.open.app",hidekeyboard:"action.hide.keyboard",openphone:"action.open.phone",openqr:"action.open.qr",opensms:"action.open.sms",viewqr:"action.view.myqr",keepscreen:"action.keep.screen",autorotate:"action.change.autorotate",checkappinstalled:"action.check.app.installed",queryshow:"action.query.show",queryhide:"action.query.hide",openinapprw:"action.open.inapprw",gettrackingstatus:"action.zalorun.getTrackingStatus",settrackingstatus:"action.zalorun.setTrackingStatus",getdaystep:"action.zalorun.getDayStep",forcesubmitdata:"action.zalorun.forceSubmitData",setweight:"action.zalorun.setWeight",getAdIdClient:"action.get.adidclient",openProfileExt:"action.open.profile.ext",downloadcate:"action.download.cate",login:"action.jump.login",openInterstitialAds:"action.open.adtima.ads.interstitial",openRewardAds:"action.open.adtima.ads",openAdtimaAds:"action.open.adtima.ads",getAdsID:"action.get.adidclient"},t.ActionHaveCallBack=[t.Action.getdownloadedsticker,t.Action.openpostfeed,t.Action.reportabuse,t.Action.followoa,t.Action.unfollowoa,t.Action.opensharesheet,t.Action.createoptionmenu,t.Action.changeleftbuttonbar,t.Action.closewindow,t.Action.jsbridge,t.Action.getlocation,t.Action.querylocationhide,t.Action.showtoast,t.Action.viewqr,t.Action.keepscreen,t.Action.gettrackingstatus,t.Action.settrackingstatus,t.Action.getdaystep,t.Action.forcesubmitdata,t.Action.setweight,t.Action.downloadcate],t.default={}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(0),a=n(2),r=n(7),i=n(3);const s=new class{constructor(e){this._debug=r.default("jssdk:native-bridge"),this._accessTk=a.getToken("zacc_session")||"DEFAULT_ACCESS_TOKEN",this._jsAccessTk=a.getToken("zlink3rd")||"DEFAULT_JS_TOKEN",this._userAgent=a.getUserAgent(),this._device=a.checkPlatform(),this._appId=e||a.getToken("zapp"),this._jsCallFuncCallbacks={},this._listenerEvent={}}setAccessToken(e){this._accessTk=e}getAccessToken(){return this._accessTk}setJSToken(e){this._jsAccessTk=e}getJSToken(){return this._jsAccessTk}getAppId(){return this._appId}onJSCall(e){try{this._debug("onJSCall","data from native callback",e);const t=a.parseJSON(e);this._debug("onJSCall","data is parsed",t);const n=this._jsCallFuncCallbacks[t.action];n&&(n.call(this,t),this._jsCallFuncCallbacks[t.action]=null,delete this._jsCallFuncCallbacks[t.action])}catch(e){this._debug("onJSCall","error",e)}try{const t=a.parseJSON(e);i.default.execute("https://api.h5.zalo.me/log","post",{appId:this._appId,action:t.action,error:t.error_code},e=>{})}catch(e){}}onMultiJSCall(e){try{this._debug("onMultiJSCall","data from native callback",e);const t=a.parseJSON(e);this._debug("onMultiJSCall","data is parsed",t);const n=this._jsCallFuncCallbacks[t.action];n&&n.call(this,t)}catch(e){console.log(e)}try{const t=a.parseJSON(e);i.default.execute("https://api.h5.zalo.me/log","post",{appId:this._appId,action:t.action,error:t.error_code},e=>{})}catch(e){}}jsCallback(e,t,n){ZaloJavaScriptInterface.jsH5EventCallback(e,t,n)}registerListenerEvent(e,t,n){console.log("register "+e+" : "+t),this._listenerEvent[e]={handler:n,data:t}}nativeEventHandler(e,t,n){if(console.log("eventId:",e,"eventName",t,"eventData",n),this._listenerEvent[t]){const{handler:n,data:o}=this._listenerEvent[t];this.jsCallback(e,t,o);try{n()}catch(e){this._debug("nativeEventHandler","H5 handle event fail",t,e)}}}defaultCallback(e){null!=e&&(e=a.parseJSON(e),this._debug("defaultCallback","Callback data",e))}jsCall(e,t,n,r=!1,i=3){try{if(!this._device.isMobile||a.isEmpty(e))return this.onJSCall({error_code:-13,error_message:"params invalid!",data:{device:this._device.isMobile,jsToken:this._jsAccessTk,access_token:this._accessTk},action:e}),!1;null==t&&(t={}),a.isFunction(t)&&void 0===n&&(n=t,t={}),n||(n=this.defaultCallback);const s={error_code:-14,error_message:"Request Timeout!",data:{},action:e};this._jsCallFuncCallbacks[e]=n,o.ActionHaveCallBack.includes(e)&&setTimeout(()=>{this.onJSCall(s)},8e3);try{return t=a.serialize(t),r?this._device.isIOS?ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,window.ZJSBridge.onMultiJSCall):ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,"ZJSBridge.onMultiJSCall"):this._device.isIOS?ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,window.ZJSBridge.onJSCall):ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,"ZJSBridge.onJSCall")}catch(o){if(!(i-- >0)){const n={error_code:-5,error_message:"Not ready!",data:{userAgent:this._userAgent,options:t,jsToken:this._jsAccessTk,access_token:this._accessTk},action:e,js_error:o};return this.onJSCall(n),!1}setTimeout(()=>{this.jsCall(e,t,n,r,i)},500)}}catch(e){this._debug("jsCall","error",e)}return!1}}(window.zAppID);t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZaloVersion=t.checkPlatform=t.getUserAgent=t.getToken=t.isFunction=t.serialize=t.isZaloBrowser=t.parseJSON=t.isString=t.isEmpty=t.isObject=t.writeCookie=void 0;const o=n(6),a=e=>{const t=document.cookie;if(t){const a=t.split("; ");if(a&&a.length>0)for(var n=e.length+1,o=a.length-1;o>=0;o--){let t=a[o];if(t&&0===t.indexOf(e)&&(t=t.substring(n,t.length),t))return t=t.replace(/["']/g,""),t}}return null};t.writeCookie=(e,t,n,a,r,i)=>{try{const s=new Date;s.setSeconds(s.getSeconds()+r),o.set(e,t,{path:n,domain:a,expires:s,secure:i})}catch(e){console.error("Fail to set cookie")}};const r=e=>a((()=>{const e=window.location.host;return e?0===e.indexOf("www.")?e.replace("www.","")+"_":e+"_":""})()+e),i=e=>a((()=>{const e=window.location.host;if(e){if(e.indexOf("zalo.me")>=0)return"zalo.me_";if(e.indexOf("baomoi.com")>=0)return"baomoi.com_";if(e.indexOf("mp3.zing.vn")>=0)return"mp3.zing.vn_";if(e.indexOf("zaloapp.com")>=0)return"zaloapp.com_"}return""})()+e);t.isObject=e=>"object"==typeof e,t.isEmpty=e=>!e||0===e.trim().length,t.isString=e=>"string"==typeof e||null!=e&&("object"==typeof e&&(!!e.constructor&&null!==e.constructor.toString().match(/string/i))),t.parseJSON=e=>t.isObject(JSON)&&JSON.parse&&t.isString(e)?JSON.parse(e):"object"==typeof e?e:new Function("return "+e)(),t.isZaloBrowser=()=>window.navigator.userAgent.includes("Zalo"),t.serialize=e=>{if(t.isObject(JSON)&&JSON.stringify)return JSON.stringify(e);if(void 0===e)return"undefined";if(null===e)return"null";try{if("string"==typeof e||null!==e.constructor.toString().match(/string/i))return'"'+e.replace(/"/g,'\\"')+'"'}catch(e){console.log(e)}var n;if(null!==Object.prototype.toString.call(e).match(/array/i)){n=new Array;for(var o=e.length,a=0;a<o;a++)n.push(t.serialize(e[a]));return"["+n.join(",")+"]"}if("object"==typeof e){for(var r in n=new Array,e)n.push('"'+r+'":'+t.serialize(e[r]));return"{"+n.join(",")+"}"}return e.toString()},t.isFunction=e=>"function"==typeof e,t.getToken=e=>(e=>{let t=r(e);return t||(t=i(e),t)?t:a(e)})(e),t.getUserAgent=()=>navigator.userAgent||navigator.vendor||window.opera,t.checkPlatform=()=>{const e=t.getUserAgent().toLowerCase();return{isWP:/iemobile/.test(e),isAndroid:/android/i.test(e)&&!/iemobile/.test(e),isIOS:/iphone|ipad|ipod/.test(e)&&!/iemobile/.test(e),isMobile:/android|iphone|ipad|ipod|iemobile/.test(e)}},t.getZaloVersion=()=>a("zversion")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(11),a=n(12);var r={error:{code:1,error_subcode:1357046,message:"Received Invalid JSON reply.",type:"http"}};function i(e){try{return null===e?r:JSON.parse(e)}catch(e){return r}}var s={execute:function(e,t,n,r){n.suppress_http_code=1;var s=o.default.encode(n);"post"!=t&&(e=o.default.appendToUrl(e,s),s="");var c=function(e,t){if(!self.XMLHttpRequest)return null;var n=new XMLHttpRequest,o=function(){};if(!("withCredentials"in n))return null;n.open(e,t,!0),n.setRequestHeader("Content-type","application/x-www-form-urlencoded");var r={send:function(e){n.send(e)}},i=a.default((function(){i=o,"onload"in r&&r.onload(n)}),"entry","XMLHttpRequest:load"),s=a.default((function(){s=o,"onerror"in r&&r.onerror(n)}),"entry","XMLHttpRequest:error");return n.onload=function(){i()},n.onerror=function(){s()},n.onreadystatechange=function(){4==n.readyState&&(200==n.status?i():s())},r}(t,e);return!!c&&(c.onload=function(e){r(i(e.responseText))},c.onerror=function(e){e.responseText?r(i(e.responseText)):r({error:{code:1,error_subcode:1357045,message:"unknown error (empty response)",status:e.status,type:"http"}})},c.send(s),!0)}};t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;const o=n(5).createZJSBridge();t.default=o,"undefined"==typeof window||window.zaloJSV2||(window.zaloJSV2={zalo_h5_event_handler:function(e,t,n){o.nativeEventHandler(e,t,n)}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createZJSBridge=void 0;const o=n(0),a=n(1),r=n(13),i=n(14),s=n(15),c=n(16),l=n(17),u=n(18);t.createZJSBridge=function(){const e=(e,t,n)=>{a.default.registerListenerEvent(e,t,n)};return{Zalo:r.default,Device:i.default,H5:s.default,Misc:c.default,Ads:l.default,getVersion:()=>"1.10.10",onJSCall:e=>{a.default.onJSCall(e)},onMultiJSCall:e=>{a.default.onMultiJSCall(e)},login:e=>{a.default.jsCall(o.Action.login,{},t=>{try{u.default.getAccessToken(e)}catch(t){return console.log(t),e(null)}},!0)},callCustomAction:(e,t,n,o=!0,r=3)=>{a.default.jsCall(e,t,n,o,r)},registerListenerEvent:e,onCloseWebview:t=>{e("h5.event.action.close",'{"handle_h5": 1}',t)},nativeEventHandler:(e,t,n)=>{a.default.nativeEventHandler(e,t,n)}}}},function(e,t,n){var o,a; | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionHaveCallBack=t.Action=void 0,t.Action={getdownloadedsticker:"action.get.downloaded.sticker",opensharesticker:"action.open.share.sticker",openprofile:"action.open.profile",openfeeddetail:"action.open.feeddetail",openfriendrada:"action.open.friendrada",openinapp:"action.open.inapp",openoutapp:"action.open.outapp",openpage:"action.open.page",openphotodetail:"action.open.photodetail",opengalary:"action.open.galary",opengamecenter:"action.open.gamecenter",opengamenews:"action.open.gamenews",opentabcontact:"action.open.tab.contact",opentabsocial:"action.open.tab.social",openfriendsuggest:"action.open.friendsuggest",opengrouplist:"action.open.grouplist",opennearby:"action.open.nearby",openroom:"action.open.room",openstickerstore:"action.open.stickerstore",opencreatechat:"action.open.createchat",copylinkcatesticker:"action.copy.link.catesticker",requestbuysticker:"action.request.buy.sticker",openchat:"action.open.chat",opentabchat:"action.open.tab.chat",openChatGroup:"action.open.chatgroup",openaddfriend:"action.open.addfriend",opentabmore:"action.open.tab.more",openpostfeed:"action.open.postfeed",openlogindevices:"action.open.logindevices",opensendsticker:"action.open.sendsticker",reportabuse:"action.report.abuse",followoa:"action.follow.oa",unfollowoa:"action.unfollow.oa",opengamedetail:"action.open.gamedetail",opensharesheet:"action.open.sharesheet",requestcamera:"action.request.permission.camera",changetitleheader:"action.change.title.header",clearcachewebview:"action.webview.clearcache",confirmcache:"action.webview.confirmcache",isvisible:"action.webview.isvisible",networktype:"action.webview.networktype",changebuttonheader:"action.change.button.header",createoptionmenu:"action.create.options.menu",createshortcut:"action.create.shortcut",changeleftbuttonbar:"action.change.actionbar.leftbutton.type",closewindow:"action.window.close",checkResError:"action.webview.checkResError",requestPayment:"action.iap.requestpayment",getzbrowserstats:"action.zbrowser.getstats",jsbridge:"action.zbrowser.jsbridge",bioauthen:"action.prompt.authentication",changeColorHeader:"action.change.actionbar.color",checkStateAuthen:"action.prompt.authentication.check_state",openappstore:"action.open.appstore",getlocation:"action.get.location",querylocationhide:"action.query.location.hide",showtoast:"action.show.toast",openapp:"action.open.app",hidekeyboard:"action.hide.keyboard",openphone:"action.open.phone",openqr:"action.open.qr",opensms:"action.open.sms",viewqr:"action.view.myqr",keepscreen:"action.keep.screen",autorotate:"action.change.autorotate",checkappinstalled:"action.check.app.installed",queryshow:"action.query.show",queryhide:"action.query.hide",openinapprw:"action.open.inapprw",gettrackingstatus:"action.zalorun.getTrackingStatus",settrackingstatus:"action.zalorun.setTrackingStatus",getdaystep:"action.zalorun.getDayStep",forcesubmitdata:"action.zalorun.forceSubmitData",setweight:"action.zalorun.setWeight",getAdIdClient:"action.get.adidclient",openProfileExt:"action.open.profile.ext",downloadcate:"action.download.cate",login:"action.jump.login",openInterstitialAds:"action.open.adtima.ads.interstitial",openRewardAds:"action.open.adtima.ads",openAdtimaAds:"action.open.adtima.ads",getAdsID:"action.get.adidclient"},t.ActionHaveCallBack=[t.Action.getdownloadedsticker,t.Action.openpostfeed,t.Action.reportabuse,t.Action.followoa,t.Action.unfollowoa,t.Action.opensharesheet,t.Action.createoptionmenu,t.Action.changeleftbuttonbar,t.Action.closewindow,t.Action.jsbridge,t.Action.getlocation,t.Action.querylocationhide,t.Action.showtoast,t.Action.viewqr,t.Action.keepscreen,t.Action.gettrackingstatus,t.Action.settrackingstatus,t.Action.getdaystep,t.Action.forcesubmitdata,t.Action.setweight,t.Action.downloadcate],t.default={}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(0),a=n(2),r=n(7),i=n(3);const s=new class{constructor(e){this._debug=r.default("jssdk:native-bridge"),this._accessTk=a.getToken("zacc_session")||"DEFAULT_ACCESS_TOKEN",this._jsAccessTk=a.getToken("zlink3rd")||"DEFAULT_JS_TOKEN",this._userAgent=a.getUserAgent(),this._device=a.checkPlatform(),this._appId=e||a.getToken("zapp"),this._jsCallFuncCallbacks={},this._listenerEvent={}}setAccessToken(e){this._accessTk=e}getAccessToken(){return this._accessTk}setJSToken(e){this._jsAccessTk=e}getJSToken(){return this._jsAccessTk}getAppId(){return this._appId}onJSCall(e){try{this._debug("onJSCall","data from native callback",e);const t=a.parseJSON(e);this._debug("onJSCall","data is parsed",t);const n=this._jsCallFuncCallbacks[t.action];n&&(n.call(this,t),this._jsCallFuncCallbacks[t.action]=null,delete this._jsCallFuncCallbacks[t.action])}catch(e){this._debug("onJSCall","error",e)}try{const t=a.parseJSON(e);i.default.execute("https://api.h5.zalo.me/log","post",{appId:this._appId,action:t.action,error:t.error_code},e=>{})}catch(e){}}onMultiJSCall(e){try{this._debug("onMultiJSCall","data from native callback",e);const t=a.parseJSON(e);this._debug("onMultiJSCall","data is parsed",t);const n=this._jsCallFuncCallbacks[t.action];n&&n.call(this,t)}catch(e){console.log(e)}try{const t=a.parseJSON(e);i.default.execute("https://api.h5.zalo.me/log","post",{appId:this._appId,action:t.action,error:t.error_code},e=>{})}catch(e){}}jsCallback(e,t,n){ZaloJavaScriptInterface.jsH5EventCallback(e,t,n)}registerListenerEvent(e,t,n){console.log("register "+e+" : "+t),this._listenerEvent[e]={handler:n,data:t}}nativeEventHandler(e,t,n){if(console.log("eventId:",e,"eventName",t,"eventData",n),this._listenerEvent[t]){const{handler:n,data:o}=this._listenerEvent[t];this.jsCallback(e,t,o);try{n()}catch(e){this._debug("nativeEventHandler","H5 handle event fail",t,e)}}}defaultCallback(e){null!=e&&(e=a.parseJSON(e),this._debug("defaultCallback","Callback data",e))}jsCall(e,t,n,r=!1,i=3){try{if(!this._device.isMobile||a.isEmpty(e))return this.onJSCall({error_code:-13,error_message:"params invalid!",data:{device:this._device.isMobile,jsToken:this._jsAccessTk,access_token:this._accessTk},action:e}),!1;null==t&&(t={}),a.isFunction(t)&&void 0===n&&(n=t,t={}),n||(n=this.defaultCallback);const s={error_code:-14,error_message:"Request Timeout!",data:{},action:e};this._jsCallFuncCallbacks[e]=n,o.ActionHaveCallBack.includes(e)&&setTimeout(()=>{this.onJSCall(s)},8e3);try{return t=a.serialize(t),r?this._device.isIOS?ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,window.ZJSBridge.onMultiJSCall):ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,"ZJSBridge.onMultiJSCall"):this._device.isIOS?ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,window.ZJSBridge.onJSCall):ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,"ZJSBridge.onJSCall")}catch(o){if(!(i-- >0)){const n={error_code:-5,error_message:"Not ready!",data:{userAgent:this._userAgent,options:t,jsToken:this._jsAccessTk,access_token:this._accessTk},action:e,js_error:o};return this.onJSCall(n),!1}setTimeout(()=>{this.jsCall(e,t,n,r,i)},500)}}catch(e){this._debug("jsCall","error",e)}return!1}}(window.zAppID);t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZaloVersion=t.checkPlatform=t.getUserAgent=t.getToken=t.isFunction=t.serialize=t.isZaloBrowser=t.parseJSON=t.isString=t.isEmpty=t.isObject=t.writeCookie=void 0;const o=n(6),a=e=>{const t=document.cookie;if(t){const a=t.split("; ");if(a&&a.length>0)for(var n=e.length+1,o=a.length-1;o>=0;o--){let t=a[o];if(t&&0===t.indexOf(e)&&(t=t.substring(n,t.length),t))return t=t.replace(/["']/g,""),t}}return null};t.writeCookie=(e,t,n,a,r,i)=>{try{const s=new Date;s.setSeconds(s.getSeconds()+r),o.set(e,t,{path:n,domain:a,expires:s,secure:i})}catch(e){console.error("Fail to set cookie")}};const r=e=>a((()=>{const e=window.location.host;return e?0===e.indexOf("www.")?e.replace("www.","")+"_":e+"_":""})()+e),i=e=>a((()=>{const e=window.location.host;if(e){if(e.indexOf("zalo.me")>=0)return"zalo.me_";if(e.indexOf("baomoi.com")>=0)return"baomoi.com_";if(e.indexOf("mp3.zing.vn")>=0)return"mp3.zing.vn_";if(e.indexOf("zaloapp.com")>=0)return"zaloapp.com_"}return""})()+e);t.isObject=e=>"object"==typeof e,t.isEmpty=e=>!e||0===e.trim().length,t.isString=e=>"string"==typeof e||null!=e&&("object"==typeof e&&(!!e.constructor&&null!==e.constructor.toString().match(/string/i))),t.parseJSON=e=>t.isObject(JSON)&&JSON.parse&&t.isString(e)?JSON.parse(e):"object"==typeof e?e:new Function("return "+e)(),t.isZaloBrowser=()=>window.navigator.userAgent.includes("Zalo"),t.serialize=e=>{if(t.isObject(JSON)&&JSON.stringify)return JSON.stringify(e);if(void 0===e)return"undefined";if(null===e)return"null";try{if("string"==typeof e||null!==e.constructor.toString().match(/string/i))return'"'+e.replace(/"/g,'\\"')+'"'}catch(e){console.log(e)}var n;if(null!==Object.prototype.toString.call(e).match(/array/i)){n=new Array;for(var o=e.length,a=0;a<o;a++)n.push(t.serialize(e[a]));return"["+n.join(",")+"]"}if("object"==typeof e){for(var r in n=new Array,e)n.push('"'+r+'":'+t.serialize(e[r]));return"{"+n.join(",")+"}"}return e.toString()},t.isFunction=e=>"function"==typeof e,t.getToken=e=>(e=>{let t=r(e);return t||(t=i(e),t)?t:a(e)})(e),t.getUserAgent=()=>navigator.userAgent||navigator.vendor||window.opera,t.checkPlatform=()=>{const e=t.getUserAgent().toLowerCase();return{isWP:/iemobile/.test(e),isAndroid:/android/i.test(e)&&!/iemobile/.test(e),isIOS:/iphone|ipad|ipod/.test(e)&&!/iemobile/.test(e),isMobile:/android|iphone|ipad|ipod|iemobile/.test(e)}},t.getZaloVersion=()=>a("zversion")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(11),a=n(12);var r={error:{code:1,error_subcode:1357046,message:"Received Invalid JSON reply.",type:"http"}};function i(e){try{return null===e?r:JSON.parse(e)}catch(e){return r}}var s={execute:function(e,t,n,r){n.suppress_http_code=1;var s=o.default.encode(n);"post"!=t&&(e=o.default.appendToUrl(e,s),s="");var c=function(e,t){if(!self.XMLHttpRequest)return null;var n=new XMLHttpRequest,o=function(){};if(!("withCredentials"in n))return null;n.open(e,t,!0),n.setRequestHeader("Content-type","application/x-www-form-urlencoded");var r={send:function(e){n.send(e)}},i=a.default((function(){i=o,"onload"in r&&r.onload(n)}),"entry","XMLHttpRequest:load"),s=a.default((function(){s=o,"onerror"in r&&r.onerror(n)}),"entry","XMLHttpRequest:error");return n.onload=function(){i()},n.onerror=function(){s()},n.onreadystatechange=function(){4==n.readyState&&(200==n.status?i():s())},r}(t,e);return!!c&&(c.onload=function(e){r(i(e.responseText))},c.onerror=function(e){e.responseText?r(i(e.responseText)):r({error:{code:1,error_subcode:1357045,message:"unknown error (empty response)",status:e.status,type:"http"}})},c.send(s),!0)}};t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;const o=n(5).createZJSBridge();t.default=o,"undefined"==typeof window||window.zaloJSV2||(window.zaloJSV2={zalo_h5_event_handler:function(e,t,n){o.nativeEventHandler(e,t,n)}},window.ZJSBridge=o)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createZJSBridge=void 0;const o=n(0),a=n(1),r=n(13),i=n(14),s=n(15),c=n(16),l=n(17),u=n(18);t.createZJSBridge=function(){const e=(e,t,n)=>{a.default.registerListenerEvent(e,t,n)};return{Zalo:r.default,Device:i.default,H5:s.default,Misc:c.default,Ads:l.default,getVersion:()=>"1.10.11",onJSCall:e=>{a.default.onJSCall(e)},onMultiJSCall:e=>{a.default.onMultiJSCall(e)},login:e=>{a.default.jsCall(o.Action.login,{},t=>{try{u.default.getAccessToken(e)}catch(t){return console.log(t),e(null)}},!0)},callCustomAction:(e,t,n,o=!0,r=3)=>{a.default.jsCall(e,t,n,o,r)},registerListenerEvent:e,onCloseWebview:t=>{e("h5.event.action.close",'{"handle_h5": 1}',t)},nativeEventHandler:(e,t,n)=>{a.default.nativeEventHandler(e,t,n)}}}},function(e,t,n){var o,a; | ||
/*! | ||
@@ -3,0 +3,0 @@ * JavaScript Cookie v2.2.1 |
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=19)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionHaveCallBack=t.Action=void 0,t.Action={getdownloadedsticker:"action.get.downloaded.sticker",opensharesticker:"action.open.share.sticker",openprofile:"action.open.profile",openfeeddetail:"action.open.feeddetail",openfriendrada:"action.open.friendrada",openinapp:"action.open.inapp",openoutapp:"action.open.outapp",openpage:"action.open.page",openphotodetail:"action.open.photodetail",opengalary:"action.open.galary",opengamecenter:"action.open.gamecenter",opengamenews:"action.open.gamenews",opentabcontact:"action.open.tab.contact",opentabsocial:"action.open.tab.social",openfriendsuggest:"action.open.friendsuggest",opengrouplist:"action.open.grouplist",opennearby:"action.open.nearby",openroom:"action.open.room",openstickerstore:"action.open.stickerstore",opencreatechat:"action.open.createchat",copylinkcatesticker:"action.copy.link.catesticker",requestbuysticker:"action.request.buy.sticker",openchat:"action.open.chat",opentabchat:"action.open.tab.chat",openChatGroup:"action.open.chatgroup",openaddfriend:"action.open.addfriend",opentabmore:"action.open.tab.more",openpostfeed:"action.open.postfeed",openlogindevices:"action.open.logindevices",opensendsticker:"action.open.sendsticker",reportabuse:"action.report.abuse",followoa:"action.follow.oa",unfollowoa:"action.unfollow.oa",opengamedetail:"action.open.gamedetail",opensharesheet:"action.open.sharesheet",requestcamera:"action.request.permission.camera",changetitleheader:"action.change.title.header",clearcachewebview:"action.webview.clearcache",confirmcache:"action.webview.confirmcache",isvisible:"action.webview.isvisible",networktype:"action.webview.networktype",changebuttonheader:"action.change.button.header",createoptionmenu:"action.create.options.menu",createshortcut:"action.create.shortcut",changeleftbuttonbar:"action.change.actionbar.leftbutton.type",closewindow:"action.window.close",checkResError:"action.webview.checkResError",requestPayment:"action.iap.requestpayment",getzbrowserstats:"action.zbrowser.getstats",jsbridge:"action.zbrowser.jsbridge",bioauthen:"action.prompt.authentication",changeColorHeader:"action.change.actionbar.color",checkStateAuthen:"action.prompt.authentication.check_state",openappstore:"action.open.appstore",getlocation:"action.get.location",querylocationhide:"action.query.location.hide",showtoast:"action.show.toast",openapp:"action.open.app",hidekeyboard:"action.hide.keyboard",openphone:"action.open.phone",openqr:"action.open.qr",opensms:"action.open.sms",viewqr:"action.view.myqr",keepscreen:"action.keep.screen",autorotate:"action.change.autorotate",checkappinstalled:"action.check.app.installed",queryshow:"action.query.show",queryhide:"action.query.hide",openinapprw:"action.open.inapprw",gettrackingstatus:"action.zalorun.getTrackingStatus",settrackingstatus:"action.zalorun.setTrackingStatus",getdaystep:"action.zalorun.getDayStep",forcesubmitdata:"action.zalorun.forceSubmitData",setweight:"action.zalorun.setWeight",getAdIdClient:"action.get.adidclient",openProfileExt:"action.open.profile.ext",downloadcate:"action.download.cate",login:"action.jump.login",openInterstitialAds:"action.open.adtima.ads.interstitial",openRewardAds:"action.open.adtima.ads",openAdtimaAds:"action.open.adtima.ads",getAdsID:"action.get.adidclient"},t.ActionHaveCallBack=[t.Action.getdownloadedsticker,t.Action.openpostfeed,t.Action.reportabuse,t.Action.followoa,t.Action.unfollowoa,t.Action.opensharesheet,t.Action.createoptionmenu,t.Action.changeleftbuttonbar,t.Action.closewindow,t.Action.jsbridge,t.Action.getlocation,t.Action.querylocationhide,t.Action.showtoast,t.Action.viewqr,t.Action.keepscreen,t.Action.gettrackingstatus,t.Action.settrackingstatus,t.Action.getdaystep,t.Action.forcesubmitdata,t.Action.setweight,t.Action.downloadcate],t.default={}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(0),a=n(2),r=n(7),i=n(3);const s=new class{constructor(e){this._debug=r.default("jssdk:native-bridge"),this._accessTk=a.getToken("zacc_session")||"DEFAULT_ACCESS_TOKEN",this._jsAccessTk=a.getToken("zlink3rd")||"DEFAULT_JS_TOKEN",this._userAgent=a.getUserAgent(),this._device=a.checkPlatform(),this._appId=e||a.getToken("zapp"),this._jsCallFuncCallbacks={},this._listenerEvent={}}setAccessToken(e){this._accessTk=e}getAccessToken(){return this._accessTk}setJSToken(e){this._jsAccessTk=e}getJSToken(){return this._jsAccessTk}getAppId(){return this._appId}onJSCall(e){try{this._debug("onJSCall","data from native callback",e);const t=a.parseJSON(e);this._debug("onJSCall","data is parsed",t);const n=this._jsCallFuncCallbacks[t.action];n&&(n.call(this,t),this._jsCallFuncCallbacks[t.action]=null,delete this._jsCallFuncCallbacks[t.action])}catch(e){this._debug("onJSCall","error",e)}try{const t=a.parseJSON(e);i.default.execute("https://api.h5.zalo.me/log","post",{appId:this._appId,action:t.action,error:t.error_code},e=>{})}catch(e){}}onMultiJSCall(e){try{this._debug("onMultiJSCall","data from native callback",e);const t=a.parseJSON(e);this._debug("onMultiJSCall","data is parsed",t);const n=this._jsCallFuncCallbacks[t.action];n&&n.call(this,t)}catch(e){console.log(e)}try{const t=a.parseJSON(e);i.default.execute("https://api.h5.zalo.me/log","post",{appId:this._appId,action:t.action,error:t.error_code},e=>{})}catch(e){}}jsCallback(e,t,n){ZaloJavaScriptInterface.jsH5EventCallback(e,t,n)}registerListenerEvent(e,t,n){console.log("register "+e+" : "+t),this._listenerEvent[e]={handler:n,data:t}}nativeEventHandler(e,t,n){if(console.log("eventId:",e,"eventName",t,"eventData",n),this._listenerEvent[t]){const{handler:n,data:o}=this._listenerEvent[t];this.jsCallback(e,t,o);try{n()}catch(e){this._debug("nativeEventHandler","H5 handle event fail",t,e)}}}defaultCallback(e){null!=e&&(e=a.parseJSON(e),this._debug("defaultCallback","Callback data",e))}jsCall(e,t,n,r=!1,i=3){try{if(!this._device.isMobile||a.isEmpty(e))return this.onJSCall({error_code:-13,error_message:"params invalid!",data:{device:this._device.isMobile,jsToken:this._jsAccessTk,access_token:this._accessTk},action:e}),!1;null==t&&(t={}),a.isFunction(t)&&void 0===n&&(n=t,t={}),n||(n=this.defaultCallback);const s={error_code:-14,error_message:"Request Timeout!",data:{},action:e};this._jsCallFuncCallbacks[e]=n,o.ActionHaveCallBack.includes(e)&&setTimeout(()=>{this.onJSCall(s)},8e3);try{return t=a.serialize(t),r?this._device.isIOS?ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,window.ZJSBridge.onMultiJSCall):ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,"ZJSBridge.onMultiJSCall"):this._device.isIOS?ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,window.ZJSBridge.onJSCall):ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,"ZJSBridge.onJSCall")}catch(o){if(!(i-- >0)){const n={error_code:-5,error_message:"Not ready!",data:{userAgent:this._userAgent,options:t,jsToken:this._jsAccessTk,access_token:this._accessTk},action:e,js_error:o};return this.onJSCall(n),!1}setTimeout(()=>{this.jsCall(e,t,n,r,i)},500)}}catch(e){this._debug("jsCall","error",e)}return!1}}(window.zAppID);t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZaloVersion=t.checkPlatform=t.getUserAgent=t.getToken=t.isFunction=t.serialize=t.isZaloBrowser=t.parseJSON=t.isString=t.isEmpty=t.isObject=t.writeCookie=void 0;const o=n(6),a=e=>{const t=document.cookie;if(t){const a=t.split("; ");if(a&&a.length>0)for(var n=e.length+1,o=a.length-1;o>=0;o--){let t=a[o];if(t&&0===t.indexOf(e)&&(t=t.substring(n,t.length),t))return t=t.replace(/["']/g,""),t}}return null};t.writeCookie=(e,t,n,a,r,i)=>{try{const s=new Date;s.setSeconds(s.getSeconds()+r),o.set(e,t,{path:n,domain:a,expires:s,secure:i})}catch(e){console.error("Fail to set cookie")}};const r=e=>a((()=>{const e=window.location.host;return e?0===e.indexOf("www.")?e.replace("www.","")+"_":e+"_":""})()+e),i=e=>a((()=>{const e=window.location.host;if(e){if(e.indexOf("zalo.me")>=0)return"zalo.me_";if(e.indexOf("baomoi.com")>=0)return"baomoi.com_";if(e.indexOf("mp3.zing.vn")>=0)return"mp3.zing.vn_";if(e.indexOf("zaloapp.com")>=0)return"zaloapp.com_"}return""})()+e);t.isObject=e=>"object"==typeof e,t.isEmpty=e=>!e||0===e.trim().length,t.isString=e=>"string"==typeof e||null!=e&&("object"==typeof e&&(!!e.constructor&&null!==e.constructor.toString().match(/string/i))),t.parseJSON=e=>t.isObject(JSON)&&JSON.parse&&t.isString(e)?JSON.parse(e):"object"==typeof e?e:new Function("return "+e)(),t.isZaloBrowser=()=>window.navigator.userAgent.includes("Zalo"),t.serialize=e=>{if(t.isObject(JSON)&&JSON.stringify)return JSON.stringify(e);if(void 0===e)return"undefined";if(null===e)return"null";try{if("string"==typeof e||null!==e.constructor.toString().match(/string/i))return'"'+e.replace(/"/g,'\\"')+'"'}catch(e){console.log(e)}var n;if(null!==Object.prototype.toString.call(e).match(/array/i)){n=new Array;for(var o=e.length,a=0;a<o;a++)n.push(t.serialize(e[a]));return"["+n.join(",")+"]"}if("object"==typeof e){for(var r in n=new Array,e)n.push('"'+r+'":'+t.serialize(e[r]));return"{"+n.join(",")+"}"}return e.toString()},t.isFunction=e=>"function"==typeof e,t.getToken=e=>(e=>{let t=r(e);return t||(t=i(e),t)?t:a(e)})(e),t.getUserAgent=()=>navigator.userAgent||navigator.vendor||window.opera,t.checkPlatform=()=>{const e=t.getUserAgent().toLowerCase();return{isWP:/iemobile/.test(e),isAndroid:/android/i.test(e)&&!/iemobile/.test(e),isIOS:/iphone|ipad|ipod/.test(e)&&!/iemobile/.test(e),isMobile:/android|iphone|ipad|ipod|iemobile/.test(e)}},t.getZaloVersion=()=>a("zversion")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(11),a=n(12);var r={error:{code:1,error_subcode:1357046,message:"Received Invalid JSON reply.",type:"http"}};function i(e){try{return null===e?r:JSON.parse(e)}catch(e){return r}}var s={execute:function(e,t,n,r){n.suppress_http_code=1;var s=o.default.encode(n);"post"!=t&&(e=o.default.appendToUrl(e,s),s="");var c=function(e,t){if(!self.XMLHttpRequest)return null;var n=new XMLHttpRequest,o=function(){};if(!("withCredentials"in n))return null;n.open(e,t,!0),n.setRequestHeader("Content-type","application/x-www-form-urlencoded");var r={send:function(e){n.send(e)}},i=a.default((function(){i=o,"onload"in r&&r.onload(n)}),"entry","XMLHttpRequest:load"),s=a.default((function(){s=o,"onerror"in r&&r.onerror(n)}),"entry","XMLHttpRequest:error");return n.onload=function(){i()},n.onerror=function(){s()},n.onreadystatechange=function(){4==n.readyState&&(200==n.status?i():s())},r}(t,e);return!!c&&(c.onload=function(e){r(i(e.responseText))},c.onerror=function(e){e.responseText?r(i(e.responseText)):r({error:{code:1,error_subcode:1357045,message:"unknown error (empty response)",status:e.status,type:"http"}})},c.send(s),!0)}};t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;const o=n(5).createZJSBridge();t.default=o,"undefined"==typeof window||window.zaloJSV2||(window.zaloJSV2={zalo_h5_event_handler:function(e,t,n){o.nativeEventHandler(e,t,n)}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createZJSBridge=void 0;const o=n(0),a=n(1),r=n(13),i=n(14),s=n(15),c=n(16),l=n(17),u=n(18);t.createZJSBridge=function(){const e=(e,t,n)=>{a.default.registerListenerEvent(e,t,n)};return{Zalo:r.default,Device:i.default,H5:s.default,Misc:c.default,Ads:l.default,getVersion:()=>"1.10.10",onJSCall:e=>{a.default.onJSCall(e)},onMultiJSCall:e=>{a.default.onMultiJSCall(e)},login:e=>{a.default.jsCall(o.Action.login,{},t=>{try{u.default.getAccessToken(e)}catch(t){return console.log(t),e(null)}},!0)},callCustomAction:(e,t,n,o=!0,r=3)=>{a.default.jsCall(e,t,n,o,r)},registerListenerEvent:e,onCloseWebview:t=>{e("h5.event.action.close",'{"handle_h5": 1}',t)},nativeEventHandler:(e,t,n)=>{a.default.nativeEventHandler(e,t,n)}}}},function(e,t,n){var o,a; | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=19)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionHaveCallBack=t.Action=void 0,t.Action={getdownloadedsticker:"action.get.downloaded.sticker",opensharesticker:"action.open.share.sticker",openprofile:"action.open.profile",openfeeddetail:"action.open.feeddetail",openfriendrada:"action.open.friendrada",openinapp:"action.open.inapp",openoutapp:"action.open.outapp",openpage:"action.open.page",openphotodetail:"action.open.photodetail",opengalary:"action.open.galary",opengamecenter:"action.open.gamecenter",opengamenews:"action.open.gamenews",opentabcontact:"action.open.tab.contact",opentabsocial:"action.open.tab.social",openfriendsuggest:"action.open.friendsuggest",opengrouplist:"action.open.grouplist",opennearby:"action.open.nearby",openroom:"action.open.room",openstickerstore:"action.open.stickerstore",opencreatechat:"action.open.createchat",copylinkcatesticker:"action.copy.link.catesticker",requestbuysticker:"action.request.buy.sticker",openchat:"action.open.chat",opentabchat:"action.open.tab.chat",openChatGroup:"action.open.chatgroup",openaddfriend:"action.open.addfriend",opentabmore:"action.open.tab.more",openpostfeed:"action.open.postfeed",openlogindevices:"action.open.logindevices",opensendsticker:"action.open.sendsticker",reportabuse:"action.report.abuse",followoa:"action.follow.oa",unfollowoa:"action.unfollow.oa",opengamedetail:"action.open.gamedetail",opensharesheet:"action.open.sharesheet",requestcamera:"action.request.permission.camera",changetitleheader:"action.change.title.header",clearcachewebview:"action.webview.clearcache",confirmcache:"action.webview.confirmcache",isvisible:"action.webview.isvisible",networktype:"action.webview.networktype",changebuttonheader:"action.change.button.header",createoptionmenu:"action.create.options.menu",createshortcut:"action.create.shortcut",changeleftbuttonbar:"action.change.actionbar.leftbutton.type",closewindow:"action.window.close",checkResError:"action.webview.checkResError",requestPayment:"action.iap.requestpayment",getzbrowserstats:"action.zbrowser.getstats",jsbridge:"action.zbrowser.jsbridge",bioauthen:"action.prompt.authentication",changeColorHeader:"action.change.actionbar.color",checkStateAuthen:"action.prompt.authentication.check_state",openappstore:"action.open.appstore",getlocation:"action.get.location",querylocationhide:"action.query.location.hide",showtoast:"action.show.toast",openapp:"action.open.app",hidekeyboard:"action.hide.keyboard",openphone:"action.open.phone",openqr:"action.open.qr",opensms:"action.open.sms",viewqr:"action.view.myqr",keepscreen:"action.keep.screen",autorotate:"action.change.autorotate",checkappinstalled:"action.check.app.installed",queryshow:"action.query.show",queryhide:"action.query.hide",openinapprw:"action.open.inapprw",gettrackingstatus:"action.zalorun.getTrackingStatus",settrackingstatus:"action.zalorun.setTrackingStatus",getdaystep:"action.zalorun.getDayStep",forcesubmitdata:"action.zalorun.forceSubmitData",setweight:"action.zalorun.setWeight",getAdIdClient:"action.get.adidclient",openProfileExt:"action.open.profile.ext",downloadcate:"action.download.cate",login:"action.jump.login",openInterstitialAds:"action.open.adtima.ads.interstitial",openRewardAds:"action.open.adtima.ads",openAdtimaAds:"action.open.adtima.ads",getAdsID:"action.get.adidclient"},t.ActionHaveCallBack=[t.Action.getdownloadedsticker,t.Action.openpostfeed,t.Action.reportabuse,t.Action.followoa,t.Action.unfollowoa,t.Action.opensharesheet,t.Action.createoptionmenu,t.Action.changeleftbuttonbar,t.Action.closewindow,t.Action.jsbridge,t.Action.getlocation,t.Action.querylocationhide,t.Action.showtoast,t.Action.viewqr,t.Action.keepscreen,t.Action.gettrackingstatus,t.Action.settrackingstatus,t.Action.getdaystep,t.Action.forcesubmitdata,t.Action.setweight,t.Action.downloadcate],t.default={}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(0),a=n(2),r=n(7),i=n(3);const s=new class{constructor(e){this._debug=r.default("jssdk:native-bridge"),this._accessTk=a.getToken("zacc_session")||"DEFAULT_ACCESS_TOKEN",this._jsAccessTk=a.getToken("zlink3rd")||"DEFAULT_JS_TOKEN",this._userAgent=a.getUserAgent(),this._device=a.checkPlatform(),this._appId=e||a.getToken("zapp"),this._jsCallFuncCallbacks={},this._listenerEvent={}}setAccessToken(e){this._accessTk=e}getAccessToken(){return this._accessTk}setJSToken(e){this._jsAccessTk=e}getJSToken(){return this._jsAccessTk}getAppId(){return this._appId}onJSCall(e){try{this._debug("onJSCall","data from native callback",e);const t=a.parseJSON(e);this._debug("onJSCall","data is parsed",t);const n=this._jsCallFuncCallbacks[t.action];n&&(n.call(this,t),this._jsCallFuncCallbacks[t.action]=null,delete this._jsCallFuncCallbacks[t.action])}catch(e){this._debug("onJSCall","error",e)}try{const t=a.parseJSON(e);i.default.execute("https://api.h5.zalo.me/log","post",{appId:this._appId,action:t.action,error:t.error_code},e=>{})}catch(e){}}onMultiJSCall(e){try{this._debug("onMultiJSCall","data from native callback",e);const t=a.parseJSON(e);this._debug("onMultiJSCall","data is parsed",t);const n=this._jsCallFuncCallbacks[t.action];n&&n.call(this,t)}catch(e){console.log(e)}try{const t=a.parseJSON(e);i.default.execute("https://api.h5.zalo.me/log","post",{appId:this._appId,action:t.action,error:t.error_code},e=>{})}catch(e){}}jsCallback(e,t,n){ZaloJavaScriptInterface.jsH5EventCallback(e,t,n)}registerListenerEvent(e,t,n){console.log("register "+e+" : "+t),this._listenerEvent[e]={handler:n,data:t}}nativeEventHandler(e,t,n){if(console.log("eventId:",e,"eventName",t,"eventData",n),this._listenerEvent[t]){const{handler:n,data:o}=this._listenerEvent[t];this.jsCallback(e,t,o);try{n()}catch(e){this._debug("nativeEventHandler","H5 handle event fail",t,e)}}}defaultCallback(e){null!=e&&(e=a.parseJSON(e),this._debug("defaultCallback","Callback data",e))}jsCall(e,t,n,r=!1,i=3){try{if(!this._device.isMobile||a.isEmpty(e))return this.onJSCall({error_code:-13,error_message:"params invalid!",data:{device:this._device.isMobile,jsToken:this._jsAccessTk,access_token:this._accessTk},action:e}),!1;null==t&&(t={}),a.isFunction(t)&&void 0===n&&(n=t,t={}),n||(n=this.defaultCallback);const s={error_code:-14,error_message:"Request Timeout!",data:{},action:e};this._jsCallFuncCallbacks[e]=n,o.ActionHaveCallBack.includes(e)&&setTimeout(()=>{this.onJSCall(s)},8e3);try{return t=a.serialize(t),r?this._device.isIOS?ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,window.ZJSBridge.onMultiJSCall):ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,"ZJSBridge.onMultiJSCall"):this._device.isIOS?ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,window.ZJSBridge.onJSCall):ZaloJavaScriptInterface.jsCall(this._jsAccessTk,e,this._accessTk,t,"ZJSBridge.onJSCall")}catch(o){if(!(i-- >0)){const n={error_code:-5,error_message:"Not ready!",data:{userAgent:this._userAgent,options:t,jsToken:this._jsAccessTk,access_token:this._accessTk},action:e,js_error:o};return this.onJSCall(n),!1}setTimeout(()=>{this.jsCall(e,t,n,r,i)},500)}}catch(e){this._debug("jsCall","error",e)}return!1}}(window.zAppID);t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZaloVersion=t.checkPlatform=t.getUserAgent=t.getToken=t.isFunction=t.serialize=t.isZaloBrowser=t.parseJSON=t.isString=t.isEmpty=t.isObject=t.writeCookie=void 0;const o=n(6),a=e=>{const t=document.cookie;if(t){const a=t.split("; ");if(a&&a.length>0)for(var n=e.length+1,o=a.length-1;o>=0;o--){let t=a[o];if(t&&0===t.indexOf(e)&&(t=t.substring(n,t.length),t))return t=t.replace(/["']/g,""),t}}return null};t.writeCookie=(e,t,n,a,r,i)=>{try{const s=new Date;s.setSeconds(s.getSeconds()+r),o.set(e,t,{path:n,domain:a,expires:s,secure:i})}catch(e){console.error("Fail to set cookie")}};const r=e=>a((()=>{const e=window.location.host;return e?0===e.indexOf("www.")?e.replace("www.","")+"_":e+"_":""})()+e),i=e=>a((()=>{const e=window.location.host;if(e){if(e.indexOf("zalo.me")>=0)return"zalo.me_";if(e.indexOf("baomoi.com")>=0)return"baomoi.com_";if(e.indexOf("mp3.zing.vn")>=0)return"mp3.zing.vn_";if(e.indexOf("zaloapp.com")>=0)return"zaloapp.com_"}return""})()+e);t.isObject=e=>"object"==typeof e,t.isEmpty=e=>!e||0===e.trim().length,t.isString=e=>"string"==typeof e||null!=e&&("object"==typeof e&&(!!e.constructor&&null!==e.constructor.toString().match(/string/i))),t.parseJSON=e=>t.isObject(JSON)&&JSON.parse&&t.isString(e)?JSON.parse(e):"object"==typeof e?e:new Function("return "+e)(),t.isZaloBrowser=()=>window.navigator.userAgent.includes("Zalo"),t.serialize=e=>{if(t.isObject(JSON)&&JSON.stringify)return JSON.stringify(e);if(void 0===e)return"undefined";if(null===e)return"null";try{if("string"==typeof e||null!==e.constructor.toString().match(/string/i))return'"'+e.replace(/"/g,'\\"')+'"'}catch(e){console.log(e)}var n;if(null!==Object.prototype.toString.call(e).match(/array/i)){n=new Array;for(var o=e.length,a=0;a<o;a++)n.push(t.serialize(e[a]));return"["+n.join(",")+"]"}if("object"==typeof e){for(var r in n=new Array,e)n.push('"'+r+'":'+t.serialize(e[r]));return"{"+n.join(",")+"}"}return e.toString()},t.isFunction=e=>"function"==typeof e,t.getToken=e=>(e=>{let t=r(e);return t||(t=i(e),t)?t:a(e)})(e),t.getUserAgent=()=>navigator.userAgent||navigator.vendor||window.opera,t.checkPlatform=()=>{const e=t.getUserAgent().toLowerCase();return{isWP:/iemobile/.test(e),isAndroid:/android/i.test(e)&&!/iemobile/.test(e),isIOS:/iphone|ipad|ipod/.test(e)&&!/iemobile/.test(e),isMobile:/android|iphone|ipad|ipod|iemobile/.test(e)}},t.getZaloVersion=()=>a("zversion")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(11),a=n(12);var r={error:{code:1,error_subcode:1357046,message:"Received Invalid JSON reply.",type:"http"}};function i(e){try{return null===e?r:JSON.parse(e)}catch(e){return r}}var s={execute:function(e,t,n,r){n.suppress_http_code=1;var s=o.default.encode(n);"post"!=t&&(e=o.default.appendToUrl(e,s),s="");var c=function(e,t){if(!self.XMLHttpRequest)return null;var n=new XMLHttpRequest,o=function(){};if(!("withCredentials"in n))return null;n.open(e,t,!0),n.setRequestHeader("Content-type","application/x-www-form-urlencoded");var r={send:function(e){n.send(e)}},i=a.default((function(){i=o,"onload"in r&&r.onload(n)}),"entry","XMLHttpRequest:load"),s=a.default((function(){s=o,"onerror"in r&&r.onerror(n)}),"entry","XMLHttpRequest:error");return n.onload=function(){i()},n.onerror=function(){s()},n.onreadystatechange=function(){4==n.readyState&&(200==n.status?i():s())},r}(t,e);return!!c&&(c.onload=function(e){r(i(e.responseText))},c.onerror=function(e){e.responseText?r(i(e.responseText)):r({error:{code:1,error_subcode:1357045,message:"unknown error (empty response)",status:e.status,type:"http"}})},c.send(s),!0)}};t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;const o=n(5).createZJSBridge();t.default=o,"undefined"==typeof window||window.zaloJSV2||(window.zaloJSV2={zalo_h5_event_handler:function(e,t,n){o.nativeEventHandler(e,t,n)}},window.ZJSBridge=o)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createZJSBridge=void 0;const o=n(0),a=n(1),r=n(13),i=n(14),s=n(15),c=n(16),l=n(17),u=n(18);t.createZJSBridge=function(){const e=(e,t,n)=>{a.default.registerListenerEvent(e,t,n)};return{Zalo:r.default,Device:i.default,H5:s.default,Misc:c.default,Ads:l.default,getVersion:()=>"1.10.11",onJSCall:e=>{a.default.onJSCall(e)},onMultiJSCall:e=>{a.default.onMultiJSCall(e)},login:e=>{a.default.jsCall(o.Action.login,{},t=>{try{u.default.getAccessToken(e)}catch(t){return console.log(t),e(null)}},!0)},callCustomAction:(e,t,n,o=!0,r=3)=>{a.default.jsCall(e,t,n,o,r)},registerListenerEvent:e,onCloseWebview:t=>{e("h5.event.action.close",'{"handle_h5": 1}',t)},nativeEventHandler:(e,t,n)=>{a.default.nativeEventHandler(e,t,n)}}}},function(e,t,n){var o,a; | ||
/*! | ||
@@ -3,0 +3,0 @@ * JavaScript Cookie v2.2.1 |
@@ -13,2 +13,3 @@ "use strict"; | ||
}; | ||
window.ZJSBridge = bridge; | ||
} |
{ | ||
"name": "zalo-js-bridge", | ||
"description": "A Javascript Framework for WebApp", | ||
"version": "1.10.10", | ||
"version": "1.10.11", | ||
"main": "dist/public/index.js", | ||
@@ -6,0 +6,0 @@ "keywords": [], |
151966
2208