@vitessce/neuroglancer 3.5.8

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/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@vitessce/neuroglancer",
3
+ "version": "3.5.8",
4
+ "author": "Gehlenborg Lab",
5
+ "homepage": "http://vitessce.io",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/vitessce/vitessce.git"
9
+ },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "main": "dist/index.js",
13
+ "files": [
14
+ "src",
15
+ "dist",
16
+ "dist-tsc"
17
+ ],
18
+ "dependencies": {
19
+ "@janelia-flyem/react-neuroglancer": "^2.5.0",
20
+ "@material-ui/core": "~4.12.3",
21
+ "@vitessce/neuroglancer-workers": "3.5.8",
22
+ "@vitessce/constants-internal": "3.5.8",
23
+ "@vitessce/vit-s": "3.5.8"
24
+ },
25
+ "devDependencies": {
26
+ "@testing-library/jest-dom": "^5.16.4",
27
+ "@testing-library/react": "^13.3.0",
28
+ "react": "^18.0.0",
29
+ "vite": "^4.3.0",
30
+ "vitest": "^0.32.2"
31
+ },
32
+ "scripts": {
33
+ "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
34
+ "test": "pnpm exec vitest --run"
35
+ },
36
+ "module": "dist/index.js",
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist-tsc/index.d.ts",
40
+ "import": "./dist/index.js"
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,49 @@
1
+ import React, { useCallback, useMemo, Suspense } from 'react';
2
+ import { ChunkWorker } from '@vitessce/neuroglancer-workers';
3
+ import { useStyles, globalNeuroglancerCss } from './styles.js';
4
+
5
+ // We lazy load the Neuroglancer component,
6
+ // because the non-dynamic import causes problems for Vitest,
7
+ // as the package appears contain be a mix of CommonJS and ESM syntax.
8
+ const LazyReactNeuroglancer = React.lazy(async () => {
9
+ const ReactNeuroglancer = await import('@janelia-flyem/react-neuroglancer');
10
+ return ReactNeuroglancer;
11
+ });
12
+
13
+ // Reference: https://github.com/developit/jsdom-worker/issues/14#issuecomment-1268070123
14
+ function createWorker() {
15
+ return new ChunkWorker();
16
+ }
17
+
18
+ export function Neuroglancer(props) {
19
+ const {
20
+ viewerState,
21
+ onViewerStateChanged,
22
+ } = props;
23
+ const classes = useStyles();
24
+ const bundleRoot = useMemo(() => createWorker(), []);
25
+
26
+ const handleStateChanged = useCallback((newState) => {
27
+ if (JSON.stringify(newState) !== JSON.stringify(viewerState)) {
28
+ if (onViewerStateChanged) {
29
+ onViewerStateChanged(newState);
30
+ }
31
+ }
32
+ }, [onViewerStateChanged, viewerState]);
33
+
34
+ return (
35
+ <>
36
+ <style>{globalNeuroglancerCss}</style>
37
+ <div className={classes.neuroglancerWrapper}>
38
+ <Suspense fallback={<div>Loading...</div>}>
39
+ <LazyReactNeuroglancer
40
+ brainMapsClientId="NOT_A_VALID_ID"
41
+ viewerState={viewerState}
42
+ onViewerStateChanged={handleStateChanged}
43
+ bundleRoot={bundleRoot}
44
+ />
45
+ </Suspense>
46
+ </div>
47
+ </>
48
+ );
49
+ }
@@ -0,0 +1,35 @@
1
+
2
+ import {
3
+ TitleInfo,
4
+ } from '@vitessce/vit-s';
5
+
6
+ import { ViewHelpMapping } from '@vitessce/constants-internal';
7
+ import { Neuroglancer } from './Neuroglancer.js';
8
+
9
+ export function NeuroglancerSubscriber(props) {
10
+ const {
11
+ closeButtonVisible,
12
+ downloadButtonVisible,
13
+ removeGridComponent,
14
+ theme,
15
+ title = 'Neuroglancer',
16
+ viewerState: viewerStateInitial = null,
17
+ helpText = ViewHelpMapping.NEUROGLANCER,
18
+ } = props;
19
+
20
+ return (
21
+ <TitleInfo
22
+ title={title}
23
+ helpText={helpText}
24
+ isSpatial
25
+ theme={theme}
26
+ closeButtonVisible={closeButtonVisible}
27
+ downloadButtonVisible={downloadButtonVisible}
28
+ removeGridComponent={removeGridComponent}
29
+ isReady
30
+ >
31
+ {viewerStateInitial && <Neuroglancer viewerState={viewerStateInitial} />}
32
+ </TitleInfo>
33
+
34
+ );
35
+ }
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ export { NeuroglancerSubscriber } from './NeuroglancerSubscriber.js';