Files
owl/tools/devtools/src/devtools_app/devtools.js
T
Julien Carion (juca) 606d14a399 [REF] devtools: Better messages forwarding
This commit improves how messages are relayed from the page to the
devtools by using a specific port for each instance of the owl devtools
panel and refreshing it through the heartbeat message. This allows
to prevent sending messages to every devtools instances and sorting
the messages inside.
2023-04-25 09:31:53 +02:00

33 lines
910 B
JavaScript

import { IS_FIREFOX } from "../utils";
let created = false;
let browserInstance = IS_FIREFOX ? browser : chrome;
// Try to load the owl panel each 1000 ms in case it (re)appears on the page later on
const checkInterval = setInterval(createPanelsIfOwl, 1000);
createPanelsIfOwl();
// Create the owl devtools panel if owl on the page is available at a sufficient version
function createPanelsIfOwl() {
if (created) {
clearInterval(checkInterval);
return;
}
browserInstance.devtools.inspectedWindow.eval(
"window.__OWL_DEVTOOLS__?.Fiber !== undefined;",
async (hasOwl) => {
if (!hasOwl || created) {
return;
}
clearInterval(checkInterval);
created = true;
browserInstance.devtools.panels.create(
"Owl",
"../../assets/icon128.png",
IS_FIREFOX ? "devtools_panel.html" : "devtools_app/devtools_panel.html"
);
}
);
}