1use crate::{
2 class::{stream, EventEmitter},
3 interface::{
4 CpuUsage,
5 Domain,
6 HrTime,
7 MemoryUsage,
8 NodeModule,
9 ProcessFeatures,
10 ProcessRelease,
11 ProcessSendOptions,
12 ProcessVersions,
13 },
14};
15use js_sys::{Function, JsString, Number, Object, Set};
16use wasm_bindgen::prelude::*;
17
18#[wasm_bindgen]
19extern {
20 #[wasm_bindgen(extends = EventEmitter)]
21 #[derive(Clone, Debug)]
22 pub type Process;
23
24 #[wasm_bindgen(method, catch)]
29 pub fn abort(this: &Process) -> Result<(), JsValue>;
30
31 #[wasm_bindgen(method)]
32 pub fn chdir(this: &Process, directory: JsString);
33
34 #[wasm_bindgen(method)]
36 pub fn config(this: &Process) -> Object;
37
38 #[wasm_bindgen(method, js_name = "cpuUsage")]
39 pub fn cpu_usage(this: &Process, previous_value: Option<&CpuUsage>) -> CpuUsage;
40
41 #[wasm_bindgen(method)]
42 pub fn cwd(this: &Process) -> JsString;
43
44 #[wasm_bindgen(method)]
45 pub fn disconnect(this: &Process);
46
47 #[wasm_bindgen(method, js_name = "emitWarning")]
48 pub fn emit_warning(this: &Process, warning: &JsString, name: Option<&JsString>, ctor: Option<&Function>);
49
50 #[wasm_bindgen(method)]
51 pub fn exit(this: &Process);
52
53 #[wasm_bindgen(method, js_name = "getegid")]
54 pub fn get_egid(this: &Process) -> i32;
55
56 #[wasm_bindgen(method, js_name = "geteuid")]
57 pub fn get_euid(this: &Process) -> i32;
58
59 #[wasm_bindgen(method, js_name = "getgid")]
60 pub fn get_gid(this: &Process) -> i32;
61
62 #[wasm_bindgen(method, js_name = "getgroups")]
63 pub fn get_groups(this: &Process) -> Box<[JsValue]>;
64
65 #[wasm_bindgen(method, js_name = "getuid")]
66 pub fn get_uid(this: &Process) -> i32;
67
68 #[wasm_bindgen(method, catch)]
69 pub fn kill(this: &Process, pid: u32) -> Result<(), JsValue>;
70
71 #[wasm_bindgen(method, catch, js_name = "kill")]
72 pub fn kill_with_signal_name(this: &Process, pid: u32, signal_name: &JsString) -> Result<(), JsValue>;
73
74 #[wasm_bindgen(method, catch, js_name = "kill")]
75 pub fn kill_with_signal_id(this: &Process, pid: u32, signal_id: i32) -> Result<(), JsValue>;
76
77 #[wasm_bindgen(method, js_name = "memoryUsage")]
78 pub fn memory_usage(this: &Process) -> MemoryUsage;
79
80 #[wasm_bindgen(method, variadic, js_name = "nextTick")]
81 pub fn next_tick(this: &Process, callback: &Function, args: Box<[JsValue]>);
82
83 #[wasm_bindgen(method, js_name = "resourceUsage")]
85 pub fn resource_usage(this: &Process) -> Object;
86
87 #[wasm_bindgen(method)]
89 pub fn send(
90 this: &Process,
91 message: &JsValue,
92 send_handle: Option<&Object>,
93 options: Option<ProcessSendOptions>,
94 callback: Option<&Function>,
95 ) -> bool;
96
97 #[wasm_bindgen(method, catch, js_name = "setegid")]
98 pub fn set_egid(this: &Process, id: u32) -> Result<(), JsValue>;
99
100 #[wasm_bindgen(method, catch, js_name = "seteuid")]
101 pub fn set_euid(this: &Process, id: u32) -> Result<(), JsValue>;
102
103 #[wasm_bindgen(method, catch, js_name = "setgid")]
104 pub fn set_gid(this: &Process, id: u32) -> Result<(), JsValue>;
105
106 #[wasm_bindgen(method, catch, js_name = "setuid")]
107 pub fn set_uid(this: &Process, id: u32) -> Result<(), JsValue>;
108
109 #[wasm_bindgen(method, catch, js_name = "setgroups")]
110 pub fn set_groups(this: &Process, id: u32) -> Result<(), JsValue>;
111
112 #[wasm_bindgen(method, js_name = "setUncaughtExceptionCaptureCallback")]
113 pub fn set_uncaught_exception_capture_callback(this: &Process, callback: &Function);
114
115 #[wasm_bindgen(method)]
116 pub fn umask(this: &Process, mask: Option<u32>) -> u32;
117
118 #[wasm_bindgen(method)]
119 pub fn uptime(this: &Process) -> f64;
120
121 #[wasm_bindgen(method, getter, js_name = "allowedNodeEnvironmentFlags")]
126 pub fn allowed_node_environment_flags(this: &Process) -> Set;
127
128 #[wasm_bindgen(method, getter)]
129 pub fn arch(this: &Process) -> JsString;
130
131 #[wasm_bindgen(method, getter)]
132 pub fn argv(this: &Process) -> Box<[JsValue]>;
133
134 #[wasm_bindgen(method, getter)]
135 pub fn argv0(this: &Process) -> JsString;
136
137 #[wasm_bindgen(method, getter)]
139 pub fn connected(this: &Process) -> bool;
140
141 #[wasm_bindgen(method, getter)]
142 pub fn debug_port(this: &Process) -> Number;
143
144 #[wasm_bindgen(method, getter)]
145 pub fn domain(this: &Process) -> Option<Domain>;
146
147 #[wasm_bindgen(method, getter)]
148 pub fn env(this: &Process) -> Object;
149
150 #[wasm_bindgen(method, getter, js_name = "execArgv")]
151 pub fn exec_argv(this: &Process) -> Box<[JsValue]>;
152
153 #[wasm_bindgen(method, getter, js_name = "execPath")]
154 pub fn exec_path(this: &Process) -> JsString;
155
156 #[wasm_bindgen(method, getter, js_name = "exitCode")]
157 pub fn exit_code(this: &Process) -> Option<i32>;
158
159 #[wasm_bindgen(method, getter)]
160 pub fn features(this: &Process) -> ProcessFeatures;
161
162 #[wasm_bindgen(method, getter, js_name = "hrtime")]
163 pub fn hr_time(this: &Process) -> HrTime;
164
165 #[wasm_bindgen(method, getter, js_name = "mainModule")]
166 pub fn main_module(this: &Process) -> Option<NodeModule>;
167
168 #[wasm_bindgen(method, getter, js_name = "noDeprecation")]
169 pub fn no_deprecation(this: &Process) -> bool;
170
171 #[wasm_bindgen(method, getter)]
172 pub fn pid(this: &Process) -> JsString;
173
174 #[wasm_bindgen(method, getter)]
175 pub fn platform(this: &Process) -> JsString;
176
177 #[wasm_bindgen(method, getter)]
178 pub fn ppid(this: &Process) -> JsString;
179
180 #[wasm_bindgen(method, getter)]
181 pub fn release(this: &Process) -> ProcessRelease;
182
183 #[wasm_bindgen(method, getter)]
185 pub fn report(this: &Process) -> Object;
186
187 #[wasm_bindgen(method, getter)]
188 pub fn stderr(this: &Process) -> stream::Writable;
189
190 #[wasm_bindgen(method, getter)]
191 pub fn stdin(this: &Process) -> stream::Readable;
192
193 #[wasm_bindgen(method, getter)]
194 pub fn stdout(this: &Process) -> stream::Writable;
195
196 #[wasm_bindgen(method, getter, js_name = "throwDeprecation")]
197 pub fn throw_deprecation(this: &Process) -> bool;
198
199 #[wasm_bindgen(method, getter)]
200 pub fn title(this: &Process) -> JsString;
201
202 #[wasm_bindgen(method, getter, js_name = "traceDeprecation")]
203 pub fn trace_deprecation(this: &Process) -> bool;
204
205 #[wasm_bindgen(method, getter)]
206 pub fn version(this: &Process) -> JsString;
207
208 #[wasm_bindgen(method, getter)]
209 pub fn versions(this: &Process) -> ProcessVersions;
210}