From b6f71f6c4a861bc9a8707a8e429a06f65667112a Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Mon, 25 Mar 2024 16:37:04 -0400 Subject: [PATCH] Try building dist --- package.json | 2 ++ src/codeium.ts | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index e14ea19..695b7fd 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "pages": "vite build", "build": "tsc --build" }, + "main": "./dist/plugin.js", + "types": "./dist/plugin.d.ts", "keywords": [ "codemirror", "typescript", diff --git a/src/codeium.ts b/src/codeium.ts index ed6cc4b..cded469 100644 --- a/src/codeium.ts +++ b/src/codeium.ts @@ -2,6 +2,7 @@ import { createPromiseClient } from "@connectrpc/connect"; import { LanguageServerService } from "./api/proto/exa/language_server_pb/language_server_connect.js"; import { createConnectTransport } from "@connectrpc/connect-web"; import { Language } from "./api/proto/exa/codeium_common_pb/codeium_common_pb.js"; +import { GetCompletionsResponse } from "./api/proto/exa/language_server_pb/language_server_pb.js"; // This is the same as the monaco editor example const EDITOR_API_KEY = "d49954eb-cfba-4992-980f-d8fb37f0e942"; @@ -22,7 +23,7 @@ export async function getCodeiumCompletions({ text: string; cursorOffset: number; }) { - const completions = await client.getCompletions( + const completions = (await client.getCompletions( { metadata: { ideName: "web", @@ -53,21 +54,22 @@ export async function getCodeiumCompletions({ Authorization: `Basic ${EDITOR_API_KEY}-${sessionId}`, }, }, - ); + // TODO: why doesn't this work by default? + )) as GetCompletionsResponse; - const parts = completions.completionItems[0].completionParts - .filter((part) => { + const parts = completions.completionItems[0]!.completionParts.filter( + (part) => { // Type 3 overwrites existing text. Maybe we need this eventually, // but not right now and it usually is duplicative. return part.type !== 3; - }) - .map((part) => { - return { - ...part, - offset: Number(part.offset), - text: part.type === 2 ? `\n${part.text}` : part.text, - }; - }); + }, + ).map((part) => { + return { + ...part, + offset: Number(part.offset), + text: part.type === 2 ? `\n${part.text}` : part.text, + }; + }); return parts; }