UNPKG

deck.gl

Version:

A suite of 3D-enabled data visualization overlays, suitable for react-map-gl

1,409 lines (1,384 loc) 3.43 MB
(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['deck'] = factory(); else root['deck'] = factory();})(globalThis, function () { "use strict"; var __exports__ = (() => { var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, { get: (a4, b3) => (typeof require !== "undefined" ? require : a4)[b3] }) : x2)(function(x2) { if (typeof require !== "undefined") return require.apply(this, arguments); throw new Error('Dynamic require of "' + x2 + '" is not supported'); }); var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod3) => function __require2() { return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports; }; var __export = (target2, all) => { for (var name13 in all) __defProp(target2, name13, { get: all[name13], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod3, isNodeMode, target2) => (target2 = mod3 != null ? __create(__getProtoOf(mod3)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod3 || !mod3.__esModule ? __defProp(target2, "default", { value: mod3, enumerable: true }) : target2, mod3 )); var __toCommonJS = (mod3) => __copyProps(__defProp({}, "__esModule", { value: true }), mod3); var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; // ../../node_modules/@probe.gl/env/dist/lib/globals.js var window_2, document_2, process_, console_, navigator_; var init_globals = __esm({ "../../node_modules/@probe.gl/env/dist/lib/globals.js"() { window_2 = globalThis; document_2 = globalThis.document || {}; process_ = globalThis.process || {}; console_ = globalThis.console; navigator_ = globalThis.navigator || {}; } }); // ../../node_modules/@probe.gl/env/dist/lib/is-electron.js function isElectron(mockUserAgent) { if (typeof window !== "undefined" && window.process?.type === "renderer") { return true; } if (typeof process !== "undefined" && Boolean(process.versions?.["electron"])) { return true; } const realUserAgent = typeof navigator !== "undefined" && navigator.userAgent; const userAgent2 = mockUserAgent || realUserAgent; return Boolean(userAgent2 && userAgent2.indexOf("Electron") >= 0); } var init_is_electron = __esm({ "../../node_modules/@probe.gl/env/dist/lib/is-electron.js"() { } }); // ../../node_modules/@probe.gl/env/dist/lib/is-browser.js function isBrowser2() { const isNode2 = ( // @ts-expect-error typeof process === "object" && String(process) === "[object process]" && !process?.browser ); return !isNode2 || isElectron(); } var init_is_browser = __esm({ "../../node_modules/@probe.gl/env/dist/lib/is-browser.js"() { init_is_electron(); } }); // ../../node_modules/@probe.gl/env/dist/lib/get-browser.js function getBrowser(mockUserAgent) { if (!mockUserAgent && !isBrowser2()) { return "Node"; } if (isElectron(mockUserAgent)) { return "Electron"; } const userAgent2 = mockUserAgent || navigator_.userAgent || ""; if (userAgent2.indexOf("Edge") > -1) { return "Edge"; } if (globalThis.chrome) { return "Chrome"; } if (globalThis.safari) { return "Safari"; } if (globalThis.mozInnerScreenX) { return "Firefox"; } return "Unknown"; } var init_get_browser = __esm({ "../../node_modules/@probe.gl/env/dist/lib/get-browser.js"() { init_is_browser(); init_is_electron(); init_globals(); } }); // ../../node_modules/@probe.gl/env/dist/index.js var VERSION; var init_dist = __esm({ "../../node_modules/@probe.gl/env/dist/index.js"() { init_globals(); init_is_browser(); init_get_browser(); VERSION = true ? "4.1.1" : "untranspiled source"; } }); // ../../node_modules/@probe.gl/log/dist/utils/assert.js function assert3(condition, message2) { if (!condition) { throw new Error(message2 || "Assertion failed"); } } var init_assert = __esm({ "../../node_modules/@probe.gl/log/dist/utils/assert.js"() { } }); // ../../node_modules/@probe.gl/log/dist/loggers/log-utils.js function normalizeLogLevel(logLevel) { if (!logLevel) { return 0; } let resolvedLevel; switch (typeof logLevel) { case "number": resolvedLevel = logLevel; break; case "object": resolvedLevel = logLevel.logLevel || logLevel.priority || 0; break; default: return 0; } assert3(Number.isFinite(resolvedLevel) && resolvedLevel >= 0); return resolvedLevel; } function normalizeArguments(opts) { const { logLevel, message: message2 } = opts; opts.logLevel = normalizeLogLevel(logLevel); const args = opts.args ? Array.from(opts.args) : []; while (args.length && args.shift() !== message2) { } switch (typeof logLevel) { case "string": case "function": if (message2 !== void 0) { args.unshift(message2); } opts.message = logLevel; break; case "object": Object.assign(opts, logLevel); break; default: } if (typeof opts.message === "function") { opts.message = opts.message(); } const messageType = typeof opts.message; assert3(messageType === "string" || messageType === "object"); return Object.assign(opts, { args }, opts.opts); } var init_log_utils = __esm({ "../../node_modules/@probe.gl/log/dist/loggers/log-utils.js"() { init_assert(); } }); // ../../node_modules/@probe.gl/log/dist/loggers/base-log.js var noop, BaseLog; var init_base_log = __esm({ "../../node_modules/@probe.gl/log/dist/loggers/base-log.js"() { init_log_utils(); noop = () => { }; BaseLog = class { constructor({ level = 0 } = {}) { this.userData = {}; this._onceCache = /* @__PURE__ */ new Set(); this._level = level; } set level(newLevel) { this.setLevel(newLevel); } get level() { return this.getLevel(); } setLevel(level) { this._level = level; return this; } getLevel() { return this._level; } // Unconditional logging warn(message2, ...args) { return this._log("warn", 0, message2, args, { once: true }); } error(message2, ...args) { return this._log("error", 0, message2, args); } // Conditional logging log(logLevel, message2, ...args) { return this._log("log", logLevel, message2, args); } info(logLevel, message2, ...args) { return this._log("info", logLevel, message2, args); } once(logLevel, message2, ...args) { return this._log("once", logLevel, message2, args, { once: true }); } _log(type, logLevel, message2, args, options = {}) { const normalized = normalizeArguments({ logLevel, message: message2, args: this._buildArgs(logLevel, message2, args), opts: options }); return this._createLogFunction(type, normalized, options); } _buildArgs(logLevel, message2, args) { return [logLevel, message2, ...args]; } _createLogFunction(type, normalized, options) { if (!this._shouldLog(normalized.logLevel)) { return noop; } const tag = this._getOnceTag(options.tag ?? normalized.tag ?? normalized.message); if ((options.once || normalized.once) && tag !== void 0) { if (this._onceCache.has(tag)) { return noop; } this._onceCache.add(tag); } return this._emit(type, normalized); } _shouldLog(logLevel) { return this.getLevel() >= normalizeLogLevel(logLevel); } _getOnceTag(tag) { if (tag === void 0) { return void 0; } try { return typeof tag === "string" ? tag : String(tag); } catch { return void 0; } } }; } }); // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js function getStorage(type) { try { const storage = window[type]; const x2 = "__storage_test__"; storage.setItem(x2, x2); storage.removeItem(x2); return storage; } catch (e5) { return null; } } var LocalStorage; var init_local_storage = __esm({ "../../node_modules/@probe.gl/log/dist/utils/local-storage.js"() { LocalStorage = class { constructor(id, defaultConfig, type = "sessionStorage") { this.storage = getStorage(type); this.id = id; this.config = defaultConfig; this._loadConfiguration(); } getConfiguration() { return this.config; } setConfiguration(configuration) { Object.assign(this.config, configuration); if (this.storage) { const serialized = JSON.stringify(this.config); this.storage.setItem(this.id, serialized); } } // Get config from persistent store, if available _loadConfiguration() { let configuration = {}; if (this.storage) { const serializedConfiguration = this.storage.getItem(this.id); configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {}; } Object.assign(this.config, configuration); return this; } }; } }); // ../../node_modules/@probe.gl/log/dist/utils/formatters.js function formatTime(ms) { let formatted; if (ms < 10) { formatted = `${ms.toFixed(2)}ms`; } else if (ms < 100) { formatted = `${ms.toFixed(1)}ms`; } else if (ms < 1e3) { formatted = `${ms.toFixed(0)}ms`; } else { formatted = `${(ms / 1e3).toFixed(2)}s`; } return formatted; } function leftPad(string, length6 = 8) { const padLength = Math.max(length6 - string.length, 0); return `${" ".repeat(padLength)}${string}`; } var init_formatters = __esm({ "../../node_modules/@probe.gl/log/dist/utils/formatters.js"() { } }); // ../../node_modules/@probe.gl/log/dist/utils/color.js function getColor(color) { if (typeof color !== "string") { return color; } color = color.toUpperCase(); return COLOR[color] || COLOR.WHITE; } function addColor(string, color, background) { if (!isBrowser2 && typeof string === "string") { if (color) { const colorCode = getColor(color); string = `\x1B[${colorCode}m${string}\x1B[39m`; } if (background) { const colorCode = getColor(background); string = `\x1B[${colorCode + BACKGROUND_INCREMENT}m${string}\x1B[49m`; } } return string; } var COLOR, BACKGROUND_INCREMENT; var init_color = __esm({ "../../node_modules/@probe.gl/log/dist/utils/color.js"() { init_dist(); (function(COLOR2) { COLOR2[COLOR2["BLACK"] = 30] = "BLACK"; COLOR2[COLOR2["RED"] = 31] = "RED"; COLOR2[COLOR2["GREEN"] = 32] = "GREEN"; COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW"; COLOR2[COLOR2["BLUE"] = 34] = "BLUE"; COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA"; COLOR2[COLOR2["CYAN"] = 36] = "CYAN"; COLOR2[COLOR2["WHITE"] = 37] = "WHITE"; COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK"; COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED"; COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN"; COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW"; COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE"; COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA"; COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN"; COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE"; })(COLOR || (COLOR = {})); BACKGROUND_INCREMENT = 10; } }); // ../../node_modules/@probe.gl/log/dist/utils/autobind.js function autobind(obj, predefined = ["constructor"]) { const proto = Object.getPrototypeOf(obj); const propNames = Object.getOwnPropertyNames(proto); const object = obj; for (const key of propNames) { const value = object[key]; if (typeof value === "function") { if (!predefined.find((name13) => key === name13)) { object[key] = value.bind(obj); } } } } var init_autobind = __esm({ "../../node_modules/@probe.gl/log/dist/utils/autobind.js"() { } }); // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js function getHiResTimestamp() { let timestamp; if (isBrowser2() && window_2.performance) { timestamp = window_2?.performance?.now?.(); } else if ("hrtime" in process_) { const timeParts = process_?.hrtime?.(); timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6; } else { timestamp = Date.now(); } return timestamp; } var init_hi_res_timestamp = __esm({ "../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js"() { init_dist(); } }); // ../../node_modules/@probe.gl/log/dist/loggers/probe-log.js function decorateMessage(id, message2, opts) { if (typeof message2 === "string") { const time = opts.time ? leftPad(formatTime(opts.total)) : ""; message2 = opts.time ? `${id}: ${time} ${message2}` : `${id}: ${message2}`; message2 = addColor(message2, opts.color, opts.background); } return message2; } function getTableHeader(table) { for (const key in table) { for (const title in table[key]) { return title || "untitled"; } } return "empty"; } var originalConsole, DEFAULT_LOG_CONFIGURATION, ProbeLog; var init_probe_log = __esm({ "../../node_modules/@probe.gl/log/dist/loggers/probe-log.js"() { init_dist(); init_base_log(); init_local_storage(); init_formatters(); init_color(); init_autobind(); init_assert(); init_hi_res_timestamp(); originalConsole = { debug: isBrowser2() ? console.debug || console.log : console.log, log: console.log, info: console.info, warn: console.warn, error: console.error }; DEFAULT_LOG_CONFIGURATION = { enabled: true, level: 0 }; ProbeLog = class extends BaseLog { constructor({ id } = { id: "" }) { super({ level: 0 }); this.VERSION = VERSION; this._startTs = getHiResTimestamp(); this._deltaTs = getHiResTimestamp(); this.userData = {}; this.LOG_THROTTLE_TIMEOUT = 0; this.id = id; this.userData = {}; this._storage = new LocalStorage(`__probe-${this.id}__`, { [this.id]: DEFAULT_LOG_CONFIGURATION }); this.timeStamp(`${this.id} started`); autobind(this); Object.seal(this); } isEnabled() { return this._getConfiguration().enabled; } getLevel() { return this._getConfiguration().level; } /** @return milliseconds, with fractions */ getTotal() { return Number((getHiResTimestamp() - this._startTs).toPrecision(10)); } /** @return milliseconds, with fractions */ getDelta() { return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10)); } /** @deprecated use logLevel */ set priority(newPriority) { this.level = newPriority; } /** @deprecated use logLevel */ get priority() { return this.level; } /** @deprecated use logLevel */ getPriority() { return this.level; } // Configure enable(enabled = true) { this._updateConfiguration({ enabled }); return this; } setLevel(level) { this._updateConfiguration({ level }); return this; } /** return the current status of the setting */ get(setting) { return this._getConfiguration()[setting]; } // update the status of the setting set(setting, value) { this._updateConfiguration({ [setting]: value }); } /** Logs the current settings as a table */ settings() { if (console.table) { console.table(this._storage.config); } else { console.log(this._storage.config); } } // Unconditional logging assert(condition, message2) { if (!condition) { throw new Error(message2 || "Assertion failed"); } } warn(message2, ...args) { return this._log("warn", 0, message2, args, { method: originalConsole.warn, once: true }); } error(message2, ...args) { return this._log("error", 0, message2, args, { method: originalConsole.error }); } /** Print a deprecation warning */ deprecated(oldUsage, newUsage) { return this.warn(`\`${oldUsage}\` is deprecated and will be removed in a later version. Use \`${newUsage}\` instead`); } /** Print a removal warning */ removed(oldUsage, newUsage) { return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`); } probe(logLevel, message2, ...args) { return this._log("log", logLevel, message2, args, { method: originalConsole.log, time: true, once: true }); } log(logLevel, message2, ...args) { return this._log("log", logLevel, message2, args, { method: originalConsole.debug }); } info(logLevel, message2, ...args) { return this._log("info", logLevel, message2, args, { method: console.info }); } once(logLevel, message2, ...args) { return this._log("once", logLevel, message2, args, { method: originalConsole.debug || originalConsole.info, once: true }); } /** Logs an object as a table */ table(logLevel, table, columns) { if (table) { return this._log("table", logLevel, table, columns && [columns] || [], { method: console.table || noop, tag: getTableHeader(table) }); } return noop; } time(logLevel, message2) { return this._log("time", logLevel, message2, [], { method: console.time ? console.time : console.info }); } timeEnd(logLevel, message2) { return this._log("time", logLevel, message2, [], { method: console.timeEnd ? console.timeEnd : console.info }); } timeStamp(logLevel, message2) { return this._log("time", logLevel, message2, [], { method: console.timeStamp || noop }); } group(logLevel, message2, opts = { collapsed: false }) { const method = (opts.collapsed ? console.groupCollapsed : console.group) || console.info; return this._log("group", logLevel, message2, [], { method }); } groupCollapsed(logLevel, message2, opts = {}) { return this.group(logLevel, message2, Object.assign({}, opts, { collapsed: true })); } groupEnd(logLevel) { return this._log("groupEnd", logLevel, "", [], { method: console.groupEnd || noop }); } // EXPERIMENTAL withGroup(logLevel, message2, func) { this.group(logLevel, message2)(); try { func(); } finally { this.groupEnd(logLevel)(); } } trace() { if (console.trace) { console.trace(); } } _shouldLog(logLevel) { return this.isEnabled() && super._shouldLog(logLevel); } _emit(_type, normalized) { const method = normalized.method; assert3(method); normalized.total = this.getTotal(); normalized.delta = this.getDelta(); this._deltaTs = getHiResTimestamp(); const message2 = decorateMessage(this.id, normalized.message, normalized); return method.bind(console, message2, ...normalized.args); } _getConfiguration() { if (!this._storage.config[this.id]) { this._updateConfiguration(DEFAULT_LOG_CONFIGURATION); } return this._storage.config[this.id]; } _updateConfiguration(configuration) { const currentConfiguration = this._storage.config[this.id] || { ...DEFAULT_LOG_CONFIGURATION }; this._storage.setConfiguration({ [this.id]: { ...currentConfiguration, ...configuration } }); } }; ProbeLog.VERSION = VERSION; } }); // ../../node_modules/@probe.gl/log/dist/init.js var init_init = __esm({ "../../node_modules/@probe.gl/log/dist/init.js"() { globalThis.probe = {}; } }); // ../../node_modules/@probe.gl/log/dist/index.js var dist_default; var init_dist2 = __esm({ "../../node_modules/@probe.gl/log/dist/index.js"() { init_probe_log(); init_probe_log(); init_init(); dist_default = new ProbeLog({ id: "@probe.gl/log" }); } }); // ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js function getHiResTimestamp2() { let timestamp; if (typeof window !== "undefined" && window.performance) { timestamp = window.performance.now(); } else if (typeof process !== "undefined" && process.hrtime) { const timeParts = process.hrtime(); timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6; } else { timestamp = Date.now(); } return timestamp; } var init_hi_res_timestamp2 = __esm({ "../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js"() { } }); // ../../node_modules/@probe.gl/stats/dist/lib/stat.js var Stat; var init_stat = __esm({ "../../node_modules/@probe.gl/stats/dist/lib/stat.js"() { init_hi_res_timestamp2(); Stat = class { constructor(name13, type) { this.sampleSize = 1; this.time = 0; this.count = 0; this.samples = 0; this.lastTiming = 0; this.lastSampleTime = 0; this.lastSampleCount = 0; this._count = 0; this._time = 0; this._samples = 0; this._startTime = 0; this._timerPending = false; this.name = name13; this.type = type; this.reset(); } reset() { this.time = 0; this.count = 0; this.samples = 0; this.lastTiming = 0; this.lastSampleTime = 0; this.lastSampleCount = 0; this._count = 0; this._time = 0; this._samples = 0; this._startTime = 0; this._timerPending = false; return this; } setSampleSize(samples) { this.sampleSize = samples; return this; } /** Call to increment count (+1) */ incrementCount() { this.addCount(1); return this; } /** Call to decrement count (-1) */ decrementCount() { this.subtractCount(1); return this; } /** Increase count */ addCount(value) { this._count += value; this._samples++; this._checkSampling(); return this; } /** Decrease count */ subtractCount(value) { this._count -= value; this._samples++; this._checkSampling(); return this; } /** Add an arbitrary timing and bump the count */ addTime(time) { this._time += time; this.lastTiming = time; this._samples++; this._checkSampling(); return this; } /** Start a timer */ timeStart() { this._startTime = getHiResTimestamp2(); this._timerPending = true; return this; } /** End a timer. Adds to time and bumps the timing count. */ timeEnd() { if (!this._timerPending) { return this; } this.addTime(getHiResTimestamp2() - this._startTime); this._timerPending = false; this._checkSampling(); return this; } getSampleAverageCount() { return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0; } /** Calculate average time / count for the previous window */ getSampleAverageTime() { return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0; } /** Calculate counts per second for the previous window */ getSampleHz() { return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0; } getAverageCount() { return this.samples > 0 ? this.count / this.samples : 0; } /** Calculate average time / count */ getAverageTime() { return this.samples > 0 ? this.time / this.samples : 0; } /** Calculate counts per second */ getHz() { return this.time > 0 ? this.samples / (this.time / 1e3) : 0; } _checkSampling() { if (this._samples === this.sampleSize) { this.lastSampleTime = this._time; this.lastSampleCount = this._count; this.count += this._count; this.time += this._time; this.samples += this._samples; this._time = 0; this._count = 0; this._samples = 0; } } }; } }); // ../../node_modules/@probe.gl/stats/dist/lib/stats.js var Stats; var init_stats = __esm({ "../../node_modules/@probe.gl/stats/dist/lib/stats.js"() { init_stat(); Stats = class { constructor(options) { this.stats = {}; this.id = options.id; this.stats = {}; this._initializeStats(options.stats); Object.seal(this); } /** Acquire a stat. Create if it doesn't exist. */ get(name13, type = "count") { return this._getOrCreate({ name: name13, type }); } get size() { return Object.keys(this.stats).length; } /** Reset all stats */ reset() { for (const stat of Object.values(this.stats)) { stat.reset(); } return this; } forEach(fn) { for (const stat of Object.values(this.stats)) { fn(stat); } } getTable() { const table = {}; this.forEach((stat) => { table[stat.name] = { time: stat.time || 0, count: stat.count || 0, average: stat.getAverageTime() || 0, hz: stat.getHz() || 0 }; }); return table; } _initializeStats(stats2 = []) { stats2.forEach((stat) => this._getOrCreate(stat)); } _getOrCreate(stat) { const { name: name13, type } = stat; let result = this.stats[name13]; if (!result) { if (stat instanceof Stat) { result = stat; } else { result = new Stat(name13, type); } this.stats[name13] = result; } return result; } }; } }); // ../../node_modules/@probe.gl/stats/dist/index.js var init_dist3 = __esm({ "../../node_modules/@probe.gl/stats/dist/index.js"() { init_stats(); init_stat(); init_hi_res_timestamp2(); } }); // ../../node_modules/@luma.gl/core/dist/utils/stats-manager.js function initializeStats(stats2, orderedStatNames) { const statsMap = stats2.stats; let addedOrderedStat = false; for (const statName of orderedStatNames) { if (!statsMap[statName]) { stats2.get(statName); addedOrderedStat = true; } } const statCount = Object.keys(statsMap).length; const cachedStats = ORDERED_STATS_CACHE.get(stats2); if (!addedOrderedStat && cachedStats?.orderedStatNames === orderedStatNames && cachedStats.statCount === statCount) { return; } const reorderedStats = {}; let orderedStatNamesSet = ORDERED_STAT_NAME_SET_CACHE.get(orderedStatNames); if (!orderedStatNamesSet) { orderedStatNamesSet = new Set(orderedStatNames); ORDERED_STAT_NAME_SET_CACHE.set(orderedStatNames, orderedStatNamesSet); } for (const statName of orderedStatNames) { if (statsMap[statName]) { reorderedStats[statName] = statsMap[statName]; } } for (const [statName, stat] of Object.entries(statsMap)) { if (!orderedStatNamesSet.has(statName)) { reorderedStats[statName] = stat; } } for (const statName of Object.keys(statsMap)) { delete statsMap[statName]; } Object.assign(statsMap, reorderedStats); ORDERED_STATS_CACHE.set(stats2, { orderedStatNames, statCount }); } var GPU_TIME_AND_MEMORY_STATS, GPU_TIME_AND_MEMORY_STAT_ORDER, ORDERED_STATS_CACHE, ORDERED_STAT_NAME_SET_CACHE, StatsManager, lumaStats; var init_stats_manager = __esm({ "../../node_modules/@luma.gl/core/dist/utils/stats-manager.js"() { init_dist3(); GPU_TIME_AND_MEMORY_STATS = "GPU Time and Memory"; GPU_TIME_AND_MEMORY_STAT_ORDER = [ "Adapter", "GPU", "GPU Type", "GPU Backend", "Frame Rate", "CPU Time", "GPU Time", "GPU Memory", "Buffer Memory", "Texture Memory", "Referenced Buffer Memory", "Referenced Texture Memory", "Swap Chain Texture" ]; ORDERED_STATS_CACHE = /* @__PURE__ */ new WeakMap(); ORDERED_STAT_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap(); StatsManager = class { stats = /* @__PURE__ */ new Map(); getStats(name13) { return this.get(name13); } get(name13) { if (!this.stats.has(name13)) { this.stats.set(name13, new Stats({ id: name13 })); } const stats2 = this.stats.get(name13); if (name13 === GPU_TIME_AND_MEMORY_STATS) { initializeStats(stats2, GPU_TIME_AND_MEMORY_STAT_ORDER); } return stats2; } }; lumaStats = new StatsManager(); } }); // ../../node_modules/@luma.gl/core/dist/utils/log.js var log2; var init_log = __esm({ "../../node_modules/@luma.gl/core/dist/utils/log.js"() { init_dist2(); log2 = new ProbeLog({ id: "luma.gl" }); } }); // ../../node_modules/@luma.gl/core/dist/utils/uid.js function uid(id = "id") { uidCounters[id] = uidCounters[id] || 1; const count3 = uidCounters[id]++; return `${id}-${count3}`; } var uidCounters; var init_uid = __esm({ "../../node_modules/@luma.gl/core/dist/utils/uid.js"() { uidCounters = {}; } }); // ../../node_modules/@luma.gl/core/dist/adapter/resources/resource.js function selectivelyMerge(props, defaultProps49) { const mergedProps = { ...defaultProps49 }; for (const key in props) { if (props[key] !== void 0) { mergedProps[key] = props[key]; } } return mergedProps; } function initializeStats2(stats2, orderedStatNames) { const statsMap = stats2.stats; let addedOrderedStat = false; for (const statName of orderedStatNames) { if (!statsMap[statName]) { stats2.get(statName); addedOrderedStat = true; } } const statCount = Object.keys(statsMap).length; const cachedStats = ORDERED_STATS_CACHE2.get(stats2); if (!addedOrderedStat && cachedStats?.orderedStatNames === orderedStatNames && cachedStats.statCount === statCount) { return; } const reorderedStats = {}; let orderedStatNamesSet = ORDERED_STAT_NAME_SET_CACHE2.get(orderedStatNames); if (!orderedStatNamesSet) { orderedStatNamesSet = new Set(orderedStatNames); ORDERED_STAT_NAME_SET_CACHE2.set(orderedStatNames, orderedStatNamesSet); } for (const statName of orderedStatNames) { if (statsMap[statName]) { reorderedStats[statName] = statsMap[statName]; } } for (const [statName, stat] of Object.entries(statsMap)) { if (!orderedStatNamesSet.has(statName)) { reorderedStats[statName] = stat; } } for (const statName of Object.keys(statsMap)) { delete statsMap[statName]; } Object.assign(statsMap, reorderedStats); ORDERED_STATS_CACHE2.set(stats2, { orderedStatNames, statCount }); } function getResourceCountStatOrder(device) { return device.type === "webgl" ? WEBGL_RESOURCE_COUNT_STAT_ORDER : BASE_RESOURCE_COUNT_STAT_ORDER; } function getCpuHotspotProfiler(device) { const profiler = device.userData[CPU_HOTSPOT_PROFILER_MODULE]; return profiler?.enabled ? profiler : null; } function getTimestamp() { return globalThis.performance?.now?.() ?? Date.now(); } function recordTransientCanvasResourceCreate(device, name13) { const profiler = getCpuHotspotProfiler(device); if (!profiler || !profiler.activeDefaultFramebufferAcquireDepth) { return; } profiler.transientCanvasResourceCreates = (profiler.transientCanvasResourceCreates || 0) + 1; switch (name13) { case "Texture": profiler.transientCanvasTextureCreates = (profiler.transientCanvasTextureCreates || 0) + 1; break; case "TextureView": profiler.transientCanvasTextureViewCreates = (profiler.transientCanvasTextureViewCreates || 0) + 1; break; case "Sampler": profiler.transientCanvasSamplerCreates = (profiler.transientCanvasSamplerCreates || 0) + 1; break; case "Framebuffer": profiler.transientCanvasFramebufferCreates = (profiler.transientCanvasFramebufferCreates || 0) + 1; break; default: break; } } function getCanonicalResourceName(resource) { let prototype = Object.getPrototypeOf(resource); while (prototype) { const parentPrototype = Object.getPrototypeOf(prototype); if (!parentPrototype || parentPrototype === Resource.prototype) { return getPrototypeToStringTag(prototype) || resource[Symbol.toStringTag] || resource.constructor.name; } prototype = parentPrototype; } return resource[Symbol.toStringTag] || resource.constructor.name; } function getPrototypeToStringTag(prototype) { const descriptor = Object.getOwnPropertyDescriptor(prototype, Symbol.toStringTag); if (typeof descriptor?.get === "function") { return descriptor.get.call(prototype); } if (typeof descriptor?.value === "string") { return descriptor.value; } return null; } var CPU_HOTSPOT_PROFILER_MODULE, RESOURCE_COUNTS_STATS, LEGACY_RESOURCE_COUNTS_STATS, GPU_TIME_AND_MEMORY_STATS2, BASE_RESOURCE_COUNT_ORDER, WEBGL_RESOURCE_COUNT_ORDER, BASE_RESOURCE_COUNT_STAT_ORDER, WEBGL_RESOURCE_COUNT_STAT_ORDER, ORDERED_STATS_CACHE2, ORDERED_STAT_NAME_SET_CACHE2, Resource; var init_resource = __esm({ "../../node_modules/@luma.gl/core/dist/adapter/resources/resource.js"() { init_uid(); CPU_HOTSPOT_PROFILER_MODULE = "cpu-hotspot-profiler"; RESOURCE_COUNTS_STATS = "GPU Resource Counts"; LEGACY_RESOURCE_COUNTS_STATS = "Resource Counts"; GPU_TIME_AND_MEMORY_STATS2 = "GPU Time and Memory"; BASE_RESOURCE_COUNT_ORDER = [ "Resources", "Buffers", "Textures", "Samplers", "TextureViews", "Framebuffers", "QuerySets", "Shaders", "RenderPipelines", "ComputePipelines", "PipelineLayouts", "VertexArrays", "RenderPasss", "ComputePasss", "CommandEncoders", "CommandBuffers" ]; WEBGL_RESOURCE_COUNT_ORDER = [ "Resources", "Buffers", "Textures", "Samplers", "TextureViews", "Framebuffers", "QuerySets", "Shaders", "RenderPipelines", "SharedRenderPipelines", "ComputePipelines", "PipelineLayouts", "VertexArrays", "RenderPasss", "ComputePasss", "CommandEncoders", "CommandBuffers" ]; BASE_RESOURCE_COUNT_STAT_ORDER = BASE_RESOURCE_COUNT_ORDER.flatMap((resourceType) => [ `${resourceType} Created`, `${resourceType} Active` ]); WEBGL_RESOURCE_COUNT_STAT_ORDER = WEBGL_RESOURCE_COUNT_ORDER.flatMap((resourceType) => [ `${resourceType} Created`, `${resourceType} Active` ]); ORDERED_STATS_CACHE2 = /* @__PURE__ */ new WeakMap(); ORDERED_STAT_NAME_SET_CACHE2 = /* @__PURE__ */ new WeakMap(); Resource = class { toString() { return `${this[Symbol.toStringTag] || this.constructor.name}:"${this.id}"`; } /** props.id, for debugging. */ id; /** The props that this resource was created with */ props; /** User data object, reserved for the application */ userData = {}; /** The device that this resource is associated with - TODO can we remove this dup? */ _device; /** Whether this resource has been destroyed */ destroyed = false; /** For resources that allocate GPU memory */ allocatedBytes = 0; /** Stats bucket currently holding the tracked allocation */ allocatedBytesName = null; /** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */ _attachedResources = /* @__PURE__ */ new Set(); /** * Create a new Resource. Called from Subclass */ constructor(device, props, defaultProps49) { if (!device) { throw new Error("no device"); } this._device = device; this.props = selectivelyMerge(props, defaultProps49); const id = this.props.id !== "undefined" ? this.props.id : uid(this[Symbol.toStringTag]); this.props.id = id; this.id = id; this.userData = this.props.userData || {}; this.addStats(); } /** * destroy can be called on any resource to release it before it is garbage collected. */ destroy() { if (this.destroyed) { return; } this.destroyResource(); } /** @deprecated Use destroy() */ delete() { this.destroy(); return this; } /** * Combines a map of user props and default props, only including props from defaultProps * @returns returns a map of overridden default props */ getProps() { return this.props; } // ATTACHED RESOURCES /** * Attaches a resource. Attached resources are auto destroyed when this resource is destroyed * Called automatically when sub resources are auto created but can be called by application */ attachResource(resource) { this._attachedResources.add(resource); } /** * Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed. */ detachResource(resource) { this._attachedResources.delete(resource); } /** * Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource. */ destroyAttachedResource(resource) { if (this._attachedResources.delete(resource)) { resource.destroy(); } } /** Destroy all owned resources. Make sure the resources are no longer needed before calling. */ destroyAttachedResources() { for (const resource of this._attachedResources) { resource.destroy(); } this._attachedResources = /* @__PURE__ */ new Set(); } // PROTECTED METHODS /** Perform all destroy steps. Can be called by derived resources when overriding destroy() */ destroyResource() { if (this.destroyed) { return; } this.destroyAttachedResources(); this.removeStats(); this.destroyed = true; } /** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */ removeStats() { const profiler = getCpuHotspotProfiler(this._device); const startTime = profiler ? getTimestamp() : 0; const statsObjects = [ this._device.statsManager.getStats(RESOURCE_COUNTS_STATS), this._device.statsManager.getStats(LEGACY_RESOURCE_COUNTS_STATS) ]; const orderedStatNames = getResourceCountStatOrder(this._device); for (const stats2 of statsObjects) { initializeStats2(stats2, orderedStatNames); } const name13 = this.getStatsName(); for (const stats2 of statsObjects) { stats2.get("Resources Active").decrementCount(); stats2.get(`${name13}s Active`).decrementCount(); } if (profiler) { profiler.statsBookkeepingCalls = (profiler.statsBookkeepingCalls || 0) + 1; profiler.statsBookkeepingTimeMs = (profiler.statsBookkeepingTimeMs || 0) + (getTimestamp() - startTime); } } /** Called by subclass to track memory allocations */ trackAllocatedMemory(bytes, name13 = this.getStatsName()) { const profiler = getCpuHotspotProfiler(this._device); const startTime = profiler ? getTimestamp() : 0; const stats2 = this._device.statsManager.getStats(GPU_TIME_AND_MEMORY_STATS2); if (this.allocatedBytes > 0 && this.allocatedBytesName) { stats2.get("GPU Memory").subtractCount(this.allocatedBytes); stats2.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes); } stats2.get("GPU Memory").addCount(bytes); stats2.get(`${name13} Memory`).addCount(bytes); if (profiler) { profiler.statsBookkeepingCalls = (profiler.statsBookkeepingCalls || 0) + 1; profiler.statsBookkeepingTimeMs = (profiler.statsBookkeepingTimeMs || 0) + (getTimestamp() - startTime); } this.allocatedBytes = bytes; this.allocatedBytesName = name13; } /** Called by subclass to track handle-backed memory allocations separately from owned allocations */ trackReferencedMemory(bytes, name13 = this.getStatsName()) { this.trackAllocatedMemory(bytes, `Referenced ${name13}`); } /** Called by subclass to track memory deallocations */ trackDeallocatedMemory(name13 = this.getStatsName()) { if (this.allocatedBytes === 0) { this.allocatedBytesName = null; return; } const profiler = getCpuHotspotProfiler(this._device); const startTime = profiler ? getTimestamp() : 0; const stats2 = this._device.statsManager.getStats(GPU_TIME_AND_MEMORY_STATS2); stats2.get("GPU Memory").subtractCount(this.allocatedBytes); stats2.get(`${this.allocatedBytesName || name13} Memory`).subtractCount(this.allocatedBytes); if (profiler) { profiler.statsBookkeepingCalls = (profiler.statsBookkeepingCalls || 0) + 1; profiler.statsBookkeepingTimeMs = (profiler.statsBookkeepingTimeMs || 0) + (getTimestamp() - startTime); } this.allocatedBytes = 0; this.allocatedBytesName = null; } /** Called by subclass to deallocate handle-backed memory tracked via trackReferencedMemory() */ trackDeallocatedReferencedMemory(name13 = this.getStatsName()) { this.trackDeallocatedMemory(`Referenced ${name13}`); } /** Called by resource constructor to track object creation */ addStats() { const name13 = this.getStatsName(); const profiler = getCpuHotspotProfiler(this._device); const startTime = profiler ? getTimestamp() : 0; const statsObjects = [ this._device.statsManager.getStats(RESOURCE_COUNTS_STATS), this._device.statsManager.getStats(LEGACY_RESOURCE_COUNTS_STATS) ]; const orderedStatNames = getResourceCountStatOrder(this._device); for (const stats2 of statsObjects) { initializeStats2(stats2, orderedStatNames); } for (const stats2 of statsObjects) { stats2.get("Resources Created").incrementCount(); stats2.get("Resources Active").incrementCount(); stats2.get(`${name13}s Created`).incrementCount(); stats2.get(`${name13}s Active`).incrementCount(); } if (profiler) { profiler.statsBookkeepingCalls = (profiler.statsBookkeepingCalls || 0) + 1; profiler.statsBookkeepingTimeMs = (profiler.statsBookkeepingTimeMs || 0) + (getTimestamp() - startTime); } recordTransientCanvasResourceCreate(this._device, name13); } /** Canonical resource name used for stats buckets. */ getStatsName() { return getCanonicalResourceName(this); } }; /** Default properties for resource */ __publicField(Resource, "defaultProps", { id: "undefined", handle: void 0, userData: void 0 }); } }); // ../../node_modules/@luma.gl/core/dist/adapter/resources/buffer.js var _Buffer, Buffer2; var init_buffer = __esm({ "../../node_modules/@luma.gl/core/dist/adapter/resources/buffer.js"() { init_resource(); _Buffer = class extends Resource { get [Symbol.toStringTag]() { return "Buffer"; } /** The usage with which this buffer was created */ usage; /** For index buffers, whether indices are 8, 16 or 32 bit. Note: uint8 indices are automatically converted to uint16 for WebGPU compatibility */ indexType; /** "Time" of last update, can be used to check if redraw is needed */ updateTimestamp; constructor(device, props) { const deducedProps = { ...props }; if ((props.usage || 0) & _Buffer.INDEX && !props.indexType) { if (props.data instanceof Uint32Array) { deducedProps.indexType = "uint32"; } else if (props.data instanceof Uint16Array) { deducedProps.indexType = "uint16"; } else if (props.data instanceof Uint8Array) { deducedProps.indexType = "uint8"; } } delete deducedProps.data; super(device, deducedProps, _Buffer.defaultProps); this.usage = deducedProps.usage || 0; this.indexType = deducedProps.indexType; this.updateTimestamp = device.incrementTimestamp(); } /** * Create a copy of this Buffer with new byteLength, with same props but of the specified size. * @note Does not copy contents of the cloned Buffer. */ clone(props) { return this.device.createBuffer({ ...this.props, ...props }); } /** A partial CPU-side copy of the data in this buffer, for debugging purposes */ debugData = new ArrayBuffer(0); /** This doesn't handle partial non-zero offset updates correctly */ _setDebugData(data, _byteOffset, byteLength) { let arrayBufferView