2022-03-07 17:21:02 +08:00
|
|
|
declare global {
|
2022-03-11 18:49:42 +08:00
|
|
|
function syscall(id: number, name: string, args: any[]): Promise<any>;
|
2022-03-07 17:21:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function syscall(name: string, ...args: any[]): Promise<any> {
|
2022-03-11 18:49:42 +08:00
|
|
|
let reqId = Math.floor(Math.random() * 1000000);
|
2022-02-27 17:17:43 +08:00
|
|
|
// console.log("Syscall", name, reqId);
|
2022-03-07 17:21:02 +08:00
|
|
|
return await self.syscall(reqId, name, args);
|
|
|
|
// return new Promise((resolve, reject) => {
|
|
|
|
// self.dispatchEvent(
|
|
|
|
// new CustomEvent("syscall", {
|
|
|
|
// detail: {
|
|
|
|
// id: reqId,
|
|
|
|
// name: name,
|
|
|
|
// args: args,
|
|
|
|
// callback: resolve,
|
|
|
|
// },
|
|
|
|
// })
|
|
|
|
// );
|
|
|
|
// });
|
2022-02-25 00:24:49 +08:00
|
|
|
}
|