@vue/language-core 3.1.5 → 3.1.6

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.
Files changed (100) hide show
  1. package/index.d.ts +2 -1
  2. package/index.js +3 -2
  3. package/lib/codegen/codeFeatures.d.ts +5 -9
  4. package/lib/codegen/codeFeatures.js +5 -5
  5. package/lib/codegen/globalTypes.js +12 -18
  6. package/lib/codegen/localTypes.d.ts +1 -1
  7. package/lib/codegen/localTypes.js +6 -6
  8. package/lib/codegen/names.d.ts +30 -0
  9. package/lib/codegen/names.js +34 -0
  10. package/lib/codegen/script/component.js +45 -54
  11. package/lib/codegen/script/context.d.ts +2 -5
  12. package/lib/codegen/script/context.js +1 -7
  13. package/lib/codegen/script/index.d.ts +10 -12
  14. package/lib/codegen/script/index.js +74 -73
  15. package/lib/codegen/script/scriptSetup.d.ts +3 -2
  16. package/lib/codegen/script/scriptSetup.js +209 -283
  17. package/lib/codegen/script/src.js +9 -3
  18. package/lib/codegen/script/template.js +64 -108
  19. package/lib/codegen/style/common.d.ts +3 -0
  20. package/lib/codegen/style/common.js +43 -0
  21. package/lib/codegen/style/index.d.ts +63 -0
  22. package/lib/codegen/style/index.js +38 -0
  23. package/lib/codegen/style/modules.d.ts +3 -2
  24. package/lib/codegen/style/modules.js +12 -11
  25. package/lib/codegen/style/scopedClasses.d.ts +2 -3
  26. package/lib/codegen/style/scopedClasses.js +23 -21
  27. package/lib/codegen/template/context.d.ts +7 -16
  28. package/lib/codegen/template/context.js +81 -93
  29. package/lib/codegen/template/element.js +151 -55
  30. package/lib/codegen/template/elementDirectives.js +32 -12
  31. package/lib/codegen/template/elementEvents.js +27 -28
  32. package/lib/codegen/template/elementProps.d.ts +2 -2
  33. package/lib/codegen/template/elementProps.js +49 -23
  34. package/lib/codegen/template/index.d.ts +8 -19
  35. package/lib/codegen/template/index.js +85 -80
  36. package/lib/codegen/template/interpolation.d.ts +3 -3
  37. package/lib/codegen/template/interpolation.js +90 -136
  38. package/lib/codegen/template/objectProperty.js +8 -4
  39. package/lib/codegen/template/propertyAccess.d.ts +1 -1
  40. package/lib/codegen/template/propertyAccess.js +5 -7
  41. package/lib/codegen/template/slotOutlet.js +25 -8
  42. package/lib/codegen/template/styleScopedClasses.d.ts +3 -6
  43. package/lib/codegen/template/styleScopedClasses.js +23 -149
  44. package/lib/codegen/template/templateChild.d.ts +0 -1
  45. package/lib/codegen/template/templateChild.js +11 -68
  46. package/lib/codegen/template/vFor.js +10 -13
  47. package/lib/codegen/template/vIf.js +5 -3
  48. package/lib/codegen/template/vSlot.js +20 -15
  49. package/lib/codegen/utils/boundary.d.ts +3 -0
  50. package/lib/codegen/utils/boundary.js +13 -0
  51. package/lib/codegen/utils/camelized.js +3 -3
  52. package/lib/codegen/utils/escaped.js +4 -2
  53. package/lib/codegen/utils/index.d.ts +3 -4
  54. package/lib/codegen/utils/index.js +42 -16
  55. package/lib/codegen/utils/merge.d.ts +2 -2
  56. package/lib/codegen/utils/merge.js +9 -9
  57. package/lib/codegen/utils/stringLiteralKey.js +6 -3
  58. package/lib/codegen/utils/transform.d.ts +8 -0
  59. package/lib/codegen/utils/transform.js +27 -0
  60. package/lib/codegen/utils/unicode.js +4 -2
  61. package/lib/compilerOptions.d.ts +5 -2
  62. package/lib/compilerOptions.js +67 -44
  63. package/lib/languagePlugin.d.ts +1 -1
  64. package/lib/languagePlugin.js +2 -2
  65. package/lib/plugins/vue-template-inline-css.js +2 -6
  66. package/lib/plugins/vue-template-inline-ts.js +12 -14
  67. package/lib/plugins/vue-tsx.d.ts +11 -20
  68. package/lib/plugins/vue-tsx.js +121 -68
  69. package/lib/plugins.js +1 -1
  70. package/lib/types.d.ts +5 -4
  71. package/lib/utils/parseSfc.js +7 -3
  72. package/lib/utils/shared.d.ts +1 -1
  73. package/lib/utils/shared.js +7 -6
  74. package/lib/utils/signals.d.ts +2 -2
  75. package/lib/utils/signals.js +8 -6
  76. package/lib/virtualCode/embeddedCodes.d.ts +12 -0
  77. package/lib/virtualCode/embeddedCodes.js +249 -0
  78. package/lib/{virtualFile/vueFile.d.ts → virtualCode/index.d.ts} +9 -9
  79. package/lib/virtualCode/index.js +81 -0
  80. package/lib/virtualCode/ir.d.ts +4 -0
  81. package/lib/{virtualFile/computedSfc.js → virtualCode/ir.js} +59 -94
  82. package/lib/virtualCode/normalize.d.ts +2 -0
  83. package/lib/virtualCode/normalize.js +170 -0
  84. package/package.json +4 -4
  85. package/lib/codegen/style/classProperty.d.ts +0 -2
  86. package/lib/codegen/style/classProperty.js +0 -18
  87. package/lib/codegen/style/imports.d.ts +0 -2
  88. package/lib/codegen/style/imports.js +0 -27
  89. package/lib/codegen/template/elementChildren.d.ts +0 -5
  90. package/lib/codegen/template/elementChildren.js +0 -12
  91. package/lib/codegen/utils/wrapWith.d.ts +0 -2
  92. package/lib/codegen/utils/wrapWith.js +0 -15
  93. package/lib/virtualFile/computedEmbeddedCodes.d.ts +0 -4
  94. package/lib/virtualFile/computedEmbeddedCodes.js +0 -262
  95. package/lib/virtualFile/computedSfc.d.ts +0 -6
  96. package/lib/virtualFile/computedVueSfc.d.ts +0 -4
  97. package/lib/virtualFile/computedVueSfc.js +0 -41
  98. package/lib/virtualFile/embeddedFile.d.ts +0 -11
  99. package/lib/virtualFile/embeddedFile.js +0 -14
  100. package/lib/virtualFile/vueFile.js +0 -49
@@ -5,12 +5,12 @@ const shared_1 = require("@vue/shared");
5
5
  const collectBindings_1 = require("../../utils/collectBindings");
6
6
  const shared_2 = require("../../utils/shared");
7
7
  const codeFeatures_1 = require("../codeFeatures");
8
+ const names = require("../names");
8
9
  const utils_1 = require("../utils");
9
10
  // https://github.com/vuejs/core/blob/fb0c3ca519f1fccf52049cd6b8db3a67a669afe9/packages/compiler-core/src/transforms/transformExpression.ts#L47
10
11
  const isLiteralWhitelisted = /*@__PURE__*/ (0, shared_1.makeMap)('true,false,null,this');
11
- function* generateInterpolation(options, ctx, source, data, code, start, prefix = '', suffix = '') {
12
- const { ts, destructuredPropNames, templateRefNames, } = options;
13
- for (const segment of forEachInterpolationSegment(ts, ctx.inlineTsAsts, destructuredPropNames, templateRefNames, ctx, code, start, prefix, suffix)) {
12
+ function* generateInterpolation(options, ctx, block, data, code, start, prefix = '', suffix = '') {
13
+ for (const segment of forEachInterpolationSegment(options, ctx, block, code, start, prefix, suffix)) {
14
14
  if (typeof segment === 'string') {
15
15
  yield segment;
16
16
  continue;
@@ -28,222 +28,176 @@ function* generateInterpolation(options, ctx, source, data, code, start, prefix
28
28
  section = section.slice(-offset);
29
29
  offset = 0;
30
30
  }
31
- const shouldSkip = section.length === 0 && (type === 'startText' || type === 'endText');
31
+ const shouldSkip = section.length === 0 && type === 'startEnd';
32
32
  if (!shouldSkip) {
33
- if (start !== undefined && data) {
34
- yield [
35
- section,
36
- source,
37
- start + offset,
38
- type === 'errorMappingOnly'
39
- ? codeFeatures_1.codeFeatures.verification
40
- : typeof data === 'function'
41
- ? data(start + offset)
42
- : data,
43
- ];
44
- }
45
- else {
46
- yield section;
47
- }
33
+ yield [
34
+ section,
35
+ block.name,
36
+ start + offset,
37
+ type === 'errorMappingOnly'
38
+ ? codeFeatures_1.codeFeatures.verification
39
+ : data,
40
+ ];
48
41
  }
49
42
  yield addSuffix;
50
43
  }
51
44
  }
52
- function* forEachInterpolationSegment(ts, inlineTsAsts, destructuredPropNames, templateRefNames, ctx, originalCode, start, prefix, suffix) {
45
+ function* forEachInterpolationSegment({ ts, setupRefs }, ctx, block, originalCode, start, prefix, suffix) {
53
46
  const code = prefix + originalCode + suffix;
54
- const offset = start !== undefined ? start - prefix.length : undefined;
55
- let ctxVars = [];
56
- if (utils_1.identifierRegex.test(originalCode) && !shouldIdentifierSkipped(ctx, originalCode, destructuredPropNames)) {
57
- ctxVars.push({
58
- text: originalCode,
59
- offset: prefix.length,
60
- });
61
- }
62
- else {
63
- const ast = (0, utils_1.createTsAst)(ts, inlineTsAsts, code);
64
- const varCb = (id, isShorthand) => {
65
- const text = (0, shared_2.getNodeText)(ts, id, ast);
66
- if (!shouldIdentifierSkipped(ctx, text, destructuredPropNames)) {
67
- ctxVars.push({
68
- text,
69
- offset: (0, shared_2.getStartEnd)(ts, id, ast).start,
70
- isShorthand,
71
- });
72
- }
73
- };
74
- ts.forEachChild(ast, node => walkIdentifiers(ts, node, ast, varCb, ctx, [], true));
75
- }
76
- ctxVars = ctxVars.sort((a, b) => a.offset - b.offset);
77
- if (ctxVars.length) {
78
- for (let i = 0; i < ctxVars.length; i++) {
79
- const lastVar = ctxVars[i - 1];
80
- const curVar = ctxVars[i];
81
- const lastVarEnd = lastVar ? lastVar.offset + lastVar.text.length : 0;
82
- if (curVar.isShorthand) {
83
- yield [code.slice(lastVarEnd, curVar.offset + curVar.text.length), lastVarEnd];
84
- yield `: `;
47
+ let prevEnd = 0;
48
+ for (const [name, offset, isShorthand] of forEachIdentifiers(ts, ctx, block, originalCode, code, prefix)) {
49
+ if (isShorthand) {
50
+ yield [code.slice(prevEnd, offset + name.length), prevEnd];
51
+ yield `: `;
52
+ }
53
+ else {
54
+ yield [code.slice(prevEnd, offset), prevEnd, prevEnd > 0 ? undefined : 'startEnd'];
55
+ }
56
+ if (setupRefs.has(name)) {
57
+ yield [name, offset];
58
+ yield `.value`;
59
+ }
60
+ else {
61
+ yield ['', offset, 'errorMappingOnly']; // #1205, #1264
62
+ if (ctx.dollarVars.has(name)) {
63
+ yield names.dollars;
85
64
  }
86
65
  else {
87
- yield [code.slice(lastVarEnd, curVar.offset), lastVarEnd, i ? undefined : 'startText'];
66
+ ctx.recordComponentAccess(block.name, name, start - prefix.length + offset);
67
+ yield names.ctx;
88
68
  }
89
- yield* generateVar(templateRefNames, ctx, code, offset, curVar);
90
- }
91
- const lastVar = ctxVars.at(-1);
92
- if (lastVar.offset + lastVar.text.length < code.length) {
93
- yield [code.slice(lastVar.offset + lastVar.text.length), lastVar.offset + lastVar.text.length, 'endText'];
69
+ yield `.`;
70
+ yield [name, offset];
94
71
  }
72
+ prevEnd = offset + name.length;
95
73
  }
96
- else {
97
- yield [code, 0];
74
+ if (prevEnd < code.length) {
75
+ yield [code.slice(prevEnd), prevEnd, 'startEnd'];
98
76
  }
99
77
  }
100
- function* generateVar(templateRefNames, ctx, code, offset, curVar) {
101
- // fix https://github.com/vuejs/language-tools/issues/1205
102
- // fix https://github.com/vuejs/language-tools/issues/1264
103
- yield ['', curVar.offset, 'errorMappingOnly'];
104
- const isTemplateRef = templateRefNames?.has(curVar.text) ?? false;
105
- if (isTemplateRef) {
106
- yield `__VLS_unref(`;
107
- yield [code.slice(curVar.offset, curVar.offset + curVar.text.length), curVar.offset];
108
- yield `)`;
109
- }
110
- else {
111
- if (offset !== undefined) {
112
- ctx.accessExternalVariable(curVar.text, offset + curVar.offset);
113
- }
114
- else {
115
- ctx.accessExternalVariable(curVar.text);
116
- }
117
- if (ctx.dollarVars.has(curVar.text)) {
118
- yield `__VLS_dollars.`;
119
- }
120
- else {
121
- yield `__VLS_ctx.`;
78
+ function* forEachIdentifiers(ts, ctx, block, originalCode, code, prefix) {
79
+ if (utils_1.identifierRegex.test(originalCode) && !shouldIdentifierSkipped(ctx, originalCode)) {
80
+ yield [originalCode, prefix.length, false];
81
+ return;
82
+ }
83
+ const endScope = ctx.startScope();
84
+ const ast = (0, utils_1.getTypeScriptAST)(ts, block, code);
85
+ for (const [id, isShorthand] of forEachDeclarations(ts, ast, ast, ctx)) {
86
+ const text = (0, shared_2.getNodeText)(ts, id, ast);
87
+ if (shouldIdentifierSkipped(ctx, text)) {
88
+ continue;
122
89
  }
123
- yield [code.slice(curVar.offset, curVar.offset + curVar.text.length), curVar.offset];
90
+ yield [text, (0, shared_2.getStartEnd)(ts, id, ast).start, isShorthand];
124
91
  }
92
+ endScope();
125
93
  }
126
- function walkIdentifiers(ts, node, ast, cb, ctx, blockVars, isRoot = false) {
94
+ function* forEachDeclarations(ts, node, ast, ctx) {
127
95
  if (ts.isIdentifier(node)) {
128
- cb(node, false);
96
+ yield [node, false];
129
97
  }
130
98
  else if (ts.isShorthandPropertyAssignment(node)) {
131
- cb(node.name, true);
99
+ yield [node.name, true];
132
100
  }
133
101
  else if (ts.isPropertyAccessExpression(node)) {
134
- walkIdentifiers(ts, node.expression, ast, cb, ctx, blockVars);
102
+ yield* forEachDeclarations(ts, node.expression, ast, ctx);
135
103
  }
136
104
  else if (ts.isVariableDeclaration(node)) {
137
- const bindingNames = (0, collectBindings_1.collectBindingNames)(ts, node.name, ast);
138
- for (const name of bindingNames) {
139
- ctx.addLocalVariable(name);
140
- blockVars.push(name);
141
- }
142
- walkIdentifiersInBinding(ts, node, ast, cb, ctx, blockVars);
105
+ ctx.declare(...(0, collectBindings_1.collectBindingNames)(ts, node.name, ast));
106
+ yield* forEachDeclarationsInBinding(ts, node, ast, ctx);
143
107
  }
144
108
  else if (ts.isArrayBindingPattern(node) || ts.isObjectBindingPattern(node)) {
145
109
  for (const element of node.elements) {
146
110
  if (ts.isBindingElement(element)) {
147
- walkIdentifiersInBinding(ts, element, ast, cb, ctx, blockVars);
111
+ yield* forEachDeclarationsInBinding(ts, element, ast, ctx);
148
112
  }
149
113
  }
150
114
  }
151
115
  else if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
152
- walkIdentifiersInFunction(ts, node, ast, cb, ctx);
116
+ yield* forEachDeclarationsInFunction(ts, node, ast, ctx);
153
117
  }
154
118
  else if (ts.isObjectLiteralExpression(node)) {
155
119
  for (const prop of node.properties) {
156
120
  if (ts.isPropertyAssignment(prop)) {
157
121
  // fix https://github.com/vuejs/language-tools/issues/1176
158
122
  if (ts.isComputedPropertyName(prop.name)) {
159
- walkIdentifiers(ts, prop.name.expression, ast, cb, ctx, blockVars);
123
+ yield* forEachDeclarations(ts, prop.name.expression, ast, ctx);
160
124
  }
161
- walkIdentifiers(ts, prop.initializer, ast, cb, ctx, blockVars);
125
+ yield* forEachDeclarations(ts, prop.initializer, ast, ctx);
162
126
  }
163
127
  // fix https://github.com/vuejs/language-tools/issues/1156
164
128
  else if (ts.isShorthandPropertyAssignment(prop)) {
165
- walkIdentifiers(ts, prop, ast, cb, ctx, blockVars);
129
+ yield* forEachDeclarations(ts, prop, ast, ctx);
166
130
  }
167
131
  // fix https://github.com/vuejs/language-tools/issues/1148#issuecomment-1094378126
168
132
  else if (ts.isSpreadAssignment(prop)) {
169
133
  // TODO: cannot report "Spread types may only be created from object types.ts(2698)"
170
- walkIdentifiers(ts, prop.expression, ast, cb, ctx, blockVars);
134
+ yield* forEachDeclarations(ts, prop.expression, ast, ctx);
171
135
  }
172
136
  // fix https://github.com/vuejs/language-tools/issues/4604
173
137
  else if (ts.isFunctionLike(prop) && prop.body) {
174
- walkIdentifiersInFunction(ts, prop, ast, cb, ctx);
138
+ yield* forEachDeclarationsInFunction(ts, prop, ast, ctx);
175
139
  }
176
140
  }
177
141
  }
178
142
  // fix https://github.com/vuejs/language-tools/issues/1422
179
143
  else if (ts.isTypeNode(node)) {
180
- walkIdentifiersInTypeNode(ts, node, cb);
144
+ yield* forEachDeclarationsInTypeNode(ts, node);
181
145
  }
182
- else {
183
- const _blockVars = blockVars;
184
- if (ts.isBlock(node)) {
185
- blockVars = [];
186
- }
187
- ts.forEachChild(node, node => walkIdentifiers(ts, node, ast, cb, ctx, blockVars));
188
- if (ts.isBlock(node)) {
189
- for (const varName of blockVars) {
190
- ctx.removeLocalVariable(varName);
191
- }
146
+ else if (ts.isBlock(node)) {
147
+ const endScope = ctx.startScope();
148
+ for (const child of (0, utils_1.forEachNode)(ts, node)) {
149
+ yield* forEachDeclarations(ts, child, ast, ctx);
192
150
  }
193
- blockVars = _blockVars;
151
+ endScope();
194
152
  }
195
- if (isRoot) {
196
- for (const varName of blockVars) {
197
- ctx.removeLocalVariable(varName);
153
+ else {
154
+ for (const child of (0, utils_1.forEachNode)(ts, node)) {
155
+ yield* forEachDeclarations(ts, child, ast, ctx);
198
156
  }
199
157
  }
200
158
  }
201
- function walkIdentifiersInBinding(ts, node, ast, cb, ctx, blockVars) {
159
+ function* forEachDeclarationsInBinding(ts, node, ast, ctx) {
202
160
  if ('type' in node && node.type) {
203
- walkIdentifiersInTypeNode(ts, node.type, cb);
161
+ yield* forEachDeclarationsInTypeNode(ts, node.type);
204
162
  }
205
163
  if (!ts.isIdentifier(node.name)) {
206
- walkIdentifiers(ts, node.name, ast, cb, ctx, blockVars);
164
+ yield* forEachDeclarations(ts, node.name, ast, ctx);
207
165
  }
208
166
  if (node.initializer) {
209
- walkIdentifiers(ts, node.initializer, ast, cb, ctx, blockVars);
167
+ yield* forEachDeclarations(ts, node.initializer, ast, ctx);
210
168
  }
211
169
  }
212
- function walkIdentifiersInFunction(ts, node, ast, cb, ctx) {
213
- const functionArgs = [];
170
+ function* forEachDeclarationsInFunction(ts, node, ast, ctx) {
171
+ const endScope = ctx.startScope();
214
172
  for (const param of node.parameters) {
215
- functionArgs.push(...(0, collectBindings_1.collectBindingNames)(ts, param.name, ast));
216
- walkIdentifiersInBinding(ts, param, ast, cb, ctx, functionArgs);
217
- }
218
- for (const varName of functionArgs) {
219
- ctx.addLocalVariable(varName);
173
+ ctx.declare(...(0, collectBindings_1.collectBindingNames)(ts, param.name, ast));
174
+ yield* forEachDeclarationsInBinding(ts, param, ast, ctx);
220
175
  }
221
176
  if (node.body) {
222
- walkIdentifiers(ts, node.body, ast, cb, ctx, [], true);
223
- }
224
- for (const varName of functionArgs) {
225
- ctx.removeLocalVariable(varName);
177
+ yield* forEachDeclarations(ts, node.body, ast, ctx);
226
178
  }
179
+ endScope();
227
180
  }
228
- function walkIdentifiersInTypeNode(ts, node, cb) {
181
+ function* forEachDeclarationsInTypeNode(ts, node) {
229
182
  if (ts.isTypeQueryNode(node)) {
230
183
  let id = node.exprName;
231
184
  while (!ts.isIdentifier(id)) {
232
185
  id = id.left;
233
186
  }
234
- cb(id, false);
187
+ yield [id, false];
235
188
  }
236
189
  else {
237
- ts.forEachChild(node, node => walkIdentifiersInTypeNode(ts, node, cb));
190
+ for (const child of (0, utils_1.forEachNode)(ts, node)) {
191
+ yield* forEachDeclarationsInTypeNode(ts, child);
192
+ }
238
193
  }
239
194
  }
240
- function shouldIdentifierSkipped(ctx, text, destructuredPropNames) {
241
- return ctx.hasLocalVariable(text)
195
+ function shouldIdentifierSkipped(ctx, text) {
196
+ return ctx.scopes.some(scope => scope.has(text))
242
197
  // https://github.com/vuejs/core/blob/245230e135152900189f13a4281302de45fdcfaa/packages/compiler-core/src/transforms/transformExpression.ts#L342-L352
243
198
  || (0, shared_1.isGloballyAllowed)(text)
244
199
  || isLiteralWhitelisted(text)
245
200
  || text === 'require'
246
- || text.startsWith('__VLS_')
247
- || destructuredPropNames?.has(text);
201
+ || text.startsWith('__VLS_');
248
202
  }
249
203
  //# sourceMappingURL=interpolation.js.map
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateObjectProperty = generateObjectProperty;
4
4
  const shared_1 = require("@vue/shared");
5
5
  const utils_1 = require("../utils");
6
+ const boundary_1 = require("../utils/boundary");
6
7
  const camelized_1 = require("../utils/camelized");
7
8
  const stringLiteralKey_1 = require("../utils/stringLiteralKey");
8
- const wrapWith_1 = require("../utils/wrapWith");
9
9
  const interpolation_1 = require("./interpolation");
10
10
  function* generateObjectProperty(options, ctx, code, offset, features, shouldCamelize = false, shouldBeConstant = false) {
11
11
  if (code.startsWith('[') && code.endsWith(']')) {
12
12
  if (shouldBeConstant) {
13
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', features, code.slice(1, -1), offset + 1, `[__VLS_tryAsConstant(`, `)]`);
13
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code.slice(1, -1), offset + 1, `[__VLS_tryAsConstant(`, `)]`);
14
14
  }
15
15
  else {
16
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', features, code, offset);
16
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code, offset);
17
17
  }
18
18
  }
19
19
  else if (shouldCamelize) {
@@ -21,7 +21,11 @@ function* generateObjectProperty(options, ctx, code, offset, features, shouldCam
21
21
  yield* (0, camelized_1.generateCamelized)(code, 'template', offset, features);
22
22
  }
23
23
  else {
24
- yield* (0, wrapWith_1.wrapWith)('template', offset, offset + code.length, features, `'`, ...(0, camelized_1.generateCamelized)(code, 'template', offset, utils_1.combineLastMapping), `'`);
24
+ const token = yield* (0, boundary_1.startBoundary)('template', offset, features);
25
+ yield `'`;
26
+ yield* (0, camelized_1.generateCamelized)(code, 'template', offset, { __combineToken: token });
27
+ yield `'`;
28
+ yield (0, boundary_1.endBoundary)(token, offset + code.length);
25
29
  }
26
30
  }
27
31
  else {
@@ -1,4 +1,4 @@
1
1
  import type { Code, VueCodeInformation } from '../../types';
2
2
  import type { TemplateCodegenContext } from './context';
3
3
  import type { TemplateCodegenOptions } from './index';
4
- export declare function generatePropertyAccess(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, code: string, offset?: number, features?: VueCodeInformation): Generator<Code>;
4
+ export declare function generatePropertyAccess(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, code: string, offset: number, features: VueCodeInformation): Generator<Code>;
@@ -5,14 +5,12 @@ const utils_1 = require("../utils");
5
5
  const stringLiteralKey_1 = require("../utils/stringLiteralKey");
6
6
  const interpolation_1 = require("./interpolation");
7
7
  function* generatePropertyAccess(options, ctx, code, offset, features) {
8
- if (!options.compilerOptions.noPropertyAccessFromIndexSignature && utils_1.identifierRegex.test(code)) {
9
- yield `.`;
10
- yield offset !== undefined && features
11
- ? [code, 'template', offset, features]
12
- : code;
8
+ if (code.startsWith('[') && code.endsWith(']')) {
9
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code, offset);
13
10
  }
14
- else if (code.startsWith('[') && code.endsWith(']')) {
15
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', features, code, offset);
11
+ else if (utils_1.identifierRegex.test(code)) {
12
+ yield `.`;
13
+ yield [code, 'template', offset, features];
16
14
  }
17
15
  else {
18
16
  yield `[`;
@@ -5,12 +5,13 @@ const CompilerDOM = require("@vue/compiler-dom");
5
5
  const shared_1 = require("../../utils/shared");
6
6
  const codeFeatures_1 = require("../codeFeatures");
7
7
  const inlayHints_1 = require("../inlayHints");
8
+ const names = require("../names");
8
9
  const utils_1 = require("../utils");
9
- const wrapWith_1 = require("../utils/wrapWith");
10
- const elementChildren_1 = require("./elementChildren");
10
+ const boundary_1 = require("../utils/boundary");
11
11
  const elementProps_1 = require("./elementProps");
12
12
  const interpolation_1 = require("./interpolation");
13
13
  const propertyAccess_1 = require("./propertyAccess");
14
+ const templateChild_1 = require("./templateChild");
14
15
  function* generateSlotOutlet(options, ctx, node) {
15
16
  const [startTagOffset] = (0, shared_1.getElementTagOffsets)(node, options.template);
16
17
  const startTagEndOffset = startTagOffset + node.tag.length;
@@ -29,7 +30,8 @@ function* generateSlotOutlet(options, ctx, node) {
29
30
  if (nameProp) {
30
31
  let codes;
31
32
  if (nameProp.type === CompilerDOM.NodeTypes.ATTRIBUTE && nameProp.value) {
32
- codes = (0, propertyAccess_1.generatePropertyAccess)(options, ctx, nameProp.value.content, (0, shared_1.getAttributeValueOffset)(nameProp.value), codeFeatures_1.codeFeatures.navigationAndVerification);
33
+ const [content, offset] = (0, shared_1.normalizeAttributeValue)(nameProp.value);
34
+ codes = (0, propertyAccess_1.generatePropertyAccess)(options, ctx, content, offset, codeFeatures_1.codeFeatures.navigationAndVerification);
33
35
  }
34
36
  else if (nameProp.type === CompilerDOM.NodeTypes.DIRECTIVE
35
37
  && nameProp.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
@@ -42,13 +44,26 @@ function* generateSlotOutlet(options, ctx, node) {
42
44
  else {
43
45
  codes = [`['default']`];
44
46
  }
45
- yield* (0, wrapWith_1.wrapWith)('template', nameProp.loc.start.offset, nameProp.loc.end.offset, codeFeatures_1.codeFeatures.verification, options.slotsAssignName ?? '__VLS_slots', ...codes);
47
+ const token = yield* (0, boundary_1.startBoundary)('template', nameProp.loc.start.offset, codeFeatures_1.codeFeatures.verification);
48
+ yield options.slotsAssignName ?? names.slots;
49
+ yield* codes;
50
+ yield (0, boundary_1.endBoundary)(token, nameProp.loc.end.offset);
46
51
  }
47
52
  else {
48
- yield* (0, wrapWith_1.wrapWith)('template', startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification, `${options.slotsAssignName ?? '__VLS_slots'}[`, ...(0, wrapWith_1.wrapWith)('template', startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification, `'default'`), `]`);
53
+ const token = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
54
+ yield `${options.slotsAssignName ?? names.slots}[`;
55
+ const token2 = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
56
+ yield `'default'`;
57
+ yield (0, boundary_1.endBoundary)(token2, startTagEndOffset);
58
+ yield `]`;
59
+ yield (0, boundary_1.endBoundary)(token, startTagEndOffset);
49
60
  }
50
61
  yield `)(`;
51
- yield* (0, wrapWith_1.wrapWith)('template', startTagOffset, startTagEndOffset, codeFeatures_1.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, node.props.filter(prop => prop !== nameProp), true), `}`);
62
+ const token = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
63
+ yield `{${utils_1.newLine}`;
64
+ yield* (0, elementProps_1.generateElementProps)(options, ctx, node, node.props.filter(prop => prop !== nameProp), true);
65
+ yield `}`;
66
+ yield (0, boundary_1.endBoundary)(token, startTagEndOffset);
52
67
  yield `)${utils_1.endOfLine}`;
53
68
  }
54
69
  else {
@@ -73,7 +88,7 @@ function* generateSlotOutlet(options, ctx, node) {
73
88
  }
74
89
  const expVar = ctx.getInternalVariable();
75
90
  yield `var ${expVar} = __VLS_tryAsConstant(`;
76
- yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', codeFeatures_1.codeFeatures.all, nameProp.exp.content, nameProp.exp.loc.start.offset);
91
+ yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, codeFeatures_1.codeFeatures.all, nameProp.exp.content, nameProp.exp.loc.start.offset);
77
92
  yield `)${utils_1.endOfLine}`;
78
93
  ctx.dynamicSlots.push({
79
94
  expVar: ctx.getHoistVariable(expVar),
@@ -89,6 +104,8 @@ function* generateSlotOutlet(options, ctx, node) {
89
104
  });
90
105
  }
91
106
  }
92
- yield* (0, elementChildren_1.generateElementChildren)(options, ctx, node.children);
107
+ for (const child of node.children) {
108
+ yield* (0, templateChild_1.generateTemplateChild)(options, ctx, child);
109
+ }
93
110
  }
94
111
  //# sourceMappingURL=slotOutlet.js.map
@@ -1,6 +1,3 @@
1
- import * as CompilerDOM from '@vue/compiler-dom';
2
- import type { Code } from '../../types';
3
- import type { TemplateCodegenContext } from './context';
4
- import type { TemplateCodegenOptions } from './index';
5
- export declare function generateStyleScopedClassReferences(ctx: TemplateCodegenContext, withDot?: boolean): Generator<Code>;
6
- export declare function collectStyleScopedClassReferences(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode): void;
1
+ import type { Code, SfcBlock } from '../../types';
2
+ export declare const references: WeakMap<SfcBlock, [version: string, [className: string, offset: number][]]>;
3
+ export declare function generateStyleScopedClassReference(block: SfcBlock, className: string, offset: number, fullStart?: number): Generator<Code>;