Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update devtools #155

Merged
merged 4 commits into from
May 29, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"date-fns": "^2.16.1",
"debounce": "^1.2.0",
"debug": "4.3.1",
"devtools-frontend-prebuilt": "^1.0.1",
"devtools-frontend-prebuilt": "1.2.0-beta1",
"electron-context-menu": "2.3.0",
"electron-devtools-installer": "3.2.0",
"electron-squirrel-startup": "1.0.0",
Expand Down
13 changes: 7 additions & 6 deletions src/main/scheme.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { normalize, join, relative } from 'path';
import { protocol } from 'electron';
import { pathToFileURL } from 'url';
import { net, protocol } from 'electron';

export function registerSchemePrivilege() {
protocol.registerSchemesAsPrivileged([
{ scheme: 'oop', privileges: { standard: true } },
{ scheme: 'oop', privileges: { standard: true, supportFetchAPI: true } },
]);
}

Expand All @@ -13,11 +14,11 @@ export function registerSchemePrivilege() {
* protecting against Sleuth freezes
*/
export function registerScheme() {
protocol.registerFileProtocol('oop', (request, callback) => {
protocol.handle('oop', (request) => {
const url = new URL(request.url);
if (url.host !== 'oop') {
// request did not match known path, cowardly refusing
callback('Not found');
return new Response(null, { status: 400 });
}

const dist = normalize(`${__dirname}/../..`);
Expand All @@ -26,9 +27,9 @@ export function registerScheme() {
const relation = relative(dist, path);
if (relation.includes('..')) {
// request appears to be try to be navigating outside of dist
callback('Not found');
return new Response(null, { status: 400 });
} else {
callback({ path });
return net.fetch(pathToFileURL(path).href);
}
});
}
1 change: 1 addition & 0 deletions src/renderer/processor/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ChromiumTrace {

export interface ThreadNameEvent {
name: 'thread_name';
cat?: string;
args?: {
name?: string;
};
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/processor/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,15 @@ export class TraceProcessor {
if (trace) {
const { traceEvents: events } = trace;
return events.reduce<number>((earliest, entry) => {
const { ts } = entry;
return ts > 0 && ts < earliest ? ts : earliest;
const { ts, cat } = entry;

// Blink events include the time that the app started. If a trace is
// performed at a later time, it creates a skewed timeline with blank
// space at the beginning.
const isBlinkEvent = cat?.startsWith('blink');
const isEarlier = ts > 0 && ts < earliest;

return isEarlier && !isBlinkEvent ? ts : earliest;
}, Number.MAX_SAFE_INTEGER);
}
return 0;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5276,10 +5276,10 @@ detect-node@^2.0.4:
resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.4.tgz#014ee8f8f669c5c58023da64b8179c083a28c46c"
integrity sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==

devtools-frontend-prebuilt@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/devtools-frontend-prebuilt/-/devtools-frontend-prebuilt-1.1.0.tgz#eb94f823e17288225db3b07f85042b7ff040e58c"
integrity sha512-SVedUtM2ecf40t68c5csgW/qkpGcA98Yz3DVoS0OKkX0GUZ5gNskiQvjqf6699vjGaPtidhvuKWKcPv2P4+cSQ==
devtools-frontend-prebuilt@1.2.0-beta1:
version "1.2.0-beta1"
resolved "https://registry.yarnpkg.com/devtools-frontend-prebuilt/-/devtools-frontend-prebuilt-1.2.0-beta1.tgz#2cbd8022ff913654a18f6844fb715bd87fc2acef"
integrity sha512-Ewkzlrn/jK4IjMblquaWBqvoSS8WSI6Dx8T2SEwAcSXnEVogrbnHvYIx02BVTeKW+9W9jsqjwNJb82rZKK8vdA==

diff-sequences@^27.4.0:
version "27.4.0"
Expand Down