2021-01-11 12:13:41 -05:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2020-08-07 10:55:02 -04:00
|
|
|
|
2021-06-05 13:30:20 -04:00
|
|
|
use deno_core::error::AnyError;
|
2021-04-28 12:41:50 -04:00
|
|
|
use deno_core::include_js_files;
|
|
|
|
use deno_core::Extension;
|
2021-06-05 13:30:20 -04:00
|
|
|
use std::fmt;
|
2020-09-30 10:51:01 -04:00
|
|
|
use std::path::PathBuf;
|
2020-08-07 10:55:02 -04:00
|
|
|
|
2020-09-30 10:51:01 -04:00
|
|
|
/// Load and execute the javascript code.
|
2021-04-28 12:41:50 -04:00
|
|
|
pub fn init() -> Extension {
|
2021-04-28 18:16:45 -04:00
|
|
|
Extension::builder()
|
|
|
|
.js(include_js_files!(
|
2021-04-30 15:51:48 -04:00
|
|
|
prefix "deno:extensions/web",
|
2021-04-28 18:16:45 -04:00
|
|
|
"00_infra.js",
|
|
|
|
"01_dom_exception.js",
|
|
|
|
"01_mimesniff.js",
|
|
|
|
"02_event.js",
|
|
|
|
"03_abort_signal.js",
|
|
|
|
"04_global_interfaces.js",
|
|
|
|
"08_text_encoding.js",
|
|
|
|
"12_location.js",
|
|
|
|
))
|
|
|
|
.build()
|
2020-08-07 10:55:02 -04:00
|
|
|
}
|
|
|
|
|
2020-09-01 16:32:07 -04:00
|
|
|
pub fn get_declaration() -> PathBuf {
|
2020-09-09 08:23:57 -04:00
|
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_web.d.ts")
|
2020-08-07 10:55:02 -04:00
|
|
|
}
|
2021-06-05 13:30:20 -04:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct DomExceptionQuotaExceededError {
|
|
|
|
pub msg: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DomExceptionQuotaExceededError {
|
|
|
|
pub fn new(msg: &str) -> Self {
|
|
|
|
DomExceptionQuotaExceededError {
|
|
|
|
msg: msg.to_string(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Display for DomExceptionQuotaExceededError {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
f.pad(&self.msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::error::Error for DomExceptionQuotaExceededError {}
|
|
|
|
|
|
|
|
pub fn get_quota_exceeded_error_class_name(
|
|
|
|
e: &AnyError,
|
|
|
|
) -> Option<&'static str> {
|
|
|
|
e.downcast_ref::<DomExceptionQuotaExceededError>()
|
|
|
|
.map(|_| "DOMExceptionQuotaExceededError")
|
|
|
|
}
|