@vue/language-core 2.2.0 → 2.2.4

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 (73) hide show
  1. package/index.d.ts +0 -1
  2. package/index.js +1 -2
  3. package/lib/codegen/codeFeatures.d.ts +83 -0
  4. package/lib/codegen/codeFeatures.js +71 -0
  5. package/lib/codegen/globalTypes.d.ts +3 -1
  6. package/lib/codegen/globalTypes.js +45 -37
  7. package/lib/codegen/localTypes.d.ts +1 -1
  8. package/lib/codegen/localTypes.js +4 -4
  9. package/lib/codegen/script/component.d.ts +1 -1
  10. package/lib/codegen/script/component.js +15 -11
  11. package/lib/codegen/script/componentSelf.d.ts +1 -1
  12. package/lib/codegen/script/componentSelf.js +2 -2
  13. package/lib/codegen/script/context.d.ts +1 -1
  14. package/lib/codegen/script/index.d.ts +1 -8
  15. package/lib/codegen/script/index.js +19 -45
  16. package/lib/codegen/script/scriptSetup.d.ts +1 -1
  17. package/lib/codegen/script/scriptSetup.js +78 -79
  18. package/lib/codegen/script/src.d.ts +2 -2
  19. package/lib/codegen/script/src.js +37 -38
  20. package/lib/codegen/script/template.d.ts +2 -3
  21. package/lib/codegen/script/template.js +12 -79
  22. package/lib/codegen/style/classProperty.d.ts +2 -0
  23. package/lib/codegen/style/classProperty.js +31 -0
  24. package/lib/codegen/style/modules.d.ts +3 -0
  25. package/lib/codegen/{script/styleModulesType.js → style/modules.js} +15 -15
  26. package/lib/codegen/style/scopedClasses.d.ts +4 -0
  27. package/lib/codegen/style/scopedClasses.js +32 -0
  28. package/lib/codegen/template/context.d.ts +122 -17
  29. package/lib/codegen/template/context.js +162 -92
  30. package/lib/codegen/template/element.d.ts +1 -1
  31. package/lib/codegen/template/element.js +86 -330
  32. package/lib/codegen/template/elementChildren.js +0 -13
  33. package/lib/codegen/template/elementDirectives.js +20 -12
  34. package/lib/codegen/template/elementEvents.d.ts +1 -1
  35. package/lib/codegen/template/elementEvents.js +15 -11
  36. package/lib/codegen/template/elementProps.d.ts +2 -1
  37. package/lib/codegen/template/elementProps.js +31 -33
  38. package/lib/codegen/template/index.d.ts +1 -0
  39. package/lib/codegen/template/index.js +53 -33
  40. package/lib/codegen/template/interpolation.js +13 -9
  41. package/lib/codegen/template/slotOutlet.js +44 -21
  42. package/lib/codegen/template/styleScopedClasses.d.ts +3 -0
  43. package/lib/codegen/template/styleScopedClasses.js +146 -9
  44. package/lib/codegen/template/templateChild.js +69 -30
  45. package/lib/codegen/template/vFor.js +2 -2
  46. package/lib/codegen/template/vIf.js +3 -3
  47. package/lib/codegen/template/vSlot.d.ts +6 -0
  48. package/lib/codegen/template/vSlot.js +92 -0
  49. package/lib/codegen/utils/index.d.ts +13 -2
  50. package/lib/codegen/utils/index.js +33 -6
  51. package/lib/parsers/scriptSetupRanges.d.ts +5 -3
  52. package/lib/parsers/scriptSetupRanges.js +24 -35
  53. package/lib/parsers/vueCompilerOptions.d.ts +2 -2
  54. package/lib/plugins/file-md.js +3 -0
  55. package/lib/plugins/vue-template-inline-ts.js +56 -15
  56. package/lib/plugins/vue-tsx.d.ts +43 -32
  57. package/lib/plugins/vue-tsx.js +88 -68
  58. package/lib/types.d.ts +29 -16
  59. package/lib/utils/parseSfc.js +41 -16
  60. package/lib/utils/signals.d.ts +2 -0
  61. package/lib/utils/signals.js +54 -0
  62. package/lib/utils/ts.d.ts +14 -2
  63. package/lib/utils/ts.js +134 -88
  64. package/lib/virtualFile/computedEmbeddedCodes.d.ts +1 -1
  65. package/lib/virtualFile/computedEmbeddedCodes.js +14 -24
  66. package/lib/virtualFile/computedSfc.d.ts +1 -2
  67. package/lib/virtualFile/computedSfc.js +86 -96
  68. package/lib/virtualFile/computedVueSfc.d.ts +1 -2
  69. package/lib/virtualFile/computedVueSfc.js +7 -7
  70. package/lib/virtualFile/vueFile.d.ts +8 -11
  71. package/lib/virtualFile/vueFile.js +15 -9
  72. package/package.json +4 -4
  73. package/lib/codegen/script/styleModulesType.d.ts +0 -4
@@ -4,41 +4,36 @@ exports.computedSfc = computedSfc;
4
4
  const alien_signals_1 = require("alien-signals");
5
5
  const parseCssClassNames_1 = require("../utils/parseCssClassNames");
6
6
  const parseCssVars_1 = require("../utils/parseCssVars");
7
- function computedSfc(ts, plugins, fileName, snapshot, parsed) {
8
- const untrackedSnapshot = () => {
9
- const prevSub = alien_signals_1.activeSub;
10
- const prevTrackId = alien_signals_1.activeTrackId;
11
- (0, alien_signals_1.setActiveSub)(undefined, 0);
12
- const res = snapshot.get();
13
- (0, alien_signals_1.setActiveSub)(prevSub, prevTrackId);
7
+ const signals_1 = require("../utils/signals");
8
+ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
9
+ const getUntrackedSnapshot = () => {
10
+ (0, alien_signals_1.pauseTracking)();
11
+ const res = getSnapshot();
12
+ (0, alien_signals_1.resumeTracking)();
14
13
  return res;
15
14
  };
16
- const content = (0, alien_signals_1.computed)(() => {
17
- return snapshot.get().getText(0, snapshot.get().getLength());
15
+ const getContent = (0, alien_signals_1.computed)(() => {
16
+ return getSnapshot().getText(0, getSnapshot().getLength());
18
17
  });
19
- const comments = (0, alien_signals_1.computed)(oldValue => {
20
- const newValue = parsed.get()?.descriptor.comments ?? [];
18
+ const getComments = (0, alien_signals_1.computed)(oldValue => {
19
+ const newValue = getParseResult()?.descriptor.comments ?? [];
21
20
  if (oldValue?.length === newValue.length
22
- && oldValue.every((v, i) => v === newValue[i])) {
21
+ && oldValue?.every((v, i) => v === newValue[i])) {
23
22
  return oldValue;
24
23
  }
25
24
  return newValue;
26
25
  });
27
- const template = computedNullableSfcBlock('template', 'html', (0, alien_signals_1.computed)(() => parsed.get()?.descriptor.template ?? undefined), (_block, base) => {
26
+ const getTemplate = computedNullableSfcBlock('template', 'html', (0, alien_signals_1.computed)(() => getParseResult()?.descriptor.template ?? undefined), (_block, base) => {
28
27
  const compiledAst = computedTemplateAst(base);
29
28
  return mergeObject(base, {
30
- get ast() { return compiledAst.get()?.ast; },
31
- get errors() { return compiledAst.get()?.errors; },
32
- get warnings() { return compiledAst.get()?.warnings; },
29
+ get ast() { return compiledAst()?.ast; },
30
+ get errors() { return compiledAst()?.errors; },
31
+ get warnings() { return compiledAst()?.warnings; },
33
32
  });
34
33
  });
35
- const script = computedNullableSfcBlock('script', 'js', (0, alien_signals_1.computed)(() => parsed.get()?.descriptor.script ?? undefined), (block, base) => {
36
- const src = (0, alien_signals_1.computed)(() => block.get().src);
37
- const srcOffset = (0, alien_signals_1.computed)(() => {
38
- const _src = src.get();
39
- return _src ? untrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_src) - base.startTagEnd : -1;
40
- });
41
- const ast = (0, alien_signals_1.computed)(() => {
34
+ const getScript = computedNullableSfcBlock('script', 'js', (0, alien_signals_1.computed)(() => getParseResult()?.descriptor.script ?? undefined), (block, base) => {
35
+ const getSrc = computedAttrValue('__src', base, block);
36
+ const getAst = (0, alien_signals_1.computed)(() => {
42
37
  for (const plugin of plugins) {
43
38
  const ast = plugin.compileSFCScript?.(base.lang, base.content);
44
39
  if (ast) {
@@ -48,21 +43,13 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
48
43
  return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
49
44
  });
50
45
  return mergeObject(base, {
51
- get src() { return src.get(); },
52
- get srcOffset() { return srcOffset.get(); },
53
- get ast() { return ast.get(); },
46
+ get src() { return getSrc(); },
47
+ get ast() { return getAst(); },
54
48
  });
55
49
  });
56
- const scriptSetupOriginal = computedNullableSfcBlock('scriptSetup', 'js', (0, alien_signals_1.computed)(() => parsed.get()?.descriptor.scriptSetup ?? undefined), (block, base) => {
57
- const generic = (0, alien_signals_1.computed)(() => {
58
- const _block = block.get();
59
- return typeof _block.attrs.generic === 'string' ? _block.attrs.generic : undefined;
60
- });
61
- const genericOffset = (0, alien_signals_1.computed)(() => {
62
- const _generic = generic.get();
63
- return _generic !== undefined ? untrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_generic) - base.startTagEnd : -1;
64
- });
65
- const ast = (0, alien_signals_1.computed)(() => {
50
+ const getOriginalScriptSetup = computedNullableSfcBlock('scriptSetup', 'js', (0, alien_signals_1.computed)(() => getParseResult()?.descriptor.scriptSetup ?? undefined), (block, base) => {
51
+ const getGeneric = computedAttrValue('__generic', base, block);
52
+ const getAst = (0, alien_signals_1.computed)(() => {
66
53
  for (const plugin of plugins) {
67
54
  const ast = plugin.compileSFCScript?.(base.lang, base.content);
68
55
  if (ast) {
@@ -72,15 +59,14 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
72
59
  return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
73
60
  });
74
61
  return mergeObject(base, {
75
- get generic() { return generic.get(); },
76
- get genericOffset() { return genericOffset.get(); },
77
- get ast() { return ast.get(); },
62
+ get generic() { return getGeneric(); },
63
+ get ast() { return getAst(); },
78
64
  });
79
65
  });
80
- const hasScript = (0, alien_signals_1.computed)(() => !!parsed.get()?.descriptor.script);
81
- const hasScriptSetup = (0, alien_signals_1.computed)(() => !!parsed.get()?.descriptor.scriptSetup);
82
- const scriptSetup = (0, alien_signals_1.computed)(() => {
83
- if (!hasScript.get() && !hasScriptSetup.get()) {
66
+ const hasScript = (0, alien_signals_1.computed)(() => !!getParseResult()?.descriptor.script);
67
+ const hasScriptSetup = (0, alien_signals_1.computed)(() => !!getParseResult()?.descriptor.scriptSetup);
68
+ const getScriptSetup = (0, alien_signals_1.computed)(() => {
69
+ if (!hasScript() && !hasScriptSetup()) {
84
70
  //#region monkey fix: https://github.com/vuejs/language-tools/pull/2113
85
71
  return {
86
72
  content: '',
@@ -96,40 +82,34 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
96
82
  ast: ts.createSourceFile('', '', 99, false, ts.ScriptKind.TS),
97
83
  };
98
84
  }
99
- return scriptSetupOriginal.get();
85
+ return getOriginalScriptSetup();
100
86
  });
101
- const styles = alien_signals_1.unstable.computedArray((0, alien_signals_1.computed)(() => parsed.get()?.descriptor.styles ?? []), (block, i) => {
102
- const base = computedSfcBlock('style_' + i, 'css', block);
103
- const module = (0, alien_signals_1.computed)(() => {
104
- const { __module } = block.get();
105
- return __module ? {
106
- name: __module.name,
107
- offset: __module.offset ? base.start + __module.offset : undefined
108
- } : undefined;
109
- });
110
- const scoped = (0, alien_signals_1.computed)(() => !!block.get().scoped);
111
- const cssVars = (0, alien_signals_1.computed)(() => [...(0, parseCssVars_1.parseCssVars)(base.content)]);
112
- const classNames = (0, alien_signals_1.computed)(() => [...(0, parseCssClassNames_1.parseCssClassNames)(base.content)]);
87
+ const styles = (0, signals_1.computedArray)((0, alien_signals_1.computed)(() => getParseResult()?.descriptor.styles ?? []), (getBlock, i) => {
88
+ const base = computedSfcBlock('style_' + i, 'css', getBlock);
89
+ const getModule = computedAttrValue('__module', base, getBlock);
90
+ const getScoped = (0, alien_signals_1.computed)(() => !!getBlock().scoped);
91
+ const getCssVars = (0, alien_signals_1.computed)(() => [...(0, parseCssVars_1.parseCssVars)(base.content)]);
92
+ const getClassNames = (0, alien_signals_1.computed)(() => [...(0, parseCssClassNames_1.parseCssClassNames)(base.content)]);
113
93
  return () => mergeObject(base, {
114
- get module() { return module.get(); },
115
- get scoped() { return scoped.get(); },
116
- get cssVars() { return cssVars.get(); },
117
- get classNames() { return classNames.get(); },
94
+ get module() { return getModule(); },
95
+ get scoped() { return getScoped(); },
96
+ get cssVars() { return getCssVars(); },
97
+ get classNames() { return getClassNames(); },
118
98
  });
119
99
  });
120
- const customBlocks = alien_signals_1.unstable.computedArray((0, alien_signals_1.computed)(() => parsed.get()?.descriptor.customBlocks ?? []), (block, i) => {
121
- const base = computedSfcBlock('custom_block_' + i, 'txt', block);
122
- const type = (0, alien_signals_1.computed)(() => block.get().type);
100
+ const customBlocks = (0, signals_1.computedArray)((0, alien_signals_1.computed)(() => getParseResult()?.descriptor.customBlocks ?? []), (getBlock, i) => {
101
+ const base = computedSfcBlock('custom_block_' + i, 'txt', getBlock);
102
+ const getType = (0, alien_signals_1.computed)(() => getBlock().type);
123
103
  return () => mergeObject(base, {
124
- get type() { return type.get(); },
104
+ get type() { return getType(); },
125
105
  });
126
106
  });
127
107
  return {
128
- get content() { return content.get(); },
129
- get comments() { return comments.get(); },
130
- get template() { return template.get(); },
131
- get script() { return script.get(); },
132
- get scriptSetup() { return scriptSetup.get(); },
108
+ get content() { return getContent(); },
109
+ get comments() { return getComments(); },
110
+ get template() { return getTemplate(); },
111
+ get script() { return getScript(); },
112
+ get scriptSetup() { return getScriptSetup(); },
133
113
  get styles() { return styles; },
134
114
  get customBlocks() { return customBlocks; },
135
115
  };
@@ -145,14 +125,12 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
145
125
  }
146
126
  // incremental update
147
127
  if (cache?.plugin.updateSFCTemplate) {
148
- const change = untrackedSnapshot().getChangeRange(cache.snapshot);
128
+ const change = getUntrackedSnapshot().getChangeRange(cache.snapshot);
149
129
  if (change) {
150
- const prevSub = alien_signals_1.activeSub;
151
- const prevTrackId = alien_signals_1.activeTrackId;
152
- (0, alien_signals_1.setActiveSub)(undefined, 0);
130
+ (0, alien_signals_1.pauseTracking)();
153
131
  const templateOffset = base.startTagEnd;
154
- (0, alien_signals_1.setActiveSub)(prevSub, prevTrackId);
155
- const newText = untrackedSnapshot().getText(change.span.start, change.span.start + change.newLength);
132
+ (0, alien_signals_1.resumeTracking)();
133
+ const newText = getUntrackedSnapshot().getText(change.span.start, change.span.start + change.newLength);
156
134
  const newResult = cache.plugin.updateSFCTemplate(cache.result, {
157
135
  start: change.span.start - templateOffset,
158
136
  end: change.span.start + change.span.length - templateOffset,
@@ -160,7 +138,7 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
160
138
  });
161
139
  if (newResult) {
162
140
  cache.template = base.content;
163
- cache.snapshot = untrackedSnapshot();
141
+ cache.snapshot = getUntrackedSnapshot();
164
142
  cache.result = newResult;
165
143
  return {
166
144
  errors: [],
@@ -195,7 +173,7 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
195
173
  if (result && !errors.length && !warnings.length) {
196
174
  cache = {
197
175
  template: base.content,
198
- snapshot: untrackedSnapshot(),
176
+ snapshot: getUntrackedSnapshot(),
199
177
  result: result,
200
178
  plugin,
201
179
  };
@@ -217,35 +195,47 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
217
195
  };
218
196
  });
219
197
  }
220
- function computedNullableSfcBlock(name, defaultLang, block, resolve) {
221
- const hasBlock = (0, alien_signals_1.computed)(() => !!block.get());
198
+ function computedNullableSfcBlock(name, defaultLang, getBlock, resolve) {
199
+ const hasBlock = (0, alien_signals_1.computed)(() => !!getBlock());
222
200
  return (0, alien_signals_1.computed)(() => {
223
- if (!hasBlock.get()) {
201
+ if (!hasBlock()) {
224
202
  return;
225
203
  }
226
- const _block = (0, alien_signals_1.computed)(() => block.get());
204
+ const _block = (0, alien_signals_1.computed)(() => getBlock());
227
205
  return resolve(_block, computedSfcBlock(name, defaultLang, _block));
228
206
  });
229
207
  }
230
- function computedSfcBlock(name, defaultLang, block) {
231
- const lang = (0, alien_signals_1.computed)(() => block.get().lang ?? defaultLang);
232
- const attrs = (0, alien_signals_1.computed)(() => block.get().attrs); // TODO: computed it
233
- const content = (0, alien_signals_1.computed)(() => block.get().content);
234
- const startTagEnd = (0, alien_signals_1.computed)(() => block.get().loc.start.offset);
235
- const endTagStart = (0, alien_signals_1.computed)(() => block.get().loc.end.offset);
236
- const start = (0, alien_signals_1.computed)(() => untrackedSnapshot().getText(0, startTagEnd.get()).lastIndexOf('<' + block.get().type));
237
- const end = (0, alien_signals_1.computed)(() => endTagStart.get() + untrackedSnapshot().getText(endTagStart.get(), untrackedSnapshot().getLength()).indexOf('>') + 1);
208
+ function computedSfcBlock(name, defaultLang, getBlock) {
209
+ const getLang = (0, alien_signals_1.computed)(() => getBlock().lang ?? defaultLang);
210
+ const getAttrs = (0, alien_signals_1.computed)(() => getBlock().attrs); // TODO: computed it
211
+ const getContent = (0, alien_signals_1.computed)(() => getBlock().content);
212
+ const getStartTagEnd = (0, alien_signals_1.computed)(() => getBlock().loc.start.offset);
213
+ const getEndTagStart = (0, alien_signals_1.computed)(() => getBlock().loc.end.offset);
214
+ const getStart = (0, alien_signals_1.computed)(() => getUntrackedSnapshot().getText(0, getStartTagEnd()).lastIndexOf('<' + getBlock().type));
215
+ const getEnd = (0, alien_signals_1.computed)(() => getEndTagStart() + getUntrackedSnapshot().getText(getEndTagStart(), getUntrackedSnapshot().getLength()).indexOf('>') + 1);
238
216
  return {
239
217
  name,
240
- get lang() { return lang.get(); },
241
- get attrs() { return attrs.get(); },
242
- get content() { return content.get(); },
243
- get startTagEnd() { return startTagEnd.get(); },
244
- get endTagStart() { return endTagStart.get(); },
245
- get start() { return start.get(); },
246
- get end() { return end.get(); },
218
+ get lang() { return getLang(); },
219
+ get attrs() { return getAttrs(); },
220
+ get content() { return getContent(); },
221
+ get startTagEnd() { return getStartTagEnd(); },
222
+ get endTagStart() { return getEndTagStart(); },
223
+ get start() { return getStart(); },
224
+ get end() { return getEnd(); },
247
225
  };
248
226
  }
227
+ function computedAttrValue(key, base, getBlock) {
228
+ return (0, alien_signals_1.computed)(() => {
229
+ const val = getBlock()[key];
230
+ if (typeof val === 'object') {
231
+ return {
232
+ ...val,
233
+ offset: base.start + val.offset,
234
+ };
235
+ }
236
+ return val;
237
+ });
238
+ }
249
239
  }
250
240
  function mergeObject(a, b) {
251
241
  return Object.defineProperties(a, Object.getOwnPropertyDescriptors(b));
@@ -1,5 +1,4 @@
1
1
  import type { SFCParseResult } from '@vue/compiler-sfc';
2
- import { Signal } from 'alien-signals';
3
2
  import type * as ts from 'typescript';
4
3
  import type { VueLanguagePluginReturn } from '../types';
5
- export declare function computedVueSfc(plugins: VueLanguagePluginReturn[], fileName: string, languageId: string, snapshot: Signal<ts.IScriptSnapshot>): import("alien-signals").Computed<SFCParseResult | undefined>;
4
+ export declare function computedVueSfc(plugins: VueLanguagePluginReturn[], fileName: string, languageId: string, getSnapshot: () => ts.IScriptSnapshot): () => SFCParseResult | undefined;
@@ -2,20 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.computedVueSfc = computedVueSfc;
4
4
  const alien_signals_1 = require("alien-signals");
5
- function computedVueSfc(plugins, fileName, languageId, snapshot) {
5
+ function computedVueSfc(plugins, fileName, languageId, getSnapshot) {
6
6
  let cache;
7
7
  return (0, alien_signals_1.computed)(() => {
8
8
  // incremental update
9
9
  if (cache?.plugin.updateSFC) {
10
- const change = snapshot.get().getChangeRange(cache.snapshot);
10
+ const change = getSnapshot().getChangeRange(cache.snapshot);
11
11
  if (change) {
12
12
  const newSfc = cache.plugin.updateSFC(cache.sfc, {
13
13
  start: change.span.start,
14
14
  end: change.span.start + change.span.length,
15
- newText: snapshot.get().getText(change.span.start, change.span.start + change.newLength),
15
+ newText: getSnapshot().getText(change.span.start, change.span.start + change.newLength),
16
16
  });
17
17
  if (newSfc) {
18
- cache.snapshot = snapshot.get();
18
+ cache.snapshot = getSnapshot();
19
19
  // force dirty
20
20
  cache.sfc = JSON.parse(JSON.stringify(newSfc));
21
21
  return cache.sfc;
@@ -23,12 +23,12 @@ function computedVueSfc(plugins, fileName, languageId, snapshot) {
23
23
  }
24
24
  }
25
25
  for (const plugin of plugins) {
26
- const sfc = plugin.parseSFC?.(fileName, snapshot.get().getText(0, snapshot.get().getLength()))
27
- ?? plugin.parseSFC2?.(fileName, languageId, snapshot.get().getText(0, snapshot.get().getLength()));
26
+ const sfc = plugin.parseSFC?.(fileName, getSnapshot().getText(0, getSnapshot().getLength()))
27
+ ?? plugin.parseSFC2?.(fileName, languageId, getSnapshot().getText(0, getSnapshot().getLength()));
28
28
  if (sfc) {
29
29
  if (!sfc.errors.length) {
30
30
  cache = {
31
- snapshot: snapshot.get(),
31
+ snapshot: getSnapshot(),
32
32
  sfc,
33
33
  plugin,
34
34
  };
@@ -9,18 +9,15 @@ export declare class VueVirtualCode implements VirtualCode {
9
9
  plugins: VueLanguagePluginReturn[];
10
10
  ts: typeof import('typescript');
11
11
  id: string;
12
- _snapshot: import("alien-signals").Signal<ts.IScriptSnapshot>;
13
- _vueSfc: import("alien-signals").Computed<import("@vue/compiler-sfc").SFCParseResult | undefined>;
14
- _sfc: import("../types").Sfc;
15
- _mappings: import("alien-signals").Computed<{
16
- sourceOffsets: number[];
17
- generatedOffsets: number[];
18
- lengths: number[];
19
- data: import("@volar/language-core").CodeInformation;
20
- }[]>;
21
- _embeddedCodes: import("alien-signals").Computed<VirtualCode[]>;
22
- get embeddedCodes(): VirtualCode[];
12
+ private _snapshot;
13
+ private _vueSfc;
14
+ private _sfc;
15
+ private _embeddedCodes;
16
+ private _mappings;
23
17
  get snapshot(): ts.IScriptSnapshot;
18
+ get vueSfc(): import("@vue/compiler-sfc").SFCParseResult | undefined;
19
+ get sfc(): import("../types").Sfc;
20
+ get embeddedCodes(): VirtualCode[];
24
21
  get mappings(): {
25
22
  sourceOffsets: number[];
26
23
  generatedOffsets: number[];
@@ -8,14 +8,20 @@ const computedSfc_1 = require("./computedSfc");
8
8
  const computedVueSfc_1 = require("./computedVueSfc");
9
9
  class VueVirtualCode {
10
10
  // others
11
- get embeddedCodes() {
12
- return this._embeddedCodes.get();
13
- }
14
11
  get snapshot() {
15
- return this._snapshot.get();
12
+ return this._snapshot();
13
+ }
14
+ get vueSfc() {
15
+ return this._vueSfc();
16
+ }
17
+ get sfc() {
18
+ return this._sfc;
19
+ }
20
+ get embeddedCodes() {
21
+ return this._embeddedCodes();
16
22
  }
17
23
  get mappings() {
18
- return this._mappings.get();
24
+ return this._mappings();
19
25
  }
20
26
  constructor(fileName, languageId, initSnapshot, vueCompilerOptions, plugins, ts) {
21
27
  this.fileName = fileName;
@@ -30,8 +36,9 @@ class VueVirtualCode {
30
36
  // computeds
31
37
  this._vueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, this.languageId, this._snapshot);
32
38
  this._sfc = (0, computedSfc_1.computedSfc)(this.ts, this.plugins, this.fileName, this._snapshot, this._vueSfc);
39
+ this._embeddedCodes = (0, computedEmbeddedCodes_1.computedEmbeddedCodes)(this.plugins, this.fileName, this._sfc);
33
40
  this._mappings = (0, alien_signals_1.computed)(() => {
34
- const snapshot = this._snapshot.get();
41
+ const snapshot = this._snapshot();
35
42
  return [{
36
43
  sourceOffsets: [0],
37
44
  generatedOffsets: [0],
@@ -39,11 +46,10 @@ class VueVirtualCode {
39
46
  data: plugins_1.allCodeFeatures,
40
47
  }];
41
48
  });
42
- this._embeddedCodes = (0, computedEmbeddedCodes_1.computedEmbeddedCodes)(this.plugins, this.fileName, this._sfc);
43
- this._snapshot.set(initSnapshot);
49
+ this._snapshot(initSnapshot);
44
50
  }
45
51
  update(newSnapshot) {
46
- this._snapshot.set(newSnapshot);
52
+ this._snapshot(newSnapshot);
47
53
  }
48
54
  }
49
55
  exports.VueVirtualCode = VueVirtualCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "2.2.0",
3
+ "version": "2.2.4",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -17,14 +17,14 @@
17
17
  "@vue/compiler-dom": "^3.5.0",
18
18
  "@vue/compiler-vue2": "^2.7.16",
19
19
  "@vue/shared": "^3.5.0",
20
- "alien-signals": "^0.4.9",
20
+ "alien-signals": "^1.0.3",
21
21
  "minimatch": "^9.0.3",
22
22
  "muggle-string": "^0.4.1",
23
23
  "path-browserify": "^1.0.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/minimatch": "^5.1.2",
27
- "@types/node": "latest",
27
+ "@types/node": "^22.10.4",
28
28
  "@types/path-browserify": "^1.0.1",
29
29
  "@volar/typescript": "~2.4.11",
30
30
  "@vue/compiler-sfc": "^3.5.0"
@@ -37,5 +37,5 @@
37
37
  "optional": true
38
38
  }
39
39
  },
40
- "gitHead": "5babca774658d4b9afbe877ac7c8cafdaecf2c3e"
40
+ "gitHead": "c28986596935cb43979c9d437c25f292bdb36cef"
41
41
  }
@@ -1,4 +0,0 @@
1
- import type { Code } from '../../types';
2
- import type { ScriptCodegenContext } from './context';
3
- import { ScriptCodegenOptions } from './index';
4
- export declare function generateStyleModulesType(options: ScriptCodegenOptions, ctx: ScriptCodegenContext): Generator<Code>;