@loaders.gl/core 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/dist.dev.js +1946 -1868
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +115 -71
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lib/api/parse-in-batches.js +1 -0
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +3 -2
- package/dist/lib/fetch/fetch-error-message.d.ts.map +1 -1
- package/dist/lib/fetch/fetch-error-message.js +2 -0
- package/dist/lib/fetch/fetch-error.d.ts +14 -0
- package/dist/lib/fetch/fetch-error.d.ts.map +1 -0
- package/dist/lib/fetch/fetch-error.js +17 -0
- package/dist/lib/fetch/fetch-file.d.ts.map +1 -1
- package/dist/lib/fetch/fetch-file.js +1 -0
- package/dist/lib/filesystems/browser-filesystem.js +4 -3
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/loggers.js +1 -0
- package/dist/lib/loader-utils/option-utils.d.ts +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +3 -0
- package/dist/lib/utils/mime-type-utils.d.ts +8 -0
- package/dist/lib/utils/mime-type-utils.d.ts.map +1 -1
- package/dist/lib/utils/mime-type-utils.js +13 -0
- package/dist/lib/utils/response-utils.d.ts.map +1 -1
- package/dist/lib/utils/response-utils.js +16 -10
- package/dist/lib/utils/url-utils.d.ts +1 -0
- package/dist/lib/utils/url-utils.d.ts.map +1 -1
- package/dist/lib/utils/url-utils.js +8 -0
- package/dist/null-loader.d.ts +40 -3
- package/dist/null-loader.d.ts.map +1 -1
- package/dist/null-loader.js +5 -1
- package/dist/null-worker-node.js +6 -2
- package/dist/null-worker.js +6 -2
- package/package.json +9 -8
- package/src/index.ts +1 -0
- package/src/lib/api/parse-in-batches.ts +6 -5
- package/src/lib/api/select-loader.ts +3 -2
- package/src/lib/fetch/fetch-error-message.ts +2 -0
- package/src/lib/fetch/fetch-error.ts +18 -0
- package/src/lib/fetch/fetch-file.ts +1 -0
- package/src/lib/loader-utils/option-utils.ts +3 -1
- package/src/lib/utils/mime-type-utils.ts +14 -0
- package/src/lib/utils/resource-utils.ts +1 -1
- package/src/lib/utils/response-utils.ts +19 -11
- package/src/lib/utils/url-utils.ts +9 -0
- package/src/null-loader.ts +9 -4
package/dist/dist.dev.js
CHANGED
|
@@ -10,6 +10,7 @@ var __exports__ = (() => {
|
|
|
10
10
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
14
|
var __export = (target, all) => {
|
|
14
15
|
for (var name in all)
|
|
15
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -23,10 +24,15 @@ var __exports__ = (() => {
|
|
|
23
24
|
return to;
|
|
24
25
|
};
|
|
25
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var __publicField = (obj, key, value) => {
|
|
28
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
26
31
|
|
|
27
32
|
// bundle.ts
|
|
28
33
|
var bundle_exports = {};
|
|
29
34
|
__export(bundle_exports, {
|
|
35
|
+
FetchError: () => FetchError,
|
|
30
36
|
JSONLoader: () => JSONLoader,
|
|
31
37
|
NullLoader: () => NullLoader,
|
|
32
38
|
NullWorkerLoader: () => NullWorkerLoader,
|
|
@@ -109,2171 +115,2236 @@ var __exports__ = (() => {
|
|
|
109
115
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
110
116
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
111
117
|
|
|
112
|
-
//
|
|
113
|
-
function
|
|
114
|
-
|
|
118
|
+
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
119
|
+
function _typeof(obj) {
|
|
120
|
+
"@babel/helpers - typeof";
|
|
121
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
122
|
+
return typeof obj2;
|
|
123
|
+
} : function(obj2) {
|
|
124
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
125
|
+
}, _typeof(obj);
|
|
115
126
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
);
|
|
128
|
-
} else {
|
|
129
|
-
options[key] = newOptions[key];
|
|
130
|
-
}
|
|
127
|
+
|
|
128
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
129
|
+
function _toPrimitive(input, hint) {
|
|
130
|
+
if (_typeof(input) !== "object" || input === null)
|
|
131
|
+
return input;
|
|
132
|
+
var prim = input[Symbol.toPrimitive];
|
|
133
|
+
if (prim !== void 0) {
|
|
134
|
+
var res = prim.call(input, hint || "default");
|
|
135
|
+
if (_typeof(res) !== "object")
|
|
136
|
+
return res;
|
|
137
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
131
138
|
}
|
|
132
|
-
return
|
|
139
|
+
return (hint === "string" ? String : Number)(input);
|
|
133
140
|
}
|
|
134
141
|
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
143
|
+
function _toPropertyKey(arg) {
|
|
144
|
+
var key = _toPrimitive(arg, "string");
|
|
145
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
149
|
+
function _defineProperty(obj, key, value) {
|
|
150
|
+
key = _toPropertyKey(key);
|
|
151
|
+
if (key in obj) {
|
|
152
|
+
Object.defineProperty(obj, key, {
|
|
153
|
+
value,
|
|
154
|
+
enumerable: true,
|
|
155
|
+
configurable: true,
|
|
156
|
+
writable: true
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
obj[key] = value;
|
|
148
160
|
}
|
|
149
|
-
return
|
|
161
|
+
return obj;
|
|
150
162
|
}
|
|
151
|
-
var VERSION = getVersion();
|
|
152
163
|
|
|
153
|
-
//
|
|
154
|
-
function
|
|
155
|
-
if (
|
|
156
|
-
|
|
164
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
165
|
+
function isElectron(mockUserAgent) {
|
|
166
|
+
if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
|
|
173
|
+
const userAgent = mockUserAgent || realUserAgent;
|
|
174
|
+
if (userAgent && userAgent.indexOf("Electron") >= 0) {
|
|
175
|
+
return true;
|
|
157
176
|
}
|
|
177
|
+
return false;
|
|
158
178
|
}
|
|
159
179
|
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
document: typeof document !== "undefined" && document
|
|
166
|
-
};
|
|
167
|
-
var self_2 = globals2.self || globals2.window || globals2.global || {};
|
|
168
|
-
var window_2 = globals2.window || globals2.self || globals2.global || {};
|
|
169
|
-
var global_2 = globals2.global || globals2.self || globals2.window || {};
|
|
170
|
-
var document_2 = globals2.document || {};
|
|
171
|
-
var isBrowser2 = (
|
|
172
|
-
// @ts-ignore process.browser
|
|
173
|
-
typeof process !== "object" || String(process) !== "[object process]" || process.browser
|
|
174
|
-
);
|
|
175
|
-
var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
|
|
176
|
-
var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
177
|
-
var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
|
|
180
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
181
|
+
function isBrowser2() {
|
|
182
|
+
const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
|
|
183
|
+
return !isNode || isElectron();
|
|
184
|
+
}
|
|
178
185
|
|
|
179
|
-
//
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
186
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
|
|
187
|
+
var self_2 = globalThis.self || globalThis.window || globalThis.global;
|
|
188
|
+
var window_2 = globalThis.window || globalThis.self || globalThis.global;
|
|
189
|
+
var document_2 = globalThis.document || {};
|
|
190
|
+
var process_ = globalThis.process || {};
|
|
191
|
+
var console_ = globalThis.console;
|
|
192
|
+
var navigator_ = globalThis.navigator || {};
|
|
193
|
+
|
|
194
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
|
|
195
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
|
|
196
|
+
var isBrowser3 = isBrowser2();
|
|
197
|
+
|
|
198
|
+
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
199
|
+
function getStorage(type) {
|
|
200
|
+
try {
|
|
201
|
+
const storage = window[type];
|
|
202
|
+
const x = "__storage_test__";
|
|
203
|
+
storage.setItem(x, x);
|
|
204
|
+
storage.removeItem(x);
|
|
205
|
+
return storage;
|
|
206
|
+
} catch (e) {
|
|
207
|
+
return null;
|
|
193
208
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
209
|
+
}
|
|
210
|
+
var LocalStorage = class {
|
|
211
|
+
constructor(id, defaultConfig) {
|
|
212
|
+
let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
|
|
213
|
+
_defineProperty(this, "storage", void 0);
|
|
214
|
+
_defineProperty(this, "id", void 0);
|
|
215
|
+
_defineProperty(this, "config", void 0);
|
|
216
|
+
this.storage = getStorage(type);
|
|
217
|
+
this.id = id;
|
|
218
|
+
this.config = defaultConfig;
|
|
219
|
+
this._loadConfiguration();
|
|
205
220
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
*/
|
|
209
|
-
done(value) {
|
|
210
|
-
assert2(this.isRunning);
|
|
211
|
-
this.isRunning = false;
|
|
212
|
-
this._resolve(value);
|
|
221
|
+
getConfiguration() {
|
|
222
|
+
return this.config;
|
|
213
223
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
this._reject(error);
|
|
224
|
+
setConfiguration(configuration) {
|
|
225
|
+
Object.assign(this.config, configuration);
|
|
226
|
+
if (this.storage) {
|
|
227
|
+
const serialized = JSON.stringify(this.config);
|
|
228
|
+
this.storage.setItem(this.id, serialized);
|
|
229
|
+
}
|
|
221
230
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
231
|
+
_loadConfiguration() {
|
|
232
|
+
let configuration = {};
|
|
233
|
+
if (this.storage) {
|
|
234
|
+
const serializedConfiguration = this.storage.getItem(this.id);
|
|
235
|
+
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
|
|
236
|
+
}
|
|
237
|
+
Object.assign(this.config, configuration);
|
|
238
|
+
return this;
|
|
227
239
|
}
|
|
228
240
|
};
|
|
229
241
|
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
workerURL = getLoadableWorkerURLFromSource(props.source);
|
|
242
|
-
workerURLCache.set(props.source, workerURL);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
assert2(workerURL);
|
|
246
|
-
return workerURL;
|
|
247
|
-
}
|
|
248
|
-
function getLoadableWorkerURLFromURL(url) {
|
|
249
|
-
if (!url.startsWith("http")) {
|
|
250
|
-
return url;
|
|
242
|
+
// ../../node_modules/@probe.gl/log/dist/utils/formatters.js
|
|
243
|
+
function formatTime(ms) {
|
|
244
|
+
let formatted;
|
|
245
|
+
if (ms < 10) {
|
|
246
|
+
formatted = "".concat(ms.toFixed(2), "ms");
|
|
247
|
+
} else if (ms < 100) {
|
|
248
|
+
formatted = "".concat(ms.toFixed(1), "ms");
|
|
249
|
+
} else if (ms < 1e3) {
|
|
250
|
+
formatted = "".concat(ms.toFixed(0), "ms");
|
|
251
|
+
} else {
|
|
252
|
+
formatted = "".concat((ms / 1e3).toFixed(2), "s");
|
|
251
253
|
}
|
|
252
|
-
|
|
253
|
-
return getLoadableWorkerURLFromSource(workerSource);
|
|
254
|
+
return formatted;
|
|
254
255
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
function leftPad(string) {
|
|
257
|
+
let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
|
|
258
|
+
const padLength = Math.max(length - string.length, 0);
|
|
259
|
+
return "".concat(" ".repeat(padLength)).concat(string);
|
|
258
260
|
}
|
|
259
|
-
function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
function formatImage(image, message, scale) {
|
|
262
|
+
let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
|
|
263
|
+
const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
|
|
264
|
+
if (image.width > maxWidth) {
|
|
265
|
+
scale = Math.min(scale, maxWidth / image.width);
|
|
266
|
+
}
|
|
267
|
+
const width = image.width * scale;
|
|
268
|
+
const height = image.height * scale;
|
|
269
|
+
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("");
|
|
270
|
+
return ["".concat(message, " %c+"), style];
|
|
266
271
|
}
|
|
267
272
|
|
|
268
|
-
//
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
273
|
+
// ../../node_modules/@probe.gl/log/dist/utils/color.js
|
|
274
|
+
var COLOR;
|
|
275
|
+
(function(COLOR2) {
|
|
276
|
+
COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
|
|
277
|
+
COLOR2[COLOR2["RED"] = 31] = "RED";
|
|
278
|
+
COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
|
|
279
|
+
COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
|
|
280
|
+
COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
|
|
281
|
+
COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
|
|
282
|
+
COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
|
|
283
|
+
COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
|
|
284
|
+
COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
|
|
285
|
+
COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
|
|
286
|
+
COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
|
|
287
|
+
COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
|
|
288
|
+
COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
|
|
289
|
+
COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
|
|
290
|
+
COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
|
|
291
|
+
COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
|
|
292
|
+
})(COLOR || (COLOR = {}));
|
|
293
|
+
var BACKGROUND_INCREMENT = 10;
|
|
294
|
+
function getColor(color) {
|
|
295
|
+
if (typeof color !== "string") {
|
|
296
|
+
return color;
|
|
281
297
|
}
|
|
282
|
-
|
|
298
|
+
color = color.toUpperCase();
|
|
299
|
+
return COLOR[color] || COLOR.WHITE;
|
|
283
300
|
}
|
|
284
|
-
function
|
|
285
|
-
if (!
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
301
|
+
function addColor(string, color, background) {
|
|
302
|
+
if (!isBrowser2 && typeof string === "string") {
|
|
303
|
+
if (color) {
|
|
304
|
+
const colorCode = getColor(color);
|
|
305
|
+
string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
|
|
306
|
+
}
|
|
307
|
+
if (background) {
|
|
308
|
+
const colorCode = getColor(background);
|
|
309
|
+
string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
|
|
310
|
+
}
|
|
293
311
|
}
|
|
294
|
-
|
|
295
|
-
|
|
312
|
+
return string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// ../../node_modules/@probe.gl/log/dist/utils/autobind.js
|
|
316
|
+
function autobind(obj) {
|
|
317
|
+
let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
|
|
318
|
+
const proto = Object.getPrototypeOf(obj);
|
|
319
|
+
const propNames = Object.getOwnPropertyNames(proto);
|
|
320
|
+
const object = obj;
|
|
321
|
+
for (const key of propNames) {
|
|
322
|
+
const value = object[key];
|
|
323
|
+
if (typeof value === "function") {
|
|
324
|
+
if (!predefined.find((name) => key === name)) {
|
|
325
|
+
object[key] = value.bind(obj);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
296
328
|
}
|
|
297
|
-
|
|
298
|
-
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// ../../node_modules/@probe.gl/log/dist/utils/assert.js
|
|
332
|
+
function assert2(condition, message) {
|
|
333
|
+
if (!condition) {
|
|
334
|
+
throw new Error(message || "Assertion failed");
|
|
299
335
|
}
|
|
300
|
-
return false;
|
|
301
336
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
337
|
+
|
|
338
|
+
// ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
|
|
339
|
+
function getHiResTimestamp() {
|
|
340
|
+
let timestamp;
|
|
341
|
+
if (isBrowser2() && window_2.performance) {
|
|
342
|
+
var _window$performance, _window$performance$n;
|
|
343
|
+
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);
|
|
344
|
+
} else if ("hrtime" in process_) {
|
|
345
|
+
var _process$hrtime;
|
|
346
|
+
const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
|
|
347
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
348
|
+
} else {
|
|
349
|
+
timestamp = Date.now();
|
|
305
350
|
}
|
|
306
|
-
|
|
307
|
-
Object.keys(clone).forEach((key) => {
|
|
308
|
-
if (typeof object[key] === "object" && !ArrayBuffer.isView(object[key]) && !(object[key] instanceof Array)) {
|
|
309
|
-
clone[key] = getTransferListForWriter(object[key]);
|
|
310
|
-
} else if (typeof clone[key] === "function" || clone[key] instanceof RegExp) {
|
|
311
|
-
clone[key] = {};
|
|
312
|
-
} else {
|
|
313
|
-
clone[key] = object[key];
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
return clone;
|
|
351
|
+
return timestamp;
|
|
317
352
|
}
|
|
318
353
|
|
|
319
|
-
//
|
|
320
|
-
var
|
|
354
|
+
// ../../node_modules/@probe.gl/log/dist/log.js
|
|
355
|
+
var originalConsole = {
|
|
356
|
+
debug: isBrowser2() ? console.debug || console.log : console.log,
|
|
357
|
+
log: console.log,
|
|
358
|
+
info: console.info,
|
|
359
|
+
warn: console.warn,
|
|
360
|
+
error: console.error
|
|
321
361
|
};
|
|
322
|
-
var
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
362
|
+
var DEFAULT_LOG_CONFIGURATION = {
|
|
363
|
+
enabled: true,
|
|
364
|
+
level: 0
|
|
365
|
+
};
|
|
366
|
+
function noop() {
|
|
367
|
+
}
|
|
368
|
+
var cache = {};
|
|
369
|
+
var ONCE = {
|
|
370
|
+
once: true
|
|
371
|
+
};
|
|
372
|
+
var Log = class {
|
|
373
|
+
constructor() {
|
|
374
|
+
let {
|
|
375
|
+
id
|
|
376
|
+
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
377
|
+
id: ""
|
|
378
|
+
};
|
|
379
|
+
_defineProperty(this, "id", void 0);
|
|
380
|
+
_defineProperty(this, "VERSION", VERSION);
|
|
381
|
+
_defineProperty(this, "_startTs", getHiResTimestamp());
|
|
382
|
+
_defineProperty(this, "_deltaTs", getHiResTimestamp());
|
|
383
|
+
_defineProperty(this, "_storage", void 0);
|
|
384
|
+
_defineProperty(this, "userData", {});
|
|
385
|
+
_defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
|
|
386
|
+
this.id = id;
|
|
387
|
+
this.userData = {};
|
|
388
|
+
this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
|
|
389
|
+
this.timeStamp("".concat(this.id, " started"));
|
|
390
|
+
autobind(this);
|
|
391
|
+
Object.seal(this);
|
|
334
392
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
return typeof Worker !== "undefined" && isBrowser2 || typeof NodeWorker !== "undefined" && !isBrowser2;
|
|
393
|
+
set level(newLevel) {
|
|
394
|
+
this.setLevel(newLevel);
|
|
338
395
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
* @note Can free up significant memory
|
|
342
|
-
*/
|
|
343
|
-
destroy() {
|
|
344
|
-
this.onMessage = NOOP;
|
|
345
|
-
this.onError = NOOP;
|
|
346
|
-
this.worker.terminate();
|
|
347
|
-
this.terminated = true;
|
|
396
|
+
get level() {
|
|
397
|
+
return this.getLevel();
|
|
348
398
|
}
|
|
349
|
-
|
|
350
|
-
return
|
|
399
|
+
isEnabled() {
|
|
400
|
+
return this._storage.config.enabled;
|
|
351
401
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
* @param data any data structure, ideally consisting mostly of transferrable objects
|
|
355
|
-
* @param transferList If not supplied, calculated automatically by traversing data
|
|
356
|
-
*/
|
|
357
|
-
postMessage(data, transferList) {
|
|
358
|
-
transferList = transferList || getTransferList(data);
|
|
359
|
-
this.worker.postMessage(data, transferList);
|
|
402
|
+
getLevel() {
|
|
403
|
+
return this._storage.config.level;
|
|
360
404
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
* Generate a standard Error from an ErrorEvent
|
|
364
|
-
* @param event
|
|
365
|
-
*/
|
|
366
|
-
_getErrorFromErrorEvent(event) {
|
|
367
|
-
let message = "Failed to load ";
|
|
368
|
-
message += `worker ${this.name} from ${this.url}. `;
|
|
369
|
-
if (event.message) {
|
|
370
|
-
message += `${event.message} in `;
|
|
371
|
-
}
|
|
372
|
-
if (event.lineno) {
|
|
373
|
-
message += `:${event.lineno}:${event.colno}`;
|
|
374
|
-
}
|
|
375
|
-
return new Error(message);
|
|
405
|
+
getTotal() {
|
|
406
|
+
return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
|
|
376
407
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
*/
|
|
380
|
-
_createBrowserWorker() {
|
|
381
|
-
this._loadableURL = getLoadableWorkerURL({ source: this.source, url: this.url });
|
|
382
|
-
const worker = new Worker(this._loadableURL, { name: this.name });
|
|
383
|
-
worker.onmessage = (event) => {
|
|
384
|
-
if (!event.data) {
|
|
385
|
-
this.onError(new Error("No data received"));
|
|
386
|
-
} else {
|
|
387
|
-
this.onMessage(event.data);
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
worker.onerror = (error) => {
|
|
391
|
-
this.onError(this._getErrorFromErrorEvent(error));
|
|
392
|
-
this.terminated = true;
|
|
393
|
-
};
|
|
394
|
-
worker.onmessageerror = (event) => console.error(event);
|
|
395
|
-
return worker;
|
|
408
|
+
getDelta() {
|
|
409
|
+
return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
|
|
396
410
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
throw new Error("no worker");
|
|
411
|
-
}
|
|
412
|
-
worker.on("message", (data) => {
|
|
413
|
-
this.onMessage(data);
|
|
414
|
-
});
|
|
415
|
-
worker.on("error", (error) => {
|
|
416
|
-
this.onError(error);
|
|
411
|
+
set priority(newPriority) {
|
|
412
|
+
this.level = newPriority;
|
|
413
|
+
}
|
|
414
|
+
get priority() {
|
|
415
|
+
return this.level;
|
|
416
|
+
}
|
|
417
|
+
getPriority() {
|
|
418
|
+
return this.level;
|
|
419
|
+
}
|
|
420
|
+
enable() {
|
|
421
|
+
let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
422
|
+
this._storage.setConfiguration({
|
|
423
|
+
enabled
|
|
417
424
|
});
|
|
418
|
-
|
|
425
|
+
return this;
|
|
426
|
+
}
|
|
427
|
+
setLevel(level) {
|
|
428
|
+
this._storage.setConfiguration({
|
|
429
|
+
level
|
|
419
430
|
});
|
|
420
|
-
return
|
|
431
|
+
return this;
|
|
421
432
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
// ../worker-utils/src/lib/worker-farm/worker-pool.ts
|
|
425
|
-
var WorkerPool = class {
|
|
426
|
-
/**
|
|
427
|
-
* @param processor - worker function
|
|
428
|
-
* @param maxConcurrency - max count of workers
|
|
429
|
-
*/
|
|
430
|
-
constructor(props) {
|
|
431
|
-
this.name = "unnamed";
|
|
432
|
-
this.maxConcurrency = 1;
|
|
433
|
-
this.maxMobileConcurrency = 1;
|
|
434
|
-
this.onDebug = () => {
|
|
435
|
-
};
|
|
436
|
-
this.reuseWorkers = true;
|
|
437
|
-
this.props = {};
|
|
438
|
-
this.jobQueue = [];
|
|
439
|
-
this.idleQueue = [];
|
|
440
|
-
this.count = 0;
|
|
441
|
-
this.isDestroyed = false;
|
|
442
|
-
this.source = props.source;
|
|
443
|
-
this.url = props.url;
|
|
444
|
-
this.setProps(props);
|
|
445
|
-
}
|
|
446
|
-
/** Checks if workers are supported on this platform */
|
|
447
|
-
static isSupported() {
|
|
448
|
-
return WorkerThread.isSupported();
|
|
433
|
+
get(setting) {
|
|
434
|
+
return this._storage.config[setting];
|
|
449
435
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
destroy() {
|
|
455
|
-
this.idleQueue.forEach((worker) => worker.destroy());
|
|
456
|
-
this.isDestroyed = true;
|
|
436
|
+
set(setting, value) {
|
|
437
|
+
this._storage.setConfiguration({
|
|
438
|
+
[setting]: value
|
|
439
|
+
});
|
|
457
440
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
if (props.maxConcurrency !== void 0) {
|
|
464
|
-
this.maxConcurrency = props.maxConcurrency;
|
|
465
|
-
}
|
|
466
|
-
if (props.maxMobileConcurrency !== void 0) {
|
|
467
|
-
this.maxMobileConcurrency = props.maxMobileConcurrency;
|
|
468
|
-
}
|
|
469
|
-
if (props.reuseWorkers !== void 0) {
|
|
470
|
-
this.reuseWorkers = props.reuseWorkers;
|
|
471
|
-
}
|
|
472
|
-
if (props.onDebug !== void 0) {
|
|
473
|
-
this.onDebug = props.onDebug;
|
|
441
|
+
settings() {
|
|
442
|
+
if (console.table) {
|
|
443
|
+
console.table(this._storage.config);
|
|
444
|
+
} else {
|
|
445
|
+
console.log(this._storage.config);
|
|
474
446
|
}
|
|
475
447
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
448
|
+
assert(condition, message) {
|
|
449
|
+
assert2(condition, message);
|
|
450
|
+
}
|
|
451
|
+
warn(message) {
|
|
452
|
+
return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
|
|
453
|
+
}
|
|
454
|
+
error(message) {
|
|
455
|
+
return this._getLogFunction(0, message, originalConsole.error, arguments);
|
|
456
|
+
}
|
|
457
|
+
deprecated(oldUsage, newUsage) {
|
|
458
|
+
return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
|
|
459
|
+
}
|
|
460
|
+
removed(oldUsage, newUsage) {
|
|
461
|
+
return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
|
|
462
|
+
}
|
|
463
|
+
probe(logLevel, message) {
|
|
464
|
+
return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
|
|
465
|
+
time: true,
|
|
466
|
+
once: true
|
|
480
467
|
});
|
|
481
|
-
this._startQueuedJob();
|
|
482
|
-
return await startPromise;
|
|
483
468
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (
|
|
495
|
-
return
|
|
496
|
-
|
|
497
|
-
const queuedJob = this.jobQueue.shift();
|
|
498
|
-
if (queuedJob) {
|
|
499
|
-
this.onDebug({
|
|
500
|
-
message: "Starting job",
|
|
501
|
-
name: queuedJob.name,
|
|
502
|
-
workerThread,
|
|
503
|
-
backlog: this.jobQueue.length
|
|
469
|
+
log(logLevel, message) {
|
|
470
|
+
return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
|
|
471
|
+
}
|
|
472
|
+
info(logLevel, message) {
|
|
473
|
+
return this._getLogFunction(logLevel, message, console.info, arguments);
|
|
474
|
+
}
|
|
475
|
+
once(logLevel, message) {
|
|
476
|
+
return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
|
|
477
|
+
}
|
|
478
|
+
table(logLevel, table, columns) {
|
|
479
|
+
if (table) {
|
|
480
|
+
return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
|
|
481
|
+
tag: getTableHeader(table)
|
|
504
482
|
});
|
|
505
|
-
const job = new WorkerJob(queuedJob.name, workerThread);
|
|
506
|
-
workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
|
|
507
|
-
workerThread.onError = (error) => queuedJob.onError(job, error);
|
|
508
|
-
queuedJob.onStart(job);
|
|
509
|
-
try {
|
|
510
|
-
await job.result;
|
|
511
|
-
} catch (error) {
|
|
512
|
-
console.error(`Worker exception: ${error}`);
|
|
513
|
-
} finally {
|
|
514
|
-
this.returnWorkerToQueue(workerThread);
|
|
515
|
-
}
|
|
516
483
|
}
|
|
484
|
+
return noop;
|
|
517
485
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
// Workers on Node.js prevent the process from exiting.
|
|
529
|
-
// Until we figure out how to close them before exit, we always destroy them
|
|
530
|
-
!isBrowser2 || // If the pool is destroyed, there is no reason to keep the worker around
|
|
531
|
-
this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
|
|
532
|
-
!this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
|
|
533
|
-
this.count > this._getMaxConcurrency()
|
|
534
|
-
);
|
|
535
|
-
if (shouldDestroyWorker) {
|
|
536
|
-
worker.destroy();
|
|
537
|
-
this.count--;
|
|
538
|
-
} else {
|
|
539
|
-
this.idleQueue.push(worker);
|
|
540
|
-
}
|
|
541
|
-
if (!this.isDestroyed) {
|
|
542
|
-
this._startQueuedJob();
|
|
486
|
+
image(_ref) {
|
|
487
|
+
let {
|
|
488
|
+
logLevel,
|
|
489
|
+
priority,
|
|
490
|
+
image,
|
|
491
|
+
message = "",
|
|
492
|
+
scale = 1
|
|
493
|
+
} = _ref;
|
|
494
|
+
if (!this._shouldLog(logLevel || priority)) {
|
|
495
|
+
return noop;
|
|
543
496
|
}
|
|
497
|
+
return isBrowser2() ? logImageInBrowser({
|
|
498
|
+
image,
|
|
499
|
+
message,
|
|
500
|
+
scale
|
|
501
|
+
}) : logImageInNode({
|
|
502
|
+
image,
|
|
503
|
+
message,
|
|
504
|
+
scale
|
|
505
|
+
});
|
|
544
506
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
*/
|
|
548
|
-
_getAvailableWorker() {
|
|
549
|
-
if (this.idleQueue.length > 0) {
|
|
550
|
-
return this.idleQueue.shift() || null;
|
|
551
|
-
}
|
|
552
|
-
if (this.count < this._getMaxConcurrency()) {
|
|
553
|
-
this.count++;
|
|
554
|
-
const name = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
|
|
555
|
-
return new WorkerThread({ name, source: this.source, url: this.url });
|
|
556
|
-
}
|
|
557
|
-
return null;
|
|
507
|
+
time(logLevel, message) {
|
|
508
|
+
return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
|
|
558
509
|
}
|
|
559
|
-
|
|
560
|
-
return
|
|
510
|
+
timeEnd(logLevel, message) {
|
|
511
|
+
return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
|
|
561
512
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
// ../worker-utils/src/lib/worker-farm/worker-farm.ts
|
|
565
|
-
var DEFAULT_PROPS = {
|
|
566
|
-
maxConcurrency: 3,
|
|
567
|
-
maxMobileConcurrency: 1,
|
|
568
|
-
reuseWorkers: true,
|
|
569
|
-
onDebug: () => {
|
|
513
|
+
timeStamp(logLevel, message) {
|
|
514
|
+
return this._getLogFunction(logLevel, message, console.timeStamp || noop);
|
|
570
515
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
516
|
+
group(logLevel, message) {
|
|
517
|
+
let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
|
|
518
|
+
collapsed: false
|
|
519
|
+
};
|
|
520
|
+
const options = normalizeArguments({
|
|
521
|
+
logLevel,
|
|
522
|
+
message,
|
|
523
|
+
opts
|
|
524
|
+
});
|
|
525
|
+
const {
|
|
526
|
+
collapsed
|
|
527
|
+
} = opts;
|
|
528
|
+
options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
|
|
529
|
+
return this._getLogFunction(options);
|
|
579
530
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
return
|
|
531
|
+
groupCollapsed(logLevel, message) {
|
|
532
|
+
let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
533
|
+
return this.group(logLevel, message, Object.assign({}, opts, {
|
|
534
|
+
collapsed: true
|
|
535
|
+
}));
|
|
583
536
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({});
|
|
587
|
-
WorkerFarm._workerFarm.setProps(props);
|
|
588
|
-
return WorkerFarm._workerFarm;
|
|
537
|
+
groupEnd(logLevel) {
|
|
538
|
+
return this._getLogFunction(logLevel, "", console.groupEnd || noop);
|
|
589
539
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
workerPool.destroy();
|
|
540
|
+
withGroup(logLevel, message, func) {
|
|
541
|
+
this.group(logLevel, message)();
|
|
542
|
+
try {
|
|
543
|
+
func();
|
|
544
|
+
} finally {
|
|
545
|
+
this.groupEnd(logLevel)();
|
|
597
546
|
}
|
|
598
|
-
this.workerPools = /* @__PURE__ */ new Map();
|
|
599
547
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
*/
|
|
604
|
-
setProps(props) {
|
|
605
|
-
this.props = { ...this.props, ...props };
|
|
606
|
-
for (const workerPool of this.workerPools.values()) {
|
|
607
|
-
workerPool.setProps(this._getWorkerPoolProps());
|
|
548
|
+
trace() {
|
|
549
|
+
if (console.trace) {
|
|
550
|
+
console.trace();
|
|
608
551
|
}
|
|
609
552
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
const { name, source, url } = options;
|
|
621
|
-
let workerPool = this.workerPools.get(name);
|
|
622
|
-
if (!workerPool) {
|
|
623
|
-
workerPool = new WorkerPool({
|
|
624
|
-
name,
|
|
625
|
-
source,
|
|
626
|
-
url
|
|
553
|
+
_shouldLog(logLevel) {
|
|
554
|
+
return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
|
|
555
|
+
}
|
|
556
|
+
_getLogFunction(logLevel, message, method, args, opts) {
|
|
557
|
+
if (this._shouldLog(logLevel)) {
|
|
558
|
+
opts = normalizeArguments({
|
|
559
|
+
logLevel,
|
|
560
|
+
message,
|
|
561
|
+
args,
|
|
562
|
+
opts
|
|
627
563
|
});
|
|
628
|
-
|
|
629
|
-
|
|
564
|
+
method = method || opts.method;
|
|
565
|
+
assert2(method);
|
|
566
|
+
opts.total = this.getTotal();
|
|
567
|
+
opts.delta = this.getDelta();
|
|
568
|
+
this._deltaTs = getHiResTimestamp();
|
|
569
|
+
const tag = opts.tag || opts.message;
|
|
570
|
+
if (opts.once && tag) {
|
|
571
|
+
if (!cache[tag]) {
|
|
572
|
+
cache[tag] = getHiResTimestamp();
|
|
573
|
+
} else {
|
|
574
|
+
return noop;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
message = decorateMessage(this.id, opts.message, opts);
|
|
578
|
+
return method.bind(console, message, ...opts.args);
|
|
630
579
|
}
|
|
631
|
-
return
|
|
632
|
-
}
|
|
633
|
-
_getWorkerPoolProps() {
|
|
634
|
-
return {
|
|
635
|
-
maxConcurrency: this.props.maxConcurrency,
|
|
636
|
-
maxMobileConcurrency: this.props.maxMobileConcurrency,
|
|
637
|
-
reuseWorkers: this.props.reuseWorkers,
|
|
638
|
-
onDebug: this.props.onDebug
|
|
639
|
-
};
|
|
580
|
+
return noop;
|
|
640
581
|
}
|
|
641
582
|
};
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
return `${worker.name}@${worker.version}${warning}`;
|
|
647
|
-
}
|
|
648
|
-
function getWorkerURL(worker, options = {}) {
|
|
649
|
-
const workerOptions = options[worker.id] || {};
|
|
650
|
-
const workerFile = isBrowser2 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
|
|
651
|
-
let url = workerOptions.workerUrl;
|
|
652
|
-
if (!url && worker.id === "compression") {
|
|
653
|
-
url = options.workerUrl;
|
|
654
|
-
}
|
|
655
|
-
if (options._workerType === "test") {
|
|
656
|
-
if (isBrowser2) {
|
|
657
|
-
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
658
|
-
} else {
|
|
659
|
-
url = `modules/${worker.module}/src/workers/${worker.id}-worker-node.ts`;
|
|
660
|
-
}
|
|
583
|
+
_defineProperty(Log, "VERSION", VERSION);
|
|
584
|
+
function normalizeLogLevel(logLevel) {
|
|
585
|
+
if (!logLevel) {
|
|
586
|
+
return 0;
|
|
661
587
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
588
|
+
let resolvedLevel;
|
|
589
|
+
switch (typeof logLevel) {
|
|
590
|
+
case "number":
|
|
591
|
+
resolvedLevel = logLevel;
|
|
592
|
+
break;
|
|
593
|
+
case "object":
|
|
594
|
+
resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
|
|
595
|
+
break;
|
|
596
|
+
default:
|
|
597
|
+
return 0;
|
|
669
598
|
}
|
|
670
|
-
assert2(
|
|
671
|
-
return
|
|
599
|
+
assert2(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
600
|
+
return resolvedLevel;
|
|
672
601
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
workerPoolProps.url = getWorkerURL(worker, options);
|
|
602
|
+
function normalizeArguments(opts) {
|
|
603
|
+
const {
|
|
604
|
+
logLevel,
|
|
605
|
+
message
|
|
606
|
+
} = opts;
|
|
607
|
+
opts.logLevel = normalizeLogLevel(logLevel);
|
|
608
|
+
const args = opts.args ? Array.from(opts.args) : [];
|
|
609
|
+
while (args.length && args.shift() !== message) {
|
|
682
610
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
onMessage.bind(null, context)
|
|
689
|
-
);
|
|
690
|
-
const transferableOptions = getTransferListForWriter(options);
|
|
691
|
-
job.postMessage("process", { input: data, options: transferableOptions });
|
|
692
|
-
const result = await job.result;
|
|
693
|
-
return result.result;
|
|
694
|
-
}
|
|
695
|
-
async function onMessage(context, job, type, payload) {
|
|
696
|
-
switch (type) {
|
|
697
|
-
case "done":
|
|
698
|
-
job.done(payload);
|
|
699
|
-
break;
|
|
700
|
-
case "error":
|
|
701
|
-
job.error(new Error(payload.error));
|
|
702
|
-
break;
|
|
703
|
-
case "process":
|
|
704
|
-
const { id, input, options } = payload;
|
|
705
|
-
try {
|
|
706
|
-
if (!context.process) {
|
|
707
|
-
job.postMessage("error", { id, error: "Worker not set up to process on main thread" });
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
const result = await context.process(input, options);
|
|
711
|
-
job.postMessage("done", { id, result });
|
|
712
|
-
} catch (error) {
|
|
713
|
-
const message = error instanceof Error ? error.message : "unknown error";
|
|
714
|
-
job.postMessage("error", { id, error: message });
|
|
611
|
+
switch (typeof logLevel) {
|
|
612
|
+
case "string":
|
|
613
|
+
case "function":
|
|
614
|
+
if (message !== void 0) {
|
|
615
|
+
args.unshift(message);
|
|
715
616
|
}
|
|
617
|
+
opts.message = logLevel;
|
|
618
|
+
break;
|
|
619
|
+
case "object":
|
|
620
|
+
Object.assign(opts, logLevel);
|
|
716
621
|
break;
|
|
717
622
|
default:
|
|
718
|
-
console.warn(`process-on-worker: unknown message ${type}`);
|
|
719
623
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
// ../worker-utils/src/lib/worker-api/validate-worker-version.ts
|
|
723
|
-
function validateWorkerVersion(worker, coreVersion = VERSION) {
|
|
724
|
-
assert2(worker, "no worker provided");
|
|
725
|
-
const workerVersion = worker.version;
|
|
726
|
-
if (!coreVersion || !workerVersion) {
|
|
727
|
-
return false;
|
|
624
|
+
if (typeof opts.message === "function") {
|
|
625
|
+
opts.message = opts.message();
|
|
728
626
|
}
|
|
729
|
-
|
|
627
|
+
const messageType = typeof opts.message;
|
|
628
|
+
assert2(messageType === "string" || messageType === "object");
|
|
629
|
+
return Object.assign(opts, {
|
|
630
|
+
args
|
|
631
|
+
}, opts.opts);
|
|
730
632
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
}
|
|
737
|
-
if (!isBrowser2 && !options?._nodeWorkers) {
|
|
738
|
-
return false;
|
|
633
|
+
function decorateMessage(id, message, opts) {
|
|
634
|
+
if (typeof message === "string") {
|
|
635
|
+
const time = opts.time ? leftPad(formatTime(opts.total)) : "";
|
|
636
|
+
message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
|
|
637
|
+
message = addColor(message, opts.color, opts.background);
|
|
739
638
|
}
|
|
740
|
-
return
|
|
639
|
+
return message;
|
|
741
640
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
"process-on-worker",
|
|
751
|
-
// @ts-expect-error
|
|
752
|
-
onMessage2.bind(null, parseOnMainThread)
|
|
753
|
-
// eslint-disable-line @typescript-eslint/no-misused-promises
|
|
754
|
-
);
|
|
755
|
-
job.postMessage("process", {
|
|
756
|
-
// @ts-ignore
|
|
757
|
-
input: data,
|
|
758
|
-
options,
|
|
759
|
-
context
|
|
760
|
-
});
|
|
761
|
-
const result = await job.result;
|
|
762
|
-
return await result.result;
|
|
641
|
+
function logImageInNode(_ref2) {
|
|
642
|
+
let {
|
|
643
|
+
image,
|
|
644
|
+
message = "",
|
|
645
|
+
scale = 1
|
|
646
|
+
} = _ref2;
|
|
647
|
+
console.warn("removed");
|
|
648
|
+
return noop;
|
|
763
649
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
const message = error instanceof Error ? error.message : "unknown error";
|
|
779
|
-
job.postMessage("error", { id, error: message });
|
|
780
|
-
}
|
|
781
|
-
break;
|
|
782
|
-
default:
|
|
783
|
-
console.warn(`parse-with-worker unknown message ${type}`);
|
|
650
|
+
function logImageInBrowser(_ref3) {
|
|
651
|
+
let {
|
|
652
|
+
image,
|
|
653
|
+
message = "",
|
|
654
|
+
scale = 1
|
|
655
|
+
} = _ref3;
|
|
656
|
+
if (typeof image === "string") {
|
|
657
|
+
const img = new Image();
|
|
658
|
+
img.onload = () => {
|
|
659
|
+
const args = formatImage(img, message, scale);
|
|
660
|
+
console.log(...args);
|
|
661
|
+
};
|
|
662
|
+
img.src = image;
|
|
663
|
+
return noop;
|
|
784
664
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
if (!WorkerFarm.isSupported()) {
|
|
790
|
-
return false;
|
|
665
|
+
const element = image.nodeName || "";
|
|
666
|
+
if (element.toLowerCase() === "img") {
|
|
667
|
+
console.log(...formatImage(image, message, scale));
|
|
668
|
+
return noop;
|
|
791
669
|
}
|
|
792
|
-
if (
|
|
793
|
-
|
|
670
|
+
if (element.toLowerCase() === "canvas") {
|
|
671
|
+
const img = new Image();
|
|
672
|
+
img.onload = () => console.log(...formatImage(img, message, scale));
|
|
673
|
+
img.src = image.toDataURL();
|
|
674
|
+
return noop;
|
|
794
675
|
}
|
|
795
|
-
return
|
|
676
|
+
return noop;
|
|
677
|
+
}
|
|
678
|
+
function getTableHeader(table) {
|
|
679
|
+
for (const key in table) {
|
|
680
|
+
for (const title in table[key]) {
|
|
681
|
+
return title || "untitled";
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
return "empty";
|
|
796
685
|
}
|
|
797
686
|
|
|
798
|
-
//
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
687
|
+
// ../../node_modules/@probe.gl/log/dist/index.js
|
|
688
|
+
var dist_default = new Log({
|
|
689
|
+
id: "@probe.gl/log"
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
// ../loader-utils/src/lib/option-utils/merge-loader-options.ts
|
|
693
|
+
function mergeLoaderOptions(baseOptions, newOptions) {
|
|
694
|
+
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
695
|
+
}
|
|
696
|
+
function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
697
|
+
if (level > 3) {
|
|
698
|
+
return newOptions;
|
|
803
699
|
}
|
|
804
|
-
const
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
700
|
+
const options = { ...baseOptions };
|
|
701
|
+
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
702
|
+
if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
|
|
703
|
+
options[key] = mergeOptionsRecursively(
|
|
704
|
+
options[key] || {},
|
|
705
|
+
newOptions[key],
|
|
706
|
+
level + 1
|
|
707
|
+
);
|
|
708
|
+
} else {
|
|
709
|
+
options[key] = newOptions[key];
|
|
809
710
|
}
|
|
810
711
|
}
|
|
811
|
-
return
|
|
712
|
+
return options;
|
|
812
713
|
}
|
|
813
|
-
|
|
814
|
-
|
|
714
|
+
|
|
715
|
+
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
716
|
+
function registerJSModules(modules) {
|
|
717
|
+
globalThis.loaders ||= {};
|
|
718
|
+
globalThis.loaders.modules ||= {};
|
|
719
|
+
Object.assign(globalThis.loaders.modules, modules);
|
|
815
720
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
721
|
+
|
|
722
|
+
// ../worker-utils/src/lib/env-utils/version.ts
|
|
723
|
+
var NPM_TAG = "latest";
|
|
724
|
+
function getVersion() {
|
|
725
|
+
if (!globalThis._loadersgl_?.version) {
|
|
726
|
+
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
727
|
+
if (typeof __VERSION__ === "undefined") {
|
|
728
|
+
console.warn(
|
|
729
|
+
"loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
|
|
730
|
+
);
|
|
731
|
+
globalThis._loadersgl_.version = NPM_TAG;
|
|
732
|
+
} else {
|
|
733
|
+
globalThis._loadersgl_.version = __VERSION__;
|
|
734
|
+
}
|
|
826
735
|
}
|
|
827
|
-
return
|
|
736
|
+
return globalThis._loadersgl_.version;
|
|
828
737
|
}
|
|
738
|
+
var VERSION2 = getVersion();
|
|
829
739
|
|
|
830
|
-
// ../
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, { stream: true });
|
|
740
|
+
// ../worker-utils/src/lib/env-utils/assert.ts
|
|
741
|
+
function assert3(condition, message) {
|
|
742
|
+
if (!condition) {
|
|
743
|
+
throw new Error(message || "loaders.gl assertion failed.");
|
|
835
744
|
}
|
|
836
745
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
746
|
+
|
|
747
|
+
// ../worker-utils/src/lib/env-utils/globals.ts
|
|
748
|
+
var globals2 = {
|
|
749
|
+
self: typeof self !== "undefined" && self,
|
|
750
|
+
window: typeof window !== "undefined" && window,
|
|
751
|
+
global: typeof global !== "undefined" && global,
|
|
752
|
+
document: typeof document !== "undefined" && document
|
|
753
|
+
};
|
|
754
|
+
var self_3 = globals2.self || globals2.window || globals2.global || {};
|
|
755
|
+
var window_3 = globals2.window || globals2.self || globals2.global || {};
|
|
756
|
+
var global_3 = globals2.global || globals2.self || globals2.window || {};
|
|
757
|
+
var document_3 = globals2.document || {};
|
|
758
|
+
var isBrowser4 = (
|
|
759
|
+
// @ts-ignore process.browser
|
|
760
|
+
typeof process !== "object" || String(process) !== "[object process]" || process.browser
|
|
761
|
+
);
|
|
762
|
+
var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
|
|
763
|
+
var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
764
|
+
var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
|
|
765
|
+
|
|
766
|
+
// ../worker-utils/src/lib/worker-farm/worker-job.ts
|
|
767
|
+
var WorkerJob = class {
|
|
768
|
+
name;
|
|
769
|
+
workerThread;
|
|
770
|
+
isRunning = true;
|
|
771
|
+
/** Promise that resolves when Job is done */
|
|
772
|
+
result;
|
|
773
|
+
_resolve = () => {
|
|
774
|
+
};
|
|
775
|
+
_reject = () => {
|
|
776
|
+
};
|
|
777
|
+
constructor(jobName, workerThread) {
|
|
778
|
+
this.name = jobName;
|
|
779
|
+
this.workerThread = workerThread;
|
|
780
|
+
this.result = new Promise((resolve2, reject) => {
|
|
781
|
+
this._resolve = resolve2;
|
|
782
|
+
this._reject = reject;
|
|
783
|
+
});
|
|
841
784
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
}
|
|
785
|
+
/**
|
|
786
|
+
* Send a message to the job's worker thread
|
|
787
|
+
* @param data any data structure, ideally consisting mostly of transferrable objects
|
|
788
|
+
*/
|
|
789
|
+
postMessage(type, payload) {
|
|
790
|
+
this.workerThread.postMessage({
|
|
791
|
+
source: "loaders.gl",
|
|
792
|
+
// Lets worker ignore unrelated messages
|
|
793
|
+
type,
|
|
794
|
+
payload
|
|
795
|
+
});
|
|
853
796
|
}
|
|
854
|
-
|
|
855
|
-
|
|
797
|
+
/**
|
|
798
|
+
* Call to resolve the `result` Promise with the supplied value
|
|
799
|
+
*/
|
|
800
|
+
done(value) {
|
|
801
|
+
assert3(this.isRunning);
|
|
802
|
+
this.isRunning = false;
|
|
803
|
+
this._resolve(value);
|
|
856
804
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
805
|
+
/**
|
|
806
|
+
* Call to reject the `result` Promise with the supplied error
|
|
807
|
+
*/
|
|
808
|
+
error(error) {
|
|
809
|
+
assert3(this.isRunning);
|
|
810
|
+
this.isRunning = false;
|
|
811
|
+
this._reject(error);
|
|
863
812
|
}
|
|
864
|
-
}
|
|
813
|
+
};
|
|
865
814
|
|
|
866
|
-
// ../
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
815
|
+
// ../worker-utils/src/lib/node/worker_threads-browser.ts
|
|
816
|
+
var NodeWorker = class {
|
|
817
|
+
terminate() {
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
// ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
|
|
822
|
+
var workerURLCache = /* @__PURE__ */ new Map();
|
|
823
|
+
function getLoadableWorkerURL(props) {
|
|
824
|
+
assert3(props.source && !props.url || !props.source && props.url);
|
|
825
|
+
let workerURL = workerURLCache.get(props.source || props.url);
|
|
826
|
+
if (!workerURL) {
|
|
827
|
+
if (props.url) {
|
|
828
|
+
workerURL = getLoadableWorkerURLFromURL(props.url);
|
|
829
|
+
workerURLCache.set(props.url, workerURL);
|
|
873
830
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
831
|
+
if (props.source) {
|
|
832
|
+
workerURL = getLoadableWorkerURLFromSource(props.source);
|
|
833
|
+
workerURLCache.set(props.source, workerURL);
|
|
877
834
|
}
|
|
878
835
|
}
|
|
836
|
+
assert3(workerURL);
|
|
837
|
+
return workerURL;
|
|
879
838
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
arrayBuffers.push(chunk);
|
|
839
|
+
function getLoadableWorkerURLFromURL(url) {
|
|
840
|
+
if (!url.startsWith("http")) {
|
|
841
|
+
return url;
|
|
884
842
|
}
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
889
|
-
function _typeof(obj) {
|
|
890
|
-
"@babel/helpers - typeof";
|
|
891
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
892
|
-
return typeof obj2;
|
|
893
|
-
} : function(obj2) {
|
|
894
|
-
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
895
|
-
}, _typeof(obj);
|
|
843
|
+
const workerSource = buildScriptSource(url);
|
|
844
|
+
return getLoadableWorkerURLFromSource(workerSource);
|
|
896
845
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
if (_typeof(input) !== "object" || input === null)
|
|
901
|
-
return input;
|
|
902
|
-
var prim = input[Symbol.toPrimitive];
|
|
903
|
-
if (prim !== void 0) {
|
|
904
|
-
var res = prim.call(input, hint || "default");
|
|
905
|
-
if (_typeof(res) !== "object")
|
|
906
|
-
return res;
|
|
907
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
908
|
-
}
|
|
909
|
-
return (hint === "string" ? String : Number)(input);
|
|
846
|
+
function getLoadableWorkerURLFromSource(workerSource) {
|
|
847
|
+
const blob = new Blob([workerSource], { type: "application/javascript" });
|
|
848
|
+
return URL.createObjectURL(blob);
|
|
910
849
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
850
|
+
function buildScriptSource(workerUrl) {
|
|
851
|
+
return `try {
|
|
852
|
+
importScripts('${workerUrl}');
|
|
853
|
+
} catch (error) {
|
|
854
|
+
console.error(error);
|
|
855
|
+
throw error;
|
|
856
|
+
}`;
|
|
916
857
|
}
|
|
917
858
|
|
|
918
|
-
//
|
|
919
|
-
function
|
|
920
|
-
|
|
921
|
-
if (
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
859
|
+
// ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
|
|
860
|
+
function getTransferList(object, recursive = true, transfers) {
|
|
861
|
+
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
862
|
+
if (!object) {
|
|
863
|
+
} else if (isTransferable(object)) {
|
|
864
|
+
transfersSet.add(object);
|
|
865
|
+
} else if (isTransferable(object.buffer)) {
|
|
866
|
+
transfersSet.add(object.buffer);
|
|
867
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
868
|
+
} else if (recursive && typeof object === "object") {
|
|
869
|
+
for (const key in object) {
|
|
870
|
+
getTransferList(object[key], recursive, transfersSet);
|
|
871
|
+
}
|
|
930
872
|
}
|
|
931
|
-
return
|
|
873
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
932
874
|
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
let timestamp;
|
|
937
|
-
if (typeof window !== "undefined" && window.performance) {
|
|
938
|
-
timestamp = window.performance.now();
|
|
939
|
-
} else if (typeof process !== "undefined" && process.hrtime) {
|
|
940
|
-
const timeParts = process.hrtime();
|
|
941
|
-
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
942
|
-
} else {
|
|
943
|
-
timestamp = Date.now();
|
|
944
|
-
}
|
|
945
|
-
return timestamp;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
// ../loader-utils/node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
949
|
-
var Stat = class {
|
|
950
|
-
constructor(name, type) {
|
|
951
|
-
_defineProperty(this, "name", void 0);
|
|
952
|
-
_defineProperty(this, "type", void 0);
|
|
953
|
-
_defineProperty(this, "sampleSize", 1);
|
|
954
|
-
_defineProperty(this, "time", 0);
|
|
955
|
-
_defineProperty(this, "count", 0);
|
|
956
|
-
_defineProperty(this, "samples", 0);
|
|
957
|
-
_defineProperty(this, "lastTiming", 0);
|
|
958
|
-
_defineProperty(this, "lastSampleTime", 0);
|
|
959
|
-
_defineProperty(this, "lastSampleCount", 0);
|
|
960
|
-
_defineProperty(this, "_count", 0);
|
|
961
|
-
_defineProperty(this, "_time", 0);
|
|
962
|
-
_defineProperty(this, "_samples", 0);
|
|
963
|
-
_defineProperty(this, "_startTime", 0);
|
|
964
|
-
_defineProperty(this, "_timerPending", false);
|
|
965
|
-
this.name = name;
|
|
966
|
-
this.type = type;
|
|
967
|
-
this.reset();
|
|
968
|
-
}
|
|
969
|
-
reset() {
|
|
970
|
-
this.time = 0;
|
|
971
|
-
this.count = 0;
|
|
972
|
-
this.samples = 0;
|
|
973
|
-
this.lastTiming = 0;
|
|
974
|
-
this.lastSampleTime = 0;
|
|
975
|
-
this.lastSampleCount = 0;
|
|
976
|
-
this._count = 0;
|
|
977
|
-
this._time = 0;
|
|
978
|
-
this._samples = 0;
|
|
979
|
-
this._startTime = 0;
|
|
980
|
-
this._timerPending = false;
|
|
981
|
-
return this;
|
|
982
|
-
}
|
|
983
|
-
setSampleSize(samples) {
|
|
984
|
-
this.sampleSize = samples;
|
|
985
|
-
return this;
|
|
986
|
-
}
|
|
987
|
-
incrementCount() {
|
|
988
|
-
this.addCount(1);
|
|
989
|
-
return this;
|
|
875
|
+
function isTransferable(object) {
|
|
876
|
+
if (!object) {
|
|
877
|
+
return false;
|
|
990
878
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
return this;
|
|
879
|
+
if (object instanceof ArrayBuffer) {
|
|
880
|
+
return true;
|
|
994
881
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
this._samples++;
|
|
998
|
-
this._checkSampling();
|
|
999
|
-
return this;
|
|
882
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
883
|
+
return true;
|
|
1000
884
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
this._samples++;
|
|
1004
|
-
this._checkSampling();
|
|
1005
|
-
return this;
|
|
885
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
886
|
+
return true;
|
|
1006
887
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
this.lastTiming = time;
|
|
1010
|
-
this._samples++;
|
|
1011
|
-
this._checkSampling();
|
|
1012
|
-
return this;
|
|
888
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
889
|
+
return true;
|
|
1013
890
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
891
|
+
return false;
|
|
892
|
+
}
|
|
893
|
+
function getTransferListForWriter(object) {
|
|
894
|
+
if (object === null) {
|
|
895
|
+
return {};
|
|
1018
896
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
897
|
+
const clone = Object.assign({}, object);
|
|
898
|
+
Object.keys(clone).forEach((key) => {
|
|
899
|
+
if (typeof object[key] === "object" && !ArrayBuffer.isView(object[key]) && !(object[key] instanceof Array)) {
|
|
900
|
+
clone[key] = getTransferListForWriter(object[key]);
|
|
901
|
+
} else if (typeof clone[key] === "function" || clone[key] instanceof RegExp) {
|
|
902
|
+
clone[key] = {};
|
|
903
|
+
} else {
|
|
904
|
+
clone[key] = object[key];
|
|
1022
905
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
906
|
+
});
|
|
907
|
+
return clone;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// ../worker-utils/src/lib/worker-farm/worker-thread.ts
|
|
911
|
+
var NOOP = () => {
|
|
912
|
+
};
|
|
913
|
+
var WorkerThread = class {
|
|
914
|
+
name;
|
|
915
|
+
source;
|
|
916
|
+
url;
|
|
917
|
+
terminated = false;
|
|
918
|
+
worker;
|
|
919
|
+
onMessage;
|
|
920
|
+
onError;
|
|
921
|
+
_loadableURL = "";
|
|
922
|
+
/** Checks if workers are supported on this platform */
|
|
923
|
+
static isSupported() {
|
|
924
|
+
return typeof Worker !== "undefined" && isBrowser4 || typeof NodeWorker !== "undefined" && !isBrowser4;
|
|
1027
925
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
926
|
+
constructor(props) {
|
|
927
|
+
const { name, source, url } = props;
|
|
928
|
+
assert3(source || url);
|
|
929
|
+
this.name = name;
|
|
930
|
+
this.source = source;
|
|
931
|
+
this.url = url;
|
|
932
|
+
this.onMessage = NOOP;
|
|
933
|
+
this.onError = (error) => console.log(error);
|
|
934
|
+
this.worker = isBrowser4 ? this._createBrowserWorker() : this._createNodeWorker();
|
|
1030
935
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
936
|
+
/**
|
|
937
|
+
* Terminate this worker thread
|
|
938
|
+
* @note Can free up significant memory
|
|
939
|
+
*/
|
|
940
|
+
destroy() {
|
|
941
|
+
this.onMessage = NOOP;
|
|
942
|
+
this.onError = NOOP;
|
|
943
|
+
this.worker.terminate();
|
|
944
|
+
this.terminated = true;
|
|
1033
945
|
}
|
|
1034
|
-
|
|
1035
|
-
return
|
|
946
|
+
get isRunning() {
|
|
947
|
+
return Boolean(this.onMessage);
|
|
1036
948
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
949
|
+
/**
|
|
950
|
+
* Send a message to this worker thread
|
|
951
|
+
* @param data any data structure, ideally consisting mostly of transferrable objects
|
|
952
|
+
* @param transferList If not supplied, calculated automatically by traversing data
|
|
953
|
+
*/
|
|
954
|
+
postMessage(data, transferList) {
|
|
955
|
+
transferList = transferList || getTransferList(data);
|
|
956
|
+
this.worker.postMessage(data, transferList);
|
|
1039
957
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
958
|
+
// PRIVATE
|
|
959
|
+
/**
|
|
960
|
+
* Generate a standard Error from an ErrorEvent
|
|
961
|
+
* @param event
|
|
962
|
+
*/
|
|
963
|
+
_getErrorFromErrorEvent(event) {
|
|
964
|
+
let message = "Failed to load ";
|
|
965
|
+
message += `worker ${this.name} from ${this.url}. `;
|
|
966
|
+
if (event.message) {
|
|
967
|
+
message += `${event.message} in `;
|
|
968
|
+
}
|
|
969
|
+
if (event.lineno) {
|
|
970
|
+
message += `:${event.lineno}:${event.colno}`;
|
|
971
|
+
}
|
|
972
|
+
return new Error(message);
|
|
1042
973
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
974
|
+
/**
|
|
975
|
+
* Creates a worker thread on the browser
|
|
976
|
+
*/
|
|
977
|
+
_createBrowserWorker() {
|
|
978
|
+
this._loadableURL = getLoadableWorkerURL({ source: this.source, url: this.url });
|
|
979
|
+
const worker = new Worker(this._loadableURL, { name: this.name });
|
|
980
|
+
worker.onmessage = (event) => {
|
|
981
|
+
if (!event.data) {
|
|
982
|
+
this.onError(new Error("No data received"));
|
|
983
|
+
} else {
|
|
984
|
+
this.onMessage(event.data);
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
worker.onerror = (error) => {
|
|
988
|
+
this.onError(this._getErrorFromErrorEvent(error));
|
|
989
|
+
this.terminated = true;
|
|
990
|
+
};
|
|
991
|
+
worker.onmessageerror = (event) => console.error(event);
|
|
992
|
+
return worker;
|
|
1045
993
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
this.
|
|
1054
|
-
this.
|
|
1055
|
-
|
|
994
|
+
/**
|
|
995
|
+
* Creates a worker thread in node.js
|
|
996
|
+
* @todo https://nodejs.org/api/async_hooks.html#async-resource-worker-pool
|
|
997
|
+
*/
|
|
998
|
+
_createNodeWorker() {
|
|
999
|
+
let worker;
|
|
1000
|
+
if (this.url) {
|
|
1001
|
+
const absolute = this.url.includes(":/") || this.url.startsWith("/");
|
|
1002
|
+
const url = absolute ? this.url : `./${this.url}`;
|
|
1003
|
+
worker = new NodeWorker(url, { eval: false });
|
|
1004
|
+
} else if (this.source) {
|
|
1005
|
+
worker = new NodeWorker(this.source, { eval: true });
|
|
1006
|
+
} else {
|
|
1007
|
+
throw new Error("no worker");
|
|
1056
1008
|
}
|
|
1009
|
+
worker.on("message", (data) => {
|
|
1010
|
+
this.onMessage(data);
|
|
1011
|
+
});
|
|
1012
|
+
worker.on("error", (error) => {
|
|
1013
|
+
this.onError(error);
|
|
1014
|
+
});
|
|
1015
|
+
worker.on("exit", (code) => {
|
|
1016
|
+
});
|
|
1017
|
+
return worker;
|
|
1057
1018
|
}
|
|
1058
1019
|
};
|
|
1059
1020
|
|
|
1060
|
-
// ../
|
|
1061
|
-
var
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1021
|
+
// ../worker-utils/src/lib/worker-farm/worker-pool.ts
|
|
1022
|
+
var WorkerPool = class {
|
|
1023
|
+
name = "unnamed";
|
|
1024
|
+
source;
|
|
1025
|
+
// | Function;
|
|
1026
|
+
url;
|
|
1027
|
+
maxConcurrency = 1;
|
|
1028
|
+
maxMobileConcurrency = 1;
|
|
1029
|
+
onDebug = () => {
|
|
1030
|
+
};
|
|
1031
|
+
reuseWorkers = true;
|
|
1032
|
+
props = {};
|
|
1033
|
+
jobQueue = [];
|
|
1034
|
+
idleQueue = [];
|
|
1035
|
+
count = 0;
|
|
1036
|
+
isDestroyed = false;
|
|
1037
|
+
/** Checks if workers are supported on this platform */
|
|
1038
|
+
static isSupported() {
|
|
1039
|
+
return WorkerThread.isSupported();
|
|
1076
1040
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1041
|
+
/**
|
|
1042
|
+
* @param processor - worker function
|
|
1043
|
+
* @param maxConcurrency - max count of workers
|
|
1044
|
+
*/
|
|
1045
|
+
constructor(props) {
|
|
1046
|
+
this.source = props.source;
|
|
1047
|
+
this.url = props.url;
|
|
1048
|
+
this.setProps(props);
|
|
1079
1049
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1050
|
+
/**
|
|
1051
|
+
* Terminates all workers in the pool
|
|
1052
|
+
* @note Can free up significant memory
|
|
1053
|
+
*/
|
|
1054
|
+
destroy() {
|
|
1055
|
+
this.idleQueue.forEach((worker) => worker.destroy());
|
|
1056
|
+
this.isDestroyed = true;
|
|
1085
1057
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1058
|
+
setProps(props) {
|
|
1059
|
+
this.props = { ...this.props, ...props };
|
|
1060
|
+
if (props.name !== void 0) {
|
|
1061
|
+
this.name = props.name;
|
|
1089
1062
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
const table = {};
|
|
1093
|
-
this.forEach((stat) => {
|
|
1094
|
-
table[stat.name] = {
|
|
1095
|
-
time: stat.time || 0,
|
|
1096
|
-
count: stat.count || 0,
|
|
1097
|
-
average: stat.getAverageTime() || 0,
|
|
1098
|
-
hz: stat.getHz() || 0
|
|
1099
|
-
};
|
|
1100
|
-
});
|
|
1101
|
-
return table;
|
|
1102
|
-
}
|
|
1103
|
-
_initializeStats() {
|
|
1104
|
-
let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
1105
|
-
stats.forEach((stat) => this._getOrCreate(stat));
|
|
1106
|
-
}
|
|
1107
|
-
_getOrCreate(stat) {
|
|
1108
|
-
const {
|
|
1109
|
-
name,
|
|
1110
|
-
type
|
|
1111
|
-
} = stat;
|
|
1112
|
-
let result = this.stats[name];
|
|
1113
|
-
if (!result) {
|
|
1114
|
-
if (stat instanceof Stat) {
|
|
1115
|
-
result = stat;
|
|
1116
|
-
} else {
|
|
1117
|
-
result = new Stat(name, type);
|
|
1118
|
-
}
|
|
1119
|
-
this.stats[name] = result;
|
|
1063
|
+
if (props.maxConcurrency !== void 0) {
|
|
1064
|
+
this.maxConcurrency = props.maxConcurrency;
|
|
1120
1065
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
};
|
|
1124
|
-
|
|
1125
|
-
// ../loader-utils/src/lib/request-utils/request-scheduler.ts
|
|
1126
|
-
var STAT_QUEUED_REQUESTS = "Queued Requests";
|
|
1127
|
-
var STAT_ACTIVE_REQUESTS = "Active Requests";
|
|
1128
|
-
var STAT_CANCELLED_REQUESTS = "Cancelled Requests";
|
|
1129
|
-
var STAT_QUEUED_REQUESTS_EVER = "Queued Requests Ever";
|
|
1130
|
-
var STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
|
|
1131
|
-
var DEFAULT_PROPS2 = {
|
|
1132
|
-
id: "request-scheduler",
|
|
1133
|
-
/** Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing. */
|
|
1134
|
-
throttleRequests: true,
|
|
1135
|
-
/** The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit. */
|
|
1136
|
-
maxRequests: 6,
|
|
1137
|
-
/**
|
|
1138
|
-
* Specifies a debounce time, in milliseconds. All requests are queued, until no new requests have
|
|
1139
|
-
* been added to the queue for this amount of time.
|
|
1140
|
-
*/
|
|
1141
|
-
debounceTime: 0
|
|
1142
|
-
};
|
|
1143
|
-
var RequestScheduler = class {
|
|
1144
|
-
constructor(props = {}) {
|
|
1145
|
-
this.activeRequestCount = 0;
|
|
1146
|
-
/** Tracks the number of active requests and prioritizes/cancels queued requests. */
|
|
1147
|
-
this.requestQueue = [];
|
|
1148
|
-
this.requestMap = /* @__PURE__ */ new Map();
|
|
1149
|
-
this.updateTimer = null;
|
|
1150
|
-
this.props = { ...DEFAULT_PROPS2, ...props };
|
|
1151
|
-
this.stats = new Stats({ id: this.props.id });
|
|
1152
|
-
this.stats.get(STAT_QUEUED_REQUESTS);
|
|
1153
|
-
this.stats.get(STAT_ACTIVE_REQUESTS);
|
|
1154
|
-
this.stats.get(STAT_CANCELLED_REQUESTS);
|
|
1155
|
-
this.stats.get(STAT_QUEUED_REQUESTS_EVER);
|
|
1156
|
-
this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
|
|
1157
|
-
}
|
|
1158
|
-
/**
|
|
1159
|
-
* Called by an application that wants to issue a request, without having it deeply queued by the browser
|
|
1160
|
-
*
|
|
1161
|
-
* When the returned promise resolved, it is OK for the application to issue a request.
|
|
1162
|
-
* The promise resolves to an object that contains a `done` method.
|
|
1163
|
-
* When the application's request has completed (or failed), the application must call the `done` function
|
|
1164
|
-
*
|
|
1165
|
-
* @param handle
|
|
1166
|
-
* @param getPriority will be called when request "slots" open up,
|
|
1167
|
-
* allowing the caller to update priority or cancel the request
|
|
1168
|
-
* Highest priority executes first, priority < 0 cancels the request
|
|
1169
|
-
* @returns a promise
|
|
1170
|
-
* - resolves to a object (with a `done` field) when the request can be issued without queueing,
|
|
1171
|
-
* - resolves to `null` if the request has been cancelled (by the callback return < 0).
|
|
1172
|
-
* In this case the application should not issue the request
|
|
1173
|
-
*/
|
|
1174
|
-
scheduleRequest(handle, getPriority = () => 0) {
|
|
1175
|
-
if (!this.props.throttleRequests) {
|
|
1176
|
-
return Promise.resolve({ done: () => {
|
|
1177
|
-
} });
|
|
1066
|
+
if (props.maxMobileConcurrency !== void 0) {
|
|
1067
|
+
this.maxMobileConcurrency = props.maxMobileConcurrency;
|
|
1178
1068
|
}
|
|
1179
|
-
if (
|
|
1180
|
-
|
|
1069
|
+
if (props.reuseWorkers !== void 0) {
|
|
1070
|
+
this.reuseWorkers = props.reuseWorkers;
|
|
1181
1071
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1072
|
+
if (props.onDebug !== void 0) {
|
|
1073
|
+
this.onDebug = props.onDebug;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
async startJob(name, onMessage3 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
|
|
1077
|
+
const startPromise = new Promise((onStart) => {
|
|
1078
|
+
this.jobQueue.push({ name, onMessage: onMessage3, onError, onStart });
|
|
1079
|
+
return this;
|
|
1186
1080
|
});
|
|
1187
|
-
this.
|
|
1188
|
-
|
|
1189
|
-
this._issueNewRequests();
|
|
1190
|
-
return promise;
|
|
1081
|
+
this._startQueuedJob();
|
|
1082
|
+
return await startPromise;
|
|
1191
1083
|
}
|
|
1192
1084
|
// PRIVATE
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
this.activeRequestCount--;
|
|
1201
|
-
this._issueNewRequests();
|
|
1202
|
-
}
|
|
1203
|
-
};
|
|
1204
|
-
this.activeRequestCount++;
|
|
1205
|
-
return resolve2 ? resolve2({ done }) : Promise.resolve({ done });
|
|
1206
|
-
}
|
|
1207
|
-
/** We check requests asynchronously, to prevent multiple updates */
|
|
1208
|
-
_issueNewRequests() {
|
|
1209
|
-
if (this.updateTimer !== null) {
|
|
1210
|
-
clearTimeout(this.updateTimer);
|
|
1211
|
-
}
|
|
1212
|
-
this.updateTimer = setTimeout(() => this._issueNewRequestsAsync(), this.props.debounceTime);
|
|
1213
|
-
}
|
|
1214
|
-
/** Refresh all requests */
|
|
1215
|
-
_issueNewRequestsAsync() {
|
|
1216
|
-
if (this.updateTimer !== null) {
|
|
1217
|
-
clearTimeout(this.updateTimer);
|
|
1085
|
+
/**
|
|
1086
|
+
* Starts first queued job if worker is available or can be created
|
|
1087
|
+
* Called when job is started and whenever a worker returns to the idleQueue
|
|
1088
|
+
*/
|
|
1089
|
+
async _startQueuedJob() {
|
|
1090
|
+
if (!this.jobQueue.length) {
|
|
1091
|
+
return;
|
|
1218
1092
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
if (freeSlots === 0) {
|
|
1093
|
+
const workerThread = this._getAvailableWorker();
|
|
1094
|
+
if (!workerThread) {
|
|
1222
1095
|
return;
|
|
1223
1096
|
}
|
|
1224
|
-
this.
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1097
|
+
const queuedJob = this.jobQueue.shift();
|
|
1098
|
+
if (queuedJob) {
|
|
1099
|
+
this.onDebug({
|
|
1100
|
+
message: "Starting job",
|
|
1101
|
+
name: queuedJob.name,
|
|
1102
|
+
workerThread,
|
|
1103
|
+
backlog: this.jobQueue.length
|
|
1104
|
+
});
|
|
1105
|
+
const job = new WorkerJob(queuedJob.name, workerThread);
|
|
1106
|
+
workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
|
|
1107
|
+
workerThread.onError = (error) => queuedJob.onError(job, error);
|
|
1108
|
+
queuedJob.onStart(job);
|
|
1109
|
+
try {
|
|
1110
|
+
await job.result;
|
|
1111
|
+
} catch (error) {
|
|
1112
|
+
console.error(`Worker exception: ${error}`);
|
|
1113
|
+
} finally {
|
|
1114
|
+
this.returnWorkerToQueue(workerThread);
|
|
1229
1115
|
}
|
|
1230
1116
|
}
|
|
1231
1117
|
}
|
|
1232
|
-
/**
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1118
|
+
/**
|
|
1119
|
+
* Returns a worker to the idle queue
|
|
1120
|
+
* Destroys the worker if
|
|
1121
|
+
* - pool is destroyed
|
|
1122
|
+
* - if this pool doesn't reuse workers
|
|
1123
|
+
* - if maxConcurrency has been lowered
|
|
1124
|
+
* @param worker
|
|
1125
|
+
*/
|
|
1126
|
+
returnWorkerToQueue(worker) {
|
|
1127
|
+
const shouldDestroyWorker = (
|
|
1128
|
+
// Workers on Node.js prevent the process from exiting.
|
|
1129
|
+
// Until we figure out how to close them before exit, we always destroy them
|
|
1130
|
+
!isBrowser4 || // If the pool is destroyed, there is no reason to keep the worker around
|
|
1131
|
+
this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
|
|
1132
|
+
!this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
|
|
1133
|
+
this.count > this._getMaxConcurrency()
|
|
1134
|
+
);
|
|
1135
|
+
if (shouldDestroyWorker) {
|
|
1136
|
+
worker.destroy();
|
|
1137
|
+
this.count--;
|
|
1138
|
+
} else {
|
|
1139
|
+
this.idleQueue.push(worker);
|
|
1242
1140
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
/** Update a single request by calling the callback */
|
|
1246
|
-
_updateRequest(request) {
|
|
1247
|
-
request.priority = request.getPriority(request.handle);
|
|
1248
|
-
if (request.priority < 0) {
|
|
1249
|
-
request.resolve(null);
|
|
1250
|
-
return false;
|
|
1141
|
+
if (!this.isDestroyed) {
|
|
1142
|
+
this._startQueuedJob();
|
|
1251
1143
|
}
|
|
1252
|
-
return true;
|
|
1253
1144
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
pathPrefix = prefix;
|
|
1261
|
-
}
|
|
1262
|
-
function getPathPrefix() {
|
|
1263
|
-
return pathPrefix;
|
|
1264
|
-
}
|
|
1265
|
-
function resolvePath(filename2) {
|
|
1266
|
-
for (const alias in fileAliases) {
|
|
1267
|
-
if (filename2.startsWith(alias)) {
|
|
1268
|
-
const replacement = fileAliases[alias];
|
|
1269
|
-
filename2 = filename2.replace(alias, replacement);
|
|
1145
|
+
/**
|
|
1146
|
+
* Returns idle worker or creates new worker if maxConcurrency has not been reached
|
|
1147
|
+
*/
|
|
1148
|
+
_getAvailableWorker() {
|
|
1149
|
+
if (this.idleQueue.length > 0) {
|
|
1150
|
+
return this.idleQueue.shift() || null;
|
|
1270
1151
|
}
|
|
1152
|
+
if (this.count < this._getMaxConcurrency()) {
|
|
1153
|
+
this.count++;
|
|
1154
|
+
const name = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
|
|
1155
|
+
return new WorkerThread({ name, source: this.source, url: this.url });
|
|
1156
|
+
}
|
|
1157
|
+
return null;
|
|
1271
1158
|
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1159
|
+
_getMaxConcurrency() {
|
|
1160
|
+
return isMobile ? this.maxMobileConcurrency : this.maxConcurrency;
|
|
1274
1161
|
}
|
|
1275
|
-
|
|
1276
|
-
}
|
|
1162
|
+
};
|
|
1277
1163
|
|
|
1278
|
-
// ../
|
|
1279
|
-
var
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
extensions: ["json", "geojson"],
|
|
1286
|
-
mimeTypes: ["application/json"],
|
|
1287
|
-
category: "json",
|
|
1288
|
-
text: true,
|
|
1289
|
-
parseTextSync,
|
|
1290
|
-
parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
|
|
1291
|
-
options: {}
|
|
1164
|
+
// ../worker-utils/src/lib/worker-farm/worker-farm.ts
|
|
1165
|
+
var DEFAULT_PROPS = {
|
|
1166
|
+
maxConcurrency: 3,
|
|
1167
|
+
maxMobileConcurrency: 1,
|
|
1168
|
+
reuseWorkers: true,
|
|
1169
|
+
onDebug: () => {
|
|
1170
|
+
}
|
|
1292
1171
|
};
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
return buffer;
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
// ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
|
|
1303
|
-
function isBuffer(value) {
|
|
1304
|
-
return value && typeof value === "object" && value.isBuffer;
|
|
1305
|
-
}
|
|
1306
|
-
function toArrayBuffer2(data) {
|
|
1307
|
-
if (isBuffer(data)) {
|
|
1308
|
-
return toArrayBuffer(data);
|
|
1172
|
+
var _WorkerFarm = class {
|
|
1173
|
+
props;
|
|
1174
|
+
workerPools = /* @__PURE__ */ new Map();
|
|
1175
|
+
/** Checks if workers are supported on this platform */
|
|
1176
|
+
static isSupported() {
|
|
1177
|
+
return WorkerThread.isSupported();
|
|
1309
1178
|
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1179
|
+
/** Get the singleton instance of the global worker farm */
|
|
1180
|
+
static getWorkerFarm(props = {}) {
|
|
1181
|
+
_WorkerFarm._workerFarm = _WorkerFarm._workerFarm || new _WorkerFarm({});
|
|
1182
|
+
_WorkerFarm._workerFarm.setProps(props);
|
|
1183
|
+
return _WorkerFarm._workerFarm;
|
|
1312
1184
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1185
|
+
/** get global instance with WorkerFarm.getWorkerFarm() */
|
|
1186
|
+
constructor(props) {
|
|
1187
|
+
this.props = { ...DEFAULT_PROPS };
|
|
1188
|
+
this.setProps(props);
|
|
1189
|
+
this.workerPools = /* @__PURE__ */ new Map();
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Terminate all workers in the farm
|
|
1193
|
+
* @note Can free up significant memory
|
|
1194
|
+
*/
|
|
1195
|
+
destroy() {
|
|
1196
|
+
for (const workerPool of this.workerPools.values()) {
|
|
1197
|
+
workerPool.destroy();
|
|
1316
1198
|
}
|
|
1317
|
-
|
|
1199
|
+
this.workerPools = /* @__PURE__ */ new Map();
|
|
1318
1200
|
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1201
|
+
/**
|
|
1202
|
+
* Set props used when initializing worker pools
|
|
1203
|
+
* @param props
|
|
1204
|
+
*/
|
|
1205
|
+
setProps(props) {
|
|
1206
|
+
this.props = { ...this.props, ...props };
|
|
1207
|
+
for (const workerPool of this.workerPools.values()) {
|
|
1208
|
+
workerPool.setProps(this._getWorkerPoolProps());
|
|
1209
|
+
}
|
|
1323
1210
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1211
|
+
/**
|
|
1212
|
+
* Returns a worker pool for the specified worker
|
|
1213
|
+
* @param options - only used first time for a specific worker name
|
|
1214
|
+
* @param options.name - the name of the worker - used to identify worker pool
|
|
1215
|
+
* @param options.url -
|
|
1216
|
+
* @param options.source -
|
|
1217
|
+
* @example
|
|
1218
|
+
* const job = WorkerFarm.getWorkerFarm().getWorkerPool({name, url}).startJob(...);
|
|
1219
|
+
*/
|
|
1220
|
+
getWorkerPool(options) {
|
|
1221
|
+
const { name, source, url } = options;
|
|
1222
|
+
let workerPool = this.workerPools.get(name);
|
|
1223
|
+
if (!workerPool) {
|
|
1224
|
+
workerPool = new WorkerPool({
|
|
1225
|
+
name,
|
|
1226
|
+
source,
|
|
1227
|
+
url
|
|
1228
|
+
});
|
|
1229
|
+
workerPool.setProps(this._getWorkerPoolProps());
|
|
1230
|
+
this.workerPools.set(name, workerPool);
|
|
1231
|
+
}
|
|
1232
|
+
return workerPool;
|
|
1326
1233
|
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
filename: () => filename,
|
|
1335
|
-
join: () => join,
|
|
1336
|
-
resolve: () => resolve
|
|
1337
|
-
});
|
|
1338
|
-
|
|
1339
|
-
// ../loader-utils/src/lib/path-utils/get-cwd.ts
|
|
1340
|
-
function getCWD() {
|
|
1341
|
-
if (typeof process !== "undefined" && typeof process.cwd !== "undefined") {
|
|
1342
|
-
return process.cwd();
|
|
1234
|
+
_getWorkerPoolProps() {
|
|
1235
|
+
return {
|
|
1236
|
+
maxConcurrency: this.props.maxConcurrency,
|
|
1237
|
+
maxMobileConcurrency: this.props.maxMobileConcurrency,
|
|
1238
|
+
reuseWorkers: this.props.reuseWorkers,
|
|
1239
|
+
onDebug: this.props.onDebug
|
|
1240
|
+
};
|
|
1343
1241
|
}
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1242
|
+
};
|
|
1243
|
+
var WorkerFarm = _WorkerFarm;
|
|
1244
|
+
// singleton
|
|
1245
|
+
__publicField(WorkerFarm, "_workerFarm");
|
|
1347
1246
|
|
|
1348
|
-
// ../
|
|
1349
|
-
function
|
|
1350
|
-
const
|
|
1351
|
-
return
|
|
1352
|
-
}
|
|
1353
|
-
function dirname(url) {
|
|
1354
|
-
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1355
|
-
return slashIndex >= 0 ? url.substr(0, slashIndex) : "";
|
|
1356
|
-
}
|
|
1357
|
-
function join(...parts) {
|
|
1358
|
-
const separator = "/";
|
|
1359
|
-
parts = parts.map((part, index) => {
|
|
1360
|
-
if (index) {
|
|
1361
|
-
part = part.replace(new RegExp(`^${separator}`), "");
|
|
1362
|
-
}
|
|
1363
|
-
if (index !== parts.length - 1) {
|
|
1364
|
-
part = part.replace(new RegExp(`${separator}$`), "");
|
|
1365
|
-
}
|
|
1366
|
-
return part;
|
|
1367
|
-
});
|
|
1368
|
-
return parts.join(separator);
|
|
1247
|
+
// ../worker-utils/src/lib/worker-api/get-worker-url.ts
|
|
1248
|
+
function getWorkerName(worker) {
|
|
1249
|
+
const warning = worker.version !== VERSION2 ? ` (worker-utils@${VERSION2})` : "";
|
|
1250
|
+
return `${worker.name}@${worker.version}${warning}`;
|
|
1369
1251
|
}
|
|
1370
|
-
function
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1373
|
-
|
|
1252
|
+
function getWorkerURL(worker, options = {}) {
|
|
1253
|
+
const workerOptions = options[worker.id] || {};
|
|
1254
|
+
const workerFile = isBrowser4 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
|
|
1255
|
+
let url = workerOptions.workerUrl;
|
|
1256
|
+
if (!url && worker.id === "compression") {
|
|
1257
|
+
url = options.workerUrl;
|
|
1374
1258
|
}
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
1379
|
-
let path;
|
|
1380
|
-
if (i >= 0) {
|
|
1381
|
-
path = paths[i];
|
|
1259
|
+
if (options._workerType === "test") {
|
|
1260
|
+
if (isBrowser4) {
|
|
1261
|
+
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
1382
1262
|
} else {
|
|
1383
|
-
|
|
1384
|
-
cwd = getCWD();
|
|
1385
|
-
}
|
|
1386
|
-
path = cwd;
|
|
1263
|
+
url = `modules/${worker.module}/src/workers/${worker.id}-worker-node.ts`;
|
|
1387
1264
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1265
|
+
}
|
|
1266
|
+
if (!url) {
|
|
1267
|
+
let version = worker.version;
|
|
1268
|
+
if (version === "latest") {
|
|
1269
|
+
version = NPM_TAG;
|
|
1390
1270
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1271
|
+
const versionTag = version ? `@${version}` : "";
|
|
1272
|
+
url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
|
|
1393
1273
|
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1274
|
+
assert3(url);
|
|
1275
|
+
return url;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// ../worker-utils/src/lib/worker-api/process-on-worker.ts
|
|
1279
|
+
async function processOnWorker(worker, data, options = {}, context = {}) {
|
|
1280
|
+
const name = getWorkerName(worker);
|
|
1281
|
+
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
1282
|
+
const { source } = options;
|
|
1283
|
+
const workerPoolProps = { name, source };
|
|
1284
|
+
if (!source) {
|
|
1285
|
+
workerPoolProps.url = getWorkerURL(worker, options);
|
|
1399
1286
|
}
|
|
1400
|
-
|
|
1287
|
+
const workerPool = workerFarm.getWorkerPool(workerPoolProps);
|
|
1288
|
+
const jobName = options.jobName || worker.name;
|
|
1289
|
+
const job = await workerPool.startJob(
|
|
1290
|
+
jobName,
|
|
1291
|
+
// eslint-disable-next-line
|
|
1292
|
+
onMessage.bind(null, context)
|
|
1293
|
+
);
|
|
1294
|
+
const transferableOptions = getTransferListForWriter(options);
|
|
1295
|
+
job.postMessage("process", { input: data, options: transferableOptions });
|
|
1296
|
+
const result = await job.result;
|
|
1297
|
+
return result.result;
|
|
1401
1298
|
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
let lastSlash = -1;
|
|
1407
|
-
let dots = 0;
|
|
1408
|
-
let code;
|
|
1409
|
-
let isAboveRoot = false;
|
|
1410
|
-
for (let i = 0; i <= path.length; ++i) {
|
|
1411
|
-
if (i < path.length) {
|
|
1412
|
-
code = path.charCodeAt(i);
|
|
1413
|
-
} else if (code === SLASH) {
|
|
1299
|
+
async function onMessage(context, job, type, payload) {
|
|
1300
|
+
switch (type) {
|
|
1301
|
+
case "done":
|
|
1302
|
+
job.done(payload);
|
|
1414
1303
|
break;
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
if (
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
let j = start;
|
|
1425
|
-
for (; j >= 0; --j) {
|
|
1426
|
-
if (res.charCodeAt(j) === SLASH) {
|
|
1427
|
-
break;
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
if (j !== start) {
|
|
1431
|
-
res = j === -1 ? "" : res.slice(0, j);
|
|
1432
|
-
lastSlash = i;
|
|
1433
|
-
dots = 0;
|
|
1434
|
-
isAboveRoot = false;
|
|
1435
|
-
continue;
|
|
1436
|
-
}
|
|
1437
|
-
} else if (res.length === 2 || res.length === 1) {
|
|
1438
|
-
res = "";
|
|
1439
|
-
lastSlash = i;
|
|
1440
|
-
dots = 0;
|
|
1441
|
-
isAboveRoot = false;
|
|
1442
|
-
continue;
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
if (allowAboveRoot) {
|
|
1446
|
-
if (res.length > 0) {
|
|
1447
|
-
res += "/..";
|
|
1448
|
-
} else {
|
|
1449
|
-
res = "..";
|
|
1450
|
-
}
|
|
1451
|
-
isAboveRoot = true;
|
|
1452
|
-
}
|
|
1453
|
-
} else {
|
|
1454
|
-
const slice = path.slice(lastSlash + 1, i);
|
|
1455
|
-
if (res.length > 0) {
|
|
1456
|
-
res += `/${slice}`;
|
|
1457
|
-
} else {
|
|
1458
|
-
res = slice;
|
|
1304
|
+
case "error":
|
|
1305
|
+
job.error(new Error(payload.error));
|
|
1306
|
+
break;
|
|
1307
|
+
case "process":
|
|
1308
|
+
const { id, input, options } = payload;
|
|
1309
|
+
try {
|
|
1310
|
+
if (!context.process) {
|
|
1311
|
+
job.postMessage("error", { id, error: "Worker not set up to process on main thread" });
|
|
1312
|
+
return;
|
|
1459
1313
|
}
|
|
1460
|
-
|
|
1314
|
+
const result = await context.process(input, options);
|
|
1315
|
+
job.postMessage("done", { id, result });
|
|
1316
|
+
} catch (error) {
|
|
1317
|
+
const message = error instanceof Error ? error.message : "unknown error";
|
|
1318
|
+
job.postMessage("error", { id, error: message });
|
|
1461
1319
|
}
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
++dots;
|
|
1466
|
-
} else {
|
|
1467
|
-
dots = -1;
|
|
1468
|
-
}
|
|
1320
|
+
break;
|
|
1321
|
+
default:
|
|
1322
|
+
console.warn(`process-on-worker: unknown message ${type}`);
|
|
1469
1323
|
}
|
|
1470
|
-
return res;
|
|
1471
1324
|
}
|
|
1472
1325
|
|
|
1473
|
-
// ../
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
this.url = blob instanceof File ? blob.name : "";
|
|
1326
|
+
// ../worker-utils/src/lib/worker-api/validate-worker-version.ts
|
|
1327
|
+
function validateWorkerVersion(worker, coreVersion = VERSION2) {
|
|
1328
|
+
assert3(worker, "no worker provided");
|
|
1329
|
+
const workerVersion = worker.version;
|
|
1330
|
+
if (!coreVersion || !workerVersion) {
|
|
1331
|
+
return false;
|
|
1480
1332
|
}
|
|
1481
|
-
|
|
1333
|
+
return true;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
// ../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts
|
|
1337
|
+
function canParseWithWorker(loader, options) {
|
|
1338
|
+
if (!WorkerFarm.isSupported()) {
|
|
1339
|
+
return false;
|
|
1482
1340
|
}
|
|
1483
|
-
|
|
1484
|
-
return
|
|
1485
|
-
size: this.handle.size,
|
|
1486
|
-
bigsize: BigInt(this.handle.size),
|
|
1487
|
-
isDirectory: false
|
|
1488
|
-
};
|
|
1341
|
+
if (!isBrowser4 && !options?._nodeWorkers) {
|
|
1342
|
+
return false;
|
|
1489
1343
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1344
|
+
return loader.worker && options?.worker;
|
|
1345
|
+
}
|
|
1346
|
+
async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
|
|
1347
|
+
const name = loader.id;
|
|
1348
|
+
const url = getWorkerURL(loader, options);
|
|
1349
|
+
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
1350
|
+
const workerPool = workerFarm.getWorkerPool({ name, url });
|
|
1351
|
+
options = JSON.parse(JSON.stringify(options));
|
|
1352
|
+
context = JSON.parse(JSON.stringify(context || {}));
|
|
1353
|
+
const job = await workerPool.startJob(
|
|
1354
|
+
"process-on-worker",
|
|
1355
|
+
// @ts-expect-error
|
|
1356
|
+
onMessage2.bind(null, parseOnMainThread)
|
|
1357
|
+
// eslint-disable-line @typescript-eslint/no-misused-promises
|
|
1358
|
+
);
|
|
1359
|
+
job.postMessage("process", {
|
|
1360
|
+
// @ts-ignore
|
|
1361
|
+
input: data,
|
|
1362
|
+
options,
|
|
1363
|
+
context
|
|
1364
|
+
});
|
|
1365
|
+
const result = await job.result;
|
|
1366
|
+
return await result.result;
|
|
1367
|
+
}
|
|
1368
|
+
async function onMessage2(parseOnMainThread, job, type, payload) {
|
|
1369
|
+
switch (type) {
|
|
1370
|
+
case "done":
|
|
1371
|
+
job.done(payload);
|
|
1372
|
+
break;
|
|
1373
|
+
case "error":
|
|
1374
|
+
job.error(new Error(payload.error));
|
|
1375
|
+
break;
|
|
1376
|
+
case "process":
|
|
1377
|
+
const { id, input, options } = payload;
|
|
1378
|
+
try {
|
|
1379
|
+
const result = await parseOnMainThread(input, options);
|
|
1380
|
+
job.postMessage("done", { id, result });
|
|
1381
|
+
} catch (error) {
|
|
1382
|
+
const message = error instanceof Error ? error.message : "unknown error";
|
|
1383
|
+
job.postMessage("error", { id, error: message });
|
|
1384
|
+
}
|
|
1385
|
+
break;
|
|
1386
|
+
default:
|
|
1387
|
+
console.warn(`parse-with-worker unknown message ${type}`);
|
|
1493
1388
|
}
|
|
1494
|
-
}
|
|
1389
|
+
}
|
|
1495
1390
|
|
|
1496
|
-
// ../loader-utils/src/lib/
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1391
|
+
// ../loader-utils/src/lib/worker-loader-utils/encode-with-worker.ts
|
|
1392
|
+
function canEncodeWithWorker(writer, options) {
|
|
1393
|
+
if (!WorkerFarm.isSupported()) {
|
|
1394
|
+
return false;
|
|
1395
|
+
}
|
|
1396
|
+
if (!isBrowser && !options?._nodeWorkers) {
|
|
1397
|
+
return false;
|
|
1398
|
+
}
|
|
1399
|
+
return writer.worker && options?.worker;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
// ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
|
|
1403
|
+
function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
|
|
1404
|
+
byteLength = byteLength || arrayBuffer1.byteLength;
|
|
1405
|
+
if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
|
|
1406
|
+
return false;
|
|
1407
|
+
}
|
|
1408
|
+
const array1 = new Uint8Array(arrayBuffer1);
|
|
1409
|
+
const array2 = new Uint8Array(arrayBuffer2);
|
|
1410
|
+
for (let i = 0; i < array1.length; ++i) {
|
|
1411
|
+
if (array1[i] !== array2[i]) {
|
|
1412
|
+
return false;
|
|
1508
1413
|
}
|
|
1509
|
-
throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
|
|
1510
1414
|
}
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1415
|
+
return true;
|
|
1416
|
+
}
|
|
1417
|
+
function concatenateArrayBuffers(...sources) {
|
|
1418
|
+
return concatenateArrayBuffersFromArray(sources);
|
|
1419
|
+
}
|
|
1420
|
+
function concatenateArrayBuffersFromArray(sources) {
|
|
1421
|
+
const sourceArrays = sources.map(
|
|
1422
|
+
(source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2
|
|
1423
|
+
);
|
|
1424
|
+
const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
|
|
1425
|
+
const result = new Uint8Array(byteLength);
|
|
1426
|
+
let offset = 0;
|
|
1427
|
+
for (const sourceArray of sourceArrays) {
|
|
1428
|
+
result.set(sourceArray, offset);
|
|
1429
|
+
offset += sourceArray.byteLength;
|
|
1514
1430
|
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1431
|
+
return result.buffer;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
// ../loader-utils/src/lib/iterators/text-iterators.ts
|
|
1435
|
+
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
1436
|
+
const textDecoder = new TextDecoder(void 0, options);
|
|
1437
|
+
for await (const arrayBuffer of arrayBufferIterator) {
|
|
1438
|
+
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, { stream: true });
|
|
1518
1439
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1440
|
+
}
|
|
1441
|
+
async function* makeTextEncoderIterator(textIterator) {
|
|
1442
|
+
const textEncoder = new TextEncoder();
|
|
1443
|
+
for await (const text of textIterator) {
|
|
1444
|
+
yield typeof text === "string" ? textEncoder.encode(text) : text;
|
|
1522
1445
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1446
|
+
}
|
|
1447
|
+
async function* makeLineIterator(textIterator) {
|
|
1448
|
+
let previous = "";
|
|
1449
|
+
for await (const textChunk of textIterator) {
|
|
1450
|
+
previous += textChunk;
|
|
1451
|
+
let eolIndex;
|
|
1452
|
+
while ((eolIndex = previous.indexOf("\n")) >= 0) {
|
|
1453
|
+
const line = previous.slice(0, eolIndex + 1);
|
|
1454
|
+
previous = previous.slice(eolIndex + 1);
|
|
1455
|
+
yield line;
|
|
1456
|
+
}
|
|
1526
1457
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
throw NOT_IMPLEMENTED;
|
|
1458
|
+
if (previous.length > 0) {
|
|
1459
|
+
yield previous;
|
|
1530
1460
|
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1461
|
+
}
|
|
1462
|
+
async function* makeNumberedLineIterator(lineIterator) {
|
|
1463
|
+
let counter = 1;
|
|
1464
|
+
for await (const line of lineIterator) {
|
|
1465
|
+
yield { counter, line };
|
|
1466
|
+
counter++;
|
|
1533
1467
|
}
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
//
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
var isWritableDOMStream = (x) => isObject(x) && isFunction(x.abort) && isFunction(x.getWriter);
|
|
1549
|
-
var isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
|
|
1550
|
-
var isWritableNodeStream = (x) => isObject(x) && isFunction(x.end) && isFunction(x.write) && isBoolean(x.writable);
|
|
1551
|
-
var isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
|
|
1552
|
-
var isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
|
|
1553
|
-
var isWritableStream = (x) => isWritableDOMStream(x) || isWritableNodeStream(x);
|
|
1554
|
-
|
|
1555
|
-
// src/lib/utils/mime-type-utils.ts
|
|
1556
|
-
var DATA_URL_PATTERN = /^data:([-\w.]+\/[-\w.+]+)(;|,)/;
|
|
1557
|
-
var MIME_TYPE_PATTERN = /^([-\w.]+\/[-\w.+]+)/;
|
|
1558
|
-
function parseMIMEType(mimeString) {
|
|
1559
|
-
const matches3 = MIME_TYPE_PATTERN.exec(mimeString);
|
|
1560
|
-
if (matches3) {
|
|
1561
|
-
return matches3[1];
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
// ../loader-utils/src/lib/iterators/async-iteration.ts
|
|
1471
|
+
async function forEach(iterator, visitor) {
|
|
1472
|
+
while (true) {
|
|
1473
|
+
const { done, value } = await iterator.next();
|
|
1474
|
+
if (done) {
|
|
1475
|
+
iterator.return();
|
|
1476
|
+
return;
|
|
1477
|
+
}
|
|
1478
|
+
const cancel = visitor(value);
|
|
1479
|
+
if (cancel) {
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1562
1482
|
}
|
|
1563
|
-
return mimeString;
|
|
1564
1483
|
}
|
|
1565
|
-
function
|
|
1566
|
-
const
|
|
1567
|
-
|
|
1568
|
-
|
|
1484
|
+
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
1485
|
+
const arrayBuffers = [];
|
|
1486
|
+
for await (const chunk of asyncIterator) {
|
|
1487
|
+
arrayBuffers.push(chunk);
|
|
1569
1488
|
}
|
|
1570
|
-
return
|
|
1489
|
+
return concatenateArrayBuffers(...arrayBuffers);
|
|
1571
1490
|
}
|
|
1572
1491
|
|
|
1573
|
-
//
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1492
|
+
// ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
1493
|
+
function getHiResTimestamp2() {
|
|
1494
|
+
let timestamp;
|
|
1495
|
+
if (typeof window !== "undefined" && window.performance) {
|
|
1496
|
+
timestamp = window.performance.now();
|
|
1497
|
+
} else if (typeof process !== "undefined" && process.hrtime) {
|
|
1498
|
+
const timeParts = process.hrtime();
|
|
1499
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
1500
|
+
} else {
|
|
1501
|
+
timestamp = Date.now();
|
|
1502
|
+
}
|
|
1503
|
+
return timestamp;
|
|
1581
1504
|
}
|
|
1582
1505
|
|
|
1583
|
-
//
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1506
|
+
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
1507
|
+
var Stat = class {
|
|
1508
|
+
constructor(name, type) {
|
|
1509
|
+
_defineProperty(this, "name", void 0);
|
|
1510
|
+
_defineProperty(this, "type", void 0);
|
|
1511
|
+
_defineProperty(this, "sampleSize", 1);
|
|
1512
|
+
_defineProperty(this, "time", 0);
|
|
1513
|
+
_defineProperty(this, "count", 0);
|
|
1514
|
+
_defineProperty(this, "samples", 0);
|
|
1515
|
+
_defineProperty(this, "lastTiming", 0);
|
|
1516
|
+
_defineProperty(this, "lastSampleTime", 0);
|
|
1517
|
+
_defineProperty(this, "lastSampleCount", 0);
|
|
1518
|
+
_defineProperty(this, "_count", 0);
|
|
1519
|
+
_defineProperty(this, "_time", 0);
|
|
1520
|
+
_defineProperty(this, "_samples", 0);
|
|
1521
|
+
_defineProperty(this, "_startTime", 0);
|
|
1522
|
+
_defineProperty(this, "_timerPending", false);
|
|
1523
|
+
this.name = name;
|
|
1524
|
+
this.type = type;
|
|
1525
|
+
this.reset();
|
|
1588
1526
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1527
|
+
reset() {
|
|
1528
|
+
this.time = 0;
|
|
1529
|
+
this.count = 0;
|
|
1530
|
+
this.samples = 0;
|
|
1531
|
+
this.lastTiming = 0;
|
|
1532
|
+
this.lastSampleTime = 0;
|
|
1533
|
+
this.lastSampleCount = 0;
|
|
1534
|
+
this._count = 0;
|
|
1535
|
+
this._time = 0;
|
|
1536
|
+
this._samples = 0;
|
|
1537
|
+
this._startTime = 0;
|
|
1538
|
+
this._timerPending = false;
|
|
1539
|
+
return this;
|
|
1592
1540
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1541
|
+
setSampleSize(samples) {
|
|
1542
|
+
this.sampleSize = samples;
|
|
1543
|
+
return this;
|
|
1595
1544
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
if (isResponse(resource)) {
|
|
1600
|
-
const response = resource;
|
|
1601
|
-
const contentTypeHeader = response.headers.get("content-type") || "";
|
|
1602
|
-
const noQueryUrl = stripQueryString(response.url);
|
|
1603
|
-
return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);
|
|
1545
|
+
incrementCount() {
|
|
1546
|
+
this.addCount(1);
|
|
1547
|
+
return this;
|
|
1604
1548
|
}
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
return
|
|
1549
|
+
decrementCount() {
|
|
1550
|
+
this.subtractCount(1);
|
|
1551
|
+
return this;
|
|
1608
1552
|
}
|
|
1609
|
-
|
|
1610
|
-
|
|
1553
|
+
addCount(value) {
|
|
1554
|
+
this._count += value;
|
|
1555
|
+
this._samples++;
|
|
1556
|
+
this._checkSampling();
|
|
1557
|
+
return this;
|
|
1611
1558
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
return response.headers["content-length"] || -1;
|
|
1559
|
+
subtractCount(value) {
|
|
1560
|
+
this._count -= value;
|
|
1561
|
+
this._samples++;
|
|
1562
|
+
this._checkSampling();
|
|
1563
|
+
return this;
|
|
1618
1564
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1565
|
+
addTime(time) {
|
|
1566
|
+
this._time += time;
|
|
1567
|
+
this.lastTiming = time;
|
|
1568
|
+
this._samples++;
|
|
1569
|
+
this._checkSampling();
|
|
1570
|
+
return this;
|
|
1622
1571
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1572
|
+
timeStart() {
|
|
1573
|
+
this._startTime = getHiResTimestamp2();
|
|
1574
|
+
this._timerPending = true;
|
|
1575
|
+
return this;
|
|
1625
1576
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1577
|
+
timeEnd() {
|
|
1578
|
+
if (!this._timerPending) {
|
|
1579
|
+
return this;
|
|
1580
|
+
}
|
|
1581
|
+
this.addTime(getHiResTimestamp2() - this._startTime);
|
|
1582
|
+
this._timerPending = false;
|
|
1583
|
+
this._checkSampling();
|
|
1584
|
+
return this;
|
|
1628
1585
|
}
|
|
1629
|
-
|
|
1630
|
-
return
|
|
1586
|
+
getSampleAverageCount() {
|
|
1587
|
+
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
|
|
1631
1588
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1589
|
+
getSampleAverageTime() {
|
|
1590
|
+
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
|
|
1591
|
+
}
|
|
1592
|
+
getSampleHz() {
|
|
1593
|
+
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
|
|
1594
|
+
}
|
|
1595
|
+
getAverageCount() {
|
|
1596
|
+
return this.samples > 0 ? this.count / this.samples : 0;
|
|
1597
|
+
}
|
|
1598
|
+
getAverageTime() {
|
|
1599
|
+
return this.samples > 0 ? this.time / this.samples : 0;
|
|
1600
|
+
}
|
|
1601
|
+
getHz() {
|
|
1602
|
+
return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
|
|
1603
|
+
}
|
|
1604
|
+
_checkSampling() {
|
|
1605
|
+
if (this._samples === this.sampleSize) {
|
|
1606
|
+
this.lastSampleTime = this._time;
|
|
1607
|
+
this.lastSampleCount = this._count;
|
|
1608
|
+
this.count += this._count;
|
|
1609
|
+
this.time += this._time;
|
|
1610
|
+
this.samples += this._samples;
|
|
1611
|
+
this._time = 0;
|
|
1612
|
+
this._count = 0;
|
|
1613
|
+
this._samples = 0;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1634
1617
|
|
|
1635
|
-
//
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1618
|
+
// ../../node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
1619
|
+
var Stats = class {
|
|
1620
|
+
constructor(options) {
|
|
1621
|
+
_defineProperty(this, "id", void 0);
|
|
1622
|
+
_defineProperty(this, "stats", {});
|
|
1623
|
+
this.id = options.id;
|
|
1624
|
+
this.stats = {};
|
|
1625
|
+
this._initializeStats(options.stats);
|
|
1626
|
+
Object.seal(this);
|
|
1639
1627
|
}
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1628
|
+
get(name) {
|
|
1629
|
+
let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
|
|
1630
|
+
return this._getOrCreate({
|
|
1631
|
+
name,
|
|
1632
|
+
type
|
|
1633
|
+
});
|
|
1644
1634
|
}
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
if (type) {
|
|
1648
|
-
headers["content-type"] = type;
|
|
1635
|
+
get size() {
|
|
1636
|
+
return Object.keys(this.stats).length;
|
|
1649
1637
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1638
|
+
reset() {
|
|
1639
|
+
for (const stat of Object.values(this.stats)) {
|
|
1640
|
+
stat.reset();
|
|
1641
|
+
}
|
|
1642
|
+
return this;
|
|
1653
1643
|
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1644
|
+
forEach(fn) {
|
|
1645
|
+
for (const stat of Object.values(this.stats)) {
|
|
1646
|
+
fn(stat);
|
|
1647
|
+
}
|
|
1656
1648
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1649
|
+
getTable() {
|
|
1650
|
+
const table = {};
|
|
1651
|
+
this.forEach((stat) => {
|
|
1652
|
+
table[stat.name] = {
|
|
1653
|
+
time: stat.time || 0,
|
|
1654
|
+
count: stat.count || 0,
|
|
1655
|
+
average: stat.getAverageTime() || 0,
|
|
1656
|
+
hz: stat.getHz() || 0
|
|
1657
|
+
};
|
|
1658
|
+
});
|
|
1659
|
+
return table;
|
|
1665
1660
|
}
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1661
|
+
_initializeStats() {
|
|
1662
|
+
let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
1663
|
+
stats.forEach((stat) => this._getOrCreate(stat));
|
|
1664
|
+
}
|
|
1665
|
+
_getOrCreate(stat) {
|
|
1666
|
+
const {
|
|
1667
|
+
name,
|
|
1668
|
+
type
|
|
1669
|
+
} = stat;
|
|
1670
|
+
let result = this.stats[name];
|
|
1671
|
+
if (!result) {
|
|
1672
|
+
if (stat instanceof Stat) {
|
|
1673
|
+
result = stat;
|
|
1674
|
+
} else {
|
|
1675
|
+
result = new Stat(name, type);
|
|
1676
|
+
}
|
|
1677
|
+
this.stats[name] = result;
|
|
1674
1678
|
}
|
|
1675
|
-
|
|
1676
|
-
message = message.length > 60 ? `${message.slice(0, 60)}...` : message;
|
|
1677
|
-
} catch (error) {
|
|
1679
|
+
return result;
|
|
1678
1680
|
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1681
|
+
};
|
|
1682
|
+
|
|
1683
|
+
// ../loader-utils/src/lib/request-utils/request-scheduler.ts
|
|
1684
|
+
var STAT_QUEUED_REQUESTS = "Queued Requests";
|
|
1685
|
+
var STAT_ACTIVE_REQUESTS = "Active Requests";
|
|
1686
|
+
var STAT_CANCELLED_REQUESTS = "Cancelled Requests";
|
|
1687
|
+
var STAT_QUEUED_REQUESTS_EVER = "Queued Requests Ever";
|
|
1688
|
+
var STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
|
|
1689
|
+
var DEFAULT_PROPS2 = {
|
|
1690
|
+
id: "request-scheduler",
|
|
1691
|
+
/** Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing. */
|
|
1692
|
+
throttleRequests: true,
|
|
1693
|
+
/** The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit. */
|
|
1694
|
+
maxRequests: 6,
|
|
1695
|
+
/**
|
|
1696
|
+
* Specifies a debounce time, in milliseconds. All requests are queued, until no new requests have
|
|
1697
|
+
* been added to the queue for this amount of time.
|
|
1698
|
+
*/
|
|
1699
|
+
debounceTime: 0
|
|
1700
|
+
};
|
|
1701
|
+
var RequestScheduler = class {
|
|
1702
|
+
props;
|
|
1703
|
+
stats;
|
|
1704
|
+
activeRequestCount = 0;
|
|
1705
|
+
/** Tracks the number of active requests and prioritizes/cancels queued requests. */
|
|
1706
|
+
requestQueue = [];
|
|
1707
|
+
requestMap = /* @__PURE__ */ new Map();
|
|
1708
|
+
updateTimer = null;
|
|
1709
|
+
constructor(props = {}) {
|
|
1710
|
+
this.props = { ...DEFAULT_PROPS2, ...props };
|
|
1711
|
+
this.stats = new Stats({ id: this.props.id });
|
|
1712
|
+
this.stats.get(STAT_QUEUED_REQUESTS);
|
|
1713
|
+
this.stats.get(STAT_ACTIVE_REQUESTS);
|
|
1714
|
+
this.stats.get(STAT_CANCELLED_REQUESTS);
|
|
1715
|
+
this.stats.get(STAT_QUEUED_REQUESTS_EVER);
|
|
1716
|
+
this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
|
|
1685
1717
|
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1718
|
+
/**
|
|
1719
|
+
* Called by an application that wants to issue a request, without having it deeply queued by the browser
|
|
1720
|
+
*
|
|
1721
|
+
* When the returned promise resolved, it is OK for the application to issue a request.
|
|
1722
|
+
* The promise resolves to an object that contains a `done` method.
|
|
1723
|
+
* When the application's request has completed (or failed), the application must call the `done` function
|
|
1724
|
+
*
|
|
1725
|
+
* @param handle
|
|
1726
|
+
* @param getPriority will be called when request "slots" open up,
|
|
1727
|
+
* allowing the caller to update priority or cancel the request
|
|
1728
|
+
* Highest priority executes first, priority < 0 cancels the request
|
|
1729
|
+
* @returns a promise
|
|
1730
|
+
* - resolves to a object (with a `done` field) when the request can be issued without queueing,
|
|
1731
|
+
* - resolves to `null` if the request has been cancelled (by the callback return < 0).
|
|
1732
|
+
* In this case the application should not issue the request
|
|
1733
|
+
*/
|
|
1734
|
+
scheduleRequest(handle, getPriority = () => 0) {
|
|
1735
|
+
if (!this.props.throttleRequests) {
|
|
1736
|
+
return Promise.resolve({ done: () => {
|
|
1737
|
+
} });
|
|
1738
|
+
}
|
|
1739
|
+
if (this.requestMap.has(handle)) {
|
|
1740
|
+
return this.requestMap.get(handle);
|
|
1741
|
+
}
|
|
1742
|
+
const request = { handle, priority: 0, getPriority };
|
|
1743
|
+
const promise = new Promise((resolve2) => {
|
|
1744
|
+
request.resolve = resolve2;
|
|
1745
|
+
return request;
|
|
1692
1746
|
});
|
|
1747
|
+
this.requestQueue.push(request);
|
|
1748
|
+
this.requestMap.set(handle, promise);
|
|
1749
|
+
this._issueNewRequests();
|
|
1750
|
+
return promise;
|
|
1693
1751
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
const
|
|
1697
|
-
|
|
1752
|
+
// PRIVATE
|
|
1753
|
+
_issueRequest(request) {
|
|
1754
|
+
const { handle, resolve: resolve2 } = request;
|
|
1755
|
+
let isDone = false;
|
|
1756
|
+
const done = () => {
|
|
1757
|
+
if (!isDone) {
|
|
1758
|
+
isDone = true;
|
|
1759
|
+
this.requestMap.delete(handle);
|
|
1760
|
+
this.activeRequestCount--;
|
|
1761
|
+
this._issueNewRequests();
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
this.activeRequestCount++;
|
|
1765
|
+
return resolve2 ? resolve2({ done }) : Promise.resolve({ done });
|
|
1698
1766
|
}
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
binary += String.fromCharCode(bytes[i]);
|
|
1767
|
+
/** We check requests asynchronously, to prevent multiple updates */
|
|
1768
|
+
_issueNewRequests() {
|
|
1769
|
+
if (this.updateTimer !== null) {
|
|
1770
|
+
clearTimeout(this.updateTimer);
|
|
1771
|
+
}
|
|
1772
|
+
this.updateTimer = setTimeout(() => this._issueNewRequestsAsync(), this.props.debounceTime);
|
|
1706
1773
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
const url = resolvePath(urlOrData);
|
|
1723
|
-
if (isNodePath(url)) {
|
|
1724
|
-
if (globalThis.loaders?.fetchNode) {
|
|
1725
|
-
return globalThis.loaders?.fetchNode(url, fetchOptions);
|
|
1774
|
+
/** Refresh all requests */
|
|
1775
|
+
_issueNewRequestsAsync() {
|
|
1776
|
+
if (this.updateTimer !== null) {
|
|
1777
|
+
clearTimeout(this.updateTimer);
|
|
1778
|
+
}
|
|
1779
|
+
this.updateTimer = null;
|
|
1780
|
+
const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);
|
|
1781
|
+
if (freeSlots === 0) {
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
this._updateAllRequests();
|
|
1785
|
+
for (let i = 0; i < freeSlots; ++i) {
|
|
1786
|
+
const request = this.requestQueue.shift();
|
|
1787
|
+
if (request) {
|
|
1788
|
+
this._issueRequest(request);
|
|
1726
1789
|
}
|
|
1727
1790
|
}
|
|
1728
|
-
return await fetch(url, fetchOptions);
|
|
1729
1791
|
}
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1792
|
+
/** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */
|
|
1793
|
+
_updateAllRequests() {
|
|
1794
|
+
const requestQueue = this.requestQueue;
|
|
1795
|
+
for (let i = 0; i < requestQueue.length; ++i) {
|
|
1796
|
+
const request = requestQueue[i];
|
|
1797
|
+
if (!this._updateRequest(request)) {
|
|
1798
|
+
requestQueue.splice(i, 1);
|
|
1799
|
+
this.requestMap.delete(request.handle);
|
|
1800
|
+
i--;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
requestQueue.sort((a, b) => a.priority - b.priority);
|
|
1737
1804
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
fileReader.onerror = (error) => reject(error);
|
|
1746
|
-
fileReader.readAsArrayBuffer(blob);
|
|
1747
|
-
});
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
1751
|
-
function isElectron(mockUserAgent) {
|
|
1752
|
-
if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
|
|
1805
|
+
/** Update a single request by calling the callback */
|
|
1806
|
+
_updateRequest(request) {
|
|
1807
|
+
request.priority = request.getPriority(request.handle);
|
|
1808
|
+
if (request.priority < 0) {
|
|
1809
|
+
request.resolve(null);
|
|
1810
|
+
return false;
|
|
1811
|
+
}
|
|
1753
1812
|
return true;
|
|
1754
1813
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1814
|
+
};
|
|
1815
|
+
|
|
1816
|
+
// ../loader-utils/src/lib/path-utils/file-aliases.ts
|
|
1817
|
+
var pathPrefix = "";
|
|
1818
|
+
var fileAliases = {};
|
|
1819
|
+
function setPathPrefix(prefix) {
|
|
1820
|
+
pathPrefix = prefix;
|
|
1821
|
+
}
|
|
1822
|
+
function getPathPrefix() {
|
|
1823
|
+
return pathPrefix;
|
|
1824
|
+
}
|
|
1825
|
+
function resolvePath(filename2) {
|
|
1826
|
+
for (const alias in fileAliases) {
|
|
1827
|
+
if (filename2.startsWith(alias)) {
|
|
1828
|
+
const replacement = fileAliases[alias];
|
|
1829
|
+
filename2 = filename2.replace(alias, replacement);
|
|
1830
|
+
}
|
|
1757
1831
|
}
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
if (userAgent && userAgent.indexOf("Electron") >= 0) {
|
|
1761
|
-
return true;
|
|
1832
|
+
if (!filename2.startsWith("http://") && !filename2.startsWith("https://")) {
|
|
1833
|
+
filename2 = `${pathPrefix}${filename2}`;
|
|
1762
1834
|
}
|
|
1763
|
-
return
|
|
1835
|
+
return filename2;
|
|
1764
1836
|
}
|
|
1765
1837
|
|
|
1766
|
-
//
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1838
|
+
// ../loader-utils/src/json-loader.ts
|
|
1839
|
+
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1840
|
+
var JSONLoader = {
|
|
1841
|
+
dataType: null,
|
|
1842
|
+
batchType: null,
|
|
1843
|
+
name: "JSON",
|
|
1844
|
+
id: "json",
|
|
1845
|
+
module: "json",
|
|
1846
|
+
version: VERSION3,
|
|
1847
|
+
extensions: ["json", "geojson"],
|
|
1848
|
+
mimeTypes: ["application/json"],
|
|
1849
|
+
category: "json",
|
|
1850
|
+
text: true,
|
|
1851
|
+
parseTextSync,
|
|
1852
|
+
parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
|
|
1853
|
+
options: {}
|
|
1854
|
+
};
|
|
1855
|
+
function parseTextSync(text) {
|
|
1856
|
+
return JSON.parse(text);
|
|
1770
1857
|
}
|
|
1771
1858
|
|
|
1772
|
-
//
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
var process_ = globalThis.process || {};
|
|
1777
|
-
var console_ = globalThis.console;
|
|
1778
|
-
var navigator_ = globalThis.navigator || {};
|
|
1779
|
-
|
|
1780
|
-
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
|
|
1781
|
-
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
|
|
1782
|
-
var isBrowser4 = isBrowser3();
|
|
1859
|
+
// ../loader-utils/src/lib/node/buffer.browser.ts
|
|
1860
|
+
function toArrayBuffer(buffer) {
|
|
1861
|
+
return buffer;
|
|
1862
|
+
}
|
|
1783
1863
|
|
|
1784
|
-
//
|
|
1785
|
-
function
|
|
1786
|
-
|
|
1787
|
-
const storage = window[type];
|
|
1788
|
-
const x = "__storage_test__";
|
|
1789
|
-
storage.setItem(x, x);
|
|
1790
|
-
storage.removeItem(x);
|
|
1791
|
-
return storage;
|
|
1792
|
-
} catch (e) {
|
|
1793
|
-
return null;
|
|
1794
|
-
}
|
|
1864
|
+
// ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
|
|
1865
|
+
function isBuffer(value) {
|
|
1866
|
+
return value && typeof value === "object" && value.isBuffer;
|
|
1795
1867
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
_defineProperty(this, "storage", void 0);
|
|
1800
|
-
_defineProperty(this, "id", void 0);
|
|
1801
|
-
_defineProperty(this, "config", void 0);
|
|
1802
|
-
this.storage = getStorage(type);
|
|
1803
|
-
this.id = id;
|
|
1804
|
-
this.config = defaultConfig;
|
|
1805
|
-
this._loadConfiguration();
|
|
1868
|
+
function toArrayBuffer2(data) {
|
|
1869
|
+
if (isBuffer(data)) {
|
|
1870
|
+
return toArrayBuffer(data);
|
|
1806
1871
|
}
|
|
1807
|
-
|
|
1808
|
-
return
|
|
1872
|
+
if (data instanceof ArrayBuffer) {
|
|
1873
|
+
return data;
|
|
1809
1874
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
const serialized = JSON.stringify(this.config);
|
|
1814
|
-
this.storage.setItem(this.id, serialized);
|
|
1875
|
+
if (ArrayBuffer.isView(data)) {
|
|
1876
|
+
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
1877
|
+
return data.buffer;
|
|
1815
1878
|
}
|
|
1879
|
+
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
1816
1880
|
}
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
|
|
1822
|
-
}
|
|
1823
|
-
Object.assign(this.config, configuration);
|
|
1824
|
-
return this;
|
|
1881
|
+
if (typeof data === "string") {
|
|
1882
|
+
const text = data;
|
|
1883
|
+
const uint8Array = new TextEncoder().encode(text);
|
|
1884
|
+
return uint8Array.buffer;
|
|
1825
1885
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
// ../../node_modules/@probe.gl/log/dist/utils/formatters.js
|
|
1829
|
-
function formatTime(ms) {
|
|
1830
|
-
let formatted;
|
|
1831
|
-
if (ms < 10) {
|
|
1832
|
-
formatted = "".concat(ms.toFixed(2), "ms");
|
|
1833
|
-
} else if (ms < 100) {
|
|
1834
|
-
formatted = "".concat(ms.toFixed(1), "ms");
|
|
1835
|
-
} else if (ms < 1e3) {
|
|
1836
|
-
formatted = "".concat(ms.toFixed(0), "ms");
|
|
1837
|
-
} else {
|
|
1838
|
-
formatted = "".concat((ms / 1e3).toFixed(2), "s");
|
|
1886
|
+
if (data && typeof data === "object" && data._toArrayBuffer) {
|
|
1887
|
+
return data._toArrayBuffer();
|
|
1839
1888
|
}
|
|
1840
|
-
|
|
1841
|
-
}
|
|
1842
|
-
function leftPad(string) {
|
|
1843
|
-
let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
|
|
1844
|
-
const padLength = Math.max(length - string.length, 0);
|
|
1845
|
-
return "".concat(" ".repeat(padLength)).concat(string);
|
|
1889
|
+
throw new Error("toArrayBuffer");
|
|
1846
1890
|
}
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1891
|
+
|
|
1892
|
+
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1893
|
+
var path_exports = {};
|
|
1894
|
+
__export(path_exports, {
|
|
1895
|
+
dirname: () => dirname,
|
|
1896
|
+
filename: () => filename,
|
|
1897
|
+
join: () => join,
|
|
1898
|
+
resolve: () => resolve
|
|
1899
|
+
});
|
|
1900
|
+
|
|
1901
|
+
// ../loader-utils/src/lib/path-utils/get-cwd.ts
|
|
1902
|
+
function getCWD() {
|
|
1903
|
+
if (typeof process !== "undefined" && typeof process.cwd !== "undefined") {
|
|
1904
|
+
return process.cwd();
|
|
1852
1905
|
}
|
|
1853
|
-
const
|
|
1854
|
-
|
|
1855
|
-
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("");
|
|
1856
|
-
return ["".concat(message, " %c+"), style];
|
|
1906
|
+
const pathname = window.location?.pathname;
|
|
1907
|
+
return pathname?.slice(0, pathname.lastIndexOf("/") + 1) || "";
|
|
1857
1908
|
}
|
|
1858
1909
|
|
|
1859
|
-
//
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
COLOR2[COLOR2["RED"] = 31] = "RED";
|
|
1864
|
-
COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
|
|
1865
|
-
COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
|
|
1866
|
-
COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
|
|
1867
|
-
COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
|
|
1868
|
-
COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
|
|
1869
|
-
COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
|
|
1870
|
-
COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
|
|
1871
|
-
COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
|
|
1872
|
-
COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
|
|
1873
|
-
COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
|
|
1874
|
-
COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
|
|
1875
|
-
COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
|
|
1876
|
-
COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
|
|
1877
|
-
COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
|
|
1878
|
-
})(COLOR || (COLOR = {}));
|
|
1879
|
-
var BACKGROUND_INCREMENT = 10;
|
|
1880
|
-
function getColor(color) {
|
|
1881
|
-
if (typeof color !== "string") {
|
|
1882
|
-
return color;
|
|
1883
|
-
}
|
|
1884
|
-
color = color.toUpperCase();
|
|
1885
|
-
return COLOR[color] || COLOR.WHITE;
|
|
1910
|
+
// ../loader-utils/src/lib/path-utils/path.ts
|
|
1911
|
+
function filename(url) {
|
|
1912
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1913
|
+
return slashIndex >= 0 ? url.substr(slashIndex + 1) : "";
|
|
1886
1914
|
}
|
|
1887
|
-
function
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1915
|
+
function dirname(url) {
|
|
1916
|
+
const slashIndex = url ? url.lastIndexOf("/") : -1;
|
|
1917
|
+
return slashIndex >= 0 ? url.substr(0, slashIndex) : "";
|
|
1918
|
+
}
|
|
1919
|
+
function join(...parts) {
|
|
1920
|
+
const separator = "/";
|
|
1921
|
+
parts = parts.map((part, index) => {
|
|
1922
|
+
if (index) {
|
|
1923
|
+
part = part.replace(new RegExp(`^${separator}`), "");
|
|
1892
1924
|
}
|
|
1893
|
-
if (
|
|
1894
|
-
|
|
1895
|
-
string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
|
|
1925
|
+
if (index !== parts.length - 1) {
|
|
1926
|
+
part = part.replace(new RegExp(`${separator}$`), "");
|
|
1896
1927
|
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1928
|
+
return part;
|
|
1929
|
+
});
|
|
1930
|
+
return parts.join(separator);
|
|
1899
1931
|
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1932
|
+
function resolve(...components) {
|
|
1933
|
+
const paths = [];
|
|
1934
|
+
for (let _i = 0; _i < components.length; _i++) {
|
|
1935
|
+
paths[_i] = components[_i];
|
|
1936
|
+
}
|
|
1937
|
+
let resolvedPath = "";
|
|
1938
|
+
let resolvedAbsolute = false;
|
|
1939
|
+
let cwd;
|
|
1940
|
+
for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
1941
|
+
let path;
|
|
1942
|
+
if (i >= 0) {
|
|
1943
|
+
path = paths[i];
|
|
1944
|
+
} else {
|
|
1945
|
+
if (cwd === void 0) {
|
|
1946
|
+
cwd = getCWD();
|
|
1912
1947
|
}
|
|
1948
|
+
path = cwd;
|
|
1949
|
+
}
|
|
1950
|
+
if (path.length === 0) {
|
|
1951
|
+
continue;
|
|
1913
1952
|
}
|
|
1953
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
1954
|
+
resolvedAbsolute = path.charCodeAt(0) === SLASH;
|
|
1914
1955
|
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
throw new Error(message || "Assertion failed");
|
|
1956
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
1957
|
+
if (resolvedAbsolute) {
|
|
1958
|
+
return `/${resolvedPath}`;
|
|
1959
|
+
} else if (resolvedPath.length > 0) {
|
|
1960
|
+
return resolvedPath;
|
|
1921
1961
|
}
|
|
1962
|
+
return ".";
|
|
1922
1963
|
}
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
function
|
|
1926
|
-
let
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1964
|
+
var SLASH = 47;
|
|
1965
|
+
var DOT = 46;
|
|
1966
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
1967
|
+
let res = "";
|
|
1968
|
+
let lastSlash = -1;
|
|
1969
|
+
let dots = 0;
|
|
1970
|
+
let code;
|
|
1971
|
+
let isAboveRoot = false;
|
|
1972
|
+
for (let i = 0; i <= path.length; ++i) {
|
|
1973
|
+
if (i < path.length) {
|
|
1974
|
+
code = path.charCodeAt(i);
|
|
1975
|
+
} else if (code === SLASH) {
|
|
1976
|
+
break;
|
|
1977
|
+
} else {
|
|
1978
|
+
code = SLASH;
|
|
1979
|
+
}
|
|
1980
|
+
if (code === SLASH) {
|
|
1981
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
1982
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
1983
|
+
if (res.length < 2 || !isAboveRoot || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
|
|
1984
|
+
if (res.length > 2) {
|
|
1985
|
+
const start = res.length - 1;
|
|
1986
|
+
let j = start;
|
|
1987
|
+
for (; j >= 0; --j) {
|
|
1988
|
+
if (res.charCodeAt(j) === SLASH) {
|
|
1989
|
+
break;
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
if (j !== start) {
|
|
1993
|
+
res = j === -1 ? "" : res.slice(0, j);
|
|
1994
|
+
lastSlash = i;
|
|
1995
|
+
dots = 0;
|
|
1996
|
+
isAboveRoot = false;
|
|
1997
|
+
continue;
|
|
1998
|
+
}
|
|
1999
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
2000
|
+
res = "";
|
|
2001
|
+
lastSlash = i;
|
|
2002
|
+
dots = 0;
|
|
2003
|
+
isAboveRoot = false;
|
|
2004
|
+
continue;
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
if (allowAboveRoot) {
|
|
2008
|
+
if (res.length > 0) {
|
|
2009
|
+
res += "/..";
|
|
2010
|
+
} else {
|
|
2011
|
+
res = "..";
|
|
2012
|
+
}
|
|
2013
|
+
isAboveRoot = true;
|
|
2014
|
+
}
|
|
2015
|
+
} else {
|
|
2016
|
+
const slice = path.slice(lastSlash + 1, i);
|
|
2017
|
+
if (res.length > 0) {
|
|
2018
|
+
res += `/${slice}`;
|
|
2019
|
+
} else {
|
|
2020
|
+
res = slice;
|
|
2021
|
+
}
|
|
2022
|
+
isAboveRoot = false;
|
|
2023
|
+
}
|
|
2024
|
+
lastSlash = i;
|
|
2025
|
+
dots = 0;
|
|
2026
|
+
} else if (code === DOT && dots !== -1) {
|
|
2027
|
+
++dots;
|
|
2028
|
+
} else {
|
|
2029
|
+
dots = -1;
|
|
2030
|
+
}
|
|
1936
2031
|
}
|
|
1937
|
-
return
|
|
2032
|
+
return res;
|
|
1938
2033
|
}
|
|
1939
2034
|
|
|
1940
|
-
//
|
|
1941
|
-
var
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
};
|
|
1952
|
-
function noop() {
|
|
1953
|
-
}
|
|
1954
|
-
var cache = {};
|
|
1955
|
-
var ONCE = {
|
|
1956
|
-
once: true
|
|
1957
|
-
};
|
|
1958
|
-
var Log = class {
|
|
1959
|
-
constructor() {
|
|
1960
|
-
let {
|
|
1961
|
-
id
|
|
1962
|
-
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
1963
|
-
id: ""
|
|
1964
|
-
};
|
|
1965
|
-
_defineProperty(this, "id", void 0);
|
|
1966
|
-
_defineProperty(this, "VERSION", VERSION3);
|
|
1967
|
-
_defineProperty(this, "_startTs", getHiResTimestamp2());
|
|
1968
|
-
_defineProperty(this, "_deltaTs", getHiResTimestamp2());
|
|
1969
|
-
_defineProperty(this, "_storage", void 0);
|
|
1970
|
-
_defineProperty(this, "userData", {});
|
|
1971
|
-
_defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
|
|
1972
|
-
this.id = id;
|
|
1973
|
-
this.userData = {};
|
|
1974
|
-
this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
|
|
1975
|
-
this.timeStamp("".concat(this.id, " started"));
|
|
1976
|
-
autobind(this);
|
|
1977
|
-
Object.seal(this);
|
|
1978
|
-
}
|
|
1979
|
-
set level(newLevel) {
|
|
1980
|
-
this.setLevel(newLevel);
|
|
1981
|
-
}
|
|
1982
|
-
get level() {
|
|
1983
|
-
return this.getLevel();
|
|
1984
|
-
}
|
|
1985
|
-
isEnabled() {
|
|
1986
|
-
return this._storage.config.enabled;
|
|
1987
|
-
}
|
|
1988
|
-
getLevel() {
|
|
1989
|
-
return this._storage.config.level;
|
|
1990
|
-
}
|
|
1991
|
-
getTotal() {
|
|
1992
|
-
return Number((getHiResTimestamp2() - this._startTs).toPrecision(10));
|
|
2035
|
+
// ../loader-utils/src/lib/files/blob-file.ts
|
|
2036
|
+
var BlobFile = class {
|
|
2037
|
+
handle;
|
|
2038
|
+
size;
|
|
2039
|
+
bigsize;
|
|
2040
|
+
url;
|
|
2041
|
+
constructor(blob) {
|
|
2042
|
+
this.handle = blob instanceof ArrayBuffer ? new Blob([blob]) : blob;
|
|
2043
|
+
this.size = blob instanceof ArrayBuffer ? blob.byteLength : blob.size;
|
|
2044
|
+
this.bigsize = BigInt(this.size);
|
|
2045
|
+
this.url = blob instanceof File ? blob.name : "";
|
|
1993
2046
|
}
|
|
1994
|
-
|
|
1995
|
-
return Number((getHiResTimestamp2() - this._deltaTs).toPrecision(10));
|
|
2047
|
+
async close() {
|
|
1996
2048
|
}
|
|
1997
|
-
|
|
1998
|
-
|
|
2049
|
+
async stat() {
|
|
2050
|
+
return {
|
|
2051
|
+
size: this.handle.size,
|
|
2052
|
+
bigsize: BigInt(this.handle.size),
|
|
2053
|
+
isDirectory: false
|
|
2054
|
+
};
|
|
1999
2055
|
}
|
|
2000
|
-
|
|
2001
|
-
|
|
2056
|
+
async read(start, length) {
|
|
2057
|
+
const arrayBuffer = await this.handle.slice(start, start + length).arrayBuffer();
|
|
2058
|
+
return arrayBuffer;
|
|
2002
2059
|
}
|
|
2003
|
-
|
|
2004
|
-
|
|
2060
|
+
};
|
|
2061
|
+
|
|
2062
|
+
// ../loader-utils/src/lib/files/node-file-facade.ts
|
|
2063
|
+
var NOT_IMPLEMENTED = new Error("Not implemented");
|
|
2064
|
+
var NodeFileFacade = class {
|
|
2065
|
+
handle;
|
|
2066
|
+
size = 0;
|
|
2067
|
+
bigsize = 0n;
|
|
2068
|
+
url = "";
|
|
2069
|
+
constructor(url, flags, mode) {
|
|
2070
|
+
if (globalThis.loaders?.NodeFile) {
|
|
2071
|
+
return new globalThis.loaders.NodeFile(url, flags, mode);
|
|
2072
|
+
}
|
|
2073
|
+
if (isBrowser) {
|
|
2074
|
+
throw new Error("Can't instantiate NodeFile in browser.");
|
|
2075
|
+
}
|
|
2076
|
+
throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
|
|
2005
2077
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
enabled
|
|
2010
|
-
});
|
|
2011
|
-
return this;
|
|
2078
|
+
/** Read data */
|
|
2079
|
+
async read(start, end) {
|
|
2080
|
+
throw NOT_IMPLEMENTED;
|
|
2012
2081
|
}
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
});
|
|
2017
|
-
return this;
|
|
2082
|
+
/** Write to file. The number of bytes written will be returned */
|
|
2083
|
+
async write(arrayBuffer, offset, length) {
|
|
2084
|
+
throw NOT_IMPLEMENTED;
|
|
2018
2085
|
}
|
|
2019
|
-
|
|
2020
|
-
|
|
2086
|
+
/** Get information about file */
|
|
2087
|
+
async stat() {
|
|
2088
|
+
throw NOT_IMPLEMENTED;
|
|
2021
2089
|
}
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
});
|
|
2090
|
+
/** Truncates the file descriptor. Only available on NodeFile. */
|
|
2091
|
+
async truncate(length) {
|
|
2092
|
+
throw NOT_IMPLEMENTED;
|
|
2026
2093
|
}
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
} else {
|
|
2031
|
-
console.log(this._storage.config);
|
|
2032
|
-
}
|
|
2094
|
+
/** Append data to a file. Only available on NodeFile. */
|
|
2095
|
+
async append(data) {
|
|
2096
|
+
throw NOT_IMPLEMENTED;
|
|
2033
2097
|
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2098
|
+
/** Close the file */
|
|
2099
|
+
async close() {
|
|
2036
2100
|
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2101
|
+
};
|
|
2102
|
+
|
|
2103
|
+
// src/javascript-utils/is-type.ts
|
|
2104
|
+
var isBoolean = (x) => typeof x === "boolean";
|
|
2105
|
+
var isFunction = (x) => typeof x === "function";
|
|
2106
|
+
var isObject = (x) => x !== null && typeof x === "object";
|
|
2107
|
+
var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
|
|
2108
|
+
var isPromise = (x) => isObject(x) && isFunction(x.then);
|
|
2109
|
+
var isIterable = (x) => Boolean(x) && typeof x[Symbol.iterator] === "function";
|
|
2110
|
+
var isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
|
|
2111
|
+
var isIterator = (x) => x && isFunction(x.next);
|
|
2112
|
+
var isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
|
|
2113
|
+
var isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
|
|
2114
|
+
var isBuffer2 = (x) => x && typeof x === "object" && x.isBuffer;
|
|
2115
|
+
var isWritableDOMStream = (x) => isObject(x) && isFunction(x.abort) && isFunction(x.getWriter);
|
|
2116
|
+
var isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
|
|
2117
|
+
var isWritableNodeStream = (x) => isObject(x) && isFunction(x.end) && isFunction(x.write) && isBoolean(x.writable);
|
|
2118
|
+
var isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
|
|
2119
|
+
var isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
|
|
2120
|
+
var isWritableStream = (x) => isWritableDOMStream(x) || isWritableNodeStream(x);
|
|
2121
|
+
|
|
2122
|
+
// src/lib/fetch/fetch-error.ts
|
|
2123
|
+
var FetchError = class extends Error {
|
|
2124
|
+
constructor(message, info) {
|
|
2125
|
+
super(message);
|
|
2126
|
+
this.reason = info.reason;
|
|
2127
|
+
this.url = info.url;
|
|
2128
|
+
this.response = info.response;
|
|
2129
|
+
}
|
|
2130
|
+
/** A best effort reason for why the fetch failed */
|
|
2131
|
+
reason;
|
|
2132
|
+
/** The URL that failed to load. Empty string if not available. */
|
|
2133
|
+
url;
|
|
2134
|
+
/** The Response object, if any. */
|
|
2135
|
+
response;
|
|
2136
|
+
};
|
|
2137
|
+
|
|
2138
|
+
// src/lib/utils/mime-type-utils.ts
|
|
2139
|
+
var DATA_URL_PATTERN = /^data:([-\w.]+\/[-\w.+]+)(;|,)/;
|
|
2140
|
+
var MIME_TYPE_PATTERN = /^([-\w.]+\/[-\w.+]+)/;
|
|
2141
|
+
function compareMIMETypes(mimeType1, mimeType2) {
|
|
2142
|
+
if (mimeType1.toLowerCase() === mimeType2.toLowerCase()) {
|
|
2143
|
+
return true;
|
|
2039
2144
|
}
|
|
2040
|
-
|
|
2041
|
-
|
|
2145
|
+
return false;
|
|
2146
|
+
}
|
|
2147
|
+
function parseMIMEType(mimeString) {
|
|
2148
|
+
const matches3 = MIME_TYPE_PATTERN.exec(mimeString);
|
|
2149
|
+
if (matches3) {
|
|
2150
|
+
return matches3[1];
|
|
2042
2151
|
}
|
|
2043
|
-
|
|
2044
|
-
|
|
2152
|
+
return mimeString;
|
|
2153
|
+
}
|
|
2154
|
+
function parseMIMETypeFromURL(url) {
|
|
2155
|
+
const matches3 = DATA_URL_PATTERN.exec(url);
|
|
2156
|
+
if (matches3) {
|
|
2157
|
+
return matches3[1];
|
|
2045
2158
|
}
|
|
2046
|
-
|
|
2047
|
-
|
|
2159
|
+
return "";
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
// src/lib/utils/url-utils.ts
|
|
2163
|
+
var QUERY_STRING_PATTERN = /\?.*/;
|
|
2164
|
+
function extractQueryString(url) {
|
|
2165
|
+
const matches3 = url.match(QUERY_STRING_PATTERN);
|
|
2166
|
+
return matches3 && matches3[0];
|
|
2167
|
+
}
|
|
2168
|
+
function stripQueryString(url) {
|
|
2169
|
+
return url.replace(QUERY_STRING_PATTERN, "");
|
|
2170
|
+
}
|
|
2171
|
+
function shortenUrlForDisplay(url) {
|
|
2172
|
+
if (url.length < 50) {
|
|
2173
|
+
return url;
|
|
2048
2174
|
}
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2175
|
+
const urlEnd = url.slice(url.length - 15);
|
|
2176
|
+
const urlStart = url.substr(0, 32);
|
|
2177
|
+
return `${urlStart}...${urlEnd}`;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
// src/lib/utils/resource-utils.ts
|
|
2181
|
+
function getResourceUrl(resource) {
|
|
2182
|
+
if (isResponse(resource)) {
|
|
2183
|
+
const response = resource;
|
|
2184
|
+
return response.url;
|
|
2054
2185
|
}
|
|
2055
|
-
|
|
2056
|
-
|
|
2186
|
+
if (isBlob(resource)) {
|
|
2187
|
+
const blob = resource;
|
|
2188
|
+
return blob.name || "";
|
|
2057
2189
|
}
|
|
2058
|
-
|
|
2059
|
-
return
|
|
2190
|
+
if (typeof resource === "string") {
|
|
2191
|
+
return resource;
|
|
2060
2192
|
}
|
|
2061
|
-
|
|
2062
|
-
|
|
2193
|
+
return "";
|
|
2194
|
+
}
|
|
2195
|
+
function getResourceMIMEType(resource) {
|
|
2196
|
+
if (isResponse(resource)) {
|
|
2197
|
+
const response = resource;
|
|
2198
|
+
const contentTypeHeader = response.headers.get("content-type") || "";
|
|
2199
|
+
const noQueryUrl = stripQueryString(response.url);
|
|
2200
|
+
return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);
|
|
2063
2201
|
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
tag: getTableHeader(table)
|
|
2068
|
-
});
|
|
2069
|
-
}
|
|
2070
|
-
return noop;
|
|
2202
|
+
if (isBlob(resource)) {
|
|
2203
|
+
const blob = resource;
|
|
2204
|
+
return blob.type || "";
|
|
2071
2205
|
}
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
logLevel,
|
|
2075
|
-
priority,
|
|
2076
|
-
image,
|
|
2077
|
-
message = "",
|
|
2078
|
-
scale = 1
|
|
2079
|
-
} = _ref;
|
|
2080
|
-
if (!this._shouldLog(logLevel || priority)) {
|
|
2081
|
-
return noop;
|
|
2082
|
-
}
|
|
2083
|
-
return isBrowser3() ? logImageInBrowser({
|
|
2084
|
-
image,
|
|
2085
|
-
message,
|
|
2086
|
-
scale
|
|
2087
|
-
}) : logImageInNode({
|
|
2088
|
-
image,
|
|
2089
|
-
message,
|
|
2090
|
-
scale
|
|
2091
|
-
});
|
|
2206
|
+
if (typeof resource === "string") {
|
|
2207
|
+
return parseMIMETypeFromURL(resource);
|
|
2092
2208
|
}
|
|
2093
|
-
|
|
2094
|
-
|
|
2209
|
+
return "";
|
|
2210
|
+
}
|
|
2211
|
+
function getResourceContentLength(resource) {
|
|
2212
|
+
if (isResponse(resource)) {
|
|
2213
|
+
const response = resource;
|
|
2214
|
+
return response.headers["content-length"] || -1;
|
|
2095
2215
|
}
|
|
2096
|
-
|
|
2097
|
-
|
|
2216
|
+
if (isBlob(resource)) {
|
|
2217
|
+
const blob = resource;
|
|
2218
|
+
return blob.size;
|
|
2098
2219
|
}
|
|
2099
|
-
|
|
2100
|
-
return
|
|
2220
|
+
if (typeof resource === "string") {
|
|
2221
|
+
return resource.length;
|
|
2101
2222
|
}
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
collapsed: false
|
|
2105
|
-
};
|
|
2106
|
-
const options = normalizeArguments({
|
|
2107
|
-
logLevel,
|
|
2108
|
-
message,
|
|
2109
|
-
opts
|
|
2110
|
-
});
|
|
2111
|
-
const {
|
|
2112
|
-
collapsed
|
|
2113
|
-
} = opts;
|
|
2114
|
-
options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
|
|
2115
|
-
return this._getLogFunction(options);
|
|
2223
|
+
if (resource instanceof ArrayBuffer) {
|
|
2224
|
+
return resource.byteLength;
|
|
2116
2225
|
}
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
return this.group(logLevel, message, Object.assign({}, opts, {
|
|
2120
|
-
collapsed: true
|
|
2121
|
-
}));
|
|
2226
|
+
if (ArrayBuffer.isView(resource)) {
|
|
2227
|
+
return resource.byteLength;
|
|
2122
2228
|
}
|
|
2123
|
-
|
|
2124
|
-
|
|
2229
|
+
return -1;
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
// src/lib/utils/response-utils.ts
|
|
2233
|
+
async function makeResponse(resource) {
|
|
2234
|
+
if (isResponse(resource)) {
|
|
2235
|
+
return resource;
|
|
2125
2236
|
}
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
} finally {
|
|
2131
|
-
this.groupEnd(logLevel)();
|
|
2132
|
-
}
|
|
2237
|
+
const headers = {};
|
|
2238
|
+
const contentLength = getResourceContentLength(resource);
|
|
2239
|
+
if (contentLength >= 0) {
|
|
2240
|
+
headers["content-length"] = String(contentLength);
|
|
2133
2241
|
}
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2242
|
+
const url = getResourceUrl(resource);
|
|
2243
|
+
const type = getResourceMIMEType(resource);
|
|
2244
|
+
if (type) {
|
|
2245
|
+
headers["content-type"] = type;
|
|
2138
2246
|
}
|
|
2139
|
-
|
|
2140
|
-
|
|
2247
|
+
const initialDataUrl = await getInitialDataUrl(resource);
|
|
2248
|
+
if (initialDataUrl) {
|
|
2249
|
+
headers["x-first-bytes"] = initialDataUrl;
|
|
2141
2250
|
}
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
opts = normalizeArguments({
|
|
2145
|
-
logLevel,
|
|
2146
|
-
message,
|
|
2147
|
-
args,
|
|
2148
|
-
opts
|
|
2149
|
-
});
|
|
2150
|
-
method = method || opts.method;
|
|
2151
|
-
assert3(method);
|
|
2152
|
-
opts.total = this.getTotal();
|
|
2153
|
-
opts.delta = this.getDelta();
|
|
2154
|
-
this._deltaTs = getHiResTimestamp2();
|
|
2155
|
-
const tag = opts.tag || opts.message;
|
|
2156
|
-
if (opts.once && tag) {
|
|
2157
|
-
if (!cache[tag]) {
|
|
2158
|
-
cache[tag] = getHiResTimestamp2();
|
|
2159
|
-
} else {
|
|
2160
|
-
return noop;
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
message = decorateMessage(this.id, opts.message, opts);
|
|
2164
|
-
return method.bind(console, message, ...opts.args);
|
|
2165
|
-
}
|
|
2166
|
-
return noop;
|
|
2251
|
+
if (typeof resource === "string") {
|
|
2252
|
+
resource = new TextEncoder().encode(resource);
|
|
2167
2253
|
}
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2254
|
+
const response = new Response(resource, { headers });
|
|
2255
|
+
Object.defineProperty(response, "url", { value: url });
|
|
2256
|
+
return response;
|
|
2257
|
+
}
|
|
2258
|
+
async function checkResponse(response) {
|
|
2259
|
+
if (!response.ok) {
|
|
2260
|
+
const error = await getResponseError(response);
|
|
2261
|
+
throw error;
|
|
2173
2262
|
}
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2263
|
+
}
|
|
2264
|
+
async function getResponseError(response) {
|
|
2265
|
+
const shortUrl = shortenUrlForDisplay(response.url);
|
|
2266
|
+
let message = `Failed to fetch resource (${response.status}) ${response.statusText}: ${shortUrl}`;
|
|
2267
|
+
message = message.length > 100 ? `${message.slice(0, 100)}...` : message;
|
|
2268
|
+
const info = {
|
|
2269
|
+
reason: response.statusText,
|
|
2270
|
+
url: response.url,
|
|
2271
|
+
response
|
|
2272
|
+
};
|
|
2273
|
+
try {
|
|
2274
|
+
const contentType = response.headers.get("Content-Type");
|
|
2275
|
+
info.reason = contentType?.includes("application/json") ? await response.json() : response.text();
|
|
2276
|
+
} catch (error) {
|
|
2184
2277
|
}
|
|
2185
|
-
|
|
2186
|
-
return resolvedLevel;
|
|
2278
|
+
return new FetchError(message, info);
|
|
2187
2279
|
}
|
|
2188
|
-
function
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
} = opts;
|
|
2193
|
-
opts.logLevel = normalizeLogLevel(logLevel);
|
|
2194
|
-
const args = opts.args ? Array.from(opts.args) : [];
|
|
2195
|
-
while (args.length && args.shift() !== message) {
|
|
2280
|
+
async function getInitialDataUrl(resource) {
|
|
2281
|
+
const INITIAL_DATA_LENGTH = 5;
|
|
2282
|
+
if (typeof resource === "string") {
|
|
2283
|
+
return `data:,${resource.slice(0, INITIAL_DATA_LENGTH)}`;
|
|
2196
2284
|
}
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
break;
|
|
2205
|
-
case "object":
|
|
2206
|
-
Object.assign(opts, logLevel);
|
|
2207
|
-
break;
|
|
2208
|
-
default:
|
|
2285
|
+
if (resource instanceof Blob) {
|
|
2286
|
+
const blobSlice = resource.slice(0, 5);
|
|
2287
|
+
return await new Promise((resolve2) => {
|
|
2288
|
+
const reader = new FileReader();
|
|
2289
|
+
reader.onload = (event) => resolve2(event?.target?.result);
|
|
2290
|
+
reader.readAsDataURL(blobSlice);
|
|
2291
|
+
});
|
|
2209
2292
|
}
|
|
2210
|
-
if (
|
|
2211
|
-
|
|
2293
|
+
if (resource instanceof ArrayBuffer) {
|
|
2294
|
+
const slice = resource.slice(0, INITIAL_DATA_LENGTH);
|
|
2295
|
+
const base64 = arrayBufferToBase64(slice);
|
|
2296
|
+
return `data:base64,${base64}`;
|
|
2212
2297
|
}
|
|
2213
|
-
|
|
2214
|
-
assert3(messageType === "string" || messageType === "object");
|
|
2215
|
-
return Object.assign(opts, {
|
|
2216
|
-
args
|
|
2217
|
-
}, opts.opts);
|
|
2298
|
+
return null;
|
|
2218
2299
|
}
|
|
2219
|
-
function
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2300
|
+
function arrayBufferToBase64(buffer) {
|
|
2301
|
+
let binary = "";
|
|
2302
|
+
const bytes = new Uint8Array(buffer);
|
|
2303
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
2304
|
+
binary += String.fromCharCode(bytes[i]);
|
|
2224
2305
|
}
|
|
2225
|
-
return
|
|
2306
|
+
return btoa(binary);
|
|
2226
2307
|
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
scale = 1
|
|
2232
|
-
} = _ref2;
|
|
2233
|
-
console.warn("removed");
|
|
2234
|
-
return noop;
|
|
2308
|
+
|
|
2309
|
+
// src/lib/fetch/fetch-file.ts
|
|
2310
|
+
function isNodePath(url) {
|
|
2311
|
+
return !isRequestURL(url) && !isDataURL(url);
|
|
2235
2312
|
}
|
|
2236
|
-
function
|
|
2237
|
-
|
|
2238
|
-
image,
|
|
2239
|
-
message = "",
|
|
2240
|
-
scale = 1
|
|
2241
|
-
} = _ref3;
|
|
2242
|
-
if (typeof image === "string") {
|
|
2243
|
-
const img = new Image();
|
|
2244
|
-
img.onload = () => {
|
|
2245
|
-
const args = formatImage(img, message, scale);
|
|
2246
|
-
console.log(...args);
|
|
2247
|
-
};
|
|
2248
|
-
img.src = image;
|
|
2249
|
-
return noop;
|
|
2250
|
-
}
|
|
2251
|
-
const element = image.nodeName || "";
|
|
2252
|
-
if (element.toLowerCase() === "img") {
|
|
2253
|
-
console.log(...formatImage(image, message, scale));
|
|
2254
|
-
return noop;
|
|
2255
|
-
}
|
|
2256
|
-
if (element.toLowerCase() === "canvas") {
|
|
2257
|
-
const img = new Image();
|
|
2258
|
-
img.onload = () => console.log(...formatImage(img, message, scale));
|
|
2259
|
-
img.src = image.toDataURL();
|
|
2260
|
-
return noop;
|
|
2261
|
-
}
|
|
2262
|
-
return noop;
|
|
2313
|
+
function isRequestURL(url) {
|
|
2314
|
+
return url.startsWith("http:") || url.startsWith("https:");
|
|
2263
2315
|
}
|
|
2264
|
-
function
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2316
|
+
function isDataURL(url) {
|
|
2317
|
+
return url.startsWith("data:");
|
|
2318
|
+
}
|
|
2319
|
+
async function fetchFile(urlOrData, fetchOptions) {
|
|
2320
|
+
if (typeof urlOrData === "string") {
|
|
2321
|
+
const url = resolvePath(urlOrData);
|
|
2322
|
+
if (isNodePath(url)) {
|
|
2323
|
+
if (globalThis.loaders?.fetchNode) {
|
|
2324
|
+
return globalThis.loaders?.fetchNode(url, fetchOptions);
|
|
2325
|
+
}
|
|
2268
2326
|
}
|
|
2327
|
+
return await fetch(url, fetchOptions);
|
|
2269
2328
|
}
|
|
2270
|
-
return
|
|
2329
|
+
return await makeResponse(urlOrData);
|
|
2271
2330
|
}
|
|
2272
2331
|
|
|
2273
|
-
//
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2332
|
+
// src/lib/fetch/read-array-buffer.ts
|
|
2333
|
+
async function readArrayBuffer(file, start, length) {
|
|
2334
|
+
if (!(file instanceof Blob)) {
|
|
2335
|
+
file = new Blob([file]);
|
|
2336
|
+
}
|
|
2337
|
+
const slice = file.slice(start, start + length);
|
|
2338
|
+
return await readBlob(slice);
|
|
2339
|
+
}
|
|
2340
|
+
async function readBlob(blob) {
|
|
2341
|
+
return await new Promise((resolve2, reject) => {
|
|
2342
|
+
const fileReader = new FileReader();
|
|
2343
|
+
fileReader.onload = (event) => resolve2(event?.target?.result);
|
|
2344
|
+
fileReader.onerror = (error) => reject(error);
|
|
2345
|
+
fileReader.readAsArrayBuffer(blob);
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2277
2348
|
|
|
2278
2349
|
// src/lib/loader-utils/loggers.ts
|
|
2279
2350
|
var probeLog = new Log({ id: "loaders.gl" });
|
|
@@ -2296,6 +2367,7 @@ var __exports__ = (() => {
|
|
|
2296
2367
|
}
|
|
2297
2368
|
};
|
|
2298
2369
|
var ConsoleLog = class {
|
|
2370
|
+
console;
|
|
2299
2371
|
constructor() {
|
|
2300
2372
|
this.console = console;
|
|
2301
2373
|
}
|
|
@@ -2380,6 +2452,7 @@ var __exports__ = (() => {
|
|
|
2380
2452
|
const state = getGlobalLoaderState();
|
|
2381
2453
|
const globalOptions = getGlobalLoaderOptions();
|
|
2382
2454
|
state.globalOptions = normalizeOptionsInternal(globalOptions, options);
|
|
2455
|
+
registerJSModules(options.modules);
|
|
2383
2456
|
}
|
|
2384
2457
|
function normalizeOptions(options, loader, loaders, url) {
|
|
2385
2458
|
loaders = loaders || [];
|
|
@@ -2632,10 +2705,10 @@ var __exports__ = (() => {
|
|
|
2632
2705
|
}
|
|
2633
2706
|
function findLoaderByMIMEType(loaders, mimeType) {
|
|
2634
2707
|
for (const loader of loaders) {
|
|
2635
|
-
if (loader.mimeTypes
|
|
2708
|
+
if (loader.mimeTypes?.some((mimeType1) => compareMIMETypes(mimeType, mimeType1))) {
|
|
2636
2709
|
return loader;
|
|
2637
2710
|
}
|
|
2638
|
-
if (mimeType
|
|
2711
|
+
if (compareMIMETypes(mimeType, `application/x.${loader.id}`)) {
|
|
2639
2712
|
return loader;
|
|
2640
2713
|
}
|
|
2641
2714
|
}
|
|
@@ -2994,7 +3067,7 @@ var __exports__ = (() => {
|
|
|
2994
3067
|
if (loaderWithParser.parse) {
|
|
2995
3068
|
return await loaderWithParser.parse(data, options, context);
|
|
2996
3069
|
}
|
|
2997
|
-
|
|
3070
|
+
assert3(!loaderWithParser.parseSync);
|
|
2998
3071
|
throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
|
|
2999
3072
|
}
|
|
3000
3073
|
|
|
@@ -3375,6 +3448,8 @@ var __exports__ = (() => {
|
|
|
3375
3448
|
// src/null-loader.ts
|
|
3376
3449
|
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
3377
3450
|
var NullWorkerLoader = {
|
|
3451
|
+
dataType: null,
|
|
3452
|
+
batchType: null,
|
|
3378
3453
|
name: "Null loader",
|
|
3379
3454
|
id: "null",
|
|
3380
3455
|
module: "core",
|
|
@@ -3388,6 +3463,8 @@ var __exports__ = (() => {
|
|
|
3388
3463
|
}
|
|
3389
3464
|
};
|
|
3390
3465
|
var NullLoader = {
|
|
3466
|
+
dataType: null,
|
|
3467
|
+
batchType: null,
|
|
3391
3468
|
name: "Null loader",
|
|
3392
3469
|
id: "null",
|
|
3393
3470
|
module: "core",
|
|
@@ -3459,15 +3536,16 @@ var __exports__ = (() => {
|
|
|
3459
3536
|
|
|
3460
3537
|
// src/lib/filesystems/browser-filesystem.ts
|
|
3461
3538
|
var BrowserFileSystem = class {
|
|
3539
|
+
_fetch;
|
|
3540
|
+
files = {};
|
|
3541
|
+
lowerCaseFiles = {};
|
|
3542
|
+
usedFiles = {};
|
|
3462
3543
|
/**
|
|
3463
3544
|
* A FileSystem API wrapper around a list of browser 'File' objects
|
|
3464
3545
|
* @param files
|
|
3465
3546
|
* @param options
|
|
3466
3547
|
*/
|
|
3467
3548
|
constructor(files, options) {
|
|
3468
|
-
this.files = {};
|
|
3469
|
-
this.lowerCaseFiles = {};
|
|
3470
|
-
this.usedFiles = {};
|
|
3471
3549
|
this._fetch = options?.fetch || fetch;
|
|
3472
3550
|
for (let i = 0; i < files.length; ++i) {
|
|
3473
3551
|
const file = files[i];
|