Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

1.5 KB
Raw Blame
use super::media_queries::simple_object_event_set_handler;
use super::shared::SIMPLE_EVENT_TARGET_LISTENERS_SLOT;
use crate::{
    util::context_host_ptr_from_global_bridge,
    util::{
        callback_data_index_value, callback_data_item, get_private_value, set_private_value,
        throw_range_error, throw_type_error,
    },
    worker::{
        WorkerGlobalKind, WorkerHandle, WorkerNetworkPolicy, WorkerSpawnOptions,
        spawn_worker_with_options, worker_secure_context_for_script_url,
    },
};

const WORKER_HANDLE_SLOT: &str = "__moliWorkerHandle";
const WORKER_ID_SLOT: &str = "__moliWorkerId";
const WORKER_ONMESSAGE_SLOT: &str = "__moliWorkerOnMessage";
const WORKER_ONMESSAGEERROR_SLOT: &str = "__moliWorkerOnMessageError";
const WORKER_ONERROR_SLOT: &str = "__moliWorkerOnError";

mod constructor;
mod dispatch;
mod methods;

pub(in crate::context_bootstrap) use constructor::{
    WorkerOptionsMembers, document_query_encoding_override, is_cross_origin_http_worker_script,
    materialize_worker_script_source, resolve_worker_script_url, throw_worker_dom_exception,
    trusted_worker_script_url_string_or_throw, worker_constructor_base_url,
    worker_script_resource_url, worker_script_scheme_can_load,
};

pub(super) use constructor::worker_constructor_callback;
pub(crate) use dispatch::{
    dispatch_worker_error_event_with_kind, dispatch_worker_event,
    flush_pending_worker_messages_for_listener, worker_has_message_delivery_listener,
};
pub(super) use methods::{worker_post_message_callback, worker_terminate_callback};

#[cfg(test)]
mod tests;