diff options
| author | Satya Rohith <me@satyarohith.com> | 2021-06-07 17:49:33 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-07 14:19:33 +0200 |
| commit | b6400a25a0ee60467a0287d725e61c876677e103 (patch) | |
| tree | 7577846005e160141ffb8bd9d861dbfe365324ff | |
| parent | 89290741d18d9b247cefccdc95563ec688a28491 (diff) | |
refactor(runtime): move performance API to timers extension (#10818)
Co-authored-by: Luca Casonato <hello@lcas.dev>
| -rw-r--r-- | extensions/broadcast_channel/01_broadcast_channel.js | 2 | ||||
| -rw-r--r-- | extensions/timers/02_performance.js (renamed from runtime/js/40_performance.js) | 12 | ||||
| -rw-r--r-- | extensions/timers/lib.rs | 1 | ||||
| -rw-r--r-- | extensions/web/02_structured_clone.js | 73 | ||||
| -rw-r--r-- | extensions/web/lib.rs | 1 | ||||
| -rw-r--r-- | runtime/js/01_web_util.js | 60 |
6 files changed, 82 insertions, 67 deletions
diff --git a/extensions/broadcast_channel/01_broadcast_channel.js b/extensions/broadcast_channel/01_broadcast_channel.js index 7670b0cfd..c2937105e 100644 --- a/extensions/broadcast_channel/01_broadcast_channel.js +++ b/extensions/broadcast_channel/01_broadcast_channel.js @@ -105,7 +105,7 @@ constructor(name) { super(); - const prefix = "Failed to construct 'broadcastChannel'"; + const prefix = "Failed to construct 'BroadcastChannel'"; webidl.requiredArguments(arguments.length, 1, { prefix }); this[_name] = webidl.converters["DOMString"](name, { diff --git a/runtime/js/40_performance.js b/extensions/timers/02_performance.js index 24c35b5c0..bca98fdbd 100644 --- a/runtime/js/40_performance.js +++ b/extensions/timers/02_performance.js @@ -2,10 +2,9 @@ "use strict"; ((window) => { + const { webidl, structuredClone } = window.__bootstrap; const { opNow } = window.__bootstrap.timers; - const { cloneValue, illegalConstructorKey } = window.__bootstrap.webUtil; - const { requiredArguments } = window.__bootstrap.webUtil; - + const illegalConstructorKey = Symbol("illegalConstructorKey"); const customInspect = Symbol.for("Deno.customInspect"); let performanceEntries = []; @@ -118,7 +117,8 @@ name, options = {}, ) { - requiredArguments("PerformanceMark", arguments.length, 1); + const prefix = "Failed to construct 'PerformanceMark'"; + webidl.requiredArguments(arguments.length, 1, { prefix }); // ensure options is object-ish, or null-ish switch (typeof options) { @@ -138,7 +138,7 @@ if (startTime < 0) { throw new TypeError("startTime cannot be negative"); } - this.#detail = cloneValue(detail); + this.#detail = structuredClone(detail); } toJSON() { @@ -184,7 +184,7 @@ throw new TypeError("Illegal constructor."); } super(name, "measure", startTime, duration, illegalConstructorKey); - this.#detail = cloneValue(detail); + this.#detail = structuredClone(detail); } toJSON() { diff --git a/extensions/timers/lib.rs b/extensions/timers/lib.rs index e9580c4b5..66e7d05ed 100644 --- a/extensions/timers/lib.rs +++ b/extensions/timers/lib.rs @@ -45,6 +45,7 @@ pub fn init<P: TimersPermission + 'static>() -> Extension { .js(include_js_files!( prefix "deno:extensions/timers", "01_timers.js", + "02_performance.js", )) .ops(vec