@loaders.gl/worker-utils 3.1.0-alpha.4 → 3.1.0-alpha.5

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.
Files changed (85) hide show
  1. package/dist/es5/index.js +19 -19
  2. package/dist/es5/index.js.map +1 -1
  3. package/dist/es5/lib/async-queue/async-queue.js +62 -76
  4. package/dist/es5/lib/async-queue/async-queue.js.map +1 -1
  5. package/dist/es5/lib/env-utils/globals.js +10 -15
  6. package/dist/es5/lib/env-utils/globals.js.map +1 -1
  7. package/dist/es5/lib/env-utils/version.js +3 -3
  8. package/dist/es5/lib/env-utils/version.js.map +1 -1
  9. package/dist/es5/lib/library-utils/library-utils.js +29 -127
  10. package/dist/es5/lib/library-utils/library-utils.js.map +1 -1
  11. package/dist/es5/lib/node/require-utils.node.js +20 -65
  12. package/dist/es5/lib/node/require-utils.node.js.map +1 -1
  13. package/dist/es5/lib/process-utils/child-process-proxy.js +90 -199
  14. package/dist/es5/lib/process-utils/child-process-proxy.js.map +1 -1
  15. package/dist/es5/lib/process-utils/process-utils.js +8 -9
  16. package/dist/es5/lib/process-utils/process-utils.js.map +1 -1
  17. package/dist/es5/lib/worker-api/create-worker.js +52 -162
  18. package/dist/es5/lib/worker-api/create-worker.js.map +1 -1
  19. package/dist/es5/lib/worker-api/get-worker-url.js +9 -10
  20. package/dist/es5/lib/worker-api/get-worker-url.js.map +1 -1
  21. package/dist/es5/lib/worker-api/process-on-worker.js +59 -130
  22. package/dist/es5/lib/worker-api/process-on-worker.js.map +1 -1
  23. package/dist/es5/lib/worker-api/validate-worker-version.js +3 -4
  24. package/dist/es5/lib/worker-api/validate-worker-version.js.map +1 -1
  25. package/dist/es5/lib/worker-farm/worker-body.js +46 -58
  26. package/dist/es5/lib/worker-farm/worker-body.js.map +1 -1
  27. package/dist/es5/lib/worker-farm/worker-farm.js +60 -99
  28. package/dist/es5/lib/worker-farm/worker-farm.js.map +1 -1
  29. package/dist/es5/lib/worker-farm/worker-job.js +28 -40
  30. package/dist/es5/lib/worker-farm/worker-job.js.map +1 -1
  31. package/dist/es5/lib/worker-farm/worker-pool.js +108 -204
  32. package/dist/es5/lib/worker-farm/worker-pool.js.map +1 -1
  33. package/dist/es5/lib/worker-farm/worker-thread.js +67 -85
  34. package/dist/es5/lib/worker-farm/worker-thread.js.map +1 -1
  35. package/dist/es5/lib/worker-utils/get-loadable-worker-url.js +4 -4
  36. package/dist/es5/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
  37. package/dist/es5/lib/worker-utils/get-transfer-list.js +4 -10
  38. package/dist/es5/lib/worker-utils/get-transfer-list.js.map +1 -1
  39. package/dist/es5/lib/worker-utils/remove-nontransferable-options.js +3 -7
  40. package/dist/es5/lib/worker-utils/remove-nontransferable-options.js.map +1 -1
  41. package/dist/es5/workers/null-worker.js +3 -26
  42. package/dist/es5/workers/null-worker.js.map +1 -1
  43. package/dist/esm/lib/env-utils/version.js +2 -2
  44. package/dist/esm/lib/library-utils/library-utils.js +5 -5
  45. package/dist/esm/lib/library-utils/library-utils.js.map +1 -1
  46. package/dist/esm/lib/node/require-utils.node.js +2 -2
  47. package/dist/esm/lib/node/require-utils.node.js.map +1 -1
  48. package/dist/esm/lib/process-utils/child-process-proxy.js +5 -5
  49. package/dist/esm/lib/process-utils/child-process-proxy.js.map +1 -1
  50. package/dist/esm/lib/worker-api/get-worker-url.js +7 -7
  51. package/dist/esm/lib/worker-api/get-worker-url.js.map +1 -1
  52. package/dist/esm/lib/worker-api/process-on-worker.js +1 -1
  53. package/dist/esm/lib/worker-api/process-on-worker.js.map +1 -1
  54. package/dist/esm/lib/worker-farm/worker-pool.js +1 -1
  55. package/dist/esm/lib/worker-farm/worker-pool.js.map +1 -1
  56. package/dist/esm/lib/worker-farm/worker-thread.js +3 -3
  57. package/dist/esm/lib/worker-farm/worker-thread.js.map +1 -1
  58. package/dist/esm/lib/worker-utils/get-loadable-worker-url.js +1 -7
  59. package/dist/esm/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
  60. package/dist/index.d.ts +19 -0
  61. package/dist/lib/async-queue/async-queue.d.ts +31 -0
  62. package/dist/lib/env-utils/assert.d.ts +2 -0
  63. package/dist/lib/env-utils/globals.d.ts +21 -0
  64. package/dist/lib/env-utils/version.d.ts +1 -0
  65. package/dist/lib/library-utils/library-utils.d.ts +17 -0
  66. package/dist/lib/node/require-utils.node.d.ts +2 -0
  67. package/dist/lib/process-utils/child-process-proxy.d.ts +42 -0
  68. package/dist/lib/process-utils/process-utils.d.ts +1 -0
  69. package/dist/lib/worker-api/create-worker.d.ts +8 -0
  70. package/dist/lib/worker-api/get-worker-url.d.ts +13 -0
  71. package/dist/lib/worker-api/process-on-worker.d.ts +19 -0
  72. package/dist/lib/worker-api/validate-worker-version.d.ts +8 -0
  73. package/dist/lib/worker-farm/worker-body.d.ts +15 -0
  74. package/dist/lib/worker-farm/worker-farm.d.ts +54 -0
  75. package/dist/lib/worker-farm/worker-job.d.ts +28 -0
  76. package/dist/lib/worker-farm/worker-pool.d.ts +74 -0
  77. package/dist/lib/worker-farm/worker-thread.d.ts +41 -0
  78. package/dist/lib/worker-utils/get-loadable-worker-url.d.ts +13 -0
  79. package/dist/lib/worker-utils/get-transfer-list.d.ts +9 -0
  80. package/dist/lib/worker-utils/remove-nontransferable-options.d.ts +5 -0
  81. package/dist/null-worker.js +3 -3
  82. package/dist/null-worker.js.map +1 -1
  83. package/dist/types.d.ts +55 -0
  84. package/dist/workers/null-worker.d.ts +1 -0
  85. package/package.json +4 -3
@@ -37,12 +37,6 @@ function getLoadableWorkerURLFromSource(workerSource) {
37
37
  }
38
38
 
39
39
  function buildScriptSource(workerUrl) {
40
- return `\
41
- try {
42
- importScripts('${workerUrl}');
43
- } catch (error) {
44
- console.error(error);
45
- throw error;
46
- }`;
40
+ return "try {\n importScripts('".concat(workerUrl, "');\n} catch (error) {\n console.error(error);\n throw error;\n}");
47
41
  }
48
42
  //# sourceMappingURL=get-loadable-worker-url.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/worker-utils/get-loadable-worker-url.ts"],"names":["assert","workerURLCache","Map","getLoadableWorkerURL","props","source","url","workerURL","get","getLoadableWorkerURLFromURL","set","getLoadableWorkerURLFromSource","startsWith","workerSource","buildScriptSource","blob","Blob","type","URL","createObjectURL","workerUrl"],"mappings":"AAAA,SAAQA,MAAR,QAAqB,qBAArB;AAEA,MAAMC,cAAc,GAAG,IAAIC,GAAJ,EAAvB;AAWA,OAAO,SAASC,oBAAT,CAA8BC,KAA9B,EAAsE;AAC3EJ,EAAAA,MAAM,CAAEI,KAAK,CAACC,MAAN,IAAgB,CAACD,KAAK,CAACE,GAAxB,IAAiC,CAACF,KAAK,CAACC,MAAP,IAAiBD,KAAK,CAACE,GAAzD,CAAN;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;;AAEDP,EAAAA,MAAM,CAACO,SAAD,CAAN;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,QAAMO,YAAY,GAAGC,iBAAiB,CAACR,GAAD,CAAtC;AACA,SAAOK,8BAA8B,CAACE,YAAD,CAArC;AACD;;AAOD,SAASF,8BAAT,CAAwCE,YAAxC,EAAsE;AAGpE,QAAME,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,SAAQ;AACV;AACA,mBAAmBA,SAAU;AAC7B;AACA;AACA;AACA,EANE;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
+ {"version":3,"sources":["../../../../src/lib/worker-utils/get-loadable-worker-url.ts"],"names":["assert","workerURLCache","Map","getLoadableWorkerURL","props","source","url","workerURL","get","getLoadableWorkerURLFromURL","set","getLoadableWorkerURLFromSource","startsWith","workerSource","buildScriptSource","blob","Blob","type","URL","createObjectURL","workerUrl"],"mappings":"AAAA,SAAQA,MAAR,QAAqB,qBAArB;AAEA,MAAMC,cAAc,GAAG,IAAIC,GAAJ,EAAvB;AAWA,OAAO,SAASC,oBAAT,CAA8BC,KAA9B,EAAsE;AAC3EJ,EAAAA,MAAM,CAAEI,KAAK,CAACC,MAAN,IAAgB,CAACD,KAAK,CAACE,GAAxB,IAAiC,CAACF,KAAK,CAACC,MAAP,IAAiBD,KAAK,CAACE,GAAzD,CAAN;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;;AAEDP,EAAAA,MAAM,CAACO,SAAD,CAAN;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,QAAMO,YAAY,GAAGC,iBAAiB,CAACR,GAAD,CAAtC;AACA,SAAOK,8BAA8B,CAACE,YAAD,CAArC;AACD;;AAOD,SAASF,8BAAT,CAAwCE,YAAxC,EAAsE;AAGpE,QAAME,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"}
@@ -0,0 +1,19 @@
1
+ import type { WorkerObject } from './types';
2
+ export type { WorkerObject, WorkerOptions, WorkerMessage, WorkerMessageType, WorkerMessageData, WorkerMessagePayload } from './types';
3
+ export { assert } from './lib/env-utils/assert';
4
+ export { isBrowser, isWorker } from './lib/env-utils/globals';
5
+ export { default as WorkerJob } from './lib/worker-farm/worker-job';
6
+ export { default as WorkerThread } from './lib/worker-farm/worker-thread';
7
+ export { default as WorkerFarm } from './lib/worker-farm/worker-farm';
8
+ export { default as WorkerPool } from './lib/worker-farm/worker-pool';
9
+ export { default as WorkerBody } from './lib/worker-farm/worker-body';
10
+ export { processOnWorker, canProcessOnWorker } from './lib/worker-api/process-on-worker';
11
+ export { createWorker } from './lib/worker-api/create-worker';
12
+ export { getWorkerURL } from './lib/worker-api/get-worker-url';
13
+ export { validateWorkerVersion } from './lib/worker-api/validate-worker-version';
14
+ export { getTransferList } from './lib/worker-utils/get-transfer-list';
15
+ export { getLibraryUrl, loadLibrary } from './lib/library-utils/library-utils';
16
+ export { default as AsyncQueue } from './lib/async-queue/async-queue';
17
+ export { default as ChildProcessProxy } from './lib/process-utils/child-process-proxy';
18
+ /** A null worker to test that worker processing is functional */
19
+ export declare const NullWorker: WorkerObject;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Async Queue
3
+ * - AsyncIterable: An async iterator can be
4
+ * - Values can be pushed onto the queue
5
+ * @example
6
+ * const asyncQueue = new AsyncQueue();
7
+ * setTimeout(() => asyncQueue.enqueue('tick'), 1000);
8
+ * setTimeout(() => asyncQueue.enqueue(new Error('done')), 10000);
9
+ * for await (const value of asyncQueue) {
10
+ * console.log(value); // tick
11
+ * }
12
+ */
13
+ export default class AsyncQueue<T> {
14
+ private _values;
15
+ private _settlers;
16
+ private _closed;
17
+ constructor();
18
+ /** Return an async iterator for this queue */
19
+ [Symbol.asyncIterator](): AsyncIterator<T>;
20
+ /** Push a new value - the async iterator will yield a promise resolved to this value */
21
+ push(value: T): void;
22
+ /**
23
+ * Push a new value - the async iterator will yield a promise resolved to this value
24
+ * Add an error - the async iterator will yield a promise rejected with this value
25
+ */
26
+ enqueue(value: T | Error): void;
27
+ /** Indicate that we not waiting for more values - The async iterator will be done */
28
+ close(): void;
29
+ /** @returns a Promise for an IteratorResult */
30
+ next(): Promise<IteratorResult<T, any>>;
31
+ }
@@ -0,0 +1,2 @@
1
+ /** Throws an `Error` with the optional `message` if `condition` is falsy */
2
+ export declare function assert(condition: any, message?: string): void;
@@ -0,0 +1,21 @@
1
+ declare const self_: {
2
+ [key: string]: any;
3
+ };
4
+ declare const window_: {
5
+ [key: string]: any;
6
+ };
7
+ declare const global_: {
8
+ [key: string]: any;
9
+ };
10
+ declare const document_: {
11
+ [key: string]: any;
12
+ };
13
+ export { self_ as self, window_ as window, global_ as global, document_ as document };
14
+ /** true if running in the browser, false if running in Node.js */
15
+ export declare const isBrowser: boolean;
16
+ /** true if running on a worker thread */
17
+ export declare const isWorker: boolean;
18
+ /** true if running on a mobile device */
19
+ export declare const isMobile: boolean;
20
+ /** Version of Node.js if running under Node, otherwise 0 */
21
+ export declare const nodeVersion: number;
@@ -0,0 +1 @@
1
+ export declare const VERSION: any;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Dynamically loads a library ("module")
3
+ *
4
+ * - wasm library: Array buffer is returned
5
+ * - js library: Parse JS is returned
6
+ *
7
+ * Method depends on environment
8
+ * - browser - script element is created and installed on document
9
+ * - worker - eval is called on global context
10
+ * - node - file is required
11
+ *
12
+ * @param libraryUrl
13
+ * @param moduleName
14
+ * @param options
15
+ */
16
+ export declare function loadLibrary(libraryUrl: string, moduleName?: string | null, options?: object): Promise<any>;
17
+ export declare function getLibraryUrl(library: any, moduleName?: string, options?: any): string;
@@ -0,0 +1,2 @@
1
+ export function requireFromFile(filename: any): Promise<any>;
2
+ export function requireFromString(code: any, filename?: string, options?: {}): any;
@@ -0,0 +1,42 @@
1
+ /// <reference types="node" />
2
+ import * as ChildProcess from 'child_process';
3
+ export declare type ChildProcessProxyProps = {
4
+ command: string;
5
+ arguments: string[];
6
+ /** Whether to add a port specified arg */
7
+ portArg?: string;
8
+ /** Base port number */
9
+ port?: number;
10
+ /** Whether to search for an available port if the base port is occupied */
11
+ autoPort?: boolean;
12
+ /** Number of milliseconds to wait until concluding success */
13
+ /** wait: 0 - infinity */
14
+ wait?: number;
15
+ /** Options passed on to Node'.js `spawn` */
16
+ spawn?: ChildProcess.SpawnOptionsWithoutStdio;
17
+ /** Callback when the */
18
+ onStart?: (proxy: ChildProcessProxy) => void;
19
+ onSuccess?: (proxy: ChildProcessProxy) => void;
20
+ };
21
+ /**
22
+ * Manager for a Node.js child process
23
+ * Prepares arguments, starts, stops and tracks output
24
+ */
25
+ export default class ChildProcessProxy {
26
+ id: string;
27
+ props: ChildProcessProxyProps;
28
+ private childProcess;
29
+ private port;
30
+ private successTimer?;
31
+ constructor({ id }?: {
32
+ id?: string | undefined;
33
+ });
34
+ /** Starts a child process with the provided props */
35
+ start(props: ChildProcessProxyProps): Promise<object>;
36
+ /** Stops a running child process */
37
+ stop(): Promise<void>;
38
+ /** Exits this process */
39
+ exit(statusCode?: number): Promise<void>;
40
+ _setTimeout(callback: (...args: any[]) => void): void;
41
+ _clearTimeout(): void;
42
+ }
@@ -0,0 +1 @@
1
+ export declare function getAvailablePort(defaultPort?: number): Promise<number>;
@@ -0,0 +1,8 @@
1
+ import type { Process, ProcessInBatches } from '../../types';
2
+ export declare type ProcessOnMainThread = (data: any, options?: {
3
+ [key: string]: any;
4
+ }, context?: any) => any;
5
+ /**
6
+ * Set up a WebWorkerGlobalScope to talk with the main thread
7
+ */
8
+ export declare function createWorker(process: Process, processInBatches?: ProcessInBatches): void;
@@ -0,0 +1,13 @@
1
+ import type { WorkerObject, WorkerOptions } from '../../types';
2
+ /**
3
+ * Gets worker object's name (for debugging in Chrome thread inspector window)
4
+ */
5
+ export declare function getWorkerName(worker: WorkerObject): string;
6
+ /**
7
+ * Generate a worker URL based on worker object and options
8
+ * @returns A URL to one of the following:
9
+ * - a published worker on unpkg CDN
10
+ * - a local test worker
11
+ * - a URL provided by the user in options
12
+ */
13
+ export declare function getWorkerURL(worker: WorkerObject, options?: WorkerOptions): string;
@@ -0,0 +1,19 @@
1
+ import type { WorkerObject, WorkerOptions, WorkerContext } from '../../types';
2
+ declare type ProcessOnWorkerOptions = WorkerOptions & {
3
+ jobName?: string;
4
+ [key: string]: any;
5
+ };
6
+ /**
7
+ * Determines if we can parse with worker
8
+ * @param loader
9
+ * @param data
10
+ * @param options
11
+ */
12
+ export declare function canProcessOnWorker(worker: WorkerObject, options?: WorkerOptions): boolean | "" | undefined;
13
+ /**
14
+ * This function expects that the worker thread sends certain messages,
15
+ * Creating such a worker can be automated if the worker is wrapper by a call to
16
+ * createWorker in @loaders.gl/worker-utils.
17
+ */
18
+ export declare function processOnWorker(worker: WorkerObject, data: any, options?: ProcessOnWorkerOptions, context?: WorkerContext): Promise<any>;
19
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { WorkerObject } from '../../types';
2
+ /**
3
+ * Check if worker is compatible with this library version
4
+ * @param worker
5
+ * @param libVersion
6
+ * @returns `true` if the two versions are compatible
7
+ */
8
+ export declare function validateWorkerVersion(worker: WorkerObject, coreVersion?: string): boolean;
@@ -0,0 +1,15 @@
1
+ import type { WorkerMessageType, WorkerMessagePayload } from '../../types';
2
+ /**
3
+ * Type safe wrapper for worker code
4
+ */
5
+ export default class WorkerBody {
6
+ static set onmessage(onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any);
7
+ static addEventListener(onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any): void;
8
+ static removeEventListener(onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any): void;
9
+ /**
10
+ * Send a message from a worker to creating thread (main thread)
11
+ * @param type
12
+ * @param payload
13
+ */
14
+ static postMessage(type: WorkerMessageType, payload: WorkerMessagePayload): void;
15
+ }
@@ -0,0 +1,54 @@
1
+ import WorkerPool from './worker-pool';
2
+ /**
3
+ * @param maxConcurrency {number} - max count of workers
4
+ */
5
+ export declare type WorkerFarmProps = {
6
+ maxConcurrency?: number;
7
+ maxMobileConcurrency?: number;
8
+ reuseWorkers?: boolean;
9
+ onDebug?: () => void;
10
+ };
11
+ /**
12
+ * Process multiple jobs with a "farm" of different workers in worker pools.
13
+ */
14
+ export default class WorkerFarm {
15
+ private props;
16
+ private workerPools;
17
+ private static _workerFarm?;
18
+ /** Check if Workers are supported */
19
+ static isSupported(): boolean;
20
+ /** Get the singleton instance of the global worker farm */
21
+ static getWorkerFarm(props?: WorkerFarmProps): WorkerFarm;
22
+ /** get global instance with WorkerFarm.getWorkerFarm() */
23
+ private constructor();
24
+ /**
25
+ * Terminate all workers in the farm
26
+ * @note Can free up significant memory
27
+ */
28
+ destroy(): void;
29
+ /**
30
+ * Set props used when initializing worker pools
31
+ * @param props
32
+ */
33
+ setProps(props: WorkerFarmProps): void;
34
+ /**
35
+ * Returns a worker pool for the specified worker
36
+ * @param options - only used first time for a specific worker name
37
+ * @param options.name - the name of the worker - used to identify worker pool
38
+ * @param options.url -
39
+ * @param options.source -
40
+ * @example
41
+ * const job = WorkerFarm.getWorkerFarm().getWorkerPool({name, url}).startJob(...);
42
+ */
43
+ getWorkerPool(options: {
44
+ name: string;
45
+ source?: string;
46
+ url?: string;
47
+ }): WorkerPool;
48
+ _getWorkerPoolProps(): {
49
+ maxConcurrency: number | undefined;
50
+ maxMobileConcurrency: number | undefined;
51
+ reuseWorkers: boolean | undefined;
52
+ onDebug: (() => void) | undefined;
53
+ };
54
+ }
@@ -0,0 +1,28 @@
1
+ import type { WorkerMessageType, WorkerMessagePayload } from '../../types';
2
+ import WorkerThread from './worker-thread';
3
+ /**
4
+ * Represents one Job handled by a WorkerPool or WorkerFarm
5
+ */
6
+ export default class WorkerJob {
7
+ readonly name: string;
8
+ readonly workerThread: WorkerThread;
9
+ isRunning: boolean;
10
+ /** Promise that resolves when Job is done */
11
+ readonly result: Promise<any>;
12
+ private _resolve;
13
+ private _reject;
14
+ constructor(jobName: string, workerThread: WorkerThread);
15
+ /**
16
+ * Send a message to the job's worker thread
17
+ * @param data any data structure, ideally consisting mostly of transferrable objects
18
+ */
19
+ postMessage(type: WorkerMessageType, payload: WorkerMessagePayload): void;
20
+ /**
21
+ * Call to resolve the `result` Promise with the supplied value
22
+ */
23
+ done(value: any): void;
24
+ /**
25
+ * Call to reject the `result` Promise with the supplied error
26
+ */
27
+ error(error: any): void;
28
+ }
@@ -0,0 +1,74 @@
1
+ import type { WorkerMessageType, WorkerMessagePayload } from '../../types';
2
+ import WorkerThread from './worker-thread';
3
+ import WorkerJob from './worker-job';
4
+ /** WorkerPool onDebug Callback Parameters */
5
+ declare type OnDebugParameters = {
6
+ message: string;
7
+ worker: string;
8
+ name: string;
9
+ job: string;
10
+ backlog: number;
11
+ workerThread: WorkerThread;
12
+ };
13
+ /** WorkerPool Properties */
14
+ export declare type WorkerPoolProps = {
15
+ name?: string;
16
+ source?: string;
17
+ url?: string;
18
+ maxConcurrency?: number;
19
+ maxMobileConcurrency?: number;
20
+ onDebug?: (options: OnDebugParameters) => any;
21
+ reuseWorkers?: boolean;
22
+ };
23
+ /** Private helper types */
24
+ declare type OnMessage = (job: WorkerJob, type: WorkerMessageType, payload: WorkerMessagePayload) => void;
25
+ declare type OnError = (job: WorkerJob, error: Error) => void;
26
+ /**
27
+ * Process multiple data messages with small pool of identical workers
28
+ */
29
+ export default class WorkerPool {
30
+ name: string;
31
+ source?: string;
32
+ url?: string;
33
+ maxConcurrency: number;
34
+ maxMobileConcurrency: number;
35
+ onDebug: (options: OnDebugParameters) => any;
36
+ reuseWorkers: boolean;
37
+ private props;
38
+ private jobQueue;
39
+ private idleQueue;
40
+ private count;
41
+ private isDestroyed;
42
+ /**
43
+ * @param processor - worker function
44
+ * @param maxConcurrency - max count of workers
45
+ */
46
+ constructor(props: WorkerPoolProps);
47
+ /**
48
+ * Terminates all workers in the pool
49
+ * @note Can free up significant memory
50
+ */
51
+ destroy(): void;
52
+ setProps(props: WorkerPoolProps): void;
53
+ startJob(name: string, onMessage?: OnMessage, onError?: OnError): Promise<WorkerJob>;
54
+ /**
55
+ * Starts first queued job if worker is available or can be created
56
+ * Called when job is started and whenever a worker returns to the idleQueue
57
+ */
58
+ _startQueuedJob(): Promise<void>;
59
+ /**
60
+ * Returns a worker to the idle queue
61
+ * Destroys the worker if
62
+ * - pool is destroyed
63
+ * - if this pool doesn't reuse workers
64
+ * - if maxConcurrency has been lowered
65
+ * @param worker
66
+ */
67
+ returnWorkerToQueue(worker: WorkerThread): void;
68
+ /**
69
+ * Returns idle worker or creates new worker if maxConcurrency has not been reached
70
+ */
71
+ _getAvailableWorker(): WorkerThread | null;
72
+ _getMaxConcurrency(): number;
73
+ }
74
+ export {};
@@ -0,0 +1,41 @@
1
+ export declare type WorkerThreadProps = {
2
+ name: string;
3
+ source?: string;
4
+ url?: string;
5
+ };
6
+ /**
7
+ * Represents one worker thread
8
+ */
9
+ export default class WorkerThread {
10
+ readonly name: string;
11
+ readonly source: string | undefined;
12
+ readonly url: string | undefined;
13
+ terminated: boolean;
14
+ worker: Worker;
15
+ onMessage: (message: any) => void;
16
+ onError: (error: Error) => void;
17
+ private _loadableURL;
18
+ static isSupported(): boolean;
19
+ constructor(props: WorkerThreadProps);
20
+ /**
21
+ * Terminate this worker thread
22
+ * @note Can free up significant memory
23
+ */
24
+ destroy(): void;
25
+ get isRunning(): boolean;
26
+ /**
27
+ * Send a message to this worker thread
28
+ * @param data any data structure, ideally consisting mostly of transferrable objects
29
+ * @param transferList If not supplied, calculated automatically by traversing data
30
+ */
31
+ postMessage(data: any, transferList?: any[]): void;
32
+ /**
33
+ * Generate a standard Error from an ErrorEvent
34
+ * @param {ErrorEvent} event
35
+ */
36
+ _getErrorFromErrorEvent(event: any): Error;
37
+ /**
38
+ * Creates a worker thread on the browser
39
+ */
40
+ _createBrowserWorker(): Worker;
41
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Creates a loadable URL from worker source or URL
3
+ * that can be used to create `Worker` instances.
4
+ * Due to CORS issues it may be necessary to wrap a URL in a small importScripts
5
+ * @param props
6
+ * @param props.source Worker source
7
+ * @param props.url Worker URL
8
+ * @returns loadable url
9
+ */
10
+ export declare function getLoadableWorkerURL(props: {
11
+ source?: string;
12
+ url?: string;
13
+ }): any;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns an array of Transferrable objects that can be used with postMessage
3
+ * https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage
4
+ * @param object data to be sent via postMessage
5
+ * @param recursive - not for application use
6
+ * @param transfers - not for application use
7
+ * @returns a transfer list that can be passed to postMessage
8
+ */
9
+ export declare function getTransferList(object: any, recursive?: boolean, transfers?: Set<any>): Transferable[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Safely stringify JSON (drop non serializable values like functions and regexps)
3
+ * @param value
4
+ */
5
+ export declare function removeNontransferableOptions(object: object): object;
@@ -87,9 +87,9 @@
87
87
  /******/ ({
88
88
 
89
89
  /***/ "../../node_modules/@babel/runtime/helpers/defineProperty.js":
90
- /*!****************************************************************************************!*\
91
- !*** /home/user/apps/loaders.gl/node_modules/@babel/runtime/helpers/defineProperty.js ***!
92
- \****************************************************************************************/
90
+ /*!**************************************************************************************************!*\
91
+ !*** /home/user/apps/loaders.gl_duplicate/node_modules/@babel/runtime/helpers/defineProperty.js ***!
92
+ \**************************************************************************************************/
93
93
  /*! no static exports found */
94
94
  /***/ (function(module, exports) {
95
95
 
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:////home/user/apps/loaders.gl/node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/lib/async-queue/async-queue.ts","webpack:///./src/lib/worker-api/create-worker.ts","webpack:///./src/lib/worker-farm/worker-body.ts","webpack:///./src/lib/worker-utils/get-transfer-list.ts","webpack:///./src/workers/null-worker.ts"],"names":["Symbol","asyncIterator","AsyncQueue","constructor","_values","_settlers","_closed","push","value","enqueue","Error","length","settler","shift","reject","resolve","close","done","next","Promise","undefined","requestId","inputBatches","options","createWorker","process","processInBatches","self","context","processOnMainThread","WorkerBody","onmessage","type","payload","result","input","postMessage","resultIterator","batch","error","message","arrayBuffer","id","onMessage","removeEventListener","addEventListener","onMessageWrapperMap","Map","isKnownMessage","data","onMessageWrapper","get","delete","source","transferList","getTransferList","startsWith","object","recursive","transfers","transfersSet","Set","isTransferable","add","buffer","ArrayBuffer","isView","key","Array","from","MessagePort","ImageBitmap","OffscreenCanvas"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;Q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zB,CAAf;AACD;AACF,GAnBe,CAqBhB;AACA;;;AACA,SAAOD,SAAS,KAAKvC,SAAd,GAA0BgD,KAAK,CAACC,IAAN,CAAWT,YAAX,CAA1B,GAAqD,EAA5D;AACD,C,CAED;;AACA,SAASE,cAAT,CAAwBL,MAAxB,EAAgC;AAC9B,MAAI,CAACA,MAAL,EAAa;AACX,WAAO,KAAP;AACD;;AACD,MAAIA,MAAM,YAAYQ,WAAtB,EAAmC;AACjC,WAAO,IAAP;AACD;;AACD,MAAI,OAAOK,WAAP,KAAuB,WAAvB,IAAsCb,MAAM,YAAYa,WAA5D,EAAyE;AACvE,WAAO,IAAP;AACD;;AACD,MAAI,OAAOC,WAAP,KAAuB,WAAvB,IAAsCd,MAAM,YAAYc,WAA5D,EAAyE;AACvE,WAAO,IAAP;AACD,GAZ6B,CAa9B;;;AACA,MAAI,OAAOC,eAAP,KAA2B,WAA3B,IAA0Cf,MAAM,YAAYe,eAAhE,EAAiF;AAC/E,WAAO,IAAP;AACD;;AACD,SAAO,KAAP;AACD,C;;;;;;;;;;;;AC5DD;AAAA;AAAA;AAEAhD,kFAAY,CAAC,MAAOyB,IAAP,IAAgB;AAC3B;AACA,SAAOA,IAAP;AACD,CAHW,CAAZ,C","file":"null-worker.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/workers/null-worker.ts\");\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","// From https://github.com/rauschma/async-iter-demo/tree/master/src under MIT license\n// http://2ality.com/2016/10/asynchronous-iteration.html\n\n/**\n * Async Queue\n * - AsyncIterable: An async iterator can be\n * - Values can be pushed onto the queue\n * @example\n * const asyncQueue = new AsyncQueue();\n * setTimeout(() => asyncQueue.enqueue('tick'), 1000);\n * setTimeout(() => asyncQueue.enqueue(new Error('done')), 10000);\n * for await (const value of asyncQueue) {\n * console.log(value); // tick\n * }\n */\nexport default class AsyncQueue<T> {\n private _values: any[];\n private _settlers: any[];\n private _closed: boolean;\n\n constructor() {\n this._values = []; // enqueues > dequeues\n this._settlers = []; // dequeues > enqueues\n this._closed = false;\n }\n\n /** Return an async iterator for this queue */\n [Symbol.asyncIterator](): AsyncIterator<T> {\n return this;\n }\n\n /** Push a new value - the async iterator will yield a promise resolved to this value */\n push(value: T): void {\n return this.enqueue(value);\n }\n\n /**\n * Push a new value - the async iterator will yield a promise resolved to this value\n * Add an error - the async iterator will yield a promise rejected with this value\n */\n enqueue(value: T | Error): void {\n if (this._closed) {\n throw new Error('Closed');\n }\n\n if (this._settlers.length > 0) {\n if (this._values.length > 0) {\n throw new Error('Illegal internal state');\n }\n const settler = this._settlers.shift();\n if (value instanceof Error) {\n settler.reject(value);\n } else {\n settler.resolve({value});\n }\n } else {\n this._values.push(value);\n }\n }\n\n /** Indicate that we not waiting for more values - The async iterator will be done */\n close(): void {\n while (this._settlers.length > 0) {\n const settler = this._settlers.shift();\n settler.resolve({done: true});\n }\n this._closed = true;\n }\n\n // ITERATOR IMPLEMENTATION\n\n /** @returns a Promise for an IteratorResult */\n next(): Promise<IteratorResult<T, any>> {\n // If values in queue, yield the first value\n if (this._values.length > 0) {\n const value = this._values.shift();\n if (value instanceof Error) {\n return Promise.reject(value);\n }\n return Promise.resolve({done: false, value});\n }\n\n // If queue is closed, the iterator is done\n if (this._closed) {\n if (this._settlers.length > 0) {\n throw new Error('Illegal internal state');\n }\n return Promise.resolve({done: true, value: undefined});\n }\n\n // Yield a promise that waits for new values to be enqueued\n return new Promise((resolve, reject) => {\n this._settlers.push({resolve, reject});\n });\n }\n}\n","import type {\n WorkerMessageType,\n WorkerMessagePayload,\n WorkerContext,\n Process,\n ProcessInBatches\n} from '../../types';\nimport AsyncQueue from '../async-queue/async-queue';\nimport WorkerBody from '../worker-farm/worker-body';\n// import {validateWorkerVersion} from './validate-worker-version';\n\n/** Counter for jobs */\nlet requestId = 0;\nlet inputBatches;\nlet options;\n\nexport type ProcessOnMainThread = (data: any, options?: {[key: string]: any}, context?) => any;\n\n/**\n * Set up a WebWorkerGlobalScope to talk with the main thread\n */\nexport function createWorker(process: Process, processInBatches?: ProcessInBatches): void {\n // Check that we are actually in a worker thread\n if (typeof self === 'undefined') {\n return;\n }\n\n const context: WorkerContext = {\n process: processOnMainThread\n };\n\n // eslint-disable-next-line complexity\n WorkerBody.onmessage = async (type: WorkerMessageType, payload: WorkerMessagePayload) => {\n try {\n switch (type) {\n case 'process':\n if (!process) {\n throw new Error('Worker does not support atomic processing');\n }\n const result = await process(payload.input, payload.options || {}, context);\n WorkerBody.postMessage('done', {result});\n break;\n\n case 'process-in-batches':\n if (!processInBatches) {\n throw new Error('Worker does not support batched processing');\n }\n inputBatches = new AsyncQueue();\n options = payload.options || {};\n const resultIterator = processInBatches(inputBatches, options, context?.processInBatches);\n for await (const batch of resultIterator) {\n WorkerBody.postMessage('output-batch', {result: batch});\n }\n WorkerBody.postMessage('done', {});\n break;\n\n case 'input-batch':\n inputBatches.push(payload.input);\n break;\n\n case 'input-done':\n inputBatches.close();\n break;\n\n default:\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n };\n}\n\nfunction processOnMainThread(arrayBuffer, options = {}) {\n return new Promise((resolve, reject) => {\n const id = requestId++;\n\n /**\n */\n const onMessage = (type, payload) => {\n if (payload.id !== id) {\n // not ours\n return;\n }\n\n switch (type) {\n case 'done':\n WorkerBody.removeEventListener(onMessage);\n resolve(payload.result);\n break;\n\n case 'error':\n WorkerBody.removeEventListener(onMessage);\n reject(payload.error);\n break;\n\n default:\n // ignore\n }\n };\n\n WorkerBody.addEventListener(onMessage);\n\n // Ask the main thread to decode data\n const payload = {id, input: arrayBuffer, options};\n WorkerBody.postMessage('process', payload);\n });\n}\n","import type {WorkerMessageData, WorkerMessageType, WorkerMessagePayload} from '../../types';\nimport {getTransferList} from '../worker-utils/get-transfer-list';\n\nconst onMessageWrapperMap = new Map();\n\n/**\n * Type safe wrapper for worker code\n */\nexport default class WorkerBody {\n /*\n * (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n */\n static set onmessage(onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any) {\n // eslint-disable-next-line no-restricted-globals\n self.onmessage = (message) => {\n if (!isKnownMessage(message)) {\n return;\n }\n\n // Confusingly the message itself also has a 'type' field which is always set to 'message'\n const {type, payload} = message.data;\n onMessage(type, payload);\n };\n }\n\n static addEventListener(\n onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n ) {\n let onMessageWrapper = onMessageWrapperMap.get(onMessage);\n\n if (!onMessageWrapper) {\n onMessageWrapper = (message) => {\n if (!isKnownMessage(message)) {\n return;\n }\n\n // Confusingly the message itself also has a 'type' field which is always set to 'message'\n const {type, payload} = message.data;\n onMessage(type, payload);\n };\n }\n\n // eslint-disable-next-line no-restricted-globals\n self.addEventListener('message', onMessageWrapper);\n }\n\n static removeEventListener(\n onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n ) {\n const onMessageWrapper = onMessageWrapperMap.get(onMessage);\n onMessageWrapperMap.delete(onMessage);\n // eslint-disable-next-line no-restricted-globals\n self.removeEventListener('message', onMessageWrapper);\n }\n\n /**\n * Send a message from a worker to creating thread (main thread)\n * @param type\n * @param payload\n */\n static postMessage(type: WorkerMessageType, payload: WorkerMessagePayload): void {\n if (self) {\n const data: WorkerMessageData = {source: 'loaders.gl', type, payload};\n const transferList = getTransferList(payload);\n // eslint-disable-next-line no-restricted-globals\n // @ts-ignore\n self.postMessage(data, transferList);\n }\n }\n}\n\n// Filter out noise messages sent to workers\nfunction isKnownMessage(message) {\n const {type, data} = message;\n return (\n type === 'message' &&\n data &&\n typeof data.source === 'string' &&\n data.source.startsWith('loaders.gl')\n );\n}\n","// 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) {\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","import {createWorker} from '../lib/worker-api/create-worker';\n\ncreateWorker(async (data) => {\n // @ts-ignore\n return data;\n});\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:////home/user/apps/loaders.gl_duplicate/node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/lib/async-queue/async-queue.ts","webpack:///./src/lib/worker-api/create-worker.ts","webpack:///./src/lib/worker-farm/worker-body.ts","webpack:///./src/lib/worker-utils/get-transfer-list.ts","webpack:///./src/workers/null-worker.ts"],"names":["Symbol","asyncIterator","AsyncQueue","constructor","_values","_settlers","_closed","push","value","enqueue","Error","length","settler","shift","reject","resolve","close","done","next","Promise","undefined","requestId","inputBatches","options","createWorker","process","processInBatches","self","context","processOnMainThread","WorkerBody","onmessage","type","payload","result","input","postMessage","resultIterator","batch","error","message","arrayBuffer","id","onMessage","removeEventListener","addEventListener","onMessageWrapperMap","Map","isKnownMessage","data","onMessageWrapper","get","delete","source","transferList","getTransferList","startsWith","object","recursive","transfers","transfersSet","Set","isTransferable","add","buffer","ArrayBuffer","isView","key","Array","from","MessagePort","ImageBitmap","OffscreenCanvas"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,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AAT,CAAwBL,MAAxB,EAAgC;AAC9B,MAAI,CAACA,MAAL,EAAa;AACX,WAAO,KAAP;AACD;;AACD,MAAIA,MAAM,YAAYQ,WAAtB,EAAmC;AACjC,WAAO,IAAP;AACD;;AACD,MAAI,OAAOK,WAAP,KAAuB,WAAvB,IAAsCb,MAAM,YAAYa,WAA5D,EAAyE;AACvE,WAAO,IAAP;AACD;;AACD,MAAI,OAAOC,WAAP,KAAuB,WAAvB,IAAsCd,MAAM,YAAYc,WAA5D,EAAyE;AACvE,WAAO,IAAP;AACD,GAZ6B,CAa9B;;;AACA,MAAI,OAAOC,eAAP,KAA2B,WAA3B,IAA0Cf,MAAM,YAAYe,eAAhE,EAAiF;AAC/E,WAAO,IAAP;AACD;;AACD,SAAO,KAAP;AACD,C;;;;;;;;;;;;AC5DD;AAAA;AAAA;AAEAhD,kFAAY,CAAC,MAAOyB,IAAP,IAAgB;AAC3B;AACA,SAAOA,IAAP;AACD,CAHW,CAAZ,C","file":"null-worker.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/workers/null-worker.ts\");\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","// From https://github.com/rauschma/async-iter-demo/tree/master/src under MIT license\n// http://2ality.com/2016/10/asynchronous-iteration.html\n\n/**\n * Async Queue\n * - AsyncIterable: An async iterator can be\n * - Values can be pushed onto the queue\n * @example\n * const asyncQueue = new AsyncQueue();\n * setTimeout(() => asyncQueue.enqueue('tick'), 1000);\n * setTimeout(() => asyncQueue.enqueue(new Error('done')), 10000);\n * for await (const value of asyncQueue) {\n * console.log(value); // tick\n * }\n */\nexport default class AsyncQueue<T> {\n private _values: any[];\n private _settlers: any[];\n private _closed: boolean;\n\n constructor() {\n this._values = []; // enqueues > dequeues\n this._settlers = []; // dequeues > enqueues\n this._closed = false;\n }\n\n /** Return an async iterator for this queue */\n [Symbol.asyncIterator](): AsyncIterator<T> {\n return this;\n }\n\n /** Push a new value - the async iterator will yield a promise resolved to this value */\n push(value: T): void {\n return this.enqueue(value);\n }\n\n /**\n * Push a new value - the async iterator will yield a promise resolved to this value\n * Add an error - the async iterator will yield a promise rejected with this value\n */\n enqueue(value: T | Error): void {\n if (this._closed) {\n throw new Error('Closed');\n }\n\n if (this._settlers.length > 0) {\n if (this._values.length > 0) {\n throw new Error('Illegal internal state');\n }\n const settler = this._settlers.shift();\n if (value instanceof Error) {\n settler.reject(value);\n } else {\n settler.resolve({value});\n }\n } else {\n this._values.push(value);\n }\n }\n\n /** Indicate that we not waiting for more values - The async iterator will be done */\n close(): void {\n while (this._settlers.length > 0) {\n const settler = this._settlers.shift();\n settler.resolve({done: true});\n }\n this._closed = true;\n }\n\n // ITERATOR IMPLEMENTATION\n\n /** @returns a Promise for an IteratorResult */\n next(): Promise<IteratorResult<T, any>> {\n // If values in queue, yield the first value\n if (this._values.length > 0) {\n const value = this._values.shift();\n if (value instanceof Error) {\n return Promise.reject(value);\n }\n return Promise.resolve({done: false, value});\n }\n\n // If queue is closed, the iterator is done\n if (this._closed) {\n if (this._settlers.length > 0) {\n throw new Error('Illegal internal state');\n }\n return Promise.resolve({done: true, value: undefined});\n }\n\n // Yield a promise that waits for new values to be enqueued\n return new Promise((resolve, reject) => {\n this._settlers.push({resolve, reject});\n });\n }\n}\n","import type {\n WorkerMessageType,\n WorkerMessagePayload,\n WorkerContext,\n Process,\n ProcessInBatches\n} from '../../types';\nimport AsyncQueue from '../async-queue/async-queue';\nimport WorkerBody from '../worker-farm/worker-body';\n// import {validateWorkerVersion} from './validate-worker-version';\n\n/** Counter for jobs */\nlet requestId = 0;\nlet inputBatches;\nlet options;\n\nexport type ProcessOnMainThread = (data: any, options?: {[key: string]: any}, context?) => any;\n\n/**\n * Set up a WebWorkerGlobalScope to talk with the main thread\n */\nexport function createWorker(process: Process, processInBatches?: ProcessInBatches): void {\n // Check that we are actually in a worker thread\n if (typeof self === 'undefined') {\n return;\n }\n\n const context: WorkerContext = {\n process: processOnMainThread\n };\n\n // eslint-disable-next-line complexity\n WorkerBody.onmessage = async (type: WorkerMessageType, payload: WorkerMessagePayload) => {\n try {\n switch (type) {\n case 'process':\n if (!process) {\n throw new Error('Worker does not support atomic processing');\n }\n const result = await process(payload.input, payload.options || {}, context);\n WorkerBody.postMessage('done', {result});\n break;\n\n case 'process-in-batches':\n if (!processInBatches) {\n throw new Error('Worker does not support batched processing');\n }\n inputBatches = new AsyncQueue();\n options = payload.options || {};\n const resultIterator = processInBatches(inputBatches, options, context?.processInBatches);\n for await (const batch of resultIterator) {\n WorkerBody.postMessage('output-batch', {result: batch});\n }\n WorkerBody.postMessage('done', {});\n break;\n\n case 'input-batch':\n inputBatches.push(payload.input);\n break;\n\n case 'input-done':\n inputBatches.close();\n break;\n\n default:\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n };\n}\n\nfunction processOnMainThread(arrayBuffer, options = {}) {\n return new Promise((resolve, reject) => {\n const id = requestId++;\n\n /**\n */\n const onMessage = (type, payload) => {\n if (payload.id !== id) {\n // not ours\n return;\n }\n\n switch (type) {\n case 'done':\n WorkerBody.removeEventListener(onMessage);\n resolve(payload.result);\n break;\n\n case 'error':\n WorkerBody.removeEventListener(onMessage);\n reject(payload.error);\n break;\n\n default:\n // ignore\n }\n };\n\n WorkerBody.addEventListener(onMessage);\n\n // Ask the main thread to decode data\n const payload = {id, input: arrayBuffer, options};\n WorkerBody.postMessage('process', payload);\n });\n}\n","import type {WorkerMessageData, WorkerMessageType, WorkerMessagePayload} from '../../types';\nimport {getTransferList} from '../worker-utils/get-transfer-list';\n\nconst onMessageWrapperMap = new Map();\n\n/**\n * Type safe wrapper for worker code\n */\nexport default class WorkerBody {\n /*\n * (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n */\n static set onmessage(onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any) {\n // eslint-disable-next-line no-restricted-globals\n self.onmessage = (message) => {\n if (!isKnownMessage(message)) {\n return;\n }\n\n // Confusingly the message itself also has a 'type' field which is always set to 'message'\n const {type, payload} = message.data;\n onMessage(type, payload);\n };\n }\n\n static addEventListener(\n onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n ) {\n let onMessageWrapper = onMessageWrapperMap.get(onMessage);\n\n if (!onMessageWrapper) {\n onMessageWrapper = (message) => {\n if (!isKnownMessage(message)) {\n return;\n }\n\n // Confusingly the message itself also has a 'type' field which is always set to 'message'\n const {type, payload} = message.data;\n onMessage(type, payload);\n };\n }\n\n // eslint-disable-next-line no-restricted-globals\n self.addEventListener('message', onMessageWrapper);\n }\n\n static removeEventListener(\n onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n ) {\n const onMessageWrapper = onMessageWrapperMap.get(onMessage);\n onMessageWrapperMap.delete(onMessage);\n // eslint-disable-next-line no-restricted-globals\n self.removeEventListener('message', onMessageWrapper);\n }\n\n /**\n * Send a message from a worker to creating thread (main thread)\n * @param type\n * @param payload\n */\n static postMessage(type: WorkerMessageType, payload: WorkerMessagePayload): void {\n if (self) {\n const data: WorkerMessageData = {source: 'loaders.gl', type, payload};\n const transferList = getTransferList(payload);\n // eslint-disable-next-line no-restricted-globals\n // @ts-ignore\n self.postMessage(data, transferList);\n }\n }\n}\n\n// Filter out noise messages sent to workers\nfunction isKnownMessage(message) {\n const {type, data} = message;\n return (\n type === 'message' &&\n data &&\n typeof data.source === 'string' &&\n data.source.startsWith('loaders.gl')\n );\n}\n","// 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) {\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","import {createWorker} from '../lib/worker-api/create-worker';\n\ncreateWorker(async (data) => {\n // @ts-ignore\n return data;\n});\n"],"sourceRoot":""}