[IMP] app: expose live apps for the devtools

This commit exposes owl apps in a global variable so that the owl
devtools can hook themselves on these apps. While the devtools are not
yet ready to be merged, exposing the apps will allow us to test the
devtools in production scenarios while polishing the development of
them.
This commit is contained in:
Julien Carion
2023-01-20 16:00:28 +01:00
committed by Géry Debongnie
parent cea82e945d
commit ad4adb930e
+14
View File
@@ -31,6 +31,18 @@ This is not suitable for production use.
See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration for more information.`;
};
declare global {
interface Window {
__OWL_DEVTOOLS__: {
apps: Set<App>;
};
}
}
window.__OWL_DEVTOOLS__ ||= {
apps: new Set<App>(),
};
export class App<
T extends abstract new (...args: any) => any = any,
P extends object = any,
@@ -48,6 +60,7 @@ export class App<
constructor(Root: ComponentConstructor<P, E>, config: AppConfig<P, E> = {}) {
super(config);
this.Root = Root;
window.__OWL_DEVTOOLS__.apps.add(this);
if (config.test) {
this.dev = true;
}
@@ -109,6 +122,7 @@ export class App<
this.scheduler.flush();
this.root.destroy();
}
window.__OWL_DEVTOOLS__.apps.delete(this);
}
createComponent<P extends Props>(