@loaders.gl/compression 4.0.0-alpha.4 → 4.0.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.d.ts +5 -0
- package/dist/brotli/decode.d.ts.map +1 -0
- package/dist/brotli/decode.js +2213 -0
- package/dist/brotli/decode.js.map +1 -0
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/compression-worker.d.ts +21 -0
- package/dist/compression-worker.d.ts.map +1 -0
- package/dist/compression-worker.js +4 -14
- package/dist/compression-worker.js.map +7 -1
- package/dist/dist.min.js +9 -2
- package/dist/dist.min.js.map +7 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/brotli-compression.d.ts +31 -0
- package/dist/lib/brotli-compression.d.ts.map +1 -0
- package/dist/lib/brotli-compression.js +17 -3
- package/dist/lib/brotli-compression.js.map +1 -1
- package/dist/lib/compression.d.ts +31 -0
- package/dist/lib/compression.d.ts.map +1 -0
- package/dist/lib/deflate-compression.d.ts +32 -0
- package/dist/lib/deflate-compression.d.ts.map +1 -0
- package/dist/lib/gzip-compression.d.ts +17 -0
- package/dist/lib/gzip-compression.d.ts.map +1 -0
- package/dist/lib/lz4-compression.d.ts +37 -0
- package/dist/lib/lz4-compression.d.ts.map +1 -0
- package/dist/lib/lzo-compression.d.ts +21 -0
- package/dist/lib/lzo-compression.d.ts.map +1 -0
- package/dist/lib/no-compression.d.ts +18 -0
- package/dist/lib/no-compression.d.ts.map +1 -0
- package/dist/lib/snappy-compression.d.ts +16 -0
- package/dist/lib/snappy-compression.d.ts.map +1 -0
- package/dist/lib/zstd-compression.d.ts +21 -0
- package/dist/lib/zstd-compression.d.ts.map +1 -0
- package/dist/lib/zstd-compression.js +4 -2
- package/dist/lib/zstd-compression.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/workers/worker.d.ts +2 -0
- package/dist/workers/worker.d.ts.map +1 -0
- package/dist/workers/worker.js +1 -10
- package/dist/workers/worker.js.map +1 -1
- package/package.json +7 -7
- package/src/brotli/decode.ts +2441 -0
- package/src/lib/brotli-compression.ts +19 -4
- package/src/lib/zstd-compression.ts +5 -2
- package/src/workers/worker.ts +10 -10
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { CompressionOptions } from './lib/compression';
|
|
2
|
+
export { Compression } from './lib/compression';
|
|
3
|
+
export { NoCompression } from './lib/no-compression';
|
|
4
|
+
export { DeflateCompression } from './lib/deflate-compression';
|
|
5
|
+
export { GZipCompression } from './lib/gzip-compression';
|
|
6
|
+
export { LZ4Compression } from './lib/lz4-compression';
|
|
7
|
+
export { ZstdCompression } from './lib/zstd-compression';
|
|
8
|
+
export { SnappyCompression } from './lib/snappy-compression';
|
|
9
|
+
export { BrotliCompression } from './lib/brotli-compression';
|
|
10
|
+
export { LZOCompression } from './lib/lzo-compression';
|
|
11
|
+
export type { CompressionWorkerOptions } from './compression-worker';
|
|
12
|
+
export { CompressionWorker, compressOnWorker } from './compression-worker';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAErD,YAAY,EAAC,wBAAwB,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CompressionOptions } from './compression';
|
|
2
|
+
import { Compression } from './compression';
|
|
3
|
+
export declare type BrotliCompressionOptions = CompressionOptions & {
|
|
4
|
+
brotli?: {
|
|
5
|
+
mode?: number;
|
|
6
|
+
quality?: number;
|
|
7
|
+
lgwin?: number;
|
|
8
|
+
useZlib?: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* brotli compression / decompression
|
|
13
|
+
*/
|
|
14
|
+
export declare class BrotliCompression extends Compression {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly extensions: string[];
|
|
17
|
+
readonly contentEncodings: string[];
|
|
18
|
+
readonly isSupported = true;
|
|
19
|
+
readonly options: BrotliCompressionOptions;
|
|
20
|
+
constructor(options: BrotliCompressionOptions);
|
|
21
|
+
/**
|
|
22
|
+
* brotli is an injectable dependency due to big size
|
|
23
|
+
* @param options
|
|
24
|
+
*/
|
|
25
|
+
preload(): Promise<void>;
|
|
26
|
+
compress(input: ArrayBuffer): Promise<ArrayBuffer>;
|
|
27
|
+
compressSync(input: ArrayBuffer): ArrayBuffer;
|
|
28
|
+
decompress(input: ArrayBuffer): Promise<ArrayBuffer>;
|
|
29
|
+
decompressSync(input: ArrayBuffer): ArrayBuffer;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=brotli-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brotli-compression.d.ts","sourceRoot":"","sources":["../../src/lib/brotli-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAQ1C,oBAAY,wBAAwB,GAAG,kBAAkB,GAAG;IAC1D,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH,CAAC;AAYF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAY;IACjC,QAAQ,CAAC,UAAU,WAAU;IAC7B,QAAQ,CAAC,gBAAgB,WAAU;IACnC,QAAQ,CAAC,WAAW,QAAQ;IAC5B,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;gBAE/B,OAAO,EAAE,wBAAwB;IAK7C;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQxB,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IASxD,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;IAkBvC,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAS1D,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;CAkBhD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { Compression } from './compression';
|
|
3
3
|
import { isBrowser, toArrayBuffer } from '@loaders.gl/loader-utils';
|
|
4
|
+
import { BrotliDecode } from '../brotli/decode';
|
|
4
5
|
import zlib from 'zlib';
|
|
5
6
|
import { promisify } from '@loaders.gl/loader-utils';
|
|
6
7
|
const DEFAULT_BROTLI_OPTIONS = {
|
|
@@ -34,7 +35,7 @@ export class BrotliCompression extends Compression {
|
|
|
34
35
|
brotli = brotli || ((_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$modules = _this$options.modules) === null || _this$options$modules === void 0 ? void 0 : _this$options$modules.brotli);
|
|
35
36
|
|
|
36
37
|
if (!brotli) {
|
|
37
|
-
|
|
38
|
+
console.warn("".concat(this.name, " library not installed"));
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -61,7 +62,13 @@ export class BrotliCompression extends Compression {
|
|
|
61
62
|
...((_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.brotli)
|
|
62
63
|
};
|
|
63
64
|
const inputArray = new Uint8Array(input);
|
|
64
|
-
|
|
65
|
+
|
|
66
|
+
if (!brotli) {
|
|
67
|
+
throw new Error('brotli compression: brotli module not installed');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const outputArray = brotli.compress(inputArray, brotliOptions);
|
|
71
|
+
return outputArray.buffer;
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
async decompress(input) {
|
|
@@ -87,7 +94,14 @@ export class BrotliCompression extends Compression {
|
|
|
87
94
|
...((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.brotli)
|
|
88
95
|
};
|
|
89
96
|
const inputArray = new Uint8Array(input);
|
|
90
|
-
|
|
97
|
+
|
|
98
|
+
if (brotli) {
|
|
99
|
+
const outputArray = brotli.decompress(inputArray, brotliOptions);
|
|
100
|
+
return outputArray.buffer;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const outputArray = BrotliDecode(inputArray, undefined);
|
|
104
|
+
return outputArray.buffer;
|
|
91
105
|
}
|
|
92
106
|
|
|
93
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/brotli-compression.ts"],"names":["Compression","isBrowser","toArrayBuffer","zlib","promisify","DEFAULT_BROTLI_OPTIONS","brotli","mode","quality","lgwin","BrotliCompression","constructor","options","preload","modules","
|
|
1
|
+
{"version":3,"sources":["../../src/lib/brotli-compression.ts"],"names":["Compression","isBrowser","toArrayBuffer","BrotliDecode","zlib","promisify","DEFAULT_BROTLI_OPTIONS","brotli","mode","quality","lgwin","BrotliCompression","constructor","options","preload","modules","console","warn","name","compress","input","useZlib","buffer","brotliCompress","compressSync","brotliCompressSync","brotliOptions","inputArray","Uint8Array","Error","outputArray","decompress","brotliDecompress","decompressSync","brotliDecompressSync","undefined"],"mappings":";AAEA,SAAQA,WAAR,QAA0B,eAA1B;AACA,SAAQC,SAAR,EAAmBC,aAAnB,QAAuC,0BAAvC;AAGA,SAAQC,YAAR,QAA2B,kBAA3B;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAAQC,SAAR,QAAwB,0BAAxB;AAWA,MAAMC,sBAAsB,GAAG;AAC7BC,EAAAA,MAAM,EAAE;AACNC,IAAAA,IAAI,EAAE,CADA;AAENC,IAAAA,OAAO,EAAE,CAFH;AAGNC,IAAAA,KAAK,EAAE;AAHD;AADqB,CAA/B;AAQA,IAAIH,MAAJ;AAKA,OAAO,MAAMI,iBAAN,SAAgCX,WAAhC,CAA4C;AAOjDY,EAAAA,WAAW,CAACC,OAAD,EAAoC;AAC7C,UAAMA,OAAN;;AAD6C,kCANvB,QAMuB;;AAAA,wCALzB,CAAC,IAAD,CAKyB;;AAAA,8CAJnB,CAAC,IAAD,CAImB;;AAAA,yCAHxB,IAGwB;;AAAA;;AAE7C,SAAKA,OAAL,GAAeA,OAAf;AACD;;AAMY,QAAPC,OAAO,GAAkB;AAAA;;AAC7BP,IAAAA,MAAM,GAAGA,MAAM,sBAAI,KAAKM,OAAT,2EAAI,cAAcE,OAAlB,0DAAI,sBAAuBR,MAA3B,CAAf;;AACA,QAAI,CAACA,MAAL,EAAa;AAEXS,MAAAA,OAAO,CAACC,IAAR,WAAgB,KAAKC,IAArB;AACD;AACF;;AAEa,QAARC,QAAQ,CAACC,KAAD,EAA2C;AAAA;;AAEvD,QAAI,CA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CAAP;AACD;;AAEDa,EAAAA,cAAc,CAACb,KAAD,EAAkC;AAAA;;AAE9C,QAAI,CAACnB,SAAD,6BAAc,KAAKY,OAAL,CAAaN,MAA3B,kDAAc,sBAAqBc,OAAvC,EAAgD;AAC9C,YAAMC,MAAM,GAAGlB,IAAI,CAAC8B,oBAAL,CAA0Bd,KAA1B,CAAf;AACA,aAAOlB,aAAa,CAACoB,MAAD,CAApB;AACD;;AAED,UAAMI,aAAa,GAAG,EAAC,GAAGpB,sBAAsB,CAACC,MAA3B;AAAmC,4BAAG,KAAKM,OAAR,mDAAG,eAAcN,MAAjB;AAAnC,KAAtB;AACA,UAAMoB,UAAU,GAAG,IAAIC,UAAJ,CAAeR,KAAf,CAAnB;;AAEA,QAAIb,MAAJ,EAAY;AAEV,YAAMuB,WAAW,GAAGvB,MAAM,CAACwB,UAAP,CAAkBJ,UAAlB,EAA8BD,aAA9B,CAApB;AACA,aAAOI,WAAW,CAACR,MAAnB;AACD;;AACD,UAAMQ,WAAW,GAAG3B,YAAY,CAACwB,UAAD,EAAaQ,SAAb,CAAhC;AACA,WAAOL,WAAW,CAACR,MAAnB;AACD;;AA7EgD","sourcesContent":["// BROTLI\nimport type {CompressionOptions} from './compression';\nimport {Compression} from './compression';\nimport {isBrowser, toArrayBuffer} from '@loaders.gl/loader-utils';\nimport type brotliNamespace from 'brotli';\n// import brotli from 'brotli'; // https://bundlephobia.com/package/brotli\nimport {BrotliDecode} from '../brotli/decode';\nimport zlib from 'zlib';\nimport {promisify} from '@loaders.gl/loader-utils';\n\nexport type BrotliCompressionOptions = CompressionOptions & {\n brotli?: {\n mode?: number;\n quality?: number;\n lgwin?: number;\n useZlib?: boolean;\n };\n};\n\nconst DEFAULT_BROTLI_OPTIONS = {\n brotli: {\n mode: 0,\n quality: 8,\n lgwin: 22\n }\n};\n\nlet brotli: typeof brotliNamespace;\n\n/**\n * brotli compression / decompression\n */\nexport class BrotliCompression extends Compression {\n readonly name: string = 'brotli';\n readonly extensions = ['br'];\n readonly contentEncodings = ['br'];\n readonly isSupported = true;\n readonly options: BrotliCompressionOptions;\n\n constructor(options: BrotliCompressionOptions) {\n super(options);\n this.options = options;\n }\n\n /**\n * brotli is an injectable dependency due to big size\n * @param options\n */\n async preload(): Promise<void> {\n brotli = brotli || this.options?.modules?.brotli;\n if (!brotli) {\n // eslint-disable-next-line no-console\n console.warn(`${this.name} library not installed`);\n }\n }\n\n async compress(input: ArrayBuffer): Promise<ArrayBuffer> {\n // On Node.js we can use built-in zlib\n if (!isBrowser && this.options.brotli?.useZlib) {\n const buffer = await promisify(zlib.brotliCompress)(input);\n return toArrayBuffer(buffer);\n }\n return this.compressSync(input);\n }\n\n compressSync(input: ArrayBuffer): ArrayBuffer {\n // On Node.js we can use built-in zlib\n if (!isBrowser && this.options.brotli?.useZlib) {\n const buffer = zlib.brotliCompressSync(input);\n return toArrayBuffer(buffer);\n }\n const brotliOptions = {...DEFAULT_BROTLI_OPTIONS.brotli, ...this.options?.brotli};\n const inputArray = new Uint8Array(input);\n\n if (!brotli) {\n throw new Error('brotli compression: brotli module not installed');\n }\n\n // @ts-ignore brotli types state that only Buffers are accepted...\n const outputArray = brotli.compress(inputArray, brotliOptions);\n return outputArray.buffer;\n }\n\n async decompress(input: ArrayBuffer): Promise<ArrayBuffer> {\n // On Node.js we can use built-in zlib\n if (!isBrowser && this.options.brotli?.useZlib) {\n const buffer = await promisify(zlib.brotliDecompress)(input);\n return toArrayBuffer(buffer);\n }\n return this.decompressSync(input);\n }\n\n decompressSync(input: ArrayBuffer): ArrayBuffer {\n // On Node.js we can use built-in zlib\n if (!isBrowser && this.options.brotli?.useZlib) {\n const buffer = zlib.brotliDecompressSync(input);\n return toArrayBuffer(buffer);\n }\n\n const brotliOptions = {...DEFAULT_BROTLI_OPTIONS.brotli, ...this.options?.brotli};\n const inputArray = new Uint8Array(input);\n\n if (brotli) {\n // @ts-ignore brotli types state that only Buffers are accepted...\n const outputArray = brotli.decompress(inputArray, brotliOptions);\n return outputArray.buffer;\n }\n const outputArray = BrotliDecode(inputArray, undefined);\n return outputArray.buffer;\n }\n}\n"],"file":"brotli-compression.js"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Compression options */
|
|
2
|
+
export declare type CompressionOptions = {
|
|
3
|
+
modules?: {
|
|
4
|
+
[moduleName: string]: any;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
/** Compression */
|
|
8
|
+
export declare abstract class Compression {
|
|
9
|
+
abstract readonly name: string;
|
|
10
|
+
abstract readonly extensions: string[];
|
|
11
|
+
abstract readonly contentEncodings: string[];
|
|
12
|
+
abstract readonly isSupported: boolean;
|
|
13
|
+
constructor(options?: CompressionOptions);
|
|
14
|
+
/** Preloads any dynamic libraries. May enable sync functions */
|
|
15
|
+
preload(): Promise<void>;
|
|
16
|
+
/** Asynchronously compress data */
|
|
17
|
+
compress(input: ArrayBuffer): Promise<ArrayBuffer>;
|
|
18
|
+
/** Asynchronously decompress data */
|
|
19
|
+
decompress(input: ArrayBuffer, size?: number): Promise<ArrayBuffer>;
|
|
20
|
+
/** Synchronously compress data */
|
|
21
|
+
compressSync(input: ArrayBuffer): ArrayBuffer;
|
|
22
|
+
/** Synchronously compress data */
|
|
23
|
+
decompressSync(input: ArrayBuffer, size?: number): ArrayBuffer;
|
|
24
|
+
/** Compress batches */
|
|
25
|
+
compressBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
26
|
+
/** Decompress batches */
|
|
27
|
+
decompressBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
28
|
+
protected concatenate(asyncIterator: any): Promise<ArrayBuffer>;
|
|
29
|
+
protected improveError(error: any): any;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compression.d.ts","sourceRoot":"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WAAW,CAAC;IAI1D,SAAS,CAAC,YAAY,CAAC,KAAK,KAAA;CAM7B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CompressionOptions } from './compression';
|
|
2
|
+
import { Compression } from './compression';
|
|
3
|
+
import pako from 'pako';
|
|
4
|
+
export declare type DeflateCompressionOptions = CompressionOptions & {
|
|
5
|
+
deflate?: pako.InflateOptions & pako.DeflateOptions & {
|
|
6
|
+
useZlib?: boolean;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* DEFLATE compression / decompression
|
|
11
|
+
*/
|
|
12
|
+
export declare class DeflateCompression extends Compression {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly extensions: string[];
|
|
15
|
+
readonly contentEncodings: string[];
|
|
16
|
+
readonly isSupported = true;
|
|
17
|
+
readonly options: DeflateCompressionOptions;
|
|
18
|
+
private _chunks;
|
|
19
|
+
constructor(options?: DeflateCompressionOptions);
|
|
20
|
+
compress(input: ArrayBuffer): Promise<ArrayBuffer>;
|
|
21
|
+
decompress(input: ArrayBuffer): Promise<ArrayBuffer>;
|
|
22
|
+
compressSync(input: ArrayBuffer): ArrayBuffer;
|
|
23
|
+
decompressSync(input: ArrayBuffer): ArrayBuffer;
|
|
24
|
+
compressBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
25
|
+
decompressBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
26
|
+
transformBatches(pakoProcessor: pako.Inflate | pako.Deflate, asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
27
|
+
_onData(chunk: any): void;
|
|
28
|
+
_onEnd(status: any): void;
|
|
29
|
+
_getChunks(): ArrayBuffer[];
|
|
30
|
+
_getError(code?: number): string;
|
|
31
|
+
}
|
|
32
|
+
//# s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AW,CAAC;IAMtB,gBAAgB,CACrB,aAAa,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,EAC1C,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,aAAa,CAAC,WAAW,CAAC;IAwB7B,OAAO,CAAC,KAAK,KAAA;IAIb,MAAM,CAAC,MAAM,KAAA;IAMb,UAAU,IAAI,WAAW,EAAE;IAO3B,SAAS,CAAC,IAAI,GAAE,MAAU,GAAG,MAAM;CAuBpC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CompressionOptions } from './compression';
|
|
2
|
+
import { DeflateCompression } from './deflate-compression';
|
|
3
|
+
import pako from 'pako';
|
|
4
|
+
export declare type GZipCompressionOptions = CompressionOptions & {
|
|
5
|
+
gzip?: pako.InflateOptions & pako.DeflateOptions;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* GZIP compression / decompression
|
|
9
|
+
*/
|
|
10
|
+
export declare class GZipCompression extends DeflateCompression {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly extensions: string[];
|
|
13
|
+
readonly contentEncodings: string[];
|
|
14
|
+
readonly isSupported = true;
|
|
15
|
+
constructor(options?: GZipCompressionOptions);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=gzip-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gzip-compression.d.ts","sourceRoot":"","sources":["../../src/lib/gzip-compression.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,oBAAY,sBAAsB,GAAG,kBAAkB,GAAG;IACxD,IAAI,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAgB,SAAQ,kBAAkB;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAU;IAC/B,QAAQ,CAAC,UAAU,WAAkB;IACrC,QAAQ,CAAC,gBAAgB,WAAsB;IAC/C,QAAQ,CAAC,WAAW,QAAQ;gBAEhB,OAAO,CAAC,EAAE,sBAAsB;CAG7C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CompressionOptions } from './compression';
|
|
2
|
+
import { Compression } from './compression';
|
|
3
|
+
/**
|
|
4
|
+
* LZ4 compression / decompression
|
|
5
|
+
*/
|
|
6
|
+
export declare class LZ4Compression extends Compression {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly extensions: string[];
|
|
9
|
+
readonly contentEncodings: string[];
|
|
10
|
+
readonly isSupported = true;
|
|
11
|
+
readonly options: CompressionOptions;
|
|
12
|
+
constructor(options: CompressionOptions);
|
|
13
|
+
compressSync(input: ArrayBuffer): ArrayBuffer;
|
|
14
|
+
/**
|
|
15
|
+
* Decompresses an ArrayBuffer containing an Lz4 frame. maxSize is optional; if not
|
|
16
|
+
* provided, a maximum size will be determined by examining the data. The
|
|
17
|
+
* returned ArrayBuffer will always be perfectly sized.
|
|
18
|
+
* If data provided without magic number we will parse it as block
|
|
19
|
+
*/
|
|
20
|
+
decompressSync(data: ArrayBuffer, maxSize?: number): ArrayBuffer;
|
|
21
|
+
/**
|
|
22
|
+
* Decode lz4 file as block
|
|
23
|
+
* Solution taken from here
|
|
24
|
+
* https://github.com/pierrec/node-lz4/blob/0dac687262403fd34f905b963da7220692f2a4a1/lib/binding.js#L25
|
|
25
|
+
* @param input
|
|
26
|
+
* @param output
|
|
27
|
+
* @param startIndex
|
|
28
|
+
* @param endIndex
|
|
29
|
+
*/
|
|
30
|
+
decodeBlock(data: Uint8Array, output: Uint8Array, startIndex?: number, endIndex?: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Compare file magic with lz4 magic number
|
|
33
|
+
* @param input
|
|
34
|
+
*/
|
|
35
|
+
checkMagicNumber(data: ArrayBuffer): boolean;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=lz4-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lz4-compression.d.ts","sourceRoot":"","sources":["../../src/lib/lz4-compression.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAM1C;;GAEG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAS;IAC9B,QAAQ,CAAC,UAAU,WAAW;IAC9B,QAAQ,CAAC,gBAAgB,WAAa;IACtC,QAAQ,CAAC,WAAW,QAAQ;IAC5B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAEzB,OAAO,EAAE,kBAAkB;IAUvC,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;IAK7C;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW;IAwBhE;;;;;;;;OAQG;IACH,WAAW,CACT,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,UAAU,EAClB,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM;IAgET;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO;CAI7C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CompressionOptions } from './compression';
|
|
2
|
+
import { Compression } from './compression';
|
|
3
|
+
/**
|
|
4
|
+
* Lempel-Ziv-Oberheimer compression / decompression
|
|
5
|
+
*/
|
|
6
|
+
export declare class LZOCompression extends Compression {
|
|
7
|
+
readonly name = "lzo";
|
|
8
|
+
readonly extensions: never[];
|
|
9
|
+
readonly contentEncodings: never[];
|
|
10
|
+
readonly isSupported = false;
|
|
11
|
+
readonly options: CompressionOptions;
|
|
12
|
+
/**
|
|
13
|
+
* lzo is an injectable dependency due to big size
|
|
14
|
+
* @param options
|
|
15
|
+
*/
|
|
16
|
+
constructor(options: CompressionOptions);
|
|
17
|
+
preload(): Promise<void>;
|
|
18
|
+
compress(input: ArrayBuffer): Promise<ArrayBuffer>;
|
|
19
|
+
decompress(input: ArrayBuffer): Promise<ArrayBuffer>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=lzo-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lzo-compression.d.ts","sourceRoot":"","sources":["../../src/lib/lzo-compression.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CompressionOptions } from './compression';
|
|
2
|
+
import { Compression } from './compression';
|
|
3
|
+
/**
|
|
4
|
+
* Applies no compression.
|
|
5
|
+
*/
|
|
6
|
+
export declare class NoCompression extends Compression {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly extensions: string[];
|
|
9
|
+
readonly contentEncodings: string[];
|
|
10
|
+
readonly isSupported = true;
|
|
11
|
+
readonly options: CompressionOptions;
|
|
12
|
+
constructor(options?: CompressionOptions);
|
|
13
|
+
compressSync(input: ArrayBuffer): ArrayBuffer;
|
|
14
|
+
decompressSync(input: ArrayBuffer): ArrayBuffer;
|
|
15
|
+
compressBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
16
|
+
decompressBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrayBuffer>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=no-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-compression.d.ts","sourceRoot":"","sources":["../../src/lib/no-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CompressionOptions } from './compression';
|
|
2
|
+
import { Compression } from './compression';
|
|
3
|
+
/**
|
|
4
|
+
* Snappy/zippy compression / decompression
|
|
5
|
+
*/
|
|
6
|
+
export declare class SnappyCompression extends Compression {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly extensions: never[];
|
|
9
|
+
readonly contentEncodings: never[];
|
|
10
|
+
readonly isSupported = true;
|
|
11
|
+
readonly options: CompressionOptions;
|
|
12
|
+
constructor(options?: CompressionOptions);
|
|
13
|
+
compressSync(input: ArrayBuffer): ArrayBuffer;
|
|
14
|
+
decompressSync(input: ArrayBuffer): ArrayBuffer;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=snappy-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snappy-compression.d.ts","sourceRoot":"","sources":["../../src/lib/snappy-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CompressionOptions } from './compression';
|
|
2
|
+
import { Compression } from './compression';
|
|
3
|
+
/**
|
|
4
|
+
* Zstandard compression / decompression
|
|
5
|
+
*/
|
|
6
|
+
export declare class ZstdCompression extends Compression {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly extensions: never[];
|
|
9
|
+
readonly contentEncodings: never[];
|
|
10
|
+
readonly isSupported = true;
|
|
11
|
+
readonly options: CompressionOptions;
|
|
12
|
+
/**
|
|
13
|
+
* zstd-codec is an injectable dependency due to big size
|
|
14
|
+
* @param options
|
|
15
|
+
*/
|
|
16
|
+
constructor(options: CompressionOptions);
|
|
17
|
+
preload(): Promise<void>;
|
|
18
|
+
compressSync(input: ArrayBuffer): ArrayBuffer;
|
|
19
|
+
decompressSync(input: ArrayBuffer): ArrayBuffer;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=zstd-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zstd-compression.d.ts","sourceRoot":"","sources":["../../src/lib/zstd-compression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;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"}
|
|
@@ -22,12 +22,14 @@ export class ZstdCompression extends Compression {
|
|
|
22
22
|
ZstdCodec = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$modules = _this$options.modules) === null || _this$options$modules === void 0 ? void 0 : _this$options$modules['zstd-codec'];
|
|
23
23
|
|
|
24
24
|
if (!ZstdCodec) {
|
|
25
|
-
|
|
25
|
+
console.warn("".concat(this.name, " library not installed"));
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async preload() {
|
|
30
|
-
|
|
30
|
+
if (!zstd && ZstdCodec) {
|
|
31
|
+
zstd = await new Promise(resolve => ZstdCodec.run(zstd => resolve(zstd)));
|
|
32
|
+
}
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
compressSync(input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/zstd-compression.ts"],"names":["Compression","ZstdCodec","zstd","ZstdCompression","constructor","options","modules","
|
|
1
|
+
{"version":3,"sources":["../../src/lib/zstd-compression.ts"],"names":["Compression","ZstdCodec","zstd","ZstdCompression","constructor","options","modules","console","warn","name","preload","Promise","resolve","run","compressSync","input","simpleZstd","Simple","inputArray","Uint8Array","compress","buffer","decompressSync","decompress"],"mappings":";AAEA,SAAQA,WAAR,QAA0B,eAA1B;AAGA,IAAIC,SAAJ;AACA,IAAIC,IAAJ;AAKA,OAAO,MAAMC,eAAN,SAA8BH,WAA9B,CAA0C;AAW/CI,EAAAA,WAAW,CAACC,OAAD,EAA8B;AAAA;;AACvC,UAAMA,OAAN;;AADuC,kCAVjB,MAUiB;;AAAA,wCATnB,EASmB;;AAAA,8CARb,EAQa;;AAAA,yCAPlB,IAOkB;;AAAA;;AAEvC,SAAKA,OAAL,GAAeA,OAAf;AAEAJ,IAAAA,SAAS,oBAAG,KAAKI,OAAR,2EAAG,cAAcC,OAAjB,0DAAG,sBAAwB,YAAxB,CAAZ;;AACA,QAAI,CAACL,SAAL,EAAgB;AAEdM,MAAAA,OAAO,CAACC,IAAR,WAAgB,KAAKC,IAArB;AACD;AACF;;AAEY,QAAPC,OAAO,GAAkB;AAC7B,QAAI,CAACR,IAAD,IAASD,SAAb,EAAwB;AACtBC,MAAAA,IAAI,GAAG,MAAM,IAAIS,OAAJ,CAAaC,OAAD,IAAaX,SAAS,CAACY,GAAV,CAAeX,IAAD,IAAUU,OAAO,CAACV,IAAD,CAA/B,CAAzB,CAAb;AACD;AACF;;AAEDY,EAAAA,YAAY,CAACC,KAAD,EAAkC;AAC5C,UAAMC,UAAU,GAAG,IAAId,IAAI,CAACe,MAAT,EAAnB;AACA,UAAMC,UAAU,GAAG,IAAIC,UAAJ,CAAeJ,KAAf,CAAnB;AACA,WAAOC,UAAU,CAACI,QAAX,CAAoBF,UAApB,EAAgCG,MAAvC;AACD;;AAEDC,EAAAA,cAAc,CAACP,KAAD,EAAkC;AAC9C,UAAMC,UAAU,GAAG,IAAId,IAAI,CAACe,MAAT,EAAnB;AAGA,UAAMC,UAAU,GAAG,IAAIC,UAAJ,CAAeJ,KAAf,CAAnB;AACA,WAAOC,UAAU,CAACO,UAAX,CAAsBL,UAAtB,EAAkCG,MAAzC;AACD;;AAxC8C","sourcesContent":["// ZSTD\nimport type {CompressionOptions} from './compression';\nimport {Compression} from './compression';\n// import {ZstdCodec} from 'zstd-codec'; // https://bundlephobia.com/package/zstd-codec\n\nlet ZstdCodec;\nlet zstd;\n\n/**\n * Zstandard compression / decompression\n */\nexport class ZstdCompression extends Compression {\n readonly name: string = 'zstd';\n readonly extensions = [];\n readonly contentEncodings = [];\n readonly isSupported = true;\n readonly options: CompressionOptions;\n\n /**\n * zstd-codec is an injectable dependency due to big size\n * @param options\n */\n constructor(options: CompressionOptions) {\n super(options);\n this.options = options;\n\n ZstdCodec = this.options?.modules?.['zstd-codec'];\n if (!ZstdCodec) {\n // eslint-disable-next-line no-console\n console.warn(`${this.name} library not installed`);\n }\n }\n\n async preload(): Promise<void> {\n if (!zstd && ZstdCodec) {\n zstd = await new Promise((resolve) => ZstdCodec.run((zstd) => resolve(zstd)));\n }\n }\n\n compressSync(input: ArrayBuffer): ArrayBuffer {\n const simpleZstd = new zstd.Simple();\n const inputArray = new Uint8Array(input);\n return simpleZstd.compress(inputArray).buffer;\n }\n\n decompressSync(input: ArrayBuffer): ArrayBuffer {\n const simpleZstd = new zstd.Simple();\n // var ddict = new zstd.Dict.Decompression(dictData);\n // var jsonBytes = simpleZstd.decompressUsingDict(jsonZstData, ddict);\n const inputArray = new Uint8Array(input);\n return simpleZstd.decompress(inputArray).buffer;\n }\n}\n"],"file":"zstd-compression.js"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/workers/worker.ts"],"names":[],"mappings":""}
|
package/dist/workers/worker.js
CHANGED
|
@@ -6,18 +6,9 @@ import { GZipCompression } from '../lib/gzip-compression';
|
|
|
6
6
|
import { LZ4Compression } from '../lib/lz4-compression';
|
|
7
7
|
import { SnappyCompression } from '../lib/snappy-compression';
|
|
8
8
|
import { ZstdCompression } from '../lib/zstd-compression';
|
|
9
|
-
import brotliDecompress from 'brotli/decompress';
|
|
10
9
|
import lz4js from 'lz4js';
|
|
11
|
-
import { ZstdCodec } from 'zstd-codec';
|
|
12
10
|
const modules = {
|
|
13
|
-
|
|
14
|
-
decompress: brotliDecompress,
|
|
15
|
-
compress: () => {
|
|
16
|
-
throw new Error('brotli compress');
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
lz4js,
|
|
20
|
-
'zstd-codec': ZstdCodec
|
|
11
|
+
lz4js
|
|
21
12
|
};
|
|
22
13
|
const COMPRESSIONS = [new NoCompression({
|
|
23
14
|
modules
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/workers/worker.ts"],"names":["createWorker","NoCompression","BrotliCompression","DeflateCompression","GZipCompression","LZ4Compression","SnappyCompression","ZstdCompression","
|
|
1
|
+
{"version":3,"sources":["../../src/workers/worker.ts"],"names":["createWorker","NoCompression","BrotliCompression","DeflateCompression","GZipCompression","LZ4Compression","SnappyCompression","ZstdCompression","lz4js","modules","COMPRESSIONS","data","options","operation","getOperation","String","compression","getCompression","compress","decompress","Error","name","Compression","find","compression_"],"mappings":"AAAA,SAAQA,YAAR,QAA2B,0BAA3B;AAGA,SAAQC,aAAR,QAA4B,uBAA5B;AACA,SAAQC,iBAAR,QAAgC,2BAAhC;AACA,SAAQC,kBAAR,QAAiC,4BAAjC;AACA,SAAQC,eAAR,QAA8B,yBAA9B;AACA,SAAQC,cAAR,QAA6B,wBAA7B;AAEA,SAAQC,iBAAR,QAAgC,2BAAhC;AACA,SAAQC,eAAR,QAA8B,yBAA9B;AAMA,OAAOC,KAAP,MAAkB,OAAlB;AAKA,MAAMC,OAAO,GAAG;AAQdD,EAAAA;AARc,CAAhB;AAcA,MAAME,YAAY,GAAG,CACnB,IAAIT,aAAJ,CAAkB;AAACQ,EAAAA;AAAD,CAAlB,CADmB,EAEnB,IAAIP,iBAAJ,CAAsB;AAACO,EAAAA;AAAD,CAAtB,CAFmB,EAGnB,IAAIN,kBAAJ,CAAuB;AAACM,EAAAA;AAAD,CAAvB,CAHmB,EAInB,IAAIL,eAAJ,CAAoB;AAACK,EAAAA;AAAD,CAApB,CAJmB,EAMnB,IAAIJ,cAAJ,CAAmB;AAACI,EAAAA;AAAD,CAAnB,CANmB,EAOnB,IAAIH,iBAAJ,CAAsB;AAACG,EAAAA;AAAD,CAAtB,CAPmB,EAQnB,IAAIF,eAAJ,CAAoB;AAACE,EAAAA;AAAD,CAApB,CARmB,CAArB;AAWAT,YAAY,CAAC,OAAOW,IAAP,EAAaC,OAAO,GAAG,EAAvB,KAA8B;AACzC,QAAMC,SAAS,GAAGC,YAAY,CAACC,MAAM,CAACH,OAAD,aAACA,OAAD,uBAACA,OAAO,CAAEC,SAAV,CAAP,CAA9B;AACA,QAAMG,WAAW,GAAGC,cAAc,CAACF,MAAM,CAACH,OAAD,aAACA,OAAD,uBAACA,OAAO,CAAEI,WAAV,CAAP,CAAlC;;AAGA,UAAQH,SAAR;AACE,SAAK,UAAL;AACE,aAAO,MAAMG,WAAW,CAACE,QAAZ,CAAqBP,IAArB,CAAb;;AACF,SAAK,YAAL;AACE,aAAO,MAAMK,WAAW,CAACG,UAAZ,CAAuBR,IAAvB,CAAb;;AACF;AACE,YAAM,IAAIS,KAAJ,CAAU,gBAAV,CAAN;AANJ;AAQD,CAbW,CAAZ;;AAeA,SAASN,YAAT,CAAsBD,SAAtB,EAAoE;AAClE,UAAQA,SAAR;AACE,SAAK,UAAL;AACA,SAAK,SAAL;AACE,aAAO,UAAP;;AACF,SAAK,YAAL;AACA,SAAK,SAAL;AACE,aAAO,YAAP;;AACF;AACE,YAAM,IAAIO,KAAJ,0DAC8CP,SAD9C,2CAAN;AARJ;AAYD;;AAED,SAASI,cAAT,CAAwBI,IAAxB,EAAsC;AACpC,QAAMC,WAAW,GAAGZ,YAAY,CAACa,IAAb,CAAmBC,YAAD,IAAkBH,IAAI,KAAKG,YAAY,CAACH,IAA1D,CAApB;;AACA,MAAI,CAACC,WAAL,EAAkB;AAChB,UAAM,IAAIF,KAAJ,4DAA8DC,IAA9D,EAAN;AACD;;AACD,SAAOC,WAAP;AACD","sourcesContent":["import {createWorker} from '@loaders.gl/worker-utils';\n\n// Compressors\nimport {NoCompression} from '../lib/no-compression';\nimport {BrotliCompression} from '../lib/brotli-compression';\nimport {DeflateCompression} from '../lib/deflate-compression';\nimport {GZipCompression} from '../lib/gzip-compression';\nimport {LZ4Compression} from '../lib/lz4-compression';\n// import {LZOCompression} from '../lib/lzo-compression';\nimport {SnappyCompression} from '../lib/snappy-compression';\nimport {ZstdCompression} from '../lib/zstd-compression';\n\n// Import big dependencies\n\n// import brotli from 'brotli'; - brotli has problems with decompress in browsers\n// import brotliDecompress from 'brotli/decompress';\nimport lz4js from 'lz4js';\n// import lzo from 'lzo';\n// import {ZstdCodec} from 'zstd-codec';\n\n// Inject large dependencies through Compression constructor options\nconst modules = {\n // brotli has problems with decompress in browsers\n // brotli: {\n // decompress: brotliDecompress,\n // compress: () => {\n // throw new Error('brotli compress');\n // }\n // },\n lz4js\n // lzo,\n // 'zstd-codec': ZstdCodec\n};\n\n/** @type {Compression[]} */\nconst COMPRESSIONS = [\n new NoCompression({modules}),\n new BrotliCompression({modules}),\n new DeflateCompression({modules}),\n new GZipCompression({modules}),\n // new LZOCompression({modules}),\n new LZ4Compression({modules}),\n new SnappyCompression({modules}),\n new ZstdCompression({modules})\n];\n\ncreateWorker(async (data, options = {}) => {\n const operation = getOperation(String(options?.operation));\n const compression = getCompression(String(options?.compression));\n\n // @ts-ignore\n switch (operation) {\n case 'compress':\n return await compression.compress(data);\n case 'decompress':\n return await compression.decompress(data);\n default:\n throw new Error('invalid option');\n }\n});\n\nfunction getOperation(operation: string): 'compress' | 'decompress' {\n switch (operation) {\n case 'compress':\n case 'deflate':\n return 'compress';\n case 'decompress':\n case 'inflate':\n return 'decompress';\n default:\n throw new Error(\n `@loaders.gl/compression: Unsupported operation ${operation}. Expected 'compress' or 'decompress'`\n );\n }\n}\n\nfunction getCompression(name: string) {\n const Compression = COMPRESSIONS.find((compression_) => name === compression_.name);\n if (!Compression) {\n throw new Error(`@loaders.gl/compression: Unsupported compression ${name}`);\n }\n return Compression;\n}\n"],"file":"worker.js"}
|
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.5",
|
|
4
4
|
"description": "Decompression and compression plugins for loaders.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"mesh",
|
|
18
18
|
"point cloud"
|
|
19
19
|
],
|
|
20
|
-
"types": "
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
21
|
"main": "dist/index.js",
|
|
22
22
|
"module": "dist/index.js",
|
|
23
23
|
"sideEffects": false,
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"pre-build": "npm run build-bundle && npm run build-worker",
|
|
36
|
-
"build-bundle": "
|
|
37
|
-
"build-worker": "
|
|
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\\\""
|
|
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.5",
|
|
42
|
+
"@loaders.gl/worker-utils": "4.0.0-alpha.5",
|
|
43
43
|
"@types/brotli": "^1.3.0",
|
|
44
44
|
"@types/pako": "^1.0.1",
|
|
45
45
|
"lzo-wasm": "^0.0.4",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"lzo": "^0.4.11",
|
|
59
59
|
"zstd-codec": "^0.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
|
|
62
62
|
}
|