mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Add desiredSize accessor to WritableStreamDefaultWriter
Returns 1 when writable (default high water mark), 0 when closed, and null when errored, matching the spec behavior for streams without a custom queuing strategy.
This commit is contained in:
@@ -50,6 +50,14 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id=writable_stream_writer_desired_size>
|
||||
{
|
||||
const ws = new WritableStream();
|
||||
const writer = ws.getWriter();
|
||||
testing.expectEqual(1, writer.desiredSize);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id=text_encoder_stream_encoding>
|
||||
{
|
||||
const tes = new TextEncoderStream();
|
||||
|
||||
@@ -79,6 +79,15 @@ pub fn getClosed(self: *WritableStreamDefaultWriter, page: *Page) !js.Promise {
|
||||
return page.js.local.?.resolvePromise(.{});
|
||||
}
|
||||
|
||||
pub fn getDesiredSize(self: *const WritableStreamDefaultWriter) ?i32 {
|
||||
const stream = self._stream orelse return null;
|
||||
return switch (stream._state) {
|
||||
.writable => 1,
|
||||
.closed => 0,
|
||||
.errored => null,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn getReady(self: *WritableStreamDefaultWriter, page: *Page) !js.Promise {
|
||||
_ = self;
|
||||
return page.js.local.?.resolvePromise(.{});
|
||||
@@ -98,4 +107,5 @@ pub const JsApi = struct {
|
||||
pub const releaseLock = bridge.function(WritableStreamDefaultWriter.releaseLock, .{});
|
||||
pub const closed = bridge.accessor(WritableStreamDefaultWriter.getClosed, null, .{});
|
||||
pub const ready = bridge.accessor(WritableStreamDefaultWriter.getReady, null, .{});
|
||||
pub const desiredSize = bridge.accessor(WritableStreamDefaultWriter.getDesiredSize, null, .{});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user