diff --git a/.github/workflows/new-pull-request-comment.yml b/.github/workflows/new-pull-request-comment.yml index 4527c8f56f3..a2509f9acac 100644 --- a/.github/workflows/new-pull-request-comment.yml +++ b/.github/workflows/new-pull-request-comment.yml @@ -29,7 +29,7 @@ jobs: | JSON, structs, primitives and collections | `@hasanaburayyan` | Platforms and plugins | `@hasanaburayyan` | Frontend resources (website, react, etc) | `@tsuf239` - | Language design | `@eladb` + | Language design | `@chriscbr` | VSCode extension and language server | `@markmcculloh` | Compiler architecture, inflights, lifting | `@yoav-steinberg` | Wing Testing Framework | `@tsuf239` diff --git a/apps/vscode-wing/.projen/deps.json b/apps/vscode-wing/.projen/deps.json index 87de4c79094..24b6d81e897 100644 --- a/apps/vscode-wing/.projen/deps.json +++ b/apps/vscode-wing/.projen/deps.json @@ -40,16 +40,6 @@ "name": "@vscode/vsce", "type": "build" }, - { - "name": "@wingconsole/app", - "version": "workspace:^", - "type": "build" - }, - { - "name": "@wingconsole/server", - "version": "workspace:^", - "type": "build" - }, { "name": "eslint-config-prettier", "type": "build" diff --git a/apps/vscode-wing/.projenrc.ts b/apps/vscode-wing/.projenrc.ts index 2907435a702..bfa1bc0a95f 100644 --- a/apps/vscode-wing/.projenrc.ts +++ b/apps/vscode-wing/.projenrc.ts @@ -67,8 +67,6 @@ const project = new TypeScriptAppProject({ "@vscode/vsce", "@types/node-fetch", "@types/ws", - "@wingconsole/app@workspace:^", - "@wingconsole/server@workspace:^", "winglang@workspace:^", ], }); @@ -135,61 +133,14 @@ const contributes: VSCodeExtensionContributions = { dark: "resources/icon-dark.svg", }, }, - { - command: "wing.openFile", - title: "Open source file", - icon: { - light: "resources/icon-light.svg", - dark: "resources/icon-dark.svg", - }, - }, - { - command: "wingConsole.openResource", - title: "Open resource", - }, - { - command: "wingConsole.runTest", - title: "Run test", - icon: { - light: "resources/play-light.svg", - dark: "resources/play-dark.svg", - }, - }, - { - command: "wingConsole.runAllTests", - title: "Run all tests", - icon: { - light: "resources/play-all-light.svg", - dark: "resources/play-all-dark.svg", - }, - }, ], menus: { "editor/title": [ { - when: "resourceLangId == wing && activeWebviewPanelId != 'wing.console'", + when: "resourceLangId == wing", command: "wing.openConsole", group: "navigation", }, - { - when: "resourceLangId != wing && activeWebviewPanelId == 'wing.console'", - command: "wing.openFile", - group: "navigation", - }, - ], - "view/item/context": [ - { - command: "wingConsole.runTest", - when: "view == consoleTestsExplorer", - group: "inline", - }, - ], - "explorer/context": [ - { - command: "wingConsole.runAllTests", - when: "view == consoleTestsExplorer", - group: "inline", - }, ], }, configuration: [ @@ -204,22 +155,6 @@ const contributes: VSCodeExtensionContributions = { }, }, ], - views: { - explorer: [ - { - id: "consoleExplorer", - name: "Wing Resources", - }, - { - id: "consoleTestsExplorer", - name: "Wing Tests", - }, - { - id: "consoleEndpointsExplorer", - name: "Wing Endpoints", - }, - ], - }, }; project.addFields({ diff --git a/apps/vscode-wing/package.json b/apps/vscode-wing/package.json index db78d4e1169..6b051d72b71 100644 --- a/apps/vscode-wing/package.json +++ b/apps/vscode-wing/package.json @@ -36,8 +36,6 @@ "@typescript-eslint/eslint-plugin": "^5", "@typescript-eslint/parser": "^5", "@vscode/vsce": "^2.21.0", - "@wingconsole/app": "workspace:^", - "@wingconsole/server": "workspace:^", "eslint": "^8", "eslint-config-prettier": "^8.10.0", "eslint-import-resolver-node": "^0.3.9", @@ -137,61 +135,14 @@ "light": "resources/icon-light.svg", "dark": "resources/icon-dark.svg" } - }, - { - "command": "wing.openFile", - "title": "Open source file", - "icon": { - "light": "resources/icon-light.svg", - "dark": "resources/icon-dark.svg" - } - }, - { - "command": "wingConsole.openResource", - "title": "Open resource" - }, - { - "command": "wingConsole.runTest", - "title": "Run test", - "icon": { - "light": "resources/play-light.svg", - "dark": "resources/play-dark.svg" - } - }, - { - "command": "wingConsole.runAllTests", - "title": "Run all tests", - "icon": { - "light": "resources/play-all-light.svg", - "dark": "resources/play-all-dark.svg" - } } ], "menus": { "editor/title": [ { - "when": "resourceLangId == wing && activeWebviewPanelId != 'wing.console'", + "when": "resourceLangId == wing", "command": "wing.openConsole", "group": "navigation" - }, - { - "when": "resourceLangId != wing && activeWebviewPanelId == 'wing.console'", - "command": "wing.openFile", - "group": "navigation" - } - ], - "view/item/context": [ - { - "command": "wingConsole.runTest", - "when": "view == consoleTestsExplorer", - "group": "inline" - } - ], - "explorer/context": [ - { - "command": "wingConsole.runAllTests", - "when": "view == consoleTestsExplorer", - "group": "inline" } ] }, @@ -205,23 +156,7 @@ } } } - ], - "views": { - "explorer": [ - { - "id": "consoleExplorer", - "name": "Wing Resources" - }, - { - "id": "consoleTestsExplorer", - "name": "Wing Tests" - }, - { - "id": "consoleEndpointsExplorer", - "name": "Wing Endpoints" - } - ] - } + ] }, "volta": { "extends": "../../package.json" diff --git a/apps/vscode-wing/resources/icon-dark.svg b/apps/vscode-wing/resources/icon-dark.svg deleted file mode 100644 index a9aec13f73f..00000000000 --- a/apps/vscode-wing/resources/icon-dark.svg +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/apps/vscode-wing/resources/resource-icons/dark/archive-box.svg b/apps/vscode-wing/resources/resource-icons/dark/archive-box.svg deleted file mode 100644 index f6ef06fab73..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/archive-box.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/beaker.svg b/apps/vscode-wing/resources/resource-icons/dark/beaker.svg deleted file mode 100644 index c45c483c366..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/beaker.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/bolt.svg b/apps/vscode-wing/resources/resource-icons/dark/bolt.svg deleted file mode 100644 index 61574e4aee3..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/bolt.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/calculator.svg b/apps/vscode-wing/resources/resource-icons/dark/calculator.svg deleted file mode 100644 index d79e9726463..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/calculator.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/clock.svg b/apps/vscode-wing/resources/resource-icons/dark/clock.svg deleted file mode 100644 index 87eab2dc2dc..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/clock.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/cloud.svg b/apps/vscode-wing/resources/resource-icons/dark/cloud.svg deleted file mode 100644 index 4eb9e708fbb..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/cloud.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/cube.svg b/apps/vscode-wing/resources/resource-icons/dark/cube.svg deleted file mode 100644 index 8ce57410c00..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/cube.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/globe-alt.svg b/apps/vscode-wing/resources/resource-icons/dark/globe-alt.svg deleted file mode 100644 index ab078d2abb6..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/globe-alt.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/megaphone.svg b/apps/vscode-wing/resources/resource-icons/dark/megaphone.svg deleted file mode 100644 index f5c85040fe1..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/megaphone.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/queue-list.svg b/apps/vscode-wing/resources/resource-icons/dark/queue-list.svg deleted file mode 100644 index 7eec9855d33..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/queue-list.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/dark/redis.svg b/apps/vscode-wing/resources/resource-icons/dark/redis.svg deleted file mode 100644 index 66e31bd3336..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/redis.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - diff --git a/apps/vscode-wing/resources/resource-icons/dark/table-cells.svg b/apps/vscode-wing/resources/resource-icons/dark/table-cells.svg deleted file mode 100644 index 3902cf36eb9..00000000000 --- a/apps/vscode-wing/resources/resource-icons/dark/table-cells.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/archive-box.svg b/apps/vscode-wing/resources/resource-icons/light/archive-box.svg deleted file mode 100644 index 897ecf080e6..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/archive-box.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/beaker.svg b/apps/vscode-wing/resources/resource-icons/light/beaker.svg deleted file mode 100644 index 6bd47ac6aa2..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/beaker.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/bolt.svg b/apps/vscode-wing/resources/resource-icons/light/bolt.svg deleted file mode 100644 index 52b44d7d5b1..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/bolt.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/calculator.svg b/apps/vscode-wing/resources/resource-icons/light/calculator.svg deleted file mode 100644 index f8c51446893..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/calculator.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/clock.svg b/apps/vscode-wing/resources/resource-icons/light/clock.svg deleted file mode 100644 index f9ade369484..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/clock.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/cloud.svg b/apps/vscode-wing/resources/resource-icons/light/cloud.svg deleted file mode 100644 index 6ca053e0754..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/cloud.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/cube.svg b/apps/vscode-wing/resources/resource-icons/light/cube.svg deleted file mode 100644 index 7bd64203b32..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/cube.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/globe-alt.svg b/apps/vscode-wing/resources/resource-icons/light/globe-alt.svg deleted file mode 100644 index 4733d467555..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/globe-alt.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/megaphone.svg b/apps/vscode-wing/resources/resource-icons/light/megaphone.svg deleted file mode 100644 index 8d077b760b5..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/megaphone.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/queue-list.svg b/apps/vscode-wing/resources/resource-icons/light/queue-list.svg deleted file mode 100644 index fc0f71ee8d4..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/queue-list.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/resources/resource-icons/light/redis.svg b/apps/vscode-wing/resources/resource-icons/light/redis.svg deleted file mode 100644 index 930dc657380..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/redis.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - diff --git a/apps/vscode-wing/resources/resource-icons/light/table-cells.svg b/apps/vscode-wing/resources/resource-icons/light/table-cells.svg deleted file mode 100644 index eedec1524f4..00000000000 --- a/apps/vscode-wing/resources/resource-icons/light/table-cells.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/vscode-wing/src/console/console-manager.ts b/apps/vscode-wing/src/console/console-manager.ts deleted file mode 100644 index e0322d705f0..00000000000 --- a/apps/vscode-wing/src/console/console-manager.ts +++ /dev/null @@ -1,349 +0,0 @@ -import { - window, - WebviewPanel, - commands, - TreeView, - ViewColumn, - Uri, - ExtensionContext, - Position, - Range, -} from "vscode"; - -import { - EndpointItem, - EndpointsExplorerProvider, -} from "./explorer-providers/EndpointsExplorerProvider"; -import { - ResourceItem, - ResourcesExplorerProvider, -} from "./explorer-providers/ResourcesExplorerProvider"; -import { - TestItem, - TestsExplorerProvider, -} from "./explorer-providers/TestsExplorerProvider"; -import { type Client } from "./services/client"; -import { VIEW_TYPE_CONSOLE } from "../constants"; -import { Loggers } from "../logging"; - -export interface ConsoleInstance { - id: string; - wingfile: string; - url: string; - client: Client; - onDidClose: () => void; -} - -export interface ConsoleManager { - addInstance: (instance: ConsoleInstance) => Promise; - getInstance: (instanceId: string) => ConsoleInstance | undefined; - closeInstance: (instanceId: string) => void; - setActiveInstance: (instanceId: string) => Promise; - activeInstances: () => boolean; - getActiveInstanceId: () => string | undefined; - stopAll: () => Promise; -} - -export const createConsoleManager = ( - context: ExtensionContext -): ConsoleManager => { - const instances: Record = {}; - const resourcesExplorer = new ResourcesExplorerProvider(); - const testsExplorer = new TestsExplorerProvider(); - const endpointsExplorer = new EndpointsExplorerProvider(); - - let activeInstanceId: string | undefined; - let webviewPanel: WebviewPanel | undefined; - let explorerView: TreeView | undefined; - let testsExplorerView: TreeView | undefined; - let endpointsExplorerView: TreeView | undefined; - - let timeout: NodeJS.Timeout | undefined; - let logsTimestamp: number = 0; - - const registerCommands = () => { - commands.registerCommand("wingConsole.openResource", async (resourceId) => { - if (!activeInstanceId) { - return; - } - const activePanel = getInstance(activeInstanceId); - if (!activePanel) { - return; - } - await activePanel.client.setSelectedNode(resourceId); - }); - - commands.registerCommand("wingConsole.runTest", async (test: TestItem) => { - if (!activeInstanceId) { - return; - } - const activePanel = getInstance(activeInstanceId); - if (!activePanel) { - return; - } - const tests = testsExplorer.getTests(); - testsExplorer.update( - tests.map((testItem) => { - if (testItem.id === test.id) { - return { - ...test, - status: "running", - }; - } - return testItem; - }) - ); - await activePanel.client.runTest(test.id); - }); - - commands.registerCommand("wingConsole.runAllTests", async () => { - if (!activeInstanceId) { - return; - } - const activePanel = getInstance(activeInstanceId); - if (!activePanel) { - return; - } - const tests = testsExplorer.getTests(); - testsExplorer.update( - tests.map((testItem) => { - return { - ...testItem, - status: "running", - }; - }) - ); - await activePanel.client.runAllTests(); - }); - }; - - const updateLogs = async (instance: ConsoleInstance) => { - const logs = await instance.client.getLogs({ time: logsTimestamp }); - - logs.forEach((log) => { - Loggers.console.appendLine(`[${log.level}] ${log.message}`); - }); - logsTimestamp = Date.now(); - }; - - const getTheme = () => { - const theme = window.activeColorTheme.kind; - if (theme === 1) { - return "light"; - } - return "dark"; - }; - - const getInstance = (instanceId: string) => { - if (!instanceId) { - return; - } - return instances[instanceId]; - }; - - const addInstance = async (instance: ConsoleInstance) => { - Loggers.console.appendLine( - `Wing Console is running at http://${instance.url}` - ); - - instance.client.onInvalidateQuery({ - onData: async (key) => { - if (activeInstanceId !== instance.id) { - return; - } - if (timeout) { - clearTimeout(timeout); - } - timeout = setTimeout(async () => { - if (!key || key === "app.logs") { - await updateLogs(instance); - } - resourcesExplorer.update(await instance.client.listResources()); - testsExplorer.update(await instance.client.listTests()); - endpointsExplorer.update(await instance.client.listEndpoints()); - }, 300); - }, - onError: (err) => { - Loggers.console.appendLine(err); - }, - }); - - instance.client.onOpenFileInEditor({ - onData: async (data) => { - const path = data?.path; - const line = data?.line - 1 || 0; - const column = data?.column || 0; - - const openEditor = window.visibleTextEditors.find((editor) => { - return editor.document.uri.fsPath === path; - }); - - if (!openEditor || !openEditor.viewColumn) { - await commands.executeCommand( - "vscode.open", - Uri.file(path), - new Position(line, column) - ); - return; - } - - await commands.executeCommand("workbench.action.focusFirstEditorGroup"); - for (let i = 0; i < openEditor.viewColumn - 1; i++) { - await commands.executeCommand("workbench.action.focusNextGroup"); - } - await window.showTextDocument(openEditor.document, { - selection: new Range( - new Position(line, column), - new Position(line, column) - ), - }); - }, - onError: (err) => { - Loggers.console.appendLine(err); - }, - }); - - instances[instance.id] = instance; - - await setActiveInstance(instance.id); - }; - - const setActiveInstance = async (instanceId: string) => { - const instance = getInstance(instanceId); - if (!instance) { - return; - } - - if (!webviewPanel) { - webviewPanel = window.createWebviewPanel( - VIEW_TYPE_CONSOLE, - `Console`, - ViewColumn.Beside, - { - enableScripts: true, - enableCommandUris: true, - } - ); - - webviewPanel.iconPath = { - light: Uri.joinPath( - context.extensionUri, - "resources", - "icon-light.svg" - ), - dark: Uri.joinPath(context.extensionUri, "resources", "icon-dark.svg"), - }; - - webviewPanel.onDidDispose(async () => { - resourcesExplorer.clear(); - testsExplorer.clear(); - endpointsExplorer.clear(); - webviewPanel = undefined; - activeInstanceId = undefined; - - Object.keys(instances).forEach(async (id) => { - await closeInstance(id); - }); - }); - Loggers.console.show(); - } - - webviewPanel.title = `${instance.wingfile} - [console]`; - webviewPanel.webview.html = ` - - - - - - - - -