mirror of
https://github.com/denoland/deno.git
synced 2024-12-26 17:19:06 -05:00
cd61c01545
Remove `ExtensionFileSourceCode::LoadedFromFsDuringSnapshot` and feature `include_js_for_snapshotting` since they leak paths that are only applicable in this repo to embedders. Replace with feature `exclude_js_sources`. Additionally the feature `force_include_js_sources` allows negating it, if both features are set. We need both of these because features are additive and there must be a way of force including sources for snapshot creation while still having the `exclude_js_sources` feature. `force_include_js_sources` is only set for build deps, so sources are still excluded from the final binary. You can also specify `force_include_js_sources` on any extension to override the above features for that extension. Towards #19398. But there was still the snapshot-from-snapshot situation where code could be executed twice, I addressed that by making `mod_evaluate()` and scripts like `core/01_core.js` behave idempotently. This allowed unifying `ext::init_ops()` and `ext::init_ops_and_esm()` into `ext::init()`.
187 lines
5.4 KiB
Rust
187 lines
5.4 KiB
Rust
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
mod async_cancel;
|
|
mod async_cell;
|
|
mod bindings;
|
|
pub mod error;
|
|
mod error_codes;
|
|
mod extensions;
|
|
mod fast_string;
|
|
mod flags;
|
|
mod gotham_state;
|
|
mod inspector;
|
|
mod io;
|
|
mod module_specifier;
|
|
mod modules;
|
|
mod normalize_path;
|
|
mod ops;
|
|
mod ops_builtin;
|
|
mod ops_builtin_v8;
|
|
mod ops_metrics;
|
|
mod path;
|
|
mod realm;
|
|
mod resources;
|
|
mod runtime;
|
|
pub mod snapshot_util;
|
|
mod source_map;
|
|
pub mod task;
|
|
mod task_queue;
|
|
|
|
// Re-exports
|
|
pub use anyhow;
|
|
pub use futures;
|
|
pub use parking_lot;
|
|
pub use serde;
|
|
pub use serde_json;
|
|
pub use serde_v8;
|
|
pub use serde_v8::ByteString;
|
|
pub use serde_v8::DetachedBuffer;
|
|
pub use serde_v8::StringOrBuffer;
|
|
pub use serde_v8::U16String;
|
|
pub use serde_v8::ZeroCopyBuf;
|
|
pub use sourcemap;
|
|
pub use url;
|
|
pub use v8;
|
|
|
|
pub use deno_ops::op;
|
|
|
|
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;
|
|
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;
|
|
pub use crate::async_cell::RcLike;
|
|
pub use crate::async_cell::RcRef;
|
|
pub use crate::extensions::Extension;
|
|
pub use crate::extensions::ExtensionBuilder;
|
|
pub use crate::extensions::ExtensionFileSource;
|
|
pub use crate::extensions::OpDecl;
|
|
pub use crate::extensions::OpMiddlewareFn;
|
|
pub use crate::fast_string::FastString;
|
|
pub use crate::flags::v8_set_flags;
|
|
pub use crate::inspector::InspectorMsg;
|
|
pub use crate::inspector::InspectorMsgKind;
|
|
pub use crate::inspector::InspectorSessionProxy;
|
|
pub use crate::inspector::JsRuntimeInspector;
|
|
pub use crate::inspector::LocalInspectorSession;
|
|
pub use crate::io::BufMutView;
|
|
pub use crate::io::BufView;
|
|
pub use crate::io::WriteOutcome;
|
|
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;
|
|
pub use crate::module_specifier::ModuleResolutionError;
|
|
pub use crate::module_specifier::ModuleSpecifier;
|
|
pub use crate::modules::ExtModuleLoaderCb;
|
|
pub use crate::modules::FsModuleLoader;
|
|
pub use crate::modules::ModuleCode;
|
|
pub use crate::modules::ModuleId;
|
|
pub use crate::modules::ModuleLoader;
|
|
pub use crate::modules::ModuleSource;
|
|
pub use crate::modules::ModuleSourceFuture;
|
|
pub use crate::modules::ModuleType;
|
|
pub use crate::modules::NoopModuleLoader;
|
|
pub use crate::modules::ResolutionKind;
|
|
pub use crate::normalize_path::normalize_path;
|
|
pub use crate::ops::OpCall;
|
|
pub use crate::ops::OpError;
|
|
pub use crate::ops::OpId;
|
|
pub use crate::ops::OpResult;
|
|
pub use crate::ops::OpState;
|
|
pub use crate::ops::PromiseId;
|
|
pub use crate::ops_builtin::op_close;
|
|
pub use crate::ops_builtin::op_print;
|
|
pub use crate::ops_builtin::op_resources;
|
|
pub use crate::ops_builtin::op_void_async;
|
|
pub use crate::ops_builtin::op_void_sync;
|
|
pub use crate::ops_metrics::OpsTracker;
|
|
pub use crate::path::strip_unc_prefix;
|
|
pub use crate::realm::JsRealm;
|
|
pub use crate::resources::AsyncResult;
|
|
pub use crate::resources::Resource;
|
|
pub use crate::resources::ResourceId;
|
|
pub use crate::resources::ResourceTable;
|
|
pub use crate::runtime::CompiledWasmModuleStore;
|
|
pub use crate::runtime::CrossIsolateStore;
|
|
pub use crate::runtime::GetErrorClassFn;
|
|
pub use crate::runtime::JsErrorCreateFn;
|
|
pub use crate::runtime::JsRuntime;
|
|
pub use crate::runtime::JsRuntimeForSnapshot;
|
|
pub use crate::runtime::RuntimeOptions;
|
|
pub use crate::runtime::SharedArrayBufferStore;
|
|
pub use crate::runtime::Snapshot;
|
|
pub use crate::runtime::V8_WRAPPER_OBJECT_INDEX;
|
|
pub use crate::runtime::V8_WRAPPER_TYPE_INDEX;
|
|
pub use crate::source_map::SourceMapGetter;
|
|
pub use crate::task_queue::TaskQueue;
|
|
pub use crate::task_queue::TaskQueuePermit;
|
|
|
|
pub fn v8_version() -> &'static str {
|
|
v8::V8::get_version()
|
|
}
|
|
|
|
/// An internal module re-exporting functions used by the #[op] (`deno_ops`) macro
|
|
#[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;
|
|
pub use super::ops::OpCtx;
|
|
pub use super::ops::OpResult;
|
|
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;
|
|
pub use super::runtime::queue_async_op;
|
|
pub use super::runtime::queue_fast_async_op;
|
|
pub use super::runtime::V8_WRAPPER_OBJECT_INDEX;
|
|
pub use super::runtime::V8_WRAPPER_TYPE_INDEX;
|
|
}
|
|
|
|
/// A helper macro that will return a call site in Rust code. Should be
|
|
/// used when executing internal one-line scripts for JsRuntime lifecycle.
|
|
///
|
|
/// Returns a string in form of: "`[ext:<filename>:<line>:<column>]`"
|
|
#[macro_export]
|
|
macro_rules! located_script_name {
|
|
() => {
|
|
concat!(
|
|
"[ext:",
|
|
std::file!(),
|
|
":",
|
|
std::line!(),
|
|
":",
|
|
std::column!(),
|
|
"]"
|
|
)
|
|
};
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[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.
|
|
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);
|
|
}
|
|
|
|
#[test]
|
|
fn test_v8_version() {
|
|
assert!(v8_version().len() > 3);
|
|
}
|
|
}
|