@everymatrix/lottery-program-wof 1.23.0 → 1.24.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 +7 -0
- package/dist/lottery-program-wof.js +187 -115
- package/dist/lottery-program-wof.js.map +1 -1
- package/package.json +2 -2
- package/src/LotteryProgramWof.svelte +3 -1
- package/src/class.process.ts +79 -24
- package/src/private.item.svg.svelte +10 -1
- package/src/private.message.svelte +11 -3
- package/src/translations.js +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everymatrix/lottery-program-wof",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"main": "dist/lottery-program-wof.js",
|
|
5
5
|
"svelte": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "88308bab2d4819ec71d025befe5d4165e8c092ca"
|
|
43
43
|
}
|
|
@@ -75,7 +75,9 @@
|
|
|
75
75
|
|
|
76
76
|
const fetcher = async () => {
|
|
77
77
|
bonuses = await api.lotteries(endpoint, session)
|
|
78
|
-
|
|
78
|
+
|
|
79
|
+
_postMessage({ type: 'WofStatus', avaliable: bonuses.length > 0 })
|
|
80
|
+
_postMessage({ type: 'wof-private-bonuses', bonuses })
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
const loginAction = (loginevent, loginurl) => {
|
package/src/class.process.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import { api } from "./business"
|
|
2
1
|
import { _postMessage } from "./message"
|
|
3
|
-
import { setMessage
|
|
4
|
-
|
|
2
|
+
import { setMessage } from './business';
|
|
5
3
|
|
|
6
4
|
export class Process {
|
|
7
5
|
|
|
8
|
-
id
|
|
9
|
-
halter
|
|
10
|
-
afterSuccess
|
|
11
|
-
afterSetMessage
|
|
12
|
-
fetcher
|
|
6
|
+
id: string
|
|
7
|
+
halter: Function
|
|
8
|
+
afterSuccess: Function
|
|
9
|
+
afterSetMessage: Function
|
|
10
|
+
fetcher: Function
|
|
11
|
+
|
|
12
|
+
private guid: string
|
|
13
|
+
private isDrawn: boolean = false
|
|
14
|
+
private drawnIndex: number;
|
|
15
|
+
private retryingTimes: number = 0
|
|
16
|
+
private retryingMaxTimes: number = 4
|
|
13
17
|
|
|
14
18
|
constructor(params){
|
|
15
19
|
this.id = params.id
|
|
@@ -19,8 +23,8 @@ export class Process {
|
|
|
19
23
|
this.fetcher = params.fetcher
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
handleHaltProcess(index, message, fn = () => {}){
|
|
23
|
-
|
|
26
|
+
handleHaltProcess(index, message, fn: Function = () => {}){
|
|
27
|
+
_postMessage({ id: this.id, type: 'wof-private-message-spin-before' })
|
|
24
28
|
|
|
25
29
|
const cb = () => {
|
|
26
30
|
setTimeout(() => {
|
|
@@ -33,31 +37,82 @@ export class Process {
|
|
|
33
37
|
// spinner.halt(calc.getDeg(index), cb)
|
|
34
38
|
this.halter(index, cb)
|
|
35
39
|
}
|
|
40
|
+
|
|
41
|
+
getRetryingPeriod() {
|
|
42
|
+
if(this.retryingTimes === 1){
|
|
43
|
+
return 5 * 1000
|
|
44
|
+
}else{
|
|
45
|
+
return 10 * 1000
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
drawInit() {
|
|
50
|
+
this.retryingTimes = 0
|
|
51
|
+
this.guid = undefined
|
|
52
|
+
this.isDrawn = false
|
|
53
|
+
}
|
|
36
54
|
|
|
37
|
-
async drawer (guid
|
|
55
|
+
async drawer (guid?: string){
|
|
56
|
+
if(guid) this.guid = guid
|
|
57
|
+
if(!this.guid) throw new Error('GUID NOT FOUND')
|
|
58
|
+
|
|
59
|
+
if(this.retryingTimes >= this.retryingMaxTimes){
|
|
60
|
+
|
|
61
|
+
if(this.isDrawn){
|
|
62
|
+
this.handleHaltProcess(this.drawnIndex, 'DrawFailed')
|
|
63
|
+
}else{
|
|
64
|
+
this.handleHaltProcess(undefined, 'Timeout')
|
|
65
|
+
}
|
|
38
66
|
|
|
39
|
-
|
|
67
|
+
this.drawInit()
|
|
68
|
+
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.retryingTimes += 1
|
|
72
|
+
|
|
73
|
+
let isFetchSucceeded = false
|
|
74
|
+
let isTimeouted = false
|
|
75
|
+
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
if(!isFetchSucceeded){
|
|
78
|
+
isTimeouted = true
|
|
79
|
+
this.setMessage({
|
|
80
|
+
mode: 'timeout',
|
|
81
|
+
modeValue: 'Retry'
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
}, this.getRetryingPeriod())
|
|
40
85
|
|
|
41
86
|
try {
|
|
42
|
-
const { data, message, index: _index } = await this.fetcher(guid)
|
|
43
|
-
index = _index
|
|
44
|
-
|
|
45
|
-
if(!data.success) throw new Error()
|
|
46
|
-
if(data.item.state === "drawn") throw new Error()
|
|
47
87
|
|
|
48
|
-
|
|
88
|
+
const { data, message, index: _index } = await this.fetcher(this.guid)
|
|
89
|
+
this.drawnIndex = _index
|
|
49
90
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
91
|
+
isFetchSucceeded = true
|
|
92
|
+
|
|
93
|
+
if(!data.success) throw new Error()
|
|
94
|
+
switch(data.item.state) {
|
|
95
|
+
case 'fulfilled':
|
|
96
|
+
this.isDrawn = true
|
|
97
|
+
break
|
|
98
|
+
case 'drawn':
|
|
99
|
+
this.isDrawn = true
|
|
100
|
+
throw new Error()
|
|
55
101
|
}
|
|
102
|
+
|
|
103
|
+
if(isTimeouted) return;
|
|
104
|
+
|
|
105
|
+
this.handleHaltProcess(this.drawnIndex, message, this.afterSuccess)
|
|
106
|
+
this.drawInit()
|
|
107
|
+
|
|
108
|
+
} catch (e) {
|
|
109
|
+
if(isTimeouted) return;
|
|
110
|
+
this.drawer()
|
|
56
111
|
}
|
|
57
112
|
}
|
|
58
113
|
|
|
59
114
|
setMessage(entry: string | object) {
|
|
60
|
-
|
|
115
|
+
setMessage(this.id, entry)
|
|
61
116
|
this.afterSetMessage()
|
|
62
117
|
}
|
|
63
118
|
}
|
|
@@ -143,7 +143,10 @@
|
|
|
143
143
|
$: process = new Process({
|
|
144
144
|
id,
|
|
145
145
|
afterSetMessage: () => messageShown = true,
|
|
146
|
-
halter: (index, cb) =>
|
|
146
|
+
halter: (index, cb) => {
|
|
147
|
+
const targetIndex = index >= 0 ? index : options.length - 1
|
|
148
|
+
spinner.halt(calc.getDeg(targetIndex), cb)
|
|
149
|
+
},
|
|
147
150
|
afterSuccess: () => isShowPrizeArea = true,
|
|
148
151
|
fetcher: async (guid) => await api.draw(endpoint, session, id, guid, options)
|
|
149
152
|
})
|
|
@@ -177,6 +180,12 @@
|
|
|
177
180
|
setTimeout(() => updateSpinable(), 1)
|
|
178
181
|
messageShown = false
|
|
179
182
|
},
|
|
183
|
+
'wof-private-message-retry': (data) => {
|
|
184
|
+
if(data.id !== id) return;
|
|
185
|
+
|
|
186
|
+
messageShown = false
|
|
187
|
+
process.drawer()
|
|
188
|
+
}
|
|
180
189
|
})
|
|
181
190
|
|
|
182
191
|
const renderImage = (node: SVGElement, index) => {
|
|
@@ -41,8 +41,16 @@
|
|
|
41
41
|
const _postMessageScoped = (props) => _postMessage({ ...props, id })
|
|
42
42
|
|
|
43
43
|
const eventButton = () => {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
switch(mode){
|
|
45
|
+
case 'timeout':
|
|
46
|
+
isShown = false
|
|
47
|
+
_postMessageScoped({ type: 'wof-private-message-retry' })
|
|
48
|
+
break
|
|
49
|
+
default:
|
|
50
|
+
isShown = false
|
|
51
|
+
_postMessageScoped({ type: 'wof-private-message-close' })
|
|
52
|
+
break
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
const getTimeString = (_d) => {
|
|
@@ -102,7 +110,7 @@
|
|
|
102
110
|
].join(';')}
|
|
103
111
|
>
|
|
104
112
|
|
|
105
|
-
{#if mode === 'normal' || mode === 'init-failed'}
|
|
113
|
+
{#if mode === 'normal' || mode === 'init-failed' || mode === 'timeout'}
|
|
106
114
|
<p>{$_(`wof.${modeValue}`)}</p>
|
|
107
115
|
{/if}
|
|
108
116
|
|
package/src/translations.js
CHANGED
|
@@ -9,9 +9,11 @@ export const translations = {
|
|
|
9
9
|
ActiveTickets: `Active Tickets`,
|
|
10
10
|
ImplicitTickets: `Implicit Tickets`,
|
|
11
11
|
RemainingTimes: `Remaining Times`,
|
|
12
|
+
Retry: 'Network is a bit busy now, please click OK to re-spin',
|
|
12
13
|
ShowNext: `The Wheel will be available on<br /> <strong>{startTime}</strong> <br />Please wait till it is open.`,
|
|
13
14
|
SpinFailed: `We are sorry that you don't have any Wheels available, please <strong>check T&C</strong> here to get a chance!`,
|
|
14
|
-
DrawFailed: '
|
|
15
|
+
DrawFailed: 'The prize assignment may be failed, please contact customer support for more details',
|
|
16
|
+
Timeout: 'Network is a bit busy now, please try again later.',
|
|
15
17
|
Congratulation: `Congratulations! You won a {prize}!`,
|
|
16
18
|
OK: `OK`,
|
|
17
19
|
Rewards: `Rewards`,
|