-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Hello,
I am working with a not-thread-safe library and so I have to use SharedWorkers.
JavaScript Sample of WebAPI You Wish to Use
const myWorker = new SharedWorker("worker.js");
MDN Link to the Involved Function or Interfaces
MDN Documentation Link: https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker
Thank you for maintaining this project. It is important!
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
nojaf commentedon Jun 19, 2025
Hi there, thank you for opening this issue.
Are you interested in contributing these bindings?
If so, I can give you some pointers to get started!
switch-to-gitlab commentedon Jun 19, 2025
@nojaf Yeah I could use a hand. This sounds like a silly question, but when I run the code generator... where is
tmp
folder with the generated files (ref)?I see a
generated
folder... is that it?switch-to-gitlab commentedon Jun 19, 2025
@nojaf Update: wait there's a
tmp
directory in the root... but if that's it I definitely did something wrong--there doesn't appear to be anything in there that looks like theSharedWorker
I'm trying to generate.nojaf commentedon Jun 20, 2025
Hello, try uncommenting
experimental-rescript-webapi/tools/TypeScript-DOM-lib-generator/src/build.ts
Lines 323 to 328 in 79e60ba
Then you need to update
const windowInterface = allInterfaces.find((i) => i.name === "WindowOrWorkerGlobalScope");
I would add
somewhere, so you have an idea what is present.
switch-to-gitlab commentedon Jun 21, 2025
Forgive me, but
Where does this go?
nojaf commentedon Jun 21, 2025
No worries, I was referring to
experimental-rescript-webapi/tools/TypeScript-DOM-lib-generator/src/build/emitter.ts
Lines 1570 to 1571 in 79e60ba
This will help generate the Global bindings. What is globally available will be different in your SharedWorker context.
switch-to-gitlab commentedon Jun 29, 2025
@nojaf Alright, I could use a hand. This commit is my attempt so far, which is pretty far off base.
This seems fairly right to me, but it does not produce valid ReScript in tmp/Temp.res. Instead it produces:
So
workerOptions
is there twice and somehow there's a chunk missing? With the part that begins "turns" that should obviously be/** Returns
.It does also produce a Global.res file that scans as close enough to what I'm looking for for the
SharedWorkerGlobalScope
, which is encouraging, but I suspect I'll have questions about how to situate that so the inheritance makes sense with the rest of the API.nojaf commentedon Jun 30, 2025
Hmm, I've tried what you have so far and I got:
out of it.
Seems, okay-ish.
Changing the open to
open FetchAPI
, compiled for me.