diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2024-09-24 07:04:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 07:04:52 -0700 |
commit | 5a1943cd9560466a5922bd3cd79cca5c9f378561 (patch) | |
tree | 8d73d135dc638a2d8d169bc93df8ddbccfedf945 | |
parent | 3242550f5f0b33769a4e0a24a7dc96773647ca75 (diff) |
fix: better error for Deno.UnsafeWindowSurface, correct HttpClient name, cleanup unused code (#25833)
-rw-r--r-- | cli/main.rs | 7 | ||||
-rw-r--r-- | cli/tsc/dts/lib.deno.ns.d.ts | 4 | ||||
-rw-r--r-- | runtime/js/90_deno_ns.js | 11 | ||||
-rw-r--r-- | runtime/lib.rs | 4 | ||||
-rw-r--r-- | tests/unit/fetch_test.ts | 1 |
5 files changed, 14 insertions, 13 deletions
diff --git a/cli/main.rs b/cli/main.rs index 84c3704ca..c0eccab5d 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -385,6 +385,13 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec<FixSuggestion> { FixSuggestion::info("window global is not available in Deno 2."), FixSuggestion::hint("Replace `window` with `globalThis`."), ]; + } else if msg.contains("UnsafeWindowSurface is not a constructor") { + return vec![ + FixSuggestion::info("Deno.UnsafeWindowSurface is an unstable API."), + FixSuggestion::hint( + "Run again with `--unstable-webgpu` flag to enable this API.", + ), + ]; } } diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 3cca95cdf..36592e10d 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -6041,9 +6041,11 @@ declare namespace Deno { * * @category Fetch */ - export interface HttpClient extends Disposable { + export class HttpClient implements Disposable { /** Close the HTTP client. */ close(): void; + + [Symbol.dispose](): void; } /** diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 35378da4d..2448bc3bc 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -132,7 +132,7 @@ const denoNs = { UnsafePointerView: ffi.UnsafePointerView, UnsafeFnPointer: ffi.UnsafeFnPointer, umask: fs.umask, - httpClient: httpClient.httpClient, + HttpClient: httpClient.HttpClient, createHttpClient: httpClient.createHttpClient, }; @@ -160,15 +160,6 @@ denoNsUnstableById[unstableIds.cron] = { cron: cron.cron, }; -denoNsUnstableById[unstableIds.ffi] = {}; - -denoNsUnstableById[unstableIds.fs] = {}; - -denoNsUnstableById[unstableIds.http] = { - HttpClient: httpClient.HttpClient, - createHttpClient: httpClient.createHttpClient, -}; - denoNsUnstableById[unstableIds.kv] = { openKv: kv.openKv, AtomicOperation: kv.AtomicOperation, diff --git a/runtime/lib.rs b/runtime/lib.rs index 034c094a0..f0b1129ce 100644 --- a/runtime/lib.rs +++ b/runtime/lib.rs @@ -122,8 +122,8 @@ pub static UNSTABLE_GRANULAR_FLAGS: &[UnstableGranularFlag] = &[ }, UnstableGranularFlag { name: deno_webgpu::UNSTABLE_FEATURE_NAME, - help_text: "Enable unstable `WebGPU` API", - show_in_help: false, + help_text: "Enable unstable `WebGPU` APIs", + show_in_help: true, id: 11, }, UnstableGranularFlag { diff --git a/tests/unit/fetch_test.ts b/tests/unit/fetch_test.ts index 48cde90ab..3ae96746a 100644 --- a/tests/unit/fetch_test.ts +++ b/tests/unit/fetch_test.ts @@ -1156,6 +1156,7 @@ Deno.test( > { const caCert = Deno.readTextFileSync("tests/testdata/tls/RootCA.pem"); const client = Deno.createHttpClient({ caCerts: [caCert] }); + assert(client instanceof Deno.HttpClient); const response = await fetch("https://localhost:5545/assets/fixture.json", { client, }); |