From ad4adb930ee839fb2743b501c535341c30b539c4 Mon Sep 17 00:00:00 2001 From: Julien Carion Date: Fri, 20 Jan 2023 16:00:28 +0100 Subject: [PATCH] [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. --- src/runtime/app.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/runtime/app.ts b/src/runtime/app.ts index 96b5789b..53f1fa85 100644 --- a/src/runtime/app.ts +++ b/src/runtime/app.ts @@ -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; + }; + } +} + +window.__OWL_DEVTOOLS__ ||= { + apps: new Set(), +}; + 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, config: AppConfig = {}) { 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

(