Skip to content

Commit

Permalink
refactor: rename deno specifiers to internal (denoland#17655)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats authored Feb 5, 2023
1 parent a092963 commit 84a9611
Show file tree
Hide file tree
Showing 46 changed files with 95 additions and 84 deletions.
2 changes: 1 addition & 1 deletion cli/args/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ pub fn get_ts_config_for_emit(
"sourceMap": false,
"strict": true,
"target": "esnext",
"tsBuildInfoFile": "deno:///.tsbuildinfo",
"tsBuildInfoFile": "internal:///.tsbuildinfo",
"useDefineForClassFields": true,
// TODO(@kitsonk) remove for Deno 2.0
"useUnknownInCatchVariables": false,
Expand Down
4 changes: 2 additions & 2 deletions cli/args/flags_allow_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl FromStr for BarePort {
}

pub fn validator(host_and_port: &str) -> Result<(), String> {
if Url::parse(&format!("deno://{host_and_port}")).is_ok()
if Url::parse(&format!("internal://{host_and_port}")).is_ok()
|| host_and_port.parse::<IpAddr>().is_ok()
|| host_and_port.parse::<BarePort>().is_ok()
{
Expand All @@ -43,7 +43,7 @@ pub fn validator(host_and_port: &str) -> Result<(), String> {
pub fn parse(paths: Vec<String>) -> clap::Result<Vec<String>> {
let mut out: Vec<String> = vec![];
for host_and_port in paths.iter() {
if Url::parse(&format!("deno://{host_and_port}")).is_ok()
if Url::parse(&format!("internal://{host_and_port}")).is_ok()
|| host_and_port.parse::<IpAddr>().is_ok()
{
out.push(host_and_port.to_owned())
Expand Down
6 changes: 3 additions & 3 deletions cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ impl Inner {

async fn did_close(&mut self, params: DidCloseTextDocumentParams) {
let mark = self.performance.mark("did_close", Some(&params));
if params.text_document.uri.scheme() == "deno" {
if params.text_document.uri.scheme() == "internal" {
// we can ignore virtual text documents closing, as they don't need to
// be tracked in memory, as they are static assets that won't change
// already managed by the language service
Expand Down Expand Up @@ -2609,7 +2609,7 @@ impl tower_lsp::LanguageServer for LanguageServer {
}

async fn did_open(&self, params: DidOpenTextDocumentParams) {
if params.text_document.uri.scheme() == "deno" {
if params.text_document.uri.scheme() == "internal" {
// we can ignore virtual text documents opening, as they don't need to
// be tracked in memory, as they are static assets that won't change
// already managed by the language service
Expand Down Expand Up @@ -3121,7 +3121,7 @@ impl Inner {
.performance
.mark("virtual_text_document", Some(&params));
let specifier = self.url_map.normalize_url(&params.text_document.uri);
let contents = if specifier.as_str() == "deno:/status.md" {
let contents = if specifier.as_str() == "internal:/status.md" {
let mut contents = String::new();
let mut documents_specifiers = self
.documents
Expand Down
8 changes: 6 additions & 2 deletions cli/lsp/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,11 +1154,15 @@ impl ImplementationLocation {
language_server: &language_server::Inner,
) -> lsp::Location {
let specifier = normalize_specifier(&self.document_span.file_name)
.unwrap_or_else(|_| ModuleSpecifier::parse("deno://invalid").unwrap());
.unwrap_or_else(|_| {
ModuleSpecifier::parse("internal://invalid").unwrap()
});
let uri = language_server
.url_map
.normalize_specifier(&specifier)
.unwrap_or_else(|_| ModuleSpecifier::parse("deno://invalid").unwrap());
.unwrap_or_else(|_| {
ModuleSpecifier::parse("internal://invalid").unwrap()
});
lsp::Location {
uri,
range: self.document_span.text_span.to_range(line_index),
Expand Down
18 changes: 9 additions & 9 deletions cli/lsp/urls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::sync::Arc;
/// Used in situations where a default URL needs to be used where otherwise a
/// panic is undesired.
pub static INVALID_SPECIFIER: Lazy<ModuleSpecifier> =
Lazy::new(|| ModuleSpecifier::parse("deno://invalid").unwrap());
Lazy::new(|| ModuleSpecifier::parse("internal://invalid").unwrap());

/// Matches the `encodeURIComponent()` encoding from JavaScript, which matches
/// the component percent encoding set.
Expand Down Expand Up @@ -81,7 +81,7 @@ impl LspUrlMapInner {
}

/// A bi-directional map of URLs sent to the LSP client and internal module
/// specifiers. We need to map internal specifiers into `deno:` schema URLs
/// specifiers. We need to map internal specifiers into `internal:` schema URLs
/// to allow the Deno language server to manage these as virtual documents.
#[derive(Debug, Default, Clone)]
pub struct LspUrlMap(Arc<Mutex<LspUrlMapInner>>);
Expand All @@ -101,7 +101,7 @@ impl LspUrlMap {
specifier.clone()
} else {
let specifier_str = if specifier.scheme() == "asset" {
format!("deno:/asset{}", specifier.path())
format!("internal:/asset{}", specifier.path())
} else if specifier.scheme() == "data" {
let data_url = DataUrl::process(specifier.as_str())
.map_err(|e| uri_error(format!("{e:?}")))?;
Expand All @@ -114,7 +114,7 @@ impl LspUrlMap {
media_type.as_ts_extension()
};
format!(
"deno:/{}/data_url{}",
"internal:/{}/data_url{}",
hash_data_specifier(specifier),
extension
)
Expand All @@ -128,7 +128,7 @@ impl LspUrlMap {
})
.collect();
path.push_str(&parts.join("/"));
format!("deno:/{path}")
format!("internal:/{path}")
};
let url = Url::parse(&specifier_str)?;
inner.put(specifier.clone(), url.clone());
Expand All @@ -138,7 +138,7 @@ impl LspUrlMap {
}
}

/// Normalize URLs from the client, where "virtual" `deno:///` URLs are
/// Normalize URLs from the client, where "virtual" `internal:///` URLs are
/// converted into proper module specifiers, as well as handle situations
/// where the client encodes a file URL differently than Rust does by default
/// causing issues with string matching of URLs.
Expand Down Expand Up @@ -178,7 +178,7 @@ mod tests {
.normalize_specifier(&fixture)
.expect("could not handle specifier");
let expected_url =
Url::parse("deno:/https/deno.land/x/pkg%401.0.0/mod.ts").unwrap();
Url::parse("internal:/https/deno.land/x/pkg%401.0.0/mod.ts").unwrap();
assert_eq!(actual_url, expected_url);

let actual_specifier = map.normalize_url(&actual_url);
Expand All @@ -193,7 +193,7 @@ mod tests {
let actual_url = map
.normalize_specifier(&fixture)
.expect("could not handle specifier");
let expected_url = Url::parse("deno:/https/cdn.skypack.dev/-/postcss%40v8.2.9-E4SktPp9c0AtxrJHp8iV/dist%3Des2020%2Cmode%3Dtypes/lib/postcss.d.ts").unwrap();
let expected_url = Url::parse("internal:/https/cdn.skypack.dev/-/postcss%40v8.2.9-E4SktPp9c0AtxrJHp8iV/dist%3Des2020%2Cmode%3Dtypes/lib/postcss.d.ts").unwrap();
assert_eq!(actual_url, expected_url);

let actual_specifier = map.normalize_url(&actual_url);
Expand All @@ -207,7 +207,7 @@ mod tests {
let actual_url = map
.normalize_specifier(&fixture)
.expect("could not handle specifier");
let expected_url = Url::parse("deno:/c21c7fc382b2b0553dc0864aa81a3acacfb7b3d1285ab5ae76da6abec213fb37/data_url.ts").unwrap();
let expected_url = Url::parse("internal:/c21c7fc382b2b0553dc0864aa81a3acacfb7b3d1285ab5ae76da6abec213fb37/data_url.ts").unwrap();
assert_eq!(actual_url, expected_url);

let actual_specifier = map.normalize_url(&actual_url);
Expand Down
2 changes: 1 addition & 1 deletion cli/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl NodeResolution {
}
Some(resolution) => (resolution.into_url(), MediaType::Dts),
None => (
ModuleSpecifier::parse("deno:///missing_dependency.d.ts").unwrap(),
ModuleSpecifier::parse("internal:///missing_dependency.d.ts").unwrap(),
MediaType::Dts,
),
}
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ fn lsp_hover_asset() {
"deno/virtualTextDocument",
json!({
"textDocument": {
"uri": "deno:/asset/lib.deno.shared_globals.d.ts"
"uri": "internal:/asset/lib.deno.shared_globals.d.ts"
}
}),
)
Expand All @@ -1084,7 +1084,7 @@ fn lsp_hover_asset() {
"textDocument/hover",
json!({
"textDocument": {
"uri": "deno:/asset/lib.es2015.symbol.wellknown.d.ts"
"uri": "internal:/asset/lib.es2015.symbol.wellknown.d.ts"
},
"position": {
"line": 109,
Expand Down Expand Up @@ -3103,7 +3103,7 @@ fn lsp_code_lens_non_doc_nav_tree() {
"deno/virtualTextDocument",
json!({
"textDocument": {
"uri": "deno:/asset/lib.deno.shared_globals.d.ts"
"uri": "internal:/asset/lib.deno.shared_globals.d.ts"
}
}),
)
Expand All @@ -3115,7 +3115,7 @@ fn lsp_code_lens_non_doc_nav_tree() {
"textDocument/codeLens",
json!({
"textDocument": {
"uri": "deno:/asset/lib.deno.shared_globals.d.ts"
"uri": "internal:/asset/lib.deno.shared_globals.d.ts"
}
}),
)
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/testdata/run/error_009_extensions_error.js.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
new Event();
^
at [WILDCARD]
at new Event (deno:ext/web/[WILDCARD])
at new Event (internal:ext/web/[WILDCARD])
at [WILDCARD]
2 changes: 1 addition & 1 deletion cli/tests/testdata/run/fetch_async_error_stack.ts.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: Uncaught (in promise) TypeError: error sending request for url[WILDCARD]
await fetch("https://nonexistent.deno.land/");
^[WILDCARD]
at async fetch (deno:[WILDCARD])
at async fetch (internal:[WILDCARD])
at async file:///[WILDCARD]/fetch_async_error_stack.ts:1:1
2 changes: 1 addition & 1 deletion cli/tests/testdata/run/queue_microtask_error.ts.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ error: Uncaught Error: foo
throw new Error("foo");
^
at [WILDCARD]/queue_microtask_error.ts:2:9
at deno:core/[WILDCARD]
at internal:core/[WILDCARD]
4 changes: 2 additions & 2 deletions cli/tests/testdata/run/queue_microtask_error_handled.ts.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
colno: 9,
error: Error: foo
at [WILDCARD]/queue_microtask_error_handled.ts:18:9
at deno:core/[WILDCARD]
at internal:core/[WILDCARD]
}
onerror() called Error: foo
at [WILDCARD]/queue_microtask_error_handled.ts:18:9
at deno:core/[WILDCARD]
at internal:core/[WILDCARD]
2
2 changes: 1 addition & 1 deletion cli/tests/testdata/run/wasm_streaming_panic_test.js.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
error: Uncaught (in promise) TypeError: Invalid WebAssembly content type.
at handleWasmStreaming (deno:ext/fetch/26_fetch.js:[WILDCARD])
at handleWasmStreaming (internal:ext/fetch/26_fetch.js:[WILDCARD])
6 changes: 3 additions & 3 deletions cli/tests/testdata/run/worker_drop_handle_race.js.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: Uncaught (in worker "") Error
throw new Error();
^
at [WILDCARD]/workers/drop_handle_race.js:2:9
at Object.action (deno:ext/web/02_timers.js:[WILDCARD])
at handleTimerMacrotask (deno:ext/web/02_timers.js:[WILDCARD])
at Object.action (internal:ext/web/02_timers.js:[WILDCARD])
at handleTimerMacrotask (internal:ext/web/02_timers.js:[WILDCARD])
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl (deno:runtime/js/11_workers.js:[WILDCARD])
at Worker.#pollControl (internal:runtime/js/11_workers.js:[WILDCARD])
8 changes: 4 additions & 4 deletions cli/tests/testdata/test/steps/failing_steps.out
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ failing step in failing test ... FAILED ([WILDCARD])

nested failure => ./test/steps/failing_steps.ts:[WILDCARD]
error: Error: 1 test step failed.
at runTest (deno:cli/js/40_testing.js:[WILDCARD])
at async runTests (deno:cli/js/40_testing.js:[WILDCARD])
at runTest (internal:cli/js/40_testing.js:[WILDCARD])
at async runTests (internal:cli/js/40_testing.js:[WILDCARD])

multiple test step failures => ./test/steps/failing_steps.ts:[WILDCARD]
error: Error: 2 test steps failed.
at runTest (deno:cli/js/40_testing.js:[WILDCARD])
at async runTests (deno:cli/js/40_testing.js:[WILDCARD])
at runTest (internal:cli/js/40_testing.js:[WILDCARD])
at async runTests (internal:cli/js/40_testing.js:[WILDCARD])

failing step in failing test => ./test/steps/failing_steps.ts:[WILDCARD]
error: Error: Fail test.
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/unit/opcall_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Deno.test(async function sendAsyncStackTrace() {
assertStringIncludes(s, "opcall_test.ts");
assertStringIncludes(s, "read");
assert(
!s.includes("deno:core"),
"opcall stack traces should NOT include deno:core internals such as unwrapOpResult",
!s.includes("internal:core"),
"opcall stack traces should NOT include internal:core internals such as unwrapOpResult",
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ fn filter_coverages(
coverages
.into_iter()
.filter(|e| {
let is_internal = e.url.starts_with("deno:")
let is_internal = e.url.starts_with("internal:")
|| e.url.ends_with("__anonymous__")
|| e.url.ends_with("$deno$test.js")
|| e.url.ends_with(".snap");
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub async fn print_docs(
let mut doc_nodes = match doc_flags.source_file {
DocSourceFileFlag::Builtin => {
let source_file_specifier =
ModuleSpecifier::parse("deno://lib.deno.d.ts").unwrap();
ModuleSpecifier::parse("internal://lib.deno.d.ts").unwrap();
let content = get_types_declaration_file_text(ps.options.unstable());
let mut loader = deno_graph::source::MemoryLoader::new(
vec![(
Expand Down
6 changes: 4 additions & 2 deletions cli/tools/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ fn abbreviate_test_error(js_error: &JsError) -> JsError {
// check if there are any stack frames coming from user code
let should_filter = frames.iter().any(|f| {
if let Some(file_name) = &f.file_name {
!(file_name.starts_with("[deno:") || file_name.starts_with("deno:"))
!(file_name.starts_with("[internal:")
|| file_name.starts_with("internal:"))
} else {
true
}
Expand All @@ -667,7 +668,8 @@ fn abbreviate_test_error(js_error: &JsError) -> JsError {
.rev()
.skip_while(|f| {
if let Some(file_name) = &f.file_name {
file_name.starts_with("[deno:") || file_name.starts_with("deno:")
file_name.starts_with("[internal:")
|| file_name.starts_with("internal:")
} else {
false
}
Expand Down
24 changes: 13 additions & 11 deletions cli/tsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ struct EmitArgs {
fn op_emit(state: &mut OpState, args: EmitArgs) -> bool {
let state = state.borrow_mut::<State>();
match args.file_name.as_ref() {
"deno:///.tsbuildinfo" => state.maybe_tsbuildinfo = Some(args.data),
"internal:///.tsbuildinfo" => state.maybe_tsbuildinfo = Some(args.data),
_ => {
if cfg!(debug_assertions) {
panic!("Unhandled emit write: {}", args.file_name);
Expand Down Expand Up @@ -518,11 +518,11 @@ fn op_load(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
let mut hash: Option<String> = None;
let mut media_type = MediaType::Unknown;
let graph_data = state.graph_data.read();
let data = if &v.specifier == "deno:///.tsbuildinfo" {
let data = if &v.specifier == "internal:///.tsbuildinfo" {
state.maybe_tsbuildinfo.as_deref().map(Cow::Borrowed)
// in certain situations we return a "blank" module to tsc and we need to
// handle the request for that module here.
} else if &v.specifier == "deno:///missing_dependency.d.ts" {
} else if &v.specifier == "internal:///missing_dependency.d.ts" {
hash = Some("1".to_string());
media_type = MediaType::Dts;
Some(Cow::Borrowed("declare const __: any;\nexport = __;\n"))
Expand Down Expand Up @@ -726,7 +726,7 @@ fn op_resolve(
(specifier_str, media_type.as_ts_extension().into())
}
None => (
"deno:///missing_dependency.d.ts".to_string(),
"internal:///missing_dependency.d.ts".to_string(),
".d.ts".to_string(),
),
};
Expand Down Expand Up @@ -983,10 +983,10 @@ mod tests {
"lib": ["deno.window"],
"module": "esnext",
"noEmit": true,
"outDir": "deno:///",
"outDir": "internal:///",
"strict": true,
"target": "esnext",
"tsBuildInfoFile": "deno:///.tsbuildinfo",
"tsBuildInfoFile": "internal:///.tsbuildinfo",
}));
let request = Request {
config,
Expand Down Expand Up @@ -1075,7 +1075,7 @@ mod tests {
&mut state,
EmitArgs {
data: "some file content".to_string(),
file_name: "deno:///.tsbuildinfo".to_string(),
file_name: "internal:///.tsbuildinfo".to_string(),
},
);
assert!(actual);
Expand Down Expand Up @@ -1146,9 +1146,11 @@ mod tests {
Some("some content".to_string()),
)
.await;
let actual =
op_load::call(&mut state, json!({ "specifier": "deno:///.tsbuildinfo"}))
.expect("should have invoked op");
let actual = op_load::call(
&mut state,
json!({ "specifier": "internal:///.tsbuildinfo"}),
)
.expect("should have invoked op");
assert_eq!(
actual,
json!({
Expand Down Expand Up @@ -1217,7 +1219,7 @@ mod tests {
.expect("should have not errored");
assert_eq!(
actual,
vec![("deno:///missing_dependency.d.ts".into(), ".d.ts".into())]
vec![("internal:///missing_dependency.d.ts".into(), ".d.ts".into())]
);
}

Expand Down
Loading

0 comments on commit 84a9611

Please sign in to comment.