From e90e5c100f88f65562fdeae1d29ab8dce14409bd Mon Sep 17 00:00:00 2001 From: isstuev Date: Thu, 11 Jul 2024 14:25:41 +0200 Subject: [PATCH] bridge-test --- index.html | 781 +++++++++++++++++++++++++++++++++++++++- instant-games-bridge.js | 2 + 2 files changed, 782 insertions(+), 1 deletion(-) mode change 100644 => 100755 index.html create mode 100644 instant-games-bridge.js diff --git a/index.html b/index.html old mode 100644 new mode 100755 index 5e1c309..323317f --- a/index.html +++ b/index.html @@ -1 +1,780 @@ -Hello World \ No newline at end of file + + + + + + + + + + +
+
+

Instant Games Bridge Sandbox

+

Loading..

+
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + diff --git a/instant-games-bridge.js b/instant-games-bridge.js new file mode 100644 index 0000000..9a7a5db --- /dev/null +++ b/instant-games-bridge.js @@ -0,0 +1,2 @@ +/*! For license information please see instant-games-bridge.js.LICENSE.txt */ +(()=>{var e={258:e=>{!function(t){e.exports=t;var r="listeners",n={on:function(e,t){return a(this,e).push(t),this},once:function(e,t){var r=this;return n.originalListener=t,a(r,e).push(n),r;function n(){i.call(r,e,n),t.apply(this,arguments)}},off:i,emit:function(e,t){var r=this,n=a(r,e,!0);if(!n)return!1;var o=arguments.length;if(1===o)n.forEach((function(e){e.call(r)}));else if(2===o)n.forEach((function(e){e.call(r,t)}));else{var i=Array.prototype.slice.call(arguments,1);n.forEach((function(e){e.apply(r,i)}))}return!!n.length}};function o(e){for(var t in n)e[t]=n[t];return e}function i(e,t){var n,o=this;if(arguments.length){if(t){if(n=a(o,e,!0)){if(!(n=n.filter((function(e){return e!==t&&e.originalListener!==t}))).length)return i.call(o,e);o[r][e]=n}}else if((n=o[r])&&(delete n[e],!Object.keys(n).length))return i.call(o)}else delete o[r];return o}function a(e,t,n){if(!n||e[r]){var o=e[r]||(e[r]={});return o[t]||(o[t]=[])}}o(t.prototype),t.mixin=o}((function e(){if(!(this instanceof e))return new e}))}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e={VK:"vk",VK_PLAY:"vk_play",OK:"ok",YANDEX:"yandex",CRAZY_GAMES:"crazy_games",ABSOLUTE_GAMES:"absolute_games",GAME_DISTRIBUTION:"game_distribution",PLAYGAMA:"playgama",WORTAL:"wortal",PLAYDECK:"playdeck",MOCK:"mock"},t={PLATFORM:"platform",PLAYER:"player",GAME:"game",STORAGE:"storage",ADVERTISEMENT:"advertisement",SOCIAL:"social",DEVICE:"device",LEADERBOARD:"leaderboard",PAYMENTS:"payments",REMOTE_CONFIG:"remote_config",CLIPBOARD:"clipboard"},n={INTERSTITIAL_STATE_CHANGED:"interstitial_state_changed",REWARDED_STATE_CHANGED:"rewarded_state_changed",BANNER_STATE_CHANGED:"banner_state_changed",VISIBILITY_STATE_CHANGED:"visibility_state_changed"},o={VISIBLE:"visible",HIDDEN:"hidden"},i={LOADING:"loading",OPENED:"opened",CLOSED:"closed",FAILED:"failed"},a={LOADING:"loading",OPENED:"opened",CLOSED:"closed",FAILED:"failed",REWARDED:"rewarded"},s={LOADING:"loading",SHOWN:"shown",HIDDEN:"hidden",FAILED:"failed"},u={LOCAL_STORAGE:"local_storage",PLATFORM_INTERNAL:"platform_internal"},c={DESKTOP:"desktop",MOBILE:"mobile",TABLET:"tablet",TV:"tv"},l={GAME_READY:"game_ready",IN_GAME_LOADING_STARTED:"in_game_loading_started",IN_GAME_LOADING_STOPPED:"in_game_loading_stopped",GAMEPLAY_STARTED:"gameplay_started",GAMEPLAY_STOPPED:"gameplay_stopped",PLAYER_GOT_ACHIEVEMENT:"player_got_achievement",GAME_OVER:"game_over"},f={INITIALIZE:"initialize",AUTHORIZE_PLAYER:"authorize_player",SHARE:"share",INVITE_FRIENDS:"invite_friends",JOIN_COMMUNITY:"join_community",CREATE_POST:"create_post",ADD_TO_HOME_SCREEN:"add_to_home_screen",ADD_TO_FAVORITES:"add_to_favorites",RATE:"rate",SET_LEADERBOARD_SCORE:"set_leaderboard_score",GET_LEADERBOARD_SCORE:"get_leaderboard_score",GET_LEADERBOARD_ENTRIES:"get_leaderboard_entries",GET_PURCHASES:"get_purchases",GET_CATALOG:"get_catalog",PURCHASE:"purchase",CONSUME_PURCHASE:"consume_purchase",GET_REMOTE_CONFIG:"get_remote_config",GET_STORAGE_DATA:"get_storage_data",SHOW_LEADERBOARD_NATIVE_POPUP:"show_leaderboard_native_popup",CLIPBOARD_WRITE:"clipboard_write",ADBLOCK_DETECT:"adblock_detect"},p={message:"Before using the SDK you must initialize it"},y={message:"Storage not supported"},d={message:"Storage not available"},h={message:"GameDistribution Game ID is undefined"},m={message:"VK Play Game ID is undefined"},v={message:"OK Game params are not found"},_={message:"Message is too long"};function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function g(e,t){for(var r=0;r2&&void 0!==arguments[2])||arguments[2];if(t){var n=t[this._platformBridge.platformId];if(n)return this.get(e,n,r)}var o=t;return o||(o=this.defaultType),this._platformBridge.isStorageAvailable(o)?this._platformBridge.getDataFromStorage(e,o,r):Promise.reject()}},{key:"set",value:function(e,t,r){if(r){var n=r[this._platformBridge.platformId];if(n)return this.set(e,t,n)}var o=r;return o||(o=this.defaultType),this._platformBridge.isStorageAvailable(o)?this._platformBridge.setDataToStorage(e,t,o):Promise.reject()}},{key:"delete",value:function(e,t){if(t){var r=t[this._platformBridge.platformId];if(r)return this.delete(e,r)}var n=t;return n||(n=this.defaultType),this._platformBridge.isStorageAvailable(n)?this._platformBridge.deleteDataFromStorage(e,n):Promise.reject()}}],r&&re(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),a}(L);function se(e){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},se(e)}function ue(e,t){for(var r=0;r0&&Ge(Le(t),xe,Ze).call(Le(t)),t.emit(n.INTERSTITIAL_STATE_CHANGED,e)})),t._platformBridge.on(n.REWARDED_STATE_CHANGED,(function(e){return t.emit(n.REWARDED_STATE_CHANGED,e)})),t._platformBridge.on(n.BANNER_STATE_CHANGED,(function(e){return t.emit(n.BANNER_STATE_CHANGED,e)})),t}return t=l,(r=[{key:"isBannerSupported",get:function(){return this._platformBridge.isBannerSupported}},{key:"bannerState",get:function(){return this._platformBridge.bannerState}},{key:"interstitialState",get:function(){return this._platformBridge.interstitialState}},{key:"rewardedState",get:function(){return this._platformBridge.rewardedState}},{key:"minimumDelayBetweenInterstitial",get:function(){return We(this,Ue)}},{key:"setMinimumDelayBetweenInterstitial",value:function(e){if(e){var t=e[this._platformBridge.platformId];if(void 0!==t)return void this.setMinimumDelayBetweenInterstitial(t)}var r=De(e),n=We(this,Ue);switch(r){case"number":n=e;break;case"string":if(n=parseInt(e,10),Number.isNaN(n))return;break;default:return}Fe(this,Ue,n),We(this,He)&&(We(this,He).stop(),Ge(this,xe,Ze).call(this))}},{key:"showBanner",value:function(e){if(e){var t=e[this._platformBridge.platformId];if(t)return void this.showBanner(t)}this.bannerState!==s.LOADING&&this.bannerState!==s.SHOWN&&(this._platformBridge._setBannerState(s.LOADING),this.isBannerSupported?this._platformBridge.showBanner(e):this._platformBridge._setBannerState(s.FAILED))}},{key:"hideBanner",value:function(){this.bannerState!==s.LOADING&&this.bannerState!==s.HIDDEN&&this.isBannerSupported&&this._platformBridge.hideBanner()}},{key:"showInterstitial",value:function(e){if(!Ge(this,Ve,Ke).call(this)){if(e){var t=e[this._platformBridge.platformId];if(t)return void this.showInterstitial(t)}var r=!1;e&&"boolean"==typeof e.ignoreDelay&&(r=e.ignoreDelay),this._platformBridge._setInterstitialState(i.LOADING),!We(this,He)||We(this,He).state===_e||r?this._platformBridge.showInterstitial(e):this._platformBridge._setInterstitialState(i.FAILED)}}},{key:"showRewarded",value:function(e){if(!Ge(this,Ve,Ke).call(this)){if(e){var t=e[this._platformBridge.platformId];if(t)return void this.showRewarded(t)}this._platformBridge._setRewardedState(a.LOADING),this._platformBridge.showRewarded(e)}}},{key:"checkAdBlock",value:function(){return this._platformBridge.checkAdBlock()}}])&&Ie(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),l}(L);function Ze(){Fe(this,He,new Te(We(this,Ue))),We(this,He).start()}function Ke(){return this.interstitialState===i.LOADING||this.interstitialState===i.OPENED||!![a.LOADING,a.OPENED,a.REWARDED].includes(this.rewardedState)}Z().mixin(Ye.prototype);const Je=Ye;function qe(e){return qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qe(e)}function Xe(e,t){for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"result",i=this._getPromiseDecorator(e);return i||(i=this._createPromiseDecorator(e),this._platformSdk.send(t,n).then((function(t){t[o]?r._resolvePromiseDecorator(e):r._rejectPromiseDecorator(e)})).catch((function(t){r._rejectPromiseDecorator(e,t)}))),i.promise}const nr=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Zt(e,t)}(y,t);var r,n,o,l,p=(o=y,l=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Jt(o);if(l){var r=Jt(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===Ut(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Kt(e)}(this,e)});function y(){var e,t,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,y);for(var n=arguments.length,o=new Array(n),i=0;i0&&(r=e.entries.map((function(e){return{id:e.player.uniqueID,score:e.score,rank:e.rank,name:e.player.publicName,photo:e.player.getAvatarSrc("large")}}))),t._resolvePromiseDecorator(f.GET_LEADERBOARD_ENTRIES,r)})).catch((function(e){t._rejectPromiseDecorator(f.GET_LEADERBOARD_ENTRIES,e)}))}return r.promise}},{key:"purchase",value:function(e){var t=this;if(!vr(this,wr)||!e.id)return Promise.reject();var r=this._getPromiseDecorator(f.PURCHASE);return r||(r=this._createPromiseDecorator(f.PURCHASE),vr(this,wr).purchase(e).then((function(e){t._resolvePromiseDecorator(f.PURCHASE,e)})).catch((function(e){t._rejectPromiseDecorator(f.PURCHASE,e)}))),r.promise}},{key:"getPaymentsPurchases",value:function(){var e=this;if(!vr(this,wr))return Promise.reject();var t=this._getPromiseDecorator(f.GET_PURCHASES);return t||(t=this._createPromiseDecorator(f.GET_PURCHASES),vr(this,wr).getPurchases().then((function(t){e._resolvePromiseDecorator(f.GET_PURCHASES,t)})).catch((function(t){e._rejectPromiseDecorator(f.GET_PURCHASES,t)}))),t.promise}},{key:"getPaymentsCatalog",value:function(){var e=this;if(!vr(this,wr))return Promise.reject();var t=this._getPromiseDecorator(f.GET_CATALOG);return t||(t=this._createPromiseDecorator(f.GET_CATALOG),vr(this,wr).getCatalog().then((function(t){e._resolvePromiseDecorator(f.GET_CATALOG,t)})).catch((function(t){e._rejectPromiseDecorator(f.GET_CATALOG,t)}))),t.promise}},{key:"consumePurchase",value:function(e){var t=this;if(!vr(this,wr)||!e.purchaseToken)return Promise.reject();var r=this._getPromiseDecorator(f.CONSUME_PURCHASE);return r||(r=this._createPromiseDecorator(f.CONSUME_PURCHASE),vr(this,wr).consumePurchase(e.purchaseToken).then((function(e){t._resolvePromiseDecorator(f.CONSUME_PURCHASE,e)})).catch((function(e){t._rejectPromiseDecorator(f.CONSUME_PURCHASE,e)}))),r.promise}},{key:"getRemoteConfig",value:function(e){var t=this;if(!this._platformSdk)return Promise.reject();if(e&&(null==e||!e.defaultFlags)&&(null==e||!e.clientFeatures))return Promise.reject();var r=this._getPromiseDecorator(f.GET_REMOTE_CONFIG);return r||(r=this._createPromiseDecorator(f.GET_REMOTE_CONFIG),(e?this._platformSdk.getFlags(e):this._platformSdk.getFlags()).then((function(e){t._resolvePromiseDecorator(f.GET_REMOTE_CONFIG,e)})).catch((function(e){t._rejectPromiseDecorator(f.GET_REMOTE_CONFIG,e)}))),r.promise}},{key:"clipboardWrite",value:function(e){var t=this,r=this._getPromiseDecorator(f.CLIPBOARD_WRITE);return r||(r=this._createPromiseDecorator(f.CLIPBOARD_WRITE),this._platformSdk.clipboard.writeText(e).then((function(){t._resolvePromiseDecorator(f.CLIPBOARD_WRITE,!0)})).catch((function(e){t._rejectPromiseDecorator(f.CLIPBOARD_WRITE,e)}))),r.promise}}])&&sr(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),d}(Wt);class Or extends Error{}function kr(e){return kr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},kr(e)}function Tr(e,t){for(var r=0;r{let r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return atob(t)}}(n)}catch(e){throw new Or(`Invalid token specified: invalid base64 for part #${r+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new Or(`Invalid token specified: invalid json for part #${r+1} (${e.message})`)}}(r);e._isPlayerAuthorized=!0,e._defaultStorageType=u.PLATFORM_INTERNAL,n.userId&&(e._playerId=n.userId),n.username&&(e._playerName=n.username),n.profilePictureUrl&&(e._playerPhotos=[n.profilePictureUrl]),t()})).catch((function(e){r(e)}))})):Promise.reject()}const Vr=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Rr(e,t)}(d,t);var r,n,o,p,y=(o=d,p=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Lr(o);if(p){var r=Lr(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===kr(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return jr(e)}(this,e)});function d(){var e,t,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,d);for(var n=arguments.length,o=new Array(n),s=0;s120?this._rejectPromiseDecorator(f.INVITE_FRIENDS,_):this._platformSdk.UI.showInvite(t)),r.promise}},{key:"rate",value:function(){var e=this._getPromiseDecorator(f.RATE);return e||(e=this._createPromiseDecorator(f.RATE),this._platformSdk.UI.showRatingDialog()),e.promise}},{key:"createPost",value:function(e){if(!e||null==e||!e.media)return Promise.reject();var t,r=this._getPromiseDecorator(f.CREATE_POST);return r||(r=this._createPromiseDecorator(f.CREATE_POST),this._platformSdk.UI.postMediatopic(e,null!==(t=e.status)&&void 0!==t&&t)),r.promise}},{key:"joinCommunity",value:function(e){if(!e||null==e||!e.groupId)return Promise.reject();var t,r=this._getPromiseDecorator(f.JOIN_COMMUNITY);return r||(r=this._createPromiseDecorator(f.JOIN_COMMUNITY),this._platformSdk.UI.joinGroup(e.groupId,null!==(t=e.enableMessages)&&void 0!==t&&t)),r.promise}}])&&Vn(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),l}(Wt);function Vo(e){return Vo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vo(e)}function Yo(e,t){for(var r=0;r