FuseBox didn't work out

This commit is contained in:
Asher 2019-01-11 18:11:34 -06:00 committed by Kyle Carberry
parent 0c3ffb301a
commit d44a0a3e59
No known key found for this signature in database
GPG key ID: A0409BDB6B0B3EDB
15 changed files with 3257 additions and 1337 deletions

1
.gitignore vendored
View file

@ -1,4 +1,3 @@
.fusebox
lib/vscode
node_modules
dist

19
fuse.js
View file

@ -1,19 +0,0 @@
const {
FuseBox, SassPlugin, CSSPlugin, WebIndexPlugin,
} = require("fuse-box");
const fuse = FuseBox.init({
homeDir: ".",
output: "dist/$name.js",
plugins: [
WebIndexPlugin({ template: "packages/app/src/index.html" }),
[ SassPlugin(), CSSPlugin() ],
],
});
fuse.dev();
fuse.bundle("app").hmr().watch()
.instructions(">packages/app/src/index.ts");
fuse.run();

View file

@ -10,14 +10,32 @@
"vscode": "npm-run-all vscode:*",
"packages:install": "cd ./packages && yarn",
"postinstall": "npm-run-all --parallel vscode packages:install",
"start": "node fuse.js",
"start": "webpack-dev-server --hot --config ./webpack.config.app.js",
"test": "cd ./packages && yarn test"
},
"devDependencies": {
"@types/node": "^10.12.18",
"fuse-box": "^3.6.0",
"crypto-browserify": "^3.12.0",
"css-loader": "^2.1.0",
"file-loader": "^3.0.1",
"fork-ts-checker-webpack-plugin": "^0.5.2",
"happypack": "^5.0.1",
"html-webpack-plugin": "^3.2.0",
"http-browserify": "^1.7.0",
"mini-css-extract-plugin": "^0.5.0",
"node-sass": "^4.11.0",
"npm-run-all": "^4.1.5",
"typescript": "^3.2.2"
"os-browserify": "^0.3.0",
"preload-webpack-plugin": "^3.0.0-beta.2",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"ts-loader": "^5.3.3",
"typescript": "^3.2.2",
"uglifyjs-webpack-plugin": "^2.1.1",
"webpack": "^4.28.4",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.1.14",
"write-file-webpack-plugin": "^4.5.0"
}
}

View file

@ -43,7 +43,6 @@
<div class="message">
</div>
</div>
$bundles
</body>
</html>

View file

@ -1,5 +1,8 @@
import { logger } from "@coder/logger";
import "./index.scss";
logger.info("Starting app");
const overlay = document.getElementById("overlay");
const logo = document.getElementById("logo");
if (overlay && logo) {
@ -10,3 +13,5 @@ if (overlay && logo) {
logo.style.transform = `perspective(200px) rotateX(${yPos}deg) rotateY(${xPos}deg)`;
});
}
import "@coder/vscode";

View file

@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

View file

@ -1,352 +1,352 @@
import * as electron from "electron";
import { EventEmitter } from "events";
import * as fs from "fs";
import { getFetchUrl } from "../src/coder/api";
import { escapePath } from "../src/coder/common";
import { wush } from "../src/coder/server";
import { IKey, Dialog } from "./dialog";
// import * as electron from "electron";
// import { EventEmitter } from "events";
// import * as fs from "fs";
// import { getFetchUrl } from "../src/coder/api";
// import { escapePath } from "../src/coder/common";
// import { wush } from "../src/coder/server";
// import { IKey, Dialog } from "./dialog";
(global as any).getOpenUrls = () => {
return [];
};
// (global as any).getOpenUrls = () => {
// return [];
// };
const oldCreateElement = document.createElement;
// const oldCreateElement = document.createElement;
document.createElement = (tagName: string) => {
const createElement = (tagName: string) => {
return oldCreateElement.call(document, tagName);
};
// document.createElement = (tagName: string) => {
// const createElement = (tagName: string) => {
// return oldCreateElement.call(document, tagName);
// };
if (tagName === "webview") {
const view = createElement("iframe") as HTMLIFrameElement;
view.style.border = "0px";
const frameID = Math.random().toString();
view.addEventListener("error", (event) => {
console.log("Got iframe error", event.error, event.message);
});
window.addEventListener("message", (event) => {
if (!event.data || !event.data.id) {
return;
}
if (event.data.id !== frameID) {
return;
}
const e = new CustomEvent("ipc-message");
(e as any).channel = event.data.channel;
(e as any).args = event.data.data;
view.dispatchEvent(e);
});
view.sandbox.add("allow-same-origin", "allow-scripts", "allow-popups", "allow-forms");
Object.defineProperty(view, "preload", {
set: (url: string) => {
view.onload = () => {
view.contentDocument.body.id = frameID;
view.contentDocument.body.parentElement.style.overflow = "hidden";
const script = document.createElement("script");
script.src = url;
view.contentDocument.head.appendChild(script);
};
},
});
(view as any).getWebContents = () => undefined;
(view as any).send = (channel: string, ...args) => {
if (args[0] && typeof args[0] === "object" && args[0].contents) {
args[0].contents = (args[0].contents as string).replace(/"(file:\/\/[^"]*)"/g, (m) => `"${getFetchUrl(m)}"`);
args[0].contents = (args[0].contents as string).replace(/"vscode-resource:([^"]*)"/g, (m) => `"${getFetchUrl(m)}"`);
}
view.contentWindow.postMessage({
channel,
data: args,
id: frameID,
}, "*");
};
return view;
}
// if (tagName === "webview") {
// const view = createElement("iframe") as HTMLIFrameElement;
// view.style.border = "0px";
// const frameID = Math.random().toString();
// view.addEventListener("error", (event) => {
// console.log("Got iframe error", event.error, event.message);
// });
// window.addEventListener("message", (event) => {
// if (!event.data || !event.data.id) {
// return;
// }
// if (event.data.id !== frameID) {
// return;
// }
// const e = new CustomEvent("ipc-message");
// (e as any).channel = event.data.channel;
// (e as any).args = event.data.data;
// view.dispatchEvent(e);
// });
// view.sandbox.add("allow-same-origin", "allow-scripts", "allow-popups", "allow-forms");
// Object.defineProperty(view, "preload", {
// set: (url: string) => {
// view.onload = () => {
// view.contentDocument.body.id = frameID;
// view.contentDocument.body.parentElement.style.overflow = "hidden";
// const script = document.createElement("script");
// script.src = url;
// view.contentDocument.head.appendChild(script);
// };
// },
// });
// (view as any).getWebContents = () => undefined;
// (view as any).send = (channel: string, ...args) => {
// if (args[0] && typeof args[0] === "object" && args[0].contents) {
// args[0].contents = (args[0].contents as string).replace(/"(file:\/\/[^"]*)"/g, (m) => `"${getFetchUrl(m)}"`);
// args[0].contents = (args[0].contents as string).replace(/"vscode-resource:([^"]*)"/g, (m) => `"${getFetchUrl(m)}"`);
// }
// view.contentWindow.postMessage({
// channel,
// data: args,
// id: frameID,
// }, "*");
// };
// return view;
// }
return createElement(tagName);
};
// return createElement(tagName);
// };
const rendererToMainEmitter = new EventEmitter();
const mainToRendererEmitter = new EventEmitter();
// const rendererToMainEmitter = new EventEmitter();
// const mainToRendererEmitter = new EventEmitter();
module.exports = {
clipboard: {
has: () => {
return false;
},
writeText: (value: string) => {
// Taken from https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
const active = document.activeElement as HTMLElement;
const el = document.createElement('textarea'); // Create a <textarea> element
el.value = value; // Set its value to the string that you want copied
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
el.style.position = 'absolute';
el.style.left = '-9999px'; // Move outside the screen to make it invisible
document.body.appendChild(el); // Append the <textarea> element to the HTML document
const selected =
document.getSelection().rangeCount > 0 // Check if there is any content selected previously
? document.getSelection().getRangeAt(0) // Store selection if found
: false; // Mark as false to know no selection existed before
el.select(); // Select the <textarea> content
document.execCommand('copy'); // Copy - only works as a result of a user action (e.g. click events)
document.body.removeChild(el); // Remove the <textarea> element
if (selected) { // If a selection existed before copying
document.getSelection().removeAllRanges(); // Unselect everything on the HTML document
document.getSelection().addRange(selected); // Restore the original selection
}
active.focus();
},
},
dialog: {
showSaveDialog: (_: void, options: Electron.SaveDialogOptions, callback: (filename: string) => void): void => {
const defaultPath = options.defaultPath || "/untitled";
const fileIndex = defaultPath.lastIndexOf("/");
const extensionIndex = defaultPath.lastIndexOf(".");
const saveDialogOptions = {
buttons: ["Cancel", "Save"],
detail: "Enter a path for this file",
input: {
value: defaultPath,
selection: {
start: fileIndex === -1 ? 0 : fileIndex + 1,
end: extensionIndex === -1 ? defaultPath.length : extensionIndex,
},
},
message: "Save file",
};
// module.exports = {
// clipboard: {
// has: () => {
// return false;
// },
// writeText: (value: string) => {
// // Taken from https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
// const active = document.activeElement as HTMLElement;
// const el = document.createElement('textarea'); // Create a <textarea> element
// el.value = value; // Set its value to the string that you want copied
// el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
// el.style.position = 'absolute';
// el.style.left = '-9999px'; // Move outside the screen to make it invisible
// document.body.appendChild(el); // Append the <textarea> element to the HTML document
// const selected =
// document.getSelection().rangeCount > 0 // Check if there is any content selected previously
// ? document.getSelection().getRangeAt(0) // Store selection if found
// : false; // Mark as false to know no selection existed before
// el.select(); // Select the <textarea> content
// document.execCommand('copy'); // Copy - only works as a result of a user action (e.g. click events)
// document.body.removeChild(el); // Remove the <textarea> element
// if (selected) { // If a selection existed before copying
// document.getSelection().removeAllRanges(); // Unselect everything on the HTML document
// document.getSelection().addRange(selected); // Restore the original selection
// }
// active.focus();
// },
// },
// dialog: {
// showSaveDialog: (_: void, options: Electron.SaveDialogOptions, callback: (filename: string) => void): void => {
// const defaultPath = options.defaultPath || "/untitled";
// const fileIndex = defaultPath.lastIndexOf("/");
// const extensionIndex = defaultPath.lastIndexOf(".");
// const saveDialogOptions = {
// buttons: ["Cancel", "Save"],
// detail: "Enter a path for this file",
// input: {
// value: defaultPath,
// selection: {
// start: fileIndex === -1 ? 0 : fileIndex + 1,
// end: extensionIndex === -1 ? defaultPath.length : extensionIndex,
// },
// },
// message: "Save file",
// };
const dialog = new Dialog(saveDialogOptions);
dialog.onAction((action) => {
if (action.key !== IKey.Enter && action.buttonIndex !== 1) {
dialog.hide();
return callback(undefined);
}
// const dialog = new Dialog(saveDialogOptions);
// dialog.onAction((action) => {
// if (action.key !== IKey.Enter && action.buttonIndex !== 1) {
// dialog.hide();
// return callback(undefined);
// }
const filePath = dialog.inputValue.replace(/\/+$/, "");
const split = filePath.split("/");
const fileName = split.pop();
const parentName = split.pop() || "/";
if (fileName === "") {
dialog.error = "You must enter a file name.";
return;
}
// const filePath = dialog.inputValue.replace(/\/+$/, "");
// const split = filePath.split("/");
// const fileName = split.pop();
// const parentName = split.pop() || "/";
// if (fileName === "") {
// dialog.error = "You must enter a file name.";
// return;
// }
fs.stat(filePath, (error, stats) => {
if (error && error.code === "ENOENT") {
dialog.hide();
callback(filePath);
} else if (error) {
dialog.error = error.message;
} else if (stats.isDirectory()) {
dialog.error = `A directory named "${fileName}" already exists.`;
} else {
dialog.error = undefined;
// fs.stat(filePath, (error, stats) => {
// if (error && error.code === "ENOENT") {
// dialog.hide();
// callback(filePath);
// } else if (error) {
// dialog.error = error.message;
// } else if (stats.isDirectory()) {
// dialog.error = `A directory named "${fileName}" already exists.`;
// } else {
// dialog.error = undefined;
const confirmDialog = new Dialog({
message: `A file named "${fileName}" already exists. Do you want to replace it?`,
detail: `The file already exists in "${parentName}". Replacing it will overwrite its contents.`,
buttons: ["Cancel", "Replace"],
});
// const confirmDialog = new Dialog({
// message: `A file named "${fileName}" already exists. Do you want to replace it?`,
// detail: `The file already exists in "${parentName}". Replacing it will overwrite its contents.`,
// buttons: ["Cancel", "Replace"],
// });
confirmDialog.onAction((action) => {
if (action.buttonIndex === 1) {
confirmDialog.hide();
return callback(filePath);
}
// confirmDialog.onAction((action) => {
// if (action.buttonIndex === 1) {
// confirmDialog.hide();
// return callback(filePath);
// }
confirmDialog.hide();
dialog.show();
});
// confirmDialog.hide();
// dialog.show();
// });
dialog.hide();
confirmDialog.show();
}
});
});
dialog.show();
},
showOpenDialog: () => {
console.log("Trying to show the open dialog");
},
showMessageBox: (_: void, options: Electron.MessageBoxOptions, callback: (button: number, checked: boolean) => void): void => {
const dialog = new Dialog(options);
dialog.onAction((action) => {
dialog.hide();
callback(action.buttonIndex, false);
});
dialog.show();
},
},
remote: {
dialog: {
showOpenDialog: () => {
console.log("Trying to remotely open");
},
},
},
webFrame: {
getZoomFactor: () => {
return 1;
},
getZoomLevel: () => {
return 1;
},
setZoomLevel: () => {
return;
},
},
screen: {
getAllDisplays: () => {
return [{
bounds: {
x: 1000,
y: 1000,
},
}];
},
},
app: {
isAccessibilitySupportEnabled: () => {
return false;
},
setAsDefaultProtocolClient: () => {
// dialog.hide();
// confirmDialog.show();
// }
// });
// });
// dialog.show();
// },
// showOpenDialog: () => {
// console.log("Trying to show the open dialog");
// },
// showMessageBox: (_: void, options: Electron.MessageBoxOptions, callback: (button: number, checked: boolean) => void): void => {
// const dialog = new Dialog(options);
// dialog.onAction((action) => {
// dialog.hide();
// callback(action.buttonIndex, false);
// });
// dialog.show();
// },
// },
// remote: {
// dialog: {
// showOpenDialog: () => {
// console.log("Trying to remotely open");
// },
// },
// },
// webFrame: {
// getZoomFactor: () => {
// return 1;
// },
// getZoomLevel: () => {
// return 1;
// },
// setZoomLevel: () => {
// return;
// },
// },
// screen: {
// getAllDisplays: () => {
// return [{
// bounds: {
// x: 1000,
// y: 1000,
// },
// }];
// },
// },
// app: {
// isAccessibilitySupportEnabled: () => {
// return false;
// },
// setAsDefaultProtocolClient: () => {
},
send: (str) => {
console.log("APP Trying to send", str);
//
},
on: () => {
//
},
once: () => {
//
},
},
// ipcRenderer communicates with ipcMain
ipcRenderer: {
send: (str, ...args) => {
rendererToMainEmitter.emit(str, {
sender: module.exports.ipcMain,
}, ...args);
},
on: (str, listener) => {
mainToRendererEmitter.on(str, listener);
},
once: (str, listener) => {
mainToRendererEmitter.once(str, listener);
},
removeListener: (str, listener) => {
mainToRendererEmitter.removeListener(str, listener);
},
},
ipcMain: {
send: (str, ...args) => {
mainToRendererEmitter.emit(str, {
sender: module.exports.ipcRenderer,
}, ...args);
},
on: (str, listener) => {
rendererToMainEmitter.on(str, listener);
},
once: (str, listener) => {
rendererToMainEmitter.once(str, listener);
},
},
shell: {
moveItemToTrash: async (path) => {
const response = await wush.execute({
command: `trash-put --trash-dir ${escapePath("~/.Trash")} ${escapePath(path)}`,
}).done();
return response.wasSuccessful();
},
},
BrowserWindow: class {
// },
// send: (str) => {
// console.log("APP Trying to send", str);
// //
// },
// on: () => {
// //
// },
// once: () => {
// //
// },
// },
// // ipcRenderer communicates with ipcMain
// ipcRenderer: {
// send: (str, ...args) => {
// rendererToMainEmitter.emit(str, {
// sender: module.exports.ipcMain,
// }, ...args);
// },
// on: (str, listener) => {
// mainToRendererEmitter.on(str, listener);
// },
// once: (str, listener) => {
// mainToRendererEmitter.once(str, listener);
// },
// removeListener: (str, listener) => {
// mainToRendererEmitter.removeListener(str, listener);
// },
// },
// ipcMain: {
// send: (str, ...args) => {
// mainToRendererEmitter.emit(str, {
// sender: module.exports.ipcRenderer,
// }, ...args);
// },
// on: (str, listener) => {
// rendererToMainEmitter.on(str, listener);
// },
// once: (str, listener) => {
// rendererToMainEmitter.once(str, listener);
// },
// },
// shell: {
// moveItemToTrash: async (path) => {
// const response = await wush.execute({
// command: `trash-put --trash-dir ${escapePath("~/.Trash")} ${escapePath(path)}`,
// }).done();
// return response.wasSuccessful();
// },
// },
// BrowserWindow: class {
public webContents = {
on: () => {
// public webContents = {
// on: () => {
},
session: {
webRequest: {
onBeforeRequest: () => {
// },
// session: {
// webRequest: {
// onBeforeRequest: () => {
},
// },
onBeforeSendHeaders: () => {
// onBeforeSendHeaders: () => {
},
// },
onHeadersReceived: () => {
// onHeadersReceived: () => {
},
}
},
removeAllListeners: () => {
// },
// }
// },
// removeAllListeners: () => {
},
}
// },
// }
public static getFocusedWindow() {
return undefined;
}
// public static getFocusedWindow() {
// return undefined;
// }
public isMaximized() {
return false;
}
// public isMaximized() {
// return false;
// }
public isFullScreen() {
return false;
}
// public isFullScreen() {
// return false;
// }
public setMenuBarVisibility(visibility) {
console.log("We are setting the menu bar to ", visibility);
}
// public setMenuBarVisibility(visibility) {
// console.log("We are setting the menu bar to ", visibility);
// }
public setAutoHideMenuBar() {
// public setAutoHideMenuBar() {
}
// }
public on() {
// public on() {
}
// }
public setTitle(value: string): void {
document.title = value;
}
},
toggleFullScreen: () => {
const doc = document as any;
const isInFullScreen = doc.fullscreenElement
|| doc.webkitFullscreenElement
|| doc.mozFullScreenElement
|| doc.msFullscreenElement;
// public setTitle(value: string): void {
// document.title = value;
// }
// },
// toggleFullScreen: () => {
// const doc = document as any;
// const isInFullScreen = doc.fullscreenElement
// || doc.webkitFullscreenElement
// || doc.mozFullScreenElement
// || doc.msFullscreenElement;
const body = doc.body;
if (!isInFullScreen) {
if (body.requestFullscreen) {
body.requestFullscreen();
} else if (body.mozRequestFullScreen) {
body.mozRequestFullScreen();
} else if (body.webkitRequestFullScreen) {
body.webkitRequestFullScreen();
} else if (body.msRequestFullscreen) {
body.msRequestFullscreen();
}
} else {
if (doc.exitFullscreen) {
doc.exitFullscreen();
} else if (doc.webkitExitFullscreen) {
doc.webkitExitFullscreen();
} else if (doc.mozCancelFullScreen) {
doc.mozCancelFullScreen();
} else if (doc.msExitFullscreen) {
doc.msExitFullscreen();
}
}
},
focusWindow: () => {
console.log("focusing window");
window.focus();
},
};
// const body = doc.body;
// if (!isInFullScreen) {
// if (body.requestFullscreen) {
// body.requestFullscreen();
// } else if (body.mozRequestFullScreen) {
// body.mozRequestFullScreen();
// } else if (body.webkitRequestFullScreen) {
// body.webkitRequestFullScreen();
// } else if (body.msRequestFullscreen) {
// body.msRequestFullscreen();
// }
// } else {
// if (doc.exitFullscreen) {
// doc.exitFullscreen();
// } else if (doc.webkitExitFullscreen) {
// doc.webkitExitFullscreen();
// } else if (doc.mozCancelFullScreen) {
// doc.mozCancelFullScreen();
// } else if (doc.msExitFullscreen) {
// doc.msExitFullscreen();
// }
// }
// },
// focusWindow: () => {
// console.log("focusing window");
// window.focus();
// },
// };

4
packages/ide/yarn.lock Normal file
View file

@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

View file

@ -1,4 +1,5 @@
{
"name": "@coder/vscode",
"description": "VS Code implementation of the browser-based IDE client."
"description": "VS Code implementation of the browser-based IDE client.",
"main": "src/index.ts"
}

View file

@ -1,55 +0,0 @@
const loadTime = time(2500);
import { URI } from "vs/base/common/uri";
import { field, logger, time } from "@coder/logger";
import { Client, IURI, setUriFactory } from "@coder/ide";
import "./firefox";
import "./setup";
setUriFactory({
// TODO: not sure why this is an error.
// tslint:disable-next-line no-any
create: <URI>(uri: IURI): URI => URI.from(uri) as any,
file: (path: string): IURI => URI.file(path),
parse: (raw: string): IURI => URI.parse(raw),
});
export const client = new Client({
mkDirs: [
"~/vscode/extensions",
"~/.config/User",
],
});
const overlayElement = document.getElementById("overlay");
const msgElement = overlayElement
? overlayElement.querySelector(".message") as HTMLElement
: undefined;
const importTime = time(1500);
import(/* webpackPrefetch: true */ "./workbench").then((module) => {
logger.info("Loaded workbench bundle", field("duration", importTime));
const initTime = time(1500);
return module.initialize(client).then(() => {
logger.info("Initialized workbench", field("duration", initTime));
logger.info("Load completed", field("duration", loadTime));
if (overlayElement) {
overlayElement.style.opacity = "0";
overlayElement.addEventListener("transitionend", () => {
overlayElement.remove();
});
}
});
}).catch((error) => {
logger.error(error);
if (overlayElement) {
overlayElement.classList.add("error");
}
if (msgElement) {
msgElement.innerText = `Failed to load: ${error.message}. Retrying in 3 seconds...`;
}
setTimeout(() => {
location.reload();
}, 3000);
});

View file

@ -0,0 +1,54 @@
import { field, logger, time } from "@coder/logger";
const loadTime = time(2500);
import { Client, IURI, setUriFactory } from "@coder/ide";
import { URI } from "vs/base/common/uri";
import "./firefox";
setUriFactory({
// TODO: not sure why this is an error.
// tslint:disable-next-line no-any
create: <URI>(uri: IURI): URI => URI.from(uri) as any,
file: (path: string): IURI => URI.file(path),
parse: (raw: string): IURI => URI.parse(raw),
});
// export const client = new Client({
// mkDirs: [
// "~/vscode/extensions",
// "~/.config/User",
// ],
// });
// const overlayElement = document.getElementById("overlay");
// const msgElement = overlayElement
// ? overlayElement.querySelector(".message") as HTMLElement
// : undefined;
// const importTime = time(1500);
// import(/* webpackPrefetch: true */ "./workbench").then((module) => {
// logger.info("Loaded workbench bundle", field("duration", importTime));
// const initTime = time(1500);
// return module.initialize(client).then(() => {
// logger.info("Initialized workbench", field("duration", initTime));
// logger.info("Load completed", field("duration", loadTime));
// if (overlayElement) {
// overlayElement.style.opacity = "0";
// overlayElement.addEventListener("transitionend", () => {
// overlayElement.remove();
// });
// }
// });
// }).catch((error) => {
// logger.error(error);
// if (overlayElement) {
// overlayElement.classList.add("error");
// }
// if (msgElement) {
// msgElement.innerText = `Failed to load: ${error.message}. Retrying in 3 seconds...`;
// }
// setTimeout(() => {
// location.reload();
// }, 3000);
// });

View file

@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

View file

@ -1,11 +1,10 @@
const path = require("path");
const sourcePath = "./src";
const entryFile = "./coder/entry.ts";
const isCi = typeof process.env.CI !== "undefined";
const environment = process.env.NODE_ENV || "development";
const isCi = typeof process.env.CI !== "undefined";
const minify = isCi;
const compatibility = isCi;
const HappyPack = require("happypack");
const webpack = require("webpack");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
@ -16,47 +15,30 @@ const WriteFilePlugin = require("write-file-webpack-plugin");
const PreloadWebpackPlugin = require("preload-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const root = __dirname;
const nodeFills = path.join(root, "packages", "node-browser", "src");
const vscodeFills = path.join(root, "packages", "vscode", "src", "fill");
module.exports = {
context: path.join(__dirname, sourcePath),
devtool: "eval", // "cheap-module-eval-source-map",
entry: entryFile,
context: root,
devtool: "eval",
entry: "./packages/app/src/index.ts",
mode: isCi ? "production" : "development",
output: {
chunkFilename: "[name]-[hash:6].bundle.js",
path: path.resolve(__dirname, "./dist"),
publicPath: process.env.BUILD_ID ? `/${process.env.BUILD_ID}/ide/` : "/ide/",
path: path.join(root, "dist"),
filename: "[hash:6].bundle.js",
globalObject: "this",
},
module: {
rules: [
{
loader: "string-replace-loader",
test: /\.(js|ts)/,
options: {
multiple: [
{
search: "require\\.toUrl\\(",
replace: "requireToUrl(",
flags: "g",
},
{
search: "require\\.__\\$__nodeRequire",
replace: "require",
flags: "g",
},
],
},
},
{
rules: [{
test: /\.(js)/,
exclude: /test/,
},
{
}, {
test: /\.(node|txt|d\.ts|test.ts|perf.data.js|jxs)/,
use: [{
loader: "ignore-loader",
},
{
}],
}, {
use: [{
loader: "happypack/loader?id=ts",
}],
@ -64,106 +46,90 @@ module.exports = {
}, {
exclude: /test/,
test: /\.s?css$/,
// This is required otherwise it'll fail to resolve
// CSS in common
include: __dirname,
use: [true ? {
// This is required otherwise it'll fail to resolve CSS in common.
include: root,
use: [{
loader: MiniCssExtractPlugin.loader,
} : "style-loader", require.resolve("css-loader"), require.resolve("sass-loader")],
}, {
loader: "css-loader",
}, {
loader: "sass-loader",
}],
}, {
test: /\.(svg|png|ttf|woff|eot)$/,
use: ["file-loader"]
use: [{
loader: "file-loader",
}],
}, {
test: /\.wasm$/,
type: "javascript/auto",
}
],
noParse: /(\.test\.tsx?)|(\.test\.jsx?)/,
},
node: {
// electron: "empty",
// fs: "empty",
// child_process: "empty",
module: "empty",
// net: "empty",
crypto: "empty",
tls: "empty",
}],
noParse: /\.test\.(j|t)sx?/,
},
resolve: {
alias: {
"gc-signals": path.resolve(__dirname, "./fill/empty.ts"),
"native-keymap": path.resolve(__dirname, "./fill/native-keymap.ts"),
"windows-process-tree": path.resolve(__dirname, "./fill/empty.ts"),
"windows-mutex": path.resolve(__dirname, "./fill/empty.ts"),
"selenium-webdriver": path.resolve(__dirname, "./fill/empty.ts"),
"windows-foreground-love": path.resolve(__dirname, "./fill/empty.ts"),
"vscode-fsevents": path.resolve(__dirname, "./fill/empty.ts"),
"vsda": path.resolve(__dirname, "./fill/empty.ts"),
"vscode": path.resolve(__dirname, "./fill/empty.ts"),
"coder$": path.resolve(__dirname, "./fill/empty.ts"),
"native-keymap": path.join(vscodeFills, "native-keymap.ts"),
"node-pty": path.join(vscodeFills, "node-pty.ts"),
"gc-signals": path.join(nodeFills, "empty.ts"),
"selenium-webdriver": path.join(nodeFills, "empty.ts"),
"vscode": path.join(nodeFills, "empty.ts"),
"vscode-fsevents": path.join(nodeFills, "empty.ts"),
"vsda": path.join(nodeFills, "empty.ts"),
"windows-foreground-love": path.join(nodeFills, "empty.ts"),
"windows-mutex": path.join(nodeFills, "empty.ts"),
"windows-process-tree": path.join(nodeFills, "empty.ts"),
"crypto": "crypto-browserify",
"spdlog": path.resolve(__dirname, "./fill/spdlog.ts"),
"child_process": path.resolve(__dirname, "./fill/child_process.ts"),
"electron": path.resolve(__dirname, "./fill/electron.ts"),
"fs": path.resolve(__dirname, "./fill/fs.ts"),
"http": "http-browserify",
"node-pty": path.resolve(__dirname, "./fill/node-pty.ts"),
"os": "os-browserify",
"net": path.resolve(__dirname, "./fill/net.ts"),
"coder": path.resolve(__dirname, "./src/coder"),
"vs": path.resolve(__dirname, "./src/vs"),
"util": path.resolve(__dirname, "./node_modules/util"),
"@coder": path.resolve(__dirname, "../../"),
"util": path.join(root, "node_modules", "util"),
"child_process": path.join(nodeFills, "child_process.ts"),
"fs": path.join(nodeFills, "fs.ts"),
"net": path.join(nodeFills, "net.ts"),
"electron": path.join(root, "packages", "electron-browser", "src", "electron.ts"),
"@coder": path.join(root, "packages"),
"vs": path.join(root, "lib", "vscode", "src", "vs"),
},
extensions: [".js", ".jsx", ".ts", ".tsx", ".json", ".css"],
mainFiles: [
"index",
"src/index",
],
modules: [
path.resolve(__dirname, "./node_modules"),
"../node_modules",
path.resolve(__dirname, "../../../"),
],
},
resolveLoader: {
alias: {
"vs/css": path.resolve(__dirname, "./fill/css.js"),
"vs/css": path.join(vscodeFills, "css.js"),
},
modules: [
path.resolve(__dirname, "./node_modules"),
path.join(root, "node_modules"),
],
},
devServer: {
contentBase: sourcePath,
compress: true,
host: "0.0.0.0",
hot: true,
historyApiFallback: true,
port: 9966,
inline: true,
disableHostCheck: true,
port: 3000,
stats: {
warnings: false
all: false, // Fallback for options not defined.
errors: true,
warnings: true,
},
},
plugins: [
new HtmlWebpackPlugin({
template: "./index.html",
template: "packages/app/src/index.html",
}),
new HappyPack({
id: "ts",
threads: 2,
loaders: [
{
loaders: [{
path: "ts-loader",
query: {
happyPackMode: true,
},
}
],
}],
}),
// new BundleAnalyzerPlugin(),
new WriteFilePlugin({
@ -174,7 +140,7 @@ module.exports = {
as: "script",
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': `"${environment}"`,
"process.env.NODE_ENV": `"${environment}"`,
}),
new MiniCssExtractPlugin({
filename: "[name].css",
@ -187,8 +153,13 @@ module.exports = {
// }) : undefined,
// new ForkTsCheckerWebpackPlugin({
// checkSyntacticErrors: true,
// tsconfig: path.resolve(__dirname, "./src/tsconfig.json"),
// tsconfig: path.join(root, "./src/tsconfig.json"),
// }),
],
target: "web",
stats: {
all: false, // Fallback for options not defined.
errors: true,
warnings: true,
},
};

View file

@ -1,180 +0,0 @@
const path = require("path");
const sourcePath = "./src";
const entryFile = "./bootstrap-fork.js";
const minify = false;
const HappyPack = require("happypack");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
module.exports = (env) => {
const afterCompileCommand = env && env.afterCompileCommand;
return {
context: path.join(__dirname, sourcePath),
entry: entryFile,
mode: minify ? "production" : "development",
target: "node",
output: {
chunkFilename: "[name].bundle.js",
path: path.resolve(__dirname, "./bin"),
publicPath: "/",
filename: "entry.bundle.js",
// libraryTarget: "amd",
globalObject: "this",
},
module: {
rules: [{
loader: "string-replace-loader",
test: /\.(js|ts)$/,
options: {
multiple: [
{
search: "require\\.toUrl\\(",
replace: "requireToUrl(",
flags: "g",
},
{
search: "require\\.__\\$__nodeRequire",
replace: "require",
flags: "g",
},
],
},
}, {
use: [{
loader: "happypack/loader?id=ts",
}],
test: /(^.?|\.[^d]|[^.]d|[^.][^d])\.tsx?$/,
}, {
test: /\.s?css$/,
use: [{
loader: "style-loader",
}, {
loader: "css-loader",
}],
}, {
test: /\.(svg|png|ttf|woff|eot)$/,
use: ["file-loader"]
}, {
test: /\.wasm$/,
type: "javascript/auto",
}, {
// Ignore a bunch of file types we don't have loaders for. Also ignore
// test directories, some files with invalid JSON, and files we don't
// actually require but throw warnings or errors. This all seems to be a
// case of dynamic loading including things we won't require.
// This also results in the bundle being significantly smaller which
// makes uglify much faster.
test: /(\/vs\/code\/electron-main\/)|(\/test\/)|(OSSREADME\.json$)|(\.(test\.ts|test\.js|d\.ts|qwoff|node|html|txt|exe|wuff|md|sh|scpt|less)$)/,
use: ["ignore-loader"]
}],
},
// node: {
// // electron: "empty",
// // fs: "empty",
// // child_process: "empty",
// module: "empty",
// // net: "empty",
// crypto: "empty",
// tls: "empty",
// },
// externals: [
// function(context, request, callback) {
// process.stderr.write("requiring external " + request + "\n");
// callback();
// },
// ],
resolve: {
alias: {
"gc-signals": path.resolve(__dirname, "./fill/empty.ts"),
"native-keymap": path.resolve(__dirname, "./fill/native-keymap.ts"),
"windows-process-tree": path.resolve(__dirname, "./fill/empty.ts"),
"electron": path.resolve(__dirname, "./fill/electron.ts"),
// "crypto": "crypto-browserify",
// "child_process": path.resolve(__dirname, "./fill/child_process.ts"),
// "fs": path.resolve(__dirname, "./fill/fs.ts"),
// "http": "http-browserify",
// "node-pty": path.resolve(__dirname, "./fill/node-pty.ts"),
// "os": "os-browserify",
// "net": path.resolve(__dirname, "./fill/net.ts"),
// TODO: The real spdlog doesn't work and keeps saying the path argument is undefined.
"spdlog": path.resolve(__dirname, "./fill/spdlog.ts"),
"coder": path.resolve(__dirname, "./src/coder"),
"vs": path.resolve(__dirname, "./src/vs"),
},
extensions: [".js", ".ts", ".json", ".css"],
mainFiles: [
"index",
"src/index",
],
modules: [
"../node_modules",
path.resolve(__dirname, "../../../"),
],
},
resolveLoader: {
alias: {
"vs/css": path.resolve(__dirname, "./fill/css.js"),
},
},
// devServer: {
// contentBase: sourcePath,
// compress: true,
// host: "0.0.0.0",
// hot: true,
// historyApiFallback: true,
// port: 9966,
// inline: true,
// disableHostCheck: true,
// stats: {
// warnings: false
// },
// },
plugins: [
// new HtmlWebpackPlugin({
// template: "./index.html",
// }),
new HappyPack({
id: "ts",
threads: 2,
loaders: [
{
path: "ts-loader",
query: {
happyPackMode: true,
},
}
],
}),
new webpack.ProgressPlugin((percentage, msg) => {
if (percentage === 1) {
if (afterCompileCommand) {
require("child_process").execSync(afterCompileCommand, {
stdio: "inherit"
});
}
}
}),
// new UglifyJsPlugin(),
// new BundleAnalyzerPlugin(),
// new WriteFilePlugin({
// exitOnErrors: false,
// }),
// new PreloadWebpackPlugin({
// rel: "preload",
// as: "script",
// }),
// new ForkTsCheckerWebpackPlugin({
// checkSyntacticErrors: true,
// tsconfig: path.resolve(__dirname, "./src/tsconfig.json"),
// }),
],
stats: {
all: false, // Fallback for options not defined.
errors: true,
warnings: true,
},
};
};

3407
yarn.lock

File diff suppressed because it is too large Load diff