Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ If you're web developer and want to assess implementation correctness - this too
- requestIdleCallback
- cancelIdleCallback

##### Note:

- while measuring performance of your code – consider disabling this extension as it may affect the results.
> [!NOTE]
> While measuring performance of your code – consider disabling this extension as it may affect the results.

<details>
<summary> <strong>Example</strong> </summary>
Expand All @@ -49,8 +48,8 @@ If you're web developer and want to assess implementation correctness - this too
### Build requirements

- OS: Linux
- Node: 22.12.0 (LTS)
- [Deno](https://docs.deno.com/runtime/getting_started/installation/) 2.2.8
- Node: 22.14.0 (LTS)
- [Deno](https://docs.deno.com/runtime/getting_started/installation/) 2.2.12

### Build instructions

Expand Down
2 changes: 1 addition & 1 deletion build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const buildOptions: BuildOptions = {
minify: isProd,
sourcemap: false,
treeShaking: true,
logLevel: 'warning',
logLevel: isProd ? 'warning' : 'debug',
};

if (isProd) {
Expand Down
8 changes: 5 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@
"include": [
"src/",
"tests/",
"public/*.html",
"public/*.css",
"build.ts",
"*.json"
]
},
"imports": {
"esbuild": "https://deno.land/x/esbuild@v0.25.2/mod.js",
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@0.11.1",
"esbuild-svelte": "npm:esbuild-svelte@0.9.0",
"esbuild-svelte": "npm:esbuild-svelte@0.9.2",
"svelte-preprocess": "npm:svelte-preprocess@6.0.3",

"@std/expect": "jsr:@std/expect@1.0.14",
"@std/testing": "jsr:@std/testing@1.0.10",
"@std/expect": "jsr:@std/expect@^1.0.15",
"@std/testing": "jsr:@std/testing@^1.0.11",
"happy-dom": "npm:happy-dom@17.4.4"
}
}
192 changes: 96 additions & 96 deletions deno.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"version": "1.1.0",
"version": "1.2.0",
"name": "API Monitor",
"manifest_version": 3,
"description": "Show active intervals, scheduled timeouts, animation frames, idle callbacks, eval invocations, media events and properties",
"minimum_chrome_version": "135.0",
"homepage_url": "https://github.com/zendive/browser-api-monitor",
"permissions": ["storage"],
"permissions": ["storage", "power"],
"host_permissions": ["*://*/*"],
"devtools_page": "public/api-monitor-devtools.html",
"icons": {
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"type": "module",
"devDependencies": {
"@types/chrome": "0.0.313",
"@types/chrome": "0.0.317",
"@types/deno": "2.2.0",
"sass": "1.86.3",
"sv": "0.8.0",
"svelte": "5.25.7",
"svelte-check": "4.1.5",
"sass": "1.87.0",
"sv": "0.8.3",
"svelte": "5.28.2",
"svelte-check": "4.1.6",
"typescript": "5.8.3"
},
"dependencies": {
"@noble/hashes": "1.7.1",
"@noble/hashes": "1.8.0",
"jsondiffpatch": "0.7.3"
}
}
2 changes: 1 addition & 1 deletion public/api-monitor-devtools-panel.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
5 changes: 3 additions & 2 deletions public/api-monitor-devtools.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!doctype html>
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>DevtoolsTab</title>
<script src="./build/api-monitor-devtools.js"></script>
</head>
<body></body>
Expand Down
31 changes: 28 additions & 3 deletions public/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
--text-trace: light-dark(rgb(30% 30% 30%), rgb(70% 70% 70%));
--link: light-dark(rgb(0% 0% 0%), rgb(100% 100% 100%));
--link-visited-bg: rgb(79 189 36 / 0.24);
--error: rgb(100% 0% 0%);
--attention: rgb(100% 0% 0%);

--small-icon-size: 0.6875rem;
}
Expand All @@ -30,8 +30,15 @@ body {
padding: 0;
box-sizing: border-box;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu,
Cantarell, 'Helvetica Neue', sans-serif;
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen-Sans,
Ubuntu,
Cantarell,
'Helvetica Neue',
sans-serif;
}

a {
Expand Down Expand Up @@ -73,6 +80,9 @@ th,
.ta-r {
text-align: right;
}
.tc-attention {
color: var(--attention);
}
.t-zebra:where(:nth-child(even)) {
background-color: var(--bg-table-even);
}
Expand Down Expand Up @@ -103,6 +113,15 @@ th,
margin-right: 0;
}

.sticky-header {
/* @NOTE: unstable in Chrome v135 */
/*position: sticky;*/
/*top: 0;*/
/*z-index: 1;*/
height: 1rem;
vertical-align: middle;
}

.icon {
display: inline-block;
width: 1rem;
Expand Down Expand Up @@ -173,9 +192,15 @@ th .icon {
.icon.-trace-extension {
mask-image: url(img/trace-extension.svg);
}
.icon.-trace-webpack {
mask-image: url(img/trace-webpack.svg);
}
.icon.-breakpoint {
mask-image: url(img/breakpoint.svg);
}
.icon.-bypass {
mask-image: url(img/bypass.svg);
}
.icon.-facts {
mask-image: url(img/facts.svg);
}
3 changes: 3 additions & 0 deletions public/img/breakpoint.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/img/facts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/img/trace-webpack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 27 additions & 10 deletions src/api-monitor-cs-isolated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,34 @@ import {
windowListen,
windowPost,
} from './api/communication.ts';
import { getSettings, onSettingsChange } from './api/settings.ts';
import { loadLocalStorage, onLocalStorageChange } from './api/storage.local.ts';
import {
loadSessionStorage,
onSessionStorageChange,
} from './api/storage.session.ts';

Promise.all([loadLocalStorage(), loadSessionStorage()]).then(
([config, session]) => {
windowPost({ msg: EMsg.CONFIG, config });
windowPost({ msg: EMsg.SESSION, session });

if (config.devtoolsPanelShown && !config.paused) {
windowPost({ msg: EMsg.START_OBSERVE });
}

getSettings().then((settings) => {
windowPost({ msg: EMsg.SETTINGS, settings: settings });
portListen(windowPost);
windowListen(runtimePost);

onSettingsChange((newValue) => {
windowPost({ msg: EMsg.SETTINGS, settings: newValue });
});
});
onLocalStorageChange((newValue) => {
windowPost({ msg: EMsg.CONFIG, config: newValue });
});
onSessionStorageChange((newValue) => {
windowPost({ msg: EMsg.SESSION, session: newValue });
});

portListen(windowPost);
windowListen(runtimePost);
runtimePost({ msg: EMsg.CONTENT_SCRIPT_LOADED });

runtimePost({ msg: EMsg.CONTENT_SCRIPT_LOADED });
__development__ &&
console.log('api-monitor-cs-isolated.ts', performance.now());
},
);
14 changes: 7 additions & 7 deletions src/api-monitor-cs-main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { EMsg, windowListen, windowPost } from './api/communication.ts';
import { IS_DEV } from './api/env.ts';
import { TELEMETRY_FREQUENCY_1PS } from './api/const.ts';
import { adjustTelemetryDelay, Timer } from './api/time.ts';
import {
applyConfig,
applySession,
cleanHistory,
collectMetrics,
onEachSecond,
runMediaCommand,
runTimerCommand,
setSettings,
type TTelemetry,
} from './wrapper/Wrapper.ts';
import diff from './api/diff.ts';
Expand Down Expand Up @@ -52,11 +52,9 @@ windowListen((o) => {
originalMetrics = currentMetrics;
eachSecond.isPending() && tick.start();
} else if (
o.msg === EMsg.SETTINGS &&
o.settings &&
typeof o.settings === 'object'
o.msg === EMsg.CONFIG && o.config && typeof o.config === 'object'
) {
setSettings(o.settings);
applyConfig(o.config);
} else if (o.msg === EMsg.START_OBSERVE) {
originalMetrics = currentMetrics = null;
tick.trigger();
Expand All @@ -73,7 +71,9 @@ windowListen((o) => {
runTimerCommand(o.type, o.handler);
} else if (o.msg === EMsg.MEDIA_COMMAND) {
runMediaCommand(o.mediaId, o.cmd, o.property);
} else if (o.msg === EMsg.SESSION) {
applySession(o.session);
}
});

IS_DEV && console.debug('cs-main.ts');
__development__ && console.debug('api-monitor-cs-main.ts', performance.now());
7 changes: 6 additions & 1 deletion src/api-monitor-devtools-panel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { mount } from 'svelte';
import App from './view/App.svelte';
import { initConfigState } from './state/config.state.svelte.ts';
import { onHidePanel } from './devtoolsPanelUtil.ts';

mount(App, { target: document.body });
initConfigState().then(() => {
mount(App, { target: document.body });
globalThis.addEventListener('beforeunload', onHidePanel);
});
21 changes: 13 additions & 8 deletions src/api-monitor-devtools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { EMsg, portPost } from './api/communication.ts';
import { getSettings, setSettings } from './api/settings.ts';
import { loadLocalStorage, saveLocalStorage } from './api/storage.local.ts';
import { enableSessionInContentScript } from './api/storage.session.ts';
import { onHidePanel } from './devtoolsPanelUtil.ts';

// tabId may be null if user opened the devtools of the devtools
if (chrome.devtools.inspectedWindow.tabId !== null) {
Expand All @@ -9,16 +11,19 @@ if (chrome.devtools.inspectedWindow.tabId !== null) {
'/public/api-monitor-devtools-panel.html',
(panel) => {
panel.onShown.addListener(async () => {
const settings = await getSettings();
if (!settings.paused) {
const config = await loadLocalStorage();
if (!config.paused) {
portPost({ msg: EMsg.START_OBSERVE });
}
setSettings({ devtoolsPanelShown: true });
});
panel.onHidden.addListener(() => {
portPost({ msg: EMsg.STOP_OBSERVE });
setSettings({ devtoolsPanelShown: false });
if (config.keepAwake) {
chrome.power.requestKeepAwake('display');
}
await saveLocalStorage({ devtoolsPanelShown: true });
});

panel.onHidden.addListener(onHidePanel);
},
);

enableSessionInContentScript();
}
Loading