2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2020-12-03 17:52:55 -05:00
|
|
|
mod async_cancel;
|
2020-11-24 18:38:23 -05:00
|
|
|
mod async_cell;
|
2020-01-06 10:24:44 -05:00
|
|
|
mod bindings;
|
2020-09-14 12:48:57 -04:00
|
|
|
pub mod error;
|
2021-11-04 11:44:34 -04:00
|
|
|
mod error_codes;
|
2021-04-28 12:41:50 -04:00
|
|
|
mod extensions;
|
2023-04-04 08:46:31 -04:00
|
|
|
mod fast_string;
|
2019-03-11 17:57:36 -04:00
|
|
|
mod flags;
|
2020-09-10 09:57:45 -04:00
|
|
|
mod gotham_state;
|
2021-05-26 15:07:12 -04:00
|
|
|
mod inspector;
|
2022-10-09 10:49:25 -04:00
|
|
|
mod io;
|
2019-06-12 19:55:59 -04:00
|
|
|
mod module_specifier;
|
2019-03-26 11:56:34 -04:00
|
|
|
mod modules;
|
2020-08-12 16:34:17 -04:00
|
|
|
mod normalize_path;
|
2019-09-30 14:59:44 -04:00
|
|
|
mod ops;
|
2021-04-25 13:23:22 -04:00
|
|
|
mod ops_builtin;
|
2022-06-07 05:25:10 -04:00
|
|
|
mod ops_builtin_v8;
|
2021-10-10 11:20:30 -04:00
|
|
|
mod ops_metrics;
|
2023-05-01 20:35:33 -04:00
|
|
|
mod path;
|
2023-04-08 11:00:02 -04:00
|
|
|
mod realm;
|
2019-10-23 12:32:28 -04:00
|
|
|
mod resources;
|
2020-09-06 15:44:29 -04:00
|
|
|
mod runtime;
|
2022-11-21 08:36:26 -05:00
|
|
|
pub mod snapshot_util;
|
2022-04-15 10:08:09 -04:00
|
|
|
mod source_map;
|
2023-05-14 17:40:01 -04:00
|
|
|
pub mod task;
|
2023-03-04 19:10:31 -05:00
|
|
|
mod task_queue;
|
2019-02-26 17:36:05 -05:00
|
|
|
|
2020-09-16 14:28:07 -04:00
|
|
|
// Re-exports
|
2021-11-16 09:02:28 -05:00
|
|
|
pub use anyhow;
|
2020-09-16 14:28:07 -04:00
|
|
|
pub use futures;
|
2021-07-06 23:48:01 -04:00
|
|
|
pub use parking_lot;
|
2020-10-09 15:45:40 -04:00
|
|
|
pub use serde;
|
2020-09-16 14:28:07 -04:00
|
|
|
pub use serde_json;
|
2021-06-25 21:09:25 -04:00
|
|
|
pub use serde_v8;
|
2021-06-26 11:34:24 -04:00
|
|
|
pub use serde_v8::ByteString;
|
2022-07-11 11:27:33 -04:00
|
|
|
pub use serde_v8::DetachedBuffer;
|
2021-10-20 09:40:20 -04:00
|
|
|
pub use serde_v8::StringOrBuffer;
|
2022-03-15 19:22:00 -04:00
|
|
|
pub use serde_v8::U16String;
|
2022-04-25 10:56:47 -04:00
|
|
|
pub use serde_v8::ZeroCopyBuf;
|
2022-04-15 10:08:09 -04:00
|
|
|
pub use sourcemap;
|
2020-09-16 14:28:07 -04:00
|
|
|
pub use url;
|
2021-10-27 17:26:15 -04:00
|
|
|
pub use v8;
|
2020-01-05 09:19:29 -05:00
|
|
|
|
2023-01-14 23:06:46 -05:00
|
|
|
pub use deno_ops::op;
|
|
|
|
|
2020-12-03 17:52:55 -05:00
|
|
|
pub use crate::async_cancel::CancelFuture;
|
|
|
|
pub use crate::async_cancel::CancelHandle;
|
|
|
|
pub use crate::async_cancel::CancelTryFuture;
|
|
|
|
pub use crate::async_cancel::Cancelable;
|
|
|
|
pub use crate::async_cancel::Canceled;
|
|
|
|
pub use crate::async_cancel::TryCancelable;
|
2020-11-24 18:38:23 -05:00
|
|
|
pub use crate::async_cell::AsyncMut;
|
|
|
|
pub use crate::async_cell::AsyncMutFuture;
|
|
|
|
pub use crate::async_cell::AsyncRef;
|
|
|
|
pub use crate::async_cell::AsyncRefCell;
|
|
|
|
pub use crate::async_cell::AsyncRefFuture;
|
2020-12-03 17:52:55 -05:00
|
|
|
pub use crate::async_cell::RcLike;
|
2020-11-24 18:38:23 -05:00
|
|
|
pub use crate::async_cell::RcRef;
|
2022-03-14 13:44:15 -04:00
|
|
|
pub use crate::extensions::Extension;
|
|
|
|
pub use crate::extensions::ExtensionBuilder;
|
2023-02-07 18:21:43 -05:00
|
|
|
pub use crate::extensions::ExtensionFileSource;
|
2023-02-19 19:11:56 -05:00
|
|
|
pub use crate::extensions::ExtensionFileSourceCode;
|
2022-03-15 18:43:17 -04:00
|
|
|
pub use crate::extensions::OpDecl;
|
2022-03-14 13:44:15 -04:00
|
|
|
pub use crate::extensions::OpMiddlewareFn;
|
2023-04-04 08:46:31 -04:00
|
|
|
pub use crate::fast_string::FastString;
|
2019-03-11 17:57:36 -04:00
|
|
|
pub use crate::flags::v8_set_flags;
|
2021-12-28 11:40:42 -05:00
|
|
|
pub use crate::inspector::InspectorMsg;
|
|
|
|
pub use crate::inspector::InspectorMsgKind;
|
2021-05-26 15:07:12 -04:00
|
|
|
pub use crate::inspector::InspectorSessionProxy;
|
|
|
|
pub use crate::inspector::JsRuntimeInspector;
|
|
|
|
pub use crate::inspector::LocalInspectorSession;
|
2022-10-09 10:49:25 -04:00
|
|
|
pub use crate::io::BufMutView;
|
|
|
|
pub use crate::io::BufView;
|
|
|
|
pub use crate::io::WriteOutcome;
|
2021-02-17 13:47:18 -05:00
|
|
|
pub use crate::module_specifier::resolve_import;
|
|
|
|
pub use crate::module_specifier::resolve_path;
|
|
|
|
pub use crate::module_specifier::resolve_url;
|
|
|
|
pub use crate::module_specifier::resolve_url_or_path;
|
2020-05-28 13:36:43 -04:00
|
|
|
pub use crate::module_specifier::ModuleResolutionError;
|
|
|
|
pub use crate::module_specifier::ModuleSpecifier;
|
2023-03-08 06:44:54 -05:00
|
|
|
pub use crate::modules::ExtModuleLoader;
|
|
|
|
pub use crate::modules::ExtModuleLoaderCb;
|
2020-11-27 16:45:38 -05:00
|
|
|
pub use crate::modules::FsModuleLoader;
|
2023-03-21 18:33:12 -04:00
|
|
|
pub use crate::modules::ModuleCode;
|
2020-05-28 13:36:43 -04:00
|
|
|
pub use crate::modules::ModuleId;
|
|
|
|
pub use crate::modules::ModuleLoader;
|
|
|
|
pub use crate::modules::ModuleSource;
|
|
|
|
pub use crate::modules::ModuleSourceFuture;
|
2021-12-15 13:22:36 -05:00
|
|
|
pub use crate::modules::ModuleType;
|
2020-12-11 12:49:26 -05:00
|
|
|
pub use crate::modules::NoopModuleLoader;
|
2023-01-10 08:35:44 -05:00
|
|
|
pub use crate::modules::ResolutionKind;
|
2020-08-12 16:34:17 -04:00
|
|
|
pub use crate::normalize_path::normalize_path;
|
2021-10-09 16:37:19 -04:00
|
|
|
pub use crate::ops::OpCall;
|
2022-03-14 13:44:15 -04:00
|
|
|
pub use crate::ops::OpError;
|
2020-05-28 13:36:43 -04:00
|
|
|
pub use crate::ops::OpId;
|
2021-04-30 10:51:54 -04:00
|
|
|
pub use crate::ops::OpResult;
|
2020-09-10 09:57:45 -04:00
|
|
|
pub use crate::ops::OpState;
|
2021-03-31 10:37:38 -04:00
|
|
|
pub use crate::ops::PromiseId;
|
2021-04-25 13:23:22 -04:00
|
|
|
pub use crate::ops_builtin::op_close;
|
2021-05-02 19:30:03 -04:00
|
|
|
pub use crate::ops_builtin::op_print;
|
2021-04-25 13:23:22 -04:00
|
|
|
pub use crate::ops_builtin::op_resources;
|
2022-03-15 17:58:03 -04:00
|
|
|
pub use crate::ops_builtin::op_void_async;
|
|
|
|
pub use crate::ops_builtin::op_void_sync;
|
2022-03-14 13:44:15 -04:00
|
|
|
pub use crate::ops_metrics::OpsTracker;
|
2023-05-01 20:35:33 -04:00
|
|
|
pub use crate::path::strip_unc_prefix;
|
2023-04-08 11:00:02 -04:00
|
|
|
pub use crate::realm::JsRealm;
|
2021-11-09 13:26:17 -05:00
|
|
|
pub use crate::resources::AsyncResult;
|
2020-12-16 11:14:12 -05:00
|
|
|
pub use crate::resources::Resource;
|
|
|
|
pub use crate::resources::ResourceId;
|
2020-05-28 13:36:43 -04:00
|
|
|
pub use crate::resources::ResourceTable;
|
2021-12-21 09:53:46 -05:00
|
|
|
pub use crate::runtime::CompiledWasmModuleStore;
|
2021-12-29 20:05:26 -05:00
|
|
|
pub use crate::runtime::CrossIsolateStore;
|
2020-09-06 15:44:29 -04:00
|
|
|
pub use crate::runtime::GetErrorClassFn;
|
2020-12-01 17:33:44 -05:00
|
|
|
pub use crate::runtime::JsErrorCreateFn;
|
2020-09-06 15:44:29 -04:00
|
|
|
pub use crate::runtime::JsRuntime;
|
2020-09-11 09:18:49 -04:00
|
|
|
pub use crate::runtime::RuntimeOptions;
|
2021-12-21 09:53:46 -05:00
|
|
|
pub use crate::runtime::SharedArrayBufferStore;
|
2020-09-06 15:44:29 -04:00
|
|
|
pub use crate::runtime::Snapshot;
|
2022-08-18 08:05:02 -04:00
|
|
|
pub use crate::runtime::V8_WRAPPER_OBJECT_INDEX;
|
|
|
|
pub use crate::runtime::V8_WRAPPER_TYPE_INDEX;
|
2022-04-15 10:08:09 -04:00
|
|
|
pub use crate::source_map::SourceMapGetter;
|
2023-03-04 19:10:31 -05:00
|
|
|
pub use crate::task_queue::TaskQueue;
|
2023-03-04 20:07:11 -05:00
|
|
|
pub use crate::task_queue::TaskQueuePermit;
|
2019-02-26 17:36:05 -05:00
|
|
|
|
2019-03-11 17:57:36 -04:00
|
|
|
pub fn v8_version() -> &'static str {
|
2020-01-05 09:19:29 -05:00
|
|
|
v8::V8::get_version()
|
2019-02-26 17:36:05 -05:00
|
|
|
}
|
|
|
|
|
2023-01-14 23:06:46 -05:00
|
|
|
/// An internal module re-exporting functions used by the #[op] (`deno_ops`) macro
|
2022-03-14 13:44:15 -04:00
|
|
|
#[doc(hidden)]
|
|
|
|
pub mod _ops {
|
|
|
|
pub use super::bindings::throw_type_error;
|
|
|
|
pub use super::error_codes::get_error_code;
|
|
|
|
pub use super::ops::to_op_result;
|
2022-04-08 04:32:48 -04:00
|
|
|
pub use super::ops::OpCtx;
|
2022-11-11 08:44:53 -05:00
|
|
|
pub use super::ops::OpResult;
|
2023-04-26 14:02:27 -04:00
|
|
|
pub use super::runtime::map_async_op1;
|
|
|
|
pub use super::runtime::map_async_op2;
|
|
|
|
pub use super::runtime::map_async_op3;
|
|
|
|
pub use super::runtime::map_async_op4;
|
2022-03-14 13:44:15 -04:00
|
|
|
pub use super::runtime::queue_async_op;
|
2022-11-11 08:44:53 -05:00
|
|
|
pub use super::runtime::queue_fast_async_op;
|
2022-08-21 08:07:53 -04:00
|
|
|
pub use super::runtime::V8_WRAPPER_OBJECT_INDEX;
|
|
|
|
pub use super::runtime::V8_WRAPPER_TYPE_INDEX;
|
2022-03-14 13:44:15 -04:00
|
|
|
}
|
|
|
|
|
2021-06-21 19:45:41 -04:00
|
|
|
/// A helper macro that will return a call site in Rust code. Should be
|
|
|
|
/// used when executing internal one-line scripts for JsRuntime lifecycle.
|
|
|
|
///
|
2023-03-08 06:44:54 -05:00
|
|
|
/// Returns a string in form of: "`[ext:<filename>:<line>:<column>]`"
|
2021-06-21 19:45:41 -04:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! located_script_name {
|
|
|
|
() => {
|
2023-03-23 18:00:59 -04:00
|
|
|
concat!(
|
|
|
|
"[ext:",
|
|
|
|
std::file!(),
|
|
|
|
":",
|
|
|
|
std::line!(),
|
|
|
|
":",
|
|
|
|
std::column!(),
|
|
|
|
"]"
|
|
|
|
)
|
2021-06-21 19:45:41 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-02-01 10:55:23 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
2023-03-23 18:00:59 -04:00
|
|
|
#[test]
|
|
|
|
fn located_script_name() {
|
|
|
|
// Note that this test will fail if this file is moved. We don't
|
|
|
|
// test line locations because that's just too brittle.
|
2023-03-24 12:00:47 -04:00
|
|
|
let name = located_script_name!();
|
|
|
|
let expected = if cfg!(windows) {
|
|
|
|
"[ext:core\\lib.rs:"
|
|
|
|
} else {
|
|
|
|
"[ext:core/lib.rs:"
|
|
|
|
};
|
|
|
|
assert_eq!(&name[..expected.len()], expected);
|
2023-03-23 18:00:59 -04:00
|
|
|
}
|
|
|
|
|
2021-02-01 10:55:23 -05:00
|
|
|
#[test]
|
|
|
|
fn test_v8_version() {
|
|
|
|
assert!(v8_version().len() > 3);
|
|
|
|
}
|
2019-02-26 17:36:05 -05:00
|
|
|
}
|