@jetthai/cuora 1.0.177 → 1.0.179
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 +4 -0
- package/package.json +1 -1
- package/src/machine/auth.js +18 -10
- package/src/machine/game_v2.js +126 -12
- package/src/machine/side_v2.js +5 -2
- package/src/util/constant.js +2 -1
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.0.179](https://github.com/jetthai/cuora-module/compare/v1.0.178...v1.0.179) (2022-09-26)
|
|
6
|
+
|
|
7
|
+
### [1.0.178](https://github.com/jetthai/cuora-module/compare/v1.0.177...v1.0.178) (2022-09-26)
|
|
8
|
+
|
|
5
9
|
### [1.0.177](https://github.com/jetthai/cuora-module/compare/v1.0.168-1...v1.0.177) (2022-09-23)
|
|
6
10
|
|
|
7
11
|
### [1.0.176](https://github.com/jetthai/cuora-module/compare/v1.0.175...v1.0.176) (2022-09-23)
|
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -11,6 +11,7 @@ export default function (request) {
|
|
|
11
11
|
const { clientId, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
12
12
|
const tokenKey = `cuora_${clientId}`
|
|
13
13
|
const userKey = `cuora_tempuser`
|
|
14
|
+
const phoneCountryCode = 'phone_countrycode'
|
|
14
15
|
const accountPhoneKey = 'account_phone'
|
|
15
16
|
const accountEmailKey = 'account_email'
|
|
16
17
|
const cookies = new Cookies()
|
|
@@ -31,6 +32,7 @@ export default function (request) {
|
|
|
31
32
|
username: null,
|
|
32
33
|
password: null,
|
|
33
34
|
},
|
|
35
|
+
countryAbbr: null,
|
|
34
36
|
userInfo: {},
|
|
35
37
|
redirectURL: null,
|
|
36
38
|
reCaptchaToken: null,
|
|
@@ -209,7 +211,7 @@ export default function (request) {
|
|
|
209
211
|
}
|
|
210
212
|
}),
|
|
211
213
|
setLoginPhone: assign((context, event) => {
|
|
212
|
-
const { countryCode, phone, password } = event.data
|
|
214
|
+
const { countryCode, countryAbbr, phone, password } = event.data
|
|
213
215
|
return {
|
|
214
216
|
loginData: {
|
|
215
217
|
provider: 'phone',
|
|
@@ -217,6 +219,7 @@ export default function (request) {
|
|
|
217
219
|
phone,
|
|
218
220
|
password,
|
|
219
221
|
},
|
|
222
|
+
countryAbbr,
|
|
220
223
|
}
|
|
221
224
|
}),
|
|
222
225
|
setLoginEmail: assign((context, event) => {
|
|
@@ -261,12 +264,17 @@ export default function (request) {
|
|
|
261
264
|
setAccount: assign((context, event) => {
|
|
262
265
|
if (context.loginData.phone) {
|
|
263
266
|
cookies.remove(accountEmailKey)
|
|
264
|
-
cookies.set(accountPhoneKey,
|
|
267
|
+
cookies.set(accountPhoneKey, `${context.loginData.phone}`, {
|
|
268
|
+
path: '/',
|
|
269
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
270
|
+
})
|
|
271
|
+
cookies.set(phoneCountryCode, `${context.countryAbbr}_${context.loginData.countryCode}`, {
|
|
265
272
|
path: '/',
|
|
266
273
|
maxAge: 60 * 60 * 24 * 7,
|
|
267
274
|
})
|
|
268
275
|
} else if (context.loginData.email) {
|
|
269
276
|
cookies.remove(accountPhoneKey)
|
|
277
|
+
cookies.remove(phoneCountryCode)
|
|
270
278
|
cookies.set(accountEmailKey, context.loginData.email, {
|
|
271
279
|
path: '/',
|
|
272
280
|
maxAge: 60 * 60 * 24 * 7,
|
|
@@ -306,14 +314,14 @@ export default function (request) {
|
|
|
306
314
|
const redirectURL = urljoin(
|
|
307
315
|
request.config.fullURL,
|
|
308
316
|
'login?' +
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
+
new URLSearchParams({
|
|
318
|
+
provider,
|
|
319
|
+
redirectURI: `${window.location.protocol}//${window.location.host}`,
|
|
320
|
+
channel: cookies.get('channel') || channel || defaultChannel || 'official',
|
|
321
|
+
subchannel: cookies.get('subchannel') || subchannel || defaultSubchannel || 'pwa',
|
|
322
|
+
// dt,
|
|
323
|
+
platform: 'pwa',
|
|
324
|
+
}).toString()
|
|
317
325
|
)
|
|
318
326
|
window.location.href = redirectURL
|
|
319
327
|
},
|
package/src/machine/game_v2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import api from '../api/game.js'
|
|
3
3
|
import UAParser from 'ua-parser-js'
|
|
4
|
-
import { MY_FAVORITE } from '../util/constant.js'
|
|
4
|
+
import { MY_FAVORITE, GAME_SEARCH } from '../util/constant.js'
|
|
5
5
|
|
|
6
6
|
export default function (request) {
|
|
7
7
|
return createMachine(
|
|
@@ -29,6 +29,7 @@ export default function (request) {
|
|
|
29
29
|
lang: 'en_US',
|
|
30
30
|
isMobile: new UAParser().getResult().device.type,
|
|
31
31
|
gameURL: null,
|
|
32
|
+
...oldContext
|
|
32
33
|
},
|
|
33
34
|
states: {
|
|
34
35
|
flow: {
|
|
@@ -173,6 +174,60 @@ export default function (request) {
|
|
|
173
174
|
},
|
|
174
175
|
},
|
|
175
176
|
},
|
|
177
|
+
oldTimer: {
|
|
178
|
+
initial: 'fetchingGameSHA',
|
|
179
|
+
states: {
|
|
180
|
+
fetchingGameSHA: {
|
|
181
|
+
invoke: {
|
|
182
|
+
src: 'fetchGameSHA',
|
|
183
|
+
onDone: {
|
|
184
|
+
target: 'checking',
|
|
185
|
+
actions: 'setGameSHA',
|
|
186
|
+
},
|
|
187
|
+
onError: {
|
|
188
|
+
target: 'pending',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
checking: {
|
|
193
|
+
always: [
|
|
194
|
+
{ target: 'updatingStatus', cond: 'isStatusChanged' },
|
|
195
|
+
{ target: 'pending' },
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
updatingStatus: {
|
|
199
|
+
invoke: {
|
|
200
|
+
src: 'fetchStatus',
|
|
201
|
+
onDone: {
|
|
202
|
+
target: 'updatingOption',
|
|
203
|
+
actions: ['setStatus'],
|
|
204
|
+
},
|
|
205
|
+
onError: {
|
|
206
|
+
target: 'pending',
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
updatingOption: {
|
|
211
|
+
invoke: {
|
|
212
|
+
src: 'fetchOption',
|
|
213
|
+
onDone: {
|
|
214
|
+
target: 'pending',
|
|
215
|
+
actions: 'mergeOption',
|
|
216
|
+
},
|
|
217
|
+
onError: {
|
|
218
|
+
target: 'pending',
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
pending: {
|
|
223
|
+
after: {
|
|
224
|
+
20000: {
|
|
225
|
+
target: 'fetchingGameSHA',
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
},
|
|
176
231
|
},
|
|
177
232
|
},
|
|
178
233
|
{
|
|
@@ -200,19 +255,24 @@ export default function (request) {
|
|
|
200
255
|
}),
|
|
201
256
|
appendContent: assign((context, event) => {
|
|
202
257
|
const { room, favoriteList } = context
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
258
|
+
if (room.categoryId === GAME_SEARCH) {
|
|
259
|
+
return
|
|
260
|
+
} else {
|
|
261
|
+
const { data, ...rest } = event.data
|
|
262
|
+
return {
|
|
263
|
+
favoriteList: room.categoryId === MY_FAVORITE ? data : favoriteList,
|
|
264
|
+
content: {
|
|
265
|
+
...context.content,
|
|
266
|
+
...rest,
|
|
267
|
+
data: context.content.data.concat(data),
|
|
268
|
+
},
|
|
269
|
+
}
|
|
211
270
|
}
|
|
212
271
|
}),
|
|
213
272
|
swapContent: assign((context, event) => {
|
|
214
273
|
const { room, favoriteList } = context
|
|
215
|
-
|
|
274
|
+
const item = event.data
|
|
275
|
+
if (item.data?.length) {
|
|
216
276
|
return {
|
|
217
277
|
favoriteList: room.categoryId === MY_FAVORITE ? event.data.data : favoriteList,
|
|
218
278
|
content: event.data,
|
|
@@ -250,6 +310,7 @@ export default function (request) {
|
|
|
250
310
|
favoriteList: context.favoriteList.filter((item) => item.gameCode !== event.data.gameCode),
|
|
251
311
|
}
|
|
252
312
|
}),
|
|
313
|
+
...oldActions
|
|
253
314
|
},
|
|
254
315
|
guards: {
|
|
255
316
|
isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
|
|
@@ -257,6 +318,7 @@ export default function (request) {
|
|
|
257
318
|
hasRoom: (context, event) => context.room?.categoryId,
|
|
258
319
|
isFavorite: (context, event) => context.favoriteList.some((item) => item.gameCode === event.data.gameCode),
|
|
259
320
|
isNotFavorite: (context, event) => !context.favoriteList.some((item) => item.gameCode === event.data.gameCode),
|
|
321
|
+
...oldGuards
|
|
260
322
|
},
|
|
261
323
|
services: {
|
|
262
324
|
getFavorite: async (context, event) => {
|
|
@@ -264,7 +326,9 @@ export default function (request) {
|
|
|
264
326
|
},
|
|
265
327
|
getPageContent: async (context, event) => {
|
|
266
328
|
const { room, index } = context
|
|
267
|
-
if (room.categoryId ===
|
|
329
|
+
if (room.categoryId === GAME_SEARCH) {
|
|
330
|
+
return
|
|
331
|
+
} else if (room.categoryId === MY_FAVORITE) {
|
|
268
332
|
return await request.send(api.getListMyFavorite())
|
|
269
333
|
} else {
|
|
270
334
|
return await request.send(api.getListCategory({ categoryId: room.categoryId, index }))
|
|
@@ -272,7 +336,9 @@ export default function (request) {
|
|
|
272
336
|
},
|
|
273
337
|
updatePageContent: async (context, event) => {
|
|
274
338
|
const { room, content, index } = context
|
|
275
|
-
if (room.categoryId ===
|
|
339
|
+
if (room.categoryId === GAME_SEARCH) {
|
|
340
|
+
return
|
|
341
|
+
} else if (room.categoryId === MY_FAVORITE) {
|
|
276
342
|
// return await request.send(api.getListMyFavorite({ timestamp: content.timestamp }))
|
|
277
343
|
} else {
|
|
278
344
|
return await request.send(
|
|
@@ -321,7 +387,55 @@ export default function (request) {
|
|
|
321
387
|
throw event.data
|
|
322
388
|
}
|
|
323
389
|
},
|
|
390
|
+
...oldServices(request)
|
|
324
391
|
},
|
|
325
392
|
}
|
|
326
393
|
)
|
|
327
394
|
}
|
|
395
|
+
|
|
396
|
+
const oldContext = {
|
|
397
|
+
sha: {
|
|
398
|
+
status: null,
|
|
399
|
+
},
|
|
400
|
+
isStatusChanged: false,
|
|
401
|
+
statusMap: {},
|
|
402
|
+
optionMap: {},
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const oldActions = {
|
|
406
|
+
setGameSHA: assign((context, event) => {
|
|
407
|
+
const { sha } = context
|
|
408
|
+
const newSha = event.data
|
|
409
|
+
return {
|
|
410
|
+
sha: newSha,
|
|
411
|
+
isStatusChanged: !sha.status || sha.status !== newSha.status,
|
|
412
|
+
}
|
|
413
|
+
}),
|
|
414
|
+
setStatus: assign((context, event) => {
|
|
415
|
+
return {
|
|
416
|
+
statusMap: event.data,
|
|
417
|
+
}
|
|
418
|
+
}),
|
|
419
|
+
mergeOption: assign((context, event) => {
|
|
420
|
+
const { optionMap } = context
|
|
421
|
+
return {
|
|
422
|
+
optionMap: { ...optionMap, ...event.data },
|
|
423
|
+
}
|
|
424
|
+
}),
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const oldGuards = {
|
|
428
|
+
isStatusChanged: (context, event) => context.isStatusChanged,
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const oldServices = (request) => ({
|
|
432
|
+
fetchOption: async (context, event) => {
|
|
433
|
+
return await request.send(api.getOptionMap())
|
|
434
|
+
},
|
|
435
|
+
fetchGameSHA: async (context, event) => {
|
|
436
|
+
return await request.send(api.getGameSHA())
|
|
437
|
+
},
|
|
438
|
+
fetchStatus: async (context, event) => {
|
|
439
|
+
return await request.send(api.getGameStatus())
|
|
440
|
+
},
|
|
441
|
+
})
|
package/src/machine/side_v2.js
CHANGED
|
@@ -73,8 +73,11 @@ export default function (request) {
|
|
|
73
73
|
return { menu }
|
|
74
74
|
}),
|
|
75
75
|
setDefaultMenuItemStack: assign((context, event) => {
|
|
76
|
-
const
|
|
77
|
-
|
|
76
|
+
const menu = event.data
|
|
77
|
+
if (menu.data.length > 0) {
|
|
78
|
+
const menuItemStack = getDefaultItem(menu.data[0])
|
|
79
|
+
return { menuItemStack }
|
|
80
|
+
}
|
|
78
81
|
}),
|
|
79
82
|
setMenuItemStack: assign((context, event) => {
|
|
80
83
|
const { menuItemStack } = context
|
package/src/util/constant.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export const MY_FAVORITE = 'MyFavorite'
|
|
1
|
+
export const MY_FAVORITE = 'MyFavorite'
|
|
2
|
+
export const GAME_SEARCH = 'GameSearch'
|