@loaders.gl/worker-utils 3.1.0-beta.5 → 3.1.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.
- package/dist/es5/index.js +19 -19
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/async-queue/async-queue.js +76 -62
- package/dist/es5/lib/async-queue/async-queue.js.map +1 -1
- package/dist/es5/lib/env-utils/globals.js +15 -10
- package/dist/es5/lib/env-utils/globals.js.map +1 -1
- package/dist/es5/lib/env-utils/version.js +3 -3
- package/dist/es5/lib/env-utils/version.js.map +1 -1
- package/dist/es5/lib/library-utils/library-utils.js +133 -29
- package/dist/es5/lib/library-utils/library-utils.js.map +1 -1
- package/dist/es5/lib/node/require-utils.node.js +56 -16
- package/dist/es5/lib/node/require-utils.node.js.map +1 -1
- package/dist/es5/lib/process-utils/child-process-proxy.js +199 -90
- package/dist/es5/lib/process-utils/child-process-proxy.js.map +1 -1
- package/dist/es5/lib/process-utils/process-utils.js +9 -8
- package/dist/es5/lib/process-utils/process-utils.js.map +1 -1
- package/dist/es5/lib/worker-api/create-worker.js +162 -52
- package/dist/es5/lib/worker-api/create-worker.js.map +1 -1
- package/dist/es5/lib/worker-api/get-worker-url.js +14 -9
- package/dist/es5/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/es5/lib/worker-api/process-on-worker.js +130 -59
- package/dist/es5/lib/worker-api/process-on-worker.js.map +1 -1
- package/dist/es5/lib/worker-api/validate-worker-version.js +4 -3
- package/dist/es5/lib/worker-api/validate-worker-version.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-body.js +58 -46
- package/dist/es5/lib/worker-farm/worker-body.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-farm.js +99 -60
- package/dist/es5/lib/worker-farm/worker-farm.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-job.js +40 -28
- package/dist/es5/lib/worker-farm/worker-job.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-pool.js +204 -108
- package/dist/es5/lib/worker-farm/worker-pool.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-thread.js +85 -67
- package/dist/es5/lib/worker-farm/worker-thread.js.map +1 -1
- package/dist/es5/lib/worker-utils/get-loadable-worker-url.js +4 -4
- package/dist/es5/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
- package/dist/es5/lib/worker-utils/get-transfer-list.js +10 -4
- package/dist/es5/lib/worker-utils/get-transfer-list.js.map +1 -1
- package/dist/es5/lib/worker-utils/remove-nontransferable-options.js +7 -3
- package/dist/es5/lib/worker-utils/remove-nontransferable-options.js.map +1 -1
- package/dist/es5/workers/null-worker.js +26 -3
- package/dist/es5/workers/null-worker.js.map +1 -1
- package/dist/esm/lib/env-utils/version.js +3 -3
- package/dist/esm/lib/env-utils/version.js.map +1 -1
- package/dist/esm/lib/library-utils/library-utils.js +7 -3
- package/dist/esm/lib/library-utils/library-utils.js.map +1 -1
- package/dist/esm/lib/worker-api/get-worker-url.js +6 -2
- package/dist/esm/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/lib/env-utils/version.js +1 -1
- package/dist/lib/library-utils/library-utils.js +7 -2
- package/dist/lib/worker-api/get-worker-url.d.ts.map +1 -1
- package/dist/lib/worker-api/get-worker-url.js +10 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/lib/env-utils/version.ts +1 -1
- package/src/lib/library-utils/library-utils.ts +6 -2
- package/src/lib/worker-api/get-worker-url.ts +11 -1
- package/src/types.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/worker-utils/get-loadable-worker-url.ts"],"names":["workerURLCache","Map","getLoadableWorkerURL","props","source","url","workerURL","get","getLoadableWorkerURLFromURL","set","getLoadableWorkerURLFromSource","startsWith","workerSource","buildScriptSource","blob","Blob","type","URL","createObjectURL","workerUrl"],"mappings":";;;;;;;AAAA;;AAEA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/worker-utils/get-loadable-worker-url.ts"],"names":["workerURLCache","Map","getLoadableWorkerURL","props","source","url","workerURL","get","getLoadableWorkerURLFromURL","set","getLoadableWorkerURLFromSource","startsWith","workerSource","buildScriptSource","blob","Blob","type","URL","createObjectURL","workerUrl"],"mappings":";;;;;;;AAAA;;AAEA,IAAMA,cAAc,GAAG,IAAIC,GAAJ,EAAvB;;AAWO,SAASC,oBAAT,CAA8BC,KAA9B,EAAsE;AAC3E,sBAAQA,KAAK,CAACC,MAAN,IAAgB,CAACD,KAAK,CAACE,GAAxB,IAAiC,CAACF,KAAK,CAACC,MAAP,IAAiBD,KAAK,CAACE,GAA/D;AAEA,MAAIC,SAAS,GAAGN,cAAc,CAACO,GAAf,CAAmBJ,KAAK,CAACC,MAAN,IAAgBD,KAAK,CAACE,GAAzC,CAAhB;;AACA,MAAI,CAACC,SAAL,EAAgB;AAEd,QAAIH,KAAK,CAACE,GAAV,EAAe;AACbC,MAAAA,SAAS,GAAGE,2BAA2B,CAACL,KAAK,CAACE,GAAP,CAAvC;AACAL,MAAAA,cAAc,CAACS,GAAf,CAAmBN,KAAK,CAACE,GAAzB,EAA8BC,SAA9B;AACD;;AAED,QAAIH,KAAK,CAACC,MAAV,EAAkB;AAChBE,MAAAA,SAAS,GAAGI,8BAA8B,CAACP,KAAK,CAACC,MAAP,CAA1C;AACAJ,MAAAA,cAAc,CAACS,GAAf,CAAmBN,KAAK,CAACC,MAAzB,EAAiCE,SAAjC;AACD;AACF;;AAED,sBAAOA,SAAP;AACA,SAAOA,SAAP;AACD;;AAOD,SAASE,2BAAT,CAAqCH,GAArC,EAA0D;AAExD,MAAI,CAACA,GAAG,CAACM,UAAJ,CAAe,MAAf,CAAL,EAA6B;AAC3B,WAAON,GAAP;AACD;;AAGD,MAAMO,YAAY,GAAGC,iBAAiB,CAACR,GAAD,CAAtC;AACA,SAAOK,8BAA8B,CAACE,YAAD,CAArC;AACD;;AAOD,SAASF,8BAAT,CAAwCE,YAAxC,EAAsE;AAGpE,MAAME,IAAI,GAAG,IAAIC,IAAJ,CAAS,CAACH,YAAD,CAAT,EAAyB;AAACI,IAAAA,IAAI,EAAE;AAAP,GAAzB,CAAb;AACA,SAAOC,GAAG,CAACC,eAAJ,CAAoBJ,IAApB,CAAP;AACD;;AAUD,SAASD,iBAAT,CAA2BM,SAA3B,EAAsD;AACpD,2CAEiBA,SAFjB;AAOD","sourcesContent":["import {assert} from '../env-utils/assert';\n\nconst workerURLCache = new Map();\n\n/**\n * Creates a loadable URL from worker source or URL\n * that can be used to create `Worker` instances.\n * Due to CORS issues it may be necessary to wrap a URL in a small importScripts\n * @param props\n * @param props.source Worker source\n * @param props.url Worker URL\n * @returns loadable url\n */\nexport function getLoadableWorkerURL(props: {source?: string; url?: string}) {\n assert((props.source && !props.url) || (!props.source && props.url)); // Either source or url must be defined\n\n let workerURL = workerURLCache.get(props.source || props.url);\n if (!workerURL) {\n // Differentiate worker urls from worker source code\n if (props.url) {\n workerURL = getLoadableWorkerURLFromURL(props.url);\n workerURLCache.set(props.url, workerURL);\n }\n\n if (props.source) {\n workerURL = getLoadableWorkerURLFromSource(props.source);\n workerURLCache.set(props.source, workerURL);\n }\n }\n\n assert(workerURL);\n return workerURL;\n}\n\n/**\n * Build a loadable worker URL from worker URL\n * @param url\n * @returns loadable URL\n */\nfunction getLoadableWorkerURLFromURL(url: string): string {\n // A local script url, we can use it to initialize a Worker directly\n if (!url.startsWith('http')) {\n return url;\n }\n\n // A remote script, we need to use `importScripts` to load from different origin\n const workerSource = buildScriptSource(url);\n return getLoadableWorkerURLFromSource(workerSource);\n}\n\n/**\n * Build a loadable worker URL from worker source\n * @param workerSource\n * @returns loadable url\n */\nfunction getLoadableWorkerURLFromSource(workerSource: string): string {\n // NOTE: webworkify was previously used\n // const blob = webworkify(workerSource, {bare: true});\n const blob = new Blob([workerSource], {type: 'application/javascript'});\n return URL.createObjectURL(blob);\n}\n\n/**\n * Per spec, worker cannot be initialized with a script from a different origin\n * However a local worker script can still import scripts from other origins,\n * so we simply build a wrapper script.\n *\n * @param workerUrl\n * @returns source\n */\nfunction buildScriptSource(workerUrl: string): string {\n return `\\\ntry {\n importScripts('${workerUrl}');\n} catch (error) {\n console.error(error);\n throw error;\n}`;\n}\n"],"file":"get-loadable-worker-url.js"}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.getTransferList = getTransferList;
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
12
|
+
function getTransferList(object) {
|
|
13
|
+
var recursive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
14
|
+
var transfers = arguments.length > 2 ? arguments[2] : undefined;
|
|
15
|
+
var transfersSet = transfers || new Set();
|
|
10
16
|
|
|
11
17
|
if (!object) {} else if (isTransferable(object)) {
|
|
12
18
|
transfersSet.add(object);
|
|
13
19
|
} else if (isTransferable(object.buffer)) {
|
|
14
20
|
transfersSet.add(object.buffer);
|
|
15
|
-
} else if (ArrayBuffer.isView(object)) {} else if (recursive &&
|
|
16
|
-
for (
|
|
21
|
+
} else if (ArrayBuffer.isView(object)) {} else if (recursive && (0, _typeof2.default)(object) === 'object') {
|
|
22
|
+
for (var key in object) {
|
|
17
23
|
getTransferList(object[key], recursive, transfersSet);
|
|
18
24
|
}
|
|
19
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/worker-utils/get-transfer-list.ts"],"names":["getTransferList","object","recursive","transfers","transfersSet","Set","isTransferable","add","buffer","ArrayBuffer","isView","key","undefined","Array","from","MessagePort","ImageBitmap","OffscreenCanvas"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/worker-utils/get-transfer-list.ts"],"names":["getTransferList","object","recursive","transfers","transfersSet","Set","isTransferable","add","buffer","ArrayBuffer","isView","key","undefined","Array","from","MessagePort","ImageBitmap","OffscreenCanvas"],"mappings":";;;;;;;;;;;AAWO,SAASA,eAAT,CACLC,MADK,EAIW;AAAA,MAFhBC,SAEgB,uEAFK,IAEL;AAAA,MADhBC,SACgB;AAEhB,MAAMC,YAAY,GAAGD,SAAS,IAAI,IAAIE,GAAJ,EAAlC;;AAEA,MAAI,CAACJ,MAAL,EAAa,CAEZ,CAFD,MAEO,IAAIK,cAAc,CAACL,MAAD,CAAlB,EAA4B;AACjCG,IAAAA,YAAY,CAACG,GAAb,CAAiBN,MAAjB;AACD,GAFM,MAEA,IAAIK,cAAc,CAACL,MAAM,CAACO,MAAR,CAAlB,EAAmC;AAExCJ,IAAAA,YAAY,CAACG,GAAb,CAAiBN,MAAM,CAACO,MAAxB;AACD,GAHM,MAGA,IAAIC,WAAW,CAACC,MAAZ,CAAmBT,MAAnB,CAAJ,EAAgC,CAGtC,CAHM,MAGA,IAAIC,SAAS,IAAI,sBAAOD,MAAP,MAAkB,QAAnC,EAA6C;AAClD,SAAK,IAAMU,GAAX,IAAkBV,MAAlB,EAA0B;AAExBD,MAAAA,eAAe,CAACC,MAAM,CAACU,GAAD,CAAP,EAAcT,SAAd,EAAyBE,YAAzB,CAAf;AACD;AACF;;AAID,SAAOD,SAAS,KAAKS,SAAd,GAA0BC,KAAK,CAACC,IAAN,CAAWV,YAAX,CAA1B,GAAqD,EAA5D;AACD;;AAGD,SAASE,cAAT,CAAwBL,MAAxB,EAAyC;AACvC,MAAI,CAACA,MAAL,EAAa;AACX,WAAO,KAAP;AACD;;AACD,MAAIA,MAAM,YAAYQ,WAAtB,EAAmC;AACjC,WAAO,IAAP;AACD;;AACD,MAAI,OAAOM,WAAP,KAAuB,WAAvB,IAAsCd,MAAM,YAAYc,WAA5D,EAAyE;AACvE,WAAO,IAAP;AACD;;AACD,MAAI,OAAOC,WAAP,KAAuB,WAAvB,IAAsCf,MAAM,YAAYe,WAA5D,EAAyE;AACvE,WAAO,IAAP;AACD;;AAED,MAAI,OAAOC,eAAP,KAA2B,WAA3B,IAA0ChB,MAAM,YAAYgB,eAAhE,EAAiF;AAC/E,WAAO,IAAP;AACD;;AACD,SAAO,KAAP;AACD","sourcesContent":["// NOTE - there is a copy of this function is both in core and loader-utils\n// core does not need all the utils in loader-utils, just this one.\n\n/**\n * Returns an array of Transferrable objects that can be used with postMessage\n * https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\n * @param object data to be sent via postMessage\n * @param recursive - not for application use\n * @param transfers - not for application use\n * @returns a transfer list that can be passed to postMessage\n */\nexport function getTransferList(\n object: any,\n recursive: boolean = true,\n transfers?: Set<any>\n): Transferable[] {\n // Make sure that items in the transfer list is unique\n const transfersSet = transfers || new Set();\n\n if (!object) {\n // ignore\n } else if (isTransferable(object)) {\n transfersSet.add(object);\n } else if (isTransferable(object.buffer)) {\n // Typed array\n transfersSet.add(object.buffer);\n } else if (ArrayBuffer.isView(object)) {\n // object is a TypeArray viewing into a SharedArrayBuffer (not transferable)\n // Do not iterate through the content in this case\n } else if (recursive && typeof object === 'object') {\n for (const key in object) {\n // Avoid perf hit - only go one level deep\n getTransferList(object[key], recursive, transfersSet);\n }\n }\n\n // If transfers is defined, is internal recursive call\n // Otherwise it's called by the user\n return transfers === undefined ? Array.from(transfersSet) : [];\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Transferable\nfunction isTransferable(object: unknown) {\n if (!object) {\n return false;\n }\n if (object instanceof ArrayBuffer) {\n return true;\n }\n if (typeof MessagePort !== 'undefined' && object instanceof MessagePort) {\n return true;\n }\n if (typeof ImageBitmap !== 'undefined' && object instanceof ImageBitmap) {\n return true;\n }\n // @ts-ignore\n if (typeof OffscreenCanvas !== 'undefined' && object instanceof OffscreenCanvas) {\n return true;\n }\n return false;\n}\n"],"file":"get-transfer-list.js"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.removeNontransferableOptions = removeNontransferableOptions;
|
|
7
9
|
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
8
12
|
function removeNontransferableOptions(object) {
|
|
9
13
|
return JSON.parse(stringifyJSON(object));
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
function stringifyJSON(v) {
|
|
13
|
-
|
|
14
|
-
return JSON.stringify(v, (key, value)
|
|
15
|
-
if (
|
|
17
|
+
var cache = new Set();
|
|
18
|
+
return JSON.stringify(v, function (key, value) {
|
|
19
|
+
if ((0, _typeof2.default)(value) === 'object' && value !== null) {
|
|
16
20
|
if (cache.has(value)) {
|
|
17
21
|
try {
|
|
18
22
|
return JSON.parse(JSON.stringify(value));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/worker-utils/remove-nontransferable-options.ts"],"names":["removeNontransferableOptions","object","JSON","parse","stringifyJSON","v","cache","Set","stringify","key","value","has","err","undefined","add"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/worker-utils/remove-nontransferable-options.ts"],"names":["removeNontransferableOptions","object","JSON","parse","stringifyJSON","v","cache","Set","stringify","key","value","has","err","undefined","add"],"mappings":";;;;;;;;;;;AAIO,SAASA,4BAAT,CAAsCC,MAAtC,EAA8D;AAInE,SAAOC,IAAI,CAACC,KAAL,CAAWC,aAAa,CAACH,MAAD,CAAxB,CAAP;AACD;;AAED,SAASG,aAAT,CAAuBC,CAAvB,EAAmC;AACjC,MAAMC,KAAK,GAAG,IAAIC,GAAJ,EAAd;AACA,SAAOL,IAAI,CAACM,SAAL,CAAeH,CAAf,EAAkB,UAACI,GAAD,EAAMC,KAAN,EAAgB;AACvC,QAAI,sBAAOA,KAAP,MAAiB,QAAjB,IAA6BA,KAAK,KAAK,IAA3C,EAAiD;AAC/C,UAAIJ,KAAK,CAACK,GAAN,CAAUD,KAAV,CAAJ,EAAsB;AAEpB,YAAI;AAEF,iBAAOR,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACM,SAAL,CAAeE,KAAf,CAAX,CAAP;AACD,SAHD,CAGE,OAAOE,GAAP,EAAY;AAEZ,iBAAOC,SAAP;AACD;AACF;;AAEDP,MAAAA,KAAK,CAACQ,GAAN,CAAUJ,KAAV;AACD;;AACD,WAAOA,KAAP;AACD,GAhBM,CAAP;AAiBD","sourcesContent":["/**\n * Safely stringify JSON (drop non serializable values like functions and regexps)\n * @param value\n */\nexport function removeNontransferableOptions(object: object): object {\n // options.log object contains functions which cannot be transferred\n // TODO - decide how to handle logging on workers\n // TODO - warn if options stringification is long\n return JSON.parse(stringifyJSON(object));\n}\n\nfunction stringifyJSON(v: unknown) {\n const cache = new Set();\n return JSON.stringify(v, (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n // Circular reference found\n try {\n // If this value does not reference a parent it can be deduped\n return JSON.parse(JSON.stringify(value));\n } catch (err) {\n // discard key if value cannot be deduped\n return undefined;\n }\n }\n // Store value in our set\n cache.add(value);\n }\n return value;\n });\n}\n"],"file":"remove-nontransferable-options.js"}
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
3
9
|
var _createWorker = require("../lib/worker-api/create-worker");
|
|
4
10
|
|
|
5
|
-
(0, _createWorker.createWorker)(
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
(0, _createWorker.createWorker)(function () {
|
|
12
|
+
var _ref = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data) {
|
|
13
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
14
|
+
while (1) {
|
|
15
|
+
switch (_context.prev = _context.next) {
|
|
16
|
+
case 0:
|
|
17
|
+
return _context.abrupt("return", data);
|
|
18
|
+
|
|
19
|
+
case 1:
|
|
20
|
+
case "end":
|
|
21
|
+
return _context.stop();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}, _callee);
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
return function (_x) {
|
|
28
|
+
return _ref.apply(this, arguments);
|
|
29
|
+
};
|
|
30
|
+
}());
|
|
8
31
|
//# sourceMappingURL=null-worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/workers/null-worker.ts"],"names":["data"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/workers/null-worker.ts"],"names":["data"],"mappings":";;;;;;;;AAAA;;AAEA;AAAA,uEAAa,iBAAOA,IAAP;AAAA;AAAA;AAAA;AAAA;AAAA,6CAEJA,IAFI;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAAb;;AAAA;AAAA;AAAA;AAAA","sourcesContent":["import {createWorker} from '../lib/worker-api/create-worker';\n\ncreateWorker(async (data) => {\n // @ts-ignore\n return data;\n});\n"],"file":"null-worker.js"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const DEFAULT_VERSION = '
|
|
2
|
-
export const VERSION = typeof "3.1.
|
|
1
|
+
const DEFAULT_VERSION = 'latest';
|
|
2
|
+
export const VERSION = typeof "3.1.1" !== 'undefined' ? "3.1.1" : DEFAULT_VERSION;
|
|
3
3
|
|
|
4
|
-
if (typeof "3.1.
|
|
4
|
+
if (typeof "3.1.1" === 'undefined') {
|
|
5
5
|
console.error('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.');
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/env-utils/version.ts"],"names":["DEFAULT_VERSION","VERSION","console","error"],"mappings":"AAIA,MAAMA,eAAe,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/env-utils/version.ts"],"names":["DEFAULT_VERSION","VERSION","console","error"],"mappings":"AAIA,MAAMA,eAAe,GAAG,QAAxB;AAEA,OAAO,MAAMC,OAAO,GAAG,mBAAuB,WAAvB,aAAmDD,eAAnE;;AACP,IAAI,mBAAuB,WAA3B,EAAwC;AAEtCE,EAAAA,OAAO,CAACC,KAAR,CACE,iIADF;AAGD","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"],"file":"version.js"}
|
|
@@ -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 = '
|
|
6
|
-
const VERSION = typeof "3.1.
|
|
5
|
+
const LATEST = 'latest';
|
|
6
|
+
const VERSION = typeof "3.1.1" !== 'undefined' ? "3.1.1" : LATEST;
|
|
7
7
|
const loadLibraryPromises = {};
|
|
8
8
|
export async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
|
|
9
9
|
if (moduleName) {
|
|
@@ -47,7 +47,11 @@ async function loadLibraryFromFile(libraryUrl) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (!isBrowser) {
|
|
50
|
-
|
|
50
|
+
try {
|
|
51
|
+
return node && node.requireFromFile && (await node.requireFromFile(libraryUrl));
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
if (isWorker) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/library-utils/library-utils.ts"],"names":["global","isBrowser","isWorker","node","assert","VERSION","__VERSION__","LATEST","loadLibraryPromises","loadLibrary","libraryUrl","moduleName","options","getLibraryUrl","loadLibraryFromFile","library","startsWith","modules","CDN","endsWith","response","fetch","arrayBuffer","requireFromFile","importScripts","scriptSource","text","loadLibraryFromString","id","requireFromString","eval","call","script","document","createElement","appendChild","createTextNode","e","body"],"mappings":"AACA,SAAQA,MAAR,EAAgBC,SAAhB,EAA2BC,QAA3B,QAA0C,sBAA1C;AACA,OAAO,KAAKC,IAAZ,MAAsB,4BAAtB;AACA,SAAQC,MAAR,QAAqB,qBAArB;AACA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,sBAArC;AAGA,MAAMC,MAAM,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/library-utils/library-utils.ts"],"names":["global","isBrowser","isWorker","node","assert","VERSION","__VERSION__","LATEST","loadLibraryPromises","loadLibrary","libraryUrl","moduleName","options","getLibraryUrl","loadLibraryFromFile","library","startsWith","modules","CDN","endsWith","response","fetch","arrayBuffer","requireFromFile","importScripts","scriptSource","text","loadLibraryFromString","id","requireFromString","eval","call","script","document","createElement","appendChild","createTextNode","e","body"],"mappings":"AACA,SAAQA,MAAR,EAAgBC,SAAhB,EAA2BC,QAA3B,QAA0C,sBAA1C;AACA,OAAO,KAAKC,IAAZ,MAAs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nB;AACD,GAFD,CAEE,OAAOY,CAAP,EAAU;AACVL,IAAAA,MAAM,CAACN,IAAP,GAAcD,YAAd;AACD;;AACDQ,EAAAA,QAAQ,CAACK,IAAT,CAAcH,WAAd,CAA0BH,MAA1B;AACA,SAAO,IAAP;AACD","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// TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...\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"],"file":"library-utils.js"}
|
|
@@ -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 = '
|
|
4
|
-
const VERSION = typeof "3.1.
|
|
3
|
+
const NPM_TAG = 'latest';
|
|
4
|
+
const VERSION = typeof "3.1.1" !== 'undefined' ? "3.1.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);
|
|
@@ -11,6 +11,10 @@ export function getWorkerURL(worker, options = {}) {
|
|
|
11
11
|
const workerFile = "".concat(worker.id, "-worker.js");
|
|
12
12
|
let url = workerOptions.workerUrl;
|
|
13
13
|
|
|
14
|
+
if (!url && worker.id === 'compression') {
|
|
15
|
+
url = options.workerUrl;
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
if (options._workerType === 'test') {
|
|
15
19
|
url = "modules/".concat(worker.module, "/dist/").concat(workerFile);
|
|
16
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/worker-api/get-worker-url.ts"],"names":["assert","VERSION","__VERSION__","NPM_TAG","getWorkerName","worker","warning","version","name","getWorkerURL","options","workerOptions","id","workerFile","url","workerUrl","_workerType","module","versionTag"],"mappings":"AACA,SAAQA,MAAR,QAAqB,qBAArB;AACA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,sBAArC;AAEA,MAAMC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/worker-api/get-worker-url.ts"],"names":["assert","VERSION","__VERSION__","NPM_TAG","getWorkerName","worker","warning","version","name","getWorkerURL","options","workerOptions","id","workerFile","url","workerUrl","_workerType","module","versionTag"],"mappings":"AACA,SAAQA,MAAR,QAAqB,qBAArB;AACA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,sBAArC;AAEA,MAAMC,OAAO,GAAG,QAAhB;AACA,MAAMF,OAAO,GAAG,mBAAuB,WAAvB,aAAmDE,OAAnE;AAKA,OAAO,SAASC,aAAT,CAAuBC,MAAvB,EAAqD;AAC1D,QAAMC,OAAO,GAAGD,MAAM,CAACE,OAAP,KAAmBN,OAAnB,4BAA+CA,OAA/C,SAA4D,EAA5E;AACA,mBAAUI,MAAM,CAACG,IAAjB,cAAyBH,MAAM,CAACE,OAAhC,SAA0CD,OAA1C;AACD;AASD,OAAO,SAASG,YAAT,CAAsBJ,MAAtB,EAA4CK,OAAsB,GAAG,EAArE,EAAiF;AACtF,QAAMC,aAAa,GAAGD,OAAO,CAACL,MAAM,CAACO,EAAR,CAAP,IAAsB,EAA5C;AAEA,QAAMC,UAAU,aAAMR,MAAM,CAACO,EAAb,eAAhB;AAEA,MAAIE,GAAG,GAAGH,aAAa,CAACI,SAAxB;;AAQA,MAAI,CAACD,GAAD,IAAQT,MAAM,CAACO,EAAP,KAAc,aAA1B,EAAyC;AACvCE,IAAAA,GAAG,GAAGJ,OAAO,CAACK,SAAd;AACD;;AAID,MAAIL,OAAO,CAACM,WAAR,KAAwB,MAA5B,EAAoC;AAClCF,IAAAA,GAAG,qBAAcT,MAAM,CAACY,MAArB,mBAAoCJ,UAApC,CAAH;AACD;;AAGD,MAAI,CAACC,GAAL,EAAU;AAER,QAAIP,OAAO,GAAGF,MAAM,CAACE,OAArB;;AAEA,QAAIA,OAAO,KAAK,QAAhB,EAA0B;AAExBA,MAAAA,OAAO,GAAGJ,OAAV;AACD;;AACD,UAAMe,UAAU,GAAGX,OAAO,cAAOA,OAAP,IAAmB,EAA7C;AACAO,IAAAA,GAAG,2CAAoCT,MAAM,CAACY,MAA3C,SAAoDC,UAApD,mBAAuEL,UAAvE,CAAH;AACD;;AAEDb,EAAAA,MAAM,CAACc,GAAD,CAAN;AAGA,SAAOA,GAAP;AACD","sourcesContent":["import type {WorkerObject, WorkerOptions} from '../../types';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\nconst NPM_TAG = 'latest'; // Change to '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"],"file":"get-worker-url.js"}
|
|
@@ -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 = '
|
|
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
|
|
@@ -26,7 +26,7 @@ const node = __importStar(require("../node/require-utils.node"));
|
|
|
26
26
|
const assert_1 = require("../env-utils/assert");
|
|
27
27
|
const version_1 = require("../env-utils/version");
|
|
28
28
|
// TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...
|
|
29
|
-
const LATEST = '
|
|
29
|
+
const LATEST = 'latest';
|
|
30
30
|
const VERSION = typeof version_1.VERSION !== 'undefined' ? version_1.VERSION : LATEST;
|
|
31
31
|
const loadLibraryPromises = {}; // promises
|
|
32
32
|
/**
|
|
@@ -89,7 +89,12 @@ async function loadLibraryFromFile(libraryUrl) {
|
|
|
89
89
|
return await response.arrayBuffer();
|
|
90
90
|
}
|
|
91
91
|
if (!globals_1.isBrowser) {
|
|
92
|
-
|
|
92
|
+
try {
|
|
93
|
+
return node && node.requireFromFile && (await node.requireFromFile(libraryUrl));
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
93
98
|
}
|
|
94
99
|
if (globals_1.isWorker) {
|
|
95
100
|
return importScripts(libraryUrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-worker-url.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-api/get-worker-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAO7D;;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,
|
|
1
|
+
{"version":3,"file":"get-worker-url.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-api/get-worker-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAO7D;;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"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getWorkerURL = exports.getWorkerName = void 0;
|
|
4
4
|
const assert_1 = require("../env-utils/assert");
|
|
5
5
|
const version_1 = require("../env-utils/version");
|
|
6
|
-
const NPM_TAG = '
|
|
6
|
+
const NPM_TAG = 'latest'; // Change to 'latest' on release-branch
|
|
7
7
|
const VERSION = typeof version_1.VERSION !== 'undefined' ? version_1.VERSION : NPM_TAG;
|
|
8
8
|
/**
|
|
9
9
|
* Gets worker object's name (for debugging in Chrome thread inspector window)
|
|
@@ -24,6 +24,15 @@ function getWorkerURL(worker, options = {}) {
|
|
|
24
24
|
const workerOptions = options[worker.id] || {};
|
|
25
25
|
const workerFile = `${worker.id}-worker.js`;
|
|
26
26
|
let url = workerOptions.workerUrl;
|
|
27
|
+
// HACK: Allow for non-nested workerUrl for the CompressionWorker.
|
|
28
|
+
// For the compression worker, workerOptions is currently not nested correctly. For most loaders,
|
|
29
|
+
// you'd have options within an object, i.e. `{mvt: {coordinates: ...}}` but the CompressionWorker
|
|
30
|
+
// puts options at the top level, not within a `compression` key (its `id`). For this reason, the
|
|
31
|
+
// above `workerOptions` will always be a string (i.e. `'gzip'`) for the CompressionWorker. To not
|
|
32
|
+
// break backwards compatibility, we allow the CompressionWorker to have options at the top level.
|
|
33
|
+
if (!url && worker.id === 'compression') {
|
|
34
|
+
url = options.workerUrl;
|
|
35
|
+
}
|
|
27
36
|
// If URL is test, generate local loaders.gl url
|
|
28
37
|
// @ts-ignore _workerType
|
|
29
38
|
if (options._workerType === 'test') {
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,aAAa,GAAG;IAE1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF,oBAAY,OAAO,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,GAAG,CAAC;AAElG,oBAAY,gBAAgB,GAAG,CAC7B,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,G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AAC;AAmBF,oBAAY,iBAAiB,GACzB,SAAS,GACT,MAAM,GACN,OAAO,GACP,oBAAoB,GACpB,aAAa,GACb,YAAY,GACZ,cAAc,CAAC;AAEnB,oBAAY,oBAAoB,GAAG;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,oBAAoB,CAAC;CAC/B,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/worker-utils",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Utilities for running tasks on worker threads",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.3.1"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ed3c238bcb68ab5a2d4ddc64319f6f4c02a20df7"
|
|
49
49
|
}
|
|
@@ -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 = '
|
|
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') {
|
|
@@ -5,7 +5,7 @@ import {assert} from '../env-utils/assert';
|
|
|
5
5
|
import {VERSION as __VERSION__} from '../env-utils/version';
|
|
6
6
|
|
|
7
7
|
// TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...
|
|
8
|
-
const LATEST = '
|
|
8
|
+
const LATEST = 'latest';
|
|
9
9
|
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : LATEST;
|
|
10
10
|
|
|
11
11
|
const loadLibraryPromises: Record<string, Promise<any>> = {}; // promises
|
|
@@ -82,7 +82,11 @@ async function loadLibraryFromFile(libraryUrl: string): Promise<any> {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (!isBrowser) {
|
|
85
|
-
|
|
85
|
+
try {
|
|
86
|
+
return node && node.requireFromFile && (await node.requireFromFile(libraryUrl));
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
86
90
|
}
|
|
87
91
|
if (isWorker) {
|
|
88
92
|
return importScripts(libraryUrl);
|
|
@@ -2,7 +2,7 @@ import type {WorkerObject, WorkerOptions} from '../../types';
|
|
|
2
2
|
import {assert} from '../env-utils/assert';
|
|
3
3
|
import {VERSION as __VERSION__} from '../env-utils/version';
|
|
4
4
|
|
|
5
|
-
const NPM_TAG = '
|
|
5
|
+
const NPM_TAG = 'latest'; // Change to 'latest' on release-branch
|
|
6
6
|
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : NPM_TAG;
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -27,6 +27,16 @@ export function getWorkerURL(worker: WorkerObject, options: WorkerOptions = {}):
|
|
|
27
27
|
|
|
28
28
|
let url = workerOptions.workerUrl;
|
|
29
29
|
|
|
30
|
+
// HACK: Allow for non-nested workerUrl for the CompressionWorker.
|
|
31
|
+
// For the compression worker, workerOptions is currently not nested correctly. For most loaders,
|
|
32
|
+
// you'd have options within an object, i.e. `{mvt: {coordinates: ...}}` but the CompressionWorker
|
|
33
|
+
// puts options at the top level, not within a `compression` key (its `id`). For this reason, the
|
|
34
|
+
// above `workerOptions` will always be a string (i.e. `'gzip'`) for the CompressionWorker. To not
|
|
35
|
+
// break backwards compatibility, we allow the CompressionWorker to have options at the top level.
|
|
36
|
+
if (!url && worker.id === 'compression') {
|
|
37
|
+
url = options.workerUrl;
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
// If URL is test, generate local loaders.gl url
|
|
31
41
|
// @ts-ignore _workerType
|
|
32
42
|
if (options._workerType === 'test') {
|