@notix.games/react-bridge 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
package/index.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={216:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(733),t),o(r(757),t),o(r(965),t)},848:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.createIFrame=function(e){var t=e.eventHandler,r=e.context,a=e.React,i=e.src,u=e.gameId,c=e.style,l=e.customProps,s=a.createRef(),d=a.createElement("iframe",n({src:i,id:(0,o.createIFrameId)(u),style:c,ref:s},l)),f=function(e){var n;e.source===(null===(n=s.current)||void 0===n?void 0:n.contentWindow)&&(null==t||t(e,r))};return window.addEventListener("message",f,!1),{iframe:d,destructor:function(){window.removeEventListener("message",f,!1),function(){var e;try{(null===(e=null==r?void 0:r.getMetadata())||void 0===e?void 0:e.prevWindowTitle)?window.top.document.title=r.getMetadata().prevWindowTitle:window.localStorage.getItem("prevWindowTitle")?window.top.document.title=window.localStorage.getItem("prevWindowTitle"):window.top.document.title=""}catch(e){console.log("Error trying to set document title (KEEP CALM, for now it`s OK for iFrame-in-iFrame setting due to parent window security settings):",e)}}()},meta:{iframeRef:s}}};var o=r(707)},482:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(848),t)},388:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createIFrame=function(e){var t=e.src,r=e.gameId,o=e.style,a=e.eventHandler,i=e.context,u=e.customProps,c=document.createElement("iframe");for(var l in c.src=t,c.id=(0,n.createIFrameId)(r),o)if(l in c.style){var s=o[l];try{c.style.setProperty(l,"number"==typeof s?"".concat(s,"px"):s)}catch(e){console.error("Error setting style for ".concat(l,": "),e)}}for(var l in Object.keys(Object(u)))c.setAttribute(l,u[l]);var d=function(e){e.source===c.contentWindow&&(null==a||a(e,i))};return window.addEventListener("message",d,!1),{iframe:c,destructor:function(){window.removeEventListener("message",d,!1),function(){var e;try{(null===(e=null==i?void 0:i.getMetadata())||void 0===e?void 0:e.prevWindowTitle)?window.top.document.title=i.getMetadata().prevWindowTitle:window.localStorage.getItem("prevWindowTitle")?window.top.document.title=window.localStorage.getItem("prevWindowTitle"):window.top.document.title=""}catch(e){console.log("Error trying to set document title (KEEP CALM, for now it`s OK for iFrame-in-iFrame setting due to parent window security settings):",e)}}()},meta:{}}};var n=r(707)},278:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(388),t)},668:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NOTIX_BACKEND_BASE_URL_DEV=t.NOTIX_BACKEND_BASE_URL_STAGE=t.NOTIX_BACKEND_BASE_URL=t.IFRAME_GAME_ID_PREFIX=void 0,t.IFRAME_GAME_ID_PREFIX="notix_embedded_",t.NOTIX_BACKEND_BASE_URL="https://game-aggregator.stage.notix.games/external/api/v1",t.NOTIX_BACKEND_BASE_URL_STAGE="https://game-aggregator.stage.notix.games/external/api/v1",t.NOTIX_BACKEND_BASE_URL_DEV="https://game-aggregator.stage.notix.games/external/api/v1"},29:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function u(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,u)}c((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.iFrameCreators=void 0,t.initNotixBridge=function(e){var r,l=this,s=!1,p=null,v=e,h="prod",y=function(e){var t=e.token,n=e.partnerId,o=e.clientId,a=e.environment;if(!t||!n||!o)throw new Error("Not all required parameters are provided on Notix Bridge configuration.");r=t,p=n,a&&(h=a),s=!0};return{createIFrame:function(e){return function(e){return o(this,void 0,void 0,(function(){var o,c,l,y,g,b,w,m,_,I,P,O,A,E,M,S,j,T,x,G,R,U,k,W,N,F,B,D,L,C;return a(this,(function(a){switch(a.label){case 0:if(o=e.gameId,c=e.nodeId,l=e.player,y=e.browserSession,g=e.balance,b=e.eventHandler,w=e.customProps,m=e.style,_=l.id,I=l.country,P=y.viewType,O=y.language,A=y.timeZone,E=y.ip,M=g.currency,S=g.amount,!s)throw new Error("Notix Bridge is not configured. Please call the configure method first.");a.label=1;case 1:return a.trys.push([1,3,,4]),j=(0,i.v4)(),console.log("START GAME FROM BRIDGE: incomeParams: ",e,"startGameParams: ",{gameId:o,partnerId:p,nodeId:c,requestId:j,player:{id:_,country:I},browserSession:{language:O,viewType:P,timeZone:A,ip:E},balance:{currency:M,amount:S},partnerToken:r,env:h}),[4,(0,u.startGame)({gameId:o,partnerId:p,nodeId:c,requestId:j,player:{id:_,country:I},browserSession:{language:O,viewType:P,timeZone:A,ip:E},balance:{currency:M,amount:S},partnerToken:r,env:h})];case 2:if(T=a.sent(),x=T.iFrameURI,G=T.token,!x)throw new Error("No iFrame URI provided by the server.");if(!G)throw new Error("No player token provided by the server.");if(R={_playerToken:G,_iframe:null,_metadata:{},updateMetadata:function(e){this._metadata=Object.assign(this._metadata,e)},addPropertyToMetadata:function(e,t){this._metadata[e]=t},getMetadata:function(){return this._metadata},getPlayerToken:function(){return this._playerToken},getIframe:function(){return this._iframe},updatePlayerToken:function(e){this._playerToken=e},updateIframe:function(e){this._iframe=e}},U=(0,d.createEventMiddleware)(f.handleGPWebAppInit,f.handleGPWebAppSetPageLoaded,f.handleGPWebAppSetPageTitle,f.handleGPWebAppShowAuthenticationFailed,f.handleGPWebAppShowGameState)(b),k=null,"react"===v){if(!(W=e.React))throw new Error("React instance is not provided.");N={eventHandler:U,context:R,React:W,customProps:w,src:x,gameId:o,style:m},k=t.iFrameCreators.react(N)}else"vanilla"===v&&(F={eventHandler:U,customProps:w,context:R,src:x,gameId:o,style:m},k=t.iFrameCreators.vanilla(F));if(!k)throw new Error("No iFrame creator result.");return B=k.iframe,D=k.destructor,L=k.meta,R.updateIframe(B),R.updateMetadata(Object.assign(L,{framework:v})),[2,n({iframe:B,destructor:D},L)];case 3:return[2,{error:C=a.sent(),message:C.message}];case 4:return[2]}}))}))}(e)},configure:y,configureAsync:function(e){return o(l,[e],void 0,(function(e){var t=e.token,r=e.partnerId,n=e.clientId;return a(this,(function(e){return[2,new Promise((function(e,o){try{y({token:t,partnerId:r,clientId:n}),e()}catch(e){o(e)}}))]}))}))},getGames:function(){return o(l,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:if(t.trys.push([0,2,,3]),!s)throw new Error("Notix Bridge is not configured. Please call the configure method first.");return[4,(0,c.getGamesList)({partnerId:p,token:r,env:h})];case 1:return[2,t.sent()];case 2:return[2,{error:e=t.sent(),message:e.message}];case 3:return[2]}}))}))},getIFrameURI:function(e){return o(this,void 0,void 0,(function(){var t,n,o,c,l,d,f,v,y,g,b,w,m,_,I,P,O,A,E;return a(this,(function(a){switch(a.label){case 0:if(t=e.gameId,n=e.nodeId,o=e.player,c=e.browserSession,l=e.balance,d=e.sessionId,f=o.id,v=o.country,y=c.viewType,g=c.language,b=c.timeZone,w=c.ip,m=l.currency,_=l.amount,!s)throw new Error("Notix Bridge is not configured. Please call the configure method first.");a.label=1;case 1:return a.trys.push([1,3,,4]),I=(0,i.v4)(),console.log("🚀 ~ getIFrameURI ~ requestId:",I),[4,(0,u.startGame)({gameId:t,partnerId:p,nodeId:n,requestId:I,player:{id:f,country:v},browserSession:{language:g,viewType:y,timeZone:b,ip:w},balance:{currency:m,amount:_},partnerToken:r,env:h,sessionId:d})];case 2:if(P=a.sent(),O=P.iFrameURI,A=P.token,!O)throw new Error("No iFrame URI provided by the server.");if(!A)throw new Error("No player token provided by the server.");return[2,O];case 3:return[2,{error:E=a.sent(),message:E.message}];case 4:return[2]}}))}))}}};var i=r(935),u=r(74),c=r(410),l=r(482),s=r(278),d=r(707),f=r(720);t.iFrameCreators={react:l.createIFrame,vanilla:s.createIFrame}},720:(e,t)=>{function r(e){var t,r=e.getIframe(),n=e.getMetadata();return"react"===n.framework?null===(t=null==n?void 0:n.iframeRef)||void 0===t?void 0:t.current:r}Object.defineProperty(t,"__esModule",{value:!0}),t.handleGPWebAppShowGameState=t.handleGPWebAppShowAuthenticationFailed=t.handleGPWebAppSetPageTitle=t.handleGPWebAppSetPageLoaded=t.handleGPWebAppInit=void 0;t.handleGPWebAppInit=function(e,t,n){var o,a,i;if("GPWebAppInit"===e.data.type){var u=r(t);null===(o=null==u?void 0:u.contentWindow)||void 0===o||o.postMessage({type:"GPWebAppInitResult",data:{result:!0,requestId:null===(i=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.requestId}},"*")}n()};t.handleGPWebAppSetPageLoaded=function(e,t,n){"GPWebAppSetPageLoaded"===e.data.type&&r(t).contentWindow.postMessage({type:"GPWebAppSetPageLoadedResult",data:{result:!0,requestId:e.data.data.requestId}},"*");n()};t.handleGPWebAppSetPageTitle=function(e,t,n){try{var o=r(t);if("GPWebAppSetPageTitle"===e.data.type){var a=window.top.document.title;window.top.document.title=e.data.data.title,t.addPropertyToMetadata("prevWindowTitle",a),window.localStorage.setItem("prevWindowTitle",a),o.contentWindow.postMessage({type:"GPWebAppSetPageTitleResult",data:{result:!0,requestId:e.data.data.requestId}},"*")}}catch(e){console.log("Error trying to read document title (KEEP CALM, for now it`s OK for iFrame-in-iFrame setting due to parent window security settings):",e)}n()};t.handleGPWebAppShowAuthenticationFailed=function(e,t,n){var o=r(t);"GPWebAppShowAuthenticationFailed"===e.data.type&&(console.log("AUTH FAIL",e.data.type,e),o.contentWindow.postMessage({type:"GPWebAppShowAuthenticationFailedResult",data:{result:!0,requestId:e.data.data.requestId,token:"NEW_TOKEN_WILL_BE_HERE"}},"*")),n()};t.handleGPWebAppShowGameState=function(e,t,n){var o=r(t);"GPWebAppShowGameState"===e.data.type&&o.contentWindow.postMessage({type:"GPWebAppShowGameStateResult",data:{result:!0,requestId:e.data.data.requestId}},"*"),n()}},733:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(29),t),o(r(287),t)},410:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function u(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,u)}c((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.getGamesList=void 0;var a=r(865),i=function(e,t,r){return n(void 0,void 0,void 0,(function(){var n,i,u;return o(this,(function(o){switch(o.label){case 0:return n=(0,a.default)(r),i="".concat(n,"/partners/games/list?partnerID=").concat(e),[4,fetch(i,{method:"GET",headers:{Authorization:"Bearer ".concat(t)}})];case 1:if(!(u=o.sent()).ok)throw new Error("Failed to fetch games list: Server responeded with status ".concat(u.status));return[2,u.json()]}}))}))};t.getGamesList=function(e){return n(void 0,[e],void 0,(function(e){var t=e.partnerId,r=e.token,n=e.env;return o(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,i(t,r,n)];case 1:return[2,e.sent()];case 2:throw e.sent();case 3:return[2]}}))}))}},74:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function u(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,u)}c((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.startGame=void 0;var a=r(865);t.startGame=function(e){return n(void 0,void 0,void 0,(function(){var t,r,n,i,u,c;return o(this,(function(o){switch(o.label){case 0:t=(0,a.default)(e.env),r="".concat(t,"/partners/games/start"),n=function(e){var t=e.gameId,r=e.nodeId,n=e.partnerId,o=e.requestId,a=e.player,i=e.browserSession,u=e.balance,c=e.sessionId;return{partnerId:n,requestId:o,gameId:t,nodeId:r,isTest:!0,player:{id:a.id,country:a.country},browserSession:{language:i.language,viewType:i.viewType,timeZone:i.timeZone,ip:i.ip},balance:{currency:u.currency,amount:u.amount},sessionId:c}}(e),i={method:"POST",headers:{Authorization:"Bearer ".concat(e.partnerToken),"Content-Type":"application/json"},body:JSON.stringify(n)},o.label=1;case 1:return o.trys.push([1,4,,5]),[4,fetch(r,i)];case 2:if(!(u=o.sent()).ok)throw new Error("Failed to start game: Server responded with status ".concat(u.status));return[4,u.json()];case 3:return c=o.sent(),[2,{iFrameURI:decodeURI(null==c?void 0:c.uri),token:null==c?void 0:c.sessionId}];case 4:throw o.sent();case 5:return[2]}}))}))}},287:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},355:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function u(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,u)}c((n=n.apply(e,t||[])).next())}))},n=this&&this.__generator||function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.createEventMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var o=this;return function(a,i){return r(o,void 0,void 0,(function(){var o,u=this;return n(this,(function(c){switch(c.label){case 0:o=function(c){return r(u,void 0,void 0,(function(){var u=this;return n(this,(function(l){switch(l.label){case 0:return c<e.length?[4,e[c](a,i,(function(){return r(u,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,o(c+1)];case 1:return e.sent(),[2]}}))}))}))]:[3,2];case 1:return l.sent(),[3,4];case 2:return[4,t(a)];case 3:l.sent(),l.label=4;case 4:return[2]}}))}))},c.label=1;case 1:return c.trys.push([1,3,,4]),[4,o(0)];case 2:return[2,c.sent()];case 3:throw c.sent();case 4:return[2]}}))}))}}}},865:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if("dev"===e)return n.NOTIX_BACKEND_BASE_URL_DEV;if("stage"===e)return n.NOTIX_BACKEND_BASE_URL_STAGE;if("prod"===e)return n.NOTIX_BACKEND_BASE_URL;throw new Error("Incorrect env identifier passed in getBaseURL in Bridge backend request. Could not find matching base url")};var n=r(668)},707:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.createIFrameId=function(e){return"".concat(a.IFRAME_GAME_ID_PREFIX).concat(e)};var a=r(668);o(r(355),t)},757:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NotixBridge=void 0;var n=(0,r(216).initNotixBridge)("react");t.NotixBridge=n},965:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VanillaNotixBridge=void 0;var n=(0,r(733).initNotixBridge)("vanilla");t.VanillaNotixBridge=n},935:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"NIL",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(t,"v1",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"v3",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(t,"v4",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(t,"v5",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(t,"validate",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(t,"version",{enumerable:!0,get:function(){return c.default}});var n=f(r(766)),o=f(r(532)),a=f(r(521)),i=f(r(10)),u=f(r(688)),c=f(r(687)),l=f(r(893)),s=f(r(750)),d=f(r(512));function f(e){return e&&e.__esModule?e:{default:e}}},391:(e,t)=>{function r(e){return 14+(e+64>>>9<<4)+1}function n(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function o(e,t,r,o,a,i){return n((u=n(n(t,e),n(o,i)))<<(c=a)|u>>>32-c,r);var u,c}function a(e,t,r,n,a,i,u){return o(t&r|~t&n,e,t,a,i,u)}function i(e,t,r,n,a,i,u){return o(t&n|r&~n,e,t,a,i,u)}function u(e,t,r,n,a,i,u){return o(t^r^n,e,t,a,i,u)}function c(e,t,r,n,a,i,u){return o(r^(t|~n),e,t,a,i,u)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=function(e){if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r)}return function(e){const t=[],r=32*e.length,n="0123456789abcdef";for(let o=0;o<r;o+=8){const r=e[o>>5]>>>o%32&255,a=parseInt(n.charAt(r>>>4&15)+n.charAt(15&r),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[r(t)-1]=t;let o=1732584193,l=-271733879,s=-1732584194,d=271733878;for(let t=0;t<e.length;t+=16){const r=o,f=l,p=s,v=d;o=a(o,l,s,d,e[t],7,-680876936),d=a(d,o,l,s,e[t+1],12,-389564586),s=a(s,d,o,l,e[t+2],17,606105819),l=a(l,s,d,o,e[t+3],22,-1044525330),o=a(o,l,s,d,e[t+4],7,-176418897),d=a(d,o,l,s,e[t+5],12,1200080426),s=a(s,d,o,l,e[t+6],17,-1473231341),l=a(l,s,d,o,e[t+7],22,-45705983),o=a(o,l,s,d,e[t+8],7,1770035416),d=a(d,o,l,s,e[t+9],12,-1958414417),s=a(s,d,o,l,e[t+10],17,-42063),l=a(l,s,d,o,e[t+11],22,-1990404162),o=a(o,l,s,d,e[t+12],7,1804603682),d=a(d,o,l,s,e[t+13],12,-40341101),s=a(s,d,o,l,e[t+14],17,-1502002290),l=a(l,s,d,o,e[t+15],22,1236535329),o=i(o,l,s,d,e[t+1],5,-165796510),d=i(d,o,l,s,e[t+6],9,-1069501632),s=i(s,d,o,l,e[t+11],14,643717713),l=i(l,s,d,o,e[t],20,-373897302),o=i(o,l,s,d,e[t+5],5,-701558691),d=i(d,o,l,s,e[t+10],9,38016083),s=i(s,d,o,l,e[t+15],14,-660478335),l=i(l,s,d,o,e[t+4],20,-405537848),o=i(o,l,s,d,e[t+9],5,568446438),d=i(d,o,l,s,e[t+14],9,-1019803690),s=i(s,d,o,l,e[t+3],14,-187363961),l=i(l,s,d,o,e[t+8],20,1163531501),o=i(o,l,s,d,e[t+13],5,-1444681467),d=i(d,o,l,s,e[t+2],9,-51403784),s=i(s,d,o,l,e[t+7],14,1735328473),l=i(l,s,d,o,e[t+12],20,-1926607734),o=u(o,l,s,d,e[t+5],4,-378558),d=u(d,o,l,s,e[t+8],11,-2022574463),s=u(s,d,o,l,e[t+11],16,1839030562),l=u(l,s,d,o,e[t+14],23,-35309556),o=u(o,l,s,d,e[t+1],4,-1530992060),d=u(d,o,l,s,e[t+4],11,1272893353),s=u(s,d,o,l,e[t+7],16,-155497632),l=u(l,s,d,o,e[t+10],23,-1094730640),o=u(o,l,s,d,e[t+13],4,681279174),d=u(d,o,l,s,e[t],11,-358537222),s=u(s,d,o,l,e[t+3],16,-722521979),l=u(l,s,d,o,e[t+6],23,76029189),o=u(o,l,s,d,e[t+9],4,-640364487),d=u(d,o,l,s,e[t+12],11,-421815835),s=u(s,d,o,l,e[t+15],16,530742520),l=u(l,s,d,o,e[t+2],23,-995338651),o=c(o,l,s,d,e[t],6,-198630844),d=c(d,o,l,s,e[t+7],10,1126891415),s=c(s,d,o,l,e[t+14],15,-1416354905),l=c(l,s,d,o,e[t+5],21,-57434055),o=c(o,l,s,d,e[t+12],6,1700485571),d=c(d,o,l,s,e[t+3],10,-1894986606),s=c(s,d,o,l,e[t+10],15,-1051523),l=c(l,s,d,o,e[t+1],21,-2054922799),o=c(o,l,s,d,e[t+8],6,1873313359),d=c(d,o,l,s,e[t+15],10,-30611744),s=c(s,d,o,l,e[t+6],15,-1560198380),l=c(l,s,d,o,e[t+13],21,1309151649),o=c(o,l,s,d,e[t+4],6,-145523070),d=c(d,o,l,s,e[t+11],10,-1120210379),s=c(s,d,o,l,e[t+2],15,718787259),l=c(l,s,d,o,e[t+9],21,-343485551),o=n(o,r),l=n(l,f),s=n(s,p),d=n(d,v)}return[o,l,s,d]}(function(e){if(0===e.length)return[];const t=8*e.length,n=new Uint32Array(r(t));for(let r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))};t.default=l},460:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};t.default=r},688:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default="00000000-0000-0000-0000-000000000000"},512:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=(n=r(893))&&n.__esModule?n:{default:n};var a=function(e){if(!(0,o.default)(e))throw TypeError("Invalid UUID");let t;const r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r};t.default=a},264:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},722:(e,t)=>{let r;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(!r&&(r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!r))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(n)};const n=new Uint8Array(16)},210:(e,t)=>{function r(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function n(e,t){return e<<t|e>>>32-t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e){const t=[1518500249,1859775393,2400959708,3395469782],o=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);const a=e.length/4+2,i=Math.ceil(a/16),u=new Array(i);for(let t=0;t<i;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];u[t]=r}u[i-1][14]=8*(e.length-1)/Math.pow(2,32),u[i-1][14]=Math.floor(u[i-1][14]),u[i-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<i;++e){const a=new Uint32Array(80);for(let t=0;t<16;++t)a[t]=u[e][t];for(let e=16;e<80;++e)a[e]=n(a[e-3]^a[e-8]^a[e-14]^a[e-16],1);let i=o[0],c=o[1],l=o[2],s=o[3],d=o[4];for(let e=0;e<80;++e){const o=Math.floor(e/20),u=n(i,5)+r(o,c,l,s)+d+t[o]+a[e]>>>0;d=s,s=l,l=n(c,30)>>>0,c=i,i=u}o[0]=o[0]+i>>>0,o[1]=o[1]+c>>>0,o[2]=o[2]+l>>>0,o[3]=o[3]+s>>>0,o[4]=o[4]+d>>>0}return[o[0]>>24&255,o[0]>>16&255,o[0]>>8&255,255&o[0],o[1]>>24&255,o[1]>>16&255,o[1]>>8&255,255&o[1],o[2]>>24&255,o[2]>>16&255,o[2]>>8&255,255&o[2],o[3]>>24&255,o[3]>>16&255,o[3]>>8&255,255&o[3],o[4]>>24&255,o[4]>>16&255,o[4]>>8&255,255&o[4]]};t.default=o},750:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.unsafeStringify=i;var n,o=(n=r(893))&&n.__esModule?n:{default:n};const a=[];for(let e=0;e<256;++e)a.push((e+256).toString(16).slice(1));function i(e,t=0){return a[e[t+0]]+a[e[t+1]]+a[e[t+2]]+a[e[t+3]]+"-"+a[e[t+4]]+a[e[t+5]]+"-"+a[e[t+6]]+a[e[t+7]]+"-"+a[e[t+8]]+a[e[t+9]]+"-"+a[e[t+10]]+a[e[t+11]]+a[e[t+12]]+a[e[t+13]]+a[e[t+14]]+a[e[t+15]]}var u=function(e,t=0){const r=i(e,t);if(!(0,o.default)(r))throw TypeError("Stringified UUID is invalid");return r};t.default=u},766:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=(n=r(722))&&n.__esModule?n:{default:n},a=r(750);let i,u,c=0,l=0;var s=function(e,t,r){let n=t&&r||0;const s=t||new Array(16);let d=(e=e||{}).node||i,f=void 0!==e.clockseq?e.clockseq:u;if(null==d||null==f){const t=e.random||(e.rng||o.default)();null==d&&(d=i=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==f&&(f=u=16383&(t[6]<<8|t[7]))}let p=void 0!==e.msecs?e.msecs:Date.now(),v=void 0!==e.nsecs?e.nsecs:l+1;const h=p-c+(v-l)/1e4;if(h<0&&void 0===e.clockseq&&(f=f+1&16383),(h<0||p>c)&&void 0===e.nsecs&&(v=0),v>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");c=p,l=v,u=f,p+=122192928e5;const y=(1e4*(268435455&p)+v)%4294967296;s[n++]=y>>>24&255,s[n++]=y>>>16&255,s[n++]=y>>>8&255,s[n++]=255&y;const g=p/4294967296*1e4&268435455;s[n++]=g>>>8&255,s[n++]=255&g,s[n++]=g>>>24&15|16,s[n++]=g>>>16&255,s[n++]=f>>>8|128,s[n++]=255&f;for(let e=0;e<6;++e)s[n+e]=d[e];return t||(0,a.unsafeStringify)(s)};t.default=s},532:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=a(r(449)),o=a(r(391));function a(e){return e&&e.__esModule?e:{default:e}}var i=(0,n.default)("v3",48,o.default);t.default=i},449:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=void 0,t.default=function(e,t,r){function n(e,n,i,u){var c;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}(e)),"string"==typeof n&&(n=(0,a.default)(n)),16!==(null===(c=n)||void 0===c?void 0:c.length))throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+e.length);if(l.set(n),l.set(e,n.length),l=r(l),l[6]=15&l[6]|t,l[8]=63&l[8]|128,i){u=u||0;for(let e=0;e<16;++e)i[u+e]=l[e];return i}return(0,o.unsafeStringify)(l)}try{n.name=e}catch(e){}return n.DNS=i,n.URL=u,n};var n,o=r(750),a=(n=r(512))&&n.__esModule?n:{default:n};const i="6ba7b810-9dad-11d1-80b4-00c04fd430c8";t.DNS=i;const u="6ba7b811-9dad-11d1-80b4-00c04fd430c8";t.URL=u},521:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i(r(460)),o=i(r(722)),a=r(750);function i(e){return e&&e.__esModule?e:{default:e}}var u=function(e,t,r){if(n.default.randomUUID&&!t&&!e)return n.default.randomUUID();const i=(e=e||{}).random||(e.rng||o.default)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=i[e];return t}return(0,a.unsafeStringify)(i)};t.default=u},10:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=a(r(449)),o=a(r(210));function a(e){return e&&e.__esModule?e:{default:e}}var i=(0,n.default)("v5",80,o.default);t.default=i},893:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=(n=r(264))&&n.__esModule?n:{default:n};var a=function(e){return"string"==typeof e&&o.default.test(e)};t.default=a},687:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=(n=r(893))&&n.__esModule?n:{default:n};var a=function(e){if(!(0,o.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)};t.default=a}},t={};var r=function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(757);module.exports=r})();
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@notix.games/react-bridge",
3
+ "version": "3.0.7",
4
+ "description": "Notix Games Bridge Module React Library",
5
+ "main": "./index.js",
6
+ "types": "./types/index.d.ts",
7
+ "files": [
8
+ "./index.js",
9
+ "./types"
10
+ ],
11
+ "license": "UNLICENSED",
12
+ "private": false,
13
+ "keywords": [],
14
+ "author": "Notix Games",
15
+ "dependencies": {
16
+ "uuid": "^9.0.1"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ }
21
+ }
@@ -0,0 +1,3 @@
1
+ export * from './src';
2
+ export * from './targets/react';
3
+ export * from './targets/vanilla';
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { CSSStyleProperties, GameId, MiddlewareContext } from '../../types';
3
+ export interface CreateIFrameProps {
4
+ eventHandler?: (event: MessageEvent, context: MiddlewareContext) => void;
5
+ customProps: {
6
+ [key: string]: any;
7
+ };
8
+ context: MiddlewareContext;
9
+ React: typeof React;
10
+ src: string;
11
+ gameId: GameId;
12
+ style: CSSStyleProperties;
13
+ }
14
+ export interface CreateIFrameResult {
15
+ iframe: React.ReactElement;
16
+ destructor: () => void;
17
+ meta: {
18
+ iframeRef: React.RefObject<HTMLIFrameElement>;
19
+ };
20
+ }
21
+ export declare function createIFrame({ eventHandler, context, React, src, gameId, style, customProps }: CreateIFrameProps): CreateIFrameResult;
@@ -0,0 +1 @@
1
+ export * from './createIFrame';
@@ -0,0 +1,16 @@
1
+ import { GameId, CSSStyleProperties, MiddlewareContext } from '../../types';
2
+ export interface CreateIFrameProps {
3
+ eventHandler?: (event: Event, context: MiddlewareContext) => void;
4
+ customProps: {
5
+ [key: string]: any;
6
+ };
7
+ context: MiddlewareContext;
8
+ src: string;
9
+ gameId: GameId;
10
+ style: CSSStyleProperties;
11
+ }
12
+ export declare function createIFrame({ src, gameId, style, eventHandler, context, customProps }: CreateIFrameProps): {
13
+ iframe: HTMLElement;
14
+ destructor: () => void;
15
+ meta: {};
16
+ };
@@ -0,0 +1 @@
1
+ export * from './createIFrame';
@@ -0,0 +1,9 @@
1
+ import { GameId } from '../../types';
2
+ interface CreateIFrameProps {
3
+ style: {
4
+ [key: string]: string;
5
+ };
6
+ gameId: GameId;
7
+ }
8
+ export declare function createIFrame({ style, gameId }: CreateIFrameProps): Promise<void>;
9
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const IFRAME_GAME_ID_PREFIX = "notix_embedded_";
2
+ export declare const NOTIX_BACKEND_BASE_URL = "https://game-aggregator.stage.notix.games/external/api/v1";
3
+ export declare const NOTIX_BACKEND_BASE_URL_STAGE = "https://game-aggregator.stage.notix.games/external/api/v1";
4
+ export declare const NOTIX_BACKEND_BASE_URL_DEV = "https://game-aggregator.stage.notix.games/external/api/v1";
@@ -0,0 +1,72 @@
1
+ import * as React from 'react';
2
+ import { ReactElement } from 'react';
3
+ import { GameId, CSSStyleProperties, Game, NodeId, ViewType, PlayerCountry, Language, Currency, PlayerId, env } from '../types';
4
+ import { CreateIFrameProps as ReactCreateIFrameProps } from '../adapters/react';
5
+ import { CreateIFrameProps as VanillaCreateIFrameProps } from '../adapters/vanilla';
6
+ export interface InitNotixBridgeParams {
7
+ token: string;
8
+ partnerId: string;
9
+ clientId: string;
10
+ environment?: env;
11
+ }
12
+ export type Framework = 'react' | 'vanilla';
13
+ export type iFrameCreatorsProps = ReactCreateIFrameProps | VanillaCreateIFrameProps;
14
+ export type IFrameCreators = {
15
+ [K in Framework]: (props: iFrameCreatorsProps) => {
16
+ iframe: ReactElement | HTMLElement;
17
+ destructor: () => void;
18
+ meta?: {
19
+ [key: string]: any;
20
+ };
21
+ };
22
+ };
23
+ export interface BaseIFrameParams {
24
+ gameId: GameId;
25
+ nodeId: NodeId;
26
+ player: {
27
+ id: PlayerId;
28
+ country: PlayerCountry;
29
+ };
30
+ browserSession: {
31
+ language: Language;
32
+ viewType: ViewType;
33
+ timeZone: number;
34
+ ip: string;
35
+ };
36
+ balance: {
37
+ currency: Currency;
38
+ amount: number;
39
+ };
40
+ style?: CSSStyleProperties;
41
+ eventHandler?: (event: Event) => void;
42
+ customProps?: {
43
+ [key: string]: any;
44
+ };
45
+ sessionId?: string;
46
+ }
47
+ export interface ReactIFrameParams extends BaseIFrameParams {
48
+ React: typeof React;
49
+ }
50
+ export interface VanillaIFrameParams extends BaseIFrameParams {
51
+ }
52
+ export type FrameworkIFrameParams<FW extends Framework> = FW extends 'vanilla' ? VanillaIFrameParams : ReactIFrameParams;
53
+ export interface BridgeMethodError {
54
+ error: Error;
55
+ message: string;
56
+ }
57
+ export interface getIframeResult<FW extends Framework> {
58
+ iframe: FW extends 'vanilla' ? HTMLElement : React.ReactElement;
59
+ destructor: () => void;
60
+ meta?: {
61
+ [key: string]: any;
62
+ };
63
+ }
64
+ export interface NotixBridgeInstance<FW extends Framework> {
65
+ createIFrame: (props: FrameworkIFrameParams<FW>) => Promise<Partial<getIframeResult<FW> & BridgeMethodError>>;
66
+ configure: (params: InitNotixBridgeParams) => void;
67
+ configureAsync: (params: InitNotixBridgeParams) => Promise<void>;
68
+ getGames: () => Promise<Partial<Game[] & BridgeMethodError>>;
69
+ getIFrameURI: (props: Omit<BaseIFrameParams, 'style'>) => Promise<string>;
70
+ }
71
+ export declare const iFrameCreators: IFrameCreators;
72
+ export declare function initNotixBridge<T extends Framework>(targetFramework: T): NotixBridgeInstance<T>;
@@ -0,0 +1,6 @@
1
+ import { MiddlewareContext } from '../types';
2
+ export declare const handleGPWebAppInit: (event: MessageEvent, context: MiddlewareContext, next: () => void) => void;
3
+ export declare const handleGPWebAppSetPageLoaded: (event: MessageEvent, context: MiddlewareContext, next: () => void) => void;
4
+ export declare const handleGPWebAppSetPageTitle: (event: MessageEvent, context: MiddlewareContext, next: () => void) => void;
5
+ export declare const handleGPWebAppShowAuthenticationFailed: (event: MessageEvent, context: MiddlewareContext, next: () => void) => void;
6
+ export declare const handleGPWebAppShowGameState: (event: MessageEvent, context: MiddlewareContext, next: () => void) => void;
@@ -0,0 +1,2 @@
1
+ export * from './core';
2
+ export * from './types';
@@ -0,0 +1,8 @@
1
+ import { Game, PartnerId, env } from '../types';
2
+ interface GetGamesListProps {
3
+ partnerId: PartnerId;
4
+ token: string;
5
+ env: env;
6
+ }
7
+ export declare const getGamesList: ({ partnerId, token, env }: GetGamesListProps) => Promise<Game[]>;
8
+ export {};
@@ -0,0 +1,33 @@
1
+ import { Currency, GameId, Language, NodeId, PartnerId, PlayerCountry, PlayerId, RequestId, ViewType, env } from '../types';
2
+ interface Player {
3
+ id: PlayerId;
4
+ country: PlayerCountry;
5
+ }
6
+ interface BrowserSession {
7
+ language: Language;
8
+ viewType: ViewType;
9
+ timeZone: number;
10
+ ip: string;
11
+ }
12
+ interface Balance {
13
+ currency: Currency;
14
+ amount: number;
15
+ }
16
+ interface StartGameProps {
17
+ gameId: GameId;
18
+ nodeId: NodeId;
19
+ partnerId: PartnerId;
20
+ requestId: RequestId;
21
+ player: Player;
22
+ browserSession: BrowserSession;
23
+ balance: Balance;
24
+ partnerToken: string;
25
+ env: env;
26
+ sessionId?: string;
27
+ }
28
+ interface StartGameResult {
29
+ iFrameURI: string;
30
+ token: string;
31
+ }
32
+ export declare const startGame: (props: StartGameProps) => Promise<StartGameResult>;
33
+ export {};
@@ -0,0 +1,35 @@
1
+ export type GameId = string;
2
+ export type PartnerId = string;
3
+ export type PlayerId = string;
4
+ export type NodeId = number;
5
+ export type RequestId = string;
6
+ export type PlayerCountry = string;
7
+ export type Language = string;
8
+ export type ViewType = 'desktop' | 'mobile';
9
+ export type Currency = string;
10
+ export type env = 'prod' | 'stage' | 'dev';
11
+ export interface Game {
12
+ id: GameId;
13
+ title: string;
14
+ type: string;
15
+ description: string;
16
+ }
17
+ export type CSSStyleProperties = Record<string, string | number>;
18
+ export interface MiddlewareContext {
19
+ _playerToken: string | null;
20
+ _iframe: React.ReactElement | HTMLElement | null;
21
+ _metadata: {
22
+ [key: string]: any;
23
+ };
24
+ getMetadata: () => {
25
+ [key: string]: any;
26
+ };
27
+ updateMetadata: (metadata: {
28
+ [key: string]: any;
29
+ }) => void;
30
+ addPropertyToMetadata: (key: string, value: any) => void;
31
+ getPlayerToken: () => string | null;
32
+ getIframe: () => React.ReactElement | HTMLElement | null;
33
+ updatePlayerToken: (token: string) => void;
34
+ updateIframe: (iframe: React.ReactElement | HTMLElement) => void;
35
+ }
@@ -0,0 +1,3 @@
1
+ export type EventMiddleware = (event: MessageEvent, context: any, next: () => Promise<void>) => void | Promise<void>;
2
+ export type EventHandler = (event: MessageEvent) => void | Promise<void>;
3
+ export declare function createEventMiddleware(...middlewares: EventMiddleware[]): (eventHandler: EventHandler) => (event: MessageEvent, context: any) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { env } from './../../src/types';
2
+ export default function getBaseURL(env: env): string;
@@ -0,0 +1,3 @@
1
+ import { GameId } from '../types';
2
+ export * from './createMiddleware';
3
+ export declare function createIFrameId(gameId: GameId): string;
@@ -0,0 +1,2 @@
1
+ declare const NotixBridge: import("../../index").NotixBridgeInstance<"react">;
2
+ export { NotixBridge };
@@ -0,0 +1,2 @@
1
+ declare const VanillaNotixBridge: import("../../src").NotixBridgeInstance<"vanilla">;
2
+ export { VanillaNotixBridge };