diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-04-07 15:22:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-07 15:22:14 +0200 |
commit | 966ce7de8a23f63d0f30b1748fe69ccaf07519e0 (patch) | |
tree | 3275ca96a835fe91a62a73d5a4c83bf6ca917b66 /runtime/ops | |
parent | 2865f39bec6da135a2d2d679a65e7ff139131bd7 (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/ops')
-rw-r--r-- | runtime/ops/file.rs | 31 | ||||
-rw-r--r-- | runtime/ops/mod.rs | 1 |
2 files changed, 32 insertions, 0 deletions
diff --git a/runtime/ops/file.rs b/runtime/ops/file.rs new file mode 100644 index 000000000..e7f68b207 --- /dev/null +++ b/runtime/ops/file.rs @@ -0,0 +1,31 @@ +// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. +use deno_core::url::Url; +use deno_file::op_file_create_object_url; +use deno_file::op_file_revoke_object_url; +use deno_file::BlobUrlStore; +use deno_file::Location; + +pub fn init( + rt: &mut deno_core::JsRuntime, + blob_url_store: BlobUrlStore, + maybe_location: Option<Url>, +) { + { + let op_state = rt.op_state(); + let mut op_state = op_state.borrow_mut(); + op_state.put(blob_url_store); + if let Some(location) = maybe_location { + op_state.put(Location(location)); + } + } + super::reg_json_sync( + rt, + "op_file_create_object_url", + op_file_create_object_url, + ); + super::reg_json_sync( + rt, + "op_file_revoke_object_url", + op_file_revoke_object_url, + ); +} diff --git a/runtime/ops/mod.rs b/runtime/ops/mod.rs index 6574546b1..67eae27b2 100644 --- a/runtime/ops/mod.rs +++ b/runtime/ops/mod.rs @@ -2,6 +2,7 @@ pub mod crypto; pub mod fetch; +pub mod file; pub mod fs; pub mod fs_events; pub mod io; |