1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix: better error for Deno.UnsafeWindowSurface, correct HttpClient name, cleanup unused code (#25833)

This commit is contained in:
Leo Kettmeir 2024-09-24 07:04:52 -07:00 committed by GitHub
parent 3242550f5f
commit 5a1943cd95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 13 deletions

View file

@ -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::info("window global is not available in Deno 2."),
FixSuggestion::hint("Replace `window` with `globalThis`."), 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.",
),
];
} }
} }

View file

@ -6041,9 +6041,11 @@ declare namespace Deno {
* *
* @category Fetch * @category Fetch
*/ */
export interface HttpClient extends Disposable { export class HttpClient implements Disposable {
/** Close the HTTP client. */ /** Close the HTTP client. */
close(): void; close(): void;
[Symbol.dispose](): void;
} }
/** /**

View file

@ -132,7 +132,7 @@ const denoNs = {
UnsafePointerView: ffi.UnsafePointerView, UnsafePointerView: ffi.UnsafePointerView,
UnsafeFnPointer: ffi.UnsafeFnPointer, UnsafeFnPointer: ffi.UnsafeFnPointer,
umask: fs.umask, umask: fs.umask,
httpClient: httpClient.httpClient, HttpClient: httpClient.HttpClient,
createHttpClient: httpClient.createHttpClient, createHttpClient: httpClient.createHttpClient,
}; };
@ -160,15 +160,6 @@ denoNsUnstableById[unstableIds.cron] = {
cron: cron.cron, cron: cron.cron,
}; };
denoNsUnstableById[unstableIds.ffi] = {};
denoNsUnstableById[unstableIds.fs] = {};
denoNsUnstableById[unstableIds.http] = {
HttpClient: httpClient.HttpClient,
createHttpClient: httpClient.createHttpClient,
};
denoNsUnstableById[unstableIds.kv] = { denoNsUnstableById[unstableIds.kv] = {
openKv: kv.openKv, openKv: kv.openKv,
AtomicOperation: kv.AtomicOperation, AtomicOperation: kv.AtomicOperation,

View file

@ -122,8 +122,8 @@ pub static UNSTABLE_GRANULAR_FLAGS: &[UnstableGranularFlag] = &[
}, },
UnstableGranularFlag { UnstableGranularFlag {
name: deno_webgpu::UNSTABLE_FEATURE_NAME, name: deno_webgpu::UNSTABLE_FEATURE_NAME,
help_text: "Enable unstable `WebGPU` API", help_text: "Enable unstable `WebGPU` APIs",
show_in_help: false, show_in_help: true,
id: 11, id: 11,
}, },
UnstableGranularFlag { UnstableGranularFlag {

View file

@ -1156,6 +1156,7 @@ Deno.test(
> { > {
const caCert = Deno.readTextFileSync("tests/testdata/tls/RootCA.pem"); const caCert = Deno.readTextFileSync("tests/testdata/tls/RootCA.pem");
const client = Deno.createHttpClient({ caCerts: [caCert] }); const client = Deno.createHttpClient({ caCerts: [caCert] });
assert(client instanceof Deno.HttpClient);
const response = await fetch("https://localhost:5545/assets/fixture.json", { const response = await fetch("https://localhost:5545/assets/fixture.json", {
client, client,
}); });