@loaders.gl/compression 3.1.0-beta.7 → 3.1.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/gzip-compression.ts"],"names":["GZipCompression","DeflateCompression","constructor","options","deflate","gzip"],"mappings":";;;;;;;;;;;AAGA;;AAUO,MAAMA,eAAN,SAA8BC,sCAA9B,CAAiD;AAMtDC,EAAAA,WAAW,CAACC,OAAD,EAAmC;AAC5C,UAAM,EAAC,GAAGA,OAAJ;AAAaC,MAAAA,OAAO,EAAE,EAAC,IAAGD,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEE,IAAZ,CAAD;AAAmBA,QAAAA,IAAI,EAAE;AAAzB;AAAtB,KAAN;AAD4C,gDALtB,MAKsB;AAAA,sDAJxB,CAAC,IAAD,EAAO,MAAP,CAIwB;AAAA,4DAHlB,CAAC,MAAD,EAAS,QAAT,CAGkB;AAAA,uDAFvB,IAEuB;AAE7C;;AARqD","sourcesContent":["// GZIP\n// import {isBrowser} from '@loaders.gl/loader-utils';\nimport type {CompressionOptions} from './compression';\nimport {DeflateCompression} from './deflate-compression';\nimport pako from 'pako'; // https://bundlephobia.com/package/pako\n\nexport type GZipCompressionOptions = CompressionOptions & {\n gzip?: pako.InflateOptions & pako.DeflateOptions;\n};\n\n/**\n * GZIP compression / decompression\n */\nexport class GZipCompression extends DeflateCompression {\n readonly name: string = 'gzip';\n readonly extensions = ['gz', 'gzip'];\n readonly contentEncodings = ['gzip', 'x-gzip'];\n readonly isSupported = true;\n\n constructor(options?: GZipCompressionOptions) {\n super({...options, deflate: {...options?.gzip, gzip: true}});\n }\n}\n"],"file":"gzip-compression.js"}
1
+ {"version":3,"sources":["../../../src/lib/gzip-compression.ts"],"names":["GZipCompression","options","deflate","gzip","DeflateCompression"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;IAUaA,e;;;;;AAMX,2BAAYC,OAAZ,EAA8C;AAAA;;AAAA;AAC5C,8DAAUA,OAAV;AAAmBC,MAAAA,OAAO,kCAAMD,OAAN,aAAMA,OAAN,uBAAMA,OAAO,CAAEE,IAAf;AAAqBA,QAAAA,IAAI,EAAE;AAA3B;AAA1B;AAD4C,uFALtB,MAKsB;AAAA,6FAJxB,CAAC,IAAD,EAAO,MAAP,CAIwB;AAAA,mGAHlB,CAAC,MAAD,EAAS,QAAT,CAGkB;AAAA,8FAFvB,IAEuB;AAAA;AAE7C;;;EARkCC,sC","sourcesContent":["// GZIP\n// import {isBrowser} from '@loaders.gl/loader-utils';\nimport type {CompressionOptions} from './compression';\nimport {DeflateCompression} from './deflate-compression';\nimport pako from 'pako'; // https://bundlephobia.com/package/pako\n\nexport type GZipCompressionOptions = CompressionOptions & {\n gzip?: pako.InflateOptions & pako.DeflateOptions;\n};\n\n/**\n * GZIP compression / decompression\n */\nexport class GZipCompression extends DeflateCompression {\n readonly name: string = 'gzip';\n readonly extensions = ['gz', 'gzip'];\n readonly contentEncodings = ['gzip', 'x-gzip'];\n readonly isSupported = true;\n\n constructor(options?: GZipCompressionOptions) {\n super({...options, deflate: {...options?.gzip, gzip: true}});\n }\n}\n"],"file":"gzip-compression.js"}
@@ -7,120 +7,151 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.LZ4Compression = void 0;
9
9
 
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
10
22
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
23
 
12
24
  var _loaderUtils = require("@loaders.gl/loader-utils");
13
25
 
14
26
  var _compression = require("./compression");
15
27
 
16
- const LZ4_MAGIC_NUMBER = 0x184d2204;
17
- let lz4js;
28
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
29
+
30
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
+
32
+ var LZ4_MAGIC_NUMBER = 0x184d2204;
33
+ var lz4js;
34
+
35
+ var LZ4Compression = function (_Compression) {
36
+ (0, _inherits2.default)(LZ4Compression, _Compression);
18
37
 
19
- class LZ4Compression extends _compression.Compression {
20
- constructor(options) {
38
+ var _super = _createSuper(LZ4Compression);
39
+
40
+ function LZ4Compression(options) {
21
41
  var _this$options, _this$options$modules;
22
42
 
23
- super(options);
24
- (0, _defineProperty2.default)(this, "name", 'lz4');
25
- (0, _defineProperty2.default)(this, "extensions", ['lz4']);
26
- (0, _defineProperty2.default)(this, "contentEncodings", ['x-lz4']);
27
- (0, _defineProperty2.default)(this, "isSupported", true);
28
- (0, _defineProperty2.default)(this, "options", void 0);
29
- this.options = options;
30
- lz4js = lz4js || ((_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.lz4js);
43
+ var _this;
44
+
45
+ (0, _classCallCheck2.default)(this, LZ4Compression);
46
+ _this = _super.call(this, options);
47
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "name", 'lz4');
48
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "extensions", ['lz4']);
49
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "contentEncodings", ['x-lz4']);
50
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isSupported", true);
51
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "options", void 0);
52
+ _this.options = options;
53
+ lz4js = lz4js || ((_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.lz4js);
31
54
 
32
55
  if (!lz4js) {
33
- throw new Error(this.name);
56
+ throw new Error(_this.name);
34
57
  }
35
- }
36
58
 
37
- compressSync(input) {
38
- const inputArray = new Uint8Array(input);
39
- return lz4js.compress(inputArray).buffer;
59
+ return _this;
40
60
  }
41
61
 
42
- decompressSync(data, maxSize) {
43
- try {
44
- const isMagicNumberExists = this.checkMagicNumber(data);
45
- const inputArray = new Uint8Array(data);
62
+ (0, _createClass2.default)(LZ4Compression, [{
63
+ key: "compressSync",
64
+ value: function compressSync(input) {
65
+ var inputArray = new Uint8Array(input);
66
+ return lz4js.compress(inputArray).buffer;
67
+ }
68
+ }, {
69
+ key: "decompressSync",
70
+ value: function decompressSync(data, maxSize) {
71
+ try {
72
+ var isMagicNumberExists = this.checkMagicNumber(data);
73
+ var inputArray = new Uint8Array(data);
74
+
75
+ if (isMagicNumberExists) {
76
+ return lz4js.decompress(inputArray, maxSize).buffer;
77
+ }
46
78
 
47
- if (isMagicNumberExists) {
48
- return lz4js.decompress(inputArray, maxSize).buffer;
49
- }
79
+ if (!maxSize) {
80
+ var error = new Error('Need to provide maxSize');
81
+ throw this.improveError(error);
82
+ }
50
83
 
51
- if (!maxSize) {
52
- const error = new Error('Need to provide maxSize');
84
+ var uncompressed = new Uint8Array(maxSize);
85
+ var uncompressedSize = this.decodeBlock(inputArray, uncompressed);
86
+ uncompressed = uncompressed.slice(0, uncompressedSize);
87
+ return (0, _loaderUtils.toArrayBuffer)(uncompressed);
88
+ } catch (error) {
53
89
  throw this.improveError(error);
54
90
  }
55
-
56
- let uncompressed = new Uint8Array(maxSize);
57
- const uncompressedSize = this.decodeBlock(inputArray, uncompressed);
58
- uncompressed = uncompressed.slice(0, uncompressedSize);
59
- return (0, _loaderUtils.toArrayBuffer)(uncompressed);
60
- } catch (error) {
61
- throw this.improveError(error);
62
91
  }
63
- }
92
+ }, {
93
+ key: "decodeBlock",
94
+ value: function decodeBlock(data, output, startIndex, endIndex) {
95
+ startIndex = startIndex || 0;
96
+ endIndex = endIndex || data.length - startIndex;
97
+ var uncompressedSize = 0;
98
+
99
+ for (var index = startIndex; index < endIndex;) {
100
+ var token = data[index++];
101
+ var literalsLength = token >> 4;
102
+
103
+ if (literalsLength > 0) {
104
+ var _length = literalsLength + 240;
105
+
106
+ while (_length === 255) {
107
+ _length = data[index++];
108
+ literalsLength += _length;
109
+ }
110
+
111
+ var _end = index + literalsLength;
112
+
113
+ while (index < _end) {
114
+ output[uncompressedSize++] = data[index++];
115
+ }
116
+
117
+ if (index === endIndex) {
118
+ return uncompressedSize;
119
+ }
120
+ }
64
121
 
65
- decodeBlock(data, output, startIndex, endIndex) {
66
- startIndex = startIndex || 0;
67
- endIndex = endIndex || data.length - startIndex;
68
- let uncompressedSize = 0;
122
+ var offset = data[index++] | data[index++] << 8;
69
123
 
70
- for (let index = startIndex; index < endIndex;) {
71
- const token = data[index++];
72
- let literalsLength = token >> 4;
124
+ if (offset === 0 || offset > uncompressedSize) {
125
+ return -(index - 2);
126
+ }
73
127
 
74
- if (literalsLength > 0) {
75
- let length = literalsLength + 240;
128
+ var matchLength = token & 0xf;
129
+ var length = matchLength + 240;
76
130
 
77
131
  while (length === 255) {
78
132
  length = data[index++];
79
- literalsLength += length;
133
+ matchLength += length;
80
134
  }
81
135
 
82
- const end = index + literalsLength;
136
+ var pos = uncompressedSize - offset;
137
+ var end = uncompressedSize + matchLength + 4;
83
138
 
84
- while (index < end) {
85
- output[uncompressedSize++] = data[index++];
139
+ while (uncompressedSize < end) {
140
+ output[uncompressedSize++] = output[pos++];
86
141
  }
87
-
88
- if (index === endIndex) {
89
- return uncompressedSize;
90
- }
91
- }
92
-
93
- const offset = data[index++] | data[index++] << 8;
94
-
95
- if (offset === 0 || offset > uncompressedSize) {
96
- return -(index - 2);
97
- }
98
-
99
- let matchLength = token & 0xf;
100
- let length = matchLength + 240;
101
-
102
- while (length === 255) {
103
- length = data[index++];
104
- matchLength += length;
105
142
  }
106
143
 
107
- let pos = uncompressedSize - offset;
108
- const end = uncompressedSize + matchLength + 4;
109
-
110
- while (uncompressedSize < end) {
111
- output[uncompressedSize++] = output[pos++];
112
- }
144
+ return uncompressedSize;
113
145
  }
114
-
115
- return uncompressedSize;
116
- }
117
-
118
- checkMagicNumber(data) {
119
- const magic = new Uint32Array(data.slice(0, 4));
120
- return magic[0] === LZ4_MAGIC_NUMBER;
121
- }
122
-
123
- }
146
+ }, {
147
+ key: "checkMagicNumber",
148
+ value: function checkMagicNumber(data) {
149
+ var magic = new Uint32Array(data.slice(0, 4));
150
+ return magic[0] === LZ4_MAGIC_NUMBER;
151
+ }
152
+ }]);
153
+ return LZ4Compression;
154
+ }(_compression.Compression);
124
155
 
125
156
  exports.LZ4Compression = LZ4Compression;
126
157
  //# sourceMappingURL=lz4-compression.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/lz4-compression.ts"],"names":["LZ4_MAGIC_NUMBER","lz4js","LZ4Compression","Compression","constructor","options","modules","Error","name","compressSync","input","inputArray","Uint8Array","compress","buffer","decompressSync","data","maxSize","isMagicNumberExists","checkMagicNumber","decompress","error","improveError","uncompressed","uncompressedSize","decodeBlock","slice","output","startIndex","endIndex","length","index","token","literalsLength","end","offset","matchLength","pos","magic","Uint32Array"],"mappings":";;;;;;;;;;;AAwBA;;AAEA;;A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jD;;AAGA,UAAII,MAAM,KAAK,CAAX,IAAgBA,MAAM,GAAGX,gBAA7B,EAA+C;AAC7C,eAAO,EAAEO,KAAK,GAAG,CAAV,CAAP;AACD;;AAGD,UAAIK,WAAW,GAAGJ,KAAK,GAAG,GAA1B;AACA,UAAIF,MAAM,GAAGM,WAAW,GAAG,GAA3B;;AAEA,aAAON,MAAM,KAAK,GAAlB,EAAuB;AACrBA,QAAAA,MAAM,GAAGd,IAAI,CAACe,KAAK,EAAN,CAAb;AACAK,QAAAA,WAAW,IAAIN,MAAf;AACD;;AAGD,UAAIO,GAAG,GAAGb,gBAAgB,GAAGW,MAA7B;AACA,YAAMD,GAAG,GAAGV,gBAAgB,GAAGY,WAAnB,GAAiC,CAA7C;;AAEA,aAAOZ,gBAAgB,GAAGU,GAA1B,EAA+B;AAC7BP,QAAAA,MAAM,CAACH,gBAAgB,EAAjB,CAAN,GAA6BG,MAAM,CAACU,GAAG,EAAJ,CAAnC;AACD;AACF;;AAED,WAAOb,gBAAP;AACD;;AAMDL,EAAAA,gBAAgB,CAACH,IAAD,EAA6B;AAC3C,UAAMsB,KAAK,GAAG,IAAIC,WAAJ,CAAgBvB,IAAI,CAACU,KAAL,CAAW,CAAX,EAAc,CAAd,CAAhB,CAAd;AACA,WAAOY,KAAK,CAAC,CAAD,CAAL,KAAatC,gBAApB;AACD;;AAzI6C","sourcesContent":["// Copyright (c) 2012 Pierre Curto\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\n\n// LZ4\nimport {toArrayBuffer} from '@loaders.gl/loader-utils';\nimport type {CompressionOptions} from './compression';\nimport {Compression} from './compression';\n// import lz4js from 'lz4js'; // https://bundlephobia.com/package/lz4\nconst LZ4_MAGIC_NUMBER = 0x184d2204;\n\nlet lz4js;\n\n/**\n * LZ4 compression / decompression\n */\nexport class LZ4Compression extends Compression {\n readonly name: string = 'lz4';\n readonly extensions = ['lz4'];\n readonly contentEncodings = ['x-lz4'];\n readonly isSupported = true;\n readonly options: CompressionOptions;\n\n constructor(options: CompressionOptions) {\n super(options);\n this.options = options;\n\n lz4js = lz4js || this.options?.modules?.lz4js;\n if (!lz4js) {\n throw new Error(this.name);\n }\n }\n\n compressSync(input: ArrayBuffer): ArrayBuffer {\n const inputArray = new Uint8Array(input);\n return lz4js.compress(inputArray).buffer;\n }\n\n /**\n * Decompresses an ArrayBuffer containing an Lz4 frame. maxSize is optional; if not\n * provided, a maximum size will be determined by examining the data. The\n * returned ArrayBuffer will always be perfectly sized.\n * If data provided without magic number we will parse it as block\n */\n decompressSync(data: ArrayBuffer, maxSize?: number): ArrayBuffer {\n try {\n const isMagicNumberExists = this.checkMagicNumber(data);\n const inputArray = new Uint8Array(data);\n\n if (isMagicNumberExists) {\n return lz4js.decompress(inputArray, maxSize).buffer;\n }\n\n if (!maxSize) {\n const error = new Error('Need to provide maxSize');\n throw this.improveError(error);\n }\n\n let uncompressed = new Uint8Array(maxSize);\n const uncompressedSize = this.decodeBlock(inputArray, uncompressed);\n uncompressed = uncompressed.slice(0, uncompressedSize);\n\n return toArrayBuffer(uncompressed);\n } catch (error) {\n throw this.improveError(error);\n }\n }\n\n /**\n * Decode lz4 file as block\n * Solution taken from here\n * https://github.com/pierrec/node-lz4/blob/0dac687262403fd34f905b963da7220692f2a4a1/lib/binding.js#L25\n * @param input\n * @param output\n * @param startIndex\n * @param endIndex\n */\n decodeBlock(\n data: Uint8Array,\n output: Uint8Array,\n startIndex?: number,\n endIndex?: number\n ): number {\n startIndex = startIndex || 0;\n endIndex = endIndex || data.length - startIndex;\n\n let uncompressedSize = 0;\n // Process each sequence in the incoming data\n for (let index = startIndex; index < endIndex; ) {\n const token = data[index++];\n\n // Literals\n let literalsLength = token >> 4;\n\n if (literalsLength > 0) {\n // length of literals\n let length = literalsLength + 240;\n\n while (length === 255) {\n length = data[index++];\n literalsLength += length;\n }\n\n // Copy the literals\n const end = index + literalsLength;\n\n while (index < end) {\n output[uncompressedSize++] = data[index++];\n }\n\n // End of buffer?\n if (index === endIndex) {\n return uncompressedSize;\n }\n }\n\n // Match copy\n // 2 bytes offset (little endian)\n const offset = data[index++] | (data[index++] << 8);\n\n // 0 is an invalid offset value\n if (offset === 0 || offset > uncompressedSize) {\n return -(index - 2);\n }\n\n // length of match copy\n let matchLength = token & 0xf;\n let length = matchLength + 240;\n\n while (length === 255) {\n length = data[index++];\n matchLength += length;\n }\n\n // Copy the match\n let pos = uncompressedSize - offset; // position of the match copy in the current output\n const end = uncompressedSize + matchLength + 4; // minmatch = 4\n\n while (uncompressedSize < end) {\n output[uncompressedSize++] = output[pos++];\n }\n }\n\n return uncompressedSize;\n }\n\n /**\n * Compare file magic with lz4 magic number\n * @param input\n */\n checkMagicNumber(data: ArrayBuffer): boolean {\n const magic = new Uint32Array(data.slice(0, 4));\n return magic[0] === LZ4_MAGIC_NUMBER;\n }\n}\n"],"file":"lz4-compression.js"}
1
+ {"version":3,"sources":["../../../src/lib/lz4-compression.ts"],"names":["LZ4_MAGIC_NUMBER","lz4js","LZ4Compression","options","modules","Error","name","input","inputArray","Uint8Array","compress","buffer","data","maxSize","isMagicNumberExists","checkMagicNumber","decompress","error","improveError","uncompressed","uncompressedSize","decodeBlock","slice","output","startIndex","endIndex","length","index","token","literalsLength","end","offset","matchLength","pos","magic","Uint32Array","Compression"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA;;AAEA;;;;;;AAEA,IAAMA,gBAAgB,GAAG,UAAzB;AAEA,IAAIC,KAAJ;;IAKaC,c;;;;;AAOX,0BAAYC,OAAZ,EAAyC;AAAA;;AAAA;;AAAA;AACvC,8BAAMA,OAAN;AADuC,uFANjB,KAMiB;AAAA,6FALnB,CAAC,KAAD,CAKmB;AAAA,mGAJb,CAAC,OAAD,CAIa;AAAA,8FAHlB,IAGkB;AAAA;AAEvC,UAAKA,OAAL,GAAeA,OAAf;AAEAF,IAAAA,KAAK,GAAGA,KAAK,sBAAI,MAAKE,OAAT,2EAAI,cAAcC,OAAlB,0DAAI,sBAAuBH,KAA3B,CAAb;;AACA,QAAI,CAACA,KAAL,EAAY;AACV,YAAM,IAAII,KAAJ,CAAU,MAAKC,IAAf,CAAN;AACD;;AAPsC;AAQxC;;;;WAED,sBAAaC,KAAb,EAA8C;AAC5C,UAAMC,UAAU,GAAG,IAAIC,UAAJ,CAAeF,KAAf,CAAnB;AACA,aAAON,KAAK,CAACS,QAAN,CAAeF,UAAf,EAA2BG,MAAlC;AACD;;;WAQD,wBAAeC,IAAf,EAAkCC,OAAlC,EAAiE;AAC/D,UAAI;AACF,YAAMC,mBAAmB,GAAG,KAAKC,gBAAL,CAAsBH,IAAtB,CAA5B;AACA,YAAMJ,UAAU,GAAG,IAAIC,UAAJ,CAAeG,IAAf,CAAnB;;AAEA,YAAIE,mBAAJ,EAAyB;AACvB,iBAAOb,KAAK,CAACe,UAAN,CAAiBR,UAAjB,EAA6BK,OAA7B,EAAsCF,MAA7C;AACD;;AAED,YAAI,CAACE,OAAL,EAAc;AACZ,cAA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e,KAAK,EAAN,CAAjC;AACD;;AAGD,cAAIA,KAAK,KAAKF,QAAd,EAAwB;AACtB,mBAAOL,gBAAP;AACD;AACF;;AAID,YAAMW,MAAM,GAAGnB,IAAI,CAACe,KAAK,EAAN,CAAJ,GAAiBf,IAAI,CAACe,KAAK,EAAN,CAAJ,IAAiB,CAAjD;;AAGA,YAAII,MAAM,KAAK,CAAX,IAAgBA,MAAM,GAAGX,gBAA7B,EAA+C;AAC7C,iBAAO,EAAEO,KAAK,GAAG,CAAV,CAAP;AACD;;AAGD,YAAIK,WAAW,GAAGJ,KAAK,GAAG,GAA1B;AACA,YAAIF,MAAM,GAAGM,WAAW,GAAG,GAA3B;;AAEA,eAAON,MAAM,KAAK,GAAlB,EAAuB;AACrBA,UAAAA,MAAM,GAAGd,IAAI,CAACe,KAAK,EAAN,CAAb;AACAK,UAAAA,WAAW,IAAIN,MAAf;AACD;;AAGD,YAAIO,GAAG,GAAGb,gBAAgB,GAAGW,MAA7B;AACA,YAAMD,GAAG,GAAGV,gBAAgB,GAAGY,WAAnB,GAAiC,CAA7C;;AAEA,eAAOZ,gBAAgB,GAAGU,GAA1B,EAA+B;AAC7BP,UAAAA,MAAM,CAACH,gBAAgB,EAAjB,CAAN,GAA6BG,MAAM,CAACU,GAAG,EAAJ,CAAnC;AACD;AACF;;AAED,aAAOb,gBAAP;AACD;;;WAMD,0BAAiBR,IAAjB,EAA6C;AAC3C,UAAMsB,KAAK,GAAG,IAAIC,WAAJ,CAAgBvB,IAAI,CAACU,KAAL,CAAW,CAAX,EAAc,CAAd,CAAhB,CAAd;AACA,aAAOY,KAAK,CAAC,CAAD,CAAL,KAAalC,gBAApB;AACD;;;EAzIiCoC,wB","sourcesContent":["// Copyright (c) 2012 Pierre Curto\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\n\n// LZ4\nimport {toArrayBuffer} from '@loaders.gl/loader-utils';\nimport type {CompressionOptions} from './compression';\nimport {Compression} from './compression';\n// import lz4js from 'lz4js'; // https://bundlephobia.com/package/lz4\nconst LZ4_MAGIC_NUMBER = 0x184d2204;\n\nlet lz4js;\n\n/**\n * LZ4 compression / decompression\n */\nexport class LZ4Compression extends Compression {\n readonly name: string = 'lz4';\n readonly extensions = ['lz4'];\n readonly contentEncodings = ['x-lz4'];\n readonly isSupported = true;\n readonly options: CompressionOptions;\n\n constructor(options: CompressionOptions) {\n super(options);\n this.options = options;\n\n lz4js = lz4js || this.options?.modules?.lz4js;\n if (!lz4js) {\n throw new Error(this.name);\n }\n }\n\n compressSync(input: ArrayBuffer): ArrayBuffer {\n const inputArray = new Uint8Array(input);\n return lz4js.compress(inputArray).buffer;\n }\n\n /**\n * Decompresses an ArrayBuffer containing an Lz4 frame. maxSize is optional; if not\n * provided, a maximum size will be determined by examining the data. The\n * returned ArrayBuffer will always be perfectly sized.\n * If data provided without magic number we will parse it as block\n */\n decompressSync(data: ArrayBuffer, maxSize?: number): ArrayBuffer {\n try {\n const isMagicNumberExists = this.checkMagicNumber(data);\n const inputArray = new Uint8Array(data);\n\n if (isMagicNumberExists) {\n return lz4js.decompress(inputArray, maxSize).buffer;\n }\n\n if (!maxSize) {\n const error = new Error('Need to provide maxSize');\n throw this.improveError(error);\n }\n\n let uncompressed = new Uint8Array(maxSize);\n const uncompressedSize = this.decodeBlock(inputArray, uncompressed);\n uncompressed = uncompressed.slice(0, uncompressedSize);\n\n return toArrayBuffer(uncompressed);\n } catch (error) {\n throw this.improveError(error);\n }\n }\n\n /**\n * Decode lz4 file as block\n * Solution taken from here\n * https://github.com/pierrec/node-lz4/blob/0dac687262403fd34f905b963da7220692f2a4a1/lib/binding.js#L25\n * @param input\n * @param output\n * @param startIndex\n * @param endIndex\n */\n decodeBlock(\n data: Uint8Array,\n output: Uint8Array,\n startIndex?: number,\n endIndex?: number\n ): number {\n startIndex = startIndex || 0;\n endIndex = endIndex || data.length - startIndex;\n\n let uncompressedSize = 0;\n // Process each sequence in the incoming data\n for (let index = startIndex; index < endIndex; ) {\n const token = data[index++];\n\n // Literals\n let literalsLength = token >> 4;\n\n if (literalsLength > 0) {\n // length of literals\n let length = literalsLength + 240;\n\n while (length === 255) {\n length = data[index++];\n literalsLength += length;\n }\n\n // Copy the literals\n const end = index + literalsLength;\n\n while (index < end) {\n output[uncompressedSize++] = data[index++];\n }\n\n // End of buffer?\n if (index === endIndex) {\n return uncompressedSize;\n }\n }\n\n // Match copy\n // 2 bytes offset (little endian)\n const offset = data[index++] | (data[index++] << 8);\n\n // 0 is an invalid offset value\n if (offset === 0 || offset > uncompressedSize) {\n return -(index - 2);\n }\n\n // length of match copy\n let matchLength = token & 0xf;\n let length = matchLength + 240;\n\n while (length === 255) {\n length = data[index++];\n matchLength += length;\n }\n\n // Copy the match\n let pos = uncompressedSize - offset; // position of the match copy in the current output\n const end = uncompressedSize + matchLength + 4; // minmatch = 4\n\n while (uncompressedSize < end) {\n output[uncompressedSize++] = output[pos++];\n }\n }\n\n return uncompressedSize;\n }\n\n /**\n * Compare file magic with lz4 magic number\n * @param input\n */\n checkMagicNumber(data: ArrayBuffer): boolean {\n const magic = new Uint32Array(data.slice(0, 4));\n return magic[0] === LZ4_MAGIC_NUMBER;\n }\n}\n"],"file":"lz4-compression.js"}
@@ -7,51 +7,151 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.LZOCompression = void 0;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
14
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
+
16
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
+
18
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
+
20
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
+
22
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
23
+
24
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
25
+
10
26
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
27
 
12
28
  var _loaderUtils = require("@loaders.gl/loader-utils");
13
29
 
14
30
  var _compression = require("./compression");
15
31
 
16
- let lzo;
32
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
33
+
34
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
35
+
36
+ var lzo;
17
37
 
18
- class LZOCompression extends _compression.Compression {
19
- constructor(options) {
38
+ var LZOCompression = function (_Compression) {
39
+ (0, _inherits2.default)(LZOCompression, _Compression);
40
+
41
+ var _super = _createSuper(LZOCompression);
42
+
43
+ function LZOCompression(options) {
20
44
  var _this$options, _this$options$modules;
21
45
 
22
- super(options);
23
- (0, _defineProperty2.default)(this, "name", 'lzo');
24
- (0, _defineProperty2.default)(this, "extensions", []);
25
- (0, _defineProperty2.default)(this, "contentEncodings", []);
26
- (0, _defineProperty2.default)(this, "isSupported", false);
27
- (0, _defineProperty2.default)(this, "options", void 0);
28
- this.options = options;
29
- lzo = lzo || ((_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.lzo);
46
+ var _this;
47
+
48
+ (0, _classCallCheck2.default)(this, LZOCompression);
49
+ _this = _super.call(this, options);
50
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "name", 'lzo');
51
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "extensions", []);
52
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "contentEncodings", []);
53
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isSupported", false);
54
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "options", void 0);
55
+ _this.options = options;
56
+ lzo = lzo || ((_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.lzo);
30
57
 
31
58
  if (!lzo) {
32
- throw new Error(this.name);
59
+ throw new Error(_this.name);
33
60
  }
61
+
62
+ return _this;
34
63
  }
35
64
 
36
- async preload() {}
65
+ (0, _createClass2.default)(LZOCompression, [{
66
+ key: "preload",
67
+ value: function () {
68
+ var _preload = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
69
+ return _regenerator.default.wrap(function _callee$(_context) {
70
+ while (1) {
71
+ switch (_context.prev = _context.next) {
72
+ case 0:
73
+ case "end":
74
+ return _context.stop();
75
+ }
76
+ }
77
+ }, _callee);
78
+ }));
37
79
 
38
- async compress(input) {
39
- await this.preload();
40
- const inputBuffer = (0, _loaderUtils.toBuffer)(input);
41
- return lzo.compress(inputBuffer).buffer;
42
- }
80
+ function preload() {
81
+ return _preload.apply(this, arguments);
82
+ }
43
83
 
44
- async decompress(input) {
45
- try {
46
- await this.preload();
47
- const inputBuffer = (0, _loaderUtils.toBuffer)(input);
48
- return lzo.decompress(inputBuffer).buffer;
49
- } catch (error) {
50
- throw error;
51
- }
52
- }
84
+ return preload;
85
+ }()
86
+ }, {
87
+ key: "compress",
88
+ value: function () {
89
+ var _compress = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(input) {
90
+ var inputBuffer;
91
+ return _regenerator.default.wrap(function _callee2$(_context2) {
92
+ while (1) {
93
+ switch (_context2.prev = _context2.next) {
94
+ case 0:
95
+ _context2.next = 2;
96
+ return this.preload();
97
+
98
+ case 2:
99
+ inputBuffer = (0, _loaderUtils.toBuffer)(input);
100
+ return _context2.abrupt("return", lzo.compress(inputBuffer).buffer);
101
+
102
+ case 4:
103
+ case "end":
104
+ return _context2.stop();
105
+ }
106
+ }
107
+ }, _callee2, this);
108
+ }));
109
+
110
+ function compress(_x) {
111
+ return _compress.apply(this, arguments);
112
+ }
113
+
114
+ return compress;
115
+ }()
116
+ }, {
117
+ key: "decompress",
118
+ value: function () {
119
+ var _decompress = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(input) {
120
+ var inputBuffer;
121
+ return _regenerator.default.wrap(function _callee3$(_context3) {
122
+ while (1) {
123
+ switch (_context3.prev = _context3.next) {
124
+ case 0:
125
+ _context3.prev = 0;
126
+ _context3.next = 3;
127
+ return this.preload();
128
+
129
+ case 3:
130
+ inputBuffer = (0, _loaderUtils.toBuffer)(input);
131
+ return _context3.abrupt("return", lzo.decompress(inputBuffer).buffer);
132
+
133
+ case 7:
134
+ _context3.prev = 7;
135
+ _context3.t0 = _context3["catch"](0);
136
+ throw _context3.t0;
137
+
138
+ case 10:
139
+ case "end":
140
+ return _context3.stop();
141
+ }
142
+ }
143
+ }, _callee3, this, [[0, 7]]);
144
+ }));
145
+
146
+ function decompress(_x2) {
147
+ return _decompress.apply(this, arguments);
148
+ }
53
149
 
54
- }
150
+ return decompress;
151
+ }()
152
+ }]);
153
+ return LZOCompression;
154
+ }(_compression.Compression);
55
155
 
56
156
  exports.LZOCompression = LZOCompression;
57
157
  //# sourceMappingURL=lzo-compression.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/lzo-compression.ts"],"names":["lzo","LZOCompression","Compression","constructor","options","modules","Error","name","preload","compress","input","inputBuffer","buffer","decompress","error"],"mappings":";;;;;;;;;;;AAEA;;AAGA;;AASA,IAAIA,GAAJ;;AAKO,MAAMC,cAAN,SAA6BC,wBAA7B,CAAyC;AAW9CC,EAAAA,WAAW,CAACC,OAAD,EAA8B;AAAA;;AACvC,UAAMA,OAAN;AADuC,gDAVzB,KAUyB;AAAA,sDATnB,EASmB;AAAA,4DARb,EAQa;AAAA,uDAPlB,KAOkB;AAAA;AAEvC,SAAKA,OAAL,GAAeA,OAAf;AAEAJ,IAAAA,GAAG,GAAGA,GAAG,sBAAI,KAAKI,OAAT,2EAAI,cAAcC,OAAlB,0DAAI,sBAAuBL,GAA3B,CAAT;;AACA,QAAI,CAACA,GAAL,EAAU;AACR,YAAM,IAAIM,KAAJ,CAAU,KAAKC,IAAf,CAAN;AACD;AACF;;AAEY,QAAPC,OAAO,GAAG,CAGf;;AAEa,QAARC,QAAQ,CAACC,KAAD,EAA2C;AACvD,UAAM,KAAKF,OAAL,EAAN;AAEA,UAAMG,WAAW,GAAG,2BAASD,KAAT,CAApB;AACA,WAAOV,GAAG,CAACS,QAAJ,CAAaE,WAAb,EAA0BC,MAAjC;AACD;;AAEe,QAAVC,UAAU,CAACH,KAAD,EAA2C;AACzD,QAAI;AACF,YAAM,KAAKF,OAAL,EAAN;AAEA,YAAMG,WAAW,GAAG,2BAASD,KAAT,CAApB;AACA,aAAOV,GAAG,CAACa,UAAJ,CAAeF,WAAf,EAA4BC,MAAnC;AACD,KALD,CAKE,OAAOE,KAAP,EAAc;AAGd,YAAMA,KAAN;AACD;AACF;;AA5C6C","sourcesContent":["// LZO\n// import {loadLibrary} from '@loaders.gl/worker-utils';\nimport {toBuffer} from '@loaders.gl/loader-utils';\n\nimport type {CompressionOptions} from './compression';\nimport {Compression} from './compression';\n// import {isBrowser} from '@loaders.gl/loader-utils';\n\n// import lzo from 'lzo'; // https://bundlephobia.com/package/lzo\n// import {decompress} from 'lzo-wasm';\n\n// const LZO_WASM_JS_URL = './node_modules/lzo-wasm/lzo-wasm.js';\n// const LZO_WASM_WASM_URL = './node_modules/lzo-wasm/lzo-wasm.wasm';\n\nlet lzo;\n\n/**\n * Lempel-Ziv-Oberheimer compression / decompression\n */\nexport class LZOCompression extends Compression {\n readonly name = 'lzo';\n readonly extensions = [];\n readonly contentEncodings = [];\n readonly isSupported = false; // !isBrowser;\n readonly options: CompressionOptions;\n\n /**\n * lzo 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 lzo = lzo || this.options?.modules?.lzo;\n if (!lzo) {\n throw new Error(this.name);\n }\n }\n\n async preload() {\n // await loadLibrary(LZO_WASM_JS_URL);\n // await loadLibrary(LZO_WASM_WASM_URL);\n }\n\n async compress(input: ArrayBuffer): Promise<ArrayBuffer> {\n await this.preload();\n // const inputArray = new Uint8Array(input);\n const inputBuffer = toBuffer(input);\n return lzo.compress(inputBuffer).buffer;\n }\n\n async decompress(input: ArrayBuffer): Promise<ArrayBuffer> {\n try {\n await this.preload();\n // const inputArray = new Uint8Array(input);\n const inputBuffer = toBuffer(input);\n return lzo.decompress(inputBuffer).buffer;\n } catch (error) {\n // TODO - solve SharedArrayBuffer issues\n // return decompress(input);\n throw error;\n }\n }\n}\n"],"file":"lzo-compression.js"}
1
+ {"version":3,"sources":["../../../src/lib/lzo-compression.ts"],"names":["lzo","LZOCompression","options","modules","Error","name","input","preload","inputBuffer","compress","buffer","decompress","Compression"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AAGA;;;;;;AASA,IAAIA,GAAJ;;IAKaC,c;;;;;AAWX,0BAAYC,OAAZ,EAAyC;AAAA;;AAAA;;AAAA;AACvC,8BAAMA,OAAN;AADuC,uFAVzB,KAUyB;AAAA,6FATnB,EASmB;AAAA,mGARb,EAQa;AAAA,8FAPlB,KAOkB;AAAA;AAEvC,UAAKA,OAAL,GAAeA,OAAf;AAEAF,IAAAA,GAAG,GAAGA,GAAG,sBAAI,MAAKE,OAAT,2EAAI,cAAcC,OAAlB,0DAAI,sBAAuBH,GAA3B,CAAT;;AACA,QAAI,CAACA,GAAL,EAAU;AACR,YAAM,IAAII,KAAJ,CAAU,MAAKC,IAAf,CAAN;AACD;;AAPsC;AAQxC;;;;;+EAED;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;gFAKA,kBAAeC,KAAf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBACQ,KAAKC,OAAL,EADR;;AAAA;AAGQC,gBAAAA,WAHR,GAGsB,2BAASF,KAAT,CAHtB;AAAA,kDAISN,GAAG,CAACS,QAAJ,CAAaD,WAAb,EAA0BE,MAJnC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;kFAOA,kBAAiBJ,KAAjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAEU,KAAKC,OAAL,EAFV;;AAAA;AAIUC,gBAAAA,WAJV,GAIwB,2BAASF,KAAT,CAJxB;AAAA,kDAKWN,GAAG,CAACW,UAAJ,CAAeH,WAAf,EAA4BE,MALvC;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAjCkCE,wB","sourcesContent":["// LZO\n// import {loadLibrary} from '@loaders.gl/worker-utils';\nimport {toBuffer} from '@loaders.gl/loader-utils';\n\nimport type {CompressionOptions} from './compression';\nimport {Compression} from './compression';\n// import {isBrowser} from '@loaders.gl/loader-utils';\n\n// import lzo from 'lzo'; // https://bundlephobia.com/package/lzo\n// import {decompress} from 'lzo-wasm';\n\n// const LZO_WASM_JS_URL = './node_modules/lzo-wasm/lzo-wasm.js';\n// const LZO_WASM_WASM_URL = './node_modules/lzo-wasm/lzo-wasm.wasm';\n\nlet lzo;\n\n/**\n * Lempel-Ziv-Oberheimer compression / decompression\n */\nexport class LZOCompression extends Compression {\n readonly name = 'lzo';\n readonly extensions = [];\n readonly contentEncodings = [];\n readonly isSupported = false; // !isBrowser;\n readonly options: CompressionOptions;\n\n /**\n * lzo 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 lzo = lzo || this.options?.modules?.lzo;\n if (!lzo) {\n throw new Error(this.name);\n }\n }\n\n async preload() {\n // await loadLibrary(LZO_WASM_JS_URL);\n // await loadLibrary(LZO_WASM_WASM_URL);\n }\n\n async compress(input: ArrayBuffer): Promise<ArrayBuffer> {\n await this.preload();\n // const inputArray = new Uint8Array(input);\n const inputBuffer = toBuffer(input);\n return lzo.compress(inputBuffer).buffer;\n }\n\n async decompress(input: ArrayBuffer): Promise<ArrayBuffer> {\n try {\n await this.preload();\n // const inputArray = new Uint8Array(input);\n const inputBuffer = toBuffer(input);\n return lzo.decompress(inputBuffer).buffer;\n } catch (error) {\n // TODO - solve SharedArrayBuffer issues\n // return decompress(input);\n throw error;\n }\n }\n}\n"],"file":"lzo-compression.js"}
@@ -7,38 +7,110 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.NoCompression = void 0;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
20
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
22
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
+
10
24
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
25
 
26
+ var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
27
+
28
+ var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
29
+
30
+ var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncIterator"));
31
+
32
+ var _asyncGeneratorDelegate2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncGeneratorDelegate"));
33
+
12
34
  var _compression = require("./compression");
13
35
 
14
- class NoCompression extends _compression.Compression {
15
- constructor(options) {
16
- super(options);
17
- (0, _defineProperty2.default)(this, "name", 'uncompressed');
18
- (0, _defineProperty2.default)(this, "extensions", []);
19
- (0, _defineProperty2.default)(this, "contentEncodings", []);
20
- (0, _defineProperty2.default)(this, "isSupported", true);
21
- (0, _defineProperty2.default)(this, "options", void 0);
22
- this.options = options || {};
23
- }
36
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
24
37
 
25
- compressSync(input) {
26
- return input;
27
- }
38
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
28
39
 
29
- decompressSync(input) {
30
- return input;
31
- }
40
+ var NoCompression = function (_Compression) {
41
+ (0, _inherits2.default)(NoCompression, _Compression);
32
42
 
33
- async *compressBatches(asyncIterator) {
34
- return yield* asyncIterator;
35
- }
43
+ var _super = _createSuper(NoCompression);
36
44
 
37
- async *decompressBatches(asyncIterator) {
38
- return yield* asyncIterator;
45
+ function NoCompression(options) {
46
+ var _this;
47
+
48
+ (0, _classCallCheck2.default)(this, NoCompression);
49
+ _this = _super.call(this, options);
50
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "name", 'uncompressed');
51
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "extensions", []);
52
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "contentEncodings", []);
53
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isSupported", true);
54
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "options", void 0);
55
+ _this.options = options || {};
56
+ return _this;
39
57
  }
40
58
 
41
- }
59
+ (0, _createClass2.default)(NoCompression, [{
60
+ key: "compressSync",
61
+ value: function compressSync(input) {
62
+ return input;
63
+ }
64
+ }, {
65
+ key: "decompressSync",
66
+ value: function decompressSync(input) {
67
+ return input;
68
+ }
69
+ }, {
70
+ key: "compressBatches",
71
+ value: function compressBatches(asyncIterator) {
72
+ return (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee() {
73
+ return _regenerator.default.wrap(function _callee$(_context) {
74
+ while (1) {
75
+ switch (_context.prev = _context.next) {
76
+ case 0:
77
+ return _context.delegateYield((0, _asyncGeneratorDelegate2.default)((0, _asyncIterator2.default)(asyncIterator), _awaitAsyncGenerator2.default), "t0", 1);
78
+
79
+ case 1:
80
+ return _context.abrupt("return", _context.t0);
81
+
82
+ case 2:
83
+ case "end":
84
+ return _context.stop();
85
+ }
86
+ }
87
+ }, _callee);
88
+ }))();
89
+ }
90
+ }, {
91
+ key: "decompressBatches",
92
+ value: function decompressBatches(asyncIterator) {
93
+ return (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee2() {
94
+ return _regenerator.default.wrap(function _callee2$(_context2) {
95
+ while (1) {
96
+ switch (_context2.prev = _context2.next) {
97
+ case 0:
98
+ return _context2.delegateYield((0, _asyncGeneratorDelegate2.default)((0, _asyncIterator2.default)(asyncIterator), _awaitAsyncGenerator2.default), "t0", 1);
99
+
100
+ case 1:
101
+ return _context2.abrupt("return", _context2.t0);
102
+
103
+ case 2:
104
+ case "end":
105
+ return _context2.stop();
106
+ }
107
+ }
108
+ }, _callee2);
109
+ }))();
110
+ }
111
+ }]);
112
+ return NoCompression;
113
+ }(_compression.Compression);
42
114
 
43
115
  exports.NoCompression = NoCompression;
44
116
  //# sourceMappingURL=no-compression.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/no-compression.ts"],"names":["NoCompression","Compression","constructor","options","compressSync","input","decompressSync","compressBatches","asyncIterator","decompressBatches"],"mappings":";;;;;;;;;;;AAEA;;AAKO,MAAMA,aAAN,SAA4BC,wBAA5B,CAAwC;AAQ7CC,EAAAA,WAAW,CAACC,OAAD,EAA+B;AACxC,UAAMA,OAAN;AADwC,gDAPlB,cAOkB;AAAA,sDANV,EAMU;AAAA,4DALJ,EAKI;AAAA,uDAJnB,IAImB;AAAA;AAExC,SAAKA,OAAL,GAAeA,OAAO,IAAI,EAA1B;AACD;;AAEDC,EAAAA,YAAY,CAACC,KAAD,EAAkC;AAC5C,WAAOA,KAAP;AACD;;AAEDC,EAAAA,cAAc,CAACD,KAAD,EAAkC;AAC9C,WAAOA,KAAP;AACD;;AAEqB,SAAfE,eAAe,CACpBC,aADoB,EAEQ;AAC5B,WAAO,OAAOA,aAAd;AACD;;AAEuB,SAAjBC,iBAAiB,CACtBD,aADsB,EAEM;AAC5B,WAAO,OAAOA,aAAd;AACD;;AA/B4C","sourcesContent":["// NO COMPRESSION\nimport type {CompressionOptions} from './compression';\nimport {Compression} from './compression';\n\n/**\n * Applies no compression.\n */\nexport class NoCompression extends Compression {\n readonly name: string = 'uncompressed';\n readonly extensions: string[] = [];\n readonly contentEncodings: string[] = [];\n readonly isSupported = true;\n\n readonly options: CompressionOptions;\n\n constructor(options?: CompressionOptions) {\n super(options);\n this.options = options || {};\n }\n\n compressSync(input: ArrayBuffer): ArrayBuffer {\n return input;\n }\n\n decompressSync(input: ArrayBuffer): ArrayBuffer {\n return input;\n }\n\n async *compressBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n ): AsyncIterable<ArrayBuffer> {\n return yield* asyncIterator;\n }\n\n async *decompressBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n ): AsyncIterable<ArrayBuffer> {\n return yield* asyncIterator;\n }\n}\n"],"file":"no-compression.js"}
1
+ {"version":3,"sources":["../../../src/lib/no-compression.ts"],"names":["NoCompression","options","input","asyncIterator","Compression"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;;IAKaA,a;;;;;AAQX,yBAAYC,OAAZ,EAA0C;AAAA;;AAAA;AACxC,8BAAMA,OAAN;AADwC,uFAPlB,cAOkB;AAAA,6FANV,EAMU;AAAA,mGALJ,EAKI;AAAA,8FAJnB,IAImB;AAAA;AAExC,UAAKA,OAAL,GAAeA,OAAO,IAAI,EAA1B;AAFwC;AAGzC;;;;WAED,sBAAaC,KAAb,EAA8C;AAC5C,aAAOA,KAAP;AACD;;;WAED,wBAAeA,KAAf,EAAgD;AAC9C,aAAOA,KAAP;AACD;;;WAED,yBACEC,aADF,EAE8B;AAAA;AAAA;AAAA;AAAA;AAAA;AACrB,iHAAOA,aAAP;;AADqB;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE7B;;;WAED,2BACEA,aADF,EAE8B;AAAA;AAAA;AAAA;AAAA;AAAA;AACrB,kHAAOA,aAAP;;AADqB;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE7B;;;EA/BgCC,wB","sourcesContent":["// NO COMPRESSION\nimport type {CompressionOptions} from './compression';\nimport {Compression} from './compression';\n\n/**\n * Applies no compression.\n */\nexport class NoCompression extends Compression {\n readonly name: string = 'uncompressed';\n readonly extensions: string[] = [];\n readonly contentEncodings: string[] = [];\n readonly isSupported = true;\n\n readonly options: CompressionOptions;\n\n constructor(options?: CompressionOptions) {\n super(options);\n this.options = options || {};\n }\n\n compressSync(input: ArrayBuffer): ArrayBuffer {\n return input;\n }\n\n decompressSync(input: ArrayBuffer): ArrayBuffer {\n return input;\n }\n\n async *compressBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n ): AsyncIterable<ArrayBuffer> {\n return yield* asyncIterator;\n }\n\n async *decompressBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n ): AsyncIterable<ArrayBuffer> {\n return yield* asyncIterator;\n }\n}\n"],"file":"no-compression.js"}