@xylabs/threads 3.5.1 → 3.5.2
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/common.js +3 -5
- package/{dist-esm → dist/esm}/common.js +0 -1
- package/{dist-esm → dist/esm}/index.js +0 -1
- package/{dist-esm → dist/esm}/master/get-bundle-url.browser.js +0 -2
- package/{dist-esm → dist/esm}/master/implementation.browser.js +1 -5
- package/{dist-esm → dist/esm}/master/implementation.js +0 -8
- package/{dist-esm → dist/esm}/master/implementation.node.js +0 -26
- package/{dist-esm → dist/esm}/master/index.js +0 -2
- package/{dist-esm → dist/esm}/master/invocation-proxy.js +0 -8
- package/{dist-esm → dist/esm}/master/pool-types.js +0 -1
- package/{dist-esm → dist/esm}/master/pool.js +2 -21
- package/{dist-esm → dist/esm}/master/register.js +0 -1
- package/{dist-esm → dist/esm}/master/spawn.js +0 -13
- package/{dist-esm → dist/esm}/master/thread.js +0 -4
- package/{dist-esm → dist/esm}/observable-promise.js +0 -24
- package/{dist-esm → dist/esm}/observable.js +0 -10
- package/{dist-esm → dist/esm}/ponyfills.js +0 -1
- package/{dist-esm → dist/esm}/promise.js +0 -5
- package/{dist-esm → dist/esm}/transferable.js +0 -2
- package/{dist-esm → dist/esm}/types/master.js +0 -4
- package/{dist-esm → dist/esm}/types/messages.js +0 -4
- package/{dist-esm → dist/esm}/worker/bundle-entry.js +0 -1
- package/{dist-esm → dist/esm}/worker/implementation.browser.js +0 -4
- package/{dist-esm → dist/esm}/worker/implementation.js +0 -5
- package/{dist-esm → dist/esm}/worker/implementation.tiny-worker.js +0 -7
- package/{dist-esm → dist/esm}/worker/implementation.worker_threads.js +0 -1
- package/{dist-esm → dist/esm}/worker/index.js +0 -19
- package/{dist-esm → dist/esm}/worker_threads.js +0 -4
- package/dist/index.js +0 -1
- package/dist/master/get-bundle-url.browser.js +2 -5
- package/dist/master/implementation.browser.js +4 -8
- package/dist/master/implementation.d.ts +0 -2
- package/dist/master/implementation.js +0 -8
- package/dist/master/implementation.node.d.ts +0 -1
- package/dist/master/implementation.node.js +3 -29
- package/dist/master/index.d.ts +0 -2
- package/dist/master/index.js +0 -2
- package/dist/master/invocation-proxy.js +2 -11
- package/dist/master/pool-types.d.ts +0 -14
- package/dist/master/pool-types.js +0 -1
- package/dist/master/pool.d.ts +0 -41
- package/dist/master/pool.js +2 -21
- package/dist/master/register.js +0 -1
- package/dist/master/spawn.d.ts +0 -9
- package/dist/master/spawn.js +1 -15
- package/dist/master/thread.d.ts +2 -6
- package/dist/master/thread.js +0 -4
- package/dist/observable-promise.d.ts +0 -13
- package/dist/observable-promise.js +0 -24
- package/dist/observable.d.ts +0 -9
- package/dist/observable.js +0 -10
- package/dist/ponyfills.js +1 -3
- package/dist/promise.d.ts +0 -4
- package/dist/promise.js +1 -7
- package/dist/serializers.js +2 -2
- package/dist/transferable.d.ts +0 -33
- package/dist/transferable.js +2 -5
- package/dist/types/master.d.ts +0 -14
- package/dist/types/master.js +0 -4
- package/dist/types/messages.js +0 -4
- package/dist/worker/bundle-entry.js +0 -1
- package/dist/worker/implementation.browser.d.ts +1 -2
- package/dist/worker/implementation.browser.js +0 -4
- package/dist/worker/implementation.js +0 -5
- package/dist/worker/implementation.tiny-worker.d.ts +1 -2
- package/dist/worker/implementation.tiny-worker.js +0 -7
- package/dist/worker/implementation.worker_threads.d.ts +1 -1
- package/dist/worker/implementation.worker_threads.js +0 -1
- package/dist/worker/index.d.ts +0 -8
- package/dist/worker/index.js +2 -21
- package/dist/worker_threads.js +1 -5
- package/index.mjs +0 -1
- package/observable.d.ts +0 -1
- package/observable.js +0 -2
- package/observable.mjs +0 -1
- package/package.json +16 -17
- package/register.d.ts +0 -2
- package/register.js +0 -2
- package/register.mjs +0 -1
- package/rollup.config.js +0 -1
- package/src/index.ts +0 -1
- package/src/master/pool.ts +2 -1
- package/src/master/spawn.ts +1 -2
- package/src/observable-promise.ts +1 -0
- package/src/worker/implementation.browser.ts +1 -1
- package/src/worker/implementation.tiny-worker.ts +1 -1
- package/src/worker/implementation.ts +1 -1
- package/src/worker/implementation.worker_threads.ts +1 -1
- package/src/worker/index.ts +1 -1
- package/src/worker_threads.ts +1 -1
- package/test/lib/serialization.ts +1 -1
- package/test/observable-promise.test.ts +0 -1
- package/test/observable.test.ts +1 -1
- package/test/pool.test.ts +3 -2
- package/test/serialization.test.ts +0 -1
- package/test/spawn.chromium.mocha.ts +0 -1
- package/test/spawn.test.ts +2 -3
- package/test/streaming.test.ts +0 -1
- package/test/transferables.test.ts +1 -1
- package/test/workers/arraybuffer-xor.ts +0 -1
- package/test/workers/count-to-five.ts +0 -1
- package/test/workers/counter.ts +0 -1
- package/test/workers/faulty-function.ts +0 -1
- package/test/workers/hello-world.ts +0 -1
- package/test/workers/increment.ts +0 -1
- package/test/workers/minmax.ts +0 -1
- package/test/workers/serialization.ts +1 -1
- package/test-tooling/rollup/app.js +0 -1
- package/test-tooling/rollup/rollup.config.ts +1 -1
- package/test-tooling/rollup/worker.js +2 -2
- package/test-tooling/tsconfig/minimal.ts +1 -1
- package/test-tooling/webpack/addition-worker.ts +0 -1
- package/test-tooling/webpack/app-with-inlined-worker.ts +3 -3
- package/test-tooling/webpack/app.ts +2 -2
- package/test-tooling/webpack/pool-worker.ts +0 -1
- package/test-tooling/webpack/webpack.node.config.js +0 -1
- package/test-tooling/webpack/webpack.web.config.js +0 -1
- package/worker.d.ts +0 -1
- package/worker.js +0 -2
- package/worker.mjs +0 -1
- /package/{dist-esm → dist/esm}/serializers.js +0 -0
- /package/{dist-esm → dist/esm}/symbols.js +0 -0
- /package/{dist-esm → dist/esm}/types/worker.js +0 -0
package/src/master/pool.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/* eslint-disable unicorn/no-thenable */
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
/* eslint-disable require-await */
|
|
4
4
|
/* eslint-disable @typescript-eslint/member-ordering */
|
|
5
5
|
/* eslint-disable unicorn/no-array-reduce */
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
7
|
/* eslint-disable import/export */
|
|
8
8
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
9
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
9
10
|
import DebugLogger from 'debug'
|
|
10
11
|
import { multicast, Observable, Subject } from 'observable-fns'
|
|
11
12
|
|
package/src/master/spawn.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
3
3
|
import DebugLogger from 'debug'
|
|
4
4
|
import { Observable } from 'observable-fns'
|
|
5
5
|
|
|
@@ -124,7 +124,6 @@ function setPrivateThreadProps<T>(
|
|
|
124
124
|
.filter((event) => event.type === WorkerEventType.internalError)
|
|
125
125
|
.map((errorEvent) => (errorEvent as WorkerInternalErrorEvent).error)
|
|
126
126
|
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
127
|
return Object.assign(raw as any, {
|
|
129
128
|
[$errors]: workerErrors,
|
|
130
129
|
[$events]: workerEvents,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable unicorn/no-thenable */
|
|
2
2
|
/* eslint-disable @typescript-eslint/member-ordering */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
4
|
+
|
|
4
5
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
6
|
/* eslint-disable @typescript-eslint/no-this-alias */
|
|
6
7
|
/* eslint-disable unicorn/no-this-assignment */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-default-export */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
2
|
/// <reference lib="dom" />
|
|
4
3
|
// tslint:disable no-shadowed-variable
|
|
@@ -33,6 +32,7 @@ const subscribeToMasterMessages: AbstractedWorkerAPI['subscribeToMasterMessages'
|
|
|
33
32
|
return unsubscribe
|
|
34
33
|
}
|
|
35
34
|
|
|
35
|
+
// eslint-disable-next-line import/no-default-export
|
|
36
36
|
export default {
|
|
37
37
|
isWorkerRuntime,
|
|
38
38
|
postMessageToMaster,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-default-export */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
2
|
/// <reference lib="dom" />
|
|
4
3
|
// tslint:disable no-shadowed-variable
|
|
@@ -48,6 +47,7 @@ const subscribeToMasterMessages: AbstractedWorkerAPI['subscribeToMasterMessages'
|
|
|
48
47
|
return unsubscribe
|
|
49
48
|
}
|
|
50
49
|
|
|
50
|
+
// eslint-disable-next-line import/no-default-export
|
|
51
51
|
export default {
|
|
52
52
|
isWorkerRuntime,
|
|
53
53
|
postMessageToMaster,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-default-export */
|
|
2
1
|
// tslint:disable no-var-requires
|
|
3
2
|
/*
|
|
4
3
|
* This file is only a stub to make './implementation' resolve to the right module.
|
|
@@ -20,4 +19,5 @@ function selectNodeImplementation(): AbstractedWorkerAPI {
|
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
|
|
22
|
+
// eslint-disable-next-line import/no-default-export
|
|
23
23
|
export default runningInNode ? selectNodeImplementation() : WebWorkerImplementation
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-default-export */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
2
|
// tslint:disable no-shadowed-variable
|
|
4
3
|
import { MessagePort } from 'node:worker_threads'
|
|
@@ -42,6 +41,7 @@ function testImplementation() {
|
|
|
42
41
|
WorkerThreads()
|
|
43
42
|
}
|
|
44
43
|
|
|
44
|
+
// eslint-disable-next-line import/no-default-export
|
|
45
45
|
export default {
|
|
46
46
|
isWorkerRuntime,
|
|
47
47
|
postMessageToMaster,
|
package/src/worker/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
3
3
|
import isSomeObservable from 'is-observable-2-1-0'
|
|
4
4
|
import { Observable, Subscription } from 'observable-fns'
|
|
5
5
|
|
package/src/worker_threads.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-default-export */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
2
|
// Webpack hack
|
|
4
3
|
// tslint:disable no-eval
|
|
@@ -20,6 +19,7 @@ function selectImplementation(): WorkerThreadsModule {
|
|
|
20
19
|
return typeof __non_webpack_require__ === 'function' ? __non_webpack_require__('worker_threads') : eval('require')('worker_threads')
|
|
21
20
|
}
|
|
22
21
|
|
|
22
|
+
// eslint-disable-next-line import/no-default-export
|
|
23
23
|
export default function getImplementation(): WorkerThreadsModule {
|
|
24
24
|
if (!implementation) {
|
|
25
25
|
implementation = selectImplementation()
|
package/test/observable.test.ts
CHANGED
package/test/pool.test.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
1
2
|
/* eslint-disable require-await */
|
|
2
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
// eslint-disable import/no-internal-modules
|
|
5
6
|
import test from 'ava'
|
|
6
7
|
|
|
7
8
|
import { Pool, spawn, Worker } from '../src/index'
|
package/test/spawn.test.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
/* eslint-disable import/no-internal-modules */
|
|
4
3
|
import test from 'ava'
|
|
5
4
|
import { Observable } from 'observable-fns'
|
|
6
5
|
|
|
@@ -47,7 +46,7 @@ test('can spawn a module thread', async (t) => {
|
|
|
47
46
|
|
|
48
47
|
test('thread job errors are handled', async (t) => {
|
|
49
48
|
const fail = await spawn<() => Promise<never>>(new Worker('./workers/faulty-function'))
|
|
50
|
-
await t.throwsAsync(fail(),
|
|
49
|
+
await t.throwsAsync(fail(), undefined, 'I am supposed to fail.')
|
|
51
50
|
await Thread.terminate(fail)
|
|
52
51
|
})
|
|
53
52
|
|
|
@@ -65,7 +64,7 @@ test('thread transfer errors are handled', async (t) => {
|
|
|
65
64
|
})
|
|
66
65
|
|
|
67
66
|
test('catches top-level thread errors', async (t) => {
|
|
68
|
-
await t.throwsAsync(spawn(new Worker('./workers/top-level-throw')),
|
|
67
|
+
await t.throwsAsync(spawn(new Worker('./workers/top-level-throw')), undefined, 'Top-level worker error')
|
|
69
68
|
})
|
|
70
69
|
|
|
71
70
|
test.todo('can subscribe to thread events')
|
package/test/streaming.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import test from 'ava'
|
|
5
5
|
|
|
6
6
|
import { spawn, Thread, Transfer, Worker } from '../src/index'
|
package/test/workers/counter.ts
CHANGED
package/test/workers/minmax.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/* eslint-disable import/no-default-export */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
/* eslint-disable import/no-internal-modules */
|
|
4
1
|
/* eslint-disable import/no-unresolved */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
|
|
5
4
|
/// <reference types="./raw-loader" />
|
|
6
5
|
|
|
7
6
|
import AdditionWorkerNodeBundle from 'raw-loader!./dist/addition-worker.node/worker.js'
|
|
@@ -26,4 +25,5 @@ async function test() {
|
|
|
26
25
|
return 'test succeeded'
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
// eslint-disable-next-line import/no-default-export
|
|
29
29
|
export default test
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/* eslint-disable import/no-default-export */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
|
|
2
|
+
|
|
4
3
|
import { isWorkerRuntime, Pool, spawn, Worker } from '../../src/index'
|
|
5
4
|
|
|
6
5
|
type AdditionWorker = (a: number, b: number) => number
|
|
@@ -57,4 +56,5 @@ function test4() {
|
|
|
57
56
|
|
|
58
57
|
const testAll = () => Promise.all([test(), test2(), test3(), test4()])
|
|
59
58
|
|
|
59
|
+
// eslint-disable-next-line import/no-default-export
|
|
60
60
|
export default testAll
|
package/worker.d.ts
CHANGED
package/worker.js
CHANGED
package/worker.mjs
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|