@everymatrix/casino-game-page 0.0.214 → 0.0.218

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-game-page",
3
- "version": "0.0.214",
3
+ "version": "0.0.218",
4
4
  "main": "dist/casino-game-page.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "504c889b442d1a70906bdb23ddaef68e256963b6"
39
+ "gitHead": "ae78406d20c106f1d3c352c0e97189a7bdffacfb"
40
40
  }
@@ -1,50 +1,57 @@
1
1
  <svelte:options tag={null} />
2
2
 
3
- <script lang="typescript">
3
+ <script lang="ts">
4
4
  import { onMount } from "svelte";
5
5
  import { isMobile, checkSession, getDevice } from 'rvhelper';
6
- import { _, addNewMessages } from './i18n';
6
+ import { _, addNewMessages, setupI18n } from './i18n';
7
7
  import { GamePageTranslations } from './translations';
8
8
 
9
+ // Native bridge
10
+ import {
11
+ isNative,
12
+ call as callNative,
13
+ registerEventListener as registerNativeEventListener,
14
+ } from 'js-native-bridge';
15
+
9
16
  import moment from 'moment';
10
17
 
11
- export let endpoint:String = '';
12
- export let datasource:String = '';
13
- export let lang:String = ''; // Language
14
- export let session:String = ''; // Value for sessionID
15
- export let userid:String = ''; // Value for UserID;
16
- export let clientstyling:String = '';
17
- export let clientstylingurl:String = '';
18
+ export let endpoint:string = '';
19
+ export let datasource:string = '';
20
+ export let lang:string = ''; // Language
21
+ export let session:string = ''; // Value for sessionID
22
+ export let userid:string = ''; // Value for UserID;
23
+ export let clientstyling:string = '';
24
+ export let clientstylingurl:string = '';
18
25
  export let favorites:string = '';
19
26
 
20
- export let loginurl:String = '';
21
- export let registerurl:String = '';
22
- export let depositurl:String = '';
23
- export let loginevent:String = '';
24
- export let registerevent:String = '';
25
- export let depositevent:String = '';
27
+ export let loginurl:string = '';
28
+ export let registerurl:string = '';
29
+ export let depositurl:string = '';
30
+ export let loginevent:string = '';
31
+ export let registerevent:string = '';
32
+ export let depositevent:string = '';
26
33
 
27
- export let clockformat:String = '';
28
- export let haspanicbutton:String = 'false';
34
+ export let clockformat:string = '';
35
+ export let haspanicbutton:string = 'false';
29
36
 
30
37
  let time:Object;
31
38
  let iframe:any;
32
39
 
33
- let isLoggedIn:Boolean = false;
34
- let hasErrors:Boolean = false;
35
- let isLoading:Boolean = true;
40
+ let isLoggedIn:boolean = false;
41
+ let hasErrors:boolean = false;
42
+ let isLoading:boolean = true;
36
43
 
37
- let playerID:String;
38
- let sessionID:String;
44
+ let playerID:string;
45
+ let sessionID:string;
39
46
 
40
47
  let game:any;
41
- let detailsObtained:Boolean = false;
42
- let funMode:Boolean = false;
43
- let anonymousFunMode:Boolean = false;
48
+ let detailsObtained:boolean = false;
49
+ let funMode:boolean = false;
50
+ let anonymousFunMode:boolean = false;
44
51
 
45
52
  let gameFrameContainer:HTMLElement;
46
53
  let gameInnerContainer:HTMLElement;
47
- let isFullscreen:Boolean = false;
54
+ let isFullscreen:boolean = false;
48
55
  let gameFrameCloseFullScreen:HTMLElement;
49
56
  let modalFrameWidth:number;
50
57
  let modalFrameHeight:number;
@@ -53,25 +60,31 @@
53
60
  let definitiveIframeWidth:string;
54
61
  let definitiveIframeHeight:string;
55
62
  let userAgent:any = window.navigator.userAgent;
56
- let mobileView:Boolean = false;
63
+ let mobileView:boolean = false;
57
64
  let favoriteGames: Array<Object> = [];
58
65
  let customStylingContainer:HTMLElement;
59
66
 
67
+ let isOnNative:boolean = false;
68
+
69
+ setupI18n({ withLocale: 'en', translations: {}});
70
+
60
71
  Object.keys(GamePageTranslations).forEach((item) => {
61
72
  addNewMessages(item, GamePageTranslations[item]);
62
73
  });
63
74
 
64
- const formatGameLaunchUrl = (game:any) => {
65
- let url:any = new URL(game.launchUrl);
75
+ // @TODO game typescript model type
76
+ const formatGameLaunchUrl = (game:any):void => {
77
+ let url:URL = new URL(game.launchUrl);
66
78
 
67
79
  url.searchParams.append('language', lang);
68
80
 
81
+ // @TODO wtf? session check or go home
69
82
  // Maybe we should check if the session is valid, somehow?
70
83
  if (sessionID && sessionID.length > 0) {
71
84
  isLoggedIn = true;
72
85
 
73
86
  url.searchParams.append('_sid', sessionID)
74
- url.searchParams.append('funMode', false)
87
+ url.searchParams.append('funMode', 'false')
75
88
  url.searchParams.append('language', lang)
76
89
  }
77
90
 
@@ -80,14 +93,15 @@
80
93
  return game;
81
94
  }
82
95
 
83
- const messageHandler = (e:any) => {
96
+ const messageHandler = (e:any):void => {
84
97
  switch (e.data.type) {
85
98
  case 'GameLaunchID':
86
- let url = new URL(`${endpoint}/casino/games/${e.data.gameId}`);
99
+ let url:URL = new URL(`${endpoint}/casino/games/${e.data.gameId}`);
87
100
 
88
101
  url.searchParams.append('language', lang);
102
+ url.searchParams.append('expand', 'game(vendor)');
89
103
 
90
- fetch(url)
104
+ fetch(url.href)
91
105
  .then((res:any) => res.json())
92
106
  .then((data:any) => {
93
107
  game = formatGameLaunchUrl(data[0]);
@@ -164,14 +178,10 @@
164
178
  favoriteGames = e.data.receivedFavoriteResults.items;
165
179
  }
166
180
  break;
167
-
168
- default:
169
- // Nothing to do here
170
- break;
171
181
  }
172
182
  }
173
183
 
174
- const checkFavorite = (gameId:string) => {
184
+ const checkFavorite = (gameId:string):boolean => {
175
185
  if (favoriteGames.findIndex(obj => obj.id == gameId) !== -1) {
176
186
  return true;
177
187
  } else {
@@ -179,7 +189,7 @@
179
189
  }
180
190
  }
181
191
 
182
- const toggleFavoriteGame = (id:any) => {
192
+ const toggleFavoriteGame = (id:any):void => {
183
193
  let triggerFactor = "gamepage";
184
194
 
185
195
  if (game.isFavored) {
@@ -191,12 +201,13 @@
191
201
  }
192
202
  }
193
203
 
194
- let openGameFrame = (gameId:string, gameFunMode:Boolean) => {
195
- let url = new URL(`${endpoint}/casino/games/${gameId}`);
204
+ const openGameFrame = (gameId:string, gameFunMode:boolean):void => {
205
+ let url:URL = new URL(`${endpoint}/casino/games/${gameId}`);
196
206
 
197
207
  url.searchParams.append('language', lang);
208
+ url.searchParams.append('expand', 'vendor');
198
209
 
199
- fetch(url)
210
+ fetch(url.href)
200
211
  .then((res:any) => res.json())
201
212
  .then((data:any) => {
202
213
  game = formatGameLaunchUrl(data[0]);
@@ -235,11 +246,21 @@
235
246
  definitiveIframeHeight = Math.floor(gameFrameHeight) + "px";
236
247
  }
237
248
 
238
- const openGameWindow = (game:any) => {
239
- window.open(game.launchUrl, '_blank');
249
+ const openGameWindow = (game:any):void => {
250
+ if (isOnNative) {
251
+ let data = {
252
+ url: game.launchUrl,
253
+ id: game.id,
254
+ vendor: game.vendor.name
255
+ }
256
+
257
+ callNative('OPEN_GAME', data);
258
+ } else {
259
+ window.open(game.launchUrl, '_blank');
260
+ }
240
261
  }
241
262
 
242
- const resizeHandler = () => {
263
+ const resizeHandler = ():void => {
243
264
  // sent to modal component a flag (detailsObtained) by witch to determine if a game is open
244
265
  window.postMessage({ type: 'GameStateOnResize', detailsObtained }, window.location.href);
245
266
  // make sure that a game is open before trying to get the element properties
@@ -252,36 +273,39 @@
252
273
  }
253
274
 
254
275
  // End section: keep aspect ratio for iframe on resize
255
- const toggleLogin = () => {
276
+ const toggleLogin = ():void => {
256
277
  if (loginevent) {
257
- window.postMessage({ type: loginevent, login: true }, window.location.href);
278
+ window.postMessage({ type: loginevent, transition: 'Login' }, window.location.href);
258
279
  window.postMessage({ type: 'ModalClosed' }, window.location.href);
259
280
  }
260
281
 
261
282
  if (loginurl) {
262
- window.location = loginUrl;
283
+ // @ts-ignore
284
+ window.location = loginurl;
263
285
  }
264
286
  }
265
287
 
266
- const toggleRegister = () => {
288
+ const toggleRegister = ():void => {
267
289
  if (registerevent) {
268
- window.postMessage({ type: registerevent, register: true }, window.location.href);
290
+ window.postMessage({ type: registerevent, transition: 'Register' }, window.location.href);
269
291
  window.postMessage({ type: 'ModalClosed' }, window.location.href);
270
292
  }
271
293
 
272
294
  if (registerurl) {
273
- window.location = registerUrl;
295
+ // @ts-ignore
296
+ window.location = registerurl;
274
297
  }
275
298
  }
276
299
 
277
- const toggleDeposit = () => {
300
+ const toggleDeposit = ():void => {
278
301
  if (depositevent) {
279
302
  window.postMessage({ type: depositevent }, window.location.href);
280
303
  window.postMessage({ type: 'ModalClosed' }, window.location.href);
281
304
  }
282
305
 
283
306
  if (depositurl) {
284
- window.location = depositUrl;
307
+ // @ts-ignore
308
+ window.location = depositurl;
285
309
  }
286
310
  }
287
311
 
@@ -327,11 +351,11 @@
327
351
  }
328
352
  }
329
353
 
330
- const PanicAction = () => {
354
+ const panicAction = ():void => {
331
355
  window.postMessage({ type: 'PanicButtonClicked' }, window.location.href);
332
356
  }
333
357
 
334
- const refreshTime = () => {
358
+ const refreshTime = ():void => {
335
359
  if (clockformat) {
336
360
  time = moment().format(clockformat);
337
361
  } else {
@@ -343,7 +367,7 @@
343
367
  refreshTime();
344
368
  }, 100);
345
369
 
346
- const initialSetup = () => {
370
+ const initialSetup = ():void => {
347
371
  isLoading = false;
348
372
 
349
373
  if (isMobile(userAgent)) {
@@ -351,7 +375,7 @@
351
375
  }
352
376
  }
353
377
 
354
- const setSession = () => {
378
+ const setSession = ():void => {
355
379
  checkSession(endpoint, session).then((res:any) => {
356
380
  sessionID = res.Guid;
357
381
  playerID = res.UserID;
@@ -362,17 +386,19 @@
362
386
  });
363
387
  }
364
388
 
365
- const setClientStyling = () => {
389
+ const setClientStyling = ():void => {
366
390
  let sheet = document.createElement('style');
367
391
  sheet.innerHTML = clientstyling;
368
392
  customStylingContainer.appendChild(sheet);
369
393
  }
370
394
 
371
- const setClientStylingURL = () => {
395
+ const setClientStylingURL = ():void => {
372
396
  let cssFile:HTMLElement = document.createElement('style');
373
397
 
374
398
  if (clientstylingurl) {
375
- fetch(new URL(clientstylingurl))
399
+ let url:URL = new URL(clientstylingurl);
400
+
401
+ fetch(url.href)
376
402
  .then((res:any) => res.text())
377
403
  .then((data:any) => {
378
404
  cssFile.innerHTML = data
@@ -388,6 +414,8 @@
388
414
  window.addEventListener('resize', resizeHandler, false);
389
415
  window.addEventListener('message', messageHandler, false);
390
416
 
417
+ isOnNative = !!isNative(userAgent);
418
+
391
419
  return () => {
392
420
  window.removeEventListener('resize', resizeHandler);
393
421
  window.removeEventListener('message', messageHandler);
@@ -447,7 +475,7 @@
447
475
  <svg class="w-1 h-1" fill="none" stroke="white" width="34px" height="34px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
448
476
  <p>{$_('gamePage.break')}</p>
449
477
  </div>
450
- <button class="Button" on:click={() => PanicAction()}>{$_('gamePage.breakButton')}</button>
478
+ <button class="Button" on:click={() => panicAction()}>{$_('gamePage.breakButton')}</button>
451
479
  </div>
452
480
  {/if}
453
481
  <p>{time}</p>
@@ -487,7 +515,7 @@
487
515
  <div class="PanicSection">
488
516
  <svg class="w-1 h-1" fill="none" stroke="white" width="34px" height="34px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
489
517
  <p>{$_('gamePage.break')}</p>
490
- <button class="Button" on:click={() => PanicAction()}>{$_('gamePage.breakButton')}</button>
518
+ <button class="Button" on:click={() => panicAction()}>{$_('gamePage.breakButton')}</button>
491
519
  </div>
492
520
  {/if}
493
521
  {#if isFullscreen}
package/src/i18n.js CHANGED
@@ -11,9 +11,7 @@ function setupI18n({ withLocale: _locale, translations }) {
11
11
  dictionary.set(translations);
12
12
  locale.set(_locale);
13
13
  }
14
- }); // maybe we will need this to make sure that the i18n is set up only once
15
- /*dictionary.set(translations);
16
- locale.set(_locale);*/
14
+ });
17
15
  }
18
16
 
19
17
  function addNewMessages(lang, dict) {
@@ -17,8 +17,8 @@ export const GamePageTranslations = {
17
17
  deposit: 'Einzahlung',
18
18
  playForFun: 'Play for fun',
19
19
  playNow: 'Jetzt starten!',
20
- break: 'Take 1 day break from playing',
21
- breakButton: '24-hour Cool Off',
20
+ break: 'Mach mal einen Tag Pause!',
21
+ breakButton: '24 Stunden Auszeit',
22
22
  }
23
23
  },
24
24
  it: {