@loaders.gl/worker-utils 3.4.14 → 3.4.15
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 +20 -20
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/async-queue/async-queue.js +55 -71
- package/dist/es5/lib/async-queue/async-queue.js.map +1 -1
- package/dist/es5/lib/env-utils/globals.js +10 -12
- 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 +33 -104
- package/dist/es5/lib/library-utils/library-utils.js.map +1 -1
- package/dist/es5/lib/node/require-utils.browser.js +4 -4
- package/dist/es5/lib/node/require-utils.browser.js.map +1 -1
- package/dist/es5/lib/node/require-utils.node.js +17 -44
- package/dist/es5/lib/node/require-utils.node.js.map +1 -1
- package/dist/es5/lib/node/worker_threads-browser.js +4 -14
- package/dist/es5/lib/node/worker_threads-browser.js.map +1 -1
- package/dist/es5/lib/node/worker_threads.js +4 -5
- package/dist/es5/lib/node/worker_threads.js.map +1 -1
- package/dist/es5/lib/process-utils/child-process-proxy.js +84 -163
- package/dist/es5/lib/process-utils/child-process-proxy.js.map +1 -1
- package/dist/es5/lib/process-utils/process-utils.js +8 -8
- package/dist/es5/lib/process-utils/process-utils.js.map +1 -1
- package/dist/es5/lib/worker-api/create-worker.js +47 -122
- package/dist/es5/lib/worker-api/create-worker.js.map +1 -1
- package/dist/es5/lib/worker-api/get-worker-url.js +9 -9
- package/dist/es5/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/es5/lib/worker-api/process-on-worker.js +59 -113
- package/dist/es5/lib/worker-api/process-on-worker.js.map +1 -1
- package/dist/es5/lib/worker-api/validate-worker-version.js +3 -3
- package/dist/es5/lib/worker-api/validate-worker-version.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-body.js +68 -84
- package/dist/es5/lib/worker-farm/worker-body.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-farm.js +55 -88
- package/dist/es5/lib/worker-farm/worker-farm.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-job.js +25 -37
- package/dist/es5/lib/worker-farm/worker-job.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-pool.js +96 -175
- package/dist/es5/lib/worker-farm/worker-pool.js.map +1 -1
- package/dist/es5/lib/worker-farm/worker-thread.js +76 -99
- 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 +8 -10
- package/dist/es5/lib/worker-utils/get-transfer-list.js.map +1 -1
- package/dist/es5/lib/worker-utils/remove-nontransferable-options.js +3 -5
- package/dist/es5/lib/worker-utils/remove-nontransferable-options.js.map +1 -1
- package/dist/es5/workers/null-worker.js +3 -19
- package/dist/es5/workers/null-worker.js.map +1 -1
- package/dist/esm/lib/env-utils/version.js +2 -2
- package/dist/esm/lib/library-utils/library-utils.js +1 -1
- package/dist/esm/lib/worker-api/get-worker-url.js +1 -1
- package/package.json +2 -2
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getLoadableWorkerURL = getLoadableWorkerURL;
|
|
7
7
|
var _assert = require("../env-utils/assert");
|
|
8
|
-
|
|
8
|
+
const workerURLCache = new Map();
|
|
9
9
|
function getLoadableWorkerURL(props) {
|
|
10
10
|
(0, _assert.assert)(props.source && !props.url || !props.source && props.url);
|
|
11
|
-
|
|
11
|
+
let workerURL = workerURLCache.get(props.source || props.url);
|
|
12
12
|
if (!workerURL) {
|
|
13
13
|
if (props.url) {
|
|
14
14
|
workerURL = getLoadableWorkerURLFromURL(props.url);
|
|
@@ -26,11 +26,11 @@ function getLoadableWorkerURLFromURL(url) {
|
|
|
26
26
|
if (!url.startsWith('http')) {
|
|
27
27
|
return url;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
const workerSource = buildScriptSource(url);
|
|
30
30
|
return getLoadableWorkerURLFromSource(workerSource);
|
|
31
31
|
}
|
|
32
32
|
function getLoadableWorkerURLFromSource(workerSource) {
|
|
33
|
-
|
|
33
|
+
const blob = new Blob([workerSource], {
|
|
34
34
|
type: 'application/javascript'
|
|
35
35
|
});
|
|
36
36
|
return URL.createObjectURL(blob);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-loadable-worker-url.js","names":["_assert","require","workerURLCache","Map","getLoadableWorkerURL","props","assert","source","url","workerURL","get","getLoadableWorkerURLFromURL","set","getLoadableWorkerURLFromSource","startsWith","workerSource","buildScriptSource","blob","Blob","type","URL","createObjectURL","workerUrl","concat"],"sources":["../../../../src/lib/worker-utils/get-loadable-worker-url.ts"],"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 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"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,
|
|
1
|
+
{"version":3,"file":"get-loadable-worker-url.js","names":["_assert","require","workerURLCache","Map","getLoadableWorkerURL","props","assert","source","url","workerURL","get","getLoadableWorkerURLFromURL","set","getLoadableWorkerURLFromSource","startsWith","workerSource","buildScriptSource","blob","Blob","type","URL","createObjectURL","workerUrl","concat"],"sources":["../../../../src/lib/worker-utils/get-loadable-worker-url.ts"],"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 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"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAAC,CAAC;AAWzB,SAASC,oBAAoBA,CAACC,KAAsC,EAAE;EAC3E,IAAAC,cAAM,EAAED,KAAK,CAACE,MAAM,IAAI,CAACF,KAAK,CAACG,GAAG,IAAM,CAACH,KAAK,CAACE,MAAM,IAAIF,KAAK,CAACG,GAAI,CAAC;EAEpE,IAAIC,SAAS,GAAGP,cAAc,CAACQ,GAAG,CAACL,KAAK,CAACE,MAAM,IAAIF,KAAK,CAACG,GAAG,CAAC;EAC7D,IAAI,CAACC,SAAS,EAAE;IAEd,IAAIJ,KAAK,CAACG,GAAG,EAAE;MACbC,SAAS,GAAGE,2BAA2B,CAACN,KAAK,CAACG,GAAG,CAAC;MAClDN,cAAc,CAACU,GAAG,CAACP,KAAK,CAACG,GAAG,EAAEC,SAAS,CAAC;IAC1C;IAEA,IAAIJ,KAAK,CAACE,MAAM,EAAE;MAChBE,SAAS,GAAGI,8BAA8B,CAACR,KAAK,CAACE,MAAM,CAAC;MACxDL,cAAc,CAACU,GAAG,CAACP,KAAK,CAACE,MAAM,EAAEE,SAAS,CAAC;IAC7C;EACF;EAEA,IAAAH,cAAM,EAACG,SAAS,CAAC;EACjB,OAAOA,SAAS;AAClB;AAOA,SAASE,2BAA2BA,CAACH,GAAW,EAAU;EAExD,IAAI,CAACA,GAAG,CAACM,UAAU,CAAC,MAAM,CAAC,EAAE;IAC3B,OAAON,GAAG;EACZ;EAGA,MAAMO,YAAY,GAAGC,iBAAiB,CAACR,GAAG,CAAC;EAC3C,OAAOK,8BAA8B,CAACE,YAAY,CAAC;AACrD;AAOA,SAASF,8BAA8BA,CAACE,YAAoB,EAAU;EACpE,MAAME,IAAI,GAAG,IAAIC,IAAI,CAAC,CAACH,YAAY,CAAC,EAAE;IAACI,IAAI,EAAE;EAAwB,CAAC,CAAC;EACvE,OAAOC,GAAG,CAACC,eAAe,CAACJ,IAAI,CAAC;AAClC;AAUA,SAASD,iBAAiBA,CAACM,SAAiB,EAAU;EACpD,kCAAAC,MAAA,CAEiBD,SAAS;AAK5B"}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.getTransferList = getTransferList;
|
|
8
7
|
exports.getTransferListForWriter = getTransferListForWriter;
|
|
9
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
8
|
function getTransferList(object) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
let recursive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
10
|
+
let transfers = arguments.length > 2 ? arguments[2] : undefined;
|
|
11
|
+
const transfersSet = transfers || new Set();
|
|
14
12
|
if (!object) {} else if (isTransferable(object)) {
|
|
15
13
|
transfersSet.add(object);
|
|
16
14
|
} else if (isTransferable(object.buffer)) {
|
|
17
15
|
transfersSet.add(object.buffer);
|
|
18
|
-
} else if (ArrayBuffer.isView(object)) {} else if (recursive &&
|
|
19
|
-
for (
|
|
16
|
+
} else if (ArrayBuffer.isView(object)) {} else if (recursive && typeof object === 'object') {
|
|
17
|
+
for (const key in object) {
|
|
20
18
|
getTransferList(object[key], recursive, transfersSet);
|
|
21
19
|
}
|
|
22
20
|
}
|
|
@@ -44,9 +42,9 @@ function getTransferListForWriter(object) {
|
|
|
44
42
|
if (object === null) {
|
|
45
43
|
return {};
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
Object.keys(clone).forEach(
|
|
49
|
-
if (
|
|
45
|
+
const clone = Object.assign({}, object);
|
|
46
|
+
Object.keys(clone).forEach(key => {
|
|
47
|
+
if (typeof object[key] === 'object' && !ArrayBuffer.isView(object[key]) && !(object[key] instanceof Array)) {
|
|
50
48
|
clone[key] = getTransferListForWriter(object[key]);
|
|
51
49
|
} else if (typeof clone[key] === 'function' || clone[key] instanceof RegExp) {
|
|
52
50
|
clone[key] = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-transfer-list.js","names":["getTransferList","object","recursive","arguments","length","undefined","transfers","transfersSet","Set","isTransferable","add","buffer","ArrayBuffer","isView","
|
|
1
|
+
{"version":3,"file":"get-transfer-list.js","names":["getTransferList","object","recursive","arguments","length","undefined","transfers","transfersSet","Set","isTransferable","add","buffer","ArrayBuffer","isView","key","Array","from","MessagePort","ImageBitmap","OffscreenCanvas","getTransferListForWriter","clone","Object","assign","keys","forEach","RegExp"],"sources":["../../../../src/lib/worker-utils/get-transfer-list.ts"],"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\n/**\n * Recursively drop non serializable values like functions and regexps.\n * @param object\n */\nexport function getTransferListForWriter(object: object | null): object {\n if (object === null) {\n return {};\n }\n const clone = Object.assign({}, object);\n\n Object.keys(clone).forEach((key) => {\n // Typed Arrays and Arrays are passed with no change\n if (\n typeof object[key] === 'object' &&\n !ArrayBuffer.isView(object[key]) &&\n !(object[key] instanceof Array)\n ) {\n clone[key] = getTransferListForWriter(object[key]);\n } else if (typeof clone[key] === 'function' || clone[key] instanceof RegExp) {\n clone[key] = {};\n } else {\n clone[key] = object[key];\n }\n });\n\n return clone;\n}\n"],"mappings":";;;;;;;AAWO,SAASA,eAAeA,CAC7BC,MAAW,EAGK;EAAA,IAFhBC,SAAkB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAAA,IACzBG,SAAoB,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAGpB,MAAME,YAAY,GAAGD,SAAS,IAAI,IAAIE,GAAG,CAAC,CAAC;EAE3C,IAAI,CAACP,MAAM,EAAE,CAEb,CAAC,MAAM,IAAIQ,cAAc,CAACR,MAAM,CAAC,EAAE;IACjCM,YAAY,CAACG,GAAG,CAACT,MAAM,CAAC;EAC1B,CAAC,MAAM,IAAIQ,cAAc,CAACR,MAAM,CAACU,MAAM,CAAC,EAAE;IAExCJ,YAAY,CAACG,GAAG,CAACT,MAAM,CAACU,MAAM,CAAC;EACjC,CAAC,MAAM,IAAIC,WAAW,CAACC,MAAM,CAACZ,MAAM,CAAC,EAAE,CAGvC,CAAC,MAAM,IAAIC,SAAS,IAAI,OAAOD,MAAM,KAAK,QAAQ,EAAE;IAClD,KAAK,MAAMa,GAAG,IAAIb,MAAM,EAAE;MAExBD,eAAe,CAACC,MAAM,CAACa,GAAG,CAAC,EAAEZ,SAAS,EAAEK,YAAY,CAAC;IACvD;EACF;EAIA,OAAOD,SAAS,KAAKD,SAAS,GAAGU,KAAK,CAACC,IAAI,CAACT,YAAY,CAAC,GAAG,EAAE;AAChE;AAGA,SAASE,cAAcA,CAACR,MAAe,EAAE;EACvC,IAAI,CAACA,MAAM,EAAE;IACX,OAAO,KAAK;EACd;EACA,IAAIA,MAAM,YAAYW,WAAW,EAAE;IACjC,OAAO,IAAI;EACb;EACA,IAAI,OAAOK,WAAW,KAAK,WAAW,IAAIhB,MAAM,YAAYgB,WAAW,EAAE;IACvE,OAAO,IAAI;EACb;EACA,IAAI,OAAOC,WAAW,KAAK,WAAW,IAAIjB,MAAM,YAAYiB,WAAW,EAAE;IACvE,OAAO,IAAI;EACb;EAEA,IAAI,OAAOC,eAAe,KAAK,WAAW,IAAIlB,MAAM,YAAYkB,eAAe,EAAE;IAC/E,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd;AAMO,SAASC,wBAAwBA,CAACnB,MAAqB,EAAU;EACtE,IAAIA,MAAM,KAAK,IAAI,EAAE;IACnB,OAAO,CAAC,CAAC;EACX;EACA,MAAMoB,KAAK,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEtB,MAAM,CAAC;EAEvCqB,MAAM,CAACE,IAAI,CAACH,KAAK,CAAC,CAACI,OAAO,CAAEX,GAAG,IAAK;IAElC,IACE,OAAOb,MAAM,CAACa,GAAG,CAAC,KAAK,QAAQ,IAC/B,CAACF,WAAW,CAACC,MAAM,CAACZ,MAAM,CAACa,GAAG,CAAC,CAAC,IAChC,EAAEb,MAAM,CAACa,GAAG,CAAC,YAAYC,KAAK,CAAC,EAC/B;MACAM,KAAK,CAACP,GAAG,CAAC,GAAGM,wBAAwB,CAACnB,MAAM,CAACa,GAAG,CAAC,CAAC;IACpD,CAAC,MAAM,IAAI,OAAOO,KAAK,CAACP,GAAG,CAAC,KAAK,UAAU,IAAIO,KAAK,CAACP,GAAG,CAAC,YAAYY,MAAM,EAAE;MAC3EL,KAAK,CAACP,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC,MAAM;MACLO,KAAK,CAACP,GAAG,CAAC,GAAGb,MAAM,CAACa,GAAG,CAAC;IAC1B;EACF,CAAC,CAAC;EAEF,OAAOO,KAAK;AACd"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.removeNontransferableOptions = removeNontransferableOptions;
|
|
8
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
7
|
function removeNontransferableOptions(object) {
|
|
10
8
|
if (object === null) {
|
|
11
9
|
return {};
|
|
12
10
|
}
|
|
13
|
-
|
|
14
|
-
Object.keys(clone).forEach(
|
|
15
|
-
if (
|
|
11
|
+
const clone = Object.assign({}, object);
|
|
12
|
+
Object.keys(clone).forEach(key => {
|
|
13
|
+
if (typeof object[key] === 'object' && !ArrayBuffer.isView(object[key])) {
|
|
16
14
|
clone[key] = removeNontransferableOptions(object[key]);
|
|
17
15
|
} else if (typeof clone[key] === 'function' || clone[key] instanceof RegExp) {
|
|
18
16
|
clone[key] = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-nontransferable-options.js","names":["removeNontransferableOptions","object","clone","Object","assign","keys","forEach","key","
|
|
1
|
+
{"version":3,"file":"remove-nontransferable-options.js","names":["removeNontransferableOptions","object","clone","Object","assign","keys","forEach","key","ArrayBuffer","isView","RegExp"],"sources":["../../../../src/lib/worker-utils/remove-nontransferable-options.ts"],"sourcesContent":["/**\n * Recursively drop non serializable values like functions and regexps.\n * @param object\n */\nexport function removeNontransferableOptions(object: object | null): object {\n if (object === null) {\n return {};\n }\n const clone = Object.assign({}, object);\n\n Object.keys(clone).forEach((key) => {\n // Checking if it is an object and not a typed array.\n if (typeof object[key] === 'object' && !ArrayBuffer.isView(object[key])) {\n clone[key] = removeNontransferableOptions(object[key]);\n } else if (typeof clone[key] === 'function' || clone[key] instanceof RegExp) {\n clone[key] = {};\n } else {\n clone[key] = object[key];\n }\n });\n\n return clone;\n}\n"],"mappings":";;;;;;AAIO,SAASA,4BAA4BA,CAACC,MAAqB,EAAU;EAC1E,IAAIA,MAAM,KAAK,IAAI,EAAE;IACnB,OAAO,CAAC,CAAC;EACX;EACA,MAAMC,KAAK,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEH,MAAM,CAAC;EAEvCE,MAAM,CAACE,IAAI,CAACH,KAAK,CAAC,CAACI,OAAO,CAAEC,GAAG,IAAK;IAElC,IAAI,OAAON,MAAM,CAACM,GAAG,CAAC,KAAK,QAAQ,IAAI,CAACC,WAAW,CAACC,MAAM,CAACR,MAAM,CAACM,GAAG,CAAC,CAAC,EAAE;MACvEL,KAAK,CAACK,GAAG,CAAC,GAAGP,4BAA4B,CAACC,MAAM,CAACM,GAAG,CAAC,CAAC;IACxD,CAAC,MAAM,IAAI,OAAOL,KAAK,CAACK,GAAG,CAAC,KAAK,UAAU,IAAIL,KAAK,CAACK,GAAG,CAAC,YAAYG,MAAM,EAAE;MAC3ER,KAAK,CAACK,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC,MAAM;MACLL,KAAK,CAACK,GAAG,CAAC,GAAGN,MAAM,CAACM,GAAG,CAAC;IAC1B;EACF,CAAC,CAAC;EAEF,OAAOL,KAAK;AACd"}
|
|
@@ -1,23 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
5
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
3
|
var _createWorker = require("../lib/worker-api/create-worker");
|
|
7
|
-
(0, _createWorker.createWorker)(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
while (1) switch (_context.prev = _context.next) {
|
|
11
|
-
case 0:
|
|
12
|
-
return _context.abrupt("return", data);
|
|
13
|
-
case 1:
|
|
14
|
-
case "end":
|
|
15
|
-
return _context.stop();
|
|
16
|
-
}
|
|
17
|
-
}, _callee);
|
|
18
|
-
}));
|
|
19
|
-
return function (_x) {
|
|
20
|
-
return _ref.apply(this, arguments);
|
|
21
|
-
};
|
|
22
|
-
}());
|
|
4
|
+
(0, _createWorker.createWorker)(async data => {
|
|
5
|
+
return data;
|
|
6
|
+
});
|
|
23
7
|
//# sourceMappingURL=null-worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"null-worker.js","names":["_createWorker","require","createWorker","
|
|
1
|
+
{"version":3,"file":"null-worker.js","names":["_createWorker","require","createWorker","data"],"sources":["../../../src/workers/null-worker.ts"],"sourcesContent":["import {createWorker} from '../lib/worker-api/create-worker';\n\ncreateWorker(async (data) => {\n // @ts-ignore\n return data;\n});\n"],"mappings":";;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,0BAAY,EAAC,MAAOC,IAAI,IAAK;EAE3B,OAAOA,IAAI;AACb,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const DEFAULT_VERSION = 'latest';
|
|
2
|
-
export const VERSION = typeof "3.4.
|
|
3
|
-
if (typeof "3.4.
|
|
2
|
+
export const VERSION = typeof "3.4.15" !== 'undefined' ? "3.4.15" : DEFAULT_VERSION;
|
|
3
|
+
if (typeof "3.4.15" === '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
|
|
@@ -3,7 +3,7 @@ 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
5
|
const LATEST = 'latest';
|
|
6
|
-
const VERSION = typeof "3.4.
|
|
6
|
+
const VERSION = typeof "3.4.15" !== 'undefined' ? "3.4.15" : 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,7 +1,7 @@
|
|
|
1
1
|
import { assert } from '../env-utils/assert';
|
|
2
2
|
import { VERSION as __VERSION__ } from '../env-utils/version';
|
|
3
3
|
const NPM_TAG = 'latest';
|
|
4
|
-
const VERSION = typeof "3.4.
|
|
4
|
+
const VERSION = typeof "3.4.15" !== 'undefined' ? "3.4.15" : 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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/worker-utils",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.15",
|
|
4
4
|
"description": "Utilities for running tasks on worker threads",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@babel/runtime": "^7.3.1"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "19e941d5805568e449ef9092490d6568a4853298"
|
|
52
52
|
}
|