From a33482b7a01419deb865ea123fbabb780faf87c1 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 09:02:28 -0800 Subject: [PATCH 01/23] Add chunk filename --- browser/webpack.debug.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/browser/webpack.debug.config.js b/browser/webpack.debug.config.js index e24c304259..dd990b57ae 100644 --- a/browser/webpack.debug.config.js +++ b/browser/webpack.debug.config.js @@ -51,7 +51,8 @@ module.exports = { output: { path: path.join(__dirname, "..", "lib", "browser"), publicPath: "/", - filename: "bundle.js" + filename: "bundle.js", + chunkFilename: "[name].bundle.js" }, node: { process: false, From 4322aa4cb0b0aae8865a505a775ffcae15db0513 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 09:44:29 -0800 Subject: [PATCH 02/23] Refactor CSS to asynchronous bundle --- browser/src/CSS.ts | 24 +++++++++++++++++++ .../ContextMenu/ContextMenuComponent.tsx | 2 -- browser/src/Services/Menu/MenuComponent.tsx | 5 ---- browser/src/Services/Sidebar/SidebarView.tsx | 2 -- browser/src/UI/components/Cursor.tsx | 2 -- browser/src/UI/components/Definition.tsx | 2 -- browser/src/UI/components/Error.tsx | 2 -- browser/src/UI/components/InstallHelp.tsx | 2 -- browser/src/UI/components/Message.tsx | 5 ---- browser/src/UI/components/QuickInfo.tsx | 2 -- browser/src/UI/components/StatusBar.tsx | 2 -- browser/src/UI/components/Tabs.tsx | 2 -- browser/src/index.tsx | 17 ++++++------- browser/src/neovim/NeovimInstance.ts | 6 +++++ browser/tsconfig.json | 2 +- browser/webpack.debug.config.js | 2 +- 16 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 browser/src/CSS.ts diff --git a/browser/src/CSS.ts b/browser/src/CSS.ts new file mode 100644 index 0000000000..ce364a5045 --- /dev/null +++ b/browser/src/CSS.ts @@ -0,0 +1,24 @@ +/** + * CSS.ts + * + * Entry point for loading all of Oni's CSS + */ + +export const activate = () => { + require("./overlay.less") // tslint:disable-line + + require("./Services/ContextMenu/ContextMenu.less") // tslint:disable-line + + require("./Services/Explorer/Explorer.less") // tslint:disable-line + require("./Services/Menu/Menu.less") + require("./Services/Sidebar/Sidebar.less") + + require("./UI/components/Cursor.less") + require("./UI/components/Definition.less") + require("./UI/components/Error.less") + require("./UI/components/InstallHelp.less") + require("./UI/components/Message.less") + require("./UI/components/QuickInfo.less") + require("./UI/components/StatusBar.less") + require("./UI/components/Tabs.less") +} diff --git a/browser/src/Services/ContextMenu/ContextMenuComponent.tsx b/browser/src/Services/ContextMenu/ContextMenuComponent.tsx index 3bfeff055b..6a7367d4d0 100644 --- a/browser/src/Services/ContextMenu/ContextMenuComponent.tsx +++ b/browser/src/Services/ContextMenu/ContextMenuComponent.tsx @@ -37,8 +37,6 @@ export interface IContextMenuProps { highlightColor: string } -require("./ContextMenu.less") // tslint:disable-line no-var-requires - export class ContextMenuView extends React.PureComponent { public render(): null | JSX.Element { diff --git a/browser/src/Services/Menu/MenuComponent.tsx b/browser/src/Services/Menu/MenuComponent.tsx index e6db326178..7dfb1a6dfe 100644 --- a/browser/src/Services/Menu/MenuComponent.tsx +++ b/browser/src/Services/Menu/MenuComponent.tsx @@ -15,11 +15,6 @@ import { IMenuOptionWithHighlights, menuStore } from "./Menu" import * as ActionCreators from "./MenuActionCreators" import * as State from "./MenuState" -/** - * Popup menu - */ -require("./Menu.less") // tslint:disable-line no-var-requires - export interface IMenuProps { visible: boolean selectedIndex: number diff --git a/browser/src/Services/Sidebar/SidebarView.tsx b/browser/src/Services/Sidebar/SidebarView.tsx index f55f50a151..1a8203856b 100644 --- a/browser/src/Services/Sidebar/SidebarView.tsx +++ b/browser/src/Services/Sidebar/SidebarView.tsx @@ -14,8 +14,6 @@ import { Icon, IconSize } from "./../../UI/Icon" import { ISidebarEntry, ISidebarState } from "./SidebarStore" -require("./Sidebar.less") // tslint:disable-line - export interface ISidebarIconProps { active: boolean iconName: string diff --git a/browser/src/UI/components/Cursor.tsx b/browser/src/UI/components/Cursor.tsx index a7d97572f0..5967b66415 100644 --- a/browser/src/UI/components/Cursor.tsx +++ b/browser/src/UI/components/Cursor.tsx @@ -28,8 +28,6 @@ export interface ICursorRendererProps { typingPrediction: TypingPredictionManager } -require("./Cursor.less") // tslint:disable-line no-var-requires - export interface ICursorRendererState { predictedCursorColumn: number } diff --git a/browser/src/UI/components/Definition.tsx b/browser/src/UI/components/Definition.tsx index fa6a500fd3..c9f18d01c9 100644 --- a/browser/src/UI/components/Definition.tsx +++ b/browser/src/UI/components/Definition.tsx @@ -9,8 +9,6 @@ import * as types from "vscode-languageserver-types" import { BufferToScreen, ScreenToPixel } from "./../Coordinates" -require("./Definition.less") // tslint:disable-line no-var-requires - export interface IDefinitionProps { range: types.Range fontWidthInPixels: number diff --git a/browser/src/UI/components/Error.tsx b/browser/src/UI/components/Error.tsx index ae605fe29b..45b989e582 100644 --- a/browser/src/UI/components/Error.tsx +++ b/browser/src/UI/components/Error.tsx @@ -13,8 +13,6 @@ import { Icon } from "./../Icon" import { BufferToScreen, ScreenToPixel } from "./../Coordinates" -require("./Error.less") // tslint:disable-line no-var-requires - export interface IErrorsProps { errors: types.Diagnostic[] fontWidthInPixels: number diff --git a/browser/src/UI/components/InstallHelp.tsx b/browser/src/UI/components/InstallHelp.tsx index c3fc7139fb..6957528fc1 100644 --- a/browser/src/UI/components/InstallHelp.tsx +++ b/browser/src/UI/components/InstallHelp.tsx @@ -8,8 +8,6 @@ import { Icon, IconSize } from "./../Icon" import * as State from "./../State" -require("./InstallHelp.less") // tslint:disable-line no-var-requires - export interface InstallHelpViewProps { visible: boolean } diff --git a/browser/src/UI/components/Message.tsx b/browser/src/UI/components/Message.tsx index cb8f0c19de..9a2a913251 100644 --- a/browser/src/UI/components/Message.tsx +++ b/browser/src/UI/components/Message.tsx @@ -7,11 +7,6 @@ import * as React from "react" import { Visible } from "./Visible" -/** - * Popup menu - */ -require("./Message.less") // tslint:disable-line no-var-requires - // export interface IMenuProps { // visible: boolean // items: string[] diff --git a/browser/src/UI/components/QuickInfo.tsx b/browser/src/UI/components/QuickInfo.tsx index 997f0d446d..fb2395f58b 100644 --- a/browser/src/UI/components/QuickInfo.tsx +++ b/browser/src/UI/components/QuickInfo.tsx @@ -2,8 +2,6 @@ import * as os from "os" import * as React from "react" -require("./QuickInfo.less") // tslint:disable-line no-var-requires - export interface ITextProps { text: string } diff --git a/browser/src/UI/components/StatusBar.tsx b/browser/src/UI/components/StatusBar.tsx index 9e609ec90c..1d26acdcbb 100644 --- a/browser/src/UI/components/StatusBar.tsx +++ b/browser/src/UI/components/StatusBar.tsx @@ -9,8 +9,6 @@ import { IState, StatusBarAlignment } from "./../State" import { addDefaultUnitIfNeeded } from "./../../Font" -require("./StatusBar.less") // tslint:disable-line no-var-requires - export interface StatusBarProps { items: StatusBarItemProps[] enabled: boolean diff --git a/browser/src/UI/components/Tabs.tsx b/browser/src/UI/components/Tabs.tsx index bfccb127b2..e173a3be5e 100644 --- a/browser/src/UI/components/Tabs.tsx +++ b/browser/src/UI/components/Tabs.tsx @@ -18,8 +18,6 @@ import { Icon } from "./../../UI/Icon" import { FileIcon } from "./../../Services/FileIcon" -require("./Tabs.less") // tslint:disable-line no-var-requires - export interface ITabProps { id: number name: string diff --git a/browser/src/index.tsx b/browser/src/index.tsx index 8463d577f7..7a73347b67 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -17,26 +17,25 @@ import * as BrowserWindowConfigurationSynchronizer from "./Services/BrowserWindo import { commandManager } from "./Services/CommandManager" import { configuration, IConfigurationValues } from "./Services/Configuration" import { editorManager } from "./Services/EditorManager" -import * as IconThemes from "./Services/IconThemes" import { inputManager } from "./Services/InputManager" import { languageManager } from "./Services/Language" -import * as Themes from "./Services/Themes" import * as SharedNeovimInstance from "./neovim/SharedNeovimInstance" import { createLanguageClientsFromConfiguration } from "./Services/Language" -import * as UI from "./UI/index" - -require("./overlay.less") // tslint:disable-line +// import * as UI from "./UI/index" const start = async (args: string[]): Promise => { Performance.startMeasure("Oni.Start") + const UI = await import("./UI") UI.activate() const parsedArgs = minimist(args) + const cssPromise = await import("./CSS") + // Helper for debugging: window["UI"] = UI // tslint:disable-line no-string-literal @@ -64,8 +63,9 @@ const start = async (args: string[]): Promise => { pluginManager.discoverPlugins() Performance.endMeasure("Oni.Start.Plugins.Discover") - // TODO: Can these be parallelized? Performance.startMeasure("Oni.Start.Themes") + const Themes = await import("./Services/Themes") + const IconThemes = await import("./Services/IconThemes") await Promise.all([ Themes.activate(configuration), IconThemes.activate(configuration, pluginManager) @@ -77,7 +77,6 @@ const start = async (args: string[]): Promise => { BrowserWindowConfigurationSynchronizer.activate(configuration, Colors.getInstance()) - // TODO: Can these be parallelized? Performance.startMeasure("Oni.Start.Editors") await Promise.all([ SharedNeovimInstance.activate(), @@ -86,7 +85,6 @@ const start = async (args: string[]): Promise => { Performance.endMeasure("Oni.Start.Editors") Performance.startMeasure("Oni.Start.Activate") - const api = pluginManager.startApi() configuration.activate(api) @@ -95,6 +93,9 @@ const start = async (args: string[]): Promise => { AutoClosingPairs.activate(configuration, editorManager, inputManager, languageManager) Performance.endMeasure("Oni.Start.Activate") + const CSS = await cssPromise + CSS.activate() + UI.Actions.setLoadingComplete() checkForUpdates() diff --git a/browser/src/neovim/NeovimInstance.ts b/browser/src/neovim/NeovimInstance.ts index 99aa4d5498..02824edbe7 100644 --- a/browser/src/neovim/NeovimInstance.ts +++ b/browser/src/neovim/NeovimInstance.ts @@ -7,6 +7,7 @@ import * as Oni from "oni-api" import { Event, IEvent } from "oni-types" import * as Log from "./../Log" +import * as Performance from "./../Performance" import { EventContext } from "./EventContext" import { addDefaultUnitIfNeeded, measureFont } from "./../Font" @@ -272,6 +273,7 @@ export class NeovimInstance extends EventEmitter implements INeovimInstance { } public start(startOptions?: INeovimStartOptions): Promise { + Performance.startMeasure("NeovimInstance.Start") this._initPromise = startNeovim(startOptions) .then((nv) => { Log.info("NeovimInstance: Neovim started") @@ -357,9 +359,11 @@ export class NeovimInstance extends EventEmitter implements INeovimInstance { // Workaround for bug in neovim/node-client // The 'uiAttach' method overrides the new 'nvim_ui_attach' method + Performance.startMeasure("NeovimInstance.Start.Attach") return this._attachUI(size.cols, size.rows) .then(async () => { Log.info("Attach success") + Performance.endMeasure("NeovimInstance.Start.Attach") // TODO: #702 - Batch these calls via `nvim_call_atomic` // Override completeopt so Oni works correctly with external popupmenu @@ -368,6 +372,8 @@ export class NeovimInstance extends EventEmitter implements INeovimInstance { // set title after attaching listeners so we can get the initial title await this.command("set title") + Performance.endMeasure("NeovimInstance.Start") + this._initComplete = true }, (err: any) => { diff --git a/browser/tsconfig.json b/browser/tsconfig.json index d6f906421e..248bf6137e 100644 --- a/browser/tsconfig.json +++ b/browser/tsconfig.json @@ -9,7 +9,7 @@ "dom", "es2017" ], - "module": "commonjs", + "module": "esnext", "moduleResolution": "node", "newLine": "LF", "noEmitOnError": true, diff --git a/browser/webpack.debug.config.js b/browser/webpack.debug.config.js index dd990b57ae..a6111846c8 100644 --- a/browser/webpack.debug.config.js +++ b/browser/webpack.debug.config.js @@ -50,7 +50,7 @@ module.exports = { ], output: { path: path.join(__dirname, "..", "lib", "browser"), - publicPath: "/", + publicPath: "lib/browser/", filename: "bundle.js", chunkFilename: "[name].bundle.js" }, From f007fc24a69adb6a839d318d8662d2a42b78d59f Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 11:09:30 -0800 Subject: [PATCH 03/23] Add tool to profile webpack bundle --- .gitignore | 3 +++ package.json | 4 +++- yarn.lock | 56 +++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 26f781575b..ebeb85ff53 100644 --- a/.gitignore +++ b/.gitignore @@ -143,3 +143,6 @@ $RECYCLE.BIN/ .merlin yarn.lock + +# Webpack stats file +stats.json diff --git a/package.json b/package.json index 58e396e523..b01d8f9126 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,8 @@ "watch:plugins": "cd vim/core/oni-plugin-typescript && tsc --watch", "uninstall-global": "npm rm -g oni-vim", "install-global": "npm install -g oni-vim", - "postinstall": "electron-rebuild && opencollective postinstall" + "postinstall": "electron-rebuild && opencollective postinstall", + "profile:webpack": "webpack --config browser/webpack.production.config.js --profile --json > stats.json && webpack-bundle-analyzer stats.json" }, "repository": { "type": "git", @@ -201,6 +202,7 @@ "wcwidth": "1.0.1", "webdriverio": "4.8.0", "webpack": "3.5.3", + "webpack-bundle-analyzer": "^2.9.1", "webpack-dev-server": "2.7.1" }, "collective": { diff --git a/yarn.lock b/yarn.lock index 5c2fa665f2..048ada5887 100644 --- a/yarn.lock +++ b/yarn.lock @@ -167,7 +167,7 @@ acorn@^4.0.3, acorn@^4.0.4: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" -acorn@^5.0.0: +acorn@^5.0.0, acorn@^5.1.1: version "5.2.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.2.1.tgz#317ac7821826c22c702d66189ab8359675f135d7" @@ -409,6 +409,10 @@ async-exit-hook@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/async-exit-hook/-/async-exit-hook-2.0.1.tgz#8bd8b024b0ec9b1c01cccb9af9db29bd717dfaf3" +async-limiter@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" + async@2.6.0, async@^2.0.0, async@^2.1.2: version "2.6.0" resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" @@ -1902,6 +1906,10 @@ duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" +duplexer@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" + ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" @@ -1912,7 +1920,7 @@ ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" -ejs@^2.5.7, ejs@~2.5.6: +ejs@^2.5.6, ejs@^2.5.7, ejs@~2.5.6: version "2.5.7" resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.7.tgz#cc872c168880ae3c7189762fd5ffc00896c9518a" @@ -2325,7 +2333,7 @@ expand-template@^1.0.2: version "1.1.0" resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-1.1.0.tgz#e09efba977bf98f9ee0ed25abd0c692e02aec3fc" -express@^4.13.3: +express@^4.13.3, express@^4.15.2: version "4.16.2" resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c" dependencies: @@ -2460,6 +2468,10 @@ filename-regex@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" +filesize@^3.5.9: + version "3.5.11" + resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.5.11.tgz#1919326749433bb3cf77368bd158caabcc19e9ee" + fill-range@^2.1.0: version "2.2.3" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" @@ -2764,6 +2776,12 @@ growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" +gzip-size@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-3.0.0.tgz#546188e9bdc337f673772f81660464b389dce520" + dependencies: + duplexer "^0.1.1" + handle-thing@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-1.2.5.tgz#fd7aad726bf1a5fd16dfc29b2f7a6601d27139c4" @@ -4218,6 +4236,10 @@ opencollective@1.0.3: node-fetch "1.6.3" opn "4.0.2" +opener@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/opener/-/opener-1.4.3.tgz#5c6da2c5d7e5831e8ffa3964950f8d6674ac90b8" + opn@4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/opn/-/opn-4.0.2.tgz#7abc22e644dff63b0a96d5ab7f2790c0f01abc95" @@ -6157,6 +6179,10 @@ uid-number@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" +ultron@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" + uniq@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff" @@ -6451,6 +6477,22 @@ webidl-conversions@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" +webpack-bundle-analyzer@^2.9.1: + version "2.9.1" + resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.9.1.tgz#c2c8e03e8e5768ed288b39ae9e27a8b8d7b9d476" + dependencies: + acorn "^5.1.1" + chalk "^1.1.3" + commander "^2.9.0" + ejs "^2.5.6" + express "^4.15.2" + filesize "^3.5.9" + gzip-size "^3.0.0" + lodash "^4.17.4" + mkdirp "^0.5.1" + opener "^1.4.3" + ws "^3.3.1" + webpack-dev-middleware@^1.11.0: version "1.12.1" resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.12.1.tgz#338be3ca930973be1c2ce07d84d275e997e1a25a" @@ -6631,6 +6673,14 @@ write-file-atomic@^2.0.0: imurmurhash "^0.1.4" signal-exit "^3.0.2" +ws@^3.3.1: + version "3.3.2" + resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.2.tgz#96c1d08b3fefda1d5c1e33700d3bfaa9be2d5608" + dependencies: + async-limiter "~1.0.0" + safe-buffer "~5.1.0" + ultron "~1.1.0" + xdg-basedir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" From ef75f760429f6a75e1df4f7897405f1101d26350 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 11:23:53 -0800 Subject: [PATCH 04/23] Get hot reload + unit tests working --- browser/tsconfig.json | 2 +- browser/webpack.debug.config.js | 2 +- browser/webpack.production.config.js | 6 ++++++ package.json | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/browser/tsconfig.json b/browser/tsconfig.json index 248bf6137e..d6f906421e 100644 --- a/browser/tsconfig.json +++ b/browser/tsconfig.json @@ -9,7 +9,7 @@ "dom", "es2017" ], - "module": "esnext", + "module": "commonjs", "moduleResolution": "node", "newLine": "LF", "noEmitOnError": true, diff --git a/browser/webpack.debug.config.js b/browser/webpack.debug.config.js index a6111846c8..4bc9f08777 100644 --- a/browser/webpack.debug.config.js +++ b/browser/webpack.debug.config.js @@ -50,7 +50,7 @@ module.exports = { ], output: { path: path.join(__dirname, "..", "lib", "browser"), - publicPath: "lib/browser/", + publicPath: "http://localhost:8191/", filename: "bundle.js", chunkFilename: "[name].bundle.js" }, diff --git a/browser/webpack.production.config.js b/browser/webpack.production.config.js index ea4af64b9a..90c28ebf33 100644 --- a/browser/webpack.production.config.js +++ b/browser/webpack.production.config.js @@ -16,6 +16,12 @@ const productionConfig = Object.assign({}, baseConfig, { sourceMap: false }) ], + output: { + path: path.join(__dirname, "..", "lib", "browser"), + publicPath: "lib/browser/", + filename: "bundle.js", + chunkFilename: "[name].bundle.js" + }, }) module.exports = productionConfig diff --git a/package.json b/package.json index b01d8f9126..249e2a829b 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "build:plugin:oni-plugin-typescript": "cd vim/core/oni-plugin-typescript && npm run build", "build:test": "cd test && tsc -p tsconfig.json", "copy-icons": "node build/CopyIcons.js", - "debug:test:unit:browser": "cd browser && tsc -p tsconfig.json && electron-mocha --interactive --debug --renderer --require testHelpers.js --recursive ../lib_test/browser/test", + "debug:test:unit:browser": "cd browser && tsc -p tsconfig.test.json && electron-mocha --interactive --debug --renderer --require testHelpers.js --recursive ../lib_test/browser/test", "demo": "npm run build:test && mocha -t 30000 lib_test/test/Demo.js", "dist:win": "build --arch ia32 --publish never", "pack:win": "node build/BuildSetupTemplate.js && innosetup-compiler dist/setup.iss --verbose --O=dist", @@ -107,7 +107,7 @@ "uninstall-global": "npm rm -g oni-vim", "install-global": "npm install -g oni-vim", "postinstall": "electron-rebuild && opencollective postinstall", - "profile:webpack": "webpack --config browser/webpack.production.config.js --profile --json > stats.json && webpack-bundle-analyzer stats.json" + "profile:webpack": "webpack --config browser/webpack.production.config.js --profile --json > stats.json && webpack-bundle-analyzer browser/stats.json" }, "repository": { "type": "git", From 4e728cfbd4c1eab6d2a340cf4e363fe76d666959 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 11:37:04 -0800 Subject: [PATCH 05/23] Refactor language manager to be async --- browser/src/Editor/BufferManager.ts | 6 +++--- browser/src/Editor/NeovimEditor.tsx | 3 ++- browser/src/Plugins/Api/Oni.ts | 4 ++-- browser/src/Services/Language/CodeAction.ts | 4 +++- browser/src/Services/Language/Diagnostics.ts | 5 +++-- browser/src/Services/Language/FindAllReferences.ts | 3 ++- browser/src/Services/Language/Formatting.ts | 8 ++++---- .../src/Services/Language/LanguageConfiguration.ts | 4 ++-- browser/src/Services/Language/LanguageManager.ts | 10 +++++++++- browser/src/Services/Language/Rename.tsx | 3 ++- browser/src/Services/Language/SignatureHelp.ts | 3 ++- browser/src/Services/Language/Symbols.ts | 12 ++++-------- browser/src/index.tsx | 9 +++++++-- browser/{tsconfig.src.json => tsconfig.test.json} | 5 +++-- 14 files changed, 48 insertions(+), 31 deletions(-) rename browser/{tsconfig.src.json => tsconfig.test.json} (92%) diff --git a/browser/src/Editor/BufferManager.ts b/browser/src/Editor/BufferManager.ts index 95cae43af2..d3fa1fd3de 100644 --- a/browser/src/Editor/BufferManager.ts +++ b/browser/src/Editor/BufferManager.ts @@ -16,7 +16,7 @@ import "rxjs/add/operator/concatMap" import * as Oni from "oni-api" import { EventContext, NeovimInstance } from "./../neovim" -import { languageManager, sortTextEdits } from "./../Services/Language" +import * as LanguageManager from "./../Services/Language" import { PromiseQueue } from "./../Services/Language/PromiseQueue" import * as SyntaxHighlighting from "./../Services/SyntaxHighlighting" @@ -94,7 +94,7 @@ export class Buffer implements Oni.Buffer { const textEditsAsArray = textEdits instanceof Array ? textEdits : [textEdits] - const sortedEdits = sortTextEdits(textEditsAsArray) + const sortedEdits = LanguageManager.sortTextEdits(textEditsAsArray) const deferredEdits = sortedEdits.map((te) => { return Observable.defer(async () => { @@ -186,7 +186,7 @@ export class Buffer implements Oni.Buffer { public async getTokenAt(line: number, column: number): Promise { const result = await this.getLines(line, line + 1) - const tokenRegEx = languageManager.getTokenRegex(this.language) + const tokenRegEx = LanguageManager.getInstance().getTokenRegex(this.language) const getLastMatchingCharacter = (lineContents: string, character: number, dir: number, regex: RegExp) => { while (character > 0 && character < lineContents.length) { diff --git a/browser/src/Editor/NeovimEditor.tsx b/browser/src/Editor/NeovimEditor.tsx index 628bcc1ecb..bee3f878e0 100644 --- a/browser/src/Editor/NeovimEditor.tsx +++ b/browser/src/Editor/NeovimEditor.tsx @@ -31,7 +31,7 @@ import { registerBuiltInCommands } from "./../Services/Commands" import { Completion } from "./../Services/Completion" import { configuration, IConfigurationValues } from "./../Services/Configuration" import { Errors } from "./../Services/Errors" -import { addInsertModeLanguageFunctionality, LanguageEditorIntegration, languageManager } from "./../Services/Language" +import { addInsertModeLanguageFunctionality, LanguageEditorIntegration, getInstance as getLanguageManagerInstance } from "./../Services/Language" import { ISyntaxHighlighter, NullSyntaxHighlighter, SyntaxHighlighter } from "./../Services/SyntaxHighlighting" import { getThemeManagerInstance } from "./../Services/Themes" import { TypingPredictionManager } from "./../Services/TypingPredictionManager" @@ -245,6 +245,7 @@ export class NeovimEditor extends Editor implements IEditor { const textMateHighlightingEnabled = this._config.getValue("experimental.editor.textMateHighlighting.enabled") this._syntaxHighlighter = textMateHighlightingEnabled ? new SyntaxHighlighter() : new NullSyntaxHighlighter() + const languageManager = getLanguageManagerInstance() this._completion = new Completion(this, languageManager, configuration) this._completionMenu = new CompletionMenu() diff --git a/browser/src/Plugins/Api/Oni.ts b/browser/src/Plugins/Api/Oni.ts index 6d279d91ee..c2cd5799e6 100644 --- a/browser/src/Plugins/Api/Oni.ts +++ b/browser/src/Plugins/Api/Oni.ts @@ -23,7 +23,7 @@ import { configuration } from "./../../Services/Configuration" import { contextMenuManager } from "./../../Services/ContextMenu" import { editorManager } from "./../../Services/EditorManager" import { inputManager } from "./../../Services/InputManager" -import { languageManager } from "./../../Services/Language" +import * as LanguageManager from "./../../Services/Language" import { menuManager } from "./../../Services/Menu" import { recorder } from "./../../Services/Recorder" import { statusBar } from "./../../Services/StatusBar" @@ -102,7 +102,7 @@ export class Oni extends EventEmitter implements OniApi.Plugin.Api { } public get language(): any { - return languageManager + return LanguageManager.getInstance() } public get menu(): any /* TODO */ { diff --git a/browser/src/Services/Language/CodeAction.ts b/browser/src/Services/Language/CodeAction.ts index b9dce2ddfd..afbca0b96e 100644 --- a/browser/src/Services/Language/CodeAction.ts +++ b/browser/src/Services/Language/CodeAction.ts @@ -11,7 +11,7 @@ import * as types from "vscode-languageserver-types" // import * as UI from "./../../UI" import { contextMenuManager } from "./../ContextMenu" -import { languageManager } from "./LanguageManager" +import * as LanguageManager from "./LanguageManager" import * as Log from "./../../Log" import { editorManager } from "./../EditorManager" @@ -25,6 +25,7 @@ let lastFileInfo: any = {} codeActionsContextMenu.onItemSelected.subscribe(async (selectedItem) => { const commandName = selectedItem.data + const languageManager = LanguageManager.getInstance() await languageManager.sendLanguageServerRequest(lastFileInfo.language, lastFileInfo.filePath, "workspace/executeCommand", { command: commandName }) }) @@ -57,6 +58,7 @@ const getCodeActions = async (): Promise => { return null } + const languageManager = LanguageManager.getInstance() if (languageManager.isLanguageServerAvailable(language)) { let result: types.Command[] = null try { diff --git a/browser/src/Services/Language/Diagnostics.ts b/browser/src/Services/Language/Diagnostics.ts index 07963b92b4..faf8580df9 100644 --- a/browser/src/Services/Language/Diagnostics.ts +++ b/browser/src/Services/Language/Diagnostics.ts @@ -9,7 +9,7 @@ import * as types from "vscode-languageserver-types" import * as UI from "./../../UI" import * as Selectors from "./../../UI/Selectors" -import { ILanguageServerNotificationResponse, languageManager } from "./LanguageManager" +import * as LanguageManager from "./LanguageManager" import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpers" @@ -36,7 +36,8 @@ export class DiagnosticsDataSource { } export const listenForDiagnostics = () => { - languageManager.subscribeToLanguageServerNotification("textDocument/publishDiagnostics", (args: ILanguageServerNotificationResponse) => { + const languageManager = LanguageManager.getInstance() + languageManager.subscribeToLanguageServerNotification("textDocument/publishDiagnostics", (args: LanguageManager.ILanguageServerNotificationResponse) => { const test = args.payload as IPublishDiagnosticsParams UI.Actions.setErrors(Helpers.unwrapFileUriPath(test.uri), "language-" + args.language, test.diagnostics) diff --git a/browser/src/Services/Language/FindAllReferences.ts b/browser/src/Services/Language/FindAllReferences.ts index 5a9a277b6f..1c137648fb 100644 --- a/browser/src/Services/Language/FindAllReferences.ts +++ b/browser/src/Services/Language/FindAllReferences.ts @@ -8,7 +8,7 @@ import * as types from "vscode-languageserver-types" import { INeovimInstance } from "./../../neovim" import { editorManager } from "./../EditorManager" -import { languageManager } from "./LanguageManager" +import * as LanguageManager from "./LanguageManager" import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpers" @@ -29,6 +29,7 @@ export const findAllReferences = async () => { return } + const languageManager = LanguageManager.getInstance() if (languageManager.isLanguageServerAvailable(activeBuffer.language)) { const args = { ...Helpers.bufferToTextDocumentPositionParams(activeBuffer), context: { diff --git a/browser/src/Services/Language/Formatting.ts b/browser/src/Services/Language/Formatting.ts index 4f262a8ae4..453257bfe7 100644 --- a/browser/src/Services/Language/Formatting.ts +++ b/browser/src/Services/Language/Formatting.ts @@ -9,13 +9,13 @@ import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpe import { editorManager } from "./../EditorManager" -import { languageManager } from "./LanguageManager" +import * as LanguageManager from "./LanguageManager" export const format = async () => { const activeBuffer = editorManager.activeEditor.activeBuffer - const capabilities = await languageManager.getCapabilitiesForLanguage(activeBuffer.language) + const capabilities = await LanguageManager.getInstance().getCapabilitiesForLanguage(activeBuffer.language) if (capabilities.documentFormattingProvider) { await formatDocument() @@ -37,7 +37,7 @@ export const formatDocument = async () => { let result: types.TextEdit[] = null try { - result = await languageManager.sendLanguageServerRequest(activeBuffer.language, activeBuffer.filePath, "textDocument/formatting", args) + result = await LanguageManager.getInstance().sendLanguageServerRequest(activeBuffer.language, activeBuffer.filePath, "textDocument/formatting", args) } catch (ex) { Log.warn(ex) } @@ -60,7 +60,7 @@ export const rangeFormatDocument = async () => { let result: types.TextEdit[] = null try { - result = await languageManager.sendLanguageServerRequest(activeBuffer.language, activeBuffer.filePath, "textDocument/rangeFormatting", args) + result = await LanguageManager.getInstance().sendLanguageServerRequest(activeBuffer.language, activeBuffer.filePath, "textDocument/rangeFormatting", args) } catch (ex) { Log.warn(ex) } diff --git a/browser/src/Services/Language/LanguageConfiguration.ts b/browser/src/Services/Language/LanguageConfiguration.ts index 54d7b5e2b9..fee14f9fdb 100644 --- a/browser/src/Services/Language/LanguageConfiguration.ts +++ b/browser/src/Services/Language/LanguageConfiguration.ts @@ -8,7 +8,7 @@ import * as Log from "./../../Log" import { LanguageClient } from "./LanguageClient" import { InitializationOptions, LanguageClientProcess, ServerRunOptions } from "./LanguageClientProcess" -import { languageManager } from "./LanguageManager" +import * as LanguageManager from "./LanguageManager" import { getRootProjectFileFunc } from "./../../Utility" @@ -97,5 +97,5 @@ const createLanguageClientFromConfig = (language: string, config: ILightweightLa rootPath: pathResolver, } const languageClient = new LanguageClient(language, new LanguageClientProcess(serverRunOptions, initializationOptions, configuration)) - languageManager.registerLanguageClient(language, languageClient) + LanguageManager.getInstance().registerLanguageClient(language, languageClient) } diff --git a/browser/src/Services/Language/LanguageManager.ts b/browser/src/Services/Language/LanguageManager.ts index f754077179..d6cb1dd95b 100644 --- a/browser/src/Services/Language/LanguageManager.ts +++ b/browser/src/Services/Language/LanguageManager.ts @@ -338,4 +338,12 @@ const logDebug = (args: any) => { } } -export const languageManager = new LanguageManager() +let _languageManager: LanguageManager = null + +export const activate = (): void => { + _languageManager = new LanguageManager() +} + +export const getInstance = (): LanguageManager => { + return _languageManager +} diff --git a/browser/src/Services/Language/Rename.tsx b/browser/src/Services/Language/Rename.tsx index 474a805d4b..18c4a2c839 100644 --- a/browser/src/Services/Language/Rename.tsx +++ b/browser/src/Services/Language/Rename.tsx @@ -11,7 +11,7 @@ import * as UI from "./../../UI" import { editorManager } from "./../EditorManager" import { workspace } from "./../Workspace" -import { languageManager } from "./LanguageManager" +import * as LanguageManager from "./LanguageManager" const _renameToolTipName = "rename-tool-tip" let _isRenameActive = false @@ -88,6 +88,7 @@ export const doRename = async (newName: string): Promise => { newName, } + const languageManager = LanguageManager.getInstance() let result = null try { result = await languageManager.sendLanguageServerRequest(activeBuffer.language, activeBuffer.filePath, "textDocument/rename", args) diff --git a/browser/src/Services/Language/SignatureHelp.ts b/browser/src/Services/Language/SignatureHelp.ts index a6ceb700b5..576066a119 100644 --- a/browser/src/Services/Language/SignatureHelp.ts +++ b/browser/src/Services/Language/SignatureHelp.ts @@ -15,7 +15,7 @@ import * as UI from "./../../UI" import { editorManager } from "./../EditorManager" import { ILatestCursorAndBufferInfo } from "./addInsertModeLanguageFunctionality" -import { languageManager } from "./LanguageManager" +import * as LanguageManager from "./LanguageManager" import * as SignatureHelp from "./SignatureHelpView" export const initUI = (latestCursorAndBufferInfo$: Observable, modeChanged$: Observable) => { @@ -49,6 +49,7 @@ export const initUI = (latestCursorAndBufferInfo$: Observable => { + const languageManager = LanguageManager.getInstance() if (languageManager.isLanguageServerAvailable(language)) { const buffer = editorManager.activeEditor.activeBuffer diff --git a/browser/src/Services/Language/Symbols.ts b/browser/src/Services/Language/Symbols.ts index f7c143fde3..6678c0e15f 100644 --- a/browser/src/Services/Language/Symbols.ts +++ b/browser/src/Services/Language/Symbols.ts @@ -3,25 +3,18 @@ * */ -// import * as os from "os" import * as types from "vscode-languageserver-types" import * as Oni from "oni-api" -// import { configuration } from "./../Configuration" - -// import * as UI from "./../../UI" - import { editorManager } from "./../EditorManager" import { menuManager } from "./../Menu" import { gotoPositionInUri } from "./Definition" -import { languageManager } from "./LanguageManager" +import * as LanguageManager from "./LanguageManager" import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpers" -// import * as Log from "./../../Log" - export const openWorkspaceSymbolsMenu = async () => { const menu = menuManager.create() @@ -49,6 +42,8 @@ export const openWorkspaceSymbolsMenu = async () => { const getKey = (si: types.SymbolInformation) => si.name + getDetailFromSymbol(si) + const languageManager = LanguageManager.getInstance() + filterTextChanged$ .debounceTime(25) .do(() => menu.setLoading(true)) @@ -131,6 +126,7 @@ export const openDocumentSymbolsMenu = async () => { const buffer = editorManager.activeEditor.activeBuffer + const languageManager = LanguageManager.getInstance() const result: types.SymbolInformation[] = await languageManager.sendLanguageServerRequest(buffer.language, buffer.filePath, "textDocument/documentSymbol", { textDocument: { uri: Helpers.wrapPathInFileUri(buffer.filePath), diff --git a/browser/src/index.tsx b/browser/src/index.tsx index 7a73347b67..aa34445925 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -18,7 +18,7 @@ import { commandManager } from "./Services/CommandManager" import { configuration, IConfigurationValues } from "./Services/Configuration" import { editorManager } from "./Services/EditorManager" import { inputManager } from "./Services/InputManager" -import { languageManager } from "./Services/Language" +// import * as LanguageManager from "./Services/Language" import * as SharedNeovimInstance from "./neovim/SharedNeovimInstance" @@ -34,7 +34,8 @@ const start = async (args: string[]): Promise => { const parsedArgs = minimist(args) - const cssPromise = await import("./CSS") + const cssPromise = import("./CSS") + const languageManagerPromise = import("./Services/Language") // Helper for debugging: window["UI"] = UI // tslint:disable-line no-string-literal @@ -84,6 +85,10 @@ const start = async (args: string[]): Promise => { ]) Performance.endMeasure("Oni.Start.Editors") + const LanguageManager = await languageManagerPromise + LanguageManager.activate() + const languageManager = LanguageManager.getInstance() + Performance.startMeasure("Oni.Start.Activate") const api = pluginManager.startApi() configuration.activate(api) diff --git a/browser/tsconfig.src.json b/browser/tsconfig.test.json similarity index 92% rename from browser/tsconfig.src.json rename to browser/tsconfig.test.json index 40f9b8a0f6..248bf6137e 100644 --- a/browser/tsconfig.src.json +++ b/browser/tsconfig.test.json @@ -9,7 +9,7 @@ "dom", "es2017" ], - "module": "commonjs", + "module": "esnext", "moduleResolution": "node", "newLine": "LF", "noEmitOnError": true, @@ -29,7 +29,8 @@ "sourceMap": true }, "include": [ - "src/**/*.ts" + "src/**/*.ts", + "test/**/*.ts" ], "exclude": [ "node_modules" From 05fefc8627c90293c7fcce862d11b5c8acf06abd Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 11:44:02 -0800 Subject: [PATCH 06/23] Fix module definitions in tsconfig --- browser/src/index.tsx | 8 ++++---- browser/tsconfig.json | 2 +- browser/tsconfig.test.json | 2 +- browser/webpack.production.config.js | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/browser/src/index.tsx b/browser/src/index.tsx index aa34445925..48d42395de 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -8,7 +8,6 @@ import { ipcRenderer } from "electron" import * as minimist from "minimist" import * as Log from "./Log" import * as Performance from "./Performance" -import { pluginManager } from "./Plugins/PluginManager" import * as AutoClosingPairs from "./Services/AutoClosingPairs" import { autoUpdater, constructFeedUrl } from "./Services/AutoUpdate" @@ -18,14 +17,11 @@ import { commandManager } from "./Services/CommandManager" import { configuration, IConfigurationValues } from "./Services/Configuration" import { editorManager } from "./Services/EditorManager" import { inputManager } from "./Services/InputManager" -// import * as LanguageManager from "./Services/Language" import * as SharedNeovimInstance from "./neovim/SharedNeovimInstance" import { createLanguageClientsFromConfiguration } from "./Services/Language" -// import * as UI from "./UI/index" - const start = async (args: string[]): Promise => { Performance.startMeasure("Oni.Start") @@ -36,6 +32,7 @@ const start = async (args: string[]): Promise => { const cssPromise = import("./CSS") const languageManagerPromise = import("./Services/Language") + const pluginManagerPromise = import("./Plugins/PluginManager") // Helper for debugging: window["UI"] = UI // tslint:disable-line no-string-literal @@ -60,6 +57,9 @@ const start = async (args: string[]): Promise => { configuration.onConfigurationChanged.subscribe(configChange) Performance.endMeasure("Oni.Start.Config") + const PluginManager = await pluginManagerPromise + const pluginManager = PluginManager.pluginManager + Performance.startMeasure("Oni.Start.Plugins.Discover") pluginManager.discoverPlugins() Performance.endMeasure("Oni.Start.Plugins.Discover") diff --git a/browser/tsconfig.json b/browser/tsconfig.json index d6f906421e..248bf6137e 100644 --- a/browser/tsconfig.json +++ b/browser/tsconfig.json @@ -9,7 +9,7 @@ "dom", "es2017" ], - "module": "commonjs", + "module": "esnext", "moduleResolution": "node", "newLine": "LF", "noEmitOnError": true, diff --git a/browser/tsconfig.test.json b/browser/tsconfig.test.json index 248bf6137e..d6f906421e 100644 --- a/browser/tsconfig.test.json +++ b/browser/tsconfig.test.json @@ -9,7 +9,7 @@ "dom", "es2017" ], - "module": "esnext", + "module": "commonjs", "moduleResolution": "node", "newLine": "LF", "noEmitOnError": true, diff --git a/browser/webpack.production.config.js b/browser/webpack.production.config.js index 90c28ebf33..f2c34d46c8 100644 --- a/browser/webpack.production.config.js +++ b/browser/webpack.production.config.js @@ -1,4 +1,6 @@ -var webpack = require("webpack"); +const path = require("path") + +const webpack = require("webpack") const baseConfig = require("./webpack.debug.config.js") From b908a8c30f659fde7b347d88ad50bf01f2bd8d41 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 11:46:31 -0800 Subject: [PATCH 07/23] Refactor autoclosingpairs to async import --- browser/src/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser/src/index.tsx b/browser/src/index.tsx index 48d42395de..836ad11a66 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -9,7 +9,7 @@ import * as minimist from "minimist" import * as Log from "./Log" import * as Performance from "./Performance" -import * as AutoClosingPairs from "./Services/AutoClosingPairs" +// import * as AutoClosingPairs from "./Services/AutoClosingPairs" import { autoUpdater, constructFeedUrl } from "./Services/AutoUpdate" import * as Colors from "./Services/Colors" import * as BrowserWindowConfigurationSynchronizer from "./Services/BrowserWindowConfigurationSynchronizer" @@ -31,6 +31,7 @@ const start = async (args: string[]): Promise => { const parsedArgs = minimist(args) const cssPromise = import("./CSS") + const autoClosingPairsPromise = import("./Services/AutoClosingPairs") const languageManagerPromise = import("./Services/Language") const pluginManagerPromise = import("./Plugins/PluginManager") @@ -95,6 +96,7 @@ const start = async (args: string[]): Promise => { createLanguageClientsFromConfiguration(configuration.getValues()) + const AutoClosingPairs = await autoClosingPairsPromise AutoClosingPairs.activate(configuration, editorManager, inputManager, languageManager) Performance.endMeasure("Oni.Start.Activate") From 92fbe7083c229a8b570625bdc13b6c3dda799455 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 11:54:04 -0800 Subject: [PATCH 08/23] Start refactoring additional items to async dependencies --- browser/src/index.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/browser/src/index.tsx b/browser/src/index.tsx index 836ad11a66..dcf242dcb8 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -9,10 +9,6 @@ import * as minimist from "minimist" import * as Log from "./Log" import * as Performance from "./Performance" -// import * as AutoClosingPairs from "./Services/AutoClosingPairs" -import { autoUpdater, constructFeedUrl } from "./Services/AutoUpdate" -import * as Colors from "./Services/Colors" -import * as BrowserWindowConfigurationSynchronizer from "./Services/BrowserWindowConfigurationSynchronizer" import { commandManager } from "./Services/CommandManager" import { configuration, IConfigurationValues } from "./Services/Configuration" import { editorManager } from "./Services/EditorManager" @@ -31,9 +27,13 @@ const start = async (args: string[]): Promise => { const parsedArgs = minimist(args) const cssPromise = import("./CSS") + const pluginManagerPromise = import("./Plugins/PluginManager") const autoClosingPairsPromise = import("./Services/AutoClosingPairs") + const browserWindowConfigurationSynchronizerPromise = import("./Services/BrowserWindowConfigurationSynchronizer") + const colorsPromise = import("./Services/Colors") const languageManagerPromise = import("./Services/Language") - const pluginManagerPromise = import("./Plugins/PluginManager") + const themesPromise = import("./Services/Themes") + const iconThemesPromise = import("./Services/IconThemes") // Helper for debugging: window["UI"] = UI // tslint:disable-line no-string-literal @@ -66,17 +66,19 @@ const start = async (args: string[]): Promise => { Performance.endMeasure("Oni.Start.Plugins.Discover") Performance.startMeasure("Oni.Start.Themes") - const Themes = await import("./Services/Themes") - const IconThemes = await import("./Services/IconThemes") + const Themes = await themesPromise + const IconThemes = await iconThemesPromise await Promise.all([ Themes.activate(configuration), IconThemes.activate(configuration, pluginManager) ]) + const Colors = await colorsPromise Colors.activate(configuration, Themes.getThemeManagerInstance()) UI.Actions.setColors(Themes.getThemeManagerInstance().getColors()) Performance.endMeasure("Oni.Start.Themes") + const BrowserWindowConfigurationSynchronizer = await browserWindowConfigurationSynchronizerPromise BrowserWindowConfigurationSynchronizer.activate(configuration, Colors.getInstance()) Performance.startMeasure("Oni.Start.Editors") @@ -120,6 +122,9 @@ ipcRenderer.on("execute-command", (_evt: any, command: string) => { }) const checkForUpdates = async (): Promise => { + const AutoUpdate = await import("./Services/AutoUpdate") + const { autoUpdater, constructFeedUrl } = AutoUpdate + const feedUrl = await constructFeedUrl("https://api.onivim.io/v1/update") autoUpdater.onUpdateAvailable.subscribe(() => Log.info("Update available.")) From 0033e8c72313c3397c89759058cc45b3dfa0e011 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 12:34:33 -0800 Subject: [PATCH 09/23] Move command manager to an async import --- browser/src/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/src/index.tsx b/browser/src/index.tsx index dcf242dcb8..ffa5bde5c2 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -9,7 +9,6 @@ import * as minimist from "minimist" import * as Log from "./Log" import * as Performance from "./Performance" -import { commandManager } from "./Services/CommandManager" import { configuration, IConfigurationValues } from "./Services/Configuration" import { editorManager } from "./Services/EditorManager" import { inputManager } from "./Services/InputManager" @@ -117,7 +116,8 @@ ipcRenderer.on("init", (_evt: any, message: any) => { start(message.args) }) -ipcRenderer.on("execute-command", (_evt: any, command: string) => { +ipcRenderer.on("execute-command", async (_evt: any, command: string) => { + const { commandManager } = await import("./Services/CommandManager") commandManager.executeCommand(command, null) }) From 2339f4c52157766e1130c985ad8d5cd269a0b7fd Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 12:37:07 -0800 Subject: [PATCH 10/23] Factor SharedNeovimInstance to async import --- browser/src/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/src/index.tsx b/browser/src/index.tsx index ffa5bde5c2..299d9e35f1 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -13,8 +13,6 @@ import { configuration, IConfigurationValues } from "./Services/Configuration" import { editorManager } from "./Services/EditorManager" import { inputManager } from "./Services/InputManager" -import * as SharedNeovimInstance from "./neovim/SharedNeovimInstance" - import { createLanguageClientsFromConfiguration } from "./Services/Language" const start = async (args: string[]): Promise => { @@ -26,6 +24,7 @@ const start = async (args: string[]): Promise => { const parsedArgs = minimist(args) const cssPromise = import("./CSS") + const sharedNeovimInstancePromise = import("./neovim/SharedNeovimInstance") const pluginManagerPromise = import("./Plugins/PluginManager") const autoClosingPairsPromise = import("./Services/AutoClosingPairs") const browserWindowConfigurationSynchronizerPromise = import("./Services/BrowserWindowConfigurationSynchronizer") @@ -81,6 +80,7 @@ const start = async (args: string[]): Promise => { BrowserWindowConfigurationSynchronizer.activate(configuration, Colors.getInstance()) Performance.startMeasure("Oni.Start.Editors") + const SharedNeovimInstance = await sharedNeovimInstancePromise await Promise.all([ SharedNeovimInstance.activate(), UI.startEditors(parsedArgs._, Colors.getInstance(), configuration) From c8247ea2d6deca739b02faea9a0174c74333bed9 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 12:43:08 -0800 Subject: [PATCH 11/23] Finish making LanguageManager async, and make configuration async --- browser/src/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/browser/src/index.tsx b/browser/src/index.tsx index 299d9e35f1..936e3f3a23 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -9,12 +9,10 @@ import * as minimist from "minimist" import * as Log from "./Log" import * as Performance from "./Performance" -import { configuration, IConfigurationValues } from "./Services/Configuration" +import { IConfigurationValues } from "./Services/Configuration/IConfigurationValues" import { editorManager } from "./Services/EditorManager" import { inputManager } from "./Services/InputManager" -import { createLanguageClientsFromConfiguration } from "./Services/Language" - const start = async (args: string[]): Promise => { Performance.startMeasure("Oni.Start") @@ -29,6 +27,7 @@ const start = async (args: string[]): Promise => { const autoClosingPairsPromise = import("./Services/AutoClosingPairs") const browserWindowConfigurationSynchronizerPromise = import("./Services/BrowserWindowConfigurationSynchronizer") const colorsPromise = import("./Services/Colors") + const configurationPromise = import("./Services/Configuration") const languageManagerPromise = import("./Services/Language") const themesPromise = import("./Services/Themes") const iconThemesPromise = import("./Services/IconThemes") @@ -38,6 +37,8 @@ const start = async (args: string[]): Promise => { Performance.startMeasure("Oni.Start.Config") + const { configuration } = await configurationPromise + const initialConfigParsingError = configuration.getParsingError() if (initialConfigParsingError) { Log.error(initialConfigParsingError) @@ -90,6 +91,7 @@ const start = async (args: string[]): Promise => { const LanguageManager = await languageManagerPromise LanguageManager.activate() const languageManager = LanguageManager.getInstance() + const createLanguageClientsFromConfiguration = LanguageManager.createLanguageClientsFromConfiguration Performance.startMeasure("Oni.Start.Activate") const api = pluginManager.startApi() From d885b67171fd3fe28b436b2ecd303f1c800b298a Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 12:44:48 -0800 Subject: [PATCH 12/23] Move EditorManager to be async --- browser/src/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/browser/src/index.tsx b/browser/src/index.tsx index 936e3f3a23..91882c00a6 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -10,7 +10,7 @@ import * as Log from "./Log" import * as Performance from "./Performance" import { IConfigurationValues } from "./Services/Configuration/IConfigurationValues" -import { editorManager } from "./Services/EditorManager" +// import { editorManager } from "./Services/EditorManager" import { inputManager } from "./Services/InputManager" const start = async (args: string[]): Promise => { @@ -28,6 +28,7 @@ const start = async (args: string[]): Promise => { const browserWindowConfigurationSynchronizerPromise = import("./Services/BrowserWindowConfigurationSynchronizer") const colorsPromise = import("./Services/Colors") const configurationPromise = import("./Services/Configuration") + const editorManagerPromise = import("./Services/EditorManager") const languageManagerPromise = import("./Services/Language") const themesPromise = import("./Services/Themes") const iconThemesPromise = import("./Services/IconThemes") @@ -99,6 +100,8 @@ const start = async (args: string[]): Promise => { createLanguageClientsFromConfiguration(configuration.getValues()) + const { editorManager } = await editorManagerPromise + const AutoClosingPairs = await autoClosingPairsPromise AutoClosingPairs.activate(configuration, editorManager, inputManager, languageManager) Performance.endMeasure("Oni.Start.Activate") From 93cc92954f95561f07b19da23d7030affa231e7b Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Wed, 13 Dec 2017 12:58:35 -0800 Subject: [PATCH 13/23] Fix plugin manager --- browser/src/index.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/browser/src/index.tsx b/browser/src/index.tsx index 91882c00a6..be3f375169 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -10,8 +10,6 @@ import * as Log from "./Log" import * as Performance from "./Performance" import { IConfigurationValues } from "./Services/Configuration/IConfigurationValues" -// import { editorManager } from "./Services/EditorManager" -import { inputManager } from "./Services/InputManager" const start = async (args: string[]): Promise => { Performance.startMeasure("Oni.Start") @@ -21,17 +19,18 @@ const start = async (args: string[]): Promise => { const parsedArgs = minimist(args) - const cssPromise = import("./CSS") - const sharedNeovimInstancePromise = import("./neovim/SharedNeovimInstance") + const configurationPromise = import("./Services/Configuration") const pluginManagerPromise = import("./Plugins/PluginManager") + const themesPromise = import("./Services/Themes") + const iconThemesPromise = import("./Services/IconThemes") + const sharedNeovimInstancePromise = import("./neovim/SharedNeovimInstance") const autoClosingPairsPromise = import("./Services/AutoClosingPairs") const browserWindowConfigurationSynchronizerPromise = import("./Services/BrowserWindowConfigurationSynchronizer") const colorsPromise = import("./Services/Colors") - const configurationPromise = import("./Services/Configuration") const editorManagerPromise = import("./Services/EditorManager") + const inputManagerPromise = import("./Services/InputManager") const languageManagerPromise = import("./Services/Language") - const themesPromise = import("./Services/Themes") - const iconThemesPromise = import("./Services/IconThemes") + const cssPromise = import("./CSS") // Helper for debugging: window["UI"] = UI // tslint:disable-line no-string-literal @@ -58,8 +57,7 @@ const start = async (args: string[]): Promise => { configuration.onConfigurationChanged.subscribe(configChange) Performance.endMeasure("Oni.Start.Config") - const PluginManager = await pluginManagerPromise - const pluginManager = PluginManager.pluginManager + const { pluginManager } = await pluginManagerPromise Performance.startMeasure("Oni.Start.Plugins.Discover") pluginManager.discoverPlugins() @@ -101,6 +99,7 @@ const start = async (args: string[]): Promise => { createLanguageClientsFromConfiguration(configuration.getValues()) const { editorManager } = await editorManagerPromise + const { inputManager } = await inputManagerPromise const AutoClosingPairs = await autoClosingPairsPromise AutoClosingPairs.activate(configuration, editorManager, inputManager, languageManager) From 6f33f5732b0f45fc4ff5b0af00367f8fe8fdaf03 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 15 Dec 2017 09:22:48 -0800 Subject: [PATCH 14/23] Fix some typing issues --- .../src/Services/Language/LanguageManager.ts | 20 ++++++++----------- browser/src/index.tsx | 4 ++-- browser/webpack.production.config.js | 6 +++++- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/browser/src/Services/Language/LanguageManager.ts b/browser/src/Services/Language/LanguageManager.ts index 579fe25976..679232dbf5 100644 --- a/browser/src/Services/Language/LanguageManager.ts +++ b/browser/src/Services/Language/LanguageManager.ts @@ -14,13 +14,9 @@ import { Event, IDisposable } from "oni-types" import * as Log from "./../../Log" -import { configuration, Configuration } from "./../Configuration" -import { editorManager, EditorManager } from "./../EditorManager" - import { ILanguageClient } from "./LanguageClient" -import { IServerCapabilities } from "./ServerCapabilities" - import * as LanguageClientTypes from "./LanguageClientTypes" +import { IServerCapabilities } from "./ServerCapabilities" import { LanguageClientState, LanguageClientStatusBar } from "./LanguageClientStatusBar" @@ -44,8 +40,8 @@ export class LanguageManager { private _currentTrackedFile: string = null constructor( - private _configuration: Configuration = configuration, - private _editorManager: EditorManager = editorManager, + private _configuration: Oni.Configuration, + private _editorManager: Oni.EditorManager, ) { this._editorManager.allEditors.onBufferEnter.subscribe(async () => this._onBufferEnter()) @@ -139,7 +135,7 @@ export class LanguageManager { } public getTokenRegex(language: string): RegExp { - const languageSpecificTokenRegex = this._configuration.getValue(`language.${language}.tokenRegex`) + const languageSpecificTokenRegex = this._configuration.getValue(`language.${language}.tokenRegex`) as RegExp if (languageSpecificTokenRegex) { return RegExp(languageSpecificTokenRegex, "i") @@ -153,7 +149,7 @@ export class LanguageManager { } public getCompletionTriggerCharacters(language: string): string[] { - const languageSpecificTriggerChars = this._configuration.getValue(`language.${language}.completionTriggerCharacters`) + const languageSpecificTriggerChars = this._configuration.getValue(`language.${language}.completionTriggerCharacters`) as string[] if (languageSpecificTriggerChars) { return languageSpecificTriggerChars @@ -332,7 +328,7 @@ export class LanguageManager { } private async _simulateFakeLag(): Promise { - const delay = this._configuration.getValue("debug.fakeLag.languageServer") + const delay = this._configuration.getValue("debug.fakeLag.languageServer") as number if (!delay) { return } else { @@ -355,8 +351,8 @@ const logDebug = (args: any) => { let _languageManager: LanguageManager = null -export const activate = (): void => { - _languageManager = new LanguageManager() +export const activate = (configuration: Oni.Configuration, editorManager: Oni.EditorManager): void => { + _languageManager = new LanguageManager(configuration, editorManager) } export const getInstance = (): LanguageManager => { diff --git a/browser/src/index.tsx b/browser/src/index.tsx index be3f375169..0844cf6c5d 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -85,10 +85,11 @@ const start = async (args: string[]): Promise => { SharedNeovimInstance.activate(), UI.startEditors(parsedArgs._, Colors.getInstance(), configuration) ]) + const { editorManager } = await editorManagerPromise Performance.endMeasure("Oni.Start.Editors") const LanguageManager = await languageManagerPromise - LanguageManager.activate() + LanguageManager.activate(configuration, editorManager) const languageManager = LanguageManager.getInstance() const createLanguageClientsFromConfiguration = LanguageManager.createLanguageClientsFromConfiguration @@ -98,7 +99,6 @@ const start = async (args: string[]): Promise => { createLanguageClientsFromConfiguration(configuration.getValues()) - const { editorManager } = await editorManagerPromise const { inputManager } = await inputManagerPromise const AutoClosingPairs = await autoClosingPairsPromise diff --git a/browser/webpack.production.config.js b/browser/webpack.production.config.js index f2c34d46c8..7d42363ba1 100644 --- a/browser/webpack.production.config.js +++ b/browser/webpack.production.config.js @@ -13,10 +13,14 @@ const productionConfig = Object.assign({}, baseConfig, { new webpack.DefinePlugin({ "process.env.NODE_ENV":'"production"' }), + new webpack.optimize.CommonsChunkPlugin({ + name: "common", + async: true, + }), new BabiliPlugin(), new OptimizeJsPlugin({ sourceMap: false - }) + }), ], output: { path: path.join(__dirname, "..", "lib", "browser"), From 93a9dad96eb8d26789932954b759c079b2f54efd Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 15 Dec 2017 16:12:16 -0800 Subject: [PATCH 15/23] Add oni icon to repo --- images/oni-icon-no-border.svg | 160 ++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 images/oni-icon-no-border.svg diff --git a/images/oni-icon-no-border.svg b/images/oni-icon-no-border.svg new file mode 100644 index 0000000000..0599b73456 --- /dev/null +++ b/images/oni-icon-no-border.svg @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3d7090a1f191b48271e6e62dfe268c38ab8235de Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 15 Dec 2017 16:37:40 -0800 Subject: [PATCH 16/23] Refactor 'startEditors' method --- browser/src/Editor/NeovimEditor.tsx | 10 +++--- .../Services/{Language => }/Diagnostics.ts | 15 ++++---- .../src/Services/Language/HoverRequestor.ts | 2 +- browser/src/Services/Language/index.ts | 1 - browser/src/UI/index.tsx | 30 ---------------- browser/src/index.tsx | 17 +++++++--- browser/src/startEditors.ts | 34 +++++++++++++++++++ 7 files changed, 60 insertions(+), 49 deletions(-) rename browser/src/Services/{Language => }/Diagnostics.ts (69%) create mode 100644 browser/src/startEditors.ts diff --git a/browser/src/Editor/NeovimEditor.tsx b/browser/src/Editor/NeovimEditor.tsx index 0035a237e3..9908d789ed 100644 --- a/browser/src/Editor/NeovimEditor.tsx +++ b/browser/src/Editor/NeovimEditor.tsx @@ -29,11 +29,10 @@ import { Colors } from "./../Services/Colors" import { CallbackCommand, commandManager } from "./../Services/CommandManager" import { registerBuiltInCommands } from "./../Services/Commands" import { Completion } from "./../Services/Completion" -import { configuration, IConfigurationValues } from "./../Services/Configuration" +import {C Configuration } from "./../Services/Configuration" import { Errors } from "./../Services/Errors" -import { addInsertModeLanguageFunctionality, LanguageEditorIntegration, getInstance as getLanguageManagerInstance } from "./../Services/Language" +import { addInsertModeLanguageFunctionality, LanguageEditorIntegration, LanguageManager } from "./../Services/Language" import { ISyntaxHighlighter, NullSyntaxHighlighter, SyntaxHighlighter } from "./../Services/SyntaxHighlighting" -import { getThemeManagerInstance } from "./../Services/Themes" import { TypingPredictionManager } from "./../Services/TypingPredictionManager" import { workspace } from "./../Services/Workspace" @@ -101,8 +100,9 @@ export class NeovimEditor extends Editor implements IEditor { constructor( private _colors: Colors, - private _config = configuration, - private _themeManager = getThemeManagerInstance(), + private _config: Configuration, + private _languageManager: LanguageManager, + private _themeManager: ThemeManager, ) { super() diff --git a/browser/src/Services/Language/Diagnostics.ts b/browser/src/Services/Diagnostics.ts similarity index 69% rename from browser/src/Services/Language/Diagnostics.ts rename to browser/src/Services/Diagnostics.ts index faf8580df9..1d674ebb14 100644 --- a/browser/src/Services/Language/Diagnostics.ts +++ b/browser/src/Services/Diagnostics.ts @@ -6,14 +6,14 @@ import * as types from "vscode-languageserver-types" -import * as UI from "./../../UI" -import * as Selectors from "./../../UI/Selectors" +import * as UI from "./../UI" +import * as Selectors from "./../UI/Selectors" -import * as LanguageManager from "./LanguageManager" +import { LanguageManager, ILanguageServerNotificationResponse } from "./Language" -import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpers" +import * as Helpers from "./../Plugins/Api/LanguageClient/LanguageClientHelpers" -import * as Utility from "./../../Utility" +import * as Utility from "./../Utility" interface IPublishDiagnosticsParams { uri: string @@ -35,9 +35,8 @@ export class DiagnosticsDataSource { } } -export const listenForDiagnostics = () => { - const languageManager = LanguageManager.getInstance() - languageManager.subscribeToLanguageServerNotification("textDocument/publishDiagnostics", (args: LanguageManager.ILanguageServerNotificationResponse) => { +export const activate = (languageManager: LanguageManager) => { + languageManager.subscribeToLanguageServerNotification("textDocument/publishDiagnostics", (args: ILanguageServerNotificationResponse) => { const test = args.payload as IPublishDiagnosticsParams UI.Actions.setErrors(Helpers.unwrapFileUriPath(test.uri), "language-" + args.language, test.diagnostics) diff --git a/browser/src/Services/Language/HoverRequestor.ts b/browser/src/Services/Language/HoverRequestor.ts index dea3ccfe10..50034e48e5 100644 --- a/browser/src/Services/Language/HoverRequestor.ts +++ b/browser/src/Services/Language/HoverRequestor.ts @@ -11,7 +11,7 @@ import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpe import { LanguageManager } from "./LanguageManager" -import { DiagnosticsDataSource, IDiagnosticsDataSource } from "./Diagnostics" +import { DiagnosticsDataSource, IDiagnosticsDataSource } from "./../Diagnostics" export interface IHoverResult { hover: types.Hover diff --git a/browser/src/Services/Language/index.ts b/browser/src/Services/Language/index.ts index 2019f6bbed..328a6138f8 100644 --- a/browser/src/Services/Language/index.ts +++ b/browser/src/Services/Language/index.ts @@ -2,7 +2,6 @@ export * from "./addInsertModeLanguageFunctionality" export * from "./CodeAction" export * from "./Definition" export * from "./DefinitionRequestor" -export * from "./Diagnostics" export * from "./Edits" export * from "./FindAllReferences" export * from "./Formatting" diff --git a/browser/src/UI/index.tsx b/browser/src/UI/index.tsx index 2a45ee23b4..60de0aebac 100644 --- a/browser/src/UI/index.tsx +++ b/browser/src/UI/index.tsx @@ -21,18 +21,8 @@ import { reducer } from "./Reducer" import { getActiveDefinition } from "./selectors/DefinitionSelectors" import * as State from "./State" -import { Colors } from "./../Services/Colors" -import { commandManager } from "./../Services/CommandManager" -import { Configuration } from "./../Services/Configuration" -import { editorManager } from "./../Services/EditorManager" -import { ExplorerSplit } from "./../Services/Explorer/ExplorerSplit" import { focusManager } from "./../Services/FocusManager" -import { listenForDiagnostics } from "./../Services/Language" -import { SidebarSplit } from "./../Services/Sidebar" import { windowManager } from "./../Services/WindowManager" -import { workspace } from "./../Services/Workspace" - -import { NeovimEditor } from "./../Editor/NeovimEditor" import { createStore } from "./../Redux" @@ -78,30 +68,10 @@ export const render = (_state: State.IState): void => { , hostElement) } -export const startEditors = async (args: any, colors: Colors, configuration: Configuration): Promise => { - if (configuration.getValue("experimental.sidebar.enabled")) { - const leftDock = windowManager.getDock(2) - leftDock.addSplit(new SidebarSplit(colors)) - leftDock.addSplit(new ExplorerSplit(configuration, workspace, commandManager, editorManager)) - } - - const editor = new NeovimEditor(colors) - editorManager.setActiveEditor(editor) - windowManager.split(0, editor) - - await editor.init(args) -} - // Don't execute code that depends on DOM in unit-tests if (global["window"]) { // tslint:disable-line updateViewport() - // TODO: Why is this breaking? - window.setTimeout(() => { - listenForDiagnostics() - }) - window.addEventListener("resize", updateViewport) - document.body.addEventListener("click", () => focusManager.enforceFocus()) } diff --git a/browser/src/index.tsx b/browser/src/index.tsx index 0844cf6c5d..35cff1de62 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -23,10 +23,14 @@ const start = async (args: string[]): Promise => { const pluginManagerPromise = import("./Plugins/PluginManager") const themesPromise = import("./Services/Themes") const iconThemesPromise = import("./Services/IconThemes") + + const startEditorsPromise = import("./startEditors") + const sharedNeovimInstancePromise = import("./neovim/SharedNeovimInstance") const autoClosingPairsPromise = import("./Services/AutoClosingPairs") const browserWindowConfigurationSynchronizerPromise = import("./Services/BrowserWindowConfigurationSynchronizer") const colorsPromise = import("./Services/Colors") + const diagnosticsPromise = import("./Services/Diagnostics") const editorManagerPromise = import("./Services/EditorManager") const inputManagerPromise = import("./Services/InputManager") const languageManagerPromise = import("./Services/Language") @@ -79,20 +83,25 @@ const start = async (args: string[]): Promise => { const BrowserWindowConfigurationSynchronizer = await browserWindowConfigurationSynchronizerPromise BrowserWindowConfigurationSynchronizer.activate(configuration, Colors.getInstance()) + const LanguageManager = await languageManagerPromise + LanguageManager.activate(configuration, editorManager) + const languageManager = LanguageManager.getInstance() + Performance.startMeasure("Oni.Start.Editors") const SharedNeovimInstance = await sharedNeovimInstancePromise + const { startEditors } = await startEditorsPromise await Promise.all([ SharedNeovimInstance.activate(), - UI.startEditors(parsedArgs._, Colors.getInstance(), configuration) + startEditors(parsedArgs._, Colors.getInstance(), configuration, languageManager, Themes.getThemeManagerInstance()) ]) const { editorManager } = await editorManagerPromise Performance.endMeasure("Oni.Start.Editors") - const LanguageManager = await languageManagerPromise - LanguageManager.activate(configuration, editorManager) - const languageManager = LanguageManager.getInstance() const createLanguageClientsFromConfiguration = LanguageManager.createLanguageClientsFromConfiguration + const Diagnostics = await diagnosticsPromise + Diagnostics.activate(languageManager) + Performance.startMeasure("Oni.Start.Activate") const api = pluginManager.startApi() configuration.activate(api) diff --git a/browser/src/startEditors.ts b/browser/src/startEditors.ts new file mode 100644 index 0000000000..9db9dff752 --- /dev/null +++ b/browser/src/startEditors.ts @@ -0,0 +1,34 @@ +/** + * startEditors.ts + * + * Initialization for the core set of editors + */ + +import { NeovimEditor } from "./Editor/NeovimEditor" + +import { Colors } from "./Services/Colors" +import { commandManager } from "./Services/CommandManager" +import { Configuration } from "./Services/Configuration" +import { editorManager } from "./Services/EditorManager" +import { ExplorerSplit } from "./Services/Explorer/ExplorerSplit" +import { focusManager } from "./Services/FocusManager" +import { LanguageManager } from "./Services/Language" +import { SidebarSplit } from "./Services/Sidebar" +import { ThemeManager } from "./Services/Themes" +import { windowManager } from "./Services/WindowManager" +import { workspace } from "./Services/Workspace" + +export const startEditors = async (args: any, colors: Colors, configuration: Configuration, languageManager: LanguageManager, themeManager: ThemeManager): Promise => { + + if (configuration.getValue("experimental.sidebar.enabled")) { + const leftDock = windowManager.getDock(2) + leftDock.addSplit(new SidebarSplit(colors)) + leftDock.addSplit(new ExplorerSplit(configuration, workspace, commandManager, editorManager)) + } + + const editor = new NeovimEditor(colors, configuration, languageManager, themeManager) + editorManager.setActiveEditor(editor) + windowManager.split(0, editor) + + await editor.init(args) +} From 17f8197c52a4a868caac11d5632e4e1b91f986b6 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 15 Dec 2017 17:41:31 -0800 Subject: [PATCH 17/23] Continue removing global dependencies --- browser/src/Editor/NeovimEditor.tsx | 38 ++++++++++++++-------------- browser/src/index.tsx | 3 ++- browser/src/startEditors.ts | 1 - browser/webpack.production.config.js | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/browser/src/Editor/NeovimEditor.tsx b/browser/src/Editor/NeovimEditor.tsx index 9908d789ed..24711fd9ec 100644 --- a/browser/src/Editor/NeovimEditor.tsx +++ b/browser/src/Editor/NeovimEditor.tsx @@ -29,10 +29,11 @@ import { Colors } from "./../Services/Colors" import { CallbackCommand, commandManager } from "./../Services/CommandManager" import { registerBuiltInCommands } from "./../Services/Commands" import { Completion } from "./../Services/Completion" -import {C Configuration } from "./../Services/Configuration" +import { Configuration, IConfigurationValues } from "./../Services/Configuration" import { Errors } from "./../Services/Errors" import { addInsertModeLanguageFunctionality, LanguageEditorIntegration, LanguageManager } from "./../Services/Language" import { ISyntaxHighlighter, NullSyntaxHighlighter, SyntaxHighlighter } from "./../Services/SyntaxHighlighting" +import { ThemeManager } from "./../Services/Themes" import { TypingPredictionManager } from "./../Services/TypingPredictionManager" import { workspace } from "./../Services/Workspace" @@ -100,7 +101,7 @@ export class NeovimEditor extends Editor implements IEditor { constructor( private _colors: Colors, - private _config: Configuration, + private _configuration: Configuration, private _languageManager: LanguageManager, private _themeManager: ThemeManager, ) { @@ -112,7 +113,7 @@ export class NeovimEditor extends Editor implements IEditor { this._bufferManager = new BufferManager(this._neovimInstance) this._screen = new NeovimScreen() - this._hoverRenderer = new HoverRenderer(this, this._config) + this._hoverRenderer = new HoverRenderer(this, this._configuration) this._popupMenu = new NeovimPopupMenu( this._neovimInstance.onShowPopupMenu, @@ -151,7 +152,7 @@ export class NeovimEditor extends Editor implements IEditor { this._windowManager = new NeovimWindowManager(this._neovimInstance) this._neovimInstance.onYank.subscribe((yankInfo) => { - if (configuration.getValue("editor.clipboard.enabled")) { + if (this._configuration.getValue("editor.clipboard.enabled")) { clipboard.writeText(yankInfo.regcontents.join(require("os").EOL)) } }) @@ -163,7 +164,7 @@ export class NeovimEditor extends Editor implements IEditor { this._neovimInstance.onLeave.subscribe(() => { // TODO: Only leave if all editors are closed... - if (!configuration.getValue("debug.persistOnNeovimExit")) { + if (!this._configuration.getValue("debug.persistOnNeovimExit")) { remote.getCurrentWindow().close() } }) @@ -255,11 +256,10 @@ export class NeovimEditor extends Editor implements IEditor { addInsertModeLanguageFunctionality(this._cursorMovedI$, this._modeChanged$) - const textMateHighlightingEnabled = this._config.getValue("experimental.editor.textMateHighlighting.enabled") + const textMateHighlightingEnabled = this._configuration.getValue("experimental.editor.textMateHighlighting.enabled") this._syntaxHighlighter = textMateHighlightingEnabled ? new SyntaxHighlighter() : new NullSyntaxHighlighter() - const languageManager = getLanguageManagerInstance() - this._completion = new Completion(this, languageManager, configuration) + this._completion = new Completion(this, this._languageManager, this._configuration) this._completionMenu = new CompletionMenu() this._completion.onShowCompletionItems.subscribe((completions) => { @@ -278,7 +278,7 @@ export class NeovimEditor extends Editor implements IEditor { this._completion.commitItem(item) }) - this._languageIntegration = new LanguageEditorIntegration(this, this._config, languageManager) + this._languageIntegration = new LanguageEditorIntegration(this, this._configuration, this._languageManager) this._languageIntegration.onShowHover.subscribe((hover) => { this._hoverRenderer.showQuickInfo(hover.hover, hover.errors) @@ -308,8 +308,8 @@ export class NeovimEditor extends Editor implements IEditor { this._neovimInstance.autoCommands.executeAutoCommand("FocusGained") }) - this._onConfigChanged(this._config.getValues()) - this._config.onConfigurationChanged.subscribe((newValues: Partial) => this._onConfigChanged(newValues)) + this._onConfigChanged(this._configuration.getValues()) + this._configuration.onConfigurationChanged.subscribe((newValues: Partial) => this._onConfigChanged(newValues)) ipcRenderer.on("menu-item-click", (_evt: any, message: string) => { if (message.startsWith(":")) { @@ -387,7 +387,7 @@ export class NeovimEditor extends Editor implements IEditor { public async init(filesToOpen: string[]): Promise { const startOptions: INeovimStartOptions = { runtimePaths: pluginManager.getAllRuntimePaths(), - transport: configuration.getValue("experimental.neovim.transport"), + transport: this._configuration.getValue("experimental.neovim.transport"), } await this._neovimInstance.start(startOptions) @@ -396,7 +396,7 @@ export class NeovimEditor extends Editor implements IEditor { return } - VimConfigurationSynchronizer.synchronizeConfiguration(this._neovimInstance, this._config.getValues()) + VimConfigurationSynchronizer.synchronizeConfiguration(this._neovimInstance, this._configuration.getValues()) this._themeManager.onThemeChanged.subscribe(() => { const newTheme = this._themeManager.activeTheme @@ -465,7 +465,7 @@ export class NeovimEditor extends Editor implements IEditor { this._typingPredictionManager.clearAllPredictions() - if (newMode === "insert" && configuration.getValue("editor.typingPrediction")) { + if (newMode === "insert" && this._configuration.getValue("editor.typingPrediction")) { this._typingPredictionManager.enable() } else { this._typingPredictionManager.disable() @@ -533,9 +533,9 @@ export class NeovimEditor extends Editor implements IEditor { } private _onConfigChanged(newValues: Partial): void { - const fontFamily = this._config.getValue("editor.fontFamily") - const fontSize = addDefaultUnitIfNeeded(this._config.getValue("editor.fontSize")) - const linePadding = this._config.getValue("editor.linePadding") + const fontFamily = this._configuration.getValue("editor.fontFamily") + const fontSize = addDefaultUnitIfNeeded(this._configuration.getValue("editor.fontSize")) + const linePadding = this._configuration.getValue("editor.linePadding") UI.Actions.setFont(fontFamily, fontSize) this._neovimInstance.setFont(fontFamily, fontSize, linePadding) @@ -587,8 +587,8 @@ export class NeovimEditor extends Editor implements IEditor { } private async _onKeyDown(key: string): Promise { - if (configuration.getValue("debug.fakeLag.neovimInput")) { - await sleep(configuration.getValue("debug.fakeLag.neovimInput")) + if (this._configuration.getValue("debug.fakeLag.neovimInput")) { + await sleep(this._configuration.getValue("debug.fakeLag.neovimInput")) } await this._neovimInstance.input(key) diff --git a/browser/src/index.tsx b/browser/src/index.tsx index 35cff1de62..dac8896859 100644 --- a/browser/src/index.tsx +++ b/browser/src/index.tsx @@ -83,6 +83,8 @@ const start = async (args: string[]): Promise => { const BrowserWindowConfigurationSynchronizer = await browserWindowConfigurationSynchronizerPromise BrowserWindowConfigurationSynchronizer.activate(configuration, Colors.getInstance()) + const { editorManager } = await editorManagerPromise + const LanguageManager = await languageManagerPromise LanguageManager.activate(configuration, editorManager) const languageManager = LanguageManager.getInstance() @@ -94,7 +96,6 @@ const start = async (args: string[]): Promise => { SharedNeovimInstance.activate(), startEditors(parsedArgs._, Colors.getInstance(), configuration, languageManager, Themes.getThemeManagerInstance()) ]) - const { editorManager } = await editorManagerPromise Performance.endMeasure("Oni.Start.Editors") const createLanguageClientsFromConfiguration = LanguageManager.createLanguageClientsFromConfiguration diff --git a/browser/src/startEditors.ts b/browser/src/startEditors.ts index 9db9dff752..986b32bcc0 100644 --- a/browser/src/startEditors.ts +++ b/browser/src/startEditors.ts @@ -11,7 +11,6 @@ import { commandManager } from "./Services/CommandManager" import { Configuration } from "./Services/Configuration" import { editorManager } from "./Services/EditorManager" import { ExplorerSplit } from "./Services/Explorer/ExplorerSplit" -import { focusManager } from "./Services/FocusManager" import { LanguageManager } from "./Services/Language" import { SidebarSplit } from "./Services/Sidebar" import { ThemeManager } from "./Services/Themes" diff --git a/browser/webpack.production.config.js b/browser/webpack.production.config.js index 7d42363ba1..61af42eb25 100644 --- a/browser/webpack.production.config.js +++ b/browser/webpack.production.config.js @@ -14,8 +14,8 @@ const productionConfig = Object.assign({}, baseConfig, { "process.env.NODE_ENV":'"production"' }), new webpack.optimize.CommonsChunkPlugin({ - name: "common", async: true, + minChunks: 2, }), new BabiliPlugin(), new OptimizeJsPlugin({ From 772edce8d8358c83e3188b9696d974347b16305a Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 15 Dec 2017 17:49:54 -0800 Subject: [PATCH 18/23] Externalize msgpack-lite, react, and react-dom --- browser/webpack.debug.config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/browser/webpack.debug.config.js b/browser/webpack.debug.config.js index 4bc9f08777..18f14607ce 100644 --- a/browser/webpack.debug.config.js +++ b/browser/webpack.debug.config.js @@ -10,7 +10,10 @@ module.exports = { "vscode-textmate": "require('vscode-textmate')", "vscode-languageserver-types": "require('vscode-languageserver-types')", "keyboard-layout": "require('keyboard-layout')", - "gifshot": "require('gifshot')" + "gifshot": "require('gifshot')", + "msgpack-lite": "require('msgpack-lite')", + "react": "require('react')", + "react-dom": "require('react-dom')", }, resolve: { extensions: [".tsx", ".ts", ".js", ".less"] From 3ef5c44016d7d64fd1db6edf239d88258d98b75a Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 15 Dec 2017 17:53:56 -0800 Subject: [PATCH 19/23] Move some dependencies from dev -> production --- browser/webpack.debug.config.js | 1 + package.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/browser/webpack.debug.config.js b/browser/webpack.debug.config.js index 18f14607ce..49200c12b4 100644 --- a/browser/webpack.debug.config.js +++ b/browser/webpack.debug.config.js @@ -7,6 +7,7 @@ module.exports = { ], target: "electron-renderer", externals: { + "vscode-jsonrpc": "require('vscode-jsonrpc')", "vscode-textmate": "require('vscode-textmate')", "vscode-languageserver-types": "require('vscode-languageserver-types')", "keyboard-layout": "require('keyboard-layout')", diff --git a/package.json b/package.json index 23fbba784b..bae9a0e134 100644 --- a/package.json +++ b/package.json @@ -126,6 +126,8 @@ "oni-neovim-binaries": "0.1.0", "oni-ripgrep": "0.0.3", "oni-types": "0.0.4", + "react": "16.0.0", + "react-dom": "16.0.0", "redux-batched-subscribe": "^0.1.6", "shell-env": "^0.3.0", "typescript": "2.6.1", @@ -181,8 +183,6 @@ "oni-release-downloader": "0.0.8", "opencollective": "1.0.3", "optimize-js-plugin": "0.0.4", - "react": "16.0.0", - "react-dom": "16.0.0", "react-hot-loader": "1.3.1", "react-motion": "0.5.2", "react-redux": "5.0.6", From 0e8223e3f70766d535e0ebae6aea886e6cbbde21 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 15 Dec 2017 17:59:19 -0800 Subject: [PATCH 20/23] Fix lint issue --- browser/src/Services/Diagnostics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/src/Services/Diagnostics.ts b/browser/src/Services/Diagnostics.ts index 1d674ebb14..9076046eb6 100644 --- a/browser/src/Services/Diagnostics.ts +++ b/browser/src/Services/Diagnostics.ts @@ -9,7 +9,7 @@ import * as types from "vscode-languageserver-types" import * as UI from "./../UI" import * as Selectors from "./../UI/Selectors" -import { LanguageManager, ILanguageServerNotificationResponse } from "./Language" +import { ILanguageServerNotificationResponse, LanguageManager } from "./Language" import * as Helpers from "./../Plugins/Api/LanguageClient/LanguageClientHelpers" From 1c11ea61f2821e42dc08772ad12ddae18ff8c810 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 15 Dec 2017 18:21:22 -0800 Subject: [PATCH 21/23] Make sudo/shell-env async imports --- browser/src/Platform.ts | 2 +- browser/src/Plugins/Api/Process.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/src/Platform.ts b/browser/src/Platform.ts index de382d00b4..11cafdeccb 100644 --- a/browser/src/Platform.ts +++ b/browser/src/Platform.ts @@ -3,7 +3,6 @@ import * as fs from "fs" import * as os from "os" import * as path from "path" -import * as sudo from "sudo-prompt" export const isWindows = () => os.platform() === "win32" export const isMac = () => os.platform() === "darwin" @@ -33,6 +32,7 @@ export const addToPath = async () => { } const _runSudoCommand = async (command: string, options: any) => { + const sudo = await import("sudo-prompt") return new Promise(resolve => { sudo.exec(command, options, (error: Error, stdout: string, stderr: string) => { resolve({error, stdout, stderr}) diff --git a/browser/src/Plugins/Api/Process.ts b/browser/src/Plugins/Api/Process.ts index 1bc8a99529..a2676d2434 100644 --- a/browser/src/Plugins/Api/Process.ts +++ b/browser/src/Plugins/Api/Process.ts @@ -1,5 +1,4 @@ import * as ChildProcess from "child_process" -import * as shellEnv from "shell-env" import * as Platform from "./../../Platform" import { configuration } from "./../../Services/Configuration" @@ -24,6 +23,7 @@ const mergeSpawnOptions = async (originalSpawnOptions: ChildProcess.ExecOptions let existingPath: string try { + const shellEnv = await import("shell-env") const shellEnvironment = await shellEnv() process.env = { ...process.env, ...shellEnvironment } existingPath = process.env.Path || process.env.PATH From 9e6a5a60240380bb78b95f3b0802d8ebca9f2ab4 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Mon, 18 Dec 2017 18:53:30 -0800 Subject: [PATCH 22/23] Remove deleted CSS files --- browser/src/CSS.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/browser/src/CSS.ts b/browser/src/CSS.ts index ce364a5045..f354789109 100644 --- a/browser/src/CSS.ts +++ b/browser/src/CSS.ts @@ -13,11 +13,8 @@ export const activate = () => { require("./Services/Menu/Menu.less") require("./Services/Sidebar/Sidebar.less") - require("./UI/components/Cursor.less") - require("./UI/components/Definition.less") require("./UI/components/Error.less") require("./UI/components/InstallHelp.less") - require("./UI/components/Message.less") require("./UI/components/QuickInfo.less") require("./UI/components/StatusBar.less") require("./UI/components/Tabs.less") From c083a954b554aa10148c2da2a9d8b59cd2614771 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Mon, 18 Dec 2017 18:57:29 -0800 Subject: [PATCH 23/23] Use tsconfig.test.json for test files --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bd0fe76716..f8a198ed93 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "test:integration": "npm run build:test && mocha -t 30000 lib_test/test/CiTests.js", "test:stability": "npm run build:test && mocha -t 600000 --recursive lib_test/test/stability", "test:unit": "npm run test:unit:browser", - "test:unit:browser": "cd browser && tsc -p tsconfig.json && electron-mocha --renderer --require testHelpers.js --recursive ../lib_test/browser/test", + "test:unit:browser": "cd browser && tsc -p tsconfig.test.json && electron-mocha --renderer --require testHelpers.js --recursive ../lib_test/browser/test", "fix-lint": "npm run fix-lint:browser && npm run fix-lint:main && npm run fix-lint:test", "fix-lint:browser": "tslint --fix --project browser/tsconfig.json --config tslint.json && tslint --fix --project vim/core/oni-plugin-typescript/tsconfig.json --config tslint.json", "fix-lint:main": "tslint --fix --project main/tsconfig.json --config tslint.json",