Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add deno_web APIs like setTimeout #34

Merged
merged 5 commits into from
Feb 9, 2023
Merged

feat: add deno_web APIs like setTimeout #34

merged 5 commits into from
Feb 9, 2023

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented Feb 9, 2023

Add JS APIs from deno_web crate.

Most notably:

  • Events and AbortController
  • TextEncoder and TextDecoder (will be needed for WASM)
  • File, FileReader and Blob
  • MessageChannel, structuredClone and friends
  • atob and atoa (will be needed for WASM)
  • setTimeout, setInterval, and friends
  • Performance APIs
  • Streams (ReadableStream, WritableStream, etc.)
  • URL and friends

See #7

Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
@bajtos
Copy link
Member Author

bajtos commented Feb 9, 2023

@juliangruber This pull request is adding many new public APIs, significantly increasing the amount of stuff we will need to support in the future.

Most of these APIs are lightweight (e.g. AbortController, events, Performance, URL), so I don't anticipate any need to restrict their usage when we start limiting resource consumption.

Many other APIs will be needed in the future:

  • TextEncoder, TextDecoder and btoa (or atob?) are required by wasm-bindgen
  • Web Streams are needed for Fetch API. We will need some concept of streams anyways, I think it's best to build on a standard, even if it's not the greatest API.

Could you please review the list of the new APIs and let me know if there is anything you would prefer to remove from the global scope (make it private)?

Do you have any opinions on how to test this? I don't want to replicate the Deno test suite or Web API conformance tests. At the same time, I think it would be nice to have some sort of smoke tests to verify that the APIs are correctly exposed. But that's quite a lot of work, considering how many new APIs are added in this PR.

docs/building-modules.md Outdated Show resolved Hide resolved
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
@juliangruber
Copy link
Member

  • Web Streams are needed for Fetch API. We will need some concept of streams anyways, I think it's best to build on a standard, even if it's not the greatest API.

+100, always go with the platform / ecosystem.

Could you please review the list of the new APIs and let me know if there is anything you would prefer to remove from the global scope (make it private)?

I'm not sure how to think about this. In general, everything that is expected in a modern JS platform should be here, unless its implementation is problematic for Zinnia's purposes.

Do you have any opinions on how to test this? I don't want to replicate the Deno test suite or Web API conformance tests. At the same time, I think it would be nice to have some sort of smoke tests to verify that the APIs are correctly exposed. But that's quite a lot of work, considering how many new APIs are added in this PR.

What about just checking whether the global is defined? And then progress with regression tests where necessary. We could also add some more tests to one specific module, which "proves" that in general integrating modules from Deno works.

@bajtos
Copy link
Member Author

bajtos commented Feb 9, 2023

Cool.

What about just checking whether the global is defined? And then progress with regression tests where necessary. We could also add some more tests to one specific module, which "proves" that in general integrating modules from Deno works.

I will land this PR as-is and open another PR to add some smoke tests. I'll see if I can find a reasonably easy way to add these tests en masse.

@bajtos bajtos merged commit 57c30e1 into main Feb 9, 2023
@bajtos bajtos deleted the feat-core-web-apis branch February 9, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants