diff --git a/packages/vscode-typescript-repl/icon.png b/packages/vscode-typescript-repl/icon.png new file mode 100644 index 0000000..6484141 Binary files /dev/null and b/packages/vscode-typescript-repl/icon.png differ diff --git a/packages/vscode-typescript-repl/icon_square.png b/packages/vscode-typescript-repl/icon_square.png new file mode 100644 index 0000000..809b1f9 Binary files /dev/null and b/packages/vscode-typescript-repl/icon_square.png differ diff --git a/packages/vscode-typescript-repl/package.json b/packages/vscode-typescript-repl/package.json index bab08a1..19333d9 100644 --- a/packages/vscode-typescript-repl/package.json +++ b/packages/vscode-typescript-repl/package.json @@ -2,7 +2,8 @@ "name": "vscode-typescript-repl", "displayName": "TypeScript REPL", "description": "Run TypeScript instantly.", - "version": "0.0.4", + "version": "0.0.6", + "icon": "icon_square.png", "engines": { "vscode": "^1.81.0" }, @@ -53,11 +54,7 @@ "package:test": "npm version prerelease --no-workspaces-update --preid alpha && yarn package" }, "dependencies": { - "@effect/data": "^0.18.3", - "@effect/io": "^0.39.0", - "@effect/schema": "^0.34.0", "@swc/core": "^1.3.83", - "@types/ramda": "^0.29.3", "pirates": "^4.0.6", "ramda": "^0.29.0", "swc-ts-repl-transpile": "workspace:^", @@ -67,6 +64,7 @@ "devDependencies": { "@types/mocha": "^10.0.1", "@types/node": "16.x", + "@types/ramda": "^0.29.9", "@types/vscode": "^1.81.0", "@typescript-eslint/eslint-plugin": "^6.4.1", "@typescript-eslint/parser": "^6.4.1", @@ -81,8 +79,12 @@ "bugs": { "url": "https://github.com/alex-dixon/vscode-typescript-repl/issues" }, - "homepage": "https://github.com/alex-dixon/vscode-typescript-repl#readme", - "keywords": [], - "author": "", - "license": "ISC" + "homepage": "https://github.com/alex-dixon/vscode-typescript-repl", + "keywords": [ + "vscode", + "typescript", + "repl" + ], + "author": "Alex Dixon ", + "license": "MIT" } diff --git a/packages/vscode-typescript-repl/src/extension.ts b/packages/vscode-typescript-repl/src/extension.ts index c68800b..56f8fd4 100644 --- a/packages/vscode-typescript-repl/src/extension.ts +++ b/packages/vscode-typescript-repl/src/extension.ts @@ -4,6 +4,7 @@ import {logger} from "./logger"; import {createREPL, evaluate, repls} from "./repl"; import * as path from 'node:path' import * as vscode from 'vscode'; +import { EventEmitter } from 'node:stream'; let myREPL = createREPL({name: 'test-repl-id'}) let chan = vscode.window.createOutputChannel("typescript-repl") @@ -74,25 +75,43 @@ export function activate(context: vscode.ExtensionContext) { }) } + + chan.appendLine(text + " =>") + const result = await evaluate({ code: text, filename: currentlyOpenTabFilePath, replId: myREPL.id, - __dirname: currentlyOpenTabDirname - }, undefined) - - if (result.type === 'error') { - vscode.window.showInformationMessage(result.text); - chan.appendLine(result.text) - } else if (result.type === 'print') { - chan.appendLine(result.result) - // TODO. This is annoying because it forces the user to look at the panel...It looks like it doesn't show up otherwise though - chan.show(true) - // vscode.window.showInformationMessage(result.result); - } else { - console.error(result) - throw new Error("Unhandled result") - } + __dirname: currentlyOpenTabDirname, + }, { + send: (topic:string, message:any)=> { + logger.debug("Recieved", topic, message) + if (topic==='repl:output') { + if (message.type==='error') { + chan.appendLine(message.text) + } + if (message.type==='print') { + // if (message.input) { + // chan.appendLine(message.input.code + " =>") + // } + chan.appendLine(message.result) + chan.show(true) + } + } + }}) + + // if (result.type === 'error') { + // vscode.window.showInformationMessage(result.text); + // chan.appendLine(result.text) + // } else if (result.type === 'print') { + // chan.appendLine(result.result) + // // TODO. This is annoying because it forces the user to look at the panel...It looks like it doesn't show up otherwise though + // chan.show(true) + // // vscode.window.showInformationMessage(result.result); + // } else { + // console.error(result) + // throw new Error("Unhandled result") + // } } catch (e) { console.error(e) vscode.window.showInformationMessage(e.toString()); diff --git a/packages/vscode-typescript-repl/src/repl.ts b/packages/vscode-typescript-repl/src/repl.ts index 0e50d78..cf6ed0a 100644 --- a/packages/vscode-typescript-repl/src/repl.ts +++ b/packages/vscode-typescript-repl/src/repl.ts @@ -188,7 +188,8 @@ const print = (x: unknown) => const api = { emit: (socket: any, topic: any, payload: any) => { - console.log("emit", {socket, topic, payload}) + socket?.send(topic,payload) + // console.log("emit", {socket, topic, payload}) }, broadcast: (topic: string, payload: any) => { console.log("broadcast", topic, payload) @@ -346,7 +347,7 @@ export const evaluate = async (args: EvaluateInput, socket: unknown): Promise print(x)).join(" "), + result: args.map((x) => typeof x === "string" ? x : print(x)).join(" "), filename: filenameOrNamespace, // todo. view should just print this absent input info input: {}, @@ -406,7 +407,22 @@ export const evaluate = async (args: EvaluateInput, socket: unknown): Promise