Skip to content

Commit

Permalink
Slider fix and updated how inspector-preload.js is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
justinwilaby committed May 8, 2019
1 parent 1dd9473 commit 81c351a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,15 @@ export class Inspector extends React.Component<InspectorProps, InspectorState> {
}

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;
}

Expand Down
31 changes: 10 additions & 21 deletions packages/app/main/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/shared/src/extensions/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface InspectorAccessoryState extends HTMLAttributes<HTMLButtonElemen
export interface ExtensionInspector {
name?: string;
src?: string;
preloadPath?: string;
criteria?: InspectorCriteria | InspectorCriteria[];
summaryText?: string | string[];
accessories?: InspectorAccessory[];
Expand Down

0 comments on commit 81c351a

Please sign in to comment.