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