@loaders.gl/compression 4.2.0-alpha.6 → 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.
- package/dist/compress-on-worker.d.ts.map +1 -1
- package/dist/compress-on-worker.js +4 -1
- package/dist/compression-worker.js +2 -2
- package/dist/compression-worker.js.map +4 -4
- package/dist/dist.dev.js +663 -50
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +76 -63
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/lib/brotli-compression.d.ts +1 -1
- package/dist/lib/brotli-compression.d.ts.map +1 -1
- package/dist/lib/brotli-compression.js +9 -10
- package/dist/lib/compression.d.ts +1 -1
- package/dist/lib/compression.d.ts.map +1 -1
- package/dist/lib/compression.js +6 -1
- package/dist/lib/deflate-compression.d.ts.map +1 -1
- package/dist/lib/deflate-compression.js +3 -0
- package/dist/lib/gzip-compression.d.ts.map +1 -1
- package/dist/lib/gzip-compression.js +3 -0
- package/dist/lib/lz4-compression.d.ts +1 -0
- package/dist/lib/lz4-compression.d.ts.map +1 -1
- package/dist/lib/lz4-compression.js +10 -5
- package/dist/lib/lzo-compression.d.ts +1 -1
- package/dist/lib/lzo-compression.d.ts.map +1 -1
- package/dist/lib/lzo-compression.js +9 -7
- package/dist/lib/no-compression.d.ts.map +1 -1
- package/dist/lib/no-compression.js +3 -0
- package/dist/lib/snappy-compression.d.ts.map +1 -1
- package/dist/lib/snappy-compression.js +3 -0
- package/dist/lib/zstd-compression.d.ts +2 -1
- package/dist/lib/zstd-compression.d.ts.map +1 -1
- package/dist/lib/zstd-compression.js +29 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/dist/workers/compression-worker-node.d.ts.map +1 -1
- package/dist/workers/compression-worker-node.js +3 -0
- package/dist/workers/compression-worker.js +3 -0
- package/package.json +4 -4
- package/src/compress-on-worker.ts +4 -0
- package/src/index.ts +4 -0
- package/src/lib/brotli-compression.ts +12 -11
- package/src/lib/compression.ts +7 -1
- package/src/lib/deflate-compression.ts +4 -0
- package/src/lib/gzip-compression.ts +4 -0
- package/src/lib/lz4-compression.ts +13 -6
- package/src/lib/lzo-compression.ts +10 -9
- package/src/lib/no-compression.ts +4 -0
- package/src/lib/snappy-compression.ts +4 -0
- package/src/lib/zstd-compression.ts +35 -10
- package/src/types.ts +4 -0
- package/src/workers/compression-worker-node.ts +4 -0
- package/src/workers/compression-worker.ts +4 -0
package/dist/dist.dev.js
CHANGED
|
@@ -4691,6 +4691,607 @@ var __exports__ = (() => {
|
|
|
4691
4691
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
4692
4692
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
4693
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
|
+
|
|
4694
5295
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
4695
5296
|
var NPM_TAG = "latest";
|
|
4696
5297
|
function getVersion() {
|
|
@@ -4707,10 +5308,10 @@ var __exports__ = (() => {
|
|
|
4707
5308
|
}
|
|
4708
5309
|
return globalThis._loadersgl_.version;
|
|
4709
5310
|
}
|
|
4710
|
-
var
|
|
5311
|
+
var VERSION2 = getVersion();
|
|
4711
5312
|
|
|
4712
5313
|
// ../worker-utils/src/lib/env-utils/assert.ts
|
|
4713
|
-
function
|
|
5314
|
+
function assert2(condition, message) {
|
|
4714
5315
|
if (!condition) {
|
|
4715
5316
|
throw new Error(message || "loaders.gl assertion failed.");
|
|
4716
5317
|
}
|
|
@@ -4723,11 +5324,11 @@ var __exports__ = (() => {
|
|
|
4723
5324
|
global: typeof global !== "undefined" && global,
|
|
4724
5325
|
document: typeof document !== "undefined" && document
|
|
4725
5326
|
};
|
|
4726
|
-
var
|
|
4727
|
-
var
|
|
4728
|
-
var
|
|
4729
|
-
var
|
|
4730
|
-
var
|
|
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 = (
|
|
4731
5332
|
// @ts-ignore process.browser
|
|
4732
5333
|
typeof process !== "object" || String(process) !== "[object process]" || process.browser
|
|
4733
5334
|
);
|
|
@@ -4770,7 +5371,7 @@ var __exports__ = (() => {
|
|
|
4770
5371
|
* Call to resolve the `result` Promise with the supplied value
|
|
4771
5372
|
*/
|
|
4772
5373
|
done(value) {
|
|
4773
|
-
|
|
5374
|
+
assert2(this.isRunning);
|
|
4774
5375
|
this.isRunning = false;
|
|
4775
5376
|
this._resolve(value);
|
|
4776
5377
|
}
|
|
@@ -4778,7 +5379,7 @@ var __exports__ = (() => {
|
|
|
4778
5379
|
* Call to reject the `result` Promise with the supplied error
|
|
4779
5380
|
*/
|
|
4780
5381
|
error(error) {
|
|
4781
|
-
|
|
5382
|
+
assert2(this.isRunning);
|
|
4782
5383
|
this.isRunning = false;
|
|
4783
5384
|
this._reject(error);
|
|
4784
5385
|
}
|
|
@@ -4793,7 +5394,7 @@ var __exports__ = (() => {
|
|
|
4793
5394
|
// ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
|
|
4794
5395
|
var workerURLCache = /* @__PURE__ */ new Map();
|
|
4795
5396
|
function getLoadableWorkerURL(props) {
|
|
4796
|
-
|
|
5397
|
+
assert2(props.source && !props.url || !props.source && props.url);
|
|
4797
5398
|
let workerURL = workerURLCache.get(props.source || props.url);
|
|
4798
5399
|
if (!workerURL) {
|
|
4799
5400
|
if (props.url) {
|
|
@@ -4805,7 +5406,7 @@ var __exports__ = (() => {
|
|
|
4805
5406
|
workerURLCache.set(props.source, workerURL);
|
|
4806
5407
|
}
|
|
4807
5408
|
}
|
|
4808
|
-
|
|
5409
|
+
assert2(workerURL);
|
|
4809
5410
|
return workerURL;
|
|
4810
5411
|
}
|
|
4811
5412
|
function getLoadableWorkerURLFromURL(url) {
|
|
@@ -4893,17 +5494,17 @@ var __exports__ = (() => {
|
|
|
4893
5494
|
_loadableURL = "";
|
|
4894
5495
|
/** Checks if workers are supported on this platform */
|
|
4895
5496
|
static isSupported() {
|
|
4896
|
-
return typeof Worker !== "undefined" &&
|
|
5497
|
+
return typeof Worker !== "undefined" && isBrowser4 || typeof NodeWorker !== "undefined" && !isBrowser4;
|
|
4897
5498
|
}
|
|
4898
5499
|
constructor(props) {
|
|
4899
5500
|
const { name, source, url } = props;
|
|
4900
|
-
|
|
5501
|
+
assert2(source || url);
|
|
4901
5502
|
this.name = name;
|
|
4902
5503
|
this.source = source;
|
|
4903
5504
|
this.url = url;
|
|
4904
5505
|
this.onMessage = NOOP;
|
|
4905
5506
|
this.onError = (error) => console.log(error);
|
|
4906
|
-
this.worker =
|
|
5507
|
+
this.worker = isBrowser4 ? this._createBrowserWorker() : this._createNodeWorker();
|
|
4907
5508
|
}
|
|
4908
5509
|
/**
|
|
4909
5510
|
* Terminate this worker thread
|
|
@@ -5099,7 +5700,7 @@ var __exports__ = (() => {
|
|
|
5099
5700
|
const shouldDestroyWorker = (
|
|
5100
5701
|
// Workers on Node.js prevent the process from exiting.
|
|
5101
5702
|
// Until we figure out how to close them before exit, we always destroy them
|
|
5102
|
-
!
|
|
5703
|
+
!isBrowser4 || // If the pool is destroyed, there is no reason to keep the worker around
|
|
5103
5704
|
this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
|
|
5104
5705
|
!this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
|
|
5105
5706
|
this.count > this._getMaxConcurrency()
|
|
@@ -5218,18 +5819,18 @@ var __exports__ = (() => {
|
|
|
5218
5819
|
|
|
5219
5820
|
// ../worker-utils/src/lib/worker-api/get-worker-url.ts
|
|
5220
5821
|
function getWorkerName(worker) {
|
|
5221
|
-
const warning = worker.version !==
|
|
5822
|
+
const warning = worker.version !== VERSION2 ? ` (worker-utils@${VERSION2})` : "";
|
|
5222
5823
|
return `${worker.name}@${worker.version}${warning}`;
|
|
5223
5824
|
}
|
|
5224
5825
|
function getWorkerURL(worker, options = {}) {
|
|
5225
5826
|
const workerOptions = options[worker.id] || {};
|
|
5226
|
-
const workerFile =
|
|
5827
|
+
const workerFile = isBrowser4 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
|
|
5227
5828
|
let url = workerOptions.workerUrl;
|
|
5228
5829
|
if (!url && worker.id === "compression") {
|
|
5229
5830
|
url = options.workerUrl;
|
|
5230
5831
|
}
|
|
5231
5832
|
if (options._workerType === "test") {
|
|
5232
|
-
if (
|
|
5833
|
+
if (isBrowser4) {
|
|
5233
5834
|
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
5234
5835
|
} else {
|
|
5235
5836
|
url = `modules/${worker.module}/src/workers/${worker.id}-worker-node.ts`;
|
|
@@ -5243,7 +5844,7 @@ var __exports__ = (() => {
|
|
|
5243
5844
|
const versionTag = version ? `@${version}` : "";
|
|
5244
5845
|
url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
|
|
5245
5846
|
}
|
|
5246
|
-
|
|
5847
|
+
assert2(url);
|
|
5247
5848
|
return url;
|
|
5248
5849
|
}
|
|
5249
5850
|
|
|
@@ -5375,7 +5976,8 @@ var __exports__ = (() => {
|
|
|
5375
5976
|
this.decompressBatches = this.decompressBatches.bind(this);
|
|
5376
5977
|
}
|
|
5377
5978
|
/** Preloads any dynamic libraries. May enable sync functions */
|
|
5378
|
-
async preload() {
|
|
5979
|
+
async preload(modules = {}) {
|
|
5980
|
+
registerJSModules(modules);
|
|
5379
5981
|
return;
|
|
5380
5982
|
}
|
|
5381
5983
|
/** Asynchronously compress data */
|
|
@@ -7645,7 +8247,6 @@ var __exports__ = (() => {
|
|
|
7645
8247
|
lgwin: 22
|
|
7646
8248
|
}
|
|
7647
8249
|
};
|
|
7648
|
-
var brotli;
|
|
7649
8250
|
var BrotliCompression = class extends Compression {
|
|
7650
8251
|
name = "brotli";
|
|
7651
8252
|
extensions = ["br"];
|
|
@@ -7655,16 +8256,14 @@ var __exports__ = (() => {
|
|
|
7655
8256
|
constructor(options) {
|
|
7656
8257
|
super(options);
|
|
7657
8258
|
this.options = options;
|
|
8259
|
+
registerJSModules(options?.modules);
|
|
7658
8260
|
}
|
|
7659
8261
|
/**
|
|
7660
8262
|
* brotli is an injectable dependency due to big size
|
|
7661
8263
|
* @param options
|
|
7662
8264
|
*/
|
|
7663
|
-
async preload() {
|
|
7664
|
-
|
|
7665
|
-
if (!brotli) {
|
|
7666
|
-
console.warn(`${this.name} library not installed`);
|
|
7667
|
-
}
|
|
8265
|
+
async preload(modules = {}) {
|
|
8266
|
+
registerJSModules(modules);
|
|
7668
8267
|
}
|
|
7669
8268
|
async compress(input) {
|
|
7670
8269
|
if (!isBrowser && this.options.brotli?.useZlib) {
|
|
@@ -7680,9 +8279,7 @@ var __exports__ = (() => {
|
|
|
7680
8279
|
}
|
|
7681
8280
|
const brotliOptions = { ...DEFAULT_BROTLI_OPTIONS.brotli, ...this.options?.brotli };
|
|
7682
8281
|
const inputArray = new Uint8Array(input);
|
|
7683
|
-
|
|
7684
|
-
throw new Error("brotli compression: brotli module not installed");
|
|
7685
|
-
}
|
|
8282
|
+
const brotli = getJSModule("brotli", this.name);
|
|
7686
8283
|
const outputArray = brotli.compress(inputArray, brotliOptions);
|
|
7687
8284
|
return outputArray.buffer;
|
|
7688
8285
|
}
|
|
@@ -7700,6 +8297,7 @@ var __exports__ = (() => {
|
|
|
7700
8297
|
}
|
|
7701
8298
|
const brotliOptions = { ...DEFAULT_BROTLI_OPTIONS.brotli, ...this.options?.brotli };
|
|
7702
8299
|
const inputArray = new Uint8Array(input);
|
|
8300
|
+
const brotli = getJSModuleOrNull("brotli");
|
|
7703
8301
|
if (brotli) {
|
|
7704
8302
|
const outputArray2 = brotli.decompress(inputArray, brotliOptions);
|
|
7705
8303
|
return outputArray2.buffer;
|
|
@@ -7731,7 +8329,6 @@ var __exports__ = (() => {
|
|
|
7731
8329
|
|
|
7732
8330
|
// src/lib/lz4-compression.ts
|
|
7733
8331
|
var LZ4_MAGIC_NUMBER = 407708164;
|
|
7734
|
-
var lz4js;
|
|
7735
8332
|
var LZ4Compression = class extends Compression {
|
|
7736
8333
|
name = "lz4";
|
|
7737
8334
|
extensions = ["lz4"];
|
|
@@ -7741,12 +8338,13 @@ var __exports__ = (() => {
|
|
|
7741
8338
|
constructor(options) {
|
|
7742
8339
|
super(options);
|
|
7743
8340
|
this.options = options;
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
8341
|
+
registerJSModules(options?.modules);
|
|
8342
|
+
}
|
|
8343
|
+
async preload(modules = {}) {
|
|
8344
|
+
registerJSModules(modules);
|
|
7748
8345
|
}
|
|
7749
8346
|
compressSync(input) {
|
|
8347
|
+
const lz4js = getJSModule("lz4js", this.name);
|
|
7750
8348
|
const inputArray = new Uint8Array(input);
|
|
7751
8349
|
return lz4js.compress(inputArray).buffer;
|
|
7752
8350
|
}
|
|
@@ -7757,6 +8355,7 @@ var __exports__ = (() => {
|
|
|
7757
8355
|
* If data provided without magic number we will parse it as block
|
|
7758
8356
|
*/
|
|
7759
8357
|
decompressSync(data, maxSize) {
|
|
8358
|
+
const lz4js = getJSModule("lz4js", this.name);
|
|
7760
8359
|
try {
|
|
7761
8360
|
const isMagicNumberExists = this.checkMagicNumber(data);
|
|
7762
8361
|
const inputArray = new Uint8Array(data);
|
|
@@ -7834,7 +8433,8 @@ var __exports__ = (() => {
|
|
|
7834
8433
|
};
|
|
7835
8434
|
|
|
7836
8435
|
// src/lib/zstd-compression.ts
|
|
7837
|
-
var
|
|
8436
|
+
var CHUNK_SIZE = 1e6;
|
|
8437
|
+
var zstdPromise;
|
|
7838
8438
|
var zstd;
|
|
7839
8439
|
var ZstdCompression = class extends Compression {
|
|
7840
8440
|
name = "zstd";
|
|
@@ -7849,30 +8449,43 @@ var __exports__ = (() => {
|
|
|
7849
8449
|
constructor(options) {
|
|
7850
8450
|
super(options);
|
|
7851
8451
|
this.options = options;
|
|
7852
|
-
|
|
7853
|
-
if (!ZstdCodec) {
|
|
7854
|
-
console.warn(`${this.name} library not installed`);
|
|
7855
|
-
}
|
|
8452
|
+
registerJSModules(options?.modules);
|
|
7856
8453
|
}
|
|
7857
|
-
async preload() {
|
|
7858
|
-
|
|
7859
|
-
|
|
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;
|
|
7860
8461
|
}
|
|
7861
8462
|
}
|
|
7862
8463
|
compressSync(input) {
|
|
8464
|
+
getJSModule("zstd-codec", this.name);
|
|
7863
8465
|
const simpleZstd = new zstd.Simple();
|
|
7864
8466
|
const inputArray = new Uint8Array(input);
|
|
7865
8467
|
return simpleZstd.compress(inputArray).buffer;
|
|
7866
8468
|
}
|
|
7867
8469
|
decompressSync(input) {
|
|
8470
|
+
getJSModule("zstd-codec", this.name);
|
|
7868
8471
|
const simpleZstd = new zstd.Simple();
|
|
7869
8472
|
const inputArray = new Uint8Array(input);
|
|
7870
8473
|
return simpleZstd.decompress(inputArray).buffer;
|
|
7871
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
|
+
}
|
|
7872
8486
|
};
|
|
7873
8487
|
|
|
7874
8488
|
// src/lib/lzo-compression.ts
|
|
7875
|
-
var lzo;
|
|
7876
8489
|
var LZOCompression = class extends Compression {
|
|
7877
8490
|
name = "lzo";
|
|
7878
8491
|
extensions = [];
|
|
@@ -7887,21 +8500,21 @@ var __exports__ = (() => {
|
|
|
7887
8500
|
constructor(options) {
|
|
7888
8501
|
super(options);
|
|
7889
8502
|
this.options = options;
|
|
7890
|
-
|
|
7891
|
-
if (!lzo) {
|
|
7892
|
-
throw new Error(this.name);
|
|
7893
|
-
}
|
|
8503
|
+
registerJSModules(options?.modules);
|
|
7894
8504
|
}
|
|
7895
|
-
async preload() {
|
|
8505
|
+
async preload(modules = {}) {
|
|
8506
|
+
registerJSModules(modules);
|
|
7896
8507
|
}
|
|
7897
8508
|
async compress(input) {
|
|
7898
8509
|
await this.preload();
|
|
8510
|
+
const lzo = getJSModule("lzo", this.name);
|
|
7899
8511
|
const inputBuffer = toBuffer2(input);
|
|
7900
8512
|
return lzo.compress(inputBuffer).buffer;
|
|
7901
8513
|
}
|
|
7902
8514
|
async decompress(input) {
|
|
7903
8515
|
try {
|
|
7904
8516
|
await this.preload();
|
|
8517
|
+
const lzo = getJSModule("lzo", this.name);
|
|
7905
8518
|
const inputBuffer = toBuffer2(input);
|
|
7906
8519
|
return lzo.decompress(inputBuffer).buffer;
|
|
7907
8520
|
} catch (error) {
|
|
@@ -7911,12 +8524,12 @@ var __exports__ = (() => {
|
|
|
7911
8524
|
};
|
|
7912
8525
|
|
|
7913
8526
|
// src/compress-on-worker.ts
|
|
7914
|
-
var
|
|
8527
|
+
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
7915
8528
|
var CompressionWorker = {
|
|
7916
8529
|
id: "compression",
|
|
7917
8530
|
name: "compression",
|
|
7918
8531
|
module: "compression",
|
|
7919
|
-
version:
|
|
8532
|
+
version: VERSION3,
|
|
7920
8533
|
options: {}
|
|
7921
8534
|
};
|
|
7922
8535
|
function compressOnWorker(data, options) {
|