summaryrefslogtreecommitdiff
path: root/runtime/web_worker.rs
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2021-04-07 15:22:14 +0200
committerGitHub <noreply@github.com>2021-04-07 15:22:14 +0200
commit966ce7de8a23f63d0f30b1748fe69ccaf07519e0 (patch)
tree3275ca96a835fe91a62a73d5a4c83bf6ca917b66 /runtime/web_worker.rs
parent2865f39bec6da135a2d2d679a65e7ff139131bd7 (diff)
feat: blob URL support (#10045)
This commit adds blob URL support. Blob URLs are stored in a process global storage, that can be accessed from all workers, and the module loader. Blob URLs can be created using `URL.createObjectURL` and revoked using `URL.revokeObjectURL`. This commit does not add support for `fetch`ing blob URLs. This will be added in a follow up commit.
Diffstat (limited to 'runtime/web_worker.rs')
-rw-r--r--runtime/web_worker.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs
index f5c81e6d4..c30b715e4 100644
--- a/runtime/web_worker.rs
+++ b/runtime/web_worker.rs
@@ -23,6 +23,7 @@ use deno_core::JsRuntime;
use deno_core::ModuleLoader;
use deno_core::ModuleSpecifier;
use deno_core::RuntimeOptions;
+use deno_file::BlobUrlStore;
use log::debug;
use std::env;
use std::rc::Rc;
@@ -155,6 +156,7 @@ pub struct WebWorkerOptions {
/// Sets `Deno.noColor` in JS runtime.
pub no_color: bool,
pub get_error_class_fn: Option<GetErrorClassFn>,
+ pub blob_url_store: BlobUrlStore,
}
impl WebWorker {
@@ -217,7 +219,7 @@ impl WebWorker {
}
ops::web_worker::init(js_runtime, sender.clone(), handle);
- ops::runtime::init(js_runtime, main_module);
+ ops::runtime::init(js_runtime, main_module.clone());
ops::fetch::init(
js_runtime,
options.user_agent.clone(),
@@ -232,6 +234,11 @@ impl WebWorker {
ops::reg_json_sync(js_runtime, "op_close", deno_core::op_close);
ops::reg_json_sync(js_runtime, "op_resources", deno_core::op_resources);
ops::url::init(js_runtime);
+ ops::file::init(
+ js_runtime,
+ options.blob_url_store.clone(),
+ Some(main_module),
+ );
ops::io::init(js_runtime);
ops::webgpu::init(js_runtime);
ops::websocket::init(
@@ -518,6 +525,7 @@ mod tests {
ts_version: "x".to_string(),
no_color: true,
get_error_class_fn: None,
+ blob_url_store: BlobUrlStore::default(),
};
let mut worker = WebWorker::from_options(