@jetthai/cuora 1.1.346 → 1.1.348

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,10 @@
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.348](https://github.com/jetthai/cuora-module/compare/v1.1.347...v1.1.348) (2025-03-30)
6
+
7
+ ### [1.1.347](https://github.com/jetthai/cuora-module/compare/v1.1.346...v1.1.347) (2025-03-30)
8
+
5
9
  ### [1.1.346](https://github.com/jetthai/cuora-module/compare/v1.1.345...v1.1.346) (2025-03-27)
6
10
 
7
11
  ### [1.1.345](https://github.com/jetthai/cuora-module/compare/v1.1.344...v1.1.345) (2025-03-25)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.346",
3
+ "version": "1.1.348",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/resetGitBranch.sh CHANGED
@@ -59,4 +59,46 @@ git branch --set-upstream-to=origin/dev dev
59
59
  if [ $? -ne 0 ]; then
60
60
  echo "設定 dev 分支的上游分支為 origin/dev 失敗"
61
61
  exit 1
62
+ fi
63
+
64
+ # 切換到 master 分支
65
+ git checkout master
66
+ if [ $? -ne 0 ]; then
67
+ echo "切換到 master 分支失敗"
68
+ exit 1
69
+ fi
70
+
71
+ # 刪除本地的 qa 分支
72
+ git branch -D qa
73
+ if [ $? -ne 0 ]; then
74
+ echo "刪除本地 qa 分支失敗"
75
+ exit 1
76
+ fi
77
+
78
+ # 刪除遠端的 qa 分支
79
+ git push origin --delete qa
80
+ if [ $? -ne 0 ]; then
81
+ echo "刪除遠端 qa 分支失敗"
82
+ exit 1
83
+ fi
84
+
85
+ # 建立並切換到新的 qa 分支
86
+ git checkout -b qa
87
+ if [ $? -ne 0 ]; then
88
+ echo "建立並切換到新的 qa 分支失敗"
89
+ exit 1
90
+ fi
91
+
92
+ # 強制推送新的 qa 分支到遠端
93
+ git push -f origin qa
94
+ if [ $? -ne 0 ]; then
95
+ echo "強制推送新的 qa 分支到遠端失敗"
96
+ exit 1
97
+ fi
98
+
99
+ # 設定 qa 分支的上游分支為 origin/qa
100
+ git branch --set-upstream-to=origin/qa qa
101
+ if [ $? -ne 0 ]; then
102
+ echo "設定 qa 分支的上游分支為 origin/qa 失敗"
103
+ exit 1
62
104
  fi
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
  }
@@ -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
  },
@@ -282,63 +280,6 @@ export default function (request) {
282
280
  },
283
281
  },
284
282
  },
285
- oldTimer: {
286
- initial: 'fetchingGameSHA',
287
- states: {
288
- fetchingGameSHA: {
289
- invoke: {
290
- src: 'fetchGameSHA',
291
- onDone: {
292
- target: 'checking',
293
- actions: 'setGameSHA',
294
- },
295
- onError: {
296
- target: 'pending',
297
- },
298
- },
299
- },
300
- checking: {
301
- always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
302
- },
303
- updatingStatus: {
304
- invoke: {
305
- src: 'fetchStatus',
306
- onDone: {
307
- target: 'updatingOption',
308
- actions: ['setStatus'],
309
- },
310
- onError: {
311
- target: 'pending',
312
- },
313
- },
314
- },
315
- updatingOption: {
316
- invoke: {
317
- src: 'fetchOption',
318
- onDone: {
319
- target: 'pending',
320
- actions: 'mergeOption',
321
- },
322
- onError: {
323
- target: 'pending',
324
- },
325
- },
326
- },
327
- pending: {
328
- after: {
329
- 20000: [
330
- {
331
- target: 'fetchingGameSHA',
332
- cond: 'isNotInGame',
333
- },
334
- {
335
- target: 'pending',
336
- },
337
- ],
338
- },
339
- },
340
- },
341
- },
342
283
  },
343
284
  },
344
285
  {
@@ -455,9 +396,6 @@ export default function (request) {
455
396
  return event.data.gameWalletType
456
397
  },
457
398
  }),
458
- clearGameInfo: assign((context, event) => {
459
- return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
460
- }),
461
399
  setGameInfo: assign((context, event) => {
462
400
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = event.data.game
463
401
  return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
@@ -491,7 +429,6 @@ export default function (request) {
491
429
  isPlaying: event.data,
492
430
  }
493
431
  }),
494
- ...oldActions,
495
432
  },
496
433
  guards: {
497
434
  isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
@@ -500,13 +437,9 @@ export default function (request) {
500
437
  // 是否有下一頁
501
438
  return loadable && !isLastPage
502
439
  },
503
- isNotInGame: (context, event) => {
504
- return !context.isPlaying
505
- },
506
440
  hasRoomAndIsNotInGame: (context, event) => {
507
441
  return context.room?.categoryId && !context.isPlaying
508
442
  },
509
- ...oldGuards,
510
443
  },
511
444
  services: {
512
445
  batchFetch: async (context, event) => {
@@ -634,75 +567,7 @@ export default function (request) {
634
567
  const provider_id = context.game.providerId
635
568
  return await request.send(api.logoutGame({ uid_site, provider_id }))
636
569
  },
637
- ...oldServices(request),
638
570
  },
639
571
  }
640
572
  )
641
573
  }
642
-
643
- const oldContext = {
644
- sha: {
645
- status: null,
646
- },
647
- isStatusChanged: false,
648
- statusMap: {},
649
- optionMap: {},
650
- }
651
-
652
- const oldActions = {
653
- setGameSHA: assign((context, event) => {
654
- const { sha } = context
655
- const newSha = event.data
656
- return {
657
- sha: newSha,
658
- isStatusChanged: !sha.status || sha.status !== newSha.status,
659
- }
660
- }),
661
- setStatus: assign((context, event) => {
662
- return {
663
- statusMap: event.data,
664
- }
665
- }),
666
- mergeOption: assign((context, event) => {
667
- const { optionMap } = context
668
- return {
669
- optionMap: { ...optionMap, ...event.data },
670
- }
671
- }),
672
- resetSHA: assign((context, event) => {
673
- return {
674
- sha: {
675
- status: null,
676
- },
677
- isStatusChanged: false,
678
- statusMap: {},
679
- optionMap: {},
680
- }
681
- }),
682
- }
683
-
684
- const oldGuards = {
685
- isStatusChanged: (context, event) => context.isStatusChanged,
686
- }
687
-
688
- const oldServices = (request) => ({
689
- fetchOption: async (context, event) => {
690
- if (request.getToken()) {
691
- return await request.send(api.getOptionMap())
692
- }
693
- },
694
- fetchGameSHA: async (context, event) => {
695
- if (request.getToken()) {
696
- return await request.send(api.getGameSHA())
697
- } else {
698
- return {
699
- status: null,
700
- }
701
- }
702
- },
703
- fetchStatus: async (context, event) => {
704
- if (request.getToken()) {
705
- return await request.send(api.getGameStatus())
706
- }
707
- },
708
- })
@@ -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
  )