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

@volar/language-core

Package Overview
Dependencies
Maintainers
1
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volar/language-core - npm Package Compare versions

Comparing version 1.0.22 to 1.0.24

out/virtualFiles.d.ts

2

out/index.d.ts

@@ -1,4 +0,4 @@

export * from './documentRegistry';
export * from './virtualFiles';
export * from './languageContext';
export * from './sourceMaps';
export * from './types';

@@ -16,3 +16,3 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./documentRegistry"), exports);
__exportStar(require("./virtualFiles"), exports);
__exportStar(require("./languageContext"), exports);

@@ -19,0 +19,0 @@ __exportStar(require("./sourceMaps"), exports);

@@ -9,11 +9,12 @@ import type * as ts from 'typescript/lib/tsserverlibrary';

virtualFiles: {
all: Map<string, [string, ts.IScriptSnapshot, import("./types").VirtualFile, LanguageModule<import("./types").VirtualFile>]>;
update(fileName: string, snapshot: ts.IScriptSnapshot): import("./types").VirtualFile | undefined;
delete(fileName: string): void;
get(fileName: string): readonly [ts.IScriptSnapshot, import("./types").VirtualFile] | undefined;
hasSourceFile: (fileName: string) => boolean;
allSources(): import("./virtualFiles").Source[];
updateSource(fileName: string, snapshot: ts.IScriptSnapshot): import("./types").VirtualFile | undefined;
deleteSource(fileName: string): void;
getSource(fileName: string): import("./virtualFiles").Source | undefined;
hasSource: (fileName: string) => boolean;
getMirrorMap: (file: import("./types").VirtualFile) => import("./sourceMaps").MirrorMap | undefined;
getMaps: (virtualFile: import("./types").VirtualFile) => [string, import("@volar/source-map").SourceMap<import("./types").FileRangeCapabilities>][];
getSourceByVirtualFileName(fileName: string): readonly [string, ts.IScriptSnapshot, import("./types").VirtualFile] | undefined;
hasVirtualFile(fileName: string): boolean;
getVirtualFile(fileName: string): readonly [import("./types").VirtualFile, import("./virtualFiles").Source] | readonly [undefined, undefined];
};
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createLanguageContext = void 0;
const path_1 = require("path");
const documentRegistry_1 = require("./documentRegistry");
const virtualFiles_1 = require("./virtualFiles");
const types_1 = require("./types");

@@ -22,3 +22,3 @@ function createLanguageContext(host, languageModules) {

let tsProjectVersion = 0;
const virtualFiles = (0, documentRegistry_1.createVirtualFiles)(languageModules);
const virtualFiles = (0, virtualFiles_1.createVirtualFiles)(languageModules);
const ts = host.getTypeScriptModule();

@@ -33,14 +33,23 @@ const scriptSnapshots = new Map();

var _a;
// .vue.js -> .vue
// .vue.ts -> .vue
// .vue.d.ts -> [ignored]
const vueFileName = fileName.substring(0, fileName.lastIndexOf('.'));
if (!virtualFiles.hasSourceFile(vueFileName)) {
// create virtual files
const scriptSnapshot = host.getScriptSnapshot(vueFileName);
if (scriptSnapshot) {
virtualFiles.update(vueFileName, scriptSnapshot);
const ext = fileName.substring(fileName.lastIndexOf('.'));
if (ext === '.js'
|| ext === '.ts'
|| ext === '.jsx'
|| ext === '.tsx') {
/**
* If try to access a external .vue file that outside of the project,
* the file will not process by language service host,
* so virtual file will not be created.
*
* We try to create virtual file here.
*/
const sourceFileName = fileName.substring(0, fileName.lastIndexOf('.'));
if (!virtualFiles.hasSource(sourceFileName)) {
const scriptSnapshot = host.getScriptSnapshot(sourceFileName);
if (scriptSnapshot) {
virtualFiles.updateSource(sourceFileName, scriptSnapshot);
}
}
}
if (virtualFiles.getSourceByVirtualFileName(fileName)) {
if (virtualFiles.hasVirtualFile(fileName)) {
return true;

@@ -60,3 +69,3 @@ }

const result = (_b = (_a = host.readDirectory) === null || _a === void 0 ? void 0 : _a.call(host, _path, extensions, exclude, include, depth)) !== null && _b !== void 0 ? _b : [];
for (const [, [fileName]] of virtualFiles.all) {
for (const { fileName } of virtualFiles.allSources()) {
const vuePath2 = path_1.posix.join(_path, path_1.posix.basename(fileName));

@@ -77,3 +86,3 @@ if (path_1.posix.relative(_path.toLowerCase(), fileName.toLowerCase()).startsWith('..')) {

if (ts) {
if (virtualFiles.hasSourceFile(fileName))
if (virtualFiles.hasSource(fileName))
return ts.ScriptKind.Deferred;

@@ -119,3 +128,3 @@ switch (path_1.posix.extname(fileName)) {

// .vue
for (const [_, [fileName]] of virtualFiles.all) {
for (const { fileName } of virtualFiles.allSources()) {
remainRootFiles.delete(fileName);

@@ -125,3 +134,3 @@ const snapshot = host.getScriptSnapshot(fileName);

// delete
virtualFiles.delete(fileName);
virtualFiles.deleteSource(fileName);
shouldUpdateTsProject = true;

@@ -135,3 +144,3 @@ virtualFilesUpdatedNum++;

sourceFileVersions.set(fileName, newVersion);
virtualFiles.update(fileName, snapshot);
virtualFiles.updateSource(fileName, snapshot);
virtualFilesUpdatedNum++;

@@ -148,3 +157,3 @@ }

if (snapshot) {
const virtualFile = virtualFiles.update(fileName, snapshot);
const virtualFile = virtualFiles.updateSource(fileName, snapshot);
if (virtualFile) {

@@ -178,5 +187,5 @@ remainRootFiles.delete(fileName);

}
for (const [_, [_1, _2, virtualFile]] of virtualFiles.all) {
for (const { root: rootVirtualFile } of virtualFiles.allSources()) {
if (!shouldUpdateTsProject) {
(0, documentRegistry_1.forEachEmbeddedFile)(virtualFile, embedded => {
(0, virtualFiles_1.forEachEmbeddedFile)(rootVirtualFile, embedded => {
var _a;

@@ -197,4 +206,4 @@ if (embedded.kind === types_1.FileKind.TypeScriptHostFile) {

const tsFileNames = new Set();
for (const [_, [_1, _2, sourceFile]] of virtualFiles.all) {
(0, documentRegistry_1.forEachEmbeddedFile)(sourceFile, embedded => {
for (const { root: rootVirtualFile } of virtualFiles.allSources()) {
(0, virtualFiles_1.forEachEmbeddedFile)(rootVirtualFile, embedded => {
if (embedded.kind === types_1.FileKind.TypeScriptHostFile) {

@@ -206,3 +215,3 @@ tsFileNames.add(embedded.fileName); // virtual .ts

for (const fileName of host.getScriptFileNames()) {
if (!virtualFiles.hasSourceFile(fileName)) {
if (!virtualFiles.hasSource(fileName)) {
tsFileNames.add(fileName); // .ts

@@ -214,19 +223,19 @@ }

function getScriptVersion(fileName) {
let source = virtualFiles.getSourceByVirtualFileName(fileName);
if (source) {
let version = virtualFileVersions.get(source[2].fileName);
let [virtualFile, source] = virtualFiles.getVirtualFile(fileName);
if (virtualFile && source) {
let version = virtualFileVersions.get(virtualFile.fileName);
if (!version) {
version = {
value: 0,
virtualFileSnapshot: source[2].snapshot,
sourceFileSnapshot: source[1],
virtualFileSnapshot: virtualFile.snapshot,
sourceFileSnapshot: source.snapshot,
};
virtualFileVersions.set(source[2].fileName, version);
virtualFileVersions.set(virtualFile.fileName, version);
}
else if (version.virtualFileSnapshot !== source[2].snapshot
|| (host.isTsc && version.sourceFileSnapshot !== source[1]) // fix https://github.com/johnsoncodehk/volar/issues/1082
else if (version.virtualFileSnapshot !== virtualFile.snapshot
|| (host.isTsc && version.sourceFileSnapshot !== source.snapshot) // fix https://github.com/johnsoncodehk/volar/issues/1082
) {
version.value++;
version.virtualFileSnapshot = source[2].snapshot;
version.sourceFileSnapshot = source[1];
version.virtualFileSnapshot = virtualFile.snapshot;
version.sourceFileSnapshot = source.snapshot;
}

@@ -243,5 +252,5 @@ return version.value.toString();

}
const source = virtualFiles.getSourceByVirtualFileName(fileName);
if (source) {
const snapshot = source[2].snapshot;
const [virtualFile] = virtualFiles.getVirtualFile(fileName);
if (virtualFile) {
const snapshot = virtualFile.snapshot;
scriptSnapshots.set(fileName.toLowerCase(), [version, snapshot]);

@@ -248,0 +257,0 @@ return snapshot;

@@ -35,2 +35,11 @@ import { Mapping } from '@volar/source-map';

}
export declare namespace FileCapabilities {
const full: FileCapabilities;
}
export declare namespace FileRangeCapabilities {
const full: FileRangeCapabilities;
}
export declare namespace MirrorBehaviorCapabilities {
const full: MirrorBehaviorCapabilities;
}
export declare enum FileKind {

@@ -37,0 +46,0 @@ TextFile = 0,

Object.defineProperty(exports, "__esModule", { value: true });
exports.FileKind = void 0;
exports.FileKind = exports.MirrorBehaviorCapabilities = exports.FileRangeCapabilities = exports.FileCapabilities = void 0;
var FileCapabilities;
(function (FileCapabilities) {
FileCapabilities.full = {
diagnostic: true,
foldingRange: true,
documentFormatting: true,
documentSymbol: true,
codeAction: true,
inlayHint: true,
};
})(FileCapabilities = exports.FileCapabilities || (exports.FileCapabilities = {}));
var FileRangeCapabilities;
(function (FileRangeCapabilities) {
FileRangeCapabilities.full = {
hover: true,
references: true,
definition: true,
rename: true,
completion: true,
diagnostic: true,
semanticTokens: true,
};
})(FileRangeCapabilities = exports.FileRangeCapabilities || (exports.FileRangeCapabilities = {}));
var MirrorBehaviorCapabilities;
(function (MirrorBehaviorCapabilities) {
MirrorBehaviorCapabilities.full = {
references: true,
definition: true,
rename: true,
};
})(MirrorBehaviorCapabilities = exports.MirrorBehaviorCapabilities || (exports.MirrorBehaviorCapabilities = {}));
var FileKind;

@@ -4,0 +35,0 @@ (function (FileKind) {

{
"name": "@volar/language-core",
"version": "1.0.22",
"version": "1.0.24",
"main": "out/index.js",

@@ -16,6 +16,6 @@ "license": "MIT",

"dependencies": {
"@volar/source-map": "1.0.22",
"@volar/source-map": "1.0.24",
"muggle-string": "^0.1.0"
},
"gitHead": "eed05323d6fe1d8eda712f63bb765ba57bdd40ae"
"gitHead": "46da609e8914e29642f4707dec31507ad51b03fc"
}
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