diff --git a/.eslintignore b/.eslintignore index 8424dce28..f0bf621b6 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,5 @@ dev/*.js -src/lib/**/*.* +src/**/*.* types/**/*.ts resources/**/*.js out diff --git a/.madgerc b/.madgerc new file mode 100644 index 000000000..4a7c7253b --- /dev/null +++ b/.madgerc @@ -0,0 +1,7 @@ +{ + "detectiveOptions": { + "ts": { + "skipTypeImports": true + } + } +} \ No newline at end of file diff --git a/.vscodeignore b/.vscodeignore index 7552922bc..a89b6ecb2 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -6,10 +6,7 @@ out/resources/ out/snippets/ out/test/ test/ -src/*.* -src/components/ -src/lib/**/*.ts -src/providers/ +src/**/*.ts samples/ types/ viewer/**/*.ts diff --git a/dev/editviewer.py b/dev/editviewer.py index fe16c0385..b9837ca98 100644 --- a/dev/editviewer.py +++ b/dev/editviewer.py @@ -13,7 +13,7 @@ line.replace('''PDF.js viewer''', '''\n PDF.js viewer''') .replace('''''', '''\n ''') .replace('''''', '''''') - .replace('''''', '''''') + .replace('''''', '''\n ''') ) with open(args.web + '/viewer.mjs', 'rt', encoding='utf-8') as fin: diff --git a/package-lock.json b/package-lock.json index cce8e4ef2..72b64ae9b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "latex-utensils": "6.2.0", "mathjax-full": "3.2.2", "micromatch": "4.0.5", - "pdfjs-dist": "^4.0.189", + "pdfjs-dist": "4.0.189", "tmp": "0.2.1", "workerpool": "8.0.0", "ws": "8.14.2" diff --git a/package.json b/package.json index 12c4b9894..f506a06c9 100644 --- a/package.json +++ b/package.json @@ -2576,7 +2576,7 @@ "latex-utensils": "6.2.0", "mathjax-full": "3.2.2", "micromatch": "4.0.5", - "pdfjs-dist": "^4.0.189", + "pdfjs-dist": "4.0.189", "tmp": "0.2.1", "workerpool": "8.0.0", "ws": "8.14.2" diff --git a/src/components/builder.ts b/src/compile/build.ts similarity index 98% rename from src/components/builder.ts rename to src/compile/build.ts index 96ad99319..65596e0a3 100644 --- a/src/components/builder.ts +++ b/src/compile/build.ts @@ -3,11 +3,11 @@ import * as path from 'path' import * as fs from 'fs' import * as cp from 'child_process' import * as cs from 'cross-spawn' -import * as lw from '../lw' +import { lw } from '../lw' import { replaceArgumentPlaceholders } from '../utils/utils' -import { AutoBuildInitiated, AutoCleaned, BuildDone } from './eventbus' -import { getLogger } from './logger' -import { parser } from './parser' +import { AutoBuildInitiated, AutoCleaned, BuildDone } from '../core/event-bus' +import { getLogger } from '../utils/logging/logger' +import { parser } from '../parse/parser' const logger = getLogger('Builder') @@ -33,8 +33,8 @@ export class Builder { private readonly MAX_PRINT_LINE = '10000' constructor() { - lw.cacher.src.onChange(filePath => this.buildOnFileChanged(filePath)) - lw.cacher.bib.onChange(filePath => this.buildOnFileChanged(filePath, true)) + lw.watcher.src.onChange(filePath => this.buildOnFileChanged(filePath)) + lw.watcher.bib.onChange(filePath => this.buildOnFileChanged(filePath, true)) // Check if pdflatex is available, and is MikTeX distro try { const pdflatexVersion = cp.execSync('pdflatex --version') @@ -104,9 +104,9 @@ export class Builder { } const configuration = vscode.workspace.getConfiguration('latex-workshop', vscode.Uri.file(file)) if (!bibChanged && lw.manager.localRootFile && configuration.get('latex.rootFile.useSubFile')) { - return lw.commander.build(true, lw.manager.localRootFile, lw.manager.rootFileLanguageId) + return lw.commands.build(true, lw.manager.localRootFile, lw.manager.rootFileLanguageId) } else { - return lw.commander.build(true, lw.manager.rootFile, lw.manager.rootFileLanguageId) + return lw.commands.build(true, lw.manager.rootFile, lw.manager.rootFileLanguageId) } } diff --git a/src/providers/bibtexcompletion.ts b/src/completion/bibtex.ts similarity index 98% rename from src/providers/bibtexcompletion.ts rename to src/completion/bibtex.ts index 59171bad4..43a5aa0a4 100644 --- a/src/providers/bibtexcompletion.ts +++ b/src/completion/bibtex.ts @@ -1,9 +1,9 @@ import * as vscode from 'vscode' import * as fs from 'fs' -import * as lw from '../lw' -import { getBibtexFormatConfig, type BibtexFormatConfig } from './bibtexformatterlib/bibtexutils' +import { lw } from '../lw' +import { getBibtexFormatConfig, type BibtexFormatConfig } from '../lint/bibtexformatterlib/bibtexutils' -import { getLogger } from '../components/logger' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Intelli', 'Bib') diff --git a/src/providers/completer/argument.ts b/src/completion/completer/argument.ts similarity index 98% rename from src/providers/completer/argument.ts rename to src/completion/completer/argument.ts index f837b4c8a..b1a3f4238 100644 --- a/src/providers/completer/argument.ts +++ b/src/completion/completer/argument.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode' -import * as lw from '../../lw' -import type { IProvider, IProviderArgs } from '../completion' +import { lw } from '../../lw' +import type { IProvider, IProviderArgs } from '../latex' import { CmdEnvSuggestion, filterArgumentHint } from './completerutils' import { EnvSnippetType } from './environment' diff --git a/src/providers/completer/atsuggestion.ts b/src/completion/completer/atsuggestion.ts similarity index 94% rename from src/providers/completer/atsuggestion.ts rename to src/completion/completer/atsuggestion.ts index 5d2c97126..31f711eae 100644 --- a/src/providers/completer/atsuggestion.ts +++ b/src/completion/completer/atsuggestion.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import * as fs from 'fs' -import * as lw from '../../lw' -import type {IProvider, IProviderArgs} from '../completion' +import { lw, registerDisposable } from '../../lw' +import type {IProvider, IProviderArgs} from '../latex' import {escapeRegExp} from '../../utils/utils' interface AtSuggestionItemEntry { @@ -23,7 +23,7 @@ export class AtSuggestion implements IProvider { const allSuggestions: {[key: string]: AtSuggestionItemEntry} = JSON.parse(fs.readFileSync(`${lw.extensionRoot}/data/at-suggestions.json`).toString()) as DataAtSuggestionJsonType this.initialize(allSuggestions) - lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { + registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { if (e.affectsConfiguration('latex-workshop.intellisense.atSuggestion.user')) { this.initialize(allSuggestions) } diff --git a/src/providers/completer/citation.ts b/src/completion/completer/citation.ts similarity index 96% rename from src/providers/completer/citation.ts rename to src/completion/completer/citation.ts index 663e79eaf..1997e2511 100644 --- a/src/providers/completer/citation.ts +++ b/src/completion/completer/citation.ts @@ -1,14 +1,14 @@ import * as vscode from 'vscode' import * as fs from 'fs' import {bibtexParser} from 'latex-utensils' -import * as lw from '../../lw' -import * as eventbus from '../../components/eventbus' +import { lw } from '../../lw' +import * as eventbus from '../../core/event-bus' import {trimMultiLineString} from '../../utils/utils' import {computeFilteringRange} from './completerutils' -import type { IProvider, ICompletionItem, IProviderArgs } from '../completion' -import { getLogger } from '../../components/logger' -import { parser } from '../../components/parser' -import { Cache } from '../../components/cacher' +import type { IProvider, ICompletionItem, IProviderArgs } from '../latex' +import { getLogger } from '../../utils/logging/logger' +import { parser } from '../../parse/parser' +import { Cache } from '../../core/cache' const logger = getLogger('Intelli', 'Citation') @@ -133,9 +133,9 @@ export class Citation implements IProvider { private readonly bibEntries = new Map() constructor() { - lw.cacher.bib.onCreate(filePath => this.parseBibFile(filePath)) - lw.cacher.bib.onChange(filePath => this.parseBibFile(filePath)) - lw.cacher.bib.onDelete(filePath => this.removeEntriesInFile(filePath)) + lw.watcher.bib.onCreate(filePath => this.parseBibFile(filePath)) + lw.watcher.bib.onChange(filePath => this.parseBibFile(filePath)) + lw.watcher.bib.onDelete(filePath => this.removeEntriesInFile(filePath)) } provideFrom(_result: RegExpMatchArray, args: IProviderArgs) { @@ -277,7 +277,8 @@ export class Citation implements IProvider { return } suggestions = suggestions.concat(cachedBibs.map(bib => { - return {...bib, + return { + ...bib, key: bib.label, detail: bib.detail ? bib.detail : '', file: cachedFile, diff --git a/src/providers/completer/command.ts b/src/completion/completer/command.ts similarity index 98% rename from src/providers/completer/command.ts rename to src/completion/completer/command.ts index 86c413be3..883d6e37e 100644 --- a/src/providers/completer/command.ts +++ b/src/completion/completer/command.ts @@ -1,14 +1,14 @@ import * as vscode from 'vscode' import * as fs from 'fs' import type * as Ast from '@unified-latex/unified-latex-types' -import * as lw from '../../lw' -import type { IProvider, ICompletionItem, PkgType, IProviderArgs } from '../completion' +import { lw, registerDisposable } from '../../lw' +import type { IProvider, ICompletionItem, PkgType, IProviderArgs } from '../latex' import { CmdEnvSuggestion, splitSignatureString, filterNonLetterSuggestions, filterArgumentHint } from './completerutils' import {SurroundCommand} from './commandlib/surround' import { Environment, EnvSnippetType } from './environment' -import { getLogger } from '../../components/logger' -import { Cache } from '../../components/cacher' +import { getLogger } from '../../utils/logging/logger' +import { Cache } from '../../core/cache' const logger = getLogger('Intelli', 'Command') @@ -55,7 +55,7 @@ export class Command implements IProvider { const symbols: { [key: string]: CmdType } = JSON.parse(fs.readFileSync(`${lw.extensionRoot}/data/unimathsymbols.json`).toString()) as DataUnimathSymbolsJsonType Object.entries(symbols).forEach(([key, symbol]) => this.defaultSymbols.push(this.entryCmdToCompletion(key, symbol))) - lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { + registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { if (!e.affectsConfiguration('latex-workshop.intellisense.command.user') && !e.affectsConfiguration('latex-workshop.intellisense.package.exclude')) { return diff --git a/src/providers/completer/commandlib/surround.ts b/src/completion/completer/commandlib/surround.ts similarity index 97% rename from src/providers/completer/commandlib/surround.ts rename to src/completion/completer/commandlib/surround.ts index 73acae197..bd773f96c 100644 --- a/src/providers/completer/commandlib/surround.ts +++ b/src/completion/completer/commandlib/surround.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode' -import type { ICompletionItem } from '../../completion' +import type { ICompletionItem } from '../../latex' export class SurroundCommand { static surround(cmdItems: ICompletionItem[]) { diff --git a/src/providers/completer/completerutils.ts b/src/completion/completer/completerutils.ts similarity index 98% rename from src/providers/completer/completerutils.ts rename to src/completion/completer/completerutils.ts index 24e5bf603..f4205b9ff 100644 --- a/src/providers/completer/completerutils.ts +++ b/src/completion/completer/completerutils.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode' -import type { ICompletionItem } from '../completion' +import type { ICompletionItem } from '../latex' interface CmdSignature { /** name without leading `\` */ diff --git a/src/providers/completer/documentclass.ts b/src/completion/completer/documentclass.ts similarity index 93% rename from src/providers/completer/documentclass.ts rename to src/completion/completer/documentclass.ts index 4094873dd..1aaadc4d5 100644 --- a/src/providers/completer/documentclass.ts +++ b/src/completion/completer/documentclass.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import * as fs from 'fs' -import * as lw from '../../lw' -import type { IProvider } from '../completion' +import { lw } from '../../lw' +import type { IProvider } from '../latex' type DataClassnamesJsonType = typeof import('../../../data/classnames.json') diff --git a/src/providers/completer/environment.ts b/src/completion/completer/environment.ts similarity index 97% rename from src/providers/completer/environment.ts rename to src/completion/completer/environment.ts index d52943b1f..bb8eb94a1 100644 --- a/src/providers/completer/environment.ts +++ b/src/completion/completer/environment.ts @@ -1,13 +1,12 @@ import * as vscode from 'vscode' import * as fs from 'fs' import type * as Ast from '@unified-latex/unified-latex-types' -import * as lw from '../../lw' -import type { ICompletionItem, IProviderArgs } from '../completion' -import type { IProvider } from '../completion' +import { lw, registerDisposable } from '../../lw' +import type { ICompletionItem, IProvider, IProviderArgs } from '../latex' import { CmdEnvSuggestion, splitSignatureString, filterNonLetterSuggestions, filterArgumentHint } from './completerutils' -import { getLogger } from '../../components/logger' -import { Cache } from '../../components/cacher' +import { getLogger } from '../../utils/logging/logger' +import { Cache } from '../../core/cache' const logger = getLogger('Intelli', 'Environment') @@ -45,7 +44,7 @@ export class Environment implements IProvider { private readonly packageEnvsForBegin= new Map() constructor() { - lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { + registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { if (!e.affectsConfiguration('latex-workshop.intellisense.package.exclude')) { return } diff --git a/src/providers/completer/glossary.ts b/src/completion/completer/glossary.ts similarity index 97% rename from src/providers/completer/glossary.ts rename to src/completion/completer/glossary.ts index fd7a9ccb8..67c7c71e6 100644 --- a/src/providers/completer/glossary.ts +++ b/src/completion/completer/glossary.ts @@ -1,9 +1,8 @@ import * as vscode from 'vscode' import type * as Ast from '@unified-latex/unified-latex-types' -import * as lw from '../../lw' -import type { ICompletionItem } from '../completion' -import type { IProvider } from '../completion' -import { Cache } from '../../components/cacher' +import { lw } from '../../lw' +import type { ICompletionItem, IProvider } from '../latex' +import { Cache } from '../../core/cache' import { argContentToStr } from '../../utils/parser' import { getLongestBalancedString } from '../../utils/utils' diff --git a/src/providers/completer/input.ts b/src/completion/completer/input.ts similarity index 97% rename from src/providers/completer/input.ts rename to src/completion/completer/input.ts index 1fda1fc80..0031ab8f2 100644 --- a/src/providers/completer/input.ts +++ b/src/completion/completer/input.ts @@ -2,11 +2,11 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' import * as micromatch from 'micromatch' -import * as lw from '../../lw' -import type { IProvider, IProviderArgs } from '../completion' +import { lw } from '../../lw' +import type { IProvider, IProviderArgs } from '../latex' -import { getLogger } from '../../components/logger' -import { Cache } from '../../components/cacher' +import { getLogger } from '../../utils/logging/logger' +import type { Cache } from '../../core/cache' const logger = getLogger('Intelli', 'Input') diff --git a/src/providers/completer/package.ts b/src/completion/completer/package.ts similarity index 97% rename from src/providers/completer/package.ts rename to src/completion/completer/package.ts index d1f6ccdbe..ad5c5b046 100644 --- a/src/providers/completer/package.ts +++ b/src/completion/completer/package.ts @@ -1,11 +1,11 @@ import * as vscode from 'vscode' import * as fs from 'fs' import type * as Ast from '@unified-latex/unified-latex-types' -import * as lw from '../../lw' -import type { IProvider } from '../completion' +import { lw } from '../../lw' +import type { IProvider } from '../latex' import { argContentToStr } from '../../utils/parser' -import { Cache } from '../../components/cacher' -import { kpsewhich } from '../../components/cacherlib/pathutils' +import { Cache } from '../../core/cache' +import { kpsewhich } from '../../core/cacherlib/pathutils' type DataPackagesJsonType = typeof import('../../../data/packagenames.json') diff --git a/src/providers/completer/reference.ts b/src/completion/completer/reference.ts similarity index 99% rename from src/providers/completer/reference.ts rename to src/completion/completer/reference.ts index 1ad9bfd3d..f729c8213 100644 --- a/src/providers/completer/reference.ts +++ b/src/completion/completer/reference.ts @@ -2,12 +2,12 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' import type * as Ast from '@unified-latex/unified-latex-types' -import * as lw from '../../lw' +import { lw } from '../../lw' import { getLongestBalancedString, stripEnvironments } from '../../utils/utils' import { computeFilteringRange } from './completerutils' -import type { IProvider, ICompletionItem, IProviderArgs } from '../completion' +import type { IProvider, ICompletionItem, IProviderArgs } from '../latex' import { argContentToStr } from '../../utils/parser' -import { Cache } from '../../components/cacher' +import { Cache } from '../../core/cache' export interface ReferenceEntry extends ICompletionItem { /** The file that defines the ref. */ diff --git a/src/providers/completion.ts b/src/completion/latex.ts similarity index 99% rename from src/providers/completion.ts rename to src/completion/latex.ts index 45ea1fae0..a0c490c54 100644 --- a/src/providers/completion.ts +++ b/src/completion/latex.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' -import * as lw from '../lw' +import { lw } from '../lw' import { Citation } from './completer/citation' import { DocumentClass } from './completer/documentclass' import { Command } from './completer/command' @@ -16,7 +16,7 @@ import { Input, Import, SubImport } from './completer/input' import { Glossary } from './completer/glossary' import type { ReferenceDocType } from './completer/reference' import { escapeRegExp } from '../utils/utils' -import { getLogger } from '../components/logger' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Intelli') diff --git a/src/components/cacher.ts b/src/core/cache.ts similarity index 92% rename from src/components/cacher.ts rename to src/core/cache.ts index f45999ef3..39979cedb 100644 --- a/src/components/cacher.ts +++ b/src/core/cache.ts @@ -2,19 +2,18 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' import type * as Ast from '@unified-latex/unified-latex-types' -import * as lw from '../lw' -import * as eventbus from './eventbus' +import { lw } from '../lw' +import * as eventbus from './event-bus' import * as utils from '../utils/utils' -import type { CmdEnvSuggestion } from '../providers/completer/completerutils' -import type { CiteSuggestion } from '../providers/completer/citation' -import type { GlossarySuggestion } from '../providers/completer/glossary' -import type { ICompletionItem } from '../providers/completion' +import type { CmdEnvSuggestion } from '../completion/completer/completerutils' +import type { CiteSuggestion } from '../completion/completer/citation' +import type { GlossarySuggestion } from '../completion/completer/glossary' +import type { ICompletionItem } from '../completion/latex' import { InputFileRegExp } from '../utils/inputfilepath' import * as CacherUtils from './cacherlib/cacherutils' import * as PathUtils from './cacherlib/pathutils' -import { Watcher } from './cacherlib/watcher' -import { getLogger } from './logger' -import { parser } from './parser' +import { getLogger } from '../utils/logging/logger' +import { parser } from '../parse/parser' import { performance } from 'perf_hooks' const logger = getLogger('Cacher') @@ -59,19 +58,16 @@ export interface Cache { export class Cacher { private readonly caches: {[filePath: string]: Cache} = {} - readonly src: Watcher = new Watcher() - readonly pdf: Watcher = new Watcher('.pdf') - readonly bib: Watcher = new Watcher('.bib') private caching = 0 private promises: {[filePath: string]: Promise} = {} constructor() { - this.src.onChange((filePath: string) => { + lw.watcher.src.onChange((filePath: string) => { if (CacherUtils.canCache(filePath)) { void this.refreshCache(filePath) } }) - this.src.onDelete((filePath: string) => { + lw.watcher.src.onDelete((filePath: string) => { if (filePath in this.caches) { delete this.caches[filePath] logger.log(`Removed ${filePath} .`) @@ -84,9 +80,9 @@ export class Cacher { logger.log(`Ignored ${filePath} .`) return } - if (!this.src.has(filePath)) { + if (!lw.watcher.src.has(filePath)) { logger.log(`Adding ${filePath} .`) - this.src.add(filePath) + lw.watcher.src.add(filePath) } } @@ -127,9 +123,9 @@ export class Cacher { } reset() { - this.src.reset() - this.bib.reset() - this.pdf.reset() + lw.watcher.src.reset() + lw.watcher.bib.reset() + lw.watcher.pdf.reset() Object.keys(this.caches).forEach(filePath => delete this.caches[filePath]) } @@ -204,7 +200,7 @@ export class Cacher { }) logger.log(`Input ${result.path} from ${cache.filePath} .`) - if (this.src.has(result.path)) { + if (lw.watcher.src.has(result.path)) { continue } this.add(result.path) @@ -232,7 +228,7 @@ export class Cacher { logger.log(`External document ${externalPath} from ${cache.filePath} .` + (result[1] ? ` Prefix is ${result[1]}`: '')) - if (this.src.has(externalPath)) { + if (lw.watcher.src.has(externalPath)) { continue } this.add(externalPath) @@ -270,8 +266,8 @@ export class Cacher { for (const bibPath of bibPaths) { cache.bibfiles.add(bibPath) logger.log(`Bib ${bibPath} from ${cache.filePath} .`) - if (!this.bib.has(bibPath)) { - this.bib.add(bibPath) + if (!lw.watcher.bib.has(bibPath)) { + lw.watcher.bib.add(bibPath) } } } @@ -306,7 +302,7 @@ export class Cacher { !fs.existsSync(inputFile)) { continue } - if (inputFile === filePath || this.src.has(inputFile)) { + if (inputFile === filePath || lw.watcher.src.has(inputFile)) { // Drop the current rootFile often listed as INPUT // Drop any file that is already watched as it is handled by // onWatchedFileChange. @@ -330,7 +326,7 @@ export class Cacher { } else { logger.log(`Cache not finished on ${filePath} when parsing fls.`) } - } else if (!this.src.has(inputFile)) { + } else if (!lw.watcher.src.has(inputFile)) { // Watch non-tex files. this.add(inputFile) } @@ -364,8 +360,8 @@ export class Cacher { this.get(lw.manager.rootFile)?.bibfiles.add(bibPath) logger.log(`Found .bib ${bibPath} from .aux ${filePath} .`) } - if (!this.bib.has(bibPath)) { - this.bib.add(bibPath) + if (!lw.watcher.bib.has(bibPath)) { + lw.watcher.bib.add(bibPath) } } } diff --git a/src/components/cacherlib/cacherutils.ts b/src/core/cacherlib/cacherutils.ts similarity index 97% rename from src/components/cacherlib/cacherutils.ts rename to src/core/cacherlib/cacherutils.ts index 99b254ee8..1f5e0de9d 100644 --- a/src/components/cacherlib/cacherutils.ts +++ b/src/core/cacherlib/cacherutils.ts @@ -2,7 +2,7 @@ import vscode from 'vscode' import path from 'path' import os from 'os' import micromatch from 'micromatch' -import { isTeX } from '../manager' +import { isTeX } from '../root-file' export function canCache(filePath: string) { return isTeX(path.extname(filePath)) && !filePath.includes('expl3-code.tex') diff --git a/src/components/cacherlib/pathutils.ts b/src/core/cacherlib/pathutils.ts similarity index 96% rename from src/components/cacherlib/pathutils.ts rename to src/core/cacherlib/pathutils.ts index a014952e9..0e250e681 100644 --- a/src/components/cacherlib/pathutils.ts +++ b/src/core/cacherlib/pathutils.ts @@ -2,9 +2,9 @@ import * as vscode from 'vscode' import * as path from 'path' import * as cs from 'cross-spawn' import * as fs from 'fs' -import * as lw from '../../lw' +import { lw } from '../../lw' import * as utils from '../../utils/utils' -import { getLogger } from '../logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Cacher', 'Path') diff --git a/src/commander.ts b/src/core/commands.ts similarity index 99% rename from src/commander.ts rename to src/core/commands.ts index c2884a0fc..84f0b899c 100644 --- a/src/commander.ts +++ b/src/core/commands.ts @@ -1,9 +1,9 @@ import * as vscode from 'vscode' import * as path from 'path' -import * as lw from './lw' -import { getSurroundingCommandRange, stripText } from './utils/utils' -import { getLogger } from './components/logger' -import { parser } from './components/parser' +import { lw } from '../lw' +import { getSurroundingCommandRange, stripText } from '../utils/utils' +import { getLogger } from '../utils/logging/logger' +import { parser } from '../parse/parser' const logger = getLogger('Commander') diff --git a/src/components/eventbus.ts b/src/core/event-bus.ts similarity index 98% rename from src/components/eventbus.ts rename to src/core/event-bus.ts index 048bf1bf7..909840e4f 100644 --- a/src/components/eventbus.ts +++ b/src/core/event-bus.ts @@ -2,7 +2,7 @@ import {EventEmitter} from 'events' import type {PdfViewerState} from '../../types/latex-workshop-protocol-types/index' import type {Disposable} from 'vscode' -import { getLogger } from '../components/logger' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Event') diff --git a/src/components/lwfs.ts b/src/core/file-system.ts similarity index 100% rename from src/components/lwfs.ts rename to src/core/file-system.ts diff --git a/src/components/manager.ts b/src/core/root-file.ts similarity index 98% rename from src/components/manager.ts rename to src/core/root-file.ts index 3594c787b..e658e012f 100644 --- a/src/components/manager.ts +++ b/src/core/root-file.ts @@ -4,9 +4,9 @@ import * as path from 'path' import * as fs from 'fs' import * as tmp from 'tmp' import * as utils from '../utils/utils' -import * as lw from '../lw' -import * as eventbus from './eventbus' -import { getLogger } from './logger' +import { lw } from '../lw' +import * as eventbus from './event-bus' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Manager') @@ -39,7 +39,7 @@ export class Manager { constructor() { this.registerSetEnvVar() - lw.cacher.src.onDelete(filePath => { + lw.watcher.src.onDelete(filePath => { if (filePath === this.rootFile) { this.rootFile = undefined void this.findRoot() @@ -304,7 +304,7 @@ export class Manager { // We also clean the completions from the old project lw.completer.input.reset() lw.dupLabelDetector.reset() - lw.cacher.src.reset() + lw.watcher.src.reset() lw.cacher.add(rootFile) void lw.cacher.refreshCache(rootFile).then(async () => { // We need to parse the fls to discover file dependencies when defined by TeX macro diff --git a/src/components/cacherlib/watcher.ts b/src/core/watcher.ts similarity index 93% rename from src/components/cacherlib/watcher.ts rename to src/core/watcher.ts index 8e2085a6f..92954eed4 100644 --- a/src/components/cacherlib/watcher.ts +++ b/src/core/watcher.ts @@ -1,21 +1,21 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' -import * as lw from '../../lw' -import * as eventbus from '../eventbus' -import { getLogger } from '../logger' -import { isBinary } from '../manager' +import { lw } from '../lw' +import * as eventbus from './event-bus' +import { getLogger } from '../utils/logging/logger' +import { isBinary } from './root-file' const logger = getLogger('Cacher', 'Watcher') -export class Watcher { +class Watcher { private readonly watchers: {[folder: string]: {watcher: vscode.FileSystemWatcher, files: Set}} = {} private readonly onCreateHandlers: Set<(filePath: string) => void> = new Set() private readonly onChangeHandlers: Set<(filePath: string) => void> = new Set() private readonly onDeleteHandlers: Set<(filePath: string) => void> = new Set() private readonly polling: {[filePath: string]: {time: number, size: number}} = {} - constructor(private readonly fileExt: string = '.*') {} + constructor(private readonly fileExt: '.*' | '.bib' | '.pdf' = '.*') {} onCreate(handler: (filePath: string) => void) { this.onCreateHandlers.add(handler) @@ -130,3 +130,9 @@ export class Watcher { logger.log('Reset.') } } + +export const watcher = { + src: new Watcher(), + pdf: new Watcher('.pdf'), + bib: new Watcher('.bib') +} diff --git a/src/components/commander.ts b/src/extras/activity-bar.ts similarity index 99% rename from src/components/commander.ts rename to src/extras/activity-bar.ts index 5e2fb9dd7..7582ddfd3 100644 --- a/src/components/commander.ts +++ b/src/extras/activity-bar.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode' -import * as lw from '../lw' +import { lw } from '../lw' export class LaTeXCommanderTreeView { private readonly latexCommanderProvider: LaTeXCommanderProvider diff --git a/src/components/cleaner.ts b/src/extras/cleaner.ts similarity index 98% rename from src/components/cleaner.ts rename to src/extras/cleaner.ts index 2d469a115..01c21348d 100644 --- a/src/components/cleaner.ts +++ b/src/extras/cleaner.ts @@ -3,10 +3,10 @@ import * as path from 'path' import * as fs from 'fs' import { glob } from 'glob' import * as cs from 'cross-spawn' -import * as lw from '../lw' +import { lw } from '../lw' import { replaceArgumentPlaceholders } from '../utils/utils' -import { getLogger } from './logger' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Cleaner') diff --git a/src/components/counter.ts b/src/extras/counter.ts similarity index 98% rename from src/components/counter.ts rename to src/extras/counter.ts index c8a623faa..819fe7c6a 100644 --- a/src/components/counter.ts +++ b/src/extras/counter.ts @@ -2,8 +2,8 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' import * as cs from 'cross-spawn' -import * as lw from '../lw' -import { getLogger } from './logger' +import { lw } from '../lw' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Counter') diff --git a/src/components/mathpreviewpanel.ts b/src/extras/math-preview-panel.ts similarity index 98% rename from src/components/mathpreviewpanel.ts rename to src/extras/math-preview-panel.ts index 22713d2dc..57bed948e 100644 --- a/src/components/mathpreviewpanel.ts +++ b/src/extras/math-preview-panel.ts @@ -1,9 +1,9 @@ import * as vscode from 'vscode' import * as path from 'path' -import type { TexMathEnv } from '../providers/preview/mathpreview' +import type { TexMathEnv } from '../preview/math/mathpreview' import { moveWebviewPanel } from '../utils/webview' -import * as lw from '../lw' -import { getLogger } from './logger' +import { lw } from '../lw' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Preview', 'Math') diff --git a/src/components/section.ts b/src/extras/section.ts similarity index 99% rename from src/components/section.ts rename to src/extras/section.ts index d8ba9d20f..972d43ef4 100644 --- a/src/components/section.ts +++ b/src/extras/section.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode' import { stripCommentsAndVerbatim } from '../utils/utils' -import { getLogger } from './logger' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Section') diff --git a/src/components/snippetview.ts b/src/extras/snippet-view.ts similarity index 99% rename from src/components/snippetview.ts rename to src/extras/snippet-view.ts index 3bb759263..1a1ac135d 100644 --- a/src/components/snippetview.ts +++ b/src/extras/snippet-view.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import {readFileSync} from 'fs' import * as path from 'path' -import * as lw from '../lw' +import { lw } from '../lw' import {replaceWebviewPlaceholders} from '../utils/webview' diff --git a/src/components/texdoc.ts b/src/extras/texdoc.ts similarity index 97% rename from src/components/texdoc.ts rename to src/extras/texdoc.ts index 22afb35e9..e1a9544ca 100644 --- a/src/components/texdoc.ts +++ b/src/extras/texdoc.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import * as cs from 'cross-spawn' -import * as lw from '../lw' -import { getLogger } from './logger' +import { lw } from '../lw' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('TeXDoc') diff --git a/src/components/texmagician.ts b/src/extras/texroot.ts similarity index 100% rename from src/components/texmagician.ts rename to src/extras/texroot.ts diff --git a/src/providers/definition.ts b/src/language/definition.ts similarity index 97% rename from src/providers/definition.ts rename to src/language/definition.ts index ccbfc12b3..cb82c19c2 100644 --- a/src/providers/definition.ts +++ b/src/language/definition.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' -import * as lw from '../lw' -import {tokenizer} from './tokenizer' +import { lw } from '../lw' +import { tokenizer } from '../utils/tokenizer' import * as utils from '../utils/utils' export class DefinitionProvider implements vscode.DefinitionProvider { diff --git a/src/providers/folding.ts b/src/language/folding.ts similarity index 100% rename from src/providers/folding.ts rename to src/language/folding.ts diff --git a/src/providers/selection.ts b/src/language/selection.ts similarity index 97% rename from src/providers/selection.ts rename to src/language/selection.ts index 3a3f762ba..dee6a67e2 100644 --- a/src/providers/selection.ts +++ b/src/language/selection.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import type * as Ast from '@unified-latex/unified-latex-types' -import * as lw from '../lw' -import { getLogger } from '../components/logger' +import { lw } from '../lw' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Selection') diff --git a/src/providers/docsymbol.ts b/src/language/symbol-document.ts similarity index 88% rename from src/providers/docsymbol.ts rename to src/language/symbol-document.ts index b4819f090..cddac5226 100644 --- a/src/providers/docsymbol.ts +++ b/src/language/symbol-document.ts @@ -1,9 +1,9 @@ import * as vscode from 'vscode' -import * as lw from '../lw' -import { TeXElement, TeXElementType } from './structure' -import { buildBibTeX } from './structurelib/bibtex' -import { construct as constructLaTeX } from './structurelib/latex' -import { construct } from './structurelib/doctex' +import { lw } from '../lw' +import { TeXElement, TeXElementType } from '../outline/structurelib/types' +import { buildBibTeX } from '../outline/structurelib/bibtex' +import { construct as constructLaTeX } from '../outline/structurelib/latex' +import { construct } from '../outline/structurelib/doctex' export class DocSymbolProvider implements vscode.DocumentSymbolProvider { diff --git a/src/providers/projectsymbol.ts b/src/language/symbol-project.ts similarity index 89% rename from src/providers/projectsymbol.ts rename to src/language/symbol-project.ts index be16004e3..0f644dc3b 100644 --- a/src/providers/projectsymbol.ts +++ b/src/language/symbol-project.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' -import * as lw from '../lw' -import { construct } from './structurelib/latex' -import { TeXElement } from './structure' +import { lw } from '../lw' +import { construct } from '../outline/structurelib/latex' +import { TeXElement } from '../outline/structurelib/types' export class ProjectSymbolProvider implements vscode.WorkspaceSymbolProvider { diff --git a/src/providers/bibtexformatter.ts b/src/lint/bibtex-formatter.ts similarity index 98% rename from src/providers/bibtexformatter.ts rename to src/lint/bibtex-formatter.ts index eb4233adc..9f79d6b7d 100644 --- a/src/providers/bibtexformatter.ts +++ b/src/lint/bibtex-formatter.ts @@ -2,8 +2,8 @@ import * as vscode from 'vscode' import { bibtexParser } from 'latex-utensils' import { performance } from 'perf_hooks' import * as BibtexUtils from './bibtexformatterlib/bibtexutils' -import { getLogger } from '../components/logger' -import { parser } from '../components/parser' +import { getLogger } from '../utils/logging/logger' +import { parser } from '../parse/parser' const logger = getLogger('Format', 'Bib') diff --git a/src/providers/bibtexformatterlib/bibtexutils.ts b/src/lint/bibtexformatterlib/bibtexutils.ts similarity index 99% rename from src/providers/bibtexformatterlib/bibtexutils.ts rename to src/lint/bibtexformatterlib/bibtexutils.ts index f4311d91e..63b2904f4 100644 --- a/src/providers/bibtexformatterlib/bibtexutils.ts +++ b/src/lint/bibtexformatterlib/bibtexutils.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode' import {bibtexParser} from 'latex-utensils' -import { getLogger } from '../../components/logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Format', 'Bib') diff --git a/src/components/duplabeldetector.ts b/src/lint/duplicate-label.ts similarity index 98% rename from src/components/duplabeldetector.ts rename to src/lint/duplicate-label.ts index f90683122..912867b19 100644 --- a/src/components/duplabeldetector.ts +++ b/src/lint/duplicate-label.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode' import * as path from 'path' -import * as lw from '../lw' +import { lw } from '../lw' const duplicatedLabelsDiagnostics = vscode.languages.createDiagnosticCollection('Duplicate Labels') diff --git a/src/providers/codeactions.ts b/src/lint/latex-code-actions.ts similarity index 98% rename from src/providers/codeactions.ts rename to src/lint/latex-code-actions.ts index 9aad0b841..7709d5485 100644 --- a/src/providers/codeactions.ts +++ b/src/lint/latex-code-actions.ts @@ -1,5 +1,5 @@ import * as vs from 'vscode' -import { TeXMathEnvFinder } from './preview/mathpreviewlib/texmathenvfinder' +import { TeXMathEnvFinder } from '../preview/math/mathpreviewlib/texmathenvfinder' /** * Each number corresponds to the warning number of ChkTeX. diff --git a/src/providers/latexformatter.ts b/src/lint/latex-formatter.ts similarity index 97% rename from src/providers/latexformatter.ts rename to src/lint/latex-formatter.ts index a392cc547..6423df29d 100644 --- a/src/providers/latexformatter.ts +++ b/src/lint/latex-formatter.ts @@ -3,9 +3,9 @@ import * as cs from 'cross-spawn' import * as path from 'path' import * as fs from 'fs' import * as os from 'os' -import * as lw from '../lw' +import { lw, registerDisposable } from '../lw' import {replaceArgumentPlaceholders} from '../utils/utils' -import { getLogger } from '../components/logger' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Format', 'TeX') @@ -195,7 +195,7 @@ class LatexFormatterProvider implements vscode.DocumentFormattingEditProvider, v logger.log('LaTexFormatter: Unsupported OS') } - lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { + registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { if (e.affectsConfiguration('latex-workshop.latexindent.path')) { formatter = '' } diff --git a/src/components/linter.ts b/src/lint/latex-linter.ts similarity index 96% rename from src/components/linter.ts rename to src/lint/latex-linter.ts index dca74e543..379bfdbca 100644 --- a/src/components/linter.ts +++ b/src/lint/latex-linter.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' -import * as lw from '../lw' +import { lw } from '../lw' import { chkTeX } from './linterlib/chktex' import { laCheck } from './linterlib/lacheck' -import { getLogger } from './logger' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Linter') diff --git a/src/components/linterlib/chktex.ts b/src/lint/linterlib/chktex.ts similarity index 98% rename from src/components/linterlib/chktex.ts rename to src/lint/linterlib/chktex.ts index 1d25995c6..710d143d1 100644 --- a/src/components/linterlib/chktex.ts +++ b/src/lint/linterlib/chktex.ts @@ -3,11 +3,11 @@ import * as path from 'path' import * as fs from 'fs' import * as os from 'os' import { ChildProcessWithoutNullStreams, spawn } from 'child_process' -import * as lw from '../../lw' -import type { ILinter } from '../linter' +import { lw } from '../../lw' +import type { ILinter } from '../latex-linter' import { processWrapper } from './linterutils' import { convertFilenameEncoding } from '../../utils/convertfilename' -import { getLogger } from '../logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Linter', 'ChkTeX') diff --git a/src/components/linterlib/lacheck.ts b/src/lint/linterlib/lacheck.ts similarity index 97% rename from src/components/linterlib/lacheck.ts rename to src/lint/linterlib/lacheck.ts index 48482cb8d..17a1f0957 100644 --- a/src/components/linterlib/lacheck.ts +++ b/src/lint/linterlib/lacheck.ts @@ -2,11 +2,11 @@ import * as vscode from 'vscode' import * as path from 'path' import * as fs from 'fs' import { ChildProcessWithoutNullStreams, spawn } from 'child_process' -import * as lw from '../../lw' -import type { ILinter } from '../linter' +import { lw } from '../../lw' +import type { ILinter } from '../latex-linter' import { processWrapper } from './linterutils' import { convertFilenameEncoding } from '../../utils/convertfilename' -import { getLogger } from '../logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Linter', 'LaCheck') diff --git a/src/components/linterlib/linterutils.ts b/src/lint/linterlib/linterutils.ts similarity index 97% rename from src/components/linterlib/linterutils.ts rename to src/lint/linterlib/linterutils.ts index 69e0408ca..6b3748fbd 100644 --- a/src/components/linterlib/linterutils.ts +++ b/src/lint/linterlib/linterutils.ts @@ -1,6 +1,6 @@ import * as os from 'os' import type { ChildProcessWithoutNullStreams } from 'child_process' -import { getLogger } from '../logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Linter') diff --git a/src/components/envpair.ts b/src/locate/environment.ts similarity index 99% rename from src/components/envpair.ts rename to src/locate/environment.ts index fece0e2f6..23c19e81a 100644 --- a/src/components/envpair.ts +++ b/src/locate/environment.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' -import { getLogger } from './logger' +import { getLogger } from '../utils/logging/logger' import type * as Ast from '@unified-latex/unified-latex-types' import { argContentToStr } from '../utils/parser' -import { parser } from './parser' +import { parser } from '../parse/parser' const logger = getLogger('EnvPair') diff --git a/src/components/locatorlib/synctex.ts b/src/locate/locatorlib/synctex.ts similarity index 98% rename from src/components/locatorlib/synctex.ts rename to src/locate/locatorlib/synctex.ts index 5f0c21095..ee2264a6f 100644 --- a/src/components/locatorlib/synctex.ts +++ b/src/locate/locatorlib/synctex.ts @@ -2,12 +2,12 @@ import * as fs from 'fs' import * as iconv from 'iconv-lite' import * as path from 'path' import * as zlib from 'zlib' -import type { SyncTeXRecordForward, SyncTeXRecordBackward } from '../locator' -import { PdfSyncObject, parseSyncTex, Block } from '../../lib/synctexjs' +import type { SyncTeXRecordForward, SyncTeXRecordBackward } from '../synctex' +import { PdfSyncObject, parseSyncTex, Block } from '../synctexjs' import { iconvLiteSupportedEncodings } from '../../utils/convertfilename' import { isSameRealPath } from '../../utils/pathnormalize' -import { getLogger } from '../logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('SyncTeX') diff --git a/src/components/locator.ts b/src/locate/synctex.ts similarity index 99% rename from src/components/locator.ts rename to src/locate/synctex.ts index 7691b6c72..4fb8cb62d 100644 --- a/src/components/locator.ts +++ b/src/locate/synctex.ts @@ -2,12 +2,12 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' import * as cs from 'cross-spawn' -import * as lw from '../lw' +import { lw } from '../lw' import * as SyncTeX from './locatorlib/synctex' import { replaceArgumentPlaceholders } from '../utils/utils' import { isSameRealPath } from '../utils/pathnormalize' import type { ClientRequest } from '../../types/latex-workshop-protocol-types' -import { getLogger } from './logger' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Locator') diff --git a/src/lib/synctexjs.ts b/src/locate/synctexjs.ts similarity index 86% rename from src/lib/synctexjs.ts rename to src/locate/synctexjs.ts index b6a7421f4..af7b8e0ca 100644 --- a/src/lib/synctexjs.ts +++ b/src/locate/synctexjs.ts @@ -29,80 +29,80 @@ https://durieux.me/synctex-js/ */ export type Block = { - type: string; - parent: Block | Page; - fileNumber: number; - file: InputFile; - line: number; - left: number; - bottom: number; - width: number | undefined; - height: number; - depth?: number; - blocks?: Block[]; - elements?: Block[]; - page: number; + type: string, + parent: Block | Page, + fileNumber: number, + file: InputFile, + line: number, + left: number, + bottom: number, + width: number | undefined, + height: number, + depth?: number, + blocks?: Block[], + elements?: Block[], + page: number } -function isBlock(b: Block | Page) : b is Block { +function isBlock(b: Block | Page): b is Block { return (b as Block).parent !== undefined } type InputFile = { - path: string; + path: string } -type InputFiles = { [fileNumber: string]: InputFile; } +type InputFiles = { [fileNumber: string]: InputFile } type Page = { - page: number; - blocks: Block[]; - type: string; + page: number, + blocks: Block[], + type: string } -type Pages = { [pageNum: string]: Page; } +type Pages = { [pageNum: string]: Page } type BlockNumberLine = { [inputFileFullPath: string]: { [inputLineNum: number]: { - [pageNum: number]: Block[]; - }; - }; + [pageNum: number]: Block[] + } + } } export type PdfSyncObject = { offset: { - x: number; - y: number; - }; - version: string; - files: InputFiles; - pages: Pages; - blockNumberLine: BlockNumberLine; - hBlocks: Block[]; - numberPages: number; + x: number, + y: number + }, + version: string, + files: InputFiles, + pages: Pages, + blockNumberLine: BlockNumberLine, + hBlocks: Block[], + numberPages: number } -export function parseSyncTex(pdfsyncBody: string) : PdfSyncObject | undefined { +export function parseSyncTex(pdfsyncBody: string): PdfSyncObject | undefined { const unit = 65781.76 let numberPages = 0 let currentPage: Page | undefined let currentElement: Block | Page | undefined - const blockNumberLine: BlockNumberLine = Object.create(null) + const blockNumberLine = Object.create(null) as BlockNumberLine const hBlocks: Block[] = [] - const files: InputFiles = Object.create(null) - const pages: Pages = Object.create(null) + const files = Object.create(null) as InputFiles + const pages = Object.create(null) as Pages const pdfsyncObject: PdfSyncObject = { offset: { x: 0, y: 0 }, version: '', - files: Object.create(null), - pages: Object.create(null), - blockNumberLine: Object.create(null), + files: Object.create(null) as InputFiles, + pages: Object.create(null) as Pages, + blockNumberLine: Object.create(null) as BlockNumberLine, hBlocks: [], numberPages: 0 } @@ -279,10 +279,10 @@ export function parseSyncTex(pdfsyncBody: string) : PdfSyncObject | undefined { continue } if (blockNumberLine[elem.file.path] === undefined) { - blockNumberLine[elem.file.path] = Object.create(null) + blockNumberLine[elem.file.path] = Object.create(null) as { [inputLineNum: number]: { [pageNum: number]: Block[] } } } if (blockNumberLine[elem.file.path][lineNumber] === undefined) { - blockNumberLine[elem.file.path][lineNumber] = Object.create(null) + blockNumberLine[elem.file.path][lineNumber] = Object.create(null) as { [pageNum: number]: Block[] } } if (blockNumberLine[elem.file.path][lineNumber][elem.page] === undefined) { blockNumberLine[elem.file.path][lineNumber][elem.page] = [] diff --git a/src/lw.ts b/src/lw.ts index c5f1a2f45..39b8ace8c 100644 --- a/src/lw.ts +++ b/src/lw.ts @@ -1,104 +1,73 @@ -import vscode from 'vscode' -import path from 'path' -import { Builder } from './components/builder' -import { Cacher } from './components/cacher' -import { Cleaner } from './components/cleaner' -import { LaTeXCommanderTreeView } from './components/commander' -import { Configuration } from './components/configuration' -import { Counter } from './components/counter' -export { dupLabelDetector } from './components/duplabeldetector' -import { EnvPair } from './components/envpair' -import { EventBus } from './components/eventbus' -import { Linter } from './components/linter' -import { Locator } from './components/locator' -import { LwFileSystem } from './components/lwfs' -import { Manager } from './components/manager' -import { MathPreviewPanel } from './components/mathpreviewpanel' -import { parser } from './components/parser' -import { Section } from './components/section' -import { Server } from './components/server' -import { SnippetView } from './components/snippetview' -import { TeXMagician } from './components/texmagician' -import { Viewer } from './components/viewer' -import { CodeActions } from './providers/codeactions' -import { AtSuggestionCompleter, Completer } from './providers/completion' -import { GraphicsPreview } from './providers/preview/graphicspreview' -import { MathPreview } from './providers/preview/mathpreview' -import { StructureView } from './providers/structure' -import { getLogger } from './components/logger' -import { TeXDoc } from './components/texdoc' -import { MathJaxPool } from './providers/preview/mathjaxpool' +import * as vscode from 'vscode' +import type { watcher } from './core/watcher' + +import type { Builder } from './compile/build' +import type { Cacher } from './core/cache' +import type { Cleaner } from './extras/cleaner' +import type { LaTeXCommanderTreeView } from './extras/activity-bar' +import type { Configuration } from './utils/logging/log-config' +import type { Counter } from './extras/counter' +import type { EnvPair } from './locate/environment' +import type { EventBus } from './core/event-bus' +import type { Linter } from './lint/latex-linter' +import type { Locator } from './locate/synctex' +import type { LwFileSystem } from './core/file-system' +import type { Manager } from './core/root-file' +import type { MathPreviewPanel } from './extras/math-preview-panel' +import type { Section } from './extras/section' +import type { dupLabelDetector } from './lint/duplicate-label' +import type { Server } from './preview/server' +import type { SnippetView } from './extras/snippet-view' +import type { TeXMagician } from './extras/texroot' +import type { Viewer } from './preview/viewer' +import type { CodeActions } from './lint/latex-code-actions' +import type { AtSuggestionCompleter, Completer } from './completion/latex' +import type { GraphicsPreview } from './preview/graphics' +import type { MathPreview } from './preview/math/mathpreview' +import type { StructureView } from './outline/project' +import type { TeXDoc } from './extras/texdoc' +import type * as commands from './core/commands' + +export const lw = { + extensionContext: Object.create(null) as vscode.ExtensionContext, + extensionRoot: '', + watcher: {} as typeof watcher, + eventBus: Object.create(null) as EventBus, + configuration: Object.create(null) as Configuration, + lwfs: Object.create(null) as LwFileSystem, + cacher: Object.create(null) as Cacher, + manager: Object.create(null) as Manager, + builder: Object.create(null) as Builder, + viewer: Object.create(null) as Viewer, + server: Object.create(null) as Server, + locator: Object.create(null) as Locator, + completer: Object.create(null) as Completer, + atSuggestionCompleter: Object.create(null) as AtSuggestionCompleter, + linter: Object.create(null) as Linter, + cleaner: Object.create(null) as Cleaner, + counter: Object.create(null) as Counter, + texdoc: Object.create(null) as TeXDoc, + codeActions: Object.create(null) as CodeActions, + texMagician: Object.create(null) as TeXMagician, + envPair: Object.create(null) as EnvPair, + section: Object.create(null) as Section, + dupLabelDetector: Object.create(null) as typeof dupLabelDetector, + latexCommanderTreeView: Object.create(null) as LaTeXCommanderTreeView, + structureViewer: Object.create(null) as StructureView, + snippetView: Object.create(null) as SnippetView, + graphicsPreview: Object.create(null) as GraphicsPreview, + mathPreview: Object.create(null) as MathPreview, + mathPreviewPanel: Object.create(null) as MathPreviewPanel, + commands: Object.create(null) as typeof commands +} let disposables: { dispose(): any }[] = [] -let context: vscode.ExtensionContext export function registerDisposable(...items: vscode.Disposable[]) { - if (context) { - context.subscriptions.push(...disposables, ...items) + if (lw.extensionContext.subscriptions) { + lw.extensionContext.subscriptions.push(...disposables, ...items) disposables = [] } else { disposables = [...disposables, ...items] } -} - -export * as commander from './commander' - -export const extensionRoot = path.resolve(`${__dirname}/../../`) -export const eventBus = new EventBus() -export const configuration = new Configuration() -export const lwfs = new LwFileSystem() -export const cacher = new Cacher() -export const manager = new Manager() -export const builder = new Builder() -export const viewer = new Viewer() -export const server = new Server() -export const locator = new Locator() -export const completer = new Completer() -export const atSuggestionCompleter = new AtSuggestionCompleter() -export const linter = new Linter() -export const cleaner = new Cleaner() -export const counter = new Counter() -export const texdoc = new TeXDoc() -export const codeActions = new CodeActions() -export const texMagician = new TeXMagician() -export const envPair = new EnvPair() -export const section = new Section() -export const latexCommanderTreeView = new LaTeXCommanderTreeView() -export const structureViewer = new StructureView() -export const snippetView = new SnippetView() -export const graphicsPreview = new GraphicsPreview() -export const mathPreview = new MathPreview() -export const mathPreviewPanel = new MathPreviewPanel() - -const logger = getLogger('Extension') - -export function init(extensionContext: vscode.ExtensionContext) { - context = extensionContext - registerDisposable() - addLogFundamentals() - void parser.reset() - logger.initializeStatusBarItem() - logger.log('LaTeX Workshop initialized.') - return { - dispose: async () => { - cacher.reset() - server.dispose() - await parser.dispose() - MathJaxPool.dispose() - } - } -} - -export function addLogFundamentals() { - logger.log('Initializing LaTeX Workshop.') - logger.log(`Extension root: ${extensionRoot}`) - logger.log(`$PATH: ${process.env.PATH}`) - logger.log(`$SHELL: ${process.env.SHELL}`) - logger.log(`$LANG: ${process.env.LANG}`) - logger.log(`$LC_ALL: ${process.env.LC_ALL}`) - logger.log(`process.platform: ${process.platform}`) - logger.log(`process.arch: ${process.arch}`) - logger.log(`vscode.env.appName: ${vscode.env.appName}`) - logger.log(`vscode.env.remoteName: ${vscode.env.remoteName}`) - logger.log(`vscode.env.uiKind: ${vscode.env.uiKind}`) -} +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index d0ec4362e..a22b7f902 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,30 +1,128 @@ import * as vscode from 'vscode' -import * as lw from './lw' -import { pdfViewerHookProvider, pdfViewerPanelSerializer } from './components/viewer' -import { MathPreviewPanelSerializer } from './components/mathpreviewpanel' -import { BibtexCompleter } from './providers/bibtexcompletion' -import { HoverProvider } from './providers/hover' -import { DocSymbolProvider } from './providers/docsymbol' -import { ProjectSymbolProvider } from './providers/projectsymbol' -import { DefinitionProvider } from './providers/definition' -import { latexFormatterProvider } from './providers/latexformatter' -import { FoldingProvider, WeaveFoldingProvider } from './providers/folding' -import { SelectionRangeProvider } from './providers/selection' -import { bibtexFormat, bibtexFormatterProvider } from './providers/bibtexformatter' -import { getLogger } from './components/logger' -import { DocumentChanged } from './components/eventbus' +import * as path from 'path' +import { lw, registerDisposable } from './lw' + +import { watcher } from './core/watcher' +lw.watcher = watcher + +import { pdfViewerHookProvider, pdfViewerPanelSerializer } from './preview/viewer' +import { MathPreviewPanelSerializer } from './extras/math-preview-panel' +import { BibtexCompleter } from './completion/bibtex' +import { HoverProvider } from './preview/hover' +import { DocSymbolProvider } from './language/symbol-document' +import { ProjectSymbolProvider } from './language/symbol-project' +import { DefinitionProvider } from './language/definition' +import { latexFormatterProvider } from './lint/latex-formatter' +import { FoldingProvider, WeaveFoldingProvider } from './language/folding' +import { SelectionRangeProvider } from './language/selection' +import { bibtexFormat, bibtexFormatterProvider } from './lint/bibtex-formatter' +import { getLogger } from './utils/logging/logger' +import { DocumentChanged } from './core/event-bus' const logger = getLogger('Extension') +import { Builder } from './compile/build' +import { Cacher } from './core/cache' +import { Cleaner } from './extras/cleaner' +import { LaTeXCommanderTreeView } from './extras/activity-bar' +import { Configuration } from './utils/logging/log-config' +import { Counter } from './extras/counter' +import { dupLabelDetector } from './lint/duplicate-label' +import { EnvPair } from './locate/environment' +import { EventBus } from './core/event-bus' +import { Linter } from './lint/latex-linter' +import { Locator } from './locate/synctex' +import { LwFileSystem } from './core/file-system' +import { Manager } from './core/root-file' +import { MathPreviewPanel } from './extras/math-preview-panel' +import { Section } from './extras/section' +import { Server } from './preview/server' +import { SnippetView } from './extras/snippet-view' +import { TeXMagician } from './extras/texroot' +import { Viewer } from './preview/viewer' +import { CodeActions } from './lint/latex-code-actions' +import { AtSuggestionCompleter, Completer } from './completion/latex' +import { GraphicsPreview } from './preview/graphics' +import { MathPreview } from './preview/math/mathpreview' +import { StructureView } from './outline/project' +import { TeXDoc } from './extras/texdoc' +import { parser } from './parse/parser' +import { MathJaxPool } from './preview/math/mathjaxpool' +import * as commander from './core/commands' + +function initialize(extensionContext: vscode.ExtensionContext) { + lw.extensionContext = extensionContext + lw.extensionRoot = path.resolve(`${__dirname}/../../`) + lw.eventBus = new EventBus() + lw.configuration = new Configuration() + lw.lwfs = new LwFileSystem() + lw.cacher = new Cacher() + lw.manager = new Manager() + lw.builder = new Builder() + lw.viewer = new Viewer() + lw.server = new Server() + lw.locator = new Locator() + lw.completer = new Completer() + lw.atSuggestionCompleter = new AtSuggestionCompleter() + lw.linter = new Linter() + lw.cleaner = new Cleaner() + lw.counter = new Counter() + lw.texdoc = new TeXDoc() + lw.codeActions = new CodeActions() + lw.texMagician = new TeXMagician() + lw.envPair = new EnvPair() + lw.section = new Section() + lw.dupLabelDetector = dupLabelDetector + lw.latexCommanderTreeView = new LaTeXCommanderTreeView() + lw.structureViewer = new StructureView() + lw.snippetView = new SnippetView() + lw.graphicsPreview = new GraphicsPreview() + lw.mathPreview = new MathPreview() + lw.mathPreviewPanel = new MathPreviewPanel() + lw.commands = commander + registerDisposable() + + void parser.reset() + logger.initializeStatusBarItem() + logger.log('Initializing LaTeX Workshop.') + logger.log(`Extension root: ${lw.extensionRoot}`) + logger.log(`$PATH: ${process.env.PATH}`) + logger.log(`$SHELL: ${process.env.SHELL}`) + logger.log(`$LANG: ${process.env.LANG}`) + logger.log(`$LC_ALL: ${process.env.LC_ALL}`) + logger.log(`process.platform: ${process.platform}`) + logger.log(`process.arch: ${process.arch}`) + logger.log(`vscode.env.appName: ${vscode.env.appName}`) + logger.log(`vscode.env.remoteName: ${vscode.env.remoteName}`) + logger.log(`vscode.env.uiKind: ${vscode.env.uiKind}`) + logger.log('LaTeX Workshop initialized.') + return { + dispose: async () => { + lw.cacher.reset() + lw.server.dispose() + await parser.dispose() + MathJaxPool.dispose() + } + } +} + export function activate(extensionContext: vscode.ExtensionContext) { void vscode.commands.executeCommand('setContext', 'latex-workshop:enabled', true) - const lwDisposable = lw.init(extensionContext) - lw.registerDisposable(lwDisposable) + initialize(extensionContext) + + extensionContext.subscriptions.push({ + dispose: async () => { + lw.cacher.reset() + lw.server.dispose() + await parser.dispose() + MathJaxPool.dispose() + } + }) - registerLatexWorkshopCommands() + registerLatexWorkshopCommands(extensionContext) - lw.registerDisposable(vscode.workspace.onDidSaveTextDocument( (e: vscode.TextDocument) => { + extensionContext.subscriptions.push(vscode.workspace.onDidSaveTextDocument( (e: vscode.TextDocument) => { if (lw.lwfs.isVirtualUri(e.uri)){ return } @@ -41,7 +139,7 @@ export function activate(extensionContext: vscode.ExtensionContext) { /** The previous active TeX document path. If this changed, root need to be re-searched */ let prevTeXDocumentPath: string | undefined let isLaTeXActive = false - lw.registerDisposable(vscode.window.onDidChangeActiveTextEditor(async (e: vscode.TextEditor | undefined) => { + extensionContext.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(async (e: vscode.TextEditor | undefined) => { const configuration = vscode.workspace.getConfiguration('latex-workshop') if (vscode.window.visibleTextEditors.filter(editor => lw.manager.hasTexId(editor.document.languageId)).length > 0) { @@ -66,7 +164,7 @@ export function activate(extensionContext: vscode.ExtensionContext) { })) let updateCompleter: NodeJS.Timeout - lw.registerDisposable(vscode.workspace.onDidChangeTextDocument((e: vscode.TextDocumentChangeEvent) => { + extensionContext.subscriptions.push(vscode.workspace.onDidChangeTextDocument((e: vscode.TextDocumentChangeEvent) => { if (lw.lwfs.isVirtualUri(e.document.uri)){ return } @@ -94,7 +192,7 @@ export function activate(extensionContext: vscode.ExtensionContext) { } })) - lw.registerDisposable(vscode.window.onDidChangeTextEditorSelection((e: vscode.TextEditorSelectionChangeEvent) => { + extensionContext.subscriptions.push(vscode.window.onDidChangeTextEditorSelection((e: vscode.TextEditorSelectionChangeEvent) => { if (lw.manager.hasTexId(e.textEditor.document.languageId) || lw.manager.hasBibtexId(e.textEditor.document.languageId) || lw.manager.hasDoctexId(e.textEditor.document.languageId)) { @@ -103,7 +201,7 @@ export function activate(extensionContext: vscode.ExtensionContext) { return })) - registerProviders() + registerProviders(extensionContext) void lw.manager.findRoot().then(() => { lw.linter.lintRootFileIfEnabled() @@ -114,85 +212,85 @@ export function activate(extensionContext: vscode.ExtensionContext) { conflictCheck() } -function registerLatexWorkshopCommands() { - lw.registerDisposable( - vscode.commands.registerCommand('latex-workshop.saveWithoutBuilding', () => lw.commander.saveActive()), - vscode.commands.registerCommand('latex-workshop.build', () => lw.commander.build()), - vscode.commands.registerCommand('latex-workshop.recipes', (recipe: string | undefined) => lw.commander.recipes(recipe)), - vscode.commands.registerCommand('latex-workshop.view', (uri: vscode.Uri) => lw.commander.view(uri)), - vscode.commands.registerCommand('latex-workshop.refresh-viewer', () => lw.commander.refresh()), - vscode.commands.registerCommand('latex-workshop.tab', () => lw.commander.view('tab')), - vscode.commands.registerCommand('latex-workshop.viewInBrowser', () => lw.commander.view('browser')), - vscode.commands.registerCommand('latex-workshop.viewExternal', () => lw.commander.view('external')), - vscode.commands.registerCommand('latex-workshop.kill', () => lw.commander.kill()), - vscode.commands.registerCommand('latex-workshop.synctex', () => lw.commander.synctex()), - vscode.commands.registerCommand('latex-workshop.texdoc', (packageName: string | undefined) => lw.commander.texdoc(packageName)), - vscode.commands.registerCommand('latex-workshop.texdocUsepackages', () => lw.commander.texdocUsepackages()), - vscode.commands.registerCommand('latex-workshop.synctexto', (line: number, filePath: string) => lw.commander.synctexonref(line, filePath)), - vscode.commands.registerCommand('latex-workshop.clean', () => lw.commander.clean()), - vscode.commands.registerCommand('latex-workshop.actions', () => lw.commander.actions()), +function registerLatexWorkshopCommands(extensionContext: vscode.ExtensionContext) { + extensionContext.subscriptions.push( + vscode.commands.registerCommand('latex-workshop.saveWithoutBuilding', () => lw.commands.saveActive()), + vscode.commands.registerCommand('latex-workshop.build', () => lw.commands.build()), + vscode.commands.registerCommand('latex-workshop.recipes', (recipe: string | undefined) => lw.commands.recipes(recipe)), + vscode.commands.registerCommand('latex-workshop.view', (uri: vscode.Uri) => lw.commands.view(uri)), + vscode.commands.registerCommand('latex-workshop.refresh-viewer', () => lw.commands.refresh()), + vscode.commands.registerCommand('latex-workshop.tab', () => lw.commands.view('tab')), + vscode.commands.registerCommand('latex-workshop.viewInBrowser', () => lw.commands.view('browser')), + vscode.commands.registerCommand('latex-workshop.viewExternal', () => lw.commands.view('external')), + vscode.commands.registerCommand('latex-workshop.kill', () => lw.commands.kill()), + vscode.commands.registerCommand('latex-workshop.synctex', () => lw.commands.synctex()), + vscode.commands.registerCommand('latex-workshop.texdoc', (packageName: string | undefined) => lw.commands.texdoc(packageName)), + vscode.commands.registerCommand('latex-workshop.texdocUsepackages', () => lw.commands.texdocUsepackages()), + vscode.commands.registerCommand('latex-workshop.synctexto', (line: number, filePath: string) => lw.commands.synctexonref(line, filePath)), + vscode.commands.registerCommand('latex-workshop.clean', () => lw.commands.clean()), + vscode.commands.registerCommand('latex-workshop.actions', () => lw.commands.actions()), vscode.commands.registerCommand('latex-workshop.activate', () => undefined), - vscode.commands.registerCommand('latex-workshop.citation', () => lw.commander.citation()), - vscode.commands.registerCommand('latex-workshop.addtexroot', () => lw.commander.addTexRoot()), - vscode.commands.registerCommand('latex-workshop.wordcount', () => lw.commander.wordcount()), - vscode.commands.registerCommand('latex-workshop.log', () => lw.commander.showLog()), - vscode.commands.registerCommand('latex-workshop.compilerlog', () => lw.commander.showLog('compiler')), + vscode.commands.registerCommand('latex-workshop.citation', () => lw.commands.citation()), + vscode.commands.registerCommand('latex-workshop.addtexroot', () => lw.commands.addTexRoot()), + vscode.commands.registerCommand('latex-workshop.wordcount', () => lw.commands.wordcount()), + vscode.commands.registerCommand('latex-workshop.log', () => lw.commands.showLog()), + vscode.commands.registerCommand('latex-workshop.compilerlog', () => lw.commands.showLog('compiler')), vscode.commands.registerCommand('latex-workshop.code-action', (d: vscode.TextDocument, r: vscode.Range, c: number, m: string) => lw.codeActions.runCodeAction(d, r, c, m)), - vscode.commands.registerCommand('latex-workshop.goto-section', (filePath: string, lineNumber: number) => lw.commander.gotoSection(filePath, lineNumber)), - vscode.commands.registerCommand('latex-workshop.navigate-envpair', () => lw.commander.navigateToEnvPair()), - vscode.commands.registerCommand('latex-workshop.select-envcontent', () => lw.commander.selectEnvContent('content')), - vscode.commands.registerCommand('latex-workshop.select-env', () => lw.commander.selectEnvContent('whole')), - vscode.commands.registerCommand('latex-workshop.select-envname', () => lw.commander.selectEnvName()), - vscode.commands.registerCommand('latex-workshop.multicursor-envname', () => lw.commander.multiCursorEnvName()), - vscode.commands.registerCommand('latex-workshop.toggle-equation-envname', () => lw.commander.toggleEquationEnv()), - vscode.commands.registerCommand('latex-workshop.close-env', () => lw.commander.closeEnv()), - vscode.commands.registerCommand('latex-workshop.wrap-env', () => lw.commander.insertSnippet('wrapEnv')), - vscode.commands.registerCommand('latex-workshop.onEnterKey', () => lw.commander.onEnterKey()), - vscode.commands.registerCommand('latex-workshop.onAltEnterKey', () => lw.commander.onEnterKey('alt')), - vscode.commands.registerCommand('latex-workshop.revealOutputDir', () => lw.commander.revealOutputDir()), - vscode.commands.registerCommand('latex-workshop.changeHostName', () => lw.commander.changeHostName()), - vscode.commands.registerCommand('latex-workshop.resetHostName', () => lw.commander.resetHostName()), - vscode.commands.registerCommand('latex-workshop-dev.parselog', () => lw.commander.devParseLog()), - vscode.commands.registerCommand('latex-workshop-dev.parsetex', () => lw.commander.devParseTeX()), - vscode.commands.registerCommand('latex-workshop-dev.parsebib', () => lw.commander.devParseBib()), - vscode.commands.registerCommand('latex-workshop-dev.striptext', () => lw.commander.devStripText()), - - vscode.commands.registerCommand('latex-workshop.shortcut.item', () => lw.commander.insertSnippet('item')), - vscode.commands.registerCommand('latex-workshop.shortcut.emph', () => lw.commander.toggleSelectedKeyword('emph')), - vscode.commands.registerCommand('latex-workshop.shortcut.textbf', () => lw.commander.toggleSelectedKeyword('textbf')), - vscode.commands.registerCommand('latex-workshop.shortcut.textit', () => lw.commander.toggleSelectedKeyword('textit')), - vscode.commands.registerCommand('latex-workshop.shortcut.underline', () => lw.commander.toggleSelectedKeyword('underline')), - vscode.commands.registerCommand('latex-workshop.shortcut.textrm', () => lw.commander.toggleSelectedKeyword('textrm')), - vscode.commands.registerCommand('latex-workshop.shortcut.texttt', () => lw.commander.toggleSelectedKeyword('texttt')), - vscode.commands.registerCommand('latex-workshop.shortcut.textsl', () => lw.commander.toggleSelectedKeyword('textsl')), - vscode.commands.registerCommand('latex-workshop.shortcut.textsc', () => lw.commander.toggleSelectedKeyword('textsc')), - vscode.commands.registerCommand('latex-workshop.shortcut.textnormal', () => lw.commander.toggleSelectedKeyword('textnormal')), - vscode.commands.registerCommand('latex-workshop.shortcut.textsuperscript', () => lw.commander.toggleSelectedKeyword('textsuperscript')), - vscode.commands.registerCommand('latex-workshop.shortcut.textsubscript', () => lw.commander.toggleSelectedKeyword('textsubscript')), - vscode.commands.registerCommand('latex-workshop.shortcut.mathbf', () => lw.commander.toggleSelectedKeyword('mathbf')), - vscode.commands.registerCommand('latex-workshop.shortcut.mathit', () => lw.commander.toggleSelectedKeyword('mathit')), - vscode.commands.registerCommand('latex-workshop.shortcut.mathrm', () => lw.commander.toggleSelectedKeyword('mathrm')), - vscode.commands.registerCommand('latex-workshop.shortcut.mathtt', () => lw.commander.toggleSelectedKeyword('mathtt')), - vscode.commands.registerCommand('latex-workshop.shortcut.mathsf', () => lw.commander.toggleSelectedKeyword('mathsf')), - vscode.commands.registerCommand('latex-workshop.shortcut.mathbb', () => lw.commander.toggleSelectedKeyword('mathbb')), - vscode.commands.registerCommand('latex-workshop.shortcut.mathcal', () => lw.commander.toggleSelectedKeyword('mathcal')), + vscode.commands.registerCommand('latex-workshop.goto-section', (filePath: string, lineNumber: number) => lw.commands.gotoSection(filePath, lineNumber)), + vscode.commands.registerCommand('latex-workshop.navigate-envpair', () => lw.commands.navigateToEnvPair()), + vscode.commands.registerCommand('latex-workshop.select-envcontent', () => lw.commands.selectEnvContent('content')), + vscode.commands.registerCommand('latex-workshop.select-env', () => lw.commands.selectEnvContent('whole')), + vscode.commands.registerCommand('latex-workshop.select-envname', () => lw.commands.selectEnvName()), + vscode.commands.registerCommand('latex-workshop.multicursor-envname', () => lw.commands.multiCursorEnvName()), + vscode.commands.registerCommand('latex-workshop.toggle-equation-envname', () => lw.commands.toggleEquationEnv()), + vscode.commands.registerCommand('latex-workshop.close-env', () => lw.commands.closeEnv()), + vscode.commands.registerCommand('latex-workshop.wrap-env', () => lw.commands.insertSnippet('wrapEnv')), + vscode.commands.registerCommand('latex-workshop.onEnterKey', () => lw.commands.onEnterKey()), + vscode.commands.registerCommand('latex-workshop.onAltEnterKey', () => lw.commands.onEnterKey('alt')), + vscode.commands.registerCommand('latex-workshop.revealOutputDir', () => lw.commands.revealOutputDir()), + vscode.commands.registerCommand('latex-workshop.changeHostName', () => lw.commands.changeHostName()), + vscode.commands.registerCommand('latex-workshop.resetHostName', () => lw.commands.resetHostName()), + vscode.commands.registerCommand('latex-workshop-dev.parselog', () => lw.commands.devParseLog()), + vscode.commands.registerCommand('latex-workshop-dev.parsetex', () => lw.commands.devParseTeX()), + vscode.commands.registerCommand('latex-workshop-dev.parsebib', () => lw.commands.devParseBib()), + vscode.commands.registerCommand('latex-workshop-dev.striptext', () => lw.commands.devStripText()), + + vscode.commands.registerCommand('latex-workshop.shortcut.item', () => lw.commands.insertSnippet('item')), + vscode.commands.registerCommand('latex-workshop.shortcut.emph', () => lw.commands.toggleSelectedKeyword('emph')), + vscode.commands.registerCommand('latex-workshop.shortcut.textbf', () => lw.commands.toggleSelectedKeyword('textbf')), + vscode.commands.registerCommand('latex-workshop.shortcut.textit', () => lw.commands.toggleSelectedKeyword('textit')), + vscode.commands.registerCommand('latex-workshop.shortcut.underline', () => lw.commands.toggleSelectedKeyword('underline')), + vscode.commands.registerCommand('latex-workshop.shortcut.textrm', () => lw.commands.toggleSelectedKeyword('textrm')), + vscode.commands.registerCommand('latex-workshop.shortcut.texttt', () => lw.commands.toggleSelectedKeyword('texttt')), + vscode.commands.registerCommand('latex-workshop.shortcut.textsl', () => lw.commands.toggleSelectedKeyword('textsl')), + vscode.commands.registerCommand('latex-workshop.shortcut.textsc', () => lw.commands.toggleSelectedKeyword('textsc')), + vscode.commands.registerCommand('latex-workshop.shortcut.textnormal', () => lw.commands.toggleSelectedKeyword('textnormal')), + vscode.commands.registerCommand('latex-workshop.shortcut.textsuperscript', () => lw.commands.toggleSelectedKeyword('textsuperscript')), + vscode.commands.registerCommand('latex-workshop.shortcut.textsubscript', () => lw.commands.toggleSelectedKeyword('textsubscript')), + vscode.commands.registerCommand('latex-workshop.shortcut.mathbf', () => lw.commands.toggleSelectedKeyword('mathbf')), + vscode.commands.registerCommand('latex-workshop.shortcut.mathit', () => lw.commands.toggleSelectedKeyword('mathit')), + vscode.commands.registerCommand('latex-workshop.shortcut.mathrm', () => lw.commands.toggleSelectedKeyword('mathrm')), + vscode.commands.registerCommand('latex-workshop.shortcut.mathtt', () => lw.commands.toggleSelectedKeyword('mathtt')), + vscode.commands.registerCommand('latex-workshop.shortcut.mathsf', () => lw.commands.toggleSelectedKeyword('mathsf')), + vscode.commands.registerCommand('latex-workshop.shortcut.mathbb', () => lw.commands.toggleSelectedKeyword('mathbb')), + vscode.commands.registerCommand('latex-workshop.shortcut.mathcal', () => lw.commands.toggleSelectedKeyword('mathcal')), vscode.commands.registerCommand('latex-workshop.surround', () => lw.completer.command.surround()), - vscode.commands.registerCommand('latex-workshop.promote-sectioning', () => lw.commander.shiftSectioningLevel('promote')), - vscode.commands.registerCommand('latex-workshop.demote-sectioning', () => lw.commander.shiftSectioningLevel('demote')), - vscode.commands.registerCommand('latex-workshop.select-section', () => lw.commander.selectSection()), + vscode.commands.registerCommand('latex-workshop.promote-sectioning', () => lw.commands.shiftSectioningLevel('promote')), + vscode.commands.registerCommand('latex-workshop.demote-sectioning', () => lw.commands.shiftSectioningLevel('demote')), + vscode.commands.registerCommand('latex-workshop.select-section', () => lw.commands.selectSection()), vscode.commands.registerCommand('latex-workshop.bibsort', () => bibtexFormat(true, false)), vscode.commands.registerCommand('latex-workshop.bibalign', () => bibtexFormat(false, true)), vscode.commands.registerCommand('latex-workshop.bibalignsort', () => bibtexFormat(true, true)), - vscode.commands.registerCommand('latex-workshop.openMathPreviewPanel', () => lw.commander.openMathPreviewPanel()), - vscode.commands.registerCommand('latex-workshop.closeMathPreviewPanel', () => lw.commander.closeMathPreviewPanel()), - vscode.commands.registerCommand('latex-workshop.toggleMathPreviewPanel', () => lw.commander.toggleMathPreviewPanel()) + vscode.commands.registerCommand('latex-workshop.openMathPreviewPanel', () => lw.commands.openMathPreviewPanel()), + vscode.commands.registerCommand('latex-workshop.closeMathPreviewPanel', () => lw.commands.closeMathPreviewPanel()), + vscode.commands.registerCommand('latex-workshop.toggleMathPreviewPanel', () => lw.commands.toggleMathPreviewPanel()) ) } -function registerProviders() { +function registerProviders(extensionContext: vscode.ExtensionContext) { const configuration = vscode.workspace.getConfiguration('latex-workshop') // According to cmhughes/latexindent.pl, it aims to beautify .tex, .sty and .cls files. @@ -202,20 +300,20 @@ function registerProviders() { const latexDoctexSelector = selectDocumentsWithId(['latex', 'latex-expl3', 'pweave', 'jlweave', 'rsweave', 'doctex']) const bibtexSelector = selectDocumentsWithId(['bibtex']) - lw.registerDisposable( + extensionContext.subscriptions.push( vscode.languages.registerDocumentFormattingEditProvider(latexindentSelector, latexFormatterProvider), vscode.languages.registerDocumentFormattingEditProvider(bibtexSelector, bibtexFormatterProvider), vscode.languages.registerDocumentRangeFormattingEditProvider(latexindentSelector, latexFormatterProvider), vscode.languages.registerDocumentRangeFormattingEditProvider(bibtexSelector, bibtexFormatterProvider) ) - lw.registerDisposable( + extensionContext.subscriptions.push( vscode.window.registerWebviewPanelSerializer('latex-workshop-pdf', pdfViewerPanelSerializer), vscode.window.registerCustomEditorProvider('latex-workshop-pdf-hook', pdfViewerHookProvider, {supportsMultipleEditorsPerDocument: true, webviewOptions: {retainContextWhenHidden: true}}), vscode.window.registerWebviewPanelSerializer('latex-workshop-mathpreview', new MathPreviewPanelSerializer()) ) - lw.registerDisposable( + extensionContext.subscriptions.push( vscode.languages.registerHoverProvider(latexSelector, new HoverProvider()), vscode.languages.registerDefinitionProvider(latexSelector, new DefinitionProvider()), vscode.languages.registerDocumentSymbolProvider(latexSelector, new DocSymbolProvider()), @@ -224,7 +322,7 @@ function registerProviders() { vscode.languages.registerWorkspaceSymbolProvider(new ProjectSymbolProvider()) ) - lw.registerDisposable( + extensionContext.subscriptions.push( vscode.languages.registerCompletionItemProvider({ scheme: 'file', language: 'tex'}, lw.completer, '\\', '{'), vscode.languages.registerCompletionItemProvider(bibtexSelector, new BibtexCompleter(), '@') ) @@ -236,10 +334,10 @@ function registerProviders() { logger.log(`Trigger characters for intellisense of LaTeX documents: ${JSON.stringify(latexTriggers)}`) triggerDisposable = vscode.languages.registerCompletionItemProvider(latexDoctexSelector, lw.completer, ...latexTriggers) - lw.registerDisposable(triggerDisposable) + extensionContext.subscriptions.push(triggerDisposable) } registerTrigger() - lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { + extensionContext.subscriptions.push(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { if (e.affectsConfiguration('latex-workshop.intellisense.triggers.latex')) { if (triggerDisposable) { triggerDisposable.dispose() @@ -256,11 +354,11 @@ function registerProviders() { if (atSuggestionLatexTrigger !== '') { lw.atSuggestionCompleter.updateTrigger() atSuggestionDisposable = vscode.languages.registerCompletionItemProvider(latexDoctexSelector, lw.atSuggestionCompleter, atSuggestionLatexTrigger) - lw.registerDisposable(atSuggestionDisposable) + extensionContext.subscriptions.push(atSuggestionDisposable) } } registerAtSuggestion() - lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { + extensionContext.subscriptions.push(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { if (e.affectsConfiguration('latex-workshop.intellisense.atSuggestion.trigger.latex')) { if (atSuggestionDisposable) { atSuggestionDisposable.dispose() @@ -271,7 +369,7 @@ function registerProviders() { return })) - lw.registerDisposable( + extensionContext.subscriptions.push( vscode.languages.registerCodeActionsProvider(latexSelector, lw.codeActions), vscode.languages.registerFoldingRangeProvider(latexSelector, new FoldingProvider()), vscode.languages.registerFoldingRangeProvider(weaveSelector, new WeaveFoldingProvider()) @@ -279,10 +377,10 @@ function registerProviders() { const selectionLatex = configuration.get('selection.smart.latex.enabled', true) if (selectionLatex) { - lw.registerDisposable(vscode.languages.registerSelectionRangeProvider({language: 'latex'}, new SelectionRangeProvider())) + extensionContext.subscriptions.push(vscode.languages.registerSelectionRangeProvider({language: 'latex'}, new SelectionRangeProvider())) } - lw.registerDisposable( + extensionContext.subscriptions.push( vscode.window.registerWebviewViewProvider( 'latex-workshop-snippet-view', lw.snippetView.snippetViewProvider, diff --git a/src/providers/structure.ts b/src/outline/project.ts similarity index 92% rename from src/providers/structure.ts rename to src/outline/project.ts index 57828ae95..4a0e1fed3 100644 --- a/src/providers/structure.ts +++ b/src/outline/project.ts @@ -1,29 +1,16 @@ import * as vscode from 'vscode' -import * as lw from '../lw' -import { StructureUpdated } from '../components/eventbus' +import { lw } from '../lw' +import { StructureUpdated } from '../core/event-bus' import { construct as constructLaTeX } from './structurelib/latex' import { buildBibTeX } from './structurelib/bibtex' import { construct as constructDocTeX } from './structurelib/doctex' -import { getLogger } from '../components/logger' -import { parser } from '../components/parser' +import type { TeXElement } from './structurelib/types' +import { getLogger } from '../utils/logging/logger' +import { parser } from '../parse/parser' const logger = getLogger('Structure') -export enum TeXElementType { Environment, Command, Section, SectionAst, SubFile, BibItem, BibField } - -export type TeXElement = { - readonly type: TeXElementType, - readonly name: string, - label: string, - readonly lineFr: number, - lineTo: number, - readonly filePath: string, - children: TeXElement[], - parent?: TeXElement, - appendix?: boolean -} - export class StructureView implements vscode.TreeDataProvider { private readonly structureChanged: vscode.EventEmitter = new vscode.EventEmitter() readonly onDidChangeTreeData: vscode.Event diff --git a/src/providers/structurelib/bibtex.ts b/src/outline/structurelib/bibtex.ts similarity index 92% rename from src/providers/structurelib/bibtex.ts rename to src/outline/structurelib/bibtex.ts index 591ad4336..088844954 100644 --- a/src/providers/structurelib/bibtex.ts +++ b/src/outline/structurelib/bibtex.ts @@ -1,10 +1,10 @@ import * as vscode from 'vscode' import { bibtexParser } from 'latex-utensils' -import { TeXElement, TeXElementType } from '../structure' -import { parser } from '../../components/parser' +import { TeXElement, TeXElementType } from './types' +import { parser } from '../../parse/parser' -import { getLogger } from '../../components/logger' -import { bibTools } from '../completer/citation' +import { getLogger } from '../../utils/logging/logger' +import { bibTools } from '../../completion/completer/citation' const logger = getLogger('Structure', 'BibTeX') diff --git a/src/providers/structurelib/doctex.ts b/src/outline/structurelib/doctex.ts similarity index 94% rename from src/providers/structurelib/doctex.ts rename to src/outline/structurelib/doctex.ts index eab8eb921..a2c650c73 100644 --- a/src/providers/structurelib/doctex.ts +++ b/src/outline/structurelib/doctex.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' -import { TeXElement } from '../structure' -import { parser } from '../../components/parser' +import { TeXElement } from './types' +import { parser } from '../../parse/parser' import { outline } from './latex' -import { getLogger } from '../../components/logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Structure', 'DocTeX') diff --git a/src/providers/structurelib/latex.ts b/src/outline/structurelib/latex.ts similarity index 99% rename from src/providers/structurelib/latex.ts rename to src/outline/structurelib/latex.ts index a825792f8..f7667a036 100644 --- a/src/providers/structurelib/latex.ts +++ b/src/outline/structurelib/latex.ts @@ -1,12 +1,12 @@ import * as vscode from 'vscode' import * as path from 'path' import type * as Ast from '@unified-latex/unified-latex-types' -import * as lw from '../../lw' -import { TeXElement, TeXElementType } from '../structure' +import { lw } from '../../lw' +import { TeXElement, TeXElementType } from './types' import { resolveFile } from '../../utils/utils' import { InputFileRegExp } from '../../utils/inputfilepath' -import { getLogger } from '../../components/logger' +import { getLogger } from '../../utils/logging/logger' import { argContentToStr } from '../../utils/parser' const logger = getLogger('Structure', 'LaTeX') diff --git a/src/outline/structurelib/types.ts b/src/outline/structurelib/types.ts new file mode 100644 index 000000000..9f0183ee6 --- /dev/null +++ b/src/outline/structurelib/types.ts @@ -0,0 +1,13 @@ +export enum TeXElementType { Environment, Command, Section, SectionAst, SubFile, BibItem, BibField } + +export type TeXElement = { + readonly type: TeXElementType, + readonly name: string, + label: string, + readonly lineFr: number, + lineTo: number, + readonly filePath: string, + children: TeXElement[], + parent?: TeXElement, + appendix?: boolean +} \ No newline at end of file diff --git a/src/components/parser.ts b/src/parse/parser.ts similarity index 100% rename from src/components/parser.ts rename to src/parse/parser.ts diff --git a/src/components/parserlib/biberlog.ts b/src/parse/parserlib/biberlog.ts similarity index 97% rename from src/components/parserlib/biberlog.ts rename to src/parse/parserlib/biberlog.ts index faf2cf7cc..a43f6e9c5 100644 --- a/src/components/parserlib/biberlog.ts +++ b/src/parse/parserlib/biberlog.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' -import * as lw from '../../lw' +import { lw } from '../../lw' import { type IParser, type LogEntry, showCompilerDiagnostics } from './parserutils' -import { getLogger } from '../logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Parser', 'BiberLog') diff --git a/src/components/parserlib/bibtexlog.ts b/src/parse/parserlib/bibtexlog.ts similarity index 98% rename from src/components/parserlib/bibtexlog.ts rename to src/parse/parserlib/bibtexlog.ts index c1167cbd2..9c5eea8b3 100644 --- a/src/components/parserlib/bibtexlog.ts +++ b/src/parse/parserlib/bibtexlog.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' -import * as lw from '../../lw' +import { lw } from '../../lw' import { type IParser, type LogEntry, showCompilerDiagnostics } from './parserutils' -import { getLogger } from '../logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Parser', 'BibTeXLog') diff --git a/src/components/parserlib/latexlog.ts b/src/parse/parserlib/latexlog.ts similarity index 99% rename from src/components/parserlib/latexlog.ts rename to src/parse/parserlib/latexlog.ts index b531236ff..9c6d4ed45 100644 --- a/src/components/parserlib/latexlog.ts +++ b/src/parse/parserlib/latexlog.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' import * as path from 'path' -import * as lw from '../../lw' +import { lw } from '../../lw' import { type IParser, type LogEntry, showCompilerDiagnostics } from './parserutils' -import { getLogger } from '../logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Parser', 'TexLog') diff --git a/src/components/parserlib/parserutils.ts b/src/parse/parserlib/parserutils.ts similarity index 98% rename from src/components/parserlib/parserutils.ts rename to src/parse/parserlib/parserutils.ts index bd6be4cf4..6864396a5 100644 --- a/src/components/parserlib/parserutils.ts +++ b/src/parse/parserlib/parserutils.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode' import * as fs from 'fs' -import * as lw from '../../lw' +import { lw } from '../../lw' import { convertFilenameEncoding } from '../../utils/convertfilename' export interface IParser { diff --git a/src/components/parserlib/unified-defs.ts b/src/parse/parserlib/unified-defs.ts similarity index 100% rename from src/components/parserlib/unified-defs.ts rename to src/parse/parserlib/unified-defs.ts diff --git a/src/components/parserlib/unified.ts b/src/parse/parserlib/unified.ts similarity index 100% rename from src/components/parserlib/unified.ts rename to src/parse/parserlib/unified.ts diff --git a/src/providers/preview/graphicspreview.ts b/src/preview/graphics.ts similarity index 98% rename from src/providers/preview/graphicspreview.ts rename to src/preview/graphics.ts index dc22ead01..d9763d540 100644 --- a/src/providers/preview/graphicspreview.ts +++ b/src/preview/graphics.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' -import * as lw from '../../lw' -import { getLogger } from '../../components/logger' +import { lw } from '../lw' +import { getLogger } from '../utils/logging/logger' const logger = getLogger('Preview', 'Graphics') diff --git a/src/providers/hover.ts b/src/preview/hover.ts similarity index 95% rename from src/providers/hover.ts rename to src/preview/hover.ts index 98799a07b..b151f6114 100644 --- a/src/providers/hover.ts +++ b/src/preview/hover.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' -import * as lw from '../lw' -import { tokenizer, onAPackage } from './tokenizer' -import { findProjectNewCommand } from './preview/mathpreviewlib/newcommandfinder' -import { CmdEnvSuggestion } from './completer/completerutils' +import { lw } from '../lw' +import { tokenizer, onAPackage } from '../utils/tokenizer' +import { findProjectNewCommand } from '../preview/math/mathpreviewlib/newcommandfinder' +import { CmdEnvSuggestion } from '../completion/completer/completerutils' export class HoverProvider implements vscode.HoverProvider { public async provideHover(document: vscode.TextDocument, position: vscode.Position, ctoken: vscode.CancellationToken): Promise { diff --git a/src/providers/preview/mathjaxpool.ts b/src/preview/math/mathjaxpool.ts similarity index 100% rename from src/providers/preview/mathjaxpool.ts rename to src/preview/math/mathjaxpool.ts diff --git a/src/providers/preview/mathjaxpool_worker.ts b/src/preview/math/mathjaxpool_worker.ts similarity index 100% rename from src/providers/preview/mathjaxpool_worker.ts rename to src/preview/math/mathjaxpool_worker.ts diff --git a/src/providers/preview/mathpreview.ts b/src/preview/math/mathpreview.ts similarity index 97% rename from src/providers/preview/mathpreview.ts rename to src/preview/math/mathpreview.ts index 9133837cc..b32ae0941 100644 --- a/src/providers/preview/mathpreview.ts +++ b/src/preview/math/mathpreview.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import { MathJaxPool } from './mathjaxpool' import * as utils from '../../utils/svg' -import type { ReferenceEntry } from '../completer/reference' +import type { ReferenceEntry } from '../../completion/completer/reference' import { getCurrentThemeLightness } from '../../utils/theme' import { renderCursor } from './mathpreviewlib/cursorrenderer' import { type ITextDocumentLike, TextDocumentLike } from './mathpreviewlib/textdocumentlike' @@ -9,7 +9,7 @@ import { findProjectNewCommand } from './mathpreviewlib/newcommandfinder' import { TexMathEnv, TeXMathEnvFinder } from './mathpreviewlib/texmathenvfinder' import { HoverPreviewOnRefProvider } from './mathpreviewlib/hoverpreviewonref' import { MathPreviewUtils } from './mathpreviewlib/mathpreviewutils' -import { getLogger } from '../../components/logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Preview', 'Math') diff --git a/src/providers/preview/mathpreviewlib/cursorrenderer.ts b/src/preview/math/mathpreviewlib/cursorrenderer.ts similarity index 96% rename from src/providers/preview/mathpreviewlib/cursorrenderer.ts rename to src/preview/math/mathpreviewlib/cursorrenderer.ts index 3b9219302..11ce50a53 100644 --- a/src/providers/preview/mathpreviewlib/cursorrenderer.ts +++ b/src/preview/math/mathpreviewlib/cursorrenderer.ts @@ -2,9 +2,9 @@ import * as vscode from 'vscode' import type * as Ast from '@unified-latex/unified-latex-types' import { TexMathEnv } from './texmathenvfinder' import type { ITextDocumentLike } from './textdocumentlike' -import { parser } from '../../../components/parser' -import { getLogger } from '../../../components/logger' -import { findNode } from '../../selection' +import { parser } from '../../../parse/parser' +import { getLogger } from '../../../utils/logging/logger' +import { findNode } from '../../../language/selection' const logger = getLogger('Preview', 'Math', 'Cursor') diff --git a/src/providers/preview/mathpreviewlib/hoverpreviewonref.ts b/src/preview/math/mathpreviewlib/hoverpreviewonref.ts similarity index 96% rename from src/providers/preview/mathpreviewlib/hoverpreviewonref.ts rename to src/preview/math/mathpreviewlib/hoverpreviewonref.ts index 8d33cc961..56bdf3694 100644 --- a/src/providers/preview/mathpreviewlib/hoverpreviewonref.ts +++ b/src/preview/math/mathpreviewlib/hoverpreviewonref.ts @@ -1,10 +1,10 @@ import * as vscode from 'vscode' import * as utils from '../../../utils/svg' import { MathJaxPool } from '../mathjaxpool' -import type { ReferenceEntry } from '../../completer/reference' +import type { ReferenceEntry } from '../../../completion/completer/reference' import type { TexMathEnv } from './texmathenvfinder' import { MathPreviewUtils } from './mathpreviewutils' -import { getLogger } from '../../../components/logger' +import { getLogger } from '../../../utils/logging/logger' const logger = getLogger('Preview', 'Hover') diff --git a/src/providers/preview/mathpreviewlib/mathpreviewutils.ts b/src/preview/math/mathpreviewlib/mathpreviewutils.ts similarity index 100% rename from src/providers/preview/mathpreviewlib/mathpreviewutils.ts rename to src/preview/math/mathpreviewlib/mathpreviewutils.ts diff --git a/src/providers/preview/mathpreviewlib/newcommandfinder.ts b/src/preview/math/mathpreviewlib/newcommandfinder.ts similarity index 97% rename from src/providers/preview/mathpreviewlib/newcommandfinder.ts rename to src/preview/math/mathpreviewlib/newcommandfinder.ts index d049585bb..99f34428f 100644 --- a/src/providers/preview/mathpreviewlib/newcommandfinder.ts +++ b/src/preview/math/mathpreviewlib/newcommandfinder.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' import * as path from 'path' -import * as lw from '../../../lw' +import { lw } from '../../../lw' import { stripCommentsAndVerbatim } from '../../../utils/utils' -import { getLogger } from '../../../components/logger' +import { getLogger } from '../../../utils/logging/logger' const logger = getLogger('Preview', 'Math') diff --git a/src/providers/preview/mathpreviewlib/texmathenvfinder.ts b/src/preview/math/mathpreviewlib/texmathenvfinder.ts similarity index 99% rename from src/providers/preview/mathpreviewlib/texmathenvfinder.ts rename to src/preview/math/mathpreviewlib/texmathenvfinder.ts index b821f5ee6..15f07247d 100644 --- a/src/providers/preview/mathpreviewlib/texmathenvfinder.ts +++ b/src/preview/math/mathpreviewlib/texmathenvfinder.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import * as utils from '../../../utils/utils' import { type ITextDocumentLike, TextDocumentLike } from './textdocumentlike' -import type { ReferenceEntry } from '../../completer/reference' +import type { ReferenceEntry } from '../../../completion/completer/reference' export type TexMathEnv = { texString: string, range: vscode.Range, envname: string } diff --git a/src/providers/preview/mathpreviewlib/textdocumentlike.ts b/src/preview/math/mathpreviewlib/textdocumentlike.ts similarity index 100% rename from src/providers/preview/mathpreviewlib/textdocumentlike.ts rename to src/preview/math/mathpreviewlib/textdocumentlike.ts diff --git a/src/components/server.ts b/src/preview/server.ts similarity index 99% rename from src/components/server.ts rename to src/preview/server.ts index bb18a7817..0cb5341a5 100644 --- a/src/components/server.ts +++ b/src/preview/server.ts @@ -4,10 +4,10 @@ import ws from 'ws' import * as fs from 'fs' import * as path from 'path' import * as vscode from 'vscode' -import * as lw from '../lw' +import { lw } from '../lw' import * as PdfFilePathEncoder from './serverlib/encodepath' import { EventEmitter } from 'events' -import { getLogger } from './logger' +import { getLogger } from '../utils/logging/logger' import { viewerManager } from './viewerlib/pdfviewermanager' const logger = getLogger('Server') diff --git a/src/components/serverlib/encodepath.ts b/src/preview/serverlib/encodepath.ts similarity index 100% rename from src/components/serverlib/encodepath.ts rename to src/preview/serverlib/encodepath.ts diff --git a/src/components/viewer.ts b/src/preview/viewer.ts similarity index 97% rename from src/components/viewer.ts rename to src/preview/viewer.ts index c781e158f..f4ba1d57a 100644 --- a/src/components/viewer.ts +++ b/src/preview/viewer.ts @@ -3,15 +3,15 @@ import type ws from 'ws' import * as path from 'path' import * as os from 'os' import * as cs from 'cross-spawn' -import * as lw from '../lw' -import type { SyncTeXRecordForward } from './locator' +import { lw, registerDisposable } from '../lw' +import type { SyncTeXRecordForward } from '../locate/synctex' import { getCurrentThemeLightness } from '../utils/theme' import type { ClientRequest, PdfViewerParams, PdfViewerState } from '../../types/latex-workshop-protocol-types/index' import { Client } from './viewerlib/client' import { createPdfViewerPanel } from './viewerlib/pdfviewerpanel' import { viewerManager } from './viewerlib/pdfviewermanager' -import { ViewerPageLoaded } from './eventbus' -import { getLogger } from './logger' +import { ViewerPageLoaded } from '../core/event-bus' +import { getLogger } from '../utils/logging/logger' import { moveActiveEditor } from '../utils/webview' const logger = getLogger('Viewer') @@ -23,12 +23,12 @@ export { pdfViewerPanelSerializer } from './viewerlib/pdfviewerpanel' export class Viewer { constructor() { - lw.cacher.pdf.onChange(pdfPath => { + lw.watcher.pdf.onChange(pdfPath => { if (lw.builder.isOutputPDF(pdfPath)) { this.refreshExistingViewer(pdfPath) } }) - lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { + registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => { if (e.affectsConfiguration('latex-workshop.view.pdf.invertMode.enabled') || e.affectsConfiguration('latex-workshop.view.pdf.invert') || e.affectsConfiguration('latex-workshop.view.pdf.invertMode.brightness') || @@ -128,7 +128,7 @@ export class Viewer { } const pdfFileUri = vscode.Uri.file(pdfFile) viewerManager.createClientSet(pdfFileUri) - lw.cacher.pdf.add(pdfFileUri.fsPath) + lw.watcher.pdf.add(pdfFileUri.fsPath) try { logger.log(`Serving PDF file at ${url}`) await vscode.env.openExternal(vscode.Uri.parse(url, true)) diff --git a/src/components/viewerlib/client.ts b/src/preview/viewerlib/client.ts similarity index 89% rename from src/components/viewerlib/client.ts rename to src/preview/viewerlib/client.ts index 5b2c8a668..56274cd2b 100644 --- a/src/components/viewerlib/client.ts +++ b/src/preview/viewerlib/client.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode' import type ws from 'ws' -import type {ServerResponse} from '../../../types/latex-workshop-protocol-types/index' +import type { ServerResponse } from '../../../types/latex-workshop-protocol-types/index' export class Client { readonly viewer: 'browser' | 'tab' diff --git a/src/components/viewerlib/pdfviewerhook.ts b/src/preview/viewerlib/pdfviewerhook.ts similarity index 94% rename from src/components/viewerlib/pdfviewerhook.ts rename to src/preview/viewerlib/pdfviewerhook.ts index 0c1923cc9..f6d103685 100644 --- a/src/components/viewerlib/pdfviewerhook.ts +++ b/src/preview/viewerlib/pdfviewerhook.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode' -import * as lw from '../../lw' -import { ViewerMode } from '../viewer' +import { lw } from '../../lw' +import type { ViewerMode } from '../viewer' import { viewerManager } from './pdfviewermanager' import { populatePdfViewerPanel } from './pdfviewerpanel' diff --git a/src/components/viewerlib/pdfviewermanager.ts b/src/preview/viewerlib/pdfviewermanager.ts similarity index 92% rename from src/components/viewerlib/pdfviewermanager.ts rename to src/preview/viewerlib/pdfviewermanager.ts index 075a1b007..23c0b8d89 100644 --- a/src/components/viewerlib/pdfviewermanager.ts +++ b/src/preview/viewerlib/pdfviewermanager.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' -import * as lw from '../../lw' -import type {Client} from './client' -import type {PdfViewerPanel} from './pdfviewerpanel' +import { lw } from '../../lw' +import type { Client } from './client' +import type { PdfViewerPanel } from './pdfviewerpanel' class PdfViewerManager { private readonly webviewPanelMap = new Map>() @@ -50,7 +50,7 @@ class PdfViewerManager { initiatePdfViewerPanel(pdfPanel: PdfViewerPanel): PdfViewerPanel | undefined { const pdfFileUri = pdfPanel.pdfFileUri - lw.cacher.pdf.add(pdfFileUri.fsPath) + lw.watcher.pdf.add(pdfFileUri.fsPath) this.createClientSet(pdfFileUri) const panelSet = this.getPanelSet(pdfFileUri) if (!panelSet) { diff --git a/src/components/viewerlib/pdfviewerpanel.ts b/src/preview/viewerlib/pdfviewerpanel.ts similarity index 96% rename from src/components/viewerlib/pdfviewerpanel.ts rename to src/preview/viewerlib/pdfviewerpanel.ts index 32c9ab618..71c1f8971 100644 --- a/src/components/viewerlib/pdfviewerpanel.ts +++ b/src/preview/viewerlib/pdfviewerpanel.ts @@ -1,12 +1,12 @@ import * as vscode from 'vscode' import * as path from 'path' -import * as lw from '../../lw' -import type {PanelRequest, PdfViewerState} from '../../../types/latex-workshop-protocol-types/index' +import { lw } from '../../lw' +import type { PanelRequest, PdfViewerState } from '../../../types/latex-workshop-protocol-types/index' import { escapeHtml, sleep } from '../../utils/utils' import { viewerManager } from './pdfviewermanager' -import { ViewerStatusChanged } from '../eventbus' +import { ViewerStatusChanged } from '../../core/event-bus' -import { getLogger } from '../logger' +import { getLogger } from '../../utils/logging/logger' const logger = getLogger('Viewer', 'Panel') diff --git a/src/components/configuration.ts b/src/utils/logging/log-config.ts similarity index 97% rename from src/components/configuration.ts rename to src/utils/logging/log-config.ts index 4f0b5f69b..1709c68d0 100644 --- a/src/components/configuration.ts +++ b/src/utils/logging/log-config.ts @@ -24,7 +24,7 @@ export class Configuration { private readonly defaultConf: Configs constructor() { - this.defaultConf = (JSON.parse(readFileSync(path.resolve(__dirname, '../../../package.json')).toString()) as PackageJSON).contributes.configuration.properties + this.defaultConf = (JSON.parse(readFileSync(path.resolve(__dirname, '../../../../package.json')).toString()) as PackageJSON).contributes.configuration.properties this.logConfiguration() this.checkDeprecatedConfiguration() vscode.workspace.onDidChangeConfiguration((ev) => { diff --git a/src/components/logger.ts b/src/utils/logging/logger.ts similarity index 100% rename from src/components/logger.ts rename to src/utils/logging/logger.ts diff --git a/src/providers/tokenizer.ts b/src/utils/tokenizer.ts similarity index 98% rename from src/providers/tokenizer.ts rename to src/utils/tokenizer.ts index 1807a5461..ac28c674e 100644 --- a/src/providers/tokenizer.ts +++ b/src/utils/tokenizer.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode' -import * as utils from '../utils/utils' +import * as utils from './utils' /** * If a string on `position` is like `\command`, `\command{` or `\command[`, diff --git a/src/utils/webview.ts b/src/utils/webview.ts index b898f788d..0567a4dd0 100644 --- a/src/utils/webview.ts +++ b/src/utils/webview.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode' -import * as lw from '../lw' +import { lw } from '../lw' export function replaceWebviewPlaceholders(content: string, webview: vscode.Webview): string { const extensionRootUri = vscode.Uri.file(lw.extensionRoot) diff --git a/test/suites/01_build.test.ts b/test/suites/01_build.test.ts index 6ceb72e29..9b478f043 100644 --- a/test/suites/01_build.test.ts +++ b/test/suites/01_build.test.ts @@ -2,9 +2,9 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' import * as assert from 'assert' -import * as lw from '../../src/lw' +import { lw } from '../../src/lw' import * as test from './utils' -import { BuildDone } from '../../src/components/eventbus' +import { BuildDone } from '../../src/core/event-bus' suite('Build TeX files test suite', () => { test.suite.name = path.basename(__filename).replace('.test.js', '') @@ -190,7 +190,7 @@ suite('Build TeX files test suite', () => { await test.build(fixture, 'sub/s.tex', undefined, async () => { const event = test.wait(BuildDone) - void lw.commander.build() + void lw.commands.build() await test.sleep(500) await vscode.commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem') await event @@ -206,7 +206,7 @@ suite('Build TeX files test suite', () => { ], {local: 1, skipCache: true}) await test.build(fixture, 'sub/s.tex', undefined, async () => { const event = test.wait(BuildDone) - void lw.commander.build() + void lw.commands.build() await test.sleep(500) await vscode.commands.executeCommand('workbench.action.quickOpenSelectNext') await test.sleep(250) diff --git a/test/suites/03_findroot.test.ts b/test/suites/03_findroot.test.ts index a7fd85574..17f9b207e 100644 --- a/test/suites/03_findroot.test.ts +++ b/test/suites/03_findroot.test.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import * as path from 'path' import * as assert from 'assert' -import * as lw from '../../src/lw' +import { lw } from '../../src/lw' import * as test from './utils' suite('Find root file test suite', () => { diff --git a/test/suites/04_intellisense.test.ts b/test/suites/04_intellisense.test.ts index aea8a39f0..be4b2fc38 100644 --- a/test/suites/04_intellisense.test.ts +++ b/test/suites/04_intellisense.test.ts @@ -3,12 +3,12 @@ import * as fs from 'fs' import * as path from 'path' import * as assert from 'assert' import { glob } from 'glob' -import * as lw from '../../src/lw' +import { lw } from '../../src/lw' import * as test from './utils' -import { EnvSnippetType, EnvType } from '../../src/providers/completer/environment' -import { CmdType } from '../../src/providers/completer/command' -import { PkgType } from '../../src/providers/completion' -import { isTriggerSuggestNeeded } from '../../src/providers/completer/command' +import { EnvSnippetType, EnvType } from '../../src/completion/completer/environment' +import { CmdType } from '../../src/completion/completer/command' +import { PkgType } from '../../src/completion/latex' +import { isTriggerSuggestNeeded } from '../../src/completion/completer/command' function assertKeys(keys: string[], expected: string[] = [], message: string): void { assert.ok( diff --git a/test/suites/05_viewer.test.ts b/test/suites/05_viewer.test.ts index 93fb5dc73..0c76e3782 100644 --- a/test/suites/05_viewer.test.ts +++ b/test/suites/05_viewer.test.ts @@ -1,9 +1,9 @@ import * as vscode from 'vscode' import * as path from 'path' import * as assert from 'assert' -import * as lw from '../../src/lw' +import { lw } from '../../src/lw' import * as test from './utils' -import { BuildDone } from '../../src/components/eventbus' +import { BuildDone } from '../../src/core/event-bus' suite('PDF viewer test suite', () => { test.suite.name = path.basename(__filename).replace('.test.js', '') @@ -42,11 +42,11 @@ suite('PDF viewer test suite', () => { await test.build(fixture, 'main.tex') await test.view(fixture, 'main.pdf') await test.sleep(250) - await lw.commander.view() + await lw.commands.view() let statuses = lw.viewer.getViewerState(vscode.Uri.file(path.resolve(fixture, 'main.pdf'))) assert.strictEqual(statuses.length, 1) await vscode.workspace.getConfiguration('latex-workshop').update('view.pdf.viewer', 'legacy') - await lw.commander.view() + await lw.commands.view() await test.sleep(250) statuses = lw.viewer.getViewerState(vscode.Uri.file(path.resolve(fixture, 'main.pdf'))) assert.strictEqual(statuses.length, 2) @@ -61,16 +61,16 @@ suite('PDF viewer test suite', () => { await test.build(fixture, 'main.tex') await test.view(fixture, 'main.pdf') await test.sleep(250) - await lw.commander.view() + await lw.commands.view() let statuses = lw.viewer.getViewerState(vscode.Uri.file(path.resolve(fixture, 'main.pdf'))) assert.strictEqual(statuses.length, 1) // Make sure a custom editor was opened await test.sleep(250) - await lw.commander.view() + await lw.commands.view() await test.sleep(250) statuses = lw.viewer.getViewerState(vscode.Uri.file(path.resolve(fixture, 'main.pdf'))) assert.strictEqual(statuses.length, 1) // Make sure the custom editor got reused await vscode.workspace.getConfiguration('latex-workshop').update('view.pdf.viewer', 'legacy') - await lw.commander.view() + await lw.commands.view() await test.sleep(250) statuses = lw.viewer.getViewerState(vscode.Uri.file(path.resolve(fixture, 'main.pdf'))) assert.strictEqual(statuses.length, 2) // Make sure a non-customEditor viewer was opened @@ -109,7 +109,7 @@ suite('PDF viewer test suite', () => { await test.build(fixture, 'sub/s.tex', undefined, async () => { const event = test.wait(BuildDone) - void lw.commander.build() + void lw.commands.build() await test.sleep(500) await vscode.commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem') await event @@ -129,7 +129,7 @@ suite('PDF viewer test suite', () => { await test.build(fixture, 'sub/s.tex', undefined, async () => { const event = test.wait(BuildDone) - void lw.commander.build() + void lw.commands.build() await test.sleep(500) await vscode.commands.executeCommand('workbench.action.quickOpenSelectNext') await test.sleep(250) diff --git a/test/suites/06_structure.test.ts b/test/suites/06_structure.test.ts index 1e576439a..e09b37eed 100644 --- a/test/suites/06_structure.test.ts +++ b/test/suites/06_structure.test.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode' import * as path from 'path' import * as assert from 'assert' -import * as lw from '../../src/lw' +import { lw } from '../../src/lw' import * as test from './utils' // async function loadTestFiles(fixture: string) { diff --git a/test/suites/07_mathpreview.test.ts b/test/suites/07_mathpreview.test.ts index d15a7e027..3d751fd0d 100644 --- a/test/suites/07_mathpreview.test.ts +++ b/test/suites/07_mathpreview.test.ts @@ -2,9 +2,9 @@ import * as vscode from 'vscode' import * as path from 'path' import * as assert from 'assert' import * as test from './utils' -import { TextDocumentLike } from '../../src/providers/preview/mathpreviewlib/textdocumentlike' -import { TeXMathEnvFinder } from '../../src/providers/preview/mathpreviewlib/texmathenvfinder' -import { testTools } from '../../src/providers/preview/mathpreviewlib/cursorrenderer' +import { TextDocumentLike } from '../../src/preview/math/mathpreviewlib/textdocumentlike' +import { TeXMathEnvFinder } from '../../src/preview/math/mathpreviewlib/texmathenvfinder' +import { testTools } from '../../src/preview/math/mathpreviewlib/cursorrenderer' suite('Math preview test suite', () => { test.suite.name = path.basename(__filename).replace('.test.js', '') diff --git a/test/suites/08_linter.test.ts b/test/suites/08_linter.test.ts index c03393910..b63bd750f 100644 --- a/test/suites/08_linter.test.ts +++ b/test/suites/08_linter.test.ts @@ -1,10 +1,10 @@ import * as vscode from 'vscode' import * as path from 'path' import * as assert from 'assert' -import * as lw from '../../src/lw' +import { lw } from '../../src/lw' import * as test from './utils' -import { chkTeX } from '../../src/components/linterlib/chktex' -import { laCheck } from '../../src/components/linterlib/lacheck' +import { chkTeX } from '../../src/lint/linterlib/chktex' +import { laCheck } from '../../src/lint/linterlib/lacheck' suite('Linter test suite', () => { test.suite.name = path.basename(__filename).replace('.test.js', '') diff --git a/test/suites/10_cleaner.test.ts b/test/suites/10_cleaner.test.ts index eb142de5b..4a24f5a3c 100644 --- a/test/suites/10_cleaner.test.ts +++ b/test/suites/10_cleaner.test.ts @@ -2,9 +2,9 @@ import * as vscode from 'vscode' import * as fs from 'fs' import * as path from 'path' import * as assert from 'assert' -import * as lw from '../../src/lw' +import { lw } from '../../src/lw' import * as test from './utils' -import { AutoCleaned } from '../../src/components/eventbus' +import { AutoCleaned } from '../../src/core/event-bus' suite('Cleaner test suite', () => { test.suite.name = path.basename(__filename).replace('.test.js', '') diff --git a/test/suites/11_snippet.test.ts b/test/suites/11_snippet.test.ts index d1bb16a68..c9ad11427 100644 --- a/test/suites/11_snippet.test.ts +++ b/test/suites/11_snippet.test.ts @@ -2,9 +2,9 @@ import * as vscode from 'vscode' import * as path from 'path' import * as assert from 'assert' import * as test from './utils' -import { SurroundCommand } from '../../src/providers/completer/commandlib/surround' -import { ICompletionItem } from '../../src/providers/completion' -import { DocumentChanged } from '../../src/components/eventbus' +import { SurroundCommand } from '../../src/completion/completer/commandlib/surround' +import { ICompletionItem } from '../../src/completion/latex' +import { DocumentChanged } from '../../src/core/event-bus' suite('Snippet test suite', () => { test.suite.name = path.basename(__filename).replace('.test.js', '') @@ -42,5 +42,5 @@ suite('Snippet test suite', () => { await promise const changed = vscode.window.activeTextEditor?.document.getText() assert.ok(changed?.includes('\\fbox{a}bc')) - }) + }, ['linux', 'darwin']) }) diff --git a/test/suites/12_envpair.test.ts b/test/suites/12_envpair.test.ts index 2e7a46d19..2faaf44da 100644 --- a/test/suites/12_envpair.test.ts +++ b/test/suites/12_envpair.test.ts @@ -2,7 +2,7 @@ import * as vscode from 'vscode' import * as path from 'path' import * as assert from 'assert' import * as test from './utils' -import { EnvPair } from '../../src/components/envpair' +import { EnvPair } from '../../src/locate/environment' async function loadTestFiles(fixture: string) { await test.load(fixture, [ diff --git a/test/suites/utils.ts b/test/suites/utils.ts index 5c86db80c..05bcd5f17 100644 --- a/test/suites/utils.ts +++ b/test/suites/utils.ts @@ -4,10 +4,10 @@ import * as fs from 'fs' import { glob } from 'glob' import * as os from 'os' import {ok, strictEqual} from 'assert' -import * as lw from '../../src/lw' -import { AutoBuildInitiated, DocumentChanged, EventArgs, ViewerPageLoaded, ViewerStatusChanged } from '../../src/components/eventbus' -import type { EventName } from '../../src/components/eventbus' -import { getCachedLog, getLogger, resetCachedLog } from '../../src/components/logger' +import { lw } from '../../src/lw' +import { AutoBuildInitiated, DocumentChanged, EventArgs, ViewerPageLoaded, ViewerStatusChanged } from '../../src/core/event-bus' +import type { EventName } from '../../src/core/event-bus' +import { getCachedLog, getLogger, resetCachedLog } from '../../src/utils/logging/logger' let testIndex = 0 const logger = getLogger('Test') @@ -166,7 +166,7 @@ export async function build(fixture: string, openFile: string, ws?: string, acti logger.log(`Open ${openFile} .`) await open(path.resolve(getWsFixture(fixture, ws), openFile)) logger.log('Initiate a build.') - await (action ?? lw.commander.build)() + await (action ?? lw.commands.build)() } export async function auto(fixture: string, editFile: string, noBuild = false, save = false, ws?: string): Promise<{type: 'onChange' | 'onSave', file: string}> { @@ -215,7 +215,7 @@ export async function view(fixture: string, pdfName: string, postAction?: () => wait(ViewerPageLoaded), wait(ViewerStatusChanged) ]) - void lw.commander.view() + void lw.commands.view() if (postAction) { await postAction() } diff --git a/viewer/latexworkshop.ts b/viewer/latexworkshop.ts index dee8c8cbd..f511dd6c8 100644 --- a/viewer/latexworkshop.ts +++ b/viewer/latexworkshop.ts @@ -771,5 +771,3 @@ class LateXWorkshopPdfViewer implements ILatexWorkshopPdfViewer { const extension = new LateXWorkshopPdfViewer() await extension.waitSetupAppOptionsFinished() -// @ts-expect-error -await import('../../viewer/viewer.mjs') diff --git a/viewer/viewer.html b/viewer/viewer.html index b3d67dafa..24554cb9c 100644 --- a/viewer/viewer.html +++ b/viewer/viewer.html @@ -36,6 +36,7 @@ +