From bd9f7e1fdd0e2baa3138551635361b9c5cb8eef0 Mon Sep 17 00:00:00 2001 From: Theodore Ni <3806110+tjni@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:25:25 -0800 Subject: [PATCH 1/7] Replace Deno.Closer with Closer from io/types. --- src/core/process.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/process.ts b/src/core/process.ts index 6912af70e1..b658141a5c 100644 --- a/src/core/process.ts +++ b/src/core/process.ts @@ -6,6 +6,7 @@ import { MuxAsyncIterator, pooledMap } from "async"; import { iterateReader } from "io/iterate-reader"; +import { type Closer } from "io/types"; import { debug, info } from "../deno_ral/log.ts"; import { onCleanup } from "./cleanup.ts"; import { ProcessResult } from "./process-types.ts"; @@ -104,7 +105,7 @@ export async function execProcess( // Add streams to the multiplexer const addStream = ( - stream: (Deno.Reader & Deno.Closer) | null, + stream: (Deno.Reader & Closer) | null, filter?: (output: string) => string, ) => { if (stream !== null) { @@ -131,7 +132,7 @@ export async function execProcess( } // Close the streams - const closeStream = (stream: (Deno.Reader & Deno.Closer) | null) => { + const closeStream = (stream: (Deno.Reader & Closer) | null) => { if (stream) { stream.close(); } From 4a498040c2fc2652a929b42fc41070ae8a0a3e40 Mon Sep 17 00:00:00 2001 From: Theodore Ni <3806110+tjni@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:31:27 -0800 Subject: [PATCH 2/7] Replace Deno.Reader with Reader from io/types. --- src/core/process.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/process.ts b/src/core/process.ts index b658141a5c..809431547b 100644 --- a/src/core/process.ts +++ b/src/core/process.ts @@ -6,7 +6,7 @@ import { MuxAsyncIterator, pooledMap } from "async"; import { iterateReader } from "io/iterate-reader"; -import { type Closer } from "io/types"; +import { type Closer, type Reader } from "io/types"; import { debug, info } from "../deno_ral/log.ts"; import { onCleanup } from "./cleanup.ts"; import { ProcessResult } from "./process-types.ts"; @@ -105,7 +105,7 @@ export async function execProcess( // Add streams to the multiplexer const addStream = ( - stream: (Deno.Reader & Closer) | null, + stream: (Reader & Closer) | null, filter?: (output: string) => string, ) => { if (stream !== null) { @@ -132,7 +132,7 @@ export async function execProcess( } // Close the streams - const closeStream = (stream: (Deno.Reader & Closer) | null) => { + const closeStream = (stream: (Reader & Closer) | null) => { if (stream) { stream.close(); } From 08c227a6ffd2ddb3e5570cc2518c1e1683e3a337 Mon Sep 17 00:00:00 2001 From: Theodore Ni <3806110+tjni@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:35:52 -0800 Subject: [PATCH 3/7] Replace Deno.close() with close() on resource. --- package/src/util/utils.ts | 2 +- src/core/console.ts | 2 +- src/project/types/website/listing/website-listing-feed.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package/src/util/utils.ts b/package/src/util/utils.ts index 3a0445a2d7..f3145cf642 100644 --- a/package/src/util/utils.ts +++ b/package/src/util/utils.ts @@ -24,7 +24,7 @@ export async function download(src: string, dest: string): Promise { const file = await Deno.create(dest); await writeAll(file, contents); - Deno.close(file.rid); + file.close(); } export async function unzip( diff --git a/src/core/console.ts b/src/core/console.ts index 590e855479..0795ed0685 100644 --- a/src/core/console.ts +++ b/src/core/console.ts @@ -173,7 +173,7 @@ export function writeFileToStdout(file: string) { const df = Deno.openSync(file, { read: true }); const contents = readAllSync(df); writeAllSync(Deno.stdout, contents); - Deno.close(df.rid); + df.close(); } export function clearLine() { diff --git a/src/project/types/website/listing/website-listing-feed.ts b/src/project/types/website/listing/website-listing-feed.ts index b23f144dd7..d99291625c 100644 --- a/src/project/types/website/listing/website-listing-feed.ts +++ b/src/project/types/website/listing/website-listing-feed.ts @@ -536,7 +536,7 @@ async function generateFeed( ); await Deno.write(feedFile.rid, textEncoder.encode(postamble)); } finally { - Deno.close(feedFile.rid); + feedFile.close(); } } From 99a97a91b2a09830f85ffa5948fb59cbd215c470 Mon Sep 17 00:00:00 2001 From: Theodore Ni <3806110+tjni@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:28:26 -0800 Subject: [PATCH 4/7] Replace Deno.isatty with isTerminal(). --- src/core/platform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/platform.ts b/src/core/platform.ts index 74c890d4e4..adb28fc819 100644 --- a/src/core/platform.ts +++ b/src/core/platform.ts @@ -93,7 +93,7 @@ export function jupyterHubServicePrefix() { } export function isInteractiveTerminal() { - return Deno.isatty(Deno.stderr.rid); + return Deno.stderr.isTerminal(); } export function isInteractiveSession() { From d09d6bd686967d6d806c63a53d3f3304ed9cb372 Mon Sep 17 00:00:00 2001 From: Theodore Ni <3806110+tjni@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:32:59 -0800 Subject: [PATCH 5/7] Remove Deno.metrics() call. This API has been removed without replacement in Deno 2. --- src/core/performance/metrics.ts | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/src/core/performance/metrics.ts b/src/core/performance/metrics.ts index 9551375a59..fe4dfcbe06 100644 --- a/src/core/performance/metrics.ts +++ b/src/core/performance/metrics.ts @@ -41,37 +41,4 @@ export function reportPeformanceMetrics() { console.log("Performance metrics"); console.log("Quarto:"); console.log(JSON.stringify(quartoPerformanceMetrics(), null, 2)); - console.log(); - // denoMetrics is some kind of fancy object that doesn't respond - // to a bunch of the normal methods. So we have to do this - // the JSON-round-trip way. - console.log("Deno:"); - const denoMetrics = JSON.parse(JSON.stringify(Deno.metrics() as any)); - denoMetrics.ops = Object.fromEntries( - Object.entries(denoMetrics.ops).map( - ([key, opMetrics]: any) => { - for (const key of Object.keys(opMetrics)) { - if (opMetrics[key] === 0) { - delete opMetrics[key]; - } - } - return [key, opMetrics]; - }, - ).filter(([_key, opMetrics]: any) => Object.keys(opMetrics).length > 0) - .map(([key, opMetrics]: any) => { - if ( - (opMetrics.opsDispatched === opMetrics.opsDispatchedSync && - opMetrics.opsDispatched === opMetrics.opsCompleted && - opMetrics.opsDispatched === opMetrics.opsCompletedSync) || - (opMetrics.opsDispatched === opMetrics.opsDispatchedAsync && - opMetrics.opsDispatched === opMetrics.opsCompleted && - opMetrics.opsDispatched === opMetrics.opsCompletedAsync) - ) { - return [key, opMetrics.opsDispatched]; - } else { - return [key, opMetrics]; - } - }), - ); - console.log(JSON.stringify(denoMetrics, null, 2)); } From d559c203db8701ba6ea995781c3c3028254f395e Mon Sep 17 00:00:00 2001 From: Theodore Ni <3806110+tjni@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:37:33 -0800 Subject: [PATCH 6/7] Replace Deno.write with instance method. --- src/project/types/website/listing/website-listing-feed.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/project/types/website/listing/website-listing-feed.ts b/src/project/types/website/listing/website-listing-feed.ts index d99291625c..1b9d6ccd46 100644 --- a/src/project/types/website/listing/website-listing-feed.ts +++ b/src/project/types/website/listing/website-listing-feed.ts @@ -513,7 +513,7 @@ async function generateFeed( escape, }, ); - await Deno.write(feedFile.rid, textEncoder.encode(preamble)); + await feedFile.write(textEncoder.encode(preamble)); for (const feedItem of feedItems) { const item = renderEjs( @@ -523,7 +523,7 @@ async function generateFeed( escape, }, ); - await Deno.write(feedFile.rid, textEncoder.encode(item)); + await feedFile.write(textEncoder.encode(item)); } // Render the postamble @@ -534,7 +534,7 @@ async function generateFeed( escape, }, ); - await Deno.write(feedFile.rid, textEncoder.encode(postamble)); + await feedFile.write(textEncoder.encode(postamble)); } finally { feedFile.close(); } From 5b9df7343b666c3ff1790f72286cf7f1d1e5293b Mon Sep 17 00:00:00 2001 From: Theodore Ni <3806110+tjni@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:43:50 -0800 Subject: [PATCH 7/7] Replace window with globalThis. --- src/publish/common/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish/common/publish.ts b/src/publish/common/publish.ts index 20c9e1f7cf..e5a11573cc 100644 --- a/src/publish/common/publish.ts +++ b/src/publish/common/publish.ts @@ -267,7 +267,7 @@ function stageDocumentPublish(title: string, publishFiles: PublishFiles) { const publishDir = globalTempContext().createDir(); // copy all files to it - const stagedFiles = window.structuredClone(publishFiles) as PublishFiles; + const stagedFiles = globalThis.structuredClone(publishFiles) as PublishFiles; stagedFiles.baseDir = publishDir; for (const file of publishFiles.files) { const src = join(publishFiles.baseDir, file);