@loaders.gl/i3s 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.
- package/dist/arcgis-webscene-loader.d.ts +19 -2
- package/dist/arcgis-webscene-loader.d.ts.map +1 -1
- package/dist/arcgis-webscene-loader.js +3 -1
- package/dist/dist.dev.js +192 -144
- package/dist/dist.min.js +1 -1
- package/dist/i3s-attribute-loader.d.ts +14 -3
- package/dist/i3s-attribute-loader.d.ts.map +1 -1
- package/dist/i3s-attribute-loader.js +3 -1
- package/dist/i3s-building-scene-layer-loader.d.ts +15 -3
- package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -1
- package/dist/i3s-building-scene-layer-loader.js +3 -1
- package/dist/i3s-content-loader.d.ts +18 -2
- package/dist/i3s-content-loader.d.ts.map +1 -1
- package/dist/i3s-content-loader.js +6 -1
- package/dist/i3s-content-worker-node.js +51 -51
- package/dist/i3s-content-worker-node.js.map +4 -4
- package/dist/i3s-content-worker.js +1722 -1702
- package/dist/i3s-loader.d.ts +30 -2
- package/dist/i3s-loader.d.ts.map +1 -1
- package/dist/i3s-loader.js +8 -2
- package/dist/i3s-node-page-loader.d.ts +17 -3
- package/dist/i3s-node-page-loader.d.ts.map +1 -1
- package/dist/i3s-node-page-loader.js +6 -1
- package/dist/i3s-slpk-loader.d.ts +13 -2
- package/dist/i3s-slpk-loader.d.ts.map +1 -1
- package/dist/i3s-slpk-loader.js +6 -1
- package/dist/index.cjs +43 -35
- package/dist/index.cjs.map +2 -2
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
- package/dist/lib/helpers/i3s-nodepages-tiles.js +11 -7
- package/dist/lib/parsers/parse-arcgis-webscene.js +1 -0
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +3 -25
- package/dist/lib/parsers/parse-slpk/slpk-archieve.js +5 -3
- package/package.json +12 -10
- package/src/arcgis-webscene-loader.ts +4 -6
- package/src/i3s-attribute-loader.ts +4 -2
- package/src/i3s-building-scene-layer-loader.ts +6 -6
- package/src/i3s-content-loader.ts +9 -2
- package/src/i3s-loader.ts +11 -3
- package/src/i3s-node-page-loader.ts +9 -2
- package/src/i3s-slpk-loader.ts +9 -2
- package/src/lib/helpers/i3s-nodepages-tiles.ts +1 -3
- package/src/lib/parsers/parse-i3s-tile-content.ts +7 -30
|
@@ -1,47 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
-
};
|
|
13
5
|
var __export = (target, all) => {
|
|
14
6
|
for (var name in all)
|
|
15
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
8
|
};
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
-
for (let key of __getOwnPropNames(from))
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
-
mod
|
|
32
|
-
));
|
|
33
9
|
var __publicField = (obj, key, value) => {
|
|
34
10
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
35
11
|
return value;
|
|
36
12
|
};
|
|
37
13
|
|
|
38
|
-
// (disabled):../worker-utils/src/lib/node/require-utils.node
|
|
39
|
-
var require_require_utils = __commonJS({
|
|
40
|
-
"(disabled):../worker-utils/src/lib/node/require-utils.node"() {
|
|
41
|
-
"use strict";
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
14
|
// ../loader-utils/src/loader-types.ts
|
|
46
15
|
async function parseFromContext(data, loaders, options, context) {
|
|
47
16
|
return context._parse(data, loaders, options, context);
|
|
@@ -72,1873 +41,1921 @@
|
|
|
72
41
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
73
42
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
74
43
|
|
|
75
|
-
//
|
|
76
|
-
function
|
|
77
|
-
|
|
44
|
+
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
45
|
+
function _typeof(obj) {
|
|
46
|
+
"@babel/helpers - typeof";
|
|
47
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
48
|
+
return typeof obj2;
|
|
49
|
+
} : function(obj2) {
|
|
50
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
51
|
+
}, _typeof(obj);
|
|
78
52
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
);
|
|
91
|
-
} else {
|
|
92
|
-
options[key] = newOptions[key];
|
|
93
|
-
}
|
|
53
|
+
|
|
54
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
55
|
+
function _toPrimitive(input, hint) {
|
|
56
|
+
if (_typeof(input) !== "object" || input === null)
|
|
57
|
+
return input;
|
|
58
|
+
var prim = input[Symbol.toPrimitive];
|
|
59
|
+
if (prim !== void 0) {
|
|
60
|
+
var res = prim.call(input, hint || "default");
|
|
61
|
+
if (_typeof(res) !== "object")
|
|
62
|
+
return res;
|
|
63
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
94
64
|
}
|
|
95
|
-
return
|
|
65
|
+
return (hint === "string" ? String : Number)(input);
|
|
96
66
|
}
|
|
97
67
|
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
68
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
69
|
+
function _toPropertyKey(arg) {
|
|
70
|
+
var key = _toPrimitive(arg, "string");
|
|
71
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
75
|
+
function _defineProperty(obj, key, value) {
|
|
76
|
+
key = _toPropertyKey(key);
|
|
77
|
+
if (key in obj) {
|
|
78
|
+
Object.defineProperty(obj, key, {
|
|
79
|
+
value,
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
obj[key] = value;
|
|
111
86
|
}
|
|
112
|
-
return
|
|
87
|
+
return obj;
|
|
113
88
|
}
|
|
114
|
-
var VERSION = getVersion();
|
|
115
89
|
|
|
116
|
-
//
|
|
117
|
-
function
|
|
118
|
-
if (
|
|
119
|
-
|
|
90
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
91
|
+
function isElectron(mockUserAgent) {
|
|
92
|
+
if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
|
|
96
|
+
return true;
|
|
120
97
|
}
|
|
98
|
+
const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
|
|
99
|
+
const userAgent = mockUserAgent || realUserAgent;
|
|
100
|
+
if (userAgent && userAgent.indexOf("Electron") >= 0) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
121
104
|
}
|
|
122
105
|
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
document: typeof document !== "undefined" && document
|
|
129
|
-
};
|
|
130
|
-
var self_2 = globals2.self || globals2.window || globals2.global || {};
|
|
131
|
-
var window_2 = globals2.window || globals2.self || globals2.global || {};
|
|
132
|
-
var global_2 = globals2.global || globals2.self || globals2.window || {};
|
|
133
|
-
var document_2 = globals2.document || {};
|
|
134
|
-
var isBrowser2 = (
|
|
135
|
-
// @ts-ignore process.browser
|
|
136
|
-
typeof process !== "object" || String(process) !== "[object process]" || process.browser
|
|
137
|
-
);
|
|
138
|
-
var isWorker = typeof importScripts === "function";
|
|
139
|
-
var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
|
|
140
|
-
var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
141
|
-
var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
|
|
106
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
107
|
+
function isBrowser2() {
|
|
108
|
+
const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
|
|
109
|
+
return !isNode || isElectron();
|
|
110
|
+
}
|
|
142
111
|
|
|
143
|
-
//
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
112
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
|
|
113
|
+
var self_2 = globalThis.self || globalThis.window || globalThis.global;
|
|
114
|
+
var window_2 = globalThis.window || globalThis.self || globalThis.global;
|
|
115
|
+
var document_2 = globalThis.document || {};
|
|
116
|
+
var process_ = globalThis.process || {};
|
|
117
|
+
var console_ = globalThis.console;
|
|
118
|
+
var navigator_ = globalThis.navigator || {};
|
|
119
|
+
|
|
120
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
|
|
121
|
+
var VERSION = true ? "4.2.0-alpha.6" : "untranspiled source";
|
|
122
|
+
var isBrowser3 = isBrowser2();
|
|
123
|
+
|
|
124
|
+
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
125
|
+
function getStorage(type) {
|
|
126
|
+
try {
|
|
127
|
+
const storage = window[type];
|
|
128
|
+
const x = "__storage_test__";
|
|
129
|
+
storage.setItem(x, x);
|
|
130
|
+
storage.removeItem(x);
|
|
131
|
+
return storage;
|
|
132
|
+
} catch (e2) {
|
|
133
|
+
return null;
|
|
161
134
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
this
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
135
|
+
}
|
|
136
|
+
var LocalStorage = class {
|
|
137
|
+
constructor(id, defaultConfig) {
|
|
138
|
+
let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
|
|
139
|
+
_defineProperty(this, "storage", void 0);
|
|
140
|
+
_defineProperty(this, "id", void 0);
|
|
141
|
+
_defineProperty(this, "config", void 0);
|
|
142
|
+
this.storage = getStorage(type);
|
|
143
|
+
this.id = id;
|
|
144
|
+
this.config = defaultConfig;
|
|
145
|
+
this._loadConfiguration();
|
|
173
146
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
*/
|
|
177
|
-
done(value) {
|
|
178
|
-
assert2(this.isRunning);
|
|
179
|
-
this.isRunning = false;
|
|
180
|
-
this._resolve(value);
|
|
147
|
+
getConfiguration() {
|
|
148
|
+
return this.config;
|
|
181
149
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
this._reject(error);
|
|
150
|
+
setConfiguration(configuration) {
|
|
151
|
+
Object.assign(this.config, configuration);
|
|
152
|
+
if (this.storage) {
|
|
153
|
+
const serialized = JSON.stringify(this.config);
|
|
154
|
+
this.storage.setItem(this.id, serialized);
|
|
155
|
+
}
|
|
189
156
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
157
|
+
_loadConfiguration() {
|
|
158
|
+
let configuration = {};
|
|
159
|
+
if (this.storage) {
|
|
160
|
+
const serializedConfiguration = this.storage.getItem(this.id);
|
|
161
|
+
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
|
|
162
|
+
}
|
|
163
|
+
Object.assign(this.config, configuration);
|
|
164
|
+
return this;
|
|
195
165
|
}
|
|
196
166
|
};
|
|
197
|
-
var parentPort = null;
|
|
198
167
|
|
|
199
|
-
//
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
workerURL = getLoadableWorkerURLFromSource(props.source);
|
|
211
|
-
workerURLCache.set(props.source, workerURL);
|
|
212
|
-
}
|
|
168
|
+
// ../../node_modules/@probe.gl/log/dist/utils/formatters.js
|
|
169
|
+
function formatTime(ms) {
|
|
170
|
+
let formatted;
|
|
171
|
+
if (ms < 10) {
|
|
172
|
+
formatted = "".concat(ms.toFixed(2), "ms");
|
|
173
|
+
} else if (ms < 100) {
|
|
174
|
+
formatted = "".concat(ms.toFixed(1), "ms");
|
|
175
|
+
} else if (ms < 1e3) {
|
|
176
|
+
formatted = "".concat(ms.toFixed(0), "ms");
|
|
177
|
+
} else {
|
|
178
|
+
formatted = "".concat((ms / 1e3).toFixed(2), "s");
|
|
213
179
|
}
|
|
214
|
-
|
|
215
|
-
return workerURL;
|
|
180
|
+
return formatted;
|
|
216
181
|
}
|
|
217
|
-
function
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const workerSource = buildScriptSource(url);
|
|
222
|
-
return getLoadableWorkerURLFromSource(workerSource);
|
|
182
|
+
function leftPad(string) {
|
|
183
|
+
let length2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
|
|
184
|
+
const padLength = Math.max(length2 - string.length, 0);
|
|
185
|
+
return "".concat(" ".repeat(padLength)).concat(string);
|
|
223
186
|
}
|
|
224
|
-
function
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}`;
|
|
187
|
+
function formatImage(image, message, scale3) {
|
|
188
|
+
let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
|
|
189
|
+
const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
|
|
190
|
+
if (image.width > maxWidth) {
|
|
191
|
+
scale3 = Math.min(scale3, maxWidth / image.width);
|
|
192
|
+
}
|
|
193
|
+
const width = image.width * scale3;
|
|
194
|
+
const height = image.height * scale3;
|
|
195
|
+
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("");
|
|
196
|
+
return ["".concat(message, " %c+"), style];
|
|
235
197
|
}
|
|
236
198
|
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
199
|
+
// ../../node_modules/@probe.gl/log/dist/utils/color.js
|
|
200
|
+
var COLOR;
|
|
201
|
+
(function(COLOR2) {
|
|
202
|
+
COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
|
|
203
|
+
COLOR2[COLOR2["RED"] = 31] = "RED";
|
|
204
|
+
COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
|
|
205
|
+
COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
|
|
206
|
+
COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
|
|
207
|
+
COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
|
|
208
|
+
COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
|
|
209
|
+
COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
|
|
210
|
+
COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
|
|
211
|
+
COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
|
|
212
|
+
COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
|
|
213
|
+
COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
|
|
214
|
+
COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
|
|
215
|
+
COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
|
|
216
|
+
COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
|
|
217
|
+
COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
|
|
218
|
+
})(COLOR || (COLOR = {}));
|
|
219
|
+
var BACKGROUND_INCREMENT = 10;
|
|
220
|
+
function getColor(color) {
|
|
221
|
+
if (typeof color !== "string") {
|
|
222
|
+
return color;
|
|
250
223
|
}
|
|
251
|
-
|
|
224
|
+
color = color.toUpperCase();
|
|
225
|
+
return COLOR[color] || COLOR.WHITE;
|
|
252
226
|
}
|
|
253
|
-
function
|
|
254
|
-
if (!
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
227
|
+
function addColor(string, color, background) {
|
|
228
|
+
if (!isBrowser2 && typeof string === "string") {
|
|
229
|
+
if (color) {
|
|
230
|
+
const colorCode = getColor(color);
|
|
231
|
+
string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
|
|
232
|
+
}
|
|
233
|
+
if (background) {
|
|
234
|
+
const colorCode = getColor(background);
|
|
235
|
+
string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
|
|
236
|
+
}
|
|
259
237
|
}
|
|
260
|
-
|
|
261
|
-
|
|
238
|
+
return string;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ../../node_modules/@probe.gl/log/dist/utils/autobind.js
|
|
242
|
+
function autobind(obj) {
|
|
243
|
+
let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
|
|
244
|
+
const proto = Object.getPrototypeOf(obj);
|
|
245
|
+
const propNames = Object.getOwnPropertyNames(proto);
|
|
246
|
+
const object = obj;
|
|
247
|
+
for (const key of propNames) {
|
|
248
|
+
const value = object[key];
|
|
249
|
+
if (typeof value === "function") {
|
|
250
|
+
if (!predefined.find((name) => key === name)) {
|
|
251
|
+
object[key] = value.bind(obj);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
262
254
|
}
|
|
263
|
-
|
|
264
|
-
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ../../node_modules/@probe.gl/log/dist/utils/assert.js
|
|
258
|
+
function assert2(condition, message) {
|
|
259
|
+
if (!condition) {
|
|
260
|
+
throw new Error(message || "Assertion failed");
|
|
265
261
|
}
|
|
266
|
-
|
|
267
|
-
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
|
|
265
|
+
function getHiResTimestamp() {
|
|
266
|
+
let timestamp;
|
|
267
|
+
if (isBrowser2() && window_2.performance) {
|
|
268
|
+
var _window$performance, _window$performance$n;
|
|
269
|
+
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);
|
|
270
|
+
} else if ("hrtime" in process_) {
|
|
271
|
+
var _process$hrtime;
|
|
272
|
+
const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
|
|
273
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
274
|
+
} else {
|
|
275
|
+
timestamp = Date.now();
|
|
268
276
|
}
|
|
269
|
-
return
|
|
277
|
+
return timestamp;
|
|
270
278
|
}
|
|
271
279
|
|
|
272
|
-
//
|
|
273
|
-
var
|
|
280
|
+
// ../../node_modules/@probe.gl/log/dist/log.js
|
|
281
|
+
var originalConsole = {
|
|
282
|
+
debug: isBrowser2() ? console.debug || console.log : console.log,
|
|
283
|
+
log: console.log,
|
|
284
|
+
info: console.info,
|
|
285
|
+
warn: console.warn,
|
|
286
|
+
error: console.error
|
|
274
287
|
};
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
288
|
+
var DEFAULT_LOG_CONFIGURATION = {
|
|
289
|
+
enabled: true,
|
|
290
|
+
level: 0
|
|
291
|
+
};
|
|
292
|
+
function noop() {
|
|
293
|
+
}
|
|
294
|
+
var cache = {};
|
|
295
|
+
var ONCE = {
|
|
296
|
+
once: true
|
|
297
|
+
};
|
|
298
|
+
var Log = class {
|
|
299
|
+
constructor() {
|
|
300
|
+
let {
|
|
301
|
+
id
|
|
302
|
+
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
303
|
+
id: ""
|
|
304
|
+
};
|
|
305
|
+
_defineProperty(this, "id", void 0);
|
|
306
|
+
_defineProperty(this, "VERSION", VERSION);
|
|
307
|
+
_defineProperty(this, "_startTs", getHiResTimestamp());
|
|
308
|
+
_defineProperty(this, "_deltaTs", getHiResTimestamp());
|
|
309
|
+
_defineProperty(this, "_storage", void 0);
|
|
310
|
+
_defineProperty(this, "userData", {});
|
|
311
|
+
_defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
|
|
312
|
+
this.id = id;
|
|
313
|
+
this.userData = {};
|
|
314
|
+
this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
|
|
315
|
+
this.timeStamp("".concat(this.id, " started"));
|
|
316
|
+
autobind(this);
|
|
317
|
+
Object.seal(this);
|
|
287
318
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
assert2(source || url);
|
|
291
|
-
this.name = name;
|
|
292
|
-
this.source = source;
|
|
293
|
-
this.url = url;
|
|
294
|
-
this.onMessage = NOOP;
|
|
295
|
-
this.onError = (error) => console.log(error);
|
|
296
|
-
this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
|
|
319
|
+
set level(newLevel) {
|
|
320
|
+
this.setLevel(newLevel);
|
|
297
321
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
* @note Can free up significant memory
|
|
301
|
-
*/
|
|
302
|
-
destroy() {
|
|
303
|
-
this.onMessage = NOOP;
|
|
304
|
-
this.onError = NOOP;
|
|
305
|
-
this.worker.terminate();
|
|
306
|
-
this.terminated = true;
|
|
322
|
+
get level() {
|
|
323
|
+
return this.getLevel();
|
|
307
324
|
}
|
|
308
|
-
|
|
309
|
-
return
|
|
325
|
+
isEnabled() {
|
|
326
|
+
return this._storage.config.enabled;
|
|
310
327
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
* @param data any data structure, ideally consisting mostly of transferrable objects
|
|
314
|
-
* @param transferList If not supplied, calculated automatically by traversing data
|
|
315
|
-
*/
|
|
316
|
-
postMessage(data, transferList) {
|
|
317
|
-
transferList = transferList || getTransferList(data);
|
|
318
|
-
this.worker.postMessage(data, transferList);
|
|
328
|
+
getLevel() {
|
|
329
|
+
return this._storage.config.level;
|
|
319
330
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
* Generate a standard Error from an ErrorEvent
|
|
323
|
-
* @param event
|
|
324
|
-
*/
|
|
325
|
-
_getErrorFromErrorEvent(event) {
|
|
326
|
-
let message = "Failed to load ";
|
|
327
|
-
message += `worker ${this.name} from ${this.url}. `;
|
|
328
|
-
if (event.message) {
|
|
329
|
-
message += `${event.message} in `;
|
|
330
|
-
}
|
|
331
|
-
if (event.lineno) {
|
|
332
|
-
message += `:${event.lineno}:${event.colno}`;
|
|
333
|
-
}
|
|
334
|
-
return new Error(message);
|
|
331
|
+
getTotal() {
|
|
332
|
+
return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
|
|
335
333
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
*/
|
|
339
|
-
_createBrowserWorker() {
|
|
340
|
-
this._loadableURL = getLoadableWorkerURL({ source: this.source, url: this.url });
|
|
341
|
-
const worker = new Worker(this._loadableURL, { name: this.name });
|
|
342
|
-
worker.onmessage = (event) => {
|
|
343
|
-
if (!event.data) {
|
|
344
|
-
this.onError(new Error("No data received"));
|
|
345
|
-
} else {
|
|
346
|
-
this.onMessage(event.data);
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
worker.onerror = (error) => {
|
|
350
|
-
this.onError(this._getErrorFromErrorEvent(error));
|
|
351
|
-
this.terminated = true;
|
|
352
|
-
};
|
|
353
|
-
worker.onmessageerror = (event) => console.error(event);
|
|
354
|
-
return worker;
|
|
334
|
+
getDelta() {
|
|
335
|
+
return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
|
|
355
336
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
* @todo https://nodejs.org/api/async_hooks.html#async-resource-worker-pool
|
|
359
|
-
*/
|
|
360
|
-
_createNodeWorker() {
|
|
361
|
-
let worker;
|
|
362
|
-
if (this.url) {
|
|
363
|
-
const absolute = this.url.includes(":/") || this.url.startsWith("/");
|
|
364
|
-
const url = absolute ? this.url : `./${this.url}`;
|
|
365
|
-
worker = new NodeWorker(url, { eval: false });
|
|
366
|
-
} else if (this.source) {
|
|
367
|
-
worker = new NodeWorker(this.source, { eval: true });
|
|
368
|
-
} else {
|
|
369
|
-
throw new Error("no worker");
|
|
370
|
-
}
|
|
371
|
-
worker.on("message", (data) => {
|
|
372
|
-
this.onMessage(data);
|
|
373
|
-
});
|
|
374
|
-
worker.on("error", (error) => {
|
|
375
|
-
this.onError(error);
|
|
376
|
-
});
|
|
377
|
-
worker.on("exit", (code) => {
|
|
378
|
-
});
|
|
379
|
-
return worker;
|
|
337
|
+
set priority(newPriority) {
|
|
338
|
+
this.level = newPriority;
|
|
380
339
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
// ../worker-utils/src/lib/worker-farm/worker-pool.ts
|
|
384
|
-
var WorkerPool = class {
|
|
385
|
-
name = "unnamed";
|
|
386
|
-
source;
|
|
387
|
-
// | Function;
|
|
388
|
-
url;
|
|
389
|
-
maxConcurrency = 1;
|
|
390
|
-
maxMobileConcurrency = 1;
|
|
391
|
-
onDebug = () => {
|
|
392
|
-
};
|
|
393
|
-
reuseWorkers = true;
|
|
394
|
-
props = {};
|
|
395
|
-
jobQueue = [];
|
|
396
|
-
idleQueue = [];
|
|
397
|
-
count = 0;
|
|
398
|
-
isDestroyed = false;
|
|
399
|
-
/** Checks if workers are supported on this platform */
|
|
400
|
-
static isSupported() {
|
|
401
|
-
return WorkerThread.isSupported();
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* @param processor - worker function
|
|
405
|
-
* @param maxConcurrency - max count of workers
|
|
406
|
-
*/
|
|
407
|
-
constructor(props) {
|
|
408
|
-
this.source = props.source;
|
|
409
|
-
this.url = props.url;
|
|
410
|
-
this.setProps(props);
|
|
340
|
+
get priority() {
|
|
341
|
+
return this.level;
|
|
411
342
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
* @note Can free up significant memory
|
|
415
|
-
*/
|
|
416
|
-
destroy() {
|
|
417
|
-
this.idleQueue.forEach((worker) => worker.destroy());
|
|
418
|
-
this.isDestroyed = true;
|
|
343
|
+
getPriority() {
|
|
344
|
+
return this.level;
|
|
419
345
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
this.maxConcurrency = props.maxConcurrency;
|
|
427
|
-
}
|
|
428
|
-
if (props.maxMobileConcurrency !== void 0) {
|
|
429
|
-
this.maxMobileConcurrency = props.maxMobileConcurrency;
|
|
430
|
-
}
|
|
431
|
-
if (props.reuseWorkers !== void 0) {
|
|
432
|
-
this.reuseWorkers = props.reuseWorkers;
|
|
433
|
-
}
|
|
434
|
-
if (props.onDebug !== void 0) {
|
|
435
|
-
this.onDebug = props.onDebug;
|
|
436
|
-
}
|
|
346
|
+
enable() {
|
|
347
|
+
let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
348
|
+
this._storage.setConfiguration({
|
|
349
|
+
enabled
|
|
350
|
+
});
|
|
351
|
+
return this;
|
|
437
352
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
return this;
|
|
353
|
+
setLevel(level) {
|
|
354
|
+
this._storage.setConfiguration({
|
|
355
|
+
level
|
|
442
356
|
});
|
|
443
|
-
this
|
|
444
|
-
return await startPromise;
|
|
357
|
+
return this;
|
|
445
358
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
* Starts first queued job if worker is available or can be created
|
|
449
|
-
* Called when job is started and whenever a worker returns to the idleQueue
|
|
450
|
-
*/
|
|
451
|
-
async _startQueuedJob() {
|
|
452
|
-
if (!this.jobQueue.length) {
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
const workerThread = this._getAvailableWorker();
|
|
456
|
-
if (!workerThread) {
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
const queuedJob = this.jobQueue.shift();
|
|
460
|
-
if (queuedJob) {
|
|
461
|
-
this.onDebug({
|
|
462
|
-
message: "Starting job",
|
|
463
|
-
name: queuedJob.name,
|
|
464
|
-
workerThread,
|
|
465
|
-
backlog: this.jobQueue.length
|
|
466
|
-
});
|
|
467
|
-
const job = new WorkerJob(queuedJob.name, workerThread);
|
|
468
|
-
workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
|
|
469
|
-
workerThread.onError = (error) => queuedJob.onError(job, error);
|
|
470
|
-
queuedJob.onStart(job);
|
|
471
|
-
try {
|
|
472
|
-
await job.result;
|
|
473
|
-
} catch (error) {
|
|
474
|
-
console.error(`Worker exception: ${error}`);
|
|
475
|
-
} finally {
|
|
476
|
-
this.returnWorkerToQueue(workerThread);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
359
|
+
get(setting) {
|
|
360
|
+
return this._storage.config[setting];
|
|
479
361
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
returnWorkerToQueue(worker) {
|
|
489
|
-
const shouldDestroyWorker = (
|
|
490
|
-
// Workers on Node.js prevent the process from exiting.
|
|
491
|
-
// Until we figure out how to close them before exit, we always destroy them
|
|
492
|
-
!isBrowser2 || // If the pool is destroyed, there is no reason to keep the worker around
|
|
493
|
-
this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
|
|
494
|
-
!this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
|
|
495
|
-
this.count > this._getMaxConcurrency()
|
|
496
|
-
);
|
|
497
|
-
if (shouldDestroyWorker) {
|
|
498
|
-
worker.destroy();
|
|
499
|
-
this.count--;
|
|
362
|
+
set(setting, value) {
|
|
363
|
+
this._storage.setConfiguration({
|
|
364
|
+
[setting]: value
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
settings() {
|
|
368
|
+
if (console.table) {
|
|
369
|
+
console.table(this._storage.config);
|
|
500
370
|
} else {
|
|
501
|
-
this.
|
|
502
|
-
}
|
|
503
|
-
if (!this.isDestroyed) {
|
|
504
|
-
this._startQueuedJob();
|
|
371
|
+
console.log(this._storage.config);
|
|
505
372
|
}
|
|
506
373
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
*/
|
|
510
|
-
_getAvailableWorker() {
|
|
511
|
-
if (this.idleQueue.length > 0) {
|
|
512
|
-
return this.idleQueue.shift() || null;
|
|
513
|
-
}
|
|
514
|
-
if (this.count < this._getMaxConcurrency()) {
|
|
515
|
-
this.count++;
|
|
516
|
-
const name = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
|
|
517
|
-
return new WorkerThread({ name, source: this.source, url: this.url });
|
|
518
|
-
}
|
|
519
|
-
return null;
|
|
374
|
+
assert(condition, message) {
|
|
375
|
+
assert2(condition, message);
|
|
520
376
|
}
|
|
521
|
-
|
|
522
|
-
return
|
|
377
|
+
warn(message) {
|
|
378
|
+
return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
|
|
523
379
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
// ../worker-utils/src/lib/worker-farm/worker-farm.ts
|
|
527
|
-
var DEFAULT_PROPS = {
|
|
528
|
-
maxConcurrency: 3,
|
|
529
|
-
maxMobileConcurrency: 1,
|
|
530
|
-
reuseWorkers: true,
|
|
531
|
-
onDebug: () => {
|
|
380
|
+
error(message) {
|
|
381
|
+
return this._getLogFunction(0, message, originalConsole.error, arguments);
|
|
532
382
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
props;
|
|
536
|
-
workerPools = /* @__PURE__ */ new Map();
|
|
537
|
-
/** Checks if workers are supported on this platform */
|
|
538
|
-
static isSupported() {
|
|
539
|
-
return WorkerThread.isSupported();
|
|
383
|
+
deprecated(oldUsage, newUsage) {
|
|
384
|
+
return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
|
|
540
385
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
_WorkerFarm._workerFarm = _WorkerFarm._workerFarm || new _WorkerFarm({});
|
|
544
|
-
_WorkerFarm._workerFarm.setProps(props);
|
|
545
|
-
return _WorkerFarm._workerFarm;
|
|
386
|
+
removed(oldUsage, newUsage) {
|
|
387
|
+
return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
|
|
546
388
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
389
|
+
probe(logLevel, message) {
|
|
390
|
+
return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
|
|
391
|
+
time: true,
|
|
392
|
+
once: true
|
|
393
|
+
});
|
|
552
394
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
* @note Can free up significant memory
|
|
556
|
-
*/
|
|
557
|
-
destroy() {
|
|
558
|
-
for (const workerPool of this.workerPools.values()) {
|
|
559
|
-
workerPool.destroy();
|
|
560
|
-
}
|
|
561
|
-
this.workerPools = /* @__PURE__ */ new Map();
|
|
395
|
+
log(logLevel, message) {
|
|
396
|
+
return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
|
|
562
397
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
* @param props
|
|
566
|
-
*/
|
|
567
|
-
setProps(props) {
|
|
568
|
-
this.props = { ...this.props, ...props };
|
|
569
|
-
for (const workerPool of this.workerPools.values()) {
|
|
570
|
-
workerPool.setProps(this._getWorkerPoolProps());
|
|
571
|
-
}
|
|
398
|
+
info(logLevel, message) {
|
|
399
|
+
return this._getLogFunction(logLevel, message, console.info, arguments);
|
|
572
400
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
* const job = WorkerFarm.getWorkerFarm().getWorkerPool({name, url}).startJob(...);
|
|
581
|
-
*/
|
|
582
|
-
getWorkerPool(options) {
|
|
583
|
-
const { name, source, url } = options;
|
|
584
|
-
let workerPool = this.workerPools.get(name);
|
|
585
|
-
if (!workerPool) {
|
|
586
|
-
workerPool = new WorkerPool({
|
|
587
|
-
name,
|
|
588
|
-
source,
|
|
589
|
-
url
|
|
401
|
+
once(logLevel, message) {
|
|
402
|
+
return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
|
|
403
|
+
}
|
|
404
|
+
table(logLevel, table, columns) {
|
|
405
|
+
if (table) {
|
|
406
|
+
return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
|
|
407
|
+
tag: getTableHeader(table)
|
|
590
408
|
});
|
|
591
|
-
workerPool.setProps(this._getWorkerPoolProps());
|
|
592
|
-
this.workerPools.set(name, workerPool);
|
|
593
409
|
}
|
|
594
|
-
return
|
|
595
|
-
}
|
|
596
|
-
_getWorkerPoolProps() {
|
|
597
|
-
return {
|
|
598
|
-
maxConcurrency: this.props.maxConcurrency,
|
|
599
|
-
maxMobileConcurrency: this.props.maxMobileConcurrency,
|
|
600
|
-
reuseWorkers: this.props.reuseWorkers,
|
|
601
|
-
onDebug: this.props.onDebug
|
|
602
|
-
};
|
|
410
|
+
return noop;
|
|
603
411
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
var WorkerBody = class {
|
|
615
|
-
/** Check that we are actually in a worker thread */
|
|
616
|
-
static async inWorkerThread() {
|
|
617
|
-
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
618
|
-
}
|
|
619
|
-
/*
|
|
620
|
-
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
621
|
-
*/
|
|
622
|
-
static set onmessage(onMessage2) {
|
|
623
|
-
async function handleMessage(message) {
|
|
624
|
-
const parentPort2 = await getParentPort();
|
|
625
|
-
const { type, payload } = parentPort2 ? message : message.data;
|
|
626
|
-
onMessage2(type, payload);
|
|
412
|
+
image(_ref) {
|
|
413
|
+
let {
|
|
414
|
+
logLevel,
|
|
415
|
+
priority,
|
|
416
|
+
image,
|
|
417
|
+
message = "",
|
|
418
|
+
scale: scale3 = 1
|
|
419
|
+
} = _ref;
|
|
420
|
+
if (!this._shouldLog(logLevel || priority)) {
|
|
421
|
+
return noop;
|
|
627
422
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
423
|
+
return isBrowser2() ? logImageInBrowser({
|
|
424
|
+
image,
|
|
425
|
+
message,
|
|
426
|
+
scale: scale3
|
|
427
|
+
}) : logImageInNode({
|
|
428
|
+
image,
|
|
429
|
+
message,
|
|
430
|
+
scale: scale3
|
|
635
431
|
});
|
|
636
432
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
if (!onMessageWrapper) {
|
|
640
|
-
onMessageWrapper = async (message) => {
|
|
641
|
-
if (!isKnownMessage(message)) {
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
const parentPort3 = await getParentPort();
|
|
645
|
-
const { type, payload } = parentPort3 ? message : message.data;
|
|
646
|
-
onMessage2(type, payload);
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
const parentPort2 = await getParentPort();
|
|
650
|
-
if (parentPort2) {
|
|
651
|
-
console.error("not implemented");
|
|
652
|
-
} else {
|
|
653
|
-
globalThis.addEventListener("message", onMessageWrapper);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
static async removeEventListener(onMessage2) {
|
|
657
|
-
const onMessageWrapper = onMessageWrapperMap.get(onMessage2);
|
|
658
|
-
onMessageWrapperMap.delete(onMessage2);
|
|
659
|
-
const parentPort2 = await getParentPort();
|
|
660
|
-
if (parentPort2) {
|
|
661
|
-
console.error("not implemented");
|
|
662
|
-
} else {
|
|
663
|
-
globalThis.removeEventListener("message", onMessageWrapper);
|
|
664
|
-
}
|
|
433
|
+
time(logLevel, message) {
|
|
434
|
+
return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
|
|
665
435
|
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
* @param type
|
|
669
|
-
* @param payload
|
|
670
|
-
*/
|
|
671
|
-
static async postMessage(type, payload) {
|
|
672
|
-
const data = { source: "loaders.gl", type, payload };
|
|
673
|
-
const transferList = getTransferList(payload);
|
|
674
|
-
const parentPort2 = await getParentPort();
|
|
675
|
-
if (parentPort2) {
|
|
676
|
-
parentPort2.postMessage(data, transferList);
|
|
677
|
-
} else {
|
|
678
|
-
globalThis.postMessage(data, transferList);
|
|
679
|
-
}
|
|
436
|
+
timeEnd(logLevel, message) {
|
|
437
|
+
return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
|
|
680
438
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
const { type, data } = message;
|
|
684
|
-
return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
// ../worker-utils/src/lib/worker-api/get-worker-url.ts
|
|
688
|
-
function getWorkerURL(worker, options = {}) {
|
|
689
|
-
const workerOptions = options[worker.id] || {};
|
|
690
|
-
const workerFile = isBrowser2 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
|
|
691
|
-
let url = workerOptions.workerUrl;
|
|
692
|
-
if (!url && worker.id === "compression") {
|
|
693
|
-
url = options.workerUrl;
|
|
439
|
+
timeStamp(logLevel, message) {
|
|
440
|
+
return this._getLogFunction(logLevel, message, console.timeStamp || noop);
|
|
694
441
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
|
|
442
|
+
group(logLevel, message) {
|
|
443
|
+
let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
|
|
444
|
+
collapsed: false
|
|
445
|
+
};
|
|
446
|
+
const options = normalizeArguments({
|
|
447
|
+
logLevel,
|
|
448
|
+
message,
|
|
449
|
+
opts
|
|
450
|
+
});
|
|
451
|
+
const {
|
|
452
|
+
collapsed
|
|
453
|
+
} = opts;
|
|
454
|
+
options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
|
|
455
|
+
return this._getLogFunction(options);
|
|
701
456
|
}
|
|
702
|
-
|
|
703
|
-
let
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
}
|
|
707
|
-
const versionTag = version ? `@${version}` : "";
|
|
708
|
-
url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
|
|
457
|
+
groupCollapsed(logLevel, message) {
|
|
458
|
+
let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
459
|
+
return this.group(logLevel, message, Object.assign({}, opts, {
|
|
460
|
+
collapsed: true
|
|
461
|
+
}));
|
|
709
462
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
// ../worker-utils/src/lib/worker-api/validate-worker-version.ts
|
|
715
|
-
function validateWorkerVersion(worker, coreVersion = VERSION) {
|
|
716
|
-
assert2(worker, "no worker provided");
|
|
717
|
-
const workerVersion = worker.version;
|
|
718
|
-
if (!coreVersion || !workerVersion) {
|
|
719
|
-
return false;
|
|
463
|
+
groupEnd(logLevel) {
|
|
464
|
+
return this._getLogFunction(logLevel, "", console.groupEnd || noop);
|
|
720
465
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
if (moduleName) {
|
|
729
|
-
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
466
|
+
withGroup(logLevel, message, func) {
|
|
467
|
+
this.group(logLevel, message)();
|
|
468
|
+
try {
|
|
469
|
+
func();
|
|
470
|
+
} finally {
|
|
471
|
+
this.groupEnd(logLevel)();
|
|
472
|
+
}
|
|
730
473
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
736
|
-
if (!options.useLocalLibraries && library.startsWith("http")) {
|
|
737
|
-
return library;
|
|
474
|
+
trace() {
|
|
475
|
+
if (console.trace) {
|
|
476
|
+
console.trace();
|
|
477
|
+
}
|
|
738
478
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
if (modules[libraryName]) {
|
|
742
|
-
return modules[libraryName];
|
|
479
|
+
_shouldLog(logLevel) {
|
|
480
|
+
return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
|
|
743
481
|
}
|
|
744
|
-
|
|
745
|
-
|
|
482
|
+
_getLogFunction(logLevel, message, method, args, opts) {
|
|
483
|
+
if (this._shouldLog(logLevel)) {
|
|
484
|
+
opts = normalizeArguments({
|
|
485
|
+
logLevel,
|
|
486
|
+
message,
|
|
487
|
+
args,
|
|
488
|
+
opts
|
|
489
|
+
});
|
|
490
|
+
method = method || opts.method;
|
|
491
|
+
assert2(method);
|
|
492
|
+
opts.total = this.getTotal();
|
|
493
|
+
opts.delta = this.getDelta();
|
|
494
|
+
this._deltaTs = getHiResTimestamp();
|
|
495
|
+
const tag = opts.tag || opts.message;
|
|
496
|
+
if (opts.once && tag) {
|
|
497
|
+
if (!cache[tag]) {
|
|
498
|
+
cache[tag] = getHiResTimestamp();
|
|
499
|
+
} else {
|
|
500
|
+
return noop;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
message = decorateMessage(this.id, opts.message, opts);
|
|
504
|
+
return method.bind(console, message, ...opts.args);
|
|
505
|
+
}
|
|
506
|
+
return noop;
|
|
746
507
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
508
|
+
};
|
|
509
|
+
_defineProperty(Log, "VERSION", VERSION);
|
|
510
|
+
function normalizeLogLevel(logLevel) {
|
|
511
|
+
if (!logLevel) {
|
|
512
|
+
return 0;
|
|
750
513
|
}
|
|
751
|
-
|
|
752
|
-
|
|
514
|
+
let resolvedLevel;
|
|
515
|
+
switch (typeof logLevel) {
|
|
516
|
+
case "number":
|
|
517
|
+
resolvedLevel = logLevel;
|
|
518
|
+
break;
|
|
519
|
+
case "object":
|
|
520
|
+
resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
|
|
521
|
+
break;
|
|
522
|
+
default:
|
|
523
|
+
return 0;
|
|
753
524
|
}
|
|
754
|
-
|
|
525
|
+
assert2(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
526
|
+
return resolvedLevel;
|
|
755
527
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
528
|
+
function normalizeArguments(opts) {
|
|
529
|
+
const {
|
|
530
|
+
logLevel,
|
|
531
|
+
message
|
|
532
|
+
} = opts;
|
|
533
|
+
opts.logLevel = normalizeLogLevel(logLevel);
|
|
534
|
+
const args = opts.args ? Array.from(opts.args) : [];
|
|
535
|
+
while (args.length && args.shift() !== message) {
|
|
759
536
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
537
|
+
switch (typeof logLevel) {
|
|
538
|
+
case "string":
|
|
539
|
+
case "function":
|
|
540
|
+
if (message !== void 0) {
|
|
541
|
+
args.unshift(message);
|
|
542
|
+
}
|
|
543
|
+
opts.message = logLevel;
|
|
544
|
+
break;
|
|
545
|
+
case "object":
|
|
546
|
+
Object.assign(opts, logLevel);
|
|
547
|
+
break;
|
|
548
|
+
default:
|
|
767
549
|
}
|
|
768
|
-
if (
|
|
769
|
-
|
|
550
|
+
if (typeof opts.message === "function") {
|
|
551
|
+
opts.message = opts.message();
|
|
770
552
|
}
|
|
771
|
-
const
|
|
772
|
-
|
|
553
|
+
const messageType = typeof opts.message;
|
|
554
|
+
assert2(messageType === "string" || messageType === "object");
|
|
555
|
+
return Object.assign(opts, {
|
|
556
|
+
args
|
|
557
|
+
}, opts.opts);
|
|
773
558
|
}
|
|
774
|
-
function
|
|
775
|
-
if (
|
|
776
|
-
|
|
559
|
+
function decorateMessage(id, message, opts) {
|
|
560
|
+
if (typeof message === "string") {
|
|
561
|
+
const time = opts.time ? leftPad(formatTime(opts.total)) : "";
|
|
562
|
+
message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
|
|
563
|
+
message = addColor(message, opts.color, opts.background);
|
|
777
564
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
565
|
+
return message;
|
|
566
|
+
}
|
|
567
|
+
function logImageInNode(_ref2) {
|
|
568
|
+
let {
|
|
569
|
+
image,
|
|
570
|
+
message = "",
|
|
571
|
+
scale: scale3 = 1
|
|
572
|
+
} = _ref2;
|
|
573
|
+
console.warn("removed");
|
|
574
|
+
return noop;
|
|
575
|
+
}
|
|
576
|
+
function logImageInBrowser(_ref3) {
|
|
577
|
+
let {
|
|
578
|
+
image,
|
|
579
|
+
message = "",
|
|
580
|
+
scale: scale3 = 1
|
|
581
|
+
} = _ref3;
|
|
582
|
+
if (typeof image === "string") {
|
|
583
|
+
const img = new Image();
|
|
584
|
+
img.onload = () => {
|
|
585
|
+
const args = formatImage(img, message, scale3);
|
|
586
|
+
console.log(...args);
|
|
587
|
+
};
|
|
588
|
+
img.src = image;
|
|
589
|
+
return noop;
|
|
781
590
|
}
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
} catch (e2) {
|
|
787
|
-
script.text = scriptSource;
|
|
591
|
+
const element = image.nodeName || "";
|
|
592
|
+
if (element.toLowerCase() === "img") {
|
|
593
|
+
console.log(...formatImage(image, message, scale3));
|
|
594
|
+
return noop;
|
|
788
595
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
const response = await fetch(url);
|
|
795
|
-
return await response.arrayBuffer();
|
|
596
|
+
if (element.toLowerCase() === "canvas") {
|
|
597
|
+
const img = new Image();
|
|
598
|
+
img.onload = () => console.log(...formatImage(img, message, scale3));
|
|
599
|
+
img.src = image.toDataURL();
|
|
600
|
+
return noop;
|
|
796
601
|
}
|
|
797
|
-
return
|
|
602
|
+
return noop;
|
|
798
603
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
const
|
|
802
|
-
|
|
604
|
+
function getTableHeader(table) {
|
|
605
|
+
for (const key in table) {
|
|
606
|
+
for (const title in table[key]) {
|
|
607
|
+
return title || "untitled";
|
|
608
|
+
}
|
|
803
609
|
}
|
|
804
|
-
return
|
|
610
|
+
return "empty";
|
|
805
611
|
}
|
|
806
612
|
|
|
807
|
-
//
|
|
808
|
-
var
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
613
|
+
// ../../node_modules/@probe.gl/log/dist/index.js
|
|
614
|
+
var dist_default = new Log({
|
|
615
|
+
id: "@probe.gl/log"
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
// ../loader-utils/src/lib/option-utils/merge-loader-options.ts
|
|
619
|
+
function mergeLoaderOptions(baseOptions, newOptions) {
|
|
620
|
+
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
621
|
+
}
|
|
622
|
+
function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
623
|
+
if (level > 3) {
|
|
624
|
+
return newOptions;
|
|
812
625
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
context: {
|
|
824
|
-
...context,
|
|
825
|
-
_parse: parseOnMainThread
|
|
826
|
-
}
|
|
827
|
-
});
|
|
828
|
-
WorkerBody.postMessage("done", { result });
|
|
829
|
-
} catch (error) {
|
|
830
|
-
const message = error instanceof Error ? error.message : "";
|
|
831
|
-
WorkerBody.postMessage("error", { error: message });
|
|
832
|
-
}
|
|
833
|
-
break;
|
|
834
|
-
default:
|
|
626
|
+
const options = { ...baseOptions };
|
|
627
|
+
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
628
|
+
if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
|
|
629
|
+
options[key] = mergeOptionsRecursively(
|
|
630
|
+
options[key] || {},
|
|
631
|
+
newOptions[key],
|
|
632
|
+
level + 1
|
|
633
|
+
);
|
|
634
|
+
} else {
|
|
635
|
+
options[key] = newOptions[key];
|
|
835
636
|
}
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
function parseOnMainThread(arrayBuffer, loader, options, context) {
|
|
839
|
-
return new Promise((resolve2, reject) => {
|
|
840
|
-
const id = requestId++;
|
|
841
|
-
const onMessage2 = (type, payload2) => {
|
|
842
|
-
if (payload2.id !== id) {
|
|
843
|
-
return;
|
|
844
|
-
}
|
|
845
|
-
switch (type) {
|
|
846
|
-
case "done":
|
|
847
|
-
WorkerBody.removeEventListener(onMessage2);
|
|
848
|
-
resolve2(payload2.result);
|
|
849
|
-
break;
|
|
850
|
-
case "error":
|
|
851
|
-
WorkerBody.removeEventListener(onMessage2);
|
|
852
|
-
reject(payload2.error);
|
|
853
|
-
break;
|
|
854
|
-
default:
|
|
855
|
-
}
|
|
856
|
-
};
|
|
857
|
-
WorkerBody.addEventListener(onMessage2);
|
|
858
|
-
const payload = { id, input: arrayBuffer, options };
|
|
859
|
-
WorkerBody.postMessage("process", payload);
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
async function parseData({
|
|
863
|
-
loader,
|
|
864
|
-
arrayBuffer,
|
|
865
|
-
options,
|
|
866
|
-
context
|
|
867
|
-
}) {
|
|
868
|
-
let data;
|
|
869
|
-
let parser;
|
|
870
|
-
if (loader.parseSync || loader.parse) {
|
|
871
|
-
data = arrayBuffer;
|
|
872
|
-
parser = loader.parseSync || loader.parse;
|
|
873
|
-
} else if (loader.parseTextSync) {
|
|
874
|
-
const textDecoder = new TextDecoder();
|
|
875
|
-
data = textDecoder.decode(arrayBuffer);
|
|
876
|
-
parser = loader.parseTextSync;
|
|
877
|
-
} else {
|
|
878
|
-
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
879
637
|
}
|
|
880
|
-
options
|
|
881
|
-
...options,
|
|
882
|
-
modules: loader && loader.options && loader.options.modules || {},
|
|
883
|
-
worker: false
|
|
884
|
-
};
|
|
885
|
-
return await parser(data, { ...options }, context, loader);
|
|
638
|
+
return options;
|
|
886
639
|
}
|
|
887
640
|
|
|
888
|
-
// ../loader-utils/src/lib/
|
|
889
|
-
function
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
if (!isBrowser2 && !options?._nodeWorkers) {
|
|
894
|
-
return false;
|
|
895
|
-
}
|
|
896
|
-
return loader.worker && options?.worker;
|
|
897
|
-
}
|
|
898
|
-
async function parseWithWorker(loader, data, options, context, parseOnMainThread2) {
|
|
899
|
-
const name = loader.id;
|
|
900
|
-
const url = getWorkerURL(loader, options);
|
|
901
|
-
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
902
|
-
const workerPool = workerFarm.getWorkerPool({ name, url });
|
|
903
|
-
options = JSON.parse(JSON.stringify(options));
|
|
904
|
-
context = JSON.parse(JSON.stringify(context || {}));
|
|
905
|
-
const job = await workerPool.startJob(
|
|
906
|
-
"process-on-worker",
|
|
907
|
-
// @ts-expect-error
|
|
908
|
-
onMessage.bind(null, parseOnMainThread2)
|
|
909
|
-
// eslint-disable-line @typescript-eslint/no-misused-promises
|
|
910
|
-
);
|
|
911
|
-
job.postMessage("process", {
|
|
912
|
-
// @ts-ignore
|
|
913
|
-
input: data,
|
|
914
|
-
options,
|
|
915
|
-
context
|
|
916
|
-
});
|
|
917
|
-
const result = await job.result;
|
|
918
|
-
return await result.result;
|
|
641
|
+
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
642
|
+
function registerJSModules(modules) {
|
|
643
|
+
globalThis.loaders ||= {};
|
|
644
|
+
globalThis.loaders.modules ||= {};
|
|
645
|
+
Object.assign(globalThis.loaders.modules, modules);
|
|
919
646
|
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
job.done(payload);
|
|
924
|
-
break;
|
|
925
|
-
case "error":
|
|
926
|
-
job.error(new Error(payload.error));
|
|
927
|
-
break;
|
|
928
|
-
case "process":
|
|
929
|
-
const { id, input, options } = payload;
|
|
930
|
-
try {
|
|
931
|
-
const result = await parseOnMainThread2(input, options);
|
|
932
|
-
job.postMessage("done", { id, result });
|
|
933
|
-
} catch (error) {
|
|
934
|
-
const message = error instanceof Error ? error.message : "unknown error";
|
|
935
|
-
job.postMessage("error", { id, error: message });
|
|
936
|
-
}
|
|
937
|
-
break;
|
|
938
|
-
default:
|
|
939
|
-
console.warn(`parse-with-worker unknown message ${type}`);
|
|
940
|
-
}
|
|
647
|
+
function getJSModuleOrNull(name) {
|
|
648
|
+
const module = globalThis.loaders?.modules?.[name];
|
|
649
|
+
return module || null;
|
|
941
650
|
}
|
|
942
651
|
|
|
943
|
-
// ../
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
if (
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
652
|
+
// ../worker-utils/src/lib/env-utils/version.ts
|
|
653
|
+
var NPM_TAG = "latest";
|
|
654
|
+
function getVersion() {
|
|
655
|
+
if (!globalThis._loadersgl_?.version) {
|
|
656
|
+
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
657
|
+
if (false) {
|
|
658
|
+
console.warn(
|
|
659
|
+
"loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
|
|
660
|
+
);
|
|
661
|
+
globalThis._loadersgl_.version = NPM_TAG;
|
|
662
|
+
} else {
|
|
663
|
+
globalThis._loadersgl_.version = "4.2.0-alpha.6";
|
|
954
664
|
}
|
|
955
665
|
}
|
|
956
|
-
return
|
|
957
|
-
}
|
|
958
|
-
function concatenateArrayBuffers(...sources) {
|
|
959
|
-
return concatenateArrayBuffersFromArray(sources);
|
|
666
|
+
return globalThis._loadersgl_.version;
|
|
960
667
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
let offset = 0;
|
|
968
|
-
for (const sourceArray of sourceArrays) {
|
|
969
|
-
result.set(sourceArray, offset);
|
|
970
|
-
offset += sourceArray.byteLength;
|
|
668
|
+
var VERSION2 = getVersion();
|
|
669
|
+
|
|
670
|
+
// ../worker-utils/src/lib/env-utils/assert.ts
|
|
671
|
+
function assert3(condition, message) {
|
|
672
|
+
if (!condition) {
|
|
673
|
+
throw new Error(message || "loaders.gl assertion failed.");
|
|
971
674
|
}
|
|
972
|
-
return result.buffer;
|
|
973
675
|
}
|
|
974
676
|
|
|
975
|
-
// ../
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
677
|
+
// ../worker-utils/src/lib/env-utils/globals.ts
|
|
678
|
+
var globals2 = {
|
|
679
|
+
self: typeof self !== "undefined" && self,
|
|
680
|
+
window: typeof window !== "undefined" && window,
|
|
681
|
+
global: typeof global !== "undefined" && global,
|
|
682
|
+
document: typeof document !== "undefined" && document
|
|
683
|
+
};
|
|
684
|
+
var self_3 = globals2.self || globals2.window || globals2.global || {};
|
|
685
|
+
var window_3 = globals2.window || globals2.self || globals2.global || {};
|
|
686
|
+
var global_3 = globals2.global || globals2.self || globals2.window || {};
|
|
687
|
+
var document_3 = globals2.document || {};
|
|
688
|
+
var isBrowser4 = (
|
|
689
|
+
// @ts-ignore process.browser
|
|
690
|
+
typeof process !== "object" || String(process) !== "[object process]" || process.browser
|
|
691
|
+
);
|
|
692
|
+
var isWorker = typeof importScripts === "function";
|
|
693
|
+
var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
|
|
694
|
+
var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
695
|
+
var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
|
|
993
696
|
|
|
994
|
-
//
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
697
|
+
// ../worker-utils/src/lib/worker-farm/worker-job.ts
|
|
698
|
+
var WorkerJob = class {
|
|
699
|
+
name;
|
|
700
|
+
workerThread;
|
|
701
|
+
isRunning = true;
|
|
702
|
+
/** Promise that resolves when Job is done */
|
|
703
|
+
result;
|
|
704
|
+
_resolve = () => {
|
|
705
|
+
};
|
|
706
|
+
_reject = () => {
|
|
707
|
+
};
|
|
708
|
+
constructor(jobName, workerThread) {
|
|
709
|
+
this.name = jobName;
|
|
710
|
+
this.workerThread = workerThread;
|
|
711
|
+
this.result = new Promise((resolve2, reject) => {
|
|
712
|
+
this._resolve = resolve2;
|
|
713
|
+
this._reject = reject;
|
|
714
|
+
});
|
|
1004
715
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
function _defineProperty(obj, key, value) {
|
|
1016
|
-
key = _toPropertyKey(key);
|
|
1017
|
-
if (key in obj) {
|
|
1018
|
-
Object.defineProperty(obj, key, {
|
|
1019
|
-
value,
|
|
1020
|
-
enumerable: true,
|
|
1021
|
-
configurable: true,
|
|
1022
|
-
writable: true
|
|
716
|
+
/**
|
|
717
|
+
* Send a message to the job's worker thread
|
|
718
|
+
* @param data any data structure, ideally consisting mostly of transferrable objects
|
|
719
|
+
*/
|
|
720
|
+
postMessage(type, payload) {
|
|
721
|
+
this.workerThread.postMessage({
|
|
722
|
+
source: "loaders.gl",
|
|
723
|
+
// Lets worker ignore unrelated messages
|
|
724
|
+
type,
|
|
725
|
+
payload
|
|
1023
726
|
});
|
|
1024
|
-
} else {
|
|
1025
|
-
obj[key] = value;
|
|
1026
727
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
728
|
+
/**
|
|
729
|
+
* Call to resolve the `result` Promise with the supplied value
|
|
730
|
+
*/
|
|
731
|
+
done(value) {
|
|
732
|
+
assert3(this.isRunning);
|
|
733
|
+
this.isRunning = false;
|
|
734
|
+
this._resolve(value);
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Call to reject the `result` Promise with the supplied error
|
|
738
|
+
*/
|
|
739
|
+
error(error) {
|
|
740
|
+
assert3(this.isRunning);
|
|
741
|
+
this.isRunning = false;
|
|
742
|
+
this._reject(error);
|
|
743
|
+
}
|
|
744
|
+
};
|
|
1029
745
|
|
|
1030
|
-
// ../
|
|
1031
|
-
var
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
746
|
+
// ../worker-utils/src/lib/node/worker_threads-browser.ts
|
|
747
|
+
var NodeWorker = class {
|
|
748
|
+
terminate() {
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
var parentPort = null;
|
|
752
|
+
|
|
753
|
+
// ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
|
|
754
|
+
var workerURLCache = /* @__PURE__ */ new Map();
|
|
755
|
+
function getLoadableWorkerURL(props) {
|
|
756
|
+
assert3(props.source && !props.url || !props.source && props.url);
|
|
757
|
+
let workerURL = workerURLCache.get(props.source || props.url);
|
|
758
|
+
if (!workerURL) {
|
|
759
|
+
if (props.url) {
|
|
760
|
+
workerURL = getLoadableWorkerURLFromURL(props.url);
|
|
761
|
+
workerURLCache.set(props.url, workerURL);
|
|
762
|
+
}
|
|
763
|
+
if (props.source) {
|
|
764
|
+
workerURL = getLoadableWorkerURLFromSource(props.source);
|
|
765
|
+
workerURLCache.set(props.source, workerURL);
|
|
1038
766
|
}
|
|
1039
767
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
768
|
+
assert3(workerURL);
|
|
769
|
+
return workerURL;
|
|
770
|
+
}
|
|
771
|
+
function getLoadableWorkerURLFromURL(url) {
|
|
772
|
+
if (!url.startsWith("http")) {
|
|
773
|
+
return url;
|
|
1042
774
|
}
|
|
1043
|
-
|
|
775
|
+
const workerSource = buildScriptSource(url);
|
|
776
|
+
return getLoadableWorkerURLFromSource(workerSource);
|
|
1044
777
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
778
|
+
function getLoadableWorkerURLFromSource(workerSource) {
|
|
779
|
+
const blob = new Blob([workerSource], { type: "application/javascript" });
|
|
780
|
+
return URL.createObjectURL(blob);
|
|
781
|
+
}
|
|
782
|
+
function buildScriptSource(workerUrl) {
|
|
783
|
+
return `try {
|
|
784
|
+
importScripts('${workerUrl}');
|
|
785
|
+
} catch (error) {
|
|
786
|
+
console.error(error);
|
|
787
|
+
throw error;
|
|
788
|
+
}`;
|
|
1049
789
|
}
|
|
1050
790
|
|
|
1051
|
-
// ../
|
|
1052
|
-
function
|
|
1053
|
-
|
|
791
|
+
// ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
|
|
792
|
+
function getTransferList(object, recursive = true, transfers) {
|
|
793
|
+
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
794
|
+
if (!object) {
|
|
795
|
+
} else if (isTransferable(object)) {
|
|
796
|
+
transfersSet.add(object);
|
|
797
|
+
} else if (isTransferable(object.buffer)) {
|
|
798
|
+
transfersSet.add(object.buffer);
|
|
799
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
800
|
+
} else if (recursive && typeof object === "object") {
|
|
801
|
+
for (const key in object) {
|
|
802
|
+
getTransferList(object[key], recursive, transfersSet);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
1054
806
|
}
|
|
1055
|
-
function
|
|
1056
|
-
if (
|
|
1057
|
-
return
|
|
807
|
+
function isTransferable(object) {
|
|
808
|
+
if (!object) {
|
|
809
|
+
return false;
|
|
1058
810
|
}
|
|
1059
|
-
if (
|
|
1060
|
-
return
|
|
811
|
+
if (object instanceof ArrayBuffer) {
|
|
812
|
+
return true;
|
|
1061
813
|
}
|
|
1062
|
-
if (
|
|
1063
|
-
|
|
1064
|
-
return data.buffer;
|
|
1065
|
-
}
|
|
1066
|
-
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
814
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
815
|
+
return true;
|
|
1067
816
|
}
|
|
1068
|
-
if (typeof
|
|
1069
|
-
|
|
1070
|
-
const uint8Array = new TextEncoder().encode(text);
|
|
1071
|
-
return uint8Array.buffer;
|
|
817
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
818
|
+
return true;
|
|
1072
819
|
}
|
|
1073
|
-
if (
|
|
1074
|
-
return
|
|
820
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
821
|
+
return true;
|
|
1075
822
|
}
|
|
1076
|
-
|
|
823
|
+
return false;
|
|
1077
824
|
}
|
|
1078
825
|
|
|
1079
|
-
// ../
|
|
1080
|
-
var
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
826
|
+
// ../worker-utils/src/lib/worker-farm/worker-thread.ts
|
|
827
|
+
var NOOP = () => {
|
|
828
|
+
};
|
|
829
|
+
var WorkerThread = class {
|
|
830
|
+
name;
|
|
831
|
+
source;
|
|
832
|
+
url;
|
|
833
|
+
terminated = false;
|
|
834
|
+
worker;
|
|
835
|
+
onMessage;
|
|
836
|
+
onError;
|
|
837
|
+
_loadableURL = "";
|
|
838
|
+
/** Checks if workers are supported on this platform */
|
|
839
|
+
static isSupported() {
|
|
840
|
+
return typeof Worker !== "undefined" && isBrowser4 || typeof NodeWorker !== "undefined" && !isBrowser4;
|
|
1092
841
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
function dirname(url) {
|
|
1103
|
-
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1104
|
-
return slashIndex >= 0 ? url.substr(0, slashIndex) : "";
|
|
1105
|
-
}
|
|
1106
|
-
function join(...parts) {
|
|
1107
|
-
const separator = "/";
|
|
1108
|
-
parts = parts.map((part, index) => {
|
|
1109
|
-
if (index) {
|
|
1110
|
-
part = part.replace(new RegExp(`^${separator}`), "");
|
|
1111
|
-
}
|
|
1112
|
-
if (index !== parts.length - 1) {
|
|
1113
|
-
part = part.replace(new RegExp(`${separator}$`), "");
|
|
1114
|
-
}
|
|
1115
|
-
return part;
|
|
1116
|
-
});
|
|
1117
|
-
return parts.join(separator);
|
|
1118
|
-
}
|
|
1119
|
-
function resolve(...components) {
|
|
1120
|
-
const paths = [];
|
|
1121
|
-
for (let _i = 0; _i < components.length; _i++) {
|
|
1122
|
-
paths[_i] = components[_i];
|
|
842
|
+
constructor(props) {
|
|
843
|
+
const { name, source, url } = props;
|
|
844
|
+
assert3(source || url);
|
|
845
|
+
this.name = name;
|
|
846
|
+
this.source = source;
|
|
847
|
+
this.url = url;
|
|
848
|
+
this.onMessage = NOOP;
|
|
849
|
+
this.onError = (error) => console.log(error);
|
|
850
|
+
this.worker = isBrowser4 ? this._createBrowserWorker() : this._createNodeWorker();
|
|
1123
851
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
852
|
+
/**
|
|
853
|
+
* Terminate this worker thread
|
|
854
|
+
* @note Can free up significant memory
|
|
855
|
+
*/
|
|
856
|
+
destroy() {
|
|
857
|
+
this.onMessage = NOOP;
|
|
858
|
+
this.onError = NOOP;
|
|
859
|
+
this.worker.terminate();
|
|
860
|
+
this.terminated = true;
|
|
861
|
+
}
|
|
862
|
+
get isRunning() {
|
|
863
|
+
return Boolean(this.onMessage);
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Send a message to this worker thread
|
|
867
|
+
* @param data any data structure, ideally consisting mostly of transferrable objects
|
|
868
|
+
* @param transferList If not supplied, calculated automatically by traversing data
|
|
869
|
+
*/
|
|
870
|
+
postMessage(data, transferList) {
|
|
871
|
+
transferList = transferList || getTransferList(data);
|
|
872
|
+
this.worker.postMessage(data, transferList);
|
|
873
|
+
}
|
|
874
|
+
// PRIVATE
|
|
875
|
+
/**
|
|
876
|
+
* Generate a standard Error from an ErrorEvent
|
|
877
|
+
* @param event
|
|
878
|
+
*/
|
|
879
|
+
_getErrorFromErrorEvent(event) {
|
|
880
|
+
let message = "Failed to load ";
|
|
881
|
+
message += `worker ${this.name} from ${this.url}. `;
|
|
882
|
+
if (event.message) {
|
|
883
|
+
message += `${event.message} in `;
|
|
1136
884
|
}
|
|
1137
|
-
if (
|
|
1138
|
-
|
|
885
|
+
if (event.lineno) {
|
|
886
|
+
message += `:${event.lineno}:${event.colno}`;
|
|
1139
887
|
}
|
|
1140
|
-
|
|
1141
|
-
resolvedAbsolute = path.charCodeAt(0) === SLASH;
|
|
888
|
+
return new Error(message);
|
|
1142
889
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
890
|
+
/**
|
|
891
|
+
* Creates a worker thread on the browser
|
|
892
|
+
*/
|
|
893
|
+
_createBrowserWorker() {
|
|
894
|
+
this._loadableURL = getLoadableWorkerURL({ source: this.source, url: this.url });
|
|
895
|
+
const worker = new Worker(this._loadableURL, { name: this.name });
|
|
896
|
+
worker.onmessage = (event) => {
|
|
897
|
+
if (!event.data) {
|
|
898
|
+
this.onError(new Error("No data received"));
|
|
899
|
+
} else {
|
|
900
|
+
this.onMessage(event.data);
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
worker.onerror = (error) => {
|
|
904
|
+
this.onError(this._getErrorFromErrorEvent(error));
|
|
905
|
+
this.terminated = true;
|
|
906
|
+
};
|
|
907
|
+
worker.onmessageerror = (event) => console.error(event);
|
|
908
|
+
return worker;
|
|
1148
909
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
code = path.charCodeAt(i2);
|
|
1162
|
-
} else if (code === SLASH) {
|
|
1163
|
-
break;
|
|
910
|
+
/**
|
|
911
|
+
* Creates a worker thread in node.js
|
|
912
|
+
* @todo https://nodejs.org/api/async_hooks.html#async-resource-worker-pool
|
|
913
|
+
*/
|
|
914
|
+
_createNodeWorker() {
|
|
915
|
+
let worker;
|
|
916
|
+
if (this.url) {
|
|
917
|
+
const absolute = this.url.includes(":/") || this.url.startsWith("/");
|
|
918
|
+
const url = absolute ? this.url : `./${this.url}`;
|
|
919
|
+
worker = new NodeWorker(url, { eval: false });
|
|
920
|
+
} else if (this.source) {
|
|
921
|
+
worker = new NodeWorker(this.source, { eval: true });
|
|
1164
922
|
} else {
|
|
1165
|
-
|
|
923
|
+
throw new Error("no worker");
|
|
1166
924
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
925
|
+
worker.on("message", (data) => {
|
|
926
|
+
this.onMessage(data);
|
|
927
|
+
});
|
|
928
|
+
worker.on("error", (error) => {
|
|
929
|
+
this.onError(error);
|
|
930
|
+
});
|
|
931
|
+
worker.on("exit", (code) => {
|
|
932
|
+
});
|
|
933
|
+
return worker;
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
// ../worker-utils/src/lib/worker-farm/worker-pool.ts
|
|
938
|
+
var WorkerPool = class {
|
|
939
|
+
name = "unnamed";
|
|
940
|
+
source;
|
|
941
|
+
// | Function;
|
|
942
|
+
url;
|
|
943
|
+
maxConcurrency = 1;
|
|
944
|
+
maxMobileConcurrency = 1;
|
|
945
|
+
onDebug = () => {
|
|
946
|
+
};
|
|
947
|
+
reuseWorkers = true;
|
|
948
|
+
props = {};
|
|
949
|
+
jobQueue = [];
|
|
950
|
+
idleQueue = [];
|
|
951
|
+
count = 0;
|
|
952
|
+
isDestroyed = false;
|
|
953
|
+
/** Checks if workers are supported on this platform */
|
|
954
|
+
static isSupported() {
|
|
955
|
+
return WorkerThread.isSupported();
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* @param processor - worker function
|
|
959
|
+
* @param maxConcurrency - max count of workers
|
|
960
|
+
*/
|
|
961
|
+
constructor(props) {
|
|
962
|
+
this.source = props.source;
|
|
963
|
+
this.url = props.url;
|
|
964
|
+
this.setProps(props);
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Terminates all workers in the pool
|
|
968
|
+
* @note Can free up significant memory
|
|
969
|
+
*/
|
|
970
|
+
destroy() {
|
|
971
|
+
this.idleQueue.forEach((worker) => worker.destroy());
|
|
972
|
+
this.isDestroyed = true;
|
|
973
|
+
}
|
|
974
|
+
setProps(props) {
|
|
975
|
+
this.props = { ...this.props, ...props };
|
|
976
|
+
if (props.name !== void 0) {
|
|
977
|
+
this.name = props.name;
|
|
978
|
+
}
|
|
979
|
+
if (props.maxConcurrency !== void 0) {
|
|
980
|
+
this.maxConcurrency = props.maxConcurrency;
|
|
981
|
+
}
|
|
982
|
+
if (props.maxMobileConcurrency !== void 0) {
|
|
983
|
+
this.maxMobileConcurrency = props.maxMobileConcurrency;
|
|
984
|
+
}
|
|
985
|
+
if (props.reuseWorkers !== void 0) {
|
|
986
|
+
this.reuseWorkers = props.reuseWorkers;
|
|
987
|
+
}
|
|
988
|
+
if (props.onDebug !== void 0) {
|
|
989
|
+
this.onDebug = props.onDebug;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
async startJob(name, onMessage2 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
|
|
993
|
+
const startPromise = new Promise((onStart) => {
|
|
994
|
+
this.jobQueue.push({ name, onMessage: onMessage2, onError, onStart });
|
|
995
|
+
return this;
|
|
996
|
+
});
|
|
997
|
+
this._startQueuedJob();
|
|
998
|
+
return await startPromise;
|
|
999
|
+
}
|
|
1000
|
+
// PRIVATE
|
|
1001
|
+
/**
|
|
1002
|
+
* Starts first queued job if worker is available or can be created
|
|
1003
|
+
* Called when job is started and whenever a worker returns to the idleQueue
|
|
1004
|
+
*/
|
|
1005
|
+
async _startQueuedJob() {
|
|
1006
|
+
if (!this.jobQueue.length) {
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
const workerThread = this._getAvailableWorker();
|
|
1010
|
+
if (!workerThread) {
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
const queuedJob = this.jobQueue.shift();
|
|
1014
|
+
if (queuedJob) {
|
|
1015
|
+
this.onDebug({
|
|
1016
|
+
message: "Starting job",
|
|
1017
|
+
name: queuedJob.name,
|
|
1018
|
+
workerThread,
|
|
1019
|
+
backlog: this.jobQueue.length
|
|
1020
|
+
});
|
|
1021
|
+
const job = new WorkerJob(queuedJob.name, workerThread);
|
|
1022
|
+
workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
|
|
1023
|
+
workerThread.onError = (error) => queuedJob.onError(job, error);
|
|
1024
|
+
queuedJob.onStart(job);
|
|
1025
|
+
try {
|
|
1026
|
+
await job.result;
|
|
1027
|
+
} catch (error) {
|
|
1028
|
+
console.error(`Worker exception: ${error}`);
|
|
1029
|
+
} finally {
|
|
1030
|
+
this.returnWorkerToQueue(workerThread);
|
|
1210
1031
|
}
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Returns a worker to the idle queue
|
|
1036
|
+
* Destroys the worker if
|
|
1037
|
+
* - pool is destroyed
|
|
1038
|
+
* - if this pool doesn't reuse workers
|
|
1039
|
+
* - if maxConcurrency has been lowered
|
|
1040
|
+
* @param worker
|
|
1041
|
+
*/
|
|
1042
|
+
returnWorkerToQueue(worker) {
|
|
1043
|
+
const shouldDestroyWorker = (
|
|
1044
|
+
// Workers on Node.js prevent the process from exiting.
|
|
1045
|
+
// Until we figure out how to close them before exit, we always destroy them
|
|
1046
|
+
!isBrowser4 || // If the pool is destroyed, there is no reason to keep the worker around
|
|
1047
|
+
this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
|
|
1048
|
+
!this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
|
|
1049
|
+
this.count > this._getMaxConcurrency()
|
|
1050
|
+
);
|
|
1051
|
+
if (shouldDestroyWorker) {
|
|
1052
|
+
worker.destroy();
|
|
1053
|
+
this.count--;
|
|
1215
1054
|
} else {
|
|
1216
|
-
|
|
1055
|
+
this.idleQueue.push(worker);
|
|
1056
|
+
}
|
|
1057
|
+
if (!this.isDestroyed) {
|
|
1058
|
+
this._startQueuedJob();
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Returns idle worker or creates new worker if maxConcurrency has not been reached
|
|
1063
|
+
*/
|
|
1064
|
+
_getAvailableWorker() {
|
|
1065
|
+
if (this.idleQueue.length > 0) {
|
|
1066
|
+
return this.idleQueue.shift() || null;
|
|
1067
|
+
}
|
|
1068
|
+
if (this.count < this._getMaxConcurrency()) {
|
|
1069
|
+
this.count++;
|
|
1070
|
+
const name = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
|
|
1071
|
+
return new WorkerThread({ name, source: this.source, url: this.url });
|
|
1072
|
+
}
|
|
1073
|
+
return null;
|
|
1074
|
+
}
|
|
1075
|
+
_getMaxConcurrency() {
|
|
1076
|
+
return isMobile ? this.maxMobileConcurrency : this.maxConcurrency;
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
// ../worker-utils/src/lib/worker-farm/worker-farm.ts
|
|
1081
|
+
var DEFAULT_PROPS = {
|
|
1082
|
+
maxConcurrency: 3,
|
|
1083
|
+
maxMobileConcurrency: 1,
|
|
1084
|
+
reuseWorkers: true,
|
|
1085
|
+
onDebug: () => {
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
var _WorkerFarm = class {
|
|
1089
|
+
props;
|
|
1090
|
+
workerPools = /* @__PURE__ */ new Map();
|
|
1091
|
+
/** Checks if workers are supported on this platform */
|
|
1092
|
+
static isSupported() {
|
|
1093
|
+
return WorkerThread.isSupported();
|
|
1094
|
+
}
|
|
1095
|
+
/** Get the singleton instance of the global worker farm */
|
|
1096
|
+
static getWorkerFarm(props = {}) {
|
|
1097
|
+
_WorkerFarm._workerFarm = _WorkerFarm._workerFarm || new _WorkerFarm({});
|
|
1098
|
+
_WorkerFarm._workerFarm.setProps(props);
|
|
1099
|
+
return _WorkerFarm._workerFarm;
|
|
1100
|
+
}
|
|
1101
|
+
/** get global instance with WorkerFarm.getWorkerFarm() */
|
|
1102
|
+
constructor(props) {
|
|
1103
|
+
this.props = { ...DEFAULT_PROPS };
|
|
1104
|
+
this.setProps(props);
|
|
1105
|
+
this.workerPools = /* @__PURE__ */ new Map();
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Terminate all workers in the farm
|
|
1109
|
+
* @note Can free up significant memory
|
|
1110
|
+
*/
|
|
1111
|
+
destroy() {
|
|
1112
|
+
for (const workerPool of this.workerPools.values()) {
|
|
1113
|
+
workerPool.destroy();
|
|
1114
|
+
}
|
|
1115
|
+
this.workerPools = /* @__PURE__ */ new Map();
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Set props used when initializing worker pools
|
|
1119
|
+
* @param props
|
|
1120
|
+
*/
|
|
1121
|
+
setProps(props) {
|
|
1122
|
+
this.props = { ...this.props, ...props };
|
|
1123
|
+
for (const workerPool of this.workerPools.values()) {
|
|
1124
|
+
workerPool.setProps(this._getWorkerPoolProps());
|
|
1217
1125
|
}
|
|
1218
1126
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
if (matches3) {
|
|
1242
|
-
return matches3[1];
|
|
1127
|
+
/**
|
|
1128
|
+
* Returns a worker pool for the specified worker
|
|
1129
|
+
* @param options - only used first time for a specific worker name
|
|
1130
|
+
* @param options.name - the name of the worker - used to identify worker pool
|
|
1131
|
+
* @param options.url -
|
|
1132
|
+
* @param options.source -
|
|
1133
|
+
* @example
|
|
1134
|
+
* const job = WorkerFarm.getWorkerFarm().getWorkerPool({name, url}).startJob(...);
|
|
1135
|
+
*/
|
|
1136
|
+
getWorkerPool(options) {
|
|
1137
|
+
const { name, source, url } = options;
|
|
1138
|
+
let workerPool = this.workerPools.get(name);
|
|
1139
|
+
if (!workerPool) {
|
|
1140
|
+
workerPool = new WorkerPool({
|
|
1141
|
+
name,
|
|
1142
|
+
source,
|
|
1143
|
+
url
|
|
1144
|
+
});
|
|
1145
|
+
workerPool.setProps(this._getWorkerPoolProps());
|
|
1146
|
+
this.workerPools.set(name, workerPool);
|
|
1147
|
+
}
|
|
1148
|
+
return workerPool;
|
|
1243
1149
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1150
|
+
_getWorkerPoolProps() {
|
|
1151
|
+
return {
|
|
1152
|
+
maxConcurrency: this.props.maxConcurrency,
|
|
1153
|
+
maxMobileConcurrency: this.props.maxMobileConcurrency,
|
|
1154
|
+
reuseWorkers: this.props.reuseWorkers,
|
|
1155
|
+
onDebug: this.props.onDebug
|
|
1156
|
+
};
|
|
1250
1157
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1158
|
+
};
|
|
1159
|
+
var WorkerFarm = _WorkerFarm;
|
|
1160
|
+
// singleton
|
|
1161
|
+
__publicField(WorkerFarm, "_workerFarm");
|
|
1253
1162
|
|
|
1254
|
-
// ../
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
const matches3 = url.match(QUERY_STRING_PATTERN);
|
|
1258
|
-
return matches3 && matches3[0];
|
|
1259
|
-
}
|
|
1260
|
-
function stripQueryString(url) {
|
|
1261
|
-
return url.replace(QUERY_STRING_PATTERN, "");
|
|
1163
|
+
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
1164
|
+
async function getParentPort() {
|
|
1165
|
+
return parentPort;
|
|
1262
1166
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
return response.url;
|
|
1269
|
-
}
|
|
1270
|
-
if (isBlob(resource)) {
|
|
1271
|
-
const blob = resource;
|
|
1272
|
-
return blob.name || "";
|
|
1167
|
+
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
1168
|
+
var WorkerBody = class {
|
|
1169
|
+
/** Check that we are actually in a worker thread */
|
|
1170
|
+
static async inWorkerThread() {
|
|
1171
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
1273
1172
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1173
|
+
/*
|
|
1174
|
+
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
1175
|
+
*/
|
|
1176
|
+
static set onmessage(onMessage2) {
|
|
1177
|
+
async function handleMessage(message) {
|
|
1178
|
+
const parentPort2 = await getParentPort();
|
|
1179
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
1180
|
+
onMessage2(type, payload);
|
|
1181
|
+
}
|
|
1182
|
+
getParentPort().then((parentPort2) => {
|
|
1183
|
+
if (parentPort2) {
|
|
1184
|
+
parentPort2.on("message", (message) => {
|
|
1185
|
+
handleMessage(message);
|
|
1186
|
+
});
|
|
1187
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
1188
|
+
} else {
|
|
1189
|
+
globalThis.onmessage = handleMessage;
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1276
1192
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1193
|
+
static async addEventListener(onMessage2) {
|
|
1194
|
+
let onMessageWrapper = onMessageWrapperMap.get(onMessage2);
|
|
1195
|
+
if (!onMessageWrapper) {
|
|
1196
|
+
onMessageWrapper = async (message) => {
|
|
1197
|
+
if (!isKnownMessage(message)) {
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
const parentPort3 = await getParentPort();
|
|
1201
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
1202
|
+
onMessage2(type, payload);
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
const parentPort2 = await getParentPort();
|
|
1206
|
+
if (parentPort2) {
|
|
1207
|
+
console.error("not implemented");
|
|
1208
|
+
} else {
|
|
1209
|
+
globalThis.addEventListener("message", onMessageWrapper);
|
|
1210
|
+
}
|
|
1285
1211
|
}
|
|
1286
|
-
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1212
|
+
static async removeEventListener(onMessage2) {
|
|
1213
|
+
const onMessageWrapper = onMessageWrapperMap.get(onMessage2);
|
|
1214
|
+
onMessageWrapperMap.delete(onMessage2);
|
|
1215
|
+
const parentPort2 = await getParentPort();
|
|
1216
|
+
if (parentPort2) {
|
|
1217
|
+
console.error("not implemented");
|
|
1218
|
+
} else {
|
|
1219
|
+
globalThis.removeEventListener("message", onMessageWrapper);
|
|
1220
|
+
}
|
|
1289
1221
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1222
|
+
/**
|
|
1223
|
+
* Send a message from a worker to creating thread (main thread)
|
|
1224
|
+
* @param type
|
|
1225
|
+
* @param payload
|
|
1226
|
+
*/
|
|
1227
|
+
static async postMessage(type, payload) {
|
|
1228
|
+
const data = { source: "loaders.gl", type, payload };
|
|
1229
|
+
const transferList = getTransferList(payload);
|
|
1230
|
+
const parentPort2 = await getParentPort();
|
|
1231
|
+
if (parentPort2) {
|
|
1232
|
+
parentPort2.postMessage(data, transferList);
|
|
1233
|
+
} else {
|
|
1234
|
+
globalThis.postMessage(data, transferList);
|
|
1235
|
+
}
|
|
1292
1236
|
}
|
|
1293
|
-
|
|
1237
|
+
};
|
|
1238
|
+
function isKnownMessage(message) {
|
|
1239
|
+
const { type, data } = message;
|
|
1240
|
+
return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
|
|
1294
1241
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
}
|
|
1304
|
-
if (typeof resource === "string") {
|
|
1305
|
-
return resource.length;
|
|
1242
|
+
|
|
1243
|
+
// ../worker-utils/src/lib/worker-api/get-worker-url.ts
|
|
1244
|
+
function getWorkerURL(worker, options = {}) {
|
|
1245
|
+
const workerOptions = options[worker.id] || {};
|
|
1246
|
+
const workerFile = isBrowser4 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
|
|
1247
|
+
let url = workerOptions.workerUrl;
|
|
1248
|
+
if (!url && worker.id === "compression") {
|
|
1249
|
+
url = options.workerUrl;
|
|
1306
1250
|
}
|
|
1307
|
-
if (
|
|
1308
|
-
|
|
1251
|
+
if (options._workerType === "test") {
|
|
1252
|
+
if (isBrowser4) {
|
|
1253
|
+
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
1254
|
+
} else {
|
|
1255
|
+
url = `modules/${worker.module}/src/workers/${worker.id}-worker-node.ts`;
|
|
1256
|
+
}
|
|
1309
1257
|
}
|
|
1310
|
-
if (
|
|
1311
|
-
|
|
1258
|
+
if (!url) {
|
|
1259
|
+
let version = worker.version;
|
|
1260
|
+
if (version === "latest") {
|
|
1261
|
+
version = NPM_TAG;
|
|
1262
|
+
}
|
|
1263
|
+
const versionTag = version ? `@${version}` : "";
|
|
1264
|
+
url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
|
|
1312
1265
|
}
|
|
1313
|
-
|
|
1266
|
+
assert3(url);
|
|
1267
|
+
return url;
|
|
1314
1268
|
}
|
|
1315
1269
|
|
|
1316
|
-
// ../
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1270
|
+
// ../worker-utils/src/lib/worker-api/validate-worker-version.ts
|
|
1271
|
+
function validateWorkerVersion(worker, coreVersion = VERSION2) {
|
|
1272
|
+
assert3(worker, "no worker provided");
|
|
1273
|
+
const workerVersion = worker.version;
|
|
1274
|
+
if (!coreVersion || !workerVersion) {
|
|
1275
|
+
return false;
|
|
1320
1276
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1277
|
+
return true;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
// ../worker-utils/src/lib/library-utils/library-utils.ts
|
|
1281
|
+
var loadLibraryPromises = {};
|
|
1282
|
+
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
1283
|
+
if (moduleName) {
|
|
1284
|
+
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
1325
1285
|
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1286
|
+
loadLibraryPromises[libraryUrl] = // eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
1287
|
+
loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
1288
|
+
return await loadLibraryPromises[libraryUrl];
|
|
1289
|
+
}
|
|
1290
|
+
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
1291
|
+
if (!options.useLocalLibraries && library.startsWith("http")) {
|
|
1292
|
+
return library;
|
|
1330
1293
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1294
|
+
libraryName = libraryName || library;
|
|
1295
|
+
const modules = options.modules || {};
|
|
1296
|
+
if (modules[libraryName]) {
|
|
1297
|
+
return modules[libraryName];
|
|
1334
1298
|
}
|
|
1335
|
-
if (
|
|
1336
|
-
|
|
1299
|
+
if (!isBrowser4) {
|
|
1300
|
+
return `modules/${moduleName}/dist/libs/${libraryName}`;
|
|
1337
1301
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
const message = await getResponseError(response);
|
|
1345
|
-
throw new Error(message);
|
|
1302
|
+
if (options.CDN) {
|
|
1303
|
+
assert3(options.CDN.startsWith("http"));
|
|
1304
|
+
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
|
|
1305
|
+
}
|
|
1306
|
+
if (isWorker) {
|
|
1307
|
+
return `../src/libs/${libraryName}`;
|
|
1346
1308
|
}
|
|
1309
|
+
return `modules/${moduleName}/src/libs/${libraryName}`;
|
|
1347
1310
|
}
|
|
1348
|
-
async function
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1311
|
+
async function loadLibraryFromFile(libraryUrl) {
|
|
1312
|
+
if (libraryUrl.endsWith("wasm")) {
|
|
1313
|
+
return await loadAsArrayBuffer(libraryUrl);
|
|
1314
|
+
}
|
|
1315
|
+
if (!isBrowser4) {
|
|
1316
|
+
try {
|
|
1317
|
+
const { requireFromFile } = globalThis.loaders || {};
|
|
1318
|
+
return await requireFromFile?.(libraryUrl);
|
|
1319
|
+
} catch (error) {
|
|
1320
|
+
console.error(error);
|
|
1321
|
+
return null;
|
|
1355
1322
|
}
|
|
1356
|
-
message += text;
|
|
1357
|
-
message = message.length > 60 ? `${message.slice(0, 60)}...` : message;
|
|
1358
|
-
} catch (error) {
|
|
1359
1323
|
}
|
|
1360
|
-
|
|
1324
|
+
if (isWorker) {
|
|
1325
|
+
return importScripts(libraryUrl);
|
|
1326
|
+
}
|
|
1327
|
+
const scriptSource = await loadAsText(libraryUrl);
|
|
1328
|
+
return loadLibraryFromString(scriptSource, libraryUrl);
|
|
1361
1329
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
return
|
|
1330
|
+
function loadLibraryFromString(scriptSource, id) {
|
|
1331
|
+
if (!isBrowser4) {
|
|
1332
|
+
const { requireFromString } = globalThis.loaders || {};
|
|
1333
|
+
return requireFromString?.(scriptSource, id);
|
|
1366
1334
|
}
|
|
1367
|
-
if (
|
|
1368
|
-
|
|
1369
|
-
return
|
|
1370
|
-
const reader = new FileReader();
|
|
1371
|
-
reader.onload = (event) => resolve2(event?.target?.result);
|
|
1372
|
-
reader.readAsDataURL(blobSlice);
|
|
1373
|
-
});
|
|
1335
|
+
if (isWorker) {
|
|
1336
|
+
eval.call(globalThis, scriptSource);
|
|
1337
|
+
return null;
|
|
1374
1338
|
}
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1339
|
+
const script = document.createElement("script");
|
|
1340
|
+
script.id = id;
|
|
1341
|
+
try {
|
|
1342
|
+
script.appendChild(document.createTextNode(scriptSource));
|
|
1343
|
+
} catch (e2) {
|
|
1344
|
+
script.text = scriptSource;
|
|
1379
1345
|
}
|
|
1346
|
+
document.body.appendChild(script);
|
|
1380
1347
|
return null;
|
|
1381
1348
|
}
|
|
1382
|
-
function
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1349
|
+
async function loadAsArrayBuffer(url) {
|
|
1350
|
+
const { readFileAsArrayBuffer } = globalThis.loaders || {};
|
|
1351
|
+
if (isBrowser4 || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
1352
|
+
const response = await fetch(url);
|
|
1353
|
+
return await response.arrayBuffer();
|
|
1387
1354
|
}
|
|
1388
|
-
return
|
|
1355
|
+
return await readFileAsArrayBuffer(url);
|
|
1356
|
+
}
|
|
1357
|
+
async function loadAsText(url) {
|
|
1358
|
+
const { readFileAsText } = globalThis.loaders || {};
|
|
1359
|
+
if (isBrowser4 || !readFileAsText || url.startsWith("http")) {
|
|
1360
|
+
const response = await fetch(url);
|
|
1361
|
+
return await response.text();
|
|
1362
|
+
}
|
|
1363
|
+
return await readFileAsText(url);
|
|
1389
1364
|
}
|
|
1390
1365
|
|
|
1391
|
-
// ../
|
|
1392
|
-
|
|
1393
|
-
|
|
1366
|
+
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
1367
|
+
var requestId = 0;
|
|
1368
|
+
async function createLoaderWorker(loader) {
|
|
1369
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
WorkerBody.onmessage = async (type, payload) => {
|
|
1373
|
+
switch (type) {
|
|
1374
|
+
case "process":
|
|
1375
|
+
try {
|
|
1376
|
+
const { input, options = {}, context = {} } = payload;
|
|
1377
|
+
const result = await parseData({
|
|
1378
|
+
loader,
|
|
1379
|
+
arrayBuffer: input,
|
|
1380
|
+
options,
|
|
1381
|
+
// @ts-expect-error fetch missing
|
|
1382
|
+
context: {
|
|
1383
|
+
...context,
|
|
1384
|
+
_parse: parseOnMainThread
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1387
|
+
WorkerBody.postMessage("done", { result });
|
|
1388
|
+
} catch (error) {
|
|
1389
|
+
const message = error instanceof Error ? error.message : "";
|
|
1390
|
+
WorkerBody.postMessage("error", { error: message });
|
|
1391
|
+
}
|
|
1392
|
+
break;
|
|
1393
|
+
default:
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1394
1396
|
}
|
|
1395
|
-
function
|
|
1396
|
-
return
|
|
1397
|
+
function parseOnMainThread(arrayBuffer, loader, options, context) {
|
|
1398
|
+
return new Promise((resolve2, reject) => {
|
|
1399
|
+
const id = requestId++;
|
|
1400
|
+
const onMessage2 = (type, payload2) => {
|
|
1401
|
+
if (payload2.id !== id) {
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
switch (type) {
|
|
1405
|
+
case "done":
|
|
1406
|
+
WorkerBody.removeEventListener(onMessage2);
|
|
1407
|
+
resolve2(payload2.result);
|
|
1408
|
+
break;
|
|
1409
|
+
case "error":
|
|
1410
|
+
WorkerBody.removeEventListener(onMessage2);
|
|
1411
|
+
reject(payload2.error);
|
|
1412
|
+
break;
|
|
1413
|
+
default:
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
WorkerBody.addEventListener(onMessage2);
|
|
1417
|
+
const payload = { id, input: arrayBuffer, options };
|
|
1418
|
+
WorkerBody.postMessage("process", payload);
|
|
1419
|
+
});
|
|
1397
1420
|
}
|
|
1398
|
-
function
|
|
1399
|
-
|
|
1421
|
+
async function parseData({
|
|
1422
|
+
loader,
|
|
1423
|
+
arrayBuffer,
|
|
1424
|
+
options,
|
|
1425
|
+
context
|
|
1426
|
+
}) {
|
|
1427
|
+
let data;
|
|
1428
|
+
let parser;
|
|
1429
|
+
if (loader.parseSync || loader.parse) {
|
|
1430
|
+
data = arrayBuffer;
|
|
1431
|
+
parser = loader.parseSync || loader.parse;
|
|
1432
|
+
} else if (loader.parseTextSync) {
|
|
1433
|
+
const textDecoder = new TextDecoder();
|
|
1434
|
+
data = textDecoder.decode(arrayBuffer);
|
|
1435
|
+
parser = loader.parseTextSync;
|
|
1436
|
+
} else {
|
|
1437
|
+
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
1438
|
+
}
|
|
1439
|
+
options = {
|
|
1440
|
+
...options,
|
|
1441
|
+
modules: loader && loader.options && loader.options.modules || {},
|
|
1442
|
+
worker: false
|
|
1443
|
+
};
|
|
1444
|
+
return await parser(data, { ...options }, context, loader);
|
|
1400
1445
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1446
|
+
|
|
1447
|
+
// ../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts
|
|
1448
|
+
function canParseWithWorker(loader, options) {
|
|
1449
|
+
if (!WorkerFarm.isSupported()) {
|
|
1450
|
+
return false;
|
|
1451
|
+
}
|
|
1452
|
+
if (!isBrowser4 && !options?._nodeWorkers) {
|
|
1453
|
+
return false;
|
|
1454
|
+
}
|
|
1455
|
+
return loader.worker && options?.worker;
|
|
1456
|
+
}
|
|
1457
|
+
async function parseWithWorker(loader, data, options, context, parseOnMainThread2) {
|
|
1458
|
+
const name = loader.id;
|
|
1459
|
+
const url = getWorkerURL(loader, options);
|
|
1460
|
+
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
1461
|
+
const workerPool = workerFarm.getWorkerPool({ name, url });
|
|
1462
|
+
options = JSON.parse(JSON.stringify(options));
|
|
1463
|
+
context = JSON.parse(JSON.stringify(context || {}));
|
|
1464
|
+
const job = await workerPool.startJob(
|
|
1465
|
+
"process-on-worker",
|
|
1466
|
+
// @ts-expect-error
|
|
1467
|
+
onMessage.bind(null, parseOnMainThread2)
|
|
1468
|
+
// eslint-disable-line @typescript-eslint/no-misused-promises
|
|
1469
|
+
);
|
|
1470
|
+
job.postMessage("process", {
|
|
1471
|
+
// @ts-ignore
|
|
1472
|
+
input: data,
|
|
1473
|
+
options,
|
|
1474
|
+
context
|
|
1475
|
+
});
|
|
1476
|
+
const result = await job.result;
|
|
1477
|
+
return await result.result;
|
|
1478
|
+
}
|
|
1479
|
+
async function onMessage(parseOnMainThread2, job, type, payload) {
|
|
1480
|
+
switch (type) {
|
|
1481
|
+
case "done":
|
|
1482
|
+
job.done(payload);
|
|
1483
|
+
break;
|
|
1484
|
+
case "error":
|
|
1485
|
+
job.error(new Error(payload.error));
|
|
1486
|
+
break;
|
|
1487
|
+
case "process":
|
|
1488
|
+
const { id, input, options } = payload;
|
|
1489
|
+
try {
|
|
1490
|
+
const result = await parseOnMainThread2(input, options);
|
|
1491
|
+
job.postMessage("done", { id, result });
|
|
1492
|
+
} catch (error) {
|
|
1493
|
+
const message = error instanceof Error ? error.message : "unknown error";
|
|
1494
|
+
job.postMessage("error", { id, error: message });
|
|
1407
1495
|
}
|
|
1496
|
+
break;
|
|
1497
|
+
default:
|
|
1498
|
+
console.warn(`parse-with-worker unknown message ${type}`);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
// ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
|
|
1503
|
+
function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
|
|
1504
|
+
byteLength = byteLength || arrayBuffer1.byteLength;
|
|
1505
|
+
if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
|
|
1506
|
+
return false;
|
|
1507
|
+
}
|
|
1508
|
+
const array1 = new Uint8Array(arrayBuffer1);
|
|
1509
|
+
const array2 = new Uint8Array(arrayBuffer2);
|
|
1510
|
+
for (let i2 = 0; i2 < array1.length; ++i2) {
|
|
1511
|
+
if (array1[i2] !== array2[i2]) {
|
|
1512
|
+
return false;
|
|
1408
1513
|
}
|
|
1409
|
-
return await fetch(url, fetchOptions);
|
|
1410
1514
|
}
|
|
1411
|
-
return
|
|
1515
|
+
return true;
|
|
1516
|
+
}
|
|
1517
|
+
function concatenateArrayBuffers(...sources) {
|
|
1518
|
+
return concatenateArrayBuffersFromArray(sources);
|
|
1519
|
+
}
|
|
1520
|
+
function concatenateArrayBuffersFromArray(sources) {
|
|
1521
|
+
const sourceArrays = sources.map(
|
|
1522
|
+
(source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2
|
|
1523
|
+
);
|
|
1524
|
+
const byteLength = sourceArrays.reduce((length2, typedArray) => length2 + typedArray.byteLength, 0);
|
|
1525
|
+
const result = new Uint8Array(byteLength);
|
|
1526
|
+
let offset = 0;
|
|
1527
|
+
for (const sourceArray of sourceArrays) {
|
|
1528
|
+
result.set(sourceArray, offset);
|
|
1529
|
+
offset += sourceArray.byteLength;
|
|
1530
|
+
}
|
|
1531
|
+
return result.buffer;
|
|
1412
1532
|
}
|
|
1413
1533
|
|
|
1414
|
-
//
|
|
1415
|
-
function
|
|
1416
|
-
|
|
1417
|
-
|
|
1534
|
+
// ../loader-utils/src/lib/iterators/async-iteration.ts
|
|
1535
|
+
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
1536
|
+
const arrayBuffers = [];
|
|
1537
|
+
for await (const chunk of asyncIterator) {
|
|
1538
|
+
arrayBuffers.push(chunk);
|
|
1418
1539
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1540
|
+
return concatenateArrayBuffers(...arrayBuffers);
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// ../loader-utils/src/lib/path-utils/file-aliases.ts
|
|
1544
|
+
var pathPrefix = "";
|
|
1545
|
+
var fileAliases = {};
|
|
1546
|
+
function resolvePath(filename2) {
|
|
1547
|
+
for (const alias in fileAliases) {
|
|
1548
|
+
if (filename2.startsWith(alias)) {
|
|
1549
|
+
const replacement = fileAliases[alias];
|
|
1550
|
+
filename2 = filename2.replace(alias, replacement);
|
|
1551
|
+
}
|
|
1421
1552
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
if (userAgent && userAgent.indexOf("Electron") >= 0) {
|
|
1425
|
-
return true;
|
|
1553
|
+
if (!filename2.startsWith("http://") && !filename2.startsWith("https://")) {
|
|
1554
|
+
filename2 = `${pathPrefix}${filename2}`;
|
|
1426
1555
|
}
|
|
1427
|
-
return
|
|
1556
|
+
return filename2;
|
|
1428
1557
|
}
|
|
1429
1558
|
|
|
1430
|
-
//
|
|
1431
|
-
function
|
|
1432
|
-
|
|
1433
|
-
return !isNode || isElectron();
|
|
1559
|
+
// ../loader-utils/src/lib/node/buffer.browser.ts
|
|
1560
|
+
function toArrayBuffer(buffer) {
|
|
1561
|
+
return buffer;
|
|
1434
1562
|
}
|
|
1435
1563
|
|
|
1436
|
-
//
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
var document_3 = globalThis.document || {};
|
|
1440
|
-
var process_ = globalThis.process || {};
|
|
1441
|
-
var console_ = globalThis.console;
|
|
1442
|
-
var navigator_ = globalThis.navigator || {};
|
|
1443
|
-
|
|
1444
|
-
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
|
|
1445
|
-
var VERSION2 = true ? "4.2.0-alpha.4" : "untranspiled source";
|
|
1446
|
-
var isBrowser4 = isBrowser3();
|
|
1447
|
-
|
|
1448
|
-
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
1449
|
-
function getStorage(type) {
|
|
1450
|
-
try {
|
|
1451
|
-
const storage = window[type];
|
|
1452
|
-
const x = "__storage_test__";
|
|
1453
|
-
storage.setItem(x, x);
|
|
1454
|
-
storage.removeItem(x);
|
|
1455
|
-
return storage;
|
|
1456
|
-
} catch (e2) {
|
|
1457
|
-
return null;
|
|
1458
|
-
}
|
|
1564
|
+
// ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
|
|
1565
|
+
function isBuffer(value) {
|
|
1566
|
+
return value && typeof value === "object" && value.isBuffer;
|
|
1459
1567
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
_defineProperty(this, "storage", void 0);
|
|
1464
|
-
_defineProperty(this, "id", void 0);
|
|
1465
|
-
_defineProperty(this, "config", void 0);
|
|
1466
|
-
this.storage = getStorage(type);
|
|
1467
|
-
this.id = id;
|
|
1468
|
-
this.config = defaultConfig;
|
|
1469
|
-
this._loadConfiguration();
|
|
1568
|
+
function toArrayBuffer2(data) {
|
|
1569
|
+
if (isBuffer(data)) {
|
|
1570
|
+
return toArrayBuffer(data);
|
|
1470
1571
|
}
|
|
1471
|
-
|
|
1472
|
-
return
|
|
1572
|
+
if (data instanceof ArrayBuffer) {
|
|
1573
|
+
return data;
|
|
1473
1574
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
const serialized = JSON.stringify(this.config);
|
|
1478
|
-
this.storage.setItem(this.id, serialized);
|
|
1575
|
+
if (ArrayBuffer.isView(data)) {
|
|
1576
|
+
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
1577
|
+
return data.buffer;
|
|
1479
1578
|
}
|
|
1579
|
+
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
1480
1580
|
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
|
|
1486
|
-
}
|
|
1487
|
-
Object.assign(this.config, configuration);
|
|
1488
|
-
return this;
|
|
1581
|
+
if (typeof data === "string") {
|
|
1582
|
+
const text = data;
|
|
1583
|
+
const uint8Array = new TextEncoder().encode(text);
|
|
1584
|
+
return uint8Array.buffer;
|
|
1489
1585
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
// ../../node_modules/@probe.gl/log/dist/utils/formatters.js
|
|
1493
|
-
function formatTime(ms) {
|
|
1494
|
-
let formatted;
|
|
1495
|
-
if (ms < 10) {
|
|
1496
|
-
formatted = "".concat(ms.toFixed(2), "ms");
|
|
1497
|
-
} else if (ms < 100) {
|
|
1498
|
-
formatted = "".concat(ms.toFixed(1), "ms");
|
|
1499
|
-
} else if (ms < 1e3) {
|
|
1500
|
-
formatted = "".concat(ms.toFixed(0), "ms");
|
|
1501
|
-
} else {
|
|
1502
|
-
formatted = "".concat((ms / 1e3).toFixed(2), "s");
|
|
1586
|
+
if (data && typeof data === "object" && data._toArrayBuffer) {
|
|
1587
|
+
return data._toArrayBuffer();
|
|
1503
1588
|
}
|
|
1504
|
-
|
|
1505
|
-
}
|
|
1506
|
-
function leftPad(string) {
|
|
1507
|
-
let length2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
|
|
1508
|
-
const padLength = Math.max(length2 - string.length, 0);
|
|
1509
|
-
return "".concat(" ".repeat(padLength)).concat(string);
|
|
1589
|
+
throw new Error("toArrayBuffer");
|
|
1510
1590
|
}
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1591
|
+
|
|
1592
|
+
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1593
|
+
var path_exports = {};
|
|
1594
|
+
__export(path_exports, {
|
|
1595
|
+
dirname: () => dirname,
|
|
1596
|
+
filename: () => filename,
|
|
1597
|
+
join: () => join,
|
|
1598
|
+
resolve: () => resolve
|
|
1599
|
+
});
|
|
1600
|
+
|
|
1601
|
+
// ../loader-utils/src/lib/path-utils/get-cwd.ts
|
|
1602
|
+
function getCWD() {
|
|
1603
|
+
if (typeof process !== "undefined" && typeof process.cwd !== "undefined") {
|
|
1604
|
+
return process.cwd();
|
|
1516
1605
|
}
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1519
|
-
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("");
|
|
1520
|
-
return ["".concat(message, " %c+"), style];
|
|
1606
|
+
const pathname = window.location?.pathname;
|
|
1607
|
+
return pathname?.slice(0, pathname.lastIndexOf("/") + 1) || "";
|
|
1521
1608
|
}
|
|
1522
1609
|
|
|
1523
|
-
//
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1610
|
+
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1611
|
+
function filename(url) {
|
|
1612
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1613
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : "";
|
|
1614
|
+
}
|
|
1615
|
+
function dirname(url) {
|
|
1616
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1617
|
+
return slashIndex >= 0 ? url.substr(0, slashIndex) : "";
|
|
1618
|
+
}
|
|
1619
|
+
function join(...parts) {
|
|
1620
|
+
const separator = "/";
|
|
1621
|
+
parts = parts.map((part, index) => {
|
|
1622
|
+
if (index) {
|
|
1623
|
+
part = part.replace(new RegExp(`^${separator}`), "");
|
|
1624
|
+
}
|
|
1625
|
+
if (index !== parts.length - 1) {
|
|
1626
|
+
part = part.replace(new RegExp(`${separator}$`), "");
|
|
1627
|
+
}
|
|
1628
|
+
return part;
|
|
1629
|
+
});
|
|
1630
|
+
return parts.join(separator);
|
|
1631
|
+
}
|
|
1632
|
+
function resolve(...components) {
|
|
1633
|
+
const paths = [];
|
|
1634
|
+
for (let _i = 0; _i < components.length; _i++) {
|
|
1635
|
+
paths[_i] = components[_i];
|
|
1547
1636
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1637
|
+
let resolvedPath = "";
|
|
1638
|
+
let resolvedAbsolute = false;
|
|
1639
|
+
let cwd;
|
|
1640
|
+
for (let i2 = paths.length - 1; i2 >= -1 && !resolvedAbsolute; i2--) {
|
|
1641
|
+
let path;
|
|
1642
|
+
if (i2 >= 0) {
|
|
1643
|
+
path = paths[i2];
|
|
1644
|
+
} else {
|
|
1645
|
+
if (cwd === void 0) {
|
|
1646
|
+
cwd = getCWD();
|
|
1647
|
+
}
|
|
1648
|
+
path = cwd;
|
|
1649
|
+
}
|
|
1650
|
+
if (path.length === 0) {
|
|
1651
|
+
continue;
|
|
1652
|
+
}
|
|
1653
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
1654
|
+
resolvedAbsolute = path.charCodeAt(0) === SLASH;
|
|
1655
|
+
}
|
|
1656
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
1657
|
+
if (resolvedAbsolute) {
|
|
1658
|
+
return `/${resolvedPath}`;
|
|
1659
|
+
} else if (resolvedPath.length > 0) {
|
|
1660
|
+
return resolvedPath;
|
|
1661
|
+
}
|
|
1662
|
+
return ".";
|
|
1550
1663
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1664
|
+
var SLASH = 47;
|
|
1665
|
+
var DOT = 46;
|
|
1666
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
1667
|
+
let res = "";
|
|
1668
|
+
let lastSlash = -1;
|
|
1669
|
+
let dots = 0;
|
|
1670
|
+
let code;
|
|
1671
|
+
let isAboveRoot = false;
|
|
1672
|
+
for (let i2 = 0; i2 <= path.length; ++i2) {
|
|
1673
|
+
if (i2 < path.length) {
|
|
1674
|
+
code = path.charCodeAt(i2);
|
|
1675
|
+
} else if (code === SLASH) {
|
|
1676
|
+
break;
|
|
1677
|
+
} else {
|
|
1678
|
+
code = SLASH;
|
|
1556
1679
|
}
|
|
1557
|
-
if (
|
|
1558
|
-
|
|
1559
|
-
|
|
1680
|
+
if (code === SLASH) {
|
|
1681
|
+
if (lastSlash === i2 - 1 || dots === 1) {
|
|
1682
|
+
} else if (lastSlash !== i2 - 1 && dots === 2) {
|
|
1683
|
+
if (res.length < 2 || !isAboveRoot || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
|
|
1684
|
+
if (res.length > 2) {
|
|
1685
|
+
const start = res.length - 1;
|
|
1686
|
+
let j = start;
|
|
1687
|
+
for (; j >= 0; --j) {
|
|
1688
|
+
if (res.charCodeAt(j) === SLASH) {
|
|
1689
|
+
break;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
if (j !== start) {
|
|
1693
|
+
res = j === -1 ? "" : res.slice(0, j);
|
|
1694
|
+
lastSlash = i2;
|
|
1695
|
+
dots = 0;
|
|
1696
|
+
isAboveRoot = false;
|
|
1697
|
+
continue;
|
|
1698
|
+
}
|
|
1699
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
1700
|
+
res = "";
|
|
1701
|
+
lastSlash = i2;
|
|
1702
|
+
dots = 0;
|
|
1703
|
+
isAboveRoot = false;
|
|
1704
|
+
continue;
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
if (allowAboveRoot) {
|
|
1708
|
+
if (res.length > 0) {
|
|
1709
|
+
res += "/..";
|
|
1710
|
+
} else {
|
|
1711
|
+
res = "..";
|
|
1712
|
+
}
|
|
1713
|
+
isAboveRoot = true;
|
|
1714
|
+
}
|
|
1715
|
+
} else {
|
|
1716
|
+
const slice = path.slice(lastSlash + 1, i2);
|
|
1717
|
+
if (res.length > 0) {
|
|
1718
|
+
res += `/${slice}`;
|
|
1719
|
+
} else {
|
|
1720
|
+
res = slice;
|
|
1721
|
+
}
|
|
1722
|
+
isAboveRoot = false;
|
|
1723
|
+
}
|
|
1724
|
+
lastSlash = i2;
|
|
1725
|
+
dots = 0;
|
|
1726
|
+
} else if (code === DOT && dots !== -1) {
|
|
1727
|
+
++dots;
|
|
1728
|
+
} else {
|
|
1729
|
+
dots = -1;
|
|
1560
1730
|
}
|
|
1561
1731
|
}
|
|
1562
|
-
return
|
|
1732
|
+
return res;
|
|
1563
1733
|
}
|
|
1564
1734
|
|
|
1565
|
-
//
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1735
|
+
// ../core/src/javascript-utils/is-type.ts
|
|
1736
|
+
var isBoolean = (x) => typeof x === "boolean";
|
|
1737
|
+
var isFunction = (x) => typeof x === "function";
|
|
1738
|
+
var isObject = (x) => x !== null && typeof x === "object";
|
|
1739
|
+
var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
|
|
1740
|
+
var isIterable = (x) => Boolean(x) && typeof x[Symbol.iterator] === "function";
|
|
1741
|
+
var isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
|
|
1742
|
+
var isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
|
|
1743
|
+
var isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
|
|
1744
|
+
var isBuffer2 = (x) => x && typeof x === "object" && x.isBuffer;
|
|
1745
|
+
var isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
|
|
1746
|
+
var isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
|
|
1747
|
+
var isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
|
|
1748
|
+
|
|
1749
|
+
// ../core/src/lib/fetch/fetch-error.ts
|
|
1750
|
+
var FetchError = class extends Error {
|
|
1751
|
+
constructor(message, info) {
|
|
1752
|
+
super(message);
|
|
1753
|
+
this.reason = info.reason;
|
|
1754
|
+
this.url = info.url;
|
|
1755
|
+
this.response = info.response;
|
|
1756
|
+
}
|
|
1757
|
+
/** A best effort reason for why the fetch failed */
|
|
1758
|
+
reason;
|
|
1759
|
+
/** The URL that failed to load. Empty string if not available. */
|
|
1760
|
+
url;
|
|
1761
|
+
/** The Response object, if any. */
|
|
1762
|
+
response;
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
// ../core/src/lib/utils/mime-type-utils.ts
|
|
1766
|
+
var DATA_URL_PATTERN = /^data:([-\w.]+\/[-\w.+]+)(;|,)/;
|
|
1767
|
+
var MIME_TYPE_PATTERN = /^([-\w.]+\/[-\w.+]+)/;
|
|
1768
|
+
function compareMIMETypes(mimeType1, mimeType2) {
|
|
1769
|
+
if (mimeType1.toLowerCase() === mimeType2.toLowerCase()) {
|
|
1770
|
+
return true;
|
|
1578
1771
|
}
|
|
1772
|
+
return false;
|
|
1579
1773
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
throw new Error(message || "Assertion failed");
|
|
1774
|
+
function parseMIMEType(mimeString) {
|
|
1775
|
+
const matches3 = MIME_TYPE_PATTERN.exec(mimeString);
|
|
1776
|
+
if (matches3) {
|
|
1777
|
+
return matches3[1];
|
|
1585
1778
|
}
|
|
1779
|
+
return mimeString;
|
|
1586
1780
|
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
if (isBrowser3() && window_3.performance) {
|
|
1592
|
-
var _window$performance, _window$performance$n;
|
|
1593
|
-
timestamp = window_3 === null || window_3 === void 0 ? void 0 : (_window$performance = window_3.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);
|
|
1594
|
-
} else if ("hrtime" in process_) {
|
|
1595
|
-
var _process$hrtime;
|
|
1596
|
-
const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
|
|
1597
|
-
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
1598
|
-
} else {
|
|
1599
|
-
timestamp = Date.now();
|
|
1781
|
+
function parseMIMETypeFromURL(url) {
|
|
1782
|
+
const matches3 = DATA_URL_PATTERN.exec(url);
|
|
1783
|
+
if (matches3) {
|
|
1784
|
+
return matches3[1];
|
|
1600
1785
|
}
|
|
1601
|
-
return
|
|
1786
|
+
return "";
|
|
1602
1787
|
}
|
|
1603
1788
|
|
|
1604
|
-
//
|
|
1605
|
-
var
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
warn: console.warn,
|
|
1610
|
-
error: console.error
|
|
1611
|
-
};
|
|
1612
|
-
var DEFAULT_LOG_CONFIGURATION = {
|
|
1613
|
-
enabled: true,
|
|
1614
|
-
level: 0
|
|
1615
|
-
};
|
|
1616
|
-
function noop() {
|
|
1789
|
+
// ../core/src/lib/utils/url-utils.ts
|
|
1790
|
+
var QUERY_STRING_PATTERN = /\?.*/;
|
|
1791
|
+
function extractQueryString(url) {
|
|
1792
|
+
const matches3 = url.match(QUERY_STRING_PATTERN);
|
|
1793
|
+
return matches3 && matches3[0];
|
|
1617
1794
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
let {
|
|
1625
|
-
id
|
|
1626
|
-
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
1627
|
-
id: ""
|
|
1628
|
-
};
|
|
1629
|
-
_defineProperty(this, "id", void 0);
|
|
1630
|
-
_defineProperty(this, "VERSION", VERSION2);
|
|
1631
|
-
_defineProperty(this, "_startTs", getHiResTimestamp());
|
|
1632
|
-
_defineProperty(this, "_deltaTs", getHiResTimestamp());
|
|
1633
|
-
_defineProperty(this, "_storage", void 0);
|
|
1634
|
-
_defineProperty(this, "userData", {});
|
|
1635
|
-
_defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
|
|
1636
|
-
this.id = id;
|
|
1637
|
-
this.userData = {};
|
|
1638
|
-
this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
|
|
1639
|
-
this.timeStamp("".concat(this.id, " started"));
|
|
1640
|
-
autobind(this);
|
|
1641
|
-
Object.seal(this);
|
|
1642
|
-
}
|
|
1643
|
-
set level(newLevel) {
|
|
1644
|
-
this.setLevel(newLevel);
|
|
1645
|
-
}
|
|
1646
|
-
get level() {
|
|
1647
|
-
return this.getLevel();
|
|
1648
|
-
}
|
|
1649
|
-
isEnabled() {
|
|
1650
|
-
return this._storage.config.enabled;
|
|
1651
|
-
}
|
|
1652
|
-
getLevel() {
|
|
1653
|
-
return this._storage.config.level;
|
|
1654
|
-
}
|
|
1655
|
-
getTotal() {
|
|
1656
|
-
return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
|
|
1657
|
-
}
|
|
1658
|
-
getDelta() {
|
|
1659
|
-
return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
|
|
1660
|
-
}
|
|
1661
|
-
set priority(newPriority) {
|
|
1662
|
-
this.level = newPriority;
|
|
1663
|
-
}
|
|
1664
|
-
get priority() {
|
|
1665
|
-
return this.level;
|
|
1666
|
-
}
|
|
1667
|
-
getPriority() {
|
|
1668
|
-
return this.level;
|
|
1669
|
-
}
|
|
1670
|
-
enable() {
|
|
1671
|
-
let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
1672
|
-
this._storage.setConfiguration({
|
|
1673
|
-
enabled
|
|
1674
|
-
});
|
|
1675
|
-
return this;
|
|
1676
|
-
}
|
|
1677
|
-
setLevel(level) {
|
|
1678
|
-
this._storage.setConfiguration({
|
|
1679
|
-
level
|
|
1680
|
-
});
|
|
1681
|
-
return this;
|
|
1682
|
-
}
|
|
1683
|
-
get(setting) {
|
|
1684
|
-
return this._storage.config[setting];
|
|
1685
|
-
}
|
|
1686
|
-
set(setting, value) {
|
|
1687
|
-
this._storage.setConfiguration({
|
|
1688
|
-
[setting]: value
|
|
1689
|
-
});
|
|
1690
|
-
}
|
|
1691
|
-
settings() {
|
|
1692
|
-
if (console.table) {
|
|
1693
|
-
console.table(this._storage.config);
|
|
1694
|
-
} else {
|
|
1695
|
-
console.log(this._storage.config);
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
assert(condition, message) {
|
|
1699
|
-
assert3(condition, message);
|
|
1700
|
-
}
|
|
1701
|
-
warn(message) {
|
|
1702
|
-
return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
|
|
1703
|
-
}
|
|
1704
|
-
error(message) {
|
|
1705
|
-
return this._getLogFunction(0, message, originalConsole.error, arguments);
|
|
1706
|
-
}
|
|
1707
|
-
deprecated(oldUsage, newUsage) {
|
|
1708
|
-
return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
|
|
1709
|
-
}
|
|
1710
|
-
removed(oldUsage, newUsage) {
|
|
1711
|
-
return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
|
|
1795
|
+
function stripQueryString(url) {
|
|
1796
|
+
return url.replace(QUERY_STRING_PATTERN, "");
|
|
1797
|
+
}
|
|
1798
|
+
function shortenUrlForDisplay(url) {
|
|
1799
|
+
if (url.length < 50) {
|
|
1800
|
+
return url;
|
|
1712
1801
|
}
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1802
|
+
const urlEnd = url.slice(url.length - 15);
|
|
1803
|
+
const urlStart = url.substr(0, 32);
|
|
1804
|
+
return `${urlStart}...${urlEnd}`;
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
// ../core/src/lib/utils/resource-utils.ts
|
|
1808
|
+
function getResourceUrl(resource) {
|
|
1809
|
+
if (isResponse(resource)) {
|
|
1810
|
+
const response = resource;
|
|
1811
|
+
return response.url;
|
|
1718
1812
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1813
|
+
if (isBlob(resource)) {
|
|
1814
|
+
const blob = resource;
|
|
1815
|
+
return blob.name || "";
|
|
1721
1816
|
}
|
|
1722
|
-
|
|
1723
|
-
return
|
|
1817
|
+
if (typeof resource === "string") {
|
|
1818
|
+
return resource;
|
|
1724
1819
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1820
|
+
return "";
|
|
1821
|
+
}
|
|
1822
|
+
function getResourceMIMEType(resource) {
|
|
1823
|
+
if (isResponse(resource)) {
|
|
1824
|
+
const response = resource;
|
|
1825
|
+
const contentTypeHeader = response.headers.get("content-type") || "";
|
|
1826
|
+
const noQueryUrl = stripQueryString(response.url);
|
|
1827
|
+
return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);
|
|
1727
1828
|
}
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
tag: getTableHeader(table)
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
|
-
return noop;
|
|
1829
|
+
if (isBlob(resource)) {
|
|
1830
|
+
const blob = resource;
|
|
1831
|
+
return blob.type || "";
|
|
1735
1832
|
}
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
logLevel,
|
|
1739
|
-
priority,
|
|
1740
|
-
image,
|
|
1741
|
-
message = "",
|
|
1742
|
-
scale: scale3 = 1
|
|
1743
|
-
} = _ref;
|
|
1744
|
-
if (!this._shouldLog(logLevel || priority)) {
|
|
1745
|
-
return noop;
|
|
1746
|
-
}
|
|
1747
|
-
return isBrowser3() ? logImageInBrowser({
|
|
1748
|
-
image,
|
|
1749
|
-
message,
|
|
1750
|
-
scale: scale3
|
|
1751
|
-
}) : logImageInNode({
|
|
1752
|
-
image,
|
|
1753
|
-
message,
|
|
1754
|
-
scale: scale3
|
|
1755
|
-
});
|
|
1833
|
+
if (typeof resource === "string") {
|
|
1834
|
+
return parseMIMETypeFromURL(resource);
|
|
1756
1835
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1836
|
+
return "";
|
|
1837
|
+
}
|
|
1838
|
+
function getResourceContentLength(resource) {
|
|
1839
|
+
if (isResponse(resource)) {
|
|
1840
|
+
const response = resource;
|
|
1841
|
+
return response.headers["content-length"] || -1;
|
|
1759
1842
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1843
|
+
if (isBlob(resource)) {
|
|
1844
|
+
const blob = resource;
|
|
1845
|
+
return blob.size;
|
|
1762
1846
|
}
|
|
1763
|
-
|
|
1764
|
-
return
|
|
1847
|
+
if (typeof resource === "string") {
|
|
1848
|
+
return resource.length;
|
|
1765
1849
|
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
collapsed: false
|
|
1769
|
-
};
|
|
1770
|
-
const options = normalizeArguments({
|
|
1771
|
-
logLevel,
|
|
1772
|
-
message,
|
|
1773
|
-
opts
|
|
1774
|
-
});
|
|
1775
|
-
const {
|
|
1776
|
-
collapsed
|
|
1777
|
-
} = opts;
|
|
1778
|
-
options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
|
|
1779
|
-
return this._getLogFunction(options);
|
|
1850
|
+
if (resource instanceof ArrayBuffer) {
|
|
1851
|
+
return resource.byteLength;
|
|
1780
1852
|
}
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
return this.group(logLevel, message, Object.assign({}, opts, {
|
|
1784
|
-
collapsed: true
|
|
1785
|
-
}));
|
|
1853
|
+
if (ArrayBuffer.isView(resource)) {
|
|
1854
|
+
return resource.byteLength;
|
|
1786
1855
|
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1856
|
+
return -1;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
// ../core/src/lib/utils/response-utils.ts
|
|
1860
|
+
async function makeResponse(resource) {
|
|
1861
|
+
if (isResponse(resource)) {
|
|
1862
|
+
return resource;
|
|
1789
1863
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
} finally {
|
|
1795
|
-
this.groupEnd(logLevel)();
|
|
1796
|
-
}
|
|
1864
|
+
const headers = {};
|
|
1865
|
+
const contentLength = getResourceContentLength(resource);
|
|
1866
|
+
if (contentLength >= 0) {
|
|
1867
|
+
headers["content-length"] = String(contentLength);
|
|
1797
1868
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1869
|
+
const url = getResourceUrl(resource);
|
|
1870
|
+
const type = getResourceMIMEType(resource);
|
|
1871
|
+
if (type) {
|
|
1872
|
+
headers["content-type"] = type;
|
|
1802
1873
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1874
|
+
const initialDataUrl = await getInitialDataUrl(resource);
|
|
1875
|
+
if (initialDataUrl) {
|
|
1876
|
+
headers["x-first-bytes"] = initialDataUrl;
|
|
1805
1877
|
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
opts = normalizeArguments({
|
|
1809
|
-
logLevel,
|
|
1810
|
-
message,
|
|
1811
|
-
args,
|
|
1812
|
-
opts
|
|
1813
|
-
});
|
|
1814
|
-
method = method || opts.method;
|
|
1815
|
-
assert3(method);
|
|
1816
|
-
opts.total = this.getTotal();
|
|
1817
|
-
opts.delta = this.getDelta();
|
|
1818
|
-
this._deltaTs = getHiResTimestamp();
|
|
1819
|
-
const tag = opts.tag || opts.message;
|
|
1820
|
-
if (opts.once && tag) {
|
|
1821
|
-
if (!cache[tag]) {
|
|
1822
|
-
cache[tag] = getHiResTimestamp();
|
|
1823
|
-
} else {
|
|
1824
|
-
return noop;
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
message = decorateMessage(this.id, opts.message, opts);
|
|
1828
|
-
return method.bind(console, message, ...opts.args);
|
|
1829
|
-
}
|
|
1830
|
-
return noop;
|
|
1878
|
+
if (typeof resource === "string") {
|
|
1879
|
+
resource = new TextEncoder().encode(resource);
|
|
1831
1880
|
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1881
|
+
const response = new Response(resource, { headers });
|
|
1882
|
+
Object.defineProperty(response, "url", { value: url });
|
|
1883
|
+
return response;
|
|
1884
|
+
}
|
|
1885
|
+
async function checkResponse(response) {
|
|
1886
|
+
if (!response.ok) {
|
|
1887
|
+
const error = await getResponseError(response);
|
|
1888
|
+
throw error;
|
|
1837
1889
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1890
|
+
}
|
|
1891
|
+
async function getResponseError(response) {
|
|
1892
|
+
const shortUrl = shortenUrlForDisplay(response.url);
|
|
1893
|
+
let message = `Failed to fetch resource (${response.status}) ${response.statusText}: ${shortUrl}`;
|
|
1894
|
+
message = message.length > 100 ? `${message.slice(0, 100)}...` : message;
|
|
1895
|
+
const info = {
|
|
1896
|
+
reason: response.statusText,
|
|
1897
|
+
url: response.url,
|
|
1898
|
+
response
|
|
1899
|
+
};
|
|
1900
|
+
try {
|
|
1901
|
+
const contentType = response.headers.get("Content-Type");
|
|
1902
|
+
info.reason = contentType?.includes("application/json") ? await response.json() : response.text();
|
|
1903
|
+
} catch (error) {
|
|
1848
1904
|
}
|
|
1849
|
-
|
|
1850
|
-
return resolvedLevel;
|
|
1905
|
+
return new FetchError(message, info);
|
|
1851
1906
|
}
|
|
1852
|
-
function
|
|
1853
|
-
const
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
} = opts;
|
|
1857
|
-
opts.logLevel = normalizeLogLevel(logLevel);
|
|
1858
|
-
const args = opts.args ? Array.from(opts.args) : [];
|
|
1859
|
-
while (args.length && args.shift() !== message) {
|
|
1907
|
+
async function getInitialDataUrl(resource) {
|
|
1908
|
+
const INITIAL_DATA_LENGTH = 5;
|
|
1909
|
+
if (typeof resource === "string") {
|
|
1910
|
+
return `data:,${resource.slice(0, INITIAL_DATA_LENGTH)}`;
|
|
1860
1911
|
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
break;
|
|
1869
|
-
case "object":
|
|
1870
|
-
Object.assign(opts, logLevel);
|
|
1871
|
-
break;
|
|
1872
|
-
default:
|
|
1912
|
+
if (resource instanceof Blob) {
|
|
1913
|
+
const blobSlice = resource.slice(0, 5);
|
|
1914
|
+
return await new Promise((resolve2) => {
|
|
1915
|
+
const reader = new FileReader();
|
|
1916
|
+
reader.onload = (event) => resolve2(event?.target?.result);
|
|
1917
|
+
reader.readAsDataURL(blobSlice);
|
|
1918
|
+
});
|
|
1873
1919
|
}
|
|
1874
|
-
if (
|
|
1875
|
-
|
|
1920
|
+
if (resource instanceof ArrayBuffer) {
|
|
1921
|
+
const slice = resource.slice(0, INITIAL_DATA_LENGTH);
|
|
1922
|
+
const base64 = arrayBufferToBase64(slice);
|
|
1923
|
+
return `data:base64,${base64}`;
|
|
1876
1924
|
}
|
|
1877
|
-
|
|
1878
|
-
assert3(messageType === "string" || messageType === "object");
|
|
1879
|
-
return Object.assign(opts, {
|
|
1880
|
-
args
|
|
1881
|
-
}, opts.opts);
|
|
1925
|
+
return null;
|
|
1882
1926
|
}
|
|
1883
|
-
function
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1927
|
+
function arrayBufferToBase64(buffer) {
|
|
1928
|
+
let binary = "";
|
|
1929
|
+
const bytes = new Uint8Array(buffer);
|
|
1930
|
+
for (let i2 = 0; i2 < bytes.byteLength; i2++) {
|
|
1931
|
+
binary += String.fromCharCode(bytes[i2]);
|
|
1888
1932
|
}
|
|
1889
|
-
return
|
|
1933
|
+
return btoa(binary);
|
|
1890
1934
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
scale: scale3 = 1
|
|
1896
|
-
} = _ref2;
|
|
1897
|
-
console.warn("removed");
|
|
1898
|
-
return noop;
|
|
1935
|
+
|
|
1936
|
+
// ../core/src/lib/fetch/fetch-file.ts
|
|
1937
|
+
function isNodePath(url) {
|
|
1938
|
+
return !isRequestURL(url) && !isDataURL(url);
|
|
1899
1939
|
}
|
|
1900
|
-
function
|
|
1901
|
-
|
|
1902
|
-
image,
|
|
1903
|
-
message = "",
|
|
1904
|
-
scale: scale3 = 1
|
|
1905
|
-
} = _ref3;
|
|
1906
|
-
if (typeof image === "string") {
|
|
1907
|
-
const img = new Image();
|
|
1908
|
-
img.onload = () => {
|
|
1909
|
-
const args = formatImage(img, message, scale3);
|
|
1910
|
-
console.log(...args);
|
|
1911
|
-
};
|
|
1912
|
-
img.src = image;
|
|
1913
|
-
return noop;
|
|
1914
|
-
}
|
|
1915
|
-
const element = image.nodeName || "";
|
|
1916
|
-
if (element.toLowerCase() === "img") {
|
|
1917
|
-
console.log(...formatImage(image, message, scale3));
|
|
1918
|
-
return noop;
|
|
1919
|
-
}
|
|
1920
|
-
if (element.toLowerCase() === "canvas") {
|
|
1921
|
-
const img = new Image();
|
|
1922
|
-
img.onload = () => console.log(...formatImage(img, message, scale3));
|
|
1923
|
-
img.src = image.toDataURL();
|
|
1924
|
-
return noop;
|
|
1925
|
-
}
|
|
1926
|
-
return noop;
|
|
1940
|
+
function isRequestURL(url) {
|
|
1941
|
+
return url.startsWith("http:") || url.startsWith("https:");
|
|
1927
1942
|
}
|
|
1928
|
-
function
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1943
|
+
function isDataURL(url) {
|
|
1944
|
+
return url.startsWith("data:");
|
|
1945
|
+
}
|
|
1946
|
+
async function fetchFile(urlOrData, fetchOptions) {
|
|
1947
|
+
if (typeof urlOrData === "string") {
|
|
1948
|
+
const url = resolvePath(urlOrData);
|
|
1949
|
+
if (isNodePath(url)) {
|
|
1950
|
+
if (globalThis.loaders?.fetchNode) {
|
|
1951
|
+
return globalThis.loaders?.fetchNode(url, fetchOptions);
|
|
1952
|
+
}
|
|
1932
1953
|
}
|
|
1954
|
+
return await fetch(url, fetchOptions);
|
|
1933
1955
|
}
|
|
1934
|
-
return
|
|
1956
|
+
return await makeResponse(urlOrData);
|
|
1935
1957
|
}
|
|
1936
1958
|
|
|
1937
|
-
// ../../node_modules/@probe.gl/log/dist/index.js
|
|
1938
|
-
var dist_default = new Log({
|
|
1939
|
-
id: "@probe.gl/log"
|
|
1940
|
-
});
|
|
1941
|
-
|
|
1942
1959
|
// ../core/src/lib/loader-utils/loggers.ts
|
|
1943
1960
|
var probeLog = new Log({ id: "loaders.gl" });
|
|
1944
1961
|
var NullLog = class {
|
|
@@ -2278,10 +2295,10 @@
|
|
|
2278
2295
|
}
|
|
2279
2296
|
function findLoaderByMIMEType(loaders, mimeType) {
|
|
2280
2297
|
for (const loader of loaders) {
|
|
2281
|
-
if (loader.mimeTypes
|
|
2298
|
+
if (loader.mimeTypes?.some((mimeType1) => compareMIMETypes(mimeType, mimeType1))) {
|
|
2282
2299
|
return loader;
|
|
2283
2300
|
}
|
|
2284
|
-
if (mimeType
|
|
2301
|
+
if (compareMIMETypes(mimeType, `application/x.${loader.id}`)) {
|
|
2285
2302
|
return loader;
|
|
2286
2303
|
}
|
|
2287
2304
|
}
|
|
@@ -2603,7 +2620,7 @@
|
|
|
2603
2620
|
if (loaderWithParser.parse) {
|
|
2604
2621
|
return await loaderWithParser.parse(data, options, context);
|
|
2605
2622
|
}
|
|
2606
|
-
|
|
2623
|
+
assert3(!loaderWithParser.parseSync);
|
|
2607
2624
|
throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
|
|
2608
2625
|
}
|
|
2609
2626
|
|
|
@@ -5312,7 +5329,7 @@
|
|
|
5312
5329
|
_defineProperty(Ellipsoid, "WGS84", new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z));
|
|
5313
5330
|
|
|
5314
5331
|
// ../images/src/lib/utils/version.ts
|
|
5315
|
-
var VERSION3 = true ? "4.2.0-alpha.
|
|
5332
|
+
var VERSION3 = true ? "4.2.0-alpha.6" : "latest";
|
|
5316
5333
|
|
|
5317
5334
|
// ../images/src/lib/category-api/image-type.ts
|
|
5318
5335
|
var parseImageNode = globalThis.loaders?.parseImageNode;
|
|
@@ -5705,6 +5722,8 @@
|
|
|
5705
5722
|
// imagebitmap: {} - passes (platform dependent) parameters to ImageBitmap constructor
|
|
5706
5723
|
};
|
|
5707
5724
|
var ImageLoader = {
|
|
5725
|
+
dataType: null,
|
|
5726
|
+
batchType: null,
|
|
5708
5727
|
id: "image",
|
|
5709
5728
|
module: "images",
|
|
5710
5729
|
name: "Images",
|
|
@@ -5718,10 +5737,12 @@
|
|
|
5718
5737
|
};
|
|
5719
5738
|
|
|
5720
5739
|
// ../draco/src/lib/utils/version.ts
|
|
5721
|
-
var VERSION4 = true ? "4.2.0-alpha.
|
|
5740
|
+
var VERSION4 = true ? "4.2.0-alpha.6" : "latest";
|
|
5722
5741
|
|
|
5723
5742
|
// ../draco/src/draco-loader.ts
|
|
5724
5743
|
var DracoLoader = {
|
|
5744
|
+
dataType: null,
|
|
5745
|
+
batchType: null,
|
|
5725
5746
|
name: "Draco",
|
|
5726
5747
|
id: "draco",
|
|
5727
5748
|
module: "draco",
|
|
@@ -5799,7 +5820,11 @@
|
|
|
5799
5820
|
4: Uint16Array,
|
|
5800
5821
|
5: Int32Array,
|
|
5801
5822
|
6: Uint32Array,
|
|
5823
|
+
// 7: BigInt64Array,
|
|
5824
|
+
// 8: BigUint64Array,
|
|
5802
5825
|
9: Float32Array
|
|
5826
|
+
// 10: Float64Array
|
|
5827
|
+
// 11: BOOL - What array type do we use for this?
|
|
5803
5828
|
};
|
|
5804
5829
|
var INDEX_ITEM_SIZE = 4;
|
|
5805
5830
|
var DracoParser = class {
|
|
@@ -5972,14 +5997,17 @@
|
|
|
5972
5997
|
for (const loaderAttribute of Object.values(loaderData.attributes)) {
|
|
5973
5998
|
const attributeName = this._deduceAttributeName(loaderAttribute, options);
|
|
5974
5999
|
loaderAttribute.name = attributeName;
|
|
5975
|
-
const
|
|
5976
|
-
|
|
5977
|
-
value,
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
6000
|
+
const values = this._getAttributeValues(dracoGeometry, loaderAttribute);
|
|
6001
|
+
if (values) {
|
|
6002
|
+
const { value, size } = values;
|
|
6003
|
+
attributes[attributeName] = {
|
|
6004
|
+
value,
|
|
6005
|
+
size,
|
|
6006
|
+
byteOffset: loaderAttribute.byte_offset,
|
|
6007
|
+
byteStride: loaderAttribute.byte_stride,
|
|
6008
|
+
normalized: loaderAttribute.normalized
|
|
6009
|
+
};
|
|
6010
|
+
}
|
|
5983
6011
|
}
|
|
5984
6012
|
return attributes;
|
|
5985
6013
|
}
|
|
@@ -6021,6 +6049,10 @@
|
|
|
6021
6049
|
*/
|
|
6022
6050
|
_getAttributeValues(dracoGeometry, attribute) {
|
|
6023
6051
|
const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
|
|
6052
|
+
if (!TypedArrayCtor) {
|
|
6053
|
+
console.warn(`DRACO: Unsupported attribute type ${attribute.data_type}`);
|
|
6054
|
+
return null;
|
|
6055
|
+
}
|
|
6024
6056
|
const numComponents = attribute.num_components;
|
|
6025
6057
|
const numPoints = dracoGeometry.num_points();
|
|
6026
6058
|
const numValues = numPoints * numComponents;
|
|
@@ -6251,11 +6283,11 @@
|
|
|
6251
6283
|
async function loadDracoDecoderModule(options) {
|
|
6252
6284
|
const modules = options.modules || {};
|
|
6253
6285
|
if (modules.draco3d) {
|
|
6254
|
-
loadDecoderPromise
|
|
6286
|
+
loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
|
|
6255
6287
|
return { draco };
|
|
6256
6288
|
});
|
|
6257
6289
|
} else {
|
|
6258
|
-
loadDecoderPromise
|
|
6290
|
+
loadDecoderPromise ||= loadDracoDecoder(options);
|
|
6259
6291
|
}
|
|
6260
6292
|
return await loadDecoderPromise;
|
|
6261
6293
|
}
|
|
@@ -6321,7 +6353,7 @@
|
|
|
6321
6353
|
}
|
|
6322
6354
|
|
|
6323
6355
|
// ../textures/src/lib/utils/version.ts
|
|
6324
|
-
var VERSION5 = true ? "4.2.0-alpha.
|
|
6356
|
+
var VERSION5 = true ? "4.2.0-alpha.6" : "latest";
|
|
6325
6357
|
|
|
6326
6358
|
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
6327
6359
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
@@ -6336,11 +6368,12 @@
|
|
|
6336
6368
|
};
|
|
6337
6369
|
var loadBasisTranscoderPromise;
|
|
6338
6370
|
async function loadBasisTranscoderModule(options) {
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6371
|
+
registerJSModules(options.modules);
|
|
6372
|
+
const basis = getJSModuleOrNull("basis");
|
|
6373
|
+
if (basis) {
|
|
6374
|
+
return basis;
|
|
6342
6375
|
}
|
|
6343
|
-
loadBasisTranscoderPromise
|
|
6376
|
+
loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
|
|
6344
6377
|
return await loadBasisTranscoderPromise;
|
|
6345
6378
|
}
|
|
6346
6379
|
async function loadBasisTranscoder(options) {
|
|
@@ -7006,6 +7039,8 @@
|
|
|
7006
7039
|
|
|
7007
7040
|
// ../textures/src/basis-loader.ts
|
|
7008
7041
|
var BasisWorkerLoader = {
|
|
7042
|
+
dataType: null,
|
|
7043
|
+
batchType: null,
|
|
7009
7044
|
name: "Basis",
|
|
7010
7045
|
id: "basis",
|
|
7011
7046
|
module: "textures",
|
|
@@ -7018,12 +7053,9 @@
|
|
|
7018
7053
|
options: {
|
|
7019
7054
|
basis: {
|
|
7020
7055
|
format: "auto",
|
|
7021
|
-
// gl context doesn't exist on a worker thread
|
|
7022
7056
|
libraryPath: "libs/",
|
|
7023
7057
|
containerFormat: "auto",
|
|
7024
|
-
// 'basis' || 'ktx2' || 'auto'
|
|
7025
7058
|
module: "transcoder"
|
|
7026
|
-
// 'transcoder' || 'encoder'
|
|
7027
7059
|
}
|
|
7028
7060
|
}
|
|
7029
7061
|
};
|
|
@@ -7324,6 +7356,8 @@
|
|
|
7324
7356
|
|
|
7325
7357
|
// ../textures/src/compressed-texture-loader.ts
|
|
7326
7358
|
var CompressedTextureWorkerLoader = {
|
|
7359
|
+
dataType: null,
|
|
7360
|
+
batchType: null,
|
|
7327
7361
|
name: "Texture Containers",
|
|
7328
7362
|
id: "compressed-texture",
|
|
7329
7363
|
module: "textures",
|
|
@@ -7483,11 +7517,7 @@
|
|
|
7483
7517
|
texture: null
|
|
7484
7518
|
};
|
|
7485
7519
|
if (tileOptions.textureUrl) {
|
|
7486
|
-
const url = getUrlWithToken(
|
|
7487
|
-
getInternalPathFromUrl(tileOptions.textureUrl),
|
|
7488
|
-
// @ts-expect-error options is not properly typed
|
|
7489
|
-
options?.i3s?.token
|
|
7490
|
-
);
|
|
7520
|
+
const url = getUrlWithToken(tileOptions.textureUrl, options?.i3s?.token);
|
|
7491
7521
|
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
7492
7522
|
const fetchFunc = context?.fetch || fetch;
|
|
7493
7523
|
const response = await fetchFunc(url);
|
|
@@ -7525,18 +7555,6 @@
|
|
|
7525
7555
|
}
|
|
7526
7556
|
return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
7527
7557
|
}
|
|
7528
|
-
function getInternalPathFromUrl(url) {
|
|
7529
|
-
const slpkUrlParts = url.split(".slpk");
|
|
7530
|
-
let filename2;
|
|
7531
|
-
if (slpkUrlParts.length === 1) {
|
|
7532
|
-
filename2 = url;
|
|
7533
|
-
} else if (slpkUrlParts.length === 2) {
|
|
7534
|
-
filename2 = slpkUrlParts[1].slice(1);
|
|
7535
|
-
} else {
|
|
7536
|
-
filename2 = url;
|
|
7537
|
-
}
|
|
7538
|
-
return filename2;
|
|
7539
|
-
}
|
|
7540
7558
|
async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
7541
7559
|
const contentByteLength = arrayBuffer.byteLength;
|
|
7542
7560
|
let attributes;
|
|
@@ -7664,11 +7682,11 @@
|
|
|
7664
7682
|
for (const { property, type } of options.store.defaultGeometrySchema.header) {
|
|
7665
7683
|
const TypedArrayTypeHeader = getConstructorForDataFormat(type);
|
|
7666
7684
|
switch (property) {
|
|
7667
|
-
case "vertexCount" /* vertexCount
|
|
7685
|
+
case "vertexCount" /* vertexCount */.toString():
|
|
7668
7686
|
vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];
|
|
7669
7687
|
byteOffset += sizeOf(type);
|
|
7670
7688
|
break;
|
|
7671
|
-
case "featureCount" /* featureCount
|
|
7689
|
+
case "featureCount" /* featureCount */.toString():
|
|
7672
7690
|
featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];
|
|
7673
7691
|
byteOffset += sizeOf(type);
|
|
7674
7692
|
break;
|
|
@@ -7866,8 +7884,10 @@
|
|
|
7866
7884
|
}
|
|
7867
7885
|
|
|
7868
7886
|
// src/i3s-content-loader.ts
|
|
7869
|
-
var VERSION6 = true ? "4.2.0-alpha.
|
|
7887
|
+
var VERSION6 = true ? "4.2.0-alpha.6" : "latest";
|
|
7870
7888
|
var I3SContentLoader = {
|
|
7889
|
+
dataType: null,
|
|
7890
|
+
batchType: null,
|
|
7871
7891
|
name: "I3S Content (Indexed Scene Layers)",
|
|
7872
7892
|
id: "i3s-content",
|
|
7873
7893
|
module: "i3s",
|