forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutor.ts
More file actions
36 lines (31 loc) · 932 Bytes
/
executor.ts
File metadata and controls
36 lines (31 loc) · 932 Bytes
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
export interface IFiles {
[path: string]: {
code: string | null;
savedCode: string | null;
isBinary: boolean;
path: string;
};
}
export interface ISetupParams {
files: IFiles;
sandboxId: string;
}
/**
* An executor is responsible for the communication with the service that executes
* the code. Examples of these services are:
*
* - Sandbox Service: this is the browser bundler
* - SSE Service: this is an external container that executes the code
*
* The executor will set these services up, and update them when files change. It also
* serves as the interface to communicate with the service.
*/
export interface IExecutor {
sandboxId?: string;
initialize(params: ISetupParams): Promise<void>;
setup(): Promise<void>;
dispose(): Promise<void>;
updateFiles(newFiles: IFiles): void;
on(event: string, listener: (data: any) => void): void;
emit(event: string, data?: any): void;
}