@loaders.gl/compression 4.2.0-alpha.5 → 4.2.0-beta.1

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.
Files changed (53) hide show
  1. package/dist/compress-on-worker.d.ts.map +1 -1
  2. package/dist/compress-on-worker.js +4 -1
  3. package/dist/compression-worker.js +2 -2
  4. package/dist/compression-worker.js.map +4 -4
  5. package/dist/dist.dev.js +762 -119
  6. package/dist/dist.min.js +3 -3
  7. package/dist/index.cjs +117 -96
  8. package/dist/index.cjs.map +3 -3
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +3 -0
  11. package/dist/lib/brotli-compression.d.ts +1 -1
  12. package/dist/lib/brotli-compression.d.ts.map +1 -1
  13. package/dist/lib/brotli-compression.js +14 -14
  14. package/dist/lib/compression.d.ts +1 -1
  15. package/dist/lib/compression.d.ts.map +1 -1
  16. package/dist/lib/compression.js +6 -1
  17. package/dist/lib/deflate-compression.d.ts.map +1 -1
  18. package/dist/lib/deflate-compression.js +9 -5
  19. package/dist/lib/gzip-compression.d.ts.map +1 -1
  20. package/dist/lib/gzip-compression.js +7 -4
  21. package/dist/lib/lz4-compression.d.ts +1 -0
  22. package/dist/lib/lz4-compression.d.ts.map +1 -1
  23. package/dist/lib/lz4-compression.js +15 -9
  24. package/dist/lib/lzo-compression.d.ts +1 -1
  25. package/dist/lib/lzo-compression.d.ts.map +1 -1
  26. package/dist/lib/lzo-compression.js +14 -11
  27. package/dist/lib/no-compression.d.ts.map +1 -1
  28. package/dist/lib/no-compression.js +8 -4
  29. package/dist/lib/snappy-compression.d.ts.map +1 -1
  30. package/dist/lib/snappy-compression.js +8 -4
  31. package/dist/lib/zstd-compression.d.ts +2 -1
  32. package/dist/lib/zstd-compression.d.ts.map +1 -1
  33. package/dist/lib/zstd-compression.js +34 -13
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/types.js +3 -0
  36. package/dist/workers/compression-worker-node.d.ts.map +1 -1
  37. package/dist/workers/compression-worker-node.js +3 -0
  38. package/dist/workers/compression-worker.js +3 -0
  39. package/package.json +6 -6
  40. package/src/compress-on-worker.ts +4 -0
  41. package/src/index.ts +4 -0
  42. package/src/lib/brotli-compression.ts +12 -11
  43. package/src/lib/compression.ts +7 -1
  44. package/src/lib/deflate-compression.ts +4 -0
  45. package/src/lib/gzip-compression.ts +4 -0
  46. package/src/lib/lz4-compression.ts +13 -6
  47. package/src/lib/lzo-compression.ts +10 -9
  48. package/src/lib/no-compression.ts +4 -0
  49. package/src/lib/snappy-compression.ts +4 -0
  50. package/src/lib/zstd-compression.ts +35 -10
  51. package/src/types.ts +4 -0
  52. package/src/workers/compression-worker-node.ts +4 -0
  53. package/src/workers/compression-worker.ts +4 -0
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({
@@ -4686,6 +4691,607 @@ var __exports__ = (() => {
4686
4691
  var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
4687
4692
  var nodeVersion = matches && parseFloat(matches[1]) || 0;
4688
4693
 
4694
+ // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
4695
+ function _typeof(obj) {
4696
+ "@babel/helpers - typeof";
4697
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
4698
+ return typeof obj2;
4699
+ } : function(obj2) {
4700
+ return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
4701
+ }, _typeof(obj);
4702
+ }
4703
+
4704
+ // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
4705
+ function _toPrimitive(input, hint) {
4706
+ if (_typeof(input) !== "object" || input === null)
4707
+ return input;
4708
+ var prim = input[Symbol.toPrimitive];
4709
+ if (prim !== void 0) {
4710
+ var res = prim.call(input, hint || "default");
4711
+ if (_typeof(res) !== "object")
4712
+ return res;
4713
+ throw new TypeError("@@toPrimitive must return a primitive value.");
4714
+ }
4715
+ return (hint === "string" ? String : Number)(input);
4716
+ }
4717
+
4718
+ // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
4719
+ function _toPropertyKey(arg) {
4720
+ var key = _toPrimitive(arg, "string");
4721
+ return _typeof(key) === "symbol" ? key : String(key);
4722
+ }
4723
+
4724
+ // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
4725
+ function _defineProperty(obj, key, value) {
4726
+ key = _toPropertyKey(key);
4727
+ if (key in obj) {
4728
+ Object.defineProperty(obj, key, {
4729
+ value,
4730
+ enumerable: true,
4731
+ configurable: true,
4732
+ writable: true
4733
+ });
4734
+ } else {
4735
+ obj[key] = value;
4736
+ }
4737
+ return obj;
4738
+ }
4739
+
4740
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
4741
+ function isElectron(mockUserAgent) {
4742
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
4743
+ return true;
4744
+ }
4745
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
4746
+ return true;
4747
+ }
4748
+ const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
4749
+ const userAgent = mockUserAgent || realUserAgent;
4750
+ if (userAgent && userAgent.indexOf("Electron") >= 0) {
4751
+ return true;
4752
+ }
4753
+ return false;
4754
+ }
4755
+
4756
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
4757
+ function isBrowser2() {
4758
+ const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
4759
+ return !isNode || isElectron();
4760
+ }
4761
+
4762
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
4763
+ var self_2 = globalThis.self || globalThis.window || globalThis.global;
4764
+ var window_2 = globalThis.window || globalThis.self || globalThis.global;
4765
+ var document_2 = globalThis.document || {};
4766
+ var process_ = globalThis.process || {};
4767
+ var console_ = globalThis.console;
4768
+ var navigator_ = globalThis.navigator || {};
4769
+
4770
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
4771
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
4772
+ var isBrowser3 = isBrowser2();
4773
+
4774
+ // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
4775
+ function getStorage(type) {
4776
+ try {
4777
+ const storage = window[type];
4778
+ const x = "__storage_test__";
4779
+ storage.setItem(x, x);
4780
+ storage.removeItem(x);
4781
+ return storage;
4782
+ } catch (e) {
4783
+ return null;
4784
+ }
4785
+ }
4786
+ var LocalStorage = class {
4787
+ constructor(id, defaultConfig) {
4788
+ let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
4789
+ _defineProperty(this, "storage", void 0);
4790
+ _defineProperty(this, "id", void 0);
4791
+ _defineProperty(this, "config", void 0);
4792
+ this.storage = getStorage(type);
4793
+ this.id = id;
4794
+ this.config = defaultConfig;
4795
+ this._loadConfiguration();
4796
+ }
4797
+ getConfiguration() {
4798
+ return this.config;
4799
+ }
4800
+ setConfiguration(configuration) {
4801
+ Object.assign(this.config, configuration);
4802
+ if (this.storage) {
4803
+ const serialized = JSON.stringify(this.config);
4804
+ this.storage.setItem(this.id, serialized);
4805
+ }
4806
+ }
4807
+ _loadConfiguration() {
4808
+ let configuration = {};
4809
+ if (this.storage) {
4810
+ const serializedConfiguration = this.storage.getItem(this.id);
4811
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
4812
+ }
4813
+ Object.assign(this.config, configuration);
4814
+ return this;
4815
+ }
4816
+ };
4817
+
4818
+ // ../../node_modules/@probe.gl/log/dist/utils/formatters.js
4819
+ function formatTime(ms) {
4820
+ let formatted;
4821
+ if (ms < 10) {
4822
+ formatted = "".concat(ms.toFixed(2), "ms");
4823
+ } else if (ms < 100) {
4824
+ formatted = "".concat(ms.toFixed(1), "ms");
4825
+ } else if (ms < 1e3) {
4826
+ formatted = "".concat(ms.toFixed(0), "ms");
4827
+ } else {
4828
+ formatted = "".concat((ms / 1e3).toFixed(2), "s");
4829
+ }
4830
+ return formatted;
4831
+ }
4832
+ function leftPad(string) {
4833
+ let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
4834
+ const padLength = Math.max(length - string.length, 0);
4835
+ return "".concat(" ".repeat(padLength)).concat(string);
4836
+ }
4837
+ function formatImage(image, message, scale) {
4838
+ let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
4839
+ const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
4840
+ if (image.width > maxWidth) {
4841
+ scale = Math.min(scale, maxWidth / image.width);
4842
+ }
4843
+ const width = image.width * scale;
4844
+ const height = image.height * scale;
4845
+ const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
4846
+ return ["".concat(message, " %c+"), style];
4847
+ }
4848
+
4849
+ // ../../node_modules/@probe.gl/log/dist/utils/color.js
4850
+ var COLOR;
4851
+ (function(COLOR2) {
4852
+ COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
4853
+ COLOR2[COLOR2["RED"] = 31] = "RED";
4854
+ COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
4855
+ COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
4856
+ COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
4857
+ COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
4858
+ COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
4859
+ COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
4860
+ COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
4861
+ COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
4862
+ COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
4863
+ COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
4864
+ COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
4865
+ COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
4866
+ COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
4867
+ COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
4868
+ })(COLOR || (COLOR = {}));
4869
+ var BACKGROUND_INCREMENT = 10;
4870
+ function getColor(color) {
4871
+ if (typeof color !== "string") {
4872
+ return color;
4873
+ }
4874
+ color = color.toUpperCase();
4875
+ return COLOR[color] || COLOR.WHITE;
4876
+ }
4877
+ function addColor(string, color, background) {
4878
+ if (!isBrowser2 && typeof string === "string") {
4879
+ if (color) {
4880
+ const colorCode = getColor(color);
4881
+ string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
4882
+ }
4883
+ if (background) {
4884
+ const colorCode = getColor(background);
4885
+ string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
4886
+ }
4887
+ }
4888
+ return string;
4889
+ }
4890
+
4891
+ // ../../node_modules/@probe.gl/log/dist/utils/autobind.js
4892
+ function autobind(obj) {
4893
+ let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
4894
+ const proto = Object.getPrototypeOf(obj);
4895
+ const propNames = Object.getOwnPropertyNames(proto);
4896
+ const object = obj;
4897
+ for (const key of propNames) {
4898
+ const value = object[key];
4899
+ if (typeof value === "function") {
4900
+ if (!predefined.find((name) => key === name)) {
4901
+ object[key] = value.bind(obj);
4902
+ }
4903
+ }
4904
+ }
4905
+ }
4906
+
4907
+ // ../../node_modules/@probe.gl/log/dist/utils/assert.js
4908
+ function assert(condition, message) {
4909
+ if (!condition) {
4910
+ throw new Error(message || "Assertion failed");
4911
+ }
4912
+ }
4913
+
4914
+ // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
4915
+ function getHiResTimestamp() {
4916
+ let timestamp;
4917
+ if (isBrowser2() && window_2.performance) {
4918
+ var _window$performance, _window$performance$n;
4919
+ timestamp = window_2 === null || window_2 === void 0 ? void 0 : (_window$performance = window_2.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
4920
+ } else if ("hrtime" in process_) {
4921
+ var _process$hrtime;
4922
+ const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
4923
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
4924
+ } else {
4925
+ timestamp = Date.now();
4926
+ }
4927
+ return timestamp;
4928
+ }
4929
+
4930
+ // ../../node_modules/@probe.gl/log/dist/log.js
4931
+ var originalConsole = {
4932
+ debug: isBrowser2() ? console.debug || console.log : console.log,
4933
+ log: console.log,
4934
+ info: console.info,
4935
+ warn: console.warn,
4936
+ error: console.error
4937
+ };
4938
+ var DEFAULT_LOG_CONFIGURATION = {
4939
+ enabled: true,
4940
+ level: 0
4941
+ };
4942
+ function noop() {
4943
+ }
4944
+ var cache = {};
4945
+ var ONCE = {
4946
+ once: true
4947
+ };
4948
+ var Log = class {
4949
+ constructor() {
4950
+ let {
4951
+ id
4952
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
4953
+ id: ""
4954
+ };
4955
+ _defineProperty(this, "id", void 0);
4956
+ _defineProperty(this, "VERSION", VERSION);
4957
+ _defineProperty(this, "_startTs", getHiResTimestamp());
4958
+ _defineProperty(this, "_deltaTs", getHiResTimestamp());
4959
+ _defineProperty(this, "_storage", void 0);
4960
+ _defineProperty(this, "userData", {});
4961
+ _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
4962
+ this.id = id;
4963
+ this.userData = {};
4964
+ this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
4965
+ this.timeStamp("".concat(this.id, " started"));
4966
+ autobind(this);
4967
+ Object.seal(this);
4968
+ }
4969
+ set level(newLevel) {
4970
+ this.setLevel(newLevel);
4971
+ }
4972
+ get level() {
4973
+ return this.getLevel();
4974
+ }
4975
+ isEnabled() {
4976
+ return this._storage.config.enabled;
4977
+ }
4978
+ getLevel() {
4979
+ return this._storage.config.level;
4980
+ }
4981
+ getTotal() {
4982
+ return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
4983
+ }
4984
+ getDelta() {
4985
+ return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
4986
+ }
4987
+ set priority(newPriority) {
4988
+ this.level = newPriority;
4989
+ }
4990
+ get priority() {
4991
+ return this.level;
4992
+ }
4993
+ getPriority() {
4994
+ return this.level;
4995
+ }
4996
+ enable() {
4997
+ let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
4998
+ this._storage.setConfiguration({
4999
+ enabled
5000
+ });
5001
+ return this;
5002
+ }
5003
+ setLevel(level) {
5004
+ this._storage.setConfiguration({
5005
+ level
5006
+ });
5007
+ return this;
5008
+ }
5009
+ get(setting) {
5010
+ return this._storage.config[setting];
5011
+ }
5012
+ set(setting, value) {
5013
+ this._storage.setConfiguration({
5014
+ [setting]: value
5015
+ });
5016
+ }
5017
+ settings() {
5018
+ if (console.table) {
5019
+ console.table(this._storage.config);
5020
+ } else {
5021
+ console.log(this._storage.config);
5022
+ }
5023
+ }
5024
+ assert(condition, message) {
5025
+ assert(condition, message);
5026
+ }
5027
+ warn(message) {
5028
+ return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
5029
+ }
5030
+ error(message) {
5031
+ return this._getLogFunction(0, message, originalConsole.error, arguments);
5032
+ }
5033
+ deprecated(oldUsage, newUsage) {
5034
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
5035
+ }
5036
+ removed(oldUsage, newUsage) {
5037
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
5038
+ }
5039
+ probe(logLevel, message) {
5040
+ return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
5041
+ time: true,
5042
+ once: true
5043
+ });
5044
+ }
5045
+ log(logLevel, message) {
5046
+ return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
5047
+ }
5048
+ info(logLevel, message) {
5049
+ return this._getLogFunction(logLevel, message, console.info, arguments);
5050
+ }
5051
+ once(logLevel, message) {
5052
+ return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
5053
+ }
5054
+ table(logLevel, table, columns) {
5055
+ if (table) {
5056
+ return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
5057
+ tag: getTableHeader(table)
5058
+ });
5059
+ }
5060
+ return noop;
5061
+ }
5062
+ image(_ref) {
5063
+ let {
5064
+ logLevel,
5065
+ priority,
5066
+ image,
5067
+ message = "",
5068
+ scale = 1
5069
+ } = _ref;
5070
+ if (!this._shouldLog(logLevel || priority)) {
5071
+ return noop;
5072
+ }
5073
+ return isBrowser2() ? logImageInBrowser({
5074
+ image,
5075
+ message,
5076
+ scale
5077
+ }) : logImageInNode({
5078
+ image,
5079
+ message,
5080
+ scale
5081
+ });
5082
+ }
5083
+ time(logLevel, message) {
5084
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
5085
+ }
5086
+ timeEnd(logLevel, message) {
5087
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
5088
+ }
5089
+ timeStamp(logLevel, message) {
5090
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop);
5091
+ }
5092
+ group(logLevel, message) {
5093
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
5094
+ collapsed: false
5095
+ };
5096
+ const options = normalizeArguments({
5097
+ logLevel,
5098
+ message,
5099
+ opts
5100
+ });
5101
+ const {
5102
+ collapsed
5103
+ } = opts;
5104
+ options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
5105
+ return this._getLogFunction(options);
5106
+ }
5107
+ groupCollapsed(logLevel, message) {
5108
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
5109
+ return this.group(logLevel, message, Object.assign({}, opts, {
5110
+ collapsed: true
5111
+ }));
5112
+ }
5113
+ groupEnd(logLevel) {
5114
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop);
5115
+ }
5116
+ withGroup(logLevel, message, func) {
5117
+ this.group(logLevel, message)();
5118
+ try {
5119
+ func();
5120
+ } finally {
5121
+ this.groupEnd(logLevel)();
5122
+ }
5123
+ }
5124
+ trace() {
5125
+ if (console.trace) {
5126
+ console.trace();
5127
+ }
5128
+ }
5129
+ _shouldLog(logLevel) {
5130
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
5131
+ }
5132
+ _getLogFunction(logLevel, message, method, args, opts) {
5133
+ if (this._shouldLog(logLevel)) {
5134
+ opts = normalizeArguments({
5135
+ logLevel,
5136
+ message,
5137
+ args,
5138
+ opts
5139
+ });
5140
+ method = method || opts.method;
5141
+ assert(method);
5142
+ opts.total = this.getTotal();
5143
+ opts.delta = this.getDelta();
5144
+ this._deltaTs = getHiResTimestamp();
5145
+ const tag = opts.tag || opts.message;
5146
+ if (opts.once && tag) {
5147
+ if (!cache[tag]) {
5148
+ cache[tag] = getHiResTimestamp();
5149
+ } else {
5150
+ return noop;
5151
+ }
5152
+ }
5153
+ message = decorateMessage(this.id, opts.message, opts);
5154
+ return method.bind(console, message, ...opts.args);
5155
+ }
5156
+ return noop;
5157
+ }
5158
+ };
5159
+ _defineProperty(Log, "VERSION", VERSION);
5160
+ function normalizeLogLevel(logLevel) {
5161
+ if (!logLevel) {
5162
+ return 0;
5163
+ }
5164
+ let resolvedLevel;
5165
+ switch (typeof logLevel) {
5166
+ case "number":
5167
+ resolvedLevel = logLevel;
5168
+ break;
5169
+ case "object":
5170
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
5171
+ break;
5172
+ default:
5173
+ return 0;
5174
+ }
5175
+ assert(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
5176
+ return resolvedLevel;
5177
+ }
5178
+ function normalizeArguments(opts) {
5179
+ const {
5180
+ logLevel,
5181
+ message
5182
+ } = opts;
5183
+ opts.logLevel = normalizeLogLevel(logLevel);
5184
+ const args = opts.args ? Array.from(opts.args) : [];
5185
+ while (args.length && args.shift() !== message) {
5186
+ }
5187
+ switch (typeof logLevel) {
5188
+ case "string":
5189
+ case "function":
5190
+ if (message !== void 0) {
5191
+ args.unshift(message);
5192
+ }
5193
+ opts.message = logLevel;
5194
+ break;
5195
+ case "object":
5196
+ Object.assign(opts, logLevel);
5197
+ break;
5198
+ default:
5199
+ }
5200
+ if (typeof opts.message === "function") {
5201
+ opts.message = opts.message();
5202
+ }
5203
+ const messageType = typeof opts.message;
5204
+ assert(messageType === "string" || messageType === "object");
5205
+ return Object.assign(opts, {
5206
+ args
5207
+ }, opts.opts);
5208
+ }
5209
+ function decorateMessage(id, message, opts) {
5210
+ if (typeof message === "string") {
5211
+ const time = opts.time ? leftPad(formatTime(opts.total)) : "";
5212
+ message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
5213
+ message = addColor(message, opts.color, opts.background);
5214
+ }
5215
+ return message;
5216
+ }
5217
+ function logImageInNode(_ref2) {
5218
+ let {
5219
+ image,
5220
+ message = "",
5221
+ scale = 1
5222
+ } = _ref2;
5223
+ console.warn("removed");
5224
+ return noop;
5225
+ }
5226
+ function logImageInBrowser(_ref3) {
5227
+ let {
5228
+ image,
5229
+ message = "",
5230
+ scale = 1
5231
+ } = _ref3;
5232
+ if (typeof image === "string") {
5233
+ const img = new Image();
5234
+ img.onload = () => {
5235
+ const args = formatImage(img, message, scale);
5236
+ console.log(...args);
5237
+ };
5238
+ img.src = image;
5239
+ return noop;
5240
+ }
5241
+ const element = image.nodeName || "";
5242
+ if (element.toLowerCase() === "img") {
5243
+ console.log(...formatImage(image, message, scale));
5244
+ return noop;
5245
+ }
5246
+ if (element.toLowerCase() === "canvas") {
5247
+ const img = new Image();
5248
+ img.onload = () => console.log(...formatImage(img, message, scale));
5249
+ img.src = image.toDataURL();
5250
+ return noop;
5251
+ }
5252
+ return noop;
5253
+ }
5254
+ function getTableHeader(table) {
5255
+ for (const key in table) {
5256
+ for (const title in table[key]) {
5257
+ return title || "untitled";
5258
+ }
5259
+ }
5260
+ return "empty";
5261
+ }
5262
+
5263
+ // ../../node_modules/@probe.gl/log/dist/index.js
5264
+ var dist_default = new Log({
5265
+ id: "@probe.gl/log"
5266
+ });
5267
+
5268
+ // ../loader-utils/src/lib/log-utils/log.ts
5269
+ var log = new Log({ id: "loaders.gl" });
5270
+
5271
+ // ../loader-utils/src/lib/module-utils/js-module-utils.ts
5272
+ function registerJSModules(modules) {
5273
+ globalThis.loaders ||= {};
5274
+ globalThis.loaders.modules ||= {};
5275
+ Object.assign(globalThis.loaders.modules, modules);
5276
+ }
5277
+ function checkJSModule(name, caller) {
5278
+ const module = globalThis.loaders?.modules?.[name];
5279
+ if (!module) {
5280
+ log.warn(`${caller}: ${name} library not installed`)();
5281
+ }
5282
+ }
5283
+ function getJSModule(name, caller) {
5284
+ const module = globalThis.loaders?.modules?.[name];
5285
+ if (!module) {
5286
+ throw new Error(`${caller}: ${name} library not installed`);
5287
+ }
5288
+ return module;
5289
+ }
5290
+ function getJSModuleOrNull(name) {
5291
+ const module = globalThis.loaders?.modules?.[name];
5292
+ return module || null;
5293
+ }
5294
+
4689
5295
  // ../worker-utils/src/lib/env-utils/version.ts
4690
5296
  var NPM_TAG = "latest";
4691
5297
  function getVersion() {
@@ -4702,10 +5308,10 @@ var __exports__ = (() => {
4702
5308
  }
4703
5309
  return globalThis._loadersgl_.version;
4704
5310
  }
4705
- var VERSION = getVersion();
5311
+ var VERSION2 = getVersion();
4706
5312
 
4707
5313
  // ../worker-utils/src/lib/env-utils/assert.ts
4708
- function assert(condition, message) {
5314
+ function assert2(condition, message) {
4709
5315
  if (!condition) {
4710
5316
  throw new Error(message || "loaders.gl assertion failed.");
4711
5317
  }
@@ -4718,11 +5324,11 @@ var __exports__ = (() => {
4718
5324
  global: typeof global !== "undefined" && global,
4719
5325
  document: typeof document !== "undefined" && document
4720
5326
  };
4721
- var self_2 = globals2.self || globals2.window || globals2.global || {};
4722
- var window_2 = globals2.window || globals2.self || globals2.global || {};
4723
- var global_2 = globals2.global || globals2.self || globals2.window || {};
4724
- var document_2 = globals2.document || {};
4725
- var isBrowser2 = (
5327
+ var self_3 = globals2.self || globals2.window || globals2.global || {};
5328
+ var window_3 = globals2.window || globals2.self || globals2.global || {};
5329
+ var global_3 = globals2.global || globals2.self || globals2.window || {};
5330
+ var document_3 = globals2.document || {};
5331
+ var isBrowser4 = (
4726
5332
  // @ts-ignore process.browser
4727
5333
  typeof process !== "object" || String(process) !== "[object process]" || process.browser
4728
5334
  );
@@ -4732,12 +5338,16 @@ var __exports__ = (() => {
4732
5338
 
4733
5339
  // ../worker-utils/src/lib/worker-farm/worker-job.ts
4734
5340
  var WorkerJob = class {
5341
+ name;
5342
+ workerThread;
5343
+ isRunning = true;
5344
+ /** Promise that resolves when Job is done */
5345
+ result;
5346
+ _resolve = () => {
5347
+ };
5348
+ _reject = () => {
5349
+ };
4735
5350
  constructor(jobName, workerThread) {
4736
- this.isRunning = true;
4737
- this._resolve = () => {
4738
- };
4739
- this._reject = () => {
4740
- };
4741
5351
  this.name = jobName;
4742
5352
  this.workerThread = workerThread;
4743
5353
  this.result = new Promise((resolve, reject) => {
@@ -4761,7 +5371,7 @@ var __exports__ = (() => {
4761
5371
  * Call to resolve the `result` Promise with the supplied value
4762
5372
  */
4763
5373
  done(value) {
4764
- assert(this.isRunning);
5374
+ assert2(this.isRunning);
4765
5375
  this.isRunning = false;
4766
5376
  this._resolve(value);
4767
5377
  }
@@ -4769,7 +5379,7 @@ var __exports__ = (() => {
4769
5379
  * Call to reject the `result` Promise with the supplied error
4770
5380
  */
4771
5381
  error(error) {
4772
- assert(this.isRunning);
5382
+ assert2(this.isRunning);
4773
5383
  this.isRunning = false;
4774
5384
  this._reject(error);
4775
5385
  }
@@ -4784,7 +5394,7 @@ var __exports__ = (() => {
4784
5394
  // ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
4785
5395
  var workerURLCache = /* @__PURE__ */ new Map();
4786
5396
  function getLoadableWorkerURL(props) {
4787
- assert(props.source && !props.url || !props.source && props.url);
5397
+ assert2(props.source && !props.url || !props.source && props.url);
4788
5398
  let workerURL = workerURLCache.get(props.source || props.url);
4789
5399
  if (!workerURL) {
4790
5400
  if (props.url) {
@@ -4796,7 +5406,7 @@ var __exports__ = (() => {
4796
5406
  workerURLCache.set(props.source, workerURL);
4797
5407
  }
4798
5408
  }
4799
- assert(workerURL);
5409
+ assert2(workerURL);
4800
5410
  return workerURL;
4801
5411
  }
4802
5412
  function getLoadableWorkerURLFromURL(url) {
@@ -4874,21 +5484,27 @@ var __exports__ = (() => {
4874
5484
  var NOOP = () => {
4875
5485
  };
4876
5486
  var WorkerThread = class {
5487
+ name;
5488
+ source;
5489
+ url;
5490
+ terminated = false;
5491
+ worker;
5492
+ onMessage;
5493
+ onError;
5494
+ _loadableURL = "";
5495
+ /** Checks if workers are supported on this platform */
5496
+ static isSupported() {
5497
+ return typeof Worker !== "undefined" && isBrowser4 || typeof NodeWorker !== "undefined" && !isBrowser4;
5498
+ }
4877
5499
  constructor(props) {
4878
- this.terminated = false;
4879
- this._loadableURL = "";
4880
5500
  const { name, source, url } = props;
4881
- assert(source || url);
5501
+ assert2(source || url);
4882
5502
  this.name = name;
4883
5503
  this.source = source;
4884
5504
  this.url = url;
4885
5505
  this.onMessage = NOOP;
4886
5506
  this.onError = (error) => console.log(error);
4887
- this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
4888
- }
4889
- /** Checks if workers are supported on this platform */
4890
- static isSupported() {
4891
- return typeof Worker !== "undefined" && isBrowser2 || typeof NodeWorker !== "undefined" && !isBrowser2;
5507
+ this.worker = isBrowser4 ? this._createBrowserWorker() : this._createNodeWorker();
4892
5508
  }
4893
5509
  /**
4894
5510
  * Terminate this worker thread
@@ -4977,30 +5593,33 @@ var __exports__ = (() => {
4977
5593
 
4978
5594
  // ../worker-utils/src/lib/worker-farm/worker-pool.ts
4979
5595
  var WorkerPool = class {
5596
+ name = "unnamed";
5597
+ source;
5598
+ // | Function;
5599
+ url;
5600
+ maxConcurrency = 1;
5601
+ maxMobileConcurrency = 1;
5602
+ onDebug = () => {
5603
+ };
5604
+ reuseWorkers = true;
5605
+ props = {};
5606
+ jobQueue = [];
5607
+ idleQueue = [];
5608
+ count = 0;
5609
+ isDestroyed = false;
5610
+ /** Checks if workers are supported on this platform */
5611
+ static isSupported() {
5612
+ return WorkerThread.isSupported();
5613
+ }
4980
5614
  /**
4981
5615
  * @param processor - worker function
4982
5616
  * @param maxConcurrency - max count of workers
4983
5617
  */
4984
5618
  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
5619
  this.source = props.source;
4997
5620
  this.url = props.url;
4998
5621
  this.setProps(props);
4999
5622
  }
5000
- /** Checks if workers are supported on this platform */
5001
- static isSupported() {
5002
- return WorkerThread.isSupported();
5003
- }
5004
5623
  /**
5005
5624
  * Terminates all workers in the pool
5006
5625
  * @note Can free up significant memory
@@ -5081,7 +5700,7 @@ var __exports__ = (() => {
5081
5700
  const shouldDestroyWorker = (
5082
5701
  // Workers on Node.js prevent the process from exiting.
5083
5702
  // Until we figure out how to close them before exit, we always destroy them
5084
- !isBrowser2 || // If the pool is destroyed, there is no reason to keep the worker around
5703
+ !isBrowser4 || // If the pool is destroyed, there is no reason to keep the worker around
5085
5704
  this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
5086
5705
  !this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
5087
5706
  this.count > this._getMaxConcurrency()
@@ -5123,23 +5742,24 @@ var __exports__ = (() => {
5123
5742
  onDebug: () => {
5124
5743
  }
5125
5744
  };
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
- }
5745
+ var _WorkerFarm = class {
5746
+ props;
5747
+ workerPools = /* @__PURE__ */ new Map();
5134
5748
  /** Checks if workers are supported on this platform */
5135
5749
  static isSupported() {
5136
5750
  return WorkerThread.isSupported();
5137
5751
  }
5138
5752
  /** Get the singleton instance of the global worker farm */
5139
5753
  static getWorkerFarm(props = {}) {
5140
- WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({});
5141
- WorkerFarm._workerFarm.setProps(props);
5142
- return WorkerFarm._workerFarm;
5754
+ _WorkerFarm._workerFarm = _WorkerFarm._workerFarm || new _WorkerFarm({});
5755
+ _WorkerFarm._workerFarm.setProps(props);
5756
+ return _WorkerFarm._workerFarm;
5757
+ }
5758
+ /** get global instance with WorkerFarm.getWorkerFarm() */
5759
+ constructor(props) {
5760
+ this.props = { ...DEFAULT_PROPS };
5761
+ this.setProps(props);
5762
+ this.workerPools = /* @__PURE__ */ new Map();
5143
5763
  }
5144
5764
  /**
5145
5765
  * Terminate all workers in the farm
@@ -5193,21 +5813,24 @@ var __exports__ = (() => {
5193
5813
  };
5194
5814
  }
5195
5815
  };
5816
+ var WorkerFarm = _WorkerFarm;
5817
+ // singleton
5818
+ __publicField(WorkerFarm, "_workerFarm");
5196
5819
 
5197
5820
  // ../worker-utils/src/lib/worker-api/get-worker-url.ts
5198
5821
  function getWorkerName(worker) {
5199
- const warning = worker.version !== VERSION ? ` (worker-utils@${VERSION})` : "";
5822
+ const warning = worker.version !== VERSION2 ? ` (worker-utils@${VERSION2})` : "";
5200
5823
  return `${worker.name}@${worker.version}${warning}`;
5201
5824
  }
5202
5825
  function getWorkerURL(worker, options = {}) {
5203
5826
  const workerOptions = options[worker.id] || {};
5204
- const workerFile = isBrowser2 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
5827
+ const workerFile = isBrowser4 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
5205
5828
  let url = workerOptions.workerUrl;
5206
5829
  if (!url && worker.id === "compression") {
5207
5830
  url = options.workerUrl;
5208
5831
  }
5209
5832
  if (options._workerType === "test") {
5210
- if (isBrowser2) {
5833
+ if (isBrowser4) {
5211
5834
  url = `modules/${worker.module}/dist/${workerFile}`;
5212
5835
  } else {
5213
5836
  url = `modules/${worker.module}/src/workers/${worker.id}-worker-node.ts`;
@@ -5221,7 +5844,7 @@ var __exports__ = (() => {
5221
5844
  const versionTag = version ? `@${version}` : "";
5222
5845
  url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
5223
5846
  }
5224
- assert(url);
5847
+ assert2(url);
5225
5848
  return url;
5226
5849
  }
5227
5850
 
@@ -5353,7 +5976,8 @@ var __exports__ = (() => {
5353
5976
  this.decompressBatches = this.decompressBatches.bind(this);
5354
5977
  }
5355
5978
  /** Preloads any dynamic libraries. May enable sync functions */
5356
- async preload() {
5979
+ async preload(modules = {}) {
5980
+ registerJSModules(modules);
5357
5981
  return;
5358
5982
  }
5359
5983
  /** Asynchronously compress data */
@@ -5398,12 +6022,13 @@ var __exports__ = (() => {
5398
6022
 
5399
6023
  // src/lib/no-compression.ts
5400
6024
  var NoCompression = class extends Compression {
6025
+ name = "uncompressed";
6026
+ extensions = [];
6027
+ contentEncodings = [];
6028
+ isSupported = true;
6029
+ options;
5401
6030
  constructor(options) {
5402
6031
  super(options);
5403
- this.name = "uncompressed";
5404
- this.extensions = [];
5405
- this.contentEncodings = [];
5406
- this.isSupported = true;
5407
6032
  this.options = options || {};
5408
6033
  }
5409
6034
  compressSync(input) {
@@ -5424,13 +6049,14 @@ var __exports__ = (() => {
5424
6049
  var import_pako = __toESM(require_pako(), 1);
5425
6050
  var import_zlib = __toESM(require_zlib(), 1);
5426
6051
  var DeflateCompression = class extends Compression {
6052
+ name = "deflate";
6053
+ extensions = [];
6054
+ contentEncodings = ["deflate"];
6055
+ isSupported = true;
6056
+ options;
6057
+ _chunks = [];
5427
6058
  constructor(options = {}) {
5428
6059
  super(options);
5429
- this.name = "deflate";
5430
- this.extensions = [];
5431
- this.contentEncodings = ["deflate"];
5432
- this.isSupported = true;
5433
- this._chunks = [];
5434
6060
  this.options = options;
5435
6061
  }
5436
6062
  async compress(input) {
@@ -5537,12 +6163,12 @@ var __exports__ = (() => {
5537
6163
 
5538
6164
  // src/lib/gzip-compression.ts
5539
6165
  var GZipCompression = class extends DeflateCompression {
6166
+ name = "gzip";
6167
+ extensions = ["gz", "gzip"];
6168
+ contentEncodings = ["gzip", "x-gzip"];
6169
+ isSupported = true;
5540
6170
  constructor(options) {
5541
6171
  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
6172
  }
5547
6173
  };
5548
6174
 
@@ -7621,25 +8247,23 @@ var __exports__ = (() => {
7621
8247
  lgwin: 22
7622
8248
  }
7623
8249
  };
7624
- var brotli;
7625
8250
  var BrotliCompression = class extends Compression {
8251
+ name = "brotli";
8252
+ extensions = ["br"];
8253
+ contentEncodings = ["br"];
8254
+ isSupported = true;
8255
+ options;
7626
8256
  constructor(options) {
7627
8257
  super(options);
7628
- this.name = "brotli";
7629
- this.extensions = ["br"];
7630
- this.contentEncodings = ["br"];
7631
- this.isSupported = true;
7632
8258
  this.options = options;
8259
+ registerJSModules(options?.modules);
7633
8260
  }
7634
8261
  /**
7635
8262
  * brotli is an injectable dependency due to big size
7636
8263
  * @param options
7637
8264
  */
7638
- async preload() {
7639
- brotli = brotli || this.options?.modules?.brotli;
7640
- if (!brotli) {
7641
- console.warn(`${this.name} library not installed`);
7642
- }
8265
+ async preload(modules = {}) {
8266
+ registerJSModules(modules);
7643
8267
  }
7644
8268
  async compress(input) {
7645
8269
  if (!isBrowser && this.options.brotli?.useZlib) {
@@ -7655,9 +8279,7 @@ var __exports__ = (() => {
7655
8279
  }
7656
8280
  const brotliOptions = { ...DEFAULT_BROTLI_OPTIONS.brotli, ...this.options?.brotli };
7657
8281
  const inputArray = new Uint8Array(input);
7658
- if (!brotli) {
7659
- throw new Error("brotli compression: brotli module not installed");
7660
- }
8282
+ const brotli = getJSModule("brotli", this.name);
7661
8283
  const outputArray = brotli.compress(inputArray, brotliOptions);
7662
8284
  return outputArray.buffer;
7663
8285
  }
@@ -7675,6 +8297,7 @@ var __exports__ = (() => {
7675
8297
  }
7676
8298
  const brotliOptions = { ...DEFAULT_BROTLI_OPTIONS.brotli, ...this.options?.brotli };
7677
8299
  const inputArray = new Uint8Array(input);
8300
+ const brotli = getJSModuleOrNull("brotli");
7678
8301
  if (brotli) {
7679
8302
  const outputArray2 = brotli.decompress(inputArray, brotliOptions);
7680
8303
  return outputArray2.buffer;
@@ -7687,12 +8310,13 @@ var __exports__ = (() => {
7687
8310
  // src/lib/snappy-compression.ts
7688
8311
  var import_snappyjs = __toESM(require_snappyjs(), 1);
7689
8312
  var SnappyCompression = class extends Compression {
8313
+ name = "snappy";
8314
+ extensions = [];
8315
+ contentEncodings = [];
8316
+ isSupported = true;
8317
+ options;
7690
8318
  constructor(options) {
7691
8319
  super(options);
7692
- this.name = "snappy";
7693
- this.extensions = [];
7694
- this.contentEncodings = [];
7695
- this.isSupported = true;
7696
8320
  this.options = options || {};
7697
8321
  }
7698
8322
  compressSync(input) {
@@ -7705,21 +8329,22 @@ var __exports__ = (() => {
7705
8329
 
7706
8330
  // src/lib/lz4-compression.ts
7707
8331
  var LZ4_MAGIC_NUMBER = 407708164;
7708
- var lz4js;
7709
8332
  var LZ4Compression = class extends Compression {
8333
+ name = "lz4";
8334
+ extensions = ["lz4"];
8335
+ contentEncodings = ["x-lz4"];
8336
+ isSupported = true;
8337
+ options;
7710
8338
  constructor(options) {
7711
8339
  super(options);
7712
- this.name = "lz4";
7713
- this.extensions = ["lz4"];
7714
- this.contentEncodings = ["x-lz4"];
7715
- this.isSupported = true;
7716
8340
  this.options = options;
7717
- lz4js = lz4js || this.options?.modules?.lz4js;
7718
- if (!lz4js) {
7719
- throw new Error(this.name);
7720
- }
8341
+ registerJSModules(options?.modules);
8342
+ }
8343
+ async preload(modules = {}) {
8344
+ registerJSModules(modules);
7721
8345
  }
7722
8346
  compressSync(input) {
8347
+ const lz4js = getJSModule("lz4js", this.name);
7723
8348
  const inputArray = new Uint8Array(input);
7724
8349
  return lz4js.compress(inputArray).buffer;
7725
8350
  }
@@ -7730,6 +8355,7 @@ var __exports__ = (() => {
7730
8355
  * If data provided without magic number we will parse it as block
7731
8356
  */
7732
8357
  decompressSync(data, maxSize) {
8358
+ const lz4js = getJSModule("lz4js", this.name);
7733
8359
  try {
7734
8360
  const isMagicNumberExists = this.checkMagicNumber(data);
7735
8361
  const inputArray = new Uint8Array(data);
@@ -7807,71 +8433,88 @@ var __exports__ = (() => {
7807
8433
  };
7808
8434
 
7809
8435
  // src/lib/zstd-compression.ts
7810
- var ZstdCodec;
8436
+ var CHUNK_SIZE = 1e6;
8437
+ var zstdPromise;
7811
8438
  var zstd;
7812
8439
  var ZstdCompression = class extends Compression {
8440
+ name = "zstd";
8441
+ extensions = [];
8442
+ contentEncodings = [];
8443
+ isSupported = true;
8444
+ options;
7813
8445
  /**
7814
8446
  * zstd-codec is an injectable dependency due to big size
7815
8447
  * @param options
7816
8448
  */
7817
8449
  constructor(options) {
7818
8450
  super(options);
7819
- this.name = "zstd";
7820
- this.extensions = [];
7821
- this.contentEncodings = [];
7822
- this.isSupported = true;
7823
8451
  this.options = options;
7824
- ZstdCodec = this.options?.modules?.["zstd-codec"];
7825
- if (!ZstdCodec) {
7826
- console.warn(`${this.name} library not installed`);
7827
- }
8452
+ registerJSModules(options?.modules);
7828
8453
  }
7829
- async preload() {
7830
- if (!zstd && ZstdCodec) {
7831
- zstd = await new Promise((resolve) => ZstdCodec.run((zstd2) => resolve(zstd2)));
8454
+ async preload(modules = {}) {
8455
+ registerJSModules(modules);
8456
+ checkJSModule("zstd-codec", this.name);
8457
+ const ZstdCodec = getJSModuleOrNull("zstd-codec");
8458
+ if (!zstdPromise && ZstdCodec) {
8459
+ zstdPromise = new Promise((resolve) => ZstdCodec.run((zstd2) => resolve(zstd2)));
8460
+ zstd = await zstdPromise;
7832
8461
  }
7833
8462
  }
7834
8463
  compressSync(input) {
8464
+ getJSModule("zstd-codec", this.name);
7835
8465
  const simpleZstd = new zstd.Simple();
7836
8466
  const inputArray = new Uint8Array(input);
7837
8467
  return simpleZstd.compress(inputArray).buffer;
7838
8468
  }
7839
8469
  decompressSync(input) {
8470
+ getJSModule("zstd-codec", this.name);
7840
8471
  const simpleZstd = new zstd.Simple();
7841
8472
  const inputArray = new Uint8Array(input);
7842
8473
  return simpleZstd.decompress(inputArray).buffer;
7843
8474
  }
8475
+ async decompress(input, size) {
8476
+ await this.preload();
8477
+ const simpleZstd = new zstd.Streaming();
8478
+ const inputArray = new Uint8Array(input);
8479
+ const chunks = [];
8480
+ for (let i = 0; i <= inputArray.length; i += CHUNK_SIZE) {
8481
+ chunks.push(inputArray.subarray(i, i + CHUNK_SIZE));
8482
+ }
8483
+ const decompressResult = await simpleZstd.decompressChunks(chunks);
8484
+ return decompressResult.buffer;
8485
+ }
7844
8486
  };
7845
8487
 
7846
8488
  // src/lib/lzo-compression.ts
7847
- var lzo;
7848
8489
  var LZOCompression = class extends Compression {
8490
+ name = "lzo";
8491
+ extensions = [];
8492
+ contentEncodings = [];
8493
+ isSupported = false;
8494
+ // !isBrowser;
8495
+ options;
7849
8496
  /**
7850
8497
  * lzo is an injectable dependency due to big size
7851
8498
  * @param options
7852
8499
  */
7853
8500
  constructor(options) {
7854
8501
  super(options);
7855
- this.name = "lzo";
7856
- this.extensions = [];
7857
- this.contentEncodings = [];
7858
- this.isSupported = false;
7859
8502
  this.options = options;
7860
- lzo = lzo || this.options?.modules?.lzo;
7861
- if (!lzo) {
7862
- throw new Error(this.name);
7863
- }
8503
+ registerJSModules(options?.modules);
7864
8504
  }
7865
- async preload() {
8505
+ async preload(modules = {}) {
8506
+ registerJSModules(modules);
7866
8507
  }
7867
8508
  async compress(input) {
7868
8509
  await this.preload();
8510
+ const lzo = getJSModule("lzo", this.name);
7869
8511
  const inputBuffer = toBuffer2(input);
7870
8512
  return lzo.compress(inputBuffer).buffer;
7871
8513
  }
7872
8514
  async decompress(input) {
7873
8515
  try {
7874
8516
  await this.preload();
8517
+ const lzo = getJSModule("lzo", this.name);
7875
8518
  const inputBuffer = toBuffer2(input);
7876
8519
  return lzo.decompress(inputBuffer).buffer;
7877
8520
  } catch (error) {
@@ -7881,12 +8524,12 @@ var __exports__ = (() => {
7881
8524
  };
7882
8525
 
7883
8526
  // src/compress-on-worker.ts
7884
- var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
8527
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
7885
8528
  var CompressionWorker = {
7886
8529
  id: "compression",
7887
8530
  name: "compression",
7888
8531
  module: "compression",
7889
- version: VERSION2,
8532
+ version: VERSION3,
7890
8533
  options: {}
7891
8534
  };
7892
8535
  function compressOnWorker(data, options) {