@loaders.gl/worker-utils 4.0.0-alpha.4 → 4.0.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 (57) hide show
  1. package/dist/index.d.ts +20 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/lib/async-queue/async-queue.d.ts +32 -0
  4. package/dist/lib/async-queue/async-queue.d.ts.map +1 -0
  5. package/dist/lib/env-utils/assert.d.ts +3 -0
  6. package/dist/lib/env-utils/assert.d.ts.map +1 -0
  7. package/dist/lib/env-utils/globals.d.ts +22 -0
  8. package/dist/lib/env-utils/globals.d.ts.map +1 -0
  9. package/dist/lib/env-utils/version.d.ts +2 -0
  10. package/dist/lib/env-utils/version.d.ts.map +1 -0
  11. package/dist/lib/env-utils/version.js +2 -2
  12. package/dist/lib/library-utils/library-utils.d.ts +18 -0
  13. package/dist/lib/library-utils/library-utils.d.ts.map +1 -0
  14. package/dist/lib/library-utils/library-utils.js +6 -2
  15. package/dist/lib/library-utils/library-utils.js.map +1 -1
  16. package/dist/lib/node/require-utils.node.d.ts +6 -0
  17. package/dist/lib/node/require-utils.node.d.ts.map +1 -0
  18. package/dist/lib/process-utils/child-process-proxy.d.ts +43 -0
  19. package/dist/lib/process-utils/child-process-proxy.d.ts.map +1 -0
  20. package/dist/lib/process-utils/process-utils.d.ts +2 -0
  21. package/dist/lib/process-utils/process-utils.d.ts.map +1 -0
  22. package/dist/lib/worker-api/create-worker.d.ts +9 -0
  23. package/dist/lib/worker-api/create-worker.d.ts.map +1 -0
  24. package/dist/lib/worker-api/get-worker-url.d.ts +14 -0
  25. package/dist/lib/worker-api/get-worker-url.d.ts.map +1 -0
  26. package/dist/lib/worker-api/get-worker-url.js +5 -1
  27. package/dist/lib/worker-api/get-worker-url.js.map +1 -1
  28. package/dist/lib/worker-api/process-on-worker.d.ts +20 -0
  29. package/dist/lib/worker-api/process-on-worker.d.ts.map +1 -0
  30. package/dist/lib/worker-api/validate-worker-version.d.ts +9 -0
  31. package/dist/lib/worker-api/validate-worker-version.d.ts.map +1 -0
  32. package/dist/lib/worker-farm/worker-body.d.ts +16 -0
  33. package/dist/lib/worker-farm/worker-body.d.ts.map +1 -0
  34. package/dist/lib/worker-farm/worker-farm.d.ts +55 -0
  35. package/dist/lib/worker-farm/worker-farm.d.ts.map +1 -0
  36. package/dist/lib/worker-farm/worker-job.d.ts +29 -0
  37. package/dist/lib/worker-farm/worker-job.d.ts.map +1 -0
  38. package/dist/lib/worker-farm/worker-pool.d.ts +75 -0
  39. package/dist/lib/worker-farm/worker-pool.d.ts.map +1 -0
  40. package/dist/lib/worker-farm/worker-thread.d.ts +42 -0
  41. package/dist/lib/worker-farm/worker-thread.d.ts.map +1 -0
  42. package/dist/lib/worker-utils/get-loadable-worker-url.d.ts +14 -0
  43. package/dist/lib/worker-utils/get-loadable-worker-url.d.ts.map +1 -0
  44. package/dist/lib/worker-utils/get-transfer-list.d.ts +10 -0
  45. package/dist/lib/worker-utils/get-transfer-list.d.ts.map +1 -0
  46. package/dist/lib/worker-utils/remove-nontransferable-options.d.ts +6 -0
  47. package/dist/lib/worker-utils/remove-nontransferable-options.d.ts.map +1 -0
  48. package/dist/null-worker.js +189 -550
  49. package/dist/null-worker.js.map +7 -1
  50. package/dist/types.d.ts +57 -0
  51. package/dist/types.d.ts.map +1 -0
  52. package/dist/workers/null-worker.d.ts +2 -0
  53. package/dist/workers/null-worker.d.ts.map +1 -0
  54. package/package.json +7 -5
  55. package/src/lib/library-utils/library-utils.ts +5 -1
  56. package/src/lib/worker-api/get-worker-url.ts +10 -0
  57. package/src/types.ts +1 -0
@@ -0,0 +1,42 @@
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: ErrorEvent): Error;
37
+ /**
38
+ * Creates a worker thread on the browser
39
+ */
40
+ _createBrowserWorker(): Worker;
41
+ }
42
+ //# sourceMappingURL=worker-thread.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-thread.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-farm/worker-thread.ts"],"names":[],"mappings":"AAMA,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,OAAO,CAAS;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEhC,OAAO,CAAC,YAAY,CAAc;IAElC,MAAM,CAAC,WAAW,IAAI,OAAO;gBAIjB,KAAK,EAAE,iBAAiB;IAYpC;;;OAGG;IACH,OAAO,IAAI,IAAI;IAQf,IAAI,SAAS,YAEZ;IAED;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI;IAQlD;;;OAGG;IACH,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK;IAiBjD;;OAEG;IACH,oBAAoB;CAqBrB"}
@@ -0,0 +1,14 @@
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;
14
+ //# sourceMappingURL=get-loadable-worker-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-loadable-worker-url.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-utils/get-loadable-worker-url.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAC,OAmB1E"}
@@ -0,0 +1,10 @@
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[];
10
+ //# sourceMappingURL=get-transfer-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-transfer-list.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-utils/get-transfer-list.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,GAAG,EACX,SAAS,GAAE,OAAc,EACzB,SAAS,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GACnB,YAAY,EAAE,CAwBhB"}
@@ -0,0 +1,6 @@
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;
6
+ //# sourceMappingURL=remove-nontransferable-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-nontransferable-options.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-utils/remove-nontransferable-options.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKnE"}