@vue/language-core 1.9.0-alpha.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -9
- package/out/generators/script.d.ts +0 -15
- package/out/generators/script.js +0 -887
- package/out/generators/template.d.ts +0 -21
- package/out/generators/template.js +0 -1506
- package/out/index.d.ts +0 -16
- package/out/index.js +0 -33
- package/out/languageModule.d.ts +0 -10
- package/out/languageModule.js +0 -99
- package/out/parsers/scriptRanges.d.ts +0 -16
- package/out/parsers/scriptRanges.js +0 -58
- package/out/parsers/scriptSetupRanges.d.ts +0 -49
- package/out/parsers/scriptSetupRanges.js +0 -291
- package/out/plugins/file-html.d.ts +0 -4
- package/out/plugins/file-html.js +0 -81
- package/out/plugins/file-md.d.ts +0 -4
- package/out/plugins/file-md.js +0 -71
- package/out/plugins/file-vue.d.ts +0 -4
- package/out/plugins/file-vue.js +0 -40
- package/out/plugins/vue-sfc-customblocks.d.ts +0 -4
- package/out/plugins/vue-sfc-customblocks.js +0 -33
- package/out/plugins/vue-sfc-scripts.d.ts +0 -4
- package/out/plugins/vue-sfc-scripts.js +0 -42
- package/out/plugins/vue-sfc-styles.d.ts +0 -4
- package/out/plugins/vue-sfc-styles.js +0 -33
- package/out/plugins/vue-sfc-template.d.ts +0 -4
- package/out/plugins/vue-sfc-template.js +0 -29
- package/out/plugins/vue-template-html.d.ts +0 -4
- package/out/plugins/vue-template-html.js +0 -169
- package/out/plugins/vue-tsx.d.ts +0 -73
- package/out/plugins/vue-tsx.js +0 -159
- package/out/plugins.d.ts +0 -25
- package/out/plugins.js +0 -58
- package/out/types.d.ts +0 -125
- package/out/types.js +0 -3
- package/out/utils/globalTypes.d.ts +0 -4
- package/out/utils/globalTypes.js +0 -135
- package/out/utils/parseCssClassNames.d.ts +0 -5
- package/out/utils/parseCssClassNames.js +0 -19
- package/out/utils/parseCssVars.d.ts +0 -6
- package/out/utils/parseCssVars.js +0 -28
- package/out/utils/parseSfc.d.ts +0 -3
- package/out/utils/parseSfc.js +0 -135
- package/out/utils/shared.d.ts +0 -4
- package/out/utils/shared.js +0 -20
- package/out/utils/transform.d.ts +0 -9
- package/out/utils/transform.js +0 -195
- package/out/utils/ts.d.ts +0 -9
- package/out/utils/ts.js +0 -237
- package/out/utils/vue2TemplateCompiler.d.ts +0 -3
- package/out/utils/vue2TemplateCompiler.js +0 -86
- package/out/virtualFile/computedFiles.d.ts +0 -4
- package/out/virtualFile/computedFiles.js +0 -204
- package/out/virtualFile/computedMappings.d.ts +0 -6
- package/out/virtualFile/computedMappings.js +0 -39
- package/out/virtualFile/computedSfc.d.ts +0 -5
- package/out/virtualFile/computedSfc.js +0 -197
- package/out/virtualFile/computedVueSfc.d.ts +0 -5
- package/out/virtualFile/computedVueSfc.js +0 -41
- package/out/virtualFile/embeddedFile.d.ts +0 -13
- package/out/virtualFile/embeddedFile.js +0 -16
- package/out/virtualFile/vueFile.d.ts +0 -28
- package/out/virtualFile/vueFile.js +0 -53
package/out/plugins/vue-tsx.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tsCodegen = void 0;
|
|
4
|
-
const computeds_1 = require("computeds");
|
|
5
|
-
const script_1 = require("../generators/script");
|
|
6
|
-
const template_1 = require("../generators/template");
|
|
7
|
-
const scriptRanges_1 = require("../parsers/scriptRanges");
|
|
8
|
-
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
|
|
9
|
-
const language_core_1 = require("@volar/language-core");
|
|
10
|
-
const muggle = require("muggle-string");
|
|
11
|
-
const templateFormatReg = /^\.template_format\.ts$/;
|
|
12
|
-
const templateStyleCssReg = /^\.template_style\.css$/;
|
|
13
|
-
exports.tsCodegen = new WeakMap();
|
|
14
|
-
const plugin = (ctx) => {
|
|
15
|
-
return {
|
|
16
|
-
version: 1,
|
|
17
|
-
requiredCompilerOptions: [
|
|
18
|
-
'noPropertyAccessFromIndexSignature',
|
|
19
|
-
'exactOptionalPropertyTypes',
|
|
20
|
-
],
|
|
21
|
-
getEmbeddedFileNames(fileName, sfc) {
|
|
22
|
-
const tsx = useTsx(fileName, sfc);
|
|
23
|
-
const fileNames = [];
|
|
24
|
-
if (['js', 'ts', 'jsx', 'tsx'].includes(tsx.lang())) {
|
|
25
|
-
fileNames.push(fileName + '.' + tsx.lang());
|
|
26
|
-
}
|
|
27
|
-
if (sfc.template) {
|
|
28
|
-
fileNames.push(fileName + '.template_format.ts');
|
|
29
|
-
fileNames.push(fileName + '.template_style.css');
|
|
30
|
-
}
|
|
31
|
-
return fileNames;
|
|
32
|
-
},
|
|
33
|
-
resolveEmbeddedFile(fileName, sfc, embeddedFile) {
|
|
34
|
-
const _tsx = useTsx(fileName, sfc);
|
|
35
|
-
const suffix = embeddedFile.fileName.replace(fileName, '');
|
|
36
|
-
if (suffix === '.' + _tsx.lang()) {
|
|
37
|
-
embeddedFile.kind = language_core_1.FileKind.TypeScriptHostFile;
|
|
38
|
-
embeddedFile.capabilities = {
|
|
39
|
-
...language_core_1.FileCapabilities.full,
|
|
40
|
-
foldingRange: false,
|
|
41
|
-
documentFormatting: false,
|
|
42
|
-
documentSymbol: false,
|
|
43
|
-
};
|
|
44
|
-
const tsx = _tsx.generatedScript();
|
|
45
|
-
if (tsx) {
|
|
46
|
-
const [content, contentStacks] = ctx.codegenStack ? muggle.track([...tsx.codes], [...tsx.codeStacks]) : [[...tsx.codes], [...tsx.codeStacks]];
|
|
47
|
-
embeddedFile.content = content;
|
|
48
|
-
embeddedFile.contentStacks = contentStacks;
|
|
49
|
-
embeddedFile.mirrorBehaviorMappings = [...tsx.mirrorBehaviorMappings];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else if (suffix.match(templateFormatReg)) {
|
|
53
|
-
embeddedFile.parentFileName = fileName + '.template.' + sfc.template?.lang;
|
|
54
|
-
embeddedFile.kind = language_core_1.FileKind.TextFile;
|
|
55
|
-
embeddedFile.capabilities = {
|
|
56
|
-
...language_core_1.FileCapabilities.full,
|
|
57
|
-
diagnostic: false,
|
|
58
|
-
foldingRange: false,
|
|
59
|
-
codeAction: false,
|
|
60
|
-
inlayHint: false,
|
|
61
|
-
};
|
|
62
|
-
const template = _tsx.generatedTemplate();
|
|
63
|
-
if (template) {
|
|
64
|
-
const [content, contentStacks] = ctx.codegenStack
|
|
65
|
-
? muggle.track([...template.formatCodes], [...template.formatCodeStacks])
|
|
66
|
-
: [[...template.formatCodes], [...template.formatCodeStacks]];
|
|
67
|
-
embeddedFile.content = content;
|
|
68
|
-
embeddedFile.contentStacks = contentStacks;
|
|
69
|
-
}
|
|
70
|
-
for (const style of sfc.styles) {
|
|
71
|
-
embeddedFile.content.push('\n\n');
|
|
72
|
-
for (const cssVar of style.cssVars) {
|
|
73
|
-
embeddedFile.content.push('(');
|
|
74
|
-
embeddedFile.content.push([
|
|
75
|
-
cssVar.text,
|
|
76
|
-
style.name,
|
|
77
|
-
cssVar.offset,
|
|
78
|
-
{},
|
|
79
|
-
]);
|
|
80
|
-
embeddedFile.content.push(');\n');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else if (suffix.match(templateStyleCssReg)) {
|
|
85
|
-
embeddedFile.parentFileName = fileName + '.template.' + sfc.template?.lang;
|
|
86
|
-
const template = _tsx.generatedTemplate();
|
|
87
|
-
if (template) {
|
|
88
|
-
const [content, contentStacks] = ctx.codegenStack
|
|
89
|
-
? muggle.track([...template.cssCodes], [...template.cssCodeStacks])
|
|
90
|
-
: [[...template.cssCodes], [...template.cssCodeStacks]];
|
|
91
|
-
embeddedFile.content = content;
|
|
92
|
-
embeddedFile.contentStacks = contentStacks;
|
|
93
|
-
}
|
|
94
|
-
// for color pickers support
|
|
95
|
-
embeddedFile.capabilities.documentSymbol = true;
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
function useTsx(fileName, sfc) {
|
|
100
|
-
if (!exports.tsCodegen.has(sfc)) {
|
|
101
|
-
exports.tsCodegen.set(sfc, createTsx(fileName, sfc, ctx));
|
|
102
|
-
}
|
|
103
|
-
return exports.tsCodegen.get(sfc);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
exports.default = plugin;
|
|
107
|
-
function createTsx(fileName, _sfc, { vueCompilerOptions, compilerOptions, codegenStack, modules }) {
|
|
108
|
-
const ts = modules.typescript;
|
|
109
|
-
const lang = (0, computeds_1.computed)(() => {
|
|
110
|
-
return !_sfc.script && !_sfc.scriptSetup ? 'ts'
|
|
111
|
-
: _sfc.scriptSetup && _sfc.scriptSetup.lang !== 'js' ? _sfc.scriptSetup.lang
|
|
112
|
-
: _sfc.script && _sfc.script.lang !== 'js' ? _sfc.script.lang
|
|
113
|
-
: 'js';
|
|
114
|
-
});
|
|
115
|
-
const scriptRanges = (0, computeds_1.computed)(() => _sfc.script
|
|
116
|
-
? (0, scriptRanges_1.parseScriptRanges)(ts, _sfc.script.ast, !!_sfc.scriptSetup, false)
|
|
117
|
-
: undefined);
|
|
118
|
-
const scriptSetupRanges = (0, computeds_1.computed)(() => _sfc.scriptSetup
|
|
119
|
-
? (0, scriptSetupRanges_1.parseScriptSetupRanges)(ts, _sfc.scriptSetup.ast, vueCompilerOptions)
|
|
120
|
-
: undefined);
|
|
121
|
-
const shouldGenerateScopedClasses = (0, computeds_1.computed)(() => {
|
|
122
|
-
const option = vueCompilerOptions.experimentalResolveStyleCssClasses;
|
|
123
|
-
return _sfc.styles.some(s => {
|
|
124
|
-
return option === 'always' || (option === 'scoped' && s.scoped);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
const stylesScopedClasses = (0, computeds_1.computedSet)(() => {
|
|
128
|
-
const classes = new Set();
|
|
129
|
-
if (!shouldGenerateScopedClasses()) {
|
|
130
|
-
return classes;
|
|
131
|
-
}
|
|
132
|
-
for (const style of _sfc.styles) {
|
|
133
|
-
const option = vueCompilerOptions.experimentalResolveStyleCssClasses;
|
|
134
|
-
if (option === 'always' || (option === 'scoped' && style.scoped)) {
|
|
135
|
-
for (const className of style.classNames) {
|
|
136
|
-
classes.add(className.text.substring(1));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return classes;
|
|
141
|
-
});
|
|
142
|
-
const generatedTemplate = (0, computeds_1.computed)(() => {
|
|
143
|
-
if (!_sfc.template)
|
|
144
|
-
return;
|
|
145
|
-
return (0, template_1.generate)(ts, compilerOptions, vueCompilerOptions, _sfc.template, shouldGenerateScopedClasses(), stylesScopedClasses(), hasScriptSetupSlots(), slotsAssignName(), propsAssignName(), codegenStack);
|
|
146
|
-
});
|
|
147
|
-
const hasScriptSetupSlots = (0, computeds_1.computed)(() => !!scriptSetupRanges()?.slots.define);
|
|
148
|
-
const slotsAssignName = (0, computeds_1.computed)(() => scriptSetupRanges()?.slots.name);
|
|
149
|
-
const propsAssignName = (0, computeds_1.computed)(() => scriptSetupRanges()?.props.name);
|
|
150
|
-
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));
|
|
151
|
-
return {
|
|
152
|
-
scriptRanges,
|
|
153
|
-
scriptSetupRanges,
|
|
154
|
-
lang,
|
|
155
|
-
generatedScript,
|
|
156
|
-
generatedTemplate,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
//# sourceMappingURL=vue-tsx.js.map
|
package/out/plugins.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import { VueCompilerOptions } from './types';
|
|
3
|
-
import * as CompilerDOM from '@vue/compiler-dom';
|
|
4
|
-
export declare function getDefaultVueLanguagePlugins(ts: typeof import('typescript/lib/tsserverlibrary'), compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, codegenStack: boolean): {
|
|
5
|
-
version: 1;
|
|
6
|
-
name?: string | undefined;
|
|
7
|
-
order?: number | undefined;
|
|
8
|
-
requiredCompilerOptions?: string[] | undefined;
|
|
9
|
-
parseSFC?(fileName: string, content: string): import("@vue/compiler-sfc").SFCParseResult | undefined;
|
|
10
|
-
updateSFC?(oldResult: import("@vue/compiler-sfc").SFCParseResult, textChange: {
|
|
11
|
-
start: number;
|
|
12
|
-
end: number;
|
|
13
|
-
newText: string;
|
|
14
|
-
}): import("@vue/compiler-sfc").SFCParseResult | undefined;
|
|
15
|
-
resolveTemplateCompilerOptions?(options: CompilerDOM.CompilerOptions): CompilerDOM.CompilerOptions;
|
|
16
|
-
compileSFCTemplate?(lang: string, template: string, options: CompilerDOM.CompilerOptions): CompilerDOM.CodegenResult | undefined;
|
|
17
|
-
updateSFCTemplate?(oldResult: CompilerDOM.CodegenResult, textChange: {
|
|
18
|
-
start: number;
|
|
19
|
-
end: number;
|
|
20
|
-
newText: string;
|
|
21
|
-
}): CompilerDOM.CodegenResult | undefined;
|
|
22
|
-
getEmbeddedFileNames?(fileName: string, sfc: import("./types").Sfc): string[];
|
|
23
|
-
resolveEmbeddedFile?(fileName: string, sfc: import("./types").Sfc, embeddedFile: import("./virtualFile/embeddedFile").VueEmbeddedFile): void;
|
|
24
|
-
}[];
|
|
25
|
-
//# sourceMappingURL=plugins.d.ts.map
|
package/out/plugins.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultVueLanguagePlugins = void 0;
|
|
4
|
-
const file_html_1 = require("./plugins/file-html");
|
|
5
|
-
const file_md_1 = require("./plugins/file-md");
|
|
6
|
-
const file_vue_1 = require("./plugins/file-vue");
|
|
7
|
-
const vue_sfc_customblocks_1 = require("./plugins/vue-sfc-customblocks");
|
|
8
|
-
const vue_sfc_scripts_1 = require("./plugins/vue-sfc-scripts");
|
|
9
|
-
const vue_sfc_styles_1 = require("./plugins/vue-sfc-styles");
|
|
10
|
-
const vue_sfc_template_1 = require("./plugins/vue-sfc-template");
|
|
11
|
-
const vue_template_html_1 = require("./plugins/vue-template-html");
|
|
12
|
-
const vue_tsx_1 = require("./plugins/vue-tsx");
|
|
13
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
14
|
-
const CompilerVue2 = require("./utils/vue2TemplateCompiler");
|
|
15
|
-
function getDefaultVueLanguagePlugins(ts, compilerOptions, vueCompilerOptions, codegenStack) {
|
|
16
|
-
const plugins = [
|
|
17
|
-
file_md_1.default,
|
|
18
|
-
file_html_1.default,
|
|
19
|
-
file_vue_1.default,
|
|
20
|
-
vue_template_html_1.default,
|
|
21
|
-
vue_sfc_styles_1.default,
|
|
22
|
-
vue_sfc_customblocks_1.default,
|
|
23
|
-
vue_sfc_scripts_1.default,
|
|
24
|
-
vue_sfc_template_1.default,
|
|
25
|
-
vue_tsx_1.default,
|
|
26
|
-
...vueCompilerOptions.plugins,
|
|
27
|
-
];
|
|
28
|
-
const pluginCtx = {
|
|
29
|
-
modules: {
|
|
30
|
-
'@vue/compiler-dom': vueCompilerOptions.target < 3
|
|
31
|
-
? {
|
|
32
|
-
...CompilerDOM,
|
|
33
|
-
compile: CompilerVue2.compile,
|
|
34
|
-
}
|
|
35
|
-
: CompilerDOM,
|
|
36
|
-
typescript: ts,
|
|
37
|
-
},
|
|
38
|
-
compilerOptions,
|
|
39
|
-
vueCompilerOptions,
|
|
40
|
-
codegenStack,
|
|
41
|
-
};
|
|
42
|
-
const pluginInstances = plugins
|
|
43
|
-
.map(plugin => plugin(pluginCtx))
|
|
44
|
-
.sort((a, b) => {
|
|
45
|
-
const aOrder = a.order ?? 0;
|
|
46
|
-
const bOrder = b.order ?? 0;
|
|
47
|
-
return aOrder - bOrder;
|
|
48
|
-
});
|
|
49
|
-
return pluginInstances.filter((plugin) => {
|
|
50
|
-
const valid = plugin.version >= 1 && plugin.version < 2;
|
|
51
|
-
if (!valid) {
|
|
52
|
-
console.warn(`Plugin ${JSON.stringify(plugin.name)} API version incompatible, expected 1.x but got ${JSON.stringify(plugin.version)}`);
|
|
53
|
-
}
|
|
54
|
-
return valid;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
exports.getDefaultVueLanguagePlugins = getDefaultVueLanguagePlugins;
|
|
58
|
-
//# sourceMappingURL=plugins.js.map
|
package/out/types.d.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import type * as CompilerDOM from '@vue/compiler-dom';
|
|
2
|
-
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
3
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
4
|
-
import type { VueEmbeddedFile } from './virtualFile/embeddedFile';
|
|
5
|
-
export type { SFCParseResult } from '@vue/compiler-sfc';
|
|
6
|
-
export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | 'plugins'>> & {
|
|
7
|
-
target?: 'auto' | 2 | 2.7 | 3 | 3.3;
|
|
8
|
-
plugins?: string[];
|
|
9
|
-
};
|
|
10
|
-
export interface VueCompilerOptions {
|
|
11
|
-
target: number;
|
|
12
|
-
lib: string;
|
|
13
|
-
extensions: string[];
|
|
14
|
-
jsxSlots: boolean;
|
|
15
|
-
strictTemplates: boolean;
|
|
16
|
-
skipTemplateCodegen: boolean;
|
|
17
|
-
nativeTags: string[];
|
|
18
|
-
dataAttributes: string[];
|
|
19
|
-
htmlAttributes: string[];
|
|
20
|
-
optionsWrapper: [string, string] | [];
|
|
21
|
-
macros: {
|
|
22
|
-
defineProps: string[];
|
|
23
|
-
defineSlots: string[];
|
|
24
|
-
defineEmits: string[];
|
|
25
|
-
defineExpose: string[];
|
|
26
|
-
defineModel: string[];
|
|
27
|
-
defineOptions: string[];
|
|
28
|
-
withDefaults: string[];
|
|
29
|
-
};
|
|
30
|
-
plugins: VueLanguagePlugin[];
|
|
31
|
-
hooks: string[];
|
|
32
|
-
experimentalDefinePropProposal: 'kevinEdition' | 'johnsonEdition' | false;
|
|
33
|
-
experimentalResolveStyleCssClasses: 'scoped' | 'always' | 'never';
|
|
34
|
-
experimentalModelPropName: Record<string, Record<string, boolean | Record<string, string> | Record<string, string>[]>>;
|
|
35
|
-
experimentalUseElementAccessInTemplate: boolean;
|
|
36
|
-
experimentalAdditionalLanguageModules: string[];
|
|
37
|
-
}
|
|
38
|
-
export type VueLanguagePlugin = (ctx: {
|
|
39
|
-
modules: {
|
|
40
|
-
typescript: typeof import('typescript/lib/tsserverlibrary');
|
|
41
|
-
'@vue/compiler-dom': typeof import('@vue/compiler-dom');
|
|
42
|
-
};
|
|
43
|
-
compilerOptions: ts.CompilerOptions;
|
|
44
|
-
vueCompilerOptions: VueCompilerOptions;
|
|
45
|
-
codegenStack: boolean;
|
|
46
|
-
}) => {
|
|
47
|
-
version: 1;
|
|
48
|
-
name?: string;
|
|
49
|
-
order?: number;
|
|
50
|
-
requiredCompilerOptions?: string[];
|
|
51
|
-
parseSFC?(fileName: string, content: string): SFCParseResult | undefined;
|
|
52
|
-
updateSFC?(oldResult: SFCParseResult, textChange: {
|
|
53
|
-
start: number;
|
|
54
|
-
end: number;
|
|
55
|
-
newText: string;
|
|
56
|
-
}): SFCParseResult | undefined;
|
|
57
|
-
resolveTemplateCompilerOptions?(options: CompilerDOM.CompilerOptions): CompilerDOM.CompilerOptions;
|
|
58
|
-
compileSFCTemplate?(lang: string, template: string, options: CompilerDOM.CompilerOptions): CompilerDOM.CodegenResult | undefined;
|
|
59
|
-
updateSFCTemplate?(oldResult: CompilerDOM.CodegenResult, textChange: {
|
|
60
|
-
start: number;
|
|
61
|
-
end: number;
|
|
62
|
-
newText: string;
|
|
63
|
-
}): CompilerDOM.CodegenResult | undefined;
|
|
64
|
-
getEmbeddedFileNames?(fileName: string, sfc: Sfc): string[];
|
|
65
|
-
resolveEmbeddedFile?(fileName: string, sfc: Sfc, embeddedFile: VueEmbeddedFile): void;
|
|
66
|
-
};
|
|
67
|
-
export interface SfcBlock {
|
|
68
|
-
name: string;
|
|
69
|
-
start: number;
|
|
70
|
-
end: number;
|
|
71
|
-
startTagEnd: number;
|
|
72
|
-
endTagStart: number;
|
|
73
|
-
lang: string;
|
|
74
|
-
content: string;
|
|
75
|
-
attrs: Record<string, string | true>;
|
|
76
|
-
}
|
|
77
|
-
export interface Sfc {
|
|
78
|
-
template: SfcBlock & {
|
|
79
|
-
ast: CompilerDOM.RootNode | undefined;
|
|
80
|
-
errors: CompilerDOM.CompilerError[];
|
|
81
|
-
warnings: CompilerDOM.CompilerError[];
|
|
82
|
-
} | undefined;
|
|
83
|
-
script: (SfcBlock & {
|
|
84
|
-
src: string | undefined;
|
|
85
|
-
srcOffset: number;
|
|
86
|
-
ast: ts.SourceFile;
|
|
87
|
-
}) | undefined;
|
|
88
|
-
scriptSetup: SfcBlock & {
|
|
89
|
-
generic: string | undefined;
|
|
90
|
-
genericOffset: number;
|
|
91
|
-
ast: ts.SourceFile;
|
|
92
|
-
} | undefined;
|
|
93
|
-
styles: readonly (SfcBlock & {
|
|
94
|
-
module: string | undefined;
|
|
95
|
-
scoped: boolean;
|
|
96
|
-
cssVars: {
|
|
97
|
-
text: string;
|
|
98
|
-
offset: number;
|
|
99
|
-
}[];
|
|
100
|
-
classNames: {
|
|
101
|
-
text: string;
|
|
102
|
-
offset: number;
|
|
103
|
-
}[];
|
|
104
|
-
})[];
|
|
105
|
-
customBlocks: readonly (SfcBlock & {
|
|
106
|
-
type: string;
|
|
107
|
-
})[];
|
|
108
|
-
/**
|
|
109
|
-
* @deprecated use `template.ast` instead
|
|
110
|
-
*/
|
|
111
|
-
templateAst: CompilerDOM.RootNode | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* @deprecated use `script.ast` instead
|
|
114
|
-
*/
|
|
115
|
-
scriptAst: ts.SourceFile | undefined;
|
|
116
|
-
/**
|
|
117
|
-
* @deprecated use `scriptSetup.ast` instead
|
|
118
|
-
*/
|
|
119
|
-
scriptSetupAst: ts.SourceFile | undefined;
|
|
120
|
-
}
|
|
121
|
-
export interface TextRange {
|
|
122
|
-
start: number;
|
|
123
|
-
end: number;
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=types.d.ts.map
|
package/out/types.js
DELETED
package/out/utils/globalTypes.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTypesCode = exports.baseName = void 0;
|
|
4
|
-
const shared_1 = require("./shared");
|
|
5
|
-
exports.baseName = '__VLS_types.d.ts';
|
|
6
|
-
function getTypesCode(vueCompilerOptions) {
|
|
7
|
-
return `
|
|
8
|
-
// @ts-nocheck
|
|
9
|
-
|
|
10
|
-
type __VLS_IntrinsicElements = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<JSX.IntrinsicElements, Record<string, any>>>;
|
|
11
|
-
type __VLS_Element = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.Element, JSX.Element>;
|
|
12
|
-
|
|
13
|
-
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
|
|
14
|
-
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
15
|
-
|
|
16
|
-
type __VLS_Prettify<T> = { [K in keyof T]: T[K]; } & {};
|
|
17
|
-
|
|
18
|
-
type __VLS_OmitKeepDiscriminatedUnion<T, K extends keyof any> =
|
|
19
|
-
T extends any
|
|
20
|
-
? Pick<T, Exclude<keyof T, K>>
|
|
21
|
-
: never;
|
|
22
|
-
|
|
23
|
-
type __VLS_GlobalComponents =
|
|
24
|
-
__VLS_PickNotAny<import('vue').GlobalComponents, {}>
|
|
25
|
-
& __VLS_PickNotAny<import('@vue/runtime-core').GlobalComponents, {}>
|
|
26
|
-
& __VLS_PickNotAny<import('@vue/runtime-dom').GlobalComponents, {}>
|
|
27
|
-
& Pick<typeof import('${vueCompilerOptions.lib}'),
|
|
28
|
-
'Transition'
|
|
29
|
-
| 'TransitionGroup'
|
|
30
|
-
| 'KeepAlive'
|
|
31
|
-
| 'Suspense'
|
|
32
|
-
| 'Teleport'
|
|
33
|
-
>;
|
|
34
|
-
|
|
35
|
-
declare const __VLS_intrinsicElements: __VLS_IntrinsicElements;
|
|
36
|
-
|
|
37
|
-
// v-for
|
|
38
|
-
declare function __VLS_getVForSourceType(source: number): [number, number, number][];
|
|
39
|
-
declare function __VLS_getVForSourceType(source: string): [string, number, number][];
|
|
40
|
-
declare function __VLS_getVForSourceType<T extends any[]>(source: T): [
|
|
41
|
-
T[number], // item
|
|
42
|
-
number, // key
|
|
43
|
-
number, // index
|
|
44
|
-
][];
|
|
45
|
-
declare function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
|
|
46
|
-
T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never, // item
|
|
47
|
-
number, // key
|
|
48
|
-
undefined, // index
|
|
49
|
-
][];
|
|
50
|
-
declare function __VLS_getVForSourceType<T>(source: T): [
|
|
51
|
-
T[keyof T], // item
|
|
52
|
-
keyof T, // key
|
|
53
|
-
number, // index
|
|
54
|
-
][];
|
|
55
|
-
|
|
56
|
-
declare function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
|
|
57
|
-
declare function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
|
|
58
|
-
declare function __VLS_directiveFunction<T>(dir: T):
|
|
59
|
-
T extends import('${vueCompilerOptions.lib}').ObjectDirective<infer E, infer V> | import('${vueCompilerOptions.lib}').FunctionDirective<infer E, infer V> ? (value: V) => void
|
|
60
|
-
: T;
|
|
61
|
-
declare function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
|
|
62
|
-
declare function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
|
|
63
|
-
|
|
64
|
-
type __VLS_SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {};
|
|
65
|
-
type __VLS_WithComponent<N0 extends string, LocalComponents, N1 extends string, N2 extends string, N3 extends string> =
|
|
66
|
-
N1 extends keyof LocalComponents ? N1 extends N0 ? Pick<LocalComponents, N0> : { [K in N0]: LocalComponents[N1] } :
|
|
67
|
-
N2 extends keyof LocalComponents ? N2 extends N0 ? Pick<LocalComponents, N0> : { [K in N0]: LocalComponents[N2] } :
|
|
68
|
-
N3 extends keyof LocalComponents ? N3 extends N0 ? Pick<LocalComponents, N0> : { [K in N0]: LocalComponents[N3] } :
|
|
69
|
-
N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0> : { [K in N0]: __VLS_GlobalComponents[N1] } :
|
|
70
|
-
N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0> : { [K in N0]: __VLS_GlobalComponents[N2] } :
|
|
71
|
-
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0> : { [K in N0]: __VLS_GlobalComponents[N3] } :
|
|
72
|
-
${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: unknown }'}
|
|
73
|
-
|
|
74
|
-
type __VLS_FillingEventArg_ParametersLength<E extends (...args: any) => any> = __VLS_IsAny<Parameters<E>> extends true ? -1 : Parameters<E>['length'];
|
|
75
|
-
type __VLS_FillingEventArg<E> = E extends (...args: any) => any ? __VLS_FillingEventArg_ParametersLength<E> extends 0 ? ($event?: undefined) => ReturnType<E> : E : E;
|
|
76
|
-
declare function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
|
|
77
|
-
T extends new (...args: any) => any
|
|
78
|
-
? (props: (K extends { $props: infer Props } ? Props : any)${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: {
|
|
79
|
-
attrs?: any,
|
|
80
|
-
slots?: K extends { ${(0, shared_1.getSlotsPropertyName)(vueCompilerOptions.target)}: infer Slots } ? Slots : any,
|
|
81
|
-
emit?: K extends { $emit: infer Emit } ? Emit : any
|
|
82
|
-
}) => JSX.Element & { __ctx?: typeof ctx & { props?: typeof props; expose?(exposed: K): void; } }
|
|
83
|
-
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
|
|
84
|
-
: T extends (...args: any) => any ? T
|
|
85
|
-
: (_: {}${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'} } };
|
|
86
|
-
declare function __VLS_elementAsFunctionalComponent<T>(t: T): (_: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'} } };
|
|
87
|
-
declare function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
|
|
88
|
-
declare function __VLS_pickEvent<E1, E2>(emitEvent: E1, propEvent: E2): __VLS_FillingEventArg<
|
|
89
|
-
__VLS_PickNotAny<
|
|
90
|
-
__VLS_AsFunctionOrAny<E2>,
|
|
91
|
-
__VLS_AsFunctionOrAny<E1>
|
|
92
|
-
>
|
|
93
|
-
> | undefined;
|
|
94
|
-
declare function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): __VLS_PickNotAny<
|
|
95
|
-
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any
|
|
96
|
-
, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
|
|
97
|
-
>;
|
|
98
|
-
type __VLS_FunctionalComponentProps<T, K> =
|
|
99
|
-
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
|
|
100
|
-
: T extends (props: infer P, ...args: any) => any ? P :
|
|
101
|
-
{};
|
|
102
|
-
type __VLS_AsFunctionOrAny<F> = unknown extends F ? any : ((...args: any) => any) extends F ? F : any;
|
|
103
|
-
|
|
104
|
-
declare function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* emit
|
|
108
|
-
*/
|
|
109
|
-
// fix https://github.com/vuejs/language-tools/issues/926
|
|
110
|
-
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
|
|
111
|
-
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
|
|
112
|
-
? U extends T
|
|
113
|
-
? never
|
|
114
|
-
: __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R)
|
|
115
|
-
: never;
|
|
116
|
-
type __VLS_OverloadUnion<T> = Exclude<
|
|
117
|
-
__VLS_OverloadUnionInner<(() => never) & T>,
|
|
118
|
-
T extends () => never ? never : () => never
|
|
119
|
-
>;
|
|
120
|
-
type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F
|
|
121
|
-
? F extends (event: infer E, ...args: infer A) => any
|
|
122
|
-
? { [K in E & string]: (...args: A) => void; }
|
|
123
|
-
: never
|
|
124
|
-
: never;
|
|
125
|
-
type __VLS_NormalizeEmits<T> = __VLS_Prettify<
|
|
126
|
-
__VLS_UnionToIntersection<
|
|
127
|
-
__VLS_ConstructorOverloads<T> & {
|
|
128
|
-
[K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never
|
|
129
|
-
}
|
|
130
|
-
>
|
|
131
|
-
>;
|
|
132
|
-
`.trim();
|
|
133
|
-
}
|
|
134
|
-
exports.getTypesCode = getTypesCode;
|
|
135
|
-
//# sourceMappingURL=globalTypes.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCssClassNames = void 0;
|
|
4
|
-
const parseCssVars_1 = require("./parseCssVars");
|
|
5
|
-
const cssClassNameReg = /(?=([\.]{1}[a-zA-Z_]+[\w\_\-]*)[\s\.\+\{\>#\:]{1})/g;
|
|
6
|
-
function* parseCssClassNames(styleContent) {
|
|
7
|
-
styleContent = (0, parseCssVars_1.clearComments)(styleContent);
|
|
8
|
-
const matches = styleContent.matchAll(cssClassNameReg);
|
|
9
|
-
for (const match of matches) {
|
|
10
|
-
if (match.index !== undefined) {
|
|
11
|
-
const matchText = match[1];
|
|
12
|
-
if (matchText !== undefined) {
|
|
13
|
-
yield { offset: match.index, text: matchText };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.parseCssClassNames = parseCssClassNames;
|
|
19
|
-
//# sourceMappingURL=parseCssClassNames.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/cssVars.ts#L47-L61
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearComments = exports.parseCssVars = void 0;
|
|
5
|
-
const vBindCssVarReg = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^)]*))\s*\)/g;
|
|
6
|
-
const commentReg1 = /\/\*([\s\S]*?)\*\//g;
|
|
7
|
-
const commentReg2 = /\/\/([\s\S]*?)\n/g;
|
|
8
|
-
function* parseCssVars(styleContent) {
|
|
9
|
-
styleContent = clearComments(styleContent);
|
|
10
|
-
const matchs = styleContent.matchAll(vBindCssVarReg);
|
|
11
|
-
for (const match of matchs) {
|
|
12
|
-
if (match.index !== undefined) {
|
|
13
|
-
const matchText = match[1] ?? match[2] ?? match[3];
|
|
14
|
-
if (matchText !== undefined) {
|
|
15
|
-
const offset = match.index + styleContent.slice(match.index).indexOf(matchText);
|
|
16
|
-
yield { offset, text: matchText };
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.parseCssVars = parseCssVars;
|
|
22
|
-
function clearComments(css) {
|
|
23
|
-
return css
|
|
24
|
-
.replace(commentReg1, match => `/*${' '.repeat(match.length - 4)}*/`)
|
|
25
|
-
.replace(commentReg2, match => `//${' '.repeat(match.length - 3)}\n`);
|
|
26
|
-
}
|
|
27
|
-
exports.clearComments = clearComments;
|
|
28
|
-
//# sourceMappingURL=parseCssVars.js.map
|
package/out/utils/parseSfc.d.ts
DELETED