mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor: rewrite cli/ ops to op2 (#20462)
This commit is contained in:
parent
4a8b873111
commit
0b78a61f08
6 changed files with 70 additions and 50 deletions
19
cli/build.rs
19
cli/build.rs
|
@ -12,7 +12,7 @@ mod ts {
|
||||||
use super::*;
|
use super::*;
|
||||||
use deno_core::error::custom_error;
|
use deno_core::error::custom_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op2;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_runtime::deno_node::SUPPORTED_BUILTIN_NODE_MODULES;
|
use deno_runtime::deno_node::SUPPORTED_BUILTIN_NODE_MODULES;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -35,8 +35,9 @@ mod ts {
|
||||||
node_built_in_module_names: Vec<String>,
|
node_built_in_module_names: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
fn op_build_info<'s>(state: &mut OpState) -> BuildInfoResponse {
|
#[serde]
|
||||||
|
fn op_build_info(state: &mut OpState) -> BuildInfoResponse {
|
||||||
let build_specifier = "asset:///bootstrap.ts".to_string();
|
let build_specifier = "asset:///bootstrap.ts".to_string();
|
||||||
let build_libs = state
|
let build_libs = state
|
||||||
.borrow::<Vec<&str>>()
|
.borrow::<Vec<&str>>()
|
||||||
|
@ -54,7 +55,7 @@ mod ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2(fast)]
|
||||||
fn op_is_node_file() -> bool {
|
fn op_is_node_file() -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -65,10 +66,11 @@ mod ts {
|
||||||
specifier: String,
|
specifier: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[string]
|
||||||
fn op_script_version(
|
fn op_script_version(
|
||||||
_state: &mut OpState,
|
_state: &mut OpState,
|
||||||
_args: ScriptVersionArgs,
|
#[serde] _args: ScriptVersionArgs,
|
||||||
) -> Result<Option<String>, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
Ok(Some("1".to_string()))
|
Ok(Some("1".to_string()))
|
||||||
}
|
}
|
||||||
|
@ -81,12 +83,13 @@ mod ts {
|
||||||
script_kind: i32,
|
script_kind: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
// using the same op that is used in `tsc.rs` for loading modules and reading
|
// using the same op that is used in `tsc.rs` for loading modules and reading
|
||||||
// files, but a slightly different implementation at build time.
|
// files, but a slightly different implementation at build time.
|
||||||
fn op_load(
|
fn op_load(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: LoadArgs,
|
#[serde] args: LoadArgs,
|
||||||
) -> Result<LoadResponse, AnyError> {
|
) -> Result<LoadResponse, AnyError> {
|
||||||
let op_crate_libs = state.borrow::<HashMap<&str, PathBuf>>();
|
let op_crate_libs = state.borrow::<HashMap<&str, PathBuf>>();
|
||||||
let path_dts = state.borrow::<PathBuf>();
|
let path_dts = state.borrow::<PathBuf>();
|
||||||
|
|
|
@ -36,7 +36,7 @@ use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::custom_error;
|
use deno_core::error::custom_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::located_script_name;
|
use deno_core::located_script_name;
|
||||||
use deno_core::op;
|
use deno_core::op2;
|
||||||
use deno_core::parking_lot::Mutex;
|
use deno_core::parking_lot::Mutex;
|
||||||
use deno_core::resolve_url;
|
use deno_core::resolve_url;
|
||||||
use deno_core::serde::de;
|
use deno_core::serde::de;
|
||||||
|
@ -3232,14 +3232,14 @@ struct SpecifierArgs {
|
||||||
specifier: String,
|
specifier: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2(fast)]
|
||||||
fn op_is_cancelled(state: &mut OpState) -> bool {
|
fn op_is_cancelled(state: &mut OpState) -> bool {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
state.token.is_cancelled()
|
state.token.is_cancelled()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2(fast)]
|
||||||
fn op_is_node_file(state: &mut OpState, path: String) -> bool {
|
fn op_is_node_file(state: &mut OpState, #[string] path: String) -> bool {
|
||||||
let state = state.borrow::<State>();
|
let state = state.borrow::<State>();
|
||||||
match ModuleSpecifier::parse(&path) {
|
match ModuleSpecifier::parse(&path) {
|
||||||
Ok(specifier) => state
|
Ok(specifier) => state
|
||||||
|
@ -3260,10 +3260,11 @@ struct LoadResponse {
|
||||||
version: Option<String>,
|
version: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
fn op_load(
|
fn op_load(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: SpecifierArgs,
|
#[serde] args: SpecifierArgs,
|
||||||
) -> Result<Option<LoadResponse>, AnyError> {
|
) -> Result<Option<LoadResponse>, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mark = state.performance.mark("op_load", Some(&args));
|
let mark = state.performance.mark("op_load", Some(&args));
|
||||||
|
@ -3277,10 +3278,11 @@ fn op_load(
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
fn op_resolve(
|
fn op_resolve(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ResolveArgs,
|
#[serde] args: ResolveArgs,
|
||||||
) -> Result<Vec<Option<(String, String)>>, AnyError> {
|
) -> Result<Vec<Option<(String, String)>>, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mark = state.performance.mark("op_resolve", Some(&args));
|
let mark = state.performance.mark("op_resolve", Some(&args));
|
||||||
|
@ -3314,13 +3316,14 @@ fn op_resolve(
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
fn op_respond(state: &mut OpState, args: Response) {
|
fn op_respond(state: &mut OpState, #[serde] args: Response) {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
state.response = Some(args);
|
state.response = Some(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
fn op_script_names(state: &mut OpState) -> Vec<String> {
|
fn op_script_names(state: &mut OpState) -> Vec<String> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let documents = &state.state_snapshot.documents;
|
let documents = &state.state_snapshot.documents;
|
||||||
|
@ -3371,10 +3374,11 @@ struct ScriptVersionArgs {
|
||||||
specifier: String,
|
specifier: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[string]
|
||||||
fn op_script_version(
|
fn op_script_version(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ScriptVersionArgs,
|
#[serde] args: ScriptVersionArgs,
|
||||||
) -> Result<Option<String>, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
// this op is very "noisy" and measuring its performance is not useful, so we
|
// this op is very "noisy" and measuring its performance is not useful, so we
|
||||||
|
|
|
@ -7,6 +7,7 @@ use std::time;
|
||||||
use deno_core::error::generic_error;
|
use deno_core::error::generic_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
|
use deno_core::op2;
|
||||||
use deno_core::serde_v8;
|
use deno_core::serde_v8;
|
||||||
use deno_core::v8;
|
use deno_core::v8;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
|
@ -47,10 +48,11 @@ deno_core::extension!(deno_bench,
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct PermissionsHolder(Uuid, PermissionsContainer);
|
struct PermissionsHolder(Uuid, PermissionsContainer);
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
pub fn op_pledge_test_permissions(
|
pub fn op_pledge_test_permissions(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ChildPermissionsArg,
|
#[serde] args: ChildPermissionsArg,
|
||||||
) -> Result<Uuid, AnyError> {
|
) -> Result<Uuid, AnyError> {
|
||||||
let token = Uuid::new_v4();
|
let token = Uuid::new_v4();
|
||||||
let parent_permissions = state.borrow_mut::<PermissionsContainer>();
|
let parent_permissions = state.borrow_mut::<PermissionsContainer>();
|
||||||
|
@ -73,10 +75,10 @@ pub fn op_pledge_test_permissions(
|
||||||
Ok(token)
|
Ok(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
pub fn op_restore_test_permissions(
|
pub fn op_restore_test_permissions(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
token: Uuid,
|
#[serde] token: Uuid,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
|
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
|
||||||
if token != permissions_holder.0 {
|
if token != permissions_holder.0 {
|
||||||
|
@ -114,11 +116,12 @@ struct BenchRegisterResult {
|
||||||
|
|
||||||
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
|
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
#[op(v8)]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
fn op_register_bench<'a>(
|
fn op_register_bench<'a>(
|
||||||
scope: &mut v8::HandleScope<'a>,
|
scope: &mut v8::HandleScope<'a>,
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
info: BenchInfo<'a>,
|
#[serde] info: BenchInfo<'a>,
|
||||||
) -> Result<BenchRegisterResult, AnyError> {
|
) -> Result<BenchRegisterResult, AnyError> {
|
||||||
let id = NEXT_ID.fetch_add(1, Ordering::SeqCst);
|
let id = NEXT_ID.fetch_add(1, Ordering::SeqCst);
|
||||||
let origin = state.borrow::<ModuleSpecifier>().to_string();
|
let origin = state.borrow::<ModuleSpecifier>().to_string();
|
||||||
|
@ -143,8 +146,8 @@ fn op_register_bench<'a>(
|
||||||
Ok(BenchRegisterResult { id, origin })
|
Ok(BenchRegisterResult { id, origin })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
fn op_dispatch_bench_event(state: &mut OpState, event: BenchEvent) {
|
fn op_dispatch_bench_event(state: &mut OpState, #[serde] event: BenchEvent) {
|
||||||
assert!(
|
assert!(
|
||||||
matches!(event, BenchEvent::Output(_)),
|
matches!(event, BenchEvent::Output(_)),
|
||||||
"Only output events are expected from JS."
|
"Only output events are expected from JS."
|
||||||
|
@ -153,6 +156,7 @@ fn op_dispatch_bench_event(state: &mut OpState, event: BenchEvent) {
|
||||||
sender.send(event).ok();
|
sender.send(event).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(bartlomieju): op2 forces to use bigint, but JS doesn't expect a bigint
|
||||||
#[op]
|
#[op]
|
||||||
fn op_bench_now(state: &mut OpState) -> Result<u64, AnyError> {
|
fn op_bench_now(state: &mut OpState) -> Result<u64, AnyError> {
|
||||||
let ns = state.borrow::<time::Instant>().elapsed().as_nanos();
|
let ns = state.borrow::<time::Instant>().elapsed().as_nanos();
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use crate::npm::CliNpmResolver;
|
use crate::npm::CliNpmResolver;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op2;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ deno_core::extension!(cli,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[string]
|
||||||
fn op_npm_process_state(state: &mut OpState) -> Result<String, AnyError> {
|
fn op_npm_process_state(state: &mut OpState) -> Result<String, AnyError> {
|
||||||
let npm_resolver = state.borrow_mut::<Arc<CliNpmResolver>>();
|
let npm_resolver = state.borrow_mut::<Arc<CliNpmResolver>>();
|
||||||
Ok(npm_resolver.get_npm_process_state())
|
Ok(npm_resolver.get_npm_process_state())
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::tools::test::TestStepDescription;
|
||||||
|
|
||||||
use deno_core::error::generic_error;
|
use deno_core::error::generic_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op2;
|
||||||
use deno_core::serde_v8;
|
use deno_core::serde_v8;
|
||||||
use deno_core::v8;
|
use deno_core::v8;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
|
@ -48,10 +48,11 @@ deno_core::extension!(deno_test,
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct PermissionsHolder(Uuid, PermissionsContainer);
|
struct PermissionsHolder(Uuid, PermissionsContainer);
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
pub fn op_pledge_test_permissions(
|
pub fn op_pledge_test_permissions(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ChildPermissionsArg,
|
#[serde] args: ChildPermissionsArg,
|
||||||
) -> Result<Uuid, AnyError> {
|
) -> Result<Uuid, AnyError> {
|
||||||
let token = Uuid::new_v4();
|
let token = Uuid::new_v4();
|
||||||
let parent_permissions = state.borrow_mut::<PermissionsContainer>();
|
let parent_permissions = state.borrow_mut::<PermissionsContainer>();
|
||||||
|
@ -73,10 +74,10 @@ pub fn op_pledge_test_permissions(
|
||||||
Ok(token)
|
Ok(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
pub fn op_restore_test_permissions(
|
pub fn op_restore_test_permissions(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
token: Uuid,
|
#[serde] token: Uuid,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
|
if let Some(permissions_holder) = state.try_take::<PermissionsHolder>() {
|
||||||
if token != permissions_holder.0 {
|
if token != permissions_holder.0 {
|
||||||
|
@ -113,11 +114,12 @@ struct TestRegisterResult {
|
||||||
|
|
||||||
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
|
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
#[op(v8)]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
fn op_register_test<'a>(
|
fn op_register_test<'a>(
|
||||||
scope: &mut v8::HandleScope<'a>,
|
scope: &mut v8::HandleScope<'a>,
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
info: TestInfo<'a>,
|
#[serde] info: TestInfo<'a>,
|
||||||
) -> Result<TestRegisterResult, AnyError> {
|
) -> Result<TestRegisterResult, AnyError> {
|
||||||
let id = NEXT_ID.fetch_add(1, Ordering::SeqCst);
|
let id = NEXT_ID.fetch_add(1, Ordering::SeqCst);
|
||||||
let origin = state.borrow::<ModuleSpecifier>().to_string();
|
let origin = state.borrow::<ModuleSpecifier>().to_string();
|
||||||
|
@ -164,10 +166,11 @@ struct TestStepInfo {
|
||||||
root_name: String,
|
root_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
fn op_register_test_step(
|
fn op_register_test_step(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
info: TestStepInfo,
|
#[serde] info: TestStepInfo,
|
||||||
) -> Result<TestRegisterResult, AnyError> {
|
) -> Result<TestRegisterResult, AnyError> {
|
||||||
let id = NEXT_ID.fetch_add(1, Ordering::SeqCst);
|
let id = NEXT_ID.fetch_add(1, Ordering::SeqCst);
|
||||||
let origin = state.borrow::<ModuleSpecifier>().to_string();
|
let origin = state.borrow::<ModuleSpecifier>().to_string();
|
||||||
|
@ -186,10 +189,10 @@ fn op_register_test_step(
|
||||||
Ok(TestRegisterResult { id, origin })
|
Ok(TestRegisterResult { id, origin })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
fn op_dispatch_test_event(
|
fn op_dispatch_test_event(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
event: TestEvent,
|
#[serde] event: TestEvent,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
assert!(
|
assert!(
|
||||||
matches!(event, TestEvent::StepWait(_) | TestEvent::StepResult(..)),
|
matches!(event, TestEvent::StepWait(_) | TestEvent::StepResult(..)),
|
||||||
|
|
|
@ -14,6 +14,7 @@ use deno_core::ascii_str;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::located_script_name;
|
use deno_core::located_script_name;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
|
use deno_core::op2;
|
||||||
use deno_core::resolve_url_or_path;
|
use deno_core::resolve_url_or_path;
|
||||||
use deno_core::serde::Deserialize;
|
use deno_core::serde::Deserialize;
|
||||||
use deno_core::serde::Deserializer;
|
use deno_core::serde::Deserializer;
|
||||||
|
@ -377,8 +378,9 @@ fn normalize_specifier(
|
||||||
resolve_url_or_path(specifier, current_dir).map_err(|err| err.into())
|
resolve_url_or_path(specifier, current_dir).map_err(|err| err.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
fn op_create_hash(s: &mut OpState, text: &str) -> String {
|
#[string]
|
||||||
|
fn op_create_hash(s: &mut OpState, #[string] text: &str) -> String {
|
||||||
let state = s.borrow_mut::<State>();
|
let state = s.borrow_mut::<State>();
|
||||||
get_hash(text, state.hash_data)
|
get_hash(text, state.hash_data)
|
||||||
}
|
}
|
||||||
|
@ -393,8 +395,8 @@ struct EmitArgs {
|
||||||
file_name: String,
|
file_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
fn op_emit(state: &mut OpState, args: EmitArgs) -> bool {
|
fn op_emit(state: &mut OpState, #[serde] args: EmitArgs) -> bool {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
match args.file_name.as_ref() {
|
match args.file_name.as_ref() {
|
||||||
"internal:///.tsbuildinfo" => state.maybe_tsbuildinfo = Some(args.data),
|
"internal:///.tsbuildinfo" => state.maybe_tsbuildinfo = Some(args.data),
|
||||||
|
@ -435,6 +437,7 @@ pub fn as_ts_script_kind(media_type: MediaType) -> i32 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(bartlomieju): `op2` doesn't support `serde_json::Value`
|
||||||
#[op]
|
#[op]
|
||||||
fn op_load(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
|
fn op_load(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
|
@ -528,10 +531,11 @@ pub struct ResolveArgs {
|
||||||
pub specifiers: Vec<String>,
|
pub specifiers: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2]
|
||||||
|
#[serde]
|
||||||
fn op_resolve(
|
fn op_resolve(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
args: ResolveArgs,
|
#[serde] args: ResolveArgs,
|
||||||
) -> Result<Vec<(String, String)>, AnyError> {
|
) -> Result<Vec<(String, String)>, AnyError> {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
let mut resolved: Vec<(String, String)> =
|
let mut resolved: Vec<(String, String)> =
|
||||||
|
@ -713,8 +717,8 @@ fn resolve_non_graph_specifier_types(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op2(fast)]
|
||||||
fn op_is_node_file(state: &mut OpState, path: &str) -> bool {
|
fn op_is_node_file(state: &mut OpState, #[string] path: &str) -> bool {
|
||||||
let state = state.borrow::<State>();
|
let state = state.borrow::<State>();
|
||||||
match ModuleSpecifier::parse(path) {
|
match ModuleSpecifier::parse(path) {
|
||||||
Ok(specifier) => state
|
Ok(specifier) => state
|
||||||
|
@ -732,6 +736,7 @@ struct RespondArgs {
|
||||||
pub stats: Stats,
|
pub stats: Stats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(bartlomieju): `op2` doesn't support `serde_json::Value`
|
||||||
#[op]
|
#[op]
|
||||||
fn op_respond(state: &mut OpState, args: RespondArgs) {
|
fn op_respond(state: &mut OpState, args: RespondArgs) {
|
||||||
let state = state.borrow_mut::<State>();
|
let state = state.borrow_mut::<State>();
|
||||||
|
|
Loading…
Reference in a new issue