mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[ADD] tools: create owl-devtools extension
This commit adds the code of the owl devtools extension. This extension can be added on chrome or on firefox for developpers to be able to inspect the contents of all owl applications that are present on any web page, see all the components, interract with them and their content to some extend and perform a bit of profiling with their renders.
This commit is contained in:
committed by
Géry Debongnie
parent
a9323c3fcd
commit
ef5e4a0637
@@ -0,0 +1,33 @@
|
||||
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"
|
||||
);
|
||||
browserInstance.runtime.sendMessage({ type: "newDevtoolsPanel" });
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user