Skip to content

Commit dc7771a

Browse files
committed
1 parent 9eda9f2 commit dc7771a

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
3-
"checkJs": true,
4-
"lib": ["deno.window"],
3+
"types": ["npm:@types/chrome"],
4+
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"],
55
"strict": true
66
},
77
"lint": {

deno.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"description": "Show active intervals, scheduled timeouts, animation frames, idle callbacks, eval invocations, media events and properties",
66
"minimum_chrome_version": "135.0",
77
"homepage_url": "https://github.com/zendive/browser-api-monitor",
8-
"author": "[email protected]",
98
"permissions": ["storage"],
109
"host_permissions": ["*://*/*"],
1110
"devtools_page": "public/api-monitor-devtools.html",

src/api/const.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,27 @@ export const MEDIA_ELEMENT_PROPS = [
100100
'videoHeight',
101101
];
102102

103-
export const MEDIA_ELEMENT_TOGGABLE_PROPS: Set<
104-
Partial<keyof HTMLVideoElement> | Partial<keyof HTMLAudioElement>
105-
> = /*@__PURE__*/ new Set([
106-
'autoplay',
107-
'playsInline',
108-
'loop',
109-
'defaultMuted',
110-
'muted',
111-
'preservesPitch',
112-
'controls',
113-
'disablePictureInPicture',
114-
]);
103+
export type TWritableBooleanKeys<T> = {
104+
[K in keyof T]-?: boolean extends T[K]
105+
? (<U>() => { [P in K]: T[K] } extends { -readonly [P in K]: T[K] } ? K
106+
: never) extends (<U>() => infer I) ? I
107+
: never
108+
: never;
109+
}[keyof T];
110+
export type TToggableMediaProps = TWritableBooleanKeys<
111+
HTMLVideoElement & HTMLAudioElement
112+
>;
113+
export const MEDIA_ELEMENT_TOGGABLE_PROPS: Set<TToggableMediaProps> =
114+
/*@__PURE__*/ new Set([
115+
'autoplay',
116+
'playsInline',
117+
'loop',
118+
'defaultMuted',
119+
'muted',
120+
'preservesPitch',
121+
'controls',
122+
'disablePictureInPicture',
123+
]);
115124

116125
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/networkState
117126
export const NETWORK_STATE = [

src/wrapper/MediaWrapper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
MEDIA_ELEMENT_TOGGABLE_PROPS,
77
NETWORK_STATE,
88
READY_STATE,
9-
} from '../api/const';
9+
} from '../api/const.ts';
1010

1111
type TMediaElement = HTMLVideoElement | HTMLAudioElement;
1212
type TMediaModel = {
@@ -203,7 +203,6 @@ export class MediaWrapper {
203203
mediaModel.el.currentTime += FRAME_1of60;
204204
} else if (cmd === 'toggle-boolean' && typeof property === 'string') {
205205
if (MEDIA_ELEMENT_TOGGABLE_PROPS.has(property)) {
206-
// @ts-expect-error props a handy picked to be overwritable booleans
207206
mediaModel.el[property] = !mediaModel.el[property];
208207
}
209208
} else if (cmd === 'slower') {

0 commit comments

Comments
 (0)