summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/Cargo.toml2
-rw-r--r--runtime/build.rs1
-rw-r--r--runtime/errors.rs2
-rw-r--r--runtime/examples/hello_runtime.rs1
-rw-r--r--runtime/js/99_main.js24
-rw-r--r--runtime/lib.rs1
-rw-r--r--runtime/worker.rs3
7 files changed, 34 insertions, 0 deletions
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml
index 8acd61f7e..4cefa23ee 100644
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -29,6 +29,7 @@ deno_web = { path = "../extensions/web", version = "0.35.0" }
deno_webgpu = { path = "../extensions/webgpu", version = "0.6.0" }
deno_webidl = { path = "../extensions/webidl", version = "0.5.0" }
deno_websocket = { path = "../extensions/websocket", version = "0.10.0" }
+deno_webstorage = { path = "../extensions/webstorage", version = "0.1.0" }
[target.'cfg(windows)'.build-dependencies]
winres = "0.1.11"
@@ -46,6 +47,7 @@ deno_web = { path = "../extensions/web", version = "0.35.0" }
deno_webgpu = { path = "../extensions/webgpu", version = "0.6.0" }
deno_webidl = { path = "../extensions/webidl", version = "0.5.0" }
deno_websocket = { path = "../extensions/websocket", version = "0.10.0" }
+deno_webstorage = { path = "../extensions/webstorage", version = "0.1.0" }
atty = "0.2.14"
bytes = "1"
diff --git a/runtime/build.rs b/runtime/build.rs
index b6a9da582..e1cae7195 100644
--- a/runtime/build.rs
+++ b/runtime/build.rs
@@ -48,6 +48,7 @@ fn create_runtime_snapshot(snapshot_path: &Path, files: Vec<PathBuf>) {
"".to_owned(),
None,
),
+ deno_webstorage::init(None),
deno_crypto::init(None),
deno_webgpu::init(false),
deno_timers::init::<deno_timers::NoTimersPermission>(),
diff --git a/runtime/errors.rs b/runtime/errors.rs
index f9ef947a3..c5e93d65b 100644
--- a/runtime/errors.rs
+++ b/runtime/errors.rs
@@ -157,6 +157,8 @@ fn get_nix_error_class(error: &nix::Error) -> &'static str {
pub fn get_error_class_name(e: &AnyError) -> Option<&'static str> {
deno_core::error::get_custom_error_class(e)
.or_else(|| deno_webgpu::error::get_error_class_name(e))
+ .or_else(|| deno_webstorage::get_quota_exceeded_error_class_name(e))
+ .or_else(|| deno_webstorage::get_not_supported_error_class_name(e))
.or_else(|| {
e.downcast_ref::<dlopen::Error>()
.map(get_dlopen_error_class)
diff --git a/runtime/examples/hello_runtime.rs b/runtime/examples/hello_runtime.rs
index 9c3cbd67e..80a258c17 100644
--- a/runtime/examples/hello_runtime.rs
+++ b/runtime/examples/hello_runtime.rs
@@ -40,6 +40,7 @@ async fn main() -> Result<(), AnyError> {
no_color: false,
get_error_class_fn: Some(&get_error_class_name),
location: None,
+ location_data_dir: None,
blob_url_store: BlobUrlStore::default(),
};
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index fee7cd2d7..d2926bb1f 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -28,6 +28,7 @@ delete Object.prototype.__proto__;
const fileReader = window.__bootstrap.fileReader;
const webgpu = window.__bootstrap.webgpu;
const webSocket = window.__bootstrap.webSocket;
+ const webStorage = window.__bootstrap.webStorage;
const file = window.__bootstrap.file;
const formData = window.__bootstrap.formData;
const fetch = window.__bootstrap.fetch;
@@ -190,6 +191,18 @@ delete Object.prototype.__proto__;
return new DOMException(msg, "OperationError");
},
);
+ core.registerErrorBuilder(
+ "DOMExceptionQuotaExceededError",
+ function DOMExceptionQuotaExceededError(msg) {
+ return new DOMException(msg, "QuotaExceededError");
+ },
+ );
+ core.registerErrorBuilder(
+ "DOMExceptionNotSupportedError",
+ function DOMExceptionNotSupportedError(msg) {
+ return new DOMException(msg, "NotSupported");
+ },
+ );
}
class Navigator {
@@ -351,6 +364,17 @@ delete Object.prototype.__proto__;
alert: util.writable(prompt.alert),
confirm: util.writable(prompt.confirm),
prompt: util.writable(prompt.prompt),
+ localStorage: {
+ configurable: true,
+ enumerable: true,
+ get: webStorage.localStorage,
+ },
+ sessionStorage: {
+ configurable: true,
+ enumerable: true,
+ get: webStorage.sessionStorage,
+ },
+ Storage: util.nonEnumerable(webStorage.Storage),
};
const workerRuntimeGlobalProperties = {
diff --git a/runtime/lib.rs b/runtime/lib.rs
index 61b8fc77e..d45a72727 100644
--- a/runtime/lib.rs
+++ b/runtime/lib.rs
@@ -10,6 +10,7 @@ pub use deno_web;
pub use deno_webgpu;
pub use deno_webidl;
pub use deno_websocket;
+pub use deno_webstorage;
pub mod colors;
pub mod errors;
diff --git a/runtime/worker.rs b/runtime/worker.rs
index b4c27b4f4..ab54e2153 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -69,6 +69,7 @@ pub struct WorkerOptions {
pub no_color: bool,
pub get_error_class_fn: Option<GetErrorClassFn>,
pub location: Option<Url>,
+ pub location_data_dir: Option<std::path::PathBuf>,
pub blob_url_store: BlobUrlStore,
}
@@ -104,6 +105,7 @@ impl MainWorker {
options.user_agent.clone(),
options.ca_data.clone(),
),
+ deno_webstorage::init(options.location_data_dir.clone()),
deno_crypto::init(options.seed),
deno_webgpu::init(options.unstable),
deno_timers::init::<Permissions>(),
@@ -291,6 +293,7 @@ mod tests {
no_color: true,
get_error_class_fn: None,
location: None,
+ location_data_dir: None,
blob_url_store: BlobUrlStore::default(),
};