@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.
Files changed (123) hide show
  1. package/.eslintignore +2 -14
  2. package/.github/workflows/test.yaml +26 -0
  3. package/.nvmrc +1 -0
  4. package/AGENTS.md +26 -0
  5. package/index.html +1 -1
  6. package/package.json +80 -22
  7. package/src/AlertClientVue.vue +160 -0
  8. package/src/App.vue +154 -296
  9. package/src/assets/img/ui/arrow-down.svg +4 -11
  10. package/src/assets/img/ui/arrow-up.svg +4 -11
  11. package/src/assets/img/ui/clear.svg +7 -21
  12. package/src/assets/img/ui/close.svg +4 -15
  13. package/src/assets/img/ui/toggle-selected.svg +5 -6
  14. package/src/assets/img/ui/toggle-unselected.svg +5 -6
  15. package/src/assets/img/warning/cold-weather.svg +3 -6
  16. package/src/assets/img/warning/flood-level-3.svg +4 -7
  17. package/src/assets/img/warning/forest-fire-weather.svg +2 -6
  18. package/src/assets/img/warning/grass-fire-weather.svg +2 -6
  19. package/src/assets/img/warning/hot-weather.svg +3 -6
  20. package/src/assets/img/warning/pedestrian-safety.svg +3 -7
  21. package/src/assets/img/warning/rain.svg +2 -7
  22. package/src/assets/img/warning/sea-icing.svg +2 -6
  23. package/src/assets/img/warning/sea-thunder-storm.svg +2 -5
  24. package/src/assets/img/warning/sea-water-height-high-water.svg +3 -8
  25. package/src/assets/img/warning/sea-water-height-shallow-water.svg +3 -7
  26. package/src/assets/img/warning/sea-wave-height.svg +4 -7
  27. package/src/assets/img/warning/sea-wind-legend.svg +2 -5
  28. package/src/assets/img/warning/sea-wind.svg +2 -5
  29. package/src/assets/img/warning/several.svg +2 -5
  30. package/src/assets/img/warning/thunder-storm.svg +2 -5
  31. package/src/assets/img/warning/traffic-weather.svg +2 -6
  32. package/src/assets/img/warning/uv-note.svg +2 -6
  33. package/src/assets/img/warning/wind.svg +2 -5
  34. package/src/components/AlertClient.vue +330 -251
  35. package/src/components/CollapsiblePanel.vue +281 -0
  36. package/src/components/DayLarge.vue +146 -110
  37. package/src/components/DaySmall.vue +97 -81
  38. package/src/components/Days.vue +229 -159
  39. package/src/components/DescriptionWarning.vue +63 -38
  40. package/src/components/GrayScaleToggle.vue +58 -54
  41. package/src/components/Legend.vue +102 -325
  42. package/src/components/MapLarge.vue +574 -351
  43. package/src/components/MapSmall.vue +137 -122
  44. package/src/components/PopupRow.vue +24 -12
  45. package/src/components/Region.vue +168 -118
  46. package/src/components/RegionWarning.vue +40 -33
  47. package/src/components/Regions.vue +189 -105
  48. package/src/components/Warning.vue +70 -45
  49. package/src/components/Warnings.vue +136 -72
  50. package/src/composables/useAlertClient.ts +360 -0
  51. package/src/composables/useConfig.ts +573 -0
  52. package/src/composables/useFields.ts +66 -0
  53. package/src/composables/useI18n.ts +62 -0
  54. package/src/composables/useKeyCodes.ts +16 -0
  55. package/src/composables/useMapPaths.ts +477 -0
  56. package/src/composables/useUtils.ts +683 -0
  57. package/src/composables/useWarningsProcessor.ts +1007 -0
  58. package/src/data/geometries.json +993 -0
  59. package/src/{main.js → main.ts} +1 -0
  60. package/src/mixins/geojsonsvg.d.ts +57 -0
  61. package/src/mixins/geojsonsvg.js +5 -3
  62. package/src/plugins/index.ts +5 -0
  63. package/src/scss/_utilities.scss +193 -0
  64. package/src/scss/constants.scss +2 -1
  65. package/src/scss/warningImages.scss +8 -3
  66. package/src/types/index.ts +509 -0
  67. package/src/vite-env.d.ts +23 -0
  68. package/src/vue.ts +41 -0
  69. package/svgo.config.js +45 -0
  70. package/tests/README.md +430 -0
  71. package/tests/fixtures/mockWarningData.ts +152 -0
  72. package/tests/integration/warning-flow.spec.ts +445 -0
  73. package/tests/setup.ts +41 -0
  74. package/tests/unit/components/AlertClient.spec.ts +701 -0
  75. package/tests/unit/components/DayLarge.spec.ts +348 -0
  76. package/tests/unit/components/DaySmall.spec.ts +352 -0
  77. package/tests/unit/components/Days.spec.ts +548 -0
  78. package/tests/unit/components/DescriptionWarning.spec.ts +385 -0
  79. package/tests/unit/components/GrayScaleToggle.spec.ts +318 -0
  80. package/tests/unit/components/Legend.spec.ts +295 -0
  81. package/tests/unit/components/MapLarge.spec.ts +448 -0
  82. package/tests/unit/components/MapSmall.spec.ts +367 -0
  83. package/tests/unit/components/PopupRow.spec.ts +270 -0
  84. package/tests/unit/components/Region.spec.ts +373 -0
  85. package/tests/unit/components/RegionWarning.snapshot.spec.ts +361 -0
  86. package/tests/unit/components/RegionWarning.spec.ts +381 -0
  87. package/tests/unit/components/Regions.spec.ts +503 -0
  88. package/tests/unit/components/Warning.snapshot.spec.ts +483 -0
  89. package/tests/unit/components/Warning.spec.ts +489 -0
  90. package/tests/unit/components/Warnings.spec.ts +343 -0
  91. package/tests/unit/components/__snapshots__/RegionWarning.snapshot.spec.ts.snap +41 -0
  92. package/tests/unit/components/__snapshots__/Warning.snapshot.spec.ts.snap +433 -0
  93. package/tests/unit/composables/useConfig.spec.ts +279 -0
  94. package/tests/unit/composables/useI18n.spec.ts +116 -0
  95. package/tests/unit/composables/useKeyCodes.spec.ts +27 -0
  96. package/tests/unit/composables/useUtils.spec.ts +213 -0
  97. package/tsconfig.json +43 -0
  98. package/tsconfig.node.json +11 -0
  99. package/vite.config.js +96 -26
  100. package/vitest.config.js +40 -0
  101. package/dist/favicon.ico +0 -0
  102. package/dist/index.dark.html +0 -20
  103. package/dist/index.en.html +0 -15
  104. package/dist/index.fi.html +0 -15
  105. package/dist/index.html +0 -15
  106. package/dist/index.js +0 -281
  107. package/dist/index.mjs +0 -281
  108. package/dist/index.mjs.map +0 -1
  109. package/dist/index.relative.html +0 -19
  110. package/dist/index.start.html +0 -20
  111. package/dist/index.sv.html +0 -15
  112. package/playwright.config.ts +0 -18
  113. package/public/index.relative.html +0 -19
  114. package/public/index.start.html +0 -20
  115. package/src/mixins/config.js +0 -1378
  116. package/src/mixins/fields.js +0 -26
  117. package/src/mixins/i18n.js +0 -25
  118. package/src/mixins/keycodes.js +0 -10
  119. package/src/mixins/panzoom.js +0 -900
  120. package/src/mixins/utils.js +0 -900
  121. package/src/plugins/index.js +0 -3
  122. package/test/snapshot.test.ts +0 -126
  123. package/vitest.config.ts +0 -6
package/vite.config.js CHANGED
@@ -2,54 +2,124 @@
2
2
  import vue from '@vitejs/plugin-vue'
3
3
  import { fileURLToPath, URL } from 'node:url'
4
4
  import { visualizer } from 'rollup-plugin-visualizer'
5
- import { BootstrapVueNextResolver } from 'unplugin-vue-components/resolvers'
6
- import Components from 'unplugin-vue-components/vite'
7
5
  import { defineConfig } from 'vite'
8
6
  import banner from 'vite-plugin-banner'
9
7
  import { viteStaticCopy } from 'vite-plugin-static-copy'
10
8
 
11
9
  import pkg from './package.json'
12
10
 
11
+ // Check build mode: 'vue' for library build, default for web component
12
+ const buildMode = process.env.BUILD_MODE
13
+
13
14
  export default defineConfig({
14
15
  base: './',
15
16
  plugins: [
16
17
  vue({
17
- customElement: true,
18
- }),
19
- Components({
20
- resolvers: [BootstrapVueNextResolver()],
18
+ // Only use customElement mode for web component build
19
+ customElement: buildMode !== 'vue',
21
20
  }),
22
21
  banner(
23
22
  `/**\n * name: ${pkg.name}\n * version: v${pkg.version}\n * description: ${pkg.description}\n * author: ${pkg.author}\n * homepage: ${pkg.homepage}\n */`
24
23
  ),
25
24
  visualizer(),
26
- viteStaticCopy({
27
- targets: [
25
+ ...(buildMode !== 'vue'
26
+ ? [
27
+ viteStaticCopy({
28
+ targets: [
29
+ {
30
+ src: 'dist/index.mjs',
31
+ dest: './',
32
+ rename: 'index.js',
33
+ },
34
+ ],
35
+ }),
36
+ ]
37
+ : []),
38
+ ],
39
+ build:
40
+ buildMode === 'vue'
41
+ ? // Vue library build configuration
28
42
  {
29
- src: 'dist/index.mjs',
30
- dest: './',
31
- rename: 'index.js',
43
+ target: 'es2020',
44
+ outDir: 'dist/vue',
45
+ sourcemap: false,
46
+ minify: 'esbuild',
47
+ cssCodeSplit: false,
48
+ cssMinify: true,
49
+ copyPublicDir: false,
50
+ lib: {
51
+ entry: fileURLToPath(new URL('./src/vue.ts', import.meta.url)),
52
+ name: 'SmartMetAlertClient',
53
+ formats: ['es'],
54
+ fileName: () => 'index.mjs',
55
+ },
56
+ rollupOptions: {
57
+ external: ['vue'],
58
+ output: {
59
+ globals: {
60
+ vue: 'Vue',
61
+ },
62
+ generatedCode: {
63
+ constBindings: true,
64
+ objectShorthand: true,
65
+ },
66
+ },
67
+ },
32
68
  }
33
- ]
34
- })
35
- ],
69
+ : // Web component build configuration (default)
70
+ {
71
+ target: 'es2020',
72
+ outDir: 'dist',
73
+ assetsDir: '',
74
+ sourcemap: false,
75
+ minify: 'esbuild',
76
+ cssCodeSplit: false,
77
+ cssMinify: true,
78
+ chunkSizeWarningLimit: 1500,
79
+ rollupOptions: {
80
+ output: {
81
+ entryFileNames: 'index.mjs',
82
+ compact: true,
83
+ inlineDynamicImports: false,
84
+ manualChunks: (id) => {
85
+ // XML parsers as separate chunk
86
+ if (id.includes('@xmldom/xmldom') || id.includes('xpath')) {
87
+ return 'xml-parser'
88
+ }
89
+ // Locale files as separate chunks
90
+ if (id.includes('/locales/')) {
91
+ const match = id.match(/locales\/(\w+)\.json/)
92
+ if (match) {
93
+ return `locale-${match[1]}`
94
+ }
95
+ }
96
+ // Core vendor libraries
97
+ if (id.includes('node_modules')) {
98
+ if (id.includes('vue')) {
99
+ return 'vendor'
100
+ }
101
+ }
102
+ },
103
+ generatedCode: {
104
+ constBindings: true,
105
+ objectShorthand: true,
106
+ },
107
+ },
108
+ },
109
+ },
110
+ css: {
111
+ preprocessorOptions: {
112
+ scss: {
113
+ api: 'modern-compiler',
114
+ silenceDeprecations: ['import', 'legacy-js-api'],
115
+ },
116
+ },
117
+ },
36
118
  resolve: {
37
119
  alias: {
38
120
  '@': fileURLToPath(new URL('./src', import.meta.url)),
39
121
  },
40
122
  },
41
- build: {
42
- target: 'es2019',
43
- outDir: 'dist',
44
- assetsDir: '',
45
- sourcemap: true,
46
- minify: true,
47
- rollupOptions: {
48
- output: {
49
- entryFileNames: 'index.mjs',
50
- },
51
- },
52
- },
53
123
  define: {
54
124
  __APP_VERSION__: JSON.stringify(pkg.version),
55
125
  },
@@ -0,0 +1,40 @@
1
+ import { defineConfig } from 'vitest/config'
2
+ import vue from '@vitejs/plugin-vue'
3
+ import path from 'path'
4
+
5
+ export default defineConfig({
6
+ plugins: [vue()],
7
+ css: {
8
+ preprocessorOptions: {
9
+ scss: {
10
+ api: 'modern-compiler',
11
+ silenceDeprecations: ['import', 'legacy-js-api'],
12
+ },
13
+ },
14
+ },
15
+ test: {
16
+ globals: true,
17
+ environment: 'jsdom',
18
+ setupFiles: ['./tests/setup.ts'],
19
+ coverage: {
20
+ provider: 'v8',
21
+ reporter: ['text', 'json', 'html'],
22
+ exclude: [
23
+ 'node_modules/',
24
+ 'tests/',
25
+ 'dist/',
26
+ 'public/',
27
+ '*.config.js',
28
+ '.eslintrc.js',
29
+ ],
30
+ },
31
+ },
32
+ resolve: {
33
+ alias: {
34
+ '@': path.resolve(__dirname, './src'),
35
+ },
36
+ },
37
+ define: {
38
+ __APP_VERSION__: JSON.stringify('test-version'),
39
+ },
40
+ })
package/dist/favicon.ico DELETED
Binary file
@@ -1,20 +0,0 @@
1
- <!doctype html>
2
- <html lang="fi">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta
6
- name="viewport"
7
- content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0, user-scalable=yes" />
8
- <title>SmartMet Alert Client</title>
9
- <style>
10
- body {
11
- background-color: #191b22;
12
- }
13
- </style>
14
- </head>
15
-
16
- <body>
17
- <smartmet-alert-client language="fi" theme="dark"></smartmet-alert-client>
18
- <script type="module" src="./index.js"></script>
19
- </body>
20
- </html>
@@ -1,15 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta
6
- name="viewport"
7
- content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0, user-scalable=yes" />
8
- <title>SmartMet Alert Client</title>
9
- </head>
10
-
11
- <body>
12
- <smartmet-alert-client language="en"></smartmet-alert-client>
13
- <script type="module" src="./index.js"></script>
14
- </body>
15
- </html>
@@ -1,15 +0,0 @@
1
- <!doctype html>
2
- <html lang="fi">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta
6
- name="viewport"
7
- content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0, user-scalable=yes" />
8
- <title>SmartMet Alert Client</title>
9
- </head>
10
-
11
- <body>
12
- <smartmet-alert-client language="fi"></smartmet-alert-client>
13
- <script type="module" src="./index.js"></script>
14
- </body>
15
- </html>
package/dist/index.html DELETED
@@ -1,15 +0,0 @@
1
- <!doctype html>
2
- <html lang="fi">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta
6
- name="viewport"
7
- content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
8
- <title>SmartMet Alert Client</title>
9
- <script type="module" crossorigin src="./index.mjs"></script>
10
- </head>
11
-
12
- <body>
13
- <smartmet-alert-client></smartmet-alert-client>
14
- </body>
15
- </html>