Comparing version 1.0.28 to 1.0.29
@@ -7,2 +7,3 @@ var AgRuSdkMethods = /* @__PURE__ */ ((AgRuSdkMethods2) => { | ||
AgRuSdkMethods2["IsAppUser"] = "agru-isAppUser"; | ||
AgRuSdkMethods2["Logout"] = "agru-logout"; | ||
AgRuSdkMethods2["SayHello"] = "agru-sayHello"; | ||
@@ -97,2 +98,6 @@ AgRuSdkMethods2["ShowCampaign"] = "agru-showCampaign"; | ||
} | ||
logout(callback) { | ||
this._sendMessage(AgRuSdkMethods.Logout, null); | ||
return this._handleEvent(AgRuSdkMethods.Logout, callback); | ||
} | ||
off(type, handler) { | ||
@@ -99,0 +104,0 @@ return this._emitter.off(type, handler); |
@@ -1,1 +0,1 @@ | ||
var e=(e=>(e.Authorize="agru-authorize",e.AuthorizeAndWait="agru-authorizeAndWait",e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.ShowPayment="agru-showPayment",e.SetSaveData="agru-setSaveData",e.ToggleFullscreen="agru-toggleFullscreen",e))(e||{}),t=(e=>(e.OptionsUpdates="agru-optionsUpdates",e))(t||{});class s{constructor(e={}){if(this.options=e,s._instance)return s._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),s._instance=this,s._instance._emitter=this._createEmitter(),s._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var n=t.get(e);n?n.push(s):t.set(e,[s])},off:function(e,s){var n=t.get(e);n&&(s?n.splice(n.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var n=t.get(e);n&&n.slice().map((function(e){e(s)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,s)}))}};var t;const s=e.on;return e.on=(e,t)=>{"function"==typeof t&&s(e,(e=>t.call(null,...e)))},e.once=(t,n)=>{const a=(...s)=>{e.off(t,a),"function"==typeof n&&n.call(null,...s)};s(t,a)},e}_handleEvent(e,t){return t?this._emitter.once(e,t):new Promise((t=>this._emitter.once(e,((...e)=>t(e)))))}_listen(){window.addEventListener("message",(e=>{const{data:t,type:s}=e.data;e.source!==window&&this._emitter.emit(s,t)}))}_sendMessage(e,t){return null==top?void 0:top.postMessage({data:t,type:e},"*")}authorize(t){return this._sendMessage(e.Authorize,void 0),this._handleEvent(e.Authorize,t)}authorizeAndWait(t){return this._sendMessage(e.AuthorizeAndWait,void 0),this._handleEvent(e.AuthorizeAndWait,t)}getSaveData(t){return this._sendMessage(e.GetSaveData,this.options),this._handleEvent(e.GetSaveData,t)}getUsers(t,s){return this._sendMessage(e.GetUsers,t.join(",")),this._handleEvent(e.GetUsers,s)}isAppUser(t,s){return this._sendMessage(e.IsAppUser,t),this._handleEvent(e.IsAppUser,s)}off(e,t){return this._emitter.off(e,t)}on(e,s){this._emitter.on(e,s);return Object.values(t).includes(e)&&this._sendMessage("event",e),()=>this._emitter.off(e,s)}once(e,t){return this._emitter.once(e,t)}sayHello(t){return this._sendMessage(e.SayHello,"And here's Johnny"),this._handleEvent(e.SayHello,t)}showCampaign(t="default",s){return this._sendMessage(e.ShowCampaign,{options:this.options,type:t}),this._handleEvent(e.ShowCampaign,s)}showPayment(t,s){return this._sendMessage(e.ShowPayment,t),this._handleEvent(e.ShowPayment,s)}toggleFullscreen(t){return this._sendMessage(e.ToggleFullscreen,null),this._handleEvent(e.ToggleFullscreen,t)}setSaveData(t,s){return this._sendMessage(e.SetSaveData,{data:t,options:this.options}),this._handleEvent(e.SetSaveData,s)}}export{s as AgRuSdk,t as AgRuSdkEvents,e as AgRuSdkMethods}; | ||
var e=(e=>(e.Authorize="agru-authorize",e.AuthorizeAndWait="agru-authorizeAndWait",e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.Logout="agru-logout",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.ShowPayment="agru-showPayment",e.SetSaveData="agru-setSaveData",e.ToggleFullscreen="agru-toggleFullscreen",e))(e||{}),t=(e=>(e.OptionsUpdates="agru-optionsUpdates",e))(t||{});class s{constructor(e={}){if(this.options=e,s._instance)return s._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),s._instance=this,s._instance._emitter=this._createEmitter(),s._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var n=t.get(e);n?n.push(s):t.set(e,[s])},off:function(e,s){var n=t.get(e);n&&(s?n.splice(n.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var n=t.get(e);n&&n.slice().map((function(e){e(s)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,s)}))}};var t;const s=e.on;return e.on=(e,t)=>{"function"==typeof t&&s(e,(e=>t.call(null,...e)))},e.once=(t,n)=>{const a=(...s)=>{e.off(t,a),"function"==typeof n&&n.call(null,...s)};s(t,a)},e}_handleEvent(e,t){return t?this._emitter.once(e,t):new Promise((t=>this._emitter.once(e,((...e)=>t(e)))))}_listen(){window.addEventListener("message",(e=>{const{data:t,type:s}=e.data;e.source!==window&&this._emitter.emit(s,t)}))}_sendMessage(e,t){return null==top?void 0:top.postMessage({data:t,type:e},"*")}authorize(t){return this._sendMessage(e.Authorize,void 0),this._handleEvent(e.Authorize,t)}authorizeAndWait(t){return this._sendMessage(e.AuthorizeAndWait,void 0),this._handleEvent(e.AuthorizeAndWait,t)}getSaveData(t){return this._sendMessage(e.GetSaveData,this.options),this._handleEvent(e.GetSaveData,t)}getUsers(t,s){return this._sendMessage(e.GetUsers,t.join(",")),this._handleEvent(e.GetUsers,s)}isAppUser(t,s){return this._sendMessage(e.IsAppUser,t),this._handleEvent(e.IsAppUser,s)}logout(t){return this._sendMessage(e.Logout,null),this._handleEvent(e.Logout,t)}off(e,t){return this._emitter.off(e,t)}on(e,s){this._emitter.on(e,s);return Object.values(t).includes(e)&&this._sendMessage("event",e),()=>this._emitter.off(e,s)}once(e,t){return this._emitter.once(e,t)}sayHello(t){return this._sendMessage(e.SayHello,"And here's Johnny"),this._handleEvent(e.SayHello,t)}showCampaign(t="default",s){return this._sendMessage(e.ShowCampaign,{options:this.options,type:t}),this._handleEvent(e.ShowCampaign,s)}showPayment(t,s){return this._sendMessage(e.ShowPayment,t),this._handleEvent(e.ShowPayment,s)}toggleFullscreen(t){return this._sendMessage(e.ToggleFullscreen,null),this._handleEvent(e.ToggleFullscreen,t)}setSaveData(t,s){return this._sendMessage(e.SetSaveData,{data:t,options:this.options}),this._handleEvent(e.SetSaveData,s)}}export{s as AgRuSdk,t as AgRuSdkEvents,e as AgRuSdkMethods}; |
@@ -9,2 +9,3 @@ import { Emitter } from 'mitt'; | ||
IsAppUser = "agru-isAppUser", | ||
Logout = "agru-logout", | ||
SayHello = "agru-sayHello", | ||
@@ -34,2 +35,3 @@ ShowCampaign = "agru-showCampaign", | ||
[AgRuSdkMethods.IsAppUser]: number; | ||
[AgRuSdkMethods.Logout]: null; | ||
[AgRuSdkMethods.SayHello]: string; | ||
@@ -61,2 +63,3 @@ [AgRuSdkMethods.ShowCampaign]: { | ||
[AgRuSdkMethods.IsAppUser]: boolean; | ||
[AgRuSdkMethods.Logout]: boolean; | ||
[AgRuSdkMethods.SayHello]: string; | ||
@@ -158,2 +161,7 @@ [AgRuSdkMethods.ShowCampaign]: { | ||
/** | ||
* Logout user. | ||
*/ | ||
logout(): AgRuPromise<AgRuSdkMethods.Logout>; | ||
logout(callback: AgRuCallback<AgRuSdkMethods.Logout>): void; | ||
/** | ||
* Unlisten the event. | ||
@@ -160,0 +168,0 @@ * @param type Event type. |
@@ -11,2 +11,3 @@ 'use strict'; | ||
AgRuSdkMethods2["IsAppUser"] = "agru-isAppUser"; | ||
AgRuSdkMethods2["Logout"] = "agru-logout"; | ||
AgRuSdkMethods2["SayHello"] = "agru-sayHello"; | ||
@@ -101,2 +102,6 @@ AgRuSdkMethods2["ShowCampaign"] = "agru-showCampaign"; | ||
} | ||
logout(callback) { | ||
this._sendMessage(AgRuSdkMethods.Logout, null); | ||
return this._handleEvent(AgRuSdkMethods.Logout, callback); | ||
} | ||
off(type, handler) { | ||
@@ -103,0 +108,0 @@ return this._emitter.off(type, handler); |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=(e=>(e.Authorize="agru-authorize",e.AuthorizeAndWait="agru-authorizeAndWait",e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.ShowPayment="agru-showPayment",e.SetSaveData="agru-setSaveData",e.ToggleFullscreen="agru-toggleFullscreen",e))(e||{}),t=(e=>(e.OptionsUpdates="agru-optionsUpdates",e))(t||{});class s{constructor(e={}){if(this.options=e,s._instance)return s._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),s._instance=this,s._instance._emitter=this._createEmitter(),s._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var n=t.get(e);n?n.push(s):t.set(e,[s])},off:function(e,s){var n=t.get(e);n&&(s?n.splice(n.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var n=t.get(e);n&&n.slice().map((function(e){e(s)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,s)}))}};var t;const s=e.on;return e.on=(e,t)=>{"function"==typeof t&&s(e,(e=>t.call(null,...e)))},e.once=(t,n)=>{const a=(...s)=>{e.off(t,a),"function"==typeof n&&n.call(null,...s)};s(t,a)},e}_handleEvent(e,t){return t?this._emitter.once(e,t):new Promise((t=>this._emitter.once(e,((...e)=>t(e)))))}_listen(){window.addEventListener("message",(e=>{const{data:t,type:s}=e.data;e.source!==window&&this._emitter.emit(s,t)}))}_sendMessage(e,t){return null==top?void 0:top.postMessage({data:t,type:e},"*")}authorize(t){return this._sendMessage(e.Authorize,void 0),this._handleEvent(e.Authorize,t)}authorizeAndWait(t){return this._sendMessage(e.AuthorizeAndWait,void 0),this._handleEvent(e.AuthorizeAndWait,t)}getSaveData(t){return this._sendMessage(e.GetSaveData,this.options),this._handleEvent(e.GetSaveData,t)}getUsers(t,s){return this._sendMessage(e.GetUsers,t.join(",")),this._handleEvent(e.GetUsers,s)}isAppUser(t,s){return this._sendMessage(e.IsAppUser,t),this._handleEvent(e.IsAppUser,s)}off(e,t){return this._emitter.off(e,t)}on(e,s){this._emitter.on(e,s);return Object.values(t).includes(e)&&this._sendMessage("event",e),()=>this._emitter.off(e,s)}once(e,t){return this._emitter.once(e,t)}sayHello(t){return this._sendMessage(e.SayHello,"And here's Johnny"),this._handleEvent(e.SayHello,t)}showCampaign(t="default",s){return this._sendMessage(e.ShowCampaign,{options:this.options,type:t}),this._handleEvent(e.ShowCampaign,s)}showPayment(t,s){return this._sendMessage(e.ShowPayment,t),this._handleEvent(e.ShowPayment,s)}toggleFullscreen(t){return this._sendMessage(e.ToggleFullscreen,null),this._handleEvent(e.ToggleFullscreen,t)}setSaveData(t,s){return this._sendMessage(e.SetSaveData,{data:t,options:this.options}),this._handleEvent(e.SetSaveData,s)}}exports.AgRuSdk=s,exports.AgRuSdkEvents=t,exports.AgRuSdkMethods=e; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=(e=>(e.Authorize="agru-authorize",e.AuthorizeAndWait="agru-authorizeAndWait",e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.Logout="agru-logout",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.ShowPayment="agru-showPayment",e.SetSaveData="agru-setSaveData",e.ToggleFullscreen="agru-toggleFullscreen",e))(e||{}),t=(e=>(e.OptionsUpdates="agru-optionsUpdates",e))(t||{});class s{constructor(e={}){if(this.options=e,s._instance)return s._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),s._instance=this,s._instance._emitter=this._createEmitter(),s._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var n=t.get(e);n?n.push(s):t.set(e,[s])},off:function(e,s){var n=t.get(e);n&&(s?n.splice(n.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var n=t.get(e);n&&n.slice().map((function(e){e(s)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,s)}))}};var t;const s=e.on;return e.on=(e,t)=>{"function"==typeof t&&s(e,(e=>t.call(null,...e)))},e.once=(t,n)=>{const a=(...s)=>{e.off(t,a),"function"==typeof n&&n.call(null,...s)};s(t,a)},e}_handleEvent(e,t){return t?this._emitter.once(e,t):new Promise((t=>this._emitter.once(e,((...e)=>t(e)))))}_listen(){window.addEventListener("message",(e=>{const{data:t,type:s}=e.data;e.source!==window&&this._emitter.emit(s,t)}))}_sendMessage(e,t){return null==top?void 0:top.postMessage({data:t,type:e},"*")}authorize(t){return this._sendMessage(e.Authorize,void 0),this._handleEvent(e.Authorize,t)}authorizeAndWait(t){return this._sendMessage(e.AuthorizeAndWait,void 0),this._handleEvent(e.AuthorizeAndWait,t)}getSaveData(t){return this._sendMessage(e.GetSaveData,this.options),this._handleEvent(e.GetSaveData,t)}getUsers(t,s){return this._sendMessage(e.GetUsers,t.join(",")),this._handleEvent(e.GetUsers,s)}isAppUser(t,s){return this._sendMessage(e.IsAppUser,t),this._handleEvent(e.IsAppUser,s)}logout(t){return this._sendMessage(e.Logout,null),this._handleEvent(e.Logout,t)}off(e,t){return this._emitter.off(e,t)}on(e,s){this._emitter.on(e,s);return Object.values(t).includes(e)&&this._sendMessage("event",e),()=>this._emitter.off(e,s)}once(e,t){return this._emitter.once(e,t)}sayHello(t){return this._sendMessage(e.SayHello,"And here's Johnny"),this._handleEvent(e.SayHello,t)}showCampaign(t="default",s){return this._sendMessage(e.ShowCampaign,{options:this.options,type:t}),this._handleEvent(e.ShowCampaign,s)}showPayment(t,s){return this._sendMessage(e.ShowPayment,t),this._handleEvent(e.ShowPayment,s)}toggleFullscreen(t){return this._sendMessage(e.ToggleFullscreen,null),this._handleEvent(e.ToggleFullscreen,t)}setSaveData(t,s){return this._sendMessage(e.SetSaveData,{data:t,options:this.options}),this._handleEvent(e.SetSaveData,s)}}exports.AgRuSdk=s,exports.AgRuSdkEvents=t,exports.AgRuSdkMethods=e; |
@@ -13,2 +13,3 @@ (function (global, factory) { | ||
AgRuSdkMethods2["IsAppUser"] = "agru-isAppUser"; | ||
AgRuSdkMethods2["Logout"] = "agru-logout"; | ||
AgRuSdkMethods2["SayHello"] = "agru-sayHello"; | ||
@@ -103,2 +104,6 @@ AgRuSdkMethods2["ShowCampaign"] = "agru-showCampaign"; | ||
} | ||
logout(callback) { | ||
this._sendMessage(AgRuSdkMethods.Logout, null); | ||
return this._handleEvent(AgRuSdkMethods.Logout, callback); | ||
} | ||
off(type, handler) { | ||
@@ -105,0 +110,0 @@ return this._emitter.off(type, handler); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).agru={})}(this,(function(e){"use strict";var t=(e=>(e.Authorize="agru-authorize",e.AuthorizeAndWait="agru-authorizeAndWait",e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.ShowPayment="agru-showPayment",e.SetSaveData="agru-setSaveData",e.ToggleFullscreen="agru-toggleFullscreen",e))(t||{}),s=(e=>(e.OptionsUpdates="agru-optionsUpdates",e))(s||{});class n{constructor(e={}){if(this.options=e,n._instance)return n._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),n._instance=this,n._instance._emitter=this._createEmitter(),n._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var n=t.get(e);n?n.push(s):t.set(e,[s])},off:function(e,s){var n=t.get(e);n&&(s?n.splice(n.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var n=t.get(e);n&&n.slice().map((function(e){e(s)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,s)}))}};var t;const s=e.on;return e.on=(e,t)=>{"function"==typeof t&&s(e,(e=>t.call(null,...e)))},e.once=(t,n)=>{const a=(...s)=>{e.off(t,a),"function"==typeof n&&n.call(null,...s)};s(t,a)},e}_handleEvent(e,t){return t?this._emitter.once(e,t):new Promise((t=>this._emitter.once(e,((...e)=>t(e)))))}_listen(){window.addEventListener("message",(e=>{const{data:t,type:s}=e.data;e.source!==window&&this._emitter.emit(s,t)}))}_sendMessage(e,t){return null==top?void 0:top.postMessage({data:t,type:e},"*")}authorize(e){return this._sendMessage(t.Authorize,void 0),this._handleEvent(t.Authorize,e)}authorizeAndWait(e){return this._sendMessage(t.AuthorizeAndWait,void 0),this._handleEvent(t.AuthorizeAndWait,e)}getSaveData(e){return this._sendMessage(t.GetSaveData,this.options),this._handleEvent(t.GetSaveData,e)}getUsers(e,s){return this._sendMessage(t.GetUsers,e.join(",")),this._handleEvent(t.GetUsers,s)}isAppUser(e,s){return this._sendMessage(t.IsAppUser,e),this._handleEvent(t.IsAppUser,s)}off(e,t){return this._emitter.off(e,t)}on(e,t){this._emitter.on(e,t);return Object.values(s).includes(e)&&this._sendMessage("event",e),()=>this._emitter.off(e,t)}once(e,t){return this._emitter.once(e,t)}sayHello(e){return this._sendMessage(t.SayHello,"And here's Johnny"),this._handleEvent(t.SayHello,e)}showCampaign(e="default",s){return this._sendMessage(t.ShowCampaign,{options:this.options,type:e}),this._handleEvent(t.ShowCampaign,s)}showPayment(e,s){return this._sendMessage(t.ShowPayment,e),this._handleEvent(t.ShowPayment,s)}toggleFullscreen(e){return this._sendMessage(t.ToggleFullscreen,null),this._handleEvent(t.ToggleFullscreen,e)}setSaveData(e,s){return this._sendMessage(t.SetSaveData,{data:e,options:this.options}),this._handleEvent(t.SetSaveData,s)}}e.AgRuSdk=n,e.AgRuSdkEvents=s,e.AgRuSdkMethods=t,Object.defineProperty(e,"__esModule",{value:!0}),window.AgRuSdk=agru.AgRuSdk,window.AgRuSdkMethods=agru.AgRuSdkMethods,window.AgRuSdkEvents=agru.AgRuSdkEvents})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).agru={})}(this,(function(e){"use strict";var t=(e=>(e.Authorize="agru-authorize",e.AuthorizeAndWait="agru-authorizeAndWait",e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.Logout="agru-logout",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.ShowPayment="agru-showPayment",e.SetSaveData="agru-setSaveData",e.ToggleFullscreen="agru-toggleFullscreen",e))(t||{}),s=(e=>(e.OptionsUpdates="agru-optionsUpdates",e))(s||{});class n{constructor(e={}){if(this.options=e,n._instance)return n._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),n._instance=this,n._instance._emitter=this._createEmitter(),n._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var n=t.get(e);n?n.push(s):t.set(e,[s])},off:function(e,s){var n=t.get(e);n&&(s?n.splice(n.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var n=t.get(e);n&&n.slice().map((function(e){e(s)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,s)}))}};var t;const s=e.on;return e.on=(e,t)=>{"function"==typeof t&&s(e,(e=>t.call(null,...e)))},e.once=(t,n)=>{const a=(...s)=>{e.off(t,a),"function"==typeof n&&n.call(null,...s)};s(t,a)},e}_handleEvent(e,t){return t?this._emitter.once(e,t):new Promise((t=>this._emitter.once(e,((...e)=>t(e)))))}_listen(){window.addEventListener("message",(e=>{const{data:t,type:s}=e.data;e.source!==window&&this._emitter.emit(s,t)}))}_sendMessage(e,t){return null==top?void 0:top.postMessage({data:t,type:e},"*")}authorize(e){return this._sendMessage(t.Authorize,void 0),this._handleEvent(t.Authorize,e)}authorizeAndWait(e){return this._sendMessage(t.AuthorizeAndWait,void 0),this._handleEvent(t.AuthorizeAndWait,e)}getSaveData(e){return this._sendMessage(t.GetSaveData,this.options),this._handleEvent(t.GetSaveData,e)}getUsers(e,s){return this._sendMessage(t.GetUsers,e.join(",")),this._handleEvent(t.GetUsers,s)}isAppUser(e,s){return this._sendMessage(t.IsAppUser,e),this._handleEvent(t.IsAppUser,s)}logout(e){return this._sendMessage(t.Logout,null),this._handleEvent(t.Logout,e)}off(e,t){return this._emitter.off(e,t)}on(e,t){this._emitter.on(e,t);return Object.values(s).includes(e)&&this._sendMessage("event",e),()=>this._emitter.off(e,t)}once(e,t){return this._emitter.once(e,t)}sayHello(e){return this._sendMessage(t.SayHello,"And here's Johnny"),this._handleEvent(t.SayHello,e)}showCampaign(e="default",s){return this._sendMessage(t.ShowCampaign,{options:this.options,type:e}),this._handleEvent(t.ShowCampaign,s)}showPayment(e,s){return this._sendMessage(t.ShowPayment,e),this._handleEvent(t.ShowPayment,s)}toggleFullscreen(e){return this._sendMessage(t.ToggleFullscreen,null),this._handleEvent(t.ToggleFullscreen,e)}setSaveData(e,s){return this._sendMessage(t.SetSaveData,{data:e,options:this.options}),this._handleEvent(t.SetSaveData,s)}}e.AgRuSdk=n,e.AgRuSdkEvents=s,e.AgRuSdkMethods=t,Object.defineProperty(e,"__esModule",{value:!0}),window.AgRuSdk=agru.AgRuSdk,window.AgRuSdkMethods=agru.AgRuSdkMethods,window.AgRuSdkEvents=agru.AgRuSdkEvents})); |
{ | ||
"name": "@agru/sdk", | ||
"version": "1.0.28", | ||
"version": "1.0.29", | ||
"description": "AG RU SDK for the games integration", | ||
@@ -5,0 +5,0 @@ "module": "dist/esm/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45709
685