fix(ext,runtime): add missing custom inspections (#21219)

This commit is contained in:
Kenta Moriuchi 2023-11-19 17:13:38 +09:00 committed by GitHub
parent a7548afb58
commit c806fbdabe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 848 additions and 376 deletions

View file

@ -12,6 +12,7 @@
const core = globalThis.Deno.core;
const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
const primordials = globalThis.__bootstrap.primordials;
const {
DataViewPrototypeGetBuffer,
@ -23,6 +24,7 @@ const {
// SharedArrayBufferPrototype
StringPrototypeCharCodeAt,
StringPrototypeSlice,
SymbolFor,
TypedArrayPrototypeSubarray,
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteLength,
@ -190,6 +192,21 @@ class TextDecoder {
}
}
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(TextDecoderPrototype, this),
keys: [
"encoding",
"fatal",
"ignoreBOM",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(TextDecoder);
@ -247,6 +264,17 @@ class TextEncoder {
written: encodeIntoBuf[1],
};
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(TextEncoderPrototype, this),
keys: ["encoding"],
}),
inspectOptions,
);
}
}
const encodeIntoBuf = new Uint32Array(2);
@ -342,6 +370,26 @@ class TextDecoderStream {
webidl.assertBranded(this, TextDecoderStreamPrototype);
return this.#transform.writable;
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
TextDecoderStreamPrototype,
this,
),
keys: [
"encoding",
"fatal",
"ignoreBOM",
"readable",
"writable",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(TextDecoderStream);
@ -415,6 +463,24 @@ class TextEncoderStream {
webidl.assertBranded(this, TextEncoderStreamPrototype);
return this.#transform.writable;
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
TextEncoderStreamPrototype,
this,
),
keys: [
"encoding",
"readable",
"writable",
],
}),
inspectOptions,
);
}
}
webidl.configureInterface(TextEncoderStream);