@vue/language-core 1.9.0-alpha.3 → 2.0.1
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/index.d.ts +13 -0
- package/{out/index.js → index.js} +12 -14
- package/lib/generators/script.d.ts +13 -0
- package/lib/generators/script.js +1060 -0
- package/lib/generators/template.d.ts +9 -0
- package/lib/generators/template.js +1567 -0
- package/lib/generators/utils.d.ts +6 -0
- package/lib/generators/utils.js +58 -0
- package/lib/languageModule.d.ts +5 -0
- package/lib/languageModule.js +114 -0
- package/{out → lib}/parsers/scriptRanges.d.ts +2 -3
- package/{out → lib}/parsers/scriptRanges.js +11 -6
- package/{out → lib}/parsers/scriptSetupRanges.d.ts +17 -9
- package/{out → lib}/parsers/scriptSetupRanges.js +42 -35
- package/lib/plugins/file-html.d.ts +3 -0
- package/{out → lib}/plugins/file-html.js +1 -1
- package/lib/plugins/file-md.d.ts +3 -0
- package/{out → lib}/plugins/file-md.js +8 -8
- package/lib/plugins/file-vue.d.ts +3 -0
- package/{out → lib}/plugins/file-vue.js +9 -2
- package/lib/plugins/vue-sfc-customblocks.d.ts +3 -0
- package/lib/plugins/vue-sfc-customblocks.js +28 -0
- package/lib/plugins/vue-sfc-scripts.d.ts +3 -0
- package/lib/plugins/vue-sfc-scripts.js +36 -0
- package/lib/plugins/vue-sfc-styles.d.ts +3 -0
- package/lib/plugins/vue-sfc-styles.js +28 -0
- package/lib/plugins/vue-sfc-template.d.ts +3 -0
- package/lib/plugins/vue-sfc-template.js +29 -0
- package/lib/plugins/vue-template-html.d.ts +3 -0
- package/{out → lib}/plugins/vue-template-html.js +12 -12
- package/{out → lib}/plugins/vue-tsx.d.ts +25 -18
- package/lib/plugins/vue-tsx.js +212 -0
- package/{out → lib}/plugins.d.ts +19 -7
- package/{out → lib}/plugins.js +24 -18
- package/{out → lib}/types.d.ts +26 -9
- package/lib/types.js +5 -0
- package/{out → lib}/utils/parseCssClassNames.d.ts +0 -1
- package/{out → lib}/utils/parseCssVars.d.ts +0 -1
- package/{out → lib}/utils/parseSfc.d.ts +0 -1
- package/{out → lib}/utils/parseSfc.js +4 -18
- package/{out → lib}/utils/shared.d.ts +0 -1
- package/lib/utils/transform.d.ts +8 -0
- package/{out → lib}/utils/transform.js +62 -62
- package/{out → lib}/utils/ts.d.ts +3 -4
- package/{out → lib}/utils/ts.js +0 -12
- package/lib/utils/vue2TemplateCompiler.d.ts +2 -0
- package/{out → lib}/utils/vue2TemplateCompiler.js +5 -2
- package/{out → lib}/virtualFile/computedFiles.d.ts +2 -3
- package/{out → lib}/virtualFile/computedFiles.js +55 -42
- package/lib/virtualFile/computedMappings.d.ts +4 -0
- package/{out → lib}/virtualFile/computedMappings.js +9 -12
- package/lib/virtualFile/computedSfc.d.ts +4 -0
- package/{out → lib}/virtualFile/computedSfc.js +3 -3
- package/{out → lib}/virtualFile/computedVueSfc.d.ts +2 -3
- package/lib/virtualFile/embeddedFile.d.ts +12 -0
- package/lib/virtualFile/embeddedFile.js +15 -0
- package/lib/virtualFile/vueFile.d.ts +25 -0
- package/{out → lib}/virtualFile/vueFile.js +11 -21
- package/package.json +8 -11
- 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/languageModule.d.ts +0 -10
- package/out/languageModule.js +0 -99
- package/out/plugins/file-html.d.ts +0 -4
- package/out/plugins/file-md.d.ts +0 -4
- package/out/plugins/file-vue.d.ts +0 -4
- 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-tsx.js +0 -159
- package/out/types.js +0 -3
- package/out/utils/globalTypes.d.ts +0 -4
- package/out/utils/globalTypes.js +0 -135
- package/out/utils/transform.d.ts +0 -9
- package/out/utils/vue2TemplateCompiler.d.ts +0 -3
- package/out/virtualFile/computedMappings.d.ts +0 -6
- package/out/virtualFile/computedSfc.d.ts +0 -5
- 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 → lib}/utils/parseCssClassNames.js +0 -0
- /package/{out → lib}/utils/parseCssVars.js +0 -0
- /package/{out → lib}/utils/shared.js +0 -0
- /package/{out → lib}/virtualFile/computedVueSfc.js +0 -0
package/out/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from './generators/template';
|
|
2
|
-
export * from './languageModule';
|
|
3
|
-
export * from './parsers/scriptSetupRanges';
|
|
4
|
-
export * from './plugins';
|
|
5
|
-
export * from './virtualFile/vueFile';
|
|
6
|
-
export * from './types';
|
|
7
|
-
export * from './utils/ts';
|
|
8
|
-
export * from './utils/parseSfc';
|
|
9
|
-
export * as scriptRanges from './parsers/scriptRanges';
|
|
10
|
-
export * as sharedTypes from './utils/globalTypes';
|
|
11
|
-
export * from './utils/shared';
|
|
12
|
-
export { tsCodegen } from './plugins/vue-tsx';
|
|
13
|
-
export * from '@volar/language-core';
|
|
14
|
-
export * from '@volar/source-map';
|
|
15
|
-
export type * as CompilerDOM from '@vue/compiler-dom';
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
package/out/languageModule.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Language } from '@volar/language-core';
|
|
2
|
-
import { VueFile } from './virtualFile/vueFile';
|
|
3
|
-
import { VueCompilerOptions } from './types';
|
|
4
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
5
|
-
export declare function createVueLanguage(ts: typeof import('typescript/lib/tsserverlibrary'), compilerOptions?: ts.CompilerOptions, _vueCompilerOptions?: Partial<VueCompilerOptions>, codegenStack?: boolean): Language<VueFile>;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated planed to remove in 2.0, please use createVueLanguage instead of
|
|
8
|
-
*/
|
|
9
|
-
export declare function createLanguages(ts: typeof import('typescript/lib/tsserverlibrary'), compilerOptions?: ts.CompilerOptions, vueCompilerOptions?: Partial<VueCompilerOptions>, codegenStack?: boolean): Language[];
|
|
10
|
-
//# sourceMappingURL=languageModule.d.ts.map
|
package/out/languageModule.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLanguages = exports.createVueLanguage = void 0;
|
|
4
|
-
const path = require("path-browserify");
|
|
5
|
-
const plugins_1 = require("./plugins");
|
|
6
|
-
const vueFile_1 = require("./virtualFile/vueFile");
|
|
7
|
-
const sharedTypes = require("./utils/globalTypes");
|
|
8
|
-
const ts_1 = require("./utils/ts");
|
|
9
|
-
const fileRegistries = [];
|
|
10
|
-
function getVueFileRegistry(key, plugins) {
|
|
11
|
-
let fileRegistry = fileRegistries.find(r => r.key === key
|
|
12
|
-
&& r.plugins.length === plugins.length
|
|
13
|
-
&& r.plugins.every(plugin => plugins.includes(plugin)))?.files;
|
|
14
|
-
if (!fileRegistry) {
|
|
15
|
-
fileRegistry = new Map();
|
|
16
|
-
fileRegistries.push({
|
|
17
|
-
key: key,
|
|
18
|
-
plugins: plugins,
|
|
19
|
-
files: fileRegistry,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return fileRegistry;
|
|
23
|
-
}
|
|
24
|
-
function createVueLanguage(ts, compilerOptions = {}, _vueCompilerOptions = {}, codegenStack = false) {
|
|
25
|
-
const vueCompilerOptions = (0, ts_1.resolveVueCompilerOptions)(_vueCompilerOptions);
|
|
26
|
-
const plugins = (0, plugins_1.getDefaultVueLanguagePlugins)(ts, compilerOptions, vueCompilerOptions, codegenStack);
|
|
27
|
-
const keys = [
|
|
28
|
-
...Object.keys(vueCompilerOptions)
|
|
29
|
-
.sort()
|
|
30
|
-
.filter(key => key !== 'plugins')
|
|
31
|
-
.map(key => [key, vueCompilerOptions[key]]),
|
|
32
|
-
[...new Set(plugins.map(plugin => plugin.requiredCompilerOptions ?? []).flat())]
|
|
33
|
-
.sort()
|
|
34
|
-
.map(key => [key, compilerOptions[key]]),
|
|
35
|
-
];
|
|
36
|
-
const fileRegistry = getVueFileRegistry(JSON.stringify(keys), _vueCompilerOptions.plugins ?? []);
|
|
37
|
-
const allowLanguageIds = new Set(['vue']);
|
|
38
|
-
if (vueCompilerOptions.extensions.includes('.md')) {
|
|
39
|
-
allowLanguageIds.add('markdown');
|
|
40
|
-
}
|
|
41
|
-
if (vueCompilerOptions.extensions.includes('.html')) {
|
|
42
|
-
allowLanguageIds.add('html');
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
createVirtualFile(fileName, snapshot, languageId) {
|
|
46
|
-
if ((languageId && allowLanguageIds.has(languageId))
|
|
47
|
-
|| (!languageId && vueCompilerOptions.extensions.some(ext => fileName.endsWith(ext)))) {
|
|
48
|
-
if (fileRegistry.has(fileName)) {
|
|
49
|
-
const reusedVueFile = fileRegistry.get(fileName);
|
|
50
|
-
reusedVueFile.update(snapshot);
|
|
51
|
-
return reusedVueFile;
|
|
52
|
-
}
|
|
53
|
-
const vueFile = new vueFile_1.VueFile(fileName, snapshot, vueCompilerOptions, plugins, ts, codegenStack);
|
|
54
|
-
fileRegistry.set(fileName, vueFile);
|
|
55
|
-
return vueFile;
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
updateVirtualFile(sourceFile, snapshot) {
|
|
59
|
-
sourceFile.update(snapshot);
|
|
60
|
-
},
|
|
61
|
-
resolveHost(host) {
|
|
62
|
-
const sharedTypesSnapshot = ts.ScriptSnapshot.fromString(sharedTypes.getTypesCode(vueCompilerOptions));
|
|
63
|
-
const sharedTypesFileName = path.join(host.rootPath, sharedTypes.baseName);
|
|
64
|
-
return {
|
|
65
|
-
...host,
|
|
66
|
-
resolveModuleName(moduleName, impliedNodeFormat) {
|
|
67
|
-
if (impliedNodeFormat === ts.ModuleKind.ESNext && vueCompilerOptions.extensions.some(ext => moduleName.endsWith(ext))) {
|
|
68
|
-
return `${moduleName}.js`;
|
|
69
|
-
}
|
|
70
|
-
return host.resolveModuleName?.(moduleName, impliedNodeFormat) ?? moduleName;
|
|
71
|
-
},
|
|
72
|
-
getScriptFileNames() {
|
|
73
|
-
return [
|
|
74
|
-
sharedTypesFileName,
|
|
75
|
-
...host.getScriptFileNames(),
|
|
76
|
-
];
|
|
77
|
-
},
|
|
78
|
-
getScriptSnapshot(fileName) {
|
|
79
|
-
if (fileName === sharedTypesFileName) {
|
|
80
|
-
return sharedTypesSnapshot;
|
|
81
|
-
}
|
|
82
|
-
return host.getScriptSnapshot(fileName);
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
exports.createVueLanguage = createVueLanguage;
|
|
89
|
-
/**
|
|
90
|
-
* @deprecated planed to remove in 2.0, please use createVueLanguage instead of
|
|
91
|
-
*/
|
|
92
|
-
function createLanguages(ts, compilerOptions = {}, vueCompilerOptions = {}, codegenStack = false) {
|
|
93
|
-
return [
|
|
94
|
-
createVueLanguage(ts, compilerOptions, vueCompilerOptions, codegenStack),
|
|
95
|
-
...vueCompilerOptions.experimentalAdditionalLanguageModules?.map(module => require(module)) ?? [],
|
|
96
|
-
];
|
|
97
|
-
}
|
|
98
|
-
exports.createLanguages = createLanguages;
|
|
99
|
-
//# sourceMappingURL=languageModule.js.map
|
package/out/plugins/file-md.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const language_core_1 = require("@volar/language-core");
|
|
4
|
-
const customBlockReg = /^(.*)\.customBlock_([^_]+)_(\d+)\.([^.]+)$/;
|
|
5
|
-
const plugin = () => {
|
|
6
|
-
return {
|
|
7
|
-
version: 1,
|
|
8
|
-
getEmbeddedFileNames(fileName, sfc) {
|
|
9
|
-
const names = [];
|
|
10
|
-
for (let i = 0; i < sfc.customBlocks.length; i++) {
|
|
11
|
-
const customBlock = sfc.customBlocks[i];
|
|
12
|
-
names.push(fileName + '.customBlock_' + customBlock.type + '_' + i + '.' + customBlock.lang);
|
|
13
|
-
}
|
|
14
|
-
return names;
|
|
15
|
-
},
|
|
16
|
-
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
|
|
17
|
-
const match = embeddedFile.fileName.match(customBlockReg);
|
|
18
|
-
if (match) {
|
|
19
|
-
const index = parseInt(match[3]);
|
|
20
|
-
const customBlock = sfc.customBlocks[index];
|
|
21
|
-
embeddedFile.capabilities = language_core_1.FileCapabilities.full;
|
|
22
|
-
embeddedFile.content.push([
|
|
23
|
-
customBlock.content,
|
|
24
|
-
customBlock.name,
|
|
25
|
-
0,
|
|
26
|
-
language_core_1.FileRangeCapabilities.full,
|
|
27
|
-
]);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.default = plugin;
|
|
33
|
-
//# sourceMappingURL=vue-sfc-customblocks.js.map
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const language_core_1 = require("@volar/language-core");
|
|
4
|
-
const scriptFormatReg = /^(.*)\.script_format\.([^.]+)$/;
|
|
5
|
-
const scriptSetupFormatReg = /^(.*)\.scriptSetup_format\.([^.]+)$/;
|
|
6
|
-
const plugin = () => {
|
|
7
|
-
return {
|
|
8
|
-
version: 1,
|
|
9
|
-
getEmbeddedFileNames(fileName, sfc) {
|
|
10
|
-
const names = [];
|
|
11
|
-
if (sfc.script) {
|
|
12
|
-
names.push(fileName + '.script_format.' + sfc.script.lang);
|
|
13
|
-
}
|
|
14
|
-
if (sfc.scriptSetup) {
|
|
15
|
-
names.push(fileName + '.scriptSetup_format.' + sfc.scriptSetup.lang);
|
|
16
|
-
}
|
|
17
|
-
return names;
|
|
18
|
-
},
|
|
19
|
-
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
|
|
20
|
-
const scriptMatch = embeddedFile.fileName.match(scriptFormatReg);
|
|
21
|
-
const scriptSetupMatch = embeddedFile.fileName.match(scriptSetupFormatReg);
|
|
22
|
-
const script = scriptMatch ? sfc.script : scriptSetupMatch ? sfc.scriptSetup : undefined;
|
|
23
|
-
if (script) {
|
|
24
|
-
embeddedFile.kind = language_core_1.FileKind.TextFile;
|
|
25
|
-
embeddedFile.capabilities = {
|
|
26
|
-
...language_core_1.FileCapabilities.full,
|
|
27
|
-
diagnostic: false,
|
|
28
|
-
codeAction: false,
|
|
29
|
-
inlayHint: false,
|
|
30
|
-
};
|
|
31
|
-
embeddedFile.content.push([
|
|
32
|
-
script.content,
|
|
33
|
-
script.name,
|
|
34
|
-
0,
|
|
35
|
-
{},
|
|
36
|
-
]);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
exports.default = plugin;
|
|
42
|
-
//# sourceMappingURL=vue-sfc-scripts.js.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const language_core_1 = require("@volar/language-core");
|
|
4
|
-
const styleReg = /^(.*)\.style_(\d+)\.([^.]+)$/;
|
|
5
|
-
const plugin = () => {
|
|
6
|
-
return {
|
|
7
|
-
version: 1,
|
|
8
|
-
getEmbeddedFileNames(fileName, sfc) {
|
|
9
|
-
const names = [];
|
|
10
|
-
for (let i = 0; i < sfc.styles.length; i++) {
|
|
11
|
-
const style = sfc.styles[i];
|
|
12
|
-
names.push(fileName + '.style_' + i + '.' + style.lang);
|
|
13
|
-
}
|
|
14
|
-
return names;
|
|
15
|
-
},
|
|
16
|
-
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
|
|
17
|
-
const match = embeddedFile.fileName.match(styleReg);
|
|
18
|
-
if (match) {
|
|
19
|
-
const index = parseInt(match[2]);
|
|
20
|
-
const style = sfc.styles[index];
|
|
21
|
-
embeddedFile.capabilities = language_core_1.FileCapabilities.full;
|
|
22
|
-
embeddedFile.content.push([
|
|
23
|
-
style.content,
|
|
24
|
-
style.name,
|
|
25
|
-
0,
|
|
26
|
-
language_core_1.FileRangeCapabilities.full,
|
|
27
|
-
]);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.default = plugin;
|
|
33
|
-
//# sourceMappingURL=vue-sfc-styles.js.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const language_core_1 = require("@volar/language-core");
|
|
4
|
-
const templateReg = /^(.*)\.template\.([^.]+)$/;
|
|
5
|
-
const plugin = () => {
|
|
6
|
-
return {
|
|
7
|
-
version: 1,
|
|
8
|
-
getEmbeddedFileNames(fileName, sfc) {
|
|
9
|
-
if (sfc.template) {
|
|
10
|
-
return [fileName + '.template.' + sfc.template.lang];
|
|
11
|
-
}
|
|
12
|
-
return [];
|
|
13
|
-
},
|
|
14
|
-
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
|
|
15
|
-
const match = embeddedFile.fileName.match(templateReg);
|
|
16
|
-
if (match && sfc.template) {
|
|
17
|
-
embeddedFile.capabilities = language_core_1.FileCapabilities.full;
|
|
18
|
-
embeddedFile.content.push([
|
|
19
|
-
sfc.template.content,
|
|
20
|
-
sfc.template.name,
|
|
21
|
-
0,
|
|
22
|
-
language_core_1.FileRangeCapabilities.full,
|
|
23
|
-
]);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
exports.default = plugin;
|
|
29
|
-
//# sourceMappingURL=vue-sfc-template.js.map
|
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/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
|
package/out/utils/transform.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import { VueCompilerOptions } from '../types';
|
|
3
|
-
export declare function walkInterpolationFragment(ts: typeof import('typescript/lib/tsserverlibrary'), code: string, ast: ts.SourceFile, cb: (fragment: string, offset: number | undefined, isJustForErrorMapping?: boolean) => void, localVars: Map<string, number>, identifiers: Set<string>, vueOptions: VueCompilerOptions): {
|
|
4
|
-
text: string;
|
|
5
|
-
isShorthand: boolean;
|
|
6
|
-
offset: number;
|
|
7
|
-
}[];
|
|
8
|
-
export declare function collectVars(ts: typeof import('typescript/lib/tsserverlibrary'), node: ts.Node, result: string[]): void;
|
|
9
|
-
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FileRangeCapabilities } from '@volar/language-core';
|
|
2
|
-
import { Mapping } from '@volar/source-map';
|
|
3
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
4
|
-
import { Sfc } from '../types';
|
|
5
|
-
export declare function computedMappings(snapshot: () => ts.IScriptSnapshot, sfc: Sfc): () => Mapping<FileRangeCapabilities>[];
|
|
6
|
-
//# sourceMappingURL=computedMappings.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
2
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
-
import { Sfc, VueLanguagePlugin } from '../types';
|
|
4
|
-
export declare function computedSfc(ts: typeof import('typescript/lib/tsserverlibrary'), plugins: ReturnType<VueLanguagePlugin>[], fileName: string, snapshot: () => ts.IScriptSnapshot, parsed: () => SFCParseResult | undefined): Sfc;
|
|
5
|
-
//# sourceMappingURL=computedSfc.d.ts.map
|