Skip to content

Commit 1013662

Browse files
authored
refactor: update deno_core (#31607)
For denoland/deno_core#1262
1 parent 824b30c commit 1013662

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+502
-663
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ repository = "https://github.com/denoland/deno"
6666

6767
[workspace.dependencies]
6868
deno_ast = { version = "=0.52.0", features = ["transpiling"] }
69-
deno_core = { version = "0.381.1" }
69+
deno_core = { version = "0.382.0" }
7070

7171
deno_cache_dir = "=0.26.3"
7272
deno_doc = "=0.189.1"

cli/lsp/tsc.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4746,7 +4746,6 @@ fn op_is_node_file(state: &mut OpState, #[string] path: String) -> bool {
47464746
}
47474747

47484748
#[op2]
4749-
#[serde]
47504749
fn op_libs() -> Vec<String> {
47514750
crate::tsc::lib_names()
47524751
}
@@ -4841,12 +4840,11 @@ fn op_release(
48414840
}
48424841

48434842
#[op2]
4844-
#[serde]
48454843
#[allow(clippy::type_complexity)]
48464844
fn op_resolve(
48474845
state: &mut OpState,
48484846
#[string] base: &str,
4849-
#[serde] specifiers: Vec<(bool, String)>,
4847+
#[scoped] specifiers: Vec<(bool, String)>,
48504848
) -> Result<Vec<Option<(String, Option<String>)>>, deno_core::url::ParseError> {
48514849
let _span = super::logging::lsp_tracing_info_span!("op_resolve").entered();
48524850
op_resolve_inner(state, ResolveArgs { base, specifiers })
@@ -4899,8 +4897,7 @@ impl<'a> ToV8<'a> for TscRequestArray {
48994897
}
49004898
}
49014899

4902-
#[op2(async)]
4903-
#[to_v8]
4900+
#[op2]
49044901
async fn op_poll_requests(
49054902
state: Rc<RefCell<OpState>>,
49064903
) -> convert::OptionNull<TscRequestArray> {

cli/ops/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
9999
#[op2]
100100
fn op_register_bench(
101101
state: &mut OpState,
102-
#[global] function: v8::Global<v8::Function>,
102+
#[scoped] function: v8::Global<v8::Function>,
103103
#[string] name: String,
104104
baseline: bool,
105105
#[string] group: Option<String>,

cli/ops/jupyter.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ pub enum JupyterBroadcastError {
122122
ZeroMq(AnyError),
123123
}
124124

125-
#[op2(async)]
125+
#[op2]
126126
pub async fn op_jupyter_broadcast(
127127
state: Rc<RefCell<OpState>>,
128128
#[string] message_type: String,
@@ -355,7 +355,6 @@ pub fn op_jupyter_create_png_from_texture(
355355
}
356356

357357
#[op2]
358-
#[serde]
359358
pub fn op_jupyter_get_buffer(
360359
#[cppgc] buffer: &deno_runtime::deno_webgpu::buffer::GPUBuffer,
361360
) -> Result<Vec<u8>, deno_runtime::deno_webgpu::error::GPUError> {

cli/ops/lint.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use deno_ast::ParseDiagnostic;
66
use deno_ast::SourceRange;
77
use deno_ast::SourceTextInfo;
88
use deno_ast::SourceTextProvider;
9+
use deno_core::FromV8;
910
use deno_core::OpState;
11+
use deno_core::convert::Uint8Array;
1012
use deno_core::op2;
1113
use deno_lint::diagnostic::LintDiagnostic;
1214
use deno_lint::diagnostic::LintDiagnosticDetails;
@@ -204,12 +206,11 @@ pub enum LintError {
204206
}
205207

206208
#[op2]
207-
#[buffer]
208209
#[allow(clippy::result_large_err)]
209210
fn op_lint_create_serialized_ast(
210211
#[string] file_name: &str,
211212
#[string] source: String,
212-
) -> Result<Vec<u8>, LintError> {
213+
) -> Result<Uint8Array, LintError> {
213214
let file_text = deno_ast::strip_bom(source);
214215
let path = std::env::current_dir()?.join(file_name);
215216
let specifier = ModuleSpecifier::from_file_path(&path)
@@ -224,10 +225,10 @@ fn op_lint_create_serialized_ast(
224225
maybe_syntax: None,
225226
})?;
226227
let utf16_map = Utf16Map::new(parsed_source.text().as_ref());
227-
Ok(lint::serialize_ast_to_buffer(&parsed_source, &utf16_map))
228+
Ok(lint::serialize_ast_to_buffer(&parsed_source, &utf16_map).into())
228229
}
229230

230-
#[derive(serde::Deserialize)]
231+
#[derive(FromV8)]
231232
struct LintReportFix {
232233
text: String,
233234
range: (usize, usize),
@@ -254,7 +255,7 @@ fn op_lint_report(
254255
#[string] hint: Option<String>,
255256
#[smi] start_utf16: usize,
256257
#[smi] end_utf16: usize,
257-
#[serde] fix: Vec<LintReportFix>,
258+
#[scoped] fix: Vec<LintReportFix>,
258259
) -> Result<(), LintReportError> {
259260
let container = state.borrow_mut::<LintPluginContainer>();
260261
container.report(id, message, hint, start_utf16, end_utf16, fix)?;

cli/ops/testing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
9595
#[op2]
9696
fn op_register_test(
9797
state: &mut OpState,
98-
#[global] function: v8::Global<v8::Function>,
98+
#[scoped] function: v8::Global<v8::Function>,
9999
#[string] name: String,
100100
ignore: bool,
101101
only: bool,
@@ -139,7 +139,7 @@ fn op_register_test(
139139
fn op_register_test_hook(
140140
state: &mut OpState,
141141
#[string] hook_type: String,
142-
#[global] function: v8::Global<v8::Function>,
142+
#[scoped] function: v8::Global<v8::Function>,
143143
) -> Result<(), JsErrorBox> {
144144
let container = state.borrow_mut::<TestContainer>();
145145
container.register_hook(hook_type, function);

cli/tools/bundle/provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn convert_build_output_file(
7474
) -> rt_bundle::BuildOutputFile {
7575
rt_bundle::BuildOutputFile {
7676
path: file.path,
77-
contents: Some(file.contents),
77+
contents: Some(file.contents.into()),
7878
hash: file.hash,
7979
}
8080
}

cli/tsc/js.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,15 @@ fn op_remap_specifier(
5151
}
5252

5353
#[op2]
54-
#[serde]
5554
fn op_libs() -> Vec<String> {
5655
crate::tsc::lib_names()
5756
}
5857

5958
#[op2]
60-
#[serde]
6159
fn op_resolve(
6260
state: &mut OpState,
6361
#[string] base: &str,
64-
#[serde] specifiers: Vec<(bool, String)>,
62+
#[scoped] specifiers: Vec<(bool, String)>,
6563
) -> Result<Vec<(String, Option<&'static str>)>, ResolveError> {
6664
op_resolve_inner(state, ResolveArgs { base, specifiers })
6765
}

ext/bundle/src/lib.rs

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ use std::rc::Rc;
55
use std::sync::Arc;
66

77
use async_trait::async_trait;
8+
use deno_core::FromV8;
89
use deno_core::OpState;
10+
use deno_core::ToV8;
11+
use deno_core::convert::Uint8Array;
912
use deno_core::error::AnyError;
1013
use deno_core::op2;
1114
use deno_error::JsErrorBox;
@@ -53,38 +56,31 @@ pub trait BundleProvider: Send + Sync {
5356
) -> Result<BuildResponse, AnyError>;
5457
}
5558

56-
#[derive(Clone, Debug, Eq, PartialEq, Default, serde::Deserialize)]
57-
#[serde(rename_all = "camelCase")]
59+
#[derive(Clone, Debug, Eq, PartialEq, Default, FromV8)]
5860
pub struct BundleOptions {
5961
pub entrypoints: Vec<String>,
60-
#[serde(default)]
6162
pub output_path: Option<String>,
62-
#[serde(default)]
6363
pub output_dir: Option<String>,
64-
#[serde(default)]
64+
#[from_v8(default)]
6565
pub external: Vec<String>,
66-
#[serde(default)]
66+
#[from_v8(serde, default)]
6767
pub format: BundleFormat,
68-
#[serde(default)]
68+
#[from_v8(default)]
6969
pub minify: bool,
70-
#[serde(default)]
70+
#[from_v8(default)]
7171
pub code_splitting: bool,
72-
#[serde(default = "tru")]
72+
#[from_v8(default = true)]
7373
pub inline_imports: bool,
74-
#[serde(default)]
74+
#[from_v8(serde, default)]
7575
pub packages: PackageHandling,
76-
#[serde(default)]
76+
#[from_v8(serde)]
7777
pub sourcemap: Option<SourceMapType>,
78-
#[serde(default)]
78+
#[from_v8(serde, default)]
7979
pub platform: BundlePlatform,
80-
#[serde(default = "tru")]
80+
#[from_v8(default = true)]
8181
pub write: bool,
8282
}
8383

84-
fn tru() -> bool {
85-
true
86-
}
87-
8884
#[derive(Clone, Debug, Eq, PartialEq, Copy, Default, serde::Deserialize)]
8985
#[serde(rename_all = "camelCase")]
9086
pub enum BundlePlatform {
@@ -147,16 +143,14 @@ impl std::fmt::Display for PackageHandling {
147143
}
148144
}
149145
}
150-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
151-
#[serde(rename_all = "camelCase")]
146+
#[derive(Debug, Clone, FromV8, ToV8)]
152147
pub struct Message {
153148
pub text: String,
154149
pub location: Option<Location>,
155150
pub notes: Vec<Note>,
156151
}
157152

158-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
159-
#[serde(rename_all = "camelCase")]
153+
#[derive(Debug, Clone, FromV8, ToV8)]
160154
pub struct PartialMessage {
161155
pub id: Option<String>,
162156
pub plugin_name: Option<String>,
@@ -166,28 +160,24 @@ pub struct PartialMessage {
166160
pub detail: Option<u32>,
167161
}
168162

169-
#[derive(Debug, Clone, serde::Serialize)]
170-
#[serde(rename_all = "camelCase")]
163+
#[derive(Debug, Clone, ToV8)]
171164
pub struct BuildOutputFile {
172165
pub path: String,
173-
pub contents: Option<Vec<u8>>,
166+
pub contents: Option<Uint8Array>,
174167
pub hash: String,
175168
}
176-
#[derive(Debug, Clone, serde::Serialize)]
177-
#[serde(rename_all = "camelCase")]
169+
#[derive(Debug, Clone, ToV8)]
178170
pub struct BuildResponse {
179171
pub errors: Vec<Message>,
180172
pub warnings: Vec<Message>,
181173
pub output_files: Option<Vec<BuildOutputFile>>,
182174
}
183-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
184-
#[serde(rename_all = "camelCase")]
175+
#[derive(Debug, Clone, FromV8, ToV8)]
185176
pub struct Note {
186177
pub text: String,
187178
pub location: Option<Location>,
188179
}
189-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
190-
#[serde(rename_all = "camelCase")]
180+
#[derive(Debug, Clone, FromV8, ToV8)]
191181
pub struct Location {
192182
pub file: String,
193183
pub namespace: Option<String>,
@@ -222,11 +212,10 @@ pub struct OnLoadOptions {
222212
pub namespace: Option<String>,
223213
}
224214

225-
#[op2(async)]
226-
#[serde]
215+
#[op2]
227216
pub async fn op_bundle(
228217
state: Rc<RefCell<OpState>>,
229-
#[serde] options: BundleOptions,
218+
#[scoped] options: BundleOptions,
230219
) -> Result<BuildResponse, JsErrorBox> {
231220
// eprintln!("op_bundle: {:?}", options);
232221
let provider = {

0 commit comments

Comments
 (0)