-
Notifications
You must be signed in to change notification settings - Fork 161
Fetch request body as ReadableStream #628
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 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
05a0a12
WIP
ptrdom 6c5a02f
Fix ReadableStream binary compatibility and test compilation.
ptrdom 7c149c8
WIP
ptrdom d3b38ed
Fix casts in ReadableStream tests for Scala 2.12.
ptrdom 5d11d2c
Fix scaladoc for ReadableStreamReader.cancel overloads.
ptrdom 6b7ab22
Fix type casts for Scala 2.11.
ptrdom 2c54ad6
Generate api-reports.
ptrdom 1620172
WIP
ptrdom fadb50b
WIP
ptrdom 86cd967
WIP
ptrdom 775bb39
WIP
ptrdom 345ae04
Regenerate api-reports.
ptrdom eabf4b0
WIP
ptrdom 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
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
11 changes: 11 additions & 0 deletions
11
dom/src/main/scala-2/org/scalajs/dom/ReadableStreamType.scala
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,11 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** [[https://streams.spec.whatwg.org/#enumdef-readablestreamtype ReadableStreamType enum]] */ | ||
@js.native | ||
sealed trait ReadableStreamType extends js.Any | ||
|
||
object ReadableStreamType { | ||
val bytes: ReadableStreamType = "bytes".asInstanceOf[ReadableStreamType] | ||
} |
7 changes: 7 additions & 0 deletions
7
dom/src/main/scala-3/org/scalajs/dom/ReadableStreamType.scala
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,7 @@ | ||
package org.scalajs.dom | ||
|
||
opaque type ReadableStreamType <: String = String | ||
|
||
object ReadableStreamType { | ||
val bytes: ReadableStreamType = "bytes" | ||
} |
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,23 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** See [[https://streams.spec.whatwg.org/#qs-api ¶7.1. The queuing strategy API]] | ||
* | ||
* @tparam T | ||
* Type of the Chunks returned by the Stream | ||
*/ | ||
trait QueuingStrategy[T] extends js.Object { | ||
|
||
/** A non-negative number indicating the high water mark of the stream using this queuing strategy. */ | ||
var highWaterMark: Int | ||
|
||
/** (non-byte streams only) | ||
* | ||
* The result is used to determine backpressure, manifesting via the appropriate desiredSize property. For readable | ||
* streams, it also governs when the underlying source's [[ReadableStreamUnderlyingSource.pull]] method is called. | ||
* | ||
* A function that computes and returns the finite non-negative size of the given chunk value. | ||
*/ | ||
var size: js.Function1[T, Int] | ||
} |
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
57 changes: 57 additions & 0 deletions
57
dom/src/main/scala/org/scalajs/dom/ReadableStreamUnderlyingSource.scala
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,57 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** See [[https://streams.spec.whatwg.org/#underlying-source-api ¶4.2.3. The underlying source API]] of whatwg streams | ||
* spec. | ||
* | ||
* @tparam T | ||
* Type of the Chunks returned by the Stream | ||
*/ | ||
trait ReadableStreamUnderlyingSource[T] extends js.Object { | ||
|
||
/** A function that is called immediately during creation of the ReadableStream. | ||
* | ||
* If this setup process is asynchronous, it can return a promise to signal success or failure; a rejected promise | ||
* will error the stream. Any thrown exceptions will be re-thrown by the [[ReadableStream]] constructor. | ||
*/ | ||
var start: js.UndefOr[js.Function1[ReadableStreamController[T], js.UndefOr[js.Promise[Unit]]]] = js.undefined | ||
|
||
/** A function that is called whenever the stream’s internal queue of chunks becomes not full, i.e. whenever the | ||
* queue’s desired size becomes positive. Generally, it will be called repeatedly until the queue reaches its high | ||
* water mark (i.e. until the desired size becomes non-positive). | ||
* | ||
* This function will not be called until [[start]] successfully completes. Additionally, it will only be called | ||
* repeatedly if it enqueues at least one chunk or fulfills a BYOB request; a no-op [[pull]] implementation will not | ||
* be continually called. | ||
* | ||
* If the function returns a promise, then it will not be called again until that promise fulfills. (If the promise | ||
* rejects, the stream will become errored.) This is mainly used in the case of pull sources, where the promise | ||
* returned represents the process of acquiring a new chunk. Throwing an exception is treated the same as returning a | ||
* rejected promise. | ||
*/ | ||
var pull: js.UndefOr[js.Function1[ReadableStreamController[T], js.UndefOr[js.Promise[Unit]]]] = js.undefined | ||
|
||
/** A function that is called whenever the consumer cancels the stream, via [[ReadableStream.cancel]] or | ||
* [[ReadableStreamReader.cancel():scala\.scalajs\.js\.Promise[Unit]*]]. It takes as its argument the same value as | ||
* was passed to those methods by the consumer. If the shutdown process is asynchronous, it can return a promise to | ||
* signal success or failure; the result will be communicated via the return value of the [[cancel]] method that was | ||
* called. Additionally, a rejected promise will error the stream, instead of letting it close. Throwing an exception | ||
* is treated the same as returning a rejected promise. | ||
*/ | ||
var cancel: js.UndefOr[js.Function1[js.Any, js.UndefOr[js.Promise[Unit]]]] = js.undefined | ||
|
||
/** Can be set to "bytes" to signal that the constructed [[ReadableStream]] is a readable byte stream. | ||
* | ||
* Setting any value other than "bytes" or undefined will cause the ReadableStream() constructor to throw an | ||
* exception. | ||
*/ | ||
var `type`: js.UndefOr[ReadableStreamType] = js.undefined | ||
|
||
/** (byte streams only) | ||
* | ||
* Can be set to a positive integer to cause the implementation to automatically allocate buffers for the underlying | ||
* source code to write into. | ||
*/ | ||
var autoAllocateChunkSize: js.UndefOr[Int] = js.undefined | ||
} |
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
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.