@vitessce/utils 3.2.1 → 3.3.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/dist/index.js +182 -137
- package/dist-tsc/Pool.d.ts +8 -7
- package/dist-tsc/Pool.d.ts.map +1 -1
- package/dist-tsc/Pool.js +5 -3
- package/dist-tsc/components.d.ts +25 -21
- package/dist-tsc/components.d.ts.map +1 -1
- package/dist-tsc/components.js +7 -6
- package/dist-tsc/gating.d.ts +8 -8
- package/dist-tsc/gating.d.ts.map +1 -1
- package/dist-tsc/gating.js +3 -3
- package/dist-tsc/index.d.ts +5 -5
- package/dist-tsc/index.d.ts.map +1 -1
- package/dist-tsc/index.js +2 -2
- package/dist-tsc/interpolate-colors.d.ts +14 -8
- package/dist-tsc/interpolate-colors.d.ts.map +1 -1
- package/dist-tsc/interpolate-colors.js +9 -8
- package/dist-tsc/interpolate-colors.test.d.ts.map +1 -1
- package/dist-tsc/root.d.ts +8 -6
- package/dist-tsc/root.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/{Pool.js → Pool.ts} +11 -6
- package/src/{components.js → components.ts} +17 -16
- package/src/{gating.js → gating.ts} +4 -4
- package/src/index.ts +39 -0
- package/src/{interpolate-colors.test.js → interpolate-colors.test.ts} +1 -1
- package/src/{interpolate-colors.js → interpolate-colors.ts} +26 -16
- package/src/missing-types.d.ts +2 -0
- package/src/{root.js → root.ts} +7 -7
- package/src/index.js +0 -12
package/dist-tsc/Pool.d.ts
CHANGED
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
* This is a line-for-line copy of GeoTIFFs old implementation: https://github.com/geotiffjs/geotiff.js/blob/v1.0.0-beta.6/src/pool.js
|
|
4
4
|
*/
|
|
5
5
|
export default class Pool {
|
|
6
|
+
workers: Worker[];
|
|
7
|
+
idleWorkers: Worker[];
|
|
8
|
+
waitQueue: {
|
|
9
|
+
resolve?: (worker: Worker) => void;
|
|
10
|
+
}[];
|
|
6
11
|
/**
|
|
7
12
|
* @constructor
|
|
8
13
|
* @param {object} Worker The worker class to be used for processing.
|
|
9
14
|
*/
|
|
10
|
-
constructor(createWorker:
|
|
11
|
-
workers: any[];
|
|
12
|
-
idleWorkers: any[];
|
|
13
|
-
waitQueue: any[];
|
|
14
|
-
decoder: any;
|
|
15
|
+
constructor(createWorker: () => Worker);
|
|
15
16
|
process(): Promise<void>;
|
|
16
|
-
waitForWorker(): Promise<
|
|
17
|
-
finishTask(currentWorker:
|
|
17
|
+
waitForWorker(): Promise<unknown>;
|
|
18
|
+
finishTask(currentWorker: Worker): Promise<void>;
|
|
18
19
|
destroy(): void;
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=Pool.d.ts.map
|
package/dist-tsc/Pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pool.d.ts","sourceRoot":"","sources":["../src/Pool.
|
|
1
|
+
{"version":3,"file":"Pool.d.ts","sourceRoot":"","sources":["../src/Pool.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,IAAI;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,SAAS,EAAE;QAAE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,EAAE,CAAC;IAEpD;;;OAGG;gBACS,YAAY,EAAE,MAAM,MAAM;IAchC,OAAO;IAIP,aAAa;IAcb,UAAU,CAAC,aAAa,EAAE,MAAM;IAStC,OAAO;CAMR"}
|
package/dist-tsc/Pool.js
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
// We need to give a different way of getting this for safari, so 4 is probably a safe bet
|
|
3
3
|
// for parallel processing in the meantime. More can't really hurt since they'll just block
|
|
4
4
|
// each other and not the UI thread, which is the real benefit.
|
|
5
|
-
const defaultPoolSize = typeof navigator !== 'undefined' ? navigator.hardwareConcurrency || 4 :
|
|
5
|
+
const defaultPoolSize = typeof navigator !== 'undefined' ? navigator.hardwareConcurrency || 4 : 1;
|
|
6
6
|
/**
|
|
7
7
|
* Pool for workers to decode chunks of the images.
|
|
8
8
|
* This is a line-for-line copy of GeoTIFFs old implementation: https://github.com/geotiffjs/geotiff.js/blob/v1.0.0-beta.6/src/pool.js
|
|
9
9
|
*/
|
|
10
10
|
export default class Pool {
|
|
11
|
+
workers;
|
|
12
|
+
idleWorkers;
|
|
13
|
+
waitQueue;
|
|
11
14
|
/**
|
|
12
15
|
* @constructor
|
|
13
16
|
* @param {object} Worker The worker class to be used for processing.
|
|
@@ -16,7 +19,6 @@ export default class Pool {
|
|
|
16
19
|
this.workers = [];
|
|
17
20
|
this.idleWorkers = [];
|
|
18
21
|
this.waitQueue = [];
|
|
19
|
-
this.decoder = null;
|
|
20
22
|
// eslint-disable-next-line no-plusplus
|
|
21
23
|
for (let i = 0; i < defaultPoolSize; ++i) {
|
|
22
24
|
const w = createWorker();
|
|
@@ -42,7 +44,7 @@ export default class Pool {
|
|
|
42
44
|
}
|
|
43
45
|
async finishTask(currentWorker) {
|
|
44
46
|
const waiter = this.waitQueue.pop();
|
|
45
|
-
if (waiter) {
|
|
47
|
+
if (waiter && waiter.resolve) {
|
|
46
48
|
waiter.resolve(currentWorker);
|
|
47
49
|
}
|
|
48
50
|
else {
|
package/dist-tsc/components.d.ts
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export function
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
1
|
+
export declare const DEFAULT_DARK_COLOR: number[];
|
|
2
|
+
export declare const DEFAULT_LIGHT_COLOR: number[];
|
|
3
|
+
export declare function getDefaultColor(theme: 'dark' | 'light'): number[];
|
|
4
|
+
export declare const PALETTE: number[][];
|
|
5
|
+
export declare const VIEWER_PALETTE: number[][];
|
|
6
|
+
export declare const PATHOLOGY_PALETTE: number[][];
|
|
7
|
+
export declare const LARGE_PATHOLOGY_PALETTE: number[][];
|
|
8
|
+
export declare const COLORMAP_OPTIONS: string[];
|
|
9
|
+
export declare const DEFAULT_GL_OPTIONS: {
|
|
10
|
+
webgl2: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function createDefaultUpdateStatus(componentName: string): (message: string) => void;
|
|
13
|
+
export declare function createDefaultUpdateCellsSelection(componentName: string): (cellsSelection: any) => void;
|
|
14
|
+
export declare function createDefaultUpdateCellsHover(componentName: string): (hoverInfo: {
|
|
15
|
+
cellId: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
export declare function createDefaultUpdateGenesHover(componentName: string): (hoverInfo: {
|
|
18
|
+
geneId: string;
|
|
19
|
+
}) => void;
|
|
20
|
+
export declare function createDefaultUpdateTracksHover(componentName: string): (hoverInfo: any) => void;
|
|
21
|
+
export declare function createDefaultUpdateViewInfo(componentName: string): (viewInfo: any) => void;
|
|
22
|
+
export declare function createDefaultClearPleaseWait(): () => void;
|
|
9
23
|
/**
|
|
10
24
|
* Copy a typed array into a new array buffer.
|
|
11
25
|
* @param {Uint8Array} arr The typed array to be copied.
|
|
12
26
|
* @returns {Uint8Array} The copied array.
|
|
13
27
|
*/
|
|
14
|
-
export function copyUint8Array(arr: Uint8Array): Uint8Array;
|
|
15
|
-
export function asEsModule(component: any): {
|
|
28
|
+
export declare function copyUint8Array(arr: Uint8Array): Uint8Array;
|
|
29
|
+
export declare function asEsModule(component: any): {
|
|
16
30
|
__esModule: boolean;
|
|
17
31
|
default: any;
|
|
18
32
|
};
|
|
19
|
-
export function formatBytes(bytes:
|
|
20
|
-
export const DEFAULT_DARK_COLOR: number[];
|
|
21
|
-
export const DEFAULT_LIGHT_COLOR: number[];
|
|
22
|
-
export const PALETTE: number[][];
|
|
23
|
-
export const VIEWER_PALETTE: number[][];
|
|
24
|
-
export const PATHOLOGY_PALETTE: number[][];
|
|
25
|
-
export const LARGE_PATHOLOGY_PALETTE: number[][];
|
|
26
|
-
export const COLORMAP_OPTIONS: string[];
|
|
27
|
-
export namespace DEFAULT_GL_OPTIONS {
|
|
28
|
-
const webgl2: boolean;
|
|
29
|
-
}
|
|
33
|
+
export declare function formatBytes(bytes: number, decimals?: number): string;
|
|
30
34
|
//# sourceMappingURL=components.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,kBAAkB,UAAe,CAAC;AAC/C,eAAO,MAAM,mBAAmB,UAAkB,CAAC;AAEnD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,YAEtD;AAGD,eAAO,MAAM,OAAO,YAUnB,CAAC;AAEF,eAAO,MAAM,cAAc,YAS1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAS7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,YAiBnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAW5B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;CAAmB,CAAC;AAEnD,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,aAC5C,MAAM,UACxB;AAED,wBAAgB,iCAAiC,CAAC,aAAa,EAAE,MAAM,oBAC7C,GAAG,UAC5B;AAED,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,MAAM,eAC9C;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,UACtC;AAED,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,MAAM,eAC9C;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,UACtC;AAED,wBAAgB,8BAA8B,CAAC,aAAa,EAAE,MAAM,eAC/C,GAAG,UACvB;AAED,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,cAC7C,GAAG,UACtB;AAED,wBAAgB,4BAA4B,eAG3C;AAGD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,cAK7C;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,GAAG;;;EAKxC;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,UAWtD"}
|
package/dist-tsc/components.js
CHANGED
|
@@ -68,24 +68,25 @@ export const COLORMAP_OPTIONS = [
|
|
|
68
68
|
];
|
|
69
69
|
export const DEFAULT_GL_OPTIONS = { webgl2: true };
|
|
70
70
|
export function createDefaultUpdateStatus(componentName) {
|
|
71
|
-
return message => console.warn(`${componentName} updateStatus: ${message}`);
|
|
71
|
+
return (message) => console.warn(`${componentName} updateStatus: ${message}`);
|
|
72
72
|
}
|
|
73
73
|
export function createDefaultUpdateCellsSelection(componentName) {
|
|
74
|
-
return cellsSelection => console.warn(`${componentName} updateCellsSelection: ${cellsSelection}`);
|
|
74
|
+
return (cellsSelection) => console.warn(`${componentName} updateCellsSelection: ${cellsSelection}`);
|
|
75
75
|
}
|
|
76
76
|
export function createDefaultUpdateCellsHover(componentName) {
|
|
77
|
-
return hoverInfo => console.warn(`${componentName} updateCellsHover: ${hoverInfo.cellId}`);
|
|
77
|
+
return (hoverInfo) => console.warn(`${componentName} updateCellsHover: ${hoverInfo.cellId}`);
|
|
78
78
|
}
|
|
79
79
|
export function createDefaultUpdateGenesHover(componentName) {
|
|
80
|
-
return hoverInfo => console.warn(`${componentName} updateGenesHover: ${hoverInfo.geneId}`);
|
|
80
|
+
return (hoverInfo) => console.warn(`${componentName} updateGenesHover: ${hoverInfo.geneId}`);
|
|
81
81
|
}
|
|
82
82
|
export function createDefaultUpdateTracksHover(componentName) {
|
|
83
|
-
return hoverInfo => console.warn(`${componentName} updateTracksHover: ${hoverInfo}`);
|
|
83
|
+
return (hoverInfo) => console.warn(`${componentName} updateTracksHover: ${hoverInfo}`);
|
|
84
84
|
}
|
|
85
85
|
export function createDefaultUpdateViewInfo(componentName) {
|
|
86
|
-
return viewInfo => console.warn(`${componentName} updateViewInfo: ${viewInfo}`);
|
|
86
|
+
return (viewInfo) => console.warn(`${componentName} updateViewInfo: ${viewInfo}`);
|
|
87
87
|
}
|
|
88
88
|
export function createDefaultClearPleaseWait() {
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
89
90
|
return () => { };
|
|
90
91
|
}
|
|
91
92
|
/**
|
package/dist-tsc/gating.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export declare const VALUE_TRANSFORM_OPTIONS: ({
|
|
2
|
+
name: string;
|
|
3
|
+
value: null;
|
|
4
|
+
} | {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
})[];
|
|
1
8
|
/**
|
|
2
9
|
* Get a feature value transform function such as
|
|
3
10
|
* log1p or arcsinh.
|
|
@@ -7,12 +14,5 @@
|
|
|
7
14
|
* as a parameter and returns the transformed number
|
|
8
15
|
* (or the original number in the identity case).
|
|
9
16
|
*/
|
|
10
|
-
export function getValueTransformFunction(featureValueTransform:
|
|
11
|
-
export const VALUE_TRANSFORM_OPTIONS: ({
|
|
12
|
-
name: string;
|
|
13
|
-
value: null;
|
|
14
|
-
} | {
|
|
15
|
-
name: string;
|
|
16
|
-
value: string;
|
|
17
|
-
})[];
|
|
17
|
+
export declare function getValueTransformFunction(featureValueTransform: 'log1p' | 'arcsinh' | null, coefficient: number): (v: number) => number;
|
|
18
18
|
//# sourceMappingURL=gating.d.ts.map
|
package/dist-tsc/gating.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gating.d.ts","sourceRoot":"","sources":["../src/gating.
|
|
1
|
+
{"version":3,"file":"gating.d.ts","sourceRoot":"","sources":["../src/gating.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,uBAAuB;;;;;;IAInC,CAAC;AACF;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,qBAAqB,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,OAKlF,MAAM,YASnC"}
|
package/dist-tsc/gating.js
CHANGED
|
@@ -18,13 +18,13 @@ export function getValueTransformFunction(featureValueTransform, coefficient) {
|
|
|
18
18
|
let transformFunction;
|
|
19
19
|
switch (featureValueTransform) {
|
|
20
20
|
case 'log1p':
|
|
21
|
-
transformFunction = v => Math.log(1 + v * coefficient);
|
|
21
|
+
transformFunction = (v) => Math.log(1 + v * coefficient);
|
|
22
22
|
break;
|
|
23
23
|
case 'arcsinh':
|
|
24
|
-
transformFunction = v => Math.asinh(v * coefficient);
|
|
24
|
+
transformFunction = (v) => Math.asinh(v * coefficient);
|
|
25
25
|
break;
|
|
26
26
|
default:
|
|
27
|
-
transformFunction = v => v;
|
|
27
|
+
transformFunction = (v) => v;
|
|
28
28
|
}
|
|
29
29
|
return transformFunction;
|
|
30
30
|
}
|
package/dist-tsc/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { fromEntries, commaNumber, capitalize, pluralize, getLongestString, getNextScope, } from './root.js';
|
|
2
|
+
export { DEFAULT_DARK_COLOR, DEFAULT_LIGHT_COLOR, getDefaultColor, PALETTE, VIEWER_PALETTE, PATHOLOGY_PALETTE, LARGE_PATHOLOGY_PALETTE, COLORMAP_OPTIONS, DEFAULT_GL_OPTIONS, createDefaultUpdateStatus, createDefaultUpdateCellsSelection, createDefaultUpdateCellsHover, createDefaultUpdateGenesHover, createDefaultUpdateTracksHover, createDefaultUpdateViewInfo, createDefaultClearPleaseWait, copyUint8Array, asEsModule, formatBytes, } from './components.js';
|
|
3
|
+
export { getValueTransformFunction, VALUE_TRANSFORM_OPTIONS, } from './gating.js';
|
|
4
|
+
export { getCellColors, } from './interpolate-colors.js';
|
|
5
|
+
export { default as Pool } from './Pool.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist-tsc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,iCAAiC,EACjC,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,cAAc,EACd,UAAU,EACV,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
package/dist-tsc/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line react-refresh/only-export-components
|
|
2
|
-
export
|
|
2
|
+
export { fromEntries, commaNumber, capitalize, pluralize, getLongestString, getNextScope, } from './root.js';
|
|
3
3
|
// eslint-disable-next-line react-refresh/only-export-components
|
|
4
|
-
export
|
|
4
|
+
export { DEFAULT_DARK_COLOR, DEFAULT_LIGHT_COLOR, getDefaultColor, PALETTE, VIEWER_PALETTE, PATHOLOGY_PALETTE, LARGE_PATHOLOGY_PALETTE, COLORMAP_OPTIONS, DEFAULT_GL_OPTIONS, createDefaultUpdateStatus, createDefaultUpdateCellsSelection, createDefaultUpdateCellsHover, createDefaultUpdateGenesHover, createDefaultUpdateTracksHover, createDefaultUpdateViewInfo, createDefaultClearPleaseWait, copyUint8Array, asEsModule, formatBytes, } from './components.js';
|
|
5
5
|
export { getValueTransformFunction, VALUE_TRANSFORM_OPTIONS, } from './gating.js';
|
|
6
6
|
export { getCellColors, } from './interpolate-colors.js';
|
|
7
7
|
export { default as Pool } from './Pool.js';
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export declare const interpolateRdBu: (t: number) => number[];
|
|
2
|
+
export declare const interpolatePlasma: (t: number) => number[];
|
|
3
|
+
declare type GetCellColorsParams = {
|
|
4
|
+
cellSetSelection: string[][] | null;
|
|
5
|
+
cellSetColor: {
|
|
6
|
+
path: string[];
|
|
7
|
+
color: [number, number, number];
|
|
8
|
+
}[] | null;
|
|
9
|
+
cellSets: object;
|
|
10
|
+
obsIndex: string[] | null;
|
|
11
|
+
theme: 'light' | 'dark' | null;
|
|
12
|
+
};
|
|
1
13
|
/**
|
|
2
14
|
* Get a mapping of cell IDs to cell colors based on
|
|
3
15
|
* gene / cell set selection coordination state.
|
|
@@ -11,12 +23,6 @@
|
|
|
11
23
|
* in order to get the theme-based default color.
|
|
12
24
|
* @returns {Map} Mapping from cell IDs to [r, g, b] color arrays.
|
|
13
25
|
*/
|
|
14
|
-
export function getCellColors(params:
|
|
15
|
-
|
|
16
|
-
cellSetColor: object[];
|
|
17
|
-
obsIndex: string[];
|
|
18
|
-
theme: string;
|
|
19
|
-
}): Map<any, any>;
|
|
20
|
-
export function interpolateRdBu(t: any): any[];
|
|
21
|
-
export function interpolatePlasma(t: any): any;
|
|
26
|
+
export declare function getCellColors(params: GetCellColorsParams): Map<string, number[]>;
|
|
27
|
+
export {};
|
|
22
28
|
//# sourceMappingURL=interpolate-colors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolate-colors.d.ts","sourceRoot":"","sources":["../src/interpolate-colors.
|
|
1
|
+
{"version":3,"file":"interpolate-colors.d.ts","sourceRoot":"","sources":["../src/interpolate-colors.ts"],"names":[],"mappings":"AAuEA,eAAO,MAAM,eAAe,MAnCb,MAAM,aAmCyC,CAAC;AAC/D,eAAO,MAAM,iBAAiB,MAJjB,MAAM,aAIsD,CAAC;AAE1E,aAAK,mBAAmB,GAAG;IACzB,gBAAgB,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC;IACpC,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,EAAE,GAAG,IAAI,CAAC;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;CAChC,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAkBhF"}
|
|
@@ -16,9 +16,9 @@ const schemePlasma = [[13, 8, 135], [16, 7, 136], [19, 7, 137], [22, 7, 138], [2
|
|
|
16
16
|
function rgbSpline(spline) {
|
|
17
17
|
return (colors) => {
|
|
18
18
|
const n = colors.length;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const r = new Array(n);
|
|
20
|
+
const g = new Array(n);
|
|
21
|
+
const b = new Array(n);
|
|
22
22
|
let i;
|
|
23
23
|
let color;
|
|
24
24
|
// eslint-disable-next-line no-plusplus
|
|
@@ -28,10 +28,10 @@ function rgbSpline(spline) {
|
|
|
28
28
|
g[i] = color[1] || 0;
|
|
29
29
|
b[i] = color[2] || 0;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return t => [
|
|
31
|
+
const rFunc = spline(r);
|
|
32
|
+
const gFunc = spline(g);
|
|
33
|
+
const bFunc = spline(b);
|
|
34
|
+
return (t) => [rFunc(t), gFunc(t), bFunc(t)];
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
// Reference: https://github.com/d3/d3-interpolate/blob/594a32af1fe1118812b439012c2cb742e907c0c0/src/basis.js
|
|
@@ -58,7 +58,7 @@ function basis(values) {
|
|
|
58
58
|
const interpolateRgbBasis = rgbSpline(basis);
|
|
59
59
|
function interpolateSequentialMulti(range) {
|
|
60
60
|
const n = range.length;
|
|
61
|
-
return t => range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
|
|
61
|
+
return (t) => range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
|
|
62
62
|
}
|
|
63
63
|
export const interpolateRdBu = interpolateRgbBasis(schemeRdBu);
|
|
64
64
|
export const interpolatePlasma = interpolateSequentialMulti(schemePlasma);
|
|
@@ -78,6 +78,7 @@ export const interpolatePlasma = interpolateSequentialMulti(schemePlasma);
|
|
|
78
78
|
export function getCellColors(params) {
|
|
79
79
|
const { cellSets, cellSetSelection, cellSetColor, obsIndex, theme, } = params;
|
|
80
80
|
if (cellSetSelection && cellSets) {
|
|
81
|
+
// TODO(ts): fix typing here once better typing in sets-utils.
|
|
81
82
|
return treeToCellColorsBySetNames(cellSets, cellSetSelection, cellSetColor, theme);
|
|
82
83
|
}
|
|
83
84
|
if (obsIndex && theme) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolate-colors.test.d.ts","sourceRoot":"","sources":["../src/interpolate-colors.test.
|
|
1
|
+
{"version":3,"file":"interpolate-colors.test.d.ts","sourceRoot":"","sources":["../src/interpolate-colors.test.ts"],"names":[],"mappings":""}
|
package/dist-tsc/root.d.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
export function fromEntries(iterable: any):
|
|
2
|
-
|
|
1
|
+
export declare function fromEntries(iterable: [string, any][]): {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
export declare function commaNumber(n: number): string;
|
|
3
5
|
/**
|
|
4
6
|
* Capitalize a the first letter of a string.
|
|
5
7
|
* @param {string} word A string to capitalize.
|
|
6
8
|
* @returns {string} The word parameter with the first letter capitalized.
|
|
7
9
|
*/
|
|
8
|
-
export function capitalize(word: string): string;
|
|
10
|
+
export declare function capitalize(word: string | null): string;
|
|
9
11
|
/**
|
|
10
12
|
* Capitalize a the first letter of a string.
|
|
11
13
|
* @param {string} word A string to capitalize.
|
|
12
14
|
* @returns {string} The word parameter with the first letter capitalized.
|
|
13
15
|
*/
|
|
14
|
-
export function pluralize(word: string, count?: null):
|
|
16
|
+
export declare function pluralize(word: string, count?: number | null): any;
|
|
15
17
|
/**
|
|
16
18
|
* Get the longest string in the array of strings.
|
|
17
19
|
* @param {string[]} strings The array of strings.
|
|
18
20
|
* @returns The longest string.
|
|
19
21
|
*/
|
|
20
|
-
export function getLongestString(strings: string[]): string;
|
|
22
|
+
export declare function getLongestString(strings: string[]): string;
|
|
21
23
|
/**
|
|
22
24
|
* Generate a new scope name which does not
|
|
23
25
|
* conflict / overlap with a previous scope name.
|
|
@@ -28,5 +30,5 @@ export function getLongestString(strings: string[]): string;
|
|
|
28
30
|
* @param {string[]} prevScopes Previous scope names.
|
|
29
31
|
* @returns {string} The new scope name.
|
|
30
32
|
*/
|
|
31
|
-
export function getNextScope(prevScopes: string[]): string;
|
|
33
|
+
export declare function getNextScope(prevScopes: string[]): string;
|
|
32
34
|
//# sourceMappingURL=root.d.ts.map
|
package/dist-tsc/root.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAQA,wBAAgB,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAG7E;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,UAGpC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,UAE7C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,GAAG,IAAW,OAElE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,UAMjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,UAqChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lodash-es": "^4.17.21",
|
|
21
21
|
"lz-string": "^1.4.4",
|
|
22
22
|
"pluralize": "^8.0.0",
|
|
23
|
-
"@vitessce/sets-utils": "3.
|
|
23
|
+
"@vitessce/sets-utils": "3.3.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
|
package/src/{Pool.js → Pool.ts}
RENAMED
|
@@ -2,22 +2,27 @@
|
|
|
2
2
|
// We need to give a different way of getting this for safari, so 4 is probably a safe bet
|
|
3
3
|
// for parallel processing in the meantime. More can't really hurt since they'll just block
|
|
4
4
|
// each other and not the UI thread, which is the real benefit.
|
|
5
|
-
const defaultPoolSize = typeof navigator !== 'undefined' ? navigator.hardwareConcurrency || 4 :
|
|
5
|
+
const defaultPoolSize = typeof navigator !== 'undefined' ? navigator.hardwareConcurrency || 4 : 1;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Pool for workers to decode chunks of the images.
|
|
9
9
|
* This is a line-for-line copy of GeoTIFFs old implementation: https://github.com/geotiffjs/geotiff.js/blob/v1.0.0-beta.6/src/pool.js
|
|
10
10
|
*/
|
|
11
11
|
export default class Pool {
|
|
12
|
+
workers: Worker[];
|
|
13
|
+
|
|
14
|
+
idleWorkers: Worker[];
|
|
15
|
+
|
|
16
|
+
waitQueue: { resolve?: (worker: Worker) => void }[];
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* @constructor
|
|
14
20
|
* @param {object} Worker The worker class to be used for processing.
|
|
15
21
|
*/
|
|
16
|
-
constructor(createWorker) {
|
|
22
|
+
constructor(createWorker: () => Worker) {
|
|
17
23
|
this.workers = [];
|
|
18
24
|
this.idleWorkers = [];
|
|
19
25
|
this.waitQueue = [];
|
|
20
|
-
this.decoder = null;
|
|
21
26
|
|
|
22
27
|
// eslint-disable-next-line no-plusplus
|
|
23
28
|
for (let i = 0; i < defaultPoolSize; ++i) {
|
|
@@ -37,7 +42,7 @@ export default class Pool {
|
|
|
37
42
|
if (idleWorker) {
|
|
38
43
|
return idleWorker;
|
|
39
44
|
}
|
|
40
|
-
const waiter = {};
|
|
45
|
+
const waiter: { resolve?: (worker: Worker) => void } = {};
|
|
41
46
|
const promise = new Promise((resolve) => {
|
|
42
47
|
waiter.resolve = resolve;
|
|
43
48
|
});
|
|
@@ -46,9 +51,9 @@ export default class Pool {
|
|
|
46
51
|
return promise;
|
|
47
52
|
}
|
|
48
53
|
|
|
49
|
-
async finishTask(currentWorker) {
|
|
54
|
+
async finishTask(currentWorker: Worker) {
|
|
50
55
|
const waiter = this.waitQueue.pop();
|
|
51
|
-
if (waiter) {
|
|
56
|
+
if (waiter && waiter.resolve) {
|
|
52
57
|
waiter.resolve(currentWorker);
|
|
53
58
|
} else {
|
|
54
59
|
this.idleWorkers.push(currentWorker);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export const DEFAULT_DARK_COLOR = [50, 50, 50];
|
|
3
3
|
export const DEFAULT_LIGHT_COLOR = [200, 200, 200];
|
|
4
4
|
|
|
5
|
-
export function getDefaultColor(theme) {
|
|
5
|
+
export function getDefaultColor(theme: 'dark' | 'light') {
|
|
6
6
|
return theme === 'dark' ? DEFAULT_DARK_COLOR : DEFAULT_LIGHT_COLOR;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -75,31 +75,32 @@ export const COLORMAP_OPTIONS = [
|
|
|
75
75
|
|
|
76
76
|
export const DEFAULT_GL_OPTIONS = { webgl2: true };
|
|
77
77
|
|
|
78
|
-
export function createDefaultUpdateStatus(componentName) {
|
|
79
|
-
return message => console.warn(`${componentName} updateStatus: ${message}`);
|
|
78
|
+
export function createDefaultUpdateStatus(componentName: string) {
|
|
79
|
+
return (message: string) => console.warn(`${componentName} updateStatus: ${message}`);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export function createDefaultUpdateCellsSelection(componentName) {
|
|
83
|
-
return cellsSelection => console.warn(`${componentName} updateCellsSelection: ${cellsSelection}`);
|
|
82
|
+
export function createDefaultUpdateCellsSelection(componentName: string) {
|
|
83
|
+
return (cellsSelection: any) => console.warn(`${componentName} updateCellsSelection: ${cellsSelection}`);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export function createDefaultUpdateCellsHover(componentName) {
|
|
87
|
-
return hoverInfo => console.warn(`${componentName} updateCellsHover: ${hoverInfo.cellId}`);
|
|
86
|
+
export function createDefaultUpdateCellsHover(componentName: string) {
|
|
87
|
+
return (hoverInfo: { cellId: string }) => console.warn(`${componentName} updateCellsHover: ${hoverInfo.cellId}`);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
export function createDefaultUpdateGenesHover(componentName) {
|
|
91
|
-
return hoverInfo => console.warn(`${componentName} updateGenesHover: ${hoverInfo.geneId}`);
|
|
90
|
+
export function createDefaultUpdateGenesHover(componentName: string) {
|
|
91
|
+
return (hoverInfo: { geneId: string }) => console.warn(`${componentName} updateGenesHover: ${hoverInfo.geneId}`);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export function createDefaultUpdateTracksHover(componentName) {
|
|
95
|
-
return hoverInfo => console.warn(`${componentName} updateTracksHover: ${hoverInfo}`);
|
|
94
|
+
export function createDefaultUpdateTracksHover(componentName: string) {
|
|
95
|
+
return (hoverInfo: any) => console.warn(`${componentName} updateTracksHover: ${hoverInfo}`);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
export function createDefaultUpdateViewInfo(componentName) {
|
|
99
|
-
return viewInfo => console.warn(`${componentName} updateViewInfo: ${viewInfo}`);
|
|
98
|
+
export function createDefaultUpdateViewInfo(componentName: string) {
|
|
99
|
+
return (viewInfo: any) => console.warn(`${componentName} updateViewInfo: ${viewInfo}`);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
export function createDefaultClearPleaseWait() {
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
103
104
|
return () => {};
|
|
104
105
|
}
|
|
105
106
|
|
|
@@ -109,14 +110,14 @@ export function createDefaultClearPleaseWait() {
|
|
|
109
110
|
* @param {Uint8Array} arr The typed array to be copied.
|
|
110
111
|
* @returns {Uint8Array} The copied array.
|
|
111
112
|
*/
|
|
112
|
-
export function copyUint8Array(arr) {
|
|
113
|
+
export function copyUint8Array(arr: Uint8Array) {
|
|
113
114
|
const newBuffer = new ArrayBuffer(arr.buffer.byteLength);
|
|
114
115
|
const newArr = new Uint8Array(newBuffer);
|
|
115
116
|
newArr.set(arr);
|
|
116
117
|
return newArr;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
export function asEsModule(component) {
|
|
120
|
+
export function asEsModule(component: any) {
|
|
120
121
|
return {
|
|
121
122
|
__esModule: true,
|
|
122
123
|
default: component,
|
|
@@ -124,7 +125,7 @@ export function asEsModule(component) {
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
|
|
127
|
-
export function formatBytes(bytes, decimals = 2) {
|
|
128
|
+
export function formatBytes(bytes: number, decimals = 2) {
|
|
128
129
|
if (bytes === 0) return '0 Bytes';
|
|
129
130
|
|
|
130
131
|
const k = 1024;
|
|
@@ -13,18 +13,18 @@ export const VALUE_TRANSFORM_OPTIONS = [
|
|
|
13
13
|
* as a parameter and returns the transformed number
|
|
14
14
|
* (or the original number in the identity case).
|
|
15
15
|
*/
|
|
16
|
-
export function getValueTransformFunction(featureValueTransform, coefficient) {
|
|
16
|
+
export function getValueTransformFunction(featureValueTransform: 'log1p' | 'arcsinh' | null, coefficient: number) {
|
|
17
17
|
// Set transform function
|
|
18
18
|
let transformFunction;
|
|
19
19
|
switch (featureValueTransform) {
|
|
20
20
|
case 'log1p':
|
|
21
|
-
transformFunction = v => Math.log(1 + v * coefficient);
|
|
21
|
+
transformFunction = (v: number) => Math.log(1 + v * coefficient);
|
|
22
22
|
break;
|
|
23
23
|
case 'arcsinh':
|
|
24
|
-
transformFunction = v => Math.asinh(v * coefficient);
|
|
24
|
+
transformFunction = (v: number) => Math.asinh(v * coefficient);
|
|
25
25
|
break;
|
|
26
26
|
default:
|
|
27
|
-
transformFunction = v => v;
|
|
27
|
+
transformFunction = (v: number) => v;
|
|
28
28
|
}
|
|
29
29
|
return transformFunction;
|
|
30
30
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
2
|
+
export {
|
|
3
|
+
fromEntries,
|
|
4
|
+
commaNumber,
|
|
5
|
+
capitalize,
|
|
6
|
+
pluralize,
|
|
7
|
+
getLongestString,
|
|
8
|
+
getNextScope,
|
|
9
|
+
} from './root.js';
|
|
10
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
11
|
+
export {
|
|
12
|
+
DEFAULT_DARK_COLOR,
|
|
13
|
+
DEFAULT_LIGHT_COLOR,
|
|
14
|
+
getDefaultColor,
|
|
15
|
+
PALETTE,
|
|
16
|
+
VIEWER_PALETTE,
|
|
17
|
+
PATHOLOGY_PALETTE,
|
|
18
|
+
LARGE_PATHOLOGY_PALETTE,
|
|
19
|
+
COLORMAP_OPTIONS,
|
|
20
|
+
DEFAULT_GL_OPTIONS,
|
|
21
|
+
createDefaultUpdateStatus,
|
|
22
|
+
createDefaultUpdateCellsSelection,
|
|
23
|
+
createDefaultUpdateCellsHover,
|
|
24
|
+
createDefaultUpdateGenesHover,
|
|
25
|
+
createDefaultUpdateTracksHover,
|
|
26
|
+
createDefaultUpdateViewInfo,
|
|
27
|
+
createDefaultClearPleaseWait,
|
|
28
|
+
copyUint8Array,
|
|
29
|
+
asEsModule,
|
|
30
|
+
formatBytes,
|
|
31
|
+
} from './components.js';
|
|
32
|
+
export {
|
|
33
|
+
getValueTransformFunction,
|
|
34
|
+
VALUE_TRANSFORM_OPTIONS,
|
|
35
|
+
} from './gating.js';
|
|
36
|
+
export {
|
|
37
|
+
getCellColors,
|
|
38
|
+
} from './interpolate-colors.js';
|
|
39
|
+
export { default as Pool } from './Pool.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { interpolateRdBu, interpolatePlasma } from './interpolate-colors.js';
|
|
3
3
|
|
|
4
|
-
const expectRgb = ([testR, testG, testB], [r, g, b]) => ([
|
|
4
|
+
const expectRgb = ([testR, testG, testB]: number[], [r, g, b]: number[]) => ([
|
|
5
5
|
expect(testR).toBeCloseTo(r),
|
|
6
6
|
expect(testG).toBeCloseTo(g),
|
|
7
7
|
expect(testB).toBeCloseTo(b),
|