@jetthai/cuora 1.0.302-sl-2 → 1.1.0
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 +3 -848
- package/README.md +0 -6
- package/dist/bundle.mjs +18461 -0
- package/package.json +9 -6
- package/rollup.config.js +16 -0
- package/src/api/activity.js +2 -43
- package/src/api/auth.js +7 -22
- package/src/api/common.js +1 -3
- package/src/api/game.js +7 -20
- package/src/api/mailbox.js +5 -9
- package/src/api/payment.js +19 -167
- package/src/api/user.js +0 -7
- package/src/machine/activity/activity.js +26 -111
- package/src/machine/activity/{friend_invite_friends_activity.js → affiliate_invite_friends_activity.js} +41 -70
- package/src/machine/activity/continue_deposit_activity.js +2 -11
- package/src/machine/activity/deposit_activity.js +4 -13
- package/src/machine/activity/diamond_shop_activity_vn.js +89 -54
- package/src/machine/activity/fafafa_activity.js +19 -34
- package/src/machine/activity/index.js +4 -22
- package/src/machine/activity/invite_friends_activity.js +14 -14
- package/src/machine/activity/ranking_activity.js +2 -11
- package/src/machine/activity/sign_in_activity.js +14 -21
- package/src/machine/activity/specify_bets_activity.js +3 -25
- package/src/machine/activity/specify_turnover_activity.js +3 -25
- package/src/machine/activity/time_bomb_activity.js +2 -11
- package/src/machine/auth.js +21 -134
- package/src/machine/auth_otp.js +201 -0
- package/src/machine/auth_otp_v2.js +4 -10
- package/src/machine/auth_otp_v3.js +3 -11
- package/src/machine/bank_binding.js +12 -112
- package/src/machine/common.js +25 -113
- package/src/machine/deposit/crypto.js +29 -50
- package/src/machine/deposit/crypto_button.js +39 -174
- package/src/machine/deposit/deposit_fc.js +5 -8
- package/src/machine/deposit/direct.js +16 -111
- package/src/machine/deposit/index.js +2 -43
- package/src/machine/deposit/loadcard_vn.js +43 -191
- package/src/machine/deposit/manual_vn.js +60 -182
- package/src/machine/deposit/qrcode_v2.js +52 -285
- package/src/machine/deposit/qrcode_vn.js +206 -0
- package/src/machine/game.js +285 -0
- package/src/machine/game_favorite.js +123 -0
- package/src/machine/game_favorite_v2.js +28 -74
- package/src/machine/game_search.js +244 -0
- package/src/machine/game_search_v2.js +24 -64
- package/src/machine/game_v2.js +356 -0
- package/src/machine/inbox.js +34 -259
- package/src/machine/index.js +17 -24
- package/src/machine/leaderboard.js +8 -31
- package/src/machine/reward.js +7 -74
- package/src/machine/setting.js +2 -5
- package/src/machine/side_v2.js +28 -33
- package/src/machine/user_sign_up.js +17 -117
- package/src/machine/{withdraw/withdraw_crypto.js → withdraw_crypto.js} +69 -220
- package/src/machine/{withdraw/withdraw_fc.js → withdraw_fc.js} +2 -2
- package/src/machine/{withdraw/withdraw_amb.js → withdraw_vn.js} +78 -146
- package/src/request/request.js +5 -10
- package/src/util/constant.js +1 -19
- package/src/util/deviceToken.js +8 -18
- package/src/util/index.js +1 -2
- package/src/util/storage.js +22 -22
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -1
- package/src/lib/fingerprint.js +0 -9779
- package/src/machine/activity/activity_cash.js +0 -159
- package/src/machine/activity/cash_rain_activity.js +0 -153
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -179
- package/src/machine/activity/instant_rebate_activity.js +0 -217
- package/src/machine/activity/jackpot.js +0 -74
- package/src/machine/activity/otp_verified_activity.js +0 -74
- package/src/machine/activity/roulette_activity_v2.js +0 -90
- package/src/machine/activity/sign_in_monthly_activity.js +0 -65
- package/src/machine/activity/vip_card_activity.js +0 -140
- package/src/machine/bank_binding_amb.js +0 -145
- package/src/machine/deposit/amb.js +0 -92
- package/src/machine/deposit/crypto_bank.js +0 -317
- package/src/machine/deposit/crypto_bank_cash.js +0 -287
- package/src/machine/deposit/crypto_cash.js +0 -255
- package/src/machine/deposit/crypto_qrcode.js +0 -148
- package/src/machine/deposit/crypto_qrcode_cash.js +0 -131
- package/src/machine/deposit/crypto_way.js +0 -239
- package/src/machine/deposit/crypto_way_cash.js +0 -256
- package/src/machine/deposit/direct_cash.js +0 -217
- package/src/machine/deposit/float.js +0 -366
- package/src/machine/deposit/krway.js +0 -151
- package/src/machine/deposit/loadcard_cash.js +0 -207
- package/src/machine/deposit/manual_cash.js +0 -356
- package/src/machine/deposit/qrcode_cash.js +0 -217
- package/src/machine/deposit/usdt.js +0 -144
- package/src/machine/deposit/usdt_cash.js +0 -138
- package/src/machine/deposit/vpay.js +0 -359
- package/src/machine/game_info.js +0 -57
- package/src/machine/game_search_cash.js +0 -390
- package/src/machine/game_v2_1.js +0 -662
- package/src/machine/honor_board_cash.js +0 -63
- package/src/machine/navbar.js +0 -57
- package/src/machine/promotions.js +0 -171
- package/src/machine/reward_cash.js +0 -219
- package/src/machine/roulette_v2.js +0 -276
- package/src/machine/side_cash.js +0 -110
- package/src/machine/user_photo.js +0 -65
- package/src/machine/withdraw/index.js +0 -23
- package/src/machine/withdraw/withdraw_crypto2.js +0 -540
- package/src/machine/withdraw/withdraw_crypto_cash.js +0 -319
- package/src/machine/withdraw/withdraw_krway.js +0 -207
- package/src/machine/withdraw/withdraw_manual.js +0 -595
- package/src/machine/withdraw/withdraw_manual_cash.js +0 -303
- package/src/machine/withdraw/withdraw_vn.js +0 -533
- package/src/machine/withdraw/withdraw_vn2.js +0 -548
- package/src/util/math.js +0 -4
package/src/machine/game_v2_1.js
DELETED
|
@@ -1,662 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import api from '../api/game.js'
|
|
3
|
-
import UAParser from 'ua-parser-js'
|
|
4
|
-
import { GAME_SEARCH } from '../util/constant.js'
|
|
5
|
-
|
|
6
|
-
// 對應 intersectionObserver 版本
|
|
7
|
-
export default function (request) {
|
|
8
|
-
return createMachine(
|
|
9
|
-
{
|
|
10
|
-
id: 'game',
|
|
11
|
-
type: 'parallel',
|
|
12
|
-
context: {
|
|
13
|
-
base: '/',
|
|
14
|
-
batch: null,
|
|
15
|
-
loadable: false,
|
|
16
|
-
isLastPage: false,
|
|
17
|
-
pageLoading: true,
|
|
18
|
-
room: null,
|
|
19
|
-
index: -1,
|
|
20
|
-
content: {
|
|
21
|
-
data: [],
|
|
22
|
-
timestamp: null,
|
|
23
|
-
parentCategoryId: null,
|
|
24
|
-
totalPage: 0,
|
|
25
|
-
},
|
|
26
|
-
additionEnable: false,
|
|
27
|
-
addition: {
|
|
28
|
-
data: [],
|
|
29
|
-
timestamp: null,
|
|
30
|
-
totalPage: 0,
|
|
31
|
-
},
|
|
32
|
-
staticData: [],
|
|
33
|
-
// play params
|
|
34
|
-
game: {
|
|
35
|
-
providerId: null,
|
|
36
|
-
gameId: null,
|
|
37
|
-
gameTypeId: null,
|
|
38
|
-
mappingId: null,
|
|
39
|
-
portrait: null,
|
|
40
|
-
gameCode: null,
|
|
41
|
-
name: null,
|
|
42
|
-
},
|
|
43
|
-
lang: 'en_US',
|
|
44
|
-
isMobile: new UAParser().getResult().device.type,
|
|
45
|
-
gameURL: null,
|
|
46
|
-
gameToken: null,
|
|
47
|
-
gameHtml: null,
|
|
48
|
-
switchGame: null,
|
|
49
|
-
...oldContext,
|
|
50
|
-
},
|
|
51
|
-
states: {
|
|
52
|
-
flow: {
|
|
53
|
-
initial: 'idle',
|
|
54
|
-
states: {
|
|
55
|
-
idle: {
|
|
56
|
-
enter: 'clearGameInfo',
|
|
57
|
-
on: {
|
|
58
|
-
SET_STATIC_DATA: {
|
|
59
|
-
actions: 'setStaticData',
|
|
60
|
-
},
|
|
61
|
-
SET_ADDITION_ENABLE: {
|
|
62
|
-
actions: 'setAdditionEnable',
|
|
63
|
-
},
|
|
64
|
-
LOAD: {
|
|
65
|
-
target: 'routing',
|
|
66
|
-
actions: 'setLoadable',
|
|
67
|
-
},
|
|
68
|
-
// 載入下一頁
|
|
69
|
-
NEXT_PAGE: {
|
|
70
|
-
target: 'routing',
|
|
71
|
-
actions: 'setLoadable',
|
|
72
|
-
},
|
|
73
|
-
SET_ROOM: {
|
|
74
|
-
cond: 'isDifferentRoom',
|
|
75
|
-
actions: ['setRoom', 'resetContent'],
|
|
76
|
-
},
|
|
77
|
-
BATCH: {
|
|
78
|
-
target: 'batchFetching',
|
|
79
|
-
},
|
|
80
|
-
ENTER_GAME: {
|
|
81
|
-
target: 'connecting',
|
|
82
|
-
actions: ['setGameInfo', 'setLang'],
|
|
83
|
-
},
|
|
84
|
-
MENU_ENTER_GAME: {
|
|
85
|
-
target: 'connecting',
|
|
86
|
-
actions: ['setGameInfo', 'setLang'],
|
|
87
|
-
},
|
|
88
|
-
UPDATE: {
|
|
89
|
-
target: 'updating',
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
batchFetching: {
|
|
94
|
-
invoke: {
|
|
95
|
-
src: 'batchFetch',
|
|
96
|
-
onDone: {
|
|
97
|
-
target: 'idle',
|
|
98
|
-
actions: 'setBatch',
|
|
99
|
-
},
|
|
100
|
-
onError: {
|
|
101
|
-
target: 'idle',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
loading: {
|
|
106
|
-
entry: 'increaseIndex',
|
|
107
|
-
invoke: {
|
|
108
|
-
src: 'getPageContent',
|
|
109
|
-
onDone: {
|
|
110
|
-
// 原本的: 形成迴圈直到hasNxet條件不成立
|
|
111
|
-
// target: 'routing',
|
|
112
|
-
// 現在: 載完一個頁面就切成loaded狀態
|
|
113
|
-
target: 'loaded',
|
|
114
|
-
actions: ['appendContent', 'setLastPage'],
|
|
115
|
-
},
|
|
116
|
-
onError: {
|
|
117
|
-
target: 'idle',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
on: {
|
|
121
|
-
LOAD: { actions: 'setLoadable' },
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
// 已將當前頁載入完成
|
|
125
|
-
loaded: {
|
|
126
|
-
after: {
|
|
127
|
-
0: {
|
|
128
|
-
target: 'idle',
|
|
129
|
-
actions: 'setPageLoadingDone',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
routing: {
|
|
134
|
-
always: [
|
|
135
|
-
{
|
|
136
|
-
target: 'loading',
|
|
137
|
-
cond: 'hasNext',
|
|
138
|
-
actions: 'setPageLoading',
|
|
139
|
-
},
|
|
140
|
-
{ target: 'idle', actions: 'setPageLoadingDone' },
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
updating: {
|
|
144
|
-
invoke: {
|
|
145
|
-
src: 'updatePageContent',
|
|
146
|
-
onDone: {
|
|
147
|
-
target: 'idle',
|
|
148
|
-
actions: 'swapContent',
|
|
149
|
-
},
|
|
150
|
-
onError: {
|
|
151
|
-
target: 'idle',
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
connecting: {
|
|
156
|
-
invoke: {
|
|
157
|
-
src: 'connectGame',
|
|
158
|
-
onDone: {
|
|
159
|
-
target: 'playing',
|
|
160
|
-
actions: 'setGameURL',
|
|
161
|
-
},
|
|
162
|
-
onError: {
|
|
163
|
-
target: 'idle',
|
|
164
|
-
actions: 'setGameURL',
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
on: {
|
|
168
|
-
EXIT_GAME: {
|
|
169
|
-
target: 'disconnect',
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
connectSwitching: {
|
|
174
|
-
invoke: {
|
|
175
|
-
src: 'disconnectGame',
|
|
176
|
-
onDone: {
|
|
177
|
-
target: 'connecting',
|
|
178
|
-
actions: ['setSwitchGameInfo', 'setGameURL'],
|
|
179
|
-
},
|
|
180
|
-
onError: {
|
|
181
|
-
target: 'idle',
|
|
182
|
-
actions: ['setSwitchGameInfo', 'setGameURL'],
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
on: {
|
|
186
|
-
EXIT_GAME: {
|
|
187
|
-
target: 'disconnect',
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
playing: {
|
|
192
|
-
on: {
|
|
193
|
-
EXIT_GAME: {
|
|
194
|
-
target: 'disconnect',
|
|
195
|
-
},
|
|
196
|
-
REFRESH: {
|
|
197
|
-
target: 'refreshing',
|
|
198
|
-
},
|
|
199
|
-
MENU_ENTER_GAME: {
|
|
200
|
-
target: 'connectSwitching',
|
|
201
|
-
actions: ['setSwitch', 'setLang'],
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
refreshing: {
|
|
206
|
-
invoke: {
|
|
207
|
-
src: 'disconnectGame',
|
|
208
|
-
onDone: {
|
|
209
|
-
target: 'refreshPending',
|
|
210
|
-
actions: 'setGameURL',
|
|
211
|
-
},
|
|
212
|
-
onError: {
|
|
213
|
-
target: 'idle',
|
|
214
|
-
actions: 'setGameURL',
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
refreshPending: {
|
|
219
|
-
after: {
|
|
220
|
-
500: {
|
|
221
|
-
target: 'connecting',
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
disconnect: {
|
|
226
|
-
invoke: {
|
|
227
|
-
src: 'disconnectGame',
|
|
228
|
-
onDone: {
|
|
229
|
-
target: 'idle',
|
|
230
|
-
actions: 'setGameURL',
|
|
231
|
-
},
|
|
232
|
-
onError: {
|
|
233
|
-
target: 'idle',
|
|
234
|
-
actions: 'setGameURL',
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
timer: {
|
|
241
|
-
initial: 'pending',
|
|
242
|
-
states: {
|
|
243
|
-
pending: {
|
|
244
|
-
after: {
|
|
245
|
-
20000: [
|
|
246
|
-
{
|
|
247
|
-
target: 'updating',
|
|
248
|
-
cond: 'hasRoom',
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
target: 'pending',
|
|
252
|
-
},
|
|
253
|
-
],
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
updating: {
|
|
257
|
-
invoke: {
|
|
258
|
-
src: 'updatePageContent',
|
|
259
|
-
onDone: {
|
|
260
|
-
target: 'pending',
|
|
261
|
-
actions: 'swapContent',
|
|
262
|
-
},
|
|
263
|
-
onError: {
|
|
264
|
-
target: 'pending',
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
oldTimer: {
|
|
271
|
-
initial: 'fetchingGameSHA',
|
|
272
|
-
states: {
|
|
273
|
-
fetchingGameSHA: {
|
|
274
|
-
invoke: {
|
|
275
|
-
src: 'fetchGameSHA',
|
|
276
|
-
onDone: {
|
|
277
|
-
target: 'checking',
|
|
278
|
-
actions: 'setGameSHA',
|
|
279
|
-
},
|
|
280
|
-
onError: {
|
|
281
|
-
target: 'pending',
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
checking: {
|
|
286
|
-
always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
|
|
287
|
-
},
|
|
288
|
-
updatingStatus: {
|
|
289
|
-
invoke: {
|
|
290
|
-
src: 'fetchStatus',
|
|
291
|
-
onDone: {
|
|
292
|
-
target: 'updatingOption',
|
|
293
|
-
actions: ['setStatus'],
|
|
294
|
-
},
|
|
295
|
-
onError: {
|
|
296
|
-
target: 'pending',
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
updatingOption: {
|
|
301
|
-
invoke: {
|
|
302
|
-
src: 'fetchOption',
|
|
303
|
-
onDone: {
|
|
304
|
-
target: 'pending',
|
|
305
|
-
actions: 'mergeOption',
|
|
306
|
-
},
|
|
307
|
-
onError: {
|
|
308
|
-
target: 'pending',
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
pending: {
|
|
313
|
-
after: {
|
|
314
|
-
20000: {
|
|
315
|
-
target: 'fetchingGameSHA',
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
actions: {
|
|
325
|
-
setStaticData: assign((context, event) => {
|
|
326
|
-
return {
|
|
327
|
-
staticData: event.data,
|
|
328
|
-
}
|
|
329
|
-
}),
|
|
330
|
-
setAdditionEnable: assign((context, event) => {
|
|
331
|
-
return {
|
|
332
|
-
additionEnable: event.data,
|
|
333
|
-
}
|
|
334
|
-
}),
|
|
335
|
-
setLoadable: assign((context, event) => {
|
|
336
|
-
return {
|
|
337
|
-
loadable: event.data,
|
|
338
|
-
}
|
|
339
|
-
}),
|
|
340
|
-
setLastPage: assign((context, event) => {
|
|
341
|
-
const { index, content } = context
|
|
342
|
-
// 最後一頁
|
|
343
|
-
return {
|
|
344
|
-
isLastPage: index >= content?.totalPage - 1,
|
|
345
|
-
}
|
|
346
|
-
}),
|
|
347
|
-
setRoom: assign((context, event) => {
|
|
348
|
-
return {
|
|
349
|
-
room: event.data,
|
|
350
|
-
}
|
|
351
|
-
}),
|
|
352
|
-
setBatch: assign((context, event) => {
|
|
353
|
-
return {
|
|
354
|
-
batch: event.data,
|
|
355
|
-
}
|
|
356
|
-
}),
|
|
357
|
-
resetContent: assign((context, event) => {
|
|
358
|
-
return {
|
|
359
|
-
loadable: false,
|
|
360
|
-
isLastPage: false,
|
|
361
|
-
index: -1,
|
|
362
|
-
content: {
|
|
363
|
-
data: [],
|
|
364
|
-
timestamp: null,
|
|
365
|
-
parentCategoryId: null,
|
|
366
|
-
totalPage: 0,
|
|
367
|
-
},
|
|
368
|
-
addition: {
|
|
369
|
-
data: [],
|
|
370
|
-
timestamp: null,
|
|
371
|
-
totalPage: 0,
|
|
372
|
-
},
|
|
373
|
-
}
|
|
374
|
-
}),
|
|
375
|
-
appendContent: assign((context, event) => {
|
|
376
|
-
const { room, additionEnable } = context
|
|
377
|
-
if (room.categoryId === GAME_SEARCH) {
|
|
378
|
-
return
|
|
379
|
-
} else if (additionEnable) {
|
|
380
|
-
const [content, addition = {}] = event.data
|
|
381
|
-
return {
|
|
382
|
-
content: {
|
|
383
|
-
...context.content,
|
|
384
|
-
...content,
|
|
385
|
-
data: context.content.data.concat(content.data),
|
|
386
|
-
},
|
|
387
|
-
addition: {
|
|
388
|
-
...context.addition,
|
|
389
|
-
...addition,
|
|
390
|
-
data: context.addition.data.concat(addition.data),
|
|
391
|
-
},
|
|
392
|
-
}
|
|
393
|
-
} else {
|
|
394
|
-
const [content] = event.data
|
|
395
|
-
return {
|
|
396
|
-
content: {
|
|
397
|
-
...context.content,
|
|
398
|
-
...content,
|
|
399
|
-
data: context.content.data.concat(content.data),
|
|
400
|
-
},
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}),
|
|
404
|
-
swapContent: assign((context, event) => {
|
|
405
|
-
const [content, addition] = event.data
|
|
406
|
-
let result = {}
|
|
407
|
-
if (content?.data?.length) {
|
|
408
|
-
result.content = content
|
|
409
|
-
}
|
|
410
|
-
if (addition?.data?.length) {
|
|
411
|
-
result.addition = addition
|
|
412
|
-
}
|
|
413
|
-
return result
|
|
414
|
-
}),
|
|
415
|
-
increaseIndex: assign((context, event) => {
|
|
416
|
-
return {
|
|
417
|
-
index: context.index + 1,
|
|
418
|
-
}
|
|
419
|
-
}),
|
|
420
|
-
setGameURL: assign({
|
|
421
|
-
type: (context, event) => {
|
|
422
|
-
return event.data.type
|
|
423
|
-
},
|
|
424
|
-
gameToken: (context, event) => {
|
|
425
|
-
return event.data.gameToken
|
|
426
|
-
},
|
|
427
|
-
gameHtml: (context, event) => {
|
|
428
|
-
return event.data.gameHtml
|
|
429
|
-
},
|
|
430
|
-
gameURL: (context, event) => {
|
|
431
|
-
return event.data.gameURL
|
|
432
|
-
},
|
|
433
|
-
}),
|
|
434
|
-
clearGameInfo: assign((context, event) => {
|
|
435
|
-
return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
|
|
436
|
-
}),
|
|
437
|
-
setGameInfo: assign((context, event) => {
|
|
438
|
-
const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = event.data.game
|
|
439
|
-
return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
|
|
440
|
-
}),
|
|
441
|
-
setSwitch: assign((context, event) => {
|
|
442
|
-
return { switchGame: event.data.game }
|
|
443
|
-
}),
|
|
444
|
-
setSwitchGameInfo: assign((context, event) => {
|
|
445
|
-
const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = context.switchGame
|
|
446
|
-
return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
|
|
447
|
-
}),
|
|
448
|
-
setLang: assign((context, event) => {
|
|
449
|
-
const lang = event.data.locale.replace('-', '_')
|
|
450
|
-
return { lang }
|
|
451
|
-
}),
|
|
452
|
-
setPageLoadingDone: assign((context, event) => {
|
|
453
|
-
// const { index } = context
|
|
454
|
-
// console.log('*載入完成:當前頁碼', index)
|
|
455
|
-
return {
|
|
456
|
-
pageLoading: true,
|
|
457
|
-
}
|
|
458
|
-
}),
|
|
459
|
-
setPageLoading: assign((context, event) => {
|
|
460
|
-
return {
|
|
461
|
-
pageLoading: false,
|
|
462
|
-
}
|
|
463
|
-
}),
|
|
464
|
-
...oldActions,
|
|
465
|
-
},
|
|
466
|
-
guards: {
|
|
467
|
-
isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
|
|
468
|
-
hasNext: (context, event) => {
|
|
469
|
-
const { loadable, isLastPage } = context
|
|
470
|
-
// 是否有下一頁
|
|
471
|
-
return loadable && !isLastPage
|
|
472
|
-
},
|
|
473
|
-
hasRoom: (context, event) => context.room?.categoryId,
|
|
474
|
-
...oldGuards,
|
|
475
|
-
},
|
|
476
|
-
services: {
|
|
477
|
-
batchFetch: async (context, event) => {
|
|
478
|
-
const { room, index, additionEnable, staticData } = context
|
|
479
|
-
let requestChain = null
|
|
480
|
-
if (!request.getToken()) {
|
|
481
|
-
// 如果沒 token ,id 列表去 static 找
|
|
482
|
-
const list = event.data.list.map((targetCategory, b) => {
|
|
483
|
-
return {
|
|
484
|
-
id: targetCategory.id,
|
|
485
|
-
i18n: targetCategory.i18n,
|
|
486
|
-
downLine: staticData
|
|
487
|
-
.find((item) => item.category === targetCategory.id)
|
|
488
|
-
.info.filter((item) => item.isGame === true)
|
|
489
|
-
.slice(0, 20),
|
|
490
|
-
}
|
|
491
|
-
})
|
|
492
|
-
return list.filter((item) => item.downLine.length > 0).slice(0, 6)
|
|
493
|
-
} else if (additionEnable) {
|
|
494
|
-
const param = { categoryId: room.categoryId, index }
|
|
495
|
-
requestChain = event.data.list.map((category, b) => {
|
|
496
|
-
return request
|
|
497
|
-
.send(
|
|
498
|
-
api.getListCategory({
|
|
499
|
-
categoryId: category.id,
|
|
500
|
-
index: 0,
|
|
501
|
-
})
|
|
502
|
-
)
|
|
503
|
-
.then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame === true).slice(0, 20) }, category))
|
|
504
|
-
})
|
|
505
|
-
const result = await Promise.all([...requestChain, request.send(api.getListAddition(param))])
|
|
506
|
-
return result.filter((item) => item.downLine.length > 0).slice(0, 6)
|
|
507
|
-
} else {
|
|
508
|
-
requestChain = event.data.list.map((category, b) => {
|
|
509
|
-
return request
|
|
510
|
-
.send(
|
|
511
|
-
api.getListCategory({
|
|
512
|
-
categoryId: category.id,
|
|
513
|
-
index: 0,
|
|
514
|
-
})
|
|
515
|
-
)
|
|
516
|
-
.then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame === true).slice(0, 20) }, category))
|
|
517
|
-
})
|
|
518
|
-
const result = await Promise.all([...requestChain])
|
|
519
|
-
return result.filter((item) => item.downLine.length > 0).slice(0, 6)
|
|
520
|
-
}
|
|
521
|
-
},
|
|
522
|
-
getPageContent: async (context, event) => {
|
|
523
|
-
const { room, index, additionEnable, staticData } = context
|
|
524
|
-
if (room.categoryId === GAME_SEARCH) {
|
|
525
|
-
return
|
|
526
|
-
} else if (!request.getToken()) {
|
|
527
|
-
const list = staticData.find((data) => data.category == room.categoryId)?.info || []
|
|
528
|
-
|
|
529
|
-
return [
|
|
530
|
-
{
|
|
531
|
-
data: list.slice(index * 20, (index + 1) * 20),
|
|
532
|
-
totalPage: Math.ceil(list.length / 20),
|
|
533
|
-
timestamp: Math.floor(Date.now() / 1000),
|
|
534
|
-
},
|
|
535
|
-
]
|
|
536
|
-
} else if (additionEnable) {
|
|
537
|
-
const param = { categoryId: room.categoryId, index }
|
|
538
|
-
return await Promise.all([request.send(api.getListCategory(param)), request.send(api.getListAddition(param))])
|
|
539
|
-
} else {
|
|
540
|
-
const param = { categoryId: room.categoryId, index }
|
|
541
|
-
return await Promise.all([request.send(api.getListCategory(param))])
|
|
542
|
-
}
|
|
543
|
-
},
|
|
544
|
-
updatePageContent: async (context, event) => {
|
|
545
|
-
const { room, content, index, additionEnable } = context
|
|
546
|
-
if (room.categoryId === GAME_SEARCH) {
|
|
547
|
-
return []
|
|
548
|
-
} else if (!request.getToken()) {
|
|
549
|
-
return []
|
|
550
|
-
} else if (additionEnable) {
|
|
551
|
-
return await Promise.all([
|
|
552
|
-
request.send(
|
|
553
|
-
api.getListCategoryByRange({
|
|
554
|
-
categoryId: room.categoryId,
|
|
555
|
-
end: index,
|
|
556
|
-
timestamp: content.timestamp,
|
|
557
|
-
})
|
|
558
|
-
),
|
|
559
|
-
request.send(
|
|
560
|
-
api.getListAdditionByRange({
|
|
561
|
-
categoryId: room.categoryId,
|
|
562
|
-
end: index,
|
|
563
|
-
timestamp: content.timestamp,
|
|
564
|
-
})
|
|
565
|
-
),
|
|
566
|
-
])
|
|
567
|
-
} else {
|
|
568
|
-
return await Promise.all([
|
|
569
|
-
request.send(
|
|
570
|
-
api.getListCategoryByRange({
|
|
571
|
-
categoryId: room.categoryId,
|
|
572
|
-
end: index,
|
|
573
|
-
timestamp: content.timestamp,
|
|
574
|
-
})
|
|
575
|
-
),
|
|
576
|
-
])
|
|
577
|
-
}
|
|
578
|
-
},
|
|
579
|
-
connectGame: async (context, event) => {
|
|
580
|
-
const returnProviders = ['RSG', 'KP', 'EPICWIN', 'AMBSLOT', 'SEXY_VENUS', 'SEXY_SEXYBCRT', 'PG', 'NPG']
|
|
581
|
-
const { lang, isMobile } = context
|
|
582
|
-
const { providerId, gameId, gameTypeId, mappingId } = context.game
|
|
583
|
-
const params = {
|
|
584
|
-
provider_id: providerId,
|
|
585
|
-
game_id: gameId,
|
|
586
|
-
gametype_id: gameTypeId,
|
|
587
|
-
mapping_id: mappingId,
|
|
588
|
-
is_demo: false,
|
|
589
|
-
is_mobile: isMobile === 'mobile' ? 'y' : null,
|
|
590
|
-
lang,
|
|
591
|
-
return_url: returnProviders.includes(providerId) ? `${window.location.origin}${context.base}return` : window.location.href, // For providers to return.
|
|
592
|
-
}
|
|
593
|
-
const { type, redirect_url, gameToken, gameHtml } = await request.send(api.playGame(params))
|
|
594
|
-
return { type, gameToken, gameHtml, gameURL: redirect_url }
|
|
595
|
-
},
|
|
596
|
-
disconnectGame: async (context, event) => {
|
|
597
|
-
const uid_site = event.data
|
|
598
|
-
const provider_id = context.game.providerId
|
|
599
|
-
return await request.send(api.logoutGame({ uid_site, provider_id }))
|
|
600
|
-
},
|
|
601
|
-
...oldServices(request),
|
|
602
|
-
},
|
|
603
|
-
}
|
|
604
|
-
)
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
const oldContext = {
|
|
608
|
-
sha: {
|
|
609
|
-
status: null,
|
|
610
|
-
},
|
|
611
|
-
isStatusChanged: false,
|
|
612
|
-
statusMap: {},
|
|
613
|
-
optionMap: {},
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
const oldActions = {
|
|
617
|
-
setGameSHA: assign((context, event) => {
|
|
618
|
-
const { sha } = context
|
|
619
|
-
const newSha = event.data
|
|
620
|
-
return {
|
|
621
|
-
sha: newSha,
|
|
622
|
-
isStatusChanged: !sha.status || sha.status !== newSha.status,
|
|
623
|
-
}
|
|
624
|
-
}),
|
|
625
|
-
setStatus: assign((context, event) => {
|
|
626
|
-
return {
|
|
627
|
-
statusMap: event.data,
|
|
628
|
-
}
|
|
629
|
-
}),
|
|
630
|
-
mergeOption: assign((context, event) => {
|
|
631
|
-
const { optionMap } = context
|
|
632
|
-
return {
|
|
633
|
-
optionMap: { ...optionMap, ...event.data },
|
|
634
|
-
}
|
|
635
|
-
}),
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
const oldGuards = {
|
|
639
|
-
isStatusChanged: (context, event) => context.isStatusChanged,
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
const oldServices = (request) => ({
|
|
643
|
-
fetchOption: async (context, event) => {
|
|
644
|
-
if (request.getToken()) {
|
|
645
|
-
return await request.send(api.getOptionMap())
|
|
646
|
-
}
|
|
647
|
-
},
|
|
648
|
-
fetchGameSHA: async (context, event) => {
|
|
649
|
-
if (request.getToken()) {
|
|
650
|
-
return await request.send(api.getGameSHA())
|
|
651
|
-
} else {
|
|
652
|
-
return {
|
|
653
|
-
status: null,
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
},
|
|
657
|
-
fetchStatus: async (context, event) => {
|
|
658
|
-
if (request.getToken()) {
|
|
659
|
-
return await request.send(api.getGameStatus())
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
})
|