@vue/language-core 2.1.8 → 2.1.10
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/lib/codegen/globalTypes.js +1 -3
- package/lib/codegen/script/componentSelf.js +2 -1
- package/lib/codegen/script/index.d.ts +1 -1
- package/lib/codegen/script/index.js +6 -1
- package/lib/codegen/script/scriptSetup.js +14 -10
- package/lib/codegen/script/styleModulesType.js +1 -1
- package/lib/codegen/script/template.js +4 -2
- package/lib/parsers/scriptSetupRanges.d.ts +3 -1
- package/lib/parsers/scriptSetupRanges.js +4 -1
- package/lib/plugins/vue-tsx.d.ts +3 -1
- package/lib/plugins/vue-tsx.js +1 -2
- package/lib/virtualFile/computedSfc.js +1 -1
- package/package.json +2 -2
- package/lib/codegen/types.d.ts +0 -9
- package/lib/codegen/types.js +0 -3
|
@@ -88,9 +88,7 @@ function generateGlobalTypes(lib, target, strictTemplates) {
|
|
|
88
88
|
function __VLS_getVForSourceType(source: number): [number, number, number][];
|
|
89
89
|
function __VLS_getVForSourceType(source: string): [string, number, number][];
|
|
90
90
|
function __VLS_getVForSourceType<T extends any[]>(source: T): [
|
|
91
|
-
item:
|
|
92
|
-
target >= 2.7 ? `import('${lib}').UnwrapNestedRefs<T[number]>` :
|
|
93
|
-
`T[number]`)},
|
|
91
|
+
item: T[number],
|
|
94
92
|
key: number,
|
|
95
93
|
index: number,
|
|
96
94
|
][];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateComponentSelf = generateComponentSelf;
|
|
4
|
+
const path = require("path-browserify");
|
|
4
5
|
const common_1 = require("../common");
|
|
5
6
|
const component_1 = require("./component");
|
|
6
7
|
const index_1 = require("./index");
|
|
@@ -54,7 +55,7 @@ function* generateComponentSelf(options, ctx, templateCodegenCtx) {
|
|
|
54
55
|
yield `})${common_1.endOfLine}`; // defineComponent {
|
|
55
56
|
}
|
|
56
57
|
else if (options.sfc.script) {
|
|
57
|
-
yield `let __VLS_self!: typeof import('./${options.
|
|
58
|
+
yield `let __VLS_self!: typeof import('./${path.basename(options.fileName)}').default${common_1.endOfLine}`;
|
|
58
59
|
}
|
|
59
60
|
else {
|
|
60
61
|
yield `const __VLS_self = (await import('${options.vueCompilerOptions.lib}')).defineComponent({})${common_1.endOfLine}`;
|
|
@@ -13,7 +13,7 @@ export declare const codeFeatures: {
|
|
|
13
13
|
navigationWithoutRename: VueCodeInformation;
|
|
14
14
|
};
|
|
15
15
|
export interface ScriptCodegenOptions {
|
|
16
|
-
|
|
16
|
+
fileName: string;
|
|
17
17
|
ts: typeof ts;
|
|
18
18
|
compilerOptions: ts.CompilerOptions;
|
|
19
19
|
vueCompilerOptions: VueCompilerOptions;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.codeFeatures = void 0;
|
|
4
4
|
exports.generateScript = generateScript;
|
|
5
5
|
exports.generateScriptSectionPartiallyEnding = generateScriptSectionPartiallyEnding;
|
|
6
|
+
const path = require("path-browserify");
|
|
6
7
|
const common_1 = require("../common");
|
|
7
8
|
const globalTypes_1 = require("../globalTypes");
|
|
8
9
|
const componentSelf_1 = require("./componentSelf");
|
|
@@ -38,7 +39,11 @@ function* generateScript(options) {
|
|
|
38
39
|
if (options.vueCompilerOptions.__setupedGlobalTypes) {
|
|
39
40
|
const globalTypes = options.vueCompilerOptions.__setupedGlobalTypes;
|
|
40
41
|
if (typeof globalTypes === 'object') {
|
|
41
|
-
|
|
42
|
+
let relativePath = path.relative(path.dirname(options.fileName), globalTypes.absolutePath);
|
|
43
|
+
if (relativePath !== globalTypes.absolutePath && !relativePath.startsWith('./') && !relativePath.startsWith('../')) {
|
|
44
|
+
relativePath = './' + relativePath;
|
|
45
|
+
}
|
|
46
|
+
yield `/// <reference types="${relativePath}" />${common_1.newLine}`;
|
|
42
47
|
}
|
|
43
48
|
else {
|
|
44
49
|
yield `/// <reference types=".vue-global-types/${options.vueCompilerOptions.lib}_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}.d.ts" />${common_1.newLine}`;
|
|
@@ -156,27 +156,31 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
if (scriptSetupRanges.cssModules.length) {
|
|
159
|
-
for (const { define
|
|
159
|
+
for (const { define } of scriptSetupRanges.cssModules) {
|
|
160
160
|
setupCodeModifies.push([
|
|
161
|
-
|
|
161
|
+
[`(`],
|
|
162
|
+
define.start,
|
|
163
|
+
define.start
|
|
164
|
+
], [
|
|
165
|
+
define.arg ? [
|
|
162
166
|
` as Omit<__VLS_StyleModules, '$style'>[`,
|
|
163
|
-
(0, common_1.generateSfcBlockSection)(scriptSetup, arg.start, arg.end, index_1.codeFeatures.all),
|
|
164
|
-
`]`
|
|
167
|
+
(0, common_1.generateSfcBlockSection)(scriptSetup, define.arg.start, define.arg.end, index_1.codeFeatures.all),
|
|
168
|
+
`])`
|
|
165
169
|
] : [
|
|
166
170
|
` as __VLS_StyleModules[`,
|
|
167
|
-
['', scriptSetup.name, exp.start, index_1.codeFeatures.verification],
|
|
171
|
+
['', scriptSetup.name, define.exp.start, index_1.codeFeatures.verification],
|
|
168
172
|
`'$style'`,
|
|
169
|
-
['', scriptSetup.name, exp.end, index_1.codeFeatures.verification],
|
|
170
|
-
`]`
|
|
173
|
+
['', scriptSetup.name, define.exp.end, index_1.codeFeatures.verification],
|
|
174
|
+
`])`
|
|
171
175
|
],
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
define.end,
|
|
177
|
+
define.end
|
|
174
178
|
]);
|
|
175
179
|
}
|
|
176
180
|
}
|
|
177
181
|
const isTs = options.lang !== 'js' && options.lang !== 'jsx';
|
|
178
182
|
for (const { define } of scriptSetupRanges.templateRefs) {
|
|
179
|
-
if (!define
|
|
183
|
+
if (!define.arg) {
|
|
180
184
|
continue;
|
|
181
185
|
}
|
|
182
186
|
if (isTs) {
|
|
@@ -6,7 +6,7 @@ const template_1 = require("./template");
|
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
function* generateStyleModulesType(options, ctx) {
|
|
8
8
|
const styles = options.sfc.styles.map((style, i) => [style, i]).filter(([style]) => style.module);
|
|
9
|
-
if (!styles.length) {
|
|
9
|
+
if (!styles.length && !options.scriptSetupRanges?.cssModules.length) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
yield `type __VLS_StyleModules = {${common_1.newLine}`;
|
|
@@ -4,6 +4,7 @@ exports.generateTemplateDirectives = generateTemplateDirectives;
|
|
|
4
4
|
exports.generateTemplate = generateTemplate;
|
|
5
5
|
exports.generateCssClassProperty = generateCssClassProperty;
|
|
6
6
|
exports.getTemplateUsageVars = getTemplateUsageVars;
|
|
7
|
+
const path = require("path-browserify");
|
|
7
8
|
const shared_1 = require("../../utils/shared");
|
|
8
9
|
const common_1 = require("../common");
|
|
9
10
|
const context_1 = require("../template/context");
|
|
@@ -13,7 +14,7 @@ const index_1 = require("./index");
|
|
|
13
14
|
function* generateTemplateCtx(options) {
|
|
14
15
|
const exps = [];
|
|
15
16
|
exps.push(`{} as InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>`);
|
|
16
|
-
if (options.vueCompilerOptions.petiteVueExtensions.some(ext => options.
|
|
17
|
+
if (options.vueCompilerOptions.petiteVueExtensions.some(ext => options.fileName.endsWith(ext))) {
|
|
17
18
|
exps.push(`globalThis`);
|
|
18
19
|
}
|
|
19
20
|
if (options.sfc.styles.some(style => style.module)) {
|
|
@@ -51,7 +52,8 @@ function* generateTemplateComponents(options) {
|
|
|
51
52
|
nameType = options.sfc.script.content.substring(nameOption.start, nameOption.end);
|
|
52
53
|
}
|
|
53
54
|
else if (options.sfc.scriptSetup) {
|
|
54
|
-
|
|
55
|
+
const baseName = path.basename(options.fileName);
|
|
56
|
+
nameType = `'${options.scriptSetupRanges?.options.name ?? baseName.substring(0, baseName.lastIndexOf('.'))}'`;
|
|
55
57
|
}
|
|
56
58
|
if (nameType) {
|
|
57
59
|
exps.push(`{} as {
|
|
@@ -207,7 +207,10 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
else if (vueCompilerOptions.macros.defineSlots.includes(callText)) {
|
|
210
|
-
slots.define =
|
|
210
|
+
slots.define = {
|
|
211
|
+
...parseDefineFunction(node),
|
|
212
|
+
statement: getStatementRange(ts, parents, node, ast)
|
|
213
|
+
};
|
|
211
214
|
if (ts.isVariableDeclaration(parent)) {
|
|
212
215
|
if (ts.isIdentifier(parent.name)) {
|
|
213
216
|
slots.name = getNodeText(ts, parent.name, ast);
|
package/lib/plugins/vue-tsx.d.ts
CHANGED
|
@@ -42,7 +42,9 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
42
42
|
exp: import("../types").TextRange;
|
|
43
43
|
arg?: import("../types").TextRange;
|
|
44
44
|
typeArg?: import("../types").TextRange;
|
|
45
|
-
}
|
|
45
|
+
}> & {
|
|
46
|
+
statement: import("../types").TextRange;
|
|
47
|
+
};
|
|
46
48
|
};
|
|
47
49
|
emits: {
|
|
48
50
|
name?: string;
|
package/lib/plugins/vue-tsx.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tsCodegen = void 0;
|
|
4
4
|
const alien_signals_1 = require("alien-signals");
|
|
5
|
-
const path_browserify_1 = require("path-browserify");
|
|
6
5
|
const script_1 = require("../codegen/script");
|
|
7
6
|
const template_1 = require("../codegen/template");
|
|
8
7
|
const scriptRanges_1 = require("../parsers/scriptRanges");
|
|
@@ -148,7 +147,7 @@ function createTsx(fileName, _sfc, ctx, appendGlobalTypes) {
|
|
|
148
147
|
let generatedLength = 0;
|
|
149
148
|
const codegen = (0, script_1.generateScript)({
|
|
150
149
|
ts,
|
|
151
|
-
|
|
150
|
+
fileName,
|
|
152
151
|
sfc: _sfc,
|
|
153
152
|
lang: lang.get(),
|
|
154
153
|
scriptRanges: scriptRanges.get(),
|
|
@@ -6,7 +6,7 @@ const parseCssClassNames_1 = require("../utils/parseCssClassNames");
|
|
|
6
6
|
const parseCssVars_1 = require("../utils/parseCssVars");
|
|
7
7
|
function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
8
8
|
const untrackedSnapshot = () => {
|
|
9
|
-
const prevTrackId = alien_signals_1.System.activeTrackId
|
|
9
|
+
const prevTrackId = alien_signals_1.System.activeTrackId;
|
|
10
10
|
alien_signals_1.System.activeTrackId = 0;
|
|
11
11
|
const res = snapshot.get();
|
|
12
12
|
alien_signals_1.System.activeTrackId = prevTrackId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"optional": true
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "b0af30caee2f8dfb1a8393c1b400f38e31fa4883"
|
|
41
41
|
}
|
package/lib/codegen/types.d.ts
DELETED
package/lib/codegen/types.js
DELETED