got busy this past week with a bunch of other duties, so slow progress.
i set up a thread pool class with a promise API and type safety… which is kinda overkill but that’s a bit of the whole goal with this project :p but so far i offloaded initially parsing the web page for a <meta http-equiv="refresh"> and determining the link. which is not a long task, so not a huge main thread blocker! but it would allow me to cement the code structure with the worker pool.
the thing was, i really wanted to optimize this build, and the useCache hook i wrote only supported JSON stringifyable values, which means no array buffers. the fetch API allows you to get the response directly as an ArrayBuffer, which, once you mark as transferrable, means that a thread can work directly on the buffer without having to copy all of the data. and since memory contention is one of the two problems i’m trying to solve here… that’s incredibly useful.
the thing was, i couldn’t just insert it directly into the JSON cache entry since it would be parsed by JSON.parse as a string, so i set up another content-addressed directory (cache/blobs instead of cache/files, where most things go) and modified the types to ensure that it was still type safe.
turns out… making that type work out in the function was a PAIN,, especially considering i had generics involved. i was able to work through it with an atrocious amount of as keywords sprinkled throughout, but it’s not very elegant.
in terms of the site, i opened up figma and started working on some prototypes! i’ve been meaning to learn figma and figured this was the perfect opportunity to go through the process. i love how, for the most part, everything is really intuitive. but the “frame” and “group” and “component” concepts being separate things was really confusing to me.
i’m really tired and about to lose my train of thought but for tomorrow i’ll work on porting the rest of the DOM processing over to the worker threads and to cheerio. i’ll also probably have to rethink how code is organized because now the “adapter” is split across two files. there’s definitely a way to make things more elegant, though.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.