Merge branch 'fix/jsdom-import' of https://github.com/germankrause/continue into germankrause-fix/jsdom-import

This commit is contained in:
Nate Sesti 2024-03-21 17:54:09 -07:00
commit b43c774101
5 changed files with 37 additions and 39 deletions

View file

@ -58,14 +58,6 @@ Continue is continuously improving, but a feature isn't complete until it is ref
#### VS Code
<!-- Pre-requisite: you will need `cargo` the rust package manager installed ([get it on rust-lang.org](https://www.rust-lang.org/tools/install)). -->
Pre-requisite: you have Node.js version 20.11.0 (LTS) or higher installed. [get it on https://nodejs.org](https://nodejs.org/en/download/
Alternatively, if you are using NVM (Node Version Manager), you can set the correct version of Node.js for this project by running the following command in the root of the project:
```bash
nvm use
Pre-requisite: You should have Node.js version 20.11.0 (LTS) or higher installed. You can get it on [nodejs.org](https://nodejs.org/en/download) or, if you are using NVM (Node Version Manager), you can set the correct version of Node.js for this project by running the following command in the root of the project:
```bash

View file

@ -94,9 +94,7 @@ export function chunkArticle(articleResult: Article): Chunk[] {
return chunks;
}
async function extractTitlesAndBodies(
html: string,
): Promise<ArticleComponent[]> {
function extractTitlesAndBodies(html: string): ArticleComponent[] {
const dom = new JSDOM(html);
const document = dom.window.document;
@ -117,13 +115,13 @@ async function extractTitlesAndBodies(
return result;
}
export async function stringToArticle(
export function stringToArticle(
url: string,
htmlContent: string,
html: string,
subpath: string,
): Promise<Article | undefined> {
): Article | undefined {
try {
const dom = new JSDOM(htmlContent);
const dom = new JSDOM(html);
let reader = new Readability(dom.window.document);
let article = reader.parse();
@ -131,7 +129,8 @@ export async function stringToArticle(
return undefined;
}
let article_components = await extractTitlesAndBodies(article.content);
let article_components = extractTitlesAndBodies(article.content);
return {
url,
subpath,
@ -144,9 +143,7 @@ export async function stringToArticle(
}
}
export async function pageToArticle(
page: PageData,
): Promise<Article | undefined> {
export function pageToArticle(page: PageData): Article | undefined {
try {
return stringToArticle(page.url, page.html, page.path);
} catch (err) {

View file

@ -29,7 +29,7 @@ export async function* indexDocs(
const articles: Article[] = [];
for await (const page of crawlPage(baseUrl)) {
const article = await pageToArticle(page);
const article = pageToArticle(page);
if (!article) continue;
articles.push(article);

View file

@ -326,6 +326,11 @@
resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@esbuild/darwin-arm64@0.19.12":
version "0.19.12"
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz"
integrity sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==
"@eslint-community/eslint-utils@^4.2.0":
version "4.4.0"
resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz"
@ -2662,6 +2667,11 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
fsevents@^2.3.2:
version "2.3.3"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
function-bind@^1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"

View file

@ -15,7 +15,6 @@ import { registerAllCodeLensProviders } from "../lang-server/codeLens";
import { setupRemoteConfigSync } from "../stubs/activation";
import { TabAutocompleteModel } from "../util/loadAutocompleteModel";
import { VsCodeWebviewProtocol } from "../webviewProtocol";
import { registerDebugTracker } from "../debug/debug";
export class VsCodeExtension {
private configHandler: ConfigHandler;
@ -49,26 +48,26 @@ export class VsCodeExtension {
// Config Handler with output channel
const outputChannel = vscode.window.createOutputChannel(
"Continue - LLM Prompt/Completion"
"Continue - LLM Prompt/Completion",
);
this.configHandler = new ConfigHandler(
this.ide,
Promise.resolve(ideSettings),
async (log: string) => {
outputChannel.appendLine(
"=========================================================================="
"==========================================================================",
);
outputChannel.appendLine(
"=========================================================================="
"==========================================================================",
);
outputChannel.append(log);
},
() => this.webviewProtocol?.request("configUpdate", undefined)
() => this.webviewProtocol?.request("configUpdate", undefined),
);
this.configHandler.reloadConfig();
this.verticalDiffManager = new VerticalPerLineDiffManager(
this.configHandler
this.configHandler,
);
this.extensionContext = context;
this.tabAutocompleteModel = new TabAutocompleteModel(this.configHandler);
@ -78,7 +77,7 @@ export class VsCodeExtension {
this.ide,
this.windowId,
this.extensionContext,
this.verticalDiffManager
this.verticalDiffManager,
);
setupRemoteConfigSync(
@ -92,14 +91,14 @@ export class VsCodeExtension {
this.sidebar,
{
webviewOptions: { retainContextWhenHidden: true },
}
)
},
),
);
this.webviewProtocol = this.sidebar.webviewProtocol;
// Indexing + pause token
const indexingPauseToken = new PauseToken(
context.globalState.get<boolean>("continue.indexingPaused") === true
context.globalState.get<boolean>("continue.indexingPaused") === true,
);
this.webviewProtocol.on("index/setPaused", (msg) => {
context.globalState.update("continue.indexingPaused", msg.data);
@ -110,14 +109,14 @@ export class VsCodeExtension {
this.indexer = new CodebaseIndexer(
this.configHandler,
this.ide,
indexingPauseToken
indexingPauseToken,
);
// CodeLens
registerAllCodeLensProviders(
context,
this.diffManager,
this.verticalDiffManager.editorToVerticalDiffCodeLens
this.verticalDiffManager.editorToVerticalDiffCodeLens,
);
// Tab autocomplete
@ -132,9 +131,9 @@ export class VsCodeExtension {
new ContinueCompletionProvider(
this.configHandler,
this.ide,
this.tabAutocompleteModel
)
)
this.tabAutocompleteModel,
),
),
);
// Commands
@ -145,7 +144,7 @@ export class VsCodeExtension {
this.sidebar,
this.configHandler,
this.diffManager,
this.verticalDiffManager
this.verticalDiffManager,
);
registerDebugTracker(this.webviewProtocol, this.ide);
@ -196,7 +195,7 @@ export class VsCodeExtension {
}
});
}
})
}),
);
// Register a content provider for the readonly virtual documents
@ -214,8 +213,8 @@ export class VsCodeExtension {
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(
VsCodeExtension.continueVirtualDocumentScheme,
documentContentProvider
)
documentContentProvider,
),
);
}