@vue/language-core 3.1.7 → 3.2.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/index.d.ts +1 -1
- package/index.js +25 -3
- package/lib/codegen/codeFeatures.d.ts +18 -84
- package/lib/codegen/names.d.ts +2 -5
- package/lib/codegen/names.js +3 -6
- package/lib/codegen/script/component.js +38 -18
- package/lib/codegen/script/index.d.ts +4 -12
- package/lib/codegen/script/index.js +132 -71
- package/lib/codegen/script/scriptSetup.js +52 -14
- package/lib/codegen/script/template.d.ts +1 -1
- package/lib/codegen/script/template.js +73 -50
- package/lib/codegen/style/index.d.ts +10 -13
- package/lib/codegen/style/modules.js +34 -1
- package/lib/codegen/template/context.d.ts +8 -11
- package/lib/codegen/template/context.js +36 -2
- package/lib/codegen/template/element.js +146 -159
- package/lib/codegen/template/elementDirectives.js +36 -3
- package/lib/codegen/template/elementEvents.d.ts +1 -1
- package/lib/codegen/template/elementEvents.js +39 -6
- package/lib/codegen/template/elementProps.js +35 -2
- package/lib/codegen/template/index.d.ts +11 -14
- package/lib/codegen/template/index.js +34 -1
- package/lib/codegen/template/interpolation.d.ts +4 -3
- package/lib/codegen/template/interpolation.js +37 -4
- package/lib/codegen/template/slotOutlet.js +35 -2
- package/lib/codegen/template/templateChild.js +45 -16
- package/lib/codegen/template/vFor.js +37 -4
- package/lib/codegen/template/vIf.js +34 -1
- package/lib/codegen/template/vSlot.d.ts +1 -1
- package/lib/codegen/template/vSlot.js +52 -25
- package/lib/codegen/utils/index.js +4 -2
- package/lib/compilerOptions.d.ts +7 -11
- package/lib/compilerOptions.js +48 -89
- package/lib/languagePlugin.js +34 -1
- package/lib/parsers/scriptRanges.d.ts +27 -15
- package/lib/parsers/scriptRanges.js +66 -62
- package/lib/parsers/scriptSetupRanges.d.ts +19 -24
- package/lib/parsers/scriptSetupRanges.js +13 -15
- package/lib/parsers/utils.d.ts +3 -6
- package/lib/parsers/utils.js +4 -0
- package/lib/plugins/vue-script-js.js +1 -1
- package/lib/plugins/vue-template-inline-css.js +34 -1
- package/lib/plugins/vue-template-inline-ts.js +34 -1
- package/lib/plugins/vue-tsx.d.ts +38 -117
- package/lib/plugins/vue-tsx.js +62 -33
- package/lib/plugins.js +17 -14
- package/lib/types.d.ts +8 -8
- package/lib/utils/collectBindings.d.ts +1 -1
- package/lib/utils/forEachTemplateNode.js +34 -1
- package/lib/utils/parseSfc.js +34 -1
- package/lib/utils/shared.d.ts +1 -1
- package/lib/utils/shared.js +2 -1
- package/lib/virtualCode/embeddedCodes.js +6 -2
- package/lib/virtualCode/index.js +10 -1
- package/lib/virtualCode/ir.js +34 -1
- package/lib/virtualCode/normalize.js +37 -2
- package/package.json +4 -12
- package/types/props-fallback.d.ts +5 -0
- package/types/template-helpers.d.ts +146 -0
- package/types/vue-3.4-shims.d.ts +6 -0
- package/lib/codegen/globalTypes.d.ts +0 -3
- package/lib/codegen/globalTypes.js +0 -163
- package/lib/codegen/script/src.d.ts +0 -2
- package/lib/codegen/script/src.js +0 -38
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.generateScriptSetupImports = generateScriptSetupImports;
|
|
4
37
|
exports.generateGeneric = generateGeneric;
|
|
5
38
|
exports.generateSetupFunction = generateSetupFunction;
|
|
6
39
|
const shared_1 = require("@vue/shared");
|
|
7
40
|
const codeFeatures_1 = require("../codeFeatures");
|
|
8
|
-
const names = require("../names");
|
|
41
|
+
const names = __importStar(require("../names"));
|
|
9
42
|
const utils_1 = require("../utils");
|
|
10
43
|
const boundary_1 = require("../utils/boundary");
|
|
11
44
|
const camelized_1 = require("../utils/camelized");
|
|
@@ -36,6 +69,7 @@ function* generateGeneric(options, ctx, scriptSetup, scriptSetupRanges, generic,
|
|
|
36
69
|
+ ` ${names.setup} = (async () => {${utils_1.newLine}`;
|
|
37
70
|
yield* body;
|
|
38
71
|
const propTypes = [];
|
|
72
|
+
const emitTypes = [];
|
|
39
73
|
const { vueCompilerOptions } = options;
|
|
40
74
|
if (ctx.generatedTypes.has(names.PublicProps)) {
|
|
41
75
|
propTypes.push(names.PublicProps);
|
|
@@ -49,10 +83,9 @@ function* generateGeneric(options, ctx, scriptSetup, scriptSetupRanges, generic,
|
|
|
49
83
|
if (scriptSetupRanges.defineEmits || scriptSetupRanges.defineModel.length) {
|
|
50
84
|
propTypes.push(names.EmitProps);
|
|
51
85
|
}
|
|
52
|
-
if (options.
|
|
86
|
+
if (options.templateAndStyleTypes.has(names.InheritedAttrs)) {
|
|
53
87
|
propTypes.push(names.InheritedAttrs);
|
|
54
88
|
}
|
|
55
|
-
const emitTypes = [];
|
|
56
89
|
if (scriptSetupRanges.defineEmits) {
|
|
57
90
|
emitTypes.push(`typeof ${scriptSetupRanges.defineEmits.name ?? names.emit}`);
|
|
58
91
|
}
|
|
@@ -60,23 +93,28 @@ function* generateGeneric(options, ctx, scriptSetup, scriptSetupRanges, generic,
|
|
|
60
93
|
emitTypes.push(`typeof ${names.modelEmit}`);
|
|
61
94
|
}
|
|
62
95
|
yield `return {} as {${utils_1.newLine}`;
|
|
63
|
-
yield ` props:
|
|
96
|
+
yield ` props: `;
|
|
97
|
+
yield vueCompilerOptions.target >= 3.4
|
|
64
98
|
? `import('${vueCompilerOptions.lib}').PublicProps`
|
|
65
99
|
: vueCompilerOptions.target >= 3
|
|
66
100
|
? `import('${vueCompilerOptions.lib}').VNodeProps`
|
|
67
101
|
+ ` & import('${vueCompilerOptions.lib}').AllowedComponentProps`
|
|
68
102
|
+ ` & import('${vueCompilerOptions.lib}').ComponentCustomProps`
|
|
69
|
-
: `globalThis.JSX.IntrinsicAttributes
|
|
103
|
+
: `globalThis.JSX.IntrinsicAttributes`;
|
|
104
|
+
if (propTypes.length) {
|
|
105
|
+
yield ` & ${ctx.localTypes.PrettifyLocal}<${propTypes.join(` & `)}>`;
|
|
106
|
+
}
|
|
107
|
+
yield ` & (typeof globalThis extends { __VLS_PROPS_FALLBACK: infer P } ? P : {})${utils_1.endOfLine}`;
|
|
70
108
|
yield ` expose: (exposed: `;
|
|
71
109
|
yield scriptSetupRanges.defineExpose
|
|
72
110
|
? `import('${vueCompilerOptions.lib}').ShallowUnwrapRef<typeof ${names.exposed}>`
|
|
73
111
|
: `{}`;
|
|
74
112
|
if (options.vueCompilerOptions.inferComponentDollarRefs
|
|
75
|
-
&& options.
|
|
113
|
+
&& options.templateAndStyleTypes.has(names.TemplateRefs)) {
|
|
76
114
|
yield ` & { $refs: ${names.TemplateRefs}; }`;
|
|
77
115
|
}
|
|
78
116
|
if (options.vueCompilerOptions.inferComponentDollarEl
|
|
79
|
-
&& options.
|
|
117
|
+
&& options.templateAndStyleTypes.has(names.RootEl)) {
|
|
80
118
|
yield ` & { $el: ${names.RootEl}; }`;
|
|
81
119
|
}
|
|
82
120
|
yield `) => void${utils_1.endOfLine}`;
|
|
@@ -141,7 +179,7 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, bo
|
|
|
141
179
|
transforms.push((0, transform_1.insert)(callExp.start, function* () {
|
|
142
180
|
yield `(`;
|
|
143
181
|
}));
|
|
144
|
-
const type = options.
|
|
182
|
+
const type = options.templateAndStyleTypes.has(names.StyleModules)
|
|
145
183
|
? names.StyleModules
|
|
146
184
|
: `{}`;
|
|
147
185
|
if (arg) {
|
|
@@ -150,7 +188,7 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, bo
|
|
|
150
188
|
yield* (0, utils_1.generateSfcBlockSection)(scriptSetup, arg.start, arg.end, codeFeatures_1.codeFeatures.withoutSemantic);
|
|
151
189
|
yield `])`;
|
|
152
190
|
}), (0, transform_1.replace)(arg.start, arg.end, function* () {
|
|
153
|
-
yield
|
|
191
|
+
yield `{} as any`;
|
|
154
192
|
}));
|
|
155
193
|
}
|
|
156
194
|
else {
|
|
@@ -176,7 +214,7 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, bo
|
|
|
176
214
|
transforms.push((0, transform_1.insert)(callExp.start, function* () {
|
|
177
215
|
yield `(`;
|
|
178
216
|
}), (0, transform_1.insert)(callExp.end, function* () {
|
|
179
|
-
yield ` as
|
|
217
|
+
yield ` as Readonly<import('${options.vueCompilerOptions.lib}').ShallowRef<`;
|
|
180
218
|
if (arg) {
|
|
181
219
|
yield names.TemplateRefs;
|
|
182
220
|
yield `[`;
|
|
@@ -186,11 +224,11 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, bo
|
|
|
186
224
|
else {
|
|
187
225
|
yield `unknown`;
|
|
188
226
|
}
|
|
189
|
-
yield
|
|
227
|
+
yield ` | null>>)`;
|
|
190
228
|
}));
|
|
191
229
|
if (arg) {
|
|
192
230
|
transforms.push((0, transform_1.replace)(arg.start, arg.end, function* () {
|
|
193
|
-
yield
|
|
231
|
+
yield `{} as any`;
|
|
194
232
|
}));
|
|
195
233
|
}
|
|
196
234
|
}
|
|
@@ -219,7 +257,7 @@ function* generateMacros(options) {
|
|
|
219
257
|
yield `// @ts-ignore${utils_1.newLine}`;
|
|
220
258
|
yield `declare const { `;
|
|
221
259
|
for (const macro of Object.keys(options.vueCompilerOptions.macros)) {
|
|
222
|
-
if (!options.
|
|
260
|
+
if (!options.exposed.has(macro)) {
|
|
223
261
|
yield `${macro}, `;
|
|
224
262
|
}
|
|
225
263
|
}
|
|
@@ -299,7 +337,7 @@ function* generatePublicProps(options, ctx, scriptSetup, scriptSetupRanges) {
|
|
|
299
337
|
}
|
|
300
338
|
function hasSlotsType(options) {
|
|
301
339
|
return !!(options.scriptSetupRanges?.defineSlots
|
|
302
|
-
|| options.
|
|
340
|
+
|| options.templateAndStyleTypes.has(names.Slots));
|
|
303
341
|
}
|
|
304
342
|
function* generateModels(scriptSetup, scriptSetupRanges) {
|
|
305
343
|
if (!scriptSetupRanges.defineModel.length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Code } from '../../types';
|
|
2
2
|
import type { ScriptCodegenContext } from './context';
|
|
3
3
|
import type { ScriptCodegenOptions } from './index';
|
|
4
|
-
export declare function generateTemplate(options: ScriptCodegenOptions, ctx: ScriptCodegenContext): Generator<Code>;
|
|
4
|
+
export declare function generateTemplate(options: ScriptCodegenOptions, ctx: ScriptCodegenContext, selfType?: string): Generator<Code>;
|
|
@@ -1,55 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.generateTemplate = generateTemplate;
|
|
4
|
-
const path = require("path-browserify");
|
|
5
37
|
const codeFeatures_1 = require("../codeFeatures");
|
|
6
|
-
const names = require("../names");
|
|
38
|
+
const names = __importStar(require("../names"));
|
|
7
39
|
const utils_1 = require("../utils");
|
|
8
40
|
const merge_1 = require("../utils/merge");
|
|
9
|
-
function* generateTemplate(options, ctx) {
|
|
10
|
-
yield* generateSelf(options);
|
|
41
|
+
function* generateTemplate(options, ctx, selfType) {
|
|
11
42
|
yield* generateSetupExposed(options, ctx);
|
|
12
|
-
yield* generateTemplateCtx(options, ctx);
|
|
13
|
-
yield* generateTemplateComponents(options);
|
|
14
|
-
yield* generateTemplateDirectives(options);
|
|
15
|
-
if (options.
|
|
16
|
-
yield* options.
|
|
17
|
-
}
|
|
18
|
-
if (options.templateCodegen) {
|
|
19
|
-
yield* options.templateCodegen.codes;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function* generateSelf({ script, scriptRanges, vueCompilerOptions, fileName }) {
|
|
23
|
-
if (script && scriptRanges?.componentOptions) {
|
|
24
|
-
yield `const ${names.self} = (await import('${vueCompilerOptions.lib}')).defineComponent(`;
|
|
25
|
-
const { args } = scriptRanges.componentOptions;
|
|
26
|
-
yield* (0, utils_1.generateSfcBlockSection)(script, args.start, args.end, codeFeatures_1.codeFeatures.all);
|
|
27
|
-
yield `)${utils_1.endOfLine}`;
|
|
28
|
-
}
|
|
29
|
-
else if (script && scriptRanges?.exportDefault) {
|
|
30
|
-
yield `const ${names.self} = `;
|
|
31
|
-
const { expression } = scriptRanges.exportDefault;
|
|
32
|
-
yield* (0, utils_1.generateSfcBlockSection)(script, expression.start, expression.end, codeFeatures_1.codeFeatures.all);
|
|
33
|
-
yield utils_1.endOfLine;
|
|
34
|
-
}
|
|
35
|
-
else if (script?.src) {
|
|
36
|
-
yield `let ${names.self}!: typeof import('./${path.basename(fileName)}').default${utils_1.endOfLine}`;
|
|
43
|
+
yield* generateTemplateCtx(options, ctx, selfType);
|
|
44
|
+
yield* generateTemplateComponents(options, ctx);
|
|
45
|
+
yield* generateTemplateDirectives(options, ctx);
|
|
46
|
+
if (options.templateAndStyleCodes.length) {
|
|
47
|
+
yield* options.templateAndStyleCodes;
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
|
-
function* generateTemplateCtx({ vueCompilerOptions,
|
|
50
|
+
function* generateTemplateCtx({ vueCompilerOptions, templateAndStyleTypes, scriptSetupRanges, fileName }, ctx, selfType) {
|
|
40
51
|
const exps = [];
|
|
41
52
|
const emitTypes = [];
|
|
42
53
|
const propTypes = [];
|
|
43
54
|
if (vueCompilerOptions.petiteVueExtensions.some(ext => fileName.endsWith(ext))) {
|
|
44
55
|
exps.push([`globalThis`]);
|
|
45
56
|
}
|
|
46
|
-
if (
|
|
47
|
-
exps.push([`{} as InstanceType<__VLS_PickNotAny<typeof ${
|
|
57
|
+
if (selfType) {
|
|
58
|
+
exps.push([`{} as InstanceType<__VLS_PickNotAny<typeof ${selfType}, new () => {}>>`]);
|
|
48
59
|
}
|
|
49
60
|
else {
|
|
50
61
|
exps.push([`{} as import('${vueCompilerOptions.lib}').ComponentPublicInstance`]);
|
|
51
62
|
}
|
|
52
|
-
if (
|
|
63
|
+
if (templateAndStyleTypes.has(names.StyleModules)) {
|
|
53
64
|
exps.push([`{} as ${names.StyleModules}`]);
|
|
54
65
|
}
|
|
55
66
|
if (scriptSetupRanges?.defineEmits) {
|
|
@@ -84,37 +95,49 @@ function* generateTemplateCtx({ vueCompilerOptions, script, scriptRanges, styleC
|
|
|
84
95
|
yield* (0, merge_1.generateSpreadMerge)(exps);
|
|
85
96
|
yield utils_1.endOfLine;
|
|
86
97
|
}
|
|
87
|
-
function* generateTemplateComponents(
|
|
88
|
-
const types = [
|
|
89
|
-
if (
|
|
90
|
-
|
|
98
|
+
function* generateTemplateComponents({ vueCompilerOptions, script, scriptRanges }, ctx) {
|
|
99
|
+
const types = [];
|
|
100
|
+
if (ctx.generatedTypes.has(names.SetupExposed)) {
|
|
101
|
+
types.push(names.SetupExposed);
|
|
102
|
+
}
|
|
103
|
+
if (script && scriptRanges?.exportDefault?.options?.components) {
|
|
104
|
+
const { components } = scriptRanges.exportDefault.options;
|
|
91
105
|
yield `const __VLS_componentsOption = `;
|
|
92
|
-
yield* (0, utils_1.generateSfcBlockSection)(
|
|
106
|
+
yield* (0, utils_1.generateSfcBlockSection)(script, components.start, components.end, codeFeatures_1.codeFeatures.navigation);
|
|
93
107
|
yield utils_1.endOfLine;
|
|
94
108
|
types.push(`typeof __VLS_componentsOption`);
|
|
95
109
|
}
|
|
96
|
-
yield `type __VLS_LocalComponents = ${types.join(` & `)}${utils_1.endOfLine}`;
|
|
110
|
+
yield `type __VLS_LocalComponents = ${types.length ? types.join(` & `) : `{}`}${utils_1.endOfLine}`;
|
|
111
|
+
yield `type __VLS_GlobalComponents = ${vueCompilerOptions.target >= 3.5
|
|
112
|
+
? `import('${vueCompilerOptions.lib}').GlobalComponents`
|
|
113
|
+
: `import('${vueCompilerOptions.lib}').GlobalComponents & Pick<typeof import('${vueCompilerOptions.lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>`}${utils_1.endOfLine}`;
|
|
97
114
|
yield `let ${names.components}!: __VLS_LocalComponents & __VLS_GlobalComponents${utils_1.endOfLine}`;
|
|
115
|
+
yield `let ${names.intrinsics}!: ${vueCompilerOptions.target >= 3.3
|
|
116
|
+
? `import('${vueCompilerOptions.lib}/jsx-runtime').JSX.IntrinsicElements`
|
|
117
|
+
: `globalThis.JSX.IntrinsicElements`}${utils_1.endOfLine}`;
|
|
98
118
|
}
|
|
99
|
-
function* generateTemplateDirectives(
|
|
100
|
-
const types = [
|
|
101
|
-
if (
|
|
102
|
-
|
|
119
|
+
function* generateTemplateDirectives({ vueCompilerOptions, script, scriptRanges }, ctx) {
|
|
120
|
+
const types = [];
|
|
121
|
+
if (ctx.generatedTypes.has(names.SetupExposed)) {
|
|
122
|
+
types.push(names.SetupExposed);
|
|
123
|
+
}
|
|
124
|
+
if (script && scriptRanges?.exportDefault?.options?.directives) {
|
|
125
|
+
const { directives } = scriptRanges.exportDefault.options;
|
|
103
126
|
yield `const __VLS_directivesOption = `;
|
|
104
|
-
yield* (0, utils_1.generateSfcBlockSection)(
|
|
127
|
+
yield* (0, utils_1.generateSfcBlockSection)(script, directives.start, directives.end, codeFeatures_1.codeFeatures.navigation);
|
|
105
128
|
yield utils_1.endOfLine;
|
|
106
129
|
types.push(`__VLS_ResolveDirectives<typeof __VLS_directivesOption>`);
|
|
107
130
|
}
|
|
108
|
-
yield `type __VLS_LocalDirectives = ${types.join(` & `)}${utils_1.endOfLine}`;
|
|
109
|
-
yield `let ${names.directives}!: __VLS_LocalDirectives &
|
|
131
|
+
yield `type __VLS_LocalDirectives = ${types.length ? types.join(` & `) : `{}`}${utils_1.endOfLine}`;
|
|
132
|
+
yield `let ${names.directives}!: __VLS_LocalDirectives & import('${vueCompilerOptions.lib}').GlobalDirectives${utils_1.endOfLine}`;
|
|
110
133
|
}
|
|
111
|
-
function* generateSetupExposed({
|
|
112
|
-
if (!
|
|
134
|
+
function* generateSetupExposed({ vueCompilerOptions, exposed }, ctx) {
|
|
135
|
+
if (!exposed.size) {
|
|
113
136
|
return;
|
|
114
137
|
}
|
|
115
138
|
ctx.generatedTypes.add(names.SetupExposed);
|
|
116
|
-
yield `type ${names.SetupExposed} =
|
|
117
|
-
for (const bindingName of
|
|
139
|
+
yield `type ${names.SetupExposed} = import('${vueCompilerOptions.lib}').ShallowUnwrapRef<{${utils_1.newLine}`;
|
|
140
|
+
for (const bindingName of exposed) {
|
|
118
141
|
const token = Symbol(bindingName.length);
|
|
119
142
|
yield ['', undefined, 0, { __linkedToken: token }];
|
|
120
143
|
yield `${bindingName}: typeof `;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Code, Sfc, VueCompilerOptions } from '../../types';
|
|
2
2
|
export interface StyleCodegenOptions {
|
|
3
|
-
|
|
3
|
+
typescript: typeof import('typescript');
|
|
4
4
|
vueCompilerOptions: VueCompilerOptions;
|
|
5
5
|
styles: Sfc['styles'];
|
|
6
6
|
setupRefs: Set<string>;
|
|
@@ -8,24 +8,23 @@ export interface StyleCodegenOptions {
|
|
|
8
8
|
}
|
|
9
9
|
export { generate as generateStyle };
|
|
10
10
|
declare function generate(options: StyleCodegenOptions): {
|
|
11
|
-
codes: Code[];
|
|
12
11
|
generatedTypes: Set<string>;
|
|
13
12
|
currentInfo: {
|
|
14
|
-
ignoreError?: boolean;
|
|
13
|
+
ignoreError?: boolean | undefined;
|
|
15
14
|
expectError?: {
|
|
16
15
|
token: number;
|
|
17
16
|
node: import("@vue/compiler-dom").CommentNode;
|
|
18
|
-
};
|
|
17
|
+
} | undefined;
|
|
19
18
|
generic?: {
|
|
20
19
|
content: string;
|
|
21
20
|
offset: number;
|
|
22
|
-
};
|
|
21
|
+
} | undefined;
|
|
23
22
|
};
|
|
24
23
|
resolveCodeFeatures: (features: import("../../types").VueCodeInformation) => import("../../types").VueCodeInformation;
|
|
25
24
|
inVFor: boolean;
|
|
26
25
|
slots: {
|
|
27
26
|
name: string;
|
|
28
|
-
offset?: number;
|
|
27
|
+
offset?: number | undefined;
|
|
29
28
|
tagRange: [number, number];
|
|
30
29
|
nodeLoc: any;
|
|
31
30
|
propsVar: string;
|
|
@@ -43,21 +42,19 @@ declare function generate(options: StyleCodegenOptions): {
|
|
|
43
42
|
typeExp: string;
|
|
44
43
|
offset: number;
|
|
45
44
|
}[]>;
|
|
46
|
-
currentComponent: {
|
|
47
|
-
get ctxVar(): string;
|
|
48
|
-
get propsVar(): string;
|
|
49
|
-
} | undefined;
|
|
50
45
|
singleRootElTypes: Set<string>;
|
|
51
46
|
singleRootNodes: Set<import("@vue/compiler-dom").ElementNode | null>;
|
|
52
47
|
addTemplateRef(name: string, typeExp: string, offset: number): void;
|
|
53
|
-
recordComponentAccess(source: string, name: string, offset?: number): void;
|
|
48
|
+
recordComponentAccess(source: string, name: string, offset?: number | undefined): void;
|
|
54
49
|
scopes: Set<string>[];
|
|
50
|
+
components: (() => string)[];
|
|
55
51
|
declare(...varNames: string[]): void;
|
|
56
52
|
startScope(): () => Generator<Code, any, any>;
|
|
57
53
|
getInternalVariable(): string;
|
|
58
54
|
getHoistVariable(originalVar: string): string;
|
|
59
55
|
generateHoistVariables(): Generator<string, void, unknown>;
|
|
60
56
|
generateConditionGuards(): Generator<string, void, unknown>;
|
|
61
|
-
enter(node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").
|
|
62
|
-
exit(): Generator<Code>;
|
|
57
|
+
enter(node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").SimpleExpressionNode | import("@vue/compiler-dom").TemplateChildNode): boolean;
|
|
58
|
+
exit(): Generator<Code, any, any>;
|
|
59
|
+
codes: Code[];
|
|
63
60
|
};
|
|
@@ -1,8 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.generateStyleModules = generateStyleModules;
|
|
4
37
|
const codeFeatures_1 = require("../codeFeatures");
|
|
5
|
-
const names = require("../names");
|
|
38
|
+
const names = __importStar(require("../names"));
|
|
6
39
|
const utils_1 = require("../utils");
|
|
7
40
|
const common_1 = require("./common");
|
|
8
41
|
function* generateStyleModules({ styles, vueCompilerOptions }, ctx) {
|
|
@@ -102,21 +102,21 @@ export type TemplateCodegenContext = ReturnType<typeof createTemplateCodegenCont
|
|
|
102
102
|
export declare function createTemplateCodegenContext(): {
|
|
103
103
|
generatedTypes: Set<string>;
|
|
104
104
|
readonly currentInfo: {
|
|
105
|
-
ignoreError?: boolean;
|
|
105
|
+
ignoreError?: boolean | undefined;
|
|
106
106
|
expectError?: {
|
|
107
107
|
token: number;
|
|
108
108
|
node: CompilerDOM.CommentNode;
|
|
109
|
-
};
|
|
109
|
+
} | undefined;
|
|
110
110
|
generic?: {
|
|
111
111
|
content: string;
|
|
112
112
|
offset: number;
|
|
113
|
-
};
|
|
113
|
+
} | undefined;
|
|
114
114
|
};
|
|
115
115
|
resolveCodeFeatures: (features: VueCodeInformation) => VueCodeInformation;
|
|
116
116
|
inVFor: boolean;
|
|
117
117
|
slots: {
|
|
118
118
|
name: string;
|
|
119
|
-
offset?: number;
|
|
119
|
+
offset?: number | undefined;
|
|
120
120
|
tagRange: [number, number];
|
|
121
121
|
nodeLoc: any;
|
|
122
122
|
propsVar: string;
|
|
@@ -134,21 +134,18 @@ export declare function createTemplateCodegenContext(): {
|
|
|
134
134
|
typeExp: string;
|
|
135
135
|
offset: number;
|
|
136
136
|
}[]>;
|
|
137
|
-
currentComponent: {
|
|
138
|
-
get ctxVar(): string;
|
|
139
|
-
get propsVar(): string;
|
|
140
|
-
} | undefined;
|
|
141
137
|
singleRootElTypes: Set<string>;
|
|
142
138
|
singleRootNodes: Set<CompilerDOM.ElementNode | null>;
|
|
143
139
|
addTemplateRef(name: string, typeExp: string, offset: number): void;
|
|
144
|
-
recordComponentAccess(source: string, name: string, offset?: number): void;
|
|
140
|
+
recordComponentAccess(source: string, name: string, offset?: number | undefined): void;
|
|
145
141
|
scopes: Set<string>[];
|
|
142
|
+
components: (() => string)[];
|
|
146
143
|
declare(...varNames: string[]): void;
|
|
147
144
|
startScope(): () => Generator<Code, any, any>;
|
|
148
145
|
getInternalVariable(): string;
|
|
149
146
|
getHoistVariable(originalVar: string): string;
|
|
150
147
|
generateHoistVariables(): Generator<string, void, unknown>;
|
|
151
148
|
generateConditionGuards(): Generator<string, void, unknown>;
|
|
152
|
-
enter(node: CompilerDOM.RootNode | CompilerDOM.
|
|
153
|
-
exit(): Generator<Code>;
|
|
149
|
+
enter(node: CompilerDOM.RootNode | CompilerDOM.SimpleExpressionNode | CompilerDOM.TemplateChildNode): boolean;
|
|
150
|
+
exit(): Generator<Code, any, any>;
|
|
154
151
|
};
|
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.createTemplateCodegenContext = createTemplateCodegenContext;
|
|
4
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
37
|
+
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
5
38
|
const codeFeatures_1 = require("../codeFeatures");
|
|
6
39
|
const utils_1 = require("../utils");
|
|
7
40
|
const boundary_1 = require("../utils/boundary");
|
|
@@ -106,6 +139,7 @@ const commentDirectiveRegex = /^<!--\s*@vue-(?<name>[-\w]+)\b(?<content>[\s\S]*)
|
|
|
106
139
|
function createTemplateCodegenContext() {
|
|
107
140
|
let variableId = 0;
|
|
108
141
|
const scopes = [];
|
|
142
|
+
const components = [];
|
|
109
143
|
const hoistVars = new Map();
|
|
110
144
|
const dollarVars = new Set();
|
|
111
145
|
const componentAccessMap = new Map();
|
|
@@ -132,7 +166,6 @@ function createTemplateCodegenContext() {
|
|
|
132
166
|
inlayHints,
|
|
133
167
|
inheritedAttrVars,
|
|
134
168
|
templateRefs,
|
|
135
|
-
currentComponent: undefined,
|
|
136
169
|
singleRootElTypes: new Set(),
|
|
137
170
|
singleRootNodes: new Set(),
|
|
138
171
|
addTemplateRef(name, typeExp, offset) {
|
|
@@ -156,6 +189,7 @@ function createTemplateCodegenContext() {
|
|
|
156
189
|
}
|
|
157
190
|
},
|
|
158
191
|
scopes,
|
|
192
|
+
components,
|
|
159
193
|
declare(...varNames) {
|
|
160
194
|
const scope = scopes.at(-1);
|
|
161
195
|
for (const varName of varNames) {
|