@loaders.gl/worker-utils 4.0.0-alpha.24 → 4.0.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/lib/env-utils/version.js +17 -6
- package/dist/es5/lib/env-utils/version.js.map +1 -1
- package/dist/es5/lib/library-utils/library-utils.js +1 -3
- package/dist/es5/lib/library-utils/library-utils.js.map +1 -1
- package/dist/es5/lib/worker-api/get-worker-url.js +2 -4
- package/dist/es5/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/esm/lib/env-utils/version.js +14 -4
- package/dist/esm/lib/env-utils/version.js.map +1 -1
- package/dist/esm/lib/library-utils/library-utils.js +1 -3
- package/dist/esm/lib/library-utils/library-utils.js.map +1 -1
- package/dist/esm/lib/worker-api/get-worker-url.js +1 -3
- package/dist/esm/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/lib/env-utils/version.d.ts +6 -1
- package/dist/lib/env-utils/version.d.ts.map +1 -1
- package/dist/lib/library-utils/library-utils.d.ts.map +1 -1
- package/dist/lib/worker-api/get-worker-url.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/lib/env-utils/version.ts +25 -9
- package/src/lib/library-utils/library-utils.ts +1 -8
- package/src/lib/worker-api/get-worker-url.ts +1 -4
|
@@ -3,11 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.VERSION = void 0;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
exports.VERSION = exports.NPM_TAG = void 0;
|
|
7
|
+
var NPM_TAG = 'beta';
|
|
8
|
+
exports.NPM_TAG = NPM_TAG;
|
|
9
|
+
function getVersion() {
|
|
10
|
+
var _globalThis$_loadersg;
|
|
11
|
+
if (!((_globalThis$_loadersg = globalThis._loadersgl_) !== null && _globalThis$_loadersg !== void 0 && _globalThis$_loadersg.version)) {
|
|
12
|
+
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
13
|
+
if (typeof "4.0.0-alpha.26" === 'undefined') {
|
|
14
|
+
console.error('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.');
|
|
15
|
+
globalThis._loadersgl_.version = NPM_TAG;
|
|
16
|
+
} else {
|
|
17
|
+
globalThis._loadersgl_.version = "4.0.0-alpha.26";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return globalThis._loadersgl_.version;
|
|
12
21
|
}
|
|
22
|
+
var VERSION = getVersion();
|
|
23
|
+
exports.VERSION = VERSION;
|
|
13
24
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":["
|
|
1
|
+
{"version":3,"file":"version.js","names":["NPM_TAG","exports","getVersion","_globalThis$_loadersg","globalThis","_loadersgl_","version","console","error","VERSION"],"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\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 */\nexport const NPM_TAG = 'beta'; // Change to `latest` on production branches\n\ndeclare let __VERSION__: string;\n\nfunction getVersion() {\n if (!globalThis._loadersgl_?.version) {\n globalThis._loadersgl_ = globalThis._loadersgl_ || {};\n // __VERSION__ is injected by babel-plugin-version-inline\n if (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 globalThis._loadersgl_.version = NPM_TAG;\n } else {\n globalThis._loadersgl_.version = __VERSION__;\n }\n }\n\n return globalThis._loadersgl_.version;\n}\n\nexport const VERSION = getVersion();\n"],"mappings":";;;;;;AAMO,IAAMA,OAAO,GAAG,MAAM;AAACC,OAAA,CAAAD,OAAA,GAAAA,OAAA;AAI9B,SAASE,UAAUA,CAAA,EAAG;EAAA,IAAAC,qBAAA;EACpB,IAAI,GAAAA,qBAAA,GAACC,UAAU,CAACC,WAAW,cAAAF,qBAAA,eAAtBA,qBAAA,CAAwBG,OAAO,GAAE;IACpCF,UAAU,CAACC,WAAW,GAAGD,UAAU,CAACC,WAAW,IAAI,CAAC,CAAC;IAErD,IAAI,uBAAkB,KAAK,WAAW,EAAE;MAEtCE,OAAO,CAACC,KAAK,CACX,iIACF,CAAC;MACDJ,UAAU,CAACC,WAAW,CAACC,OAAO,GAAGN,OAAO;IAC1C,CAAC,MAAM;MACLI,UAAU,CAACC,WAAW,CAACC,OAAO,mBAAc;IAC9C;EACF;EAEA,OAAOF,UAAU,CAACC,WAAW,CAACC,OAAO;AACvC;AAEO,IAAMG,OAAO,GAAGP,UAAU,CAAC,CAAC;AAACD,OAAA,CAAAQ,OAAA,GAAAA,OAAA"}
|
|
@@ -15,8 +15,6 @@ 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 "4.0.0-alpha.24" !== 'undefined' ? "4.0.0-alpha.24" : LATEST;
|
|
20
18
|
var loadLibraryPromises = {};
|
|
21
19
|
function loadLibrary(_x) {
|
|
22
20
|
return _loadLibrary.apply(this, arguments);
|
|
@@ -65,7 +63,7 @@ function getLibraryUrl(library, moduleName) {
|
|
|
65
63
|
}
|
|
66
64
|
if (options.CDN) {
|
|
67
65
|
(0, _assert.assert)(options.CDN.startsWith('http'));
|
|
68
|
-
return "".concat(options.CDN, "/").concat(moduleName, "@").concat(VERSION, "/dist/libs/").concat(libraryName);
|
|
66
|
+
return "".concat(options.CDN, "/").concat(moduleName, "@").concat(_version.VERSION, "/dist/libs/").concat(libraryName);
|
|
69
67
|
}
|
|
70
68
|
if (_globals.isWorker) {
|
|
71
69
|
return "../src/libs/".concat(libraryName);
|
|
@@ -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","libraryName","_args","wrap","_callee$","_context","prev","next","length","undefined","getLibraryUrl","loadLibraryFromFile","abrupt","sent","stop","library","useLocalLibraries","startsWith","modules","isBrowser","concat","CDN","assert","isWorker","_x2","_loadLibraryFromFile","_callee2","scriptSource","_callee2$","_context2","endsWith","loadAsArrayBuffer","t0","requireFromFile","t1","importScripts","loadAsText","loadLibraryFromString","id","requireFromString","eval","global","script","document","createElement","appendChild","createTextNode","e","text","body","_x3","_loadAsArrayBuffer","_callee3","url","response","_callee3$","_context3","readFileAsArrayBuffer","fetch","arrayBuffer","_x4","_loadAsText","_callee4","_callee4$","_context4","readFileAsText"],"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 libraryName: string | null = null\n): Promise<any> {\n if (moduleName) {\n libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);\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(\n library: string,\n moduleName?: string,\n options: any = {},\n libraryName: string | null = null\n): string {\n // Check if already a URL\n if (!options.useLocalLibraries && library.startsWith('http')) {\n return library;\n }\n\n libraryName = libraryName || library;\n\n // Allow application to import and supply libraries through `options.modules`\n const modules = options.modules || {};\n if (modules[libraryName]) {\n return modules[libraryName];\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/${libraryName}`;\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/${libraryName}`;\n }\n\n // TODO - loading inside workers requires paths relative to worker script location...\n if (isWorker) {\n return `../src/libs/${libraryName}`;\n }\n\n return `modules/${moduleName}/src/libs/${libraryName}`;\n}\n\nasync function loadLibraryFromFile(libraryUrl: string): Promise<any> {\n if (libraryUrl.endsWith('wasm')) {\n return await loadAsArrayBuffer(libraryUrl);\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 scriptSource = await loadAsText(libraryUrl);\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\nasync function loadAsArrayBuffer(url: string): Promise<ArrayBuffer> {\n if (!node.readFileAsArrayBuffer || url.startsWith('http')) {\n const response = await fetch(url);\n return await response.arrayBuffer();\n }\n return await node.readFileAsArrayBuffer(url);\n}\n\n/**\n * Load a file from local file system\n * @param filename\n * @returns\n */\nasync function loadAsText(url: string): Promise<string> {\n if (!node.readFileAsText || url.startsWith('http')) {\n const response = await fetch(url);\n return await response.text();\n }\n return await node.readFileAsText(url);\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,CAA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AmD,SAAA,CAAAlD,IAAA;MAAA;IAAA,GAAAgD,QAAA;EAAA,CACtC;EAAA,OAAAD,WAAA,CAAArE,KAAA,OAAAC,SAAA;AAAA"}
|
|
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","loadLibraryPromises","loadLibrary","_x","_loadLibrary","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","libraryUrl","moduleName","options","libraryName","_args","wrap","_callee$","_context","prev","next","length","undefined","getLibraryUrl","loadLibraryFromFile","abrupt","sent","stop","library","useLocalLibraries","startsWith","modules","isBrowser","concat","CDN","assert","VERSION","isWorker","_x2","_loadLibraryFromFile","_callee2","scriptSource","_callee2$","_context2","endsWith","loadAsArrayBuffer","t0","requireFromFile","t1","importScripts","loadAsText","loadLibraryFromString","id","requireFromString","eval","global","script","document","createElement","appendChild","createTextNode","e","text","body","_x3","_loadAsArrayBuffer","_callee3","url","response","_callee3$","_context3","readFileAsArrayBuffer","fetch","arrayBuffer","_x4","_loadAsText","_callee4","_callee4$","_context4","readFileAsText"],"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} from '../env-utils/version';\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 libraryName: string | null = null\n): Promise<any> {\n if (moduleName) {\n libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);\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(\n library: string,\n moduleName?: string,\n options: any = {},\n libraryName: string | null = null\n): string {\n // Check if already a URL\n if (!options.useLocalLibraries && library.startsWith('http')) {\n return library;\n }\n\n libraryName = libraryName || library;\n\n // Allow application to import and supply libraries through `options.modules`\n const modules = options.modules || {};\n if (modules[libraryName]) {\n return modules[libraryName];\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/${libraryName}`;\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/${libraryName}`;\n }\n\n // TODO - loading inside workers requires paths relative to worker script location...\n if (isWorker) {\n return `../src/libs/${libraryName}`;\n }\n\n return `modules/${moduleName}/src/libs/${libraryName}`;\n}\n\nasync function loadLibraryFromFile(libraryUrl: string): Promise<any> {\n if (libraryUrl.endsWith('wasm')) {\n return await loadAsArrayBuffer(libraryUrl);\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 scriptSource = await loadAsText(libraryUrl);\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\nasync function loadAsArrayBuffer(url: string): Promise<ArrayBuffer> {\n if (!node.readFileAsArrayBuffer || url.startsWith('http')) {\n const response = await fetch(url);\n return await response.arrayBuffer();\n }\n return await node.readFileAsArrayBuffer(url);\n}\n\n/**\n * Load a file from local file system\n * @param filename\n * @returns\n */\nasync function loadAsText(url: string): Promise<string> {\n if (!node.readFileAsText || url.startsWith('http')) {\n const response = await fetch(url);\n return await response.text();\n }\n return await node.readFileAsText(url);\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA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,IAAA;YAAA;UAAA;UAAA0D,SAAA,CAAA1D,IAAA;UAAA,OACzBoD,KAAK,CAACL,GAAG,CAAC;QAAA;UAA3BC,QAAQ,GAAAU,SAAA,CAAApD,IAAA;UAAAoD,SAAA,CAAA1D,IAAA;UAAA,OACDgD,QAAQ,CAACN,IAAI,CAAC,CAAC;QAAA;UAAA,OAAAgB,SAAA,CAAArD,MAAA,WAAAqD,SAAA,CAAApD,IAAA;QAAA;UAAAoD,SAAA,CAAA1D,IAAA;UAAA,OAEjB9C,IAAI,CAACyG,cAAc,CAACZ,GAAG,CAAC;QAAA;UAAA,OAAAW,SAAA,CAAArD,MAAA,WAAAqD,SAAA,CAAApD,IAAA;QAAA;QAAA;UAAA,OAAAoD,SAAA,CAAAnD,IAAA;MAAA;IAAA,GAAAiD,QAAA;EAAA,CACtC;EAAA,OAAAD,WAAA,CAAAtE,KAAA,OAAAC,SAAA;AAAA"}
|
|
@@ -8,10 +8,8 @@ exports.getWorkerURL = getWorkerURL;
|
|
|
8
8
|
var _assert = require("../env-utils/assert");
|
|
9
9
|
var _globals = require("../env-utils/globals");
|
|
10
10
|
var _version = require("../env-utils/version");
|
|
11
|
-
var NPM_TAG = 'beta';
|
|
12
|
-
var VERSION = typeof "4.0.0-alpha.24" !== 'undefined' ? "4.0.0-alpha.24" : NPM_TAG;
|
|
13
11
|
function getWorkerName(worker) {
|
|
14
|
-
var warning = worker.version !== VERSION ? " (worker-utils@".concat(VERSION, ")") : '';
|
|
12
|
+
var warning = worker.version !== _version.VERSION ? " (worker-utils@".concat(_version.VERSION, ")") : '';
|
|
15
13
|
return "".concat(worker.name, "@").concat(worker.version).concat(warning);
|
|
16
14
|
}
|
|
17
15
|
function getWorkerURL(worker) {
|
|
@@ -28,7 +26,7 @@ function getWorkerURL(worker) {
|
|
|
28
26
|
if (!url) {
|
|
29
27
|
var version = worker.version;
|
|
30
28
|
if (version === 'latest') {
|
|
31
|
-
version = NPM_TAG;
|
|
29
|
+
version = _version.NPM_TAG;
|
|
32
30
|
}
|
|
33
31
|
var versionTag = version ? "@".concat(version) : '';
|
|
34
32
|
url = "https://unpkg.com/@loaders.gl/".concat(worker.module).concat(versionTag, "/dist/").concat(workerFile);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-worker-url.js","names":["_assert","require","_globals","_version","
|
|
1
|
+
{"version":3,"file":"get-worker-url.js","names":["_assert","require","_globals","_version","getWorkerName","worker","warning","version","VERSION","concat","name","getWorkerURL","options","arguments","length","undefined","workerOptions","id","workerFile","isBrowser","url","workerUrl","_workerType","module","NPM_TAG","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 {isBrowser} from '../env-utils/globals';\nimport {VERSION, NPM_TAG} from '../env-utils/version';\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 = isBrowser ? `${worker.id}-worker.js` : `${worker.id}-worker-node.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;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKO,SAASG,aAAaA,CAACC,MAAoB,EAAU;EAC1D,IAAMC,OAAO,GAAGD,MAAM,CAACE,OAAO,KAAKC,gBAAO,qBAAAC,MAAA,CAAqBD,gBAAO,SAAM,EAAE;EAC9E,UAAAC,MAAA,CAAUJ,MAAM,CAACK,IAAI,OAAAD,MAAA,CAAIJ,MAAM,CAACE,OAAO,EAAAE,MAAA,CAAGH,OAAO;AACnD;AASO,SAASK,YAAYA,CAACN,MAAoB,EAAuC;EAAA,IAArCO,OAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC5E,IAAMG,aAAa,GAAGJ,OAAO,CAACP,MAAM,CAACY,EAAE,CAAC,IAAI,CAAC,CAAC;EAE9C,IAAMC,UAAU,GAAGC,kBAAS,MAAAV,MAAA,CAAMJ,MAAM,CAACY,EAAE,qBAAAR,MAAA,CAAkBJ,MAAM,CAACY,EAAE,oBAAiB;EAEvF,IAAIG,GAAG,GAAGJ,aAAa,CAACK,SAAS;EAQjC,IAAI,CAACD,GAAG,IAAIf,MAAM,CAACY,EAAE,KAAK,aAAa,EAAE;IACvCG,GAAG,GAAGR,OAAO,CAACS,SAAS;EACzB;EAIA,IAAIT,OAAO,CAACU,WAAW,KAAK,MAAM,EAAE;IAClCF,GAAG,cAAAX,MAAA,CAAcJ,MAAM,CAACkB,MAAM,YAAAd,MAAA,CAASS,UAAU,CAAE;EACrD;EAGA,IAAI,CAACE,GAAG,EAAE;IAER,IAAIb,OAAO,GAAGF,MAAM,CAACE,OAAO;IAE5B,IAAIA,OAAO,KAAK,QAAQ,EAAE;MAExBA,OAAO,GAAGiB,gBAAO;IACnB;IACA,IAAMC,UAAU,GAAGlB,OAAO,OAAAE,MAAA,CAAOF,OAAO,IAAK,EAAE;IAC/Ca,GAAG,oCAAAX,MAAA,CAAoCJ,MAAM,CAACkB,MAAM,EAAAd,MAAA,CAAGgB,UAAU,YAAAhB,MAAA,CAASS,UAAU,CAAE;EACxF;EAEA,IAAAQ,cAAM,EAACN,GAAG,CAAC;EAGX,OAAOA,GAAG;AACZ"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const NPM_TAG = 'beta';
|
|
2
|
+
function getVersion() {
|
|
3
|
+
var _globalThis$_loadersg;
|
|
4
|
+
if (!((_globalThis$_loadersg = globalThis._loadersgl_) !== null && _globalThis$_loadersg !== void 0 && _globalThis$_loadersg.version)) {
|
|
5
|
+
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
6
|
+
if (typeof "4.0.0-alpha.26" === 'undefined') {
|
|
7
|
+
console.error('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.');
|
|
8
|
+
globalThis._loadersgl_.version = NPM_TAG;
|
|
9
|
+
} else {
|
|
10
|
+
globalThis._loadersgl_.version = "4.0.0-alpha.26";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return globalThis._loadersgl_.version;
|
|
5
14
|
}
|
|
15
|
+
export const VERSION = getVersion();
|
|
6
16
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":["
|
|
1
|
+
{"version":3,"file":"version.js","names":["NPM_TAG","getVersion","_globalThis$_loadersg","globalThis","_loadersgl_","version","console","error","VERSION"],"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\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 */\nexport const NPM_TAG = 'beta'; // Change to `latest` on production branches\n\ndeclare let __VERSION__: string;\n\nfunction getVersion() {\n if (!globalThis._loadersgl_?.version) {\n globalThis._loadersgl_ = globalThis._loadersgl_ || {};\n // __VERSION__ is injected by babel-plugin-version-inline\n if (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 globalThis._loadersgl_.version = NPM_TAG;\n } else {\n globalThis._loadersgl_.version = __VERSION__;\n }\n }\n\n return globalThis._loadersgl_.version;\n}\n\nexport const VERSION = getVersion();\n"],"mappings":"AAMA,OAAO,MAAMA,OAAO,GAAG,MAAM;AAI7B,SAASC,UAAUA,CAAA,EAAG;EAAA,IAAAC,qBAAA;EACpB,IAAI,GAAAA,qBAAA,GAACC,UAAU,CAACC,WAAW,cAAAF,qBAAA,eAAtBA,qBAAA,CAAwBG,OAAO,GAAE;IACpCF,UAAU,CAACC,WAAW,GAAGD,UAAU,CAACC,WAAW,IAAI,CAAC,CAAC;IAErD,IAAI,uBAAkB,KAAK,WAAW,EAAE;MAEtCE,OAAO,CAACC,KAAK,CACX,iIACF,CAAC;MACDJ,UAAU,CAACC,WAAW,CAACC,OAAO,GAAGL,OAAO;IAC1C,CAAC,MAAM;MACLG,UAAU,CAACC,WAAW,CAACC,OAAO,mBAAc;IAC9C;EACF;EAEA,OAAOF,UAAU,CAACC,WAAW,CAACC,OAAO;AACvC;AAEA,OAAO,MAAMG,OAAO,GAAGP,UAAU,CAAC,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
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
|
-
import { VERSION
|
|
5
|
-
const LATEST = 'beta';
|
|
6
|
-
const VERSION = typeof "4.0.0-alpha.24" !== 'undefined' ? "4.0.0-alpha.24" : LATEST;
|
|
4
|
+
import { VERSION } from '../env-utils/version';
|
|
7
5
|
const loadLibraryPromises = {};
|
|
8
6
|
export async function loadLibrary(libraryUrl) {
|
|
9
7
|
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","
|
|
1
|
+
{"version":3,"file":"library-utils.js","names":["global","isBrowser","isWorker","node","assert","VERSION","loadLibraryPromises","loadLibrary","libraryUrl","moduleName","arguments","length","undefined","options","libraryName","getLibraryUrl","loadLibraryFromFile","library","useLocalLibraries","startsWith","modules","concat","CDN","endsWith","loadAsArrayBuffer","requireFromFile","importScripts","scriptSource","loadAsText","loadLibraryFromString","id","requireFromString","eval","call","script","document","createElement","appendChild","createTextNode","e","text","body","url","readFileAsArrayBuffer","response","fetch","arrayBuffer","readFileAsText"],"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} from '../env-utils/version';\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 libraryName: string | null = null\n): Promise<any> {\n if (moduleName) {\n libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);\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(\n library: string,\n moduleName?: string,\n options: any = {},\n libraryName: string | null = null\n): string {\n // Check if already a URL\n if (!options.useLocalLibraries && library.startsWith('http')) {\n return library;\n }\n\n libraryName = libraryName || library;\n\n // Allow application to import and supply libraries through `options.modules`\n const modules = options.modules || {};\n if (modules[libraryName]) {\n return modules[libraryName];\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/${libraryName}`;\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/${libraryName}`;\n }\n\n // TODO - loading inside workers requires paths relative to worker script location...\n if (isWorker) {\n return `../src/libs/${libraryName}`;\n }\n\n return `modules/${moduleName}/src/libs/${libraryName}`;\n}\n\nasync function loadLibraryFromFile(libraryUrl: string): Promise<any> {\n if (libraryUrl.endsWith('wasm')) {\n return await loadAsArrayBuffer(libraryUrl);\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 scriptSource = await loadAsText(libraryUrl);\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\nasync function loadAsArrayBuffer(url: string): Promise<ArrayBuffer> {\n if (!node.readFileAsArrayBuffer || url.startsWith('http')) {\n const response = await fetch(url);\n return await response.arrayBuffer();\n }\n return await node.readFileAsArrayBuffer(url);\n}\n\n/**\n * Load a file from local file system\n * @param filename\n * @returns\n */\nasync function loadAsText(url: string): Promise<string> {\n if (!node.readFileAsText || url.startsWith('http')) {\n const response = await fetch(url);\n return await response.text();\n }\n return await node.readFileAsText(url);\n}\n"],"mappings":"AACA,SAAQA,MAAM,EAAEC,SAAS,EAAEC,QAA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@@
|
|
|
1
1
|
import { assert } from '../env-utils/assert';
|
|
2
2
|
import { isBrowser } from '../env-utils/globals';
|
|
3
|
-
import { VERSION
|
|
4
|
-
const NPM_TAG = 'beta';
|
|
5
|
-
const VERSION = typeof "4.0.0-alpha.24" !== 'undefined' ? "4.0.0-alpha.24" : NPM_TAG;
|
|
3
|
+
import { VERSION, NPM_TAG } from '../env-utils/version';
|
|
6
4
|
export function getWorkerName(worker) {
|
|
7
5
|
const warning = worker.version !== VERSION ? " (worker-utils@".concat(VERSION, ")") : '';
|
|
8
6
|
return "".concat(worker.name, "@").concat(worker.version).concat(warning);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-worker-url.js","names":["assert","isBrowser","VERSION","
|
|
1
|
+
{"version":3,"file":"get-worker-url.js","names":["assert","isBrowser","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 {isBrowser} from '../env-utils/globals';\nimport {VERSION, NPM_TAG} from '../env-utils/version';\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 = isBrowser ? `${worker.id}-worker.js` : `${worker.id}-worker-node.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,SAAS,QAAO,sBAAsB;AAC9C,SAAQC,OAAO,EAAEC,OAAO,QAAO,sBAAsB;AAKrD,OAAO,SAASC,aAAaA,CAACC,MAAoB,EAAU;EAC1D,MAAMC,OAAO,GAAGD,MAAM,CAACE,OAAO,KAAKL,OAAO,qBAAAM,MAAA,CAAqBN,OAAO,SAAM,EAAE;EAC9E,UAAAM,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,GAAGhB,SAAS,MAAAO,MAAA,CAAMH,MAAM,CAACW,EAAE,qBAAAR,MAAA,CAAkBH,MAAM,CAACW,EAAE,oBAAiB;EAEvF,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,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...
|
|
3
|
+
* 'beta' on beta branch, 'latest' on prod branch
|
|
4
|
+
*/
|
|
5
|
+
export declare const NPM_TAG = "beta";
|
|
6
|
+
export declare const VERSION: any;
|
|
2
7
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/env-utils/version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/env-utils/version.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,OAAO,SAAS,CAAC;AAsB9B,eAAO,MAAM,OAAO,KAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/library-utils/library-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"library-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/library-utils/library-utils.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAAM,GAAG,IAAW,EAChC,OAAO,GAAE,MAAW,EACpB,WAAW,GAAE,MAAM,GAAG,IAAW,GAChC,OAAO,CAAC,GAAG,CAAC,CAUd;AAGD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,GAAE,GAAQ,EACjB,WAAW,GAAE,MAAM,GAAG,IAAW,GAChC,MAAM,CAgCR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-worker-url.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-api/get-worker-url.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"get-worker-url.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-api/get-worker-url.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAK7D;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAG1D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAwCtF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/worker-utils",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.26",
|
|
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": "
|
|
52
|
+
"gitHead": "91adce71f74dacc7c8bfc379f0d122f2beae70d9"
|
|
53
53
|
}
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
// Version constant cannot be imported, it needs to correspond to the build version of **this** module.
|
|
2
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...
|
|
5
|
+
* 'beta' on beta branch, 'latest' on prod branch
|
|
6
|
+
*/
|
|
7
|
+
export const NPM_TAG = 'beta'; // Change to `latest` on production branches
|
|
8
|
+
|
|
6
9
|
declare let __VERSION__: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
|
|
11
|
+
function getVersion() {
|
|
12
|
+
if (!globalThis._loadersgl_?.version) {
|
|
13
|
+
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
14
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
15
|
+
if (typeof __VERSION__ === 'undefined') {
|
|
16
|
+
// eslint-disable-next-line
|
|
17
|
+
console.error(
|
|
18
|
+
'loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.'
|
|
19
|
+
);
|
|
20
|
+
globalThis._loadersgl_.version = NPM_TAG;
|
|
21
|
+
} else {
|
|
22
|
+
globalThis._loadersgl_.version = __VERSION__;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return globalThis._loadersgl_.version;
|
|
13
27
|
}
|
|
28
|
+
|
|
29
|
+
export const VERSION = getVersion();
|
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
import {global, isBrowser, isWorker} from '../env-utils/globals';
|
|
3
3
|
import * as node from '../node/require-utils.node';
|
|
4
4
|
import {assert} from '../env-utils/assert';
|
|
5
|
-
import {VERSION
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...
|
|
9
|
-
* 'beta' on beta branch, 'latest' on prod branch
|
|
10
|
-
*/
|
|
11
|
-
const LATEST = 'beta';
|
|
12
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : LATEST;
|
|
5
|
+
import {VERSION} from '../env-utils/version';
|
|
13
6
|
|
|
14
7
|
const loadLibraryPromises: Record<string, Promise<any>> = {}; // promises
|
|
15
8
|
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
import type {WorkerObject, WorkerOptions} from '../../types';
|
|
4
4
|
import {assert} from '../env-utils/assert';
|
|
5
5
|
import {isBrowser} from '../env-utils/globals';
|
|
6
|
-
import {VERSION
|
|
7
|
-
|
|
8
|
-
const NPM_TAG = 'beta'; // 'beta', or 'latest' on release-branch
|
|
9
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : NPM_TAG;
|
|
6
|
+
import {VERSION, NPM_TAG} from '../env-utils/version';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* Gets worker object's name (for debugging in Chrome thread inspector window)
|