Getting the client to run (#12)
* Clean up workbench and integrate initialization data * Uncomment Electron fill * Run server & client together * Clean up Electron fill & patch * Bind fs methods This makes them usable with the promise form: `promisify(access)(...)`. * Add space between tag and title to browser logger * Add typescript dep to server and default __dirname for path * Serve web files from server * Adjust some dev options * Rework workbench a bit to use a class and catch unexpected errors * No mkdirs for now, fix util fill, use bash with exec * More fills, make general client abstract * More fills * Fix cp.exec * Fix require calls in fs fill being aliased * Create data and storage dir * Implement fs.watch Using exec for now. * Implement storage database fill * Fix os export and homedir * Add comment to use navigator.sendBeacon * Fix fs callbacks (some args are optional) * Make sure data directory exists when passing it back * Update patch * Target es5 * More fills * Add APIs required for bootstrap-fork to function (#15) * Add bootstrap-fork execution * Add createConnection * Bundle bootstrap-fork into cli * Remove .node directory created from spdlog * Fix npm start * Remove unnecessary comment * Add webpack-hot-middleware if CLI env is not set * Add restarting to shared process * Fix starting with yarn
This commit is contained in:
@ -1,47 +1,2 @@
|
||||
import { logger, field, time } from "@coder/logger";
|
||||
import { load } from "@coder/vscode";
|
||||
import "./index.scss";
|
||||
|
||||
const loadTime = time(2500);
|
||||
logger.info("Loading IDE");
|
||||
|
||||
const overlay = document.getElementById("overlay");
|
||||
const logo = document.getElementById("logo");
|
||||
const msgElement = overlay
|
||||
? overlay.querySelector(".message") as HTMLElement
|
||||
: undefined;
|
||||
|
||||
if (overlay && logo) {
|
||||
overlay.addEventListener("mousemove", (event) => {
|
||||
const xPos = ((event.clientX - logo.offsetLeft) / 24).toFixed(2);
|
||||
const yPos = ((logo.offsetTop - event.clientY) / 24).toFixed(2);
|
||||
|
||||
logo.style.transform = `perspective(200px) rotateX(${yPos}deg) rotateY(${xPos}deg)`;
|
||||
});
|
||||
}
|
||||
|
||||
load().then(() => {
|
||||
if (overlay) {
|
||||
overlay.style.opacity = "0";
|
||||
overlay.addEventListener("transitionend", () => {
|
||||
overlay.remove();
|
||||
});
|
||||
}
|
||||
}).catch((error: Error) => {
|
||||
logger.error(error.message);
|
||||
if (overlay) {
|
||||
overlay.classList.add("error");
|
||||
}
|
||||
if (msgElement) {
|
||||
const button = document.createElement("div");
|
||||
button.className = "reload-button";
|
||||
button.innerText = "Reload";
|
||||
button.addEventListener("click", () => {
|
||||
location.reload();
|
||||
});
|
||||
msgElement.innerText = `Failed to load: ${error.message}.`;
|
||||
msgElement.parentElement!.appendChild(button);
|
||||
}
|
||||
}).finally(() => {
|
||||
logger.info("Load completed", field("duration", loadTime));
|
||||
});
|
||||
import "@coder/vscode";
|
||||
|
8
packages/web/tsconfig.json
Normal file
8
packages/web/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "esnext"],
|
||||
"importHelpers": true
|
||||
}
|
||||
}
|
103
packages/web/webpack.common.config.js
Normal file
103
packages/web/webpack.common.config.js
Normal file
@ -0,0 +1,103 @@
|
||||
const path = require("path");
|
||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
|
||||
const PreloadWebpackPlugin = require("preload-webpack-plugin");
|
||||
const HappyPack = require("happypack");
|
||||
const root = path.resolve(__dirname, "..", "..");
|
||||
const fills = path.join(root, "packages", "ide", "src", "fill");
|
||||
const vsFills = path.join(root, "packages", "vscode", "src", "fill");
|
||||
|
||||
const merge = require("webpack-merge");
|
||||
|
||||
module.exports = merge({
|
||||
devtool: "source-map",
|
||||
entry: "./packages/web/src/index.ts",
|
||||
output: {
|
||||
chunkFilename: "[name]-[hash:6].bundle.js",
|
||||
path: path.join(root, "dist"),
|
||||
filename: "[hash:6].bundle.js",
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
loader: "string-replace-loader",
|
||||
test: /\.(j|t)s/,
|
||||
options: {
|
||||
multiple: [{
|
||||
search: "require\\.toUrl\\(",
|
||||
replace: "requireToUrl(",
|
||||
flags: "g",
|
||||
}, {
|
||||
search: "require\\.__\\$__nodeRequire",
|
||||
replace: "require",
|
||||
flags: "g",
|
||||
}, {
|
||||
search: "\\.attributes\\[([^\\]]+)\\] = ([^;]+)",
|
||||
replace: ".setAttribute($1, $2)",
|
||||
flags: "g",
|
||||
}],
|
||||
},
|
||||
}],
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"gc-signals": path.join(fills, "empty.ts"),
|
||||
"selenium-webdriver": path.join(fills, "empty.ts"),
|
||||
"vscode": path.join(fills, "empty.ts"),
|
||||
"vscode-fsevents": path.join(fills, "empty.ts"),
|
||||
"vsda": path.join(fills, "empty.ts"),
|
||||
"windows-foreground-love": path.join(fills, "empty.ts"),
|
||||
"windows-mutex": path.join(fills, "empty.ts"),
|
||||
"windows-process-tree": path.join(fills, "empty.ts"),
|
||||
"vscode-sqlite3": path.join(fills, "empty.ts"),
|
||||
"tls": path.join(fills, "empty.ts"),
|
||||
"native-is-elevated": path.join(fills, "empty.ts"),
|
||||
|
||||
"crypto": "crypto-browserify",
|
||||
"http": "http-browserify",
|
||||
|
||||
"child_process": path.join(fills, "child_process.ts"),
|
||||
"os": path.join(fills, "os.ts"),
|
||||
"fs": path.join(fills, "fs.ts"),
|
||||
"net": path.join(fills, "net.ts"),
|
||||
"util": path.join(fills, "util.ts"),
|
||||
"electron": path.join(fills, "electron.ts"),
|
||||
|
||||
"native-keymap": path.join(vsFills, "native-keymap.ts"),
|
||||
"node-pty": path.join(vsFills, "node-pty.ts"),
|
||||
"graceful-fs": path.join(vsFills, "graceful-fs.ts"),
|
||||
"spdlog": path.join(vsFills, "spdlog.ts"),
|
||||
|
||||
"vs/base/node/paths": path.join(vsFills, "paths.ts"),
|
||||
"vs/base/common/amd": path.join(vsFills, "amd.ts"),
|
||||
"vs/platform/node/product": path.join(vsFills, "product.ts"),
|
||||
"vs/platform/node/package": path.join(vsFills, "package.ts"),
|
||||
"vs": path.join(root, "lib", "vscode", "src", "vs"),
|
||||
},
|
||||
},
|
||||
resolveLoader: {
|
||||
alias: {
|
||||
"vs/css": path.join(vsFills, "css.js"),
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: "packages/web/src/index.html",
|
||||
}),
|
||||
new PreloadWebpackPlugin({
|
||||
rel: "preload",
|
||||
as: "script",
|
||||
}),
|
||||
new HappyPack({
|
||||
id: "ts",
|
||||
threads: 2,
|
||||
loaders: [{
|
||||
path: "ts-loader",
|
||||
query: {
|
||||
happyPackMode: true,
|
||||
configFile: path.join(__dirname, "tsconfig.json"),
|
||||
},
|
||||
}],
|
||||
}),
|
||||
],
|
||||
target: "web",
|
||||
}, require(path.join(root, "scripts", "webpack.general.config.js"))());
|
13
packages/web/webpack.dev.config.js
Normal file
13
packages/web/webpack.dev.config.js
Normal file
@ -0,0 +1,13 @@
|
||||
const webpack = require("webpack");
|
||||
const merge = require("webpack-merge");
|
||||
|
||||
module.exports = merge(require("./webpack.common.config.js"), {
|
||||
devtool: "cheap-module-eval-source-map",
|
||||
entry: [
|
||||
"webpack-hot-middleware/client?reload=true&quiet=true",
|
||||
"./packages/web/src/index.ts"
|
||||
],
|
||||
plugins: [
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
]
|
||||
});
|
Reference in New Issue
Block a user