mirror of https://github.com/coder/code-server.git
FuseBox didn't work out
This commit is contained in:
parent
0c3ffb301a
commit
d44a0a3e59
|
@ -1,4 +1,3 @@
|
||||||
.fusebox
|
|
||||||
lib/vscode
|
lib/vscode
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
|
19
fuse.js
19
fuse.js
|
@ -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();
|
|
24
package.json
24
package.json
|
@ -10,14 +10,32 @@
|
||||||
"vscode": "npm-run-all vscode:*",
|
"vscode": "npm-run-all vscode:*",
|
||||||
"packages:install": "cd ./packages && yarn",
|
"packages:install": "cd ./packages && yarn",
|
||||||
"postinstall": "npm-run-all --parallel vscode packages:install",
|
"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"
|
"test": "cd ./packages && yarn test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^10.12.18",
|
"@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",
|
"node-sass": "^4.11.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
<div class="message">
|
<div class="message">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
$bundles
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
import { logger } from "@coder/logger";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
|
|
||||||
|
logger.info("Starting app");
|
||||||
|
|
||||||
const overlay = document.getElementById("overlay");
|
const overlay = document.getElementById("overlay");
|
||||||
const logo = document.getElementById("logo");
|
const logo = document.getElementById("logo");
|
||||||
if (overlay && logo) {
|
if (overlay && logo) {
|
||||||
|
@ -10,3 +13,5 @@ if (overlay && logo) {
|
||||||
logo.style.transform = `perspective(200px) rotateX(${yPos}deg) rotateY(${xPos}deg)`;
|
logo.style.transform = `perspective(200px) rotateX(${yPos}deg) rotateY(${xPos}deg)`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import "@coder/vscode";
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
|
@ -1,352 +1,352 @@
|
||||||
import * as electron from "electron";
|
// import * as electron from "electron";
|
||||||
import { EventEmitter } from "events";
|
// import { EventEmitter } from "events";
|
||||||
import * as fs from "fs";
|
// import * as fs from "fs";
|
||||||
import { getFetchUrl } from "../src/coder/api";
|
// import { getFetchUrl } from "../src/coder/api";
|
||||||
import { escapePath } from "../src/coder/common";
|
// import { escapePath } from "../src/coder/common";
|
||||||
import { wush } from "../src/coder/server";
|
// import { wush } from "../src/coder/server";
|
||||||
import { IKey, Dialog } from "./dialog";
|
// import { IKey, Dialog } from "./dialog";
|
||||||
|
|
||||||
(global as any).getOpenUrls = () => {
|
// (global as any).getOpenUrls = () => {
|
||||||
return [];
|
// return [];
|
||||||
};
|
// };
|
||||||
|
|
||||||
const oldCreateElement = document.createElement;
|
// const oldCreateElement = document.createElement;
|
||||||
|
|
||||||
document.createElement = (tagName: string) => {
|
// document.createElement = (tagName: string) => {
|
||||||
const createElement = (tagName: string) => {
|
// const createElement = (tagName: string) => {
|
||||||
return oldCreateElement.call(document, tagName);
|
// return oldCreateElement.call(document, tagName);
|
||||||
};
|
// };
|
||||||
|
|
||||||
if (tagName === "webview") {
|
// if (tagName === "webview") {
|
||||||
const view = createElement("iframe") as HTMLIFrameElement;
|
// const view = createElement("iframe") as HTMLIFrameElement;
|
||||||
view.style.border = "0px";
|
// view.style.border = "0px";
|
||||||
const frameID = Math.random().toString();
|
// const frameID = Math.random().toString();
|
||||||
view.addEventListener("error", (event) => {
|
// view.addEventListener("error", (event) => {
|
||||||
console.log("Got iframe error", event.error, event.message);
|
// console.log("Got iframe error", event.error, event.message);
|
||||||
});
|
// });
|
||||||
window.addEventListener("message", (event) => {
|
// window.addEventListener("message", (event) => {
|
||||||
if (!event.data || !event.data.id) {
|
// if (!event.data || !event.data.id) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (event.data.id !== frameID) {
|
// if (event.data.id !== frameID) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
const e = new CustomEvent("ipc-message");
|
// const e = new CustomEvent("ipc-message");
|
||||||
(e as any).channel = event.data.channel;
|
// (e as any).channel = event.data.channel;
|
||||||
(e as any).args = event.data.data;
|
// (e as any).args = event.data.data;
|
||||||
view.dispatchEvent(e);
|
// view.dispatchEvent(e);
|
||||||
});
|
// });
|
||||||
view.sandbox.add("allow-same-origin", "allow-scripts", "allow-popups", "allow-forms");
|
// view.sandbox.add("allow-same-origin", "allow-scripts", "allow-popups", "allow-forms");
|
||||||
Object.defineProperty(view, "preload", {
|
// Object.defineProperty(view, "preload", {
|
||||||
set: (url: string) => {
|
// set: (url: string) => {
|
||||||
view.onload = () => {
|
// view.onload = () => {
|
||||||
view.contentDocument.body.id = frameID;
|
// view.contentDocument.body.id = frameID;
|
||||||
view.contentDocument.body.parentElement.style.overflow = "hidden";
|
// view.contentDocument.body.parentElement.style.overflow = "hidden";
|
||||||
const script = document.createElement("script");
|
// const script = document.createElement("script");
|
||||||
script.src = url;
|
// script.src = url;
|
||||||
view.contentDocument.head.appendChild(script);
|
// view.contentDocument.head.appendChild(script);
|
||||||
};
|
// };
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
(view as any).getWebContents = () => undefined;
|
// (view as any).getWebContents = () => undefined;
|
||||||
(view as any).send = (channel: string, ...args) => {
|
// (view as any).send = (channel: string, ...args) => {
|
||||||
if (args[0] && typeof args[0] === "object" && args[0].contents) {
|
// 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(/"(file:\/\/[^"]*)"/g, (m) => `"${getFetchUrl(m)}"`);
|
||||||
args[0].contents = (args[0].contents as string).replace(/"vscode-resource:([^"]*)"/g, (m) => `"${getFetchUrl(m)}"`);
|
// args[0].contents = (args[0].contents as string).replace(/"vscode-resource:([^"]*)"/g, (m) => `"${getFetchUrl(m)}"`);
|
||||||
}
|
// }
|
||||||
view.contentWindow.postMessage({
|
// view.contentWindow.postMessage({
|
||||||
channel,
|
// channel,
|
||||||
data: args,
|
// data: args,
|
||||||
id: frameID,
|
// id: frameID,
|
||||||
}, "*");
|
// }, "*");
|
||||||
};
|
// };
|
||||||
return view;
|
// return view;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return createElement(tagName);
|
// return createElement(tagName);
|
||||||
};
|
// };
|
||||||
|
|
||||||
const rendererToMainEmitter = new EventEmitter();
|
// const rendererToMainEmitter = new EventEmitter();
|
||||||
const mainToRendererEmitter = new EventEmitter();
|
// const mainToRendererEmitter = new EventEmitter();
|
||||||
|
|
||||||
module.exports = {
|
// module.exports = {
|
||||||
clipboard: {
|
// clipboard: {
|
||||||
has: () => {
|
// has: () => {
|
||||||
return false;
|
// return false;
|
||||||
},
|
// },
|
||||||
writeText: (value: string) => {
|
// writeText: (value: string) => {
|
||||||
// Taken from https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
|
// // Taken from https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
|
||||||
const active = document.activeElement as HTMLElement;
|
// const active = document.activeElement as HTMLElement;
|
||||||
const el = document.createElement('textarea'); // Create a <textarea> element
|
// const el = document.createElement('textarea'); // Create a <textarea> element
|
||||||
el.value = value; // Set its value to the string that you want copied
|
// el.value = value; // Set its value to the string that you want copied
|
||||||
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
|
// el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
|
||||||
el.style.position = 'absolute';
|
// el.style.position = 'absolute';
|
||||||
el.style.left = '-9999px'; // Move outside the screen to make it invisible
|
// el.style.left = '-9999px'; // Move outside the screen to make it invisible
|
||||||
document.body.appendChild(el); // Append the <textarea> element to the HTML document
|
// document.body.appendChild(el); // Append the <textarea> element to the HTML document
|
||||||
const selected =
|
// const selected =
|
||||||
document.getSelection().rangeCount > 0 // Check if there is any content selected previously
|
// document.getSelection().rangeCount > 0 // Check if there is any content selected previously
|
||||||
? document.getSelection().getRangeAt(0) // Store selection if found
|
// ? document.getSelection().getRangeAt(0) // Store selection if found
|
||||||
: false; // Mark as false to know no selection existed before
|
// : false; // Mark as false to know no selection existed before
|
||||||
el.select(); // Select the <textarea> content
|
// el.select(); // Select the <textarea> content
|
||||||
document.execCommand('copy'); // Copy - only works as a result of a user action (e.g. click events)
|
// 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
|
// document.body.removeChild(el); // Remove the <textarea> element
|
||||||
if (selected) { // If a selection existed before copying
|
// if (selected) { // If a selection existed before copying
|
||||||
document.getSelection().removeAllRanges(); // Unselect everything on the HTML document
|
// document.getSelection().removeAllRanges(); // Unselect everything on the HTML document
|
||||||
document.getSelection().addRange(selected); // Restore the original selection
|
// document.getSelection().addRange(selected); // Restore the original selection
|
||||||
}
|
// }
|
||||||
active.focus();
|
// active.focus();
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
dialog: {
|
// dialog: {
|
||||||
showSaveDialog: (_: void, options: Electron.SaveDialogOptions, callback: (filename: string) => void): void => {
|
// showSaveDialog: (_: void, options: Electron.SaveDialogOptions, callback: (filename: string) => void): void => {
|
||||||
const defaultPath = options.defaultPath || "/untitled";
|
// const defaultPath = options.defaultPath || "/untitled";
|
||||||
const fileIndex = defaultPath.lastIndexOf("/");
|
// const fileIndex = defaultPath.lastIndexOf("/");
|
||||||
const extensionIndex = defaultPath.lastIndexOf(".");
|
// const extensionIndex = defaultPath.lastIndexOf(".");
|
||||||
const saveDialogOptions = {
|
// const saveDialogOptions = {
|
||||||
buttons: ["Cancel", "Save"],
|
// buttons: ["Cancel", "Save"],
|
||||||
detail: "Enter a path for this file",
|
// detail: "Enter a path for this file",
|
||||||
input: {
|
// input: {
|
||||||
value: defaultPath,
|
// value: defaultPath,
|
||||||
selection: {
|
// selection: {
|
||||||
start: fileIndex === -1 ? 0 : fileIndex + 1,
|
// start: fileIndex === -1 ? 0 : fileIndex + 1,
|
||||||
end: extensionIndex === -1 ? defaultPath.length : extensionIndex,
|
// end: extensionIndex === -1 ? defaultPath.length : extensionIndex,
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
message: "Save file",
|
// message: "Save file",
|
||||||
};
|
// };
|
||||||
|
|
||||||
const dialog = new Dialog(saveDialogOptions);
|
// const dialog = new Dialog(saveDialogOptions);
|
||||||
dialog.onAction((action) => {
|
// dialog.onAction((action) => {
|
||||||
if (action.key !== IKey.Enter && action.buttonIndex !== 1) {
|
// if (action.key !== IKey.Enter && action.buttonIndex !== 1) {
|
||||||
dialog.hide();
|
// dialog.hide();
|
||||||
return callback(undefined);
|
// return callback(undefined);
|
||||||
}
|
// }
|
||||||
|
|
||||||
const filePath = dialog.inputValue.replace(/\/+$/, "");
|
// const filePath = dialog.inputValue.replace(/\/+$/, "");
|
||||||
const split = filePath.split("/");
|
// const split = filePath.split("/");
|
||||||
const fileName = split.pop();
|
// const fileName = split.pop();
|
||||||
const parentName = split.pop() || "/";
|
// const parentName = split.pop() || "/";
|
||||||
if (fileName === "") {
|
// if (fileName === "") {
|
||||||
dialog.error = "You must enter a file name.";
|
// dialog.error = "You must enter a file name.";
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
fs.stat(filePath, (error, stats) => {
|
// fs.stat(filePath, (error, stats) => {
|
||||||
if (error && error.code === "ENOENT") {
|
// if (error && error.code === "ENOENT") {
|
||||||
dialog.hide();
|
// dialog.hide();
|
||||||
callback(filePath);
|
// callback(filePath);
|
||||||
} else if (error) {
|
// } else if (error) {
|
||||||
dialog.error = error.message;
|
// dialog.error = error.message;
|
||||||
} else if (stats.isDirectory()) {
|
// } else if (stats.isDirectory()) {
|
||||||
dialog.error = `A directory named "${fileName}" already exists.`;
|
// dialog.error = `A directory named "${fileName}" already exists.`;
|
||||||
} else {
|
// } else {
|
||||||
dialog.error = undefined;
|
// dialog.error = undefined;
|
||||||
|
|
||||||
const confirmDialog = new Dialog({
|
// const confirmDialog = new Dialog({
|
||||||
message: `A file named "${fileName}" already exists. Do you want to replace it?`,
|
// 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.`,
|
// detail: `The file already exists in "${parentName}". Replacing it will overwrite its contents.`,
|
||||||
buttons: ["Cancel", "Replace"],
|
// buttons: ["Cancel", "Replace"],
|
||||||
});
|
// });
|
||||||
|
|
||||||
confirmDialog.onAction((action) => {
|
// confirmDialog.onAction((action) => {
|
||||||
if (action.buttonIndex === 1) {
|
// if (action.buttonIndex === 1) {
|
||||||
confirmDialog.hide();
|
// confirmDialog.hide();
|
||||||
return callback(filePath);
|
// return callback(filePath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
confirmDialog.hide();
|
// confirmDialog.hide();
|
||||||
dialog.show();
|
// dialog.show();
|
||||||
});
|
// });
|
||||||
|
|
||||||
dialog.hide();
|
// dialog.hide();
|
||||||
confirmDialog.show();
|
// confirmDialog.show();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
dialog.show();
|
// dialog.show();
|
||||||
},
|
// },
|
||||||
showOpenDialog: () => {
|
// showOpenDialog: () => {
|
||||||
console.log("Trying to show the open dialog");
|
// console.log("Trying to show the open dialog");
|
||||||
},
|
// },
|
||||||
showMessageBox: (_: void, options: Electron.MessageBoxOptions, callback: (button: number, checked: boolean) => void): void => {
|
// showMessageBox: (_: void, options: Electron.MessageBoxOptions, callback: (button: number, checked: boolean) => void): void => {
|
||||||
const dialog = new Dialog(options);
|
// const dialog = new Dialog(options);
|
||||||
dialog.onAction((action) => {
|
// dialog.onAction((action) => {
|
||||||
dialog.hide();
|
// dialog.hide();
|
||||||
callback(action.buttonIndex, false);
|
// callback(action.buttonIndex, false);
|
||||||
});
|
// });
|
||||||
dialog.show();
|
// dialog.show();
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
remote: {
|
// remote: {
|
||||||
dialog: {
|
// dialog: {
|
||||||
showOpenDialog: () => {
|
// showOpenDialog: () => {
|
||||||
console.log("Trying to remotely open");
|
// console.log("Trying to remotely open");
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
webFrame: {
|
// webFrame: {
|
||||||
getZoomFactor: () => {
|
// getZoomFactor: () => {
|
||||||
return 1;
|
// return 1;
|
||||||
},
|
// },
|
||||||
getZoomLevel: () => {
|
// getZoomLevel: () => {
|
||||||
return 1;
|
// return 1;
|
||||||
},
|
// },
|
||||||
setZoomLevel: () => {
|
// setZoomLevel: () => {
|
||||||
return;
|
// return;
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
screen: {
|
// screen: {
|
||||||
getAllDisplays: () => {
|
// getAllDisplays: () => {
|
||||||
return [{
|
// return [{
|
||||||
bounds: {
|
// bounds: {
|
||||||
x: 1000,
|
// x: 1000,
|
||||||
y: 1000,
|
// y: 1000,
|
||||||
},
|
// },
|
||||||
}];
|
// }];
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
app: {
|
// app: {
|
||||||
isAccessibilitySupportEnabled: () => {
|
// isAccessibilitySupportEnabled: () => {
|
||||||
return false;
|
// return false;
|
||||||
},
|
// },
|
||||||
setAsDefaultProtocolClient: () => {
|
// setAsDefaultProtocolClient: () => {
|
||||||
|
|
||||||
},
|
// },
|
||||||
send: (str) => {
|
// send: (str) => {
|
||||||
console.log("APP Trying to send", str);
|
// console.log("APP Trying to send", str);
|
||||||
//
|
// //
|
||||||
},
|
// },
|
||||||
on: () => {
|
// on: () => {
|
||||||
//
|
// //
|
||||||
},
|
// },
|
||||||
once: () => {
|
// once: () => {
|
||||||
//
|
// //
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
// ipcRenderer communicates with ipcMain
|
// // ipcRenderer communicates with ipcMain
|
||||||
ipcRenderer: {
|
// ipcRenderer: {
|
||||||
send: (str, ...args) => {
|
// send: (str, ...args) => {
|
||||||
rendererToMainEmitter.emit(str, {
|
// rendererToMainEmitter.emit(str, {
|
||||||
sender: module.exports.ipcMain,
|
// sender: module.exports.ipcMain,
|
||||||
}, ...args);
|
// }, ...args);
|
||||||
},
|
// },
|
||||||
on: (str, listener) => {
|
// on: (str, listener) => {
|
||||||
mainToRendererEmitter.on(str, listener);
|
// mainToRendererEmitter.on(str, listener);
|
||||||
},
|
// },
|
||||||
once: (str, listener) => {
|
// once: (str, listener) => {
|
||||||
mainToRendererEmitter.once(str, listener);
|
// mainToRendererEmitter.once(str, listener);
|
||||||
},
|
// },
|
||||||
removeListener: (str, listener) => {
|
// removeListener: (str, listener) => {
|
||||||
mainToRendererEmitter.removeListener(str, listener);
|
// mainToRendererEmitter.removeListener(str, listener);
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
ipcMain: {
|
// ipcMain: {
|
||||||
send: (str, ...args) => {
|
// send: (str, ...args) => {
|
||||||
mainToRendererEmitter.emit(str, {
|
// mainToRendererEmitter.emit(str, {
|
||||||
sender: module.exports.ipcRenderer,
|
// sender: module.exports.ipcRenderer,
|
||||||
}, ...args);
|
// }, ...args);
|
||||||
},
|
// },
|
||||||
on: (str, listener) => {
|
// on: (str, listener) => {
|
||||||
rendererToMainEmitter.on(str, listener);
|
// rendererToMainEmitter.on(str, listener);
|
||||||
},
|
// },
|
||||||
once: (str, listener) => {
|
// once: (str, listener) => {
|
||||||
rendererToMainEmitter.once(str, listener);
|
// rendererToMainEmitter.once(str, listener);
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
shell: {
|
// shell: {
|
||||||
moveItemToTrash: async (path) => {
|
// moveItemToTrash: async (path) => {
|
||||||
const response = await wush.execute({
|
// const response = await wush.execute({
|
||||||
command: `trash-put --trash-dir ${escapePath("~/.Trash")} ${escapePath(path)}`,
|
// command: `trash-put --trash-dir ${escapePath("~/.Trash")} ${escapePath(path)}`,
|
||||||
}).done();
|
// }).done();
|
||||||
return response.wasSuccessful();
|
// return response.wasSuccessful();
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
BrowserWindow: class {
|
// BrowserWindow: class {
|
||||||
|
|
||||||
public webContents = {
|
// public webContents = {
|
||||||
on: () => {
|
// on: () => {
|
||||||
|
|
||||||
},
|
// },
|
||||||
session: {
|
// session: {
|
||||||
webRequest: {
|
// webRequest: {
|
||||||
onBeforeRequest: () => {
|
// onBeforeRequest: () => {
|
||||||
|
|
||||||
},
|
// },
|
||||||
|
|
||||||
onBeforeSendHeaders: () => {
|
// onBeforeSendHeaders: () => {
|
||||||
|
|
||||||
},
|
// },
|
||||||
|
|
||||||
onHeadersReceived: () => {
|
// onHeadersReceived: () => {
|
||||||
|
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
removeAllListeners: () => {
|
// removeAllListeners: () => {
|
||||||
|
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static getFocusedWindow() {
|
// public static getFocusedWindow() {
|
||||||
return undefined;
|
// return undefined;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public isMaximized() {
|
// public isMaximized() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public isFullScreen() {
|
// public isFullScreen() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public setMenuBarVisibility(visibility) {
|
// public setMenuBarVisibility(visibility) {
|
||||||
console.log("We are setting the menu bar to ", visibility);
|
// console.log("We are setting the menu bar to ", visibility);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public setAutoHideMenuBar() {
|
// public setAutoHideMenuBar() {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public on() {
|
// public on() {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public setTitle(value: string): void {
|
// public setTitle(value: string): void {
|
||||||
document.title = value;
|
// document.title = value;
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
toggleFullScreen: () => {
|
// toggleFullScreen: () => {
|
||||||
const doc = document as any;
|
// const doc = document as any;
|
||||||
const isInFullScreen = doc.fullscreenElement
|
// const isInFullScreen = doc.fullscreenElement
|
||||||
|| doc.webkitFullscreenElement
|
// || doc.webkitFullscreenElement
|
||||||
|| doc.mozFullScreenElement
|
// || doc.mozFullScreenElement
|
||||||
|| doc.msFullscreenElement;
|
// || doc.msFullscreenElement;
|
||||||
|
|
||||||
const body = doc.body;
|
// const body = doc.body;
|
||||||
if (!isInFullScreen) {
|
// if (!isInFullScreen) {
|
||||||
if (body.requestFullscreen) {
|
// if (body.requestFullscreen) {
|
||||||
body.requestFullscreen();
|
// body.requestFullscreen();
|
||||||
} else if (body.mozRequestFullScreen) {
|
// } else if (body.mozRequestFullScreen) {
|
||||||
body.mozRequestFullScreen();
|
// body.mozRequestFullScreen();
|
||||||
} else if (body.webkitRequestFullScreen) {
|
// } else if (body.webkitRequestFullScreen) {
|
||||||
body.webkitRequestFullScreen();
|
// body.webkitRequestFullScreen();
|
||||||
} else if (body.msRequestFullscreen) {
|
// } else if (body.msRequestFullscreen) {
|
||||||
body.msRequestFullscreen();
|
// body.msRequestFullscreen();
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (doc.exitFullscreen) {
|
// if (doc.exitFullscreen) {
|
||||||
doc.exitFullscreen();
|
// doc.exitFullscreen();
|
||||||
} else if (doc.webkitExitFullscreen) {
|
// } else if (doc.webkitExitFullscreen) {
|
||||||
doc.webkitExitFullscreen();
|
// doc.webkitExitFullscreen();
|
||||||
} else if (doc.mozCancelFullScreen) {
|
// } else if (doc.mozCancelFullScreen) {
|
||||||
doc.mozCancelFullScreen();
|
// doc.mozCancelFullScreen();
|
||||||
} else if (doc.msExitFullscreen) {
|
// } else if (doc.msExitFullscreen) {
|
||||||
doc.msExitFullscreen();
|
// doc.msExitFullscreen();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
focusWindow: () => {
|
// focusWindow: () => {
|
||||||
console.log("focusing window");
|
// console.log("focusing window");
|
||||||
window.focus();
|
// window.focus();
|
||||||
},
|
// },
|
||||||
};
|
// };
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "@coder/vscode",
|
"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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
|
||||||
});
|
|
|
@ -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);
|
||||||
|
// });
|
|
@ -0,0 +1,4 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
const path = require("path");
|
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 environment = process.env.NODE_ENV || "development";
|
||||||
|
const isCi = typeof process.env.CI !== "undefined";
|
||||||
const minify = isCi;
|
const minify = isCi;
|
||||||
const compatibility = isCi;
|
const compatibility = isCi;
|
||||||
|
|
||||||
const HappyPack = require("happypack");
|
const HappyPack = require("happypack");
|
||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
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 PreloadWebpackPlugin = require("preload-webpack-plugin");
|
||||||
const MiniCssExtractPlugin = require("mini-css-extract-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 = {
|
module.exports = {
|
||||||
context: path.join(__dirname, sourcePath),
|
context: root,
|
||||||
devtool: "eval", // "cheap-module-eval-source-map",
|
devtool: "eval",
|
||||||
entry: entryFile,
|
entry: "./packages/app/src/index.ts",
|
||||||
mode: isCi ? "production" : "development",
|
mode: isCi ? "production" : "development",
|
||||||
output: {
|
output: {
|
||||||
chunkFilename: "[name]-[hash:6].bundle.js",
|
chunkFilename: "[name]-[hash:6].bundle.js",
|
||||||
path: path.resolve(__dirname, "./dist"),
|
path: path.join(root, "dist"),
|
||||||
publicPath: process.env.BUILD_ID ? `/${process.env.BUILD_ID}/ide/` : "/ide/",
|
|
||||||
filename: "[hash:6].bundle.js",
|
filename: "[hash:6].bundle.js",
|
||||||
globalObject: "this",
|
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [{
|
||||||
{
|
|
||||||
loader: "string-replace-loader",
|
|
||||||
test: /\.(js|ts)/,
|
|
||||||
options: {
|
|
||||||
multiple: [
|
|
||||||
{
|
|
||||||
search: "require\\.toUrl\\(",
|
|
||||||
replace: "requireToUrl(",
|
|
||||||
flags: "g",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
search: "require\\.__\\$__nodeRequire",
|
|
||||||
replace: "require",
|
|
||||||
flags: "g",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(js)/,
|
test: /\.(js)/,
|
||||||
exclude: /test/,
|
exclude: /test/,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
test: /\.(node|txt|d\.ts|test.ts|perf.data.js|jxs)/,
|
test: /\.(node|txt|d\.ts|test.ts|perf.data.js|jxs)/,
|
||||||
|
use: [{
|
||||||
loader: "ignore-loader",
|
loader: "ignore-loader",
|
||||||
},
|
}],
|
||||||
{
|
}, {
|
||||||
use: [{
|
use: [{
|
||||||
loader: "happypack/loader?id=ts",
|
loader: "happypack/loader?id=ts",
|
||||||
}],
|
}],
|
||||||
|
@ -64,106 +46,90 @@ module.exports = {
|
||||||
}, {
|
}, {
|
||||||
exclude: /test/,
|
exclude: /test/,
|
||||||
test: /\.s?css$/,
|
test: /\.s?css$/,
|
||||||
// This is required otherwise it'll fail to resolve
|
// This is required otherwise it'll fail to resolve CSS in common.
|
||||||
// CSS in common
|
include: root,
|
||||||
include: __dirname,
|
use: [{
|
||||||
use: [true ? {
|
|
||||||
loader: MiniCssExtractPlugin.loader,
|
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)$/,
|
test: /\.(svg|png|ttf|woff|eot)$/,
|
||||||
use: ["file-loader"]
|
use: [{
|
||||||
|
loader: "file-loader",
|
||||||
|
}],
|
||||||
}, {
|
}, {
|
||||||
test: /\.wasm$/,
|
test: /\.wasm$/,
|
||||||
type: "javascript/auto",
|
type: "javascript/auto",
|
||||||
}
|
}],
|
||||||
],
|
noParse: /\.test\.(j|t)sx?/,
|
||||||
noParse: /(\.test\.tsx?)|(\.test\.jsx?)/,
|
|
||||||
},
|
|
||||||
node: {
|
|
||||||
// electron: "empty",
|
|
||||||
// fs: "empty",
|
|
||||||
// child_process: "empty",
|
|
||||||
|
|
||||||
module: "empty",
|
|
||||||
// net: "empty",
|
|
||||||
crypto: "empty",
|
|
||||||
tls: "empty",
|
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"gc-signals": path.resolve(__dirname, "./fill/empty.ts"),
|
"native-keymap": path.join(vscodeFills, "native-keymap.ts"),
|
||||||
"native-keymap": path.resolve(__dirname, "./fill/native-keymap.ts"),
|
"node-pty": path.join(vscodeFills, "node-pty.ts"),
|
||||||
"windows-process-tree": path.resolve(__dirname, "./fill/empty.ts"),
|
|
||||||
"windows-mutex": path.resolve(__dirname, "./fill/empty.ts"),
|
"gc-signals": path.join(nodeFills, "empty.ts"),
|
||||||
"selenium-webdriver": path.resolve(__dirname, "./fill/empty.ts"),
|
"selenium-webdriver": path.join(nodeFills, "empty.ts"),
|
||||||
"windows-foreground-love": path.resolve(__dirname, "./fill/empty.ts"),
|
"vscode": path.join(nodeFills, "empty.ts"),
|
||||||
"vscode-fsevents": path.resolve(__dirname, "./fill/empty.ts"),
|
"vscode-fsevents": path.join(nodeFills, "empty.ts"),
|
||||||
"vsda": path.resolve(__dirname, "./fill/empty.ts"),
|
"vsda": path.join(nodeFills, "empty.ts"),
|
||||||
"vscode": path.resolve(__dirname, "./fill/empty.ts"),
|
"windows-foreground-love": path.join(nodeFills, "empty.ts"),
|
||||||
"coder$": path.resolve(__dirname, "./fill/empty.ts"),
|
"windows-mutex": path.join(nodeFills, "empty.ts"),
|
||||||
|
"windows-process-tree": path.join(nodeFills, "empty.ts"),
|
||||||
|
|
||||||
"crypto": "crypto-browserify",
|
"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",
|
"http": "http-browserify",
|
||||||
"node-pty": path.resolve(__dirname, "./fill/node-pty.ts"),
|
|
||||||
"os": "os-browserify",
|
"os": "os-browserify",
|
||||||
"net": path.resolve(__dirname, "./fill/net.ts"),
|
"util": path.join(root, "node_modules", "util"),
|
||||||
"coder": path.resolve(__dirname, "./src/coder"),
|
|
||||||
"vs": path.resolve(__dirname, "./src/vs"),
|
"child_process": path.join(nodeFills, "child_process.ts"),
|
||||||
"util": path.resolve(__dirname, "./node_modules/util"),
|
"fs": path.join(nodeFills, "fs.ts"),
|
||||||
"@coder": path.resolve(__dirname, "../../"),
|
"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"],
|
extensions: [".js", ".jsx", ".ts", ".tsx", ".json", ".css"],
|
||||||
mainFiles: [
|
mainFiles: [
|
||||||
"index",
|
"index",
|
||||||
"src/index",
|
"src/index",
|
||||||
],
|
],
|
||||||
modules: [
|
|
||||||
path.resolve(__dirname, "./node_modules"),
|
|
||||||
"../node_modules",
|
|
||||||
path.resolve(__dirname, "../../../"),
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
resolveLoader: {
|
resolveLoader: {
|
||||||
alias: {
|
alias: {
|
||||||
"vs/css": path.resolve(__dirname, "./fill/css.js"),
|
"vs/css": path.join(vscodeFills, "css.js"),
|
||||||
},
|
},
|
||||||
modules: [
|
modules: [
|
||||||
path.resolve(__dirname, "./node_modules"),
|
path.join(root, "node_modules"),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: sourcePath,
|
|
||||||
compress: true,
|
|
||||||
host: "0.0.0.0",
|
|
||||||
hot: true,
|
hot: true,
|
||||||
historyApiFallback: true,
|
port: 3000,
|
||||||
port: 9966,
|
|
||||||
inline: true,
|
|
||||||
disableHostCheck: true,
|
|
||||||
stats: {
|
stats: {
|
||||||
warnings: false
|
all: false, // Fallback for options not defined.
|
||||||
|
errors: true,
|
||||||
|
warnings: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: "./index.html",
|
template: "packages/app/src/index.html",
|
||||||
}),
|
}),
|
||||||
new HappyPack({
|
new HappyPack({
|
||||||
id: "ts",
|
id: "ts",
|
||||||
threads: 2,
|
threads: 2,
|
||||||
loaders: [
|
loaders: [{
|
||||||
{
|
|
||||||
path: "ts-loader",
|
path: "ts-loader",
|
||||||
query: {
|
query: {
|
||||||
happyPackMode: true,
|
happyPackMode: true,
|
||||||
},
|
},
|
||||||
}
|
}],
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
// new BundleAnalyzerPlugin(),
|
// new BundleAnalyzerPlugin(),
|
||||||
new WriteFilePlugin({
|
new WriteFilePlugin({
|
||||||
|
@ -174,7 +140,7 @@ module.exports = {
|
||||||
as: "script",
|
as: "script",
|
||||||
}),
|
}),
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env.NODE_ENV': `"${environment}"`,
|
"process.env.NODE_ENV": `"${environment}"`,
|
||||||
}),
|
}),
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
filename: "[name].css",
|
filename: "[name].css",
|
||||||
|
@ -187,8 +153,13 @@ module.exports = {
|
||||||
// }) : undefined,
|
// }) : undefined,
|
||||||
// new ForkTsCheckerWebpackPlugin({
|
// new ForkTsCheckerWebpackPlugin({
|
||||||
// checkSyntacticErrors: true,
|
// checkSyntacticErrors: true,
|
||||||
// tsconfig: path.resolve(__dirname, "./src/tsconfig.json"),
|
// tsconfig: path.join(root, "./src/tsconfig.json"),
|
||||||
// }),
|
// }),
|
||||||
],
|
],
|
||||||
target: "web",
|
target: "web",
|
||||||
|
stats: {
|
||||||
|
all: false, // Fallback for options not defined.
|
||||||
|
errors: true,
|
||||||
|
warnings: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -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,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
Loading…
Reference in New Issue