1 | import { FileDescriptions, StrykerOptions } from '@stryker-mutator/api/core';
|
2 |
|
3 | import { LoggingClientContext } from '../logging/index.js';
|
4 |
|
5 | export enum WorkerMessageKind {
|
6 | Init,
|
7 | Call,
|
8 | Dispose,
|
9 | }
|
10 |
|
11 | export enum ParentMessageKind {
|
12 | |
13 |
|
14 |
|
15 | Ready,
|
16 | |
17 |
|
18 |
|
19 | Initialized,
|
20 | |
21 |
|
22 |
|
23 | InitError,
|
24 | |
25 |
|
26 |
|
27 | CallResult,
|
28 | |
29 |
|
30 |
|
31 | CallRejection,
|
32 | |
33 |
|
34 |
|
35 | DisposeCompleted,
|
36 | }
|
37 |
|
38 | export type WorkerMessage = CallMessage | DisposeMessage | InitMessage;
|
39 | export type ParentMessage =
|
40 | | InitRejectionResult
|
41 | | RejectionResult
|
42 | | WorkResult
|
43 | | { kind: ParentMessageKind.DisposeCompleted | ParentMessageKind.Initialized | ParentMessageKind.Ready };
|
44 |
|
45 | export interface InitMessage {
|
46 | kind: WorkerMessageKind.Init;
|
47 | loggingContext: LoggingClientContext;
|
48 | options: StrykerOptions;
|
49 | fileDescriptions: FileDescriptions;
|
50 | pluginModulePaths: readonly string[];
|
51 | workingDirectory: string;
|
52 | namedExport: string;
|
53 | modulePath: string;
|
54 | }
|
55 |
|
56 | export interface DisposeMessage {
|
57 | kind: WorkerMessageKind.Dispose;
|
58 | }
|
59 |
|
60 | export interface WorkResult {
|
61 | kind: ParentMessageKind.CallResult;
|
62 | correlationId: number;
|
63 | result: any;
|
64 | }
|
65 |
|
66 | export interface RejectionResult {
|
67 | kind: ParentMessageKind.CallRejection;
|
68 | correlationId: number;
|
69 | error: string;
|
70 | }
|
71 |
|
72 | export interface InitRejectionResult {
|
73 | kind: ParentMessageKind.InitError;
|
74 | error: string;
|
75 | }
|
76 |
|
77 | export interface CallMessage {
|
78 | correlationId: number;
|
79 | kind: WorkerMessageKind.Call;
|
80 | args: any[];
|
81 | methodName: string;
|
82 | }
|