@jetthai/cuora 1.1.341-dev-1 → 1.1.341-dev-3

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.341-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-2...v1.1.341-dev-3) (2025-03-02)
6
+
7
+ ### [1.1.341-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-1...v1.1.341-dev-2) (2025-02-27)
8
+
5
9
  ### [1.1.341-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-dev-1) (2025-02-27)
6
10
 
7
11
  ### [1.1.341](https://github.com/jetthai/cuora-module/compare/v1.1.340...v1.1.341) (2025-02-25)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.341-dev-1",
3
+ "version": "1.1.341-dev-3",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/api/game.js CHANGED
@@ -100,4 +100,5 @@ export default {
100
100
  }),
101
101
  getFreeGameList: () => ({ method: 'get', url: 'activities/getFreeGameRewardList' }),
102
102
  getFreeGameReward: ({ activityNo, receiveNo }) => ({ method: 'post', url: 'activities/getFreeGameReward', params: { activityNo, receiveNo } }),
103
+ getV3GameInfo: ({ appSecret, gameCodes }) => ({ method: 'post', url: 'game/list/v3/gameInfo', params: { appSecret, gameCodes } }),
103
104
  }
@@ -430,7 +430,7 @@ export default function (request) {
430
430
  }),
431
431
  redirectTo3Party: async (context, event) => {
432
432
  const { provider, channel, subchannel, fc } = event.data
433
- const deviceTokenEnable = context.siteConfig?.dtVerify === '1'
433
+ const deviceTokenEnable = context.siteConfig?.dtVerify
434
434
 
435
435
  const dt = await getDeviceToken({
436
436
  fpToken,
@@ -513,7 +513,7 @@ export default function (request) {
513
513
  return await request.send(user.getUserInfo())
514
514
  },
515
515
  checkDeviceToken: async (context, event) => {
516
- const deviceTokenEnable = context.siteConfig?.dtVerify === '1'
516
+ const deviceTokenEnable = context.siteConfig?.dtVerify
517
517
  if (deviceTokenEnable) {
518
518
  const { exist } = await request.send(user.checkDt())
519
519
  if (!exist) {
@@ -17,7 +17,7 @@ export default function (request) {
17
17
  lineat: null,
18
18
  },
19
19
  loginMethods: {},
20
- forceValidation: '0',
20
+ forceValidation: false,
21
21
  urls: {
22
22
  widget: null,
23
23
  },
@@ -55,8 +55,8 @@ export default function (request) {
55
55
  target: 'fetching',
56
56
  cond: (context, event) => {
57
57
  const { siteConfig = {}, promotion = {}, selectedCrypto } = context
58
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
59
- return !!selectedCrypto && walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
58
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
59
+ return !!selectedCrypto && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
60
60
  },
61
61
  },
62
62
  { target: 'loaded' },
@@ -72,8 +72,8 @@ export default function (request) {
72
72
  target: 'fetching',
73
73
  cond: (context, event) => {
74
74
  const { siteConfig = {}, promotion = {} } = context
75
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
76
- return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
75
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
76
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
77
77
  },
78
78
  },
79
79
  { target: 'loaded' },
@@ -49,8 +49,8 @@ export default function (request) {
49
49
  target: 'fetching',
50
50
  cond: (context, event) => {
51
51
  const { siteConfig = {}, promotion = {}, selectedCard } = context
52
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
53
- return !!selectedCard && walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
52
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
53
+ return !!selectedCard && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
54
54
  },
55
55
  },
56
56
  { target: 'loaded' },
@@ -78,8 +78,8 @@ export default function (request) {
78
78
  actions: 'setCard',
79
79
  cond: (context, event) => {
80
80
  const { siteConfig = {}, promotion = {} } = context
81
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
82
- return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
81
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
82
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
83
83
  },
84
84
  },
85
85
  {
@@ -216,8 +216,8 @@ export default function (request) {
216
216
  actions: 'setCard',
217
217
  cond: (context, event) => {
218
218
  const { siteConfig = {}, promotion = {} } = context
219
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
220
- return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
219
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
220
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
221
221
  },
222
222
  },
223
223
  {
@@ -49,8 +49,8 @@ export default function (request) {
49
49
  target: 'fetching',
50
50
  cond: (context, event) => {
51
51
  const { siteConfig = {}, promotion = {}, selectedQrcode } = context
52
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
53
- return !!selectedQrcode && walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
52
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
53
+ return !!selectedQrcode && walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
54
54
  },
55
55
  },
56
56
  {
@@ -86,8 +86,8 @@ export default function (request) {
86
86
  actions: 'setQrcode',
87
87
  cond: (context, event) => {
88
88
  const { siteConfig = {}, promotion = {} } = context
89
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
90
- return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
89
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
90
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
91
91
  },
92
92
  },
93
93
  {
@@ -314,8 +314,8 @@ export default function (request) {
314
314
  actions: 'setQrcode',
315
315
  cond: (context, event) => {
316
316
  const { siteConfig = {}, promotion = {} } = context
317
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
318
- return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
317
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
318
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
319
319
  },
320
320
  },
321
321
  {
@@ -74,8 +74,8 @@ export default function (request) {
74
74
  target: 'fetching',
75
75
  cond: (context, event) => {
76
76
  const { siteConfig = {}, promotion = {} } = context
77
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
78
- return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
77
+ const { walletMode = '', bonusPreviewEnable } = siteConfig
78
+ return walletMode === '4' && bonusPreviewEnable && promotion.activityNo != 'none'
79
79
  },
80
80
  },
81
81
  { target: 'loaded' },
@@ -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: {
@@ -33,10 +37,19 @@ export default function () {
33
37
  },
34
38
  logout: {},
35
39
  deposit: {},
36
- unfinishedGame: {},
40
+ unfinishedGame: {
41
+ invoke: {
42
+ src: 'getGameInfo',
43
+ onDone: {
44
+ actions: 'setGame',
45
+ },
46
+ onError: {
47
+ target: 'unfinishedGame',
48
+ },
49
+ },
50
+ },
37
51
  freeGameSettle: {},
38
52
  freeGameGiveUp: {},
39
- // hall: {},
40
53
  },
41
54
  },
42
55
  },
@@ -58,6 +71,12 @@ export default function () {
58
71
  gameCode: context.error.extend.split(/_(.+)/)[1],
59
72
  }
60
73
  }),
74
+ setGame: assign((context, event) => {
75
+ const gameInfo = event.data
76
+ return {
77
+ game: gameInfo?.[0],
78
+ }
79
+ }),
61
80
  },
62
81
  guards: {
63
82
  isLogout: (context, event) => {
@@ -76,7 +95,12 @@ export default function () {
76
95
  return context.error.code === 'ERR_G125'
77
96
  },
78
97
  },
79
- services: {},
98
+ services: {
99
+ getGameInfo: async (context, event) => {
100
+ const { gameCode } = context
101
+ return await request.send(api.getV3GameInfo({ appSecret, gameCodes: [gameCode] }))
102
+ },
103
+ },
80
104
  }
81
105
  )
82
106
  }
@@ -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,35 @@ 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
+ { target: 'idle' },
26
+ ],
27
+ onError: {
28
+ target: 'idle',
29
+ },
30
+ },
31
+ },
32
+ checking: {
33
+ always: [{ target: 'combinning', cond: (context, event) => context.gameCodes?.length > 0 }, { target: 'idle' }],
34
+ },
35
+ combinning: {
36
+ invoke: {
37
+ src: 'getGameInfo',
17
38
  onDone: {
18
39
  target: 'idle',
19
- actions: 'setNavbar',
40
+ actions: 'combindGames',
20
41
  },
21
42
  onError: {
22
43
  target: 'idle',
@@ -34,6 +55,47 @@ export default function (request) {
34
55
  navbar: navbarConfig.settings,
35
56
  }
36
57
  }),
58
+ filterGameCodes: assign((context, event) => {
59
+ const { navbar = [] } = context
60
+ const gameCodes = navbar.reduce((acc, item) => {
61
+ if (item.type.toLowerCase() === 'game' && item.gameCode) {
62
+ acc.push(item.gameCode)
63
+ }
64
+ return acc
65
+ }, [])
66
+
67
+ return { gameCodes }
68
+ }),
69
+ combindGames: assign((context, event) => {
70
+ const gameInfo = event.data?.data || []
71
+ const { navbar = [] } = context
72
+ const combindNavBar = navbar.map((item) => {
73
+ if (item.type.toLowerCase() === 'game') {
74
+ const currentGame = gameInfo.find((game) => game.gameCode === item.gameCode)
75
+ return {
76
+ ...item,
77
+ ...currentGame,
78
+ }
79
+ } else {
80
+ return item
81
+ }
82
+ })
83
+
84
+ return {
85
+ navbar: combindNavBar,
86
+ }
87
+ }),
88
+ },
89
+ guards: {
90
+ haveGames: (context, event) => {
91
+ const { navbarConfig = {} } = event.data
92
+ const { settings = [] } = navbarConfig
93
+ if (settings?.length) {
94
+ return settings.some((item) => item.type.toLowerCase() === 'game')
95
+ } else {
96
+ return false
97
+ }
98
+ },
37
99
  },
38
100
  services: {
39
101
  fetchNavbar: async (context, event) => {
@@ -51,6 +113,10 @@ export default function (request) {
51
113
  )
52
114
  return { navbarConfig: JSON.parse(decodeResult) }
53
115
  },
116
+ getGameInfo: async (context, event) => {
117
+ const { gameCodes } = context
118
+ return await request.send(game.getV3GameInfo({ appSecret, gameCodes }))
119
+ },
54
120
  },
55
121
  }
56
122
  )