transfer to purescript-web
gbagan opened this issue · 8 comments
This is a proposal to transfer this repo to purescript-web.
@JordanMartinez
Thanks for the ping.
Here's what I think is correct:
- Web.Worker.Location (i.e. WorkerLocation)
- Web.Worker.MessagePort (i.e. MessagesPort)
Here's what I think is incorrect or has missing functionality:
- Web.Worker.GlobalScope (i.e. WorkerGlobalScope). These functions are missing:
- Web.Worker.MessageEvent (i.e. MessageEvent):
- the nullable
sourceattribute, which is a MessageEventSource
- the nullable
- Web.Worker.Worker (i.e. Worker):
- "credentials is only used if [the WorkerType] is 'module'" (source: WorkerOptions). We should account for that in our bindings to prevent someone from including credentials if they are using
Classic. I think the easiest way would be to makeModuletake aCredentialsargument. - where is
terminate? - AFAICT, a
Workeris aDedicatedWorkerGlobalScope- where is
close?
- where is
- "credentials is only used if [the WorkerType] is 'module'" (source: WorkerOptions). We should account for that in our bindings to prevent someone from including credentials if they are using
- Shared Worker
- Where are the bindings for
SharedWorker?
- Where are the bindings for
I'm not sure about these things:
- Web.Worker.Navigator (i.e. WorkerNavigator)
- the stuff from the NavigatorID interface is missing. I'm not sure if this should be added, however, because they mostly return constants for privacy reasons.
Other than above, is there anything you think is problematic with the current bindings? Or things you think should be done a certain way but may not have time to do right now?
Also, I'd prefer that the FFI be written using EffectFnX, but I don't think that's a requirement to get this transferred.
Thank you for your review.
I will try to take all comments into account.
Actually, some functions were not implemented due to the low percentage of support e.g. offline
https://caniuse.com/mdn-api_workerglobalscope_offline_event
Unless I am wrong, close and terminate are implemented.
For SharedWorker, someone on Discord advised me to implement it in a different library.
What do you think?
Unless I am wrong, close and terminate are implemented.
Ah, you're correct. Sorry about that.
For SharedWorker, someone on Discord advised me to implement it in a different library. What do you think?
Hmm... What advantages would there be in implementing it in a separate library? Won't it need to use some of the types defined here, which means it's harder to maintain due to the dependency? I'm not sure that makes sense.
I think I have adressed all your comments (except for WorkerNavigator).
Some remarks.
-
I have created two modules DedicatedWorkerGlobalScope and SharedWorkerGlobalScope.
Each of these modules imports and reexports functions in GlobalScope. -
The classes Worker and SharedWorker inherit from AbstractWorker but, since the only method of AbstractWorker is onerror, I have duplicated the function onError in the module Worker and SharedWorker.
-
In general, MessageEventSource can be a MessagePort or a WindowProxy or a ServiceWorker.
But, in the context of (Shared) Workers, it can only be a MessagePort (or null).
So the function MessgeEvent.source returns a Maybe MessagePort.
Although it is not very generic, I think it prevents cross dependencies between different libraries -
I have replaced bower.json with spago.dhall
I think this is good enough for a transfer. I'd still like to make a few changes, but that can be done once the transfer is done. Sound good?
Thank you. Can I transfer the repo now or am I waiting for something?
Nah, let's transfer it. I'll clean it up once I get access to it.