@biongff/vizarr 1.0.1 → 1.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.
Files changed (114) hide show
  1. package/dist/biongff-vizarr.cjs.js +1 -0
  2. package/dist/biongff-vizarr.es.js +7 -0
  3. package/dist/blosc-CeItQ6qj.cjs +17 -0
  4. package/dist/blosc-DaK8KnI4.js +719 -0
  5. package/dist/chunk-INHXZS53-DiyuLb3Z.js +14 -0
  6. package/dist/chunk-INHXZS53-z3BpFH8p.cjs +1 -0
  7. package/dist/deflate-BeJu5ryY.js +10 -0
  8. package/dist/deflate-Ctyqttht.cjs +1 -0
  9. package/dist/index-BR2zkK5Y.cjs +3811 -0
  10. package/dist/index-CU_d8468.js +49053 -0
  11. package/dist/index.d.ts +67 -0
  12. package/dist/jpeg-BWDIgcDK.js +533 -0
  13. package/dist/jpeg-Mp_UXZAJ.cjs +1 -0
  14. package/dist/jpeg2k-1tnzEScI.js +24 -0
  15. package/dist/jpeg2k-CcF6vCxI.cjs +1 -0
  16. package/dist/lerc-BJaDi7aO.js +1039 -0
  17. package/dist/lerc-D-6RihsZ.cjs +1 -0
  18. package/dist/lz4-CssV0LoA.js +643 -0
  19. package/dist/lz4-PFaIsPAh.cjs +15 -0
  20. package/dist/lzw-DBp1lk8U.js +84 -0
  21. package/dist/lzw-De76dcEC.cjs +1 -0
  22. package/dist/packbits-B6vt-6GN.cjs +1 -0
  23. package/dist/packbits-MT4dFhEA.js +24 -0
  24. package/dist/pako.esm-Bx5X36Wo.js +1074 -0
  25. package/dist/pako.esm-DZC2QrbJ.cjs +1 -0
  26. package/dist/raw-BF-NUDI1.js +9 -0
  27. package/dist/raw-vwCA5qWn.cjs +1 -0
  28. package/dist/ref-DAXKePD4.cjs +1 -0
  29. package/dist/ref-HqVJFnCG.js +196 -0
  30. package/dist/webimage-BQlxeHEQ.cjs +1 -0
  31. package/dist/webimage-DTyyK3Ev.js +19 -0
  32. package/dist/zstd-Cqadn9HA.js +610 -0
  33. package/dist/zstd-_xUhkGOV.cjs +15 -0
  34. package/package.json +25 -20
  35. package/.gitattributes +0 -1
  36. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
  37. package/.github/ISSUE_TEMPLATE/documentation_update.md +0 -16
  38. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -19
  39. package/.github/ISSUE_TEMPLATE/maintenance.md +0 -19
  40. package/.github/ISSUE_TEMPLATE/optimisation_request.md +0 -23
  41. package/.github/ISSUE_TEMPLATE/support_request.md +0 -25
  42. package/.github/PULL_REQUEST_TEMPLATE.md +0 -21
  43. package/.github/dependabot.yml +0 -13
  44. package/.github/workflows/deploy.yml +0 -56
  45. package/.github/workflows/npm-publish-dev.yml +0 -49
  46. package/.github/workflows/npm-publish.yml +0 -42
  47. package/.github/workflows/release.yml +0 -37
  48. package/.github/workflows/test.yml +0 -21
  49. package/.releaserc.json +0 -29
  50. package/CHANGELOG.md +0 -56
  51. package/CITATION.cff +0 -56
  52. package/CONTRIBUTING.md +0 -82
  53. package/README.md +0 -85
  54. package/assets/favicon.ico +0 -0
  55. package/assets/favicon.png +0 -0
  56. package/assets/logo-wide.png +0 -0
  57. package/assets/logo-wide.svg +0 -60
  58. package/assets/logo.png +0 -0
  59. package/assets/logo.svg +0 -36
  60. package/assets/robots.txt +0 -3
  61. package/assets/screenshot.png +0 -0
  62. package/biome.json +0 -34
  63. package/index.html +0 -24
  64. package/main.ts +0 -52
  65. package/patches/@vivjs__loaders@0.17.2.patch +0 -13
  66. package/python/.python-version +0 -1
  67. package/python/README.md +0 -14
  68. package/python/Untitled.ipynb +0 -40
  69. package/python/deno.json +0 -22
  70. package/python/notebooks/IDR_example.ipynb +0 -86
  71. package/python/notebooks/README.md +0 -35
  72. package/python/notebooks/create_fixture.py +0 -72
  73. package/python/notebooks/getting_started.ipynb +0 -217
  74. package/python/notebooks/mandelbrot.ipynb +0 -211
  75. package/python/notebooks/spatial_transformations.ipynb +0 -139
  76. package/python/pyproject.toml +0 -18
  77. package/python/src/vizarr/__init__.py +0 -10
  78. package/python/src/vizarr/_widget.js +0 -113
  79. package/python/src/vizarr/_widget.py +0 -67
  80. package/python/uv.lock +0 -2495
  81. package/src/ZarrPixelSource.ts +0 -182
  82. package/src/codecs/jpeg2k.ts +0 -22
  83. package/src/codecs/register.ts +0 -2
  84. package/src/components/LayerController/AcquisitionController.tsx +0 -46
  85. package/src/components/LayerController/AddChannelButton.tsx +0 -122
  86. package/src/components/LayerController/AxisOptions.tsx +0 -93
  87. package/src/components/LayerController/AxisSlider.tsx +0 -86
  88. package/src/components/LayerController/AxisSliders.tsx +0 -29
  89. package/src/components/LayerController/ChannelController.tsx +0 -84
  90. package/src/components/LayerController/ChannelOptions.tsx +0 -183
  91. package/src/components/LayerController/ColorPalette.tsx +0 -40
  92. package/src/components/LayerController/Content.tsx +0 -71
  93. package/src/components/LayerController/Header.tsx +0 -48
  94. package/src/components/LayerController/Labels.tsx +0 -73
  95. package/src/components/LayerController/LayerFitToViewportButton.tsx +0 -43
  96. package/src/components/LayerController/LayerVisibilityButton.tsx +0 -32
  97. package/src/components/LayerController/OpacitySlider.tsx +0 -25
  98. package/src/components/LayerController/index.tsx +0 -42
  99. package/src/components/Menu.tsx +0 -54
  100. package/src/components/Viewer.tsx +0 -136
  101. package/src/hooks.ts +0 -29
  102. package/src/index.tsx +0 -138
  103. package/src/io.ts +0 -276
  104. package/src/layers/grid-layer.ts +0 -214
  105. package/src/layers/label-layer.ts +0 -446
  106. package/src/layers/viv-layers.ts +0 -55
  107. package/src/lru-store.ts +0 -57
  108. package/src/ome.ts +0 -388
  109. package/src/state.ts +0 -202
  110. package/src/theme.ts +0 -80
  111. package/src/types.ts +0 -112
  112. package/src/utils.ts +0 -655
  113. package/tsconfig.json +0 -14
  114. package/vite.config.js +0 -47
@@ -1,113 +0,0 @@
1
- import * as vizarr from "https://hms-dbmi.github.io/vizarr/index.js";
2
- import debounce from "https://esm.sh/just-debounce-it@3";
3
-
4
- /**
5
- * @template T
6
- * @param {import("npm:@anywidget/types").AnyModel} model
7
- * @param {any} payload
8
- * @param {{ timeout?: number }} [options]
9
- * @returns {Promise<{ data: T, buffers: DataView[] }>}
10
- */
11
- function send(model, payload, { timeout = 3000 } = {}) {
12
- let uuid = globalThis.crypto.randomUUID();
13
- return new Promise((resolve, reject) => {
14
- let timer = setTimeout(() => {
15
- reject(new Error(`Promise timed out after ${timeout} ms`));
16
- model.off("msg:custom", handler);
17
- }, timeout);
18
- /**
19
- * @param {{ uuid: string, payload: T }} msg
20
- * @param {DataView[]} buffers
21
- */
22
- function handler(msg, buffers) {
23
- if (!(msg.uuid === uuid)) return;
24
- clearTimeout(timer);
25
- resolve({ data: msg.payload, buffers });
26
- model.off("msg:custom", handler);
27
- }
28
- model.on("msg:custom", handler);
29
- model.send({ payload, uuid });
30
- });
31
- }
32
-
33
- /**
34
- * @param {import("npm:@anywidget/types").AnyModel} model
35
- * @param {string | { id: string }} source
36
- */
37
- function get_source(model, source) {
38
- if (typeof source === "string") {
39
- return source;
40
- }
41
- // create a python
42
- return {
43
- /**
44
- * @param {string} key
45
- * @return {Promise<Uint8Array | undefined>}
46
- */
47
- async get(key) {
48
- const { data, buffers } = await send(model, {
49
- type: "get",
50
- source_id: source.id,
51
- key,
52
- });
53
- if (!data.success) {
54
- return undefined;
55
- }
56
- return new Uint8Array(buffers[0].buffer);
57
- },
58
- };
59
- }
60
-
61
- /**
62
- * @typedef Model
63
- * @property {string} height
64
- * @property {ViewState=} view_state
65
- * @property {{ source: string | { id: string }}[]} _configs
66
- */
67
-
68
- /**
69
- * @typedef ViewState
70
- * @property {number} zoom
71
- * @property {[x: number, y: number]} target
72
- */
73
-
74
- export default {
75
- /** @type {import("npm:@anywidget/types").Render<Model>} */
76
- async render({ model, el }) {
77
- let div = document.createElement("div");
78
- {
79
- div.style.height = model.get("height");
80
- div.style.backgroundColor = "black";
81
- model.on("change:height", () => {
82
- div.style.height = model.get("height");
83
- });
84
- }
85
- let viewer = await vizarr.createViewer(div);
86
- {
87
- model.on("change:view_state", () => {
88
- viewer.setViewState(model.get("view_state"));
89
- });
90
- viewer.on(
91
- "viewStateChange",
92
- debounce((/** @type {ViewState} */ update) => {
93
- model.set("view_state", update);
94
- model.save_changes();
95
- }, 200),
96
- );
97
- }
98
- {
99
- // sources are append-only now
100
- for (const config of model.get("_configs")) {
101
- const source = get_source(model, config.source);
102
- viewer.addImage({ ...config, source });
103
- }
104
- model.on("change:_configs", () => {
105
- const last = model.get("_configs").at(-1);
106
- if (!last) return;
107
- const source = get_source(model, last.source);
108
- viewer.addImage({ ...last, source });
109
- });
110
- }
111
- el.appendChild(div);
112
- },
113
- };
@@ -1,67 +0,0 @@
1
- import anywidget
2
- import traitlets
3
- import pathlib
4
-
5
- import zarr
6
- import numpy as np
7
-
8
- __all__ = ["Viewer"]
9
-
10
-
11
- def _store_keyprefix(obj):
12
- # Just grab the store and key_prefix from zarr.Array and zarr.Group objects
13
- if isinstance(obj, (zarr.Array, zarr.Group)):
14
- return obj.store, obj._key_prefix
15
-
16
- if isinstance(obj, np.ndarray):
17
- # Create an in-memory store, and write array as as single chunk
18
- store = {}
19
- arr = zarr.create(
20
- store=store, shape=obj.shape, chunks=obj.shape, dtype=obj.dtype
21
- )
22
- arr[:] = obj
23
- return store, ""
24
-
25
- if hasattr(obj, "__getitem__") and hasattr(obj, "__contains__"):
26
- return obj, ""
27
-
28
- raise TypeError("Cannot normalize store path")
29
-
30
-
31
- class Viewer(anywidget.AnyWidget):
32
- _esm = pathlib.Path(__file__).parent / "_widget.js"
33
- _configs = traitlets.List().tag(sync=True)
34
- view_state = traitlets.Dict().tag(sync=True)
35
- height = traitlets.Unicode("500px").tag(sync=True)
36
-
37
- def __init__(self, **kwargs):
38
- super().__init__(**kwargs)
39
- self._store_paths = []
40
- self.on_msg(self._handle_custom_msg)
41
-
42
- def _handle_custom_msg(self, msg, buffers):
43
- store, key_prefix = self._store_paths[msg["payload"]["source_id"]]
44
- key = key_prefix + msg["payload"]["key"].lstrip("/")
45
-
46
- if msg["payload"]["type"] == "has":
47
- self.send({"uuid": msg["uuid"], "payload": key in store})
48
- return
49
-
50
- if msg["payload"]["type"] == "get":
51
- try:
52
- buffers = [store[key]]
53
- except KeyError:
54
- buffers = []
55
- self.send(
56
- {"uuid": msg["uuid"], "payload": {"success": len(buffers) == 1}},
57
- buffers,
58
- )
59
- return
60
-
61
- def add_image(self, source, **config):
62
- if not isinstance(source, str):
63
- store, key_prefix = _store_keyprefix(source)
64
- source = {"id": len(self._store_paths)}
65
- self._store_paths.append((store, key_prefix))
66
- config["source"] = source
67
- self._configs = self._configs + [config]