@vue/language-core 3.1.6 → 3.1.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.
- package/lib/codegen/globalTypes.js +1 -1
- package/lib/codegen/names.d.ts +0 -1
- package/lib/codegen/names.js +1 -2
- package/lib/codegen/script/component.js +1 -14
- package/lib/codegen/script/index.js +59 -53
- package/lib/codegen/script/scriptSetup.js +2 -2
- package/lib/codegen/script/src.d.ts +1 -0
- package/lib/codegen/script/src.js +17 -12
- package/lib/codegen/script/template.d.ts +1 -1
- package/lib/codegen/script/template.js +9 -24
- package/lib/codegen/style/classProperty.d.ts +2 -0
- package/lib/codegen/style/classProperty.js +18 -0
- package/lib/codegen/style/imports.d.ts +2 -0
- package/lib/codegen/style/imports.js +27 -0
- package/lib/codegen/style/index.d.ts +1 -4
- package/lib/codegen/template/context.d.ts +1 -4
- package/lib/codegen/template/context.js +2 -1
- package/lib/codegen/template/element.js +105 -157
- package/lib/codegen/template/elementChildren.d.ts +5 -0
- package/lib/codegen/template/elementChildren.js +12 -0
- package/lib/codegen/template/elementEvents.d.ts +1 -1
- package/lib/codegen/template/elementEvents.js +3 -3
- package/lib/codegen/template/index.d.ts +2 -5
- package/lib/codegen/template/templateChild.js +11 -15
- package/lib/codegen/template/vSlot.d.ts +1 -1
- package/lib/codegen/template/vSlot.js +14 -20
- package/lib/codegen/utils/index.d.ts +2 -2
- package/lib/codegen/utils/index.js +15 -11
- package/lib/codegen/utils/wrapWith.d.ts +2 -0
- package/lib/codegen/utils/wrapWith.js +15 -0
- package/lib/languagePlugin.js +3 -4
- package/lib/parsers/scriptRanges.d.ts +6 -8
- package/lib/parsers/scriptRanges.js +5 -2
- package/lib/parsers/scriptSetupRanges.d.ts +2 -6
- package/lib/parsers/scriptSetupRanges.js +3 -2
- package/lib/parsers/utils.d.ts +4 -6
- package/lib/parsers/utils.js +25 -27
- package/lib/plugins/vue-script-js.js +1 -1
- package/lib/plugins/vue-tsx.d.ts +7 -17
- package/lib/plugins/vue-tsx.js +7 -18
- package/lib/virtualFile/computedEmbeddedCodes.d.ts +4 -0
- package/lib/virtualFile/computedEmbeddedCodes.js +262 -0
- package/lib/virtualFile/computedSfc.d.ts +6 -0
- package/lib/virtualFile/computedSfc.js +340 -0
- package/lib/virtualFile/computedVueSfc.d.ts +4 -0
- package/lib/virtualFile/computedVueSfc.js +41 -0
- package/lib/virtualFile/embeddedFile.d.ts +11 -0
- package/lib/virtualFile/embeddedFile.js +14 -0
- package/lib/virtualFile/vueFile.d.ts +24 -0
- package/lib/virtualFile/vueFile.js +49 -0
- package/package.json +2 -2
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.templateInlineTsAsts = void 0;
|
|
4
|
+
exports.computedSfc = computedSfc;
|
|
5
|
+
const CompilerDOM = require("@vue/compiler-dom");
|
|
6
|
+
const alien_signals_1 = require("alien-signals");
|
|
7
|
+
const signals_1 = require("../utils/signals");
|
|
8
|
+
exports.templateInlineTsAsts = new WeakMap();
|
|
9
|
+
function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
10
|
+
const getUntrackedSnapshot = () => {
|
|
11
|
+
const pausedSub = (0, alien_signals_1.setActiveSub)(undefined);
|
|
12
|
+
const res = getSnapshot();
|
|
13
|
+
(0, alien_signals_1.setActiveSub)(pausedSub);
|
|
14
|
+
return res;
|
|
15
|
+
};
|
|
16
|
+
const getContent = (0, alien_signals_1.computed)(() => {
|
|
17
|
+
return getSnapshot().getText(0, getSnapshot().getLength());
|
|
18
|
+
});
|
|
19
|
+
const getComments = (0, alien_signals_1.computed)(oldValue => {
|
|
20
|
+
const newValue = getParseResult()?.descriptor.comments ?? [];
|
|
21
|
+
if (oldValue?.length === newValue.length
|
|
22
|
+
&& oldValue.every((v, i) => v === newValue[i])) {
|
|
23
|
+
return oldValue;
|
|
24
|
+
}
|
|
25
|
+
return newValue;
|
|
26
|
+
});
|
|
27
|
+
const getTemplate = computedNullableSfcBlock('template', 'html', (0, alien_signals_1.computed)(() => getParseResult()?.descriptor.template ?? undefined), (_block, base) => {
|
|
28
|
+
const compiledAst = computedTemplateAst(base);
|
|
29
|
+
return mergeObject(base, {
|
|
30
|
+
get ast() {
|
|
31
|
+
return compiledAst().ast;
|
|
32
|
+
},
|
|
33
|
+
get errors() {
|
|
34
|
+
return compiledAst().errors;
|
|
35
|
+
},
|
|
36
|
+
get warnings() {
|
|
37
|
+
return compiledAst().warnings;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
const getScript = computedNullableSfcBlock('script', 'js', (0, alien_signals_1.computed)(() => getParseResult()?.descriptor.script ?? undefined), (block, base) => {
|
|
42
|
+
const getSrc = computedAttrValue('__src', base, block);
|
|
43
|
+
const getAst = (0, alien_signals_1.computed)(() => {
|
|
44
|
+
for (const plugin of plugins) {
|
|
45
|
+
const ast = plugin.compileSFCScript?.(base.lang, base.content);
|
|
46
|
+
if (ast) {
|
|
47
|
+
return ast;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
|
|
51
|
+
});
|
|
52
|
+
return mergeObject(base, {
|
|
53
|
+
get src() {
|
|
54
|
+
return getSrc();
|
|
55
|
+
},
|
|
56
|
+
get ast() {
|
|
57
|
+
return getAst();
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
const getOriginalScriptSetup = computedNullableSfcBlock('scriptSetup', 'js', (0, alien_signals_1.computed)(() => getParseResult()?.descriptor.scriptSetup ?? undefined), (block, base) => {
|
|
62
|
+
const getGeneric = computedAttrValue('__generic', base, block);
|
|
63
|
+
const getAst = (0, alien_signals_1.computed)(() => {
|
|
64
|
+
for (const plugin of plugins) {
|
|
65
|
+
const ast = plugin.compileSFCScript?.(base.lang, base.content);
|
|
66
|
+
if (ast) {
|
|
67
|
+
return ast;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
|
|
71
|
+
});
|
|
72
|
+
return mergeObject(base, {
|
|
73
|
+
get generic() {
|
|
74
|
+
return getGeneric();
|
|
75
|
+
},
|
|
76
|
+
get ast() {
|
|
77
|
+
return getAst();
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
const hasScript = (0, alien_signals_1.computed)(() => !!getParseResult()?.descriptor.script);
|
|
82
|
+
const hasScriptSetup = (0, alien_signals_1.computed)(() => !!getParseResult()?.descriptor.scriptSetup);
|
|
83
|
+
const getScriptSetup = (0, alien_signals_1.computed)(() => {
|
|
84
|
+
if (!hasScript() && !hasScriptSetup()) {
|
|
85
|
+
// #region monkey fix: https://github.com/vuejs/language-tools/pull/2113
|
|
86
|
+
return {
|
|
87
|
+
content: '',
|
|
88
|
+
lang: 'ts',
|
|
89
|
+
name: '',
|
|
90
|
+
start: 0,
|
|
91
|
+
end: 0,
|
|
92
|
+
startTagEnd: 0,
|
|
93
|
+
endTagStart: 0,
|
|
94
|
+
generic: undefined,
|
|
95
|
+
genericOffset: 0,
|
|
96
|
+
attrs: {},
|
|
97
|
+
ast: ts.createSourceFile('', '', 99, false, ts.ScriptKind.TS),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return getOriginalScriptSetup();
|
|
101
|
+
});
|
|
102
|
+
const styles = (0, signals_1.computedArray)((0, alien_signals_1.computed)(() => getParseResult()?.descriptor.styles ?? []), (getBlock, i) => {
|
|
103
|
+
const base = computedSfcBlock('style_' + i, 'css', getBlock);
|
|
104
|
+
const getSrc = computedAttrValue('__src', base, getBlock);
|
|
105
|
+
const getModule = computedAttrValue('__module', base, getBlock);
|
|
106
|
+
const getScoped = (0, alien_signals_1.computed)(() => !!getBlock().scoped);
|
|
107
|
+
const getIr = (0, alien_signals_1.computed)(() => {
|
|
108
|
+
for (const plugin of plugins) {
|
|
109
|
+
const ast = plugin.compileSFCStyle?.(base.lang, base.content);
|
|
110
|
+
if (ast) {
|
|
111
|
+
return ast;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
const getImports = (0, signals_1.computedItems)(() => getIr()?.imports ?? [], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
116
|
+
const getBindings = (0, signals_1.computedItems)(() => getIr()?.bindings ?? [], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
117
|
+
const getClassNames = (0, signals_1.computedItems)(() => getIr()?.classNames ?? [], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
118
|
+
return () => mergeObject(base, {
|
|
119
|
+
get src() {
|
|
120
|
+
return getSrc();
|
|
121
|
+
},
|
|
122
|
+
get module() {
|
|
123
|
+
return getModule();
|
|
124
|
+
},
|
|
125
|
+
get scoped() {
|
|
126
|
+
return getScoped();
|
|
127
|
+
},
|
|
128
|
+
get imports() {
|
|
129
|
+
return getImports();
|
|
130
|
+
},
|
|
131
|
+
get bindings() {
|
|
132
|
+
return getBindings();
|
|
133
|
+
},
|
|
134
|
+
get classNames() {
|
|
135
|
+
return getClassNames();
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
const customBlocks = (0, signals_1.computedArray)((0, alien_signals_1.computed)(() => getParseResult()?.descriptor.customBlocks ?? []), (getBlock, i) => {
|
|
140
|
+
const base = computedSfcBlock('custom_block_' + i, 'txt', getBlock);
|
|
141
|
+
const getType = (0, alien_signals_1.computed)(() => getBlock().type);
|
|
142
|
+
return () => mergeObject(base, {
|
|
143
|
+
get type() {
|
|
144
|
+
return getType();
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
return {
|
|
149
|
+
get content() {
|
|
150
|
+
return getContent();
|
|
151
|
+
},
|
|
152
|
+
get comments() {
|
|
153
|
+
return getComments();
|
|
154
|
+
},
|
|
155
|
+
get template() {
|
|
156
|
+
return getTemplate();
|
|
157
|
+
},
|
|
158
|
+
get script() {
|
|
159
|
+
return getScript();
|
|
160
|
+
},
|
|
161
|
+
get scriptSetup() {
|
|
162
|
+
return getScriptSetup();
|
|
163
|
+
},
|
|
164
|
+
get styles() {
|
|
165
|
+
return styles;
|
|
166
|
+
},
|
|
167
|
+
get customBlocks() {
|
|
168
|
+
return customBlocks;
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
function computedTemplateAst(base) {
|
|
172
|
+
let cache;
|
|
173
|
+
let inlineTsAsts;
|
|
174
|
+
function updateInlineTsAsts(newAst, oldAst) {
|
|
175
|
+
let newTsAsts = exports.templateInlineTsAsts.get(newAst);
|
|
176
|
+
if (!newTsAsts) {
|
|
177
|
+
exports.templateInlineTsAsts.set(newAst, newTsAsts = new Map());
|
|
178
|
+
}
|
|
179
|
+
const oldTsAsts = oldAst && exports.templateInlineTsAsts.get(oldAst) || inlineTsAsts;
|
|
180
|
+
if (oldTsAsts) {
|
|
181
|
+
for (const [text, ast] of oldTsAsts) {
|
|
182
|
+
if (!ast.__volar_used) {
|
|
183
|
+
oldTsAsts.delete(text);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
newTsAsts.set(text, ast);
|
|
187
|
+
ast.__volar_used = false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
inlineTsAsts = new Map(newTsAsts);
|
|
192
|
+
}
|
|
193
|
+
return (0, alien_signals_1.computed)(() => {
|
|
194
|
+
if (cache?.template === base.content) {
|
|
195
|
+
return {
|
|
196
|
+
errors: [],
|
|
197
|
+
warnings: [],
|
|
198
|
+
ast: cache.result.ast,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
// incremental update
|
|
202
|
+
if (cache?.plugin.updateSFCTemplate) {
|
|
203
|
+
const change = getUntrackedSnapshot().getChangeRange(cache.snapshot);
|
|
204
|
+
if (change) {
|
|
205
|
+
const pausedSub = (0, alien_signals_1.setActiveSub)(undefined);
|
|
206
|
+
const templateOffset = base.startTagEnd;
|
|
207
|
+
(0, alien_signals_1.setActiveSub)(pausedSub);
|
|
208
|
+
const newText = getUntrackedSnapshot().getText(change.span.start, change.span.start + change.newLength);
|
|
209
|
+
const newResult = cache.plugin.updateSFCTemplate(cache.result, {
|
|
210
|
+
start: change.span.start - templateOffset,
|
|
211
|
+
end: change.span.start + change.span.length - templateOffset,
|
|
212
|
+
newText,
|
|
213
|
+
});
|
|
214
|
+
if (newResult) {
|
|
215
|
+
updateInlineTsAsts(newResult.ast, cache.result.ast);
|
|
216
|
+
cache.template = base.content;
|
|
217
|
+
cache.snapshot = getUntrackedSnapshot();
|
|
218
|
+
cache.result = newResult;
|
|
219
|
+
return {
|
|
220
|
+
errors: [],
|
|
221
|
+
warnings: [],
|
|
222
|
+
ast: newResult.ast,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const errors = [];
|
|
228
|
+
const warnings = [];
|
|
229
|
+
const [nodeTransforms, directiveTransforms] = CompilerDOM.getBaseTransformPreset();
|
|
230
|
+
let options = {
|
|
231
|
+
onError: err => errors.push(err),
|
|
232
|
+
onWarn: err => warnings.push(err),
|
|
233
|
+
expressionPlugins: ['typescript'],
|
|
234
|
+
nodeTransforms,
|
|
235
|
+
directiveTransforms,
|
|
236
|
+
};
|
|
237
|
+
for (const plugin of plugins) {
|
|
238
|
+
if (plugin.resolveTemplateCompilerOptions) {
|
|
239
|
+
options = plugin.resolveTemplateCompilerOptions(options);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
for (const plugin of plugins) {
|
|
243
|
+
let result;
|
|
244
|
+
try {
|
|
245
|
+
result = plugin.compileSFCTemplate?.(base.lang, base.content, options);
|
|
246
|
+
if (result) {
|
|
247
|
+
updateInlineTsAsts(result.ast, cache?.result.ast);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
const err = e;
|
|
252
|
+
errors.push(err);
|
|
253
|
+
}
|
|
254
|
+
if (result || errors.length) {
|
|
255
|
+
if (result && !errors.length && !warnings.length) {
|
|
256
|
+
cache = {
|
|
257
|
+
template: base.content,
|
|
258
|
+
snapshot: getUntrackedSnapshot(),
|
|
259
|
+
result: result,
|
|
260
|
+
plugin,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
cache = undefined;
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
errors,
|
|
268
|
+
warnings,
|
|
269
|
+
ast: result?.ast,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
errors,
|
|
275
|
+
warnings,
|
|
276
|
+
ast: undefined,
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function computedNullableSfcBlock(name, defaultLang, getBlock, resolve) {
|
|
281
|
+
const hasBlock = (0, alien_signals_1.computed)(() => !!getBlock());
|
|
282
|
+
return (0, alien_signals_1.computed)(() => {
|
|
283
|
+
if (!hasBlock()) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const _block = (0, alien_signals_1.computed)(() => getBlock());
|
|
287
|
+
return resolve(_block, computedSfcBlock(name, defaultLang, _block));
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function computedSfcBlock(name, defaultLang, getBlock) {
|
|
291
|
+
const getLang = (0, alien_signals_1.computed)(() => getBlock().lang ?? defaultLang);
|
|
292
|
+
const getAttrs = (0, alien_signals_1.computed)(() => getBlock().attrs); // TODO: computed it
|
|
293
|
+
const getContent = (0, alien_signals_1.computed)(() => getBlock().content);
|
|
294
|
+
const getStartTagEnd = (0, alien_signals_1.computed)(() => getBlock().loc.start.offset);
|
|
295
|
+
const getEndTagStart = (0, alien_signals_1.computed)(() => getBlock().loc.end.offset);
|
|
296
|
+
const getStart = (0, alien_signals_1.computed)(() => getUntrackedSnapshot().getText(0, getStartTagEnd()).lastIndexOf('<' + getBlock().type));
|
|
297
|
+
const getEnd = (0, alien_signals_1.computed)(() => getEndTagStart()
|
|
298
|
+
+ getUntrackedSnapshot().getText(getEndTagStart(), getUntrackedSnapshot().getLength()).indexOf('>') + 1);
|
|
299
|
+
return {
|
|
300
|
+
name,
|
|
301
|
+
get lang() {
|
|
302
|
+
return getLang();
|
|
303
|
+
},
|
|
304
|
+
get attrs() {
|
|
305
|
+
return getAttrs();
|
|
306
|
+
},
|
|
307
|
+
get content() {
|
|
308
|
+
return getContent();
|
|
309
|
+
},
|
|
310
|
+
get startTagEnd() {
|
|
311
|
+
return getStartTagEnd();
|
|
312
|
+
},
|
|
313
|
+
get endTagStart() {
|
|
314
|
+
return getEndTagStart();
|
|
315
|
+
},
|
|
316
|
+
get start() {
|
|
317
|
+
return getStart();
|
|
318
|
+
},
|
|
319
|
+
get end() {
|
|
320
|
+
return getEnd();
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function computedAttrValue(key, base, getBlock) {
|
|
325
|
+
return (0, alien_signals_1.computed)(() => {
|
|
326
|
+
const val = getBlock()[key];
|
|
327
|
+
if (typeof val === 'object') {
|
|
328
|
+
return {
|
|
329
|
+
...val,
|
|
330
|
+
offset: base.start + val.offset,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
return val;
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function mergeObject(a, b) {
|
|
338
|
+
return Object.defineProperties(a, Object.getOwnPropertyDescriptors(b));
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=computedSfc.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
|
+
import type { VueLanguagePluginReturn } from '../types';
|
|
4
|
+
export declare function computedVueSfc(plugins: VueLanguagePluginReturn[], fileName: string, languageId: string, getSnapshot: () => ts.IScriptSnapshot): () => SFCParseResult | undefined;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computedVueSfc = computedVueSfc;
|
|
4
|
+
const alien_signals_1 = require("alien-signals");
|
|
5
|
+
function computedVueSfc(plugins, fileName, languageId, getSnapshot) {
|
|
6
|
+
let cache;
|
|
7
|
+
return (0, alien_signals_1.computed)(() => {
|
|
8
|
+
// incremental update
|
|
9
|
+
if (cache?.plugin.updateSFC) {
|
|
10
|
+
const change = getSnapshot().getChangeRange(cache.snapshot);
|
|
11
|
+
if (change) {
|
|
12
|
+
const newSfc = cache.plugin.updateSFC(cache.sfc, {
|
|
13
|
+
start: change.span.start,
|
|
14
|
+
end: change.span.start + change.span.length,
|
|
15
|
+
newText: getSnapshot().getText(change.span.start, change.span.start + change.newLength),
|
|
16
|
+
});
|
|
17
|
+
if (newSfc) {
|
|
18
|
+
cache.snapshot = getSnapshot();
|
|
19
|
+
// force dirty
|
|
20
|
+
cache.sfc = JSON.parse(JSON.stringify(newSfc));
|
|
21
|
+
return cache.sfc;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
for (const plugin of plugins) {
|
|
26
|
+
const sfc = plugin.parseSFC?.(fileName, getSnapshot().getText(0, getSnapshot().getLength()))
|
|
27
|
+
?? plugin.parseSFC2?.(fileName, languageId, getSnapshot().getText(0, getSnapshot().getLength()));
|
|
28
|
+
if (sfc) {
|
|
29
|
+
if (!sfc.errors.length) {
|
|
30
|
+
cache = {
|
|
31
|
+
snapshot: getSnapshot(),
|
|
32
|
+
sfc,
|
|
33
|
+
plugin,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return sfc;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=computedVueSfc.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Mapping } from '@volar/language-core';
|
|
2
|
+
import type { Code } from '../types';
|
|
3
|
+
export declare class VueEmbeddedCode {
|
|
4
|
+
id: string;
|
|
5
|
+
lang: string;
|
|
6
|
+
content: Code[];
|
|
7
|
+
parentCodeId?: string;
|
|
8
|
+
linkedCodeMappings: Mapping[];
|
|
9
|
+
embeddedCodes: VueEmbeddedCode[];
|
|
10
|
+
constructor(id: string, lang: string, content: Code[]);
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VueEmbeddedCode = void 0;
|
|
4
|
+
class VueEmbeddedCode {
|
|
5
|
+
constructor(id, lang, content) {
|
|
6
|
+
this.id = id;
|
|
7
|
+
this.lang = lang;
|
|
8
|
+
this.content = content;
|
|
9
|
+
this.linkedCodeMappings = [];
|
|
10
|
+
this.embeddedCodes = [];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.VueEmbeddedCode = VueEmbeddedCode;
|
|
14
|
+
//# sourceMappingURL=embeddedFile.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CodeInformation, Mapping, VirtualCode } from '@volar/language-core';
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
|
+
import type { VueCompilerOptions, VueLanguagePluginReturn } from '../types';
|
|
4
|
+
import { computedSfc } from './computedSfc';
|
|
5
|
+
export declare class VueVirtualCode implements VirtualCode {
|
|
6
|
+
fileName: string;
|
|
7
|
+
languageId: string;
|
|
8
|
+
initSnapshot: ts.IScriptSnapshot;
|
|
9
|
+
vueCompilerOptions: VueCompilerOptions;
|
|
10
|
+
plugins: VueLanguagePluginReturn[];
|
|
11
|
+
ts: typeof import('typescript');
|
|
12
|
+
readonly id = "main";
|
|
13
|
+
readonly sfc: ReturnType<typeof computedSfc>;
|
|
14
|
+
private _snapshot;
|
|
15
|
+
private _vueSfc;
|
|
16
|
+
private _embeddedCodes;
|
|
17
|
+
private _mappings;
|
|
18
|
+
get snapshot(): ts.IScriptSnapshot;
|
|
19
|
+
get vueSfc(): import("@vue/compiler-sfc").SFCParseResult | undefined;
|
|
20
|
+
get embeddedCodes(): VirtualCode[];
|
|
21
|
+
get mappings(): Mapping<CodeInformation>[];
|
|
22
|
+
constructor(fileName: string, languageId: string, initSnapshot: ts.IScriptSnapshot, vueCompilerOptions: VueCompilerOptions, plugins: VueLanguagePluginReturn[], ts: typeof import('typescript'));
|
|
23
|
+
update(newSnapshot: ts.IScriptSnapshot): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VueVirtualCode = void 0;
|
|
4
|
+
const alien_signals_1 = require("alien-signals");
|
|
5
|
+
const plugins_1 = require("../plugins");
|
|
6
|
+
const computedEmbeddedCodes_1 = require("./computedEmbeddedCodes");
|
|
7
|
+
const computedSfc_1 = require("./computedSfc");
|
|
8
|
+
const computedVueSfc_1 = require("./computedVueSfc");
|
|
9
|
+
class VueVirtualCode {
|
|
10
|
+
get snapshot() {
|
|
11
|
+
return this._snapshot();
|
|
12
|
+
}
|
|
13
|
+
get vueSfc() {
|
|
14
|
+
return this._vueSfc();
|
|
15
|
+
}
|
|
16
|
+
get embeddedCodes() {
|
|
17
|
+
return this._embeddedCodes();
|
|
18
|
+
}
|
|
19
|
+
get mappings() {
|
|
20
|
+
return this._mappings();
|
|
21
|
+
}
|
|
22
|
+
constructor(fileName, languageId, initSnapshot, vueCompilerOptions, plugins, ts) {
|
|
23
|
+
this.fileName = fileName;
|
|
24
|
+
this.languageId = languageId;
|
|
25
|
+
this.initSnapshot = initSnapshot;
|
|
26
|
+
this.vueCompilerOptions = vueCompilerOptions;
|
|
27
|
+
this.plugins = plugins;
|
|
28
|
+
this.ts = ts;
|
|
29
|
+
this.id = 'main';
|
|
30
|
+
this._snapshot = (0, alien_signals_1.signal)(initSnapshot);
|
|
31
|
+
this._vueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, this.languageId, this._snapshot);
|
|
32
|
+
this.sfc = (0, computedSfc_1.computedSfc)(this.ts, this.plugins, this.fileName, this._snapshot, this._vueSfc);
|
|
33
|
+
this._embeddedCodes = (0, computedEmbeddedCodes_1.computedEmbeddedCodes)(this.plugins, this.fileName, this.sfc);
|
|
34
|
+
this._mappings = (0, alien_signals_1.computed)(() => {
|
|
35
|
+
const snapshot = this._snapshot();
|
|
36
|
+
return [{
|
|
37
|
+
sourceOffsets: [0],
|
|
38
|
+
generatedOffsets: [0],
|
|
39
|
+
lengths: [snapshot.getLength()],
|
|
40
|
+
data: plugins_1.allCodeFeatures,
|
|
41
|
+
}];
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
update(newSnapshot) {
|
|
45
|
+
this._snapshot(newSnapshot);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.VueVirtualCode = VueVirtualCode;
|
|
49
|
+
//# sourceMappingURL=vueFile.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"optional": true
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "0c9b66d0332698a1764fa56b64d47a6a30e81b47"
|
|
40
40
|
}
|