UNPKG

maplibre-gl

Version:

BSD licensed community fork of mapbox-gl, a WebGL interactive maps library

1,408 lines (1,300 loc) 2.23 MB
/** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.7.0/LICENSE.txt */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.maplibregl = {})); })(this, (function (exports) { 'use strict'; var name = "maplibre-gl"; var description = "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library"; var version$2 = "4.7.0"; var main = "dist/maplibre-gl.js"; var style = "dist/maplibre-gl.css"; var license = "BSD-3-Clause"; var homepage = "https://maplibre.org/"; var funding = "https://github.com/maplibre/maplibre-gl-js?sponsor=1"; var bugs = { url: "https://github.com/maplibre/maplibre-gl-js/issues/" }; var repository = { type: "git", url: "git://github.com/maplibre/maplibre-gl-js.git" }; var types$2 = "dist/maplibre-gl.d.ts"; var type = "module"; var dependencies = { "@mapbox/geojson-rewind": "^0.5.2", "@mapbox/jsonlint-lines-primitives": "^2.0.2", "@mapbox/point-geometry": "^0.1.0", "@mapbox/tiny-sdf": "^2.0.6", "@mapbox/unitbezier": "^0.0.1", "@mapbox/vector-tile": "^1.3.1", "@mapbox/whoots-js": "^3.1.0", "@maplibre/maplibre-gl-style-spec": "^20.3.1", "@types/geojson": "^7946.0.14", "@types/geojson-vt": "3.2.5", "@types/mapbox__point-geometry": "^0.1.4", "@types/mapbox__vector-tile": "^1.3.4", "@types/pbf": "^3.0.5", "@types/supercluster": "^7.1.3", earcut: "^3.0.0", "geojson-vt": "^4.0.2", "gl-matrix": "^3.4.3", "global-prefix": "^4.0.0", kdbush: "^4.0.2", "murmurhash-js": "^1.0.0", pbf: "^3.3.0", potpack: "^2.0.0", quickselect: "^3.0.0", supercluster: "^8.0.1", tinyqueue: "^3.0.0", "vt-pbf": "^3.1.3" }; var devDependencies = { autoprefixer: "^10.4.20", "@mapbox/mapbox-gl-rtl-text": "^0.3.0", "@mapbox/mvt-fixtures": "^3.10.0", "@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-replace": "^5.0.7", "@rollup/plugin-strip": "^3.0.4", "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@types/benchmark": "^2.1.5", "@types/cssnano": "^5.0.0", "@types/d3": "^7.4.3", "@types/diff": "^5.2.2", "@types/earcut": "^2.1.4", "@types/eslint": "^8.56.7", "@types/gl": "^6.0.5", "@types/glob": "^8.1.0", "@types/jest": "^29.5.12", "@types/jsdom": "^21.1.7", "@types/minimist": "^1.2.5", "@types/murmurhash-js": "^1.0.6", "@types/nise": "^1.4.5", "@types/node": "^22.5.4", "@types/offscreencanvas": "^2019.7.3", "@types/pixelmatch": "^5.2.6", "@types/pngjs": "^6.0.5", "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", "@types/request": "^2.48.12", "@types/shuffle-seed": "^1.1.3", "@types/window-or-global": "^1.0.6", "@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/parser": "^7.18.0", address: "^2.0.3", benchmark: "^2.1.4", canvas: "^2.11.2", cssnano: "^7.0.6", d3: "^7.9.0", "d3-queue": "^3.0.7", "devtools-protocol": "^0.0.1351223", diff: "^6.0.0", "dts-bundle-generator": "^9.5.1", eslint: "^8.57.0", "eslint-config-mourner": "^3.0.0", "eslint-plugin-html": "^8.1.1", "eslint-plugin-import": "^2.30.0", "eslint-plugin-jest": "^28.8.3", "eslint-plugin-react": "^7.35.2", "eslint-plugin-tsdoc": "0.3.0", expect: "^29.7.0", glob: "^11.0.0", "is-builtin-module": "^4.0.0", jest: "^29.7.0", "jest-environment-jsdom": "^29.7.0", "jest-junit": "^16.0.0", "jest-monocart-coverage": "^1.1.1", "jest-webgl-canvas-mock": "^2.5.3", jsdom: "^25.0.0", "junit-report-builder": "^5.0.0", minimist: "^1.2.8", "mock-geolocation": "^1.0.11", "monocart-coverage-reports": "^2.10.3", nise: "^6.0.0", "npm-font-open-sans": "^1.1.0", "npm-run-all": "^4.1.5", "pdf-merger-js": "^5.1.2", pixelmatch: "^6.0.0", pngjs: "^7.0.0", postcss: "^8.4.45", "postcss-cli": "^11.0.0", "postcss-inline-svg": "^6.0.0", "pretty-bytes": "^6.1.1", puppeteer: "^23.3.0", react: "^18.3.1", "react-dom": "^18.3.1", rollup: "^4.21.2", "rollup-plugin-sourcemaps": "^0.6.3", rw: "^1.3.3", semver: "^7.6.3", "shuffle-seed": "^1.1.6", "source-map-explorer": "^2.5.3", st: "^3.0.0", stylelint: "^16.9.0", "stylelint-config-standard": "^36.0.1", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", tslib: "^2.7.0", typedoc: "^0.26.6", "typedoc-plugin-markdown": "^4.2.7", "typedoc-plugin-missing-exports": "^3.0.0", typescript: "^5.5.4" }; var scripts = { "generate-dist-package": "node --no-warnings --loader ts-node/esm build/generate-dist-package.js", "generate-shaders": "node --no-warnings --loader ts-node/esm build/generate-shaders.ts", "generate-struct-arrays": "node --no-warnings --loader ts-node/esm build/generate-struct-arrays.ts", "generate-style-code": "node --no-warnings --loader ts-node/esm build/generate-style-code.ts", "generate-typings": "dts-bundle-generator --export-referenced-types --umd-module-name=maplibregl -o ./dist/maplibre-gl.d.ts ./src/index.ts", "generate-docs": "typedoc && node --no-warnings --loader ts-node/esm build/generate-docs.ts", "generate-images": "node --no-warnings --loader ts-node/esm build/generate-doc-images.ts", "build-dist": "npm run build-css && npm run generate-typings && npm run build-dev && npm run build-csp-dev && npm run build-prod && npm run build-prod-unminified && npm run build-csp", "build-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev", "watch-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch", "build-prod": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production,MINIFY:true", "build-prod-unminified": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production", "build-csp": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:production,MINIFY:true", "build-csp-dev": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:dev", "build-css": "postcss -o dist/maplibre-gl.css src/css/maplibre-gl.css", "watch-css": "postcss --watch -o dist/maplibre-gl.css src/css/maplibre-gl.css", "build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts", "watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch", "start-server": "st --no-cache -H 0.0.0.0 --port 9966 .", "start-docs": "docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material", start: "run-p watch-css watch-dev start-server", "start-bench": "run-p watch-css watch-benchmarks start-server", lint: "eslint --cache --ext .ts,.tsx,.js,.html --ignore-path .gitignore .", "lint-css": "stylelint **/*.css --fix -f verbose", test: "run-p lint lint-css test-render jest", jest: "jest", "test-build": "jest --selectProjects=build --reporters=default", "test-build-ci": "jest --selectProjects=build", "test-integration": "jest --selectProjects=integration --reporters=default", "test-integration-ci": "jest --coverage --selectProjects=integration", "test-render": "node --no-warnings --loader ts-node/esm test/integration/render/run_render_tests.ts", "test-unit": "jest --selectProjects=unit --reporters=default", "test-unit-ci": "jest --coverage --selectProjects unit", "test-watch-roots": "jest --watch", codegen: "run-p --print-label generate-dist-package generate-style-code generate-struct-arrays generate-shaders && npm run generate-typings", benchmark: "node --no-warnings --loader ts-node/esm test/bench/run-benchmarks.ts", "gl-stats": "node --no-warnings --loader ts-node/esm test/bench/gl-stats.ts", prepare: "npm run codegen", typecheck: "tsc --noEmit && tsc --project tsconfig.dist.json", tsnode: "node --experimental-loader=ts-node/esm --no-warnings" }; var files = [ "build/", "dist/*", "src/" ]; var engines = { npm: ">=8.1.0", node: ">=16.14.0" }; var packageJSON = { name: name, description: description, version: version$2, main: main, style: style, license: license, homepage: homepage, funding: funding, bugs: bugs, repository: repository, types: types$2, type: type, dependencies: dependencies, devDependencies: devDependencies, scripts: scripts, files: files, engines: engines }; /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for (var i = decorators.length - 1; i >= 0; i--) { var context = {}; for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; for (var p in contextIn.access) context.access[p] = contextIn.access[p]; context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || typeof result !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.unshift(_); } else if (_ = accept(result)) { if (kind === "field") initializers.unshift(_); else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; }; function __runInitializers(thisArg, initializers, value) { var useValue = arguments.length > 2; for (var i = 0; i < initializers.length; i++) { value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); } return useValue ? value : void 0; }; function __propKey(x) { return typeof x === "symbol" ? x : "".concat(x); }; function __setFunctionName(f, name, prefix) { if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); }; function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } var __createBinding = Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); function __exportStar(m, o) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } /** @deprecated */ function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } /** @deprecated */ function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i; function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; } function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __setModuleDefault = Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); } function __classPrivateFieldSet(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; } function __classPrivateFieldIn(state, receiver) { if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); return typeof state === "function" ? receiver === state : state.has(receiver); } function __addDisposableResource(env, value, async) { if (value !== null && value !== void 0) { if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); var dispose, inner; if (async) { if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); dispose = value[Symbol.asyncDispose]; } if (dispose === void 0) { if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); dispose = value[Symbol.dispose]; if (async) inner = dispose; } if (typeof dispose !== "function") throw new TypeError("Object not disposable."); if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } }; env.stack.push({ value: value, dispose: dispose, async: async }); } else if (async) { env.stack.push({ async: true }); } return value; } var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; function __disposeResources(env) { function fail(e) { env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; env.hasError = true; } var r, s = 0; function next() { while (r = env.stack.pop()) { try { if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); if (r.dispose) { var result = r.dispose.call(r.value); if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); } else s |= 1; } catch (e) { fail(e); } } if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); if (env.hasError) throw env.error; } return next(); } var tslib_es6 = { __extends: __extends, __assign: __assign, __rest: __rest, __decorate: __decorate, __param: __param, __metadata: __metadata, __awaiter: __awaiter, __generator: __generator, __createBinding: __createBinding, __exportStar: __exportStar, __values: __values, __read: __read, __spread: __spread, __spreadArrays: __spreadArrays, __spreadArray: __spreadArray, __await: __await, __asyncGenerator: __asyncGenerator, __asyncDelegator: __asyncDelegator, __asyncValues: __asyncValues, __makeTemplateObject: __makeTemplateObject, __importStar: __importStar, __importDefault: __importDefault, __classPrivateFieldGet: __classPrivateFieldGet, __classPrivateFieldSet: __classPrivateFieldSet, __classPrivateFieldIn: __classPrivateFieldIn, __addDisposableResource: __addDisposableResource, __disposeResources: __disposeResources, }; var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function getDefaultExportFromCjs$1 (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function getDefaultExportFromNamespaceIfPresent (n) { return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n; } function getDefaultExportFromNamespaceIfNotNamed (n) { return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n; } function getAugmentedNamespace(n) { if (n.__esModule) return n; var f = n.default; if (typeof f == "function") { var a = function a () { if (this instanceof a) { return Reflect.construct(f, arguments, this.constructor); } return f.apply(this, arguments); }; a.prototype = f.prototype; } else a = {}; Object.defineProperty(a, '__esModule', {value: true}); Object.keys(n).forEach(function (k) { var d = Object.getOwnPropertyDescriptor(n, k); Object.defineProperty(a, k, d.get ? d : { enumerable: true, get: function () { return n[k]; } }); }); return a; } 'use strict'; var pointGeometry = Point$1; /** * A standalone point geometry with useful accessor, comparison, and * modification methods. * * @class Point * @param {Number} x the x-coordinate. this could be longitude or screen * pixels, or any other sort of unit. * @param {Number} y the y-coordinate. this could be latitude or screen * pixels, or any other sort of unit. * @example * var point = new Point(-77, 38); */ function Point$1(x, y) { this.x = x; this.y = y; } Point$1.prototype = { /** * Clone this point, returning a new point that can be modified * without affecting the old one. * @return {Point} the clone */ clone: function() { return new Point$1(this.x, this.y); }, /** * Add this point's x & y coordinates to another point, * yielding a new point. * @param {Point} p the other point * @return {Point} output point */ add: function(p) { return this.clone()._add(p); }, /** * Subtract this point's x & y coordinates to from point, * yielding a new point. * @param {Point} p the other point * @return {Point} output point */ sub: function(p) { return this.clone()._sub(p); }, /** * Multiply this point's x & y coordinates by point, * yielding a new point. * @param {Point} p the other point * @return {Point} output point */ multByPoint: function(p) { return this.clone()._multByPoint(p); }, /** * Divide this point's x & y coordinates by point, * yielding a new point. * @param {Point} p the other point * @return {Point} output point */ divByPoint: function(p) { return this.clone()._divByPoint(p); }, /** * Multiply this point's x & y coordinates by a factor, * yielding a new point. * @param {Point} k factor * @return {Point} output point */ mult: function(k) { return this.clone()._mult(k); }, /** * Divide this point's x & y coordinates by a factor, * yielding a new point. * @param {Point} k factor * @return {Point} output point */ div: function(k) { return this.clone()._div(k); }, /** * Rotate this point around the 0, 0 origin by an angle a, * given in radians * @param {Number} a angle to rotate around, in radians * @return {Point} output point */ rotate: function(a) { return this.clone()._rotate(a); }, /** * Rotate this point around p point by an angle a, * given in radians * @param {Number} a angle to rotate around, in radians * @param {Point} p Point to rotate around * @return {Point} output point */ rotateAround: function(a,p) { return this.clone()._rotateAround(a,p); }, /** * Multiply this point by a 4x1 transformation matrix * @param {Array<Number>} m transformation matrix * @return {Point} output point */ matMult: function(m) { return this.clone()._matMult(m); }, /** * Calculate this point but as a unit vector from 0, 0, meaning * that the distance from the resulting point to the 0, 0 * coordinate will be equal to 1 and the angle from the resulting * point to the 0, 0 coordinate will be the same as before. * @return {Point} unit vector point */ unit: function() { return this.clone()._unit(); }, /** * Compute a perpendicular point, where the new y coordinate * is the old x coordinate and the new x coordinate is the old y * coordinate multiplied by -1 * @return {Point} perpendicular point */ perp: function() { return this.clone()._perp(); }, /** * Return a version of this point with the x & y coordinates * rounded to integers. * @return {Point} rounded point */ round: function() { return this.clone()._round(); }, /** * Return the magitude of this point: this is the Euclidean * distance from the 0, 0 coordinate to this point's x and y * coordinates. * @return {Number} magnitude */ mag: function() { return Math.sqrt(this.x * this.x + this.y * this.y); }, /** * Judge whether this point is equal to another point, returning * true or false. * @param {Point} other the other point * @return {boolean} whether the points are equal */ equals: function(other) { return this.x === other.x && this.y === other.y; }, /** * Calculate the distance from this point to another point * @param {Point} p the other point * @return {Number} distance */ dist: function(p) { return Math.sqrt(this.distSqr(p)); }, /** * Calculate the distance from this point to another point, * without the square root step. Useful if you're comparing * relative distances. * @param {Point} p the other point * @return {Number} distance */ distSqr: function(p) { var dx = p.x - this.x, dy = p.y - this.y; return dx * dx + dy * dy; }, /** * Get the angle from the 0, 0 coordinate to this point, in radians * coordinates. * @return {Number} angle */ angle: function() { return Math.atan2(this.y, this.x); }, /** * Get the angle from this point to another point, in radians * @param {Point} b the other point * @return {Number} angle */ angleTo: function(b) { return Math.atan2(this.y - b.y, this.x - b.x); }, /** * Get the angle between this point and another point, in radians * @param {Point} b the other point * @return {Number} angle */ angleWith: function(b) { return this.angleWithSep(b.x, b.y); }, /* * Find the angle of the two vectors, solving the formula for * the cross product a x b = |a||b|sin(θ) for θ. * @param {Number} x the x-coordinate * @param {Number} y the y-coordinate * @return {Number} the angle in radians */ angleWithSep: function(x, y) { return Math.atan2( this.x * y - this.y * x, this.x * x + this.y * y); }, _matMult: function(m) { var x = m[0] * this.x + m[1] * this.y, y = m[2] * this.x + m[3] * this.y; this.x = x; this.y = y; return this; }, _add: function(p) { this.x += p.x; this.y += p.y; return this; }, _sub: function(p) { this.x -= p.x; this.y -= p.y; return this; }, _mult: function(k) { this.x *= k; this.y *= k; return this; }, _div: function(k) { this.x /= k; this.y /= k; return this; }, _multByPoint: function(p) { this.x *= p.x; this.y *= p.y; return this; }, _divByPoint: function(p) { this.x /= p.x; this.y /= p.y; return this; }, _unit: function() { this._div(this.mag()); return this; }, _perp: function() { var y = this.y; this.y = this.x; this.x = -y; return this; }, _rotate: function(angle) { var cos = Math.cos(angle), sin = Math.sin(angle), x = cos * this.x - sin * this.y, y = sin * this.x + cos * this.y; this.x = x; this.y = y; return this; }, _rotateAround: function(angle, p) { var cos = Math.cos(angle), sin = Math.sin(angle), x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y), y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y); this.x = x; this.y = y; return this; }, _round: function() { this.x = Math.round(this.x); this.y = Math.round(this.y); return this; } }; /** * Construct a point from an array if necessary, otherwise if the input * is already a Point, or an unknown type, return it unchanged * @param {Array<Number>|Point|*} a any kind of input value * @return {Point} constructed point, or passed-through value. * @example * // this * var point = Point.convert([0, 1]); * // is equivalent to * var point = new Point(0, 1); */ Point$1.convert = function (a) { if (a instanceof Point$1) { return a; } if (Array.isArray(a)) { return new Point$1(a[0], a[1]); } return a; }; var Point$2 = /*@__PURE__*/getDefaultExportFromCjs$1(pointGeometry); 'use strict'; var unitbezier$1 = UnitBezier$2; function UnitBezier$2(p1x, p1y, p2x, p2y) { // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1). this.cx = 3.0 * p1x; this.bx = 3.0 * (p2x - p1x) - this.cx; this.ax = 1.0 - this.cx - this.bx; this.cy = 3.0 * p1y; this.by = 3.0 * (p2y - p1y) - this.cy; this.ay = 1.0 - this.cy - this.by; this.p1x = p1x; this.p1y = p1y; this.p2x = p2x; this.p2y = p2y; } UnitBezier$2.prototype = { sampleCurveX: function (t) { // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule. return ((this.ax * t + this.bx) * t + this.cx) * t; }, sampleCurveY: function (t) { return ((this.ay * t + this.by) * t + this.cy) * t; }, sampleCurveDerivativeX: function (t) { return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx; }, solveCurveX: function (x, epsilon) { if (epsilon === undefined) epsilon = 1e-6; if (x < 0.0) return 0.0; if (x > 1.0) return 1.0; var t = x; // First try a few iterations of Newton's method - normally very fast. for (var i = 0; i < 8; i++) { var x2 = this.sampleCurveX(t) - x; if (Math.abs(x2) < epsilon) return t; var d2 = this.sampleCurveDerivativeX(t); if (Math.abs(d2) < 1e-6) break; t = t - x2 / d2; } // Fall back to the bisection method for reliability. var t0 = 0.0; var t1 = 1.0; t = x; for (i = 0; i < 20; i++) { x2 = this.sampleCurveX(t); if (Math.abs(x2 - x) < epsilon) break; if (x > x2) { t0 = t; } else { t1 = t; } t = (t1 - t0) * 0.5 + t0; } return t; }, solve: function (x, epsilon) { return this.sampleCurveY(this.solveCurveX(x, epsilon)); } }; var UnitBezier$3 = /*@__PURE__*/getDefaultExportFromCjs$1(unitbezier$1); let supportsOffscreenCanvas; function offscreenCanvasSupported() { if (supportsOffscreenCanvas == null) { supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' && new OffscreenCanvas(1, 1).getContext('2d') && typeof createImageBitmap === 'function'; } return supportsOffscreenCanvas; } let offscreenCanvasDistorted; /** * Some browsers don't return the exact pixels from a canvas to prevent user fingerprinting (see #3185). * This function writes pixels to an OffscreenCanvas and reads them back using getImageData, returning false * if they don't match. * * @returns true if the browser supports OffscreenCanvas but it distorts getImageData results, false otherwise. */ function isOffscreenCanvasDistorted() { if (offscreenCanvasDistorted == null) { offscreenCanvasDistorted = false; if (offscreenCanvasSupported()) { const size = 5; const canvas = new OffscreenCanvas(size, size); const context = canvas.getContext('2d', { willReadFrequently: true }); if (context) { // fill each pixel with an RGB value that should make the byte at index i equal to i (except alpha channel): // [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, ...] for (let i = 0; i < size * size; i++) { const base = i * 4; context.fillStyle = `rgb(${base},${base + 1},${base + 2})`; context.fillRect(i % size, Math.floor(i / size), 1, 1); } const data = context.getImageData(0, 0, size, size).data; for (let i = 0; i < size * size * 4; i++) { if (i % 4 !== 3 && data[i] !== i) { offscreenCanvasDistorted = true; break; } } } } } return offscreenCanvasDistorted || false; } /** * For a given collection of 2D points, returns their axis-aligned bounding box, * in the format [minX, minY, maxX, maxY]. */ function getAABB(points) { let tlX = Infinity; let tlY = Infinity; let brX = -Infinity; let brY = -Infinity; for (const p of points) { tlX = Math.min(tlX, p.x); tlY = Math.min(tlY, p.y); brX = Math.max(brX, p.x); brY = Math.max(brY, p.y); } return [tlX, tlY, brX, brY]; } /** * Given a value `t` that varies between 0 and 1, return * an interpolation function that eases between 0 and 1 in a pleasing * cubic in-out fashion. */ function easeCubicInOut(t) { if (t <= 0) return 0; if (t >= 1) return 1; const t2 = t * t, t3 = t2 * t; return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75); } /** * Given given (x, y), (x1, y1) control points for a bezier curve, * return a function that interpolates along that curve. * * @param p1x - control point 1 x coordinate * @param p1y - control point 1 y coordinate * @param p2x - control point 2 x coordinate * @param p2y - control point 2 y coordinate */ function bezier$1(p1x, p1y, p2x, p2y) { const bezier = new UnitBezier$3(p1x, p1y, p2x, p2y); return (t) => { return bezier.solve(t); }; } /** * A default bezier-curve powered easing function with * control points (0.25, 0.1) and (0.25, 1) */ const defaultEasing = bezier$1(0.25, 0.1, 0.25, 1); /** * constrain n to the given range via min + max * * @param n - value * @param min - the minimum value to be returned * @param max - the maximum value to be returned * @returns the clamped value */ function clamp$1(n, min, max) { return Math.min(max, Math.max(min, n)); } /** * constrain n to the given range, excluding the minimum, via modular arithmetic * * @param n - value * @param min - the minimum value to be returned, exclusive * @param max - the maximum value to be returned, inclusive * @returns constrained number */ function wrap(n, min, max) { const d = max - min; const w = ((n - min) % d + d) % d + min; return (w === min) ? max : w; } /** * Compute the difference between the keys in one object and the keys * in another object. * * @returns keys difference */ function keysDifference(obj, other) { const difference = []; for (const i in obj) { if (!(i in other)) { difference.push(i); } } return difference; } function extend(dest, ...sources) { for (const src of sources) { for (const k in src) { dest[k] = src[k]; } } return dest; } /** * Given an object and a number of properties as strings, return version * of that object with only those properties. * * @param src - the object * @param properties - an array of property names chosen * to appear on the resulting object. * @returns object with limited properties. * @example * ```ts * let foo = { name: 'Charlie', age: 10 }; * let justName = pick(foo, ['name']); // justName = { name: 'Charlie' } * ``` */ function pick(src, properties) { const result = {}; for (let i = 0; i < properties.length; i++) { const k = properties[i]; if (k in src) { result[k] = src[k]; } } return result; } let id = 1; /** * Return a unique numeric id, starting at 1 and incrementing with * each call. * * @returns unique numeric id. */ function uniqueId() { return id++; } /** * Return whether a given value is a power of two */ function isPowerOfTwo(value) { return (Math.log(value) / Math.LN2) % 1 === 0; } /** * Return the next power of two, or the input value if already a power of two */ function nextPowerOfTwo(value) { if (value <= 1) return 1; return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2)); } /** * Create an object by mapping all the values of an existing object while * preserving their keys. */ function mapObject(input, iterator, context) { const output = {}; for (const key in input) { output[key] = iterator.call(context || this, input[key], key, input); } return output; } /** * Create an object by filtering out values of an existing object. */ function filterObject(input, iterator, context) { const output = {}; for (const key in input) { if (iterator.call(context || this, input[key], key, input)) { output[key] = input[key]; } } return output; } /** * Deeply compares two object literals. * @param a - first object literal to be compared * @param b - second object literal to be compared * @returns true if the two object literals are deeply equal, false otherwise */ function deepEqual$1(a, b) { if (Array.isArray(a)) { if (!Array.isArray(b) || a.length !== b.length) return false; for (let i = 0; i < a.length; i++) { if (!deepEqual$1(a[i], b[i])) return false; } return true; } if (typeof a === 'object' && a !== null && b !== null) { if (!(typeof b === 'object')) return false; const keys = Object.keys(a); if (keys.length !== Object.keys(b).length) return false; for (const key in a) { if (!deepEqual$1(a[key], b[key])) return false; } return true; } return a === b; } /** * Deeply clones two objects. */ function clone$9(input) { if (Array.isArray(input)) { return input.map(clone$9); } else if (typeof input === 'object' && input) { return mapObject(input, clone$9); } else { return input; } } /** * Check if two arrays have at least one common element. */ function arraysIntersect(a, b) { for (let l = 0; l < a.length; l++) { if (b.indexOf(a[l]) >= 0) return true; } return false; } /** * Print a warning message to the console and ensure duplicate warning messages * are not printed. */ const warnOnceHistory = {}; function warnOnce(message) { if (!warnOnceHistory[message]) { // console isn't defined in some WebWorkers, see #2558 if (typeof console !== 'undefined') console.warn(message); warnOnceHistory[message] = true; } } /** * Indicates if the provided Points are in a counter clockwise (true) or clockwise (false) order * * @returns true for a counter clockwise set of points */ // https://bryceboe.com/2006/10/23/line-segment-intersection-algorithm/ function isCounterClockwise(a, b, c) { return (c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x); } /** * For two lines a and b in 2d space, defined by any two points along the lines, * find the intersection point, or return null if the lines are parallel * * @param a1 - First point on line a * @param a2 - Second point on line a * @param b1 - First point on line b * @param b2 - Second point on line b * * @returns the intersection point of the two lines or null if they are parallel */ function findLineIntersection(a1, a2, b1, b2) { const aDeltaY = a2.y - a1.y; const aDeltaX = a2.x - a1.x; const bDeltaY = b2.y - b1.y; const bDeltaX = b2.x - b1.x; const denominator = (bDeltaY * aDeltaX) - (bDeltaX * aDeltaY); if (denominator === 0) { // Lines are parallel return null; } const originDeltaY = a1.y - b1.y; const originDeltaX = a1.x - b1.x; const aInterpolation = (bDeltaX * originDeltaY - bDeltaY * originDeltaX) / denominator; // Find intersection by projecting out from origin of first segment return new Point$2(a1.x + (aInterpolation * aDeltaX), a1.y + (aInterpolation * aDeltaY)); } /** * Converts spherical coordinates to cartesian coordinates. * * @param spherical - Spherical coordinates, in [radial, azimuthal, polar] * @returns cartesian coordinates in [x, y, z] */ function sphericalToCartesian([r, azimuthal, polar]) { // We abstract "north"/"up" (compass-wise) to be 0° when really this is 90° (π/2): // correct for that here azimuthal += 90; // Convert azimuthal and polar angles to radians azimuthal *= Math.PI / 180; polar *= Math.PI / 180; return { x: r * Math.cos(azimuthal) * Math.sin(polar), y: r * Math.sin(azimuthal) * Math.sin(polar), z: r * Math.cos(polar) }; } /** * Returns true if the when run in the web-worker context. * * @returns `true` if the when run in the web-worker context. */ function isWorker(self) { // @ts-ignore return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope; } /** * Parses data from 'Cache-Control' headers. * * @param cacheControl - Value of 'Cache-Control' header * @returns object containing parsed header info. */ function parseCacheControl(cacheControl) { // Taken from [Wreck](https://github.com/hapijs/wreck) const re = /(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g; const header = {}; cacheControl.replace(re, ($0, $1, $2, $3) => { const value = $2 || $3; header[$1] = value ? value.toLowerCase() : true; return ''; }); if (header['max-age']) { const maxAge = parseInt(header['max-age'], 10); if (isNaN(maxAge)) delete header['max-age']; else header['max-age'] = maxAge; } return header; } let _isSafari = null; /** * Returns true when run in WebKit derived browsers. * This is used as a workaround for a memo