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

fix: remove inspect proxy abstraction

This commit is contained in:
Marvin Hagemeister 2024-08-16 13:34:09 +02:00
parent 0c26d9b638
commit 71ab7d44c5
28 changed files with 405 additions and 1030 deletions

View file

@ -13,14 +13,13 @@ const {
ArrayPrototypeIndexOf,
ArrayPrototypePush,
ArrayPrototypeSplice,
ObjectPrototypeIsPrototypeOf,
Symbol,
SymbolFor,
Uint8Array,
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import {
defineEventHandler,
EventTarget,
@ -143,18 +142,7 @@ class BroadcastChannel extends EventTarget {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(BroadcastChannelPrototype, this),
keys: [
"name",
"onmessage",
"onmessageerror",
],
}),
inspectOptions,
);
return privateInspect(this, ["canvas"], inspect, inspectOptions);
}
}

View file

@ -4,7 +4,7 @@ import { internals, primordials } from "ext:core/mod.js";
import { op_image_decode_png, op_image_process } from "ext:core/ops";
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { DOMException } from "ext:deno_web/01_dom_exception.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { BlobPrototype } from "ext:deno_web/09_file.js";
import { sniffImage } from "ext:deno_web/01_mimesniff.js";
const {
@ -140,17 +140,7 @@ class ImageBitmap {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ImageBitmapPrototype, this),
keys: [
"width",
"height",
],
}),
inspectOptions,
);
return privateInspect(this, ["width", "height"], inspect, inspectOptions);
}
}
const ImageBitmapPrototype = ImageBitmap.prototype;

View file

@ -102,10 +102,7 @@ const {
ObjectPrototypePropertyIsEnumerable,
ObjectSetPrototypeOf,
ObjectValues,
Proxy,
ReflectGet,
ReflectGetOwnPropertyDescriptor,
ReflectGetPrototypeOf,
ReflectHas,
ReflectOwnKeys,
RegExpPrototypeExec,
@ -471,7 +468,7 @@ function formatValue(
// inspect implementations in `extensions` need it, but may not have access
// to the `Deno` namespace in web workers. Remove when the `Deno`
// namespace is always enabled.
return String(value[privateCustomInspect](inspect, ctx));
return String(value[privateCustomInspect].call(value, inspect, ctx));
} else if (ReflectHas(value, nodeCustomInspectSymbol)) {
const maybeCustom = value[nodeCustomInspectSymbol];
if (
@ -3449,67 +3446,24 @@ function inspect(
return formatValue(ctx, value, 0);
}
class FilteredProxy extends Proxy {
privateCustomInspectProxy;
}
/** Creates a proxy that represents a subset of the properties
* of the original object optionally without evaluating the properties
* in order to get the values. */
function createFilteredInspectProxy({ object, keys, evaluate }) {
const obj = class {};
if (object.constructor?.name) {
ObjectDefineProperty(obj, "name", { value: object.constructor.name });
/**
* Print a serialized version of the passed object with only the
* keys specified. This is used in `Deno.privateCustomInspect()`
* @template T
* @param {T} obj
* @param {keyof T} keys
* @param {typeof inspect} inspect
* @param {*} inspectOptions
* @returns {string}
*/
function privateInspect(obj, keys, inspect, inspectOptions) {
const value = {};
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
value[key] = ReflectGet(obj, key);
}
return new Proxy(new obj(), {
get(_target, key) {
if (key === SymbolToStringTag) {
return object.constructor?.name;
} else if (key === privateCustomInspectProxy) {
return true;
} else if (ArrayPrototypeIncludes(keys, key)) {
return ReflectGet(object, key);
} else {
return undefined;
}
},
getOwnPropertyDescriptor(_target, key) {
if (!ArrayPrototypeIncludes(keys, key)) {
return undefined;
} else if (evaluate) {
return getEvaluatedDescriptor(object, key);
} else {
return getDescendantPropertyDescriptor(object, key) ??
getEvaluatedDescriptor(object, key);
}
},
has(_target, key) {
return ArrayPrototypeIncludes(keys, key);
},
ownKeys() {
return keys;
},
});
function getDescendantPropertyDescriptor(object, key) {
let propertyDescriptor = ReflectGetOwnPropertyDescriptor(object, key);
if (!propertyDescriptor) {
const prototype = ReflectGetPrototypeOf(object);
if (prototype) {
propertyDescriptor = getDescendantPropertyDescriptor(prototype, key);
}
}
return propertyDescriptor;
}
function getEvaluatedDescriptor(object, key) {
return {
configurable: true,
enumerable: true,
value: object[key],
};
}
return `${obj.constructor.name} ${inspect(value, inspectOptions)}`;
}
// Expose these fields to internalObject for tests.
@ -3522,7 +3476,6 @@ internals.parseCssColor = parseCssColor;
export {
colors,
Console,
createFilteredInspectProxy,
createStylizeWithColor,
CSI,
customInspect,
@ -3534,6 +3487,7 @@ export {
getStdoutNoColor,
inspect,
inspectArgs,
privateInspect,
quoteString,
setNoColorFns,
styles,

View file

@ -81,8 +81,8 @@ const {
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { DOMException } from "ext:deno_web/01_dom_exception.js";
import { privateInspect } from "ext:deno_console/01_console.js";
const supportedNamedCurves = ["P-256", "P-384", "P-521"];
const recognisedUsages = [
@ -380,17 +380,10 @@ class CryptoKey {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CryptoKeyPrototype, this),
keys: [
"type",
"extractable",
"algorithm",
"usages",
],
}),
return privateInspect(
this,
["type", "extractable", "algorithm", "usages"],
inspect,
inspectOptions,
);
}
@ -4757,14 +4750,7 @@ class Crypto {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CryptoPrototype, this),
keys: ["subtle"],
}),
inspectOptions,
);
return privateInspect(this, ["subtle"], inspect, inspectOptions);
}
}

View file

@ -25,7 +25,7 @@ const {
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import {
byteUpperCase,
HTTP_TOKEN_CODE_POINT_RE,
@ -511,18 +511,10 @@ class Request {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(RequestPrototype, this),
keys: [
"bodyUsed",
"headers",
"method",
"redirect",
"url",
],
}),
return privateInspect(
this,
["bodyUsed", "headers", "method", "redirect", "url"],
inspect,
inspectOptions,
);
}

View file

@ -12,7 +12,7 @@
import { core, primordials } from "ext:core/mod.js";
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import {
byteLowerCase,
HTTP_TAB_OR_SPACE,
@ -34,7 +34,6 @@ const {
ArrayPrototypeMap,
ArrayPrototypePush,
ObjectDefineProperties,
ObjectPrototypeIsPrototypeOf,
RangeError,
RegExpPrototypeExec,
SafeArrayIterator,
@ -408,11 +407,9 @@ class Response {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ResponsePrototype, this),
keys: [
return privateInspect(
this,
[
"body",
"bodyUsed",
"headers",
@ -422,7 +419,7 @@ class Response {
"statusText",
"url",
],
}),
inspect,
inspectOptions,
);
}

View file

@ -10,7 +10,6 @@ const {
NumberIsFinite,
NumberIsNaN,
ObjectDefineProperties,
ObjectPrototypeIsPrototypeOf,
StringPrototypeEndsWith,
StringPrototypeIncludes,
StringPrototypeIndexOf,
@ -21,7 +20,7 @@ const {
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { URL } from "ext:deno_url/00_url.js";
import { DOMException } from "ext:deno_web/01_dom_exception.js";
import {
@ -333,11 +332,9 @@ class EventSource extends EventTarget {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(EventSourcePrototype, this),
keys: [
return privateInspect(
this,
[
"readyState",
"url",
"withCredentials",
@ -345,7 +342,7 @@ class EventSource extends EventTarget {
"onmessage",
"onerror",
],
}),
inspect,
inspectOptions,
);
}

View file

@ -22,7 +22,6 @@ const {
ArrayPrototypeSort,
ArrayPrototypeSplice,
ObjectKeys,
ObjectPrototypeIsPrototypeOf,
SafeArrayIterator,
StringPrototypeSlice,
StringPrototypeStartsWith,
@ -34,7 +33,7 @@ const {
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
const _list = Symbol("list");
const _urlObject = Symbol("url object");
@ -459,11 +458,9 @@ class URL {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(URLPrototype, this),
keys: [
return privateInspect(
this,
[
"href",
"origin",
"protocol",
@ -476,7 +473,7 @@ class URL {
"hash",
"search",
],
}),
inspect,
inspectOptions,
);
}

View file

@ -17,7 +17,6 @@ const {
MathRandom,
ObjectAssign,
ObjectCreate,
ObjectPrototypeIsPrototypeOf,
RegExpPrototypeExec,
RegExpPrototypeTest,
SafeMap,
@ -28,7 +27,7 @@ const {
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
const _components = Symbol("components");
@ -368,11 +367,9 @@ class URLPattern {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(URLPatternPrototype, this),
keys: [
return privateInspect(
this,
[
"protocol",
"username",
"password",
@ -383,7 +380,7 @@ class URLPattern {
"hash",
"hasRegExpGroups",
],
}),
inspect,
inspectOptions,
);
}

View file

@ -15,14 +15,13 @@ const {
ObjectCreate,
ObjectEntries,
ObjectHasOwn,
ObjectPrototypeIsPrototypeOf,
ObjectSetPrototypeOf,
Symbol,
SymbolFor,
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
const _name = Symbol("name");
const _message = Symbol("message");
@ -137,16 +136,10 @@ class DOMException {
return stack;
}
}
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(DOMExceptionPrototype, this),
keys: [
"message",
"name",
"code",
],
}),
return privateInspect(
this,
["message", "name", "code"],
inspect,
inspectOptions,
);
}

View file

@ -36,7 +36,7 @@ const {
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { DOMException } from "./01_dom_exception.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
// This should be set via setGlobalThis this is required so that if even
// user deletes globalThis it is still usable
@ -158,14 +158,7 @@ class Event {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(EventPrototype, this),
keys: EVENT_PROPS,
}),
inspectOptions,
);
return privateInspect(this, EVENT_PROPS, inspect, inspectOptions);
}
get type() {
@ -387,8 +380,6 @@ class Event {
}
}
const EventPrototype = Event.prototype;
// Not spec compliant. The spec defines it as [LegacyUnforgeable]
// but doing so has a big performance hit
ReflectDefineProperty(Event.prototype, "isTrusted", {
@ -1111,11 +1102,9 @@ class ErrorEvent extends Event {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ErrorEventPrototype, this),
keys: [
return privateInspect(
this,
[
...new SafeArrayIterator(EVENT_PROPS),
"message",
"filename",
@ -1123,7 +1112,7 @@ class ErrorEvent extends Event {
"colno",
"error",
],
}),
inspect,
inspectOptions,
);
}
@ -1177,24 +1166,20 @@ class CloseEvent extends Event {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CloseEventPrototype, this),
keys: [
return privateInspect(
this,
[
...new SafeArrayIterator(EVENT_PROPS),
"wasClean",
"code",
"reason",
],
}),
inspect,
inspectOptions,
);
}
}
const CloseEventPrototype = CloseEvent.prototype;
class MessageEvent extends Event {
get source() {
return null;
@ -1214,17 +1199,15 @@ class MessageEvent extends Event {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(MessageEventPrototype, this),
keys: [
return privateInspect(
this,
[
...new SafeArrayIterator(EVENT_PROPS),
"data",
"origin",
"lastEventId",
],
}),
inspect,
inspectOptions,
);
}
@ -1233,8 +1216,6 @@ class MessageEvent extends Event {
[SymbolToStringTag] = "MessageEvent";
}
const MessageEventPrototype = MessageEvent.prototype;
class CustomEvent extends Event {
#detail = null;
@ -1254,15 +1235,13 @@ class CustomEvent extends Event {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CustomEventPrototype, this),
keys: [
return privateInspect(
this,
[
...new SafeArrayIterator(EVENT_PROPS),
"detail",
],
}),
inspect,
inspectOptions,
);
}
@ -1271,8 +1250,6 @@ class CustomEvent extends Event {
[SymbolToStringTag] = "CustomEvent";
}
const CustomEventPrototype = CustomEvent.prototype;
ReflectDefineProperty(CustomEvent.prototype, "detail", {
enumerable: true,
});
@ -1289,17 +1266,15 @@ class ProgressEvent extends Event {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ProgressEventPrototype, this),
keys: [
return privateInspect(
this,
[
...new SafeArrayIterator(EVENT_PROPS),
"lengthComputable",
"loaded",
"total",
],
}),
inspect,
inspectOptions,
);
}
@ -1308,8 +1283,6 @@ class ProgressEvent extends Event {
[SymbolToStringTag] = "ProgressEvent";
}
const ProgressEventPrototype = ProgressEvent.prototype;
class PromiseRejectionEvent extends Event {
#promise = null;
#reason = null;
@ -1342,19 +1315,14 @@ class PromiseRejectionEvent extends Event {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
PromiseRejectionEventPrototype,
return privateInspect(
this,
),
keys: [
[
...new SafeArrayIterator(EVENT_PROPS),
"promise",
"reason",
],
}),
inspect,
inspectOptions,
);
}
@ -1363,8 +1331,6 @@ class PromiseRejectionEvent extends Event {
[SymbolToStringTag] = "PromiseRejectionEvent";
}
const PromiseRejectionEventPrototype = PromiseRejectionEvent.prototype;
defineEnumerableProps(PromiseRejectionEvent, [
"promise",
"reason",

View file

@ -8,7 +8,6 @@ const {
ArrayPrototypeEvery,
ArrayPrototypePush,
FunctionPrototypeApply,
ObjectPrototypeIsPrototypeOf,
SafeSet,
SafeSetIterator,
SafeWeakRef,
@ -25,7 +24,7 @@ const {
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { assert } from "./00_infra.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import {
defineEventHandler,
Event,
@ -250,16 +249,10 @@ class AbortSignal extends EventTarget {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(AbortSignalPrototype, this),
keys: [
"aborted",
"reason",
"onabort",
],
}),
return privateInspect(
this,
["aborted", "reason", "onabort"],
inspect,
inspectOptions,
);
}
@ -287,16 +280,7 @@ class AbortController {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(AbortControllerPrototype, this),
keys: [
"signal",
],
}),
inspectOptions,
);
return privateInspect(this, ["signal"], inspect, inspectOptions);
}
}

View file

@ -99,7 +99,7 @@ import {
signalAbort,
} from "./03_abort_signal.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { assert, AssertionError } from "./00_infra.js";
/** @template T */
@ -4993,18 +4993,10 @@ class ByteLengthQueuingStrategy {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
ByteLengthQueuingStrategyPrototype,
return privateInspect(
this,
),
keys: [
"highWaterMark",
"size",
],
}),
["highWaterMark", "size"],
inspect,
inspectOptions,
);
}
@ -5050,18 +5042,10 @@ class CountQueuingStrategy {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
CountQueuingStrategyPrototype,
return privateInspect(
this,
),
keys: [
"highWaterMark",
"size",
],
}),
["highWaterMark", "size"],
inspect,
inspectOptions,
);
}
@ -5365,17 +5349,7 @@ class ReadableStream {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableStreamPrototype,
this,
),
keys: ["locked"],
}),
inspectOptions,
);
return privateInspect(this, ["locked"], inspect, inspectOptions);
}
}
@ -5487,17 +5461,7 @@ class ReadableStreamDefaultReader {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableStreamDefaultReaderPrototype,
this,
),
keys: ["closed"],
}),
inspectOptions,
);
return privateInspect(this, ["closed"], inspect, inspectOptions);
}
}
@ -5657,17 +5621,7 @@ class ReadableStreamBYOBReader {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableStreamBYOBReaderPrototype,
this,
),
keys: ["closed"],
}),
inspectOptions,
);
return privateInspect(this, ["closed"], inspect, inspectOptions);
}
}
@ -5883,17 +5837,7 @@ class ReadableByteStreamController {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableByteStreamControllerPrototype,
this,
),
keys: ["desiredSize"],
}),
inspectOptions,
);
return privateInspect(this, ["desiredSize"], inspect, inspectOptions);
}
/**
@ -6037,17 +5981,7 @@ class ReadableStreamDefaultController {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
ReadableStreamDefaultControllerPrototype,
this,
),
keys: ["desiredSize"],
}),
inspectOptions,
);
return privateInspect(this, ["desiredSize"], inspect, inspectOptions);
}
/**
@ -6199,15 +6133,10 @@ class TransformStream {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
TransformStreamPrototype,
return privateInspect(
this,
),
keys: ["readable", "writable"],
}),
["readable", "writable"],
inspect,
inspectOptions,
);
}
@ -6276,17 +6205,7 @@ class TransformStreamDefaultController {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
TransformStreamDefaultControllerPrototype,
this,
),
keys: ["desiredSize"],
}),
inspectOptions,
);
return privateInspect(this, ["desiredSize"], inspect, inspectOptions);
}
}
@ -6427,17 +6346,7 @@ class WritableStream {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
WritableStreamPrototype,
this,
),
keys: ["locked"],
}),
inspectOptions,
);
return privateInspect(this, ["locked"], inspect, inspectOptions);
}
}
@ -6572,19 +6481,10 @@ class WritableStreamDefaultWriter {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
WritableStreamDefaultWriterPrototype,
return privateInspect(
this,
),
keys: [
"closed",
"desiredSize",
"ready",
],
}),
["closed", "desiredSize", "ready"],
inspect,
inspectOptions,
);
}
@ -6646,17 +6546,7 @@ class WritableStreamDefaultController {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
WritableStreamDefaultControllerPrototype,
this,
),
keys: ["signal"],
}),
inspectOptions,
);
return privateInspect(this, ["signal"], inspect, inspectOptions);
}
/**

View file

@ -27,7 +27,6 @@ const {
DataViewPrototypeGetBuffer,
DataViewPrototypeGetByteLength,
DataViewPrototypeGetByteOffset,
ObjectPrototypeIsPrototypeOf,
PromiseReject,
PromiseResolve,
// TODO(lucacasonato): add SharedArrayBuffer to primordials
@ -44,7 +43,7 @@ const {
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
class TextDecoder {
/** @type {string} */
@ -189,16 +188,10 @@ class TextDecoder {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(TextDecoderPrototype, this),
keys: [
"encoding",
"fatal",
"ignoreBOM",
],
}),
return privateInspect(
this,
["encoding", "fatal", "ignoreBOM"],
inspect,
inspectOptions,
);
}
@ -261,14 +254,7 @@ class TextEncoder {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(TextEncoderPrototype, this),
keys: ["encoding"],
}),
inspectOptions,
);
return privateInspect(this, ["encoding"], inspect, inspectOptions);
}
}
@ -367,21 +353,10 @@ class TextDecoderStream {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
TextDecoderStreamPrototype,
return privateInspect(
this,
),
keys: [
"encoding",
"fatal",
"ignoreBOM",
"readable",
"writable",
],
}),
["encoding", "fatal", "ignoreBOM", "readable", "writable"],
inspect,
inspectOptions,
);
}
@ -460,19 +435,10 @@ class TextEncoderStream {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
TextEncoderStreamPrototype,
return privateInspect(
this,
),
keys: [
"encoding",
"readable",
"writable",
],
}),
["encoding", "readbale", "writable"],
inspect,
inspectOptions,
);
}

View file

@ -59,7 +59,7 @@ const {
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { ReadableStream } from "./06_streams.js";
import { URL } from "ext:deno_url/00_url.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
// TODO(lucacasonato): this needs to not be hardcoded and instead depend on
// host os.
@ -435,17 +435,10 @@ class Blob {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(BlobPrototype, this),
keys: [
"size",
"type",
],
}),
inspectOptions,
);
// return privateInspect(this, ["size", "type"], inspect, inspectOptions);
const { size, type } = this;
const value = { size, type };
return `${this.constructor.name} ${inspect(value, inspectOptions)}`;
}
}
@ -554,16 +547,10 @@ class File extends Blob {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(FilePrototype, this),
keys: [
"name",
"size",
"type",
],
}),
return privateInspect(
this,
["name", "size", "type"],
inspect,
inspectOptions,
);
}

View file

@ -19,7 +19,6 @@ const {
MapPrototypeGet,
MapPrototypeSet,
ObjectDefineProperty,
ObjectPrototypeIsPrototypeOf,
queueMicrotask,
SafeArrayIterator,
SafeMap,
@ -34,7 +33,7 @@ const {
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { forgivingBase64Encode } from "./00_infra.js";
import { EventTarget, ProgressEvent } from "./02_event.js";
import { decode, TextDecoder } from "./08_text_encoding.js";
@ -435,16 +434,10 @@ class FileReader extends EventTarget {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(FileReaderPrototype, this),
keys: [
"error",
"readyState",
"result",
],
}),
return privateInspect(
this,
["error", "readyState", "result"],
inspect,
inspectOptions,
);
}

View file

@ -30,7 +30,7 @@ const {
isArrayBuffer,
} = core;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import {
defineEventHandler,
EventTarget,
@ -69,17 +69,7 @@ class MessageChannel {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(MessageChannelPrototype, this),
keys: [
"port1",
"port2",
],
}),
inspectOptions,
);
return privateInspect(this, ["port1", "port2"], inspect, inspectOptions);
}
}
@ -277,15 +267,10 @@ class MessagePort extends EventTarget {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(MessagePortPrototype, this),
keys: [
"onmessage",
"onmessageerror",
],
}),
return privateInspectSerialize(
this,
["onmessage", "onmessageerror"],
inspect,
inspectOptions,
);
}

View file

@ -13,12 +13,11 @@ import {
} from "ext:core/ops";
const {
SymbolFor,
ObjectPrototypeIsPrototypeOf,
TypedArrayPrototypeGetByteLength,
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { TransformStream } from "./06_streams.js";
webidl.converters.CompressionFormat = webidl.createEnumConverter(
@ -72,18 +71,10 @@ class CompressionStream {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
CompressionStreamPrototype,
return privateInspect(
this,
),
keys: [
"readable",
"writable",
],
}),
["readable", "writable"],
inspect,
inspectOptions,
);
}
@ -134,18 +125,10 @@ class DecompressionStream {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
DecompressionStreamPrototype,
return privateInspect(
this,
),
keys: [
"readable",
"writable",
],
}),
["readable", "writable"],
inspect,
inspectOptions,
);
}

View file

@ -8,7 +8,6 @@ const {
ArrayPrototypeReverse,
ArrayPrototypeSlice,
ObjectKeys,
ObjectPrototypeIsPrototypeOf,
ReflectHas,
Symbol,
SymbolFor,
@ -17,7 +16,7 @@ const {
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { structuredClone } from "./02_structured_clone.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { EventTarget } from "./02_event.js";
import { opNow } from "./02_timers.js";
import { DOMException } from "./01_dom_exception.js";
@ -197,20 +196,10 @@ class PerformanceEntry {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
PerformanceEntryPrototype,
return privateInspect(
this,
),
keys: [
"name",
"entryType",
"startTime",
"duration",
],
}),
["name", "entryType", "startTime", "duration"],
inspect,
inspectOptions,
);
}
@ -269,18 +258,10 @@ class PerformanceMark extends PerformanceEntry {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(PerformanceMarkPrototype, this),
keys: [
"name",
"entryType",
"startTime",
"duration",
"detail",
],
}),
return privateInspect(
this,
["name", "entryType", "startTime", "duration", "detail"],
inspect,
inspectOptions,
);
}
@ -328,21 +309,10 @@ class PerformanceMeasure extends PerformanceEntry {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
PerformanceMeasurePrototype,
return privateInspect(
this,
),
keys: [
"name",
"entryType",
"startTime",
"duration",
"detail",
],
}),
["entryType", "startTime", "duration", "detail"],
inspect,
inspectOptions,
);
}
@ -579,14 +549,7 @@ class Performance extends EventTarget {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(PerformancePrototype, this),
keys: ["timeOrigin"],
}),
inspectOptions,
);
return privateInspect(this, ["timeOrigin"], inspect, inspectOptions);
}
}
webidl.configureInterface(Performance);

View file

@ -3,9 +3,8 @@
import { primordials } from "ext:core/mod.js";
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { DOMException } from "./01_dom_exception.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
const {
ObjectPrototypeIsPrototypeOf,
Symbol,
SymbolFor,
TypedArrayPrototypeGetLength,
@ -198,17 +197,10 @@ class ImageData {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ImageDataPrototype, this),
keys: [
"data",
"width",
"height",
"colorSpace",
],
}),
return privateInspect(
this,
["data", "width", "height", "colorSpace"],
inspect,
inspectOptions,
);
}

View file

@ -127,7 +127,7 @@ import {
setEventTargetData,
} from "ext:deno_web/02_event.js";
import { DOMException } from "ext:deno_web/01_dom_exception.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
const _rid = Symbol("[[rid]]");
const _size = Symbol("[[size]]");
@ -391,7 +391,7 @@ class GPU {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return `${this.constructor.name} ${inspect({}, inspectOptions)}`;
return privateInspect(this, [], inspect, inspectOptions);
}
}
const GPUPrototype = GPU.prototype;
@ -539,17 +539,15 @@ class GPUAdapter {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUAdapterPrototype, this),
keys: [
return privateInspect(
this,
[
"features",
"limits",
"info",
"isFallbackAdapter",
],
}),
inspect,
inspectOptions,
);
}
@ -590,17 +588,15 @@ class GPUAdapterInfo {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUAdapterInfoPrototype, this),
keys: [
return privateInspect(
this,
[
"vendor",
"architecture",
"device",
"description",
],
}),
inspect,
inspectOptions,
);
}
@ -773,14 +769,9 @@ class GPUSupportedLimits {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPUSupportedLimitsPrototype,
return privateInspect(
this,
),
keys: [
[
"maxTextureDimension1D",
"maxTextureDimension2D",
"maxTextureDimension3D",
@ -812,7 +803,7 @@ class GPUSupportedLimits {
"maxComputeWorkgroupSizeZ",
"maxComputeWorkgroupsPerDimension",
],
}),
inspect,
inspectOptions,
);
}
@ -881,18 +872,10 @@ class GPUDeviceLostInfo {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPUDeviceLostInfoPrototype,
return privateInspect(
this,
),
keys: [
"reason",
"message",
],
}),
["reason", "message"],
inspect,
inspectOptions,
);
}
@ -1831,11 +1814,9 @@ class GPUDevice extends EventTarget {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUDevicePrototype, this),
keys: [
return privateInspect(
this,
[
"features",
"label",
"limits",
@ -1844,7 +1825,7 @@ class GPUDevice extends EventTarget {
// TODO(lucacasonato): emit an UncapturedErrorEvent
// "onuncapturederror"
],
}),
inspect,
inspectOptions,
);
}
@ -2062,16 +2043,7 @@ class GPUQueue {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUQueuePrototype, this),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUQueue", GPUQueue);
@ -2373,17 +2345,15 @@ class GPUBuffer {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUBufferPrototype, this),
keys: [
return privateInspect(
this,
[
"label",
"mapState",
"size",
"usage",
],
}),
inspect,
inspectOptions,
);
}
@ -2585,11 +2555,9 @@ class GPUTexture {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUTexturePrototype, this),
keys: [
return privateInspect(
this,
[
"label",
"width",
"height",
@ -2600,7 +2568,7 @@ class GPUTexture {
"format",
"usage",
],
}),
inspect,
inspectOptions,
);
}
@ -2664,16 +2632,7 @@ class GPUTextureView {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUTextureViewPrototype, this),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUTextureView", GPUTextureView);
@ -2755,19 +2714,7 @@ class GPUBindGroupLayout {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPUBindGroupLayoutPrototype,
this,
),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUBindGroupLayout", GPUBindGroupLayout);
@ -2806,23 +2753,10 @@ class GPUPipelineLayout {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPUPipelineLayoutPrototype,
this,
),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUPipelineLayout", GPUPipelineLayout);
const GPUPipelineLayoutPrototype = GPUPipelineLayout.prototype;
/**
* @param {string | null} label
@ -2858,20 +2792,10 @@ class GPUBindGroup {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUBindGroupPrototype, this),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUBindGroup", GPUBindGroup);
const GPUBindGroupPrototype = GPUBindGroup.prototype;
/**
* @param {string | null} label
* @param {InnerGPUDevice} device
@ -2906,16 +2830,7 @@ class GPUShaderModule {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUShaderModulePrototype, this),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUShaderModule", GPUShaderModule);
@ -3000,19 +2915,7 @@ class GPUComputePipeline {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPUComputePipelinePrototype,
this,
),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUComputePipeline", GPUComputePipeline);
@ -3078,19 +2981,7 @@ class GPURenderPipeline {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPURenderPipelinePrototype,
this,
),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPURenderPipeline", GPURenderPipeline);
@ -3799,19 +3690,7 @@ class GPUCommandEncoder {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPUCommandEncoderPrototype,
this,
),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUCommandEncoder", GPUCommandEncoder);
@ -4407,19 +4286,7 @@ class GPURenderPassEncoder {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPURenderPassEncoderPrototype,
this,
),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPURenderPassEncoder", GPURenderPassEncoder);
@ -4683,19 +4550,7 @@ class GPUComputePassEncoder {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPUComputePassEncoderPrototype,
this,
),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUComputePassEncoder", GPUComputePassEncoder);
@ -4736,20 +4591,10 @@ class GPUCommandBuffer {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUCommandBufferPrototype, this),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPUCommandBuffer", GPUCommandBuffer);
const GPUCommandBufferPrototype = GPUCommandBuffer.prototype;
/**
* @param {string | null} label
@ -5124,19 +4969,7 @@ class GPURenderBundleEncoder {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(
GPURenderBundleEncoderPrototype,
this,
),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPURenderBundleEncoder", GPURenderBundleEncoder);
@ -5177,20 +5010,10 @@ class GPURenderBundle {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPURenderBundlePrototype, this),
keys: [
"label",
],
}),
inspectOptions,
);
return privateInspect(this, ["label"], inspect, inspectOptions);
}
}
GPUObjectBaseMixin("GPURenderBundle", GPURenderBundle);
const GPURenderBundlePrototype = GPURenderBundle.prototype;
/**
* @param {string | null} label
* @param {InnerGPUDevice} device
@ -5248,16 +5071,10 @@ class GPUQuerySet {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUQuerySetPrototype, this),
keys: [
"label",
"type",
"count",
],
}),
return privateInspect(
this,
["label", "type", "count"],
inspect,
inspectOptions,
);
}

View file

@ -14,14 +14,13 @@ import {
op_webgpu_surface_present,
} from "ext:core/ops";
const {
ObjectPrototypeIsPrototypeOf,
Symbol,
SymbolFor,
TypeError,
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { loadWebGPU } from "ext:deno_webgpu/00_init.js";
const _surfaceRid = Symbol("[[surfaceRid]]");
@ -144,16 +143,7 @@ class GPUCanvasContext {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(GPUCanvasContextPrototype, this),
keys: [
"canvas",
],
}),
inspectOptions,
);
return privateInspect(this, ["canvas"], inspect, inspectOptions);
}
}
const GPUCanvasContextPrototype = GPUCanvasContext.prototype;

View file

@ -1138,6 +1138,13 @@ function assertBranded(self, prototype) {
if (
!ObjectPrototypeIsPrototypeOf(prototype, self) || self[brand] !== brand
) {
console.log(
self.toString(),
prototype.toString(),
self === prototype,
self[brand],
brand.toString(),
);
throw new TypeError("Illegal invocation");
}
}

View file

@ -47,7 +47,7 @@ const {
import { URL } from "ext:deno_url/00_url.js";
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { HTTP_TOKEN_CODE_POINT_RE } from "ext:deno_web/00_infra.js";
import { DOMException } from "ext:deno_web/01_dom_exception.js";
import { clearTimeout, setTimeout } from "ext:deno_web/02_timers.js";
@ -603,11 +603,9 @@ class WebSocket extends EventTarget {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(WebSocketPrototype, this),
keys: [
return privateInspect(
this,
[
"url",
"readyState",
"extensions",
@ -619,7 +617,7 @@ class WebSocket extends EventTarget {
"onclose",
"onopen",
],
}),
inspect,
inspectOptions,
);
}

View file

@ -33,7 +33,7 @@ const {
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { Deferred, writableStreamClose } from "ext:deno_web/06_streams.js";
import { DOMException } from "ext:deno_web/01_dom_exception.js";
import { add, remove } from "ext:deno_web/03_abort_signal.js";
@ -426,16 +426,10 @@ class WebSocketStream {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(WebSocketStreamPrototype, this),
keys: [
"closed",
"opened",
"url",
],
}),
return privateInspect(
this,
["closed", "opened", "url"],
inspect,
inspectOptions,
);
}
@ -505,17 +499,10 @@ class WebSocketError extends DOMException {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(WebSocketErrorPrototype, this),
keys: [
"message",
"name",
"closeCode",
"reason",
],
}),
return privateInspect(
this,
["message", "name", "closeCode", "reason"],
inspect,
inspectOptions,
);
}

View file

@ -21,7 +21,7 @@ const {
} = primordials;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import { URL } from "ext:deno_url/00_url.js";
import { getLocationHref } from "ext:deno_web/12_location.js";
import { serializePermissions } from "ext:runtime/10_permissions.js";
@ -292,16 +292,10 @@ class Worker extends EventTarget {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(WorkerPrototype, this),
keys: [
"onerror",
"onmessage",
"onmessageerror",
],
}),
return privateInspect(
this,
["onerror", "onmessage", "onmessageerror"],
inspect,
inspectOptions,
);
}
@ -309,8 +303,6 @@ class Worker extends EventTarget {
[SymbolToStringTag] = "Worker";
}
const WorkerPrototype = Worker.prototype;
defineEventHandler(Worker.prototype, "error");
defineEventHandler(Worker.prototype, "message");
defineEventHandler(Worker.prototype, "messageerror");

View file

@ -8,12 +8,11 @@ import {
} from "ext:core/ops";
const {
ObjectDefineProperties,
ObjectPrototypeIsPrototypeOf,
SymbolFor,
} = primordials;
import * as location from "ext:deno_web/12_location.js";
import * as console from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import * as webidl from "ext:deno_webidl/00_webidl.js";
import * as globalInterfaces from "ext:deno_web/04_global_interfaces.js";
import * as webStorage from "ext:deno_webstorage/01_webstorage.js";
@ -26,17 +25,10 @@ class Navigator {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
console.createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(NavigatorPrototype, this),
keys: [
"hardwareConcurrency",
"userAgent",
"language",
"languages",
],
}),
return privateInspect(
this,
["hardwareConcurrency", "userAgent", "language", "languages"],
inspect,
inspectOptions,
);
}

View file

@ -8,12 +8,11 @@ import {
} from "ext:core/ops";
const {
ObjectDefineProperties,
ObjectPrototypeIsPrototypeOf,
SymbolFor,
} = primordials;
import * as location from "ext:deno_web/12_location.js";
import * as console from "ext:deno_console/01_console.js";
import { privateInspect } from "ext:deno_console/01_console.js";
import * as webidl from "ext:deno_webidl/00_webidl.js";
import * as globalInterfaces from "ext:deno_web/04_global_interfaces.js";
import { loadWebGPU } from "ext:deno_webgpu/00_init.js";
@ -38,17 +37,10 @@ class WorkerNavigator {
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
console.createFilteredInspectProxy({
object: this,
evaluate: ObjectPrototypeIsPrototypeOf(WorkerNavigatorPrototype, this),
keys: [
"hardwareConcurrency",
"userAgent",
"language",
"languages",
],
}),
return privateInspect(
this,
["hardwareConcurrency", "userAgent", "language", "languages"],
inspect,
inspectOptions,
);
}