@vitessce/neuroglancer-workers 4.1.2 → 4.2.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/README.md +21 -8
- package/dist/index.js +15 -36
- package/package.json +5 -10
- package/scripts/build.mjs +194 -0
- package/dist/index.js.map +0 -1
- package/src/index.js +0 -6
package/README.md
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
# @vitessce/neuroglancer-workers
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
We can use rollup and [rollup-plugin-web-worker-loader](https://github.com/darionco/rollup-plugin-web-worker-loader) to perform this build step.
|
|
3
|
+
Inlined Neuroglancer worker scripts, so that consumers of Vitessce do not need to configure their bundler to emit Neuroglancer's worker and WebAssembly files (and so that Vitessce works when loaded cross-origin, e.g. from a CDN in vitessce-python).
|
|
6
4
|
|
|
7
5
|
```sh
|
|
8
6
|
pnpm run build
|
|
9
7
|
```
|
|
10
8
|
|
|
11
|
-
##
|
|
9
|
+
## How it works
|
|
10
|
+
|
|
11
|
+
Mainline [neuroglancer](https://github.com/google/neuroglancer) creates its workers with
|
|
12
|
+
`new Worker(new URL('./chunk_worker.bundle.js', import.meta.url), { type: 'module' })`
|
|
13
|
+
and loads WASM decoders (Draco, PNG, JPEG-XL, compresso) with
|
|
14
|
+
`fetch(new URL('./x.wasm', import.meta.url))`.
|
|
15
|
+
|
|
16
|
+
`scripts/build.mjs` uses Rollup to bundle each worker entry point into a single classic-worker IIFE:
|
|
17
|
+
|
|
18
|
+
- Neuroglancer's package-internal `#src/...` subpath imports are resolved with the `default` condition (all datasources/kvstores enabled).
|
|
19
|
+
- `new URL('./x.wasm', import.meta.url)` is replaced with a `data:application/wasm;base64,...` URL.
|
|
20
|
+
- The async-computation worker (decoders) is spawned from inside the chunk worker, so its code is embedded in the chunk worker and started from a Blob URL (a nested worker). Terminating the chunk worker also terminates these.
|
|
21
|
+
|
|
22
|
+
`dist/index.js` exports `ChunkWorker()`, which starts the chunk worker from a Blob URL.
|
|
23
|
+
|
|
24
|
+
The main-thread side lives in `@vitessce/neuroglancer`: `setup-viewer.js` passes the worker to Neuroglancer's `DataManagementContext`, which is patched (`patches/neuroglancer@2.41.2.patch`) to accept an injected worker instead of constructing one from a URL. The viewer takes ownership of the worker and terminates it on `viewer.dispose()`.
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
## Upgrading Neuroglancer
|
|
14
27
|
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
1. Bump `neuroglancer` here and in `@vitessce/neuroglancer`, and rename the patch / `patchedDependencies` entry to the new version (re-apply with `pnpm patch` if `lib/data_management_context.js` changed).
|
|
29
|
+
2. Run `pnpm run build`. The build fails loudly if the async worker construction in `lib/async_computation/request.js` changed shape, or if any `import.meta` reference survives bundling.
|