@vue/language-core 1.8.15 → 1.8.17
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/out/generators/script.js +27 -20
- package/out/generators/template.d.ts +1 -1
- package/out/generators/template.js +4 -1
- package/out/parsers/scriptSetupRanges.d.ts +1 -0
- package/out/parsers/scriptSetupRanges.js +5 -0
- package/out/plugins/vue-tsx.d.ts +1 -0
- package/out/plugins/vue-tsx.js +3 -1
- package/out/utils/globalTypes.js +2 -2
- package/package.json +5 -5
package/out/generators/script.js
CHANGED
|
@@ -55,6 +55,7 @@ function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htm
|
|
|
55
55
|
bindings: [],
|
|
56
56
|
emitsAssignName: undefined,
|
|
57
57
|
exposeRuntimeArg: undefined,
|
|
58
|
+
exposeTypeArg: undefined,
|
|
58
59
|
leadingCommentEndOffset: 0,
|
|
59
60
|
importSectionEndOffset: 0,
|
|
60
61
|
withDefaults: undefined,
|
|
@@ -356,10 +357,10 @@ function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htm
|
|
|
356
357
|
//#endregion
|
|
357
358
|
codes.push('return {} as {\n');
|
|
358
359
|
codes.push(`props: __VLS_Prettify<Omit<typeof __VLS_fnPropsDefineComponent & typeof __VLS_fnPropsTypeOnly, keyof typeof __VLS_defaultProps>> & typeof __VLS_fnPropsSlots & typeof __VLS_defaultProps,\n`);
|
|
359
|
-
codes.push(`expose(exposed: ${scriptSetupRanges.
|
|
360
|
+
codes.push(`expose(exposed: import('${vueCompilerOptions.lib}').ShallowUnwrapRef<${scriptSetupRanges.defineExpose ? 'typeof __VLS_exposed' : '{}'}>): void,\n`);
|
|
360
361
|
codes.push('attrs: any,\n');
|
|
361
362
|
codes.push('slots: ReturnType<typeof __VLS_template>,\n');
|
|
362
|
-
codes.push(
|
|
363
|
+
codes.push(`emit: typeof ${scriptSetupRanges.emitsAssignName ?? '__VLS_emit'},\n`);
|
|
363
364
|
codes.push('};\n');
|
|
364
365
|
codes.push('})(),\n');
|
|
365
366
|
codes.push(`) => ({} as import('${vueCompilerOptions.lib}').VNode & { __ctx?: Awaited<typeof __VLS_setup> }))`);
|
|
@@ -429,12 +430,11 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
429
430
|
const scriptSetupGeneratedOffset = muggle.getLength(codes) - scriptSetupRanges.importSectionEndOffset;
|
|
430
431
|
let setupCodeModifies = [];
|
|
431
432
|
if (scriptSetupRanges.defineProps && !scriptSetupRanges.propsAssignName) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
433
|
+
const ranges = scriptSetupRanges.withDefaults ?? scriptSetupRanges.defineProps;
|
|
434
|
+
codes.push(`const __VLS_props = `);
|
|
435
|
+
addVirtualCode('scriptSetup', ranges.start, ranges.end);
|
|
436
|
+
codes.push(`;\n`);
|
|
437
|
+
setupCodeModifies.push([() => codes.push(`__VLS_props`), ranges.start, ranges.end]);
|
|
438
438
|
}
|
|
439
439
|
if (scriptSetupRanges.defineSlots && !scriptSetupRanges.slotsAssignName) {
|
|
440
440
|
setupCodeModifies.push([() => codes.push(`const __VLS_slots = `), scriptSetupRanges.defineSlots.start, scriptSetupRanges.defineSlots.start]);
|
|
@@ -442,15 +442,22 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
442
442
|
if (scriptSetupRanges.defineEmits && !scriptSetupRanges.emitsAssignName) {
|
|
443
443
|
setupCodeModifies.push([() => codes.push(`const __VLS_emit = `), scriptSetupRanges.defineEmits.start, scriptSetupRanges.defineEmits.start]);
|
|
444
444
|
}
|
|
445
|
-
if (scriptSetupRanges.defineExpose
|
|
445
|
+
if (scriptSetupRanges.defineExpose) {
|
|
446
446
|
setupCodeModifies.push([() => {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
447
|
+
if (scriptSetupRanges?.exposeTypeArg) {
|
|
448
|
+
codes.push(`let __VLS_exposed!: `);
|
|
449
|
+
addExtraReferenceVirtualCode('scriptSetup', scriptSetupRanges.exposeTypeArg.start, scriptSetupRanges.exposeTypeArg.end);
|
|
450
|
+
codes.push(`;\n`);
|
|
451
|
+
}
|
|
452
|
+
else if (scriptSetupRanges?.exposeRuntimeArg) {
|
|
453
|
+
codes.push(`const __VLS_exposed = `);
|
|
454
|
+
addExtraReferenceVirtualCode('scriptSetup', scriptSetupRanges.exposeRuntimeArg.start, scriptSetupRanges.exposeRuntimeArg.end);
|
|
455
|
+
codes.push(`;\n`);
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
codes.push(`const __VLS_exposed = {};\n`);
|
|
459
|
+
}
|
|
460
|
+
}, scriptSetupRanges.defineExpose.start, scriptSetupRanges.defineExpose.start]);
|
|
454
461
|
}
|
|
455
462
|
setupCodeModifies = setupCodeModifies.sort((a, b) => a[1] - b[1]);
|
|
456
463
|
if (setupCodeModifies.length) {
|
|
@@ -546,14 +553,11 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
546
553
|
codes.push(`setup() {\n`);
|
|
547
554
|
codes.push(`return {\n`);
|
|
548
555
|
generateSetupReturns();
|
|
549
|
-
if (scriptSetupRanges.
|
|
556
|
+
if (scriptSetupRanges.defineExpose) {
|
|
550
557
|
codes.push(`...__VLS_exposed,\n`);
|
|
551
558
|
}
|
|
552
559
|
codes.push(`};\n`);
|
|
553
560
|
codes.push(`},\n`);
|
|
554
|
-
if (scriptRanges?.exportDefault?.args) {
|
|
555
|
-
addVirtualCode('script', scriptRanges.exportDefault.args.start + 1, scriptRanges.exportDefault.args.end - 1);
|
|
556
|
-
}
|
|
557
561
|
codes.push(`})`);
|
|
558
562
|
}
|
|
559
563
|
function generateComponentOptions(functional) {
|
|
@@ -595,6 +599,9 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
595
599
|
codes.push(`emits: ({} as __VLS_NormalizeEmits<typeof `, scriptSetupRanges.emitsAssignName ?? '__VLS_emit', `>),\n`);
|
|
596
600
|
}
|
|
597
601
|
}
|
|
602
|
+
if (scriptRanges?.exportDefault?.args) {
|
|
603
|
+
addVirtualCode('script', scriptRanges.exportDefault.args.start + 1, scriptRanges.exportDefault.args.end - 1);
|
|
604
|
+
}
|
|
598
605
|
}
|
|
599
606
|
function generateSetupReturns() {
|
|
600
607
|
if (scriptSetupRanges && bypassDefineComponent) {
|
|
@@ -5,7 +5,7 @@ import * as muggle from 'muggle-string';
|
|
|
5
5
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
6
6
|
import { Sfc, VueCompilerOptions } from '../types';
|
|
7
7
|
type Code = Segment<FileRangeCapabilities>;
|
|
8
|
-
export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, sourceTemplate: string, sourceLang: string, sfc: Sfc, hasScriptSetupSlots: boolean, slotsAssignName: string | undefined, codegenStack: boolean): {
|
|
8
|
+
export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, sourceTemplate: string, sourceLang: string, sfc: Sfc, hasScriptSetupSlots: boolean, slotsAssignName: string | undefined, propsAssignName: string | undefined, codegenStack: boolean): {
|
|
9
9
|
codes: Code[];
|
|
10
10
|
codeStacks: muggle.StackNode[];
|
|
11
11
|
formatCodes: Code[];
|
|
@@ -84,7 +84,7 @@ const transformContext = {
|
|
|
84
84
|
},
|
|
85
85
|
expressionPlugins: ['typescript'],
|
|
86
86
|
};
|
|
87
|
-
function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourceLang, sfc, hasScriptSetupSlots, slotsAssignName, codegenStack) {
|
|
87
|
+
function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourceLang, sfc, hasScriptSetupSlots, slotsAssignName, propsAssignName, codegenStack) {
|
|
88
88
|
const nativeTags = new Set(vueCompilerOptions.nativeTags);
|
|
89
89
|
const [codes, codeStacks] = codegenStack ? muggle.track([]) : [[], []];
|
|
90
90
|
const [formatCodes, formatCodeStacks] = codegenStack ? muggle.track([]) : [[], []];
|
|
@@ -104,6 +104,9 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
104
104
|
let ignoreStart;
|
|
105
105
|
let expectedErrorStart;
|
|
106
106
|
let expectedErrorNode;
|
|
107
|
+
if (propsAssignName) {
|
|
108
|
+
localVars[propsAssignName] = 1;
|
|
109
|
+
}
|
|
107
110
|
generatePreResolveComponents();
|
|
108
111
|
if (sfc.templateAst) {
|
|
109
112
|
visitNode(sfc.templateAst, undefined, undefined, undefined);
|
|
@@ -18,6 +18,7 @@ export declare function parseScriptSetupRanges(ts: typeof import('typescript/lib
|
|
|
18
18
|
slotsAssignName: string | undefined;
|
|
19
19
|
emitsAssignName: string | undefined;
|
|
20
20
|
exposeRuntimeArg: TextRange | undefined;
|
|
21
|
+
exposeTypeArg: TextRange | undefined;
|
|
21
22
|
defineProp: {
|
|
22
23
|
name: TextRange | undefined;
|
|
23
24
|
nameIsString: boolean;
|
|
@@ -16,6 +16,7 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
16
16
|
let slotsAssignName;
|
|
17
17
|
let emitsAssignName;
|
|
18
18
|
let exposeRuntimeArg;
|
|
19
|
+
let exposeTypeArg;
|
|
19
20
|
const definePropProposalA = vueCompilerOptions.experimentalDefinePropProposal === 'kevinEdition' || ast.getFullText().trimStart().startsWith('// @experimentalDefinePropProposal=kevinEdition');
|
|
20
21
|
const definePropProposalB = vueCompilerOptions.experimentalDefinePropProposal === 'johnsonEdition' || ast.getFullText().trimStart().startsWith('// @experimentalDefinePropProposal=johnsonEdition');
|
|
21
22
|
const defineProp = [];
|
|
@@ -58,6 +59,7 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
58
59
|
slotsAssignName,
|
|
59
60
|
emitsAssignName,
|
|
60
61
|
exposeRuntimeArg,
|
|
62
|
+
exposeTypeArg,
|
|
61
63
|
defineProp,
|
|
62
64
|
};
|
|
63
65
|
function _getStartEnd(node) {
|
|
@@ -159,6 +161,9 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
159
161
|
if (node.arguments.length) {
|
|
160
162
|
exposeRuntimeArg = _getStartEnd(node.arguments[0]);
|
|
161
163
|
}
|
|
164
|
+
if (node.typeArguments?.length) {
|
|
165
|
+
exposeTypeArg = _getStartEnd(node.typeArguments[0]);
|
|
166
|
+
}
|
|
162
167
|
}
|
|
163
168
|
else if (vueCompilerOptions.macros.defineProps.includes(callText)) {
|
|
164
169
|
defineProps = _getStartEnd(node);
|
package/out/plugins/vue-tsx.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
28
28
|
slotsAssignName: string | undefined;
|
|
29
29
|
emitsAssignName: string | undefined;
|
|
30
30
|
exposeRuntimeArg: import("../types").TextRange | undefined;
|
|
31
|
+
exposeTypeArg: import("../types").TextRange | undefined;
|
|
31
32
|
defineProp: {
|
|
32
33
|
name: import("../types").TextRange | undefined;
|
|
33
34
|
nameIsString: boolean;
|
package/out/plugins/vue-tsx.js
CHANGED
|
@@ -138,15 +138,17 @@ function createTsx(fileName, _sfc, { vueCompilerOptions, compilerOptions, codege
|
|
|
138
138
|
const htmlGen = (0, reactivity_1.computed)(() => {
|
|
139
139
|
if (!_sfc.templateAst)
|
|
140
140
|
return;
|
|
141
|
-
return templateGen.generate(ts, compilerOptions, vueCompilerOptions, _sfc.template?.content ?? '', _sfc.template?.lang ?? 'html', _sfc, hasScriptSetupSlots.value, slotsAssignName.value, codegenStack);
|
|
141
|
+
return templateGen.generate(ts, compilerOptions, vueCompilerOptions, _sfc.template?.content ?? '', _sfc.template?.lang ?? 'html', _sfc, hasScriptSetupSlots.value, slotsAssignName.value, propsAssignName.value, codegenStack);
|
|
142
142
|
});
|
|
143
143
|
//#region remove when https://github.com/vuejs/core/pull/5912 merged
|
|
144
144
|
const hasScriptSetupSlots = (0, reactivity_1.shallowRef)(false);
|
|
145
145
|
const slotsAssignName = (0, reactivity_1.shallowRef)();
|
|
146
|
+
const propsAssignName = (0, reactivity_1.shallowRef)();
|
|
146
147
|
//#endregion
|
|
147
148
|
const tsxGen = (0, reactivity_1.computed)(() => {
|
|
148
149
|
hasScriptSetupSlots.value = !!scriptSetupRanges.value?.defineSlots;
|
|
149
150
|
slotsAssignName.value = scriptSetupRanges.value?.slotsAssignName;
|
|
151
|
+
propsAssignName.value = scriptSetupRanges.value?.propsAssignName;
|
|
150
152
|
return (0, script_1.generate)(ts, fileName, _sfc, lang.value, scriptRanges.value, scriptSetupRanges.value, htmlGen.value, compilerOptions, vueCompilerOptions, codegenStack);
|
|
151
153
|
});
|
|
152
154
|
return {
|
package/out/utils/globalTypes.js
CHANGED
|
@@ -111,8 +111,8 @@ type __VLS_OverloadUnion<T> = Exclude<
|
|
|
111
111
|
T extends () => never ? never : () => never
|
|
112
112
|
>;
|
|
113
113
|
type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F
|
|
114
|
-
? F extends (event: infer E, ...args: infer A) =>
|
|
115
|
-
? { [K in E
|
|
114
|
+
? F extends (event: infer E, ...args: infer A) => any
|
|
115
|
+
? { [K in E & string]: (...args: A) => void; }
|
|
116
116
|
: never
|
|
117
117
|
: never;
|
|
118
118
|
type __VLS_NormalizeEmits<T> = __VLS_Prettify<
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.17",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"directory": "packages/vue-language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "
|
|
17
|
-
"@volar/source-map": "
|
|
16
|
+
"@volar/language-core": "1.10.2",
|
|
17
|
+
"@volar/source-map": "1.10.2",
|
|
18
18
|
"@vue/compiler-dom": "^3.3.0",
|
|
19
19
|
"@vue/reactivity": "^3.3.0",
|
|
20
20
|
"@vue/shared": "^3.3.0",
|
|
21
|
-
"minimatch": "^9.0.
|
|
21
|
+
"minimatch": "^9.0.3",
|
|
22
22
|
"muggle-string": "^0.3.1",
|
|
23
23
|
"vue-template-compiler": "^2.7.14"
|
|
24
24
|
},
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "81b41fe5daa15b01183459d036710ccc2491782e"
|
|
38
38
|
}
|