This commit is contained in:
2024-02-07 01:33:07 -05:00
commit c1af19d441
4088 changed files with 1260170 additions and 0 deletions

View File

@ -0,0 +1,4 @@
import { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;
//# sourceMappingURL=file-html.d.ts.map

View File

@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const sfcBlockReg = /\<(script|style)\b([\s\S]*?)\>([\s\S]*?)\<\/\1\>/g;
const langReg = /\blang\s*=\s*(['\"]?)(\S*)\b\1/;
const plugin = () => {
return {
version: 1,
parseSFC(fileName, content) {
if (fileName.endsWith('.html')) {
let sfc = {
descriptor: {
filename: fileName,
source: content,
template: null,
script: null,
scriptSetup: null,
styles: [],
customBlocks: [],
cssVars: [],
shouldForceReload: () => false,
slotted: false,
},
errors: [],
};
let templateContent = content;
for (const match of content.matchAll(sfcBlockReg)) {
const matchText = match[0];
const tag = match[1];
const attrs = match[2];
const lang = attrs.match(langReg)?.[2];
const content = match[3];
const contentStart = match.index + matchText.indexOf(content);
if (tag === 'style') {
sfc.descriptor.styles.push({
attrs: {},
content,
loc: {
start: { column: -1, line: -1, offset: contentStart },
end: { column: -1, line: -1, offset: contentStart + content.length },
source: content,
},
type: 'style',
lang,
});
}
// ignore `<script src="...">`
else if (tag === 'script' && attrs.indexOf('src=') === -1) {
let type = attrs.indexOf('type=') >= 0 ? 'scriptSetup' : 'script';
sfc.descriptor[type] = {
attrs: {},
content,
loc: {
start: { column: -1, line: -1, offset: contentStart },
end: { column: -1, line: -1, offset: contentStart + content.length },
source: content,
},
type: 'script',
lang,
};
}
templateContent = templateContent.substring(0, match.index) + ' '.repeat(matchText.length) + templateContent.substring(match.index + matchText.length);
}
sfc.descriptor.template = {
attrs: {},
content: templateContent,
loc: {
start: { column: -1, line: -1, offset: 0 },
end: { column: -1, line: -1, offset: templateContent.length },
source: templateContent,
},
type: 'template',
ast: {},
};
return sfc;
}
;
}
};
};
exports.default = plugin;
//# sourceMappingURL=file-html.js.map

View File

@ -0,0 +1,4 @@
import { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;
//# sourceMappingURL=file-md.d.ts.map

71
node_modules/@vue/language-core/out/plugins/file-md.js generated vendored Normal file
View File

@ -0,0 +1,71 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const source_map_1 = require("@volar/source-map");
const parseSfc_1 = require("../utils/parseSfc");
const codeblockReg = /```[\s\S]+?```/g;
const inlineCodeblockReg = /`[^\n`]+?`/g;
const scriptSetupReg = /\\\<[\s\S]+?\>\n?/g;
const sfcBlockReg = /\<(script|style)\b[\s\S]*?\>([\s\S]*?)\<\/\1\>/g;
const angleBracketReg = /\<\S*\:\S*\>/g;
const linkReg = /\[[\s\S]*?\]\([\s\S]*?\)/g;
const codeSnippetImportReg = /^\s*<<<\s*.+/gm;
const plugin = () => {
return {
version: 1,
parseSFC(fileName, content) {
if (fileName.endsWith('.md')) {
content = content
// code block
.replace(codeblockReg, match => '```' + ' '.repeat(match.length - 6) + '```')
// inline code block
.replace(inlineCodeblockReg, match => `\`${' '.repeat(match.length - 2)}\``)
// # \<script setup>
.replace(scriptSetupReg, match => ' '.repeat(match.length))
// <<< https://vitepress.dev/guide/markdown#import-code-snippets
.replace(codeSnippetImportReg, match => ' '.repeat(match.length));
const codes = [];
for (const match of content.matchAll(sfcBlockReg)) {
if (match.index !== undefined) {
const matchText = match[0];
codes.push([matchText, undefined, match.index]);
codes.push('\n\n');
content = content.substring(0, match.index) + ' '.repeat(matchText.length) + content.substring(match.index + matchText.length);
}
}
content = content
// angle bracket: <http://foo.com>
.replace(angleBracketReg, match => ' '.repeat(match.length))
// [foo](http://foo.com)
.replace(linkReg, match => ' '.repeat(match.length));
codes.push('<template>\n');
codes.push([content, undefined, 0]);
codes.push('\n</template>');
const file2VueSourceMap = new source_map_1.SourceMap((0, source_map_1.buildMappings)(codes));
const sfc = (0, parseSfc_1.parse)((0, source_map_1.toString)(codes));
if (sfc.descriptor.template) {
transformRange(sfc.descriptor.template);
}
if (sfc.descriptor.script) {
transformRange(sfc.descriptor.script);
}
if (sfc.descriptor.scriptSetup) {
transformRange(sfc.descriptor.scriptSetup);
}
for (const style of sfc.descriptor.styles) {
transformRange(style);
}
for (const customBlock of sfc.descriptor.customBlocks) {
transformRange(customBlock);
}
return sfc;
function transformRange(block) {
block.loc.start.offset = file2VueSourceMap.toSourceOffset(block.loc.start.offset)?.[0] ?? -1;
block.loc.end.offset = file2VueSourceMap.toSourceOffset(block.loc.end.offset)?.[0] ?? -1;
}
}
;
}
};
};
exports.default = plugin;
//# sourceMappingURL=file-md.js.map

View File

@ -0,0 +1,4 @@
import { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;
//# sourceMappingURL=file-vue.d.ts.map

View File

@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const parseSfc_1 = require("../utils/parseSfc");
const plugin = (_ctx) => {
return {
version: 1,
parseSFC(_fileName, content) {
return (0, parseSfc_1.parse)(content);
},
updateSFC(sfc, change) {
const blocks = [
sfc.descriptor.template,
sfc.descriptor.script,
sfc.descriptor.scriptSetup,
...sfc.descriptor.styles,
...sfc.descriptor.customBlocks,
].filter((block) => !!block);
const hitBlock = blocks.find(block => change.start >= block.loc.start.offset && change.end <= block.loc.end.offset);
if (!hitBlock) {
return;
}
const oldContent = hitBlock.content;
const newContent = hitBlock.content =
hitBlock.content.substring(0, change.start - hitBlock.loc.start.offset)
+ change.newText
+ hitBlock.content.substring(change.end - hitBlock.loc.start.offset);
// #3449
const endTagRegex = new RegExp(`</\\s*${hitBlock.type}\\s*>`);
const insertedEndTag = !!oldContent.match(endTagRegex) !== !!newContent.match(endTagRegex);
if (insertedEndTag) {
return;
}
const lengthDiff = change.newText.length - (change.end - change.start);
for (const block of blocks) {
if (block.loc.start.offset > change.end) {
block.loc.start.offset += lengthDiff;
}
if (block.loc.end.offset >= change.end) {
block.loc.end.offset += lengthDiff;
}
}
return sfc;
},
};
};
exports.default = plugin;
//# sourceMappingURL=file-vue.js.map

View File

@ -0,0 +1,4 @@
import { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;
//# sourceMappingURL=vue-sfc-customblocks.d.ts.map

View File

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const language_core_1 = require("@volar/language-core");
const customBlockReg = /^(.*)\.customBlock_([^_]+)_(\d+)\.([^.]+)$/;
const plugin = () => {
return {
version: 1,
getEmbeddedFileNames(fileName, sfc) {
const names = [];
for (let i = 0; i < sfc.customBlocks.length; i++) {
const customBlock = sfc.customBlocks[i];
names.push(fileName + '.customBlock_' + customBlock.type + '_' + i + '.' + customBlock.lang);
}
return names;
},
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
const match = embeddedFile.fileName.match(customBlockReg);
if (match) {
const index = parseInt(match[3]);
const customBlock = sfc.customBlocks[index];
embeddedFile.capabilities = language_core_1.FileCapabilities.full;
embeddedFile.content.push([
customBlock.content,
customBlock.name,
0,
language_core_1.FileRangeCapabilities.full,
]);
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-sfc-customblocks.js.map

View File

@ -0,0 +1,4 @@
import { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;
//# sourceMappingURL=vue-sfc-scripts.d.ts.map

View File

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const language_core_1 = require("@volar/language-core");
const scriptFormatReg = /^(.*)\.script_format\.([^.]+)$/;
const scriptSetupFormatReg = /^(.*)\.scriptSetup_format\.([^.]+)$/;
const plugin = () => {
return {
version: 1,
getEmbeddedFileNames(fileName, sfc) {
const names = [];
if (sfc.script) {
names.push(fileName + '.script_format.' + sfc.script.lang);
}
if (sfc.scriptSetup) {
names.push(fileName + '.scriptSetup_format.' + sfc.scriptSetup.lang);
}
return names;
},
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
const scriptMatch = embeddedFile.fileName.match(scriptFormatReg);
const scriptSetupMatch = embeddedFile.fileName.match(scriptSetupFormatReg);
const script = scriptMatch ? sfc.script : scriptSetupMatch ? sfc.scriptSetup : undefined;
if (script) {
embeddedFile.kind = language_core_1.FileKind.TextFile;
embeddedFile.capabilities = {
...language_core_1.FileCapabilities.full,
diagnostic: false,
codeAction: false,
inlayHint: false,
};
embeddedFile.content.push([
script.content,
script.name,
0,
{},
]);
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-sfc-scripts.js.map

View File

@ -0,0 +1,4 @@
import { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;
//# sourceMappingURL=vue-sfc-styles.d.ts.map

View File

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const language_core_1 = require("@volar/language-core");
const styleReg = /^(.*)\.style_(\d+)\.([^.]+)$/;
const plugin = () => {
return {
version: 1,
getEmbeddedFileNames(fileName, sfc) {
const names = [];
for (let i = 0; i < sfc.styles.length; i++) {
const style = sfc.styles[i];
names.push(fileName + '.style_' + i + '.' + style.lang);
}
return names;
},
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
const match = embeddedFile.fileName.match(styleReg);
if (match) {
const index = parseInt(match[2]);
const style = sfc.styles[index];
embeddedFile.capabilities = language_core_1.FileCapabilities.full;
embeddedFile.content.push([
style.content,
style.name,
0,
language_core_1.FileRangeCapabilities.full,
]);
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-sfc-styles.js.map

View File

@ -0,0 +1,4 @@
import { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;
//# sourceMappingURL=vue-sfc-template.d.ts.map

View File

@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const language_core_1 = require("@volar/language-core");
const templateReg = /^(.*)\.template\.([^.]+)$/;
const plugin = () => {
return {
version: 1,
getEmbeddedFileNames(fileName, sfc) {
if (sfc.template) {
return [fileName + '.template.' + sfc.template.lang];
}
return [];
},
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
const match = embeddedFile.fileName.match(templateReg);
if (match && sfc.template) {
embeddedFile.capabilities = language_core_1.FileCapabilities.full;
embeddedFile.content.push([
sfc.template.content,
sfc.template.name,
0,
language_core_1.FileRangeCapabilities.full,
]);
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-sfc-template.js.map

View File

@ -0,0 +1,4 @@
import { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;
//# sourceMappingURL=vue-template-html.d.ts.map

View File

@ -0,0 +1,169 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugin = ({ modules }) => {
return {
version: 1,
compileSFCTemplate(lang, template, options) {
if (lang === 'html') {
const compiler = modules['@vue/compiler-dom'];
return compiler.compile(template, {
...options,
comments: true,
});
}
},
updateSFCTemplate(oldResult, change) {
const CompilerDOM = modules['@vue/compiler-dom'];
const lengthDiff = change.newText.length - (change.end - change.start);
let hitNodes = [];
if (tryUpdateNode(oldResult.ast) && hitNodes.length) {
hitNodes = hitNodes.sort((a, b) => a.loc.source.length - b.loc.source.length);
const hitNode = hitNodes[0];
if (hitNode.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) {
return oldResult;
}
}
function tryUpdateNode(node) {
if (withinChangeRange(node.loc)) {
hitNodes.push(node);
}
if (tryUpdateNodeLoc(node.loc)) {
if (node.type === 0 /* CompilerDOM.NodeTypes.ROOT */) {
for (const child of node.children) {
if (!tryUpdateNode(child)) {
return false;
}
}
}
else if (node.type === 1 /* CompilerDOM.NodeTypes.ELEMENT */) {
if (withinChangeRange(node.loc)) {
// if not self closing, should not hit tag name
const start = node.loc.start.offset + 2;
const end = node.loc.start.offset + node.loc.source.lastIndexOf('</');
if (!withinChangeRange({ start: { offset: start }, end: { offset: end }, source: '' })) {
return false;
}
}
for (const prop of node.props) {
if (!tryUpdateNode(prop)) {
return false;
}
}
for (const child of node.children) {
if (!tryUpdateNode(child)) {
return false;
}
}
}
else if (node.type === 6 /* CompilerDOM.NodeTypes.ATTRIBUTE */) {
if (node.value && !tryUpdateNode(node.value)) {
return false;
}
}
else if (node.type === 7 /* CompilerDOM.NodeTypes.DIRECTIVE */) {
if (node.arg && withinChangeRange(node.arg.loc) && node.name === 'slot') {
return false;
}
if (node.exp && withinChangeRange(node.exp.loc) && node.name === 'for') { // #2266
return false;
}
if (node.arg && !tryUpdateNode(node.arg)) {
return false;
}
if (node.exp && !tryUpdateNode(node.exp)) {
return false;
}
}
else if (node.type === 12 /* CompilerDOM.NodeTypes.TEXT_CALL */) {
if (!tryUpdateNode(node.content)) {
return false;
}
}
else if (node.type === 8 /* CompilerDOM.NodeTypes.COMPOUND_EXPRESSION */) {
for (const childNode of node.children) {
if (typeof childNode === 'object') {
if (!tryUpdateNode(childNode)) {
return false;
}
}
}
}
else if (node.type === 9 /* CompilerDOM.NodeTypes.IF */) {
for (const branch of node.branches) {
if (branch.condition && !tryUpdateNode(branch.condition)) {
return false;
}
for (const child of branch.children) {
if (!tryUpdateNode(child)) {
return false;
}
}
}
}
else if (node.type === 11 /* CompilerDOM.NodeTypes.FOR */) {
for (const child of [
node.parseResult.source,
node.parseResult.value,
node.parseResult.key,
node.parseResult.index,
]) {
if (child && !tryUpdateNode(child)) {
return false;
}
}
for (const child of node.children) {
if (!tryUpdateNode(child)) {
return false;
}
}
}
else if (node.type === 5 /* CompilerDOM.NodeTypes.INTERPOLATION */) {
if (!tryUpdateNode(node.content)) {
return false;
}
}
else if (node.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) {
if (withinChangeRange(node.loc)) { // TODO: review this (slot name?)
if (node.isStatic) {
return false;
}
else {
node.content = node.loc.source;
}
}
}
return true;
}
return false;
}
function tryUpdateNodeLoc(loc) {
delete loc.__endOffset;
if (withinChangeRange(loc)) {
loc.source =
loc.source.substring(0, change.start - loc.start.offset)
+ change.newText
+ loc.source.substring(change.end - loc.start.offset);
loc.__endOffset = loc.end.offset;
loc.end.offset += lengthDiff;
return true;
}
else if (change.end <= loc.start.offset) {
loc.__endOffset = loc.end.offset;
loc.start.offset += lengthDiff;
loc.end.offset += lengthDiff;
return true;
}
else if (change.start >= loc.end.offset) {
return true; // no need update
}
return false;
}
function withinChangeRange(loc) {
const originalLocEnd = loc.__endOffset ?? loc.end.offset;
return change.start >= loc.start.offset && change.end <= originalLocEnd;
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-template-html.js.map

View File

@ -0,0 +1,80 @@
import { Sfc, VueLanguagePlugin } from '../types';
import * as muggle from 'muggle-string';
export declare const tsCodegen: WeakMap<Sfc, {
scriptRanges: () => {
exportDefault: (import("../types").TextRange & {
expression: import("../types").TextRange;
args: import("../types").TextRange;
argsNode: import("typescript").ObjectLiteralExpression | undefined;
componentsOption: import("../types").TextRange | undefined;
componentsOptionNode: import("typescript").ObjectLiteralExpression | undefined;
nameOption: import("../types").TextRange | undefined;
}) | undefined;
bindings: import("../types").TextRange[];
} | undefined;
scriptSetupRanges: () => {
leadingCommentEndOffset: number;
importSectionEndOffset: number;
bindings: import("../types").TextRange[];
props: {
name?: string | undefined;
define?: (import("../types").TextRange & {
arg?: import("../types").TextRange | undefined;
typeArg?: import("../types").TextRange | undefined;
} & {
statement: import("../types").TextRange;
}) | undefined;
withDefaults?: (import("../types").TextRange & {
arg?: import("../types").TextRange | undefined;
}) | undefined;
};
slots: {
name?: string | undefined;
define?: (import("../types").TextRange & {
arg?: import("../types").TextRange | undefined;
typeArg?: import("../types").TextRange | undefined;
}) | undefined;
};
emits: {
name?: string | undefined;
define?: (import("../types").TextRange & {
arg?: import("../types").TextRange | undefined;
typeArg?: import("../types").TextRange | undefined;
}) | undefined;
};
expose: {
name?: string | undefined;
define?: (import("../types").TextRange & {
arg?: import("../types").TextRange | undefined;
typeArg?: import("../types").TextRange | undefined;
}) | undefined;
};
defineProp: {
name: import("../types").TextRange | undefined;
nameIsString: boolean;
type: import("../types").TextRange | undefined;
defaultValue: import("../types").TextRange | undefined;
required: boolean;
}[];
} | undefined;
lang: () => string;
generatedScript: () => {
codes: muggle.Segment<import("@volar/language-core").FileRangeCapabilities>[];
codeStacks: muggle.StackNode[];
mirrorBehaviorMappings: import("@volar/source-map").Mapping<[import("@volar/language-core").MirrorBehaviorCapabilities, import("@volar/language-core").MirrorBehaviorCapabilities]>[];
};
generatedTemplate: () => {
codes: (string | [string, string | undefined, number | [number, number], import("@volar/language-core").FileRangeCapabilities])[];
codeStacks: muggle.StackNode[];
formatCodes: (string | [string, string | undefined, number | [number, number], import("@volar/language-core").FileRangeCapabilities])[];
formatCodeStacks: muggle.StackNode[];
cssCodes: (string | [string, string | undefined, number | [number, number], import("@volar/language-core").FileRangeCapabilities])[];
cssCodeStacks: muggle.StackNode[];
tagNames: Record<string, number[]>;
accessedGlobalVariables: Set<string>;
hasSlot: boolean;
} | undefined;
}>;
declare const plugin: VueLanguagePlugin;
export default plugin;
//# sourceMappingURL=vue-tsx.d.ts.map

159
node_modules/@vue/language-core/out/plugins/vue-tsx.js generated vendored Normal file
View File

@ -0,0 +1,159 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tsCodegen = void 0;
const computeds_1 = require("computeds");
const script_1 = require("../generators/script");
const template_1 = require("../generators/template");
const scriptRanges_1 = require("../parsers/scriptRanges");
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
const language_core_1 = require("@volar/language-core");
const muggle = require("muggle-string");
const templateFormatReg = /^\.template_format\.ts$/;
const templateStyleCssReg = /^\.template_style\.css$/;
exports.tsCodegen = new WeakMap();
const plugin = (ctx) => {
return {
version: 1,
requiredCompilerOptions: [
'noPropertyAccessFromIndexSignature',
'exactOptionalPropertyTypes',
],
getEmbeddedFileNames(fileName, sfc) {
const tsx = useTsx(fileName, sfc);
const fileNames = [];
if (['js', 'ts', 'jsx', 'tsx'].includes(tsx.lang())) {
fileNames.push(fileName + '.' + tsx.lang());
}
if (sfc.template) {
fileNames.push(fileName + '.template_format.ts');
fileNames.push(fileName + '.template_style.css');
}
return fileNames;
},
resolveEmbeddedFile(fileName, sfc, embeddedFile) {
const _tsx = useTsx(fileName, sfc);
const suffix = embeddedFile.fileName.replace(fileName, '');
if (suffix === '.' + _tsx.lang()) {
embeddedFile.kind = language_core_1.FileKind.TypeScriptHostFile;
embeddedFile.capabilities = {
...language_core_1.FileCapabilities.full,
foldingRange: false,
documentFormatting: false,
documentSymbol: false,
};
const tsx = _tsx.generatedScript();
if (tsx) {
const [content, contentStacks] = ctx.codegenStack ? muggle.track([...tsx.codes], [...tsx.codeStacks]) : [[...tsx.codes], [...tsx.codeStacks]];
embeddedFile.content = content;
embeddedFile.contentStacks = contentStacks;
embeddedFile.mirrorBehaviorMappings = [...tsx.mirrorBehaviorMappings];
}
}
else if (suffix.match(templateFormatReg)) {
embeddedFile.parentFileName = fileName + '.template.' + sfc.template?.lang;
embeddedFile.kind = language_core_1.FileKind.TextFile;
embeddedFile.capabilities = {
...language_core_1.FileCapabilities.full,
diagnostic: false,
foldingRange: false,
codeAction: false,
inlayHint: false,
};
const template = _tsx.generatedTemplate();
if (template) {
const [content, contentStacks] = ctx.codegenStack
? muggle.track([...template.formatCodes], [...template.formatCodeStacks])
: [[...template.formatCodes], [...template.formatCodeStacks]];
embeddedFile.content = content;
embeddedFile.contentStacks = contentStacks;
}
for (const style of sfc.styles) {
embeddedFile.content.push('\n\n');
for (const cssVar of style.cssVars) {
embeddedFile.content.push('(');
embeddedFile.content.push([
cssVar.text,
style.name,
cssVar.offset,
{},
]);
embeddedFile.content.push(');\n');
}
}
}
else if (suffix.match(templateStyleCssReg)) {
embeddedFile.parentFileName = fileName + '.template.' + sfc.template?.lang;
const template = _tsx.generatedTemplate();
if (template) {
const [content, contentStacks] = ctx.codegenStack
? muggle.track([...template.cssCodes], [...template.cssCodeStacks])
: [[...template.cssCodes], [...template.cssCodeStacks]];
embeddedFile.content = content;
embeddedFile.contentStacks = contentStacks;
}
// for color pickers support
embeddedFile.capabilities.documentSymbol = true;
}
},
};
function useTsx(fileName, sfc) {
if (!exports.tsCodegen.has(sfc)) {
exports.tsCodegen.set(sfc, createTsx(fileName, sfc, ctx));
}
return exports.tsCodegen.get(sfc);
}
};
exports.default = plugin;
function createTsx(fileName, _sfc, { vueCompilerOptions, compilerOptions, codegenStack, modules }) {
const ts = modules.typescript;
const lang = (0, computeds_1.computed)(() => {
return !_sfc.script && !_sfc.scriptSetup ? 'ts'
: _sfc.scriptSetup && _sfc.scriptSetup.lang !== 'js' ? _sfc.scriptSetup.lang
: _sfc.script && _sfc.script.lang !== 'js' ? _sfc.script.lang
: 'js';
});
const scriptRanges = (0, computeds_1.computed)(() => _sfc.script
? (0, scriptRanges_1.parseScriptRanges)(ts, _sfc.script.ast, !!_sfc.scriptSetup, false)
: undefined);
const scriptSetupRanges = (0, computeds_1.computed)(() => _sfc.scriptSetup
? (0, scriptSetupRanges_1.parseScriptSetupRanges)(ts, _sfc.scriptSetup.ast, vueCompilerOptions)
: undefined);
const shouldGenerateScopedClasses = (0, computeds_1.computed)(() => {
const option = vueCompilerOptions.experimentalResolveStyleCssClasses;
return _sfc.styles.some(s => {
return option === 'always' || (option === 'scoped' && s.scoped);
});
});
const stylesScopedClasses = (0, computeds_1.computedSet)(() => {
const classes = new Set();
if (!shouldGenerateScopedClasses()) {
return classes;
}
for (const style of _sfc.styles) {
const option = vueCompilerOptions.experimentalResolveStyleCssClasses;
if (option === 'always' || (option === 'scoped' && style.scoped)) {
for (const className of style.classNames) {
classes.add(className.text.substring(1));
}
}
}
return classes;
});
const generatedTemplate = (0, computeds_1.computed)(() => {
if (!_sfc.template)
return;
return (0, template_1.generate)(ts, compilerOptions, vueCompilerOptions, _sfc.template, shouldGenerateScopedClasses(), stylesScopedClasses(), hasScriptSetupSlots(), slotsAssignName(), propsAssignName(), codegenStack);
});
const hasScriptSetupSlots = (0, computeds_1.computed)(() => !!scriptSetupRanges()?.slots.define);
const slotsAssignName = (0, computeds_1.computed)(() => scriptSetupRanges()?.slots.name);
const propsAssignName = (0, computeds_1.computed)(() => scriptSetupRanges()?.props.name);
const generatedScript = (0, computeds_1.computed)(() => (0, script_1.generate)(ts, fileName, _sfc.script, _sfc.scriptSetup, _sfc.styles, lang(), scriptRanges(), scriptSetupRanges(), generatedTemplate(), compilerOptions, vueCompilerOptions, codegenStack));
return {
scriptRanges,
scriptSetupRanges,
lang,
generatedScript,
generatedTemplate,
};
}
//# sourceMappingURL=vue-tsx.js.map