UNPKG

1.78 kBPlain TextView Raw
1import { FileDescriptions, StrykerOptions } from '@stryker-mutator/api/core';
2
3import { LoggingClientContext } from '../logging/index.js';
4
5export enum WorkerMessageKind {
6 Init,
7 Call,
8 Dispose,
9}
10
11export enum ParentMessageKind {
12 /**
13 * Indicates that the child process is spawned and ready to receive messages
14 */
15 Ready,
16 /**
17 * Indicates that initialization is done
18 */
19 Initialized,
20 /**
21 * Indicates an error happened during initialization
22 */
23 InitError,
24 /**
25 * Indicates that a 'Call' was successful
26 */
27 CallResult,
28 /**
29 * Indicates that a 'Call' was rejected
30 */
31 CallRejection,
32 /**
33 * Indicates that a 'Dispose' was completed
34 */
35 DisposeCompleted,
36}
37
38export type WorkerMessage = CallMessage | DisposeMessage | InitMessage;
39export type ParentMessage =
40 | InitRejectionResult
41 | RejectionResult
42 | WorkResult
43 | { kind: ParentMessageKind.DisposeCompleted | ParentMessageKind.Initialized | ParentMessageKind.Ready };
44
45export 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
56export interface DisposeMessage {
57 kind: WorkerMessageKind.Dispose;
58}
59
60export interface WorkResult {
61 kind: ParentMessageKind.CallResult;
62 correlationId: number;
63 result: any;
64}
65
66export interface RejectionResult {
67 kind: ParentMessageKind.CallRejection;
68 correlationId: number;
69 error: string;
70}
71
72export interface InitRejectionResult {
73 kind: ParentMessageKind.InitError;
74 error: string;
75}
76
77export interface CallMessage {
78 correlationId: number;
79 kind: WorkerMessageKind.Call;
80 args: any[];
81 methodName: string;
82}