From d44a0a3e590405032a4266bca79a2cd4ae7fcc33 Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 11 Jan 2019 18:11:34 -0600 Subject: [PATCH] FuseBox didn't work out --- .gitignore | 1 - fuse.js | 19 - package.json | 24 +- packages/app/src/index.html | 1 - packages/app/src/index.ts | 5 + packages/disposable/yarn.lock | 4 + packages/electron-browser/src/electron.ts | 638 ++-- packages/ide/yarn.lock | 4 + packages/vscode/package.json | 3 +- packages/vscode/src/entry.ts | 55 - packages/vscode/src/index.ts | 54 + packages/vscode/yarn.lock | 4 + webpack.config.app.js | 195 +- webpack.config.bootstrap.js | 180 -- yarn.lock | 3407 +++++++++++++++++---- 15 files changed, 3257 insertions(+), 1337 deletions(-) delete mode 100644 fuse.js create mode 100644 packages/disposable/yarn.lock create mode 100644 packages/ide/yarn.lock delete mode 100644 packages/vscode/src/entry.ts create mode 100644 packages/vscode/src/index.ts create mode 100644 packages/vscode/yarn.lock delete mode 100644 webpack.config.bootstrap.js diff --git a/.gitignore b/.gitignore index 65b6691..3fc94be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.fusebox lib/vscode node_modules dist diff --git a/fuse.js b/fuse.js deleted file mode 100644 index 45da56d..0000000 --- a/fuse.js +++ /dev/null @@ -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(); diff --git a/package.json b/package.json index 05a51b2..4862531 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/packages/app/src/index.html b/packages/app/src/index.html index be80840..f1e85c4 100644 --- a/packages/app/src/index.html +++ b/packages/app/src/index.html @@ -43,7 +43,6 @@
- $bundles diff --git a/packages/app/src/index.ts b/packages/app/src/index.ts index a9d819e..94e8605 100644 --- a/packages/app/src/index.ts +++ b/packages/app/src/index.ts @@ -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"; diff --git a/packages/disposable/yarn.lock b/packages/disposable/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/packages/disposable/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + diff --git a/packages/electron-browser/src/electron.ts b/packages/electron-browser/src/electron.ts index 27cded6..ef2bcd5 100644 --- a/packages/electron-browser/src/electron.ts +++ b/packages/electron-browser/src/electron.ts @@ -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