script: Limit public exports. (#34915)

* script: Restrict reexport visibility of DOM types.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Mass pub->pub(crate) conversion.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Hide existing dead code warnings.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy warnings.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix unit tests.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* More formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-01-10 03:19:19 -05:00 committed by GitHub
parent f220d6d3a5
commit c94d909a86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
585 changed files with 5411 additions and 5013 deletions

View file

@ -25,21 +25,21 @@ use crate::script_runtime::CanGc;
#[derive(JSTraceable, MallocSizeOf)]
#[allow(crown::unrooted_must_root)]
pub struct DefaultTeeReadRequestMicrotask {
pub(crate) struct DefaultTeeReadRequestMicrotask {
#[ignore_malloc_size_of = "mozjs"]
chunk: Box<Heap<JSVal>>,
tee_read_request: Dom<DefaultTeeReadRequest>,
}
impl DefaultTeeReadRequestMicrotask {
pub fn microtask_chunk_steps(&self, can_gc: CanGc) {
pub(crate) fn microtask_chunk_steps(&self, can_gc: CanGc) {
self.tee_read_request.chunk_steps(&self.chunk, can_gc)
}
}
#[dom_struct]
/// <https://streams.spec.whatwg.org/#ref-for-read-request%E2%91%A2>
pub struct DefaultTeeReadRequest {
pub(crate) struct DefaultTeeReadRequest {
reflector_: Reflector,
stream: Dom<ReadableStream>,
branch_1: Dom<ReadableStream>,
@ -61,7 +61,7 @@ pub struct DefaultTeeReadRequest {
impl DefaultTeeReadRequest {
#[allow(clippy::too_many_arguments)]
#[allow(crown::unrooted_must_root)]
pub fn new(
pub(crate) fn new(
stream: &ReadableStream,
branch_1: &ReadableStream,
branch_2: &ReadableStream,
@ -94,12 +94,12 @@ impl DefaultTeeReadRequest {
}
/// Call into cancel of the stream,
/// <https://streams.spec.whatwg.org/#readable-stream-cancel>
pub fn stream_cancel(&self, reason: SafeHandleValue, can_gc: CanGc) {
pub(crate) fn stream_cancel(&self, reason: SafeHandleValue, can_gc: CanGc) {
self.stream.cancel(reason, can_gc);
}
/// Enqueue a microtask to perform the chunk steps
/// <https://streams.spec.whatwg.org/#ref-for-read-request-chunk-steps%E2%91%A2>
pub fn enqueue_chunk_steps(&self, chunk: RootedTraceableBox<Heap<JSVal>>) {
pub(crate) fn enqueue_chunk_steps(&self, chunk: RootedTraceableBox<Heap<JSVal>>) {
// Queue a microtask to perform the following steps:
let tee_read_request_chunk = DefaultTeeReadRequestMicrotask {
chunk: Heap::boxed(*chunk.handle()),
@ -116,7 +116,7 @@ impl DefaultTeeReadRequest {
/// <https://streams.spec.whatwg.org/#ref-for-read-request-chunk-steps%E2%91%A2>
#[allow(unsafe_code)]
#[allow(clippy::borrowed_box)]
pub fn chunk_steps(&self, chunk: &Box<Heap<JSVal>>, can_gc: CanGc) {
pub(crate) fn chunk_steps(&self, chunk: &Box<Heap<JSVal>>, can_gc: CanGc) {
// Set readAgain to false.
self.read_again.set(false);
// Let chunk1 and chunk2 be chunk.
@ -181,7 +181,7 @@ impl DefaultTeeReadRequest {
}
}
/// <https://streams.spec.whatwg.org/#read-request-close-steps>
pub fn close_steps(&self) {
pub(crate) fn close_steps(&self) {
// Set reading to false.
self.reading.set(false);
// If canceled_1 is false, perform ! ReadableStreamDefaultControllerClose(branch_1.[[controller]]).
@ -198,7 +198,7 @@ impl DefaultTeeReadRequest {
}
}
/// <https://streams.spec.whatwg.org/#read-request-error-steps>
pub fn error_steps(&self) {
pub(crate) fn error_steps(&self) {
// Set reading to false.
self.reading.set(false);
}
@ -232,7 +232,7 @@ impl DefaultTeeReadRequest {
stream.get_default_controller().error(error);
}
pub fn pull_algorithm(&self, can_gc: CanGc) {
pub(crate) fn pull_algorithm(&self, can_gc: CanGc) {
self.tee_underlying_source.pull_algorithm(can_gc);
}
}