feat: upgrade v8 runtime crates
This commit is contained in:
parent
f882cf2c95
commit
80f7585153
9 changed files with 508 additions and 429 deletions
|
|
@ -33,18 +33,10 @@ pub(crate) fn exec(
|
|||
return Err(CompilerError::MissingElmStuff(elm_cache_dir).into());
|
||||
}
|
||||
|
||||
// step 2.5 get the module name out of the file.
|
||||
let data = std::fs::read(&file)
|
||||
.map_err(|io_err| CompilerError::ReadInputFailed(io_err, file.clone()))?;
|
||||
|
||||
let mut hasher = PortableHash::new();
|
||||
hasher.write_all(&data).unwrap();
|
||||
// also include the function name in the checksum so users can run multiple functions
|
||||
// from the same file but still get caching if the file does not change.
|
||||
hasher.write_all(function.as_bytes()).unwrap();
|
||||
let source_checksum = hasher.finish();
|
||||
|
||||
// step 2.5 get the module name out of the file.
|
||||
|
||||
let entrypoint = elmi::Global(
|
||||
elmi::ModuleNameCanonical {
|
||||
package: elmi::PackageName::new("author", "project"),
|
||||
|
|
@ -77,6 +69,13 @@ pub(crate) fn exec(
|
|||
};
|
||||
drop(timing_guard);
|
||||
|
||||
let mut hasher = PortableHash::new();
|
||||
hasher.write_all(&data).unwrap();
|
||||
// also include the function name in the checksum so users can run multiple functions
|
||||
// from the same file but still get caching if the file does not change.
|
||||
hasher.write_all(function.as_bytes()).unwrap();
|
||||
let source_checksum = hasher.finish();
|
||||
|
||||
match mode {
|
||||
ExecutionMode::Scripting(input_type, output_type) => scripting::run(
|
||||
debug,
|
||||
|
|
@ -120,30 +119,34 @@ mod runtime {
|
|||
use crate::reporting::InterpreterError;
|
||||
use deno_core::error::{type_error, AnyError};
|
||||
use deno_core::futures::FutureExt;
|
||||
use deno_core::{resolve_url, FsModuleLoader, ModuleLoader, ModuleSpecifier};
|
||||
use deno_core::{resolve_url, Extension, FsModuleLoader, ModuleLoader, ModuleSpecifier};
|
||||
use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel;
|
||||
use deno_runtime::permissions::Permissions;
|
||||
use deno_runtime::worker::MainWorker;
|
||||
use deno_runtime::worker::WorkerOptions;
|
||||
use deno_runtime::BootstrapOptions;
|
||||
use deno_web::BlobStore;
|
||||
|
||||
use std::pin::Pin;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use tracing::{info_span, Instrument};
|
||||
|
||||
fn get_error_class_name(e: &AnyError) -> &'static str {
|
||||
deno_runtime::errors::get_error_class_name(e).unwrap_or("Error")
|
||||
}
|
||||
|
||||
pub fn setup_worker(path_str: &str) -> Result<(MainWorker, ModuleSpecifier), AnyError> {
|
||||
pub fn setup_worker(
|
||||
extensions: Vec<Extension>,
|
||||
path_str: &str,
|
||||
) -> Result<(MainWorker, ModuleSpecifier), AnyError> {
|
||||
//let module_loader = Rc::new(EmbeddedModuleLoader("void".to_owned()));
|
||||
let module_loader = Rc::new(FsModuleLoader);
|
||||
let create_web_worker_cb = Arc::new(|_| {
|
||||
todo!("Web workers are not supported in the example");
|
||||
});
|
||||
let web_worker_preload_module_cb = Arc::new(|_| {
|
||||
todo!("Web workers are not supported in the example");
|
||||
});
|
||||
|
||||
let options = WorkerOptions {
|
||||
bootstrap: BootstrapOptions {
|
||||
|
|
@ -152,19 +155,21 @@ mod runtime {
|
|||
cpu_count: 1,
|
||||
debug_flag: false,
|
||||
enable_testing_features: false,
|
||||
is_tty: false,
|
||||
location: None,
|
||||
no_color: false,
|
||||
runtime_version: "0.29.0".to_string(),
|
||||
runtime_version: "0.50.0".to_string(),
|
||||
ts_version: "2.0.0".to_string(),
|
||||
unstable: false,
|
||||
},
|
||||
extensions: vec![],
|
||||
extensions: extensions,
|
||||
unsafely_ignore_certificate_errors: None,
|
||||
root_cert_store: None,
|
||||
user_agent: "hello_runtime".to_string(),
|
||||
seed: None,
|
||||
module_loader,
|
||||
create_web_worker_cb,
|
||||
web_worker_preload_module_cb,
|
||||
js_error_create_fn: None,
|
||||
maybe_inspector_server: None,
|
||||
should_break_on_first_statement: false,
|
||||
|
|
@ -193,7 +198,7 @@ mod runtime {
|
|||
foo: F,
|
||||
) -> Result<(), InterpreterError>
|
||||
where
|
||||
F: FnOnce(rusty_v8::HandleScope) -> Result<(), InterpreterError>,
|
||||
F: FnOnce(deno_core::v8::HandleScope) -> Result<(), InterpreterError>,
|
||||
{
|
||||
let wait_for_inspector = false;
|
||||
// step 10 load the module into our v8 isolate
|
||||
|
|
@ -263,6 +268,7 @@ mod runtime {
|
|||
|
||||
Ok(deno_core::ModuleSource {
|
||||
code,
|
||||
module_type: deno_core::ModuleType::JavaScript,
|
||||
module_url_specified: module_specifier.to_string(),
|
||||
module_url_found: module_specifier.to_string(),
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue