Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@volar/typescript

Package Overview
Dependencies
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volar/typescript - npm Package Compare versions

Comparing version 2.2.0-alpha.10 to 2.2.0-alpha.11

lib/common.d.ts

105

lib/node/decorateLanguageService.js

@@ -8,6 +8,8 @@ "use strict";

const transform_1 = require("./transform");
const windowsPathReg = /\\/g;
function decorateLanguageService(language, languageService) {
// ignored methods
const { getNavigationTree, getOutliningSpans, } = languageService;
languageService.getNavigationTree = fileName => {
languageService.getNavigationTree = filePath => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript] = (0, utils_1.getServiceScript)(language, fileName);

@@ -23,3 +25,4 @@ if (serviceScript) {

};
languageService.getOutliningSpans = fileName => {
languageService.getOutliningSpans = filePath => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript] = (0, utils_1.getServiceScript)(language, fileName);

@@ -35,3 +38,4 @@ if (serviceScript) {

const { findReferences, findRenameLocations, getCompletionEntryDetails, getCompletionsAtPosition, getDefinitionAndBoundSpan, getDefinitionAtPosition, getFileReferences, getFormattingEditsForDocument, getFormattingEditsForRange, getFormattingEditsAfterKeystroke, getImplementationAtPosition, getLinkedEditingRangeAtPosition, getQuickInfoAtPosition, getSignatureHelpItems, getReferencesAtPosition, getSemanticDiagnostics, getSyntacticDiagnostics, getSuggestionDiagnostics, getTypeDefinitionAtPosition, getEncodedSemanticClassifications, getDocumentHighlights, getApplicableRefactors, getEditsForFileRename, getEditsForRefactor, getRenameInfo, getCodeFixesAtPosition, prepareCallHierarchy, provideCallHierarchyIncomingCalls, provideCallHierarchyOutgoingCalls, provideInlayHints, organizeImports, } = languageService;
languageService.getFormattingEditsForDocument = (fileName, options) => {
languageService.getFormattingEditsForDocument = (filePath, options) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -51,3 +55,4 @@ if (serviceScript) {

};
languageService.getFormattingEditsForRange = (fileName, start, end, options) => {
languageService.getFormattingEditsForRange = (filePath, start, end, options) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -69,3 +74,4 @@ if (serviceScript) {

};
languageService.getFormattingEditsAfterKeystroke = (fileName, position, key, options) => {
languageService.getFormattingEditsAfterKeystroke = (filePath, position, key, options) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -92,3 +98,4 @@ if (serviceScript) {

};
languageService.getLinkedEditingRangeAtPosition = (fileName, position) => {
languageService.getLinkedEditingRangeAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -113,3 +120,4 @@ if (serviceScript) {

};
languageService.prepareCallHierarchy = (fileName, position) => {
languageService.prepareCallHierarchy = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -132,4 +140,5 @@ if (serviceScript) {

};
languageService.provideCallHierarchyIncomingCalls = (fileName, position) => {
languageService.provideCallHierarchyIncomingCalls = (filePath, position) => {
let calls = [];
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -157,4 +166,5 @@ if (serviceScript) {

};
languageService.provideCallHierarchyOutgoingCalls = (fileName, position) => {
languageService.provideCallHierarchyOutgoingCalls = (filePath, position) => {
let calls = [];
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -191,3 +201,4 @@ if (serviceScript) {

};
languageService.getQuickInfoAtPosition = (fileName, position) => {
languageService.getQuickInfoAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -213,3 +224,4 @@ if (serviceScript) {

};
languageService.getSignatureHelpItems = (fileName, position, options) => {
languageService.getSignatureHelpItems = (filePath, position, options) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -235,3 +247,4 @@ if (serviceScript) {

};
languageService.getDocumentHighlights = (fileName, position, filesToSearch) => {
languageService.getDocumentHighlights = (filePath, position, filesToSearch) => {
const fileName = filePath.replace(windowsPathReg, '/');
const unresolved = linkedCodeFeatureWorker(fileName, position, language_core_1.isHighlightEnabled, position => getDocumentHighlights(fileName, position, filesToSearch), function* (result) {

@@ -265,3 +278,4 @@ for (const ref of result) {

};
languageService.getApplicableRefactors = (fileName, positionOrRange, preferences, triggerReason, kind, includeInteractiveActions) => {
languageService.getApplicableRefactors = (filePath, positionOrRange, preferences, triggerReason, kind, includeInteractiveActions) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -285,4 +299,5 @@ if (serviceScript) {

};
languageService.getEditsForRefactor = (fileName, formatOptions, positionOrRange, refactorName, actionName, preferences) => {
languageService.getEditsForRefactor = (filePath, formatOptions, positionOrRange, refactorName, actionName, preferences) => {
let edits;
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -313,8 +328,9 @@ if (serviceScript) {

};
languageService.getRenameInfo = (fileName, position, options) => {
languageService.getRenameInfo = (filePath, position, options) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(sourceScript, map, position, language_core_1.isRenameEnabled);
if (generatePosition !== undefined) {
const info = getRenameInfo(fileName, generatePosition, options);
let failed;
for (const generateOffset of (0, transform_1.forEachGeneratedOffset)(sourceScript, map, position, language_core_1.isRenameEnabled)) {
const info = getRenameInfo(fileName, generateOffset, options);
if (info.canRename) {

@@ -328,5 +344,8 @@ const span = (0, transform_1.transformTextSpan)(sourceScript, map, info.triggerSpan, language_core_1.isRenameEnabled);

else {
return info;
failed = info;
}
}
if (failed) {
return failed;
}
return {

@@ -341,4 +360,5 @@ canRename: false,

};
languageService.getCodeFixesAtPosition = (fileName, start, end, errorCodes, formatOptions, preferences) => {
languageService.getCodeFixesAtPosition = (filePath, start, end, errorCodes, formatOptions, preferences) => {
let fixes = [];
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -361,3 +381,4 @@ if (serviceScript) {

};
languageService.getEncodedSemanticClassifications = (fileName, span, format) => {
languageService.getEncodedSemanticClassifications = (filePath, span, format) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -396,3 +417,4 @@ if (serviceScript) {

};
languageService.getSyntacticDiagnostics = fileName => {
languageService.getSyntacticDiagnostics = filePath => {
const fileName = filePath.replace(windowsPathReg, '/');
return getSyntacticDiagnostics(fileName)

@@ -402,3 +424,4 @@ .map(d => (0, transform_1.transformDiagnostic)(language, d, false))

};
languageService.getSemanticDiagnostics = fileName => {
languageService.getSemanticDiagnostics = filePath => {
const fileName = filePath.replace(windowsPathReg, '/');
return getSemanticDiagnostics(fileName)

@@ -408,3 +431,4 @@ .map(d => (0, transform_1.transformDiagnostic)(language, d, false))

};
languageService.getSuggestionDiagnostics = fileName => {
languageService.getSuggestionDiagnostics = filePath => {
const fileName = filePath.replace(windowsPathReg, '/');
return getSuggestionDiagnostics(fileName)

@@ -414,3 +438,4 @@ .map(d => (0, transform_1.transformDiagnostic)(language, d, false))

};
languageService.getDefinitionAndBoundSpan = (fileName, position) => {
languageService.getDefinitionAndBoundSpan = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const unresolved = linkedCodeFeatureWorker(fileName, position, language_core_1.isDefinitionEnabled, position => getDefinitionAndBoundSpan(fileName, position), function* (result) {

@@ -438,3 +463,4 @@ for (const ref of result.definitions ?? []) {

};
languageService.findReferences = (fileName, position) => {
languageService.findReferences = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const unresolved = linkedCodeFeatureWorker(fileName, position, language_core_1.isReferencesEnabled, position => findReferences(fileName, position), function* (result) {

@@ -460,3 +486,4 @@ for (const ref of result) {

};
languageService.getDefinitionAtPosition = (fileName, position) => {
languageService.getDefinitionAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const unresolved = linkedCodeFeatureWorker(fileName, position, language_core_1.isDefinitionEnabled, position => getDefinitionAtPosition(fileName, position), function* (result) {

@@ -473,3 +500,4 @@ for (const ref of result) {

};
languageService.getTypeDefinitionAtPosition = (fileName, position) => {
languageService.getTypeDefinitionAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const unresolved = linkedCodeFeatureWorker(fileName, position, language_core_1.isTypeDefinitionEnabled, position => getTypeDefinitionAtPosition(fileName, position), function* (result) {

@@ -486,3 +514,4 @@ for (const ref of result) {

};
languageService.getImplementationAtPosition = (fileName, position) => {
languageService.getImplementationAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const unresolved = linkedCodeFeatureWorker(fileName, position, language_core_1.isImplementationEnabled, position => getImplementationAtPosition(fileName, position), function* (result) {

@@ -499,3 +528,4 @@ for (const ref of result) {

};
languageService.findRenameLocations = (fileName, position, findInStrings, findInComments, preferences) => {
languageService.findRenameLocations = (filePath, position, findInStrings, findInComments, preferences) => {
const fileName = filePath.replace(windowsPathReg, '/');
const unresolved = linkedCodeFeatureWorker(fileName, position, language_core_1.isRenameEnabled, position => findRenameLocations(fileName, position, findInStrings, findInComments, preferences), function* (result) {

@@ -512,3 +542,4 @@ for (const ref of result) {

};
languageService.getReferencesAtPosition = (fileName, position) => {
languageService.getReferencesAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const unresolved = linkedCodeFeatureWorker(fileName, position, language_core_1.isReferencesEnabled, position => getReferencesAtPosition(fileName, position), function* (result) {

@@ -525,3 +556,4 @@ for (const ref of result) {

};
languageService.getCompletionsAtPosition = (fileName, position, options, formattingSettings) => {
languageService.getCompletionsAtPosition = (filePath, position, options, formattingSettings) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -574,4 +606,5 @@ if (serviceScript) {

};
languageService.getCompletionEntryDetails = (fileName, position, entryName, formatOptions, source, preferences, data) => {
languageService.getCompletionEntryDetails = (filePath, position, entryName, formatOptions, source, preferences, data) => {
let details;
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -594,3 +627,4 @@ if (serviceScript) {

};
languageService.provideInlayHints = (fileName, span, preferences) => {
languageService.provideInlayHints = (filePath, span, preferences) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);

@@ -631,3 +665,4 @@ if (serviceScript) {

};
languageService.getFileReferences = fileName => {
languageService.getFileReferences = filePath => {
const fileName = filePath.replace(windowsPathReg, '/');
const unresolved = getFileReferences(fileName);

@@ -634,0 +669,0 @@ const resolved = unresolved

import { LanguagePlugin } from '@volar/language-core';
import type * as ts from 'typescript';
export declare function proxyCreateProgram(ts: typeof import('typescript'), original: typeof ts['createProgram'], getLanguagePlugins: (ts: typeof import('typescript'), options: ts.CreateProgramOptions) => LanguagePlugin[], getLanguageId: (fileName: string) => string): typeof import("typescript").createProgram;
export declare function proxyCreateProgram(ts: typeof import('typescript'), original: typeof ts['createProgram'], getLanguagePlugins: (ts: typeof import('typescript'), options: ts.CreateProgramOptions) => LanguagePlugin[]): typeof import("typescript").createProgram;

@@ -7,2 +7,3 @@ "use strict";

const decorateProgram_1 = require("./decorateProgram");
const common_1 = require("../common");
const arrayEqual = (a, b) => {

@@ -32,3 +33,3 @@ if (a.length !== b.length) {

};
function proxyCreateProgram(ts, original, getLanguagePlugins, getLanguageId) {
function proxyCreateProgram(ts, original, getLanguagePlugins) {
const sourceFileSnapshots = new Map();

@@ -52,3 +53,6 @@ const parsedSourceFiles = new WeakMap();

languagePlugins = getLanguagePlugins(ts, options);
language = (0, language_core_1.createLanguage)(languagePlugins, ts.sys.useCaseSensitiveFileNames, fileName => {
language = (0, language_core_1.createLanguage)([
...languagePlugins,
common_1.fileLanguageIdProviderPlugin,
], ts.sys.useCaseSensitiveFileNames, fileName => {
if (!sourceFileSnapshots.has(fileName)) {

@@ -75,3 +79,3 @@ const sourceFileText = originalHost.readFile(fileName);

if (snapshot) {
language.scripts.set(fileName, getLanguageId(fileName), snapshot);
language.scripts.set(fileName, snapshot);
}

@@ -78,0 +82,0 @@ else {

@@ -16,1 +16,2 @@ import { Language, CodeInformation, SourceMap, SourceScript } from '@volar/language-core';

export declare function toGeneratedOffset(sourceScript: SourceScript, map: SourceMap, position: number, filter: (data: CodeInformation) => boolean): number | undefined;
export declare function forEachGeneratedOffset(sourceScript: SourceScript, map: SourceMap, position: number, filter: (data: CodeInformation) => boolean): Generator<number, void, unknown>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toGeneratedOffset = exports.toSourceOffset = exports.transformTextSpan = exports.transformTextChange = exports.transformSpan = exports.transformDocumentSpan = exports.transformFileTextChanges = exports.fillSourceFileText = exports.transformDiagnostic = exports.transformCallHierarchyItem = void 0;
exports.forEachGeneratedOffset = exports.toGeneratedOffset = exports.toSourceOffset = exports.transformTextSpan = exports.transformTextChange = exports.transformSpan = exports.transformDocumentSpan = exports.transformFileTextChanges = exports.fillSourceFileText = exports.transformDiagnostic = exports.transformCallHierarchyItem = void 0;
const language_core_1 = require("@volar/language-core");

@@ -175,2 +175,10 @@ const utils_1 = require("./utils");

exports.toGeneratedOffset = toGeneratedOffset;
function* forEachGeneratedOffset(sourceScript, map, position, filter) {
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
if (filter(mapping.data)) {
yield generateOffset + sourceScript.snapshot.getLength();
}
}
}
exports.forEachGeneratedOffset = forEachGeneratedOffset;
//# sourceMappingURL=transform.js.map

@@ -8,6 +8,10 @@ "use strict";

const resolveModuleName_1 = require("../resolveModuleName");
const common_1 = require("../common");
const scriptVersions = new Map();
const fsFileSnapshots = new Map();
function createTypeScriptLanguage(ts, languagePlugins, projectHost) {
const language = (0, language_core_1.createLanguage)(languagePlugins, projectHost.useCaseSensitiveFileNames, scriptId => {
const language = (0, language_core_1.createLanguage)([
...languagePlugins,
common_1.fileLanguageIdProviderPlugin,
], projectHost.useCaseSensitiveFileNames, scriptId => {
const fileName = projectHost.scriptIdToFileName(scriptId);

@@ -33,3 +37,3 @@ // opened files

if (snapshot) {
language.scripts.set(scriptId, projectHost.getLanguageId(scriptId), snapshot);
language.scripts.set(scriptId, snapshot);
}

@@ -36,0 +40,0 @@ else {

import type * as ts from 'typescript';
import { LanguagePlugin } from '@volar/language-core';
export declare function createAsyncLanguageServicePlugin(extensions: string[], scriptKind: ts.ScriptKind, loadLanguagePlugins: (ts: typeof import('typescript'), info: ts.server.PluginCreateInfo) => Promise<LanguagePlugin[]>, getLanguageId: (fileName: string) => string): ts.server.PluginModuleFactory;
export declare function createAsyncLanguageServicePlugin(extensions: string[], scriptKind: ts.ScriptKind, loadLanguagePlugins: (ts: typeof import('typescript'), info: ts.server.PluginCreateInfo) => Promise<LanguagePlugin[]>): ts.server.PluginModuleFactory;

@@ -8,6 +8,7 @@ "use strict";

const createLanguageServicePlugin_1 = require("./createLanguageServicePlugin");
const common_1 = require("../common");
const externalFiles = new WeakMap();
const decoratedLanguageServices = new WeakSet();
const decoratedLanguageServiceHosts = new WeakSet();
function createAsyncLanguageServicePlugin(extensions, scriptKind, loadLanguagePlugins, getLanguageId) {
function createAsyncLanguageServicePlugin(extensions, scriptKind, loadLanguagePlugins) {
return modules => {

@@ -56,6 +57,15 @@ const { typescript: ts } = modules;

loadLanguagePlugins(ts, info).then(languagePlugins => {
const language = (0, language_core_1.createLanguage)(languagePlugins, ts.sys.useCaseSensitiveFileNames, fileName => {
const syncedScriptVersions = new language_core_1.FileMap(ts.sys.useCaseSensitiveFileNames);
const language = (0, language_core_1.createLanguage)([
...languagePlugins,
common_1.fileLanguageIdProviderPlugin,
], ts.sys.useCaseSensitiveFileNames, fileName => {
const version = getScriptVersion(fileName);
if (syncedScriptVersions.get(fileName) === version) {
return;
}
syncedScriptVersions.set(fileName, version);
const snapshot = getScriptSnapshot(fileName);
if (snapshot) {
language.scripts.set(fileName, getLanguageId(fileName), snapshot);
language.scripts.set(fileName, snapshot);
}

@@ -62,0 +72,0 @@ else {

import type * as ts from 'typescript';
import { LanguagePlugin } from '@volar/language-core';
export declare function createLanguageServicePlugin(loadLanguagePlugins: (ts: typeof import('typescript'), info: ts.server.PluginCreateInfo) => LanguagePlugin[], getLanguageId: (fileName: string) => string): ts.server.PluginModuleFactory;
export declare function createLanguageServicePlugin(loadLanguagePlugins: (ts: typeof import('typescript'), info: ts.server.PluginCreateInfo) => LanguagePlugin[]): ts.server.PluginModuleFactory;
export declare function arrayItemsEqual(a: string[], b: string[]): boolean;

@@ -7,2 +7,3 @@ "use strict";

const language_core_1 = require("@volar/language-core");
const common_1 = require("../common");
const externalFiles = new WeakMap();

@@ -12,3 +13,3 @@ const projectExternalFileExtensions = new WeakMap();

const decoratedLanguageServiceHosts = new WeakSet();
function createLanguageServicePlugin(loadLanguagePlugins, getLanguageId) {
function createLanguageServicePlugin(loadLanguagePlugins) {
return modules => {

@@ -28,6 +29,16 @@ const { typescript: ts } = modules;

const getScriptSnapshot = info.languageServiceHost.getScriptSnapshot.bind(info.languageServiceHost);
const language = (0, language_core_1.createLanguage)(languagePlugins, ts.sys.useCaseSensitiveFileNames, fileName => {
const getScriptVersion = info.languageServiceHost.getScriptVersion.bind(info.languageServiceHost);
const syncedScriptVersions = new language_core_1.FileMap(ts.sys.useCaseSensitiveFileNames);
const language = (0, language_core_1.createLanguage)([
...languagePlugins,
common_1.fileLanguageIdProviderPlugin,
], ts.sys.useCaseSensitiveFileNames, fileName => {
const version = getScriptVersion(fileName);
if (syncedScriptVersions.get(fileName) === version) {
return;
}
syncedScriptVersions.set(fileName, version);
const snapshot = getScriptSnapshot(fileName);
if (snapshot) {
language.scripts.set(fileName, getLanguageId(fileName), snapshot);
language.scripts.set(fileName, snapshot);
}

@@ -34,0 +45,0 @@ else {

{
"name": "@volar/typescript",
"version": "2.2.0-alpha.10",
"version": "2.2.0-alpha.11",
"license": "MIT",

@@ -15,3 +15,3 @@ "files": [

"dependencies": {
"@volar/language-core": "2.2.0-alpha.10",
"@volar/language-core": "2.2.0-alpha.11",
"path-browserify": "^1.0.1"

@@ -22,5 +22,5 @@ },

"@types/path-browserify": "latest",
"@volar/language-service": "2.2.0-alpha.10"
"@volar/language-service": "2.2.0-alpha.11"
},
"gitHead": "aedd2230883c457f703be93ed150917a3efde75c"
"gitHead": "b3e82d02777af164097a7f268e602bc7f94ea1cd"
}
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