1
0

Monorepo with yarn workspaces requires yarn 3.2

This commit is contained in:
Zef Hemel
2022-04-21 13:57:45 +02:00
parent 32f3501773
commit 1f842ec1d6
167 changed files with 10424 additions and 8263 deletions
+25
View File
@@ -0,0 +1,25 @@
import { syscall } from "./syscall";
export async function dispatch(
eventName: string,
data: any,
timeout?: number
): Promise<any[]> {
return new Promise((resolve, reject) => {
let timeouter: any = -1;
if (timeout) {
timeouter = setTimeout(() => {
console.log("Timeout!");
reject("timeout");
}, timeout);
}
syscall("event.dispatch", eventName, data)
.then((r) => {
if (timeouter !== -1) {
clearTimeout(timeouter);
}
resolve(r);
})
.catch(reject);
});
}
+12
View File
@@ -0,0 +1,12 @@
import { syscall } from "./syscall";
export async function json(url: RequestInfo, init: RequestInit): Promise<any> {
return syscall("fetch.json", url, init);
}
export async function text(
url: RequestInfo,
init: RequestInit = {}
): Promise<string> {
return syscall("fetch.text", url, init);
}
+4
View File
@@ -0,0 +1,4 @@
{
"name": "@silverbulletmd/plugos-syscall",
"version": "1.0.0"
}
+8
View File
@@ -0,0 +1,8 @@
import { syscall } from "./syscall";
export async function run(
cmd: string,
args: string[]
): Promise<{ stdout: string; stderr: string }> {
return syscall("shell.run", cmd, args);
}
+40
View File
@@ -0,0 +1,40 @@
import { syscall } from "./syscall";
export type KV = {
key: string;
value: any;
};
export async function set(key: string, value: any): Promise<void> {
return syscall("store.set", key, value);
}
export async function batchSet(kvs: KV[]): Promise<void> {
return syscall("store.batchSet", kvs);
}
export async function get(key: string): Promise<any> {
return syscall("store.get", key);
}
export async function del(key: string): Promise<void> {
return syscall("store.delete", key);
}
export async function batchDel(keys: string[]): Promise<void> {
return syscall("store.batchDelete", keys);
}
export async function queryPrefix(
prefix: string
): Promise<{ key: string; value: any }[]> {
return syscall("store.scanPrefix", prefix);
}
export async function deletePrefix(prefix: string): Promise<void> {
return syscall("store.deletePrefix", prefix);
}
export async function deleteAll(): Promise<void> {
return syscall("store.deleteAll");
}
+5
View File
@@ -0,0 +1,5 @@
declare global {
function syscall(name: string, ...args: any[]): Promise<any>;
}
export const syscall = self.syscall;