Skip to content

Commit e3a2ce9

Browse files
committed
Upgrade deps including H5Web to v14
1 parent e1e6a2c commit e3a2ce9

File tree

9 files changed

+3031
-3288
lines changed

9 files changed

+3031
-3288
lines changed

package.json

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "https://gitlab.esrf.fr/ui/myhdf5"
1111
},
1212
"engines": {
13-
"node": "20.x",
13+
"node": "22.x",
1414
"pnpm": "9.x"
1515
},
1616
"packageManager": "[email protected]",
@@ -23,38 +23,37 @@
2323
"lint:eslint": "eslint \"**/*.{ts,tsx}\" --max-warnings=0",
2424
"lint:tsc": "tsc",
2525
"lint:prettier": "prettier --cache --check .",
26-
"analyze": "npx source-map-explorer 'build/static/js/*.js'"
26+
"analyze": "pnpm dlx source-map-explorer \"dist/assets/*.js\" --no-border-checks"
2727
},
2828
"dependencies": {
29-
"@h5web/app": "13.0.0",
30-
"@h5web/h5wasm": "13.0.0",
31-
"@react-hookz/web": "15.1.0",
29+
"@h5web/app": "14.0.0",
30+
"@h5web/h5wasm": "14.0.0",
31+
"@react-hookz/web": "25.1.0",
3232
"h5wasm-plugins": "0.0.3",
33-
"immer": "9.0.15",
3433
"normalize.css": "8.0.1",
35-
"react": "18.2.0",
36-
"react-dom": "18.2.0",
37-
"react-dropzone": "14.2.1",
38-
"react-error-boundary": "4.0.11",
39-
"react-hook-form": "7.34.2",
40-
"react-icons": "4.4.0",
34+
"react": "18.3.1",
35+
"react-dom": "18.3.1",
36+
"react-dropzone": "14.3.8",
37+
"react-error-boundary": "5.0.0",
38+
"react-hook-form": "7.54.2",
39+
"react-icons": "5.4.0",
4140
"react-router-dom": "6.3.0",
42-
"suspend-react": "0.0.8",
43-
"zustand": "4.0.0"
41+
"suspend-react": "0.1.3",
42+
"zustand": "5.0.3"
4443
},
4544
"devDependencies": {
46-
"@types/node": "^20.10.5",
47-
"@types/react": "^18.2.31",
48-
"@types/react-dom": "^18.2.14",
49-
"@vitejs/plugin-react": "4.2.1",
45+
"@types/node": "^22.13.10",
46+
"@types/react": "^18.3.19",
47+
"@types/react-dom": "^18.3.5",
48+
"@vitejs/plugin-react-swc": "3.8.1",
5049
"babel-preset-react-app": "10.0.1",
5150
"eslint": "8.56.0",
5251
"eslint-config-galex": "4.5.2",
5352
"npm-run-all": "4.1.5",
54-
"prettier": "3.1.1",
53+
"prettier": "3.5.3",
5554
"typescript": "5.0.4",
56-
"vite": "5.1.6",
57-
"vite-plugin-checker": "0.6.4",
55+
"vite": "6.2.2",
56+
"vite-plugin-checker": "0.9.1",
5857
"vite-plugin-eslint": "1.8.1"
5958
},
6059
"pnpm": {

pnpm-lock.yaml

Lines changed: 2970 additions & 3169 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/LocalFileViewer.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { H5WasmLocalFileProvider } from '@h5web/h5wasm';
33

44
import { getPlugin } from './plugin-utils';
55
import type { LocalFile } from './stores';
6-
import { buildMailto, FEEDBACK_MESSAGE, getExportURL } from './utils';
6+
import { buildMailto, FEEDBACK_MESSAGE } from './utils';
77

88
export const CACHE_KEY = Symbol('bufferFetcher');
99

@@ -16,11 +16,7 @@ function LocalFileViewer(props: Props) {
1616
const { resolvedUrl, file: rawFile } = file;
1717

1818
return (
19-
<H5WasmLocalFileProvider
20-
file={rawFile}
21-
getExportURL={getExportURL}
22-
getPlugin={getPlugin}
23-
>
19+
<H5WasmLocalFileProvider file={rawFile} getPlugin={getPlugin}>
2420
<App
2521
key={resolvedUrl}
2622
disableDarkMode

src/RemoteFileViewer.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { suspend } from 'suspend-react';
55
import { fetchBuffer } from './fetch-utils';
66
import { getPlugin } from './plugin-utils';
77
import type { RemoteFile } from './stores';
8-
import { buildMailto, FEEDBACK_MESSAGE, getExportURL } from './utils';
8+
import { buildMailto, FEEDBACK_MESSAGE } from './utils';
99

1010
export const CACHE_KEY = Symbol('bufferFetcher');
1111

@@ -20,12 +20,7 @@ function RemoteFileViewer(props: Props) {
2020
const buffer = suspend(fetchBuffer, [resolvedUrl, CACHE_KEY]);
2121

2222
return (
23-
<H5WasmBufferProvider
24-
filename={name}
25-
buffer={buffer}
26-
getExportURL={getExportURL}
27-
getPlugin={getPlugin}
28-
>
23+
<H5WasmBufferProvider filename={name} buffer={buffer} getPlugin={getPlugin}>
2924
<App
3025
key={resolvedUrl}
3126
disableDarkMode

src/index.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
--color-btns: #f06f66;
66
--color-five: lightgreen;
77

8-
--font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
9-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
10-
sans-serif;
8+
--font-body:
9+
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
10+
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
1111
--font-logo: 'Lobster', var(--font-body);
1212
}
1313

@@ -34,7 +34,8 @@ body {
3434
}
3535

3636
code {
37-
font-family: 'Lucida Console', 'Lucida Sans Typewriter', monaco,
37+
font-family:
38+
'Lucida Console', 'Lucida Sans Typewriter', monaco,
3839
'Bitstream Vera Sans Mono', monospace;
3940
}
4041

src/sidebar/OpenedFiles.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
useSearchParams,
1616
} from 'react-router-dom';
1717
import { clear } from 'suspend-react';
18-
import shallow from 'zustand/shallow';
1918

2019
import type { H5File } from '../stores';
2120
import { FileService, useStore } from '../stores';
@@ -31,10 +30,8 @@ const ICONS: Record<FileService, IconType> = {
3130
};
3231

3332
function OpenedFiles() {
34-
const { opened, removeFileAt } = useStore(
35-
({ opened, removeFileAt }) => ({ opened, removeFileAt }),
36-
shallow,
37-
);
33+
const opened = useStore((state) => state.opened);
34+
const removeFileAt = useStore((state) => state.removeFileAt);
3835

3936
const navigate = useNavigate();
4037
const [searchParams] = useSearchParams();

src/stores.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import create from 'zustand';
1+
import { create } from 'zustand';
22
import { persist } from 'zustand/middleware';
3-
import { immer } from 'zustand/middleware/immer';
43

54
export enum FileService {
65
Local = 'Local',
@@ -38,38 +37,36 @@ interface Store {
3837
}
3938

4039
export const useStore = create<Store>()(
41-
immer(
42-
persist(
43-
(set) => ({
44-
opened: [],
40+
persist(
41+
(set) => ({
42+
opened: [],
4543

46-
openFiles: (files) => {
47-
set((state) => {
48-
state.opened.push(...files);
49-
});
50-
},
44+
openFiles: (files) => {
45+
set((state) => ({ opened: [...state.opened, ...files] }));
46+
},
5147

52-
removeFileAt: (index) => {
53-
set((state) => {
54-
state.opened.splice(index, 1);
55-
});
56-
},
48+
removeFileAt: (index) => {
49+
set((state) => ({
50+
opened: [
51+
...state.opened.slice(0, index),
52+
...state.opened.slice(index + 1),
53+
],
54+
}));
55+
},
5756

58-
sidebarMayCollapse: false,
59-
toggleSidebar: () => {
60-
set((state) => {
61-
state.sidebarMayCollapse = !state.sidebarMayCollapse;
62-
});
63-
},
64-
}),
65-
{
66-
name: 'myhdf5',
67-
partialize: ({ opened, sidebarMayCollapse }) => ({
68-
opened: opened.filter(({ service }) => service !== FileService.Local), // filter out local files, since they can't be re-opened
69-
sidebarMayCollapse,
70-
}),
71-
version: 1,
57+
sidebarMayCollapse: false,
58+
59+
toggleSidebar: () => {
60+
set((state) => ({ sidebarMayCollapse: !state.sidebarMayCollapse }));
7261
},
73-
),
62+
}),
63+
{
64+
name: 'myhdf5',
65+
partialize: ({ opened, sidebarMayCollapse }) => ({
66+
opened: opened.filter(({ service }) => service !== FileService.Local), // filter out local files, since they can't be re-opened
67+
sidebarMayCollapse,
68+
}),
69+
version: 1,
70+
},
7471
),
7572
);

src/utils.ts

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { GetExportURL } from '@h5web/app';
21
import { createSearchParams } from 'react-router-dom';
32

43
import {
@@ -122,44 +121,3 @@ export const FEEDBACK_MESSAGE = `<<
122121
=> To report an issue, please include screenshots, reproduction steps, etc.
123122
=> To suggest a new feature, please describe the needs this feature would fulfill.
124123
>>`;
125-
126-
export const getExportURL: GetExportURL = (
127-
format,
128-
dataset,
129-
selection,
130-
value,
131-
// eslint-disable-next-line sonarjs/cognitive-complexity
132-
) => {
133-
if (format !== 'csv') {
134-
return undefined;
135-
}
136-
137-
return async () => {
138-
// Find dimensions of dataset/slice to export
139-
// Note that there is currently no way to know if the dataset/slice is transposed - https://github.com/silx-kit/h5web/issues/1454
140-
const dims = selection
141-
? dataset.shape.filter((_, index) => selection[index * 2] === ':')
142-
: dataset.shape;
143-
144-
if (dims.length === 0 || dims.length > 2) {
145-
throw new Error(
146-
'Expected dataset/slice to export to have 1 or 2 dimensions',
147-
);
148-
}
149-
150-
let csv = '';
151-
const [rows, cols = 1] = dims; // export 1D dataset/slice as column (i.e. 1 value per line)
152-
153-
for (let i = 0; i < rows; i += 1) {
154-
for (let j = 0; j < cols; j += 1) {
155-
csv += `${(value[i * cols + j] as number).toString()}${
156-
j < cols - 1 ? ',' : ''
157-
}`;
158-
}
159-
160-
csv += i < rows - 1 ? '\n' : '';
161-
}
162-
163-
return new Blob([csv]);
164-
};
165-
};

vite.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import react from '@vitejs/plugin-react';
1+
import react from '@vitejs/plugin-react-swc';
22
import { defineConfig } from 'vite';
33
import { checker } from 'vite-plugin-checker';
44
// https://github.com/gxmari007/vite-plugin-eslint/pull/90
@@ -20,7 +20,6 @@ export default defineConfig({
2020
optimizeDeps: { esbuildOptions: { target: 'es2020' } },
2121
build: {
2222
target: 'es2020',
23-
// Out of memory! https://github.com/vitejs/vite/issues/2433
24-
// sourcemap: true,
23+
sourcemap: true,
2524
},
2625
});

0 commit comments

Comments
 (0)