From 44355baad190875404b3c078bbd68c50411a8c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0ime=C4=8Dek?= Date: Fri, 6 Dec 2019 12:10:50 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20updated=20devtools=20man?= =?UTF-8?q?ager=20code=20to=20ima17?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devtools-scripts/src/main.js | 33 +++++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/packages/devtools-scripts/src/main.js b/packages/devtools-scripts/src/main.js index d1fc82f821..4f06d9cedd 100644 --- a/packages/devtools-scripts/src/main.js +++ b/packages/devtools-scripts/src/main.js @@ -2,6 +2,19 @@ import { aop, createHook, hookName, createCallTrap } from 'to-aop'; import uid from 'easy-uid'; import DevToolManager from './DevToolManager'; +const ImaMainModules = [ + 'onLoad', + 'getInitialImaConfigFunctions', + 'getNamespace', + 'getInitialPluginConfig', + 'createImaApp', + 'getClientBootConfig', + 'bootClientApp', + 'routeClientApp', + 'hotReloadClientApp', + 'reviveClientApp' +]; + // eslint-disable-next-line no-unused-vars function createDevtool(registerHook) { $IMA.devtool = $IMA.devtool || {}; @@ -182,21 +195,21 @@ function createDevtool(registerHook) { } ); - // TODO CHANGE FOR IMA@17 - let imaMain = importIMAClass('ima/main'); + let imaCore = importIMAClass('@ima/core'); + ImaMainModules.forEach(moduleName => { + const key = `__${moduleName}__`; - Object.keys(imaMain).forEach(property => { - const key = `__${property}__`; - Object.defineProperty(imaMain, key, { - value: imaMain[property], + Object.defineProperty(imaCore, key, { + value: imaCore[moduleName], enumerable: false, configurable: false, writable: false }); - imaMain[key] = imaMain[property]; - imaMain[property] = createCallTrap({ - target: imaMain, - object: imaMain, + + imaCore[key] = imaCore[moduleName]; + imaCore[moduleName] = createCallTrap({ + target: imaCore, + object: imaCore, property: key, pattern: revivePattern });