Skip to content

Commit

Permalink
refactor: upgrade deno_core to 0.238
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Dec 30, 2023
1 parent 87103b2 commit 25ac7ff
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 150 deletions.
169 changes: 48 additions & 121 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
]

[workspace.dependencies]
deno_core = "0.222.0"
dprint-core = "0.63.3"
deno_core = "0.238.0"
dprint-core = "0.65.0"
serde = { version = "1.0.149", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
1 change: 1 addition & 0 deletions base/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn create_snapshot(options: CreateSnapshotOptions) -> CreateSnapshotOutput {
snapshot_path: options.snapshot_path,
startup_snapshot: None,
extensions: options.extensions,
skip_op_registration: false,
#[cfg(debug_assertions)]
compression_cb: None,
#[cfg(not(debug_assertions))]
Expand Down
2 changes: 1 addition & 1 deletion base/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait Formatter<TConfiguration> {
async fn format_text(
&mut self,
request: FormatRequest<TConfiguration>,
) -> Result<Option<String>, Error>;
) -> Result<Option<Vec<u8>>, Error>;
}

pub type CreateFormatterCb<TConfiguration> =
Expand Down
14 changes: 11 additions & 3 deletions base/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use deno_core::anyhow::Result;
use deno_core::serde_v8;
use deno_core::v8;
use deno_core::Extension;
use deno_core::PollEventLoopOptions;
use deno_core::RuntimeOptions;
use serde::Deserialize;

Expand Down Expand Up @@ -42,7 +43,11 @@ impl JsRuntime {

pub async fn execute_format_script(&mut self, code: String) -> Result<Option<String>, Error> {
let global = self.inner.execute_script("format.js", code.into())?;
let global = self.inner.resolve_value(global).await?;
let resolve = self.inner.resolve(global);
let global = self
.inner
.with_event_loop_promise(resolve, PollEventLoopOptions::default())
.await?;
let scope = &mut self.inner.handle_scope();
let local = v8::Local::new(scope, global);
if local.is_undefined() {
Expand All @@ -66,12 +71,15 @@ impl JsRuntime {
{
let inner = &mut self.inner;
let fn_value = inner.execute_script(script_name, fn_name.into())?;
let fn_value = inner.resolve_value(fn_value).await?;
let fn_value = inner.resolve(fn_value).await?;
let mut scope = inner.handle_scope();
let fn_func: v8::Local<v8::Function> = v8::Local::new(&mut scope, fn_value).try_into()?;
let fn_func = v8::Global::new(&mut scope, fn_func);
drop(scope);
let result = inner.call_and_await(&fn_func).await?;
let call = inner.call(&fn_func);
let result = inner
.with_event_loop_promise(call, PollEventLoopOptions::default())
.await?;
let mut scope = inner.handle_scope();
let local = v8::Local::new(&mut scope, result);
Ok(serde_v8::from_v8::<T>(&mut scope, local)?)
Expand Down
2 changes: 1 addition & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"https://plugins.dprint.dev/json-0.19.1.wasm",
"https://plugins.dprint.dev/markdown-0.16.3.wasm",
"https://plugins.dprint.dev/exec-0.4.4.json@c207bf9b9a4ee1f0ecb75c594f774924baf62e8e53a2ce9d873816a408cecbf7",
"https://plugins.dprint.dev/prettier-0.28.1.json@a4808eb7b1edaa23e7df7f1facc9483b494b639c2de9f25034339f76c71d9636",
"https://plugins.dprint.dev/prettier-0.32.0.json@fa93f05ab38f00c6de138f7747372585c661f79dfb11d7f1209c069b56680820",
"https://plugins.dprint.dev/toml-0.5.4.wasm"
]
}
Loading

0 comments on commit 25ac7ff

Please sign in to comment.