@atlaspack/workers 2.14.21-typescript-0c2081aca.0 → 2.14.21-typescript-c10a7ae7b.0
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/index.d.ts +94 -2
- package/package.json +9 -9
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
import type {FilePath} from '@atlaspack/types';
|
|
3
|
+
import type EventEmitter from 'events';
|
|
3
4
|
|
|
4
5
|
type BackendType = 'process' | 'threads';
|
|
5
6
|
|
|
@@ -15,10 +16,101 @@ export type FarmOptions = {
|
|
|
15
16
|
shouldTrace?: boolean;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
export class Bus extends EventEmitter {
|
|
20
|
+
emit(event: string, ...args: Array<any>): boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const bus: Bus;
|
|
20
24
|
|
|
25
|
+
export declare class WorkerFarm {
|
|
26
|
+
ending: boolean;
|
|
27
|
+
workerApi: {
|
|
28
|
+
callChild: (
|
|
29
|
+
childId: number,
|
|
30
|
+
request: HandleCallRequest,
|
|
31
|
+
) => Promise<unknown>;
|
|
32
|
+
callMaster: (
|
|
33
|
+
request: CallRequest,
|
|
34
|
+
awaitResponse?: boolean | null | undefined,
|
|
35
|
+
) => Promise<unknown>;
|
|
36
|
+
createReverseHandle: (fn: HandleFunction) => Handle;
|
|
37
|
+
getSharedReference: (ref: SharedReference) => unknown;
|
|
38
|
+
resolveSharedReference: (value: unknown) => undefined | SharedReference;
|
|
39
|
+
runHandle: (handle: Handle, args: Array<any>) => Promise<unknown>;
|
|
40
|
+
};
|
|
41
|
+
constructor(options: Partial<FarmOptions>);
|
|
42
|
+
createSharedReference(
|
|
43
|
+
value: unknown,
|
|
44
|
+
isCacheable?: boolean,
|
|
45
|
+
): {
|
|
46
|
+
ref: SharedReference;
|
|
47
|
+
dispose(): Promise<unknown>;
|
|
48
|
+
};
|
|
49
|
+
startProfile(): Promise<void>;
|
|
50
|
+
endProfile(): Promise<void>;
|
|
51
|
+
takeHeapSnapshot(): Promise<void>;
|
|
52
|
+
createHandle(method: string, useMainThread?: boolean): HandleFunction;
|
|
53
|
+
createReverseHandle(fn: HandleFunction): Handle;
|
|
54
|
+
callAllWorkers(method: string, args: Array<any>): Promise<void>;
|
|
55
|
+
static getWorkerApi(): {
|
|
56
|
+
callMaster: (
|
|
57
|
+
request: CallRequest,
|
|
58
|
+
awaitResponse?: boolean | null | undefined,
|
|
59
|
+
) => Promise<unknown>;
|
|
60
|
+
createReverseHandle: (fn: (...args: Array<any>) => unknown) => Handle;
|
|
61
|
+
getSharedReference: (ref: SharedReference) => unknown;
|
|
62
|
+
resolveSharedReference: (value: unknown) => undefined | SharedReference;
|
|
63
|
+
runHandle: (handle: Handle, args: Array<any>) => Promise<unknown>;
|
|
64
|
+
};
|
|
21
65
|
end(): Promise<void>;
|
|
66
|
+
static isWorker(): boolean;
|
|
22
67
|
}
|
|
23
68
|
|
|
24
69
|
export default WorkerFarm;
|
|
70
|
+
|
|
71
|
+
export type SharedReference = number;
|
|
72
|
+
|
|
73
|
+
export type WorkerApi = {
|
|
74
|
+
callMaster(
|
|
75
|
+
arg1: CallRequest,
|
|
76
|
+
arg2?: boolean | null | undefined,
|
|
77
|
+
): Promise<unknown>;
|
|
78
|
+
createReverseHandle(fn: HandleFunction): Handle;
|
|
79
|
+
getSharedReference(ref: SharedReference): unknown;
|
|
80
|
+
resolveSharedReference(value: unknown): SharedReference | null | undefined;
|
|
81
|
+
callChild?: (childId: number, request: HandleCallRequest) => Promise<unknown>;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type HandleFunction = (...args: Array<any>) => any;
|
|
85
|
+
|
|
86
|
+
export type LocationCallRequest = {
|
|
87
|
+
args: ReadonlyArray<unknown>;
|
|
88
|
+
location: string;
|
|
89
|
+
method?: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type HandleCallRequest = {
|
|
93
|
+
args: ReadonlyArray<unknown>;
|
|
94
|
+
handle: number;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type CallRequest = LocationCallRequest | HandleCallRequest;
|
|
98
|
+
|
|
99
|
+
type HandleOpts = {
|
|
100
|
+
fn?: HandleFunction;
|
|
101
|
+
childId?: number | null | undefined;
|
|
102
|
+
id?: number;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export declare class Handle {
|
|
106
|
+
id: number;
|
|
107
|
+
childId: number | null | undefined;
|
|
108
|
+
fn: HandleFunction | null | undefined;
|
|
109
|
+
constructor(opts: HandleOpts);
|
|
110
|
+
dispose(): void;
|
|
111
|
+
serialize(): {
|
|
112
|
+
childId: number | null | undefined;
|
|
113
|
+
id: number;
|
|
114
|
+
};
|
|
115
|
+
static deserialize(opts: HandleOpts): Handle;
|
|
116
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/workers",
|
|
3
|
-
"version": "2.14.21-typescript-
|
|
3
|
+
"version": "2.14.21-typescript-c10a7ae7b.0",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
},
|
|
13
13
|
"main": "lib/index.js",
|
|
14
14
|
"source": "src/index.ts",
|
|
15
|
-
"types": "
|
|
15
|
+
"types": "index.d.ts",
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">= 16.0.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@atlaspack/build-cache": "2.13.4-typescript-
|
|
21
|
-
"@atlaspack/diagnostic": "2.14.2-typescript-
|
|
22
|
-
"@atlaspack/logger": "2.14.14-typescript-
|
|
23
|
-
"@atlaspack/profiler": "2.14.18-typescript-
|
|
24
|
-
"@atlaspack/types-internal": "2.15.3-typescript-
|
|
25
|
-
"@atlaspack/utils": "2.17.3-typescript-
|
|
20
|
+
"@atlaspack/build-cache": "2.13.4-typescript-c10a7ae7b.0",
|
|
21
|
+
"@atlaspack/diagnostic": "2.14.2-typescript-c10a7ae7b.0",
|
|
22
|
+
"@atlaspack/logger": "2.14.14-typescript-c10a7ae7b.0",
|
|
23
|
+
"@atlaspack/profiler": "2.14.18-typescript-c10a7ae7b.0",
|
|
24
|
+
"@atlaspack/types-internal": "2.15.3-typescript-c10a7ae7b.0",
|
|
25
|
+
"@atlaspack/utils": "2.17.3-typescript-c10a7ae7b.0",
|
|
26
26
|
"nullthrows": "^1.1.1"
|
|
27
27
|
},
|
|
28
28
|
"browser": {
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"check-ts": "tsc --noEmit"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "c10a7ae7b0dc2c79430506d16447ff9bb9966043"
|
|
37
37
|
}
|