Skip to content

Commit

Permalink
Merge 2109f52 into 42b41e8
Browse files Browse the repository at this point in the history
  • Loading branch information
a-b-r-o-w-n committed May 1, 2019
2 parents 42b41e8 + 2109f52 commit fbc4c9c
Showing 1 changed file with 14 additions and 8 deletions.
Expand Up @@ -271,13 +271,14 @@ export class Inspector extends React.Component<InspectorProps, InspectorState> {
if (!src) {
return;
}
const encodedSrc = encodeURI(src);
const { webViewByLocation: webViews } = this;
if (!webViews[src]) {
webViews[src] = this.createWebView(state);
if (!webViews[encodedSrc]) {
webViews[encodedSrc] = this.createWebView(state);
} else {
this.sendInitializationStackToInspector();
}
const nextInspector = webViews[src] || (webViews[src] = this.createWebView(state));
const nextInspector = webViews[encodedSrc] || (webViews[encodedSrc] = this.createWebView(state));
nextInspector.style.display = '';

const { containerRef } = this.state;
Expand All @@ -296,8 +297,13 @@ export class Inspector extends React.Component<InspectorProps, InspectorState> {
}

private createWebView(state: InspectorState): ElectronHTMLWebViewElement {
const { cwdAsBase } = this.props;
const preload = `file://${cwdAsBase}/node_modules/@bfemulator/client/public/inspector-preload.js`;
// const { cwdAsBase } = this.props;
// const preload = `file://${cwdAsBase}/../../../node_modules/@bfemulator/client/public/inspector-preload.js`;
// const preload = `file://node_modules/@bfemulator/client/public/inspector-preload.js`;
// THIS IS A HACK!! WILL FIX LATER
const preload = state.inspector.src
.replace(/extension-.*/, 'client/public/inspector-preload.js')
.replace('asar.unpacked', 'asar');
const webView: ElectronHTMLWebViewElement = document.createElement('webview');

webView.className = styles.webViewContainer;
Expand All @@ -306,7 +312,7 @@ export class Inspector extends React.Component<InspectorProps, InspectorState> {
webView.addEventListener('ipc-message', this.ipcMessageEventHandler);
webView.setAttribute('partition', `persist:${state.botHash}`);
webView.setAttribute('preload', preload);
webView.setAttribute('src', state.inspector.src);
webView.setAttribute('src', encodeURI(state.inspector.src));
return webView;
}

Expand Down Expand Up @@ -430,8 +436,8 @@ export class Inspector extends React.Component<InspectorProps, InspectorState> {

private sendToInspector(channel: string, ...args: any[]) {
const { inspectorSrc } = this.state;
const inspector = this.webViewByLocation[inspectorSrc];
if (!inspector || !this.domReadyByLocation[inspectorSrc]) {
const inspector = this.webViewByLocation[encodeURI(inspectorSrc)];
if (!inspector || !this.domReadyByLocation[encodeURI(inspectorSrc)]) {
return;
}
try {
Expand Down

0 comments on commit fbc4c9c

Please sign in to comment.