@vitessce/json 4.0.8 → 4.0.10

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
@@ -1,5 +1,6 @@
1
- import { C, d, e, f, h, G, b, J, M, i, O, c, R, j } from "./index-l5IGfUA8.js";
1
+ import { A, C, d, e, f, h, G, b, J, M, i, O, c, R, j } from "./index-B31MphL5.js";
2
2
  export {
3
+ A as AnnotationStoryJsonLoader,
3
4
  C as CellsJsonAsObsEmbeddingLoader,
4
5
  d as CellsJsonAsObsLabelsLoader,
5
6
  e as CellsJsonAsObsLocationsLoader,
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-l5IGfUA8.js";
1
+ import { B as BaseDecoder } from "./index-B31MphL5.js";
2
2
  const dctZigZag = new Int32Array([
3
3
  0,
4
4
  1,
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-l5IGfUA8.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-B31MphL5.js";
3
3
  var LercDecode = { exports: {} };
4
4
  var hasRequiredLercDecode;
5
5
  function requireLercDecode() {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-l5IGfUA8.js";
1
+ import { B as BaseDecoder } from "./index-B31MphL5.js";
2
2
  const MIN_BITS = 9;
3
3
  const CLEAR_CODE = 256;
4
4
  const EOI_CODE = 257;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-l5IGfUA8.js";
1
+ import { B as BaseDecoder } from "./index-B31MphL5.js";
2
2
  class PackbitsDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  const dataView = new DataView(buffer);
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-l5IGfUA8.js";
1
+ import { B as BaseDecoder } from "./index-B31MphL5.js";
2
2
  class RawDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  return buffer;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-l5IGfUA8.js";
1
+ import { B as BaseDecoder } from "./index-B31MphL5.js";
2
2
  class WebImageDecoder extends BaseDecoder {
3
3
  constructor() {
4
4
  super();
@@ -0,0 +1,11 @@
1
+ export default class AnnotationStoryJsonLoader extends JsonLoader {
2
+ load(): Promise<LoaderResult<{
3
+ annotationStory: any;
4
+ }>>;
5
+ cachedResult: LoaderResult<{
6
+ annotationStory: any;
7
+ }> | undefined;
8
+ }
9
+ import JsonLoader from './JsonLoader.js';
10
+ import { LoaderResult } from '@vitessce/abstract';
11
+ //# sourceMappingURL=AnnotationStoryJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationStoryJson.d.ts","sourceRoot":"","sources":["../../src/json-loaders/AnnotationStoryJson.js"],"names":[],"mappings":"AAIA;IAME;;QAgBC;IAFC;;mBAAkF;CAGrF;uBAzBsB,iBAAiB;6BAFX,oBAAoB"}
@@ -0,0 +1,27 @@
1
+ import { LoaderResult } from '@vitessce/abstract';
2
+ import { annotationStoryObj } from '@vitessce/schemas';
3
+ import JsonLoader from './JsonLoader.js';
4
+ export default class AnnotationStoryJsonLoader extends JsonLoader {
5
+ constructor(dataSource, params) {
6
+ super(dataSource, params);
7
+ this.schema = annotationStoryObj;
8
+ }
9
+ async load() {
10
+ // JsonLoader.load returns the raw JSON (rather than a LoaderResult)
11
+ // on subsequent calls, so cache the full result here.
12
+ if (this.cachedResult) {
13
+ return this.cachedResult;
14
+ }
15
+ const payload = await super.load();
16
+ const { data: annotationStory, url } = payload;
17
+ // The story is provided as an initial coordination value.
18
+ // It is only set when the coordination space value is null,
19
+ // via initCoordinationSpace in the data hook.
20
+ const coordinationValues = {
21
+ annotationStory,
22
+ };
23
+ this.cachedResult = new LoaderResult({ annotationStory }, url, coordinationValues);
24
+ return this.cachedResult;
25
+ }
26
+ }
27
+ //# sourceMappingURL=AnnotationStoryJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationStoryJson.js","sourceRoot":"","sources":["../../src/json-loaders/AnnotationStoryJson.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,UAAU;IAC/D,YAAY,UAAU,EAAE,MAAM;QAC5B,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,kBAAkB,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,oEAAoE;QACpE,sDAAsD;QACtD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QAC/C,0DAA0D;QAC1D,4DAA4D;QAC5D,8CAA8C;QAC9C,MAAM,kBAAkB,GAAG;YACzB,eAAe;SAChB,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,EAAE,eAAe,EAAE,EAAE,GAAG,EAAE,kBAAkB,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AnnotationStoryJson.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationStoryJson.test.d.ts","sourceRoot":"","sources":["../../src/json-loaders/AnnotationStoryJson.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { LoaderResult } from '@vitessce/abstract';
3
+ import { JsonLoaderValidationError } from '@vitessce/error';
4
+ import AnnotationStoryJsonLoader from './AnnotationStoryJson.js';
5
+ const storyFixture = {
6
+ uid: 'story-1',
7
+ title: 'My story',
8
+ frames: [],
9
+ };
10
+ function createLoader(data) {
11
+ const dataSource = { loadJson: async () => data };
12
+ return new AnnotationStoryJsonLoader(dataSource, {
13
+ fileType: 'annotationStory.json',
14
+ url: 'http://example.com/story.json',
15
+ });
16
+ }
17
+ describe('loaders/json-loaders/AnnotationStoryJson', () => {
18
+ it('loads the story as data and as a coordination value', async () => {
19
+ const loader = createLoader(storyFixture);
20
+ const result = await loader.load();
21
+ expect(result).toBeInstanceOf(LoaderResult);
22
+ expect(result.data).toEqual({ annotationStory: storyFixture });
23
+ expect(result.coordinationValues).toEqual({ annotationStory: storyFixture });
24
+ expect(result.url).toEqual('http://example.com/story.json');
25
+ });
26
+ it('returns the same result when loaded more than once', async () => {
27
+ const loader = createLoader(storyFixture);
28
+ const firstResult = await loader.load();
29
+ const secondResult = await loader.load();
30
+ expect(secondResult).toBe(firstResult);
31
+ });
32
+ it('throws when the JSON does not match the annotationStory schema', async () => {
33
+ const loader = createLoader({ title: 'Missing uid and frames' });
34
+ await expect(loader.load()).rejects.toThrow(JsonLoaderValidationError);
35
+ });
36
+ });
37
+ //# sourceMappingURL=AnnotationStoryJson.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationStoryJson.test.js","sourceRoot":"","sources":["../../src/json-loaders/AnnotationStoryJson.test.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,yBAAyB,MAAM,0BAA0B,CAAC;A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AC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;QAC9E,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAC;QACjE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { default as JsonLoader } from "./JsonLoader.js";
2
2
  export { default as ObsSegmentationsJsonLoader } from "./ObsSegmentationsJson.js";
3
3
  export { default as ObsSetsJsonLoader } from "./ObsSetsJson.js";
4
+ export { default as AnnotationStoryJsonLoader } from "./AnnotationStoryJson.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,5 @@
1
1
  export { default as JsonLoader } from './JsonLoader.js';
2
2
  export { default as ObsSegmentationsJsonLoader } from './ObsSegmentationsJson.js';
3
3
  export { default as ObsSetsJsonLoader } from './ObsSetsJson.js';
4
+ export { default as AnnotationStoryJsonLoader } from './AnnotationStoryJson.js';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/json-loaders/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/json-loaders/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/json",
3
- "version": "4.0.8",
3
+ "version": "4.0.10",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -20,17 +20,17 @@
20
20
  "lodash-es": "^4.17.21",
21
21
  "zarrita": "0.7.5",
22
22
  "zod": "^3.21.4",
23
- "@vitessce/constants-internal": "4.0.8",
24
- "@vitessce/gl": "4.0.8",
25
- "@vitessce/globals": "4.0.8",
26
- "@vitessce/schemas": "4.0.8",
27
- "@vitessce/sets-utils": "4.0.8",
28
- "@vitessce/spatial-utils": "4.0.8",
29
- "@vitessce/utils": "4.0.8",
30
- "@vitessce/abstract": "4.0.8",
31
- "@vitessce/error": "4.0.8",
32
- "@vitessce/zarr-utils": "4.0.8",
33
- "@vitessce/config": "4.0.8"
23
+ "@vitessce/constants-internal": "4.0.10",
24
+ "@vitessce/gl": "4.0.10",
25
+ "@vitessce/globals": "4.0.10",
26
+ "@vitessce/schemas": "4.0.10",
27
+ "@vitessce/sets-utils": "4.0.10",
28
+ "@vitessce/abstract": "4.0.10",
29
+ "@vitessce/spatial-utils": "4.0.10",
30
+ "@vitessce/zarr-utils": "4.0.10",
31
+ "@vitessce/error": "4.0.10",
32
+ "@vitessce/config": "4.0.10",
33
+ "@vitessce/utils": "4.0.10"
34
34
  },
35
35
  "scripts": {
36
36
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
@@ -0,0 +1,28 @@
1
+ import { LoaderResult } from '@vitessce/abstract';
2
+ import { annotationStoryObj } from '@vitessce/schemas';
3
+ import JsonLoader from './JsonLoader.js';
4
+
5
+ export default class AnnotationStoryJsonLoader extends JsonLoader {
6
+ constructor(dataSource, params) {
7
+ super(dataSource, params);
8
+ this.schema = annotationStoryObj;
9
+ }
10
+
11
+ async load() {
12
+ // JsonLoader.load returns the raw JSON (rather than a LoaderResult)
13
+ // on subsequent calls, so cache the full result here.
14
+ if (this.cachedResult) {
15
+ return this.cachedResult;
16
+ }
17
+ const payload = await super.load();
18
+ const { data: annotationStory, url } = payload;
19
+ // The story is provided as an initial coordination value.
20
+ // It is only set when the coordination space value is null,
21
+ // via initCoordinationSpace in the data hook.
22
+ const coordinationValues = {
23
+ annotationStory,
24
+ };
25
+ this.cachedResult = new LoaderResult({ annotationStory }, url, coordinationValues);
26
+ return this.cachedResult;
27
+ }
28
+ }
@@ -0,0 +1,41 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { LoaderResult } from '@vitessce/abstract';
3
+ import { JsonLoaderValidationError } from '@vitessce/error';
4
+ import AnnotationStoryJsonLoader from './AnnotationStoryJson.js';
5
+
6
+ const storyFixture = {
7
+ uid: 'story-1',
8
+ title: 'My story',
9
+ frames: [],
10
+ };
11
+
12
+ function createLoader(data) {
13
+ const dataSource = { loadJson: async () => data };
14
+ return new AnnotationStoryJsonLoader(dataSource, {
15
+ fileType: 'annotationStory.json',
16
+ url: 'http://example.com/story.json',
17
+ });
18
+ }
19
+
20
+ describe('loaders/json-loaders/AnnotationStoryJson', () => {
21
+ it('loads the story as data and as a coordination value', async () => {
22
+ const loader = createLoader(storyFixture);
23
+ const result = await loader.load();
24
+ expect(result).toBeInstanceOf(LoaderResult);
25
+ expect(result.data).toEqual({ annotationStory: storyFixture });
26
+ expect(result.coordinationValues).toEqual({ annotationStory: storyFixture });
27
+ expect(result.url).toEqual('http://example.com/story.json');
28
+ });
29
+
30
+ it('returns the same result when loaded more than once', async () => {
31
+ const loader = createLoader(storyFixture);
32
+ const firstResult = await loader.load();
33
+ const secondResult = await loader.load();
34
+ expect(secondResult).toBe(firstResult);
35
+ });
36
+
37
+ it('throws when the JSON does not match the annotationStory schema', async () => {
38
+ const loader = createLoader({ title: 'Missing uid and frames' });
39
+ await expect(loader.load()).rejects.toThrow(JsonLoaderValidationError);
40
+ });
41
+ });
@@ -1,3 +1,4 @@
1
1
  export { default as JsonLoader } from './JsonLoader.js';
2
2
  export { default as ObsSegmentationsJsonLoader } from './ObsSegmentationsJson.js';
3
3
  export { default as ObsSetsJsonLoader } from './ObsSetsJson.js';
4
+ export { default as AnnotationStoryJsonLoader } from './AnnotationStoryJson.js';