@loaders.gl/compression 4.0.0-alpha.5 → 4.0.0-alpha.6
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 +2320 -2187
- package/dist/bundle.js +2 -2
- package/dist/compression-worker.d.ts +1 -1
- package/dist/compression-worker.d.ts.map +1 -1
- package/dist/compression-worker.js +2 -2
- package/dist/compression-worker.js.map +3 -3
- package/dist/dist.min.js +3 -3
- package/dist/dist.min.js.map +3 -3
- package/dist/es5/brotli/decode.js +1778 -0
- package/dist/es5/brotli/decode.js.map +1 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/compression-worker.js +23 -0
- package/dist/es5/compression-worker.js.map +1 -0
- package/dist/es5/index.js +82 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/brotli-compression.js +170 -0
- package/dist/es5/lib/brotli-compression.js.map +1 -0
- package/dist/es5/lib/compression.js +160 -0
- package/dist/es5/lib/compression.js.map +1 -0
- package/dist/es5/lib/deflate-compression.js +318 -0
- package/dist/es5/lib/deflate-compression.js.map +1 -0
- package/dist/es5/lib/gzip-compression.js +40 -0
- package/dist/es5/lib/gzip-compression.js.map +1 -0
- package/dist/es5/lib/lz4-compression.js +119 -0
- package/dist/es5/lib/lz4-compression.js.map +1 -0
- package/dist/es5/lib/lzo-compression.js +116 -0
- package/dist/es5/lib/lzo-compression.js.map +1 -0
- package/dist/es5/lib/no-compression.js +87 -0
- package/dist/es5/lib/no-compression.js.map +1 -0
- package/dist/es5/lib/snappy-compression.js +48 -0
- package/dist/es5/lib/snappy-compression.js.map +1 -0
- package/dist/es5/lib/zstd-compression.js +90 -0
- package/dist/es5/lib/zstd-compression.js.map +1 -0
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/workers/worker.js +91 -0
- package/dist/es5/workers/worker.js.map +1 -0
- package/dist/esm/brotli/decode.js +1771 -0
- package/dist/esm/brotli/decode.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/compression-worker.js +14 -0
- package/dist/esm/compression-worker.js.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/brotli-compression.js +84 -0
- package/dist/esm/lib/brotli-compression.js.map +1 -0
- package/dist/esm/lib/compression.js +47 -0
- package/dist/esm/lib/compression.js.map +1 -0
- package/dist/esm/lib/deflate-compression.js +118 -0
- package/dist/esm/lib/deflate-compression.js.map +1 -0
- package/dist/esm/lib/gzip-compression.js +18 -0
- package/dist/esm/lib/gzip-compression.js.map +1 -0
- package/dist/esm/lib/lz4-compression.js +88 -0
- package/dist/esm/lib/lz4-compression.js.map +1 -0
- package/dist/esm/lib/lzo-compression.js +36 -0
- package/dist/esm/lib/lzo-compression.js.map +1 -0
- package/dist/esm/lib/no-compression.js +26 -0
- package/dist/esm/lib/no-compression.js.map +1 -0
- package/dist/esm/lib/snappy-compression.js +21 -0
- package/dist/esm/lib/snappy-compression.js.map +1 -0
- package/dist/esm/lib/zstd-compression.js +36 -0
- package/dist/esm/lib/zstd-compression.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/workers/worker.js +60 -0
- package/dist/esm/workers/worker.js.map +1 -0
- package/dist/index.js +24 -11
- package/dist/lib/brotli-compression.d.ts +1 -1
- package/dist/lib/brotli-compression.d.ts.map +1 -1
- package/dist/lib/brotli-compression.js +82 -98
- package/dist/lib/compression.d.ts +1 -1
- package/dist/lib/compression.d.ts.map +1 -1
- package/dist/lib/compression.js +56 -61
- package/dist/lib/deflate-compression.d.ts +1 -1
- package/dist/lib/deflate-compression.d.ts.map +1 -1
- package/dist/lib/deflate-compression.js +128 -150
- package/dist/lib/gzip-compression.d.ts +1 -1
- package/dist/lib/gzip-compression.d.ts.map +1 -1
- package/dist/lib/gzip-compression.js +16 -20
- package/dist/lib/lz4-compression.js +132 -108
- package/dist/lib/lzo-compression.js +54 -44
- package/dist/lib/no-compression.js +29 -36
- package/dist/lib/snappy-compression.js +26 -29
- package/dist/lib/zstd-compression.js +42 -43
- package/dist/types.js +2 -2
- package/dist/workers/worker.js +70 -61
- package/package.json +7 -9
- package/src/lib/brotli-compression.ts +3 -3
- package/src/lib/deflate-compression.ts +5 -5
- package/dist/brotli/decode.js.map +0 -1
- package/dist/bundle.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/worker.js.map +0 -1
|
@@ -1,48 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LZOCompression = void 0;
|
|
4
|
+
// LZO
|
|
5
|
+
// import {loadLibrary} from '@loaders.gl/worker-utils';
|
|
6
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
7
|
+
const compression_1 = require("./compression");
|
|
8
|
+
// import {isBrowser} from '@loaders.gl/loader-utils';
|
|
9
|
+
// import lzo from 'lzo'; // https://bundlephobia.com/package/lzo
|
|
10
|
+
// import {decompress} from 'lzo-wasm';
|
|
11
|
+
// const LZO_WASM_JS_URL = './node_modules/lzo-wasm/lzo-wasm.js';
|
|
12
|
+
// const LZO_WASM_WASM_URL = './node_modules/lzo-wasm/lzo-wasm.wasm';
|
|
4
13
|
let lzo;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (!lzo) {
|
|
25
|
-
throw new Error(this.name);
|
|
14
|
+
/**
|
|
15
|
+
* Lempel-Ziv-Oberheimer compression / decompression
|
|
16
|
+
*/
|
|
17
|
+
class LZOCompression extends compression_1.Compression {
|
|
18
|
+
/**
|
|
19
|
+
* lzo is an injectable dependency due to big size
|
|
20
|
+
* @param options
|
|
21
|
+
*/
|
|
22
|
+
constructor(options) {
|
|
23
|
+
super(options);
|
|
24
|
+
this.name = 'lzo';
|
|
25
|
+
this.extensions = [];
|
|
26
|
+
this.contentEncodings = [];
|
|
27
|
+
this.isSupported = false; // !isBrowser;
|
|
28
|
+
this.options = options;
|
|
29
|
+
lzo = lzo || this.options?.modules?.lzo;
|
|
30
|
+
if (!lzo) {
|
|
31
|
+
throw new Error(this.name);
|
|
32
|
+
}
|
|
26
33
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
async preload() {
|
|
35
|
+
// await loadLibrary(LZO_WASM_JS_URL);
|
|
36
|
+
// await loadLibrary(LZO_WASM_WASM_URL);
|
|
37
|
+
}
|
|
38
|
+
async compress(input) {
|
|
39
|
+
await this.preload();
|
|
40
|
+
// const inputArray = new Uint8Array(input);
|
|
41
|
+
const inputBuffer = (0, loader_utils_1.toBuffer)(input);
|
|
42
|
+
return lzo.compress(inputBuffer).buffer;
|
|
43
|
+
}
|
|
44
|
+
async decompress(input) {
|
|
45
|
+
try {
|
|
46
|
+
await this.preload();
|
|
47
|
+
// const inputArray = new Uint8Array(input);
|
|
48
|
+
const inputBuffer = (0, loader_utils_1.toBuffer)(input);
|
|
49
|
+
return lzo.decompress(inputBuffer).buffer;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
// TODO - solve SharedArrayBuffer issues
|
|
53
|
+
// return decompress(input);
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
44
56
|
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
57
|
}
|
|
48
|
-
|
|
58
|
+
exports.LZOCompression = LZOCompression;
|
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return yield* asyncIterator;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async *decompressBatches(asyncIterator) {
|
|
33
|
-
return yield* asyncIterator;
|
|
34
|
-
}
|
|
35
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoCompression = void 0;
|
|
4
|
+
const compression_1 = require("./compression");
|
|
5
|
+
/**
|
|
6
|
+
* Applies no compression.
|
|
7
|
+
*/
|
|
8
|
+
class NoCompression extends compression_1.Compression {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super(options);
|
|
11
|
+
this.name = 'uncompressed';
|
|
12
|
+
this.extensions = [];
|
|
13
|
+
this.contentEncodings = [];
|
|
14
|
+
this.isSupported = true;
|
|
15
|
+
this.options = options || {};
|
|
16
|
+
}
|
|
17
|
+
compressSync(input) {
|
|
18
|
+
return input;
|
|
19
|
+
}
|
|
20
|
+
decompressSync(input) {
|
|
21
|
+
return input;
|
|
22
|
+
}
|
|
23
|
+
async *compressBatches(asyncIterator) {
|
|
24
|
+
return yield* asyncIterator;
|
|
25
|
+
}
|
|
26
|
+
async *decompressBatches(asyncIterator) {
|
|
27
|
+
return yield* asyncIterator;
|
|
28
|
+
}
|
|
36
29
|
}
|
|
37
|
-
|
|
30
|
+
exports.NoCompression = NoCompression;
|
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return uncompress(input);
|
|
27
|
-
}
|
|
28
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnappyCompression = void 0;
|
|
4
|
+
const compression_1 = require("./compression");
|
|
5
|
+
const snappyjs_1 = require("snappyjs"); // https://bundlephobia.com/package/snappy
|
|
6
|
+
/**
|
|
7
|
+
* Snappy/zippy compression / decompression
|
|
8
|
+
*/
|
|
9
|
+
class SnappyCompression extends compression_1.Compression {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super(options);
|
|
12
|
+
this.name = 'snappy';
|
|
13
|
+
this.extensions = [];
|
|
14
|
+
this.contentEncodings = [];
|
|
15
|
+
this.isSupported = true;
|
|
16
|
+
this.options = options || {};
|
|
17
|
+
}
|
|
18
|
+
compressSync(input) {
|
|
19
|
+
// Accepts arrayBuffer - https://github.com/zhipeng-jia/snappyjs#usage
|
|
20
|
+
return (0, snappyjs_1.compress)(input);
|
|
21
|
+
}
|
|
22
|
+
decompressSync(input) {
|
|
23
|
+
// Accepts arrayBuffer - https://github.com/zhipeng-jia/snappyjs#usage
|
|
24
|
+
return (0, snappyjs_1.uncompress)(input);
|
|
25
|
+
}
|
|
29
26
|
}
|
|
30
|
-
|
|
27
|
+
exports.SnappyCompression = SnappyCompression;
|
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZstdCompression = void 0;
|
|
4
|
+
const compression_1 = require("./compression");
|
|
5
|
+
// import {ZstdCodec} from 'zstd-codec'; // https://bundlephobia.com/package/zstd-codec
|
|
3
6
|
let ZstdCodec;
|
|
4
7
|
let zstd;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
console.warn("".concat(this.name, " library not installed"));
|
|
8
|
+
/**
|
|
9
|
+
* Zstandard compression / decompression
|
|
10
|
+
*/
|
|
11
|
+
class ZstdCompression extends compression_1.Compression {
|
|
12
|
+
/**
|
|
13
|
+
* zstd-codec is an injectable dependency due to big size
|
|
14
|
+
* @param options
|
|
15
|
+
*/
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(options);
|
|
18
|
+
this.name = 'zstd';
|
|
19
|
+
this.extensions = [];
|
|
20
|
+
this.contentEncodings = [];
|
|
21
|
+
this.isSupported = true;
|
|
22
|
+
this.options = options;
|
|
23
|
+
ZstdCodec = this.options?.modules?.['zstd-codec'];
|
|
24
|
+
if (!ZstdCodec) {
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.warn(`${this.name} library not installed`);
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
async preload() {
|
|
30
|
+
if (!zstd && ZstdCodec) {
|
|
31
|
+
zstd = await new Promise((resolve) => ZstdCodec.run((zstd) => resolve(zstd)));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
compressSync(input) {
|
|
35
|
+
const simpleZstd = new zstd.Simple();
|
|
36
|
+
const inputArray = new Uint8Array(input);
|
|
37
|
+
return simpleZstd.compress(inputArray).buffer;
|
|
38
|
+
}
|
|
39
|
+
decompressSync(input) {
|
|
40
|
+
const simpleZstd = new zstd.Simple();
|
|
41
|
+
// var ddict = new zstd.Dict.Decompression(dictData);
|
|
42
|
+
// var jsonBytes = simpleZstd.decompressUsingDict(jsonZstData, ddict);
|
|
43
|
+
const inputArray = new Uint8Array(input);
|
|
44
|
+
return simpleZstd.decompress(inputArray).buffer;
|
|
32
45
|
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
compressSync(input) {
|
|
36
|
-
const simpleZstd = new zstd.Simple();
|
|
37
|
-
const inputArray = new Uint8Array(input);
|
|
38
|
-
return simpleZstd.compress(inputArray).buffer;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
decompressSync(input) {
|
|
42
|
-
const simpleZstd = new zstd.Simple();
|
|
43
|
-
const inputArray = new Uint8Array(input);
|
|
44
|
-
return simpleZstd.decompress(inputArray).buffer;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
46
|
}
|
|
48
|
-
|
|
47
|
+
exports.ZstdCompression = ZstdCompression;
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/workers/worker.js
CHANGED
|
@@ -1,68 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
7
|
+
// Compressors
|
|
8
|
+
const no_compression_1 = require("../lib/no-compression");
|
|
9
|
+
const brotli_compression_1 = require("../lib/brotli-compression");
|
|
10
|
+
const deflate_compression_1 = require("../lib/deflate-compression");
|
|
11
|
+
const gzip_compression_1 = require("../lib/gzip-compression");
|
|
12
|
+
const lz4_compression_1 = require("../lib/lz4-compression");
|
|
13
|
+
// import {LZOCompression} from '../lib/lzo-compression.js';
|
|
14
|
+
const snappy_compression_1 = require("../lib/snappy-compression");
|
|
15
|
+
const zstd_compression_1 = require("../lib/zstd-compression");
|
|
16
|
+
// Import big dependencies
|
|
17
|
+
// import brotli from 'brotli'; - brotli has problems with decompress in browsers
|
|
18
|
+
// import brotliDecompress from 'brotli/decompress';
|
|
19
|
+
const lz4js_1 = __importDefault(require("lz4js"));
|
|
20
|
+
// import lzo from 'lzo';
|
|
21
|
+
// import {ZstdCodec} from 'zstd-codec';
|
|
22
|
+
// Inject large dependencies through Compression constructor options
|
|
10
23
|
const modules = {
|
|
11
|
-
|
|
24
|
+
// brotli has problems with decompress in browsers
|
|
25
|
+
// brotli: {
|
|
26
|
+
// decompress: brotliDecompress,
|
|
27
|
+
// compress: () => {
|
|
28
|
+
// throw new Error('brotli compress');
|
|
29
|
+
// }
|
|
30
|
+
// },
|
|
31
|
+
lz4js: lz4js_1.default
|
|
32
|
+
// lzo,
|
|
33
|
+
// 'zstd-codec': ZstdCodec
|
|
12
34
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
case 'decompress':
|
|
37
|
-
return await compression.decompress(data);
|
|
38
|
-
|
|
39
|
-
default:
|
|
40
|
-
throw new Error('invalid option');
|
|
41
|
-
}
|
|
35
|
+
/** @type {Compression[]} */
|
|
36
|
+
const COMPRESSIONS = [
|
|
37
|
+
new no_compression_1.NoCompression({ modules }),
|
|
38
|
+
new brotli_compression_1.BrotliCompression({ modules }),
|
|
39
|
+
new deflate_compression_1.DeflateCompression({ modules }),
|
|
40
|
+
new gzip_compression_1.GZipCompression({ modules }),
|
|
41
|
+
// new LZOCompression({modules}),
|
|
42
|
+
new lz4_compression_1.LZ4Compression({ modules }),
|
|
43
|
+
new snappy_compression_1.SnappyCompression({ modules }),
|
|
44
|
+
new zstd_compression_1.ZstdCompression({ modules })
|
|
45
|
+
];
|
|
46
|
+
(0, worker_utils_1.createWorker)(async (data, options = {}) => {
|
|
47
|
+
const operation = getOperation(String(options?.operation));
|
|
48
|
+
const compression = getCompression(String(options?.compression));
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
switch (operation) {
|
|
51
|
+
case 'compress':
|
|
52
|
+
return await compression.compress(data);
|
|
53
|
+
case 'decompress':
|
|
54
|
+
return await compression.decompress(data);
|
|
55
|
+
default:
|
|
56
|
+
throw new Error('invalid option');
|
|
57
|
+
}
|
|
42
58
|
});
|
|
43
|
-
|
|
44
59
|
function getOperation(operation) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
throw new Error("@loaders.gl/compression: Unsupported operation ".concat(operation, ". Expected 'compress' or 'decompress'"));
|
|
56
|
-
}
|
|
60
|
+
switch (operation) {
|
|
61
|
+
case 'compress':
|
|
62
|
+
case 'deflate':
|
|
63
|
+
return 'compress';
|
|
64
|
+
case 'decompress':
|
|
65
|
+
case 'inflate':
|
|
66
|
+
return 'decompress';
|
|
67
|
+
default:
|
|
68
|
+
throw new Error(`@loaders.gl/compression: Unsupported operation ${operation}. Expected 'compress' or 'decompress'`);
|
|
69
|
+
}
|
|
57
70
|
}
|
|
58
|
-
|
|
59
71
|
function getCompression(name) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return Compression;
|
|
72
|
+
const Compression = COMPRESSIONS.find((compression_) => name === compression_.name);
|
|
73
|
+
if (!Compression) {
|
|
74
|
+
throw new Error(`@loaders.gl/compression: Unsupported compression ${name}`);
|
|
75
|
+
}
|
|
76
|
+
return Compression;
|
|
67
77
|
}
|
|
68
|
-
//# sourceMappingURL=worker.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/compression",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.6",
|
|
4
4
|
"description": "Decompression and compression plugins for loaders.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"point cloud"
|
|
19
19
|
],
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
|
-
"main": "dist/index.js",
|
|
22
|
-
"module": "dist/index.js",
|
|
21
|
+
"main": "dist/es5/index.js",
|
|
22
|
+
"module": "dist/esm/index.js",
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"files": [
|
|
25
25
|
"src",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"pre-build": "npm run build-bundle && npm run build-worker",
|
|
36
36
|
"build-bundle": "esbuild src/bundle.ts --outfile=dist/dist.min.js --bundle --minify --sourcemap --external:{fs,path,crypto}",
|
|
37
|
-
"build-worker": "esbuild src/workers/worker.ts --outfile=dist/compression-worker.js --bundle --minify --sourcemap --external:{fs,path,crypto} --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
37
|
+
"build-worker": "esbuild src/workers/worker.ts --outfile=dist/compression-worker.js --target=esnext,node12 --bundle --minify --sourcemap --external:{fs,path,crypto} --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@babel/runtime": "^7.3.1",
|
|
41
|
-
"@loaders.gl/loader-utils": "4.0.0-alpha.
|
|
42
|
-
"@loaders.gl/worker-utils": "4.0.0-alpha.
|
|
41
|
+
"@loaders.gl/loader-utils": "4.0.0-alpha.6",
|
|
42
|
+
"@loaders.gl/worker-utils": "4.0.0-alpha.6",
|
|
43
43
|
"@types/brotli": "^1.3.0",
|
|
44
44
|
"@types/pako": "^1.0.1",
|
|
45
45
|
"lzo-wasm": "^0.0.4",
|
|
@@ -49,14 +49,12 @@
|
|
|
49
49
|
"optionalDependencies": {
|
|
50
50
|
"brotli": "^1.3.2",
|
|
51
51
|
"lz4js": "^0.2.0",
|
|
52
|
-
"lzo": "^0.4.11",
|
|
53
52
|
"zstd-codec": "^0.1"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"brotli": "^1.3.2",
|
|
57
56
|
"lz4js": "^0.2.0",
|
|
58
|
-
"lzo": "^0.4.11",
|
|
59
57
|
"zstd-codec": "^0.1"
|
|
60
58
|
},
|
|
61
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "acc1985050dfaa0f1f0c066f8da5bce7454a046c"
|
|
62
60
|
}
|
|
@@ -6,7 +6,7 @@ import type brotliNamespace from 'brotli';
|
|
|
6
6
|
// import brotli from 'brotli'; // https://bundlephobia.com/package/brotli
|
|
7
7
|
import {BrotliDecode} from '../brotli/decode';
|
|
8
8
|
import zlib from 'zlib';
|
|
9
|
-
import {
|
|
9
|
+
import {promisify1} from '@loaders.gl/loader-utils';
|
|
10
10
|
|
|
11
11
|
export type BrotliCompressionOptions = CompressionOptions & {
|
|
12
12
|
brotli?: {
|
|
@@ -57,7 +57,7 @@ export class BrotliCompression extends Compression {
|
|
|
57
57
|
async compress(input: ArrayBuffer): Promise<ArrayBuffer> {
|
|
58
58
|
// On Node.js we can use built-in zlib
|
|
59
59
|
if (!isBrowser && this.options.brotli?.useZlib) {
|
|
60
|
-
const buffer = await
|
|
60
|
+
const buffer = await promisify1(zlib.brotliCompress)(input);
|
|
61
61
|
return toArrayBuffer(buffer);
|
|
62
62
|
}
|
|
63
63
|
return this.compressSync(input);
|
|
@@ -84,7 +84,7 @@ export class BrotliCompression extends Compression {
|
|
|
84
84
|
async decompress(input: ArrayBuffer): Promise<ArrayBuffer> {
|
|
85
85
|
// On Node.js we can use built-in zlib
|
|
86
86
|
if (!isBrowser && this.options.brotli?.useZlib) {
|
|
87
|
-
const buffer = await
|
|
87
|
+
const buffer = await promisify1(zlib.brotliDecompress)(input);
|
|
88
88
|
return toArrayBuffer(buffer);
|
|
89
89
|
}
|
|
90
90
|
return this.decompressSync(input);
|
|
@@ -4,7 +4,7 @@ import {Compression} from './compression';
|
|
|
4
4
|
import {isBrowser, toArrayBuffer} from '@loaders.gl/loader-utils';
|
|
5
5
|
import pako from 'pako'; // https://bundlephobia.com/package/pako
|
|
6
6
|
import zlib from 'zlib';
|
|
7
|
-
import {
|
|
7
|
+
import {promisify1} from '@loaders.gl/loader-utils';
|
|
8
8
|
|
|
9
9
|
export type DeflateCompressionOptions = CompressionOptions & {
|
|
10
10
|
deflate?: pako.InflateOptions & pako.DeflateOptions & {useZlib?: boolean};
|
|
@@ -32,8 +32,8 @@ export class DeflateCompression extends Compression {
|
|
|
32
32
|
// On Node.js we can use built-in zlib
|
|
33
33
|
if (!isBrowser && this.options.deflate?.useZlib) {
|
|
34
34
|
const buffer = this.options.deflate?.gzip
|
|
35
|
-
? await
|
|
36
|
-
: await
|
|
35
|
+
? await promisify1(zlib.gzip)(input)
|
|
36
|
+
: await promisify1(zlib.deflate)(input);
|
|
37
37
|
return toArrayBuffer(buffer);
|
|
38
38
|
}
|
|
39
39
|
return this.compressSync(input);
|
|
@@ -43,8 +43,8 @@ export class DeflateCompression extends Compression {
|
|
|
43
43
|
// On Node.js we can use built-in zlib
|
|
44
44
|
if (!isBrowser && this.options.deflate?.useZlib) {
|
|
45
45
|
const buffer = this.options.deflate?.gzip
|
|
46
|
-
? await
|
|
47
|
-
: await
|
|
46
|
+
? await promisify1(zlib.gunzip)(input)
|
|
47
|
+
: await promisify1(zlib.inflate)(input);
|
|
48
48
|
return toArrayBuffer(buffer);
|
|
49
49
|
}
|
|
50
50
|
return this.decompressSync(input);
|