@jetthai/cuora 1.1.346-dev-2 → 1.1.346-dev-4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.346-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.346-ranking-1...v1.1.346-dev-4) (2025-04-02)
6
+
7
+ ### [1.1.346-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-2...v1.1.346-dev-3) (2025-03-30)
8
+
9
+ ### [1.1.346-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-1...v1.1.346-dev-2) (2025-03-28)
10
+
11
+ ### [1.1.346-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.346...v1.1.346-dev-1) (2025-03-28)
12
+
13
+ ### [1.1.346-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-2...v1.1.346-dev-3) (2025-03-30)
14
+
5
15
  ### [1.1.346-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.346-dev-1...v1.1.346-dev-2) (2025-03-28)
6
16
 
7
17
  ### [1.1.346-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.346...v1.1.346-dev-1) (2025-03-28)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.346-dev-2",
3
+ "version": "1.1.346-dev-4",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/api/game.js CHANGED
@@ -1,7 +1,4 @@
1
1
  export default {
2
- getGameSHA: () => ({ method: 'get', url: 'game/list/v2/sha' }),
3
- getOptionMap: (code) => ({ method: 'get', url: 'game/list/v2/options', params: { code } }),
4
- getGameStatus: () => ({ method: 'get', url: 'game/list/v2/status' }),
5
2
  getGameCategory: ({ id, first } = {}) => ({ method: 'get', url: 'game/list/v2/category', params: { id, first } }),
6
3
  addFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/add', params: { games: [code] } }),
7
4
  removeFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/remove', params: { games: [code] } }),
@@ -100,4 +97,5 @@ export default {
100
97
  }),
101
98
  getFreeGameList: () => ({ method: 'get', url: 'activities/getFreeGameRewardList' }),
102
99
  getFreeGameReward: ({ activityNo, receiveNo }) => ({ method: 'post', url: 'activities/getFreeGameReward', params: { activityNo, receiveNo } }),
100
+ getV3GameInfo: ({ appSecret, gameCodes }) => ({ method: 'post', url: 'game/list/v3/gameInfo', params: { appSecret, gameCodes } }),
103
101
  }
@@ -292,8 +292,12 @@ export default function (request) {
292
292
  return { announcementList: { data } }
293
293
  }),
294
294
  setFeeds: assign((context, event) => {
295
- const { announcementList, broadcastList, mailBoxInfo } = event.data
295
+ const { announcementList, broadcastList, mailBoxInfo, siteConfig } = event.data
296
296
  const promotions = announcementList?.announcements?.filter?.((item) => item.category === 3) || []
297
+ const customerMessageEnable = siteConfig?.csChat?.some((item) => item.enable && item.name === 'customermessage')
298
+ if (!customerMessageEnable) {
299
+ mailBoxInfo.rows -= mailBoxInfo.detailRows.CUSTOMER || 0
300
+ }
297
301
  return { broadcastList, mailBoxInfo, promotions }
298
302
  }),
299
303
  setBroadcast: assign((context, event) => {
@@ -1,6 +1,9 @@
1
1
  import { assign, createMachine } from 'xstate'
2
+ import api from '../api/game.js'
3
+
4
+ export default function (request) {
5
+ const { appSecret } = request.config
2
6
 
3
- export default function () {
4
7
  return createMachine(
5
8
  {
6
9
  id: 'error',
@@ -8,6 +11,7 @@ export default function () {
8
11
  context: {
9
12
  error: null,
10
13
  gameCode: null,
14
+ game: null,
11
15
  },
12
16
  states: {
13
17
  normal: {
@@ -28,15 +32,23 @@ export default function () {
28
32
  { target: 'unfinishedGame', cond: 'isUnfinishedGame', actions: 'setUnfinishedGame' },
29
33
  { target: 'freeGameSettle', cond: 'isFreeGameSettle' },
30
34
  { target: 'freeGameGiveUp', cond: 'isFreeGameGiveUp' },
31
- // { target: 'hall' },
32
35
  ],
33
36
  },
34
37
  logout: {},
35
38
  deposit: {},
36
- unfinishedGame: {},
39
+ unfinishedGame: {
40
+ invoke: {
41
+ src: 'getGameInfo',
42
+ onDone: {
43
+ actions: 'setGame',
44
+ },
45
+ onError: {
46
+ target: 'unfinishedGame',
47
+ },
48
+ },
49
+ },
37
50
  freeGameSettle: {},
38
51
  freeGameGiveUp: {},
39
- // hall: {},
40
52
  },
41
53
  },
42
54
  },
@@ -58,6 +70,12 @@ export default function () {
58
70
  gameCode: context.error.extend.split(/_(.+)/)[1],
59
71
  }
60
72
  }),
73
+ setGame: assign((context, event) => {
74
+ const { data = [] } = event.data
75
+ return {
76
+ game: data?.[0],
77
+ }
78
+ }),
61
79
  },
62
80
  guards: {
63
81
  isLogout: (context, event) => {
@@ -76,7 +94,12 @@ export default function () {
76
94
  return context.error.code === 'ERR_G125'
77
95
  },
78
96
  },
79
- services: {},
97
+ services: {
98
+ getGameInfo: async (context, event) => {
99
+ const { gameCode } = context
100
+ return await request.send(api.getV3GameInfo({ appSecret, gameCodes: [gameCode] }))
101
+ },
102
+ },
80
103
  }
81
104
  )
82
105
  }
@@ -49,7 +49,6 @@ export default function (request) {
49
49
  gameWalletType: null,
50
50
  switchGame: null,
51
51
  isPlaying: false,
52
- ...oldContext,
53
52
  },
54
53
  states: {
55
54
  flow: {
@@ -207,7 +206,6 @@ export default function (request) {
207
206
  actions: ['setIsPlaying', 'resetContent', 'resetSHA'],
208
207
  },
209
208
  LEAVE_GAME_REFRESH: {
210
- target: '#game.oldTimer',
211
209
  actions: 'setIsPlaying',
212
210
  },
213
211
  },
@@ -286,63 +284,6 @@ export default function (request) {
286
284
  },
287
285
  },
288
286
  },
289
- oldTimer: {
290
- initial: 'fetchingGameSHA',
291
- states: {
292
- fetchingGameSHA: {
293
- invoke: {
294
- src: 'fetchGameSHA',
295
- onDone: {
296
- target: 'checking',
297
- actions: 'setGameSHA',
298
- },
299
- onError: {
300
- target: 'pending',
301
- },
302
- },
303
- },
304
- checking: {
305
- always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
306
- },
307
- updatingStatus: {
308
- invoke: {
309
- src: 'fetchStatus',
310
- onDone: {
311
- target: 'updatingOption',
312
- actions: ['setStatus'],
313
- },
314
- onError: {
315
- target: 'pending',
316
- },
317
- },
318
- },
319
- updatingOption: {
320
- invoke: {
321
- src: 'fetchOption',
322
- onDone: {
323
- target: 'pending',
324
- actions: 'mergeOption',
325
- },
326
- onError: {
327
- target: 'pending',
328
- },
329
- },
330
- },
331
- pending: {
332
- after: {
333
- 20000: [
334
- {
335
- target: 'fetchingGameSHA',
336
- cond: 'isNotInGame',
337
- },
338
- {
339
- target: 'pending',
340
- },
341
- ],
342
- },
343
- },
344
- },
345
- },
346
287
  },
347
288
  },
348
289
  {
@@ -459,9 +400,6 @@ export default function (request) {
459
400
  return event.data.gameWalletType
460
401
  },
461
402
  }),
462
- clearGameInfo: assign((context, event) => {
463
- return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
464
- }),
465
403
  setGameInfo: assign((context, event) => {
466
404
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = event.data.game
467
405
  return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
@@ -495,7 +433,6 @@ export default function (request) {
495
433
  isPlaying: event.data,
496
434
  }
497
435
  }),
498
- ...oldActions,
499
436
  },
500
437
  guards: {
501
438
  isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
@@ -504,13 +441,9 @@ export default function (request) {
504
441
  // 是否有下一頁
505
442
  return loadable && !isLastPage
506
443
  },
507
- isNotInGame: (context, event) => {
508
- return !context.isPlaying
509
- },
510
444
  hasRoomAndIsNotInGame: (context, event) => {
511
445
  return context.room?.categoryId && !context.isPlaying
512
446
  },
513
- ...oldGuards,
514
447
  },
515
448
  services: {
516
449
  batchFetch: async (context, event) => {
@@ -638,75 +571,7 @@ export default function (request) {
638
571
  const provider_id = context.game.providerId
639
572
  return await request.send(api.logoutGame({ uid_site, provider_id }))
640
573
  },
641
- ...oldServices(request),
642
574
  },
643
575
  }
644
576
  )
645
577
  }
646
-
647
- const oldContext = {
648
- sha: {
649
- status: null,
650
- },
651
- isStatusChanged: false,
652
- statusMap: {},
653
- optionMap: {},
654
- }
655
-
656
- const oldActions = {
657
- setGameSHA: assign((context, event) => {
658
- const { sha } = context
659
- const newSha = event.data
660
- return {
661
- sha: newSha,
662
- isStatusChanged: !sha.status || sha.status !== newSha.status,
663
- }
664
- }),
665
- setStatus: assign((context, event) => {
666
- return {
667
- statusMap: event.data,
668
- }
669
- }),
670
- mergeOption: assign((context, event) => {
671
- const { optionMap } = context
672
- return {
673
- optionMap: { ...optionMap, ...event.data },
674
- }
675
- }),
676
- resetSHA: assign((context, event) => {
677
- return {
678
- sha: {
679
- status: null,
680
- },
681
- isStatusChanged: false,
682
- statusMap: {},
683
- optionMap: {},
684
- }
685
- }),
686
- }
687
-
688
- const oldGuards = {
689
- isStatusChanged: (context, event) => context.isStatusChanged,
690
- }
691
-
692
- const oldServices = (request) => ({
693
- fetchOption: async (context, event) => {
694
- if (request.getToken()) {
695
- return await request.send(api.getOptionMap())
696
- }
697
- },
698
- fetchGameSHA: async (context, event) => {
699
- if (request.getToken()) {
700
- return await request.send(api.getGameSHA())
701
- } else {
702
- return {
703
- status: null,
704
- }
705
- }
706
- },
707
- fetchStatus: async (context, event) => {
708
- if (request.getToken()) {
709
- return await request.send(api.getGameStatus())
710
- }
711
- },
712
- })
@@ -39,7 +39,7 @@ import honor_board from './honor_board.js'
39
39
  import user_photo from './user_photo.js'
40
40
  import navbar from './navbar.js'
41
41
  import websocket from './websocket.js'
42
- import dragon_tiger_ranking from './dragon_tiger_ranking.js'
42
+ import ranking from './ranking.js'
43
43
 
44
44
  export default {
45
45
  ...activity,
@@ -83,5 +83,5 @@ export default {
83
83
  navbar,
84
84
  ...withdraw,
85
85
  websocket,
86
- dragon_tiger_ranking,
86
+ ranking,
87
87
  }
@@ -1,5 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import common from '../api/common.js'
3
+ import game from '../api/game.js'
3
4
 
4
5
  export default function (request) {
5
6
  const { appSecret } = request.config
@@ -8,15 +9,38 @@ export default function (request) {
8
9
  id: 'navbar',
9
10
  initial: 'fetching',
10
11
  context: {
11
- navbar: null,
12
+ navbar: [],
13
+ gameCodes: [],
12
14
  },
13
15
  states: {
14
16
  fetching: {
15
17
  invoke: {
16
18
  src: 'fetchNavbar',
19
+ onDone: [
20
+ {
21
+ target: 'checking',
22
+ actions: ['setNavbar', 'filterGameCodes'],
23
+ cond: 'haveGames',
24
+ },
25
+ {
26
+ target: 'idle',
27
+ actions: 'setNavbar',
28
+ },
29
+ ],
30
+ onError: {
31
+ target: 'idle',
32
+ },
33
+ },
34
+ },
35
+ checking: {
36
+ always: [{ target: 'combinning', cond: (context, event) => context.gameCodes?.length > 0 }, { target: 'idle' }],
37
+ },
38
+ combinning: {
39
+ invoke: {
40
+ src: 'getGameInfo',
17
41
  onDone: {
18
42
  target: 'idle',
19
- actions: 'setNavbar',
43
+ actions: 'combindGames',
20
44
  },
21
45
  onError: {
22
46
  target: 'idle',
@@ -34,6 +58,47 @@ export default function (request) {
34
58
  navbar: navbarConfig.settings,
35
59
  }
36
60
  }),
61
+ filterGameCodes: assign((context, event) => {
62
+ const { navbar = [] } = context
63
+ const gameCodes = navbar.reduce((acc, item) => {
64
+ if (item.type.toLowerCase() === 'game' && item.gameCode) {
65
+ acc.push(item.gameCode)
66
+ }
67
+ return acc
68
+ }, [])
69
+
70
+ return { gameCodes }
71
+ }),
72
+ combindGames: assign((context, event) => {
73
+ const gameInfo = event.data?.data || []
74
+ const { navbar = [] } = context
75
+ const combindNavBar = navbar.map((item) => {
76
+ if (item.type.toLowerCase() === 'game') {
77
+ const currentGame = gameInfo.find((game) => game.gameCode === item.gameCode)
78
+ return {
79
+ ...item,
80
+ ...currentGame,
81
+ }
82
+ } else {
83
+ return item
84
+ }
85
+ })
86
+
87
+ return {
88
+ navbar: combindNavBar,
89
+ }
90
+ }),
91
+ },
92
+ guards: {
93
+ haveGames: (context, event) => {
94
+ const { navbarConfig = {} } = event.data
95
+ const { settings = [] } = navbarConfig
96
+ if (settings?.length) {
97
+ return settings.some((item) => item.type.toLowerCase() === 'game')
98
+ } else {
99
+ return false
100
+ }
101
+ },
37
102
  },
38
103
  services: {
39
104
  fetchNavbar: async (context, event) => {
@@ -51,6 +116,10 @@ export default function (request) {
51
116
  )
52
117
  return { navbarConfig: JSON.parse(decodeResult) }
53
118
  },
119
+ getGameInfo: async (context, event) => {
120
+ const { gameCodes } = context
121
+ return await request.send(game.getV3GameInfo({ appSecret, gameCodes }))
122
+ },
54
123
  },
55
124
  }
56
125
  )
@@ -20,7 +20,7 @@ export default function (request) {
20
20
 
21
21
  return createMachine(
22
22
  {
23
- id: 'dragon_tiger_ranking',
23
+ id: 'ranking',
24
24
  initial: 'idle',
25
25
  context: {
26
26
  auth: false,