@jetthai/cuora 1.1.343-dev-4 → 1.1.343-dev-5
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 +7 -119
- package/package.json +1 -1
- package/src/api/game.js +3 -1
- package/src/machine/error.js +5 -28
- package/src/machine/game_v2_1.js +135 -0
- package/src/machine/navbar.js +2 -68
- package/src/machine/websocket.js +14 -18
package/CHANGELOG.md
CHANGED
|
@@ -2,131 +2,19 @@
|
|
|
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.343-dev-
|
|
6
|
-
|
|
7
|
-
### [1.1.343-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-6...v1.1.343-dev-3) (2025-03-13)
|
|
8
|
-
|
|
9
|
-
### [1.1.343-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-5...v1.1.343-dev-2) (2025-03-13)
|
|
10
|
-
|
|
11
|
-
### [1.1.343-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-12...v1.1.343-dev-1) (2025-03-13)
|
|
12
|
-
|
|
13
|
-
### [1.1.341-dev-12](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-4...v1.1.341-dev-12) (2025-03-12)
|
|
14
|
-
|
|
15
|
-
### [1.1.341-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-10...v1.1.341-dev-11) (2025-03-11)
|
|
16
|
-
|
|
17
|
-
### [1.1.341-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.343...v1.1.341-dev-10) (2025-03-11)
|
|
18
|
-
|
|
19
|
-
### [1.1.343](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-9...v1.1.343) (2025-03-11)
|
|
20
|
-
|
|
21
|
-
### [1.1.341-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-3...v1.1.341-dev-9) (2025-03-10)
|
|
22
|
-
|
|
23
|
-
### [1.1.341-dev-8](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-7...v1.1.341-dev-8) (2025-03-10)
|
|
24
|
-
|
|
25
|
-
### [1.1.341-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.342...v1.1.341-dev-7) (2025-03-10)
|
|
26
|
-
|
|
27
|
-
### [1.1.342](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-6...v1.1.342) (2025-03-10)
|
|
28
|
-
|
|
29
|
-
### [1.1.341-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-2...v1.1.341-dev-6) (2025-03-06)
|
|
30
|
-
|
|
31
|
-
### [1.1.341-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-1...v1.1.341-dev-5) (2025-03-06)
|
|
32
|
-
|
|
33
|
-
### [1.1.341-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-3...v1.1.341-dev-4) (2025-03-03)
|
|
34
|
-
|
|
35
|
-
### [1.1.341-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-2...v1.1.341-dev-3) (2025-03-03)
|
|
36
|
-
|
|
37
|
-
### [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)
|
|
38
|
-
|
|
39
|
-
### [1.1.341-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-dev-1) (2025-02-27)
|
|
40
|
-
|
|
41
|
-
### [1.1.343-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-5...v1.1.343-dev-2) (2025-03-13)
|
|
42
|
-
|
|
43
|
-
### [1.1.343-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-12...v1.1.343-dev-1) (2025-03-13)
|
|
44
|
-
|
|
45
|
-
### [1.1.341-dev-12](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-4...v1.1.341-dev-12) (2025-03-12)
|
|
46
|
-
|
|
47
|
-
### [1.1.341-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-10...v1.1.341-dev-11) (2025-03-11)
|
|
48
|
-
|
|
49
|
-
### [1.1.341-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.343...v1.1.341-dev-10) (2025-03-11)
|
|
50
|
-
|
|
51
|
-
### [1.1.343](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-9...v1.1.343) (2025-03-11)
|
|
52
|
-
|
|
53
|
-
### [1.1.341-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-3...v1.1.341-dev-9) (2025-03-10)
|
|
54
|
-
|
|
55
|
-
### [1.1.341-dev-8](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-7...v1.1.341-dev-8) (2025-03-10)
|
|
56
|
-
|
|
57
|
-
### [1.1.341-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.342...v1.1.341-dev-7) (2025-03-10)
|
|
58
|
-
|
|
59
|
-
### [1.1.342](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-6...v1.1.342) (2025-03-10)
|
|
60
|
-
|
|
61
|
-
### [1.1.341-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-2...v1.1.341-dev-6) (2025-03-06)
|
|
5
|
+
### [1.1.343-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.343-dev-4...v1.1.343-dev-5) (2025-03-14)
|
|
62
6
|
|
|
63
|
-
### [1.1.
|
|
64
|
-
|
|
65
|
-
### [1.1.341-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-3...v1.1.341-dev-4) (2025-03-03)
|
|
66
|
-
|
|
67
|
-
### [1.1.341-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-2...v1.1.341-dev-3) (2025-03-03)
|
|
68
|
-
|
|
69
|
-
### [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)
|
|
70
|
-
|
|
71
|
-
### [1.1.341-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-dev-1) (2025-02-27)
|
|
72
|
-
|
|
73
|
-
### [1.1.343-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-12...v1.1.343-dev-1) (2025-03-13)
|
|
74
|
-
|
|
75
|
-
### [1.1.343](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-9...v1.1.343) (2025-03-11)
|
|
76
|
-
|
|
77
|
-
### [1.1.342](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-6...v1.1.342) (2025-03-10)
|
|
78
|
-
|
|
79
|
-
### [1.1.341-dev-12](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-4...v1.1.341-dev-12) (2025-03-12)
|
|
80
|
-
|
|
81
|
-
### [1.1.341-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-10...v1.1.341-dev-11) (2025-03-11)
|
|
82
|
-
|
|
83
|
-
### [1.1.341-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-9...v1.1.341-dev-10) (2025-03-11)
|
|
84
|
-
|
|
85
|
-
### [1.1.341-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-3...v1.1.341-dev-9) (2025-03-10)
|
|
86
|
-
|
|
87
|
-
### [1.1.341-dev-8](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-7...v1.1.341-dev-8) (2025-03-10)
|
|
88
|
-
|
|
89
|
-
### [1.1.341-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-6...v1.1.341-dev-7) (2025-03-10)
|
|
90
|
-
|
|
91
|
-
### [1.1.341-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-2...v1.1.341-dev-6) (2025-03-06)
|
|
92
|
-
|
|
93
|
-
### [1.1.341-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-1...v1.1.341-dev-5) (2025-03-06)
|
|
94
|
-
|
|
95
|
-
### [1.1.341-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-3...v1.1.341-dev-4) (2025-03-03)
|
|
96
|
-
|
|
97
|
-
### [1.1.341-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-2...v1.1.341-dev-3) (2025-03-03)
|
|
98
|
-
|
|
99
|
-
### [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)
|
|
100
|
-
|
|
101
|
-
### [1.1.341-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-dev-1) (2025-02-27)
|
|
102
|
-
|
|
103
|
-
### [1.1.341-dev-11](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-10...v1.1.341-dev-11) (2025-03-11)
|
|
104
|
-
|
|
105
|
-
### [1.1.341-dev-10](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-9...v1.1.341-dev-10) (2025-03-11)
|
|
106
|
-
|
|
107
|
-
### [1.1.341-rank-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-8...v1.1.341-rank-3) (2025-03-10)
|
|
108
|
-
|
|
109
|
-
### [1.1.341-rank-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-5...v1.1.341-rank-2) (2025-03-06)
|
|
110
|
-
|
|
111
|
-
### [1.1.341-rank-1](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-4...v1.1.341-rank-1) (2025-03-05)
|
|
112
|
-
|
|
113
|
-
### [1.1.341-dev-9](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-8...v1.1.341-dev-9) (2025-03-10)
|
|
114
|
-
|
|
115
|
-
### [1.1.341-dev-8](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-7...v1.1.341-dev-8) (2025-03-10)
|
|
116
|
-
|
|
117
|
-
### [1.1.341-dev-7](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-6...v1.1.341-dev-7) (2025-03-10)
|
|
118
|
-
|
|
119
|
-
### [1.1.341-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.341-dev-5...v1.1.341-dev-6) (2025-03-06)
|
|
7
|
+
### [1.1.343-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.343-dev-3...v1.1.343-dev-4) (2025-03-14)
|
|
120
8
|
|
|
121
|
-
### [1.1.
|
|
9
|
+
### [1.1.343-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.343-dev-2...v1.1.343-dev-3) (2025-03-14)
|
|
122
10
|
|
|
123
|
-
### [1.1.
|
|
11
|
+
### [1.1.343-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.343-dev-1...v1.1.343-dev-2) (2025-03-14)
|
|
124
12
|
|
|
125
|
-
### [1.1.
|
|
13
|
+
### [1.1.343-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.343...v1.1.343-dev-1) (2025-03-14)
|
|
126
14
|
|
|
127
|
-
### [1.1.
|
|
15
|
+
### [1.1.343](https://github.com/jetthai/cuora-module/compare/v1.1.342...v1.1.343) (2025-03-11)
|
|
128
16
|
|
|
129
|
-
### [1.1.
|
|
17
|
+
### [1.1.342](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.342) (2025-03-10)
|
|
130
18
|
|
|
131
19
|
### [1.1.341](https://github.com/jetthai/cuora-module/compare/v1.1.340...v1.1.341) (2025-02-25)
|
|
132
20
|
|
package/package.json
CHANGED
package/src/api/game.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
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' }),
|
|
2
5
|
getGameCategory: ({ id, first } = {}) => ({ method: 'get', url: 'game/list/v2/category', params: { id, first } }),
|
|
3
6
|
addFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/add', params: { games: [code] } }),
|
|
4
7
|
removeFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/remove', params: { games: [code] } }),
|
|
@@ -97,5 +100,4 @@ export default {
|
|
|
97
100
|
}),
|
|
98
101
|
getFreeGameList: () => ({ method: 'get', url: 'activities/getFreeGameRewardList' }),
|
|
99
102
|
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 } }),
|
|
101
103
|
}
|
package/src/machine/error.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
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
|
|
6
2
|
|
|
3
|
+
export default function () {
|
|
7
4
|
return createMachine(
|
|
8
5
|
{
|
|
9
6
|
id: 'error',
|
|
@@ -11,7 +8,6 @@ export default function (request) {
|
|
|
11
8
|
context: {
|
|
12
9
|
error: null,
|
|
13
10
|
gameCode: null,
|
|
14
|
-
game: null,
|
|
15
11
|
},
|
|
16
12
|
states: {
|
|
17
13
|
normal: {
|
|
@@ -32,23 +28,15 @@ export default function (request) {
|
|
|
32
28
|
{ target: 'unfinishedGame', cond: 'isUnfinishedGame', actions: 'setUnfinishedGame' },
|
|
33
29
|
{ target: 'freeGameSettle', cond: 'isFreeGameSettle' },
|
|
34
30
|
{ target: 'freeGameGiveUp', cond: 'isFreeGameGiveUp' },
|
|
31
|
+
// { target: 'hall' },
|
|
35
32
|
],
|
|
36
33
|
},
|
|
37
34
|
logout: {},
|
|
38
35
|
deposit: {},
|
|
39
|
-
unfinishedGame: {
|
|
40
|
-
invoke: {
|
|
41
|
-
src: 'getGameInfo',
|
|
42
|
-
onDone: {
|
|
43
|
-
actions: 'setGame',
|
|
44
|
-
},
|
|
45
|
-
onError: {
|
|
46
|
-
target: 'unfinishedGame',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
36
|
+
unfinishedGame: {},
|
|
50
37
|
freeGameSettle: {},
|
|
51
38
|
freeGameGiveUp: {},
|
|
39
|
+
// hall: {},
|
|
52
40
|
},
|
|
53
41
|
},
|
|
54
42
|
},
|
|
@@ -70,12 +58,6 @@ export default function (request) {
|
|
|
70
58
|
gameCode: context.error.extend.split(/_(.+)/)[1],
|
|
71
59
|
}
|
|
72
60
|
}),
|
|
73
|
-
setGame: assign((context, event) => {
|
|
74
|
-
const { data = [] } = event.data
|
|
75
|
-
return {
|
|
76
|
-
game: data?.[0],
|
|
77
|
-
}
|
|
78
|
-
}),
|
|
79
61
|
},
|
|
80
62
|
guards: {
|
|
81
63
|
isLogout: (context, event) => {
|
|
@@ -94,12 +76,7 @@ export default function (request) {
|
|
|
94
76
|
return context.error.code === 'ERR_G125'
|
|
95
77
|
},
|
|
96
78
|
},
|
|
97
|
-
services: {
|
|
98
|
-
getGameInfo: async (context, event) => {
|
|
99
|
-
const { gameCode } = context
|
|
100
|
-
return await request.send(api.getV3GameInfo({ appSecret, gameCodes: [gameCode] }))
|
|
101
|
-
},
|
|
102
|
-
},
|
|
79
|
+
services: {},
|
|
103
80
|
}
|
|
104
81
|
)
|
|
105
82
|
}
|
package/src/machine/game_v2_1.js
CHANGED
|
@@ -49,6 +49,7 @@ export default function (request) {
|
|
|
49
49
|
gameWalletType: null,
|
|
50
50
|
switchGame: null,
|
|
51
51
|
isPlaying: false,
|
|
52
|
+
...oldContext,
|
|
52
53
|
},
|
|
53
54
|
states: {
|
|
54
55
|
flow: {
|
|
@@ -206,6 +207,7 @@ export default function (request) {
|
|
|
206
207
|
actions: ['setIsPlaying', 'resetContent', 'resetSHA'],
|
|
207
208
|
},
|
|
208
209
|
LEAVE_GAME_REFRESH: {
|
|
210
|
+
target: '#game.oldTimer',
|
|
209
211
|
actions: 'setIsPlaying',
|
|
210
212
|
},
|
|
211
213
|
},
|
|
@@ -280,6 +282,63 @@ export default function (request) {
|
|
|
280
282
|
},
|
|
281
283
|
},
|
|
282
284
|
},
|
|
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
|
+
},
|
|
283
342
|
},
|
|
284
343
|
},
|
|
285
344
|
{
|
|
@@ -396,6 +455,9 @@ export default function (request) {
|
|
|
396
455
|
return event.data.gameWalletType
|
|
397
456
|
},
|
|
398
457
|
}),
|
|
458
|
+
clearGameInfo: assign((context, event) => {
|
|
459
|
+
return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
|
|
460
|
+
}),
|
|
399
461
|
setGameInfo: assign((context, event) => {
|
|
400
462
|
const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = event.data.game
|
|
401
463
|
return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
|
|
@@ -429,6 +491,7 @@ export default function (request) {
|
|
|
429
491
|
isPlaying: event.data,
|
|
430
492
|
}
|
|
431
493
|
}),
|
|
494
|
+
...oldActions,
|
|
432
495
|
},
|
|
433
496
|
guards: {
|
|
434
497
|
isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
|
|
@@ -437,9 +500,13 @@ export default function (request) {
|
|
|
437
500
|
// 是否有下一頁
|
|
438
501
|
return loadable && !isLastPage
|
|
439
502
|
},
|
|
503
|
+
isNotInGame: (context, event) => {
|
|
504
|
+
return !context.isPlaying
|
|
505
|
+
},
|
|
440
506
|
hasRoomAndIsNotInGame: (context, event) => {
|
|
441
507
|
return context.room?.categoryId && !context.isPlaying
|
|
442
508
|
},
|
|
509
|
+
...oldGuards,
|
|
443
510
|
},
|
|
444
511
|
services: {
|
|
445
512
|
batchFetch: async (context, event) => {
|
|
@@ -567,7 +634,75 @@ export default function (request) {
|
|
|
567
634
|
const provider_id = context.game.providerId
|
|
568
635
|
return await request.send(api.logoutGame({ uid_site, provider_id }))
|
|
569
636
|
},
|
|
637
|
+
...oldServices(request),
|
|
570
638
|
},
|
|
571
639
|
}
|
|
572
640
|
)
|
|
573
641
|
}
|
|
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
|
+
})
|
package/src/machine/navbar.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import common from '../api/common.js'
|
|
3
|
-
import game from '../api/game.js'
|
|
4
3
|
|
|
5
4
|
export default function (request) {
|
|
6
5
|
const { appSecret } = request.config
|
|
@@ -9,35 +8,15 @@ export default function (request) {
|
|
|
9
8
|
id: 'navbar',
|
|
10
9
|
initial: 'fetching',
|
|
11
10
|
context: {
|
|
12
|
-
navbar:
|
|
13
|
-
gameCodes: [],
|
|
11
|
+
navbar: null,
|
|
14
12
|
},
|
|
15
13
|
states: {
|
|
16
14
|
fetching: {
|
|
17
15
|
invoke: {
|
|
18
16
|
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',
|
|
38
17
|
onDone: {
|
|
39
18
|
target: 'idle',
|
|
40
|
-
actions: '
|
|
19
|
+
actions: 'setNavbar',
|
|
41
20
|
},
|
|
42
21
|
onError: {
|
|
43
22
|
target: 'idle',
|
|
@@ -55,47 +34,6 @@ export default function (request) {
|
|
|
55
34
|
navbar: navbarConfig.settings,
|
|
56
35
|
}
|
|
57
36
|
}),
|
|
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
|
-
},
|
|
99
37
|
},
|
|
100
38
|
services: {
|
|
101
39
|
fetchNavbar: async (context, event) => {
|
|
@@ -113,10 +51,6 @@ export default function (request) {
|
|
|
113
51
|
)
|
|
114
52
|
return { navbarConfig: JSON.parse(decodeResult) }
|
|
115
53
|
},
|
|
116
|
-
getGameInfo: async (context, event) => {
|
|
117
|
-
const { gameCodes } = context
|
|
118
|
-
return await request.send(game.getV3GameInfo({ appSecret, gameCodes }))
|
|
119
|
-
},
|
|
120
54
|
},
|
|
121
55
|
}
|
|
122
56
|
)
|
package/src/machine/websocket.js
CHANGED
|
@@ -176,22 +176,19 @@ export default function (request) {
|
|
|
176
176
|
}),
|
|
177
177
|
pushEvent: assign((context, value) => {
|
|
178
178
|
const { analytics } = context
|
|
179
|
-
const { data, event
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (event === 'purchase' && data?.isFirst === true && isTracking) {
|
|
179
|
+
const { data, event } = value.data
|
|
180
|
+
analytics?.push(
|
|
181
|
+
{
|
|
182
|
+
event: event,
|
|
183
|
+
paymentMethod: data.paymentMethod,
|
|
184
|
+
transaction_id: data.transactionId,
|
|
185
|
+
currency: data.currency,
|
|
186
|
+
value: data.value,
|
|
187
|
+
app_value: data.value,
|
|
188
|
+
},
|
|
189
|
+
{ eventID: data.transactionId }
|
|
190
|
+
)
|
|
191
|
+
if (event === 'purchase' && data?.isFirst === true) {
|
|
195
192
|
analytics?.push(
|
|
196
193
|
{
|
|
197
194
|
event: 'first_deposit',
|
|
@@ -274,7 +271,6 @@ export default function (request) {
|
|
|
274
271
|
clientSocket.on('activity-info', (data) => {
|
|
275
272
|
console.log('[socket][activity-info]:', data)
|
|
276
273
|
callback({ type: 'ACTIVITY_INFO', data })
|
|
277
|
-
callback({ type: 'PUSH_ANALYTICS', data })
|
|
278
274
|
})
|
|
279
275
|
|
|
280
276
|
// 監聽 activity-reward-info 事件
|
|
@@ -291,7 +287,7 @@ export default function (request) {
|
|
|
291
287
|
|
|
292
288
|
// 監聽 payment-info 事件
|
|
293
289
|
clientSocket.on('payment-info', (data) => {
|
|
294
|
-
console.log('[socket][payment-info]:', data)
|
|
290
|
+
console.log('[socket][payment-info]:', data, data.windowType)
|
|
295
291
|
if (data.windowType === 'toast') {
|
|
296
292
|
callback({ type: 'ACTIVITY_INFO', data })
|
|
297
293
|
}
|