diff --git a/packages/app/client/src/ui/editor/emulator/parts/inspector/inspector.tsx b/packages/app/client/src/ui/editor/emulator/parts/inspector/inspector.tsx index c5ae8f5e8..2db9eee80 100644 --- a/packages/app/client/src/ui/editor/emulator/parts/inspector/inspector.tsx +++ b/packages/app/client/src/ui/editor/emulator/parts/inspector/inspector.tsx @@ -300,14 +300,15 @@ export class Inspector extends React.Component { } private createWebView(state: InspectorState): ElectronHTMLWebViewElement { - const webView: any = document.createElement('webview'); - webView.executeJavaScript(inspectPreload); + const webView: ElectronHTMLWebViewElement = document.createElement('webview'); + webView.className = styles.webViewContainer; webView.addEventListener('dragenter', this.onInspectorDrag, true); webView.addEventListener('dragover', this.onInspectorDrag, true); webView.addEventListener('ipc-message', this.ipcMessageEventHandler); webView.setAttribute('partition', `persist:${state.botHash}`); - + webView.setAttribute('preload', state.inspector.preloadPath); + webView.setAttribute('src', encodeURI(state.inspector.src)); return webView; } diff --git a/packages/app/main/src/extensions.ts b/packages/app/main/src/extensions.ts index 6768f94d8..e924bbf23 100644 --- a/packages/app/main/src/extensions.ts +++ b/packages/app/main/src/extensions.ts @@ -280,27 +280,16 @@ class ExtManagerImpl extends DisposableImpl implements ExtensionManager { inspectors.forEach(inspector => { inspector.src = (inspector.src || '').replace(/\\/g, '/'); }); - if ( - extension.config.client.debug && - extension.config.client.debug.enabled && - extension.config.client.debug.webpack - ) { - // If running in debug mode, rewrite inspector paths as http URLs for webpack-dev-server. - const port = extension.config.client.debug.webpack.port || 3030; - const host = extension.config.client.debug.webpack.host || 'localhost'; - inspectors.forEach(inspector => { - inspector.src = `http://${host}:${port}/${inspector.src}`.replace(extension.config.client.basePath, ''); - }); - } else { - // If not in debug mode, rewrite paths as file path URLs. - inspectors.forEach(inspector => { - let folder = path.resolve(configPath).replace(/\\/g, '/'); - if (folder[0] !== '/') { - folder = `/${folder}`; - } - inspector.src = `file://${folder}/` + inspector.src; - }); - } + inspectors.forEach(inspector => { + let folder = path.resolve(configPath).replace(/\\/g, '/'); + if (folder[0] !== '/') { + folder = `/${folder}`; + } + inspector.src = `file://${folder}/` + inspector.src; + inspector.preloadPath = + 'file://' + path.resolve(path.join(__dirname, '..', 'extensions', 'inspector-preload.js')); + }); + // Connect to the extension's node process (if any). extension.connect(); // Notify the client of the new extension. diff --git a/packages/app/client/src/ui/editor/emulator/parts/inspector/inspector-preload.js b/packages/app/main/src/extensions/inspector-preload.js similarity index 100% rename from packages/app/client/src/ui/editor/emulator/parts/inspector/inspector-preload.js rename to packages/app/main/src/extensions/inspector-preload.js diff --git a/packages/sdk/shared/src/extensions/config.ts b/packages/sdk/shared/src/extensions/config.ts index c36332f1c..112413f8a 100644 --- a/packages/sdk/shared/src/extensions/config.ts +++ b/packages/sdk/shared/src/extensions/config.ts @@ -67,6 +67,7 @@ export interface InspectorAccessoryState extends HTMLAttributes