@fmidev/smartmet-alert-client 4.4.19 → 4.7.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/.eslintignore +2 -14
- package/.github/workflows/test.yaml +26 -0
- package/.nvmrc +1 -0
- package/AGENTS.md +26 -0
- package/index.html +1 -1
- package/package.json +80 -22
- package/src/AlertClientVue.vue +160 -0
- package/src/App.vue +154 -296
- package/src/assets/img/ui/arrow-down.svg +4 -11
- package/src/assets/img/ui/arrow-up.svg +4 -11
- package/src/assets/img/ui/clear.svg +7 -21
- package/src/assets/img/ui/close.svg +4 -15
- package/src/assets/img/ui/toggle-selected.svg +5 -6
- package/src/assets/img/ui/toggle-unselected.svg +5 -6
- package/src/assets/img/warning/cold-weather.svg +3 -6
- package/src/assets/img/warning/flood-level-3.svg +4 -7
- package/src/assets/img/warning/forest-fire-weather.svg +2 -6
- package/src/assets/img/warning/grass-fire-weather.svg +2 -6
- package/src/assets/img/warning/hot-weather.svg +3 -6
- package/src/assets/img/warning/pedestrian-safety.svg +3 -7
- package/src/assets/img/warning/rain.svg +2 -7
- package/src/assets/img/warning/sea-icing.svg +2 -6
- package/src/assets/img/warning/sea-thunder-storm.svg +2 -5
- package/src/assets/img/warning/sea-water-height-high-water.svg +3 -8
- package/src/assets/img/warning/sea-water-height-shallow-water.svg +3 -7
- package/src/assets/img/warning/sea-wave-height.svg +4 -7
- package/src/assets/img/warning/sea-wind-legend.svg +2 -5
- package/src/assets/img/warning/sea-wind.svg +2 -5
- package/src/assets/img/warning/several.svg +2 -5
- package/src/assets/img/warning/thunder-storm.svg +2 -5
- package/src/assets/img/warning/traffic-weather.svg +2 -6
- package/src/assets/img/warning/uv-note.svg +2 -6
- package/src/assets/img/warning/wind.svg +2 -5
- package/src/components/AlertClient.vue +330 -251
- package/src/components/CollapsiblePanel.vue +281 -0
- package/src/components/DayLarge.vue +146 -110
- package/src/components/DaySmall.vue +97 -81
- package/src/components/Days.vue +229 -159
- package/src/components/DescriptionWarning.vue +63 -38
- package/src/components/GrayScaleToggle.vue +58 -54
- package/src/components/Legend.vue +102 -325
- package/src/components/MapLarge.vue +574 -351
- package/src/components/MapSmall.vue +137 -122
- package/src/components/PopupRow.vue +24 -12
- package/src/components/Region.vue +168 -118
- package/src/components/RegionWarning.vue +40 -33
- package/src/components/Regions.vue +189 -105
- package/src/components/Warning.vue +70 -45
- package/src/components/Warnings.vue +136 -72
- package/src/composables/useAlertClient.ts +360 -0
- package/src/composables/useConfig.ts +573 -0
- package/src/composables/useFields.ts +66 -0
- package/src/composables/useI18n.ts +62 -0
- package/src/composables/useKeyCodes.ts +16 -0
- package/src/composables/useMapPaths.ts +477 -0
- package/src/composables/useUtils.ts +683 -0
- package/src/composables/useWarningsProcessor.ts +1007 -0
- package/src/data/geometries.json +993 -0
- package/src/{main.js → main.ts} +1 -0
- package/src/mixins/geojsonsvg.d.ts +57 -0
- package/src/mixins/geojsonsvg.js +5 -3
- package/src/plugins/index.ts +5 -0
- package/src/scss/_utilities.scss +193 -0
- package/src/scss/constants.scss +2 -1
- package/src/scss/warningImages.scss +8 -3
- package/src/types/index.ts +509 -0
- package/src/vite-env.d.ts +23 -0
- package/src/vue.ts +41 -0
- package/svgo.config.js +45 -0
- package/tests/README.md +430 -0
- package/tests/fixtures/mockWarningData.ts +152 -0
- package/tests/integration/warning-flow.spec.ts +445 -0
- package/tests/setup.ts +41 -0
- package/tests/unit/components/AlertClient.spec.ts +701 -0
- package/tests/unit/components/DayLarge.spec.ts +348 -0
- package/tests/unit/components/DaySmall.spec.ts +352 -0
- package/tests/unit/components/Days.spec.ts +548 -0
- package/tests/unit/components/DescriptionWarning.spec.ts +385 -0
- package/tests/unit/components/GrayScaleToggle.spec.ts +318 -0
- package/tests/unit/components/Legend.spec.ts +295 -0
- package/tests/unit/components/MapLarge.spec.ts +448 -0
- package/tests/unit/components/MapSmall.spec.ts +367 -0
- package/tests/unit/components/PopupRow.spec.ts +270 -0
- package/tests/unit/components/Region.spec.ts +373 -0
- package/tests/unit/components/RegionWarning.snapshot.spec.ts +361 -0
- package/tests/unit/components/RegionWarning.spec.ts +381 -0
- package/tests/unit/components/Regions.spec.ts +503 -0
- package/tests/unit/components/Warning.snapshot.spec.ts +483 -0
- package/tests/unit/components/Warning.spec.ts +489 -0
- package/tests/unit/components/Warnings.spec.ts +343 -0
- package/tests/unit/components/__snapshots__/RegionWarning.snapshot.spec.ts.snap +41 -0
- package/tests/unit/components/__snapshots__/Warning.snapshot.spec.ts.snap +433 -0
- package/tests/unit/composables/useConfig.spec.ts +279 -0
- package/tests/unit/composables/useI18n.spec.ts +116 -0
- package/tests/unit/composables/useKeyCodes.spec.ts +27 -0
- package/tests/unit/composables/useUtils.spec.ts +213 -0
- package/tsconfig.json +43 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.js +96 -26
- package/vitest.config.js +40 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.dark.html +0 -20
- package/dist/index.en.html +0 -15
- package/dist/index.fi.html +0 -15
- package/dist/index.html +0 -15
- package/dist/index.js +0 -281
- package/dist/index.mjs +0 -281
- package/dist/index.mjs.map +0 -1
- package/dist/index.relative.html +0 -19
- package/dist/index.start.html +0 -20
- package/dist/index.sv.html +0 -15
- package/playwright.config.ts +0 -18
- package/public/index.relative.html +0 -19
- package/public/index.start.html +0 -20
- package/src/mixins/config.js +0 -1378
- package/src/mixins/fields.js +0 -26
- package/src/mixins/i18n.js +0 -25
- package/src/mixins/keycodes.js +0 -10
- package/src/mixins/panzoom.js +0 -900
- package/src/mixins/utils.js +0 -900
- package/src/plugins/index.js +0 -3
- package/test/snapshot.test.ts +0 -126
- package/vitest.config.ts +0 -6
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmartMet Alert Client Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Language & Localization
|
|
7
|
+
// ============================================================================
|
|
8
|
+
|
|
9
|
+
export type Language = 'fi' | 'sv' | 'en'
|
|
10
|
+
|
|
11
|
+
export interface LocalizedText {
|
|
12
|
+
fi?: string
|
|
13
|
+
sv?: string
|
|
14
|
+
en?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Theme
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
export type Theme =
|
|
22
|
+
| 'light-theme'
|
|
23
|
+
| 'dark-theme'
|
|
24
|
+
| 'light-gray-theme'
|
|
25
|
+
| 'dark-gray-theme'
|
|
26
|
+
|
|
27
|
+
export interface ThemeColors {
|
|
28
|
+
sea: string
|
|
29
|
+
levels: [string, string, string, string, string]
|
|
30
|
+
missing: string
|
|
31
|
+
stroke: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type ThemeColorMap = Record<Theme, ThemeColors>
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Warning Types
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
export type WarningType =
|
|
41
|
+
| 'thunderStorm'
|
|
42
|
+
| 'wind'
|
|
43
|
+
| 'rain'
|
|
44
|
+
| 'trafficWeather'
|
|
45
|
+
| 'pedestrianSafety'
|
|
46
|
+
| 'forestFireWeather'
|
|
47
|
+
| 'grassFireWeather'
|
|
48
|
+
| 'hotWeather'
|
|
49
|
+
| 'coldWeather'
|
|
50
|
+
| 'uvNote'
|
|
51
|
+
| 'floodLevel'
|
|
52
|
+
| 'seaWind'
|
|
53
|
+
| 'seaThunderStorm'
|
|
54
|
+
| 'seaWaterHeightHighWater'
|
|
55
|
+
| 'seaWaterHeightShallowWater'
|
|
56
|
+
| 'seaWaveHeight'
|
|
57
|
+
| 'seaIcing'
|
|
58
|
+
| 'multiple'
|
|
59
|
+
|
|
60
|
+
export type RegionType = 'land' | 'sea'
|
|
61
|
+
export type RegionSubType = 'lake'
|
|
62
|
+
|
|
63
|
+
export type Severity = 0 | 1 | 2 | 3 | 4
|
|
64
|
+
|
|
65
|
+
export interface CoverageData {
|
|
66
|
+
path: string
|
|
67
|
+
reference: [number, number] | []
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface Warning {
|
|
71
|
+
type: WarningType | string
|
|
72
|
+
id: string
|
|
73
|
+
regions: Record<string, boolean>
|
|
74
|
+
covRegions: Map<string, number>
|
|
75
|
+
coveragesLarge: CoverageData[]
|
|
76
|
+
coveragesSmall: CoverageData[]
|
|
77
|
+
effectiveFrom: string
|
|
78
|
+
effectiveUntil: string
|
|
79
|
+
effectiveDays: boolean[]
|
|
80
|
+
validInterval: string
|
|
81
|
+
severity: Severity
|
|
82
|
+
direction: number
|
|
83
|
+
value: number
|
|
84
|
+
text: string
|
|
85
|
+
info: LocalizedText
|
|
86
|
+
link: string
|
|
87
|
+
linkText: string
|
|
88
|
+
dailyWarning?: boolean
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type WarningsMap = Record<string, Warning>
|
|
92
|
+
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// Day Types
|
|
95
|
+
// ============================================================================
|
|
96
|
+
|
|
97
|
+
export interface Day {
|
|
98
|
+
weekdayName: string
|
|
99
|
+
day: number
|
|
100
|
+
month: number
|
|
101
|
+
year: number
|
|
102
|
+
severity: Severity
|
|
103
|
+
updatedDate: string
|
|
104
|
+
updatedTime: string
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ============================================================================
|
|
108
|
+
// Region Types
|
|
109
|
+
// ============================================================================
|
|
110
|
+
|
|
111
|
+
export interface RegionGeometry {
|
|
112
|
+
name: string
|
|
113
|
+
type: RegionType
|
|
114
|
+
subType?: RegionSubType
|
|
115
|
+
parent: string
|
|
116
|
+
children: string[]
|
|
117
|
+
neighbours: string[]
|
|
118
|
+
weight: number
|
|
119
|
+
center: [number, number]
|
|
120
|
+
pathLarge?: string
|
|
121
|
+
pathSmall?: string
|
|
122
|
+
align?: 'left' | 'right'
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface BorderPaths {
|
|
126
|
+
pathLarge: string
|
|
127
|
+
pathSmall: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface Borders {
|
|
131
|
+
land: BorderPaths
|
|
132
|
+
sea: BorderPaths
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface GeometryData {
|
|
136
|
+
[regionId: string]: RegionGeometry | Borders | undefined
|
|
137
|
+
borders: Borders
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Type guard to check if a geometry entry is a RegionGeometry (not Borders)
|
|
141
|
+
export function isRegionGeometry(
|
|
142
|
+
geom: RegionGeometry | Borders | undefined
|
|
143
|
+
): geom is RegionGeometry {
|
|
144
|
+
return geom != null && 'type' in geom && typeof geom.type === 'string'
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface GeometryCollection {
|
|
148
|
+
[year: string]: GeometryData
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface RegionWarningItem {
|
|
152
|
+
type: WarningType | string
|
|
153
|
+
identifiers: string[]
|
|
154
|
+
coverage: number
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface RegionListItem {
|
|
158
|
+
key: string
|
|
159
|
+
regionIndex: number
|
|
160
|
+
name: string
|
|
161
|
+
warnings: RegionWarningItem[]
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface DayRegions {
|
|
165
|
+
land: RegionListItem[]
|
|
166
|
+
sea: RegionListItem[]
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type RegionsData = DayRegions[]
|
|
170
|
+
|
|
171
|
+
// ============================================================================
|
|
172
|
+
// Legend Types
|
|
173
|
+
// ============================================================================
|
|
174
|
+
|
|
175
|
+
export interface LegendItem {
|
|
176
|
+
type: WarningType | string
|
|
177
|
+
severity: Severity
|
|
178
|
+
visible: boolean
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// ============================================================================
|
|
182
|
+
// Warning Icon Types
|
|
183
|
+
// ============================================================================
|
|
184
|
+
|
|
185
|
+
export interface WarningIcon {
|
|
186
|
+
aspectRatio: [number, number]
|
|
187
|
+
scale: number
|
|
188
|
+
geom?: string
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface WarningIconInput {
|
|
192
|
+
type: WarningType | string
|
|
193
|
+
severity: Severity
|
|
194
|
+
direction?: number
|
|
195
|
+
text?: string
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface PopupRowInput extends WarningIconInput {
|
|
199
|
+
interval: string
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ============================================================================
|
|
203
|
+
// Map Path Types
|
|
204
|
+
// ============================================================================
|
|
205
|
+
|
|
206
|
+
export interface PathData {
|
|
207
|
+
key: string
|
|
208
|
+
d: string
|
|
209
|
+
opacity: string
|
|
210
|
+
strokeWidth: number
|
|
211
|
+
fill?: string
|
|
212
|
+
fillOpacity?: number
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ============================================================================
|
|
216
|
+
// GeoJSON Types
|
|
217
|
+
// ============================================================================
|
|
218
|
+
|
|
219
|
+
export type GeoJSONCoordinate = [number, number]
|
|
220
|
+
export type GeoJSONCoordinates = GeoJSONCoordinate[]
|
|
221
|
+
export type GeoJSONPolygonCoordinates = GeoJSONCoordinates[]
|
|
222
|
+
export type GeoJSONMultiPolygonCoordinates = GeoJSONPolygonCoordinates[]
|
|
223
|
+
|
|
224
|
+
export interface GeoJSONPoint {
|
|
225
|
+
type: 'Point'
|
|
226
|
+
coordinates: GeoJSONCoordinate
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface GeoJSONMultiPoint {
|
|
230
|
+
type: 'MultiPoint'
|
|
231
|
+
coordinates: GeoJSONCoordinates
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface GeoJSONLineString {
|
|
235
|
+
type: 'LineString'
|
|
236
|
+
coordinates: GeoJSONCoordinates
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface GeoJSONMultiLineString {
|
|
240
|
+
type: 'MultiLineString'
|
|
241
|
+
coordinates: GeoJSONCoordinates[]
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface GeoJSONPolygon {
|
|
245
|
+
type: 'Polygon'
|
|
246
|
+
coordinates: GeoJSONPolygonCoordinates
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface GeoJSONMultiPolygon {
|
|
250
|
+
type: 'MultiPolygon'
|
|
251
|
+
coordinates: GeoJSONMultiPolygonCoordinates
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface GeoJSONGeometryCollection {
|
|
255
|
+
type: 'GeometryCollection'
|
|
256
|
+
geometries: GeoJSONGeometry[]
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export type GeoJSONGeometry =
|
|
260
|
+
| GeoJSONPoint
|
|
261
|
+
| GeoJSONMultiPoint
|
|
262
|
+
| GeoJSONLineString
|
|
263
|
+
| GeoJSONMultiLineString
|
|
264
|
+
| GeoJSONPolygon
|
|
265
|
+
| GeoJSONMultiPolygon
|
|
266
|
+
| GeoJSONGeometryCollection
|
|
267
|
+
|
|
268
|
+
export interface GeoJSONFeature {
|
|
269
|
+
type: 'Feature'
|
|
270
|
+
id?: string
|
|
271
|
+
geometry: GeoJSONGeometry | null
|
|
272
|
+
geometry_name?: string
|
|
273
|
+
properties: Record<string, unknown>
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface GeoJSONCRS {
|
|
277
|
+
type: string
|
|
278
|
+
properties: {
|
|
279
|
+
name: string
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface GeoJSONFeatureCollection {
|
|
284
|
+
type: 'FeatureCollection'
|
|
285
|
+
features: GeoJSONFeature[]
|
|
286
|
+
totalFeatures?: number
|
|
287
|
+
crs?: GeoJSONCRS
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ============================================================================
|
|
291
|
+
// API Response Types
|
|
292
|
+
// ============================================================================
|
|
293
|
+
|
|
294
|
+
export interface WarningsData {
|
|
295
|
+
weather_update_time?: GeoJSONFeatureCollection
|
|
296
|
+
flood_update_time?: GeoJSONFeatureCollection
|
|
297
|
+
weather_finland_active_all?: GeoJSONFeatureCollection
|
|
298
|
+
flood_finland_active_all?: GeoJSONFeatureCollection
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Alias for API response (same as WarningsData, used for prop typing)
|
|
302
|
+
export type WarningsDataResponse = WarningsData
|
|
303
|
+
|
|
304
|
+
export interface WeatherWarningProperties {
|
|
305
|
+
identifier: string
|
|
306
|
+
reference: string
|
|
307
|
+
coverage_references?: string
|
|
308
|
+
severity: string
|
|
309
|
+
warning_context: string
|
|
310
|
+
context_extension?: string
|
|
311
|
+
effective_from: string
|
|
312
|
+
effective_until: string
|
|
313
|
+
physical_direction?: number
|
|
314
|
+
physical_value?: number
|
|
315
|
+
info_fi?: string
|
|
316
|
+
info_sv?: string
|
|
317
|
+
info_en?: string
|
|
318
|
+
representative_x?: number
|
|
319
|
+
representative_y?: number
|
|
320
|
+
update_time?: string
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface FloodWarningProperties {
|
|
324
|
+
identifier: string
|
|
325
|
+
reference: string
|
|
326
|
+
severity: string
|
|
327
|
+
onset: string
|
|
328
|
+
expires: string
|
|
329
|
+
description?: string
|
|
330
|
+
language: string
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// ============================================================================
|
|
334
|
+
// Processed Data Types
|
|
335
|
+
// ============================================================================
|
|
336
|
+
|
|
337
|
+
export interface ProcessedWarningsResult {
|
|
338
|
+
warnings: WarningsMap
|
|
339
|
+
days: Day[]
|
|
340
|
+
regions: RegionsData
|
|
341
|
+
parents: Record<string, boolean[]>
|
|
342
|
+
legend: LegendItem[]
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// ============================================================================
|
|
346
|
+
// Component Props Types
|
|
347
|
+
// ============================================================================
|
|
348
|
+
|
|
349
|
+
export interface AlertClientProps {
|
|
350
|
+
refreshInterval?: number
|
|
351
|
+
defaultDay?: number
|
|
352
|
+
staticDays?: boolean
|
|
353
|
+
startFrom?: 'updated' | ''
|
|
354
|
+
regionListEnabled?: boolean
|
|
355
|
+
grayScaleSelector?: boolean
|
|
356
|
+
currentTime?: number
|
|
357
|
+
warningsData?: WarningsData | null
|
|
358
|
+
dailyWarningTypes?: string[]
|
|
359
|
+
geometryId?: number
|
|
360
|
+
language?: Language
|
|
361
|
+
theme?: Theme
|
|
362
|
+
loading?: number
|
|
363
|
+
sleep?: boolean
|
|
364
|
+
spinnerEnabled?: boolean
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface DaysProps {
|
|
368
|
+
input: Day[]
|
|
369
|
+
visibleWarnings: string[]
|
|
370
|
+
selectedDay: number
|
|
371
|
+
staticDays: boolean
|
|
372
|
+
timeOffset: number
|
|
373
|
+
warnings: WarningsMap | null
|
|
374
|
+
regions: RegionsData
|
|
375
|
+
geometryId: number
|
|
376
|
+
loading: boolean
|
|
377
|
+
theme: Theme
|
|
378
|
+
language: Language
|
|
379
|
+
spinnerEnabled?: boolean
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export interface LegendProps {
|
|
383
|
+
input: LegendItem[]
|
|
384
|
+
visibleWarnings: string[]
|
|
385
|
+
grayScaleSelector: boolean
|
|
386
|
+
theme: Theme
|
|
387
|
+
language: Language
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export interface RegionsProps {
|
|
391
|
+
input: RegionsData
|
|
392
|
+
selectedDay: number
|
|
393
|
+
warnings: WarningsMap | null
|
|
394
|
+
parents: Record<string, boolean[]>
|
|
395
|
+
geometryId: number
|
|
396
|
+
theme: Theme
|
|
397
|
+
language: Language
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface WarningProps {
|
|
401
|
+
input: WarningIconInput
|
|
402
|
+
language: Language
|
|
403
|
+
theme: Theme
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export interface DayLargeProps {
|
|
407
|
+
input: Day
|
|
408
|
+
index: number
|
|
409
|
+
visibleWarnings: string[]
|
|
410
|
+
selectedDay: number
|
|
411
|
+
warnings: WarningsMap | null
|
|
412
|
+
regions: RegionsData
|
|
413
|
+
geometryId: number
|
|
414
|
+
theme: Theme
|
|
415
|
+
language: Language
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export interface DaySmallProps extends DayLargeProps {
|
|
419
|
+
staticDays: boolean
|
|
420
|
+
timeOffset: number
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export interface MapLargeProps {
|
|
424
|
+
input: DayRegions
|
|
425
|
+
index: number
|
|
426
|
+
visibleWarnings: string[]
|
|
427
|
+
warnings: WarningsMap | null
|
|
428
|
+
geometryId: number
|
|
429
|
+
theme: Theme
|
|
430
|
+
language: Language
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export interface MapSmallProps extends MapLargeProps {}
|
|
434
|
+
|
|
435
|
+
// ============================================================================
|
|
436
|
+
// Time Utilities
|
|
437
|
+
// ============================================================================
|
|
438
|
+
|
|
439
|
+
export interface TimeZoneMoment {
|
|
440
|
+
year: number
|
|
441
|
+
month: number
|
|
442
|
+
day: number
|
|
443
|
+
weekday: string
|
|
444
|
+
hour: number
|
|
445
|
+
minute: number
|
|
446
|
+
second: number
|
|
447
|
+
millisecond: number
|
|
448
|
+
timeZone: string
|
|
449
|
+
timeZoneName?: string
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// ============================================================================
|
|
453
|
+
// Bounds & Transform (for GeoJSON SVG conversion)
|
|
454
|
+
// ============================================================================
|
|
455
|
+
|
|
456
|
+
export interface BoundsData {
|
|
457
|
+
xmin: number
|
|
458
|
+
ymin: number
|
|
459
|
+
xmax: number
|
|
460
|
+
ymax: number
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export interface TransformData {
|
|
464
|
+
mx: number
|
|
465
|
+
my: number
|
|
466
|
+
bx: number
|
|
467
|
+
by: number
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// ============================================================================
|
|
471
|
+
// Constants
|
|
472
|
+
// ============================================================================
|
|
473
|
+
|
|
474
|
+
export const NUMBER_OF_DAYS = 5 as const
|
|
475
|
+
|
|
476
|
+
export const WARNING_LEVELS = [
|
|
477
|
+
'level-1',
|
|
478
|
+
'level-2',
|
|
479
|
+
'level-3',
|
|
480
|
+
'level-4',
|
|
481
|
+
] as const
|
|
482
|
+
export type WarningLevel = (typeof WARNING_LEVELS)[number]
|
|
483
|
+
|
|
484
|
+
export const FLOOD_LEVELS = {
|
|
485
|
+
minor: 1,
|
|
486
|
+
moderate: 2,
|
|
487
|
+
severe: 3,
|
|
488
|
+
extreme: 4,
|
|
489
|
+
} as const
|
|
490
|
+
export type FloodLevel = keyof typeof FLOOD_LEVELS
|
|
491
|
+
|
|
492
|
+
// ============================================================================
|
|
493
|
+
// Key Codes (for keyboard navigation)
|
|
494
|
+
// ============================================================================
|
|
495
|
+
|
|
496
|
+
export const KEY_CODES = {
|
|
497
|
+
END: 35,
|
|
498
|
+
HOME: 36,
|
|
499
|
+
LEFT: 37,
|
|
500
|
+
RIGHT: 39,
|
|
501
|
+
} as const
|
|
502
|
+
|
|
503
|
+
// ============================================================================
|
|
504
|
+
// Global declarations
|
|
505
|
+
// ============================================================================
|
|
506
|
+
|
|
507
|
+
declare global {
|
|
508
|
+
const __APP_VERSION__: string
|
|
509
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
interface ImportMetaEnv {
|
|
4
|
+
readonly VITE_LANGUAGE: string
|
|
5
|
+
readonly VITE_THEME: string
|
|
6
|
+
readonly VITE_GRAY_SCALE: string
|
|
7
|
+
readonly VITE_REFRESH: string
|
|
8
|
+
readonly VITE_JSON_PATH: string
|
|
9
|
+
readonly VITE_GEOMETRY_ID: string
|
|
10
|
+
readonly VITE_STATIC_DAYS: string
|
|
11
|
+
// Add other env variables as needed
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ImportMeta {
|
|
15
|
+
readonly env: ImportMetaEnv
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Vue component shim for non-TypeScript components during migration
|
|
19
|
+
declare module '*.vue' {
|
|
20
|
+
import type { DefineComponent } from 'vue'
|
|
21
|
+
const component: DefineComponent<object, object, unknown>
|
|
22
|
+
export default component
|
|
23
|
+
}
|
package/src/vue.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue component exports for use in Vue/Nuxt applications.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { SmartMetAlertClient } from '@fmidev/smartmet-alert-client/vue'
|
|
6
|
+
* import '@fmidev/smartmet-alert-client/vue/style.css'
|
|
7
|
+
*
|
|
8
|
+
* <SmartMetAlertClient
|
|
9
|
+
* :refresh-interval="900000"
|
|
10
|
+
* :selected-day="0"
|
|
11
|
+
* :geometry-id="2021"
|
|
12
|
+
* language="fi"
|
|
13
|
+
* />
|
|
14
|
+
*
|
|
15
|
+
* Props:
|
|
16
|
+
* language String 'fi' Language code: 'fi', 'sv', 'en'
|
|
17
|
+
* theme String 'light' Theme: 'light', 'dark', 'light-gray', 'dark-gray'
|
|
18
|
+
* geometry-id String|Number 2021 Geometry version ID
|
|
19
|
+
* selected-day String|Number 0 Initially selected day (0-4)
|
|
20
|
+
* refresh-interval String|Number 900000 Data refresh interval in ms (0 to disable)
|
|
21
|
+
* region-list-enabled String|Boolean true Show region list below the map
|
|
22
|
+
* static-days String|Boolean true Use static day labels
|
|
23
|
+
* spinner-enabled String|Boolean true Show loading spinner
|
|
24
|
+
* gray-scale-selector String|Boolean true Show grayscale theme toggle
|
|
25
|
+
* sleep String|Boolean true Pause updates when tab is hidden
|
|
26
|
+
* font-scale String|Number 1 Font size multiplier
|
|
27
|
+
* base-url String (FMI GeoServer) Base URL for WFS queries
|
|
28
|
+
* start-from String '' Start date override (ISO format)
|
|
29
|
+
* current-date String|Date null Override current date for testing
|
|
30
|
+
* warnings String|Object null Pre-loaded warnings data (skip fetch)
|
|
31
|
+
* weather-warnings String '' Custom weather warnings query
|
|
32
|
+
* flood-warnings String '' Custom flood warnings query
|
|
33
|
+
* weather-updated String '' Custom weather update time query
|
|
34
|
+
* flood-updated String '' Custom flood update time query
|
|
35
|
+
* daily-warning-types String|Array [] Filter specific warning types
|
|
36
|
+
* debug-mode String|Boolean false Enable debug logging
|
|
37
|
+
*/
|
|
38
|
+
import AlertClientVue from './AlertClientVue.vue'
|
|
39
|
+
|
|
40
|
+
export { AlertClientVue as SmartMetAlertClient }
|
|
41
|
+
export default AlertClientVue
|
package/svgo.config.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
multipass: true,
|
|
3
|
+
js2svg: {
|
|
4
|
+
indent: 2,
|
|
5
|
+
pretty: true,
|
|
6
|
+
},
|
|
7
|
+
plugins: [
|
|
8
|
+
{
|
|
9
|
+
name: 'preset-default',
|
|
10
|
+
params: {
|
|
11
|
+
overrides: {
|
|
12
|
+
// Keep useful IDs in case they're referenced
|
|
13
|
+
cleanupIds: {
|
|
14
|
+
minify: false,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
// Keep viewBox as it's needed for responsive scaling
|
|
20
|
+
{
|
|
21
|
+
name: 'removeViewBox',
|
|
22
|
+
active: false,
|
|
23
|
+
},
|
|
24
|
+
// Remove XML declaration (<?xml version="1.0"?>)
|
|
25
|
+
'removeXMLProcInst',
|
|
26
|
+
// Remove unnecessary xmlns:xlink
|
|
27
|
+
{
|
|
28
|
+
name: 'removeUnusedNS',
|
|
29
|
+
},
|
|
30
|
+
// Clean up numeric values (reduce decimal precision with rounding)
|
|
31
|
+
{
|
|
32
|
+
name: 'cleanupNumericValues',
|
|
33
|
+
params: {
|
|
34
|
+
floatPrecision: 3,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
// Convert style attributes to attributes where possible
|
|
38
|
+
{
|
|
39
|
+
name: 'convertStyleToAttrs',
|
|
40
|
+
params: {
|
|
41
|
+
keepImportant: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
}
|