@vue/language-core 3.3.1 → 3.3.2

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.
@@ -210,7 +210,7 @@ function* generatePropExp(options, ctx, prop, exp) {
210
210
  ...codeFeatures_1.codeFeatures.withoutHighlightAndCompletion,
211
211
  __shorthandExpression: 'html',
212
212
  });
213
- if (ctx.scopes.some(scope => scope.has(propVariableName))) {
213
+ if ((0, interpolation_1.shouldIdentifierSkipped)(ctx, propVariableName)) {
214
214
  yield* codes;
215
215
  }
216
216
  else if (options.setupRefs.has(propVariableName)) {
@@ -4,3 +4,4 @@ export declare function generateInterpolation({ typescript, setupRefs }: {
4
4
  typescript: typeof import('typescript');
5
5
  setupRefs: Set<string>;
6
6
  }, ctx: TemplateCodegenContext, block: IRBlock, data: VueCodeInformation, code: string, start: number, prefix?: string, suffix?: string): Generator<Code>;
7
+ export declare function shouldIdentifierSkipped(ctx: TemplateCodegenContext, text: string): boolean;
@@ -1,95 +1,96 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateInterpolation = generateInterpolation;
4
+ exports.shouldIdentifierSkipped = shouldIdentifierSkipped;
4
5
  const shared_1 = require("@vue/shared");
5
6
  const collectBindings_1 = require("../../utils/collectBindings");
6
7
  const shared_2 = require("../../utils/shared");
7
8
  const codeFeatures_1 = require("../codeFeatures");
8
9
  const names_1 = require("../names");
9
10
  const utils_1 = require("../utils");
11
+ const boundary_1 = require("../utils/boundary");
10
12
  // https://github.com/vuejs/core/blob/fb0c3ca519f1fccf52049cd6b8db3a67a669afe9/packages/compiler-core/src/transforms/transformExpression.ts#L47
11
13
  const isLiteralWhitelisted = /*@__PURE__*/ (0, shared_1.makeMap)('true,false,null,this');
12
14
  function* generateInterpolation({ typescript, setupRefs }, ctx, block, data, code, start, prefix = '', suffix = '') {
13
- for (const segment of forEachInterpolationSegment(typescript, setupRefs, ctx, block, code, start, prefix, suffix)) {
14
- if (typeof segment === 'string') {
15
- yield segment;
16
- continue;
17
- }
18
- let [section, offset, type] = segment;
19
- offset -= prefix.length;
20
- let addSuffix = '';
21
- const overLength = offset + section.length - code.length;
22
- if (overLength > 0) {
23
- addSuffix = section.slice(section.length - overLength);
24
- section = section.slice(0, -overLength);
25
- }
26
- if (offset < 0) {
27
- yield section.slice(0, -offset);
28
- section = section.slice(-offset);
29
- offset = 0;
30
- }
31
- const shouldSkip = section.length === 0 && type === 'startEnd';
32
- if (!shouldSkip) {
33
- yield [
34
- section,
35
- block.name,
36
- start + offset,
37
- type === 'errorMappingOnly'
38
- ? codeFeatures_1.codeFeatures.verification
39
- : type === 'shorthand'
40
- ? { ...data, __shorthandExpression: 'js' }
41
- : data,
42
- ];
43
- }
44
- yield addSuffix;
15
+ if (prefix) {
16
+ yield prefix;
45
17
  }
46
- }
47
- function* forEachInterpolationSegment(ts, setupRefs, ctx, block, originalCode, start, prefix, suffix) {
48
- const code = prefix + originalCode + suffix;
49
18
  let prevEnd = 0;
50
- for (const [name, offset, isShorthand] of forEachIdentifiers(ts, ctx, block, originalCode, code, prefix)) {
19
+ for (const [name, offset, isShorthand] of forEachIdentifiers(typescript, ctx, block, code, prefix, suffix)) {
51
20
  if (isShorthand) {
52
- yield [code.slice(prevEnd, offset + name.length), prevEnd];
21
+ yield [
22
+ code.slice(prevEnd, offset + name.length),
23
+ block.name,
24
+ start + prevEnd,
25
+ data,
26
+ ];
53
27
  yield `: `;
54
28
  }
55
- else {
56
- yield [code.slice(prevEnd, offset), prevEnd, prevEnd > 0 ? undefined : 'startEnd'];
29
+ else if (prevEnd < offset) {
30
+ yield [
31
+ code.slice(prevEnd, offset),
32
+ block.name,
33
+ start + prevEnd,
34
+ data,
35
+ ];
57
36
  }
58
37
  if (setupRefs.has(name)) {
59
- yield [name, offset];
38
+ yield [
39
+ name,
40
+ block.name,
41
+ start + offset,
42
+ data,
43
+ ];
60
44
  yield `.value`;
61
45
  }
62
46
  else {
63
- yield ['', offset, 'errorMappingOnly']; // #1205, #1264
47
+ // #1205, #1264
48
+ const token = yield* (0, boundary_1.startBoundary)(block.name, start + offset, codeFeatures_1.codeFeatures.verification);
64
49
  if (ctx.dollarVars.has(name)) {
65
50
  yield names_1.names.dollars;
66
51
  }
67
52
  else {
68
- ctx.recordComponentAccess(block.name, name, start - prefix.length + offset);
53
+ ctx.recordComponentAccess(block.name, name, start + offset);
69
54
  yield names_1.names.ctx;
70
55
  }
71
56
  yield `.`;
72
- yield [name, offset, isShorthand ? 'shorthand' : undefined];
57
+ yield [
58
+ name,
59
+ block.name,
60
+ start + offset,
61
+ isShorthand
62
+ ? { ...data, __shorthandExpression: 'js' }
63
+ : data,
64
+ ];
65
+ yield (0, boundary_1.endBoundary)(token, start + offset + name.length);
73
66
  }
74
67
  prevEnd = offset + name.length;
75
68
  }
76
69
  if (prevEnd < code.length) {
77
- yield [code.slice(prevEnd), prevEnd, 'startEnd'];
70
+ yield [
71
+ code.slice(prevEnd),
72
+ block.name,
73
+ start + prevEnd,
74
+ data,
75
+ ];
76
+ }
77
+ if (suffix) {
78
+ yield suffix;
78
79
  }
79
80
  }
80
- function* forEachIdentifiers(ts, ctx, block, originalCode, code, prefix) {
81
- if (utils_1.identifierRegex.test(originalCode) && !shouldIdentifierSkipped(ctx, originalCode)) {
82
- yield [originalCode, prefix.length, false];
81
+ function* forEachIdentifiers(ts, ctx, block, code, prefix, suffix) {
82
+ if (utils_1.identifierRegex.test(code) && !shouldIdentifierSkipped(ctx, code)) {
83
+ yield [code, 0, false];
83
84
  return;
84
85
  }
85
86
  const endScope = ctx.startScope();
86
- const ast = (0, utils_1.getTypeScriptAST)(ts, block, code);
87
+ const ast = (0, utils_1.getTypeScriptAST)(ts, block, prefix + code + suffix);
87
88
  for (const [id, isShorthand] of forEachDeclarations(ts, ast, ast, ctx)) {
88
89
  const text = (0, shared_2.getNodeText)(ts, id, ast);
89
90
  if (shouldIdentifierSkipped(ctx, text)) {
90
91
  continue;
91
92
  }
92
- yield [text, (0, shared_2.getStartEnd)(ts, id, ast).start, isShorthand];
93
+ yield [text, (0, shared_2.getStartEnd)(ts, id, ast).start - prefix.length, isShorthand];
93
94
  }
94
95
  endScope();
95
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "index.d.ts",
@@ -34,5 +34,5 @@
34
34
  "@volar/typescript": "2.4.28",
35
35
  "@vue/compiler-sfc": "^3.5.0"
36
36
  },
37
- "gitHead": "9109bf31282c3d92ca0dd1825b0872a59b572b84"
37
+ "gitHead": "7a00047bb6d133bf26fa6e916e856fdca40b3c49"
38
38
  }
@@ -109,7 +109,7 @@ declare global {
109
109
  };
110
110
  type __VLS_PrettifyGlobal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
111
111
 
112
- function __VLS_vFor<T>(source: T): T extends number ? [number, number][]
112
+ function __VLS_vFor<const T>(source: T): T extends number ? [number, number][]
113
113
  : T extends string ? [string, number][]
114
114
  : T extends readonly (infer U)[] ? [U, number][]
115
115
  : T extends Iterable<infer V> ? [V, number][]