File size: 767 Bytes
05c5ed5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export type LogEntry = {
  type: "log" | "error" | (string & {});
  args: ({ type: "data"; value: any } | { type: "image"; value: string })[];
};

export type CodeRunnerResult = {
  success: boolean;
  logs: LogEntry[];
  error?: string;
  executionTimeMs?: number;
  result?: any;
};

export type CodeRunnerOptions = {
  code: string;
  timeout?: number;
  onLog?: (entry: LogEntry) => void;
};

export type CodeWorkerRequest = {
  code: string;
  type: "javascript" | "python";
  timeout?: number;
  id: string;
};

export type CodeWorkerEvent = {
  id: string;
  type: "log";
  entry: LogEntry;
};
export type CodeWorkerResult = {
  id: string;
  type: "result";
  result: CodeRunnerResult;
};

export type CodeWorkerResponse = CodeWorkerEvent | CodeWorkerResult;