@vue/language-core 3.0.7 → 3.1.0-alpha.0
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 +19 -13
- package/lib/codegen/localTypes.d.ts +2 -4
- package/lib/codegen/localTypes.js +10 -33
- package/lib/codegen/script/component.d.ts +0 -3
- package/lib/codegen/script/component.js +15 -22
- package/lib/codegen/script/context.d.ts +2 -4
- package/lib/codegen/script/index.d.ts +4 -6
- package/lib/codegen/script/index.js +70 -59
- package/lib/codegen/script/scriptSetup.js +140 -141
- package/lib/codegen/script/template.d.ts +1 -3
- package/lib/codegen/script/template.js +90 -16
- package/lib/codegen/template/context.js +1 -1
- package/lib/codegen/template/element.js +1 -3
- package/lib/codegen/template/elementProps.js +2 -6
- package/lib/codegen/template/index.d.ts +1 -1
- package/lib/codegen/template/index.js +10 -10
- package/lib/codegen/utils/index.d.ts +1 -0
- package/lib/codegen/utils/index.js +7 -0
- package/lib/compilerOptions.js +1 -3
- package/lib/languagePlugin.js +8 -19
- package/lib/parsers/scriptRanges.d.ts +0 -1
- package/lib/parsers/scriptRanges.js +6 -9
- package/lib/parsers/scriptSetupRanges.d.ts +0 -6
- package/lib/parsers/scriptSetupRanges.js +7 -93
- package/lib/plugins/vue-tsx.d.ts +2 -5
- package/lib/plugins/vue-tsx.js +15 -10
- package/lib/types.d.ts +1 -1
- package/lib/utils/shared.d.ts +0 -1
- package/lib/utils/shared.js +0 -4
- package/lib/virtualFile/vueFile.d.ts +5 -10
- package/lib/virtualFile/vueFile.js +3 -10
- package/package.json +2 -3
- package/lib/utils/ts.d.ts +0 -24
- package/lib/utils/ts.js +0 -296
- package/lib/utils/vue2TemplateCompiler.d.ts +0 -2
- package/lib/utils/vue2TemplateCompiler.js +0 -90
package/lib/compilerOptions.js
CHANGED
|
@@ -245,9 +245,7 @@ function getDefaultCompilerOptions(target = 99, lib = 'vue', strictTemplates = f
|
|
|
245
245
|
],
|
|
246
246
|
dataAttributes: [],
|
|
247
247
|
htmlAttributes: ['aria-*'],
|
|
248
|
-
optionsWrapper:
|
|
249
|
-
? [`(await import('${lib}')).defineComponent(`, `)`]
|
|
250
|
-
: [`(await import('${lib}')).default.extend(`, `)`],
|
|
248
|
+
optionsWrapper: [`(await import('${lib}')).defineComponent(`, `)`],
|
|
251
249
|
macros: {
|
|
252
250
|
defineProps: ['defineProps'],
|
|
253
251
|
defineSlots: ['defineSlots'],
|
package/lib/languagePlugin.js
CHANGED
|
@@ -6,7 +6,6 @@ exports.getAllExtensions = getAllExtensions;
|
|
|
6
6
|
const language_core_1 = require("@volar/language-core");
|
|
7
7
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
8
8
|
const plugins_1 = require("./plugins");
|
|
9
|
-
const CompilerVue2 = require("./utils/vue2TemplateCompiler");
|
|
10
9
|
const vueFile_1 = require("./virtualFile/vueFile");
|
|
11
10
|
const fileRegistries = [];
|
|
12
11
|
function getVueFileRegistry(key, plugins) {
|
|
@@ -38,12 +37,7 @@ function getFileRegistryKey(compilerOptions, vueCompilerOptions, plugins) {
|
|
|
38
37
|
function createVueLanguagePlugin(ts, compilerOptions, vueCompilerOptions, asFileName) {
|
|
39
38
|
const pluginContext = {
|
|
40
39
|
modules: {
|
|
41
|
-
'@vue/compiler-dom':
|
|
42
|
-
? {
|
|
43
|
-
...CompilerDOM,
|
|
44
|
-
compile: CompilerVue2.compile,
|
|
45
|
-
}
|
|
46
|
-
: CompilerDOM,
|
|
40
|
+
'@vue/compiler-dom': CompilerDOM,
|
|
47
41
|
typescript: ts,
|
|
48
42
|
},
|
|
49
43
|
compilerOptions,
|
|
@@ -109,17 +103,12 @@ function createVueLanguagePlugin(ts, compilerOptions, vueCompilerOptions, asFile
|
|
|
109
103
|
};
|
|
110
104
|
}
|
|
111
105
|
function getAllExtensions(options) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return [...result];
|
|
106
|
+
return [
|
|
107
|
+
...new Set([
|
|
108
|
+
'extensions',
|
|
109
|
+
'vitePressExtensions',
|
|
110
|
+
'petiteVueExtensions',
|
|
111
|
+
].flatMap(key => options[key])),
|
|
112
|
+
];
|
|
124
113
|
}
|
|
125
114
|
//# sourceMappingURL=languagePlugin.js.map
|
|
@@ -13,7 +13,6 @@ export declare function parseScriptRanges(ts: typeof import('typescript'), ast:
|
|
|
13
13
|
nameOption: TextRange | undefined;
|
|
14
14
|
inheritAttrsOption: string | undefined;
|
|
15
15
|
}) | undefined;
|
|
16
|
-
classBlockEnd: number | undefined;
|
|
17
16
|
bindings: {
|
|
18
17
|
range: TextRange;
|
|
19
18
|
moduleName?: string;
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseScriptRanges = parseScriptRanges;
|
|
4
4
|
const shared_1 = require("../utils/shared");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
6
|
function parseScriptRanges(ts, ast, hasScriptSetup) {
|
|
7
7
|
let exportDefault;
|
|
8
|
-
|
|
9
|
-
const bindings = hasScriptSetup ? (0, scriptSetupRanges_1.parseBindingRanges)(ts, ast) : [];
|
|
8
|
+
const bindings = hasScriptSetup ? (0, utils_1.parseBindingRanges)(ts, ast) : [];
|
|
10
9
|
ts.forEachChild(ast, raw => {
|
|
11
10
|
if (ts.isExportAssignment(raw)) {
|
|
12
11
|
let node = raw;
|
|
@@ -56,17 +55,15 @@ function parseScriptRanges(ts, ast, hasScriptSetup) {
|
|
|
56
55
|
nameOption: nameOptionNode ? _getStartEnd(nameOptionNode) : undefined,
|
|
57
56
|
inheritAttrsOption,
|
|
58
57
|
};
|
|
58
|
+
const comment = (0, utils_1.getClosestMultiLineCommentRange)(ts, raw, [], ast);
|
|
59
|
+
if (comment) {
|
|
60
|
+
exportDefault.start = comment.start;
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
if (ts.isClassDeclaration(raw)
|
|
62
|
-
&& raw.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword)
|
|
63
|
-
&& raw.modifiers.some(mod => mod.kind === ts.SyntaxKind.DefaultKeyword)) {
|
|
64
|
-
classBlockEnd = raw.end - 1;
|
|
65
|
-
}
|
|
66
64
|
});
|
|
67
65
|
return {
|
|
68
66
|
exportDefault,
|
|
69
|
-
classBlockEnd,
|
|
70
67
|
bindings,
|
|
71
68
|
};
|
|
72
69
|
function _getStartEnd(node) {
|
|
@@ -66,10 +66,4 @@ export declare function parseScriptSetupRanges(ts: typeof import('typescript'),
|
|
|
66
66
|
useSlots: CallExpressionRange[];
|
|
67
67
|
useTemplateRef: UseTemplateRef[];
|
|
68
68
|
};
|
|
69
|
-
export declare function parseBindingRanges(ts: typeof import('typescript'), ast: ts.SourceFile): {
|
|
70
|
-
range: TextRange;
|
|
71
|
-
moduleName?: string;
|
|
72
|
-
isDefaultImport?: boolean;
|
|
73
|
-
isNamespace?: boolean;
|
|
74
|
-
}[];
|
|
75
69
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseScriptSetupRanges = parseScriptSetupRanges;
|
|
4
|
-
exports.parseBindingRanges = parseBindingRanges;
|
|
5
4
|
const collectBindings_1 = require("../utils/collectBindings");
|
|
6
5
|
const shared_1 = require("../utils/shared");
|
|
7
|
-
const
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const tsCheckReg = /^\/\/\s*@ts-(?:no)?check(?:$|\s)/;
|
|
8
8
|
function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
9
9
|
const defineModel = [];
|
|
10
10
|
let defineProps;
|
|
@@ -20,7 +20,7 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
20
20
|
const text = ast.text;
|
|
21
21
|
const leadingCommentRanges = ts.getLeadingCommentRanges(text, 0)?.reverse() ?? [];
|
|
22
22
|
const leadingCommentEndOffset = leadingCommentRanges.find(range => tsCheckReg.test(text.slice(range.pos, range.end)))?.end ?? 0;
|
|
23
|
-
let bindings = parseBindingRanges(ts, ast);
|
|
23
|
+
let bindings = (0, utils_1.parseBindingRanges)(ts, ast);
|
|
24
24
|
let foundNonImportExportNode = false;
|
|
25
25
|
let importSectionEndOffset = 0;
|
|
26
26
|
ts.forEachChild(ast, node => {
|
|
@@ -134,7 +134,7 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
134
134
|
runtimeType,
|
|
135
135
|
defaultValue,
|
|
136
136
|
required,
|
|
137
|
-
comments: getClosestMultiLineCommentRange(ts, node, parents, ast),
|
|
137
|
+
comments: (0, utils_1.getClosestMultiLineCommentRange)(ts, node, parents, ast),
|
|
138
138
|
argNode: options,
|
|
139
139
|
});
|
|
140
140
|
}
|
|
@@ -250,7 +250,9 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
250
250
|
}
|
|
251
251
|
function parseCallExpressionAssignment(node, parent) {
|
|
252
252
|
return {
|
|
253
|
-
name: ts.isVariableDeclaration(parent)
|
|
253
|
+
name: ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name)
|
|
254
|
+
? _getNodeText(parent.name)
|
|
255
|
+
: undefined,
|
|
254
256
|
...parseCallExpression(node),
|
|
255
257
|
};
|
|
256
258
|
}
|
|
@@ -261,77 +263,6 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
261
263
|
return (0, shared_1.getNodeText)(ts, node, ast);
|
|
262
264
|
}
|
|
263
265
|
}
|
|
264
|
-
function parseBindingRanges(ts, ast) {
|
|
265
|
-
const bindings = [];
|
|
266
|
-
ts.forEachChild(ast, node => {
|
|
267
|
-
if (ts.isVariableStatement(node)) {
|
|
268
|
-
for (const decl of node.declarationList.declarations) {
|
|
269
|
-
const ranges = (0, collectBindings_1.collectBindingRanges)(ts, decl.name, ast);
|
|
270
|
-
bindings.push(...ranges.map(range => ({ range })));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
else if (ts.isFunctionDeclaration(node)) {
|
|
274
|
-
if (node.name && ts.isIdentifier(node.name)) {
|
|
275
|
-
bindings.push({
|
|
276
|
-
range: _getStartEnd(node.name),
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
else if (ts.isClassDeclaration(node)) {
|
|
281
|
-
if (node.name) {
|
|
282
|
-
bindings.push({
|
|
283
|
-
range: _getStartEnd(node.name),
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
else if (ts.isEnumDeclaration(node)) {
|
|
288
|
-
bindings.push({
|
|
289
|
-
range: _getStartEnd(node.name),
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
if (ts.isImportDeclaration(node)) {
|
|
293
|
-
const moduleName = _getNodeText(node.moduleSpecifier).slice(1, -1);
|
|
294
|
-
if (node.importClause && !node.importClause.isTypeOnly) {
|
|
295
|
-
const { name, namedBindings } = node.importClause;
|
|
296
|
-
if (name) {
|
|
297
|
-
bindings.push({
|
|
298
|
-
range: _getStartEnd(name),
|
|
299
|
-
moduleName,
|
|
300
|
-
isDefaultImport: true,
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
if (namedBindings) {
|
|
304
|
-
if (ts.isNamedImports(namedBindings)) {
|
|
305
|
-
for (const element of namedBindings.elements) {
|
|
306
|
-
if (element.isTypeOnly) {
|
|
307
|
-
continue;
|
|
308
|
-
}
|
|
309
|
-
bindings.push({
|
|
310
|
-
range: _getStartEnd(element.name),
|
|
311
|
-
moduleName,
|
|
312
|
-
isDefaultImport: element.propertyName?.text === 'default',
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
bindings.push({
|
|
318
|
-
range: _getStartEnd(namedBindings.name),
|
|
319
|
-
moduleName,
|
|
320
|
-
isNamespace: true,
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
return bindings;
|
|
328
|
-
function _getStartEnd(node) {
|
|
329
|
-
return (0, shared_1.getStartEnd)(ts, node, ast);
|
|
330
|
-
}
|
|
331
|
-
function _getNodeText(node) {
|
|
332
|
-
return (0, shared_1.getNodeText)(ts, node, ast);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
266
|
function getStatementRange(ts, parents, node, ast) {
|
|
336
267
|
let statementRange;
|
|
337
268
|
for (let i = parents.length - 1; i >= 0; i--) {
|
|
@@ -350,21 +281,4 @@ function getStatementRange(ts, parents, node, ast) {
|
|
|
350
281
|
}
|
|
351
282
|
return statementRange;
|
|
352
283
|
}
|
|
353
|
-
function getClosestMultiLineCommentRange(ts, node, parents, ast) {
|
|
354
|
-
for (let i = parents.length - 1; i >= 0; i--) {
|
|
355
|
-
if (ts.isStatement(node)) {
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
node = parents[i];
|
|
359
|
-
}
|
|
360
|
-
const comment = ts.getLeadingCommentRanges(ast.text, node.pos)
|
|
361
|
-
?.reverse()
|
|
362
|
-
.find(range => range.kind === 3);
|
|
363
|
-
if (comment) {
|
|
364
|
-
return {
|
|
365
|
-
start: comment.pos,
|
|
366
|
-
end: comment.end,
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
284
|
//# sourceMappingURL=scriptSetupRanges.js.map
|
package/lib/plugins/vue-tsx.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
12
12
|
nameOption: import("../types").TextRange | undefined;
|
|
13
13
|
inheritAttrsOption: string | undefined;
|
|
14
14
|
}) | undefined;
|
|
15
|
-
classBlockEnd: number | undefined;
|
|
16
15
|
bindings: {
|
|
17
16
|
range: import("../types").TextRange;
|
|
18
17
|
moduleName?: string;
|
|
@@ -124,11 +123,9 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
124
123
|
bypassDefineComponent: boolean;
|
|
125
124
|
bindingNames: Set<string>;
|
|
126
125
|
localTypes: {
|
|
127
|
-
generate: (
|
|
128
|
-
getUsedNames(): Set<string>;
|
|
126
|
+
generate: () => Generator<string, void, unknown>;
|
|
129
127
|
readonly PrettifyLocal: string;
|
|
130
|
-
readonly
|
|
131
|
-
readonly WithDefaults: string;
|
|
128
|
+
readonly WithDefaultsLocal: string;
|
|
132
129
|
readonly WithSlots: string;
|
|
133
130
|
readonly PropsChildren: string;
|
|
134
131
|
readonly TypePropsToOption: string;
|
package/lib/plugins/vue-tsx.js
CHANGED
|
@@ -118,25 +118,30 @@ function createTsx(fileName, sfc, ctx) {
|
|
|
118
118
|
return newNames;
|
|
119
119
|
});
|
|
120
120
|
const setupHasDefineSlots = (0, alien_signals_1.computed)(() => !!getScriptSetupRanges()?.defineSlots);
|
|
121
|
-
const getSetupSlotsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineSlots?.name);
|
|
122
121
|
const getSetupPropsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineProps?.name);
|
|
122
|
+
const getSetupSlotsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineSlots?.name);
|
|
123
123
|
const getSetupInheritAttrs = (0, alien_signals_1.computed)(() => {
|
|
124
124
|
const value = getScriptSetupRanges()?.defineOptions?.inheritAttrs
|
|
125
125
|
?? getScriptRanges()?.exportDefault?.inheritAttrsOption;
|
|
126
126
|
return value !== 'false';
|
|
127
127
|
});
|
|
128
128
|
const getComponentSelfName = (0, alien_signals_1.computed)(() => {
|
|
129
|
+
let name;
|
|
129
130
|
const { exportDefault } = getScriptRanges() ?? {};
|
|
130
131
|
if (sfc.script && exportDefault?.nameOption) {
|
|
131
|
-
|
|
132
|
-
return sfc.script.content.slice(nameOption.start + 1, nameOption.end - 1);
|
|
132
|
+
name = sfc.script.content.slice(exportDefault.nameOption.start + 1, exportDefault.nameOption.end - 1);
|
|
133
133
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
else {
|
|
135
|
+
const { defineOptions } = getScriptSetupRanges() ?? {};
|
|
136
|
+
if (sfc.scriptSetup && defineOptions?.name) {
|
|
137
|
+
name = defineOptions.name;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
const baseName = path.basename(fileName);
|
|
141
|
+
name = baseName.slice(0, baseName.lastIndexOf('.'));
|
|
142
|
+
}
|
|
137
143
|
}
|
|
138
|
-
|
|
139
|
-
return (0, shared_1.capitalize)((0, shared_1.camelize)(baseName.slice(0, baseName.lastIndexOf('.'))));
|
|
144
|
+
return (0, shared_1.capitalize)((0, shared_1.camelize)(name));
|
|
140
145
|
});
|
|
141
146
|
const getGeneratedTemplate = (0, alien_signals_1.computed)(() => {
|
|
142
147
|
if (getResolvedOptions().skipTemplateCodegen || !sfc.template) {
|
|
@@ -152,8 +157,8 @@ function createTsx(fileName, sfc, ctx) {
|
|
|
152
157
|
destructuredPropNames: getSetupDestructuredPropNames(),
|
|
153
158
|
templateRefNames: getSetupTemplateRefNames(),
|
|
154
159
|
hasDefineSlots: setupHasDefineSlots(),
|
|
155
|
-
slotsAssignName: getSetupSlotsAssignName(),
|
|
156
160
|
propsAssignName: getSetupPropsAssignName(),
|
|
161
|
+
slotsAssignName: getSetupSlotsAssignName(),
|
|
157
162
|
inheritAttrs: getSetupInheritAttrs(),
|
|
158
163
|
selfComponentName: getComponentSelfName(),
|
|
159
164
|
});
|
|
@@ -163,7 +168,7 @@ function createTsx(fileName, sfc, ctx) {
|
|
|
163
168
|
ts,
|
|
164
169
|
compilerOptions: ctx.compilerOptions,
|
|
165
170
|
vueCompilerOptions: getResolvedOptions(),
|
|
166
|
-
sfc
|
|
171
|
+
sfc,
|
|
167
172
|
fileName,
|
|
168
173
|
lang: getLang(),
|
|
169
174
|
scriptRanges: getScriptRanges(),
|
package/lib/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { SFCParseResult } from '@vue/compiler-sfc';
|
|
|
8
8
|
export { VueEmbeddedCode };
|
|
9
9
|
export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | 'globalTypesPath' | 'plugins'>> & {
|
|
10
10
|
strictTemplates?: boolean;
|
|
11
|
-
target?: 'auto' |
|
|
11
|
+
target?: 'auto' | 3 | 3.3 | 3.5 | 3.6 | 99 | number;
|
|
12
12
|
globalTypesPath?: string;
|
|
13
13
|
plugins?: string[];
|
|
14
14
|
};
|
package/lib/utils/shared.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type * as ts from 'typescript';
|
|
|
3
3
|
import type { Sfc, TextRange } from '../types';
|
|
4
4
|
export { hyphenate as hyphenateTag } from '@vue/shared';
|
|
5
5
|
export declare function hyphenateAttr(str: string): string;
|
|
6
|
-
export declare function getSlotsPropertyName(vueVersion: number): "$scopedSlots" | "$slots";
|
|
7
6
|
export declare function getElementTagOffsets(node: CompilerDOM.ElementNode, template: NonNullable<Sfc['template']>): [number] | [number, number];
|
|
8
7
|
export declare function getStartEnd(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): TextRange;
|
|
9
8
|
export declare function getNodeText(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): string;
|
package/lib/utils/shared.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hyphenateTag = void 0;
|
|
4
4
|
exports.hyphenateAttr = hyphenateAttr;
|
|
5
|
-
exports.getSlotsPropertyName = getSlotsPropertyName;
|
|
6
5
|
exports.getElementTagOffsets = getElementTagOffsets;
|
|
7
6
|
exports.getStartEnd = getStartEnd;
|
|
8
7
|
exports.getNodeText = getNodeText;
|
|
@@ -17,9 +16,6 @@ function hyphenateAttr(str) {
|
|
|
17
16
|
}
|
|
18
17
|
return hyphencase;
|
|
19
18
|
}
|
|
20
|
-
function getSlotsPropertyName(vueVersion) {
|
|
21
|
-
return vueVersion < 3 ? '$scopedSlots' : '$slots';
|
|
22
|
-
}
|
|
23
19
|
function getElementTagOffsets(node, template) {
|
|
24
20
|
const tagOffsets = [
|
|
25
21
|
template.content.indexOf(node.tag, node.loc.start.offset),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { VirtualCode } from '@volar/language-core';
|
|
1
|
+
import type { CodeInformation, Mapping, VirtualCode } from '@volar/language-core';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { VueCompilerOptions, VueLanguagePluginReturn } from '../types';
|
|
4
|
+
import { computedSfc } from './computedSfc';
|
|
4
5
|
export declare class VueVirtualCode implements VirtualCode {
|
|
5
6
|
fileName: string;
|
|
6
7
|
languageId: string;
|
|
@@ -8,22 +9,16 @@ export declare class VueVirtualCode implements VirtualCode {
|
|
|
8
9
|
vueCompilerOptions: VueCompilerOptions;
|
|
9
10
|
plugins: VueLanguagePluginReturn[];
|
|
10
11
|
ts: typeof import('typescript');
|
|
11
|
-
id
|
|
12
|
+
readonly id = "main";
|
|
13
|
+
readonly sfc: ReturnType<typeof computedSfc>;
|
|
12
14
|
private _snapshot;
|
|
13
15
|
private _vueSfc;
|
|
14
|
-
private _sfc;
|
|
15
16
|
private _embeddedCodes;
|
|
16
17
|
private _mappings;
|
|
17
18
|
get snapshot(): ts.IScriptSnapshot;
|
|
18
19
|
get vueSfc(): import("@vue/compiler-sfc").SFCParseResult | undefined;
|
|
19
|
-
get sfc(): import("../types").Sfc;
|
|
20
20
|
get embeddedCodes(): VirtualCode[];
|
|
21
|
-
get mappings():
|
|
22
|
-
sourceOffsets: number[];
|
|
23
|
-
generatedOffsets: number[];
|
|
24
|
-
lengths: number[];
|
|
25
|
-
data: import("@volar/language-core").CodeInformation;
|
|
26
|
-
}[];
|
|
21
|
+
get mappings(): Mapping<CodeInformation>[];
|
|
27
22
|
constructor(fileName: string, languageId: string, initSnapshot: ts.IScriptSnapshot, vueCompilerOptions: VueCompilerOptions, plugins: VueLanguagePluginReturn[], ts: typeof import('typescript'));
|
|
28
23
|
update(newSnapshot: ts.IScriptSnapshot): void;
|
|
29
24
|
}
|
|
@@ -7,16 +7,12 @@ const computedEmbeddedCodes_1 = require("./computedEmbeddedCodes");
|
|
|
7
7
|
const computedSfc_1 = require("./computedSfc");
|
|
8
8
|
const computedVueSfc_1 = require("./computedVueSfc");
|
|
9
9
|
class VueVirtualCode {
|
|
10
|
-
// others
|
|
11
10
|
get snapshot() {
|
|
12
11
|
return this._snapshot();
|
|
13
12
|
}
|
|
14
13
|
get vueSfc() {
|
|
15
14
|
return this._vueSfc();
|
|
16
15
|
}
|
|
17
|
-
get sfc() {
|
|
18
|
-
return this._sfc;
|
|
19
|
-
}
|
|
20
16
|
get embeddedCodes() {
|
|
21
17
|
return this._embeddedCodes();
|
|
22
18
|
}
|
|
@@ -30,13 +26,11 @@ class VueVirtualCode {
|
|
|
30
26
|
this.vueCompilerOptions = vueCompilerOptions;
|
|
31
27
|
this.plugins = plugins;
|
|
32
28
|
this.ts = ts;
|
|
33
|
-
// sources
|
|
34
29
|
this.id = 'main';
|
|
35
|
-
this._snapshot = (0, alien_signals_1.signal)(
|
|
36
|
-
// computeds
|
|
30
|
+
this._snapshot = (0, alien_signals_1.signal)(initSnapshot);
|
|
37
31
|
this._vueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, this.languageId, this._snapshot);
|
|
38
|
-
this.
|
|
39
|
-
this._embeddedCodes = (0, computedEmbeddedCodes_1.computedEmbeddedCodes)(this.plugins, this.fileName, this.
|
|
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);
|
|
40
34
|
this._mappings = (0, alien_signals_1.computed)(() => {
|
|
41
35
|
const snapshot = this._snapshot();
|
|
42
36
|
return [{
|
|
@@ -46,7 +40,6 @@ class VueVirtualCode {
|
|
|
46
40
|
data: plugins_1.allCodeFeatures,
|
|
47
41
|
}];
|
|
48
42
|
});
|
|
49
|
-
this._snapshot(initSnapshot);
|
|
50
43
|
}
|
|
51
44
|
update(newSnapshot) {
|
|
52
45
|
this._snapshot(newSnapshot);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.1.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@volar/language-core": "2.4.23",
|
|
17
17
|
"@vue/compiler-dom": "^3.5.0",
|
|
18
|
-
"@vue/compiler-vue2": "^2.7.16",
|
|
19
18
|
"@vue/shared": "^3.5.0",
|
|
20
19
|
"alien-signals": "^2.0.5",
|
|
21
20
|
"muggle-string": "^0.4.1",
|
|
@@ -37,5 +36,5 @@
|
|
|
37
36
|
"optional": true
|
|
38
37
|
}
|
|
39
38
|
},
|
|
40
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "adcbd8b1a7bf432844230755de999d22b95dc160"
|
|
41
40
|
}
|
package/lib/utils/ts.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript';
|
|
2
|
-
import type { RawVueCompilerOptions, VueCompilerOptions, VueLanguagePlugin } from '../types';
|
|
3
|
-
interface ParseConfigHost extends Omit<ts.ParseConfigHost, 'readDirectory'> {
|
|
4
|
-
}
|
|
5
|
-
export interface ParsedCommandLine extends Omit<ts.ParsedCommandLine, 'fileNames'> {
|
|
6
|
-
vueOptions: VueCompilerOptions;
|
|
7
|
-
}
|
|
8
|
-
export declare function createParsedCommandLineByJson(ts: typeof import('typescript'), host: ParseConfigHost, rootDir: string, json: any, configFileName?: string): ParsedCommandLine;
|
|
9
|
-
export declare function createParsedCommandLine(ts: typeof import('typescript'), host: ParseConfigHost, configFileName: string): ParsedCommandLine;
|
|
10
|
-
export declare class CompilerOptionsResolver {
|
|
11
|
-
fileExists?: ((path: string) => boolean) | undefined;
|
|
12
|
-
configRoots: Set<string>;
|
|
13
|
-
options: Omit<RawVueCompilerOptions, 'target' | 'globalTypesPath' | 'plugins'>;
|
|
14
|
-
target: number | undefined;
|
|
15
|
-
globalTypesPath: string | undefined;
|
|
16
|
-
plugins: VueLanguagePlugin[];
|
|
17
|
-
constructor(fileExists?: ((path: string) => boolean) | undefined);
|
|
18
|
-
addConfig(options: RawVueCompilerOptions, rootDir: string): void;
|
|
19
|
-
build(defaults?: VueCompilerOptions): VueCompilerOptions;
|
|
20
|
-
private findNodeModulesRoot;
|
|
21
|
-
}
|
|
22
|
-
export declare function getDefaultCompilerOptions(target?: number, lib?: string, strictTemplates?: boolean): VueCompilerOptions;
|
|
23
|
-
export declare function writeGlobalTypes(vueOptions: VueCompilerOptions, writeFile: (fileName: string, data: string) => void): void;
|
|
24
|
-
export {};
|