generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 383
Add streams/web module #761
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
748f62f
Web streams
jackkleeman 43d03d2
Set up global ReadableStream etc classes
jackkleeman fe6e226
Avoid Option for readable stream controller
jackkleeman da836c9
Bundle stored_error into state
jackkleeman 8e370a4
Avoid usage of ctx.eval and ctx.globals
jackkleeman 5ea3137
Use primordials more sparingly
jackkleeman a3f67a1
Use Function::new less
jackkleeman 6dc019f
Use primordials for the array constructor lookup
jackkleeman 64afdd8
Rename ObjectExt
jackkleeman cd066bf
Move structured_clone into llrt_utils and use it in tee
jackkleeman 36d5e2b
Assorted cleanup
jackkleeman 513dfed
queuing strategy comments
jackkleeman f23d14c
Move option helpers into utils
jackkleeman 329c5b0
Move helpers from lib into our own utils
jackkleeman 234c245
Add docs for StreamWebModule
jackkleeman c70633e
Add stream/web types
jackkleeman e4f892b
Review comments
jackkleeman a85e623
Review comments
jackkleeman 363b4ad
Split readablestream out into its own module
jackkleeman 3cde6bf
Move writablestream into its own module
jackkleeman 823c27d
Check signal matches abortsignal earlier
jackkleeman 52e56a5
Use Acquire/Release for atomic store/load
jackkleeman 0b5172e
Avoid use of super
jackkleeman 4ef0ca4
Add DomExceptionName and wpt for DomException
jackkleeman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
richarddavison marked this conversation as resolved.
Show resolved
Hide resolved
|
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| use rquickjs::{ | ||
| class::{Trace, Tracer}, | ||
| Ctx, FromJs, IntoJs, JsLifetime, Result, Type, Value, | ||
| }; | ||
|
|
||
| /// Helper type for treating an undefined value as None, without treating null as None | ||
| #[derive(Clone)] | ||
| pub struct Undefined<T>(pub Option<T>); | ||
|
|
||
| impl<'js, T: FromJs<'js>> FromJs<'js> for Undefined<T> { | ||
| fn from_js(ctx: &Ctx<'js>, value: Value<'js>) -> Result<Self> { | ||
| if value.type_of() == Type::Undefined { | ||
| Ok(Self(None)) | ||
| } else { | ||
| Ok(Self(Some(FromJs::from_js(ctx, value)?))) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<'js, T: IntoJs<'js>> IntoJs<'js> for Undefined<T> { | ||
| fn into_js(self, ctx: &Ctx<'js>) -> Result<Value<'js>> { | ||
| match self.0 { | ||
| None => Ok(Value::new_undefined(ctx.clone())), | ||
| Some(val) => val.into_js(ctx), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<T> Default for Undefined<T> { | ||
| fn default() -> Self { | ||
| Self(None) | ||
| } | ||
| } | ||
|
|
||
| unsafe impl<'js, T: JsLifetime<'js>> JsLifetime<'js> for Undefined<T> { | ||
| type Changed<'to> = Undefined<T::Changed<'to>>; | ||
| } | ||
|
|
||
| impl<'js, T: Trace<'js>> Trace<'js> for Undefined<T> { | ||
| fn trace<'a>(&self, tracer: Tracer<'a, 'js>) { | ||
| self.0.trace(tracer) | ||
| } | ||
| } | ||
|
|
||
| /// Helper type for converting an None into null instead of undefined. | ||
| /// Needed while rquickjs::function::Null has no IntoJs implementation | ||
| #[derive(Clone)] | ||
| pub struct Null<T>(pub Option<T>); | ||
|
|
||
| impl<'js, T: FromJs<'js>> FromJs<'js> for Null<T> { | ||
| fn from_js(ctx: &Ctx<'js>, value: Value<'js>) -> Result<Self> { | ||
| if value.type_of() == Type::Null { | ||
| Ok(Self(None)) | ||
| } else { | ||
| Ok(Self(Some(FromJs::from_js(ctx, value)?))) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<'js, T: IntoJs<'js>> IntoJs<'js> for Null<T> { | ||
| fn into_js(self, ctx: &Ctx<'js>) -> Result<Value<'js>> { | ||
| match self.0 { | ||
| None => Ok(Value::new_null(ctx.clone())), | ||
| Some(val) => val.into_js(ctx), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| unsafe impl<'js, T: JsLifetime<'js>> JsLifetime<'js> for Null<T> { | ||
| type Changed<'to> = Null<T::Changed<'to>>; | ||
| } | ||
|
|
||
| impl<'js, T: Trace<'js>> Trace<'js> for Null<T> { | ||
| fn trace<'a>(&self, tracer: Tracer<'a, 'js>) { | ||
| self.0.trace(tracer) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.