@vitessce/vit-s 3.8.6 → 3.8.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/dist/index.js CHANGED
@@ -32251,7 +32251,7 @@ const AUTO_INDEPENDENT_COORDINATION_TYPES = [
32251
32251
  CoordinationType$1.HIERARCHY_LEVELS
32252
32252
  ]
32253
32253
  });
32254
- const version = "3.8.6";
32254
+ const version = "3.8.8";
32255
32255
  const META_VERSION = {
32256
32256
  version
32257
32257
  };
@@ -44290,7 +44290,7 @@ After: ${JSON.stringify(coordinationValuesWithDefaults)}`);
44290
44290
  }
44291
44291
  return coordinationValuesWithDefaults;
44292
44292
  }
44293
- function createLoaders(datasets, configDescription, fileTypes, coordinationTypes, stores) {
44293
+ function createLoaders(datasets, configDescription, fileTypes, coordinationTypes, stores, queryClient) {
44294
44294
  const result = {};
44295
44295
  const dataSources = new InternMap([], JSON.stringify);
44296
44296
  const defaultCoordinationValues = Object.fromEntries(
@@ -44331,7 +44331,8 @@ function createLoaders(datasets, configDescription, fileTypes, coordinationTypes
44331
44331
  refSpecUrl: options == null ? void 0 : options.refSpecUrl,
44332
44332
  // Optionally, pass a Zarrita store to the data source,
44333
44333
  // if one was mapped to this URL.
44334
- store: stores == null ? void 0 : stores[url]
44334
+ store: stores == null ? void 0 : stores[url],
44335
+ queryClient
44335
44336
  }));
44336
44337
  }
44337
44338
  const loader = new LoaderClass(dataSources.get(dataSourceKey), file);
@@ -44970,11 +44971,12 @@ function VitessceGrid(props) {
44970
44971
  coordinationTypes,
44971
44972
  stores,
44972
44973
  pageMode,
44973
- children
44974
+ children,
44975
+ queryClient
44974
44976
  } = props;
44975
44977
  const [rowHeight, containerRef] = useRowHeight(config2, initialRowHeight, height2, margin, padding);
44976
44978
  const onResize = useEmitGridResize();
44977
- const [componentWidth] = useClosestVitessceContainerSize(containerRef, 0);
44979
+ const [componentWidth] = useClosestVitessceContainerSize(containerRef);
44978
44980
  const { classes } = useVitessceContainerStyles();
44979
44981
  const { classes: titleClasses } = useTitleStyles();
44980
44982
  const altText = useMemo(() => getAltText(config2), [configKey]);
@@ -45001,7 +45003,8 @@ function VitessceGrid(props) {
45001
45003
  config2.description,
45002
45004
  fileTypes,
45003
45005
  coordinationTypes,
45004
- stores
45006
+ stores,
45007
+ queryClient
45005
45008
  );
45006
45009
  newConfig = config2;
45007
45010
  }
@@ -45469,7 +45472,8 @@ function VitS(props) {
45469
45472
  configOrWarning.description,
45470
45473
  fileTypes,
45471
45474
  coordinationTypes,
45472
- stores
45475
+ stores,
45476
+ queryClient
45473
45477
  );
45474
45478
  return createViewConfigStore(loaders, configOrWarning);
45475
45479
  }
@@ -45498,7 +45502,8 @@ function VitS(props) {
45498
45502
  height: height2,
45499
45503
  theme,
45500
45504
  isBounded,
45501
- stores
45505
+ stores,
45506
+ queryClient
45502
45507
  },
45503
45508
  children
45504
45509
  ), /* @__PURE__ */ React__default.createElement(
@@ -47612,7 +47617,20 @@ class FlatFileSystemStore {
47612
47617
  const buffer = await file.arrayBuffer();
47613
47618
  return new Uint8Array(buffer);
47614
47619
  }
47615
- // TODO: implement getRange
47620
+ async getRange(key, range2) {
47621
+ const file = this.files.find((f2) => `/${f2.relpath}` === key);
47622
+ if (!file) return void 0;
47623
+ const buffer = await file.arrayBuffer();
47624
+ if ("suffixLength" in range2) {
47625
+ const { suffixLength } = range2;
47626
+ return new Uint8Array(buffer, buffer.byteLength - suffixLength, suffixLength);
47627
+ }
47628
+ if ("offset" in range2 && "length" in range2) {
47629
+ const { offset: offset2, length: length2 } = range2;
47630
+ return new Uint8Array(buffer, offset2, length2);
47631
+ }
47632
+ throw new Error("Invalid rangeQuery value.");
47633
+ }
47616
47634
  }
47617
47635
  function createOnDrop(setters, isFileInput = false, isConfigInput = false) {
47618
47636
  return async (e2) => {
@@ -1 +1 @@
1
- {"version":3,"file":"VitS.d.ts","sourceRoot":"","sources":["../src/VitS.js"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,4BApCG;IAAsB,MAAM,EAApB,MAAM;IAGkB,SAAS,EAAjC,SAAS,GAAC,MAAM;IACF,MAAM,EAApB,MAAM;IACQ,KAAK,EAAnB,MAAM;IAEU,MAAM;IACN,cAAc;IAEd,cAAc;IAEf,cAAc,EAA7B,OAAO;IAIQ,sBAAsB,EAArC,OAAO;IAGY,GAAG,EAAtB,IAAI,GAAC,MAAM;IAGW,cAAc,EAApC,SAAS,GAAC,IAAI;IAEC,kBAAkB,EAAjC,OAAO;IAEM,SAAS,EAAtB,KAAK;IACQ,SAAS,EAAtB,KAAK;IACQ,cAAc,EAA3B,KAAK;IACQ,iBAAiB,EAA9B,KAAK;IACc,OAAO,EAA1B,IAAI,GAAC,MAAM;IACI,QAAQ,EAAvB,OAAO;IACQ,SAAS,EAAxB,OAAO;IACY,QAAQ,EAA3B,IAAI,GAAC,MAAM;CAErB,eAmQA"}
1
+ {"version":3,"file":"VitS.d.ts","sourceRoot":"","sources":["../src/VitS.js"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,4BApCG;IAAsB,MAAM,EAApB,MAAM;IAGkB,SAAS,EAAjC,SAAS,GAAC,MAAM;IACF,MAAM,EAApB,MAAM;IACQ,KAAK,EAAnB,MAAM;IAEU,MAAM;IACN,cAAc;IAEd,cAAc;IAEf,cAAc,EAA7B,OAAO;IAIQ,sBAAsB,EAArC,OAAO;IAGY,GAAG,EAAtB,IAAI,GAAC,MAAM;IAGW,cAAc,EAApC,SAAS,GAAC,IAAI;IAEC,kBAAkB,EAAjC,OAAO;IAEM,SAAS,EAAtB,KAAK;IACQ,SAAS,EAAtB,KAAK;IACQ,cAAc,EAA3B,KAAK;IACQ,iBAAiB,EAA9B,KAAK;IACc,OAAO,EAA1B,IAAI,GAAC,MAAM;IACI,QAAQ,EAAvB,OAAO;IACQ,SAAS,EAAxB,OAAO;IACY,QAAQ,EAA3B,IAAI,GAAC,MAAM;CAErB,eA4PA"}
package/dist-tsc/VitS.js CHANGED
@@ -55,14 +55,6 @@ import { AsyncFunctionsContext } from './contexts.js';
55
55
  */
56
56
  export function VitS(props) {
57
57
  const { config, stores, rowHeight, height, theme, onWarn, onConfigChange, onLoaderChange, validateConfig = true, validateOnConfigChange = false, isBounded = false, uid = null, styleContainer, remountOnUidChange = true, viewTypes: viewTypesProp, fileTypes: fileTypesProp, jointFileTypes: jointFileTypesProp, coordinationTypes: coordinationTypesProp, asyncFunctions: asyncFunctionsProp, warning, pageMode = false, children, debugMode = DEFAULT_DEBUG_MODE, logLevel = DEFAULT_LOG_LEVEL, } = props;
58
- /*
59
- const prefersDark = (
60
- window.matchMedia
61
- && window.matchMedia('(prefers-color-scheme: dark)').matches
62
- );
63
- const defaultTheme = prefersDark ? 'dark' : 'light';
64
- const [theme, setTheme] = useState(themeProp ?? defaultTheme);
65
- */
66
58
  // eslint-disable-next-line no-unused-vars
67
59
  const [debugErrors, setDebugErrors] = useState([]);
68
60
  const viewTypes = useMemo(() => (viewTypesProp || []), [viewTypesProp]);
@@ -184,7 +176,7 @@ export function VitS(props) {
184
176
  // Initialize the view config and loaders in the global state.
185
177
  const createViewConfigStoreClosure = useCallback(() => {
186
178
  if (success) {
187
- const loaders = createLoaders(configOrWarning.datasets, configOrWarning.description, fileTypes, coordinationTypes, stores);
179
+ const loaders = createLoaders(configOrWarning.datasets, configOrWarning.description, fileTypes, coordinationTypes, stores, queryClient);
188
180
  return createViewConfigStore(loaders, configOrWarning);
189
181
  }
190
182
  // No config found, so clear the loaders.
@@ -197,5 +189,5 @@ export function VitS(props) {
197
189
  if (debugMode && debugErrors.length > 0) {
198
190
  return (_jsx(CacheProvider, { value: muiCache, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(DebugWindow, { debugErrors: debugErrors }) }) }));
199
191
  }
200
- return success ? (_jsx(CacheProvider, { value: muiCache, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(ViewConfigProvider, { createStore: createViewConfigStoreClosure, children: _jsx(AuxiliaryProvider, { createStore: createAuxiliaryStore, children: _jsxs(AsyncFunctionsContext.Provider, { value: asyncFunctions, children: [_jsx(VitessceGrid, { pageMode: pageMode, success: success, configKey: configKey, viewTypes: viewTypes, fileTypes: fileTypes, coordinationTypes: coordinationTypes, config: configOrWarning, rowHeight: rowHeight, height: height, theme: theme, isBounded: isBounded, stores: stores, children: children }), _jsx(CallbackPublisher, { onWarn: onWarn, onConfigChange: onConfigChange, onLoaderChange: onLoaderChange, validateOnConfigChange: validateOnConfigChange, pluginSpecificConfigSchema: pluginSpecificConfigSchema })] }) }) }, (remountOnUidChange ? configKey : undefined)) }) }) })) : (_jsx(CacheProvider, { value: muiCache, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(Warning, { ...configOrWarning }) }) }));
192
+ return success ? (_jsx(CacheProvider, { value: muiCache, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(ViewConfigProvider, { createStore: createViewConfigStoreClosure, children: _jsx(AuxiliaryProvider, { createStore: createAuxiliaryStore, children: _jsxs(AsyncFunctionsContext.Provider, { value: asyncFunctions, children: [_jsx(VitessceGrid, { pageMode: pageMode, success: success, configKey: configKey, viewTypes: viewTypes, fileTypes: fileTypes, coordinationTypes: coordinationTypes, config: configOrWarning, rowHeight: rowHeight, height: height, theme: theme, isBounded: isBounded, stores: stores, queryClient: queryClient, children: children }), _jsx(CallbackPublisher, { onWarn: onWarn, onConfigChange: onConfigChange, onLoaderChange: onLoaderChange, validateOnConfigChange: validateOnConfigChange, pluginSpecificConfigSchema: pluginSpecificConfigSchema })] }) }) }, (remountOnUidChange ? configKey : undefined)) }) }) })) : (_jsx(CacheProvider, { value: muiCache, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(Warning, { ...configOrWarning }) }) }));
201
193
  }
@@ -1 +1 @@
1
- {"version":3,"file":"VitessceGrid.d.ts","sourceRoot":"","sources":["../src/VitessceGrid.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;GAYG;AACH,4CAVG;IAAsB,SAAS,EAAvB,MAAM;IACQ,MAAM,EAApB,MAAM;IACQ,KAAK,EAAnB,MAAM;IACQ,MAAM,EAApB,MAAM;IACU,MAAM;IACE,SAAS,EAAjC,cAAc,EAAE;IACQ,SAAS,EAAjC,cAAc,EAAE;IACgB,iBAAiB,EAAjD,sBAAsB,EAAE;IACT,QAAQ,EAAvB,OAAO;CACjB,eAsGA"}
1
+ {"version":3,"file":"VitessceGrid.d.ts","sourceRoot":"","sources":["../src/VitessceGrid.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;GAYG;AACH,4CAVG;IAAsB,SAAS,EAAvB,MAAM;IACQ,MAAM,EAApB,MAAM;IACQ,KAAK,EAAnB,MAAM;IACQ,MAAM,EAApB,MAAM;IACU,MAAM;IACE,SAAS,EAAjC,cAAc,EAAE;IACQ,SAAS,EAAjC,cAAc,EAAE;IACgB,iBAAiB,EAAjD,sBAAsB,EAAE;IACT,QAAQ,EAAvB,OAAO;CACjB,eAwGA"}
@@ -25,10 +25,10 @@ const margin = 5;
25
25
  * @param {boolean} props.pageMode
26
26
  */
27
27
  export default function VitessceGrid(props) {
28
- const { success, configKey, rowHeight: initialRowHeight, config, theme, height, isBounded, viewTypes, fileTypes, coordinationTypes, stores, pageMode, children, } = props;
28
+ const { success, configKey, rowHeight: initialRowHeight, config, theme, height, isBounded, viewTypes, fileTypes, coordinationTypes, stores, pageMode, children, queryClient, } = props;
29
29
  const [rowHeight, containerRef] = useRowHeight(config, initialRowHeight, height, margin, padding);
30
30
  const onResize = useEmitGridResize();
31
- const [componentWidth] = useClosestVitessceContainerSize(containerRef, 0);
31
+ const [componentWidth] = useClosestVitessceContainerSize(containerRef);
32
32
  const { classes } = useVitessceContainerStyles();
33
33
  const { classes: titleClasses } = useTitleStyles();
34
34
  const altText = useMemo(() => getAltText(config), [configKey]);
@@ -55,7 +55,7 @@ export default function VitessceGrid(props) {
55
55
  let newLoaders = null;
56
56
  let newConfig = null;
57
57
  if (success) {
58
- newLoaders = createLoaders(config.datasets, config.description, fileTypes, coordinationTypes, stores);
58
+ newLoaders = createLoaders(config.datasets, config.description, fileTypes, coordinationTypes, stores, queryClient);
59
59
  newConfig = config;
60
60
  }
61
61
  setViewConfig(newConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"on-drop.d.ts","sourceRoot":"","sources":["../src/on-drop.js"],"names":[],"mappings":"AAoEA;;;;;;;;;;GAUG;AACH,sCARG;IAA0B,aAAa;IACb,SAAS;CACnC,gBAAQ,OAAO,kBAEP,OAAO,6BAyHjB"}
1
+ {"version":3,"file":"on-drop.d.ts","sourceRoot":"","sources":["../src/on-drop.js"],"names":[],"mappings":"AAkFA;;;;;;;;;;GAUG;AACH,sCARG;IAA0B,aAAa;IACb,SAAS;CACnC,gBAAQ,OAAO,kBAEP,OAAO,6BAyHjB"}
@@ -14,6 +14,22 @@ class FlatFileSystemStore {
14
14
  const buffer = await file.arrayBuffer();
15
15
  return new Uint8Array(buffer);
16
16
  }
17
+ async getRange(key, range) {
18
+ // The list of files does not prefix its paths with slashes.
19
+ const file = this.files.find(f => `/${f.relpath}` === key);
20
+ if (!file)
21
+ return undefined;
22
+ const buffer = await file.arrayBuffer();
23
+ if ('suffixLength' in range) {
24
+ const { suffixLength } = range;
25
+ return new Uint8Array(buffer, buffer.byteLength - suffixLength, suffixLength);
26
+ }
27
+ if ('offset' in range && 'length' in range) {
28
+ const { offset, length } = range;
29
+ return new Uint8Array(buffer, offset, length);
30
+ }
31
+ throw new Error('Invalid rangeQuery value.');
32
+ }
17
33
  }
18
34
  /*
19
35
  // Get a file handle to a file in a directory.
@@ -7,8 +7,9 @@ export function useRowHeight(config: any, initialRowHeight: any, height: any, ma
7
7
  * @param {PluginFileType[]} fileTypes
8
8
  * @param {PluginCoordinationType[]} coordinationTypes
9
9
  * @param {object} stores Optional mapping from URLs to Zarrita stores.
10
+ * @param {QueryClient} queryClient A react-query QueryClient instance.
10
11
  * @returns {object} Mapping from dataset ID to data type to loader
11
12
  * instance.
12
13
  */
13
- export function createLoaders(datasets: object[], configDescription: string, fileTypes: PluginFileType[], coordinationTypes: PluginCoordinationType[], stores: object): object;
14
+ export function createLoaders(datasets: object[], configDescription: string, fileTypes: PluginFileType[], coordinationTypes: PluginCoordinationType[], stores: object, queryClient: QueryClient): object;
14
15
  //# sourceMappingURL=vitessce-grid-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vitessce-grid-utils.d.ts","sourceRoot":"","sources":["../src/vitessce-grid-utils.js"],"names":[],"mappings":"AAyCA,gHA6CC;AA4BD;;;;;;;;;;GAUG;AACH,wCATW,MAAM,EAAE,qBACR,MAAM,aAEN,cAAc,EAAE,qBAChB,sBAAsB,EAAE,UACxB,MAAM,GACJ,MAAM,CAmElB"}
1
+ {"version":3,"file":"vitessce-grid-utils.d.ts","sourceRoot":"","sources":["../src/vitessce-grid-utils.js"],"names":[],"mappings":"AAyCA,gHA6CC;AA4BD;;;;;;;;;;;GAWG;AACH,wCAVW,MAAM,EAAE,qBACR,MAAM,aAEN,cAAc,EAAE,qBAChB,sBAAsB,EAAE,UACxB,MAAM,eACN,WAAW,GACT,MAAM,CA2ElB"}
@@ -103,10 +103,11 @@ function withDefaults(coordinationValues, dataType, fileType, datasetUid, defaul
103
103
  * @param {PluginFileType[]} fileTypes
104
104
  * @param {PluginCoordinationType[]} coordinationTypes
105
105
  * @param {object} stores Optional mapping from URLs to Zarrita stores.
106
+ * @param {QueryClient} queryClient A react-query QueryClient instance.
106
107
  * @returns {object} Mapping from dataset ID to data type to loader
107
108
  * instance.
108
109
  */
109
- export function createLoaders(datasets, configDescription, fileTypes, coordinationTypes, stores) {
110
+ export function createLoaders(datasets, configDescription, fileTypes, coordinationTypes, stores, queryClient) {
110
111
  const result = {};
111
112
  const dataSources = new InternMap([], JSON.stringify);
112
113
  const defaultCoordinationValues = Object.fromEntries(coordinationTypes.map(ct => ([ct.name, ct.defaultValue])));
@@ -142,6 +143,7 @@ export function createLoaders(datasets, configDescription, fileTypes, coordinati
142
143
  // Optionally, pass a Zarrita store to the data source,
143
144
  // if one was mapped to this URL.
144
145
  store: stores?.[url],
146
+ queryClient,
145
147
  }));
146
148
  }
147
149
  const loader = new LoaderClass(dataSources.get(dataSourceKey), file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/vit-s",
3
- "version": "3.8.6",
3
+ "version": "3.8.8",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -30,16 +30,16 @@
30
30
  "react-error-boundary": "^5.0.0",
31
31
  "@placemarkio/flat-drop-files": "^1.0.2",
32
32
  "zarrita": "0.5.4",
33
- "@vitessce/styles": "3.8.6",
34
- "@vitessce/abstract": "3.8.6",
35
- "@vitessce/error": "3.8.6",
36
- "@vitessce/constants-internal": "3.8.6",
37
- "@vitessce/plugins": "3.8.6",
38
- "@vitessce/schemas": "3.8.6",
39
- "@vitessce/sets-utils": "3.8.6",
40
- "@vitessce/utils": "3.8.6",
41
- "@vitessce/config": "3.8.6",
42
- "@vitessce/globals": "3.8.6"
33
+ "@vitessce/styles": "3.8.8",
34
+ "@vitessce/abstract": "3.8.8",
35
+ "@vitessce/error": "3.8.8",
36
+ "@vitessce/constants-internal": "3.8.8",
37
+ "@vitessce/plugins": "3.8.8",
38
+ "@vitessce/schemas": "3.8.8",
39
+ "@vitessce/utils": "3.8.8",
40
+ "@vitessce/sets-utils": "3.8.8",
41
+ "@vitessce/config": "3.8.8",
42
+ "@vitessce/globals": "3.8.8"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@testing-library/jest-dom": "^6.6.3",
@@ -48,7 +48,7 @@
48
48
  "react-dom": "18.3.1",
49
49
  "vite": "^7.0.0",
50
50
  "vitest": "^3.1.4",
51
- "@vitessce/types": "3.8.6"
51
+ "@vitessce/types": "3.8.8"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
package/src/VitS.js CHANGED
@@ -102,15 +102,6 @@ export function VitS(props) {
102
102
  logLevel = DEFAULT_LOG_LEVEL,
103
103
  } = props;
104
104
 
105
- /*
106
- const prefersDark = (
107
- window.matchMedia
108
- && window.matchMedia('(prefers-color-scheme: dark)').matches
109
- );
110
- const defaultTheme = prefersDark ? 'dark' : 'light';
111
- const [theme, setTheme] = useState(themeProp ?? defaultTheme);
112
- */
113
-
114
105
  // eslint-disable-next-line no-unused-vars
115
106
  const [debugErrors, setDebugErrors] = useState([]);
116
107
  const viewTypes = useMemo(() => (viewTypesProp || []), [viewTypesProp]);
@@ -266,6 +257,7 @@ export function VitS(props) {
266
257
  fileTypes,
267
258
  coordinationTypes,
268
259
  stores,
260
+ queryClient,
269
261
  );
270
262
  return createViewConfigStore(loaders, configOrWarning);
271
263
  }
@@ -309,6 +301,7 @@ export function VitS(props) {
309
301
  theme={theme}
310
302
  isBounded={isBounded}
311
303
  stores={stores}
304
+ queryClient={queryClient}
312
305
  >
313
306
  {children}
314
307
  </VitessceGrid>
@@ -57,12 +57,13 @@ export default function VitessceGrid(props) {
57
57
  stores,
58
58
  pageMode,
59
59
  children,
60
+ queryClient,
60
61
  } = props;
61
62
 
62
63
  const [rowHeight, containerRef] = useRowHeight(config, initialRowHeight, height, margin, padding);
63
64
  const onResize = useEmitGridResize();
64
65
 
65
- const [componentWidth] = useClosestVitessceContainerSize(containerRef, 0);
66
+ const [componentWidth] = useClosestVitessceContainerSize(containerRef);
66
67
 
67
68
  const { classes } = useVitessceContainerStyles();
68
69
  const { classes: titleClasses } = useTitleStyles();
@@ -101,6 +102,7 @@ export default function VitessceGrid(props) {
101
102
  fileTypes,
102
103
  coordinationTypes,
103
104
  stores,
105
+ queryClient,
104
106
  );
105
107
  newConfig = config;
106
108
  }
package/src/on-drop.js CHANGED
@@ -17,7 +17,21 @@ class FlatFileSystemStore {
17
17
  return new Uint8Array(buffer);
18
18
  }
19
19
 
20
- // TODO: implement getRange
20
+ async getRange(key, range) {
21
+ // The list of files does not prefix its paths with slashes.
22
+ const file = this.files.find(f => `/${f.relpath}` === key);
23
+ if (!file) return undefined;
24
+ const buffer = await file.arrayBuffer();
25
+ if ('suffixLength' in range) {
26
+ const { suffixLength } = range;
27
+ return new Uint8Array(buffer, buffer.byteLength - suffixLength, suffixLength);
28
+ }
29
+ if ('offset' in range && 'length' in range) {
30
+ const { offset, length } = range;
31
+ return new Uint8Array(buffer, offset, length);
32
+ }
33
+ throw new Error('Invalid rangeQuery value.');
34
+ }
21
35
  }
22
36
 
23
37
  /*
@@ -120,10 +120,18 @@ function withDefaults(
120
120
  * @param {PluginFileType[]} fileTypes
121
121
  * @param {PluginCoordinationType[]} coordinationTypes
122
122
  * @param {object} stores Optional mapping from URLs to Zarrita stores.
123
+ * @param {QueryClient} queryClient A react-query QueryClient instance.
123
124
  * @returns {object} Mapping from dataset ID to data type to loader
124
125
  * instance.
125
126
  */
126
- export function createLoaders(datasets, configDescription, fileTypes, coordinationTypes, stores) {
127
+ export function createLoaders(
128
+ datasets,
129
+ configDescription,
130
+ fileTypes,
131
+ coordinationTypes,
132
+ stores,
133
+ queryClient,
134
+ ) {
127
135
  const result = {};
128
136
  const dataSources = new InternMap([], JSON.stringify);
129
137
  const defaultCoordinationValues = Object.fromEntries(
@@ -173,6 +181,7 @@ export function createLoaders(datasets, configDescription, fileTypes, coordinati
173
181
  // Optionally, pass a Zarrita store to the data source,
174
182
  // if one was mapped to this URL.
175
183
  store: stores?.[url],
184
+ queryClient,
176
185
  }));
177
186
  }
178
187
  const loader = new LoaderClass(dataSources.get(dataSourceKey), file);