New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

volar-service-typescript

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

volar-service-typescript - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

13

out/index.d.ts
import { InjectionKey, Service } from '@volar/language-service';
import type * as ts from 'typescript/lib/tsserverlibrary';
import type { TextDocument } from 'vscode-languageserver-textdocument';
export declare const rulesInjectionKey: InjectionKey<{
sourceFile: ts.SourceFile;
languageService: ts.LanguageService;
languageServiceHost: ts.LanguageServiceHost;
getTextDocument(uri: string): TextDocument | undefined;
}>;
export declare const injectionKeys: {
typescript: InjectionKey<[], typeof import('typescript/lib/tsserverlibrary')>;
sourceFile: InjectionKey<[TextDocument], ts.SourceFile>;
languageService: InjectionKey<[TextDocument], ts.LanguageService>;
languageServiceHost: InjectionKey<[TextDocument], ts.LanguageServiceHost>;
textDocument: InjectionKey<[uri: string], TextDocument>;
};
declare const _default: () => Service;
export default _default;

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.rulesInjectionKey = void 0;
exports.injectionKeys = void 0;
const language_service_1 = require("@volar/language-service");

@@ -59,3 +59,9 @@ const semver = __importStar(require("semver"));

const tsconfig = __importStar(require("./services/tsconfig"));
exports.rulesInjectionKey = Symbol();
exports.injectionKeys = {
typescript: 'typescript/typescript',
sourceFile: 'typescript/sourceFile',
languageService: 'typescript/languageService',
languageServiceHost: 'typescript/languageServiceHost',
textDocument: 'typescript/textDocument',
};
exports.default = () => (contextOrNull, modules) => {

@@ -121,2 +127,3 @@ const jsDocTriggerCharacter = '*';

let syntacticHostCtx = {
document: undefined,
fileName: '',

@@ -149,32 +156,31 @@ fileVersion: 0,

return {
rules: {
provide: {
[exports.rulesInjectionKey](document, type) {
if ((0, shared_1.isTsDocument)(document)) {
if (type === language_service_1.RuleType.Format || type === language_service_1.RuleType.Syntax) {
prepareSyntacticService(document);
const sourceFile = syntacticCtx.typescript.languageService.getProgram()?.getSourceFile(syntacticHostCtx.fileName);
if (sourceFile) {
return {
sourceFile,
languageService: syntacticCtx.typescript.languageService,
languageServiceHost: syntacticCtx.typescript.languageServiceHost,
getTextDocument: syntacticCtx.getTextDocument,
};
}
}
else {
const sourceFile = semanticCtx.typescript.languageService.getProgram()?.getSourceFile(context.env.uriToFileName(document.uri));
if (sourceFile) {
return {
sourceFile,
languageService: semanticCtx.typescript.languageService,
languageServiceHost: semanticCtx.typescript.languageServiceHost,
getTextDocument: semanticCtx.getTextDocument,
};
}
}
provide: {
...(0, language_service_1.defineProvide)(exports.injectionKeys.typescript, () => ts),
...(0, language_service_1.defineProvide)(exports.injectionKeys.sourceFile, document => {
if ((0, shared_1.isTsDocument)(document)) {
const sourceFile = getSemanticServiceSourceFile(document.uri);
if (sourceFile) {
return sourceFile;
}
},
},
prepareSyntacticService(document);
return syntacticCtx.typescript.languageService.getProgram()?.getSourceFile(syntacticHostCtx.fileName);
}
}),
...(0, language_service_1.defineProvide)(exports.injectionKeys.languageService, document => {
const sourceFile = getSemanticServiceSourceFile(document.uri);
if (sourceFile) {
return semanticCtx.typescript.languageService;
}
prepareSyntacticService(document);
return syntacticCtx.typescript.languageService;
}),
...(0, language_service_1.defineProvide)(exports.injectionKeys.languageServiceHost, document => {
const sourceFile = getSemanticServiceSourceFile(document.uri);
if (sourceFile) {
return semanticCtx.typescript.languageServiceHost;
}
prepareSyntacticService(document);
return syntacticCtx.typescript.languageServiceHost;
}),
...(0, language_service_1.defineProvide)(exports.injectionKeys.textDocument, semanticCtx.getTextDocument),
},

@@ -399,3 +405,12 @@ ...triggerCharacters,

};
function getSemanticServiceSourceFile(uri) {
const sourceFile = semanticCtx.typescript.languageService.getProgram()?.getSourceFile(context.env.uriToFileName(uri));
if (sourceFile) {
return sourceFile;
}
}
function prepareSyntacticService(document) {
if (syntacticHostCtx.document === document && syntacticHostCtx.fileVersion === document.version) {
return;
}
syntacticHostCtx.fileName = context.env.uriToFileName(document.uri);

@@ -402,0 +417,0 @@ syntacticHostCtx.fileVersion = document.version;

import type * as ts from 'typescript/lib/tsserverlibrary';
export declare namespace SymbolKind {
function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 15 | 22 | 26;
function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 10 | 22 | 11 | 6 | 7 | 13 | 12 | 9 | 26 | 15;
}
{
"name": "volar-service-typescript",
"version": "0.0.1",
"version": "0.0.2",
"main": "out/index.js",

@@ -30,3 +30,3 @@ "license": "MIT",

},
"gitHead": "5bf5152f076f25cb1ddbc7aa6978a8d1c7009fd6"
"gitHead": "19482084693c7349f461dc75ec52ee6917739c51"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc