@jetthai/cuora 1.1.341-dev-2 → 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 +2 -0
- package/package.json +1 -1
- package/src/api/game.js +1 -0
- package/src/machine/error.js +28 -4
- package/src/machine/navbar.js +68 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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
|
+
|
|
5
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)
|
|
6
8
|
|
|
7
9
|
### [1.1.341-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-dev-1) (2025-02-27)
|
package/package.json
CHANGED
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
|
}
|
package/src/machine/error.js
CHANGED
|
@@ -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
|
}
|
package/src/machine/navbar.js
CHANGED
|
@@ -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:
|
|
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: '
|
|
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
|
)
|