@vixoniccom/footbal-score 1.4.6-dev.0 → 1.4.6-dev.2
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 +9 -0
- package/build/main.js +1 -1
- package/build/test/parameters.json +1 -0
- package/build.zip +0 -0
- package/configuration/dataGroup/dataInputs.ts +7 -0
- package/configuration.json +8 -0
- package/package.json +1 -1
- package/src/App.tsx +59 -35
- package/src/components/Table/components/Time.tsx +30 -3
- package/src/helpers/getFixture.ts +12 -8
- package/src/parameters.d.ts +1 -1
- package/src/test/parameters.json +1 -0
package/build.zip
CHANGED
|
Binary file
|
|
@@ -98,4 +98,11 @@ export const dataInputs = [
|
|
|
98
98
|
description: 'Duración por página (en segundos)',
|
|
99
99
|
range: new NumberRangeValue(1, 100),
|
|
100
100
|
}),
|
|
101
|
+
new Switch({
|
|
102
|
+
id: 'debugTimezone',
|
|
103
|
+
label: 'Debug Timezone',
|
|
104
|
+
displayOnTrue: 'Visible',
|
|
105
|
+
displayOnFalse: 'Oculto',
|
|
106
|
+
defaultValue: false,
|
|
107
|
+
}),
|
|
101
108
|
]
|
package/configuration.json
CHANGED
|
@@ -373,6 +373,14 @@
|
|
|
373
373
|
"type": "number-input",
|
|
374
374
|
"range": "[1:100:]",
|
|
375
375
|
"description": "Duración por página (en segundos)"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"id": "debugTimezone",
|
|
379
|
+
"label": "Debug Timezone",
|
|
380
|
+
"type": "switch",
|
|
381
|
+
"defaultValue": false,
|
|
382
|
+
"displayOnTrue": "Visible",
|
|
383
|
+
"displayOnFalse": "Oculto"
|
|
376
384
|
}
|
|
377
385
|
]
|
|
378
386
|
},
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react'
|
|
2
2
|
import localforage from 'localforage'
|
|
3
3
|
import { FontLoader, FormattedText, Table } from './components'
|
|
4
|
-
import { getFixture } from './helpers/getFixture'
|
|
4
|
+
import { getFixture, resolvedTimezone } from './helpers/getFixture'
|
|
5
5
|
|
|
6
6
|
export type Props = {
|
|
7
7
|
data: VixonicData
|
|
@@ -56,7 +56,7 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
56
56
|
const [dataFixture, setDataFixture] = useState<any[]>([])
|
|
57
57
|
const [leagueState, setLeagueState] = useState<string>('')
|
|
58
58
|
const { parameters, downloadsPath } = data
|
|
59
|
-
const { backgroundImage, padding, msj0 = '', league = '9' } = parameters
|
|
59
|
+
const { backgroundImage, padding, msj0 = '', league = '9', debugTimezone = false } = parameters
|
|
60
60
|
const backgroundImageState = backgroundImage?.filename
|
|
61
61
|
? `url("${downloadsPath}/${backgroundImage.filename}")`
|
|
62
62
|
: ''
|
|
@@ -142,42 +142,66 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
142
142
|
fetchAndSchedule()
|
|
143
143
|
}, [league])
|
|
144
144
|
|
|
145
|
+
const timezone = resolvedTimezone
|
|
146
|
+
|
|
145
147
|
return (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
<>
|
|
149
|
+
{dataFixture.length > 0 ?
|
|
150
|
+
<div style={{
|
|
151
|
+
position: 'absolute',
|
|
152
|
+
top: 0,
|
|
153
|
+
bottom: 0,
|
|
154
|
+
left: 0,
|
|
155
|
+
right: 0,
|
|
156
|
+
backgroundImage: backgroundImageState,
|
|
157
|
+
backgroundSize: '100% 100%',
|
|
158
|
+
padding: padding
|
|
159
|
+
}}>
|
|
160
|
+
<FontLoader paths={['nameFormat.font', 'statusFormat.font', 'timeFormat.font', 'titleFormat.font', 'descriptionFormat.font', 'dateDayFormat.font', 'dateMonthFormat.font', 'goalsFormat.font']} parameters={parameters} downloadsPath={downloadsPath} />
|
|
161
|
+
{parameters.titleEnabled &&
|
|
162
|
+
<div style={{ display: 'flex', position: 'relative', flex: '1 1 0%', flexDirection: 'column' }}>
|
|
163
|
+
<FormattedText text={parameters.title0 || 'Partidos Mundial'} format={parameters.titleFormat} />
|
|
164
|
+
</div>
|
|
165
|
+
}
|
|
166
|
+
<Table dataFixture={dataFixture} parameters={parameters} />
|
|
167
|
+
</div> :
|
|
168
|
+
<div style={{
|
|
169
|
+
position: 'absolute',
|
|
170
|
+
top: 0,
|
|
171
|
+
bottom: 0,
|
|
172
|
+
left: 0,
|
|
173
|
+
right: 0,
|
|
174
|
+
backgroundImage: backgroundImageState,
|
|
175
|
+
backgroundSize: '100% 100%',
|
|
176
|
+
padding: padding,
|
|
177
|
+
display: 'flex',
|
|
178
|
+
alignItems: parameters.alignVerticalMsj
|
|
179
|
+
}}>
|
|
180
|
+
<FontLoader paths={['nameFormat.font', 'descriptionFormat.font', 'dateDayFormat.font', 'dateMonthFormat.font', 'formatMjs.font']} parameters={parameters} downloadsPath={downloadsPath} />
|
|
159
181
|
<div style={{ display: 'flex', position: 'relative', flex: '1 1 0%', flexDirection: 'column' }}>
|
|
160
|
-
<FormattedText text={
|
|
182
|
+
<FormattedText text={msj0 || 'Sin partidos'} format={parameters.formatMjs} />
|
|
161
183
|
</div>
|
|
162
|
-
}
|
|
163
|
-
<Table dataFixture={dataFixture} parameters={parameters} />
|
|
164
|
-
</div> :
|
|
165
|
-
<div style={{
|
|
166
|
-
position: 'absolute',
|
|
167
|
-
top: 0,
|
|
168
|
-
bottom: 0,
|
|
169
|
-
left: 0,
|
|
170
|
-
right: 0,
|
|
171
|
-
backgroundImage: backgroundImageState,
|
|
172
|
-
backgroundSize: '100% 100%',
|
|
173
|
-
padding: padding,
|
|
174
|
-
display: 'flex',
|
|
175
|
-
alignItems: parameters.alignVerticalMsj
|
|
176
|
-
}}>
|
|
177
|
-
<FontLoader paths={['nameFormat.font', 'descriptionFormat.font', 'dateDayFormat.font', 'dateMonthFormat.font', 'formatMjs.font']} parameters={parameters} downloadsPath={downloadsPath} />
|
|
178
|
-
<div style={{ display: 'flex', position: 'relative', flex: '1 1 0%', flexDirection: 'column' }}>
|
|
179
|
-
<FormattedText text={msj0 || 'Sin partidos'} format={parameters.formatMjs} />
|
|
180
184
|
</div>
|
|
181
|
-
|
|
185
|
+
}
|
|
186
|
+
{debugTimezone && (
|
|
187
|
+
<div style={{
|
|
188
|
+
position: 'fixed',
|
|
189
|
+
bottom: 8,
|
|
190
|
+
right: 8,
|
|
191
|
+
background: 'rgba(0,0,0,0.75)',
|
|
192
|
+
color: '#00ff00',
|
|
193
|
+
fontSize: 10,
|
|
194
|
+
fontFamily: 'monospace',
|
|
195
|
+
padding: '4px 8px',
|
|
196
|
+
borderRadius: 4,
|
|
197
|
+
zIndex: 9999,
|
|
198
|
+
lineHeight: 1.4,
|
|
199
|
+
pointerEvents: 'none',
|
|
200
|
+
whiteSpace: 'nowrap',
|
|
201
|
+
}}>
|
|
202
|
+
TZ: {timezone}
|
|
203
|
+
</div>
|
|
204
|
+
)}
|
|
205
|
+
</>
|
|
182
206
|
)
|
|
183
207
|
}
|
|
@@ -1,17 +1,44 @@
|
|
|
1
|
-
import moment from 'moment'
|
|
2
1
|
import React from 'react'
|
|
3
2
|
import { FormattedText } from '../../'
|
|
3
|
+
import { resolvedTimezone } from '../../../helpers/getFixture'
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
time: number
|
|
7
7
|
parameters: VixonicParameters
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
const timezone = resolvedTimezone
|
|
11
|
+
|
|
12
|
+
const formatFixtureTime = (timestamp: number) => {
|
|
13
|
+
const date = new Date(timestamp * 1000)
|
|
14
|
+
|
|
15
|
+
const dateParts = new Intl.DateTimeFormat('es-ES', {
|
|
16
|
+
timeZone: timezone,
|
|
17
|
+
day: '2-digit',
|
|
18
|
+
month: '2-digit',
|
|
19
|
+
}).formatToParts(date)
|
|
20
|
+
const day = dateParts.find(p => p.type === 'day')?.value ?? ''
|
|
21
|
+
const month = dateParts.find(p => p.type === 'month')?.value ?? ''
|
|
22
|
+
|
|
23
|
+
const timeParts = new Intl.DateTimeFormat('en-US', {
|
|
24
|
+
timeZone: timezone,
|
|
25
|
+
hour: 'numeric',
|
|
26
|
+
minute: '2-digit',
|
|
27
|
+
hour12: true,
|
|
28
|
+
}).formatToParts(date)
|
|
29
|
+
const hour = timeParts.find(p => p.type === 'hour')?.value ?? ''
|
|
30
|
+
const minute = timeParts.find(p => p.type === 'minute')?.value ?? ''
|
|
31
|
+
const period = timeParts.find(p => p.type === 'dayPeriod')?.value?.toLowerCase() ?? ''
|
|
32
|
+
|
|
33
|
+
return { dateStr: `${day}-${month}`, timeStr: `${hour}:${minute} ${period}` }
|
|
34
|
+
}
|
|
35
|
+
|
|
10
36
|
export const Time: React.FunctionComponent<Props> = ({ time, parameters }) => {
|
|
37
|
+
const { dateStr, timeStr } = formatFixtureTime(time)
|
|
11
38
|
return (
|
|
12
39
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
|
|
13
|
-
<FormattedText text={
|
|
14
|
-
<FormattedText text={
|
|
40
|
+
<FormattedText text={dateStr} format={parameters.timeFormat} />
|
|
41
|
+
<FormattedText text={timeStr} format={parameters.timeFormat} />
|
|
15
42
|
</div>
|
|
16
43
|
)
|
|
17
44
|
}
|
|
@@ -11,6 +11,17 @@ const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000
|
|
|
11
11
|
|
|
12
12
|
const USE_MOCK = false
|
|
13
13
|
|
|
14
|
+
export const resolvedTimezone = (() => {
|
|
15
|
+
try {
|
|
16
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
17
|
+
console.log(`[football-score] Timezone resolved: ${tz}`)
|
|
18
|
+
return tz
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.warn('[football-score] Failed to resolve timezone, defaulting to UTC', error)
|
|
21
|
+
return 'UTC'
|
|
22
|
+
}
|
|
23
|
+
})()
|
|
24
|
+
|
|
14
25
|
export const getFixture = async (league: string, yesterday?: boolean, tomorrow?: boolean) => {
|
|
15
26
|
if (USE_MOCK) return mockFixtures
|
|
16
27
|
|
|
@@ -18,14 +29,7 @@ export const getFixture = async (league: string, yesterday?: boolean, tomorrow?:
|
|
|
18
29
|
const year = moment().format('YYYY')
|
|
19
30
|
const from = yesterday ? moment(Date.now() - MILLISECONDS_PER_DAY).format('YYYY-MM-DD') : today
|
|
20
31
|
const to = tomorrow ? moment(Date.now() + MILLISECONDS_PER_DAY).format('YYYY-MM-DD') : today
|
|
21
|
-
const timezone =
|
|
22
|
-
try {
|
|
23
|
-
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
24
|
-
return tz
|
|
25
|
-
} catch (error) {
|
|
26
|
-
return 'UTC'
|
|
27
|
-
}
|
|
28
|
-
})()
|
|
32
|
+
const timezone = resolvedTimezone
|
|
29
33
|
|
|
30
34
|
const options = {
|
|
31
35
|
method: 'GET',
|
package/src/parameters.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ declare type VixonicData = {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
declare type VixonicParameters = Partial<{
|
|
8
|
-
league: '1' | '9' | '4' | '22' | '15' | '1220' | '128' | '265', matchesYesterday: boolean, matchesTomorrow: boolean, timeStart: '12m' | '1m' | '2m' | '3m' | '4m' | '5m' | '6m' | '7m' | '8m' | '9m' | '10m' | '11m' | '12pm' | '1pm' | '2pm' | '3pm' | '4pm' | '5pm' | '6pm' | '7pm' | '8pm' | '9pm' | '10pm' | '11pm', timeEnd: '12m' | '1m' | '2m' | '3m' | '4m' | '5m' | '6m' | '7m' | '8m' | '9m' | '10m' | '11m' | '12pm' | '1pm' | '2pm' | '3pm' | '4pm' | '5pm' | '6pm' | '7pm' | '8pm' | '9pm' | '10pm' | '11pm', updateTime: 300000 | 600000 | 1800000 | 3600000 | 21600000 | 43200000 | 86400000, titleEnabled: boolean, title0: string, titleFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, msj0: string, formatMjs: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, alignVerticalMsj: 'flex-start' | 'center' | 'flex-end', itemsPerPage: number, durationPerPage: number, backgroundImage: {id?: string, filename?: string, extension?: string}, padding: string, columnGap: string, rowGap: string, timeFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, widthTime: string, statusFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, widthStatus: string, goalsFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, widthScore: string, descriptionEnabled: boolean, descriptionFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, widthDescription: string, imageSize: number, widthImage: string
|
|
8
|
+
league: '1' | '9' | '4' | '22' | '15' | '1220' | '128' | '265', matchesYesterday: boolean, matchesTomorrow: boolean, timeStart: '12m' | '1m' | '2m' | '3m' | '4m' | '5m' | '6m' | '7m' | '8m' | '9m' | '10m' | '11m' | '12pm' | '1pm' | '2pm' | '3pm' | '4pm' | '5pm' | '6pm' | '7pm' | '8pm' | '9pm' | '10pm' | '11pm', timeEnd: '12m' | '1m' | '2m' | '3m' | '4m' | '5m' | '6m' | '7m' | '8m' | '9m' | '10m' | '11m' | '12pm' | '1pm' | '2pm' | '3pm' | '4pm' | '5pm' | '6pm' | '7pm' | '8pm' | '9pm' | '10pm' | '11pm', updateTime: 300000 | 600000 | 1800000 | 3600000 | 21600000 | 43200000 | 86400000, titleEnabled: boolean, title0: string, titleFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, msj0: string, formatMjs: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, alignVerticalMsj: 'flex-start' | 'center' | 'flex-end', itemsPerPage: number, durationPerPage: number, backgroundImage: {id?: string, filename?: string, extension?: string}, padding: string, columnGap: string, rowGap: string, timeFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, widthTime: string, statusFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, widthStatus: string, goalsFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, widthScore: string, descriptionEnabled: boolean, descriptionFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, widthDescription: string, imageSize: number, widthImage: string, debugTimezone: boolean
|
|
9
9
|
}>
|