@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.
- package/index.d.ts +0 -1
- package/index.js +1 -2
- package/lib/codegen/codeFeatures.d.ts +83 -0
- package/lib/codegen/codeFeatures.js +71 -0
- package/lib/codegen/globalTypes.d.ts +3 -1
- package/lib/codegen/globalTypes.js +45 -37
- package/lib/codegen/localTypes.d.ts +1 -1
- package/lib/codegen/localTypes.js +4 -4
- package/lib/codegen/script/component.d.ts +1 -1
- package/lib/codegen/script/component.js +15 -11
- package/lib/codegen/script/componentSelf.d.ts +1 -1
- package/lib/codegen/script/componentSelf.js +2 -2
- package/lib/codegen/script/context.d.ts +1 -1
- package/lib/codegen/script/index.d.ts +1 -8
- package/lib/codegen/script/index.js +19 -45
- package/lib/codegen/script/scriptSetup.d.ts +1 -1
- package/lib/codegen/script/scriptSetup.js +78 -79
- package/lib/codegen/script/src.d.ts +2 -2
- package/lib/codegen/script/src.js +37 -38
- package/lib/codegen/script/template.d.ts +2 -3
- package/lib/codegen/script/template.js +12 -79
- package/lib/codegen/style/classProperty.d.ts +2 -0
- package/lib/codegen/style/classProperty.js +31 -0
- package/lib/codegen/style/modules.d.ts +3 -0
- package/lib/codegen/{script/styleModulesType.js → style/modules.js} +15 -15
- package/lib/codegen/style/scopedClasses.d.ts +4 -0
- package/lib/codegen/style/scopedClasses.js +32 -0
- package/lib/codegen/template/context.d.ts +122 -17
- package/lib/codegen/template/context.js +162 -92
- package/lib/codegen/template/element.d.ts +1 -1
- package/lib/codegen/template/element.js +86 -330
- package/lib/codegen/template/elementChildren.js +0 -13
- package/lib/codegen/template/elementDirectives.js +20 -12
- package/lib/codegen/template/elementEvents.d.ts +1 -1
- package/lib/codegen/template/elementEvents.js +15 -11
- package/lib/codegen/template/elementProps.d.ts +2 -1
- package/lib/codegen/template/elementProps.js +31 -33
- package/lib/codegen/template/index.d.ts +1 -0
- package/lib/codegen/template/index.js +53 -33
- package/lib/codegen/template/interpolation.js +13 -9
- package/lib/codegen/template/slotOutlet.js +44 -21
- package/lib/codegen/template/styleScopedClasses.d.ts +3 -0
- package/lib/codegen/template/styleScopedClasses.js +146 -9
- package/lib/codegen/template/templateChild.js +69 -30
- package/lib/codegen/template/vFor.js +2 -2
- package/lib/codegen/template/vIf.js +3 -3
- package/lib/codegen/template/vSlot.d.ts +6 -0
- package/lib/codegen/template/vSlot.js +92 -0
- package/lib/codegen/utils/index.d.ts +13 -2
- package/lib/codegen/utils/index.js +33 -6
- package/lib/parsers/scriptSetupRanges.d.ts +5 -3
- package/lib/parsers/scriptSetupRanges.js +24 -35
- package/lib/parsers/vueCompilerOptions.d.ts +2 -2
- package/lib/plugins/file-md.js +3 -0
- package/lib/plugins/vue-template-inline-ts.js +56 -15
- package/lib/plugins/vue-tsx.d.ts +43 -32
- package/lib/plugins/vue-tsx.js +88 -68
- package/lib/types.d.ts +29 -16
- package/lib/utils/parseSfc.js +41 -16
- package/lib/utils/signals.d.ts +2 -0
- package/lib/utils/signals.js +54 -0
- package/lib/utils/ts.d.ts +14 -2
- package/lib/utils/ts.js +134 -88
- package/lib/virtualFile/computedEmbeddedCodes.d.ts +1 -1
- package/lib/virtualFile/computedEmbeddedCodes.js +14 -24
- package/lib/virtualFile/computedSfc.d.ts +1 -2
- package/lib/virtualFile/computedSfc.js +86 -96
- package/lib/virtualFile/computedVueSfc.d.ts +1 -2
- package/lib/virtualFile/computedVueSfc.js +7 -7
- package/lib/virtualFile/vueFile.d.ts +8 -11
- package/lib/virtualFile/vueFile.js +15 -9
- package/package.json +4 -4
- 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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
17
|
-
return
|
|
15
|
+
const getContent = (0, alien_signals_1.computed)(() => {
|
|
16
|
+
return getSnapshot().getText(0, getSnapshot().getLength());
|
|
18
17
|
});
|
|
19
|
-
const
|
|
20
|
-
const newValue =
|
|
18
|
+
const getComments = (0, alien_signals_1.computed)(oldValue => {
|
|
19
|
+
const newValue = getParseResult()?.descriptor.comments ?? [];
|
|
21
20
|
if (oldValue?.length === newValue.length
|
|
22
|
-
&& oldValue
|
|
21
|
+
&& oldValue?.every((v, i) => v === newValue[i])) {
|
|
23
22
|
return oldValue;
|
|
24
23
|
}
|
|
25
24
|
return newValue;
|
|
26
25
|
});
|
|
27
|
-
const
|
|
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
|
|
31
|
-
get errors() { return compiledAst
|
|
32
|
-
get warnings() { return compiledAst
|
|
29
|
+
get ast() { return compiledAst()?.ast; },
|
|
30
|
+
get errors() { return compiledAst()?.errors; },
|
|
31
|
+
get warnings() { return compiledAst()?.warnings; },
|
|
33
32
|
});
|
|
34
33
|
});
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
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
|
|
52
|
-
get
|
|
53
|
-
get ast() { return ast.get(); },
|
|
46
|
+
get src() { return getSrc(); },
|
|
47
|
+
get ast() { return getAst(); },
|
|
54
48
|
});
|
|
55
49
|
});
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
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
|
|
76
|
-
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)(() => !!
|
|
81
|
-
const hasScriptSetup = (0, alien_signals_1.computed)(() => !!
|
|
82
|
-
const
|
|
83
|
-
if (!hasScript
|
|
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
|
|
85
|
+
return getOriginalScriptSetup();
|
|
100
86
|
});
|
|
101
|
-
const styles =
|
|
102
|
-
const base = computedSfcBlock('style_' + i, 'css',
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
|
115
|
-
get scoped() { return
|
|
116
|
-
get cssVars() { return
|
|
117
|
-
get classNames() { return
|
|
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 =
|
|
121
|
-
const base = computedSfcBlock('custom_block_' + i, 'txt',
|
|
122
|
-
const
|
|
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
|
|
104
|
+
get type() { return getType(); },
|
|
125
105
|
});
|
|
126
106
|
});
|
|
127
107
|
return {
|
|
128
|
-
get content() { return
|
|
129
|
-
get comments() { return
|
|
130
|
-
get template() { return
|
|
131
|
-
get script() { return
|
|
132
|
-
get scriptSetup() { return
|
|
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 =
|
|
128
|
+
const change = getUntrackedSnapshot().getChangeRange(cache.snapshot);
|
|
149
129
|
if (change) {
|
|
150
|
-
|
|
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.
|
|
155
|
-
const newText =
|
|
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 =
|
|
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:
|
|
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,
|
|
221
|
-
const hasBlock = (0, alien_signals_1.computed)(() => !!
|
|
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
|
|
201
|
+
if (!hasBlock()) {
|
|
224
202
|
return;
|
|
225
203
|
}
|
|
226
|
-
const _block = (0, alien_signals_1.computed)(() =>
|
|
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,
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
const
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
const
|
|
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
|
|
241
|
-
get attrs() { return
|
|
242
|
-
get content() { return
|
|
243
|
-
get startTagEnd() { return
|
|
244
|
-
get endTagStart() { return
|
|
245
|
-
get start() { return
|
|
246
|
-
get end() { return
|
|
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,
|
|
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,
|
|
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 =
|
|
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:
|
|
15
|
+
newText: getSnapshot().getText(change.span.start, change.span.start + change.newLength),
|
|
16
16
|
});
|
|
17
17
|
if (newSfc) {
|
|
18
|
-
cache.snapshot =
|
|
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,
|
|
27
|
-
?? plugin.parseSFC2?.(fileName, languageId,
|
|
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:
|
|
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
|
|
13
|
-
_vueSfc
|
|
14
|
-
_sfc
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
43
|
-
this._snapshot.set(initSnapshot);
|
|
49
|
+
this._snapshot(initSnapshot);
|
|
44
50
|
}
|
|
45
51
|
update(newSnapshot) {
|
|
46
|
-
this._snapshot
|
|
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.
|
|
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.
|
|
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": "
|
|
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": "
|
|
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>;
|