@vue/language-core 3.2.7 → 3.2.8

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.
@@ -41,7 +41,7 @@ const muggle_string_1 = require("muggle-string");
41
41
  const shared_2 = require("../../utils/shared");
42
42
  const codeFeatures_1 = require("../codeFeatures");
43
43
  const inlayHints_1 = require("../inlayHints");
44
- const names = __importStar(require("../names"));
44
+ const names_1 = require("../names");
45
45
  const utils_1 = require("../utils");
46
46
  const boundary_1 = require("../utils/boundary");
47
47
  const camelized_1 = require("../utils/camelized");
@@ -114,9 +114,9 @@ function* generateComponent(options, ctx, node) {
114
114
  yield utils_1.endOfLine;
115
115
  }
116
116
  else {
117
- yield `let ${componentVar}!: __VLS_WithComponent<'${tag}', __VLS_LocalComponents, __VLS_GlobalComponents`;
117
+ yield `let ${componentVar}!: ${names_1.names.WithComponent}<'${tag}', ${names_1.names.LocalComponents}, ${names_1.names.GlobalComponents}`;
118
118
  yield originalNames.has(options.componentName)
119
- ? `, typeof ${names._export}`
119
+ ? `, typeof ${names_1.names.export}`
120
120
  : `, void`;
121
121
  for (const name of originalNames) {
122
122
  yield `, '${name}'`;
@@ -131,18 +131,21 @@ function* generateComponent(options, ctx, node) {
131
131
  yield `]${utils_1.endOfLine}`;
132
132
  if (utils_1.identifierRegex.test((0, shared_1.camelize)(tag))) {
133
133
  // navigation support
134
- yield `/** @ts-ignore @type {typeof ${names.components}.`;
135
- yield* (0, camelized_1.generateCamelized)(tag, 'template', startTagOffset, codeFeatures_1.codeFeatures.navigation);
136
- if (tag[0] !== tag[0].toUpperCase()) {
137
- yield ` | typeof ${names.components}.`;
138
- yield* (0, camelized_1.generateCamelized)((0, shared_1.capitalize)(tag), 'template', startTagOffset, codeFeatures_1.codeFeatures.navigation);
139
- }
140
- if (endTagOffset !== undefined) {
141
- yield ` | typeof ${names.components}.`;
142
- yield* (0, camelized_1.generateCamelized)(tag, 'template', endTagOffset, codeFeatures_1.codeFeatures.navigation);
134
+ yield `/** @ts-ignore @type {`;
135
+ for (const offset of [startTagOffset, endTagOffset]) {
136
+ if (offset === undefined) {
137
+ continue;
138
+ }
139
+ yield ` | typeof ${names_1.names.components}.`;
140
+ yield* (0, camelized_1.generateCamelized)(tag, 'template', offset, codeFeatures_1.codeFeatures.navigation);
143
141
  if (tag[0] !== tag[0].toUpperCase()) {
144
- yield ` | typeof ${names.components}.`;
145
- yield* (0, camelized_1.generateCamelized)((0, shared_1.capitalize)(tag), 'template', endTagOffset, codeFeatures_1.codeFeatures.navigation);
142
+ yield ` | typeof ${names_1.names.components}.`;
143
+ yield* (0, camelized_1.generateCamelized)((0, shared_1.capitalize)(tag), 'template', offset, codeFeatures_1.codeFeatures.navigation);
144
+ }
145
+ if (tag.includes('-')) {
146
+ yield ` | typeof ${names_1.names.components}[`;
147
+ yield* (0, stringLiteralKey_1.generateStringLiteralKey)(tag, offset, codeFeatures_1.codeFeatures.navigation);
148
+ yield `]`;
146
149
  }
147
150
  }
148
151
  yield `} */${utils_1.newLine}`;
@@ -163,16 +166,16 @@ function* generateComponentBody(options, ctx, node, tag, tagOffset, props, compo
163
166
  const failGeneratedExpressions = [];
164
167
  const propCodes = [...(0, elementProps_1.generateElementProps)(options, ctx, node, props, options.vueCompilerOptions.checkUnknownProps, failGeneratedExpressions)];
165
168
  const functionalVar = ctx.getInternalVariable();
166
- const vNodeVar = ctx.getInternalVariable();
169
+ const vnodeVar = ctx.getInternalVariable();
167
170
  const ctxVar = ctx.getInternalVariable();
168
171
  const propsVar = ctx.getInternalVariable();
169
172
  yield `// @ts-ignore${utils_1.newLine}`;
170
- yield `const ${functionalVar} = ${options.vueCompilerOptions.checkUnknownProps ? '__VLS_asFunctionalComponent0' : '__VLS_asFunctionalComponent1'}(${componentVar}, new ${componentVar}({${utils_1.newLine}`;
173
+ yield `const ${functionalVar} = ${options.vueCompilerOptions.checkUnknownProps ? names_1.names.asFunctionalComponent0 : names_1.names.asFunctionalComponent1}(${componentVar}, new ${componentVar}({${utils_1.newLine}`;
171
174
  yield (0, muggle_string_1.toString)(propCodes);
172
175
  yield `}))${utils_1.endOfLine}`;
173
176
  yield `const `;
174
177
  const token = yield* (0, boundary_1.startBoundary)('template', node.loc.start.offset, codeFeatures_1.codeFeatures.doNotReportTs6133);
175
- yield vNodeVar;
178
+ yield vnodeVar;
176
179
  yield (0, boundary_1.endBoundary)(token, node.loc.end.offset);
177
180
  yield ` = ${functionalVar}`;
178
181
  if (ctx.currentInfo.generic) {
@@ -189,7 +192,7 @@ function* generateComponentBody(options, ctx, node, tag, tagOffset, props, compo
189
192
  yield* propCodes;
190
193
  yield `}`;
191
194
  yield (0, boundary_1.endBoundary)(token2, tagOffset + tag.length);
192
- yield `, ...__VLS_functionalComponentArgsRest(${functionalVar}))${utils_1.endOfLine}`;
195
+ yield `, ...${names_1.names.functionalComponentArgsRest}(${functionalVar}))${utils_1.endOfLine}`;
193
196
  yield* generateFailedExpressions(options, ctx, failGeneratedExpressions);
194
197
  yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, componentVar, getCtxVar, getPropsVar);
195
198
  yield* (0, elementDirectives_1.generateElementDirectives)(options, ctx, node);
@@ -220,21 +223,21 @@ function* generateComponentBody(options, ctx, node, tag, tagOffset, props, compo
220
223
  yield* (0, vSlot_1.generateVSlot)(options, ctx, node, slotDir, getCtxVar());
221
224
  }
222
225
  if (isCtxVarUsed) {
223
- yield `var ${ctxVar}!: __VLS_FunctionalComponentCtx<typeof ${componentVar}, typeof ${vNodeVar}>${utils_1.endOfLine}`;
226
+ yield `var ${ctxVar}!: ${names_1.names.FunctionalComponentCtx}<typeof ${componentVar}, typeof ${vnodeVar}>${utils_1.endOfLine}`;
224
227
  }
225
228
  if (isPropsVarUsed) {
226
- yield `var ${propsVar}!: __VLS_FunctionalComponentProps<typeof ${componentVar}, typeof ${vNodeVar}>${utils_1.endOfLine}`;
229
+ yield `var ${propsVar}!: ${names_1.names.FunctionalComponentProps}<typeof ${componentVar}, typeof ${vnodeVar}>${utils_1.endOfLine}`;
227
230
  }
228
231
  ctx.components.pop();
229
232
  }
230
233
  function* generateElement(options, ctx, node) {
231
234
  const [startTagOffset, endTagOffset] = (0, shared_2.getElementTagOffsets)(node, options.template);
232
235
  const failedPropExps = [];
233
- yield `${options.vueCompilerOptions.checkUnknownProps ? `__VLS_asFunctionalElement0` : `__VLS_asFunctionalElement1`}(${names.intrinsics}`;
236
+ yield `${options.vueCompilerOptions.checkUnknownProps ? names_1.names.asFunctionalElement0 : names_1.names.asFunctionalElement1}(${names_1.names.intrinsics}`;
234
237
  yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, startTagOffset, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion);
235
238
  if (endTagOffset !== undefined) {
236
239
  yield `, `;
237
- yield names.intrinsics;
240
+ yield names_1.names.intrinsics;
238
241
  yield* (0, propertyAccess_1.generatePropertyAccess)(options, ctx, node.tag, endTagOffset, codeFeatures_1.codeFeatures.withoutHighlightAndCompletion);
239
242
  }
240
243
  yield `)(`;
@@ -248,17 +251,17 @@ function* generateElement(options, ctx, node) {
248
251
  yield* (0, elementDirectives_1.generateElementDirectives)(options, ctx, node);
249
252
  const templateRef = getTemplateRef(node);
250
253
  if (templateRef) {
251
- let typeExp = `__VLS_Elements['${node.tag}']`;
254
+ let typeExp = `${names_1.names.Elements}['${node.tag}']`;
252
255
  if (ctx.inVFor) {
253
256
  typeExp += `[]`;
254
257
  }
255
258
  ctx.addTemplateRef(templateRef[0], typeExp, templateRef[1]);
256
259
  }
257
260
  if (ctx.singleRootNodes.has(node)) {
258
- ctx.singleRootElTypes.add(`__VLS_Elements['${node.tag}']`);
261
+ ctx.singleRootElTypes.add(`${names_1.names.Elements}['${node.tag}']`);
259
262
  }
260
263
  if (hasVBindAttrs(options, ctx, node)) {
261
- ctx.inheritedAttrVars.add(`__VLS_intrinsics.${node.tag}`);
264
+ ctx.inheritedAttrVars.add(`${names_1.names.intrinsics}.${node.tag}`);
262
265
  }
263
266
  yield* generateStyleScopedClassReferences(options, node);
264
267
  for (const child of node.children) {
@@ -38,7 +38,7 @@ exports.generateModifiers = generateModifiers;
38
38
  const CompilerDOM = __importStar(require("@vue/compiler-dom"));
39
39
  const shared_1 = require("@vue/shared");
40
40
  const codeFeatures_1 = require("../codeFeatures");
41
- const names = __importStar(require("../names"));
41
+ const names_1 = require("../names");
42
42
  const utils_1 = require("../utils");
43
43
  const boundary_1 = require("../utils/boundary");
44
44
  const camelized_1 = require("../utils/camelized");
@@ -56,9 +56,9 @@ function* generateElementDirectives(options, ctx, node) {
56
56
  continue;
57
57
  }
58
58
  const token = yield* (0, boundary_1.startBoundary)('template', prop.loc.start.offset, codeFeatures_1.codeFeatures.verification);
59
- yield `__VLS_asFunctionalDirective(`;
59
+ yield `${names_1.names.asFunctionalDirective}(`;
60
60
  yield* generateIdentifier(options, ctx, prop);
61
- yield `, {} as import('${options.vueCompilerOptions.lib}').ObjectDirective)(null!, { ...__VLS_directiveBindingRestFields, `;
61
+ yield `, {} as import('${options.vueCompilerOptions.lib}').ObjectDirective)(null!, { ...${names_1.names.directiveBindingRestFields}, `;
62
62
  yield* generateArg(options, ctx, prop);
63
63
  yield* generateModifiers(options, ctx, prop);
64
64
  yield* generateValue(options, ctx, prop);
@@ -71,7 +71,7 @@ function* generateIdentifier(options, ctx, prop) {
71
71
  const rawName = 'v-' + prop.name;
72
72
  const startOffset = prop.loc.start.offset;
73
73
  const token = yield* (0, boundary_1.startBoundary)('template', startOffset, codeFeatures_1.codeFeatures.verification);
74
- yield names.directives;
74
+ yield names_1.names.directives;
75
75
  yield `.`;
76
76
  yield* (0, camelized_1.generateCamelized)(rawName, 'template', prop.loc.start.offset, {
77
77
  ...codeFeatures_1.codeFeatures.withoutHighlightAndCompletion,
@@ -41,6 +41,7 @@ exports.isCompoundExpression = isCompoundExpression;
41
41
  const CompilerDOM = __importStar(require("@vue/compiler-dom"));
42
42
  const shared_1 = require("@vue/shared");
43
43
  const codeFeatures_1 = require("../codeFeatures");
44
+ const names_1 = require("../names");
44
45
  const utils_1 = require("../utils");
45
46
  const boundary_1 = require("../utils/boundary");
46
47
  const camelized_1 = require("../utils/camelized");
@@ -56,7 +57,7 @@ function* generateElementEvents(options, ctx, node, componentOriginalVar, getCtx
56
57
  && (!prop.arg || prop.arg.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic))) {
57
58
  if (!emitsVar) {
58
59
  emitsVar = ctx.getInternalVariable();
59
- yield `let ${emitsVar}!: __VLS_ResolveEmits<typeof ${componentOriginalVar}, typeof ${getCtxVar()}.emit>${utils_1.endOfLine}`;
60
+ yield `let ${emitsVar}!: ${names_1.names.ResolveEmits}<typeof ${componentOriginalVar}, typeof ${getCtxVar()}.emit>${utils_1.endOfLine}`;
60
61
  }
61
62
  let source = prop.arg?.loc.source ?? 'model-value';
62
63
  let start = prop.arg?.loc.start.offset;
@@ -75,7 +76,7 @@ function* generateElementEvents(options, ctx, node, componentOriginalVar, getCtx
75
76
  const propName = (0, shared_1.camelize)(propPrefix + source);
76
77
  const emitName = emitPrefix + source;
77
78
  const camelizedEmitName = (0, shared_1.camelize)(emitName);
78
- yield `const ${ctx.getInternalVariable()}: __VLS_NormalizeComponentEvent<typeof ${getPropsVar()}, typeof ${emitsVar}, '${propName}', '${emitName}', '${camelizedEmitName}'> = (${utils_1.newLine}`;
79
+ yield `const ${ctx.getInternalVariable()}: ${names_1.names.NormalizeComponentEvent}<typeof ${getPropsVar()}, typeof ${emitsVar}, '${propName}', '${emitName}', '${camelizedEmitName}'> = (${utils_1.newLine}`;
79
80
  if (prop.name === 'on') {
80
81
  yield `{ `;
81
82
  yield* generateEventArg(options, source, start, emitPrefix.slice(0, -1), codeFeatures_1.codeFeatures.navigation);
@@ -41,7 +41,7 @@ const picomatch_1 = require("picomatch");
41
41
  const shared_2 = require("../../utils/shared");
42
42
  const codeFeatures_1 = require("../codeFeatures");
43
43
  const inlayHints_1 = require("../inlayHints");
44
- const names = __importStar(require("../names"));
44
+ const names_1 = require("../names");
45
45
  const utils_1 = require("../utils");
46
46
  const boundary_1 = require("../utils/boundary");
47
47
  const camelized_1 = require("../utils/camelized");
@@ -136,7 +136,7 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, fail
136
136
  if (isComponent && prop.name === 'model' && prop.modifiers.length) {
137
137
  const propertyName = prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
138
138
  ? !prop.arg.isStatic
139
- ? `[__VLS_tryAsConstant(\`\${${prop.arg.content}}Modifiers\`)]`
139
+ ? `[${names_1.names.tryAsConstant}(\`\${${prop.arg.content}}Modifiers\`)]`
140
140
  : (0, shared_1.camelize)(propName) + `Modifiers`
141
141
  : `modelModifiers`;
142
142
  yield* (0, elementDirectives_1.generateModifiers)(options, ctx, prop, propertyName);
@@ -219,7 +219,7 @@ function* generatePropExp(options, ctx, prop, exp) {
219
219
  }
220
220
  else {
221
221
  ctx.recordComponentAccess('template', propVariableName, exp.loc.start.offset);
222
- yield names.ctx;
222
+ yield names_1.names.ctx;
223
223
  yield `.`;
224
224
  yield* codes;
225
225
  }
@@ -1,41 +1,8 @@
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
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.generateTemplate = generate;
37
4
  const codeFeatures_1 = require("../codeFeatures");
38
- const names = __importStar(require("../names"));
5
+ const names_1 = require("../names");
39
6
  const utils_1 = require("../utils");
40
7
  const boundary_1 = require("../utils/boundary");
41
8
  const context_1 = require("./context");
@@ -84,24 +51,24 @@ function* generateWorker(options, ctx) {
84
51
  yield* generateTemplateRefsType(options, ctx);
85
52
  yield* generateRootElType(ctx);
86
53
  if (ctx.dollarVars.size) {
87
- yield `var ${names.dollars}!: {${utils_1.newLine}`;
54
+ yield `var ${names_1.names.dollars}!: {${utils_1.newLine}`;
88
55
  if (ctx.dollarVars.has('$slots')) {
89
- const type = ctx.generatedTypes.has(names.Slots) ? names.Slots : `{}`;
56
+ const type = ctx.generatedTypes.has(names_1.names.Slots) ? names_1.names.Slots : `{}`;
90
57
  yield `$slots: ${type}${utils_1.endOfLine}`;
91
58
  }
92
59
  if (ctx.dollarVars.has('$attrs')) {
93
60
  yield `$attrs: import('${vueCompilerOptions.lib}').ComponentPublicInstance['$attrs']`;
94
- if (ctx.generatedTypes.has(names.InheritedAttrs)) {
95
- yield ` & ${names.InheritedAttrs}`;
61
+ if (ctx.generatedTypes.has(names_1.names.InheritedAttrs)) {
62
+ yield ` & ${names_1.names.InheritedAttrs}`;
96
63
  }
97
64
  yield utils_1.endOfLine;
98
65
  }
99
66
  if (ctx.dollarVars.has('$refs')) {
100
- const type = ctx.generatedTypes.has(names.TemplateRefs) ? names.TemplateRefs : `{}`;
67
+ const type = ctx.generatedTypes.has(names_1.names.TemplateRefs) ? names_1.names.TemplateRefs : `{}`;
101
68
  yield `$refs: ${type}${utils_1.endOfLine}`;
102
69
  }
103
70
  if (ctx.dollarVars.has('$el')) {
104
- const type = ctx.generatedTypes.has(names.RootEl) ? names.RootEl : `any`;
71
+ const type = ctx.generatedTypes.has(names_1.names.RootEl) ? names_1.names.RootEl : `any`;
105
72
  yield `$el: ${type}${utils_1.endOfLine}`;
106
73
  }
107
74
  yield `} & { [K in keyof import('${vueCompilerOptions.lib}').ComponentPublicInstance]: unknown }${utils_1.endOfLine}`;
@@ -110,14 +77,14 @@ function* generateWorker(options, ctx) {
110
77
  }
111
78
  function* generateSlotsType(options, ctx) {
112
79
  if (options.hasDefineSlots) {
113
- ctx.generatedTypes.add(names.Slots);
80
+ ctx.generatedTypes.add(names_1.names.Slots);
114
81
  return;
115
82
  }
116
83
  if (!ctx.slots.length && !ctx.dynamicSlots.length) {
117
84
  return;
118
85
  }
119
- ctx.generatedTypes.add(names.Slots);
120
- yield `type ${names.Slots} = {}`;
86
+ ctx.generatedTypes.add(names_1.names.Slots);
87
+ yield `type ${names_1.names.Slots} = {}`;
121
88
  for (const { expVar, propsVar } of ctx.dynamicSlots) {
122
89
  yield `${utils_1.newLine}& { [K in NonNullable<typeof ${expVar}>]?: (props: typeof ${propsVar}) => any }`;
123
90
  }
@@ -139,16 +106,16 @@ function* generateInheritedAttrsType(ctx) {
139
106
  if (!ctx.inheritedAttrVars.size) {
140
107
  return;
141
108
  }
142
- ctx.generatedTypes.add(names.InheritedAttrs);
143
- yield `type ${names.InheritedAttrs} = Partial<${[...ctx.inheritedAttrVars].map(name => `typeof ${name}`).join(` & `)}>`;
109
+ ctx.generatedTypes.add(names_1.names.InheritedAttrs);
110
+ yield `type ${names_1.names.InheritedAttrs} = Partial<${[...ctx.inheritedAttrVars].map(name => `typeof ${name}`).join(` & `)}>`;
144
111
  yield utils_1.endOfLine;
145
112
  }
146
113
  function* generateTemplateRefsType(options, ctx) {
147
114
  if (!ctx.templateRefs.size) {
148
115
  return;
149
116
  }
150
- ctx.generatedTypes.add(names.TemplateRefs);
151
- yield `type ${names.TemplateRefs} = {}`;
117
+ ctx.generatedTypes.add(names_1.names.TemplateRefs);
118
+ yield `type ${names_1.names.TemplateRefs} = {}`;
152
119
  for (const [name, refs] of ctx.templateRefs) {
153
120
  yield `${utils_1.newLine}& `;
154
121
  if (refs.length >= 2) {
@@ -173,8 +140,8 @@ function* generateRootElType(ctx) {
173
140
  if (!ctx.singleRootElTypes.size || ctx.singleRootNodes.has(null)) {
174
141
  return;
175
142
  }
176
- ctx.generatedTypes.add(names.RootEl);
177
- yield `type ${names.RootEl} = `;
143
+ ctx.generatedTypes.add(names_1.names.RootEl);
144
+ yield `type ${names_1.names.RootEl} = `;
178
145
  for (const type of ctx.singleRootElTypes) {
179
146
  yield `${utils_1.newLine}| ${type}`;
180
147
  }
@@ -1,44 +1,11 @@
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
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.generateInterpolation = generateInterpolation;
37
4
  const shared_1 = require("@vue/shared");
38
5
  const collectBindings_1 = require("../../utils/collectBindings");
39
6
  const shared_2 = require("../../utils/shared");
40
7
  const codeFeatures_1 = require("../codeFeatures");
41
- const names = __importStar(require("../names"));
8
+ const names_1 = require("../names");
42
9
  const utils_1 = require("../utils");
43
10
  // https://github.com/vuejs/core/blob/fb0c3ca519f1fccf52049cd6b8db3a67a669afe9/packages/compiler-core/src/transforms/transformExpression.ts#L47
44
11
  const isLiteralWhitelisted = /*@__PURE__*/ (0, shared_1.makeMap)('true,false,null,this');
@@ -95,11 +62,11 @@ function* forEachInterpolationSegment(ts, setupRefs, ctx, block, originalCode, s
95
62
  else {
96
63
  yield ['', offset, 'errorMappingOnly']; // #1205, #1264
97
64
  if (ctx.dollarVars.has(name)) {
98
- yield names.dollars;
65
+ yield names_1.names.dollars;
99
66
  }
100
67
  else {
101
68
  ctx.recordComponentAccess(block.name, name, start - prefix.length + offset);
102
- yield names.ctx;
69
+ yield names_1.names.ctx;
103
70
  }
104
71
  yield `.`;
105
72
  yield [name, offset, isShorthand ? 'shorthand' : undefined];
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateObjectProperty = generateObjectProperty;
4
4
  const shared_1 = require("@vue/shared");
5
+ const names_1 = require("../names");
5
6
  const utils_1 = require("../utils");
6
7
  const boundary_1 = require("../utils/boundary");
7
8
  const camelized_1 = require("../utils/camelized");
@@ -10,7 +11,7 @@ const interpolation_1 = require("./interpolation");
10
11
  function* generateObjectProperty(options, ctx, code, offset, features, shouldCamelize = false, shouldBeConstant = false) {
11
12
  if (code.startsWith('[') && code.endsWith(']')) {
12
13
  if (shouldBeConstant) {
13
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code.slice(1, -1), offset + 1, `[__VLS_tryAsConstant(`, `)]`);
14
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code.slice(1, -1), offset + 1, `[${names_1.names.tryAsConstant}(`, `)]`);
14
15
  }
15
16
  else {
16
17
  yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code, offset);
@@ -38,7 +38,7 @@ const CompilerDOM = __importStar(require("@vue/compiler-dom"));
38
38
  const shared_1 = require("../../utils/shared");
39
39
  const codeFeatures_1 = require("../codeFeatures");
40
40
  const inlayHints_1 = require("../inlayHints");
41
- const names = __importStar(require("../names"));
41
+ const names_1 = require("../names");
42
42
  const utils_1 = require("../utils");
43
43
  const boundary_1 = require("../utils/boundary");
44
44
  const elementProps_1 = require("./elementProps");
@@ -59,7 +59,7 @@ function* generateSlotOutlet(options, ctx, node) {
59
59
  }
60
60
  });
61
61
  if (options.hasDefineSlots) {
62
- yield `__VLS_asFunctionalSlot(`;
62
+ yield `${names_1.names.asFunctionalSlot}(`;
63
63
  if (nameProp) {
64
64
  let codes;
65
65
  if (nameProp.type === CompilerDOM.NodeTypes.ATTRIBUTE && nameProp.value) {
@@ -78,13 +78,13 @@ function* generateSlotOutlet(options, ctx, node) {
78
78
  codes = [`['default']`];
79
79
  }
80
80
  const token = yield* (0, boundary_1.startBoundary)('template', nameProp.loc.start.offset, codeFeatures_1.codeFeatures.verification);
81
- yield options.slotsAssignName ?? names.slots;
81
+ yield options.slotsAssignName ?? names_1.names.slots;
82
82
  yield* codes;
83
83
  yield (0, boundary_1.endBoundary)(token, nameProp.loc.end.offset);
84
84
  }
85
85
  else {
86
86
  const token = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
87
- yield `${options.slotsAssignName ?? names.slots}[`;
87
+ yield `${options.slotsAssignName ?? names_1.names.slots}[`;
88
88
  const token2 = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
89
89
  yield `'default'`;
90
90
  yield (0, boundary_1.endBoundary)(token2, startTagEndOffset);
@@ -120,7 +120,7 @@ function* generateSlotOutlet(options, ctx, node) {
120
120
  ctx.inlayHints.push((0, inlayHints_1.createVBindShorthandInlayHintInfo)(nameProp.exp.loc, 'name'));
121
121
  }
122
122
  const expVar = ctx.getInternalVariable();
123
- yield `var ${expVar} = __VLS_tryAsConstant(`;
123
+ yield `var ${expVar} = ${names_1.names.tryAsConstant}(`;
124
124
  yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, isShortHand
125
125
  ? codeFeatures_1.codeFeatures.withoutHighlightAndCompletion
126
126
  : codeFeatures_1.codeFeatures.all, nameProp.exp.content, nameProp.exp.loc.start.offset);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.references = void 0;
4
4
  exports.generateStyleScopedClassReference = generateStyleScopedClassReference;
5
5
  const codeFeatures_1 = require("../codeFeatures");
6
+ const names_1 = require("../names");
6
7
  const utils_1 = require("../utils");
7
8
  const boundary_1 = require("../utils/boundary");
8
9
  const escaped_1 = require("../utils/escaped");
@@ -11,7 +12,7 @@ const classNameEscapeRegex = /([\\'])/;
11
12
  exports.references = new WeakMap();
12
13
  function* generateStyleScopedClassReference(block, className, offset, fullStart = offset) {
13
14
  if (!className) {
14
- yield `/** @type {__VLS_StyleScopedClasses['`;
15
+ yield `/** @type {${names_1.names.StyleScopedClasses}['`;
15
16
  yield ['', 'template', offset, codeFeatures_1.codeFeatures.completion];
16
17
  yield `']} */${utils_1.endOfLine}`;
17
18
  return;
@@ -25,7 +26,7 @@ function* generateStyleScopedClassReference(block, className, offset, fullStart
25
26
  else {
26
27
  cache[1].push([className, offset]);
27
28
  }
28
- yield `/** @type {__VLS_StyleScopedClasses[`;
29
+ yield `/** @type {${names_1.names.StyleScopedClasses}[`;
29
30
  const token = yield* (0, boundary_1.startBoundary)(block.name, fullStart, codeFeatures_1.codeFeatures.navigation);
30
31
  yield `'`;
31
32
  yield* (0, escaped_1.generateEscaped)(className, block.name, offset, codeFeatures_1.codeFeatures.navigationAndCompletion, classNameEscapeRegex);
@@ -38,6 +38,7 @@ exports.parseVForNode = parseVForNode;
38
38
  const CompilerDOM = __importStar(require("@vue/compiler-dom"));
39
39
  const collectBindings_1 = require("../../utils/collectBindings");
40
40
  const codeFeatures_1 = require("../codeFeatures");
41
+ const names_1 = require("../names");
41
42
  const utils_1 = require("../utils");
42
43
  const interpolation_1 = require("./interpolation");
43
44
  const templateChild_1 = require("./templateChild");
@@ -58,7 +59,7 @@ function* generateVFor(options, ctx, node) {
58
59
  }
59
60
  yield `] of `;
60
61
  if (source.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
61
- yield `__VLS_vFor(`;
62
+ yield `${names_1.names.vFor}(`;
62
63
  yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, codeFeatures_1.codeFeatures.all, source.content, source.loc.start.offset, `(`, `)`);
63
64
  yield `!)`; // #3102
64
65
  }
@@ -38,6 +38,7 @@ const CompilerDOM = __importStar(require("@vue/compiler-dom"));
38
38
  const muggle_string_1 = require("muggle-string");
39
39
  const collectBindings_1 = require("../../utils/collectBindings");
40
40
  const codeFeatures_1 = require("../codeFeatures");
41
+ const names_1 = require("../names");
41
42
  const utils_1 = require("../utils");
42
43
  const boundary_1 = require("../utils/boundary");
43
44
  const interpolation_1 = require("./interpolation");
@@ -125,7 +126,7 @@ function* generateSlotParameters(options, ctx, ast, exp, slotVar) {
125
126
  }
126
127
  yield `const [`;
127
128
  yield* interpolation;
128
- yield `] = __VLS_vSlot(${slotVar}!`;
129
+ yield `] = ${names_1.names.vSlot}(${slotVar}!`;
129
130
  if (types.some(t => t)) {
130
131
  yield `, `;
131
132
  const token = yield* (0, boundary_1.startBoundary)('template', exp.loc.start.offset, codeFeatures_1.codeFeatures.verification);
@@ -33,8 +33,6 @@ const plugin = ({ vueCompilerOptions }) => {
33
33
  .replace(frontmatterReg, match => ' '.repeat(match.length))
34
34
  // code block
35
35
  .replace(codeblockReg, (match, quotes) => quotes + ' '.repeat(match.length - quotes.length * 2) + quotes)
36
- // inline code block
37
- .replace(inlineCodeblockReg, match => `\`${' '.repeat(match.length - 2)}\``)
38
36
  // latex block
39
37
  .replace(latexBlockReg, (match, quotes) => quotes + ' '.repeat(match.length - quotes.length * 2) + quotes)
40
38
  // # \<script setup>
@@ -50,6 +48,8 @@ const plugin = ({ vueCompilerOptions }) => {
50
48
  + content.slice(match.index + matchText.length);
51
49
  }
52
50
  content = content
51
+ // inline code block
52
+ .replace(inlineCodeblockReg, match => `\`${' '.repeat(match.length - 2)}\``)
53
53
  // angle bracket: <http://foo.com>
54
54
  .replace(angleBracketReg, match => ' '.repeat(match.length))
55
55
  // [foo](http://foo.com)
@@ -206,28 +206,11 @@ function useCodegen(ts, vueCompilerOptions, fileName, sfc) {
206
206
  if (!allVars.size) {
207
207
  return allVars;
208
208
  }
209
- const exposedNames = new Set();
210
- const generatedTemplate = getGeneratedTemplate();
211
- const generatedStyle = getGeneratedStyle();
212
- for (const [name] of generatedTemplate?.componentAccessMap ?? []) {
213
- if (allVars.has(name)) {
214
- exposedNames.add(name);
215
- }
216
- }
217
- for (const [name] of generatedStyle?.componentAccessMap ?? []) {
218
- if (allVars.has(name)) {
219
- exposedNames.add(name);
220
- }
221
- }
222
- for (const component of sfc.template?.ast?.components ?? []) {
223
- const testNames = new Set([(0, shared_1.camelize)(component), (0, shared_1.capitalize)((0, shared_1.camelize)(component))]);
224
- for (const testName of testNames) {
225
- if (allVars.has(testName)) {
226
- exposedNames.add(testName);
227
- }
228
- }
229
- }
230
- return exposedNames;
209
+ return new Set([
210
+ ...getGeneratedTemplate()?.componentAccessMap.keys() ?? [],
211
+ ...getGeneratedStyle()?.componentAccessMap.keys() ?? [],
212
+ ...sfc.template?.ast?.components.flatMap(name => [(0, shared_1.camelize)(name), (0, shared_1.capitalize)((0, shared_1.camelize)(name))]) ?? [],
213
+ ].filter(name => allVars.has(name)));
231
214
  });
232
215
  const getGeneratedScript = (0, alien_signals_1.computed)(() => {
233
216
  return (0, script_1.generateScript)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "3.2.7",
3
+ "version": "3.2.8",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,6 +12,9 @@
12
12
  "url": "https://github.com/vuejs/language-tools.git",
13
13
  "directory": "packages/language-core"
14
14
  },
15
+ "scripts": {
16
+ "generate-names": "node scripts/generate-names.js"
17
+ },
15
18
  "dependencies": {
16
19
  "@volar/language-core": "2.4.28",
17
20
  "@vue/compiler-dom": "^3.5.0",
@@ -28,5 +31,5 @@
28
31
  "@volar/typescript": "2.4.28",
29
32
  "@vue/compiler-sfc": "^3.5.0"
30
33
  },
31
- "gitHead": "a7092edf12862f0db8e39bd2afbda3d54aa26506"
34
+ "gitHead": "618bd6bfb19729726787df7b52fccda72c888c95"
32
35
  }
@@ -0,0 +1,41 @@
1
+ // @ts-check
2
+ const { readFile, writeFile } = require('node:fs/promises');
3
+ const { join } = require('node:path');
4
+
5
+ generateNames();
6
+
7
+ async function generateNames() {
8
+ const typePath = join(__dirname, '../types/template-helpers.d.ts');
9
+ const typeText = await readFile(typePath, 'utf-8');
10
+
11
+ /** @type {Set<string>} */
12
+ const pascalNames = new Set();
13
+ /** @type {Set<string>} */
14
+ const camelNames = new Set();
15
+
16
+ const declReg = /(?<=const\s+)\w*?(?=:)|(?<=type\s+)\w*?(?=\s*=|<)|(?<=function\s+)\w*?(?=\(|<)/g;
17
+ const prefix = '__VLS_';
18
+
19
+ for (const match of typeText.matchAll(declReg)) {
20
+ const name = match[0].slice(prefix.length);
21
+ if (name[0]?.toUpperCase() === name[0]) {
22
+ pascalNames.add(name);
23
+ }
24
+ else {
25
+ camelNames.add(name);
26
+ }
27
+ }
28
+
29
+ const namesPath = join(__dirname, '../lib/codegen/names.ts');
30
+ const namesText = await readFile(namesPath, 'utf-8');
31
+
32
+ await writeFile(
33
+ namesPath,
34
+ namesText.replace(
35
+ /(?<=\/\/ #region .*\n).*?(?=\t\/\/ #endregion)/ms,
36
+ [...camelNames].sort().map(name => `\t${name}: '',\n`).join('')
37
+ + '\n'
38
+ + [...pascalNames].sort().map(name => `\t${name}: '',\n`).join(''),
39
+ ),
40
+ );
41
+ }