feat: init

This commit is contained in:
2026-02-13 22:02:30 +01:00
commit 8f9ff830fb
16711 changed files with 3307340 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,91 @@
"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 = ({ vueCompilerOptions }) => {
return {
version: 2.2,
getLanguageId(fileName) {
if (vueCompilerOptions.petiteVueExtensions.some(ext => fileName.endsWith(ext))) {
return 'html';
}
},
isValidFile(_fileName, languageId) {
return languageId === 'html';
},
parseSFC2(fileName, languageId, content) {
if (languageId !== 'html') {
return;
}
let sfc = {
descriptor: {
filename: fileName,
source: content,
comments: [],
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.includes('src=')) {
let type = attrs.includes('type=') ? '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.slice(0, match.index) + ' '.repeat(matchText.length)
+ templateContent.slice(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,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

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

@@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const language_core_1 = require("@volar/language-core");
const muggle_string_1 = require("muggle-string");
const buildMappings_1 = require("../utils/buildMappings");
const parseSfc_1 = require("../utils/parseSfc");
const frontmatterReg = /^---[\s\S]*?\n---(?:\r?\n|$)/;
const codeblockReg = /(`{3,})[\s\S]+?\1/g;
const inlineCodeblockReg = /`[^\n`]+?`/g;
const latexBlockReg = /(\${2,})[\s\S]+?\1/g;
const scriptSetupReg = /\\<[\s\S]+?>\n?/g;
const codeSnippetImportReg = /^\s*<<<\s*.+/gm;
const sfcBlockReg = /<(script|style)\b[\s\S]*?>([\s\S]*?)<\/\1>/g;
const angleBracketReg = /<\S*:\S*>/g;
const linkReg = /\[[\s\S]*?\]\([\s\S]*?\)/g;
const plugin = ({ vueCompilerOptions }) => {
return {
version: 2.2,
getLanguageId(fileName) {
if (vueCompilerOptions.vitePressExtensions.some(ext => fileName.endsWith(ext))) {
return 'markdown';
}
},
isValidFile(_fileName, languageId) {
return languageId === 'markdown';
},
parseSFC2(_fileName, languageId, content) {
if (languageId !== 'markdown') {
return;
}
content = content
// frontmatter
.replace(frontmatterReg, match => ' '.repeat(match.length))
// code block
.replace(codeblockReg, (match, quotes) => quotes + ' '.repeat(match.length - quotes.length * 2) + quotes)
// inline code block
.replace(inlineCodeblockReg, match => `\`${' '.repeat(match.length - 2)}\``)
// latex block
.replace(latexBlockReg, (match, quotes) => quotes + ' '.repeat(match.length - quotes.length * 2) + quotes)
// # \<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)) {
const matchText = match[0];
codes.push([matchText, undefined, match.index]);
codes.push('\n\n');
content = content.slice(0, match.index) + ' '.repeat(matchText.length)
+ content.slice(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 mappings = (0, buildMappings_1.buildMappings)(codes);
const mapper = new language_core_1.SourceMap(mappings);
const sfc = (0, parseSfc_1.parse)((0, muggle_string_1.toString)(codes));
for (const block of [
sfc.descriptor.template,
sfc.descriptor.script,
sfc.descriptor.scriptSetup,
...sfc.descriptor.styles,
...sfc.descriptor.customBlocks,
]) {
if (block) {
transformRange(block);
}
}
return sfc;
function transformRange(block) {
const { start, end } = block.loc;
const startOffset = start.offset;
const endOffset = end.offset;
start.offset = -1;
end.offset = -1;
for (const [offset] of mapper.toSourceLocation(startOffset)) {
start.offset = offset;
break;
}
for (const [offset] of mapper.toSourceLocation(endOffset)) {
end.offset = offset;
break;
}
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=file-md.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const parseSfc_1 = require("../utils/parseSfc");
const plugin = ({ vueCompilerOptions }) => {
return {
version: 2.2,
getLanguageId(fileName) {
if (vueCompilerOptions.extensions.some(ext => fileName.endsWith(ext))) {
return 'vue';
}
},
isValidFile(_fileName, languageId) {
return languageId === 'vue';
},
parseSFC2(_fileName, languageId, content) {
if (languageId !== 'vue') {
return;
}
const sfc = (0, parseSfc_1.parse)(content);
for (const error of sfc.errors) {
// Handle 'Element is missing end tag.' error, see #4893
if ('code' in error && error.code === 24 && sfc.descriptor.template
&& error.loc?.start.line === sfc.descriptor.template.loc.start.line) {
const template = sfc.descriptor.template;
const templateText = template.content;
const endTagOffset = templateText.lastIndexOf('<');
const endTagText = templateText.slice(endTagOffset).trimEnd();
if ('</template>'.startsWith(endTagText)) {
sfc.descriptor.template.loc.end.offset = template.loc.start.offset + endTagOffset;
template.content = templateText.slice(0, endTagOffset);
}
}
}
return sfc;
},
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.slice(0, change.start - hitBlock.loc.start.offset)
+ change.newText
+ hitBlock.content.slice(change.end - hitBlock.loc.start.offset);
// #3449
const endTagRegex = new RegExp(`</\\s*${hitBlock.type}\\s*>`);
const insertedEndTag = endTagRegex.test(oldContent) !== endTagRegex.test(newContent);
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,2 @@
import type { CodeInformation } from '@volar/language-core';
export declare const allCodeFeatures: CodeInformation;

12
node_modules/@vue/language-core/lib/plugins/shared.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.allCodeFeatures = void 0;
exports.allCodeFeatures = {
verification: true,
completion: true,
semantic: true,
navigation: true,
structure: true,
format: true,
};
//# sourceMappingURL=shared.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const muggle_string_1 = require("muggle-string");
const shared_1 = require("./shared");
const plugin = () => {
return {
version: 2.2,
getEmbeddedCodes() {
return [{
id: 'root_tags',
lang: 'vue-root-tags',
}];
},
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
if (embeddedFile.id === 'root_tags') {
embeddedFile.content.push([sfc.content, undefined, 0, shared_1.allCodeFeatures]);
for (const block of [
sfc.template,
sfc.script,
sfc.scriptSetup,
...sfc.styles,
...sfc.customBlocks,
]) {
if (!block) {
continue;
}
const offset = block.content.lastIndexOf('\n', block.content.lastIndexOf('\n') - 1) + 1;
// fix folding range end position failed to mapping
(0, muggle_string_1.replaceSourceRange)(embeddedFile.content, undefined, block.startTagEnd, block.endTagStart, sfc.content.slice(block.startTagEnd, block.startTagEnd + offset), [
'',
undefined,
block.startTagEnd + offset,
{ structure: true },
], sfc.content.slice(block.startTagEnd + offset, block.endTagStart));
}
}
else {
embeddedFile.parentCodeId ??= 'root_tags';
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-root-tags.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugin = ({ modules }) => {
return {
version: 2.2,
compileSFCScript(lang, script) {
if (lang === 'js' || lang === 'ts' || lang === 'jsx' || lang === 'tsx') {
const ts = modules.typescript;
return ts.createSourceFile('.' + lang, script, 99);
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-script-js.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shared_1 = require("./shared");
const plugin = () => {
return {
version: 2.2,
getEmbeddedCodes(_fileName, sfc) {
return sfc.customBlocks.map((customBlock, i) => ({
id: 'custom_block_' + i,
lang: customBlock.lang,
}));
},
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
if (embeddedFile.id.startsWith('custom_block_')) {
const index = parseInt(embeddedFile.id.slice('custom_block_'.length));
const customBlock = sfc.customBlocks[index];
embeddedFile.content.push([
customBlock.content,
customBlock.name,
0,
shared_1.allCodeFeatures,
]);
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-sfc-customblocks.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugin = () => {
return {
version: 2.2,
getEmbeddedCodes(_fileName, sfc) {
const names = [];
if (sfc.script) {
names.push({ id: 'script_raw', lang: sfc.script.lang });
}
if (sfc.scriptSetup) {
names.push({ id: 'scriptsetup_raw', lang: sfc.scriptSetup.lang });
}
return names;
},
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
const script = embeddedFile.id === 'script_raw'
? sfc.script
: embeddedFile.id === 'scriptsetup_raw'
? sfc.scriptSetup
: undefined;
if (script) {
embeddedFile.content.push([
script.content,
script.name,
0,
{
structure: true,
format: true,
},
]);
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-sfc-scripts.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shared_1 = require("./shared");
const plugin = () => {
return {
version: 2.2,
getEmbeddedCodes(_fileName, sfc) {
const result = [];
for (let i = 0; i < sfc.styles.length; i++) {
const style = sfc.styles[i];
if (style) {
result.push({
id: 'style_' + i,
lang: style.lang,
});
if (style.bindings.length) {
result.push({
id: 'style_' + i + '_inline_ts',
lang: 'ts',
});
}
}
}
return result;
},
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
if (embeddedFile.id.startsWith('style_')) {
const index = parseInt(embeddedFile.id.split('_')[1]);
const style = sfc.styles[index];
if (embeddedFile.id.endsWith('_inline_ts')) {
embeddedFile.parentCodeId = 'style_' + index;
for (const binding of style.bindings) {
embeddedFile.content.push('(', [
binding.text,
style.name,
binding.offset,
shared_1.allCodeFeatures,
], ');\n');
}
}
else {
embeddedFile.content.push([
style.content,
style.name,
0,
shared_1.allCodeFeatures,
]);
}
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-sfc-styles.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shared_1 = require("./shared");
const plugin = () => {
return {
version: 2.2,
getEmbeddedCodes(_fileName, sfc) {
if (sfc.template?.lang === 'html') {
return [{
id: 'template',
lang: sfc.template.lang,
}];
}
return [];
},
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
if (embeddedFile.id === 'template' && sfc.template?.lang === 'html') {
embeddedFile.content.push([
sfc.template.content,
sfc.template.name,
0,
shared_1.allCodeFeatures,
]);
}
},
};
};
exports.default = plugin;
//# sourceMappingURL=vue-sfc-template.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugin = () => {
return {
version: 2.2,
compileSFCStyle(_lang, style) {
return {
imports: [...parseCssImports(style)],
bindings: [...parseCssBindings(style)],
classNames: [...parseCssClassNames(style)],
};
},
};
};
exports.default = plugin;
const cssImportReg = /(?<=@import\s+url\()(["']?).*?\1(?=\))|(?<=@import\b\s*)(["']).*?\2/g;
const cssBindingReg = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([a-z_]\w*))\s*\)/gi;
const cssClassNameReg = /(?=(\.[a-z_][-\w]*)[\s.,+~>:#)[{])/gi;
const commentReg = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
const fragmentReg = /(?<={)[^{]*(?=(?<!\\);)/g;
function* parseCssImports(css) {
const matches = css.matchAll(cssImportReg);
for (const match of matches) {
let text = match[0];
let offset = match.index;
if (text.startsWith("'") || text.startsWith('"')) {
text = text.slice(1, -1);
offset += 1;
}
if (text) {
yield { text, offset };
}
}
}
function* parseCssBindings(css) {
css = fillBlank(css, commentReg);
const matchs = css.matchAll(cssBindingReg);
for (const match of matchs) {
const matchText = match.slice(1).find(t => t);
if (matchText) {
const offset = match.index + css.slice(match.index).indexOf(matchText);
yield { offset, text: matchText };
}
}
}
function* parseCssClassNames(css) {
css = fillBlank(css, commentReg, fragmentReg);
const matches = css.matchAll(cssClassNameReg);
for (const match of matches) {
const matchText = match[1];
if (matchText) {
yield { offset: match.index, text: matchText };
}
}
}
function fillBlank(css, ...regs) {
for (const reg of regs) {
css = css.replace(reg, match => ' '.repeat(match.length));
}
return css;
}
//# sourceMappingURL=vue-style-css.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,203 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shouldAddSuffix = /(?<=<[^>/]+)$/;
const plugin = ({ modules }) => {
const CompilerDOM = modules['@vue/compiler-dom'];
return {
version: 2.2,
compileSFCTemplate(lang, template, options) {
if (lang === 'html' || lang === 'md') {
let addedSuffix = false;
// #4583
if (shouldAddSuffix.test(template)) {
template += '>';
addedSuffix = true;
}
const ast = CompilerDOM.parse(template, {
...options,
comments: true,
});
CompilerDOM.transform(ast, options);
return {
ast,
code: '',
preamble: '',
__addedSuffix: addedSuffix,
};
}
},
updateSFCTemplate(oldResult, change) {
const newSource = oldResult.ast.source.slice(0, change.start)
+ change.newText
+ oldResult.ast.source.slice(change.end);
// @ts-expect-error
if (oldResult.__addedSuffix) {
const originalTemplate = newSource.slice(0, -1); // remove added '>'
if (!shouldAddSuffix.test(originalTemplate)) {
return undefined;
}
}
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 === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
return oldResult;
}
}
function tryUpdateNode(node) {
if (withinChangeRange(node.loc)) {
hitNodes.push(node);
}
if (tryUpdateNodeLoc(node.loc)) {
if (node.type === CompilerDOM.NodeTypes.ROOT) {
for (const child of node.children) {
if (!tryUpdateNode(child)) {
return false;
}
}
}
else if (node.type === 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 === CompilerDOM.NodeTypes.ATTRIBUTE) {
if (node.value && !tryUpdateNode(node.value)) {
return false;
}
}
else if (node.type === 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 === CompilerDOM.NodeTypes.TEXT_CALL) {
if (!tryUpdateNode(node.content)) {
return false;
}
}
else if (node.type === CompilerDOM.NodeTypes.COMPOUND_EXPRESSION) {
for (const childNode of node.children) {
if (typeof childNode === 'object') {
if (!tryUpdateNode(childNode)) {
return false;
}
}
}
}
else if (node.type === 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 === CompilerDOM.NodeTypes.FOR) {
for (const child of [
node.parseResult.source,
node.parseResult.value,
node.parseResult.key,
node.parseResult.index,
]) {
if (child) {
if (!tryUpdateNode(child)) {
return false;
}
if (child.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
const content = child.content.trim();
if (content.startsWith('(') || content.endsWith(')')) {
return false;
}
}
}
}
for (const child of node.children) {
if (!tryUpdateNode(child)) {
return false;
}
}
}
else if (node.type === CompilerDOM.NodeTypes.INTERPOLATION) {
if (!tryUpdateNode(node.content)) {
return false;
}
}
else if (node.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
if (withinChangeRange(node.loc)) { // TODO: review this (slot name?)
if (node.isStatic) {
return false;
}
else if (!node.loc.source) {
// :class="..." -> :class=""
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.slice(0, change.start - loc.start.offset)
+ change.newText
+ loc.source.slice(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,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,78 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
const forEachTemplateNode_1 = require("../utils/forEachTemplateNode");
const shared_1 = require("../utils/shared");
const shared_2 = require("./shared");
const codeFeatures = {
...shared_2.allCodeFeatures,
format: false,
structure: false,
};
const plugin = () => {
return {
version: 2.2,
getEmbeddedCodes(_fileName, sfc) {
if (!sfc.template?.ast) {
return [];
}
return [{ id: 'template_inline_css', lang: 'css' }];
},
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
if (embeddedFile.id !== 'template_inline_css' || !sfc.template?.ast) {
return;
}
embeddedFile.parentCodeId = sfc.template.lang === 'md' ? 'root_tags' : 'template';
embeddedFile.content.push(...generate(sfc.template.ast));
},
};
};
exports.default = plugin;
function* generate(templateAst) {
for (const node of (0, forEachTemplateNode_1.forEachElementNode)(templateAst)) {
for (const prop of node.props) {
if (prop.type === CompilerDOM.NodeTypes.ATTRIBUTE
&& prop.name === 'style'
&& prop.value) {
yield `x { `;
const [content, offset] = (0, shared_1.normalizeAttributeValue)(prop.value);
yield [content, 'template', offset, codeFeatures];
yield ` }\n`;
}
}
}
}
//# sourceMappingURL=vue-template-inline-css.js.map

View File

@@ -0,0 +1,3 @@
import type { VueLanguagePlugin } from '../types';
declare const plugin: VueLanguagePlugin;
export default plugin;

View File

@@ -0,0 +1,236 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
const elementEvents_1 = require("../codegen/template/elementEvents");
const templateChild_1 = require("../codegen/template/templateChild");
const vFor_1 = require("../codegen/template/vFor");
const utils_1 = require("../codegen/utils");
const codeFeatures = {
format: true,
};
const formatBrackets = {
normal: ['`${', '}`;'],
if: ['if (', ') { }'],
for: ['for (', ') { }'],
// fix https://github.com/vuejs/language-tools/issues/3572
params: ['(', ') => {};'],
// fix https://github.com/vuejs/language-tools/issues/1210
// fix https://github.com/vuejs/language-tools/issues/2305
curly: ['0 +', '+ 0;'],
event: ['() => ', ';'],
generic: ['<', '>() => {};'],
};
const plugin = ({ modules: { typescript: ts } }) => {
const parseds = new WeakMap();
return {
version: 2.2,
getEmbeddedCodes(_fileName, sfc) {
if (!sfc.template?.ast) {
return [];
}
const parsed = parse(sfc);
parseds.set(sfc, parsed);
const result = [];
for (const [id] of parsed) {
result.push({ id, lang: 'ts' });
}
return result;
},
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
if (!embeddedFile.id.startsWith('template_inline_ts_')) {
return;
}
// access template content to watch change
void sfc.template?.content;
const parsed = parseds.get(sfc);
if (parsed) {
const codes = parsed.get(embeddedFile.id);
if (codes) {
embeddedFile.content.push(...codes);
embeddedFile.parentCodeId = sfc.template?.lang === 'md' ? 'root_tags' : 'template';
}
}
},
};
function parse(sfc) {
const result = new Map();
if (!sfc.template?.ast) {
return result;
}
const template = sfc.template;
let i = 0;
sfc.template.ast.children.forEach(visit);
return result;
function visit(node) {
if (node.type === CompilerDOM.NodeTypes.COMMENT) {
const match = node.loc.source.match(/^<!--\s*@vue-generic\s*\{(?<content>[\s\S]*)\}\s*-->$/);
if (match) {
const { content } = match.groups;
addFormatCodes(content, node.loc.start.offset + node.loc.source.indexOf('{') + 1, formatBrackets.generic);
}
}
else if (node.type === CompilerDOM.NodeTypes.ELEMENT) {
for (const prop of node.props) {
if (prop.type !== CompilerDOM.NodeTypes.DIRECTIVE) {
continue;
}
const isShorthand = prop.arg?.loc.start.offset === prop.exp?.loc.start.offset; // vue 3.4+
if (isShorthand) {
continue;
}
if (prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && !prop.arg.isStatic) {
addFormatCodes(prop.arg.loc.source, prop.arg.loc.start.offset, formatBrackets.normal);
}
if (prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
&& prop.exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY // style='z-index: 2' will compile to {'z-index':'2'}
) {
if (prop.name === 'on' && prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
const ast = (0, utils_1.getTypeScriptAST)(ts, template, prop.exp.content);
if ((0, elementEvents_1.isCompoundExpression)(ts, ast)) {
addFormatCodes(prop.exp.loc.source, prop.exp.loc.start.offset, formatBrackets.event);
}
else {
const lines = prop.exp.content.split('\n');
const firstLineEmpty = lines[0].trim() === '';
const lastLineEmpty = lines[lines.length - 1].trim() === '';
if (lines.length <= 1 || (!firstLineEmpty && !lastLineEmpty)) {
addFormatCodes(prop.exp.loc.source, prop.exp.loc.start.offset, formatBrackets.normal);
}
else {
addFormatCodes(prop.exp.loc.source, prop.exp.loc.start.offset, ['(', ');']);
}
}
}
else if (prop.name === 'slot') {
addFormatCodes(prop.exp.loc.source, prop.exp.loc.start.offset, formatBrackets.params);
}
else if (prop.rawName === 'v-for') {
// #2586
addFormatCodes(prop.exp.loc.source, prop.exp.loc.start.offset, formatBrackets.for);
}
else {
addFormatCodes(prop.exp.loc.source, prop.exp.loc.start.offset, formatBrackets.normal);
}
}
}
for (const child of node.children) {
visit(child);
}
}
else if (node.type === CompilerDOM.NodeTypes.IF) {
for (const branch of node.branches) {
if (branch.condition?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
addFormatCodes(branch.condition.loc.source, branch.condition.loc.start.offset, formatBrackets.if);
}
for (const childNode of branch.children) {
visit(childNode);
}
}
}
else if (node.type === CompilerDOM.NodeTypes.FOR) {
const { leftExpressionRange, leftExpressionText } = (0, vFor_1.parseVForNode)(node);
const { source } = node.parseResult;
if (leftExpressionRange && leftExpressionText && source.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
let start = leftExpressionRange.start;
let end = source.loc.start.offset + source.content.length;
while (template.content[start - 1] === ' ' || template.content[start - 1] === '(') {
start--;
}
while (template.content[end] === ' ' || template.content[end] === ')') {
end++;
}
addFormatCodes(template.content.slice(start, end), start, formatBrackets.for);
}
for (const child of node.children) {
visit(child);
}
}
else if (node.type === CompilerDOM.NodeTypes.TEXT_CALL) {
// {{ var }}
visit(node.content);
}
else if (node.type === CompilerDOM.NodeTypes.COMPOUND_EXPRESSION) {
// {{ ... }} {{ ... }}
for (const childNode of node.children) {
if (typeof childNode === 'object') {
visit(childNode);
}
}
}
else if (node.type === CompilerDOM.NodeTypes.INTERPOLATION) {
// {{ ... }}
const [content, start] = (0, templateChild_1.parseInterpolationNode)(node, template.content);
const lines = content.split('\n');
const firstLineEmpty = lines[0].trim() === '';
const lastLineEmpty = lines[lines.length - 1].trim() === '';
if (content.includes('=>')) { // arrow function
if (lines.length <= 1 || (!firstLineEmpty && !lastLineEmpty)) {
addFormatCodes(content, start, formatBrackets.normal);
}
else {
addFormatCodes(content, start, ['(', ');']);
}
}
else {
if (lines.length <= 1 || (!firstLineEmpty && !lastLineEmpty)) {
addFormatCodes(content, start, formatBrackets.curly);
}
else {
addFormatCodes(content, start, [
firstLineEmpty ? '(' : '(0 +',
lastLineEmpty ? ');' : '+ 0);',
]);
}
}
}
}
function addFormatCodes(code, offset, wrapper) {
const id = 'template_inline_ts_' + i++;
result.set(id, [
wrapper[0],
[
code,
'template',
offset,
codeFeatures,
],
wrapper[1],
]);
}
}
};
exports.default = plugin;
//# sourceMappingURL=vue-template-inline-ts.js.map

View File

@@ -0,0 +1,106 @@
import type { Sfc, VueLanguagePlugin } from '../types';
export declare const tsCodegen: WeakMap<Sfc, {
getScriptRanges: () => {
exportDefault: (import("../types").TextRange<import("typescript").Node> & {
expression: import("../types").TextRange<import("typescript").Expression>;
isObjectLiteral: boolean;
options?: {
isObjectLiteral: boolean;
expression: import("../types").TextRange<import("typescript").Node>;
args: import("../types").TextRange<import("typescript").ObjectLiteralExpression>;
components: import("../types").TextRange<import("typescript").ObjectLiteralExpression> | undefined;
directives: import("../types").TextRange<import("typescript").Node> | undefined;
name: import("../types").TextRange<import("typescript").StringLiteral> | undefined;
inheritAttrs: string | undefined;
} | undefined;
}) | undefined;
bindings: import("../types").TextRange<import("typescript").Node>[];
components: import("../types").TextRange<import("typescript").Node>[];
} | undefined;
getScriptSetupRanges: () => {
leadingCommentEndOffset: number;
importSectionEndOffset: number;
bindings: import("../types").TextRange<import("typescript").Node>[];
components: import("../types").TextRange<import("typescript").Node>[];
defineModel: import("../parsers/scriptSetupRanges").DefineModel[];
defineProps: import("../parsers/scriptSetupRanges").DefineProps | undefined;
withDefaults: import("../parsers/scriptSetupRanges").CallExpressionRange | undefined;
defineEmits: import("../parsers/scriptSetupRanges").DefineEmits | undefined;
defineSlots: import("../parsers/scriptSetupRanges").DefineSlots | undefined;
defineExpose: import("../parsers/scriptSetupRanges").CallExpressionRange | undefined;
defineOptions: import("../parsers/scriptSetupRanges").DefineOptions | undefined;
useAttrs: import("../parsers/scriptSetupRanges").CallExpressionRange[];
useCssModule: import("../parsers/scriptSetupRanges").CallExpressionRange[];
useSlots: import("../parsers/scriptSetupRanges").CallExpressionRange[];
useTemplateRef: import("../parsers/scriptSetupRanges").UseTemplateRef[];
} | undefined;
getGeneratedScript: () => {
generatedTypes: Set<string>;
localTypes: {
generate: () => Generator<string, void, unknown>;
readonly PrettifyLocal: string;
readonly WithDefaults: string;
readonly WithSlots: string;
readonly PropsChildren: string;
readonly TypePropsToOption: string;
readonly OmitIndexSignature: string;
};
inlayHints: import("../codegen/inlayHints").InlayHintInfo[];
codes: import("../types").Code[];
};
getGeneratedTemplate: () => {
generatedTypes: Set<string>;
currentInfo: {
ignoreError?: boolean | undefined;
expectError?: {
token: number;
node: import("@vue/compiler-dom").CommentNode;
} | undefined;
generic?: {
content: string;
offset: number;
} | undefined;
};
resolveCodeFeatures: (features: import("../types").VueCodeInformation) => import("../types").VueCodeInformation;
inVFor: boolean;
slots: {
name: string;
offset?: number | undefined;
tagRange: [number, number];
nodeLoc: any;
propsVar: string;
}[];
dynamicSlots: {
expVar: string;
propsVar: string;
}[];
dollarVars: Set<string>;
componentAccessMap: Map<string, Map<string, Set<number>>>;
blockConditions: string[];
inlayHints: import("../codegen/inlayHints").InlayHintInfo[];
inheritedAttrVars: Set<string>;
templateRefs: Map<string, {
typeExp: string;
offset: number;
}[]>;
singleRootElTypes: Set<string>;
singleRootNodes: Set<import("@vue/compiler-dom").ElementNode | null>;
addTemplateRef(name: string, typeExp: string, offset: number): void;
recordComponentAccess(source: string, name: string, offset?: number | undefined): void;
scopes: Set<string>[];
components: (() => string)[];
declare(...varNames: string[]): void;
startScope(): () => Generator<import("../types").Code, any, any>;
getInternalVariable(): string;
getHoistVariable(originalVar: string): string;
generateHoistVariables(): Generator<string, void, unknown>;
generateConditionGuards(): Generator<string, void, unknown>;
enter(node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").SimpleExpressionNode | import("@vue/compiler-dom").TemplateChildNode): boolean;
exit(): Generator<import("../types").Code, any, any>;
codes: import("../types").Code[];
} | undefined;
getImportedComponents: () => Set<string>;
getSetupExposed: () => Set<string>;
}>;
declare const plugin: VueLanguagePlugin;
export default plugin;

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

@@ -0,0 +1,260 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.tsCodegen = void 0;
const shared_1 = require("@vue/shared");
const alien_signals_1 = require("alien-signals");
const path = __importStar(require("path-browserify"));
const script_1 = require("../codegen/script");
const style_1 = require("../codegen/style");
const template_1 = require("../codegen/template");
const compilerOptions_1 = require("../compilerOptions");
const scriptRanges_1 = require("../parsers/scriptRanges");
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
const vueCompilerOptions_1 = require("../parsers/vueCompilerOptions");
const signals_1 = require("../utils/signals");
exports.tsCodegen = new WeakMap();
const validLangs = new Set(['js', 'jsx', 'ts', 'tsx']);
const plugin = ({ modules: { typescript: ts }, vueCompilerOptions, }) => {
return {
version: 2.2,
getEmbeddedCodes(_fileName, sfc) {
const lang = computeLang(sfc);
return [{ lang, id: 'script_' + lang }];
},
resolveEmbeddedCode(fileName, sfc, embeddedFile) {
if (/script_(js|jsx|ts|tsx)/.test(embeddedFile.id)) {
let codegen = exports.tsCodegen.get(sfc);
if (!codegen) {
exports.tsCodegen.set(sfc, codegen = useCodegen(ts, vueCompilerOptions, fileName, sfc));
}
const generatedScript = codegen.getGeneratedScript();
embeddedFile.content = [...generatedScript.codes];
}
},
};
function computeLang(sfc) {
let lang = sfc.scriptSetup?.lang ?? sfc.script?.lang;
if (sfc.script && sfc.scriptSetup) {
if (sfc.scriptSetup.lang !== 'js') {
lang = sfc.scriptSetup.lang;
}
else {
lang = sfc.script.lang;
}
}
if (lang && validLangs.has(lang)) {
return lang;
}
return 'ts';
}
};
exports.default = plugin;
function useCodegen(ts, vueCompilerOptions, fileName, sfc) {
const getResolvedOptions = (0, alien_signals_1.computed)(() => {
const options = (0, vueCompilerOptions_1.parseVueCompilerOptions)(sfc.comments);
if (options) {
const resolver = new compilerOptions_1.CompilerOptionsResolver(ts, () => undefined /* does not support resolving target="auto" */);
resolver.addConfig(options, path.dirname(fileName));
return resolver.build(vueCompilerOptions);
}
return vueCompilerOptions;
});
const getScriptRanges = (0, alien_signals_1.computed)(() => sfc.script && validLangs.has(sfc.script.lang)
? (0, scriptRanges_1.parseScriptRanges)(ts, sfc.script.ast, getResolvedOptions())
: undefined);
const getScriptSetupRanges = (0, alien_signals_1.computed)(() => sfc.scriptSetup && validLangs.has(sfc.scriptSetup.lang)
? (0, scriptSetupRanges_1.parseScriptSetupRanges)(ts, sfc.scriptSetup.ast, getResolvedOptions())
: undefined);
const getImportedComponents = (0, signals_1.computedSet)(() => {
const names = new Set();
const scriptSetupRanges = getScriptSetupRanges();
if (sfc.scriptSetup && scriptSetupRanges) {
for (const range of scriptSetupRanges.components) {
names.add(sfc.scriptSetup.content.slice(range.start, range.end));
}
const scriptRange = getScriptRanges();
if (sfc.script && scriptRange) {
for (const range of scriptRange.components) {
names.add(sfc.script.content.slice(range.start, range.end));
}
}
}
return names;
});
const getSetupConsts = (0, signals_1.computedSet)(() => {
const scriptSetupRanges = getScriptSetupRanges();
const names = new Set([
...scriptSetupRanges?.defineProps?.destructured?.keys() ?? [],
...getImportedComponents(),
]);
const rest = scriptSetupRanges?.defineProps?.destructuredRest;
if (rest) {
names.add(rest);
}
return names;
});
const getSetupRefs = (0, signals_1.computedSet)(() => {
return new Set(getScriptSetupRanges()?.useTemplateRef
.map(({ name }) => name)
.filter(name => name !== undefined));
});
const hasDefineSlots = (0, alien_signals_1.computed)(() => !!getScriptSetupRanges()?.defineSlots);
const getSetupPropsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineProps?.name);
const getSetupSlotsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineSlots?.name);
const getInheritAttrs = (0, alien_signals_1.computed)(() => {
const value = getScriptSetupRanges()?.defineOptions?.inheritAttrs
?? getScriptRanges()?.exportDefault?.options?.inheritAttrs;
return value !== 'false';
});
const getComponentName = (0, alien_signals_1.computed)(() => {
let name;
const componentOptions = getScriptRanges()?.exportDefault?.options;
if (sfc.script && componentOptions?.name) {
name = sfc.script.content.slice(componentOptions.name.start + 1, componentOptions.name.end - 1);
}
else {
const { defineOptions } = getScriptSetupRanges() ?? {};
if (sfc.scriptSetup && defineOptions?.name) {
name = defineOptions.name;
}
else {
const baseName = path.basename(fileName);
name = baseName.slice(0, baseName.lastIndexOf('.'));
}
}
return (0, shared_1.capitalize)((0, shared_1.camelize)(name));
});
const getGeneratedTemplate = (0, alien_signals_1.computed)(() => {
if (getResolvedOptions().skipTemplateCodegen || !sfc.template) {
return;
}
return (0, template_1.generateTemplate)({
typescript: ts,
vueCompilerOptions: getResolvedOptions(),
template: sfc.template,
componentName: getComponentName(),
setupConsts: getSetupConsts(),
setupRefs: getSetupRefs(),
hasDefineSlots: hasDefineSlots(),
propsAssignName: getSetupPropsAssignName(),
slotsAssignName: getSetupSlotsAssignName(),
inheritAttrs: getInheritAttrs(),
});
});
const getGeneratedStyle = (0, alien_signals_1.computed)(() => {
if (!sfc.styles.length) {
return;
}
return (0, style_1.generateStyle)({
typescript: ts,
vueCompilerOptions: getResolvedOptions(),
styles: sfc.styles,
setupConsts: getSetupConsts(),
setupRefs: getSetupRefs(),
});
});
const getSetupExposed = (0, signals_1.computedSet)(() => {
const allVars = new Set();
const scriptSetupRanges = getScriptSetupRanges();
if (!sfc.scriptSetup || !scriptSetupRanges) {
return allVars;
}
for (const range of scriptSetupRanges.bindings) {
const name = sfc.scriptSetup.content.slice(range.start, range.end);
allVars.add(name);
}
const scriptRanges = getScriptRanges();
if (sfc.script && scriptRanges) {
for (const range of scriptRanges.bindings) {
const name = sfc.script.content.slice(range.start, range.end);
allVars.add(name);
}
}
if (!allVars.size) {
return allVars;
}
const exposedNames = new Set();
const generatedTemplate = getGeneratedTemplate();
const generatedStyle = getGeneratedStyle();
for (const [name] of generatedTemplate?.componentAccessMap ?? []) {
if (allVars.has(name)) {
exposedNames.add(name);
}
}
for (const [name] of generatedStyle?.componentAccessMap ?? []) {
if (allVars.has(name)) {
exposedNames.add(name);
}
}
for (const component of sfc.template?.ast?.components ?? []) {
const testNames = new Set([(0, shared_1.camelize)(component), (0, shared_1.capitalize)((0, shared_1.camelize)(component))]);
for (const testName of testNames) {
if (allVars.has(testName)) {
exposedNames.add(testName);
}
}
}
return exposedNames;
});
const getGeneratedScript = (0, alien_signals_1.computed)(() => {
return (0, script_1.generateScript)({
vueCompilerOptions: getResolvedOptions(),
fileName,
script: sfc.script,
scriptSetup: sfc.scriptSetup,
exposed: getSetupExposed(),
scriptRanges: getScriptRanges(),
scriptSetupRanges: getScriptSetupRanges(),
templateAndStyleTypes: new Set([
...getGeneratedTemplate()?.generatedTypes ?? [],
...getGeneratedStyle()?.generatedTypes ?? [],
]),
templateAndStyleCodes: [
...getGeneratedStyle()?.codes ?? [],
...getGeneratedTemplate()?.codes ?? [],
],
});
});
return {
getScriptRanges,
getScriptSetupRanges,
getGeneratedScript,
getGeneratedTemplate,
getImportedComponents,
getSetupExposed,
};
}
//# sourceMappingURL=vue-tsx.js.map