@loaders.gl/compression 4.2.0-alpha.4 → 4.2.0-alpha.5
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/brotli/decode.js +2311 -1739
- package/dist/compress-on-worker.js +15 -7
- package/dist/dist.dev.js +576 -198
- package/dist/dist.min.js +16 -0
- package/dist/index.cjs +36 -119
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +12 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/lib/brotli-compression.d.ts +2 -2
- package/dist/lib/brotli-compression.d.ts.map +1 -1
- package/dist/lib/brotli-compression.js +69 -67
- package/dist/lib/compression.js +50 -43
- package/dist/lib/deflate-compression.d.ts +2 -2
- package/dist/lib/deflate-compression.d.ts.map +1 -1
- package/dist/lib/deflate-compression.js +118 -107
- package/dist/lib/gzip-compression.d.ts +2 -2
- package/dist/lib/gzip-compression.d.ts.map +1 -1
- package/dist/lib/gzip-compression.js +10 -14
- package/dist/lib/lz4-compression.d.ts +2 -2
- package/dist/lib/lz4-compression.d.ts.map +1 -1
- package/dist/lib/lz4-compression.js +125 -75
- package/dist/lib/lzo-compression.d.ts +2 -2
- package/dist/lib/lzo-compression.d.ts.map +1 -1
- package/dist/lib/lzo-compression.js +47 -28
- package/dist/lib/no-compression.d.ts +2 -2
- package/dist/lib/no-compression.d.ts.map +1 -1
- package/dist/lib/no-compression.js +23 -22
- package/dist/lib/snappy-compression.d.ts +2 -2
- package/dist/lib/snappy-compression.d.ts.map +1 -1
- package/dist/lib/snappy-compression.js +20 -17
- package/dist/lib/zstd-compression.d.ts +2 -2
- package/dist/lib/zstd-compression.d.ts.map +1 -1
- package/dist/lib/zstd-compression.js +36 -28
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/workers/compression-worker-node.d.ts +1 -1
- package/dist/workers/compression-worker-node.d.ts.map +1 -1
- package/dist/workers/compression-worker-node.js +0 -1
- package/dist/workers/compression-worker.js +56 -44
- package/package.json +10 -7
- package/dist/brotli/decode.js.map +0 -1
- package/dist/compress-on-worker.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/brotli-compression.js.map +0 -1
- package/dist/lib/compression.js.map +0 -1
- package/dist/lib/deflate-compression.js.map +0 -1
- package/dist/lib/gzip-compression.js.map +0 -1
- package/dist/lib/lz4-compression.js.map +0 -1
- package/dist/lib/lzo-compression.js.map +0 -1
- package/dist/lib/no-compression.js.map +0 -1
- package/dist/lib/snappy-compression.js.map +0 -1
- package/dist/lib/zstd-compression.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/workers/compression-worker-node.js.map +0 -1
- package/dist/workers/compression-worker.js.map +0 -1
|
@@ -1,87 +1,137 @@
|
|
|
1
|
+
// Copyright (c) 2012 Pierre Curto
|
|
2
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
4
|
+
// in the Software without restriction, including without limitation the rights
|
|
5
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
6
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
// furnished to do so, subject to the following conditions:
|
|
8
|
+
// The above copyright notice and this permission notice shall be included in
|
|
9
|
+
// all copies or substantial portions of the Software.
|
|
10
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
16
|
+
// THE SOFTWARE.
|
|
17
|
+
/* eslint-disable complexity */
|
|
18
|
+
/* eslint-disable max-statements */
|
|
19
|
+
// LZ4
|
|
1
20
|
import { toArrayBuffer } from '@loaders.gl/loader-utils';
|
|
2
21
|
import { Compression } from "./compression.js";
|
|
22
|
+
// import lz4js from 'lz4js'; // https://bundlephobia.com/package/lz4
|
|
3
23
|
const LZ4_MAGIC_NUMBER = 0x184d2204;
|
|
4
24
|
let lz4js;
|
|
25
|
+
/**
|
|
26
|
+
* LZ4 compression / decompression
|
|
27
|
+
*/
|
|
5
28
|
export class LZ4Compression extends Compression {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
throw new Error(this.name);
|
|
29
|
+
constructor(options) {
|
|
30
|
+
super(options);
|
|
31
|
+
this.name = 'lz4';
|
|
32
|
+
this.extensions = ['lz4'];
|
|
33
|
+
this.contentEncodings = ['x-lz4'];
|
|
34
|
+
this.isSupported = true;
|
|
35
|
+
this.options = options;
|
|
36
|
+
lz4js = lz4js || this.options?.modules?.lz4js;
|
|
37
|
+
if (!lz4js) {
|
|
38
|
+
throw new Error(this.name);
|
|
39
|
+
}
|
|
18
40
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return lz4js.compress(inputArray).buffer;
|
|
23
|
-
}
|
|
24
|
-
decompressSync(data, maxSize) {
|
|
25
|
-
try {
|
|
26
|
-
const isMagicNumberExists = this.checkMagicNumber(data);
|
|
27
|
-
const inputArray = new Uint8Array(data);
|
|
28
|
-
if (isMagicNumberExists) {
|
|
29
|
-
return lz4js.decompress(inputArray, maxSize).buffer;
|
|
30
|
-
}
|
|
31
|
-
if (!maxSize) {
|
|
32
|
-
const error = new Error('Need to provide maxSize');
|
|
33
|
-
throw this.improveError(error);
|
|
34
|
-
}
|
|
35
|
-
let uncompressed = new Uint8Array(maxSize);
|
|
36
|
-
const uncompressedSize = this.decodeBlock(inputArray, uncompressed);
|
|
37
|
-
uncompressed = uncompressed.slice(0, uncompressedSize);
|
|
38
|
-
return toArrayBuffer(uncompressed);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
throw this.improveError(error);
|
|
41
|
+
compressSync(input) {
|
|
42
|
+
const inputArray = new Uint8Array(input);
|
|
43
|
+
return lz4js.compress(inputArray).buffer;
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Decompresses an ArrayBuffer containing an Lz4 frame. maxSize is optional; if not
|
|
47
|
+
* provided, a maximum size will be determined by examining the data. The
|
|
48
|
+
* returned ArrayBuffer will always be perfectly sized.
|
|
49
|
+
* If data provided without magic number we will parse it as block
|
|
50
|
+
*/
|
|
51
|
+
decompressSync(data, maxSize) {
|
|
52
|
+
try {
|
|
53
|
+
const isMagicNumberExists = this.checkMagicNumber(data);
|
|
54
|
+
const inputArray = new Uint8Array(data);
|
|
55
|
+
if (isMagicNumberExists) {
|
|
56
|
+
return lz4js.decompress(inputArray, maxSize).buffer;
|
|
57
|
+
}
|
|
58
|
+
if (!maxSize) {
|
|
59
|
+
const error = new Error('Need to provide maxSize');
|
|
60
|
+
throw this.improveError(error);
|
|
61
|
+
}
|
|
62
|
+
let uncompressed = new Uint8Array(maxSize);
|
|
63
|
+
const uncompressedSize = this.decodeBlock(inputArray, uncompressed);
|
|
64
|
+
uncompressed = uncompressed.slice(0, uncompressedSize);
|
|
65
|
+
return toArrayBuffer(uncompressed);
|
|
55
66
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
output[uncompressedSize++] = data[index++];
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw this.improveError(error);
|
|
59
69
|
}
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Decode lz4 file as block
|
|
73
|
+
* Solution taken from here
|
|
74
|
+
* https://github.com/pierrec/node-lz4/blob/0dac687262403fd34f905b963da7220692f2a4a1/lib/binding.js#L25
|
|
75
|
+
* @param input
|
|
76
|
+
* @param output
|
|
77
|
+
* @param startIndex
|
|
78
|
+
* @param endIndex
|
|
79
|
+
*/
|
|
80
|
+
decodeBlock(data, output, startIndex, endIndex) {
|
|
81
|
+
startIndex = startIndex || 0;
|
|
82
|
+
endIndex = endIndex || data.length - startIndex;
|
|
83
|
+
let uncompressedSize = 0;
|
|
84
|
+
// Process each sequence in the incoming data
|
|
85
|
+
for (let index = startIndex; index < endIndex;) {
|
|
86
|
+
const token = data[index++];
|
|
87
|
+
// Literals
|
|
88
|
+
let literalsLength = token >> 4;
|
|
89
|
+
if (literalsLength > 0) {
|
|
90
|
+
// length of literals
|
|
91
|
+
let length = literalsLength + 240;
|
|
92
|
+
while (length === 255) {
|
|
93
|
+
length = data[index++];
|
|
94
|
+
literalsLength += length;
|
|
95
|
+
}
|
|
96
|
+
// Copy the literals
|
|
97
|
+
const end = index + literalsLength;
|
|
98
|
+
while (index < end) {
|
|
99
|
+
output[uncompressedSize++] = data[index++];
|
|
100
|
+
}
|
|
101
|
+
// End of buffer?
|
|
102
|
+
if (index === endIndex) {
|
|
103
|
+
return uncompressedSize;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Match copy
|
|
107
|
+
// 2 bytes offset (little endian)
|
|
108
|
+
const offset = data[index++] | (data[index++] << 8);
|
|
109
|
+
// 0 is an invalid offset value
|
|
110
|
+
if (offset === 0 || offset > uncompressedSize) {
|
|
111
|
+
return -(index - 2);
|
|
112
|
+
}
|
|
113
|
+
// length of match copy
|
|
114
|
+
let matchLength = token & 0xf;
|
|
115
|
+
let length = matchLength + 240;
|
|
116
|
+
while (length === 255) {
|
|
117
|
+
length = data[index++];
|
|
118
|
+
matchLength += length;
|
|
119
|
+
}
|
|
120
|
+
// Copy the match
|
|
121
|
+
let pos = uncompressedSize - offset; // position of the match copy in the current output
|
|
122
|
+
const end = uncompressedSize + matchLength + 4; // minmatch = 4
|
|
123
|
+
while (uncompressedSize < end) {
|
|
124
|
+
output[uncompressedSize++] = output[pos++];
|
|
125
|
+
}
|
|
62
126
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
matchLength += length;
|
|
73
|
-
}
|
|
74
|
-
let pos = uncompressedSize - offset;
|
|
75
|
-
const end = uncompressedSize + matchLength + 4;
|
|
76
|
-
while (uncompressedSize < end) {
|
|
77
|
-
output[uncompressedSize++] = output[pos++];
|
|
78
|
-
}
|
|
127
|
+
return uncompressedSize;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Compare file magic with lz4 magic number
|
|
131
|
+
* @param input
|
|
132
|
+
*/
|
|
133
|
+
checkMagicNumber(data) {
|
|
134
|
+
const magic = new Uint32Array(data.slice(0, 4));
|
|
135
|
+
return magic[0] === LZ4_MAGIC_NUMBER;
|
|
79
136
|
}
|
|
80
|
-
return uncompressedSize;
|
|
81
|
-
}
|
|
82
|
-
checkMagicNumber(data) {
|
|
83
|
-
const magic = new Uint32Array(data.slice(0, 4));
|
|
84
|
-
return magic[0] === LZ4_MAGIC_NUMBER;
|
|
85
|
-
}
|
|
86
137
|
}
|
|
87
|
-
//# sourceMappingURL=lz4-compression.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CompressionOptions } from
|
|
2
|
-
import { Compression } from
|
|
1
|
+
import type { CompressionOptions } from "./compression.js";
|
|
2
|
+
import { Compression } from "./compression.js";
|
|
3
3
|
/**
|
|
4
4
|
* Lempel-Ziv-Oberheimer compression / decompression
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lzo-compression.d.ts","sourceRoot":"","sources":["../../src/lib/lzo-compression.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,kBAAkB,EAAC,
|
|
1
|
+
{"version":3,"file":"lzo-compression.d.ts","sourceRoot":"","sources":["../../src/lib/lzo-compression.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,kBAAkB,EAAC,yBAAsB;AACtD,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAW1C;;GAEG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,CAAC,IAAI,SAAS;IACtB,QAAQ,CAAC,UAAU,UAAM;IACzB,QAAQ,CAAC,gBAAgB,UAAM;IAC/B,QAAQ,CAAC,WAAW,SAAS;IAC7B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAErC;;;OAGG;gBACS,OAAO,EAAE,kBAAkB;IAUjC,OAAO;IAKP,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAOlD,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAY3D"}
|
|
@@ -1,35 +1,54 @@
|
|
|
1
|
+
// LZO
|
|
2
|
+
// import {loadLibrary} from '@loaders.gl/worker-utils';
|
|
1
3
|
import { toBuffer } from '@loaders.gl/loader-utils';
|
|
2
4
|
import { Compression } from "./compression.js";
|
|
5
|
+
// import {isBrowser} from '@loaders.gl/loader-utils';
|
|
6
|
+
// import lzo from 'lzo'; // https://bundlephobia.com/package/lzo
|
|
7
|
+
// import {decompress} from 'lzo-wasm';
|
|
8
|
+
// const LZO_WASM_JS_URL = './node_modules/lzo-wasm/lzo-wasm.js';
|
|
9
|
+
// const LZO_WASM_WASM_URL = './node_modules/lzo-wasm/lzo-wasm.wasm';
|
|
3
10
|
let lzo;
|
|
11
|
+
/**
|
|
12
|
+
* Lempel-Ziv-Oberheimer compression / decompression
|
|
13
|
+
*/
|
|
4
14
|
export class LZOCompression extends Compression {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* lzo is an injectable dependency due to big size
|
|
17
|
+
* @param options
|
|
18
|
+
*/
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super(options);
|
|
21
|
+
this.name = 'lzo';
|
|
22
|
+
this.extensions = [];
|
|
23
|
+
this.contentEncodings = [];
|
|
24
|
+
this.isSupported = false; // !isBrowser;
|
|
25
|
+
this.options = options;
|
|
26
|
+
lzo = lzo || this.options?.modules?.lzo;
|
|
27
|
+
if (!lzo) {
|
|
28
|
+
throw new Error(this.name);
|
|
29
|
+
}
|
|
17
30
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
async preload() {
|
|
32
|
+
// await loadLibrary(LZO_WASM_JS_URL);
|
|
33
|
+
// await loadLibrary(LZO_WASM_WASM_URL);
|
|
34
|
+
}
|
|
35
|
+
async compress(input) {
|
|
36
|
+
await this.preload();
|
|
37
|
+
// const inputArray = new Uint8Array(input);
|
|
38
|
+
const inputBuffer = toBuffer(input);
|
|
39
|
+
return lzo.compress(inputBuffer).buffer;
|
|
40
|
+
}
|
|
41
|
+
async decompress(input) {
|
|
42
|
+
try {
|
|
43
|
+
await this.preload();
|
|
44
|
+
// const inputArray = new Uint8Array(input);
|
|
45
|
+
const inputBuffer = toBuffer(input);
|
|
46
|
+
return lzo.decompress(inputBuffer).buffer;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
// TODO - solve SharedArrayBuffer issues
|
|
50
|
+
// return decompress(input);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
32
53
|
}
|
|
33
|
-
}
|
|
34
54
|
}
|
|
35
|
-
//# sourceMappingURL=lzo-compression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-compression.d.ts","sourceRoot":"","sources":["../../src/lib/no-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,
|
|
1
|
+
{"version":3,"file":"no-compression.d.ts","sourceRoot":"","sources":["../../src/lib/no-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,yBAAsB;AACtD,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAE1C;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAkB;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAM;IACnC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAM;IACzC,QAAQ,CAAC,WAAW,QAAQ;IAE5B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAEzB,OAAO,CAAC,EAAE,kBAAkB;IAKxC,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;IAI7C,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;IAIxC,eAAe,CACpB,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,aAAa,CAAC,WAAW,CAAC;IAItB,iBAAiB,CACtB,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,aAAa,CAAC,WAAW,CAAC;CAG9B"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { Compression } from "./compression.js";
|
|
2
|
+
/**
|
|
3
|
+
* Applies no compression.
|
|
4
|
+
*/
|
|
2
5
|
export class NoCompression extends Compression {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options);
|
|
8
|
+
this.name = 'uncompressed';
|
|
9
|
+
this.extensions = [];
|
|
10
|
+
this.contentEncodings = [];
|
|
11
|
+
this.isSupported = true;
|
|
12
|
+
this.options = options || {};
|
|
13
|
+
}
|
|
14
|
+
compressSync(input) {
|
|
15
|
+
return input;
|
|
16
|
+
}
|
|
17
|
+
decompressSync(input) {
|
|
18
|
+
return input;
|
|
19
|
+
}
|
|
20
|
+
async *compressBatches(asyncIterator) {
|
|
21
|
+
return yield* asyncIterator;
|
|
22
|
+
}
|
|
23
|
+
async *decompressBatches(asyncIterator) {
|
|
24
|
+
return yield* asyncIterator;
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
|
-
//# sourceMappingURL=no-compression.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CompressionOptions } from
|
|
2
|
-
import { Compression } from
|
|
1
|
+
import type { CompressionOptions } from "./compression.js";
|
|
2
|
+
import { Compression } from "./compression.js";
|
|
3
3
|
/**
|
|
4
4
|
* Snappy/zippy compression / decompression
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snappy-compression.d.ts","sourceRoot":"","sources":["../../src/lib/snappy-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,
|
|
1
|
+
{"version":3,"file":"snappy-compression.d.ts","sourceRoot":"","sources":["../../src/lib/snappy-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,yBAAsB;AACtD,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAG1C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAY;IACjC,QAAQ,CAAC,UAAU,UAAM;IACzB,QAAQ,CAAC,gBAAgB,UAAM;IAC/B,QAAQ,CAAC,WAAW,QAAQ;IAC5B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAEzB,OAAO,CAAC,EAAE,kBAAkB;IAKxC,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;IAK7C,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;CAIhD"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { Compression } from "./compression.js";
|
|
2
|
-
import { compress, uncompress } from 'snappyjs';
|
|
2
|
+
import { compress, uncompress } from 'snappyjs'; // https://bundlephobia.com/package/snappy
|
|
3
|
+
/**
|
|
4
|
+
* Snappy/zippy compression / decompression
|
|
5
|
+
*/
|
|
3
6
|
export class SnappyCompression extends Compression {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super(options);
|
|
9
|
+
this.name = 'snappy';
|
|
10
|
+
this.extensions = [];
|
|
11
|
+
this.contentEncodings = [];
|
|
12
|
+
this.isSupported = true;
|
|
13
|
+
this.options = options || {};
|
|
14
|
+
}
|
|
15
|
+
compressSync(input) {
|
|
16
|
+
// Accepts arrayBuffer - https://github.com/zhipeng-jia/snappyjs#usage
|
|
17
|
+
return compress(input);
|
|
18
|
+
}
|
|
19
|
+
decompressSync(input) {
|
|
20
|
+
// Accepts arrayBuffer - https://github.com/zhipeng-jia/snappyjs#usage
|
|
21
|
+
return uncompress(input);
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
|
-
//# sourceMappingURL=snappy-compression.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CompressionOptions } from
|
|
2
|
-
import { Compression } from
|
|
1
|
+
import type { CompressionOptions } from "./compression.js";
|
|
2
|
+
import { Compression } from "./compression.js";
|
|
3
3
|
/**
|
|
4
4
|
* Zstandard compression / decompression
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zstd-compression.d.ts","sourceRoot":"","sources":["../../src/lib/zstd-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,
|
|
1
|
+
{"version":3,"file":"zstd-compression.d.ts","sourceRoot":"","sources":["../../src/lib/zstd-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,yBAAsB;AACtD,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAM1C;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAU;IAC/B,QAAQ,CAAC,UAAU,UAAM;IACzB,QAAQ,CAAC,gBAAgB,UAAM;IAC/B,QAAQ,CAAC,WAAW,QAAQ;IAC5B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAErC;;;OAGG;gBACS,OAAO,EAAE,kBAAkB;IAWjC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;IAM7C,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;CAOhD"}
|
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
import { Compression } from "./compression.js";
|
|
2
|
+
// import {ZstdCodec} from 'zstd-codec'; // https://bundlephobia.com/package/zstd-codec
|
|
2
3
|
let ZstdCodec;
|
|
3
4
|
let zstd;
|
|
5
|
+
/**
|
|
6
|
+
* Zstandard compression / decompression
|
|
7
|
+
*/
|
|
4
8
|
export class ZstdCompression extends Compression {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
/**
|
|
10
|
+
* zstd-codec is an injectable dependency due to big size
|
|
11
|
+
* @param options
|
|
12
|
+
*/
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super(options);
|
|
15
|
+
this.name = 'zstd';
|
|
16
|
+
this.extensions = [];
|
|
17
|
+
this.contentEncodings = [];
|
|
18
|
+
this.isSupported = true;
|
|
19
|
+
this.options = options;
|
|
20
|
+
ZstdCodec = this.options?.modules?.['zstd-codec'];
|
|
21
|
+
if (!ZstdCodec) {
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.warn(`${this.name} library not installed`);
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
async preload() {
|
|
27
|
+
if (!zstd && ZstdCodec) {
|
|
28
|
+
zstd = await new Promise((resolve) => ZstdCodec.run((zstd) => resolve(zstd)));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
compressSync(input) {
|
|
32
|
+
const simpleZstd = new zstd.Simple();
|
|
33
|
+
const inputArray = new Uint8Array(input);
|
|
34
|
+
return simpleZstd.compress(inputArray).buffer;
|
|
35
|
+
}
|
|
36
|
+
decompressSync(input) {
|
|
37
|
+
const simpleZstd = new zstd.Simple();
|
|
38
|
+
// var ddict = new zstd.Dict.Decompression(dictData);
|
|
39
|
+
// var jsonBytes = simpleZstd.decompressUsingDict(jsonZstData, ddict);
|
|
40
|
+
const inputArray = new Uint8Array(input);
|
|
41
|
+
return simpleZstd.decompress(inputArray).buffer;
|
|
22
42
|
}
|
|
23
|
-
}
|
|
24
|
-
compressSync(input) {
|
|
25
|
-
const simpleZstd = new zstd.Simple();
|
|
26
|
-
const inputArray = new Uint8Array(input);
|
|
27
|
-
return simpleZstd.compress(inputArray).buffer;
|
|
28
|
-
}
|
|
29
|
-
decompressSync(input) {
|
|
30
|
-
const simpleZstd = new zstd.Simple();
|
|
31
|
-
const inputArray = new Uint8Array(input);
|
|
32
|
-
return simpleZstd.decompress(inputArray).buffer;
|
|
33
|
-
}
|
|
34
43
|
}
|
|
35
|
-
//# sourceMappingURL=zstd-compression.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { Compression, CompressionOptions } from
|
|
1
|
+
export type { Compression, CompressionOptions } from "./lib/compression.js";
|
|
2
2
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,WAAW,EAAE,kBAAkB,EAAC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,WAAW,EAAE,kBAAkB,EAAC,6BAA0B"}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./compression-worker.js";
|
|
2
2
|
//# sourceMappingURL=compression-worker-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compression-worker-node.d.ts","sourceRoot":"","sources":["../../src/workers/compression-worker-node.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"compression-worker-node.d.ts","sourceRoot":"","sources":["../../src/workers/compression-worker-node.ts"],"names":[],"mappings":"AAAA,iCAA8B"}
|