@loaders.gl/compression 4.2.0-alpha.5 → 4.2.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/dist.dev.js CHANGED
@@ -12,6 +12,7 @@ var __exports__ = (() => {
12
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
13
13
  var __getProtoOf = Object.getPrototypeOf;
14
14
  var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
16
  var __commonJS = (cb, mod) => function __require() {
16
17
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
18
  };
@@ -37,6 +38,10 @@ var __exports__ = (() => {
37
38
  mod
38
39
  ));
39
40
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __publicField = (obj, key, value) => {
42
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
43
+ return value;
44
+ };
40
45
 
41
46
  // external-global-plugin:@loaders.gl/core
42
47
  var require_core = __commonJS({
@@ -4732,12 +4737,16 @@ var __exports__ = (() => {
4732
4737
 
4733
4738
  // ../worker-utils/src/lib/worker-farm/worker-job.ts
4734
4739
  var WorkerJob = class {
4740
+ name;
4741
+ workerThread;
4742
+ isRunning = true;
4743
+ /** Promise that resolves when Job is done */
4744
+ result;
4745
+ _resolve = () => {
4746
+ };
4747
+ _reject = () => {
4748
+ };
4735
4749
  constructor(jobName, workerThread) {
4736
- this.isRunning = true;
4737
- this._resolve = () => {
4738
- };
4739
- this._reject = () => {
4740
- };
4741
4750
  this.name = jobName;
4742
4751
  this.workerThread = workerThread;
4743
4752
  this.result = new Promise((resolve, reject) => {
@@ -4874,9 +4883,19 @@ var __exports__ = (() => {
4874
4883
  var NOOP = () => {
4875
4884
  };
4876
4885
  var WorkerThread = class {
4886
+ name;
4887
+ source;
4888
+ url;
4889
+ terminated = false;
4890
+ worker;
4891
+ onMessage;
4892
+ onError;
4893
+ _loadableURL = "";
4894
+ /** Checks if workers are supported on this platform */
4895
+ static isSupported() {
4896
+ return typeof Worker !== "undefined" && isBrowser2 || typeof NodeWorker !== "undefined" && !isBrowser2;
4897
+ }
4877
4898
  constructor(props) {
4878
- this.terminated = false;
4879
- this._loadableURL = "";
4880
4899
  const { name, source, url } = props;
4881
4900
  assert(source || url);
4882
4901
  this.name = name;
@@ -4886,10 +4905,6 @@ var __exports__ = (() => {
4886
4905
  this.onError = (error) => console.log(error);
4887
4906
  this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
4888
4907
  }
4889
- /** Checks if workers are supported on this platform */
4890
- static isSupported() {
4891
- return typeof Worker !== "undefined" && isBrowser2 || typeof NodeWorker !== "undefined" && !isBrowser2;
4892
- }
4893
4908
  /**
4894
4909
  * Terminate this worker thread
4895
4910
  * @note Can free up significant memory
@@ -4977,30 +4992,33 @@ var __exports__ = (() => {
4977
4992
 
4978
4993
  // ../worker-utils/src/lib/worker-farm/worker-pool.ts
4979
4994
  var WorkerPool = class {
4995
+ name = "unnamed";
4996
+ source;
4997
+ // | Function;
4998
+ url;
4999
+ maxConcurrency = 1;
5000
+ maxMobileConcurrency = 1;
5001
+ onDebug = () => {
5002
+ };
5003
+ reuseWorkers = true;
5004
+ props = {};
5005
+ jobQueue = [];
5006
+ idleQueue = [];
5007
+ count = 0;
5008
+ isDestroyed = false;
5009
+ /** Checks if workers are supported on this platform */
5010
+ static isSupported() {
5011
+ return WorkerThread.isSupported();
5012
+ }
4980
5013
  /**
4981
5014
  * @param processor - worker function
4982
5015
  * @param maxConcurrency - max count of workers
4983
5016
  */
4984
5017
  constructor(props) {
4985
- this.name = "unnamed";
4986
- this.maxConcurrency = 1;
4987
- this.maxMobileConcurrency = 1;
4988
- this.onDebug = () => {
4989
- };
4990
- this.reuseWorkers = true;
4991
- this.props = {};
4992
- this.jobQueue = [];
4993
- this.idleQueue = [];
4994
- this.count = 0;
4995
- this.isDestroyed = false;
4996
5018
  this.source = props.source;
4997
5019
  this.url = props.url;
4998
5020
  this.setProps(props);
4999
5021
  }
5000
- /** Checks if workers are supported on this platform */
5001
- static isSupported() {
5002
- return WorkerThread.isSupported();
5003
- }
5004
5022
  /**
5005
5023
  * Terminates all workers in the pool
5006
5024
  * @note Can free up significant memory
@@ -5123,23 +5141,24 @@ var __exports__ = (() => {
5123
5141
  onDebug: () => {
5124
5142
  }
5125
5143
  };
5126
- var WorkerFarm = class {
5127
- /** get global instance with WorkerFarm.getWorkerFarm() */
5128
- constructor(props) {
5129
- this.workerPools = /* @__PURE__ */ new Map();
5130
- this.props = { ...DEFAULT_PROPS };
5131
- this.setProps(props);
5132
- this.workerPools = /* @__PURE__ */ new Map();
5133
- }
5144
+ var _WorkerFarm = class {
5145
+ props;
5146
+ workerPools = /* @__PURE__ */ new Map();
5134
5147
  /** Checks if workers are supported on this platform */
5135
5148
  static isSupported() {
5136
5149
  return WorkerThread.isSupported();
5137
5150
  }
5138
5151
  /** Get the singleton instance of the global worker farm */
5139
5152
  static getWorkerFarm(props = {}) {
5140
- WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({});
5141
- WorkerFarm._workerFarm.setProps(props);
5142
- return WorkerFarm._workerFarm;
5153
+ _WorkerFarm._workerFarm = _WorkerFarm._workerFarm || new _WorkerFarm({});
5154
+ _WorkerFarm._workerFarm.setProps(props);
5155
+ return _WorkerFarm._workerFarm;
5156
+ }
5157
+ /** get global instance with WorkerFarm.getWorkerFarm() */
5158
+ constructor(props) {
5159
+ this.props = { ...DEFAULT_PROPS };
5160
+ this.setProps(props);
5161
+ this.workerPools = /* @__PURE__ */ new Map();
5143
5162
  }
5144
5163
  /**
5145
5164
  * Terminate all workers in the farm
@@ -5193,6 +5212,9 @@ var __exports__ = (() => {
5193
5212
  };
5194
5213
  }
5195
5214
  };
5215
+ var WorkerFarm = _WorkerFarm;
5216
+ // singleton
5217
+ __publicField(WorkerFarm, "_workerFarm");
5196
5218
 
5197
5219
  // ../worker-utils/src/lib/worker-api/get-worker-url.ts
5198
5220
  function getWorkerName(worker) {
@@ -5398,12 +5420,13 @@ var __exports__ = (() => {
5398
5420
 
5399
5421
  // src/lib/no-compression.ts
5400
5422
  var NoCompression = class extends Compression {
5423
+ name = "uncompressed";
5424
+ extensions = [];
5425
+ contentEncodings = [];
5426
+ isSupported = true;
5427
+ options;
5401
5428
  constructor(options) {
5402
5429
  super(options);
5403
- this.name = "uncompressed";
5404
- this.extensions = [];
5405
- this.contentEncodings = [];
5406
- this.isSupported = true;
5407
5430
  this.options = options || {};
5408
5431
  }
5409
5432
  compressSync(input) {
@@ -5424,13 +5447,14 @@ var __exports__ = (() => {
5424
5447
  var import_pako = __toESM(require_pako(), 1);
5425
5448
  var import_zlib = __toESM(require_zlib(), 1);
5426
5449
  var DeflateCompression = class extends Compression {
5450
+ name = "deflate";
5451
+ extensions = [];
5452
+ contentEncodings = ["deflate"];
5453
+ isSupported = true;
5454
+ options;
5455
+ _chunks = [];
5427
5456
  constructor(options = {}) {
5428
5457
  super(options);
5429
- this.name = "deflate";
5430
- this.extensions = [];
5431
- this.contentEncodings = ["deflate"];
5432
- this.isSupported = true;
5433
- this._chunks = [];
5434
5458
  this.options = options;
5435
5459
  }
5436
5460
  async compress(input) {
@@ -5537,12 +5561,12 @@ var __exports__ = (() => {
5537
5561
 
5538
5562
  // src/lib/gzip-compression.ts
5539
5563
  var GZipCompression = class extends DeflateCompression {
5564
+ name = "gzip";
5565
+ extensions = ["gz", "gzip"];
5566
+ contentEncodings = ["gzip", "x-gzip"];
5567
+ isSupported = true;
5540
5568
  constructor(options) {
5541
5569
  super({ ...options, deflate: { ...options?.gzip, gzip: true } });
5542
- this.name = "gzip";
5543
- this.extensions = ["gz", "gzip"];
5544
- this.contentEncodings = ["gzip", "x-gzip"];
5545
- this.isSupported = true;
5546
5570
  }
5547
5571
  };
5548
5572
 
@@ -7623,12 +7647,13 @@ var __exports__ = (() => {
7623
7647
  };
7624
7648
  var brotli;
7625
7649
  var BrotliCompression = class extends Compression {
7650
+ name = "brotli";
7651
+ extensions = ["br"];
7652
+ contentEncodings = ["br"];
7653
+ isSupported = true;
7654
+ options;
7626
7655
  constructor(options) {
7627
7656
  super(options);
7628
- this.name = "brotli";
7629
- this.extensions = ["br"];
7630
- this.contentEncodings = ["br"];
7631
- this.isSupported = true;
7632
7657
  this.options = options;
7633
7658
  }
7634
7659
  /**
@@ -7687,12 +7712,13 @@ var __exports__ = (() => {
7687
7712
  // src/lib/snappy-compression.ts
7688
7713
  var import_snappyjs = __toESM(require_snappyjs(), 1);
7689
7714
  var SnappyCompression = class extends Compression {
7715
+ name = "snappy";
7716
+ extensions = [];
7717
+ contentEncodings = [];
7718
+ isSupported = true;
7719
+ options;
7690
7720
  constructor(options) {
7691
7721
  super(options);
7692
- this.name = "snappy";
7693
- this.extensions = [];
7694
- this.contentEncodings = [];
7695
- this.isSupported = true;
7696
7722
  this.options = options || {};
7697
7723
  }
7698
7724
  compressSync(input) {
@@ -7707,12 +7733,13 @@ var __exports__ = (() => {
7707
7733
  var LZ4_MAGIC_NUMBER = 407708164;
7708
7734
  var lz4js;
7709
7735
  var LZ4Compression = class extends Compression {
7736
+ name = "lz4";
7737
+ extensions = ["lz4"];
7738
+ contentEncodings = ["x-lz4"];
7739
+ isSupported = true;
7740
+ options;
7710
7741
  constructor(options) {
7711
7742
  super(options);
7712
- this.name = "lz4";
7713
- this.extensions = ["lz4"];
7714
- this.contentEncodings = ["x-lz4"];
7715
- this.isSupported = true;
7716
7743
  this.options = options;
7717
7744
  lz4js = lz4js || this.options?.modules?.lz4js;
7718
7745
  if (!lz4js) {
@@ -7810,16 +7837,17 @@ var __exports__ = (() => {
7810
7837
  var ZstdCodec;
7811
7838
  var zstd;
7812
7839
  var ZstdCompression = class extends Compression {
7840
+ name = "zstd";
7841
+ extensions = [];
7842
+ contentEncodings = [];
7843
+ isSupported = true;
7844
+ options;
7813
7845
  /**
7814
7846
  * zstd-codec is an injectable dependency due to big size
7815
7847
  * @param options
7816
7848
  */
7817
7849
  constructor(options) {
7818
7850
  super(options);
7819
- this.name = "zstd";
7820
- this.extensions = [];
7821
- this.contentEncodings = [];
7822
- this.isSupported = true;
7823
7851
  this.options = options;
7824
7852
  ZstdCodec = this.options?.modules?.["zstd-codec"];
7825
7853
  if (!ZstdCodec) {
@@ -7846,16 +7874,18 @@ var __exports__ = (() => {
7846
7874
  // src/lib/lzo-compression.ts
7847
7875
  var lzo;
7848
7876
  var LZOCompression = class extends Compression {
7877
+ name = "lzo";
7878
+ extensions = [];
7879
+ contentEncodings = [];
7880
+ isSupported = false;
7881
+ // !isBrowser;
7882
+ options;
7849
7883
  /**
7850
7884
  * lzo is an injectable dependency due to big size
7851
7885
  * @param options
7852
7886
  */
7853
7887
  constructor(options) {
7854
7888
  super(options);
7855
- this.name = "lzo";
7856
- this.extensions = [];
7857
- this.contentEncodings = [];
7858
- this.isSupported = false;
7859
7889
  this.options = options;
7860
7890
  lzo = lzo || this.options?.modules?.lzo;
7861
7891
  if (!lzo) {