@loaders.gl/worker-utils 3.4.0-alpha.5 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VERSION = void 0;
7
- var DEFAULT_VERSION = 'beta';
8
- var VERSION = typeof "3.4.0-alpha.5" !== 'undefined' ? "3.4.0-alpha.5" : DEFAULT_VERSION;
7
+ var DEFAULT_VERSION = 'latest';
8
+ var VERSION = typeof "3.4.1" !== 'undefined' ? "3.4.1" : DEFAULT_VERSION;
9
9
  exports.VERSION = VERSION;
10
- if (typeof "3.4.0-alpha.5" === 'undefined') {
10
+ if (typeof "3.4.1" === 'undefined') {
11
11
  console.error('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.');
12
12
  }
13
13
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":["DEFAULT_VERSION","VERSION","exports","console","error"],"sources":["../../../../src/lib/env-utils/version.ts"],"sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n\n// Change to `latest` on production branches\nconst DEFAULT_VERSION = 'beta';\ndeclare let __VERSION__: string;\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : DEFAULT_VERSION;\nif (typeof __VERSION__ === 'undefined') {\n // eslint-disable-next-line\n console.error(\n 'loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.'\n );\n}\n"],"mappings":";;;;;;AAIA,IAAMA,eAAe,GAAG,MAAM;AAEvB,IAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiBD,eAAe;AAACE,OAAA,CAAAD,OAAA,GAAAA,OAAA;AAC1F,IAAI,sBAAkB,KAAK,WAAW,EAAE;EAEtCE,OAAO,CAACC,KAAK,CACX,iIACF,CAAC;AACH"}
1
+ {"version":3,"file":"version.js","names":["DEFAULT_VERSION","VERSION","exports","console","error"],"sources":["../../../../src/lib/env-utils/version.ts"],"sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n\n// Change to `latest` on production branches\nconst DEFAULT_VERSION = 'latest';\ndeclare let __VERSION__: string;\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : DEFAULT_VERSION;\nif (typeof __VERSION__ === 'undefined') {\n // eslint-disable-next-line\n console.error(\n 'loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.'\n );\n}\n"],"mappings":";;;;;;AAIA,IAAMA,eAAe,GAAG,QAAQ;AAEzB,IAAMC,OAAO,GAAG,cAAkB,KAAK,WAAW,aAAiBD,eAAe;AAACE,OAAA,CAAAD,OAAA,GAAAA,OAAA;AAC1F,IAAI,cAAkB,KAAK,WAAW,EAAE;EAEtCE,OAAO,CAACC,KAAK,CACX,iIACF,CAAC;AACH"}
@@ -15,8 +15,8 @@ var _assert = require("../env-utils/assert");
15
15
  var _version = require("../env-utils/version");
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
- var LATEST = 'beta';
19
- var VERSION = typeof "3.4.0-alpha.5" !== 'undefined' ? "3.4.0-alpha.5" : LATEST;
18
+ var LATEST = 'latest';
19
+ var VERSION = typeof "3.4.1" !== 'undefined' ? "3.4.1" : LATEST;
20
20
  var loadLibraryPromises = {};
21
21
  function loadLibrary(_x) {
22
22
  return _loadLibrary.apply(this, arguments);
@@ -1 +1 @@
1
- {"version":3,"file":"library-utils.js","names":["_globals","require","node","_interopRequireWildcard","_assert","_version","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","LATEST","VERSION","loadLibraryPromises","loadLibrary","_x","_loadLibrary","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","libraryUrl","moduleName","options","_args","wrap","_callee$","_context","prev","next","length","undefined","getLibraryUrl","loadLibraryFromFile","abrupt","sent","stop","library","startsWith","modules","isBrowser","concat","CDN","assert","isWorker","_x2","_loadLibraryFromFile","_callee2","_response","response","scriptSource","_callee2$","_context2","endsWith","fetch","arrayBuffer","t0","requireFromFile","t1","importScripts","text","loadLibraryFromString","id","requireFromString","eval","global","script","document","createElement","appendChild","createTextNode","e","body"],"sources":["../../../../src/lib/library-utils/library-utils.ts"],"sourcesContent":["/* global importScripts */\nimport {global, isBrowser, isWorker} from '../env-utils/globals';\nimport * as node from '../node/require-utils.node';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\n/**\n * TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...\n * 'beta' on beta branch, 'latest' on prod branch\n */\nconst LATEST = 'beta';\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : LATEST;\n\nconst loadLibraryPromises: Record<string, Promise<any>> = {}; // promises\n\n/**\n * Dynamically loads a library (\"module\")\n *\n * - wasm library: Array buffer is returned\n * - js library: Parse JS is returned\n *\n * Method depends on environment\n * - browser - script element is created and installed on document\n * - worker - eval is called on global context\n * - node - file is required\n *\n * @param libraryUrl\n * @param moduleName\n * @param options\n */\nexport async function loadLibrary(\n libraryUrl: string,\n moduleName: string | null = null,\n options: object = {}\n): Promise<any> {\n if (moduleName) {\n libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);\n }\n\n // Ensure libraries are only loaded once\n\n loadLibraryPromises[libraryUrl] =\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);\n return await loadLibraryPromises[libraryUrl];\n}\n\n// TODO - sort out how to resolve paths for main/worker and dev/prod\nexport function getLibraryUrl(library: string, moduleName?: string, options?: any): string {\n // Check if already a URL\n if (library.startsWith('http')) {\n return library;\n }\n\n // Allow application to import and supply libraries through `options.modules`\n const modules = options.modules || {};\n if (modules[library]) {\n return modules[library];\n }\n\n // Load from local files, not from CDN scripts in Node.js\n // TODO - needs to locate the modules directory when installed!\n if (!isBrowser) {\n return `modules/${moduleName}/dist/libs/${library}`;\n }\n\n // In browser, load from external scripts\n if (options.CDN) {\n assert(options.CDN.startsWith('http'));\n return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${library}`;\n }\n\n // TODO - loading inside workers requires paths relative to worker script location...\n if (isWorker) {\n return `../src/libs/${library}`;\n }\n\n return `modules/${moduleName}/src/libs/${library}`;\n}\n\nasync function loadLibraryFromFile(libraryUrl: string): Promise<any> {\n if (libraryUrl.endsWith('wasm')) {\n const response = await fetch(libraryUrl);\n return await response.arrayBuffer();\n }\n\n if (!isBrowser) {\n try {\n return node && node.requireFromFile && (await node.requireFromFile(libraryUrl));\n } catch {\n return null;\n }\n }\n if (isWorker) {\n return importScripts(libraryUrl);\n }\n // TODO - fix - should be more secure than string parsing since observes CORS\n // if (isBrowser) {\n // return await loadScriptFromFile(libraryUrl);\n // }\n\n const response = await fetch(libraryUrl);\n const scriptSource = await response.text();\n return loadLibraryFromString(scriptSource, libraryUrl);\n}\n\n/*\nasync function loadScriptFromFile(libraryUrl) {\n const script = document.createElement('script');\n script.src = libraryUrl;\n return await new Promise((resolve, reject) => {\n script.onload = data => {\n resolve(data);\n };\n script.onerror = reject;\n });\n}\n*/\n\n// TODO - Needs security audit...\n// - Raw eval call\n// - Potentially bypasses CORS\n// Upside is that this separates fetching and parsing\n// we could create a`LibraryLoader` or`ModuleLoader`\nfunction loadLibraryFromString(scriptSource: string, id: string): null | any {\n if (!isBrowser) {\n return node.requireFromString && node.requireFromString(scriptSource, id);\n }\n\n if (isWorker) {\n // Use lvalue trick to make eval run in global scope\n eval.call(global, scriptSource); // eslint-disable-line no-eval\n // https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript\n // http://perfectionkills.com/global-eval-what-are-the-options/\n return null;\n }\n\n const script = document.createElement('script');\n script.id = id;\n // most browsers like a separate text node but some throw an error. The second method covers those.\n try {\n script.appendChild(document.createTextNode(scriptSource));\n } catch (e) {\n script.text = scriptSource;\n }\n document.body.appendChild(script);\n return null;\n}\n\n// TODO - technique for module injection into worker, from THREE.DracoLoader...\n/*\nfunction combineWorkerWithLibrary(worker, jsContent) {\n var fn = wWorker.toString();\n var body = [\n '// injected',\n jsContent,\n '',\n '// worker',\n fn.substring(fn.indexOf('{') + 1, fn.lastIndexOf('}'))\n ].join('\\n');\n this.workerSourceURL = URL.createObjectURL(new Blob([body]));\n}\n*/\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAA4D,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,i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B,IAAA;MAAA;IAAA,GAAAW,QAAA;EAAA,CACvD;EAAA,OAAAD,oBAAA,CAAA/B,KAAA,OAAAC,SAAA;AAAA;AAoBD,SAAS6C,qBAAqBA,CAACX,YAAoB,EAAEY,EAAU,EAAc;EAC3E,IAAI,CAACtB,kBAAS,EAAE;IACd,OAAO1D,IAAI,CAACiF,iBAAiB,IAAIjF,IAAI,CAACiF,iBAAiB,CAACb,YAAY,EAAEY,EAAE,CAAC;EAC3E;EAEA,IAAIlB,iBAAQ,EAAE;IAEZoB,IAAI,CAAC1D,IAAI,CAAC2D,eAAM,EAAEf,YAAY,CAAC;IAG/B,OAAO,IAAI;EACb;EAEA,IAAMgB,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;EAC/CF,MAAM,CAACJ,EAAE,GAAGA,EAAE;EAEd,IAAI;IACFI,MAAM,CAACG,WAAW,CAACF,QAAQ,CAACG,cAAc,CAACpB,YAAY,CAAC,CAAC;EAC3D,CAAC,CAAC,OAAOqB,CAAC,EAAE;IACVL,MAAM,CAACN,IAAI,GAAGV,YAAY;EAC5B;EACAiB,QAAQ,CAACK,IAAI,CAACH,WAAW,CAACH,MAAM,CAAC;EACjC,OAAO,IAAI;AACb"}
1
+ {"version":3,"file":"library-utils.js","names":["_globals","require","node","_interopRequireWildcard","_assert","_version","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","LATEST","VERSION","loadLibraryPromises","loadLibrary","_x","_loadLibrary","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","libraryUrl","moduleName","options","_args","wrap","_callee$","_context","prev","next","length","undefined","getLibraryUrl","loadLibraryFromFile","abrupt","sent","stop","library","startsWith","modules","isBrowser","concat","CDN","assert","isWorker","_x2","_loadLibraryFromFile","_callee2","_response","response","scriptSource","_callee2$","_context2","endsWith","fetch","arrayBuffer","t0","requireFromFile","t1","importScripts","text","loadLibraryFromString","id","requireFromString","eval","global","script","document","createElement","appendChild","createTextNode","e","body"],"sources":["../../../../src/lib/library-utils/library-utils.ts"],"sourcesContent":["/* global importScripts */\nimport {global, isBrowser, isWorker} from '../env-utils/globals';\nimport * as node from '../node/require-utils.node';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\n/**\n * TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...\n * 'beta' on beta branch, 'latest' on prod branch\n */\nconst LATEST = 'latest';\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : LATEST;\n\nconst loadLibraryPromises: Record<string, Promise<any>> = {}; // promises\n\n/**\n * Dynamically loads a library (\"module\")\n *\n * - wasm library: Array buffer is returned\n * - js library: Parse JS is returned\n *\n * Method depends on environment\n * - browser - script element is created and installed on document\n * - worker - eval is called on global context\n * - node - file is required\n *\n * @param libraryUrl\n * @param moduleName\n * @param options\n */\nexport async function loadLibrary(\n libraryUrl: string,\n moduleName: string | null = null,\n options: object = {}\n): Promise<any> {\n if (moduleName) {\n libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);\n }\n\n // Ensure libraries are only loaded once\n\n loadLibraryPromises[libraryUrl] =\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);\n return await loadLibraryPromises[libraryUrl];\n}\n\n// TODO - sort out how to resolve paths for main/worker and dev/prod\nexport function getLibraryUrl(library: string, moduleName?: string, options?: any): string {\n // Check if already a URL\n if (library.startsWith('http')) {\n return library;\n }\n\n // Allow application to import and supply libraries through `options.modules`\n const modules = options.modules || {};\n if (modules[library]) {\n return modules[library];\n }\n\n // Load from local files, not from CDN scripts in Node.js\n // TODO - needs to locate the modules directory when installed!\n if (!isBrowser) {\n return `modules/${moduleName}/dist/libs/${library}`;\n }\n\n // In browser, load from external scripts\n if (options.CDN) {\n assert(options.CDN.startsWith('http'));\n return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${library}`;\n }\n\n // TODO - loading inside workers requires paths relative to worker script location...\n if (isWorker) {\n return `../src/libs/${library}`;\n }\n\n return `modules/${moduleName}/src/libs/${library}`;\n}\n\nasync function loadLibraryFromFile(libraryUrl: string): Promise<any> {\n if (libraryUrl.endsWith('wasm')) {\n const response = await fetch(libraryUrl);\n return await response.arrayBuffer();\n }\n\n if (!isBrowser) {\n try {\n return node && node.requireFromFile && (await node.requireFromFile(libraryUrl));\n } catch {\n return null;\n }\n }\n if (isWorker) {\n return importScripts(libraryUrl);\n }\n // TODO - fix - should be more secure than string parsing since observes CORS\n // if (isBrowser) {\n // return await loadScriptFromFile(libraryUrl);\n // }\n\n const response = await fetch(libraryUrl);\n const scriptSource = await response.text();\n return loadLibraryFromString(scriptSource, libraryUrl);\n}\n\n/*\nasync function loadScriptFromFile(libraryUrl) {\n const script = document.createElement('script');\n script.src = libraryUrl;\n return await new Promise((resolve, reject) => {\n script.onload = data => {\n resolve(data);\n };\n script.onerror = reject;\n });\n}\n*/\n\n// TODO - Needs security audit...\n// - Raw eval call\n// - Potentially bypasses CORS\n// Upside is that this separates fetching and parsing\n// we could create a`LibraryLoader` or`ModuleLoader`\nfunction loadLibraryFromString(scriptSource: string, id: string): null | any {\n if (!isBrowser) {\n return node.requireFromString && node.requireFromString(scriptSource, id);\n }\n\n if (isWorker) {\n // Use lvalue trick to make eval run in global scope\n eval.call(global, scriptSource); // eslint-disable-line no-eval\n // https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript\n // http://perfectionkills.com/global-eval-what-are-the-options/\n return null;\n }\n\n const script = document.createElement('script');\n script.id = id;\n // most browsers like a separate text node but some throw an error. The second method covers those.\n try {\n script.appendChild(document.createTextNode(scriptSource));\n } catch (e) {\n script.text = scriptSource;\n }\n document.body.appendChild(script);\n return null;\n}\n\n// TODO - technique for module injection into worker, from THREE.DracoLoader...\n/*\nfunction combineWorkerWithLibrary(worker, jsContent) {\n var fn = wWorker.toString();\n var body = [\n '// injected',\n jsContent,\n '',\n '// worker',\n fn.substring(fn.indexOf('{') + 1, fn.lastIndexOf('}'))\n ].join('\\n');\n this.workerSourceURL = URL.createObjectURL(new Blob([body]));\n}\n*/\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAA4D,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,4BAAAG,OAAA,EAAAH,GAAA,UAAAI,KAAA,GAAAT,wBAAA,CAAAC,WAAA,OAAAQ,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAL,GAAA,YAAAI,KAAA,CAAAE,GAAA,CAAAN,GAAA,SAAAO,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAZ,GAAA,QAAAY,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAf,GAAA,EAAAY,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAX,GAAA,EAAAY,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MA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L = getWorkerURL;
8
8
  var _assert = require("../env-utils/assert");
9
9
  var _version = require("../env-utils/version");
10
- var NPM_TAG = 'beta';
11
- var VERSION = typeof "3.4.0-alpha.5" !== 'undefined' ? "3.4.0-alpha.5" : NPM_TAG;
10
+ var NPM_TAG = 'latest';
11
+ var VERSION = typeof "3.4.1" !== 'undefined' ? "3.4.1" : NPM_TAG;
12
12
  function getWorkerName(worker) {
13
13
  var warning = worker.version !== VERSION ? " (worker-utils@".concat(VERSION, ")") : '';
14
14
  return "".concat(worker.name, "@").concat(worker.version).concat(warning);
@@ -1 +1 @@
1
- {"version":3,"file":"get-worker-url.js","names":["_assert","require","_version","NPM_TAG","VERSION","getWorkerName","worker","warning","version","concat","name","getWorkerURL","options","arguments","length","undefined","workerOptions","id","workerFile","url","workerUrl","_workerType","module","versionTag","assert"],"sources":["../../../../src/lib/worker-api/get-worker-url.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {WorkerObject, WorkerOptions} from '../../types';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\nconst NPM_TAG = 'beta'; // 'beta', or 'latest' on release-branch\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : NPM_TAG;\n\n/**\n * Gets worker object's name (for debugging in Chrome thread inspector window)\n */\nexport function getWorkerName(worker: WorkerObject): string {\n const warning = worker.version !== VERSION ? ` (worker-utils@${VERSION})` : '';\n return `${worker.name}@${worker.version}${warning}`;\n}\n\n/**\n * Generate a worker URL based on worker object and options\n * @returns A URL to one of the following:\n * - a published worker on unpkg CDN\n * - a local test worker\n * - a URL provided by the user in options\n */\nexport function getWorkerURL(worker: WorkerObject, options: WorkerOptions = {}): string {\n const workerOptions = options[worker.id] || {};\n\n const workerFile = `${worker.id}-worker.js`;\n\n let url = workerOptions.workerUrl;\n\n // HACK: Allow for non-nested workerUrl for the CompressionWorker.\n // For the compression worker, workerOptions is currently not nested correctly. For most loaders,\n // you'd have options within an object, i.e. `{mvt: {coordinates: ...}}` but the CompressionWorker\n // puts options at the top level, not within a `compression` key (its `id`). For this reason, the\n // above `workerOptions` will always be a string (i.e. `'gzip'`) for the CompressionWorker. To not\n // break backwards compatibility, we allow the CompressionWorker to have options at the top level.\n if (!url && worker.id === 'compression') {\n url = options.workerUrl;\n }\n\n // If URL is test, generate local loaders.gl url\n // @ts-ignore _workerType\n if (options._workerType === 'test') {\n url = `modules/${worker.module}/dist/${workerFile}`;\n }\n\n // If url override is not provided, generate a URL to published version on npm CDN unpkg.com\n if (!url) {\n // GENERATE\n let version = worker.version;\n // On master we need to load npm alpha releases published with the `beta` tag\n if (version === 'latest') {\n // throw new Error('latest worker version specified');\n version = NPM_TAG;\n }\n const versionTag = version ? `@${version}` : '';\n url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;\n }\n\n assert(url);\n\n // Allow user to override location\n return url;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAME,OAAO,GAAG,MAAM;AACtB,IAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiBD,OAAO;AAKnE,SAASE,aAAaA,CAACC,MAAoB,EAAU;EAC1D,IAAMC,OAAO,GAAGD,MAAM,CAACE,OAAO,KAAKJ,OAAO,qBAAAK,MAAA,CAAqBL,OAAO,SAAM,EAAE;EAC9E,UAAAK,MAAA,CAAUH,MAAM,CAACI,IAAI,OAAAD,MAAA,CAAIH,MAAM,CAACE,OAAO,EAAAC,MAAA,CAAGF,OAAO;AACnD;AASO,SAASI,YAAYA,CAACL,MAAoB,EAAuC;EAAA,IAArCM,OAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC5E,IAAMG,aAAa,GAAGJ,OAAO,CAACN,MAAM,CAACW,EAAE,CAAC,IAAI,CAAC,CAAC;EAE9C,IAAMC,UAAU,MAAAT,MAAA,CAAMH,MAAM,CAACW,EAAE,eAAY;EAE3C,IAAIE,GAAG,GAAGH,aAAa,CAACI,SAAS;EAQjC,IAAI,CAACD,GAAG,IAAIb,MAAM,CAACW,EAAE,KAAK,aAAa,EAAE;IACvCE,GAAG,GAAGP,OAAO,CAACQ,SAAS;EACzB;EAIA,IAAIR,OAAO,CAACS,WAAW,KAAK,MAAM,EAAE;IAClCF,GAAG,cAAAV,MAAA,CAAcH,MAAM,CAACgB,MAAM,YAAAb,MAAA,CAASS,UAAU,CAAE;EACrD;EAGA,IAAI,CAACC,GAAG,EAAE;IAER,IAAIX,OAAO,GAAGF,MAAM,CAACE,OAAO;IAE5B,IAAIA,OAAO,KAAK,QAAQ,EAAE;MAExBA,OAAO,GAAGL,OAAO;IACnB;IACA,IAAMoB,UAAU,GAAGf,OAAO,OAAAC,MAAA,CAAOD,OAAO,IAAK,EAAE;IAC/CW,GAAG,oCAAAV,MAAA,CAAoCH,MAAM,CAACgB,MAAM,EAAAb,MAAA,CAAGc,UAAU,YAAAd,MAAA,CAASS,UAAU,CAAE;EACxF;EAEA,IAAAM,cAAM,EAACL,GAAG,CAAC;EAGX,OAAOA,GAAG;AACZ"}
1
+ {"version":3,"file":"get-worker-url.js","names":["_assert","require","_version","NPM_TAG","VERSION","getWorkerName","worker","warning","version","concat","name","getWorkerURL","options","arguments","length","undefined","workerOptions","id","workerFile","url","workerUrl","_workerType","module","versionTag","assert"],"sources":["../../../../src/lib/worker-api/get-worker-url.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {WorkerObject, WorkerOptions} from '../../types';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\nconst NPM_TAG = 'latest'; // 'beta', or 'latest' on release-branch\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : NPM_TAG;\n\n/**\n * Gets worker object's name (for debugging in Chrome thread inspector window)\n */\nexport function getWorkerName(worker: WorkerObject): string {\n const warning = worker.version !== VERSION ? ` (worker-utils@${VERSION})` : '';\n return `${worker.name}@${worker.version}${warning}`;\n}\n\n/**\n * Generate a worker URL based on worker object and options\n * @returns A URL to one of the following:\n * - a published worker on unpkg CDN\n * - a local test worker\n * - a URL provided by the user in options\n */\nexport function getWorkerURL(worker: WorkerObject, options: WorkerOptions = {}): string {\n const workerOptions = options[worker.id] || {};\n\n const workerFile = `${worker.id}-worker.js`;\n\n let url = workerOptions.workerUrl;\n\n // HACK: Allow for non-nested workerUrl for the CompressionWorker.\n // For the compression worker, workerOptions is currently not nested correctly. For most loaders,\n // you'd have options within an object, i.e. `{mvt: {coordinates: ...}}` but the CompressionWorker\n // puts options at the top level, not within a `compression` key (its `id`). For this reason, the\n // above `workerOptions` will always be a string (i.e. `'gzip'`) for the CompressionWorker. To not\n // break backwards compatibility, we allow the CompressionWorker to have options at the top level.\n if (!url && worker.id === 'compression') {\n url = options.workerUrl;\n }\n\n // If URL is test, generate local loaders.gl url\n // @ts-ignore _workerType\n if (options._workerType === 'test') {\n url = `modules/${worker.module}/dist/${workerFile}`;\n }\n\n // If url override is not provided, generate a URL to published version on npm CDN unpkg.com\n if (!url) {\n // GENERATE\n let version = worker.version;\n // On master we need to load npm alpha releases published with the `beta` tag\n if (version === 'latest') {\n // throw new Error('latest worker version specified');\n version = NPM_TAG;\n }\n const versionTag = version ? `@${version}` : '';\n url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;\n }\n\n assert(url);\n\n // Allow user to override location\n return url;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAME,OAAO,GAAG,QAAQ;AACxB,IAAMC,OAAO,GAAG,cAAkB,KAAK,WAAW,aAAiBD,OAAO;AAKnE,SAASE,aAAaA,CAACC,MAAoB,EAAU;EAC1D,IAAMC,OAAO,GAAGD,MAAM,CAACE,OAAO,KAAKJ,OAAO,qBAAAK,MAAA,CA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pha.5" : DEFAULT_VERSION;
3
- if (typeof "3.4.0-alpha.5" === 'undefined') {
1
+ const DEFAULT_VERSION = 'latest';
2
+ export const VERSION = typeof "3.4.1" !== 'undefined' ? "3.4.1" : DEFAULT_VERSION;
3
+ if (typeof "3.4.1" === 'undefined') {
4
4
  console.error('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.');
5
5
  }
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":["DEFAULT_VERSION","VERSION","console","error"],"sources":["../../../../src/lib/env-utils/version.ts"],"sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n\n// Change to `latest` on production branches\nconst DEFAULT_VERSION = 'beta';\ndeclare let __VERSION__: string;\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : DEFAULT_VERSION;\nif (typeof __VERSION__ === 'undefined') {\n // eslint-disable-next-line\n console.error(\n 'loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.'\n );\n}\n"],"mappings":"AAIA,MAAMA,eAAe,GAAG,MAAM;AAE9B,OAAO,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiBD,eAAe;AACzF,IAAI,sBAAkB,KAAK,WAAW,EAAE;EAEtCE,OAAO,CAACC,KAAK,CACX,iIACF,CAAC;AACH"}
1
+ {"version":3,"file":"version.js","names":["DEFAULT_VERSION","VERSION","console","error"],"sources":["../../../../src/lib/env-utils/version.ts"],"sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n\n// Change to `latest` on production branches\nconst DEFAULT_VERSION = 'latest';\ndeclare let __VERSION__: string;\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : DEFAULT_VERSION;\nif (typeof __VERSION__ === 'undefined') {\n // eslint-disable-next-line\n console.error(\n 'loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.'\n );\n}\n"],"mappings":"AAIA,MAAMA,eAAe,GAAG,QAAQ;AAEhC,OAAO,MAAMC,OAAO,GAAG,cAAkB,KAAK,WAAW,aAAiBD,eAAe;AACzF,IAAI,cAAkB,KAAK,WAAW,EAAE;EAEtCE,OAAO,CAACC,KAAK,CACX,iIACF,CAAC;AACH"}
@@ -2,8 +2,8 @@ import { global, isBrowser, isWorker } from '../env-utils/globals';
2
2
  import * as node from '../node/require-utils.node';
3
3
  import { assert } from '../env-utils/assert';
4
4
  import { VERSION as __VERSION__ } from '../env-utils/version';
5
- const LATEST = 'beta';
6
- const VERSION = typeof "3.4.0-alpha.5" !== 'undefined' ? "3.4.0-alpha.5" : LATEST;
5
+ const LATEST = 'latest';
6
+ const VERSION = typeof "3.4.1" !== 'undefined' ? "3.4.1" : LATEST;
7
7
  const loadLibraryPromises = {};
8
8
  export async function loadLibrary(libraryUrl) {
9
9
  let moduleName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
@@ -1 +1 @@
1
- {"version":3,"file":"library-utils.js","names":["global","isBrowser","isWorker","node","assert","VERSION","__VERSION__","LATEST","loadLibraryPromises","loadLibrary","libraryUrl","moduleName","arguments","length","undefined","options","getLibraryUrl","loadLibraryFromFile","library","startsWith","modules","concat","CDN","endsWith","response","fetch","arrayBuffer","requireFromFile","importScripts","scriptSource","text","loadLibraryFromString","id","requireFromString","eval","call","script","document","createElement","appendChild","createTextNode","e","body"],"sources":["../../../../src/lib/library-utils/library-utils.ts"],"sourcesContent":["/* global importScripts */\nimport {global, isBrowser, isWorker} from '../env-utils/globals';\nimport * as node from '../node/require-utils.node';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\n/**\n * TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...\n * 'beta' on beta branch, 'latest' on prod branch\n */\nconst LATEST = 'beta';\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : LATEST;\n\nconst loadLibraryPromises: Record<string, Promise<any>> = {}; // promises\n\n/**\n * Dynamically loads a library (\"module\")\n *\n * - wasm library: Array buffer is returned\n * - js library: Parse JS is returned\n *\n * Method depends on environment\n * - browser - script element is created and installed on document\n * - worker - eval is called on global context\n * - node - file is required\n *\n * @param libraryUrl\n * @param moduleName\n * @param options\n */\nexport async function loadLibrary(\n libraryUrl: string,\n moduleName: string | null = null,\n options: object = {}\n): Promise<any> {\n if (moduleName) {\n libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);\n }\n\n // Ensure libraries are only loaded once\n\n loadLibraryPromises[libraryUrl] =\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);\n return await loadLibraryPromises[libraryUrl];\n}\n\n// TODO - sort out how to resolve paths for main/worker and dev/prod\nexport function getLibraryUrl(library: string, moduleName?: string, options?: any): string {\n // Check if already a URL\n if (library.startsWith('http')) {\n return library;\n }\n\n // Allow application to import and supply libraries through `options.modules`\n const modules = options.modules || {};\n if (modules[library]) {\n return modules[library];\n }\n\n // Load from local files, not from CDN scripts in Node.js\n // TODO - needs to locate the modules directory when installed!\n if (!isBrowser) {\n return `modules/${moduleName}/dist/libs/${library}`;\n }\n\n // In browser, load from external scripts\n if (options.CDN) {\n assert(options.CDN.startsWith('http'));\n return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${library}`;\n }\n\n // TODO - loading inside workers requires paths relative to worker script location...\n if (isWorker) {\n return `../src/libs/${library}`;\n }\n\n return `modules/${moduleName}/src/libs/${library}`;\n}\n\nasync function loadLibraryFromFile(libraryUrl: string): Promise<any> {\n if (libraryUrl.endsWith('wasm')) {\n const response = await fetch(libraryUrl);\n return await response.arrayBuffer();\n }\n\n if (!isBrowser) {\n try {\n return node && node.requireFromFile && (await node.requireFromFile(libraryUrl));\n } catch {\n return null;\n }\n }\n if (isWorker) {\n return importScripts(libraryUrl);\n }\n // TODO - fix - should be more secure than string parsing since observes CORS\n // if (isBrowser) {\n // return await loadScriptFromFile(libraryUrl);\n // }\n\n const response = await fetch(libraryUrl);\n const scriptSource = await response.text();\n return loadLibraryFromString(scriptSource, libraryUrl);\n}\n\n/*\nasync function loadScriptFromFile(libraryUrl) {\n const script = document.createElement('script');\n script.src = libraryUrl;\n return await new Promise((resolve, reject) => {\n script.onload = data => {\n resolve(data);\n };\n script.onerror = reject;\n });\n}\n*/\n\n// TODO - Needs security audit...\n// - Raw eval call\n// - Potentially bypasses CORS\n// Upside is that this separates fetching and parsing\n// we could create a`LibraryLoader` or`ModuleLoader`\nfunction loadLibraryFromString(scriptSource: string, id: string): null | any {\n if (!isBrowser) {\n return node.requireFromString && node.requireFromString(scriptSource, id);\n }\n\n if (isWorker) {\n // Use lvalue trick to make eval run in global scope\n eval.call(global, scriptSource); // eslint-disable-line no-eval\n // https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript\n // http://perfectionkills.com/global-eval-what-are-the-options/\n return null;\n }\n\n const script = document.createElement('script');\n script.id = id;\n // most browsers like a separate text node but some throw an error. The second method covers those.\n try {\n script.appendChild(document.createTextNode(scriptSource));\n } catch (e) {\n script.text = scriptSource;\n }\n document.body.appendChild(script);\n return null;\n}\n\n// TODO - technique for module injection into worker, from THREE.DracoLoader...\n/*\nfunction combineWorkerWithLibrary(worker, jsContent) {\n var fn = wWorker.toString();\n var body = [\n '// injected',\n jsContent,\n '',\n '// worker',\n fn.substring(fn.indexOf('{') + 1, fn.lastIndexOf('}'))\n ].join('\\n');\n this.workerSourceURL = URL.createObjectURL(new Blob([body]));\n}\n*/\n"],"mappings":"AACA,SAAQA,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAO,sBAAsB;AAChE,OAAO,KAAKC,IAAI,MAAM,4BAA4B;AAClD,SAAQC,MAAM,QAAO,qBAAqB;AAC1C,SAAQC,OAAO,IAAIC,WAAW,QAAO,sBAAsB;AAM3D,M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/CF,MAAM,CAACJ,EAAE,GAAGA,EAAE;EAEd,IAAI;IACFI,MAAM,CAACG,WAAW,CAACF,QAAQ,CAACG,cAAc,CAACX,YAAY,CAAC,CAAC;EAC3D,CAAC,CAAC,OAAOY,CAAC,EAAE;IACVL,MAAM,CAACN,IAAI,GAAGD,YAAY;EAC5B;EACAQ,QAAQ,CAACK,IAAI,CAACH,WAAW,CAACH,MAAM,CAAC;EACjC,OAAO,IAAI;AACb"}
1
+ {"version":3,"file":"library-utils.js","names":["global","isBrowser","isWorker","node","assert","VERSION","__VERSION__","LATEST","loadLibraryPromises","loadLibrary","libraryUrl","moduleName","arguments","length","undefined","options","getLibraryUrl","loadLibraryFromFile","library","startsWith","modules","concat","CDN","endsWith","response","fetch","arrayBuffer","requireFromFile","importScripts","scriptSource","text","loadLibraryFromString","id","requireFromString","eval","call","script","document","createElement","appendChild","createTextNode","e","body"],"sources":["../../../../src/lib/library-utils/library-utils.ts"],"sourcesContent":["/* global importScripts */\nimport {global, isBrowser, isWorker} from '../env-utils/globals';\nimport * as node from '../node/require-utils.node';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\n/**\n * TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...\n * 'beta' on beta branch, 'latest' on prod branch\n */\nconst LATEST = 'latest';\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : LATEST;\n\nconst loadLibraryPromises: Record<string, Promise<any>> = {}; // promises\n\n/**\n * Dynamically loads a library (\"module\")\n *\n * - wasm library: Array buffer is returned\n * - js library: Parse JS is returned\n *\n * Method depends on environment\n * - browser - script element is created and installed on document\n * - worker - eval is called on global context\n * - node - file is required\n *\n * @param libraryUrl\n * @param moduleName\n * @param options\n */\nexport async function loadLibrary(\n libraryUrl: string,\n moduleName: string | null = null,\n options: object = {}\n): Promise<any> {\n if (moduleName) {\n libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);\n }\n\n // Ensure libraries are only loaded once\n\n loadLibraryPromises[libraryUrl] =\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);\n return await loadLibraryPromises[libraryUrl];\n}\n\n// TODO - sort out how to resolve paths for main/worker and dev/prod\nexport function getLibraryUrl(library: string, moduleName?: string, options?: any): string {\n // Check if already a URL\n if (library.startsWith('http')) {\n return library;\n }\n\n // Allow application to import and supply libraries through `options.modules`\n const modules = options.modules || {};\n if (modules[library]) {\n return modules[library];\n }\n\n // Load from local files, not from CDN scripts in Node.js\n // TODO - needs to locate the modules directory when installed!\n if (!isBrowser) {\n return `modules/${moduleName}/dist/libs/${library}`;\n }\n\n // In browser, load from external scripts\n if (options.CDN) {\n assert(options.CDN.startsWith('http'));\n return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${library}`;\n }\n\n // TODO - loading inside workers requires paths relative to worker script location...\n if (isWorker) {\n return `../src/libs/${library}`;\n }\n\n return `modules/${moduleName}/src/libs/${library}`;\n}\n\nasync function loadLibraryFromFile(libraryUrl: string): Promise<any> {\n if (libraryUrl.endsWith('wasm')) {\n const response = await fetch(libraryUrl);\n return await response.arrayBuffer();\n }\n\n if (!isBrowser) {\n try {\n return node && node.requireFromFile && (await node.requireFromFile(libraryUrl));\n } catch {\n return null;\n }\n }\n if (isWorker) {\n return importScripts(libraryUrl);\n }\n // TODO - fix - should be more secure than string parsing since observes CORS\n // if (isBrowser) {\n // return await loadScriptFromFile(libraryUrl);\n // }\n\n const response = await fetch(libraryUrl);\n const scriptSource = await response.text();\n return loadLibraryFromString(scriptSource, libraryUrl);\n}\n\n/*\nasync function loadScriptFromFile(libraryUrl) {\n const script = document.createElement('script');\n script.src = libraryUrl;\n return await new Promise((resolve, reject) => {\n script.onload = data => {\n resolve(data);\n };\n script.onerror = reject;\n });\n}\n*/\n\n// TODO - Needs security audit...\n// - Raw eval call\n// - Potentially bypasses CORS\n// Upside is that this separates fetching and parsing\n// we could create a`LibraryLoader` or`ModuleLoader`\nfunction loadLibraryFromString(scriptSource: string, id: string): null | any {\n if (!isBrowser) {\n return node.requireFromString && node.requireFromString(scriptSource, id);\n }\n\n if (isWorker) {\n // Use lvalue trick to make eval run in global scope\n eval.call(global, scriptSource); // eslint-disable-line no-eval\n // https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript\n // http://perfectionkills.com/global-eval-what-are-the-options/\n return null;\n }\n\n const script = document.createElement('script');\n script.id = id;\n // most browsers like a separate text node but some throw an error. The second method covers those.\n try {\n script.appendChild(document.createTextNode(scriptSource));\n } catch (e) {\n script.text = scriptSource;\n }\n document.body.appendChild(script);\n return null;\n}\n\n// TODO - technique for module injection into worker, from THREE.DracoLoader...\n/*\nfunction combineWorkerWithLibrary(worker, jsContent) {\n var fn = wWorker.toString();\n var body = [\n '// injected',\n jsContent,\n '',\n '// worker',\n fn.substring(fn.indexOf('{') + 1, fn.lastIndexOf('}'))\n ].join('\\n');\n this.workerSourceURL = URL.createObjectURL(new Blob([body]));\n}\n*/\n"],"mappings":"AACA,SAAQA,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAO,sBAAsB;AAChE,OAAO,KAAKC,IAAI,MAAM,4BAA4B;AAClD,SAAQC,MAAM,QAAO,qBAAqB;AAC1C,SAAQC,OAAO,IAAIC,WAAW,QAAO,sBAAsB;AAM3D,MAAMC,MAAM,GAAG,QAAQ;AACvB,MAAMF,OAAO,GAAG,cAAkB,KAAK,WAAW,aAAiBE,MAAM;AAEzE,MAAMC,mBAAiD,GAAG,CAAC,CAAC;AAiB5D,OAAO,eAAeC,WAAWA,CAC/BC,UAAkB,EAGJ;EAAA,IAFdC,UAAyB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAAA,IAChCG,OAAe,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEpB,IAAID,UA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AC;EACrC;EAEA,IAAI,CAACzB,SAAS,EAAE;IACd,IAAI;MACF,OAAOE,IAAI,IAAIA,IAAI,CAACwB,eAAe,KAAK,MAAMxB,IAAI,CAACwB,eAAe,CAACjB,UAAU,CAAC,CAAC;IACjF,CAAC,CAAC,MAAM;MACN,OAAO,IAAI;IACb;EACF;EACA,IAAIR,QAAQ,EAAE;IACZ,OAAO0B,aAAa,CAAClB,UAAU,CAAC;EAClC;EAMA,MAAMc,QAAQ,GAAG,MAAMC,KAAK,CAACf,UAAU,CAAC;EACxC,MAAMmB,YAAY,GAAG,MAAML,QAAQ,CAACM,IAAI,CAAC,CAAC;EAC1C,OAAOC,qBAAqB,CAACF,YAAY,EAAEnB,UAAU,CAAC;AACxD;AAoBA,SAASqB,qBAAqBA,CAACF,YAAoB,EAAEG,EAAU,EAAc;EAC3E,IAAI,CAAC/B,SAAS,EAAE;IACd,OAAOE,IAAI,CAAC8B,iBAAiB,IAAI9B,IAAI,CAAC8B,iBAAiB,CAACJ,YAAY,EAAEG,EAAE,CAAC;EAC3E;EAEA,IAAI9B,QAAQ,EAAE;IAEZgC,IAAI,CAACC,IAAI,CAACnC,MAAM,EAAE6B,YAAY,CAAC;IAG/B,OAAO,IAAI;EACb;EAEA,MAAMO,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;EAC/CF,MAAM,CAACJ,EAAE,GAAGA,EAAE;EAEd,IAAI;IACFI,MAAM,CAACG,WAAW,CAACF,QAAQ,CAACG,cAAc,CAACX,YAAY,CAAC,CAAC;EAC3D,CAAC,CAAC,OAAOY,CAAC,EAAE;IACVL,MAAM,CAACN,IAAI,GAAGD,YAAY;EAC5B;EACAQ,QAAQ,CAACK,IAAI,CAACH,WAAW,CAACH,MAAM,CAAC;EACjC,OAAO,IAAI;AACb"}
@@ -1,7 +1,7 @@
1
1
  import { assert } from '../env-utils/assert';
2
2
  import { VERSION as __VERSION__ } from '../env-utils/version';
3
- const NPM_TAG = 'beta';
4
- const VERSION = typeof "3.4.0-alpha.5" !== 'undefined' ? "3.4.0-alpha.5" : NPM_TAG;
3
+ const NPM_TAG = 'latest';
4
+ const VERSION = typeof "3.4.1" !== 'undefined' ? "3.4.1" : NPM_TAG;
5
5
  export function getWorkerName(worker) {
6
6
  const warning = worker.version !== VERSION ? " (worker-utils@".concat(VERSION, ")") : '';
7
7
  return "".concat(worker.name, "@").concat(worker.version).concat(warning);
@@ -1 +1 @@
1
- {"version":3,"file":"get-worker-url.js","names":["assert","VERSION","__VERSION__","NPM_TAG","getWorkerName","worker","warning","version","concat","name","getWorkerURL","options","arguments","length","undefined","workerOptions","id","workerFile","url","workerUrl","_workerType","module","versionTag"],"sources":["../../../../src/lib/worker-api/get-worker-url.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {WorkerObject, WorkerOptions} from '../../types';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\nconst NPM_TAG = 'beta'; // 'beta', or 'latest' on release-branch\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : NPM_TAG;\n\n/**\n * Gets worker object's name (for debugging in Chrome thread inspector window)\n */\nexport function getWorkerName(worker: WorkerObject): string {\n const warning = worker.version !== VERSION ? ` (worker-utils@${VERSION})` : '';\n return `${worker.name}@${worker.version}${warning}`;\n}\n\n/**\n * Generate a worker URL based on worker object and options\n * @returns A URL to one of the following:\n * - a published worker on unpkg CDN\n * - a local test worker\n * - a URL provided by the user in options\n */\nexport function getWorkerURL(worker: WorkerObject, options: WorkerOptions = {}): string {\n const workerOptions = options[worker.id] || {};\n\n const workerFile = `${worker.id}-worker.js`;\n\n let url = workerOptions.workerUrl;\n\n // HACK: Allow for non-nested workerUrl for the CompressionWorker.\n // For the compression worker, workerOptions is currently not nested correctly. For most loaders,\n // you'd have options within an object, i.e. `{mvt: {coordinates: ...}}` but the CompressionWorker\n // puts options at the top level, not within a `compression` key (its `id`). For this reason, the\n // above `workerOptions` will always be a string (i.e. `'gzip'`) for the CompressionWorker. To not\n // break backwards compatibility, we allow the CompressionWorker to have options at the top level.\n if (!url && worker.id === 'compression') {\n url = options.workerUrl;\n }\n\n // If URL is test, generate local loaders.gl url\n // @ts-ignore _workerType\n if (options._workerType === 'test') {\n url = `modules/${worker.module}/dist/${workerFile}`;\n }\n\n // If url override is not provided, generate a URL to published version on npm CDN unpkg.com\n if (!url) {\n // GENERATE\n let version = worker.version;\n // On master we need to load npm alpha releases published with the `beta` tag\n if (version === 'latest') {\n // throw new Error('latest worker version specified');\n version = NPM_TAG;\n }\n const versionTag = version ? `@${version}` : '';\n url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;\n }\n\n assert(url);\n\n // Allow user to override location\n return url;\n}\n"],"mappings":"AAGA,SAAQA,MAAM,QAAO,qBAAqB;AAC1C,SAAQC,OAAO,IAAIC,WAAW,QAAO,sBAAsB;AAE3D,MAAMC,OAAO,GAAG,MAAM;AACtB,MAAMF,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiBE,OAAO;AAK1E,OAAO,SAASC,aAAaA,CAACC,MAAoB,EAAU;EAC1D,MAAMC,OAAO,GAAGD,MAAM,CAACE,OAAO,KAAKN,OAAO,qBAAAO,MAAA,CAAqBP,OAAO,SAAM,EAAE;EAC9E,UAAAO,MAAA,CAAUH,MAAM,CAACI,IAAI,OAAAD,MAAA,CAAIH,MAAM,CAACE,OAAO,EAAAC,MAAA,CAAGF,OAAO;AACnD;AASA,OAAO,SAASI,YAAYA,CAACL,MAAoB,EAAuC;EAAA,IAArCM,OAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC5E,MAAMG,aAAa,GAAGJ,OAAO,CAACN,MAAM,CAACW,EAAE,CAAC,IAAI,CAAC,CAAC;EAE9C,MAAMC,UAAU,MAAAT,MAAA,CAAMH,MAAM,CAACW,EAAE,eAAY;EAE3C,IAAIE,GAAG,GAAGH,aAAa,CAACI,SAAS;EAQjC,IAAI,CAACD,GAAG,IAAIb,MAAM,CAACW,EAAE,KAAK,aAAa,EAAE;IACvCE,GAAG,GAAGP,OAAO,CAACQ,SAAS;EACzB;EAIA,IAAIR,OAAO,CAACS,WAAW,KAAK,MAAM,EAAE;IAClCF,GAAG,cAAAV,MAAA,CAAcH,MAAM,CAACgB,MAAM,YAAAb,MAAA,CAASS,UAAU,CAAE;EACrD;EAGA,IAAI,CAACC,GAAG,EAAE;IAER,IAAIX,OAAO,GAAGF,MAAM,CAACE,OAAO;IAE5B,IAAIA,OAAO,KAAK,QAAQ,EAAE;MAExBA,OAAO,GAAGJ,OAAO;IACnB;IACA,MAAMmB,UAAU,GAAGf,OAAO,OAAAC,MAAA,CAAOD,OAAO,IAAK,EAAE;IAC/CW,GAAG,oCAAAV,MAAA,CAAoCH,MAAM,CAACgB,MAAM,EAAAb,MAAA,CAAGc,UAAU,YAAAd,MAAA,CAASS,UAAU,CAAE;EACxF;EAEAjB,MAAM,CAACkB,GAAG,CAAC;EAGX,OAAOA,GAAG;AACZ"}
1
+ {"version":3,"file":"get-worker-url.js","names":["assert","VERSION","__VERSION__","NPM_TAG","getWorkerName","worker","warning","version","concat","name","getWorkerURL","options","arguments","length","undefined","workerOptions","id","workerFile","url","workerUrl","_workerType","module","versionTag"],"sources":["../../../../src/lib/worker-api/get-worker-url.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {WorkerObject, WorkerOptions} from '../../types';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\nconst NPM_TAG = 'latest'; // 'beta', or 'latest' on release-branch\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : NPM_TAG;\n\n/**\n * Gets worker object's name (for debugging in Chrome thread inspector window)\n */\nexport function getWorkerName(worker: WorkerObject): string {\n const warning = worker.version !== VERSION ? ` (worker-utils@${VERSION})` : '';\n return `${worker.name}@${worker.version}${warning}`;\n}\n\n/**\n * Generate a worker URL based on worker object and options\n * @returns A URL to one of the following:\n * - a published worker on unpkg CDN\n * - a local test worker\n * - a URL provided by the user in options\n */\nexport function getWorkerURL(worker: WorkerObject, options: WorkerOptions = {}): string {\n const workerOptions = options[worker.id] || {};\n\n const workerFile = `${worker.id}-worker.js`;\n\n let url = workerOptions.workerUrl;\n\n // HACK: Allow for non-nested workerUrl for the CompressionWorker.\n // For the compression worker, workerOptions is currently not nested correctly. For most loaders,\n // you'd have options within an object, i.e. `{mvt: {coordinates: ...}}` but the CompressionWorker\n // puts options at the top level, not within a `compression` key (its `id`). For this reason, the\n // above `workerOptions` will always be a string (i.e. `'gzip'`) for the CompressionWorker. To not\n // break backwards compatibility, we allow the CompressionWorker to have options at the top level.\n if (!url && worker.id === 'compression') {\n url = options.workerUrl;\n }\n\n // If URL is test, generate local loaders.gl url\n // @ts-ignore _workerType\n if (options._workerType === 'test') {\n url = `modules/${worker.module}/dist/${workerFile}`;\n }\n\n // If url override is not provided, generate a URL to published version on npm CDN unpkg.com\n if (!url) {\n // GENERATE\n let version = worker.version;\n // On master we need to load npm alpha releases published with the `beta` tag\n if (version === 'latest') {\n // throw new Error('latest worker version specified');\n version = NPM_TAG;\n }\n const versionTag = version ? `@${version}` : '';\n url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;\n }\n\n assert(url);\n\n // Allow user to override location\n return url;\n}\n"],"mappings":"AAGA,SAAQA,MAAM,QAAO,qBAAqB;AAC1C,SAAQC,OAAO,IAAIC,WAAW,QAAO,sBAAsB;AAE3D,MAAMC,OAAO,GAAG,QAAQ;AACxB,MAAMF,OAAO,GAAG,cAAkB,KAAK,WAAW,aAAiBE,OAAO;AAK1E,OAAO,SAASC,aAAaA,CAACC,MAAoB,EAAU;EAC1D,MAAMC,OAAO,GAAGD,MAAM,CAACE,OAAO,KAAKN,OAAO,qBAAAO,MAAA,CAAqBP,OAAO,SAAM,EAAE;EAC9E,UAAAO,MAAA,CAAUH,MAAM,CAACI,IAAI,OAAAD,MAAA,CAAIH,MAAM,CAACE,OAAO,EAAAC,MAAA,CAAGF,OAAO;AACnD;AASA,OAAO,SAASI,YAAYA,CAACL,MAAoB,EAAuC;EAAA,IAArCM,OAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC5E,MAAMG,aAAa,GAAGJ,OAAO,CAACN,MAAM,CAACW,EAAE,CAAC,IAAI,CAAC,CAAC;EAE9C,MAAMC,UAAU,MAAAT,MAAA,CAAMH,MAAM,CAACW,EAAE,eAAY;EAE3C,IAAIE,GAAG,GAAGH,aAAa,CAACI,SAAS;EAQjC,IAAI,CAACD,GAAG,IAAIb,MAAM,CAACW,EAAE,KAAK,aAAa,EAAE;IACvCE,GAAG,GAAGP,OAAO,CAACQ,SAAS;EACzB;EAIA,IAAIR,OAAO,CAACS,WAAW,KAAK,MAAM,EAAE;IAClCF,GAAG,cAAAV,MAAA,CAAcH,MAAM,CAACgB,MAAM,YAAAb,MAAA,CAASS,UAAU,CAAE;EACrD;EAGA,IAAI,CAACC,GAAG,EAAE;IAER,IAAIX,OAAO,GAAGF,MAAM,CAACE,OAAO;IAE5B,IAAIA,OAAO,KAAK,QAAQ,EAAE;MAExBA,OAAO,GAAGJ,OAAO;IACnB;IACA,MAAMmB,UAAU,GAAGf,OAAO,OAAAC,MAAA,CAAOD,OAAO,IAAK,EAAE;IAC/CW,GAAG,oCAAAV,MAAA,CAAoCH,MAAM,CAACgB,MAAM,EAAAb,MAAA,CAAGc,UAAU,YAAAd,MAAA,CAASS,UAAU,CAAE;EACxF;EAEAjB,MAAM,CAACkB,GAAG,CAAC;EAGX,OAAOA,GAAG;AACZ"}
@@ -4,7 +4,7 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.VERSION = void 0;
6
6
  // Change to `latest` on production branches
7
- const DEFAULT_VERSION = 'beta';
7
+ const DEFAULT_VERSION = 'latest';
8
8
  exports.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : DEFAULT_VERSION;
9
9
  if (typeof __VERSION__ === 'undefined') {
10
10
  // eslint-disable-next-line
@@ -33,7 +33,7 @@ const version_1 = require("../env-utils/version");
33
33
  * TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...
34
34
  * 'beta' on beta branch, 'latest' on prod branch
35
35
  */
36
- const LATEST = 'beta';
36
+ const LATEST = 'latest';
37
37
  const VERSION = typeof version_1.VERSION !== 'undefined' ? version_1.VERSION : LATEST;
38
38
  const loadLibraryPromises = {}; // promises
39
39
  /**
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.getWorkerURL = exports.getWorkerName = void 0;
5
5
  const assert_1 = require("../env-utils/assert");
6
6
  const version_1 = require("../env-utils/version");
7
- const NPM_TAG = 'beta'; // 'beta', or 'latest' on release-branch
7
+ const NPM_TAG = 'latest'; // 'beta', or 'latest' on release-branch
8
8
  const VERSION = typeof version_1.VERSION !== 'undefined' ? version_1.VERSION : NPM_TAG;
9
9
  /**
10
10
  * Gets worker object's name (for debugging in Chrome thread inspector window)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/worker-utils",
3
- "version": "3.4.0-alpha.5",
3
+ "version": "3.4.1",
4
4
  "description": "Utilities for running tasks on worker threads",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -49,5 +49,5 @@
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7.3.1"
51
51
  },
52
- "gitHead": "686929f85b3420c15df051eab769942b260dd242"
52
+ "gitHead": "2c39d1032c1a8b3678a6f09507b89ffe92ca9e1b"
53
53
  }
@@ -2,7 +2,7 @@
2
2
  // __VERSION__ is injected by babel-plugin-version-inline
3
3
 
4
4
  // Change to `latest` on production branches
5
- const DEFAULT_VERSION = 'beta';
5
+ const DEFAULT_VERSION = 'latest';
6
6
  declare let __VERSION__: string;
7
7
  export const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : DEFAULT_VERSION;
8
8
  if (typeof __VERSION__ === 'undefined') {
@@ -8,7 +8,7 @@ import {VERSION as __VERSION__} from '../env-utils/version';
8
8
  * TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...
9
9
  * 'beta' on beta branch, 'latest' on prod branch
10
10
  */
11
- const LATEST = 'beta';
11
+ const LATEST = 'latest';
12
12
  const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : LATEST;
13
13
 
14
14
  const loadLibraryPromises: Record<string, Promise<any>> = {}; // promises
@@ -4,7 +4,7 @@ import type {WorkerObject, WorkerOptions} from '../../types';
4
4
  import {assert} from '../env-utils/assert';
5
5
  import {VERSION as __VERSION__} from '../env-utils/version';
6
6
 
7
- const NPM_TAG = 'beta'; // 'beta', or 'latest' on release-branch
7
+ const NPM_TAG = 'latest'; // 'beta', or 'latest' on release-branch
8
8
  const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : NPM_TAG;
9
9
 
10
10
  /**