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 2.2.5 to 2.3.0-alpha.0

6

index.d.ts

@@ -8,5 +8,5 @@ export * from '@volar/source-map';

import type * as ts from 'typescript';
import type { CodeInformation, Language, LanguagePlugin, VirtualCode } from './lib/types';
export declare function createLanguage(plugins: LanguagePlugin[], caseSensitive: boolean, sync: (id: string) => void): Language;
export declare function updateVirtualCodeMapOfMap(virtualCode: VirtualCode, mapOfMap: Map<string, [ts.IScriptSnapshot, SourceMap<CodeInformation>]>, getSourceSnapshot: (id: string | undefined) => [string, ts.IScriptSnapshot] | undefined): void;
import type { CodeInformation, Language, LanguagePlugin, SourceScript, VirtualCode } from './lib/types';
export declare function createLanguage<T>(plugins: LanguagePlugin<T>[], scriptRegistry: Map<T, SourceScript<T>>, sync: (id: T) => void): Language<T>;
export declare function updateVirtualCodeMapOfMap<T>(virtualCode: VirtualCode, mapOfMap: Map<T, [ts.IScriptSnapshot, SourceMap<CodeInformation>]>, getSourceSnapshot: (source: string | undefined) => [T, ts.IScriptSnapshot] | undefined): void;
export declare function forEachEmbeddedCode(virtualCode: VirtualCode): Generator<VirtualCode>;

@@ -25,5 +25,3 @@ "use strict";

const linkedCodeMap_1 = require("./lib/linkedCodeMap");
const utils_1 = require("./lib/utils");
function createLanguage(plugins, caseSensitive, sync) {
const sourceScripts = new utils_1.FileMap(caseSensitive);
function createLanguage(plugins, scriptRegistry, sync) {
const virtualCodeToSourceFileMap = new WeakMap();

@@ -37,3 +35,3 @@ const virtualCodeToMaps = new WeakMap();

sync(id);
return sourceScripts.get(id);
return scriptRegistry.get(id);
},

@@ -53,4 +51,4 @@ set(id, snapshot, languageId, _plugins = plugins) {

}
if (sourceScripts.has(id)) {
const sourceScript = sourceScripts.get(id);
if (scriptRegistry.has(id)) {
const sourceScript = scriptRegistry.get(id);
if (sourceScript.languageId !== languageId) {

@@ -89,3 +87,3 @@ // languageId changed

const sourceScript = { id, languageId, snapshot };
sourceScripts.set(id, sourceScript);
scriptRegistry.set(id, sourceScript);
for (const languagePlugin of _plugins) {

@@ -110,3 +108,3 @@ const virtualCode = languagePlugin.createVirtualCode?.(id, languageId, snapshot);

delete(id) {
const value = sourceScripts.get(id);
const value = scriptRegistry.get(id);
if (value) {

@@ -116,3 +114,3 @@ if (value.generated) {

}
sourceScripts.delete(id);
scriptRegistry.delete(id);
}

@@ -144,4 +142,5 @@ },

if (id) {
const sourceScript = sourceScripts.get(id);
return [id, sourceScript.snapshot];
throw 'not implemented';
// const sourceScript = sourceScripts.get(id)!;
// return [id, sourceScript.snapshot];
}

@@ -148,0 +147,0 @@ else {

@@ -1,14 +0,14 @@

import type { Mapping, SourceMap, Stack } from '@volar/source-map';
import type { Mapping, SourceMap } from '@volar/source-map';
import type * as ts from 'typescript';
import type { LinkedCodeMap } from './linkedCodeMap';
export interface Language {
plugins: LanguagePlugin[];
export interface Language<T> {
plugins: LanguagePlugin<T>[];
scripts: {
get(id: string): SourceScript | undefined;
set(id: string, snapshot: ts.IScriptSnapshot, languageId?: string, plugins?: LanguagePlugin[]): SourceScript | undefined;
delete(id: string): void;
get(id: T): SourceScript<T> | undefined;
set(id: T, snapshot: ts.IScriptSnapshot, languageId?: string, plugins?: LanguagePlugin<T>[]): SourceScript<T> | undefined;
delete(id: T): void;
};
maps: {
get(virtualCode: VirtualCode, scriptId?: string): SourceMap<CodeInformation> | undefined;
forEach(virtualCode: VirtualCode): Map<string, [ts.IScriptSnapshot, SourceMap<CodeInformation>]>;
get(virtualCode: VirtualCode, scriptId?: T): SourceMap<CodeInformation> | undefined;
forEach(virtualCode: VirtualCode): Map<T, [ts.IScriptSnapshot, SourceMap<CodeInformation>]>;
};

@@ -19,12 +19,15 @@ linkedCodeMaps: {

typescript?: {
projectHost: TypeScriptProjectHost;
configFileName: string | undefined;
sys: ts.System & {
version?: number;
sync?(): Promise<number>;
};
languageServiceHost: ts.LanguageServiceHost;
getExtraServiceScript(fileName: string): ExtraServiceScript | undefined;
getExtraServiceScript(fileName: string): TypeScriptExtraServiceScript | undefined;
asScriptId(fileName: string): T;
asFileName(scriptId: T): string;
};
}
export interface SourceScript {
/**
* uri or fileName
*/
id: string;
export interface SourceScript<T> {
id: T;
languageId: string;

@@ -34,3 +37,3 @@ snapshot: ts.IScriptSnapshot;

root: VirtualCode;
languagePlugin: LanguagePlugin;
languagePlugin: LanguagePlugin<T>;
embeddedCodes: Map<string, VirtualCode>;

@@ -46,3 +49,2 @@ };

embeddedCodes?: VirtualCode[];
codegenStacks?: Stack[];
linkedCodeMappings?: Mapping[];

@@ -75,3 +77,3 @@ }

}
export interface ServiceScript {
export interface TypeScriptServiceScript {
code: VirtualCode;

@@ -81,10 +83,10 @@ extension: '.ts' | '.js' | '.mts' | '.mjs' | '.cjs' | '.cts' | '.d.ts' | string;

}
export interface ExtraServiceScript extends ServiceScript {
export interface TypeScriptExtraServiceScript extends TypeScriptServiceScript {
fileName: string;
}
export interface LanguagePlugin<T extends VirtualCode = VirtualCode> {
getLanguageId(scriptId: string): string | undefined;
createVirtualCode?(scriptId: string, languageId: string, snapshot: ts.IScriptSnapshot): T | undefined;
updateVirtualCode?(scriptId: string, virtualCode: T, newSnapshot: ts.IScriptSnapshot): T | undefined;
disposeVirtualCode?(scriptId: string, virtualCode: T): void;
export interface LanguagePlugin<T, K extends VirtualCode = VirtualCode> {
getLanguageId(scriptId: T): string | undefined;
createVirtualCode?(scriptId: T, languageId: string, snapshot: ts.IScriptSnapshot): K | undefined;
updateVirtualCode?(scriptId: T, virtualCode: K, newSnapshot: ts.IScriptSnapshot): K | undefined;
disposeVirtualCode?(scriptId: T, virtualCode: K): void;
typescript?: {

@@ -98,7 +100,7 @@ /**

*/
getServiceScript(rootVirtualCode: T): ServiceScript | undefined;
getServiceScript(rootVirtualCode: K): TypeScriptServiceScript | undefined;
/**
* LSP only
*/
getExtraServiceScripts?(fileName: string, rootVirtualCode: T): ExtraServiceScript[];
getExtraServiceScripts?(fileName: string, rootVirtualCode: K): TypeScriptExtraServiceScript[];
/**

@@ -110,8 +112,1 @@ * LSP only

}
export interface TypeScriptProjectHost extends ts.System, Pick<ts.LanguageServiceHost, 'getLocalizedDiagnosticMessages' | 'getCompilationSettings' | 'getProjectReferences' | 'getCurrentDirectory' | 'getScriptFileNames' | 'getProjectVersion' | 'getScriptSnapshot'> {
configFileName: string | undefined;
getSystemVersion?(): number;
syncSystem?(): Promise<number>;
scriptIdToFileName(scriptId: string): string;
fileNameToScriptId(fileName: string): string;
}
{
"name": "@volar/language-core",
"version": "2.2.5",
"version": "2.3.0-alpha.0",
"license": "MIT",

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

"dependencies": {
"@volar/source-map": "2.2.5"
"@volar/source-map": "2.3.0-alpha.0"
},
"gitHead": "ee4aaa9da58c4c942d6cb74f9028d19b7ef4465d"
"gitHead": "f17c19f712651acde33cc2171a112e64db0b460e"
}
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