This commit is contained in:
Rizky 2024-06-21 04:59:04 +07:00
parent 40df47cd2d
commit 3bd3ee0429
2 changed files with 24 additions and 19 deletions

View File

@ -7,6 +7,7 @@ type SingleExport = {
val: string; val: string;
}; };
export const parseTypeDef = async (path: string) => { export const parseTypeDef = async (path: string) => {
console.log("parsing", path);
const ast = await parseFile(path, { syntax: "typescript" }); const ast = await parseFile(path, { syntax: "typescript" });
const exports = {} as Record<string, SingleExport[]>; const exports = {} as Record<string, SingleExport[]>;

View File

@ -94,27 +94,31 @@ export const initTypings = async (
} }
} }
const res = JSON.stringify(await parseTypeDef(path)); try {
await Bun.write( const res = JSON.stringify(await parseTypeDef(path));
dir.data(`/code/${id_site}/site/type_def.${file.lastModified}.json`), await Bun.write(
res dir.data(
); `/code/${id_site}/site/type_def.${file.lastModified}.json`
),
res
);
const client_ids = new Set<string>(); const client_ids = new Set<string>();
user.active.findAll({ site_id: id_site }).forEach((e) => { user.active.findAll({ site_id: id_site }).forEach((e) => {
client_ids.add(e.client_id); client_ids.add(e.client_id);
}); });
const now = Date.now(); const now = Date.now();
client_ids.forEach((client_id) => { client_ids.forEach((client_id) => {
const ws = conns.get(client_id)?.ws; const ws = conns.get(client_id)?.ws;
if (ws) if (ws)
sendWS(ws, { sendWS(ws, {
type: SyncType.Event, type: SyncType.Event,
event: "code_changes", event: "code_changes",
data: { ts: now, mode: "typings" }, data: { ts: now, mode: "typings" },
}); });
}); });
} catch (e) {}
}, 180); }, 180);
}); });
} catch (e) { } catch (e) {