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.3.0-alpha.8 to 2.3.0-alpha.9

161

lib/node/decorateLanguageService.js

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

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -44,2 +44,3 @@ return [];

if (serviceScript) {
const map = language.maps.get(serviceScript.code, sourceScript);
if (!map.mappings.some(mapping => (0, language_core_1.isFormattingEnabled)(mapping.data))) {

@@ -50,3 +51,3 @@ return [];

return edits
.map(edit => (0, transform_1.transformTextChange)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.map(edit => (0, transform_1.transformTextChange)(sourceScript, language, serviceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.filter(utils_1.notEmpty);

@@ -60,3 +61,3 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -66,8 +67,8 @@ return [];

if (serviceScript) {
const generateStart = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, start, language_core_1.isFormattingEnabled);
const generateEnd = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, end, language_core_1.isFormattingEnabled);
const generateStart = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, start, language_core_1.isFormattingEnabled);
const generateEnd = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, end, language_core_1.isFormattingEnabled);
if (generateStart !== undefined && generateEnd !== undefined) {
const edits = getFormattingEditsForRange(sourceScript.id, generateStart, generateEnd, options);
return edits
.map(edit => (0, transform_1.transformTextChange)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.map(edit => (0, transform_1.transformTextChange)(sourceScript, language, serviceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.filter(utils_1.notEmpty);

@@ -83,3 +84,3 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -89,7 +90,7 @@ return [];

if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, position, language_core_1.isFormattingEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isFormattingEnabled);
if (generatePosition !== undefined) {
const edits = getFormattingEditsAfterKeystroke(sourceScript.id, generatePosition, key, options);
return edits
.map(edit => (0, transform_1.transformTextChange)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.map(edit => (0, transform_1.transformTextChange)(sourceScript, language, serviceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.filter(utils_1.notEmpty);

@@ -105,7 +106,7 @@ }

const edits = getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences);
return (0, transform_1.transformFileTextChanges)(transform_1.ToSourceMode.IncludeAssciated, language, edits, language_core_1.isRenameEnabled);
return (0, transform_1.transformFileTextChanges)(undefined, language, edits, language_core_1.isRenameEnabled);
};
languageService.getLinkedEditingRangeAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -115,3 +116,3 @@ return undefined;

if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, position, language_core_1.isLinkedEditingEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isLinkedEditingEnabled);
if (generatePosition !== undefined) {

@@ -122,3 +123,3 @@ const info = getLinkedEditingRangeAtPosition(sourceScript.id, generatePosition);

ranges: info.ranges
.map(span => (0, transform_1.transformTextSpan)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, span, language_core_1.isLinkedEditingEnabled)?.[1])
.map(span => (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, span, language_core_1.isLinkedEditingEnabled)?.[1])
.filter(utils_1.notEmpty),

@@ -136,3 +137,3 @@ wordPattern: info.wordPattern,

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -142,10 +143,10 @@ return undefined;

if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, position, language_core_1.isCallHierarchyEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isCallHierarchyEnabled);
if (generatePosition !== undefined) {
const item = prepareCallHierarchy(sourceScript.id, generatePosition);
if (Array.isArray(item)) {
return item.map(item => (0, transform_1.transformCallHierarchyItem)(transform_1.ToSourceMode.IncludeAssciated, language, item, language_core_1.isCallHierarchyEnabled));
return item.map(item => (0, transform_1.transformCallHierarchyItem)(undefined, language, item, language_core_1.isCallHierarchyEnabled));
}
else if (item) {
return (0, transform_1.transformCallHierarchyItem)(transform_1.ToSourceMode.IncludeAssciated, language, item, language_core_1.isCallHierarchyEnabled);
return (0, transform_1.transformCallHierarchyItem)(undefined, language, item, language_core_1.isCallHierarchyEnabled);
}

@@ -161,3 +162,3 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -167,3 +168,3 @@ return [];

if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, position, language_core_1.isCallHierarchyEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isCallHierarchyEnabled);
if (generatePosition !== undefined) {

@@ -178,5 +179,5 @@ calls = provideCallHierarchyIncomingCalls(sourceScript.id, generatePosition);

.map(call => {
const from = (0, transform_1.transformCallHierarchyItem)(transform_1.ToSourceMode.IncludeAssciated, language, call.from, language_core_1.isCallHierarchyEnabled);
const from = (0, transform_1.transformCallHierarchyItem)(undefined, language, call.from, language_core_1.isCallHierarchyEnabled);
const fromSpans = call.fromSpans
.map(span => (0, transform_1.transformSpan)(transform_1.ToSourceMode.IncludeAssciated, language, call.from.file, span, language_core_1.isCallHierarchyEnabled)?.textSpan)
.map(span => (0, transform_1.transformSpan)(undefined, language, call.from.file, span, language_core_1.isCallHierarchyEnabled)?.textSpan)
.filter(utils_1.notEmpty);

@@ -192,3 +193,3 @@ return {

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -198,3 +199,3 @@ return [];

if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, position, language_core_1.isCallHierarchyEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isCallHierarchyEnabled);
if (generatePosition !== undefined) {

@@ -209,6 +210,6 @@ calls = provideCallHierarchyOutgoingCalls(fileName, generatePosition);

.map(call => {
const to = (0, transform_1.transformCallHierarchyItem)(transform_1.ToSourceMode.IncludeAssciated, language, call.to, language_core_1.isCallHierarchyEnabled);
const to = (0, transform_1.transformCallHierarchyItem)(undefined, language, call.to, language_core_1.isCallHierarchyEnabled);
const fromSpans = call.fromSpans
.map(span => serviceScript
? (0, transform_1.transformTextSpan)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, span, language_core_1.isCallHierarchyEnabled)?.[1]
? (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, span, language_core_1.isCallHierarchyEnabled)?.[1]
: span)

@@ -224,7 +225,7 @@ .filter(utils_1.notEmpty);

const unresolved = organizeImports(args, formatOptions, preferences);
return (0, transform_1.transformFileTextChanges)(transform_1.ToSourceMode.IncludeAssciated, language, unresolved, language_core_1.isCodeActionsEnabled);
return (0, transform_1.transformFileTextChanges)(undefined, language, unresolved, language_core_1.isCodeActionsEnabled);
};
languageService.getQuickInfoAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -235,6 +236,6 @@ return undefined;

const infos = [];
for (const [generatePosition] of (0, transform_1.toGeneratedOffsets)(serviceScript, sourceScript, map, position, language_core_1.isHoverEnabled)) {
for (const [generatePosition] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, sourceScript, position, language_core_1.isHoverEnabled)) {
const info = getQuickInfoAtPosition(sourceScript.id, generatePosition);
if (info) {
const textSpan = (0, transform_1.transformTextSpan)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, info.textSpan, language_core_1.isHoverEnabled)?.[1];
const textSpan = (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, info.textSpan, language_core_1.isHoverEnabled)?.[1];
if (textSpan) {

@@ -293,3 +294,3 @@ infos.push({

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -299,7 +300,7 @@ return undefined;

if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, position, language_core_1.isSignatureHelpEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isSignatureHelpEnabled);
if (generatePosition !== undefined) {
const result = getSignatureHelpItems(sourceScript.id, generatePosition, options);
if (result) {
const applicableSpan = (0, transform_1.transformTextSpan)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, result.applicableSpan, language_core_1.isSignatureHelpEnabled)?.[1];
const applicableSpan = (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, result.applicableSpan, language_core_1.isSignatureHelpEnabled)?.[1];
if (applicableSpan) {

@@ -334,7 +335,7 @@ return {

.map(span => {
const { textSpan } = (0, transform_1.transformSpan)(transform_1.ToSourceMode.IncludeAssciated, language, span.fileName ?? highlights.fileName, span.textSpan, language_core_1.isHighlightEnabled) ?? {};
const { textSpan } = (0, transform_1.transformSpan)(undefined, language, span.fileName ?? highlights.fileName, span.textSpan, language_core_1.isHighlightEnabled) ?? {};
if (textSpan) {
return {
...span,
contextSpan: (0, transform_1.transformSpan)(transform_1.ToSourceMode.IncludeAssciated, language, span.fileName ?? highlights.fileName, span.contextSpan, language_core_1.isHighlightEnabled)?.textSpan,
contextSpan: (0, transform_1.transformSpan)(undefined, language, span.fileName ?? highlights.fileName, span.contextSpan, language_core_1.isHighlightEnabled)?.textSpan,
textSpan,

@@ -351,3 +352,3 @@ };

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -357,3 +358,3 @@ return [];

if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, typeof positionOrRange === 'number' ? positionOrRange : positionOrRange.pos, language_core_1.isCodeActionsEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, typeof positionOrRange === 'number' ? positionOrRange : positionOrRange.pos, language_core_1.isCodeActionsEnabled);
if (generatePosition !== undefined) {

@@ -377,3 +378,3 @@ const por = typeof positionOrRange === 'number'

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -383,3 +384,3 @@ return undefined;

if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, typeof positionOrRange === 'number'
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, typeof positionOrRange === 'number'
? positionOrRange

@@ -401,3 +402,3 @@ : positionOrRange.pos, language_core_1.isCodeActionsEnabled);

if (edits) {
edits.edits = (0, transform_1.transformFileTextChanges)(transform_1.ToSourceMode.IncludeAssciated, language, edits.edits, language_core_1.isCodeActionsEnabled);
edits.edits = (0, transform_1.transformFileTextChanges)(undefined, language, edits.edits, language_core_1.isCodeActionsEnabled);
return edits;

@@ -408,3 +409,3 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -418,6 +419,6 @@ return {

let failed;
for (const [generateOffset] of (0, transform_1.toGeneratedOffsets)(serviceScript, sourceScript, map, position, language_core_1.isRenameEnabled)) {
for (const [generateOffset] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, sourceScript, position, language_core_1.isRenameEnabled)) {
const info = getRenameInfo(sourceScript.id, generateOffset, options);
if (info.canRename) {
const span = (0, transform_1.transformTextSpan)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, info.triggerSpan, language_core_1.isRenameEnabled)?.[1];
const span = (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, info.triggerSpan, language_core_1.isRenameEnabled)?.[1];
if (span) {

@@ -447,3 +448,3 @@ info.triggerSpan = span;

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -453,4 +454,4 @@ return [];

if (serviceScript) {
const generateStart = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, start, language_core_1.isCodeActionsEnabled);
const generateEnd = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, end, language_core_1.isCodeActionsEnabled);
const generateStart = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, start, language_core_1.isCodeActionsEnabled);
const generateEnd = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, end, language_core_1.isCodeActionsEnabled);
if (generateStart !== undefined && generateEnd !== undefined) {

@@ -464,3 +465,3 @@ fixes = getCodeFixesAtPosition(sourceScript.id, generateStart, generateEnd, errorCodes, formatOptions, preferences);

fixes = fixes.map(fix => {
fix.changes = (0, transform_1.transformFileTextChanges)(transform_1.ToSourceMode.IncludeAssciated, language, fix.changes, language_core_1.isCodeActionsEnabled);
fix.changes = (0, transform_1.transformFileTextChanges)(undefined, language, fix.changes, language_core_1.isCodeActionsEnabled);
return fix;

@@ -472,3 +473,3 @@ });

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -483,2 +484,3 @@ return {

let end;
const map = language.maps.get(serviceScript.code, sourceScript);
for (const mapping of map.mappings) {

@@ -495,3 +497,3 @@ // TODO reuse the logic from language service

end ??= sourceScript.snapshot.getLength();
const mappingOffset = (0, transform_1.getMappingOffset)(serviceScript, sourceScript);
const mappingOffset = (0, transform_1.getMappingOffset)(language, serviceScript);
start += mappingOffset;

@@ -502,4 +504,4 @@ end += mappingOffset;

for (let i = 0; i < result.spans.length; i += 3) {
for (const sourceStart of (0, transform_1.toSourceOffsets)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, result.spans[i], language_core_1.isSemanticTokensEnabled)) {
for (const sourceEnd of (0, transform_1.toSourceOffsets)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, result.spans[i] + result.spans[i + 1], language_core_1.isSemanticTokensEnabled)) {
for (const sourceStart of (0, transform_1.toSourceOffsets)(sourceScript, language, serviceScript, result.spans[i], language_core_1.isSemanticTokensEnabled)) {
for (const sourceEnd of (0, transform_1.toSourceOffsets)(sourceScript, language, serviceScript, result.spans[i] + result.spans[i + 1], language_core_1.isSemanticTokensEnabled)) {
if (sourceStart[0] === sourceEnd[0] && sourceEnd[1] >= sourceStart[1]) {

@@ -529,3 +531,3 @@ spans.push(sourceStart[1], sourceEnd[1] - sourceStart[1], result.spans[i + 2]);

return getSyntacticDiagnostics(fileName)
.map(d => (0, transform_1.transformDiagnostic)(transform_1.ToSourceMode.SkipAssciated, language, d, languageService.getProgram(), false))
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, languageService.getProgram(), false))
.filter(utils_1.notEmpty);

@@ -540,3 +542,3 @@ };

return getSemanticDiagnostics(fileName)
.map(d => (0, transform_1.transformDiagnostic)(transform_1.ToSourceMode.SkipAssciated, language, d, languageService.getProgram(), false))
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, languageService.getProgram(), false))
.filter(utils_1.notEmpty);

@@ -551,3 +553,3 @@ };

return getSuggestionDiagnostics(fileName)
.map(d => (0, transform_1.transformDiagnostic)(transform_1.ToSourceMode.SkipAssciated, language, d, languageService.getProgram(), false))
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, languageService.getProgram(), false))
.filter(utils_1.notEmpty);

@@ -563,3 +565,3 @@ };

const textSpan = unresolved
.map(s => (0, transform_1.transformSpan)(transform_1.ToSourceMode.IncludeAssciated, language, fileName, s.textSpan, language_core_1.isDefinitionEnabled)?.textSpan)
.map(s => (0, transform_1.transformSpan)(undefined, language, fileName, s.textSpan, language_core_1.isDefinitionEnabled)?.textSpan)
.filter(utils_1.notEmpty)[0];

@@ -571,3 +573,3 @@ if (!textSpan) {

.map(s => s.definitions
?.map(s => (0, transform_1.transformDocumentSpan)(transform_1.ToSourceMode.IncludeAssciated, language, s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
?.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
.filter(utils_1.notEmpty))

@@ -593,7 +595,7 @@ .filter(utils_1.notEmpty)

.map(symbol => {
const definition = (0, transform_1.transformDocumentSpan)(transform_1.ToSourceMode.IncludeAssciated, language, symbol.definition, language_core_1.isDefinitionEnabled, true);
const definition = (0, transform_1.transformDocumentSpan)(undefined, language, symbol.definition, language_core_1.isDefinitionEnabled, true);
return {
definition,
references: symbol.references
.map(r => (0, transform_1.transformDocumentSpan)(transform_1.ToSourceMode.IncludeAssciated, language, r, language_core_1.isReferencesEnabled))
.map(r => (0, transform_1.transformDocumentSpan)(undefined, language, r, language_core_1.isReferencesEnabled))
.filter(utils_1.notEmpty),

@@ -613,3 +615,3 @@ };

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(transform_1.ToSourceMode.IncludeAssciated, language, s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
.filter(utils_1.notEmpty);

@@ -627,3 +629,3 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(transform_1.ToSourceMode.IncludeAssciated, language, s, language_core_1.isTypeDefinitionEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isTypeDefinitionEnabled))
.filter(utils_1.notEmpty);

@@ -641,3 +643,3 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(transform_1.ToSourceMode.IncludeAssciated, language, s, language_core_1.isImplementationEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isImplementationEnabled))
.filter(utils_1.notEmpty);

@@ -655,3 +657,3 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(transform_1.ToSourceMode.IncludeAssciated, language, s, language_core_1.isRenameEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isRenameEnabled))
.filter(utils_1.notEmpty);

@@ -669,3 +671,3 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(transform_1.ToSourceMode.IncludeAssciated, language, s, language_core_1.isReferencesEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isReferencesEnabled))
.filter(utils_1.notEmpty);

@@ -676,3 +678,3 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -683,3 +685,3 @@ return undefined;

const results = [];
for (const [generatedOffset, mapping] of (0, transform_1.toGeneratedOffsets)(serviceScript, sourceScript, map, position, language_core_1.isCompletionEnabled)) {
for (const [generatedOffset, mapping] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, sourceScript, position, language_core_1.isCompletionEnabled)) {
const result = getCompletionsAtPosition(sourceScript.id, generatedOffset, options, formattingSettings);

@@ -693,6 +695,6 @@ if (!result) {

for (const entry of result.entries) {
entry.replacementSpan = entry.replacementSpan && (0, transform_1.transformTextSpan)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, entry.replacementSpan, language_core_1.isCompletionEnabled)?.[1];
entry.replacementSpan = entry.replacementSpan && (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, entry.replacementSpan, language_core_1.isCompletionEnabled)?.[1];
}
result.optionalReplacementSpan = result.optionalReplacementSpan
&& (0, transform_1.transformTextSpan)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, result.optionalReplacementSpan, language_core_1.isCompletionEnabled)?.[1];
&& (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, result.optionalReplacementSpan, language_core_1.isCompletionEnabled)?.[1];
const isAdditional = typeof mapping.data.completion === 'object' && mapping.data.completion.isAdditional;

@@ -722,3 +724,3 @@ if (isAdditional) {

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -728,3 +730,3 @@ return undefined;

if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(serviceScript, sourceScript, map, position, language_core_1.isCompletionEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isCompletionEnabled);
if (generatePosition !== undefined) {

@@ -739,3 +741,3 @@ details = getCompletionEntryDetails(sourceScript.id, generatePosition, entryName, formatOptions, source, preferences, data);

for (const codeAction of details.codeActions) {
codeAction.changes = (0, transform_1.transformFileTextChanges)(transform_1.ToSourceMode.IncludeAssciated, language, codeAction.changes, language_core_1.isCompletionEnabled);
codeAction.changes = (0, transform_1.transformFileTextChanges)(undefined, language, codeAction.changes, language_core_1.isCompletionEnabled);
}

@@ -747,3 +749,3 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {

@@ -755,2 +757,3 @@ return [];

let end;
const map = language.maps.get(serviceScript.code, sourceScript);
for (const mapping of map.mappings) {

@@ -768,3 +771,3 @@ if ((0, language_core_1.isInlayHintsEnabled)(mapping.data) && mapping.sourceOffsets[0] >= span.start && mapping.sourceOffsets[0] <= span.start + span.length) {

}
const mappingOffset = (0, transform_1.getMappingOffset)(serviceScript, sourceScript);
const mappingOffset = (0, transform_1.getMappingOffset)(language, serviceScript);
start += mappingOffset;

@@ -775,3 +778,3 @@ end += mappingOffset;

for (const hint of result) {
const sourcePosition = (0, transform_1.toSourceOffset)(transform_1.ToSourceMode.SkipAssciated, language, serviceScript, sourceScript, hint.position, language_core_1.isInlayHintsEnabled);
const sourcePosition = (0, transform_1.toSourceOffset)(sourceScript, language, serviceScript, hint.position, language_core_1.isInlayHintsEnabled);
if (sourcePosition !== undefined) {

@@ -794,3 +797,3 @@ hints.push({

const resolved = unresolved
.map(s => (0, transform_1.transformDocumentSpan)(transform_1.ToSourceMode.IncludeAssciated, language, s, language_core_1.isReferencesEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isReferencesEnabled))
.filter(utils_1.notEmpty);

@@ -802,8 +805,6 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

const processedFilePositions = new Set();
const [serviceScript, sourceScript, map] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (serviceScript) {
for (const [generatedOffset, mapping] of map.getGeneratedOffsets(position)) {
if (filter(mapping.data)) {
process(sourceScript.id, generatedOffset + (0, transform_1.getMappingOffset)(serviceScript, sourceScript));
}
for (const [generatedOffset] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, sourceScript, position, filter)) {
process(sourceScript.id, generatedOffset);
}

@@ -827,3 +828,3 @@ }

processedFilePositions.add(ref[0] + ':' + ref[1]);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, ref[0]);
const [serviceScript] = (0, utils_1.getServiceScript)(language, ref[0]);
if (!serviceScript) {

@@ -836,3 +837,3 @@ continue;

}
const mappingOffset = (0, transform_1.getMappingOffset)(serviceScript, sourceScript);
const mappingOffset = (0, transform_1.getMappingOffset)(language, serviceScript);
for (const linkedCodeOffset of linkedCodeMap.getLinkedOffsets(ref[1] - mappingOffset)) {

@@ -839,0 +840,0 @@ process(ref[0], linkedCodeOffset + mappingOffset);

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

diagnostics: result.diagnostics
.map(d => (0, transform_1.transformDiagnostic)(transform_1.ToSourceMode.IncludeAssciated, language, d, program, true))
.map(d => (0, transform_1.transformDiagnostic)(undefined, language, d, program, true))
.filter(utils_1.notEmpty),

@@ -33,3 +33,3 @@ };

return getSyntacticDiagnostics(actualSourceFile, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(transform_1.ToSourceMode.SkipAssciated, language, d, program, true))
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, program, true))
.filter(utils_1.notEmpty);

@@ -44,3 +44,3 @@ };

return getSemanticDiagnostics(actualSourceFile, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(transform_1.ToSourceMode.SkipAssciated, language, d, program, true))
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, program, true))
.filter(utils_1.notEmpty);

@@ -50,3 +50,3 @@ };

return getGlobalDiagnostics(cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(transform_1.ToSourceMode.IncludeAssciated, language, d, program, true))
.map(d => (0, transform_1.transformDiagnostic)(undefined, language, d, program, true))
.filter(utils_1.notEmpty);

@@ -62,3 +62,3 @@ };

return getBindAndCheckDiagnostics(actualSourceFile, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(transform_1.ToSourceMode.SkipAssciated, language, d, program, true))
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, program, true))
.filter(utils_1.notEmpty);

@@ -65,0 +65,0 @@ };

@@ -1,23 +0,19 @@

import type { CodeInformation, SourceMap, SourceScript, TypeScriptServiceScript } from '@volar/language-core';
import type { CodeInformation, SourceScript, TypeScriptServiceScript } from '@volar/language-core';
import { Language } from '@volar/language-core';
import type * as ts from 'typescript';
export declare enum ToSourceMode {
IncludeAssciated = 0,
SkipAssciated = 1
}
export declare function transformCallHierarchyItem(mode: ToSourceMode, language: Language<string>, item: ts.CallHierarchyItem, filter: (data: CodeInformation) => boolean): ts.CallHierarchyItem;
export declare function transformDiagnostic<T extends ts.Diagnostic>(mode: ToSourceMode, language: Language<string>, diagnostic: T, program: ts.Program | undefined, isTsc: boolean): T | undefined;
export declare function transformCallHierarchyItem(targetScript: SourceScript<string> | undefined, language: Language<string>, item: ts.CallHierarchyItem, filter: (data: CodeInformation) => boolean): ts.CallHierarchyItem;
export declare function transformDiagnostic<T extends ts.Diagnostic>(targetScript: SourceScript<string> | undefined, language: Language<string>, diagnostic: T, program: ts.Program | undefined, isTsc: boolean): T | undefined;
export declare function fillSourceFileText(language: Language<string>, sourceFile: ts.SourceFile): void;
export declare function transformFileTextChanges(mode: ToSourceMode, language: Language<string>, changes: readonly ts.FileTextChanges[], filter: (data: CodeInformation) => boolean): ts.FileTextChanges[];
export declare function transformDocumentSpan<T extends ts.DocumentSpan>(mode: ToSourceMode, language: Language<string>, documentSpan: T, filter: (data: CodeInformation) => boolean, shouldFallback?: boolean): T | undefined;
export declare function transformSpan(mode: ToSourceMode, language: Language<string>, fileName: string | undefined, textSpan: ts.TextSpan | undefined, filter: (data: CodeInformation) => boolean): {
export declare function transformFileTextChanges(targetScript: SourceScript<string> | undefined, language: Language<string>, changes: readonly ts.FileTextChanges[], filter: (data: CodeInformation) => boolean): ts.FileTextChanges[];
export declare function transformDocumentSpan<T extends ts.DocumentSpan>(targetScript: SourceScript<string> | undefined, language: Language<string>, documentSpan: T, filter: (data: CodeInformation) => boolean, shouldFallback?: boolean): T | undefined;
export declare function transformSpan(targetScript: SourceScript<string> | undefined, language: Language<string>, fileName: string | undefined, textSpan: ts.TextSpan | undefined, filter: (data: CodeInformation) => boolean): {
fileName: string;
textSpan: ts.TextSpan;
} | undefined;
export declare function transformTextChange(mode: ToSourceMode, language: Language<string>, serviceScript: TypeScriptServiceScript, sourceScript: SourceScript<string>, textChange: ts.TextChange, filter: (data: CodeInformation) => boolean): [string, ts.TextChange] | undefined;
export declare function transformTextSpan(mode: ToSourceMode, language: Language<string>, serviceScript: TypeScriptServiceScript, sourceScript: SourceScript<string>, textSpan: ts.TextSpan, filter: (data: CodeInformation) => boolean): [string, ts.TextSpan] | undefined;
export declare function toSourceOffset(mode: ToSourceMode, language: Language<string>, serviceScript: TypeScriptServiceScript, sourceScript: SourceScript<string>, position: number, filter: (data: CodeInformation) => boolean): [fileName: string, offset: number] | undefined;
export declare function toSourceOffsets(mode: ToSourceMode, language: Language<string>, serviceScript: TypeScriptServiceScript, sourceScript: SourceScript<string>, position: number, filter: (data: CodeInformation) => boolean): Generator<[fileName: string, offset: number]>;
export declare function toGeneratedOffset(serviceScript: TypeScriptServiceScript, sourceScript: SourceScript<string>, map: SourceMap<CodeInformation>, position: number, filter: (data: CodeInformation) => boolean): number | undefined;
export declare function toGeneratedOffsets(serviceScript: TypeScriptServiceScript, sourceScript: SourceScript<string>, map: SourceMap<CodeInformation>, position: number, filter: (data: CodeInformation) => boolean): Generator<readonly [number, import("@volar/language-core").Mapping<CodeInformation>], void, unknown>;
export declare function getMappingOffset(serviceScript: TypeScriptServiceScript, sourceScript: SourceScript<string>): number;
export declare function transformTextChange(targetScript: SourceScript<string> | undefined, language: Language<string>, serviceScript: TypeScriptServiceScript, textChange: ts.TextChange, filter: (data: CodeInformation) => boolean): [string, ts.TextChange] | undefined;
export declare function transformTextSpan(targetScript: SourceScript<string> | undefined, language: Language<string>, serviceScript: TypeScriptServiceScript, textSpan: ts.TextSpan, filter: (data: CodeInformation) => boolean): [string, ts.TextSpan] | undefined;
export declare function toSourceOffset(targetScript: SourceScript<string> | undefined, language: Language<string>, serviceScript: TypeScriptServiceScript, position: number, filter: (data: CodeInformation) => boolean): [fileName: string, offset: number] | undefined;
export declare function toSourceOffsets(targetScript: SourceScript<string> | undefined, language: Language<string>, serviceScript: TypeScriptServiceScript, position: number, filter: (data: CodeInformation) => boolean): Generator<[fileName: string, offset: number]>;
export declare function toGeneratedOffset(language: Language, serviceScript: TypeScriptServiceScript, sourceScript: SourceScript<string>, position: number, filter: (data: CodeInformation) => boolean): number | undefined;
export declare function toGeneratedOffsets(language: Language, serviceScript: TypeScriptServiceScript, sourceScript: SourceScript<string>, position: number, filter: (data: CodeInformation) => boolean): Generator<readonly [number, import("@volar/language-core").Mapping<CodeInformation>], void, unknown>;
export declare function getMappingOffset(language: Language, serviceScript: TypeScriptServiceScript): number;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMappingOffset = exports.toGeneratedOffsets = exports.toGeneratedOffset = exports.toSourceOffsets = exports.toSourceOffset = exports.transformTextSpan = exports.transformTextChange = exports.transformSpan = exports.transformDocumentSpan = exports.transformFileTextChanges = exports.fillSourceFileText = exports.transformDiagnostic = exports.transformCallHierarchyItem = exports.ToSourceMode = void 0;
exports.getMappingOffset = exports.toGeneratedOffsets = exports.toGeneratedOffset = exports.toSourceOffsets = 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");
const utils_1 = require("./utils");
var ToSourceMode;
(function (ToSourceMode) {
ToSourceMode[ToSourceMode["IncludeAssciated"] = 0] = "IncludeAssciated";
ToSourceMode[ToSourceMode["SkipAssciated"] = 1] = "SkipAssciated";
})(ToSourceMode || (exports.ToSourceMode = ToSourceMode = {}));
const transformedDiagnostics = new WeakMap();
const transformedSourceFile = new WeakSet();
function transformCallHierarchyItem(mode, language, item, filter) {
const span = transformSpan(mode, language, item.file, item.span, filter);
const selectionSpan = transformSpan(mode, language, item.file, item.selectionSpan, filter);
function transformCallHierarchyItem(targetScript, language, item, filter) {
const span = transformSpan(targetScript, language, item.file, item.span, filter);
const selectionSpan = transformSpan(targetScript, language, item.file, item.selectionSpan, filter);
return {

@@ -24,3 +19,3 @@ ...item,

exports.transformCallHierarchyItem = transformCallHierarchyItem;
function transformDiagnostic(mode, language, diagnostic, program, isTsc) {
function transformDiagnostic(targetScript, language, diagnostic, program, isTsc) {
if (!transformedDiagnostics.has(diagnostic)) {

@@ -31,3 +26,3 @@ transformedDiagnostics.set(diagnostic, undefined);

diagnostic.relatedInformation = relatedInformation
.map(d => transformDiagnostic(mode, language, d, program, isTsc))
.map(d => transformDiagnostic(targetScript, language, d, program, isTsc))
.filter(utils_1.notEmpty);

@@ -40,3 +35,3 @@ }

if (serviceScript) {
const [sourceSpanFileName, sourceSpan] = transformTextSpan(mode, language, serviceScript, sourceScript, {
const [sourceSpanFileName, sourceSpan] = transformTextSpan(sourceScript, language, serviceScript, {
start: diagnostic.start,

@@ -86,3 +81,3 @@ length: diagnostic.length

exports.fillSourceFileText = fillSourceFileText;
function transformFileTextChanges(mode, language, changes, filter) {
function transformFileTextChanges(targetScript, language, changes, filter) {
const changesPerFile = {};

@@ -94,3 +89,3 @@ const newFiles = new Set();

fileChanges.textChanges.forEach(c => {
const { fileName, textSpan } = transformSpan(mode, language, fileChanges.fileName, c.span, filter) ?? {};
const { fileName, textSpan } = transformSpan(targetScript, language, fileChanges.fileName, c.span, filter) ?? {};
if (fileName && textSpan) {

@@ -122,4 +117,4 @@ (changesPerFile[fileName] ?? (changesPerFile[fileName] = [])).push({ ...c, span: textSpan });

exports.transformFileTextChanges = transformFileTextChanges;
function transformDocumentSpan(mode, language, documentSpan, filter, shouldFallback) {
let textSpan = transformSpan(mode, language, documentSpan.fileName, documentSpan.textSpan, filter);
function transformDocumentSpan(targetScript, language, documentSpan, filter, shouldFallback) {
let textSpan = transformSpan(targetScript, language, documentSpan.fileName, documentSpan.textSpan, filter);
if (!textSpan && shouldFallback) {

@@ -134,5 +129,5 @@ textSpan = {

}
const contextSpan = transformSpan(mode, language, documentSpan.fileName, documentSpan.contextSpan, filter);
const originalTextSpan = transformSpan(mode, language, documentSpan.originalFileName, documentSpan.originalTextSpan, filter);
const originalContextSpan = transformSpan(mode, language, documentSpan.originalFileName, documentSpan.originalContextSpan, filter);
const contextSpan = transformSpan(targetScript, language, documentSpan.fileName, documentSpan.contextSpan, filter);
const originalTextSpan = transformSpan(targetScript, language, documentSpan.originalFileName, documentSpan.originalTextSpan, filter);
const originalContextSpan = transformSpan(targetScript, language, documentSpan.originalFileName, documentSpan.originalContextSpan, filter);
return {

@@ -149,3 +144,3 @@ ...documentSpan,

exports.transformDocumentSpan = transformDocumentSpan;
function transformSpan(mode, language, fileName, textSpan, filter) {
function transformSpan(targetScript, language, fileName, textSpan, filter) {
if (!fileName || !textSpan) {

@@ -159,3 +154,3 @@ return;

else if (serviceScript) {
const [sourceSpanFileName, sourceSpan] = transformTextSpan(mode, language, serviceScript, sourceScript, textSpan, filter) ?? [];
const [sourceSpanFileName, sourceSpan] = transformTextSpan(targetScript, language, serviceScript, textSpan, filter) ?? [];
if (sourceSpan && sourceSpanFileName) {

@@ -176,4 +171,4 @@ return {

exports.transformSpan = transformSpan;
function transformTextChange(mode, language, serviceScript, sourceScript, textChange, filter) {
const [sourceSpanFileName, sourceSpan] = transformTextSpan(mode, language, serviceScript, sourceScript, textChange.span, filter) ?? [];
function transformTextChange(targetScript, language, serviceScript, textChange, filter) {
const [sourceSpanFileName, sourceSpan] = transformTextSpan(targetScript, language, serviceScript, textChange.span, filter) ?? [];
if (sourceSpan && sourceSpanFileName) {

@@ -188,7 +183,7 @@ return [sourceSpanFileName, {

exports.transformTextChange = transformTextChange;
function transformTextSpan(mode, language, serviceScript, sourceScript, textSpan, filter) {
function transformTextSpan(targetScript, language, serviceScript, textSpan, filter) {
const start = textSpan.start;
const end = textSpan.start + textSpan.length;
for (const sourceStart of toSourceOffsets(mode, language, serviceScript, sourceScript, start, filter)) {
for (const sourceEnd of toSourceOffsets(mode, language, serviceScript, sourceScript, end, filter)) {
for (const sourceStart of toSourceOffsets(targetScript, language, serviceScript, start, filter)) {
for (const sourceEnd of toSourceOffsets(targetScript, language, serviceScript, end, filter)) {
if (sourceStart[0] === sourceEnd[0]

@@ -205,4 +200,4 @@ && sourceEnd[1] >= sourceStart[1]) {

exports.transformTextSpan = transformTextSpan;
function toSourceOffset(mode, language, serviceScript, sourceScript, position, filter) {
for (const source of toSourceOffsets(mode, language, serviceScript, sourceScript, position, filter)) {
function toSourceOffset(targetScript, language, serviceScript, position, filter) {
for (const source of toSourceOffsets(targetScript, language, serviceScript, position, filter)) {
return source;

@@ -212,8 +207,8 @@ }

exports.toSourceOffset = toSourceOffset;
function* toSourceOffsets(mode, language, serviceScript, sourceScript, position, filter) {
if (mode === ToSourceMode.SkipAssciated) {
const map = language.maps.get(serviceScript.code);
for (const [sourceOffset, mapping] of map.getSourceOffsets(position - getMappingOffset(serviceScript, sourceScript))) {
function* toSourceOffsets(targetScript, language, serviceScript, position, filter) {
if (targetScript) {
const map = language.maps.get(serviceScript.code, targetScript);
for (const [sourceOffset, mapping] of map.getSourceOffsets(position - getMappingOffset(language, serviceScript))) {
if (filter(mapping.data)) {
yield [sourceScript.id, sourceOffset];
yield [targetScript.id, sourceOffset];
}

@@ -224,3 +219,3 @@ }

for (const [fileName, _snapshot, map] of language.maps.forEach(serviceScript.code)) {
for (const [sourceOffset, mapping] of map.getSourceOffsets(position - getMappingOffset(serviceScript, sourceScript))) {
for (const [sourceOffset, mapping] of map.getSourceOffsets(position - getMappingOffset(language, serviceScript))) {
if (filter(mapping.data)) {

@@ -234,4 +229,4 @@ yield [fileName, sourceOffset];

exports.toSourceOffsets = toSourceOffsets;
function toGeneratedOffset(serviceScript, sourceScript, map, position, filter) {
for (const [generateOffset] of toGeneratedOffsets(serviceScript, sourceScript, map, position, filter)) {
function toGeneratedOffset(language, serviceScript, sourceScript, position, filter) {
for (const [generateOffset] of toGeneratedOffsets(language, serviceScript, sourceScript, position, filter)) {
return generateOffset;

@@ -241,6 +236,7 @@ }

exports.toGeneratedOffset = toGeneratedOffset;
function* toGeneratedOffsets(serviceScript, sourceScript, map, position, filter) {
function* toGeneratedOffsets(language, serviceScript, sourceScript, position, filter) {
const map = language.maps.get(serviceScript.code, sourceScript);
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
if (filter(mapping.data)) {
yield [generateOffset + getMappingOffset(serviceScript, sourceScript), mapping];
yield [generateOffset + getMappingOffset(language, serviceScript), mapping];
}

@@ -250,8 +246,10 @@ }

exports.toGeneratedOffsets = toGeneratedOffsets;
function getMappingOffset(serviceScript, sourceScript) {
return !serviceScript.preventLeadingOffset
? sourceScript.snapshot.getLength()
: 0;
function getMappingOffset(language, serviceScript) {
if (serviceScript.preventLeadingOffset) {
return 0;
}
const sourceScript = language.scripts.fromVirtualCode(serviceScript.code);
return sourceScript.snapshot.getLength();
}
exports.getMappingOffset = getMappingOffset;
//# sourceMappingURL=transform.js.map

@@ -1,3 +0,3 @@

import type { CodeInformation, Language, SourceMap, SourceScript, TypeScriptServiceScript } from '@volar/language-core';
import type { Language, SourceScript, TypeScriptServiceScript } from '@volar/language-core';
export declare function notEmpty<T>(value: T | null | undefined): value is T;
export declare function getServiceScript(language: Language<string>, fileName: string): [TypeScriptServiceScript, SourceScript<string>, SourceMap<CodeInformation>] | [undefined, SourceScript<string>, undefined] | [undefined, undefined, undefined];
export declare function getServiceScript(language: Language<string>, fileName: string): [TypeScriptServiceScript, SourceScript<string>] | [undefined, SourceScript<string>] | [undefined, undefined];

@@ -9,16 +9,10 @@ "use strict";

function getServiceScript(language, fileName) {
let sourceScript = language.scripts.get(fileName);
if (sourceScript?.targetIds && sourceScript?.targetIds.size > 0) {
const sourceId = sourceScript.id;
const sourceScript = language.scripts.get(fileName);
if (sourceScript?.targetIds.size) {
for (const targetId of sourceScript.targetIds) {
sourceScript = language.scripts.get(targetId);
if (sourceScript?.generated) {
const serviceScript = sourceScript.generated.languagePlugin.typescript?.getServiceScript(sourceScript.generated.root);
const targetScript = language.scripts.get(targetId);
if (targetScript?.generated) {
const serviceScript = targetScript.generated.languagePlugin.typescript?.getServiceScript(targetScript.generated.root);
if (serviceScript) {
for (const [id, _snapshot, map] of language.maps.forEach(serviceScript.code)) {
if (id === sourceId) {
return [serviceScript, sourceScript, map];
}
}
break;
return [serviceScript, targetScript];
}

@@ -29,3 +23,3 @@ }

if (sourceScript?.associatedOnly) {
return [undefined, sourceScript, undefined];
return [undefined, sourceScript];
}

@@ -35,11 +29,8 @@ if (sourceScript?.generated) {

if (serviceScript) {
const map = language.maps.get(serviceScript.code);
if (map) {
return [serviceScript, sourceScript, map];
}
return [serviceScript, sourceScript];
}
}
return [undefined, undefined, undefined];
return [undefined, undefined];
}
exports.getServiceScript = getServiceScript;
//# sourceMappingURL=utils.js.map
{
"name": "@volar/typescript",
"version": "2.3.0-alpha.8",
"version": "2.3.0-alpha.9",
"license": "MIT",

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

"dependencies": {
"@volar/language-core": "2.3.0-alpha.8",
"@volar/language-core": "2.3.0-alpha.9",
"path-browserify": "^1.0.1",

@@ -23,5 +23,5 @@ "vscode-uri": "^3.0.8"

"@types/path-browserify": "latest",
"@volar/language-service": "2.3.0-alpha.8"
"@volar/language-service": "2.3.0-alpha.9"
},
"gitHead": "377a0083ac697a476509805a6777a2339391dcaf"
"gitHead": "3f741930343896dfc464a893ebe5f3619bb1a1aa"
}
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