@vue/language-core 3.2.6 → 3.2.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/index.d.ts +1 -1
- package/index.js +3 -24
- package/lib/codegen/codeFeatures.d.ts +84 -18
- package/lib/codegen/names.d.ts +73 -26
- package/lib/codegen/names.js +75 -27
- package/lib/codegen/script/component.js +19 -58
- package/lib/codegen/script/index.js +12 -12
- package/lib/codegen/script/scriptSetup.js +48 -81
- package/lib/codegen/script/template.js +29 -63
- package/lib/codegen/style/index.d.ts +7 -7
- package/lib/codegen/style/modules.js +4 -37
- package/lib/codegen/style/scopedClasses.js +2 -1
- package/lib/codegen/template/context.d.ts +7 -7
- package/lib/codegen/template/element.js +28 -25
- package/lib/codegen/template/elementDirectives.js +4 -4
- package/lib/codegen/template/elementEvents.js +3 -2
- package/lib/codegen/template/elementProps.js +3 -3
- package/lib/codegen/template/index.d.ts +7 -7
- package/lib/codegen/template/index.js +16 -49
- package/lib/codegen/template/interpolation.js +3 -36
- package/lib/codegen/template/objectProperty.js +2 -1
- package/lib/codegen/template/slotOutlet.js +5 -5
- package/lib/codegen/template/styleScopedClasses.js +3 -2
- package/lib/codegen/template/vFor.js +2 -1
- package/lib/codegen/template/vSlot.js +2 -1
- package/lib/compilerOptions.js +2 -6
- package/lib/parsers/scriptRanges.d.ts +3 -3
- package/lib/plugins/file-md.js +2 -2
- package/lib/plugins/vue-tsx.d.ts +10 -10
- package/lib/plugins/vue-tsx.js +5 -22
- package/lib/types.d.ts +1 -1
- package/lib/utils/shared.js +1 -1
- package/lib/virtualCode/embeddedCodes.js +2 -6
- package/lib/virtualCode/index.js +1 -10
- package/package.json +9 -6
- package/scripts/generate-names.js +41 -0
package/lib/plugins/vue-tsx.d.ts
CHANGED
|
@@ -6,13 +6,13 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
6
6
|
isObjectLiteral: boolean;
|
|
7
7
|
options?: {
|
|
8
8
|
isObjectLiteral: boolean;
|
|
9
|
-
expression: import("../types").TextRange
|
|
9
|
+
expression: import("../types").TextRange;
|
|
10
10
|
args: import("../types").TextRange<import("typescript").ObjectLiteralExpression>;
|
|
11
11
|
components: import("../types").TextRange<import("typescript").ObjectLiteralExpression> | undefined;
|
|
12
|
-
directives: import("../types").TextRange
|
|
12
|
+
directives: import("../types").TextRange | undefined;
|
|
13
13
|
name: import("../types").TextRange<import("typescript").StringLiteral> | undefined;
|
|
14
14
|
inheritAttrs: string | undefined;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
}) | undefined;
|
|
17
17
|
bindings: import("../types").TextRange<import("typescript").Node>[];
|
|
18
18
|
components: import("../types").TextRange<import("typescript").Node>[];
|
|
@@ -51,21 +51,21 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
51
51
|
getGeneratedTemplate: () => {
|
|
52
52
|
generatedTypes: Set<string>;
|
|
53
53
|
currentInfo: {
|
|
54
|
-
ignoreError?: boolean
|
|
54
|
+
ignoreError?: boolean;
|
|
55
55
|
expectError?: {
|
|
56
56
|
token: number;
|
|
57
57
|
node: import("@vue/compiler-dom").CommentNode;
|
|
58
|
-
}
|
|
58
|
+
};
|
|
59
59
|
generic?: {
|
|
60
60
|
content: string;
|
|
61
61
|
offset: number;
|
|
62
|
-
}
|
|
62
|
+
};
|
|
63
63
|
};
|
|
64
64
|
resolveCodeFeatures: (features: import("../types").VueCodeInformation) => import("../types").VueCodeInformation;
|
|
65
65
|
inVFor: boolean;
|
|
66
66
|
slots: {
|
|
67
67
|
name: string;
|
|
68
|
-
offset?: number
|
|
68
|
+
offset?: number;
|
|
69
69
|
tagRange: [number, number];
|
|
70
70
|
nodeLoc: any;
|
|
71
71
|
propsVar: string;
|
|
@@ -86,7 +86,7 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
86
86
|
singleRootElTypes: Set<string>;
|
|
87
87
|
singleRootNodes: Set<import("@vue/compiler-dom").ElementNode | null>;
|
|
88
88
|
addTemplateRef(name: string, typeExp: string, offset: number): void;
|
|
89
|
-
recordComponentAccess(source: string, name: string, offset?: number
|
|
89
|
+
recordComponentAccess(source: string, name: string, offset?: number): void;
|
|
90
90
|
scopes: Set<string>[];
|
|
91
91
|
components: (() => string)[];
|
|
92
92
|
declare(...varNames: string[]): void;
|
|
@@ -95,8 +95,8 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
95
95
|
getHoistVariable(originalVar: string): string;
|
|
96
96
|
generateHoistVariables(): Generator<string, void, unknown>;
|
|
97
97
|
generateConditionGuards(): Generator<string, void, unknown>;
|
|
98
|
-
enter(node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").
|
|
99
|
-
exit(): Generator<import("../types").Code
|
|
98
|
+
enter(node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").TemplateChildNode | import("@vue/compiler-dom").SimpleExpressionNode): boolean;
|
|
99
|
+
exit(): Generator<import("../types").Code>;
|
|
100
100
|
codes: import("../types").Code[];
|
|
101
101
|
} | undefined;
|
|
102
102
|
getImportedComponents: () => Set<string>;
|
package/lib/plugins/vue-tsx.js
CHANGED
|
@@ -206,28 +206,11 @@ function useCodegen(ts, vueCompilerOptions, fileName, sfc) {
|
|
|
206
206
|
if (!allVars.size) {
|
|
207
207
|
return allVars;
|
|
208
208
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
exposedNames.add(name);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
for (const [name] of generatedStyle?.componentAccessMap ?? []) {
|
|
218
|
-
if (allVars.has(name)) {
|
|
219
|
-
exposedNames.add(name);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
for (const component of sfc.template?.ast?.components ?? []) {
|
|
223
|
-
const testNames = new Set([(0, shared_1.camelize)(component), (0, shared_1.capitalize)((0, shared_1.camelize)(component))]);
|
|
224
|
-
for (const testName of testNames) {
|
|
225
|
-
if (allVars.has(testName)) {
|
|
226
|
-
exposedNames.add(testName);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return exposedNames;
|
|
209
|
+
return new Set([
|
|
210
|
+
...getGeneratedTemplate()?.componentAccessMap.keys() ?? [],
|
|
211
|
+
...getGeneratedStyle()?.componentAccessMap.keys() ?? [],
|
|
212
|
+
...sfc.template?.ast?.components.flatMap(name => [(0, shared_1.camelize)(name), (0, shared_1.capitalize)((0, shared_1.camelize)(name))]) ?? [],
|
|
213
|
+
].filter(name => allVars.has(name)));
|
|
231
214
|
});
|
|
232
215
|
const getGeneratedScript = (0, alien_signals_1.computed)(() => {
|
|
233
216
|
return (0, script_1.generateScript)({
|
package/lib/types.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export interface VueCompilerOptions {
|
|
|
69
69
|
}
|
|
70
70
|
export declare const validVersions: readonly [2, 2.1, 2.2];
|
|
71
71
|
export interface VueLanguagePluginReturn {
|
|
72
|
-
version: typeof validVersions[number];
|
|
72
|
+
version: (typeof validVersions)[number];
|
|
73
73
|
name?: string;
|
|
74
74
|
order?: number;
|
|
75
75
|
requiredCompilerOptions?: string[];
|
package/lib/utils/shared.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.getElementTagOffsets = getElementTagOffsets;
|
|
|
7
7
|
exports.getStartEnd = getStartEnd;
|
|
8
8
|
exports.getNodeText = getNodeText;
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
10
|
-
|
|
10
|
+
var shared_2 = require("@vue/shared");
|
|
11
11
|
Object.defineProperty(exports, "hyphenateTag", { enumerable: true, get: function () { return shared_2.hyphenate; } });
|
|
12
12
|
function hyphenateAttr(str) {
|
|
13
13
|
let hyphencase = (0, shared_1.hyphenate)(str);
|
|
@@ -6,16 +6,12 @@ const alien_signals_1 = require("alien-signals");
|
|
|
6
6
|
const muggle_string_1 = require("muggle-string");
|
|
7
7
|
const buildMappings_1 = require("../utils/buildMappings");
|
|
8
8
|
class VueEmbeddedCode {
|
|
9
|
-
id;
|
|
10
|
-
lang;
|
|
11
|
-
content;
|
|
12
|
-
parentCodeId;
|
|
13
|
-
linkedCodeMappings = [];
|
|
14
|
-
embeddedCodes = [];
|
|
15
9
|
constructor(id, lang, content) {
|
|
16
10
|
this.id = id;
|
|
17
11
|
this.lang = lang;
|
|
18
12
|
this.content = content;
|
|
13
|
+
this.linkedCodeMappings = [];
|
|
14
|
+
this.embeddedCodes = [];
|
|
19
15
|
}
|
|
20
16
|
}
|
|
21
17
|
exports.VueEmbeddedCode = VueEmbeddedCode;
|
package/lib/virtualCode/index.js
CHANGED
|
@@ -6,16 +6,6 @@ const plugins_1 = require("../plugins");
|
|
|
6
6
|
const embeddedCodes_1 = require("./embeddedCodes");
|
|
7
7
|
const ir_1 = require("./ir");
|
|
8
8
|
class VueVirtualCode {
|
|
9
|
-
fileName;
|
|
10
|
-
languageId;
|
|
11
|
-
initSnapshot;
|
|
12
|
-
vueCompilerOptions;
|
|
13
|
-
id = 'main';
|
|
14
|
-
_snapshot;
|
|
15
|
-
_parsedSfcResult;
|
|
16
|
-
_ir;
|
|
17
|
-
_embeddedCodes;
|
|
18
|
-
_mappings;
|
|
19
9
|
get snapshot() {
|
|
20
10
|
return this._snapshot();
|
|
21
11
|
}
|
|
@@ -36,6 +26,7 @@ class VueVirtualCode {
|
|
|
36
26
|
this.languageId = languageId;
|
|
37
27
|
this.initSnapshot = initSnapshot;
|
|
38
28
|
this.vueCompilerOptions = vueCompilerOptions;
|
|
29
|
+
this.id = 'main';
|
|
39
30
|
this._snapshot = (0, alien_signals_1.signal)(initSnapshot);
|
|
40
31
|
this._parsedSfcResult = (0, alien_signals_1.computed)(lastResult => this.parseSfc(plugins, lastResult));
|
|
41
32
|
this._ir = (0, ir_1.useIR)(ts, plugins, fileName, this._snapshot, () => this._parsedSfcResult()?.result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,21 +12,24 @@
|
|
|
12
12
|
"url": "https://github.com/vuejs/language-tools.git",
|
|
13
13
|
"directory": "packages/language-core"
|
|
14
14
|
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"generate-names": "node scripts/generate-names.js"
|
|
17
|
+
},
|
|
15
18
|
"dependencies": {
|
|
16
19
|
"@volar/language-core": "2.4.28",
|
|
17
20
|
"@vue/compiler-dom": "^3.5.0",
|
|
18
21
|
"@vue/shared": "^3.5.0",
|
|
19
|
-
"alien-signals": "^3.
|
|
22
|
+
"alien-signals": "^3.1.2",
|
|
20
23
|
"muggle-string": "^0.4.1",
|
|
21
24
|
"path-browserify": "^1.0.1",
|
|
22
|
-
"picomatch": "^4.0.
|
|
25
|
+
"picomatch": "^4.0.4"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@types/node": "^22.10.4",
|
|
26
|
-
"@types/path-browserify": "^1.0.
|
|
27
|
-
"@types/picomatch": "^4.0.
|
|
29
|
+
"@types/path-browserify": "^1.0.3",
|
|
30
|
+
"@types/picomatch": "^4.0.3",
|
|
28
31
|
"@volar/typescript": "2.4.28",
|
|
29
32
|
"@vue/compiler-sfc": "^3.5.0"
|
|
30
33
|
},
|
|
31
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "618bd6bfb19729726787df7b52fccda72c888c95"
|
|
32
35
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { readFile, writeFile } = require('node:fs/promises');
|
|
3
|
+
const { join } = require('node:path');
|
|
4
|
+
|
|
5
|
+
generateNames();
|
|
6
|
+
|
|
7
|
+
async function generateNames() {
|
|
8
|
+
const typePath = join(__dirname, '../types/template-helpers.d.ts');
|
|
9
|
+
const typeText = await readFile(typePath, 'utf-8');
|
|
10
|
+
|
|
11
|
+
/** @type {Set<string>} */
|
|
12
|
+
const pascalNames = new Set();
|
|
13
|
+
/** @type {Set<string>} */
|
|
14
|
+
const camelNames = new Set();
|
|
15
|
+
|
|
16
|
+
const declReg = /(?<=const\s+)\w*?(?=:)|(?<=type\s+)\w*?(?=\s*=|<)|(?<=function\s+)\w*?(?=\(|<)/g;
|
|
17
|
+
const prefix = '__VLS_';
|
|
18
|
+
|
|
19
|
+
for (const match of typeText.matchAll(declReg)) {
|
|
20
|
+
const name = match[0].slice(prefix.length);
|
|
21
|
+
if (name[0]?.toUpperCase() === name[0]) {
|
|
22
|
+
pascalNames.add(name);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
camelNames.add(name);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const namesPath = join(__dirname, '../lib/codegen/names.ts');
|
|
30
|
+
const namesText = await readFile(namesPath, 'utf-8');
|
|
31
|
+
|
|
32
|
+
await writeFile(
|
|
33
|
+
namesPath,
|
|
34
|
+
namesText.replace(
|
|
35
|
+
/(?<=\/\/ #region .*\n).*?(?=\t\/\/ #endregion)/ms,
|
|
36
|
+
[...camelNames].sort().map(name => `\t${name}: '',\n`).join('')
|
|
37
|
+
+ '\n'
|
|
38
|
+
+ [...pascalNames].sort().map(name => `\t${name}: '',\n`).join(''),
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
}
|