@jetthai/cuora 1.2.0 → 2.0.0-beta.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/BREAKING_CHANGES.md +9 -0
- package/CHANGELOG.md +36 -0
- package/package.json +5 -2
- package/resetGitBranch.sh +16 -16
- package/src/api/account.js +8 -0
- package/src/api/auth.js +1 -1
- package/src/api/common.js +6 -1
- package/src/api/index.js +3 -1
- package/src/api/otp.js +5 -0
- package/src/api/user.js +1 -0
- package/src/machine/activity/activity.js +23 -19
- package/src/machine/activity/activity_cash.js +27 -22
- package/src/machine/activity/cash_rain_activity.js +1 -0
- package/src/machine/activity/continue_deposit_activity.js +1 -0
- package/src/machine/activity/deposit_activity.js +1 -0
- package/src/machine/activity/diamond_shop_activity_cash.js +7 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +1 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +1 -0
- package/src/machine/activity/fafafa_activity.js +1 -0
- package/src/machine/activity/friend_invite_friends_activity.js +7 -8
- package/src/machine/activity/instant_rebate_activity.js +1 -0
- package/src/machine/activity/invite_friends_activity.js +1 -0
- package/src/machine/activity/jackpot.js +1 -0
- package/src/machine/activity/mini_game_activity.js +1 -0
- package/src/machine/activity/otp_verified_activity.js +1 -0
- package/src/machine/activity/ranking_activity.js +1 -0
- package/src/machine/activity/return_bonus_activity.js +3 -1
- package/src/machine/activity/roulette_activity_v2.js +6 -0
- package/src/machine/activity/sign_in_activity.js +1 -0
- package/src/machine/activity/sign_in_monthly_activity.js +2 -1
- package/src/machine/activity/specify_bets_activity.js +1 -0
- package/src/machine/activity/specify_turnover_activity.js +1 -0
- package/src/machine/activity/time_bomb_activity.js +1 -0
- package/src/machine/activity/vip_card_activity.js +1 -0
- package/src/machine/auth.js +18 -6
- package/src/machine/auth_otp_v2.js +1 -0
- package/src/machine/auth_otp_v3.js +48 -11
- package/src/machine/bank_binding.js +1 -0
- package/src/machine/bank_binding_amb.js +1 -0
- package/src/machine/bonus.js +1 -0
- package/src/machine/common.js +24 -4
- package/src/machine/deposit/amb.js +1 -0
- package/src/machine/deposit/crypto_bank.js +20 -5
- package/src/machine/deposit/crypto_bank_cash.js +35 -9
- package/src/machine/deposit/crypto_qrcode.js +11 -1
- package/src/machine/deposit/crypto_qrcode_cash.js +24 -1
- package/src/machine/deposit/crypto_way.js +11 -5
- package/src/machine/deposit/crypto_way_cash.js +15 -6
- package/src/machine/deposit/deposit_fc.js +1 -0
- package/src/machine/deposit/direct.js +1 -0
- package/src/machine/deposit/direct_cash.js +1 -0
- package/src/machine/deposit/float.js +1 -0
- package/src/machine/deposit/krway.js +1 -0
- package/src/machine/deposit/loadcard_cash.js +2 -1
- package/src/machine/deposit/loadcard_vn.js +1 -0
- package/src/machine/deposit/manual_cash.js +1 -0
- package/src/machine/deposit/manual_vn.js +1 -0
- package/src/machine/deposit/qrcode_cash.js +6 -5
- package/src/machine/deposit/qrcode_v2.js +1 -0
- package/src/machine/deposit/usdt.js +23 -4
- package/src/machine/deposit/usdt_cash.js +15 -1
- package/src/machine/deposit/virtual_bank_cash.js +11 -9
- package/src/machine/deposit/virtual_bank_vn.js +1 -0
- package/src/machine/deposit/vpay.js +7 -0
- package/src/machine/error.js +1 -0
- package/src/machine/game_betslip.js +1 -0
- package/src/machine/game_favorite_v2.js +1 -0
- package/src/machine/game_hot_new.js +1 -0
- package/src/machine/game_info.js +5 -0
- package/src/machine/game_replay.js +1 -0
- package/src/machine/game_search_cash.js +1 -0
- package/src/machine/game_search_v2.js +1 -0
- package/src/machine/game_v2_1.js +88 -46
- package/src/machine/honor_board.js +1 -0
- package/src/machine/honor_board_cash.js +11 -8
- package/src/machine/inbox.js +93 -43
- package/src/machine/leaderboard.js +1 -0
- package/src/machine/merge.js +1 -0
- package/src/machine/navbar.js +3 -1
- package/src/machine/payment_data.js +1 -0
- package/src/machine/promotions.js +11 -18
- package/src/machine/ranking.js +5 -2
- package/src/machine/reward.js +1 -0
- package/src/machine/reward_cash.js +1 -0
- package/src/machine/reward_fc.js +1 -0
- package/src/machine/roulette_v2.js +18 -26
- package/src/machine/setting.js +1 -0
- package/src/machine/side.js +10 -4
- package/src/machine/side_cash.js +1 -0
- package/src/machine/side_v2.js +38 -24
- package/src/machine/user_info.js +1 -0
- package/src/machine/user_photo.js +1 -0
- package/src/machine/user_reset_password.js +5 -2
- package/src/machine/user_sign_up.js +1 -0
- package/src/machine/vip_table.js +1 -0
- package/src/machine/websocket.js +42 -14
- package/src/machine/welcome.js +1 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +1 -0
- package/src/machine/withdraw/withdraw_krway.js +1 -0
- package/src/machine/withdraw/withdraw_manual.js +16 -8
- package/src/machine/withdraw/withdraw_manual_cash.js +1 -0
- package/src/request/request.js +34 -30
- package/src/util/deviceToken.js +7 -6
- package/src/util/storage.js +4 -3
- package/test/api.behavior.test.js +69 -0
- package/test/api.contract.test.js +18 -0
- package/test/config.test.js +27 -0
- package/test/deviceToken.test.js +139 -0
- package/test/helpers.coverage.test.js +11 -0
- package/test/helpers.js +91 -0
- package/test/index.exports.test.js +14 -0
- package/test/machine.activity.core.coverage.test.js +337 -0
- package/test/machine.activity.gap.coverage.test.js +252 -0
- package/test/machine.activity.more.coverage.test.js +180 -0
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +201 -0
- package/test/machine.activity_timer_bonus.coverage.test.js +136 -0
- package/test/machine.activity_welcome.low.coverage.test.js +211 -0
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +201 -0
- package/test/machine.auth.coverage.test.js +215 -0
- package/test/machine.bank_binding.test.js +143 -0
- package/test/machine.binding_otp_krway.coverage.test.js +223 -0
- package/test/machine.contract.test.js +50 -0
- package/test/machine.crypto_bank.coverage.test.js +270 -0
- package/test/machine.crypto_way.coverage.test.js +108 -0
- package/test/machine.crypto_way_cash.coverage.test.js +114 -0
- package/test/machine.definition.test.js +137 -0
- package/test/machine.deposit.manual.coverage.test.js +365 -0
- package/test/machine.deposit_fc.coverage.test.js +126 -0
- package/test/machine.direct.coverage.test.js +96 -0
- package/test/machine.direct_cash.coverage.test.js +108 -0
- package/test/machine.error.coverage.test.js +37 -0
- package/test/machine.events.test.js +126 -0
- package/test/machine.favorite_jackpot.coverage.test.js +82 -0
- package/test/machine.float.coverage.test.js +136 -0
- package/test/machine.flow.test.js +226 -0
- package/test/machine.game_hot_new_vip_table.coverage.test.js +105 -0
- package/test/machine.game_search_cash.coverage.test.js +155 -0
- package/test/machine.game_search_v2.test.js +199 -0
- package/test/machine.game_user_profile.coverage.test.js +100 -0
- package/test/machine.honor_board.test.js +133 -0
- package/test/machine.inbox.common.coverage.test.js +304 -0
- package/test/machine.loadcard_cash.coverage.test.js +101 -0
- package/test/machine.loadcard_vn.coverage.test.js +122 -0
- package/test/machine.misc.coverage.test.js +361 -0
- package/test/machine.more2.coverage.test.js +261 -0
- package/test/machine.options.execution.test.js +272 -0
- package/test/machine.priority.coverage.test.js +603 -0
- package/test/machine.qrcode_cash.coverage.test.js +107 -0
- package/test/machine.qrcode_v2.coverage.test.js +121 -0
- package/test/machine.regression.test.js +82 -0
- package/test/machine.roulette_v2.test.js +142 -0
- package/test/machine.side_reward_reset.coverage.test.js +220 -0
- package/test/machine.targeted.coverage.test.js +313 -0
- package/test/machine.usdt.coverage.test.js +95 -0
- package/test/machine.usdt_cash.coverage.test.js +73 -0
- package/test/machine.vip_card_activity.test.js +114 -0
- package/test/machine.virtual_bank_cash.coverage.test.js +105 -0
- package/test/machine.virtual_bank_vn.coverage.test.js +105 -0
- package/test/machine.vpay.coverage.test.js +142 -0
- package/test/machine.withdraw_crypto_cash.coverage.test.js +166 -0
- package/test/machine.withdraw_krway.coverage.test.js +123 -0
- package/test/machine.withdraw_manual.coverage.test.js +185 -0
- package/test/machine.withdraw_manual_cash.coverage.test.js +123 -0
- package/test/request.test.js +325 -0
- package/test/util.storage.errors.test.js +47 -0
- package/test/util.test.js +41 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import { max } from '../../util'
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
6
6
|
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'qrcode_cash',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'loading',
|
|
11
12
|
context: {
|
|
12
13
|
currentCategory: 'loadcard',
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import { max } from '../../util'
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
6
6
|
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'qrcode_cash',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'loading',
|
|
11
12
|
context: {
|
|
12
13
|
paymentDetail,
|
|
@@ -136,15 +137,15 @@ export default function (request, context) {
|
|
|
136
137
|
}),
|
|
137
138
|
setPromotion: assign((context, event) => {
|
|
138
139
|
const { selectedAmount } = context
|
|
139
|
-
const promotion = event.data
|
|
140
|
-
const qrcodes = context.qrcodes
|
|
140
|
+
const promotion = event.data || {}
|
|
141
|
+
const qrcodes = Array.isArray(context.qrcodes) ? context.qrcodes : []
|
|
141
142
|
const selectedQrcode = qrcodes[0]
|
|
142
143
|
return {
|
|
143
144
|
promotion,
|
|
144
145
|
qrcodes,
|
|
145
146
|
selectedQrcode,
|
|
146
147
|
options: selectedQrcode?.optional,
|
|
147
|
-
selectedAmount: max(promotion
|
|
148
|
+
selectedAmount: max(promotion?.minimumAmount, selectedQrcode?.minimum, selectedAmount, 0),
|
|
148
149
|
calculation: null,
|
|
149
150
|
}
|
|
150
151
|
}),
|
|
@@ -195,7 +196,7 @@ export default function (request, context) {
|
|
|
195
196
|
},
|
|
196
197
|
guards: {
|
|
197
198
|
hasQrcodeMethods: (context, event) => {
|
|
198
|
-
return context.paymentDetail?.
|
|
199
|
+
return context.paymentDetail?.some((element) => element.category === context.currentCategory) || false
|
|
199
200
|
},
|
|
200
201
|
},
|
|
201
202
|
services: {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
3
|
|
|
4
4
|
export default function (request) {
|
|
5
5
|
return createMachine(
|
|
6
6
|
{
|
|
7
7
|
id: 'usdt',
|
|
8
|
+
predictableActionArguments: true,
|
|
8
9
|
initial: 'loading',
|
|
9
10
|
context: {
|
|
10
11
|
paymentDetails: [],
|
|
@@ -74,8 +75,17 @@ export default function (request) {
|
|
|
74
75
|
{
|
|
75
76
|
actions: {
|
|
76
77
|
setPayment: assign((context, event) => {
|
|
77
|
-
const
|
|
78
|
-
const
|
|
78
|
+
const paymentDetails = Array.isArray(event.data) ? event.data : []
|
|
79
|
+
const currentPayment = paymentDetails.find((element) => element.category === context.currentCategory)
|
|
80
|
+
if (!currentPayment) {
|
|
81
|
+
return {
|
|
82
|
+
networks: [],
|
|
83
|
+
selectedNetwork: null,
|
|
84
|
+
currentPayment: null,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const networkNames = Array.isArray(currentPayment.networkName) ? currentPayment.networkName : []
|
|
88
|
+
const defaultNetworks = networkNames.map((value, i) => {
|
|
79
89
|
return {
|
|
80
90
|
label: currentPayment.networkOptional?.[i],
|
|
81
91
|
value,
|
|
@@ -85,7 +95,7 @@ export default function (request) {
|
|
|
85
95
|
|
|
86
96
|
return {
|
|
87
97
|
networks: defaultNetworks,
|
|
88
|
-
selectedNetwork: defaultNetworks[0],
|
|
98
|
+
selectedNetwork: defaultNetworks[0] || null,
|
|
89
99
|
currentPayment,
|
|
90
100
|
}
|
|
91
101
|
}),
|
|
@@ -94,6 +104,9 @@ export default function (request) {
|
|
|
94
104
|
}),
|
|
95
105
|
setResultFromLocal: assign((context, event) => {
|
|
96
106
|
const { resultMap, selectedNetwork } = context
|
|
107
|
+
if (!selectedNetwork) {
|
|
108
|
+
return {}
|
|
109
|
+
}
|
|
97
110
|
return { result: resultMap[selectedNetwork.value] }
|
|
98
111
|
}),
|
|
99
112
|
setResult: assign((context, event) => {
|
|
@@ -121,6 +134,9 @@ export default function (request) {
|
|
|
121
134
|
guards: {
|
|
122
135
|
isFound: (context, event) => {
|
|
123
136
|
const { resultMap, selectedNetwork } = context
|
|
137
|
+
if (!selectedNetwork) {
|
|
138
|
+
return false
|
|
139
|
+
}
|
|
124
140
|
return resultMap[selectedNetwork.value]
|
|
125
141
|
},
|
|
126
142
|
},
|
|
@@ -130,6 +146,9 @@ export default function (request) {
|
|
|
130
146
|
},
|
|
131
147
|
submitDeposit: async (context, event) => {
|
|
132
148
|
const { currentPayment, selectedNetwork } = context
|
|
149
|
+
if (!currentPayment || !selectedNetwork) {
|
|
150
|
+
throw { code: 'ERR_INVALID_USDT_NETWORK' }
|
|
151
|
+
}
|
|
133
152
|
return await request.send(
|
|
134
153
|
payment.submitDepositTransactionCrypto({
|
|
135
154
|
method: currentPayment.method,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
3
|
|
|
4
4
|
export default function (request, context) {
|
|
5
5
|
const { paymentDetail = [] } = context || {}
|
|
6
6
|
return createMachine(
|
|
7
7
|
{
|
|
8
8
|
id: 'usdt',
|
|
9
|
+
predictableActionArguments: true,
|
|
9
10
|
initial: 'loading',
|
|
10
11
|
context: {
|
|
11
12
|
paymentDetail,
|
|
@@ -74,6 +75,13 @@ export default function (request, context) {
|
|
|
74
75
|
const currentPayment = context.paymentDetail.find(
|
|
75
76
|
(element) => element.transferType === 'deposit' && element.category === context.currentCategory
|
|
76
77
|
)
|
|
78
|
+
if (!currentPayment) {
|
|
79
|
+
return {
|
|
80
|
+
networks: [],
|
|
81
|
+
selectedNetwork: null,
|
|
82
|
+
currentPayment: null,
|
|
83
|
+
}
|
|
84
|
+
}
|
|
77
85
|
const defaultNetworks = currentPayment.networkName.map((value, i) => {
|
|
78
86
|
return {
|
|
79
87
|
label: currentPayment.networkOptional?.[i],
|
|
@@ -92,6 +100,9 @@ export default function (request, context) {
|
|
|
92
100
|
}),
|
|
93
101
|
setResultFromLocal: assign((context, event) => {
|
|
94
102
|
const { resultMap, selectedNetwork } = context
|
|
103
|
+
if (!selectedNetwork) {
|
|
104
|
+
return {}
|
|
105
|
+
}
|
|
95
106
|
return { result: resultMap[selectedNetwork.value] }
|
|
96
107
|
}),
|
|
97
108
|
setResult: assign((context, event) => {
|
|
@@ -118,6 +129,9 @@ export default function (request, context) {
|
|
|
118
129
|
guards: {
|
|
119
130
|
isFound: (context, event) => {
|
|
120
131
|
const { resultMap, selectedNetwork } = context
|
|
132
|
+
if (!selectedNetwork) {
|
|
133
|
+
return false
|
|
134
|
+
}
|
|
121
135
|
return resultMap[selectedNetwork.value]
|
|
122
136
|
},
|
|
123
137
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '
|
|
3
|
-
import { max } from '
|
|
2
|
+
import payment from '../../api/payment.js'
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
4
4
|
|
|
5
5
|
export default function (request, context) {
|
|
6
6
|
const { appSecret } = request.config
|
|
@@ -9,6 +9,7 @@ export default function (request, context) {
|
|
|
9
9
|
return createMachine(
|
|
10
10
|
{
|
|
11
11
|
id: 'virtual_bank_cash',
|
|
12
|
+
predictableActionArguments: true,
|
|
12
13
|
initial: 'loading',
|
|
13
14
|
context: {
|
|
14
15
|
siteConfig,
|
|
@@ -112,13 +113,13 @@ export default function (request, context) {
|
|
|
112
113
|
setInitData: assign((context, event) => {
|
|
113
114
|
const { currentPayment } = event.data
|
|
114
115
|
|
|
115
|
-
const processing = currentPayment?.processing?.[0]
|
|
116
|
+
const processing = currentPayment?.processing?.[0] || null
|
|
116
117
|
|
|
117
|
-
const virtualBanks = currentPayment?.virtualBanks?.[0]
|
|
118
|
+
const virtualBanks = currentPayment?.virtualBanks?.[0] || null
|
|
118
119
|
|
|
119
120
|
return {
|
|
120
121
|
currentPayment,
|
|
121
|
-
method: currentPayment
|
|
122
|
+
method: currentPayment?.method || null,
|
|
122
123
|
processing,
|
|
123
124
|
selectedAmount: max(promotion?.minimumAmount, currentPayment?.minimum, selectedAmount, 0),
|
|
124
125
|
virtualBanks,
|
|
@@ -163,10 +164,11 @@ export default function (request, context) {
|
|
|
163
164
|
},
|
|
164
165
|
guards: {
|
|
165
166
|
isCalculable: (context, event) => {
|
|
166
|
-
const {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
167
|
+
const { selectedAmount, currentPayment } = context
|
|
168
|
+
if (!currentPayment) {
|
|
169
|
+
return false
|
|
170
|
+
}
|
|
171
|
+
const { maximum, minimum } = currentPayment
|
|
170
172
|
return selectedAmount && minimum <= +selectedAmount && +selectedAmount <= maximum
|
|
171
173
|
},
|
|
172
174
|
isProcessing: (context, event) => {
|
|
@@ -7,6 +7,7 @@ export default function (request) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'vpay',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'loading',
|
|
11
12
|
context: {
|
|
12
13
|
method: 'vpay',
|
|
@@ -304,6 +305,12 @@ export default function (request) {
|
|
|
304
305
|
calculation: null,
|
|
305
306
|
}
|
|
306
307
|
}),
|
|
308
|
+
reset: assign(() => {
|
|
309
|
+
return {
|
|
310
|
+
amount: 0,
|
|
311
|
+
calculation: null,
|
|
312
|
+
}
|
|
313
|
+
}),
|
|
307
314
|
},
|
|
308
315
|
guards: {
|
|
309
316
|
hasUserAccount: (context, event) => {
|
package/src/machine/error.js
CHANGED
package/src/machine/game_info.js
CHANGED
|
@@ -7,6 +7,7 @@ export default function (request, context) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'game_info',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'fetching',
|
|
11
12
|
context: {
|
|
12
13
|
gameInfo: {},
|
|
@@ -49,6 +50,10 @@ export default function (request, context) {
|
|
|
49
50
|
services: {
|
|
50
51
|
// 取得遊戲資訊
|
|
51
52
|
fetchGameInfo: async (context, event) => {
|
|
53
|
+
// [防呆] 確保有 gameCode
|
|
54
|
+
if (!gameCode) {
|
|
55
|
+
return { data: {} }
|
|
56
|
+
}
|
|
52
57
|
return await request.send(game.getGameInfo({ appSecret, gameCode }))
|
|
53
58
|
},
|
|
54
59
|
},
|
package/src/machine/game_v2_1.js
CHANGED
|
@@ -9,6 +9,7 @@ export default function (request) {
|
|
|
9
9
|
return createMachine(
|
|
10
10
|
{
|
|
11
11
|
id: 'game',
|
|
12
|
+
predictableActionArguments: true,
|
|
12
13
|
type: 'parallel',
|
|
13
14
|
context: {
|
|
14
15
|
base: '/',
|
|
@@ -185,7 +186,7 @@ export default function (request) {
|
|
|
185
186
|
src: 'demoGame',
|
|
186
187
|
onDone: {
|
|
187
188
|
target: 'playingDemo',
|
|
188
|
-
actions: 'setGameURL',
|
|
189
|
+
actions: ['setGameURL', 'setGameDemoStatus'],
|
|
189
190
|
},
|
|
190
191
|
onError: {
|
|
191
192
|
target: 'idle',
|
|
@@ -390,29 +391,32 @@ export default function (request) {
|
|
|
390
391
|
}),
|
|
391
392
|
appendContent: assign((context, event) => {
|
|
392
393
|
const { room, additionEnable } = context
|
|
393
|
-
if (room
|
|
394
|
+
if (room?.categoryId === GAME_SEARCH) {
|
|
394
395
|
return
|
|
395
396
|
} else if (additionEnable) {
|
|
396
397
|
const [content, addition = {}] = event.data
|
|
398
|
+
const contentData = Array.isArray(content?.data) ? content.data : []
|
|
399
|
+
const additionData = Array.isArray(addition?.data) ? addition.data : []
|
|
397
400
|
return {
|
|
398
401
|
content: {
|
|
399
402
|
...context.content,
|
|
400
403
|
...content,
|
|
401
|
-
data: context.content.data.concat(
|
|
404
|
+
data: context.content.data.concat(contentData),
|
|
402
405
|
},
|
|
403
406
|
addition: {
|
|
404
407
|
...context.addition,
|
|
405
408
|
...addition,
|
|
406
|
-
data: context.addition.data.concat(
|
|
409
|
+
data: context.addition.data.concat(additionData),
|
|
407
410
|
},
|
|
408
411
|
}
|
|
409
412
|
} else {
|
|
410
413
|
const [content] = event.data
|
|
414
|
+
const contentData = Array.isArray(content?.data) ? content.data : []
|
|
411
415
|
return {
|
|
412
416
|
content: {
|
|
413
417
|
...context.content,
|
|
414
418
|
...content,
|
|
415
|
-
data: context.content.data.concat(
|
|
419
|
+
data: context.content.data.concat(contentData),
|
|
416
420
|
},
|
|
417
421
|
}
|
|
418
422
|
}
|
|
@@ -435,19 +439,19 @@ export default function (request) {
|
|
|
435
439
|
}),
|
|
436
440
|
setGameURL: assign({
|
|
437
441
|
type: (context, event) => {
|
|
438
|
-
return event.data
|
|
442
|
+
return event.data?.type
|
|
439
443
|
},
|
|
440
444
|
gameToken: (context, event) => {
|
|
441
|
-
return event.data
|
|
445
|
+
return event.data?.gameToken
|
|
442
446
|
},
|
|
443
447
|
gameHtml: (context, event) => {
|
|
444
|
-
return event.data
|
|
448
|
+
return event.data?.gameHtml
|
|
445
449
|
},
|
|
446
450
|
gameURL: (context, event) => {
|
|
447
|
-
return event.data
|
|
451
|
+
return event.data?.gameURL
|
|
448
452
|
},
|
|
449
453
|
gameWalletType: (context, event) => {
|
|
450
|
-
return event.data
|
|
454
|
+
return event.data?.gameWalletType
|
|
451
455
|
},
|
|
452
456
|
}),
|
|
453
457
|
setGameInfo: assign((context, event) => {
|
|
@@ -465,7 +469,8 @@ export default function (request) {
|
|
|
465
469
|
return { walletType: event.data.walletType }
|
|
466
470
|
}),
|
|
467
471
|
setLang: assign((context, event) => {
|
|
468
|
-
const
|
|
472
|
+
const locale = event.data?.locale
|
|
473
|
+
const lang = typeof locale === 'string' ? locale.replace('-', '_') : context.lang || 'en_US'
|
|
469
474
|
return { lang }
|
|
470
475
|
}),
|
|
471
476
|
setSite: assign((context, event) => {
|
|
@@ -487,6 +492,15 @@ export default function (request) {
|
|
|
487
492
|
isPlaying: event.data,
|
|
488
493
|
}
|
|
489
494
|
}),
|
|
495
|
+
setGameDemoStatus: assign((context, event) => {
|
|
496
|
+
return {
|
|
497
|
+
game: {
|
|
498
|
+
...context.game,
|
|
499
|
+
isDemo: !!event.data?.isDemo,
|
|
500
|
+
},
|
|
501
|
+
}
|
|
502
|
+
}),
|
|
503
|
+
resetSHA: assign(() => ({})),
|
|
490
504
|
},
|
|
491
505
|
guards: {
|
|
492
506
|
isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
|
|
@@ -504,51 +518,72 @@ export default function (request) {
|
|
|
504
518
|
const { room, index, additionEnable, staticData } = context
|
|
505
519
|
let requestChain = null
|
|
506
520
|
if (!request.getToken()) {
|
|
521
|
+
const staticInfoByCategory = new Map((staticData || []).map((item) => [item.category, item.info || []]))
|
|
507
522
|
// 如果沒 token ,id 列表去 static 找
|
|
508
|
-
const list = event.data.list.map((targetCategory
|
|
523
|
+
const list = event.data.list.map((targetCategory) => {
|
|
524
|
+
const categoryInfo = staticInfoByCategory.get(targetCategory.id) || []
|
|
509
525
|
return {
|
|
510
526
|
id: targetCategory.id,
|
|
511
527
|
i18n: targetCategory.i18n,
|
|
512
|
-
downLine:
|
|
513
|
-
.find((item) => item.category === targetCategory.id)
|
|
514
|
-
.info.filter((item) => item.isGame)
|
|
515
|
-
.slice(0, 20),
|
|
528
|
+
downLine: categoryInfo.filter((item) => item.isGame).slice(0, 20),
|
|
516
529
|
}
|
|
517
530
|
})
|
|
518
531
|
return list.filter((item) => item.downLine.length > 0).slice(0, 6)
|
|
519
532
|
} else if (additionEnable) {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
533
|
+
// [防呆] 確保有 categoryId
|
|
534
|
+
const hasCategoryId = !!room?.categoryId
|
|
535
|
+
const param = hasCategoryId ? { categoryId: room.categoryId, index, appSecret } : null
|
|
536
|
+
// [防呆] 確保有 categoryId
|
|
537
|
+
requestChain = event.data.list
|
|
538
|
+
.filter((category) => category?.id != null)
|
|
539
|
+
.map((category) =>
|
|
540
|
+
request
|
|
541
|
+
.send(
|
|
542
|
+
api.getListCategory({
|
|
543
|
+
categoryId: category.id,
|
|
544
|
+
index: 0,
|
|
545
|
+
appSecret,
|
|
546
|
+
})
|
|
547
|
+
)
|
|
548
|
+
.then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
|
|
549
|
+
)
|
|
550
|
+
const promises = [...requestChain]
|
|
551
|
+
if (hasCategoryId) {
|
|
552
|
+
promises.push(request.send(api.getListAddition(param)))
|
|
553
|
+
}
|
|
554
|
+
const result = await Promise.all(promises)
|
|
555
|
+
return result.filter((item) => item.downLine?.length > 0).slice(0, 6)
|
|
534
556
|
} else {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
557
|
+
// [防呆] 確保有 categoryId
|
|
558
|
+
requestChain = event.data.list
|
|
559
|
+
.filter((category) => category?.id != null)
|
|
560
|
+
.map((category) =>
|
|
561
|
+
request
|
|
562
|
+
.send(
|
|
563
|
+
api.getListCategory({
|
|
564
|
+
categoryId: category.id,
|
|
565
|
+
index: 0,
|
|
566
|
+
appSecret,
|
|
567
|
+
})
|
|
568
|
+
)
|
|
569
|
+
.then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
|
|
570
|
+
)
|
|
546
571
|
const result = await Promise.all([...requestChain])
|
|
547
572
|
return result.filter((item) => item.downLine.length > 0).slice(0, 6)
|
|
548
573
|
}
|
|
549
574
|
},
|
|
550
575
|
getPageContent: async (context, event) => {
|
|
551
576
|
const { room, index, additionEnable, staticData } = context
|
|
577
|
+
// [防呆] 確保有 categoryId
|
|
578
|
+
if (!room?.categoryId) {
|
|
579
|
+
return [
|
|
580
|
+
{
|
|
581
|
+
data: [],
|
|
582
|
+
totalPage: 0,
|
|
583
|
+
timestamp: context.content?.timestamp ?? null,
|
|
584
|
+
},
|
|
585
|
+
]
|
|
586
|
+
}
|
|
552
587
|
if (room.categoryId === GAME_SEARCH) {
|
|
553
588
|
return
|
|
554
589
|
} else if (!request.getToken()) {
|
|
@@ -571,6 +606,10 @@ export default function (request) {
|
|
|
571
606
|
},
|
|
572
607
|
updatePageContent: async (context, event) => {
|
|
573
608
|
const { room, content, index, additionEnable } = context
|
|
609
|
+
// [防呆] 確保有 categoryId
|
|
610
|
+
if (!room?.categoryId) {
|
|
611
|
+
return []
|
|
612
|
+
}
|
|
574
613
|
if (room.categoryId === GAME_SEARCH) {
|
|
575
614
|
return []
|
|
576
615
|
} else if (!request.getToken()) {
|
|
@@ -608,9 +647,14 @@ export default function (request) {
|
|
|
608
647
|
}
|
|
609
648
|
},
|
|
610
649
|
connectGame: async (context, event) => {
|
|
650
|
+
// [防呆] 確保有 providerId 和 gameId
|
|
651
|
+
const { providerId, gameId } = context.game || {}
|
|
652
|
+
if (!providerId || !gameId) {
|
|
653
|
+
return
|
|
654
|
+
}
|
|
611
655
|
const returnProviders = ['RSG', 'KP', 'EPICWIN', 'AMBSLOT', 'SEXY_VENUS', 'SEXY_SEXYBCRT', 'PG', 'NPG']
|
|
612
656
|
const { lang, isMobile, walletType } = context
|
|
613
|
-
const {
|
|
657
|
+
const { gameTypeId, mappingId } = context.game
|
|
614
658
|
const params = {
|
|
615
659
|
provider_id: providerId,
|
|
616
660
|
game_id: gameId,
|
|
@@ -628,7 +672,7 @@ export default function (request) {
|
|
|
628
672
|
return { type, gameToken, gameHtml, gameURL: redirect_url, gameWalletType: wallet_type }
|
|
629
673
|
},
|
|
630
674
|
demoGame: async (context, event) => {
|
|
631
|
-
const { lang, site, isMobile
|
|
675
|
+
const { lang, site, isMobile } = context
|
|
632
676
|
const { providerId, gameId, gameTypeId, mappingId } = context.game
|
|
633
677
|
const params = {
|
|
634
678
|
site,
|
|
@@ -641,9 +685,7 @@ export default function (request) {
|
|
|
641
685
|
appSecret,
|
|
642
686
|
}
|
|
643
687
|
const { type, redirect_url, gameToken, gameHtml, is_demo } = await request.send(api.demoGame(params))
|
|
644
|
-
|
|
645
|
-
game.isDemo = is_demo
|
|
646
|
-
return { type, gameToken, gameHtml, gameURL: redirect_url, game }
|
|
688
|
+
return { type, gameToken, gameHtml, gameURL: redirect_url, isDemo: is_demo }
|
|
647
689
|
},
|
|
648
690
|
disconnectGame: async (context, event) => {
|
|
649
691
|
const uid_site = event.data
|