Open NullVoxPopuli opened 2 years ago
Also, update networking code? https://docs.holepunch.to/
Standard auth: https://webauthn.guide
Something that might help with long-term maintenance,
Use MessageChannels instead of worker-bi
¹ https://developer.mozilla.org/en-US/docs/Web/API/AbortController ² https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API
from @sukima:
For workers I used MessageChannel to convert the postMessage
into a promise async/await version
function asyncPostMessage<t = unknown>(worker: Worker, message: unknown, transfers: Transferable[] = []): Promise<T> {
let { port1, port2 } = new MessageChannel();
return new Promise<T>((resolve) => {
port1.onmessage = ({ data }: MessageEvent<T>) => resolve(data);
worker.postMessage(message, [port2, ...transfers]);
});
}
and in the worker:
self.addEventListener('message', ({ data, ports: [port] }: MessageEvent<…>) => {
// Do stuff with data
port.postMessage(result);
});
As far as gjs/gts and v2 addons are concerned, a lot can be done to improve this repo' including adding turborepo to speed up ci.
I should do some of this and modernize this codebase.
Thankfully, it's not tooooo big.