diff --git a/packages/typescript-plugin-vue/package.json b/packages/typescript-plugin-vue/package.json index ea7314c2..0e549fb3 100644 --- a/packages/typescript-plugin-vue/package.json +++ b/packages/typescript-plugin-vue/package.json @@ -37,6 +37,12 @@ ] } } + ], + "types/3.x.d.ts": [ + { + "format": "dts", + "file": "runtime/3.x.vuedx_runtime.d.ts" + } ] }, "external": [ @@ -66,10 +72,22 @@ }, "homepage": "https://github.com/znck/vue-developer-experience#readme", "dependencies": { + "@vuedx/projectconfig": "workspace:*", "@vuedx/shared": "workspace:*", - "@vuedx/vue-languageservice": "workspace:*" + "@vuedx/template-ast-types": "workspace:*", + "@vuedx/vue-virtual-textdocument": "workspace:*", + "inversify": "^5.1.1", + "json5": "^2.2.0", + "node-ipc": "10.1.0", + "reflect-metadata": "^0.1.13" }, "devDependencies": { - "typescript": "^4.6.3" + "csstype": "^3.1.0", + "@vuedx/compiler-tsx": "workspace:*", + "@types/web": "^0.0.56", + "@vue/runtime-core": "^3.2.39", + "quick-lru": "^6.0.1", + "vscode-languageserver-types": "^3.16.0", + "vue": "^3.2.39" } } diff --git a/packages/vue-languageservice/src/constants.ts b/packages/typescript-plugin-vue/src/constants.ts similarity index 50% rename from packages/vue-languageservice/src/constants.ts rename to packages/typescript-plugin-vue/src/constants.ts index 84696c08..4d261568 100644 --- a/packages/vue-languageservice/src/constants.ts +++ b/packages/typescript-plugin-vue/src/constants.ts @@ -1,2 +1,2 @@ -export const NAMESPACE = `package:@vuedx/vue-languageservice` as const +export const NAMESPACE = `package:@vuedx/typescript-plugin-vue` as const export const TS_LANGUAGE_SERVICE = Symbol('Undecorated Language Service') diff --git a/packages/vue-languageservice/src/contracts/Disposable.ts b/packages/typescript-plugin-vue/src/contracts/Disposable.ts similarity index 100% rename from packages/vue-languageservice/src/contracts/Disposable.ts rename to packages/typescript-plugin-vue/src/contracts/Disposable.ts diff --git a/packages/vue-languageservice/src/contracts/FilesystemProvider.ts b/packages/typescript-plugin-vue/src/contracts/FilesystemProvider.ts similarity index 57% rename from packages/vue-languageservice/src/contracts/FilesystemProvider.ts rename to packages/typescript-plugin-vue/src/contracts/FilesystemProvider.ts index ec53092d..11a46753 100644 --- a/packages/vue-languageservice/src/contracts/FilesystemProvider.ts +++ b/packages/typescript-plugin-vue/src/contracts/FilesystemProvider.ts @@ -1,13 +1,13 @@ -import type { TextDocumentContentChangeEvent } from '@vuedx/vue-virtual-textdocument'; +import type { TextDocumentContentChangeEvent } from '@vuedx/vue-virtual-textdocument' export interface FilesystemProvider { - exists(fileName: string): boolean; - read(fileName: string): string; + exists(fileName: string): boolean + read(fileName: string): string watch( fileName: string, onChange: ( changes: TextDocumentContentChangeEvent[], - version: number - ) => void - ): () => void; + version: number, + ) => void, + ): () => void } diff --git a/packages/vue-languageservice/src/contracts/LanguageService.ts b/packages/typescript-plugin-vue/src/contracts/LanguageService.ts similarity index 100% rename from packages/vue-languageservice/src/contracts/LanguageService.ts rename to packages/typescript-plugin-vue/src/contracts/LanguageService.ts diff --git a/packages/typescript-plugin-vue/src/contracts/OffsetRangeLike.ts b/packages/typescript-plugin-vue/src/contracts/OffsetRangeLike.ts new file mode 100644 index 00000000..50270784 --- /dev/null +++ b/packages/typescript-plugin-vue/src/contracts/OffsetRangeLike.ts @@ -0,0 +1,4 @@ +export interface OffsetRangeLike { + start: number | undefined + length: number | undefined +} diff --git a/packages/vue-languageservice/src/contracts/TypeScript.ts b/packages/typescript-plugin-vue/src/contracts/TypeScript.ts similarity index 100% rename from packages/vue-languageservice/src/contracts/TypeScript.ts rename to packages/typescript-plugin-vue/src/contracts/TypeScript.ts diff --git a/packages/vue-languageservice/src/contracts/TypescriptProvider.ts b/packages/typescript-plugin-vue/src/contracts/TypescriptProvider.ts similarity index 100% rename from packages/vue-languageservice/src/contracts/TypescriptProvider.ts rename to packages/typescript-plugin-vue/src/contracts/TypescriptProvider.ts diff --git a/packages/vue-languageservice/src/features/CallHierarchyService.ts b/packages/typescript-plugin-vue/src/features/CallHierarchyService.ts similarity index 100% rename from packages/vue-languageservice/src/features/CallHierarchyService.ts rename to packages/typescript-plugin-vue/src/features/CallHierarchyService.ts diff --git a/packages/vue-languageservice/src/features/CodeFixService.ts b/packages/typescript-plugin-vue/src/features/CodeFixService.ts similarity index 100% rename from packages/vue-languageservice/src/features/CodeFixService.ts rename to packages/typescript-plugin-vue/src/features/CodeFixService.ts diff --git a/packages/vue-languageservice/src/features/CommentsService.ts b/packages/typescript-plugin-vue/src/features/CommentsService.ts similarity index 100% rename from packages/vue-languageservice/src/features/CommentsService.ts rename to packages/typescript-plugin-vue/src/features/CommentsService.ts diff --git a/packages/vue-languageservice/src/features/CompletionsService.ts b/packages/typescript-plugin-vue/src/features/CompletionsService.ts similarity index 100% rename from packages/vue-languageservice/src/features/CompletionsService.ts rename to packages/typescript-plugin-vue/src/features/CompletionsService.ts diff --git a/packages/vue-languageservice/src/features/DeclarationService.ts b/packages/typescript-plugin-vue/src/features/DeclarationService.ts similarity index 100% rename from packages/vue-languageservice/src/features/DeclarationService.ts rename to packages/typescript-plugin-vue/src/features/DeclarationService.ts diff --git a/packages/vue-languageservice/src/features/DefinitionService.ts b/packages/typescript-plugin-vue/src/features/DefinitionService.ts similarity index 100% rename from packages/vue-languageservice/src/features/DefinitionService.ts rename to packages/typescript-plugin-vue/src/features/DefinitionService.ts diff --git a/packages/vue-languageservice/src/features/DiagnosticsService.ts b/packages/typescript-plugin-vue/src/features/DiagnosticsService.ts similarity index 100% rename from packages/vue-languageservice/src/features/DiagnosticsService.ts rename to packages/typescript-plugin-vue/src/features/DiagnosticsService.ts diff --git a/packages/vue-languageservice/src/features/EmitService.ts b/packages/typescript-plugin-vue/src/features/EmitService.ts similarity index 100% rename from packages/vue-languageservice/src/features/EmitService.ts rename to packages/typescript-plugin-vue/src/features/EmitService.ts diff --git a/packages/vue-languageservice/src/features/FoldingRangeService.ts b/packages/typescript-plugin-vue/src/features/FoldingRangeService.ts similarity index 100% rename from packages/vue-languageservice/src/features/FoldingRangeService.ts rename to packages/typescript-plugin-vue/src/features/FoldingRangeService.ts diff --git a/packages/vue-languageservice/src/features/FormattingService.ts b/packages/typescript-plugin-vue/src/features/FormattingService.ts similarity index 100% rename from packages/vue-languageservice/src/features/FormattingService.ts rename to packages/typescript-plugin-vue/src/features/FormattingService.ts diff --git a/packages/vue-languageservice/src/features/HighlightsService.ts b/packages/typescript-plugin-vue/src/features/HighlightsService.ts similarity index 100% rename from packages/vue-languageservice/src/features/HighlightsService.ts rename to packages/typescript-plugin-vue/src/features/HighlightsService.ts diff --git a/packages/vue-languageservice/src/features/ImplementationService.ts b/packages/typescript-plugin-vue/src/features/ImplementationService.ts similarity index 100% rename from packages/vue-languageservice/src/features/ImplementationService.ts rename to packages/typescript-plugin-vue/src/features/ImplementationService.ts diff --git a/packages/vue-languageservice/src/features/NavigationService.ts b/packages/typescript-plugin-vue/src/features/NavigationService.ts similarity index 100% rename from packages/vue-languageservice/src/features/NavigationService.ts rename to packages/typescript-plugin-vue/src/features/NavigationService.ts diff --git a/packages/vue-languageservice/src/features/QuickInfoService.ts b/packages/typescript-plugin-vue/src/features/QuickInfoService.ts similarity index 100% rename from packages/vue-languageservice/src/features/QuickInfoService.ts rename to packages/typescript-plugin-vue/src/features/QuickInfoService.ts diff --git a/packages/vue-languageservice/src/features/RefactorService.ts b/packages/typescript-plugin-vue/src/features/RefactorService.ts similarity index 100% rename from packages/vue-languageservice/src/features/RefactorService.ts rename to packages/typescript-plugin-vue/src/features/RefactorService.ts diff --git a/packages/vue-languageservice/src/features/ReferencesService.ts b/packages/typescript-plugin-vue/src/features/ReferencesService.ts similarity index 100% rename from packages/vue-languageservice/src/features/ReferencesService.ts rename to packages/typescript-plugin-vue/src/features/ReferencesService.ts diff --git a/packages/vue-languageservice/src/features/RenameService.ts b/packages/typescript-plugin-vue/src/features/RenameService.ts similarity index 100% rename from packages/vue-languageservice/src/features/RenameService.ts rename to packages/typescript-plugin-vue/src/features/RenameService.ts diff --git a/packages/vue-languageservice/src/features/SignatureHelpService.ts b/packages/typescript-plugin-vue/src/features/SignatureHelpService.ts similarity index 100% rename from packages/vue-languageservice/src/features/SignatureHelpService.ts rename to packages/typescript-plugin-vue/src/features/SignatureHelpService.ts diff --git a/packages/vue-languageservice/src/features/TemplateCompletionsService.ts b/packages/typescript-plugin-vue/src/features/TemplateCompletionsService.ts similarity index 100% rename from packages/vue-languageservice/src/features/TemplateCompletionsService.ts rename to packages/typescript-plugin-vue/src/features/TemplateCompletionsService.ts diff --git a/packages/vue-languageservice/src/features/diagnostics/ScriptSetupDiagnosticsProvider.ts b/packages/typescript-plugin-vue/src/features/diagnostics/ScriptSetupDiagnosticsProvider.ts similarity index 100% rename from packages/vue-languageservice/src/features/diagnostics/ScriptSetupDiagnosticsProvider.ts rename to packages/typescript-plugin-vue/src/features/diagnostics/ScriptSetupDiagnosticsProvider.ts diff --git a/packages/vue-languageservice/src/features/helpers.ts b/packages/typescript-plugin-vue/src/features/helpers.ts similarity index 100% rename from packages/vue-languageservice/src/features/helpers.ts rename to packages/typescript-plugin-vue/src/features/helpers.ts diff --git a/packages/vue-languageservice/src/features/languageFacts/vue-builtin-directives.json b/packages/typescript-plugin-vue/src/features/languageFacts/vue-builtin-directives.json similarity index 100% rename from packages/vue-languageservice/src/features/languageFacts/vue-builtin-directives.json rename to packages/typescript-plugin-vue/src/features/languageFacts/vue-builtin-directives.json diff --git a/packages/vue-languageservice/src/features/languageFacts/vue-template.ts b/packages/typescript-plugin-vue/src/features/languageFacts/vue-template.ts similarity index 100% rename from packages/vue-languageservice/src/features/languageFacts/vue-template.ts rename to packages/typescript-plugin-vue/src/features/languageFacts/vue-template.ts diff --git a/packages/vue-languageservice/src/helpers/areOverlappingTextSpans.ts b/packages/typescript-plugin-vue/src/helpers/areOverlappingTextSpans.ts similarity index 100% rename from packages/vue-languageservice/src/helpers/areOverlappingTextSpans.ts rename to packages/typescript-plugin-vue/src/helpers/areOverlappingTextSpans.ts diff --git a/packages/vue-languageservice/src/helpers/createFilesystemProvider.ts b/packages/typescript-plugin-vue/src/helpers/createFilesystemProvider.ts similarity index 100% rename from packages/vue-languageservice/src/helpers/createFilesystemProvider.ts rename to packages/typescript-plugin-vue/src/helpers/createFilesystemProvider.ts diff --git a/packages/vue-languageservice/src/helpers/isOffsetInSourceLocation.ts b/packages/typescript-plugin-vue/src/helpers/isOffsetInSourceLocation.ts similarity index 100% rename from packages/vue-languageservice/src/helpers/isOffsetInSourceLocation.ts rename to packages/typescript-plugin-vue/src/helpers/isOffsetInSourceLocation.ts diff --git a/packages/vue-languageservice/src/helpers/overrideMethod.ts b/packages/typescript-plugin-vue/src/helpers/overrideMethod.ts similarity index 100% rename from packages/vue-languageservice/src/helpers/overrideMethod.ts rename to packages/typescript-plugin-vue/src/helpers/overrideMethod.ts diff --git a/packages/vue-languageservice/src/helpers/templateContextAtPosition.ts b/packages/typescript-plugin-vue/src/helpers/templateContextAtPosition.ts similarity index 100% rename from packages/vue-languageservice/src/helpers/templateContextAtPosition.ts rename to packages/typescript-plugin-vue/src/helpers/templateContextAtPosition.ts diff --git a/packages/typescript-plugin-vue/src/index.ts b/packages/typescript-plugin-vue/src/index.ts index f3dc4f02..03f41ada 100644 --- a/packages/typescript-plugin-vue/src/index.ts +++ b/packages/typescript-plugin-vue/src/index.ts @@ -7,15 +7,17 @@ console.log = console.trace = () => {} -export type { - PluginConfig, - PluginSideChannel -} from '@vuedx/vue-languageservice' +import 'reflect-metadata' import { Telemetry } from '@vuedx/shared' -import { pluginManager } from '@vuedx/vue-languageservice' import * as Path from 'path' import type { Modules, PluginCreateInfo, TS } from './interfaces' +import type { PluginConfig } from './managers/ConfigManager' +import { pluginManager } from './managers/PluginManager' +import { PluginSideChannel } from './services/PluginSideChannel' + +export { PluginSideChannel } +export type { PluginConfig } pluginManager.fixConsole(console) diff --git a/packages/typescript-plugin-vue/src/interfaces.ts b/packages/typescript-plugin-vue/src/interfaces.ts index 4ee64caa..849084f5 100644 --- a/packages/typescript-plugin-vue/src/interfaces.ts +++ b/packages/typescript-plugin-vue/src/interfaces.ts @@ -1,5 +1,5 @@ -import type { PluginConfig } from '@vuedx/vue-languageservice' import type * as TS from 'typescript/lib/tsserverlibrary' +import type { PluginConfig } from './managers/ConfigManager' export { TS } export interface Modules { diff --git a/packages/vue-languageservice/src/managers/ConfigManager.ts b/packages/typescript-plugin-vue/src/managers/ConfigManager.ts similarity index 100% rename from packages/vue-languageservice/src/managers/ConfigManager.ts rename to packages/typescript-plugin-vue/src/managers/ConfigManager.ts diff --git a/packages/vue-languageservice/src/managers/PluginManager.ts b/packages/typescript-plugin-vue/src/managers/PluginManager.ts similarity index 100% rename from packages/vue-languageservice/src/managers/PluginManager.ts rename to packages/typescript-plugin-vue/src/managers/PluginManager.ts diff --git a/packages/vue-languageservice/src/services/AggregateLanguageService.ts b/packages/typescript-plugin-vue/src/services/AggregateLanguageService.ts similarity index 100% rename from packages/vue-languageservice/src/services/AggregateLanguageService.ts rename to packages/typescript-plugin-vue/src/services/AggregateLanguageService.ts diff --git a/packages/vue-languageservice/src/services/BlockLanguageService.ts b/packages/typescript-plugin-vue/src/services/BlockLanguageService.ts similarity index 100% rename from packages/vue-languageservice/src/services/BlockLanguageService.ts rename to packages/typescript-plugin-vue/src/services/BlockLanguageService.ts diff --git a/packages/vue-languageservice/src/services/CacheService.ts b/packages/typescript-plugin-vue/src/services/CacheService.ts similarity index 100% rename from packages/vue-languageservice/src/services/CacheService.ts rename to packages/typescript-plugin-vue/src/services/CacheService.ts diff --git a/packages/vue-languageservice/src/services/EncodedClassificationsService.ts b/packages/typescript-plugin-vue/src/services/EncodedClassificationsService.ts similarity index 100% rename from packages/vue-languageservice/src/services/EncodedClassificationsService.ts rename to packages/typescript-plugin-vue/src/services/EncodedClassificationsService.ts diff --git a/packages/vue-languageservice/src/services/FilesystemService.ts b/packages/typescript-plugin-vue/src/services/FilesystemService.ts similarity index 100% rename from packages/vue-languageservice/src/services/FilesystemService.ts rename to packages/typescript-plugin-vue/src/services/FilesystemService.ts diff --git a/packages/vue-languageservice/src/services/IPCService.ts b/packages/typescript-plugin-vue/src/services/IPCService.ts similarity index 100% rename from packages/vue-languageservice/src/services/IPCService.ts rename to packages/typescript-plugin-vue/src/services/IPCService.ts diff --git a/packages/vue-languageservice/src/services/LoggerService.ts b/packages/typescript-plugin-vue/src/services/LoggerService.ts similarity index 100% rename from packages/vue-languageservice/src/services/LoggerService.ts rename to packages/typescript-plugin-vue/src/services/LoggerService.ts diff --git a/packages/vue-languageservice/src/services/PluginSideChannel.ts b/packages/typescript-plugin-vue/src/services/PluginSideChannel.ts similarity index 100% rename from packages/vue-languageservice/src/services/PluginSideChannel.ts rename to packages/typescript-plugin-vue/src/services/PluginSideChannel.ts diff --git a/packages/vue-languageservice/src/services/TemplateDeclarationsService.ts b/packages/typescript-plugin-vue/src/services/TemplateDeclarationsService.ts similarity index 100% rename from packages/vue-languageservice/src/services/TemplateDeclarationsService.ts rename to packages/typescript-plugin-vue/src/services/TemplateDeclarationsService.ts diff --git a/packages/vue-languageservice/src/services/TypescriptContextService.ts b/packages/typescript-plugin-vue/src/services/TypescriptContextService.ts similarity index 100% rename from packages/vue-languageservice/src/services/TypescriptContextService.ts rename to packages/typescript-plugin-vue/src/services/TypescriptContextService.ts diff --git a/packages/vue-languageservice/src/services/TypescriptPluginService.ts b/packages/typescript-plugin-vue/src/services/TypescriptPluginService.ts similarity index 96% rename from packages/vue-languageservice/src/services/TypescriptPluginService.ts rename to packages/typescript-plugin-vue/src/services/TypescriptPluginService.ts index b84dcfac..217c705f 100644 --- a/packages/vue-languageservice/src/services/TypescriptPluginService.ts +++ b/packages/typescript-plugin-vue/src/services/TypescriptPluginService.ts @@ -6,18 +6,9 @@ import type { } from '../contracts/TypeScript' import { CodeFixService } from '../features/CodeFixService' import { CompletionsService } from '../features/CompletionsService' -import { - CssLanguageService, - LessLanguageService, - ScssLanguageService, -} from '../features/CssLanguageService' import { DefinitionService } from '../features/DefinitionService' import { DiagnosticsService } from '../features/DiagnosticsService' import { FoldingRangeService } from '../features/FoldingRangeService' -import { - VueHtmlLanguageService, - VueSfcLanguageService, -} from '../features/HtmlLanguageService' import { ImplementationService } from '../features/ImplementationService' import { QuickInfoService } from '../features/QuickInfoService' import { RefactorService } from '../features/RefactorService' @@ -27,7 +18,6 @@ import { SignatureHelpService } from '../features/SignatureHelpService' import { EncodedClassificationsService } from './EncodedClassificationsService' import { FilesystemService } from './FilesystemService' import { IPCService } from './IPCService' -import { LanguageServiceProvider } from './LanguageServiceProvider' import { LoggerService } from './LoggerService' import { TypescriptContextService } from './TypescriptContextService' @@ -71,25 +61,7 @@ export class TypescriptPluginService private readonly ts: TypescriptContextService, @inject(IPCService) private readonly ipc: IPCService, - @inject(LanguageServiceProvider) - private readonly languages: LanguageServiceProvider, - @inject(CssLanguageService) - css: CssLanguageService, - @inject(ScssLanguageService) - scss: ScssLanguageService, - @inject(LessLanguageService) - less: LessLanguageService, - @inject(VueHtmlLanguageService) - html: VueHtmlLanguageService, - @inject(VueSfcLanguageService) - sfc: VueSfcLanguageService, ) { - ;[css, scss, less, html, sfc].forEach((service) => { - service.supportedLanguages.forEach((language) => { - this.languages.registerLanguageService(language, service) - }) - }) - if (Math.random() > 1) { console.log([ this.classifications, diff --git a/packages/vue-languageservice/test-dts/defineSetupComponent.test-d.tsx b/packages/typescript-plugin-vue/test-dts/defineSetupComponent.test-d.tsx similarity index 100% rename from packages/vue-languageservice/test-dts/defineSetupComponent.test-d.tsx rename to packages/typescript-plugin-vue/test-dts/defineSetupComponent.test-d.tsx diff --git a/packages/vue-languageservice/test-dts/fixtures/component-setup-type-only.ts b/packages/typescript-plugin-vue/test-dts/fixtures/component-setup-type-only.ts similarity index 100% rename from packages/vue-languageservice/test-dts/fixtures/component-setup-type-only.ts rename to packages/typescript-plugin-vue/test-dts/fixtures/component-setup-type-only.ts diff --git a/packages/vue-languageservice/test-dts/fixtures/component-setup.ts b/packages/typescript-plugin-vue/test-dts/fixtures/component-setup.ts similarity index 100% rename from packages/vue-languageservice/test-dts/fixtures/component-setup.ts rename to packages/typescript-plugin-vue/test-dts/fixtures/component-setup.ts diff --git a/packages/vue-languageservice/test-dts/fixtures/component.ts b/packages/typescript-plugin-vue/test-dts/fixtures/component.ts similarity index 100% rename from packages/vue-languageservice/test-dts/fixtures/component.ts rename to packages/typescript-plugin-vue/test-dts/fixtures/component.ts diff --git a/packages/vue-languageservice/test-dts/index.d.ts b/packages/typescript-plugin-vue/test-dts/index.d.ts similarity index 100% rename from packages/vue-languageservice/test-dts/index.d.ts rename to packages/typescript-plugin-vue/test-dts/index.d.ts diff --git a/packages/vue-languageservice/test-dts/package.json b/packages/typescript-plugin-vue/test-dts/package.json similarity index 100% rename from packages/vue-languageservice/test-dts/package.json rename to packages/typescript-plugin-vue/test-dts/package.json diff --git a/packages/vue-languageservice/test-dts/props.test-d.tsx b/packages/typescript-plugin-vue/test-dts/props.test-d.tsx similarity index 100% rename from packages/vue-languageservice/test-dts/props.test-d.tsx rename to packages/typescript-plugin-vue/test-dts/props.test-d.tsx diff --git a/packages/vue-languageservice/test-dts/tsconfig.json b/packages/typescript-plugin-vue/test-dts/tsconfig.json similarity index 100% rename from packages/vue-languageservice/test-dts/tsconfig.json rename to packages/typescript-plugin-vue/test-dts/tsconfig.json diff --git a/packages/vue-languageservice/test-dts/v-model.test-d.tsx b/packages/typescript-plugin-vue/test-dts/v-model.test-d.tsx similarity index 100% rename from packages/vue-languageservice/test-dts/v-model.test-d.tsx rename to packages/typescript-plugin-vue/test-dts/v-model.test-d.tsx diff --git a/packages/vue-languageservice/test-dts/v-on.test-d.tsx b/packages/typescript-plugin-vue/test-dts/v-on.test-d.tsx similarity index 100% rename from packages/vue-languageservice/test-dts/v-on.test-d.tsx rename to packages/typescript-plugin-vue/test-dts/v-on.test-d.tsx diff --git a/packages/vue-languageservice/test-dts/v-text.test-d.tsx b/packages/typescript-plugin-vue/test-dts/v-text.test-d.tsx similarity index 67% rename from packages/vue-languageservice/test-dts/v-text.test-d.tsx rename to packages/typescript-plugin-vue/test-dts/v-text.test-d.tsx index e5ef2e4a..54394909 100644 --- a/packages/vue-languageservice/test-dts/v-text.test-d.tsx +++ b/packages/typescript-plugin-vue/test-dts/v-text.test-d.tsx @@ -1,4 +1,4 @@ describe('v-text', () => { - let a = (null as unknown) as string | undefined + let a = null as unknown as string | undefined VueDX.internal.checkDirective('text', 'div' as const, undefined, a, {}) }) diff --git a/packages/typescript-plugin-vue/tsconfig.json b/packages/typescript-plugin-vue/tsconfig.json index 3d0a8f2d..dc970f42 100644 --- a/packages/typescript-plugin-vue/tsconfig.json +++ b/packages/typescript-plugin-vue/tsconfig.json @@ -1,4 +1,4 @@ { "extends": "../../tsconfig.base.json", - "include": ["src/", "../global.d.ts"] + "include": ["src/", "../../@types", "../global.d.ts"] } diff --git a/packages/vue-languageservice/types/3.x.d.ts b/packages/typescript-plugin-vue/types/3.x.d.ts similarity index 100% rename from packages/vue-languageservice/types/3.x.d.ts rename to packages/typescript-plugin-vue/types/3.x.d.ts diff --git a/packages/vue-languageservice/types/shared/Props.d.ts b/packages/typescript-plugin-vue/types/shared/Props.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/Props.d.ts rename to packages/typescript-plugin-vue/types/shared/Props.d.ts diff --git a/packages/vue-languageservice/types/shared/Slots.d.ts b/packages/typescript-plugin-vue/types/shared/Slots.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/Slots.d.ts rename to packages/typescript-plugin-vue/types/shared/Slots.d.ts diff --git a/packages/vue-languageservice/types/shared/checkDirective.d.ts b/packages/typescript-plugin-vue/types/shared/checkDirective.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/checkDirective.d.ts rename to packages/typescript-plugin-vue/types/shared/checkDirective.d.ts diff --git a/packages/vue-languageservice/types/shared/checkDirectiveModel.d.ts b/packages/typescript-plugin-vue/types/shared/checkDirectiveModel.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/checkDirectiveModel.d.ts rename to packages/typescript-plugin-vue/types/shared/checkDirectiveModel.d.ts diff --git a/packages/vue-languageservice/types/shared/checkDirectiveOn.d.ts b/packages/typescript-plugin-vue/types/shared/checkDirectiveOn.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/checkDirectiveOn.d.ts rename to packages/typescript-plugin-vue/types/shared/checkDirectiveOn.d.ts diff --git a/packages/vue-languageservice/types/shared/checkInterpolation.d.ts b/packages/typescript-plugin-vue/types/shared/checkInterpolation.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/checkInterpolation.d.ts rename to packages/typescript-plugin-vue/types/shared/checkInterpolation.d.ts diff --git a/packages/vue-languageservice/types/shared/checkRef.d.ts b/packages/typescript-plugin-vue/types/shared/checkRef.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/checkRef.d.ts rename to packages/typescript-plugin-vue/types/shared/checkRef.d.ts diff --git a/packages/vue-languageservice/types/shared/checkSlots.d.ts b/packages/typescript-plugin-vue/types/shared/checkSlots.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/checkSlots.d.ts rename to packages/typescript-plugin-vue/types/shared/checkSlots.d.ts diff --git a/packages/vue-languageservice/types/shared/components.d.ts b/packages/typescript-plugin-vue/types/shared/components.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/components.d.ts rename to packages/typescript-plugin-vue/types/shared/components.d.ts diff --git a/packages/vue-languageservice/types/shared/directives.d.ts b/packages/typescript-plugin-vue/types/shared/directives.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/directives.d.ts rename to packages/typescript-plugin-vue/types/shared/directives.d.ts diff --git a/packages/vue-languageservice/types/shared/element.d.ts b/packages/typescript-plugin-vue/types/shared/element.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/element.d.ts rename to packages/typescript-plugin-vue/types/shared/element.d.ts diff --git a/packages/vue-languageservice/types/shared/emits.d.ts b/packages/typescript-plugin-vue/types/shared/emits.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/emits.d.ts rename to packages/typescript-plugin-vue/types/shared/emits.d.ts diff --git a/packages/vue-languageservice/types/shared/jsx.d.ts b/packages/typescript-plugin-vue/types/shared/jsx.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/jsx.d.ts rename to packages/typescript-plugin-vue/types/shared/jsx.d.ts diff --git a/packages/vue-languageservice/types/shared/renderList.d.ts b/packages/typescript-plugin-vue/types/shared/renderList.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/renderList.d.ts rename to packages/typescript-plugin-vue/types/shared/renderList.d.ts diff --git a/packages/vue-languageservice/types/shared/renderSlot.d.ts b/packages/typescript-plugin-vue/types/shared/renderSlot.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/renderSlot.d.ts rename to packages/typescript-plugin-vue/types/shared/renderSlot.d.ts diff --git a/packages/vue-languageservice/types/shared/utils.d.ts b/packages/typescript-plugin-vue/types/shared/utils.d.ts similarity index 100% rename from packages/vue-languageservice/types/shared/utils.d.ts rename to packages/typescript-plugin-vue/types/shared/utils.d.ts diff --git a/packages/vue-languageservice/package.json b/packages/vue-languageservice/package.json index f9654b11..fcb20e06 100644 --- a/packages/vue-languageservice/package.json +++ b/packages/vue-languageservice/package.json @@ -7,25 +7,6 @@ "main": "lib/index.cjs", "module": "lib/index.mjs", "types": "lib/index.d.ts", - "buildConfig": { - "sources": { - "types/3.x.d.ts": [ - { - "format": "dts", - "file": "lib/runtime/3.x.vuedx_runtime.d.ts" - }, - { - "format": "dts", - "file": "../typescript-plugin-vue/runtime/3.x.vuedx_runtime.d.ts" - } - ] - }, - "external": [ - "typescript", - "typescript/lib/tsserverlibrary", - "@vue/runtime-core" - ] - }, "files": [ "lib/" ], @@ -46,24 +27,12 @@ "url": "https://github.com/sponsors/znck" }, "dependencies": { - "@vuedx/projectconfig": "workspace:*", "@vuedx/shared": "workspace:*", "@vuedx/template-ast-types": "workspace:*", - "@vuedx/vue-virtual-textdocument": "workspace:*", "inversify": "^5.1.1", - "json5": "^2.2.0", - "node-ipc": "10.1.0", "reflect-metadata": "^0.1.13", "vscode-css-languageservice": "^5.1.13", "vscode-html-languageservice": "^4.2.2" }, - "devDependencies": { - "csstype": "^3.1.0", - "@vuedx/compiler-tsx": "workspace:*", - "@types/web": "^0.0.56", - "@vue/runtime-core": "^3.2.39", - "quick-lru": "^6.0.1", - "vscode-languageserver-types": "^3.16.0", - "vue": "^3.2.39" - } + "devDependencies": {} } diff --git a/packages/vue-languageservice/src/contracts/OffsetRangeLike.ts b/packages/vue-languageservice/src/contracts/OffsetRangeLike.ts deleted file mode 100644 index 47b273ae..00000000 --- a/packages/vue-languageservice/src/contracts/OffsetRangeLike.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface OffsetRangeLike { - start: number | undefined; - length: number | undefined; -} diff --git a/packages/vue-languageservice/src/features/CssLanguageService.ts b/packages/vue-languageservice/src/features/CssLanguageService.ts deleted file mode 100644 index 76402c62..00000000 --- a/packages/vue-languageservice/src/features/CssLanguageService.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { inject, injectable } from 'inversify' -import { - getCSSLanguageService, - getLESSLanguageService, - getSCSSLanguageService, - LanguageService as VSCodeCssLanguageService, - Stylesheet, - TextDocument, -} from 'vscode-css-languageservice' -import type { LanguageService } from '../contracts/LanguageService' -import { CacheService } from '../services/CacheService' -import { FilesystemService } from '../services/FilesystemService' -import { LoggerService } from '../services/LoggerService' - -abstract class BaseLanguageService implements LanguageService { - protected readonly logger = LoggerService.getLogger('CssLanguageService') - protected readonly stylesheets = new CacheService((fileName) => - this.fs.getVersion(fileName), - ) - - constructor( - protected readonly fs: FilesystemService, - protected readonly service: VSCodeCssLanguageService, - ) {} - - private getTextDocument(fileName: string): TextDocument { - const doc = this.fs.getSourceFile(fileName) - - if (doc == null) throw new Error(`File not found: ${fileName}`) - this.logger.debug('Reading:', fileName, doc.getText()) - - return doc - } - - private getStylesheet(fileName: string): Stylesheet { - return this.stylesheets.withCache(fileName, (stylesheet) => { - if (stylesheet != null) return stylesheet - return this.service.parseStylesheet(this.getTextDocument(fileName)) - }) - } - - public getDiagnostics(fileName: string): LanguageService.Diagnostic[] { - return this.service.doValidation( - this.getTextDocument(fileName), - this.getStylesheet(fileName), - ) - } - - public getDefinitionAt( - fileName: string, - position: LanguageService.Position, - ): LanguageService.Definition[] { - const definition = this.service.findDefinition( - this.getTextDocument(fileName), - position, - this.getStylesheet(fileName), - ) - - return definition != null ? [definition] : [] - } - - public getQuickInfoAtPosition( - fileName: string, - position: LanguageService.Position, - ): LanguageService.QuickInfo | null { - return this.service.doHover( - this.getTextDocument(fileName), - position, - this.getStylesheet(fileName), - ) - } - - public getCompletionsAtPosition( - fileName: string, - position: LanguageService.Position, - ): LanguageService.CompletionList { - return this.service.doComplete( - this.getTextDocument(fileName), - position, - this.getStylesheet(fileName), - { - triggerPropertyValueCompletion: true, - completePropertyWithSemicolon: true, - }, - ) - } - - public dispose(): void { - // noop - } -} - -@injectable() -export class CssLanguageService extends BaseLanguageService { - public constructor(@inject(FilesystemService) fs: FilesystemService) { - super(fs, getCSSLanguageService({ useDefaultDataProvider: true })) - } - - public readonly supportedLanguages = ['css'] -} - -@injectable() -export class ScssLanguageService extends BaseLanguageService { - public constructor(@inject(FilesystemService) fs: FilesystemService) { - super(fs, getSCSSLanguageService({ useDefaultDataProvider: true })) - } - - public readonly supportedLanguages = ['scss', 'sass'] -} - -@injectable() -export class LessLanguageService extends BaseLanguageService { - public constructor(@inject(FilesystemService) fs: FilesystemService) { - super(fs, getLESSLanguageService({ useDefaultDataProvider: true })) - } - - public readonly supportedLanguages = ['less'] -} diff --git a/packages/vue-languageservice/src/features/HtmlLanguageService.ts b/packages/vue-languageservice/src/features/HtmlLanguageService.ts deleted file mode 100644 index e7c0c961..00000000 --- a/packages/vue-languageservice/src/features/HtmlLanguageService.ts +++ /dev/null @@ -1,345 +0,0 @@ -import { debug, ucfirst } from '@vuedx/shared' -import type { TextDocument } from '@vuedx/vue-virtual-textdocument' -import { inject, injectable } from 'inversify' -import type { - CompletionList, - HTMLDocument, - LanguageService as VSCodeHtmlLanguageService, - Position, -} from 'vscode-html-languageservice' -import { - getLanguageService, - newHTMLDataProvider, -} from 'vscode-html-languageservice' -import type { LanguageService } from '../contracts/LanguageService' -import { CacheService } from '../services/CacheService' -import { FilesystemService } from '../services/FilesystemService' -import { LoggerService } from '../services/LoggerService' -import { TypescriptContextService } from '../services/TypescriptContextService' -import { data } from './languageFacts/vue' - -abstract class HtmlLanguageService implements LanguageService { - protected readonly logger = LoggerService.getLogger('HTML') - - private readonly documents = new CacheService((fileName) => - this.fs.getVersion(fileName), - ) - - protected constructor( - protected readonly fs: FilesystemService, - protected readonly service: VSCodeHtmlLanguageService, - ) {} - - getDiagnostics(_fileName: string): LanguageService.Diagnostic[] { - return [] - } - - getDefinitionAt( - _fileName: string, - _position: LanguageService.Position, - ): LanguageService.Definition[] { - return [] - } - - getQuickInfoAtPosition( - fileName: string, - position: LanguageService.Position, - ): LanguageService.QuickInfo | null { - return this.service.doHover( - this.getTextDocument(fileName), - position, - this.getHTMLDocument(fileName), - ) - } - - public getCompletionsAtPosition( - fileName: string, - position: LanguageService.Position, - ): LanguageService.CompletionList { - return this.service.doComplete( - this.getTextDocument(fileName), - position, - this.getHTMLDocument(fileName), - { - attributeDefaultValue: 'doublequotes', - hideAutoCompleteProposals: false, - }, - ) - } - - protected getTextDocument(fileName: string): TextDocument { - const doc = this.fs.getSourceFile(fileName) - - if (doc == null) throw new Error(`File not found: ${fileName}`) - - return doc - } - - protected getHTMLDocument(fileName: string): HTMLDocument { - return this.documents.withCache(fileName, (document) => { - if (document != null) return document - - return this.service.parseHTMLDocument(this.getTextDocument(fileName)) - }) - } - - public dispose(): void { - // noop - } -} - -@injectable() -export class VueHtmlLanguageService extends HtmlLanguageService { - public constructor( - @inject(FilesystemService) - fs: FilesystemService, - ) { - super(fs, getLanguageService({ useDefaultDataProvider: true })) - } - - public readonly supportedLanguages = ['vue-html'] - - public getCompletionsAtPosition( - fileName: string, - position: Position, - ): CompletionList { - const result = super.getCompletionsAtPosition(fileName, position) - - result.items = result.items.map((item) => { - if (item.label.startsWith('on')) { - const label = item.label - item.label = `on${ucfirst(item.label.slice(2))}` - if (item.insertText != null) { - item.insertText = item.insertText.replace(label, item.label) - } - if (item.textEdit != null) { - item.textEdit.newText = item.textEdit.newText.replace( - label, - item.label, - ) - } - } - return item - }) - - return result - } - - public getQuickInfoAtPosition( - fileName: string, - position: LanguageService.Position, - ): LanguageService.QuickInfo | null { - this.logger.debug( - `QuickInfo at ${fileName}:${position.line}:${position.character}`, - ) - - const text = this.getTextDocument(fileName) - const html = this.getHTMLDocument(fileName) - const node = html.findNodeAt(text.offsetAt(position)) - - //