Fixes monaco webworker and chunk loading issues.

This commit is contained in:
Henning Dieterichs
2020-03-21 12:52:20 +01:00
parent 107c2f6470
commit 776b6aee02
3 changed files with 16 additions and 3 deletions

View File

@@ -59,8 +59,12 @@ export class Server {
return `http://localhost:${port}/index.html?serverPort=${this.port}&serverSecret=${this.secret}${inWebView}${expr}`;
}
public get publicPath(): string {
return `http://localhost:${this.port}/`;
}
public get mainBundleUrl(): string {
return `http://localhost:${this.port}/main.js`;
return `${this.publicPath}main.js`;
}
public get port(): number {

View File

@@ -62,7 +62,7 @@ export function getHtml(server: Server) {
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';">
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline'; worker-src * data: 'unsafe-inline' 'unsafe-eval'; font-src * 'unsafe-inline' 'unsafe-eval';">
<style>
html { height: 100%; width: 100%; padding: 0; margin: 0; }
body { height: 100%; width: 100%; padding: 0; margin: 0; }
@@ -74,6 +74,7 @@ export function getHtml(server: Server) {
window.webViewData = ${JSON.stringify({
serverSecret: server.secret,
serverPort: server.port,
publicPath: server.publicPath,
})};
const api = window.VsCodeApi = acquireVsCodeApi();
window.addEventListener('message', event => {
@@ -89,6 +90,7 @@ export function getHtml(server: Server) {
}
});
</script>
${
isDev
? `<iframe sandbox="allow-top-navigation allow-scripts allow-same-origin allow-popups allow-pointer-lock allow-forms" src="${server.getIndexUrl(

View File

@@ -17,9 +17,15 @@ import { Disposable } from "@hediet/std/disposable";
import { startInterval } from "@hediet/std/timer";
declare const window: Window & {
webViewData?: { serverSecret: string; serverPort: number };
webViewData?: {
serverSecret: string;
serverPort: number;
publicPath: string;
};
};
declare let __webpack_public_path__: string;
export class Model {
public readonly dispose = Disposable.fn();
public readonly runningMode: "standalone" | "webView" | "webViewIFrame" =
@@ -83,6 +89,7 @@ export class Model {
this.port = data.serverPort;
this.serverSecret = data.serverSecret;
this.runningMode = "webView";
__webpack_public_path__ = data.publicPath;
const updateTheme = () => {
const isLight = document.body.classList.contains(