@vitessce/all 2.0.2 → 2.0.3

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.
@@ -0,0 +1,128 @@
1
+ import { B as BaseDecoder } from "./index.7dac8670.mjs";
2
+ import "react";
3
+ import "@vitessce/vit-s";
4
+ import "react-dom";
5
+ const MIN_BITS = 9;
6
+ const CLEAR_CODE = 256;
7
+ const EOI_CODE = 257;
8
+ const MAX_BYTELENGTH = 12;
9
+ function getByte(array, position, length) {
10
+ const d = position % 8;
11
+ const a = Math.floor(position / 8);
12
+ const de = 8 - d;
13
+ const ef = position + length - (a + 1) * 8;
14
+ let fg = 8 * (a + 2) - (position + length);
15
+ const dg = (a + 2) * 8 - position;
16
+ fg = Math.max(0, fg);
17
+ if (a >= array.length) {
18
+ console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)");
19
+ return EOI_CODE;
20
+ }
21
+ let chunk1 = array[a] & 2 ** (8 - d) - 1;
22
+ chunk1 <<= length - de;
23
+ let chunks = chunk1;
24
+ if (a + 1 < array.length) {
25
+ let chunk2 = array[a + 1] >>> fg;
26
+ chunk2 <<= Math.max(0, length - dg);
27
+ chunks += chunk2;
28
+ }
29
+ if (ef > 8 && a + 2 < array.length) {
30
+ const hi = (a + 3) * 8 - (position + length);
31
+ const chunk3 = array[a + 2] >>> hi;
32
+ chunks += chunk3;
33
+ }
34
+ return chunks;
35
+ }
36
+ function appendReversed(dest, source) {
37
+ for (let i = source.length - 1; i >= 0; i--) {
38
+ dest.push(source[i]);
39
+ }
40
+ return dest;
41
+ }
42
+ function decompress(input) {
43
+ const dictionaryIndex = new Uint16Array(4093);
44
+ const dictionaryChar = new Uint8Array(4093);
45
+ for (let i = 0; i <= 257; i++) {
46
+ dictionaryIndex[i] = 4096;
47
+ dictionaryChar[i] = i;
48
+ }
49
+ let dictionaryLength = 258;
50
+ let byteLength = MIN_BITS;
51
+ let position = 0;
52
+ function initDictionary() {
53
+ dictionaryLength = 258;
54
+ byteLength = MIN_BITS;
55
+ }
56
+ function getNext(array2) {
57
+ const byte = getByte(array2, position, byteLength);
58
+ position += byteLength;
59
+ return byte;
60
+ }
61
+ function addToDictionary(i, c) {
62
+ dictionaryChar[dictionaryLength] = c;
63
+ dictionaryIndex[dictionaryLength] = i;
64
+ dictionaryLength++;
65
+ return dictionaryLength - 1;
66
+ }
67
+ function getDictionaryReversed(n) {
68
+ const rev = [];
69
+ for (let i = n; i !== 4096; i = dictionaryIndex[i]) {
70
+ rev.push(dictionaryChar[i]);
71
+ }
72
+ return rev;
73
+ }
74
+ const result = [];
75
+ initDictionary();
76
+ const array = new Uint8Array(input);
77
+ let code = getNext(array);
78
+ let oldCode;
79
+ while (code !== EOI_CODE) {
80
+ if (code === CLEAR_CODE) {
81
+ initDictionary();
82
+ code = getNext(array);
83
+ while (code === CLEAR_CODE) {
84
+ code = getNext(array);
85
+ }
86
+ if (code === EOI_CODE) {
87
+ break;
88
+ } else if (code > CLEAR_CODE) {
89
+ throw new Error(`corrupted code at scanline ${code}`);
90
+ } else {
91
+ const val = getDictionaryReversed(code);
92
+ appendReversed(result, val);
93
+ oldCode = code;
94
+ }
95
+ } else if (code < dictionaryLength) {
96
+ const val = getDictionaryReversed(code);
97
+ appendReversed(result, val);
98
+ addToDictionary(oldCode, val[val.length - 1]);
99
+ oldCode = code;
100
+ } else {
101
+ const oldVal = getDictionaryReversed(oldCode);
102
+ if (!oldVal) {
103
+ throw new Error(`Bogus entry. Not in dictionary, ${oldCode} / ${dictionaryLength}, position: ${position}`);
104
+ }
105
+ appendReversed(result, oldVal);
106
+ result.push(oldVal[oldVal.length - 1]);
107
+ addToDictionary(oldCode, oldVal[oldVal.length - 1]);
108
+ oldCode = code;
109
+ }
110
+ if (dictionaryLength + 1 >= 2 ** byteLength) {
111
+ if (byteLength === MAX_BYTELENGTH) {
112
+ oldCode = void 0;
113
+ } else {
114
+ byteLength++;
115
+ }
116
+ }
117
+ code = getNext(array);
118
+ }
119
+ return new Uint8Array(result);
120
+ }
121
+ class LZWDecoder extends BaseDecoder {
122
+ decodeBlock(buffer) {
123
+ return decompress(buffer).buffer;
124
+ }
125
+ }
126
+ export {
127
+ LZWDecoder as default
128
+ };
@@ -0,0 +1,30 @@
1
+ import { B as BaseDecoder } from "./index.7dac8670.mjs";
2
+ import "react";
3
+ import "@vitessce/vit-s";
4
+ import "react-dom";
5
+ class PackbitsDecoder extends BaseDecoder {
6
+ decodeBlock(buffer) {
7
+ const dataView = new DataView(buffer);
8
+ const out = [];
9
+ for (let i = 0; i < buffer.byteLength; ++i) {
10
+ let header = dataView.getInt8(i);
11
+ if (header < 0) {
12
+ const next = dataView.getUint8(i + 1);
13
+ header = -header;
14
+ for (let j = 0; j <= header; ++j) {
15
+ out.push(next);
16
+ }
17
+ i += 1;
18
+ } else {
19
+ for (let j = 0; j <= header; ++j) {
20
+ out.push(dataView.getUint8(i + j + 1));
21
+ }
22
+ i += header + 1;
23
+ }
24
+ }
25
+ return new Uint8Array(out).buffer;
26
+ }
27
+ }
28
+ export {
29
+ PackbitsDecoder as default
30
+ };