| 
									
										
										
										
											2022-09-21 23:27:13 +01:00
										 |  |  |  | /*
 | 
					
						
							|  |  |  |  |  * Copyright (c) 2022, Linus Groh <linusg@serenityos.org> | 
					
						
							| 
									
										
										
										
											2023-03-28 17:43:34 -07:00
										 |  |  |  |  * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org> | 
					
						
							| 
									
										
										
										
											2025-01-18 00:43:11 +13:00
										 |  |  |  |  * Copyright (c) 2023-2025, Shannon Booth <shannon@serenityos.org> | 
					
						
							| 
									
										
										
										
											2024-04-06 18:56:42 +02:00
										 |  |  |  |  * Copyright (c) 2023-2024, Kenneth Myhra <kennethmyhra@serenityos.org> | 
					
						
							| 
									
										
										
										
											2022-09-21 23:27:13 +01:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #pragma once
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | #include <LibGC/Ptr.h>
 | 
					
						
							| 
									
										
										
										
											2022-09-21 23:27:13 +01:00
										 |  |  |  | #include <LibWeb/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2024-12-08 17:12:11 +13:00
										 |  |  |  | #include <LibWeb/Streams/Algorithms.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-09 01:26:48 -07:00
										 |  |  |  | #include <LibWeb/Streams/ReadableStream.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-16 17:40:09 -07:00
										 |  |  |  | #include <LibWeb/WebIDL/CallbackType.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:50 -07:00
										 |  |  |  | #include <LibWeb/WebIDL/ExceptionOr.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-28 17:43:34 -07:00
										 |  |  |  | #include <LibWeb/WebIDL/Promise.h>
 | 
					
						
							| 
									
										
										
										
											2024-07-08 16:39:52 +02:00
										 |  |  |  | #include <LibWeb/WebIDL/Types.h>
 | 
					
						
							| 
									
										
										
										
											2022-09-21 23:27:13 +01:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace Web::Streams { | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | WebIDL::ExceptionOr<GC::Ref<ReadableStreamDefaultReader>> acquire_readable_stream_default_reader(ReadableStream&); | 
					
						
							|  |  |  |  | WebIDL::ExceptionOr<GC::Ref<ReadableStreamBYOBReader>> acquire_readable_stream_byob_reader(ReadableStream&); | 
					
						
							| 
									
										
										
										
											2022-09-21 23:27:13 +01:00
										 |  |  |  | bool is_readable_stream_locked(ReadableStream const&); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | GC::Ref<SizeAlgorithm> extract_size_algorithm(JS::VM&, QueuingStrategy const&); | 
					
						
							| 
									
										
										
										
											2023-06-18 21:45:39 +12:00
										 |  |  |  | WebIDL::ExceptionOr<double> extract_high_water_mark(QueuingStrategy const&, double default_hwm); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-28 17:43:34 -07:00
										 |  |  |  | void readable_stream_close(ReadableStream&); | 
					
						
							| 
									
										
										
										
											2023-03-28 18:56:11 -07:00
										 |  |  |  | void readable_stream_error(ReadableStream&, JS::Value error); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | WebIDL::ExceptionOr<GC::Ref<ReadableStream>> readable_stream_from_iterable(JS::VM& vm, JS::Value async_iterable); | 
					
						
							|  |  |  |  | void readable_stream_add_read_request(ReadableStream&, GC::Ref<ReadRequest>); | 
					
						
							|  |  |  |  | void readable_stream_add_read_into_request(ReadableStream&, GC::Ref<ReadIntoRequest>); | 
					
						
							|  |  |  |  | GC::Ref<WebIDL::Promise> readable_stream_cancel(ReadableStream&, JS::Value reason); | 
					
						
							| 
									
										
										
										
											2023-11-19 11:34:47 +13:00
										 |  |  |  | void readable_stream_fulfill_read_into_request(ReadableStream&, JS::Value chunk, bool done); | 
					
						
							| 
									
										
										
										
											2023-03-28 18:56:11 -07:00
										 |  |  |  | void readable_stream_fulfill_read_request(ReadableStream&, JS::Value chunk, bool done); | 
					
						
							| 
									
										
										
										
											2023-04-09 10:26:13 -07:00
										 |  |  |  | size_t readable_stream_get_num_read_into_requests(ReadableStream const&); | 
					
						
							|  |  |  |  | size_t readable_stream_get_num_read_requests(ReadableStream const&); | 
					
						
							|  |  |  |  | bool readable_stream_has_byob_reader(ReadableStream const&); | 
					
						
							|  |  |  |  | bool readable_stream_has_default_reader(ReadableStream const&); | 
					
						
							| 
									
										
										
										
											2023-03-28 17:43:34 -07:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-24 12:25:01 +13:00
										 |  |  |  | GC::Ref<WebIDL::Promise> readable_stream_pipe_to(ReadableStream& source, WritableStream& dest, bool prevent_close, bool prevent_abort, bool prevent_cancel, JS::Value signal = JS::js_undefined()); | 
					
						
							| 
									
										
										
										
											2024-04-06 18:56:42 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-28 10:28:59 -05:00
										 |  |  |  | WebIDL::ExceptionOr<ReadableStreamPair> readable_stream_tee(JS::Realm&, ReadableStream&, bool clone_for_branch2); | 
					
						
							| 
									
										
										
										
											2024-01-28 10:31:26 -05:00
										 |  |  |  | WebIDL::ExceptionOr<ReadableStreamPair> readable_stream_default_tee(JS::Realm& realm, ReadableStream& stream, bool clone_for_branch2); | 
					
						
							| 
									
										
										
										
											2024-01-28 14:21:05 -05:00
										 |  |  |  | WebIDL::ExceptionOr<ReadableStreamPair> readable_byte_stream_tee(JS::Realm& realm, ReadableStream& stream); | 
					
						
							| 
									
										
										
										
											2024-01-28 10:28:59 -05:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | GC::Ref<WebIDL::Promise> readable_stream_reader_generic_cancel(ReadableStreamGenericReaderMixin&, JS::Value reason); | 
					
						
							| 
									
										
										
										
											2023-04-09 01:26:48 -07:00
										 |  |  |  | void readable_stream_reader_generic_initialize(ReadableStreamReader, ReadableStream&); | 
					
						
							| 
									
										
										
										
											2024-04-29 16:45:50 -04:00
										 |  |  |  | void readable_stream_reader_generic_release(ReadableStreamGenericReaderMixin&); | 
					
						
							| 
									
										
										
										
											2023-03-28 18:30:22 -07:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | void readable_stream_default_reader_error_read_requests(ReadableStreamDefaultReader&, JS::Value error); | 
					
						
							| 
									
										
										
										
											2023-08-27 13:28:08 +12:00
										 |  |  |  | void readable_stream_byob_reader_error_read_into_requests(ReadableStreamBYOBReader&, JS::Value error); | 
					
						
							| 
									
										
										
										
											2023-11-19 11:54:46 +13:00
										 |  |  |  | JS::Value readable_byte_stream_controller_convert_pull_into_descriptor(JS::Realm&, PullIntoDescriptor const&); | 
					
						
							| 
									
										
										
										
											2024-07-08 16:39:52 +02:00
										 |  |  |  | void readable_byte_stream_controller_pull_into(ReadableByteStreamController&, WebIDL::ArrayBufferView&, u64 min, ReadIntoRequest&); | 
					
						
							|  |  |  |  | void readable_stream_byob_reader_read(ReadableStreamBYOBReader&, WebIDL::ArrayBufferView&, u64 min, ReadIntoRequest&); | 
					
						
							| 
									
										
										
										
											2023-11-19 12:03:45 +13:00
										 |  |  |  | void readable_byte_stream_controller_fill_head_pull_into_descriptor(ReadableByteStreamController const&, u64 size, PullIntoDescriptor&); | 
					
						
							| 
									
										
										
										
											2023-08-27 13:28:08 +12:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-29 16:45:50 -04:00
										 |  |  |  | void readable_stream_default_reader_read(ReadableStreamDefaultReader&, ReadRequest&); | 
					
						
							|  |  |  |  | void readable_stream_default_reader_release(ReadableStreamDefaultReader&); | 
					
						
							| 
									
										
										
										
											2023-08-27 13:29:01 +12:00
										 |  |  |  | void readable_stream_byob_reader_release(ReadableStreamBYOBReader&); | 
					
						
							| 
									
										
										
										
											2023-03-28 18:30:22 -07:00
										 |  |  |  | WebIDL::ExceptionOr<void> set_up_readable_stream_default_reader(ReadableStreamDefaultReader&, ReadableStream&); | 
					
						
							| 
									
										
										
										
											2023-06-29 20:52:35 +12:00
										 |  |  |  | WebIDL::ExceptionOr<void> set_up_readable_stream_byob_reader(ReadableStreamBYOBReader&, ReadableStream&); | 
					
						
							| 
									
										
										
										
											2023-03-28 18:56:11 -07:00
										 |  |  |  | void readable_stream_default_controller_close(ReadableStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2023-07-07 19:30:07 +02:00
										 |  |  |  | bool readable_stream_default_controller_has_backpressure(ReadableStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2023-03-28 18:56:11 -07:00
										 |  |  |  | WebIDL::ExceptionOr<void> readable_stream_default_controller_enqueue(ReadableStreamDefaultController&, JS::Value chunk); | 
					
						
							| 
									
										
										
										
											2024-04-29 16:17:32 -04:00
										 |  |  |  | void readable_stream_default_controller_can_pull_if_needed(ReadableStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2023-03-28 18:56:11 -07:00
										 |  |  |  | bool readable_stream_default_controller_should_call_pull(ReadableStreamDefaultController&); | 
					
						
							|  |  |  |  | void readable_stream_default_controller_clear_algorithms(ReadableStreamDefaultController&); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void readable_stream_default_controller_error(ReadableStreamDefaultController&, JS::Value error); | 
					
						
							| 
									
										
										
										
											2023-04-22 10:44:07 -07:00
										 |  |  |  | Optional<double> readable_stream_default_controller_get_desired_size(ReadableStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2023-03-28 18:56:11 -07:00
										 |  |  |  | bool readable_stream_default_controller_can_close_or_enqueue(ReadableStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller(ReadableStream&, ReadableStreamDefaultController&, GC::Ref<StartAlgorithm>, GC::Ref<PullAlgorithm>, GC::Ref<CancelAlgorithm>, double high_water_mark, GC::Ref<SizeAlgorithm>); | 
					
						
							|  |  |  |  | WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller_from_underlying_source(ReadableStream&, JS::Value underlying_source_value, UnderlyingSource, double high_water_mark, GC::Ref<SizeAlgorithm>); | 
					
						
							|  |  |  |  | WebIDL::ExceptionOr<void> set_up_readable_byte_stream_controller(ReadableStream&, ReadableByteStreamController&, GC::Ref<StartAlgorithm>, GC::Ref<PullAlgorithm>, GC::Ref<CancelAlgorithm>, double high_water_mark, JS::Value auto_allocate_chunk_size); | 
					
						
							| 
									
										
										
										
											2023-06-18 21:47:02 +12:00
										 |  |  |  | WebIDL::ExceptionOr<void> set_up_readable_byte_stream_controller_from_underlying_source(ReadableStream&, JS::Value underlying_source, UnderlyingSource const& underlying_source_dict, double high_water_mark); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | GC::Ptr<ReadableStreamBYOBRequest> readable_byte_stream_controller_get_byob_request(GC::Ref<ReadableByteStreamController>); | 
					
						
							| 
									
										
										
										
											2023-03-28 17:43:34 -07:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-02 21:13:29 +13:00
										 |  |  |  | WebIDL::ExceptionOr<void> readable_byte_stream_controller_respond_in_readable_state(ReadableByteStreamController&, u64 bytes_written, PullIntoDescriptor&); | 
					
						
							| 
									
										
										
										
											2023-12-02 21:15:44 +13:00
										 |  |  |  | void readable_byte_stream_controller_respond_in_closed_state(ReadableByteStreamController&, PullIntoDescriptor&); | 
					
						
							| 
									
										
										
										
											2023-12-02 21:20:15 +13:00
										 |  |  |  | WebIDL::ExceptionOr<void> readable_byte_stream_controller_respond_internal(ReadableByteStreamController&, u64 bytes_written); | 
					
						
							| 
									
										
										
										
											2023-12-02 21:26:38 +13:00
										 |  |  |  | WebIDL::ExceptionOr<void> readable_byte_stream_controller_respond(ReadableByteStreamController&, u64 bytes_written); | 
					
						
							| 
									
										
										
										
											2024-01-28 13:00:12 -05:00
										 |  |  |  | WebIDL::ExceptionOr<void> readable_byte_stream_controller_respond_with_new_view(JS::Realm&, ReadableByteStreamController&, WebIDL::ArrayBufferView&); | 
					
						
							| 
									
										
										
										
											2023-12-02 21:13:29 +13:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-13 07:26:59 +12:00
										 |  |  |  | WebIDL::ExceptionOr<void> readable_byte_stream_controller_enqueue(ReadableByteStreamController& controller, JS::Value chunk); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> transfer_array_buffer(JS::Realm& realm, JS::ArrayBuffer& buffer); | 
					
						
							| 
									
										
										
										
											2023-06-13 07:26:59 +12:00
										 |  |  |  | WebIDL::ExceptionOr<void> readable_byte_stream_controller_enqueue_detached_pull_into_queue(ReadableByteStreamController& controller, PullIntoDescriptor& pull_into_descriptor); | 
					
						
							| 
									
										
										
										
											2023-11-19 12:11:47 +13:00
										 |  |  |  | void readable_byte_stream_controller_commit_pull_into_descriptor(ReadableStream&, PullIntoDescriptor const&); | 
					
						
							| 
									
										
										
										
											2024-04-29 16:29:02 -04:00
										 |  |  |  | void readable_byte_stream_controller_process_read_requests_using_queue(ReadableByteStreamController& controller); | 
					
						
							| 
									
										
										
										
											2025-01-18 00:43:11 +13:00
										 |  |  |  | [[nodiscard]] SinglyLinkedList<GC::Root<PullIntoDescriptor>> readable_byte_stream_controller_process_pull_into_descriptors_using_queue(ReadableByteStreamController&); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | void readable_byte_stream_controller_enqueue_chunk_to_queue(ReadableByteStreamController& controller, GC::Ref<JS::ArrayBuffer> buffer, u32 byte_offset, u32 byte_length); | 
					
						
							| 
									
										
										
										
											2023-06-13 07:26:59 +12:00
										 |  |  |  | WebIDL::ExceptionOr<void> readable_byte_stream_controller_enqueue_cloned_chunk_to_queue(ReadableByteStreamController& controller, JS::ArrayBuffer& buffer, u64 byte_offset, u64 byte_length); | 
					
						
							| 
									
										
										
										
											2025-01-18 00:43:11 +13:00
										 |  |  |  | GC::Ref<PullIntoDescriptor> readable_byte_stream_controller_shift_pending_pull_into(ReadableByteStreamController& controller); | 
					
						
							| 
									
										
										
										
											2023-06-13 07:26:59 +12:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-29 16:17:32 -04:00
										 |  |  |  | void readable_byte_stream_controller_call_pull_if_needed(ReadableByteStreamController&); | 
					
						
							| 
									
										
										
										
											2023-04-08 06:31:36 -07:00
										 |  |  |  | void readable_byte_stream_controller_clear_algorithms(ReadableByteStreamController&); | 
					
						
							|  |  |  |  | void readable_byte_stream_controller_clear_pending_pull_intos(ReadableByteStreamController&); | 
					
						
							| 
									
										
										
										
											2023-04-09 10:40:15 -07:00
										 |  |  |  | WebIDL::ExceptionOr<void> readable_byte_stream_controller_close(ReadableByteStreamController&); | 
					
						
							| 
									
										
										
										
											2023-04-09 10:26:13 -07:00
										 |  |  |  | void readable_byte_stream_controller_error(ReadableByteStreamController&, JS::Value error); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | void readable_byte_stream_controller_fill_read_request_from_queue(ReadableByteStreamController&, GC::Ref<ReadRequest>); | 
					
						
							| 
									
										
										
										
											2023-11-19 12:18:25 +13:00
										 |  |  |  | bool readable_byte_stream_controller_fill_pull_into_descriptor_from_queue(ReadableByteStreamController&, PullIntoDescriptor&); | 
					
						
							| 
									
										
										
										
											2023-04-11 16:33:32 -07:00
										 |  |  |  | Optional<double> readable_byte_stream_controller_get_desired_size(ReadableByteStreamController const&); | 
					
						
							| 
									
										
										
										
											2024-04-29 16:17:32 -04:00
										 |  |  |  | void readable_byte_stream_controller_handle_queue_drain(ReadableByteStreamController&); | 
					
						
							| 
									
										
										
										
											2023-04-08 06:31:36 -07:00
										 |  |  |  | void readable_byte_stream_controller_invalidate_byob_request(ReadableByteStreamController&); | 
					
						
							| 
									
										
										
										
											2023-04-09 10:26:13 -07:00
										 |  |  |  | bool readable_byte_stream_controller_should_call_pull(ReadableByteStreamController const&); | 
					
						
							| 
									
										
										
										
											2023-04-11 16:33:32 -07:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | WebIDL::ExceptionOr<GC::Ref<ReadableStream>> create_readable_stream(JS::Realm& realm, GC::Ref<StartAlgorithm> start_algorithm, GC::Ref<PullAlgorithm> pull_algorithm, GC::Ref<CancelAlgorithm> cancel_algorithm, Optional<double> high_water_mark = {}, GC::Ptr<SizeAlgorithm> size_algorithm = {}); | 
					
						
							|  |  |  |  | WebIDL::ExceptionOr<GC::Ref<ReadableStream>> create_readable_byte_stream(JS::Realm& realm, GC::Ref<StartAlgorithm> start_algorithm, GC::Ref<PullAlgorithm> pull_algorithm, GC::Ref<CancelAlgorithm> cancel_algorithm); | 
					
						
							|  |  |  |  | WebIDL::ExceptionOr<GC::Ref<WritableStream>> create_writable_stream(JS::Realm& realm, GC::Ref<StartAlgorithm> start_algorithm, GC::Ref<WriteAlgorithm> write_algorithm, GC::Ref<CloseAlgorithm> close_algorithm, GC::Ref<AbortAlgorithm> abort_algorithm, double high_water_mark, GC::Ref<SizeAlgorithm> size_algorithm); | 
					
						
							| 
									
										
										
										
											2023-07-08 08:18:47 +02:00
										 |  |  |  | void initialize_readable_stream(ReadableStream&); | 
					
						
							| 
									
										
										
										
											2023-07-08 06:48:25 +02:00
										 |  |  |  | void initialize_writable_stream(WritableStream&); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | WebIDL::ExceptionOr<GC::Ref<WritableStreamDefaultWriter>> acquire_writable_stream_default_writer(WritableStream&); | 
					
						
							| 
									
										
										
										
											2023-04-02 15:15:53 -07:00
										 |  |  |  | bool is_writable_stream_locked(WritableStream const&); | 
					
						
							| 
									
										
										
										
											2023-03-30 19:27:45 -07:00
										 |  |  |  | WebIDL::ExceptionOr<void> set_up_writable_stream_default_writer(WritableStreamDefaultWriter&, WritableStream&); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | GC::Ref<WebIDL::Promise> writable_stream_abort(WritableStream&, JS::Value reason); | 
					
						
							|  |  |  |  | GC::Ref<WebIDL::Promise> writable_stream_close(WritableStream&); | 
					
						
							| 
									
										
										
										
											2023-03-30 19:27:45 -07:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | GC::Ref<WebIDL::Promise> writable_stream_add_write_request(WritableStream&); | 
					
						
							| 
									
										
										
										
											2023-03-30 19:27:45 -07:00
										 |  |  |  | bool writable_stream_close_queued_or_in_flight(WritableStream const&); | 
					
						
							| 
									
										
										
										
											2024-04-29 17:16:24 -04:00
										 |  |  |  | void writable_stream_deal_with_rejection(WritableStream&, JS::Value error); | 
					
						
							|  |  |  |  | void writable_stream_finish_erroring(WritableStream&); | 
					
						
							| 
									
										
										
										
											2023-04-02 08:19:10 -07:00
										 |  |  |  | void writable_stream_finish_in_flight_close(WritableStream&); | 
					
						
							| 
									
										
										
										
											2024-04-29 17:16:24 -04:00
										 |  |  |  | void writable_stream_finish_in_flight_close_with_error(WritableStream&, JS::Value error); | 
					
						
							| 
									
										
										
										
											2023-04-02 08:19:10 -07:00
										 |  |  |  | void writable_stream_finish_in_flight_write(WritableStream&); | 
					
						
							| 
									
										
										
										
											2024-04-29 17:16:24 -04:00
										 |  |  |  | void writable_stream_finish_in_flight_write_with_error(WritableStream&, JS::Value error); | 
					
						
							| 
									
										
										
										
											2023-04-01 19:53:28 -07:00
										 |  |  |  | bool writable_stream_has_operation_marked_in_flight(WritableStream const&); | 
					
						
							| 
									
										
										
										
											2023-04-02 08:19:10 -07:00
										 |  |  |  | void writable_stream_mark_close_request_in_flight(WritableStream&); | 
					
						
							|  |  |  |  | void writable_stream_mark_first_write_request_in_flight(WritableStream&); | 
					
						
							| 
									
										
										
										
											2023-04-01 19:53:28 -07:00
										 |  |  |  | void writable_stream_reject_close_and_closed_promise_if_needed(WritableStream&); | 
					
						
							| 
									
										
										
										
											2024-04-29 17:16:24 -04:00
										 |  |  |  | void writable_stream_start_erroring(WritableStream&, JS::Value reason); | 
					
						
							| 
									
										
										
										
											2023-04-02 08:19:10 -07:00
										 |  |  |  | void writable_stream_update_backpressure(WritableStream&, bool backpressure); | 
					
						
							| 
									
										
										
										
											2023-03-30 19:27:45 -07:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | GC::Ref<WebIDL::Promise> writable_stream_default_writer_abort(WritableStreamDefaultWriter&, JS::Value reason); | 
					
						
							|  |  |  |  | GC::Ref<WebIDL::Promise> writable_stream_default_writer_close(WritableStreamDefaultWriter&); | 
					
						
							| 
									
										
										
										
											2023-04-02 10:52:01 -07:00
										 |  |  |  | void writable_stream_default_writer_ensure_closed_promise_rejected(WritableStreamDefaultWriter&, JS::Value error); | 
					
						
							| 
									
										
										
										
											2023-04-01 19:53:28 -07:00
										 |  |  |  | void writable_stream_default_writer_ensure_ready_promise_rejected(WritableStreamDefaultWriter&, JS::Value error); | 
					
						
							|  |  |  |  | Optional<double> writable_stream_default_writer_get_desired_size(WritableStreamDefaultWriter const&); | 
					
						
							| 
									
										
										
										
											2024-04-29 18:15:07 -04:00
										 |  |  |  | void writable_stream_default_writer_release(WritableStreamDefaultWriter&); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | GC::Ref<WebIDL::Promise> writable_stream_default_writer_write(WritableStreamDefaultWriter&, JS::Value chunk); | 
					
						
							| 
									
										
										
										
											2023-04-01 19:53:28 -07:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | WebIDL::ExceptionOr<void> set_up_writable_stream_default_controller(WritableStream&, WritableStreamDefaultController&, GC::Ref<StartAlgorithm>, GC::Ref<WriteAlgorithm>, GC::Ref<CloseAlgorithm>, GC::Ref<AbortAlgorithm>, double high_water_mark, GC::Ref<SizeAlgorithm>); | 
					
						
							|  |  |  |  | WebIDL::ExceptionOr<void> set_up_writable_stream_default_controller_from_underlying_sink(WritableStream&, JS::Value underlying_sink_value, UnderlyingSink&, double high_water_mark, GC::Ref<SizeAlgorithm> size_algorithm); | 
					
						
							| 
									
										
										
										
											2024-04-29 17:16:24 -04:00
										 |  |  |  | void writable_stream_default_controller_advance_queue_if_needed(WritableStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2023-04-01 19:53:28 -07:00
										 |  |  |  | void writable_stream_default_controller_clear_algorithms(WritableStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2024-04-29 18:01:44 -04:00
										 |  |  |  | void writable_stream_default_controller_close(WritableStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2024-04-29 17:16:24 -04:00
										 |  |  |  | void writable_stream_default_controller_error(WritableStreamDefaultController&, JS::Value error); | 
					
						
							|  |  |  |  | void writable_stream_default_controller_error_if_needed(WritableStreamDefaultController&, JS::Value error); | 
					
						
							| 
									
										
										
										
											2023-04-02 08:19:10 -07:00
										 |  |  |  | bool writable_stream_default_controller_get_backpressure(WritableStreamDefaultController const&); | 
					
						
							| 
									
										
										
										
											2024-04-29 17:16:24 -04:00
										 |  |  |  | JS::Value writable_stream_default_controller_get_chunk_size(WritableStreamDefaultController&, JS::Value chunk); | 
					
						
							| 
									
										
										
										
											2023-04-01 19:53:28 -07:00
										 |  |  |  | double writable_stream_default_controller_get_desired_size(WritableStreamDefaultController const&); | 
					
						
							| 
									
										
										
										
											2024-04-29 16:17:32 -04:00
										 |  |  |  | void writable_stream_default_controller_process_close(WritableStreamDefaultController&); | 
					
						
							|  |  |  |  | void writable_stream_default_controller_process_write(WritableStreamDefaultController&, JS::Value chunk); | 
					
						
							| 
									
										
										
										
											2024-04-29 17:16:24 -04:00
										 |  |  |  | void writable_stream_default_controller_write(WritableStreamDefaultController&, JS::Value chunk, JS::Value chunk_size); | 
					
						
							| 
									
										
										
										
											2023-04-02 15:15:53 -07:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | void initialize_transform_stream(TransformStream&, GC::Ref<WebIDL::Promise> start_promise, double writable_high_water_mark, GC::Ref<SizeAlgorithm> writable_size_algorithm, double readable_high_water_mark, GC::Ref<SizeAlgorithm> readable_size_algorithm); | 
					
						
							|  |  |  |  | void set_up_transform_stream_default_controller(TransformStream&, TransformStreamDefaultController&, GC::Ref<TransformAlgorithm>, GC::Ref<FlushAlgorithm>, GC::Ref<CancelAlgorithm>); | 
					
						
							| 
									
										
										
										
											2024-04-29 18:15:07 -04:00
										 |  |  |  | void set_up_transform_stream_default_controller_from_transformer(TransformStream&, JS::Value transformer, Transformer&); | 
					
						
							| 
									
										
										
										
											2023-07-07 16:06:18 +02:00
										 |  |  |  | void transform_stream_default_controller_clear_algorithms(TransformStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2023-07-07 19:30:34 +02:00
										 |  |  |  | WebIDL::ExceptionOr<void> transform_stream_default_controller_enqueue(TransformStreamDefaultController&, JS::Value chunk); | 
					
						
							| 
									
										
										
										
											2024-04-29 18:01:44 -04:00
										 |  |  |  | void transform_stream_default_controller_error(TransformStreamDefaultController&, JS::Value error); | 
					
						
							|  |  |  |  | void transform_stream_default_controller_terminate(TransformStreamDefaultController&); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |  | GC::Ref<WebIDL::Promise> transform_stream_default_controller_perform_transform(TransformStreamDefaultController&, JS::Value chunk); | 
					
						
							|  |  |  |  | GC::Ref<WebIDL::Promise> transform_stream_default_sink_abort_algorithm(TransformStream&, JS::Value reason); | 
					
						
							|  |  |  |  | GC::Ref<WebIDL::Promise> transform_stream_default_sink_close_algorithm(TransformStream&); | 
					
						
							|  |  |  |  | GC::Ref<WebIDL::Promise> transform_stream_default_sink_write_algorithm(TransformStream&, JS::Value chunk); | 
					
						
							|  |  |  |  | GC::Ref<WebIDL::Promise> transform_stream_default_source_pull_algorithm(TransformStream&); | 
					
						
							|  |  |  |  | GC::Ref<WebIDL::Promise> transform_stream_default_source_cancel_algorithm(TransformStream&, JS::Value reason); | 
					
						
							| 
									
										
										
										
											2024-04-29 18:01:44 -04:00
										 |  |  |  | void transform_stream_error(TransformStream&, JS::Value error); | 
					
						
							|  |  |  |  | void transform_stream_error_writable_and_unblock_write(TransformStream&, JS::Value error); | 
					
						
							|  |  |  |  | void transform_stream_set_backpressure(TransformStream&, bool backpressure); | 
					
						
							| 
									
										
										
										
											2024-06-02 21:35:49 +02:00
										 |  |  |  | void transform_stream_unblock_write(TransformStream&); | 
					
						
							| 
									
										
										
										
											2023-07-07 16:06:18 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:54 -07:00
										 |  |  |  | bool is_non_negative_number(JS::Value); | 
					
						
							| 
									
										
										
										
											2024-12-01 21:36:06 +01:00
										 |  |  |  | bool can_copy_data_block_bytes_buffer(JS::ArrayBuffer const& to_buffer, u64 to_index, JS::ArrayBuffer const& from_buffer, u64 from_index, u64 count); | 
					
						
							| 
									
										
										
										
											2023-12-02 20:28:17 +13:00
										 |  |  |  | bool can_transfer_array_buffer(JS::ArrayBuffer const& array_buffer); | 
					
						
							| 
									
										
										
										
											2024-01-28 12:20:55 -05:00
										 |  |  |  | WebIDL::ExceptionOr<JS::Value> clone_as_uint8_array(JS::Realm&, WebIDL::ArrayBufferView&); | 
					
						
							| 
									
										
										
										
											2024-01-28 10:22:52 -05:00
										 |  |  |  | WebIDL::ExceptionOr<JS::Value> structured_clone(JS::Realm&, JS::Value value); | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:54 -07:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:50 -07:00
										 |  |  |  | // https://streams.spec.whatwg.org/#value-with-size
 | 
					
						
							|  |  |  |  | struct ValueWithSize { | 
					
						
							|  |  |  |  |     JS::Value value; | 
					
						
							|  |  |  |  |     double size; | 
					
						
							|  |  |  |  | }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // https://streams.spec.whatwg.org/#dequeue-value
 | 
					
						
							|  |  |  |  | template<typename T> | 
					
						
							|  |  |  |  | JS::Value dequeue_value(T& container) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     // 1. Assert: container has [[queue]] and [[queueTotalSize]] internal slots.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 2. Assert: container.[[queue]] is not empty.
 | 
					
						
							|  |  |  |  |     VERIFY(!container.queue().is_empty()); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 3. Let valueWithSize be container.[[queue]][0].
 | 
					
						
							|  |  |  |  |     // 4. Remove valueWithSize from container.[[queue]].
 | 
					
						
							|  |  |  |  |     auto value_with_size = container.queue().take_first(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 5. Set container.[[queueTotalSize]] to container.[[queueTotalSize]] − valueWithSize’s size.
 | 
					
						
							|  |  |  |  |     container.set_queue_total_size(container.queue_total_size() - value_with_size.size); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 6. If container.[[queueTotalSize]] < 0, set container.[[queueTotalSize]] to 0. (This can occur due to rounding errors.)
 | 
					
						
							|  |  |  |  |     if (container.queue_total_size() < 0.0) | 
					
						
							|  |  |  |  |         container.set_queue_total_size(0.0); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 7. Return valueWithSize’s value.
 | 
					
						
							|  |  |  |  |     return value_with_size.value; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // https://streams.spec.whatwg.org/#enqueue-value-with-size
 | 
					
						
							|  |  |  |  | template<typename T> | 
					
						
							| 
									
										
										
										
											2024-04-29 17:20:55 -04:00
										 |  |  |  | WebIDL::ExceptionOr<void> enqueue_value_with_size(T& container, JS::Value value, JS::Value size) | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:50 -07:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |     // 1. Assert: container has [[queue]] and [[queueTotalSize]] internal slots.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 2. If ! IsNonNegativeNumber(size) is false, throw a RangeError exception.
 | 
					
						
							| 
									
										
										
										
											2024-04-29 17:20:55 -04:00
										 |  |  |  |     if (!is_non_negative_number(size)) | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:54 -07:00
										 |  |  |  |         return WebIDL::SimpleException { WebIDL::SimpleExceptionType::RangeError, "Chunk has non-positive size"sv }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:50 -07:00
										 |  |  |  |     // 3. If size is +∞, throw a RangeError exception.
 | 
					
						
							| 
									
										
										
										
											2024-04-29 17:20:55 -04:00
										 |  |  |  |     if (size.is_positive_infinity()) | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:50 -07:00
										 |  |  |  |         return WebIDL::SimpleException { WebIDL::SimpleExceptionType::RangeError, "Chunk has infinite size"sv }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 4. Append a new value-with-size with value value and size size to container.[[queue]].
 | 
					
						
							| 
									
										
										
										
											2024-04-29 17:20:55 -04:00
										 |  |  |  |     container.queue().append({ value, size.as_double() }); | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:50 -07:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 5. Set container.[[queueTotalSize]] to container.[[queueTotalSize]] + size.
 | 
					
						
							| 
									
										
										
										
											2024-04-29 17:20:55 -04:00
										 |  |  |  |     container.set_queue_total_size(container.queue_total_size() + size.as_double()); | 
					
						
							| 
									
										
										
										
											2023-04-09 15:21:50 -07:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     return {}; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // https://streams.spec.whatwg.org/#peek-queue-value
 | 
					
						
							|  |  |  |  | template<typename T> | 
					
						
							|  |  |  |  | JS::Value peek_queue_value(T& container) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     // 1. Assert: container has [[queue]] and [[queueTotalSize]] internal slots.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 2. Assert: container.[[queue]] is not empty.
 | 
					
						
							|  |  |  |  |     VERIFY(!container.queue().is_empty()); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 3. Let valueWithSize be container.[[queue]][0].
 | 
					
						
							|  |  |  |  |     auto& value_with_size = container.queue().first(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 4. Return valueWithSize’s value.
 | 
					
						
							|  |  |  |  |     return value_with_size.value; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // https://streams.spec.whatwg.org/#reset-queue
 | 
					
						
							|  |  |  |  | template<typename T> | 
					
						
							|  |  |  |  | void reset_queue(T& container) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     // 1. Assert: container has [[queue]] and [[queueTotalSize]] internal slots.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 2. Set container.[[queue]] to a new empty list.
 | 
					
						
							|  |  |  |  |     container.queue().clear(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 3. Set container.[[queueTotalSize]] to 0.
 | 
					
						
							|  |  |  |  |     container.set_queue_total_size(0); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-21 23:27:13 +01:00
										 |  |  |  | } |