@loaders.gl/worker-utils 3.3.0-alpha.7 → 3.3.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/lib/env-utils/version.js +2 -2
- package/dist/es5/lib/library-utils/library-utils.js +1 -1
- package/dist/es5/lib/worker-api/get-worker-url.js +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/dist/lib/process-utils/child-process-proxy.d.ts +1 -1
- package/dist/lib/process-utils/child-process-proxy.d.ts.map +1 -1
- package/dist/lib/worker-api/create-worker.d.ts +1 -1
- package/dist/lib/worker-api/create-worker.d.ts.map +1 -1
- package/dist/lib/worker-api/create-worker.js +1 -1
- package/dist/lib/worker-api/process-on-worker.d.ts +1 -1
- package/dist/lib/worker-api/process-on-worker.d.ts.map +1 -1
- package/dist/lib/worker-farm/worker-farm.d.ts +1 -1
- package/dist/lib/worker-farm/worker-farm.d.ts.map +1 -1
- package/dist/lib/worker-farm/worker-farm.js +8 -8
- package/dist/lib/worker-farm/worker-pool.d.ts +4 -4
- package/dist/lib/worker-farm/worker-pool.d.ts.map +1 -1
- package/dist/lib/worker-farm/worker-pool.js +4 -4
- package/dist/lib/worker-farm/worker-thread.d.ts +1 -1
- package/dist/lib/worker-farm/worker-thread.d.ts.map +1 -1
- package/dist/lib/worker-farm/worker-thread.js +5 -5
- package/dist/types.d.ts +9 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.VERSION = void 0;
|
|
7
7
|
|
|
8
8
|
var DEFAULT_VERSION = 'beta';
|
|
9
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
9
|
+
var VERSION = typeof "3.3.0-alpha.9" !== 'undefined' ? "3.3.0-alpha.9" : DEFAULT_VERSION;
|
|
10
10
|
exports.VERSION = VERSION;
|
|
11
|
-
if (typeof "3.3.0-alpha.
|
|
11
|
+
if (typeof "3.3.0-alpha.9" === 'undefined') {
|
|
12
12
|
console.error('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.');
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=version.js.map
|
|
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
17
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
18
|
|
|
19
19
|
var LATEST = 'beta';
|
|
20
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
20
|
+
var VERSION = typeof "3.3.0-alpha.9" !== 'undefined' ? "3.3.0-alpha.9" : LATEST;
|
|
21
21
|
var loadLibraryPromises = {};
|
|
22
22
|
|
|
23
23
|
function loadLibrary(_x) {
|
|
@@ -8,7 +8,7 @@ exports.getWorkerURL = getWorkerURL;
|
|
|
8
8
|
var _assert = require("../env-utils/assert");
|
|
9
9
|
var _version = require("../env-utils/version");
|
|
10
10
|
var NPM_TAG = 'beta';
|
|
11
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
11
|
+
var VERSION = typeof "3.3.0-alpha.9" !== 'undefined' ? "3.3.0-alpha.9" : NPM_TAG;
|
|
12
12
|
|
|
13
13
|
function getWorkerName(worker) {
|
|
14
14
|
var warning = worker.version !== VERSION ? " (worker-utils@".concat(VERSION, ")") : '';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
const DEFAULT_VERSION = 'beta';
|
|
4
|
-
export const VERSION = typeof "3.3.0-alpha.
|
|
5
|
-
if (typeof "3.3.0-alpha.
|
|
4
|
+
export const VERSION = typeof "3.3.0-alpha.9" !== 'undefined' ? "3.3.0-alpha.9" : DEFAULT_VERSION;
|
|
5
|
+
if (typeof "3.3.0-alpha.9" === 'undefined') {
|
|
6
6
|
console.error('loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.');
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=version.js.map
|
|
@@ -5,7 +5,7 @@ import { assert } from '../env-utils/assert';
|
|
|
5
5
|
import { VERSION as __VERSION__ } from '../env-utils/version';
|
|
6
6
|
|
|
7
7
|
const LATEST = 'beta';
|
|
8
|
-
const VERSION = typeof "3.3.0-alpha.
|
|
8
|
+
const VERSION = typeof "3.3.0-alpha.9" !== 'undefined' ? "3.3.0-alpha.9" : LATEST;
|
|
9
9
|
const loadLibraryPromises = {};
|
|
10
10
|
|
|
11
11
|
export async function loadLibrary(libraryUrl) {
|
|
@@ -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 = 'beta';
|
|
4
|
-
const VERSION = typeof "3.3.0-alpha.
|
|
4
|
+
const VERSION = typeof "3.3.0-alpha.9" !== 'undefined' ? "3.3.0-alpha.9" : NPM_TAG;
|
|
5
5
|
|
|
6
6
|
export function getWorkerName(worker) {
|
|
7
7
|
const warning = worker.version !== VERSION ? " (worker-utils@".concat(VERSION, ")") : '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child-process-proxy.d.ts","sourceRoot":"","sources":["../../../src/lib/process-utils/child-process-proxy.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAG9C,
|
|
1
|
+
{"version":3,"file":"child-process-proxy.d.ts","sourceRoot":"","sources":["../../../src/lib/process-utils/child-process-proxy.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAG9C,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC;IAC9C,yBAAyB;IACzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7C,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAChD,CAAC;AAaF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,sBAAsB,CAAsB;IACnD,OAAO,CAAC,YAAY,CAA0C;IAC9D,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,YAAY,CAAC,CAAM;gBAGf,EAAC,EAAqB,EAAC;;KAAK;IAIxC,qDAAqD;IAC/C,KAAK,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAsD3D,oCAAoC;IAC9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3B,yBAAyB;IACnB,IAAI,CAAC,UAAU,GAAE,MAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjD,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;IAM9C,aAAa;CAKd"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WorkerContext, Process, ProcessInBatches } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export type ProcessOnMainThread = (data: any, options?: {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
}, context?: WorkerContext) => any;
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-api/create-worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,aAAa,EACb,OAAO,EACP,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAUrB,
|
|
1
|
+
{"version":3,"file":"create-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-api/create-worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,aAAa,EACb,OAAO,EACP,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAUrB,MAAM,MAAM,mBAAmB,GAAG,CAChC,IAAI,EAAE,GAAG,EACT,OAAO,CAAC,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,EAC9B,OAAO,CAAC,EAAE,aAAa,KACpB,GAAG,CAAC;AAET;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAiDxF"}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createWorker = void 0;
|
|
7
7
|
const async_queue_1 = __importDefault(require("../async-queue/async-queue"));
|
|
8
8
|
const worker_body_1 = __importDefault(require("../worker-farm/worker-body"));
|
|
9
|
-
// import {validateWorkerVersion} from './validate-worker-version';
|
|
9
|
+
// import {validateWorkerVersion} from './validate-worker-version.js';
|
|
10
10
|
/** Counter for jobs */
|
|
11
11
|
let requestId = 0;
|
|
12
12
|
let inputBatches;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-on-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-api/process-on-worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EAGd,MAAM,aAAa,CAAC;AAMrB,
|
|
1
|
+
{"version":3,"file":"process-on-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-api/process-on-worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EAGd,MAAM,aAAa,CAAC;AAMrB,KAAK,sBAAsB,GAAG,aAAa,GAAG;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,aAAa,4BAM/E;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,GAAG,EACT,OAAO,GAAE,sBAA2B,EACpC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,GAAG,CAAC,CAwBd"}
|
|
@@ -6,7 +6,7 @@ import WorkerPool from './worker-pool';
|
|
|
6
6
|
* @param reuseWorkers - if false, destroys workers when task is completed
|
|
7
7
|
* @param onDebug - callback intended to allow application to log worker pool activity
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type WorkerFarmProps = {
|
|
10
10
|
maxConcurrency?: number;
|
|
11
11
|
maxMobileConcurrency?: number;
|
|
12
12
|
reuseWorkers?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-farm.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-farm/worker-farm.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAC;AAGvC;;;;;;GAMG;AACH,
|
|
1
|
+
{"version":3,"file":"worker-farm.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-farm/worker-farm.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAC;AAGvC;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AASF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,WAAW,CAAiC;IAEpD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAa;IAExC,uDAAuD;IACvD,MAAM,CAAC,WAAW,IAAI,OAAO;IAI7B,2DAA2D;IAC3D,MAAM,CAAC,aAAa,CAAC,KAAK,GAAE,eAAoB,GAAG,UAAU;IAM7D,0DAA0D;IAC1D,OAAO;IAOP;;;OAGG;IACH,OAAO,IAAI,IAAI;IAOf;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAQtC;;;;;;;;OAQG;IACH,aAAa,CAAC,OAAO,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,UAAU;IAejF,mBAAmB;;;;;;CAQpB"}
|
|
@@ -15,14 +15,6 @@ const DEFAULT_PROPS = {
|
|
|
15
15
|
* Process multiple jobs with a "farm" of different workers in worker pools.
|
|
16
16
|
*/
|
|
17
17
|
class WorkerFarm {
|
|
18
|
-
/** get global instance with WorkerFarm.getWorkerFarm() */
|
|
19
|
-
constructor(props) {
|
|
20
|
-
this.workerPools = new Map();
|
|
21
|
-
this.props = { ...DEFAULT_PROPS };
|
|
22
|
-
this.setProps(props);
|
|
23
|
-
/** @type Map<string, WorkerPool>} */
|
|
24
|
-
this.workerPools = new Map();
|
|
25
|
-
}
|
|
26
18
|
/** Checks if workers are supported on this platform */
|
|
27
19
|
static isSupported() {
|
|
28
20
|
return worker_thread_1.default.isSupported();
|
|
@@ -33,6 +25,14 @@ class WorkerFarm {
|
|
|
33
25
|
WorkerFarm._workerFarm.setProps(props);
|
|
34
26
|
return WorkerFarm._workerFarm;
|
|
35
27
|
}
|
|
28
|
+
/** get global instance with WorkerFarm.getWorkerFarm() */
|
|
29
|
+
constructor(props) {
|
|
30
|
+
this.workerPools = new Map();
|
|
31
|
+
this.props = { ...DEFAULT_PROPS };
|
|
32
|
+
this.setProps(props);
|
|
33
|
+
/** @type Map<string, WorkerPool>} */
|
|
34
|
+
this.workerPools = new Map();
|
|
35
|
+
}
|
|
36
36
|
/**
|
|
37
37
|
* Terminate all workers in the farm
|
|
38
38
|
* @note Can free up significant memory
|
|
@@ -2,7 +2,7 @@ import type { WorkerMessageType, WorkerMessagePayload } from '../../types';
|
|
|
2
2
|
import WorkerThread from './worker-thread';
|
|
3
3
|
import WorkerJob from './worker-job';
|
|
4
4
|
/** WorkerPool onDebug Callback Parameters */
|
|
5
|
-
|
|
5
|
+
type OnDebugParameters = {
|
|
6
6
|
message: string;
|
|
7
7
|
worker: string;
|
|
8
8
|
name: string;
|
|
@@ -11,7 +11,7 @@ declare type OnDebugParameters = {
|
|
|
11
11
|
workerThread: WorkerThread;
|
|
12
12
|
};
|
|
13
13
|
/** WorkerPool Properties */
|
|
14
|
-
export
|
|
14
|
+
export type WorkerPoolProps = {
|
|
15
15
|
name?: string;
|
|
16
16
|
source?: string;
|
|
17
17
|
url?: string;
|
|
@@ -21,8 +21,8 @@ export declare type WorkerPoolProps = {
|
|
|
21
21
|
reuseWorkers?: boolean;
|
|
22
22
|
};
|
|
23
23
|
/** Private helper types */
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
type OnMessage = (job: WorkerJob, type: WorkerMessageType, payload: WorkerMessagePayload) => void;
|
|
25
|
+
type OnError = (job: WorkerJob, error: Error) => void;
|
|
26
26
|
/**
|
|
27
27
|
* Process multiple data messages with small pool of identical workers
|
|
28
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-pool.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-farm/worker-pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,oBAAoB,EAAC,MAAM,aAAa,CAAC;AAEzE,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,6CAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"worker-pool.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-farm/worker-pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,oBAAoB,EAAC,MAAM,aAAa,CAAC;AAEzE,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,6CAA6C;AAC7C,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,4BAA4B;AAC5B,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,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;OAEG;IACH,mBAAmB,IAAI,YAAY,GAAG,IAAI;IAiB1C,kBAAkB;CAGnB"}
|
|
@@ -10,6 +10,10 @@ const worker_job_1 = __importDefault(require("./worker-job"));
|
|
|
10
10
|
* Process multiple data messages with small pool of identical workers
|
|
11
11
|
*/
|
|
12
12
|
class WorkerPool {
|
|
13
|
+
/** Checks if workers are supported on this platform */
|
|
14
|
+
static isSupported() {
|
|
15
|
+
return worker_thread_1.default.isSupported();
|
|
16
|
+
}
|
|
13
17
|
/**
|
|
14
18
|
* @param processor - worker function
|
|
15
19
|
* @param maxConcurrency - max count of workers
|
|
@@ -29,10 +33,6 @@ class WorkerPool {
|
|
|
29
33
|
this.url = props.url;
|
|
30
34
|
this.setProps(props);
|
|
31
35
|
}
|
|
32
|
-
/** Checks if workers are supported on this platform */
|
|
33
|
-
static isSupported() {
|
|
34
|
-
return worker_thread_1.default.isSupported();
|
|
35
|
-
}
|
|
36
36
|
/**
|
|
37
37
|
* Terminates all workers in the pool
|
|
38
38
|
* @note Can free up significant memory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-thread.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-farm/worker-thread.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAQ5D,
|
|
1
|
+
{"version":3,"file":"worker-thread.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-farm/worker-thread.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAQ5D,MAAM,MAAM,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,GAAG,UAAU,CAAC;IAC5B,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,uDAAuD;IACvD,MAAM,CAAC,WAAW,IAAI,OAAO;gBAOjB,KAAK,EAAE,iBAAiB;IAYpC;;;OAGG;IACH,OAAO,IAAI,IAAI;IAOf,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,IAAI,MAAM;IAsB9B;;;OAGG;IACH,iBAAiB,IAAI,UAAU;CA0BhC"}
|
|
@@ -10,6 +10,11 @@ const NOOP = () => { };
|
|
|
10
10
|
* Represents one worker thread
|
|
11
11
|
*/
|
|
12
12
|
class WorkerThread {
|
|
13
|
+
/** Checks if workers are supported on this platform */
|
|
14
|
+
static isSupported() {
|
|
15
|
+
return ((typeof Worker !== 'undefined' && globals_1.isBrowser) ||
|
|
16
|
+
(typeof worker_threads_1.Worker !== 'undefined' && !globals_1.isBrowser));
|
|
17
|
+
}
|
|
13
18
|
constructor(props) {
|
|
14
19
|
this.terminated = false;
|
|
15
20
|
this._loadableURL = '';
|
|
@@ -22,11 +27,6 @@ class WorkerThread {
|
|
|
22
27
|
this.onError = (error) => console.log(error); // eslint-disable-line
|
|
23
28
|
this.worker = globals_1.isBrowser ? this._createBrowserWorker() : this._createNodeWorker();
|
|
24
29
|
}
|
|
25
|
-
/** Checks if workers are supported on this platform */
|
|
26
|
-
static isSupported() {
|
|
27
|
-
return ((typeof Worker !== 'undefined' && globals_1.isBrowser) ||
|
|
28
|
-
(typeof worker_threads_1.Worker !== 'undefined' && !globals_1.isBrowser));
|
|
29
|
-
}
|
|
30
30
|
/**
|
|
31
31
|
* Terminate this worker thread
|
|
32
32
|
* @note Can free up significant memory
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Worker Options
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type WorkerOptions = {
|
|
5
5
|
CDN?: string;
|
|
6
6
|
worker?: boolean;
|
|
7
7
|
maxConcurrency?: number;
|
|
@@ -11,20 +11,20 @@ export declare type WorkerOptions = {
|
|
|
11
11
|
workerUrl?: string;
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type WorkerContext = {
|
|
15
15
|
process?: Process;
|
|
16
16
|
processInBatches?: ProcessInBatches;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type Process = (data: any, options?: {
|
|
19
19
|
[key: string]: any;
|
|
20
20
|
}, context?: WorkerContext) => any;
|
|
21
|
-
export
|
|
21
|
+
export type ProcessInBatches = (iterator: AsyncIterable<any> | Iterable<any>, options?: {
|
|
22
22
|
[key: string]: any;
|
|
23
23
|
}, context?: WorkerContext) => AsyncIterable<any>;
|
|
24
24
|
/**
|
|
25
25
|
* A worker description object
|
|
26
26
|
*/
|
|
27
|
-
export
|
|
27
|
+
export type WorkerObject = {
|
|
28
28
|
id: string;
|
|
29
29
|
name: string;
|
|
30
30
|
module: string;
|
|
@@ -37,8 +37,8 @@ export declare type WorkerObject = {
|
|
|
37
37
|
process?: Process;
|
|
38
38
|
processInBatches?: ProcessInBatches;
|
|
39
39
|
};
|
|
40
|
-
export
|
|
41
|
-
export
|
|
40
|
+
export type WorkerMessageType = 'process' | 'done' | 'error' | 'process-in-batches' | 'input-batch' | 'input-done' | 'output-batch';
|
|
41
|
+
export type WorkerMessagePayload = {
|
|
42
42
|
id?: number;
|
|
43
43
|
options?: {
|
|
44
44
|
[key: string]: any;
|
|
@@ -50,12 +50,12 @@ export declare type WorkerMessagePayload = {
|
|
|
50
50
|
result?: any;
|
|
51
51
|
error?: string;
|
|
52
52
|
};
|
|
53
|
-
export
|
|
53
|
+
export type WorkerMessageData = {
|
|
54
54
|
source: 'loaders.gl';
|
|
55
55
|
type: WorkerMessageType;
|
|
56
56
|
payload: WorkerMessagePayload;
|
|
57
57
|
};
|
|
58
|
-
export
|
|
58
|
+
export type WorkerMessage = {
|
|
59
59
|
type: string;
|
|
60
60
|
data: WorkerMessageData;
|
|
61
61
|
};
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAE1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC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MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,oBAAoB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/worker-utils",
|
|
3
|
-
"version": "3.3.0-alpha.
|
|
3
|
+
"version": "3.3.0-alpha.9",
|
|
4
4
|
"description": "Utilities for running tasks on worker threads",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@babel/runtime": "^7.3.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "c95a4ff72512668a93d9041ce8636bac09333fd5"
|
|
53
53
|
}
|