@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
package/lib/utils/ts.js
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompilerOptionsResolver = void 0;
|
|
3
4
|
exports.createParsedCommandLineByJson = createParsedCommandLineByJson;
|
|
4
5
|
exports.createParsedCommandLine = createParsedCommandLine;
|
|
6
|
+
exports.getDefaultCompilerOptions = getDefaultCompilerOptions;
|
|
5
7
|
exports.resolveVueCompilerOptions = resolveVueCompilerOptions;
|
|
6
8
|
exports.setupGlobalTypes = setupGlobalTypes;
|
|
7
9
|
const shared_1 = require("@vue/shared");
|
|
8
10
|
const path_browserify_1 = require("path-browserify");
|
|
9
11
|
const globalTypes_1 = require("../codegen/globalTypes");
|
|
10
12
|
const languagePlugin_1 = require("../languagePlugin");
|
|
13
|
+
const shared_2 = require("./shared");
|
|
11
14
|
function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, configFileName = rootDir + '/jsconfig.json', skipGlobalTypesSetup = false) {
|
|
12
15
|
const proxyHost = proxyParseConfigHostForExtendConfigPaths(parseConfigHost);
|
|
13
16
|
ts.parseJsonConfigFileContent(json, proxyHost.host, rootDir, {}, configFileName);
|
|
14
|
-
|
|
17
|
+
const resolver = new CompilerOptionsResolver();
|
|
15
18
|
for (const extendPath of proxyHost.extendConfigPaths.reverse()) {
|
|
16
19
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const configFile = ts.readJsonConfigFile(extendPath, proxyHost.host.readFile);
|
|
21
|
+
const obj = ts.convertToObject(configFile, []);
|
|
22
|
+
const rawOptions = obj?.vueCompilerOptions ?? {};
|
|
23
|
+
resolver.addConfig(rawOptions, path_browserify_1.posix.dirname(configFile.fileName));
|
|
21
24
|
}
|
|
22
25
|
catch (err) { }
|
|
23
26
|
}
|
|
24
|
-
const resolvedVueOptions =
|
|
27
|
+
const resolvedVueOptions = resolver.build();
|
|
25
28
|
if (skipGlobalTypesSetup) {
|
|
26
29
|
resolvedVueOptions.__setupedGlobalTypes = true;
|
|
27
30
|
}
|
|
@@ -48,17 +51,17 @@ function createParsedCommandLine(ts, parseConfigHost, tsConfigPath, skipGlobalTy
|
|
|
48
51
|
const proxyHost = proxyParseConfigHostForExtendConfigPaths(parseConfigHost);
|
|
49
52
|
const config = ts.readJsonConfigFile(tsConfigPath, proxyHost.host.readFile);
|
|
50
53
|
ts.parseJsonSourceFileConfigFileContent(config, proxyHost.host, path_browserify_1.posix.dirname(tsConfigPath), {}, tsConfigPath);
|
|
51
|
-
|
|
54
|
+
const resolver = new CompilerOptionsResolver();
|
|
52
55
|
for (const extendPath of proxyHost.extendConfigPaths.reverse()) {
|
|
53
56
|
try {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
const configFile = ts.readJsonConfigFile(extendPath, proxyHost.host.readFile);
|
|
58
|
+
const obj = ts.convertToObject(configFile, []);
|
|
59
|
+
const rawOptions = obj?.vueCompilerOptions ?? {};
|
|
60
|
+
resolver.addConfig(rawOptions, path_browserify_1.posix.dirname(configFile.fileName));
|
|
58
61
|
}
|
|
59
62
|
catch (err) { }
|
|
60
63
|
}
|
|
61
|
-
const resolvedVueOptions =
|
|
64
|
+
const resolvedVueOptions = resolver.build();
|
|
62
65
|
if (skipGlobalTypesSetup) {
|
|
63
66
|
resolvedVueOptions.__setupedGlobalTypes = true;
|
|
64
67
|
}
|
|
@@ -85,7 +88,7 @@ function createParsedCommandLine(ts, parseConfigHost, tsConfigPath, skipGlobalTy
|
|
|
85
88
|
return {
|
|
86
89
|
fileNames: [],
|
|
87
90
|
options: {},
|
|
88
|
-
vueOptions:
|
|
91
|
+
vueOptions: getDefaultCompilerOptions(),
|
|
89
92
|
errors: [],
|
|
90
93
|
};
|
|
91
94
|
}
|
|
@@ -110,67 +113,104 @@ function proxyParseConfigHostForExtendConfigPaths(parseConfigHost) {
|
|
|
110
113
|
extendConfigPaths,
|
|
111
114
|
};
|
|
112
115
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
class CompilerOptionsResolver {
|
|
117
|
+
constructor() {
|
|
118
|
+
this.options = {};
|
|
119
|
+
this.plugins = [];
|
|
120
|
+
}
|
|
121
|
+
addConfig(options, rootDir) {
|
|
122
|
+
for (const key in options) {
|
|
123
|
+
switch (key) {
|
|
124
|
+
case 'target':
|
|
125
|
+
const target = options.target;
|
|
126
|
+
if (typeof target === 'string') {
|
|
127
|
+
this.target = findVueVersion(rootDir);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.target = target;
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case 'plugins':
|
|
134
|
+
this.plugins = (options.plugins ?? [])
|
|
135
|
+
.map((pluginPath) => {
|
|
136
|
+
try {
|
|
137
|
+
const resolvedPath = resolvePath(pluginPath, rootDir);
|
|
138
|
+
if (resolvedPath) {
|
|
139
|
+
const plugin = require(resolvedPath);
|
|
140
|
+
plugin.__moduleName = pluginPath;
|
|
141
|
+
return plugin;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
console.warn('[Vue] Load plugin failed:', pluginPath);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
console.warn('[Vue] Resolve plugin path failed:', pluginPath, error);
|
|
149
|
+
}
|
|
150
|
+
return [];
|
|
151
|
+
});
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
// @ts-expect-error
|
|
155
|
+
this.options[key] = options[key];
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
127
158
|
}
|
|
128
|
-
|
|
129
|
-
|
|
159
|
+
if (this.target === undefined) {
|
|
160
|
+
this.fallbackTarget = findVueVersion(rootDir);
|
|
130
161
|
}
|
|
131
162
|
}
|
|
132
|
-
|
|
133
|
-
|
|
163
|
+
build(defaults) {
|
|
164
|
+
const target = this.target ?? this.fallbackTarget;
|
|
165
|
+
defaults ??= getDefaultCompilerOptions(target, this.options.lib, this.options.strictTemplates);
|
|
166
|
+
return {
|
|
167
|
+
...defaults,
|
|
168
|
+
...this.options,
|
|
169
|
+
plugins: this.plugins,
|
|
170
|
+
macros: {
|
|
171
|
+
...defaults.macros,
|
|
172
|
+
...this.options.macros,
|
|
173
|
+
},
|
|
174
|
+
composables: {
|
|
175
|
+
...defaults.composables,
|
|
176
|
+
...this.options.composables,
|
|
177
|
+
},
|
|
178
|
+
fallthroughComponentNames: [
|
|
179
|
+
...defaults.fallthroughComponentNames,
|
|
180
|
+
...this.options.fallthroughComponentNames ?? []
|
|
181
|
+
].map(shared_2.hyphenateTag),
|
|
182
|
+
// https://github.com/vuejs/vue-next/blob/master/packages/compiler-dom/src/transforms/vModel.ts#L49-L51
|
|
183
|
+
// https://vuejs.org/guide/essentials/forms.html#form-input-bindings
|
|
184
|
+
experimentalModelPropName: Object.fromEntries(Object.entries(this.options.experimentalModelPropName ?? defaults.experimentalModelPropName).map(([k, v]) => [(0, shared_1.camelize)(k), v])),
|
|
185
|
+
};
|
|
134
186
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return plugin;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
console.warn('[Vue] Load plugin failed:', pluginPath);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
console.warn('[Vue] Resolve plugin path failed:', pluginPath, error);
|
|
151
|
-
}
|
|
152
|
-
return [];
|
|
153
|
-
});
|
|
154
|
-
result.plugins = plugins;
|
|
187
|
+
}
|
|
188
|
+
exports.CompilerOptionsResolver = CompilerOptionsResolver;
|
|
189
|
+
function findVueVersion(rootDir) {
|
|
190
|
+
const resolvedPath = resolvePath('vue/package.json', rootDir);
|
|
191
|
+
if (resolvedPath) {
|
|
192
|
+
const vuePackageJson = require(resolvedPath);
|
|
193
|
+
const versionNumbers = vuePackageJson.version.split('.');
|
|
194
|
+
return Number(versionNumbers[0] + '.' + versionNumbers[1]);
|
|
155
195
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
196
|
+
else {
|
|
197
|
+
// console.warn('Load vue/package.json failed from', folder);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function resolvePath(scriptPath, root) {
|
|
201
|
+
try {
|
|
202
|
+
if (require?.resolve) {
|
|
203
|
+
return require.resolve(scriptPath, { paths: [root] });
|
|
165
204
|
}
|
|
166
|
-
|
|
167
|
-
// console.warn(
|
|
205
|
+
else {
|
|
206
|
+
// console.warn('failed to resolve path:', scriptPath, 'require.resolve is not supported in web');
|
|
168
207
|
}
|
|
169
208
|
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
// console.warn(error);
|
|
211
|
+
}
|
|
170
212
|
}
|
|
171
|
-
function
|
|
172
|
-
const target = options.target ?? 3.3;
|
|
173
|
-
const lib = options.lib ?? 'vue';
|
|
213
|
+
function getDefaultCompilerOptions(target = 99, lib = 'vue', strictTemplates = false) {
|
|
174
214
|
return {
|
|
175
215
|
target,
|
|
176
216
|
lib,
|
|
@@ -178,9 +218,24 @@ function getDefaultOptions(options) {
|
|
|
178
218
|
vitePressExtensions: [],
|
|
179
219
|
petiteVueExtensions: [],
|
|
180
220
|
jsxSlots: false,
|
|
181
|
-
|
|
221
|
+
checkUnknownProps: strictTemplates,
|
|
222
|
+
checkUnknownEvents: strictTemplates,
|
|
223
|
+
checkUnknownDirectives: strictTemplates,
|
|
224
|
+
checkUnknownComponents: strictTemplates,
|
|
225
|
+
inferComponentDollarEl: false,
|
|
226
|
+
inferComponentDollarRefs: false,
|
|
227
|
+
inferTemplateDollarAttrs: false,
|
|
228
|
+
inferTemplateDollarEl: false,
|
|
229
|
+
inferTemplateDollarRefs: false,
|
|
230
|
+
inferTemplateDollarSlots: false,
|
|
182
231
|
skipTemplateCodegen: false,
|
|
183
232
|
fallthroughAttributes: false,
|
|
233
|
+
fallthroughComponentNames: [
|
|
234
|
+
'Transition',
|
|
235
|
+
'KeepAlive',
|
|
236
|
+
'Teleport',
|
|
237
|
+
'Suspense',
|
|
238
|
+
],
|
|
184
239
|
dataAttributes: [],
|
|
185
240
|
htmlAttributes: ['aria-*'],
|
|
186
241
|
optionsWrapper: target >= 2.7
|
|
@@ -204,25 +259,7 @@ function getDefaultOptions(options) {
|
|
|
204
259
|
plugins: [],
|
|
205
260
|
experimentalDefinePropProposal: false,
|
|
206
261
|
experimentalResolveStyleCssClasses: 'scoped',
|
|
207
|
-
experimentalModelPropName:
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
;
|
|
211
|
-
function resolveVueCompilerOptions(options, defaults = getDefaultOptions(options)) {
|
|
212
|
-
return {
|
|
213
|
-
...defaults,
|
|
214
|
-
...options,
|
|
215
|
-
macros: {
|
|
216
|
-
...defaults.macros,
|
|
217
|
-
...options.macros,
|
|
218
|
-
},
|
|
219
|
-
composables: {
|
|
220
|
-
...defaults.composables,
|
|
221
|
-
...options.composables,
|
|
222
|
-
},
|
|
223
|
-
// https://github.com/vuejs/vue-next/blob/master/packages/compiler-dom/src/transforms/vModel.ts#L49-L51
|
|
224
|
-
// https://vuejs.org/guide/essentials/forms.html#form-input-bindings
|
|
225
|
-
experimentalModelPropName: Object.fromEntries(Object.entries(options.experimentalModelPropName ?? defaults.experimentalModelPropName ?? {
|
|
262
|
+
experimentalModelPropName: {
|
|
226
263
|
'': {
|
|
227
264
|
input: true
|
|
228
265
|
},
|
|
@@ -231,7 +268,16 @@ function resolveVueCompilerOptions(options, defaults = getDefaultOptions(options
|
|
|
231
268
|
textarea: true,
|
|
232
269
|
select: true
|
|
233
270
|
}
|
|
234
|
-
}
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @deprecated use `getDefaultCompilerOptions` instead
|
|
276
|
+
*/
|
|
277
|
+
function resolveVueCompilerOptions(options) {
|
|
278
|
+
return {
|
|
279
|
+
...getDefaultCompilerOptions(options.target, options.lib),
|
|
280
|
+
...options,
|
|
235
281
|
};
|
|
236
282
|
}
|
|
237
283
|
function setupGlobalTypes(rootDir, vueOptions, host) {
|
|
@@ -247,8 +293,8 @@ function setupGlobalTypes(rootDir, vueOptions, host) {
|
|
|
247
293
|
}
|
|
248
294
|
dir = parentDir;
|
|
249
295
|
}
|
|
250
|
-
const globalTypesPath = path_browserify_1.posix.join(dir, 'node_modules', '.vue-global-types',
|
|
251
|
-
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + (0, globalTypes_1.generateGlobalTypes)(vueOptions
|
|
296
|
+
const globalTypesPath = path_browserify_1.posix.join(dir, 'node_modules', '.vue-global-types', (0, globalTypes_1.getGlobalTypesFileName)(vueOptions));
|
|
297
|
+
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + (0, globalTypes_1.generateGlobalTypes)(vueOptions);
|
|
252
298
|
host.writeFile(globalTypesPath, globalTypesContents);
|
|
253
299
|
return { absolutePath: globalTypesPath };
|
|
254
300
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { VirtualCode } from '@volar/language-core';
|
|
2
2
|
import type { Sfc, VueLanguagePluginReturn } from '../types';
|
|
3
|
-
export declare function computedEmbeddedCodes(plugins: VueLanguagePluginReturn[], fileName: string, sfc: Sfc):
|
|
3
|
+
export declare function computedEmbeddedCodes(plugins: VueLanguagePluginReturn[], fileName: string, sfc: Sfc): () => VirtualCode[];
|
|
4
4
|
export declare function resolveCommonLanguageId(lang: string): string;
|
|
@@ -7,7 +7,7 @@ const muggle_string_1 = require("muggle-string");
|
|
|
7
7
|
const buildMappings_1 = require("../utils/buildMappings");
|
|
8
8
|
const embeddedFile_1 = require("./embeddedFile");
|
|
9
9
|
function computedEmbeddedCodes(plugins, fileName, sfc) {
|
|
10
|
-
const
|
|
10
|
+
const getNameToBlockMap = (0, alien_signals_1.computed)(() => {
|
|
11
11
|
const blocks = {};
|
|
12
12
|
if (sfc.template) {
|
|
13
13
|
blocks[sfc.template.name] = sfc.template;
|
|
@@ -26,11 +26,11 @@ function computedEmbeddedCodes(plugins, fileName, sfc) {
|
|
|
26
26
|
}
|
|
27
27
|
return blocks;
|
|
28
28
|
});
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
29
|
+
const getPluginsResult = plugins.map(plugin => computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, name => getNameToBlockMap()[name]));
|
|
30
|
+
const getFlatResult = (0, alien_signals_1.computed)(() => getPluginsResult.map(r => r()).flat());
|
|
31
|
+
const getStructuredResult = (0, alien_signals_1.computed)(() => {
|
|
32
32
|
const embeddedCodes = [];
|
|
33
|
-
let remain = [...
|
|
33
|
+
let remain = [...getFlatResult()];
|
|
34
34
|
while (remain.length) {
|
|
35
35
|
const beforeLength = remain.length;
|
|
36
36
|
consumeRemain();
|
|
@@ -85,12 +85,12 @@ function computedEmbeddedCodes(plugins, fileName, sfc) {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
return
|
|
88
|
+
return getStructuredResult;
|
|
89
89
|
}
|
|
90
|
-
function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc,
|
|
90
|
+
function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, getBlockByName) {
|
|
91
91
|
const computeds = new Map();
|
|
92
92
|
const getComputedKey = (code) => code.id + '__' + code.lang;
|
|
93
|
-
const
|
|
93
|
+
const getCodes = (0, alien_signals_1.computed)(() => {
|
|
94
94
|
try {
|
|
95
95
|
if (!plugin.getEmbeddedCodes) {
|
|
96
96
|
return [...computeds.values()];
|
|
@@ -148,8 +148,8 @@ function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock
|
|
|
148
148
|
return [...computeds.values()];
|
|
149
149
|
});
|
|
150
150
|
return (0, alien_signals_1.computed)(() => {
|
|
151
|
-
return
|
|
152
|
-
const { code, snapshot } = _file
|
|
151
|
+
return getCodes().map(_file => {
|
|
152
|
+
const { code, snapshot } = _file();
|
|
153
153
|
const mappings = (0, buildMappings_1.buildMappings)(code.content.map(segment => {
|
|
154
154
|
if (typeof segment === 'string') {
|
|
155
155
|
return segment;
|
|
@@ -158,7 +158,7 @@ function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock
|
|
|
158
158
|
if (source === undefined) {
|
|
159
159
|
return segment;
|
|
160
160
|
}
|
|
161
|
-
const block =
|
|
161
|
+
const block = getBlockByName(source);
|
|
162
162
|
if (!block) {
|
|
163
163
|
// console.warn('Unable to find block: ' + source);
|
|
164
164
|
return segment;
|
|
@@ -171,28 +171,18 @@ function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock
|
|
|
171
171
|
];
|
|
172
172
|
}));
|
|
173
173
|
const newMappings = [];
|
|
174
|
-
let lastValidMapping;
|
|
175
174
|
for (let i = 0; i < mappings.length; i++) {
|
|
176
175
|
const mapping = mappings[i];
|
|
177
|
-
if (mapping.data.
|
|
178
|
-
const offsetMapping = mappings[i - mapping.data.
|
|
176
|
+
if (mapping.data.__combineOffset !== undefined) {
|
|
177
|
+
const offsetMapping = mappings[i - mapping.data.__combineOffset];
|
|
179
178
|
if (typeof offsetMapping === 'string' || !offsetMapping) {
|
|
180
|
-
throw new Error('Invalid offset mapping, mappings: ' + mappings.length + ', i: ' + i + ', offset: ' + mapping.data.
|
|
179
|
+
throw new Error('Invalid offset mapping, mappings: ' + mappings.length + ', i: ' + i + ', offset: ' + mapping.data.__combineOffset);
|
|
181
180
|
}
|
|
182
181
|
offsetMapping.sourceOffsets.push(...mapping.sourceOffsets);
|
|
183
182
|
offsetMapping.generatedOffsets.push(...mapping.generatedOffsets);
|
|
184
183
|
offsetMapping.lengths.push(...mapping.lengths);
|
|
185
184
|
continue;
|
|
186
185
|
}
|
|
187
|
-
else if (mapping.data.__combineLastMapping) {
|
|
188
|
-
lastValidMapping.sourceOffsets.push(...mapping.sourceOffsets);
|
|
189
|
-
lastValidMapping.generatedOffsets.push(...mapping.generatedOffsets);
|
|
190
|
-
lastValidMapping.lengths.push(...mapping.lengths);
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
lastValidMapping = mapping;
|
|
195
|
-
}
|
|
196
186
|
newMappings.push(mapping);
|
|
197
187
|
}
|
|
198
188
|
return {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
2
|
-
import { ISignal, Signal } from 'alien-signals';
|
|
3
2
|
import type * as ts from 'typescript';
|
|
4
3
|
import type { Sfc, VueLanguagePluginReturn } from '../types';
|
|
5
|
-
export declare function computedSfc(ts: typeof import('typescript'), plugins: VueLanguagePluginReturn[], fileName: string,
|
|
4
|
+
export declare function computedSfc(ts: typeof import('typescript'), plugins: VueLanguagePluginReturn[], fileName: string, getSnapshot: () => ts.IScriptSnapshot, getParseResult: () => SFCParseResult | undefined): Sfc;
|