@vitessce/spatial-utils 2.0.3 → 3.0.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/{deflate.b31189ff.mjs → deflate-132dedf0.js} +2 -3
- package/dist/{index.75f0a489.mjs → index-ce1fad7e.js} +37344 -28760
- package/dist/{index.mjs → index.js} +7 -5
- package/dist/{jpeg.1d104fed.mjs → jpeg-258024ce.js} +1 -2
- package/dist/{lerc.95b793c7.mjs → lerc-279c1032.js} +76 -6
- package/dist/{lzw.ade1d376.mjs → lzw-d830df9b.js} +1 -2
- package/dist/{packbits.16b1394a.mjs → packbits-fe766b57.js} +1 -2
- package/dist/{pako.esm.4b234125.mjs → pako.esm-68f84e2a.js} +97 -15
- package/dist/{raw.c3b45ab1.mjs → raw-f15bab0d.js} +1 -2
- package/dist/{webimage.53b9bf75.mjs → webimage-03150187.js} +1 -2
- package/dist-tsc/index.d.ts +2 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +1 -1
- package/dist-tsc/layer-controller.d.ts +23 -0
- package/dist-tsc/layer-controller.d.ts.map +1 -0
- package/dist-tsc/layer-controller.js +109 -0
- package/dist-tsc/spatial.d.ts +87 -0
- package/dist-tsc/spatial.d.ts.map +1 -0
- package/dist-tsc/spatial.js +375 -0
- package/dist-tsc/spatial.test.d.ts +2 -0
- package/dist-tsc/spatial.test.d.ts.map +1 -0
- package/dist-tsc/spatial.test.js +43 -0
- package/package.json +15 -6
- package/src/index.js +4 -1
- package/src/spatial.js +102 -2
- package/src/spatial.test.js +37 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { D, e, a, b, c, d, G,
|
|
2
|
-
import "@vitessce/vit-s";
|
|
1
|
+
import { D, e, a, b, c, d, G, n, l, m, h, i, f, j, k, s } from "./index-ce1fad7e.js";
|
|
3
2
|
import "react";
|
|
4
3
|
export {
|
|
5
4
|
D as DEFAULT_CELLS_LAYER,
|
|
@@ -9,10 +8,13 @@ export {
|
|
|
9
8
|
c as DEFAULT_RASTER_DOMAIN_TYPE,
|
|
10
9
|
d as DEFAULT_RASTER_LAYER_PROPS,
|
|
11
10
|
G as GLOBAL_LABELS,
|
|
12
|
-
|
|
11
|
+
n as coordinateTransformationsToMatrix,
|
|
12
|
+
l as getNgffAxes,
|
|
13
|
+
m as getNgffAxesForTiff,
|
|
14
|
+
h as getSourceFromLoader,
|
|
13
15
|
i as initializeLayerChannels,
|
|
14
16
|
f as initializeRasterLayersAndChannels,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
j as isInterleaved,
|
|
18
|
+
k as isRgb,
|
|
17
19
|
s as square
|
|
18
20
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { i as inflate_1 } from "./pako.esm.
|
|
2
|
-
import { B as BaseDecoder } from "./index.
|
|
3
|
-
import "@vitessce/vit-s";
|
|
1
|
+
import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
|
|
2
|
+
import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-ce1fad7e.js";
|
|
4
3
|
import "react";
|
|
5
4
|
const LercParameters = {
|
|
6
5
|
Version: 0,
|
|
@@ -371,6 +370,8 @@ var LercDecode = { exports: {} };
|
|
|
371
370
|
}();
|
|
372
371
|
var Lerc2Decode = function() {
|
|
373
372
|
var BitStuffer = {
|
|
373
|
+
//methods ending with 2 are for the new byte order used by Lerc2.3 and above.
|
|
374
|
+
//originalUnstuff is used to unpack Huffman code table. code is duplicated to unstuffx for performance reasons.
|
|
374
375
|
unstuff: function(src, dest, bitsPerPixel, numPixels, lutArr, offset, scale, maxValue) {
|
|
375
376
|
var bitMask = (1 << bitsPerPixel) - 1;
|
|
376
377
|
var i = 0, o;
|
|
@@ -581,6 +582,7 @@ var LercDecode = { exports: {} };
|
|
|
581
582
|
};
|
|
582
583
|
var Lerc2Helpers = {
|
|
583
584
|
HUFFMAN_LUT_BITS_MAX: 12,
|
|
585
|
+
//use 2^12 lut, treat it like constant
|
|
584
586
|
computeChecksumFletcher32: function(input) {
|
|
585
587
|
var sum1 = 65535, sum2 = 65535;
|
|
586
588
|
var len = input.length;
|
|
@@ -1391,6 +1393,9 @@ var LercDecode = { exports: {} };
|
|
|
1391
1393
|
data.pixels.resultPixels = Lerc2Helpers.swapDimensionOrder(data.pixels.resultPixels, numPixels, numDims, OutPixelTypeArray);
|
|
1392
1394
|
}
|
|
1393
1395
|
},
|
|
1396
|
+
/*****************
|
|
1397
|
+
* private methods (helper methods)
|
|
1398
|
+
*****************/
|
|
1394
1399
|
formatFileInfo: function(data) {
|
|
1395
1400
|
return {
|
|
1396
1401
|
"fileIdentifierString": data.headerInfo.fileIdentifierString,
|
|
@@ -1410,6 +1415,7 @@ var LercDecode = { exports: {} };
|
|
|
1410
1415
|
"pixels": {
|
|
1411
1416
|
"numBlocksX": data.pixels.numBlocksX,
|
|
1412
1417
|
"numBlocksY": data.pixels.numBlocksY,
|
|
1418
|
+
//"numBytes": data.pixels.numBytes,
|
|
1413
1419
|
"maxValue": data.headerInfo.zMax,
|
|
1414
1420
|
"minValue": data.headerInfo.zMin,
|
|
1415
1421
|
"noDataValue": data.noDataValue
|
|
@@ -1697,14 +1703,48 @@ var LercDecode = { exports: {} };
|
|
|
1697
1703
|
this.right = right;
|
|
1698
1704
|
};
|
|
1699
1705
|
var Lerc2Decode2 = {
|
|
1706
|
+
/*
|
|
1707
|
+
* ********removed options compared to LERC1. We can bring some of them back if needed.
|
|
1708
|
+
* removed pixel type. LERC2 is typed and doesn't require user to give pixel type
|
|
1709
|
+
* changed encodedMaskData to maskData. LERC2 's js version make it faster to use maskData directly.
|
|
1710
|
+
* removed returnMask. mask is used by LERC2 internally and is cost free. In case of user input mask, it's returned as well and has neglible cost.
|
|
1711
|
+
* removed nodatavalue. Because LERC2 pixels are typed, nodatavalue will sacrify a useful value for many types (8bit, 16bit) etc,
|
|
1712
|
+
* user has to be knowledgable enough about raster and their data to avoid usability issues. so nodata value is simply removed now.
|
|
1713
|
+
* We can add it back later if their's a clear requirement.
|
|
1714
|
+
* removed encodedMask. This option was not implemented in LercDecode. It can be done after decoding (less efficient)
|
|
1715
|
+
* removed computeUsedBitDepths.
|
|
1716
|
+
*
|
|
1717
|
+
*
|
|
1718
|
+
* response changes compared to LERC1
|
|
1719
|
+
* 1. encodedMaskData is not available
|
|
1720
|
+
* 2. noDataValue is optional (returns only if user's noDataValue is with in the valid data type range)
|
|
1721
|
+
* 3. maskData is always available
|
|
1722
|
+
*/
|
|
1723
|
+
/*****************
|
|
1724
|
+
* public properties
|
|
1725
|
+
******************/
|
|
1726
|
+
//HUFFMAN_LUT_BITS_MAX: 12, //use 2^12 lut, not configurable
|
|
1727
|
+
/*****************
|
|
1728
|
+
* public methods
|
|
1729
|
+
*****************/
|
|
1730
|
+
/**
|
|
1731
|
+
* Decode a LERC2 byte stream and return an object containing the pixel data and optional metadata.
|
|
1732
|
+
*
|
|
1733
|
+
* @param {ArrayBuffer} input The LERC input byte stream
|
|
1734
|
+
* @param {object} [options] options Decoding options
|
|
1735
|
+
* @param {number} [options.inputOffset] The number of bytes to skip in the input byte stream. A valid LERC file is expected at that position
|
|
1736
|
+
* @param {boolean} [options.returnFileInfo] If true, the return value will have a fileInfo property that contains metadata obtained from the LERC headers and the decoding process
|
|
1737
|
+
* @param {boolean} [options.returnPixelInterleavedDims] If true, returned dimensions are pixel-interleaved, a.k.a [p1_dim0, p1_dim1, p1_dimn, p2_dim0...], default is [p1_dim0, p2_dim0, ..., p1_dim1, p2_dim1...]
|
|
1738
|
+
*/
|
|
1700
1739
|
decode: function(input, options) {
|
|
1701
1740
|
options = options || {};
|
|
1702
1741
|
var noDataValue = options.noDataValue;
|
|
1703
1742
|
var i = 0, data = {};
|
|
1704
1743
|
data.ptr = options.inputOffset || 0;
|
|
1705
1744
|
data.pixels = {};
|
|
1706
|
-
if (!Lerc2Helpers.readHeaderInfo(input, data))
|
|
1707
|
-
;
|
|
1745
|
+
if (!Lerc2Helpers.readHeaderInfo(input, data)) {
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1708
1748
|
var headerInfo = data.headerInfo;
|
|
1709
1749
|
var fileVersion = headerInfo.fileVersion;
|
|
1710
1750
|
var OutPixelTypeArray = Lerc2Helpers.getDataTypeArray(headerInfo.imageType);
|
|
@@ -1782,6 +1822,7 @@ var LercDecode = { exports: {} };
|
|
|
1782
1822
|
maxValues: headerInfo.maxValues
|
|
1783
1823
|
},
|
|
1784
1824
|
maskData: data.pixels.resultMask
|
|
1825
|
+
//noDataValue: noDataValue
|
|
1785
1826
|
};
|
|
1786
1827
|
if (data.pixels.resultMask && Lerc2Helpers.isValidPixelValue(headerInfo.imageType, noDataValue)) {
|
|
1787
1828
|
var mask = data.pixels.resultMask;
|
|
@@ -1823,6 +1864,25 @@ var LercDecode = { exports: {} };
|
|
|
1823
1864
|
return b[0] === 1;
|
|
1824
1865
|
}();
|
|
1825
1866
|
var Lerc2 = {
|
|
1867
|
+
/************wrapper**********************************************/
|
|
1868
|
+
/**
|
|
1869
|
+
* A wrapper for decoding both LERC1 and LERC2 byte streams capable of handling multiband pixel blocks for various pixel types.
|
|
1870
|
+
*
|
|
1871
|
+
* @alias module:Lerc
|
|
1872
|
+
* @param {ArrayBuffer} input The LERC input byte stream
|
|
1873
|
+
* @param {object} [options] The decoding options below are optional.
|
|
1874
|
+
* @param {number} [options.inputOffset] The number of bytes to skip in the input byte stream. A valid Lerc file is expected at that position.
|
|
1875
|
+
* @param {string} [options.pixelType] (LERC1 only) Default value is F32. Valid pixel types for input are U8/S8/S16/U16/S32/U32/F32.
|
|
1876
|
+
* @param {number} [options.noDataValue] (LERC1 only). It is recommended to use the returned mask instead of setting this value.
|
|
1877
|
+
* @param {boolean} [options.returnPixelInterleavedDims] (nDim LERC2 only) If true, returned dimensions are pixel-interleaved, a.k.a [p1_dim0, p1_dim1, p1_dimn, p2_dim0...], default is [p1_dim0, p2_dim0, ..., p1_dim1, p2_dim1...]
|
|
1878
|
+
* @returns {{width, height, pixels, pixelType, mask, statistics}}
|
|
1879
|
+
* @property {number} width Width of decoded image.
|
|
1880
|
+
* @property {number} height Height of decoded image.
|
|
1881
|
+
* @property {array} pixels [band1, band2, …] Each band is a typed array of width*height.
|
|
1882
|
+
* @property {string} pixelType The type of pixels represented in the output.
|
|
1883
|
+
* @property {mask} mask Typed array with a size of width*height, or null if all pixels are valid.
|
|
1884
|
+
* @property {array} statistics [statistics_band1, statistics_band2, …] Each element is a statistics object representing min and max values
|
|
1885
|
+
**/
|
|
1826
1886
|
decode: function(encodedData, options) {
|
|
1827
1887
|
if (!isPlatformLittleEndian) {
|
|
1828
1888
|
throw "Big endian system is not supported.";
|
|
@@ -1854,14 +1914,23 @@ var LercDecode = { exports: {} };
|
|
|
1854
1914
|
while (inputOffset < eof) {
|
|
1855
1915
|
var result = lerc.decode(encodedData, {
|
|
1856
1916
|
inputOffset,
|
|
1917
|
+
//for both lerc1 and lerc2
|
|
1857
1918
|
encodedMaskData,
|
|
1919
|
+
//lerc1 only
|
|
1858
1920
|
maskData,
|
|
1921
|
+
//lerc2 only
|
|
1859
1922
|
returnMask: iPlane === 0 ? true : false,
|
|
1923
|
+
//lerc1 only
|
|
1860
1924
|
returnEncodedMask: iPlane === 0 ? true : false,
|
|
1925
|
+
//lerc1 only
|
|
1861
1926
|
returnFileInfo: true,
|
|
1927
|
+
//for both lerc1 and lerc2
|
|
1862
1928
|
returnPixelInterleavedDims: options.returnPixelInterleavedDims,
|
|
1929
|
+
//for ndim lerc2 only
|
|
1863
1930
|
pixelType: options.pixelType || null,
|
|
1931
|
+
//lerc1 only
|
|
1864
1932
|
noDataValue: options.noDataValue || null
|
|
1933
|
+
//lerc1 only
|
|
1865
1934
|
});
|
|
1866
1935
|
inputOffset = result.fileInfo.eofOffset;
|
|
1867
1936
|
maskData = result.maskData;
|
|
@@ -1914,7 +1983,8 @@ var LercDecode = { exports: {} };
|
|
|
1914
1983
|
}
|
|
1915
1984
|
})();
|
|
1916
1985
|
})(LercDecode);
|
|
1917
|
-
|
|
1986
|
+
var LercDecodeExports = LercDecode.exports;
|
|
1987
|
+
const Lerc = /* @__PURE__ */ getDefaultExportFromCjs(LercDecodeExports);
|
|
1918
1988
|
class LercDecoder extends BaseDecoder {
|
|
1919
1989
|
constructor(fileDirectory) {
|
|
1920
1990
|
super();
|
|
@@ -27,9 +27,18 @@ const END_BLOCK = 256;
|
|
|
27
27
|
const REP_3_6 = 16;
|
|
28
28
|
const REPZ_3_10 = 17;
|
|
29
29
|
const REPZ_11_138 = 18;
|
|
30
|
-
const extra_lbits =
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const extra_lbits = (
|
|
31
|
+
/* extra bits for each length code */
|
|
32
|
+
new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0])
|
|
33
|
+
);
|
|
34
|
+
const extra_dbits = (
|
|
35
|
+
/* extra bits for each distance code */
|
|
36
|
+
new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13])
|
|
37
|
+
);
|
|
38
|
+
const extra_blbits = (
|
|
39
|
+
/* extra bits for each bit length code */
|
|
40
|
+
new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7])
|
|
41
|
+
);
|
|
33
42
|
const bl_order = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
34
43
|
const DIST_CODE_LEN = 512;
|
|
35
44
|
const static_ltree = new Array((L_CODES$1 + 2) * 2);
|
|
@@ -79,7 +88,12 @@ const send_bits = (s, value, length) => {
|
|
|
79
88
|
}
|
|
80
89
|
};
|
|
81
90
|
const send_code = (s, c, tree) => {
|
|
82
|
-
send_bits(
|
|
91
|
+
send_bits(
|
|
92
|
+
s,
|
|
93
|
+
tree[c * 2],
|
|
94
|
+
tree[c * 2 + 1]
|
|
95
|
+
/*.Len*/
|
|
96
|
+
);
|
|
83
97
|
};
|
|
84
98
|
const bi_reverse = (code, len) => {
|
|
85
99
|
let res = 0;
|
|
@@ -368,19 +382,44 @@ const build_tree = (s, desc) => {
|
|
|
368
382
|
}
|
|
369
383
|
node = elems;
|
|
370
384
|
do {
|
|
371
|
-
n = s.heap[
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
385
|
+
n = s.heap[
|
|
386
|
+
1
|
|
387
|
+
/*SMALLEST*/
|
|
388
|
+
];
|
|
389
|
+
s.heap[
|
|
390
|
+
1
|
|
391
|
+
/*SMALLEST*/
|
|
392
|
+
] = s.heap[s.heap_len--];
|
|
393
|
+
pqdownheap(
|
|
394
|
+
s,
|
|
395
|
+
tree,
|
|
396
|
+
1
|
|
397
|
+
/*SMALLEST*/
|
|
398
|
+
);
|
|
399
|
+
m = s.heap[
|
|
400
|
+
1
|
|
401
|
+
/*SMALLEST*/
|
|
402
|
+
];
|
|
375
403
|
s.heap[--s.heap_max] = n;
|
|
376
404
|
s.heap[--s.heap_max] = m;
|
|
377
405
|
tree[node * 2] = tree[n * 2] + tree[m * 2];
|
|
378
406
|
s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
|
|
379
407
|
tree[n * 2 + 1] = tree[m * 2 + 1] = node;
|
|
380
|
-
s.heap[
|
|
381
|
-
|
|
408
|
+
s.heap[
|
|
409
|
+
1
|
|
410
|
+
/*SMALLEST*/
|
|
411
|
+
] = node++;
|
|
412
|
+
pqdownheap(
|
|
413
|
+
s,
|
|
414
|
+
tree,
|
|
415
|
+
1
|
|
416
|
+
/*SMALLEST*/
|
|
417
|
+
);
|
|
382
418
|
} while (s.heap_len >= 2);
|
|
383
|
-
s.heap[--s.heap_max] = s.heap[
|
|
419
|
+
s.heap[--s.heap_max] = s.heap[
|
|
420
|
+
1
|
|
421
|
+
/*SMALLEST*/
|
|
422
|
+
];
|
|
384
423
|
gen_bitlen(s, desc);
|
|
385
424
|
gen_codes(tree, max_code, s.bl_count);
|
|
386
425
|
};
|
|
@@ -640,16 +679,26 @@ const crc32 = (crc, buf, len, pos) => {
|
|
|
640
679
|
var crc32_1 = crc32;
|
|
641
680
|
var messages = {
|
|
642
681
|
2: "need dictionary",
|
|
682
|
+
/* Z_NEED_DICT 2 */
|
|
643
683
|
1: "stream end",
|
|
684
|
+
/* Z_STREAM_END 1 */
|
|
644
685
|
0: "",
|
|
686
|
+
/* Z_OK 0 */
|
|
645
687
|
"-1": "file error",
|
|
688
|
+
/* Z_ERRNO (-1) */
|
|
646
689
|
"-2": "stream error",
|
|
690
|
+
/* Z_STREAM_ERROR (-2) */
|
|
647
691
|
"-3": "data error",
|
|
692
|
+
/* Z_DATA_ERROR (-3) */
|
|
648
693
|
"-4": "insufficient memory",
|
|
694
|
+
/* Z_MEM_ERROR (-4) */
|
|
649
695
|
"-5": "buffer error",
|
|
696
|
+
/* Z_BUF_ERROR (-5) */
|
|
650
697
|
"-6": "incompatible version"
|
|
698
|
+
/* Z_VERSION_ERROR (-6) */
|
|
651
699
|
};
|
|
652
700
|
var constants$2 = {
|
|
701
|
+
/* Allowed flush values; see deflate() and inflate() below for details */
|
|
653
702
|
Z_NO_FLUSH: 0,
|
|
654
703
|
Z_PARTIAL_FLUSH: 1,
|
|
655
704
|
Z_SYNC_FLUSH: 2,
|
|
@@ -657,6 +706,9 @@ var constants$2 = {
|
|
|
657
706
|
Z_FINISH: 4,
|
|
658
707
|
Z_BLOCK: 5,
|
|
659
708
|
Z_TREES: 6,
|
|
709
|
+
/* Return codes for the compression/decompression functions. Negative values
|
|
710
|
+
* are errors, positive values are used for special but normal events.
|
|
711
|
+
*/
|
|
660
712
|
Z_OK: 0,
|
|
661
713
|
Z_STREAM_END: 1,
|
|
662
714
|
Z_NEED_DICT: 2,
|
|
@@ -665,6 +717,8 @@ var constants$2 = {
|
|
|
665
717
|
Z_DATA_ERROR: -3,
|
|
666
718
|
Z_MEM_ERROR: -4,
|
|
667
719
|
Z_BUF_ERROR: -5,
|
|
720
|
+
//Z_VERSION_ERROR: -6,
|
|
721
|
+
/* compression levels */
|
|
668
722
|
Z_NO_COMPRESSION: 0,
|
|
669
723
|
Z_BEST_SPEED: 1,
|
|
670
724
|
Z_BEST_COMPRESSION: 9,
|
|
@@ -674,10 +728,14 @@ var constants$2 = {
|
|
|
674
728
|
Z_RLE: 3,
|
|
675
729
|
Z_FIXED: 4,
|
|
676
730
|
Z_DEFAULT_STRATEGY: 0,
|
|
731
|
+
/* Possible values of the data_type field (though see inflate()) */
|
|
677
732
|
Z_BINARY: 0,
|
|
678
733
|
Z_TEXT: 1,
|
|
734
|
+
//Z_ASCII: 1, // = Z_TEXT (deprecated)
|
|
679
735
|
Z_UNKNOWN: 2,
|
|
736
|
+
/* The deflate compression method */
|
|
680
737
|
Z_DEFLATED: 8
|
|
738
|
+
//Z_NULL: null // Use -1 or null inline, depending on var type
|
|
681
739
|
};
|
|
682
740
|
const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = trees;
|
|
683
741
|
const {
|
|
@@ -1195,16 +1253,27 @@ function Config(good_length, max_lazy, nice_length, max_chain, func) {
|
|
|
1195
1253
|
this.func = func;
|
|
1196
1254
|
}
|
|
1197
1255
|
const configuration_table = [
|
|
1256
|
+
/* good lazy nice chain */
|
|
1198
1257
|
new Config(0, 0, 0, 0, deflate_stored),
|
|
1258
|
+
/* 0 store only */
|
|
1199
1259
|
new Config(4, 4, 8, 4, deflate_fast),
|
|
1260
|
+
/* 1 max speed, no lazy matches */
|
|
1200
1261
|
new Config(4, 5, 16, 8, deflate_fast),
|
|
1262
|
+
/* 2 */
|
|
1201
1263
|
new Config(4, 6, 32, 32, deflate_fast),
|
|
1264
|
+
/* 3 */
|
|
1202
1265
|
new Config(4, 4, 16, 16, deflate_slow),
|
|
1266
|
+
/* 4 lazy matches */
|
|
1203
1267
|
new Config(8, 16, 32, 32, deflate_slow),
|
|
1268
|
+
/* 5 */
|
|
1204
1269
|
new Config(8, 16, 128, 128, deflate_slow),
|
|
1270
|
+
/* 6 */
|
|
1205
1271
|
new Config(8, 32, 128, 256, deflate_slow),
|
|
1272
|
+
/* 7 */
|
|
1206
1273
|
new Config(32, 128, 258, 1024, deflate_slow),
|
|
1274
|
+
/* 8 */
|
|
1207
1275
|
new Config(32, 258, 258, 4096, deflate_slow)
|
|
1276
|
+
/* 9 max compression */
|
|
1208
1277
|
];
|
|
1209
1278
|
const lm_init = (s) => {
|
|
1210
1279
|
s.window_size = 2 * s.w_size;
|
|
@@ -2247,6 +2316,7 @@ const CODES$1 = 0;
|
|
|
2247
2316
|
const LENS$1 = 1;
|
|
2248
2317
|
const DISTS$1 = 2;
|
|
2249
2318
|
const lbase = new Uint16Array([
|
|
2319
|
+
/* Length codes 257..285 base */
|
|
2250
2320
|
3,
|
|
2251
2321
|
4,
|
|
2252
2322
|
5,
|
|
@@ -2280,6 +2350,7 @@ const lbase = new Uint16Array([
|
|
|
2280
2350
|
0
|
|
2281
2351
|
]);
|
|
2282
2352
|
const lext = new Uint8Array([
|
|
2353
|
+
/* Length codes 257..285 extra */
|
|
2283
2354
|
16,
|
|
2284
2355
|
16,
|
|
2285
2356
|
16,
|
|
@@ -2313,6 +2384,7 @@ const lext = new Uint8Array([
|
|
|
2313
2384
|
78
|
|
2314
2385
|
]);
|
|
2315
2386
|
const dbase = new Uint16Array([
|
|
2387
|
+
/* Distance codes 0..29 base */
|
|
2316
2388
|
1,
|
|
2317
2389
|
2,
|
|
2318
2390
|
3,
|
|
@@ -2347,6 +2419,7 @@ const dbase = new Uint16Array([
|
|
|
2347
2419
|
0
|
|
2348
2420
|
]);
|
|
2349
2421
|
const dext = new Uint8Array([
|
|
2422
|
+
/* Distance codes 0..29 extra */
|
|
2350
2423
|
16,
|
|
2351
2424
|
16,
|
|
2352
2425
|
16,
|
|
@@ -2799,7 +2872,10 @@ const inflate$2 = (strm, flush) => {
|
|
|
2799
2872
|
const hbuf = new Uint8Array(4);
|
|
2800
2873
|
let opts;
|
|
2801
2874
|
let n;
|
|
2802
|
-
const order =
|
|
2875
|
+
const order = (
|
|
2876
|
+
/* permutation of code lengths */
|
|
2877
|
+
new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])
|
|
2878
|
+
);
|
|
2803
2879
|
if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
|
|
2804
2880
|
return Z_STREAM_ERROR$1;
|
|
2805
2881
|
}
|
|
@@ -2848,7 +2924,8 @@ const inflate$2 = (strm, flush) => {
|
|
|
2848
2924
|
if (state.head) {
|
|
2849
2925
|
state.head.done = false;
|
|
2850
2926
|
}
|
|
2851
|
-
if (!(state.wrap & 1) ||
|
|
2927
|
+
if (!(state.wrap & 1) || /* check if zlib header allowed */
|
|
2928
|
+
(((hold & 255) << 8) + (hold >> 8)) % 31) {
|
|
2852
2929
|
strm.msg = "incorrect header check";
|
|
2853
2930
|
state.mode = BAD;
|
|
2854
2931
|
break;
|
|
@@ -2988,8 +3065,11 @@ const inflate$2 = (strm, flush) => {
|
|
|
2988
3065
|
state.head.extra.set(
|
|
2989
3066
|
input.subarray(
|
|
2990
3067
|
next,
|
|
3068
|
+
// extra field is limited to 65536 bytes
|
|
3069
|
+
// - no need for additional size check
|
|
2991
3070
|
next + copy
|
|
2992
3071
|
),
|
|
3072
|
+
/*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
|
|
2993
3073
|
len
|
|
2994
3074
|
);
|
|
2995
3075
|
}
|
|
@@ -3604,7 +3684,8 @@ const inflate$2 = (strm, flush) => {
|
|
|
3604
3684
|
strm.total_out += _out;
|
|
3605
3685
|
state.total += _out;
|
|
3606
3686
|
if (_out) {
|
|
3607
|
-
strm.adler = state.check =
|
|
3687
|
+
strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/
|
|
3688
|
+
state.flags ? crc32_1(state.check, output, _out, put - _out) : adler32_1(state.check, output, _out, put - _out);
|
|
3608
3689
|
}
|
|
3609
3690
|
_out = left;
|
|
3610
3691
|
if ((state.flags ? hold : zswap32(hold)) !== state.check) {
|
|
@@ -3664,7 +3745,8 @@ const inflate$2 = (strm, flush) => {
|
|
|
3664
3745
|
strm.total_out += _out;
|
|
3665
3746
|
state.total += _out;
|
|
3666
3747
|
if (state.wrap && _out) {
|
|
3667
|
-
strm.adler = state.check =
|
|
3748
|
+
strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
|
|
3749
|
+
state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out);
|
|
3668
3750
|
}
|
|
3669
3751
|
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
|
|
3670
3752
|
if ((_in === 0 && _out === 0 || flush === Z_FINISH$1) && ret === Z_OK$1) {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { GLOBAL_LABELS, DEFAULT_CELLS_LAYER, DEFAULT_MOLECULES_LAYER, DEFAULT_NEIGHBORHOODS_LAYER, DEFAULT_RASTER_DOMAIN_TYPE, DEFAULT_RASTER_LAYER_PROPS, DEFAULT_LAYER_TYPE_ORDERING, square, initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix } from "./spatial.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|
package/dist-tsc/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { GLOBAL_LABELS, DEFAULT_CELLS_LAYER, DEFAULT_MOLECULES_LAYER, DEFAULT_NEIGHBORHOODS_LAYER, DEFAULT_RASTER_DOMAIN_TYPE, DEFAULT_RASTER_LAYER_PROPS, DEFAULT_LAYER_TYPE_ORDERING, square, initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, } from './spatial';
|
|
1
|
+
export { GLOBAL_LABELS, DEFAULT_CELLS_LAYER, DEFAULT_MOLECULES_LAYER, DEFAULT_NEIGHBORHOODS_LAYER, DEFAULT_RASTER_DOMAIN_TYPE, DEFAULT_RASTER_LAYER_PROPS, DEFAULT_LAYER_TYPE_ORDERING, square, initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix, } from './spatial.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get physical size scaling Matrix4
|
|
3
|
+
* @param {Object} loader PixelSource
|
|
4
|
+
* @returns {Object} matrix
|
|
5
|
+
*/
|
|
6
|
+
export function getPhysicalSizeScalingMatrix(loader: Object): Object;
|
|
7
|
+
/**
|
|
8
|
+
* Get bounding cube for a given loader
|
|
9
|
+
* @param {Object} loader PixelSource|PixelSource[]
|
|
10
|
+
* @returns {Array} [0, width], [0, height], [0, depth]]
|
|
11
|
+
*/
|
|
12
|
+
export function getBoundingCube(loader: Object): any[];
|
|
13
|
+
export function abbreviateNumber(value: any): any;
|
|
14
|
+
export function getSingleSelectionStats({ loader, selection, use3d }: Object): Object;
|
|
15
|
+
export function getMultiSelectionStats({ loader, selections, use3d }: {
|
|
16
|
+
loader: any;
|
|
17
|
+
selections: any;
|
|
18
|
+
use3d: any;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
domains: any[];
|
|
21
|
+
sliders: any[];
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=layer-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-controller.d.ts","sourceRoot":"","sources":["../src/layer-controller.js"],"names":[],"mappings":"AAuEA;;;;GAIG;AACH,qDAHW,MAAM,GACJ,MAAM,CAUlB;AAED;;;;GAIG;AACH,wCAHW,MAAM,SAchB;AAED,kDAwBC;AAzEM,sEALI,MAAM,GAGJ,MAAM,CAOlB;AAEM;;;;;;;GAON"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Matrix4 } from 'math.gl';
|
|
2
|
+
import { viv } from '@vitessce/gl';
|
|
3
|
+
async function getSingleSelectionStats2D({ loader, selection }) {
|
|
4
|
+
const data = Array.isArray(loader) ? loader[loader.length - 1] : loader;
|
|
5
|
+
const raster = await data.getRaster({ selection });
|
|
6
|
+
const selectionStats = viv.getChannelStats(raster.data);
|
|
7
|
+
const { domain, contrastLimits: slider } = selectionStats;
|
|
8
|
+
return { domain, slider };
|
|
9
|
+
}
|
|
10
|
+
async function getSingleSelectionStats3D({ loader, selection }) {
|
|
11
|
+
const lowResSource = loader[loader.length - 1];
|
|
12
|
+
const { shape, labels } = lowResSource;
|
|
13
|
+
// eslint-disable-next-line no-bitwise
|
|
14
|
+
const sizeZ = shape[labels.indexOf('z')] >> (loader.length - 1);
|
|
15
|
+
const raster0 = await lowResSource.getRaster({
|
|
16
|
+
selection: { ...selection, z: 0 },
|
|
17
|
+
});
|
|
18
|
+
const rasterMid = await lowResSource.getRaster({
|
|
19
|
+
selection: { ...selection, z: Math.floor(sizeZ / 2) },
|
|
20
|
+
});
|
|
21
|
+
const rasterTop = await lowResSource.getRaster({
|
|
22
|
+
selection: { ...selection, z: Math.max(0, sizeZ - 1) },
|
|
23
|
+
});
|
|
24
|
+
const stats0 = viv.getChannelStats(raster0.data);
|
|
25
|
+
const statsMid = viv.getChannelStats(rasterMid.data);
|
|
26
|
+
const statsTop = viv.getChannelStats(rasterTop.data);
|
|
27
|
+
return {
|
|
28
|
+
domain: [
|
|
29
|
+
Math.min(stats0.domain[0], statsMid.domain[0], statsTop.domain[0]),
|
|
30
|
+
Math.max(stats0.domain[1], statsMid.domain[1], statsTop.domain[1]),
|
|
31
|
+
],
|
|
32
|
+
slider: [
|
|
33
|
+
Math.min(stats0.contrastLimits[0], statsMid.contrastLimits[0], statsTop.contrastLimits[0]),
|
|
34
|
+
Math.max(stats0.contrastLimits[1], statsMid.contrastLimits[1], statsTop.contrastLimits[1]),
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get bounding cube for a given loader i.e [[0, width], [0, height], [0, depth]]
|
|
40
|
+
* @param {Object} loader PixelSource|PixelSource[]
|
|
41
|
+
* @param {[]} selection Selection for stats.
|
|
42
|
+
* @param {boolean} use3d Whether or not to get 3d stats.
|
|
43
|
+
* @returns {Object} { domains, sliders }
|
|
44
|
+
*/
|
|
45
|
+
export const getSingleSelectionStats = async ({ loader, selection, use3d }) => {
|
|
46
|
+
const getStats = use3d
|
|
47
|
+
? getSingleSelectionStats3D
|
|
48
|
+
: getSingleSelectionStats2D;
|
|
49
|
+
return getStats({ loader, selection });
|
|
50
|
+
};
|
|
51
|
+
export const getMultiSelectionStats = async ({ loader, selections, use3d }) => {
|
|
52
|
+
const stats = await Promise.all(selections.map(selection => getSingleSelectionStats({ loader, selection, use3d })));
|
|
53
|
+
const domains = stats.map(stat => stat.domain);
|
|
54
|
+
const sliders = stats.map(stat => stat.slider);
|
|
55
|
+
return { domains, sliders };
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Get physical size scaling Matrix4
|
|
59
|
+
* @param {Object} loader PixelSource
|
|
60
|
+
* @returns {Object} matrix
|
|
61
|
+
*/
|
|
62
|
+
export function getPhysicalSizeScalingMatrix(loader) {
|
|
63
|
+
const { x, y, z } = loader?.meta?.physicalSizes ?? {};
|
|
64
|
+
if (x?.size && y?.size && z?.size) {
|
|
65
|
+
const min = Math.min(z.size, x.size, y.size);
|
|
66
|
+
const ratio = [x.size / min, y.size / min, z.size / min];
|
|
67
|
+
return new Matrix4().scale(ratio);
|
|
68
|
+
}
|
|
69
|
+
return new Matrix4().identity();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get bounding cube for a given loader
|
|
73
|
+
* @param {Object} loader PixelSource|PixelSource[]
|
|
74
|
+
* @returns {Array} [0, width], [0, height], [0, depth]]
|
|
75
|
+
*/
|
|
76
|
+
export function getBoundingCube(loader) {
|
|
77
|
+
const source = Array.isArray(loader) ? loader[0] : loader;
|
|
78
|
+
const { shape, labels } = source;
|
|
79
|
+
const physicalSizeScalingMatrix = getPhysicalSizeScalingMatrix(source);
|
|
80
|
+
const xSlice = [0, physicalSizeScalingMatrix[0] * shape[labels.indexOf('x')]];
|
|
81
|
+
const ySlice = [0, physicalSizeScalingMatrix[5] * shape[labels.indexOf('y')]];
|
|
82
|
+
const zSlice = [
|
|
83
|
+
0,
|
|
84
|
+
physicalSizeScalingMatrix[10] * shape[labels.indexOf('z')],
|
|
85
|
+
];
|
|
86
|
+
return [xSlice, ySlice, zSlice];
|
|
87
|
+
}
|
|
88
|
+
export function abbreviateNumber(value) {
|
|
89
|
+
// Return an abbreviated representation of value, in 5 characters or less.
|
|
90
|
+
const maxLength = 5;
|
|
91
|
+
let maxNaiveDigits = maxLength;
|
|
92
|
+
/* eslint-disable no-plusplus */
|
|
93
|
+
if (!Number.isInteger(value)) {
|
|
94
|
+
--maxNaiveDigits;
|
|
95
|
+
} // Wasted on "."
|
|
96
|
+
if (value < 1) {
|
|
97
|
+
--maxNaiveDigits;
|
|
98
|
+
} // Wasted on "0."
|
|
99
|
+
/* eslint-disable no-plusplus */
|
|
100
|
+
const naive = Intl.NumberFormat('en-US', {
|
|
101
|
+
maximumSignificantDigits: maxNaiveDigits,
|
|
102
|
+
useGrouping: false,
|
|
103
|
+
}).format(value);
|
|
104
|
+
if (naive.length <= maxLength)
|
|
105
|
+
return naive;
|
|
106
|
+
// "e+9" consumes 3 characters, so if we even had two significant digits,
|
|
107
|
+
// it would take take us to six characters, including the decimal point.
|
|
108
|
+
return value.toExponential(0);
|
|
109
|
+
}
|