Comparing version 1.0.13 to 1.0.14-1
@@ -35,2 +35,8 @@ var AgRuSdkMethods = /* @__PURE__ */ ((AgRuSdkMethods2) => { | ||
const instance = mitt(); | ||
const on = instance.on; | ||
instance.on = (type, handler) => { | ||
if (typeof handler === "function") { | ||
on(type, (args) => handler.call(null, ...args)); | ||
} | ||
}; | ||
instance.once = (type, handler) => { | ||
@@ -43,3 +49,3 @@ const wrap = (...args) => { | ||
}; | ||
instance.on(type, wrap); | ||
on(type, wrap); | ||
}; | ||
@@ -46,0 +52,0 @@ return instance; |
@@ -1,1 +0,1 @@ | ||
var e=(e=>(e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.SetSaveData="agru-setSaveData",e))(e||{});class t{constructor(e={}){if(this.options=e,t._instance)return t._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return e.debug?console.info("SDK is running in DEBUG mode!"):this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),t._instance=this,t._instance._emitter=this._createEmitter(),t._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var a=t.get(e);a?a.push(s):t.set(e,[s])},off:function(e,s){var a=t.get(e);a&&(s?a.splice(a.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var a=t.get(e);a&&a.slice().map((function(e){e(s)})),(a=t.get("*"))&&a.slice().map((function(t){t(e,s)}))}};var t;return e.once=(t,s)=>{const a=(...n)=>{e.off(t,a),"function"==typeof s&&s.apply(null,...n)};e.on(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;this._emitter.emit(s,t)}))}_sendMessage(e,t,s){return this.options.debug?setTimeout(s):null==top?void 0:top.postMessage({data:t,type:e},"*")}getSaveData(t){return this._sendMessage(e.GetSaveData,this.options,(()=>{this._emitter.emit(e.GetSaveData,[{a:!0,b:!1,c:1},null])})),this._handleEvent(e.GetSaveData,t)}getUsers(t,s){return this._sendMessage(e.GetUsers,t,(()=>{this._emitter.emit(e.GetUsers,[t.map((e=>({avatar:`https://api.lorem.space/image/face?w=150&h=150&hash=${e}`,id:e,name:Math.random().toString(16).substring(2)}))),null])})),this._handleEvent(e.GetUsers,s)}isAppUser(t,s){return this._sendMessage(e.IsAppUser,t,(()=>{this._emitter.emit(e.IsAppUser,[!0,null])})),this._handleEvent(e.IsAppUser,s)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}sayHello(t){const s="And here's Johnny";return this._sendMessage(e.SayHello,s,(()=>{this._emitter.emit(e.SayHello,[s,null])})),this._handleEvent(e.SayHello,t)}showCampaign(t="default",s){return this._sendMessage(e.ShowCampaign,{options:this.options,type:t},(()=>{this._emitter.emit(e.ShowCampaign,[{type:t,status:!0},null])})),this._handleEvent(e.ShowCampaign,s)}setSaveData(t,s){return this._sendMessage(e.SetSaveData,{data:t,options:this.options},(()=>{this._emitter.emit(e.SetSaveData,[!0,null])})),this._handleEvent(e.SetSaveData,s)}}export{t as AgRuSdk,e as AgRuSdkMethods}; | ||
var e=(e=>(e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.SetSaveData="agru-setSaveData",e))(e||{});class t{constructor(e={}){if(this.options=e,t._instance)return t._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return e.debug?console.info("SDK is running in DEBUG mode!"):this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),t._instance=this,t._instance._emitter=this._createEmitter(),t._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var a=t.get(e);a?a.push(s):t.set(e,[s])},off:function(e,s){var a=t.get(e);a&&(s?a.splice(a.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var a=t.get(e);a&&a.slice().map((function(e){e(s)})),(a=t.get("*"))&&a.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,a)=>{const n=(...s)=>{e.off(t,n),"function"==typeof a&&a.apply(null,...s)};s(t,n)},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;this._emitter.emit(s,t)}))}_sendMessage(e,t,s){return this.options.debug?setTimeout(s):null==top?void 0:top.postMessage({data:t,type:e},"*")}getSaveData(t){return this._sendMessage(e.GetSaveData,this.options,(()=>{this._emitter.emit(e.GetSaveData,[{a:!0,b:!1,c:1},null])})),this._handleEvent(e.GetSaveData,t)}getUsers(t,s){return this._sendMessage(e.GetUsers,t,(()=>{this._emitter.emit(e.GetUsers,[t.map((e=>({avatar:`https://api.lorem.space/image/face?w=150&h=150&hash=${e}`,id:e,name:Math.random().toString(16).substring(2)}))),null])})),this._handleEvent(e.GetUsers,s)}isAppUser(t,s){return this._sendMessage(e.IsAppUser,t,(()=>{this._emitter.emit(e.IsAppUser,[!0,null])})),this._handleEvent(e.IsAppUser,s)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}sayHello(t){const s="And here's Johnny";return this._sendMessage(e.SayHello,s,(()=>{this._emitter.emit(e.SayHello,[s,null])})),this._handleEvent(e.SayHello,t)}showCampaign(t="default",s){return this._sendMessage(e.ShowCampaign,{options:this.options,type:t},(()=>{this._emitter.emit(e.ShowCampaign,[{type:t,status:!0},null])})),this._handleEvent(e.ShowCampaign,s)}setSaveData(t,s){return this._sendMessage(e.SetSaveData,{data:t,options:this.options},(()=>{this._emitter.emit(e.SetSaveData,[!0,null])})),this._handleEvent(e.SetSaveData,s)}}export{t as AgRuSdk,e as AgRuSdkMethods}; |
@@ -39,2 +39,8 @@ 'use strict'; | ||
const instance = mitt(); | ||
const on = instance.on; | ||
instance.on = (type, handler) => { | ||
if (typeof handler === "function") { | ||
on(type, (args) => handler.call(null, ...args)); | ||
} | ||
}; | ||
instance.once = (type, handler) => { | ||
@@ -47,3 +53,3 @@ const wrap = (...args) => { | ||
}; | ||
instance.on(type, wrap); | ||
on(type, wrap); | ||
}; | ||
@@ -50,0 +56,0 @@ return instance; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=(e=>(e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.SetSaveData="agru-setSaveData",e))(e||{});class t{constructor(e={}){if(this.options=e,t._instance)return t._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return e.debug?console.info("SDK is running in DEBUG mode!"):this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),t._instance=this,t._instance._emitter=this._createEmitter(),t._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var a=t.get(e);a?a.push(s):t.set(e,[s])},off:function(e,s){var a=t.get(e);a&&(s?a.splice(a.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var a=t.get(e);a&&a.slice().map((function(e){e(s)})),(a=t.get("*"))&&a.slice().map((function(t){t(e,s)}))}};var t;return e.once=(t,s)=>{const a=(...n)=>{e.off(t,a),"function"==typeof s&&s.apply(null,...n)};e.on(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;this._emitter.emit(s,t)}))}_sendMessage(e,t,s){return this.options.debug?setTimeout(s):null==top?void 0:top.postMessage({data:t,type:e},"*")}getSaveData(t){return this._sendMessage(e.GetSaveData,this.options,(()=>{this._emitter.emit(e.GetSaveData,[{a:!0,b:!1,c:1},null])})),this._handleEvent(e.GetSaveData,t)}getUsers(t,s){return this._sendMessage(e.GetUsers,t,(()=>{this._emitter.emit(e.GetUsers,[t.map((e=>({avatar:`https://api.lorem.space/image/face?w=150&h=150&hash=${e}`,id:e,name:Math.random().toString(16).substring(2)}))),null])})),this._handleEvent(e.GetUsers,s)}isAppUser(t,s){return this._sendMessage(e.IsAppUser,t,(()=>{this._emitter.emit(e.IsAppUser,[!0,null])})),this._handleEvent(e.IsAppUser,s)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}sayHello(t){const s="And here's Johnny";return this._sendMessage(e.SayHello,s,(()=>{this._emitter.emit(e.SayHello,[s,null])})),this._handleEvent(e.SayHello,t)}showCampaign(t="default",s){return this._sendMessage(e.ShowCampaign,{options:this.options,type:t},(()=>{this._emitter.emit(e.ShowCampaign,[{type:t,status:!0},null])})),this._handleEvent(e.ShowCampaign,s)}setSaveData(t,s){return this._sendMessage(e.SetSaveData,{data:t,options:this.options},(()=>{this._emitter.emit(e.SetSaveData,[!0,null])})),this._handleEvent(e.SetSaveData,s)}}exports.AgRuSdk=t,exports.AgRuSdkMethods=e; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=(e=>(e.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.SetSaveData="agru-setSaveData",e))(e||{});class t{constructor(e={}){if(this.options=e,t._instance)return t._instance;for(const[e,t]of new URLSearchParams(location.search).entries())this.options[e]=t;return e.debug?console.info("SDK is running in DEBUG mode!"):this.options.auth_key||console.warn('You need to pass the "auth_key" in options, to be able to use the SDK.'),t._instance=this,t._instance._emitter=this._createEmitter(),t._instance.options=e,this._listen(),this}_createEmitter(){const e={all:t=t||new Map,on:function(e,s){var a=t.get(e);a?a.push(s):t.set(e,[s])},off:function(e,s){var a=t.get(e);a&&(s?a.splice(a.indexOf(s)>>>0,1):t.set(e,[]))},emit:function(e,s){var a=t.get(e);a&&a.slice().map((function(e){e(s)})),(a=t.get("*"))&&a.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,a)=>{const n=(...s)=>{e.off(t,n),"function"==typeof a&&a.apply(null,...s)};s(t,n)},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;this._emitter.emit(s,t)}))}_sendMessage(e,t,s){return this.options.debug?setTimeout(s):null==top?void 0:top.postMessage({data:t,type:e},"*")}getSaveData(t){return this._sendMessage(e.GetSaveData,this.options,(()=>{this._emitter.emit(e.GetSaveData,[{a:!0,b:!1,c:1},null])})),this._handleEvent(e.GetSaveData,t)}getUsers(t,s){return this._sendMessage(e.GetUsers,t,(()=>{this._emitter.emit(e.GetUsers,[t.map((e=>({avatar:`https://api.lorem.space/image/face?w=150&h=150&hash=${e}`,id:e,name:Math.random().toString(16).substring(2)}))),null])})),this._handleEvent(e.GetUsers,s)}isAppUser(t,s){return this._sendMessage(e.IsAppUser,t,(()=>{this._emitter.emit(e.IsAppUser,[!0,null])})),this._handleEvent(e.IsAppUser,s)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}sayHello(t){const s="And here's Johnny";return this._sendMessage(e.SayHello,s,(()=>{this._emitter.emit(e.SayHello,[s,null])})),this._handleEvent(e.SayHello,t)}showCampaign(t="default",s){return this._sendMessage(e.ShowCampaign,{options:this.options,type:t},(()=>{this._emitter.emit(e.ShowCampaign,[{type:t,status:!0},null])})),this._handleEvent(e.ShowCampaign,s)}setSaveData(t,s){return this._sendMessage(e.SetSaveData,{data:t,options:this.options},(()=>{this._emitter.emit(e.SetSaveData,[!0,null])})),this._handleEvent(e.SetSaveData,s)}}exports.AgRuSdk=t,exports.AgRuSdkMethods=e; |
@@ -41,2 +41,8 @@ (function (global, factory) { | ||
const instance = mitt(); | ||
const on = instance.on; | ||
instance.on = (type, handler) => { | ||
if (typeof handler === "function") { | ||
on(type, (args) => handler.call(null, ...args)); | ||
} | ||
}; | ||
instance.once = (type, handler) => { | ||
@@ -49,3 +55,3 @@ const wrap = (...args) => { | ||
}; | ||
instance.on(type, wrap); | ||
on(type, wrap); | ||
}; | ||
@@ -52,0 +58,0 @@ return instance; |
@@ -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.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.SetSaveData="agru-setSaveData",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 e.debug?console.info("SDK is running in DEBUG mode!"):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;return e.once=(t,s)=>{const n=(...a)=>{e.off(t,n),"function"==typeof s&&s.apply(null,...a)};e.on(t,n)},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;this._emitter.emit(s,t)}))}_sendMessage(e,t,s){return this.options.debug?setTimeout(s):null==top?void 0:top.postMessage({data:t,type:e},"*")}getSaveData(e){return this._sendMessage(t.GetSaveData,this.options,(()=>{this._emitter.emit(t.GetSaveData,[{a:!0,b:!1,c:1},null])})),this._handleEvent(t.GetSaveData,e)}getUsers(e,s){return this._sendMessage(t.GetUsers,e,(()=>{this._emitter.emit(t.GetUsers,[e.map((e=>({avatar:`https://api.lorem.space/image/face?w=150&h=150&hash=${e}`,id:e,name:Math.random().toString(16).substring(2)}))),null])})),this._handleEvent(t.GetUsers,s)}isAppUser(e,s){return this._sendMessage(t.IsAppUser,e,(()=>{this._emitter.emit(t.IsAppUser,[!0,null])})),this._handleEvent(t.IsAppUser,s)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}sayHello(e){const s="And here's Johnny";return this._sendMessage(t.SayHello,s,(()=>{this._emitter.emit(t.SayHello,[s,null])})),this._handleEvent(t.SayHello,e)}showCampaign(e="default",s){return this._sendMessage(t.ShowCampaign,{options:this.options,type:e},(()=>{this._emitter.emit(t.ShowCampaign,[{type:e,status:!0},null])})),this._handleEvent(t.ShowCampaign,s)}setSaveData(e,s){return this._sendMessage(t.SetSaveData,{data:e,options:this.options},(()=>{this._emitter.emit(t.SetSaveData,[!0,null])})),this._handleEvent(t.SetSaveData,s)}}e.AgRuSdk=s,e.AgRuSdkMethods=t,Object.defineProperty(e,"__esModule",{value:!0}),window.AgRuSdk=agru.AgRuSdk,window.AgRuSdkMethods=agru.AgRuSdkMethods})); | ||
!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.GetSaveData="agru-getSaveData",e.GetUsers="agru-getUsers",e.IsAppUser="agru-isAppUser",e.SayHello="agru-sayHello",e.ShowCampaign="agru-showCampaign",e.SetSaveData="agru-setSaveData",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 e.debug?console.info("SDK is running in DEBUG mode!"):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.apply(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;this._emitter.emit(s,t)}))}_sendMessage(e,t,s){return this.options.debug?setTimeout(s):null==top?void 0:top.postMessage({data:t,type:e},"*")}getSaveData(e){return this._sendMessage(t.GetSaveData,this.options,(()=>{this._emitter.emit(t.GetSaveData,[{a:!0,b:!1,c:1},null])})),this._handleEvent(t.GetSaveData,e)}getUsers(e,s){return this._sendMessage(t.GetUsers,e,(()=>{this._emitter.emit(t.GetUsers,[e.map((e=>({avatar:`https://api.lorem.space/image/face?w=150&h=150&hash=${e}`,id:e,name:Math.random().toString(16).substring(2)}))),null])})),this._handleEvent(t.GetUsers,s)}isAppUser(e,s){return this._sendMessage(t.IsAppUser,e,(()=>{this._emitter.emit(t.IsAppUser,[!0,null])})),this._handleEvent(t.IsAppUser,s)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}sayHello(e){const s="And here's Johnny";return this._sendMessage(t.SayHello,s,(()=>{this._emitter.emit(t.SayHello,[s,null])})),this._handleEvent(t.SayHello,e)}showCampaign(e="default",s){return this._sendMessage(t.ShowCampaign,{options:this.options,type:e},(()=>{this._emitter.emit(t.ShowCampaign,[{type:e,status:!0},null])})),this._handleEvent(t.ShowCampaign,s)}setSaveData(e,s){return this._sendMessage(t.SetSaveData,{data:e,options:this.options},(()=>{this._emitter.emit(t.SetSaveData,[!0,null])})),this._handleEvent(t.SetSaveData,s)}}e.AgRuSdk=s,e.AgRuSdkMethods=t,Object.defineProperty(e,"__esModule",{value:!0}),window.AgRuSdk=agru.AgRuSdk,window.AgRuSdkMethods=agru.AgRuSdkMethods})); |
{ | ||
"name": "@agru/sdk", | ||
"version": "1.0.13", | ||
"version": "1.0.14-1", | ||
"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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
35217
627
2